Skip to content

Commit

Permalink
wayland: add support for linux-dmabuf
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
emersion authored and XinfengZhang committed Mar 21, 2024
1 parent 6f3e068 commit d5bef6b
Show file tree
Hide file tree
Showing 8 changed files with 1,035 additions and 14 deletions.
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ m4_define([libva_lt_age],
[m4_eval(libva_binary_age - libva_interface_age)])

# libdrm minimun version requirement
m4_define([libdrm_version], [2.4.60])
# 2.4.75 for drmGetDevices2
m4_define([libdrm_version], [2.4.75])

# Wayland minimum version number
# 1.11.0 for wl_proxy_create_wrapper
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cc = meson.get_compiler('c')
dl_dep = cc.find_library('dl', required : false)

WITH_DRM = not get_option('disable_drm') and (host_machine.system() != 'windows')
libdrm_dep = dependency('libdrm', version : '>= 2.4.60', required : (host_machine.system() != 'windows'))
libdrm_dep = dependency('libdrm', version : '>= 2.4.75', required : (host_machine.system() != 'windows'))

WITH_X11 = false
if get_option('with_x11') != 'no'
Expand Down
32 changes: 20 additions & 12 deletions va/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ endif
if WITH_WAYLAND
libva_wayland_sources = [
'wayland/va_wayland.c',
'wayland/va_wayland_linux_dmabuf.c',
'wayland/va_wayland_drm.c',
'wayland/va_wayland_emgd.c',
'drm/va_drm_utils.c',
Expand All @@ -241,24 +242,31 @@ if WITH_WAYLAND
libva_headers_subproject += libva_wayland_headers

libva_wayland_headers_priv = [
'wayland/va_wayland_linux_dmabuf.h',
'wayland/va_wayland_drm.h',
'wayland/va_wayland_emgd.h',
'wayland/va_wayland_private.h',
]

protocol_files = [
custom_target(
'wayland-drm-client-protocol.c',
output : 'wayland-drm-client-protocol.c',
input : 'wayland/wayland-drm.xml',
command : [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@']),

custom_target(
'wayland-drm-client-protocol.h',
output : 'wayland-drm-client-protocol.h',
input : 'wayland/wayland-drm.xml',
# XXX: grab linux-dmabuf-v1.xml from wayland-protocols
protocols = {
'wayland-drm': 'wayland/wayland-drm.xml',
'linux-dmabuf-v1': 'wayland/linux-dmabuf-v1.xml',
}

protocol_files = []
foreach name, xml : protocols
protocol_files += custom_target(
name + '-client-protocol.c',
output : name + '-client-protocol.c',
input : xml,
command : [wl_scanner, 'private-code', '@INPUT@', '@OUTPUT@'])
protocol_files += custom_target(
name + '-client-protocol.h',
output : name + '-client-protocol.h',
input : xml,
command : [wl_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])
]
endforeach

install_headers(libva_wayland_headers, subdir : 'va')

Expand Down
6 changes: 6 additions & 0 deletions va/wayland/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ AM_CPPFLAGS = \

source_c = \
va_wayland.c \
va_wayland_linux_dmabuf.c \
va_wayland_drm.c \
va_wayland_emgd.c \
../drm/va_drm_utils.c \
Expand All @@ -40,16 +41,19 @@ source_h = \
$(NULL)

source_h_priv = \
va_wayland_linux_dmabuf.h \
va_wayland_drm.h \
va_wayland_emgd.h \
va_wayland_private.h \
$(NULL)

protocol_source_c = \
linux-dmabuf-v1-client-protocol.c \
wayland-drm-client-protocol.c \
$(NULL)

protocol_source_h = \
linux-dmabuf-v1-client-protocol.h \
wayland-drm-client-protocol.h \
$(NULL)

Expand All @@ -61,13 +65,15 @@ noinst_HEADERS = $(source_h_priv)

# Wayland protocol
va_wayland_drm.c: $(protocol_source_h)
va_wayland_linux_dmabuf.c: $(protocol_source_h)
%-client-protocol.h : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
%-client-protocol.c : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) private-code < $< > $@

EXTRA_DIST = \
wayland-drm.xml \
linux-dmabuf-v1.xml \
$(NULL)

BUILT_SOURCES = $(protocol_source_h) $(protocol_source_c)
Expand Down
Loading

0 comments on commit d5bef6b

Please sign in to comment.