From 8fdc55c03fb7324d784b76d426eb779e5612e684 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Fri, 1 Nov 2024 14:02:36 +0000 Subject: [PATCH] pixel-formats: Add NV15/20/30 YUV 10bpc formats NV15/20/30 are a family of 10bpc YUV formats which have 4 horizontally-adjacent samples packed into a 40-bit cluster. The difference between 15/20/30 is in the subsampling. No fallbacks are provided, as there is no format pairing which would allow us to sensibly unpack the clusters. Signed-off-by: Daniel Stone --- libweston/pixel-formats.c | 21 +++++++++++++++++++++ shared/weston-drm-fourcc.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/libweston/pixel-formats.c b/libweston/pixel-formats.c index 09cae16f3..f432854f4 100644 --- a/libweston/pixel-formats.c +++ b/libweston/pixel-formats.c @@ -495,6 +495,27 @@ static const struct pixel_format_info pixel_format_table[] = { .hsub = 2, .vsub = 2, }, + { + DRM_FORMAT(NV15), + SAMPLER_TYPE(EGL_TEXTURE_Y_UV_WL), + .num_planes = 2, + .hsub = 2, + .vsub = 2, + }, + { + DRM_FORMAT(NV20), + SAMPLER_TYPE(EGL_TEXTURE_Y_UV_WL), + .num_planes = 2, + .hsub = 2, + .vsub = 1, + }, + { + DRM_FORMAT(NV30), + SAMPLER_TYPE(EGL_TEXTURE_Y_UV_WL), + .num_planes = 2, + .hsub = 1, + .vsub = 1, + }, { DRM_FORMAT(NV21), SAMPLER_TYPE(EGL_TEXTURE_Y_UV_WL), diff --git a/shared/weston-drm-fourcc.h b/shared/weston-drm-fourcc.h index 0a013f791..d9a66c34b 100644 --- a/shared/weston-drm-fourcc.h +++ b/shared/weston-drm-fourcc.h @@ -46,4 +46,13 @@ #define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] A:B:G:R 16:16:16:16 little endian */ #endif +/* + * 2 plane YCbCr + * index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian + * index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian + */ +#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled Cr:Cb plane */ +#define DRM_FORMAT_NV20 fourcc_code('N', 'V', '2', '0') /* 2x1 subsampled Cr:Cb plane */ +#define DRM_FORMAT_NV30 fourcc_code('N', 'V', '3', '0') /* non-subsampled Cr:Cb plane */ + #endif