[PATCH 3/3] media: i2c: ov8865: Allow fine analogue gain steps
From: Marco Ziliani
Date: Thu Dec 03 2026 - 12:55:25 EST
The analogue gain register (0x3508/0x3509) holds the gain with 7
fractional bits, 128 being 1x, but the control has a step of 128, which
limits the gain to the integer values 1x to 16x. An AGC can then only
move in steps of a whole stop or more at low gain, and it oscillates
between adjacent steps: on a Surface Book 2 at about 2.5x-2.9x gain,
libcamera's AGC gave a luma standard deviation of 1.4-1.7 with a step
of 16, 0.5-0.8 with a step of 8 and 0.03-0.10 with a step of 1. On a
Surface Pro 7+ the software ISP stayed at a low gain in a dark room
with a step of 128, and ramped up to the maximum with a step of 1.
Set the step to 1. The sensor resolves about 1/128 of the current gain
(1/64x at 2x, 1/32x at 4x, 1/16x at 8x) and ignores finer codes, so the
finer steps stay monotonic.
Tested-by: irishchug <75328733+irishchug@xxxxxxxxxxxxxxxxxxxxxxxx>
Tested-by: Firas Sharary <29305778+T-Caster@xxxxxxxxxxxxxxxxxxxxxxxx>
Link: https://github.com/linux-surface/kernel/pull/181#issuecomment-7225079329
Signed-off-by: Marco Ziliani <rylos78@xxxxxxxxx>
---
drivers/media/i2c/ov8865.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index e85e4c974..0977f2b3b 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -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 */
--
2.56.1