From patchwork Tue Nov 17 08:47:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 28944 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 B610FBDE17 for ; Tue, 17 Nov 2026 08:47:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 680026A886; Tue, 17 Nov 2026 09:47:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kg7t7GoS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EBCC76A883 for ; Tue, 17 Nov 2026 09:47:33 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:27fa:cb4b:1d83:9b64]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 82D12593; Tue, 17 Nov 2026 09:45:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794905106; bh=VqhEcmHADJXpPkEN5HfwcIxTQ7kSwlu3+4wBOLc7f4E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kg7t7GoSVOfK51vrvDmtC5Hs2eG7oZ0ie3l3Xtg9bXVt51c4CE9EgvI4V8DAvQLTj S8yKcfgd25rj3IWtYA9a4rtPcbzgiapw18+6PloN5DAM12nkDzy3spZzfeHf/AgKym 1qI7YshNGZnGji+C7tbZzfYW6SquPYUyDvCEl8Aw= From: Stefan Klug Date: Tue, 17 Nov 2026 09:47:17 +0100 Subject: [PATCH 07/10] ipa: rkisp1: agc: Add digital gain support MIME-Version: 1.0 Message-Id: <20261117-sklug-digital-gain-support-v1-v1-7-f0aa342ca877@ideasonboard.com> References: <20261117-sklug-digital-gain-support-v1-v1-0-f0aa342ca877@ideasonboard.com> In-Reply-To: <20261117-sklug-digital-gain-support-v1-v1-0-f0aa342ca877@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug X-Mailer: b4 0.14.3 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" Add digital gain support by using the compress modules to apply gain. Note: the Compress module must be placed *after* the Agc module in the tuning file for this to work correctly. Eventually this constraint should be modeled in code. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index d82bb2ece24a..771128fc3d4c 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -39,6 +39,17 @@ LOG_DEFINE_CATEGORY(RkISP1Agc) * \brief A mean-based auto-exposure algorithm */ +namespace { + +/* + * The maximum digital gain that the compress algorithm can supply. This is + * a workaround as we don't have support for inter-algorithm dependencies. + * \todo Implement using proper dependencies + */ +constexpr double kAgcMaxDigitalGain = 64.0; + +} /* namespace */ + int Agc::parseMeteringModes(IPAContext &context, const ValueNode &tuningData) { if (!tuningData.isDictionary()) @@ -167,6 +178,16 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) .sensorControls = context.sensorControls, .ctrlMap = context.ctrlMap, .autoAllowed = !context.configuration.raw, + /* + * \todo The Compress algo must come after Agc in the tuning + * file to pick up the digital gain in prepare(). But as it is + * after Agc we can't query + * context.configuration.compress.supported here as the Compress + * algo is not configured yet. Therefore enable digital gain + * unconditionally for now. It won't effectively be enabled if + * the tuning file doesn't contain a maxDigitalGain > 1. + */ + .maxDigitalGain = kAgcMaxDigitalGain }); if (ret) return ret; @@ -213,7 +234,7 @@ void Agc::prepare(IPAContext &context, const uint32_t frame, if (context.configuration.compress.supported) { frameContext.compress.enable = true; - frameContext.compress.gain = frameContext.agc.quantizationGain; + frameContext.compress.gain = frameContext.agc.quantizationGain * frameContext.agc.digitalGain; } if (frame > 0 && !frameContext.agc.updateMetering)