Skip to content

Commit 922ce7d

Browse files
committed
wayland: add support for linux-dmabuf
wl_drm is a legacy protocol, and wlroots is getting rid of it [1]. Use the newer and standard linux-dmabuf protocol if available to get the DRM device. [1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4397 Signed-off-by: Simon Ser <contact@emersion.fr>
1 parent 3457aa8 commit 922ce7d

7 files changed

+417
-15
lines changed

configure.ac

+12-1
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,16 @@ m4_define([libva_lt_age],
7575
[m4_eval(libva_binary_age - libva_interface_age)])
7676

7777
# libdrm minimun version requirement
78-
m4_define([libdrm_version], [2.4.60])
78+
m4_define([libdrm_version], [2.4.109])
7979

8080
# Wayland minimum version number
8181
# 1.11.0 for wl_proxy_create_wrapper
8282
m4_define([wayland_api_version], [1.11.0])
8383

84+
# wayland-protocols minimum version number
85+
# 1.24 for linux-dmabuf v4
86+
m4_define([wayland_protocols_version], [1.24])
87+
8488
AC_PREREQ(2.57)
8589
AC_INIT([libva],
8690
[libva_version],
@@ -304,10 +308,15 @@ USE_WAYLAND="no"
304308
if test "x$enable_wayland" != "xno"; then
305309
PKG_CHECK_MODULES([WAYLAND], [wayland-client >= wayland_api_version],
306310
[USE_WAYLAND="yes"], [:])
311+
PKG_CHECK_MODULES([WAYLAND_PROTOCOLS], [wayland-protocols >= wayland_protocols_version],
312+
[USE_WAYLAND="yes"], [:])
307313

308314
if test "x$USE_WAYLAND" = "xno" -a "x$enable_wayland" = "xyes"; then
309315
AC_MSG_ERROR([wayland explicitly enabled, however $WAYLAND_PKG_ERRORS])
310316
fi
317+
if test "x$USE_WAYLAND_PROTOCOLS" = "xno" -a "x$enable_wayland" = "xyes"; then
318+
AC_MSG_ERROR([wayland explicitly enabled, however $WAYLAND_PROTOCOLS_PKG_ERRORS])
319+
fi
311320

312321
if test "$USE_WAYLAND" = "yes"; then
313322

@@ -322,6 +331,8 @@ if test "x$enable_wayland" != "xno"; then
322331
AC_SUBST(WAYLAND_SCANNER, `$PKG_CONFIG --variable=wayland_scanner wayland-scanner`)
323332
fi
324333

334+
AC_SUBST(WAYLAND_PROTOCOLS_DIR, `$PKG_CONFIG --variable=pkgdatadir wayland-protocols`)
335+
325336
AC_DEFINE([HAVE_VA_WAYLAND], [1],
326337
[Defined to 1 if VA/Wayland API is built])
327338
fi

meson.build

+5-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ cc = meson.get_compiler('c')
8585
dl_dep = cc.find_library('dl', required : false)
8686

8787
WITH_DRM = not get_option('disable_drm') and (host_machine.system() != 'windows')
88-
libdrm_dep = dependency('libdrm', version : '>= 2.4.60', required : (host_machine.system() != 'windows'))
88+
libdrm_dep = dependency('libdrm', version : '>= 2.4.109', required : (host_machine.system() != 'windows'))
8989

9090
WITH_X11 = false
9191
if get_option('with_x11') != 'no'
@@ -121,7 +121,10 @@ if get_option('with_wayland') != 'no'
121121
if wayland_scanner_dep.found()
122122
wl_scanner = find_program(wayland_scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))
123123
endif
124-
WITH_WAYLAND = wayland_dep.found() and wayland_scanner_dep.found()
124+
wayland_protocols_dep = dependency('wayland-protocols', version : '>= 1.24',
125+
required : get_option('with_wayland') == 'yes')
126+
WITH_WAYLAND = wayland_dep.found() and wayland_scanner_dep.found() and \
127+
wayland_protocols_dep.found()
125128
endif
126129

127130
WITH_WIN32 = false

va/meson.build

+21-12
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ endif
227227
if WITH_WAYLAND
228228
libva_wayland_sources = [
229229
'wayland/va_wayland.c',
230+
'wayland/va_wayland_linux_dmabuf.c',
230231
'wayland/va_wayland_drm.c',
231232
'wayland/va_wayland_emgd.c',
232233
'drm/va_drm_utils.c',
@@ -240,24 +241,32 @@ if WITH_WAYLAND
240241
libva_headers_subproject += libva_wayland_headers
241242

242243
libva_wayland_headers_priv = [
244+
'wayland/va_wayland_linux_dmabuf.h',
243245
'wayland/va_wayland_drm.h',
244246
'wayland/va_wayland_emgd.h',
245247
'wayland/va_wayland_private.h',
246248
]
247249

248-
protocol_files = [
249-
custom_target(
250-
'wayland-drm-client-protocol.c',
251-
output : 'wayland-drm-client-protocol.c',
252-
input : 'wayland/wayland-drm.xml',
253-
command : [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@']),
254-
255-
custom_target(
256-
'wayland-drm-client-protocol.h',
257-
output : 'wayland-drm-client-protocol.h',
258-
input : 'wayland/wayland-drm.xml',
250+
wayland_protocols_dir = wayland_protocols_dep.get_variable(pkgconfig : 'pkgdatadir')
251+
252+
protocols = {
253+
'wayland-drm': 'wayland/wayland-drm.xml',
254+
'linux-dmabuf-unstable-v1': wayland_protocols_dir / 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml',
255+
}
256+
257+
protocol_files = []
258+
foreach name, xml : protocols
259+
protocol_files += custom_target(
260+
name + '-client-protocol.c',
261+
output : name + '-client-protocol.c',
262+
input : xml,
263+
command : [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'])
264+
protocol_files += custom_target(
265+
name + '-client-protocol.h',
266+
output : name + '-client-protocol.h',
267+
input : xml,
259268
command : [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])
260-
]
269+
endforeach
261270

262271
install_headers(libva_wayland_headers, subdir : 'va')
263272

va/wayland/Makefile.am

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ AM_CPPFLAGS = \
2929

3030
source_c = \
3131
va_wayland.c \
32+
va_wayland_linux_dmabuf.c \
3233
va_wayland_drm.c \
3334
va_wayland_emgd.c \
3435
../drm/va_drm_utils.c \
@@ -40,16 +41,19 @@ source_h = \
4041
$(NULL)
4142

4243
source_h_priv = \
44+
va_wayland_linux_dmabuf.h \
4345
va_wayland_drm.h \
4446
va_wayland_emgd.h \
4547
va_wayland_private.h \
4648
$(NULL)
4749

4850
protocol_source_c = \
51+
linux-dmabuf-unstable-v1-client-protocol.c \
4952
wayland-drm-client-protocol.c \
5053
$(NULL)
5154

5255
protocol_source_h = \
56+
linux-dmabuf-unstable-v1-client-protocol.h \
5357
wayland-drm-client-protocol.h \
5458
$(NULL)
5559

@@ -66,6 +70,12 @@ va_wayland_drm.c: $(protocol_source_h)
6670
%-client-protocol.c : %.xml
6771
$(AM_V_GEN)$(WAYLAND_SCANNER) private-code < $< > $@
6872

73+
va_wayland_linux_dmabuf.c: $(protocol_source_h)
74+
linux-dmabuf-unstable-v1-client-protocol.h: $(WAYLAND_PROTOCOLS_DIR)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
75+
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
76+
linux-dmabuf-unstable-v1-client-protocol.c : $(WAYLAND_PROTOCOLS_DIR)/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
77+
$(AM_V_GEN)$(WAYLAND_SCANNER) private-code < $< > $@
78+
6979
EXTRA_DIST = \
7080
wayland-drm.xml \
7181
$(NULL)

va/wayland/va_wayland.c

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "sysdeps.h"
2828
#include <stdarg.h>
2929
#include "va_wayland.h"
30+
#include "va_wayland_linux_dmabuf.h"
3031
#include "va_wayland_drm.h"
3132
#include "va_wayland_emgd.h"
3233
#include "va_wayland_private.h"
@@ -90,6 +91,10 @@ struct va_wayland_backend {
9091
};
9192

9293
static const struct va_wayland_backend g_backends[] = {
94+
{
95+
va_wayland_linux_dmabuf_create,
96+
va_wayland_linux_dmabuf_destroy
97+
},
9398
{
9499
va_wayland_drm_create,
95100
va_wayland_drm_destroy

0 commit comments

Comments
 (0)