All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes.
@ 2019-02-01 11:15 Maarten Lankhorst
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-01 11:15 UTC (permalink / raw)
  To: igt-dev

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_color_encoding.c | 83 +++++++++++++++++++++++++++++++---------
 lib/igt_color_encoding.h |  9 ++++-
 lib/igt_fb.c             | 27 +++++++++----
 3 files changed, 91 insertions(+), 28 deletions(-)

diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index 03e16e0c9658..4cbe18e217e3 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -24,6 +24,8 @@
 #include "igt_color_encoding.h"
 #include "igt_matrix.h"
 #include "igt_core.h"
+#include "igt_fb.h"
+#include "drmtest.h"
 
 struct color_encoding {
 	float kr, kb;
@@ -85,60 +87,105 @@ static struct igt_mat4 ycbcr_to_rgb_matrix(const struct color_encoding *e)
 	return ret;
 }
 
-static struct igt_mat4 ycbcr_input_convert_matrix(enum igt_color_range color_range)
+static struct igt_mat4 ycbcr_input_convert_matrix(enum igt_color_range color_range, float scale,
+						  float ofs_y, float max_y,
+						  float ofs_cbcr, float mid_cbcr, float max_cbcr,
+						  float max_val)
 {
 	struct igt_mat4 t, s;
 
 	if (color_range == IGT_COLOR_YCBCR_FULL_RANGE) {
-		t = igt_matrix_translate(0.0f, -128.0f, -128.0f);
-		s = igt_matrix_scale(1.0f, 2.0f, 2.0f);
+		t = igt_matrix_translate(0.f, -mid_cbcr, -mid_cbcr);
+		s = igt_matrix_scale(scale, 2.0f * scale, 2.0f * scale);
 	} else {
-		t = igt_matrix_translate(-16.0f, -128.0f, -128.0f);
-		s = igt_matrix_scale(255.0f / (235.0f - 16.0f),
-				     255.0f / (240.0f - 128.0f),
-				     255.0f / (240.0f - 128.0f));
+		t = igt_matrix_translate(-ofs_y, -mid_cbcr, -mid_cbcr);
+		s = igt_matrix_scale(scale * max_val / (max_y - ofs_y),
+				     scale * max_val / (max_cbcr - mid_cbcr),
+				     scale * max_val / (max_cbcr - mid_cbcr));
 	}
 
 	return igt_matrix_multiply(&s, &t);
 }
 
-static struct igt_mat4 ycbcr_output_convert_matrix(enum igt_color_range color_range)
+static struct igt_mat4 ycbcr_output_convert_matrix(enum igt_color_range color_range, float scale,
+						   float ofs_y, float max_y,
+						   float ofs_cbcr, float mid_cbcr, float max_cbcr,
+						   float max_val)
 {
 	struct igt_mat4 s, t;
 
 	if (color_range == IGT_COLOR_YCBCR_FULL_RANGE) {
-		s = igt_matrix_scale(1.0f, 0.5f, 0.5f);
-		t = igt_matrix_translate(0.0f, 128.0f, 128.0f);
+		s = igt_matrix_scale(scale, 0.5f * scale, 0.5f * scale);
+		t = igt_matrix_translate(0.f, mid_cbcr, mid_cbcr);
 	} else {
-		s = igt_matrix_scale((235.0f - 16.0f) / 255.0f,
-				     (240.0f - 128.0f) / 255.0f,
-				     (240.0f - 128.0f) / 255.0f);
-		t = igt_matrix_translate(16.0f, 128.0f, 128.0f);
+		s = igt_matrix_scale(scale * (max_y - ofs_y) / max_val,
+				     scale * (max_cbcr - mid_cbcr) / max_val,
+				     scale * (max_cbcr - mid_cbcr) / max_val);
+		t = igt_matrix_translate(ofs_y, mid_cbcr, mid_cbcr);
 	}
 
 	return igt_matrix_multiply(&t, &s);
 }
 
-struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding color_encoding,
+static const struct color_encoding_format {
+	uint32_t fourcc;
+
+	float max_val;
+
+	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
+} formats[] = {
+	{ DRM_FORMAT_XRGB8888, 255.f, },
+	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+};
+
+static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(formats); i++)
+		if (fourcc == formats[i].fourcc)
+			return &formats[i];
+
+	igt_assert_f(0, "Could not look up fourcc %.4s\n", (char *)&fourcc);
+}
+
+struct igt_mat4 igt_ycbcr_to_rgb_matrix(uint32_t from_fourcc,
+					uint32_t to_fourcc,
+					enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range)
 {
 	const struct color_encoding *e = &color_encodings[color_encoding];
 	struct igt_mat4 r, c;
+	const struct color_encoding_format *fycbcr = lookup_fourcc(from_fourcc);
+	const struct color_encoding_format *frgb = lookup_fourcc(to_fourcc);
+	float scale = frgb->max_val / fycbcr->max_val;
 
-	r = ycbcr_input_convert_matrix(color_range);
+	igt_assert(fycbcr->ofs_y && !frgb->ofs_y);
+
+	r = ycbcr_input_convert_matrix(color_range, scale, fycbcr->ofs_y, fycbcr->max_y, fycbcr->ofs_cbcr, fycbcr->mid_cbcr, fycbcr->max_cbcr, fycbcr->max_val);
 	c = ycbcr_to_rgb_matrix(e);
 
 	return igt_matrix_multiply(&c, &r);
 }
 
-struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
+struct igt_mat4 igt_rgb_to_ycbcr_matrix(uint32_t from_fourcc,
+					uint32_t to_fourcc,
+					enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range)
 {
 	const struct color_encoding *e = &color_encodings[color_encoding];
+	const struct color_encoding_format *frgb = lookup_fourcc(from_fourcc);
+	const struct color_encoding_format *fycbcr = lookup_fourcc(to_fourcc);
 	struct igt_mat4 c, r;
+	float scale = fycbcr->max_val / frgb->max_val;
+
+	igt_assert(fycbcr->ofs_y && !frgb->ofs_y);
 
 	c = rgb_to_ycbcr_matrix(e);
-	r = ycbcr_output_convert_matrix(color_range);
+	r = ycbcr_output_convert_matrix(color_range, scale, fycbcr->ofs_y, fycbcr->max_y, fycbcr->ofs_cbcr, fycbcr->mid_cbcr, fycbcr->max_cbcr, fycbcr->max_val);
 
 	return igt_matrix_multiply(&r, &c);
 }
diff --git a/lib/igt_color_encoding.h b/lib/igt_color_encoding.h
index 3884e4939f4c..db45b16d3687 100644
--- a/lib/igt_color_encoding.h
+++ b/lib/igt_color_encoding.h
@@ -25,6 +25,7 @@
 #define __IGT_COLOR_ENCODING_H__
 
 #include <stdbool.h>
+#include <stdint.h>
 
 #include "igt_matrix.h"
 
@@ -44,9 +45,13 @@ enum igt_color_range {
 const char *igt_color_encoding_to_str(enum igt_color_encoding encoding);
 const char *igt_color_range_to_str(enum igt_color_range range);
 
-struct igt_mat4 igt_ycbcr_to_rgb_matrix(enum igt_color_encoding color_encoding,
+struct igt_mat4 igt_ycbcr_to_rgb_matrix(uint32_t ycbcr_fourcc,
+					uint32_t rgb_fourcc,
+					enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range);
-struct igt_mat4 igt_rgb_to_ycbcr_matrix(enum igt_color_encoding color_encoding,
+struct igt_mat4 igt_rgb_to_ycbcr_matrix(uint32_t rgb_fourcc,
+					uint32_t ycbcr_fourcc,
+					enum igt_color_encoding color_encoding,
 					enum igt_color_range color_range);
 
 #endif /* __IGT_COLOR_ENCODING_H__ */
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 5cd1829a3ce4..a971aebb36b3 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1475,7 +1475,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
 		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
-	shadow->strides[0] = ALIGN(width * 4, 16);
+	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
 	shadow->size = ALIGN(shadow->strides[0] * height,
 			     sysconf(_SC_PAGESIZE));
 	ptr = mmap(NULL, shadow->size, PROT_READ | PROT_WRITE,
@@ -1557,7 +1557,9 @@ static void convert_nv12_to_rgb24(struct fb_convert *cvt)
 	uint8_t *rgb24 = cvt->dst.ptr;
 	unsigned int rgb24_stride = cvt->dst.fb->strides[0];
 	unsigned int planar_stride = cvt->src.fb->strides[0];
-	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding,
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
 						    cvt->src.fb->color_range);
 	uint8_t *buf;
 
@@ -1664,7 +1666,9 @@ static void convert_yuv444_to_rgb24(struct fb_convert *cvt)
 	uint8_t *rgb24 = cvt->dst.ptr;
 	unsigned rgb24_stride = cvt->dst.fb->strides[0], xyuv_stride = cvt->src.fb->strides[0];
 	uint8_t *buf = malloc(cvt->src.fb->size);
-	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding,
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
 						    cvt->src.fb->color_range);
 
 	/*
@@ -1705,7 +1709,9 @@ static void convert_rgb24_to_yuv444(struct fb_convert *cvt)
 	uint8_t *rgb24;
 	uint8_t *yuv444 = cvt->dst.ptr + cvt->dst.fb->offsets[0];
 	unsigned int rgb24_stride = cvt->src.fb->strides[0], xyuv_stride = cvt->dst.fb->strides[0];
-	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding,
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
 						    cvt->dst.fb->color_range);
 
 	rgb24 = cvt->src.ptr;
@@ -1737,7 +1743,9 @@ static void convert_rgb24_to_nv12(struct fb_convert *cvt)
 	const uint8_t *rgb24 = cvt->src.ptr;
 	unsigned rgb24_stride = cvt->src.fb->strides[0];
 	unsigned planar_stride = cvt->dst.fb->strides[0];
-	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding,
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
 						    cvt->dst.fb->color_range);
 
 	igt_assert(cvt->src.fb->drm_format == DRM_FORMAT_XRGB8888 &&
@@ -1864,7 +1872,9 @@ static void convert_yuyv_to_rgb24(struct fb_convert *cvt)
 	uint8_t *rgb24 = cvt->dst.ptr;
 	unsigned int rgb24_stride = cvt->dst.fb->strides[0];
 	unsigned int yuyv_stride = cvt->src.fb->strides[0];
-	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->color_encoding,
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
 						    cvt->src.fb->color_range);
 	const unsigned char *swz = yuyv_swizzle(cvt->src.fb->drm_format);
 	uint8_t *buf;
@@ -1925,7 +1935,9 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
 	const uint8_t *rgb24 = cvt->src.ptr;
 	unsigned rgb24_stride = cvt->src.fb->strides[0];
 	unsigned yuyv_stride = cvt->dst.fb->strides[0];
-	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->dst.fb->color_encoding,
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
 						    cvt->dst.fb->color_range);
 	const unsigned char *swz = yuyv_swizzle(cvt->dst.fb->drm_format);
 
@@ -2088,7 +2100,6 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 	struct fb_convert cvt = { };
 
 	igt_assert(blit);
-
 	blit->base.fd = fd;
 	blit->base.fb = fb;
 	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
@ 2019-02-01 11:15 ` Maarten Lankhorst
  2019-02-04 12:46   ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2 Maarten Lankhorst
  2019-02-04 13:22   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Sharma, Swati2
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well Maarten Lankhorst
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-01 11:15 UTC (permalink / raw)
  To: igt-dev

The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
This means they can all be converted the same way. Only the range is slightly different,
and this is handled in the color_encoding implementation.

This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
For more than 8 bits precision a few more patches are required to pixman, pending review:
https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
https://lists.freedesktop.org/archives/pixman/2019-January/004809.html

Once those are merged, we will require the next pixman release for better precision.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 configure.ac                  |   4 +-
 include/drm-uapi/drm_fourcc.h |  10 ++
 lib/igt_color_encoding.c      |   4 +
 lib/igt_fb.c                  | 205 ++++++++++++++++++++++++++++++++--
 lib/igt_fb.h                  |   6 +
 meson.build                   |   4 +-
 6 files changed, 218 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index b46f024f875a..336a05bb3f0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,10 +136,10 @@ fi
 PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3, AC_DEFINE(HAVE_XRANDR, 1, [Have libXrandr]), [have_xrandr=no])
 
 # for testdisplay
-PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0])
+PKG_CHECK_MODULES(CAIRO, [cairo >= 1.17.2])
 PKG_CHECK_MODULES(LIBUDEV, [libudev])
 PKG_CHECK_MODULES(GLIB, [glib-2.0])
-PKG_CHECK_MODULES(PIXMAN, [pixman-1])
+PKG_CHECK_MODULES(PIXMAN, [pixman-1 >= 0.36])
 PKG_CHECK_MODULES(GSL, [gsl], [gsl=yes], [gsl=no])
 AM_CONDITIONAL(HAVE_GSL, [test "x$gsl" = xyes])
 
diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index 4ddf754bab09..c9a5e5787031 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -195,6 +195,16 @@ extern "C" {
 #define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
 #define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
 
+/*
+ * 2 plane YCbCr
+ * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
+ * component xxx msb Y [xxx:16-xxx]
+ * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
+ */
+#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
+#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
+#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
+
 /*
  * 3 plane YCbCr
  * index 0: Y plane, [7:0] Y
diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index 4cbe18e217e3..b7a12a1e07f7 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -135,11 +135,15 @@ static const struct color_encoding_format {
 	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
 } formats[] = {
 	{ DRM_FORMAT_XRGB8888, 255.f, },
+	{ IGT_FORMAT_FLOAT, 1.f, },
 	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ 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 },
 };
 
 static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index a971aebb36b3..8bd0420fc2e4 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -151,6 +151,22 @@ static const struct format_desc_struct {
 	  .cairo_id = CAIRO_FORMAT_RGB24,
 	  .num_planes = 1, .plane_bpp = { 16, },
 	},
+	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
+	  .cairo_id = CAIRO_FORMAT_INVALID,
+	  .num_planes = 1, .plane_bpp = { 128 },
+	},
 };
 #define for_each_format(f)	\
 	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
@@ -239,10 +255,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 
 static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->width, 2);
-
-	return fb->width;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->width, 2);
+		/* fall-thru */
+	default:
+		return fb->width;
+	}
 }
 
 static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
@@ -254,10 +277,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
 
 static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->height, 2);
-
-	return fb->height;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->height, 2);
+		/* fall-thru */
+	default:
+		return fb->height;
+	}
 }
 
 static int fb_num_planes(const struct igt_fb *fb)
@@ -516,6 +546,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					full_range ? 0x00800080 : 0x10801080,
 					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
 				break;
+			case DRM_FORMAT_P010:
+			case DRM_FORMAT_P012:
+			case DRM_FORMAT_P016:
+				wmemset(ptr, full_range ? 0 : 0x10001000,
+					fb->offsets[1] / sizeof(wchar_t));
+				wmemset(ptr + fb->offsets[1], 0x80008000,
+					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
 			}
 			gem_munmap(ptr, fb->size);
 
@@ -1463,6 +1500,7 @@ struct fb_convert_blit_upload {
 };
 
 static void *igt_fb_create_cairo_shadow_buffer(int fd,
+					       unsigned drm_format,
 					       unsigned int width,
 					       unsigned int height,
 					       struct igt_fb *shadow)
@@ -1472,7 +1510,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 	igt_assert(shadow);
 
 	fb_init(shadow, fd, width, height,
-		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
 		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
@@ -1983,6 +2021,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
 	}
 }
 
+static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
+{
+	rgb->d[0] = rgb24[0];
+	rgb->d[1] = rgb24[1];
+	rgb->d[2] = rgb24[2];
+	rgb->d[3] = 1.0f;
+}
+
+static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
+{
+	rgb24[0] = rgb->d[0];
+	rgb24[1] = rgb->d[1];
+	rgb24[2] = rgb->d[2];
+}
+
+static void convert_p01X_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_p01x = cvt->src.fb;
+	struct igt_fb *fb_float = cvt->dst.fb;
+	const uint16_t *y, *uv;
+	void *buf = convert_src_get(cvt);
+	float *ptr = cvt->dst.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
+						    fb_float->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	y = buf + fb_p01x->offsets[0];
+	uv = buf + fb_p01x->offsets[1];
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 yuv[4];
+			struct igt_vec4 rgb[4];
+
+			yuv[0].d[0] = y[j * 2 + 0];
+			yuv[1].d[0] = y[j * 2 + 1];
+			yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
+			yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
+
+			yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
+			yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
+			yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
+
+			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
+			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
+			rgb[2] = igt_matrix_transform(&m, &yuv[2]);
+			rgb[3] = igt_matrix_transform(&m, &yuv[3]);
+
+			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
+			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
+			write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
+			write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_p01X(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_float = cvt->src.fb;
+	struct igt_fb *fb_p01x = cvt->dst.fb;
+	uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
+	uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
+	const float *ptr = cvt->src.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
+						    fb_p01x->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 rgb[4];
+			struct igt_vec4 yuv[4];
+
+			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
+			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
+			read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
+			read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
+
+			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
+			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
+			yuv[2] = igt_matrix_transform(&m, &rgb[2]);
+			yuv[3] = igt_matrix_transform(&m, &rgb[3]);
+
+			y[j * 2 + 0] = yuv[0].d[0];
+			y[j * 2 + 1] = yuv[1].d[0];
+			y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
+			y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
+
+			/*
+			 * We assume the MPEG2 chroma siting convention, where
+			 * pixel center for Cb'Cr' is between the left top and
+			 * bottom pixel in a 2x2 block, so take the average.
+			 */
+			uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
+			uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+}
+
 static void convert_pixman(struct fb_convert *cvt)
 {
 	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
@@ -2058,6 +2214,22 @@ static void fb_convert(struct fb_convert *cvt)
 			convert_rgb24_to_yuyv(cvt);
 			return;
 		}
+	} else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->src.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_p01X_to_float(cvt);
+			return;
+		}
+	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->dst.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_float_to_p01X(cvt);
+			return;
+		}
 	}
 
 	igt_assert_f(false,
@@ -2098,11 +2270,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 {
 	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
 	struct fb_convert cvt = { };
+	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
+	unsigned drm_format;
+
+	if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
+	    f->cairo_id == CAIRO_FORMAT_RGBA128F)
+		drm_format = IGT_FORMAT_FLOAT;
+	else
+		drm_format = DRM_FORMAT_XRGB8888;
 
 	igt_assert(blit);
 	blit->base.fd = fd;
 	blit->base.fb = fb;
-	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
+	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
 							     fb->width,
 							     fb->height,
 							     &blit->shadow_fb);
@@ -2129,7 +2309,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 
 	fb->cairo_surface =
 		cairo_image_surface_create_for_data(blit->shadow_ptr,
-						    CAIRO_FORMAT_RGB24,
+						    f->cairo_id,
 						    fb->width, fb->height,
 						    blit->shadow_fb.strides[0]);
 
@@ -2400,6 +2580,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
 {
 	switch (drm_format) {
 	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 9f027deba842..8c683db5e9ec 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -38,6 +38,12 @@
 
 #include "igt_color_encoding.h"
 
+/*
+ * Internal format to denote a buffer compatible with pixman's
+ * floating point format. Range [0-1].
+ */
+#define IGT_FORMAT_FLOAT fourcc_code('I', 'G', 'F', 'x')
+
 /**
  * igt_fb_t:
  * @fb_id: KMS ID of the framebuffer
diff --git a/meson.build b/meson.build
index b17e67ef7f05..4269f361823d 100644
--- a/meson.build
+++ b/meson.build
@@ -149,7 +149,7 @@ endif
 build_info += 'With libunwind: ' + libunwindinfo
 
 libdw = dependency('libdw', required : true)
-pixman = dependency('pixman-1', required : true)
+pixman = dependency('pixman-1', version : '>= 0.36', required : true)
 
 valgrind = null_dep
 valgrindinfo = 'No'
@@ -162,7 +162,7 @@ if with_valgrind != 'false'
 endif
 build_info += 'Valgrind annotations: ' + valgrindinfo
 
-cairo = dependency('cairo', version : '>1.12.0', required : true)
+cairo = dependency('cairo', version : '>=1.17.2', required : true)
 libudev = dependency('libudev', required : true)
 glib = dependency('glib-2.0', required : true)
 
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
@ 2019-02-01 11:15 ` Maarten Lankhorst
  2019-02-05 13:14   ` Sharma, Swati2
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats Maarten Lankhorst
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-01 11:15 UTC (permalink / raw)
  To: igt-dev

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

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

diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -151,6 +151,18 @@ static const struct format_desc_struct {
 	  .cairo_id = CAIRO_FORMAT_RGB24,
 	  .num_planes = 1, .plane_bpp = { 16, },
 	},
+	{ .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	},
+	{ .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	},
+	{ .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	},
 	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
 	  .cairo_id = CAIRO_FORMAT_RGB96F,
 	  .num_planes = 2, .plane_bpp = { 16, 32 },
@@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					fb->offsets[1] / sizeof(wchar_t));
 				wmemset(ptr + fb->offsets[1], 0x80008000,
 					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
+			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;
 			}
 			gem_munmap(ptr, fb->size);
 
@@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
 	}
 }
 
+
+static void convert_Y21X_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	const uint16_t *yuyv;
+	uint16_t *buf;
+	float *ptr = cvt->dst.ptr;
+	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
+	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
+						    cvt->src.fb->color_range);
+
+	igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
+		    cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
+		    cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
+		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
+
+	yuyv = buf = convert_src_get(cvt);
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
+			/* Convert 2x1 pixel blocks */
+			struct igt_vec4 yuv[2];
+			struct igt_vec4 rgb[2];
+
+			yuv[0].d[0] = yuyv[j * 4 + 0];
+			yuv[1].d[0] = yuyv[j * 4 + 2];
+			yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
+			yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
+			yuv[0].d[3] = yuv[1].d[3] = 1.0f;
+
+			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
+			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
+
+			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
+			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
+		}
+
+		if (cvt->dst.fb->width & 1) {
+			struct igt_vec4 yuv;
+			struct igt_vec4 rgb;
+
+			yuv.d[0] = yuyv[j * 4 + 0];
+			yuv.d[1] = yuyv[j * 4 + 1];
+			yuv.d[2] = yuyv[j * 4 + 3];
+			yuv.d[3] = 1.0f;
+
+			rgb = igt_matrix_transform(&m, &yuv);
+
+			write_rgbf(&ptr[j * 6 + 0], &rgb);
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_Y21X(struct fb_convert *cvt)
+{
+	int i, j;
+	uint16_t *yuyv = cvt->dst.ptr;
+	const float *ptr = cvt->src.ptr;
+	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
+	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
+						    cvt->dst.fb->color_range);
+
+	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
+		   (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
+		    cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
+		    cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
+			/* Convert 2x1 pixel blocks */
+			struct igt_vec4 rgb[2];
+			struct igt_vec4 yuv[2];
+
+			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
+			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
+
+			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
+			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
+
+			yuyv[j * 4 + 0] = yuv[0].d[0];
+			yuyv[j * 4 + 2] = yuv[1].d[0];
+			yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
+			yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
+		}
+
+		if (cvt->dst.fb->width & 1) {
+			struct igt_vec4 rgb;
+			struct igt_vec4 yuv;
+
+			read_rgbf(&rgb, &ptr[j * 6 + 0]);
+
+			yuv = igt_matrix_transform(&m, &rgb);
+
+			yuyv[j * 4 + 0] = yuv.d[0];
+			yuyv[j * 4 + 1] = yuv.d[1];
+			yuyv[j * 4 + 3] = yuv.d[2];
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+}
+
 static void convert_pixman(struct fb_convert *cvt)
 {
 	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
@@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_P016:
 			convert_p01X_to_float(cvt);
 			return;
+		case DRM_FORMAT_Y210:
+		case DRM_FORMAT_Y212:
+		case DRM_FORMAT_Y216:
+			convert_Y21X_to_float(cvt);
+			return;
 		}
 	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
 		switch (cvt->dst.fb->drm_format) {
@@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_P016:
 			convert_float_to_p01X(cvt);
 			return;
+		case DRM_FORMAT_Y210:
+		case DRM_FORMAT_Y212:
+		case DRM_FORMAT_Y216:
+			convert_float_to_Y21X(cvt);
+			return;
 		}
 	}
 
@@ -2583,6 +2726,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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats.
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well Maarten Lankhorst
@ 2019-02-01 11:15 ` Maarten Lankhorst
  2019-02-06 14:26   ` Sharma, Swati2
  2019-02-01 11:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes Patchwork
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-01 11:15 UTC (permalink / raw)
  To: igt-dev

Y410 is packed with compressed a channel and only 32 bpp, like
10 bits RGB formats. Y416 is a packed 16 bits per component format.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 include/drm-uapi/drm_fourcc.h |   3 +
 lib/igt_color_encoding.c      |   2 +
 lib/igt_fb.c                  | 203 ++++++++++++++++++++++++++++++++++
 3 files changed, 208 insertions(+)

diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index 8f1b5f832a09..1d04304a0528 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -157,6 +157,9 @@ extern "C" {
 #define DRM_FORMAT_Y212		fourcc_code('Y', '2', '1', '2')
 #define DRM_FORMAT_Y216		fourcc_code('Y', '2', '1', '6')
 
+#define DRM_FORMAT_Y410		fourcc_code('Y', '4', '1', '0') /* [31:0] A:V:Y:U 2:10:10:10 little endian */
+#define DRM_FORMAT_Y416		fourcc_code('Y', '4', '1', '6') /* [127:0] A: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 6f82fcec62e4..bc9575fca1b4 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -147,6 +147,8 @@ static const struct color_encoding_format {
 	{ 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 },
+	{ DRM_FORMAT_Y410, 1023.f, 64.f, 940.f, 64.f, 512.f, 960.f },
+	{ DRM_FORMAT_Y416, 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 c14cc10d1b73..15c541d1fc4e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -163,6 +163,14 @@ static const struct format_desc_struct {
 	  .cairo_id = CAIRO_FORMAT_RGB96F,
 	  .num_planes = 1, .plane_bpp = { 32, },
 	},
+	{ .name = "Y410", .depth = -1, .drm_id = DRM_FORMAT_Y410,
+	  .cairo_id = CAIRO_FORMAT_RGBA128F,
+	  .num_planes = 1, .plane_bpp = { 32, },
+	},
+	{ .name = "Y416", .depth = -1, .drm_id = DRM_FORMAT_Y416,
+	  .cairo_id = CAIRO_FORMAT_RGBA128F,
+	  .num_planes = 1, .plane_bpp = { 64, },
+	},
 	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
 	  .cairo_id = CAIRO_FORMAT_RGB96F,
 	  .num_planes = 2, .plane_bpp = { 16, 32 },
@@ -572,6 +580,28 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					full_range ? 0x80000000 : 0x80001000,
 					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
 				break;
+			case DRM_FORMAT_Y410:
+				wmemset(ptr + fb->offsets[0],
+					full_range ? 0xc0080000 : 0xc4080040,
+					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+				break;
+			case DRM_FORMAT_Y416: {
+				struct ayuv16 { uint16_t u, y, v, a; };
+				const struct ayuv16 pixel = {
+					.a = 0xffff,
+					.v = full_range ? 0 : 0x1000,
+					.y = 0x8000,
+					.u = full_range ? 0 : 0x1000
+				};
+
+				for (int i = 0; i < fb->plane_height[0]; i++) {
+					struct ayuv16 *cur = ptr + fb->offsets[0] + fb->strides[0] * i;
+
+					for (int j = 0; i < fb->plane_width[0]; j++)
+						*cur++ = pixel;
+				}
+				break;
+				}
 			}
 			gem_munmap(ptr, fb->size);
 
@@ -2272,6 +2302,165 @@ static void convert_float_to_Y21X(struct fb_convert *cvt)
 	}
 }
 
+static void convert_Y410_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	const uint32_t *yuyv;
+	uint32_t *buf;
+	float *ptr = cvt->dst.ptr;
+	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
+	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
+						    cvt->src.fb->color_range);
+
+	igt_assert(cvt->src.fb->drm_format == DRM_FORMAT_Y410 &&
+		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
+
+	yuyv = buf = convert_src_get(cvt);
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			/* Convert 2x1 pixel blocks */
+			struct igt_vec4 yuv;
+			struct igt_vec4 rgb;
+
+			yuv.d[0] = yuyv[j] & 0x3ff;
+			yuv.d[1] = (yuyv[j] >> 10) & 0x3ff;
+			yuv.d[2] = (yuyv[j] >> 20) & 0x3ff;
+			yuv.d[3] = 1.f;
+
+			rgb = igt_matrix_transform(&m, &yuv);
+
+			write_rgbf(&ptr[j * 4 + 0], &rgb);
+			ptr[j * 4 + 3] = (float)(yuyv[j] >> 30) / 3;
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_Y410(struct fb_convert *cvt)
+{
+	int i, j;
+	uint32_t *yuyv = cvt->dst.ptr;
+	const float *ptr = cvt->src.ptr;
+	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
+	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
+						    cvt->dst.fb->color_range);
+
+	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
+		   cvt->dst.fb->drm_format == DRM_FORMAT_Y410);
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			struct igt_vec4 rgb;
+			struct igt_vec4 yuv;
+			uint8_t alpha = ptr[j * 4 + 3] * 3.f + .5f;
+			uint16_t y, cb, cr;
+
+			read_rgbf(&rgb, &ptr[j * 4 + 0]);
+
+			yuv = igt_matrix_transform(&m, &rgb);
+			cr = yuv.d[0];
+			y = yuv.d[1];
+			cb = yuv.d[2];
+
+			yuyv[j] = ((cr & 0x3ff) << 0) |
+				  ((y & 0x3ff) << 10) |
+				  ((cb & 0x3ff) << 20) |
+				  ((alpha & 3) << 30);
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+}
+
+static void convert_Y416_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	const uint16_t *yuyv;
+	uint16_t *buf;
+	float *ptr = cvt->dst.ptr;
+	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
+	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->src.fb->color_encoding,
+						    cvt->src.fb->color_range);
+
+	igt_assert(cvt->src.fb->drm_format == DRM_FORMAT_Y416 &&
+		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
+
+	buf = convert_src_get(cvt);
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			/* Convert 2x1 pixel blocks */
+			struct igt_vec4 yuv;
+			struct igt_vec4 rgb;
+
+			yuv.d[0] = yuyv[j * 4 + 0];
+			yuv.d[1] = yuyv[j * 4 + 1];
+			yuv.d[2] = yuyv[j * 4 + 2];
+			yuv.d[3] = 1.f;
+
+			rgb = igt_matrix_transform(&m, &yuv);
+
+			write_rgbf(&ptr[j * 4 + 0], &rgb);
+			ptr[j * 4 + 3] = (float)yuyv[j * 4 + 3] / 65535.f;
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_Y416(struct fb_convert *cvt)
+{
+	int i, j;
+	uint16_t *yuyv = cvt->dst.ptr;
+	const float *ptr = cvt->src.ptr;
+	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
+	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
+						    cvt->dst.fb->drm_format,
+						    cvt->dst.fb->color_encoding,
+						    cvt->dst.fb->color_range);
+
+	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
+		   cvt->dst.fb->drm_format == DRM_FORMAT_Y416);
+
+	for (i = 0; i < cvt->dst.fb->height; i++) {
+		for (j = 0; j < cvt->dst.fb->width; j++) {
+			struct igt_vec4 rgb;
+			struct igt_vec4 yuv;
+
+			read_rgbf(&rgb, &ptr[j * 4 + 0]);
+
+			yuv = igt_matrix_transform(&m, &rgb);
+
+			yuyv[j * 4 + 0] = yuv.d[0];
+			yuyv[j * 4 + 1] = yuv.d[1];
+			yuyv[j * 4 + 2] = yuv.d[2];
+			yuyv[j * 4 + 3] = ptr[j * 4 + 3] * 65535.f + .5f;
+		}
+
+		ptr += float_stride;
+		yuyv += yuyv_stride;
+	}
+}
+
 static void convert_pixman(struct fb_convert *cvt)
 {
 	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
@@ -2359,6 +2548,12 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_Y216:
 			convert_Y21X_to_float(cvt);
 			return;
+		case DRM_FORMAT_Y410:
+			convert_Y410_to_float(cvt);
+			return;
+		case DRM_FORMAT_Y416:
+			convert_Y416_to_float(cvt);
+			return;
 		}
 	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
 		switch (cvt->dst.fb->drm_format) {
@@ -2372,6 +2567,12 @@ static void fb_convert(struct fb_convert *cvt)
 		case DRM_FORMAT_Y216:
 			convert_float_to_Y21X(cvt);
 			return;
+		case DRM_FORMAT_Y410:
+			convert_float_to_Y410(cvt);
+			return;
+		case DRM_FORMAT_Y416:
+			convert_float_to_Y416(cvt);
+			return;
 		}
 	}
 
@@ -2729,6 +2930,8 @@ bool igt_format_is_yuv(uint32_t drm_format)
 	case DRM_FORMAT_Y210:
 	case DRM_FORMAT_Y212:
 	case DRM_FORMAT_Y216:
+	case DRM_FORMAT_Y410:
+	case DRM_FORMAT_Y416:
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes.
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
                   ` (2 preceding siblings ...)
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats Maarten Lankhorst
@ 2019-02-01 11:37 ` Patchwork
  2019-02-04 13:17 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2) Patchwork
  2019-02-05 15:19 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3) Patchwork
  5 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2019-02-01 11:37 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes.
URL   : https://patchwork.freedesktop.org/series/56083/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
973367176b61e81b5ca811620adb0467f6570aec debugfs: Fix writing an extra zero out of bounds in igt_crc_to_string_extended()

Compiler for C supports argument -Wimplicit-fallthrough=0: YES
Compiler for C supports argument -Wlogical-op: YES
Compiler for C supports argument -Wmissing-declarations: YES
Compiler for C supports argument -Wmissing-format-attribute: YES
Compiler for C supports argument -Wmissing-noreturn: YES
Compiler for C supports argument -Wmissing-prototypes: YES
Compiler for C supports argument -Wnested-externs: YES
Compiler for C supports argument -Wold-style-definition: YES
Compiler for C supports argument -Wpointer-arith: YES
Compiler for C supports argument -Wredundant-decls: YES
Compiler for C supports argument -Wshadow: YES
Compiler for C supports argument -Wstrict-prototypes: YES
Compiler for C supports argument -Wuninitialized: YES
Compiler for C supports argument -Wunused: YES
Compiler for C supports argument -Wno-clobbered: YES
Compiler for C supports argument -Wno-maybe-uninitialized: YES
Compiler for C supports argument -Wno-missing-field-initializers: YES
Compiler for C supports argument -Wno-pointer-arith: YES
Compiler for C supports argument -Wno-sign-compare: YES
Compiler for C supports argument -Wno-type-limits: YES
Compiler for C supports argument -Wno-unused-parameter: YES
Compiler for C supports argument -Wno-unused-result: YES
Compiler for C supports argument -Werror=address: YES
Compiler for C supports argument -Werror=array-bounds: YES
Compiler for C supports argument -Werror=implicit: YES
Compiler for C supports argument -Werror=init-self: YES
Compiler for C supports argument -Werror=int-to-pointer-cast: YES
Compiler for C supports argument -Werror=main: YES
Compiler for C supports argument -Werror=missing-braces: YES
Compiler for C supports argument -Werror=nonnull: YES
Compiler for C supports argument -Werror=pointer-to-int-cast: YES
Compiler for C supports argument -Werror=return-type: YES
Compiler for C supports argument -Werror=sequence-point: YES
Compiler for C supports argument -Werror=trigraphs: YES
Compiler for C supports argument -Werror=write-strings: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Native dependency libdrm found: YES 2.4.97
Native dependency libdrm_intel found: YES 2.4.97
Native dependency libdrm_nouveau found: YES 2.4.91
Native dependency libdrm_amdgpu found: YES 2.4.97
Native dependency pciaccess found: YES 0.14
Native dependency libkmod found: YES 24
Native dependency libprocps found: YES 3.3.12
Native dependency libunwind found: YES 1.21
Native dependency libdw found: YES 0.170
Native dependency pixman-1 found: NO found '0.34.0' but need: '>= 0.36'

meson.build:152:0: ERROR: Invalid version of dependency, need 'pixman-1' ['>= 0.36'] found '0.34.0'.

A full log can be found at /home/cidrm/igt-gpu-tools/build/meson-logs/meson-log.txt

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2.
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
@ 2019-02-04 12:46   ` Maarten Lankhorst
  2019-02-04 14:09     ` Sharma, Swati2
  2019-02-04 13:22   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Sharma, Swati2
  1 sibling, 1 reply; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-04 12:46 UTC (permalink / raw)
  To: igt-dev

The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
This means they can all be converted the same way. Only the range is slightly different,
and this is handled in the color_encoding implementation.

This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
For more than 8 bits precision a few more patches are required to pixman, pending review:
https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
https://lists.freedesktop.org/archives/pixman/2019-January/004809.html

Once those are merged, we will require the next pixman release for better precision.

Changes since v1:
- Add fallback color definitions when compiling on cairo version < 1.17.2.
- Skip when FB creation fails on HDR formats, instead of failing.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 include/drm-uapi/drm_fourcc.h |  10 ++
 lib/igt_color_encoding.c      |   4 +
 lib/igt_fb.c                  | 234 ++++++++++++++++++++++++++++++++--
 lib/igt_fb.h                  |   6 +
 4 files changed, 243 insertions(+), 11 deletions(-)

diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index 4ddf754bab09..c9a5e5787031 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -195,6 +195,16 @@ extern "C" {
 #define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
 #define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
 
+/*
+ * 2 plane YCbCr
+ * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
+ * component xxx msb Y [xxx:16-xxx]
+ * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
+ */
+#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
+#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
+#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
+
 /*
  * 3 plane YCbCr
  * index 0: Y plane, [7:0] Y
diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index 4cbe18e217e3..b7a12a1e07f7 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -135,11 +135,15 @@ static const struct color_encoding_format {
 	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
 } formats[] = {
 	{ DRM_FORMAT_XRGB8888, 255.f, },
+	{ IGT_FORMAT_FLOAT, 1.f, },
 	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ 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 },
 };
 
 static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index a971aebb36b3..30e55eabdfa8 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -62,6 +62,20 @@
 
 #define PIXMAN_invalid	0
 
+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 17, 2)
+/*
+ * We need cairo 1.17.2 to use HDR formats, but the only thing added is a value
+ * to pixman_format_code_t.
+ *
+ * To prevent going outside the enum, make pixman_format_code_t an int and define
+ * ourselves.
+ */
+
+#define CAIRO_FORMAT_RGB96F (6)
+#define CAIRO_FORMAT_RGBA128F (7)
+#define pixman_format_code_t int
+#endif
+
 /* drm fourcc/cairo format maps */
 static const struct format_desc_struct {
 	const char *name;
@@ -151,6 +165,22 @@ static const struct format_desc_struct {
 	  .cairo_id = CAIRO_FORMAT_RGB24,
 	  .num_planes = 1, .plane_bpp = { 16, },
 	},
+	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
+	  .cairo_id = CAIRO_FORMAT_INVALID,
+	  .num_planes = 1, .plane_bpp = { 128 },
+	},
 };
 #define for_each_format(f)	\
 	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
@@ -239,10 +269,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 
 static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->width, 2);
-
-	return fb->width;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->width, 2);
+		/* fall-thru */
+	default:
+		return fb->width;
+	}
 }
 
 static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
@@ -254,10 +291,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
 
 static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->height, 2);
-
-	return fb->height;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->height, 2);
+		/* fall-thru */
+	default:
+		return fb->height;
+	}
 }
 
 static int fb_num_planes(const struct igt_fb *fb)
@@ -516,6 +560,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					full_range ? 0x00800080 : 0x10801080,
 					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
 				break;
+			case DRM_FORMAT_P010:
+			case DRM_FORMAT_P012:
+			case DRM_FORMAT_P016:
+				wmemset(ptr, full_range ? 0 : 0x10001000,
+					fb->offsets[1] / sizeof(wchar_t));
+				wmemset(ptr + fb->offsets[1], 0x80008000,
+					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
 			}
 			gem_munmap(ptr, fb->size);
 
@@ -1463,6 +1514,7 @@ struct fb_convert_blit_upload {
 };
 
 static void *igt_fb_create_cairo_shadow_buffer(int fd,
+					       unsigned drm_format,
 					       unsigned int width,
 					       unsigned int height,
 					       struct igt_fb *shadow)
@@ -1472,7 +1524,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 	igt_assert(shadow);
 
 	fb_init(shadow, fd, width, height,
-		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
 		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
@@ -1983,6 +2035,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
 	}
 }
 
+static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
+{
+	rgb->d[0] = rgb24[0];
+	rgb->d[1] = rgb24[1];
+	rgb->d[2] = rgb24[2];
+	rgb->d[3] = 1.0f;
+}
+
+static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
+{
+	rgb24[0] = rgb->d[0];
+	rgb24[1] = rgb->d[1];
+	rgb24[2] = rgb->d[2];
+}
+
+static void convert_p01X_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_p01x = cvt->src.fb;
+	struct igt_fb *fb_float = cvt->dst.fb;
+	const uint16_t *y, *uv;
+	void *buf = convert_src_get(cvt);
+	float *ptr = cvt->dst.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
+						    fb_float->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	y = buf + fb_p01x->offsets[0];
+	uv = buf + fb_p01x->offsets[1];
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 yuv[4];
+			struct igt_vec4 rgb[4];
+
+			yuv[0].d[0] = y[j * 2 + 0];
+			yuv[1].d[0] = y[j * 2 + 1];
+			yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
+			yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
+
+			yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
+			yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
+			yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
+
+			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
+			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
+			rgb[2] = igt_matrix_transform(&m, &yuv[2]);
+			rgb[3] = igt_matrix_transform(&m, &yuv[3]);
+
+			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
+			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
+			write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
+			write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_p01X(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_float = cvt->src.fb;
+	struct igt_fb *fb_p01x = cvt->dst.fb;
+	uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
+	uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
+	const float *ptr = cvt->src.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
+						    fb_p01x->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 rgb[4];
+			struct igt_vec4 yuv[4];
+
+			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
+			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
+			read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
+			read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
+
+			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
+			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
+			yuv[2] = igt_matrix_transform(&m, &rgb[2]);
+			yuv[3] = igt_matrix_transform(&m, &rgb[3]);
+
+			y[j * 2 + 0] = yuv[0].d[0];
+			y[j * 2 + 1] = yuv[1].d[0];
+			y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
+			y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
+
+			/*
+			 * We assume the MPEG2 chroma siting convention, where
+			 * pixel center for Cb'Cr' is between the left top and
+			 * bottom pixel in a 2x2 block, so take the average.
+			 */
+			uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
+			uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+}
+
 static void convert_pixman(struct fb_convert *cvt)
 {
 	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
@@ -2058,6 +2228,22 @@ static void fb_convert(struct fb_convert *cvt)
 			convert_rgb24_to_yuyv(cvt);
 			return;
 		}
+	} else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->src.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_p01X_to_float(cvt);
+			return;
+		}
+	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->dst.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_float_to_p01X(cvt);
+			return;
+		}
 	}
 
 	igt_assert_f(false,
@@ -2098,11 +2284,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 {
 	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
 	struct fb_convert cvt = { };
+	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
+	unsigned drm_format;
+
+	if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
+	    f->cairo_id == CAIRO_FORMAT_RGBA128F)
+		drm_format = IGT_FORMAT_FLOAT;
+	else
+		drm_format = DRM_FORMAT_XRGB8888;
 
 	igt_assert(blit);
 	blit->base.fd = fd;
 	blit->base.fb = fb;
-	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
+	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
 							     fb->width,
 							     fb->height,
 							     &blit->shadow_fb);
@@ -2129,7 +2323,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 
 	fb->cairo_surface =
 		cairo_image_surface_create_for_data(blit->shadow_ptr,
-						    CAIRO_FORMAT_RGB24,
+						    f->cairo_id,
 						    fb->width, fb->height,
 						    blit->shadow_fb.strides[0]);
 
@@ -2194,6 +2388,21 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
 			create_cairo_surface__blit(fd, fb);
 		else
 			create_cairo_surface__gtt(fd, fb);
+
+		if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
+		    f->cairo_id == CAIRO_FORMAT_RGBA128F) {
+			cairo_status_t status = cairo_surface_status(fb->cairo_surface);
+
+			igt_skip_on_f(status == CAIRO_STATUS_INVALID_FORMAT &&
+				      cairo_version() < CAIRO_VERSION_ENCODE(1, 17, 2),
+				      "Cairo version too old, need 1.17.2, have %s\n",
+				      cairo_version_string());
+
+			igt_skip_on_f(status == CAIRO_STATUS_NO_MEMORY &&
+				      pixman_version() < PIXMAN_VERSION_ENCODE(0, 36, 0),
+				      "Pixman version too old, need 0.36.0, have %s\n",
+				      pixman_version_string());
+		}
 	}
 
 	igt_assert(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS);
@@ -2400,6 +2609,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
 {
 	switch (drm_format) {
 	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 9f027deba842..8c683db5e9ec 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -38,6 +38,12 @@
 
 #include "igt_color_encoding.h"
 
+/*
+ * Internal format to denote a buffer compatible with pixman's
+ * floating point format. Range [0-1].
+ */
+#define IGT_FORMAT_FLOAT fourcc_code('I', 'G', 'F', 'x')
+
 /**
  * igt_fb_t:
  * @fb_id: KMS ID of the framebuffer
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2)
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
                   ` (3 preceding siblings ...)
  2019-02-01 11:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes Patchwork
@ 2019-02-04 13:17 ` Patchwork
  2019-02-05 15:19 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3) Patchwork
  5 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2019-02-04 13:17 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2)
URL   : https://patchwork.freedesktop.org/series/56083/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_5536 -> IGTPW_2340
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with IGTPW_2340 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_2340, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/56083/revisions/2/mbox/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in IGTPW_2340:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live_sanitycheck:
    - fi-skl-6770hq:      PASS -> INCOMPLETE

  
Known issues
------------

  Here are the changes found in IGTPW_2340 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
    - fi-byt-clapper:     PASS -> FAIL [fdo#103191] / [fdo#107362]

  * igt@prime_vgem@basic-fence-flip:
    - fi-gdg-551:         PASS -> DMESG-FAIL [fdo#103182]

  
#### Possible fixes ####

  * igt@kms_busy@basic-flip-a:
    - fi-gdg-551:         FAIL [fdo#103182] -> PASS

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       FAIL [fdo#109485] -> PASS

  * igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
    - fi-skl-guc:         FAIL [fdo#103191] / [fdo#107362] -> PASS

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
    - fi-blb-e6850:       INCOMPLETE [fdo#107718] -> PASS

  * igt@prime_vgem@basic-fence-flip:
    - fi-ilk-650:         FAIL [fdo#104008] -> PASS

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
  [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
  [fdo#104008]: https://bugs.freedesktop.org/show_bug.cgi?id=104008
  [fdo#105998]: https://bugs.freedesktop.org/show_bug.cgi?id=105998
  [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
  [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
  [fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
  [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
  [fdo#109294]: https://bugs.freedesktop.org/show_bug.cgi?id=109294
  [fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
  [fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485
  [fdo#109527]: https://bugs.freedesktop.org/show_bug.cgi?id=109527
  [fdo#109528]: https://bugs.freedesktop.org/show_bug.cgi?id=109528
  [fdo#109530]: https://bugs.freedesktop.org/show_bug.cgi?id=109530


Participating hosts (46 -> 43)
------------------------------

  Additional (3): fi-icl-y fi-byt-j1900 fi-pnv-d510 
  Missing    (6): fi-kbl-soraka fi-ilk-m540 fi-hsw-peppy fi-byt-squawks fi-bsw-cyan fi-bwr-2160 


Build changes
-------------

    * IGT: IGT_4805 -> IGTPW_2340

  CI_DRM_5536: 0a5caf6e62fb99d027b3e6af226abb47be732f15 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_2340: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2340/
  IGT_4805: cb6610f5a91a08b1d7f8ae910875891003c6f67c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2340/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
  2019-02-04 12:46   ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2 Maarten Lankhorst
@ 2019-02-04 13:22   ` Sharma, Swati2
  2019-02-04 17:06     ` Maarten Lankhorst
  1 sibling, 1 reply; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-04 13:22 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev


On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
> The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
> This means they can all be converted the same way. Only the range is slightly different,
> and this is handled in the color_encoding implementation.
>
> This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
> For more than 8 bits precision a few more patches are required to pixman, pending review:
> https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
> https://lists.freedesktop.org/archives/pixman/2019-January/004809.html
>
> Once those are merged, we will require the next pixman release for better precision.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>   configure.ac                  |   4 +-
>   include/drm-uapi/drm_fourcc.h |  10 ++
>   lib/igt_color_encoding.c      |   4 +
>   lib/igt_fb.c                  | 205 ++++++++++++++++++++++++++++++++--
>   lib/igt_fb.h                  |   6 +
>   meson.build                   |   4 +-
>   6 files changed, 218 insertions(+), 15 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index b46f024f875a..336a05bb3f0d 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -136,10 +136,10 @@ fi
>   PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3, AC_DEFINE(HAVE_XRANDR, 1, [Have libXrandr]), [have_xrandr=no])
>   
>   # for testdisplay
> -PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0])
> +PKG_CHECK_MODULES(CAIRO, [cairo >= 1.17.2])
>   PKG_CHECK_MODULES(LIBUDEV, [libudev])
>   PKG_CHECK_MODULES(GLIB, [glib-2.0])
> -PKG_CHECK_MODULES(PIXMAN, [pixman-1])
> +PKG_CHECK_MODULES(PIXMAN, [pixman-1 >= 0.36])
>   PKG_CHECK_MODULES(GSL, [gsl], [gsl=yes], [gsl=no])
>   AM_CONDITIONAL(HAVE_GSL, [test "x$gsl" = xyes])
>   
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index 4ddf754bab09..c9a5e5787031 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -195,6 +195,16 @@ extern "C" {
>   #define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
>   #define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
>   
> +/*
> + * 2 plane YCbCr
> + * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
> + * component xxx msb Y [xxx:16-xxx]
> + * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
> + */
> +#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
> +#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
> +#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
> +
>   /*
>    * 3 plane YCbCr
>    * index 0: Y plane, [7:0] Y
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index 4cbe18e217e3..b7a12a1e07f7 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -135,11 +135,15 @@ static const struct color_encoding_format {
>   	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
>   } formats[] = {
>   	{ DRM_FORMAT_XRGB8888, 255.f, },
> +	{ IGT_FORMAT_FLOAT, 1.f, },
>   	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
> +	{ 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 },
>   };
>   
>   static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index a971aebb36b3..8bd0420fc2e4 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -151,6 +151,22 @@ static const struct format_desc_struct {
>   	  .cairo_id = CAIRO_FORMAT_RGB24,
>   	  .num_planes = 1, .plane_bpp = { 16, },
>   	},
> +	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
> +	  .cairo_id = CAIRO_FORMAT_INVALID,
> +	  .num_planes = 1, .plane_bpp = { 128 },
> +	},
>   };
>   #define for_each_format(f)	\
>   	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
> @@ -239,10 +255,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
>   
>   static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
>   {
> -	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
> -		return DIV_ROUND_UP(fb->width, 2);
> -
> -	return fb->width;
> +	switch (fb->drm_format) {
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
> +	case DRM_FORMAT_NV12:
> +		if (plane == 1)
> +			return DIV_ROUND_UP(fb->width, 2);
> +		/* fall-thru */
> +	default:
> +		return fb->width;
> +	}
>   }
>   
>   static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
> @@ -254,10 +277,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>   
>   static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
>   {
> -	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
> -		return DIV_ROUND_UP(fb->height, 2);
> -
> -	return fb->height;
> +	switch (fb->drm_format) {
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
> +	case DRM_FORMAT_NV12:
> +		if (plane == 1)
> +			return DIV_ROUND_UP(fb->height, 2);
> +		/* fall-thru */
> +	default:
> +		return fb->height;
> +	}
>   }
>   
>   static int fb_num_planes(const struct igt_fb *fb)
> @@ -516,6 +546,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>   					full_range ? 0x00800080 : 0x10801080,
>   					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
>   				break;
> +			case DRM_FORMAT_P010:
> +			case DRM_FORMAT_P012:
> +			case DRM_FORMAT_P016:
> +				wmemset(ptr, full_range ? 0 : 0x10001000,
> +					fb->offsets[1] / sizeof(wchar_t));
> +				wmemset(ptr + fb->offsets[1], 0x80008000,
> +					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>   			}
>   			gem_munmap(ptr, fb->size);
>   
> @@ -1463,6 +1500,7 @@ struct fb_convert_blit_upload {
>   };
>   
>   static void *igt_fb_create_cairo_shadow_buffer(int fd,
> +					       unsigned drm_format,
>   					       unsigned int width,
>   					       unsigned int height,
>   					       struct igt_fb *shadow)
> @@ -1472,7 +1510,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
>   	igt_assert(shadow);
>   
>   	fb_init(shadow, fd, width, height,
> -		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
>   		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
>   
>   	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
> @@ -1983,6 +2021,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
>   	}
>   }
>   
> +static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
> +{
> +	rgb->d[0] = rgb24[0];
> +	rgb->d[1] = rgb24[1];
> +	rgb->d[2] = rgb24[2];
> +	rgb->d[3] = 1.0f;
> +}
> +
> +static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
> +{
> +	rgb24[0] = rgb->d[0];
> +	rgb24[1] = rgb->d[1];
> +	rgb24[2] = rgb->d[2];
> +}
> +
> +static void convert_p01X_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	struct igt_fb *fb_p01x = cvt->src.fb;
> +	struct igt_fb *fb_float = cvt->dst.fb;
> +	const uint16_t *y, *uv;
> +	void *buf = convert_src_get(cvt);
> +	float *ptr = cvt->dst.ptr + fb_float->offsets[0];
> +	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
> +	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
> +						    fb_float->drm_format,
> +						    fb_p01x->color_encoding,
> +						    fb_p01x->color_range);
> +
> +	y = buf + fb_p01x->offsets[0];
> +	uv = buf + fb_p01x->offsets[1];
> +
> +	for (i = 0; i < fb_p01x->height / 2; i++) {
> +		for (j = 0; j < fb_p01x->width / 2; j++) {
> +			/* Convert 2x2 pixel blocks */
> +			struct igt_vec4 yuv[4];
> +			struct igt_vec4 rgb[4];
> +
> +			yuv[0].d[0] = y[j * 2 + 0];
> +			yuv[1].d[0] = y[j * 2 + 1];
> +			yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
> +			yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
> +
> +			yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
> +			yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
> +			yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
> +
> +			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
> +			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
> +			rgb[2] = igt_matrix_transform(&m, &yuv[2]);
> +			rgb[3] = igt_matrix_transform(&m, &yuv[3]);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
> +			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
> +			write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
> +			write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
> +		}
> +
> +		ptr += 2 * float_stride;
> +		y += 2 * planar_stride;
> +		uv += planar_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_p01X(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	struct igt_fb *fb_float = cvt->src.fb;
> +	struct igt_fb *fb_p01x = cvt->dst.fb;
> +	uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
> +	uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
> +	const float *ptr = cvt->src.ptr + fb_float->offsets[0];
> +	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
> +	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
> +						    fb_p01x->drm_format,
> +						    fb_p01x->color_encoding,
> +						    fb_p01x->color_range);
> +
> +	for (i = 0; i < fb_p01x->height / 2; i++) {
> +		for (j = 0; j < fb_p01x->width / 2; j++) {
> +			/* Convert 2x2 pixel blocks */
> +			struct igt_vec4 rgb[4];
> +			struct igt_vec4 yuv[4];
> +
> +			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
> +			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
> +			read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
> +			read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
> +
> +			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
> +			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
> +			yuv[2] = igt_matrix_transform(&m, &rgb[2]);
> +			yuv[3] = igt_matrix_transform(&m, &rgb[3]);
> +
> +			y[j * 2 + 0] = yuv[0].d[0];
> +			y[j * 2 + 1] = yuv[1].d[0];
> +			y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
> +			y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
> +
> +			/*
> +			 * We assume the MPEG2 chroma siting convention, where
> +			 * pixel center for Cb'Cr' is between the left top and
> +			 * bottom pixel in a 2x2 block, so take the average.
> +			 */
> +			uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
> +			uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
> +		}
> +
> +		ptr += 2 * float_stride;
> +		y += 2 * planar_stride;
> +		uv += planar_stride;
> +	}
> +}
> +
>   static void convert_pixman(struct fb_convert *cvt)
>   {
>   	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
> @@ -2058,6 +2214,22 @@ static void fb_convert(struct fb_convert *cvt)
>   			convert_rgb24_to_yuyv(cvt);
>   			return;
>   		}
> +	} else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
> +		switch (cvt->src.fb->drm_format) {
> +		case DRM_FORMAT_P010:
> +		case DRM_FORMAT_P012:
> +		case DRM_FORMAT_P016:
> +			convert_p01X_to_float(cvt);
> +			return;
> +		}
> +	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
> +		switch (cvt->dst.fb->drm_format) {
> +		case DRM_FORMAT_P010:
> +		case DRM_FORMAT_P012:
> +		case DRM_FORMAT_P016:
> +			convert_float_to_p01X(cvt);
> +			return;
> +		}
>   	}
>   
>   	igt_assert_f(false,
> @@ -2098,11 +2270,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>   {
>   	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
>   	struct fb_convert cvt = { };
> +	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
> +	unsigned drm_format;
> +
> +	if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
> +	    f->cairo_id == CAIRO_FORMAT_RGBA128F)
> +		drm_format = IGT_FORMAT_FLOAT;
> +	else
> +		drm_format = DRM_FORMAT_XRGB8888;
>   
>   	igt_assert(blit);
>   	blit->base.fd = fd;
>   	blit->base.fb = fb;
> -	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
> +	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
>   							     fb->width,
>   							     fb->height,
>   							     &blit->shadow_fb);
> @@ -2129,7 +2309,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>   
>   	fb->cairo_surface =
>   		cairo_image_surface_create_for_data(blit->shadow_ptr,
> -						    CAIRO_FORMAT_RGB24,
> +						    f->cairo_id,

Hi Maarten,

With this change f->cairo_id, for pixel format AB24 whose 
cairo_id=CAIRO_FORMAT_INVALID and pixman_id!=invalid, when cairo will 
try to create surface it will return non-zero value i.e. 16 
(CAIRO_STATUS_INVALID_FORMAT).  May be some change required in 
igt_get_cairo_surface if condition or need to assign cairo format for 
pixel format having invalid cairo like it was earlier :/

>   						    fb->width, fb->height,
>   						    blit->shadow_fb.strides[0]);
>   
> @@ -2400,6 +2580,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
>   {
>   	switch (drm_format) {
>   	case DRM_FORMAT_NV12:
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
>   	case DRM_FORMAT_YUYV:
>   	case DRM_FORMAT_YVYU:
>   	case DRM_FORMAT_UYVY:
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 9f027deba842..8c683db5e9ec 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -38,6 +38,12 @@
>   
>   #include "igt_color_encoding.h"
>   
> +/*
> + * Internal format to denote a buffer compatible with pixman's
> + * floating point format. Range [0-1].
> + */
> +#define IGT_FORMAT_FLOAT fourcc_code('I', 'G', 'F', 'x')
> +
>   /**
>    * igt_fb_t:
>    * @fb_id: KMS ID of the framebuffer
> diff --git a/meson.build b/meson.build
> index b17e67ef7f05..4269f361823d 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -149,7 +149,7 @@ endif
>   build_info += 'With libunwind: ' + libunwindinfo
>   
>   libdw = dependency('libdw', required : true)
> -pixman = dependency('pixman-1', required : true)
> +pixman = dependency('pixman-1', version : '>= 0.36', required : true)
>   
>   valgrind = null_dep
>   valgrindinfo = 'No'
> @@ -162,7 +162,7 @@ if with_valgrind != 'false'
>   endif
>   build_info += 'Valgrind annotations: ' + valgrindinfo
>   
> -cairo = dependency('cairo', version : '>1.12.0', required : true)
> +cairo = dependency('cairo', version : '>=1.17.2', required : true)
>   libudev = dependency('libudev', required : true)
>   glib = dependency('glib-2.0', required : true)
>   

-- 
Thanks and Regards,
Swati

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2.
  2019-02-04 12:46   ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2 Maarten Lankhorst
@ 2019-02-04 14:09     ` Sharma, Swati2
  2019-02-04 14:49       ` Maarten Lankhorst
  2019-02-05 15:08       ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v3 Maarten Lankhorst
  0 siblings, 2 replies; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-04 14:09 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev


On 04-Feb-19 6:16 PM, Maarten Lankhorst wrote:
> The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
> This means they can all be converted the same way. Only the range is slightly different,
> and this is handled in the color_encoding implementation.
>
> This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
> For more than 8 bits precision a few more patches are required to pixman, pending review:
> https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
> https://lists.freedesktop.org/archives/pixman/2019-January/004809.html
>
> Once those are merged, we will require the next pixman release for better precision.
>
> Changes since v1:
> - Add fallback color definitions when compiling on cairo version < 1.17.2.
> - Skip when FB creation fails on HDR formats, instead of failing.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>   include/drm-uapi/drm_fourcc.h |  10 ++
>   lib/igt_color_encoding.c      |   4 +
>   lib/igt_fb.c                  | 234 ++++++++++++++++++++++++++++++++--
>   lib/igt_fb.h                  |   6 +
>   4 files changed, 243 insertions(+), 11 deletions(-)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index 4ddf754bab09..c9a5e5787031 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -195,6 +195,16 @@ extern "C" {
>   #define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
>   #define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
>   
> +/*
> + * 2 plane YCbCr
> + * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
> + * component xxx msb Y [xxx:16-xxx]
> + * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
> + */
> +#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
> +#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
> +#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
> +
>   /*
>    * 3 plane YCbCr
>    * index 0: Y plane, [7:0] Y
> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
> index 4cbe18e217e3..b7a12a1e07f7 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -135,11 +135,15 @@ static const struct color_encoding_format {
>   	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
>   } formats[] = {
>   	{ DRM_FORMAT_XRGB8888, 255.f, },
> +	{ IGT_FORMAT_FLOAT, 1.f, },
>   	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>   	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
> +	{ 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 },
>   };
>   
>   static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index a971aebb36b3..30e55eabdfa8 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -62,6 +62,20 @@
>   
>   #define PIXMAN_invalid	0
>   
> +#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 17, 2)
> +/*
> + * We need cairo 1.17.2 to use HDR formats, but the only thing added is a value
> + * to pixman_format_code_t.
> + *
> + * To prevent going outside the enum, make pixman_format_code_t an int and define
> + * ourselves.
> + */
> +
> +#define CAIRO_FORMAT_RGB96F (6)
> +#define CAIRO_FORMAT_RGBA128F (7)
> +#define pixman_format_code_t int
> +#endif
> +
>   /* drm fourcc/cairo format maps */
>   static const struct format_desc_struct {
>   	const char *name;
> @@ -151,6 +165,22 @@ static const struct format_desc_struct {
>   	  .cairo_id = CAIRO_FORMAT_RGB24,
>   	  .num_planes = 1, .plane_bpp = { 16, },
>   	},
> +	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 2, .plane_bpp = { 16, 32 },
> +	},
> +	{ .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
> +	  .cairo_id = CAIRO_FORMAT_INVALID,
> +	  .num_planes = 1, .plane_bpp = { 128 },
> +	},
>   };
>   #define for_each_format(f)	\
>   	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
> @@ -239,10 +269,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
>   
>   static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
>   {
> -	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
> -		return DIV_ROUND_UP(fb->width, 2);
> -
> -	return fb->width;
> +	switch (fb->drm_format) {
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
> +	case DRM_FORMAT_NV12:
> +		if (plane == 1)
> +			return DIV_ROUND_UP(fb->width, 2);
> +		/* fall-thru */
> +	default:
> +		return fb->width;
> +	}
>   }
>   
>   static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
> @@ -254,10 +291,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>   
>   static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
>   {
> -	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
> -		return DIV_ROUND_UP(fb->height, 2);
> -
> -	return fb->height;
> +	switch (fb->drm_format) {
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
> +	case DRM_FORMAT_NV12:
> +		if (plane == 1)
> +			return DIV_ROUND_UP(fb->height, 2);
> +		/* fall-thru */
> +	default:
> +		return fb->height;
> +	}
>   }
>   
>   static int fb_num_planes(const struct igt_fb *fb)
> @@ -516,6 +560,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>   					full_range ? 0x00800080 : 0x10801080,
>   					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
>   				break;
> +			case DRM_FORMAT_P010:
> +			case DRM_FORMAT_P012:
> +			case DRM_FORMAT_P016:
> +				wmemset(ptr, full_range ? 0 : 0x10001000,
> +					fb->offsets[1] / sizeof(wchar_t));
> +				wmemset(ptr + fb->offsets[1], 0x80008000,
> +					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>   			}
>   			gem_munmap(ptr, fb->size);
>   
> @@ -1463,6 +1514,7 @@ struct fb_convert_blit_upload {
>   };
>   
>   static void *igt_fb_create_cairo_shadow_buffer(int fd,
> +					       unsigned drm_format,
>   					       unsigned int width,
>   					       unsigned int height,
>   					       struct igt_fb *shadow)
> @@ -1472,7 +1524,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
>   	igt_assert(shadow);
>   
>   	fb_init(shadow, fd, width, height,
> -		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
> +		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
>   		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
>   
>   	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
> @@ -1983,6 +2035,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
>   	}
>   }
>   
> +static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
> +{
> +	rgb->d[0] = rgb24[0];
> +	rgb->d[1] = rgb24[1];
> +	rgb->d[2] = rgb24[2];
> +	rgb->d[3] = 1.0f;
> +}
> +
> +static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
> +{
> +	rgb24[0] = rgb->d[0];
> +	rgb24[1] = rgb->d[1];
> +	rgb24[2] = rgb->d[2];
> +}
> +
> +static void convert_p01X_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	struct igt_fb *fb_p01x = cvt->src.fb;
> +	struct igt_fb *fb_float = cvt->dst.fb;
> +	const uint16_t *y, *uv;
> +	void *buf = convert_src_get(cvt);
> +	float *ptr = cvt->dst.ptr + fb_float->offsets[0];
> +	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
> +	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
> +						    fb_float->drm_format,
> +						    fb_p01x->color_encoding,
> +						    fb_p01x->color_range);
> +
> +	y = buf + fb_p01x->offsets[0];
> +	uv = buf + fb_p01x->offsets[1];
> +
> +	for (i = 0; i < fb_p01x->height / 2; i++) {
> +		for (j = 0; j < fb_p01x->width / 2; j++) {
> +			/* Convert 2x2 pixel blocks */
> +			struct igt_vec4 yuv[4];
> +			struct igt_vec4 rgb[4];
> +
> +			yuv[0].d[0] = y[j * 2 + 0];
> +			yuv[1].d[0] = y[j * 2 + 1];
> +			yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
> +			yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
> +
> +			yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
> +			yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
> +			yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
> +
> +			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
> +			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
> +			rgb[2] = igt_matrix_transform(&m, &yuv[2]);
> +			rgb[3] = igt_matrix_transform(&m, &yuv[3]);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
> +			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
> +			write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
> +			write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
> +		}
> +
> +		ptr += 2 * float_stride;
> +		y += 2 * planar_stride;
> +		uv += planar_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_p01X(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	struct igt_fb *fb_float = cvt->src.fb;
> +	struct igt_fb *fb_p01x = cvt->dst.fb;
> +	uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
> +	uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
> +	const float *ptr = cvt->src.ptr + fb_float->offsets[0];
> +	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
> +	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
> +						    fb_p01x->drm_format,
> +						    fb_p01x->color_encoding,
> +						    fb_p01x->color_range);
> +
> +	for (i = 0; i < fb_p01x->height / 2; i++) {
> +		for (j = 0; j < fb_p01x->width / 2; j++) {
> +			/* Convert 2x2 pixel blocks */
> +			struct igt_vec4 rgb[4];
> +			struct igt_vec4 yuv[4];
> +
> +			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
> +			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
> +			read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
> +			read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
> +
> +			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
> +			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
> +			yuv[2] = igt_matrix_transform(&m, &rgb[2]);
> +			yuv[3] = igt_matrix_transform(&m, &rgb[3]);
> +
> +			y[j * 2 + 0] = yuv[0].d[0];
> +			y[j * 2 + 1] = yuv[1].d[0];
> +			y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
> +			y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
> +
> +			/*
> +			 * We assume the MPEG2 chroma siting convention, where
> +			 * pixel center for Cb'Cr' is between the left top and
> +			 * bottom pixel in a 2x2 block, so take the average.
> +			 */
> +			uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
> +			uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
> +		}
> +
> +		ptr += 2 * float_stride;
> +		y += 2 * planar_stride;
> +		uv += planar_stride;
> +	}
> +}
> +
>   static void convert_pixman(struct fb_convert *cvt)
>   {
>   	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
> @@ -2058,6 +2228,22 @@ static void fb_convert(struct fb_convert *cvt)
>   			convert_rgb24_to_yuyv(cvt);
>   			return;
>   		}
> +	} else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
> +		switch (cvt->src.fb->drm_format) {
> +		case DRM_FORMAT_P010:
> +		case DRM_FORMAT_P012:
> +		case DRM_FORMAT_P016:
> +			convert_p01X_to_float(cvt);
> +			return;
> +		}
> +	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
> +		switch (cvt->dst.fb->drm_format) {
> +		case DRM_FORMAT_P010:
> +		case DRM_FORMAT_P012:
> +		case DRM_FORMAT_P016:
> +			convert_float_to_p01X(cvt);
> +			return;
> +		}
>   	}
>   
>   	igt_assert_f(false,
> @@ -2098,11 +2284,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>   {
>   	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
>   	struct fb_convert cvt = { };
> +	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
> +	unsigned drm_format;
> +
> +	if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
> +	    f->cairo_id == CAIRO_FORMAT_RGBA128F)
> +		drm_format = IGT_FORMAT_FLOAT;
> +	else
> +		drm_format = DRM_FORMAT_XRGB8888;
>   
>   	igt_assert(blit);
>   	blit->base.fd = fd;
>   	blit->base.fb = fb;
> -	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
> +	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
>   							     fb->width,
>   							     fb->height,
>   							     &blit->shadow_fb);
> @@ -2129,7 +2323,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>   
>   	fb->cairo_surface =
>   		cairo_image_surface_create_for_data(blit->shadow_ptr,
> -						    CAIRO_FORMAT_RGB24,
> +						    f->cairo_id,
>   						    fb->width, fb->height,
>   						    blit->shadow_fb.strides[0]);
>   
> @@ -2194,6 +2388,21 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
>   			create_cairo_surface__blit(fd, fb);
>   		else
>   			create_cairo_surface__gtt(fd, fb);
> +
> +		if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
> +		    f->cairo_id == CAIRO_FORMAT_RGBA128F) {
> +			cairo_status_t status = cairo_surface_status(fb->cairo_surface);
> +
> +			igt_skip_on_f(status == CAIRO_STATUS_INVALID_FORMAT &&
> +				      cairo_version() < CAIRO_VERSION_ENCODE(1, 17, 2),
> +				      "Cairo version too old, need 1.17.2, have %s\n",
> +				      cairo_version_string());
> +
> +			igt_skip_on_f(status == CAIRO_STATUS_NO_MEMORY &&
> +				      pixman_version() < PIXMAN_VERSION_ENCODE(0, 36, 0),
> +				      "Pixman version too old, need 0.36.0, have %s\n",
> +				      pixman_version_string());
> +		}
>   	}

Hi Maarten,

Though I have installed cairo and pixman versions 1.17.3 and 37.1 
respectively as seen in /usr/include/cairo and /usr/include/pixman-1 
versions file . Still cairo_version() and pixman_version() prints the 
old 1.14.06 and 33.06 respectively in i-g-t. Are there some changes 
required in i-g-t to link to new releases of cairo and pixman?

>   	igt_assert(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS);
> @@ -2400,6 +2609,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
>   {
>   	switch (drm_format) {
>   	case DRM_FORMAT_NV12:
> +	case DRM_FORMAT_P010:
> +	case DRM_FORMAT_P012:
> +	case DRM_FORMAT_P016:
>   	case DRM_FORMAT_YUYV:
>   	case DRM_FORMAT_YVYU:
>   	case DRM_FORMAT_UYVY:
> diff --git a/lib/igt_fb.h b/lib/igt_fb.h
> index 9f027deba842..8c683db5e9ec 100644
> --- a/lib/igt_fb.h
> +++ b/lib/igt_fb.h
> @@ -38,6 +38,12 @@
>   
>   #include "igt_color_encoding.h"
>   
> +/*
> + * Internal format to denote a buffer compatible with pixman's
> + * floating point format. Range [0-1].
> + */
> +#define IGT_FORMAT_FLOAT fourcc_code('I', 'G', 'F', 'x')
> +
>   /**
>    * igt_fb_t:
>    * @fb_id: KMS ID of the framebuffer

-- 
Thanks and Regards,
Swati

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2.
  2019-02-04 14:09     ` Sharma, Swati2
@ 2019-02-04 14:49       ` Maarten Lankhorst
  2019-02-05 15:08       ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v3 Maarten Lankhorst
  1 sibling, 0 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-04 14:49 UTC (permalink / raw)
  To: Sharma, Swati2, igt-dev

Op 04-02-2019 om 15:09 schreef Sharma, Swati2:
>
> On 04-Feb-19 6:16 PM, Maarten Lankhorst wrote:
>> The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
>> This means they can all be converted the same way. Only the range is slightly different,
>> and this is handled in the color_encoding implementation.
>>
>> This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
>> For more than 8 bits precision a few more patches are required to pixman, pending review:
>> https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
>> https://lists.freedesktop.org/archives/pixman/2019-January/004809.html
>>
>> Once those are merged, we will require the next pixman release for better precision.
>>
>> Changes since v1:
>> - Add fallback color definitions when compiling on cairo version < 1.17.2.
>> - Skip when FB creation fails on HDR formats, instead of failing.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>   include/drm-uapi/drm_fourcc.h |  10 ++
>>   lib/igt_color_encoding.c      |   4 +
>>   lib/igt_fb.c                  | 234 ++++++++++++++++++++++++++++++++--
>>   lib/igt_fb.h                  |   6 +
>>   4 files changed, 243 insertions(+), 11 deletions(-)
>>
>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>> index 4ddf754bab09..c9a5e5787031 100644
>> --- a/include/drm-uapi/drm_fourcc.h
>> +++ b/include/drm-uapi/drm_fourcc.h
>> @@ -195,6 +195,16 @@ extern "C" {
>>   #define DRM_FORMAT_NV24        fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
>>   #define DRM_FORMAT_NV42        fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
>>   +/*
>> + * 2 plane YCbCr
>> + * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
>> + * component xxx msb Y [xxx:16-xxx]
>> + * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
>> + */
>> +#define DRM_FORMAT_P010        fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
>> +#define DRM_FORMAT_P012        fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
>> +#define DRM_FORMAT_P016        fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
>> +
>>   /*
>>    * 3 plane YCbCr
>>    * index 0: Y plane, [7:0] Y
>> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
>> index 4cbe18e217e3..b7a12a1e07f7 100644
>> --- a/lib/igt_color_encoding.c
>> +++ b/lib/igt_color_encoding.c
>> @@ -135,11 +135,15 @@ static const struct color_encoding_format {
>>       float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
>>   } formats[] = {
>>       { DRM_FORMAT_XRGB8888, 255.f, },
>> +    { IGT_FORMAT_FLOAT, 1.f, },
>>       { DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>> +    { 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 },
>>   };
>>     static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>> index a971aebb36b3..30e55eabdfa8 100644
>> --- a/lib/igt_fb.c
>> +++ b/lib/igt_fb.c
>> @@ -62,6 +62,20 @@
>>     #define PIXMAN_invalid    0
>>   +#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 17, 2)
>> +/*
>> + * We need cairo 1.17.2 to use HDR formats, but the only thing added is a value
>> + * to pixman_format_code_t.
>> + *
>> + * To prevent going outside the enum, make pixman_format_code_t an int and define
>> + * ourselves.
>> + */
>> +
>> +#define CAIRO_FORMAT_RGB96F (6)
>> +#define CAIRO_FORMAT_RGBA128F (7)
>> +#define pixman_format_code_t int
>> +#endif
>> +
>>   /* drm fourcc/cairo format maps */
>>   static const struct format_desc_struct {
>>       const char *name;
>> @@ -151,6 +165,22 @@ static const struct format_desc_struct {
>>         .cairo_id = CAIRO_FORMAT_RGB24,
>>         .num_planes = 1, .plane_bpp = { 16, },
>>       },
>> +    { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
>> +      .cairo_id = CAIRO_FORMAT_INVALID,
>> +      .num_planes = 1, .plane_bpp = { 128 },
>> +    },
>>   };
>>   #define for_each_format(f)    \
>>       for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
>> @@ -239,10 +269,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
>>     static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
>>   {
>> -    if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
>> -        return DIV_ROUND_UP(fb->width, 2);
>> -
>> -    return fb->width;
>> +    switch (fb->drm_format) {
>> +    case DRM_FORMAT_P010:
>> +    case DRM_FORMAT_P012:
>> +    case DRM_FORMAT_P016:
>> +    case DRM_FORMAT_NV12:
>> +        if (plane == 1)
>> +            return DIV_ROUND_UP(fb->width, 2);
>> +        /* fall-thru */
>> +    default:
>> +        return fb->width;
>> +    }
>>   }
>>     static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>> @@ -254,10 +291,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>>     static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
>>   {
>> -    if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
>> -        return DIV_ROUND_UP(fb->height, 2);
>> -
>> -    return fb->height;
>> +    switch (fb->drm_format) {
>> +    case DRM_FORMAT_P010:
>> +    case DRM_FORMAT_P012:
>> +    case DRM_FORMAT_P016:
>> +    case DRM_FORMAT_NV12:
>> +        if (plane == 1)
>> +            return DIV_ROUND_UP(fb->height, 2);
>> +        /* fall-thru */
>> +    default:
>> +        return fb->height;
>> +    }
>>   }
>>     static int fb_num_planes(const struct igt_fb *fb)
>> @@ -516,6 +560,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>                       full_range ? 0x00800080 : 0x10801080,
>>                       fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
>>                   break;
>> +            case DRM_FORMAT_P010:
>> +            case DRM_FORMAT_P012:
>> +            case DRM_FORMAT_P016:
>> +                wmemset(ptr, full_range ? 0 : 0x10001000,
>> +                    fb->offsets[1] / sizeof(wchar_t));
>> +                wmemset(ptr + fb->offsets[1], 0x80008000,
>> +                    DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>               }
>>               gem_munmap(ptr, fb->size);
>>   @@ -1463,6 +1514,7 @@ struct fb_convert_blit_upload {
>>   };
>>     static void *igt_fb_create_cairo_shadow_buffer(int fd,
>> +                           unsigned drm_format,
>>                              unsigned int width,
>>                              unsigned int height,
>>                              struct igt_fb *shadow)
>> @@ -1472,7 +1524,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
>>       igt_assert(shadow);
>>         fb_init(shadow, fd, width, height,
>> -        DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
>> +        drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
>>           IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
>>         shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
>> @@ -1983,6 +2035,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
>>       }
>>   }
>>   +static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
>> +{
>> +    rgb->d[0] = rgb24[0];
>> +    rgb->d[1] = rgb24[1];
>> +    rgb->d[2] = rgb24[2];
>> +    rgb->d[3] = 1.0f;
>> +}
>> +
>> +static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
>> +{
>> +    rgb24[0] = rgb->d[0];
>> +    rgb24[1] = rgb->d[1];
>> +    rgb24[2] = rgb->d[2];
>> +}
>> +
>> +static void convert_p01X_to_float(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    struct igt_fb *fb_p01x = cvt->src.fb;
>> +    struct igt_fb *fb_float = cvt->dst.fb;
>> +    const uint16_t *y, *uv;
>> +    void *buf = convert_src_get(cvt);
>> +    float *ptr = cvt->dst.ptr + fb_float->offsets[0];
>> +    unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
>> +    unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
>> +                            fb_float->drm_format,
>> +                            fb_p01x->color_encoding,
>> +                            fb_p01x->color_range);
>> +
>> +    y = buf + fb_p01x->offsets[0];
>> +    uv = buf + fb_p01x->offsets[1];
>> +
>> +    for (i = 0; i < fb_p01x->height / 2; i++) {
>> +        for (j = 0; j < fb_p01x->width / 2; j++) {
>> +            /* Convert 2x2 pixel blocks */
>> +            struct igt_vec4 yuv[4];
>> +            struct igt_vec4 rgb[4];
>> +
>> +            yuv[0].d[0] = y[j * 2 + 0];
>> +            yuv[1].d[0] = y[j * 2 + 1];
>> +            yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
>> +            yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
>> +
>> +            yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
>> +            yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
>> +            yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
>> +
>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>> +            rgb[2] = igt_matrix_transform(&m, &yuv[2]);
>> +            rgb[3] = igt_matrix_transform(&m, &yuv[3]);
>> +
>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>> +            write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
>> +            write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
>> +        }
>> +
>> +        ptr += 2 * float_stride;
>> +        y += 2 * planar_stride;
>> +        uv += planar_stride;
>> +    }
>> +
>> +    convert_src_put(cvt, buf);
>> +}
>> +
>> +static void convert_float_to_p01X(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    struct igt_fb *fb_float = cvt->src.fb;
>> +    struct igt_fb *fb_p01x = cvt->dst.fb;
>> +    uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
>> +    uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
>> +    const float *ptr = cvt->src.ptr + fb_float->offsets[0];
>> +    unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
>> +    unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
>> +                            fb_p01x->drm_format,
>> +                            fb_p01x->color_encoding,
>> +                            fb_p01x->color_range);
>> +
>> +    for (i = 0; i < fb_p01x->height / 2; i++) {
>> +        for (j = 0; j < fb_p01x->width / 2; j++) {
>> +            /* Convert 2x2 pixel blocks */
>> +            struct igt_vec4 rgb[4];
>> +            struct igt_vec4 yuv[4];
>> +
>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>> +            read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
>> +            read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
>> +
>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>> +            yuv[2] = igt_matrix_transform(&m, &rgb[2]);
>> +            yuv[3] = igt_matrix_transform(&m, &rgb[3]);
>> +
>> +            y[j * 2 + 0] = yuv[0].d[0];
>> +            y[j * 2 + 1] = yuv[1].d[0];
>> +            y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
>> +            y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
>> +
>> +            /*
>> +             * We assume the MPEG2 chroma siting convention, where
>> +             * pixel center for Cb'Cr' is between the left top and
>> +             * bottom pixel in a 2x2 block, so take the average.
>> +             */
>> +            uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
>> +            uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
>> +        }
>> +
>> +        ptr += 2 * float_stride;
>> +        y += 2 * planar_stride;
>> +        uv += planar_stride;
>> +    }
>> +}
>> +
>>   static void convert_pixman(struct fb_convert *cvt)
>>   {
>>       pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>> @@ -2058,6 +2228,22 @@ static void fb_convert(struct fb_convert *cvt)
>>               convert_rgb24_to_yuyv(cvt);
>>               return;
>>           }
>> +    } else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
>> +        switch (cvt->src.fb->drm_format) {
>> +        case DRM_FORMAT_P010:
>> +        case DRM_FORMAT_P012:
>> +        case DRM_FORMAT_P016:
>> +            convert_p01X_to_float(cvt);
>> +            return;
>> +        }
>> +    } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>> +        switch (cvt->dst.fb->drm_format) {
>> +        case DRM_FORMAT_P010:
>> +        case DRM_FORMAT_P012:
>> +        case DRM_FORMAT_P016:
>> +            convert_float_to_p01X(cvt);
>> +            return;
>> +        }
>>       }
>>         igt_assert_f(false,
>> @@ -2098,11 +2284,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>>   {
>>       struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
>>       struct fb_convert cvt = { };
>> +    const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
>> +    unsigned drm_format;
>> +
>> +    if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
>> +        f->cairo_id == CAIRO_FORMAT_RGBA128F)
>> +        drm_format = IGT_FORMAT_FLOAT;
>> +    else
>> +        drm_format = DRM_FORMAT_XRGB8888;
>>         igt_assert(blit);
>>       blit->base.fd = fd;
>>       blit->base.fb = fb;
>> -    blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
>> +    blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
>>                                    fb->width,
>>                                    fb->height,
>>                                    &blit->shadow_fb);
>> @@ -2129,7 +2323,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>>         fb->cairo_surface =
>>           cairo_image_surface_create_for_data(blit->shadow_ptr,
>> -                            CAIRO_FORMAT_RGB24,
>> +                            f->cairo_id,
>>                               fb->width, fb->height,
>>                               blit->shadow_fb.strides[0]);
>>   @@ -2194,6 +2388,21 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
>>               create_cairo_surface__blit(fd, fb);
>>           else
>>               create_cairo_surface__gtt(fd, fb);
>> +
>> +        if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
>> +            f->cairo_id == CAIRO_FORMAT_RGBA128F) {
>> +            cairo_status_t status = cairo_surface_status(fb->cairo_surface);
>> +
>> +            igt_skip_on_f(status == CAIRO_STATUS_INVALID_FORMAT &&
>> +                      cairo_version() < CAIRO_VERSION_ENCODE(1, 17, 2),
>> +                      "Cairo version too old, need 1.17.2, have %s\n",
>> +                      cairo_version_string());
>> +
>> +            igt_skip_on_f(status == CAIRO_STATUS_NO_MEMORY &&
>> +                      pixman_version() < PIXMAN_VERSION_ENCODE(0, 36, 0),
>> +                      "Pixman version too old, need 0.36.0, have %s\n",
>> +                      pixman_version_string());
>> +        }
>>       }
>
> Hi Maarten,
>
> Though I have installed cairo and pixman versions 1.17.3 and 37.1 respectively as seen in /usr/include/cairo and /usr/include/pixman-1 versions file . Still cairo_version() and pixman_version() prints the old 1.14.06 and 33.06 respectively in i-g-t. Are there some changes required in i-g-t to link to new releases of cairo and pixman? 

Hey,

Try "ldd $testfile" ?

Maybe it picks up the wrong libcairo/pixman at runtime.

~Maarten

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats
  2019-02-04 13:22   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Sharma, Swati2
@ 2019-02-04 17:06     ` Maarten Lankhorst
  0 siblings, 0 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-04 17:06 UTC (permalink / raw)
  To: Sharma, Swati2; +Cc: igt-dev

Op 04-02-2019 om 14:22 schreef Sharma, Swati2:
>
> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>> The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
>> This means they can all be converted the same way. Only the range is slightly different,
>> and this is handled in the color_encoding implementation.
>>
>> This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
>> For more than 8 bits precision a few more patches are required to pixman, pending review:
>> https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
>> https://lists.freedesktop.org/archives/pixman/2019-January/004809.html
>>
>> Once those are merged, we will require the next pixman release for better precision.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>   configure.ac                  |   4 +-
>>   include/drm-uapi/drm_fourcc.h |  10 ++
>>   lib/igt_color_encoding.c      |   4 +
>>   lib/igt_fb.c                  | 205 ++++++++++++++++++++++++++++++++--
>>   lib/igt_fb.h                  |   6 +
>>   meson.build                   |   4 +-
>>   6 files changed, 218 insertions(+), 15 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index b46f024f875a..336a05bb3f0d 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -136,10 +136,10 @@ fi
>>   PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3, AC_DEFINE(HAVE_XRANDR, 1, [Have libXrandr]), [have_xrandr=no])
>>     # for testdisplay
>> -PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0])
>> +PKG_CHECK_MODULES(CAIRO, [cairo >= 1.17.2])
>>   PKG_CHECK_MODULES(LIBUDEV, [libudev])
>>   PKG_CHECK_MODULES(GLIB, [glib-2.0])
>> -PKG_CHECK_MODULES(PIXMAN, [pixman-1])
>> +PKG_CHECK_MODULES(PIXMAN, [pixman-1 >= 0.36])
>>   PKG_CHECK_MODULES(GSL, [gsl], [gsl=yes], [gsl=no])
>>   AM_CONDITIONAL(HAVE_GSL, [test "x$gsl" = xyes])
>>   diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>> index 4ddf754bab09..c9a5e5787031 100644
>> --- a/include/drm-uapi/drm_fourcc.h
>> +++ b/include/drm-uapi/drm_fourcc.h
>> @@ -195,6 +195,16 @@ extern "C" {
>>   #define DRM_FORMAT_NV24        fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
>>   #define DRM_FORMAT_NV42        fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
>>   +/*
>> + * 2 plane YCbCr
>> + * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
>> + * component xxx msb Y [xxx:16-xxx]
>> + * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
>> + */
>> +#define DRM_FORMAT_P010        fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
>> +#define DRM_FORMAT_P012        fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
>> +#define DRM_FORMAT_P016        fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
>> +
>>   /*
>>    * 3 plane YCbCr
>>    * index 0: Y plane, [7:0] Y
>> diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
>> index 4cbe18e217e3..b7a12a1e07f7 100644
>> --- a/lib/igt_color_encoding.c
>> +++ b/lib/igt_color_encoding.c
>> @@ -135,11 +135,15 @@ static const struct color_encoding_format {
>>       float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
>>   } formats[] = {
>>       { DRM_FORMAT_XRGB8888, 255.f, },
>> +    { IGT_FORMAT_FLOAT, 1.f, },
>>       { DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>>       { DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
>> +    { 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 },
>>   };
>>     static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
>> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
>> index a971aebb36b3..8bd0420fc2e4 100644
>> --- a/lib/igt_fb.c
>> +++ b/lib/igt_fb.c
>> @@ -151,6 +151,22 @@ static const struct format_desc_struct {
>>         .cairo_id = CAIRO_FORMAT_RGB24,
>>         .num_planes = 1, .plane_bpp = { 16, },
>>       },
>> +    { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 2, .plane_bpp = { 16, 32 },
>> +    },
>> +    { .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
>> +      .cairo_id = CAIRO_FORMAT_INVALID,
>> +      .num_planes = 1, .plane_bpp = { 128 },
>> +    },
>>   };
>>   #define for_each_format(f)    \
>>       for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
>> @@ -239,10 +255,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
>>     static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
>>   {
>> -    if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
>> -        return DIV_ROUND_UP(fb->width, 2);
>> -
>> -    return fb->width;
>> +    switch (fb->drm_format) {
>> +    case DRM_FORMAT_P010:
>> +    case DRM_FORMAT_P012:
>> +    case DRM_FORMAT_P016:
>> +    case DRM_FORMAT_NV12:
>> +        if (plane == 1)
>> +            return DIV_ROUND_UP(fb->width, 2);
>> +        /* fall-thru */
>> +    default:
>> +        return fb->width;
>> +    }
>>   }
>>     static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>> @@ -254,10 +277,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
>>     static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
>>   {
>> -    if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
>> -        return DIV_ROUND_UP(fb->height, 2);
>> -
>> -    return fb->height;
>> +    switch (fb->drm_format) {
>> +    case DRM_FORMAT_P010:
>> +    case DRM_FORMAT_P012:
>> +    case DRM_FORMAT_P016:
>> +    case DRM_FORMAT_NV12:
>> +        if (plane == 1)
>> +            return DIV_ROUND_UP(fb->height, 2);
>> +        /* fall-thru */
>> +    default:
>> +        return fb->height;
>> +    }
>>   }
>>     static int fb_num_planes(const struct igt_fb *fb)
>> @@ -516,6 +546,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>                       full_range ? 0x00800080 : 0x10801080,
>>                       fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
>>                   break;
>> +            case DRM_FORMAT_P010:
>> +            case DRM_FORMAT_P012:
>> +            case DRM_FORMAT_P016:
>> +                wmemset(ptr, full_range ? 0 : 0x10001000,
>> +                    fb->offsets[1] / sizeof(wchar_t));
>> +                wmemset(ptr + fb->offsets[1], 0x80008000,
>> +                    DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>               }
>>               gem_munmap(ptr, fb->size);
>>   @@ -1463,6 +1500,7 @@ struct fb_convert_blit_upload {
>>   };
>>     static void *igt_fb_create_cairo_shadow_buffer(int fd,
>> +                           unsigned drm_format,
>>                              unsigned int width,
>>                              unsigned int height,
>>                              struct igt_fb *shadow)
>> @@ -1472,7 +1510,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
>>       igt_assert(shadow);
>>         fb_init(shadow, fd, width, height,
>> -        DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
>> +        drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
>>           IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
>>         shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
>> @@ -1983,6 +2021,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
>>       }
>>   }
>>   +static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
>> +{
>> +    rgb->d[0] = rgb24[0];
>> +    rgb->d[1] = rgb24[1];
>> +    rgb->d[2] = rgb24[2];
>> +    rgb->d[3] = 1.0f;
>> +}
>> +
>> +static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
>> +{
>> +    rgb24[0] = rgb->d[0];
>> +    rgb24[1] = rgb->d[1];
>> +    rgb24[2] = rgb->d[2];
>> +}
>> +
>> +static void convert_p01X_to_float(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    struct igt_fb *fb_p01x = cvt->src.fb;
>> +    struct igt_fb *fb_float = cvt->dst.fb;
>> +    const uint16_t *y, *uv;
>> +    void *buf = convert_src_get(cvt);
>> +    float *ptr = cvt->dst.ptr + fb_float->offsets[0];
>> +    unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
>> +    unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
>> +                            fb_float->drm_format,
>> +                            fb_p01x->color_encoding,
>> +                            fb_p01x->color_range);
>> +
>> +    y = buf + fb_p01x->offsets[0];
>> +    uv = buf + fb_p01x->offsets[1];
>> +
>> +    for (i = 0; i < fb_p01x->height / 2; i++) {
>> +        for (j = 0; j < fb_p01x->width / 2; j++) {
>> +            /* Convert 2x2 pixel blocks */
>> +            struct igt_vec4 yuv[4];
>> +            struct igt_vec4 rgb[4];
>> +
>> +            yuv[0].d[0] = y[j * 2 + 0];
>> +            yuv[1].d[0] = y[j * 2 + 1];
>> +            yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
>> +            yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
>> +
>> +            yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
>> +            yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
>> +            yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
>> +
>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>> +            rgb[2] = igt_matrix_transform(&m, &yuv[2]);
>> +            rgb[3] = igt_matrix_transform(&m, &yuv[3]);
>> +
>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>> +            write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
>> +            write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
>> +        }
>> +
>> +        ptr += 2 * float_stride;
>> +        y += 2 * planar_stride;
>> +        uv += planar_stride;
>> +    }
>> +
>> +    convert_src_put(cvt, buf);
>> +}
>> +
>> +static void convert_float_to_p01X(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    struct igt_fb *fb_float = cvt->src.fb;
>> +    struct igt_fb *fb_p01x = cvt->dst.fb;
>> +    uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
>> +    uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
>> +    const float *ptr = cvt->src.ptr + fb_float->offsets[0];
>> +    unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
>> +    unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
>> +                            fb_p01x->drm_format,
>> +                            fb_p01x->color_encoding,
>> +                            fb_p01x->color_range);
>> +
>> +    for (i = 0; i < fb_p01x->height / 2; i++) {
>> +        for (j = 0; j < fb_p01x->width / 2; j++) {
>> +            /* Convert 2x2 pixel blocks */
>> +            struct igt_vec4 rgb[4];
>> +            struct igt_vec4 yuv[4];
>> +
>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>> +            read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
>> +            read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
>> +
>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>> +            yuv[2] = igt_matrix_transform(&m, &rgb[2]);
>> +            yuv[3] = igt_matrix_transform(&m, &rgb[3]);
>> +
>> +            y[j * 2 + 0] = yuv[0].d[0];
>> +            y[j * 2 + 1] = yuv[1].d[0];
>> +            y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
>> +            y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
>> +
>> +            /*
>> +             * We assume the MPEG2 chroma siting convention, where
>> +             * pixel center for Cb'Cr' is between the left top and
>> +             * bottom pixel in a 2x2 block, so take the average.
>> +             */
>> +            uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
>> +            uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
>> +        }
>> +
>> +        ptr += 2 * float_stride;
>> +        y += 2 * planar_stride;
>> +        uv += planar_stride;
>> +    }
>> +}
>> +
>>   static void convert_pixman(struct fb_convert *cvt)
>>   {
>>       pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>> @@ -2058,6 +2214,22 @@ static void fb_convert(struct fb_convert *cvt)
>>               convert_rgb24_to_yuyv(cvt);
>>               return;
>>           }
>> +    } else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
>> +        switch (cvt->src.fb->drm_format) {
>> +        case DRM_FORMAT_P010:
>> +        case DRM_FORMAT_P012:
>> +        case DRM_FORMAT_P016:
>> +            convert_p01X_to_float(cvt);
>> +            return;
>> +        }
>> +    } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>> +        switch (cvt->dst.fb->drm_format) {
>> +        case DRM_FORMAT_P010:
>> +        case DRM_FORMAT_P012:
>> +        case DRM_FORMAT_P016:
>> +            convert_float_to_p01X(cvt);
>> +            return;
>> +        }
>>       }
>>         igt_assert_f(false,
>> @@ -2098,11 +2270,19 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>>   {
>>       struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
>>       struct fb_convert cvt = { };
>> +    const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
>> +    unsigned drm_format;
>> +
>> +    if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
>> +        f->cairo_id == CAIRO_FORMAT_RGBA128F)
>> +        drm_format = IGT_FORMAT_FLOAT;
>> +    else
>> +        drm_format = DRM_FORMAT_XRGB8888;
>>         igt_assert(blit);
>>       blit->base.fd = fd;
>>       blit->base.fb = fb;
>> -    blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
>> +    blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
>>                                    fb->width,
>>                                    fb->height,
>>                                    &blit->shadow_fb);
>> @@ -2129,7 +2309,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
>>         fb->cairo_surface =
>>           cairo_image_surface_create_for_data(blit->shadow_ptr,
>> -                            CAIRO_FORMAT_RGB24,
>> +                            f->cairo_id,
>
> Hi Maarten,
>
> With this change f->cairo_id, for pixel format AB24 whose cairo_id=CAIRO_FORMAT_INVALID and pixman_id!=invalid, when cairo will try to create surface it will return non-zero value i.e. 16 (CAIRO_STATUS_INVALID_FORMAT).  May be some change required in igt_get_cairo_surface if condition or need to assign cairo format for pixel format having invalid cairo like it was earlier :/ 


Thanks, will make sure that INVALID_FORMAT is caught. :)

~Maarten

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well Maarten Lankhorst
@ 2019-02-05 13:14   ` Sharma, Swati2
  2019-02-05 14:31     ` Maarten Lankhorst
  0 siblings, 1 reply; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-05 13:14 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev


On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
> Those formats are packed like YUYV, but only 16 bits per component.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>   include/drm-uapi/drm_fourcc.h |   6 +-
>   lib/igt_color_encoding.c      |   3 +
>   lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>   3 files changed, 154 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>   	  .cairo_id = CAIRO_FORMAT_RGB24,
>   	  .num_planes = 1, .plane_bpp = { 16, },
>   	},
> +	{ .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
> +	{ .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
> +	{ .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
> +	  .cairo_id = CAIRO_FORMAT_RGB96F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
>   	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>   	  .cairo_id = CAIRO_FORMAT_RGB96F,
>   	  .num_planes = 2, .plane_bpp = { 16, 32 },
> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>   					fb->offsets[1] / sizeof(wchar_t));
>   				wmemset(ptr + fb->offsets[1], 0x80008000,
>   					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
> +			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;
>   			}
>   			gem_munmap(ptr, fb->size);

Hi Maarten,

While testing Y210 pixel format, IGT is failing with debug message 
showing igt_create_fb() failure

(kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function 
igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
(kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, 
fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, 
fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
(kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument

dmesg showing bad pitch 12800 for Y210 pixel format

[  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for 
plane 0
[  634.104444] [IGT] kms_plane: exiting, ret=99

Can you please confirm whether changes needs to be done from igt or some 
issue with Y2xx driver patches?

> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>   	}
>   }
>   
> +
> +static void convert_Y21X_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	const uint16_t *yuyv;
> +	uint16_t *buf;
> +	float *ptr = cvt->dst.ptr;
> +	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
> +	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->src.fb->color_encoding,
> +						    cvt->src.fb->color_range);
> +
> +	igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
> +		    cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
> +		    cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
> +		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
> +
> +	yuyv = buf = convert_src_get(cvt);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 yuv[2];
> +			struct igt_vec4 rgb[2];
> +
> +			yuv[0].d[0] = yuyv[j * 4 + 0];
> +			yuv[1].d[0] = yuyv[j * 4 + 2];
> +			yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
> +			yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
> +			yuv[0].d[3] = yuv[1].d[3] = 1.0f;
> +
> +			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
> +			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
> +			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
> +		}
> +
> +		if (cvt->dst.fb->width & 1) {
> +			struct igt_vec4 yuv;
> +			struct igt_vec4 rgb;
> +
> +			yuv.d[0] = yuyv[j * 4 + 0];
> +			yuv.d[1] = yuyv[j * 4 + 1];
> +			yuv.d[2] = yuyv[j * 4 + 3];
> +			yuv.d[3] = 1.0f;
> +
> +			rgb = igt_matrix_transform(&m, &yuv);
> +
> +			write_rgbf(&ptr[j * 6 + 0], &rgb);
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_Y21X(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint16_t *yuyv = cvt->dst.ptr;
> +	const float *ptr = cvt->src.ptr;
> +	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
> +	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->dst.fb->color_encoding,
> +						    cvt->dst.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
> +		   (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
> +		    cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
> +		    cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width / 2; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 rgb[2];
> +			struct igt_vec4 yuv[2];
> +
> +			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
> +			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
> +
> +			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
> +			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
> +
> +			yuyv[j * 4 + 0] = yuv[0].d[0];
> +			yuyv[j * 4 + 2] = yuv[1].d[0];
> +			yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
> +			yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
> +		}
> +
> +		if (cvt->dst.fb->width & 1) {
> +			struct igt_vec4 rgb;
> +			struct igt_vec4 yuv;
> +
> +			read_rgbf(&rgb, &ptr[j * 6 + 0]);
> +
> +			yuv = igt_matrix_transform(&m, &rgb);
> +
> +			yuyv[j * 4 + 0] = yuv.d[0];
> +			yuyv[j * 4 + 1] = yuv.d[1];
> +			yuyv[j * 4 + 3] = yuv.d[2];
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +}
> +
>   static void convert_pixman(struct fb_convert *cvt)
>   {
>   	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_P016:
>   			convert_p01X_to_float(cvt);
>   			return;
> +		case DRM_FORMAT_Y210:
> +		case DRM_FORMAT_Y212:
> +		case DRM_FORMAT_Y216:
> +			convert_Y21X_to_float(cvt);
> +			return;
>   		}
>   	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>   		switch (cvt->dst.fb->drm_format) {
> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_P016:
>   			convert_float_to_p01X(cvt);
>   			return;
> +		case DRM_FORMAT_Y210:
> +		case DRM_FORMAT_Y212:
> +		case DRM_FORMAT_Y216:
> +			convert_float_to_Y21X(cvt);
> +			return;
>   		}
>   	}
>   
> @@ -2583,6 +2726,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:

-- 
Thanks and Regards,
Swati

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-05 13:14   ` Sharma, Swati2
@ 2019-02-05 14:31     ` Maarten Lankhorst
  2019-02-06  6:47       ` Sharma, Swati2
  0 siblings, 1 reply; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-05 14:31 UTC (permalink / raw)
  To: Sharma, Swati2, igt-dev

Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>
> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>> Those formats are packed like YUYV, but only 16 bits per component.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>   include/drm-uapi/drm_fourcc.h |   6 +-
>>   lib/igt_color_encoding.c      |   3 +
>>   lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>>   3 files changed, 154 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>> --- a/lib/igt_fb.c
>> +++ b/lib/igt_fb.c
>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>         .cairo_id = CAIRO_FORMAT_RGB24,
>>         .num_planes = 1, .plane_bpp = { 16, },
>>       },
>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 1, .plane_bpp = { 32, },
>> +    },
>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 1, .plane_bpp = { 32, },
>> +    },
>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>> +      .num_planes = 1, .plane_bpp = { 32, },
>> +    },
>>       { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>         .cairo_id = CAIRO_FORMAT_RGB96F,
>>         .num_planes = 2, .plane_bpp = { 16, 32 },
>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>                       fb->offsets[1] / sizeof(wchar_t));
>>                   wmemset(ptr + fb->offsets[1], 0x80008000,
>>                       DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>> +            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;
>>               }
>>               gem_munmap(ptr, fb->size);
>
> Hi Maarten,
>
> While testing Y210 pixel format, IGT is failing with debug message showing igt_create_fb() failure
>
> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>
> dmesg showing bad pitch 12800 for Y210 pixel format
>
> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
> [  634.104444] [IGT] kms_plane: exiting, ret=99
>
> Can you please confirm whether changes needs to be done from igt or some issue with Y2xx driver patches?
>
>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>>       }
>>   }
>>   +
>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    const uint16_t *yuyv;
>> +    uint16_t *buf;
>> +    float *ptr = cvt->dst.ptr;
>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>> +                            cvt->dst.fb->drm_format,
>> +                            cvt->src.fb->color_encoding,
>> +                            cvt->src.fb->color_range);
>> +
>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>> +
>> +    yuyv = buf = convert_src_get(cvt);
>> +
>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>> +            /* Convert 2x1 pixel blocks */
>> +            struct igt_vec4 yuv[2];
>> +            struct igt_vec4 rgb[2];
>> +
>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>> +
>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>> +
>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>> +        }
>> +
>> +        if (cvt->dst.fb->width & 1) {
>> +            struct igt_vec4 yuv;
>> +            struct igt_vec4 rgb;
>> +
>> +            yuv.d[0] = yuyv[j * 4 + 0];
>> +            yuv.d[1] = yuyv[j * 4 + 1];
>> +            yuv.d[2] = yuyv[j * 4 + 3];
>> +            yuv.d[3] = 1.0f;
>> +
>> +            rgb = igt_matrix_transform(&m, &yuv);
>> +
>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>> +        }
>> +
>> +        ptr += float_stride;
>> +        yuyv += yuyv_stride;
>> +    }
>> +
>> +    convert_src_put(cvt, buf);
>> +}
>> +
>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>> +{
>> +    int i, j;
>> +    uint16_t *yuyv = cvt->dst.ptr;
>> +    const float *ptr = cvt->src.ptr;
>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>> +                            cvt->dst.fb->drm_format,
>> +                            cvt->dst.fb->color_encoding,
>> +                            cvt->dst.fb->color_range);
>> +
>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>> +
>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>> +            /* Convert 2x1 pixel blocks */
>> +            struct igt_vec4 rgb[2];
>> +            struct igt_vec4 yuv[2];
>> +
>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>> +
>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>> +
>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>> +        }
>> +
>> +        if (cvt->dst.fb->width & 1) {
>> +            struct igt_vec4 rgb;
>> +            struct igt_vec4 yuv;
>> +
>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>> +
>> +            yuv = igt_matrix_transform(&m, &rgb);
>> +
>> +            yuyv[j * 4 + 0] = yuv.d[0];
>> +            yuyv[j * 4 + 1] = yuv.d[1];
>> +            yuyv[j * 4 + 3] = yuv.d[2];
>> +        }
>> +
>> +        ptr += float_stride;
>> +        yuyv += yuyv_stride;
>> +    }
>> +}
>> +
>>   static void convert_pixman(struct fb_convert *cvt)
>>   {
>>       pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>           case DRM_FORMAT_P016:
>>               convert_p01X_to_float(cvt);
>>               return;
>> +        case DRM_FORMAT_Y210:
>> +        case DRM_FORMAT_Y212:
>> +        case DRM_FORMAT_Y216:
>> +            convert_Y21X_to_float(cvt);
>> +            return;
>>           }
>>       } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>           switch (cvt->dst.fb->drm_format) {
>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>           case DRM_FORMAT_P016:
>>               convert_float_to_p01X(cvt);
>>               return;
>> +        case DRM_FORMAT_Y210:
>> +        case DRM_FORMAT_Y212:
>> +        case DRM_FORMAT_Y216:
>> +            convert_float_to_Y21X(cvt);
>> +            return;
>>           }
>>       }
>>   @@ -2583,6 +2726,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:
>
Can I get the full IGT / dmesg logs? I can't see what the fb dimensions they are.

~Maarten

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v3.
  2019-02-04 14:09     ` Sharma, Swati2
  2019-02-04 14:49       ` Maarten Lankhorst
@ 2019-02-05 15:08       ` Maarten Lankhorst
  1 sibling, 0 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-05 15:08 UTC (permalink / raw)
  To: igt-dev

The P01x formats are planar 16 bits per component, with the unused lower bits set to 0.
This means they can all be converted the same way. Only the range is slightly different,
and this is handled in the color_encoding implementation.

This requires cairo 1.17.2 and pixman 0.36. This works but doesn't give extra precision.
For more than 8 bits precision a few more patches are required to pixman, pending review:
https://lists.freedesktop.org/archives/pixman/2019-January/004815.html
https://lists.freedesktop.org/archives/pixman/2019-January/004809.html

Once those are merged, we will require the next pixman release for better precision.

Changes since v1:
- Add fallback color definitions when compiling on cairo version < 1.17.2.
- Skip when FB creation fails on HDR formats, instead of failing.
Changes since v2:
- Complain slightly harder when pixman/cairo are out of date.
- Create a fb with alpha when converting to pixman formats with alpha.
- Oops, s/pixman_format_code_t/cairo_format_t/

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 configure.ac                  |  11 +-
 include/drm-uapi/drm_fourcc.h |  10 ++
 lib/igt_color_encoding.c      |   4 +
 lib/igt_fb.c                  | 251 ++++++++++++++++++++++++++++++++--
 lib/igt_fb.h                  |   6 +
 meson.build                   |  10 ++
 6 files changed, 279 insertions(+), 13 deletions(-)

diff --git a/configure.ac b/configure.ac
index b46f024f875a..a333cf8d6dbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,10 +136,17 @@ fi
 PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3, AC_DEFINE(HAVE_XRANDR, 1, [Have libXrandr]), [have_xrandr=no])
 
 # for testdisplay
-PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0])
+PKG_CHECK_MODULES(CAIRO, [cairo >= 1.17.2], [],
+	[AC_MSG_WARN([Cairo too old, HDR formats not available. Upgrade to cairo 1.17.2])
+	PKG_CHECK_MODULES(CAIRO, [cairo >= 1.12.0])]
+)
 PKG_CHECK_MODULES(LIBUDEV, [libudev])
 PKG_CHECK_MODULES(GLIB, [glib-2.0])
-PKG_CHECK_MODULES(PIXMAN, [pixman-1])
+PKG_CHECK_MODULES(PIXMAN, [pixman-1 >= 0.36.0], [], [
+	AC_MSG_WARN([Pixman too old, HDR formats not available. Upgrade to pixman 0.36.0])
+	PKG_CHECK_MODULES(PIXMAN, [pixman-1])
+])
+
 PKG_CHECK_MODULES(GSL, [gsl], [gsl=yes], [gsl=no])
 AM_CONDITIONAL(HAVE_GSL, [test "x$gsl" = xyes])
 
diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
index 4ddf754bab09..c9a5e5787031 100644
--- a/include/drm-uapi/drm_fourcc.h
+++ b/include/drm-uapi/drm_fourcc.h
@@ -195,6 +195,16 @@ extern "C" {
 #define DRM_FORMAT_NV24		fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */
 #define DRM_FORMAT_NV42		fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */
 
+/*
+ * 2 plane YCbCr
+ * index 0 = Y plane, [15:0] Y little endian where Pxxx indicate
+ * component xxx msb Y [xxx:16-xxx]
+ * index 1 = Cr:Cb plane, [31:0] Cr:Cb little endian [xxx:16-xxx:xxx:16-xxx]
+ */
+#define DRM_FORMAT_P010		fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cr:Cb plane, 10 bit per channel */
+#define DRM_FORMAT_P012		fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cr:Cb plane, 12 bit per channel */
+#define DRM_FORMAT_P016		fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane, 16 bit per channel */
+
 /*
  * 3 plane YCbCr
  * index 0: Y plane, [7:0] Y
diff --git a/lib/igt_color_encoding.c b/lib/igt_color_encoding.c
index 4cbe18e217e3..b7a12a1e07f7 100644
--- a/lib/igt_color_encoding.c
+++ b/lib/igt_color_encoding.c
@@ -135,11 +135,15 @@ static const struct color_encoding_format {
 	float ofs_y, max_y, ofs_cbcr, mid_cbcr, max_cbcr;
 } formats[] = {
 	{ DRM_FORMAT_XRGB8888, 255.f, },
+	{ IGT_FORMAT_FLOAT, 1.f, },
 	{ DRM_FORMAT_NV12, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YUYV, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_YVYU, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_UYVY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
 	{ DRM_FORMAT_VYUY, 255.f, 16.f, 235.f, 16.f, 128.f, 240.f },
+	{ 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 },
 };
 
 static const struct color_encoding_format *lookup_fourcc(uint32_t fourcc)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index a971aebb36b3..20c637436477 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -62,6 +62,20 @@
 
 #define PIXMAN_invalid	0
 
+#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 17, 2)
+/*
+ * We need cairo 1.17.2 to use HDR formats, but the only thing added is a value
+ * to cairo_format_t.
+ *
+ * To prevent going outside the enum, make cairo_format_t an int and define
+ * ourselves.
+ */
+
+#define CAIRO_FORMAT_RGB96F (6)
+#define CAIRO_FORMAT_RGBA128F (7)
+#define cairo_format_t int
+#endif
+
 /* drm fourcc/cairo format maps */
 static const struct format_desc_struct {
 	const char *name;
@@ -151,6 +165,22 @@ static const struct format_desc_struct {
 	  .cairo_id = CAIRO_FORMAT_RGB24,
 	  .num_planes = 1, .plane_bpp = { 16, },
 	},
+	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P012", .depth = -1, .drm_id = DRM_FORMAT_P012,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "P016", .depth = -1, .drm_id = DRM_FORMAT_P016,
+	  .cairo_id = CAIRO_FORMAT_RGB96F,
+	  .num_planes = 2, .plane_bpp = { 16, 32 },
+	},
+	{ .name = "IGT-FLOAT", .depth = -1, .drm_id = IGT_FORMAT_FLOAT,
+	  .cairo_id = CAIRO_FORMAT_INVALID,
+	  .num_planes = 1, .plane_bpp = { 128 },
+	},
 };
 #define for_each_format(f)	\
 	for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
@@ -239,10 +269,17 @@ void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
 
 static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->width, 2);
-
-	return fb->width;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->width, 2);
+		/* fall-thru */
+	default:
+		return fb->width;
+	}
 }
 
 static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
@@ -254,10 +291,17 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
 
 static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
 {
-	if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
-		return DIV_ROUND_UP(fb->height, 2);
-
-	return fb->height;
+	switch (fb->drm_format) {
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
+	case DRM_FORMAT_NV12:
+		if (plane == 1)
+			return DIV_ROUND_UP(fb->height, 2);
+		/* fall-thru */
+	default:
+		return fb->height;
+	}
 }
 
 static int fb_num_planes(const struct igt_fb *fb)
@@ -516,6 +560,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
 					full_range ? 0x00800080 : 0x10801080,
 					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
 				break;
+			case DRM_FORMAT_P010:
+			case DRM_FORMAT_P012:
+			case DRM_FORMAT_P016:
+				wmemset(ptr, full_range ? 0 : 0x10001000,
+					fb->offsets[1] / sizeof(wchar_t));
+				wmemset(ptr + fb->offsets[1], 0x80008000,
+					DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
 			}
 			gem_munmap(ptr, fb->size);
 
@@ -1463,6 +1514,7 @@ struct fb_convert_blit_upload {
 };
 
 static void *igt_fb_create_cairo_shadow_buffer(int fd,
+					       unsigned drm_format,
 					       unsigned int width,
 					       unsigned int height,
 					       struct igt_fb *shadow)
@@ -1472,7 +1524,7 @@ static void *igt_fb_create_cairo_shadow_buffer(int fd,
 	igt_assert(shadow);
 
 	fb_init(shadow, fd, width, height,
-		DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
+		drm_format, LOCAL_DRM_FORMAT_MOD_NONE,
 		IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);
 
 	shadow->strides[0] = ALIGN(width * shadow->plane_bpp[0], 16);
@@ -1983,6 +2035,124 @@ static void convert_rgb24_to_yuyv(struct fb_convert *cvt)
 	}
 }
 
+static void read_rgbf(struct igt_vec4 *rgb, const float *rgb24)
+{
+	rgb->d[0] = rgb24[0];
+	rgb->d[1] = rgb24[1];
+	rgb->d[2] = rgb24[2];
+	rgb->d[3] = 1.0f;
+}
+
+static void write_rgbf(float *rgb24, const struct igt_vec4 *rgb)
+{
+	rgb24[0] = rgb->d[0];
+	rgb24[1] = rgb->d[1];
+	rgb24[2] = rgb->d[2];
+}
+
+static void convert_p01X_to_float(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_p01x = cvt->src.fb;
+	struct igt_fb *fb_float = cvt->dst.fb;
+	const uint16_t *y, *uv;
+	void *buf = convert_src_get(cvt);
+	float *ptr = cvt->dst.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(fb_p01x->drm_format,
+						    fb_float->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	y = buf + fb_p01x->offsets[0];
+	uv = buf + fb_p01x->offsets[1];
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 yuv[4];
+			struct igt_vec4 rgb[4];
+
+			yuv[0].d[0] = y[j * 2 + 0];
+			yuv[1].d[0] = y[j * 2 + 1];
+			yuv[2].d[0] = y[j * 2 + 0 + planar_stride];
+			yuv[3].d[0] = y[j * 2 + 1 + planar_stride];
+
+			yuv[0].d[1] = yuv[1].d[1] = yuv[2].d[1] = yuv[3].d[1] = uv[j * 2 + 0];
+			yuv[0].d[2] = yuv[1].d[2] = yuv[2].d[2] = yuv[3].d[2] = uv[j * 2 + 1];
+			yuv[0].d[3] = yuv[1].d[3] = yuv[2].d[3] = yuv[3].d[3] = 1.0f;
+
+			rgb[0] = igt_matrix_transform(&m, &yuv[0]);
+			rgb[1] = igt_matrix_transform(&m, &yuv[1]);
+			rgb[2] = igt_matrix_transform(&m, &yuv[2]);
+			rgb[3] = igt_matrix_transform(&m, &yuv[3]);
+
+			write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
+			write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
+			write_rgbf(&ptr[j * 6 + 0 + float_stride], &rgb[2]);
+			write_rgbf(&ptr[j * 6 + 3 + float_stride], &rgb[3]);
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+
+	convert_src_put(cvt, buf);
+}
+
+static void convert_float_to_p01X(struct fb_convert *cvt)
+{
+	int i, j;
+	struct igt_fb *fb_float = cvt->src.fb;
+	struct igt_fb *fb_p01x = cvt->dst.fb;
+	uint16_t *y = cvt->dst.ptr + fb_p01x->offsets[0];
+	uint16_t *uv = cvt->dst.ptr + fb_p01x->offsets[1];
+	const float *ptr = cvt->src.ptr + fb_float->offsets[0];
+	unsigned float_stride = fb_float->strides[0] / sizeof(*ptr);
+	unsigned planar_stride = fb_p01x->strides[0] / sizeof(*y);
+	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(fb_float->drm_format,
+						    fb_p01x->drm_format,
+						    fb_p01x->color_encoding,
+						    fb_p01x->color_range);
+
+	for (i = 0; i < fb_p01x->height / 2; i++) {
+		for (j = 0; j < fb_p01x->width / 2; j++) {
+			/* Convert 2x2 pixel blocks */
+			struct igt_vec4 rgb[4];
+			struct igt_vec4 yuv[4];
+
+			read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
+			read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
+			read_rgbf(&rgb[2], &ptr[j * 6 + 0 + float_stride]);
+			read_rgbf(&rgb[3], &ptr[j * 6 + 3 + float_stride]);
+
+			yuv[0] = igt_matrix_transform(&m, &rgb[0]);
+			yuv[1] = igt_matrix_transform(&m, &rgb[1]);
+			yuv[2] = igt_matrix_transform(&m, &rgb[2]);
+			yuv[3] = igt_matrix_transform(&m, &rgb[3]);
+
+			y[j * 2 + 0] = yuv[0].d[0];
+			y[j * 2 + 1] = yuv[1].d[0];
+			y[j * 2 + 0 + planar_stride] = yuv[2].d[0];
+			y[j * 2 + 1 + planar_stride] = yuv[3].d[0];
+
+			/*
+			 * We assume the MPEG2 chroma siting convention, where
+			 * pixel center for Cb'Cr' is between the left top and
+			 * bottom pixel in a 2x2 block, so take the average.
+			 */
+			uv[j * 2 + 0] = (yuv[0].d[1] + yuv[2].d[1]) / 2.0f;
+			uv[j * 2 + 1] = (yuv[0].d[2] + yuv[2].d[2]) / 2.0f;
+		}
+
+		ptr += 2 * float_stride;
+		y += 2 * planar_stride;
+		uv += planar_stride;
+	}
+}
+
 static void convert_pixman(struct fb_convert *cvt)
 {
 	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
@@ -2058,6 +2228,22 @@ static void fb_convert(struct fb_convert *cvt)
 			convert_rgb24_to_yuyv(cvt);
 			return;
 		}
+	} else if (cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->src.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_p01X_to_float(cvt);
+			return;
+		}
+	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
+		switch (cvt->dst.fb->drm_format) {
+		case DRM_FORMAT_P010:
+		case DRM_FORMAT_P012:
+		case DRM_FORMAT_P016:
+			convert_float_to_p01X(cvt);
+			return;
+		}
 	}
 
 	igt_assert_f(false,
@@ -2098,11 +2284,36 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 {
 	struct fb_convert_blit_upload *blit = malloc(sizeof(*blit));
 	struct fb_convert cvt = { };
+	const struct format_desc_struct *f = lookup_drm_format(fb->drm_format);
+	unsigned drm_format;
+	cairo_format_t cairo_id;
+
+	if (f->cairo_id != CAIRO_FORMAT_INVALID) {
+		cairo_id = f->cairo_id;
+
+		switch (f->cairo_id) {
+		case CAIRO_FORMAT_RGB96F:
+		case CAIRO_FORMAT_RGBA128F:
+			drm_format = IGT_FORMAT_FLOAT;
+			break;
+		case CAIRO_FORMAT_RGB24:
+			drm_format = DRM_FORMAT_XRGB8888;
+			break;
+		default:
+			igt_assert_f(0, "Unsupported format %u", f->cairo_id);
+		}
+	} else if (PIXMAN_FORMAT_A(f->pixman_id)) {
+		cairo_id = CAIRO_FORMAT_ARGB32;
+		drm_format = DRM_FORMAT_ARGB8888;
+	} else {
+		cairo_id = CAIRO_FORMAT_RGB24;
+		drm_format = DRM_FORMAT_XRGB8888;
+	}
 
 	igt_assert(blit);
 	blit->base.fd = fd;
 	blit->base.fb = fb;
-	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd,
+	blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
 							     fb->width,
 							     fb->height,
 							     &blit->shadow_fb);
@@ -2129,7 +2340,7 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
 
 	fb->cairo_surface =
 		cairo_image_surface_create_for_data(blit->shadow_ptr,
-						    CAIRO_FORMAT_RGB24,
+						    cairo_id,
 						    fb->width, fb->height,
 						    blit->shadow_fb.strides[0]);
 
@@ -2194,6 +2405,21 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
 			create_cairo_surface__blit(fd, fb);
 		else
 			create_cairo_surface__gtt(fd, fb);
+
+		if (f->cairo_id == CAIRO_FORMAT_RGB96F ||
+		    f->cairo_id == CAIRO_FORMAT_RGBA128F) {
+			cairo_status_t status = cairo_surface_status(fb->cairo_surface);
+
+			igt_skip_on_f(status == CAIRO_STATUS_INVALID_FORMAT &&
+				      cairo_version() < CAIRO_VERSION_ENCODE(1, 17, 2),
+				      "Cairo version too old, need 1.17.2, have %s\n",
+				      cairo_version_string());
+
+			igt_skip_on_f(status == CAIRO_STATUS_NO_MEMORY &&
+				      pixman_version() < PIXMAN_VERSION_ENCODE(0, 36, 0),
+				      "Pixman version too old, need 0.36.0, have %s\n",
+				      pixman_version_string());
+		}
 	}
 
 	igt_assert(cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS);
@@ -2400,6 +2626,9 @@ bool igt_format_is_yuv(uint32_t drm_format)
 {
 	switch (drm_format) {
 	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_P010:
+	case DRM_FORMAT_P012:
+	case DRM_FORMAT_P016:
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 	case DRM_FORMAT_UYVY:
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 9f027deba842..8c683db5e9ec 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -38,6 +38,12 @@
 
 #include "igt_color_encoding.h"
 
+/*
+ * Internal format to denote a buffer compatible with pixman's
+ * floating point format. Range [0-1].
+ */
+#define IGT_FORMAT_FLOAT fourcc_code('I', 'G', 'F', 'x')
+
 /**
  * igt_fb_t:
  * @fb_id: KMS ID of the framebuffer
diff --git a/meson.build b/meson.build
index b17e67ef7f05..fffe86270d1a 100644
--- a/meson.build
+++ b/meson.build
@@ -336,3 +336,13 @@ message('=============')
 foreach str : build_info
 	message(str)
 endforeach
+
+if cairo.version().version_compare('<1.17.2')
+	if pixman.version().version_compare('<0.36.0')
+		warning('Pixman < 0.36.0 found, cannot test HDR formats')
+	endif
+	warning('Cairo < 1.17.2 found, cannot test HDR formats')
+elif not pixman.version().version_compare('<0.36.0')
+	# Cairo 1.17.2 requires 0.36.0 to compile, but somehow it went missing?
+	error('Cairo with floating point support found, but pixman version too old')
+endif
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3)
  2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
                   ` (4 preceding siblings ...)
  2019-02-04 13:17 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2) Patchwork
@ 2019-02-05 15:19 ` Patchwork
  5 siblings, 0 replies; 21+ messages in thread
From: Patchwork @ 2019-02-05 15:19 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: igt-dev

== Series Details ==

Series: series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3)
URL   : https://patchwork.freedesktop.org/series/56083/
State : failure

== Summary ==

Applying: lib/color_encoding: Prepare support for HDR modes.
Using index info to reconstruct a base tree...
M	lib/igt_fb.c
Falling back to patching base and 3-way merge...
Auto-merging lib/igt_fb.c
CONFLICT (content): Merge conflict in lib/igt_fb.c
Patch failed at 0001 lib/color_encoding: Prepare support for HDR modes.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-05 14:31     ` Maarten Lankhorst
@ 2019-02-06  6:47       ` Sharma, Swati2
  2019-02-06 14:21         ` Sharma, Swati2
  0 siblings, 1 reply; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-06  6:47 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev

[-- Attachment #1: Type: text/plain, Size: 14508 bytes --]


On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>>> Those formats are packed like YUYV, but only 16 bits per component.
>>>
>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>> ---
>>>    include/drm-uapi/drm_fourcc.h |   6 +-
>>>    lib/igt_color_encoding.c      |   3 +
>>>    lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>>>    3 files changed, 154 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>>> --- a/lib/igt_fb.c
>>> +++ b/lib/igt_fb.c
>>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>>          .cairo_id = CAIRO_FORMAT_RGB24,
>>>          .num_planes = 1, .plane_bpp = { 16, },
>>>        },
>>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>> +    },
>>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>> +    },
>>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>> +    },
>>>        { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>>          .cairo_id = CAIRO_FORMAT_RGB96F,
>>>          .num_planes = 2, .plane_bpp = { 16, 32 },
>>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>>                        fb->offsets[1] / sizeof(wchar_t));
>>>                    wmemset(ptr + fb->offsets[1], 0x80008000,
>>>                        DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>> +            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;
>>>                }
>>>                gem_munmap(ptr, fb->size);
>> Hi Maarten,
>>
>> While testing Y210 pixel format, IGT is failing with debug message showing igt_create_fb() failure
>>
>> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>
>> dmesg showing bad pitch 12800 for Y210 pixel format
>>
>> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
>> [  634.104444] [IGT] kms_plane: exiting, ret=99
>>
>> Can you please confirm whether changes needs to be done from igt or some issue with Y2xx driver patches?
>>
>>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>>>        }
>>>    }
>>>    +
>>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>>> +{
>>> +    int i, j;
>>> +    const uint16_t *yuyv;
>>> +    uint16_t *buf;
>>> +    float *ptr = cvt->dst.ptr;
>>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
>>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
>>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>>> +                            cvt->dst.fb->drm_format,
>>> +                            cvt->src.fb->color_encoding,
>>> +                            cvt->src.fb->color_range);
>>> +
>>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>>> +
>>> +    yuyv = buf = convert_src_get(cvt);
>>> +
>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>> +            /* Convert 2x1 pixel blocks */
>>> +            struct igt_vec4 yuv[2];
>>> +            struct igt_vec4 rgb[2];
>>> +
>>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>>> +
>>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>>> +
>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>>> +        }
>>> +
>>> +        if (cvt->dst.fb->width & 1) {
>>> +            struct igt_vec4 yuv;
>>> +            struct igt_vec4 rgb;
>>> +
>>> +            yuv.d[0] = yuyv[j * 4 + 0];
>>> +            yuv.d[1] = yuyv[j * 4 + 1];
>>> +            yuv.d[2] = yuyv[j * 4 + 3];
>>> +            yuv.d[3] = 1.0f;
>>> +
>>> +            rgb = igt_matrix_transform(&m, &yuv);
>>> +
>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>>> +        }
>>> +
>>> +        ptr += float_stride;
>>> +        yuyv += yuyv_stride;
>>> +    }
>>> +
>>> +    convert_src_put(cvt, buf);
>>> +}
>>> +
>>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>>> +{
>>> +    int i, j;
>>> +    uint16_t *yuyv = cvt->dst.ptr;
>>> +    const float *ptr = cvt->src.ptr;
>>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>>> +                            cvt->dst.fb->drm_format,
>>> +                            cvt->dst.fb->color_encoding,
>>> +                            cvt->dst.fb->color_range);
>>> +
>>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>>> +
>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>> +            /* Convert 2x1 pixel blocks */
>>> +            struct igt_vec4 rgb[2];
>>> +            struct igt_vec4 yuv[2];
>>> +
>>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>>> +
>>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>>> +
>>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>>> +        }
>>> +
>>> +        if (cvt->dst.fb->width & 1) {
>>> +            struct igt_vec4 rgb;
>>> +            struct igt_vec4 yuv;
>>> +
>>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>>> +
>>> +            yuv = igt_matrix_transform(&m, &rgb);
>>> +
>>> +            yuyv[j * 4 + 0] = yuv.d[0];
>>> +            yuyv[j * 4 + 1] = yuv.d[1];
>>> +            yuyv[j * 4 + 3] = yuv.d[2];
>>> +        }
>>> +
>>> +        ptr += float_stride;
>>> +        yuyv += yuyv_stride;
>>> +    }
>>> +}
>>> +
>>>    static void convert_pixman(struct fb_convert *cvt)
>>>    {
>>>        pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>            case DRM_FORMAT_P016:
>>>                convert_p01X_to_float(cvt);
>>>                return;
>>> +        case DRM_FORMAT_Y210:
>>> +        case DRM_FORMAT_Y212:
>>> +        case DRM_FORMAT_Y216:
>>> +            convert_Y21X_to_float(cvt);
>>> +            return;
>>>            }
>>>        } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>>            switch (cvt->dst.fb->drm_format) {
>>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>            case DRM_FORMAT_P016:
>>>                convert_float_to_p01X(cvt);
>>>                return;
>>> +        case DRM_FORMAT_Y210:
>>> +        case DRM_FORMAT_Y212:
>>> +        case DRM_FORMAT_Y216:
>>> +            convert_float_to_Y21X(cvt);
>>> +            return;
>>>            }
>>>        }
>>>    @@ -2583,6 +2726,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:
> Can I get the full IGT / dmesg logs? I can't see what the fb dimensions they are.

IGT Logs:

(kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
(kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, 
height=1800, format=0x30313259, tiling=0x0, size=0)
(kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, 
pitch=12800)
(kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: 
igt_has_fb_modifiers(fd)
(kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function 
igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
(kms_plane:4960) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, 
fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, 
fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
(kms_plane:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
(kms_plane:4960) igt_core-INFO: Stack trace:
(kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 
__igt_fail_assert()
(kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 
igt_create_fb_with_bo_size()
(kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
(kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 
igt_create_color_fb()
(kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 
test_format_plane_color()
(kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 
test_format_plane()
(kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 
test_pixel_formats()
(kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 
run_tests_for_pipe_plane()
(kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 
__real_main642()
(kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
(kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 
__libc_start_main()
(kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
(kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
****  END  ****

Dmesg Logs: Attached y210_dmesg_failure.txt

>
> ~Maarten
>
-- 
Thanks and Regards,
Swati


[-- Attachment #2: y210_dmesg_failure.txt --]
[-- Type: text/plain, Size: 54214 bytes --]

[60955.650072] Console: switching to colour dummy device 80x25
[60955.650083] [IGT] kms_plane: executing
[60955.683244] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:195:DP-2]
[60955.683248] [drm:intel_dp_detect] [CONNECTOR:195:DP-2]
[60955.683250] [drm:intel_power_well_enable] enabling AUX B
[60955.683276] [drm:intel_power_well_disable] disabling AUX B
[60955.683307] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:195:DP-2] disconnected
[60955.683350] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:202:HDMI-A-1]
[60955.683352] [drm:intel_hdmi_detect] [CONNECTOR:202:HDMI-A-1]
[60955.683370] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:202:HDMI-A-1] disconnected
[60955.683411] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:208:DP-3]
[60955.683416] [drm:intel_dp_detect] [CONNECTOR:208:DP-3]
[60955.704207] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.724982] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.745760] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.766535] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.787310] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.808085] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.828863] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.849639] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.870415] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.891190] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.911968] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.932745] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.953522] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.974297] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60955.995075] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.015856] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.036636] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.057412] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.078190] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.098965] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.119741] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.140523] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.161297] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.182072] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.202848] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.223630] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.244405] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.265181] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.285957] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.306732] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.327506] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.348280] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.348284] [drm:drm_dp_dpcd_access] Too many retries, giving up. First error: -110
[60956.348287] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:208:DP-3] disconnected
[60956.348382] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:218:DP-4]
[60956.348384] [drm:intel_dp_detect] [CONNECTOR:218:DP-4]
[60956.348386] [drm:intel_power_well_enable] enabling AUX D
[60956.369167] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.389945] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.410720] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.431497] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.452275] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.473050] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.493825] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.514600] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.535379] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.556155] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.576932] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.597707] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.618483] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.639258] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.660035] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.680810] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.701588] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.722365] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.743141] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.763918] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.784696] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.805472] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.826254] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.847031] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.867807] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.888583] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.909358] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.930138] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.950913] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.971687] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60956.992462] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.013237] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.013241] [drm:drm_dp_dpcd_access] Too many retries, giving up. First error: -110
[60957.013243] [drm:intel_power_well_disable] disabling AUX D
[60957.013246] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:218:DP-4] disconnected
[60957.013313] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:224:HDMI-A-3]
[60957.013314] [drm:intel_hdmi_detect] [CONNECTOR:224:HDMI-A-3]
[60957.025565] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out after NAK
[60957.025591] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] NAK for addr: 0050 w(1)
[60957.038202] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out after NAK
[60957.038228] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] NAK for addr: 0050 w(1)
[60957.088598] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out, falling back to bit banging on pin 10
[60957.104680] [drm:drm_do_probe_ddc_edid] drm: skipping non-existent adapter i915 gmbus tc2
[60957.104685] [drm:intel_hdmi_set_edid] HDMI GMBUS EDID read failed, retry using GPIO bit-banging
[60957.104690] [drm:intel_gmbus_force_bit] enabling bit-banging on i915 gmbus tc2. force bit now 1
[60957.120655] [drm:drm_do_probe_ddc_edid] drm: skipping non-existent adapter i915 gmbus tc2
[60957.120662] [drm:intel_gmbus_force_bit] disabling bit-banging on i915 gmbus tc2. force bit now 0
[60957.171590] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out, falling back to bit banging on pin 10
[60957.187624] [drm:drm_dp_dual_mode_detect] DP dual mode HDMI ID:  (err -6)
[60957.187632] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:224:HDMI-A-3] disconnected
[60957.187832] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:228:DP-5]
[60957.187838] [drm:intel_dp_detect] [CONNECTOR:228:DP-5]
[60957.187844] [drm:intel_power_well_enable] enabling AUX F
[60957.187854] [drm:intel_digital_port_connected] DP PHY for TC port 3 not ready
[60957.187855] ------------[ cut here ]------------
[60957.187856] WARN_ON(dig_port->tc_legacy_port)
[60957.187875] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60957.187876] Modules linked in: x86_pkg_temp_thermal efivarfs
[60957.187884] CPU: 6 PID: 4960 Comm: kms_plane Tainted: G     U  W         5.0.0-rc4+ #7
[60957.187886] Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP, BIOS ICLSFWR1.R00.2513.A01.1812192053 12/19/2018
[60957.187890] RIP: 0010:intel_digital_port_connected+0x705/0x710
[60957.187893] Code: c0 89 54 24 04 e8 ab 5f b0 ff 0f 0b 8b 54 24 04 e9 64 fc ff ff 48 c7 c6 60 24 85 90 48 c7 c7 f5 ca 86 90 31 c0 e8 8b 5f b0 ff <0f> 0b 31 c0 e9 56 f9 ff ff 66 90 41 57 41 56 41 55 41 54 55 53 48
[60957.187895] RSP: 0018:ffff9ec641bafb28 EFLAGS: 00010292
[60957.187898] RAX: 0000000000000021 RBX: ffff93e6e3f78000 RCX: 0000000000000000
[60957.187899] RDX: 0000000000000021 RSI: ffffffff910bee61 RDI: ffffffff910bf261
[60957.187901] RBP: 0000000000000008 R08: 0000000000000000 R09: ffffffebd834e11c
[60957.187902] R10: 0000000000000021 R11: 0000000000001cc5 R12: ffff93e6e3ec3000
[60957.187904] R13: 0000000000000003 R14: 0000000000000005 R15: ffffffff90697f00
[60957.187907] FS:  00007fc735e0aa40(0000) GS:ffff93e6e7f80000(0000) knlGS:0000000000000000
[60957.187909] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[60957.187910] CR2: 00007ffa3af84710 CR3: 0000000275ef0006 CR4: 0000000000760ee0
[60957.187912] PKRU: 55555554
[60957.187913] Call Trace:
[60957.187920]  intel_dp_detect+0xa5/0x5c0
[60957.187924]  ? drm_modeset_lock+0x31/0xc0
[60957.187928]  drm_helper_probe_single_connector_modes+0xc4/0x660
[60957.187934]  ? lookup_fast+0xb6/0x290
[60957.187939]  drm_mode_getconnector+0x454/0x4a0
[60957.187945]  ? _cond_resched+0x10/0x20
[60957.187948]  ? ww_mutex_lock+0xd/0x70
[60957.187953]  ? drm_connector_property_set_ioctl+0x30/0x30
[60957.187956]  drm_ioctl_kernel+0x85/0xd0
[60957.187960]  drm_ioctl+0x2ef/0x387
[60957.187964]  ? drm_connector_property_set_ioctl+0x30/0x30
[60957.187970]  ? selinux_file_ioctl+0x11d/0x1e0
[60957.187973]  do_vfs_ioctl+0x8d/0x5e0
[60957.187978]  ksys_ioctl+0x5b/0x90
[60957.187981]  __x64_sys_ioctl+0x11/0x20
[60957.187985]  do_syscall_64+0x44/0xf0
[60957.187988]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[60957.187992] RIP: 0033:0x7fc735340f47
[60957.187994] Code: 00 00 00 48 8b 05 51 6f 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 6f 2c 00 f7 d8 64 89 01 48
[60957.187996] RSP: 002b:00007fff8be34648 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[60957.187999] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc735340f47
[60957.188000] RDX: 00007fff8be34680 RSI: 00000000c05064a7 RDI: 0000000000000003
[60957.188001] RBP: 00007fff8be34680 R08: 0000000001c59b20 R09: 0000000000000000
[60957.188003] R10: 0000000000000004 R11: 0000000000000246 R12: 00000000c05064a7
[60957.188004] R13: 0000000000000003 R14: 00007fff8be34680 R15: 0000000000000003
[60957.188010] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60957.188011] ---[ end trace be686e381b2eacad ]---
[60957.188017] [drm:intel_power_well_disable] disabling AUX F
[60957.188024] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:228:DP-5] disconnected
[60957.188170] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:233:HDMI-A-4]
[60957.188174] [drm:intel_hdmi_detect] [CONNECTOR:233:HDMI-A-4]
[60957.188180] [drm:intel_digital_port_connected] DP PHY for TC port 3 not ready
[60957.188181] ------------[ cut here ]------------
[60957.188182] WARN_ON(dig_port->tc_legacy_port)
[60957.188195] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60957.188196] Modules linked in: x86_pkg_temp_thermal efivarfs
[60957.188200] CPU: 6 PID: 4960 Comm: kms_plane Tainted: G     U  W         5.0.0-rc4+ #7
[60957.188202] Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP, BIOS ICLSFWR1.R00.2513.A01.1812192053 12/19/2018
[60957.188205] RIP: 0010:intel_digital_port_connected+0x705/0x710
[60957.188207] Code: c0 89 54 24 04 e8 ab 5f b0 ff 0f 0b 8b 54 24 04 e9 64 fc ff ff 48 c7 c6 60 24 85 90 48 c7 c7 f5 ca 86 90 31 c0 e8 8b 5f b0 ff <0f> 0b 31 c0 e9 56 f9 ff ff 66 90 41 57 41 56 41 55 41 54 55 53 48
[60957.188209] RSP: 0018:ffff9ec641bafb68 EFLAGS: 00010296
[60957.188211] RAX: 0000000000000021 RBX: ffff93e6e3f78000 RCX: 0000000000000000
[60957.188213] RDX: 0000000000000021 RSI: ffffffff910bee61 RDI: ffffffff910bf261
[60957.188214] RBP: 0000000000000008 R08: 0000000000000000 R09: ffffffebd834e11c
[60957.188216] R10: 0000000000000021 R11: 0000000000001cf8 R12: ffff93e6e3ec3000
[60957.188217] R13: 0000000000000003 R14: 0000000000000005 R15: ffffffff90698700
[60957.188219] FS:  00007fc735e0aa40(0000) GS:ffff93e6e7f80000(0000) knlGS:0000000000000000
[60957.188221] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[60957.188222] CR2: 0000000001c5a038 CR3: 0000000275ef0006 CR4: 0000000000760ee0
[60957.188224] PKRU: 55555554
[60957.188225] Call Trace:
[60957.188229]  intel_hdmi_detect+0x49/0xc0
[60957.188234]  drm_helper_probe_single_connector_modes+0xc4/0x660
[60957.188238]  ? lookup_fast+0xb6/0x290
[60957.188242]  drm_mode_getconnector+0x454/0x4a0
[60957.188247]  ? drm_connector_property_set_ioctl+0x30/0x30
[60957.188249]  drm_ioctl_kernel+0x85/0xd0
[60957.188252]  drm_ioctl+0x2ef/0x387
[60957.188256]  ? drm_connector_property_set_ioctl+0x30/0x30
[60957.188260]  ? selinux_file_ioctl+0x11d/0x1e0
[60957.188264]  do_vfs_ioctl+0x8d/0x5e0
[60957.188267]  ksys_ioctl+0x5b/0x90
[60957.188270]  __x64_sys_ioctl+0x11/0x20
[60957.188273]  do_syscall_64+0x44/0xf0
[60957.188276]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[60957.188277] RIP: 0033:0x7fc735340f47
[60957.188280] Code: 00 00 00 48 8b 05 51 6f 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 6f 2c 00 f7 d8 64 89 01 48
[60957.188281] RSP: 002b:00007fff8be34648 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[60957.188283] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc735340f47
[60957.188285] RDX: 00007fff8be34680 RSI: 00000000c05064a7 RDI: 0000000000000003
[60957.188286] RBP: 00007fff8be34680 R08: 0000000001c58fc0 R09: 0000000000000000
[60957.188287] R10: 0000000000000004 R11: 0000000000000246 R12: 00000000c05064a7
[60957.188289] R13: 0000000000000003 R14: 00007fff8be34680 R15: 0000000000000003
[60957.188293] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60957.188295] ---[ end trace be686e381b2eacae ]---
[60957.188300] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:233:HDMI-A-4] disconnected
[60957.188567] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:190:DP-1]
[60957.188580] [drm:intel_dp_detect] [CONNECTOR:190:DP-1]
[60957.189039] [drm:intel_dp_read_dpcd] DPCD: 12 14 c4 41 00 00 01 c0 02 00 00 00 1f 0b 00
[60957.189348] [drm:intel_dp_print_rates] source rates: 162000, 216000, 270000, 324000, 432000, 540000
[60957.189352] [drm:intel_dp_print_rates] sink rates: 162000, 270000, 540000
[60957.189356] [drm:intel_dp_print_rates] common rates: 162000, 270000, 540000
[60957.189762] [drm:drm_dp_read_desc] DP sink: OUI 00-22-b9 dev-ID sivarT HW-rev 0.0 SW-rev 0.0 quirks 0x0001
[60957.190066] [drm:intel_dp_detect] MST support? port A: no, sink: no, modparam: yes
[60957.192075] [drm:drm_dp_i2c_do_msg] native defer
[60957.193359] [drm:drm_dp_i2c_do_msg] native defer
[60957.194654] [drm:drm_dp_i2c_do_msg] native defer
[60957.195997] [drm:drm_dp_i2c_do_msg] native defer
[60957.197286] [drm:drm_dp_i2c_do_msg] native defer
[60957.198578] [drm:drm_dp_i2c_do_msg] native defer
[60957.199985] [drm:drm_dp_i2c_do_msg] native defer
[60957.201275] [drm:drm_dp_i2c_do_msg] native defer
[60957.202621] [drm:drm_add_display_info] non_desktop set to 0
[60957.202629] [drm:drm_add_edid_modes] ELD: no CEA Extension found
[60957.202631] [drm:drm_add_display_info] non_desktop set to 0
[60957.202721] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:190:DP-1] probed modes :
[60957.202727] [drm:drm_mode_debug_printmodeline] Modeline "3200x1800": 60 361310 3200 3248 3280 3316 1800 1802 1807 1816 0x48 0xa
[60957.202732] [drm:drm_mode_debug_printmodeline] Modeline "3200x1800": 52 361310 3200 3248 3280 3424 1800 1802 1807 2045 0x40 0xa
[60957.202752] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:195:DP-2]
[60957.202757] [drm:intel_dp_detect] [CONNECTOR:195:DP-2]
[60957.202761] [drm:intel_power_well_enable] enabling AUX B
[60957.202812] [drm:intel_power_well_disable] disabling AUX B
[60957.202831] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:195:DP-2] disconnected
[60957.202846] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:202:HDMI-A-1]
[60957.202850] [drm:intel_hdmi_detect] [CONNECTOR:202:HDMI-A-1]
[60957.202876] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:202:HDMI-A-1] disconnected
[60957.202885] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:208:DP-3]
[60957.202888] [drm:intel_dp_detect] [CONNECTOR:208:DP-3]
[60957.223700] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.244505] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.265296] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.286076] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.306856] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.327636] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.348417] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.369198] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.389979] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.410763] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.431543] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.452325] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.473107] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.493889] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.514671] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.535451] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.556233] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.577013] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.597793] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.618574] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.639354] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.660135] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.680914] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.701695] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.722481] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.743262] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.764043] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.784824] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.805604] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.826385] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.847165] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.867947] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.867950] [drm:drm_dp_dpcd_access] Too many retries, giving up. First error: -110
[60957.867953] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:208:DP-3] disconnected
[60957.867963] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:214:HDMI-A-2]
[60957.867967] [drm:intel_hdmi_detect] [CONNECTOR:214:HDMI-A-2]
[60957.879517] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc1] timed out after NAK
[60957.879542] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc1] NAK for addr: 0050 w(1)
[60957.905970] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc1] NAK for addr: 0040 w(1)
[60957.905973] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc1] NAK on first message, retry
[60957.906160] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc1] NAK for addr: 0040 w(1)
[60957.906163] [drm:drm_dp_dual_mode_detect] DP dual mode HDMI ID:  (err -6)
[60957.906166] [drm:drm_detect_monitor_audio] Monitor has basic audio support
[60957.906169] [drm:drm_add_display_info] non_desktop set to 0
[60957.906171] [drm:drm_add_display_info] HDMI: DVI dual 0, max TMDS clock 225000 kHz
[60957.906176] [drm:drm_add_edid_modes] ELD monitor LG TV
[60957.906178] [drm:drm_add_edid_modes] HDMI: latency present 0 0, video latency 0 0, audio latency 0 0
[60957.906179] [drm:drm_add_edid_modes] ELD size 28, SAD count 1
[60957.906180] [drm:drm_add_display_info] non_desktop set to 0
[60957.906181] [drm:drm_add_display_info] HDMI: DVI dual 0, max TMDS clock 225000 kHz
[60957.906297] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:214:HDMI-A-2] probed modes :
[60957.906300] [drm:drm_mode_debug_printmodeline] Modeline "1360x768": 60 85500 1360 1424 1536 1792 768 771 777 795 0x48 0x5
[60957.906303] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 60 148500 1920 2008 2052 2200 1080 1096 1116 1125 0x40 0x5
[60957.906305] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 60 148500 1920 2008 2052 2200 1080 1084 1089 1125 0x40 0x5
[60957.906307] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 60 148352 1920 2008 2052 2200 1080 1084 1089 1125 0x40 0x5
[60957.906309] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 60 138620 1920 1968 2000 2080 1080 1082 1087 1111 0x40 0x9
[60957.906311] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080i": 60 74250 1920 2008 2052 2200 1080 1084 1094 1125 0x40 0x15
[60957.906314] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080i": 60 74250 1920 2008 2052 2200 1080 1084 1094 1125 0x40 0x15
[60957.906316] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080i": 60 74176 1920 2008 2052 2200 1080 1084 1094 1125 0x40 0x15
[60957.906318] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 30 74250 1920 2008 2052 2200 1080 1084 1089 1125 0x40 0x5
[60957.906320] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 30 74176 1920 2008 2052 2200 1080 1084 1089 1125 0x40 0x5
[60957.906323] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 24 74250 1920 2558 2602 2750 1080 1084 1089 1125 0x40 0x5
[60957.906325] [drm:drm_mode_debug_printmodeline] Modeline "1920x1080": 24 74176 1920 2558 2602 2750 1080 1084 1089 1125 0x40 0x5
[60957.906327] [drm:drm_mode_debug_printmodeline] Modeline "1280x720": 60 74250 1280 1390 1430 1650 720 725 730 750 0x40 0x5
[60957.906329] [drm:drm_mode_debug_printmodeline] Modeline "1280x720": 60 74250 1280 1390 1430 1650 720 725 730 750 0x40 0x5
[60957.906331] [drm:drm_mode_debug_printmodeline] Modeline "1280x720": 60 74176 1280 1390 1430 1650 720 725 730 750 0x40 0x5
[60957.906333] [drm:drm_mode_debug_printmodeline] Modeline "1024x768": 60 65000 1024 1048 1184 1344 768 771 777 806 0x40 0xa
[60957.906335] [drm:drm_mode_debug_printmodeline] Modeline "800x600": 60 40000 800 840 968 1056 600 601 605 628 0x40 0x5
[60957.906337] [drm:drm_mode_debug_printmodeline] Modeline "720x480": 60 27027 720 736 798 858 480 489 495 525 0x40 0xa
[60957.906339] [drm:drm_mode_debug_printmodeline] Modeline "720x480": 60 27027 720 736 798 858 480 489 495 525 0x40 0xa
[60957.906341] [drm:drm_mode_debug_printmodeline] Modeline "720x480": 60 27000 720 736 798 858 480 489 495 525 0x40 0xa
[60957.906343] [drm:drm_mode_debug_printmodeline] Modeline "720x480": 60 27000 720 736 798 858 480 489 495 525 0x40 0xa
[60957.906345] [drm:drm_mode_debug_printmodeline] Modeline "720x480": 60 27000 720 736 798 858 480 489 495 525 0x40 0xa
[60957.906347] [drm:drm_mode_debug_printmodeline] Modeline "640x480": 60 25200 640 656 752 800 480 490 492 525 0x40 0xa
[60957.906349] [drm:drm_mode_debug_printmodeline] Modeline "640x480": 60 25175 640 656 752 800 480 490 492 525 0x40 0xa
[60957.906352] [drm:drm_mode_debug_printmodeline] Modeline "720x400": 70 28320 720 738 846 900 400 412 414 449 0x40 0x6
[60957.906373] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:218:DP-4]
[60957.906376] [drm:intel_dp_detect] [CONNECTOR:218:DP-4]
[60957.906379] [drm:intel_power_well_enable] enabling AUX D
[60957.927166] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.947944] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.968721] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60957.989496] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.010270] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.031043] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.051818] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.072594] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.093369] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.114145] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.134918] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.155692] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.176467] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.197247] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.218029] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.238809] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.259593] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.280373] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.301155] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.321937] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.342719] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.363503] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.384283] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.405069] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.425849] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.446632] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.467412] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.488193] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.508974] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.529755] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.550535] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.571314] [drm:intel_dp_aux_xfer] dp_aux_ch timeout status 0x7d4003ff
[60958.571318] [drm:drm_dp_dpcd_access] Too many retries, giving up. First error: -110
[60958.571321] [drm:intel_power_well_disable] disabling AUX D
[60958.571324] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:218:DP-4] disconnected
[60958.571338] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:224:HDMI-A-3]
[60958.571339] [drm:intel_hdmi_detect] [CONNECTOR:224:HDMI-A-3]
[60958.623874] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out, falling back to bit banging on pin 10
[60958.639650] [drm:drm_do_probe_ddc_edid] drm: skipping non-existent adapter i915 gmbus tc2
[60958.639655] [drm:intel_hdmi_set_edid] HDMI GMBUS EDID read failed, retry using GPIO bit-banging
[60958.639660] [drm:intel_gmbus_force_bit] enabling bit-banging on i915 gmbus tc2. force bit now 1
[60958.655634] [drm:drm_do_probe_ddc_edid] drm: skipping non-existent adapter i915 gmbus tc2
[60958.655641] [drm:intel_gmbus_force_bit] disabling bit-banging on i915 gmbus tc2. force bit now 0
[60958.707526] [drm:do_gmbus_xfer] GMBUS [i915 gmbus tc2] timed out, falling back to bit banging on pin 10
[60958.723636] [drm:drm_dp_dual_mode_detect] DP dual mode HDMI ID:  (err -6)
[60958.723643] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:224:HDMI-A-3] disconnected
[60958.723675] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:228:DP-5]
[60958.723680] [drm:intel_dp_detect] [CONNECTOR:228:DP-5]
[60958.723686] [drm:intel_power_well_enable] enabling AUX F
[60958.723696] [drm:intel_digital_port_connected] DP PHY for TC port 3 not ready
[60958.723697] ------------[ cut here ]------------
[60958.723698] WARN_ON(dig_port->tc_legacy_port)
[60958.723717] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60958.723719] Modules linked in: x86_pkg_temp_thermal efivarfs
[60958.723726] CPU: 6 PID: 4960 Comm: kms_plane Tainted: G     U  W         5.0.0-rc4+ #7
[60958.723728] Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP, BIOS ICLSFWR1.R00.2513.A01.1812192053 12/19/2018
[60958.723732] RIP: 0010:intel_digital_port_connected+0x705/0x710
[60958.723735] Code: c0 89 54 24 04 e8 ab 5f b0 ff 0f 0b 8b 54 24 04 e9 64 fc ff ff 48 c7 c6 60 24 85 90 48 c7 c7 f5 ca 86 90 31 c0 e8 8b 5f b0 ff <0f> 0b 31 c0 e9 56 f9 ff ff 66 90 41 57 41 56 41 55 41 54 55 53 48
[60958.723737] RSP: 0018:ffff9ec641bafb28 EFLAGS: 00010292
[60958.723740] RAX: 0000000000000021 RBX: ffff93e6e3f78000 RCX: 0000000000000000
[60958.723741] RDX: 0000000000000021 RSI: ffffffff910bee61 RDI: ffffffff910bf261
[60958.723743] RBP: 0000000000000008 R08: 0000000000000000 R09: ffffffebd834e11c
[60958.723752] R10: 0000000000000021 R11: 0000000000001dc5 R12: ffff93e6e3ec3000
[60958.723754] R13: 0000000000000003 R14: 0000000000000005 R15: ffffffff90697f00
[60958.723767] FS:  00007fc735e0aa40(0000) GS:ffff93e6e7f80000(0000) knlGS:0000000000000000
[60958.723769] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[60958.723770] CR2: 0000000001c5a038 CR3: 0000000275ef0006 CR4: 0000000000760ee0
[60958.723772] PKRU: 55555554
[60958.723773] Call Trace:
[60958.723781]  intel_dp_detect+0xa5/0x5c0
[60958.723786]  ? drm_modeset_lock+0x31/0xc0
[60958.723792]  drm_helper_probe_single_connector_modes+0xc4/0x660
[60958.723798]  drm_mode_getconnector+0x454/0x4a0
[60958.723805]  ? drm_connector_property_set_ioctl+0x30/0x30
[60958.723809]  drm_ioctl_kernel+0x85/0xd0
[60958.723812]  drm_ioctl+0x2ef/0x387
[60958.723816]  ? drm_connector_property_set_ioctl+0x30/0x30
[60958.723822]  ? selinux_file_ioctl+0x11d/0x1e0
[60958.723827]  do_vfs_ioctl+0x8d/0x5e0
[60958.723831]  ksys_ioctl+0x5b/0x90
[60958.723834]  __x64_sys_ioctl+0x11/0x20
[60958.723838]  do_syscall_64+0x44/0xf0
[60958.723844]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[60958.723848] RIP: 0033:0x7fc735340f47
[60958.723850] Code: 00 00 00 48 8b 05 51 6f 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 6f 2c 00 f7 d8 64 89 01 48
[60958.723852] RSP: 002b:00007fff8be34698 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[60958.723855] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc735340f47
[60958.723856] RDX: 00007fff8be346d0 RSI: 00000000c05064a7 RDI: 0000000000000003
[60958.723858] RBP: 00007fff8be346d0 R08: 0000000001c59e20 R09: 0000000000000000
[60958.723859] R10: 00007fc735608b78 R11: 0000000000000246 R12: 00000000c05064a7
[60958.723861] R13: 0000000000000003 R14: 00007fff8be346d0 R15: 0000000000000003
[60958.723866] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60958.723868] ---[ end trace be686e381b2eacaf ]---
[60958.723873] [drm:intel_power_well_disable] disabling AUX F
[60958.723879] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:228:DP-5] disconnected
[60958.723894] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:233:HDMI-A-4]
[60958.723897] [drm:intel_hdmi_detect] [CONNECTOR:233:HDMI-A-4]
[60958.723903] [drm:intel_digital_port_connected] DP PHY for TC port 3 not ready
[60958.723904] ------------[ cut here ]------------
[60958.723905] WARN_ON(dig_port->tc_legacy_port)
[60958.723917] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60958.723918] Modules linked in: x86_pkg_temp_thermal efivarfs
[60958.723922] CPU: 6 PID: 4960 Comm: kms_plane Tainted: G     U  W         5.0.0-rc4+ #7
[60958.723924] Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP, BIOS ICLSFWR1.R00.2513.A01.1812192053 12/19/2018
[60958.723926] RIP: 0010:intel_digital_port_connected+0x705/0x710
[60958.723929] Code: c0 89 54 24 04 e8 ab 5f b0 ff 0f 0b 8b 54 24 04 e9 64 fc ff ff 48 c7 c6 60 24 85 90 48 c7 c7 f5 ca 86 90 31 c0 e8 8b 5f b0 ff <0f> 0b 31 c0 e9 56 f9 ff ff 66 90 41 57 41 56 41 55 41 54 55 53 48
[60958.723930] RSP: 0018:ffff9ec641bafb68 EFLAGS: 00010296
[60958.723932] RAX: 0000000000000021 RBX: ffff93e6e3f78000 RCX: 0000000000000000
[60958.723933] RDX: 0000000000000021 RSI: ffffffff910bee61 RDI: ffffffff910bf261
[60958.723935] RBP: 0000000000000008 R08: 0000000000000000 R09: ffffffebd834e11c
[60958.723936] R10: 0000000000000021 R11: 0000000000001df5 R12: ffff93e6e3ec3000
[60958.723938] R13: 0000000000000003 R14: 0000000000000005 R15: ffffffff90698700
[60958.723940] FS:  00007fc735e0aa40(0000) GS:ffff93e6e7f80000(0000) knlGS:0000000000000000
[60958.723941] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[60958.723943] CR2: 0000000001c5a038 CR3: 0000000275ef0006 CR4: 0000000000760ee0
[60958.723944] PKRU: 55555554
[60958.723945] Call Trace:
[60958.723949]  intel_hdmi_detect+0x49/0xc0
[60958.723954]  drm_helper_probe_single_connector_modes+0xc4/0x660
[60958.723958]  drm_mode_getconnector+0x454/0x4a0
[60958.723963]  ? drm_connector_property_set_ioctl+0x30/0x30
[60958.723965]  drm_ioctl_kernel+0x85/0xd0
[60958.723968]  drm_ioctl+0x2ef/0x387
[60958.723971]  ? drm_connector_property_set_ioctl+0x30/0x30
[60958.723976]  ? selinux_file_ioctl+0x11d/0x1e0
[60958.723979]  do_vfs_ioctl+0x8d/0x5e0
[60958.723983]  ksys_ioctl+0x5b/0x90
[60958.723985]  __x64_sys_ioctl+0x11/0x20
[60958.723988]  do_syscall_64+0x44/0xf0
[60958.723991]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[60958.723993] RIP: 0033:0x7fc735340f47
[60958.723994] Code: 00 00 00 48 8b 05 51 6f 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 21 6f 2c 00 f7 d8 64 89 01 48
[60958.723996] RSP: 002b:00007fff8be34698 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[60958.723998] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc735340f47
[60958.723999] RDX: 00007fff8be346d0 RSI: 00000000c05064a7 RDI: 0000000000000003
[60958.724001] RBP: 00007fff8be346d0 R08: 0000000001c59e20 R09: 0000000000000000
[60958.724002] R10: 00007fc735608b78 R11: 0000000000000246 R12: 00000000c05064a7
[60958.724004] R13: 0000000000000003 R14: 00007fff8be346d0 R15: 0000000000000003
[60958.724008] WARNING: CPU: 6 PID: 4960 at drivers/gpu/drm/i915/intel_dp.c:5163 intel_digital_port_connected+0x705/0x710
[60958.724009] ---[ end trace be686e381b2eacb0 ]---
[60958.724014] [drm:drm_helper_probe_single_connector_modes] [CONNECTOR:233:HDMI-A-4] disconnected
[60958.724130] [IGT] kms_plane: starting subtest pixel-format-pipe-A-planes
[60958.724296] [drm:drm_mode_addfb2] [FB:238]
[60958.726657] [drm:intel_atomic_check] New cdclk calculated to be logical 307200 kHz, actual 307200 kHz
[60958.726663] [drm:intel_atomic_check] New voltage level calculated to be logical 0, actual 0
[60958.726708] [drm:skl_compute_wm] [PLANE:30:plane 1A] ddb (0 - 1429) -> (0 - 992)
[60958.726713] [drm:skl_compute_wm] [PLANE:79:cursor A] ddb (1429 - 1437) -> (992 - 1024)
[60958.726721] [drm:skl_compute_wm] [PLANE:83:plane 1B] ddb (1437 - 2040) -> (0 - 0)
[60958.726727] [drm:skl_compute_wm] [PLANE:132:cursor B] ddb (2040 - 2048) -> (0 - 0)
[60958.743119] [drm:hsw_audio_codec_disable] Disable audio codec on pipe B
[60958.743127] [drm:intel_disable_pipe] disabling pipe B
[60958.757561] [drm:intel_power_well_disable] disabling DDI C IO
[60958.757570] [drm:intel_power_well_disable] disabling AUX C
[60958.757578] [drm:intel_disable_shared_dpll] disable MG PLL 1 (active 2, on? 1) for crtc 135
[60958.757596] [drm:intel_disable_shared_dpll] disabling MG PLL 1
[60958.757606] [drm:intel_atomic_commit_tail] [ENCODER:189:DDI A]
[60958.757609] [drm:intel_atomic_commit_tail] [ENCODER:194:DDI B]
[60958.757612] [drm:intel_atomic_commit_tail] [ENCODER:196:DP-MST A]
[60958.757614] [drm:intel_atomic_commit_tail] [ENCODER:197:DP-MST B]
[60958.757616] [drm:intel_atomic_commit_tail] [ENCODER:198:DP-MST C]
[60958.757618] [drm:intel_atomic_commit_tail] [ENCODER:207:DDI C]
[60958.757623] [drm:intel_atomic_commit_tail] [ENCODER:209:DP-MST A]
[60958.757625] [drm:intel_atomic_commit_tail] [ENCODER:210:DP-MST B]
[60958.757627] [drm:intel_atomic_commit_tail] [ENCODER:211:DP-MST C]
[60958.757629] [drm:intel_atomic_commit_tail] [ENCODER:217:DDI D]
[60958.757632] [drm:intel_atomic_commit_tail] [ENCODER:219:DP-MST A]
[60958.757634] [drm:intel_atomic_commit_tail] [ENCODER:220:DP-MST B]
[60958.757637] [drm:intel_atomic_commit_tail] [ENCODER:221:DP-MST C]
[60958.757639] [drm:intel_atomic_commit_tail] [ENCODER:227:DDI F]
[60958.757641] [drm:intel_atomic_commit_tail] [ENCODER:229:DP-MST A]
[60958.757643] [drm:intel_atomic_commit_tail] [ENCODER:230:DP-MST B]
[60958.757646] [drm:intel_atomic_commit_tail] [ENCODER:231:DP-MST C]
[60958.757648] [drm:verify_connector_state.isra.110] [CONNECTOR:195:DP-2]
[60958.757653] [drm:verify_connector_state.isra.110] [CONNECTOR:202:HDMI-A-1]
[60958.757656] [drm:verify_connector_state.isra.110] [CONNECTOR:208:DP-3]
[60958.757659] [drm:verify_connector_state.isra.110] [CONNECTOR:214:HDMI-A-2]
[60958.757662] [drm:verify_connector_state.isra.110] [CONNECTOR:218:DP-4]
[60958.757666] [drm:verify_connector_state.isra.110] [CONNECTOR:224:HDMI-A-3]
[60958.757669] [drm:verify_connector_state.isra.110] [CONNECTOR:228:DP-5]
[60958.757672] [drm:verify_connector_state.isra.110] [CONNECTOR:233:HDMI-A-4]
[60958.757676] [drm:verify_single_dpll_state.isra.143] DPLL 0
[60958.757681] [drm:verify_single_dpll_state.isra.143] DPLL 1
[60958.757684] [drm:verify_single_dpll_state.isra.143] TBT PLL
[60958.757687] [drm:verify_single_dpll_state.isra.143] MG PLL 1
[60958.757689] [drm:verify_single_dpll_state.isra.143] MG PLL 2
[60958.757692] [drm:verify_single_dpll_state.isra.143] MG PLL 3
[60958.757695] [drm:verify_single_dpll_state.isra.143] MG PLL 4
[60958.770815] [drm:intel_atomic_commit_tail] [CRTC:135:pipe B]
[60958.770860] [drm:intel_enable_sagv] Enabling the SAGV
[60958.770995] [drm:i915_fifo_underrun_reset_write] Re-arming FIFO underruns on pipe A
[60958.837572] [drm:drm_mode_addfb2] [FB:237]
[60959.887599] [drm:drm_mode_addfb2] [FB:243]
[60960.937722] [drm:drm_mode_addfb2] [FB:237]
[60961.971043] [drm:drm_mode_addfb2] [FB:243]
[60963.021135] [drm:drm_mode_addfb2] [FB:237]
[60964.071163] [drm:drm_mode_addfb2] [FB:243]
[60965.104559] [drm:drm_mode_addfb2] [FB:237]
[60966.137853] [drm:drm_mode_addfb2] [FB:243]
[60967.171257] [drm:drm_mode_addfb2] [FB:237]
[60968.204650] [drm:drm_mode_addfb2] [FB:243]
[60969.238026] [drm:drm_mode_addfb2] [FB:237]
[60970.271366] [drm:drm_mode_addfb2] [FB:243]
[60971.304784] [drm:drm_mode_addfb2] [FB:237]
[60972.338176] [drm:drm_mode_addfb2] [FB:243]
[60973.371478] [drm:drm_mode_addfb2] [FB:237]
[60974.404950] [drm:drm_mode_addfb2] [FB:243]
[60975.438596] [drm:drm_mode_addfb2] [FB:237]
[60976.471897] [drm:drm_mode_addfb2] [FB:243]
[60977.505093] [drm:drm_mode_addfb2] [FB:237]
[60978.538671] [drm:drm_mode_addfb2] [FB:243]
[60979.571858] [drm:drm_mode_addfb2] [FB:237]
[60980.605175] [drm:drm_mode_addfb2] [FB:243]
[60981.638540] [drm:drm_mode_addfb2] [FB:237]
[60982.671893] [drm:drm_mode_addfb2] [FB:243]
[60983.705223] [drm:drm_mode_addfb2] [FB:237]
[60985.838521] [drm:drm_crtc_add_crc_entry] *ERROR* Overflow of CRC buffer, userspace reads too slow.
[60987.322076] [drm:drm_mode_addfb2] [FB:243]
[60990.922241] [drm:drm_mode_addfb2] [FB:237]
[60994.522439] [drm:drm_mode_addfb2] [FB:243]
[60998.005859] [drm:drm_mode_addfb2] [FB:237]
[61001.522684] [drm:drm_mode_addfb2] [FB:243]
[61004.989525] [drm:drm_mode_addfb2] [FB:237]
[61008.456244] [drm:drm_mode_addfb2] [FB:243]
[61011.964193] [drm:drm_mode_addfb2] [FB:237]
[61013.715156] [drm:drm_mode_addfb2] [FB:243]
[61015.198825] [drm:drm_mode_addfb2] [FB:237]
[61016.926709] [drm:drm_mode_addfb2] [FB:243]
[61018.393577] [drm:drm_mode_addfb2] [FB:237]
[61019.843782] [drm:drm_mode_addfb2] [FB:243]
[61021.293495] [drm:drm_mode_addfb2] [FB:237]
[61022.780396] [drm:drm_mode_addfb2] [FB:243]
[61024.264118] [drm:drm_mode_addfb2] [FB:237]
[61025.748849] [drm:drm_mode_addfb2] [FB:243]
[61027.230855] [drm:drm_mode_addfb2] [FB:237]
[61028.713885] [drm:drm_mode_addfb2] [FB:243]
[61030.180712] [drm:drm_mode_addfb2] [FB:237]
[61031.647027] [drm:drm_mode_addfb2] [FB:243]
[61033.130873] [drm:drm_mode_addfb2] [FB:237]
[61034.614257] [drm:drm_mode_addfb2] [FB:243]
[61036.098159] [drm:drm_mode_addfb2] [FB:237]
[61037.581274] [drm:drm_mode_addfb2] [FB:243]
[61039.049380] [drm:drm_mode_addfb2] [FB:237]
[61040.531374] [drm:drm_mode_addfb2] [FB:243]
[61042.013587] [drm:drm_mode_addfb2] [FB:237]
[61043.498156] [drm:drm_mode_addfb2] [FB:243]
[61044.981325] [drm:drm_mode_addfb2] [FB:237]
[61046.465400] [drm:drm_mode_addfb2] [FB:243]
[61047.950569] [drm:drm_mode_addfb2] [FB:237]
[61049.449855] [drm:drm_mode_addfb2] [FB:243]
[61050.932229] [drm:drm_mode_addfb2] [FB:237]
[61052.414760] [drm:drm_mode_addfb2] [FB:243]
[61053.879128] [drm:drm_mode_addfb2] [FB:237]
[61055.365435] [drm:drm_mode_addfb2] [FB:243]
[61056.848359] [drm:drm_mode_addfb2] [FB:237]
[61058.332325] [drm:drm_mode_addfb2] [FB:243]
[61059.831470] [drm:drm_mode_addfb2] [FB:237]
[61060.156400] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61060.156409] [drm:skl_compute_wm] [PLANE:30:plane 1A] ddb (0 - 992) -> (0 - 379)
[61060.156411] [drm:skl_compute_wm] [PLANE:65:plane 6A] ddb (0 - 0) -> (379 - 992)
[61061.181373] [drm:drm_mode_addfb2] [FB:243]
[61061.513258] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61062.548160] [drm:drm_mode_addfb2] [FB:237]
[61062.867165] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61063.897979] [drm:drm_mode_addfb2] [FB:243]
[61064.229782] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61065.264414] [drm:drm_mode_addfb2] [FB:237]
[61065.591523] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61066.631151] [drm:drm_mode_addfb2] [FB:243]
[61066.960161] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61067.998412] [drm:drm_mode_addfb2] [FB:237]
[61068.332170] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61069.364898] [drm:drm_mode_addfb2] [FB:243]
[61069.686825] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61070.718816] [drm:drm_mode_addfb2] [FB:237]
[61071.113295] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61071.113304] [drm:skl_compute_wm] [PLANE:30:plane 1A] ddb (0 - 379) -> (0 - 415)
[61071.113306] [drm:skl_compute_wm] [PLANE:65:plane 6A] ddb (379 - 992) -> (415 - 992)
[61072.148660] [drm:drm_mode_addfb2] [FB:243]
[61072.514766] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61073.548478] [drm:drm_mode_addfb2] [FB:237]
[61073.922800] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61074.956546] [drm:drm_mode_addfb2] [FB:243]
[61075.331777] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61076.369181] [drm:drm_mode_addfb2] [FB:237]
[61076.758585] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61077.802600] [drm:drm_mode_addfb2] [FB:243]
[61078.185443] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61079.219226] [drm:drm_mode_addfb2] [FB:237]
[61079.609815] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61080.652391] [drm:drm_mode_addfb2] [FB:243]
[61081.041651] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61082.085864] [drm:drm_mode_addfb2] [FB:237]
[61082.463015] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61083.503060] [drm:drm_mode_addfb2] [FB:243]
[61083.867854] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61084.899076] [drm:drm_mode_addfb2] [FB:237]
[61085.259316] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61086.303096] [drm:drm_mode_addfb2] [FB:243]
[61086.676928] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61087.719050] [drm:drm_mode_addfb2] [FB:237]
[61088.096427] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61089.136057] [drm:drm_mode_addfb2] [FB:243]
[61089.513727] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61090.553465] [drm:drm_mode_addfb2] [FB:237]
[61090.935738] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61091.969659] [drm:drm_mode_addfb2] [FB:243]
[61092.348973] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61093.386427] [drm:drm_mode_addfb2] [FB:237]
[61093.772686] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61094.803486] [drm:drm_mode_addfb2] [FB:243]
[61095.196167] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61096.236034] [drm:drm_mode_addfb2] [FB:237]
[61096.618547] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61097.656945] [drm:drm_mode_addfb2] [FB:243]
[61098.045670] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61099.087490] [drm:drm_mode_addfb2] [FB:237]
[61099.482096] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61100.519255] [drm:drm_mode_addfb2] [FB:243]
[61100.901449] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61101.936723] [drm:drm_mode_addfb2] [FB:237]
[61102.328623] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61103.373635] [drm:drm_mode_addfb2] [FB:243]
[61103.752239] [drm:intel_crtc_atomic_check] Using plane 6A as Y plane for plane 1A
[61104.787730] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
[61104.837640] [IGT] kms_plane: exiting, ret=99
[61104.838231] [drm:intel_hdmi_compute_config] picking bpc to 12 for HDMI output
[61104.838236] [drm:intel_hdmi_compute_config] forcing pipe bpp to 36 for HDMI
[61104.838241] [drm:intel_atomic_check] hw max bpp: 36, pipe bpp: 36, dithering: 0
[61104.838246] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_hdisplay (expected 0, found 1360)
[61104.838248] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_htotal (expected 0, found 1792)
[61104.838250] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_hblank_start (expected 0, found 1360)
[61104.838252] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_hblank_end (expected 0, found 1792)
[61104.838253] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_hsync_start (expected 0, found 1424)
[61104.838255] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_hsync_end (expected 0, found 1536)
[61104.838257] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vdisplay (expected 0, found 768)
[61104.838259] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vtotal (expected 0, found 795)
[61104.838261] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vblank_start (expected 0, found 768)
[61104.838262] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vblank_end (expected 0, found 795)
[61104.838264] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vsync_start (expected 0, found 771)
[61104.838266] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_vsync_end (expected 0, found 777)
[61104.838268] [drm:pipe_config_err] mismatch in base.adjusted_mode.flags (1) (expected 0, found 1)
[61104.838270] [drm:pipe_config_err] mismatch in base.adjusted_mode.flags (4) (expected 0, found 4)
[61104.838274] [drm:pipe_config_err] mismatch in base.adjusted_mode.crtc_clock (expected 0, found 85500)
[61104.838277] [drm:intel_dump_pipe_config] [CRTC:135:pipe B][modeset]
[61104.838280] [drm:intel_dump_pipe_config] output_types: HDMI (0x40)
[61104.838282] [drm:intel_dump_pipe_config] output format: RGB
[61104.838285] [drm:intel_dump_pipe_config] cpu_transcoder: B, pipe bpp: 36, dithering: 0
[61104.838287] [drm:intel_dump_pipe_config] audio: 1, infoframes: 1
[61104.838289] [drm:intel_dump_pipe_config] requested mode:
[61104.838297] [drm:drm_mode_debug_printmodeline] Modeline "1360x768": 60 85500 1360 1424 1536 1792 768 771 777 795 0x48 0x5
[61104.838299] [drm:intel_dump_pipe_config] adjusted mode:
[61104.838303] [drm:drm_mode_debug_printmodeline] Modeline "1360x768": 60 85500 1360 1424 1536 1792 768 771 777 795 0x48 0x5
[61104.838306] [drm:intel_dump_pipe_config] crtc timings: 85500 1360 1424 1536 1792 768 771 777 795, type: 0x48 flags: 0x5
[61104.838309] [drm:intel_dump_pipe_config] port clock: 128250, pipe src size: 1360x768, pixel rate 85500
[61104.838312] [drm:intel_dump_pipe_config] num_scalers: 2, scaler_users: 0x0, scaler_id: -1
[61104.838315] [drm:intel_dump_pipe_config] pch pfit: pos: 0x00000000, size: 0x00000000, disabled
[61104.838317] [drm:intel_dump_pipe_config] ips: 0, double wide: 0
[61104.838323] [drm:icl_dump_hw_state] dpll_hw_state: cfgcr0: 0x0, cfgcr1: 0x0, mg_refclkin_ctl: 0x100, hg_clktop2_coreclkctl1: 0x500, mg_clktop2_hsclkctl: 0x1b200, mg_pll_div0: 0x79400074, mg_pll_div2: 0x21012, mg_pll_lf: 0x27110804, mg_pll_frac_lock: 0x5554a, mg_pll_ssc: 0x8001200, mg_pll_bias: 0x0, mg_pll_tdc_coldst_bias: 0x10000
[61104.838325] [drm:intel_dump_pipe_config] planes on this crtc
[61104.838328] [drm:intel_dump_pipe_config] [PLANE:83:plane 1B] disabled, scaler_id = -1
[61104.838330] [drm:intel_dump_pipe_config] [PLANE:90:plane 2B] disabled, scaler_id = -1
[61104.838332] [drm:intel_dump_pipe_config] [PLANE:97:plane 3B] disabled, scaler_id = -1
[61104.838334] [drm:intel_dump_pipe_config] [PLANE:104:plane 4B] disabled, scaler_id = -1
[61104.838336] [drm:intel_dump_pipe_config] [PLANE:111:plane 5B] disabled, scaler_id = -1
[61104.838338] [drm:intel_dump_pipe_config] [PLANE:118:plane 6B] disabled, scaler_id = -1
[61104.838340] [drm:intel_dump_pipe_config] [PLANE:125:plane 7B] disabled, scaler_id = -1
[61104.838342] [drm:intel_dump_pipe_config] [PLANE:132:cursor B] disabled, scaler_id = -1
[61104.838371] [drm:intel_atomic_check] New cdclk calculated to be logical 307200 kHz, actual 307200 kHz
[61104.838374] [drm:intel_atomic_check] New voltage level calculated to be logical 0, actual 0
[61104.838390] [drm:intel_find_shared_dpll] [CRTC:135:pipe B] allocated MG PLL 1
[61104.838392] [drm:intel_reference_shared_dpll] using MG PLL 1 for pipe B
[61104.838412] [drm:skl_compute_wm] [PLANE:30:plane 1A] ddb (0 - 415) -> (0 - 1429)
[61104.838415] [drm:skl_compute_wm] [PLANE:65:plane 6A] ddb (415 - 992) -> (0 - 0)
[61104.838419] [drm:skl_compute_wm] [PLANE:79:cursor A] ddb (992 - 1024) -> (1429 - 1437)
[61104.838422] [drm:skl_compute_wm] [PLANE:83:plane 1B] ddb (0 - 0) -> (1437 - 2040)
[61104.838425] [drm:skl_compute_wm] [PLANE:132:cursor B] ddb (0 - 0) -> (2040 - 2048)
[61104.838503] [drm:intel_disable_sagv] Disabling the SAGV
[61104.838533] [drm:intel_atomic_commit_tail] [ENCODER:189:DDI A]
[61104.838536] [drm:intel_atomic_commit_tail] [ENCODER:194:DDI B]
[61104.838539] [drm:intel_atomic_commit_tail] [ENCODER:196:DP-MST A]
[61104.838541] [drm:intel_atomic_commit_tail] [ENCODER:197:DP-MST B]
[61104.838544] [drm:intel_atomic_commit_tail] [ENCODER:198:DP-MST C]
[61104.838549] [drm:intel_atomic_commit_tail] [ENCODER:207:DDI C]
[61104.838554] [drm:intel_atomic_commit_tail] [ENCODER:209:DP-MST A]
[61104.838558] [drm:intel_atomic_commit_tail] [ENCODER:210:DP-MST B]
[61104.838562] [drm:intel_atomic_commit_tail] [ENCODER:211:DP-MST C]
[61104.838565] [drm:intel_atomic_commit_tail] [ENCODER:217:DDI D]
[61104.838572] [drm:intel_atomic_commit_tail] [ENCODER:219:DP-MST A]
[61104.838575] [drm:intel_atomic_commit_tail] [ENCODER:220:DP-MST B]
[61104.838578] [drm:intel_atomic_commit_tail] [ENCODER:221:DP-MST C]
[61104.838582] [drm:intel_atomic_commit_tail] [ENCODER:227:DDI F]
[61104.838585] [drm:intel_atomic_commit_tail] [ENCODER:229:DP-MST A]
[61104.838589] [drm:intel_atomic_commit_tail] [ENCODER:230:DP-MST B]
[61104.838592] [drm:intel_atomic_commit_tail] [ENCODER:231:DP-MST C]
[61104.838596] [drm:verify_single_dpll_state.isra.143] DPLL 0
[61104.838603] [drm:verify_single_dpll_state.isra.143] DPLL 1
[61104.838608] [drm:verify_single_dpll_state.isra.143] TBT PLL
[61104.838611] [drm:verify_single_dpll_state.isra.143] MG PLL 1
[61104.838615] [drm:verify_single_dpll_state.isra.143] MG PLL 2
[61104.838620] [drm:verify_single_dpll_state.isra.143] MG PLL 3
[61104.838627] [drm:verify_single_dpll_state.isra.143] MG PLL 4
[61104.843432] [drm:intel_power_well_enable] enabling AUX C
[61104.843442] [drm:intel_enable_shared_dpll] enable MG PLL 1 (active 2, on? 0) for crtc 135
[61104.843444] [drm:intel_enable_shared_dpll] enabling MG PLL 1
[61104.843509] [drm:intel_power_well_enable] enabling DDI C IO
[61104.843532] [drm:icl_ddi_vswing_sequence] DDI translation not found for level 9. Using 8 instead.
[61104.843699] [drm:intel_enable_pipe] enabling pipe B
[61104.843735] [drm:intel_audio_codec_enable] ELD on [CONNECTOR:214:HDMI-A-2], [ENCODER:207:DDI C]
[61104.843739] [drm:hsw_audio_codec_enable] Enable audio codec on pipe B, 28 bytes ELD
[61104.843748] [drm:audio_config_hdmi_pixel_clock] HDMI audio pixel clock setting for 85500 not found, falling back to defaults
[61104.843751] [drm:audio_config_hdmi_pixel_clock] Configuring HDMI audio for pixel clock 25200 (0x00010000)
[61104.843754] [drm:hsw_audio_config_update] using automatic N
[61104.860602] [drm:verify_connector_state.isra.110] [CONNECTOR:214:HDMI-A-2]
[61104.860613] [drm:intel_atomic_commit_tail] [CRTC:135:pipe B]
[61104.860654] [drm:verify_single_dpll_state.isra.143] MG PLL 1
[61104.864730] Console: switching to colour frame buffer device 170x48

[-- Attachment #3: Type: text/plain, Size: 154 bytes --]

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-06  6:47       ` Sharma, Swati2
@ 2019-02-06 14:21         ` Sharma, Swati2
  2019-02-06 15:05           ` Maarten Lankhorst
  0 siblings, 1 reply; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-06 14:21 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev


[-- Attachment #1.1: Type: text/plain, Size: 15136 bytes --]

On 06-Feb-19 12:17 PM, Sharma, Swati2 wrote:

>
> On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
>> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>>> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>>>> Those formats are packed like YUYV, but only 16 bits per component.
>>>>
>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>> ---
>>>>    include/drm-uapi/drm_fourcc.h |   6 +-
>>>>    lib/igt_color_encoding.c      |   3 +
>>>>    lib/igt_fb.c                  | 146 
>>>> ++++++++++++++++++++++++++++++++++
>>>>    3 files changed, 154 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/drm-uapi/drm_fourcc.h 
>>>> b/include/drm-uapi/drm_fourcc.h
>>>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>>>> --- a/lib/igt_fb.c
>>>> +++ b/lib/igt_fb.c
>>>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>>>          .cairo_id = CAIRO_FORMAT_RGB24,
>>>>          .num_planes = 1, .plane_bpp = { 16, },
>>>>        },
>>>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>> +    },
>>>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>> +    },
>>>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>> +    },
>>>>        { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>>>          .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>          .num_planes = 2, .plane_bpp = { 16, 32 },
>>>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>>>                        fb->offsets[1] / sizeof(wchar_t));
>>>>                    wmemset(ptr + fb->offsets[1], 0x80008000,
>>>>                        DIV_ROUND_UP(fb->height,2) * fb->strides[1] 
>>>> / sizeof(wchar_t));
>>>> +            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;
>>>>                }
>>>>                gem_munmap(ptr, fb->size);
>>> Hi Maarten,
>>>
>>> While testing Y210 pixel format, IGT is failing with debug message 
>>> showing igt_create_fb() failure
>>>
>>> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function 
>>> igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: 
>>> (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, 
>>> fb->drm_format, fb->tiling, fb->strides, fb->offsets, 
>>> fb->num_planes, flags, &fb->fb_id)) == 0
>>> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>>
>>> dmesg showing bad pitch 12800 for Y210 pixel format
>>>
>>> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 
>>> for plane 0
>>> [  634.104444] [IGT] kms_plane: exiting, ret=99
>>>
>>> Can you please confirm whether changes needs to be done from igt or 
>>> some issue with Y2xx driver patches?
>>>
>>>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct 
>>>> fb_convert *cvt)
>>>>        }
>>>>    }
>>>>    +
>>>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>>>> +{
>>>> +    int i, j;
>>>> +    const uint16_t *yuyv;
>>>> +    uint16_t *buf;
>>>> +    float *ptr = cvt->dst.ptr;
>>>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / 
>>>> sizeof(*ptr);
>>>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / 
>>>> sizeof(*yuyv);
>>>> +    struct igt_mat4 m = 
>>>> igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>>>> +                            cvt->dst.fb->drm_format,
>>>> + cvt->src.fb->color_encoding,
>>>> + cvt->src.fb->color_range);
>>>> +
>>>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>>>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>>>> +
>>>> +    yuyv = buf = convert_src_get(cvt);
>>>> +
>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>> +            /* Convert 2x1 pixel blocks */
>>>> +            struct igt_vec4 yuv[2];
>>>> +            struct igt_vec4 rgb[2];
>>>> +
>>>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>>>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>>>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>>>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>>>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>>>> +
>>>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>>>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>>>> +
>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>>>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>>>> +        }
>>>> +
>>>> +        if (cvt->dst.fb->width & 1) {
>>>> +            struct igt_vec4 yuv;
>>>> +            struct igt_vec4 rgb;
>>>> +
>>>> +            yuv.d[0] = yuyv[j * 4 + 0];
>>>> +            yuv.d[1] = yuyv[j * 4 + 1];
>>>> +            yuv.d[2] = yuyv[j * 4 + 3];
>>>> +            yuv.d[3] = 1.0f;
>>>> +
>>>> +            rgb = igt_matrix_transform(&m, &yuv);
>>>> +
>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>>>> +        }
>>>> +
>>>> +        ptr += float_stride;
>>>> +        yuyv += yuyv_stride;
>>>> +    }
>>>> +
>>>> +    convert_src_put(cvt, buf);
>>>> +}
>>>> +
>>>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>>>> +{
>>>> +    int i, j;
>>>> +    uint16_t *yuyv = cvt->dst.ptr;
>>>> +    const float *ptr = cvt->src.ptr;
>>>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>>>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>>>> +    struct igt_mat4 m = 
>>>> igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>>>> +                            cvt->dst.fb->drm_format,
>>>> + cvt->dst.fb->color_encoding,
>>>> + cvt->dst.fb->color_range);
>>>> +
>>>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>>>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>>>> +
>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>> +            /* Convert 2x1 pixel blocks */
>>>> +            struct igt_vec4 rgb[2];
>>>> +            struct igt_vec4 yuv[2];
>>>> +
>>>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>>>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>>>> +
>>>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>>>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>>>> +
>>>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>>>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>>>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>>>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>>>> +        }
>>>> +
>>>> +        if (cvt->dst.fb->width & 1) {
>>>> +            struct igt_vec4 rgb;
>>>> +            struct igt_vec4 yuv;
>>>> +
>>>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>>>> +
>>>> +            yuv = igt_matrix_transform(&m, &rgb);
>>>> +
>>>> +            yuyv[j * 4 + 0] = yuv.d[0];
>>>> +            yuyv[j * 4 + 1] = yuv.d[1];
>>>> +            yuyv[j * 4 + 3] = yuv.d[2];
>>>> +        }
>>>> +
>>>> +        ptr += float_stride;
>>>> +        yuyv += yuyv_stride;
>>>> +    }
>>>> +}
>>>> +
>>>>    static void convert_pixman(struct fb_convert *cvt)
>>>>    {
>>>>        pixman_format_code_t src_pixman = 
>>>> drm_format_to_pixman(cvt->src.fb->drm_format);
>>>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>            case DRM_FORMAT_P016:
>>>>                convert_p01X_to_float(cvt);
>>>>                return;
>>>> +        case DRM_FORMAT_Y210:
>>>> +        case DRM_FORMAT_Y212:
>>>> +        case DRM_FORMAT_Y216:
>>>> +            convert_Y21X_to_float(cvt);
>>>> +            return;
>>>>            }
>>>>        } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>>>            switch (cvt->dst.fb->drm_format) {
>>>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>            case DRM_FORMAT_P016:
>>>>                convert_float_to_p01X(cvt);
>>>>                return;
>>>> +        case DRM_FORMAT_Y210:
>>>> +        case DRM_FORMAT_Y212:
>>>> +        case DRM_FORMAT_Y216:
>>>> +            convert_float_to_Y21X(cvt);
>>>> +            return;
>>>>            }
>>>>        }
>>>>    @@ -2583,6 +2726,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:
>> Can I get the full IGT / dmesg logs? I can't see what the fb 
>> dimensions they are.
>
> IGT Logs:
>
> (kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, 
> height=1800, format=0x30313259, tiling=0x0, size=0)
> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, 
> pitch=12800)
> (kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: 
> igt_has_fb_modifiers(fd)
> (kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function 
> igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
> (kms_plane:4960) igt_fb-CRITICAL: Failed assertion: 
> (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, 
> fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, 
> flags, &fb->fb_id)) == 0
> (kms_plane:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
> (kms_plane:4960) igt_core-INFO: Stack trace:
> (kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 
> __igt_fail_assert()
> (kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 
> igt_create_fb_with_bo_size()
> (kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
> (kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 
> igt_create_color_fb()
> (kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 
> test_format_plane_color()
> (kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 
> test_format_plane()
> (kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 
> test_pixel_formats()
> (kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 
> run_tests_for_pipe_plane()
> (kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 
> __real_main642()
> (kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
> (kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 
> __libc_start_main()
> (kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
> (kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
> ****  END  ****
>
> Dmesg Logs: Attached y210_dmesg_failure.txt
>
Same failure exists for all the Y2xx formats Y210/Y212/Y216.
>>
>> ~Maarten
>>
>>
>> _______________________________________________
>> igt-dev mailing list
>> igt-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/igt-dev
-- 
Thanks and Regards, Swati

[-- Attachment #1.2: Type: text/html, Size: 23920 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats.
  2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats Maarten Lankhorst
@ 2019-02-06 14:26   ` Sharma, Swati2
  0 siblings, 0 replies; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-06 14:26 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev


[-- Attachment #1.1: Type: text/plain, Size: 9694 bytes --]

For Y410, there is crc mismatch for plane 0.

Being curious just wanted to ask, why haven't you added Y412? :/

On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
> Y410 is packed with compressed a channel and only 32 bpp, like
> 10 bits RGB formats. Y416 is a packed 16 bits per component format.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>   include/drm-uapi/drm_fourcc.h |   3 +
>   lib/igt_color_encoding.c      |   2 +
>   lib/igt_fb.c                  | 203 ++++++++++++++++++++++++++++++++++
>   3 files changed, 208 insertions(+)
>
> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
> index 8f1b5f832a09..1d04304a0528 100644
> --- a/include/drm-uapi/drm_fourcc.h
> +++ b/include/drm-uapi/drm_fourcc.h
> @@ -157,6 +157,9 @@ extern "C" {
>   #define DRM_FORMAT_Y212		fourcc_code('Y', '2', '1', '2')
>   #define DRM_FORMAT_Y216		fourcc_code('Y', '2', '1', '6')
>   
> +#define DRM_FORMAT_Y410		fourcc_code('Y', '4', '1', '0') /* [31:0] A:V:Y:U 2:10:10:10 little endian */
> +#define DRM_FORMAT_Y416		fourcc_code('Y', '4', '1', '6') /* [127:0] A: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 6f82fcec62e4..bc9575fca1b4 100644
> --- a/lib/igt_color_encoding.c
> +++ b/lib/igt_color_encoding.c
> @@ -147,6 +147,8 @@ static const struct color_encoding_format {
>   	{ 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 },
> +	{ DRM_FORMAT_Y410, 1023.f, 64.f, 940.f, 64.f, 512.f, 960.f },
> +	{ DRM_FORMAT_Y416, 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 c14cc10d1b73..15c541d1fc4e 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -163,6 +163,14 @@ static const struct format_desc_struct {
>   	  .cairo_id = CAIRO_FORMAT_RGB96F,
>   	  .num_planes = 1, .plane_bpp = { 32, },
>   	},
> +	{ .name = "Y410", .depth = -1, .drm_id = DRM_FORMAT_Y410,
> +	  .cairo_id = CAIRO_FORMAT_RGBA128F,
> +	  .num_planes = 1, .plane_bpp = { 32, },
> +	},
> +	{ .name = "Y416", .depth = -1, .drm_id = DRM_FORMAT_Y416,
> +	  .cairo_id = CAIRO_FORMAT_RGBA128F,
> +	  .num_planes = 1, .plane_bpp = { 64, },
> +	},
>   	{ .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>   	  .cairo_id = CAIRO_FORMAT_RGB96F,
>   	  .num_planes = 2, .plane_bpp = { 16, 32 },
> @@ -572,6 +580,28 @@ static int create_bo_for_fb(struct igt_fb *fb)
>   					full_range ? 0x80000000 : 0x80001000,
>   					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
>   				break;
> +			case DRM_FORMAT_Y410:
> +				wmemset(ptr + fb->offsets[0],
> +					full_range ? 0xc0080000 : 0xc4080040,
> +					fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
> +				break;
> +			case DRM_FORMAT_Y416: {
> +				struct ayuv16 { uint16_t u, y, v, a; };
> +				const struct ayuv16 pixel = {
> +					.a = 0xffff,
> +					.v = full_range ? 0 : 0x1000,
> +					.y = 0x8000,
> +					.u = full_range ? 0 : 0x1000
> +				};
> +
> +				for (int i = 0; i < fb->plane_height[0]; i++) {
> +					struct ayuv16 *cur = ptr + fb->offsets[0] + fb->strides[0] * i;
> +
> +					for (int j = 0; i < fb->plane_width[0]; j++)
> +						*cur++ = pixel;
> +				}
> +				break;
> +				}
>   			}
>   			gem_munmap(ptr, fb->size);
>   
> @@ -2272,6 +2302,165 @@ static void convert_float_to_Y21X(struct fb_convert *cvt)
>   	}
>   }
>   
> +static void convert_Y410_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	const uint32_t *yuyv;
> +	uint32_t *buf;
> +	float *ptr = cvt->dst.ptr;
> +	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
> +	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->src.fb->color_encoding,
> +						    cvt->src.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == DRM_FORMAT_Y410 &&
> +		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
> +
> +	yuyv = buf = convert_src_get(cvt);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 yuv;
> +			struct igt_vec4 rgb;
> +
> +			yuv.d[0] = yuyv[j] & 0x3ff;
> +			yuv.d[1] = (yuyv[j] >> 10) & 0x3ff;
> +			yuv.d[2] = (yuyv[j] >> 20) & 0x3ff;
> +			yuv.d[3] = 1.f;
> +
> +			rgb = igt_matrix_transform(&m, &yuv);
> +
> +			write_rgbf(&ptr[j * 4 + 0], &rgb);
> +			ptr[j * 4 + 3] = (float)(yuyv[j] >> 30) / 3;
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_Y410(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint32_t *yuyv = cvt->dst.ptr;
> +	const float *ptr = cvt->src.ptr;
> +	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
> +	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->dst.fb->color_encoding,
> +						    cvt->dst.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
> +		   cvt->dst.fb->drm_format == DRM_FORMAT_Y410);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			struct igt_vec4 rgb;
> +			struct igt_vec4 yuv;
> +			uint8_t alpha = ptr[j * 4 + 3] * 3.f + .5f;
> +			uint16_t y, cb, cr;
> +
> +			read_rgbf(&rgb, &ptr[j * 4 + 0]);
> +
> +			yuv = igt_matrix_transform(&m, &rgb);
> +			cr = yuv.d[0];
> +			y = yuv.d[1];
> +			cb = yuv.d[2];
> +
> +			yuyv[j] = ((cr & 0x3ff) << 0) |
> +				  ((y & 0x3ff) << 10) |
> +				  ((cb & 0x3ff) << 20) |
> +				  ((alpha & 3) << 30);
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +}
> +
> +static void convert_Y416_to_float(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	const uint16_t *yuyv;
> +	uint16_t *buf;
> +	float *ptr = cvt->dst.ptr;
> +	unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
> +	unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->src.fb->color_encoding,
> +						    cvt->src.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == DRM_FORMAT_Y416 &&
> +		   cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
> +
> +	buf = convert_src_get(cvt);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			/* Convert 2x1 pixel blocks */
> +			struct igt_vec4 yuv;
> +			struct igt_vec4 rgb;
> +
> +			yuv.d[0] = yuyv[j * 4 + 0];
> +			yuv.d[1] = yuyv[j * 4 + 1];
> +			yuv.d[2] = yuyv[j * 4 + 2];
> +			yuv.d[3] = 1.f;
> +
> +			rgb = igt_matrix_transform(&m, &yuv);
> +
> +			write_rgbf(&ptr[j * 4 + 0], &rgb);
> +			ptr[j * 4 + 3] = (float)yuyv[j * 4 + 3] / 65535.f;
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +
> +	convert_src_put(cvt, buf);
> +}
> +
> +static void convert_float_to_Y416(struct fb_convert *cvt)
> +{
> +	int i, j;
> +	uint16_t *yuyv = cvt->dst.ptr;
> +	const float *ptr = cvt->src.ptr;
> +	unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
> +	unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
> +	struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
> +						    cvt->dst.fb->drm_format,
> +						    cvt->dst.fb->color_encoding,
> +						    cvt->dst.fb->color_range);
> +
> +	igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
> +		   cvt->dst.fb->drm_format == DRM_FORMAT_Y416);
> +
> +	for (i = 0; i < cvt->dst.fb->height; i++) {
> +		for (j = 0; j < cvt->dst.fb->width; j++) {
> +			struct igt_vec4 rgb;
> +			struct igt_vec4 yuv;
> +
> +			read_rgbf(&rgb, &ptr[j * 4 + 0]);
> +
> +			yuv = igt_matrix_transform(&m, &rgb);
> +
> +			yuyv[j * 4 + 0] = yuv.d[0];
> +			yuyv[j * 4 + 1] = yuv.d[1];
> +			yuyv[j * 4 + 2] = yuv.d[2];
> +			yuyv[j * 4 + 3] = ptr[j * 4 + 3] * 65535.f + .5f;
> +		}
> +
> +		ptr += float_stride;
> +		yuyv += yuyv_stride;
> +	}
> +}
> +
>   static void convert_pixman(struct fb_convert *cvt)
>   {
>   	pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
> @@ -2359,6 +2548,12 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_Y216:
>   			convert_Y21X_to_float(cvt);
>   			return;
> +		case DRM_FORMAT_Y410:
> +			convert_Y410_to_float(cvt);
> +			return;
> +		case DRM_FORMAT_Y416:
> +			convert_Y416_to_float(cvt);
> +			return;
>   		}
>   	} else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>   		switch (cvt->dst.fb->drm_format) {
> @@ -2372,6 +2567,12 @@ static void fb_convert(struct fb_convert *cvt)
>   		case DRM_FORMAT_Y216:
>   			convert_float_to_Y21X(cvt);
>   			return;
> +		case DRM_FORMAT_Y410:
> +			convert_float_to_Y410(cvt);
> +			return;
> +		case DRM_FORMAT_Y416:
> +			convert_float_to_Y416(cvt);
> +			return;
>   		}
>   	}
>   
> @@ -2729,6 +2930,8 @@ bool igt_format_is_yuv(uint32_t drm_format)
>   	case DRM_FORMAT_Y210:
>   	case DRM_FORMAT_Y212:
>   	case DRM_FORMAT_Y216:
> +	case DRM_FORMAT_Y410:
> +	case DRM_FORMAT_Y416:
>   	case DRM_FORMAT_YUYV:
>   	case DRM_FORMAT_YVYU:
>   	case DRM_FORMAT_UYVY:
-- 
Thanks and Regards, Swati

[-- Attachment #1.2: Type: text/html, Size: 10196 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-06 14:21         ` Sharma, Swati2
@ 2019-02-06 15:05           ` Maarten Lankhorst
  2019-02-07  6:23             ` Sharma, Swati2
  0 siblings, 1 reply; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-06 15:05 UTC (permalink / raw)
  To: Sharma, Swati2, igt-dev

Op 06-02-2019 om 15:21 schreef Sharma, Swati2:
>
> On 06-Feb-19 12:17 PM, Sharma, Swati2 wrote:
>
>>
>> On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
>>> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>>>> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>>>>> Those formats are packed like YUYV, but only 16 bits per component.
>>>>>
>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>>> ---
>>>>>    include/drm-uapi/drm_fourcc.h |   6 +-
>>>>>    lib/igt_color_encoding.c      |   3 +
>>>>>    lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>>>>>    3 files changed, 154 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>>>>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>>>>> --- a/lib/igt_fb.c
>>>>> +++ b/lib/igt_fb.c
>>>>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>>>>          .cairo_id = CAIRO_FORMAT_RGB24,
>>>>>          .num_planes = 1, .plane_bpp = { 16, },
>>>>>        },
>>>>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>> +    },
>>>>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>> +    },
>>>>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>> +    },
>>>>>        { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>>>>          .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>          .num_planes = 2, .plane_bpp = { 16, 32 },
>>>>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>>>>                        fb->offsets[1] / sizeof(wchar_t));
>>>>>                    wmemset(ptr + fb->offsets[1], 0x80008000,
>>>>>                        DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>>>> +            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;
>>>>>                }
>>>>>                gem_munmap(ptr, fb->size);
>>>> Hi Maarten,
>>>>
>>>> While testing Y210 pixel format, IGT is failing with debug message showing igt_create_fb() failure
>>>>
>>>> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>>> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>>>> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>>>
>>>> dmesg showing bad pitch 12800 for Y210 pixel format
>>>>
>>>> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
>>>> [  634.104444] [IGT] kms_plane: exiting, ret=99
>>>>
>>>> Can you please confirm whether changes needs to be done from igt or some issue with Y2xx driver patches?
>>>>
>>>>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>>>>>        }
>>>>>    }
>>>>>    +
>>>>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>>>>> +{
>>>>> +    int i, j;
>>>>> +    const uint16_t *yuyv;
>>>>> +    uint16_t *buf;
>>>>> +    float *ptr = cvt->dst.ptr;
>>>>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
>>>>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
>>>>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>>>>> +                            cvt->dst.fb->drm_format,
>>>>> +                            cvt->src.fb->color_encoding,
>>>>> +                            cvt->src.fb->color_range);
>>>>> +
>>>>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>>>>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>>>>> +
>>>>> +    yuyv = buf = convert_src_get(cvt);
>>>>> +
>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>> +            /* Convert 2x1 pixel blocks */
>>>>> +            struct igt_vec4 yuv[2];
>>>>> +            struct igt_vec4 rgb[2];
>>>>> +
>>>>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>>>>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>>>>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>>>>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>>>>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>>>>> +
>>>>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>>>>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>>>>> +
>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>>>>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>>>>> +        }
>>>>> +
>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>> +            struct igt_vec4 yuv;
>>>>> +            struct igt_vec4 rgb;
>>>>> +
>>>>> +            yuv.d[0] = yuyv[j * 4 + 0];
>>>>> +            yuv.d[1] = yuyv[j * 4 + 1];
>>>>> +            yuv.d[2] = yuyv[j * 4 + 3];
>>>>> +            yuv.d[3] = 1.0f;
>>>>> +
>>>>> +            rgb = igt_matrix_transform(&m, &yuv);
>>>>> +
>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>>>>> +        }
>>>>> +
>>>>> +        ptr += float_stride;
>>>>> +        yuyv += yuyv_stride;
>>>>> +    }
>>>>> +
>>>>> +    convert_src_put(cvt, buf);
>>>>> +}
>>>>> +
>>>>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>>>>> +{
>>>>> +    int i, j;
>>>>> +    uint16_t *yuyv = cvt->dst.ptr;
>>>>> +    const float *ptr = cvt->src.ptr;
>>>>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>>>>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>>>>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>>>>> +                            cvt->dst.fb->drm_format,
>>>>> +                            cvt->dst.fb->color_encoding,
>>>>> +                            cvt->dst.fb->color_range);
>>>>> +
>>>>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>>>>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>>>>> +
>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>> +            /* Convert 2x1 pixel blocks */
>>>>> +            struct igt_vec4 rgb[2];
>>>>> +            struct igt_vec4 yuv[2];
>>>>> +
>>>>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>>>>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>>>>> +
>>>>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>>>>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>>>>> +
>>>>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>>>>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>>>>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>>>>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>>>>> +        }
>>>>> +
>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>> +            struct igt_vec4 rgb;
>>>>> +            struct igt_vec4 yuv;
>>>>> +
>>>>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>>>>> +
>>>>> +            yuv = igt_matrix_transform(&m, &rgb);
>>>>> +
>>>>> +            yuyv[j * 4 + 0] = yuv.d[0];
>>>>> +            yuyv[j * 4 + 1] = yuv.d[1];
>>>>> +            yuyv[j * 4 + 3] = yuv.d[2];
>>>>> +        }
>>>>> +
>>>>> +        ptr += float_stride;
>>>>> +        yuyv += yuyv_stride;
>>>>> +    }
>>>>> +}
>>>>> +
>>>>>    static void convert_pixman(struct fb_convert *cvt)
>>>>>    {
>>>>>        pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>>>>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>            case DRM_FORMAT_P016:
>>>>>                convert_p01X_to_float(cvt);
>>>>>                return;
>>>>> +        case DRM_FORMAT_Y210:
>>>>> +        case DRM_FORMAT_Y212:
>>>>> +        case DRM_FORMAT_Y216:
>>>>> +            convert_Y21X_to_float(cvt);
>>>>> +            return;
>>>>>            }
>>>>>        } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>>>>            switch (cvt->dst.fb->drm_format) {
>>>>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>            case DRM_FORMAT_P016:
>>>>>                convert_float_to_p01X(cvt);
>>>>>                return;
>>>>> +        case DRM_FORMAT_Y210:
>>>>> +        case DRM_FORMAT_Y212:
>>>>> +        case DRM_FORMAT_Y216:
>>>>> +            convert_float_to_Y21X(cvt);
>>>>> +            return;
>>>>>            }
>>>>>        }
>>>>>    @@ -2583,6 +2726,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:
>>> Can I get the full IGT / dmesg logs? I can't see what the fb dimensions they are.
>>
>> IGT Logs:
>>
>> (kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, height=1800, format=0x30313259, tiling=0x0, size=0)
>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, pitch=12800)
>> (kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: igt_has_fb_modifiers(fd)
>> (kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>> (kms_plane:4960) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>> (kms_plane:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>> (kms_plane:4960) igt_core-INFO: Stack trace:
>> (kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 __igt_fail_assert()
>> (kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 igt_create_fb_with_bo_size()
>> (kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
>> (kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 igt_create_color_fb()
>> (kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 test_format_plane_color()
>> (kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 test_format_plane()
>> (kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 test_pixel_formats()
>> (kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 run_tests_for_pipe_plane()
>> (kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 __real_main642()
>> (kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
>> (kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 __libc_start_main()
>> (kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
>> (kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
>> ****  END  ****
>>
>> Dmesg Logs: Attached y210_dmesg_failure.txt
>>
> Same failure exists for all the Y2xx formats Y210/Y212/Y216.

Seems like a bug with your format definition in the kernel?

Y210 is Y0 U Y1 V, for a total of 64 bits per 2 Y pixels.

pitch is set to 12800 / 4 = 3200. This is exactly the minimum, so should pass..

I'll have to rebase the IGT patches, but as far as I can tell they're correct, and you have a bug in your implementation. :)

~Maarten

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-06 15:05           ` Maarten Lankhorst
@ 2019-02-07  6:23             ` Sharma, Swati2
  2019-02-07  8:15               ` Maarten Lankhorst
  0 siblings, 1 reply; 21+ messages in thread
From: Sharma, Swati2 @ 2019-02-07  6:23 UTC (permalink / raw)
  To: Maarten Lankhorst, igt-dev


On 06-Feb-19 8:35 PM, Maarten Lankhorst wrote:
> Op 06-02-2019 om 15:21 schreef Sharma, Swati2:
>> On 06-Feb-19 12:17 PM, Sharma, Swati2 wrote:
>>
>>> On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
>>>> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>>>>> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>>>>>> Those formats are packed like YUYV, but only 16 bits per component.
>>>>>>
>>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>>>> ---
>>>>>>     include/drm-uapi/drm_fourcc.h |   6 +-
>>>>>>     lib/igt_color_encoding.c      |   3 +
>>>>>>     lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>>>>>>     3 files changed, 154 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>>>>>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>>>>>> --- a/lib/igt_fb.c
>>>>>> +++ b/lib/igt_fb.c
>>>>>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>>>>>           .cairo_id = CAIRO_FORMAT_RGB24,
>>>>>>           .num_planes = 1, .plane_bpp = { 16, },
>>>>>>         },
>>>>>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>> +    },
>>>>>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>> +    },
>>>>>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>> +    },
>>>>>>         { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>>>>>           .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>>           .num_planes = 2, .plane_bpp = { 16, 32 },
>>>>>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>>>>>                         fb->offsets[1] / sizeof(wchar_t));
>>>>>>                     wmemset(ptr + fb->offsets[1], 0x80008000,
>>>>>>                         DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>>>>> +            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;
>>>>>>                 }
>>>>>>                 gem_munmap(ptr, fb->size);
>>>>> Hi Maarten,
>>>>>
>>>>> While testing Y210 pixel format, IGT is failing with debug message showing igt_create_fb() failure
>>>>>
>>>>> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>>>> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>>>>> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>>>>
>>>>> dmesg showing bad pitch 12800 for Y210 pixel format
>>>>>
>>>>> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
>>>>> [  634.104444] [IGT] kms_plane: exiting, ret=99
>>>>>
>>>>> Can you please confirm whether changes needs to be done from igt or some issue with Y2xx driver patches?
>>>>>
>>>>>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>>>>>>         }
>>>>>>     }
>>>>>>     +
>>>>>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>>>>>> +{
>>>>>> +    int i, j;
>>>>>> +    const uint16_t *yuyv;
>>>>>> +    uint16_t *buf;
>>>>>> +    float *ptr = cvt->dst.ptr;
>>>>>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
>>>>>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
>>>>>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>>>>>> +                            cvt->dst.fb->drm_format,
>>>>>> +                            cvt->src.fb->color_encoding,
>>>>>> +                            cvt->src.fb->color_range);
>>>>>> +
>>>>>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>>>>>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>>>>>> +
>>>>>> +    yuyv = buf = convert_src_get(cvt);
>>>>>> +
>>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>>> +            /* Convert 2x1 pixel blocks */
>>>>>> +            struct igt_vec4 yuv[2];
>>>>>> +            struct igt_vec4 rgb[2];
>>>>>> +
>>>>>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>>>>>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>>>>>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>>>>>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>>>>>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>>>>>> +
>>>>>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>>>>>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>>>>>> +
>>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>>>>>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>>>>>> +        }
>>>>>> +
>>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>>> +            struct igt_vec4 yuv;
>>>>>> +            struct igt_vec4 rgb;
>>>>>> +
>>>>>> +            yuv.d[0] = yuyv[j * 4 + 0];
>>>>>> +            yuv.d[1] = yuyv[j * 4 + 1];
>>>>>> +            yuv.d[2] = yuyv[j * 4 + 3];
>>>>>> +            yuv.d[3] = 1.0f;
>>>>>> +
>>>>>> +            rgb = igt_matrix_transform(&m, &yuv);
>>>>>> +
>>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>>>>>> +        }
>>>>>> +
>>>>>> +        ptr += float_stride;
>>>>>> +        yuyv += yuyv_stride;
>>>>>> +    }
>>>>>> +
>>>>>> +    convert_src_put(cvt, buf);
>>>>>> +}
>>>>>> +
>>>>>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>>>>>> +{
>>>>>> +    int i, j;
>>>>>> +    uint16_t *yuyv = cvt->dst.ptr;
>>>>>> +    const float *ptr = cvt->src.ptr;
>>>>>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>>>>>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>>>>>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>>>>>> +                            cvt->dst.fb->drm_format,
>>>>>> +                            cvt->dst.fb->color_encoding,
>>>>>> +                            cvt->dst.fb->color_range);
>>>>>> +
>>>>>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>>>>>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>>>>>> +
>>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>>> +            /* Convert 2x1 pixel blocks */
>>>>>> +            struct igt_vec4 rgb[2];
>>>>>> +            struct igt_vec4 yuv[2];
>>>>>> +
>>>>>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>>>>>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>>>>>> +
>>>>>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>>>>>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>>>>>> +
>>>>>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>>>>>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>>>>>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>>>>>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>>>>>> +        }
>>>>>> +
>>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>>> +            struct igt_vec4 rgb;
>>>>>> +            struct igt_vec4 yuv;
>>>>>> +
>>>>>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>>>>>> +
>>>>>> +            yuv = igt_matrix_transform(&m, &rgb);
>>>>>> +
>>>>>> +            yuyv[j * 4 + 0] = yuv.d[0];
>>>>>> +            yuyv[j * 4 + 1] = yuv.d[1];
>>>>>> +            yuyv[j * 4 + 3] = yuv.d[2];
>>>>>> +        }
>>>>>> +
>>>>>> +        ptr += float_stride;
>>>>>> +        yuyv += yuyv_stride;
>>>>>> +    }
>>>>>> +}
>>>>>> +
>>>>>>     static void convert_pixman(struct fb_convert *cvt)
>>>>>>     {
>>>>>>         pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>>>>>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>>             case DRM_FORMAT_P016:
>>>>>>                 convert_p01X_to_float(cvt);
>>>>>>                 return;
>>>>>> +        case DRM_FORMAT_Y210:
>>>>>> +        case DRM_FORMAT_Y212:
>>>>>> +        case DRM_FORMAT_Y216:
>>>>>> +            convert_Y21X_to_float(cvt);
>>>>>> +            return;
>>>>>>             }
>>>>>>         } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>>>>>             switch (cvt->dst.fb->drm_format) {
>>>>>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>>             case DRM_FORMAT_P016:
>>>>>>                 convert_float_to_p01X(cvt);
>>>>>>                 return;
>>>>>> +        case DRM_FORMAT_Y210:
>>>>>> +        case DRM_FORMAT_Y212:
>>>>>> +        case DRM_FORMAT_Y216:
>>>>>> +            convert_float_to_Y21X(cvt);
>>>>>> +            return;
>>>>>>             }
>>>>>>         }
>>>>>>     @@ -2583,6 +2726,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:
>>>> Can I get the full IGT / dmesg logs? I can't see what the fb dimensions they are.
>>> IGT Logs:
>>>
>>> (kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
>>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, height=1800, format=0x30313259, tiling=0x0, size=0)
>>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, pitch=12800)
>>> (kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: igt_has_fb_modifiers(fd)
>>> (kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>> (kms_plane:4960) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>>> (kms_plane:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>> (kms_plane:4960) igt_core-INFO: Stack trace:
>>> (kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 __igt_fail_assert()
>>> (kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 igt_create_fb_with_bo_size()
>>> (kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
>>> (kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 igt_create_color_fb()
>>> (kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 test_format_plane_color()
>>> (kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 test_format_plane()
>>> (kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 test_pixel_formats()
>>> (kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 run_tests_for_pipe_plane()
>>> (kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 __real_main642()
>>> (kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
>>> (kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 __libc_start_main()
>>> (kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
>>> (kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
>>> ****  END  ****
>>>
>>> Dmesg Logs: Attached y210_dmesg_failure.txt
>>>
>> Same failure exists for all the Y2xx formats Y210/Y212/Y216.
> Seems like a bug with your format definition in the kernel?
>
> Y210 is Y0 U Y1 V, for a total of 64 bits per 2 Y pixels.
>
> pitch is set to 12800 / 4 = 3200. This is exactly the minimum, so should pass..
>
> I'll have to rebase the IGT patches, but as far as I can tell they're correct, and you have a bug in your implementation. :)
>
> ~Maarten

Hi Maarten,

You were correct :) Issue was with my kernel patch, I had written wrong 
fourcc for Y2xx. ThankYou!
Though for planes >=3 (sdr planes), we are getting CRC mismatch for all 
YUV formats, happening same for Y2xx but I think it is tracked in bugzilla.

Thanks :)

~Swati
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well.
  2019-02-07  6:23             ` Sharma, Swati2
@ 2019-02-07  8:15               ` Maarten Lankhorst
  0 siblings, 0 replies; 21+ messages in thread
From: Maarten Lankhorst @ 2019-02-07  8:15 UTC (permalink / raw)
  To: Sharma, Swati2, igt-dev

Op 07-02-2019 om 07:23 schreef Sharma, Swati2:
>
> On 06-Feb-19 8:35 PM, Maarten Lankhorst wrote:
>> Op 06-02-2019 om 15:21 schreef Sharma, Swati2:
>>> On 06-Feb-19 12:17 PM, Sharma, Swati2 wrote:
>>>
>>>> On 05-Feb-19 8:01 PM, Maarten Lankhorst wrote:
>>>>> Op 05-02-2019 om 14:14 schreef Sharma, Swati2:
>>>>>> On 01-Feb-19 4:45 PM, Maarten Lankhorst wrote:
>>>>>>> Those formats are packed like YUYV, but only 16 bits per component.
>>>>>>>
>>>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>>>>> ---
>>>>>>>     include/drm-uapi/drm_fourcc.h |   6 +-
>>>>>>>     lib/igt_color_encoding.c      |   3 +
>>>>>>>     lib/igt_fb.c                  | 146 ++++++++++++++++++++++++++++++++++
>>>>>>>     3 files changed, 154 insertions(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/include/drm-uapi/drm_fourcc.h b/include/drm-uapi/drm_fourcc.h
>>>>>>> index c9a5e5787031..8f1b5f832a09 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 8bd0420fc2e4..c14cc10d1b73 100644
>>>>>>> --- a/lib/igt_fb.c
>>>>>>> +++ b/lib/igt_fb.c
>>>>>>> @@ -151,6 +151,18 @@ static const struct format_desc_struct {
>>>>>>>           .cairo_id = CAIRO_FORMAT_RGB24,
>>>>>>>           .num_planes = 1, .plane_bpp = { 16, },
>>>>>>>         },
>>>>>>> +    { .name = "Y210", .depth = -1, .drm_id = DRM_FORMAT_Y210,
>>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>>> +    },
>>>>>>> +    { .name = "Y212", .depth = -1, .drm_id = DRM_FORMAT_Y212,
>>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>>> +    },
>>>>>>> +    { .name = "Y216", .depth = -1, .drm_id = DRM_FORMAT_Y216,
>>>>>>> +      .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>>> +      .num_planes = 1, .plane_bpp = { 32, },
>>>>>>> +    },
>>>>>>>         { .name = "P010", .depth = -1, .drm_id = DRM_FORMAT_P010,
>>>>>>>           .cairo_id = CAIRO_FORMAT_RGB96F,
>>>>>>>           .num_planes = 2, .plane_bpp = { 16, 32 },
>>>>>>> @@ -553,6 +565,13 @@ static int create_bo_for_fb(struct igt_fb *fb)
>>>>>>>                         fb->offsets[1] / sizeof(wchar_t));
>>>>>>>                     wmemset(ptr + fb->offsets[1], 0x80008000,
>>>>>>>                         DIV_ROUND_UP(fb->height,2) * fb->strides[1] / sizeof(wchar_t));
>>>>>>> +            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;
>>>>>>>                 }
>>>>>>>                 gem_munmap(ptr, fb->size);
>>>>>> Hi Maarten,
>>>>>>
>>>>>> While testing Y210 pixel format, IGT is failing with debug message showing igt_create_fb() failure
>>>>>>
>>>>>> (kms_plane:3974) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>>>>> (kms_plane:3974) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>>>>>> (kms_plane:3974) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>>>>>
>>>>>> dmesg showing bad pitch 12800 for Y210 pixel format
>>>>>>
>>>>>> [  634.066608] [drm:drm_internal_framebuffer_create] bad pitch 12800 for plane 0
>>>>>> [  634.104444] [IGT] kms_plane: exiting, ret=99
>>>>>>
>>>>>> Can you please confirm whether changes needs to be done from igt or some issue with Y2xx driver patches?
>>>>>>
>>>>>>> @@ -2139,6 +2158,120 @@ static void convert_float_to_p01X(struct fb_convert *cvt)
>>>>>>>         }
>>>>>>>     }
>>>>>>>     +
>>>>>>> +static void convert_Y21X_to_float(struct fb_convert *cvt)
>>>>>>> +{
>>>>>>> +    int i, j;
>>>>>>> +    const uint16_t *yuyv;
>>>>>>> +    uint16_t *buf;
>>>>>>> +    float *ptr = cvt->dst.ptr;
>>>>>>> +    unsigned int float_stride = cvt->dst.fb->strides[0] / sizeof(*ptr);
>>>>>>> +    unsigned int yuyv_stride = cvt->src.fb->strides[0] / sizeof(*yuyv);
>>>>>>> +    struct igt_mat4 m = igt_ycbcr_to_rgb_matrix(cvt->src.fb->drm_format,
>>>>>>> +                            cvt->dst.fb->drm_format,
>>>>>>> +                            cvt->src.fb->color_encoding,
>>>>>>> +                            cvt->src.fb->color_range);
>>>>>>> +
>>>>>>> +    igt_assert((cvt->src.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>>>> +            cvt->src.fb->drm_format == DRM_FORMAT_Y216) &&
>>>>>>> +           cvt->dst.fb->drm_format == IGT_FORMAT_FLOAT);
>>>>>>> +
>>>>>>> +    yuyv = buf = convert_src_get(cvt);
>>>>>>> +
>>>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>>>> +            /* Convert 2x1 pixel blocks */
>>>>>>> +            struct igt_vec4 yuv[2];
>>>>>>> +            struct igt_vec4 rgb[2];
>>>>>>> +
>>>>>>> +            yuv[0].d[0] = yuyv[j * 4 + 0];
>>>>>>> +            yuv[1].d[0] = yuyv[j * 4 + 2];
>>>>>>> +            yuv[0].d[1] = yuv[1].d[1] = yuyv[j * 4 + 1];
>>>>>>> +            yuv[0].d[2] = yuv[1].d[2] = yuyv[j * 4 + 3];
>>>>>>> +            yuv[0].d[3] = yuv[1].d[3] = 1.0f;
>>>>>>> +
>>>>>>> +            rgb[0] = igt_matrix_transform(&m, &yuv[0]);
>>>>>>> +            rgb[1] = igt_matrix_transform(&m, &yuv[1]);
>>>>>>> +
>>>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb[0]);
>>>>>>> +            write_rgbf(&ptr[j * 6 + 3], &rgb[1]);
>>>>>>> +        }
>>>>>>> +
>>>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>>>> +            struct igt_vec4 yuv;
>>>>>>> +            struct igt_vec4 rgb;
>>>>>>> +
>>>>>>> +            yuv.d[0] = yuyv[j * 4 + 0];
>>>>>>> +            yuv.d[1] = yuyv[j * 4 + 1];
>>>>>>> +            yuv.d[2] = yuyv[j * 4 + 3];
>>>>>>> +            yuv.d[3] = 1.0f;
>>>>>>> +
>>>>>>> +            rgb = igt_matrix_transform(&m, &yuv);
>>>>>>> +
>>>>>>> +            write_rgbf(&ptr[j * 6 + 0], &rgb);
>>>>>>> +        }
>>>>>>> +
>>>>>>> +        ptr += float_stride;
>>>>>>> +        yuyv += yuyv_stride;
>>>>>>> +    }
>>>>>>> +
>>>>>>> +    convert_src_put(cvt, buf);
>>>>>>> +}
>>>>>>> +
>>>>>>> +static void convert_float_to_Y21X(struct fb_convert *cvt)
>>>>>>> +{
>>>>>>> +    int i, j;
>>>>>>> +    uint16_t *yuyv = cvt->dst.ptr;
>>>>>>> +    const float *ptr = cvt->src.ptr;
>>>>>>> +    unsigned float_stride = cvt->src.fb->strides[0] / sizeof(*ptr);
>>>>>>> +    unsigned yuyv_stride = cvt->dst.fb->strides[0] / sizeof(*yuyv);
>>>>>>> +    struct igt_mat4 m = igt_rgb_to_ycbcr_matrix(cvt->src.fb->drm_format,
>>>>>>> +                            cvt->dst.fb->drm_format,
>>>>>>> +                            cvt->dst.fb->color_encoding,
>>>>>>> +                            cvt->dst.fb->color_range);
>>>>>>> +
>>>>>>> +    igt_assert(cvt->src.fb->drm_format == IGT_FORMAT_FLOAT &&
>>>>>>> +           (cvt->dst.fb->drm_format == DRM_FORMAT_Y210 ||
>>>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y212 ||
>>>>>>> +            cvt->dst.fb->drm_format == DRM_FORMAT_Y216));
>>>>>>> +
>>>>>>> +    for (i = 0; i < cvt->dst.fb->height; i++) {
>>>>>>> +        for (j = 0; j < cvt->dst.fb->width / 2; j++) {
>>>>>>> +            /* Convert 2x1 pixel blocks */
>>>>>>> +            struct igt_vec4 rgb[2];
>>>>>>> +            struct igt_vec4 yuv[2];
>>>>>>> +
>>>>>>> +            read_rgbf(&rgb[0], &ptr[j * 6 + 0]);
>>>>>>> +            read_rgbf(&rgb[1], &ptr[j * 6 + 3]);
>>>>>>> +
>>>>>>> +            yuv[0] = igt_matrix_transform(&m, &rgb[0]);
>>>>>>> +            yuv[1] = igt_matrix_transform(&m, &rgb[1]);
>>>>>>> +
>>>>>>> +            yuyv[j * 4 + 0] = yuv[0].d[0];
>>>>>>> +            yuyv[j * 4 + 2] = yuv[1].d[0];
>>>>>>> +            yuyv[j * 4 + 1] = (yuv[0].d[1] + yuv[1].d[1]) / 2.0f;
>>>>>>> +            yuyv[j * 4 + 3] = (yuv[0].d[2] + yuv[1].d[2]) / 2.0f;
>>>>>>> +        }
>>>>>>> +
>>>>>>> +        if (cvt->dst.fb->width & 1) {
>>>>>>> +            struct igt_vec4 rgb;
>>>>>>> +            struct igt_vec4 yuv;
>>>>>>> +
>>>>>>> +            read_rgbf(&rgb, &ptr[j * 6 + 0]);
>>>>>>> +
>>>>>>> +            yuv = igt_matrix_transform(&m, &rgb);
>>>>>>> +
>>>>>>> +            yuyv[j * 4 + 0] = yuv.d[0];
>>>>>>> +            yuyv[j * 4 + 1] = yuv.d[1];
>>>>>>> +            yuyv[j * 4 + 3] = yuv.d[2];
>>>>>>> +        }
>>>>>>> +
>>>>>>> +        ptr += float_stride;
>>>>>>> +        yuyv += yuyv_stride;
>>>>>>> +    }
>>>>>>> +}
>>>>>>> +
>>>>>>>     static void convert_pixman(struct fb_convert *cvt)
>>>>>>>     {
>>>>>>>         pixman_format_code_t src_pixman = drm_format_to_pixman(cvt->src.fb->drm_format);
>>>>>>> @@ -2221,6 +2354,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>>>             case DRM_FORMAT_P016:
>>>>>>>                 convert_p01X_to_float(cvt);
>>>>>>>                 return;
>>>>>>> +        case DRM_FORMAT_Y210:
>>>>>>> +        case DRM_FORMAT_Y212:
>>>>>>> +        case DRM_FORMAT_Y216:
>>>>>>> +            convert_Y21X_to_float(cvt);
>>>>>>> +            return;
>>>>>>>             }
>>>>>>>         } else if (cvt->src.fb->drm_format == IGT_FORMAT_FLOAT) {
>>>>>>>             switch (cvt->dst.fb->drm_format) {
>>>>>>> @@ -2229,6 +2367,11 @@ static void fb_convert(struct fb_convert *cvt)
>>>>>>>             case DRM_FORMAT_P016:
>>>>>>>                 convert_float_to_p01X(cvt);
>>>>>>>                 return;
>>>>>>> +        case DRM_FORMAT_Y210:
>>>>>>> +        case DRM_FORMAT_Y212:
>>>>>>> +        case DRM_FORMAT_Y216:
>>>>>>> +            convert_float_to_Y21X(cvt);
>>>>>>> +            return;
>>>>>>>             }
>>>>>>>         }
>>>>>>>     @@ -2583,6 +2726,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:
>>>>> Can I get the full IGT / dmesg logs? I can't see what the fb dimensions they are.
>>>> IGT Logs:
>>>>
>>>> (kms_plane:4960) INFO: Testing format Y210 (0x30313259) on A.0
>>>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(width=3200, height=1800, format=0x30313259, tiling=0x0, size=0)
>>>> (kms_plane:4960) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, pitch=12800)
>>>> (kms_plane:4960) ioctl_wrappers-DEBUG: Test requirement passed: igt_has_fb_modifiers(fd)
>>>> (kms_plane:4960) igt_fb-CRITICAL: Test assertion failure function igt_create_fb_with_bo_size, file ../lib/igt_fb.c:1051:
>>>> (kms_plane:4960) igt_fb-CRITICAL: Failed assertion: (__kms_addfb(fb->fd, fb->gem_handle, fb->width, fb->height, fb->drm_format, fb->tiling, fb->strides, fb->offsets, fb->num_planes, flags, &fb->fb_id)) == 0
>>>> (kms_plane:4960) igt_fb-CRITICAL: Last errno: 22, Invalid argument
>>>> (kms_plane:4960) igt_core-INFO: Stack trace:
>>>> (kms_plane:4960) igt_core-INFO:   #0 ../lib/igt_core.c:1474 __igt_fail_assert()
>>>> (kms_plane:4960) igt_core-INFO:   #1 ../lib/igt_fb.c:1053 igt_create_fb_with_bo_size()
>>>> (kms_plane:4960) igt_core-INFO:   #2 ../lib/igt_fb.c:1078 igt_create_fb()
>>>> (kms_plane:4960) igt_core-INFO:   #3 ../lib/igt_fb.c:1113 igt_create_color_fb()
>>>> (kms_plane:4960) igt_core-INFO:   #4 ../tests/kms_plane.c:417 test_format_plane_color()
>>>> (kms_plane:4960) igt_core-INFO:   #5 ../tests/kms_plane.c:556 test_format_plane()
>>>> (kms_plane:4960) igt_core-INFO:   #6 ../tests/kms_plane.c:587 test_pixel_formats()
>>>> (kms_plane:4960) igt_core-INFO:   #7 ../tests/kms_plane.c:602 run_tests_for_pipe_plane()
>>>> (kms_plane:4960) igt_core-INFO:   #8 ../tests/kms_plane.c:657 __real_main642()
>>>> (kms_plane:4960) igt_core-INFO:   #9 ../tests/kms_plane.c:642 main()
>>>> (kms_plane:4960) igt_core-INFO:   #10 ../csu/libc-start.c:325 __libc_start_main()
>>>> (kms_plane:4960) igt_core-INFO:   #11 [_start+0x29]
>>>> (kms_plane:4960) igt_core-INFO:   #12 [<unknown>+0x0]
>>>> ****  END  ****
>>>>
>>>> Dmesg Logs: Attached y210_dmesg_failure.txt
>>>>
>>> Same failure exists for all the Y2xx formats Y210/Y212/Y216.
>> Seems like a bug with your format definition in the kernel?
>>
>> Y210 is Y0 U Y1 V, for a total of 64 bits per 2 Y pixels.
>>
>> pitch is set to 12800 / 4 = 3200. This is exactly the minimum, so should pass..
>>
>> I'll have to rebase the IGT patches, but as far as I can tell they're correct, and you have a bug in your implementation. :)
>>
>> ~Maarten
>
> Hi Maarten,
>
> You were correct :) Issue was with my kernel patch, I had written wrong fourcc for Y2xx. ThankYou!
> Though for planes >=3 (sdr planes), we are getting CRC mismatch for all YUV formats, happening same for Y2xx but I think it is tracked in bugzilla. 

I've noticed there is a CRC mismatch when comparing the same NV12 config in SDR + plane scaler and HDR with chroma upsampler. Might be the same for HDR vs SDR planes in general.

~Maarten

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

end of thread, other threads:[~2019-02-07  8:15 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-01 11:15 [igt-dev] [PATCH i-g-t 1/4] lib/color_encoding: Prepare support for HDR modes Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Maarten Lankhorst
2019-02-04 12:46   ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v2 Maarten Lankhorst
2019-02-04 14:09     ` Sharma, Swati2
2019-02-04 14:49       ` Maarten Lankhorst
2019-02-05 15:08       ` [igt-dev] [PATCH i-g-t] lib/igt_fb: Add support for P01x formats, v3 Maarten Lankhorst
2019-02-04 13:22   ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_fb: Add support for P01x formats Sharma, Swati2
2019-02-04 17:06     ` Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_fb: Add support for Y21x formats as well Maarten Lankhorst
2019-02-05 13:14   ` Sharma, Swati2
2019-02-05 14:31     ` Maarten Lankhorst
2019-02-06  6:47       ` Sharma, Swati2
2019-02-06 14:21         ` Sharma, Swati2
2019-02-06 15:05           ` Maarten Lankhorst
2019-02-07  6:23             ` Sharma, Swati2
2019-02-07  8:15               ` Maarten Lankhorst
2019-02-01 11:15 ` [igt-dev] [PATCH i-g-t 4/4] lib/igt_fb: Add support for Y410/Y416 formats Maarten Lankhorst
2019-02-06 14:26   ` Sharma, Swati2
2019-02-01 11:37 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes Patchwork
2019-02-04 13:17 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev2) Patchwork
2019-02-05 15:19 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/4] lib/color_encoding: Prepare support for HDR modes. (rev3) Patchwork

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.