[libcamera-devel,v3,09/16] libcamera: simple: Report sensor timestamp
diff mbox series

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

Commit Message

Jacopo Mondi April 21, 2021, 4:03 p.m. UTC
Report the sensor's timestamp in the Request metadata using the
completed buffer timestamp.

The buffer's timestamp is recorded at DMA-transfer time, and it does not
theoretically matches the 'start of exposure' definition. Record this with
a \todo entry.

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

Comments

Hirokazu Honda April 22, 2021, 4:59 a.m. UTC | #1
Hi Jacopo, thank you for a patch,

On Thu, Apr 22, 2021 at 1:02 AM Jacopo Mondi <jacopo@jmondi.org> wrote:
>
> Report the sensor's timestamp in the Request metadata using the
> completed buffer timestamp.
>
> The buffer's timestamp is recorded at DMA-transfer time, and it does not
> theoretically matches the 'start of exposure' definition. Record this with
> a \todo entry.
>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index f6095d38e97a..e1ee640b0a92 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -22,6 +22,7 @@
>  #include <linux/media-bus-format.h>
>
>  #include <libcamera/camera.h>
> +#include <libcamera/control_ids.h>
>  #include <libcamera/request.h>
>  #include <libcamera/stream.h>
>
> @@ -1116,6 +1117,16 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
>                 return;
>         }
>
> +       /*
> +        * Record the sensor's timestamp in the request metadata.
> +        *
> +        * \todo The sensor timestamp should be better estimated by connecting
> +        * to the V4L2Device::frameStart signal if the platform provides it.
> +        */
> +       Request *request = buffer->request();
> +       request->metadata().set(controls::SensorTimestamp,
> +                               buffer->metadata().timestamp);
> +
>         /*
>          * Queue the captured and the request buffer to the converter if format
>          * conversion is needed. If there's no queued request, just requeue the
> @@ -1133,7 +1144,6 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
>         }
>
>         /* Otherwise simply complete the request. */
> -       Request *request = buffer->request();
>         completeBuffer(request, buffer);
>         completeRequest(request);
>  }
> --
> 2.31.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart April 26, 2021, 5:01 a.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Wed, Apr 21, 2021 at 06:03:12PM +0200, Jacopo Mondi wrote:
> Report the sensor's timestamp in the Request metadata using the
> completed buffer timestamp.
> 
> The buffer's timestamp is recorded at DMA-transfer time, and it does not
> theoretically matches the 'start of exposure' definition. Record this with
> a \todo entry.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/pipeline/simple/simple.cpp | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
> index f6095d38e97a..e1ee640b0a92 100644
> --- a/src/libcamera/pipeline/simple/simple.cpp
> +++ b/src/libcamera/pipeline/simple/simple.cpp
> @@ -22,6 +22,7 @@
>  #include <linux/media-bus-format.h>
>  
>  #include <libcamera/camera.h>
> +#include <libcamera/control_ids.h>
>  #include <libcamera/request.h>
>  #include <libcamera/stream.h>
>  
> @@ -1116,6 +1117,16 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
>  		return;
>  	}
>  
> +	/*
> +	 * Record the sensor's timestamp in the request metadata.
> +	 *
> +	 * \todo The sensor timestamp should be better estimated by connecting
> +	 * to the V4L2Device::frameStart signal if the platform provides it.
> +	 */
> +	Request *request = buffer->request();
> +	request->metadata().set(controls::SensorTimestamp,
> +				buffer->metadata().timestamp);
> +
>  	/*
>  	 * Queue the captured and the request buffer to the converter if format
>  	 * conversion is needed. If there's no queued request, just requeue the
> @@ -1133,7 +1144,6 @@ void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
>  	}
>  
>  	/* Otherwise simply complete the request. */
> -	Request *request = buffer->request();
>  	completeBuffer(request, buffer);
>  	completeRequest(request);
>  }

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp
index f6095d38e97a..e1ee640b0a92 100644
--- a/src/libcamera/pipeline/simple/simple.cpp
+++ b/src/libcamera/pipeline/simple/simple.cpp
@@ -22,6 +22,7 @@ 
 #include <linux/media-bus-format.h>
 
 #include <libcamera/camera.h>
+#include <libcamera/control_ids.h>
 #include <libcamera/request.h>
 #include <libcamera/stream.h>
 
@@ -1116,6 +1117,16 @@  void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
 		return;
 	}
 
+	/*
+	 * Record the sensor's timestamp in the request metadata.
+	 *
+	 * \todo The sensor timestamp should be better estimated by connecting
+	 * to the V4L2Device::frameStart signal if the platform provides it.
+	 */
+	Request *request = buffer->request();
+	request->metadata().set(controls::SensorTimestamp,
+				buffer->metadata().timestamp);
+
 	/*
 	 * Queue the captured and the request buffer to the converter if format
 	 * conversion is needed. If there's no queued request, just requeue the
@@ -1133,7 +1144,6 @@  void SimplePipelineHandler::bufferReady(FrameBuffer *buffer)
 	}
 
 	/* Otherwise simply complete the request. */
-	Request *request = buffer->request();
 	completeBuffer(request, buffer);
 	completeRequest(request);
 }