public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/4] tests/kms_cursor_crc: Use igt_kms calls for everything.
Date: Mon, 29 Apr 2019 18:05:57 +0200	[thread overview]
Message-ID: <20190429160557.17889-5-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20190429160557.17889-1-maarten.lankhorst@linux.intel.com>

Instead of doing direct drm calls, we can use the core to do it for
us. This can be used to increase logging verbosity, but it will also
allow us to test on overlay planes by changing all references from
DRM_PLANE_TYPE_CURSOR to DRM_PLANE_TYPE_OVERLAY.

This fails on gen9-10 because of the alpha rounding error bug, but it
can be useful for testing if the tests themselves are broken.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 tests/kms_cursor_crc.c | 71 ++++++++++++++++++++++++------------------
 1 file changed, 41 insertions(+), 30 deletions(-)

diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index ed44a2ab803e..d0fb8f1d156e 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -89,20 +89,22 @@ static void draw_cursor(cairo_t *cr, int x, int y, int cw, int ch, double a)
 static void cursor_enable(data_t *data)
 {
 	igt_output_t *output = data->output;
-	igt_plane_t *cursor;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR);
 
-	cursor = igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR);
 	igt_plane_set_fb(cursor, &data->fb);
 	igt_plane_set_size(cursor, data->curw, data->curh);
+	igt_fb_set_size(&data->fb, cursor, data->curw, data->curh);
 }
 
 static void cursor_disable(data_t *data)
 {
 	igt_output_t *output = data->output;
-	igt_plane_t *cursor;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR);
 
-	cursor = igt_output_get_plane_type(output, DRM_PLANE_TYPE_CURSOR);
 	igt_plane_set_fb(cursor, NULL);
+	igt_plane_set_position(cursor, 0, 0);
 }
 
 static bool chv_cursor_broken(data_t *data, int x)
@@ -146,7 +148,8 @@ static void do_single_test(data_t *data, int x, int y)
 	igt_display_t *display = &data->display;
 	igt_pipe_crc_t *pipe_crc = data->pipe_crc;
 	igt_crc_t crc, ref_crc;
-	igt_plane_t *cursor;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 	cairo_t *cr;
 	int ret = 0;
 
@@ -158,7 +161,6 @@ static void do_single_test(data_t *data, int x, int y)
 	igt_put_cairo_ctx(data->drm_fd, &data->primary_fb, cr);
 
 	cursor_enable(data);
-	cursor = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 	igt_plane_set_position(cursor, x, y);
 
 	if (chv_cursor_broken(data, x) && cursor_visible(data, x, y)) {
@@ -217,7 +219,8 @@ static void do_single_test(data_t *data, int x, int y)
 static void do_fail_test(data_t *data, int x, int y, int expect)
 {
 	igt_display_t *display = &data->display;
-	igt_plane_t *cursor;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 	cairo_t *cr;
 	int ret;
 
@@ -229,7 +232,6 @@ static void do_fail_test(data_t *data, int x, int y, int expect)
 	igt_put_cairo_ctx(data->drm_fd, &data->primary_fb, cr);
 
 	cursor_enable(data);
-	cursor = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 	igt_plane_set_position(cursor, x, y);
 	ret = igt_display_try_commit2(display, COMMIT_LEGACY);
 
@@ -402,7 +404,6 @@ static void test_cursor_alpha(data_t *data, double a)
 	uint32_t fb_id;
 	int curw = data->curw;
 	int curh = data->curh;
-	int ret;
 
 	/*alpha cursor fb*/
 	fb_id = igt_create_fb(data->drm_fd, curw, curh,
@@ -416,8 +417,7 @@ static void test_cursor_alpha(data_t *data, double a)
 
 	/*Hardware Test*/
 	cursor_enable(data);
-	ret = drmModeSetCursor(data->drm_fd, data->output->config.crtc->crtc_id, data->fb.gem_handle, curw, curh);
-	igt_assert_eq(ret, 0);
+	igt_display_commit(display);
 	igt_wait_for_vblank(data->drm_fd, data->pipe);
 	igt_pipe_crc_collect_crc(pipe_crc, &crc);
 	cursor_disable(data);
@@ -512,7 +512,8 @@ static void test_cursor_size(data_t *data)
 	uint32_t fb_id;
 	int i, size;
 	int cursor_max_size = data->cursor_max_w;
-	int ret;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 
 	/* Create a maximum size cursor, then change the size in flight to
 	 * smaller ones to see that the size is applied correctly
@@ -529,17 +530,16 @@ static void test_cursor_size(data_t *data)
 
 	/* Hardware test loop */
 	cursor_enable(data);
-	ret = drmModeMoveCursor(data->drm_fd, data->output->config.crtc->crtc_id, 0, 0);
-	igt_assert_eq(ret, 0);
 	for (i = 0, size = cursor_max_size; size >= 64; size /= 2, i++) {
 		/* Change size in flight: */
-		ret = drmModeSetCursor(data->drm_fd, data->output->config.crtc->crtc_id,
-				       data->fb.gem_handle, size, size);
-		igt_assert_eq(ret, 0);
+		igt_plane_set_size(cursor, size, size);
+		igt_fb_set_size(&data->fb, cursor, size, size);
+		igt_display_commit(display);
 		igt_wait_for_vblank(data->drm_fd, data->pipe);
 		igt_pipe_crc_collect_crc(pipe_crc, &crc[i]);
 	}
 	cursor_disable(data);
+	igt_display_commit(display);
 	igt_remove_fb(data->drm_fd, &data->fb);
 	/* Software test loop */
 	for (i = 0, size = cursor_max_size; size >= 64; size /= 2, i++) {
@@ -565,20 +565,29 @@ static void test_rapid_movement(data_t *data)
 	struct timeval start, end, delta;
 	int x = 0, y = 0;
 	long usec;
-	int crtc_id = data->output->config.crtc->crtc_id;
+	igt_display_t *display = &data->display;
+	igt_plane_t *cursor =
+		igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_CURSOR);
 
-	igt_assert_eq(drmModeSetCursor(data->drm_fd, crtc_id,
-			       data->fb.gem_handle, data->curw, data->curh), 0);
+	cursor_enable(data);
 
 	gettimeofday(&start, NULL);
-	for ( ; x < 100; x++)
-		igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
-	for ( ; y < 100; y++)
-		igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
-	for ( ; x > 0; x--)
-		igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
-	for ( ; y > 0; y--)
-		igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
+	for ( ; x < 100; x++) {
+		igt_plane_set_position(cursor, x, y);
+		igt_display_commit(display);
+	}
+	for ( ; y < 100; y++) {
+		igt_plane_set_position(cursor, x, y);
+		igt_display_commit(display);
+	}
+	for ( ; x > 0; x--) {
+		igt_plane_set_position(cursor, x, y);
+		igt_display_commit(display);
+	}
+	for ( ; y > 0; y--) {
+		igt_plane_set_position(cursor, x, y);
+		igt_display_commit(display);
+	}
 	gettimeofday(&end, NULL);
 
 	/*
@@ -665,8 +674,10 @@ static void run_tests_on_pipe(data_t *data, enum pipe pipe)
 		 */
 		h /= 3;
 
-		igt_fixture
-			create_cursor_fb(data, w, h);
+		igt_fixture {
+			if (has_nonsquare_cursors(data))
+				create_cursor_fb(data, w, h);
+		}
 
 		/* Using created cursor FBs to test cursor support */
 		igt_subtest_f("pipe-%s-cursor-%dx%d-onscreen", kmstest_pipe_name(pipe), w, h) {
-- 
2.20.1

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

  parent reply	other threads:[~2019-04-29 16:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 16:05 [igt-dev] [PATCH i-g-t 0/4] kms_cursor_crc test improvements and cleanups Maarten Lankhorst
2019-04-29 16:05 ` [igt-dev] [PATCH i-g-t 1/4] tests/kms_cursor_crc: Run tests once per pipe Maarten Lankhorst
2019-04-29 16:05 ` [igt-dev] [PATCH i-g-t 2/4] tests/kms_cursor_crc: Handle display cleanup in init Maarten Lankhorst
2019-04-29 16:05 ` [igt-dev] [PATCH i-g-t 3/4] lib/igt_kms: Update cursor when fb width/height changes too Maarten Lankhorst
2019-04-29 16:05 ` Maarten Lankhorst [this message]
2019-04-29 16:57 ` [igt-dev] ✓ Fi.CI.BAT: success for kms_cursor_crc test improvements and cleanups Patchwork
2019-04-29 22:31 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-05-11 15:17 ` [igt-dev] [PATCH i-g-t 0/4] " Juha-Pekka Heikkilä
2019-05-13 15:07   ` Maarten Lankhorst

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=20190429160557.17889-5-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=igt-dev@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