[libcamera-devel] [IPAIPU3 PATCH v5 6/6] ipa: ipu3: Inline parseStatistics() into processStatsBuffer()

Umang Jain umang.jain at ideasonboard.com
Wed Apr 6 16:17:09 CEST 2022


Since we have moved away from switch/case on the operation ID,
there's little reason to split the operation in two functions.

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 ipu3.cpp | 74 ++++++++++++++++++++++++--------------------------------
 1 file changed, 31 insertions(+), 43 deletions(-)

diff --git a/ipu3.cpp b/ipu3.cpp
index 0543a2e..7ecd377 100644
--- a/ipu3.cpp
+++ b/ipu3.cpp
@@ -60,10 +60,6 @@ private:
 			    const ControlInfoMap &sensorControls,
 			    ControlInfoMap *ipaControls);
 	void runAiq(unsigned int frame);
-	void parseStatistics(unsigned int frame,
-			     int64_t frameTimestamp,
-			     const ipu3_uapi_stats_3a *stats,
-			     const ControlList& sensorCtrls);
 
 	void setControls(unsigned int frame);
 
@@ -379,43 +375,6 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimest
 	const ipu3_uapi_stats_3a *stats =
 		reinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());
 
-	parseStatistics(frame, frameTimestamp, stats, sensorControls);
-}
-
-void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
-{
-	/* Run algorithms into/using this context structure */
-	resultsHistory_.extendOne();
-	aiq::AiqResults& latestResults = resultsHistory_.latest();
-
-	/* Todo: Refactor AiqInputParameters interface to set following parameters. */
-	aiqInputParams_.afParams.lens_position = lensPosition_;
-	aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;
-
-	aiq_.run2a(frame, aiqInputParams_, latestResults);
-
-	exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;
-	gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
-
-	/*
-	 * Af algorithm compares the timestamp of start of the lens movement and
-	 * that of the statistics generated to estimate whether next lens
-	 * position should be produced.
-	 * \todo use the lens movement start time reported by the pipeline handler.
-	 */
-	if (lensPosition_ != latestResults.af()->next_lens_position) {
-		utils::time_point time = utils::clock::now();
-		uint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();
-		lensMovementStartTime_ = usecs;
-	}
-	lensPosition_ = latestResults.af()->next_lens_position;
-}
-
-void IPAIPU3::parseStatistics(unsigned int frame,
-			      int64_t frameTimestamp,
-			      const ipu3_uapi_stats_3a *stats,
-			      const ControlList& sensorCtrls)
-{
 	ControlList ctrls(controls::controls);
 
 	/* \todo React to statistics and update internal state machine. */
@@ -438,11 +397,11 @@ void IPAIPU3::parseStatistics(unsigned int frame,
 	int32_t effectiveGain = 0;
 	ControlValue ctrlValue;
 
-	ctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE);
+	ctrlValue = sensorControls.get(V4L2_CID_EXPOSURE);
 	if (!ctrlValue.isNone())
 		effectiveExpo = ctrlValue.get<int32_t>();
 
-	ctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN);
+	ctrlValue = sensorControls.get(V4L2_CID_ANALOGUE_GAIN);
 	if (!ctrlValue.isNone())
 		effectiveGain = ctrlValue.get<int32_t>();
 
@@ -472,6 +431,35 @@ void IPAIPU3::parseStatistics(unsigned int frame,
 	metadataReady.emit(frame, ctrls);
 }
 
+void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)
+{
+	/* Run algorithms into/using this context structure */
+	resultsHistory_.extendOne();
+	aiq::AiqResults& latestResults = resultsHistory_.latest();
+
+	/* Todo: Refactor AiqInputParameters interface to set following parameters. */
+	aiqInputParams_.afParams.lens_position = lensPosition_;
+	aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;
+
+	aiq_.run2a(frame, aiqInputParams_, latestResults);
+
+	exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;
+	gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;
+
+	/*
+	 * Af algorithm compares the timestamp of start of the lens movement and
+	 * that of the statistics generated to estimate whether next lens
+	 * position should be produced.
+	 * \todo use the lens movement start time reported by the pipeline handler.
+	 */
+	if (lensPosition_ != latestResults.af()->next_lens_position) {
+		utils::time_point time = utils::clock::now();
+		uint64_t usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();
+		lensMovementStartTime_ = usecs;
+	}
+	lensPosition_ = latestResults.af()->next_lens_position;
+}
+
 void IPAIPU3::setControls(unsigned int frame)
 {
 	ControlList sensorCtrls(ctrls_);
-- 
2.31.0



More information about the libcamera-devel mailing list