From patchwork Mon Dec 15 11:53:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 25557 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 74CB6BD7D8 for ; Mon, 15 Dec 2025 11:53:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 660DC61977; Mon, 15 Dec 2025 12:53:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eJgLh7+S"; 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 23A88615B2 for ; Mon, 15 Dec 2025 12:53:51 +0100 (CET) Received: from pb-laptop.local (185.221.143.114.nat.pool.zt.hu [185.221.143.114]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3B788C66; Mon, 15 Dec 2025 12:53:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1765799626; bh=0lZdM3DiN6UbBXCCZ/LjCk3cp+WkrMO96zn8DujjapE=; h=From:To:Subject:Date:From; b=eJgLh7+S2LZa3BIKden2X9n1BVc1pte9Aoqy34USVSrGTa7CmmGRXUnZID8Zzcx5h Ka7Om6pc7xwBtm0h+qveLcPFZ/dll/7a70KcQaQn1elqaVpOUdO852ZFzpK3ls0Ku3 NCjaswFZ6vZDN6r3UAzH4JD6mGD3IkU2AHOuwEKI= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org, Stefan Klug Subject: [RFC PATCH v1] ipa: rkisp1: Allow algorithms to update `ControlInfoMap` Date: Mon, 15 Dec 2025 12:53:48 +0100 Message-ID: <20251215115348.626656-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.52.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" In `IPARkISP1::init()`, the `ControlInfoMap` that will be returned to the pipeline handler is updated after creating the algorithms; naturally, since otherwise no algorithm could register its own controls. However, in `IPARkISP1::configure()`, the update is done before the algorithms are configured. This is not ideal because this prevents algorithms from correctly updating e.g. the `ControlInfo`s of their controls. While no algorithm is affected today, during development, it is useful for various debug related controls, whose ranges depend on the exact configuration. However, `updateControls()` cannot simply be moved to be after the loop because it updates the limits of `FrameDurationLimits`, which `Agc::configure()` needs to access. Moving it after the loop would lead to stale data being used. So move the updating of `ipaControls` out of `updateControls()`. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/rkisp1.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 61d3d1f6f..6c9ff306d 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -76,7 +76,7 @@ protected: private: void updateControls(const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls); + ControlInfoMap::Map &ctrlMap); void setControls(unsigned int frame); std::map buffers_; @@ -202,12 +202,17 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return -EINVAL; } + ControlInfoMap::Map ctrlMap = rkisp1Controls; + + /* Initialize controls. */ + updateControls(sensorInfo, sensorControls, ctrlMap); + int ret = createAlgorithms(context_, (*data)["algorithms"]); if (ret) return ret; - /* Initialize controls. */ - updateControls(sensorInfo, sensorControls, ipaControls); + ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end()); + *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls); return 0; } @@ -254,9 +259,6 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, context_.configuration.sensor.size = info.outputSize; context_.configuration.sensor.lineDuration = info.minLineLength * 1.0s / info.pixelRate; - /* Update the camera controls using the new sensor settings. */ - updateControls(info, sensorControls_, ipaControls); - /* * When the AGC computes the new exposure values for a frame, it needs * to know the limits for exposure time and analogue gain. As it depends @@ -280,6 +282,11 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + ControlInfoMap::Map ctrlMap = rkisp1Controls; + + /* Update the camera controls using the new sensor settings. */ + updateControls(info, sensorControls_, ctrlMap); + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); @@ -293,6 +300,9 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return ret; } + ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end()); + *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls); + return 0; } @@ -388,10 +398,8 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls) + ControlInfoMap::Map &ctrlMap) { - ControlInfoMap::Map ctrlMap = rkisp1Controls; - /* * Compute exposure time limits from the V4L2_CID_EXPOSURE control * limits and the line duration. @@ -441,9 +449,6 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, context_.ctrlMap[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0], frameDurations[1], ControlValue(Span{ { frameDurations[2], frameDurations[2] } })); - - ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end()); - *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls); } void IPARkISP1::setControls(unsigned int frame)