[{"id":30252,"web_url":"https://patchwork.libcamera.org/comment/30252/","msgid":"<ZoU1q3kAR2BHdQuK@pyrite.rasen.tech>","date":"2024-07-03T11:27:39","subject":"Re: [PATCH v2 2/6] ipa: rkisp1: Move camHelper into IPAContext","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Wed, Jul 03, 2024 at 12:39:49PM +0200, Stefan Klug wrote:\n> To be able to query the black levels, the black level correction\n> algorithm needs access to the camera sensor helper. Allow this by moving\n> the camHelper_ member from IPARkISP1 into IPAContext.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n(I'll send it again just in case)\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/ipa_context.h |  6 ++++++\n>  src/ipa/rkisp1/rkisp1.cpp    | 26 ++++++++++++--------------\n>  2 files changed, 18 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index 8602b408870e..1d0e9030af1c 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -8,6 +8,8 @@\n>  \n>  #pragma once\n>  \n> +#include <memory>\n> +\n>  #include <linux/rkisp1-config.h>\n>  \n>  #include <libcamera/base/utils.h>\n> @@ -16,6 +18,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>  #include <libipa/matrix.h>\n>  \n> @@ -178,6 +181,9 @@ struct IPAContext {\n>  \tFCQueue<IPAFrameContext> frameContexts;\n>  \n>  \tControlInfoMap::Map ctrlMap;\n> +\n> +\t/* Interface to the Camera Helper */\n> +\tstd::unique_ptr<CameraSensorHelper> camHelper;\n>  };\n>  \n>  } /* namespace ipa::rkisp1 */\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index d31cdbab020b..23e0826cc335 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -29,7 +29,6 @@\n>  #include \"libcamera/internal/yaml_parser.h\"\n>  \n>  #include \"algorithms/algorithm.h\"\n> -#include \"libipa/camera_sensor_helper.h\"\n>  \n>  #include \"ipa_context.h\"\n>  \n> @@ -81,9 +80,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> @@ -115,7 +111,7 @@ const ControlInfoMap::Map rkisp1Controls{\n>  } /* namespace */\n>  \n>  IPARkISP1::IPARkISP1()\n> -\t: context_({ {}, {}, {}, { kMaxFrameContexts }, {} })\n> +\t: context_({ {}, {}, {}, { kMaxFrameContexts }, {}, {} })\n>  {\n>  }\n>  \n> @@ -147,8 +143,8 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision,\n>  \n>  \tLOG(IPARkISP1, Debug) << \"Hardware revision is \" << hwRevision;\n>  \n> -\tcamHelper_ = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> -\tif (!camHelper_) {\n> +\tcontext_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel);\n> +\tif (!context_.camHelper) {\n>  \t\tLOG(IPARkISP1, Error)\n>  \t\t\t<< \"Failed to create camera sensor helper for \"\n>  \t\t\t<< settings.sensorModel;\n> @@ -250,8 +246,10 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n>  \t\tminExposure * context_.configuration.sensor.lineDuration;\n>  \tcontext_.configuration.sensor.maxShutterSpeed =\n>  \t\tmaxExposure * context_.configuration.sensor.lineDuration;\n> -\tcontext_.configuration.sensor.minAnalogueGain = camHelper_->gain(minGain);\n> -\tcontext_.configuration.sensor.maxAnalogueGain = camHelper_->gain(maxGain);\n> +\tcontext_.configuration.sensor.minAnalogueGain =\n> +\t\tcontext_.camHelper->gain(minGain);\n> +\tcontext_.configuration.sensor.maxAnalogueGain =\n> +\t\tcontext_.camHelper->gain(maxGain);\n>  \n>  \tcontext_.configuration.raw = std::any_of(streamConfig.begin(), streamConfig.end(),\n>  \t\t[](auto &cfg) -> bool {\n> @@ -352,7 +350,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n>  \tframeContext.sensor.exposure =\n>  \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n>  \tframeContext.sensor.gain =\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> @@ -389,9 +387,9 @@ void IPARkISP1::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.emplace(std::piecewise_construct,\n>  \t\t\tstd::forward_as_tuple(&controls::AnalogueGain),\n>  \t\t\tstd::forward_as_tuple(minGain, maxGain, defGain));\n> @@ -436,7 +434,7 @@ void IPARkISP1::setControls(unsigned int frame)\n>  \n>  \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>  \tuint32_t exposure = frameContext.agc.exposure;\n> -\tuint32_t gain = camHelper_->gainCode(frameContext.agc.gain);\n> +\tuint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain);\n>  \n>  \tControlList ctrls(sensorControls_);\n>  \tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure));\n> -- \n> 2.43.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 CF3BBBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Jul 2024 11:27:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7DBC162E22;\n\tWed,  3 Jul 2024 13:27:48 +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 02A9762C99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Jul 2024 13:27:47 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 99A564CA;\n\tWed,  3 Jul 2024 13:27:17 +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=\"gC9NIoKR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720006039;\n\tbh=/9Jkh4nOSI0ooIK+X7yT5gowX87cSc3YktevKY/r/n4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gC9NIoKRMiPQAfjZ88kQuI3xrPgTDq4pTe5vKiBwXQ2PWjZgnzzJeTG3/CXxx4T0u\n\tguDO84bh9yI7CGbbpGgOVzm0W4KadSk5QPJiWQM/aoBdOt13vcFWHb1Ahx9ezbTJym\n\t0u2ninZ38OOOZeND61D25E7W3bcHsnJkdgLV7ohY=","Date":"Wed, 3 Jul 2024 20:27:39 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH v2 2/6] ipa: rkisp1: Move camHelper into IPAContext","Message-ID":"<ZoU1q3kAR2BHdQuK@pyrite.rasen.tech>","References":"<20240703104004.184783-1-stefan.klug@ideasonboard.com>\n\t<20240703104004.184783-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240703104004.184783-3-stefan.klug@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>"}}]