[libcamera-devel,03/13] libcamera: uvc: Report sensor timestamp
diff mbox series

Message ID 20210419131433.22920-4-jacopo@jmondi.org
State Accepted
Delegated to: Jacopo Mondi
Headers show
Series
  • Support SensorTimestamp metadata
Related show

Commit Message

Jacopo Mondi April 19, 2021, 1:14 p.m. UTC
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The UVC driver does not support the FRAME_SYNC v4l2 event, and the
buffer timestamp is the only available approximation of the
sensor timestamp.

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

Comments

Kieran Bingham April 19, 2021, 3:02 p.m. UTC | #1
On 19/04/2021 14:14, Jacopo Mondi wrote:
> Report the sensor's timestamp in the Request metadata using the
> completed buffer timestamp.
> 
> The UVC driver does not support the FRAME_SYNC v4l2 event, and the
> buffer timestamp is the only available approximation of the
> sensor timestamp.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> index b6c6ade5ebaf..b2d2f211e61b 100644
> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> @@ -662,6 +662,9 @@ void UVCCameraData::bufferReady(FrameBuffer *buffer)
>  {
>  	Request *request = buffer->request();
>  
> +	request->metadata().set(controls::SensorTimestamp,
> +				buffer->metadata().timestamp);
> +
>  	pipe_->completeBuffer(request, buffer);
>  	pipe_->completeRequest(request);
>  }
>
Laurent Pinchart April 20, 2021, 9:34 p.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Mon, Apr 19, 2021 at 03:14:23PM +0200, Jacopo Mondi wrote:
> Report the sensor's timestamp in the Request metadata using the
> completed buffer timestamp.
> 
> The UVC driver does not support the FRAME_SYNC v4l2 event, and the
> buffer timestamp is the only available approximation of the
> sensor timestamp.

That's actually not the full story, UVC device report timestamp
information in metadata that can be used to recover a SOE timestamp.

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> index b6c6ade5ebaf..b2d2f211e61b 100644
> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> @@ -662,6 +662,9 @@ void UVCCameraData::bufferReady(FrameBuffer *buffer)
>  {
>  	Request *request = buffer->request();
>  

I'd add

	/* \todo Use the UVC metadata to calculate a more precise timestamp */

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +	request->metadata().set(controls::SensorTimestamp,
> +				buffer->metadata().timestamp);
> +
>  	pipe_->completeBuffer(request, buffer);
>  	pipe_->completeRequest(request);
>  }

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
index b6c6ade5ebaf..b2d2f211e61b 100644
--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
@@ -662,6 +662,9 @@  void UVCCameraData::bufferReady(FrameBuffer *buffer)
 {
 	Request *request = buffer->request();
 
+	request->metadata().set(controls::SensorTimestamp,
+				buffer->metadata().timestamp);
+
 	pipe_->completeBuffer(request, buffer);
 	pipe_->completeRequest(request);
 }