public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 7/7] kms_rotation_crc: Use main test for negative cases
Date: Wed, 22 Apr 2015 16:46:48 +0100	[thread overview]
Message-ID: <1429717608-359-8-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1429717608-359-1-git-send-email-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Saves a good amount of code duplication by supporting expected
failures from the main loop.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Sonika Jindal <sonika.jindal@intel.com>
---
 tests/kms_rotation_crc.c | 106 +++++++++++++++--------------------------------
 1 file changed, 33 insertions(+), 73 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index 45a9284..0661b6b 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -41,6 +41,8 @@ typedef struct {
 	int pos_x;
 	int pos_y;
 	unsigned int w, h;
+	uint32_t override_fmt;
+	uint64_t override_tiling;
 } data_t;
 
 static void
@@ -92,8 +94,10 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	igt_display_t *display = &data->display;
 	int fb_id, fb_modeset_id;
 	unsigned int w, h;
-	uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
-	uint32_t pixel_format = DRM_FORMAT_XRGB8888;
+	uint64_t tiling = data->override_tiling ?
+			  data->override_tiling : LOCAL_DRM_FORMAT_MOD_NONE;
+	uint32_t pixel_format = data->override_fmt ?
+				data->override_fmt : DRM_FORMAT_XRGB8888;
 	enum igt_commit_style commit = COMMIT_LEGACY;
 	igt_plane_t *primary;
 
@@ -132,10 +136,12 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	 */
 	if (data->rotation == IGT_ROTATION_90 ||
 	    data->rotation == IGT_ROTATION_270) {
-		tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
+		tiling = data->override_tiling ?
+			 data->override_tiling : LOCAL_I915_FORMAT_MOD_Y_TILED;
 		w = h =  mode->vdisplay;
 	} else if (plane->is_cursor) {
-		pixel_format = DRM_FORMAT_ARGB8888;
+		pixel_format = data->override_fmt ?
+			       data->override_fmt : DRM_FORMAT_ARGB8888;
 		w = h = 128;
 	}
 
@@ -196,67 +202,6 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 	igt_display_commit(display);
 }
 
-static void test_unsupported_tiling_pixel_format(data_t *data, enum igt_plane plane_type)
-{
-	drmModeModeInfo *mode;
-	igt_display_t *display = &data->display;
-	igt_output_t *output;
-	enum pipe pipe;
-	int fb_tiling_id, fb_565_id;
-	struct igt_fb fb_565, fb_tiling;
-
-	for_each_connected_output(display, output) {
-		for_each_pipe(display, pipe) {
-			igt_plane_t *plane;
-
-			igt_output_set_pipe(output, pipe);
-
-			plane = igt_output_get_plane(output, plane_type);
-			igt_require(igt_plane_supports_rotation(plane));
-			mode = igt_output_get_mode(output);
-
-			fb_tiling_id = igt_create_fb(data->gfx_fd,
-					mode->hdisplay, mode->vdisplay,
-					DRM_FORMAT_XRGB8888,
-					LOCAL_DRM_FORMAT_MOD_NONE,
-					&fb_tiling);
-			igt_assert(fb_tiling_id);
-			igt_plane_set_fb(plane, &fb_tiling);
-			/* For the first modeset with legacy commit */
-			igt_display_commit(display);
-			igt_plane_set_rotation(plane, data->rotation);
-			/* Shud fail because 90/270 is only supported with Y/Yf */
-			igt_assert(igt_display_try_commit2(display, COMMIT_UNIVERSAL) == -EINVAL);
-
-			fb_565_id = igt_create_fb(data->gfx_fd,
-					mode->hdisplay, mode->vdisplay,
-					DRM_FORMAT_RGB565,
-					LOCAL_I915_FORMAT_MOD_Y_TILED,
-					&fb_565);
-			igt_assert(fb_565_id);
-			igt_plane_set_fb(plane, &fb_565);
-			igt_plane_set_rotation(plane, data->rotation);
-			/* Shud fail because 90/270 is not supported with RGB565 */
-			igt_assert(igt_display_try_commit2(display, COMMIT_UNIVERSAL) == -EINVAL);
-
-			/*
-			 * check the rotation state has been reset when the VT
-			 * mode is restored
-			 */
-			kmstest_restore_vt_mode();
-			kmstest_set_vt_graphics_mode();
-			prepare_crtc(data, output, pipe, plane);
-
-			igt_remove_fb(data->gfx_fd, &fb_tiling);
-			igt_remove_fb(data->gfx_fd, &fb_565);
-			cleanup_crtc(data, output, plane);
-
-			igt_display_commit(display);
-
-		}
-	}
-}
-
 static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 {
 	igt_display_t *display = &data->display;
@@ -265,6 +210,7 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 	int valid_tests = 0;
 	igt_crc_t crc_output, crc_unrotated;
 	enum igt_commit_style commit = COMMIT_LEGACY;
+	int ret;
 
 	if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) {
 		igt_require(data->display.has_universal_planes);
@@ -288,11 +234,16 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 			igt_pipe_crc_collect_crc(data->pipe_crc, &crc_unrotated);
 
 			igt_plane_set_rotation(plane, data->rotation);
-			igt_display_commit2(display, commit);
-
-			igt_pipe_crc_collect_crc(data->pipe_crc, &crc_output);
-
-			igt_assert_crc_equal(&data->ref_crc, &crc_output);
+			ret = igt_display_try_commit2(display, commit);
+			if (data->override_fmt || data->override_tiling) {
+				igt_assert(ret == -EINVAL);
+			} else {
+				igt_assert(ret == 0);
+				igt_pipe_crc_collect_crc(data->pipe_crc,
+							 &crc_output);
+				igt_assert_crc_equal(&data->ref_crc,
+						     &crc_output);
+			}
 
 			/*
 			 * check the rotation state has been reset when the VT
@@ -376,12 +327,21 @@ igt_main
 		test_plane_rotation(&data, IGT_PLANE_2);
 	}
 
-	igt_subtest_f("90-rotation-unsupported-tiling-pixel-format") {
+	igt_subtest_f("bad-pixel-format") {
 		igt_require(gen >= 9);
-		data.rotation = IGT_ROTATION_90;
 		data.pos_x = 0,
 		data.pos_y = 0;
-		test_unsupported_tiling_pixel_format(&data, IGT_PLANE_PRIMARY);
+		data.rotation = IGT_ROTATION_90;
+		data.override_fmt = DRM_FORMAT_RGB565;
+		test_plane_rotation(&data, IGT_PLANE_PRIMARY);
+	}
+
+	igt_subtest_f("bad-tiling") {
+		igt_require(gen >= 9);
+		data.override_fmt = 0;
+		data.rotation = IGT_ROTATION_90;
+		data.override_tiling = LOCAL_DRM_FORMAT_MOD_NONE;
+		test_plane_rotation(&data, IGT_PLANE_PRIMARY);
 	}
 
 	igt_fixture {
-- 
2.3.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-04-22 15:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 15:46 [PATCH i-g-t 0/7] kms_rotation_crc cleanups Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 1/7] kms_rotation_crc: Local framebuffers do not need to be global Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 2/7] kms_rotation_crc: Framebuffer used for initial modeset does not need to be painted Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 3/7] kms_rotation_crc: Remove unused variable in negative test Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 4/7] kms_rotation_crc: Negative test does not need to render anything Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 5/7] kms_rotation_crc: Consolidate plane and cursor code paths Tvrtko Ursulin
2015-04-22 15:46 ` [PATCH i-g-t 6/7] kms_rotation_crc: No need to square the buffer in paint Tvrtko Ursulin
2015-04-22 15:46 ` Tvrtko Ursulin [this message]
2015-04-23  9:41   ` [PATCH i-g-t 7/7] kms_rotation_crc: Use main test for negative cases Jindal, Sonika
2015-04-27 17:30     ` Thomas Wood

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=1429717608-359-8-git-send-email-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    /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