[4/7] ipa: rpi: Advance the delay context counter even when IPAs don't run
diff mbox series

Message ID 20250617082956.5699-5-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Raspberry Pi AEC/AGC update
Related show

Commit Message

David Plowman June 17, 2025, 8:29 a.m. UTC
The delay context counter must be advanced even when we decide not to
run prepare/process. Otherwise, when we skip them at higher
framerates, the current IPA context counter will catch up and
overwrite the delay context.

It's safe to advance the counter because the metadata is always copied
forward a slot when we decide not to run the IPAs.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
---
 src/ipa/rpi/common/ipa_base.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp
index 05699228..7af4ea5e 100644
--- a/src/ipa/rpi/common/ipa_base.cpp
+++ b/src/ipa/rpi/common/ipa_base.cpp
@@ -491,10 +491,11 @@  void IpaBase::prepareIsp(const PrepareParams &params)
 void IpaBase::processStats(const ProcessParams &params)
 {
 	unsigned int ipaContext = params.ipaContext % rpiMetadata_.size();
+	RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];
 
-	if (processPending_ && frameCount_ >= mistrustCount_) {
-		RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext];
+	Duration offset(0s);
 
+	if (processPending_ && frameCount_ >= mistrustCount_) {
 		auto it = buffers_.find(params.buffers.stats);
 		if (it == buffers_.end()) {
 			LOG(IPARPI, Error) << "Could not find stats buffer!";
@@ -510,7 +511,6 @@  void IpaBase::processStats(const ProcessParams &params)
 		controller_.process(statistics, &rpiMetadata);
 
 		/* Send any sync algorithm outputs back to the pipeline handler */
-		Duration offset(0s);
 		struct SyncStatus syncStatus;
 		if (rpiMetadata.get("sync.status", syncStatus) == 0) {
 			if (minFrameDuration_ != maxFrameDuration_)
@@ -522,14 +522,14 @@  void IpaBase::processStats(const ProcessParams &params)
 			if (syncStatus.timerKnown)
 				libcameraMetadata_.set(controls::rpi::SyncTimer, syncStatus.timerValue);
 		}
+	}
 
-		struct AgcStatus agcStatus;
-		if (rpiMetadata.get("agc.status", agcStatus) == 0) {
-			ControlList ctrls(sensorCtrls_);
-			applyAGC(&agcStatus, ctrls, offset);
-			setDelayedControls.emit(ctrls, ipaContext);
-			setCameraTimeoutValue();
-		}
+	struct AgcStatus agcStatus;
+	if (rpiMetadata.get("agc.status", agcStatus) == 0) {
+		ControlList ctrls(sensorCtrls_);
+		applyAGC(&agcStatus, ctrls, offset);
+		setDelayedControls.emit(ctrls, ipaContext);
+		setCameraTimeoutValue();
 	}
 
 	/*