All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties
@ 2021-06-03 12:20 venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 02/24] kms_color_helper: Add helper functions for plane color mgmt venkata.sai.patnana
                   ` (19 more replies)
  0 siblings, 20 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Add support for Plane color management properties.

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
(cherry picked from commit 51099f0939ca28f15fdd99143ca38e0fc52e38fe)
---
 lib/igt_kms.c | 5 +++++
 lib/igt_kms.h | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c7c69b6ea0..ae183e822c 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -581,6 +581,11 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
 	[IGT_PLANE_ALPHA] = "alpha",
 	[IGT_PLANE_ZPOS] = "zpos",
 	[IGT_PLANE_FB_DAMAGE_CLIPS] = "FB_DAMAGE_CLIPS",
+	[IGT_PLANE_CTM] = "PLANE_CTM",
+	[IGT_PLANE_GAMMA_MODE] = "PLANE_GAMMA_MODE",
+	[IGT_PLANE_GAMMA_LUT] = "PLANE_GAMMA_LUT",
+	[IGT_PLANE_DEGAMMA_MODE] = "PLANE_DEGAMMA_MODE",
+	[IGT_PLANE_DEGAMMA_LUT] = "PLANE_DEGAMMA_LUT",
 };
 
 const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 8cde24b791..41967bf28a 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -301,6 +301,11 @@ enum igt_atomic_plane_properties {
        IGT_PLANE_ALPHA,
        IGT_PLANE_ZPOS,
        IGT_PLANE_FB_DAMAGE_CLIPS,
+       IGT_PLANE_CTM,
+       IGT_PLANE_GAMMA_MODE,
+       IGT_PLANE_GAMMA_LUT,
+       IGT_PLANE_DEGAMMA_MODE,
+       IGT_PLANE_DEGAMMA_LUT,
        IGT_NUM_PLANE_PROPS
 };
 
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 02/24] kms_color_helper: Add helper functions for plane color mgmt
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 03/24] tests/kms_color: New subtests for Plane gamma venkata.sai.patnana
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Add helper functions to support Plane color management properties.

v2:
* Fix LUT size calculation logic (Bhanu)
v3:
* Remove redundant checks & drop unnecessary temp variables (Uma)
* Fix the hardcoded precision data (Bhanu)
* Fix the LUT creation logic by obtaining segment data (Uma)
* Restructure the helper functions to update plane props (Uma)
v4:
* Restructure to manage the memory (alloc & free) by the caller (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
(cherry picked from commit 1141c39fcffffec054315791fe2481a66522820a)
---
 tests/kms_color_helper.c | 144 +++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.h |  25 +++++++
 2 files changed, 169 insertions(+)

diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 5f223a8812..a14a97999e 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -232,6 +232,150 @@ void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)
 		igt_pipe_obj_replace_prop_blob(pipe, prop, NULL, 0);
 }
 
+drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane,
+				enum igt_atomic_plane_properties prop)
+{
+	igt_display_t *display = plane->pipe->display;
+	uint32_t prop_id = plane->props[prop];
+	drmModePropertyPtr drmProp;
+
+	igt_assert(prop_id);
+
+	drmProp = drmModeGetProperty(display->drm_fd, prop_id);
+
+	igt_assert(drmProp);
+	igt_assert(drmProp->count_enums);
+
+	return drmProp;
+}
+
+struct drm_color_lut_ext *create_linear_lut(segment_data_t *info)
+{
+	uint32_t val, segment, entry, index = 0;
+	uint32_t max_val = 0xffffffff;
+	struct drm_color_lut_ext *lut = malloc(sizeof(struct drm_color_lut_ext) * info->entries_count);
+	igt_assert(lut);
+
+	for (segment = 0; segment < info->segment_count; segment++) {
+		uint32_t entry_count = info->segment_data[segment].count;
+		uint32_t start = info->segment_data[segment].start;
+		uint32_t end = info->segment_data[segment].end;
+
+		for (entry = 1; entry <= entry_count; entry++) {
+			val = (index == 0) ? /* First entry is Zero. */
+				0 : start + entry * ((end - start) * 1.0 / entry_count);
+
+			lut[index].red = lut[index].green = lut[index].blue = MIN(val, max_val);
+
+			index++;
+		}
+	}
+
+	return lut;
+}
+
+struct drm_color_lut_ext *create_max_lut(segment_data_t *info)
+{
+	int i;
+	struct drm_color_lut_ext *lut;
+	uint32_t max_val = 0xffffffff;
+
+	lut = malloc(sizeof(struct drm_color_lut_ext) * info->entries_count);
+	igt_assert(lut);
+
+	lut[0].red = lut[0].green = lut[0].blue = 0; /* First entry is Zero. */
+
+	for (i = 1; i < info->entries_count; i++)
+		lut[i].red = lut[i].green = lut[i].blue = max_val;
+
+	return lut;
+}
+
+void clear_segment_data(segment_data_t *info)
+{
+	if (!info)
+		return;
+
+	free(info->segment_data);
+	free(info);
+}
+
+segment_data_t *get_segment_data(data_t *data,
+				uint64_t blob_id, char *mode)
+{
+	drmModePropertyBlobPtr blob;
+	struct drm_color_lut_range *lut_range = NULL;
+	segment_data_t *info = NULL;
+	uint32_t i;
+
+	blob = drmModeGetPropertyBlob(data->drm_fd, blob_id);
+	igt_assert(blob);
+	igt_assert(blob->length);
+
+	info = malloc(sizeof(segment_data_t));
+	igt_assert(info);
+
+	lut_range = (struct drm_color_lut_range *) blob->data;
+	info->segment_count = blob->length / sizeof(lut_range[0]);
+	igt_assert(info->segment_count);
+
+	info->segment_data = malloc(sizeof(struct drm_color_lut_range) * info->segment_count);
+	igt_assert(info->segment_data);
+
+	for (i = 0; i < info->segment_count; i++) {
+		info->entries_count += lut_range[i].count;
+		info->segment_data[i] = lut_range[i];
+	}
+
+	drmModeFreePropertyBlob(blob);
+
+	return info;
+}
+
+void set_plane_gamma(igt_plane_t *plane,
+		char *mode,
+		struct drm_color_lut_ext *lut,
+		uint32_t size)
+{
+	igt_plane_set_prop_enum(plane, IGT_PLANE_GAMMA_MODE, mode);
+	igt_plane_replace_prop_blob(plane, IGT_PLANE_GAMMA_LUT, lut, size);
+}
+
+void set_plane_degamma(igt_plane_t *plane,
+		char *mode,
+		struct drm_color_lut_ext *lut,
+		uint32_t size)
+{
+	igt_plane_set_prop_enum(plane, IGT_PLANE_DEGAMMA_MODE, mode);
+	igt_plane_replace_prop_blob(plane, IGT_PLANE_DEGAMMA_LUT, lut, size);
+}
+
+void set_plane_ctm(igt_plane_t *plane, const double *coefficients)
+{
+	struct drm_color_ctm ctm;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(ctm.matrix); i++) {
+		if (coefficients[i] < 0) {
+			ctm.matrix[i] =
+				(int64_t) (-coefficients[i] *
+				((int64_t) 1L << 32));
+			ctm.matrix[i] |= 1ULL << 63;
+		} else
+			ctm.matrix[i] =
+				(int64_t) (coefficients[i] *
+				((int64_t) 1L << 32));
+	}
+
+	igt_plane_replace_prop_blob(plane, IGT_PLANE_CTM, &ctm, sizeof(ctm));
+}
+
+void disable_plane_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop)
+{
+	if (igt_plane_has_prop(plane, prop))
+		igt_plane_replace_prop_blob(plane, prop, NULL, 0);
+}
+
 drmModePropertyBlobPtr
 get_blob(data_t *data, igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)
 {
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index 88890724c2..945cc475e3 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -64,6 +64,14 @@ typedef struct {
 	double coeffs[];
 } gamma_lut_t;
 
+typedef struct {
+	uint32_t segment_count;
+	struct drm_color_lut_range *segment_data;
+	uint32_t entries_count;
+} segment_data_t;
+
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
 			       color_t *colors,
@@ -90,10 +98,27 @@ void set_gamma(data_t *data,
 void set_ctm(igt_pipe_t *pipe, const double *coefficients);
 void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop);
 
+drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane,
+	enum igt_atomic_plane_properties prop);
+void clear_segment_data(segment_data_t *info);
+struct drm_color_lut_ext *create_linear_lut(segment_data_t *info);
+struct drm_color_lut_ext *create_max_lut(segment_data_t *info);
+segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode);
+void set_plane_gamma(igt_plane_t *plane,
+	char *mode, struct drm_color_lut_ext *lut, uint32_t size);
+void set_plane_degamma(igt_plane_t *plane,
+	char *mode, struct drm_color_lut_ext *lut, uint32_t size);
+void set_plane_ctm(igt_plane_t *plane, const double *coefficients);
+void disable_plane_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop);
+
 #define disable_degamma(pipe) disable_prop(pipe, IGT_CRTC_DEGAMMA_LUT)
 #define disable_gamma(pipe) disable_prop(pipe, IGT_CRTC_GAMMA_LUT)
 #define disable_ctm(pipe) disable_prop(pipe, IGT_CRTC_CTM)
 
+#define disable_plane_degamma(plane) disable_plane_prop(plane, IGT_PLANE_DEGAMMA_LUT)
+#define disable_plane_gamma(plane) disable_plane_prop(plane, IGT_PLANE_GAMMA_LUT)
+#define disable_plane_ctm(plane) disable_plane_prop(plane, IGT_PLANE_CTM)
+
 drmModePropertyBlobPtr get_blob(data_t *data, igt_pipe_t *pipe,
 				enum igt_atomic_crtc_properties prop);
 bool crc_equal(igt_crc_t *a, igt_crc_t *b);
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 03/24] tests/kms_color: New subtests for Plane gamma
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 02/24] kms_color_helper: Add helper functions for plane color mgmt venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 04/24] tests/kms_color: New subtests for Plane degamma venkata.sai.patnana
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify Plane gamma, draw 3 gradient rectangles in red, green and blue,
with a maxed out gamma LUT and verify we have the same CRC as drawing solid
color rectangles.

v2:
* Rename function names (Uma)
* Update to use restructured helper functions (Bhanu)
v3:
* Restructure to manage the memory (alloc & free) by the caller (Uma)
v4:
* Clear the gamma before exit (Uma)
v5:
* Ignore "no gamma" from enum list (Bhanu)
v6:
* Search for the enum name, instead of assuming value as 0 (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 7ef0226ef27bb0d71e4809cdbe3ba58e4cca7593)
---
 tests/kms_color.c | 181 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 180 insertions(+), 1 deletion(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 3a42532a5c..9b5c1d63eb 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -24,7 +24,34 @@
 
 #include "kms_color_helper.h"
 
-IGT_TEST_DESCRIPTION("Test Color Features at Pipe level");
+IGT_TEST_DESCRIPTION("Test Color Features at Pipe & Plane level");
+
+#define MAX_SUPPORTED_PLANES 7
+#define SDR_PLANE_BASE 3
+
+typedef bool (*test_t)(data_t*, igt_plane_t*);
+
+static bool is_hdr_plane(const igt_plane_t *plane)
+{
+	return plane->index >= 0 && plane->index < SDR_PLANE_BASE;
+}
+
+static bool is_valid_plane(igt_plane_t *plane)
+{
+	int index = plane->index;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		return false;
+
+	/*
+	 * Test 1 HDR plane, 1 SDR plane.
+	 *
+	 * 0,1,2 HDR planes
+	 * 3,4,5,6 SDR planes
+	 *
+	 */
+	return index >= 0 && index < MAX_SUPPORTED_PLANES;
+}
 
 static void test_pipe_degamma(data_t *data,
 			      igt_plane_t *primary)
@@ -638,6 +665,122 @@ static void test_pipe_limited_range_ctm(data_t *data,
 }
 #endif
 
+static bool plane_gamma_test(data_t *data, igt_plane_t *plane)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	struct igt_fb fb;
+	drmModePropertyPtr gamma_mode = NULL;
+	uint32_t i;
+	bool ret = true;
+	igt_pipe_crc_t *pipe_crc = NULL;
+	igt_crc_t crc_gamma, crc_fullcolors;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	igt_info("Plane gamma test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_LUT));
+
+	igt_require_pipe_crc(data->drm_fd);
+	pipe_crc = igt_pipe_crc_new(data->drm_fd,
+				  plane->pipe->pipe,
+				  INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	output = igt_get_single_output_for_pipe(display, plane->pipe->pipe);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_plane_set_fb(plane, &fb);
+	disable_ctm(plane->pipe);
+	disable_degamma(plane->pipe);
+	disable_gamma(plane->pipe);
+
+	disable_plane_ctm(plane);
+	disable_plane_degamma(plane);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	gamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_GAMMA_MODE);
+
+	/* Iterate all supported gamma modes. */
+	for (i = 0; i < gamma_mode->count_enums; i++) {
+		segment_data_t *segment_info = NULL;
+		struct drm_color_lut_ext *lut = NULL;
+		uint32_t lut_size = 0;
+
+		/* Ignore 'no gamma' from enum list. */
+		if (!strcmp(gamma_mode->enums[i].name, "no gamma"))
+			continue;
+
+		igt_info("Trying to use gamma mode: \'%s\'\n", gamma_mode->enums[i].name);
+
+		/* Draw solid colors with no gamma transformation. */
+		disable_plane_gamma(plane);
+		paint_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+		igt_wait_for_vblank(data->drm_fd,
+			display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_fullcolors);
+
+		/* Draw a gradient with gamma LUT to remap all
+		 * values to max red/green/blue.
+		 */
+		segment_info = get_segment_data(data, gamma_mode->enums[i].value,
+				gamma_mode->enums[i].name);
+		lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count;
+		lut = create_max_lut(segment_info);
+		set_plane_gamma(plane, gamma_mode->enums[i].name, lut, lut_size);
+
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+		igt_wait_for_vblank(data->drm_fd,
+			display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_gamma);
+
+		/* Verify that the CRC of the software computed output is
+		 * equal to the CRC of the gamma LUT transformation output.
+		 */
+		ret &= crc_equal(&crc_gamma, &crc_fullcolors);
+
+		free(lut);
+		clear_segment_data(segment_info);
+	}
+
+	disable_plane_gamma(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	igt_pipe_crc_free(pipe_crc);
+	drmModeFreeProperty(gamma_mode);
+
+	return ret;
+}
+
 static void
 run_tests_for_pipe(data_t *data, enum pipe p)
 {
@@ -865,6 +1008,38 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 	}
 }
 
+static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
+{
+	igt_plane_t *plane;
+	int count = 0;
+
+	for_each_plane_on_pipe(&data->display, pipe, plane) {
+		if (!is_valid_plane(plane))
+			continue;
+
+		igt_assert(test(data, plane));
+
+		count++;
+	}
+
+	if (!count)
+		igt_skip("No valid planes found.\n");
+}
+
+static void run_tests_for_plane(data_t *data, enum pipe pipe)
+{
+	igt_fixture {
+		igt_display_require_output_on_pipe(&data->display, pipe);
+		igt_require(data->display.pipes[pipe].n_planes > 0);
+		igt_require(is_i915_device(data->drm_fd));
+	}
+
+	igt_describe("Compare maxed out plane gamma LUT and solid color linear LUT");
+	igt_subtest_f("pipe-%s-plane-gamma",
+			kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_gamma_test);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -895,6 +1070,10 @@ igt_main
 	igt_subtest_f("pipe-invalid-ctm-matrix-sizes")
 		invalid_ctm_matrix_sizes(&data);
 
+	for_each_pipe_static(pipe)
+		igt_subtest_group
+			run_tests_for_plane(&data, pipe);
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 04/24] tests/kms_color: New subtests for Plane degamma
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 02/24] kms_color_helper: Add helper functions for plane color mgmt venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 03/24] tests/kms_color: New subtests for Plane gamma venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 05/24] tests/kms_color: New subtests for Plane CTM venkata.sai.patnana
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify Plane degamma, draw 3 gradient rectangles in red, green and blue,
with a maxed out degamma LUT and verify we have the same CRC as drawing solid
color rectangles with linear gamma LUT.

v2:
* Rename function names (Uma)
* Update to use restructured helper functions (Bhanu)
v3:
* Restructure to manage the memory (alloc & free) by the caller (Uma)
v4:
* Remove gamma dependency & clear degamma before exit (Uma)
v5:
* Ignore "no degamma" from enum list (Bhanu)
v6:
* Search for the enum name, instead of assuming value as 0 (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 07dbabff8a5b9c0dd01cf344991de09b6f1f9870)
---
 tests/kms_color.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 9b5c1d63eb..0874775cd2 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -781,6 +781,124 @@ static bool plane_gamma_test(data_t *data, igt_plane_t *plane)
 	return ret;
 }
 
+static bool plane_degamma_test(data_t *data, igt_plane_t *plane)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	drmModePropertyPtr degamma_mode;
+	struct igt_fb fb;
+	uint32_t i;
+	bool ret = true;
+	igt_pipe_crc_t *pipe_crc = NULL;
+	igt_crc_t crc_degamma, crc_fullcolors;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	igt_info("Plane degamma test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_LUT));
+
+	igt_require_pipe_crc(data->drm_fd);
+	pipe_crc = igt_pipe_crc_new(data->drm_fd,
+				    plane->pipe->pipe,
+				    INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	output = igt_get_single_output_for_pipe(display, plane->pipe->pipe);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_plane_set_fb(plane, &fb);
+	disable_ctm(plane->pipe);
+	disable_degamma(plane->pipe);
+	disable_gamma(plane->pipe);
+
+	disable_plane_ctm(plane);
+	disable_plane_gamma(plane);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	degamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_DEGAMMA_MODE);
+
+	/* Iterate all supported degamma modes. */
+	for (i = 0; i < degamma_mode->count_enums; i++) {
+		segment_data_t *degamma_segment_info = NULL;
+		struct drm_color_lut_ext *degamma_lut = NULL;
+		uint32_t degamma_lut_size = 0;
+
+		/* Ignore 'no degamma' from enum list. */
+		if (!strcmp(degamma_mode->enums[i].name, "no degamma"))
+			continue;
+
+		degamma_segment_info = get_segment_data(data, degamma_mode->enums[i].value,
+						degamma_mode->enums[i].name);
+		degamma_lut_size = sizeof(struct drm_color_lut_ext) * degamma_segment_info->entries_count;
+		degamma_lut = create_max_lut(degamma_segment_info);
+
+		igt_info("Trying to use degamma mode: \'%s\'\n", degamma_mode->enums[i].name);
+
+		/* Draw solid colors with no degamma. */
+		disable_plane_degamma(plane);
+		paint_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+		igt_wait_for_vblank(data->drm_fd,
+				display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_fullcolors);
+
+		/* Draw a gradient with degamma LUT to remap all
+		 * values to max red/green/blue.
+		 */
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		set_plane_degamma(plane, degamma_mode->enums[i].name,
+				  degamma_lut, degamma_lut_size);
+		igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+		igt_wait_for_vblank(data->drm_fd,
+				display->pipes[plane->pipe->pipe].crtc_offset);
+		igt_pipe_crc_collect_crc(pipe_crc, &crc_degamma);
+
+		/* Verify that the CRC of the software computed output
+		 * is equal to the CRC of the degamma LUT transformation
+		 * output.
+		 */
+		ret &= crc_equal(&crc_degamma, &crc_fullcolors);
+
+		free(degamma_lut);
+		clear_segment_data(degamma_segment_info);
+	}
+
+	disable_plane_degamma(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	igt_pipe_crc_free(pipe_crc);
+	drmModeFreeProperty(degamma_mode);
+
+	return ret;
+}
+
 static void
 run_tests_for_pipe(data_t *data, enum pipe p)
 {
@@ -1038,6 +1156,11 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_subtest_f("pipe-%s-plane-gamma",
 			kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, plane_gamma_test);
+
+	igt_describe("Compare maxed out plane degamma LUT and solid color linear LUT");
+	igt_subtest_f("pipe-%s-plane-degamma",
+			kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_degamma_test);
 }
 
 igt_main
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 05/24] tests/kms_color: New subtests for Plane CTM
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (2 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 04/24] tests/kms_color: New subtests for Plane degamma venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 06/24] tests/kms_color_chamelium: New subtests for Plane gamma venkata.sai.patnana
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify plane CTM, draw 3 rectangles using before colors with the
ctm matrix applied and verify the CRC is equal to using after colors
with an identify ctm matrix.

v2:
* Rename function names (Uma)
* Update to use restructured helper functions (Bhanu)
v3:
* Restructure to manage the memory (alloc & free) by the caller (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit c8615f4fa0b05f287cb70e355bab2ed23ddb6b57)
---
 tests/kms_color.c | 224 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 224 insertions(+)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 0874775cd2..0387c9192a 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -53,6 +53,77 @@ static bool is_valid_plane(igt_plane_t *plane)
 	return index >= 0 && index < MAX_SUPPORTED_PLANES;
 }
 
+struct {
+	const char *test_name;
+	int iter;
+	color_t expected_colors[3];
+	double ctm[9];
+} ctm_tests[] = {
+	{"plane-ctm-red-to-blue", 0,
+					{{ 0.0, 0.0, 1.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 0.0, 0.0, 0.0,
+		  0.0, 1.0, 0.0,
+		  1.0, 0.0, 1.0 },
+	},
+	{"plane-ctm-green-to-red", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 1.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 1.0, 1.0, 0.0,
+		  0.0, 0.0, 0.0,
+		  0.0, 0.0, 1.0 },
+	},
+	{"plane-ctm-blue-to-red", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 1.0, 0.0, 0.0 }},
+		{ 1.0, 0.0, 1.0,
+		  0.0, 1.0, 0.0,
+		  0.0, 0.0, 0.0 },
+	},
+	{"plane-ctm-max", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 100.0, 0.0, 0.0,
+		  0.0, 100.0, 0.0,
+		  0.0, 0.0, 100.0 },
+	},
+	{"plane-ctm-negative", 0,
+					{{ 0.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 0.0 }},
+		{ -1.0, 0.0, 0.0,
+		   0.0, -1.0, 0.0,
+		   0.0, 0.0, -1.0 },
+	},
+	/* We tests a few values around the expected result because
+	 * it depends on the hardware we're dealing with, we can
+	 * either get clamped or rounded values and we also need to
+	 * account for odd number of items in the LUTs.
+	 */
+	{"plane-ctm-0-25", 5,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.25, 0.0,  0.0,
+		  0.0,  0.25, 0.0,
+		  0.0,  0.0,  0.25 },
+	},
+	{"plane-ctm-0-50", 5,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.5,  0.0,  0.0,
+		  0.0,  0.5,  0.0,
+		  0.0,  0.0,  0.5 },
+	},
+	{"plane-ctm-0-75", 7,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.75, 0.0,  0.0,
+		  0.0,  0.75, 0.0,
+		  0.0,  0.0,  0.75 },
+	},
+};
+
 static void test_pipe_degamma(data_t *data,
 			      igt_plane_t *primary)
 {
@@ -899,6 +970,99 @@ static bool plane_degamma_test(data_t *data, igt_plane_t *plane)
 	return ret;
 }
 
+static bool test_plane_ctm(data_t *data,
+			  igt_plane_t *plane,
+			  color_t *before,
+			  color_t *after,
+			  double *ctm_matrix)
+{
+	const double ctm_identity[] = {
+		1.0, 0.0, 0.0,
+		0.0, 1.0, 0.0,
+		0.0, 0.0, 1.0
+	};
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	struct igt_fb fb;
+	igt_crc_t crc_software, crc_hardware;
+	igt_pipe_crc_t *pipe_crc = NULL;
+	bool ret = true;
+
+	igt_info("Plane CTM test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_CTM));
+
+	igt_require_pipe_crc(data->drm_fd);
+	pipe_crc = igt_pipe_crc_new(data->drm_fd,
+				  plane->pipe->pipe,
+				  INTEL_PIPE_CRC_SOURCE_AUTO);
+
+	output = igt_get_single_output_for_pipe(display, plane->pipe->pipe);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_plane_set_fb(plane, &fb);
+
+	disable_degamma(plane->pipe);
+	disable_gamma(plane->pipe);
+	disable_ctm(plane->pipe);
+
+	disable_plane_gamma(plane);
+	disable_plane_degamma(plane);
+	igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	/* Without CTM transformation. */
+	paint_rectangles(data, mode, after, &fb);
+	igt_plane_set_fb(plane, &fb);
+	set_plane_ctm(plane, ctm_identity);
+	igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+	igt_wait_for_vblank(data->drm_fd,
+			display->pipes[plane->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(pipe_crc, &crc_software);
+
+	/* With CTM transformation. */
+	paint_rectangles(data, mode, before, &fb);
+	igt_plane_set_fb(plane, &fb);
+	set_plane_ctm(plane, ctm_matrix);
+	igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+	igt_wait_for_vblank(data->drm_fd,
+			display->pipes[plane->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(pipe_crc, &crc_hardware);
+
+	/* Verify that the CRC of the software computed ouutput
+	 * is equal to the CRC of the CTM matrix transformation
+	 * output.
+	 */
+	ret = crc_equal(&crc_software, &crc_hardware);
+
+	disable_plane_ctm(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	igt_pipe_crc_free(pipe_crc);
+
+	return ret;
+}
+
 static void
 run_tests_for_pipe(data_t *data, enum pipe p)
 {
@@ -1144,8 +1308,56 @@ static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
 		igt_skip("No valid planes found.\n");
 }
 
+static void run_plane_ctm_test(data_t *data,
+				enum pipe pipe,
+				color_t *expected,
+				double *ctm,
+				int iter)
+{
+	igt_plane_t *plane;
+	bool result;
+	int i, count = 0;
+	double delta = 1.0 / (1 << 8);
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	for_each_plane_on_pipe(&data->display, pipe, plane) {
+		if (!is_valid_plane(plane))
+			continue;
+
+		result = false;
+
+		if (!iter)
+			result |= test_plane_ctm(data, plane,
+					red_green_blue, expected,
+					ctm);
+
+		for (i = 0; i < iter; i++) {
+			expected[0].r =
+			expected[1].g =
+			expected[2].b =
+				ctm[0] + delta * (i - (iter/2));
+
+			result |= test_plane_ctm(data, plane,
+					red_green_blue,	expected,
+					ctm);
+		}
+
+		igt_assert(result);
+		count++;
+	}
+
+	if (!count)
+		igt_skip("No valid planes found.\n");
+}
+
 static void run_tests_for_plane(data_t *data, enum pipe pipe)
 {
+	int i;
+
 	igt_fixture {
 		igt_display_require_output_on_pipe(&data->display, pipe);
 		igt_require(data->display.pipes[pipe].n_planes > 0);
@@ -1161,6 +1373,18 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_subtest_f("pipe-%s-plane-degamma",
 			kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, plane_degamma_test);
+
+	for (i = 0; i < ARRAY_SIZE(ctm_tests); i++) {
+		igt_describe("Compare after applying ctm matrix & identity matrix");
+		igt_subtest_f("pipe-%s-%s",
+				kmstest_pipe_name(pipe),
+				ctm_tests[i].test_name) {
+			run_plane_ctm_test(data, pipe,
+					ctm_tests[i].expected_colors,
+					ctm_tests[i].ctm,
+					ctm_tests[i].iter);
+		}
+	}
 }
 
 igt_main
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 06/24] tests/kms_color_chamelium: New subtests for Plane gamma
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (3 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 05/24] tests/kms_color: New subtests for Plane CTM venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 07/24] tests/kms_color_chamelium: New subtests for Plane degamma venkata.sai.patnana
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify Plane gamma, draw 3 gradient rectangles in red, green and blue,
with a maxed out gamma LUT and verify we have the same frame dump as
drawing solid color rectangles.

v2:
* Ignore "no gamma" from enum list (Bhanu)
v3:
* Search for the enum name, instead of assuming value as 0 (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 1d66b734cb91b0ceec60e7af958984d2947ed712)
---
 tests/kms_color_chamelium.c | 190 +++++++++++++++++++++++++++++++++++-
 1 file changed, 189 insertions(+), 1 deletion(-)

diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c
index 30b38b82e3..59afaf0f43 100644
--- a/tests/kms_color_chamelium.c
+++ b/tests/kms_color_chamelium.c
@@ -24,7 +24,34 @@
 
 #include "kms_color_helper.h"
 
-IGT_TEST_DESCRIPTION("Test Color Features at Pipe level using Chamelium to verify instead of CRC");
+IGT_TEST_DESCRIPTION("Test Color Features at Pipe & Plane level using Chamelium to verify instead of CRC");
+
+#define MAX_SUPPORTED_PLANES 7
+#define SDR_PLANE_BASE 3
+
+typedef bool (*test_t)(data_t*, igt_plane_t*);
+
+static bool is_hdr_plane(const igt_plane_t *plane)
+{
+	return plane->index >= 0 && plane->index < SDR_PLANE_BASE;
+}
+
+static bool is_valid_plane(igt_plane_t *plane)
+{
+	int index = plane->index;
+
+	if (plane->type != DRM_PLANE_TYPE_PRIMARY)
+		return false;
+
+	/*
+	 * Test 1 HDR plane, 1 SDR plane.
+	 *
+	 * 0,1,2 HDR planes
+	 * 3,4,5,6 SDR planes
+	 *
+	 */
+	return index >= 0 && index < MAX_SUPPORTED_PLANES;
+}
 
 /*
  * Draw 3 gradient rectangles in red, green and blue, with a maxed out
@@ -721,6 +748,163 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 	}
 }
 
+static bool plane_gamma_test(data_t *data, igt_plane_t *plane)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	struct igt_fb fb, fbref;
+	drmModePropertyPtr gamma_mode = NULL;
+	uint32_t i;
+	bool ret = true;
+	struct chamelium_port *port = NULL;
+	struct chamelium_frame_dump *frame_fullcolors;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	igt_info("Plane gamma test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_GAMMA_LUT));
+
+	for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) {
+		for (i = 0; i < data->port_count; i++)
+			if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) {
+				port = data->ports[i];
+				break;
+			}
+
+		if (port)
+			break;
+	}
+	igt_require(port);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fbref));
+
+	disable_degamma(plane->pipe);
+	disable_ctm(plane->pipe);
+	disable_gamma(plane->pipe);
+
+	disable_plane_degamma(plane);
+	disable_plane_ctm(plane);
+	disable_plane_gamma(plane);
+
+	igt_plane_set_fb(plane, &fbref);
+	igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	gamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_GAMMA_MODE);
+
+	/* Draw solid colors with no gamma transformation. */
+	paint_rectangles(data, mode, red_green_blue, &fbref);
+
+	/* Iterate all supported gamma modes. */
+	for (i = 0; i < gamma_mode->count_enums; i++) {
+		segment_data_t *segment_info = NULL;
+		struct drm_color_lut_ext *lut = NULL;
+		uint32_t lut_size = 0;
+
+		/* Ignore 'no gamma' from enum list. */
+		if (!strcmp(gamma_mode->enums[i].name, "no gamma"))
+			continue;
+
+		igt_info("Trying to use gamma mode: \'%s\'\n", gamma_mode->enums[i].name);
+
+		segment_info = get_segment_data(data, gamma_mode->enums[i].value,
+				gamma_mode->enums[i].name);
+		lut_size = sizeof(struct drm_color_lut_ext) * segment_info->entries_count;
+		lut = create_max_lut(segment_info);
+		set_plane_gamma(plane, gamma_mode->enums[i].name, lut, lut_size);
+
+		/* Draw a gradient with gamma LUT to remap all
+		 * values to max red/green/blue.
+		 */
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+		chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
+		frame_fullcolors =
+			chamelium_read_captured_frame(data->chamelium, 0);
+
+		/* Verify that the framebuffer reference of the software computed
+		 * output is equal to the frame dump of the gamma LUT
+		 * transformation output.
+		 */
+		ret &= chamelium_frame_match_or_dump(data->chamelium, port,
+					      frame_fullcolors, &fbref,
+					      CHAMELIUM_CHECK_ANALOG);
+		free(lut);
+		clear_segment_data(segment_info);
+	}
+
+	disable_plane_gamma(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	drmModeFreeProperty(gamma_mode);
+
+	return ret;
+}
+
+static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
+{
+	igt_plane_t *plane;
+	int count = 0;
+
+	for_each_plane_on_pipe(&data->display, pipe, plane) {
+		if (!is_valid_plane(plane))
+			continue;
+
+		igt_assert(test(data, plane));
+
+		count++;
+	}
+
+	if (!count)
+		igt_skip("No valid planes found.\n");
+}
+
+static void run_tests_for_plane(data_t *data, enum pipe pipe)
+{
+	igt_fixture {
+		igt_display_require_output_on_pipe(&data->display, pipe);
+		igt_require(data->display.pipes[pipe].n_planes > 0);
+		igt_require(is_i915_device(data->drm_fd));
+	}
+
+	igt_describe("Compare maxed out plane gamma LUT and solid color linear LUT");
+	igt_subtest_f("pipe-%s-plane-gamma",
+			kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_gamma_test);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -764,6 +948,10 @@ igt_main
 	igt_subtest_f("pipe-invalid-ctm-matrix-sizes")
 		invalid_ctm_matrix_sizes(&data);
 
+	for_each_pipe_static(pipe)
+		igt_subtest_group
+			run_tests_for_plane(&data, pipe);
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 07/24] tests/kms_color_chamelium: New subtests for Plane degamma
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (4 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 06/24] tests/kms_color_chamelium: New subtests for Plane gamma venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 08/24] tests/kms_color_chamelium: New subtests for Plane CTM venkata.sai.patnana
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify Plane degamma, draw 3 gradient rectangles in red, green and blue,
with a maxed out degamma LUT and verify we have the same frame dump as
drawing solid color rectangles with linear gamma LUT.

v2:
* Ignore "no degamma" from enum list (Bhanu)
v3:
* Search for the enum name, instead of assuming value as 0 (Uma)

Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit d8ba24e8dd1407a068e5301d62ae1117588e02f9)
---
 tests/kms_color_chamelium.c | 132 ++++++++++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)

diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c
index 59afaf0f43..17a7baa9a2 100644
--- a/tests/kms_color_chamelium.c
+++ b/tests/kms_color_chamelium.c
@@ -873,6 +873,133 @@ static bool plane_gamma_test(data_t *data, igt_plane_t *plane)
 	return ret;
 }
 
+static bool plane_degamma_test(data_t *data, igt_plane_t *plane)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	drmModePropertyPtr degamma_mode;
+	struct igt_fb fb, fbref;
+	struct chamelium_port *port;
+	struct chamelium_frame_dump *frame_fullcolors;
+	uint32_t i;
+	bool ret = true;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	igt_info("Plane degamma test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_MODE));
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_DEGAMMA_LUT));
+
+	for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) {
+		for (i = 0; i < data->port_count; i++)
+			if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) {
+				port = data->ports[i];
+				break;
+			}
+
+		if (port)
+			break;
+	}
+	igt_require(port);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fbref));
+
+	disable_degamma(plane->pipe);
+	disable_ctm(plane->pipe);
+	disable_gamma(plane->pipe);
+
+	disable_plane_degamma(plane);
+	disable_plane_ctm(plane);
+	disable_plane_gamma(plane);
+
+	igt_plane_set_fb(plane, &fbref);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	degamma_mode = get_plane_gamma_degamma_mode(plane, IGT_PLANE_DEGAMMA_MODE);
+
+	/* Draw solid colors with no degamma. */
+	paint_rectangles(data, mode, red_green_blue, &fbref);
+
+	/* Iterate all supported degamma modes. */
+	for (i = 0; i < degamma_mode->count_enums; i++) {
+		segment_data_t *degamma_segment_info = NULL;
+		struct drm_color_lut_ext *degamma_lut = NULL;
+		uint32_t degamma_lut_size = 0;
+
+		/* Ignore 'no degamma' from enum list. */
+		if (!strcmp(degamma_mode->enums[i].name, "no degamma"))
+			continue;
+
+		degamma_segment_info = get_segment_data(data, degamma_mode->enums[i].value,
+						degamma_mode->enums[i].name);
+		degamma_lut_size = sizeof(struct drm_color_lut_ext) * degamma_segment_info->entries_count;
+		degamma_lut = create_max_lut(degamma_segment_info);
+
+		igt_info("Trying to use degamma mode: \'%s\'\n", degamma_mode->enums[i].name);
+
+		/* Draw a gradient with degamma LUT to remap all
+		 * values to max red/green/blue.
+		 */
+		paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+		igt_plane_set_fb(plane, &fb);
+		set_plane_degamma(plane, degamma_mode->enums[i].name,
+				degamma_lut, degamma_lut_size);
+		igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+
+		chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
+		frame_fullcolors =
+			chamelium_read_captured_frame(data->chamelium, 0);
+
+		/* Verify that the framebuffer reference of the software computed
+		 * output is equal to the frame dump of the gamma LUT
+		 * transformation output.
+		 */
+		ret &= chamelium_frame_match_or_dump(data->chamelium, port,
+				frame_fullcolors, &fbref,
+				CHAMELIUM_CHECK_ANALOG);
+
+		free(degamma_lut);
+		clear_segment_data(degamma_segment_info);
+	}
+
+	disable_plane_degamma(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	drmModeFreeProperty(degamma_mode);
+
+	return ret;
+}
+
 static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
 {
 	igt_plane_t *plane;
@@ -903,6 +1030,11 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_subtest_f("pipe-%s-plane-gamma",
 			kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, plane_gamma_test);
+
+	igt_describe("Compare maxed out plane degamma LUT and solid color linear LUT");
+	igt_subtest_f("pipe-%s-plane-degamma",
+			kmstest_pipe_name(pipe))
+		run_plane_color_test(data, pipe, plane_degamma_test);
 }
 
 igt_main
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 08/24] tests/kms_color_chamelium: New subtests for Plane CTM
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (5 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 07/24] tests/kms_color_chamelium: New subtests for Plane degamma venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 09/24] lib/igt_kms: Add pipe color mgmt properties venkata.sai.patnana
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

To verify plane CTM, draw 3 rectangles using before colors with the
ctm matrix applied and verify the frame dump is equal to using after
colors with an identify ctm matrix.

V2:
* Fix fb creation logic

Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit df1e2a1e61de7233730f6bdf94e53f442f63fe52)
---
 tests/kms_color_chamelium.c | 228 ++++++++++++++++++++++++++++++++++++
 1 file changed, 228 insertions(+)

diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c
index 17a7baa9a2..24f25d964c 100644
--- a/tests/kms_color_chamelium.c
+++ b/tests/kms_color_chamelium.c
@@ -53,6 +53,77 @@ static bool is_valid_plane(igt_plane_t *plane)
 	return index >= 0 && index < MAX_SUPPORTED_PLANES;
 }
 
+struct {
+	const char *test_name;
+	int iter;
+	color_t expected_colors[3];
+	double ctm[9];
+} ctm_tests[] = {
+	{"plane-ctm-red-to-blue", 0,
+					{{ 0.0, 0.0, 1.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 0.0, 0.0, 0.0,
+		  0.0, 1.0, 0.0,
+		  1.0, 0.0, 1.0 },
+	},
+	{"plane-ctm-green-to-red", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 1.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 1.0, 1.0, 0.0,
+		  0.0, 0.0, 0.0,
+		  0.0, 0.0, 1.0 },
+	},
+	{"plane-ctm-blue-to-red", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 1.0, 0.0, 0.0 }},
+		{ 1.0, 0.0, 1.0,
+		  0.0, 1.0, 0.0,
+		  0.0, 0.0, 0.0 },
+	},
+	{"plane-ctm-max", 0,
+					{{ 1.0, 0.0, 0.0 },
+					 { 0.0, 1.0, 0.0 },
+					 { 0.0, 0.0, 1.0 }},
+		{ 100.0, 0.0, 0.0,
+		  0.0, 100.0, 0.0,
+		  0.0, 0.0, 100.0 },
+	},
+	{"plane-ctm-negative", 0,
+					{{ 0.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 0.0 },
+					 { 0.0, 0.0, 0.0 }},
+		{ -1.0, 0.0, 0.0,
+		   0.0, -1.0, 0.0,
+		   0.0, 0.0, -1.0 },
+	},
+	/* We tests a few values around the expected result because
+	 * it depends on the hardware we're dealing with, we can
+	 * either get clamped or rounded values and we also need to
+	 * account for odd number of items in the LUTs.
+	 */
+	{"plane-ctm-0-25", 5,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.25, 0.0,  0.0,
+		  0.0,  0.25, 0.0,
+		  0.0,  0.0,  0.25 },
+	},
+	{"plane-ctm-0-50", 5,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.5,  0.0,  0.0,
+		  0.0,  0.5,  0.0,
+		  0.0,  0.0,  0.5 },
+	},
+	{"plane-ctm-0-75", 7,
+					{{ 0.0, }, { 0.0, }, { 0.0, }},
+		{ 0.75, 0.0,  0.0,
+		  0.0,  0.75, 0.0,
+		  0.0,  0.0,  0.75 },
+	},
+};
+
 /*
  * Draw 3 gradient rectangles in red, green and blue, with a maxed out
  * degamma LUT and verify we have the same frame dump as drawing solid color
@@ -1000,6 +1071,103 @@ static bool plane_degamma_test(data_t *data, igt_plane_t *plane)
 	return ret;
 }
 
+static bool test_plane_ctm(data_t *data,
+			  igt_plane_t *plane,
+			  color_t *before,
+			  color_t *after,
+			  double *ctm_matrix)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	struct igt_fb fb, fbref;
+	struct chamelium_port *port;
+	struct chamelium_frame_dump *frame_hardware;
+	uint32_t i;
+	bool ret = true;
+
+	igt_info("Plane CTM test is running on pipe-%s plane-%s(%s)\n",
+			kmstest_pipe_name(plane->pipe->pipe),
+			kmstest_plane_type_name(plane->type),
+			is_hdr_plane(plane) ? "hdr":"sdr");
+
+	igt_require(igt_plane_has_prop(plane, IGT_PLANE_CTM));
+
+	for_each_valid_output_on_pipe(display, plane->pipe->pipe, output) {
+		for (i = 0; i < data->port_count; i++)
+			if (strcmp(output->name, chamelium_port_get_name(data->ports[i])) == 0) {
+				port = data->ports[i];
+				break;
+			}
+
+		if (port)
+			break;
+	}
+	igt_require(port);
+	igt_assert(output);
+
+	igt_output_set_pipe(output, plane->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fb));
+
+	igt_assert(igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      LOCAL_DRM_FORMAT_MOD_NONE,
+			      &fbref));
+
+	disable_degamma(plane->pipe);
+	disable_ctm(plane->pipe);
+	disable_gamma(plane->pipe);
+
+	disable_plane_degamma(plane);
+	disable_plane_ctm(plane);
+	disable_plane_gamma(plane);
+
+	igt_plane_set_fb(plane, &fbref);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	/* Without CTM transformation. */
+	paint_rectangles(data, mode, after, &fbref);
+
+	/* With CTM transformation. */
+	paint_rectangles(data, mode, before, &fb);
+	igt_plane_set_fb(plane, &fb);
+	set_plane_ctm(plane, ctm_matrix);
+	igt_display_commit2(display, display->is_atomic ?
+				COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
+	frame_hardware =
+		chamelium_read_captured_frame(data->chamelium, 0);
+
+	/* Verify that the framebuffer reference of the software
+	 * computed output is equal to the frame dump of the CTM
+	 * matrix transformation output.
+	 */
+	ret = chamelium_frame_match_or_dump(data->chamelium, port,
+					     frame_hardware,
+					     &fbref,
+					     CHAMELIUM_CHECK_ANALOG);
+
+	disable_plane_ctm(plane);
+	igt_plane_set_fb(plane, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ?
+					COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	return ret;
+}
+
 static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
 {
 	igt_plane_t *plane;
@@ -1018,8 +1186,56 @@ static void run_plane_color_test(data_t *data, enum pipe pipe, test_t test)
 		igt_skip("No valid planes found.\n");
 }
 
+static void run_plane_ctm_test(data_t *data,
+				enum pipe pipe,
+				color_t *expected,
+				double *ctm,
+				int iter)
+{
+	igt_plane_t *plane;
+	bool result;
+	int i, count = 0;
+	double delta = 1.0 / (1 << 8);
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+
+	for_each_plane_on_pipe(&data->display, pipe, plane) {
+		if (!is_valid_plane(plane))
+			continue;
+
+		result = false;
+
+		if (!iter)
+			result |= test_plane_ctm(data, plane,
+					red_green_blue, expected,
+					ctm);
+
+		for (i = 0; i < iter; i++) {
+			expected[0].r =
+			expected[1].g =
+			expected[2].b =
+				ctm[0] + delta * (i - (iter/2));
+
+			result |= test_plane_ctm(data, plane,
+					red_green_blue,	expected,
+					ctm);
+		}
+
+		igt_assert(result);
+		count++;
+	}
+
+	if (!count)
+		igt_skip("No valid planes found.\n");
+}
+
 static void run_tests_for_plane(data_t *data, enum pipe pipe)
 {
+	int i;
+
 	igt_fixture {
 		igt_display_require_output_on_pipe(&data->display, pipe);
 		igt_require(data->display.pipes[pipe].n_planes > 0);
@@ -1035,6 +1251,18 @@ static void run_tests_for_plane(data_t *data, enum pipe pipe)
 	igt_subtest_f("pipe-%s-plane-degamma",
 			kmstest_pipe_name(pipe))
 		run_plane_color_test(data, pipe, plane_degamma_test);
+
+	for (i = 0; i < ARRAY_SIZE(ctm_tests); i++) {
+		igt_describe("Compare after applying ctm matrix & identity matrix");
+		igt_subtest_f("pipe-%s-%s",
+				kmstest_pipe_name(pipe),
+				ctm_tests[i].test_name) {
+			run_plane_ctm_test(data, pipe,
+					ctm_tests[i].expected_colors,
+					ctm_tests[i].ctm,
+					ctm_tests[i].iter);
+		}
+	}
 }
 
 igt_main
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 09/24] lib/igt_kms: Add pipe color mgmt properties
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (6 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 08/24] tests/kms_color_chamelium: New subtests for Plane CTM venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 10/24] kms_color_helper: Add helper functions to support logarithmic gamma mode venkata.sai.patnana
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>

Add support for Pipe color management properties.

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
(cherry picked from commit cea63909b8b1c2a730c0bde82bd958c08b70f9b9)
---
 lib/igt_kms.c | 1 +
 lib/igt_kms.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index ae183e822c..b11c8c27a6 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -592,6 +592,7 @@ const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	[IGT_CRTC_CTM] = "CTM",
 	[IGT_CRTC_GAMMA_LUT] = "GAMMA_LUT",
 	[IGT_CRTC_GAMMA_LUT_SIZE] = "GAMMA_LUT_SIZE",
+	[IGT_CRTC_GAMMA_MODE] = "GAMMA_MODE",
 	[IGT_CRTC_DEGAMMA_LUT] = "DEGAMMA_LUT",
 	[IGT_CRTC_DEGAMMA_LUT_SIZE] = "DEGAMMA_LUT_SIZE",
 	[IGT_CRTC_MODE_ID] = "MODE_ID",
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 41967bf28a..b54f2baf7d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -119,6 +119,7 @@ enum igt_atomic_crtc_properties {
        IGT_CRTC_CTM = 0,
        IGT_CRTC_GAMMA_LUT,
        IGT_CRTC_GAMMA_LUT_SIZE,
+       IGT_CRTC_GAMMA_MODE,
        IGT_CRTC_DEGAMMA_LUT,
        IGT_CRTC_DEGAMMA_LUT_SIZE,
        IGT_CRTC_MODE_ID,
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 10/24] kms_color_helper: Add helper functions to support logarithmic gamma mode
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (7 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 09/24] lib/igt_kms: Add pipe color mgmt properties venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 11/24] tests/kms_color: Extended IGT tests " venkata.sai.patnana
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>

Add helper functions to support logarithmic gamma mode

v5: Move all compute/set logic to advance gamma mode function
v4: Removed unnecessary code and checks
    Makes the changes more generic
v3: calculate luts using gamma coefficients(Uma Shankar)

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
(cherry picked from commit de9636f5ac840d03c1ed77fa928212b85b250bf9)
---
 tests/kms_color_helper.c | 132 ++++++++++++++++++++++++++++++++++++++-
 tests/kms_color_helper.h |  16 +++++
 2 files changed, 147 insertions(+), 1 deletion(-)

diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index a14a97999e..36a9964cbf 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -24,6 +24,8 @@
 
 #include "kms_color_helper.h"
 
+#define DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES     6
+
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
 			       color_t *colors,
@@ -166,7 +168,8 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
 		 * Mask the lower bits not provided by the framebuffer so we
 		 * can do CRC comparisons.
 		 */
-		v &= mask;
+		if (intel_gen(data->devid) < 13)
+			v &= mask;
 
 		lut[i].red = v;
 		lut[i].green = v;
@@ -181,6 +184,33 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
 	return lut;
 }
 
+struct drm_color_lut *coeffs_to_logarithmic_lut(data_t *data,
+						const gamma_lut_t *gamma,
+						uint32_t color_depth,
+						int off)
+{
+	struct drm_color_lut *lut;
+	int i, lut_size = gamma->size;
+	/* This is the maximum value due to 16 bit precision in hardware. */
+	uint32_t max_hw_value = (1 << 16) - 1;
+	uint32_t v;
+	unsigned int max_segment_value = 1 << 24;
+	double scaling_factor;
+
+	lut = malloc(sizeof(struct drm_color_lut) * lut_size);
+
+	for (i = 0; i < lut_size; i++) {
+		scaling_factor = (double)max_hw_value / (double)max_segment_value;
+		v = (double)gamma->coeffs[i] * (double)scaling_factor;
+		v =  MIN(v, max_hw_value);
+		lut[i].red = v;
+		lut[i].green = v;
+		lut[i].blue = v;
+	}
+
+	return lut;
+}
+
 void set_degamma(data_t *data,
 		 igt_pipe_t *pipe,
 		 const gamma_lut_t *gamma)
@@ -194,6 +224,15 @@ void set_degamma(data_t *data,
 	free(lut);
 }
 
+void set_pipe_gamma(igt_pipe_t *pipe,
+		    uint64_t value,
+		    struct drm_color_lut *lut,
+		    uint32_t size)
+{
+	igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_GAMMA_MODE, value);
+	igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT, lut, size);
+}
+
 void set_gamma(data_t *data,
 	       igt_pipe_t *pipe, const gamma_lut_t *gamma)
 {
@@ -232,6 +271,51 @@ void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)
 		igt_pipe_obj_replace_prop_blob(pipe, prop, NULL, 0);
 }
 
+drmModePropertyPtr get_pipe_gamma_degamma_mode(igt_pipe_t *pipe,
+					       enum igt_atomic_crtc_properties prop)
+{
+	igt_display_t *display = pipe->display;
+	uint32_t prop_id = pipe->props[prop];
+	drmModePropertyPtr drmProp;
+
+	igt_assert(prop_id);
+
+	drmProp = drmModeGetProperty(display->drm_fd, prop_id);
+
+	igt_assert(drmProp);
+	igt_assert(drmProp->count_enums);
+
+	return drmProp;
+}
+
+gamma_lut_t *pipe_create_linear_lut(segment_data_t *info)
+{
+	uint32_t segment, entry, index = 0;
+	double val;
+	int i = 0;
+	gamma_lut_t *gamma = alloc_lut(info->entries_count);
+
+	igt_assert(gamma);
+
+	gamma->size = info->entries_count;
+	for (segment = 0; segment < info->segment_count; segment++) {
+		uint32_t entry_count = info->segment_data[segment].count;
+		uint32_t start = (segment == 0) ? 0 : (1 << (segment - 1));
+		uint32_t end = 1 << segment;
+
+		for (entry = 0; entry < entry_count; entry++) {
+			val = (index == 0) ? /* First entry is Zero. */
+				0 : start + entry *
+				((end - start) * 1.0 / entry_count);
+
+			gamma->coeffs[i++] = val;
+			index++;
+		}
+	}
+
+	return gamma;
+}
+
 drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane,
 				enum igt_atomic_plane_properties prop)
 {
@@ -322,6 +406,7 @@ segment_data_t *get_segment_data(data_t *data,
 	info->segment_data = malloc(sizeof(struct drm_color_lut_range) * info->segment_count);
 	igt_assert(info->segment_data);
 
+	info->entries_count = 0;
 	for (i = 0; i < info->segment_count; i++) {
 		info->entries_count += lut_range[i].count;
 		info->segment_data[i] = lut_range[i];
@@ -332,6 +417,51 @@ segment_data_t *get_segment_data(data_t *data,
 	return info;
 }
 
+void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type)
+{
+	igt_display_t *display = &data->display;
+	gamma_lut_t *gamma_log;
+	drmModePropertyPtr gamma_mode = NULL;
+	segment_data_t *segment_info = NULL;
+	struct drm_color_lut *lut = NULL;
+	int lut_size = 0;
+
+	drmSetClientCap(data->drm_fd, DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES, 1);
+	gamma_mode = get_pipe_gamma_degamma_mode(pipe, IGT_CRTC_GAMMA_MODE);
+
+	for (int i = 0; i < gamma_mode->count_enums; i++) {
+		if (!strcmp(gamma_mode->enums[i].name, "logarithmic gamma")) {
+			segment_info = get_segment_data(data,
+							gamma_mode->enums[i].value,
+							gamma_mode->enums[i].name);
+			lut_size = sizeof(struct drm_color_lut) *
+					  segment_info->entries_count;
+			if (type == LINEAR_GAMMA) {
+				gamma_log = pipe_create_linear_lut(segment_info);
+				lut = coeffs_to_logarithmic_lut(data,
+								gamma_log,
+								data->color_depth,
+								0);
+			} else if (type == MAX_GAMMA) {
+				gamma_log = generate_table_max(segment_info->entries_count);
+				gamma_log->size = segment_info->entries_count;
+				lut = coeffs_to_lut(data, gamma_log,
+						    data->color_depth, 0);
+			}
+			set_pipe_gamma(pipe, gamma_mode->enums[i].value,
+				       lut, lut_size);
+			igt_display_commit2(display, display->is_atomic
+					    ? COMMIT_ATOMIC : COMMIT_LEGACY);
+			break;
+		}
+	}
+	drmSetClientCap(data->drm_fd, DRM_CLIENT_CAP_ADVANCE_GAMMA_MODES, 0);
+	free(gamma_log);
+	free(lut);
+	clear_segment_data(segment_info);
+	drmModeFreeProperty(gamma_mode);
+}
+
 void set_plane_gamma(igt_plane_t *plane,
 		char *mode,
 		struct drm_color_lut_ext *lut,
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index 945cc475e3..14d42d29cc 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -70,6 +70,11 @@ typedef struct {
 	uint32_t entries_count;
 } segment_data_t;
 
+enum gamma_type {
+	LINEAR_GAMMA,
+	MAX_GAMMA
+};
+
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
 void paint_gradient_rectangles(data_t *data,
@@ -89,6 +94,10 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
 				    const gamma_lut_t *gamma,
 				    uint32_t color_depth,
 				    int off);
+struct drm_color_lut *coeffs_to_logarithmic_lut(data_t *data,
+						const gamma_lut_t *gamma,
+						uint32_t color_depth,
+						int off);
 void set_degamma(data_t *data,
 		 igt_pipe_t *pipe,
 		 const gamma_lut_t *gamma);
@@ -98,12 +107,19 @@ void set_gamma(data_t *data,
 void set_ctm(igt_pipe_t *pipe, const double *coefficients);
 void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop);
 
+drmModePropertyPtr get_pipe_gamma_degamma_mode(igt_pipe_t *pipe,
+					       enum igt_atomic_crtc_properties
+					       prop);
 drmModePropertyPtr get_plane_gamma_degamma_mode(igt_plane_t *plane,
 	enum igt_atomic_plane_properties prop);
 void clear_segment_data(segment_data_t *info);
+gamma_lut_t *pipe_create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_linear_lut(segment_data_t *info);
 struct drm_color_lut_ext *create_max_lut(segment_data_t *info);
 segment_data_t *get_segment_data(data_t *data, uint64_t blob_id, char *mode);
+void set_pipe_gamma(igt_pipe_t *pipe, uint64_t value,
+		    struct drm_color_lut *lut, uint32_t size);
+void set_advance_gamma(data_t *data, igt_pipe_t *pipe, enum gamma_type type);
 void set_plane_gamma(igt_plane_t *plane,
 	char *mode, struct drm_color_lut_ext *lut, uint32_t size);
 void set_plane_degamma(igt_plane_t *plane,
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 11/24] tests/kms_color: Extended IGT tests to support logarithmic gamma mode
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (8 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 10/24] kms_color_helper: Add helper functions to support logarithmic gamma mode venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 12/24] tests/kms_color_chamelium: " venkata.sai.patnana
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>

Extended IGT tests to support logarithmic gamma mode on pipe

v5: Move all compute/set logic to advance gamma mode function
v4: Make the changes more genreric
    Reset the Client caps once done.
v3: Refactor the changes.
    Keep the wrappers remain same.
    Added Client caps support(Uma)
v4: Disable gamma in ctm tests (Bhanu)
    Remove unused variables (Bhanu)
v5: Disable gamma before starting gamma tests.

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
(cherry picked from commit 521a1c1fcd945fced7bd169476a8b81a80b313d1)
---
 tests/kms_color.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 0387c9192a..f8e0485f75 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -129,7 +129,7 @@ static void test_pipe_degamma(data_t *data,
 {
 	igt_output_t *output;
 	igt_display_t *display = &data->display;
-	gamma_lut_t *degamma_linear, *degamma_full;
+	gamma_lut_t *degamma_full;
 	gamma_lut_t *gamma_linear;
 	color_t red_green_blue[] = {
 		{ 1.0, 0.0, 0.0 },
@@ -140,9 +140,7 @@ static void test_pipe_degamma(data_t *data,
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT));
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_LUT));
 
-	degamma_linear = generate_table(data->degamma_lut_size, 1.0);
 	degamma_full = generate_table_max(data->degamma_lut_size);
-
 	gamma_linear = generate_table(data->gamma_lut_size, 1.0);
 
 	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
@@ -174,8 +172,13 @@ static void test_pipe_degamma(data_t *data,
 		igt_plane_set_fb(primary, &fb_modeset);
 		disable_ctm(primary->pipe);
 		disable_degamma(primary->pipe);
-		set_gamma(data, primary->pipe, gamma_linear);
-		igt_display_commit(&data->display);
+		if (igt_pipe_obj_has_prop(primary->pipe,
+					  IGT_CRTC_GAMMA_MODE)) {
+			set_advance_gamma(data, primary->pipe, LINEAR_GAMMA);
+		} else {
+			set_gamma(data, primary->pipe, gamma_linear);
+			igt_display_commit(&data->display);
+		}
 
 		/* Draw solid colors with no degamma transformation. */
 		paint_rectangles(data, mode, red_green_blue, &fb);
@@ -207,7 +210,6 @@ static void test_pipe_degamma(data_t *data,
 		igt_remove_fb(data->drm_fd, &fb_modeset);
 	}
 
-	free_lut(degamma_linear);
 	free_lut(degamma_full);
 	free_lut(gamma_linear);
 }
@@ -259,10 +261,22 @@ static void test_pipe_gamma(data_t *data,
 		igt_assert(fb_modeset_id);
 
 		igt_plane_set_fb(primary, &fb_modeset);
+
+		/* Reset Color properties */
 		disable_ctm(primary->pipe);
 		disable_degamma(primary->pipe);
-		set_gamma(data, primary->pipe, gamma_full);
+		disable_gamma(primary->pipe);
 		igt_display_commit(&data->display);
+		igt_wait_for_vblank(data->drm_fd,
+				    display->pipes[primary->pipe->pipe].crtc_offset);
+
+		if (igt_pipe_obj_has_prop(primary->pipe,
+					  IGT_CRTC_GAMMA_MODE)) {
+			set_advance_gamma(data, primary->pipe, MAX_GAMMA);
+		} else {
+			set_gamma(data, primary->pipe, gamma_full);
+			igt_display_commit(&data->display);
+		}
 
 		/* Draw solid colors with no gamma transformation. */
 		paint_rectangles(data, mode, red_green_blue, &fb);
@@ -580,7 +594,10 @@ static bool test_pipe_ctm(data_t *data,
 		 */
 		if (memcmp(before, after, sizeof(color_t))) {
 			set_degamma(data, primary->pipe, degamma_linear);
-			set_gamma(data, primary->pipe, gamma_linear);
+			if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE))
+				disable_gamma(primary->pipe);
+			else
+				set_gamma(data, primary->pipe, gamma_linear);
 		} else {
 			/* Disable Degamma and Gamma for ctm max test */
 			disable_degamma(primary->pipe);
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 12/24] tests/kms_color_chamelium: Extended IGT tests to support logarithmic gamma mode
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (9 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 11/24] tests/kms_color: Extended IGT tests " venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 13/24] tests/kms_color: Optimize plane ctm test venkata.sai.patnana
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Extended IGT tests to support logarithmic gamma mode on pipe

V2:
* Disable gamma for CTM tests (Bhanu)

v3: Disable the pipe color properties before starting the test,
so that we begin with clean state. Addressed Bhanu's review comments.

Cc: Kunal Joshi <kunal1.joshi@intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
(cherry picked from commit b36d919700509f203f4463e033048135925274f2)
---
 tests/kms_color_chamelium.c | 61 +++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 9 deletions(-)

diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c
index 24f25d964c..38c7169737 100644
--- a/tests/kms_color_chamelium.c
+++ b/tests/kms_color_chamelium.c
@@ -133,7 +133,7 @@ static void test_pipe_degamma(data_t *data,
 			      igt_plane_t *primary)
 {
 	igt_output_t *output;
-	gamma_lut_t *degamma_linear, *degamma_full;
+	gamma_lut_t *degamma_full;
 	gamma_lut_t *gamma_linear;
 	color_t red_green_blue[] = {
 		{ 1.0, 0.0, 0.0 },
@@ -152,9 +152,7 @@ static void test_pipe_degamma(data_t *data,
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT));
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_LUT));
 
-	degamma_linear = generate_table(data->degamma_lut_size, 1.0);
 	degamma_full = generate_table_max(data->degamma_lut_size);
-
 	gamma_linear = generate_table(data->gamma_lut_size, 1.0);
 
 	for_each_valid_output_on_pipe(&data->display,
@@ -208,8 +206,12 @@ static void test_pipe_degamma(data_t *data,
 		igt_plane_set_fb(primary, &fb_modeset);
 		disable_ctm(primary->pipe);
 		disable_degamma(primary->pipe);
-		set_gamma(data, primary->pipe, gamma_linear);
-		igt_display_commit(&data->display);
+		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) {
+			set_advance_gamma(data, primary->pipe, LINEAR_GAMMA);
+		} else {
+			set_gamma(data, primary->pipe, gamma_linear);
+			igt_display_commit(&data->display);
+		}
 
 		/* Draw solid colors with no degamma transformation. */
 		paint_rectangles(data, mode, red_green_blue, &fbref);
@@ -235,9 +237,13 @@ static void test_pipe_degamma(data_t *data,
 
 		igt_plane_set_fb(primary, NULL);
 		igt_output_set_pipe(output, PIPE_NONE);
+
+		/* Cleanup */
+		disable_gamma(primary->pipe);
+		disable_degamma(primary->pipe);
+		igt_display_commit(&data->display);
 	}
 
-	free_lut(degamma_linear);
 	free_lut(degamma_full);
 	free_lut(gamma_linear);
 }
@@ -319,10 +325,21 @@ static void test_pipe_gamma(data_t *data,
 		igt_assert(fbref_id);
 
 		igt_plane_set_fb(primary, &fb_modeset);
+
+		/* Reset the color properties */
 		disable_ctm(primary->pipe);
 		disable_degamma(primary->pipe);
-		set_gamma(data, primary->pipe, gamma_full);
+		disable_gamma(primary->pipe);
 		igt_display_commit(&data->display);
+		igt_wait_for_vblank(data->drm_fd,
+				    data->display.pipes[primary->pipe->pipe].crtc_offset);
+
+		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE)) {
+			set_advance_gamma(data, primary->pipe, MAX_GAMMA);
+		} else {
+			set_gamma(data, primary->pipe, gamma_full);
+			igt_display_commit(&data->display);
+		}
 
 		/* Draw solid colors with no gamma transformation. */
 		paint_rectangles(data, mode, red_green_blue, &fbref);
@@ -347,6 +364,10 @@ static void test_pipe_gamma(data_t *data,
 
 		igt_plane_set_fb(primary, NULL);
 		igt_output_set_pipe(output, PIPE_NONE);
+
+		/* Cleanup */
+		disable_gamma(primary->pipe);
+		igt_display_commit(&data->display);
 	}
 
 	free_lut(gamma_full);
@@ -431,7 +452,10 @@ static bool test_pipe_ctm(data_t *data,
 
 		if (memcmp(before, after, sizeof(color_t))) {
 			set_degamma(data, primary->pipe, degamma_linear);
-			set_gamma(data, primary->pipe, gamma_linear);
+			if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE))
+				disable_gamma(primary->pipe);
+			else
+				set_gamma(data, primary->pipe, gamma_linear);
 		} else {
 			/* Disable Degamma and Gamma for ctm max test */
 			disable_degamma(primary->pipe);
@@ -465,6 +489,12 @@ static bool test_pipe_ctm(data_t *data,
 		igt_output_set_pipe(output, PIPE_NONE);
 	}
 
+	/* Cleanup */
+	disable_gamma(primary->pipe);
+	disable_degamma(primary->pipe);
+	disable_ctm(primary->pipe);
+	igt_display_commit(&data->display);
+
 	free_lut(degamma_linear);
 	free_lut(gamma_linear);
 
@@ -559,7 +589,14 @@ static void test_pipe_limited_range_ctm(data_t *data,
 		igt_plane_set_fb(primary, &fb_modeset);
 
 		set_degamma(data, primary->pipe, degamma_linear);
-		set_gamma(data, primary->pipe, gamma_linear);
+		/*
+		 * No need of linear gamma for limited range ctm test
+		 * Not extending for new API interface.
+		 */
+		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_MODE))
+			disable_gamma(primary->pipe);
+		else
+			set_gamma(data, primary->pipe, gamma_linear);
 		set_ctm(primary->pipe, ctm);
 
 		igt_output_set_prop_value(output,
@@ -596,6 +633,12 @@ static void test_pipe_limited_range_ctm(data_t *data,
 
 	}
 
+	/* Cleanup */
+	disable_gamma(primary->pipe);
+	disable_degamma(primary->pipe);
+	disable_ctm(primary->pipe);
+	igt_display_commit(&data->display);
+
 	free_lut(gamma_linear);
 	free_lut(degamma_linear);
 
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 13/24] tests/kms_color: Optimize plane ctm test
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (10 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 12/24] tests/kms_color_chamelium: " venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 14/24] tests/kms_color_chamelium: " venkata.sai.patnana
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Kunal Joshi <kunal1.joshi@intel.com>

Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
(cherry picked from commit 79e7179cf8a07a90da91bba8a2ad5089e8b81f7c)
---
 tests/kms_color.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index f8e0485f75..622faf0934 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -1361,6 +1361,8 @@ static void run_plane_ctm_test(data_t *data,
 			result |= test_plane_ctm(data, plane,
 					red_green_blue,	expected,
 					ctm);
+			if (result)
+				break;
 		}
 
 		igt_assert(result);
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 14/24] tests/kms_color_chamelium: Optimize plane ctm test
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (11 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 13/24] tests/kms_color: Optimize plane ctm test venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering venkata.sai.patnana
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Kunal Joshi <kunal1.joshi@intel.com>

Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
(cherry picked from commit 71599658db6b7f60ba9381201074dbbae73381cf)
---
 tests/kms_color_chamelium.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kms_color_chamelium.c b/tests/kms_color_chamelium.c
index 38c7169737..52eef8a66f 100644
--- a/tests/kms_color_chamelium.c
+++ b/tests/kms_color_chamelium.c
@@ -1265,6 +1265,8 @@ static void run_plane_ctm_test(data_t *data,
 			result |= test_plane_ctm(data, plane,
 					red_green_blue,	expected,
 					ctm);
+			if (result)
+				break;
 		}
 
 		igt_assert(result);
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (12 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 14/24] tests/kms_color_chamelium: " venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-15  5:45   ` Shankar, Uma
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 16/24] tests/kms_dither: Validate dither after CC blocks venkata.sai.patnana
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Many of the display devices have color format support less than
the color format of the input data (Ex: 8-bit input data and 6-bit
display color depth). Then the input data will be either truncated
or rounded, but this approach usually causes loss of detail and also
produce large banded areas of a single color that significantly
differs from the original image.

Dithering is a technique used to enhance these colors by creating the
illusion of smoothness by adjusting the nearby pixel color.
For Eg: Converting 8-bit to 6-bit by modifying the pixel information.

Dithering should be enabled when a panel color depth is lower than the
color depth of the framebuffer.

Even though feature Dithering is there since legacy, there is no
specific IGT for this. This patch will create New IGT for Dithering.
And below is the truth table for CRTC Dithering.

|----------------|---------|-------------|
|  Frame buffer  |  Panel  |  Dithering  |
|----------------|---------|-------------|
|      8 BPC     |  6 BPC  |     Yes     |
|----------------|---------|-------------|
|      8 BPC     |  8 BPC  |     No      |
|----------------|---------|-------------|
|      8 BPC     | 10 BPC  |     No      |
|----------------|---------|-------------|
|     10 BPC     |  6 BPC  |     Yes     |
|----------------|---------|-------------|
|     10 BPC     |  8 BPC  |     Yes     |
|----------------|---------|-------------|
|     10 BPC     | 10 BPC  |     No      |
|----------------|---------|-------------|
|     16 BPC     |  6 BPC  |     Yes     |
|----------------|---------|-------------|
|     16 BPC     |  8 BPC  |     Yes     |
|----------------|---------|-------------|
|     16 BPC     | 10 BPC  |     Yes     |
|----------------|---------|-------------|

v2:
* Fix commit message (Karthik)
* Add file author (Karthik)
* Dynamic subtests for pipe-output combinations (Karthik)
* Update deprecated pipe name (Karthik)
* Remove redundant fb creation logic (Karthik)

v3:
* Use for_each_pipe_with_valid_output() to simplify the logic (Bhanu)
* Remove magic numbers to create fb (Karthik)
* Fix typos & comments (Swati)

v4:
* Remove explicit igt_require for a valid output found,
  igt_subtest_with_dynamic will handle the SKIP (Petri)
* Limit the execution to a single pipe (Uma)

v5:
* SKIP subtest for HDMI with 6 BPC (Bhanu)
* Fix the usage of valid format to create 8 BPC Framebuffer (Bhanu)
* Add support for suspend/resume tests (Bhanu)
* Add few debug prints (Bhanu)

v6:
* Limit the execution to 8 BPC panels (Uma)
* Remove suspend/resume tests (Bhanu)

v7:
* Drop max_bpc from debugfs (Uma)

v8:
* Run test on all connected outputs (Bhanu)
* Before exiting the test reset the "max bpc" prop (Bhanu)
* Before computing the result check that the crtc bpc is updated
  with the requested one (Bhanu)

Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Nischal Varide <nischal.varide@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 24d58fef5070ec7557d8bf778b12becb93dd3315)
---
 tests/kms_dither.c | 250 +++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build  |   1 +
 2 files changed, 251 insertions(+)
 create mode 100644 tests/kms_dither.c

diff --git a/tests/kms_dither.c b/tests/kms_dither.c
new file mode 100644
index 0000000000..c25d623f81
--- /dev/null
+++ b/tests/kms_dither.c
@@ -0,0 +1,250 @@
+/*
+ * Copyright © 2020 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *     Bhanuprakash Modem <bhanuprakash.modem@intel.com>
+ *
+ */
+
+#include "igt.h"
+#include <fcntl.h>
+#include <termios.h>
+#include <unistd.h>
+
+IGT_TEST_DESCRIPTION("Test Dithering block status");
+
+/* Connector BPC */
+#define IGT_CONNECTOR_BPC_6		6
+#define IGT_CONNECTOR_BPC_8		8
+#define IGT_CONNECTOR_BPC_10		10
+#define IGT_CONNECTOR_BPC_12		12
+
+/* Framebuffer BPC */
+#define IGT_FRAME_BUFFER_BPC_8		8
+#define IGT_FRAME_BUFFER_BPC_10		10
+#define IGT_FRAME_BUFFER_BPC_16		16
+
+/* Common test data. */
+typedef struct data {
+	igt_display_t display;
+	igt_plane_t *primary;
+	igt_output_t *output;
+	igt_pipe_t *pipe;
+	drmModeModeInfo *mode;
+	enum pipe pipe_id;
+	int drm_fd;
+	igt_fb_t fb;
+} data_t;
+
+typedef struct {
+	unsigned int bpc;
+	unsigned int dither;
+} dither_status_t;
+
+/* Prepare test data. */
+static void prepare_test(data_t *data, igt_output_t *output, enum pipe pipe)
+{
+	igt_display_t *display = &data->display;
+
+	data->pipe_id = pipe;
+	data->pipe = &data->display.pipes[data->pipe_id];
+	igt_assert(data->pipe);
+
+	igt_display_reset(display);
+
+	data->output = output;
+	igt_assert(data->output);
+
+	data->mode = igt_output_get_mode(data->output);
+	igt_assert(data->mode);
+
+	data->primary =
+		igt_pipe_get_plane_type(data->pipe, DRM_PLANE_TYPE_PRIMARY);
+
+	igt_output_set_pipe(data->output, data->pipe_id);
+}
+
+/* Returns the current state of dithering from the crtc debugfs. */
+static dither_status_t get_dither_state(data_t *data)
+{
+	char buf[256];
+	char crtc_name[7];
+	char *start_loc;
+	int fd, res;
+	dither_status_t status;
+
+	snprintf(crtc_name, 7, "crtc-%d", data->pipe_id);
+	fd = igt_debugfs_open(data->drm_fd, crtc_name, O_RDONLY);
+	igt_assert(fd >= 0);
+
+	res = igt_debugfs_simple_read(fd, "dither", buf, sizeof(buf));
+	igt_require(res > 0);
+	close(fd);
+
+	igt_assert(start_loc = strstr(buf, "bpc: "));
+	igt_assert_eq(sscanf(start_loc, "bpc: %u", &status.bpc), 1);
+
+	igt_assert(start_loc = strstr(buf, "Dither: "));
+	igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.dither), 1);
+
+	return status;
+}
+
+static void test_dithering(data_t *data, enum pipe pipe,
+			   igt_output_t *output,
+			   int fb_bpc, int fb_format,
+			   int output_bpc)
+{
+	igt_display_t *display = &data->display;
+	dither_status_t status;
+	int bpc;
+
+	igt_info("Dithering test execution on %s PIPE_%s\n",
+			output->name, kmstest_pipe_name(pipe));
+	prepare_test(data, output, pipe);
+
+	igt_assert(igt_create_fb(data->drm_fd, data->mode->hdisplay,
+				 data->mode->vdisplay, fb_format,
+				 LOCAL_DRM_FORMAT_MOD_NONE, &data->fb));
+	igt_plane_set_fb(data->primary, &data->fb);
+	igt_plane_set_size(data->primary, data->mode->hdisplay, data->mode->vdisplay);
+
+	bpc = igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC);
+	igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC, output_bpc);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+	/*
+	 * Check the status of Dithering block:
+	 *
+	 * Preserve the result & compute later (after clean-up).
+	 * If fb_bpc is greater than output_bpc, Dithering should be enabled
+	 * Else disabled
+	 */
+	status = get_dither_state(data);
+
+	igt_debug("FB BPC:%d, Panel BPC:%d, Pipe BPC:%d, Expected Dither:%s, Actual result:%s\n",
+		  fb_bpc, output_bpc, status.bpc,
+		  (fb_bpc > output_bpc) ? "Enable": "Disable",
+		  status.dither ? "Enable": "Disable");
+
+       /*
+	* We must update the Connector max_bpc property back
+	* Otherwise, previously updated value will stay forever and
+	* may cause the failures for next/other subtests.
+	*/
+	igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC, bpc);
+	igt_plane_set_fb(data->primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+	igt_remove_fb(data->drm_fd, &data->fb);
+
+	/* Check if crtc bpc is updated with requested one. */
+	igt_require_f((status.bpc == output_bpc),
+			"%s can support max %u-bpc, but requested %d-bpc\n",
+				output->name, status.bpc, output_bpc);
+
+	/* Compute the result. */
+	if (fb_bpc > output_bpc)
+		igt_assert_f(status.dither, "(fb_%dbpc > output_%dbpc): Dither should be enabled\n",
+				fb_bpc, output_bpc);
+	else
+		igt_assert_f(!status.dither, "(fb_%dbpc <= output_%dbpc): Dither should be disabled\n",
+				fb_bpc, output_bpc);
+
+	return;
+}
+
+/* Returns true if an output supports max bpc property & max_bpc >= requested. */
+static bool is_supported(igt_output_t *output, int bpc)
+{
+        return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
+		(igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC) >= bpc);
+}
+
+static void
+run_dither_test(data_t *data, int fb_bpc, int fb_format, int output_bpc)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+
+	for_each_connected_output(display, output) {
+		enum pipe pipe;
+
+		if (!is_supported(output, output_bpc))
+			continue;
+
+		if ((strstr(output->name, "HDMI") != NULL) &&
+		    (output_bpc == IGT_CONNECTOR_BPC_6))
+			continue;
+
+		for_each_pipe(display, pipe) {
+			if (igt_pipe_connector_valid(pipe, output)) {
+				igt_dynamic_f("%s-pipe-%s", output->name, kmstest_pipe_name(pipe))
+					test_dithering(data, pipe, output, fb_bpc,
+							fb_format, output_bpc);
+
+				/* One pipe is enough */
+				break;
+			}
+		}
+	}
+}
+
+igt_main
+{
+	struct {
+		int fb_bpc;
+		int format;
+		int output_bpc;
+	} tests[] = {
+		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888, IGT_CONNECTOR_BPC_6 },
+		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888, IGT_CONNECTOR_BPC_8 },
+	};
+	int i;
+	data_t data = { 0 };
+
+	igt_fixture {
+		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
+		kmstest_set_vt_graphics_mode();
+
+		igt_display_require(&data.display, data.drm_fd);
+		igt_display_require_output(&data.display);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(tests); i++) {
+		igt_describe_f("Framebuffer BPC:%d, Panel BPC:%d, Expected Dither:%s\n",
+			       tests[i].fb_bpc, tests[i].output_bpc,
+			       (tests[i].fb_bpc > tests[i].output_bpc) ?
+							"Enable": "Disable");
+
+		igt_subtest_with_dynamic_f("FB-%dBPC-Vs-Panel-%dBPC",
+				tests[i].fb_bpc, tests[i].output_bpc)
+			run_dither_test(&data,
+					tests[i].fb_bpc,
+					tests[i].format,
+					tests[i].output_bpc);
+	}
+
+	igt_fixture {
+		igt_display_fini(&data.display);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index 19cc4ebe0d..ff3979207d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -28,6 +28,7 @@ test_progs = [
 	'kms_cursor_crc',
 	'kms_cursor_edge_walk',
 	'kms_cursor_legacy',
+	'kms_dither',
 	'kms_dp_aux_dev',
 	'kms_dp_dsc',
 	'kms_dp_tiled_display',
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 16/24] tests/kms_dither: Validate dither after CC blocks
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (13 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 17/24] tests/kms_dither: Dont assert if debugfs is not present venkata.sai.patnana
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Dithering after all CC blocks will be enabled only if the panel
supports 12 BPC (or more) and the Framebuffer BPC is greater than
12 BPC. And legacy dither block (at the end of PIPE) should be
disabled to avoid double dithering.

This patch will extend the support to validate Dither after all
color conversion (CC) blocks.

V2:
* Identify the dithering block, then check the status (Uma)

Cc: Swati Sharma <swati2.sharma@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Nischal Varide <nischal.varide@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 884a5ae9e1ba7187a4f13b59071db29cfdf855af)
---
 tests/kms_dither.c | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/tests/kms_dither.c b/tests/kms_dither.c
index c25d623f81..1ff07914f4 100644
--- a/tests/kms_dither.c
+++ b/tests/kms_dither.c
@@ -57,7 +57,8 @@ typedef struct data {
 
 typedef struct {
 	unsigned int bpc;
-	unsigned int dither;
+	unsigned int legacy;
+	unsigned int cc1;
 } dither_status_t;
 
 /* Prepare test data. */
@@ -104,7 +105,10 @@ static dither_status_t get_dither_state(data_t *data)
 	igt_assert_eq(sscanf(start_loc, "bpc: %u", &status.bpc), 1);
 
 	igt_assert(start_loc = strstr(buf, "Dither: "));
-	igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.dither), 1);
+	igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.legacy), 1);
+
+	igt_assert(start_loc = strstr(buf, "Dither_CC1: "));
+	igt_assert_eq(sscanf(start_loc, "Dither_CC1: %u", &status.cc1), 1);
 
 	return status;
 }
@@ -141,10 +145,10 @@ static void test_dithering(data_t *data, enum pipe pipe,
 	 */
 	status = get_dither_state(data);
 
-	igt_debug("FB BPC:%d, Panel BPC:%d, Pipe BPC:%d, Expected Dither:%s, Actual result:%s\n",
-		  fb_bpc, output_bpc, status.bpc,
-		  (fb_bpc > output_bpc) ? "Enable": "Disable",
-		  status.dither ? "Enable": "Disable");
+	igt_debug("FB BPC:%d, Panel BPC:%d, Pipe BPC:%d, "
+		  "Dither at end of the pipe:%u, Dither after CC1:%u\n",
+			fb_bpc, output_bpc, status.bpc,
+			status.legacy, status.cc1);
 
        /*
 	* We must update the Connector max_bpc property back
@@ -163,12 +167,25 @@ static void test_dithering(data_t *data, enum pipe pipe,
 				output->name, status.bpc, output_bpc);
 
 	/* Compute the result. */
-	if (fb_bpc > output_bpc)
-		igt_assert_f(status.dither, "(fb_%dbpc > output_%dbpc): Dither should be enabled\n",
-				fb_bpc, output_bpc);
-	else
-		igt_assert_f(!status.dither, "(fb_%dbpc <= output_%dbpc): Dither should be disabled\n",
+	if (fb_bpc > output_bpc) {
+		if (output_bpc < IGT_CONNECTOR_BPC_12)
+			igt_assert_f((status.legacy && !status.cc1),
+					"(fb_%dbpc > output_%dbpc): Dither should be "
+					"enabled at end of the PIPE & "
+					"disbaled at the CC1.\n",
+					fb_bpc, output_bpc);
+		else
+			igt_assert_f((!status.legacy && status.cc1),
+					"(fb_%dbpc > output_%dbpc): Dither should be "
+					"disabled at end of the PIPE & "
+					"enabled at the CC1.\n",
+					fb_bpc, output_bpc);
+	} else {
+		igt_assert_f((!status.legacy && !status.cc1),
+				"(fb_%dbpc <= output_%dbpc): Dither should be "
+				"disabled at both places (end of the PIPE & CC1).\n",
 				fb_bpc, output_bpc);
+	}
 
 	return;
 }
@@ -218,6 +235,7 @@ igt_main
 	} tests[] = {
 		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888, IGT_CONNECTOR_BPC_6 },
 		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888, IGT_CONNECTOR_BPC_8 },
+		{ IGT_FRAME_BUFFER_BPC_16, DRM_FORMAT_XRGB16161616F, IGT_CONNECTOR_BPC_12 },
 	};
 	int i;
 	data_t data = { 0 };
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 17/24] tests/kms_dither: Dont assert if debugfs is not present
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (14 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 16/24] tests/kms_dither: Validate dither after CC blocks venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 18/24] tests/device_reset: Unload snd driver before i915 unbind venkata.sai.patnana
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

As Dither_CC1 debugfs changes are not preset on older platforms, we need
not to abort the test. So if the debugfs is not present, just consider
the value as zero.

Cc: Uma Shankar <uma.shankar@intel.com>
Cc: Nischal Varide <nischal.varide@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
(cherry picked from commit 70e6b4a88d96479df497414103f1c9ddc8cd95c6)
---
 tests/kms_dither.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/kms_dither.c b/tests/kms_dither.c
index 1ff07914f4..b1f0503a6c 100644
--- a/tests/kms_dither.c
+++ b/tests/kms_dither.c
@@ -107,8 +107,11 @@ static dither_status_t get_dither_state(data_t *data)
 	igt_assert(start_loc = strstr(buf, "Dither: "));
 	igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.legacy), 1);
 
-	igt_assert(start_loc = strstr(buf, "Dither_CC1: "));
-	igt_assert_eq(sscanf(start_loc, "Dither_CC1: %u", &status.cc1), 1);
+	start_loc = strstr(buf, "Dither_CC1: ");
+	if (!start_loc)
+		status.cc1 = 0;
+	else
+		igt_assert_eq(sscanf(start_loc, "Dither_CC1: %u", &status.cc1), 1);
 
 	return status;
 }
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 18/24] tests/device_reset: Unload snd driver before i915 unbind
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (15 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 17/24] tests/kms_dither: Dont assert if debugfs is not present venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 19/24] tests/core_hotunplug: " venkata.sai.patnana
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Uma Shankar <uma.shankar@intel.com>

Unload the snd module before unbinding i915. Audio holds a wakeref which
triggers a warning otherwise, resulting in below warning and test failure.
Currently HSW/BDW and DG1 are the platforms affected, can be extended to
other platforms as well.

<4> [137.001006] ------------[ cut here ]------------
<4> [137.001010] i915 0000:00:02.0: i915 raw-wakerefs=1 wakelocks=1 on cleanup
<4> [137.001076] WARNING: CPU: 0 PID: 1417 at drivers/gpu/drm/i915/intel_runtime_pm.c:619 intel_runtime_pm_driver_release+0x56/0x60 [i915]
<4> [137.001078] Modules linked in: snd_hda_intel i915 snd_hda_codec_hdmi mei_hdcp intel_pmt_telemetry intel_pmt_core x86_pkg_temp_thermal coretemp smsc75xx crct10dif_pclmul usbnet crc32_pclmul mii ghash_clmulni_intel kvm_intel e1000e snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core ptp pps_core mei_me snd_pcm mei prime_numbers intel_pmt [last unloaded: i915]
<4> [137.001095] CPU: 0 PID: 1417 Comm: kworker/u16:7 Tainted: G U 5.9.0-g79478e23b1878-DII_3204+ #1
<4> [137.001097] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP, BIOS TGLSFWI1.R00.3197.A00.2005110542 05/11/2020
<4> [137.001102] Workqueue: events_unbound async_run_entry_fn
<4> [137.001140] RIP: 0010:intel_runtime_pm_driver_release+0x56/0x60 [i915]
<4> [137.001142] Code: fd 10 4c 8b 67 50 4d 85 e4 75 03 4c 8b 27 e8 91 59 58 e1 45 89 e8 89 e9 4c 89 e2 48 89 c6 48 c7 c7 b0 f3 48 a0 e8 55 25 ef e0 <0f> 0b eb b5 66 0f 1f 44 00 00 48 8b 87 88 45 ff ff b9 02 00 00 00
<4> [137.001144] RSP: 0018:ffffc900007dbd68 EFLAGS: 00010286
<4> [137.001147] RAX: 0000000000000000 RBX: ffff88847338bea8 RCX: 0000000000000001
<4> [137.001148] RDX: 0000000080000001 RSI: ffffffff823efa86 RDI: 00000000ffffffff
<4> [137.001150] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000001
<4> [137.001152] R10: 000000009bda34df R11: 00000000e2a8a89a R12: ffff88849b209880
<4> [137.001153] R13: 0000000000000001 R14: ffff88847338bea8 R15: ffff88847338fcc0
<4> [137.001155] FS: 0000000000000000(0000) GS:ffff8884a0600000(0000) knlGS:0000000000000000
<4> [137.001157] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4> [137.001159] CR2: 00007fc03597dd88 CR3: 0000000006610005 CR4: 0000000000770ef0
<4> [137.001160] PKRU: 55555554
<4> [137.001162] Call Trace:
<4> [137.001199] i915_drm_suspend_late+0x102/0x120 [i915]
<4> [137.001204] ? pci_pm_poweroff_late+0x30/0x30
<4> [137.001209] dpm_run_callback+0x61/0x270
<4> [137.001214] __device_suspend_late+0x8b/0x180
<4> [137.001217] async_suspend_late+0x15/0x90
<4> [137.001220] async_run_entry_fn+0x34/0x160
<4> [137.001224] process_one_work+0x26c/0x5c0
<4> [137.001231] worker_thread+0x37/0x380
<4> [137.001235] ? process_one_work+0x5c0/0x5c0
<4> [137.001238] kthread+0x149/0x170
<4> [137.001241] ? kthread_park+0x80/0x80
<4> [137.001246] ret_from_fork+0x1f/0x30
<4> [137.001256] irq event stamp: 2329

v2: Addressed Janusz review comment, added a DG1 platform check
and skip if module unload for audio fails.

v3: Extended the WA to HSW/BDW, added an igt  warning on unload to keep
visibility on the issue as suggested by Janusz

v4: Merged the revert of earlier WA within this patch and added
a flag to track the WA, as suggested by Janusz.

Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
(cherry picked from commit ab7e703161f97fee30c1bf3aae3144bb333c8821)
---
 tests/device_reset.c | 61 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff --git a/tests/device_reset.c b/tests/device_reset.c
index eef707330c..e6a468e6fa 100644
--- a/tests/device_reset.c
+++ b/tests/device_reset.c
@@ -5,11 +5,13 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#include <signal.h>
 
 #include "i915/gem.h"
 #include "igt.h"
 #include "igt_device_scan.h"
 #include "igt_sysfs.h"
+#include "igt_kmod.h"
 
 IGT_TEST_DESCRIPTION("Examine behavior of a driver on device sysfs reset");
 
@@ -28,6 +30,7 @@ struct device_fds {
 		int drv_dir;
 	} fds;
 	char dev_bus_addr[DEV_BUS_ADDR_LEN];
+	bool snd_unload;
 };
 
 static int __open_sysfs_dir(int fd, const char* path)
@@ -82,6 +85,7 @@ static void init_device_fds(struct device_fds *dev)
 {
 	char dev_path[PATH_MAX];
 	char *addr_pos;
+	uint32_t devid;
 
 	igt_debug("open device\n");
 	/**
@@ -91,9 +95,18 @@ static void init_device_fds(struct device_fds *dev)
 	 */
 	dev->fds.dev = __drm_open_driver(DRIVER_ANY);
 	igt_assert_fd(dev->fds.dev);
-	if (is_i915_device(dev->fds.dev))
+	if (is_i915_device(dev->fds.dev)) {
 		igt_require_gem(dev->fds.dev);
 
+		devid = intel_get_drm_devid(dev->fds.dev);
+		if ((IS_HASWELL(devid) || IS_BROADWELL(devid) ||
+		     IS_DG1(devid)) &&
+		     (igt_kmod_is_loaded("snd_hda_intel"))) {
+			igt_debug("Enable WA to unload snd driver\n");
+			dev->snd_unload = true;
+		}
+	}
+
 	igt_assert(device_sysfs_path(dev->fds.dev, dev_path));
 	addr_pos = strrchr(dev_path, '/');
 	igt_assert(addr_pos);
@@ -164,6 +177,34 @@ static bool is_sysfs_reset_supported(int fd)
 /* Unbind the driver from the device */
 static void driver_unbind(struct device_fds *dev)
 {
+	/**
+	 * FIXME: Unbinding the i915 driver on affected platforms with
+	 * audio results in a kernel WARN on "i915 raw-wakerefs=1
+	 * wakelocks=1 on cleanup". The below CI friendly user level
+	 * workaround to unload and de-couple audio from IGT testing,
+	 * prevents the warning from appearing. Drop this hack as soon
+	 * as this is fixed in the kernel. unbind/re-bind validation
+	 * on audio side is not robust and we could have potential
+	 * failures blocking display CI, currently this seems to the
+	 * safest and easiest way out.
+	 */
+	if (dev->snd_unload) {
+		igt_terminate_process(SIGTERM, "alsactl");
+
+		/* unbind snd_hda_intel */
+		kick_snd_hda_intel();
+
+		if (igt_kmod_unload("snd_hda_intel", 0)) {
+			dev->snd_unload = false;
+			igt_warn("Could not unload snd_hda_intel\n");
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			igt_skip("Audio is in use, skipping\n");
+		} else {
+			igt_warn("Preventively unloaded snd_hda_intel\n");
+		}
+	}
+
 	igt_debug("unbind the driver from the device\n");
 	igt_assert(igt_sysfs_set(dev->fds.drv_dir, "unbind",
 		   dev->dev_bus_addr));
@@ -175,6 +216,9 @@ static void driver_bind(struct device_fds *dev)
 	igt_debug("rebind the driver to the device\n");
 	igt_abort_on_f(!igt_sysfs_set(dev->fds.drv_dir, "bind",
 		       dev->dev_bus_addr), "driver rebind failed");
+
+	if (dev->snd_unload)
+		igt_kmod_load("snd_hda_intel", NULL);
 }
 
 /* Initiate device reset */
@@ -235,19 +279,6 @@ static void unbind_reset_rebind(struct device_fds *dev)
 	igt_debug("close the device\n");
 	close_if_opened(&dev->fds.dev);
 
-	/**
-	 * FIXME: Unbinding the i915 driver on some platforms with Azalia audio
-	 * results in a kernel WARN on "i915 raw-wakerefs=1 wakelocks=1 on cleanup".
-	 * The below CI friendly user level workaround prevents the warning from
-	 * appearing. Drop this hack as soon as this is fixed in the kernel.
-	 */
-	if (is_i915_device(dev->fds.dev)) {
-		uint32_t devid = intel_get_drm_devid(dev->fds.dev);
-		if (igt_warn_on_f(IS_HASWELL(devid) || IS_BROADWELL(devid),
-		    "Manually enabling audio PM to work around a kernel WARN\n"))
-			igt_pm_enable_audio_runtime_pm();
-	}
-
 	driver_unbind(dev);
 
 	initiate_device_reset(dev);
@@ -257,7 +288,7 @@ static void unbind_reset_rebind(struct device_fds *dev)
 
 igt_main
 {
-	struct device_fds dev = { .fds = {-1, -1, -1}, .dev_bus_addr = {0}};
+	struct device_fds dev = { .fds = {-1, -1, -1}, .dev_bus_addr = {0}, };
 
 	igt_fixture {
 		char dev_path[PATH_MAX];
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 19/24] tests/core_hotunplug: Unload snd driver before i915 unbind
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (16 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 18/24] tests/device_reset: Unload snd driver before i915 unbind venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display venkata.sai.patnana
  2021-06-03 12:41 ` [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties Petri Latvala
  19 siblings, 0 replies; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Uma Shankar <uma.shankar@intel.com>

Unload the snd module before unbinding i915. Audio holds a wakeref
which triggers a warning otherwise, resulting in below warning and
test failure. Currently HSW/BDW and DG1 are the platforms affected,
can be extended to other platforms as well.

<4> [137.001006] ------------[ cut here ]------------
<4> [137.001010] i915 0000:00:02.0: i915 raw-wakerefs=1 wakelocks=1 on cleanup
<4> [137.001076] WARNING: CPU: 0 PID: 1417 at drivers/gpu/drm/i915/intel_runtime_pm.c:619 intel_runtime_pm_driver_release+0x56/0x60 [i915]
<4> [137.001078] Modules linked in: snd_hda_intel i915 snd_hda_codec_hdmi mei_hdcp intel_pmt_telemetry intel_pmt_core x86_pkg_temp_thermal coretemp smsc75xx crct10dif_pclmul usbnet crc32_pclmul mii ghash_clmulni_intel kvm_intel e1000e snd_intel_dspcfg snd_hda_codec snd_hwdep snd_hda_core ptp pps_core mei_me snd_pcm mei prime_numbers intel_pmt [last unloaded: i915]
<4> [137.001095] CPU: 0 PID: 1417 Comm: kworker/u16:7 Tainted: G U 5.9.0-g79478e23b1878-DII_3204+ #1
<4> [137.001097] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP, BIOS TGLSFWI1.R00.3197.A00.2005110542 05/11/2020
<4> [137.001102] Workqueue: events_unbound async_run_entry_fn
<4> [137.001140] RIP: 0010:intel_runtime_pm_driver_release+0x56/0x60 [i915]
<4> [137.001142] Code: fd 10 4c 8b 67 50 4d 85 e4 75 03 4c 8b 27 e8 91 59 58 e1 45 89 e8 89 e9 4c 89 e2 48 89 c6 48 c7 c7 b0 f3 48 a0 e8 55 25 ef e0 <0f> 0b eb b5 66 0f 1f 44 00 00 48 8b 87 88 45 ff ff b9 02 00 00 00
<4> [137.001144] RSP: 0018:ffffc900007dbd68 EFLAGS: 00010286
<4> [137.001147] RAX: 0000000000000000 RBX: ffff88847338bea8 RCX: 0000000000000001
<4> [137.001148] RDX: 0000000080000001 RSI: ffffffff823efa86 RDI: 00000000ffffffff
<4> [137.001150] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000001
<4> [137.001152] R10: 000000009bda34df R11: 00000000e2a8a89a R12: ffff88849b209880
<4> [137.001153] R13: 0000000000000001 R14: ffff88847338bea8 R15: ffff88847338fcc0
<4> [137.001155] FS: 0000000000000000(0000) GS:ffff8884a0600000(0000) knlGS:0000000000000000
<4> [137.001157] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4> [137.001159] CR2: 00007fc03597dd88 CR3: 0000000006610005 CR4: 0000000000770ef0
<4> [137.001160] PKRU: 55555554
<4> [137.001162] Call Trace:
<4> [137.001199] i915_drm_suspend_late+0x102/0x120 [i915]
<4> [137.001204] ? pci_pm_poweroff_late+0x30/0x30
<4> [137.001209] dpm_run_callback+0x61/0x270
<4> [137.001214] __device_suspend_late+0x8b/0x180
<4> [137.001217] async_suspend_late+0x15/0x90
<4> [137.001220] async_run_entry_fn+0x34/0x160
<4> [137.001224] process_one_work+0x26c/0x5c0
<4> [137.001231] worker_thread+0x37/0x380
<4> [137.001235] ? process_one_work+0x5c0/0x5c0
<4> [137.001238] kthread+0x149/0x170
<4> [137.001241] ? kthread_park+0x80/0x80
<4> [137.001246] ret_from_fork+0x1f/0x30
<4> [137.001256] irq event stamp: 2329

v2: Extended the WA to HSW/BDW, added an igt warning on unload to keep
visibility on the issue as suggested by Janusz

v3: Merged the revert of earlier WA within this patch and added
a flag to track the WA, as suggested by Janusz.

Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
(cherry picked from commit 2a8468ac0132281d2fb9727112e6855c9622d0a5)
---
 tests/core_hotunplug.c | 53 +++++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 13 deletions(-)

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index a639cfb4b4..878efcc7bf 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -29,6 +29,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <signal.h>
 
 #include "i915/gem.h"
 #include "i915/gem_create.h"
@@ -53,6 +54,7 @@ struct hotunplug {
 	const char *failure;
 	bool need_healthcheck;
 	bool has_intel_perf;
+	bool snd_unload;
 };
 
 /* Helpers */
@@ -138,6 +140,34 @@ static void prepare(struct hotunplug *priv)
 static void driver_unbind(struct hotunplug *priv, const char *prefix,
 			  int timeout)
 {
+	/**
+	 * FIXME: Unbinding the i915 driver on affected platforms with
+	 * audio results in a kernel WARN on "i915 raw-wakerefs=1
+	 * wakelocks=1 on cleanup". The below CI friendly user level
+	 * workaround to unload and de-couple audio from IGT testing,
+	 * prevents the warning from appearing. Drop this hack as soon
+	 * as this is fixed in the kernel. unbind/re-bind validation
+	 * on audio side is not robust and we could have potential
+	 * failures blocking display CI, currently this seems to the
+	 * safest and easiest way out.
+	 */
+	if (priv->snd_unload) {
+		igt_terminate_process(SIGTERM, "alsactl");
+
+		/* unbind snd_hda_intel */
+		kick_snd_hda_intel();
+
+		if (igt_kmod_unload("snd_hda_intel", 0)) {
+			priv->snd_unload = false;
+			igt_warn("Could not unload snd_hda_intel\n");
+			igt_kmod_list_loaded();
+			igt_lsof("/dev/snd");
+			igt_skip("Audio is in use, skipping\n");
+		} else {
+			igt_warn("Preventively unloaded snd_hda_intel\n");
+		}
+	}
+
 	local_debug("%sunbinding the driver from the device\n", prefix);
 	priv->failure = "Driver unbind failure!";
 
@@ -166,6 +196,9 @@ static void driver_bind(struct hotunplug *priv, int timeout)
 	igt_fail_on_f(faccessat(priv->fd.sysfs_drv, priv->dev_bus_addr,
 				F_OK, 0),
 		      "Rebound device not present!\n");
+
+	if (priv->snd_unload)
+		igt_kmod_load("snd_hda_intel", NULL);
 }
 
 /* Remove (virtually unplug) the device from its bus */
@@ -574,6 +607,7 @@ igt_main
 		.failure	= NULL,
 		.need_healthcheck = true,
 		.has_intel_perf = false,
+		.snd_unload	= false,
 	};
 
 	igt_fixture {
@@ -585,23 +619,16 @@ igt_main
 		if (is_i915_device(fd_drm)) {
 			uint32_t devid = intel_get_drm_devid(fd_drm);
 
+			if ((IS_HASWELL(devid) || IS_BROADWELL(devid) ||
+			     IS_DG1(devid)) && (igt_kmod_is_loaded("snd_hda_intel"))) {
+				igt_debug("Enable WA to unload snd driver\n");
+				priv.snd_unload = true;
+			}
+
 			gem_quiescent_gpu(fd_drm);
 			igt_require_gem(fd_drm);
 
 			priv.has_intel_perf = local_i915_perf_healthcheck(fd_drm);
-
-			/**
-			 * FIXME: Unbinding the i915 driver on some Haswell
-			 * platforms with Azalia audio results in a kernel WARN
-			 * on "i915 raw-wakerefs=1 wakelocks=1 on cleanup".  The
-			 * below CI friendly user level workaround prevents the
-			 * warning from appearing.  Drop this hack as soon as
-			 * this is fixed in the kernel.
-			 */
-			if (igt_warn_on_f(IS_HASWELL(devid) ||
-					  IS_BROADWELL(devid),
-			    "Manually enabling audio PM to work around a kernel WARN\n"))
-				igt_pm_enable_audio_runtime_pm();
 		}
 
 		/* Make sure subtests always reopen the same device */
-- 
2.25.1

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

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

* [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (17 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 19/24] tests/core_hotunplug: " venkata.sai.patnana
@ 2021-06-03 12:20 ` venkata.sai.patnana
  2021-06-03 12:46   ` Petri Latvala
  2021-06-03 12:41 ` [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties Petri Latvala
  19 siblings, 1 reply; 24+ messages in thread
From: venkata.sai.patnana @ 2021-06-03 12:20 UTC (permalink / raw)
  To: igt-dev

From: Mohammed Khajapasha <mohammed.khajapasha@intel.com>

Enable suppress wakeup hpds for display, monitors like
LG 27UL650-W, 27UK850 goes into power sleep state and
generates long duration hotplug events even the monitor
connected for display, hence enabling suppress wakeup using
debugfs.

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
(cherry picked from commit 46879c55ea49ecc9cefe7051358e647964085253)
---
 lib/igt_debugfs.c | 22 ++++++++++++++++++++++
 lib/igt_debugfs.h |  1 +
 lib/igt_kms.c     |  3 +++
 3 files changed, 26 insertions(+)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 2f58519a2b..503ae7f905 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -675,6 +675,28 @@ void igt_require_hpd_storm_ctl(int drm_fd)
 	close(fd);
 }
 
+/**
+ * igt_suppress_wake_hpd:
+ *
+ * Enable/disable suppress wakeup hpds for power state connectors
+ * Monitors like LG 27UL650-W, 27UK850 goes into power sleep state
+ * and generates long duration hotplug events even the monitor
+ * connected for display.
+ */
+void igt_suppress_wakeup_hpd(int drm_fd, bool enable)
+{
+	int fd = igt_debugfs_open(drm_fd, "i915_suppress_wakeup_hpd", O_WRONLY);
+
+	if (fd < 0) {
+		igt_debug("couldn't open suppress wakeup hpd file\n");
+		return;
+	}
+
+	igt_assert_eq(write(fd, enable ? "1" : "0", 1), 1);
+
+	close(fd);
+}
+
 static igt_pipe_crc_t *
 pipe_crc_new(int fd, enum pipe pipe, const char *source, int flags)
 {
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index d43ba6c6c7..ac97876b85 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -115,6 +115,7 @@ void igt_hpd_storm_set_threshold(int fd, unsigned int threshold);
 void igt_hpd_storm_reset(int fd);
 bool igt_hpd_storm_detected(int fd);
 void igt_require_hpd_storm_ctl(int fd);
+void igt_suppress_wakeup_hpd(int fd, bool enable);
 
 /*
  * Drop caches
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b11c8c27a6..1e3505e1b0 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2140,6 +2140,9 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	display->drm_fd = drm_fd;
 	is_i915_dev = is_i915_device(drm_fd);
 
+	/* enable suppress wakeup hpds */
+	igt_suppress_wakeup_hpd(display->drm_fd, true);
+
 	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1);
 
 	resources = drmModeGetResources(display->drm_fd);
-- 
2.25.1

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

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

* Re: [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties
  2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
                   ` (18 preceding siblings ...)
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display venkata.sai.patnana
@ 2021-06-03 12:41 ` Petri Latvala
  19 siblings, 0 replies; 24+ messages in thread
From: Petri Latvala @ 2021-06-03 12:41 UTC (permalink / raw)
  To: venkata.sai.patnana; +Cc: igt-dev

On Thu, Jun 03, 2021 at 05:50:04PM +0530, venkata.sai.patnana@intel.com wrote:
> From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> 
> Add support for Plane color management properties.
> 
> Cc: Uma Shankar <uma.shankar@intel.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> Signed-off-by: Mukunda Pramodh Kumar <mukunda.pramodh.kumar@intel.com>
> (cherry picked from commit 51099f0939ca28f15fdd99143ca38e0fc52e38fe)

Remove these cherry pick lines from all these commits.

-- 
Petri Latvala



> ---
>  lib/igt_kms.c | 5 +++++
>  lib/igt_kms.h | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index c7c69b6ea0..ae183e822c 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -581,6 +581,11 @@ const char * const igt_plane_prop_names[IGT_NUM_PLANE_PROPS] = {
>  	[IGT_PLANE_ALPHA] = "alpha",
>  	[IGT_PLANE_ZPOS] = "zpos",
>  	[IGT_PLANE_FB_DAMAGE_CLIPS] = "FB_DAMAGE_CLIPS",
> +	[IGT_PLANE_CTM] = "PLANE_CTM",
> +	[IGT_PLANE_GAMMA_MODE] = "PLANE_GAMMA_MODE",
> +	[IGT_PLANE_GAMMA_LUT] = "PLANE_GAMMA_LUT",
> +	[IGT_PLANE_DEGAMMA_MODE] = "PLANE_DEGAMMA_MODE",
> +	[IGT_PLANE_DEGAMMA_LUT] = "PLANE_DEGAMMA_LUT",
>  };
>  
>  const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 8cde24b791..41967bf28a 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -301,6 +301,11 @@ enum igt_atomic_plane_properties {
>         IGT_PLANE_ALPHA,
>         IGT_PLANE_ZPOS,
>         IGT_PLANE_FB_DAMAGE_CLIPS,
> +       IGT_PLANE_CTM,
> +       IGT_PLANE_GAMMA_MODE,
> +       IGT_PLANE_GAMMA_LUT,
> +       IGT_PLANE_DEGAMMA_MODE,
> +       IGT_PLANE_DEGAMMA_LUT,
>         IGT_NUM_PLANE_PROPS
>  };
>  
> -- 
> 2.25.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display venkata.sai.patnana
@ 2021-06-03 12:46   ` Petri Latvala
  0 siblings, 0 replies; 24+ messages in thread
From: Petri Latvala @ 2021-06-03 12:46 UTC (permalink / raw)
  To: venkata.sai.patnana; +Cc: igt-dev

On Thu, Jun 03, 2021 at 05:50:24PM +0530, venkata.sai.patnana@intel.com wrote:
> From: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
> 
> Enable suppress wakeup hpds for display, monitors like
> LG 27UL650-W, 27UK850 goes into power sleep state and
> generates long duration hotplug events even the monitor
> connected for display, hence enabling suppress wakeup using
> debugfs.
> 
> Cc: Petri Latvala <petri.latvala@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
> (cherry picked from commit 46879c55ea49ecc9cefe7051358e647964085253)
> ---
>  lib/igt_debugfs.c | 22 ++++++++++++++++++++++
>  lib/igt_debugfs.h |  1 +
>  lib/igt_kms.c     |  3 +++
>  3 files changed, 26 insertions(+)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 2f58519a2b..503ae7f905 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -675,6 +675,28 @@ void igt_require_hpd_storm_ctl(int drm_fd)
>  	close(fd);
>  }
>  
> +/**
> + * igt_suppress_wake_hpd:
> + *
> + * Enable/disable suppress wakeup hpds for power state connectors
> + * Monitors like LG 27UL650-W, 27UK850 goes into power sleep state
> + * and generates long duration hotplug events even the monitor
> + * connected for display.
> + */
> +void igt_suppress_wakeup_hpd(int drm_fd, bool enable)
> +{
> +	int fd = igt_debugfs_open(drm_fd, "i915_suppress_wakeup_hpd", O_WRONLY);

This file is not in upstream kernel yet. What's the status of that?

-- 
Petri Latvala


> +
> +	if (fd < 0) {
> +		igt_debug("couldn't open suppress wakeup hpd file\n");
> +		return;
> +	}
> +
> +	igt_assert_eq(write(fd, enable ? "1" : "0", 1), 1);
> +
> +	close(fd);
> +}
> +
>  static igt_pipe_crc_t *
>  pipe_crc_new(int fd, enum pipe pipe, const char *source, int flags)
>  {
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index d43ba6c6c7..ac97876b85 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -115,6 +115,7 @@ void igt_hpd_storm_set_threshold(int fd, unsigned int threshold);
>  void igt_hpd_storm_reset(int fd);
>  bool igt_hpd_storm_detected(int fd);
>  void igt_require_hpd_storm_ctl(int fd);
> +void igt_suppress_wakeup_hpd(int fd, bool enable);
>  
>  /*
>   * Drop caches
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index b11c8c27a6..1e3505e1b0 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -2140,6 +2140,9 @@ void igt_display_require(igt_display_t *display, int drm_fd)
>  	display->drm_fd = drm_fd;
>  	is_i915_dev = is_i915_device(drm_fd);
>  
> +	/* enable suppress wakeup hpds */
> +	igt_suppress_wakeup_hpd(display->drm_fd, true);
> +
>  	drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1);
>  
>  	resources = drmModeGetResources(display->drm_fd);
> -- 
> 2.25.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering
  2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering venkata.sai.patnana
@ 2021-06-15  5:45   ` Shankar, Uma
  2021-06-15  5:56     ` Modem, Bhanuprakash
  0 siblings, 1 reply; 24+ messages in thread
From: Shankar, Uma @ 2021-06-15  5:45 UTC (permalink / raw)
  To: Patnana, Venkata Sai, igt-dev, Modem, Bhanuprakash, Varide, Nischal



> -----Original Message-----
> From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of
> venkata.sai.patnana@intel.com
> Sent: Thursday, June 3, 2021 5:50 PM
> To: igt-dev@lists.freedesktop.org
> Subject: [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc
> Dithering
> 
> From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> 
> Many of the display devices have color format support less than the color format of
> the input data (Ex: 8-bit input data and 6-bit display color depth). Then the input data
> will be either truncated or rounded, but this approach usually causes loss of detail
> and also produce large banded areas of a single color that significantly differs from
> the original image.
> 
> Dithering is a technique used to enhance these colors by creating the illusion of
> smoothness by adjusting the nearby pixel color.
> For Eg: Converting 8-bit to 6-bit by modifying the pixel information.
> 
> Dithering should be enabled when a panel color depth is lower than the color depth
> of the framebuffer.
> 
> Even though feature Dithering is there since legacy, there is no specific IGT for this.
> This patch will create New IGT for Dithering.
> And below is the truth table for CRTC Dithering.
> 
> |----------------|---------|-------------|
> |  Frame buffer  |  Panel  |  Dithering  |
> |----------------|---------|-------------|
> |      8 BPC     |  6 BPC  |     Yes     |
> |----------------|---------|-------------|
> |      8 BPC     |  8 BPC  |     No      |
> |----------------|---------|-------------|
> |      8 BPC     | 10 BPC  |     No      |
> |----------------|---------|-------------|
> |     10 BPC     |  6 BPC  |     Yes     |
> |----------------|---------|-------------|
> |     10 BPC     |  8 BPC  |     Yes     |
> |----------------|---------|-------------|
> |     10 BPC     | 10 BPC  |     No      |
> |----------------|---------|-------------|
> |     16 BPC     |  6 BPC  |     Yes     |
> |----------------|---------|-------------|
> |     16 BPC     |  8 BPC  |     Yes     |
> |----------------|---------|-------------|
> |     16 BPC     | 10 BPC  |     Yes     |
> |----------------|---------|-------------|

This test depends on the corresponding kernel driver changes.
https://patchwork.freedesktop.org/series/91383/ : Dithering support 
https://patchwork.freedesktop.org/series/79664/: Debugfs changes
The above are in review. 

I would suggest we consolidate both in 1 common series.

Also the dither IGT tests depends on a debugfs in driver. It also needs to be
merged and available in driver, before this test can go in.

Regards,
Uma Shankar

> v2:
> * Fix commit message (Karthik)
> * Add file author (Karthik)
> * Dynamic subtests for pipe-output combinations (Karthik)
> * Update deprecated pipe name (Karthik)
> * Remove redundant fb creation logic (Karthik)
> 
> v3:
> * Use for_each_pipe_with_valid_output() to simplify the logic (Bhanu)
> * Remove magic numbers to create fb (Karthik)
> * Fix typos & comments (Swati)
> 
> v4:
> * Remove explicit igt_require for a valid output found,
>   igt_subtest_with_dynamic will handle the SKIP (Petri)
> * Limit the execution to a single pipe (Uma)
> 
> v5:
> * SKIP subtest for HDMI with 6 BPC (Bhanu)
> * Fix the usage of valid format to create 8 BPC Framebuffer (Bhanu)
> * Add support for suspend/resume tests (Bhanu)
> * Add few debug prints (Bhanu)
> 
> v6:
> * Limit the execution to 8 BPC panels (Uma)
> * Remove suspend/resume tests (Bhanu)
> 
> v7:
> * Drop max_bpc from debugfs (Uma)
> 
> v8:
> * Run test on all connected outputs (Bhanu)
> * Before exiting the test reset the "max bpc" prop (Bhanu)
> * Before computing the result check that the crtc bpc is updated
>   with the requested one (Bhanu)
> 
> Cc: Swati Sharma <swati2.sharma@intel.com>
> Cc: Karthik B S <karthik.b.s@intel.com>
> Cc: Uma Shankar <uma.shankar@intel.com>
> Cc: Nischal Varide <nischal.varide@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com> (cherry
> picked from commit 24d58fef5070ec7557d8bf778b12becb93dd3315)
> ---
>  tests/kms_dither.c | 250 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build  |   1 +
>  2 files changed, 251 insertions(+)
>  create mode 100644 tests/kms_dither.c
> 
> diff --git a/tests/kms_dither.c b/tests/kms_dither.c new file mode 100644 index
> 0000000000..c25d623f81
> --- /dev/null
> +++ b/tests/kms_dither.c
> @@ -0,0 +1,250 @@
> +/*
> + * Copyright © 2020 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> +obtaining a
> + * copy of this software and associated documentation files (the
> +"Software"),
> + * to deal in the Software without restriction, including without
> +limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> +sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom
> +the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> +next
> + * paragraph) shall be included in all copies or substantial portions
> +of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> +EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
> +SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
> +DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> +OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
> +OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + *
> + * Authors:
> + *     Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> + *
> + */
> +
> +#include "igt.h"
> +#include <fcntl.h>
> +#include <termios.h>
> +#include <unistd.h>
> +
> +IGT_TEST_DESCRIPTION("Test Dithering block status");
> +
> +/* Connector BPC */
> +#define IGT_CONNECTOR_BPC_6		6
> +#define IGT_CONNECTOR_BPC_8		8
> +#define IGT_CONNECTOR_BPC_10		10
> +#define IGT_CONNECTOR_BPC_12		12
> +
> +/* Framebuffer BPC */
> +#define IGT_FRAME_BUFFER_BPC_8		8
> +#define IGT_FRAME_BUFFER_BPC_10		10
> +#define IGT_FRAME_BUFFER_BPC_16		16
> +
> +/* Common test data. */
> +typedef struct data {
> +	igt_display_t display;
> +	igt_plane_t *primary;
> +	igt_output_t *output;
> +	igt_pipe_t *pipe;
> +	drmModeModeInfo *mode;
> +	enum pipe pipe_id;
> +	int drm_fd;
> +	igt_fb_t fb;
> +} data_t;
> +
> +typedef struct {
> +	unsigned int bpc;
> +	unsigned int dither;
> +} dither_status_t;
> +
> +/* Prepare test data. */
> +static void prepare_test(data_t *data, igt_output_t *output, enum pipe
> +pipe) {
> +	igt_display_t *display = &data->display;
> +
> +	data->pipe_id = pipe;
> +	data->pipe = &data->display.pipes[data->pipe_id];
> +	igt_assert(data->pipe);
> +
> +	igt_display_reset(display);
> +
> +	data->output = output;
> +	igt_assert(data->output);
> +
> +	data->mode = igt_output_get_mode(data->output);
> +	igt_assert(data->mode);
> +
> +	data->primary =
> +		igt_pipe_get_plane_type(data->pipe,
> DRM_PLANE_TYPE_PRIMARY);
> +
> +	igt_output_set_pipe(data->output, data->pipe_id); }
> +
> +/* Returns the current state of dithering from the crtc debugfs. */
> +static dither_status_t get_dither_state(data_t *data) {
> +	char buf[256];
> +	char crtc_name[7];
> +	char *start_loc;
> +	int fd, res;
> +	dither_status_t status;
> +
> +	snprintf(crtc_name, 7, "crtc-%d", data->pipe_id);
> +	fd = igt_debugfs_open(data->drm_fd, crtc_name, O_RDONLY);
> +	igt_assert(fd >= 0);
> +
> +	res = igt_debugfs_simple_read(fd, "dither", buf, sizeof(buf));
> +	igt_require(res > 0);
> +	close(fd);
> +
> +	igt_assert(start_loc = strstr(buf, "bpc: "));
> +	igt_assert_eq(sscanf(start_loc, "bpc: %u", &status.bpc), 1);
> +
> +	igt_assert(start_loc = strstr(buf, "Dither: "));
> +	igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.dither), 1);
> +
> +	return status;
> +}
> +
> +static void test_dithering(data_t *data, enum pipe pipe,
> +			   igt_output_t *output,
> +			   int fb_bpc, int fb_format,
> +			   int output_bpc)
> +{
> +	igt_display_t *display = &data->display;
> +	dither_status_t status;
> +	int bpc;
> +
> +	igt_info("Dithering test execution on %s PIPE_%s\n",
> +			output->name, kmstest_pipe_name(pipe));
> +	prepare_test(data, output, pipe);
> +
> +	igt_assert(igt_create_fb(data->drm_fd, data->mode->hdisplay,
> +				 data->mode->vdisplay, fb_format,
> +				 LOCAL_DRM_FORMAT_MOD_NONE, &data->fb));
> +	igt_plane_set_fb(data->primary, &data->fb);
> +	igt_plane_set_size(data->primary, data->mode->hdisplay,
> +data->mode->vdisplay);
> +
> +	bpc = igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC);
> +	igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC,
> output_bpc);
> +	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC :
> +COMMIT_LEGACY);
> +
> +	/*
> +	 * Check the status of Dithering block:
> +	 *
> +	 * Preserve the result & compute later (after clean-up).
> +	 * If fb_bpc is greater than output_bpc, Dithering should be enabled
> +	 * Else disabled
> +	 */
> +	status = get_dither_state(data);
> +
> +	igt_debug("FB BPC:%d, Panel BPC:%d, Pipe BPC:%d, Expected Dither:%s,
> Actual result:%s\n",
> +		  fb_bpc, output_bpc, status.bpc,
> +		  (fb_bpc > output_bpc) ? "Enable": "Disable",
> +		  status.dither ? "Enable": "Disable");
> +
> +       /*
> +	* We must update the Connector max_bpc property back
> +	* Otherwise, previously updated value will stay forever and
> +	* may cause the failures for next/other subtests.
> +	*/
> +	igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC,
> bpc);
> +	igt_plane_set_fb(data->primary, NULL);
> +	igt_output_set_pipe(output, PIPE_NONE);
> +	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC :
> COMMIT_LEGACY);
> +	igt_remove_fb(data->drm_fd, &data->fb);
> +
> +	/* Check if crtc bpc is updated with requested one. */
> +	igt_require_f((status.bpc == output_bpc),
> +			"%s can support max %u-bpc, but requested %d-bpc\n",
> +				output->name, status.bpc, output_bpc);
> +
> +	/* Compute the result. */
> +	if (fb_bpc > output_bpc)
> +		igt_assert_f(status.dither, "(fb_%dbpc > output_%dbpc): Dither
> should be enabled\n",
> +				fb_bpc, output_bpc);
> +	else
> +		igt_assert_f(!status.dither, "(fb_%dbpc <= output_%dbpc): Dither
> should be disabled\n",
> +				fb_bpc, output_bpc);
> +
> +	return;
> +}
> +
> +/* Returns true if an output supports max bpc property & max_bpc >=
> +requested. */ static bool is_supported(igt_output_t *output, int bpc) {
> +        return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
> +		(igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC) >= bpc);
> }
> +
> +static void
> +run_dither_test(data_t *data, int fb_bpc, int fb_format, int
> +output_bpc) {
> +	igt_output_t *output;
> +	igt_display_t *display = &data->display;
> +
> +	for_each_connected_output(display, output) {
> +		enum pipe pipe;
> +
> +		if (!is_supported(output, output_bpc))
> +			continue;
> +
> +		if ((strstr(output->name, "HDMI") != NULL) &&
> +		    (output_bpc == IGT_CONNECTOR_BPC_6))
> +			continue;
> +
> +		for_each_pipe(display, pipe) {
> +			if (igt_pipe_connector_valid(pipe, output)) {
> +				igt_dynamic_f("%s-pipe-%s", output->name,
> kmstest_pipe_name(pipe))
> +					test_dithering(data, pipe, output, fb_bpc,
> +							fb_format, output_bpc);
> +
> +				/* One pipe is enough */
> +				break;
> +			}
> +		}
> +	}
> +}
> +
> +igt_main
> +{
> +	struct {
> +		int fb_bpc;
> +		int format;
> +		int output_bpc;
> +	} tests[] = {
> +		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888,
> IGT_CONNECTOR_BPC_6 },
> +		{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888,
> IGT_CONNECTOR_BPC_8 },
> +	};
> +	int i;
> +	data_t data = { 0 };
> +
> +	igt_fixture {
> +		data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
> +		kmstest_set_vt_graphics_mode();
> +
> +		igt_display_require(&data.display, data.drm_fd);
> +		igt_display_require_output(&data.display);
> +	}
> +
> +	for (i = 0; i < ARRAY_SIZE(tests); i++) {
> +		igt_describe_f("Framebuffer BPC:%d, Panel BPC:%d, Expected
> Dither:%s\n",
> +			       tests[i].fb_bpc, tests[i].output_bpc,
> +			       (tests[i].fb_bpc > tests[i].output_bpc) ?
> +							"Enable": "Disable");
> +
> +		igt_subtest_with_dynamic_f("FB-%dBPC-Vs-Panel-%dBPC",
> +				tests[i].fb_bpc, tests[i].output_bpc)
> +			run_dither_test(&data,
> +					tests[i].fb_bpc,
> +					tests[i].format,
> +					tests[i].output_bpc);
> +	}
> +
> +	igt_fixture {
> +		igt_display_fini(&data.display);
> +	}
> +}
> diff --git a/tests/meson.build b/tests/meson.build index 19cc4ebe0d..ff3979207d
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -28,6 +28,7 @@ test_progs = [
>  	'kms_cursor_crc',
>  	'kms_cursor_edge_walk',
>  	'kms_cursor_legacy',
> +	'kms_dither',
>  	'kms_dp_aux_dev',
>  	'kms_dp_dsc',
>  	'kms_dp_tiled_display',
> --
> 2.25.1
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

* Re: [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering
  2021-06-15  5:45   ` Shankar, Uma
@ 2021-06-15  5:56     ` Modem, Bhanuprakash
  0 siblings, 0 replies; 24+ messages in thread
From: Modem, Bhanuprakash @ 2021-06-15  5:56 UTC (permalink / raw)
  To: Shankar, Uma, Patnana, Venkata Sai, igt-dev, Varide, Nischal

> From: Shankar, Uma <uma.shankar@intel.com>
> Sent: Tuesday, June 15, 2021 11:16 AM
> To: Patnana, Venkata Sai <venkata.sai.patnana@intel.com>; igt-
> dev@lists.freedesktop.org; Modem, Bhanuprakash <bhanuprakash.modem@intel.com>;
> Varide, Nischal <nischal.varide@intel.com>
> Subject: RE: [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to
> validate crtc Dithering
> 
> 
> 
> > -----Original Message-----
> > From: igt-dev <igt-dev-bounces@lists.freedesktop.org> On Behalf Of
> > venkata.sai.patnana@intel.com
> > Sent: Thursday, June 3, 2021 5:50 PM
> > To: igt-dev@lists.freedesktop.org
> > Subject: [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate
> crtc
> > Dithering
> >
> > From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> >
> > Many of the display devices have color format support less than the color
> format of
> > the input data (Ex: 8-bit input data and 6-bit display color depth). Then
> the input data
> > will be either truncated or rounded, but this approach usually causes loss
> of detail
> > and also produce large banded areas of a single color that significantly
> differs from
> > the original image.
> >
> > Dithering is a technique used to enhance these colors by creating the
> illusion of
> > smoothness by adjusting the nearby pixel color.
> > For Eg: Converting 8-bit to 6-bit by modifying the pixel information.
> >
> > Dithering should be enabled when a panel color depth is lower than the color
> depth
> > of the framebuffer.
> >
> > Even though feature Dithering is there since legacy, there is no specific
> IGT for this.
> > This patch will create New IGT for Dithering.
> > And below is the truth table for CRTC Dithering.
> >
> > |----------------|---------|-------------|
> > |  Frame buffer  |  Panel  |  Dithering  |
> > |----------------|---------|-------------|
> > |      8 BPC     |  6 BPC  |     Yes     |
> > |----------------|---------|-------------|
> > |      8 BPC     |  8 BPC  |     No      |
> > |----------------|---------|-------------|
> > |      8 BPC     | 10 BPC  |     No      |
> > |----------------|---------|-------------|
> > |     10 BPC     |  6 BPC  |     Yes     |
> > |----------------|---------|-------------|
> > |     10 BPC     |  8 BPC  |     Yes     |
> > |----------------|---------|-------------|
> > |     10 BPC     | 10 BPC  |     No      |
> > |----------------|---------|-------------|
> > |     16 BPC     |  6 BPC  |     Yes     |
> > |----------------|---------|-------------|
> > |     16 BPC     |  8 BPC  |     Yes     |
> > |----------------|---------|-------------|
> > |     16 BPC     | 10 BPC  |     Yes     |
> > |----------------|---------|-------------|
> 
> This test depends on the corresponding kernel driver changes.
> https://patchwork.freedesktop.org/series/91383/ : Dithering support
> https://patchwork.freedesktop.org/series/79664/: Debugfs changes
> The above are in review.
> 
> I would suggest we consolidate both in 1 common series.

As we doesn't have a test coverage for Dithering, it was intentional to
have 2 patches:
 
* one for legacy (dither at end of the pipe)
* other to extend it for dither at end of CC block.

- Bhanu

> 
> Also the dither IGT tests depends on a debugfs in driver. It also needs to be
> merged and available in driver, before this test can go in.
> 
> Regards,
> Uma Shankar
> 
> > v2:
> > * Fix commit message (Karthik)
> > * Add file author (Karthik)
> > * Dynamic subtests for pipe-output combinations (Karthik)
> > * Update deprecated pipe name (Karthik)
> > * Remove redundant fb creation logic (Karthik)
> >
> > v3:
> > * Use for_each_pipe_with_valid_output() to simplify the logic (Bhanu)
> > * Remove magic numbers to create fb (Karthik)
> > * Fix typos & comments (Swati)
> >
> > v4:
> > * Remove explicit igt_require for a valid output found,
> >   igt_subtest_with_dynamic will handle the SKIP (Petri)
> > * Limit the execution to a single pipe (Uma)
> >
> > v5:
> > * SKIP subtest for HDMI with 6 BPC (Bhanu)
> > * Fix the usage of valid format to create 8 BPC Framebuffer (Bhanu)
> > * Add support for suspend/resume tests (Bhanu)
> > * Add few debug prints (Bhanu)
> >
> > v6:
> > * Limit the execution to 8 BPC panels (Uma)
> > * Remove suspend/resume tests (Bhanu)
> >
> > v7:
> > * Drop max_bpc from debugfs (Uma)
> >
> > v8:
> > * Run test on all connected outputs (Bhanu)
> > * Before exiting the test reset the "max bpc" prop (Bhanu)
> > * Before computing the result check that the crtc bpc is updated
> >   with the requested one (Bhanu)
> >
> > Cc: Swati Sharma <swati2.sharma@intel.com>
> > Cc: Karthik B S <karthik.b.s@intel.com>
> > Cc: Uma Shankar <uma.shankar@intel.com>
> > Cc: Nischal Varide <nischal.varide@intel.com>
> > Cc: Petri Latvala <petri.latvala@intel.com>
> > Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com> (cherry
> > picked from commit 24d58fef5070ec7557d8bf778b12becb93dd3315)
> > ---
> >  tests/kms_dither.c | 250 +++++++++++++++++++++++++++++++++++++++++++++
> >  tests/meson.build  |   1 +
> >  2 files changed, 251 insertions(+)
> >  create mode 100644 tests/kms_dither.c
> >
> > diff --git a/tests/kms_dither.c b/tests/kms_dither.c new file mode 100644
> index
> > 0000000000..c25d623f81
> > --- /dev/null
> > +++ b/tests/kms_dither.c
> > @@ -0,0 +1,250 @@
> > +/*
> > + * Copyright © 2020 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person
> > +obtaining a
> > + * copy of this software and associated documentation files (the
> > +"Software"),
> > + * to deal in the Software without restriction, including without
> > +limitation
> > + * the rights to use, copy, modify, merge, publish, distribute,
> > +sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom
> > +the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the
> > +next
> > + * paragraph) shall be included in all copies or substantial portions
> > +of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> > +EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> > +MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
> > +SHALL
> > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM,
> > +DAMAGES OR
> > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
> > +OTHERWISE,
> > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
> > +OR
> > + * OTHER DEALINGS IN THE SOFTWARE.
> > + *
> > + * Authors:
> > + *     Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> > + *
> > + */
> > +
> > +#include "igt.h"
> > +#include <fcntl.h>
> > +#include <termios.h>
> > +#include <unistd.h>
> > +
> > +IGT_TEST_DESCRIPTION("Test Dithering block status");
> > +
> > +/* Connector BPC */
> > +#define IGT_CONNECTOR_BPC_66
> > +#define IGT_CONNECTOR_BPC_88
> > +#define IGT_CONNECTOR_BPC_1010
> > +#define IGT_CONNECTOR_BPC_1212
> > +
> > +/* Framebuffer BPC */
> > +#define IGT_FRAME_BUFFER_BPC_88
> > +#define IGT_FRAME_BUFFER_BPC_1010
> > +#define IGT_FRAME_BUFFER_BPC_1616
> > +
> > +/* Common test data. */
> > +typedef struct data {
> > +igt_display_t display;
> > +igt_plane_t *primary;
> > +igt_output_t *output;
> > +igt_pipe_t *pipe;
> > +drmModeModeInfo *mode;
> > +enum pipe pipe_id;
> > +int drm_fd;
> > +igt_fb_t fb;
> > +} data_t;
> > +
> > +typedef struct {
> > +unsigned int bpc;
> > +unsigned int dither;
> > +} dither_status_t;
> > +
> > +/* Prepare test data. */
> > +static void prepare_test(data_t *data, igt_output_t *output, enum pipe
> > +pipe) {
> > +igt_display_t *display = &data->display;
> > +
> > +data->pipe_id = pipe;
> > +data->pipe = &data->display.pipes[data->pipe_id];
> > +igt_assert(data->pipe);
> > +
> > +igt_display_reset(display);
> > +
> > +data->output = output;
> > +igt_assert(data->output);
> > +
> > +data->mode = igt_output_get_mode(data->output);
> > +igt_assert(data->mode);
> > +
> > +data->primary =
> > +igt_pipe_get_plane_type(data->pipe,
> > DRM_PLANE_TYPE_PRIMARY);
> > +
> > +igt_output_set_pipe(data->output, data->pipe_id); }
> > +
> > +/* Returns the current state of dithering from the crtc debugfs. */
> > +static dither_status_t get_dither_state(data_t *data) {
> > +char buf[256];
> > +char crtc_name[7];
> > +char *start_loc;
> > +int fd, res;
> > +dither_status_t status;
> > +
> > +snprintf(crtc_name, 7, "crtc-%d", data->pipe_id);
> > +fd = igt_debugfs_open(data->drm_fd, crtc_name, O_RDONLY);
> > +igt_assert(fd >= 0);
> > +
> > +res = igt_debugfs_simple_read(fd, "dither", buf, sizeof(buf));
> > +igt_require(res > 0);
> > +close(fd);
> > +
> > +igt_assert(start_loc = strstr(buf, "bpc: "));
> > +igt_assert_eq(sscanf(start_loc, "bpc: %u", &status.bpc), 1);
> > +
> > +igt_assert(start_loc = strstr(buf, "Dither: "));
> > +igt_assert_eq(sscanf(start_loc, "Dither: %u", &status.dither), 1);
> > +
> > +return status;
> > +}
> > +
> > +static void test_dithering(data_t *data, enum pipe pipe,
> > +   igt_output_t *output,
> > +   int fb_bpc, int fb_format,
> > +   int output_bpc)
> > +{
> > +igt_display_t *display = &data->display;
> > +dither_status_t status;
> > +int bpc;
> > +
> > +igt_info("Dithering test execution on %s PIPE_%s\n",
> > +output->name, kmstest_pipe_name(pipe));
> > +prepare_test(data, output, pipe);
> > +
> > +igt_assert(igt_create_fb(data->drm_fd, data->mode->hdisplay,
> > + data->mode->vdisplay, fb_format,
> > + LOCAL_DRM_FORMAT_MOD_NONE, &data->fb));
> > +igt_plane_set_fb(data->primary, &data->fb);
> > +igt_plane_set_size(data->primary, data->mode->hdisplay,
> > +data->mode->vdisplay);
> > +
> > +bpc = igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC);
> > +igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC,
> > output_bpc);
> > +igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC :
> > +COMMIT_LEGACY);
> > +
> > +/*
> > + * Check the status of Dithering block:
> > + *
> > + * Preserve the result & compute later (after clean-up).
> > + * If fb_bpc is greater than output_bpc, Dithering should be enabled
> > + * Else disabled
> > + */
> > +status = get_dither_state(data);
> > +
> > +igt_debug("FB BPC:%d, Panel BPC:%d, Pipe BPC:%d, Expected Dither:%s,
> > Actual result:%s\n",
> > +  fb_bpc, output_bpc, status.bpc,
> > +  (fb_bpc > output_bpc) ? "Enable": "Disable",
> > +  status.dither ? "Enable": "Disable");
> > +
> > +       /*
> > +* We must update the Connector max_bpc property back
> > +* Otherwise, previously updated value will stay forever and
> > +* may cause the failures for next/other subtests.
> > +*/
> > +igt_output_set_prop_value(data->output, IGT_CONNECTOR_MAX_BPC,
> > bpc);
> > +igt_plane_set_fb(data->primary, NULL);
> > +igt_output_set_pipe(output, PIPE_NONE);
> > +igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC :
> > COMMIT_LEGACY);
> > +igt_remove_fb(data->drm_fd, &data->fb);
> > +
> > +/* Check if crtc bpc is updated with requested one. */
> > +igt_require_f((status.bpc == output_bpc),
> > +"%s can support max %u-bpc, but requested %d-bpc\n",
> > +output->name, status.bpc, output_bpc);
> > +
> > +/* Compute the result. */
> > +if (fb_bpc > output_bpc)
> > +igt_assert_f(status.dither, "(fb_%dbpc > output_%dbpc): Dither
> > should be enabled\n",
> > +fb_bpc, output_bpc);
> > +else
> > +igt_assert_f(!status.dither, "(fb_%dbpc <= output_%dbpc): Dither
> > should be disabled\n",
> > +fb_bpc, output_bpc);
> > +
> > +return;
> > +}
> > +
> > +/* Returns true if an output supports max bpc property & max_bpc >=
> > +requested. */ static bool is_supported(igt_output_t *output, int bpc) {
> > +        return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
> > +(igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC) >= bpc);
> > }
> > +
> > +static void
> > +run_dither_test(data_t *data, int fb_bpc, int fb_format, int
> > +output_bpc) {
> > +igt_output_t *output;
> > +igt_display_t *display = &data->display;
> > +
> > +for_each_connected_output(display, output) {
> > +enum pipe pipe;
> > +
> > +if (!is_supported(output, output_bpc))
> > +continue;
> > +
> > +if ((strstr(output->name, "HDMI") != NULL) &&
> > +    (output_bpc == IGT_CONNECTOR_BPC_6))
> > +continue;
> > +
> > +for_each_pipe(display, pipe) {
> > +if (igt_pipe_connector_valid(pipe, output)) {
> > +igt_dynamic_f("%s-pipe-%s", output->name,
> > kmstest_pipe_name(pipe))
> > +test_dithering(data, pipe, output, fb_bpc,
> > +fb_format, output_bpc);
> > +
> > +/* One pipe is enough */
> > +break;
> > +}
> > +}
> > +}
> > +}
> > +
> > +igt_main
> > +{
> > +struct {
> > +int fb_bpc;
> > +int format;
> > +int output_bpc;
> > +} tests[] = {
> > +{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888,
> > IGT_CONNECTOR_BPC_6 },
> > +{ IGT_FRAME_BUFFER_BPC_8, DRM_FORMAT_XRGB8888,
> > IGT_CONNECTOR_BPC_8 },
> > +};
> > +int i;
> > +data_t data = { 0 };
> > +
> > +igt_fixture {
> > +data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
> > +kmstest_set_vt_graphics_mode();
> > +
> > +igt_display_require(&data.display, data.drm_fd);
> > +igt_display_require_output(&data.display);
> > +}
> > +
> > +for (i = 0; i < ARRAY_SIZE(tests); i++) {
> > +igt_describe_f("Framebuffer BPC:%d, Panel BPC:%d, Expected
> > Dither:%s\n",
> > +       tests[i].fb_bpc, tests[i].output_bpc,
> > +       (tests[i].fb_bpc > tests[i].output_bpc) ?
> > +"Enable": "Disable");
> > +
> > +igt_subtest_with_dynamic_f("FB-%dBPC-Vs-Panel-%dBPC",
> > +tests[i].fb_bpc, tests[i].output_bpc)
> > +run_dither_test(&data,
> > +tests[i].fb_bpc,
> > +tests[i].format,
> > +tests[i].output_bpc);
> > +}
> > +
> > +igt_fixture {
> > +igt_display_fini(&data.display);
> > +}
> > +}
> > diff --git a/tests/meson.build b/tests/meson.build index
> 19cc4ebe0d..ff3979207d
> > 100644
> > --- a/tests/meson.build
> > +++ b/tests/meson.build
> > @@ -28,6 +28,7 @@ test_progs = [
> >  'kms_cursor_crc',
> >  'kms_cursor_edge_walk',
> >  'kms_cursor_legacy',
> > +'kms_dither',
> >  'kms_dp_aux_dev',
> >  'kms_dp_dsc',
> >  'kms_dp_tiled_display',
> > --
> > 2.25.1
> >
> > _______________________________________________
> > igt-dev mailing list
> > igt-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/igt-dev

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

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

end of thread, other threads:[~2021-06-15  5:57 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 12:20 [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 02/24] kms_color_helper: Add helper functions for plane color mgmt venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 03/24] tests/kms_color: New subtests for Plane gamma venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 04/24] tests/kms_color: New subtests for Plane degamma venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 05/24] tests/kms_color: New subtests for Plane CTM venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 06/24] tests/kms_color_chamelium: New subtests for Plane gamma venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 07/24] tests/kms_color_chamelium: New subtests for Plane degamma venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 08/24] tests/kms_color_chamelium: New subtests for Plane CTM venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 09/24] lib/igt_kms: Add pipe color mgmt properties venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 10/24] kms_color_helper: Add helper functions to support logarithmic gamma mode venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 11/24] tests/kms_color: Extended IGT tests " venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 12/24] tests/kms_color_chamelium: " venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 13/24] tests/kms_color: Optimize plane ctm test venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 14/24] tests/kms_color_chamelium: " venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 15/24] tests/kms_dither: New IGT to validate crtc Dithering venkata.sai.patnana
2021-06-15  5:45   ` Shankar, Uma
2021-06-15  5:56     ` Modem, Bhanuprakash
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 16/24] tests/kms_dither: Validate dither after CC blocks venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 17/24] tests/kms_dither: Dont assert if debugfs is not present venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 18/24] tests/device_reset: Unload snd driver before i915 unbind venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 19/24] tests/core_hotunplug: " venkata.sai.patnana
2021-06-03 12:20 ` [igt-dev] [PATCH i-g-t 21/24] lib/igt_debugfs: Add suppress wakeup hpds enable for display venkata.sai.patnana
2021-06-03 12:46   ` Petri Latvala
2021-06-03 12:41 ` [igt-dev] [PATCH i-g-t 01/24] lib/igt_kms: Add plane color mgmt properties Petri Latvala

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.