{"id":14568,"url":"https://patchwork.libcamera.org/api/1.1/patches/14568/?format=json","web_url":"https://patchwork.libcamera.org/patch/14568/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211111110605.105202-13-jeanmichel.hautbois@ideasonboard.com>","date":"2021-11-11T11:06:03","name":"[libcamera-devel,v3,12/14] ipa: ipu3: Cache line duration at configure call","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6069b48fb54a902b5c3f4dafb121432bdf85ec71","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14568/mbox/","series":[{"id":2713,"url":"https://patchwork.libcamera.org/api/1.1/series/2713/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2713","date":"2021-11-11T11:05:51","name":"IPA: IPU3: Introduce per-frame controls","version":3,"mbox":"https://patchwork.libcamera.org/series/2713/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14568/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14568/checks/","tags":{},"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 7B67EC324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Nov 2021 11:06:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 350996037A;\n\tThu, 11 Nov 2021 12:06:24 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB68C6038C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 12:06:11 +0100 (CET)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:e627:8337:a781:d98])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9836F1543;\n\tThu, 11 Nov 2021 12:06:11 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Fg9PDOI9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636628771;\n\tbh=Ibcoz8ZT0qS7NH3RAzlzA1DrCQiVsEEY+1t0CHwxd2Y=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Fg9PDOI9sLYr8qMvLzVFFJ5gH8gM3PDLSCOkLRFgxY2fFgh1GY6W0LN+5ByDEs+9d\n\tEeW55kwKtQ5HL9pEh/Vht0cfeILGdQe2mtbO+RM9A3m/5x/DuCY/iv+Gw2K+XEXmAd\n\tPL+8bwXPPVM1m9EqduynoEbivNwl1VomGoghQnQM=","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 11 Nov 2021 12:06:03 +0100","Message-Id":"<20211111110605.105202-13-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211111110605.105202-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20211111110605.105202-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 12/14] ipa: ipu3: Cache line duration\n\tat 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>"},"content":"We use the line duration several times in the IPAIPU3. Instead of\nrecalculating it each time, cache the value as a utils::Duration. When\nthe value is needed in double, cast it to a std::micro value.\n\nAs sensorInfo is no longer used in updateSessionConfiguration remove the\nreference to it.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/ipu3.cpp | 29 +++++++++++++----------------\n 1 file changed, 13 insertions(+), 16 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 7762c5ec..3c1aa5ad 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@@ -628,8 +626,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","prefixes":["libcamera-devel","v3","12/14"]}