summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-03-28 18:04:27 +0300
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-12-18 13:50:41 +0200
commitb45ed8baf0312915f30aa55b7d380379593edfd5 (patch)
treeae7f031ce8ee3744421d99c6abd726a6950c5ceb
parentb0341ae972531a6c3bcf43a7f8b66c44f8bc8e49 (diff)
compositor-drm: add specific_device configuration option
Developers with testing rigs having multiple graphics cards plugged in often want to test things on a specific card. We have ways to choose a card through seat assignments, but configuring that run by run is awkward. Add a new DRM backend option to try to open a specific device, and quit if it fails. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r--libweston/compositor-drm.c29
-rw-r--r--libweston/compositor-drm.h7
2 files changed, 35 insertions, 1 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index b77209c4..3eda70f3 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -3813,6 +3813,30 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
return drm_device;
}
+static struct udev_device *
+open_specific_drm_device(struct drm_backend *b, const char *name)
+{
+ struct udev_device *device;
+
+ device = udev_device_new_from_subsystem_sysname(b->udev, "drm", name);
+ if (!device) {
+ weston_log("ERROR: could not open DRM device '%s'\n", name);
+ return NULL;
+ }
+
+ if (!drm_device_is_kms(b, device)) {
+ udev_device_unref(device);
+ weston_log("ERROR: DRM device '%s' is not a KMS device.\n", name);
+ return NULL;
+ }
+
+ /* If we're returning a device to use, we must have an open FD for
+ * it. */
+ assert(b->drm.fd >= 0);
+
+ return device;
+}
+
static void
planes_binding(struct weston_keyboard *keyboard, const struct timespec *time,
uint32_t key, void *data)
@@ -4064,7 +4088,10 @@ drm_backend_create(struct weston_compositor *compositor,
b->session_listener.notify = session_notify;
wl_signal_add(&compositor->session_signal, &b->session_listener);
- drm_device = find_primary_gpu(b, seat_id);
+ if (config->specific_device)
+ drm_device = open_specific_drm_device(b, config->specific_device);
+ else
+ drm_device = find_primary_gpu(b, seat_id);
if (drm_device == NULL) {
weston_log("no drm device found\n");
goto err_udev;
diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
index 8181492f..68f93eab 100644
--- a/libweston/compositor-drm.h
+++ b/libweston/compositor-drm.h
@@ -139,6 +139,13 @@ struct weston_drm_backend_config {
*
* It is exprimed in milliseconds, 0 means disabled. */
uint32_t pageflip_timeout;
+
+ /** Specific DRM device to open
+ *
+ * A DRM device name, like "card0", to open. If NULL, use heuristics
+ * based on seat names and boot_vga to find the right device.
+ */
+ char *specific_device;
};
#ifdef __cplusplus