summaryrefslogtreecommitdiff
path: root/tests/kms_addfb_basic.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu.vizoso@collabora.com>2016-02-24 10:49:14 +0100
committerDaniel Stone <daniels@collabora.com>2016-04-14 13:54:24 +0100
commit17a5d7168d4a4e5cdce6afa7ca125c4e60ebfb3f (patch)
treecd023ed2bd3c08a6c219552221485f17ba0a0f97 /tests/kms_addfb_basic.c
parent6694b6a6699ae3414ad27c7a5271fffdc9d33710 (diff)
kms_addfb_basic: Get intel gen from within subtest
Because determining the Intel GFX generation requires a call to DRM_IOCTL_I915_GETPARAM, move the code that requires it to a subtest that can be skipped on drivers other than i915. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/kms_addfb_basic.c')
-rw-r--r--tests/kms_addfb_basic.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/tests/kms_addfb_basic.c b/tests/kms_addfb_basic.c
index 4d9b1417..7ea8c2e1 100644
--- a/tests/kms_addfb_basic.c
+++ b/tests/kms_addfb_basic.c
@@ -399,10 +399,21 @@ static void addfb25_tests(int fd)
gem_close(fd, gem_bo);
}
-static void addfb25_ytile(int fd, int gen)
+static int addfb_expected_ret(int fd)
+{
+ int gen;
+
+ if (!is_i915_device(fd))
+ return 0;
+
+ gen = intel_gen(intel_get_drm_devid(fd));
+ return gen >= 9 ? 0 : -1;
+}
+
+static void addfb25_ytile(int fd)
{
struct local_drm_mode_fb_cmd2 f = {};
- int shouldret;
+ int gen;
igt_fixture {
gem_bo = igt_create_bo_with_dimensions(fd, 1024, 1024,
@@ -412,8 +423,6 @@ static void addfb25_ytile(int fd, int gen)
DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
igt_assert(gem_bo_small);
- shouldret = gen >= 9 ? 0 : -1;
-
memset(&f, 0, sizeof(f));
f.width = 1024;
@@ -430,8 +439,9 @@ static void addfb25_ytile(int fd, int gen)
igt_require_fb_modifiers(fd);
f.modifier[0] = LOCAL_I915_FORMAT_MOD_Y_TILED;
- igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) == shouldret);
- if (!shouldret)
+ igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) ==
+ addfb_expected_ret(fd));
+ if (!addfb_expected_ret(fd))
igt_assert(drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &f.fb_id) == 0);
f.fb_id = 0;
}
@@ -440,14 +450,17 @@ static void addfb25_ytile(int fd, int gen)
igt_require_fb_modifiers(fd);
f.modifier[0] = LOCAL_I915_FORMAT_MOD_Yf_TILED;
- igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) == shouldret);
- if (!shouldret)
+ igt_assert(drmIoctl(fd, LOCAL_DRM_IOCTL_MODE_ADDFB2, &f) ==
+ addfb_expected_ret(fd));
+ if (!addfb_expected_ret(fd))
igt_assert(drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &f.fb_id) == 0);
f.fb_id = 0;
}
igt_subtest("addfb25-Y-tiled-small") {
igt_require_fb_modifiers(fd);
+
+ gen = intel_gen(intel_get_drm_devid(fd));
igt_require(gen >= 9);
f.modifier[0] = LOCAL_I915_FORMAT_MOD_Y_TILED;
@@ -464,14 +477,11 @@ static void addfb25_ytile(int fd, int gen)
}
int fd;
-int gen;
igt_main
{
- igt_fixture {
+ igt_fixture
fd = drm_open_driver_master(DRIVER_INTEL);
- gen = intel_gen(intel_get_drm_devid(fd));
- }
invalid_tests(fd);
@@ -481,7 +491,7 @@ igt_main
addfb25_tests(fd);
- addfb25_ytile(fd, gen);
+ addfb25_ytile(fd);
tiling_tests(fd);