[{"id":36411,"web_url":"https://patchwork.libcamera.org/comment/36411/","msgid":"<2wcnhwx4c7642bxv5sjrmdsqvfwpecazquzu5nbm2vvsybzhue@kql6cyufw4ca>","date":"2025-10-23T16:51:44","subject":"Re: [RFC PATCH 6/7] ipa: softipa: Move camhelper 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\n  this and the previous 2s are kind of trivial changes, but without\n  seeing how they will be used, I'm not sure we should merge these\n  right away.\n\nOn Sat, Oct 11, 2025 at 05:03:34PM +0100, Kieran Bingham wrote:\n> Move the camhelper to the context structure so that it can be accessible\n> for algorithms to use directly where needed.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nFor this and the previous ones, anyway\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n>  src/ipa/simple/ipa_context.h   |  3 +++\n>  src/ipa/simple/soft_simple.cpp | 21 ++++++++++-----------\n>  2 files changed, 13 insertions(+), 11 deletions(-)\n>\n> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n> index c3081e3069b5..3d6a8b72861f 100644\n> --- a/src/ipa/simple/ipa_context.h\n> +++ b/src/ipa/simple/ipa_context.h\n> @@ -16,6 +16,7 @@\n>  #include \"libcamera/internal/matrix.h\"\n>  #include \"libcamera/internal/vector.h\"\n>\n> +#include <libipa/camera_sensor_helper.h>\n>  #include <libipa/fc_queue.h>\n>\n>  #include \"core_ipa_interface.h\"\n> @@ -103,6 +104,8 @@ struct IPAContext {\n>  \tFCQueue<IPAFrameContext> frameContexts;\n>  \tControlInfoMap::Map ctrlMap;\n>  \tbool ccmEnabled = false;\n> +\n> +\tstd::unique_ptr<CameraSensorHelper> camHelper;\n>  };\n>\n>  } /* namespace ipa::soft */\n> diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\n> index 0821d214815f..68ddf71e9f24 100644\n> --- a/src/ipa/simple/soft_simple.cpp\n> +++ b/src/ipa/simple/soft_simple.cpp\n> @@ -76,7 +76,6 @@ private:\n>\n>  \tDebayerParams *params_;\n>  \tSwIspStats *stats_;\n> -\tstd::unique_ptr<CameraSensorHelper> camHelper_;\n>  \tControlInfoMap sensorInfoMap_;\n>\n>  \t/* Local parameter storage */\n> @@ -99,8 +98,8 @@ int IPASoftSimple::init(const IPASettings &settings,\n>  \t\t\tControlInfoMap *ipaControls,\n>  \t\t\tbool *ccmEnabled)\n>  {\n> -\tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -\tif (!camHelper_) {\n> +\tcontext_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +\tif (!context_.camHelper) {\n>  \t\tLOG(IPASoft, Warning)\n>  \t\t\t<< \"Failed to create camera sensor helper for \"\n>  \t\t\t<< settings.sensorModel;\n> @@ -220,15 +219,15 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo,\n>  \tint32_t againMax = gainInfo.max().get<int32_t>();\n>  \tint32_t againDef = gainInfo.def().get<int32_t>();\n>\n> -\tif (camHelper_) {\n> -\t\tcontext_.configuration.agc.againMin = camHelper_->gain(againMin);\n> -\t\tcontext_.configuration.agc.againMax = camHelper_->gain(againMax);\n> -\t\tcontext_.configuration.agc.again10 = camHelper_->gain(1.0);\n> +\tif (context_.camHelper) {\n> +\t\tcontext_.configuration.agc.againMin = context_.camHelper->gain(againMin);\n> +\t\tcontext_.configuration.agc.againMax = context_.camHelper->gain(againMax);\n> +\t\tcontext_.configuration.agc.again10 = context_.camHelper->gain(1.0);\n>  \t\tcontext_.configuration.agc.againMinStep =\n>  \t\t\t(context_.configuration.agc.againMax -\n>  \t\t\t context_.configuration.agc.againMin) /\n>  \t\t\t100.0;\n> -\t\tif (camHelper_->blackLevel().has_value()) {\n> +\t\tif (context_.camHelper->blackLevel().has_value()) {\n>  \t\t\t/*\n>  \t\t\t * The black level from camHelper_ is a 16 bit value, software ISP\n>  \t\t\t * works with 8 bit pixel values, both regardless of the actual\n> @@ -236,7 +235,7 @@ int IPASoftSimple::configure(const IPAConfigInfo &configInfo,\n>  \t\t\t * by dividing the value from the helper by 256.\n>  \t\t\t */\n>  \t\t\tcontext_.configuration.black.level =\n> -\t\t\t\tcamHelper_->blackLevel().value() / 256;\n> +\t\t\t\tcontext_.camHelper->blackLevel().value() / 256;\n>  \t\t}\n>  \t} else {\n>  \t\t/*\n> @@ -313,7 +312,7 @@ void IPASoftSimple::processStats(const uint32_t frame,\n>  \tframeContext.sensor.exposure =\n>  \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n>  \tint32_t again = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();\n> -\tframeContext.sensor.gain = camHelper_ ? camHelper_->gain(again) : again;\n> +\tframeContext.sensor.gain = context_.camHelper ? context_.camHelper->gain(again) : again;\n>\n>  \tControlList metadata(controls::controls);\n>  \tfor (auto const &algo : algorithms())\n> @@ -332,7 +331,7 @@ void IPASoftSimple::processStats(const uint32_t frame,\n>  \tauto &againNew = frameContext.sensor.gain;\n>  \tctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure);\n>  \tctrls.set(V4L2_CID_ANALOGUE_GAIN,\n> -\t\t  static_cast<int32_t>(camHelper_ ? camHelper_->gainCode(againNew) : againNew));\n> +\t\t  static_cast<int32_t>(context_.camHelper ? context_.camHelper->gainCode(againNew) : againNew));\n>\n>  \tsetSensorControls.emit(ctrls);\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 60EFFC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 16:51:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9542E60842;\n\tThu, 23 Oct 2025 18:51:50 +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 1AB99607FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 18:51:49 +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 DC9371127;\n\tThu, 23 Oct 2025 18:50:03 +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=\"k+IayAG0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761238204;\n\tbh=j5CsgHfxwgn+9MhjKL9eRVQ2JmrBFa69Rr9Y7yGlrl0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=k+IayAG0SVSuAWzOOzfFyIsmNDru6X3rKkHN7NwD/nyYvHKHqcd2bCyOgNcThSca6\n\ttI7WoA6uBZG/wTQNdn+7RRGSyuLG7sWR/oAZ0URmCFVuNiqagMGnNie6A+05Tszp+2\n\tOmJALt/aY8iBWr7xwZgIM5KVXNQuvNuyMrqTWF9A=","Date":"Thu, 23 Oct 2025 18:51:44 +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 6/7] ipa: softipa: Move camhelper to context","Message-ID":"<2wcnhwx4c7642bxv5sjrmdsqvfwpecazquzu5nbm2vvsybzhue@kql6cyufw4ca>","References":"<20251011160335.50578-1-kieran.bingham@ideasonboard.com>\n\t<20251011160335.50578-7-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251011160335.50578-7-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>"}}]