diff mbox

[i-g-t] drm_read: Remove use of DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID

Message ID 1457530932-439-1-git-send-email-tomeu.vizoso@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomeu Vizoso March 9, 2016, 1:42 p.m. UTC
Instead of checking that there's a CRTC in pipe 0 with a valid mode,
check that we can get a vblank in the primary display controller.

This should be equivalent, but also works with drivers other than i915.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 tests/drm_read.c | 39 +++++----------------------------------
 1 file changed, 5 insertions(+), 34 deletions(-)
diff mbox

Patch

diff --git a/tests/drm_read.c b/tests/drm_read.c
index faa3df862ea6..52dfa8ab8781 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -189,46 +189,17 @@  static void test_short_buffer(int in, int nonblock)
 	teardown(fd);
 }
 
-static int pipe0_enabled(int fd)
+static bool pipe0_enabled(int fd)
 {
-	struct drm_mode_card_res res;
-	uint32_t crtcs[32];
-	int i;
+	union drm_wait_vblank vbl;
 
 	/* We assume we can generate events on pipe 0. So we have better
 	 * make sure that is running!
 	 */
 
-	memset(&res, 0, sizeof(res));
-	res.count_crtcs = 32;
-	res.crtc_id_ptr = (uintptr_t)crtcs;
-
-	if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
-		return 0;
-
-	if (res.count_crtcs > 32)
-		return 0;
-
-	for (i = 0; i < res.count_crtcs; i++) {
-		struct drm_i915_get_pipe_from_crtc_id get_pipe;
-		struct drm_mode_crtc mode;
-
-		memset(&get_pipe, 0, sizeof(get_pipe));
-		memset(&mode, 0, sizeof(mode));
-
-		mode.crtc_id = crtcs[i];
-
-		get_pipe.pipe = -1;
-		get_pipe.crtc_id = mode.crtc_id;
-		drmIoctl(fd, DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, &get_pipe);
-		if (get_pipe.pipe)
-			continue;
-
-		drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &mode);
-		return mode.mode_valid && mode.mode.clock;
-	}
-
-	return 0;
+	memset(&vbl, 0, sizeof(vbl));
+	vbl.request.type = DRM_VBLANK_RELATIVE;
+	return drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl) == 0;
 }
 
 igt_main