All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH v5 01/13] tests/kms_addfb: Add support for fb modifiers
Date: Wed, 25 Feb 2015 17:08:37 +0000	[thread overview]
Message-ID: <1424884117-19657-1-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1424707075-27605-1-git-send-email-tvrtko.ursulin@linux.intel.com>

From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

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.

v4:
   * Moved gtkdoc comments into .c file.
   * Moved all initialization into fixtures.
   * Rebased for fb modifier changes.

v5:
   * Added bad modifier subtest.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/ioctl_wrappers.c | 23 ++++++++++++++++
 lib/ioctl_wrappers.h | 30 +++++++++++++++++++++
 tests/kms_addfb.c    | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index cd6884a..0ab25c4 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1142,3 +1142,26 @@ off_t prime_get_size(int dma_buf_fd)
 
 	return ret;
 }
+
+/**
+ * igt_require_fb_modifiers:
+ * @fd: Open DRM file descriptor.
+ *
+ * Requires presence of DRM_CAP_ADDFB2_MODIFIERS.
+ */
+void igt_require_fb_modifiers(int fd)
+{
+	static bool 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 = true;
+	}
+
+	igt_require(has_modifiers);
+}
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 7c0c87e..3c85e8b 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -135,4 +135,34 @@ int prime_handle_to_fd(int fd, uint32_t handle);
 uint32_t prime_fd_to_handle(int fd, int dma_buf_fd);
 off_t prime_get_size(int dma_buf_fd);
 
+/* addfb2 fb modifiers */
+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_DRM_FORMAT_MOD_NONE	(0)
+#define LOCAL_I915_FORMAT_MOD_X_TILED	local_fourcc_mod_code(INTEL, 1)
+
+#define LOCAL_DRM_IOCTL_MODE_ADDFB2	DRM_IOWR(0xB8, \
+						 struct local_drm_mode_fb_cmd2)
+
+#define LOCAL_DRM_CAP_ADDFB2_MODIFIERS	0x10
+
+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..58a23ea 100644
--- a/tests/kms_addfb.c
+++ b/tests/kms_addfb.c
@@ -213,6 +213,79 @@ static void size_tests(int fd)
 	}
 }
 
+static void addfb25_tests(int fd)
+{
+	struct local_drm_mode_fb_cmd2 f = {};
+
+	igt_fixture {
+		gem_bo = gem_create(fd, 1024*1024*4);
+		igt_assert(gem_bo);
+
+		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_DRM_FORMAT_MOD_NONE;
+
+		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);
+	}
+
+	igt_fixture {
+		f.flags = LOCAL_DRM_MODE_FB_MODIFIERS;
+	}
+
+	igt_subtest("addfb25-bad-modifier") {
+		igt_require_fb_modifiers(fd);
+
+		f.modifier[0] = ~0;
+		igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) < 0 && errno == EINVAL);
+	}
+
+	igt_fixture {
+		gem_set_tiling(fd, gem_bo, I915_TILING_X, 1024*4);
+	}
+
+	igt_subtest("addfb25-X-tiled-mismatch") {
+		igt_require_fb_modifiers(fd);
+
+		f.modifier[0] = LOCAL_DRM_FORMAT_MOD_NONE;
+		igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) < 0 && errno == EINVAL);
+	}
+
+	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);
+
+		f.modifier[0] = LOCAL_I915_FORMAT_MOD_X_TILED;
+		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 +297,8 @@ igt_main
 
 	size_tests(fd);
 
+	addfb25_tests(fd);
+
 	igt_fixture
 		close(fd);
 }
-- 
2.3.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-02-25 17:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-23 15:57 [PATCH i-g-t 00/12] Testing the Y tiled display Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 01/12] tests/kms_addfb: Add support for fb modifiers Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 02/12] lib: Extract igt_buf_write_to_png() from gem_render_copy Tvrtko Ursulin
2015-02-24 21:49   ` Daniel Vetter
2015-02-23 15:57 ` [PATCH i-g-t 03/12] tests/kms_addfb: Y tiled testcases Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 04/12] lib/skl: Add gen9 specific igt_blitter_fast_copy() Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 05/12] lib: Don't give a struct igt_buf * to fast_copy_pitch() Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 06/12] lib: Split two helpers to build fast copy's dword0 and dword1 Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 07/12] lib: Provide a raw version of the gen9 fast copy blits Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 08/12] tiling: Convert framebuffer helpers to use fb modifiers Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 09/12] lib: Add support for new extension to the ADDFB2 ioctl Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 10/12] lib/igt_fb: Use new ADDFB2 extension for new tiling modes Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 11/12] lib: Allow the creation of Ys/Yf tiled FBs Tvrtko Ursulin
2015-02-23 15:57 ` [PATCH i-g-t 12/12] testdisplay/skl: Add command line options for Yb/Yf tiled fbs Tvrtko Ursulin
2015-02-24 21:51   ` Daniel Vetter
2015-02-25 10:55     ` Tvrtko Ursulin
2015-02-25 15:05       ` Daniel Vetter
2015-02-24 21:53 ` [PATCH i-g-t 00/12] Testing the Y tiled display Daniel Vetter
2015-02-25 10:58   ` Tvrtko Ursulin
2015-02-25 17:08 ` Tvrtko Ursulin [this message]
2015-02-25 21:17   ` [PATCH v5 01/13] tests/kms_addfb: Add support for fb modifiers Daniel Vetter
2015-02-25 17:27 ` [PATCH v2 02/12] lib: Extract igt_buf_write_to_png() from gem_render_copy Tvrtko Ursulin

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=1424884117-19657-1-git-send-email-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.