From patchwork Wed Jun 2 10:23:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 12487 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1F170C3208 for ; Wed, 2 Jun 2021 10:23:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D81586892B; Wed, 2 Jun 2021 12:23:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nfFLhFGI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 08A746050E for ; Wed, 2 Jun 2021 12:23:45 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.189]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B99A84A5; Wed, 2 Jun 2021 12:23:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1622629424; bh=3bodz/Xb60Bp4G5y8TSCgkIFH0+0FqaPBMaUFAl8tw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nfFLhFGIq9uUa/+ge7xIVh2vK5MYJfivVPcaoRCTR7lAXuAcqB6ZHosz+u84cSIxB JVSFdyIhyYDzCIGJdhUZQZjAIM6z3/mcnH4AZa7gBE3kVIqdUcuQbTVlDU2TOYH5Xm PaQeyhWMQJYggb0exA6/NC9/opg7BWgjpTNM0IMo= From: Umang Jain 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 Subject: [libcamera-devel] [PATCH 4/4] ipa: ipu3: Calculate frame duration from minimum VBLANK value X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Frame duration is hard-coded for CTS as per [1]. Ideally, to accurately calculate the frame duration, it needs the VBLANK value from every frame's exposure. However, this particular bit is yet to be implemented in IPAIPU3. Meanwhile, we can atleast head in the right direction by not hard coding the value, instead using the minimum VBLANK value as reported the sensor. Update the existing \todo, to use the derived VBLANK value as and when it's available from each frame exposure. [1] 6c5f3fe6ced7 ("ipa: ipu3: Set output frame duration metadata") Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Tested-by: Jean-Michel Hautbois --- For reference, on `nautilus`: - minVBlank_ was reported as '104' - Calculating frame-duration using minVBlank_ came out to be: 34041 --- src/ipa/ipu3/ipu3.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 97ddb863..db4ec684 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -72,6 +72,7 @@ private: uint32_t gain_; uint32_t minGain_; uint32_t maxGain_; + uint32_t minVBlank_; /* Interface to the AWB algorithm */ std::unique_ptr awbAlgo_; @@ -162,6 +163,12 @@ void IPAIPU3::configure(const IPAConfigInfo &configInfo) return; } + const auto itVBlank = ctrls_.find(V4L2_CID_VBLANK); + if (itVBlank == ctrls_.end()) { + LOG(IPAIPU3, Error) << "Can't find VBLANK control"; + return; + } + minExposure_ = std::max(itExp->second.min().get(), 1); maxExposure_ = itExp->second.max().get(); exposure_ = minExposure_; @@ -170,6 +177,8 @@ void IPAIPU3::configure(const IPAConfigInfo &configInfo) maxGain_ = itGain->second.max().get(); gain_ = minGain_; + minVBlank_ = itVBlank->second.min().get(); + params_ = {}; calculateBdsGrid(configInfo.bdsOutputSize); @@ -273,9 +282,10 @@ void IPAIPU3::parseStatistics(unsigned int frame, if (agcAlgo_->updateControls()) setControls(frame); - /* \todo Populate this with real values */ - ctrls.set(controls::FrameDuration, - static_cast(33334)); + /* \todo Use VBlank value calculated from each frame exposure. */ + int64_t frameDuration = sensorInfo_.lineLength * (minVBlank_ + sensorInfo_.outputSize.height) / + (sensorInfo_.pixelRate / 1e6); + ctrls.set(controls::FrameDuration, frameDuration); IPU3Action op; op.op = ActionMetadataReady;