From patchwork Wed Jun 3 14:08:18 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 26819 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 064B7C324C for ; Wed, 3 Jun 2026 14:08:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33C9C63171; Wed, 3 Jun 2026 16:08:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fFnxLMqH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F5B1630BA for ; Wed, 3 Jun 2026 16:08:38 +0200 (CEST) Received: from mail.ideasonboard.com (unknown [IPv6:2401:4900:1c66:476d:c684:fe78:389f:7375]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BFE2C929; Wed, 3 Jun 2026 16:08:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1780495694; bh=FpZWLumGQUEHFZkhUIv/dtdy3OPu1d36lZmILmk9TMw=; h=From:To:Cc:Subject:Date:From; b=fFnxLMqH6IScC1qXxZNLvZDzSyCYSXkUmv3pqx008jGuw+ce8AYboHJD4dANgJkKf ECQhOayFiJ1K+DgjFrUXD90Z8hwobsIZDMSf0w4ANu2v3rjqQ+S5x0JXQx513j2qfy CxZ0c5FNxMwohCxKWoXYLE3ot1r+H0d9DNG7nhr4= From: Jai Luthra To: libcamera-devel@lists.libcamera.org Cc: Jai Luthra Subject: [PATCH] ipa: simple: Fix againMinStep calculation Date: Wed, 3 Jun 2026 19:38:18 +0530 Message-ID: <20260603140818.2558156-1-jai.luthra@ideasonboard.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the difference between againMin + 1 and againMin as the againMinStep value. This is better than a heuristic of 1% of the whole range, which doesn't match the actual allowed values by the V4L2 control, especially for sensors with an exponential gain model (that map the control values to equal-sized dB increments). Without this change I saw a lot of oscillations with IMX678. While the oscillations did go away after I narrowed the gain control to only map to 0 - 30dB of analogue gain, and ignore the 30.3 - 72dB digital gain range, I still think we should use the minimum step allowed by V4L2 rather than a heuristic of 1%. Even for sensors with a linear gain model like IMX219, that allow setting more than 100 values, this should make the AGC algorithm smoother. Signed-off-by: Jai Luthra --- src/ipa/simple/soft_simple.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index 629e1a32d..e463e38af 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -228,10 +228,9 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo) context_.configuration.agc.againMin = camHelper_->gain(againMin); context_.configuration.agc.againMax = camHelper_->gain(againMax); context_.configuration.agc.again10 = std::max(context_.configuration.agc.againMin, 1.0); + double againNext = camHelper_->gain(std::min(againMin + 1, againMax)); context_.configuration.agc.againMinStep = - (context_.configuration.agc.againMax - - context_.configuration.agc.againMin) / - 100.0; + againNext - context_.configuration.agc.againMin; if (camHelper_->blackLevel().has_value()) { /* * The black level from camHelper_ is a 16 bit value, software ISP