Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v2] media: i2c: ov13858: cap analogue gain at 15.5x
@ 2026-10-02  9:35 Sergey Lebedev
  0 siblings, 0 replies; only message in thread
From: Sergey Lebedev @ 2026-10-02  9:35 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab
  Cc: Hans de Goede, linux-media, linux-kernel

The analogue gain control is advertised up to 0x1fff, but the gain only
follows it up to 0x7c0. Measured on raw Bayer at fixed exposure, on a
Surface Pro 11:

  register   requested   measured
      1984       15.5x      14.23x
      2047      15.99x      13.71x
      2048         16x       7.54x
      8191         64x      14.28x

At 0x800 the gain halves, and above it the gain repeats values from below
0x800, so an auto exposure loop that raises the gain can get less signal
back. Cap the control at 0x7c0, as ov13b10 and ov08x40 do.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>
---
v2:
 - Commit message shortened.
 - Assisted-by added, per Documentation/process/coding-assistants.rst.

The code is v1's, byte for byte. Tested on a Surface Pro 11 with
libcamera's software ISP: image quality is unchanged, since 0x7c0 and
0x1fff reach about the same gain.

v1: https://lore.kernel.org/all/20260831180746.68878-1-lsa.uz@pm.me/

 drivers/media/i2c/ov13858.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index de2b79a9a0e..27273d589cb 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -63,7 +63,7 @@
 /* Analog gain control */
 #define OV13858_REG_ANALOG_GAIN		0x3508
 #define OV13858_ANA_GAIN_MIN		0
-#define OV13858_ANA_GAIN_MAX		0x1fff
+#define OV13858_ANA_GAIN_MAX		0x07c0
 #define OV13858_ANA_GAIN_STEP		1
 #define OV13858_ANA_GAIN_DEFAULT	0x80
 
-- 
2.54.0 (Apple Git-157)



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

only message in thread, other threads:[~2026-10-02  9:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02  9:35 [PATCH v2] media: i2c: ov13858: cap analogue gain at 15.5x Sergey Lebedev

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