[libcamera-devel,v3,6/6] libcamera: formats: Map V4L2_PIX_FMT_JPEG to formats::MJPEG
diff mbox series

Message ID 20220729160014.101503-7-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 29, 2022, 4 p.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 ++++-
 src/libcamera/v4l2_pixelformat.cpp | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart July 29, 2022, 6:41 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, Jul 29, 2022 at 06:00:14PM +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.

This patches doesn't change usage of toV4L2PixelFormat(), I would drop
"and use ...".

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

> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/formats.cpp          | 5 ++++-
>  src/libcamera/v4l2_pixelformat.cpp | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index 6921d5c43bcb..ff77ab23dda7 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -785,7 +785,10 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  	{ formats::MJPEG, {
>  		.name = "MJPEG",
>  		.format = formats::MJPEG,
> -		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), },
> +		.v4l2Formats = {
> +			V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
> +			V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
> +		},
>  		.bitsPerPixel = 0,
>  		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
>  		.packed = false,
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index bca97d1e3b4f..6abd2fa18312 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -183,6 +183,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>  	/* Compressed formats. */
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
>  		{ formats::MJPEG, "Motion-JPEG" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
> +		{ formats::MJPEG, "JPEG JFIF" } },
>  };
>  
>  } /* namespace */

Patch
diff mbox series

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index 6921d5c43bcb..ff77ab23dda7 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -785,7 +785,10 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 	{ formats::MJPEG, {
 		.name = "MJPEG",
 		.format = formats::MJPEG,
-		.v4l2Formats = { V4L2PixelFormat(V4L2_PIX_FMT_MJPEG), },
+		.v4l2Formats = {
+			V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
+			V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
+		},
 		.bitsPerPixel = 0,
 		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
 		.packed = false,
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index bca97d1e3b4f..6abd2fa18312 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -183,6 +183,8 @@  const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
 	/* Compressed formats. */
 	{ V4L2PixelFormat(V4L2_PIX_FMT_MJPEG),
 		{ formats::MJPEG, "Motion-JPEG" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_JPEG),
+		{ formats::MJPEG, "JPEG JFIF" } },
 };
 
 } /* namespace */