[{"id":22438,"web_url":"https://patchwork.libcamera.org/comment/22438/","msgid":"<YjyT4JScJ4OZjO8b@pendragon.ideasonboard.com>","date":"2022-03-24T15:53:04","subject":"Re: [libcamera-devel] [PATCH v3 2/3] ipa: ipu3: Drop sensor\n\tcontrols private members from IPAIPU3","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Thu, Mar 24, 2022 at 07:50:34PM +0530, Umang Jain via libcamera-devel wrote:\n> Drop exposure, gain private members from IPAIPU3 because the values\n> are handled directly via IPAFrameContext.\n> \n> Move the default vblank value from IPAIPU3 to IPASessionContext\n> structure as it is a default static value not expected to change\n> for a session.\n> \n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/ipa_context.h |  1 +\n>  src/ipa/ipu3/ipu3.cpp      | 29 +++++++++--------------------\n>  2 files changed, 10 insertions(+), 20 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\n> index 6b7a512e..103498ef 100644\n> --- a/src/ipa/ipu3/ipa_context.h\n> +++ b/src/ipa/ipu3/ipa_context.h\n> @@ -37,6 +37,7 @@ struct IPASessionConfiguration {\n>  \t} agc;\n>  \n>  \tstruct {\n> +\t\tint32_t defVBlank;\n\nMissing documentation.\n\n>  \t\tutils::Duration lineDuration;\n>  \t} sensor;\n>  };\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index a8cc2f6c..3717d893 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -166,11 +166,6 @@ private:\n>  \n>  \tIPACameraSensorInfo sensorInfo_;\n>  \n> -\t/* Camera sensor controls. */\n> -\tuint32_t defVBlank_;\n> -\tuint32_t exposure_;\n> -\tuint32_t gain_;\n> -\n>  \t/* Interface to the Camera Helper */\n>  \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n>  \n> @@ -187,15 +182,16 @@ private:\n>   */\n>  void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n>  {\n> +\tconst ControlInfo vBlank = sensorControls.find(V4L2_CID_VBLANK)->second;\n\nDo we need a check to verify that the control is available, or is that\nguaranteed ? The CameraSensorClass makes it mandatory so I think it\nshould be fine.\n\n> +\tcontext_.configuration.sensor.defVBlank = vBlank.def().get<int32_t>();\n> +\n>  \tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n>  \tint32_t minExposure = v4l2Exposure.min().get<int32_t>();\n>  \tint32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n> -\texposure_ = minExposure;\n>  \n>  \tconst ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n>  \tint32_t minGain = v4l2Gain.min().get<int32_t>();\n>  \tint32_t maxGain = v4l2Gain.max().get<int32_t>();\n> -\tgain_ = minGain;\n>  \n>  \t/*\n>  \t * When the AGC computes the new exposure values for a frame, it needs\n> @@ -432,14 +428,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>  \t */\n>  \tsensorCtrls_ = configInfo.sensorControls;\n>  \n> -\tconst auto itVBlank = sensorCtrls_.find(V4L2_CID_VBLANK);\n> -\tif (itVBlank == sensorCtrls_.end()) {\n> -\t\tLOG(IPAIPU3, Error) << \"Can't find VBLANK control\";\n> -\t\treturn -EINVAL;\n> -\t}\n> -\n> -\tdefVBlank_ = itVBlank->second.def().get<int32_t>();\n> -\n>  \tcalculateBdsGrid(configInfo.bdsOutputSize);\n>  \n>  \t/* Clean frameContext at each reconfiguration. */\n> @@ -605,6 +593,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \t\t\t      const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tdouble lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();\n> +\tint32_t vBlank = context_.configuration.sensor.defVBlank;\n\nconst\n\n>  \tControlList ctrls(controls::controls);\n>  \n>  \tfor (auto const &algo : algorithms_)\n> @@ -613,7 +602,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>  \tsetControls(frame);\n>  \n>  \t/* \\todo Use VBlank value calculated from each frame exposure. */\n> -\tint64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration;\n> +\tint64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;\n>  \tctrls.set(controls::FrameDuration, frameDuration);\n>  \n>  \tctrls.set(controls::AnalogueGain, context_.frameContext.sensor.gain);\n> @@ -649,12 +638,12 @@ void IPAIPU3::setControls(unsigned int frame)\n>  \tIPU3Action op;\n>  \top.op = ActionSetSensorControls;\n>  \n> -\texposure_ = context_.frameContext.agc.exposure;\n> -\tgain_ = camHelper_->gainCode(context_.frameContext.agc.gain);\n> +\tint32_t exposure = context_.frameContext.agc.exposure;\n> +\tint32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain);\n\nconst here too.\n\nWith this, and the documentation update,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n>  \tControlList ctrls(sensorCtrls_);\n> -\tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure_));\n> -\tctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain_));\n> +\tctrls.set(V4L2_CID_EXPOSURE, exposure);\n> +\tctrls.set(V4L2_CID_ANALOGUE_GAIN, gain);\n>  \top.sensorControls = ctrls;\n>  \n>  \tControlList lensCtrls(lensCtrls_);\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 E3FE1BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Mar 2022 15:53:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 10465604DB;\n\tThu, 24 Mar 2022 16:53:08 +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 1605C60397\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Mar 2022 16:53:07 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7AE531844;\n\tThu, 24 Mar 2022 16:53:06 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648137188;\n\tbh=4X5ZQpgVsDlf8YVVhmK/Ro3aWEUGDNae5lIJ/amaW2g=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=fjG77og4WcLmDYctBgDPAz/eKaKQcrmHIidmzUcaaIbdrT0S09nwrS/1nmR+22EiQ\n\tViPylpYIKZH70Y9RkZDT3br2wO5PbiNxxRuTmJzZVAYW3CwEQHfHUX0JnSUHPk/Xkv\n\tJY+ayVFDLD8nDVstqQey8P1corNkZlhGcwIP0wFHXZqkiA/1h+5umTJniHGkKbxOcr\n\t5NKh056Ilvh7+47ixLqgOcpMN7T5A8cI6KFfbFjWlr5kuq7BzsV43mBQr+OK1a2WXb\n\th4N2hcftYo5EdjJE5hp4zJ6/1JaRdosfl9XLZWoAdEi/8J0ei536hMGBO5scChVFYS\n\tKFrnXmsSyKFpQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648137186;\n\tbh=4X5ZQpgVsDlf8YVVhmK/Ro3aWEUGDNae5lIJ/amaW2g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IB+SwhIu1tkht4mYVIRGRIo1D1bHwf0aXkHA3NEq8RXz9KI9dw/gTl2hTog62kn0Y\n\tiejciQuCz5IjxsrpAuKQxZsb4IQG5q8z4pak7+HdJmH3Wu8G79isZ3d6hz+flSUDSH\n\tMT5wll2Opkp0wOqm/hvIiUdtiBhfC3GAsXZGX6fo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"IB+SwhIu\"; dkim-atps=neutral","Date":"Thu, 24 Mar 2022 17:53:04 +0200","To":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<YjyT4JScJ4OZjO8b@pendragon.ideasonboard.com>","References":"<20220324142035.47338-1-umang.jain@ideasonboard.com>\n\t<20220324142035.47338-3-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220324142035.47338-3-umang.jain@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/3] ipa: ipu3: Drop sensor\n\tcontrols private members from IPAIPU3","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]