[libcamera-devel] [PATCH 10/13] libcamera: raspberry: Report sensor timestamp

Jacopo Mondi jacopo at jmondi.org
Mon Apr 19 15:14:30 CEST 2021


Report the sensor's timestamp in the Request metadata by using the
Unicam::Image buffer timestamp as an initial approximation.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition, but when used
to compare two consecutive frames it gives an acceptable estimation of
the sensor frame period duration.

Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index d1902bfc3393..7dc92acf3c4f 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1415,6 +1415,18 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)
 			<< ", timestamp: " << buffer->metadata().timestamp;
 
 	if (stream == &unicam_[Unicam::Image]) {
+		/*
+		 * Record the sensor timestamp in the Request.
+		 *
+		 * \todo The sensor timestamp should be better estimated by
+		 * sampling the V4L2Device::frameStart signal.
+		 */
+		Request *request = requestQueue_.front();
+		ASSERT(request);
+
+		request->metadata().set(controls::SensorTimestamp,
+					buffer->metadata().timestamp);
+
 		/*
 		 * Lookup the sensor controls used for this frame sequence from
 		 * DelayedControl and queue them along with the frame buffer.
-- 
2.31.1



More information about the libcamera-devel mailing list