mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marco Ziliani <rylos78@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	 Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Daniel Scally <dan.scally@ideasonboard.com>,
	 linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] media: i2c: ov8865: Allow fine analogue gain steps
Date: Thu, 03 Dec 2026 18:55:01 +0100	[thread overview]
Message-ID: <20261203-ov8865-fixes-v1-3-2bedf7e05579@gmail.com> (raw)
In-Reply-To: <20261203-ov8865-fixes-v1-0-2bedf7e05579@gmail.com>

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@users.noreply.github.com>
Tested-by: Firas Sharary <29305778+T-Caster@users.noreply.github.com>
Link: https://github.com/linux-surface/kernel/pull/181#issuecomment-7225079329
Signed-off-by: Marco Ziliani <rylos78@gmail.com>
---
 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


      parent reply	other threads:[~2026-12-03 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:54 [PATCH 0/3] media: i2c: ov8865: Fix long frame lengths, VBLANK on mode change and " Marco Ziliani
2026-12-03 17:54 ` [PATCH 1/3] media: i2c: ov8865: Fix the VTS high byte mask Marco Ziliani
2026-12-03 17:55 ` [PATCH 2/3] media: i2c: ov8865: Reset VBLANK on mode change Marco Ziliani
2026-12-03 17:55 ` Marco Ziliani [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203-ov8865-fixes-v1-3-2bedf7e05579@gmail.com \
    --to=rylos78@gmail.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®