summaryrefslogtreecommitdiff
path: root/tests/drm_read.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2016-02-26 09:55:48 +0100
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2016-04-25 14:21:35 +0200
commita8be527172022d3a12196505ee6a78bee852da94 (patch)
tree1fafec744d7123c209aeee02b65c4bb6eeeb8859 /tests/drm_read.c
parent90a7e3bae5987d1b5fb7fe4d5413bde2b9755bca (diff)
tests/drm_read: Drop DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID
So the test runs on other drivers, drop the usage of the i915-specific DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID ioctl. Wait for a vblank event on pipe0 and if we get it, then the test can proceed (code copied from kms_vblank). Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Diffstat (limited to 'tests/drm_read.c')
-rw-r--r--tests/drm_read.c44
1 files changed, 5 insertions, 39 deletions
diff --git a/tests/drm_read.c b/tests/drm_read.c
index 3980bb05..7df36e96 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -175,46 +175,12 @@ static void test_short_buffer(int in, int nonblock)
teardown(fd);
}
-static int pipe0_enabled(int fd)
+static bool crtc0_active(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;
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ return drmIoctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl) == 0;
}
igt_main
@@ -226,7 +192,7 @@ igt_main
igt_fixture {
fd = drm_open_driver_master(DRIVER_ANY);
- igt_require(pipe0_enabled(fd));
+ igt_require(crtc0_active(fd));
}
igt_subtest("invalid-buffer")