[libcamera-devel,1/5] libcamera: formats: Add YVU422 pixel format
diff mbox series

Message ID 20220504131558.9498-2-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: Support additional pixel formats and media bus codes
Related show

Commit Message

Laurent Pinchart May 4, 2022, 1:15 p.m. UTC
The YVU422 pixel format is defined in both DRM and V4L2. libcamera
already supports YUV422, add support for the opposite chroma order.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/formats.cpp          | 13 +++++++++++++
 src/libcamera/formats.yaml         |  2 ++
 src/libcamera/v4l2_pixelformat.cpp |  2 ++
 3 files changed, 17 insertions(+)

Comments

Jacopo Mondi May 6, 2022, 12:04 p.m. UTC | #1
Hi Laurent

On Wed, May 04, 2022 at 04:15:54PM +0300, Laurent Pinchart via libcamera-devel wrote:
> The YVU422 pixel format is defined in both DRM and V4L2. libcamera
> already supports YUV422, add support for the opposite chroma order.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/formats.cpp          | 13 +++++++++++++
>  src/libcamera/formats.yaml         |  2 ++
>  src/libcamera/v4l2_pixelformat.cpp |  2 ++
>  3 files changed, 17 insertions(+)
>
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index afcaabc519f7..c5cca37b02c2 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -469,6 +469,19 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
>  		.pixelsPerGroup = 2,
>  		.planes = {{ { 2, 1 }, { 1, 1 }, { 1, 1 } }},
>  	} },
> +	{ formats::YVU422, {
> +		.name = "YVU422",
> +		.format = formats::YVU422,
> +		.v4l2Formats = {
> +			.single = V4L2PixelFormat(),
> +			.multi = V4L2PixelFormat(V4L2_PIX_FMT_YVU422M),
> +		},
> +		.bitsPerPixel = 16,
> +		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
> +		.packed = false,
> +		.pixelsPerGroup = 2,
> +		.planes = {{ { 2, 1 }, { 1, 1 }, { 1, 1 } }},
> +	} },
>
>  	/* Greyscale formats. */
>  	{ formats::R8, {
> diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
> index 1f3f043302c3..0b527dbefe32 100644
> --- a/src/libcamera/formats.yaml
> +++ b/src/libcamera/formats.yaml
> @@ -69,6 +69,8 @@ formats:
>        fourcc: DRM_FORMAT_YVU420
>    - YUV422:
>        fourcc: DRM_FORMAT_YUV422
> +  - YVU422:
> +      fourcc: DRM_FORMAT_YVU422
>
>    - MJPEG:
>        fourcc: DRM_FORMAT_MJPEG
> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
> index 1dd93baa7a64..818bd1037e14 100644
> --- a/src/libcamera/v4l2_pixelformat.cpp
> +++ b/src/libcamera/v4l2_pixelformat.cpp
> @@ -113,6 +113,8 @@ const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
>  		{ formats::YUV422, "Planar YUV 4:2:2" } },
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422M),
>  		{ formats::YUV422, "Planar YUV 4:2:2 (N-C)" } },
> +	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422M),

This should probably be V4L2_PIX_FMT_YVU422M

> +		{ formats::YVU422, "Planar YVU 4:2:2 (N-C)" } },
>
>  	/* Greyscale formats. */
>  	{ V4L2PixelFormat(V4L2_PIX_FMT_GREY),
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index afcaabc519f7..c5cca37b02c2 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -469,6 +469,19 @@  const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
 		.pixelsPerGroup = 2,
 		.planes = {{ { 2, 1 }, { 1, 1 }, { 1, 1 } }},
 	} },
+	{ formats::YVU422, {
+		.name = "YVU422",
+		.format = formats::YVU422,
+		.v4l2Formats = {
+			.single = V4L2PixelFormat(),
+			.multi = V4L2PixelFormat(V4L2_PIX_FMT_YVU422M),
+		},
+		.bitsPerPixel = 16,
+		.colourEncoding = PixelFormatInfo::ColourEncodingYUV,
+		.packed = false,
+		.pixelsPerGroup = 2,
+		.planes = {{ { 2, 1 }, { 1, 1 }, { 1, 1 } }},
+	} },
 
 	/* Greyscale formats. */
 	{ formats::R8, {
diff --git a/src/libcamera/formats.yaml b/src/libcamera/formats.yaml
index 1f3f043302c3..0b527dbefe32 100644
--- a/src/libcamera/formats.yaml
+++ b/src/libcamera/formats.yaml
@@ -69,6 +69,8 @@  formats:
       fourcc: DRM_FORMAT_YVU420
   - YUV422:
       fourcc: DRM_FORMAT_YUV422
+  - YVU422:
+      fourcc: DRM_FORMAT_YVU422
 
   - MJPEG:
       fourcc: DRM_FORMAT_MJPEG
diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp
index 1dd93baa7a64..818bd1037e14 100644
--- a/src/libcamera/v4l2_pixelformat.cpp
+++ b/src/libcamera/v4l2_pixelformat.cpp
@@ -113,6 +113,8 @@  const std::map<V4L2PixelFormat, V4L2PixelFormat::Info> vpf2pf{
 		{ formats::YUV422, "Planar YUV 4:2:2" } },
 	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422M),
 		{ formats::YUV422, "Planar YUV 4:2:2 (N-C)" } },
+	{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422M),
+		{ formats::YVU422, "Planar YVU 4:2:2 (N-C)" } },
 
 	/* Greyscale formats. */
 	{ V4L2PixelFormat(V4L2_PIX_FMT_GREY),