[{"id":38118,"web_url":"https://patchwork.libcamera.org/comment/38118/","msgid":"<177039180188.607498.16248784242161087757@neptunite.rasen.tech>","date":"2026-02-06T15:30:01","subject":"Re: [PATCH v3 01/19] ipa: mali-c55: Move CameraHelper to context","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2025-11-14 23:16:56)\n> From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Move the CameraHelper sensor to the Context so that it can be\n> used by the algorithms directly.\n> \n> While at it, document the undocumented ctrlMap member of IPAContext.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/mali-c55/ipa_context.cpp |  6 ++++++\n>  src/ipa/mali-c55/ipa_context.h   |  4 ++++\n>  src/ipa/mali-c55/mali-c55.cpp    | 27 ++++++++++++---------------\n>  3 files changed, 22 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/mali-c55/ipa_context.cpp b/src/ipa/mali-c55/ipa_context.cpp\n> index 1b203e2b260592cda945855d54f1aceefaaece91..a1e4c39f38704d3a4b5948ab789ffb9773f216c9 100644\n> --- a/src/ipa/mali-c55/ipa_context.cpp\n> +++ b/src/ipa/mali-c55/ipa_context.cpp\n> @@ -96,6 +96,12 @@ namespace libcamera::ipa::mali_c55 {\n>   *\n>   * \\var IPAContext::frameContexts\n>   * \\brief Ring buffer of per-frame contexts\n> + *\n> + * \\var IPAContext::ctrlMap\n> + * \\brief A ControlInfoMap::Map of controls populated by the algorithms\n> + *\n> + * \\var IPAContext::camHelper\n> + * \\brief The camera sensor helper\n>   */\n>  \n>  } /* namespace libcamera::ipa::mali_c55 */\n> diff --git a/src/ipa/mali-c55/ipa_context.h b/src/ipa/mali-c55/ipa_context.h\n> index 13885eb83b5c4d7c7af6c4f8d5673890834fed58..bfa805c7b93f313dda2497365e83542bbc39e291 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>         FCQueue<IPAFrameContext> frameContexts;\n>  \n>         ControlInfoMap::Map ctrlMap;\n> +\n> +       /* Interface to the Camera Helper */\n> +       std::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 7d45e7310aecdae0e47655e6d2e8830e776d74cd..0751513dc584ca84dd212bf8c1469dd4b40c053d 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>         ControlInfoMap sensorControls_;\n>  \n> -       /* Interface to the Camera Helper */\n> -       std::unique_ptr<CameraSensorHelper> camHelper_;\n> -\n>         /* Local parameter storage */\n>         struct IPAContext context_;\n>  };\n> @@ -98,8 +95,8 @@ std::string IPAMaliC55::logPrefix() const\n>  int IPAMaliC55::init(const IPASettings &settings, const IPAConfigInfo &ipaConfig,\n>                      ControlInfoMap *ipaControls)\n>  {\n> -       camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -       if (!camHelper_) {\n> +       context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +       if (!context_.camHelper) {\n>                 LOG(IPAMaliC55, Error)\n>                         << \"Failed to create camera sensor helper for \"\n>                         << settings.sensorModel;\n> @@ -142,10 +139,10 @@ void IPAMaliC55::setControls()\n>  \n>         if (activeState.agc.autoEnabled) {\n>                 exposure = activeState.agc.automatic.exposure;\n> -               gain = camHelper_->gainCode(activeState.agc.automatic.sensorGain);\n> +               gain = context_.camHelper->gainCode(activeState.agc.automatic.sensorGain);\n>         } else {\n>                 exposure = activeState.agc.manual.exposure;\n> -               gain = camHelper_->gainCode(activeState.agc.manual.sensorGain);\n> +               gain = context_.camHelper->gainCode(activeState.agc.manual.sensorGain);\n>         }\n>  \n>         ControlList ctrls(sensorControls_);\n> @@ -191,17 +188,17 @@ void IPAMaliC55::updateSessionConfiguration(const IPACameraSensorInfo &info,\n>         context_.configuration.agc.minShutterSpeed = minExposure * context_.configuration.sensor.lineDuration;\n>         context_.configuration.agc.maxShutterSpeed = maxExposure * context_.configuration.sensor.lineDuration;\n>         context_.configuration.agc.defaultExposure = defExposure;\n> -       context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n> -       context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n> +       context_.configuration.agc.minAnalogueGain = context_.camHelper->gain(minGain);\n> +       context_.configuration.agc.maxAnalogueGain = context_.camHelper->gain(maxGain);\n>  \n> -       if (camHelper_->blackLevel().has_value()) {\n> +       if (context_.camHelper->blackLevel().has_value()) {\n>                 /*\n>                  * The black level from CameraSensorHelper is a 16-bit value.\n>                  * The Mali-C55 ISP expects 20-bit settings, so we shift it to\n>                  * the appropriate width\n>                  */\n>                 context_.configuration.sensor.blackLevel =\n> -                       camHelper_->blackLevel().value() << 4;\n> +                       context_.camHelper->blackLevel().value() << 4;\n>         }\n>  }\n>  \n> @@ -252,9 +249,9 @@ void IPAMaliC55::updateControls(const IPACameraSensorInfo &sensorInfo,\n>  \n>         /* Compute the analogue gain limits. */\n>         const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n> -       float minGain = camHelper_->gain(v4l2Gain.min().get<int32_t>());\n> -       float maxGain = camHelper_->gain(v4l2Gain.max().get<int32_t>());\n> -       float defGain = camHelper_->gain(v4l2Gain.def().get<int32_t>());\n> +       float minGain = context_.camHelper->gain(v4l2Gain.min().get<int32_t>());\n> +       float maxGain = context_.camHelper->gain(v4l2Gain.max().get<int32_t>());\n> +       float defGain = context_.camHelper->gain(v4l2Gain.def().get<int32_t>());\n>         ctrlMap[&controls::AnalogueGain] = ControlInfo(minGain, maxGain, defGain);\n>  \n>         /*\n> @@ -362,7 +359,7 @@ void IPAMaliC55::processStats(unsigned int request, unsigned int bufferId,\n>         frameContext.agc.exposure =\n>                 sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n>         frameContext.agc.sensorGain =\n> -               camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n> +               context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>  \n>         ControlList metadata(controls::controls);\n>  \n> \n> -- \n> 2.51.1\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 377A3BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Feb 2026 15:30:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B644615B2;\n\tFri,  6 Feb 2026 16:30:10 +0100 (CET)","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 E0D09615B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Feb 2026 16:30:08 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:5247:7b72:2b7:10da])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 63BE62E0;\n\tFri,  6 Feb 2026 16:29:24 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nzSk/UiX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1770391765;\n\tbh=teWjZmcZjIfLl9gIHt4VE3l3QzBUfOaAKU0UXXJV6iQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=nzSk/UiXmBwtt5tt9a+Tifx/GMgpxrKL9MlsyhNkezbQFM1nTJLpeARg2HXZnYael\n\tCUfQNw1flr3roK1Zol8ec/D63gqKQ7wvJublPu8s9h/Sh2gjHaLWqXZpOy0W3tU43E\n\tpa1MZDmZSI5YIr0Ba9epddTQtgGBC7m/sSEW5zK0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251114-exposure-limits-v3-1-b7c07feba026@ideasonboard.com>","References":"<20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com>\n\t<20251114-exposure-limits-v3-1-b7c07feba026@ideasonboard.com>","Subject":"Re: [PATCH v3 01/19] ipa: mali-c55: Move CameraHelper to context","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, Niklas =?utf-8?b?U8O2?=\n\t=?utf-8?q?derlund?= <niklas.soderlund@ragnatech.se>, Robert Mader\n\t<robert.mader@collabora.com>, libcamera-devel@lists.libcamera.org","Date":"Sat, 07 Feb 2026 00:30:01 +0900","Message-ID":"<177039180188.607498.16248784242161087757@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]