summaryrefslogtreecommitdiff
path: root/va
diff options
context:
space:
mode:
authorAustin Yuan <shengquan.yuan@gmail.com>2013-03-05 14:54:42 +0800
committerbuildbot <buildbot@intel.com>2013-03-19 04:22:24 -0700
commit409de6acb4473c973ed2532e340831dc582e5e0e (patch)
tree4852ddb553a4e39188131595da6ddd20f8abae44 /va
parent4407bb4292b63ce0733f9b46d1c96e881f1f4118 (diff)
downloadlibva-409de6acb4473c973ed2532e340831dc582e5e0e.tar.gz
Rebase libVA to latest freedesktop "staging" branch
BZ: 90494 Change-Id: Ifef4ebc201bd6c516a7bfbe239834747d765fa40 Signed-off-by: Austin Yuan <shengquan.yuan@gmail.com> Reviewed-on: http://android.intel.com:8080/95042 Reviewed-by: cactus <cactus@intel.com> Reviewed-by: Yuan, Shengquan <shengquan.yuan@intel.com> Reviewed-by: Shi, PingX <pingx.shi@intel.com> Tested-by: Shi, PingX <pingx.shi@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'va')
-rwxr-xr-xva/Android.mk42
-rw-r--r--va/Makefile.am56
-rw-r--r--va/android/va_android.cpp157
-rw-r--r--va/drm/Makefile.am58
-rw-r--r--va/drm/va_drm.c126
-rw-r--r--va/drm/va_drm.h61
-rw-r--r--va/drm/va_drm_auth.c61
-rw-r--r--va/drm/va_drm_auth.h39
-rw-r--r--va/drm/va_drm_auth_x11.c172
-rw-r--r--va/drm/va_drm_auth_x11.h35
-rw-r--r--va/drm/va_drm_utils.c79
-rw-r--r--va/drm/va_drm_utils.h73
-rw-r--r--va/egl/Makefile.am7
-rw-r--r--va/glx/Makefile.am9
-rw-r--r--va/glx/va_glx.c1
-rw-r--r--va/sysdeps.h35
-rwxr-xr-xva/va.c60
-rwxr-xr-xva/va.h125
-rw-r--r--va/va_android.h32
-rwxr-xr-xva/va_backend.h51
-rw-r--r--va/va_backend_tpi.h3
-rw-r--r--va/va_dec_jpeg.h33
-rw-r--r--va/va_dec_vp8.h52
-rw-r--r--va/va_drmcommon.h76
-rw-r--r--va/va_enc.h21
-rw-r--r--va/va_enc_h264.h15
-rw-r--r--va/va_enc_mpeg2.h301
-rw-r--r--va/va_enc_vp8.h27
-rwxr-xr-xva/va_trace.c17
-rwxr-xr-xva/va_trace.h6
-rw-r--r--va/va_vpp.h180
-rw-r--r--va/va_x11.h23
-rw-r--r--va/wayland/Makefile.am66
-rw-r--r--va/wayland/protocol/Makefile.am28
-rw-r--r--va/wayland/protocol/wayland-drm.xml155
-rw-r--r--va/wayland/va_backend_wayland.h65
-rw-r--r--va/wayland/va_wayland.c194
-rw-r--r--va/wayland/va_wayland.h131
-rw-r--r--va/wayland/va_wayland_drm.c223
-rw-r--r--va/wayland/va_wayland_drm.h52
-rw-r--r--va/wayland/va_wayland_emgd.c157
-rw-r--r--va/wayland/va_wayland_emgd.h52
-rw-r--r--va/wayland/va_wayland_private.h44
-rw-r--r--va/wayland/wayland-drm-client-protocol.h213
-rw-r--r--va/x11/Makefile.am10
-rw-r--r--va/x11/dri1_util.c28
-rw-r--r--va/x11/dri2_util.c52
-rw-r--r--va/x11/va_dricommon.c33
-rw-r--r--va/x11/va_dricommon.h39
-rw-r--r--va/x11/va_x11.c11
50 files changed, 3218 insertions, 368 deletions
diff --git a/va/Android.mk b/va/Android.mk
index a6df318..241f599 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -23,12 +23,15 @@
# For libva
# =====================================================
-ifeq ($(INTEL_VA),true)
-
LOCAL_PATH:= $(call my-dir)
LIBVA_DRIVERS_PATH = /system/lib
+# Version set to Android Jelly Bean
+ALOG_VERSION_REQ := 4.1
+ALOG_VERSION := $(filter $(ALOG_VERSION_REQ),$(firstword $(sort $(PLATFORM_VERSION) \
+ $(ALOG_VERSION_REQ))))
+
include $(CLEAR_VARS)
#LIBVA_MINOR_VERSION := 31
@@ -41,7 +44,15 @@ LOCAL_SRC_FILES := \
LOCAL_CFLAGS += \
-DANDROID \
- -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\""
+ -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" \
+ -DLOG_TAG=\"libva\"
+
+# Android Jelly Bean defined ALOGx, older versions use LOGx
+ifeq ($(ALOG_VERSION), $(ALOG_VERSION_REQ))
+LOCAL_CFLAGS += -DANDROID_ALOG
+else
+LOCAL_CFLAGS += -DANDROID_LOG
+endif
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
@@ -51,15 +62,17 @@ LOCAL_C_INCLUDES += \
LOCAL_COPY_HEADERS := \
va.h \
va_version.h \
+ va_dec_jpeg.h \
va_enc.h \
va_enc_h264.h \
va_enc_vp8.h \
- va_backend.h \
- x11/va_dricommon.h \
- va_vpp.h \
va_dec_vp8.h \
va_dec_jpeg.h \
- va_backend_vpp.h
+ va_backend.h \
+ va_drmcommon.h \
+ va_vpp.h \
+ va_backend_vpp.h \
+ va_enc_mpeg2.h \
LOCAL_COPY_HEADERS_TO := libva/va
@@ -84,14 +97,16 @@ LOCAL_GENERATED_SOURCES += $(GEN)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- android/va_android.cpp
+ android/va_android.cpp \
+ drm/va_drm_utils.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID -DLOG_TAG=\"libva-android\"
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
- $(LOCAL_PATH)/x11
+ $(TARGET_OUT_HEADERS)/libdrm \
+ $(LOCAL_PATH)/drm
LOCAL_COPY_HEADERS_TO := libva/va
@@ -100,7 +115,7 @@ LOCAL_COPY_HEADERS := va_android.h
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva-android
-LOCAL_SHARED_LIBRARIES := libva
+LOCAL_SHARED_LIBRARIES := libva libdrm
include $(BUILD_SHARED_LIBRARY)
@@ -114,7 +129,7 @@ LOCAL_SRC_FILES := \
egl/va_egl.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID -DLOG_TAG=\"libva-egl\"
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
@@ -139,7 +154,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := va_tpi.c
-LOCAL_CFLAGS += -DANDROID
+LOCAL_CFLAGS += -DANDROID -DLOG_TAG=\"libva-tpi\"
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
@@ -157,4 +172,3 @@ LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libva-tpi
include $(BUILD_SHARED_LIBRARY)
-endif
diff --git a/va/Makefile.am b/va/Makefile.am
index 8d4f31a..7ffde12 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -46,14 +46,14 @@ libva_source_h = \
va_compat.h \
va_dec_jpeg.h \
va_dec_vp8.h \
+ va_drmcommon.h \
va_dummy.h \
va_enc.h \
va_enc_h264.h \
- va_enc_vp8.h \
+ va_enc_mpeg2.h \
va_tpi.h \
va_version.h \
va_vpp.h \
- va_x11.h \
$(NULL)
libva_source_h_priv = \
@@ -79,25 +79,38 @@ libva_la_LIBADD = $(LIBVA_LIBS) -ldl
lib_LTLIBRARIES += libva-tpi.la
libva_tpi_la_SOURCES = va_tpi.c
libva_tpi_la_LDFLAGS = $(LDADD) -no-undefined
-libva_tpi_la_DEPENDENCIES = $(libvacorelib)
-libva_tpi_la_LIBADD = $(libvacorelib) -ldl
+libva_tpi_la_DEPENDENCIES = libva.la
+libva_tpi_la_LIBADD = libva.la -ldl
+
+if USE_DRM
+SUBDIRS += drm
+lib_LTLIBRARIES += libva-drm.la
+libva_drm_la_SOURCES =
+libva_drm_la_LDFLAGS = $(LDADD)
+libva_drm_la_DEPENDENCIES = libva.la drm/libva_drm.la
+libva_drm_la_LIBADD = libva.la drm/libva_drm.la \
+ $(LIBVA_LIBS) $(DRM_LIBS) -ldl
+endif
+if USE_X11
SUBDIRS += x11
lib_LTLIBRARIES += libva-x11.la
+libva_source_h += va_x11.h
libva_x11_la_SOURCES =
libva_x11_la_LDFLAGS = $(LDADD)
-libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la
-libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la \
- $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(DRM_LIBS) $(XFIXES_LIBS) -ldl
+libva_x11_la_DEPENDENCIES = libva.la x11/libva_x11.la
+libva_x11_la_LIBADD = libva.la x11/libva_x11.la \
+ $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) $(DRM_LIBS) -ldl
+endif
if USE_GLX
SUBDIRS += glx
lib_LTLIBRARIES += libva-glx.la
libva_glx_la_SOURCES =
libva_glx_la_LDFLAGS = $(LDADD)
-libva_glx_la_DEPENDENCIES = $(libvacorelib) glx/libva_glx.la libva-x11.la
-libva_glx_la_LIBADD = $(libvacorelib) glx/libva_glx.la libva-x11.la \
- $(GL_DEPS_LIBS) -ldl
+libva_glx_la_DEPENDENCIES = libva.la glx/libva_glx.la libva-x11.la
+libva_glx_la_LIBADD = libva.la glx/libva_glx.la libva-x11.la \
+ $(GLX_LIBS) -ldl
endif
if USE_EGL
@@ -105,9 +118,19 @@ SUBDIRS += egl
lib_LTLIBRARIES += libva-egl.la
libva_egl_la_SOURCES =
libva_egl_la_LDFLAGS = $(LDADD)
-libva_egl_la_DEPENDENCIES = $(libvacorelib) egl/libva_egl.la libva-x11.la
-libva_egl_la_LIBADD = $(libvacorelib) egl/libva_egl.la libva-x11.la \
- $(GL_DEPS_LIBS) -ldl
+libva_egl_la_DEPENDENCIES = libva.la egl/libva_egl.la libva-x11.la
+libva_egl_la_LIBADD = libva.la egl/libva_egl.la libva-x11.la \
+ $(EGL_LIBS) -ldl
+endif
+
+if USE_WAYLAND
+SUBDIRS += wayland
+lib_LTLIBRARIES += libva-wayland.la
+libva_wayland_la_SOURCES =
+libva_wayland_la_LDFLAGS = $(LDADD)
+libva_wayland_la_DEPENDENCIES = libva.la wayland/libva_wayland.la
+libva_wayland_la_LIBADD = libva.la wayland/libva_wayland.la \
+ $(WAYLAND_LIBS) $(DRM_LIBS) -ldl
endif
if BUILD_DUMMY_BACKEND
@@ -115,12 +138,12 @@ SUBDIRS += dummy
lib_LTLIBRARIES += libva-dummy.la
libva_dummy_la_SOURCES =
libva_dummy_la_LDFLAGS = $(LDADD)
-libva_dummy_la_DEPENDENCIES = $(libvacorelib) dummy/libva_dummy.la
-libva_dummy_la_LIBADD = $(libvacorelib) dummy/libva_dummy.la \
+libva_dummy_la_DEPENDENCIES = libva.la dummy/libva_dummy.la
+libva_dummy_la_LIBADD = libva.la dummy/libva_dummy.la \
$(LIBVA_LIBS) $(DRM_LIBS)
endif
-DIST_SUBDIRS = x11 glx egl dummy
+DIST_SUBDIRS = x11 glx egl dummy drm wayland
DISTCLEANFILES = \
va_version.h \
@@ -128,4 +151,5 @@ DISTCLEANFILES = \
EXTRA_DIST = \
va_version.h.in \
+ libva.syms \
$(NULL)
diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp
index 30ebf11..e2edb92 100644
--- a/va/android/va_android.cpp
+++ b/va/android/va_android.cpp
@@ -23,29 +23,25 @@
*/
#define _GNU_SOURCE 1
+#include "sysdeps.h"
#include "va.h"
#include "va_backend.h"
#include "va_trace.h"
#include "va_fool.h"
#include "va_android.h"
-#include "va_dricommon.h" /* needs some helper functions from this file */
-#include <stdio.h>
-#include <stdlib.h>
+#include "va_drmcommon.h"
+#include "va_drm_utils.h"
#include <stdarg.h>
-#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <errno.h>
-#ifndef ANDROID
-#include <libudev.h>
-#include "drmtest.h"
-#endif
+
#define CHECK_SYMBOL(func) { if (!func) printf("func %s not found\n", #func); return VA_STATUS_ERROR_UNKNOWN; }
-#define DEVICE_NAME "/dev/card0"
+#define DEVICE_NAME "/dev/dri/card0"
static int open_device (char *dev_name)
{
@@ -89,115 +85,40 @@ static void va_DisplayContextDestroy (
VADisplayContextP pDisplayContext
)
{
- struct dri_state *dri_state;
+ struct drm_state *drm_state;
if (pDisplayContext == NULL)
return;
/* close the open-ed DRM fd */
- dri_state = (struct dri_state *)pDisplayContext->pDriverContext->dri_state;
- close(dri_state->fd);
+ drm_state = (struct drm_state *)pDisplayContext->pDriverContext->drm_state;
+ close(drm_state->fd);
- free(pDisplayContext->pDriverContext->dri_state);
+ free(pDisplayContext->pDriverContext->drm_state);
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
-#ifdef ANDROID
static VAStatus va_DisplayContextGetDriverName (
VADisplayContextP pDisplayContext,
char **driver_name
)
{
- VADriverContextP ctx = pDisplayContext->pDriverContext;
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
- int vendor_id, device_id;
-
- struct {
- int vendor_id;
- int device_id;
- char driver_name[64];
- } devices[] = {
- { 0x8086, 0x4100, "pvr" },
- { 0x8086, 0x0130, "pvr" },
- { 0x1010, 0x1cf2, "pvr" },
- { 0x0, 0x0, "\0" },
- };
-
- memset(dri_state, 0, sizeof(*dri_state));
- dri_state->fd = open_device((char *)DEVICE_NAME);
-
- if (dri_state->fd < 0) {
- fprintf(stderr,"can't open DRM devices\n");
- return VA_STATUS_ERROR_UNKNOWN;
- }
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ struct drm_state * drm_state = (struct drm_state *)ctx->drm_state;
- /* TBD: other vendor driver names */
- vendor_id = devices[0].vendor_id;
- device_id = devices[0].device_id;
- *driver_name = strdup(devices[0].driver_name);
-
- dri_state->driConnectedFlag = VA_DUMMY;
+ memset(drm_state, 0, sizeof(*drm_state));
+ drm_state->fd = open_device((char *)DEVICE_NAME);
- return VA_STATUS_SUCCESS;
-}
-#else
-static VAStatus va_DisplayContextGetDriverName (
- VADisplayContextP pDisplayContext,
- char **driver_name
-)
-{
- VADriverContextP ctx = pDisplayContext->pDriverContext;
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
- char *driver_name_env;
- int vendor_id, device_id;
- int i = 0;
-
- struct {
- int vendor_id;
- int device_id;
- char driver_name[64];
- } devices[] = {
- { 0x8086, 0x4100, "pvr" },
- { 0x8086, 0x0130, "pvr" },
- { 0x1010, 0x1cf2, "pvr" },
- { 0x0, 0x0, "\0" },
- };
-
- memset(dri_state, 0, sizeof(*dri_state));
- dri_state->fd = drm_open_any(&vendor_id, &device_id);
-
- if (dri_state->fd < 0) {
+ if (drm_state->fd < 0) {
fprintf(stderr,"can't open DRM devices\n");
return VA_STATUS_ERROR_UNKNOWN;
}
-
- /* TBD: other vendor driver names */
-
- while (devices[i].device_id != 0) {
- if ((devices[i].vendor_id == vendor_id) &&
- (devices[i].device_id == device_id))
- break;
- i++;
- }
+ drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
- if (devices[i].device_id != 0)
- *driver_name = strdup(devices[i].driver_name);
- else {
- fprintf(stderr,"device (0x%04x:0x%04x) is not supported\n",
- vendor_id, device_id);
-
- return VA_STATUS_ERROR_UNKNOWN;
- }
-
- printf("DRM device is opened, loading driver %s for device 0x%04x:0x%04x\n",
- driver_name, vendor_id, device_id);
-
- dri_state->driConnectedFlag = VA_DUMMY;
-
- return VA_STATUS_SUCCESS;
+ return VA_DRM_GetDriverName(ctx, driver_name);
}
-#endif
+
VADisplay vaGetDisplay (
void *native_dpy /* implementation specific */
@@ -212,21 +133,22 @@ VADisplay vaGetDisplay (
if (!dpy)
{
/* create new entry */
- VADriverContextP pDriverContext;
- struct dri_state *dri_state;
+ VADriverContextP pDriverContext = 0;
+ struct drm_state *drm_state = 0;
pDisplayContext = (VADisplayContextP)calloc(1, sizeof(*pDisplayContext));
pDriverContext = (VADriverContextP)calloc(1, sizeof(*pDriverContext));
- dri_state = (struct dri_state*)calloc(1, sizeof(*dri_state));
- if (pDisplayContext && pDriverContext && dri_state)
+ drm_state = (struct drm_state*)calloc(1, sizeof(*drm_state));
+ if (pDisplayContext && pDriverContext && drm_state)
{
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDriverContext->native_dpy = (void *)native_dpy;
+ pDriverContext->display_type = VA_DISPLAY_ANDROID;
pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
- pDriverContext->dri_state = dri_state;
+ pDriverContext->drm_state = drm_state;
dpy = (VADisplay)pDisplayContext;
}
else
@@ -235,8 +157,8 @@ VADisplay vaGetDisplay (
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
- if (dri_state)
- free(dri_state);
+ if (drm_state)
+ free(drm_state);
}
}
@@ -247,7 +169,6 @@ VADisplay vaGetDisplay (
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
-#ifdef ANDROID
extern "C" {
extern int fool_postp; /* do nothing for vaPutSurface if set */
extern int trace_flag; /* trace vaPutSurface parameters */
@@ -273,7 +194,7 @@ extern "C" {
VAStatus vaPutSurface (
VADisplay dpy,
VASurfaceID surface,
- sp<ISurface> draw, /* Android Surface/Window */
+ sp<ANativeWindow> draw, /* Android Native Window */
short srcx,
short srcy,
unsigned short srcw,
@@ -291,10 +212,10 @@ VAStatus vaPutSurface (
if (fool_postp)
return VA_STATUS_SUCCESS;
-/*
+
if (draw == NULL)
return VA_STATUS_ERROR_UNKNOWN;
-*/
+
CHECK_DISPLAY(dpy);
ctx = CTX(dpy);
@@ -306,24 +227,4 @@ VAStatus vaPutSurface (
destx, desty, destw, desth,
cliprects, number_cliprects, flags );
}
-#else
-VAStatus vaPutSurface (
- VADisplay dpy,
- VASurfaceID surface,
- void *draw,
- short srcx,
- short srcy,
- unsigned short srcw,
- unsigned short srch,
- short destx,
- short desty,
- unsigned short destw,
- unsigned short desth,
- VARectangle *cliprects, /* client supplied clip list */
- unsigned int number_cliprects, /* number of clip rects in the clip list */
- unsigned int flags /* de-interlacing flags */
-)
-{
- return VA_STATUS_SUCCESS;
-}
-#endif
+
diff --git a/va/drm/Makefile.am b/va/drm/Makefile.am
new file mode 100644
index 0000000..b860ff5
--- /dev/null
+++ b/va/drm/Makefile.am
@@ -0,0 +1,58 @@
+# Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(DRM_CFLAGS) \
+ $(NULL)
+
+source_c = \
+ va_drm.c \
+ va_drm_auth.c \
+ va_drm_utils.c \
+ $(NULL)
+
+source_h = \
+ va_drm.h \
+ $(NULL)
+
+source_h_priv = \
+ va_drm_auth.h \
+ va_drm_auth_x11.h \
+ va_drm_utils.h \
+ $(NULL)
+
+if USE_X11
+source_c += va_drm_auth_x11.c
+INCLUDES += $(X11_CFLAGS)
+endif
+
+noinst_LTLIBRARIES = libva_drm.la
+libva_drmincludedir = ${includedir}/va
+libva_drminclude_HEADERS = $(source_h)
+libva_drm_la_SOURCES = $(source_c)
+noinst_HEADERS = $(source_h_priv)
+
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/va/drm/va_drm.c b/va/drm/va_drm.c
new file mode 100644
index 0000000..25bf8bb
--- /dev/null
+++ b/va/drm/va_drm.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <xf86drm.h>
+#include "va_drm.h"
+#include "va_backend.h"
+#include "va_drmcommon.h"
+#include "va_drm_auth.h"
+#include "va_drm_utils.h"
+
+static int
+va_DisplayContextIsValid(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const pDriverContext = pDisplayContext->pDriverContext;
+
+ return (pDriverContext &&
+ pDriverContext->display_type == VA_DISPLAY_DRM);
+}
+
+static void
+va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
+{
+ if (!pDisplayContext)
+ return;
+
+ free(pDisplayContext->pDriverContext->drm_state);
+ free(pDisplayContext->pDriverContext);
+ free(pDisplayContext);
+}
+
+static VAStatus
+va_DisplayContextGetDriverName(
+ VADisplayContextP pDisplayContext,
+ char **driver_name_ptr
+)
+{
+
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ struct drm_state * const drm_state = ctx->drm_state;
+ drm_magic_t magic;
+ VAStatus status;
+ int ret;
+
+ status = VA_DRM_GetDriverName(ctx, driver_name_ptr);
+ if (status != VA_STATUS_SUCCESS)
+ return status;
+
+ ret = drmGetMagic(drm_state->fd, &magic);
+ if (ret < 0)
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+
+ if (!va_drm_is_authenticated(drm_state->fd)) {
+ if (!va_drm_authenticate(drm_state->fd, magic))
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+ if (!va_drm_is_authenticated(drm_state->fd))
+ return VA_STATUS_ERROR_OPERATION_FAILED;
+ }
+
+ drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
+
+ return VA_STATUS_SUCCESS;
+}
+
+VADisplay
+vaGetDisplayDRM(int fd)
+{
+ VADisplayContextP pDisplayContext = NULL;
+ VADriverContextP pDriverContext = NULL;
+ struct drm_state *drm_state = NULL;
+
+ if (fd < 0)
+ return NULL;
+
+ /* Create new entry */
+ /* XXX: handle cache? */
+ drm_state = calloc(1, sizeof(*drm_state));
+ if (!drm_state)
+ goto error;
+ drm_state->fd = fd;
+
+ pDriverContext = calloc(1, sizeof(*pDriverContext));
+ if (!pDriverContext)
+ goto error;
+ pDriverContext->native_dpy = NULL;
+ pDriverContext->display_type = VA_DISPLAY_DRM;
+ pDriverContext->drm_state = drm_state;
+
+ pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+ if (!pDisplayContext)
+ goto error;
+
+ pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
+ pDisplayContext->pDriverContext = pDriverContext;
+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+ return pDisplayContext;
+
+error:
+ free(pDisplayContext);
+ free(pDriverContext);
+ free(drm_state);
+ return NULL;
+}
diff --git a/va/drm/va_drm.h b/va/drm/va_drm.h
new file mode 100644
index 0000000..9af3cc8
--- /dev/null
+++ b/va/drm/va_drm.h
@@ -0,0 +1,61 @@
+/*
+ * va_drm.h - Raw DRM API
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_DRM_H
+#define VA_DRM_H
+
+#include <va/va.h>
+
+/**
+ * \file va_drm.h
+ * \brief The raw DRM API
+ *
+ * This file contains the \ref api_drm "Raw DRM API".
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Returns a VA display derived from the specified DRM connection.
+ *
+ * This function returns a (possibly cached) VA display from the
+ * specified DRM connection @fd.
+ *
+ * @param[in] fd the DRM connection descriptor
+ * @return the VA display
+ */
+VADisplay
+vaGetDisplayDRM(int fd);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DRM_H */
diff --git a/va/drm/va_drm_auth.c b/va/drm/va_drm_auth.c
new file mode 100644
index 0000000..59aecaf
--- /dev/null
+++ b/va/drm/va_drm_auth.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <unistd.h>
+#include <xf86drm.h>
+#include "va_drm_auth.h"
+#include "va_drm_auth_x11.h"
+
+/* Checks whether DRM connection is authenticated */
+bool
+va_drm_is_authenticated(int fd)
+{
+ pid_t client_pid;
+ int i, auth, pid, uid;
+ unsigned long magic, iocs;
+ bool is_authenticated = false;
+
+ client_pid = getpid();
+ for (i = 0; !is_authenticated; i++) {
+ if (drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs) != 0)
+ break;
+ is_authenticated = auth && pid == client_pid;
+ }
+ return is_authenticated;
+}
+
+/* Try to authenticate the DRM connection with the supplied magic id */
+bool
+va_drm_authenticate(int fd, uint32_t magic)
+{
+ /* XXX: try to authenticate through Wayland, etc. */
+#ifdef HAVE_VA_X11
+ if (va_drm_authenticate_x11(fd, magic))
+ return true;
+#endif
+
+ /* Default: root + master privs are needed for the following call */
+ return drmAuthMagic(fd, magic) == 0;
+}
diff --git a/va/drm/va_drm_auth.h b/va/drm/va_drm_auth.h
new file mode 100644
index 0000000..1aa6989
--- /dev/null
+++ b/va/drm/va_drm_auth.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_DRM_AUTH_H
+#define VA_DRM_AUTH_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+DLL_HIDDEN
+bool
+va_drm_is_authenticated(int fd);
+
+DLL_HIDDEN
+bool
+va_drm_authenticate(int fd, uint32_t magic);
+
+#endif /* VA_DRM_AUTH_H */
diff --git a/va/drm/va_drm_auth_x11.c b/va/drm/va_drm_auth_x11.c
new file mode 100644
index 0000000..54e7402
--- /dev/null
+++ b/va/drm/va_drm_auth_x11.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#define _GNU_SOURCE 1
+#include "sysdeps.h"
+#include <dlfcn.h>
+#include <X11/Xlib.h>
+#include "va_drm_auth_x11.h"
+
+#define LIBVA_MAJOR_VERSION 1
+
+typedef struct drm_auth_x11 DRMAuthX11;
+typedef struct drm_auth_x11_vtable DRMAuthX11VTable;
+
+typedef void (*VAGenericFunc)(void);
+typedef Display *(*X11OpenDisplayFunc)(const char *display_name);
+typedef int (*X11CloseDisplayFunc)(Display *display);
+typedef Bool (*VADRI2QueryExtensionFunc)(
+ Display *display, int *event_base, int *error_base);
+typedef Bool (*VADRI2QueryVersionFunc)(
+ Display *display, int *major, int *minor);
+typedef Bool (*VADRI2AuthenticateFunc)(
+ Display *display, XID window, uint32_t magic);
+
+struct drm_auth_x11_vtable {
+ X11OpenDisplayFunc x11_open_display;
+ X11CloseDisplayFunc x11_close_display;
+ VADRI2QueryExtensionFunc va_dri2_query_extension;
+ VADRI2QueryVersionFunc va_dri2_query_version;
+ VADRI2AuthenticateFunc va_dri2_authenticate;
+};
+
+struct drm_auth_x11 {
+ void *handle; /* libva-x11.so.1 */
+ DRMAuthX11VTable vtable;
+ Display *display;
+ Window window;
+};
+
+static bool
+get_symbol(void *handle, void *func_vptr, const char *name)
+{
+ VAGenericFunc func, *func_ptr = func_vptr;
+ const char *error;
+
+ dlerror();
+ func = (VAGenericFunc)dlsym(handle, name);
+ error = dlerror();
+
+ if (error) {
+ fprintf(stderr, "error: failed to resolve %s() function: %s\n",
+ name, error);
+ return false;
+ }
+
+ *func_ptr = func;
+ return true;
+}
+
+static bool
+drm_auth_x11_init(DRMAuthX11 *auth)
+{
+ struct drm_auth_x11_vtable *vtable;
+ char libva_x11_name[16];
+ int ret;
+
+ ret = snprintf(
+ libva_x11_name, sizeof(libva_x11_name),
+ "libva-x11.so.%d", LIBVA_MAJOR_VERSION
+ );
+ if (ret < 0 || ret >= sizeof(libva_x11_name))
+ return false;
+
+ auth->handle = dlopen(libva_x11_name, RTLD_LAZY | RTLD_GLOBAL);
+ if (!auth->handle) {
+ perror("open lib");
+ return false;
+ }
+
+ vtable = &auth->vtable;
+ if (!get_symbol(RTLD_DEFAULT, &vtable->x11_open_display, "XOpenDisplay"))
+ return false;
+ if (!get_symbol(RTLD_DEFAULT, &vtable->x11_close_display, "XCloseDisplay"))
+ return false;
+ if (!get_symbol(auth->handle, &vtable->va_dri2_query_extension,
+ "VA_DRI2QueryExtension"))
+ return false;
+ if (!get_symbol(auth->handle, &vtable->va_dri2_query_version,
+ "VA_DRI2QueryVersion"))
+ return false;
+ if (!get_symbol(auth->handle, &vtable->va_dri2_authenticate,
+ "VA_DRI2Authenticate"))
+ return false;
+
+ auth->display = vtable->x11_open_display(NULL);
+ if (!auth->display)
+ return false;
+
+ auth->window = DefaultRootWindow(auth->display);
+ return true;
+}
+
+static void
+drm_auth_x11_terminate(DRMAuthX11 *auth)
+{
+ if (!auth)
+ return;
+
+ if (auth->display) {
+ auth->vtable.x11_close_display(auth->display);
+ auth->display = NULL;
+ auth->window = None;
+ }
+
+ if (auth->handle) {
+ dlclose(auth->handle);
+ auth->handle = NULL;
+ }
+}
+
+static bool
+drm_auth_x11_authenticate(DRMAuthX11 *auth, int fd, uint32_t magic)
+{
+ DRMAuthX11VTable * const vtable = &auth->vtable;
+ int evt_base, err_base, v_major, v_minor;
+
+ if (!vtable->va_dri2_query_extension(auth->display, &evt_base, &err_base))
+ return false;
+ if (!vtable->va_dri2_query_version(auth->display, &v_major, &v_minor))
+ return false;
+ if (!vtable->va_dri2_authenticate(auth->display, auth->window, magic))
+ return false;
+ return true;
+}
+
+/* Try to authenticate the DRM connection with the supplied magic through X11 */
+bool
+va_drm_authenticate_x11(int fd, uint32_t magic)
+{
+ DRMAuthX11 auth;
+ bool success = false;
+
+ memset(&auth, 0, sizeof(auth));
+ if (!drm_auth_x11_init(&auth))
+ goto end;
+ success = drm_auth_x11_authenticate(&auth, fd, magic);
+
+end:
+ drm_auth_x11_terminate(&auth);
+ return success;
+}
diff --git a/va/drm/va_drm_auth_x11.h b/va/drm/va_drm_auth_x11.h
new file mode 100644
index 0000000..530eeed
--- /dev/null
+++ b/va/drm/va_drm_auth_x11.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_DRM_AUTH_X11_H
+#define VA_DRM_AUTH_X11_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
+DLL_HIDDEN
+bool
+va_drm_authenticate_x11(int fd, uint32_t magic);
+
+#endif /* VA_DRM_AUTH_X11_H */
diff --git a/va/drm/va_drm_utils.c b/va/drm/va_drm_utils.c
new file mode 100644
index 0000000..f3ffd6b
--- /dev/null
+++ b/va/drm/va_drm_utils.c
@@ -0,0 +1,79 @@
+/*
+ * va_drm_utils.c - VA/DRM Utilities
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <xf86drm.h>
+#include "va_drm_utils.h"
+#include "va_drmcommon.h"
+
+struct driver_name_map {
+ const char *key;
+ int key_len;
+ const char *name;
+};
+
+static const struct driver_name_map g_driver_name_map[] = {
+ { "i915", 4, "i965" }, // Intel OTC GenX driver
+ { "pvrsrvkm", 8, "pvr" }, // Intel UMG PVR driver
+ { "emgd", 4, "emgd" }, // Intel ECG PVR driver
+ { NULL, }
+};
+
+/* Returns the VA driver name for the active display */
+VAStatus
+VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr)
+{
+ struct drm_state * const drm_state = ctx->drm_state;
+ drmVersionPtr drm_version;
+ char *driver_name = NULL;
+ const struct driver_name_map *m;
+
+ *driver_name_ptr = NULL;
+
+ if (!drm_state || drm_state->fd < 0)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ drm_version = drmGetVersion(drm_state->fd);
+ if (!drm_version)
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ for (m = g_driver_name_map; m->key != NULL; m++) {
+ if (drm_version->name_len >= m->key_len &&
+ strncmp(drm_version->name, m->key, m->key_len) == 0)
+ break;
+ }
+ drmFreeVersion(drm_version);
+
+ if (!m->name)
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ driver_name = strdup(m->name);
+ if (!driver_name)
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+ *driver_name_ptr = driver_name;
+ return VA_STATUS_SUCCESS;
+}
diff --git a/va/drm/va_drm_utils.h b/va/drm/va_drm_utils.h
new file mode 100644
index 0000000..0cb361e
--- /dev/null
+++ b/va/drm/va_drm_utils.h
@@ -0,0 +1,73 @@
+/*
+ * va_drm_utils.h - VA/DRM Utilities
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_DRM_UTILS_H
+#define VA_DRM_UTILS_H
+
+#include <va/va_backend.h>
+
+/**
+ * \file va_drm_utils.h
+ * \brief VA/DRM Utilities
+ *
+ * This file contains VA/DRM utility functions. The API herein defined is
+ * internal to libva. Users include the VA/DRM API itself or VA/Android,
+ * should it be based on DRM.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Returns the VA driver name for the active display.
+ *
+ * This functions returns a newly allocated buffer in @driver_name_ptr that
+ * contains the VA driver name for the active display. Active display means
+ * the display obtained with any of the vaGetDisplay*() functions.
+ *
+ * The VADriverContext.drm_state structure must be valid, i.e. allocated
+ * and containing an open DRM connection descriptor. The DRM connection
+ * does *not* need to be authenticated as it only performs a call to
+ * drmGetVersion().
+ *
+ * @param[in] ctx the pointer to a VADriverContext
+ * @param[out] driver_name_ptr the newly allocated buffer containing
+ * the VA driver name
+ * @return VA_STATUS_SUCCESS if operation is successful, or another
+ * #VAStatus value otherwise.
+ */
+DLL_HIDDEN
+VAStatus
+VA_DRM_GetDriverName(VADriverContextP ctx, char **driver_name_ptr);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DRM_UTILS_H */
diff --git a/va/egl/Makefile.am b/va/egl/Makefile.am
index c02daa7..7f3f954 100644
--- a/va/egl/Makefile.am
+++ b/va/egl/Makefile.am
@@ -20,7 +20,12 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-INCLUDES = -DLINUX -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(EGL_CFLAGS) \
+ $(NULL)
source_c = \
va_egl.c
diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am
index 05cfbce..79d8594 100644
--- a/va/glx/Makefile.am
+++ b/va/glx/Makefile.am
@@ -20,7 +20,14 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-INCLUDES = -DLINUX -I$(top_srcdir) -I$(top_srcdir)/va -I$(top_srcdir)/va/x11
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ -I$(top_srcdir)/va/x11 \
+ $(X11_CFLAGS) \
+ $(GLX_CFLAGS) \
+ $(NULL)
source_c = \
va_glx.c \
diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c
index 1812ef5..e03847e 100644
--- a/va/glx/va_glx.c
+++ b/va/glx/va_glx.c
@@ -98,6 +98,7 @@ VADisplay vaGetDisplayGLX(Display *native_dpy)
if (!pDriverContextGLX)
goto error;
+ pDriverContext->display_type = VA_DISPLAY_GLX;
pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->opaque = pDisplayContextGLX;
diff --git a/va/sysdeps.h b/va/sysdeps.h
index 0752b17..786a4d0 100644
--- a/va/sysdeps.h
+++ b/va/sysdeps.h
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
@@ -39,6 +40,40 @@
# define Bool int
# define True 1
# define False 0
+
+/* Macros generated from configure */
+# define LIBVA_VERSION_S "1.2.0.pre1"
+
+/* Android logging utilities */
+# include <utils/Log.h>
+
+# ifdef ANDROID_ALOG
+# define va_log_error(buffer) do { ALOGE("%s", buffer); } while (0)
+# define va_log_info(buffer) do { ALOGI("%s", buffer); } while (0)
+# elif ANDROID_LOG
+# define va_log_error(buffer) do { LOGE("%s", buffer); } while (0)
+# define va_log_info(buffer) do { LOGI("%s", buffer); } while (0)
+# endif
+#endif
+
+#ifndef va_log_error
+#define va_log_error(buffer) do { \
+ fprintf(stderr, "libva error: %s", buffer); \
+ } while (0)
+#endif
+
+#ifndef va_log_info
+#define va_log_info(buffer) do { \
+ fprintf(stderr, "libva info: %s", buffer); \
+ } while (0)
+#endif
+
+#if defined __GNUC__ && defined HAVE_GNUC_VISIBILITY_ATTRIBUTE
+# define DLL_HIDDEN __attribute__((visibility("hidden")))
+# define DLL_EXPORT __attribute__((visibility("default")))
+#else
+# define DLL_HIDDEN
+# define DLL_EXPORT
#endif
#endif /* SYSDEPS_H */
diff --git a/va/va.c b/va/va.c
index 095032e..deff824 100755
--- a/va/va.c
+++ b/va/va.c
@@ -105,49 +105,79 @@ int vaDisplayIsValid(VADisplay dpy)
void va_errorMessage(const char *msg, ...)
{
+ char buf[512], *dynbuf;
va_list args;
+ int n, len;
- fprintf(stderr, "libva error: ");
va_start(args, msg);
- vfprintf(stderr, msg, args);
+ len = vsnprintf(buf, sizeof(buf), msg, args);
va_end(args);
+
+ if (len >= (int)sizeof(buf)) {
+ dynbuf = malloc(len + 1);
+ if (!dynbuf)
+ return;
+ va_start(args, msg);
+ n = vsnprintf(dynbuf, len + 1, msg, args);
+ va_end(args);
+ if (n == len)
+ va_log_error(dynbuf);
+ free(dynbuf);
+ }
+ else if (len > 0)
+ va_log_error(buf);
}
void va_infoMessage(const char *msg, ...)
{
+ char buf[512], *dynbuf;
va_list args;
+ int n, len;
- fprintf(stderr, "libva: ");
va_start(args, msg);
- vfprintf(stderr, msg, args);
+ len = vsnprintf(buf, sizeof(buf), msg, args);
va_end(args);
+
+ if (len >= (int)sizeof(buf)) {
+ dynbuf = malloc(len + 1);
+ if (!dynbuf)
+ return;
+ va_start(args, msg);
+ n = vsnprintf(dynbuf, len + 1, msg, args);
+ va_end(args);
+ if (n == len)
+ va_log_info(dynbuf);
+ free(dynbuf);
+ }
+ else if (len > 0)
+ va_log_info(buf);
}
-static Bool va_checkVtable(void *ptr, char *function)
+static bool va_checkVtable(void *ptr, char *function)
{
if (!ptr) {
va_errorMessage("No valid vtable entry for va%s\n", function);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static Bool va_checkMaximum(int value, char *variable)
+static bool va_checkMaximum(int value, char *variable)
{
if (!value) {
va_errorMessage("Failed to define max_%s in init\n", variable);
- return False;
+ return false;
}
- return True;
+ return true;
}
-static Bool va_checkString(const char* value, char *variable)
+static bool va_checkString(const char* value, char *variable)
{
if (!value) {
va_errorMessage("Failed to define str_%s in init\n", variable);
- return False;
+ return false;
}
- return True;
+ return true;
}
static inline int
@@ -258,7 +288,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
}
ctx->vtable_vpp = vtable_vpp;
- if (init_func && (VA_STATUS_SUCCESS == vaStatus))
+ if (init_func && VA_STATUS_SUCCESS == vaStatus)
vaStatus = (*init_func)(ctx);
if (VA_STATUS_SUCCESS == vaStatus) {
@@ -276,7 +306,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, CreateConfig);
CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
- //CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
+ CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
CHECK_VTABLE(vaStatus, ctx, CreateContext);
CHECK_VTABLE(vaStatus, ctx, DestroyContext);
diff --git a/va/va.h b/va/va.h
index f050e77..2c4587d 100755
--- a/va/va.h
+++ b/va/va.h
@@ -24,7 +24,7 @@
/*
* Video Acceleration (VA) API Specification
*
- * Rev. 0.32.2
+ * Rev. 0.30
* <jonathan.bian@intel.com>
*
* Revision History:
@@ -61,9 +61,6 @@
* screen relative rather than source video relative.
* rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1
* update VAAPI to 0.32.0
- * rev 0.32.1 (05/04/2011) - Linux VA encoding API extension proposal
- *
- * rev 0.32.2 (07/05/2011 Jonathan Bian/Andrey Yakovenko) - Video Processing interface
*
* Acknowledgements:
* Some concepts borrowed from XvMC and XvImage.
@@ -181,8 +178,10 @@ typedef int VAStatus; /* Return status type from functions */
/** \brief An invalid filter chain was supplied. */
#define VA_STATUS_ERROR_INVALID_FILTER_CHAIN 0x00000021
/** \brief Indicate HW busy (e.g. run multiple encoding simultaneously). */
-#define VA_STATUS_ERROR_HW_BUSY 0x00000022
-#define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
+#define VA_STATUS_ERROR_HW_BUSY 0x00000022
+/** \brief An invalid blend state was supplied. */
+#define VA_STATUS_ERROR_INVALID_BLEND_STATE 0x00000023
+#define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
/* De-interlacing flags for vaPutSurface() */
#define VA_FRAME_PICTURE 0x00000000
@@ -228,7 +227,7 @@ const char *vaErrorStr(VAStatus error_status);
* native window system.
* For X Windows, native_dpy would be from XOpenDisplay()
*/
-typedef void* NativeDisplay; /* window system dependent */
+typedef void* VANativeDisplay; /* window system dependent */
int vaDisplayIsValid(VADisplay dpy);
@@ -274,7 +273,8 @@ VAPrivFunc vaGetLibFunc (
/* Currently defined profiles */
typedef enum
{
- VAProfileNone = -1,
+ /** \brief Profile ID used for video processing. */
+ VAProfileNone = -1,
VAProfileMPEG2Simple = 0,
VAProfileMPEG2Main = 1,
VAProfileMPEG4Simple = 2,
@@ -287,12 +287,11 @@ typedef enum
VAProfileVC1Main = 9,
VAProfileVC1Advanced = 10,
VAProfileH263Baseline = 11,
- VAProfileJPEGBaseline = 12,
- VAProfileH264ConstrainedBaseline = 13,
- VAProfileH264MultiviewHigh = 14,
- VAProfileH264StereoHigh = 15,
- /** \brief Profile ID used for video processing. */
- VAProfileVP8Version0_3 = 17,
+ VAProfileJPEGBaseline = 12,
+ VAProfileH264ConstrainedBaseline = 13,
+ VAProfileH264MultiviewHigh = 14,
+ VAProfileH264StereoHigh = 15,
+ VAProfileVP8Version0_3 = 16,
VAProfileMax
} VAProfile;
@@ -404,7 +403,6 @@ typedef enum
*/
VAConfigAttribEncAutoReference = 17,
/**@}*/
-
VAConfigAttribTypeMax
} VAConfigAttribType;
@@ -423,6 +421,10 @@ typedef struct _VAConfigAttrib {
#define VA_RT_FORMAT_YUV420 0x00000001
#define VA_RT_FORMAT_YUV422 0x00000002
#define VA_RT_FORMAT_YUV444 0x00000004
+#define VA_RT_FORMAT_YUV411 0x00000008
+#define VA_RT_FORMAT_YUV400 0x00000010
+#define VA_RT_FORMAT_RGB16 0x00010000
+#define VA_RT_FORMAT_RGB32 0x00020000
#define VA_RT_FORMAT_PROTECTED 0x80000000
/** @name Attribute values for VAConfigAttribRateControl */
@@ -661,7 +663,7 @@ typedef enum {
* zero and drops the \c VA_SURFACE_ATTRIB_SETTABLE flag.
*/
VASurfaceAttribPixelFormat,
- /** \brief Minimal width in pixels (int, read/write). */
+ /** \brief Minimal width in pixels (int, read-only). */
VASurfaceAttribMinWidth,
/** \brief Maximal width in pixels (int, read-only). */
VASurfaceAttribMaxWidth,
@@ -669,6 +671,10 @@ typedef enum {
VASurfaceAttribMinHeight,
/** \brief Maximal height in pixels (int, read-only). */
VASurfaceAttribMaxHeight,
+ /** \brief Surface memory type expressed in bit fields (int, read/write). */
+ VASurfaceAttribMemoryType,
+ /** \brief External buffer descriptor (pointer, write). */
+ VASurfaceAttribExternalBufferDescriptor,
/** \brief Number of surface attributes. */
VASurfaceAttribCount
} VASurfaceAttribType;
@@ -683,6 +689,65 @@ typedef struct _VASurfaceAttrib {
VAGenericValue value;
} VASurfaceAttrib;
+/**
+ * @name VASurfaceAttribMemoryType values in bit fields.
+ * Bit 0:7 are reserved for generic types, Bit 31:28 are reserved for
+ * Linux DRM, Bit 23:20 are reserved for Android. DRM and Android specific
+ * types are defined in DRM and Android header files.
+ */
+/**@{*/
+/** \brief VA memory type (default) is supported. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_VA 0x00000001
+/** \brief V4L2 buffer memory type is supported. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_V4L2 0x00000002
+/** \brief User pointer memory type is supported. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR 0x00000004
+/**@}*/
+
+/**
+ * \brief VASurfaceAttribExternalBuffers structure for
+ * the VASurfaceAttribExternalBufferDescriptor attribute.
+ */
+typedef struct _VASurfaceAttribExternalBuffers {
+ /** \brief pixel format in fourcc. */
+ unsigned int pixel_format;
+ /** \brief width in pixels. */
+ unsigned int width;
+ /** \brief height in pixels. */
+ unsigned int height;
+ /** \brief total size of the buffer in bytes. */
+ unsigned int data_size;
+ /** \brief number of planes for planar layout */
+ unsigned int num_planes;
+ /** \brief pitch for each plane in bytes */
+ unsigned int pitches[4];
+ /** \brief offset for each plane in bytes */
+ unsigned int offsets[4];
+ /** \brief buffer handles or user pointers */
+ unsigned long *buffers;
+ /** \brief number of elements in the "buffers" array */
+ unsigned int num_buffers;
+ /** \brief flags. See "Surface external buffer descriptor flags". */
+ unsigned int flags;
+ /** \brief reserved for passing private data */
+ void *private_data;
+} VASurfaceAttribExternalBuffers;
+
+/** @name VASurfaceAttribExternalBuffers flags */
+/**@{*/
+/** \brief Enable memory tiling */
+#define VA_SURFACE_EXTBUF_DESC_ENABLE_TILING 0x00000001
+/** \brief Memory is cacheable */
+#define VA_SURFACE_EXTBUF_DESC_CACHED 0x00000002
+/** \brief Memory is non-cacheable */
+#define VA_SURFACE_EXTBUF_DESC_UNCACHED 0x00000004
+/** \brief Memory is write-combined */
+#define VA_SURFACE_EXTBUF_DESC_WC 0x00000008
+/** \brief Memory is protected */
+#define VA_SURFACE_EXTBUF_DESC_PROTECTED 0x80000000
+
+/**@}*/
+
/**
* \brief Get surface attributes for the supplied config.
*
@@ -865,6 +930,14 @@ typedef enum {
VAEncPackedHeaderPicture = 2,
/** \brief Packed slice header. */
VAEncPackedHeaderSlice = 3,
+ /**
+ * \brief Packed raw header.
+ *
+ * Packed raw data header can be used by the client to insert a header
+ * into the bitstream data buffer at the point it is passed, without
+ * any handling or interpretation by the implementation.
+ */
+ VAEncPackedHeaderRawData = 4,
/** \brief Misc packed header. See codec-specific definitions. */
VAEncPackedHeaderMiscMask = 0x80000000,
} VAEncPackedHeaderType;
@@ -1018,6 +1091,7 @@ typedef struct _VAEncPictureParameterBufferJPEG
VABufferID coded_buf;
} VAEncPictureParameterBufferJPEG;
+#include <va/va_dec_jpeg.h>
/****************************
* MPEG-2 data structures
@@ -1383,6 +1457,8 @@ typedef struct _VAPictureParameterBufferVC1
} bits;
unsigned int value;
} transform_fields;
+ unsigned char luma_scale2; /* PICTURE_LAYER::LUMSCALE2 */
+ unsigned char luma_shift2; /* PICTURE_LAYER::LUMSHIFT2 */
} VAPictureParameterBufferVC1;
/* VC-1 Bitplane Buffer
@@ -1581,6 +1657,7 @@ typedef struct _VAEncSliceParameterBuffer
} slice_flags;
} VAEncSliceParameterBuffer;
+
/****************************
* H.263 specific encode data structures
****************************/
@@ -1895,11 +1972,17 @@ VAStatus vaQuerySurfaceError(
((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
-/* a few common FourCCs */
+/*
+ * Pre-defined fourcc codes
+ */
#define VA_FOURCC_NV12 0x3231564E
#define VA_FOURCC_AI44 0x34344149
#define VA_FOURCC_RGBA 0x41424752
+#define VA_FOURCC_RGBX 0x58424752
#define VA_FOURCC_BGRA 0x41524742
+#define VA_FOURCC_BGRX 0x58524742
+#define VA_FOURCC_ARGB 0x42475241
+#define VA_FOURCC_XRGB 0x42475258
#define VA_FOURCC_UYVY 0x59565955
#define VA_FOURCC_YUY2 0x32595559
#define VA_FOURCC_AYUV 0x56555941
@@ -1909,6 +1992,14 @@ VAStatus vaQuerySurfaceError(
#define VA_FOURCC_IYUV 0x56555949
#define VA_FOURCC_YV24 0x34325659
#define VA_FOURCC_YV32 0x32335659
+#define VA_FOURCC_Y800 0x30303859
+#define VA_FOURCC_IMC3 0x33434D49
+#define VA_FOURCC_411P 0x50313134
+#define VA_FOURCC_422H 0x48323234
+#define VA_FOURCC_422V 0x56323234
+#define VA_FOURCC_444P 0x50343434
+#define VA_FOURCC_RGBP 0x50424752
+#define VA_FOURCC_BGRP 0x50524742
/* byte order */
#define VA_LSB_FIRST 1
diff --git a/va/va_android.h b/va/va_android.h
index f59af86..0193fb0 100644
--- a/va/va_android.h
+++ b/va/va_android.h
@@ -1,8 +1,36 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
#ifndef _VA_ANDROID_H_
#define _VA_ANDROID_H_
#include <va/va.h>
+/** \brief Android Gralloc buffer memory type. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_GRALLOC 0x00100000
+/** \brief Android ION buffer memory type. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_ANDROID_ION 0x00200000
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -33,8 +61,8 @@ using namespace android;
*/
VAStatus vaPutSurface (
VADisplay dpy,
- VASurfaceID surface,
- sp<ISurface> draw, /* Android Window/Surface */
+ VASurfaceID surface,
+ sp<ANativeWindow> draw, /* Android Native Window */
short srcx,
short srcy,
unsigned short srcw,
diff --git a/va/va_backend.h b/va/va_backend.h
index c92be53..2d7cfc7 100755
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -30,14 +30,28 @@
#define _VA_BACKEND_H_
#include <va/va.h>
-#ifndef ANDROID
-#include <X11/Xlib.h>
-#endif
#include <linux/videodev2.h>
typedef struct VADriverContext *VADriverContextP;
typedef struct VADisplayContext *VADisplayContextP;
+/** \brief VA display types. */
+enum {
+ /** \brief Mask to major identifier for VA display type. */
+ VA_DISPLAY_MAJOR_MASK = 0xf0,
+
+ /** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */
+ VA_DISPLAY_X11 = 0x10,
+ /** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */
+ VA_DISPLAY_GLX = (VA_DISPLAY_X11 | (1 << 0)),
+ /** \brief VA/Android API is used, through vaGetDisplay() entry-point. */
+ VA_DISPLAY_ANDROID = 0x20,
+ /** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
+ VA_DISPLAY_DRM = 0x30,
+ /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
+ VA_DISPLAY_WAYLAND = 0x40,
+};
+
struct VADriverVTable
{
VAStatus (*vaTerminate) ( VADriverContextP ctx );
@@ -450,8 +464,21 @@ struct VADriverContext
const char *str_vendor;
void *handle; /* dlopen handle */
-
- void *dri_state;
+
+ /**
+ * \brief DRM state.
+ *
+ * This field holds driver specific data for DRM-based
+ * drivers. This structure is allocated from libva with
+ * calloc(). Do not deallocate from within VA driver
+ * implementations.
+ *
+ * All structures shall be derived from struct drm_state. So, for
+ * instance, this field holds a dri_state structure for VA/X11
+ * drivers that use the DRM protocol.
+ */
+ void *drm_state;
+
void *glx; /* opaque for GLX code */
/**
@@ -461,7 +488,19 @@ struct VADriverContext
*/
struct VADriverVTableVPP *vtable_vpp;
- unsigned long reserved[44]; /* reserve for future add-ins, decrease the subscript accordingly */
+ /** \brief VA display type. */
+ unsigned long display_type;
+
+ /**
+ * The VA/Wayland implementation hooks.
+ *
+ * This structure is intended for drivers that implement the
+ * VA/Wayland API. libVA allocates this structure with calloc()
+ * and owns the resulting memory.
+ */
+ struct VADriverVTableWayland *vtable_wayland;
+
+ unsigned long reserved[42]; /* reserve for future add-ins, decrease the subscript accordingly */
};
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
diff --git a/va/va_backend_tpi.h b/va/va_backend_tpi.h
index b96a37e..3385e28 100644
--- a/va/va_backend_tpi.h
+++ b/va/va_backend_tpi.h
@@ -45,6 +45,7 @@ struct VADriverVTableTPI
VASurfaceAttributeTPI *attribute_tpi
);
+
VAStatus (*vaPutSurfaceBuf) (
VADriverContextP ctx,
VASurfaceID surface,
@@ -62,7 +63,7 @@ struct VADriverVTableTPI
unsigned int number_cliprects, /* number of clip rects in the clip list */
unsigned int flags /* de-interlacing flags */
);
-
+
VAStatus (*vaSetTimestampForSurface)(
VADisplay dpy,
VASurfaceID surface,
diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h
index 53f1769..091a072 100644
--- a/va/va_dec_jpeg.h
+++ b/va/va_dec_jpeg.h
@@ -36,12 +36,12 @@
extern "C" {
#endif
-#include <va/va_enc.h>
+#include <va/va.h>
/**
* \defgroup api_dec_jpeg JPEG decoding API
*
- * WIP: this is work-in-progress API subject to change.
+ * This JPEG decoding API supports Baseline profile only.
*
* @{
*/
@@ -52,13 +52,11 @@ extern "C" {
* This structure holds information from the frame header, along with
* definitions from additional segments.
*/
-typedef struct _VAPictureParameterBufferJPEG {
+typedef struct _VAPictureParameterBufferJPEGBaseline {
/** \brief Picture width in pixels. */
unsigned short picture_width;
/** \brief Picture height in pixels. */
unsigned short picture_height;
- /** \brief Sample precision (P). */
- unsigned char sample_precision;
struct {
/** \brief Component identifier (Ci). */
@@ -73,6 +71,9 @@ typedef struct _VAPictureParameterBufferJPEG {
/** \brief Number of components in frame (Nf). */
unsigned char num_components;
+ /** \brief Sample precision (P). */
+ unsigned char sample_precision;
+
/** @name Cropping (JPEG-2000) */
/**@{*/
unsigned char frame_cropping_flag;
@@ -84,7 +85,7 @@ typedef struct _VAPictureParameterBufferJPEG {
/** \brief Rotation (JPEG-2000). See \c VA_ROTATION_xxx. */
unsigned int rotation;
-} VAPictureParameterBufferJPEG;
+} VAPictureParameterBufferJPEGBaseline, VAPictureParameterBufferJPEG;
/**
* \brief Quantization table for JPEG decoding.
@@ -97,16 +98,13 @@ typedef struct _VAPictureParameterBufferJPEG {
* The #load_quantization_table array can be used as a hint to notify
* the VA driver implementation about which table(s) actually changed
* since the last submission of this buffer.
- *
- * WIP: this is work-in-progress API subject to change, and only
- * suitable to Baseline profile.
*/
-typedef struct _VAIQMatrixParameterBufferJPEG {
+typedef struct _VAIQMatrixBufferJPEGBaseline {
/** \brief Specifies which #quantiser_table is valid. */
unsigned char load_quantiser_table[4];
/** \brief Quanziation tables indexed by table identifier (Tqi). */
unsigned char quantiser_table[4][64];
-} VAIQMatrixParameterBufferJPEG;
+} VAIQMatrixBufferJPEGBaseline, VAIQMatrixParameterBufferJPEG;
/**
* \brief Huffman table for JPEG decoding.
@@ -119,11 +117,8 @@ typedef struct _VAIQMatrixParameterBufferJPEG {
* The #load_huffman_table array can be used as a hint to notify the
* VA driver implementation about which table(s) actually changed
* since the last submission of this buffer.
- *
- * WIP: this is work-in-progress API subject to change, and only
- * suitable to Baseline profile.
*/
-typedef struct _VAHuffmanTableParameterBufferJPEG {
+typedef struct _VAHuffmanTableBufferJPEGBaseline {
/** \brief Specifies which #huffman_table is valid. */
unsigned char load_huffman_table[2];
/** \brief Huffman tables indexed by table identifier (Th). */
@@ -141,9 +136,11 @@ typedef struct _VAHuffmanTableParameterBufferJPEG {
unsigned char num_ac_codes[16];
/** \brief Value associated with each Huffman code (Vij). */
unsigned char ac_values[162];
+ /** \brief Padding to 4-byte boundaries. Must be set to zero. */
+ unsigned char pad[2];
/**@}*/
} huffman_table[2];
-} VAHuffmanTableParameterBufferJPEG;
+} VAHuffmanTableBufferJPEGBaseline, VAHuffmanTableParameterBufferJPEG;
/**
* \brief Slice parameter for JPEG decoding.
@@ -152,7 +149,7 @@ typedef struct _VAHuffmanTableParameterBufferJPEG {
* definitions from additional segments. The associated slice data
* buffer holds all entropy coded segments (ECS) in the scan.
*/
-typedef struct _VASliceParameterBufferJPEG {
+typedef struct _VASliceParameterBufferJPEGBaseline {
/** @name Codec-independent Slice Parameter Buffer base. */
/**@{*/
/** \brief Number of bytes in the slice data buffer for this slice. */
@@ -183,7 +180,7 @@ typedef struct _VASliceParameterBufferJPEG {
unsigned short restart_interval;
/** \brief Number of MCUs in a scan. */
unsigned int num_mcus;
-} VASliceParameterBufferJPEG;
+} VASliceParameterBufferJPEGBaseline, VASliceParameterBufferJPEG;
/**@}*/
diff --git a/va/va_dec_vp8.h b/va/va_dec_vp8.h
index 66b866b..db74f4d 100644
--- a/va/va_dec_vp8.h
+++ b/va/va_dec_vp8.h
@@ -43,7 +43,7 @@ extern "C" {
*/
/**
- * \brief VPX Bool Coder Context structure
+ * \brief VPX Bool Coder Context structure
*
* This common structure is defined for potential sharing by other VP formats
*
@@ -84,7 +84,7 @@ typedef struct _VAPictureParameterBufferVP8
union {
struct {
/* same as key_frame in bitstream syntax */
- unsigned int key_frame : 1;
+ unsigned int key_frame : 1;
/* same as version in bitstream syntax */
unsigned int version : 3;
/* same as segmentation_enabled in bitstream syntax */
@@ -94,29 +94,29 @@ typedef struct _VAPictureParameterBufferVP8
/* same as update_segment_feature_data in bitstream syntax */
unsigned int update_segment_feature_data : 1;
/* same as filter_type in bitstream syntax */
- unsigned int filter_type : 1;
+ unsigned int filter_type : 1;
/* same as sharpness_level in bitstream syntax */
- unsigned int sharpness_level : 3;
+ unsigned int sharpness_level : 3;
/* same as loop_filter_adj_enable in bitstream syntax */
- unsigned int loop_filter_adj_enable : 1;
+ unsigned int loop_filter_adj_enable : 1;
/* same as mode_ref_lf_delta_update in bitstream syntax */
- unsigned int mode_ref_lf_delta_update : 1;
+ unsigned int mode_ref_lf_delta_update : 1;
/* same as sign_bias_golden in bitstream syntax */
- unsigned int sign_bias_golden : 1;
+ unsigned int sign_bias_golden : 1;
/* same as sign_bias_alternate in bitstream syntax */
- unsigned int sign_bias_alternate : 1;
+ unsigned int sign_bias_alternate : 1;
/* same as mb_no_coeff_skip in bitstream syntax */
- unsigned int mb_no_coeff_skip : 1;
+ unsigned int mb_no_coeff_skip : 1;
/* see section 11.1 for mb_skip_coeff */
- unsigned int mb_skip_coeff : 1;
+ unsigned int mb_skip_coeff : 1;
/* flag to indicate that loop filter should be disabled */
- unsigned int loop_filter_disable : 1;
+ unsigned int loop_filter_disable : 1;
} bits;
unsigned int value;
} pic_fields;
/*
- * probabilities of the segment_id decoding tree and same as
+ * probabilities of the segment_id decoding tree and same as
* mb_segment_tree_probs in the spec.
*/
unsigned char mb_segment_tree_probs[3];
@@ -137,18 +137,18 @@ typedef struct _VAPictureParameterBufferVP8
/* same as prob_gf in bitstream syntax */
unsigned char prob_gf;
- /*
+ /*
* list of 4 probabilities of the luma intra prediction mode decoding
* tree and same as y_mode_probs in frame header
*/
- unsigned char y_mode_probs[4];
+ unsigned char y_mode_probs[4];
/*
* list of 3 probabilities of the chroma intra prediction mode decoding
* tree and same as uv_mode_probs in frame header
*/
unsigned char uv_mode_probs[3];
- /*
- * updated mv decoding probabilities and same as mv_probs in
+ /*
+ * updated mv decoding probabilities and same as mv_probs in
* frame header
*/
unsigned char mv_probs[2][19];
@@ -169,14 +169,14 @@ typedef struct _VAPictureParameterBufferVP8
/**
* \brief VP8 Coefficient Probability Data Buffer Structure
*
- * Contains the contents of the token probability table, which may be
- * incrementally modified in the frame header. There are four dimensions to
- * the token probability array. The outermost dimension is indexed by the
- * type of plane being decoded; the next dimension is selected by the
- * position of the coefficient being decoded; the third dimension, * roughly
- * speaking, measures the "local complexity" or extent to which nearby
- * coefficients are non-zero; the fourth, and final, dimension of the token
- * probability array is indexed by the position in the token tree structure,
+ * Contains the contents of the token probability table, which may be
+ * incrementally modified in the frame header. There are four dimensions to
+ * the token probability array. The outermost dimension is indexed by the
+ * type of plane being decoded; the next dimension is selected by the
+ * position of the coefficient being decoded; the third dimension, * roughly
+ * speaking, measures the "local complexity" or extent to which nearby
+ * coefficients are non-zero; the fourth, and final, dimension of the token
+ * probability array is indexed by the position in the token tree structure,
* as are all tree probability arrays. This structure is sent once per frame.
*
*/
@@ -189,12 +189,12 @@ typedef struct _VAProbabilityDataBufferVP8
* \brief VP8 Inverse Quantization Matrix Buffer Structure
*
* Contains quantization indices for yac(0),ydc(1),y2dc(2),y2ac(3),uvdc(4),
- * uvac(5) for each segment (0-3). When segmentation is disabled, only
+ * uvac(5) for each segment (0-3). When segmentation is disabled, only
* quantization_index[0][] will be used. This structure is sent once per frame.
*/
typedef struct _VAIQMatrixBufferVP8
{
- /*
+ /*
* array first dimensional is segment and 2nd dimensional is Q index
*/
unsigned short quantization_index[4][6];
diff --git a/va/va_drmcommon.h b/va/va_drmcommon.h
new file mode 100644
index 0000000..76820a3
--- /dev/null
+++ b/va/va_drmcommon.h
@@ -0,0 +1,76 @@
+/*
+ * va_drmcommon.h - Common utilities for DRM-based drivers
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_DRM_COMMON_H
+#define VA_DRM_COMMON_H
+
+/** \brief DRM authentication type. */
+enum {
+ /** \brief Disconnected. */
+ VA_DRM_AUTH_NONE = 0,
+ /**
+ * \brief Connected. Authenticated with DRI1 protocol.
+ *
+ * @deprecated
+ * This is a deprecated authentication type. All DRI-based drivers have
+ * been migrated to use the DRI2 protocol. Newly written drivers shall
+ * use DRI2 protocol only, or a custom authentication means. e.g. opt
+ * for authenticating on the VA driver side, instead of libva side.
+ */
+ VA_DRM_AUTH_DRI1 = 1,
+ /**
+ * \brief Connected. Authenticated with DRI2 protocol.
+ *
+ * This is only useful to VA/X11 drivers. The libva-x11 library provides
+ * a helper function VA_DRI2Authenticate() for authenticating the
+ * connection. However, DRI2 conformant drivers don't need to call that
+ * function since authentication happens on the libva side, implicitly.
+ */
+ VA_DRM_AUTH_DRI2 = 2,
+ /**
+ * \brief Connected. Authenticated with some alternate raw protocol.
+ *
+ * This authentication mode is mainly used in non-VA/X11 drivers.
+ * Authentication happens through some alternative method, at the
+ * discretion of the VA driver implementation.
+ */
+ VA_DRM_AUTH_CUSTOM = 3
+};
+
+/** \brief Base DRM state. */
+struct drm_state {
+ /** \brief DRM connection descriptor. */
+ int fd;
+ /** \brief DRM authentication type. */
+ int auth_type;
+};
+
+/** \brief Kernel DRM buffer memory type. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM 0x10000000
+/** \brief DRM PRIME memory type. */
+#define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
+
+#endif /* VA_DRM_COMMON_H */
diff --git a/va/va_enc.h b/va/va_enc.h
index becd980..d98b741 100644
--- a/va/va_enc.h
+++ b/va/va_enc.h
@@ -47,6 +47,27 @@ extern "C" {
/** \brief Abstract representation of a bitstream writer. */
typedef struct _VAEncBitstream VAEncBitstream;
+/**
+ * @name Picture flags
+ *
+ * Those flags flags are meant to signal when a picture marks the end
+ * of a sequence, a stream, or even both at once.
+ *
+ * @{
+ */
+/**
+ * \brief Marks the last picture in the sequence.
+ *
+ */
+#define VA_ENC_LAST_PICTURE_EOSEQ 0x01
+/**
+ * \brief Marks the last picture in the stream.
+ *
+ */
+#define VA_ENC_LAST_PICTURE_EOSTREAM 0x02
+/**@}*/
+
+
/** @name The set of all possible error codes */
/**@{*/
/** \brief An invalid bitstream writer handle was supplied. */
diff --git a/va/va_enc_h264.h b/va/va_enc_h264.h
index 6da3f01..43aac42 100644
--- a/va/va_enc_h264.h
+++ b/va/va_enc_h264.h
@@ -57,13 +57,13 @@ extern "C" {
*
* i.e. the driver appends \c end_of_seq() NAL unit to the encoded frame.
*/
-#define H264_LAST_PICTURE_EOSEQ 0x01
+#define H264_LAST_PICTURE_EOSEQ VA_ENC_LAST_PICTURE_EOSEQ
/**
* \brief Marks the last picture in the stream.
*
* i.e. the driver appends \c end_of_stream() NAL unit to the encoded frame.
*/
-#define H264_LAST_PICTURE_EOSTREAM 0x02
+#define H264_LAST_PICTURE_EOSTREAM VA_ENC_LAST_PICTURE_EOSTREAM
/**@}*/
/**
@@ -123,7 +123,8 @@ typedef enum {
} VAEncPackedHeaderTypeH264;
/**
- * \brief Sequence parameter for H.264 encoding in main & high profiles.
+ * \brief Sequence parameter for H.264 encoding in baseline, main & high
+ * profiles.
*
* This structure holds information for \c seq_parameter_set_data() as
* defined by the H.264 specification.
@@ -259,7 +260,8 @@ typedef struct _VAEncSequenceParameterBufferH264 {
} VAEncSequenceParameterBufferH264;
/**
- * \brief Picture parameter for H.264 encoding in main & high profiles.
+ * \brief Picture parameter for H.264 encoding in baseline, main & high
+ * profiles.
*
* This structure holds information for \c pic_parameter_set_rbsp() as
* defined by the H.264 specification.
@@ -369,7 +371,7 @@ typedef struct _VAEncPictureParameterBufferH264 {
} VAEncPictureParameterBufferH264;
/**
- * \brief Slice parameter for H.264 encoding in main & high profiles.
+ * \brief Slice parameter for H.264 encoding in baseline, main & high profiles.
*
* This structure holds information for \c
* slice_layer_without_partitioning_rbsp() as defined by the H.264
@@ -524,7 +526,8 @@ typedef struct _VAEncSliceParameterBufferH264 {
/**@}*/
/**
- * \brief Macroblock parameter for H.264 encoding in main & high profiles.
+ * \brief Macroblock parameter for H.264 encoding in baseline, main & high
+ * profiles.
*
* This structure holds per-macroblock information. The buffer must be
* allocated with as many elements (macroblocks) as necessary to fit
diff --git a/va/va_enc_mpeg2.h b/va/va_enc_mpeg2.h
new file mode 100644
index 0000000..bb119e4
--- /dev/null
+++ b/va/va_enc_mpeg2.h
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file va_enc_mpeg2.h
+ * \brief The MPEG-2 encoding API
+ *
+ * This file contains the \ref api_enc_mpeg2 "MPEG-2 encoding API".
+ */
+
+#ifndef _VA_ENC_MPEG2_H_
+#define _VA_ENC_MPEG2_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <va/va_enc.h>
+
+/**
+ * \defgroup api_enc_mpeg2 MPEG-2 encoding API
+ *
+ * @{
+ */
+
+#define MPEG2_LAST_PICTURE_EOSTREAM VA_ENC_LAST_PICTURE_EOSTREAM
+
+/**
+ * \brief MPEG-2 Quantization Matrix Buffer
+ *
+ */
+typedef VAIQMatrixBufferMPEG2 VAQMatrixBufferMPEG2;
+
+/**
+ * \brief Packed header types specific to MPEG-2 encoding.
+ *
+ * Types of packed headers generally used for MPEG-2 encoding.
+ */
+typedef enum {
+ /**
+ * \brief Packed Sequence Parameter Set (SPS).
+ *
+ */
+ VAEncPackedHeaderMPEG2_SPS = VAEncPackedHeaderSequence,
+ /**
+ * \brief Packed Picture Parameter Set (PPS).
+ *
+ */
+ VAEncPackedHeaderMPEG2_PPS = VAEncPackedHeaderPicture,
+ /**
+ * \brief Packed slice header.
+ *
+ */
+ VAEncPackedHeaderMPEG2_Slice = VAEncPackedHeaderSlice,
+} VAEncPackedHeaderTypeMPEG2;
+
+/**
+ * \brief Sequence parameter for MPEG-2 encoding
+ *
+ * This structure holds information for \c sequence_header() and
+ * sequence_extension().
+ *
+ * If packed sequence headers mode is used, i.e. if the encoding
+ * pipeline was configured with the #VA_ENC_PACKED_HEADER_SEQUENCE
+ * flag, then the driver expects two more buffers to be provided to
+ * the same \c vaRenderPicture() as this buffer:
+ * - a #VAEncPackedHeaderParameterBuffer with type set to
+ * VAEncPackedHeaderType::VAEncPackedHeaderSequence ;
+ * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
+ * header data.
+ *
+ */
+typedef struct _VAEncSequenceParameterBufferMPEG2 {
+ /** \brief Period between I frames. */
+ unsigned int intra_period;
+ /** \brief Period between I/P frames. */
+ unsigned int ip_period;
+ /** \brief Picture width.
+ *
+ * A 14bits unsigned inter, the lower 12bits
+ * is horizontal_size_value, and the upper
+ * 2bits is \c horizontal_size_extension
+ *
+ */
+ unsigned short picture_width;
+ /** \brief Picture height.
+ *
+ * A 14bits unsigned inter, the lower 12bits
+ * is vertical_size_value, and the upper 2bits is
+ * vertical_size_size_extension
+ *
+ */
+ unsigned short picture_height;
+ /**
+ * \brief Initial bitrate set for this sequence in CBR or VBR modes.
+ *
+ * This field represents the initial bitrate value for this
+ * sequence if CBR or VBR mode is used, i.e. if the encoder
+ * pipeline was created with a #VAConfigAttribRateControl
+ * attribute set to either \ref VA_RC_CBR or \ref VA_RC_VBR.
+ *
+ * bits_per_second may be derived from bit_rate.
+ *
+ */
+ unsigned int bits_per_second;
+ /**
+ * \brief Frame rate
+ *
+ * Derived from frame_rate_value, frame_rate_extension_n and
+ * frame_rate_extension_d
+ *
+ */
+ float frame_rate;
+ /** \brief Same as the element in sequence_header() */
+ unsigned short aspect_ratio_information;
+ /** \brief Define the size of VBV */
+ unsigned int vbv_buffer_size;
+
+ union {
+ struct {
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int profile_and_level_indication : 8;
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int progressive_sequence : 1;
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int chroma_format : 2;
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int low_delay : 1;
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int frame_rate_extension_n : 2;
+ /** \brief Same as the element in Sequence extension() */
+ unsigned int frame_rate_extension_d : 5;
+ } bits;
+ unsigned int value;
+ } sequence_extension;
+
+ /** \brief Flag to indicate the following GOP header are being updated */
+ unsigned int new_gop_header;
+
+ union {
+ struct {
+ /** \brief Time code */
+ unsigned int time_code : 25;
+ /** \brief Same as the element in GOP header */
+ unsigned int closed_gop : 1;
+ /** \brief SAme as the element in GOP header */
+ unsigned int broken_link : 1;
+ } bits;
+ unsigned int value;
+ } gop_header;
+} VAEncSequenceParameterBufferMPEG2;
+
+/**
+ * \brief Picture parameter for MPEG-2 encoding
+ *
+ * This structure holds information for picture_header() and
+ * picture_coding_extension()
+ *
+ * If packed picture headers mode is used, i.e. if the encoding
+ * pipeline was configured with the #VA_ENC_PACKED_HEADER_PICTURE
+ * flag, then the driver expects two more buffers to be provided to
+ * the same \c vaRenderPicture() as this buffer:
+ * - a #VAEncPackedHeaderParameterBuffer with type set to
+ * VAEncPackedHeaderType::VAEncPackedHeaderPicture ;
+ * - a #VAEncPackedHeaderDataBuffer which holds the actual packed
+ * header data.
+ *
+ */
+typedef struct _VAEncPictureParameterBufferMPEG2 {
+ /** \brief Forward reference picture */
+ VASurfaceID forward_reference_picture;
+ /** \brief Backward reference picture */
+ VASurfaceID backward_reference_picture;
+ /** \brief Reconstructed(decoded) picture */
+ VASurfaceID reconstructed_picture;
+ /**
+ * \brief Output encoded bitstream.
+ *
+ * \ref coded_buf has type #VAEncCodedBufferType. It should be
+ * large enough to hold the compressed NAL slice and possibly SPS
+ * and PPS NAL units.
+ */
+ VABufferID coded_buf;
+ /**
+ * \brief Flag to indicate the picture is the last one or not.
+ *
+ * This fields holds 0 if the picture to be encoded is not
+ * the last one in the stream. Otherwise, it
+ * is \ref MPEG2_LAST_PICTURE_EOSTREAM.
+ */
+ unsigned char last_picture;
+ /** \brief Picture type */
+ VAEncPictureType picture_type;
+ /** \brief Same as the element in picture_header() */
+ unsigned int temporal_reference;
+ /** \brief Same as the element in picture_header() */
+ unsigned int vbv_delay;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned char f_code[2][2];
+ union {
+ struct {
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int intra_dc_precision : 2;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int picture_structure : 2;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int top_field_first : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int frame_pred_frame_dct : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int concealment_motion_vectors : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int q_scale_type : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int intra_vlc_format : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int alternate_scan : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int repeat_first_field : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int progressive_frame : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int composite_display_flag : 1;
+ } bits;
+ unsigned int value;
+ } picture_coding_extension;
+
+ /* \brief Parameters for composite display
+ *
+ * Valid only when omposite_display_flag is 1
+ */
+ union {
+ struct {
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int v_axis : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int field_sequence : 3;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int sub_carrier : 1;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int burst_amplitude : 7;
+ /** \brief Same as the element in Picture coding extension */
+ unsigned int sub_carrier_phase : 8;
+ } bits;
+ unsigned int value;
+ } composite_display;
+
+ /** \brief The length of user data
+ *
+ * Append user data after picture coding extension
+ * if user_data_length isn't 0.
+ *
+ */
+ unsigned int user_data_length;
+ /** \brief User data */
+ unsigned char user_data[16];
+} VAEncPictureParameterBufferMPEG2;
+
+/**
+ * \brief Slice parameter for MPEG-2 encoding
+ *
+ */
+typedef struct _VAEncSliceParameterBufferMPEG2 {
+ /** \brief Starting MB address for this slice. */
+ unsigned int macroblock_address;
+ /** \brief Number of macroblocks in this slice. */
+ unsigned int num_macroblocks;
+ /** \brief Same as the element in slice() */
+ int quantiser_scale_code;
+ /** \brief Flag to indicate intra slice */
+ int is_intra_slice;
+} VAEncSliceParameterBufferMPEG2;
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VA_ENC_MPEG2_H_ */
diff --git a/va/va_enc_vp8.h b/va/va_enc_vp8.h
index 51b2c4b..80011d2 100644
--- a/va/va_enc_vp8.h
+++ b/va/va_enc_vp8.h
@@ -50,8 +50,6 @@ extern "C" {
*/
typedef struct _VAEncSequenceParameterBufferVP8
{
- /* profile */
- unsigned int profile;
/* frame width in pixels */
unsigned int frame_width;
/* frame height in pixels */
@@ -60,8 +58,6 @@ typedef struct _VAEncSequenceParameterBufferVP8
unsigned int frame_rate;
/* whether to enable error resilience features */
unsigned int error_resilient;
- /* number of token partitions */
- unsigned int num_token_partitions;
/* auto keyframe placement, non-zero means enable auto keyframe placement */
unsigned int kf_auto;
/* keyframe minimum interval */
@@ -69,9 +65,6 @@ typedef struct _VAEncSequenceParameterBufferVP8
/* keyframe maximum interval */
unsigned int kf_max_dist;
- /* quality setting, equivalent to VP8E_SET_CPUUSED */
- unsigned int quality_setting;
-
/* RC related fields. RC modes are set with VAConfigAttribRateControl */
/* For VP8, CBR implies HRD conformance and VBR implies no HRD conformance */
@@ -92,6 +85,9 @@ typedef struct _VAEncSequenceParameterBufferVP8
/* HRD buffer optimal fullness */
unsigned int hrd_buf_optimal_fullness;
+ /* reference and reconstructed frame buffers*/
+ VASurfaceID reference_frames[4];
+
} VAEncSequenceParameterBufferVP8;
/**
@@ -102,16 +98,12 @@ typedef struct _VAEncSequenceParameterBufferVP8
*/
typedef struct _VAEncPictureParameterBufferVP8
{
- /* specifies the "last" reference frame */
- VASurfaceID last_ref_frame;
- /* specifies the "golden" reference frame */
- VASurfaceID golden_ref_frame;
- /* specifies the "alternate" referrence frame */
- VASurfaceID alt_ref_frame;
/* surface to store reconstructed frame */
VASurfaceID reconstructed_frame;
/* buffer to store coded data */
VABufferID coded_buf;
+ /* equivalent to VP8E_SET_CPUUSED */
+ unsigned int cpu_used;
union {
struct {
@@ -123,6 +115,15 @@ typedef struct _VAEncPictureParameterBufferVP8
unsigned int no_ref_gf : 1;
/* don't reference the alternate reference frame */
unsigned int no_ref_arf : 1;
+ /* 0: bicubic, 1: bilinear, other: none */
+ unsigned int recon_filter_type :2;
+ /* only invalid if recon_filter_type set to bilinear.
+ * 0: no loop fitler, 1: simple loop filter */
+ unsigned int loop_filter_type :1;
+ /* 1: enable, 0: disabled */
+ unsigned int auto_partitions :1;
+ /* number of token partitions */
+ unsigned int num_token_partitions :2;
} bits;
unsigned int value;
} pic_flags;
diff --git a/va/va_trace.c b/va/va_trace.c
index 8c2c684..11fd78d 100755
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -352,7 +352,7 @@ void va_TraceCodedBuf(VADisplay dpy)
void va_TraceSurface(VADisplay dpy)
{
- unsigned int i;
+ unsigned int i, j;
unsigned int fourcc; /* following are output argument */
unsigned int luma_stride;
unsigned int chroma_u_stride;
@@ -364,6 +364,7 @@ void va_TraceSurface(VADisplay dpy)
void *buffer = NULL;
unsigned char *Y_data, *UV_data, *tmp;
VAStatus va_status;
+ unsigned char check_sum = 0;
DPY2INDEX(dpy);
va_TraceMsg(idx, "==========dump surface data in file %s\n", trace_context[idx].trace_surface_fn);
@@ -601,11 +602,20 @@ static char * buffer_type_to_string(int type)
case VAResidualDataBufferType: return "VAResidualDataBufferType";
case VADeblockingParameterBufferType: return "VADeblockingParameterBufferType";
case VAImageBufferType: return "VAImageBufferType";
+ case VAQMatrixBufferType: return "VAQMatrixBufferType";
+ case VAHuffmanTableBufferType: return "VAHuffmanTableBufferType";
+ case VAProbabilityBufferType: return "VAProbabilityBufferType";
+/* Following are encode buffer types */
case VAEncCodedBufferType: return "VAEncCodedBufferType";
case VAEncSequenceParameterBufferType: return "VAEncSequenceParameterBufferType";
case VAEncPictureParameterBufferType: return "VAEncPictureParameterBufferType";
case VAEncSliceParameterBufferType: return "VAEncSliceParameterBufferType";
+ case VAEncPackedHeaderParameterBufferType: return "VAEncPackedHeaderParameterBufferType";
+ case VAEncPackedHeaderDataBufferType: return "VAEncPackedHeaderDataBufferType";
case VAEncMiscParameterBufferType: return "VAEncMiscParameterBufferType";
+ case VAEncMacroblockParameterBufferType: return "VAEncMacroblockParameterBufferType";
+ case VAProcPipelineParameterBufferType: return "VAProcPipelineParameterBufferType";
+ case VAProcFilterParameterBufferType: return "VAProcFilterParameterBufferType";
default: return "UnknowBuffer";
}
}
@@ -1179,6 +1189,8 @@ static void va_TraceVAIQMatrixBufferH264(
va_TraceMsg(idx, NULL);
}
+
+
static void va_TraceVAEncSequenceParameterBufferH264(
VADisplay dpy,
VAContextID context,
@@ -1190,7 +1202,7 @@ static void va_TraceVAEncSequenceParameterBufferH264(
{
VAEncSequenceParameterBufferH264 *p = (VAEncSequenceParameterBufferH264 *)data;
DPY2INDEX(dpy);
- unsigned int i;
+ int i;
va_TraceMsg(idx, "VAEncSequenceParameterBufferH264\n");
@@ -2244,6 +2256,7 @@ void va_TraceEndPicture(
va_TraceMsg(idx, NULL);
}
+
void va_TraceSyncSurface(
VADisplay dpy,
VASurfaceID render_target
diff --git a/va/va_trace.h b/va/va_trace.h
index 269bd75..6803c28 100755
--- a/va/va_trace.h
+++ b/va/va_trace.h
@@ -48,12 +48,12 @@ extern int trace_flag;
trace_func(__VA_ARGS__); \
}
#define VA_TRACE_LOG(trace_func,...) \
- if (trace_flag & VA_TRACE_FLAG_LOG) { \
+ if (trace_flag & VA_TRACE_FLAG_LOG) { \
trace_func(__VA_ARGS__); \
}
#define VA_TRACE_SURFACE(trace_func,...) \
- if (trace_flag & (VA_TRACE_FLAG_LOG | VA_TRACE_FLAG_SURFACE | VA_TRACE_FLAG_CODEDBUF)) { \
- trace_func(__VA_ARGS__); \
+ if (trace_flag & (VA_TRACE_FLAG_SURFACE | VA_TRACE_FLAG_CODEDBUF)) { \
+ trace_func(__VA_ARGS__); \
}
void va_TraceInit(VADisplay dpy);
diff --git a/va/va_vpp.h b/va/va_vpp.h
index fab634b..cb8d1da 100644
--- a/va/va_vpp.h
+++ b/va/va_vpp.h
@@ -236,27 +236,25 @@ extern "C" {
/** \brief Video filter types. */
typedef enum _VAProcFilterType {
- VAProcFilterNone = 0,
- /** \brief Dering filter. */
- VAProcFilterDering = 1,
- /** \brief De-blocking filter. */
- VAProcFilterDeblocking = 2,
+ VAProcFilterNone = 0,
/** \brief Noise reduction filter. */
- VAProcFilterNoiseReduction = 3,
+ VAProcFilterNoiseReduction,
+ /** \brief Deblocking filter. */
+ VAProcFilterDeblocking,
/** \brief Deinterlacing filter. */
- VAProcFilterDeinterlacing = 4,
+ VAProcFilterDeinterlacing,
/** \brief Sharpening filter. */
- VAProcFilterSharpening = 5,
+ VAProcFilterSharpening,
/** \brief Color balance parameters. */
- VAProcFilterColorBalance = 6,
+ VAProcFilterColorBalance,
/** \brief Color standard conversion. */
- VAProcFilterColorStandard = 7,
+ VAProcFilterColorStandard,
+ /** \brief Frame rate conversion. */
+ VAProcFilterFrameRateConversion,
+ VAProcFilterColorEnhancement,
+ VAProcFilterProcAmp,
+ VAProcFilterComposition,
/** \brief Number of video filters. */
- VAProcFilterColorEnhancement = 8,
- VAProcFilterProcAmp = 9,
- VAProcFilterComposition = 10,
- /** \brief Frame rate convert filter. */
- VAProcFilterFrameRateConversion = 11,
VAProcFilterCount
} VAProcFilterType;
@@ -317,6 +315,45 @@ typedef enum _VAProcColorStandardType {
VAProcColorStandardCount
} VAProcColorStandardType;
+/** @name Video blending flags */
+/**@{*/
+/** \brief Global alpha blending. */
+#define VA_BLEND_GLOBAL_ALPHA 0x0002
+/** \brief Premultiplied alpha blending (RGBA surfaces only). */
+#define VA_BLEND_PREMULTIPLIED_ALPHA 0x0008
+/** \brief Luma color key (YUV surfaces only). */
+#define VA_BLEND_LUMA_KEY 0x0010
+/**@}*/
+
+/** \brief Video blending state definition. */
+typedef struct _VABlendState {
+ /** \brief Video blending flags. */
+ unsigned int flags;
+ /**
+ * \brief Global alpha value.
+ *
+ * Valid if \flags has VA_BLEND_GLOBAL_ALPHA.
+ * Valid range is 0.0 to 1.0 inclusive.
+ */
+ float global_alpha;
+ /**
+ * \brief Minimum luma value.
+ *
+ * Valid if \flags has VA_BLEND_LUMA_KEY.
+ * Valid range is 0.0 to 1.0 inclusive.
+ * \ref min_luma shall be set to a sensible value lower than \ref max_luma.
+ */
+ float min_luma;
+ /**
+ * \brief Maximum luma value.
+ *
+ * Valid if \flags has VA_BLEND_LUMA_KEY.
+ * Valid range is 0.0 to 1.0 inclusive.
+ * \ref max_luma shall be set to a sensible value larger than \ref min_luma.
+ */
+ float max_luma;
+} VABlendState;
+
/** @name Video pipeline flags */
/**@{*/
/** \brief Specifies whether to apply subpictures when processing a surface. */
@@ -343,7 +380,7 @@ typedef enum _VAProcColorStandardType {
/** @name Pipeline end flags */
/**@{*/
/** \brief Specifies the pipeline is the last. */
-#define VA_PIPELINE_FLAG_END 0x00000004
+#define VA_PIPELINE_FLAG_END 0x00000004
/**@}*/
/** \brief Video processing pipeline capabilities. */
@@ -352,6 +389,18 @@ typedef struct _VAProcPipelineCaps {
unsigned int pipeline_flags;
/** \brief Extra filter flags. See VAProcPipelineParameterBuffer::filter_flags. */
unsigned int filter_flags;
+ /** \brief Number of forward reference frames that are needed. */
+ unsigned int num_forward_references;
+ /** \brief Number of backward reference frames that are needed. */
+ unsigned int num_backward_references;
+ /** \brief List of color standards supported on input. */
+ VAProcColorStandardType *input_color_standards;
+ /** \brief Number of elements in \ref input_color_standards array. */
+ unsigned int num_input_color_standards;
+ /** \brief List of color standards supported on output. */
+ VAProcColorStandardType *output_color_standards;
+ /** \brief Number of elements in \ref output_color_standards array. */
+ unsigned int num_output_color_standards;
/**
* \brief Rotation flags.
*
@@ -378,18 +427,8 @@ typedef struct _VAProcPipelineCaps {
* \endcode
*/
unsigned int rotation_flags;
- /** \brief Number of forward reference frames that are needed. */
- unsigned int num_forward_references;
- /** \brief Number of backward reference frames that are needed. */
- unsigned int num_backward_references;
- /** \brief List of color standards supported on input. */
- VAProcColorStandardType *input_color_standards;
- /** \brief Number of elements in \ref input_color_standards array. */
- unsigned int num_input_color_standards;
- /** \brief List of color standards supported on output. */
- VAProcColorStandardType *output_color_standards;
- /** \brief Number of elements in \ref output_color_standards array. */
- unsigned int num_output_color_standards;
+ /** \brief Blend flags. See "Video blending flags". */
+ unsigned int blend_flags;
} VAProcPipelineCaps;
/** \brief Specification of values supported by the filter. */
@@ -492,31 +531,6 @@ typedef struct _VAProcPipelineParameterBuffer {
*/
VAProcColorStandardType output_color_standard;
/**
- * \brief Rotation state. See rotation angles.
- *
- * The rotation angle is clockwise. There is no specific rotation
- * center for this operation. Rather, The source \ref surface is
- * first rotated by the specified angle and then scaled to fit the
- * \ref output_region.
- *
- * This means that the top-left hand corner (0,0) of the output
- * (rotated) surface is expressed as follows:
- * - \ref VA_ROTATION_NONE: (0,0) is the top left corner of the
- * source surface -- no rotation is performed ;
- * - \ref VA_ROTATION_90: (0,0) is the bottom-left corner of the
- * source surface ;
- * - \ref VA_ROTATION_180: (0,0) is the bottom-right corner of the
- * source surface -- the surface is flipped around the X axis ;
- * - \ref VA_ROTATION_270: (0,0) is the top-right corner of the
- * source surface.
- *
- * Check VAProcPipelineCaps::rotation_flags first prior to
- * defining a specific rotation angle. Otherwise, the hardware can
- * perfectly ignore this variable if it does not support any
- * rotation.
- */
- unsigned int rotation_state;
- /**
* \brief Pipeline filters. See video pipeline flags.
*
* Flags to control the pipeline, like whether to apply subpictures
@@ -569,6 +583,50 @@ typedef struct _VAProcPipelineParameterBuffer {
VASurfaceID *backward_references;
/** \brief Number of backward reference frames that were supplied. */
unsigned int num_backward_references;
+ /**
+ * \brief Rotation state. See rotation angles.
+ *
+ * The rotation angle is clockwise. There is no specific rotation
+ * center for this operation. Rather, The source \ref surface is
+ * first rotated by the specified angle and then scaled to fit the
+ * \ref output_region.
+ *
+ * This means that the top-left hand corner (0,0) of the output
+ * (rotated) surface is expressed as follows:
+ * - \ref VA_ROTATION_NONE: (0,0) is the top left corner of the
+ * source surface -- no rotation is performed ;
+ * - \ref VA_ROTATION_90: (0,0) is the bottom-left corner of the
+ * source surface ;
+ * - \ref VA_ROTATION_180: (0,0) is the bottom-right corner of the
+ * source surface -- the surface is flipped around the X axis ;
+ * - \ref VA_ROTATION_270: (0,0) is the top-right corner of the
+ * source surface.
+ *
+ * Check VAProcPipelineCaps::rotation_flags first prior to
+ * defining a specific rotation angle. Otherwise, the hardware can
+ * perfectly ignore this variable if it does not support any
+ * rotation.
+ */
+ unsigned int rotation_state;
+ /**
+ * \brief blending state. See "Video blending state definition".
+ *
+ * If \ref blend_state is NULL, then default operation mode depends
+ * on the source \ref surface format:
+ * - RGB: per-pixel alpha blending ;
+ * - YUV: no blending, i.e override the underlying pixels.
+ *
+ * Otherwise, \ref blend_state is a pointer to a #VABlendState
+ * structure that shall be live until vaEndPicture().
+ *
+ * Implementation note: the driver is responsible for checking the
+ * blend state flags against the actual source \ref surface format.
+ * e.g. premultiplied alpha blending is only applicable to RGB
+ * surfaces, and luma keying is only applicable to YUV surfaces.
+ * If a mismatch occurs, then #VA_STATUS_ERROR_INVALID_BLEND_STATE
+ * is returned.
+ */
+ const VABlendState *blend_state;
} VAProcPipelineParameterBuffer;
/**
@@ -596,12 +654,28 @@ typedef struct _VAProcFilterParameterBuffer {
float value;
} VAProcFilterParameterBuffer;
+/** @name De-interlacing flags */
+/**@{*/
+/**
+ * \brief Bottom field first in the input frame.
+ * if this is not set then assums top field first.
+ */
+#define VA_DEINTERLACING_INPUT_BOTTOM_FIELD_FIRST 0x0001
+/**
+ * \brief Bottom field used in BOB deinterlacing.
+ * if this is not set then assums top field is used.
+ */
+#define VA_DEINTERLACING_BOB_BOTTOM_FIELD 0x0002
+/**@}*/
+
/** \brief Deinterlacing filter parametrization. */
typedef struct _VAProcFilterParameterBufferDeinterlacing {
/** \brief Filter type. Shall be set to #VAProcFilterDeinterlacing. */
VAProcFilterType type;
/** \brief Deinterlacing algorithm. */
VAProcDeinterlacingType algorithm;
+ /** \brief Deinterlacing flags. */
+ unsigned int flags;
} VAProcFilterParameterBufferDeinterlacing;
/**
diff --git a/va/va_x11.h b/va/va_x11.h
index c6f9670..c9be38d 100644
--- a/va/va_x11.h
+++ b/va/va_x11.h
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
#ifndef _VA_X11_H_
#define _VA_X11_H_
diff --git a/va/wayland/Makefile.am b/va/wayland/Makefile.am
new file mode 100644
index 0000000..a9f9546
--- /dev/null
+++ b/va/wayland/Makefile.am
@@ -0,0 +1,66 @@
+# Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+SUBDIRS = protocol
+
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(WAYLAND_CFLAGS) \
+ $(DRM_CFLAGS) \
+ $(NULL)
+
+source_c = \
+ va_wayland.c \
+ va_wayland_drm.c \
+ va_wayland_emgd.c \
+ $(top_srcdir)/va/drm/va_drm_utils.c \
+ $(NULL)
+
+source_h = \
+ va_backend_wayland.h \
+ va_wayland.h \
+ $(NULL)
+
+source_h_priv = \
+ va_wayland_drm.h \
+ va_wayland_emgd.h \
+ va_wayland_private.h \
+ $(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) $(protocol_source_h)
+noinst_HEADERS = $(source_h_priv)
+
+# Wayland protocol
+va_wayland_drm.c: $(protocol_source_h)
+@wayland_scanner_rules@
+
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/va/wayland/protocol/Makefile.am b/va/wayland/protocol/Makefile.am
new file mode 100644
index 0000000..614d8a4
--- /dev/null
+++ b/va/wayland/protocol/Makefile.am
@@ -0,0 +1,28 @@
+# Copyright (C) 2012 Intel Corporation. All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+EXTRA_DIST = \
+ wayland-drm.xml \
+ $(NULL)
+
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/va/wayland/protocol/wayland-drm.xml b/va/wayland/protocol/wayland-drm.xml
new file mode 100644
index 0000000..265d4f8
--- /dev/null
+++ b/va/wayland/protocol/wayland-drm.xml
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="drm">
+
+ <copyright>
+ Copyright © 2008-2011 Kristian Høgsberg
+ Copyright © 2010-2011 Intel Corporation
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that\n the above copyright notice appear in
+ all copies and that both that copyright notice and this permission
+ notice appear in supporting documentation, and that the name of
+ the copyright holders not be used in advertising or publicity
+ pertaining to distribution of the software without specific,
+ written prior permission. The copyright holders make no
+ representations about the suitability of this software for any
+ purpose. It is provided "as is" without express or implied
+ warranty.
+
+ THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ THIS SOFTWARE.
+ </copyright>
+
+ <!-- drm support. This object is created by the server and published
+ using the display's global event. -->
+ <interface name="wl_drm" version="1">
+ <enum name="error">
+ <entry name="authenticate_fail" value="0"/>
+ <entry name="invalid_format" value="1"/>
+ <entry name="invalid_name" value="2"/>
+ </enum>
+
+ <enum name="format">
+ <!-- The drm format codes match the #defines in drm_fourcc.h.
+ The formats actually supported by the compositor will be
+ reported by the format event. -->
+ <entry name="c8" value="0x20203843"/>
+ <entry name="rgb332" value="0x38424752"/>
+ <entry name="bgr233" value="0x38524742"/>
+ <entry name="xrgb4444" value="0x32315258"/>
+ <entry name="xbgr4444" value="0x32314258"/>
+ <entry name="rgbx4444" value="0x32315852"/>
+ <entry name="bgrx4444" value="0x32315842"/>
+ <entry name="argb4444" value="0x32315241"/>
+ <entry name="abgr4444" value="0x32314241"/>
+ <entry name="rgba4444" value="0x32314152"/>
+ <entry name="bgra4444" value="0x32314142"/>
+ <entry name="xrgb1555" value="0x35315258"/>
+ <entry name="xbgr1555" value="0x35314258"/>
+ <entry name="rgbx5551" value="0x35315852"/>
+ <entry name="bgrx5551" value="0x35315842"/>
+ <entry name="argb1555" value="0x35315241"/>
+ <entry name="abgr1555" value="0x35314241"/>
+ <entry name="rgba5551" value="0x35314152"/>
+ <entry name="bgra5551" value="0x35314142"/>
+ <entry name="rgb565" value="0x36314752"/>
+ <entry name="bgr565" value="0x36314742"/>
+ <entry name="rgb888" value="0x34324752"/>
+ <entry name="bgr888" value="0x34324742"/>
+ <entry name="xrgb8888" value="0x34325258"/>
+ <entry name="xbgr8888" value="0x34324258"/>
+ <entry name="rgbx8888" value="0x34325852"/>
+ <entry name="bgrx8888" value="0x34325842"/>
+ <entry name="argb8888" value="0x34325241"/>
+ <entry name="abgr8888" value="0x34324241"/>
+ <entry name="rgba8888" value="0x34324152"/>
+ <entry name="bgra8888" value="0x34324142"/>
+ <entry name="xrgb2101010" value="0x30335258"/>
+ <entry name="xbgr2101010" value="0x30334258"/>
+ <entry name="rgbx1010102" value="0x30335852"/>
+ <entry name="bgrx1010102" value="0x30335842"/>
+ <entry name="argb2101010" value="0x30335241"/>
+ <entry name="abgr2101010" value="0x30334241"/>
+ <entry name="rgba1010102" value="0x30334152"/>
+ <entry name="bgra1010102" value="0x30334142"/>
+ <entry name="yuyv" value="0x56595559"/>
+ <entry name="yvyu" value="0x55595659"/>
+ <entry name="uyvy" value="0x59565955"/>
+ <entry name="vyuy" value="0x59555956"/>
+ <entry name="ayuv" value="0x56555941"/>
+ <entry name="nv12" value="0x3231564e"/>
+ <entry name="nv21" value="0x3132564e"/>
+ <entry name="nv16" value="0x3631564e"/>
+ <entry name="nv61" value="0x3136564e"/>
+ <entry name="yuv410" value="0x39565559"/>
+ <entry name="yvu410" value="0x39555659"/>
+ <entry name="yuv411" value="0x31315559"/>
+ <entry name="yvu411" value="0x31315659"/>
+ <entry name="yuv420" value="0x32315559"/>
+ <entry name="yvu420" value="0x32315659"/>
+ <entry name="yuv422" value="0x36315559"/>
+ <entry name="yvu422" value="0x36315659"/>
+ <entry name="yuv444" value="0x34325559"/>
+ <entry name="yvu444" value="0x34325659"/>
+ </enum>
+
+ <!-- Call this request with the magic received from drmGetMagic().
+ It will be passed on to the drmAuthMagic() or
+ DRIAuthConnection() call. This authentication must be
+ completed before create_buffer could be used. -->
+ <request name="authenticate">
+ <arg name="id" type="uint"/>
+ </request>
+
+ <!-- Create a wayland buffer for the named DRM buffer. The DRM
+ surface must have a name using the flink ioctl -->
+ <request name="create_buffer">
+ <arg name="id" type="new_id" interface="wl_buffer"/>
+ <arg name="name" type="uint"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="stride" type="uint"/>
+ <arg name="format" type="uint"/>
+ </request>
+
+ <!-- Create a wayland buffer for the named DRM buffer. The DRM
+ surface must have a name using the flink ioctl -->
+ <request name="create_planar_buffer">
+ <arg name="id" type="new_id" interface="wl_buffer"/>
+ <arg name="name" type="uint"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ <arg name="format" type="uint"/>
+ <arg name="offset0" type="int"/>
+ <arg name="stride0" type="int"/>
+ <arg name="offset1" type="int"/>
+ <arg name="stride1" type="int"/>
+ <arg name="offset2" type="int"/>
+ <arg name="stride2" type="int"/>
+ </request>
+
+ <!-- Notification of the path of the drm device which is used by
+ the server. The client should use this device for creating
+ local buffers. Only buffers created from this device should
+ be be passed to the server using this drm object's
+ create_buffer request. -->
+ <event name="device">
+ <arg name="name" type="string"/>
+ </event>
+
+ <event name="format">
+ <arg name="format" type="uint"/>
+ </event>
+
+ <!-- Raised if the authenticate request succeeded -->
+ <event name="authenticated"/>
+ </interface>
+
+</protocol>
diff --git a/va/wayland/va_backend_wayland.h b/va/wayland/va_backend_wayland.h
new file mode 100644
index 0000000..b33e3a1
--- /dev/null
+++ b/va/wayland/va_backend_wayland.h
@@ -0,0 +1,65 @@
+/*
+ * va_backend_wayland.h - VA driver implementation hooks for Wayland
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_BACKEND_WAYLAND_H
+#define VA_BACKEND_WAYLAND_H
+
+#include <va/va.h>
+#include <wayland-client.h>
+
+/** \brief VA/Wayland API version. */
+#define VA_WAYLAND_API_VERSION (0x574c4400) /* WLD0 */
+
+/* Forward declarations */
+struct VADriverContext;
+
+/** \brief VA/Wayland implementation hooks. */
+struct VADriverVTableWayland {
+ /**
+ * \brief Interface version.
+ *
+ * Implementations shall set this field to \ref VA_WAYLAND_API_VERSION.
+ */
+ unsigned int version;
+
+ /** \brief Hook to return Wayland buffer associated with the VA surface. */
+ VAStatus (*vaGetSurfaceBufferWl)(
+ struct VADriverContext *ctx,
+ VASurfaceID surface,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+ );
+
+ /** \brief Hook to return Wayland buffer associated with the VA image. */
+ VAStatus (*vaGetImageBufferWl)(
+ struct VADriverContext *ctx,
+ VAImageID image,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+ );
+};
+
+#endif /* VA_BACKEND_WAYLAND_H */
diff --git a/va/wayland/va_wayland.c b/va/wayland/va_wayland.c
new file mode 100644
index 0000000..88a841f
--- /dev/null
+++ b/va/wayland/va_wayland.c
@@ -0,0 +1,194 @@
+/*
+ * va_wayland.c - Wayland API
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <stdarg.h>
+#include "va_wayland.h"
+#include "va_wayland_drm.h"
+#include "va_wayland_emgd.h"
+#include "va_wayland_private.h"
+#include "va_backend.h"
+#include "va_backend_wayland.h"
+
+static inline VADriverContextP
+get_driver_context(VADisplay dpy)
+{
+ if (!vaDisplayIsValid(dpy))
+ return NULL;
+ return ((VADisplayContextP)dpy)->pDriverContext;
+}
+
+void
+va_wayland_error(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ fprintf(stderr, "VA error: wayland: ");
+ vfprintf(stderr, format, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+}
+
+static int
+va_DisplayContextIsValid(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const pDriverContext = pDisplayContext->pDriverContext;
+
+ return (pDriverContext &&
+ pDriverContext->display_type == VA_DISPLAY_WAYLAND);
+}
+
+static void
+va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP pDriverContext;
+ VADisplayContextWaylandP pDisplayContextWl;
+
+ if (!pDisplayContext)
+ return;
+
+ pDisplayContextWl = pDisplayContext->opaque;
+ if (pDisplayContextWl && pDisplayContextWl->destroy)
+ pDisplayContextWl->destroy(pDisplayContext);
+
+ pDriverContext = pDisplayContext->pDriverContext;
+ if (pDriverContext) {
+ free(pDriverContext->vtable_wayland);
+ pDriverContext->vtable_wayland = NULL;
+ free(pDriverContext);
+ pDisplayContext->pDriverContext = NULL;
+ }
+
+ free(pDisplayContext->opaque);
+ pDisplayContext->opaque = NULL;
+ free(pDisplayContext);
+}
+
+static VAStatus
+va_DisplayContextGetDriverName(VADisplayContextP pDisplayContext, char **name)
+{
+ *name = NULL;
+ return VA_STATUS_ERROR_UNKNOWN;
+}
+
+/* -------------------------------------------------------------------------- */
+/* --- Public interface --- */
+/* -------------------------------------------------------------------------- */
+
+struct va_wayland_backend {
+ VADisplayContextCreateFunc create;
+ VADisplayContextDestroyFunc destroy;
+};
+
+static const struct va_wayland_backend g_backends[] = {
+ { va_wayland_drm_create,
+ va_wayland_drm_destroy },
+ { va_wayland_emgd_create,
+ va_wayland_emgd_destroy },
+ { NULL, }
+};
+
+VADisplay
+vaGetDisplayWl(struct wl_display *display)
+{
+ VADisplayContextP pDisplayContext = NULL;
+ VADriverContextP pDriverContext;
+ struct VADriverVTableWayland *vtable;
+ unsigned int i;
+
+ pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+ if (!pDisplayContext)
+ return NULL;
+
+ pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
+ pDisplayContext->vaIsValid = va_DisplayContextIsValid;
+ pDisplayContext->vaDestroy = va_DisplayContextDestroy;
+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+
+ pDriverContext = calloc(1, sizeof(*pDriverContext));
+ if (!pDriverContext)
+ goto error;
+ pDisplayContext->pDriverContext = pDriverContext;
+
+ pDriverContext->native_dpy = display;
+ pDriverContext->display_type = VA_DISPLAY_WAYLAND;
+
+ vtable = calloc(1, sizeof(*vtable));
+ if (!vtable)
+ goto error;
+ pDriverContext->vtable_wayland = vtable;
+
+ vtable->version = VA_WAYLAND_API_VERSION;
+
+ for (i = 0; g_backends[i].create != NULL; i++) {
+ if (g_backends[i].create(pDisplayContext))
+ break;
+ g_backends[i].destroy(pDisplayContext);
+ }
+
+ return (VADisplay)pDisplayContext;
+
+error:
+ va_DisplayContextDestroy(pDisplayContext);
+ return NULL;
+}
+
+VAStatus
+vaGetSurfaceBufferWl(
+ VADisplay dpy,
+ VASurfaceID surface,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+)
+{
+ VADriverContextP const ctx = get_driver_context(dpy);
+
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+ if (!ctx->vtable_wayland || !ctx->vtable_wayland->vaGetSurfaceBufferWl)
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+ return ctx->vtable_wayland->vaGetSurfaceBufferWl(ctx, surface, flags,
+ out_buffer);
+}
+
+VAStatus
+vaGetImageBufferWl(
+ VADisplay dpy,
+ VAImageID image,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+)
+{
+ VADriverContextP const ctx = get_driver_context(dpy);
+
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+ if (!ctx->vtable_wayland || !ctx->vtable_wayland->vaGetImageBufferWl)
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+ return ctx->vtable_wayland->vaGetImageBufferWl(ctx, image, flags,
+ out_buffer);
+}
diff --git a/va/wayland/va_wayland.h b/va/wayland/va_wayland.h
new file mode 100644
index 0000000..46fbf2c
--- /dev/null
+++ b/va/wayland/va_wayland.h
@@ -0,0 +1,131 @@
+/*
+ * va_wayland.h - Wayland API
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_WAYLAND_H
+#define VA_WAYLAND_H
+
+#include <va/va.h>
+#include <wayland-client.h>
+
+/**
+ * \file va_wayland.h
+ * \brief The Wayland rendering API
+ *
+ * This file contains the \ref api_wayland "Wayland rendering API".
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup api_wayland Wayland rendering API
+ *
+ * @{
+ *
+ * Theory of operations:
+ * - Create a VA display for an active Wayland display ;
+ * - Perform normal VA-API operations, e.g. decode to a VA surface ;
+ * - Get wl_buffer associated to the VA surface ;
+ * - Attach wl_buffer to wl_surface ;
+ */
+
+/**
+ * \brief Returns a VA display wrapping the specified Wayland display.
+ *
+ * This functions returns a (possibly cached) VA display from the
+ * specified Wayland @display.
+ *
+ * @param[in] display the native Wayland display
+ * @return the VA display
+ */
+VADisplay
+vaGetDisplayWl(struct wl_display *display);
+
+/**
+ * \brief Returns the Wayland buffer associated with a VA surface.
+ *
+ * This function returns a wl_buffer handle that can be used as an
+ * argument to wl_surface_attach(). This buffer references the
+ * underlying VA @surface. As such, the VA @surface and Wayland
+ * @out_buffer have the same size and color format. Should specific
+ * color conversion be needed, then VA/VPP API can fulfill this
+ * purpose.
+ *
+ * The @flags describe the desired picture structure. This is useful
+ * to expose a de-interlaced buffer. If the VA driver does not support
+ * any of the supplied flags, then #VA_STATUS_ERROR_FLAG_NOT_SUPPORTED
+ * is returned. The following flags are allowed: \c VA_FRAME_PICTURE,
+ * \c VA_TOP_FIELD, \c VA_BOTTOM_FIELD.
+ *
+ * @param[in] dpy the VA display
+ * @param[in] surface the VA surface
+ * @param[in] flags the deinterlacing flags
+ * @param[out] out_buffer a wl_buffer wrapping the VA @surface
+ * @return VA_STATUS_SUCCESS if successful
+ */
+VAStatus
+vaGetSurfaceBufferWl(
+ VADisplay dpy,
+ VASurfaceID surface,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+);
+
+/**
+ * \brief Returns the Wayland buffer associated with a VA image.
+ *
+ * This function returns a wl_buffer handle that can be used as an
+ * argument to wl_surface_attach(). This buffer references the
+ * underlying VA @image. As such, the VA @image and Wayland
+ * @out_buffer have the same size and color format. Should specific
+ * color conversion be needed, then VA/VPP API can fulfill this
+ * purpose.
+ *
+ * The @flags describe the desired picture structure. See
+ * vaGetSurfaceBufferWl() description for more details.
+ *
+ * @param[in] dpy the VA display
+ * @param[in] image the VA image
+ * @param[in] flags the deinterlacing flags
+ * @param[out] out_buffer a wl_buffer wrapping the VA @image
+ * @return VA_STATUS_SUCCESS if successful
+ */
+VAStatus
+vaGetImageBufferWl(
+ VADisplay dpy,
+ VAImageID image,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
+);
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_WAYLAND_H */
diff --git a/va/wayland/va_wayland_drm.c b/va/wayland/va_wayland_drm.c
new file mode 100644
index 0000000..d292316
--- /dev/null
+++ b/va/wayland/va_wayland_drm.c
@@ -0,0 +1,223 @@
+/*
+ * va_wayland_drm.c - Wayland/DRM helpers
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <sys/stat.h>
+#include <xf86drm.h>
+#include "va_drmcommon.h"
+#include "drm/va_drm_utils.h"
+#include "va_wayland_drm.h"
+#include "va_wayland_private.h"
+#include "wayland-drm-client-protocol.h"
+
+/* XXX: Wayland/DRM support currently lives in Mesa libEGL.so.* library */
+#define LIBWAYLAND_DRM_NAME "libEGL.so.1"
+
+typedef struct va_wayland_drm_context {
+ struct va_wayland_context base;
+ void *handle;
+ struct wl_drm *drm;
+ struct wl_registry *registry;
+ void *drm_interface;
+ unsigned int is_authenticated : 1;
+} VADisplayContextWaylandDRM;
+
+static void
+drm_handle_device(void *data, struct wl_drm *drm, const char *device)
+{
+ VADisplayContextP const pDisplayContext = data;
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ VADisplayContextWaylandDRM * const wl_drm_ctx = pDisplayContext->opaque;
+ struct drm_state * const drm_state = ctx->drm_state;
+ drm_magic_t magic;
+ struct stat st;
+
+ if (stat(device, &st) < 0) {
+ va_wayland_error("failed to identify %s: %s (errno %d)",
+ device, strerror(errno), errno);
+ return;
+ }
+
+ if (!S_ISCHR(st.st_mode)) {
+ va_wayland_error("%s is not a device", device);
+ return;
+ }
+
+ drm_state->fd = open(device, O_RDWR);
+ if (drm_state->fd < 0) {
+ va_wayland_error("failed to open %s: %s (errno %d)",
+ device, strerror(errno), errno);
+ return;
+ }
+
+ drmGetMagic(drm_state->fd, &magic);
+ wl_drm_authenticate(wl_drm_ctx->drm, magic);
+}
+
+static void
+drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
+{
+}
+
+static void
+drm_handle_authenticated(void *data, struct wl_drm *drm)
+{
+ VADisplayContextP const pDisplayContext = data;
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ VADisplayContextWaylandDRM * const wl_drm_ctx = pDisplayContext->opaque;
+ struct drm_state * const drm_state = ctx->drm_state;
+
+ wl_drm_ctx->is_authenticated = 1;
+ drm_state->auth_type = VA_DRM_AUTH_CUSTOM;
+}
+
+static const struct wl_drm_listener drm_listener = {
+ drm_handle_device,
+ drm_handle_format,
+ drm_handle_authenticated
+};
+
+static VAStatus
+va_DisplayContextGetDriverName(
+ VADisplayContextP pDisplayContext,
+ char **driver_name_ptr
+)
+{
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+
+ return VA_DRM_GetDriverName(ctx, driver_name_ptr);
+}
+
+void
+va_wayland_drm_destroy(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ struct va_wayland_drm_context * const wl_drm_ctx = pDisplayContext->opaque;
+ struct drm_state * const drm_state = ctx->drm_state;
+
+ if (wl_drm_ctx->drm) {
+ wl_drm_destroy(wl_drm_ctx->drm);
+ wl_drm_ctx->drm = NULL;
+ }
+ wl_drm_ctx->is_authenticated = 0;
+
+ 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);
+ drm_state->fd = -1;
+ }
+ free(ctx->drm_state);
+ ctx->drm_state = NULL;
+ }
+}
+
+static void
+registry_handle_global(
+ void *data,
+ struct wl_registry *registry,
+ uint32_t id,
+ const char *interface,
+ uint32_t version
+)
+{
+ struct va_wayland_drm_context *wl_drm_ctx = data;
+
+ if (strcmp(interface, "wl_drm") == 0) {
+ wl_drm_ctx->drm =
+ wl_registry_bind(wl_drm_ctx->registry, id, wl_drm_ctx->drm_interface, 1);
+ }
+}
+
+static const struct wl_registry_listener registry_listener = {
+ registry_handle_global,
+ NULL,
+};
+
+bool
+va_wayland_drm_create(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ struct va_wayland_drm_context *wl_drm_ctx;
+ struct drm_state *drm_state;
+ uint32_t id;
+
+ wl_drm_ctx = malloc(sizeof(*wl_drm_ctx));
+ if (!wl_drm_ctx)
+ return false;
+ wl_drm_ctx->base.destroy = va_wayland_drm_destroy;
+ wl_drm_ctx->handle = NULL;
+ wl_drm_ctx->drm = NULL;
+ wl_drm_ctx->drm_interface = 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)
+ return false;
+ drm_state->fd = -1;
+ drm_state->auth_type = 0;
+ ctx->drm_state = drm_state;
+
+ wl_drm_ctx->handle = dlopen(LIBWAYLAND_DRM_NAME, 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)
+ return false;
+
+ wl_drm_ctx->registry = wl_display_get_registry(ctx->native_dpy);
+ wl_registry_add_listener(wl_drm_ctx->registry, &registry_listener, wl_drm_ctx);
+ wl_display_roundtrip(ctx->native_dpy);
+
+ /* registry_handle_global should have been called by the
+ * wl_display_roundtrip above
+ */
+
+ 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)
+ return false;
+
+ wl_display_roundtrip(ctx->native_dpy);
+ if (!wl_drm_ctx->is_authenticated)
+ return false;
+ return true;
+}
diff --git a/va/wayland/va_wayland_drm.h b/va/wayland/va_wayland_drm.h
new file mode 100644
index 0000000..6fb8f52
--- /dev/null
+++ b/va/wayland/va_wayland_drm.h
@@ -0,0 +1,52 @@
+/*
+ * va_wayland_drm.h - Wayland/DRM helpers
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_WAYLAND_DRM_H
+#define VA_WAYLAND_DRM_H
+
+#include <stdbool.h>
+#include "va_wayland.h"
+#include "va_backend.h"
+#include "va_backend_wayland.h"
+
+/**
+ * \brief Initializes Wayland/DRM layer.
+ *
+ * This is an internal function used to initialize the VA/DRM subsystem
+ * if the application is running on a DRM-based server.
+ *
+ * @param[in] pDisplayContext the VA display context
+ * @return true if successful
+ */
+DLL_HIDDEN
+bool
+va_wayland_drm_create(VADisplayContextP pDisplayContext);
+
+DLL_HIDDEN
+void
+va_wayland_drm_destroy(VADisplayContextP pDisplayContext);
+
+#endif /* VA_WAYLAND_DRM_H */
diff --git a/va/wayland/va_wayland_emgd.c b/va/wayland/va_wayland_emgd.c
new file mode 100644
index 0000000..cb885d1
--- /dev/null
+++ b/va/wayland/va_wayland_emgd.c
@@ -0,0 +1,157 @@
+/*
+ * va_wayland_emgd.c - Wayland/EMGD helpers
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "sysdeps.h"
+#include <unistd.h>
+#include <dlfcn.h>
+#include "va_drmcommon.h"
+#include "va_wayland_emgd.h"
+#include "va_wayland_private.h"
+
+/* XXX: Wayland/EMGD support currently lives in libwayland-emgd.so.* library */
+#define LIBWAYLAND_EMGD_NAME "libwayland-emgd.so.1"
+
+typedef struct va_wayland_emgd_context {
+ struct va_wayland_context base;
+ void *handle;
+ struct wl_emgd *emgd;
+ void *emgd_interface;
+ unsigned int is_created : 1;
+ struct wl_registry *registry;
+} VADisplayContextWaylandEMGD;
+
+static inline void
+wl_emgd_destroy(struct wl_emgd *emgd)
+{
+ wl_proxy_destroy((struct wl_proxy *)emgd);
+}
+
+static VAStatus
+va_DisplayContextGetDriverName(
+ VADisplayContextP pDisplayContext,
+ char **driver_name_ptr
+)
+{
+ *driver_name_ptr = strdup("emgd");
+ return VA_STATUS_SUCCESS;
+}
+
+void
+va_wayland_emgd_destroy(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ VADisplayContextWaylandEMGD * const wl_emgd_ctx = pDisplayContext->opaque;
+ struct drm_state * const drm_state = ctx->drm_state;
+
+ if (wl_emgd_ctx->emgd) {
+ wl_emgd_destroy(wl_emgd_ctx->emgd);
+ wl_emgd_ctx->emgd = NULL;
+ }
+ wl_emgd_ctx->is_created = 0;
+
+ if (wl_emgd_ctx->handle) {
+ dlclose(wl_emgd_ctx->handle);
+ wl_emgd_ctx->handle = NULL;
+ }
+
+ if (drm_state) {
+ if (drm_state->fd >= 0) {
+ close(drm_state->fd);
+ drm_state->fd = -1;
+ }
+ free(ctx->drm_state);
+ ctx->drm_state = NULL;
+ }
+}
+
+static void
+registry_handle_global(
+ void *data,
+ struct wl_registry *registry,
+ uint32_t id,
+ const char *interface,
+ uint32_t version
+)
+{
+ VADisplayContextWaylandEMGD *wl_emgd_ctx = data;
+
+ if (strcmp(interface, "wl_emgd") == 0) {
+ wl_emgd_ctx->emgd =
+ wl_registry_bind(registry, id, wl_emgd_ctx->emgd_interface, 1);
+ }
+}
+
+static const struct wl_registry_listener registry_listener = {
+ registry_handle_global,
+ NULL,
+};
+
+bool
+va_wayland_emgd_create(VADisplayContextP pDisplayContext)
+{
+ VADriverContextP const ctx = pDisplayContext->pDriverContext;
+ VADisplayContextWaylandEMGD *wl_emgd_ctx;
+ struct drm_state *drm_state;
+ uint32_t id;
+
+ wl_emgd_ctx = malloc(sizeof(*wl_emgd_ctx));
+ if (!wl_emgd_ctx)
+ return false;
+ wl_emgd_ctx->base.destroy = va_wayland_emgd_destroy;
+ wl_emgd_ctx->handle = NULL;
+ wl_emgd_ctx->emgd = NULL;
+ wl_emgd_ctx->emgd_interface = NULL;
+ wl_emgd_ctx->is_created = 0;
+ pDisplayContext->opaque = wl_emgd_ctx;
+ pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+
+ drm_state = calloc(1, sizeof(struct drm_state));
+ if (!drm_state)
+ return false;
+ drm_state->fd = -1;
+ drm_state->auth_type = 0;
+ ctx->drm_state = drm_state;
+
+ wl_emgd_ctx->handle = dlopen(LIBWAYLAND_EMGD_NAME, RTLD_LAZY|RTLD_LOCAL);
+ if (!wl_emgd_ctx->handle)
+ return false;
+
+ wl_emgd_ctx->emgd_interface =
+ dlsym(wl_emgd_ctx->handle, "wl_emgd_interface");
+ if (!wl_emgd_ctx->emgd_interface)
+ return false;
+
+ wl_emgd_ctx->registry = wl_display_get_registry(ctx->native_dpy);
+ wl_registry_add_listener(wl_emgd_ctx->registry, &registry_listener, wl_emgd_ctx);
+ wl_display_roundtrip(ctx->native_dpy);
+
+ /* registry_handle_global should have been called by the
+ * wl_display_roundtrip above
+ */
+ if (!wl_emgd_ctx->emgd)
+ return false;
+ return true;
+}
diff --git a/va/wayland/va_wayland_emgd.h b/va/wayland/va_wayland_emgd.h
new file mode 100644
index 0000000..053b6b4
--- /dev/null
+++ b/va/wayland/va_wayland_emgd.h
@@ -0,0 +1,52 @@
+/*
+ * va_wayland_emgd.h - Wayland/EMGD helpers
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_WAYLAND_EMGD_H
+#define VA_WAYLAND_EMGD_H
+
+#include <stdbool.h>
+#include "va_wayland.h"
+#include "va_backend.h"
+#include "va_backend_wayland.h"
+
+/**
+ * \brief Initializes Wayland/EMGD layer.
+ *
+ * This is an internal function used to initialize the VA/EMGD subsystem
+ * if the application is running on an EMGD-based server.
+ *
+ * @param[in] pDisplayContext the VA display context
+ * @return true if successful
+ */
+DLL_HIDDEN
+bool
+va_wayland_emgd_create(VADisplayContextP pDisplayContext);
+
+DLL_HIDDEN
+void
+va_wayland_emgd_destroy(VADisplayContextP pDisplayContext);
+
+#endif /* VA_WAYLAND_EMGD_H */
diff --git a/va/wayland/va_wayland_private.h b/va/wayland/va_wayland_private.h
new file mode 100644
index 0000000..f09f4b7
--- /dev/null
+++ b/va/wayland/va_wayland_private.h
@@ -0,0 +1,44 @@
+/*
+ * va_wayland_private.h - Wayland private API
+ *
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef VA_WAYLAND_PRIVATE_H
+#define VA_WAYLAND_PRIVATE_H
+
+struct va_wayland_context;
+
+typedef bool (*VADisplayContextCreateFunc)(VADisplayContextP pDisplayContext);
+typedef void (*VADisplayContextDestroyFunc)(VADisplayContextP pDisplayContext);
+
+/* VA/Wayland base display context */
+typedef struct va_wayland_context {
+ VADisplayContextDestroyFunc destroy;
+} VADisplayContextWayland, *VADisplayContextWaylandP;
+
+DLL_HIDDEN
+void
+va_wayland_error(const char *format, ...);
+
+#endif /* VA_WAYLAND_PRIVATE_H */
diff --git a/va/wayland/wayland-drm-client-protocol.h b/va/wayland/wayland-drm-client-protocol.h
new file mode 100644
index 0000000..cba188e
--- /dev/null
+++ b/va/wayland/wayland-drm-client-protocol.h
@@ -0,0 +1,213 @@
+/*
+ * Copyright © 2008-2011 Kristian Høgsberg
+ * Copyright © 2010-2011 Intel Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this
+ * software and its documentation for any purpose is hereby granted
+ * without fee, provided that\n the above copyright notice appear in
+ * all copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of
+ * the copyright holders not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+
+#ifndef DRM_CLIENT_PROTOCOL_H
+#define DRM_CLIENT_PROTOCOL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stddef.h>
+#include "wayland-client.h"
+
+struct wl_client;
+struct wl_resource;
+
+struct wl_drm;
+
+extern const struct wl_interface wl_drm_interface;
+
+#ifndef WL_DRM_ERROR_ENUM
+#define WL_DRM_ERROR_ENUM
+enum wl_drm_error {
+ WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
+ WL_DRM_ERROR_INVALID_FORMAT = 1,
+ WL_DRM_ERROR_INVALID_NAME = 2,
+};
+#endif /* WL_DRM_ERROR_ENUM */
+
+#ifndef WL_DRM_FORMAT_ENUM
+#define WL_DRM_FORMAT_ENUM
+enum wl_drm_format {
+ WL_DRM_FORMAT_C8 = 0x20203843,
+ WL_DRM_FORMAT_RGB332 = 0x38424752,
+ WL_DRM_FORMAT_BGR233 = 0x38524742,
+ WL_DRM_FORMAT_XRGB4444 = 0x32315258,
+ WL_DRM_FORMAT_XBGR4444 = 0x32314258,
+ WL_DRM_FORMAT_RGBX4444 = 0x32315852,
+ WL_DRM_FORMAT_BGRX4444 = 0x32315842,
+ WL_DRM_FORMAT_ARGB4444 = 0x32315241,
+ WL_DRM_FORMAT_ABGR4444 = 0x32314241,
+ WL_DRM_FORMAT_RGBA4444 = 0x32314152,
+ WL_DRM_FORMAT_BGRA4444 = 0x32314142,
+ WL_DRM_FORMAT_XRGB1555 = 0x35315258,
+ WL_DRM_FORMAT_XBGR1555 = 0x35314258,
+ WL_DRM_FORMAT_RGBX5551 = 0x35315852,
+ WL_DRM_FORMAT_BGRX5551 = 0x35315842,
+ WL_DRM_FORMAT_ARGB1555 = 0x35315241,
+ WL_DRM_FORMAT_ABGR1555 = 0x35314241,
+ WL_DRM_FORMAT_RGBA5551 = 0x35314152,
+ WL_DRM_FORMAT_BGRA5551 = 0x35314142,
+ WL_DRM_FORMAT_RGB565 = 0x36314752,
+ WL_DRM_FORMAT_BGR565 = 0x36314742,
+ WL_DRM_FORMAT_RGB888 = 0x34324752,
+ WL_DRM_FORMAT_BGR888 = 0x34324742,
+ WL_DRM_FORMAT_XRGB8888 = 0x34325258,
+ WL_DRM_FORMAT_XBGR8888 = 0x34324258,
+ WL_DRM_FORMAT_RGBX8888 = 0x34325852,
+ WL_DRM_FORMAT_BGRX8888 = 0x34325842,
+ WL_DRM_FORMAT_ARGB8888 = 0x34325241,
+ WL_DRM_FORMAT_ABGR8888 = 0x34324241,
+ WL_DRM_FORMAT_RGBA8888 = 0x34324152,
+ WL_DRM_FORMAT_BGRA8888 = 0x34324142,
+ WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
+ WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
+ WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
+ WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
+ WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
+ WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
+ WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
+ WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
+ WL_DRM_FORMAT_YUYV = 0x56595559,
+ WL_DRM_FORMAT_YVYU = 0x55595659,
+ WL_DRM_FORMAT_UYVY = 0x59565955,
+ WL_DRM_FORMAT_VYUY = 0x59555956,
+ WL_DRM_FORMAT_AYUV = 0x56555941,
+ WL_DRM_FORMAT_NV12 = 0x3231564e,
+ WL_DRM_FORMAT_NV21 = 0x3132564e,
+ WL_DRM_FORMAT_NV16 = 0x3631564e,
+ WL_DRM_FORMAT_NV61 = 0x3136564e,
+ WL_DRM_FORMAT_YUV410 = 0x39565559,
+ WL_DRM_FORMAT_YVU410 = 0x39555659,
+ WL_DRM_FORMAT_YUV411 = 0x31315559,
+ WL_DRM_FORMAT_YVU411 = 0x31315659,
+ WL_DRM_FORMAT_YUV420 = 0x32315559,
+ WL_DRM_FORMAT_YVU420 = 0x32315659,
+ WL_DRM_FORMAT_YUV422 = 0x36315559,
+ WL_DRM_FORMAT_YVU422 = 0x36315659,
+ WL_DRM_FORMAT_YUV444 = 0x34325559,
+ WL_DRM_FORMAT_YVU444 = 0x34325659,
+};
+#endif /* WL_DRM_FORMAT_ENUM */
+
+struct wl_drm_listener {
+ /**
+ * device - device
+ * @name: name
+ */
+ void (*device)(void *data,
+ struct wl_drm *wl_drm,
+ const char *name);
+ /**
+ * format - format
+ * @format: format
+ */
+ void (*format)(void *data,
+ struct wl_drm *wl_drm,
+ uint32_t format);
+ /**
+ * authenticated - authenticated
+ */
+ void (*authenticated)(void *data,
+ struct wl_drm *wl_drm);
+};
+
+static inline int
+wl_drm_add_listener(struct wl_drm *wl_drm,
+ const struct wl_drm_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_DRM_AUTHENTICATE 0
+#define WL_DRM_CREATE_BUFFER 1
+#define WL_DRM_CREATE_PLANAR_BUFFER 2
+
+static inline void
+wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
+{
+ wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
+}
+
+static inline void *
+wl_drm_get_user_data(struct wl_drm *wl_drm)
+{
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_destroy(struct wl_drm *wl_drm)
+{
+ wl_proxy_destroy((struct wl_proxy *) wl_drm);
+}
+
+static inline void
+wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
+{
+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
+ WL_DRM_AUTHENTICATE, id);
+}
+
+static inline struct wl_buffer *
+wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_create((struct wl_proxy *) wl_drm,
+ &wl_buffer_interface);
+ if (!id)
+ return NULL;
+
+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
+ WL_DRM_CREATE_BUFFER, id, name, width, height, stride, format);
+
+ return (struct wl_buffer *) id;
+}
+
+static inline struct wl_buffer *
+wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
+{
+ struct wl_proxy *id;
+
+ id = wl_proxy_create((struct wl_proxy *) wl_drm,
+ &wl_buffer_interface);
+ if (!id)
+ return NULL;
+
+ wl_proxy_marshal((struct wl_proxy *) wl_drm,
+ WL_DRM_CREATE_PLANAR_BUFFER, id, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
+
+ return (struct wl_buffer *) id;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am
index c1cbc7e..508506e 100644
--- a/va/x11/Makefile.am
+++ b/va/x11/Makefile.am
@@ -20,7 +20,15 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-INCLUDES = -DLINUX -I$(top_srcdir) -I$(top_srcdir)/va $(DRM_CFLAGS)
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(X11_CFLAGS) \
+ $(XEXT_CFLAGS) \
+ $(XFIXES_CFLAGS) \
+ $(DRM_CFLAGS) \
+ $(NULL)
source_c = \
dri1_util.c \
diff --git a/va/x11/dri1_util.c b/va/x11/dri1_util.c
index 7e5abf8..d3da81b 100644
--- a/va/x11/dri1_util.c
+++ b/va/x11/dri1_util.c
@@ -59,21 +59,21 @@ dri1GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
static void
dri1Close(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
free_drawable_hashtable(ctx);
VA_DRIDestroyContext(ctx->native_dpy, ctx->x11_screen, dri_state->hwContextID);
assert(dri_state->pSAREA != MAP_FAILED);
drmUnmap(dri_state->pSAREA, SAREA_MAX);
- assert(dri_state->fd >= 0);
- drmCloseOnce(dri_state->fd);
+ assert(dri_state->base.fd >= 0);
+ drmCloseOnce(dri_state->base.fd);
VA_DRICloseConnection(ctx->native_dpy, ctx->x11_screen);
}
Bool
isDRI1Connected(VADriverContextP ctx, char **driver_name)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int direct_capable;
int driver_major;
int driver_minor;
@@ -83,9 +83,9 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name)
drm_magic_t magic;
*driver_name = NULL;
- dri_state->fd = -1;
+ dri_state->base.fd = -1;
dri_state->pSAREA = MAP_FAILED;
- dri_state->driConnectedFlag = VA_NONE;
+ dri_state->base.auth_type = VA_NONE;
if (!VA_DRIQueryDirectRenderingCapable(ctx->native_dpy,
ctx->x11_screen,
@@ -105,20 +105,20 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name)
goto err_out0;
- dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened);
+ dri_state->base.fd = drmOpenOnce(NULL, BusID, &newlyopened);
XFree(BusID);
- if (dri_state->fd < 0)
+ if (dri_state->base.fd < 0)
goto err_out1;
- if (drmGetMagic(dri_state->fd, &magic))
+ if (drmGetMagic(dri_state->base.fd, &magic))
goto err_out1;
if (newlyopened && !VA_DRIAuthConnection(ctx->native_dpy, ctx->x11_screen, magic))
goto err_out1;
- if (drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA))
+ if (drmMap(dri_state->base.fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA))
goto err_out1;
if (!VA_DRICreateContext(ctx->native_dpy, ctx->x11_screen,
@@ -126,7 +126,7 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name)
&dri_state->hwContextID, &dri_state->hwContext))
goto err_out1;
- dri_state->driConnectedFlag = VA_DRI1;
+ dri_state->base.auth_type = VA_DRI1;
dri_state->createDrawable = dri1CreateDrawable;
dri_state->destroyDrawable = dri1DestroyDrawable;
dri_state->swapBuffer = dri1SwapBuffer;
@@ -139,8 +139,8 @@ err_out1:
if (dri_state->pSAREA != MAP_FAILED)
drmUnmap(dri_state->pSAREA, SAREA_MAX);
- if (dri_state->fd >= 0)
- drmCloseOnce(dri_state->fd);
+ if (dri_state->base.fd >= 0)
+ drmCloseOnce(dri_state->base.fd);
VA_DRICloseConnection(ctx->native_dpy, ctx->x11_screen);
@@ -149,7 +149,7 @@ err_out0:
XFree(*driver_name);
dri_state->pSAREA = MAP_FAILED;
- dri_state->fd = -1;
+ dri_state->base.fd = -1;
*driver_name = NULL;
return False;
diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c
index 995f235..0a2ac45 100644
--- a/va/x11/dri2_util.c
+++ b/va/x11/dri2_util.c
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
@@ -141,50 +164,51 @@ dri2GetRenderingBuffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
void
dri2Close(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
free_drawable_hashtable(ctx);
- if (dri_state->fd >= 0);
- close(dri_state->fd);
+ if (dri_state->base.fd >= 0);
+ close(dri_state->base.fd);
}
Bool
isDRI2Connected(VADriverContextP ctx, char **driver_name)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int major, minor;
int error_base;
int event_base;
char *device_name = NULL;
drm_magic_t magic;
*driver_name = NULL;
- dri_state->fd = -1;
- dri_state->driConnectedFlag = VA_NONE;
+ dri_state->base.fd = -1;
+ dri_state->base.auth_type = VA_NONE;
if (!VA_DRI2QueryExtension(ctx->native_dpy, &event_base, &error_base))
goto err_out;
if (!VA_DRI2QueryVersion(ctx->native_dpy, &major, &minor))
goto err_out;
+
if (!VA_DRI2Connect(ctx->native_dpy, RootWindow(ctx->native_dpy, ctx->x11_screen),
driver_name, &device_name))
goto err_out;
- dri_state->fd = open(device_name, O_RDWR);
- assert(dri_state->fd >= 0);
+ dri_state->base.fd = open(device_name, O_RDWR);
+ assert(dri_state->base.fd >= 0);
- if (dri_state->fd < 0)
+ if (dri_state->base.fd < 0)
goto err_out;
- if (drmGetMagic(dri_state->fd, &magic))
+ if (drmGetMagic(dri_state->base.fd, &magic))
goto err_out;
if (!VA_DRI2Authenticate(ctx->native_dpy, RootWindow(ctx->native_dpy, ctx->x11_screen),
magic))
goto err_out;
- dri_state->driConnectedFlag = VA_DRI2;
+ dri_state->base.auth_type = VA_DRI2;
dri_state->createDrawable = dri2CreateDrawable;
dri_state->destroyDrawable = dri2DestroyDrawable;
dri_state->swapBuffer = dri2SwapBuffer;
@@ -204,11 +228,11 @@ err_out:
if (*driver_name)
Xfree(*driver_name);
- if (dri_state->fd >= 0)
- close(dri_state->fd);
+ if (dri_state->base.fd >= 0)
+ close(dri_state->base.fd);
*driver_name = NULL;
- dri_state->fd = -1;
+ dri_state->base.fd = -1;
return False;
}
diff --git a/va/x11/va_dricommon.c b/va/x11/va_dricommon.c
index 07dc50c..c0cbbcc 100644
--- a/va/x11/va_dricommon.c
+++ b/va/x11/va_dricommon.c
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
#include "va_dricommon.h"
// X error trap
@@ -38,7 +61,7 @@ is_window(Display *dpy, Drawable drawable)
static struct dri_drawable *
do_drawable_hash(VADriverContextP ctx, XID drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int index = drawable % DRAWABLE_HASH_SZ;
struct dri_drawable *dri_drawable = dri_state->drawable_hash[index];
@@ -60,7 +83,7 @@ do_drawable_hash(VADriverContextP ctx, XID drawable)
void
free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int i = 0;
while (i++ < DRAWABLE_HASH_SZ) {
@@ -74,7 +97,7 @@ free_drawable(VADriverContextP ctx, struct dri_drawable* dri_drawable)
void
free_drawable_hashtable(VADriverContextP ctx)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
int i;
struct dri_drawable *dri_drawable, *prev;
@@ -100,7 +123,7 @@ dri_get_drawable(VADriverContextP ctx, XID drawable)
void
dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
dri_state->swapBuffer(ctx, dri_drawable);
}
@@ -108,7 +131,7 @@ dri_swap_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
union dri_buffer *
dri_get_rendering_buffer(VADriverContextP ctx, struct dri_drawable *dri_drawable)
{
- struct dri_state *dri_state = (struct dri_state *)ctx->dri_state;
+ struct dri_state *dri_state = (struct dri_state *)ctx->drm_state;
return dri_state->getRenderingBuffer(ctx, dri_drawable);
}
diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h
index 357cc8e..ca25d2d 100644
--- a/va/x11/va_dricommon.h
+++ b/va/x11/va_dricommon.h
@@ -1,3 +1,26 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
#ifndef _VA_DRICOMMON_H_
#define _VA_DRICOMMON_H_
@@ -9,18 +32,19 @@
#endif
#include <va/va_backend.h>
+#include <va/va_drmcommon.h>
#ifdef ANDROID
#define XID unsigned int
#define Bool int
#endif
-enum
-{
- VA_NONE = 0,
- VA_DRI1 = 1,
- VA_DRI2 = 2,
- VA_DUMMY = 3
+enum {
+ /* Compatibility. Do not use for newly-written code. */
+ VA_NONE = VA_DRM_AUTH_NONE,
+ VA_DRI1 = VA_DRM_AUTH_DRI1,
+ VA_DRI2 = VA_DRM_AUTH_DRI2,
+ VA_DUMMY = VA_DRM_AUTH_CUSTOM
};
union dri_buffer
@@ -51,8 +75,7 @@ struct dri_drawable
#define DRAWABLE_HASH_SZ 32
struct dri_state
{
- int fd;
- int driConnectedFlag; /* 0: disconnected, 1: DRI, 2: DRI2 */
+ struct drm_state base;
#ifndef ANDROID
drm_handle_t hSAREA;
drm_context_t hwContext;
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index 86b040a..dfb9d07 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -63,12 +63,12 @@ static void va_DisplayContextDestroy (
return;
ctx = pDisplayContext->pDriverContext;
- dri_state = ctx->dri_state;
+ dri_state = ctx->drm_state;
if (dri_state && dri_state->close)
dri_state->close(ctx);
- free(pDisplayContext->pDriverContext->dri_state);
+ free(pDisplayContext->pDriverContext->drm_state);
free(pDisplayContext->pDriverContext);
free(pDisplayContext);
}
@@ -150,7 +150,9 @@ static VAStatus va_DisplayContextGetDriverName (
if (driver_name)
*driver_name = NULL;
-
+ else
+ return VA_STATUS_ERROR_UNKNOWN;
+
vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
if (vaStatus != VA_STATUS_SUCCESS)
vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name);
@@ -185,12 +187,13 @@ VADisplay vaGetDisplay (
pDisplayContext->vadpy_magic = VA_DISPLAY_MAGIC;
pDriverContext->native_dpy = (void *)native_dpy;
+ pDriverContext->display_type = VA_DISPLAY_X11;
pDisplayContext->pDriverContext = pDriverContext;
pDisplayContext->vaIsValid = va_DisplayContextIsValid;
pDisplayContext->vaDestroy = va_DisplayContextDestroy;
pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
pDisplayContext->opaque = NULL;
- pDriverContext->dri_state = dri_state;
+ pDriverContext->drm_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else