aboutsummaryrefslogtreecommitdiff
path: root/backend/backend.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-21 12:49:12 +0100
committerSimon Ser <contact@emersion.fr>2023-02-21 12:51:46 +0100
commit2849712356f2183932d444edf8ff03f8efa8fc86 (patch)
tree51a3f1645e71756f764e233fabedb1702cc83393 /backend/backend.c
parent3874577d3c2a37c4291962103a18f13c8862da76 (diff)
backend: create DRM backend monitor when WLR_BACKENDS is used
Diffstat (limited to 'backend/backend.c')
-rw-r--r--backend/backend.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/backend/backend.c b/backend/backend.c
index a0ed834b..733a6ffd 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -197,18 +197,18 @@ static struct wlr_backend *attempt_headless_backend(
}
#if WLR_HAS_DRM_BACKEND
-static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
+static bool attempt_drm_backend(struct wl_display *display,
struct wlr_backend *backend, struct wlr_session *session) {
struct wlr_device *gpus[8];
ssize_t num_gpus = wlr_session_find_gpus(session, 8, gpus);
if (num_gpus < 0) {
wlr_log(WLR_ERROR, "Failed to find GPUs");
- return NULL;
+ return false;
}
if (num_gpus == 0) {
wlr_log(WLR_ERROR, "Found 0 GPUs, cannot create backend");
- return NULL;
+ return false;
} else {
wlr_log(WLR_INFO, "Found %zu GPUs", num_gpus);
}
@@ -233,7 +233,9 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
return NULL;
}
- return primary_drm;
+ drm_backend_monitor_create(backend, primary_drm, session);
+
+ return true;
}
#endif
@@ -268,8 +270,7 @@ static bool attempt_backend_by_name(struct wl_display *display,
} else {
#if WLR_HAS_DRM_BACKEND
// attempt_drm_backend adds the multi drm backends itself
- return attempt_drm_backend(display, multi,
- *session_ptr) != NULL;
+ return attempt_drm_backend(display, multi, *session_ptr);
#endif
}
} else {
@@ -379,14 +380,10 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display,
#endif
#if WLR_HAS_DRM_BACKEND
- struct wlr_backend *primary_drm =
- attempt_drm_backend(display, multi, session);
- if (!primary_drm) {
+ if (!attempt_drm_backend(display, multi, session)) {
wlr_log(WLR_ERROR, "Failed to open any DRM device");
goto error;
}
-
- drm_backend_monitor_create(multi, primary_drm, session);
#endif
success: