Skip to contentSkip to conversation

drm/fourcc: Add MSB-aligned 12- and 14-bit formats

PATCH In review Avi Shif 2 participants 2 messages Oct 22 – Oct 23

Subsystems (2)
lore
Share & tools
lore

Avi Shif

author
#0 lore raw

PATCH 1/1 drm/fourcc: Add MSB-aligned 12- and 14-bit formats

Define padded 12- and 14-bit RGB formats and add their format metadata. Each component occupies a 16-bit word, with the unused bits in the least significant positions.

Add P212, P014 and P214 for two-plane YCbCr buffers, including their plane sizes and chroma subsampling metadata.

Due to collisions with existing DRM FourCC codes, the codes for four-component formats indicate the total number of color bits per pixel rather than the number of bits per component (e.g., '3', '6' and '4', '2').

---
 drivers/gpu/drm/drm_fourcc.c  | 23 ++++++++++++++++++++++-
 include/uapi/drm/drm_fourcc.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fourcc.c +22 -1
index 60cd02b7ea64..608e2d411dfe 100644
@@ -255,6 +255,16 @@ const struct drm_format_info *__drm_format_info(u32 format)
                { .format = DRM_FORMAT_ARGB16161616F,   .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
                { .format = DRM_FORMAT_ABGR16161616F,   .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
                { .format = DRM_FORMAT_AXBXGXRX106106106106, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
+               { .format = DRM_FORMAT_RX124,           .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
+               { .format = DRM_FORMAT_GXRX124124,      .depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+               { .format = DRM_FORMAT_AXBXGXRX124124124124, .depth = 0,
+                 .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1,
+                 .has_alpha = true },
+               { .format = DRM_FORMAT_RX142,           .depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
+               { .format = DRM_FORMAT_GXRX142142,      .depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+               { .format = DRM_FORMAT_AXBXGXRX142142142142, .depth = 0,
+                 .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1,
+                 .has_alpha = true },
                { .format = DRM_FORMAT_XRGB16161616,    .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
                { .format = DRM_FORMAT_XBGR16161616,    .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
                { .format = DRM_FORMAT_ARGB16161616,    .depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
@@ -316,7 +326,10 @@ const struct drm_format_info *__drm_format_info(u32 format)
                  .hsub = 2, .vsub = 2, .is_yuv = true},
                { .format = DRM_FORMAT_P012,            .depth = 0,  .num_planes = 2,
                  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
-                  .hsub = 2, .vsub = 2, .is_yuv = true},
+                 .hsub = 2, .vsub = 2, .is_yuv = true},
+               { .format = DRM_FORMAT_P014,            .depth = 0,  .num_planes = 2,
+                 .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
+                 .hsub = 2, .vsub = 2, .is_yuv = true},
                { .format = DRM_FORMAT_P016,            .depth = 0,  .num_planes = 2,
                  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
                  .hsub = 2, .vsub = 2, .is_yuv = true},
@@ -324,6 +337,14 @@ const struct drm_format_info *__drm_format_info(u32 format)
                  .num_planes = 2, .char_per_block = { 2, 4, 0 },
                  .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
                  .vsub = 1, .is_yuv = true },
+               { .format = DRM_FORMAT_P212,            .depth = 0,
+                 .num_planes = 2, .char_per_block = { 2, 4, 0 },
+                 .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
+                 .vsub = 1, .is_yuv = true },
+               { .format = DRM_FORMAT_P214,            .depth = 0,
+                 .num_planes = 2, .char_per_block = { 2, 4, 0 },
+                 .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
+                 .vsub = 1, .is_yuv = true },
                { .format = DRM_FORMAT_VUY101010,       .depth = 0,
                  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 1, .vsub = 1,
                  .is_yuv = true },
include/uapi/drm/drm_fourcc.h +31 -0
index 0bb049f91524..efd8bc81e91a 100644
@@ -234,6 +234,16 @@ extern "C" {
  */
 #define DRM_FORMAT_AXBXGXRX106106106106 fourcc_code('A', 'B', '1', '0') /* [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian */
 
+/* 12-bit components in 16-bit words, with 4 LSBs unused per component */
+#define DRM_FORMAT_RX124       fourcc_code('R', '0', '1', '2') /* [15:0] R:x 12:4 little endian */
+#define DRM_FORMAT_GXRX124124  fourcc_code('G', 'R', '1', '2') /* [31:0] G:x:R:x 12:4:12:4 little endian */
+#define DRM_FORMAT_AXBXGXRX124124124124 fourcc_code('A', 'B', '3', '6') /* [63:0] A:x:B:x:G:x:R:x 12:4:12:4:12:4:12:4 little endian */
+
+/* 14-bit components in 16-bit words, with 2 LSBs unused per component */
+#define DRM_FORMAT_RX142       fourcc_code('R', '0', '1', '4') /* [15:0] R:x 14:2 little endian */
+#define DRM_FORMAT_GXRX142142  fourcc_code('G', 'R', '1', '4') /* [31:0] G:x:R:x 14:2:14:2 little endian */
+#define DRM_FORMAT_AXBXGXRX142142142142 fourcc_code('A', 'B', '4', '2') /* [63:0] A:x:B:x:G:x:R:x 14:2:14:2:14:2:14:2 little endian */
+
 /* packed YCbCr */
 #define DRM_FORMAT_YUYV                fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
 #define DRM_FORMAT_YVYU                fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
@@ -334,6 +344,20 @@ extern "C" {
  */
 #define DRM_FORMAT_P210                fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */
 
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [12:4] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian
+ */
+#define DRM_FORMAT_P212                fourcc_code('P', '2', '1', '2') /* 2x1 subsampled Cr:Cb plane 12 bits per channel */
+
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [14:2] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [14:2:14:2] little endian
+ */
+#define DRM_FORMAT_P214                fourcc_code('P', '2', '1', '4') /* 2x1 subsampled Cr:Cb plane 14 bits per channel */
+
 /*
  * 2 plane YCbCr MSB aligned
  * index 0 = Y plane, [15:0] Y:x [10:6] little endian
@@ -348,6 +372,13 @@ extern "C" {
  */
 #define DRM_FORMAT_P012                fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */
 
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [14:2] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [14:2:14:2] little endian
+ */
+#define DRM_FORMAT_P014                fourcc_code('P', '0', '1', '4') /* 2x2 subsampled Cr:Cb plane 14 bits per channel */
+
 /*
  * 2 plane YCbCr MSB aligned
  * index 0 = Y plane, [15:0] Y little endian

--
2.55.0

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Avi Shif

Define padded 12- and 14-bit RGB formats and add their format metadata. Each component occupies a 16-bit word, with the unused bits in the least significant positions.

Add P212, P014 and P214 for two-plane YCbCr buffers, including their plane sizes and chroma subsampling metadata.

Quoted 6 lines

Due to collisions with existing DRM FourCC codes, the codes for four-component formats indicate the total number of color bits per pixel rather than the number of bits per component (e.g., '3', '6' and '4', '2').

Best regards,
Liviu

Quoted 112 lines
---
 drivers/gpu/drm/drm_fourcc.c  | 23 ++++++++++++++++++++++-
 include/uapi/drm/drm_fourcc.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_fourcc.c +22 -1
index 60cd02b7ea64..608e2d411dfe 100644
@@ -255,6 +255,16 @@ const struct drm_format_info *__drm_format_info(u32 format)
 		{ .format = DRM_FORMAT_ARGB16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
 		{ .format = DRM_FORMAT_ABGR16161616F,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
 		{ .format = DRM_FORMAT_AXBXGXRX106106106106, .depth = 0, .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
+		{ .format = DRM_FORMAT_RX124,		.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_GXRX124124,	.depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_AXBXGXRX124124124124, .depth = 0,
+		  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1,
+		  .has_alpha = true },
+		{ .format = DRM_FORMAT_RX142,		.depth = 0, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_GXRX142142,	.depth = 0, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
+		{ .format = DRM_FORMAT_AXBXGXRX142142142142, .depth = 0,
+		  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1,
+		  .has_alpha = true },
 		{ .format = DRM_FORMAT_XRGB16161616,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
 		{ .format = DRM_FORMAT_XBGR16161616,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1 },
 		{ .format = DRM_FORMAT_ARGB16161616,	.depth = 0,  .num_planes = 1, .cpp = { 8, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true },
@@ -316,7 +326,10 @@ const struct drm_format_info *__drm_format_info(u32 format)
 		  .hsub = 2, .vsub = 2, .is_yuv = true},
 		{ .format = DRM_FORMAT_P012,		.depth = 0,  .num_planes = 2,
 		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
-		   .hsub = 2, .vsub = 2, .is_yuv = true},
+		  .hsub = 2, .vsub = 2, .is_yuv = true},
+		{ .format = DRM_FORMAT_P014,		.depth = 0,  .num_planes = 2,
+		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
+		  .hsub = 2, .vsub = 2, .is_yuv = true},
 		{ .format = DRM_FORMAT_P016,		.depth = 0,  .num_planes = 2,
 		  .char_per_block = { 2, 4, 0 }, .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 },
 		  .hsub = 2, .vsub = 2, .is_yuv = true},
@@ -324,6 +337,14 @@ const struct drm_format_info *__drm_format_info(u32 format)
 		  .num_planes = 2, .char_per_block = { 2, 4, 0 },
 		  .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
 		  .vsub = 1, .is_yuv = true },
+		{ .format = DRM_FORMAT_P212,		.depth = 0,
+		  .num_planes = 2, .char_per_block = { 2, 4, 0 },
+		  .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
+		  .vsub = 1, .is_yuv = true },
+		{ .format = DRM_FORMAT_P214,		.depth = 0,
+		  .num_planes = 2, .char_per_block = { 2, 4, 0 },
+		  .block_w = { 1, 1, 0 }, .block_h = { 1, 1, 0 }, .hsub = 2,
+		  .vsub = 1, .is_yuv = true },
 		{ .format = DRM_FORMAT_VUY101010,	.depth = 0,
 		  .num_planes = 1, .cpp = { 0, 0, 0 }, .hsub = 1, .vsub = 1,
 		  .is_yuv = true },
include/uapi/drm/drm_fourcc.h +31 -0
index 0bb049f91524..efd8bc81e91a 100644
@@ -234,6 +234,16 @@ extern "C" {
  */
 #define DRM_FORMAT_AXBXGXRX106106106106 fourcc_code('A', 'B', '1', '0') /* [63:0] A:x:B:x:G:x:R:x 10:6:10:6:10:6:10:6 little endian */
 
+/* 12-bit components in 16-bit words, with 4 LSBs unused per component */
+#define DRM_FORMAT_RX124	fourcc_code('R', '0', '1', '2') /* [15:0] R:x 12:4 little endian */
+#define DRM_FORMAT_GXRX124124	fourcc_code('G', 'R', '1', '2') /* [31:0] G:x:R:x 12:4:12:4 little endian */
+#define DRM_FORMAT_AXBXGXRX124124124124 fourcc_code('A', 'B', '3', '6') /* [63:0] A:x:B:x:G:x:R:x 12:4:12:4:12:4:12:4 little endian */
+
+/* 14-bit components in 16-bit words, with 2 LSBs unused per component */
+#define DRM_FORMAT_RX142	fourcc_code('R', '0', '1', '4') /* [15:0] R:x 14:2 little endian */
+#define DRM_FORMAT_GXRX142142	fourcc_code('G', 'R', '1', '4') /* [31:0] G:x:R:x 14:2:14:2 little endian */
+#define DRM_FORMAT_AXBXGXRX142142142142 fourcc_code('A', 'B', '4', '2') /* [63:0] A:x:B:x:G:x:R:x 14:2:14:2:14:2:14:2 little endian */
+
 /* packed YCbCr */
 #define DRM_FORMAT_YUYV		fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
 #define DRM_FORMAT_YVYU		fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
@@ -334,6 +344,20 @@ extern "C" {
  */
 #define DRM_FORMAT_P210		fourcc_code('P', '2', '1', '0') /* 2x1 subsampled Cr:Cb plane, 10 bit per channel */
 
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [12:4] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [12:4:12:4] little endian
+ */
+#define DRM_FORMAT_P212		fourcc_code('P', '2', '1', '2') /* 2x1 subsampled Cr:Cb plane 12 bits per channel */
+
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [14:2] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [14:2:14:2] little endian
+ */
+#define DRM_FORMAT_P214		fourcc_code('P', '2', '1', '4') /* 2x1 subsampled Cr:Cb plane 14 bits per channel */
+
 /*
  * 2 plane YCbCr MSB aligned
  * index 0 = Y plane, [15:0] Y:x [10:6] little endian
@@ -348,6 +372,13 @@ extern "C" {
  */
 #define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane 12 bits per channel */
 
+/*
+ * 2 plane YCbCr MSB aligned
+ * index 0 = Y plane, [15:0] Y:x [14:2] little endian
+ * index 1 = Cr:Cb plane, [31:0] Cr:x:Cb:x [14:2:14:2] little endian
+ */
+#define DRM_FORMAT_P014		fourcc_code('P', '0', '1', '4') /* 2x2 subsampled Cr:Cb plane 14 bits per channel */
+
 /*
  * 2 plane YCbCr MSB aligned
  * index 0 = Y plane, [15:0] Y little endian
Signature · 1 line
2.55.0
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯