pipeline: rpi: Add wallclock timestamp support
A ClockRecovery object is added for derived classes to use, and wallclock timestamps are copied into the request metadata for applications. Wallclock timestamps are derived corresponding to the sensor timestamp, and made available to the base pipeline handler class and to IPAs, for both vc4 and pisp platforms. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
1d1ba78b45
commit
1537da7442
4 changed files with 24 additions and 4 deletions
|
@ -685,6 +685,9 @@ int PipelineHandlerBase::start(Camera *camera, const ControlList *controls)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A good moment to add an initial clock sample. */
|
||||||
|
data->wallClockRecovery_.addSample();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reset the delayed controls with the gain and exposure values set by
|
* Reset the delayed controls with the gain and exposure values set by
|
||||||
* the IPA.
|
* the IPA.
|
||||||
|
@ -1482,6 +1485,8 @@ void CameraData::fillRequestMetadata(const ControlList &bufferControls, Request
|
||||||
{
|
{
|
||||||
request->metadata().set(controls::SensorTimestamp,
|
request->metadata().set(controls::SensorTimestamp,
|
||||||
bufferControls.get(controls::SensorTimestamp).value_or(0));
|
bufferControls.get(controls::SensorTimestamp).value_or(0));
|
||||||
|
request->metadata().set(controls::FrameWallClock,
|
||||||
|
bufferControls.get(controls::FrameWallClock).value_or(0));
|
||||||
|
|
||||||
if (cropParams_.size()) {
|
if (cropParams_.size()) {
|
||||||
std::vector<Rectangle> crops;
|
std::vector<Rectangle> crops;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "libcamera/internal/bayer_format.h"
|
#include "libcamera/internal/bayer_format.h"
|
||||||
#include "libcamera/internal/camera.h"
|
#include "libcamera/internal/camera.h"
|
||||||
#include "libcamera/internal/camera_sensor.h"
|
#include "libcamera/internal/camera_sensor.h"
|
||||||
|
#include "libcamera/internal/clock_recovery.h"
|
||||||
#include "libcamera/internal/framebuffer.h"
|
#include "libcamera/internal/framebuffer.h"
|
||||||
#include "libcamera/internal/media_device.h"
|
#include "libcamera/internal/media_device.h"
|
||||||
#include "libcamera/internal/media_object.h"
|
#include "libcamera/internal/media_object.h"
|
||||||
|
@ -172,6 +173,8 @@ public:
|
||||||
|
|
||||||
Config config_;
|
Config config_;
|
||||||
|
|
||||||
|
ClockRecovery wallClockRecovery_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void fillRequestMetadata(const ControlList &bufferControls,
|
void fillRequestMetadata(const ControlList &bufferControls,
|
||||||
Request *request);
|
Request *request);
|
||||||
|
|
|
@ -1755,9 +1755,15 @@ void PiSPCameraData::cfeBufferDequeue(FrameBuffer *buffer)
|
||||||
auto [ctrl, delayContext] = delayedCtrls_->get(buffer->metadata().sequence);
|
auto [ctrl, delayContext] = delayedCtrls_->get(buffer->metadata().sequence);
|
||||||
/*
|
/*
|
||||||
* Add the frame timestamp to the ControlList for the IPA to use
|
* Add the frame timestamp to the ControlList for the IPA to use
|
||||||
* as it does not receive the FrameBuffer object.
|
* as it does not receive the FrameBuffer object. Also derive a
|
||||||
|
* corresponding wallclock value.
|
||||||
*/
|
*/
|
||||||
ctrl.set(controls::SensorTimestamp, buffer->metadata().timestamp);
|
wallClockRecovery_.addSample();
|
||||||
|
uint64_t sensorTimestamp = buffer->metadata().timestamp;
|
||||||
|
uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp / 1000);
|
||||||
|
|
||||||
|
ctrl.set(controls::SensorTimestamp, sensorTimestamp);
|
||||||
|
ctrl.set(controls::FrameWallClock, wallClockTimestamp);
|
||||||
job.sensorControls = std::move(ctrl);
|
job.sensorControls = std::move(ctrl);
|
||||||
job.delayContext = delayContext;
|
job.delayContext = delayContext;
|
||||||
} else if (stream == &cfe_[Cfe::Config]) {
|
} else if (stream == &cfe_[Cfe::Config]) {
|
||||||
|
|
|
@ -773,9 +773,15 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer)
|
||||||
auto [ctrl, delayContext] = delayedCtrls_->get(buffer->metadata().sequence);
|
auto [ctrl, delayContext] = delayedCtrls_->get(buffer->metadata().sequence);
|
||||||
/*
|
/*
|
||||||
* Add the frame timestamp to the ControlList for the IPA to use
|
* Add the frame timestamp to the ControlList for the IPA to use
|
||||||
* as it does not receive the FrameBuffer object.
|
* as it does not receive the FrameBuffer object. Also derive a
|
||||||
|
* corresponding wallclock value.
|
||||||
*/
|
*/
|
||||||
ctrl.set(controls::SensorTimestamp, buffer->metadata().timestamp);
|
wallClockRecovery_.addSample();
|
||||||
|
uint64_t sensorTimestamp = buffer->metadata().timestamp;
|
||||||
|
uint64_t wallClockTimestamp = wallClockRecovery_.getOutput(sensorTimestamp / 1000);
|
||||||
|
|
||||||
|
ctrl.set(controls::SensorTimestamp, sensorTimestamp);
|
||||||
|
ctrl.set(controls::FrameWallClock, wallClockTimestamp);
|
||||||
bayerQueue_.push({ buffer, std::move(ctrl), delayContext });
|
bayerQueue_.push({ buffer, std::move(ctrl), delayContext });
|
||||||
} else {
|
} else {
|
||||||
embeddedQueue_.push(buffer);
|
embeddedQueue_.push(buffer);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue