[{"id":36628,"web_url":"https://patchwork.libcamera.org/comment/36628/","msgid":"<20251102195327.GH27255@pendragon.ideasonboard.com>","date":"2025-11-02T19:53:27","subject":"Re: [PATCH v2 03/10] ipa: ipu3: Move CameraHelper to context","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Oct 28, 2025 at 10:31:49AM +0100, Jacopo Mondi 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: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/ipu3/ipa_context.cpp |  3 +++\n>  src/ipa/ipu3/ipa_context.h   |  3 +++\n>  src/ipa/ipu3/ipu3.cpp        | 15 ++++++---------\n>  3 files changed, 12 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\n> index 3b22f7917650d9e400d5368c2f890d6b2dc846a0..5d0ebaaec454fca823851228614a3eb229f0132b 100644\n> --- a/src/ipa/ipu3/ipa_context.cpp\n> +++ b/src/ipa/ipu3/ipa_context.cpp\n> @@ -54,6 +54,9 @@ namespace libcamera::ipa::ipu3 {\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>  /**\n> diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\n> index 97fcf06cd4ac9ac6d64c4933fcea80ace0e572df..4544d663642fb6fde1cf69a32f1c0fbb2fbd98f6 100644\n> --- a/src/ipa/ipu3/ipa_context.h\n> +++ b/src/ipa/ipu3/ipa_context.h\n> @@ -15,6 +15,7 @@\n>  #include <libcamera/controls.h>\n>  #include <libcamera/geometry.h>\n>  \n> +#include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>  \n>  namespace libcamera {\n> @@ -95,6 +96,8 @@ struct IPAContext {\n>  \tFCQueue<IPAFrameContext> frameContexts;\n>  \n>  \tControlInfoMap::Map ctrlMap;\n> +\n> +\tstd::unique_ptr<CameraSensorHelper> camHelper;\n>  };\n>  \n>  } /* namespace ipa::ipu3 */\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 1cae08bf255f6f53a0ebee02ba3aadda5a650ae3..36d8f0da430a3d4f94e2a3f760850519742ea992 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -179,9 +179,6 @@ private:\n>  \n>  \tIPACameraSensorInfo sensorInfo_;\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> @@ -222,8 +219,8 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n>  \t */\n>  \tcontext_.configuration.agc.minExposureTime = minExposure * context_.configuration.sensor.lineDuration;\n>  \tcontext_.configuration.agc.maxExposureTime = maxExposure * context_.configuration.sensor.lineDuration;\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>  \n>  /**\n> @@ -301,8 +298,8 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \t\t  const ControlInfoMap &sensorControls,\n>  \t\t  ControlInfoMap *ipaControls)\n>  {\n> -\tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -\tif (camHelper_ == nullptr) {\n> +\tcontext_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +\tif (context_.camHelper == nullptr) {\n>  \t\tLOG(IPAIPU3, Error)\n>  \t\t\t<< \"Failed to create camera sensor helper for \"\n>  \t\t\t<< settings.sensorModel;\n> @@ -597,7 +594,7 @@ void IPAIPU3::processStats(const uint32_t frame,\n>  \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>  \n>  \tframeContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n> -\tframeContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n> +\tframeContext.sensor.gain = context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>  \n>  \tControlList metadata(controls::controls);\n>  \n> @@ -643,7 +640,7 @@ void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)\n>  void IPAIPU3::setControls(unsigned int frame)\n>  {\n>  \tint32_t exposure = context_.activeState.agc.exposure;\n> -\tint32_t gain = camHelper_->gainCode(context_.activeState.agc.gain);\n> +\tint32_t gain = context_.camHelper->gainCode(context_.activeState.agc.gain);\n>  \n>  \tControlList ctrls(sensorCtrls_);\n>  \tctrls.set(V4L2_CID_EXPOSURE, exposure);","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 2B812C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun,  2 Nov 2025 19:53:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE5386096B;\n\tSun,  2 Nov 2025 20:53:41 +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 D3741606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  2 Nov 2025 20:53:40 +0100 (CET)","from pendragon.ideasonboard.com (82-203-160-149.bb.dnainternet.fi\n\t[82.203.160.149])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 5E46599F;\n\tSun,  2 Nov 2025 20:51:48 +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=\"tJIgJHZI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762113108;\n\tbh=yZvZeD6ty+QL/q+py8PlsNdKOE2MODC4HAkb9HCCxXQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=tJIgJHZIER+dL7KX4NBlb5YJZNxttPXreMgEik+RYMnqPFw+mFbsD5h/z58IOnjaF\n\tgC47kz6InjyY3H59rxks1BAq3dk9h81/XItZvdCruw1ihlwDwed3D5ifAfsxGfXcx2\n\tf8YgymdnGnjY+594cqREPt9GLsslwqiusHDAzpGE=","Date":"Sun, 2 Nov 2025 21:53:27 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>,\n\tRobert Mader <robert.mader@collabora.com>, \n\tlibcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 03/10] ipa: ipu3: Move CameraHelper to context","Message-ID":"<20251102195327.GH27255@pendragon.ideasonboard.com>","References":"<20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com>\n\t<20251028-exposure-limits-v2-3-a8b5a318323e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251028-exposure-limits-v2-3-a8b5a318323e@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>"}},{"id":36692,"web_url":"https://patchwork.libcamera.org/comment/36692/","msgid":"<176232253326.144437.17069819993389545217@localhost>","date":"2025-11-05T06:02:13","subject":"Re: [PATCH v2 03/10] ipa: ipu3: Move CameraHelper to context","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Quoting Jacopo Mondi (2025-10-28 10:31:49)\n> Move the CameraHelper sensor to the Context so that it can be\n> used by the algorithms directly.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> \n\nRegards,\nStefan\n\n> ---\n>  src/ipa/ipu3/ipa_context.cpp |  3 +++\n>  src/ipa/ipu3/ipa_context.h   |  3 +++\n>  src/ipa/ipu3/ipu3.cpp        | 15 ++++++---------\n>  3 files changed, 12 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp\n> index 3b22f7917650d9e400d5368c2f890d6b2dc846a0..5d0ebaaec454fca823851228614a3eb229f0132b 100644\n> --- a/src/ipa/ipu3/ipa_context.cpp\n> +++ b/src/ipa/ipu3/ipa_context.cpp\n> @@ -54,6 +54,9 @@ namespace libcamera::ipa::ipu3 {\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>  /**\n> diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\n> index 97fcf06cd4ac9ac6d64c4933fcea80ace0e572df..4544d663642fb6fde1cf69a32f1c0fbb2fbd98f6 100644\n> --- a/src/ipa/ipu3/ipa_context.h\n> +++ b/src/ipa/ipu3/ipa_context.h\n> @@ -15,6 +15,7 @@\n>  #include <libcamera/controls.h>\n>  #include <libcamera/geometry.h>\n>  \n> +#include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>  \n>  namespace libcamera {\n> @@ -95,6 +96,8 @@ struct IPAContext {\n>         FCQueue<IPAFrameContext> frameContexts;\n>  \n>         ControlInfoMap::Map ctrlMap;\n> +\n> +       std::unique_ptr<CameraSensorHelper> camHelper;\n>  };\n>  \n>  } /* namespace ipa::ipu3 */\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 1cae08bf255f6f53a0ebee02ba3aadda5a650ae3..36d8f0da430a3d4f94e2a3f760850519742ea992 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -179,9 +179,6 @@ private:\n>  \n>         IPACameraSensorInfo sensorInfo_;\n>  \n> -       /* Interface to the Camera Helper */\n> -       std::unique_ptr<CameraSensorHelper> camHelper_;\n> -\n>         /* Local parameter storage */\n>         struct IPAContext context_;\n>  };\n> @@ -222,8 +219,8 @@ void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n>          */\n>         context_.configuration.agc.minExposureTime = minExposure * context_.configuration.sensor.lineDuration;\n>         context_.configuration.agc.maxExposureTime = maxExposure * context_.configuration.sensor.lineDuration;\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>  \n>  /**\n> @@ -301,8 +298,8 @@ int IPAIPU3::init(const IPASettings &settings,\n>                   const ControlInfoMap &sensorControls,\n>                   ControlInfoMap *ipaControls)\n>  {\n> -       camHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -       if (camHelper_ == nullptr) {\n> +       context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +       if (context_.camHelper == nullptr) {\n>                 LOG(IPAIPU3, Error)\n>                         << \"Failed to create camera sensor helper for \"\n>                         << settings.sensorModel;\n> @@ -597,7 +594,7 @@ void IPAIPU3::processStats(const uint32_t frame,\n>         IPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>  \n>         frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n> -       frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n> +       frameContext.sensor.gain = context_.camHelper->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>  \n>         ControlList metadata(controls::controls);\n>  \n> @@ -643,7 +640,7 @@ void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls)\n>  void IPAIPU3::setControls(unsigned int frame)\n>  {\n>         int32_t exposure = context_.activeState.agc.exposure;\n> -       int32_t gain = camHelper_->gainCode(context_.activeState.agc.gain);\n> +       int32_t gain = context_.camHelper->gainCode(context_.activeState.agc.gain);\n>  \n>         ControlList ctrls(sensorCtrls_);\n>         ctrls.set(V4L2_CID_EXPOSURE, exposure);\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 18E49C3241\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Nov 2025 06:02:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 634C460856;\n\tWed,  5 Nov 2025 07:02:21 +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 6E7F2606A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Nov 2025 07:02:19 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:3793:9dc2:3dec:ebc3])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id CB909B3;\n\tWed,  5 Nov 2025 07:00:23 +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=\"QXa9c9rn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762322424;\n\tbh=w9ShnP5W3wJ1FBex3jKnwlpk3+6NE5cGndeUPwM0Xj0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QXa9c9rncsgFfQZx3lRrFkdyoe4KfIOAH5ejfPPe9ZVNMawta/sGQWBu3w+IJw9Vh\n\tpDZKbwjgWZl5tSa27blqYrIlVN4oOAN34vEqgxbG8VRXKEyM7uFc7/+AtzU5U6Wcwe\n\t9WNsGZUOOQ8sqeyY0i1mTQA9MrM3j1jK2/s4NSgc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251028-exposure-limits-v2-3-a8b5a318323e@ideasonboard.com>","References":"<20251028-exposure-limits-v2-0-a8b5a318323e@ideasonboard.com>\n\t<20251028-exposure-limits-v2-3-a8b5a318323e@ideasonboard.com>","Subject":"Re: [PATCH v2 03/10] ipa: ipu3: Move CameraHelper to context","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@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":"Wed, 05 Nov 2025 07:02:13 +0100","Message-ID":"<176232253326.144437.17069819993389545217@localhost>","User-Agent":"alot/0.12.dev8+g2c003385c862.d20250602","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>"}}]