[libcamera-devel,v2,7/8] libcamera: formats: Map V4L2_PIX_FMT_JPEG to formats::MJPEG
diff mbox series

Message ID 20220723095330.43542-8-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: Map multiple V4L2 formats to a single libcamera::format
Related show

Commit Message

Jacopo Mondi July 23, 2022, 9:53 a.m. UTC
The V4L2_PIX_FMT_JPEG and V4L2_PIX_FMT_MJPEG formats are under-specified
and are used interchangeably by kernel drivers.

Map both of them to formats::MJPEG and use the newly re-introduced
V4L2VideoDevice::toV4L2PixelFormat() to map to the one actually used by
the video device.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/formats.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart July 23, 2022, 5:47 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Sat, Jul 23, 2022 at 11:53:29AM +0200, Jacopo Mondi via libcamera-devel wrote:
> The V4L2_PIX_FMT_JPEG and V4L2_PIX_FMT_MJPEG formats are under-specified
> and are used interchangeably by kernel drivers.
> 
> Map both of them to formats::MJPEG and use the newly re-introduced
> V4L2VideoDevice::toV4L2PixelFormat() to map to the one actually used by
> the video device.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

With the two vectors merged as proposed in the review of an earlier
patch,

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

> ---
>  src/libcamera/formats.cpp | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 86fc698a0f4e..564ccc1b5a62 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -948,7 +948,10 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.name = "MJPEG",
>  		.format = formats::MJPEG,
>  		.v4l2Formats = {
> -			.single = { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG) },
> +			.single = {
> +					V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
> +					V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
> +			},
>  			.multi = { V4L2PixelFormat() },
>  		},
>  		.bitsPerPixel = 0,

Patch
diff mbox series

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 86fc698a0f4e..564ccc1b5a62 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -948,7 +948,10 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.name = "MJPEG",
 		.format = formats::MJPEG,
 		.v4l2Formats = {
-			.single = { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG) },
+			.single = {
+					V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
+					V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
+			},
 			.multi = { V4L2PixelFormat() },
 		},
 		.bitsPerPixel = 0,