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

Stanislav Lisovskiy
2019-03-29T11:29:13Z

Removed unneeded overlays variable, changed the parms
initialization cycle that it initializes also iter_mask
and parms[i].mask at the same time, fullfiling the same
requirements(i.e always use primary, cursor and one sprite
plane, for the rest parms[i].mask is randomized).

Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com>
---
tests/kms_atomic_transition.c | 38 ++++++++++++-----------------------
1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 638fe17e..ed271532 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -212,9 +212,9 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
unsigned sprite_width, sprite_height, prev_w, prev_h;
bool max_sprite_width, max_sprite_height, alpha = true;
uint32_t n_planes = display->pipes[pipe].n_planes;
- uint32_t n_overlays = 0, overlays[n_planes];
+ uint32_t n_overlays;
igt_plane_t *plane;
- uint32_t iter_mask = 3;
+ uint32_t iter_mask;

do_or_die(drmGetCap(display->drm_fd, DRM_CAP_CURSOR_WIDTH, &cursor_width));
if (cursor_width >= mode->hdisplay)
@@ -224,6 +224,9 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
if (cursor_height >= mode->vdisplay)
cursor_height = mode->vdisplay;

+ n_overlays = 0;
+ iter_mask = 0;
+
for_each_plane_on_pipe(display, pipe, plane) {
int i = plane->index;

@@ -231,36 +234,21 @@ static void setup_parms(igt_display_t *display, enum pipe pipe,
parms[i].fb = primary_fb;
parms[i].width = mode->hdisplay;
parms[i].height = mode->vdisplay;
- parms[i].mask = 1 << 0;
} else if (plane->type == DRM_PLANE_TYPE_CURSOR) {
parms[i].fb = argb_fb;
parms[i].width = cursor_width;
parms[i].height = cursor_height;
- parms[i].mask = 1 << 1;
} else {
parms[i].fb = sprite_fb;
- parms[i].mask = 1 << 2;
-
- iter_mask |= 1 << 2;
-
- overlays[n_overlays++] = i;
+ n_overlays++;
}
- }
-
- if (n_overlays >= 2) {
- uint32_t i;
-
- /*
- * Create 2 groups for overlays, make sure 1 plane is put
- * in each then spread the rest out.
- */
- iter_mask |= 1 << 3;
- parms[overlays[n_overlays - 1]].mask = 1 << 3;
-
- for (i = 1; i < n_overlays - 1; i++) {
- int val = hars_petruska_f54_1_random_unsafe_max(2);
-
- parms[overlays[i]].mask = 1 << (2 + val);
+ iter_mask |= 1 << i;
+ if (i <= 2) {
+ /* always leave one plane as in original algorithm */
+ parms[i].mask = 1 << i;
+ }
+ else {
+ parms[i].mask = hars_petruska_f54_1_random_unsafe_max(2) << i;
}
}

--
2.17.1