summaryrefslogtreecommitdiff
path: root/tests/kms_getfb.c
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2018-03-23 11:55:00 +0000
committerDaniel Stone <daniels@collabora.com>2018-03-30 16:46:33 +0100
commit8d61c95ad017322e4d0744e63f2a5db3c510ab19 (patch)
tree45092b7852c3111acbb406642ddac093410593c7 /tests/kms_getfb.c
parentbd0756d8ab59427a264c9253f27ef323aeef9c38 (diff)
tests/kms_getfb: Split property-ID get into helper
We'll want to reuse this, so split it out into a (smaller!) helper. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tests/kms_getfb.c')
-rw-r--r--tests/kms_getfb.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index 14c118b7..5f0bd2a9 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -74,6 +74,23 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
gem_close(fd, add.handles[0]);
}
+/**
+ * Find and return an arbitrary valid property ID.
+ */
+static uint32_t get_any_prop_id(int fd)
+{
+ igt_display_t display;
+
+ igt_display_init(&display, fd);
+ for (int i = 0; i < display.n_outputs; i++) {
+ igt_output_t *output = &display.outputs[i];
+ if (output->props[IGT_CONNECTOR_DPMS] != 0)
+ return output->props[IGT_CONNECTOR_DPMS];
+ }
+
+ return 0;
+}
+
static void test_handle_input(int fd)
{
struct drm_mode_fb_cmd2 add = {};
@@ -113,23 +130,8 @@ static void test_handle_input(int fd)
}
igt_subtest("getfb-handle-not-fb") {
- struct drm_mode_fb_cmd get = { };
- uint32_t prop_id = 0;
- igt_display_t display;
-
- /* Find a valid property ID to use. */
- igt_display_init(&display, fd);
- for (int i = 0; i < display.n_outputs; i++) {
- igt_output_t *output = &display.outputs[i];
-
- if (output->props[IGT_CONNECTOR_DPMS] != 0) {
- prop_id = output->props[IGT_CONNECTOR_DPMS];
- break;
- }
- }
- igt_require(prop_id > 0);
-
- get.fb_id = prop_id;
+ struct drm_mode_fb_cmd get = { .fb_id = get_any_prop_id(fd) };
+ igt_require(get.fb_id > 0);
do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, ENOENT);
}
}