[Intel-gfx] [PATCH 2/3] tests/drm_read: remove manual crtc<->pipe mapping from drm_read test
Micah Fedke
micah.fedke at collabora.co.uk
Fri Sep 4 11:22:58 PDT 2015
the crtc id is now always equivalent to its index in the array of crtcs
returned by the kernel
---
tests/drm_read.c | 43 +++++++++++++------------------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/tests/drm_read.c b/tests/drm_read.c
index b808bed..ab7e4ef 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -44,6 +44,8 @@
#include <sys/time.h>
#include <sys/poll.h>
#include "drm.h"
+#include "igt_core.h"
+#include "igt_kms.h"
IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
@@ -152,44 +154,25 @@ static void test_short_buffer(int in, int nonblock)
static int pipe0_enabled(int fd)
{
- struct drm_mode_card_res res;
- uint32_t crtcs[32];
- int i;
+ drmModeRes *res;
+ drmModeCrtc *crtc;
+ int ret;
/* 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;
+ res = drmModeGetResources(fd);
+ igt_assert(res);
+ crtc = drmModeGetCrtc(fd, res->crtcs[0]);
+ igt_assert(crtc);
- if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
- return 0;
+ ret = crtc->mode_valid && crtc->mode.clock;
- if (res.count_crtcs > 32)
- return 0;
+ drmModeFreeCrtc(crtc);
+ drmModeFreeResources(res);
- 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;
+ return ret;
}
igt_main
--
2.1.4
More information about the Intel-gfx
mailing list