[PATCH v9 02/11] drm/fourcc: Add DRM_FORMAT_XV20

Tomi Valkeinen posted 11 patches 1 week, 1 day ago
[PATCH v9 02/11] drm/fourcc: Add DRM_FORMAT_XV20
Posted by Tomi Valkeinen 1 week, 1 day ago
Add a new pixel format, DRM_FORMAT_XV20 ("XV20")

XV20 is 2 plane 10 bit per component YCbCr 2x1 subsampled format. XV20
is similar to the already existing P030 format, which is 2x2 subsampled.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Vishal Sagar <vishal.sagar@amd.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 drivers/gpu/drm/drm_fourcc.c  | 3 +++
 include/uapi/drm/drm_fourcc.h | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index e662aea9d105..4fd37226b647 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -381,6 +381,9 @@ const struct drm_format_info *__drm_format_info(u32 format)
 		{ .format = DRM_FORMAT_S416,            .depth = 0,  .num_planes = 3,
 		  .char_per_block = { 2, 2, 2 }, .block_w = { 1, 1, 1 }, .block_h = { 1, 1, 1 },
 		  .hsub = 1, .vsub = 1, .is_yuv = true},
+		{ .format = DRM_FORMAT_XV20,		.depth = 0,  .num_planes = 2,
+		  .char_per_block = { 4, 8, 0 }, .block_w = { 3, 3, 0 }, .block_h = { 1, 1, 0 },
+		  .hsub = 2, .vsub = 1, .is_yuv = true },
 	};
 
 	unsigned int i;
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index c89aede3cb12..10cc13bdb495 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -322,6 +322,13 @@ extern "C" {
 #define DRM_FORMAT_RGB565_A8	fourcc_code('R', '5', 'A', '8')
 #define DRM_FORMAT_BGR565_A8	fourcc_code('B', '5', 'A', '8')
 
+/*
+ * 2 plane 10 bit per component YCrCb
+ * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian
+ * index 1 = Cb:Cr plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 2:10:10:10:2:10:10:10 little endian
+ */
+#define DRM_FORMAT_XV20		fourcc_code('X', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane 2:10:10:10 */
+
 /*
  * 2 plane YCbCr
  * index 0 = Y plane, [7:0] Y

-- 
2.43.0
Re: [PATCH v9 02/11] drm/fourcc: Add DRM_FORMAT_XV20
Posted by Simon Ser 1 week ago
On Wednesday, March 25th, 2026 at 15:02, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> wrote:

> XV20 is 2 plane 10 bit per component YCbCr 2x1 subsampled format. XV20
> is similar to the already existing P030 format, which is 2x2 subsampled.

I don't know for sure the multi-planar YCbCr format name scheme we're
using, but here are my observations looking at P, Q and S formats:

- The first digit indicates sub-sampling. 0 for 2x2, 2 for 2x1, 4 for none.
- The two other digits indicate bits for the Y channel, one of 10, 12, 16.
  One exception: Q401 indicates reverse order for Cb and Cr planes when compared
  to Q410.

P030 is a bit of an outlier here since it's the only one with multiple
Y samples. NV formats are also multi-planar but seem to use a completely
separate scheme.

Given the above I'd say what would make most sense to me is to use P230:
keep the last two digits and change the first one to indicate that the
only difference is the sub-sampling. Does that make sense to you?

Simon