All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 i-g-t] kms_rotation_crc: Exercise page flips with 90 degree rotation
Date: Wed,  7 Oct 2015 12:18:52 +0100	[thread overview]
Message-ID: <1444216732-3940-1-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)

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

Do some page flipping on the rotated plane just to exercise
that code path.

v2: Actually render to flip fb and fixed flip counter.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Sonika Jindal <sonika.jindal@intel.com>
Cc: Arun R Murthy <arun.r.murthy@intel.com>
---
 tests/kms_rotation_crc.c | 90 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 74 insertions(+), 16 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index cc9847ecc113..4fb00ab19b6c 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -31,6 +31,7 @@ typedef struct {
 	igt_display_t display;
 	struct igt_fb fb;
 	struct igt_fb fb_modeset;
+	struct igt_fb fb_flip;
 	igt_crc_t ref_crc;
 	igt_pipe_crc_t *pipe_crc;
 	igt_rotation_t rotation;
@@ -39,17 +40,18 @@ typedef struct {
 	unsigned int w, h;
 	uint32_t override_fmt;
 	uint64_t override_tiling;
+	unsigned int flip_stress;
 } data_t;
 
 static void
 paint_squares(data_t *data, drmModeModeInfo *mode, igt_rotation_t rotation,
-	      igt_plane_t *plane)
+	      struct igt_fb *fb, float o)
 {
 	cairo_t *cr;
 	unsigned int w = data->w;
 	unsigned int h = data->h;
 
-	cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb);
+	cr = igt_get_cairo_ctx(data->gfx_fd, fb);
 
 	if (rotation == IGT_ROTATION_180) {
 		cairo_translate(cr, w, h);
@@ -59,23 +61,23 @@ paint_squares(data_t *data, drmModeModeInfo *mode, igt_rotation_t rotation,
 	if (rotation == IGT_ROTATION_90) {
 		/* Paint 4 squares with width == height in Green, White,
 		Blue, Red Clockwise order to look like 270 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 1.0, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 1.0, 1.0, 1.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 1.0, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
+		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, o, 0.0);
+		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, o, o);
+		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, 0.0, 0.0);
+		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 0.0, o);
 	} else if (rotation == IGT_ROTATION_270) {
 		/* Paint 4 squares with width == height in Blue, Red,
 		Green, White Clockwise order to look like 90 degree rotated*/
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, 1.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 1.0, 0.0, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, 1.0, 0.0);
+		igt_paint_color(cr, 0, 0, w / 2, h / 2, 0.0, 0.0, o);
+		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, o, 0.0, 0.0);
+		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, o, o, o);
+		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 0.0, o, 0.0);
 	} else {
 		/* Paint with 4 squares of Red, Green, White, Blue Clockwise */
-		igt_paint_color(cr, 0, 0, w / 2, h / 2, 1.0, 0.0, 0.0);
-		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, 1.0, 0.0);
-		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
-		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
+		igt_paint_color(cr, 0, 0, w / 2, h / 2, o, 0.0, 0.0);
+		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, o, 0.0);
+		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, o);
+		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, o, o, o);
 	}
 
 	cairo_destroy(cr);
@@ -165,8 +167,18 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 			      &data->fb);
 	igt_assert(fb_id);
 
+	if (data->flip_stress) {
+		fb_id = igt_create_fb(data->gfx_fd,
+				      w, h,
+				      pixel_format,
+				      tiling,
+				      &data->fb_flip);
+		igt_assert(fb_id);
+		paint_squares(data, mode, IGT_ROTATION_0, &data->fb_flip, 0.92);
+	}
+
 	/* Step 1: create a reference CRC for a software-rotated fb */
-	paint_squares(data, mode, data->rotation, plane);
+	paint_squares(data, mode, data->rotation, &data->fb, 1.0);
 	commit_crtc(data, output, plane);
 	igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
 
@@ -174,7 +186,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 	 * Step 2: prepare the plane with an non-rotated fb let the hw
 	 * rotate it.
 	 */
-	paint_squares(data, mode, IGT_ROTATION_0, plane);
+	paint_squares(data, mode, IGT_ROTATION_0, &data->fb, 1.0);
 	igt_plane_set_fb(plane, &data->fb);
 }
 
@@ -187,6 +199,8 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 
 	igt_remove_fb(data->gfx_fd, &data->fb);
 	igt_remove_fb(data->gfx_fd, &data->fb_modeset);
+	if (data->fb_flip.fb_id)
+		igt_remove_fb(data->gfx_fd, &data->fb_flip);
 
 	/* XXX: see the note in prepare_crtc() */
 	if (!plane->is_primary) {
@@ -202,6 +216,23 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 	igt_display_commit(display);
 }
 
+static void wait_for_pageflip(int fd)
+{
+	drmEventContext evctx = { .version = DRM_EVENT_CONTEXT_VERSION };
+	struct timeval timeout = { .tv_sec = 0, .tv_usec = 32000 };
+	fd_set fds;
+	int ret;
+
+	/* Wait for pageflip completion, then consume event on fd */
+	FD_ZERO(&fds);
+	FD_SET(fd, &fds);
+	do {
+		ret = select(fd + 1, &fds, NULL, NULL, &timeout);
+	} while (ret < 0 && errno == EINTR);
+	igt_assert_eq(ret, 1);
+	igt_assert(drmHandleEvent(fd, &evctx) == 0);
+}
+
 static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 {
 	igt_display_t *display = &data->display;
@@ -210,6 +241,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;
+	unsigned int flip_count;
 	int ret;
 
 	if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) {
@@ -245,6 +277,24 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 						     &crc_output);
 			}
 
+			flip_count = data->flip_stress;
+			while (flip_count--) {
+				ret = drmModePageFlip(data->gfx_fd,
+						      output->config.crtc->crtc_id,
+						      data->fb_flip.fb_id,
+						      DRM_MODE_PAGE_FLIP_EVENT,
+						      NULL);
+				igt_assert(ret == 0);
+				wait_for_pageflip(data->gfx_fd);
+				ret = drmModePageFlip(data->gfx_fd,
+						      output->config.crtc->crtc_id,
+						      data->fb.fb_id,
+						      DRM_MODE_PAGE_FLIP_EVENT,
+						      NULL);
+				igt_assert(ret == 0);
+				wait_for_pageflip(data->gfx_fd);
+			}
+
 			/*
 			 * check the rotation state has been reset when the VT
 			 * mode is restored
@@ -345,6 +395,14 @@ igt_main
 		test_plane_rotation(&data, IGT_PLANE_PRIMARY);
 	}
 
+	igt_subtest_f("primary-rotation-90-flip-stress") {
+		igt_require(gen >= 9);
+		data.override_tiling = 0;
+		data.flip_stress = 60;
+		data.rotation = IGT_ROTATION_90;
+		test_plane_rotation(&data, IGT_PLANE_PRIMARY);
+	}
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
-- 
1.9.1

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

                 reply	other threads:[~2015-10-07 11:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1444216732-3940-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.