[3/6] pipelien: rpi: vc4: Populate the wallclock timestamps queue
diff mbox series

Message ID 20241004115558.9166-4-david.plowman@raspberrypi.com
State New
Headers show
Series
  • Raspberry Pi software camera sync algorithm
Related show

Commit Message

David Plowman Oct. 4, 2024, 11:55 a.m. UTC
From: Naushir Patuck <naush@raspberrypi.com>

We add wallclock timestamps to the queue when we dequeue a camera
buffer from Unicam.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/pipeline/rpi/vc4/vc4.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
index e5b6ef2b..754cfdde 100644
--- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp
+++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp
@@ -777,6 +777,18 @@  void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer)
 		 * as it does not receive the FrameBuffer object.
 		 */
 		ctrl.set(controls::SensorTimestamp, buffer->metadata().timestamp);
+
+		/* Also record a wall-clock timestamp that can be passed to IPAs. */
+		while (!frameWallClock_.empty() &&
+		       frameWallClock_.front().first < buffer->metadata().sequence)
+			frameWallClock_.pop();
+
+		if (!frameWallClock_.empty() &&
+		    frameWallClock_.front().first == buffer->metadata().sequence) {
+			ctrl.set(controls::rpi::FrameWallClock, frameWallClock_.front().second.get<std::micro>());
+			frameWallClock_.pop();
+		}
+
 		bayerQueue_.push({ buffer, std::move(ctrl), delayContext });
 	} else {
 		embeddedQueue_.push(buffer);