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

Message ID 20210907071311.3364713-2-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • [libcamera-devel,1/2] libcamera: formats: Add field for name of V4L2 format
Related show

Commit Message

Paul Elder Sept. 7, 2021, 7:13 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. 7, 2021, 9:07 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Tue, Sep 07, 2021 at 04:13:11PM +0900, Paul Elder wrote:
> Now that libcamera has the V4L2 format names, retrive and report those

s/retrive/retrieve/

> 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 07b1a90a..ec335ce2 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -270,13 +270,13 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *
>  		return -EINVAL;
>  
>  	PixelFormat format = streamConfig_.formats().pixelformats()[arg->index];
> +	PixelFormatInfo info = PixelFormatInfo::info(format);

const reference. I should make PixelFormatInfo non-copyable.

>  
>  	/* \todo Set V4L2_FMT_FLAG_COMPRESSED for compressed formats. */
>  	arg->flags = 0;

Could you add a patch to address this ? As we don't plan to support
other compressed formats than MJPEG, it can be as simple as setting
V4L2_FMT_FLAG_COMPRESSED iif the format is MJPEG.

> -	/* \todo Add map from format to description. */
>  	utils::strlcpy(reinterpret_cast<char *>(arg->description),
> -		       "Video Format Description", sizeof(arg->description));
> -	arg->pixelformat = PixelFormatInfo::info(format).v4l2Format;
> +		       info.v4l2Name, sizeof(arg->description));
> +	arg->pixelformat = info.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 07b1a90a..ec335ce2 100644
--- a/src/v4l2/v4l2_camera_proxy.cpp
+++ b/src/v4l2/v4l2_camera_proxy.cpp
@@ -270,13 +270,13 @@  int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *
 		return -EINVAL;
 
 	PixelFormat format = streamConfig_.formats().pixelformats()[arg->index];
+	PixelFormatInfo info = PixelFormatInfo::info(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 = PixelFormatInfo::info(format).v4l2Format;
+		       info.v4l2Name, sizeof(arg->description));
+	arg->pixelformat = info.v4l2Format;
 
 	memset(arg->reserved, 0, sizeof(arg->reserved));