From: Micah Fedke <micah.fedke@collabora.co.uk>
To: intel-gfx <intel-gfx@lists.freedesktop.org>,
Daniel Vetter <daniel@ffwll.ch>,
chris@chris-wilson.co.uk, Daniel Stone <daniel@fooishbar.org>
Subject: [PATCH v2 5/5] tests: make drm_read platform agnostic
Date: Tue, 11 Aug 2015 11:59:16 -0400 [thread overview]
Message-ID: <55CA1BD4.10808@collabora.co.uk> (raw)
Update the drm_read test to operate on any platform to demonstrate the use of
drm_open_driver(OPEN_ANY_GPU).
To work on exynos, the event generation code is converted to use the new CRTC
selection API for vblank. The first valid crtc is selected at fixture-time.
pipe0_enabled() is updated to use the drmMode* wrapper functions instead of
direct ioctls, and the unnecessary, intel-specific pipe<->crtc mapping ioctl is
dropped.
With these updates in place, drm_read can run successfully on intel and exynos.
Tested on ivb and peach-pi, respectively.
Signed-off-by: Micah Fedke <micah.fedke@collabora.co.uk>
---
tests/drm_read.c | 87 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 50 insertions(+), 37 deletions(-)
diff --git a/tests/drm_read.c b/tests/drm_read.c
index fdaf126..38fde26 100644
--- a/tests/drm_read.c
+++ b/tests/drm_read.c
@@ -45,10 +45,15 @@
#include "drm.h"
#include "ioctl_wrappers.h"
#include "drmtest.h"
+#include "igt_core.h"
#include "igt_aux.h"
+#include "igt_kms.h"
IGT_TEST_DESCRIPTION("Call read(drm) and see if it behaves.");
+static drmModeRes *resources;
+static int crtc_idx;
+
static void sighandler(int sig)
{
}
@@ -61,16 +66,19 @@ static void assert_empty(int fd)
static void generate_event(int fd)
{
- union drm_wait_vblank vbl;
+ drmVBlank wait_vbl;
+ unsigned crtc_idx_mask;
+ memset(&wait_vbl, 0, sizeof(wait_vbl));
- /* We require that pipe 0 is running */
+ crtc_idx_mask = crtc_idx << DRM_VBLANK_HIGH_CRTC_SHIFT;
+ igt_assert(!(crtc_idx_mask & ~DRM_VBLANK_HIGH_CRTC_MASK));
- vbl.request.type =
- DRM_VBLANK_RELATIVE |
- DRM_VBLANK_EVENT;
- vbl.request.sequence = 0;
+ wait_vbl.request.type = crtc_idx_mask;
+ wait_vbl.request.type |= DRM_VBLANK_RELATIVE;
+ wait_vbl.request.type |= DRM_VBLANK_EVENT;
+ wait_vbl.request.sequence = 1;
- do_ioctl(fd, DRM_IOCTL_WAIT_VBLANK, &vbl);
+ igt_assert(!drmWaitVBlank(fd, &wait_vbl));
}
static void wait_for_event(int fd)
@@ -154,44 +162,27 @@ 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;
-
- if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res))
- return 0;
-
- if (res.count_crtcs > 32)
+ res = drmModeGetResources(fd);
+ igt_assert(res);
+ crtc = drmModeGetCrtc(fd, res->crtcs[crtc_idx]);
+ if (!crtc){
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;
+ ret = crtc->mode_valid && crtc->mode.clock;
- drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &mode);
- return mode.mode_valid && mode.mode.clock;
- }
+ drmModeFreeCrtc(crtc);
+ drmModeFreeResources(res);
- return 0;
+ return ret;
}
igt_main
@@ -202,8 +193,30 @@ igt_main
siginterrupt(SIGALRM, 1);
igt_fixture {
- fd = drm_open_driver_master(DRIVER_INTEL);
+ struct kmstest_connector_config config;
+ int i, n;
+
+ fd = drm_open_driver_master(OPEN_ANY_GPU);
+ igt_enable_connectors(fd);
+ kmstest_set_vt_graphics_mode();
+
igt_require(pipe0_enabled(fd));
+
+ resources = drmModeGetResources(fd);
+ igt_assert(resources);
+
+ for (i = 0; i < resources->count_connectors; i++) {
+ for (n = 0; n < resources->count_crtcs; n++) {
+ //use the first connector config we find
+ if(kmstest_get_connector_config(fd, resources->connectors[i],
+ 1 << n, &config)){
+ crtc_idx = config.crtc_idx;
+ break;
+ }
+ }
+ }
+ drmModeFreeCrtc(config.crtc);
+
}
igt_subtest("invalid-buffer")
--
2.5.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next reply other threads:[~2015-08-11 15:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 15:59 Micah Fedke [this message]
2015-08-11 16:15 ` [PATCH v2 5/5] tests: make drm_read platform agnostic Chris Wilson
2015-08-12 13:26 ` Daniel Vetter
2015-08-13 18:12 ` Micah Fedke
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=55CA1BD4.10808@collabora.co.uk \
--to=micah.fedke@collabora.co.uk \
--cc=chris@chris-wilson.co.uk \
--cc=daniel@ffwll.ch \
--cc=daniel@fooishbar.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox