[libcamera-devel,1/2] v4l2: camera_proxy: Fix try_fmt format conversion

Message ID 20200107165038.93041-2-jacopo@jmondi.org
State Superseded
Headers show
Series
  • v4l2: minor fixes
Related show

Commit Message

Jacopo Mondi Jan. 7, 2020, 4:50 p.m. UTC
The set pixelformat field of struct v4l2_pix_format structure was
wrongly converted to PixelFormat by calling v4l2ToDrm(), with an already
converted 'format' argument.

Fix this by calling the right drmToV4l2() conversion function.

Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/v4l2/v4l2_camera_proxy.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Jan. 7, 2020, 5:02 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Tue, Jan 07, 2020 at 05:50:37PM +0100, Jacopo Mondi wrote:
> The set pixelformat field of struct v4l2_pix_format structure was
> wrongly converted to PixelFormat by calling v4l2ToDrm(), with an already
> converted 'format' argument.
> 
> Fix this by calling the right drmToV4l2() conversion function.
> 
> Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer")
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

This kind of issue will be caught automatically once we extend the
PixelFormat to become a real class.

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

> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 559caba69270..dbcf333a761f 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -281,7 +281,7 @@ int V4L2CameraProxy::vidioc_try_fmt(struct v4l2_format *arg)
>  
>  	arg->fmt.pix.width        = size.width;
>  	arg->fmt.pix.height       = size.height;
> -	arg->fmt.pix.pixelformat  = v4l2ToDrm(format);
> +	arg->fmt.pix.pixelformat  = drmToV4L2(format);
>  	arg->fmt.pix.field        = V4L2_FIELD_NONE;
>  	arg->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) *
>  				    arg->fmt.pix.width;

Patch

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index 559caba69270..dbcf333a761f 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -281,7 +281,7 @@  int V4L2CameraProxy::vidioc_try_fmt(struct v4l2_format *arg)
 
 	arg->fmt.pix.width        = size.width;
 	arg->fmt.pix.height       = size.height;
-	arg->fmt.pix.pixelformat  = v4l2ToDrm(format);
+	arg->fmt.pix.pixelformat  = drmToV4L2(format);
 	arg->fmt.pix.field        = V4L2_FIELD_NONE;
 	arg->fmt.pix.bytesperline = bplMultiplier(drmToV4L2(format)) *
 				    arg->fmt.pix.width;