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]: 523b3658aa
This commit is contained in:
Simon Ser 2021-06-15 09:54:29 +02:00 committed by Kenny Levinsen
parent 6c3d080e25
commit fb933d3204
2 changed files with 7 additions and 20 deletions

View file

@ -337,9 +337,8 @@ bool wlr_session_change_vt(struct wlr_session *session, unsigned vt) {
return libseat_switch_session(session->seat_handle, vt) == 0; return libseat_switch_session(session->seat_handle, vt) == 0;
} }
/* Tests if 'path' is KMS compatible by trying to open it. /* Tests if 'path' is KMS compatible by trying to open it. Returns the opened
* It leaves the open device in *fd_out it it succeeds. * device on success. */
*/
static struct wlr_device *open_if_kms(struct wlr_session *restrict session, static struct wlr_device *open_if_kms(struct wlr_session *restrict session,
const char *restrict path) { const char *restrict path) {
if (!path) { if (!path) {
@ -351,27 +350,15 @@ static struct wlr_device *open_if_kms(struct wlr_session *restrict session,
return NULL; return NULL;
} }
// The kernel errors out with EOPNOTSUPP if DRIVER_MODESET isn't set if (!drmIsKMS(dev->fd)) {
drmModeRes *res = drmModeGetResources(dev->fd); wlr_log(WLR_DEBUG, "Ignoring '%s': not a KMS device", path);
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;
}
drmModeFreeResources(res);
return dev;
out_dev:
wlr_session_close_file(session, dev); wlr_session_close_file(session, dev);
return NULL; return NULL;
} }
return dev;
}
static ssize_t explicit_find_gpus(struct wlr_session *session, static ssize_t explicit_find_gpus(struct wlr_session *session,
size_t ret_len, struct wlr_device *ret[static ret_len], const char *str) { size_t ret_len, struct wlr_device *ret[static ret_len], const char *str) {
char *gpus = strdup(str); char *gpus = strdup(str);

View file

@ -96,7 +96,7 @@ internal_features = {
wayland_server = dependency('wayland-server', version: '>=1.19') wayland_server = dependency('wayland-server', version: '>=1.19')
wayland_client = dependency('wayland-client') wayland_client = dependency('wayland-client')
drm = dependency('libdrm', version: '>=2.4.95') drm = dependency('libdrm', version: '>=2.4.105')
gbm = dependency('gbm', version: '>=17.1.0') gbm = dependency('gbm', version: '>=17.1.0')
libinput = dependency('libinput', version: '>=1.14.0') libinput = dependency('libinput', version: '>=1.14.0')
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')