[igt-dev] [PATCH i-g-t v3 3/3] igt/tests/kms_atomic_transition: Remove redundant code

Stanislav Lisovskiy stanislav.lisovskiy at intel.com
Mon Apr 1 11:23:05 UTC 2019


Removed excessive nested conditions, making code a bit
more readable(hopefully).

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy at intel.com>
---
 tests/kms_atomic_transition.c | 86 +++++++++++++++--------------------
 1 file changed, 36 insertions(+), 50 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index e4dee7e2..175546dd 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -216,6 +216,7 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
 	igt_plane_t *plane;
 	uint32_t iter_mask;
 	int retries = n_planes - 1;
+	int ret = 0;
 
 	do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width));
 	if (cursor_width >= mode->hdisplay)
@@ -289,9 +290,7 @@ retry:
 	max_sprite_width = (sprite_width == mode->hdisplay);
 	max_sprite_height = (sprite_height == mode->vdisplay);
 
-	while (1) {
-		int ret;
-
+	while (!max_sprite_width && !max_sprite_height) {
 		set_sprite_wh(display, pipe, parms, sprite_fb,
 			      alpha, sprite_width, sprite_height);
 
@@ -299,64 +298,51 @@ retry:
 		ret = igt_display_try_commit_atomic(display, DRM_MODE_ATOMIC_TEST_ONLY | DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 		igt_assert(!is_atomic_check_failure_errno(ret));
 
-		if (is_atomic_check_plane_size_errno(ret)) {
-			if (cursor_width == sprite_width &&
-			    cursor_height == sprite_height) {
-				if (--retries >= 0) {
-					/* retry once with XRGB format. */
-					if (alpha) {
-						alpha = false;
-					}
-					else if (display->pipes[pipe].n_planes > 0) {
-						display->pipes[pipe].n_planes--;
-						igt_warn("Reduced available planes to %d\n",
-							    display->pipes[pipe].n_planes);
-					}
-					n_planes = display->pipes[pipe].n_planes;
-					igt_assert_f(n_planes > 0, "No planes left to proceed with!");
-					goto retry;
-				}
-				igt_assert_f(retries > 0,
-				      "Cannot configure the test with all sprite planes enabled\n");
-			}
-
-			sprite_width = prev_w;
-			sprite_height = prev_h;
-
-			if (max_sprite_width && max_sprite_height) {
-				set_sprite_wh(display, pipe, parms, sprite_fb,
-					      alpha, sprite_width, sprite_height);
-				break;
-			}
-
-			if (!max_sprite_width)
-				max_sprite_width = true;
-			else
-				max_sprite_height = true;
-		} else {
+		if (!is_atomic_check_plane_size_errno(ret)) {
 			prev_w = sprite_width;
 			prev_h = sprite_height;
-		}
-
-		if (!max_sprite_width) {
-			sprite_width *= 2;
-
+    
+			sprite_width *= max_sprite_width ? 1 : 2;
 			if (sprite_width >= mode->hdisplay) {
 				max_sprite_width = true;
-
 				sprite_width = mode->hdisplay;
 			}
-		} else if (!max_sprite_height) {
-			sprite_height *= 2;
 
+			sprite_height *= max_sprite_height ? 1 : 2;
 			if (sprite_height >= mode->vdisplay) {
 				max_sprite_height = true;
-
 				sprite_height = mode->vdisplay;
 			}
-		} else
-			/* Max sized sprites for all! */
-			break;
+			continue;
+		}
+
+		if (cursor_width == sprite_width &&
+		    cursor_height == sprite_height) {
+			igt_assert_f(retries > 0,
+				      "Cannot configure the test with all sprite planes enabled\n");
+			--retries;
+			/* retry once with XRGB format. */
+			if (alpha) {
+				alpha = false;
+			}
+			else {
+				igt_assert_f(n_planes > 1, "No planes left to proceed with!");
+
+				display->pipes[pipe].n_planes--;
+				n_planes = display->pipes[pipe].n_planes;
+				igt_warn("Reduced available planes to %d\n",
+					    display->pipes[pipe].n_planes);
+			}
+			goto retry;
+		}
+
+		sprite_width = prev_w;
+		sprite_height = prev_h;
+
+		if (!max_sprite_width)
+			max_sprite_width = true;
+		else
+			max_sprite_height = true;
 	}
 
 	igt_info("Running test on pipe %s with resolution %dx%d and sprite size %dx%d alpha %i\n",
-- 
2.17.1



More information about the igt-dev mailing list