From fb933d32048de617fdfe5e6567e11f296e20f4fd Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 15 Jun 2021 09:54:29 +0200 Subject: backend/session: use drmIsKMS This moves the magic incantation into libdrm and is clearer. See [1] for details. While at it, fixup the doc comment and improve logging. [1]: https://gitlab.freedesktop.org/mesa/drm/-/commit/523b3658aa8efa746417e916c987de23740ce313 --- backend/session/session.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'backend/session') diff --git a/backend/session/session.c b/backend/session/session.c index 71fe5166..f87de22d 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -337,9 +337,8 @@ bool wlr_session_change_vt(struct wlr_session *session, unsigned vt) { return libseat_switch_session(session->seat_handle, vt) == 0; } -/* Tests if 'path' is KMS compatible by trying to open it. - * It leaves the open device in *fd_out it it succeeds. - */ +/* Tests if 'path' is KMS compatible by trying to open it. Returns the opened + * device on success. */ static struct wlr_device *open_if_kms(struct wlr_session *restrict session, const char *restrict path) { if (!path) { @@ -351,25 +350,13 @@ static struct wlr_device *open_if_kms(struct wlr_session *restrict session, return NULL; } - // The kernel errors out with EOPNOTSUPP if DRIVER_MODESET isn't set - drmModeRes *res = drmModeGetResources(dev->fd); - if (!res) { - if (errno != EOPNOTSUPP) { - wlr_log_errno(WLR_ERROR, "drmModeGetResources(%s) failed", path); - } - goto out_dev; - } - if (res->count_crtcs == 0) { - drmModeFreeResources(res); - goto out_dev; + if (!drmIsKMS(dev->fd)) { + wlr_log(WLR_DEBUG, "Ignoring '%s': not a KMS device", path); + wlr_session_close_file(session, dev); + return NULL; } - drmModeFreeResources(res); return dev; - -out_dev: - wlr_session_close_file(session, dev); - return NULL; } static ssize_t explicit_find_gpus(struct wlr_session *session, -- cgit v1.2.3