[i-g-t V2] tests/kms_color: Fix ctm-0.* tests

Bhanuprakash Modem bhanuprakash.modem at intel.com
Thu Sep 29 04:54:46 UTC 2022


As we are testing with a few values around the expected result
because of the hardware rounded values, fix the logic to generate
the expected values to deal with those hardware rounding issues.

V2:
- Other cleanup

Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_color.c        | 37 +++++++++++++++++++------------------
 tests/kms_color_helper.c |  4 ++--
 tests/kms_color_helper.h |  4 ++--
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/tests/kms_color.c b/tests/kms_color.c
index 2804bde8..0f9feffc 100644
--- a/tests/kms_color.c
+++ b/tests/kms_color.c
@@ -452,9 +452,9 @@ end:
  */
 static bool test_pipe_ctm(data_t *data,
 			  igt_plane_t *primary,
-			  color_t *before,
-			  color_t *after,
-			  double *ctm_matrix)
+			  const color_t *before,
+			  const color_t *after,
+			  const double *ctm_matrix)
 {
 	const double ctm_identity[] = {
 		1.0, 0.0, 0.0,
@@ -730,12 +730,12 @@ run_gamma_degamma_tests_for_pipe(data_t *data, enum pipe p,
 
 static void
 run_ctm_tests_for_pipe(data_t *data, enum pipe p,
-		       color_t *expected_colors,
-		       double *ctm,
-		       int iter)
+		       const color_t *expected_colors,
+		       const double *ctm,
+		       const int iterator)
 {
 	double delta;
-	color_t red_green_blue[] = {
+	const color_t red_green_blue[] = {
 		{ 1.0, 0.0, 0.0 },
 		{ 0.0, 1.0, 0.0 },
 		{ 0.0, 0.0, 1.0 }
@@ -754,9 +754,10 @@ run_ctm_tests_for_pipe(data_t *data, enum pipe p,
 
 	igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(p), data->output->name) {
 		bool success = false;
+		color_t expected[3];
 		int i;
 
-		if (!iter)
+		if (!iterator)
 			success = test_pipe_ctm(data, data->primary, red_green_blue,
 						expected_colors, ctm);
 
@@ -766,13 +767,13 @@ run_ctm_tests_for_pipe(data_t *data, enum pipe p,
 		 * get clamped or rounded values and we also need to account
 		 * for odd number of items in the LUTs.
 		 */
-		for (i = 0; i < iter; i++) {
-			expected_colors[0].r =
-				expected_colors[1].g =
-				expected_colors[2].b =
-				ctm[0] + delta * (i - (iter / 2));
+		for (i = 0; i < iterator; i++) {
+			expected[0].r =
+			expected[1].g =
+			expected[2].b =
+				ctm[0] + delta * (i - (iterator / 2));
 			if (test_pipe_ctm(data, data->primary, red_green_blue,
-					  expected_colors, ctm)) {
+					  (const color_t *) expected, ctm)) {
 				success = true;
 				break;
 			}
@@ -930,9 +931,9 @@ run_tests_for_pipe(data_t *data)
 	};
 	struct {
 		const char *name;
-		int iter;
-		color_t colors[3];
-		double ctm[9];
+		const int iterator;
+		const color_t colors[3];
+		const double ctm[9];
 		const char *desc;
 	} ctm_tests[] = {
 		{ "ctm-red-to-blue", 0,
@@ -1021,7 +1022,7 @@ run_tests_for_pipe(data_t *data)
 				run_ctm_tests_for_pipe(data, pipe,
 						       ctm_tests[i].colors,
 						       ctm_tests[i].ctm,
-						       ctm_tests[i].iter);
+						       ctm_tests[i].iterator);
 			}
 		}
 	}
diff --git a/tests/kms_color_helper.c b/tests/kms_color_helper.c
index 55f3e409..bd1f58c6 100644
--- a/tests/kms_color_helper.c
+++ b/tests/kms_color_helper.c
@@ -42,7 +42,7 @@ uint64_t get_max_bpc(igt_output_t *output)
 
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
-			       color_t *colors,
+			       const color_t *colors,
 			       struct igt_fb *fb)
 {
 	cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, fb);
@@ -78,7 +78,7 @@ void paint_gradient_rectangles(data_t *data,
 
 void paint_rectangles(data_t *data,
 		      drmModeModeInfo *mode,
-		      color_t *colors,
+		      const color_t *colors,
 		      struct igt_fb *fb)
 {
 	cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, fb);
diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h
index f0ae30e3..59be7dc1 100644
--- a/tests/kms_color_helper.h
+++ b/tests/kms_color_helper.h
@@ -73,11 +73,11 @@ bool panel_supports_deep_color(int fd, char *output_name);
 uint64_t get_max_bpc(igt_output_t *output);
 void paint_gradient_rectangles(data_t *data,
 			       drmModeModeInfo *mode,
-			       color_t *colors,
+			       const color_t *colors,
 			       struct igt_fb *fb);
 void paint_rectangles(data_t *data,
 		      drmModeModeInfo *mode,
-		      color_t *colors,
+		      const color_t *colors,
 		      struct igt_fb *fb);
 gamma_lut_t *alloc_lut(int lut_size);
 void free_lut(gamma_lut_t *gamma);
-- 
2.37.3



More information about the Intel-gfx-trybot mailing list