missing
stamp-h1
/va/va_version.h
+/va/wayland/wayland-drm-client-protocol-export.c
+/va/wayland/wayland-drm-client-protocol.*
# - reset micro version to zero when VA-API major or minor version is changed
m4_define([libva_major_version], [m4_eval(va_api_major_version + 1)])
m4_define([libva_minor_version], [m4_eval(va_api_minor_version - 32)])
-m4_define([libva_micro_version], [3])
-m4_define([libva_pre_version], [0])
+m4_define([libva_micro_version], [4])
+m4_define([libva_pre_version], [1])
m4_define([libva_version],
[libva_major_version.libva_minor_version.libva_micro_version])
m4_define([libdrm_version], [2.4])
# Wayland minimum version number
-m4_define([wayland_api_version], [1.0.0])
+# 1.11.0 for wl_proxy_create_wrapper
+m4_define([wayland_api_version], [1.11.0])
AC_PREREQ(2.57)
AC_INIT([libva],
AC_ARG_ENABLE(x11,
[AC_HELP_STRING([--enable-x11],
- [build with VA/X11 API support @<:@default=yes@:>@])],
- [], [enable_x11="yes"])
+ [build with VA/X11 API support @<:@default=auto@:>@])],
+ [], [enable_x11="auto"])
AC_ARG_ENABLE(glx,
[AC_HELP_STRING([--enable-glx],
- [build with VA/GLX API support @<:@default=yes@:>@])],
- [], [enable_glx="yes"])
+ [build with VA/GLX API support @<:@default=auto@:>@])],
+ [], [enable_glx="auto"])
AC_ARG_ENABLE(egl,
[AC_HELP_STRING([--enable-egl],
- [build with VA/EGL API support @<:@default=yes@:>@])],
- [], [enable_egl="yes"])
+ [build with VA/EGL API support @<:@default=auto@:>@])],
+ [], [enable_egl="auto"])
AC_ARG_ENABLE([wayland],
[AC_HELP_STRING([--enable-wayland],
- [build with VA/Wayland API support @<:@default=yes@:>@])],
- [], [enable_wayland="yes"])
+ [build with VA/Wayland API support @<:@default=auto@:>@])],
+ [], [enable_wayland="auto"])
AC_ARG_ENABLE([va-messaging],
[AC_HELP_STRING([--enable-va-messaging],
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
+AC_PROG_SED
PKG_PROG_PKG_CONFIG
AC_HEADER_STDC
# Check for X11
USE_X11="no"
-if test "$enable_x11" = "yes"; then
- USE_X11="yes"
- PKG_CHECK_MODULES([X11], [x11], [:], [USE_X11="no"])
- PKG_CHECK_MODULES([XEXT], [xext], [:], [USE_X11="no"])
- PKG_CHECK_MODULES([XFIXES], [xfixes], [:], [USE_X11="no"])
+if test "x$enable_x11" != "xno"; then
+ PKG_CHECK_MODULES([X11], [x11 xext xfixes], [USE_X11="yes"], [:])
+
+ if test "x$USE_X11" = "xno" -a "x$enable_x11" = "xyes"; then
+ AC_MSG_ERROR([VA/X11 explicitly enabled, however $X11_PKG_ERRORS])
+ fi
+
if test "$USE_X11" = "yes"; then
AC_DEFINE([HAVE_VA_X11], [1], [Defined to 1 if VA/X11 API is built])
fi
# Check for GLX
USE_GLX="no"
-if test "$USE_X11:$enable_glx" = "yes:yes"; then
+
+if test "$USE_X11:$enable_glx" = "no:yes"; then
+ AC_MSG_ERROR([VA/GLX explicitly enabled, but VA/X11 isn't built])
+fi
+
+if test "$USE_X11:$enable_glx" != "yes:no"; then
PKG_CHECK_MODULES([GLX], [gl x11], [USE_GLX="yes"], [:])
saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
AC_CHECK_LIB([GL], [glXCreateContext], [:] [USE_GLX="no"])
CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
+
+ if test "x$USE_GLX" = "xno" -a "x$enable_glx" = "xyes"; then
+ AC_MSG_ERROR([VA/GLX explicitly enabled, but libGL couldn't be found])
+ fi
+
if test "$USE_GLX" = "yes"; then
AC_DEFINE([HAVE_VA_GLX], [1], [Defined to 1 if VA/GLX API is built])
fi
# Check for EGL
USE_EGL="no"
-if test "$enable_egl" = "yes"; then
+if test "x$enable_egl" != "xno"; then
PKG_CHECK_MODULES([EGL], [egl], [USE_EGL="yes"], [:])
saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
AC_CHECK_LIB([EGL], [eglGetDisplay], [:], [USE_EGL="no"])
CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
+
+ if test "x$USE_EGL" = "xno" -a "x$enable_egl" = "xyes"; then
+ AC_MSG_ERROR([VA/EGL explicitly enabled, but libEGL couldn't be found])
+ fi
+
if test "$USE_EGL" = "yes"; then
AC_DEFINE([HAVE_VA_EGL], [1], [Defined to 1 if VA/EGL API is built])
fi
AC_SUBST(WAYLAND_API_VERSION)
USE_WAYLAND="no"
-if test "$enable_wayland" = "yes"; then
+if test "x$enable_wayland" != "xno"; then
PKG_CHECK_MODULES([WAYLAND], [wayland-client >= wayland_api_version],
[USE_WAYLAND="yes"], [:])
+
+ if test "x$USE_WAYLAND" = "xno" -a "x$enable_wayland" = "xyes"; then
+ AC_MSG_ERROR([wayland explicitly enabled, however $WAYLAND_PKG_ERRORS])
+ fi
+
if test "$USE_WAYLAND" = "yes"; then
WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client`
libdir=@libdir@
includedir=@includedir@
driverdir=@LIBVA_DRIVERS_PATH@
+libva_version=@LIBVA_VERSION@
Name: libva
Description: Userspace Video Acceleration (VA) core interface
for(i = 0; i < nbExtensions; i++)
{
const GLubyte *strExtension = glGetStringi(GL_EXTENSIONS, i);
- if(strcmp(strExtension, (const GLubyte *)name) == 0)
+ if(strcmp((const char *) strExtension, name) == 0)
return 1;
}
#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000000
/** \brief Driver supports a power-of-two number of rows per slice. */
#define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001
-/** \brief Driver supports an arbitrary number of rows per slice. */
+/** \brief Driver supports an arbitrary number of macroblocks per slice. */
#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002
/**@}*/
struct trace_buf_manager *pbuf_mgr = &pva_trace->buf_manager;
struct trace_buf_info *pbuf_info = pbuf_mgr->pbuf_info[0];
VAContextID context = VA_INVALID_ID;
- int i = 0, idx = 0, valid = 0;
+ int i = 0, idx = 0;
LOCK_RESOURCE(pva_trace);
void va_TraceInit(VADisplay dpy)
{
char env_value[1024];
- unsigned short suffix = 0xffff & ((unsigned int)time(NULL));
- FILE *tmp;
struct va_trace *pva_trace = calloc(sizeof(struct va_trace), 1);
struct trace_context *trace_ctx = calloc(sizeof(struct trace_context), 1);
void va_TraceEnd(VADisplay dpy)
{
struct va_trace *pva_trace = NULL;
- int i = 0, j = 0;
+ int i = 0;
pva_trace = (struct va_trace *)(((VADisplayContextP)dpy)->vatrace);
if(!pva_trace)
va_TraceMsg(trace_ctx, "\tmax_frame_size = %d\n", p->max_frame_size);
break;
}
+ case VAEncMiscParameterTypeQualityLevel:
+ {
+ VAEncMiscParameterBufferQualityLevel *p = (VAEncMiscParameterBufferQualityLevel *)tmp->data;
+
+ va_TraceMsg(trace_ctx, "\t--VAEncMiscParameterBufferQualityLevel\n");
+ va_TraceMsg(trace_ctx, "\tquality_level = %d\n", p->quality_level);
+ break;
+ }
default:
va_TraceMsg(trace_ctx, "Unknown VAEncMiscParameterBuffer(type = %d):\n", tmp->type);
va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, data);
{
VAEncSequenceParameterBufferVP9 *p = (VAEncSequenceParameterBufferVP9 *)data;
DPY2TRACECTX(dpy, context, VA_INVALID_ID);
- int i;
va_TraceMsg(trace_ctx, "\t--VAEncSequenceParameterBufferVP9\n");
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)
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*
#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;
}
wl_drm_ctx->is_authenticated = 0;
- if (wl_drm_ctx->handle) {
- dlclose(wl_drm_ctx->handle);
- wl_drm_ctx->handle = NULL;
+ if (wl_drm_ctx->registry) {
+ wl_registry_destroy(wl_drm_ctx->registry);
+ wl_drm_ctx->registry = NULL;
+ }
+
+ if (wl_drm_ctx->queue) {
+ wl_event_queue_destroy(wl_drm_ctx->queue);
+ wl_drm_ctx->queue = NULL;
}
if (drm_state) {
struct va_wayland_drm_context *wl_drm_ctx = data;
if (strcmp(interface, "wl_drm") == 0) {
+ /* bind to at most version 2, but also support version 1 if
+ * compositor does not have v2
+ */
wl_drm_ctx->drm =
- wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface, 2);
+ wl_registry_bind(wl_drm_ctx->registry, id, &wl_drm_interface,
+ (version < 2) ? version : 2);
}
}
NULL,
};
+static bool
+wayland_roundtrip_queue(struct wl_display *display,
+ struct wl_event_queue *queue)
+{
+ if (wl_display_roundtrip_queue(display, queue) < 0) {
+ int err = wl_display_get_error(display);
+ va_wayland_error("Wayland roundtrip error: %s (errno %d)", strerror(err), err);
+ return false;
+ } else {
+ return true;
+ }
+}
+
bool
va_wayland_drm_create(VADisplayContextP pDisplayContext)
{
struct va_wayland_drm_context *wl_drm_ctx;
struct drm_state *drm_state;
struct VADriverVTableWayland *vtable = ctx->vtable_wayland;
+ struct wl_display *wrapped_display;
wl_drm_ctx = malloc(sizeof(*wl_drm_ctx));
- if (!wl_drm_ctx)
+ if (!wl_drm_ctx) {
+ va_wayland_error("could not allocate wl_drm_ctx");
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;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
drm_state = calloc(1, sizeof(struct drm_state));
- if (!drm_state)
+ if (!drm_state) {
+ va_wayland_error("could not allocate drm_state");
return false;
+ }
drm_state->fd = -1;
drm_state->auth_type = 0;
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;
+ /* 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.
+ * Using the default queue, events might get lost and crashes occur
+ * because wl_display_roundtrip is not thread-safe with respect to the
+ * same queue.
+ */
+ wl_drm_ctx->queue = wl_display_create_queue(ctx->native_dpy);
+ if (!wl_drm_ctx->queue) {
+ va_wayland_error("could not create Wayland event queue");
+ return false;
}
- wl_drm_ctx->drm_interface =
- dlsym(wl_drm_ctx->handle, "wl_drm_interface");
- if (!wl_drm_ctx->drm_interface)
+ wrapped_display = wl_proxy_create_wrapper(ctx->native_dpy);
+ if (!wrapped_display) {
+ va_wayland_error("could not create Wayland proxy wrapper");
return false;
+ }
- wl_drm_ctx->registry = wl_display_get_registry(ctx->native_dpy);
+ /* All created objects will inherit this queue */
+ wl_proxy_set_queue((struct wl_proxy *) wrapped_display, wl_drm_ctx->queue);
+ wl_drm_ctx->registry = wl_display_get_registry(wrapped_display);
+ wl_proxy_wrapper_destroy(wrapped_display);
wl_registry_add_listener(wl_drm_ctx->registry, ®istry_listener, wl_drm_ctx);
- wl_display_roundtrip(ctx->native_dpy);
+ if (!wayland_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue))
+ return false;
/* registry_handle_global should have been called by the
- * wl_display_roundtrip above
+ * wl_display_roundtrip_queue above
*/
+ /* Do not print an error, the compositor might just not support wl_drm */
if (!wl_drm_ctx->drm)
return false;
wl_drm_add_listener(wl_drm_ctx->drm, &drm_listener, pDisplayContext);
- wl_display_roundtrip(ctx->native_dpy);
- if (drm_state->fd < 0)
+ if (!wayland_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue))
+ return false;
+ if (drm_state->fd < 0) {
+ va_wayland_error("did not get DRM device");
+ return false;
+ }
+
+ if (!wayland_roundtrip_queue(ctx->native_dpy, wl_drm_ctx->queue))
return false;
- wl_display_roundtrip(ctx->native_dpy);
- if (!wl_drm_ctx->is_authenticated)
+ if (!wl_drm_ctx->is_authenticated) {
+ va_wayland_error("Wayland compositor did not respond to DRM authentication");
return false;
+ }
+
return true;
}
-I$(top_srcdir) \
-I$(top_srcdir)/va \
$(X11_CFLAGS) \
- $(XEXT_CFLAGS) \
- $(XFIXES_CFLAGS) \
$(DRM_CFLAGS) \
$(NULL)