summaryrefslogtreecommitdiff
path: root/hw/xwayland/xwayland-glamor-gbm.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-02-27 17:06:51 +0100
committerOlivier Fourdan <fourdan@gmail.com>2023-03-03 14:18:49 +0000
commit6f0b9deed66882aa18983eb35abca45207e37316 (patch)
tree3e2943195ec8072ba97a718c93bcf476425468dd /hw/xwayland/xwayland-glamor-gbm.c
parent5a742ab8763d7b041c427f1d725f6bbd7ae82fa1 (diff)
xwayland: use drmDevice to compare DRM devices
The linux_dmabuf_v1 protocol doesn't guarantee any DRM node type: the compositor may send a primary node or a render node. Use drmDevice so that device comparisons are node-type-insensitive. Signed-off-by: Simon Ser <contact@emersion.fr> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1447
Diffstat (limited to 'hw/xwayland/xwayland-glamor-gbm.c')
-rw-r--r--hw/xwayland/xwayland-glamor-gbm.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c
index dcad1df04..8e46f30f7 100644
--- a/hw/xwayland/xwayland-glamor-gbm.c
+++ b/hw/xwayland/xwayland-glamor-gbm.c
@@ -53,7 +53,7 @@
#include "linux-dmabuf-unstable-v1-client-protocol.h"
struct xwl_gbm_private {
- dev_t device;
+ drmDevice *device;
char *device_name;
struct gbm_device *gbm;
struct wl_drm *drm;
@@ -460,6 +460,7 @@ xwl_glamor_gbm_cleanup(struct xwl_screen *xwl_screen)
if (xwl_gbm->device_name)
free(xwl_gbm->device_name);
+ drmFreeDevice(&xwl_gbm->device);
if (xwl_gbm->drm_fd)
close(xwl_gbm->drm_fd);
if (xwl_gbm->drm)
@@ -784,7 +785,6 @@ 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);
@@ -807,12 +807,11 @@ 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));
+ if (drmGetDevice2(xwl_gbm->drm_fd, 0, &xwl_gbm->device) != 0) {
+ ErrorF("wayland-egl: Could not fetch DRM device %s\n",
+ xwl_gbm->device_name);
return;
}
- xwl_gbm->device = stat.st_rdev;
if (drmGetNodeTypeFromFd(xwl_gbm->drm_fd) == DRM_NODE_RENDER) {
xwl_gbm->fd_render_node = 1;
@@ -1111,7 +1110,7 @@ error:
return FALSE;
}
-static dev_t xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
+static drmDevice *xwl_gbm_get_main_device(struct xwl_screen *xwl_screen)
{
struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen);