[v3,09/16] libcamera: delayed_controls: Add sourceSequence property
diff mbox series

Message ID 20240319120517.362082-10-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Preparation for per-frame-controls and initial tests
Related show

Commit Message

Stefan Klug March 19, 2024, 12:05 p.m. UTC
This is necessary for the upcoming rework. It allows to track the
sequence number from which a request stems.

The use case where this is needed is as follows: Assume for frame 10 a manual
ExposureTime=42 is queued because the user wants manual exposure. Now the agc
gets the stats for frame 8 (where auto regulation is still active) and pushes a
new ExposureTime for frame 9.  Frame 9 was already sent out, so it gets delayed
to frame 11 (assuming a delay of 2 on ExposureTime). This would revert the
request from frame 10.  Taking the sourceSequence into account, the delayed
request from frame 9 will be discarded, which is correct.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 include/libcamera/internal/delayed_controls.h | 8 +++++---
 src/libcamera/delayed_controls.cpp            | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h
index 224c1f7e..5a0428e0 100644
--- a/include/libcamera/internal/delayed_controls.h
+++ b/include/libcamera/internal/delayed_controls.h
@@ -39,16 +39,18 @@  private:
 	{
 	public:
 		Info()
-			: updated(false)
+			: updated(false), sourceSequence(0)
 		{
 		}
 
-		Info(const ControlValue &v, bool updated_ = true)
-			: ControlValue(v), updated(updated_)
+		Info(const ControlValue &v, uint32_t sourceSeq, bool updated_ = true)
+			: ControlValue(v), updated(updated_), sourceSequence(sourceSeq)
 		{
 		}
 
 		bool updated;
+		/* The sequence id for which this value was requested */
+		uint32_t sourceSequence;
 	};
 
 	/* \todo Make the listSize configurable at instance creation time. */
diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp
index 6f06950e..8cfa6bbb 100644
--- a/src/libcamera/delayed_controls.cpp
+++ b/src/libcamera/delayed_controls.cpp
@@ -147,7 +147,7 @@  void DelayedControls::reset(ControlList *controls)
 		 * Do not mark this control value as updated, it does not need
 		 * to be written to to device on startup.
 		 */
-		values_[id][0] = Info(ctrl.second, false);
+		values_[id][0] = Info(ctrl.second, 0, false);
 	}
 }
 
@@ -220,7 +220,7 @@  bool DelayedControls::push(const ControlList &controls)
 
 		Info &info = values_[id][queueIndex_];
 
-		info = Info(control.second);
+		info = Info(control.second, 0);
 
 		LOG(DelayedControls, Debug)
 			<< "Queuing " << id->name()