diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c index 9f95e6c14..04541bfc9 100644 --- a/hw/xwayland/xwayland-glamor-eglstream.c +++ b/hw/xwayland/xwayland-glamor-eglstream.c @@ -1118,6 +1118,7 @@ xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen) xwl_screen->eglstream_backend.post_damage = xwl_glamor_eglstream_post_damage; xwl_screen->eglstream_backend.allow_commits = xwl_glamor_eglstream_allow_commits; xwl_screen->eglstream_backend.check_flip = xwl_glamor_eglstream_check_flip; + xwl_screen->eglstream_backend.get_main_device = NULL; xwl_screen->eglstream_backend.is_available = TRUE; xwl_screen->eglstream_backend.backend_flags = XWL_EGL_BACKEND_NO_FLAG; } diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 93c15cac9..a29105f4d 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -53,6 +53,7 @@ #include "linux-dmabuf-unstable-v1-client-protocol.h" struct xwl_gbm_private { + dev_t device; char *device_name; struct gbm_device *gbm; struct wl_drm *drm; @@ -783,6 +784,7 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device) struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); drm_magic_t magic; char *render_node_path = NULL; + struct stat stat; if (!is_device_path_render_node(device)) render_node_path = get_render_node_path(device); @@ -805,6 +807,13 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device) return; } + if (fstat(xwl_gbm->drm_fd, &stat)) { + ErrorF("wayland-egl: Could not stat file %s (%s)\n", + xwl_gbm->device_name, strerror(errno)); + return; + } + xwl_gbm->device = stat.st_rdev; + if (drmGetNodeTypeFromFd(xwl_gbm->drm_fd) == DRM_NODE_RENDER) { xwl_gbm->fd_render_node = 1; xwl_screen->expecting_event--; @@ -1102,6 +1111,13 @@ error: return FALSE; } +static dev_t xwl_gbm_get_main_device(struct xwl_screen *xwl_screen) +{ + struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); + + return xwl_gbm->device; +} + void xwl_glamor_init_gbm(struct xwl_screen *xwl_screen) { @@ -1130,6 +1146,7 @@ xwl_glamor_init_gbm(struct xwl_screen *xwl_screen) xwl_screen->gbm_backend.init_screen = xwl_glamor_gbm_init_screen; xwl_screen->gbm_backend.get_wl_buffer_for_pixmap = xwl_glamor_gbm_get_wl_buffer_for_pixmap; xwl_screen->gbm_backend.check_flip = NULL; + xwl_screen->gbm_backend.get_main_device = xwl_gbm_get_main_device; xwl_screen->gbm_backend.is_available = TRUE; xwl_screen->gbm_backend.backend_flags = XWL_EGL_BACKEND_NEEDS_BUFFER_FLUSH | XWL_EGL_BACKEND_NEEDS_N_BUFFERING; diff --git a/hw/xwayland/xwayland-glamor.h b/hw/xwayland/xwayland-glamor.h index 5c3661de3..216b4bf17 100644 --- a/hw/xwayland/xwayland-glamor.h +++ b/hw/xwayland/xwayland-glamor.h @@ -96,6 +96,11 @@ struct xwl_egl_backend { * presented by xwl_present_flip. If not implemented, assumed TRUE. */ Bool (*check_flip)(PixmapPtr pixmap); + + /* Called to get the dev_t of the primary GPU that this backend + * is set up on. + */ + dev_t (*get_main_device)(struct xwl_screen *xwl_screen); }; #ifdef XWL_HAS_GLAMOR