[libcamera-devel] libcamera: camera: Reset request sequence number on stop/start
diff mbox series

Message ID 20220701103236.1007698-1-umang.jain@ideasonboard.com
State Accepted
Commit 458d917ca2cb27bfeadca2a25c61ca99c5a82e9b
Headers show
Series
  • [libcamera-devel] libcamera: camera: Reset request sequence number on stop/start
Related show

Commit Message

Umang Jain July 1, 2022, 10:32 a.m. UTC
We now have V4L2VideoDevice ensuring that sensor sequence numbers
start from zero [1], and we desire that these should match the Request
sequence number as well.

[1] 1c9dc0fd89cf ("libcamera: v4l2_videodevice: Identify non-zero stream starts")

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/libcamera/camera.cpp           | 4 +++-
 src/libcamera/pipeline_handler.cpp | 2 ++
 src/libcamera/request.cpp          | 4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

Comments

Jacopo Mondi July 1, 2022, 11:03 a.m. UTC | #1
Hi Umang

On Fri, Jul 01, 2022 at 04:02:36PM +0530, Umang Jain via libcamera-devel wrote:
> We now have V4L2VideoDevice ensuring that sensor sequence numbers
> start from zero [1], and we desire that these should match the Request
> sequence number as well.
>
> [1] 1c9dc0fd89cf ("libcamera: v4l2_videodevice: Identify non-zero stream starts")
>
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>

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

Thanks!!

> ---
>  src/libcamera/camera.cpp           | 4 +++-
>  src/libcamera/pipeline_handler.cpp | 2 ++
>  src/libcamera/request.cpp          | 4 ++--
>  3 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 713543fd..f8150dcd 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -497,7 +497,7 @@ Camera::Private::~Private()
>   * facilitate debugging of internal request usage.
>   *
>   * The requestSequence_ tracks the number of requests queued to a camera
> - * over its lifetime.
> + * over a single capture session.
>   */
>
>  static const char *const camera_state_names[] = {
> @@ -1181,6 +1181,8 @@ int Camera::start(const ControlList *controls)
>
>  	LOG(Camera, Debug) << "Starting capture";
>
> +	ASSERT(d->requestSequence_ == 0);
> +
>  	ret = d->pipe_->invokeMethod(&PipelineHandler::start,
>  				     ConnectionTypeBlocking, this, controls);
>  	if (ret)
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index 7ebd76ad..67540533 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -312,6 +312,8 @@ void PipelineHandler::stop(Camera *camera)
>  	/* Make sure no requests are pending. */
>  	Camera::Private *data = camera->_d();
>  	ASSERT(data->queuedRequests_.empty());
> +
> +	data->requestSequence_ = 0;
>  }
>
>  /**
> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
> index 51d74b29..07613cb3 100644
> --- a/src/libcamera/request.cpp
> +++ b/src/libcamera/request.cpp
> @@ -526,8 +526,8 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const
>   *
>   * When requests are queued, they are given a sequential number to track the
>   * order in which requests are queued to a camera. This number counts all
> - * requests given to a camera through its lifetime, and is not reset to zero
> - * between camera stop/start sequences.
> + * requests given to a camera and is reset to zero between camera stop/start
> + * sequences.
>   *
>   * It can be used to support debugging and identifying the flow of requests
>   * through a pipeline, but does not guarantee to represent the sequence number
> --
> 2.31.1
>
Kieran Bingham July 1, 2022, 2:18 p.m. UTC | #2
Quoting Umang Jain via libcamera-devel (2022-07-01 11:32:36)
> We now have V4L2VideoDevice ensuring that sensor sequence numbers
> start from zero [1], and we desire that these should match the Request
> sequence number as well.
> 
> [1] 1c9dc0fd89cf ("libcamera: v4l2_videodevice: Identify non-zero stream starts")
> 

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

> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  src/libcamera/camera.cpp           | 4 +++-
>  src/libcamera/pipeline_handler.cpp | 2 ++
>  src/libcamera/request.cpp          | 4 ++--
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 713543fd..f8150dcd 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -497,7 +497,7 @@ Camera::Private::~Private()
>   * facilitate debugging of internal request usage.
>   *
>   * The requestSequence_ tracks the number of requests queued to a camera
> - * over its lifetime.
> + * over a single capture session.
>   */
>  
>  static const char *const camera_state_names[] = {
> @@ -1181,6 +1181,8 @@ int Camera::start(const ControlList *controls)
>  
>         LOG(Camera, Debug) << "Starting capture";
>  
> +       ASSERT(d->requestSequence_ == 0);
> +
>         ret = d->pipe_->invokeMethod(&PipelineHandler::start,
>                                      ConnectionTypeBlocking, this, controls);
>         if (ret)
> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
> index 7ebd76ad..67540533 100644
> --- a/src/libcamera/pipeline_handler.cpp
> +++ b/src/libcamera/pipeline_handler.cpp
> @@ -312,6 +312,8 @@ void PipelineHandler::stop(Camera *camera)
>         /* Make sure no requests are pending. */
>         Camera::Private *data = camera->_d();
>         ASSERT(data->queuedRequests_.empty());
> +
> +       data->requestSequence_ = 0;
>  }
>  
>  /**
> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
> index 51d74b29..07613cb3 100644
> --- a/src/libcamera/request.cpp
> +++ b/src/libcamera/request.cpp
> @@ -526,8 +526,8 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const
>   *
>   * When requests are queued, they are given a sequential number to track the
>   * order in which requests are queued to a camera. This number counts all
> - * requests given to a camera through its lifetime, and is not reset to zero
> - * between camera stop/start sequences.
> + * requests given to a camera and is reset to zero between camera stop/start
> + * sequences.
>   *
>   * It can be used to support debugging and identifying the flow of requests
>   * through a pipeline, but does not guarantee to represent the sequence number
> -- 
> 2.31.1
>

Patch
diff mbox series

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 713543fd..f8150dcd 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -497,7 +497,7 @@  Camera::Private::~Private()
  * facilitate debugging of internal request usage.
  *
  * The requestSequence_ tracks the number of requests queued to a camera
- * over its lifetime.
+ * over a single capture session.
  */
 
 static const char *const camera_state_names[] = {
@@ -1181,6 +1181,8 @@  int Camera::start(const ControlList *controls)
 
 	LOG(Camera, Debug) << "Starting capture";
 
+	ASSERT(d->requestSequence_ == 0);
+
 	ret = d->pipe_->invokeMethod(&PipelineHandler::start,
 				     ConnectionTypeBlocking, this, controls);
 	if (ret)
diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index 7ebd76ad..67540533 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -312,6 +312,8 @@  void PipelineHandler::stop(Camera *camera)
 	/* Make sure no requests are pending. */
 	Camera::Private *data = camera->_d();
 	ASSERT(data->queuedRequests_.empty());
+
+	data->requestSequence_ = 0;
 }
 
 /**
diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp
index 51d74b29..07613cb3 100644
--- a/src/libcamera/request.cpp
+++ b/src/libcamera/request.cpp
@@ -526,8 +526,8 @@  FrameBuffer *Request::findBuffer(const Stream *stream) const
  *
  * When requests are queued, they are given a sequential number to track the
  * order in which requests are queued to a camera. This number counts all
- * requests given to a camera through its lifetime, and is not reset to zero
- * between camera stop/start sequences.
+ * requests given to a camera and is reset to zero between camera stop/start
+ * sequences.
  *
  * It can be used to support debugging and identifying the flow of requests
  * through a pipeline, but does not guarantee to represent the sequence number