From patchwork Wed Dec 17 09:14:08 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: 25572 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 B6E8EC3257 for ; Wed, 17 Dec 2025 09:14:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF77761A37; Wed, 17 Dec 2025 10:14:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="X/mcQ7X4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E724609DE for ; Wed, 17 Dec 2025 10:14:13 +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 2D5A2581; Wed, 17 Dec 2025 10:14:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1765962846; bh=EUW/1ZuCSGhR+s9m3XejmkVGZtdD2oeFnl24c4weO+0=; h=From:To:Cc:Subject:Date:From; b=X/mcQ7X4Sqi1CC3OB8U3wzcnUGfxVUZLpnE623hxRw4RGjJvg+QSfmxBJa2n0r+o6 LR+8DAAcq0U7pmgos7pWBWEcLSmMNkvawRzJRapxXECxJNWgGT3bFK6U1IFwBlx6/Z 5JUvjkFnu8AO9NLWcwEc4IK0L69mtfPTp5F/a7J0= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Stefan Klug Subject: [RFC PATCH v2] ipa: rkisp1: Allow algorithms to update `ControlInfoMap` Date: Wed, 17 Dec 2025 10:14:08 +0100 Message-ID: <20251217091408.2132770-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 split `updateControls()` into two parts: `addControls()` and `updateControls()`. Signed-off-by: Barnabás Pőcze --- changes in v2: * split `updateControls()` -> `addControls()` + `updateControls()` v1: https://patchwork.libcamera.org/patch/25557/ --- src/ipa/rkisp1/rkisp1.cpp | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) -- 2.52.0 diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index fbcc39103..cd83389b8 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -74,9 +74,9 @@ protected: std::string logPrefix() const override; private: - void updateControls(const IPACameraSensorInfo &sensorInfo, - const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls); + void addControls(const IPACameraSensorInfo &sensorInfo, + const ControlInfoMap &sensorControls); + void updateControls(ControlInfoMap *ipaControls) const; void setControls(unsigned int frame); std::map buffers_; @@ -202,12 +202,14 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return -EINVAL; } + /* Initialize controls. */ + addControls(sensorInfo, sensorControls); + int ret = createAlgorithms(context_, (*data)["algorithms"]); if (ret) return ret; - /* Initialize controls. */ - updateControls(sensorInfo, sensorControls, ipaControls); + updateControls(ipaControls); return 0; } @@ -254,9 +256,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 +279,9 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + /* Update the camera controls using the new sensor settings. */ + addControls(info, sensorControls_); + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); @@ -293,6 +295,8 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return ret; } + updateControls(ipaControls); + return 0; } @@ -386,12 +390,9 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, metadataReady.emit(frame, metadata); } -void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, - const ControlInfoMap &sensorControls, - ControlInfoMap *ipaControls) +void IPARkISP1::addControls(const IPACameraSensorInfo &sensorInfo, + const ControlInfoMap &sensorControls) { - ControlInfoMap::Map ctrlMap = rkisp1Controls; - /* * Compute exposure time limits from the V4L2_CID_EXPOSURE control * limits and the line duration. @@ -401,18 +402,14 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, int32_t minExposure = v4l2Exposure.min().get() * lineDuration; int32_t maxExposure = v4l2Exposure.max().get() * lineDuration; int32_t defExposure = v4l2Exposure.def().get() * lineDuration; - ctrlMap.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::ExposureTime), - std::forward_as_tuple(minExposure, maxExposure, defExposure)); + context_.ctrlMap[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure, defExposure); /* Compute the analogue gain limits. */ const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second; float minGain = context_.camHelper->gain(v4l2Gain.min().get()); float maxGain = context_.camHelper->gain(v4l2Gain.max().get()); float defGain = context_.camHelper->gain(v4l2Gain.def().get()); - ctrlMap.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::AnalogueGain), - std::forward_as_tuple(minGain, maxGain, defGain)); + context_.ctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain); /* * Compute the frame duration limits. @@ -441,6 +438,11 @@ void IPARkISP1::updateControls(const IPACameraSensorInfo &sensorInfo, context_.ctrlMap[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0], frameDurations[1], ControlValue(Span{ { frameDurations[2], frameDurations[2] } })); +} + +void IPARkISP1::updateControls(ControlInfoMap *ipaControls) const +{ + ControlInfoMap::Map ctrlMap = rkisp1Controls; ctrlMap.insert(context_.ctrlMap.begin(), context_.ctrlMap.end()); *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls);