On Sun Jul 6 11:53:53 2025 +0200, Hans de Goede wrote:
> When an exposure value > (mode-height + vblank) gets set the sensor will
> automatically increase vblank, lowering the framerate.
>
> This is not desirable, limit exposure the maximum exposure to mode-height +
> vblank to avoid the unwanted framerate slowdown.
>
> Signed-off-by: Hans de Goede <[email protected]>
> Reviewed-by: Andy Shevchenko <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Patch committed.
Thanks,
Mauro Carvalho Chehab
drivers/staging/media/atomisp/i2c/atomisp-gc0310.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
index d0e7f0f8452b..3e94414be6c7 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
@@ -306,12 +306,27 @@ static int gc0310_gain_set(struct gc0310_device *sensor,
u32 gain)
return ret;
}
+static int gc0310_exposure_update_range(struct gc0310_device *sensor)
+{
+ int exp_max = GC0310_NATIVE_HEIGHT + sensor->ctrls.vblank->val;
+
+ return __v4l2_ctrl_modify_range(sensor->ctrls.exposure, 0, exp_max,
+ 1, exp_max);
+}
+
static int gc0310_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct gc0310_device *sensor =
container_of(ctrl->handler, struct gc0310_device,
ctrls.handler);
int ret;
+ /* Update exposure range on vblank changes */
+ if (ctrl->id == V4L2_CID_VBLANK) {
+ ret = gc0310_exposure_update_range(sensor);
+ if (ret)
+ return ret;
+ }
+
/* Only apply changes to the controls if the device is powered up */
if (!pm_runtime_get_if_in_use(sensor->sd.dev))
return 0;
@@ -584,7 +599,7 @@ static int gc0310_init_controls(struct gc0310_device
*sensor)
struct i2c_client *client = v4l2_get_subdevdata(&sensor->sd);
struct v4l2_ctrl_handler *hdl = &sensor->ctrls.handler;
struct v4l2_fwnode_device_properties props;
- int ret;
+ int exp_max, ret;
v4l2_ctrl_handler_init(hdl, 8);
@@ -592,8 +607,10 @@ static int gc0310_init_controls(struct gc0310_device
*sensor)
hdl->lock = &sensor->input_lock;
sensor->sd.ctrl_handler = hdl;
+ exp_max = GC0310_NATIVE_HEIGHT + GC0310_V_BLANK_DEFAULT;
sensor->ctrls.exposure =
- v4l2_ctrl_new_std(hdl, &ctrl_ops, V4L2_CID_EXPOSURE, 0, 4095,
1, 1023);
+ v4l2_ctrl_new_std(hdl, &ctrl_ops, V4L2_CID_EXPOSURE, 0,
+ exp_max, 1, exp_max);
/* 32 steps at base gain 1 + 64 half steps at base gain 2 */
sensor->ctrls.gain =