summaryrefslogtreecommitdiff
path: root/lib/igt_kms.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-09-14 21:00:48 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-10-01 21:06:56 +0100
commit065e7dcb05a34aa8bd4f9bf30b9061fc2d5fbac9 (patch)
treeff096c47c01c92a38fde653c3e4aa99d9fcd75b6 /lib/igt_kms.c
parentf1249a92dd5d890b9827b5b5bc9ecde8f6427d69 (diff)
lib: Report if kms is enabled on the display
Some drivers may have disabled KMS or there may simply nothing attached to the device. In either case KMS is unusable and we may prefer to skip. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'lib/igt_kms.c')
-rw-r--r--lib/igt_kms.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4563bfd9..9710bcae 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1843,8 +1843,9 @@ static void igt_fill_display_format_mod(igt_display_t *display);
* Initialize @display and allocate the various resources required. Use
* #igt_display_fini to release the resources when they are no longer required.
*
+ * Returns: true if the display has outputs and pipes available, false otherwise
*/
-void igt_display_init(igt_display_t *display, int drm_fd)
+bool igt_display_init(igt_display_t *display, int drm_fd)
{
drmModeRes *resources;
drmModePlaneRes *plane_resources;
@@ -1857,7 +1858,8 @@ void igt_display_init(igt_display_t *display, int drm_fd)
display->drm_fd = drm_fd;
resources = drmModeGetResources(display->drm_fd);
- igt_assert(resources);
+ if (!resources)
+ goto out;
/*
* We cache the number of pipes, that number is a physical limit of the
@@ -2004,7 +2006,15 @@ void igt_display_init(igt_display_t *display, int drm_fd)
/* Set reasonable default values for every object in the display. */
igt_display_reset(display);
+out:
LOG_UNINDENT(display);
+
+ return display->n_pipes && display->n_outputs;
+}
+
+void igt_display_require(igt_display_t *display, int drm_fd)
+{
+ igt_require(igt_display_init(display, drm_fd));
}
/**