Skip to contentSkip to conversation

tests/kms_color: Add 10-bit color depth support to gamma test for MediaTek

PATCH Superseded Jay Liu 2 participants 3 messages Apr 13

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Jay Liu

author
#0 lore raw

PATCH v2 1/1 tests/kms_color: Add 10-bit color depth support to gamma test for MediaTek

1. Add 10-bit color depth flow to gamma test for MediaTek devices, which only support bit-true results with 10-bit data. The test now selects 8-bit or 10-bit color depth and framebuffer format based on device type.

2. To satisfy the legacy gamma test requirements, the MTK Gamma LUT limit should be set to 4092, in the current 16-bit LUT design, setting the entry to 0xffd0 ensures the driver maps it correctly to 4092.

---
 tests/kms_color.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
tests/kms_color.c +27 -8
index 565edb2dc..033207368 100644
@@ -288,7 +288,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	fb_id = igt_create_fb(data->drm_fd,
 			      mode->hdisplay,
 			      mode->vdisplay,
-			      DRM_FORMAT_XRGB8888,
+			      data->drm_format,
 			      DRM_FORMAT_MOD_LINEAR,
 			      &fb);
 	igt_assert(fb_id);
@@ -296,7 +296,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
-				      DRM_FORMAT_XRGB8888,
+				      data->drm_format,
 				      DRM_FORMAT_MOD_LINEAR,
 				      &fb_modeset);
 	igt_assert(fb_modeset_id);
@@ -322,9 +322,20 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	igt_plane_set_fb(primary, &fb);
 
 	red_lut[0] = green_lut[0] = blue_lut[0] = 0;
-	for (i = 1; i < legacy_lut_size; i++)
-		red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
-	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->crtc->crtc_id,
+	for (i = 1; i < legacy_lut_size; i++) {
+		/*
+		 * The Medaitek Gamma LUT maps 10bit input data to 12bit output.
+		 * In this test case, the maximum input value is 1023.
+		 * When the Gamma function is disabled, the data defaults to a 4092 output.
+		 * To achieve bit true results, the Gamma LUT maximum must be set to 4092.
+		 * Note that 0xFFFD0 represents 16-bit,which maps to 4092 in 12-bit depth.
+		 */
+		if (is_mtk_device(data->drm_fd))
+			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffd0;
+		else
+			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
+	}
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
 					  legacy_lut_size, red_lut, green_lut, blue_lut), 0);
 	igt_display_commit(&data->display);
 	igt_wait_for_vblank(primary->crtc);
@@ -752,14 +763,22 @@ static void
 run_gamma_degamma_tests_for_crtc(data_t *data, igt_crtc_t *crtc,
 				 bool (*test_t)(data_t*, igt_plane_t*))
 {
+	bool is_mtk = false;
+
 	test_setup(data, crtc);
 
+	/* MediaTek requires 10-bit pipeline for accurate (bit true) color processing */
+	if (is_mtk_device(data->drm_fd))
+		is_mtk = true;
+
 	/*
-	 * We assume an 8bits depth per color for degamma/gamma LUTs
+	 * We assume an 8bits or 10bits depth per color for degamma/gamma LUTs
 	 * for CRC checks with framebuffer references.
 	 */
-	data->color_depth = 8;
-	data->drm_format = DRM_FORMAT_XRGB8888;
+
+	/* MediaTek requires 10-bit pipeline for accurate (bit true) color processing */
+	data->color_depth = is_mtk ? 10 : 8;
+	data->drm_format = is_mtk ? DRM_FORMAT_XRGB2101010 : DRM_FORMAT_XRGB8888;
 	data->mode = igt_output_get_mode(data->output);
 
 	igt_require(crtc_output_combo_valid(data, crtc));
Signature · 1 line
2.46.0
#1 lore raw
Quoted 47 lines · Jay Liu

1. Add 10-bit color depth flow to gamma test for MediaTek devices, which only support bit-true results with 10-bit data. The test now selects 8-bit or 10-bit color depth and framebuffer format based on device type.

2. To satisfy the legacy gamma test requirements, the MTK Gamma LUT limit should be set to 4092, in the current 16-bit LUT design, setting the entry to 0xffd0 ensures the driver maps it correctly to 4092.

---
 tests/kms_color.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
tests/kms_color.c +7 -5
index 565edb2dc..033207368 100644
@@ -288,7 +288,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	fb_id = igt_create_fb(data->drm_fd,
 			      mode->hdisplay,
 			      mode->vdisplay,
-			      DRM_FORMAT_XRGB8888,
+			      data->drm_format,
 			      DRM_FORMAT_MOD_LINEAR,
 			      &fb);
 	igt_assert(fb_id);
@@ -296,7 +296,7 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
-				      DRM_FORMAT_XRGB8888,
+				      data->drm_format,
 				      DRM_FORMAT_MOD_LINEAR,
 				      &fb_modeset);
 	igt_assert(fb_modeset_id);
@@ -322,9 +322,20 @@ static bool test_pipe_legacy_gamma(data_t *data,
 	igt_plane_set_fb(primary, &fb);
 
 	red_lut[0] = green_lut[0] = blue_lut[0] = 0;
-	for (i = 1; i < legacy_lut_size; i++)
-		red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
-	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->crtc->crtc_id,
+	for (i = 1; i < legacy_lut_size; i++) {
+		/*
+		 * The Medaitek Gamma LUT maps 10bit input data to 12bit output.
+		 * In this test case, the maximum input value is 1023.
+		 * When the Gamma function is disabled, the data defaults to a 4092 output.

tests/kms_color.c static bool test_pipe_legacy_gamma(data_t *data, · line 339

Quoted 10 lines
tests/kms_color.c +9 -0
+		 * To achieve bit true results, the Gamma LUT maximum must be set to 4092.
+		 * Note that 0xFFFD0 represents 16-bit,which maps to 4092 in 12-bit depth.
+		 */
+		if (is_mtk_device(data->drm_fd))
+			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffd0;
+		else
+			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
+	}
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
 					  legacy_lut_size, red_lut, green_lut, blue_lut), 0);

This does not compile.

Quoted 28 lines
tests/kms_color.c +11 -3
 	igt_display_commit(&data->display);
 	igt_wait_for_vblank(primary->crtc);
@@ -752,14 +763,22 @@ static void
 run_gamma_degamma_tests_for_crtc(data_t *data, igt_crtc_t *crtc,
 				 bool (*test_t)(data_t*, igt_plane_t*))
 {
+	bool is_mtk = false;
+
 	test_setup(data, crtc);
 
+	/* MediaTek requires 10-bit pipeline for accurate (bit true) color processing */
+	if (is_mtk_device(data->drm_fd))
+		is_mtk = true;
+
 	/*
-	 * We assume an 8bits depth per color for degamma/gamma LUTs
+	 * We assume an 8bits or 10bits depth per color for degamma/gamma LUTs
 	 * for CRC checks with framebuffer references.
 	 */
-	data->color_depth = 8;
-	data->drm_format = DRM_FORMAT_XRGB8888;
+
+	/* MediaTek requires 10-bit pipeline for accurate (bit true) color processing */
+	data->color_depth = is_mtk ? 10 : 8;
+	data->drm_format = is_mtk ? DRM_FORMAT_XRGB2101010 : DRM_FORMAT_XRGB8888;
 	data->mode = igt_output_get_mode(data->output);
 
 	igt_require(crtc_output_combo_valid(data, crtc));
Signature · 1 line
Jani Nikula, Intel
#2 lore raw
Quoted 71 lines · Jani Nikula
Quoted 70 lines · Jay Liu

1. Add 10-bit color depth flow to gamma test for MediaTek devices, which only
support bit-true results with 10-bit data. The test now selects 8- bit or
10-bit color depth and framebuffer format based on device type.

2. To satisfy the legacy gamma test requirements, the MTK Gamma LUT limit
should be set to 4092, in the current 16-bit LUT design, setting the entry
to 0xffd0 ensures the driver maps it correctly to 4092.

---
 tests/kms_color.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
tests/kms_color.c +1 -1
index 565edb2dc..033207368 100644
@@ -288,7 +288,7 @@ static bool test_pipe_legacy_gamma(data_t
 *data,
 	fb_id = igt_create_fb(data->drm_fd,
 			      mode->hdisplay,
 			      mode->vdisplay,
-			      DRM_FORMAT_XRGB8888,
+			      data->drm_format,
 			      DRM_FORMAT_MOD_LINEAR,
 			      &fb);
tests/kms_color.c +1 -1
 	igt_assert(fb_id);
@@ -296,7 +296,7 @@ static bool test_pipe_legacy_gamma(data_t
 *data,
 	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
-				      DRM_FORMAT_XRGB8888,
+				      data->drm_format,
 				      DRM_FORMAT_MOD_LINEAR,
 				      &fb_modeset);
tests/kms_color.c +3 -3
 	igt_assert(fb_modeset_id);
@@ -322,9 +322,20 @@ static bool test_pipe_legacy_gamma(data_t
 *data,
 	igt_plane_set_fb(primary, &fb);
 
 	red_lut[0] = green_lut[0] = blue_lut[0] = 0;
-	for (i = 1; i < legacy_lut_size; i++)
-		red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
-	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->crtc-
 >crtc_id,
+	for (i = 1; i < legacy_lut_size; i++) {
+		/*
+		 * The Medaitek Gamma LUT maps 10bit input data to

12bit output.

tests/kms_color.c +2 -0
+		 * In this test case, the maximum input value is 1023.
+		 * When the Gamma function is disabled, the data

defaults to a 4092 output.

tests/kms_color.c +1 -0
+		 * To achieve bit true results, the Gamma LUT maximum

must be set to 4092.

tests/kms_color.c +1 -0
+		 * Note that 0xFFFD0 represents 16-bit,which maps to

4092 in 12-bit depth.

tests/kms_color.c +3 -0
+		 */
+		if (is_mtk_device(data->drm_fd))
+			red_lut[i] = green_lut[i] = blue_lut[i] =

0xffd0;

tests/kms_color.c +2 -0
+		else
+			red_lut[i] = green_lut[i] = blue_lut[i] =

0xffff;

tests/kms_color.c +2 -0
+	}
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe-
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

crtc_id,

legacy_lut_size, red_lut,
green_lut, blue_lut), 0);

This does not compile.

I am very sorry about this. I will fix this issue in the next version and be extra careful with the verification to ensure no additional bugs are introduced

Quoted 35 lines
Quoted 33 lines
tests/kms_color.c +3 -0
 	igt_display_commit(&data->display);
 	igt_wait_for_vblank(primary->crtc);
@@ -752,14 +763,22 @@ static void
 run_gamma_degamma_tests_for_crtc(data_t *data, igt_crtc_t *crtc,
 				 bool (*test_t)(data_t*, igt_plane_t*))
 {
+	bool is_mtk = false;
+
 	test_setup(data, crtc);
 
+	/* MediaTek requires 10-bit pipeline for accurate (bit true)

color processing */

tests/kms_color.c +4 -1
+	if (is_mtk_device(data->drm_fd))
+		is_mtk = true;
+
 	/*
-	 * We assume an 8bits depth per color for degamma/gamma LUTs
+	 * We assume an 8bits or 10bits depth per color for

degamma/gamma LUTs

tests/kms_color.c +2 -2
 	 * for CRC checks with framebuffer references.
 	 */
-	data->color_depth = 8;
-	data->drm_format = DRM_FORMAT_XRGB8888;
+
+	/* MediaTek requires 10-bit pipeline for accurate (bit true)

color processing */

tests/kms_color.c +2 -0
+	data->color_depth = is_mtk ? 10 : 8;
+	data->drm_format = is_mtk ? DRM_FORMAT_XRGB2101010 :

DRM_FORMAT_XRGB8888;

tests/kms_color.c +0 -0
 	data->mode = igt_output_get_mode(data->output);
 
 	igt_require(crtc_output_combo_valid(data, crtc));