[libcamera-devel] pipeline: imx8-isi: Set SensorTimestamp metadata
diff mbox series

Message ID 20221120172030.21821-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 47c53f8084ed9e6e40cd2f8f74415472ccccef9c
Headers show
Series
  • [libcamera-devel] pipeline: imx8-isi: Set SensorTimestamp metadata
Related show

Commit Message

Laurent Pinchart Nov. 20, 2022, 5:20 p.m. UTC
Report the sensor timestamp in metadata. Use the timestamp from the
first buffer. Accuracy could be improved by using the frame start event
from the CSI-2 receiver, but the kernel driver doesn't support it yet.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jacopo Mondi Nov. 21, 2022, 12:55 p.m. UTC | #1
Hi Laurent,

On Sun, Nov 20, 2022 at 07:20:30PM +0200, Laurent Pinchart wrote:
> Report the sensor timestamp in metadata. Use the timestamp from the
> first buffer. Accuracy could be improved by using the frame start event
> from the CSI-2 receiver, but the kernel driver doesn't support it yet.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Ack, and I can confirm it fixes an issue with the gstreamer
"videorate" element.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> index a3dfd3fc529c..e51457ebc345 100644
> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> @@ -994,6 +994,12 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)
>  {
>  	Request *request = buffer->request();
>
> +	/* Record the sensor's timestamp in the request metadata. */
> +	ControlList &metadata = request->metadata();
> +	if (!metadata.contains(controls::SensorTimestamp.id()))
> +		metadata.set(controls::SensorTimestamp,
> +			     buffer->metadata().timestamp);
> +
>  	completeBuffer(request, buffer);
>  	if (request->hasPendingBuffers())
>  		return;
> --
> Regards,
>
> Laurent Pinchart
>
Kieran Bingham Nov. 21, 2022, 1:10 p.m. UTC | #2
Quoting Laurent Pinchart via libcamera-devel (2022-11-20 17:20:30)
> Report the sensor timestamp in metadata. Use the timestamp from the
> first buffer. Accuracy could be improved by using the frame start event
> from the CSI-2 receiver, but the kernel driver doesn't support it yet.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

> ---
>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> index a3dfd3fc529c..e51457ebc345 100644
> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> @@ -994,6 +994,12 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)
>  {
>         Request *request = buffer->request();
>  
> +       /* Record the sensor's timestamp in the request metadata. */
> +       ControlList &metadata = request->metadata();
> +       if (!metadata.contains(controls::SensorTimestamp.id()))
> +               metadata.set(controls::SensorTimestamp,
> +                            buffer->metadata().timestamp);
> +
>         completeBuffer(request, buffer);
>         if (request->hasPendingBuffers())
>                 return;
> -- 
> Regards,
> 
> Laurent Pinchart
>
Kieran Bingham Nov. 21, 2022, 1:11 p.m. UTC | #3
Quoting Laurent Pinchart via libcamera-devel (2022-11-20 17:20:30)
> Report the sensor timestamp in metadata. Use the timestamp from the
> first buffer. Accuracy could be improved by using the frame start event
> from the CSI-2 receiver, but the kernel driver doesn't support it yet.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

This makes me wonder if we should have mandated metadata ... which is
always expected to be reported in any successfully completed request.

If so - there's scope for some checks to be added to lc-compliance to
help validate this during bringup of new platforms.
-
Kieran


> ---
>  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> index a3dfd3fc529c..e51457ebc345 100644
> --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> @@ -994,6 +994,12 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)
>  {
>         Request *request = buffer->request();
>  
> +       /* Record the sensor's timestamp in the request metadata. */
> +       ControlList &metadata = request->metadata();
> +       if (!metadata.contains(controls::SensorTimestamp.id()))
> +               metadata.set(controls::SensorTimestamp,
> +                            buffer->metadata().timestamp);
> +
>         completeBuffer(request, buffer);
>         if (request->hasPendingBuffers())
>                 return;
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart Nov. 21, 2022, 1:27 p.m. UTC | #4
On Mon, Nov 21, 2022 at 01:11:31PM +0000, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-11-20 17:20:30)
> > Report the sensor timestamp in metadata. Use the timestamp from the
> > first buffer. Accuracy could be improved by using the frame start event
> > from the CSI-2 receiver, but the kernel driver doesn't support it yet.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> This makes me wonder if we should have mandated metadata ... which is
> always expected to be reported in any successfully completed request.
> 
> If so - there's scope for some checks to be added to lc-compliance to
> help validate this during bringup of new platforms.

Absolutely, we should do so.

> > ---
> >  src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> > index a3dfd3fc529c..e51457ebc345 100644
> > --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> > +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
> > @@ -994,6 +994,12 @@ void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)
> >  {
> >         Request *request = buffer->request();
> >  
> > +       /* Record the sensor's timestamp in the request metadata. */
> > +       ControlList &metadata = request->metadata();
> > +       if (!metadata.contains(controls::SensorTimestamp.id()))
> > +               metadata.set(controls::SensorTimestamp,
> > +                            buffer->metadata().timestamp);
> > +
> >         completeBuffer(request, buffer);
> >         if (request->hasPendingBuffers())
> >                 return;

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
index a3dfd3fc529c..e51457ebc345 100644
--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp
@@ -994,6 +994,12 @@  void PipelineHandlerISI::bufferReady(FrameBuffer *buffer)
 {
 	Request *request = buffer->request();
 
+	/* Record the sensor's timestamp in the request metadata. */
+	ControlList &metadata = request->metadata();
+	if (!metadata.contains(controls::SensorTimestamp.id()))
+		metadata.set(controls::SensorTimestamp,
+			     buffer->metadata().timestamp);
+
 	completeBuffer(request, buffer);
 	if (request->hasPendingBuffers())
 		return;