[igt-dev] [PATCH v2 3/4] lib/igt_fb: Add support for Y21x formats as well, v2.

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Thu Feb 7 09:21:35 UTC 2019


Those formats are packed like YUYV, but only 16 bits per component.

Changes since v1:
- Rebase on top of upstream YUV changes.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
 include/drm-uapi/drm_fourcc.h |  6 ++++-
 lib/igt_color_encoding.c      |  3 +++
 lib/igt_fb.c                  | 46 +++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index fe6b66ef1756..ff9ea02766ee 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -149,10 +149,14 @@ extern "C" {
 #define DRM_FORMAT_YVYU		fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */
 #define DRM_FORMAT_UYVY		fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
 #define DRM_FORMAT_VYUY		fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
-
 #define DRM_FORMAT_AYUV		fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
 #define DRM_FORMAT_XYUV8888		fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
 
+/* Like YUYV, but 16 bpc, lowest bits unused like in DRM_FORMAT_P01X */
+#define DRM_FORMAT_Y210		fourcc_code('Y', '2', '1', '0')
+#define DRM_FORMAT_Y212		fourcc_code('Y', '2', '1', '2')
+#define DRM_FORMAT_Y216		fourcc_code('Y', '2', '1', '6')
+
 /*
  * packed YCbCr420 2x2 tiled formats
  * first 64 bits will contain Y,Cb,Cr components for a 2x2 tile
diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index b7a12a1e07f7..6f82fcec62e4 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -144,6 +144,9 @@ static const struct color_encoding_format {
 	{ DRM_FORMAT_P010, 65472.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
 	{ DRM_FORMAT_P012, 65520.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
 	{ DRM_FORMAT_P016, 65535.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
+	{ DRM_FORMAT_Y210, 65472.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
+	{ DRM_FORMAT_Y212, 65520.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
+	{ DRM_FORMAT_Y216, 65535.f, 4096.f, 60160.f, 4096.f, 32768.f, 61440.f },
 };
 
 static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 12763cc85c86..cccd6bb98395 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -184,6 +184,21 @@ static const struct format_desc_struct {
 	  .num_planes = 1, .plane_bpp = { 16, },
 	  .hsub = 2, .vsub = 1,
 	},
+	{ .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	  .hsub = 2, .vsub = 1,
+	},
+	{ .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	  .hsub = 2, .vsub = 1,
+	},
+	{ .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	  .hsub = 2, .vsub = 1,
+	},
 	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
 	  .cairo_id = CAIRO_FORMAT_RGB96F,
 	  .num_planes = 2, .plane_bpp = { 16, 32 },
@@ -561,6 +576,14 @@ static void clear_yuv_buffer(struct igt_fb *fb)
 		wmemset(ptr + fb->offsets[1], 0x80008000,
 			fb->strides[1] * fb->plane_height[1] / sizeof(wchar_t));
 		break;
+	case DRM_FORMAT_Y210:
+	case DRM_FORMAT_Y212:
+	case DRM_FORMAT_Y216:
+		wmemset(ptr + fb->offsets[0],
+			full_range ? 0x80000000 : 0x80001000,
+			fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+		break;
+
 	}
 
 	igt_fb_unmap_buffer(fb, ptr);
@@ -1652,6 +1675,9 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_Y210:
+	case DRM_FORMAT_Y212:
+	case DRM_FORMAT_Y216:
 		params->y_inc = 2;
 		params->uv_inc = 4;
 		break;
@@ -1675,6 +1701,9 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_Y210:
+	case DRM_FORMAT_Y212:
+	case DRM_FORMAT_Y216:
 	case DRM_FORMAT_XYUV8888:
 		params->y_stride = fb->strides[0];
 		params->uv_stride = fb->strides[0];
@@ -1720,6 +1749,14 @@ static void get_yuv_parameters(struct igt_fb *fb, struct yuv_parameters *params)
 		params->v_offset = fb->offsets[0];
 		break;
 
+	case DRM_FORMAT_Y210:
+	case DRM_FORMAT_Y212:
+	case DRM_FORMAT_Y216:
+		params->y_offset = fb->offsets[0];
+		params->u_offset = fb->offsets[0] + 2;
+		params->v_offset = fb->offsets[0] + 6;
+		break;
+
 	case DRM_FORMAT_XYUV8888:
 		params->y_offset = fb->offsets[0] + 1;
 		params->u_offset = fb->offsets[0] + 2;
@@ -2121,6 +2158,9 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_P010:
 		case DRM_FORMAT_P012:
 		case DRM_FORMAT_P016:
+		case DRM_FORMAT_Y210:
+		case DRM_FORMAT_Y212:
+		case DRM_FORMAT_Y216:
 			convert_yuv16_to_float(cvt);
 			return;
 		}
@@ -2129,6 +2169,9 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_P010:
 		case DRM_FORMAT_P012:
 		case DRM_FORMAT_P016:
+		case DRM_FORMAT_Y210:
+		case DRM_FORMAT_Y212:
+		case DRM_FORMAT_Y216:
 			convert_float_to_yuv16(cvt);
 			return;
 		}
@@ -2518,6 +2561,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
 	case DRM_FORMAT_P010:
 	case DRM_FORMAT_P012:
 	case DRM_FORMAT_P016:
+	case DRM_FORMAT_Y210:
+	case DRM_FORMAT_Y212:
+	case DRM_FORMAT_Y216:
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
-- 
2.20.1



More information about the igt-dev mailing list