From a53ab146feaf01a93bf5a4e38d99d84d8858591b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 1 Dec 2020 16:00:12 +0100 Subject: backend: add get_drm_fd to interface This function allows backends to return the DRM FD they are using. This will allow the allocator and the renderer to use the right device. --- backend/backend.c | 8 ++++++++ include/backend/backend.h | 8 ++++++++ include/wlr/backend/interface.h | 1 + 3 files changed, 17 insertions(+) create mode 100644 include/backend/backend.h diff --git a/backend/backend.c b/backend/backend.c index 7e299f9d..245bd429 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -16,6 +16,7 @@ #include #include #include +#include "backend/backend.h" #include "backend/multi.h" #if WLR_HAS_X11_BACKEND @@ -71,6 +72,13 @@ clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) { return CLOCK_MONOTONIC; } +int backend_get_drm_fd(struct wlr_backend *backend) { + if (!backend->impl->get_drm_fd) { + return -1; + } + return backend->impl->get_drm_fd(backend); +} + static size_t parse_outputs_env(const char *name) { const char *outputs_str = getenv(name); if (outputs_str == NULL) { diff --git a/include/backend/backend.h b/include/backend/backend.h new file mode 100644 index 00000000..f920cc9f --- /dev/null +++ b/include/backend/backend.h @@ -0,0 +1,8 @@ +#ifndef BACKEND_H +#define BACKEND_H + +#include + +int backend_get_drm_fd(struct wlr_backend *backend); + +#endif diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index 8782ae0b..3426bb45 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -19,6 +19,7 @@ struct wlr_backend_impl { struct wlr_renderer *(*get_renderer)(struct wlr_backend *backend); struct wlr_session *(*get_session)(struct wlr_backend *backend); clockid_t (*get_presentation_clock)(struct wlr_backend *backend); + int (*get_drm_fd)(struct wlr_backend *backend); }; /** -- cgit v1.2.3