[PATCH 2/6] pipeline: rpi: Add queue of wallclock timestamps
David Plowman
david.plowman at raspberrypi.com
Fri Oct 4 13:55:54 CEST 2024
From: Naushir Patuck <naush at raspberrypi.com>
Subsequent commits will add actual values to this queue, which we can
then use for sending wallclock timestamps over to the IPAs, where a
future "synchonisation algorithm" can use them.
Also add code to return the wallclock time to the application through
the frame metadata.
Signed-off-by: Naushir Patuck <naush at raspberrypi.com>
Reviewed-by: David Plowman <david.plowman at raspberrypi.com>
---
src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 9 +++++++++
src/libcamera/pipeline/rpi/common/pipeline_base.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
index 3041fd1e..253fac96 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp
@@ -676,6 +676,7 @@ int PipelineHandlerBase::start(Camera *camera, const ControlList *controls)
*/
data->delayedCtrls_->reset(0);
data->state_ = CameraData::State::Idle;
+ data->frameWallClock_ = {};
/* Enable SOF event generation. */
data->frontendDevice()->setFrameStartEnabled(true);
@@ -1353,6 +1354,11 @@ void CameraData::cameraTimeout()
void CameraData::frameStarted(uint32_t sequence)
{
+ /* Get frame wall clock. */
+ auto now = std::chrono::system_clock::now();
+ auto durNow = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch());
+ frameWallClock_.emplace(sequence, durNow);
+
LOG(RPI, Debug) << "Frame start " << sequence;
/* Write any controls for the next frame as soon as we can. */
@@ -1483,6 +1489,9 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request
request->metadata().set(controls::SensorTimestamp,
bufferControls.get(controls::SensorTimestamp).value_or(0));
+ request->metadata().set(controls::rpi::FrameWallClock,
+ bufferControls.get(controls::rpi::FrameWallClock).value_or(0));
+
request->metadata().set(controls::ScalerCrop, scalerCrop_);
}
diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h
index f9cecf70..b7f5470f 100644
--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h
+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h
@@ -163,6 +163,8 @@ public:
Config config_;
+ std::queue<std::pair<uint64_t, utils::Duration>> frameWallClock_;
+
protected:
void fillRequestMetadata(const ControlList &bufferControls,
Request *request);
--
2.39.5
More information about the libcamera-devel
mailing list