* [PATCH v5 01/15] media: i2c: os05b10: drop unused group-hold programming
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 02/15] media: i2c: os05b10: Rename vmax variable in VBLANK control Tarang Raval
` (13 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Mehdi Djait, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Vladimir Zapolskiy,
linux-media, linux-kernel
Register table included group-hold (0x3208) sequences for
groups 6/7/8/9 that only stage alternative tuning values in SRAM but are
never launched by the driver. Remove these group-hold blocks.
Also remove a duplicate register entry for 0x37bf.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/os05b10.c | 37 -------------------------------------
1 file changed, 37 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index a46cfa513e98..d5f573b1614a 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -250,7 +250,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x37ab), 0x0e },
{ CCI_REG8(0x37ac), 0xa0 },
{ CCI_REG8(0x37be), 0x0a },
- { CCI_REG8(0x37bf), 0x05 },
{ CCI_REG8(0x37bb), 0x02 },
{ CCI_REG8(0x37bf), 0x05 },
{ CCI_REG8(0x37c2), 0x04 },
@@ -415,42 +414,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x5820), 0x00 },
{ CCI_REG8(0x5821), 0x00 },
{ CCI_REG8(0x3222), 0x03 },
- { CCI_REG8(0x3208), 0x06 },
- { CCI_REG8(0x3701), 0x1d },
- { CCI_REG8(0x37ab), 0x01 },
- { CCI_REG8(0x3790), 0x21 },
- { CCI_REG8(0x38be), 0x00 },
- { CCI_REG8(0x3791), 0x5a },
- { CCI_REG8(0x37bf), 0x1c },
- { CCI_REG8(0x3610), 0x37 },
- { CCI_REG8(0x3208), 0x16 },
- { CCI_REG8(0x3208), 0x07 },
- { CCI_REG8(0x3701), 0x1d },
- { CCI_REG8(0x37ab), 0x0e },
- { CCI_REG8(0x3790), 0x21 },
- { CCI_REG8(0x38be), 0x00 },
- { CCI_REG8(0x3791), 0x5a },
- { CCI_REG8(0x37bf), 0x0a },
- { CCI_REG8(0x3610), 0x87 },
- { CCI_REG8(0x3208), 0x17 },
- { CCI_REG8(0x3208), 0x08 },
- { CCI_REG8(0x3701), 0x1d },
- { CCI_REG8(0x37ab), 0x0e },
- { CCI_REG8(0x3790), 0x21 },
- { CCI_REG8(0x38be), 0x00 },
- { CCI_REG8(0x3791), 0x5a },
- { CCI_REG8(0x37bf), 0x0a },
- { CCI_REG8(0x3610), 0x87 },
- { CCI_REG8(0x3208), 0x18 },
- { CCI_REG8(0x3208), 0x09 },
- { CCI_REG8(0x3701), 0x1d },
- { CCI_REG8(0x37ab), 0x0e },
- { CCI_REG8(0x3790), 0x28 },
- { CCI_REG8(0x38be), 0x00 },
- { CCI_REG8(0x3791), 0x63 },
- { CCI_REG8(0x37bf), 0x0a },
- { CCI_REG8(0x3610), 0x87 },
- { CCI_REG8(0x3208), 0x19 },
};
struct os05b10 {
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 02/15] media: i2c: os05b10: Rename vmax variable in VBLANK control
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
2026-10-30 10:47 ` [PATCH v5 01/15] media: i2c: os05b10: drop unused group-hold programming Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 03/15] media: i2c: os05b10: Update active format before adjusting framing controls Tarang Raval
` (12 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Vladimir Zapolskiy, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel
The VBLANK control programs the sensor VTS register. Rename the local
variable from vmax to vts to match the register meaning and improve
readability.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index d5f573b1614a..46246d297a44 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -477,7 +477,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
struct os05b10, handler);
struct v4l2_subdev_state *state;
struct v4l2_mbus_framefmt *fmt;
- int vmax, ret;
+ int vts, ret;
state = v4l2_subdev_get_locked_active_state(&os05b10->sd);
fmt = v4l2_subdev_state_get_format(state, 0);
@@ -499,8 +499,8 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
switch (ctrl->id) {
case V4L2_CID_VBLANK:
- vmax = fmt->height + ctrl->val;
- ret = cci_write(os05b10->cci, OS05B10_REG_VTS, vmax, NULL);
+ vts = fmt->height + ctrl->val;
+ ret = cci_write(os05b10->cci, OS05B10_REG_VTS, vts, NULL);
break;
case V4L2_CID_ANALOGUE_GAIN:
ret = cci_write(os05b10->cci, OS05B10_REG_ANALOG_GAIN,
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 03/15] media: i2c: os05b10: Update active format before adjusting framing controls
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
2026-10-30 10:47 ` [PATCH v5 01/15] media: i2c: os05b10: drop unused group-hold programming Tarang Raval
2026-10-30 10:47 ` [PATCH v5 02/15] media: i2c: os05b10: Rename vmax variable in VBLANK control Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 04/15] media: i2c: os05b10: Enable runtime PM autosuspend Tarang Raval
` (11 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Vladimir Zapolskiy, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Hans Verkuil,
Mehdi Djait, linux-media, linux-kernel
os05b10_set_pad_format() calls os05b10_set_framing_limits() before updating
the ACTIVE format. As a result, the VBLANK control handler uses the old
height when recalculating exposure limits, causing -ERANGE when switching
to a larger resolution.
Update the ACTIVE format before adjusting framing controls so control
callbacks use the correct dimensions.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 46246d297a44..70ad9124ad41 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -576,14 +576,14 @@ static int os05b10_set_pad_format(struct v4l2_subdev *sd,
format = v4l2_subdev_state_get_format(sd_state, 0);
+ *format = fmt->format;
+
if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
ret = os05b10_set_framing_limits(os05b10, mode);
if (ret)
return ret;
}
- *format = fmt->format;
-
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 04/15] media: i2c: os05b10: Enable runtime PM autosuspend
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (2 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 03/15] media: i2c: os05b10: Update active format before adjusting framing controls Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 05/15] media: i2c: os05b10: add register definitions and use them in init table Tarang Raval
` (10 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Hans Verkuil, Mehdi Djait, linux-media,
linux-kernel
Use pm_runtime_put_autosuspend() instead of pm_runtime_put()
to allow autosuspend. Set a 1000ms autosuspend delay.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 70ad9124ad41..7f6cb4c7edc8 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -654,7 +654,7 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
return 0;
err_rpm_put:
- pm_runtime_put(os05b10->dev);
+ pm_runtime_put_autosuspend(os05b10->dev);
return ret;
}
@@ -671,7 +671,7 @@ static int os05b10_disable_streams(struct v4l2_subdev *sd,
if (ret)
dev_err(os05b10->dev, "failed to set stream off\n");
- pm_runtime_put(os05b10->dev);
+ pm_runtime_put_autosuspend(os05b10->dev);
return 0;
}
@@ -1029,6 +1029,8 @@ static int os05b10_probe(struct i2c_client *client)
goto error_subdev_cleanup;
}
+ pm_runtime_set_autosuspend_delay(os05b10->dev, 1000);
+ pm_runtime_use_autosuspend(os05b10->dev);
pm_runtime_idle(os05b10->dev);
return 0;
@@ -1037,6 +1039,7 @@ static int os05b10_probe(struct i2c_client *client)
v4l2_subdev_cleanup(&os05b10->sd);
pm_runtime_disable(os05b10->dev);
pm_runtime_set_suspended(os05b10->dev);
+ pm_runtime_dont_use_autosuspend(os05b10->dev);
error_media_entity:
media_entity_cleanup(&os05b10->sd.entity);
@@ -1064,6 +1067,7 @@ static void os05b10_remove(struct i2c_client *client)
if (!pm_runtime_status_suspended(&client->dev)) {
os05b10_power_off(&client->dev);
pm_runtime_set_suspended(&client->dev);
+ pm_runtime_dont_use_autosuspend(&client->dev);
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 05/15] media: i2c: os05b10: add register definitions and use them in init table
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (3 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 04/15] media: i2c: os05b10: Enable runtime PM autosuspend Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 06/15] media: i2c: os05b10: split common and mode-specific init registers Tarang Raval
` (9 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Mehdi Djait, Vladimir Zapolskiy,
Himanshu Bhavani, Elgin Perumbilly, Mauro Carvalho Chehab,
Hans Verkuil, linux-media, linux-kernel
Define named register macros for OS05B10 and replace raw register
addresses in the common initialization array with the new definitions.
This improves readability and maintainability without changing
functionality.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 108 ++++++++++++++++++++++--------------
1 file changed, 67 insertions(+), 41 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 7f6cb4c7edc8..3f478bad1fbc 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -38,6 +38,16 @@
#define OS05B10_MODE_STANDBY 0x00
#define OS05B10_MODE_STREAMING 0x01
+#define OS05B10_REG_PLL_CTRL(n) CCI_REG8(0x0300 + (n))
+
+#define OS05B10_REG_MIPI_SC_CTRL CCI_REG8(0x3016)
+#define OS05B10_4_LANE_MODE 0x72
+#define OS05B10_2_LANE_MODE 0x32
+
+#define OS05B10_REG_MIPI_SC_CTRL_1 CCI_REG8(0x3022)
+#define OS05B10_10BIT_MODE 0x01
+#define OS05B10_12BIT_MODE 0x61
+
#define OS05B10_REG_EXPOSURE CCI_REG24(0x3500)
#define OS05B10_EXPOSURE_MIN 2
#define OS05B10_EXPOSURE_STEP 1
@@ -47,13 +57,43 @@
#define OS05B10_ANALOG_GAIN_MIN 0x80
#define OS05B10_ANALOG_GAIN_MAX 0x7C0
#define OS05B10_ANALOG_GAIN_STEP 1
-#define OS05B10_ANALOG_GAIN_DEFAULT 0x80
+#define OS05B10_ANALOG_GAIN_DEFAULT OS05B10_ANALOG_GAIN_MIN
+
+#define OS05B10_REG_DIGITAL_GAIN CCI_REG16(0x350a)
+#define OS05B10_DIGITAL_GAIN_MIN 0x400
+#define OS05B10_DIGITAL_GAIN_MAX 0x3fff
+#define OS05B10_DIGITAL_GAIN_STEP 1
+#define OS05B10_DIGITAL_GAIN_DEFAULT OS05B10_DIGITAL_GAIN_MIN
+
+#define OS05B10_REG_ANALOG_GAIN_SHORT CCI_REG16(0x350c)
+#define OS05B10_REG_DIGITAL_GAIN_SHORT CCI_REG16(0x350e)
+#define OS05B10_REG_EXPOSURE_SHORT CCI_REG24(0x3510)
+
+#define OS05B10_REG_X_ADDR_START CCI_REG16(0x3800)
+#define OS05B10_REG_Y_ADDR_START CCI_REG16(0x3802)
+#define OS05B10_REG_X_ADDR_END CCI_REG16(0x3804)
+#define OS05B10_REG_Y_ADDR_END CCI_REG16(0x3806)
+#define OS05B10_REG_X_OUTPUT_SIZE CCI_REG16(0x3808)
+#define OS05B10_REG_Y_OUTPUT_SIZE CCI_REG16(0x380a)
#define OS05B10_REG_HTS CCI_REG16(0x380c)
#define OS05B10_REG_VTS CCI_REG16(0x380e)
#define OS05B10_VTS_MAX 0x7fff
+#define OS05B10_REG_ISP_X_WIN CCI_REG16(0x3810)
+#define OS05B10_REG_ISP_Y_WIN CCI_REG16(0x3812)
+#define OS05B10_REG_X_INC_ODD CCI_REG8(0x3814)
+#define OS05B10_REG_X_INC_EVEN CCI_REG8(0x3815)
+#define OS05B10_REG_Y_INC_ODD CCI_REG8(0x3816)
+#define OS05B10_REG_Y_INC_EVEN CCI_REG8(0x3817)
+
+#define OS05B10_REG_FORMAT1 CCI_REG8(0x3820)
+#define OS05B10_MIRROR BIT(3)
+#define OS05B10_FLIP GENMASK(5, 4)
+
+#define OS05B10_REG_FORMAT2 CCI_REG8(0x3821)
+
#define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
static const struct v4l2_rect os05b10_native_area = {
@@ -77,30 +117,25 @@ static const char * const os05b10_supply_name[] = {
};
static const struct cci_reg_sequence os05b10_common_regs[] = {
- { CCI_REG8(0x0301), 0x44 },
- { CCI_REG8(0x0303), 0x02 },
- { CCI_REG8(0x0305), 0x32 },
- { CCI_REG8(0x0306), 0x00 },
- { CCI_REG8(0x0325), 0x3b },
+ { OS05B10_REG_PLL_CTRL(0x01), 0x44 },
+ { OS05B10_REG_PLL_CTRL(0x03), 0x02 },
+ { OS05B10_REG_PLL_CTRL(0x05), 0x32 },
+ { OS05B10_REG_PLL_CTRL(0x06), 0x00 },
+ { OS05B10_REG_PLL_CTRL(0x25), 0x3b },
{ CCI_REG8(0x3002), 0x21 },
- { CCI_REG8(0x3016), 0x72 },
+ { OS05B10_REG_MIPI_SC_CTRL, OS05B10_4_LANE_MODE },
{ CCI_REG8(0x301e), 0xb4 },
{ CCI_REG8(0x301f), 0xd0 },
{ CCI_REG8(0x3021), 0x03 },
- { CCI_REG8(0x3022), 0x01 },
+ { OS05B10_REG_MIPI_SC_CTRL_1, OS05B10_10BIT_MODE },
{ CCI_REG8(0x3107), 0xa1 },
{ CCI_REG8(0x3108), 0x7d },
{ CCI_REG8(0x3109), 0xfc },
{ CCI_REG8(0x3503), 0x88 },
- { CCI_REG8(0x350a), 0x04 },
- { CCI_REG8(0x350b), 0x00 },
- { CCI_REG8(0x350c), 0x00 },
- { CCI_REG8(0x350d), 0x80 },
- { CCI_REG8(0x350e), 0x04 },
- { CCI_REG8(0x350f), 0x00 },
- { CCI_REG8(0x3510), 0x00 },
- { CCI_REG8(0x3511), 0x00 },
- { CCI_REG8(0x3512), 0x20 },
+ { OS05B10_REG_DIGITAL_GAIN, OS05B10_DIGITAL_GAIN_DEFAULT },
+ { OS05B10_REG_ANALOG_GAIN_SHORT, 0x0080 },
+ { OS05B10_REG_DIGITAL_GAIN_SHORT, 0x0400 },
+ { OS05B10_REG_EXPOSURE_SHORT, 0x000020 },
{ CCI_REG8(0x3600), 0x4d },
{ CCI_REG8(0x3601), 0x08 },
{ CCI_REG8(0x3610), 0x87 },
@@ -274,34 +309,25 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x37f5), 0x00 },
{ CCI_REG8(0x37f6), 0x00 },
{ CCI_REG8(0x37f7), 0x00 },
- { CCI_REG8(0x3800), 0x01 },
- { CCI_REG8(0x3801), 0x30 },
- { CCI_REG8(0x3802), 0x00 },
- { CCI_REG8(0x3803), 0x00 },
- { CCI_REG8(0x3804), 0x0b },
- { CCI_REG8(0x3805), 0x5f },
- { CCI_REG8(0x3806), 0x07 },
- { CCI_REG8(0x3807), 0xa7 },
- { CCI_REG8(0x3808), 0x0a },
- { CCI_REG8(0x3809), 0x20 },
- { CCI_REG8(0x380a), 0x07 },
- { CCI_REG8(0x380b), 0x98 },
- { CCI_REG8(0x380c), 0x06 },
- { CCI_REG8(0x380d), 0xd0 },
- { CCI_REG8(0x3810), 0x00 },
- { CCI_REG8(0x3811), 0x08 },
- { CCI_REG8(0x3812), 0x00 },
- { CCI_REG8(0x3813), 0x08 },
- { CCI_REG8(0x3814), 0x01 },
- { CCI_REG8(0x3815), 0x01 },
- { CCI_REG8(0x3816), 0x01 },
- { CCI_REG8(0x3817), 0x01 },
+ { OS05B10_REG_X_ADDR_START, 0x0130 },
+ { OS05B10_REG_Y_ADDR_START, 0x0000 },
+ { OS05B10_REG_X_ADDR_END, 0x0b5f },
+ { OS05B10_REG_Y_ADDR_END, 0x07a7 },
+ { OS05B10_REG_X_OUTPUT_SIZE, 0x0a20 },
+ { OS05B10_REG_Y_OUTPUT_SIZE, 0x0798 },
+ { OS05B10_REG_HTS, 0x06d0 },
+ { OS05B10_REG_ISP_X_WIN, 0x0008 },
+ { OS05B10_REG_ISP_Y_WIN, 0x0008 },
+ { OS05B10_REG_X_INC_ODD, 0x01 },
+ { OS05B10_REG_X_INC_EVEN, 0x01 },
+ { OS05B10_REG_Y_INC_ODD, 0x01 },
+ { OS05B10_REG_Y_INC_EVEN, 0x01 },
{ CCI_REG8(0x3818), 0x00 },
{ CCI_REG8(0x3819), 0x00 },
{ CCI_REG8(0x381a), 0x00 },
{ CCI_REG8(0x381b), 0x01 },
- { CCI_REG8(0x3820), 0x88 },
- { CCI_REG8(0x3821), 0x00 },
+ { OS05B10_REG_FORMAT1, 0x88 },
+ { OS05B10_REG_FORMAT2, 0x00 },
{ CCI_REG8(0x3822), 0x12 },
{ CCI_REG8(0x3823), 0x08 },
{ CCI_REG8(0x3824), 0x00 },
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 06/15] media: i2c: os05b10: split common and mode-specific init registers
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (4 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 05/15] media: i2c: os05b10: add register definitions and use them in init table Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling Tarang Raval
` (8 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Mehdi Djait, Vladimir Zapolskiy,
Himanshu Bhavani, Elgin Perumbilly, Mauro Carvalho Chehab,
Hans Verkuil, linux-media, linux-kernel
Separate common initialization registers from mode-specific settings.
Move resolution-dependent registers into a per-mode register list and
program them during stream enable.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 96 ++++++++++++++++++++++++-------------
1 file changed, 63 insertions(+), 33 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 3f478bad1fbc..46d514d2a479 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -138,16 +138,13 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ OS05B10_REG_EXPOSURE_SHORT, 0x000020 },
{ CCI_REG8(0x3600), 0x4d },
{ CCI_REG8(0x3601), 0x08 },
- { CCI_REG8(0x3610), 0x87 },
{ CCI_REG8(0x3611), 0x24 },
{ CCI_REG8(0x3614), 0x4c },
- { CCI_REG8(0x3620), 0x0c },
{ CCI_REG8(0x3632), 0x80 },
{ CCI_REG8(0x3633), 0x00 },
{ CCI_REG8(0x3636), 0xcc },
{ CCI_REG8(0x3637), 0x27 },
{ CCI_REG8(0x3660), 0x00 },
- { CCI_REG8(0x3662), 0x10 },
{ CCI_REG8(0x3665), 0x00 },
{ CCI_REG8(0x3666), 0x00 },
{ CCI_REG8(0x366a), 0x14 },
@@ -231,7 +228,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x370f), 0x1c },
{ CCI_REG8(0x3710), 0x00 },
{ CCI_REG8(0x3713), 0x00 },
- { CCI_REG8(0x3714), 0x24 },
{ CCI_REG8(0x3716), 0x24 },
{ CCI_REG8(0x371a), 0x1e },
{ CCI_REG8(0x3724), 0x09 },
@@ -240,7 +236,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x3730), 0xe1 },
{ CCI_REG8(0x3735), 0x80 },
{ CCI_REG8(0x3739), 0x10 },
- { CCI_REG8(0x373f), 0xb0 },
{ CCI_REG8(0x3740), 0x28 },
{ CCI_REG8(0x3741), 0x21 },
{ CCI_REG8(0x3742), 0x21 },
@@ -286,8 +281,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x37ac), 0xa0 },
{ CCI_REG8(0x37be), 0x0a },
{ CCI_REG8(0x37bb), 0x02 },
- { CCI_REG8(0x37bf), 0x05 },
- { CCI_REG8(0x37c2), 0x04 },
{ CCI_REG8(0x37c4), 0x11 },
{ CCI_REG8(0x37c5), 0x80 },
{ CCI_REG8(0x37c6), 0x14 },
@@ -296,7 +289,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x37cd), 0x17 },
{ CCI_REG8(0x37ce), 0x01 },
{ CCI_REG8(0x37d8), 0x02 },
- { CCI_REG8(0x37d9), 0x08 },
{ CCI_REG8(0x37dc), 0x01 },
{ CCI_REG8(0x37e0), 0x0c },
{ CCI_REG8(0x37e1), 0x20 },
@@ -309,25 +301,10 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x37f5), 0x00 },
{ CCI_REG8(0x37f6), 0x00 },
{ CCI_REG8(0x37f7), 0x00 },
- { OS05B10_REG_X_ADDR_START, 0x0130 },
- { OS05B10_REG_Y_ADDR_START, 0x0000 },
- { OS05B10_REG_X_ADDR_END, 0x0b5f },
- { OS05B10_REG_Y_ADDR_END, 0x07a7 },
- { OS05B10_REG_X_OUTPUT_SIZE, 0x0a20 },
- { OS05B10_REG_Y_OUTPUT_SIZE, 0x0798 },
- { OS05B10_REG_HTS, 0x06d0 },
- { OS05B10_REG_ISP_X_WIN, 0x0008 },
- { OS05B10_REG_ISP_Y_WIN, 0x0008 },
- { OS05B10_REG_X_INC_ODD, 0x01 },
- { OS05B10_REG_X_INC_EVEN, 0x01 },
- { OS05B10_REG_Y_INC_ODD, 0x01 },
- { OS05B10_REG_Y_INC_EVEN, 0x01 },
{ CCI_REG8(0x3818), 0x00 },
{ CCI_REG8(0x3819), 0x00 },
{ CCI_REG8(0x381a), 0x00 },
{ CCI_REG8(0x381b), 0x01 },
- { OS05B10_REG_FORMAT1, 0x88 },
- { OS05B10_REG_FORMAT2, 0x00 },
{ CCI_REG8(0x3822), 0x12 },
{ CCI_REG8(0x3823), 0x08 },
{ CCI_REG8(0x3824), 0x00 },
@@ -337,7 +314,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x3829), 0x03 },
{ CCI_REG8(0x382a), 0x00 },
{ CCI_REG8(0x382b), 0x00 },
- { CCI_REG8(0x3832), 0x08 },
{ CCI_REG8(0x3838), 0x00 },
{ CCI_REG8(0x3839), 0x00 },
{ CCI_REG8(0x383a), 0x00 },
@@ -358,26 +334,19 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x38a7), 0x04 },
{ CCI_REG8(0x38b8), 0x02 },
{ CCI_REG8(0x3c80), 0x3e },
- { CCI_REG8(0x3c86), 0x01 },
{ CCI_REG8(0x3c87), 0x02 },
{ CCI_REG8(0x389c), 0x00 },
{ CCI_REG8(0x3ca2), 0x0c },
{ CCI_REG8(0x3d85), 0x1b },
- { CCI_REG8(0x3d8c), 0x01 },
{ CCI_REG8(0x3d8d), 0xe2 },
{ CCI_REG8(0x3f00), 0xcb },
- { CCI_REG8(0x3f03), 0x08 },
{ CCI_REG8(0x3f9e), 0x07 },
{ CCI_REG8(0x3f9f), 0x04 },
{ CCI_REG8(0x4000), 0xf3 },
{ CCI_REG8(0x4002), 0x00 },
{ CCI_REG8(0x4003), 0x40 },
- { CCI_REG8(0x4008), 0x02 },
- { CCI_REG8(0x4009), 0x0d },
- { CCI_REG8(0x400a), 0x01 },
{ CCI_REG8(0x400b), 0x00 },
{ CCI_REG8(0x4040), 0x00 },
- { CCI_REG8(0x4041), 0x07 },
{ CCI_REG8(0x4090), 0x14 },
{ CCI_REG8(0x40b0), 0x01 },
{ CCI_REG8(0x40b1), 0x01 },
@@ -397,7 +366,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x4305), 0x83 },
{ CCI_REG8(0x4306), 0x21 },
{ CCI_REG8(0x430d), 0x00 },
- { CCI_REG8(0x4505), 0xc4 },
{ CCI_REG8(0x4506), 0x00 },
{ CCI_REG8(0x4507), 0x60 },
{ CCI_REG8(0x4803), 0x00 },
@@ -409,7 +377,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x481f), 0x30 },
{ CCI_REG8(0x4825), 0x34 },
{ CCI_REG8(0x4829), 0x64 },
- { CCI_REG8(0x4837), 0x12 },
{ CCI_REG8(0x484b), 0x07 },
{ CCI_REG8(0x4883), 0x36 },
{ CCI_REG8(0x4885), 0x03 },
@@ -442,6 +409,42 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x3222), 0x03 },
};
+static const struct cci_reg_sequence mode_2592_1944_regs[] = {
+ { OS05B10_REG_X_ADDR_START, 0x0130 },
+ { OS05B10_REG_Y_ADDR_START, 0x0000 },
+ { OS05B10_REG_X_ADDR_END, 0x0b5f },
+ { OS05B10_REG_Y_ADDR_END, 0x07a7 },
+ { OS05B10_REG_X_OUTPUT_SIZE, 0x0a20 },
+ { OS05B10_REG_Y_OUTPUT_SIZE, 0x0798 },
+ { OS05B10_REG_HTS, 0x06d0 },
+ { OS05B10_REG_ISP_X_WIN, 0x0008 },
+ { OS05B10_REG_ISP_Y_WIN, 0x0008 },
+ { OS05B10_REG_X_INC_ODD, 0x01 },
+ { OS05B10_REG_X_INC_EVEN, 0x01 },
+ { OS05B10_REG_Y_INC_ODD, 0x01 },
+ { OS05B10_REG_Y_INC_EVEN, 0x01 },
+ { OS05B10_REG_FORMAT1, 0x88 },
+ { OS05B10_REG_FORMAT2, 0x00 },
+ { CCI_REG8(0x3610), 0x87 },
+ { CCI_REG8(0x3620), 0x0c },
+ { CCI_REG8(0x3662), 0x10 },
+ { CCI_REG8(0x3714), 0x24 },
+ { CCI_REG8(0x373f), 0xb0 },
+ { CCI_REG8(0x37bf), 0x05 },
+ { CCI_REG8(0x37c2), 0x04 },
+ { CCI_REG8(0x37d9), 0x08 },
+ { CCI_REG8(0x3832), 0x08 },
+ { CCI_REG8(0x3c86), 0x01 },
+ { CCI_REG8(0x3d8c), 0x01 },
+ { CCI_REG8(0x3f03), 0x08 },
+ { CCI_REG8(0x4008), 0x02 },
+ { CCI_REG8(0x4009), 0x0d },
+ { CCI_REG8(0x400a), 0x01 },
+ { CCI_REG8(0x4041), 0x07 },
+ { CCI_REG8(0x4505), 0xc4 },
+ { CCI_REG8(0x4837), 0x12 },
+};
+
struct os05b10 {
struct device *dev;
struct regmap *cci;
@@ -464,6 +467,11 @@ struct os05b10 {
u32 data_lanes;
};
+struct os05b10_reg_list {
+ u32 num_of_regs;
+ const struct cci_reg_sequence *regs;
+};
+
struct os05b10_mode {
u32 width;
u32 height;
@@ -471,6 +479,7 @@ struct os05b10_mode {
u32 hts;
u32 exp;
u8 bpp;
+ struct os05b10_reg_list reg_list;
};
static const struct os05b10_mode supported_modes_10bit[] = {
@@ -481,6 +490,10 @@ static const struct os05b10_mode supported_modes_10bit[] = {
.hts = 1744,
.exp = 1944,
.bpp = 10,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_2592_1944_regs),
+ .regs = mode_2592_1944_regs,
+ },
},
};
@@ -652,8 +665,16 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
u32 pad, u64 streams_mask)
{
struct os05b10 *os05b10 = to_os05b10(sd);
+ const struct os05b10_reg_list *reg_list;
+ const struct v4l2_mbus_framefmt *fmt;
+ const struct os05b10_mode *mode;
int ret;
+ fmt = v4l2_subdev_state_get_format(state, 0);
+ mode = v4l2_find_nearest_size(supported_modes_10bit,
+ ARRAY_SIZE(supported_modes_10bit), width,
+ height, fmt->width, fmt->height);
+
ret = pm_runtime_resume_and_get(os05b10->dev);
if (ret < 0)
return ret;
@@ -666,6 +687,15 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
goto err_rpm_put;
}
+ /* Write sensor mode registers */
+ reg_list = &mode->reg_list;
+ ret = cci_multi_reg_write(os05b10->cci, reg_list->regs,
+ reg_list->num_of_regs, NULL);
+ if (ret) {
+ dev_err(os05b10->dev, "fail to write initial registers\n");
+ goto err_rpm_put;
+ }
+
/* Apply customized user controls */
ret = __v4l2_ctrl_handler_setup(os05b10->sd.ctrl_handler);
if (ret)
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (5 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 06/15] media: i2c: os05b10: split common and mode-specific init registers Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 11:15 ` Sakari Ailus
2026-10-30 10:47 ` [PATCH v5 08/15] media: i2c: os05b10: add V4L2 digital gain control Tarang Raval
` (7 subsequent siblings)
14 siblings, 1 reply; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Vladimir Zapolskiy, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Hans Verkuil,
Mehdi Djait, linux-media, linux-kernel
link_freq and gain don't need to be stored in struct os05b10; make
them local.
Parse the fwnode properties up front and register them before the
single ctrl_hdlr->error check, so all controls are covered by one
check and the per-control NULL guards before setting flags can be
dropped.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 46 +++++++++++++++----------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 46d514d2a479..abcb7c766754 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -457,10 +457,8 @@ struct os05b10 {
/* V4L2 Controls */
struct v4l2_ctrl_handler handler;
- struct v4l2_ctrl *link_freq;
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
- struct v4l2_ctrl *gain;
struct v4l2_ctrl *exposure;
u32 link_freq_index;
@@ -920,8 +918,13 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
u64 hblank_def, vblank_def, exp_max, pixel_rate;
struct v4l2_fwnode_device_properties props;
struct v4l2_ctrl_handler *ctrl_hdlr;
+ struct v4l2_ctrl *link_freq;
int ret;
+ ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
+ if (ret)
+ return ret;
+
ctrl_hdlr = &os05b10->handler;
v4l2_ctrl_handler_init(ctrl_hdlr, 8);
@@ -929,21 +932,16 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
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,
- ARRAY_SIZE(link_frequencies) - 1,
- os05b10->link_freq_index,
- link_frequencies);
-
- if (os05b10->link_freq)
- os05b10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
+ V4L2_CID_LINK_FREQ,
+ ARRAY_SIZE(link_frequencies) - 1,
+ os05b10->link_freq_index,
+ link_frequencies);
hblank_def = mode->hts - mode->width;
os05b10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK,
hblank_def, hblank_def,
1, hblank_def);
- if (os05b10->hblank)
- os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
vblank_def = mode->vts - mode->height;
os05b10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
@@ -958,27 +956,19 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
exp_max, OS05B10_EXPOSURE_STEP,
mode->exp);
- os05b10->gain = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
- V4L2_CID_ANALOGUE_GAIN,
- OS05B10_ANALOG_GAIN_MIN,
- OS05B10_ANALOG_GAIN_MAX,
- OS05B10_ANALOG_GAIN_STEP,
- OS05B10_ANALOG_GAIN_DEFAULT);
+ v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
+ OS05B10_ANALOG_GAIN_MIN, OS05B10_ANALOG_GAIN_MAX,
+ OS05B10_ANALOG_GAIN_STEP, OS05B10_ANALOG_GAIN_DEFAULT);
- if (ctrl_hdlr->error) {
- ret = ctrl_hdlr->error;
+ ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
+ &props);
+ if (ret) {
dev_err(os05b10->dev, "control init failed (%d)\n", ret);
goto error;
}
- ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
- if (ret)
- goto error;
-
- ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
- &props);
- if (ret)
- goto error;
+ link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
os05b10->sd.ctrl_handler = ctrl_hdlr;
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling
2026-10-30 10:47 ` [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling Tarang Raval
@ 2026-10-30 11:15 ` Sakari Ailus
0 siblings, 0 replies; 19+ messages in thread
From: Sakari Ailus @ 2026-10-30 11:15 UTC (permalink / raw)
To: Tarang Raval
Cc: jai.luthra, Vladimir Zapolskiy, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Hans Verkuil,
Mehdi Djait, linux-media, linux-kernel
Hi Tarang,
On Fri, Oct 30, 2026 at 04:17:56PM +0530, Tarang Raval wrote:
> link_freq and gain don't need to be stored in struct os05b10; make
> them local.
>
> Parse the fwnode properties up front and register them before the
> single ctrl_hdlr->error check, so all controls are covered by one
> check and the per-control NULL guards before setting flags can be
> dropped.
>
> Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
> Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
> ---
> drivers/media/i2c/os05b10.c | 46 +++++++++++++++----------------------
> 1 file changed, 18 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 46d514d2a479..abcb7c766754 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -457,10 +457,8 @@ struct os05b10 {
>
> /* V4L2 Controls */
> struct v4l2_ctrl_handler handler;
> - struct v4l2_ctrl *link_freq;
> struct v4l2_ctrl *hblank;
> struct v4l2_ctrl *vblank;
> - struct v4l2_ctrl *gain;
> struct v4l2_ctrl *exposure;
>
> u32 link_freq_index;
> @@ -920,8 +918,13 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> u64 hblank_def, vblank_def, exp_max, pixel_rate;
> struct v4l2_fwnode_device_properties props;
> struct v4l2_ctrl_handler *ctrl_hdlr;
> + struct v4l2_ctrl *link_freq;
> int ret;
>
> + ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
> + if (ret)
> + return ret;
> +
> ctrl_hdlr = &os05b10->handler;
> v4l2_ctrl_handler_init(ctrl_hdlr, 8);
>
> @@ -929,21 +932,16 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> 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,
> - ARRAY_SIZE(link_frequencies) - 1,
> - os05b10->link_freq_index,
> - link_frequencies);
> -
> - if (os05b10->link_freq)
> - os05b10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> + link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
> + V4L2_CID_LINK_FREQ,
> + ARRAY_SIZE(link_frequencies) - 1,
> + os05b10->link_freq_index,
> + link_frequencies);
>
> hblank_def = mode->hts - mode->width;
> os05b10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK,
> hblank_def, hblank_def,
> 1, hblank_def);
> - if (os05b10->hblank)
> - os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>
> vblank_def = mode->vts - mode->height;
> os05b10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> @@ -958,27 +956,19 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> exp_max, OS05B10_EXPOSURE_STEP,
> mode->exp);
>
> - os05b10->gain = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> - V4L2_CID_ANALOGUE_GAIN,
> - OS05B10_ANALOG_GAIN_MIN,
> - OS05B10_ANALOG_GAIN_MAX,
> - OS05B10_ANALOG_GAIN_STEP,
> - OS05B10_ANALOG_GAIN_DEFAULT);
> + v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
> + OS05B10_ANALOG_GAIN_MIN, OS05B10_ANALOG_GAIN_MAX,
> + OS05B10_ANALOG_GAIN_STEP, OS05B10_ANALOG_GAIN_DEFAULT);
>
> - if (ctrl_hdlr->error) {
> - ret = ctrl_hdlr->error;
> + ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> + &props);
> + if (ret) {
> dev_err(os05b10->dev, "control init failed (%d)\n", ret);
> goto error;
If you're left with a single goto (hopefully that's the case), you can just
handle the error here (and avoid the goto).
> }
>
> - ret = v4l2_fwnode_device_parse(os05b10->dev, &props);
> - if (ret)
> - goto error;
> -
> - ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> - &props);
> - if (ret)
> - goto error;
> + link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> + os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
>
> os05b10->sd.ctrl_handler = ctrl_hdlr;
>
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v5 08/15] media: i2c: os05b10: add V4L2 digital gain control
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (6 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 07/15] media: i2c: os05b10: remove unused control fields, simplify error handling Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:47 ` [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support Tarang Raval
` (6 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Mehdi Djait, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Vladimir Zapolskiy,
Hans Verkuil, linux-media, linux-kernel
Stop programming digital gain in the common register sequence and expose it as
a V4L2_CID_DIGITAL_GAIN control. Initialize the new control and handle writes
in the ctrl callback.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/os05b10.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index abcb7c766754..14046f1c9324 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -132,7 +132,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x3108), 0x7d },
{ CCI_REG8(0x3109), 0xfc },
{ CCI_REG8(0x3503), 0x88 },
- { OS05B10_REG_DIGITAL_GAIN, OS05B10_DIGITAL_GAIN_DEFAULT },
{ OS05B10_REG_ANALOG_GAIN_SHORT, 0x0080 },
{ OS05B10_REG_DIGITAL_GAIN_SHORT, 0x0400 },
{ OS05B10_REG_EXPOSURE_SHORT, 0x000020 },
@@ -543,6 +542,10 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
ret = cci_write(os05b10->cci, OS05B10_REG_ANALOG_GAIN,
ctrl->val, NULL);
break;
+ case V4L2_CID_DIGITAL_GAIN:
+ ret = cci_write(os05b10->cci, OS05B10_REG_DIGITAL_GAIN,
+ ctrl->val, NULL);
+ break;
case V4L2_CID_EXPOSURE:
ret = cci_write(os05b10->cci, OS05B10_REG_EXPOSURE,
ctrl->val, NULL);
@@ -926,7 +929,7 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
return ret;
ctrl_hdlr = &os05b10->handler;
- v4l2_ctrl_handler_init(ctrl_hdlr, 8);
+ v4l2_ctrl_handler_init(ctrl_hdlr, 9);
pixel_rate = os05b10_pixel_rate(os05b10, mode);
v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_PIXEL_RATE,
@@ -960,6 +963,10 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
OS05B10_ANALOG_GAIN_MIN, OS05B10_ANALOG_GAIN_MAX,
OS05B10_ANALOG_GAIN_STEP, OS05B10_ANALOG_GAIN_DEFAULT);
+ v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
+ OS05B10_DIGITAL_GAIN_MIN, OS05B10_DIGITAL_GAIN_MAX,
+ OS05B10_DIGITAL_GAIN_STEP, OS05B10_DIGITAL_GAIN_DEFAULT);
+
ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
&props);
if (ret) {
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (7 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 08/15] media: i2c: os05b10: add V4L2 digital gain control Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-11-02 12:33 ` Sakari Ailus
2026-10-30 10:47 ` [PATCH v5 10/15] media: i2c: os05b10: Add test pattern options Tarang Raval
` (5 subsequent siblings)
14 siblings, 1 reply; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Mehdi Djait, Vladimir Zapolskiy,
Hans Verkuil, linux-media, linux-kernel
Add HFLIP and VFLIP controls, lock them while streaming, and update
the reported Bayer format based on the flip state.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 59 ++++++++++++++++++++++++++++++++++---
1 file changed, 55 insertions(+), 4 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 14046f1c9324..4b87ef60a2a7 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -92,6 +92,10 @@
#define OS05B10_MIRROR BIT(3)
#define OS05B10_FLIP GENMASK(5, 4)
+#define OS05B10_REG_ANALOG_FLIP CCI_REG8(0x3716)
+#define OS05B10_FLIP_ENABLE 0x04
+#define OS05B10_FLIP_DISABLE 0x24
+
#define OS05B10_REG_FORMAT2 CCI_REG8(0x3821)
#define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
@@ -227,7 +231,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x370f), 0x1c },
{ CCI_REG8(0x3710), 0x00 },
{ CCI_REG8(0x3713), 0x00 },
- { CCI_REG8(0x3716), 0x24 },
{ CCI_REG8(0x371a), 0x1e },
{ CCI_REG8(0x3724), 0x09 },
{ CCI_REG8(0x3725), 0xb2 },
@@ -459,6 +462,8 @@ struct os05b10 {
struct v4l2_ctrl *hblank;
struct v4l2_ctrl *vblank;
struct v4l2_ctrl *exposure;
+ struct v4l2_ctrl *vflip;
+ struct v4l2_ctrl *hflip;
u32 link_freq_index;
u32 data_lanes;
@@ -507,6 +512,16 @@ static inline struct os05b10 *to_os05b10(struct v4l2_subdev *sd)
return container_of_const(sd, struct os05b10, sd);
};
+static u32 os05b10_get_format_code(struct os05b10 *os05b10)
+{
+ static const u32 codes[2][2] = {
+ { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10, },
+ { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10, },
+ };
+
+ return codes[os05b10->vflip->val][os05b10->hflip->val];
+}
+
static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct os05b10 *os05b10 = container_of_const(ctrl->handler,
@@ -550,6 +565,25 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
ret = cci_write(os05b10->cci, OS05B10_REG_EXPOSURE,
ctrl->val, NULL);
break;
+ case V4L2_CID_HFLIP:
+ case V4L2_CID_VFLIP:
+ ret = 0;
+ cci_update_bits(os05b10->cci, OS05B10_REG_FORMAT1,
+ OS05B10_MIRROR | OS05B10_FLIP,
+ (!os05b10->hflip->val ?
+ OS05B10_MIRROR : 0) |
+ (os05b10->vflip->val ?
+ OS05B10_FLIP : 0), &ret);
+
+ cci_write(os05b10->cci, OS05B10_REG_ANALOG_FLIP,
+ (os05b10->vflip->val == 1) ?
+ OS05B10_FLIP_ENABLE : OS05B10_FLIP_DISABLE,
+ &ret);
+ if (ret)
+ break;
+
+ fmt->code = os05b10_get_format_code(os05b10);
+ break;
default:
ret = -EINVAL;
break;
@@ -564,10 +598,12 @@ static int os05b10_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
+ struct os05b10 *os05b10 = to_os05b10(sd);
+
if (code->index >= ARRAY_SIZE(os05b10_mbus_codes))
return -EINVAL;
- code->code = os05b10_mbus_codes[code->index];
+ code->code = os05b10_get_format_code(os05b10);
return 0;
}
@@ -708,6 +744,9 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
if (ret)
goto err_rpm_put;
+ __v4l2_ctrl_grab(os05b10->vflip, true);
+ __v4l2_ctrl_grab(os05b10->hflip, true);
+
return 0;
err_rpm_put:
@@ -728,6 +767,9 @@ static int os05b10_disable_streams(struct v4l2_subdev *sd,
if (ret)
dev_err(os05b10->dev, "failed to set stream off\n");
+ __v4l2_ctrl_grab(os05b10->vflip, false);
+ __v4l2_ctrl_grab(os05b10->hflip, false);
+
pm_runtime_put_autosuspend(os05b10->dev);
return 0;
@@ -736,6 +778,7 @@ static int os05b10_disable_streams(struct v4l2_subdev *sd,
static int os05b10_init_state(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state)
{
+ struct os05b10 *os05b10 = to_os05b10(sd);
struct v4l2_mbus_framefmt *format;
const struct os05b10_mode *mode;
@@ -743,7 +786,7 @@ static int os05b10_init_state(struct v4l2_subdev *sd,
format = v4l2_subdev_state_get_format(state, 0);
mode = &supported_modes_10bit[0];
- format->code = MEDIA_BUS_FMT_SBGGR10_1X10;
+ format->code = os05b10_get_format_code(os05b10);
/* Update image pad formate */
format->width = mode->width;
@@ -929,7 +972,7 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
return ret;
ctrl_hdlr = &os05b10->handler;
- v4l2_ctrl_handler_init(ctrl_hdlr, 9);
+ v4l2_ctrl_handler_init(ctrl_hdlr, 11);
pixel_rate = os05b10_pixel_rate(os05b10, mode);
v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_PIXEL_RATE,
@@ -967,6 +1010,12 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
OS05B10_DIGITAL_GAIN_MIN, OS05B10_DIGITAL_GAIN_MAX,
OS05B10_DIGITAL_GAIN_STEP, OS05B10_DIGITAL_GAIN_DEFAULT);
+ os05b10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
+ V4L2_CID_HFLIP, 0, 1, 1, 0);
+
+ os05b10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
+ V4L2_CID_VFLIP, 0, 1, 1, 0);
+
ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
&props);
if (ret) {
@@ -976,6 +1025,8 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
+ os05b10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
+ os05b10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
os05b10->sd.ctrl_handler = ctrl_hdlr;
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support
2026-10-30 10:47 ` [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support Tarang Raval
@ 2026-11-02 12:33 ` Sakari Ailus
0 siblings, 0 replies; 19+ messages in thread
From: Sakari Ailus @ 2026-11-02 12:33 UTC (permalink / raw)
To: Tarang Raval
Cc: jai.luthra, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Mehdi Djait, Vladimir Zapolskiy,
Hans Verkuil, linux-media, linux-kernel
Hi Tarang,
On Fri, Oct 30, 2026 at 04:17:58PM +0530, Tarang Raval wrote:
> Add HFLIP and VFLIP controls, lock them while streaming, and update
> the reported Bayer format based on the flip state.
>
> Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
> ---
> drivers/media/i2c/os05b10.c | 59 ++++++++++++++++++++++++++++++++++---
> 1 file changed, 55 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
> index 14046f1c9324..4b87ef60a2a7 100644
> --- a/drivers/media/i2c/os05b10.c
> +++ b/drivers/media/i2c/os05b10.c
> @@ -92,6 +92,10 @@
> #define OS05B10_MIRROR BIT(3)
> #define OS05B10_FLIP GENMASK(5, 4)
>
> +#define OS05B10_REG_ANALOG_FLIP CCI_REG8(0x3716)
> +#define OS05B10_FLIP_ENABLE 0x04
> +#define OS05B10_FLIP_DISABLE 0x24
I'd use the register name as prefix here, omitting "_REG".
0x4 has nothing to do with flip configuration, so I'd just use another
macro for that, e.g. OS05B10_ANALOG_FLIP_MAGIC, unless we know more about
that bit.
> +
> #define OS05B10_REG_FORMAT2 CCI_REG8(0x3821)
>
> #define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
> @@ -227,7 +231,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
> { CCI_REG8(0x370f), 0x1c },
> { CCI_REG8(0x3710), 0x00 },
> { CCI_REG8(0x3713), 0x00 },
> - { CCI_REG8(0x3716), 0x24 },
> { CCI_REG8(0x371a), 0x1e },
> { CCI_REG8(0x3724), 0x09 },
> { CCI_REG8(0x3725), 0xb2 },
> @@ -459,6 +462,8 @@ struct os05b10 {
> struct v4l2_ctrl *hblank;
> struct v4l2_ctrl *vblank;
> struct v4l2_ctrl *exposure;
> + struct v4l2_ctrl *vflip;
> + struct v4l2_ctrl *hflip;
>
> u32 link_freq_index;
> u32 data_lanes;
> @@ -507,6 +512,16 @@ static inline struct os05b10 *to_os05b10(struct v4l2_subdev *sd)
> return container_of_const(sd, struct os05b10, sd);
> };
>
> +static u32 os05b10_get_format_code(struct os05b10 *os05b10)
> +{
> + static const u32 codes[2][2] = {
> + { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10, },
> + { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10, },
> + };
> +
> + return codes[os05b10->vflip->val][os05b10->hflip->val];
Note that accessing the control values requires holding the handler's mutex
here. That's not the case when called from enum_mbus_code() I think.
> +}
> +
> static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
> {
> struct os05b10 *os05b10 = container_of_const(ctrl->handler,
> @@ -550,6 +565,25 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
> ret = cci_write(os05b10->cci, OS05B10_REG_EXPOSURE,
> ctrl->val, NULL);
> break;
> + case V4L2_CID_HFLIP:
> + case V4L2_CID_VFLIP:
> + ret = 0;
> + cci_update_bits(os05b10->cci, OS05B10_REG_FORMAT1,
> + OS05B10_MIRROR | OS05B10_FLIP,
> + (!os05b10->hflip->val ?
> + OS05B10_MIRROR : 0) |
> + (os05b10->vflip->val ?
> + OS05B10_FLIP : 0), &ret);
> +
> + cci_write(os05b10->cci, OS05B10_REG_ANALOG_FLIP,
> + (os05b10->vflip->val == 1) ?
> + OS05B10_FLIP_ENABLE : OS05B10_FLIP_DISABLE,
> + &ret);
Indentation. The last line can also be unwrapped.
> + if (ret)
> + break;
> +
> + fmt->code = os05b10_get_format_code(os05b10);
> + break;
> default:
> ret = -EINVAL;
> break;
> @@ -564,10 +598,12 @@ static int os05b10_enum_mbus_code(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *sd_state,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> + struct os05b10 *os05b10 = to_os05b10(sd);
> +
> if (code->index >= ARRAY_SIZE(os05b10_mbus_codes))
> return -EINVAL;
>
> - code->code = os05b10_mbus_codes[code->index];
> + code->code = os05b10_get_format_code(os05b10);
If this is the case, then any non-zero value of code->index should yield
-EINVAL.
>
> return 0;
> }
> @@ -708,6 +744,9 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
> if (ret)
> goto err_rpm_put;
>
> + __v4l2_ctrl_grab(os05b10->vflip, true);
> + __v4l2_ctrl_grab(os05b10->hflip, true);
> +
> return 0;
>
> err_rpm_put:
> @@ -728,6 +767,9 @@ static int os05b10_disable_streams(struct v4l2_subdev *sd,
> if (ret)
> dev_err(os05b10->dev, "failed to set stream off\n");
>
> + __v4l2_ctrl_grab(os05b10->vflip, false);
> + __v4l2_ctrl_grab(os05b10->hflip, false);
> +
> pm_runtime_put_autosuspend(os05b10->dev);
>
> return 0;
> @@ -736,6 +778,7 @@ static int os05b10_disable_streams(struct v4l2_subdev *sd,
> static int os05b10_init_state(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *state)
> {
> + struct os05b10 *os05b10 = to_os05b10(sd);
> struct v4l2_mbus_framefmt *format;
> const struct os05b10_mode *mode;
>
> @@ -743,7 +786,7 @@ static int os05b10_init_state(struct v4l2_subdev *sd,
> format = v4l2_subdev_state_get_format(state, 0);
>
> mode = &supported_modes_10bit[0];
> - format->code = MEDIA_BUS_FMT_SBGGR10_1X10;
> + format->code = os05b10_get_format_code(os05b10);
>
> /* Update image pad formate */
> format->width = mode->width;
> @@ -929,7 +972,7 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> return ret;
>
> ctrl_hdlr = &os05b10->handler;
> - v4l2_ctrl_handler_init(ctrl_hdlr, 9);
> + v4l2_ctrl_handler_init(ctrl_hdlr, 11);
>
> pixel_rate = os05b10_pixel_rate(os05b10, mode);
> v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops, V4L2_CID_PIXEL_RATE,
> @@ -967,6 +1010,12 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
> OS05B10_DIGITAL_GAIN_MIN, OS05B10_DIGITAL_GAIN_MAX,
> OS05B10_DIGITAL_GAIN_STEP, OS05B10_DIGITAL_GAIN_DEFAULT);
>
> + os05b10->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> + V4L2_CID_HFLIP, 0, 1, 1, 0);
> +
> + os05b10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
> + V4L2_CID_VFLIP, 0, 1, 1, 0);
> +
> ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
> &props);
> if (ret) {
> @@ -976,6 +1025,8 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
>
> link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> os05b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
> + os05b10->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
> + os05b10->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
>
> os05b10->sd.ctrl_handler = ctrl_hdlr;
>
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v5 10/15] media: i2c: os05b10: Add test pattern options
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (8 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 09/15] media: i2c: os05b10: Add H/V flip support Tarang Raval
@ 2026-10-30 10:47 ` Tarang Raval
2026-10-30 10:48 ` [PATCH v5 11/15] media: i2c: os05b10: add 12-bit RAW mode support Tarang Raval
` (4 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:47 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Mehdi Djait, Vladimir Zapolskiy,
Himanshu Bhavani, Elgin Perumbilly, Mauro Carvalho Chehab,
Hans Verkuil, linux-media, linux-kernel
Add V4L2_CID_TEST_PATTERN support with multiple sensor test-pattern modes
and program them via register 0x5080. Drop the fixed 0x5080 setting from
the common register sequence so the pattern is selected only through the
control.
Removing the default write of 0x04 to register 0x5080 does not change the
sensor's default behaviour. The value 0x04 leaves the test pattern enable
bit (bit 7) cleared, so the sensor remains in normal streaming mode. It
only programs the color bar style field, which is ignored unless a test
pattern is enabled.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 55 +++++++++++++++++++++++++++++++++++--
1 file changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 4b87ef60a2a7..48c905165954 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -98,6 +98,17 @@
#define OS05B10_REG_FORMAT2 CCI_REG8(0x3821)
+#define OS05B10_REG_PRE_ISP_20_0 CCI_REG8(0x5080)
+#define OS05B10_DISABLED 0x00
+#define OS05B10_COLOR_BAR_1 0x80
+#define OS05B10_COLOR_BAR_2 0x84
+#define OS05B10_COLOR_BAR_3 0x88
+#define OS05B10_COLOR_BAR_4 0x8c
+#define OS05B10_COLOR_SQUARE 0x82
+#define OS05B10_BW_SQUARE 0x92
+#define OS05B10_TRANSPARENT_EFFECT 0xa0
+#define OS05B10_ROLLING_BAR_EFFECT 0xc0
+
#define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
static const struct v4l2_rect os05b10_native_area = {
@@ -391,7 +402,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x5004), 0x00 },
{ CCI_REG8(0x5005), 0x0e },
{ CCI_REG8(0x5036), 0x00 },
- { CCI_REG8(0x5080), 0x04 },
{ CCI_REG8(0x5082), 0x00 },
{ CCI_REG8(0x5180), 0x00 },
{ CCI_REG8(0x5181), 0x10 },
@@ -507,6 +517,30 @@ static const u32 os05b10_mbus_codes[] = {
MEDIA_BUS_FMT_SBGGR10_1X10,
};
+static const char * const os05b10_test_pattern_menu[] = {
+ "Disabled",
+ "Color bar type 1",
+ "Color bar type 2",
+ "Color bar type 3",
+ "Color bar type 4",
+ "Color square",
+ "Black-white square",
+ "Transparent effect",
+ "Rolling bar effect",
+};
+
+static const int os05b10_tp_val[] = {
+ OS05B10_DISABLED,
+ OS05B10_COLOR_BAR_1,
+ OS05B10_COLOR_BAR_2,
+ OS05B10_COLOR_BAR_3,
+ OS05B10_COLOR_BAR_4,
+ OS05B10_COLOR_SQUARE,
+ OS05B10_BW_SQUARE,
+ OS05B10_TRANSPARENT_EFFECT,
+ OS05B10_ROLLING_BAR_EFFECT,
+};
+
static inline struct os05b10 *to_os05b10(struct v4l2_subdev *sd)
{
return container_of_const(sd, struct os05b10, sd);
@@ -522,6 +556,15 @@ static u32 os05b10_get_format_code(struct os05b10 *os05b10)
return codes[os05b10->vflip->val][os05b10->hflip->val];
}
+static int os05b10_update_test_pattern(struct os05b10 *os05b10, u32 pattern)
+{
+ if (pattern >= ARRAY_SIZE(os05b10_test_pattern_menu))
+ return -EINVAL;
+
+ return cci_write(os05b10->cci, OS05B10_REG_PRE_ISP_20_0,
+ os05b10_tp_val[pattern], NULL);
+}
+
static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct os05b10 *os05b10 = container_of_const(ctrl->handler,
@@ -584,6 +627,9 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
fmt->code = os05b10_get_format_code(os05b10);
break;
+ case V4L2_CID_TEST_PATTERN:
+ ret = os05b10_update_test_pattern(os05b10, ctrl->val);
+ break;
default:
ret = -EINVAL;
break;
@@ -972,7 +1018,7 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
return ret;
ctrl_hdlr = &os05b10->handler;
- v4l2_ctrl_handler_init(ctrl_hdlr, 11);
+ 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,
@@ -1016,6 +1062,11 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
os05b10->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
V4L2_CID_VFLIP, 0, 1, 1, 0);
+ v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &os05b10_ctrl_ops,
+ V4L2_CID_TEST_PATTERN,
+ ARRAY_SIZE(os05b10_test_pattern_menu) - 1,
+ 0, 0, os05b10_test_pattern_menu);
+
ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &os05b10_ctrl_ops,
&props);
if (ret) {
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 11/15] media: i2c: os05b10: add 12-bit RAW mode support
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (9 preceding siblings ...)
2026-10-30 10:47 ` [PATCH v5 10/15] media: i2c: os05b10: Add test pattern options Tarang Raval
@ 2026-10-30 10:48 ` Tarang Raval
2026-10-30 10:48 ` [PATCH v5 12/15] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes Tarang Raval
` (3 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:48 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Mehdi Djait, Hans Verkuil,
Vladimir Zapolskiy, linux-media, linux-kernel
Expose a 12-bit Bayer output option in the OS05B10 V4L2 sub-device driver.
Add a 12-bit mode table alongside the existing 10-bit mode, extend the
enumerated mbus codes to include RAW12, and select the correct mode table
based on the requested mbus format in enum_frame_size and stream enable.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 126 +++++++++++++++++++++++++++++++-----
1 file changed, 110 insertions(+), 16 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 48c905165954..ba6a22ced3db 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -142,7 +142,6 @@ static const struct cci_reg_sequence os05b10_common_regs[] = {
{ CCI_REG8(0x301e), 0xb4 },
{ CCI_REG8(0x301f), 0xd0 },
{ CCI_REG8(0x3021), 0x03 },
- { OS05B10_REG_MIPI_SC_CTRL_1, OS05B10_10BIT_MODE },
{ CCI_REG8(0x3107), 0xa1 },
{ CCI_REG8(0x3108), 0x7d },
{ CCI_REG8(0x3109), 0xfc },
@@ -494,6 +493,21 @@ struct os05b10_mode {
struct os05b10_reg_list reg_list;
};
+static const struct os05b10_mode supported_modes_12bit[] = {
+ {
+ .width = 2592,
+ .height = 1944,
+ .vts = 2007,
+ .hts = 1744,
+ .exp = 1900,
+ .bpp = 12,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_2592_1944_regs),
+ .regs = mode_2592_1944_regs,
+ },
+ },
+};
+
static const struct os05b10_mode supported_modes_10bit[] = {
{
.width = 2592,
@@ -515,6 +529,7 @@ static const s64 link_frequencies[] = {
static const u32 os05b10_mbus_codes[] = {
MEDIA_BUS_FMT_SBGGR10_1X10,
+ MEDIA_BUS_FMT_SBGGR12_1X12,
};
static const char * const os05b10_test_pattern_menu[] = {
@@ -546,14 +561,33 @@ static inline struct os05b10 *to_os05b10(struct v4l2_subdev *sd)
return container_of_const(sd, struct os05b10, sd);
};
-static u32 os05b10_get_format_code(struct os05b10 *os05b10)
+static u32 os05b10_get_format_code(struct os05b10 *os05b10, u32 code)
{
- static const u32 codes[2][2] = {
- { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10, },
- { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10, },
+ static const u32 codes[2][2][2] = {
+ { /* 10 bpp */
+ { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SGBRG10_1X10 },
+ { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SRGGB10_1X10 },
+ },
+ { /* 12 bpp */
+ { MEDIA_BUS_FMT_SBGGR12_1X12, MEDIA_BUS_FMT_SGBRG12_1X12 },
+ { MEDIA_BUS_FMT_SGRBG12_1X12, MEDIA_BUS_FMT_SRGGB12_1X12 },
+ },
};
+ unsigned int is_12bit;
+
+ switch (code) {
+ case MEDIA_BUS_FMT_SBGGR12_1X12:
+ case MEDIA_BUS_FMT_SGBRG12_1X12:
+ case MEDIA_BUS_FMT_SGRBG12_1X12:
+ case MEDIA_BUS_FMT_SRGGB12_1X12:
+ is_12bit = 1;
+ break;
+ default:
+ is_12bit = 0;
+ break;
+ }
- return codes[os05b10->vflip->val][os05b10->hflip->val];
+ return codes[is_12bit][os05b10->vflip->val][os05b10->hflip->val];
}
static int os05b10_update_test_pattern(struct os05b10 *os05b10, u32 pattern)
@@ -565,6 +599,34 @@ static int os05b10_update_test_pattern(struct os05b10 *os05b10, u32 pattern)
os05b10_tp_val[pattern], NULL);
}
+static int get_mode_table(struct os05b10 *os05b10, unsigned int code,
+ const struct os05b10_mode **mode_list,
+ unsigned int *num_modes)
+{
+ switch (code) {
+ case MEDIA_BUS_FMT_SBGGR12_1X12:
+ case MEDIA_BUS_FMT_SGBRG12_1X12:
+ case MEDIA_BUS_FMT_SGRBG12_1X12:
+ case MEDIA_BUS_FMT_SRGGB12_1X12:
+ *mode_list = supported_modes_12bit;
+ *num_modes = ARRAY_SIZE(supported_modes_12bit);
+ return 0;
+
+ case MEDIA_BUS_FMT_SBGGR10_1X10:
+ case MEDIA_BUS_FMT_SGBRG10_1X10:
+ case MEDIA_BUS_FMT_SGRBG10_1X10:
+ case MEDIA_BUS_FMT_SRGGB10_1X10:
+ *mode_list = supported_modes_10bit;
+ *num_modes = ARRAY_SIZE(supported_modes_10bit);
+ return 0;
+
+ default:
+ dev_err(os05b10->dev,
+ "Unsupported media bus format: %#x\n", code);
+ return -EINVAL;
+ }
+}
+
static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct os05b10 *os05b10 = container_of_const(ctrl->handler,
@@ -625,7 +687,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
if (ret)
break;
- fmt->code = os05b10_get_format_code(os05b10);
+ fmt->code = os05b10_get_format_code(os05b10, fmt->code);
break;
case V4L2_CID_TEST_PATTERN:
ret = os05b10_update_test_pattern(os05b10, ctrl->val);
@@ -649,7 +711,8 @@ static int os05b10_enum_mbus_code(struct v4l2_subdev *sd,
if (code->index >= ARRAY_SIZE(os05b10_mbus_codes))
return -EINVAL;
- code->code = os05b10_get_format_code(os05b10);
+ code->code = os05b10_get_format_code(os05b10,
+ os05b10_mbus_codes[code->index]);
return 0;
}
@@ -684,11 +747,20 @@ static int os05b10_set_pad_format(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
- const struct os05b10_mode *mode = &supported_modes_10bit[0];
struct os05b10 *os05b10 = to_os05b10(sd);
+ const struct os05b10_mode *mode_list;
struct v4l2_mbus_framefmt *format;
+ const struct os05b10_mode *mode;
+ unsigned int num_modes;
int ret;
+ ret = get_mode_table(os05b10, fmt->format.code, &mode_list, &num_modes);
+ if (ret)
+ return ret;
+
+ mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
+ fmt->format.width, fmt->format.height);
+
fmt->format.width = mode->width;
fmt->format.height = mode->height;
fmt->format.field = V4L2_FIELD_NONE;
@@ -732,12 +804,21 @@ static int os05b10_enum_frame_size(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_size_enum *fse)
{
- if (fse->index >= ARRAY_SIZE(supported_modes_10bit))
+ struct os05b10 *os05b10 = to_os05b10(sd);
+ const struct os05b10_mode *mode_list;
+ unsigned int num_modes;
+ int ret;
+
+ ret = get_mode_table(os05b10, fse->code, &mode_list, &num_modes);
+ if (ret)
+ return ret;
+
+ if (fse->index >= num_modes)
return -EINVAL;
- fse->min_width = supported_modes_10bit[fse->index].width;
+ fse->min_width = mode_list[fse->index].width;
fse->max_width = fse->min_width;
- fse->min_height = supported_modes_10bit[fse->index].height;
+ fse->min_height = mode_list[fse->index].height;
fse->max_height = fse->min_height;
return 0;
@@ -750,13 +831,18 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
struct os05b10 *os05b10 = to_os05b10(sd);
const struct os05b10_reg_list *reg_list;
const struct v4l2_mbus_framefmt *fmt;
+ const struct os05b10_mode *mode_list;
const struct os05b10_mode *mode;
+ unsigned int num_modes;
int ret;
fmt = v4l2_subdev_state_get_format(state, 0);
- mode = v4l2_find_nearest_size(supported_modes_10bit,
- ARRAY_SIZE(supported_modes_10bit), width,
- height, fmt->width, fmt->height);
+ ret = get_mode_table(os05b10, fmt->code, &mode_list, &num_modes);
+ if (ret)
+ return ret;
+
+ mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
+ fmt->width, fmt->height);
ret = pm_runtime_resume_and_get(os05b10->dev);
if (ret < 0)
@@ -770,6 +856,14 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
goto err_rpm_put;
}
+ ret = cci_write(os05b10->cci, OS05B10_REG_MIPI_SC_CTRL_1,
+ (mode->bpp == 12) ? OS05B10_12BIT_MODE :
+ OS05B10_10BIT_MODE, NULL);
+ if (ret) {
+ dev_err(os05b10->dev, "failed to write pixel bit registers\n");
+ goto err_rpm_put;
+ }
+
/* Write sensor mode registers */
reg_list = &mode->reg_list;
ret = cci_multi_reg_write(os05b10->cci, reg_list->regs,
@@ -832,7 +926,7 @@ static int os05b10_init_state(struct v4l2_subdev *sd,
format = v4l2_subdev_state_get_format(state, 0);
mode = &supported_modes_10bit[0];
- format->code = os05b10_get_format_code(os05b10);
+ format->code = os05b10_get_format_code(os05b10, os05b10_mbus_codes[0]);
/* Update image pad formate */
format->width = mode->width;
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 12/15] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (10 preceding siblings ...)
2026-10-30 10:48 ` [PATCH v5 11/15] media: i2c: os05b10: add 12-bit RAW mode support Tarang Raval
@ 2026-10-30 10:48 ` Tarang Raval
2026-10-30 10:48 ` [PATCH v5 13/15] media: i2c: os05b10: keep exposure default in sync with the active mode on VBLANK changes Tarang Raval
` (2 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:48 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Hans Verkuil, Mehdi Djait, linux-media,
linux-kernel
Add support for 1920x1080 and 1280x720 resolutions.
The 1280x720 mode uses 2x2 binning.
Both 10-bit and 12-bit pixel formats are supported.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 120 ++++++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index ba6a22ced3db..48c406b2e544 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -456,6 +456,78 @@ static const struct cci_reg_sequence mode_2592_1944_regs[] = {
{ CCI_REG8(0x4837), 0x12 },
};
+static const struct cci_reg_sequence mode_1920_1080_regs[] = {
+ { OS05B10_REG_X_ADDR_START, 0x0280 },
+ { OS05B10_REG_Y_ADDR_START, 0x01b4 },
+ { OS05B10_REG_X_ADDR_END, 0x0a0f },
+ { OS05B10_REG_Y_ADDR_END, 0x05f3 },
+ { OS05B10_REG_X_OUTPUT_SIZE, 0x0780 },
+ { OS05B10_REG_Y_OUTPUT_SIZE, 0x0438 },
+ { OS05B10_REG_HTS, 0x06d0 },
+ { OS05B10_REG_ISP_X_WIN, 0x0008 },
+ { OS05B10_REG_ISP_Y_WIN, 0x0008 },
+ { OS05B10_REG_X_INC_ODD, 0x01 },
+ { OS05B10_REG_X_INC_EVEN, 0x01 },
+ { OS05B10_REG_Y_INC_ODD, 0x01 },
+ { OS05B10_REG_Y_INC_EVEN, 0x01 },
+ { OS05B10_REG_FORMAT1, 0x88 },
+ { OS05B10_REG_FORMAT2, 0x00 },
+ { CCI_REG8(0x3610), 0x87 },
+ { CCI_REG8(0x3620), 0x0c },
+ { CCI_REG8(0x3662), 0x10 },
+ { CCI_REG8(0x3714), 0x24 },
+ { CCI_REG8(0x373f), 0xb0 },
+ { CCI_REG8(0x37bf), 0x05 },
+ { CCI_REG8(0x37c2), 0x04 },
+ { CCI_REG8(0x37d9), 0x08 },
+ { CCI_REG8(0x3832), 0x08 },
+ { CCI_REG8(0x3c86), 0x03 },
+ { CCI_REG8(0x3d8c), 0x71 },
+ { CCI_REG8(0x3f03), 0x08 },
+ { CCI_REG8(0x4008), 0x02 },
+ { CCI_REG8(0x4009), 0x0d },
+ { CCI_REG8(0x400a), 0x02 },
+ { CCI_REG8(0x4041), 0x07 },
+ { CCI_REG8(0x4505), 0xc4 },
+ { CCI_REG8(0x4837), 0x0d },
+};
+
+static const struct cci_reg_sequence mode_1280_720_regs[] = {
+ { OS05B10_REG_X_ADDR_START, 0x0140 },
+ { OS05B10_REG_Y_ADDR_START, 0x00fc },
+ { OS05B10_REG_X_ADDR_END, 0x0b4f },
+ { OS05B10_REG_Y_ADDR_END, 0x06ab },
+ { OS05B10_REG_X_OUTPUT_SIZE, 0x0500 },
+ { OS05B10_REG_Y_OUTPUT_SIZE, 0x02d0 },
+ { OS05B10_REG_HTS, 0x0368 },
+ { OS05B10_REG_ISP_X_WIN, 0x0004 },
+ { OS05B10_REG_ISP_Y_WIN, 0x0004 },
+ { OS05B10_REG_X_INC_ODD, 0x03 },
+ { OS05B10_REG_X_INC_EVEN, 0x01 },
+ { OS05B10_REG_Y_INC_ODD, 0x03 },
+ { OS05B10_REG_Y_INC_EVEN, 0x01 },
+ { OS05B10_REG_FORMAT1, 0x8b },
+ { OS05B10_REG_FORMAT2, 0x00 },
+ { CCI_REG8(0x3610), 0x57 },
+ { CCI_REG8(0x3620), 0x01 },
+ { CCI_REG8(0x3662), 0x08 },
+ { CCI_REG8(0x3714), 0x28 },
+ { CCI_REG8(0x373f), 0xa0 },
+ { CCI_REG8(0x37bf), 0x05 },
+ { CCI_REG8(0x37c2), 0x14 },
+ { CCI_REG8(0x37d9), 0x04 },
+ { CCI_REG8(0x3832), 0x00 },
+ { CCI_REG8(0x3c86), 0x03 },
+ { CCI_REG8(0x3d8c), 0x71 },
+ { CCI_REG8(0x3f03), 0x1d },
+ { CCI_REG8(0x4008), 0x01 },
+ { CCI_REG8(0x4009), 0x06 },
+ { CCI_REG8(0x400a), 0x02 },
+ { CCI_REG8(0x4041), 0x03 },
+ { CCI_REG8(0x4505), 0xe4 },
+ { CCI_REG8(0x4837), 0x0d },
+};
+
struct os05b10 {
struct device *dev;
struct regmap *cci;
@@ -506,6 +578,30 @@ static const struct os05b10_mode supported_modes_12bit[] = {
.regs = mode_2592_1944_regs,
},
},
+ { /* 40 fps */
+ .width = 1920,
+ .height = 1080,
+ .vts = 1504,
+ .hts = 1744,
+ .exp = 1472,
+ .bpp = 12,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_1920_1080_regs),
+ .regs = mode_1920_1080_regs,
+ },
+ },
+ { /* 2x2 binning 120 fps */
+ .width = 1280,
+ .height = 720,
+ .vts = 1003,
+ .hts = 872,
+ .exp = 970,
+ .bpp = 12,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_1280_720_regs),
+ .regs = mode_1280_720_regs,
+ },
+ },
};
static const struct os05b10_mode supported_modes_10bit[] = {
@@ -521,6 +617,30 @@ static const struct os05b10_mode supported_modes_10bit[] = {
.regs = mode_2592_1944_regs,
},
},
+ { /* 40 fps */
+ .width = 1920,
+ .height = 1080,
+ .vts = 1504,
+ .hts = 1744,
+ .exp = 1472,
+ .bpp = 10,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_1920_1080_regs),
+ .regs = mode_1920_1080_regs,
+ },
+ },
+ { /* 2x2 binning 120 fps */
+ .width = 1280,
+ .height = 720,
+ .vts = 1003,
+ .hts = 872,
+ .exp = 970,
+ .bpp = 10,
+ .reg_list = {
+ .num_of_regs = ARRAY_SIZE(mode_1280_720_regs),
+ .regs = mode_1280_720_regs,
+ },
+ },
};
static const s64 link_frequencies[] = {
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 13/15] media: i2c: os05b10: keep exposure default in sync with the active mode on VBLANK changes
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (11 preceding siblings ...)
2026-10-30 10:48 ` [PATCH v5 12/15] media: i2c: os05b10: Add 1080p and 2x2 binning 720p modes Tarang Raval
@ 2026-10-30 10:48 ` Tarang Raval
2026-10-30 10:48 ` [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support Tarang Raval
2026-10-30 10:48 ` [PATCH v5 15/15] media: i2c: os05b10: fix horizontal blanking calculation Tarang Raval
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:48 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Vladimir Zapolskiy, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, Mehdi Djait,
Hans Verkuil, linux-media, linux-kernel
Update vblank through the control path on mode changes so exposure
limits and default values are recalculated consistently from the
active mode.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
Reviewed-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
---
drivers/media/i2c/os05b10.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 48c406b2e544..507d714fbd21 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
+#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
@@ -751,13 +752,23 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct os05b10 *os05b10 = container_of_const(ctrl->handler,
struct os05b10, handler);
+ const struct os05b10_mode *mode_list;
struct v4l2_subdev_state *state;
+ const struct os05b10_mode *mode;
struct v4l2_mbus_framefmt *fmt;
+ unsigned int num_modes;
int vts, ret;
state = v4l2_subdev_get_locked_active_state(&os05b10->sd);
fmt = v4l2_subdev_state_get_format(state, 0);
+ ret = get_mode_table(os05b10, fmt->code, &mode_list, &num_modes);
+ if (ret)
+ return ret;
+
+ mode = v4l2_find_nearest_size(mode_list, num_modes, width, height,
+ fmt->width, fmt->height);
+
if (ctrl->id == V4L2_CID_VBLANK) {
/* Honour the VBLANK limits when setting exposure. */
s64 max = fmt->height + ctrl->val - OS05B10_EXPOSURE_MARGIN;
@@ -765,7 +776,7 @@ static int os05b10_set_ctrl(struct v4l2_ctrl *ctrl)
ret = __v4l2_ctrl_modify_range(os05b10->exposure,
os05b10->exposure->minimum, max,
os05b10->exposure->step,
- os05b10->exposure->default_value);
+ min_t(s64, mode->exp, max));
if (ret)
return ret;
}
@@ -851,15 +862,19 @@ static int os05b10_set_framing_limits(struct os05b10 *os05b10,
vblank = mode->vts - mode->height;
vblank_max = OS05B10_VTS_MAX - mode->height;
- ret = __v4l2_ctrl_modify_range(os05b10->vblank, 0, vblank_max, 1,
+ ret = __v4l2_ctrl_modify_range(os05b10->vblank, vblank, vblank_max, 1,
vblank);
if (ret)
return ret;
max_exp = mode->vts - OS05B10_EXPOSURE_MARGIN;
- return __v4l2_ctrl_modify_range(os05b10->exposure,
- OS05B10_EXPOSURE_MIN, max_exp,
- OS05B10_EXPOSURE_STEP, mode->exp);
+ ret = __v4l2_ctrl_modify_range(os05b10->exposure,
+ OS05B10_EXPOSURE_MIN, max_exp,
+ OS05B10_EXPOSURE_STEP, mode->exp);
+ if (ret)
+ return ret;
+
+ return __v4l2_ctrl_s_ctrl(os05b10->vblank, vblank);
}
static int os05b10_set_pad_format(struct v4l2_subdev *sd,
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (12 preceding siblings ...)
2026-10-30 10:48 ` [PATCH v5 13/15] media: i2c: os05b10: keep exposure default in sync with the active mode on VBLANK changes Tarang Raval
@ 2026-10-30 10:48 ` Tarang Raval
2026-11-04 16:55 ` kernel test robot
2026-10-30 10:48 ` [PATCH v5 15/15] media: i2c: os05b10: fix horizontal blanking calculation Tarang Raval
14 siblings, 1 reply; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:48 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Vladimir Zapolskiy, Hans Verkuil,
Mehdi Djait, linux-media, linux-kernel
Add support for 2-lane operation.
The link frequency depends on the number of data lanes: 750 MHz for
2-lane and 600 MHz for 4-lane. Select the matching frequency table while
parsing the endpoint and use it for the LINK_FREQ control and the pixel
rate computation. Accept 2 or 4 data lanes in the endpoint.
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 70 +++++++++++++++++++++++++++++--------
1 file changed, 55 insertions(+), 15 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 507d714fbd21..9284b21a92c7 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -111,6 +111,7 @@
#define OS05B10_ROLLING_BAR_EFFECT 0xc0
#define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
+#define OS05B10_LINK_FREQ_750MHZ (750 * HZ_PER_MHZ)
static const struct v4l2_rect os05b10_native_area = {
.top = 0,
@@ -133,13 +134,7 @@ static const char * const os05b10_supply_name[] = {
};
static const struct cci_reg_sequence os05b10_common_regs[] = {
- { OS05B10_REG_PLL_CTRL(0x01), 0x44 },
- { OS05B10_REG_PLL_CTRL(0x03), 0x02 },
- { OS05B10_REG_PLL_CTRL(0x05), 0x32 },
- { OS05B10_REG_PLL_CTRL(0x06), 0x00 },
- { OS05B10_REG_PLL_CTRL(0x25), 0x3b },
{ CCI_REG8(0x3002), 0x21 },
- { OS05B10_REG_MIPI_SC_CTRL, OS05B10_4_LANE_MODE },
{ CCI_REG8(0x301e), 0xb4 },
{ CCI_REG8(0x301f), 0xd0 },
{ CCI_REG8(0x3021), 0x03 },
@@ -529,6 +524,24 @@ static const struct cci_reg_sequence mode_1280_720_regs[] = {
{ CCI_REG8(0x4837), 0x0d },
};
+static const struct cci_reg_sequence os05b10_2lane_regs[] = {
+ { OS05B10_REG_PLL_CTRL(0x01), 0x44 },
+ { OS05B10_REG_PLL_CTRL(0x03), 0x02 },
+ { OS05B10_REG_PLL_CTRL(0x05), 0x64 },
+ { OS05B10_REG_PLL_CTRL(0x06), 0x00 },
+ { OS05B10_REG_PLL_CTRL(0x25), 0x3b },
+ { OS05B10_REG_MIPI_SC_CTRL, OS05B10_2_LANE_MODE },
+};
+
+static const struct cci_reg_sequence os05b10_4lane_regs[] = {
+ { OS05B10_REG_PLL_CTRL(0x01), 0x44 },
+ { OS05B10_REG_PLL_CTRL(0x03), 0x02 },
+ { OS05B10_REG_PLL_CTRL(0x05), 0x32 },
+ { OS05B10_REG_PLL_CTRL(0x06), 0x00 },
+ { OS05B10_REG_PLL_CTRL(0x25), 0x3b },
+ { OS05B10_REG_MIPI_SC_CTRL, OS05B10_4_LANE_MODE },
+};
+
struct os05b10 {
struct device *dev;
struct regmap *cci;
@@ -547,6 +560,7 @@ struct os05b10 {
struct v4l2_ctrl *vflip;
struct v4l2_ctrl *hflip;
+ const s64 *link_frequencies;
u32 link_freq_index;
u32 data_lanes;
};
@@ -644,10 +658,14 @@ static const struct os05b10_mode supported_modes_10bit[] = {
},
};
-static const s64 link_frequencies[] = {
+static const s64 link_frequencies_4lane[] = {
OS05B10_LINK_FREQ_600MHZ,
};
+static const s64 link_frequencies_2lane[] = {
+ OS05B10_LINK_FREQ_750MHZ,
+};
+
static const u32 os05b10_mbus_codes[] = {
MEDIA_BUS_FMT_SBGGR10_1X10,
MEDIA_BUS_FMT_SBGGR12_1X12,
@@ -983,6 +1001,19 @@ static int os05b10_enable_streams(struct v4l2_subdev *sd,
if (ret < 0)
return ret;
+ /* Write PLL and MIPI lane configuration */
+ if (os05b10->data_lanes == 2)
+ ret = cci_multi_reg_write(os05b10->cci, os05b10_2lane_regs,
+ ARRAY_SIZE(os05b10_2lane_regs), NULL);
+ else
+ ret = cci_multi_reg_write(os05b10->cci, os05b10_4lane_regs,
+ ARRAY_SIZE(os05b10_4lane_regs), NULL);
+ if (ret) {
+ dev_err(os05b10->dev,
+ "failed to write PLL and MIPI lane registers\n");
+ goto err_rpm_put;
+ }
+
/* Write common registers */
ret = cci_multi_reg_write(os05b10->cci, os05b10_common_regs,
ARRAY_SIZE(os05b10_common_regs), NULL);
@@ -1194,9 +1225,16 @@ static int os05b10_parse_endpoint(struct os05b10 *os05b10)
if (ret)
return ret;
- if (bus_cfg.bus.mipi_csi2.num_data_lanes != 4) {
+ switch (bus_cfg.bus.mipi_csi2.num_data_lanes) {
+ case 2:
+ os05b10->link_frequencies = link_frequencies_2lane;
+ break;
+ case 4:
+ os05b10->link_frequencies = link_frequencies_4lane;
+ break;
+ default:
ret = dev_err_probe(os05b10->dev, -EINVAL,
- "only 4 data lanes are supported\n");
+ "only 2 or 4 data lanes are supported\n");
goto error_out;
}
@@ -1204,11 +1242,13 @@ static int os05b10_parse_endpoint(struct os05b10 *os05b10)
ret = v4l2_link_freq_to_bitmap(os05b10->dev, bus_cfg.link_frequencies,
bus_cfg.nr_of_link_frequencies,
- link_frequencies,
- ARRAY_SIZE(link_frequencies),
+ os05b10->link_frequencies,
+ ARRAY_SIZE(link_frequencies_4lane),
&link_freq_bitmap);
if (ret) {
- dev_err(os05b10->dev, "only 600MHz frequency is available\n");
+ dev_err(os05b10->dev, "%u MHz link frequency required for %u lanes\n",
+ (unsigned int)(os05b10->link_frequencies[0] / HZ_PER_MHZ),
+ os05b10->data_lanes);
goto error_out;
}
@@ -1223,7 +1263,7 @@ static int os05b10_parse_endpoint(struct os05b10 *os05b10)
static u64 os05b10_pixel_rate(struct os05b10 *os05b10,
const struct os05b10_mode *mode)
{
- u64 link_freq = link_frequencies[os05b10->link_freq_index];
+ u64 link_freq = os05b10->link_frequencies[os05b10->link_freq_index];
u64 pixel_rate = div_u64(link_freq * 2 * os05b10->data_lanes, mode->bpp);
dev_dbg(os05b10->dev,
@@ -1255,9 +1295,9 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
V4L2_CID_LINK_FREQ,
- ARRAY_SIZE(link_frequencies) - 1,
+ ARRAY_SIZE(link_frequencies_4lane) - 1,
os05b10->link_freq_index,
- link_frequencies);
+ os05b10->link_frequencies);
hblank_def = mode->hts - mode->width;
os05b10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK,
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support
2026-10-30 10:48 ` [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support Tarang Raval
@ 2026-11-04 16:55 ` kernel test robot
0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2026-11-04 16:55 UTC (permalink / raw)
To: Tarang Raval, sakari.ailus
Cc: oe-kbuild-all, jai.luthra, Tarang Raval, Himanshu Bhavani,
Elgin Perumbilly, Mauro Carvalho Chehab, linux-media,
Vladimir Zapolskiy, Hans Verkuil, Mehdi Djait, linux-kernel
Hi Tarang,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.3 next-20261030]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Tarang-Raval/media-i2c-os05b10-drop-unused-group-hold-programming/20261030-161750
base: linus/master
patch link: https://lore.kernel.org/r/20261030104806.1223991-15-tarang.raval%40siliconsignals.io
patch subject: [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support
config: riscv-randconfig-1001-20261104 (https://download.01.org/0day-ci/archive/20261105/202611050041.o415KE0z-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261105/202611050041.o415KE0z-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611050041.o415KE0z-lkp@intel.com/
All errors (new ones prefixed by >>):
riscv32-linux-ld: drivers/media/i2c/os05b10.o: in function `.L0 ':
>> os05b10.c:(.text+0x1784): undefined reference to `__divdi3'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v5 15/15] media: i2c: os05b10: fix horizontal blanking calculation
2026-10-30 10:47 [PATCH v5 00/15] media: i2c: os05b10: Refactor driver and Add new features Tarang Raval
` (13 preceding siblings ...)
2026-10-30 10:48 ` [PATCH v5 14/15] media: i2c: os05b10: add 2-lane support Tarang Raval
@ 2026-10-30 10:48 ` Tarang Raval
14 siblings, 0 replies; 19+ messages in thread
From: Tarang Raval @ 2026-10-30 10:48 UTC (permalink / raw)
To: sakari.ailus
Cc: jai.luthra, Tarang Raval, Himanshu Bhavani, Elgin Perumbilly,
Mauro Carvalho Chehab, Hans Verkuil, Mehdi Djait,
Vladimir Zapolskiy, linux-media, linux-kernel
The HTS register is not counted in output pixels, so "hts - width" is
meaningless: for every mode hts < width (e.g. 1744 vs 2592 for
2592x1944) and the u32 subtraction wraps. v4l2-compliance flags the
resulting HBLANK range:
fail: v4l2-test-controls.cpp(413): returned control value out of range
The timing generator counts lines in internal clock cycles that cover
several pixels. At 30 fps in the 2592x1944 mode (HTS 1744, VTS 2006) the
line timing is
HTS * VTS * fps = 1744 * 2006 * 30.01 ~= 105 MHz
which is half of the 210 MHz system clock. Use 4 pixels per cycle, which
gives an internal pixel rate of 105 MHz * 4 = 420 MPix/s.
Compute HBLANK as HTS * 4 - width, with a step of 4 pixels, and report
the fixed 420 MPix/s as PIXEL_RATE so that
fps = PIXEL_RATE / ((width + HBLANK) * (height + VBLANK)) holds. This
rate does not depend on the bit depth or the number of MIPI lanes, so
stop deriving it from the link frequency.
Fixes: 3aa9296a23ec4 ("media: i2c: add os05b10 image sensor driver")
Signed-off-by: Tarang Raval <tarang.raval@siliconsignals.io>
---
drivers/media/i2c/os05b10.c | 38 +++++++++++++++++--------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/drivers/media/i2c/os05b10.c b/drivers/media/i2c/os05b10.c
index 9284b21a92c7..4e87a9bd0f4d 100644
--- a/drivers/media/i2c/os05b10.c
+++ b/drivers/media/i2c/os05b10.c
@@ -113,6 +113,15 @@
#define OS05B10_LINK_FREQ_600MHZ (600 * HZ_PER_MHZ)
#define OS05B10_LINK_FREQ_750MHZ (750 * HZ_PER_MHZ)
+/*
+ * HTS is not counted in output pixels: the timing generator runs at half of
+ * the 210 MHz system clock and handles 4 pixels per cycle, giving an
+ * internal pixel rate of 105 MHz * 4 = 420 MPix/s. This is independent of
+ * the bit depth and of the number of MIPI lanes.
+ */
+#define OS05B10_PIXEL_RATE (420 * HZ_PER_MHZ)
+#define OS05B10_PIX_PER_CLK 4
+
static const struct v4l2_rect os05b10_native_area = {
.top = 0,
.left = 0,
@@ -872,9 +881,9 @@ static int os05b10_set_framing_limits(struct os05b10 *os05b10,
u32 hblank, vblank, vblank_max, max_exp;
int ret;
- hblank = mode->hts - mode->width;
- ret = __v4l2_ctrl_modify_range(os05b10->hblank, hblank, hblank, 1,
- hblank);
+ hblank = mode->hts * OS05B10_PIX_PER_CLK - mode->width;
+ ret = __v4l2_ctrl_modify_range(os05b10->hblank, hblank, hblank,
+ OS05B10_PIX_PER_CLK, hblank);
if (ret)
return ret;
@@ -1260,23 +1269,10 @@ 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 = os05b10->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)
{
const struct os05b10_mode *mode = &supported_modes_10bit[0];
- u64 hblank_def, vblank_def, exp_max, pixel_rate;
+ u64 hblank_def, vblank_def, exp_max;
struct v4l2_fwnode_device_properties props;
struct v4l2_ctrl_handler *ctrl_hdlr;
struct v4l2_ctrl *link_freq;
@@ -1289,9 +1285,9 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
ctrl_hdlr = &os05b10->handler;
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, OS05B10_PIXEL_RATE, 1,
+ OS05B10_PIXEL_RATE);
link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &os05b10_ctrl_ops,
V4L2_CID_LINK_FREQ,
@@ -1299,10 +1295,10 @@ static int os05b10_init_controls(struct os05b10 *os05b10)
os05b10->link_freq_index,
os05b10->link_frequencies);
- hblank_def = mode->hts - mode->width;
+ hblank_def = mode->hts * OS05B10_PIX_PER_CLK - mode->width;
os05b10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL, V4L2_CID_HBLANK,
hblank_def, hblank_def,
- 1, hblank_def);
+ OS05B10_PIX_PER_CLK, hblank_def);
vblank_def = mode->vts - mode->height;
os05b10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &os05b10_ctrl_ops,
--
2.34.1
^ permalink raw reply [flat|nested] 19+ messages in thread