public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Tarang Raval <tarang.raval@siliconsignals.io>
To: sakari.ailus@linux.intel.com
Cc: mehdi.djait@linux.intel.com,
	Tarang Raval <tarang.raval@siliconsignals.io>,
	Himanshu Bhavani <himanshu.bhavani@siliconsignals.io>,
	Elgin Perumbilly <elgin.perumbilly@siliconsignals.io>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/13] media: i2c: os05b10: update pixel rate on 10/12-bit mode switch
Date: Fri,  6 Mar 2026 18:02:58 +0530	[thread overview]
Message-ID: <20260306123304.76722-9-tarang.raval@siliconsignals.io> (raw)
In-Reply-To: <20260306123304.76722-1-tarang.raval@siliconsignals.io>

After adding 12-bit RAW support, the pixel rate depends on the selected
mode bpp. Store the V4L2_CID_PIXEL_RATE control pointer and update its
range/value when the mode changes so 10/12-bit switching reports the
correct pixel rate.

Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
 drivers/media/i2c/os05b10.c | 41 ++++++++++++++++++++++++-------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index d51b7d18d28a..5ffc7aef0ed1 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -474,6 +474,7 @@ struct os05b10 {
 	/* V4L2 Controls */
 	struct v4l2_ctrl_handler handler;
 	struct v4l2_ctrl *link_freq;
+	struct v4l2_ctrl *pixel_rate;
 	struct v4l2_ctrl *hblank;
 	struct v4l2_ctrl *vblank;
 	struct v4l2_ctrl *gain;
@@ -680,12 +681,35 @@ static int os05b10_enum_mbus_code(struct v4l2_subdev *sd,
 	return 0;
 }
 
+static u64 os05b10_pixel_rate(struct os05b10 *os05b10,
+			      const struct os05b10_mode *mode)
+{
+	u64 link_freq = link_frequencies[os05b10->link_freq_index];
+	u64 pixel_rate = div_u64(link_freq * 2 * os05b10->data_lanes, mode->bpp);
+
+	dev_dbg(os05b10->dev,
+		"link_freq=%llu bpp=%u lanes=%u pixel_rate=%llu\n",
+		link_freq, mode->bpp, os05b10->data_lanes, pixel_rate);
+
+	return pixel_rate;
+}
+
 static int os05b10_set_framing_limits(struct os05b10 *os05b10,
 				      const struct os05b10_mode *mode)
 {
+	u64 pixel_rate = os05b10_pixel_rate(os05b10, mode);
 	u32 hblank, vblank, vblank_max, max_exp;
 	int ret;
 
+	ret = __v4l2_ctrl_modify_range(os05b10->pixel_rate, pixel_rate,
+				       pixel_rate, 1, pixel_rate);
+	if (ret)
+		return ret;
+
+	ret = __v4l2_ctrl_s_ctrl_int64(os05b10->pixel_rate, pixel_rate);
+	if (ret)
+		return ret;
+
 	hblank = mode->hts - mode->width;
 	ret = __v4l2_ctrl_modify_range(os05b10->hblank, hblank, hblank, 1,
 				       hblank);
@@ -1058,18 +1082,6 @@ static int os05b10_parse_endpoint(struct os05b10 *os05b10)
 	return ret;
 }
 
-static u64 os05b10_pixel_rate(struct os05b10 *os05b10,
-			      const struct os05b10_mode *mode)
-{
-	u64 link_freq = link_frequencies[os05b10->link_freq_index];
-	u64 pixel_rate = div_u64(link_freq * 2 * os05b10->data_lanes, mode->bpp);
-
-	dev_dbg(os05b10->dev,
-		"link_freq=%llu bpp=%u lanes=%u pixel_rate=%llu\n",
-		link_freq, mode->bpp, os05b10->data_lanes, pixel_rate);
-
-	return pixel_rate;
-}
 
 static int os05b10_init_controls(struct os05b10 *os05b10)
 {
@@ -1083,8 +1095,9 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
 	v4l2_ctrl_handler_init(ctrl_hdlr, 12);
 
 	pixel_rate = os05b10_pixel_rate(os05b10, mode);
-	v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_PIXEL_RATE,
-			  pixel_rate, pixel_rate, 1, pixel_rate);
+	os05b10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
+						V4L2_CID_PIXEL_RATE, pixel_rate,
+						pixel_rate, 1, pixel_rate);
 
 	os05b10->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
 						    V4L2_CID_LINK_FREQ,
-- 
2.34.1


  parent reply	other threads:[~2026-03-06 12:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 12:32 [PATCH 00/13] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
2026-03-06 12:32 ` [PATCH 01/13] media: i2c: os05b10: drop unused group-hold programming Tarang Raval
2026-03-06 12:32 ` [PATCH 02/13] media: i2c: os05b10: add register definitions and use them in init table Tarang Raval
2026-03-06 12:32 ` [PATCH 03/13] media: i2c: os05b10: split common and mode-specific init registers Tarang Raval
2026-03-06 12:32 ` [PATCH 04/13] media: i2c: os05b10: add V4L2 digital gain control Tarang Raval
2026-03-06 12:32 ` [PATCH 05/13] media: i2c: os05b10: Add H/V flip support Tarang Raval
2026-03-06 12:32 ` [PATCH 06/13] media: i2c: os05b10: Add test pattern options Tarang Raval
2026-03-06 12:32 ` [PATCH 07/13] media: i2c: os05b10: add 12-bit RAW mode support Tarang Raval
2026-03-06 12:32 ` Tarang Raval [this message]
2026-03-06 12:32 ` [PATCH 09/13] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes Tarang Raval
2026-03-06 12:33 ` [PATCH 10/13] media: i2c: os05b10: keep vblank/exposure in sync on mode switch Tarang Raval
2026-03-06 13:35   ` Sakari Ailus
2026-03-07  5:28     ` Tarang Raval
2026-03-06 12:33 ` [PATCH 11/13] media: i2c: os05b10: Update active format before adjusting framing controls Tarang Raval
2026-03-06 13:36   ` Sakari Ailus
2026-03-07  5:22     ` Tarang Raval
2026-03-09  8:19       ` Tarang Raval
2026-03-24 16:31   ` Tarang Raval
2026-03-25  8:56     ` sakari.ailus
2026-03-25  9:05       ` Tarang Raval
2026-03-06 12:33 ` [PATCH 12/13] media: i2c: os05b10: Rename vmax variable in VBLANK control Tarang Raval
2026-03-06 12:33 ` [PATCH 13/13] media: i2c: os05b10: add 2-lane support Tarang Raval
2026-03-07  1:56   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260306123304.76722-9-tarang.raval@siliconsignals.io \
    --to=tarang.raval@siliconsignals.io \
    --cc=elgin.perumbilly@siliconsignals.io \
    --cc=himanshu.bhavani@siliconsignals.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mehdi.djait@linux.intel.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox