[libcamera-devel,2/3] libcamera: ipu3: Report sensor timestamp
diff mbox series

Message ID 20210407160644.58326-3-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: Add sensor timestamp support
Related show

Commit Message

Jacopo Mondi April 7, 2021, 4:06 p.m. UTC
Report the sensor's timestamp in the Request metadata by using the
CIO2 buffer timestamp as a good-enough 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@jmondi.org>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Hirokazu Honda April 8, 2021, 9:04 a.m. UTC | #1
Hi Jacopo, Thanks for the patch.

On Thu, Apr 8, 2021 at 1:06 AM Jacopo Mondi <jacopo@jmondi.org> wrote:
>
> Report the sensor's timestamp in the Request metadata by using the
> CIO2 buffer timestamp as a good-enough 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@jmondi.org>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 519cad4f8148..d52e24f847a2 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -1251,6 +1251,15 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)
>
>         Request *request = info->request;
>
> +       /*
> +        * Record the sensor's timestamp in the request metadata.
> +        *
> +        * \todo The sensor timestamp should be better estimated by connecting
> +        * to the V4L2Device::frameStart signal.
> +        */
> +       request->metadata().set(controls::SensorTimestamp,
> +                               buffer->metadata().timestamp);
> +
>         /* If the buffer is cancelled force a complete of the whole request. */
>         if (buffer->metadata().status == FrameMetadata::FrameCancelled) {
>                 for (auto it : request->buffers())


Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> --
> 2.31.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart April 13, 2021, 2:45 a.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Wed, Apr 07, 2021 at 06:06:43PM +0200, Jacopo Mondi wrote:
> Report the sensor's timestamp in the Request metadata by using the
> CIO2 buffer timestamp as a good-enough approximation.

s/a good-enough/an initial/

The \todo comment below shows that we'll need a better implementation,
but it can wait.

> 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@jmondi.org>

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

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 519cad4f8148..d52e24f847a2 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -1251,6 +1251,15 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)
>  
>  	Request *request = info->request;
>  
> +	/*
> +	 * Record the sensor's timestamp in the request metadata.
> +	 *
> +	 * \todo The sensor timestamp should be better estimated by connecting
> +	 * to the V4L2Device::frameStart signal.
> +	 */
> +	request->metadata().set(controls::SensorTimestamp,
> +				buffer->metadata().timestamp);
> +
>  	/* If the buffer is cancelled force a complete of the whole request. */
>  	if (buffer->metadata().status == FrameMetadata::FrameCancelled) {
>  		for (auto it : request->buffers())

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 519cad4f8148..d52e24f847a2 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -1251,6 +1251,15 @@  void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer)
 
 	Request *request = info->request;
 
+	/*
+	 * Record the sensor's timestamp in the request metadata.
+	 *
+	 * \todo The sensor timestamp should be better estimated by connecting
+	 * to the V4L2Device::frameStart signal.
+	 */
+	request->metadata().set(controls::SensorTimestamp,
+				buffer->metadata().timestamp);
+
 	/* If the buffer is cancelled force a complete of the whole request. */
 	if (buffer->metadata().status == FrameMetadata::FrameCancelled) {
 		for (auto it : request->buffers())