[igt-dev] [PATCH i-g-t 1/2] lib/igt_fb: Add support for Y21x formats as well, v2.
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Fri Mar 8 13:17:22 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 | 16 ++++++++++++
lib/igt_color_encoding.c | 3 +++
lib/igt_fb.c | 46 +++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+)
diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index bab20298f422..9fa7cf7bb274 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -153,6 +153,22 @@ extern "C" {
#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 */
+/*
+ * packed Y2xx indicate for each component, xx valid data occupy msb
+ * 16-xx padding occupy lsb
+ */
+#define DRM_FORMAT_Y210 fourcc_code('Y', '2', '1', '0') /* [63:0] Y0:x:Cb0:x:Y1:x:Cr1:x 10:6:10:6:10:6:10:6 little endian per 2 Y pixels */
+#define DRM_FORMAT_Y212 fourcc_code('Y', '2', '1', '2') /* [63:0] Y0:x:Cb0:x:Y1:x:Cr1:x 12:4:12:4:12:4:12:4 little endian per 2 Y pixels */
+#define DRM_FORMAT_Y216 fourcc_code('Y', '2', '1', '6') /* [63:0] Y0:Cb0:Y1:Cr1 16:16:16:16 little endian per 2 Y pixels */
+
+/*
+ * packed Y4xx indicate for each component, xx valid data occupy msb
+ * 16-xx padding occupy lsb except Y410
+ */
+#define DRM_FORMAT_Y410 fourcc_code('Y', '4', '1', '0') /* [31:0] X:V:Y:U 2:10:10:10 little endian */
+#define DRM_FORMAT_Y412 fourcc_code('Y', '4', '1', '2') /* [63:0] X:x:V:x:Y:x:U:x 12:4:12:4:12:4:12:4 little endian */
+#define DRM_FORMAT_Y416 fourcc_code('Y', '4', '1', '6') /* [63:0] X:V:Y:U 16:16:16:16 little endian */
+
/*
* 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 cc76a9919242..9f9dc1439ee4 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -151,6 +151,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 f49becbd52f0..6c222c02a456 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -236,6 +236,21 @@ static const struct format_desc_struct {
.num_planes = 2, .plane_bpp = { 16, 32 },
.vsub = 2, .hsub = 2,
},
+ { .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 = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
.cairo_id = CAIRO_FORMAT_INVALID,
.num_planes = 1, .plane_bpp = { 128 },
@@ -639,6 +654,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);
@@ -1778,6 +1801,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;
@@ -1808,6 +1834,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];
@@ -1875,6 +1904,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;
@@ -2290,6 +2327,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;
}
@@ -2298,6 +2338,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;
}
@@ -2752,6 +2795,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