{"id":12487,"url":"https://patchwork.libcamera.org/api/patches/12487/?format=json","web_url":"https://patchwork.libcamera.org/patch/12487/","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":"<20210602102326.106549-5-umang.jain@ideasonboard.com>","date":"2021-06-02T10:23:26","name":"[libcamera-devel,4/4] ipa: ipu3: Calculate frame duration from minimum VBLANK value","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"19863d76071c0fbcfbda0a600dfbf54d211edf9a","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12487/mbox/","series":[{"id":2100,"url":"https://patchwork.libcamera.org/api/series/2100/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2100","date":"2021-06-02T10:23:22","name":"IPAIPU3 drive-by improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/2100/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12487/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12487/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 1F170C3208\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Jun 2021 10:23:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D81586892B;\n\tWed,  2 Jun 2021 12:23:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08A746050E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Jun 2021 12:23:45 +0200 (CEST)","from perceval.ideasonboard.com (unknown [103.251.226.189])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B99A84A5;\n\tWed,  2 Jun 2021 12:23:43 +0200 (CEST)"],"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=\"nfFLhFGI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622629424;\n\tbh=3bodz/Xb60Bp4G5y8TSCgkIFH0+0FqaPBMaUFAl8tw0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=nfFLhFGIq9uUa/+ge7xIVh2vK5MYJfivVPcaoRCTR7lAXuAcqB6ZHosz+u84cSIxB\n\tJVSFdyIhyYDzCIGJdhUZQZjAIM6z3/mcnH4AZa7gBE3kVIqdUcuQbTVlDU2TOYH5Xm\n\tPaQeyhWMQJYggb0exA6/NC9/opg7BWgjpTNM0IMo=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  2 Jun 2021 15:53:26 +0530","Message-Id":"<20210602102326.106549-5-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210602102326.106549-1-umang.jain@ideasonboard.com>","References":"<20210602102326.106549-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 4/4] ipa: ipu3: Calculate frame duration\n\tfrom minimum VBLANK value","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":"Frame duration is hard-coded for CTS as per [1]. Ideally, to accurately\ncalculate the frame duration, it needs the VBLANK value from every\nframe's exposure. However, this particular bit is yet to be implemented\nin IPAIPU3.\n\nMeanwhile, we can atleast head in the right direction by not hard\ncoding the value, instead using the minimum VBLANK value as reported\nthe sensor. Update the existing \\todo, to use the derived VBLANK value\nas and when it's available from each frame exposure.\n\n[1] 6c5f3fe6ced7 (\"ipa: ipu3: Set output frame duration metadata\")\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n\nFor reference, on `nautilus`:\n- minVBlank_ was reported as '104'\n- Calculating frame-duration using minVBlank_ came out to be: 34041\n\n---\n src/ipa/ipu3/ipu3.cpp | 16 +++++++++++++---\n 1 file changed, 13 insertions(+), 3 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 97ddb863..db4ec684 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -72,6 +72,7 @@ private:\n \tuint32_t gain_;\n \tuint32_t minGain_;\n \tuint32_t maxGain_;\n+\tuint32_t minVBlank_;\n \n \t/* Interface to the AWB algorithm */\n \tstd::unique_ptr<IPU3Awb> awbAlgo_;\n@@ -162,6 +163,12 @@ void IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \t\treturn;\n \t}\n \n+\tconst auto itVBlank = ctrls_.find(V4L2_CID_VBLANK);\n+\tif (itVBlank == ctrls_.end()) {\n+\t\tLOG(IPAIPU3, Error) << \"Can't find VBLANK control\";\n+\t\treturn;\n+\t}\n+\n \tminExposure_ = std::max(itExp->second.min().get<int32_t>(), 1);\n \tmaxExposure_ = itExp->second.max().get<int32_t>();\n \texposure_ = minExposure_;\n@@ -170,6 +177,8 @@ void IPAIPU3::configure(const IPAConfigInfo &configInfo)\n \tmaxGain_ = itGain->second.max().get<int32_t>();\n \tgain_ = minGain_;\n \n+\tminVBlank_ = itVBlank->second.min().get<int32_t>();\n+\n \tparams_ = {};\n \n \tcalculateBdsGrid(configInfo.bdsOutputSize);\n@@ -273,9 +282,10 @@ void IPAIPU3::parseStatistics(unsigned int frame,\n \tif (agcAlgo_->updateControls())\n \t\tsetControls(frame);\n \n-\t/* \\todo Populate this with real values */\n-\tctrls.set(controls::FrameDuration,\n-\t\t  static_cast<int64_t>(33334));\n+\t/* \\todo Use VBlank value calculated from each frame exposure. */\n+\tint64_t frameDuration = sensorInfo_.lineLength * (minVBlank_ + sensorInfo_.outputSize.height) /\n+\t\t\t\t(sensorInfo_.pixelRate / 1e6);\n+\tctrls.set(controls::FrameDuration, frameDuration);\n \n \tIPU3Action op;\n \top.op = ActionMetadataReady;\n","prefixes":["libcamera-devel","4/4"]}