[libcamera-devel,v2,5/7] v4l2: v4l2_camera_proxy: Report the proper format name in enum_fmt
diff mbox series

Message ID 20210908081437.4022697-6-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • v4l2-compat fixes
Related show

Commit Message

Paul Elder Sept. 8, 2021, 8:14 a.m. UTC
Now that libcamera has the V4L2 format names, retrive and report those
names in ENUM_FMT. While at it, refactor the code slightly with
PixelFormatInfo.

This fixes the test failures on v4l2-compliance with the v4l2
compatilibity layer that were observed in version v4l2-compliance
version 1.21.0-4838.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/v4l2/v4l2_camera_proxy.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Sept. 8, 2021, 9:25 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Wed, Sep 08, 2021 at 05:14:35PM +0900, Paul Elder wrote:
> Now that libcamera has the V4L2 format names, retrive and report those
> names in ENUM_FMT. While at it, refactor the code slightly with
> PixelFormatInfo.
> 
> This fixes the test failures on v4l2-compliance with the v4l2
> compatilibity layer that were observed in version v4l2-compliance
> version 1.21.0-4838.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index aeffef26..5fbfcdd7 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -274,13 +274,13 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *
>  		return -EINVAL;
>  
>  	PixelFormat format = streamConfig_.formats().pixelformats()[arg->index];
> +	const V4L2PixelFormat &v4l2Format = V4L2PixelFormat::fromPixelFormat(format);

	V4L2PixelFormat v4l2Format = V4L2PixelFormat::fromPixelFormat(format);

as it just stores a uint32_t.

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

>  	/* \todo Set V4L2_FMT_FLAG_COMPRESSED for compressed formats. */
>  	arg->flags = 0;
> -	/* \todo Add map from format to description. */
>  	utils::strlcpy(reinterpret_cast<char *>(arg->description),
> -		       "Video Format Description", sizeof(arg->description));
> -	arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format);
> +		       v4l2Format.toDescription(), sizeof(arg->description));
> +	arg->pixelformat = v4l2Format;
>  
>  	memset(arg->reserved, 0, sizeof(arg->reserved));
>

Patch
diff mbox series

diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
index aeffef26..5fbfcdd7 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -274,13 +274,13 @@  int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *
 		return -EINVAL;
 
 	PixelFormat format = streamConfig_.formats().pixelformats()[arg->index];
+	const V4L2PixelFormat &v4l2Format = V4L2PixelFormat::fromPixelFormat(format);
 
 	/* \todo Set V4L2_FMT_FLAG_COMPRESSED for compressed formats. */
 	arg->flags = 0;
-	/* \todo Add map from format to description. */
 	utils::strlcpy(reinterpret_cast<char *>(arg->description),
-		       "Video Format Description", sizeof(arg->description));
-	arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format);
+		       v4l2Format.toDescription(), sizeof(arg->description));
+	arg->pixelformat = v4l2Format;
 
 	memset(arg->reserved, 0, sizeof(arg->reserved));