From 75c14908271d44edac3b7c8d0f94501a3c93477e Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Tue, 8 Jun 2021 13:12:25 +0530 Subject: ipa: ipu3: Calculate frame duration from minimum VBLANK value 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 at least head in the right direction by not hard coding the value, instead using the default VBLANK value as reported by 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 Tested-by: Paul Elder Tested-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Reviewed-by: Jean-Michel Hautbois Reviewed-by: Paul Elder --- src/ipa/ipu3/ipu3.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 97ddb863..415ea9e5 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -66,6 +66,7 @@ private: IPACameraSensorInfo sensorInfo_; /* Camera sensor controls. */ + uint32_t defVBlank_; uint32_t exposure_; uint32_t minExposure_; uint32_t maxExposure_; @@ -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_; + defVBlank_ = itVBlank->second.def().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 * (defVBlank_ + sensorInfo_.outputSize.height) / + (sensorInfo_.pixelRate / 1e6); + ctrls.set(controls::FrameDuration, frameDuration); IPU3Action op; op.op = ActionMetadataReady; -- cgit v1.2.1