On Fri, Jul 31, 2015 at 04:11:11PM -0400, Micah Fedke wrote: Same comment about lack of commit message and coding style mangling. Also seems to contain some unrelated changes ... -Daniel > --- > tests/drm_read.c | 101 ++++++++++++++++++++++++++++++------------------------- > 1 file changed, 55 insertions(+), 46 deletions(-) > > diff --git a/tests/drm_read.c b/tests/drm_read.c > index fdaf126..f60e21c 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,23 @@ 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; > - > - /* 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; > + drmModeRes *res; > + drmModeCrtc *crtc; > + > + /* We assume we can generate events on pipe 0. So we have better > + * make sure that is running! > + */ > + > + res = drmModeGetResources(fd); > + igt_assert(res); > + crtc = drmModeGetCrtc(fd, res->crtcs[crtc_idx]); > + if (!crtc){ > + return 0; > + } > + drmModeFreeCrtc(crtc); > + drmModeFreeResources(res); > + > + return crtc->mode_valid && crtc->mode.clock; > } > > igt_main > @@ -202,8 +189,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.1.4 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx