All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/fourcc: Add MSB-aligned 12- and 14-bit formats
@ 2026-10-21 15:03 Avi Shif
  2026-10-23  9:59 ` Liviu Dudau
  0 siblings, 1 reply; 2+ messages in thread
From: Avi Shif @ 2026-10-21 15:03 UTC (permalink / raw)
  To: mripard, tzimmermann, airlied, simona, dri-devel
  Cc: liviu.dudau, Lisa.wu, rosen.zhelev, 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.

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').

Signed-off-by: Avi Shif <avi.shif@arm.com>
---
 drivers/gpu/drm/drm_fourcc.c  | 23 ++++++++++++++++++++++-
 include/uapi/drm/drm_fourcc.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index 60cd02b7ea64..608e2d411dfe 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -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 },
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 0bb049f91524..efd8bc81e91a 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -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.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/fourcc: Add MSB-aligned 12- and 14-bit formats
  2026-10-21 15:03 [PATCH] drm/fourcc: Add MSB-aligned 12- and 14-bit formats Avi Shif
@ 2026-10-23  9:59 ` Liviu Dudau
  0 siblings, 0 replies; 2+ messages in thread
From: Liviu Dudau @ 2026-10-23  9:59 UTC (permalink / raw)
  To: Avi Shif
  Cc: mripard, tzimmermann, airlied, simona, dri-devel, Lisa.wu,
	rosen.zhelev

On Wed, Oct 21, 2026 at 06:03:48PM +0300, Avi Shif wrote:
> 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').
> 
> Signed-off-by: Avi Shif <avi.shif@arm.com>

Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>

Best regards,
Liviu

> ---
>  drivers/gpu/drm/drm_fourcc.c  | 23 ++++++++++++++++++++++-
>  include/uapi/drm/drm_fourcc.h | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index 60cd02b7ea64..608e2d411dfe 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -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 },
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
> index 0bb049f91524..efd8bc81e91a 100644
> --- a/include/uapi/drm/drm_fourcc.h
> +++ b/include/uapi/drm/drm_fourcc.h
> @@ -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
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-23 10:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 15:03 [PATCH] drm/fourcc: Add MSB-aligned 12- and 14-bit formats Avi Shif
2026-10-23  9:59 ` Liviu Dudau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.