mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: i2c: ov8865: Allow fine-grained analogue gain steps
@ 2026-10-30 20:52 Tim Heyne
  0 siblings, 0 replies; only message in thread
From: Tim Heyne @ 2026-10-30 20:52 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab; +Cc: linux-media, linux-kernel, Tim Heyne

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.

Fixes: 11c0d8fdccc5 ("media: i2c: Add support for the OV8865 image sensor")
Signed-off-by: Tim Heyne <tim.heyne@firestrike.de>
---
 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 5a59cca8e..75fcc4c9b 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.53.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-30 20:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 20:52 [PATCH] media: i2c: ov8865: Allow fine-grained analogue gain steps Tim Heyne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®