kms_rotation_crc: Make tests pass.

Some tests were failing to set size after rotation, which resulted in
some tests failing.

Another reason was that the test assumed that vdisplay < hdisplay, this
is not the case for a 4k DP-MST display, which runs in 1920x2160 mode.

The vtcon switching test was also bogus and caused failures. It's not
always true and even on a system with fbcon I was seeing a test failure
because the vt never switched.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index cb0ac1e..eae3a7e 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -97,22 +97,28 @@
 	 * we create an fb covering the crtc and call commit
 	 */
 
-	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
-	igt_plane_set_fb(primary, &data->fb_modeset);
-	primary->rotation_changed = false;
-	igt_display_commit(display);
-
-	igt_plane_set_fb(plane, &data->fb);
-
-	if (!plane->is_cursor)
-		igt_plane_set_position(plane, data->pos_x, data->pos_y);
-
 	if (plane->is_primary || plane->is_cursor)
 		commit = COMMIT_UNIVERSAL;
 
 	if (data->display.is_atomic)
 		commit = COMMIT_ATOMIC;
 
+	primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+
+	if (commit < COMMIT_ATOMIC) {
+		igt_plane_set_fb(primary, &data->fb_modeset);
+		primary->rotation_changed = false;
+		igt_display_commit(display);
+
+		if (plane->is_primary)
+			primary->rotation_changed = true;
+	}
+
+	igt_plane_set_fb(plane, &data->fb);
+
+	if (!plane->is_cursor)
+		igt_plane_set_position(plane, data->pos_x, data->pos_y);
+
 	igt_display_commit2(display, commit);
 }
 
@@ -128,6 +134,7 @@
 				data->override_fmt : DRM_FORMAT_XRGB8888;
 
 	igt_output_set_pipe(output, pipe);
+	igt_plane_set_rotation(plane, IGT_ROTATION_0);
 
 	/* create the pipe_crc object for this pipe */
 	igt_pipe_crc_free(data->pipe_crc);
@@ -153,7 +160,7 @@
 	    data->rotation == IGT_ROTATION_270) {
 		tiling = data->override_tiling ?
 			 data->override_tiling : LOCAL_I915_FORMAT_MOD_Y_TILED;
-		w = h =  mode->vdisplay;
+		w = h = min(mode->hdisplay, mode->vdisplay);
 	} else if (plane->is_cursor) {
 		pixel_format = data->override_fmt ?
 			       data->override_fmt : DRM_FORMAT_ARGB8888;
@@ -214,6 +221,10 @@
 	}
 
 	igt_plane_set_fb(plane, NULL);
+	igt_plane_set_rotation(plane, IGT_ROTATION_0);
+
+	igt_display_commit2(display, COMMIT_UNIVERSAL);
+
 	igt_output_set_pipe(output, PIPE_ANY);
 
 	igt_display_commit(display);
@@ -301,18 +312,6 @@
 			wait_for_pageflip(data->gfx_fd);
 		}
 
-		/*
-		  * check the rotation state has been reset when the VT
-		  * mode is restored
-		  */
-		kmstest_restore_vt_mode();
-		kmstest_set_vt_graphics_mode();
-
-		commit_crtc(data, output, plane);
-
-		igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
-		igt_assert_crc_equal(&crc_unrotated, &crc_output);
-
 		valid_tests++;
 		cleanup_crtc(data, output, plane);
 	}
@@ -372,11 +371,14 @@
 
 	igt_plane_set_rotation(plane, data->rotation);
 	igt_plane_set_fb(plane, &data->fb);
+	igt_plane_set_size(plane, h, w);
 
-	drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
-				 DRM_MODE_OBJECT_PLANE,
-				 plane->rotation_property,
-				 plane->rotation);
+	if (commit < COMMIT_ATOMIC)
+		drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
+					DRM_MODE_OBJECT_PLANE,
+					plane->rotation_property,
+					plane->rotation);
+
 	ret = igt_display_try_commit2(display, commit);
 
 	igt_output_set_pipe(output, PIPE_NONE);
@@ -466,6 +468,7 @@
 		}
 
 		igt_plane_set_rotation(plane, IGT_ROTATION_90);
+		igt_plane_set_size(plane, h, w);
 
 		drmModeObjectSetProperty(fd, plane->drm_plane->plane_id,
 					 DRM_MODE_OBJECT_PLANE,