[igt-dev] [PATCH i-g-t 13/16] tests/kms_big_fb: Nuke fliptab[]

Ville Syrjala ville.syrjala at linux.intel.com
Fri Jul 16 14:44:39 UTC 2021


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

Let's just stuff the full transformation into rotations[]
and get rid of fliptab[] and yet another nested loop.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 tests/kms_big_fb.c | 104 +++++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 50 deletions(-)

diff --git a/tests/kms_big_fb.c b/tests/kms_big_fb.c
index 6be3062bd335..4c120c602ed9 100644
--- a/tests/kms_big_fb.c
+++ b/tests/kms_big_fb.c
@@ -798,15 +798,17 @@ static const struct {
 	{ IGT_ROTATION_90, 90, },
 	{ IGT_ROTATION_180, 180, },
 	{ IGT_ROTATION_270, 270, },
+	{ IGT_ROTATION_0 | IGT_REFLECT_X, 0, },
+	{ IGT_ROTATION_90 | IGT_REFLECT_X, 90, },
+	{ IGT_ROTATION_180 | IGT_REFLECT_X, 180, },
+	{ IGT_ROTATION_270 | IGT_REFLECT_X, 270, },
 };
 
-static const struct {
-	igt_rotation_t flip;
-	const char *flipname;
-} fliptab[] = {
-	{ 0, "" },
-	{ IGT_REFLECT_X, "-hflip" },
-};
+static const char *rotation_flip_str(igt_rotation_t rotation)
+{
+	return rotation & IGT_REFLECT_X ? "-hflip" : "";
+}
+
 igt_main
 {
 	igt_fixture {
@@ -905,8 +907,9 @@ igt_main
 
 				igt_describe("Sanity check if addfb ioctl works correctly for given "
 						"combination of modifier formats and rotation");
-				igt_subtest_f("%s-%dbpp-rotate-%d", modifiers[i].name,
-					      formats[j].bpp, rotations[k].angle)
+				igt_subtest_f("%s-%dbpp-rotate-%d%s", modifiers[i].name,
+					      formats[j].bpp, rotations[k].angle,
+					      rotation_flip_str(rotations[k].rotation))
 					test_scanout(&data);
 			}
 
@@ -922,54 +925,55 @@ igt_main
 
 		set_max_hw_stride(&data);
 
-		for (int l = 0; l < ARRAY_SIZE(fliptab); l++) {
-			for (int j = 0; j < ARRAY_SIZE(formats); j++) {
-				/*
-				* try only those formats which can show full length.
-				* Here 32K is used to have CI test results consistent
-				* for all platforms, 32K is smallest number possbily
-				* coming to data.hw_stride from above set_max_hw_stride()
-				*/
-				if (32768 / (formats[j].bpp >> 3) > 8192)
+		for (int j = 0; j < ARRAY_SIZE(formats); j++) {
+			/*
+			 * try only those formats which can show full length.
+			 * Here 32K is used to have CI test results consistent
+			 * for all platforms, 32K is smallest number possbily
+			 * coming to data.hw_stride from above set_max_hw_stride()
+			 */
+			if (32768 / (formats[j].bpp >> 3) > 8192)
+				continue;
+
+			data.format = formats[j].format;
+
+			for (int k = 0; k < ARRAY_SIZE(rotations); k++) {
+				data.rotation = rotations[k].rotation;
+
+				// this combination will never happen.
+				if (igt_rotation_90_or_270(data.rotation) ||
+				    (data.rotation & IGT_REFLECT_X &&
+				     modifiers[i].modifier == DRM_FORMAT_MOD_LINEAR))
 					continue;
 
-				data.format = formats[j].format;
+				igt_describe("test maximum hardware supported stride length for given bpp and modifiers.");
+				igt_subtest_f("%s-max-hw-stride-%dbpp-rotate-%d%s", modifiers[i].name,
+					      formats[j].bpp, rotations[k].angle,
+					      rotation_flip_str(rotations[k].rotation)) {
+					igt_require(intel_display_ver(intel_get_drm_devid(data.drm_fd)) >= 5);
+					data.max_hw_fb_width = min(data.hw_stride / (formats[j].bpp >> 3), data.max_fb_width);
 
-				for (int k = 0; k < ARRAY_SIZE(rotations); k++) {
-					data.rotation = rotations[k].rotation | fliptab[l].flip;
-
-					// this combination will never happen.
-					if (igt_rotation_90_or_270(data.rotation) ||
-					    (fliptab[l].flip == IGT_REFLECT_X && modifiers[i].modifier == DRM_FORMAT_MOD_LINEAR))
-						continue;
-
-					igt_describe("test maximum hardware supported stride length for given bpp and modifiers.");
-					igt_subtest_f("%s-max-hw-stride-%dbpp-rotate-%d%s", modifiers[i].name,
-						formats[j].bpp, rotations[k].angle, fliptab[l].flipname) {
-						igt_require(intel_display_ver(intel_get_drm_devid(data.drm_fd)) >= 5);
-						data.max_hw_fb_width = min(data.hw_stride / (formats[j].bpp >> 3), data.max_fb_width);
-
-						test_scanout(&data);
-					}
+					test_scanout(&data);
+				}
 
-					// async flip doesn't support linear fbs.
-					if (modifiers[i].modifier == DRM_FORMAT_MOD_LINEAR)
-						continue;
+				// async flip doesn't support linear fbs.
+				if (modifiers[i].modifier == DRM_FORMAT_MOD_LINEAR)
+					continue;
 
-					data.async_flip_test = true;
-					igt_describe("test async flip on maximum hardware supported stride length for given bpp and modifiers.");
-					igt_subtest_f("%s-max-hw-stride-%dbpp-rotate-%d%s-async-flip", modifiers[i].name,
-						formats[j].bpp, rotations[k].angle, fliptab[l].flipname) {
-							igt_require(igt_has_drm_cap(data.drm_fd, DRM_CAP_ASYNC_PAGE_FLIP));
-							data.max_hw_fb_width = min(data.hw_stride / (formats[j].bpp >> 3), data.max_fb_width);
-							test_scanout(&data);
-					}
-					data.async_flip_test = false;
+				data.async_flip_test = true;
+				igt_describe("test async flip on maximum hardware supported stride length for given bpp and modifiers.");
+				igt_subtest_f("%s-max-hw-stride-%dbpp-rotate-%d%s-async-flip", modifiers[i].name,
+					      formats[j].bpp, rotations[k].angle,
+					      rotation_flip_str(rotations[k].rotation)) {
+					igt_require(igt_has_drm_cap(data.drm_fd, DRM_CAP_ASYNC_PAGE_FLIP));
+					data.max_hw_fb_width = min(data.hw_stride / (formats[j].bpp >> 3), data.max_fb_width);
+					test_scanout(&data);
 				}
-
-				igt_fixture
-					cleanup_fb(&data);
+				data.async_flip_test = false;
 			}
+
+			igt_fixture
+				cleanup_fb(&data);
 		}
 	}
 	data.max_hw_stride_test = false;
-- 
2.31.1



More information about the igt-dev mailing list