public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: ville.syrjala@intel.com, martin.peres@intel.com,
	stanislav.lisovskiy@intel.com
Subject: [igt-dev] [PATCH i-g-t v3 3/3] igt/tests/kms_atomic_transition: Remove redundant code
Date: Mon,  1 Apr 2019 14:23:05 +0300	[thread overview]
Message-ID: <20190401112305.6832-4-stanislav.lisovskiy@intel.com> (raw)
In-Reply-To: <20190401112305.6832-1-stanislav.lisovskiy@intel.com>

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

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@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

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

  parent reply	other threads:[~2019-04-01 11:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 11:23 [igt-dev] [PATCH i-g-t v3 0/3] kms_atomic_transition improvements Stanislav Lisovskiy
2019-04-01 11:23 ` [igt-dev] [PATCH i-g-t v3 1/3] igt/tests/kms_atomic_transition: Skip transition, if no changes done Stanislav Lisovskiy
2019-04-01 23:04   ` Souza, Jose
2019-04-02  6:59     ` Lisovskiy, Stanislav
2019-04-01 11:23 ` [igt-dev] [PATCH i-g-t v3 2/3] igt/tests/kms_atomic_transition: Tolerate if can't have all planes Stanislav Lisovskiy
2019-04-02 20:42   ` Souza, Jose
2019-04-03  8:08     ` Lisovskiy, Stanislav
2019-04-01 11:23 ` Stanislav Lisovskiy [this message]
2019-04-01 12:07 ` [igt-dev] ✗ Fi.CI.BAT: failure for kms_atomic_transition improvements (rev3) Patchwork
2019-04-01 13:42 ` [igt-dev] ✗ Fi.CI.BAT: failure for kms_atomic_transition improvements (rev4) Patchwork
2019-04-02  8:59 ` [igt-dev] ✓ Fi.CI.BAT: success for kms_atomic_transition improvements (rev5) Patchwork
2019-04-02 13:50 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401112305.6832-4-stanislav.lisovskiy@intel.com \
    --to=stanislav.lisovskiy@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=martin.peres@intel.com \
    --cc=ville.syrjala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox