{"id":13556,"url":"https://patchwork.libcamera.org/api/patches/13556/?format=json","web_url":"https://patchwork.libcamera.org/patch/13556/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20210827120757.110615-17-jacopo@jmondi.org>","date":"2021-08-27T12:07:57","name":"[libcamera-devel,16/16] ipa: ipu3: Cap frame duration to 30 FPS","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"befd16605f950b765147385f667603b19c0ed182","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13556/mbox/","series":[{"id":2410,"url":"https://patchwork.libcamera.org/api/series/2410/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2410","date":"2021-08-27T12:07:41","name":"IPU3 control info update and HAL frame durations","version":1,"mbox":"https://patchwork.libcamera.org/series/2410/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13556/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13556/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 A8279C324D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Aug 2021 12:08:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A35A568958;\n\tFri, 27 Aug 2021 14:07:31 +0200 (CEST)","from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DCD726893B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Aug 2021 14:07:27 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 36B0320007;\n\tFri, 27 Aug 2021 12:07:27 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 27 Aug 2021 14:07:57 +0200","Message-Id":"<20210827120757.110615-17-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20210827120757.110615-1-jacopo@jmondi.org>","References":"<20210827120757.110615-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 16/16] ipa: ipu3: Cap frame duration to 30\n\tFPS","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":"Limit the IPU3 frame rate to 30 FPS.\n\nThe reason to do is to bring the IPU3 IPA in par with the Intel\nHAL implementation on IPU3 platform, where 30FPS is the frame rate used\nto perform quality tuning in the closed-source IPA module and has been\nvalidated as the most efficient rate for the power/performace budget.\n\nCompute the vertical blanking to maintain such frame rate and configure\nthe sensor with that.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/ipa/ipu3/ipu3.cpp | 37 ++++++++++++++++++++++++++++++++-----\n 1 file changed, 32 insertions(+), 5 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex fc5f69ed5ddc..0e5d5e479e20 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -183,7 +183,7 @@ private:\n \tIPACameraSensorInfo sensorInfo_;\n \n \t/* Camera sensor controls. */\n-\tuint32_t defVBlank_;\n+\tuint32_t vBlank_;\n \tuint32_t exposure_;\n \tuint32_t minExposure_;\n \tuint32_t maxExposure_;\n@@ -257,10 +257,39 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,\n \t\tframeDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);\n \t}\n \n+\t/*\n+\t * Cap minimum frame duration to 30FPS.\n+\t *\n+\t * 30 FPS has been validated in the closed source Intel 3A module as the\n+\t * most opportune frame rate for quality tuning, and power\n+\t * vs performances budget on Intel IPU3.\n+\t *\n+\t * Reduce the minimum achievable frame rate to 30 FPS and compute the\n+\t * vertical blanking to maintain that rate.\n+\t */\n+\tint64_t *minFrameDuration = &frameDurations[0];\n+\tif (*minFrameDuration < 1e6 / 30.0)\n+\t\t*minFrameDuration = 1e6 / 30.0;\n+\n \tcontrols[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],\n \t\t\t\t\t\t\t       frameDurations[1],\n \t\t\t\t\t\t\t       frameDurations[2]);\n \n+\t/*\n+\t * Adjust the vertical blanking to obtain the desired frame duration.\n+\t *\n+\t * Assume a fixed line length as horizontal blanking is seldom\n+\t * controllable.\n+\t *\n+\t * \\todo Support making this overridable by the application through\n+\t * controls::FrameDuration.\n+\t *\n+\t * \\todo Clamp exposure to frame duration.\n+\t */\n+\tvBlank_ = *minFrameDuration * (sensorInfo.pixelRate / 1000000U);\n+\tvBlank_ /= lineLength;\n+\tvBlank_ -= sensorInfo.outputSize.height;\n+\n \t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n }\n \n@@ -399,8 +428,6 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \tmaxGain_ = itGain->second.max().get<int32_t>();\n \tgain_ = minGain_;\n \n-\tdefVBlank_ = itVBlank->second.def().get<int32_t>();\n-\n \t/* Clean context at configuration */\n \tcontext_ = {};\n \n@@ -511,8 +538,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n \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+\tint64_t frameDuration = sensorInfo_.lineLength * (vBlank_ + sensorInfo_.outputSize.height) /\n \t\t\t\t(sensorInfo_.pixelRate / 1e6);\n \tctrls.set(controls::FrameDuration, frameDuration);\n \n@@ -534,6 +560,7 @@ void IPAIPU3::setControls(unsigned int frame)\n \tControlList ctrls(ctrls_);\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_VBLANK, static_cast<int32_t>(vBlank_));\n \top.controls = ctrls;\n \n \tqueueFrameAction.emit(frame, op);\n","prefixes":["libcamera-devel","16/16"]}