[libcamera-devel] [PATCH 08/22] ipa: ipu3: agc: Update previous exposure value

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Mon Nov 8 14:13:36 CET 2021


Previous exposure value is calculated based on the estimated shutter
time and gain applied. Now that we have the real values for the current
frame, use those before estimating the next one.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
 src/ipa/ipu3/algorithms/agc.cpp | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index e4048d40..475e715f 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -193,15 +193,12 @@ void Agc::computeExposure(uint32_t &exposure, double &analogueGain, double curre
 	/* Estimate the gain needed to have the proportion wanted */
 	double evGain = kEvGainTarget * knumHistogramBins / iqMean_;
 
-	if (std::abs(evGain - 1.0) < 0.01) {
-		LOG(IPU3Agc, Debug) << "We are well exposed (iqMean = "
-				    << iqMean_ << ")";
-		return;
-	}
-
 	/* extracted from Rpi::Agc::computeTargetExposure */
 	/* Calculate the shutter time in seconds */
 	utils::Duration currentShutter = exposure * lineDuration_;
+	/* Update the exposure value for the next computation. */
+	prevExposureValue_ = currentShutter * analogueGain;
+
 	LOG(IPU3Agc, Debug) << "Actual total exposure " << currentShutter * analogueGain
 			    << " Shutter speed " << currentShutter
 			    << " Gain " << analogueGain
@@ -250,16 +247,6 @@ void Agc::computeExposure(uint32_t &exposure, double &analogueGain, double curre
 
 	exposure = shutterTime / lineDuration_;
 	analogueGain = stepGain;
-
-	/*
-	 * Update the exposure value for the next process call.
-	 *
-	 * \todo Obtain the values of the exposure time and analog gain
-	 * that were actually used by the sensor, either from embedded
-	 * data when available, or from the delayed controls
-	 * infrastructure in case a slow down caused a mismatch.
-	 */
-	prevExposureValue_ = shutterTime * analogueGain;
 }
 
 /**
-- 
2.32.0



More information about the libcamera-devel mailing list