mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-14 08:22:25 -04:00
drm/monitor: Remove primary_drm
This field is not used anymore. This also gives us the opportunity to clean up backend autocreation.
This commit is contained in:
parent
dc7855f674
commit
873ce330a7
3 changed files with 14 additions and 36 deletions
|
|
@ -240,23 +240,23 @@ static struct wlr_backend *attempt_headless_backend(struct wl_event_loop *loop)
|
|||
return backend;
|
||||
}
|
||||
|
||||
static struct wlr_backend *attempt_drm_backend(struct wlr_backend *backend, struct wlr_session *session) {
|
||||
static bool attempt_drm_backend(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 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);
|
||||
}
|
||||
|
||||
struct wlr_backend *primary_drm = NULL;
|
||||
bool ok = false;
|
||||
for (size_t i = 0; i < (size_t)num_gpus; ++i) {
|
||||
struct wlr_backend *drm = wlr_drm_backend_create(session, gpus[i]);
|
||||
if (!drm) {
|
||||
|
|
@ -264,22 +264,20 @@ static struct wlr_backend *attempt_drm_backend(struct wlr_backend *backend, stru
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!primary_drm) {
|
||||
primary_drm = drm;
|
||||
}
|
||||
|
||||
wlr_multi_backend_add(backend, drm);
|
||||
ok = true;
|
||||
}
|
||||
if (!primary_drm) {
|
||||
|
||||
if (!ok) {
|
||||
wlr_log(WLR_ERROR, "Could not successfully create backend on any GPU");
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getenv("WLR_DRM_DEVICES") == NULL) {
|
||||
drm_backend_monitor_create(backend, primary_drm, session);
|
||||
drm_backend_monitor_create(backend, session);
|
||||
}
|
||||
|
||||
return primary_drm;
|
||||
return true;
|
||||
#else
|
||||
wlr_log(WLR_ERROR, "Cannot create DRM backend: disabled at compile-time");
|
||||
return NULL;
|
||||
|
|
@ -319,7 +317,7 @@ static bool attempt_backend_by_name(struct wl_event_loop *loop,
|
|||
backend = attempt_libinput_backend(*session_ptr);
|
||||
} else {
|
||||
// attempt_drm_backend() adds the multi drm backends itself
|
||||
return attempt_drm_backend(multi, *session_ptr) != NULL;
|
||||
return attempt_drm_backend(multi, *session_ptr);
|
||||
}
|
||||
} else {
|
||||
wlr_log(WLR_ERROR, "unrecognized backend '%s'", name);
|
||||
|
|
@ -423,16 +421,11 @@ struct wlr_backend *wlr_backend_autocreate(struct wl_event_loop *loop,
|
|||
goto error;
|
||||
}
|
||||
|
||||
struct wlr_backend *primary_drm = attempt_drm_backend(multi, session);
|
||||
if (primary_drm == NULL) {
|
||||
if (!attempt_drm_backend(multi, session)) {
|
||||
wlr_log(WLR_ERROR, "Failed to open any DRM device");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!auto_backend_monitor_create(multi, primary_drm)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
success:
|
||||
if (session_ptr != NULL) {
|
||||
*session_ptr = session;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
static void drm_backend_monitor_destroy(struct wlr_drm_backend_monitor* monitor) {
|
||||
wl_list_remove(&monitor->session_add_drm_card.link);
|
||||
wl_list_remove(&monitor->session_destroy.link);
|
||||
wl_list_remove(&monitor->primary_drm_destroy.link);
|
||||
wl_list_remove(&monitor->multi_destroy.link);
|
||||
free(monitor);
|
||||
}
|
||||
|
|
@ -49,12 +48,6 @@ static void handle_session_destroy(struct wl_listener *listener, void *data) {
|
|||
drm_backend_monitor_destroy(backend_monitor);
|
||||
}
|
||||
|
||||
static void handle_primary_drm_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_drm_backend_monitor *backend_monitor =
|
||||
wl_container_of(listener, backend_monitor, primary_drm_destroy);
|
||||
drm_backend_monitor_destroy(backend_monitor);
|
||||
}
|
||||
|
||||
static void handle_multi_destroy(struct wl_listener *listener, void *data) {
|
||||
struct wlr_drm_backend_monitor *backend_monitor =
|
||||
wl_container_of(listener, backend_monitor, multi_destroy);
|
||||
|
|
@ -62,8 +55,7 @@ static void handle_multi_destroy(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
struct wlr_drm_backend_monitor *drm_backend_monitor_create(
|
||||
struct wlr_backend *multi, struct wlr_backend *primary_drm,
|
||||
struct wlr_session *session) {
|
||||
struct wlr_backend *multi, struct wlr_session *session) {
|
||||
struct wlr_drm_backend_monitor *monitor = calloc(1, sizeof(*monitor));
|
||||
if (!monitor) {
|
||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||
|
|
@ -71,7 +63,6 @@ struct wlr_drm_backend_monitor *drm_backend_monitor_create(
|
|||
}
|
||||
|
||||
monitor->multi = multi;
|
||||
monitor->primary_drm = primary_drm;
|
||||
monitor->session = session;
|
||||
|
||||
monitor->session_add_drm_card.notify = handle_add_drm_card;
|
||||
|
|
@ -80,9 +71,6 @@ struct wlr_drm_backend_monitor *drm_backend_monitor_create(
|
|||
monitor->session_destroy.notify = handle_session_destroy;
|
||||
wl_signal_add(&session->events.destroy, &monitor->session_destroy);
|
||||
|
||||
monitor->primary_drm_destroy.notify = handle_primary_drm_destroy;
|
||||
wl_signal_add(&primary_drm->events.destroy, &monitor->primary_drm_destroy);
|
||||
|
||||
monitor->multi_destroy.notify = handle_multi_destroy;
|
||||
wl_signal_add(&multi->events.destroy, &monitor->multi_destroy);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,17 +8,14 @@
|
|||
*/
|
||||
struct wlr_drm_backend_monitor {
|
||||
struct wlr_backend *multi;
|
||||
struct wlr_backend *primary_drm;
|
||||
struct wlr_session *session;
|
||||
|
||||
struct wl_listener multi_destroy;
|
||||
struct wl_listener primary_drm_destroy;
|
||||
struct wl_listener session_destroy;
|
||||
struct wl_listener session_add_drm_card;
|
||||
};
|
||||
|
||||
struct wlr_drm_backend_monitor *drm_backend_monitor_create(
|
||||
struct wlr_backend *multi, struct wlr_backend *primary_drm,
|
||||
struct wlr_session *session);
|
||||
struct wlr_backend *multi, struct wlr_session *session);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue