1
0
Fork 0

tests/wayland-test-clients: Add gbm_device to WaylandDisplay

We'll use this later to allocate dma-bufs from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3350>
This commit is contained in:
Sebastian Wick 2023-12-12 16:38:15 +01:00 committed by Marge Bot
parent 8e7600322b
commit 24ef34f680
3 changed files with 28 additions and 4 deletions

View file

@ -20,10 +20,6 @@ wayland_test_clients = [
},
{
'name': 'dma-buf-scanout',
'extra_deps': [
libdrm_dep,
libgbm_dep,
],
},
{
'name': 'fractional-scale',
@ -92,6 +88,8 @@ foreach test : wayland_test_clients
glib_dep,
gobject_dep,
wayland_client_dep,
libdrm_dep,
libgbm_dep,
m_dep,
]
if test.has_key('extra_deps')

View file

@ -107,6 +107,26 @@ create_anonymous_file (off_t size)
return fd;
}
static struct gbm_device *
create_gbm_device (WaylandDisplay *display)
{
const char *gpu_path;
int fd;
gpu_path = lookup_property_value (display, "gpu-path");
if (!gpu_path)
return NULL;
fd = open (gpu_path, O_RDWR);
if (fd < 0)
{
g_error ("Failed to open drm render node %s: %s",
gpu_path, g_strerror (errno));
}
return gbm_create_device (fd);
}
static void
handle_xdg_wm_base_ping (void *user_data,
struct xdg_wm_base *xdg_wm_base,
@ -261,6 +281,8 @@ wayland_display_new_full (WaylandDisplayCapabilities capabilities,
wl_display_roundtrip (display->display);
display->gbm_device = create_gbm_device (display);
return display;
}

View file

@ -1,5 +1,7 @@
#pragma once
#include <drm_fourcc.h>
#include <gbm.h>
#include <glib-object.h>
#include <stdio.h>
#include <wayland-client.h>
@ -37,6 +39,8 @@ typedef struct _WaylandDisplay
uint32_t sync_event_serial_next;
GHashTable *properties;
struct gbm_device *gbm_device;
} WaylandDisplay;
#define WAYLAND_TYPE_DISPLAY (wayland_display_get_type ())