From patchwork Tue Nov 17 08:47:20 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 28947 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 CD3E9BDE17 for ; Tue, 17 Nov 2026 08:47:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8099D6A89A; Tue, 17 Nov 2026 09:47:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="C9KhC5RF"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F29E6A88C for ; Tue, 17 Nov 2026 09:47:40 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:27fa:cb4b:1d83:9b64]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 302C0593; Tue, 17 Nov 2026 09:45:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794905113; bh=jYyqZEG5wQ0Dp5iyrlIqAlhDJa5DeWjcDCXY380JwIs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C9KhC5RF2b+e7QwTBZUtHjZEukPGEjrUsZfYylvLdZeNnx5fNgGF+LONyXDsE9Tai Ekhtz0+9Fke2Y+FZMEcz65IjNTJDmHdvuqKw/WZkd5QlrmZS9CfMOJpUu0balz0xkA 0tRYqjoFwmEdIWdBEPIPVy27LD0UkRp3WNbR47Pk= From: Stefan Klug Date: Tue, 17 Nov 2026 09:47:20 +0100 Subject: [PATCH 10/10] RFC rkisp1: Model dependencies between Compress and Agc MIME-Version: 1.0 Message-Id: <20261117-sklug-digital-gain-support-v1-v1-10-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" Compress::configure() must run before Agc::configure(), so that Agc can check if compress (and therefore digital gain) is available. Agc::prepare() must run before Compress::prepare(), so that Agc can store the correct digital gain for compress in the frame comntext. Model these dependency and remove the hardcoded enablement of digital gain. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 41 +++++++++++++++++++++------------- src/ipa/rkisp1/algorithms/agc.h | 2 ++ src/ipa/rkisp1/algorithms/compress.cpp | 17 ++++++++++++++ src/ipa/rkisp1/algorithms/compress.h | 2 ++ 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 771128fc3d4c..998e3dbfeaba 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -134,6 +134,18 @@ Agc::Agc() supportsRaw_ = true; } +const std::set &Agc::dependencies() const +{ + static const std::set dependencies = { + { + .target = "Compress", + .step = AlgorithmStep::Configure, + .type = AlgorithmDependency::Before, + } + }; + return dependencies; +} + /** * \brief Initialise the AGC algorithm from tuning files * \param[in] context The shared IPA context @@ -173,22 +185,19 @@ int Agc::init(IPAContext &context, const ValueNode &tuningData) */ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { - int ret = agc_.configure(context.configuration.agc, context.activeState.agc, { - .sensorInfo = context.sensorInfo, - .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 - }); + int ret = agc_.configure( + context.configuration.agc, + context.activeState.agc, + { + .sensorInfo = context.sensorInfo, + .sensorControls = context.sensorControls, + .ctrlMap = context.ctrlMap, + .autoAllowed = !context.configuration.raw, + .maxDigitalGain = context.configuration.compress.supported + ? kAgcMaxDigitalGain + : 1.0, + }); + if (ret) return ret; diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index b8d59352e70d..9cee84bf6153 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -41,6 +41,8 @@ public: const rkisp1_stat_buffer *stats, ControlList &metadata) override; + virtual const std::set &dependencies() const override; + private: int parseMeteringModes(IPAContext &context, const ValueNode &tuningData); uint8_t computeHistogramPredivider(const Size &size, diff --git a/src/ipa/rkisp1/algorithms/compress.cpp b/src/ipa/rkisp1/algorithms/compress.cpp index 2afa449608b7..16077c29b21a 100644 --- a/src/ipa/rkisp1/algorithms/compress.cpp +++ b/src/ipa/rkisp1/algorithms/compress.cpp @@ -44,6 +44,23 @@ LOG_DEFINE_CATEGORY(RkISP1Compress) constexpr static int kRkISP1CompressInBits = 20; constexpr static int kRkISP1CompressOutBits = 12; +const std::set &Compress::dependencies() const +{ + static const std::set dependencies = { + { + .target = "Agc", + .step = AlgorithmStep::Prepare, + .type = AlgorithmDependency::Before, + }, + { + .target = "Agc", + .step = AlgorithmStep::Process, + .type = AlgorithmDependency::Before, + } + }; + return dependencies; +} + /** * \copydoc libcamera::ipa::Algorithm::configure */ diff --git a/src/ipa/rkisp1/algorithms/compress.h b/src/ipa/rkisp1/algorithms/compress.h index 87797b8ebcc5..31d516a31685 100644 --- a/src/ipa/rkisp1/algorithms/compress.h +++ b/src/ipa/rkisp1/algorithms/compress.h @@ -24,6 +24,8 @@ public: void prepare(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, RkISP1Params *params) override; + + const std::set &dependencies() const override; }; } /* namespace ipa::rkisp1::algorithms */