summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Kerling <pkerling@casix.org>2017-06-13 12:33:27 +0200
committerXiang, Haihao <haihao.xiang@intel.com>2017-11-17 15:00:52 +0800
commit438b35fcb60b653db7c959aa6b69c91690bb321e (patch)
tree2edfb579809ae277523f75b60970f522b56ab21c
parentcb7c906265dbf18c3cef585af9ff6e7faec6a501 (diff)
downloadlibva-438b35fcb60b653db7c959aa6b69c91690bb321e.tar.gz
wayland: Do not rely on external library for wl_drm_interface
Doing the runtime lookup is error-prone (as indicated in the code already by the two library names) and not necessary at all. Just compile wl_drm_interface as part of libva which is the usual way to use extra Wayland protocols. Care must be taken as to not accidentally export the symbol though. (cherry picked from commit c26a187cdff82dc5a360676ef05e6f6d761c2a0a)
-rw-r--r--.gitignore2
-rw-r--r--configure.ac1
-rw-r--r--va/wayland/Makefile.am19
-rw-r--r--va/wayland/va_wayland_drm.c31
4 files changed, 20 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index 4906534..1641e78 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,5 @@ ltmain.sh
missing
stamp-h1
/va/va_version.h
+/va/wayland/wayland-drm-client-protocol-export.c
+/va/wayland/wayland-drm-client-protocol.*
diff --git a/configure.ac b/configure.ac
index c313d97..a85e97f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -172,6 +172,7 @@ AC_PROG_LIBTOOL
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
+AC_PROG_SED
PKG_PROG_PKG_CONFIG
AC_HEADER_STDC
diff --git a/va/wayland/Makefile.am b/va/wayland/Makefile.am
index 4ab8d07..1ac8d48 100644
--- a/va/wayland/Makefile.am
+++ b/va/wayland/Makefile.am
@@ -46,6 +46,14 @@ source_h_priv = \
va_wayland_private.h \
$(NULL)
+protocol_source_export_c = \
+ wayland-drm-client-protocol-export.c \
+ $(NULL)
+
+protocol_source_c = \
+ wayland-drm-client-protocol.c \
+ $(NULL)
+
protocol_source_h = \
wayland-drm-client-protocol.h \
$(NULL)
@@ -53,19 +61,24 @@ protocol_source_h = \
noinst_LTLIBRARIES = libva_wayland.la
libva_waylandincludedir = ${includedir}/va
libva_waylandinclude_HEADERS = $(source_h)
-libva_wayland_la_SOURCES = $(source_c)
+libva_wayland_la_SOURCES = $(source_c) $(protocol_source_c)
noinst_HEADERS = $(source_h_priv)
# Wayland protocol
va_wayland_drm.c: $(protocol_source_h)
%-client-protocol.h : %.xml
$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
-
+%-client-protocol-export.c : %.xml
+ $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
+%-client-protocol.c: %-client-protocol-export.c
+ $(AM_V_GEN)$(SED) -e '1i#include "sysdeps.h"' \
+ -e 's@WL_EXPORT@DLL_HIDDEN@g' < $< > $@
+
EXTRA_DIST = \
wayland-drm.xml \
$(NULL)
-BUILT_SOURCES = $(protocol_source_h)
+BUILT_SOURCES = $(protocol_source_h) $(protocol_source_c) $(protocol_source_export_c)
CLEANFILES = $(BUILT_SOURCES)
# Extra clean files so that maintainer-clean removes *everything*
diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c
index 4a24a2c..1c9c09a 100644
--- a/va/wayland/va_wayland_drm.c
+++ b/va/wayland/va_wayland_drm.c
@@ -37,19 +37,11 @@
#include "va_wayland_private.h"
#include "wayland-drm-client-protocol.h"
-/* XXX: Wayland/DRM support currently lives in Mesa libEGL.so.* library */
-/* First try the soname of a glvnd enabled mesa build */
-#define LIBWAYLAND_DRM_NAME "libEGL_mesa.so.0"
-/* Then fallback to plain libEGL.so.1 (which might not be mesa) */
-#define LIBWAYLAND_DRM_NAME_FALLBACK "libEGL.so.1"
-
typedef struct va_wayland_drm_context {
struct va_wayland_context base;
- void *handle;
struct wl_event_queue *queue;
struct wl_drm *drm;
struct wl_registry *registry;
- void *drm_interface;
unsigned int is_authenticated : 1;
} VADisplayContextWaylandDRM;
@@ -156,11 +148,6 @@ va_wayland_drm_destroy(VADisplayContextP pDisplayContext)
wl_drm_ctx->queue = NULL;
}
- if (wl_drm_ctx->handle) {
- dlclose(wl_drm_ctx->handle);
- wl_drm_ctx->handle = NULL;
- }
-
if (drm_state) {
if (drm_state->fd >= 0) {
close(drm_state->fd);
@@ -187,7 +174,7 @@ registry_handle_global(
* compositor does not have v2
*/
wl_drm_ctx->drm =
- wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface,
+ wl_registry_bind(wl_drm_ctx->registry, id, &wl_drm_interface,
(version < 2) ? version : 2);
}
}
@@ -225,10 +212,8 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
return false;
}
wl_drm_ctx->base.destroy = va_wayland_drm_destroy;
- wl_drm_ctx->handle = NULL;
wl_drm_ctx->queue = NULL;
wl_drm_ctx->drm = NULL;
- wl_drm_ctx->drm_interface = NULL;
wl_drm_ctx->registry = NULL;
wl_drm_ctx->is_authenticated = 0;
pDisplayContext->opaque = wl_drm_ctx;
@@ -244,20 +229,6 @@ va_wayland_drm_create(VADisplayContextP pDisplayContext)
ctx->drm_state = drm_state;
vtable->has_prime_sharing = 0;
- wl_drm_ctx->handle = dlopen(LIBWAYLAND_DRM_NAME, RTLD_LAZY|RTLD_LOCAL);
- if (!wl_drm_ctx->handle) {
- wl_drm_ctx->handle = dlopen(LIBWAYLAND_DRM_NAME_FALLBACK, RTLD_LAZY|RTLD_LOCAL);
- if (!wl_drm_ctx->handle)
- return false;
- }
-
- wl_drm_ctx->drm_interface =
- dlsym(wl_drm_ctx->handle, "wl_drm_interface");
- if (!wl_drm_ctx->drm_interface) {
- va_wayland_error("wl_drm_interface not found in library");
- return false;
- }
-
/* Use wrapped wl_display with private event queue to prevent
* thread safety issues with applications that e.g. run an event pump
* parallel to libva initialization.