[libcamera-devel] [PATCH v2 12/14] ipa: ipu3: Cache line duration at configure call

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Wed Nov 10 20:58:59 CET 2021


We use the line duration several times in the IPAIPU3. Instead of
recalculating it each time, cache the value as a utils::Duration. When
the value is needed in double, call the intern count() function to get
it.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
 src/ipa/ipu3/ipu3.cpp | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index eb8c0dc4..68a97e8e 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -174,6 +174,8 @@ private:
 	uint32_t minGain_;
 	uint32_t maxGain_;
 
+	utils::Duration lineDuration_;
+
 	/* Interface to the Camera Helper */
 	std::unique_ptr<CameraSensorHelper> camHelper_;
 
@@ -195,8 +197,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,
 	int32_t minExposure = v4l2Exposure.min().get<int32_t>();
 	int32_t maxExposure = v4l2Exposure.max().get<int32_t>();
 
-	utils::Duration lineDuration = sensorInfo.lineLength * 1.0s
-				     / sensorInfo.pixelRate;
+	lineDuration_ = sensorInfo.lineLength * 1.0s
+		      / sensorInfo.pixelRate;
 
 	const ControlInfo &v4l2Gain = sensorControls.find(V4L2_CID_ANALOGUE_GAIN)->second;
 	int32_t minGain = v4l2Gain.min().get<int32_t>();
@@ -209,8 +211,8 @@ void IPAIPU3::updateSessionConfiguration(const IPACameraSensorInfo &sensorInfo,
 	 *
 	 * \todo take VBLANK into account for maximum shutter speed
 	 */
-	context_.configuration.agc.minShutterSpeed = minExposure * lineDuration;
-	context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration;
+	context_.configuration.agc.minShutterSpeed = minExposure * lineDuration_;
+	context_.configuration.agc.maxShutterSpeed = maxExposure * lineDuration_;
 	context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);
 	context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);
 }
@@ -239,11 +241,10 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo,
 	 * exposure min, max and default and convert it from lines to
 	 * microseconds.
 	 */
-	double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);
 	const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
-	int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;
-	int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;
-	int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;
+	int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration_.count();
+	int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration_.count();
+	int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration_.count();
 	controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,
 							defExposure);
 
-- 
2.32.0



More information about the libcamera-devel mailing list