media: i2c: ov8865: Allow fine-grained analogue gain steps
Subsystems (2)
PATCH 1/1 media: i2c: ov8865: Allow fine-grained analogue gain steps
The analogue gain register (0x3508/0x3509) has seven fractional bits, 128 being 1x, as already noted in commit 3fdd94e2bfa3 ("media: i2c: Fix max gain in ov8865"). The V4L2_CID_ANALOGUE_GAIN control is however registered with a step of 128, which only allows whole multiples of 1x.
The control framework rounds every value to the step. libcamera's AGC raises the gain in small increments, each of which is rounded back down to 1x, so the gain never leaves 1x and dim scenes stay dark although the exposure is already at its maximum.
Use a step of 1 so that the full precision of the register is available.
Tested on a Microsoft Surface Pro 7 (rear camera) with an out-of-tree copy of this driver carrying the same change, as the IPU4P ISP of that device is not supported by mainline: libcamera's software ISP AGC now ramps the gain up to 16x, and raw captures at 8x, 8.6x, 10x, 12x and 16x show the expected monotonic increase in brightness. The mainline driver itself was only compile-tested.
The problem was found and this fix written with the help of an AI coding assistant (Claude); the submitter reviewed the change and ran the tests described above.
--- drivers/media/i2c/ov8865.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov8865.c +1 -1
@@ -2528,7 +2528,7 @@ static int ov8865_ctrls_init(struct ov8865_sensor *sensor)/* Gain */ -v4l2_ctrl_new_std (handler, ops,V4L2_CID_ANALOGUE_GAIN ,128 ,2048 ,128 , +v4l2_ctrl_new_std (handler, ops,V4L2_CID_ANALOGUE_GAIN ,128 ,2048 ,1 ,128 );/* White Balance */
Signature · 1 line
2.53.0