[{"id":36409,"web_url":"https://patchwork.libcamera.org/comment/36409/","msgid":"<dj6lgsy52njhhnh3rk3udsho4ddnj5w6sakbju6nlqntw4lbb4@dxpdzco6xhli>","date":"2025-10-23T16:47:17","subject":"Re: [RFC PATCH 2/7] ipa: mali-c55: Move CameraHelper to context","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Kieran\n\nOn Sat, Oct 11, 2025 at 05:03:30PM +0100, Kieran Bingham wrote:\n> Move the CameraHelper sensor to the Context so that it can be\n> used by the algorithms directly.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/mali-c55/ipa_context.h |  4 ++++\n>  src/ipa/mali-c55/mali-c55.cpp  | 27 ++++++++++++---------------\n>  2 files changed, 16 insertions(+), 15 deletions(-)\n>\n> diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h\n> index 13885eb83b5c..bfa805c7b93f 100644\n> --- a/src/ipa/mali-c55/ipa_context.h\n> +++ b/src/ipa/mali-c55/ipa_context.h\n> @@ -12,6 +12,7 @@\n>\n>  #include \"libcamera/internal/bayer_format.h\"\n>\n> +#include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>\n>  namespace libcamera {\n> @@ -83,6 +84,9 @@ struct IPAContext {\n>  \tFCQueue<IPAFrameContext> frameContexts;\n>\n>  \tControlInfoMap::Map ctrlMap;\n> +\n> +\t/* Interface to the Camera Helper */\n\nI would not add any comment here, it's pretty obivous what this is\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n\n> +\tstd::unique_ptr<CameraSensorHelper> camHelper;\n>  };\n>\n>  } /* namespace ipa::mali_c55 */\n> diff --git a/src/ipa/mali-c55/mali-c55.cpp b/src/ipa/mali-c55/mali-c55.cpp\n> index 7d45e7310aec..0751513dc584 100644\n> --- a/src/ipa/mali-c55/mali-c55.cpp\n> +++ b/src/ipa/mali-c55/mali-c55.cpp\n> @@ -74,9 +74,6 @@ private:\n>\n>  \tControlInfoMap sensorControls_;\n>\n> -\t/* Interface to the Camera Helper */\n> -\tstd::unique_ptr<CameraSensorHelper> camHelper_;\n> -\n>  \t/* Local parameter storage */\n>  \tstruct IPAContext context_;\n>  };\n> @@ -98,8 +95,8 @@ std::string IPAMaliC55::logPrefix() const\n>  int IPAMaliC55::init(const IPASettings &settings, const IPAConfigInfo &ipaConfig,\n>  \t\t     ControlInfoMap *ipaControls)\n>  {\n> -\tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -\tif (!camHelper_) {\n> +\tcontext_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +\tif (!context_.camHelper) {\n>  \t\tLOG(IPAMaliC55, Error)\n>  \t\t\t<< \"Failed to create camera sensor helper for \"\n>  \t\t\t<< settings.sensorModel;\n> @@ -142,10 +139,10 @@ void IPAMaliC55::setControls()\n>\n>  \tif (activeState.agc.autoEnabled) {\n>  \t\texposure = activeState.agc.automatic.exposure;\n> -\t\tgain = camHelper_->gainCode(activeState.agc.automatic.sensorGain);\n> +\t\tgain = context_.camHelper->gainCode(activeState.agc.automatic.sensorGain);\n>  \t} else {\n>  \t\texposure = activeState.agc.manual.exposure;\n> -\t\tgain = camHelper_->gainCode(activeState.agc.manual.sensorGain);\n> +\t\tgain = context_.camHelper->gainCode(activeState.agc.manual.sensorGain);\n>  \t}\n>\n>  \tControlList ctrls(sensorControls_);\n> @@ -191,17 +188,17 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info,\n>  \tcontext_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration;\n>  \tcontext_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration;\n>  \tcontext_.configuration.agc.defaultExposure = defExposure;\n> -\tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n> -\tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n> +\tcontext_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain);\n> +\tcontext_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain);\n>\n> -\tif (camHelper_->blackLevel().has_value()) {\n> +\tif (context_.camHelper->blackLevel().has_value()) {\n>  \t\t/*\n>  \t\t * The black level from CameraSensorHelper is a 16-bit value.\n>  \t\t * The Mali-C55 ISP expects 20-bit settings, so we shift it to\n>  \t\t * the appropriate width\n>  \t\t */\n>  \t\tcontext_.configuration.sensor.blackLevel =\n> -\t\t\tcamHelper_->blackLevel().value() << 4;\n> +\t\t\tcontext_.camHelper->blackLevel().value() << 4;\n>  \t}\n>  }\n>\n> @@ -252,9 +249,9 @@ void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo,\n>\n>  \t/* Compute the analogue gain limits. */\n>  \tconst ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n> -\tfloat minGain = camHelper_->gain(v4l2Gain.min().get<int32_t>());\n> -\tfloat maxGain = camHelper_->gain(v4l2Gain.max().get<int32_t>());\n> -\tfloat defGain = camHelper_->gain(v4l2Gain.def().get<int32_t>());\n> +\tfloat minGain = context_.camHelper->gain(v4l2Gain.min().get<int32_t>());\n> +\tfloat maxGain = context_.camHelper->gain(v4l2Gain.max().get<int32_t>());\n> +\tfloat defGain = context_.camHelper->gain(v4l2Gain.def().get<int32_t>());\n>  \tctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain);\n>\n>  \t/*\n> @@ -362,7 +359,7 @@ void IPAMaliC55::processStats(unsigned int request, unsigned int bufferId,\n>  \tframeContext.agc.exposure =\n>  \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n>  \tframeContext.agc.sensorGain =\n> -\t\tcamHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n> +\t\tcontext_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>\n>  \tControlList metadata(controls::controls);\n>\n> --\n> 2.51.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1460ABE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 16:47:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B55A860835;\n\tThu, 23 Oct 2025 18:47:24 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E338D607FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 18:47:22 +0200 (CEST)","from ideasonboard.com (mob-5-90-63-16.net.vodafone.it [5.90.63.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 541F7EFE;\n\tThu, 23 Oct 2025 18:45:36 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tbWGhPB9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761237938;\n\tbh=Xvc/KFKtbakiWyJj3GHqx2EbKyHAEQbLmjbX7uW/bl8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=tbWGhPB9VA10CWAtmHssXctd+8Hj07iCfwJFw1TP6GgWloo/Ptxlf9TotdNhwRQG+\n\tBXS5C7C7CD2R5IxRrWPz3fO3i4IdSm8NlOiFzaBFLNtGfdQl5t+pfR4/sFYeFv0cbV\n\ttxohVChIfzVtrbZW0RlHAlQClt3Ra989VMlxdLRg=","Date":"Thu, 23 Oct 2025 18:47:17 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Subject":"Re: [RFC PATCH 2/7] ipa: mali-c55: Move CameraHelper to context","Message-ID":"<dj6lgsy52njhhnh3rk3udsho4ddnj5w6sakbju6nlqntw4lbb4@dxpdzco6xhli>","References":"<20251011160335.50578-1-kieran.bingham@ideasonboard.com>\n\t<20251011160335.50578-3-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251011160335.50578-3-kieran.bingham@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]