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

Message ID 20220802160136.63075-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 Aug. 2, 2022, 4:01 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>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/formats.cpp          | 5 ++++-
 src/libcamera/v4l2_pixelformat.cpp | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index b760ec0eff82..4746d38c30d2 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 264ca80aab27..8ec442d6b84d 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 */