[PATCH weston] compositor-drm: Ignore non-KMS devices

Daniel Stone daniels at collabora.com
Mon Dec 19 16:53:47 UTC 2016


Given that we can have render-only devices, or vgem in a class of its
own, ignore any non-KMS devices in compositor-drm's device selection.
For x86 platforms, this is mostly a non-issue since we look at the udev
boot_vga issue, but other architectures which lack this, and have
multiple KMS devices present, will hit this.

Signed-off-by: Daniel Stone <daniels at collabora.com>
Reported-by: Thierry Reding <treding at nvidia.com>
Reported-by: Daniel Vetter <daniel.vetter at intel.com>
---
 libweston/compositor-drm.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 70514ea..ffb8d23 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2864,6 +2864,40 @@ session_notify(struct wl_listener *listener, void *data)
 	};
 }
 
+static bool
+drm_device_is_kms(struct drm_backend *b, struct udev_device *device)
+{
+	const char *filename = udev_device_get_devnode(device);
+	drmModeRes *res;
+	int fd;
+	bool ret = false;
+
+	if (!filename)
+		goto out;
+
+	fd = weston_launcher_open(b->compositor->launcher, filename, O_RDWR);
+	if (fd < 0)
+		goto out;
+
+	res = drmModeGetResources(fd);
+	if (!res)
+		goto out_fd;
+
+	if (res->count_crtcs <= 0 || res->count_connectors <= 0 ||
+	    res->count_encoders <= 0)
+		goto out_res;
+
+	ret = true;
+	/* fallthrough */
+
+out_res:
+	drmModeFreeResources(res);
+out_fd:
+	weston_launcher_close(b->compositor->launcher, fd);
+out:
+	return ret;
+}
+
 /*
  * Find primary GPU
  * Some systems may have multiple DRM devices attached to a single seat. This
@@ -2898,6 +2932,10 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
 			continue;
 		}
 
+		/* Make sure this device is actually capable of modesetting. */
+		if (!drm_device_is_kms(b, device))
+			continue;
+
 		pci = udev_device_get_parent_with_subsystem_devtype(device,
 								"pci", NULL);
 		if (pci) {
-- 
2.9.3



More information about the wayland-devel mailing list