On Tue, Feb 10, 2015 at 05:17:34PM +0000, Tvrtko Ursulin wrote: > From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > > Just a few basic tests to make sure fb modifiers can be used and > behave sanely when mixed with the old set_tiling API. > > v2: > * Review feedback from Daniel Vetter: > 1. Move cap detection into the subtest so skipping works. > 2. Added some gtkdoc comments. > 3. Two more test cases. > 4. Removed unused parts for now. > > v3: > * Removed two tests which do not make sense any more after the > fb modifier rewrite. > > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> > --- > lib/ioctl_wrappers.c | 17 +++++++++++++ > lib/ioctl_wrappers.h | 37 ++++++++++++++++++++++++++++ > tests/kms_addfb.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 122 insertions(+) > > diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c > index 19a457a..0a7841a 100644 > --- a/lib/ioctl_wrappers.c > +++ b/lib/ioctl_wrappers.c > @@ -1091,3 +1091,20 @@ int gem_context_has_param(int fd, uint64_t param) > > return gem_context_get_param(fd, &p) == 0; > } > + > +void igt_require_fb_modifiers(int fd) gtkdoc is missing here. -Daniel > +{ > + static unsigned int has_modifiers, cap_modifiers_tested; > + > + if (!cap_modifiers_tested) { > + uint64_t cap_modifiers; > + int ret; > + > + ret = drmGetCap(fd, LOCAL_DRM_CAP_ADDFB2_MODIFIERS, &cap_modifiers); > + igt_assert(ret == 0 || errno == EINVAL); > + has_modifiers = ret == 0 && cap_modifiers == 1; > + cap_modifiers_tested = 1; > + } > + > + igt_require(has_modifiers); > +} > diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h > index 30ab836..9459130 100644 > --- a/lib/ioctl_wrappers.h > +++ b/lib/ioctl_wrappers.h > @@ -117,4 +117,41 @@ int gem_context_has_param(int fd, uint64_t param); > int gem_context_get_param(int fd, struct local_i915_gem_context_param *p); > int gem_context_set_param(int fd, struct local_i915_gem_context_param *p); > > +struct local_drm_mode_fb_cmd2 { > + uint32_t fb_id; > + uint32_t width, height; > + uint32_t pixel_format; > + uint32_t flags; > + uint32_t handles[4]; > + uint32_t pitches[4]; > + uint32_t offsets[4]; > + uint64_t modifier[4]; > +}; > + > +#define LOCAL_DRM_MODE_FB_MODIFIERS (1<<1) > + > +#define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL 0x01 > + > +#define local_fourcc_mod_code(vendor, val) \ > + ((((uint64_t)LOCAL_DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | \ > + (val & 0x00ffffffffffffffL)) > + > +#define LOCAL_I915_FORMAT_MOD_NONE local_fourcc_mod_code(INTEL, \ > + 0x00000000000000L) > +#define LOCAL_I915_FORMAT_MOD_X_TILED local_fourcc_mod_code(INTEL, \ > + 0x00000000000001L) > + > +#define LOCAL_DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, \ > + struct local_drm_mode_fb_cmd2) > + > +#define LOCAL_DRM_CAP_ADDFB2_MODIFIERS 0x10 > + > +/** > + * igt_require_fb_modifiers: > + * @fd: Open DRM file descriptor. > + * > + * Requires presence of DRM_CAP_ADDFB2_MODIFIERS. > + */ > +void igt_require_fb_modifiers(int fd); > + > #endif /* IOCTL_WRAPPERS_H */ > diff --git a/tests/kms_addfb.c b/tests/kms_addfb.c > index 756589e..625aa27 100644 > --- a/tests/kms_addfb.c > +++ b/tests/kms_addfb.c > @@ -213,6 +213,72 @@ static void size_tests(int fd) > } > } > > +static void addfb25_tests(int fd) > +{ > + struct local_drm_mode_fb_cmd2 f = {}; > + > + > + memset(&f, 0, sizeof(f)); > + > + f.width = 1024; > + f.height = 1024; > + f.pixel_format = DRM_FORMAT_XRGB8888; > + f.pitches[0] = 1024*4; > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_NONE; > + > + igt_fixture { > + gem_bo = gem_create(fd, 1024*1024*4); > + igt_assert(gem_bo); > + } > + > + f.handles[0] = gem_bo; > + > + igt_subtest("addfb25-modifier-no-flag") { > + igt_require_fb_modifiers(fd); > + > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_X_TILED; > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) < 0 && errno == EINVAL); > + f.fb_id = 0; > + } > + > + f.flags = LOCAL_DRM_MODE_FB_MODIFIERS; > + > + igt_fixture > + gem_set_tiling(fd, gem_bo, I915_TILING_X, 1024*4); > + f.pitches[0] = 1024*4; > + > + igt_subtest("addfb25-X-tiled-mismatch") { > + igt_require_fb_modifiers(fd); > + > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_NONE; > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) < 0 && errno == EINVAL); > + f.fb_id = 0; > + } > + > + igt_subtest("addfb25-X-tiled") { > + igt_require_fb_modifiers(fd); > + > + f.modifier[0] = LOCAL_I915_FORMAT_MOD_X_TILED; > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) == 0); > + igt_assert(drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &f.fb_id) == 0); > + f.fb_id = 0; > + } > + > + igt_subtest("addfb25-framebuffer-vs-set-tiling") { > + igt_require_fb_modifiers(fd); > + > + igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) == 0); > + igt_assert(__gem_set_tiling(fd, gem_bo, I915_TILING_X, 512*4) == -EBUSY); > + igt_assert(__gem_set_tiling(fd, gem_bo, I915_TILING_X, 1024*4) == -EBUSY); > + igt_assert(drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &f.fb_id) == 0); > + f.fb_id = 0; > + } > + > + igt_fixture { > + gem_close(fd, gem_bo); > + } > +} > + > int fd; > > igt_main > @@ -224,6 +290,8 @@ igt_main > > size_tests(fd); > > + addfb25_tests(fd); > + > igt_fixture > close(fd); > } > -- > 2.2.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx