aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-12-11 17:47:19 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2023-12-12 14:42:52 +0000
commitfc7a0b93dd49cb8e585ea23b8eb3eda892536abb (patch)
tree8aac5825cb5656b3504fd3cac1db277b529022cc
parent3531007b75a173ab0bd8152efb0a982f72140acb (diff)
backend/drm: add wlr_drm_backend_get_parent()
Allows compositors to figure out whether a DRM backend is secondary on a multi-GPU setup.
-rw-r--r--backend/drm/backend.c5
-rw-r--r--include/wlr/backend/drm.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 4697234d..c50e278b 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -96,6 +96,11 @@ bool wlr_backend_is_drm(struct wlr_backend *b) {
return b->impl == &backend_impl;
}
+struct wlr_backend *wlr_drm_backend_get_parent(struct wlr_backend *backend) {
+ struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
+ return drm->parent ? &drm->parent->backend : NULL;
+}
+
static void handle_session_active(struct wl_listener *listener, void *data) {
struct wlr_drm_backend *drm =
wl_container_of(listener, drm, session_active);
diff --git a/include/wlr/backend/drm.h b/include/wlr/backend/drm.h
index e4fdf65d..e8f9f6a3 100644
--- a/include/wlr/backend/drm.h
+++ b/include/wlr/backend/drm.h
@@ -44,6 +44,11 @@ bool wlr_backend_is_drm(struct wlr_backend *backend);
bool wlr_output_is_drm(struct wlr_output *output);
/**
+ * Get the parent DRM backend, if any.
+ */
+struct wlr_backend *wlr_drm_backend_get_parent(struct wlr_backend *backend);
+
+/**
* Get the KMS connector object ID.
*/
uint32_t wlr_drm_connector_get_id(struct wlr_output *output);