[libcamera-devel,v4,21/21] v4l2: v4l2_camera: Fix stream selection for buffer operations

Message ID 20200708134417.67747-22-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Clean up formats in v4l2-compat and pipeline handlers
Related show

Commit Message

Paul Elder July 8, 2020, 1:44 p.m. UTC
The buffer operations in V4L2Camera were getting the stream from the
wrong place. Fix it.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
New in v4
---
 src/v4l2/v4l2_camera.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart July 8, 2020, 3:32 p.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Wed, Jul 08, 2020 at 10:44:17PM +0900, Paul Elder wrote:
> The buffer operations in V4L2Camera were getting the stream from the
> wrong place. Fix it.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

Good catch.

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

> ---
> New in v4
> ---
>  src/v4l2/v4l2_camera.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
> index 9f81c97..61bca07 100644
> --- a/src/v4l2/v4l2_camera.cpp
> +++ b/src/v4l2/v4l2_camera.cpp
> @@ -160,7 +160,7 @@ int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat,
>  
>  int V4L2Camera::allocBuffers(unsigned int count)
>  {
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>  
>  	return bufferAllocator_->allocate(stream);
>  }
> @@ -169,13 +169,13 @@ void V4L2Camera::freeBuffers()
>  {
>  	pendingRequests_.clear();
>  
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>  	bufferAllocator_->free(stream);
>  }
>  
>  FileDescriptor V4L2Camera::getBufferFd(unsigned int index)
>  {
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>  	const std::vector<std::unique_ptr<FrameBuffer>> &buffers =
>  		bufferAllocator_->buffers(stream);
>
Jacopo Mondi July 8, 2020, 9:44 p.m. UTC | #2
Hi Paul,

On Wed, Jul 08, 2020 at 10:44:17PM +0900, Paul Elder wrote:
> The buffer operations in V4L2Camera were getting the stream from the
> wrong place. Fix it.

I wonder what is the use case for applications to get the stream list,
instead of going through the configuration. As this patch shows, that
part of the API is slippery...

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

Thanks
   j

>
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
>
> ---
> New in v4
> ---
>  src/v4l2/v4l2_camera.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
> index 9f81c97..61bca07 100644
> --- a/src/v4l2/v4l2_camera.cpp
> +++ b/src/v4l2/v4l2_camera.cpp
> @@ -160,7 +160,7 @@ int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat,
>
>  int V4L2Camera::allocBuffers(unsigned int count)
>  {
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>
>  	return bufferAllocator_->allocate(stream);
>  }
> @@ -169,13 +169,13 @@ void V4L2Camera::freeBuffers()
>  {
>  	pendingRequests_.clear();
>
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>  	bufferAllocator_->free(stream);
>  }
>
>  FileDescriptor V4L2Camera::getBufferFd(unsigned int index)
>  {
> -	Stream *stream = *camera_->streams().begin();
> +	Stream *stream = config_->at(0).stream();
>  	const std::vector<std::unique_ptr<FrameBuffer>> &buffers =
>  		bufferAllocator_->buffers(stream);
>
> --
> 2.27.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index 9f81c97..61bca07 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -160,7 +160,7 @@  int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat,
 
 int V4L2Camera::allocBuffers(unsigned int count)
 {
-	Stream *stream = *camera_->streams().begin();
+	Stream *stream = config_->at(0).stream();
 
 	return bufferAllocator_->allocate(stream);
 }
@@ -169,13 +169,13 @@  void V4L2Camera::freeBuffers()
 {
 	pendingRequests_.clear();
 
-	Stream *stream = *camera_->streams().begin();
+	Stream *stream = config_->at(0).stream();
 	bufferAllocator_->free(stream);
 }
 
 FileDescriptor V4L2Camera::getBufferFd(unsigned int index)
 {
-	Stream *stream = *camera_->streams().begin();
+	Stream *stream = config_->at(0).stream();
 	const std::vector<std::unique_ptr<FrameBuffer>> &buffers =
 		bufferAllocator_->buffers(stream);