[{"id":20910,"web_url":"https://patchwork.libcamera.org/comment/20910/","msgid":"<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>","date":"2021-11-12T12:36:21","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi JM,\n\nOn 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n> We use the line duration several times in the IPAIPU3. Instead of\n> recalculating it each time, cache the value as a utils::Duration. When\n> the value is needed, cast it to a std::micro value.\n>\n> As sensorInfo is no longer used in updateSessionConfiguration remove the\n> reference to it.\n>\n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n>   1 file changed, 13 insertions(+), 16 deletions(-)\n>\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index d3195de6..f1597f78 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -148,8 +148,7 @@ private:\n>   \tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n>   \t\t\t    const ControlInfoMap &sensorControls,\n>   \t\t\t    ControlInfoMap *ipaControls);\n> -\tvoid updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> -\t\t\t\t\tconst ControlInfoMap &sensorControls);\n> +\tvoid updateSessionConfiguration(const ControlInfoMap &sensorControls);\n>   \tvoid processControls(unsigned int frame, const ControlList &controls);\n>   \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n>   \tvoid parseStatistics(unsigned int frame,\n> @@ -174,6 +173,8 @@ private:\n>   \tuint32_t minGain_;\n>   \tuint32_t maxGain_;\n>   \n> +\tutils::Duration lineDuration_;\n> +\n>   \t/* Interface to the Camera Helper */\n>   \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n>   \n> @@ -188,16 +189,12 @@ private:\n>    * \\brief Compute IPASessionConfiguration using the sensor information and the\n>    * sensor V4L2 controls\n>    */\n> -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> -\t\t\t\t\t const ControlInfoMap &sensorControls)\n> +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\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>   \n> -\tutils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n> -\t\t\t\t     / sensorInfo.pixelRate;\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> @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>   \t *\n>   \t * \\todo take VBLANK into account for maximum shutter speed\n>   \t */\n> -\tcontext_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n> -\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n> +\tcontext_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n> +\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n>   \tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>   \tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>   }\n> @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n>   \t * exposure min, max and default and convert it from lines to\n>   \t * microseconds.\n>   \t */\n> -\tdouble lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n>   \tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> -\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n> -\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n> -\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n> +\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n> +\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n> +\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n>   \tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n>   \t\t\t\t\t\t\tdefExposure);\n>   \n> @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>   \n>   \tcalculateBdsGrid(configInfo.bdsOutputSize);\n>   \n> +\tlineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n> +\n>   \t/* Update the camera controls using the new sensor settings. */\n>   \tupdateControls(sensorInfo_, ctrls_, ipaControls);\n>   \n>   \t/* Update the IPASessionConfiguration using the sensor settings. */\n> -\tupdateSessionConfiguration(sensorInfo_, ctrls_);\n> +\tupdateSessionConfiguration(ctrls_);\n>   \n>   \tfor (auto const &algo : algorithms_) {\n>   \t\tint ret = algo->configure(context_, configInfo);\n> @@ -627,8 +625,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 = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n> -\t\t\t\t(sensorInfo_.pixelRate / 1e6);\n> +\tint64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n>   \tctrls.set(controls::FrameDuration, frameDuration);\n>   \n>   \tctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);","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 B4FE6BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 12:36:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2CD2D6034D;\n\tFri, 12 Nov 2021 13:36:28 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C3956032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 13:36:27 +0100 (CET)","from [192.168.1.106] (unknown [103.251.226.254])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9C2974C;\n\tFri, 12 Nov 2021 13:36:25 +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=\"ky/pymlb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636720586;\n\tbh=N6R0wNfaxdv7npGF6eCFGD9/PccfxBwHvQ44OhVNMEg=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=ky/pymlbvey1NnB//A2Z6rrhhW/1fodQao9jF4EcIGmOTc2Ikx/DvNk/k7lQckdyL\n\t6JlafeMDPZFO0HNfpxSxYGzvLhFYGJx4rLm55GfLn1n+dTHIGg8kk5X271/Bsfsfxw\n\thjgc3ixiRjRYbfT6bmXbbPgEnamzWckb2aEJ2BHo=","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>","Date":"Fri, 12 Nov 2021 18:06:21 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20914,"web_url":"https://patchwork.libcamera.org/comment/20914/","msgid":"<163672329165.2717916.4266256988414093364@Monstersaurus>","date":"2021-11-12T13:21:31","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Umang Jain (2021-11-12 12:36:21)\n> Hi JM,\n> \n> On 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n> > We use the line duration several times in the IPAIPU3. Instead of\n> > recalculating it each time, cache the value as a utils::Duration. When\n> > the value is needed, cast it to a std::micro value.\n\nAren't values always 'needed' when they're obtained? This isn't quite\nhelping improve the clarity.\n\nWhy is it needed in micros, vs other usages?\n\n\n> >\n> > As sensorInfo is no longer used in updateSessionConfiguration remove the\n> > reference to it.\n> >\n> > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> \n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> \n> > ---\n> >   src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n> >   1 file changed, 13 insertions(+), 16 deletions(-)\n> >\n> > diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> > index d3195de6..f1597f78 100644\n> > --- a/src/ipa/ipu3/ipu3.cpp\n> > +++ b/src/ipa/ipu3/ipu3.cpp\n> > @@ -148,8 +148,7 @@ private:\n> >       void updateControls(const IPACameraSensorInfo &sensorInfo,\n> >                           const ControlInfoMap &sensorControls,\n> >                           ControlInfoMap *ipaControls);\n> > -     void updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> > -                                     const ControlInfoMap &sensorControls);\n> > +     void updateSessionConfiguration(const ControlInfoMap &sensorControls);\n> >       void processControls(unsigned int frame, const ControlList &controls);\n> >       void fillParams(unsigned int frame, ipu3_uapi_params *params);\n> >       void parseStatistics(unsigned int frame,\n> > @@ -174,6 +173,8 @@ private:\n> >       uint32_t minGain_;\n> >       uint32_t maxGain_;\n> >   \n> > +     utils::Duration lineDuration_;\n> > +\n> >       /* Interface to the Camera Helper */\n> >       std::unique_ptr<CameraSensorHelper> camHelper_;\n> >   \n> > @@ -188,16 +189,12 @@ private:\n> >    * \\brief Compute IPASessionConfiguration using the sensor information and the\n> >    * sensor V4L2 controls\n> >    */\n> > -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> > -                                      const ControlInfoMap &sensorControls)\n> > +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n> >   {\n> >       const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> >       int32_t minExposure = v4l2Exposure.min().get<int32_t>();\n> >       int32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n> >   \n> > -     utils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n> > -                                  / sensorInfo.pixelRate;\n> > -\n> >       const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n> >       int32_t minGain = v4l2Gain.min().get<int32_t>();\n> >       int32_t maxGain = v4l2Gain.max().get<int32_t>();\n> > @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> >        *\n> >        * \\todo take VBLANK into account for maximum shutter speed\n> >        */\n> > -     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n> > -     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n> > +     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n> > +     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n> >       context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n> >       context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n> >   }\n> > @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n> >        * exposure min, max and default and convert it from lines to\n> >        * microseconds.\n> >        */\n> > -     double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n> >       const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> > -     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n> > -     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n> > -     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n> > +     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n> > +     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n> > +     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n> >       controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n> >                                                       defExposure);\n> >   \n> > @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n> >   \n> >       calculateBdsGrid(configInfo.bdsOutputSize);\n> >   \n> > +     lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n> > +\n> >       /* Update the camera controls using the new sensor settings. */\n> >       updateControls(sensorInfo_, ctrls_, ipaControls);\n> >   \n> >       /* Update the IPASessionConfiguration using the sensor settings. */\n> > -     updateSessionConfiguration(sensorInfo_, ctrls_);\n> > +     updateSessionConfiguration(ctrls_);\n> >   \n> >       for (auto const &algo : algorithms_) {\n> >               int ret = algo->configure(context_, configInfo);\n> > @@ -627,8 +625,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n> >       setControls(frame);\n> >   \n> >       /* \\todo Use VBlank value calculated from each frame exposure. */\n> > -     int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n> > -                             (sensorInfo_.pixelRate / 1e6);\n> > +     int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n> >       ctrls.set(controls::FrameDuration, frameDuration);\n> >   \n> >       ctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);","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 A5BF7BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 13:21:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EA9EB60362;\n\tFri, 12 Nov 2021 14:21:35 +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 D04986032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 14:21:34 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7AE3874C;\n\tFri, 12 Nov 2021 14:21:34 +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=\"p7KYOuc/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636723294;\n\tbh=Oj+2eVF32XvidNX+Sxg+ccVsIfljgxkyWjf7fsM/WE4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=p7KYOuc/WBcr2higi8Ya0/alpU14sf7Qz318MbtU6Y08YznOEkWe5TbXY+I9qEsaL\n\tdc3cKd8RDjGdWPCO+Fdr/scz7bRfOGejy2nn/FOaDbEVHzGoU9amkFfd4yIWe0QZWW\n\tUh7d0zEg5qv6uAjKlYeLHpuLVtIMW95lfLNov6h4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>\n\t<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 12 Nov 2021 13:21:31 +0000","Message-ID":"<163672329165.2717916.4266256988414093364@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20924,"web_url":"https://patchwork.libcamera.org/comment/20924/","msgid":"<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>","date":"2021-11-12T16:03:53","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Kieran,\n\nOn 12/11/2021 14:21, Kieran Bingham wrote:\n> Quoting Umang Jain (2021-11-12 12:36:21)\n>> Hi JM,\n>>\n>> On 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n>>> We use the line duration several times in the IPAIPU3. Instead of\n>>> recalculating it each time, cache the value as a utils::Duration. When\n>>> the value is needed, cast it to a std::micro value.\n> \n> Aren't values always 'needed' when they're obtained? This isn't quite\n> helping improve the clarity.\n> \n> Why is it needed in micros, vs other usages?\n\nOK, I may have to specify it is documented in \nsrc/libcamera/control_ids.yaml ?\n\n'''\n- ExposureTime:\n     type: int32_t\n     description: |\nExposure time (shutter speed) for the frame applied in the sensor \ndevice. This value is specified in micro-seconds.\n'''\n\nHow can I reference this file in the commit message ?\n> \n> \n>>>\n>>> As sensorInfo is no longer used in updateSessionConfiguration remove the\n>>> reference to it.\n>>>\n>>> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>\n>>\n>> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>>\n>>> ---\n>>>    src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n>>>    1 file changed, 13 insertions(+), 16 deletions(-)\n>>>\n>>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n>>> index d3195de6..f1597f78 100644\n>>> --- a/src/ipa/ipu3/ipu3.cpp\n>>> +++ b/src/ipa/ipu3/ipu3.cpp\n>>> @@ -148,8 +148,7 @@ private:\n>>>        void updateControls(const IPACameraSensorInfo &sensorInfo,\n>>>                            const ControlInfoMap &sensorControls,\n>>>                            ControlInfoMap *ipaControls);\n>>> -     void updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>> -                                     const ControlInfoMap &sensorControls);\n>>> +     void updateSessionConfiguration(const ControlInfoMap &sensorControls);\n>>>        void processControls(unsigned int frame, const ControlList &controls);\n>>>        void fillParams(unsigned int frame, ipu3_uapi_params *params);\n>>>        void parseStatistics(unsigned int frame,\n>>> @@ -174,6 +173,8 @@ private:\n>>>        uint32_t minGain_;\n>>>        uint32_t maxGain_;\n>>>    \n>>> +     utils::Duration lineDuration_;\n>>> +\n>>>        /* Interface to the Camera Helper */\n>>>        std::unique_ptr<CameraSensorHelper> camHelper_;\n>>>    \n>>> @@ -188,16 +189,12 @@ private:\n>>>     * \\brief Compute IPASessionConfiguration using the sensor information and the\n>>>     * sensor V4L2 controls\n>>>     */\n>>> -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>> -                                      const ControlInfoMap &sensorControls)\n>>> +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n>>>    {\n>>>        const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n>>>        int32_t minExposure = v4l2Exposure.min().get<int32_t>();\n>>>        int32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n>>>    \n>>> -     utils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n>>> -                                  / sensorInfo.pixelRate;\n>>> -\n>>>        const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n>>>        int32_t minGain = v4l2Gain.min().get<int32_t>();\n>>>        int32_t maxGain = v4l2Gain.max().get<int32_t>();\n>>> @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>>         *\n>>>         * \\todo take VBLANK into account for maximum shutter speed\n>>>         */\n>>> -     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n>>> -     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n>>> +     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n>>> +     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n>>>        context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>>>        context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>>>    }\n>>> @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n>>>         * exposure min, max and default and convert it from lines to\n>>>         * microseconds.\n>>>         */\n>>> -     double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n>>>        const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n>>> -     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n>>> -     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n>>> -     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n>>> +     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n>>> +     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n>>> +     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n>>>        controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n>>>                                                        defExposure);\n>>>    \n>>> @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>>>    \n>>>        calculateBdsGrid(configInfo.bdsOutputSize);\n>>>    \n>>> +     lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n>>> +\n>>>        /* Update the camera controls using the new sensor settings. */\n>>>        updateControls(sensorInfo_, ctrls_, ipaControls);\n>>>    \n>>>        /* Update the IPASessionConfiguration using the sensor settings. */\n>>> -     updateSessionConfiguration(sensorInfo_, ctrls_);\n>>> +     updateSessionConfiguration(ctrls_);\n>>>    \n>>>        for (auto const &algo : algorithms_) {\n>>>                int ret = algo->configure(context_, configInfo);\n>>> @@ -627,8 +625,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>>>        setControls(frame);\n>>>    \n>>>        /* \\todo Use VBlank value calculated from each frame exposure. */\n>>> -     int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n>>> -                             (sensorInfo_.pixelRate / 1e6);\n>>> +     int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n>>>        ctrls.set(controls::FrameDuration, frameDuration);\n>>>    \n>>>        ctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);","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 4ECADBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 16:03:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 069FA6034D;\n\tFri, 12 Nov 2021 17:03:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 651176032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 17:03:55 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:61e2:b805:836d:e891] (unknown\n\t[IPv6:2a01:e0a:169:7140:61e2:b805:836d:e891])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 20289268;\n\tFri, 12 Nov 2021 17:03:55 +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=\"ZO293VBb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636733035;\n\tbh=o1g+axw73mjCUg4ltwKUyn44ftOY8IDDQXf6IrBkVr0=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=ZO293VBb0fAxzpz1ASBVf4Ui7GV0bBTH9ndWlGJyVU+K1qMgXizVvSdbMuQSTe2Zj\n\t7nr7Bq2x2996zji6dMKUNfWqxzAtbQjs+N/LT65yrQusRGfqGb/O3be+98tSzzq+ob\n\tn1FNqKV810H/23U3U0GtiIjreDbquvDMaWbVA8Eo=","Message-ID":"<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>","Date":"Fri, 12 Nov 2021 17:03:53 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.2.1","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>\n\t<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>\n\t<163672329165.2717916.4266256988414093364@Monstersaurus>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","In-Reply-To":"<163672329165.2717916.4266256988414093364@Monstersaurus>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20926,"web_url":"https://patchwork.libcamera.org/comment/20926/","msgid":"<163673394825.2728118.649256022109016746@Monstersaurus>","date":"2021-11-12T16:19:08","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jean-Michel Hautbois (2021-11-12 16:03:53)\n> Hi Kieran,\n> \n> On 12/11/2021 14:21, Kieran Bingham wrote:\n> > Quoting Umang Jain (2021-11-12 12:36:21)\n> >> Hi JM,\n> >>\n> >> On 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n> >>> We use the line duration several times in the IPAIPU3. Instead of\n> >>> recalculating it each time, cache the value as a utils::Duration. When\n> >>> the value is needed, cast it to a std::micro value.\n> > \n> > Aren't values always 'needed' when they're obtained? This isn't quite\n> > helping improve the clarity.\n> > \n> > Why is it needed in micros, vs other usages?\n> \n> OK, I may have to specify it is documented in \n> src/libcamera/control_ids.yaml ?\n> \n> '''\n> - ExposureTime:\n>      type: int32_t\n>      description: |\n> Exposure time (shutter speed) for the frame applied in the sensor \n> device. This value is specified in micro-seconds.\n> '''\n> \n> How can I reference this file in the commit message ?\n\nI don't think you need to reference the file, just the fact that\nExposureTime and FrameDuration units are in micro-seconds, and so the\nDuration is cast accordingly.\n\n\n\n> >>> As sensorInfo is no longer used in updateSessionConfiguration remove the\n> >>> reference to it.\n> >>>\n> >>> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> >>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >>\n> >>\n> >> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> >>\n> >>> ---\n> >>>    src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n> >>>    1 file changed, 13 insertions(+), 16 deletions(-)\n> >>>\n> >>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> >>> index d3195de6..f1597f78 100644\n> >>> --- a/src/ipa/ipu3/ipu3.cpp\n> >>> +++ b/src/ipa/ipu3/ipu3.cpp\n> >>> @@ -148,8 +148,7 @@ private:\n> >>>        void updateControls(const IPACameraSensorInfo &sensorInfo,\n> >>>                            const ControlInfoMap &sensorControls,\n> >>>                            ControlInfoMap *ipaControls);\n> >>> -     void updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> >>> -                                     const ControlInfoMap &sensorControls);\n> >>> +     void updateSessionConfiguration(const ControlInfoMap &sensorControls);\n> >>>        void processControls(unsigned int frame, const ControlList &controls);\n> >>>        void fillParams(unsigned int frame, ipu3_uapi_params *params);\n> >>>        void parseStatistics(unsigned int frame,\n> >>> @@ -174,6 +173,8 @@ private:\n> >>>        uint32_t minGain_;\n> >>>        uint32_t maxGain_;\n> >>>    \n> >>> +     utils::Duration lineDuration_;\n> >>> +\n> >>>        /* Interface to the Camera Helper */\n> >>>        std::unique_ptr<CameraSensorHelper> camHelper_;\n> >>>    \n> >>> @@ -188,16 +189,12 @@ private:\n> >>>     * \\brief Compute IPASessionConfiguration using the sensor information and the\n> >>>     * sensor V4L2 controls\n> >>>     */\n> >>> -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> >>> -                                      const ControlInfoMap &sensorControls)\n> >>> +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n> >>>    {\n> >>>        const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> >>>        int32_t minExposure = v4l2Exposure.min().get<int32_t>();\n> >>>        int32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n> >>>    \n> >>> -     utils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n> >>> -                                  / sensorInfo.pixelRate;\n> >>> -\n> >>>        const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n> >>>        int32_t minGain = v4l2Gain.min().get<int32_t>();\n> >>>        int32_t maxGain = v4l2Gain.max().get<int32_t>();\n> >>> @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> >>>         *\n> >>>         * \\todo take VBLANK into account for maximum shutter speed\n> >>>         */\n> >>> -     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n> >>> -     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n> >>> +     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n> >>> +     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n> >>>        context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n> >>>        context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n> >>>    }\n> >>> @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n> >>>         * exposure min, max and default and convert it from lines to\n> >>>         * microseconds.\n> >>>         */\n> >>> -     double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n> >>>        const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> >>> -     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n> >>> -     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n> >>> -     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n> >>> +     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n> >>> +     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n> >>> +     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n> >>>        controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n> >>>                                                        defExposure);\n> >>>    \n> >>> @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n> >>>    \n> >>>        calculateBdsGrid(configInfo.bdsOutputSize);\n> >>>    \n> >>> +     lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n> >>> +\n> >>>        /* Update the camera controls using the new sensor settings. */\n> >>>        updateControls(sensorInfo_, ctrls_, ipaControls);\n> >>>    \n> >>>        /* Update the IPASessionConfiguration using the sensor settings. */\n> >>> -     updateSessionConfiguration(sensorInfo_, ctrls_);\n> >>> +     updateSessionConfiguration(ctrls_);\n> >>>    \n> >>>        for (auto const &algo : algorithms_) {\n> >>>                int ret = algo->configure(context_, configInfo);\n> >>> @@ -627,8 +625,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n> >>>        setControls(frame);\n> >>>    \n> >>>        /* \\todo Use VBlank value calculated from each frame exposure. */\n> >>> -     int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n> >>> -                             (sensorInfo_.pixelRate / 1e6);\n> >>> +     int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n> >>>        ctrls.set(controls::FrameDuration, frameDuration);\n> >>>    \n> >>>        ctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);","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 43D16BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 16:19:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6CC126036B;\n\tFri, 12 Nov 2021 17:19:13 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 141AF6032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 17:19:11 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F506268;\n\tFri, 12 Nov 2021 17:19:10 +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=\"whV/oEm0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636733950;\n\tbh=gBZVyPZXAx+t+hVu6tJvAMc5k6LmysS21W4qY+LXWmA=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=whV/oEm0Oihq3d5ubhWyJiBgNfDerUdaaZhR000drmubsYx5V33x8XFjJThMjYmF5\n\t+vd+1GvQ93MkBVgwl88g9usxkQfCtVKdSilj51bDU8Wm19/puDumd/9IKcTUhWbrbo\n\tZ+S2XammvWUNh7oKp6MUVfR2sLWADzIAgOlu3YtQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>\n\t<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>\n\t<163672329165.2717916.4266256988414093364@Monstersaurus>\n\t<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 12 Nov 2021 16:19:08 +0000","Message-ID":"<163673394825.2728118.649256022109016746@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20928,"web_url":"https://patchwork.libcamera.org/comment/20928/","msgid":"<f400d701-31b9-6fd8-a8fa-3fbc4a276c94@ideasonboard.com>","date":"2021-11-12T16:44:08","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"On 12/11/2021 17:19, Kieran Bingham wrote:\n> Quoting Jean-Michel Hautbois (2021-11-12 16:03:53)\n>> Hi Kieran,\n>>\n>> On 12/11/2021 14:21, Kieran Bingham wrote:\n>>> Quoting Umang Jain (2021-11-12 12:36:21)\n>>>> Hi JM,\n>>>>\n>>>> On 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n>>>>> We use the line duration several times in the IPAIPU3. Instead of\n>>>>> recalculating it each time, cache the value as a utils::Duration. When\n>>>>> the value is needed, cast it to a std::micro value.\n>>>\n>>> Aren't values always 'needed' when they're obtained? This isn't quite\n>>> helping improve the clarity.\n>>>\n>>> Why is it needed in micros, vs other usages?\n>>\n>> OK, I may have to specify it is documented in\n>> src/libcamera/control_ids.yaml ?\n>>\n>> '''\n>> - ExposureTime:\n>>       type: int32_t\n>>       description: |\n>> Exposure time (shutter speed) for the frame applied in the sensor\n>> device. This value is specified in micro-seconds.\n>> '''\n>>\n>> How can I reference this file in the commit message ?\n> \n> I don't think you need to reference the file, just the fact that\n> ExposureTime and FrameDuration units are in micro-seconds, and so the\n> Duration is cast accordingly.\n\nThanks,\n\n'''\nWe use the line duration several times in the IPAIPU3. Instead of\nrecalculating it each time, cache the value as a utils::Duration.\nExposureTime and FrameDuration units are in micro-seconds, cast the\nDuration accordingly.\n\nAs sensorInfo is no longer used in updateSessionConfiguration remove the\nreference to it.\n'''\n\n> \n> \n> \n>>>>> As sensorInfo is no longer used in updateSessionConfiguration remove the\n>>>>> reference to it.\n>>>>>\n>>>>> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>>>>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>>>\n>>>>\n>>>> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n>>>>\n>>>>> ---\n>>>>>     src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n>>>>>     1 file changed, 13 insertions(+), 16 deletions(-)\n>>>>>\n>>>>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n>>>>> index d3195de6..f1597f78 100644\n>>>>> --- a/src/ipa/ipu3/ipu3.cpp\n>>>>> +++ b/src/ipa/ipu3/ipu3.cpp\n>>>>> @@ -148,8 +148,7 @@ private:\n>>>>>         void updateControls(const IPACameraSensorInfo &sensorInfo,\n>>>>>                             const ControlInfoMap &sensorControls,\n>>>>>                             ControlInfoMap *ipaControls);\n>>>>> -     void updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>>>> -                                     const ControlInfoMap &sensorControls);\n>>>>> +     void updateSessionConfiguration(const ControlInfoMap &sensorControls);\n>>>>>         void processControls(unsigned int frame, const ControlList &controls);\n>>>>>         void fillParams(unsigned int frame, ipu3_uapi_params *params);\n>>>>>         void parseStatistics(unsigned int frame,\n>>>>> @@ -174,6 +173,8 @@ private:\n>>>>>         uint32_t minGain_;\n>>>>>         uint32_t maxGain_;\n>>>>>     \n>>>>> +     utils::Duration lineDuration_;\n>>>>> +\n>>>>>         /* Interface to the Camera Helper */\n>>>>>         std::unique_ptr<CameraSensorHelper> camHelper_;\n>>>>>     \n>>>>> @@ -188,16 +189,12 @@ private:\n>>>>>      * \\brief Compute IPASessionConfiguration using the sensor information and the\n>>>>>      * sensor V4L2 controls\n>>>>>      */\n>>>>> -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>>>> -                                      const ControlInfoMap &sensorControls)\n>>>>> +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\n>>>>>     {\n>>>>>         const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n>>>>>         int32_t minExposure = v4l2Exposure.min().get<int32_t>();\n>>>>>         int32_t maxExposure = v4l2Exposure.max().get<int32_t>();\n>>>>>     \n>>>>> -     utils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n>>>>> -                                  / sensorInfo.pixelRate;\n>>>>> -\n>>>>>         const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;\n>>>>>         int32_t minGain = v4l2Gain.min().get<int32_t>();\n>>>>>         int32_t maxGain = v4l2Gain.max().get<int32_t>();\n>>>>> @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>>>>>          *\n>>>>>          * \\todo take VBLANK into account for maximum shutter speed\n>>>>>          */\n>>>>> -     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n>>>>> -     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n>>>>> +     context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n>>>>> +     context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n>>>>>         context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>>>>>         context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>>>>>     }\n>>>>> @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n>>>>>          * exposure min, max and default and convert it from lines to\n>>>>>          * microseconds.\n>>>>>          */\n>>>>> -     double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n>>>>>         const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n>>>>> -     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n>>>>> -     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n>>>>> -     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n>>>>> +     int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n>>>>> +     int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n>>>>> +     int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n>>>>>         controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n>>>>>                                                         defExposure);\n>>>>>     \n>>>>> @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>>>>>     \n>>>>>         calculateBdsGrid(configInfo.bdsOutputSize);\n>>>>>     \n>>>>> +     lineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n>>>>> +\n>>>>>         /* Update the camera controls using the new sensor settings. */\n>>>>>         updateControls(sensorInfo_, ctrls_, ipaControls);\n>>>>>     \n>>>>>         /* Update the IPASessionConfiguration using the sensor settings. */\n>>>>> -     updateSessionConfiguration(sensorInfo_, ctrls_);\n>>>>> +     updateSessionConfiguration(ctrls_);\n>>>>>     \n>>>>>         for (auto const &algo : algorithms_) {\n>>>>>                 int ret = algo->configure(context_, configInfo);\n>>>>> @@ -627,8 +625,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n>>>>>         setControls(frame);\n>>>>>     \n>>>>>         /* \\todo Use VBlank value calculated from each frame exposure. */\n>>>>> -     int64_t frameDuration = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n>>>>> -                             (sensorInfo_.pixelRate / 1e6);\n>>>>> +     int64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n>>>>>         ctrls.set(controls::FrameDuration, frameDuration);\n>>>>>     \n>>>>>         ctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);","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 D897EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 16:44:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B0AD6036B;\n\tFri, 12 Nov 2021 17:44:14 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 643B86032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 17:44:12 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:61e2:b805:836d:e891] (unknown\n\t[IPv6:2a01:e0a:169:7140:61e2:b805:836d:e891])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 017724A6;\n\tFri, 12 Nov 2021 17:44:11 +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=\"ciQGx5/T\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636735452;\n\tbh=86Uv5Je7MpHOVhvjd/UxK5CGuJVOrhucYdcaV/jIURI=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=ciQGx5/T2gU1TQp1ul0uqjg0c/zJ1eFXi/u89IZgaDTZZSuNeC/9cKB3GMG9R4Ap0\n\tUCL5UxKJAxzbLpi2De1ZxwfzK3k+4EkSUjmvyB24CdWPdckZJ53W9RjKH1ju2qW3Ll\n\tQ3TYmqPlTE2A5MDIshTF0+p0jafbjClDQ4L+n1s0=","Message-ID":"<f400d701-31b9-6fd8-a8fa-3fbc4a276c94@ideasonboard.com>","Date":"Fri, 12 Nov 2021 17:44:08 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.2.1","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>\n\t<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>\n\t<163672329165.2717916.4266256988414093364@Monstersaurus>\n\t<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>\n\t<163673394825.2728118.649256022109016746@Monstersaurus>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","In-Reply-To":"<163673394825.2728118.649256022109016746@Monstersaurus>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20929,"web_url":"https://patchwork.libcamera.org/comment/20929/","msgid":"<163673844785.2728118.554902271233569408@Monstersaurus>","date":"2021-11-12T17:34:07","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jean-Michel Hautbois (2021-11-12 16:44:08)\n> \n> \n> On 12/11/2021 17:19, Kieran Bingham wrote:\n> > Quoting Jean-Michel Hautbois (2021-11-12 16:03:53)\n> >> Hi Kieran,\n> >>\n> >> On 12/11/2021 14:21, Kieran Bingham wrote:\n> >>> Quoting Umang Jain (2021-11-12 12:36:21)\n> >>>> Hi JM,\n> >>>>\n> >>>> On 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n> >>>>> We use the line duration several times in the IPAIPU3. Instead of\n> >>>>> recalculating it each time, cache the value as a utils::Duration. When\n> >>>>> the value is needed, cast it to a std::micro value.\n> >>>\n> >>> Aren't values always 'needed' when they're obtained? This isn't quite\n> >>> helping improve the clarity.\n> >>>\n> >>> Why is it needed in micros, vs other usages?\n> >>\n> >> OK, I may have to specify it is documented in\n> >> src/libcamera/control_ids.yaml ?\n> >>\n> >> '''\n> >> - ExposureTime:\n> >>       type: int32_t\n> >>       description: |\n> >> Exposure time (shutter speed) for the frame applied in the sensor\n> >> device. This value is specified in micro-seconds.\n> >> '''\n> >>\n> >> How can I reference this file in the commit message ?\n> > \n> > I don't think you need to reference the file, just the fact that\n> > ExposureTime and FrameDuration units are in micro-seconds, and so the\n> > Duration is cast accordingly.\n> \n> Thanks,\n> \n> '''\n> We use the line duration several times in the IPAIPU3. Instead of\n> recalculating it each time, cache the value as a utils::Duration.\n> ExposureTime and FrameDuration units are in micro-seconds, cast the\n> Duration accordingly.\n> \n> As sensorInfo is no longer used in updateSessionConfiguration remove the\n> reference to it.\n> '''\n\nWorks for me!\n\nThanks,\nKieran","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 3A926BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 17:34:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69AC26036B;\n\tFri, 12 Nov 2021 18:34:12 +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 1542C6032C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 18:34:11 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 98487D6E;\n\tFri, 12 Nov 2021 18:34:10 +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=\"wIVFdgkv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636738450;\n\tbh=c61lZwguCFYHioOaYRO3PtCGAQTPiHYpm4FIs8m6aSU=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=wIVFdgkvNEgg1F5+3FqcOUa6SdLgcYBPXmNKrPmf4yGMWBEMjmjN/T6Y3CQZjTg9z\n\tfNtmIH6y9Z13aNJpK4LjOaOum3BFRm5qMIjXMjPuYRvHqruq7Ch5Thfzv+Zq2KMw/G\n\tppn1ReOMqHoY4TD6x6FmvRnylY9DaDh0QmtcjKhw=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<f400d701-31b9-6fd8-a8fa-3fbc4a276c94@ideasonboard.com>","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>\n\t<0475f262-c196-7182-ef3e-922156f8fdd2@ideasonboard.com>\n\t<163672329165.2717916.4266256988414093364@Monstersaurus>\n\t<ccf4f18b-710b-284c-b40b-d94680608e43@ideasonboard.com>\n\t<163673394825.2728118.649256022109016746@Monstersaurus>\n\t<f400d701-31b9-6fd8-a8fa-3fbc4a276c94@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 12 Nov 2021 17:34:07 +0000","Message-ID":"<163673844785.2728118.554902271233569408@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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":20940,"web_url":"https://patchwork.libcamera.org/comment/20940/","msgid":"<20211112232243.GJ8453@jade.amanokami.net>","date":"2021-11-12T23:22:43","subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nOn Thu, Nov 11, 2021 at 03:09:26PM +0100, Jean-Michel Hautbois wrote:\n> We use the line duration several times in the IPAIPU3. Instead of\n> recalculating it each time, cache the value as a utils::Duration. When\n> the value is needed, cast it to a std::micro value.\n> \n> As sensorInfo is no longer used in updateSessionConfiguration remove the\n> reference to it.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n>  1 file changed, 13 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index d3195de6..f1597f78 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -148,8 +148,7 @@ private:\n>  \tvoid updateControls(const IPACameraSensorInfo &sensorInfo,\n>  \t\t\t    const ControlInfoMap &sensorControls,\n>  \t\t\t    ControlInfoMap *ipaControls);\n> -\tvoid updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> -\t\t\t\t\tconst ControlInfoMap &sensorControls);\n> +\tvoid updateSessionConfiguration(const ControlInfoMap &sensorControls);\n>  \tvoid processControls(unsigned int frame, const ControlList &controls);\n>  \tvoid fillParams(unsigned int frame, ipu3_uapi_params *params);\n>  \tvoid parseStatistics(unsigned int frame,\n> @@ -174,6 +173,8 @@ private:\n>  \tuint32_t minGain_;\n>  \tuint32_t maxGain_;\n>  \n> +\tutils::Duration lineDuration_;\n> +\n>  \t/* Interface to the Camera Helper */\n>  \tstd::unique_ptr<CameraSensorHelper> camHelper_;\n>  \n> @@ -188,16 +189,12 @@ private:\n>   * \\brief Compute IPASessionConfiguration using the sensor information and the\n>   * sensor V4L2 controls\n>   */\n> -void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n> -\t\t\t\t\t const ControlInfoMap &sensorControls)\n> +void IPAIPU3::updateSessionConfiguration(const ControlInfoMap &sensorControls)\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>  \n> -\tutils::Duration lineDuration = sensorInfo.lineLength * 1.0s\n> -\t\t\t\t     / sensorInfo.pixelRate;\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> @@ -209,8 +206,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,\n>  \t *\n>  \t * \\todo take VBLANK into account for maximum shutter speed\n>  \t */\n> -\tcontext_.configuration.agc.minShutterSpeed = minExposure * lineDuration;\n> -\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;\n> +\tcontext_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;\n> +\tcontext_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;\n>  \tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>  \tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>  }\n> @@ -239,11 +236,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n>  \t * exposure min, max and default and convert it from lines to\n>  \t * microseconds.\n>  \t */\n> -\tdouble lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n>  \tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> -\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n> -\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n> -\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n> +\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.get<std::micro>();\n> +\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.get<std::micro>();\n> +\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.get<std::micro>();\n>  \tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n>  \t\t\t\t\t\t\tdefExposure);\n>  \n> @@ -463,11 +459,13 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>  \n>  \tcalculateBdsGrid(configInfo.bdsOutputSize);\n>  \n> +\tlineDuration_ = sensorInfo_.lineLength * 1.0s / sensorInfo_.pixelRate;\n> +\n>  \t/* Update the camera controls using the new sensor settings. */\n>  \tupdateControls(sensorInfo_, ctrls_, ipaControls);\n>  \n>  \t/* Update the IPASessionConfiguration using the sensor settings. */\n> -\tupdateSessionConfiguration(sensorInfo_, ctrls_);\n> +\tupdateSessionConfiguration(ctrls_);\n>  \n>  \tfor (auto const &algo : algorithms_) {\n>  \t\tint ret = algo->configure(context_, configInfo);\n> @@ -627,8 +625,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 = sensorInfo_.lineLength * (defVBlank_ + sensorInfo_.outputSize.height) /\n> -\t\t\t\t(sensorInfo_.pixelRate / 1e6);\n> +\tint64_t frameDuration = (defVBlank_ + sensorInfo_.outputSize.height) * lineDuration_.get<std::micro>();\n>  \tctrls.set(controls::FrameDuration, frameDuration);\n>  \n>  \tctrls.set(controls::ColourTemperature, context_.frameContext.awb.temperatureK);\n> -- \n> 2.32.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 CFBC6BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 23:22:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 79C856036B;\n\tSat, 13 Nov 2021 00:22:55 +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 55CDD600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Nov 2021 00:22:53 +0100 (CET)","from jade.amanokami.net (KD027085206038.au-net.ne.jp\n\t[27.85.206.38])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3F3D39CA;\n\tSat, 13 Nov 2021 00:22:50 +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=\"hRw9OBXS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636759373;\n\tbh=kleJ+1P02v27g1vkkeSLAvfJEgS5s2f9TXZ0KWfAIeE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hRw9OBXSWmIhPxF+IuooicnWvU3fVGe8aoDBS85Rq2h9FBOiU5tBuk92mSFroF8Dl\n\tv8UXVUgtz60gaY4Z2PTWstzqcR1aFZejm75TRxmz543rYcF/6bJkSZL7aY6CizlkHM\n\txjE78YvqZXVGwtcaTjmrUCclk338gwuYvPC1qqwQ=","Date":"Sat, 13 Nov 2021 08:22:43 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<20211112232243.GJ8453@jade.amanokami.net>","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20211111140928.136111-13-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 12/14] ipa: ipu3: Cache line\n\tduration at configure call","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]