diff options
author | Simon Ser <contact@emersion.fr> | 2023-11-23 14:52:37 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-01-25 12:12:13 +0100 |
commit | be0b7845f74fd2f68e2b20802e39b81aa64cbd3e (patch) | |
tree | cab98ac9f7e38b46187e8cda3d2cd2a4b2391f92 /backend | |
parent | a82fc4cb8fed4fd6f02684320dfed68760c6b15d (diff) |
backend: make attempt_drm_backend() return the primary backend
We'll need this in the next commit.
Diffstat (limited to 'backend')
-rw-r--r-- | backend/backend.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/backend/backend.c b/backend/backend.c index 1e57e832..dcc68b3f 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -195,19 +195,19 @@ static struct wlr_backend *attempt_headless_backend( return backend; } -static bool attempt_drm_backend(struct wl_display *display, +static struct wlr_backend *attempt_drm_backend(struct wl_display *display, struct wlr_backend *backend, struct wlr_session *session) { #if WLR_HAS_DRM_BACKEND 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 false; + return NULL; } if (num_gpus == 0) { wlr_log(WLR_ERROR, "Found 0 GPUs, cannot create backend"); - return false; + return NULL; } else { wlr_log(WLR_INFO, "Found %zu GPUs", num_gpus); } @@ -236,10 +236,10 @@ static bool attempt_drm_backend(struct wl_display *display, drm_backend_monitor_create(backend, primary_drm, session, display); } - return true; + return primary_drm; #else wlr_log(WLR_ERROR, "Cannot create DRM backend: disabled at compile-time"); - return false; + return NULL; #endif } @@ -277,7 +277,7 @@ static bool attempt_backend_by_name(struct wl_display *display, backend = attempt_libinput_backend(display, *session_ptr); } else { // attempt_drm_backend() adds the multi drm backends itself - return attempt_drm_backend(display, multi, *session_ptr); + return attempt_drm_backend(display, multi, *session_ptr) != NULL; } } else { wlr_log(WLR_ERROR, "unrecognized backend '%s'", name); @@ -371,7 +371,8 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_display *display, goto error; } - if (!attempt_drm_backend(display, multi, session)) { + struct wlr_backend *primary_drm = attempt_drm_backend(display, multi, session); + if (primary_drm == NULL) { wlr_log(WLR_ERROR, "Failed to open any DRM device"); goto error; } |