All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests
@ 2021-09-03 16:15 Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 1/6] tests/kms_color: Refactor invalid LUT size tests Ville Syrjala
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Updated set of 3D LUT tests and associated refactoring/fixes.

Cc: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>

Ville Syrjälä (6):
  tests/kms_color: Refactor invalid LUT size tests
  tests/kms_color: Store r/g/b separately for LUT color tests
  tests/kms_color: Pass pipe to invalid LUT size tests
  tests/kms_color: Run each subtest only for a single connector
  lib/kms: Add GAMMA_LUT_3D support
  tests/kms_color: Add GAMMA_LUT_3D tests

 lib/igt_kms.c            |   5 +
 lib/igt_kms.h            |   2 +
 tests/kms_color.c        | 782 ++++++++++++++++++++++-----------------
 tests/kms_color_helper.c | 181 +++++----
 tests/kms_color_helper.h |  27 +-
 5 files changed, 587 insertions(+), 410 deletions(-)

-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 1/6] tests/kms_color: Refactor invalid LUT size tests
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 2/6] tests/kms_color: Store r/g/b separately for LUT color tests Ville Syrjala
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reuse the same code for all invalid LUT size tests.

v2: Drop the pointless return statements in void functions

Cc: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_color_helper.c | 81 +++++++++++++---------------------------
 1 file changed, 26 insertions(+), 55 deletions(-)

diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 5f223a88129f..68fa5f0e42ea 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -277,77 +277,48 @@ pipe_set_property_blob(igt_pipe_t *pipe,
 				       COMMIT_ATOMIC : COMMIT_LEGACY);
 }
 
-void
-invalid_gamma_lut_sizes(data_t *data)
+static void
+invalid_lut_sizes(data_t *data, enum igt_atomic_crtc_properties prop, int size)
 {
 	igt_display_t *display = &data->display;
 	igt_pipe_t *pipe = &display->pipes[0];
-	size_t gamma_lut_size = data->gamma_lut_size *
-				sizeof(struct drm_color_lut);
-	struct drm_color_lut *gamma_lut;
+	struct drm_color_lut *lut;
+	size_t lut_size = size * sizeof(lut[0]);
 
-	igt_require(igt_pipe_obj_has_prop(pipe, IGT_CRTC_GAMMA_LUT));
+	igt_require(igt_pipe_obj_has_prop(pipe, prop));
 
-	gamma_lut = malloc(gamma_lut_size * 2);
+	lut = malloc(lut_size * 2);
 
 	igt_display_commit2(display,
 			    display->is_atomic ?
 			    COMMIT_ATOMIC : COMMIT_LEGACY);
 
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_GAMMA_LUT,
-					     gamma_lut, 1), -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_GAMMA_LUT,
-					     gamma_lut, gamma_lut_size + 1),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_GAMMA_LUT,
-					     gamma_lut, gamma_lut_size - 1),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_GAMMA_LUT,
-					     gamma_lut, gamma_lut_size +
-					     sizeof(struct drm_color_lut)),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob_id(pipe, IGT_CRTC_GAMMA_LUT,
-		      pipe->crtc_id), -EINVAL);
-	igt_assert_eq(pipe_set_property_blob_id(pipe, IGT_CRTC_GAMMA_LUT,
-		      4096 * 4096), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob(pipe, prop, lut,
+					     1), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob(pipe, prop, lut,
+					     lut_size + 1), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob(pipe, prop, lut,
+					     lut_size - 1), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob(pipe, prop, lut,
+					     lut_size + sizeof(struct drm_color_lut)), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob_id(pipe, prop,
+						pipe->crtc_id), -EINVAL);
+	igt_assert_eq(pipe_set_property_blob_id(pipe, prop,
+						4096 * 4096), -EINVAL);
 
-	free(gamma_lut);
+	free(lut);
+}
+
+void
+invalid_gamma_lut_sizes(data_t *data)
+{
+	invalid_lut_sizes(data, IGT_CRTC_GAMMA_LUT, data->gamma_lut_size);
 }
 
 void
 invalid_degamma_lut_sizes(data_t *data)
 {
-	igt_display_t *display = &data->display;
-	igt_pipe_t *pipe = &display->pipes[0];
-	size_t degamma_lut_size = data->degamma_lut_size *
-				  sizeof(struct drm_color_lut);
-	struct drm_color_lut *degamma_lut;
-
-	igt_require(igt_pipe_obj_has_prop(pipe, IGT_CRTC_DEGAMMA_LUT));
-
-	degamma_lut = malloc(degamma_lut_size * 2);
-
-	igt_display_commit2(display, display->is_atomic ?
-			    COMMIT_ATOMIC : COMMIT_LEGACY);
-
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_DEGAMMA_LUT,
-					     degamma_lut, 1), -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_DEGAMMA_LUT,
-					     degamma_lut, degamma_lut_size + 1),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_DEGAMMA_LUT,
-					     degamma_lut, degamma_lut_size - 1),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob(pipe, IGT_CRTC_DEGAMMA_LUT,
-					     degamma_lut, degamma_lut_size +
-					     sizeof(struct drm_color_lut)),
-					     -EINVAL);
-	igt_assert_eq(pipe_set_property_blob_id(pipe, IGT_CRTC_DEGAMMA_LUT,
-						pipe->crtc_id), -EINVAL);
-	igt_assert_eq(pipe_set_property_blob_id(pipe, IGT_CRTC_DEGAMMA_LUT,
-						4096 * 4096), -EINVAL);
-
-	free(degamma_lut);
+	invalid_lut_sizes(data, IGT_CRTC_DEGAMMA_LUT, data->degamma_lut_size);
 }
 
 void invalid_ctm_matrix_sizes(data_t *data)
-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 2/6] tests/kms_color: Store r/g/b separately for LUT color tests
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 1/6] tests/kms_color: Refactor invalid LUT size tests Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 3/6] tests/kms_color: Pass pipe to invalid LUT size tests Ville Syrjala
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Store the r/g/b values separately for each LUT. A lot of hw
has a separate 1D LUT for each channel, so with this we can
potentially do more interesting tests. Also needed for 3D LUTs
(if we should ever support them).

Reviewed-by: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_color_helper.c | 29 +++++++++++++++++++----------
 tests/kms_color_helper.h |  2 +-
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 68fa5f0e42ea..8b08cdaeea5f 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -103,14 +103,19 @@ void free_lut(gamma_lut_t *gamma)
 	free(gamma);
 }
 
+static void set_rgb(color_t *coeff, double value)
+{
+	coeff->r = coeff->g = coeff->b = value;
+}
+
 gamma_lut_t *generate_table(int lut_size, double exp)
 {
 	gamma_lut_t *gamma = alloc_lut(lut_size);
 	int i;
 
-	gamma->coeffs[0] = 0.0;
+	set_rgb(&gamma->coeffs[0], 0.0);
 	for (i = 1; i < lut_size; i++)
-		gamma->coeffs[i] = pow(i * 1.0 / (lut_size - 1), exp);
+		set_rgb(&gamma->coeffs[i], pow(i * 1.0 / (lut_size - 1), exp));
 
 	return gamma;
 }
@@ -120,9 +125,9 @@ gamma_lut_t *generate_table_max(int lut_size)
 	gamma_lut_t *gamma = alloc_lut(lut_size);
 	int i;
 
-	gamma->coeffs[0] = 0.0;
+	set_rgb(&gamma->coeffs[0], 0.0);
 	for (i = 1; i < lut_size; i++)
-		gamma->coeffs[i] = 1.0;
+		set_rgb(&gamma->coeffs[i], 1.0);
 
 	return gamma;
 }
@@ -133,7 +138,7 @@ gamma_lut_t *generate_table_zero(int lut_size)
 	int i;
 
 	for (i = 0; i < lut_size; i++)
-		gamma->coeffs[i] = 0.0;
+		set_rgb(&gamma->coeffs[i], 0.0);
 
 	return gamma;
 }
@@ -158,7 +163,9 @@ struct drm_color_lut *coeffs_to_lut(data_t *data,
 	if (IS_CHERRYVIEW(data->devid))
 		lut_size -= 1;
 	for (i = 0; i < lut_size; i++) {
-		uint32_t v = (gamma->coeffs[i] * max_value);
+		uint32_t r = gamma->coeffs[i].r * max_value;
+		uint32_t g = gamma->coeffs[i].g * max_value;
+		uint32_t b = gamma->coeffs[i].b * max_value;
 
 		/*
 		 * Hardware might encode colors on a different number of bits
@@ -166,11 +173,13 @@ 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;
+		r &= mask;
+		g &= mask;
+		b &= mask;
 
-		lut[i].red = v;
-		lut[i].green = v;
-		lut[i].blue = v;
+		lut[i].red = r;
+		lut[i].green = g;
+		lut[i].blue = b;
 	}
 
 	if (IS_CHERRYVIEW(data->devid))
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index 88890724c2e4..3f49e7cae4c0 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -61,7 +61,7 @@ typedef struct {
 
 typedef struct {
 	int size;
-	double coeffs[];
+	color_t coeffs[];
 } gamma_lut_t;
 
 void paint_gradient_rectangles(data_t *data,
-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 3/6] tests/kms_color: Pass pipe to invalid LUT size tests
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 1/6] tests/kms_color: Refactor invalid LUT size tests Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 2/6] tests/kms_color: Store r/g/b separately for LUT color tests Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 4/6] tests/kms_color: Run each subtest only for a single connector Ville Syrjala
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Each pipe can have a different LUT sizes, so run the invalid LUT
size tests once for each pipe.

This also makes sure data->(de)gamma_lut_size are properly initialized
prior to running these subtests.

Cc: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_color.c        | 73 +++++++++++++++++++++++++---------------
 tests/kms_color_helper.c | 17 +++++-----
 tests/kms_color_helper.h |  7 ++--
 3 files changed, 58 insertions(+), 39 deletions(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 9105076aba4f..dabc6963e9e0 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -638,6 +638,26 @@ static void test_pipe_limited_range_ctm(data_t *data,
 }
 #endif
 
+static void
+prep_pipe(data_t *data, enum pipe p)
+{
+	igt_require_pipe(&data->display, p);
+
+	if (igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_DEGAMMA_LUT_SIZE)) {
+		data->degamma_lut_size =
+			igt_pipe_obj_get_prop(&data->display.pipes[p],
+					      IGT_CRTC_DEGAMMA_LUT_SIZE);
+		igt_assert_lt(0, data->degamma_lut_size);
+	}
+
+	if (igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_GAMMA_LUT_SIZE)) {
+		data->gamma_lut_size =
+			igt_pipe_obj_get_prop(&data->display.pipes[p],
+					      IGT_CRTC_GAMMA_LUT_SIZE);
+		igt_assert_lt(0, data->gamma_lut_size);
+	}
+}
+
 static void
 run_tests_for_pipe(data_t *data, enum pipe p)
 {
@@ -652,10 +672,10 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 	};
 
 	igt_fixture {
+		prep_pipe(data, p);
+
 		igt_require_pipe_crc(data->drm_fd);
 
-		igt_require_pipe(&data->display, p);
-
 		pipe = &data->display.pipes[p];
 		igt_require(pipe->n_planes >= 0);
 
@@ -665,20 +685,6 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 						  primary->pipe->pipe,
 						  INTEL_PIPE_CRC_SOURCE_AUTO);
 
-		if (igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_DEGAMMA_LUT_SIZE)) {
-			data->degamma_lut_size =
-				igt_pipe_obj_get_prop(&data->display.pipes[p],
-						      IGT_CRTC_DEGAMMA_LUT_SIZE);
-			igt_assert_lt(0, data->degamma_lut_size);
-		}
-
-		if (igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_GAMMA_LUT_SIZE)) {
-			data->gamma_lut_size =
-				igt_pipe_obj_get_prop(&data->display.pipes[p],
-						      IGT_CRTC_GAMMA_LUT_SIZE);
-			igt_assert_lt(0, data->gamma_lut_size);
-		}
-
 		igt_display_require_output_on_pipe(&data->display, p);
 	}
 
@@ -865,6 +871,25 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 	}
 }
 
+static void
+run_invalid_tests_for_pipe(data_t *data, enum pipe p)
+{
+	igt_fixture
+		prep_pipe(data, p);
+
+	igt_describe("Negative check for invalid gamma lut sizes");
+	igt_subtest_f("pipe-%s-invalid-gamma-lut-sizes", kmstest_pipe_name(p))
+		invalid_gamma_lut_sizes(data, p);
+
+	igt_describe("Negative check for invalid degamma lut sizes");
+	igt_subtest_f("pipe-%s-invalid-degamma-lut-sizes", kmstest_pipe_name(p))
+		invalid_degamma_lut_sizes(data, p);
+
+	igt_describe("Negative check for color tranformation matrix sizes");
+	igt_subtest_f("pipe-%s-invalid-ctm-matrix-sizes", kmstest_pipe_name(p))
+		invalid_ctm_matrix_sizes(data, p);
+}
+
 igt_main
 {
 	data_t data = {};
@@ -879,21 +904,13 @@ igt_main
 		igt_display_require(&data.display, data.drm_fd);
 	}
 
-	for_each_pipe_static(pipe)
+	for_each_pipe_static(pipe) {
 		igt_subtest_group
 			run_tests_for_pipe(&data, pipe);
 
-	igt_describe("Negative check for invalid gamma lut sizes");
-	igt_subtest_f("pipe-invalid-gamma-lut-sizes")
-		invalid_gamma_lut_sizes(&data);
-
-	igt_describe("Negative check for invalid degamma lut sizes");
-	igt_subtest_f("pipe-invalid-degamma-lut-sizes")
-		invalid_degamma_lut_sizes(&data);
-
-	igt_describe("Negative check for color tranformation matrix sizes");
-	igt_subtest_f("pipe-invalid-ctm-matrix-sizes")
-		invalid_ctm_matrix_sizes(&data);
+		igt_subtest_group
+			run_invalid_tests_for_pipe(&data, pipe);
+	}
 
 	igt_fixture {
 		igt_display_fini(&data.display);
diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 8b08cdaeea5f..d71e7bb2e6f9 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -287,10 +287,11 @@ pipe_set_property_blob(igt_pipe_t *pipe,
 }
 
 static void
-invalid_lut_sizes(data_t *data, enum igt_atomic_crtc_properties prop, int size)
+invalid_lut_sizes(data_t *data, enum pipe p,
+		  enum igt_atomic_crtc_properties prop, int size)
 {
 	igt_display_t *display = &data->display;
-	igt_pipe_t *pipe = &display->pipes[0];
+	igt_pipe_t *pipe = &display->pipes[p];
 	struct drm_color_lut *lut;
 	size_t lut_size = size * sizeof(lut[0]);
 
@@ -319,21 +320,21 @@ invalid_lut_sizes(data_t *data, enum igt_atomic_crtc_properties prop, int size)
 }
 
 void
-invalid_gamma_lut_sizes(data_t *data)
+invalid_gamma_lut_sizes(data_t *data, enum pipe p)
 {
-	invalid_lut_sizes(data, IGT_CRTC_GAMMA_LUT, data->gamma_lut_size);
+	invalid_lut_sizes(data, p, IGT_CRTC_GAMMA_LUT, data->gamma_lut_size);
 }
 
 void
-invalid_degamma_lut_sizes(data_t *data)
+invalid_degamma_lut_sizes(data_t *data, enum pipe p)
 {
-	invalid_lut_sizes(data, IGT_CRTC_DEGAMMA_LUT, data->degamma_lut_size);
+	invalid_lut_sizes(data, p, IGT_CRTC_DEGAMMA_LUT, data->degamma_lut_size);
 }
 
-void invalid_ctm_matrix_sizes(data_t *data)
+void invalid_ctm_matrix_sizes(data_t *data, enum pipe p)
 {
 	igt_display_t *display = &data->display;
-	igt_pipe_t *pipe = &display->pipes[0];
+	igt_pipe_t *pipe = &display->pipes[p];
 	void *ptr;
 
 	igt_require(igt_pipe_obj_has_prop(pipe, IGT_CRTC_CTM));
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index 3f49e7cae4c0..bb6f0054f388 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -103,8 +103,9 @@ int pipe_set_property_blob_id(igt_pipe_t *pipe,
 int pipe_set_property_blob(igt_pipe_t *pipe,
 			   enum igt_atomic_crtc_properties prop,
 			   void *ptr, size_t length);
-void invalid_gamma_lut_sizes(data_t *data);
-void invalid_degamma_lut_sizes(data_t *data);
-void invalid_ctm_matrix_sizes(data_t *data);
+void invalid_gamma_lut_sizes(data_t *data, enum pipe p);
+void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
+void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
+
 #endif
 
-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 4/6] tests/kms_color: Run each subtest only for a single connector
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
                   ` (2 preceding siblings ...)
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 3/6] tests/kms_color: Pass pipe to invalid LUT size tests Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 5/6] lib/kms: Add GAMMA_LUT_3D support Ville Syrjala
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

For most of the subtests the used connector should not matter,
so run each subtest just for a single connector.

Suggested-by: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_color.c | 612 +++++++++++++++++++++++-----------------------
 1 file changed, 306 insertions(+), 306 deletions(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index dabc6963e9e0..d78c7e211511 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -37,6 +37,10 @@ static void test_pipe_degamma(data_t *data,
 		{ 0.0, 1.0, 0.0 },
 		{ 0.0, 0.0, 1.0 }
 	};
+	drmModeModeInfo *mode;
+	struct igt_fb fb_modeset, fb;
+	igt_crc_t crc_fullgamma, crc_fullcolors;
+	int fb_id, fb_modeset_id;
 
 	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));
@@ -44,69 +48,65 @@ static void test_pipe_degamma(data_t *data,
 	degamma_linear = generate_table(data->degamma_lut_size, 1.0);
 	degamma_full = generate_table_max(data->degamma_lut_size);
 
-	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
-		drmModeModeInfo *mode;
-		struct igt_fb fb_modeset, fb;
-		igt_crc_t crc_fullgamma, crc_fullcolors;
-		int fb_id, fb_modeset_id;
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
 
-		igt_output_set_pipe(output, primary->pipe->pipe);
-		mode = igt_output_get_mode(output);
+	igt_output_set_pipe(output, primary->pipe->pipe);
+	mode = igt_output_get_mode(output);
 
-		/* Create a framebuffer at the size of the output. */
-		fb_id = igt_create_fb(data->drm_fd,
+	/* Create a framebuffer at the size of the output. */
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &fb);
+	igt_assert(fb_id);
+
+	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
 				      DRM_FORMAT_XRGB8888,
 				      DRM_FORMAT_MOD_NONE,
-				      &fb);
-		igt_assert(fb_id);
+				      &fb_modeset);
+	igt_assert(fb_modeset_id);
 
-		fb_modeset_id = igt_create_fb(data->drm_fd,
-					      mode->hdisplay,
-					      mode->vdisplay,
-					      DRM_FORMAT_XRGB8888,
-					      DRM_FORMAT_MOD_NONE,
-					      &fb_modeset);
-		igt_assert(fb_modeset_id);
+	igt_plane_set_fb(primary, &fb_modeset);
+	disable_ctm(primary->pipe);
+	disable_gamma(primary->pipe);
+	set_degamma(data, primary->pipe, degamma_linear);
+	igt_display_commit(&data->display);
 
-		igt_plane_set_fb(primary, &fb_modeset);
-		disable_ctm(primary->pipe);
-		disable_gamma(primary->pipe);
-		set_degamma(data, primary->pipe, degamma_linear);
-		igt_display_commit(&data->display);
+	/* Draw solid colors with linear degamma transformation. */
+	paint_rectangles(data, mode, red_green_blue, &fb);
+	igt_plane_set_fb(primary, &fb);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
 
-		/* Draw solid colors with linear degamma transformation. */
-		paint_rectangles(data, mode, red_green_blue, &fb);
-		igt_plane_set_fb(primary, &fb);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->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(primary, &fb);
+	set_degamma(data, primary->pipe, degamma_full);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
 
-		/* 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(primary, &fb);
-		set_degamma(data, primary->pipe, degamma_full);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
+	/* Verify that the CRC of the software computed output is
+	 * equal to the CRC of the degamma LUT transformation output.
+	 */
+	igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
 
-		/* Verify that the CRC of the software computed output is
-		 * equal to the CRC of the degamma LUT transformation output.
-		 */
-		igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
-
-		disable_degamma(primary->pipe);
-		igt_plane_set_fb(primary, NULL);
-		igt_output_set_pipe(output, PIPE_NONE);
-		igt_display_commit(&data->display);
-		igt_remove_fb(data->drm_fd, &fb);
-		igt_remove_fb(data->drm_fd, &fb_modeset);
-	}
+	disable_degamma(primary->pipe);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &fb);
+	igt_remove_fb(data->drm_fd, &fb_modeset);
 
 	free_lut(degamma_linear);
 	free_lut(degamma_full);
@@ -127,73 +127,73 @@ static void test_pipe_gamma(data_t *data,
 		{ 0.0, 1.0, 0.0 },
 		{ 0.0, 0.0, 1.0 }
 	};
+	drmModeModeInfo *mode;
+	struct igt_fb fb_modeset, fb;
+	igt_crc_t crc_fullgamma, crc_fullcolors;
+	int fb_id, fb_modeset_id;
 
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_LUT));
 
 	gamma_full = generate_table_max(data->gamma_lut_size);
 
-	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
-		drmModeModeInfo *mode;
-		struct igt_fb fb_modeset, fb;
-		igt_crc_t crc_fullgamma, crc_fullcolors;
-		int fb_id, fb_modeset_id;
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
 
-		igt_output_set_pipe(output, primary->pipe->pipe);
-		mode = igt_output_get_mode(output);
+	igt_output_set_pipe(output, primary->pipe->pipe);
+	mode = igt_output_get_mode(output);
 
-		/* Create a framebuffer at the size of the output. */
-		fb_id = igt_create_fb(data->drm_fd,
+	/* Create a framebuffer at the size of the output. */
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &fb);
+	igt_assert(fb_id);
+
+	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
 				      DRM_FORMAT_XRGB8888,
 				      DRM_FORMAT_MOD_NONE,
-				      &fb);
-		igt_assert(fb_id);
+				      &fb_modeset);
+	igt_assert(fb_modeset_id);
 
-		fb_modeset_id = igt_create_fb(data->drm_fd,
-					      mode->hdisplay,
-					      mode->vdisplay,
-					      DRM_FORMAT_XRGB8888,
-					      DRM_FORMAT_MOD_NONE,
-					      &fb_modeset);
-		igt_assert(fb_modeset_id);
+	igt_plane_set_fb(primary, &fb_modeset);
+	disable_ctm(primary->pipe);
+	disable_degamma(primary->pipe);
+	set_gamma(data, primary->pipe, gamma_full);
+	igt_display_commit(&data->display);
 
-		igt_plane_set_fb(primary, &fb_modeset);
-		disable_ctm(primary->pipe);
-		disable_degamma(primary->pipe);
-		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);
+	igt_plane_set_fb(primary, &fb);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
 
-		/* Draw solid colors with no gamma transformation. */
-		paint_rectangles(data, mode, red_green_blue, &fb);
-		igt_plane_set_fb(primary, &fb);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
+	/* 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(primary, &fb);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
 
-		/* 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(primary, &fb);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
+	/* Verify that the CRC of the software computed output is
+	 * equal to the CRC of the gamma LUT transformation output.
+	 */
+	igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
 
-		/* Verify that the CRC of the software computed output is
-		 * equal to the CRC of the gamma LUT transformation output.
-		 */
-		igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
-
-		disable_gamma(primary->pipe);
-		igt_plane_set_fb(primary, NULL);
-		igt_output_set_pipe(output, PIPE_NONE);
-		igt_display_commit(&data->display);
-		igt_remove_fb(data->drm_fd, &fb);
-		igt_remove_fb(data->drm_fd, &fb_modeset);
-	}
+	disable_gamma(primary->pipe);
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_display_commit(&data->display);
+	igt_remove_fb(data->drm_fd, &fb);
+	igt_remove_fb(data->drm_fd, &fb_modeset);
 
 	free_lut(gamma_full);
 }
@@ -216,6 +216,10 @@ static void test_pipe_legacy_gamma(data_t *data,
 	drmModeCrtc *kms_crtc;
 	uint32_t i, legacy_lut_size;
 	uint16_t *red_lut, *green_lut, *blue_lut;
+	drmModeModeInfo *mode;
+	struct igt_fb fb_modeset, fb;
+	igt_crc_t crc_fullgamma, crc_fullcolors;
+	int fb_id, fb_modeset_id;
 
 	kms_crtc = drmModeGetCrtc(data->drm_fd, primary->pipe->crtc_id);
 	legacy_lut_size = kms_crtc->gamma_size;
@@ -225,80 +229,76 @@ static void test_pipe_legacy_gamma(data_t *data,
 	green_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
 	blue_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
 
-	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
-		drmModeModeInfo *mode;
-		struct igt_fb fb_modeset, fb;
-		igt_crc_t crc_fullgamma, crc_fullcolors;
-		int fb_id, fb_modeset_id;
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
 
-		igt_output_set_pipe(output, primary->pipe->pipe);
-		mode = igt_output_get_mode(output);
+	igt_output_set_pipe(output, primary->pipe->pipe);
+	mode = igt_output_get_mode(output);
 
-		/* Create a framebuffer at the size of the output. */
-		fb_id = igt_create_fb(data->drm_fd,
+	/* Create a framebuffer at the size of the output. */
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &fb);
+	igt_assert(fb_id);
+
+	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
 				      DRM_FORMAT_XRGB8888,
 				      DRM_FORMAT_MOD_NONE,
-				      &fb);
-		igt_assert(fb_id);
-
-		fb_modeset_id = igt_create_fb(data->drm_fd,
-					      mode->hdisplay,
-					      mode->vdisplay,
-					      DRM_FORMAT_XRGB8888,
-					      DRM_FORMAT_MOD_NONE,
-					      &fb_modeset);
-		igt_assert(fb_modeset_id);
-
-		igt_plane_set_fb(primary, &fb_modeset);
-		disable_degamma(primary->pipe);
-		disable_gamma(primary->pipe);
-		disable_ctm(primary->pipe);
-		igt_display_commit(&data->display);
-
-		/* Draw solid colors with no gamma transformation. */
-		paint_rectangles(data, mode, red_green_blue, &fb);
-		igt_plane_set_fb(primary, &fb);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
-
-		/* 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(primary, &fb);
-
-		red_lut[0] = green_lut[0] = blue_lut[0] = 0;
-		for (i = 1; i < legacy_lut_size; i++)
-			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
-		igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
-						  legacy_lut_size, red_lut, green_lut, blue_lut), 0);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
-
-		/* Verify that the CRC of the software computed output is
-		 * equal to the CRC of the gamma LUT transformation output.
-		 */
-		igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
-
-		/* Reset output. */
-		for (i = 1; i < legacy_lut_size; i++)
-			red_lut[i] = green_lut[i] = blue_lut[i] = i << 8;
-
-		igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
-						  legacy_lut_size, red_lut, green_lut, blue_lut), 0);
-		igt_display_commit(&data->display);
-
-		igt_plane_set_fb(primary, NULL);
-		igt_output_set_pipe(output, PIPE_NONE);
-		igt_remove_fb(data->drm_fd, &fb);
-		igt_remove_fb(data->drm_fd, &fb_modeset);
-	}
+				      &fb_modeset);
+	igt_assert(fb_modeset_id);
+
+	igt_plane_set_fb(primary, &fb_modeset);
+	disable_degamma(primary->pipe);
+	disable_gamma(primary->pipe);
+	disable_ctm(primary->pipe);
+	igt_display_commit(&data->display);
+
+	/* Draw solid colors with no gamma transformation. */
+	paint_rectangles(data, mode, red_green_blue, &fb);
+	igt_plane_set_fb(primary, &fb);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
+
+	/* 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(primary, &fb);
+
+	red_lut[0] = green_lut[0] = blue_lut[0] = 0;
+	for (i = 1; i < legacy_lut_size; i++)
+		red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
+					  legacy_lut_size, red_lut, green_lut, blue_lut), 0);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullgamma);
+
+	/* Verify that the CRC of the software computed output is
+	 * equal to the CRC of the gamma LUT transformation output.
+	 */
+	igt_assert_crc_equal(&crc_fullgamma, &crc_fullcolors);
+
+	/* Reset output. */
+	for (i = 1; i < legacy_lut_size; i++)
+		red_lut[i] = green_lut[i] = blue_lut[i] = i << 8;
+
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd, primary->pipe->crtc_id,
+					  legacy_lut_size, red_lut, green_lut, blue_lut), 0);
+	igt_display_commit(&data->display);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_remove_fb(data->drm_fd, &fb);
+	igt_remove_fb(data->drm_fd, &fb_modeset);
 
 	free(red_lut);
 	free(green_lut);
@@ -331,93 +331,93 @@ static void test_pipe_legacy_gamma_reset(data_t *data,
 		degamma_linear = generate_table(data->degamma_lut_size, 1.0);
 	gamma_zero = generate_table_zero(data->gamma_lut_size);
 
-	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
-		igt_output_set_pipe(output, primary->pipe->pipe);
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
 
-		/* Ensure we have a clean state to start with. */
-		disable_degamma(primary->pipe);
-		disable_ctm(primary->pipe);
-		disable_gamma(primary->pipe);
-		igt_display_commit(&data->display);
+	igt_output_set_pipe(output, primary->pipe->pipe);
 
-		/* Set a degama & gamma LUT and a CTM using the
-		 * properties and verify the content of the
-		 * properties. */
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT))
-			set_degamma(data, primary->pipe, degamma_linear);
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM))
-			set_ctm(primary->pipe, ctm_identity);
-		set_gamma(data, primary->pipe, gamma_zero);
-		igt_display_commit(&data->display);
+	/* Ensure we have a clean state to start with. */
+	disable_degamma(primary->pipe);
+	disable_ctm(primary->pipe);
+	disable_gamma(primary->pipe);
+	igt_display_commit(&data->display);
 
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT)) {
-			blob = get_blob(data, primary->pipe, IGT_CRTC_DEGAMMA_LUT);
-			igt_assert(blob &&
-				   blob->length == (sizeof(struct drm_color_lut) *
-						    data->degamma_lut_size));
-			drmModeFreePropertyBlob(blob);
-		}
+	/* Set a degama & gamma LUT and a CTM using the
+	 * properties and verify the content of the
+	 * properties. */
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT))
+		set_degamma(data, primary->pipe, degamma_linear);
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM))
+		set_ctm(primary->pipe, ctm_identity);
+	set_gamma(data, primary->pipe, gamma_zero);
+	igt_display_commit(&data->display);
 
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM)) {
-			blob = get_blob(data, primary->pipe, IGT_CRTC_CTM);
-			igt_assert(blob &&
-				   blob->length == sizeof(struct drm_color_ctm));
-			drmModeFreePropertyBlob(blob);
-		}
-
-		blob = get_blob(data, primary->pipe, IGT_CRTC_GAMMA_LUT);
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT)) {
+		blob = get_blob(data, primary->pipe, IGT_CRTC_DEGAMMA_LUT);
 		igt_assert(blob &&
 			   blob->length == (sizeof(struct drm_color_lut) *
-					    data->gamma_lut_size));
-		lut = (struct drm_color_lut *) blob->data;
-		for (i = 0; i < data->gamma_lut_size; i++)
-			igt_assert(lut[i].red == 0 &&
-				   lut[i].green == 0 &&
-				   lut[i].blue == 0);
+					    data->degamma_lut_size));
 		drmModeFreePropertyBlob(blob);
+	}
 
-		/* Set a gamma LUT using the legacy ioctl and verify
-		 * the content of the GAMMA_LUT property is changed
-		 * and that CTM and DEGAMMA_LUT are empty. */
-		kms_crtc = drmModeGetCrtc(data->drm_fd, primary->pipe->crtc_id);
-		legacy_lut_size = kms_crtc->gamma_size;
-		drmModeFreeCrtc(kms_crtc);
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM)) {
+		blob = get_blob(data, primary->pipe, IGT_CRTC_CTM);
+		igt_assert(blob &&
+			   blob->length == sizeof(struct drm_color_ctm));
+		drmModeFreePropertyBlob(blob);
+	}
 
-		red_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
-		green_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
-		blue_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
+	blob = get_blob(data, primary->pipe, IGT_CRTC_GAMMA_LUT);
+	igt_assert(blob &&
+		   blob->length == (sizeof(struct drm_color_lut) *
+				    data->gamma_lut_size));
+	lut = (struct drm_color_lut *) blob->data;
+	for (i = 0; i < data->gamma_lut_size; i++)
+		igt_assert(lut[i].red == 0 &&
+			   lut[i].green == 0 &&
+			   lut[i].blue == 0);
+	drmModeFreePropertyBlob(blob);
 
-		for (i = 0; i < legacy_lut_size; i++)
-			red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
+	/* Set a gamma LUT using the legacy ioctl and verify
+	 * the content of the GAMMA_LUT property is changed
+	 * and that CTM and DEGAMMA_LUT are empty. */
+	kms_crtc = drmModeGetCrtc(data->drm_fd, primary->pipe->crtc_id);
+	legacy_lut_size = kms_crtc->gamma_size;
+	drmModeFreeCrtc(kms_crtc);
 
-		igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd,
-						  primary->pipe->crtc_id,
-						  legacy_lut_size,
-						  red_lut, green_lut, blue_lut),
-			      0);
-		igt_display_commit(&data->display);
+	red_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
+	green_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
+	blue_lut = malloc(sizeof(uint16_t) * legacy_lut_size);
 
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT))
-			igt_assert(get_blob(data, primary->pipe,
-					    IGT_CRTC_DEGAMMA_LUT) == NULL);
+	for (i = 0; i < legacy_lut_size; i++)
+		red_lut[i] = green_lut[i] = blue_lut[i] = 0xffff;
 
-		if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM))
-			igt_assert(get_blob(data, primary->pipe, IGT_CRTC_CTM) == NULL);
+	igt_assert_eq(drmModeCrtcSetGamma(data->drm_fd,
+					  primary->pipe->crtc_id,
+					  legacy_lut_size,
+					  red_lut, green_lut, blue_lut), 0);
+	igt_display_commit(&data->display);
 
-		blob = get_blob(data, primary->pipe, IGT_CRTC_GAMMA_LUT);
-		igt_assert(blob &&
-			   blob->length == (sizeof(struct drm_color_lut) *
-					    legacy_lut_size));
-		lut = (struct drm_color_lut *) blob->data;
-		for (i = 0; i < legacy_lut_size; i++)
-			igt_assert(lut[i].red == 0xffff &&
-				   lut[i].green == 0xffff &&
-				   lut[i].blue == 0xffff);
-		drmModeFreePropertyBlob(blob);
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_DEGAMMA_LUT))
+		igt_assert(get_blob(data, primary->pipe,
+				    IGT_CRTC_DEGAMMA_LUT) == NULL);
 
-		igt_plane_set_fb(primary, NULL);
-		igt_output_set_pipe(output, PIPE_NONE);
-	}
+	if (igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM))
+		igt_assert(get_blob(data, primary->pipe, IGT_CRTC_CTM) == NULL);
+
+	blob = get_blob(data, primary->pipe, IGT_CRTC_GAMMA_LUT);
+	igt_assert(blob &&
+		   blob->length == (sizeof(struct drm_color_lut) *
+				    legacy_lut_size));
+	lut = (struct drm_color_lut *) blob->data;
+	for (i = 0; i < legacy_lut_size; i++)
+		igt_assert(lut[i].red == 0xffff &&
+			   lut[i].green == 0xffff &&
+			   lut[i].blue == 0xffff);
+	drmModeFreePropertyBlob(blob);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
 
 	free_lut(degamma_linear);
 	free_lut(gamma_zero);
@@ -442,84 +442,84 @@ static bool test_pipe_ctm(data_t *data,
 	igt_output_t *output;
 	bool ret = true;
 	igt_display_t *display = &data->display;
+	drmModeModeInfo *mode;
+	struct igt_fb fb_modeset, fb;
+	igt_crc_t crc_software, crc_hardware;
+	int fb_id, fb_modeset_id;
 
 	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_CTM));
 
 	degamma_linear = generate_table(data->degamma_lut_size, 1.0);
 	gamma_linear = generate_table(data->gamma_lut_size, 1.0);
 
-	for_each_valid_output_on_pipe(&data->display, primary->pipe->pipe, output) {
-		drmModeModeInfo *mode;
-		struct igt_fb fb_modeset, fb;
-		igt_crc_t crc_software, crc_hardware;
-		int fb_id, fb_modeset_id;
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
 
-		igt_output_set_pipe(output, primary->pipe->pipe);
-		mode = igt_output_get_mode(output);
+	igt_output_set_pipe(output, primary->pipe->pipe);
+	mode = igt_output_get_mode(output);
 
-		/* Create a framebuffer at the size of the output. */
-		fb_id = igt_create_fb(data->drm_fd,
+	/* Create a framebuffer at the size of the output. */
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &fb);
+	igt_assert(fb_id);
+
+	fb_modeset_id = igt_create_fb(data->drm_fd,
 				      mode->hdisplay,
 				      mode->vdisplay,
 				      DRM_FORMAT_XRGB8888,
 				      DRM_FORMAT_MOD_NONE,
-				      &fb);
-		igt_assert(fb_id);
+				      &fb_modeset);
+	igt_assert(fb_modeset_id);
+	igt_plane_set_fb(primary, &fb_modeset);
 
-		fb_modeset_id = igt_create_fb(data->drm_fd,
-					      mode->hdisplay,
-					      mode->vdisplay,
-					      DRM_FORMAT_XRGB8888,
-					      DRM_FORMAT_MOD_NONE,
-					      &fb_modeset);
-		igt_assert(fb_modeset_id);
-		igt_plane_set_fb(primary, &fb_modeset);
-
-		/*
-		 * Don't program LUT's for max CTM cases, as limitation of
-		 * representing intermediate values between 0 and 1.0 causes
-		 * rounding issues and inaccuracies leading to crc mismatch.
-		 */
-		if (memcmp(before, after, sizeof(color_t))) {
-			set_degamma(data, primary->pipe, degamma_linear);
-			set_gamma(data, primary->pipe, gamma_linear);
-		} else {
-			/* Disable Degamma and Gamma for ctm max test */
-			disable_degamma(primary->pipe);
-			disable_gamma(primary->pipe);
-		}
-
-		disable_ctm(primary->pipe);
-		igt_display_commit(&data->display);
-
-		paint_rectangles(data, mode, after, &fb);
-		igt_plane_set_fb(primary, &fb);
-		set_ctm(primary->pipe, ctm_identity);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_software);
-
-		/* With CTM transformation. */
-		paint_rectangles(data, mode, before, &fb);
-		igt_plane_set_fb(primary, &fb);
-		set_ctm(primary->pipe, ctm_matrix);
-		igt_display_commit(&data->display);
-		igt_wait_for_vblank(data->drm_fd,
-				display->pipes[primary->pipe->pipe].crtc_offset);
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_hardware);
-
-		/* Verify that the CRC of the software computed output is
-		 * equal to the CRC of the CTM matrix transformation output.
-		 */
-		ret &= !igt_skip_crc_compare || igt_check_crc_equal(&crc_software, &crc_hardware);
-
-		igt_plane_set_fb(primary, NULL);
-		igt_output_set_pipe(output, PIPE_NONE);
-		igt_remove_fb(data->drm_fd, &fb);
-		igt_remove_fb(data->drm_fd, &fb_modeset);
+	/*
+	 * Don't program LUT's for max CTM cases, as limitation of
+	 * representing intermediate values between 0 and 1.0 causes
+	 * rounding issues and inaccuracies leading to crc mismatch.
+	 */
+	if (memcmp(before, after, sizeof(color_t))) {
+		set_degamma(data, primary->pipe, degamma_linear);
+		set_gamma(data, primary->pipe, gamma_linear);
+	} else {
+		/* Disable Degamma and Gamma for ctm max test */
+		disable_degamma(primary->pipe);
+		disable_gamma(primary->pipe);
 	}
 
+	disable_ctm(primary->pipe);
+	igt_display_commit(&data->display);
+
+	paint_rectangles(data, mode, after, &fb);
+	igt_plane_set_fb(primary, &fb);
+	set_ctm(primary->pipe, ctm_identity);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_software);
+
+	/* With CTM transformation. */
+	paint_rectangles(data, mode, before, &fb);
+	igt_plane_set_fb(primary, &fb);
+	set_ctm(primary->pipe, ctm_matrix);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_hardware);
+
+	/* Verify that the CRC of the software computed output is
+	 * equal to the CRC of the CTM matrix transformation output.
+	 */
+	ret &= !igt_skip_crc_compare || igt_check_crc_equal(&crc_software, &crc_hardware);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+	igt_remove_fb(data->drm_fd, &fb);
+	igt_remove_fb(data->drm_fd, &fb_modeset);
+
 	free_lut(degamma_linear);
 	free_lut(gamma_linear);
 
-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 5/6] lib/kms: Add GAMMA_LUT_3D support
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
                   ` (3 preceding siblings ...)
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 4/6] tests/kms_color: Run each subtest only for a single connector Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 6/6] tests/kms_color: Add GAMMA_LUT_3D tests Ville Syrjala
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add basic plumbing for the GAMMA_LUT_3D/GAMMA_LUT_3D_SIZE crtc props.

Reviewed-by: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c | 5 +++++
 lib/igt_kms.h | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cc38f5a25334..5b1f55a50840 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -589,6 +589,8 @@ const char * const igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = {
 	[IGT_CRTC_GAMMA_LUT_SIZE] = "GAMMA_LUT_SIZE",
 	[IGT_CRTC_DEGAMMA_LUT] = "DEGAMMA_LUT",
 	[IGT_CRTC_DEGAMMA_LUT_SIZE] = "DEGAMMA_LUT_SIZE",
+	[IGT_CRTC_GAMMA_LUT_3D] = "GAMMA_LUT_3D",
+	[IGT_CRTC_GAMMA_LUT_3D_SIZE] = "GAMMA_LUT_3D_SIZE",
 	[IGT_CRTC_MODE_ID] = "MODE_ID",
 	[IGT_CRTC_ACTIVE] = "ACTIVE",
 	[IGT_CRTC_OUT_FENCE_PTR] = "OUT_FENCE_PTR",
@@ -1983,6 +1985,9 @@ static void igt_pipe_reset(igt_pipe_t *pipe)
 	if (igt_pipe_obj_has_prop(pipe, IGT_CRTC_DEGAMMA_LUT))
 		igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_DEGAMMA_LUT, 0);
 
+	if (igt_pipe_obj_has_prop(pipe, IGT_CRTC_GAMMA_LUT_3D))
+		igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_GAMMA_LUT_3D, 0);
+
 	pipe->out_fence_fd = -1;
 }
 
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index ed598f164a59..9608097142bd 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -121,6 +121,8 @@ enum igt_atomic_crtc_properties {
        IGT_CRTC_GAMMA_LUT_SIZE,
        IGT_CRTC_DEGAMMA_LUT,
        IGT_CRTC_DEGAMMA_LUT_SIZE,
+       IGT_CRTC_GAMMA_LUT_3D,
+       IGT_CRTC_GAMMA_LUT_3D_SIZE,
        IGT_CRTC_MODE_ID,
        IGT_CRTC_ACTIVE,
        IGT_CRTC_OUT_FENCE_PTR,
-- 
2.31.1

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

* [igt-dev] [PATCH i-g-t v2 6/6] tests/kms_color: Add GAMMA_LUT_3D tests
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
                   ` (4 preceding siblings ...)
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 5/6] lib/kms: Add GAMMA_LUT_3D support Ville Syrjala
@ 2021-09-03 16:15 ` Ville Syrjala
  2021-09-03 16:18 ` [igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_color: 3D LUT tests (rev4) Patchwork
  2021-09-03 16:23 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
  7 siblings, 0 replies; 9+ messages in thread
From: Ville Syrjala @ 2021-09-03 16:15 UTC (permalink / raw)
  To: igt-dev; +Cc: Bhanuprakash Modem

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add some basic tests for 3D LUTs.

v2: Add missing igt_describe()s
    s/degamma/3D LUT/ in some comments
    Run the test for a single connector only
    Run the invalid LUT size test for each pipe

Cc: Bhanuprakash Modem <Bhanuprakash.modem@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_color.c        | 97 ++++++++++++++++++++++++++++++++++++++++
 tests/kms_color_helper.c | 58 +++++++++++++++++++++++-
 tests/kms_color_helper.h | 18 ++++++++
 3 files changed, 172 insertions(+), 1 deletion(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index d78c7e211511..2e250ffe8ae8 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -198,6 +198,88 @@ static void test_pipe_gamma(data_t *data,
 	free_lut(gamma_full);
 }
 
+static void test_pipe_gamma_lut_3d(data_t *data,
+				   igt_plane_t *primary)
+{
+	igt_output_t *output;
+	igt_display_t *display = &data->display;
+	gamma_lut_t *gamma_lut_3d_linear, *gamma_lut_3d_full;
+	color_t red_green_blue[] = {
+		{ 1.0, 0.0, 0.0 },
+		{ 0.0, 1.0, 0.0 },
+		{ 0.0, 0.0, 1.0 }
+	};
+	drmModeModeInfo *mode;
+	struct igt_fb fb_modeset, fb;
+	igt_crc_t crc_fulllut3d, crc_fullcolors;
+	int fb_id, fb_modeset_id;
+
+	igt_require(igt_pipe_obj_has_prop(primary->pipe, IGT_CRTC_GAMMA_LUT_3D));
+
+	gamma_lut_3d_linear = generate_lut_3d(data->gamma_lut_3d_size, 1.0);
+	gamma_lut_3d_full = generate_lut_3d_max(data->gamma_lut_3d_size);
+
+	output = igt_get_single_output_for_pipe(&data->display, primary->pipe->pipe);
+	igt_require(output);
+
+	igt_output_set_pipe(output, primary->pipe->pipe);
+	mode = igt_output_get_mode(output);
+
+	/* Create a framebuffer at the size of the output. */
+	fb_id = igt_create_fb(data->drm_fd,
+			      mode->hdisplay,
+			      mode->vdisplay,
+			      DRM_FORMAT_XRGB8888,
+			      DRM_FORMAT_MOD_NONE,
+			      &fb);
+	igt_assert(fb_id);
+
+	fb_modeset_id = igt_create_fb(data->drm_fd,
+				      mode->hdisplay,
+				      mode->vdisplay,
+				      DRM_FORMAT_XRGB8888,
+				      DRM_FORMAT_MOD_NONE,
+				      &fb_modeset);
+	igt_assert(fb_modeset_id);
+
+	igt_plane_set_fb(primary, &fb_modeset);
+	disable_ctm(primary->pipe);
+	disable_degamma(primary->pipe);
+	disable_gamma(primary->pipe);
+	set_gamma_lut_3d(data, primary->pipe, gamma_lut_3d_linear);
+	igt_display_commit(&data->display);
+
+	/* Draw solid colors with no 3D LUT transformation. */
+	paint_rectangles(data, mode, red_green_blue, &fb);
+	igt_plane_set_fb(primary, &fb);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fullcolors);
+
+	/* Draw a gradient with 3D LUT to remap all
+	 * values to max red/green/blue.
+	 */
+	paint_gradient_rectangles(data, mode, red_green_blue, &fb);
+	igt_plane_set_fb(primary, &fb);
+	set_gamma_lut_3d(data, primary->pipe, gamma_lut_3d_full);
+	igt_display_commit(&data->display);
+	igt_wait_for_vblank(data->drm_fd,
+			    display->pipes[primary->pipe->pipe].crtc_offset);
+	igt_pipe_crc_collect_crc(data->pipe_crc, &crc_fulllut3d);
+
+	/* Verify that the CRC of the software computed output is
+	 * equal to the CRC of the 3D LUT transformation output.
+	 */
+	igt_assert_crc_equal(&crc_fulllut3d, &crc_fullcolors);
+
+	igt_plane_set_fb(primary, NULL);
+	igt_output_set_pipe(output, PIPE_NONE);
+
+	free_lut(gamma_lut_3d_linear);
+	free_lut(gamma_lut_3d_full);
+}
+
 /*
  * Draw 3 gradient rectangles in red, green and blue, with a maxed out legacy
  * gamma LUT and verify we have the same CRC as drawing solid color rectangles
@@ -656,6 +738,13 @@ prep_pipe(data_t *data, enum pipe p)
 					      IGT_CRTC_GAMMA_LUT_SIZE);
 		igt_assert_lt(0, data->gamma_lut_size);
 	}
+
+	if (igt_pipe_obj_has_prop(&data->display.pipes[p], IGT_CRTC_GAMMA_LUT_3D_SIZE)) {
+		data->gamma_lut_3d_size =
+			igt_pipe_obj_get_prop(&data->display.pipes[p],
+					      IGT_CRTC_GAMMA_LUT_3D_SIZE);
+		igt_assert_lt(0, data->gamma_lut_3d_size);
+	}
 }
 
 static void
@@ -860,6 +949,10 @@ run_tests_for_pipe(data_t *data, enum pipe p)
 	igt_subtest_f("pipe-%s-legacy-gamma-reset", kmstest_pipe_name(p))
 		test_pipe_legacy_gamma_reset(data, primary);
 
+	igt_describe("Verify that gamma LUT 3D transformation works correctly");
+	igt_subtest_f("pipe-%s-gamma-lut-3d", kmstest_pipe_name(p))
+		test_pipe_gamma_lut_3d(data, primary);
+
 	igt_fixture {
 		disable_degamma(primary->pipe);
 		disable_gamma(primary->pipe);
@@ -888,6 +981,10 @@ run_invalid_tests_for_pipe(data_t *data, enum pipe p)
 	igt_describe("Negative check for color tranformation matrix sizes");
 	igt_subtest_f("pipe-%s-invalid-ctm-matrix-sizes", kmstest_pipe_name(p))
 		invalid_ctm_matrix_sizes(data, p);
+
+	igt_describe("Negative check for invalid gamma lut 3D sizes");
+	igt_subtest_f("pipe-%s-invalid-gamma-lut-3d-sizes", kmstest_pipe_name(p))
+		invalid_gamma_lut_3d_sizes(data, p);
 }
 
 igt_main
diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index d71e7bb2e6f9..38e388c54ee8 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -143,6 +143,44 @@ gamma_lut_t *generate_table_zero(int lut_size)
 	return gamma;
 }
 
+gamma_lut_t *generate_lut_3d(int lut_size, double exp)
+{
+	gamma_lut_t *gamma = alloc_lut(lut_3d_size(lut_size));
+
+	for (int r = 0; r < lut_size; r++) {
+		for (int g = 0; g < lut_size; g++) {
+			for (int b = 0; b < lut_size; b++) {
+				int i = lut_3d_index(r, g, b, lut_size);
+
+				gamma->coeffs[i].r = pow(r * 1.0 / (lut_size - 1), exp);
+				gamma->coeffs[i].g = pow(g * 1.0 / (lut_size - 1), exp);
+				gamma->coeffs[i].b = pow(b * 1.0 / (lut_size - 1), exp);
+			}
+		}
+	}
+
+	return gamma;
+}
+
+gamma_lut_t *generate_lut_3d_max(int lut_size)
+{
+	gamma_lut_t *gamma = alloc_lut(lut_3d_size(lut_size));
+
+	for (int r = 0; r < lut_size; r++) {
+		for (int g = 0; g < lut_size; g++) {
+			for (int b = 0; b < lut_size; b++) {
+				int i = lut_3d_index(r, g, b, lut_size);
+
+				gamma->coeffs[i].r = r == 0 ? 0.0 : 1.0;
+				gamma->coeffs[i].g = g == 0 ? 0.0 : 1.0;
+				gamma->coeffs[i].b = b == 0 ? 0.0 : 1.0;
+			}
+		}
+	}
+
+	return gamma;
+}
+
 struct drm_color_lut *coeffs_to_lut(data_t *data,
 				    const gamma_lut_t *gamma,
 				    uint32_t color_depth,
@@ -215,6 +253,19 @@ void set_gamma(data_t *data,
 	free(lut);
 }
 
+void set_gamma_lut_3d(data_t *data,
+		      igt_pipe_t *pipe,
+		      const gamma_lut_t *gamma_lut_3d)
+{
+	size_t size = sizeof(struct drm_color_lut) * gamma_lut_3d->size;
+	struct drm_color_lut *lut = coeffs_to_lut(data, gamma_lut_3d,
+						  data->color_depth, 0);
+
+	igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_GAMMA_LUT_3D, lut, size);
+
+	free(lut);
+}
+
 void set_ctm(igt_pipe_t *pipe, const double *coefficients)
 {
 	struct drm_color_ctm ctm;
@@ -331,6 +382,12 @@ invalid_degamma_lut_sizes(data_t *data, enum pipe p)
 	invalid_lut_sizes(data, p, IGT_CRTC_DEGAMMA_LUT, data->degamma_lut_size);
 }
 
+void
+invalid_gamma_lut_3d_sizes(data_t *data, enum pipe p)
+{
+	invalid_lut_sizes(data, p, IGT_CRTC_GAMMA_LUT_3D, lut_3d_size(data->gamma_lut_3d_size));
+}
+
 void invalid_ctm_matrix_sizes(data_t *data, enum pipe p)
 {
 	igt_display_t *display = &data->display;
@@ -359,4 +416,3 @@ void invalid_ctm_matrix_sizes(data_t *data, enum pipe p)
 
 	free(ptr);
 }
-
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index bb6f0054f388..7406820b6955 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -52,6 +52,7 @@ typedef struct {
 	uint32_t color_depth;
 	uint64_t degamma_lut_size;
 	uint64_t gamma_lut_size;
+	uint64_t gamma_lut_3d_size;
 	#ifdef HAVE_CHAMELIUM
 	struct chamelium *chamelium;
 	struct chamelium_port **ports;
@@ -77,6 +78,8 @@ void free_lut(gamma_lut_t *gamma);
 gamma_lut_t *generate_table(int lut_size, double exp);
 gamma_lut_t *generate_table_max(int lut_size);
 gamma_lut_t *generate_table_zero(int lut_size);
+gamma_lut_t *generate_lut_3d(int lut_size, double exp);
+gamma_lut_t *generate_lut_3d_max(int lut_size);
 struct drm_color_lut *coeffs_to_lut(data_t *data,
 				    const gamma_lut_t *gamma,
 				    uint32_t color_depth,
@@ -87,13 +90,27 @@ void set_degamma(data_t *data,
 void set_gamma(data_t *data,
 	       igt_pipe_t *pipe,
 	       const gamma_lut_t *gamma);
+void set_gamma_lut_3d(data_t *data,
+		      igt_pipe_t *pipe,
+		      const gamma_lut_t *gamma);
 void set_ctm(igt_pipe_t *pipe, const double *coefficients);
 void disable_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_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_lut_3d(pipe) disable_prop(pipe, IGT_CRTC_LUT_3D)
 #define disable_ctm(pipe) disable_prop(pipe, IGT_CRTC_CTM)
 
+static inline int lut_3d_size(int lut_size)
+{
+	return lut_size * lut_size * lut_size;
+}
+
+static inline int lut_3d_index(int r, int g, int b, int lut_size)
+{
+	return r * lut_size * lut_size + g * lut_size + b;
+}
+
 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);
@@ -105,6 +122,7 @@ int pipe_set_property_blob(igt_pipe_t *pipe,
 			   void *ptr, size_t length);
 void invalid_gamma_lut_sizes(data_t *data, enum pipe p);
 void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
+void invalid_gamma_lut_3d_sizes(data_t *data, enum pipe p);
 void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
 
 #endif
-- 
2.31.1

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

* [igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_color: 3D LUT tests (rev4)
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
                   ` (5 preceding siblings ...)
  2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 6/6] tests/kms_color: Add GAMMA_LUT_3D tests Ville Syrjala
@ 2021-09-03 16:18 ` Patchwork
  2021-09-03 16:23 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
  7 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2021-09-03 16:18 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: igt-dev

== Series Details ==

Series: tests/kms_color: 3D LUT tests (rev4)
URL   : https://patchwork.freedesktop.org/series/90165/
State : failure

== Summary ==

IGT patchset build failed on latest successful build
40888f97a6ad219f4ed48a1830d0ef3c9617d006 i915_drm.h sync

[310/428] Linking target tests/i915_getparams_basic.
[311/428] Linking target tests/i915_pm_backlight.
[312/428] Linking target tests/i915_hangman.
[313/428] Linking target tests/i915_pm_lpsp.
[314/428] Linking target tests/i915_pciid.
[315/428] Linking target tests/i915_pm_rpm.
[316/428] Linking target tests/i915_pm_sseu.
[317/428] Linking target tests/i915_suspend.
[318/428] Linking target tests/sysfs_clients.
[319/428] Linking target tests/sysfs_heartbeat_interval.
[320/428] Linking target tests/sysfs_defaults.
[321/428] Linking target tests/sysfs_preempt_timeout.
[322/428] Linking target tests/dumb_buffer.
[323/428] Linking target tests/sysfs_timeslice_duration.
[324/428] Linking target tests/gem_eio.
[325/428] Linking target tests/gem_create.
[326/428] Linking target tests/gem_ctx_freq.
[327/428] Linking target tests/gem_ctx_sseu.
[328/428] Linking target tests/gem_mmap_offset.
[329/428] Linking target tests/gem_exec_balancer.
[330/428] Linking target tests/core_hotunplug.
[331/428] Linking target tests/perf_pmu.
[332/428] Linking target tests/i915_pm_rc6_residency.
[333/428] Linking target tests/perf.
[334/428] Compiling C object 'tests/tests@@kms_color_chamelium@exe/kms_color_chamelium.c.o'.
FAILED: tests/tests@@kms_color_chamelium@exe/kms_color_chamelium.c.o 
ccache cc -Itests/tests@@kms_color_chamelium@exe -Itests -I../tests -I../include/drm-uapi -Ilib -I../lib -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/x86_64-linux-gnu -I/usr/include/alsa -I/usr/include -I/home/cidrm/kernel_headers/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -fcommon -pthread  -MD -MQ 'tests/tests@@kms_color_chamelium@exe/kms_color_chamelium.c.o' -MF 'tests/tests@@kms_color_chamelium@exe/kms_color_chamelium.c.o.d' -o 'tests/tests@@kms_color_chamelium@exe/kms_color_chamelium.c.o' -c ../tests/kms_color_chamelium.c
../tests/kms_color_chamelium.c: In function ‘__real_main724’:
../tests/kms_color_chamelium.c:757:3: error: too few arguments to function ‘invalid_gamma_lut_sizes’
   invalid_gamma_lut_sizes(&data);
   ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../tests/kms_color_chamelium.c:25:
../tests/kms_color_helper.h:123:6: note: declared here
 void invalid_gamma_lut_sizes(data_t *data, enum pipe p);
      ^~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_color_chamelium.c:761:3: error: too few arguments to function ‘invalid_degamma_lut_sizes’
   invalid_degamma_lut_sizes(&data);
   ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../tests/kms_color_chamelium.c:25:
../tests/kms_color_helper.h:124:6: note: declared here
 void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
      ^~~~~~~~~~~~~~~~~~~~~~~~~
../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
   invalid_ctm_matrix_sizes(&data);
   ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../tests/kms_color_chamelium.c:25:
../tests/kms_color_helper.h:126:6: note: declared here
 void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
      ^~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.


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

* [igt-dev] ✗ GitLab.Pipeline: warning for tests/kms_color: 3D LUT tests (rev4)
  2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
                   ` (6 preceding siblings ...)
  2021-09-03 16:18 ` [igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_color: 3D LUT tests (rev4) Patchwork
@ 2021-09-03 16:23 ` Patchwork
  7 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2021-09-03 16:23 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: igt-dev

== Series Details ==

Series: tests/kms_color: 3D LUT tests (rev4)
URL   : https://patchwork.freedesktop.org/series/90165/
State : warning

== Summary ==

Pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/394644 for the overview.

build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373823):
     invalid_degamma_lut_sizes(&data);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:124:6: note: declared here
   void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
        ^~~~~~~~~~~~~~~~~~~~~~~~~
  ../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
     invalid_ctm_matrix_sizes(&data);
     ^~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:126:6: note: declared here
   void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
        ^~~~~~~~~~~~~~~~~~~~~~~~
  ninja: build stopped: subcommand failed.
  section_end:1630685996:step_script
  section_start:1630685996:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685998:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373818):
    761 |   invalid_degamma_lut_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:124:6: note: declared here
    124 | void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~
  ../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
    765 |   invalid_ctm_matrix_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:126:6: note: declared here
    126 | void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~
  ninja: build stopped: subcommand failed.
  section_end:1630685994:step_script
  section_start:1630685994:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685996:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373822):
  ../tests/kms_color_chamelium.c:761:34: error: too few arguments to function call, expected 2, have 1
                  invalid_degamma_lut_sizes(&data);
                  ~~~~~~~~~~~~~~~~~~~~~~~~~      ^
  ../tests/kms_color_helper.h:124:1: note: 'invalid_degamma_lut_sizes' declared here
  void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
  ^
  ../tests/kms_color_chamelium.c:765:33: error: too few arguments to function call, expected 2, have 1
                  invalid_ctm_matrix_sizes(&data);
                  ~~~~~~~~~~~~~~~~~~~~~~~~      ^
  ../tests/kms_color_helper.h:126:1: note: 'invalid_ctm_matrix_sizes' declared here
  void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
  ^
  3 errors generated.
  ninja: build stopped: subcommand failed.
  section_end:1630685988:step_script
  section_start:1630685988:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685989:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373821):
    761 |   invalid_degamma_lut_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:124:6: note: declared here
    124 | void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~
  ../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
    765 |   invalid_ctm_matrix_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:126:6: note: declared here
    126 | void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~
  ninja: build stopped: subcommand failed.
  section_end:1630685994:step_script
  section_start:1630685994:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685996:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373819):
    761 |   invalid_degamma_lut_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:124:6: note: declared here
    124 | void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~
  ../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
    765 |   invalid_ctm_matrix_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:126:6: note: declared here
    126 | void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~
  ninja: build stopped: subcommand failed.
  section_end:1630685994:step_script
  section_start:1630685994:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685996:cleanup_file_variables
  ERROR: Job failed: exit code 1
  

build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/13373820):
    761 |   invalid_degamma_lut_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:124:6: note: declared here
    124 | void invalid_degamma_lut_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~~
  ../tests/kms_color_chamelium.c:765:3: error: too few arguments to function ‘invalid_ctm_matrix_sizes’
    765 |   invalid_ctm_matrix_sizes(&data);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ../tests/kms_color_chamelium.c:25:
  ../tests/kms_color_helper.h:126:6: note: declared here
    126 | void invalid_ctm_matrix_sizes(data_t *data, enum pipe p);
        |      ^~~~~~~~~~~~~~~~~~~~~~~~
  ninja: build stopped: subcommand failed.
  section_end:1630685997:step_script
  section_start:1630685997:cleanup_file_variables
  Cleaning up file based variables
  section_end:1630685998:cleanup_file_variables
  ERROR: Job failed: exit code 1

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/394644

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

end of thread, other threads:[~2021-09-03 16:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03 16:15 [igt-dev] [PATCH i-g-t v2 0/6] tests/kms_color: 3D LUT tests Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 1/6] tests/kms_color: Refactor invalid LUT size tests Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 2/6] tests/kms_color: Store r/g/b separately for LUT color tests Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 3/6] tests/kms_color: Pass pipe to invalid LUT size tests Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 4/6] tests/kms_color: Run each subtest only for a single connector Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 5/6] lib/kms: Add GAMMA_LUT_3D support Ville Syrjala
2021-09-03 16:15 ` [igt-dev] [PATCH i-g-t v2 6/6] tests/kms_color: Add GAMMA_LUT_3D tests Ville Syrjala
2021-09-03 16:18 ` [igt-dev] ✗ Fi.CI.BUILD: failure for tests/kms_color: 3D LUT tests (rev4) Patchwork
2021-09-03 16:23 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.