[SCM] libva/upstream: Imported Upstream version 1.1.0
mfv-guest at users.alioth.debian.org
mfv-guest at users.alioth.debian.org
Wed Jan 16 09:18:03 UTC 2013
The following commit has been merged in the upstream branch:
commit e1030032b2daa4b08c3803f27e863802b9b2000e
Author: Matteo F. Vescovi <mfv.debian at gmail.com>
Date: Wed Jan 16 10:09:22 2013 +0100
Imported Upstream version 1.1.0
diff --git a/.gitignore b/.gitignore
index fd8ac05..30af177 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,12 @@ config.sub
configure
debian.upstream/changelog
debian.upstream/control
+debian.upstream/libva-drm*.install
+debian.upstream/libva-egl*.install
+debian.upstream/libva-glx*.install
+debian.upstream/libva-wayland*.install
+debian.upstream/libva-x11*.install
+debian.upstream/libva[0-9]*.install
depcomp
install-sh
libtool
diff --git a/Makefile.am b/Makefile.am
index 1425b0f..beac7e9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,6 +20,8 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+
AUTOMAKE_OPTIONS = foreign
SUBDIRS = va dummy_drv_video pkgconfig test debian.upstream doc
diff --git a/NEWS b/NEWS
index 80d5f7e..9f78a99 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,18 @@
-libva NEWS -- summary of user visible changes. 2011-10-28
+libva NEWS -- summary of user visible changes. 2012-10-04
Copyright (C) 2009-2011 Intel Corporation
+Version 1.1.0 - 04.Oct.2012
+* API: add Wayland support
+* API: add raw DRM support for headless pipelines
+* Fix generic VA/GLX implementation for newer cluttersink versions
+* Fix threading issues in VA objects reference code (+Krzysztof Kotlenga)
+* Fix build on Android Ice Cream Sandwich (+Haitao Huang, Daniel Charles)
+
+Version 1.0.16 - 02.Aug.2012
+* API: data structures for JPEG Baseline decoding
+* API: clarify the definition of slice_data_bit_offset
+* Add a simple test case for JPEG decoding
+
Version 1.0.15 - 28.Oct.2011
* API: make {Top,Bottom}FieldOrderCnt signed (Yi Wang)
* Add auto-generated Debian packaging
diff --git a/autogen.sh b/autogen.sh
index 9c2f4f6..ab04e1d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,3 +1,51 @@
-#! /bin/sh
-autoreconf -v --install
-./configure "$@"
+#!/bin/sh
+# Copyright (c) 2007 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.
+
+PROJECT="libva"
+
+test -n "$srcdir" || srcdir="`dirname \"$0\"`"
+test -n "$srcdir" || srcdir=.
+
+if ! test -f "$srcdir/configure.ac"; then
+ echo "Failed to find the top-level $PROJECT directory"
+ exit 1
+fi
+
+olddir="`pwd`"
+cd "$srcdir"
+
+mkdir -p m4
+
+AUTORECONF=`which autoreconf`
+if test -z $AUTORECONF; then
+ echo "*** No autoreconf found ***"
+ exit 1
+else
+ autoreconf -v --install || exit $?
+fi
+
+cd "$olddir"
+
+if test -z "$NO_CONFIGURE"; then
+ $srcdir/configure "$@" && echo "Now type 'make' to compile $PROJECT."
+fi
diff --git a/build/gen_version.sh b/build/gen_version.sh
index f594ddd..8864f7d 100644
--- a/build/gen_version.sh
+++ b/build/gen_version.sh
@@ -1,3 +1,25 @@
+# Copyright (c) 2007 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.
+
#!/bin/sh
libva_topdir="$1"
diff --git a/configure.ac b/configure.ac
index 76bed9f..fa7af9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,14 +77,21 @@ m4_define([libva_lt_age],
# libdrm minimun version requirement
m4_define([libdrm_version], [2.4])
+# Wayland minimum version number
+m4_define([wayland_api_version], [0.95.0])
+
AC_PREREQ(2.57)
AC_INIT([libva], [libva_version], [waldo.bastian at intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER([config.h])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+TODAY="`LC_ALL=C date +'%a, %d %b %Y %X %z'`"
+AC_SUBST(TODAY)
+
VA_API_MAJOR_VERSION=va_api_major_version
VA_API_MINOR_VERSION=va_api_minor_version
VA_API_MICRO_VERSION=va_api_micro_version
@@ -116,27 +123,37 @@ AC_ARG_ENABLE(docs,
[build Doxygen documentation @<:@default=no@:>@])],
[], [enable_docs="no"])
+AC_ARG_ENABLE(drm,
+ [AC_HELP_STRING([--enable-drm],
+ [build with VA/DRM API support @<:@default=yes@:>@])],
+ [], [enable_drm="yes"])
+
+AC_ARG_ENABLE(x11,
+ [AC_HELP_STRING([--enable-x11],
+ [build with VA/X11 API support @<:@default=yes@:>@])],
+ [], [enable_x11="yes"])
+
AC_ARG_ENABLE(glx,
[AC_HELP_STRING([--enable-glx],
- [build with GLX support @<:@default=yes@:>@])],
+ [build with VA/GLX API support @<:@default=yes@:>@])],
[], [enable_glx="yes"])
AC_ARG_ENABLE(egl,
[AC_HELP_STRING([--enable-egl],
- [build with EGL support @<:@default=yes@:>@])],
+ [build with VA/EGL API support @<:@default=yes@:>@])],
[], [enable_egl="yes"])
+AC_ARG_ENABLE([wayland],
+ [AC_HELP_STRING([--enable-wayland],
+ [build with VA/Wayland API support @<:@default=yes@:>@])],
+ [], [enable_wayland="yes"])
+
AC_ARG_ENABLE(dummy-driver,
[AC_HELP_STRING([--enable-dummy-driver],
[build dummy video driver @<:@default=yes@:>@])],
[], [enable_dummy_driver="yes"])
AM_CONDITIONAL(BUILD_DUMMY_DRIVER, test x$enable_dummy_driver = xyes)
-AC_ARG_ENABLE(dummy-backend,
- [AC_HELP_STRING([--enable-dummy-backend],
- [build dummy libva backend])],
- [], [enable_dummy_backend="no"])
-
AC_ARG_WITH(drivers-path,
[AC_HELP_STRING([--with-drivers-path=[[path]]],
[drivers path])],
@@ -149,126 +166,182 @@ AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_CC
AC_PROG_CXX
+AM_PROG_CC_C_O
+PKG_PROG_PKG_CONFIG
AC_HEADER_STDC
AC_SYS_LARGEFILE
-PKG_CHECK_MODULES([X11], [x11])
-PKG_CHECK_MODULES([XEXT],[xext])
-PKG_CHECK_MODULES([XFIXES], [xfixes])
-
# Check for Doxygen
if test "$enable_docs" = "yes"; then
AC_CHECK_TOOL([DOXYGEN], [doxygen], [enable_docs="no"])
fi
AM_CONDITIONAL(ENABLE_DOCS, test "$enable_docs" = "yes")
-# Check for recent enough DRM
+# Check for __attribute__((visibility()))
+AC_CACHE_CHECK([whether __attribute__((visibility())) is supported],
+ ac_cv_have_gnuc_visibility_attribute,
+ [cat > conftest.c <<EOF
+int foo __attribute__ ((visibility ("hidden"))) = 1;
+int bar __attribute__ ((visibility ("protected"))) = 1;
+EOF
+ ac_cv_have_gnuc_visibility_attribute="no"
+ if ${CC-cc} -Werror -S conftest.c -o conftest.s >/dev/null 2>&1; then
+ if grep '\.hidden.*foo' conftest.s >/dev/null; then
+ if grep '\.protected.*bar' conftest.s >/dev/null; then
+ ac_cv_have_gnuc_visibility_attribute="yes"
+ fi
+ fi
+ fi
+ rm -f conftest.[cs]
+])
+if test "$ac_cv_have_gnuc_visibility_attribute" = "yes"; then
+ AC_DEFINE([HAVE_GNUC_VISIBILITY_ATTRIBUTE], [1],
+ [Defined to 1 if GCC visibility attribute is supported])
+fi
+
+# Check for DRM (mandatory)
LIBDRM_VERSION=libdrm_version
PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION])
AC_SUBST(LIBDRM_VERSION)
-if test x$enable_dummy_backend = xyes; then
- PKG_CHECK_MODULES([UDEV], [libudev], [libudev=yes], [libudev=no])
+USE_DRM="no"
+if test "$enable_drm" = "yes"; then
+ USE_DRM="yes"
+ AC_DEFINE([HAVE_VA_DRM], [1], [Defined to 1 if VA/DRM API is built])
fi
-if test x$libudev = xno; then
- enable_dummy_backend=no
+AM_CONDITIONAL(USE_DRM, test "$USE_DRM" = "yes")
+
+# Check for X11
+USE_X11="no"
+if test "$enable_x11" = "yes"; then
+ USE_X11="yes"
+ PKG_CHECK_MODULES([X11], [x11], [:], [USE_X11="no"])
+ PKG_CHECK_MODULES([XEXT], [xext], [:], [USE_X11="no"])
+ PKG_CHECK_MODULES([XFIXES], [xfixes], [:], [USE_X11="no"])
+ if test "$USE_X11" = "yes"; then
+ AC_DEFINE([HAVE_VA_X11], [1], [Defined to 1 if VA/X11 API is built])
+ fi
fi
-AM_CONDITIONAL(BUILD_DUMMY_BACKEND, test x$enable_dummy_backend = xyes)
+AM_CONDITIONAL(USE_X11, test "$USE_X11" = "yes")
# Check for GLX
USE_GLX="no"
-GL_DEPS_CFLAGS=""
-GL_DEPS_LIBS=""
-if test "$enable_glx" = "yes"; then
- saved_CFLAGS="$CFLAGS"
+if test "$USE_X11:$enable_glx" = "yes:yes"; then
+ PKG_CHECK_MODULES([GLX], [gl x11], [USE_GLX="yes"], [:])
+ saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
- PKG_CHECK_MODULES([GL_DEPS], [gl], [], [GL_DEPS_LIBS="-lX11 -lGL"])
- CFLAGS="$CFLAGS $GL_DEPS_CFLAGS"
- LIBS="$LIBS $GL_DEPS_LIBS"
- AC_CHECK_HEADERS([GL/gl.h])
- AC_CHECK_HEADERS([GL/glx.h])
- AC_CHECK_LIB(GL, glXCreateContext, [USE_GLX="yes"])
- CFLAGS="$saved_CFLAGS"
+ CPPFLAGS="$CPPFLAGS $GLX_CFLAGS"
+ LIBS="$LIBS $GLX_LIBS"
+ AC_CHECK_HEADERS([GL/gl.h GL/glx.h], [:], [USE_GLX="no"])
+ AC_CHECK_LIB([GL], [glXCreateContext], [:] [USE_GLX="no"])
+ CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
+ if test "$USE_GLX" = "yes"; then
+ AC_DEFINE([HAVE_VA_GLX], [1], [Defined to 1 if VA/GLX API is built])
+ fi
fi
-AC_SUBST(GL_DEPS_CFLAGS)
-AC_SUBST(GL_DEPS_LIBS)
AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes")
# Check for EGL
USE_EGL="no"
-EGL_DEPS_CFLAGS=""
-EGL_DEPS_LIBS=""
if test "$enable_egl" = "yes"; then
- saved_CFLAGS="$CFLAGS"
+ PKG_CHECK_MODULES([EGL], [egl], [USE_EGL="yes"], [:])
+ saved_CPPFLAGS="$CPPFLAGS"
saved_LIBS="$LIBS"
- PKG_CHECK_MODULES([EGL_DEPS], [egl], [], [EGL_DEPS_LIBS="-lEGL"])
- CFLAGS="$CFLAGS $EGL_DEPS_CFLAGS"
- LIBS="$LIBS $EGL_DEPS_LIBS"
- AC_CHECK_HEADERS([EGL/egl.h], [USE_EGL="yes"], [USE_EGL="no"])
-
- if test "x$USE_EGL" = "xyes"; then
- AC_CHECK_LIB(EGL, eglGetDisplay, [USE_EGL="yes"], [USE_EGL="no"])
- fi
-
- CFLAGS="$saved_CFLAGS"
+ CPPFLAGS="$CPPFLAGS $EGL_CFLAGS"
+ LIBS="$LIBS $EGL_LIBS"
+ AC_CHECK_HEADERS([EGL/egl.h], [:], [USE_EGL="no"])
+ AC_CHECK_LIB([EGL], [eglGetDisplay], [:], [USE_EGL="no"])
+ CPPFLAGS="$saved_CPPFLAGS"
LIBS="$saved_LIBS"
-
- libglesv1_cm="no"
- PKG_CHECK_MODULES([GLESv1_CM], [glesv1_cm], [libglesv1_cm="yes"], [libglesv1_cm="no"])
+ if test "$USE_EGL" = "yes"; then
+ AC_DEFINE([HAVE_VA_EGL], [1], [Defined to 1 if VA/EGL API is built])
+ fi
fi
-AC_SUBST(EGL_DEPS_CFLAGS)
-AC_SUBST(EGL_DEPS_LIBS)
AM_CONDITIONAL(USE_EGL, test "$USE_EGL" = "yes")
-AM_CONDITIONAL(BUILD_EGL_TEST, [test "x$libglesv1_cm" = "xyes"])
-# We only need the headers, we don't link against the DRM libraries
-LIBVA_CFLAGS="$DRM_CFLAGS"
-AC_SUBST(LIBVA_CFLAGS)
-AC_SUBST(LIBVA_LIBS)
+# Check for Wayland
+WAYLAND_API_VERSION=wayland_api_version
+AC_SUBST(WAYLAND_API_VERSION)
+
+USE_WAYLAND="no"
+if test "$enable_wayland" = "yes"; then
+ PKG_CHECK_MODULES([WAYLAND], [wayland-client >= wayland_api_version],
+ [USE_WAYLAND="yes"], [:])
+ if test "$USE_WAYLAND" = "yes"; then
+ AC_DEFINE([HAVE_VA_WAYLAND], [1],
+ [Defined to 1 if VA/Wayland API is built])
+ fi
+fi
+AM_CONDITIONAL(USE_WAYLAND, test "$USE_WAYLAND" = "yes")
+
+m4_ifdef([WAYLAND_SCANNER_RULES],
+ [WAYLAND_SCANNER_RULES(['$(top_srcdir)/va/wayland/protocol'])],
+ [wayland_scanner_rules=""; AC_SUBST(wayland_scanner_rules)])
pkgconfigdir=${libdir}/pkgconfig
AC_SUBST(pkgconfigdir)
-LIBVA_DISPLAY=x11
-libvacorelib=libva.la
-libvabackendlib=libva-$LIBVA_DISPLAY.la
-AC_SUBST([libvacorelib])
-AC_SUBST([libvabackendlib])
+# Check for builds without backend
+if test "$USE_DRM:$USE_X11:$USE_WAYLAND" = "no:no:no"; then
+ AC_MSG_ERROR([Please select at least one backend (DRM, X11, Wayland)])
+fi
AC_OUTPUT([
Makefile
debian.upstream/Makefile
+ debian.upstream/changelog
+ debian.upstream/control
+ debian.upstream/libva$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva.install.in
+ debian.upstream/libva-drm$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva-drm.install.in
+ debian.upstream/libva-egl$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva-egl.install.in
+ debian.upstream/libva-glx$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva-glx.install.in
+ debian.upstream/libva-wayland$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva-wayland.install.in
+ debian.upstream/libva-x11-$LIBVA_MAJOR_VERSION.install:\
+debian.upstream/libva-x11.install.in
doc/Makefile
dummy_drv_video/Makefile
pkgconfig/Makefile
+ pkgconfig/libva-drm.pc
pkgconfig/libva-egl.pc
pkgconfig/libva-glx.pc
pkgconfig/libva-tpi.pc
+ pkgconfig/libva-wayland.pc
pkgconfig/libva-x11.pc
pkgconfig/libva.pc
test/Makefile
test/basic/Makefile
+ test/common/Makefile
test/decode/Makefile
- test/egl/Makefile
test/encode/Makefile
test/putsurface/Makefile
- test/vainfo/Makefile
test/v4l_h264/Makefile
- test/v4l_h264/encode/Makefile
test/v4l_h264/decode/Makefile
+ test/v4l_h264/encode/Makefile
+ test/vainfo/Makefile
va/Makefile
- va/dummy/Makefile
+ va/drm/Makefile
va/egl/Makefile
va/glx/Makefile
va/va_version.h
+ va/wayland/Makefile
+ va/wayland/protocol/Makefile
va/x11/Makefile
])
# Print a small summary
-AS_IF([test x$USE_GLX = xyes], [BACKENDS="glx $BACKENDS"])
-AS_IF([test x$USE_EGL = xyes], [BACKENDS="egl $BACKENDS"])
+BACKENDS=""
+AS_IF([test x$USE_DRM = xyes], [BACKENDS="$BACKENDS drm"])
+AS_IF([test x$USE_X11 = xyes], [BACKENDS="$BACKENDS x11"])
+AS_IF([test x$USE_GLX = xyes], [BACKENDS="$BACKENDS glx"])
+AS_IF([test x$USE_EGL = xyes], [BACKENDS="$BACKENDS egl"])
+AS_IF([test x$USE_WAYLAND = xyes], [BACKENDS="$BACKENDS wayland"])
echo
echo "libva - ${LIBVA_VERSION} (VA-API ${VA_API_VERSION})"
diff --git a/debian.upstream/Makefile.am b/debian.upstream/Makefile.am
index 87a571a..3e0dd23 100644
--- a/debian.upstream/Makefile.am
+++ b/debian.upstream/Makefile.am
@@ -1,20 +1,29 @@
DEBIANFILES = \
- README.Debian \
- changelog.in \
- compat \
- control.in \
- copyright \
- libva-dev.dirs \
- libva-dev.install \
- libva1.dirs \
- libva1.install \
- rules \
- vainfo.install \
+ README.Debian \
+ changelog.in \
+ compat \
+ control.in \
+ copyright \
+ libva-dev.install \
+ libva-drm.install.in \
+ libva-egl.install.in \
+ libva-glx.install.in \
+ libva-wayland.install.in \
+ libva-x11.install.in \
+ libva.install.in \
+ rules \
+ vainfo.install \
$(NULL)
-DEBIANGENFILES = \
- changelog \
- control \
+DEBIANGENFILES = \
+ changelog \
+ control \
+ libva$(LIBVA_MAJOR_VERSION).install \
+ libva-drm$(LIBVA_MAJOR_VERSION).install \
+ libva-egl$(LIBVA_MAJOR_VERSION).install \
+ libva-glx$(LIBVA_MAJOR_VERSION).install \
+ libva-wayland$(LIBVA_MAJOR_VERSION).install \
+ libva-x11-$(LIBVA_MAJOR_VERSION).install \
$(NULL)
EXTRA_DIST = $(DEBIANFILES)
@@ -23,11 +32,3 @@ dist_noinst_DATA = $(DEBIANGENFILES)
# Extra clean files so that maintainer-clean removes *everything*
MAINTAINERCLEANFILES = Makefile.in $(DEBIANGENFILES)
-
-$(DEBIANGENFILES): %: %.in Makefile
- -sed \
- -e 's|\@DATE\@|'"`LC_ALL=C date +'%a, %d %b %Y %X %z'`"'|' \
- -e 's|\@LIBDRM_VERSION\@|$(LIBDRM_VERSION)|' \
- -e 's|\@LIBVA_PACKAGE_VERSION\@|$(LIBVA_PACKAGE_VERSION)|' \
- -e 's|\@PACKAGE_VERSION\@|$(PACKAGE_VERSION)|' \
- $< > $@
diff --git a/debian.upstream/changelog.in b/debian.upstream/changelog.in
index 397b5eb..f5482c4 100644
--- a/debian.upstream/changelog.in
+++ b/debian.upstream/changelog.in
@@ -2,4 +2,4 @@ libva (@PACKAGE_VERSION at -1) unstable; urgency=low
* Autogenerated package, see NEWS file for ChangeLog.
- -- Gwenole Beauchesne <gwenole.beauchesne at intel.com> @DATE@
+ -- Gwenole Beauchesne <gwenole.beauchesne at intel.com> @TODAY@
diff --git a/debian.upstream/control.in b/debian.upstream/control.in
index 78de060..6d7d82c 100644
--- a/debian.upstream/control.in
+++ b/debian.upstream/control.in
@@ -6,54 +6,104 @@ Build-Depends: automake,
cdbs,
debhelper (>= 5),
libdrm-dev (>= @LIBDRM_VERSION@),
- libgl-dev,
+ at USE_X11_TRUE@ libx11-dev, libxext-dev, libxfixes-dev,
+ at USE_GLX_TRUE@ libgl-dev,
+ at USE_WAYLAND_TRUE@ libwayland-dev (>= @WAYLAND_API_VERSION@),
libtool,
- libxext-dev,
- libxfixes-dev,
- pkg-config,
- x11proto-xext-dev
+ pkg-config
Standards-Version: 3.7.2
Section: libs
Package: libva-dev
Section: libdevel
Architecture: any
-Depends: libva1 (= ${binary:Version}),
- libdrm-dev (>= @LIBDRM_VERSION@),
- libgl-dev,
+Depends: libdrm-dev (>= @LIBDRM_VERSION@),
+ at USE_DRM_TRUE@ libva-drm at LIBVA_MAJOR_VERSION@,
+ at USE_X11_TRUE@ libva-x11- at LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libx11-dev,
+ at USE_GLX_TRUE@ libva-glx at LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libgl-dev,
+ at USE_EGL_TRUE@ libva-egl at LIBVA_MAJOR_VERSION@ (= ${binary:Version}),
+ at USE_WAYLAND_TRUE@ libva-wayland at LIBVA_MAJOR_VERSION@ (= ${binary:Version}), libwayland-dev (>= @WAYLAND_API_VERSION@),
+ libva at LIBVA_MAJOR_VERSION@ (= ${binary:Version}),
pkg-config
-Conflicts: libva-0.29-dev
-Replaces: libva-0.29-dev
Description: Video Acceleration (VA) API for Linux -- development files
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
.
This package provides the development environment for libva.
-Package: libva1
+Package: libva at LIBVA_MAJOR_VERSION@
Section: libs
Architecture: any
Depends: ${shlibs:Depends}
-Conflicts: libva-0.29-0
-Replaces: libva-0.29-0
-Provides: libva-0.29-0
-Description: Video Acceleration (VA) API for Linux -- runtime
+Description: Video Acceleration (VA) API for Linux -- Core runtime
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
+ .
+ This package contains the Core runtime library.
+
+ at USE_DRM_TRUE@Package: libva-drm at LIBVA_MAJOR_VERSION@
+ at USE_DRM_TRUE@Section: libs
+ at USE_DRM_TRUE@Architecture: any
+ at USE_DRM_TRUE@Depends: ${shlibs:Depends}
+ at USE_DRM_TRUE@Description: Video Acceleration (VA) API for Linux -- DRM runtime
+ at USE_DRM_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux.
+ at USE_DRM_TRUE@ The library loads a hardware dependendent driver.
+ at USE_DRM_TRUE@ .
+ at USE_DRM_TRUE@ This package contains the VA/DRM runtime library.
+
+ at USE_X11_TRUE@Package: libva-x11- at LIBVA_MAJOR_VERSION@
+ at USE_X11_TRUE@Section: libs
+ at USE_X11_TRUE@Architecture: any
+ at USE_X11_TRUE@Depends: ${shlibs:Depends}
+ at USE_X11_TRUE@Description: Video Acceleration (VA) API for Linux -- X11 runtime
+ at USE_X11_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux.
+ at USE_X11_TRUE@ The library loads a hardware dependendent driver.
+ at USE_X11_TRUE@ .
+ at USE_X11_TRUE@ This package contains the VA/X11 runtime library.
+
+ at USE_GLX_TRUE@Package: libva-glx at LIBVA_MAJOR_VERSION@
+ at USE_GLX_TRUE@Section: libs
+ at USE_GLX_TRUE@Architecture: any
+ at USE_GLX_TRUE@Depends: ${shlibs:Depends}
+ at USE_GLX_TRUE@Description: Video Acceleration (VA) API for Linux -- GLX runtime
+ at USE_GLX_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux.
+ at USE_GLX_TRUE@ The library loads a hardware dependendent driver.
+ at USE_GLX_TRUE@ .
+ at USE_GLX_TRUE@ This package contains the VA/GLX runtime library.
+
+ at USE_EGL_TRUE@Package: libva-egl at LIBVA_MAJOR_VERSION@
+ at USE_EGL_TRUE@Section: libs
+ at USE_EGL_TRUE@Architecture: any
+ at USE_EGL_TRUE@Depends: ${shlibs:Depends}
+ at USE_EGL_TRUE@Description: Video Acceleration (VA) API for Linux -- EGL runtime
+ at USE_EGL_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux.
+ at USE_EGL_TRUE@ The library loads a hardware dependendent driver.
+ at USE_EGL_TRUE@ .
+ at USE_EGL_TRUE@ This package contains the VA/EGL runtime library.
+
+ at USE_WAYLAND_TRUE@Package: libva-wayland at LIBVA_MAJOR_VERSION@
+ at USE_WAYLAND_TRUE@Section: libs
+ at USE_WAYLAND_TRUE@Architecture: any
+ at USE_WAYLAND_TRUE@Depends: ${shlibs:Depends}
+ at USE_WAYLAND_TRUE@Description: Video Acceleration (VA) API for Linux -- Wayland runtime
+ at USE_WAYLAND_TRUE@ The libva library implements the Video Acceleration (VA) API for Linux.
+ at USE_WAYLAND_TRUE@ The library loads a hardware dependendent driver.
+ at USE_WAYLAND_TRUE@ .
+ at USE_WAYLAND_TRUE@ This package contains the VA/Wayland runtime library.
-Package: libva1-dbg
+Package: libva at LIBVA_MAJOR_VERSION@-dbg
Section: libdevel
Architecture: any
-Depends: libva1 (= ${Source-Version})
+Depends: libva at LIBVA_MAJOR_VERSION@ (= ${Source-Version})
Description: Video Acceleration (VA) API for Linux -- runtime
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
.
- This package contains the debug files.
+ This package contains the debug info files.
Package: vainfo
Architecture: any
-Depends: libva1 (= ${Source-Version})
+Depends: libva at LIBVA_MAJOR_VERSION@ (= ${Source-Version})
Description: Video Acceleration (VA) API for Linux -- info program
The libva library implements the Video Acceleration (VA) API for Linux.
The library loads a hardware dependendent driver.
diff --git a/debian.upstream/libva-dev.dirs b/debian.upstream/libva-dev.dirs
deleted file mode 100644
index 4418816..0000000
--- a/debian.upstream/libva-dev.dirs
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib
-usr/include
diff --git a/debian.upstream/libva-drm.install.in b/debian.upstream/libva-drm.install.in
new file mode 100644
index 0000000..7a9b5f2
--- /dev/null
+++ b/debian.upstream/libva-drm.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva-drm.so.*
diff --git a/debian.upstream/libva-egl.install.in b/debian.upstream/libva-egl.install.in
new file mode 100644
index 0000000..5554b69
--- /dev/null
+++ b/debian.upstream/libva-egl.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva-egl.so.*
diff --git a/debian.upstream/libva-glx.install.in b/debian.upstream/libva-glx.install.in
new file mode 100644
index 0000000..2d33032
--- /dev/null
+++ b/debian.upstream/libva-glx.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva-glx.so.*
diff --git a/debian.upstream/libva-wayland.install.in b/debian.upstream/libva-wayland.install.in
new file mode 100644
index 0000000..2563fea
--- /dev/null
+++ b/debian.upstream/libva-wayland.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva-wayland.so.*
diff --git a/debian.upstream/libva-x11.install.in b/debian.upstream/libva-x11.install.in
new file mode 100644
index 0000000..461d7bd
--- /dev/null
+++ b/debian.upstream/libva-x11.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva-x11.so.*
diff --git a/debian.upstream/libva.install.in b/debian.upstream/libva.install.in
new file mode 100644
index 0000000..bad195c
--- /dev/null
+++ b/debian.upstream/libva.install.in
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libva.so.*
diff --git a/debian.upstream/libva1.dirs b/debian.upstream/libva1.dirs
deleted file mode 100644
index 6845771..0000000
--- a/debian.upstream/libva1.dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib
diff --git a/debian.upstream/libva1.install b/debian.upstream/libva1.install
deleted file mode 100644
index ddfd8ed..0000000
--- a/debian.upstream/libva1.install
+++ /dev/null
@@ -1,2 +0,0 @@
-debian/tmp/usr/lib/libva.so.*
-debian/tmp/usr/lib/libva-*.so.*
diff --git a/dummy_drv_video/Makefile.am b/dummy_drv_video/Makefile.am
index 245e6e8..69364c2 100644
--- a/dummy_drv_video/Makefile.am
+++ b/dummy_drv_video/Makefile.am
@@ -26,8 +26,8 @@ if BUILD_DUMMY_DRIVER
dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la
dummy_drv_video_ladir = $(LIBVA_DRIVERS_PATH)
dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined
-dummy_drv_video_la_LIBADD = $(top_builddir)/va/$(libvabackendlib)
-dummy_drv_video_la_DEPENDENCIES = $(top_builddir)/va/$(libvabackendlib)
+dummy_drv_video_la_LIBADD = $(top_builddir)/va/libva-x11.la
+dummy_drv_video_la_DEPENDENCIES = $(top_builddir)/va/libva-x11.la
dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c
noinst_HEADERS = dummy_drv_video.h object_heap.h
endif
diff --git a/dummy_drv_video/dummy_drv_video.c b/dummy_drv_video/dummy_drv_video.c
index a6e76b9..282f208 100644
--- a/dummy_drv_video/dummy_drv_video.c
+++ b/dummy_drv_video/dummy_drv_video.c
@@ -35,7 +35,7 @@
#define ASSERT assert
-#define INIT_DRIVER_DATA struct dummy_driver_data *driver_data = (struct dummy_driver_data *) ctx->pDriverData;
+#define INIT_DRIVER_DATA struct dummy_driver_data * const driver_data = (struct dummy_driver_data *) ctx->pDriverData;
#define CONFIG(id) ((object_config_p) object_heap_lookup( &driver_data->config_heap, id ))
#define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id ))
@@ -73,7 +73,6 @@ VAStatus dummy_QueryConfigProfiles(
int *num_profiles /* out */
)
{
- INIT_DRIVER_DATA
int i = 0;
profile_list[i++] = VAProfileMPEG2Simple;
@@ -102,8 +101,6 @@ VAStatus dummy_QueryConfigEntrypoints(
int *num_entrypoints /* out */
)
{
- INIT_DRIVER_DATA
-
switch (profile) {
case VAProfileMPEG2Simple:
case VAProfileMPEG2Main:
@@ -151,8 +148,6 @@ VAStatus dummy_GetConfigAttributes(
int num_attribs
)
{
- INIT_DRIVER_DATA
-
int i;
/* Other attributes don't seem to be defined */
@@ -433,8 +428,6 @@ VAStatus dummy_QueryImageFormats(
int *num_formats /* out */
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -447,8 +440,6 @@ VAStatus dummy_CreateImage(
VAImage *image /* out */
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -459,8 +450,6 @@ VAStatus dummy_DeriveImage(
VAImage *image /* out */
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -470,8 +459,6 @@ VAStatus dummy_DestroyImage(
VAImageID image
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -482,8 +469,6 @@ VAStatus dummy_SetImagePalette(
unsigned char *palette
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -498,8 +483,6 @@ VAStatus dummy_GetImage(
VAImageID image
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -519,8 +502,6 @@ VAStatus dummy_PutImage(
unsigned int dest_height
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -532,8 +513,6 @@ VAStatus dummy_QuerySubpictureFormats(
unsigned int *num_formats /* out */
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -544,8 +523,6 @@ VAStatus dummy_CreateSubpicture(
VASubpictureID *subpicture /* out */
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -555,8 +532,6 @@ VAStatus dummy_DestroySubpicture(
VASubpictureID subpicture
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -567,8 +542,6 @@ VAStatus dummy_SetSubpictureImage(
VAImageID image
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -584,8 +557,6 @@ VAStatus dummy_SetSubpicturePalette(
unsigned char *palette
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -598,8 +569,6 @@ VAStatus dummy_SetSubpictureChromakey(
unsigned int chromakey_mask
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -610,8 +579,6 @@ VAStatus dummy_SetSubpictureGlobalAlpha(
float global_alpha
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -637,8 +604,6 @@ VAStatus dummy_AssociateSubpicture(
unsigned int flags
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -650,8 +615,6 @@ VAStatus dummy_DeassociateSubpicture(
int num_surfaces
)
{
- INIT_DRIVER_DATA
-
/* TODO */
return VA_STATUS_SUCCESS;
}
@@ -1056,10 +1019,6 @@ VAStatus dummy_PutSurface(
)
{
/* TODO */
- void *drawable = (void *)draw;
-
- (void)drawable;
-
return VA_STATUS_ERROR_UNKNOWN;
}
@@ -1157,8 +1116,6 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
{
INIT_DRIVER_DATA
object_buffer_p obj_buffer;
- object_surface_p obj_surface;
- object_context_p obj_context;
object_config_p obj_config;
object_heap_iterator iter;
@@ -1196,10 +1153,8 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
VAStatus VA_DRIVER_INIT_FUNC( VADriverContextP ctx )
{
struct VADriverVTable * const vtable = ctx->vtable;
- object_base_p obj;
int result;
struct dummy_driver_data *driver_data;
- int i;
ctx->version_major = VA_MAJOR_VERSION;
ctx->version_minor = VA_MINOR_VERSION;
diff --git a/dummy_drv_video/object_heap.c b/dummy_drv_video/object_heap.c
index e867139..7f18a1f 100644
--- a/dummy_drv_video/object_heap.c
+++ b/dummy_drv_video/object_heap.c
@@ -8,11 +8,11 @@
* 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.
@@ -22,39 +22,50 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "object_heap.h"
-
-#include "assert.h"
-#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <assert.h>
+#include "object_heap.h"
-#define ASSERT assert
+#define ASSERT assert
-#define LAST_FREE -1
-#define ALLOCATED -2
+#define LAST_FREE -1
+#define ALLOCATED -2
/*
* Expands the heap
* Return 0 on success, -1 on error
*/
-static int object_heap_expand( object_heap_p heap )
+static int
+object_heap_expand(object_heap_p heap)
{
int i;
void *new_heap_index;
int next_free;
int new_heap_size = heap->heap_size + heap->heap_increment;
-
- new_heap_index = (void *) realloc( heap->heap_index, new_heap_size * heap->object_size );
- if ( NULL == new_heap_index )
- {
+ int bucket_index = new_heap_size / heap->heap_increment - 1;
+
+ if (bucket_index >= heap->num_buckets) {
+ int new_num_buckets = heap->num_buckets + 8;
+ void **new_bucket;
+
+ new_bucket = realloc(heap->bucket, new_num_buckets * sizeof(void *));
+ if (NULL == new_bucket) {
+ return -1;
+ }
+
+ heap->num_buckets = new_num_buckets;
+ heap->bucket = new_bucket;
+ }
+
+ new_heap_index = (void *) malloc(heap->heap_increment * heap->object_size);
+ if (NULL == new_heap_index) {
return -1; /* Out of memory */
}
- heap->heap_index = new_heap_index;
+
+ heap->bucket[bucket_index] = new_heap_index;
next_free = heap->next_free;
- for(i = new_heap_size; i-- > heap->heap_size; )
- {
- object_base_p obj = (object_base_p) (heap->heap_index + i * heap->object_size);
+ for (i = new_heap_size; i-- > heap->heap_size;) {
+ object_base_p obj = (object_base_p)(new_heap_index + (i - heap->heap_size) * heap->object_size);
obj->id = i + heap->id_offset;
obj->next_free = next_free;
next_free = i;
@@ -67,14 +78,17 @@ static int object_heap_expand( object_heap_p heap )
/*
* Return 0 on success, -1 on error
*/
-int object_heap_init( object_heap_p heap, int object_size, int id_offset)
+int
+object_heap_init(object_heap_p heap, int object_size, int id_offset)
{
+ pthread_mutex_init(&heap->mutex, NULL);
heap->object_size = object_size;
heap->id_offset = id_offset & OBJECT_HEAP_OFFSET_MASK;
heap->heap_size = 0;
heap->heap_increment = 16;
- heap->heap_index = NULL;
heap->next_free = LAST_FREE;
+ heap->num_buckets = 0;
+ heap->bucket = NULL;
return object_heap_expand(heap);
}
@@ -82,69 +96,103 @@ int object_heap_init( object_heap_p heap, int object_size, int id_offset)
* Allocates an object
* Returns the object ID on success, returns -1 on error
*/
-int object_heap_allocate( object_heap_p heap )
+static int
+object_heap_allocate_unlocked(object_heap_p heap)
{
object_base_p obj;
- if ( LAST_FREE == heap->next_free )
- {
- if( -1 == object_heap_expand( heap ) )
- {
+ int bucket_index, obj_index;
+
+ if (LAST_FREE == heap->next_free) {
+ if (-1 == object_heap_expand(heap)) {
return -1; /* Out of memory */
}
}
- ASSERT( heap->next_free >= 0 );
-
- obj = (object_base_p) (heap->heap_index + heap->next_free * heap->object_size);
+ ASSERT(heap->next_free >= 0);
+
+ bucket_index = heap->next_free / heap->heap_increment;
+ obj_index = heap->next_free % heap->heap_increment;
+
+ obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size);
heap->next_free = obj->next_free;
obj->next_free = ALLOCATED;
return obj->id;
}
+int
+object_heap_allocate(object_heap_p heap)
+{
+ int ret;
+
+ pthread_mutex_lock(&heap->mutex);
+ ret = object_heap_allocate_unlocked(heap);
+ pthread_mutex_unlock(&heap->mutex);
+ return ret;
+}
+
/*
* Lookup an object by object ID
* Returns a pointer to the object on success, returns NULL on error
*/
-object_base_p object_heap_lookup( object_heap_p heap, int id )
+static object_base_p
+object_heap_lookup_unlocked(object_heap_p heap, int id)
{
object_base_p obj;
- if ( (id < heap->id_offset) || (id > (heap->heap_size+heap->id_offset)) )
- {
+ int bucket_index, obj_index;
+
+ if ((id < heap->id_offset) || (id > (heap->heap_size + heap->id_offset))) {
return NULL;
}
id &= OBJECT_HEAP_ID_MASK;
- obj = (object_base_p) (heap->heap_index + id * heap->object_size);
+ bucket_index = id / heap->heap_increment;
+ obj_index = id % heap->heap_increment;
+ obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size);
- /* Check if the object has in fact been allocated */
- if ( obj->next_free != ALLOCATED )
- {
+ /* Check if the object has in fact been allocated */
+ if (obj->next_free != ALLOCATED) {
return NULL;
}
return obj;
}
+object_base_p
+object_heap_lookup(object_heap_p heap, int id)
+{
+ object_base_p obj;
+
+ pthread_mutex_lock(&heap->mutex);
+ obj = object_heap_lookup_unlocked(heap, id);
+ pthread_mutex_unlock(&heap->mutex);
+ return obj;
+}
+
/*
* Iterate over all objects in the heap.
* Returns a pointer to the first object on the heap, returns NULL if heap is empty.
*/
-object_base_p object_heap_first( object_heap_p heap, object_heap_iterator *iter )
+object_base_p
+object_heap_first(object_heap_p heap, object_heap_iterator *iter)
{
*iter = -1;
- return object_heap_next( heap, iter );
+ return object_heap_next(heap, iter);
}
/*
* Iterate over all objects in the heap.
* Returns a pointer to the next object on the heap, returns NULL if heap is empty.
*/
-object_base_p object_heap_next( object_heap_p heap, object_heap_iterator *iter )
+static object_base_p
+object_heap_next_unlocked(object_heap_p heap, object_heap_iterator *iter)
{
object_base_p obj;
+ int bucket_index, obj_index;
int i = *iter + 1;
- while ( i < heap->heap_size)
- {
- obj = (object_base_p) (heap->heap_index + i * heap->object_size);
- if (obj->next_free == ALLOCATED)
- {
+
+ while (i < heap->heap_size) {
+ bucket_index = i / heap->heap_increment;
+ obj_index = i % heap->heap_increment;
+
+ obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size);
+ if (obj->next_free == ALLOCATED) {
*iter = i;
return obj;
}
@@ -154,40 +202,66 @@ object_base_p object_heap_next( object_heap_p heap, object_heap_iterator *iter )
return NULL;
}
+object_base_p
+object_heap_next(object_heap_p heap, object_heap_iterator *iter)
+{
+ object_base_p obj;
+ pthread_mutex_lock(&heap->mutex);
+ obj = object_heap_next_unlocked(heap, iter);
+ pthread_mutex_unlock(&heap->mutex);
+ return obj;
+}
/*
* Frees an object
*/
-void object_heap_free( object_heap_p heap, object_base_p obj )
+static void
+object_heap_free_unlocked(object_heap_p heap, object_base_p obj)
{
- /* Don't complain about NULL pointers */
- if (NULL != obj)
- {
- /* Check if the object has in fact been allocated */
- ASSERT( obj->next_free == ALLOCATED );
-
- obj->next_free = heap->next_free;
- heap->next_free = obj->id & OBJECT_HEAP_ID_MASK;
- }
+ /* Check if the object has in fact been allocated */
+ ASSERT(obj->next_free == ALLOCATED);
+
+ obj->next_free = heap->next_free;
+ heap->next_free = obj->id & OBJECT_HEAP_ID_MASK;
+}
+
+void
+object_heap_free(object_heap_p heap, object_base_p obj)
+{
+ if (!obj)
+ return;
+ pthread_mutex_lock(&heap->mutex);
+ object_heap_free_unlocked(heap, obj);
+ pthread_mutex_unlock(&heap->mutex);
}
/*
* Destroys a heap, the heap must be empty.
*/
-void object_heap_destroy( object_heap_p heap )
+void
+object_heap_destroy(object_heap_p heap)
{
object_base_p obj;
- int i;
+ int bucket_index, obj_index, i;
+
/* Check if heap is empty */
- for (i = 0; i < heap->heap_size; i++)
- {
+ for (i = 0; i < heap->heap_size; i++) {
/* Check if object is not still allocated */
- obj = (object_base_p) (heap->heap_index + i * heap->object_size);
- ASSERT( obj->next_free != ALLOCATED );
+ bucket_index = i / heap->heap_increment;
+ obj_index = i % heap->heap_increment;
+ obj = (object_base_p)(heap->bucket[bucket_index] + obj_index * heap->object_size);
+ ASSERT(obj->next_free != ALLOCATED);
+ }
+
+ for (i = 0; i < heap->heap_size / heap->heap_increment; i++) {
+ free(heap->bucket[i]);
}
- free(heap->heap_index);
+
+ pthread_mutex_destroy(&heap->mutex);
+
+ free(heap->bucket);
+ heap->bucket = NULL;
heap->heap_size = 0;
- heap->heap_index = NULL;
heap->next_free = LAST_FREE;
}
diff --git a/dummy_drv_video/object_heap.h b/dummy_drv_video/object_heap.h
index 154fddb..58e1183 100644
--- a/dummy_drv_video/object_heap.h
+++ b/dummy_drv_video/object_heap.h
@@ -8,11 +8,11 @@
* 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.
@@ -22,11 +22,13 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef _OBJECT_HEAP_H_
-#define _OBJECT_HEAP_H_
+#ifndef OBJECT_HEAP_H
+#define OBJECT_HEAP_H
+
+#include <pthread.h>
-#define OBJECT_HEAP_OFFSET_MASK 0x7F000000
-#define OBJECT_HEAP_ID_MASK 0x00FFFFFF
+#define OBJECT_HEAP_OFFSET_MASK 0x7F000000
+#define OBJECT_HEAP_ID_MASK 0x00FFFFFF
typedef struct object_base *object_base_p;
typedef struct object_heap *object_heap_p;
@@ -37,12 +39,14 @@ struct object_base {
};
struct object_heap {
- int object_size;
+ pthread_mutex_t mutex;
+ int object_size;
int id_offset;
- void *heap_index;
int next_free;
int heap_size;
int heap_increment;
+ void **bucket;
+ int num_buckets;
};
typedef int object_heap_iterator;
@@ -50,40 +54,47 @@ typedef int object_heap_iterator;
/*
* Return 0 on success, -1 on error
*/
-int object_heap_init( object_heap_p heap, int object_size, int id_offset);
+int
+object_heap_init(object_heap_p heap, int object_size, int id_offset);
/*
* Allocates an object
* Returns the object ID on success, returns -1 on error
*/
-int object_heap_allocate( object_heap_p heap );
+int
+object_heap_allocate(object_heap_p heap);
/*
* Lookup an allocated object by object ID
* Returns a pointer to the object on success, returns NULL on error
*/
-object_base_p object_heap_lookup( object_heap_p heap, int id );
+object_base_p
+object_heap_lookup(object_heap_p heap, int id);
/*
* Iterate over all objects in the heap.
* Returns a pointer to the first object on the heap, returns NULL if heap is empty.
*/
-object_base_p object_heap_first( object_heap_p heap, object_heap_iterator *iter );
+object_base_p
+object_heap_first(object_heap_p heap, object_heap_iterator *iter);
/*
* Iterate over all objects in the heap.
* Returns a pointer to the next object on the heap, returns NULL if heap is empty.
*/
-object_base_p object_heap_next( object_heap_p heap, object_heap_iterator *iter );
+object_base_p
+object_heap_next(object_heap_p heap, object_heap_iterator *iter);
/*
* Frees an object
*/
-void object_heap_free( object_heap_p heap, object_base_p obj );
+void
+object_heap_free(object_heap_p heap, object_base_p obj);
/*
* Destroys a heap, the heap must be empty.
*/
-void object_heap_destroy( object_heap_p heap );
+void
+object_heap_destroy(object_heap_p heap);
-#endif /* _OBJECT_HEAP_H_ */
+#endif /* OBJECT_HEAP_H */
diff --git a/pkgconfig/Makefile.am b/pkgconfig/Makefile.am
index f595413..a3435a4 100644
--- a/pkgconfig/Makefile.am
+++ b/pkgconfig/Makefile.am
@@ -22,19 +22,29 @@
pcfiles = libva.pc
pcfiles += libva-tpi.pc
+if USE_DRM
+pcfiles += libva-drm.pc
+endif
+if USE_X11
pcfiles += libva-x11.pc
+endif
if USE_GLX
pcfiles += libva-glx.pc
endif
if USE_EGL
pcfiles += libva-egl.pc
endif
+if USE_WAYLAND
+pcfiles += libva-wayland.pc
+endif
all_pcfiles_in = libva.pc.in
all_pcfiles_in += libva-tpi.pc.in
+all_pcfiles_in += libva-drm.pc.in
all_pcfiles_in += libva-x11.pc.in
all_pcfiles_in += libva-glx.pc.in
all_pcfiles_in += libva-egl.pc.in
+all_pcfiles_in += libva-wayland.pc.in
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = $(pcfiles)
diff --git a/pkgconfig/libva-x11.pc.in b/pkgconfig/libva-drm.pc.in
similarity index 95%
copy from pkgconfig/libva-x11.pc.in
copy to pkgconfig/libva-drm.pc.in
index 4e7330c..b3fb471 100644
--- a/pkgconfig/libva-x11.pc.in
+++ b/pkgconfig/libva-drm.pc.in
@@ -2,7 +2,7 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
-display=x11
+display=drm
Name: libva-${display}
Description: Userspace Video Acceleration (VA) ${display} interface
diff --git a/pkgconfig/libva-x11.pc.in b/pkgconfig/libva-wayland.pc.in
similarity index 84%
copy from pkgconfig/libva-x11.pc.in
copy to pkgconfig/libva-wayland.pc.in
index 4e7330c..ee92ac2 100644
--- a/pkgconfig/libva-x11.pc.in
+++ b/pkgconfig/libva-wayland.pc.in
@@ -2,11 +2,11 @@ prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
-display=x11
+display=wayland
Name: libva-${display}
Description: Userspace Video Acceleration (VA) ${display} interface
-Requires: libva
+Requires: libva wayland-client
Version: @VA_API_VERSION@
Libs: -L${libdir} -lva-${display}
Cflags: -I${includedir}
diff --git a/test/Makefile.am b/test/Makefile.am
index 1ee87c9..451b90f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -20,13 +20,10 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+SUBDIRS = common decode encode vainfo
-AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11
-
-SUBDIRS = basic decode encode putsurface vainfo v4l_h264
-
-if BUILD_EGL_TEST
-SUBDIRS += egl
+if USE_X11
+SUBDIRS += basic putsurface v4l_h264
endif
-EXTRA_DIST = loadsurface.h loadsurface_yuv.h
\ No newline at end of file
+EXTRA_DIST = loadsurface.h loadsurface_yuv.h
diff --git a/test/android_winsys.cpp b/test/android_winsys.cpp
index ba75bdf..3c6a245 100644
--- a/test/android_winsys.cpp
+++ b/test/android_winsys.cpp
@@ -1,12 +1,29 @@
+/*
+ * 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 <ui/DisplayInfo.h>
namespace android {
- class Test {
- public:
- static const sp<ISurface>& getISurface(const sp<Surface>& s) {
- return s->getISurface();
- }
- };
};
#define min(a,b) (a<b?a:b)
@@ -21,21 +38,14 @@ do { \
/*h = min(win_height, info.h);*/ \
w = win_width, h = win_height; \
\
- surface_ctrl = client->createSurface(getpid(), 0, w, h, PIXEL_FORMAT_RGB_565, ISurfaceComposer::ePushBuffers); \
+ surface_ctrl = client->createSurface(getpid(), 0, w, h, PIXEL_FORMAT_RGB_565); \
android_surface = surface_ctrl->getSurface(); \
- android_isurface = Test::getISurface(android_surface); \
\
- client->openTransaction(); \
+ client->openGlobalTransaction(); \
surface_ctrl->setPosition(x, y); \
- client->closeTransaction(); \
- \
- client->openTransaction(); \
surface_ctrl->setSize(w, h); \
- client->closeTransaction(); \
- \
- client->openTransaction(); \
surface_ctrl->setLayer(0x100000); \
- client->closeTransaction(); \
+ client->closeGlobalTransaction(); \
} while (0)
diff --git a/test/basic/Android.mk b/test/basic/Android.mk
index a4b136c..708d98f 100755
--- a/test/basic/Android.mk
+++ b/test/basic/Android.mk
@@ -9,14 +9,14 @@ LOCAL_SRC_FILES := \
test_01.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_001
+LOCAL_MODULE := test_001
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -30,14 +30,14 @@ LOCAL_SRC_FILES := \
test_02.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_02_android
+LOCAL_MODULE := test_02_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -51,14 +51,14 @@ LOCAL_SRC_FILES := \
test_03.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_03_android
+LOCAL_MODULE := test_03_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -72,14 +72,14 @@ LOCAL_SRC_FILES := \
test_04.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_04_android
+LOCAL_MODULE := test_04_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -93,14 +93,14 @@ LOCAL_SRC_FILES := \
test_05.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_05_android
+LOCAL_MODULE := test_05_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -114,14 +114,14 @@ LOCAL_SRC_FILES := \
test_06.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_06_android
+LOCAL_MODULE := test_06_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -135,14 +135,14 @@ LOCAL_SRC_FILES := \
test_07.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_07_android
+LOCAL_MODULE := test_07_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -156,14 +156,14 @@ LOCAL_SRC_FILES := \
test_08.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_08_android
+LOCAL_MODULE := test_08_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -177,14 +177,14 @@ LOCAL_SRC_FILES := \
test_09.c \
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_09_android
+LOCAL_MODULE := test_09_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -198,14 +198,14 @@ LOCAL_SRC_FILES := \
test_10.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_10_android
+LOCAL_MODULE := test_10_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
@@ -219,14 +219,14 @@ LOCAL_SRC_FILES := \
test_11.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
$(TOPDIR)/hardware/intel/libva/va/
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := test_11_android
+LOCAL_MODULE := test_11_android
LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
diff --git a/test/basic/Makefile.am b/test/basic/Makefile.am
index c84c264..21f48dd 100644
--- a/test/basic/Makefile.am
+++ b/test/basic/Makefile.am
@@ -20,12 +20,31 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \
- test_07 test_08 test_09 test_10 test_11
-
-AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/src/x11
-
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib)
+noinst_PROGRAMS = \
+ test_01 \
+ test_02 \
+ test_03 \
+ test_04 \
+ test_05 \
+ test_06 \
+ test_07 \
+ test_08 \
+ test_09 \
+ test_10 \
+ test_11 \
+ $(NULL)
+
+AM_CFLAGS = \
+ -DIN_LIBVA \
+ -I$(top_srcdir) \
+ $(X11_CFLAGS) \
+ $(NULL)
+
+TEST_LIBS = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/va/libva-x11.la \
+ $(X11_LIBS) \
+ $(NULL)
test_01_LDADD = $(TEST_LIBS)
test_01_SOURCES = test_01.c
@@ -60,9 +79,9 @@ test_10_SOURCES = test_10.c
test_11_LDADD = $(TEST_LIBS)
test_11_SOURCES = test_11.c
-EXTRA_DIST = test_common.c
+EXTRA_DIST = test_common.c test_x11.c
-valgrind: $(check_PROGRAMS)
- for a in $(check_PROGRAMS); do \
+valgrind: $(noinst_PROGRAMS)
+ for a in $(noinst_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
diff --git a/doc/Makefile.am b/test/common/Makefile.am
similarity index 56%
copy from doc/Makefile.am
copy to test/common/Makefile.am
index 36c3905..763847d 100644
--- a/doc/Makefile.am
+++ b/test/common/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
+# 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
@@ -7,11 +7,11 @@
# 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.
@@ -20,33 +20,44 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-all: html
-install-data-local: install-html
+noinst_LTLIBRARIES = libva-display.la
-EXTRA_DIST = \
- Doxyfile \
+libva_display_cflags = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ -I$(top_builddir) \
+ -DIN_LIBVA \
$(NULL)
-VA_HEADER_DIR = $(top_srcdir)/va
-VA_HEADER_FILES = \
+libva_display_libs = \
+ $(top_builddir)/va/libva.la \
$(NULL)
-export VA_HEADER_DIR
-export VA_HEADER_FILES
-html-out/index.html: Doxyfile $(VA_HEADER_FILES)
- $(DOXYGEN) $<
-
-if ENABLE_DOCS
-html: html-out/index.html
-install-html-local:
- install -d $(DESTDIR)$(docdir)/html
- install -m 0644 html-out/* $(DESTDIR)$(docdir)/html
-uninstall-local:
- rm -rf $(DESTDIR)$(docdir)/html
+source_c = va_display.c
+source_h = va_display.h
+
+if USE_X11
+source_c += va_display_x11.c
+libva_display_cflags += $(X11_CFLAGS)
+libva_display_libs += $(top_builddir)/va/libva-x11.la $(X11_LIBS)
+endif
+
+if USE_DRM
+source_c += va_display_drm.c
+libva_display_cflags += $(DRM_CFLAGS)
+libva_display_libs += $(top_builddir)/va/libva-drm.la $(DRM_LIBS)
+endif
+
+if USE_WAYLAND
+source_c += va_display_wayland.c
+libva_display_cflags += $(WAYLAND_CFLAGS)
+libva_display_libs += $(top_builddir)/va/libva-wayland.la $(WAYLAND_LIBS)
endif
-clean-local:
- rm -rf html-out
+libva_display_la_SOURCES= $(source_c)
+noinst_HEADERS = $(source_h)
+libva_display_la_CFLAGS = $(libva_display_cflags)
+libva_display_la_LIBADD = $(libva_display_libs)
# Extra clean files so that maintainer-clean removes *everything*
MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/common/va_display.c b/test/common/va_display.c
new file mode 100644
index 0000000..dd58dd2
--- /dev/null
+++ b/test/common/va_display.c
@@ -0,0 +1,166 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+#include <va/va.h>
+#include "va_display.h"
+
+extern const VADisplayHooks va_display_hooks_android;
+extern const VADisplayHooks va_display_hooks_wayland;
+extern const VADisplayHooks va_display_hooks_x11;
+extern const VADisplayHooks va_display_hooks_drm;
+
+static const VADisplayHooks *g_display_hooks;
+static const VADisplayHooks *g_display_hooks_available[] = {
+#ifdef ANDROID
+ &va_display_hooks_android,
+#else
+#ifdef HAVE_VA_WAYLAND
+ &va_display_hooks_wayland,
+#endif
+#ifdef HAVE_VA_X11
+ &va_display_hooks_x11,
+#endif
+#ifdef HAVE_VA_DRM
+ &va_display_hooks_drm,
+#endif
+#endif
+ NULL
+};
+
+static const char *g_display_name;
+
+static const char *
+get_display_name(int argc, char *argv[])
+{
+ const char *display_name = NULL;
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--display") != 0)
+ continue;
+ argv[i] = NULL;
+
+ if (++i < argc) {
+ display_name = argv[i];
+ argv[i] = NULL;
+ }
+ }
+ return display_name;
+}
+
+static void
+print_display_names(void)
+{
+ const VADisplayHooks **h;
+
+ printf("Available displays:\n");
+ for (h = g_display_hooks_available; *h != NULL; h++)
+ printf(" %s\n", (*h)->name);
+}
+
+static void
+sanitize_args(int *argc, char *argv[])
+{
+ char **out_args = argv;
+ int i, n = *argc;
+
+ for (i = 0; i < n; i++) {
+ if (argv[i])
+ *out_args++ = argv[i];
+ }
+ *out_args = NULL;
+ *argc = out_args - argv;
+}
+
+void
+va_init_display_args(int *argc, char *argv[])
+{
+ const char *display_name;
+
+ display_name = get_display_name(*argc, argv);
+ if (display_name && strcmp(display_name, "help") == 0) {
+ print_display_names();
+ exit(0);
+ }
+ g_display_name = display_name;
+
+ sanitize_args(argc, argv);
+}
+
+VADisplay
+va_open_display(void)
+{
+ VADisplay va_dpy = NULL;
+ unsigned int i;
+
+ for (i = 0; !va_dpy && g_display_hooks_available[i]; i++) {
+ g_display_hooks = g_display_hooks_available[i];
+ if (g_display_name &&
+ strcmp(g_display_name, g_display_hooks->name) != 0)
+ continue;
+ if (!g_display_hooks->open_display)
+ continue;
+ va_dpy = g_display_hooks->open_display();
+ }
+
+ if (!va_dpy) {
+ fprintf(stderr, "error: failed to initialize display");
+ if (g_display_name)
+ fprintf(stderr, " '%s'", g_display_name);
+ fprintf(stderr, "\n");
+ abort();
+ }
+ return va_dpy;
+}
+
+void
+va_close_display(VADisplay va_dpy)
+{
+ if (!va_dpy)
+ return;
+
+ if (g_display_hooks && g_display_hooks->close_display)
+ g_display_hooks->close_display(va_dpy);
+}
+
+VAStatus
+va_put_surface(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+)
+{
+ if (!va_dpy)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ if (g_display_hooks && g_display_hooks->put_surface)
+ return g_display_hooks->put_surface(va_dpy, surface, src_rect, dst_rect);
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/test/basic/test_x11.c b/test/common/va_display.h
similarity index 57%
copy from test/basic/test_x11.c
copy to test/common/va_display.h
index df8f362..4ed33e0 100644
--- a/test/basic/test_x11.c
+++ b/test/common/va_display.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,40 +22,43 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-Display *dpy;
-VADisplay va_dpy;
-VAStatus va_status;
-VAProfile *profiles ;
-int major_version, minor_version;
-
-void test_init()
-{
- dpy = XOpenDisplay(NULL);
- ASSERT( dpy );
- status("XOpenDisplay: dpy = %08x\n", dpy);
-
- va_dpy = vaGetDisplay(dpy);
- ASSERT( va_dpy );
- status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
-
- va_status = vaInitialize(va_dpy, &major_version, &minor_version);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
-}
+#ifndef VA_DISPLAY_H
+#define VA_DISPLAY_H
+
+#include <va/va.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ const char *name;
+ VADisplay (*open_display) (void);
+ void (*close_display) (VADisplay va_dpy);
+ VAStatus (*put_surface) (VADisplay va_dpy, VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect);
+} VADisplayHooks;
+
+void
+va_init_display_args(int *argc, char *argv[]);
+
+VADisplay
+va_open_display(void);
-void test_terminate()
-{
- va_status = vaTerminate(va_dpy);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaTerminate\n");
+void
+va_close_display(VADisplay va_dpy);
- XCloseDisplay(dpy);
- status("XCloseDisplay\n");
+VAStatus
+va_put_surface(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+);
- if (profiles)
- {
- free(profiles);
- profiles = NULL;
- }
+#ifdef __cplusplus
}
+#endif
+#endif /* VA_DISPLAY_H */
diff --git a/test/encode/h264encode_android.cpp b/test/common/va_display_android.cpp
similarity index 60%
copy from test/encode/h264encode_android.cpp
copy to test/common/va_display_android.cpp
index 84b315b..1e45ae9 100644
--- a/test/encode/h264encode_android.cpp
+++ b/test/common/va_display_android.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,14 +22,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*
- * it is a real program to show how VAAPI encoding work,
- * It does H264 element stream level encoding on auto-generated YUV data
- *
- * gcc -o h264encode h264encode -lva -lva-x11
- * ./h264encode -w <width> -h <height> -n <frame_num>
- *
- */
+#include <va/va_android.h>
+#include "va_display.h"
+
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
@@ -39,32 +34,59 @@
#include <surfaceflinger/ISurface.h>
#include <surfaceflinger/SurfaceComposerClient.h>
#include <binder/MemoryHeapBase.h>
-#define Display unsigned int
-using namespace android;
-#include "../android_winsys.cpp"
-#include "h264encode_common.c"
+static unsigned int fake_display = 0xdeada01d;
+using namespace android;
sp<SurfaceComposerClient> client;
sp<Surface> android_surface;
sp<ISurface> android_isurface;
sp<SurfaceControl> surface_ctrl;
+#include "../android_winsys.cpp"
+
+static VADisplay
+va_open_display_android(void)
+{
+ return vaGetDisplay(&fake_display);
+}
-static int display_surface(int frame_id, int *exit_encode)
+static void
+va_close_display_android(VADisplay va_dpy)
{
- VAStatus va_status;
+}
+static VAStatus
+va_put_surface_android(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+)
+{
sp<ProcessState> proc(ProcessState::self());
ProcessState::self()->startThreadPool();
printf("Create window0 for thread0\n");
- SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 0, 0, win_width, win_height);
- va_status = vaPutSurface(va_dpy, surface_id[frame_id], android_isurface,
- 0,0, frame_width, frame_height,
- 0,0, win_width, win_height,
- NULL,0,0);
+ SURFACE_CREATE(
+ client,
+ surface_ctrl,
+ android_surface,
+ android_isurface,
+ dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height);
- *exit_encode = 0;
- return 0;
+ return vaPutSurface(va_dpy, surface, android_isurface,
+ src_rect->x, src_rect->y,
+ src_rect->width, src_rect->height,
+ dst_rect->x, dst_rect->y,
+ dst_rect->width, dst_rect->height,
+ NULL, 0,
+ VA_FRAME_PICTURE);
}
+extern "C"
+const VADisplayHooks va_display_hooks_android = {
+ "android",
+ va_open_display_android,
+ va_close_display_android,
+ va_put_surface_android
+};
diff --git a/test/basic/test_android.c b/test/common/va_display_drm.c
similarity index 54%
copy from test/basic/test_android.c
copy to test/common/va_display_drm.c
index 2bb247a..aa9f60a 100644
--- a/test/basic/test_android.c
+++ b/test/common/va_display_drm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * 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
@@ -8,11 +8,11 @@
* 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.
@@ -21,42 +21,55 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#define Display unsigned int
-Display *dpy;
-VADisplay va_dpy;
-VAStatus va_status;
-VAProfile *profiles ;
-int major_version, minor_version;
-
-void test_init()
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#ifdef IN_LIBVA
+# include "va/drm/va_drm.h"
+#else
+# include <va/va_drm.h>
+#endif
+#include "va_display.h"
+
+static int drm_fd = -1;
+
+static VADisplay
+va_open_display_drm(void)
{
- dpy = (Display*)malloc(sizeof(Display));
- *(dpy) = 0x18c34078;
- ASSERT( dpy );
- status("malloc Display: dpy = %08x\n", dpy);
-
- va_dpy = vaGetDisplay(dpy);
- ASSERT( va_dpy );
- status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
-
- va_status = vaInitialize(va_dpy, &major_version, &minor_version);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
+ drm_fd = open("/dev/dri/card0", O_RDWR);
+ if (drm_fd < 0) {
+ fprintf(stderr, "error: can't open DRM connection!\n");
+ return NULL;
+ }
+ return vaGetDisplayDRM(drm_fd);
}
-void test_terminate()
+static void
+va_close_display_drm(VADisplay va_dpy)
{
- va_status = vaTerminate(va_dpy);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaTerminate\n");
+ if (drm_fd < 0)
+ return;
- free(dpy);
- status("free Display\n");
+ close(drm_fd);
+ drm_fd = -1;
+}
- if (profiles)
- {
- free(profiles);
- profiles = NULL;
- }
+
+static VAStatus
+va_put_surface_drm(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+)
+{
+ return VA_STATUS_ERROR_OPERATION_FAILED;
}
+const VADisplayHooks va_display_hooks_drm = {
+ "drm",
+ va_open_display_drm,
+ va_close_display_drm,
+ va_put_surface_drm,
+};
diff --git a/test/common/va_display_wayland.c b/test/common/va_display_wayland.c
new file mode 100644
index 0000000..332d16d
--- /dev/null
+++ b/test/common/va_display_wayland.c
@@ -0,0 +1,194 @@
+/*
+ * 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 <string.h>
+#ifdef IN_LIBVA
+# include "va/wayland/va_wayland.h"
+#else
+# include <va/va_wayland.h>
+#endif
+#include "va_display.h"
+
+struct display {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct wl_shell *shell;
+ struct wl_shell_surface *shell_surface;
+ struct wl_surface *surface;
+ unsigned int ref_count;
+ int event_fd;
+ unsigned int event_mask;
+};
+
+static struct display *g_display;
+
+static void
+display_handle_global(
+ struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version,
+ void *data
+)
+{
+ struct display * const d = data;
+
+ if (strcmp(interface, "wl_compositor") == 0)
+ d->compositor = wl_display_bind(display, id, &wl_compositor_interface);
+ else if (strcmp(interface, "wl_shell") == 0)
+ d->shell = wl_display_bind(display, id, &wl_shell_interface);
+}
+
+static int
+event_mask_update(uint32_t mask, void *data)
+{
+ struct display * const d = data;
+
+ d->event_mask = mask;
+ return 0;
+}
+
+static VADisplay
+va_open_display_wayland(void)
+{
+ struct display *d;
+
+ if (g_display) {
+ d = g_display;
+ d->ref_count++;
+ }
+ else {
+ d = calloc(1, sizeof(*d));
+ if (!d)
+ return NULL;
+ d->event_fd = -1;
+
+ d->display = wl_display_connect(NULL);
+ if (!d->display) {
+ free(d);
+ return NULL;
+ }
+ wl_display_set_user_data(d->display, d);
+ wl_display_add_global_listener(d->display, display_handle_global, d);
+ d->event_fd = wl_display_get_fd(d->display, event_mask_update, d);
+ wl_display_iterate(d->display, d->event_mask);
+
+ d->ref_count = 1;
+ g_display = d;
+ }
+ return vaGetDisplayWl(d->display);
+}
+
+static void
+va_close_display_wayland(VADisplay va_dpy)
+{
+ struct display * const d = g_display;
+
+ if (!d || --d->ref_count > 0)
+ return;
+
+ if (d->surface) {
+ wl_surface_destroy(d->surface);
+ d->surface = NULL;
+ }
+
+ if (d->shell_surface) {
+ wl_shell_surface_destroy(d->shell_surface);
+ d->shell_surface = NULL;
+ }
+
+ if (d->shell) {
+ wl_shell_destroy(d->shell);
+ d->shell = NULL;
+ }
+
+ if (d->compositor) {
+ wl_compositor_destroy(d->compositor);
+ d->compositor = NULL;
+ }
+
+ if (d->display) {
+ wl_display_disconnect(d->display);
+ d->display = NULL;
+ }
+ free(g_display);
+ g_display = NULL;
+}
+
+static int
+ensure_window(VADisplay va_dpy, unsigned int width, unsigned int height)
+{
+ struct display * const d = g_display;
+
+ if (!d->surface) {
+ d->surface = wl_compositor_create_surface(d->compositor);
+ if (!d->surface)
+ return 0;
+ }
+
+ if (!d->shell_surface) {
+ d->shell_surface = wl_shell_get_shell_surface(d->shell, d->surface);
+ if (!d->shell_surface)
+ return 0;
+ wl_shell_surface_set_toplevel(d->shell_surface);
+ }
+ return 1;
+}
+
+static VAStatus
+va_put_surface_wayland(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+)
+{
+ struct display * const d = g_display;
+ VAStatus va_status;
+ struct wl_buffer *buffer;
+
+ if (!ensure_window(va_dpy, dst_rect->width, dst_rect->height))
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+ va_status = vaGetSurfaceBufferWl(va_dpy, surface, VA_FRAME_PICTURE, &buffer);
+ if (va_status != VA_STATUS_SUCCESS)
+ return va_status;
+
+ wl_surface_attach(d->surface, buffer, 0, 0);
+ wl_surface_damage(
+ d->surface,
+ dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height
+ );
+
+ wl_display_flush(d->display);
+ return VA_STATUS_SUCCESS;
+}
+
+const VADisplayHooks va_display_hooks_wayland = {
+ "wayland",
+ va_open_display_wayland,
+ va_close_display_wayland,
+ va_put_surface_wayland,
+};
diff --git a/test/common/va_display_x11.c b/test/common/va_display_x11.c
new file mode 100644
index 0000000..336bf86
--- /dev/null
+++ b/test/common/va_display_x11.c
@@ -0,0 +1,139 @@
+/*
+ * 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 <stdio.h>
+#include <stdbool.h>
+#include <va/va_x11.h>
+#include "va_display.h"
+
+static Display *x11_display;
+static Window x11_window;
+
+static VADisplay
+va_open_display_x11(void)
+{
+ x11_display = XOpenDisplay(NULL);
+ if (!x11_display) {
+ fprintf(stderr, "error: can't connect to X server!\n");
+ return NULL;
+ }
+ return vaGetDisplay(x11_display);
+}
+
+static void
+va_close_display_x11(VADisplay va_dpy)
+{
+ if (!x11_display)
+ return;
+
+ if (x11_window) {
+ XUnmapWindow(x11_display, x11_window);
+ XDestroyWindow(x11_display, x11_window);
+ x11_window = None;
+ }
+ XCloseDisplay(x11_display);
+ x11_display = NULL;
+}
+
+static int
+ensure_window(unsigned int width, unsigned int height)
+{
+ Window win, rootwin;
+ unsigned int black_pixel, white_pixel;
+ int screen;
+
+ if (!x11_display)
+ return 0;
+
+ if (x11_window) {
+ XResizeWindow(x11_display, x11_window, width, height);
+ return 1;
+ }
+
+ screen = DefaultScreen(x11_display);
+ rootwin = RootWindow(x11_display, screen);
+ black_pixel = BlackPixel(x11_display, screen);
+ white_pixel = WhitePixel(x11_display, screen);
+
+ win = XCreateSimpleWindow(
+ x11_display,
+ rootwin,
+ 0, 0, width, height,
+ 1, black_pixel, white_pixel
+ );
+ if (!win)
+ return 0;
+ x11_window = win;
+
+ XMapWindow(x11_display, x11_window);
+ XSync(x11_display, False);
+ return 1;
+}
+
+static inline bool
+validate_rect(const VARectangle *rect)
+{
+ return (rect &&
+ rect->x >= 0 &&
+ rect->y >= 0 &&
+ rect->width > 0 &&
+ rect->height > 0);
+}
+
+static VAStatus
+va_put_surface_x11(
+ VADisplay va_dpy,
+ VASurfaceID surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect
+)
+{
+ unsigned int win_width, win_height;
+
+ if (!va_dpy)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+ if (surface == VA_INVALID_SURFACE)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+ if (!validate_rect(src_rect) || !validate_rect(dst_rect))
+ return VA_STATUS_ERROR_INVALID_PARAMETER;
+
+ win_width = dst_rect->x + dst_rect->width;
+ win_height = dst_rect->y + dst_rect->height;
+ if (!ensure_window(win_width, win_height))
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ return vaPutSurface(va_dpy, surface, x11_window,
+ src_rect->x, src_rect->y,
+ src_rect->width, src_rect->height,
+ dst_rect->x, dst_rect->y,
+ dst_rect->width, dst_rect->height,
+ NULL, 0,
+ VA_FRAME_PICTURE);
+}
+
+const VADisplayHooks va_display_hooks_x11 = {
+ "x11",
+ va_open_display_x11,
+ va_close_display_x11,
+ va_put_surface_x11,
+};
diff --git a/test/decode/Android.mk b/test/decode/Android.mk
index 3541ee2..d1053b7 100755
--- a/test/decode/Android.mk
+++ b/test/decode/Android.mk
@@ -6,20 +6,22 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- mpeg2vldemo.cpp \
+ mpeg2vldemo.cpp \
+ ../common/va_display.c \
+ ../common/va_display_android.cpp
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/hardware/intel/libva/va/ \
- $(TARGET_OUT_HEADERS)/X11
+ $(LOCAL_PATH)/../../va \
+ $(LOCAL_PATH)/../common \
+ $(TARGET_OUT_HEADERS)/libva
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := mpeg2vldemo
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui
include $(BUILD_EXECUTABLE)
diff --git a/test/decode/Makefile.am b/test/decode/Makefile.am
index c1d3798..6fffd31 100644
--- a/test/decode/Makefile.am
+++ b/test/decode/Makefile.am
@@ -22,17 +22,28 @@
bin_PROGRAMS = mpeg2vldemo loadjpeg
-INCLUDES = -I$(top_srcdir)
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/test/common \
+ $(NULL)
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) $(top_builddir)/va/$(libvacorelib) -lX11
+TEST_LIBS = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/test/common/libva-display.la \
+ $(NULL)
-mpeg2vldemo_LDADD = $(TEST_LIBS)
-mpeg2vldemo_SOURCES = mpeg2vldemo.cpp
+mpeg2vldemo_LDADD = $(TEST_LIBS)
+mpeg2vldemo_SOURCES = mpeg2vldemo.cpp
-loadjpeg_LDADD = $(TEST_LIBS)
-loadjpeg_SOURCES = loadjpeg.c tinyjpeg.c
+loadjpeg_LDADD = $(TEST_LIBS)
+loadjpeg_SOURCES = loadjpeg.c tinyjpeg.c
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
+
+EXTRA_DIST = \
+ tinyjpeg.h \
+ tinyjpeg-internal.h \
+ $(NULL)
diff --git a/test/decode/loadjpeg.c b/test/decode/loadjpeg.c
index 3e1a60b..7a9a235 100644
--- a/test/decode/loadjpeg.c
+++ b/test/decode/loadjpeg.c
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include "va_display.h"
static void exitmessage(const char *message) __attribute__((noreturn));
static void exitmessage(const char *message)
@@ -87,7 +88,7 @@ int convert_one_image(const char *infilename)
/* Get the size of the image */
tinyjpeg_get_size(jdec, &width, &height);
- printf("Decoding JPEG image %xx%x...\n", width, height);
+ printf("Decoding JPEG image %dx%d...\n", width, height);
if (tinyjpeg_decode(jdec) < 0)
exitmessage(tinyjpeg_get_errorstring(jdec));
@@ -114,6 +115,8 @@ int main(int argc, char *argv[])
unsigned int duration;
int current_argument;
+ va_init_display_args(&argc, argv);
+
if (argc < 2)
usage();
diff --git a/test/decode/mpeg2vldemo.cpp b/test/decode/mpeg2vldemo.cpp
index efdf260..db090f8 100644
--- a/test/decode/mpeg2vldemo.cpp
+++ b/test/decode/mpeg2vldemo.cpp
@@ -43,30 +43,7 @@
#include <fcntl.h>
#include <assert.h>
#include <va/va.h>
-
-#ifdef ANDROID
-#include <va/va_android.h>
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-#include <surfaceflinger/ISurfaceComposer.h>
-#include <surfaceflinger/Surface.h>
-#include <surfaceflinger/ISurface.h>
-#include <surfaceflinger/SurfaceComposerClient.h>
-#include <binder/MemoryHeapBase.h>
-#define Display unsigned int
-
-using namespace android;
-sp<SurfaceComposerClient> client;
-sp<Surface> android_surface;
-sp<ISurface> android_isurface;
-sp<SurfaceControl> surface_ctrl;
-#include "../android_winsys.cpp"
-#else
-#include <va/va_x11.h>
-#include <X11/Xlib.h>
-#endif
+#include "va_display.h"
#define CHECK_VASTATUS(va_status,func) \
if (va_status != VA_STATUS_SUCCESS) { \
@@ -169,28 +146,16 @@ int main(int argc,char **argv)
VAContextID context_id;
VABufferID pic_param_buf,iqmatrix_buf,slice_param_buf,slice_data_buf;
int major_ver, minor_ver;
- Display *x11_display;
VADisplay va_dpy;
VAStatus va_status;
int putsurface=0;
+ va_init_display_args(&argc, argv);
+
if (argc > 1)
putsurface=1;
-#ifdef ANDROID
- x11_display = (Display*)malloc(sizeof(Display));
- *(x11_display ) = 0x18c34078;
-#else
- x11_display = XOpenDisplay(":0.0");
-#endif
-
- if (x11_display == NULL) {
- fprintf(stderr, "Can't connect X server!\n");
- exit(-1);
- }
-
- assert(x11_display);
- va_dpy = vaGetDisplay(x11_display);
+ va_dpy = va_open_display();
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
assert(va_status == VA_STATUS_SUCCESS);
@@ -285,29 +250,20 @@ int main(int argc,char **argv)
CHECK_VASTATUS(va_status, "vaSyncSurface");
if (putsurface) {
-#ifdef ANDROID
- sp<ProcessState> proc(ProcessState::self());
- ProcessState::self()->startThreadPool();
+ VARectangle src_rect, dst_rect;
- printf("Create window0 for thread0\n");
- SURFACE_CREATE(client,surface_ctrl,android_surface, android_isurface, 0, 0, WIN_WIDTH, WIN_HEIGHT);
+ src_rect.x = 0;
+ src_rect.y = 0;
+ src_rect.width = CLIP_WIDTH;
+ src_rect.height = CLIP_HEIGHT;
- va_status = vaPutSurface(va_dpy, surface_id, android_isurface,
- 0,0,CLIP_WIDTH,CLIP_HEIGHT,
- 0,0,WIN_WIDTH,WIN_HEIGHT,
- NULL,0,0);
-#else
- Window win;
- win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
- WIN_WIDTH,WIN_HEIGHT, 0, 0, WhitePixel(x11_display, 0));
- XMapWindow(x11_display, win);
- XSync(x11_display, False);
- va_status = vaPutSurface(va_dpy, surface_id, win,
- 0,0,CLIP_WIDTH,CLIP_HEIGHT,
- 0,0,WIN_WIDTH,WIN_HEIGHT,
- NULL,0,0);
-#endif
- CHECK_VASTATUS(va_status, "vaPutSurface");
+ dst_rect.x = 0;
+ dst_rect.y = 0;
+ dst_rect.width = WIN_WIDTH;
+ dst_rect.height = WIN_HEIGHT;
+
+ va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect);
+ CHECK_VASTATUS(va_status, "vaPutSurface");
}
printf("press any key to exit\n");
getchar();
@@ -317,11 +273,6 @@ int main(int argc,char **argv)
vaDestroyContext(va_dpy,context_id);
vaTerminate(va_dpy);
-#ifdef ANDROID
- free(x11_display);
-#else
- XCloseDisplay(x11_display);
-#endif
-
+ va_close_display(va_dpy);
return 0;
}
diff --git a/test/decode/tinyjpeg-internal.h b/test/decode/tinyjpeg-internal.h
index c54b98e..9caead5 100644
--- a/test/decode/tinyjpeg-internal.h
+++ b/test/decode/tinyjpeg-internal.h
@@ -106,8 +106,11 @@ struct jdec_private
struct component component_infos[COMPONENTS];
unsigned int nf_components;
unsigned char Q_tables[COMPONENTS][64]; /* quantization tables, zigzag*/
+ unsigned char Q_tables_valid[COMPONENTS];
struct huffman_table HTDC[HUFFMAN_TABLES]; /* DC huffman tables */
+ unsigned char HTDC_valid[HUFFMAN_TABLES];
struct huffman_table HTAC[HUFFMAN_TABLES]; /* AC huffman tables */
+ unsigned char HTAC_valid[HUFFMAN_TABLES];
struct jpeg_sos cur_sos; /* current sos values*/
int default_huffman_table_initialized;
int restart_interval;
diff --git a/test/decode/tinyjpeg.c b/test/decode/tinyjpeg.c
index 5b77b18..111971c 100644
--- a/test/decode/tinyjpeg.c
+++ b/test/decode/tinyjpeg.c
@@ -48,8 +48,7 @@
#include <fcntl.h>
#include <assert.h>
#include <va/va.h>
-#include <va/va_x11.h>
-#include <X11/Xlib.h>
+#include "va_display.h"
#define cY 0
@@ -60,6 +59,14 @@
#define BLACK_U 127
#define BLACK_V 127
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+#define ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
+
#if DEBUG
#define trace(fmt, args...) do { \
fprintf(stderr, fmt, ## args); \
@@ -75,15 +82,15 @@
/* Global variable to return the last error found while deconding */
static char error_string[256];
-static VAHuffmanTableBufferJPEG default_huffman_table_param={
+static VAHuffmanTableBufferJPEGBaseline default_huffman_table_param={
huffman_table:
{
// lumiance component
{
- dc_bits:{0,1,5,1,1,1,1,1,1,0,0,0}, // 12 bits is ok for baseline profile
- dc_huffval:{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b},
- ac_bits:{0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125},
- ac_huffval:{
+ num_dc_codes:{0,1,5,1,1,1,1,1,1,0,0,0}, // 12 bits is ok for baseline profile
+ dc_values:{0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b},
+ num_ac_codes:{0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125},
+ ac_values:{
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
@@ -109,10 +116,10 @@ static VAHuffmanTableBufferJPEG default_huffman_table_param={
},
// chrom component
{
- dc_bits:{0,3,1,1,1,1,1,1,1,1,1,0}, // 12 bits is ok for baseline profile
- dc_huffval:{0,1,2,3,4,5,6,7,8,9,0xa,0xb},
- ac_bits:{0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119},
- ac_huffval:{
+ num_dc_codes:{0,3,1,1,1,1,1,1,1,1,1,0}, // 12 bits is ok for baseline profile
+ dc_values:{0,1,2,3,4,5,6,7,8,9,0xa,0xb},
+ num_ac_codes:{0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119},
+ ac_values:{
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
@@ -149,10 +156,12 @@ static int build_default_huffman_tables(struct jdec_private *priv)
return 0;
for (i = 0; i < 4; i++) {
- memcpy(priv->HTDC[i].bits, default_huffman_table_param.huffman_table[i].dc_bits, 16);
- memcpy(priv->HTDC[i].values, default_huffman_table_param.huffman_table[i].dc_huffval, 16);
- memcpy(priv->HTAC[i].bits, default_huffman_table_param.huffman_table[i].ac_bits, 16);
- memcpy(priv->HTAC[i].values, default_huffman_table_param.huffman_table[i].ac_huffval, 256);
+ priv->HTDC_valid[i] = 1;
+ memcpy(priv->HTDC[i].bits, default_huffman_table_param.huffman_table[i].num_dc_codes, 16);
+ memcpy(priv->HTDC[i].values, default_huffman_table_param.huffman_table[i].dc_values, 16);
+ priv->HTAC_valid[i] = 1;
+ memcpy(priv->HTAC[i].bits, default_huffman_table_param.huffman_table[i].num_ac_codes, 16);
+ memcpy(priv->HTAC[i].values, default_huffman_table_param.huffman_table[i].ac_values, 256);
}
priv->default_huffman_table_initialized = 1;
return 0;
@@ -203,6 +212,7 @@ static int parse_DQT(struct jdec_private *priv, const unsigned char *stream)
error("No more 4 quantization table is supported (got %d)\n", qi);
#endif
memcpy(priv->Q_tables[qi&0x0F], stream, 64);
+ priv->Q_tables_valid[qi & 0x0f] = 1;
stream += 64;
}
trace("< DQT marker\n");
@@ -316,7 +326,7 @@ static int parse_DHT(struct jdec_private *priv, const unsigned char *stream)
memcpy(priv->HTAC[index & 0xf].bits, stream, 16);
}
else {
- memcpy(priv->HTDC[index & 0xf].bits, stream, 12);
+ memcpy(priv->HTDC[index & 0xf].bits, stream, 16);
}
count = 0;
@@ -334,9 +344,11 @@ static int parse_DHT(struct jdec_private *priv, const unsigned char *stream)
if (Tc) {
memcpy(priv->HTAC[index & 0xf].values, stream, count);
+ priv->HTAC_valid[index & 0xf] = 1;
}
else {
memcpy(priv->HTDC[index & 0xf].values, stream, count);
+ priv->HTDC_valid[index & 0xf] = 1;
}
length -= 1;
@@ -530,23 +542,13 @@ int tinyjpeg_decode(struct jdec_private *priv)
VAContextID context_id;
VABufferID pic_param_buf,iqmatrix_buf,huffmantable_buf,slice_param_buf,slice_data_buf;
int major_ver, minor_ver;
- Display *x11_display;
VADisplay va_dpy;
VAStatus va_status;
int max_h_factor, max_v_factor;
int putsurface=1;
- unsigned int i;
-
- x11_display = XOpenDisplay(":0.0");
-
- if (x11_display == NULL) {
- fprintf(stderr, "Can't connect X server!\n");
- exit(-1);
- }
+ unsigned int i, j;
- assert(x11_display);
-
- va_dpy = vaGetDisplay(x11_display);
+ va_dpy = va_open_display();
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
assert(va_status == VA_STATUS_SUCCESS);
@@ -576,8 +578,10 @@ int tinyjpeg_decode(struct jdec_private *priv)
&attrib, 1,&config_id);
CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
- va_status = vaCreateSurfaces(va_dpy,priv->width,priv->height, //alignment?
- VA_RT_FORMAT_YUV420, 1, &surface_id);
+ va_status = vaCreateSurfaces(va_dpy,
+ priv->width,priv->height, //alignment?
+ VA_RT_FORMAT_YUV420,
+ 1, &surface_id);
CHECK_VASTATUS(va_status, "vaCreateSurfaces");
/* Create a context for this decode pipe */
@@ -588,14 +592,11 @@ int tinyjpeg_decode(struct jdec_private *priv)
1,
&context_id);
CHECK_VASTATUS(va_status, "vaCreateContext");
-
- VAPictureParameterBufferJPEG pic_param;
+ VAPictureParameterBufferJPEGBaseline pic_param;
memset(&pic_param, 0, sizeof(pic_param));
- pic_param.type = VA_JPEG_SOF0; // tinyjpeg support baseline profile only, does it match va capability?
- pic_param.sample_precision = 8; // tinyjpeg support baseline profile only, does it match va capability?
- pic_param.image_width = priv->width;
- pic_param.image_height = priv->height;
+ pic_param.picture_width = priv->width;
+ pic_param.picture_height = priv->height;
pic_param.num_components = priv->nf_components;
for (i=0; i<pic_param.num_components; i++) { // tinyjpeg support 3 components only, does it match va?
@@ -604,47 +605,60 @@ int tinyjpeg_decode(struct jdec_private *priv)
pic_param.components[i].v_sampling_factor = priv->component_infos[i].Vfactor;
pic_param.components[i].quantiser_table_selector = priv->component_infos[i].quant_table_index;
}
-
- pic_param.roi.enabled = 0;
- pic_param.roi.start_x = 0;
- pic_param.roi.start_y = 0;
- pic_param.roi.end_x = 0;
- pic_param.roi.end_y = 0;
- pic_param.rotation = 0;
va_status = vaCreateBuffer(va_dpy, context_id,
- VAPictureParameterBufferType, // VAPictureParameterBufferJPEG?
- sizeof(VAPictureParameterBufferJPEG),
+ VAPictureParameterBufferType, // VAPictureParameterBufferJPEGBaseline?
+ sizeof(VAPictureParameterBufferJPEGBaseline),
1, &pic_param,
&pic_param_buf);
CHECK_VASTATUS(va_status, "vaCreateBuffer");
- VAIQMatrixBufferJPEG iq_matrix;
+ VAIQMatrixBufferJPEGBaseline iq_matrix;
+ const unsigned int num_quant_tables =
+ MIN(COMPONENTS, ARRAY_ELEMS(iq_matrix.load_quantiser_table));
// todo, only mask it if non-default quant matrix is used. do we need build default quant matrix?
- memset(&iq_matrix, 0, sizeof(VAIQMatrixBufferJPEG));
- for (i = 0; i < COMPONENTS; i++) {
- iq_matrix.precision[i] = 0;
- memcpy(iq_matrix.quantiser_matrix[i], priv->Q_tables[i], 64);
+ memset(&iq_matrix, 0, sizeof(VAIQMatrixBufferJPEGBaseline));
+ for (i = 0; i < num_quant_tables; i++) {
+ if (!priv->Q_tables_valid[i])
+ continue;
+ iq_matrix.load_quantiser_table[i] = 1;
+ for (j = 0; j < 64; j++)
+ iq_matrix.quantiser_table[i][j] = priv->Q_tables[i][j];
}
va_status = vaCreateBuffer(va_dpy, context_id,
- VAIQMatrixBufferType, // VAIQMatrixBufferJPEG?
- sizeof(VAIQMatrixBufferJPEG),
+ VAIQMatrixBufferType, // VAIQMatrixBufferJPEGBaseline?
+ sizeof(VAIQMatrixBufferJPEGBaseline),
1, &iq_matrix,
&iqmatrix_buf );
CHECK_VASTATUS(va_status, "vaCreateBuffer");
- VAHuffmanTableBufferJPEG huffman_table;
- memset(&huffman_table, 0, sizeof(VAHuffmanTableBufferJPEG));
- for (i = 0; i < COMPONENTS; i++) {
- memcpy(huffman_table.huffman_table[i].dc_bits, priv->HTDC[i].bits, 16);
- memcpy(huffman_table.huffman_table[i].dc_huffval, priv->HTDC[i].values, 16);
- memcpy(huffman_table.huffman_table[i].ac_bits, priv->HTAC[i].bits, 16);
- memcpy(huffman_table.huffman_table[i].ac_huffval, priv->HTAC[i].values, 256);
+ VAHuffmanTableBufferJPEGBaseline huffman_table;
+ const unsigned int num_huffman_tables =
+ MIN(COMPONENTS, ARRAY_ELEMS(huffman_table.load_huffman_table));
+ memset(&huffman_table, 0, sizeof(VAHuffmanTableBufferJPEGBaseline));
+ assert(sizeof(huffman_table.huffman_table[0].num_dc_codes) ==
+ sizeof(priv->HTDC[0].bits));
+ assert(sizeof(huffman_table.huffman_table[0].dc_values[0]) ==
+ sizeof(priv->HTDC[0].values[0]));
+ for (i = 0; i < num_huffman_tables; i++) {
+ if (!priv->HTDC_valid[i] || !priv->HTAC_valid[i])
+ continue;
+ huffman_table.load_huffman_table[i] = 1;
+ memcpy(huffman_table.huffman_table[i].num_dc_codes, priv->HTDC[i].bits,
+ sizeof(huffman_table.huffman_table[i].num_dc_codes));
+ memcpy(huffman_table.huffman_table[i].dc_values, priv->HTDC[i].values,
+ sizeof(huffman_table.huffman_table[i].dc_values));
+ memcpy(huffman_table.huffman_table[i].num_ac_codes, priv->HTAC[i].bits,
+ sizeof(huffman_table.huffman_table[i].num_ac_codes));
+ memcpy(huffman_table.huffman_table[i].ac_values, priv->HTAC[i].values,
+ sizeof(huffman_table.huffman_table[i].ac_values));
+ memset(huffman_table.huffman_table[i].pad, 0,
+ sizeof(huffman_table.huffman_table[i].pad));
}
va_status = vaCreateBuffer(va_dpy, context_id,
- VAHuffmanTableBufferType, // VAHuffmanTableBufferJPEG?
- sizeof(VAHuffmanTableBufferJPEG),
+ VAHuffmanTableBufferType, // VAHuffmanTableBufferJPEGBaseline?
+ sizeof(VAHuffmanTableBufferJPEGBaseline),
1, &huffman_table,
&huffmantable_buf );
CHECK_VASTATUS(va_status, "vaCreateBuffer");
@@ -652,7 +666,7 @@ int tinyjpeg_decode(struct jdec_private *priv)
// one slice for whole image?
max_h_factor = priv->component_infos[0].Hfactor;
max_v_factor = priv->component_infos[0].Vfactor;
- static VASliceParameterBufferJPEG slice_param;
+ static VASliceParameterBufferJPEGBaseline slice_param;
slice_param.slice_data_size = priv->stream_end - priv->stream;
slice_param.slice_data_offset = 0;
slice_param.slice_data_flag = VA_SLICE_DATA_FLAG_ALL;
@@ -660,17 +674,17 @@ int tinyjpeg_decode(struct jdec_private *priv)
slice_param.slice_vertical_position = 0;
slice_param.num_components = priv->cur_sos.nr_components;
for (i = 0; i < slice_param.num_components; i++) {
- slice_param.components[i].component_id = priv->cur_sos.components[i].component_id; /* FIXME: set to values specified in SOS */
- slice_param.components[i].dc_selector = priv->cur_sos.components[i].dc_selector; /* FIXME: set to values specified in SOS */
- slice_param.components[i].ac_selector = priv->cur_sos.components[i].ac_selector; /* FIXME: set to values specified in SOS */
+ slice_param.components[i].component_selector = priv->cur_sos.components[i].component_id; /* FIXME: set to values specified in SOS */
+ slice_param.components[i].dc_table_selector = priv->cur_sos.components[i].dc_selector; /* FIXME: set to values specified in SOS */
+ slice_param.components[i].ac_table_selector = priv->cur_sos.components[i].ac_selector; /* FIXME: set to values specified in SOS */
}
slice_param.restart_interval = priv->restart_interval;
slice_param.num_mcus = ((priv->width+max_h_factor*8-1)/(max_h_factor*8))*
((priv->height+max_v_factor*8-1)/(max_v_factor*8)); // ?? 720/16?
va_status = vaCreateBuffer(va_dpy, context_id,
- VASliceParameterBufferType, // VASliceParameterBufferJPEG?
- sizeof(VASliceParameterBufferJPEG),
+ VASliceParameterBufferType, // VASliceParameterBufferJPEGBaseline?
+ sizeof(VASliceParameterBufferJPEGBaseline),
1,
&slice_param, &slice_param_buf);
CHECK_VASTATUS(va_status, "vaCreateBuffer");
@@ -708,16 +722,16 @@ int tinyjpeg_decode(struct jdec_private *priv)
CHECK_VASTATUS(va_status, "vaSyncSurface");
if (putsurface) {
- Window win;
- win = XCreateSimpleWindow(x11_display, RootWindow(x11_display, 0), 0, 0,
- priv->width,priv->height, 0, 0, WhitePixel(x11_display, 0));
- XMapWindow(x11_display, win);
- XSync(x11_display, False);
- va_status = vaPutSurface(va_dpy, surface_id, win,
- 0,0,priv->width,priv->height,
- 0,0,priv->width,priv->height,
- NULL,0,0);
- CHECK_VASTATUS(va_status, "vaPutSurface");
+ VARectangle src_rect, dst_rect;
+
+ src_rect.x = 0;
+ src_rect.y = 0;
+ src_rect.width = priv->width;
+ src_rect.height = priv->height;
+ dst_rect = src_rect;
+
+ va_status = va_put_surface(va_dpy, surface_id, &src_rect, &dst_rect);
+ CHECK_VASTATUS(va_status, "vaPutSurface");
}
printf("press any key to exit\n");
getchar();
@@ -727,8 +741,7 @@ int tinyjpeg_decode(struct jdec_private *priv)
vaDestroyContext(va_dpy,context_id);
vaTerminate(va_dpy);
- XCloseDisplay(x11_display);
-
+ va_close_display(va_dpy);
return 0;
}
const char *tinyjpeg_get_errorstring(struct jdec_private *priv)
diff --git a/test/egl/Makefile.am b/test/egl/Makefile.am
deleted file mode 100644
index eadd26b..0000000
--- a/test/egl/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-bin_PROGRAMS = va_egl
-
-INCLUDES = -I$(top_srcdir) \
- $(GLESv1_CM_CFLAGS)
-
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/libva-egl.la -lpthread -lX11 -lEGL $(GLESv1_CM_LIBS)
-
-va_egl_LDADD = $(TEST_LIBS)
-va_egl_SOURCES = va_egl_x11.c
-
-EXTRA_DIST =
-
-valgrind: $(bin_PROGRAMS)
- for a in $(bin_PROGRAMS); do \
- valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
- done
diff --git a/test/egl/va_egl_x11.c b/test/egl/va_egl_x11.c
deleted file mode 100644
index 7d7521d..0000000
--- a/test/egl/va_egl_x11.c
+++ /dev/null
@@ -1,598 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysym.h>
-#include <GLES/gl.h>
-#include <GLES/glext.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <va/va_x11.h>
-#include <va/va_egl.h>
-
-struct va_egl_context
-{
- Display *x11_dpy;
- Window win;
-
- EGLDisplay egl_dpy;
- EGLContext egl_ctx;
- EGLSurface egl_surf;
- unsigned int egl_target;
- EGLClientBuffer egl_buffer;
- EGLImageKHR egl_image;
- PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
- PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_hkr;
- PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glegl_image_target_texture2d_oes;
-
- VADisplay va_dpy;
- VASurfaceID va_surface;
- VASurfaceEGL va_egl_surface;
-
- int x, y;
- unsigned int width, height;
- GLuint texture;
- GLfloat ar;
- unsigned int box_width;
- unsigned char ydata;
-};
-
-static void
-va_egl_fini_egl(struct va_egl_context *ctx)
-{
- eglMakeCurrent(ctx->egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- eglTerminate(ctx->egl_dpy);
-}
-
-static int
-va_egl_init_egl(struct va_egl_context *ctx)
-{
- EGLint egl_major, egl_minor;
- const char *s;
-
- ctx->egl_dpy = eglGetDisplay(ctx->x11_dpy);
-
- if (!ctx->egl_dpy) {
- printf("Error: eglGetDisplay() failed\n");
- return -1;
- }
-
- if (!eglInitialize(ctx->egl_dpy, &egl_major, &egl_minor)) {
- printf("Error: eglInitialize() failed\n");
- return -1;
- }
-
- s = eglQueryString(ctx->egl_dpy, EGL_VERSION);
- printf("EGL_VERSION = %s\n", s);
-
- return 0;
-}
-
-static int
-yuvgen_planar(int width, int height,
- unsigned char *Y_start, int Y_pitch,
- unsigned char *U_start, int U_pitch,
- unsigned char *V_start, int V_pitch,
- int UV_interleave, int box_width, unsigned char ydata)
-{
- int row;
-
- /* copy Y plane */
- for (row = 0; row < height; row++) {
- unsigned char *Y_row = Y_start + row * Y_pitch;
- int jj, xpos, ypos;
-
- ypos = (row / box_width) & 0x1;
-
- for (jj = 0; jj < width; jj++) {
- xpos = ((jj) / box_width) & 0x1;
-
- if ((xpos == 0) && (ypos == 0))
- Y_row[jj] = ydata;
- if ((xpos == 1) && (ypos == 1))
- Y_row[jj] = ydata;
-
- if ((xpos == 1) && (ypos == 0))
- Y_row[jj] = 0xff - ydata;
- if ((xpos == 0) && (ypos == 1))
- Y_row[jj] = 0xff - ydata;
- }
- }
-
- /* copy UV data */
- for( row = 0; row < height/2; row++) {
- unsigned short value = 0x80;
-
- if (UV_interleave) {
- unsigned short *UV_row = (unsigned short *)(U_start + row * U_pitch);
-
- memset(UV_row, value, width);
- } else {
- unsigned char *U_row = U_start + row * U_pitch;
- unsigned char *V_row = V_start + row * V_pitch;
-
- memset(U_row, value, width / 2);
- memset(V_row, value, width / 2);
- }
- }
-
- return 0;
-}
-
-static int
-va_egl_upload_surface(struct va_egl_context *ctx)
-{
- VAImage surface_image;
- void *surface_p = NULL, *U_start, *V_start;
-
- vaDeriveImage(ctx->va_dpy, ctx->va_surface, &surface_image);
-
- vaMapBuffer(ctx->va_dpy, surface_image.buf, &surface_p);
-
- U_start = (char *)surface_p + surface_image.offsets[1];
- V_start = (char *)surface_p + surface_image.offsets[2];
-
- /* assume surface is planar format */
- yuvgen_planar(surface_image.width, surface_image.height,
- (unsigned char *)surface_p, surface_image.pitches[0],
- (unsigned char *)U_start, surface_image.pitches[1],
- (unsigned char *)V_start, surface_image.pitches[2],
- (surface_image.format.fourcc==VA_FOURCC_NV12),
- ctx->box_width, ctx->ydata);
-
- vaUnmapBuffer(ctx->va_dpy,surface_image.buf);
-
- vaDestroyImage(ctx->va_dpy,surface_image.image_id);
-
- return 0;
-}
-
-static void
-va_egl_fini_va(struct va_egl_context *ctx)
-{
- vaDestroySurfaces(ctx->va_dpy, &ctx->va_surface, 1);
- vaTerminate(ctx->va_dpy);
-}
-
-static int
-va_egl_init_va(struct va_egl_context *ctx)
-{
- VAStatus va_status;
- int major_ver, minor_ver;
-
- ctx->va_dpy = vaGetDisplayEGL(ctx->x11_dpy, ctx->egl_dpy);
-
- if (!ctx->va_dpy) {
- printf("Error: vaGetDisplayEGL() failed\n");
- return -1;
- }
-
- va_status = vaInitialize(ctx->va_dpy, &major_ver, &minor_ver);
-
- if (va_status != VA_STATUS_SUCCESS) {
- printf("Error: vaInitialize() failed\n");
- return -1;
- }
-
- va_status = vaCreateSurfaces(ctx->va_dpy,
- ctx->width, ctx->height,
- VA_RT_FORMAT_YUV420,
- 1, &ctx->va_surface);
-
- if (va_status != VA_STATUS_SUCCESS) {
- printf("Error: vaCreateSurfaces() failed\n");
- return -1;
- }
-
- va_egl_upload_surface(ctx);
-
- return 0;
-}
-
-static void
-va_egl_make_window(struct va_egl_context *ctx, const char *title)
-{
- int scrnum;
- XSetWindowAttributes attr;
- unsigned long mask;
- Window root;
- XVisualInfo *visInfo, visTemplate;
- int num_visuals;
- EGLConfig config;
- EGLint num_configs, vid;
- const EGLint attribs[] = {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
- EGL_NONE
- };
-
- scrnum = DefaultScreen(ctx->x11_dpy);
- root = RootWindow(ctx->x11_dpy, scrnum);
-
- if (!eglChooseConfig(ctx->egl_dpy, attribs, &config, 1, &num_configs) ||
- !num_configs) {
- printf("Error: couldn't get an EGL visual config\n");
-
- return;
- }
-
- if (!eglGetConfigAttrib(ctx->egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
- printf("Error: eglGetConfigAttrib() failed\n");
-
- return;
- }
-
- /* The X window visual must match the EGL config */
- visTemplate.visualid = vid;
- visInfo = XGetVisualInfo(ctx->x11_dpy, VisualIDMask, &visTemplate, &num_visuals);
-
- if (!visInfo) {
- printf("Error: couldn't get X visual\n");
-
- return;
- }
-
- /* window attributes */
- attr.background_pixel = 0;
- attr.border_pixel = 0;
- attr.colormap = XCreateColormap(ctx->x11_dpy, root, visInfo->visual, AllocNone);
- attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
- attr.override_redirect = 0;
- mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
-
- ctx->win = XCreateWindow(ctx->x11_dpy,
- root,
- ctx->x, ctx->y,
- ctx->width, ctx->height,
- 0, visInfo->depth, InputOutput,
- visInfo->visual, mask, &attr);
-
- /* set hints and properties */
- {
- XSizeHints sizehints;
- sizehints.x = ctx->x;
- sizehints.y = ctx->y;
- sizehints.width = ctx->width;
- sizehints.height = ctx->height;
- sizehints.flags = USSize | USPosition;
- XSetNormalHints(ctx->x11_dpy, ctx->win, &sizehints);
- XSetStandardProperties(ctx->x11_dpy, ctx->win, title, title,
- None, (char **)NULL, 0, &sizehints);
- }
-
- eglBindAPI(EGL_OPENGL_ES_API);
-
- ctx->egl_ctx = eglCreateContext(ctx->egl_dpy, config, EGL_NO_CONTEXT, NULL);
-
- if (!ctx->egl_ctx) {
- printf("Error: eglCreateContext() failed\n");
-
- return;
- }
-
- ctx->egl_surf = eglCreateWindowSurface(ctx->egl_dpy, config, ctx->win, NULL);
- eglMakeCurrent(ctx->egl_dpy, ctx->egl_surf, ctx->egl_surf, ctx->egl_ctx);
- XFree(visInfo);
-}
-
-static int
-va_egl_init_extension(struct va_egl_context *ctx)
-{
- const char *exts;
-
- exts = eglQueryString(ctx->egl_dpy, EGL_EXTENSIONS);
- ctx->egl_create_image_khr =
- (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR");
- ctx->egl_destroy_image_hkr =
- (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR");
-
- if (!exts ||
- !strstr(exts, "EGL_KHR_image_base") ||
- !ctx->egl_create_image_khr ||
- !ctx->egl_destroy_image_hkr) {
- printf("EGL does not support EGL_KHR_image_base\n");
- return -1;
- }
-
- exts = (const char *)glGetString(GL_EXTENSIONS);
- ctx->glegl_image_target_texture2d_oes =
- (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
-
- if (!exts ||
- !strstr(exts, "GL_OES_EGL_image") ||
- !ctx->glegl_image_target_texture2d_oes) {
- printf("OpenGL ES does not support GL_OES_EGL_image\n");
- return -1;
- }
-
- return 0;
-}
-
-static void
-va_egl_fini_gles(struct va_egl_context *ctx)
-{
- glDeleteTextures(1, &ctx->texture);
-}
-
-static int
-va_egl_init_gles(struct va_egl_context *ctx)
-{
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glColor4f(1.0, 1.0, 1.0, 1.0);
-
- glDisable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
-
- glGenTextures(1, &ctx->texture);
- glBindTexture(GL_TEXTURE_2D, ctx->texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glEnable(GL_TEXTURE_2D);
-
- return 0;
-}
-
-static void
-va_egl_fini_va_egl(struct va_egl_context *ctx)
-{
- if (ctx->egl_image)
- ctx->egl_destroy_image_hkr(ctx->egl_dpy, ctx->egl_image);
-
- vaDeassociateSurfaceEGL(ctx->va_dpy, ctx->va_egl_surface);
- vaDestroySurfaceEGL(ctx->va_dpy, ctx->va_egl_surface);
-}
-
-static int
-va_egl_init_va_egl(struct va_egl_context *ctx)
-{
- VAStatus va_status;
- int num_max_targets = 0, num_targets = 0;
- int num_max_attributes = 0, num_attribs = 0;
- unsigned int *target_list = NULL;
- EGLint *img_attribs = NULL;
-
- num_targets = num_max_targets = vaMaxNumSurfaceTargetsEGL(ctx->va_dpy);
-
- if (num_max_targets < 1) {
- printf("Error: vaMaxNumSurfaceTargetsEGL() returns %d\n", num_max_targets);
- return -1;
- }
-
- num_attribs = num_max_attributes = vaMaxNumSurfaceAttributesEGL(ctx->va_dpy);
-
- if (num_max_attributes < 1) {
- printf("Error: vaMaxNumSurfaceAttributesEGL() returns %d\n", num_max_attributes);
- return -1;
- }
-
- target_list = malloc(num_max_targets * sizeof(unsigned int));
- va_status = vaQuerySurfaceTargetsEGL(ctx->va_dpy,
- target_list,
- &num_targets);
-
- if (va_status != VA_STATUS_SUCCESS || num_targets < 1) {
- printf("Error: vaQuerySurfaceTargetsEGL() failed\n");
- return -1;
- }
-
- va_status = vaCreateSurfaceEGL(ctx->va_dpy,
- target_list[0],
- ctx->width, ctx->height,
- &ctx->va_egl_surface);
-
- if (va_status != VA_STATUS_SUCCESS) {
- printf("Error: vaCreateSurfaceEGL() failed\n");
- return -1;
- }
-
- va_status = vaAssociateSurfaceEGL(ctx->va_dpy,
- ctx->va_egl_surface,
- ctx->va_surface,
- 0);
-
- if (va_status != VA_STATUS_SUCCESS) {
- printf("Error: vaAssociateSurfaceEGL() failed\n");
- return -1;
- }
-
- img_attribs = malloc(2 * num_max_attributes * sizeof(EGLint));
- va_status = vaGetSurfaceInfoEGL(ctx->va_dpy,
- ctx->va_egl_surface,
- &ctx->egl_target,
- &ctx->egl_buffer,
- img_attribs,
- &num_attribs);
-
- if (va_status != VA_STATUS_SUCCESS) {
- printf("Error: vaGetSurfaceInfoEGL() failed\n");
- return -1;
- }
-
- ctx->egl_image = ctx->egl_create_image_khr(ctx->egl_dpy,
- EGL_NO_CONTEXT,
- ctx->egl_target,
- ctx->egl_buffer,
- img_attribs);
-
- vaSyncSurfaceEGL(ctx->va_dpy, ctx->va_egl_surface);
- ctx->glegl_image_target_texture2d_oes(GL_TEXTURE_2D,
- (GLeglImageOES)ctx->egl_image);
-
- return 0;
-}
-
-static void
-va_egl_fini(struct va_egl_context *ctx)
-{
- va_egl_fini_gles(ctx);
- va_egl_fini_va(ctx);
- va_egl_fini_egl(ctx);
- va_egl_fini_gles(ctx);
- va_egl_fini_va_egl(ctx);
-
- // XDestroyWindow(ctx->x11_dpy, ctx->win);
- XCloseDisplay(ctx->x11_dpy);
-}
-
-static int
-va_egl_init(struct va_egl_context *ctx, int argc, char **argv)
-{
- memset(ctx, 0, sizeof(*ctx));
- ctx->x11_dpy = XOpenDisplay(NULL);
- ctx->width = 320;
- ctx->height = 320;
- ctx->ar = 1.0;
- ctx->box_width = 16;
- ctx->ydata = 0xff;
-
- if (!ctx->x11_dpy) {
- printf("Error: couldn't open display %s\n", getenv("DISPLAY"));
- return -1;
- }
-
- if (va_egl_init_egl(ctx) != 0)
- return -1;
-
- if (va_egl_init_va(ctx) != 0)
- return -1;
-
- va_egl_make_window(ctx, "VA/EGL");
- va_egl_init_extension(ctx);
- va_egl_init_gles(ctx);
- va_egl_init_va_egl(ctx);
-
- return 0;
-}
-
-static void
-va_egl_reshape(struct va_egl_context *ctx, int width, int height)
-{
- GLfloat ar = (GLfloat) width / (GLfloat) height;
-
- ctx->width = width;
- ctx->height = height;
- ctx->ar = ar;
-
- glViewport(0, 0, (GLint) width, (GLint) height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrthof(-ar, ar, -ar, ar, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-static void
-va_egl_draw(struct va_egl_context *ctx)
-{
- const GLfloat verts[][3] = {
- { -ctx->ar, -ctx->ar, 0 },
- { ctx->ar, -ctx->ar, 0 },
- { ctx->ar, ctx->ar, 0 },
- { -ctx->ar, ctx->ar, 0 }
- };
- const GLfloat texs[][2] = {
- { 0, 0 },
- { 1, 0 },
- { 1, 1 },
- { 0, 1 }
- };
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- glVertexPointer(3, GL_FLOAT, 0, verts);
- glTexCoordPointer(2, GL_FLOAT, 0, texs);
-
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-}
-
-static void
-va_egl_event_loop(struct va_egl_context *ctx)
-{
- while (1) {
- int redraw = 0;
-
- if (XPending(ctx->x11_dpy) > 0) {
- XEvent event;
- XNextEvent(ctx->x11_dpy, &event);
-
- switch (event.type) {
- case Expose:
- redraw = 1;
- break;
-
- case ConfigureNotify:
- va_egl_reshape(ctx, event.xconfigure.width, event.xconfigure.height);
- redraw = 1;
- break;
-
- case KeyPress:
- {
- char buffer[10];
- int code;
- code = XLookupKeysym(&event.xkey, 0);
-
- if (code == XK_y) {
- ctx->ydata += 0x10;
- va_egl_upload_surface(ctx);
- vaSyncSurfaceEGL(ctx->va_dpy, ctx->va_egl_surface);
- ctx->glegl_image_target_texture2d_oes(GL_TEXTURE_2D,
- (GLeglImageOES)ctx->egl_image);
- redraw = 1;
- } else {
- XLookupString(&event.xkey, buffer, sizeof(buffer),
- NULL, NULL);
-
- if (buffer[0] == 27) {
- /* escape */
- return;
- }
- }
- }
-
- break;
-
- default:
- ; /*no-op*/
- }
- }
-
- if (redraw) {
- va_egl_draw(ctx);
- eglSwapBuffers(ctx->egl_dpy, ctx->egl_surf);
- }
- }
-}
-
-static void
-va_egl_run(struct va_egl_context *ctx)
-{
- XMapWindow(ctx->x11_dpy, ctx->win);
- va_egl_reshape(ctx, ctx->width, ctx->height);
- va_egl_event_loop(ctx);
-}
-
-int
-main(int argc, char *argv[])
-{
- struct va_egl_context ctx;
-
- printf("Usage: press 'y' to change Y plane \n\n");
-
- if (va_egl_init(&ctx, argc, argv) == 0) {
- va_egl_run(&ctx);
- va_egl_fini(&ctx);
- }
-
- return 0;
-}
diff --git a/test/encode/Android.mk b/test/encode/Android.mk
index 8395cdd..9bc662a 100755
--- a/test/encode/Android.mk
+++ b/test/encode/Android.mk
@@ -6,21 +6,22 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- h264encode_android.cpp \
- #h264encode_x11.c \
+ ../common/va_display.c \
+ ../common/va_display_android.cpp \
+ avcenc.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva \
- $(TOPDIR)/hardware/intel/libva/va/ \
- $(TARGET_OUT_HEADERS)/X11
+ $(LOCAL_PATH)/../../va \
+ $(LOCAL_PATH)/../common \
+ $(TARGET_OUT_HEADERS)/libva
LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := h264encode
+LOCAL_MODULE := avcenc
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui
include $(BUILD_EXECUTABLE)
diff --git a/test/encode/Makefile.am b/test/encode/Makefile.am
index de42d31..db7f13c 100644
--- a/test/encode/Makefile.am
+++ b/test/encode/Makefile.am
@@ -20,17 +20,28 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-bin_PROGRAMS = h264encode avcenc
+bin_PROGRAMS = avcenc
+if USE_X11
+bin_PROGRAMS += h264encode
+endif
-INCLUDES = -I$(top_srcdir)
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(NULL)
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) $(top_builddir)/va/$(libvacorelib) -lpthread -lX11
+h264encode_SOURCES = h264encode_x11.c
+h264encode_CFLAGS = $(X11_CFLAGS)
+h264encode_LDADD = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/va/libva-x11.la \
+ $(X11_LIBS)
-h264encode_LDADD = $(TEST_LIBS)
-h264encode_SOURCES = h264encode_x11.c
-
-avcenc_LDADD= $(TEST_LIBS)
-avcenc_SOURCES= avcenc.c
+avcenc_SOURCES = avcenc.c
+avcenc_CFLAGS = -I$(top_srcdir)/test/common
+avcenc_LDADD = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/test/common/libva-display.la
EXTRA_DIST = h264encode_common.c
diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c
index 17411d8..a29e55b 100644
--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -1,16 +1,38 @@
/*
+ * 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.
+ */
+/*
* Simple AVC encoder based on libVA.
*
* Usage:
* ./avcenc <width> <height> <input file> <output file> [qp]
*/
+#include "sysdeps.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
-#include <X11/Xlib.h>
-
#include <unistd.h>
#include <sys/types.h>
@@ -20,7 +42,7 @@
#include <time.h>
#include <va/va.h>
-#include <va/va_x11.h>
+#include "va_display.h"
#define NAL_REF_IDC_NONE 0
#define NAL_REF_IDC_LOW 1
@@ -49,7 +71,6 @@
exit(1); \
}
-static Display *x11_display;
static VADisplay va_dpy;
static VAContextID context_id;
static VAConfigID config_id;
@@ -77,10 +98,7 @@ static void create_encode_pipe()
int major_ver, minor_ver;
VAStatus va_status;
- x11_display = XOpenDisplay(":0.0");
- assert(x11_display);
-
- va_dpy = vaGetDisplay(x11_display);
+ va_dpy = va_open_display();
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
CHECK_VASTATUS(va_status, "vaInitialize");
@@ -135,7 +153,7 @@ static void destory_encode_pipe()
vaDestroyContext(va_dpy,context_id);
vaDestroyConfig(va_dpy,config_id);
vaTerminate(va_dpy);
- XCloseDisplay(x11_display);
+ va_close_display(va_dpy);
}
/***************************************************
@@ -368,7 +386,7 @@ get_coded_bitsteam_length(unsigned char *buffer, int buffer_length)
}
static unsigned int
-swap32(unsigned int val)
+va_swap32(unsigned int val)
{
unsigned char *pval = (unsigned char *)&val;
@@ -396,7 +414,7 @@ bitstream_end(bitstream *bs, FILE *avc_fp)
size_t w_items;
if (bit_offset) {
- bs->buffer[pos] = swap32((bs->buffer[pos] << bit_left));
+ bs->buffer[pos] = va_swap32((bs->buffer[pos] << bit_left));
}
do {
@@ -423,7 +441,7 @@ bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits)
} else {
size_in_bits -= bit_left;
bs->buffer[pos] = (bs->buffer[pos] << bit_left) | (val >> size_in_bits);
- bs->buffer[pos] = swap32(bs->buffer[pos]);
+ bs->buffer[pos] = va_swap32(bs->buffer[pos]);
if (pos + 1 == bs->max_size_in_dword) {
bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING;
@@ -750,6 +768,8 @@ int main(int argc, char *argv[])
clock_t start_clock, end_clock;
float encoding_time;
+ va_init_display_args(&argc, argv);
+
if(argc != 5 && argc != 6) {
printf("Usage: %s <width> <height> <input_yuvfile> <output_avcfile> [qp]\n", argv[0]);
return -1;
diff --git a/test/putsurface/Android.mk b/test/putsurface/Android.mk
index cce0b63..03edb61 100644
--- a/test/putsurface/Android.mk
+++ b/test/putsurface/Android.mk
@@ -10,7 +10,7 @@ LOCAL_SRC_FILES := \
#putsurface_x11.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva
@@ -18,7 +18,7 @@ LOCAL_C_INCLUDES += \
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := putsurface
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libui libsurfaceflinger_client
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui
include $(BUILD_EXECUTABLE)
diff --git a/test/putsurface/Makefile.am b/test/putsurface/Makefile.am
index fbf23d3..15b3348 100644
--- a/test/putsurface/Makefile.am
+++ b/test/putsurface/Makefile.am
@@ -22,12 +22,34 @@
bin_PROGRAMS = putsurface
-INCLUDES = -I$(top_srcdir)
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(NULL)
-TEST_LIBS = $(top_builddir)/va/$(libvabackendlib) $(top_builddir)/va/$(libvacorelib) -lpthread -lX11
+TEST_CFLAGS = \
+ -DIN_LIBVA \
+ $(NULL)
-putsurface_LDADD = $(TEST_LIBS)
-putsurface_SOURCES = putsurface_x11.c
+TEST_LIBS = \
+ $(top_builddir)/va/libva.la \
+ -lpthread \
+ $(NULL)
+
+putsurface_SOURCES = putsurface_x11.c
+putsurface_CFLAGS = $(X11_CFLAGS) $(TEST_CFLAGS)
+putsurface_LDADD = $(X11_LIBS) $(TEST_LIBS) \
+ $(top_builddir)/va/libva-x11.la \
+ $(NULL)
+
+if USE_WAYLAND
+bin_PROGRAMS += putsurface_wayland
+putsurface_wayland_SOURCES = putsurface_wayland.c
+putsurface_wayland_CFLAGS = $(WAYLAND_CFLAGS) $(TEST_CFLAGS)
+putsurface_wayland_LDADD = $(WAYLAND_LIBS) $(TEST_LIBS) \
+ $(top_builddir)/va/libva-wayland.la \
+ $(NULL)
+endif
EXTRA_DIST = putsurface_common.c
diff --git a/test/putsurface/putsurface_wayland.c b/test/putsurface/putsurface_wayland.c
new file mode 100644
index 0000000..3e1d495
--- /dev/null
+++ b/test/putsurface/putsurface_wayland.c
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 2011 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 <stddef.h>
+#include <errno.h>
+#include <sys/select.h>
+#ifdef IN_LIBVA
+# include "va/wayland/va_wayland.h"
+#else
+# include <va/va_wayland.h>
+#endif
+#include <wayland-server.h>
+
+static void *open_display(void);
+static void close_display(void *win_display);
+static int create_window(void *win_display,
+ int x, int y, int width, int height);
+static int check_window_event(void *win_display, void *drawable,
+ int *width, int *height, int *quit);
+
+struct display;
+struct drawable;
+
+static VAStatus
+va_put_surface(
+ VADisplay dpy,
+ struct drawable *wl_drawable,
+ VASurfaceID va_surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect,
+ const VARectangle *cliprects,
+ unsigned int num_cliprects,
+ unsigned int flags
+);
+
+/* Glue code for the current PutSurface test design */
+#define CAST_DRAWABLE(a) (struct drawable *)(a)
+
+static inline VADisplay
+vaGetDisplay(VANativeDisplay native_dpy)
+{
+ return vaGetDisplayWl(native_dpy);
+}
+
+static VAStatus
+vaPutSurface(
+ VADisplay dpy,
+ VASurfaceID surface,
+ struct drawable *wl_drawable,
+ short src_x,
+ short src_y,
+ unsigned short src_w,
+ unsigned short src_h,
+ short dst_x,
+ short dst_y,
+ unsigned short dst_w,
+ unsigned short dst_h,
+ const VARectangle *cliprects,
+ unsigned int num_cliprects,
+ unsigned int flags
+)
+{
+ VARectangle src_rect, dst_rect;
+
+ src_rect.x = src_x;
+ src_rect.y = src_y;
+ src_rect.width = src_w;
+ src_rect.height = src_h;
+
+ dst_rect.x = src_x;
+ dst_rect.y = src_y;
+ dst_rect.width = src_w;
+ dst_rect.height = src_h;
+ return va_put_surface(dpy, wl_drawable, surface, &src_rect, &dst_rect,
+ cliprects, num_cliprects, flags);
+}
+
+#include "putsurface_common.c"
+
+struct display {
+ struct wl_display *display;
+ struct wl_compositor *compositor;
+ struct wl_shell *shell;
+ uint32_t mask;
+ int event_fd;
+};
+
+struct drawable {
+ struct wl_display *display;
+ struct wl_surface *surface;
+ unsigned int redraw_pending : 1;
+};
+
+static void
+frame_redraw_callback(void *data, struct wl_callback *callback, uint32_t time)
+{
+ struct drawable * const drawable = data;
+
+ drawable->redraw_pending = 0;
+ wl_callback_destroy(callback);
+}
+
+static const struct wl_callback_listener frame_callback_listener = {
+ frame_redraw_callback
+};
+
+static VAStatus
+va_put_surface(
+ VADisplay dpy,
+ struct drawable *wl_drawable,
+ VASurfaceID va_surface,
+ const VARectangle *src_rect,
+ const VARectangle *dst_rect,
+ const VARectangle *cliprects,
+ unsigned int num_cliprects,
+ unsigned int flags
+)
+{
+ struct display *d;
+ struct wl_callback *callback;
+ VAStatus va_status;
+ struct wl_buffer *buffer;
+
+ if (!wl_drawable)
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+
+ d = wl_display_get_user_data(wl_drawable->display);
+ if (!d)
+ return VA_STATUS_ERROR_INVALID_DISPLAY;
+
+ /* Wait for the previous frame to complete redraw */
+ if (wl_drawable->redraw_pending) {
+ wl_display_flush(d->display);
+ while (wl_drawable->redraw_pending)
+ wl_display_iterate(wl_drawable->display, WL_DISPLAY_READABLE);
+ }
+
+ va_status = vaGetSurfaceBufferWl(va_dpy, va_surface, VA_FRAME_PICTURE, &buffer);
+ if (va_status != VA_STATUS_SUCCESS)
+ return va_status;
+
+ wl_surface_attach(wl_drawable->surface, buffer, 0, 0);
+ wl_surface_damage(
+ wl_drawable->surface,
+ dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height
+ );
+
+ wl_display_flush(d->display);
+ wl_drawable->redraw_pending = 1;
+ callback = wl_surface_frame(wl_drawable->surface);
+ wl_callback_add_listener(callback, &frame_callback_listener, wl_drawable);
+ return VA_STATUS_SUCCESS;
+}
+
+static void
+display_handle_global(
+ struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version,
+ void *data
+)
+{
+ struct display * const d = data;
+
+ if (strcmp(interface, "wl_compositor") == 0)
+ d->compositor = wl_display_bind(display, id, &wl_compositor_interface);
+ else if (strcmp(interface, "wl_shell") == 0)
+ d->shell = wl_display_bind(display, id, &wl_shell_interface);
+}
+
+static int
+event_mask_update(uint32_t mask, void *data)
+{
+ struct display * const d = data;
+
+ d->mask = mask;
+ return 0;
+}
+
+static void *
+open_display(void)
+{
+ struct display *d;
+
+ d = calloc(1, sizeof *d);
+ if (!d)
+ return NULL;
+
+ d->display = wl_display_connect(NULL);
+ if (!d->display)
+ return NULL;
+
+ wl_display_set_user_data(d->display, d);
+ wl_display_add_global_listener(d->display, display_handle_global, d);
+ d->event_fd = wl_display_get_fd(d->display, event_mask_update, d);
+ wl_display_iterate(d->display, d->mask);
+ return d->display;
+}
+
+static void
+close_display(void *win_display)
+{
+ struct display * const d = wl_display_get_user_data(win_display);
+
+ if (d->shell) {
+ wl_shell_destroy(d->shell);
+ d->shell = NULL;
+ }
+
+ if (d->compositor) {
+ wl_compositor_destroy(d->compositor);
+ d->compositor = NULL;
+ }
+
+ if (d->display) {
+ wl_display_disconnect(d->display);
+ d->display = NULL;
+ }
+ free(d);
+}
+
+static int
+create_window(void *win_display, int x, int y, int width, int height)
+{
+ struct wl_display * const display = win_display;
+ struct display * const d = wl_display_get_user_data(display);
+ struct wl_surface *surface1, *surface2;
+ struct wl_shell_surface *shell_surface;
+ struct wl_shell_surface *shell_surface_2;
+ struct drawable *drawable1, *drawable2;
+
+ surface1 = wl_compositor_create_surface(d->compositor);
+ shell_surface = wl_shell_get_shell_surface(d->shell, surface1);
+ wl_shell_surface_set_toplevel(shell_surface);
+
+ drawable1 = malloc(sizeof(*drawable1));
+ drawable1->display = display;
+ drawable1->surface = surface1;
+ drawable1->redraw_pending = 0;
+
+ /* global out */
+ drawable_thread0 = drawable1;
+
+ if (multi_thread == 0)
+ return 0;
+
+ surface2 = wl_compositor_create_surface(d->compositor);
+ shell_surface_2 = wl_shell_get_shell_surface(d->shell, surface2);
+ wl_shell_surface_set_toplevel(shell_surface_2);
+
+ drawable2 = malloc(sizeof(*drawable2));
+ drawable2->display = display;
+ drawable1->surface = surface2;
+ drawable2->redraw_pending = 0;
+
+ /* global out */
+ drawable_thread1 = drawable2;
+ return 0;
+}
+
+static int
+check_window_event(
+ void *win_display,
+ void *drawable,
+ int *width,
+ int *height,
+ int *quit
+)
+{
+ struct wl_display * const display = win_display;
+ struct display * const d = wl_display_get_user_data(display);
+ struct timeval tv;
+ fd_set rfds;
+ int retval;
+
+ if (check_event == 0)
+ return 0;
+
+ if (!(d->mask & WL_DISPLAY_READABLE))
+ return 0;
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ do {
+ FD_ZERO(&rfds);
+ FD_SET(d->event_fd, &rfds);
+
+ retval = select(d->event_fd + 1, &rfds, NULL, NULL, &tv);
+ if (retval < 0) {
+ perror("select");
+ break;
+ }
+ if (retval == 1)
+ wl_display_iterate(d->display, WL_DISPLAY_READABLE);
+ } while (retval > 0);
+
+#if 0
+ /* bail on any focused key press */
+ if(event.type == KeyPress) {
+ *quit = 1;
+ return 0;
+ }
+#endif
+
+#if 0
+ /* rescale the video to fit the window */
+ if(event.type == ConfigureNotify) {
+ *width = event.xconfigure.width;
+ *height = event.xconfigure.height;
+ printf("Scale window to %dx%d\n", width, height);
+ }
+#endif
+ return 0;
+}
diff --git a/test/v4l_h264/Makefile.am b/test/v4l_h264/Makefile.am
index 4fbaa67..377850a 100644
--- a/test/v4l_h264/Makefile.am
+++ b/test/v4l_h264/Makefile.am
@@ -21,3 +21,7 @@
# USE OR OTHER DEALINGS IN THE SOFTWARE.
SUBDIRS = encode decode
+
+EXTRA_DIST = \
+ README.txt \
+ $(NULL)
diff --git a/test/v4l_h264/decode/Makefile.am b/test/v4l_h264/decode/Makefile.am
index 85dc07b..4e77dd5 100644
--- a/test/v4l_h264/decode/Makefile.am
+++ b/test/v4l_h264/decode/Makefile.am
@@ -22,16 +22,18 @@
noinst_PROGRAMS = decode
-INCLUDES = -I$(top_srcdir)
-
-TEST_LIBS = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) -lX11 -ldl
-
-decode_LDADD = $(TEST_LIBS)
-decode_SOURCES = decode_x11.cpp TCPSocketServer.cpp
-
-decode_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
+decode_SOURCES = decode_x11.cpp TCPSocketServer.cpp
+decode_CFLAGS = -I$(top_srcdir) $(X11_CFLAGS)
+decode_LDADD = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/va/libva-x11.la \
+ $(X11_LIBS)
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
+
+EXTRA_DIST = \
+ TCPSocketServer.h \
+ $(NULL)
diff --git a/test/v4l_h264/encode/Makefile.am b/test/v4l_h264/encode/Makefile.am
index 875208b..7d3a9d4 100644
--- a/test/v4l_h264/encode/Makefile.am
+++ b/test/v4l_h264/encode/Makefile.am
@@ -22,16 +22,18 @@
noinst_PROGRAMS = encode
-INCLUDES = -I$(top_srcdir)
-
-TEST_LIBS = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) -lX11 -ldl
-
-encode_LDADD = $(TEST_LIBS)
-encode_SOURCES = capture.cpp avcenc.cpp TCPSocketClient.cpp
-
-capture_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
+encode_SOURCES = capture.cpp avcenc.cpp TCPSocketClient.cpp
+encode_CFLAGS = -I$(top_srcdir) $(X11_CFLAGS)
+encode_LDADD = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/va/libva-x11.la \
+ $(X11_LIBS)
valgrind: $(bin_PROGRAMS)
for a in $(bin_PROGRAMS); do \
valgrind --leak-check=full --show-reachable=yes .libs/$$a; \
done
+
+EXTRA_DIST = \
+ TCPSocketClient.h \
+ $(NULL)
diff --git a/test/v4l_h264/encode/avcenc.cpp b/test/v4l_h264/encode/avcenc.cpp
index b3afd56..8a7bcb1 100644
--- a/test/v4l_h264/encode/avcenc.cpp
+++ b/test/v4l_h264/encode/avcenc.cpp
@@ -280,7 +280,7 @@ void encoder_close()
/* 8x8 font 0-9 only - asm type format */
-unsigned char mydigits[80] {
+unsigned char mydigits[80] = {
// 0
0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00,
// 1
diff --git a/test/vainfo/Android.mk b/test/vainfo/Android.mk
index 0aac2cf..5c97388 100644
--- a/test/vainfo/Android.mk
+++ b/test/vainfo/Android.mk
@@ -6,18 +6,22 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- vainfo.c
+ vainfo.c \
+ ../common/va_display.c \
+ ../common/va_display_android.cpp
LOCAL_CFLAGS += \
-DANDROID
LOCAL_C_INCLUDES += \
- $(TARGET_OUT_HEADERS)/libva
+ $(LOCAL_PATH)/../../va \
+ $(LOCAL_PATH)/../common \
+ $(LOCAL_PATH)/../.. \
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := vainfo
-LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils
+LOCAL_SHARED_LIBRARIES := libva-android libva libdl libdrm libcutils libutils libgui
include $(BUILD_EXECUTABLE)
diff --git a/test/vainfo/Makefile.am b/test/vainfo/Makefile.am
index 190aa8b..680d099 100644
--- a/test/vainfo/Makefile.am
+++ b/test/vainfo/Makefile.am
@@ -20,18 +20,25 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
bin_PROGRAMS = vainfo
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/test/basic \
- -DLIBVA_VERSION_S="\"${LIBVA_VERSION}\"" \
+vainfo_cflags = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ -I$(top_srcdir)/test/common \
+ -I$(top_builddir) \
+ -DLIBVA_VERSION_S="\"$(LIBVA_VERSION)\"" \
$(NULL)
-vainfo_LDADD = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib) -lX11
+vainfo_libs = \
+ $(top_builddir)/va/libva.la \
+ $(top_builddir)/test/common/libva-display.la \
+ $(NULL)
-vainfo_DEPENDENCIES = $(top_builddir)/va/$(libvacorelib) $(top_builddir)/va/$(libvabackendlib)
+vainfo_SOURCES = vainfo.c
+noinst_HEADERS = $(source_h)
+vainfo_CFLAGS = $(vainfo_cflags)
+vainfo_LDADD = $(vainfo_libs)
valgrind: vainfo
valgrind --leak-check=full --show-reachable=yes .libs/vainfo;
diff --git a/test/vainfo/vainfo.c b/test/vainfo/vainfo.c
index d98a627..d09751f 100644
--- a/test/vainfo/vainfo.c
+++ b/test/vainfo/vainfo.c
@@ -22,18 +22,13 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef ANDROID
-#include <va/va_x11.h>
-#else
-#include "va/va_android.h"
-#define Display unsigned int
-#endif
-
+#include "sysdeps.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-
+#include "va_display.h"
+#include "va/sysdeps.h"
#define CHECK_VASTATUS(va_status,func, ret) \
if (va_status != VA_STATUS_SUCCESS) { \
@@ -79,12 +74,10 @@ static char * entrypoint_string(VAEntrypoint entrypoint)
int main(int argc, const char* argv[])
{
- Display *dpy;
VADisplay va_dpy;
VAStatus va_status;
int major_version, minor_version;
const char *driver;
- const char *display = getenv("DISPLAY");
const char *name = strrchr(argv[0], '/');
VAProfile profile;
VAEntrypoint entrypoint, entrypoints[10];
@@ -95,18 +88,7 @@ int main(int argc, const char* argv[])
else
name = argv[0];
-#ifndef ANDROID
- dpy = XOpenDisplay(NULL);
-#else
- dpy = (Display*)malloc(sizeof(Display));
-#endif
- if (NULL == dpy)
- {
- fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
- return 1;
- }
-
- va_dpy = vaGetDisplay(dpy);
+ va_dpy = va_open_display();
if (NULL == va_dpy)
{
fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
@@ -139,6 +121,7 @@ int main(int argc, const char* argv[])
}
vaTerminate(va_dpy);
+ va_close_display(va_dpy);
return 0;
}
diff --git a/va/Android.mk b/va/Android.mk
index 6777f6d..88f1e80 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -27,6 +27,11 @@ 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
@@ -39,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 \
@@ -48,9 +61,10 @@ LOCAL_C_INCLUDES += \
LOCAL_COPY_HEADERS := \
va.h \
- va_version.h \
va_backend.h \
- x11/va_dricommon.h
+ va_dec_jpeg.h \
+ va_drmcommon.h \
+ va_version.h
LOCAL_COPY_HEADERS_TO := libva/va
@@ -75,14 +89,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
@@ -91,7 +107,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)
@@ -105,7 +121,7 @@ LOCAL_SRC_FILES := \
egl/va_egl.c
LOCAL_CFLAGS += \
- -DANDROID
+ -DANDROID -DLOG_TAG=\"libva-egl\"
LOCAL_C_INCLUDES += \
$(TARGET_OUT_HEADERS)/libva \
@@ -130,7 +146,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 \
diff --git a/va/Makefile.am b/va/Makefile.am
index bc70435..a3bfe06 100644
--- a/va/Makefile.am
+++ b/va/Makefile.am
@@ -23,9 +23,7 @@
SUBDIRS =
INCLUDES = \
- $(LIBVA_CFLAGS) \
-I$(top_srcdir) \
- -I$(top_srcdir)/va/x11 \
-DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\""
LDADD = \
@@ -41,10 +39,10 @@ libva_source_h = \
va.h \
va_backend.h \
va_backend_tpi.h \
- va_dummy.h \
+ va_dec_jpeg.h \
+ va_drmcommon.h \
va_tpi.h \
va_version.h \
- va_x11.h \
$(NULL)
libva_source_h_priv = \
@@ -64,25 +62,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
@@ -90,22 +101,22 @@ 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 \
- $(EGL_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 BUILD_DUMMY_BACKEND
-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_LIBS) $(DRM_LIBS)
+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
-DIST_SUBDIRS = x11 glx egl dummy
+DIST_SUBDIRS = x11 glx egl drm wayland
DISTCLEANFILES = \
va_version.h \
diff --git a/va/android/Makefile.am b/va/android/Makefile.am
index 8e532ac..26f63df 100644
--- a/va/android/Makefile.am
+++ b/va/android/Makefile.am
@@ -20,13 +20,5 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 $(DRM_CFLAGS)
-
-noinst_LTLIBRARIES = libva_dummy.la
-
-libva_dummy_la_LIBADD = $(LIBVA_LIBS) -ldl -ludev
-
-libva_dummyincludedir = ${includedir}/va
-
-libva_dummy_la_SOURCES = va_dummy.c drmtest.c
-
+# Extra clean files so that maintainer-clean removes *everything*
+MAINTAINERCLEANFILES = Makefile.in
diff --git a/va/android/drmtest.c b/va/android/drmtest.c
deleted file mode 100644
index 444ef47..0000000
--- a/va/android/drmtest.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright © 2007 Intel Corporation
- *
- * 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, sublicense,
- * 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- *
- */
-
-#include <string.h>
-#include <fcntl.h>
-#include <fnmatch.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include "drmtest.h"
-
-#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
-#include <libudev.h>
-
-static int is_master(int fd)
-{
- drm_client_t client;
- int ret;
-
- /* Check that we're the only opener and authed. */
- client.idx = 0;
- ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
- assert (ret == 0);
- if (!client.auth)
- return 0;
- client.idx = 1;
- ret = ioctl(fd, DRM_IOCTL_GET_CLIENT, &client);
- if (ret != -1 || errno != EINVAL)
- return 0;
-
- return 1;
-}
-
-/** Open the first DRM device matching the criteria */
-int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id)
-{
- struct udev *udev;
- struct udev_enumerate *e;
- struct udev_device *device, *parent;
- struct udev_list_entry *entry;
- const char *pci_id, *path;
- char *tmp;
- int fd;
-
- *vendor_id = 0;
- *device_id = 0;
-
- udev = udev_new();
- if (udev == NULL) {
- fprintf(stderr, "failed to initialize udev context\n");
- return -1;
- //abort();
- }
-
- fd = -1;
- e = udev_enumerate_new(udev);
- udev_enumerate_add_match_subsystem(e, "drm");
- udev_enumerate_scan_devices(e);
- udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(e)) {
- path = udev_list_entry_get_name(entry);
- device = udev_device_new_from_syspath(udev, path);
- parent = udev_device_get_parent(device);
- /* Filter out KMS output devices. */
- if (strcmp(udev_device_get_subsystem(parent), "pci") != 0)
- continue;
- pci_id = udev_device_get_property_value(parent, "PCI_ID");
- if (fnmatch(pci_glob, pci_id, 0) != 0)
- continue;
- fd = open(udev_device_get_devnode(device), O_RDWR);
- if (fd < 0)
- continue;
- if ((flags & DRM_TEST_MASTER) && !is_master(fd)) {
- close(fd);
- fd = -1;
- continue;
- }
-
- break;
- }
- udev_enumerate_unref(e);
- udev_unref(udev);
-
- *vendor_id = (int) strtol(pci_id, &tmp, 16);
- *device_id = (int) strtol((tmp+1), NULL, 16);
-
- return fd;
-}
-
-int drm_open_any(int *vendor_id, int *device_id)
-{
- int fd = drm_open_matching("*:*", 0, vendor_id, device_id);
-
- if (fd < 0) {
- fprintf(stderr, "failed to open any drm device\n");
- //abort();
- }
-
- return fd;
-}
-
-/**
- * Open the first DRM device we can find where we end up being the master.
- */
-int drm_open_any_master(void)
-{
- int vendor_id, device_id;
- int fd = drm_open_matching("*:*", DRM_TEST_MASTER, &vendor_id, &device_id);
-
- if (fd < 0) {
- fprintf(stderr, "failed to open any drm device\n");
- abort();
- }
-
- return fd;
-
-}
diff --git a/va/android/drmtest.h b/va/android/drmtest.h
deleted file mode 100644
index 5f10f08..0000000
--- a/va/android/drmtest.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright © 2007 Intel Corporation
- *
- * 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, sublicense,
- * 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS 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.
- *
- * Authors:
- * Eric Anholt <eric at anholt.net>
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-
-#include "xf86drm.h"
-
-#define DRM_TEST_MASTER 0x01
-
-int drm_open_any(int *vendor_id, int *device_id);
-int drm_open_any_master(void);
-int drm_open_matching(const char *pci_glob, int flags, int *vendor_id, int *device_id);
diff --git a/va/android/va_android.cpp b/va/android/va_android.cpp
index 4d4885a..ebbfbd3 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,114 +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;
- char *driver_name_env;
- int vendor_id, device_id;
-
- struct {
- int vendor_id;
- int device_id;
- char driver_name[64];
- } devices[] = {
- { 0x8086, 0x4100, "pvr" },
- { 0x8086, 0x0130, "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" },
- { 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 */
@@ -211,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
@@ -234,8 +157,8 @@ VADisplay vaGetDisplay (
free(pDisplayContext);
if (pDriverContext)
free(pDriverContext);
- if (dri_state)
- free(dri_state);
+ if (drm_state)
+ free(drm_state);
}
}
@@ -246,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 */
@@ -305,4 +227,3 @@ VAStatus vaPutSurface (
destx, desty, destw, desth,
cliprects, number_cliprects, flags );
}
-#endif
diff --git a/va/android/va_dummy.c b/va/android/va_dummy.c
deleted file mode 120000
index b47bd16..0000000
--- a/va/android/va_dummy.c
+++ /dev/null
@@ -1 +0,0 @@
-va_android.cpp
\ No newline at end of file
diff --git a/doc/Makefile.am b/va/drm/Makefile.am
similarity index 67%
copy from doc/Makefile.am
copy to va/drm/Makefile.am
index 36c3905..b860ff5 100644
--- a/doc/Makefile.am
+++ b/va/drm/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
+# 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
@@ -7,11 +7,11 @@
# 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.
@@ -20,33 +20,39 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-all: html
-install-data-local: install-html
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(DRM_CFLAGS) \
+ $(NULL)
-EXTRA_DIST = \
- Doxyfile \
+source_c = \
+ va_drm.c \
+ va_drm_auth.c \
+ va_drm_utils.c \
$(NULL)
-VA_HEADER_DIR = $(top_srcdir)/va
-VA_HEADER_FILES = \
+source_h = \
+ va_drm.h \
$(NULL)
-export VA_HEADER_DIR
-export VA_HEADER_FILES
-html-out/index.html: Doxyfile $(VA_HEADER_FILES)
- $(DOXYGEN) $<
+source_h_priv = \
+ va_drm_auth.h \
+ va_drm_auth_x11.h \
+ va_drm_utils.h \
+ $(NULL)
-if ENABLE_DOCS
-html: html-out/index.html
-install-html-local:
- install -d $(DESTDIR)$(docdir)/html
- install -m 0644 html-out/* $(DESTDIR)$(docdir)/html
-uninstall-local:
- rm -rf $(DESTDIR)$(docdir)/html
+if USE_X11
+source_c += va_drm_auth_x11.c
+INCLUDES += $(X11_CFLAGS)
endif
-clean-local:
- rm -rf html-out
+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/sysdeps.h b/va/drm/va_drm.h
similarity index 63%
copy from va/sysdeps.h
copy to va/drm/va_drm.h
index 0752b17..9af3cc8 100644
--- a/va/sysdeps.h
+++ b/va/drm/va_drm.h
@@ -1,5 +1,7 @@
/*
- * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,23 +24,38 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef SYSDEPS_H
-#define SYSDEPS_H
+#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 HAVE_CONFIG_H
-# include "config.h"
+#ifdef __cplusplus
+extern "C" {
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.h>
+/**
+ * \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 ANDROID
-# define Bool int
-# define True 1
-# define False 0
+#ifdef __cplusplus
+}
#endif
-#endif /* SYSDEPS_H */
+#endif /* VA_DRM_H */
diff --git a/test/basic/test_android.c b/va/drm/va_drm_auth.c
similarity index 52%
copy from test/basic/test_android.c
copy to va/drm/va_drm_auth.c
index 2bb247a..59aecaf 100644
--- a/test/basic/test_android.c
+++ b/va/drm/va_drm_auth.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * 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
@@ -8,11 +8,11 @@
* 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.
@@ -21,42 +21,41 @@
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#define Display unsigned int
-Display *dpy;
-VADisplay va_dpy;
-VAStatus va_status;
-VAProfile *profiles ;
-int major_version, minor_version;
-void test_init()
-{
- dpy = (Display*)malloc(sizeof(Display));
- *(dpy) = 0x18c34078;
- ASSERT( dpy );
- status("malloc Display: dpy = %08x\n", dpy);
+#include "sysdeps.h"
+#include <unistd.h>
+#include <xf86drm.h>
+#include "va_drm_auth.h"
+#include "va_drm_auth_x11.h"
- va_dpy = vaGetDisplay(dpy);
- ASSERT( va_dpy );
- status("vaGetDisplay: va_dpy = %08x\n", va_dpy);
+/* 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;
- va_status = vaInitialize(va_dpy, &major_version, &minor_version);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaInitialize: major = %d minor = %d\n", major_version, minor_version);
+ 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;
}
-void test_terminate()
+/* Try to authenticate the DRM connection with the supplied magic id */
+bool
+va_drm_authenticate(int fd, uint32_t magic)
{
- va_status = vaTerminate(va_dpy);
- ASSERT( VA_STATUS_SUCCESS == va_status );
- status("vaTerminate\n");
-
- free(dpy);
- status("free Display\n");
+ /* XXX: try to authenticate through Wayland, etc. */
+#ifdef HAVE_VA_X11
+ if (va_drm_authenticate_x11(fd, magic))
+ return true;
+#endif
- if (profiles)
- {
- free(profiles);
- profiles = NULL;
- }
+ /* Default: root + master privs are needed for the following call */
+ return drmAuthMagic(fd, magic) == 0;
}
-
diff --git a/test/basic/test_01.c b/va/drm/va_drm_auth.h
similarity index 79%
copy from test/basic/test_01.c
copy to va/drm/va_drm_auth.h
index 4075655..1aa6989 100644
--- a/test/basic/test_01.c
+++ b/va/drm/va_drm_auth.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * 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
@@ -8,11 +8,11 @@
* 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.
@@ -22,21 +22,18 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#define TEST_DESCRIPTION "Initialize & Terminate"
-
-#include "test_common.c"
+#ifndef VA_DRM_AUTH_H
+#define VA_DRM_AUTH_H
-void pre()
-{
-}
+#include <stdint.h>
+#include <stdbool.h>
-void post()
-{
-}
+DLL_HIDDEN
+bool
+va_drm_is_authenticated(int fd);
-void test()
-{
- test_init();
+DLL_HIDDEN
+bool
+va_drm_authenticate(int fd, uint32_t magic);
- test_terminate();
-}
+#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/test/basic/test_01.c b/va/drm/va_drm_auth_x11.h
similarity index 81%
copy from test/basic/test_01.c
copy to va/drm/va_drm_auth_x11.h
index 4075655..530eeed 100644
--- a/test/basic/test_01.c
+++ b/va/drm/va_drm_auth_x11.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * 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
@@ -8,11 +8,11 @@
* 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.
@@ -22,21 +22,14 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#define TEST_DESCRIPTION "Initialize & Terminate"
-
-#include "test_common.c"
-
-void pre()
-{
-}
+#ifndef VA_DRM_AUTH_X11_H
+#define VA_DRM_AUTH_X11_H
-void post()
-{
-}
+#include <stdint.h>
+#include <stdbool.h>
-void test()
-{
- test_init();
+DLL_HIDDEN
+bool
+va_drm_authenticate_x11(int fd, uint32_t magic);
- test_terminate();
-}
+#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/dummy b/va/dummy
deleted file mode 120000
index 1fd74d1..0000000
--- a/va/dummy
+++ /dev/null
@@ -1 +0,0 @@
-android
\ No newline at end of file
diff --git a/va/egl/Makefile.am b/va/egl/Makefile.am
index 7de0967..7f3f954 100644
--- a/va/egl/Makefile.am
+++ b/va/egl/Makefile.am
@@ -20,22 +20,21 @@
# 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 $(EGL_DEPS_CFLAGS)
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(EGL_CFLAGS) \
+ $(NULL)
source_c = \
- va_egl.c \
- va_egl_impl.c \
- $(NULL)
+ va_egl.c
source_h = \
- ../va_egl.h \
- va_backend_egl.h \
- $(NULL)
+ va_egl.h \
+ va_backend_egl.h
-source_h_priv = \
- va_egl_impl.h \
- va_egl_private.h \
- $(NULL)
+source_h_priv =
noinst_LTLIBRARIES = libva_egl.la
libva_eglincludedir = ${includedir}/va
diff --git a/va/egl/va_backend_egl.h b/va/egl/va_backend_egl.h
index bd0538c..925d933 100644
--- a/va/egl/va_backend_egl.h
+++ b/va/egl/va_backend_egl.h
@@ -25,7 +25,7 @@
#ifndef VA_BACKEND_EGL_H
#define VA_BACKEND_EGL_H
-#include <va/va_egl.h>
+#include <va/va.h>
#include <va/va_backend.h>
struct VADriverVTableEGL {
@@ -35,56 +35,7 @@ struct VADriverVTableEGL {
VASurfaceID surface,
void **buffer
);
-
/* TBD: more APIs for EGL */
- int max_egl_surface_targets;
- int max_egl_surface_attributes;
-
- VAStatus (*vaQuerySurfaceTargetsEGL)(
- VADriverContextP ctx,
- EGLenum *target_list, /* out */
- int *num_targets /* out */
- );
-
- VAStatus (*vaCreateSurfaceEGL)(
- VADriverContextP ctx,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *gl_surface
- );
-
- /* Optional: destroy a VA/EGL surface */
- VAStatus (*vaDestroySurfaceEGL)(
- VADriverContextP ctx,
- VASurfaceEGL egl_surface
- );
-
- VAStatus (*vaAssociateSurfaceEGL)(
- VADriverContextP ctx,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags
- );
-
- VAStatus (*vaSyncSurfaceEGL)(
- VADriverContextP ctx,
- VASurfaceEGL egl_surface
- );
-
- VAStatus (*vaGetSurfaceInfoEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target,
- EGLClientBuffer *buffer,
- EGLint *attrib_list,
- int *num_attribs
- );
-
- VAStatus (*vaDeassociateSurfaceEGL)(
- VADriverContextP ctx,
- VASurfaceEGL egl_surface
- );
};
#endif /* VA_BACKEND_EGL_H */
diff --git a/va/egl/va_egl.c b/va/egl/va_egl.c
index 48ff7a1..36e5504 100644
--- a/va/egl/va_egl.c
+++ b/va/egl/va_egl.c
@@ -53,34 +53,14 @@
*
* Bellow API vaGetEGLClientBufferFromSurface is for this purpose
*/
-#include "va_egl_private.h"
-#include "va_egl_impl.h"
+
+#include "va.h"
+#include "va_backend_egl.h"
+#include "va_egl.h"
#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
-#define INIT_CONTEXT(ctx, dpy) do { \
- if (!vaDisplayIsValid(dpy)) \
- return VA_STATUS_ERROR_INVALID_DISPLAY; \
- \
- ctx = ((VADisplayContextP)(dpy))->pDriverContext; \
- if (!(ctx)) \
- return VA_STATUS_ERROR_INVALID_DISPLAY; \
- \
- status = va_egl_init_context(dpy); \
- if (status != VA_STATUS_SUCCESS) \
- return status; \
- } while (0)
-
-#define INVOKE(ctx, func, args) do { \
- VADriverVTablePrivEGLP vtable; \
- vtable = &VA_DRIVER_CONTEXT_EGL(ctx)->vtable; \
- if (!vtable->va##func##EGL) \
- return VA_STATUS_ERROR_UNIMPLEMENTED; \
- status = vtable->va##func##EGL args; \
- } while (0)
-
-
VAStatus vaGetEGLClientBufferFromSurface (
VADisplay dpy,
VASurfaceID surface,
@@ -99,216 +79,4 @@ VAStatus vaGetEGLClientBufferFromSurface (
return VA_STATUS_ERROR_UNIMPLEMENTED;
}
-// Destroy VA/EGL display context
-static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext)
-{
- VADisplayContextEGLP pDisplayContextEGL;
- VADriverContextP pDriverContext;
- VADriverContextEGLP pDriverContextEGL;
-
- if (!pDisplayContext)
- return;
-
- pDriverContext = pDisplayContext->pDriverContext;
- pDriverContextEGL = pDriverContext->egl;
- if (pDriverContextEGL) {
- free(pDriverContextEGL);
- pDriverContext->egl = NULL;
- }
-
- pDisplayContextEGL = pDisplayContext->opaque;
- if (pDisplayContextEGL) {
- vaDestroyFunc vaDestroy = pDisplayContextEGL->vaDestroy;
- free(pDisplayContextEGL);
- pDisplayContext->opaque = NULL;
- if (vaDestroy)
- vaDestroy(pDisplayContext);
- }
-}
-
-// Return a suitable VADisplay for VA API
-VADisplay vaGetDisplayEGL(VANativeDisplay native_dpy,
- EGLDisplay egl_dpy)
-{
- VADisplay dpy = NULL;
- VADisplayContextP pDisplayContext = NULL;
- VADisplayContextEGLP pDisplayContextEGL = NULL;
- VADriverContextP pDriverContext;
- VADriverContextEGLP pDriverContextEGL = NULL;
-
- dpy = vaGetDisplay(native_dpy);
-
- if (!dpy)
- return NULL;
-
- if (egl_dpy == EGL_NO_DISPLAY)
- goto error;
-
- pDisplayContext = (VADisplayContextP)dpy;
- pDriverContext = pDisplayContext->pDriverContext;
-
- pDisplayContextEGL = calloc(1, sizeof(*pDisplayContextEGL));
- if (!pDisplayContextEGL)
- goto error;
-
- pDriverContextEGL = calloc(1, sizeof(*pDriverContextEGL));
- if (!pDriverContextEGL)
- goto error;
-
- pDisplayContextEGL->vaDestroy = pDisplayContext->vaDestroy;
- pDisplayContext->vaDestroy = va_DisplayContextDestroy;
- pDisplayContext->opaque = pDisplayContextEGL;
- pDriverContextEGL->egl_display = egl_dpy;
- pDriverContext->egl = pDriverContextEGL;
- return dpy;
-
-error:
- free(pDriverContextEGL);
- free(pDisplayContextEGL);
- pDisplayContext->vaDestroy(pDisplayContext);
- return NULL;
-}
-
-int vaMaxNumSurfaceTargetsEGL(
- VADisplay dpy
-)
-{
- VADriverContextP ctx;
- struct VADriverVTableEGL *va_egl;
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
-
- va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl;
-
- if (va_egl)
- return va_egl->max_egl_surface_targets;
- else
- return IMPL_MAX_EGL_SURFACE_TARGETS;
-}
-
-int vaMaxNumSurfaceAttributesEGL(
- VADisplay dpy
-)
-{
- VADriverContextP ctx;
- struct VADriverVTableEGL *va_egl;
- CHECK_DISPLAY(dpy);
- ctx = CTX(dpy);
-
- va_egl = (struct VADriverVTableEGL *)ctx->vtable_egl;
-
- if (va_egl)
- return va_egl->max_egl_surface_attributes;
- else
- return IMPL_MAX_EGL_SURFACE_ATTRIBUTES;
-}
-
-VAStatus vaQuerySurfaceTargetsEGL(
- VADisplay dpy,
- EGLenum *target_list, /* out */
- int *num_targets /* out */
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, QuerySurfaceTargets, (dpy, target_list, num_targets));
- return status;
-}
-
-VAStatus vaCreateSurfaceEGL(
- VADisplay dpy,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *gl_surface
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, CreateSurface, (dpy, target, width, height, gl_surface));
- return status;
-}
-
-// Destroy a VA/EGL surface
-VAStatus vaDestroySurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, DestroySurface, (dpy, egl_surface));
- return status;
-}
-
-VAStatus vaAssociateSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, AssociateSurface, (dpy, egl_surface, surface, flags));
- return status;
-}
-
-VAStatus vaSyncSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, SyncSurface, (dpy, egl_surface));
- return status;
-}
-
-VAStatus vaGetSurfaceInfoEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target, /* out, the type of <buffer> */
- EGLClientBuffer *buffer, /* out */
- EGLint *attrib_list, /* out, the last attribute must be EGL_NONE */
- int *num_attribs /* in/out */
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, GetSurfaceInfo, (dpy, egl_surface, target, buffer, attrib_list, num_attribs));
- return status;
-}
-
-VAStatus vaDeassociateSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-)
-{
- VADriverContextP ctx;
- VAStatus status;
-
- INIT_CONTEXT(ctx, dpy);
-
- INVOKE(ctx, DeassociateSurface, (dpy, egl_surface));
- return status;
-}
diff --git a/va/egl/va_egl.h b/va/egl/va_egl.h
new file mode 100644
index 0000000..4243d0b
--- /dev/null
+++ b/va/egl/va_egl.h
@@ -0,0 +1,27 @@
+#ifndef _VA_EGL_H_
+#define _VA_EGL_H_
+
+#include <va/va.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void* EGLClientBuffer;
+
+/*This function is used to get EGLClientBuffer
+ * (lower 16bits is buffer index, upper 16bits
+ * is BC device id.) from surface id. Application
+ * should maintain EGLClientBuffer itself.*/
+
+VAStatus vaGetEGLClientBufferFromSurface (
+ VADisplay dpy,
+ VASurfaceID surface,
+ EGLClientBuffer *buffer /* out*/
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _VA_EGL_H_ */
diff --git a/va/egl/va_egl_impl.c b/va/egl/va_egl_impl.c
deleted file mode 100644
index 367f43f..0000000
--- a/va/egl/va_egl_impl.c
+++ /dev/null
@@ -1,499 +0,0 @@
-#define _GNU_SOURCE 1
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include <dlfcn.h>
-
-#include "va_egl_private.h"
-#include "va_egl_impl.h"
-
-static int
-check_extension(const char *name, const char *exts)
-{
- const char *end;
- int name_len, n;
-
- if (!name || !exts)
- return 0;
-
- end = exts + strlen(exts);
- name_len = strlen(name);
-
- while (exts < end) {
- n = strcspn(exts, " ");
-
- if (n == name_len && strncmp(name, exts, n) == 0)
- return 1;
-
- exts += (n + 1);
- }
-
- return 0;
-}
-
-static int
-check_pixmap_extensions(VADriverContextP ctx, EGLDisplay egl_display)
-{
- const char *exts;
-
- exts = (const char *)eglQueryString(egl_display, EGL_EXTENSIONS);
-
- if (!check_extension("EGL_KHR_image_pixmap", exts))
- return 0;
-
- return 1;
-}
-
-/* ========================================================================= */
-/* === VA/EGL implementation from the driver (fordward calls) === */
-/* ========================================================================= */
-#ifdef INVOKE
-#undef INVOKE
-#endif
-
-#define INVOKE(ctx, func, args) do { \
- VADriverVTableEGLP vtable = (ctx)->vtable_egl; \
- if (!vtable->va##func##EGL) \
- return VA_STATUS_ERROR_UNIMPLEMENTED; \
- \
- VAStatus status = vtable->va##func##EGL args; \
- if (status != VA_STATUS_SUCCESS) \
- return status; \
- } while (0)
-
-
-static VAStatus
-vaQuerySurfaceTargetsEGL_impl_driver(VADisplay dpy,
- EGLenum *target_list,
- int *num_targets)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, QuerySurfaceTargets, (ctx, target_list, num_targets));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaCreateSurfaceEGL_impl_driver(VADisplay dpy,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *gl_surface)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, CreateSurface, (ctx, target, width, height, gl_surface));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaDestroySurfaceEGL_impl_driver(VADisplay dpy, VASurfaceEGL egl_surface)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, DestroySurface, (ctx, egl_surface));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaAssociateSurfaceEGL_impl_driver(VADisplay dpy,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, AssociateSurface, (ctx, egl_surface, surface, flags));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaSyncSurfaceEGL_impl_driver(VADisplay dpy,
- VASurfaceEGL egl_surface)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, SyncSurface, (ctx, egl_surface));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaGetSurfaceInfoEGL_impl_driver(VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target,
- EGLClientBuffer *buffer,
- EGLint *attrib_list,
- int *num_attribs)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, GetSurfaceInfo, (ctx, egl_surface, target, buffer, attrib_list, num_attribs));
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaDeassociateSurfaceEGL_impl_driver(VADisplay dpy,
- VASurfaceEGL egl_surface)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
-
- INVOKE(ctx, DeassociateSurface, (ctx, egl_surface));
-
- return VA_STATUS_SUCCESS;
-}
-
-#undef INVOKE
-
-/* ========================================================================= */
-/* === VA/EGL helpers === */
-/* ========================================================================= */
-/** Unique VASurfaceImplEGL identifier */
-#define VA_SURFACE_IMPL_EGL_MAGIC VA_FOURCC('V','E','G','L')
-
-struct VASurfaceImplEGL {
- uint32_t magic; ///< Magic number identifying a VASurfaceImplEGL
- VASurfaceID surface; ///< Associated VA surface
- EGLenum target; ///< EGL target
- EGLClientBuffer buffer;
- unsigned int width;
- unsigned int height;
- unsigned int flags;
-};
-
-static void *
-create_native_pixmap(VADisplay dpy, unsigned int width, unsigned int height)
-{
- VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
- VAStatus status;
- void *native_pixmap = NULL;
-
- status = pDisplayContext->vaCreateNativePixmap(pDisplayContext, width, height, &native_pixmap);
-
- if (status != VA_STATUS_SUCCESS)
- native_pixmap = NULL;
-
- return native_pixmap;
-}
-
-static void
-destroy_native_pixmap(VADisplay dpy, void *native_pixmap)
-{
- VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
-
- pDisplayContext->vaFreeNativePixmap(pDisplayContext, native_pixmap);
-}
-
-// Check VASurfaceImplEGL is valid
-static inline int check_surface(VASurfaceImplEGLP pSurfaceImplEGL)
-{
- return pSurfaceImplEGL && pSurfaceImplEGL->magic == VA_SURFACE_IMPL_EGL_MAGIC;
-}
-
-static inline VAStatus
-deassociate_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
-{
- pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-associate_surface(VADriverContextP ctx,
- VASurfaceImplEGLP pSurfaceImplEGL,
- VASurfaceID surface,
- unsigned int flags)
-{
- VAStatus status;
- status = deassociate_surface(ctx, pSurfaceImplEGL);
-
- if (status != VA_STATUS_SUCCESS)
- return status;
-
- pSurfaceImplEGL->surface = surface;
- pSurfaceImplEGL->flags = flags;
-
- return VA_STATUS_SUCCESS;
-}
-
-static inline VAStatus
-sync_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
-{
- if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE)
- return VA_STATUS_ERROR_INVALID_SURFACE;
-
- return ctx->vtable->vaSyncSurface(ctx, pSurfaceImplEGL->surface);
-}
-
-static VAStatus
-sync_associated_surface(VADriverContextP ctx, VASurfaceImplEGLP pSurfaceImplEGL)
-{
- VAStatus status;
-
- status = sync_surface(ctx, pSurfaceImplEGL);
-
- if (status != VA_STATUS_SUCCESS)
- return status;
-
- if (pSurfaceImplEGL->target != EGL_NATIVE_PIXMAP_KHR)
- return VA_STATUS_ERROR_UNIMPLEMENTED;
-
- status = ctx->vtable->vaPutSurface(
- ctx,
- pSurfaceImplEGL->surface,
- (void *)pSurfaceImplEGL->buffer,
- 0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height,
- 0, 0, pSurfaceImplEGL->width, pSurfaceImplEGL->height,
- NULL, 0,
- pSurfaceImplEGL->flags
- );
-
- if (status == VA_STATUS_SUCCESS) {
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
- }
-
- return status;
-}
-
-/* ========================================================================= */
-/* === VA/EGL implementation from libVA (generic and suboptimal path) === */
-/* ========================================================================= */
-#ifdef INIT_SURFACE
-#undef INIT_SURFACE
-#endif
-
-#define INIT_SURFACE(surface, egl_surface) do { \
- surface = (VASurfaceImplEGLP)(egl_surface); \
- if (!check_surface(surface)) \
- return VA_STATUS_ERROR_INVALID_SURFACE; \
- } while (0)
-
-static VAStatus
-vaQuerySurfaceTargetsEGL_impl_libva(VADisplay dpy,
- EGLenum *target_list,
- int *num_targets)
-{
- int i = 0;
-
- /* FIXME: support other targets ??? */
- target_list[i++] = EGL_NATIVE_PIXMAP_KHR;
- *num_targets = i;
- assert(i <= IMPL_MAX_EGL_SURFACE_TARGETS);
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaCreateSurfaceEGL_impl_libva(VADisplay dpy,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *egl_surface)
-{
- VASurfaceImplEGLP pSurfaceImplEGL = NULL;
-
- /* So far only support for EGL_NATIVE_PIXMAP_KHR */
- if (target != 0 && target != EGL_NATIVE_PIXMAP_KHR)
- return VA_STATUS_ERROR_INVALID_PARAMETER;
-
- pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL));
-
- if (!pSurfaceImplEGL) {
- *egl_surface = 0;
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
- }
-
- pSurfaceImplEGL->magic = VA_SURFACE_IMPL_EGL_MAGIC;
- pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
- pSurfaceImplEGL->target = target == 0 ? EGL_NATIVE_PIXMAP_KHR : target;
- pSurfaceImplEGL->buffer = 0;
- pSurfaceImplEGL->width = width;
- pSurfaceImplEGL->height = height;
- *egl_surface = (VASurfaceEGL)pSurfaceImplEGL;
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaDestroySurfaceEGL_impl_libva(VADisplay dpy, VASurfaceEGL egl_surface)
-{
- VASurfaceImplEGLP pSurfaceImplEGL;
-
- INIT_SURFACE(pSurfaceImplEGL, egl_surface);
-
- if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
- if (pSurfaceImplEGL->buffer) {
- destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
- pSurfaceImplEGL->buffer = 0;
- }
- }
-
- free(pSurfaceImplEGL);
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaAssociateSurfaceEGL_impl_libva(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags
- )
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VASurfaceImplEGLP pSurfaceImplEGL;
- VAStatus status;
-
- INIT_SURFACE(pSurfaceImplEGL, egl_surface);
-
- if (surface == VA_INVALID_SURFACE)
- return VA_STATUS_ERROR_INVALID_SURFACE;
-
- if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
- if (pSurfaceImplEGL->buffer)
- destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
-
- pSurfaceImplEGL->buffer = create_native_pixmap(dpy, pSurfaceImplEGL->width, pSurfaceImplEGL->height);
- }
-
- pSurfaceImplEGL->surface = surface;
- pSurfaceImplEGL->flags = flags;
-
- if (pSurfaceImplEGL->buffer)
- return VA_STATUS_SUCCESS;
-
- return VA_STATUS_ERROR_UNKNOWN;
-}
-
-static VAStatus
-vaSyncSurfaceEGL_impl_libva(VADisplay dpy,
- VASurfaceEGL egl_surface)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VASurfaceImplEGLP pSurfaceImplEGL;
- VAStatus status;
-
- INIT_SURFACE(pSurfaceImplEGL, egl_surface);
-
- status = sync_associated_surface(ctx, pSurfaceImplEGL);
-
- return status;
-}
-
-static VAStatus
-vaGetSurfaceInfoEGL_impl_libva(VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target,
- EGLClientBuffer *buffer,
- EGLint *attrib_list,
- int *num_attribs)
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VASurfaceImplEGLP pSurfaceImplEGL;
- VAStatus status;
- int i = 0;
-
- INIT_SURFACE(pSurfaceImplEGL, egl_surface);
-
- if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE)
- return VA_STATUS_ERROR_INVALID_SURFACE;
-
- if (*num_attribs < IMPL_MAX_EGL_SURFACE_ATTRIBUTES)
- return VA_STATUS_ERROR_INVALID_PARAMETER;
-
- *target = pSurfaceImplEGL->target;
- *buffer = pSurfaceImplEGL->buffer;
-
- if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
- attrib_list[i++] = EGL_IMAGE_PRESERVED_KHR;
- attrib_list[i + 1] = EGL_TRUE;
- attrib_list[i++] = EGL_NONE;
- } else {
- /* FIXME later */
- attrib_list[i++] = EGL_NONE;
- }
-
- *num_attribs = i;
-
- return VA_STATUS_SUCCESS;
-}
-
-static VAStatus
-vaDeassociateSurfaceEGL_impl_libva(
- VADisplay dpy,
- VASurfaceEGL egl_surface
- )
-{
- VADriverContextP ctx = ((VADisplayContextP)(dpy))->pDriverContext;
- VASurfaceImplEGLP pSurfaceImplEGL;
- VAStatus status;
-
- INIT_SURFACE(pSurfaceImplEGL, egl_surface);
-
- if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
- if (pSurfaceImplEGL->buffer)
- destroy_native_pixmap(dpy, pSurfaceImplEGL->buffer);
-
- pSurfaceImplEGL->buffer = 0;
- }
-
- pSurfaceImplEGL->surface = VA_INVALID_SURFACE;
-
- return VA_STATUS_SUCCESS;
-}
-
-#undef INIT_SURFACE
-
-/* ========================================================================= */
-/* === Private VA/EGL vtable initialization === */
-/* ========================================================================= */
-
-// Initialize EGL driver context
-VAStatus va_egl_init_context(VADisplay dpy)
-{
- VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
- VADriverContextP ctx = pDisplayContext->pDriverContext;
- VADriverContextEGLP egl_ctx = VA_DRIVER_CONTEXT_EGL(ctx);
- VADriverVTablePrivEGLP vtable = &egl_ctx->vtable;
-
- if (egl_ctx->is_initialized)
- return VA_STATUS_SUCCESS;
-
- if (ctx->vtable_egl && ctx->vtable_egl->vaCreateSurfaceEGL) {
- vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_driver;
- vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_driver;
- vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_driver;
- vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_driver;
- vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_driver;
- vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_driver;
- vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_driver;
- }
- else {
- if (pDisplayContext->vaCreateNativePixmap == NULL ||
- pDisplayContext->vaFreeNativePixmap == NULL)
- return VA_STATUS_ERROR_UNIMPLEMENTED;
-
- if (!check_pixmap_extensions(ctx, egl_ctx->egl_display))
- return VA_STATUS_ERROR_UNIMPLEMENTED;
-
- vtable->vaQuerySurfaceTargetsEGL = vaQuerySurfaceTargetsEGL_impl_libva;
- vtable->vaCreateSurfaceEGL = vaCreateSurfaceEGL_impl_libva;
- vtable->vaDestroySurfaceEGL = vaDestroySurfaceEGL_impl_libva;
- vtable->vaAssociateSurfaceEGL = vaAssociateSurfaceEGL_impl_libva;
- vtable->vaSyncSurfaceEGL = vaSyncSurfaceEGL_impl_libva;
- vtable->vaGetSurfaceInfoEGL = vaGetSurfaceInfoEGL_impl_libva;
- vtable->vaDeassociateSurfaceEGL = vaDeassociateSurfaceEGL_impl_libva;
- }
-
- egl_ctx->is_initialized = 1;
-
- return VA_STATUS_SUCCESS;
-}
diff --git a/va/egl/va_egl_impl.h b/va/egl/va_egl_impl.h
deleted file mode 100644
index 7d4b6f5..0000000
--- a/va/egl/va_egl_impl.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _VA_EGL_IMPL_H_
-#define _VA_EGL_IMPL_H_
-
-#define IMPL_MAX_EGL_SURFACE_TARGETS 4
-#define IMPL_MAX_EGL_SURFACE_ATTRIBUTES 8
-
-
-/**
- * Initialize EGL driver context
- *
- * @param[in] dpy the VA Display
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus va_egl_init_context(VADisplay dpy);
-
-#endif /* _VA_GLX_IMPL_H_ */
diff --git a/va/egl/va_egl_private.h b/va/egl/va_egl_private.h
deleted file mode 100644
index 5934e36..0000000
--- a/va/egl/va_egl_private.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef _VA_EGL_PRIVATE_H_
-#define _VA_EGL_PRIVATE_H_
-
-#include "va.h"
-#include "va_backend.h"
-#include "va_egl.h"
-#include "va_backend_egl.h"
-
-typedef struct VADisplayContextEGL *VADisplayContextEGLP;
-typedef struct VADriverContextEGL *VADriverContextEGLP;
-typedef struct VASurfaceImplEGL *VASurfaceImplEGLP;
-typedef struct VADriverVTableEGL *VADriverVTableEGLP;
-typedef struct VADriverVTablePrivEGL *VADriverVTablePrivEGLP;
-typedef void (*vaDestroyFunc)(VADisplayContextP);
-
-struct VADisplayContextEGL {
- vaDestroyFunc vaDestroy;
-};
-
-#define VA_DRIVER_CONTEXT_EGL(ctx) ((VADriverContextEGLP)((ctx)->egl))
-
-struct VADriverVTablePrivEGL {
- VAStatus (*vaQuerySurfaceTargetsEGL)(
- VADisplay dpy,
- EGLenum *target_list, /* out */
- int *num_targets /* out */
- );
-
- VAStatus (*vaCreateSurfaceEGL)(
- VADisplay dpy,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *gl_surface
- );
-
- VAStatus (*vaDestroySurfaceEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface
- );
-
- VAStatus (*vaAssociateSurfaceEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags
- );
-
- VAStatus (*vaSyncSurfaceEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface
- );
-
- VAStatus (*vaGetSurfaceInfoEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target,
- EGLClientBuffer *buffer,
- EGLint *attrib_list,
- int *num_attribs
- );
-
- VAStatus (*vaDeassociateSurfaceEGL)(
- VADisplay dpy,
- VASurfaceEGL egl_surface
- );
-};
-
-struct VADriverContextEGL {
- struct VADriverVTablePrivEGL vtable;
- unsigned int is_initialized : 1;
- EGLDisplay egl_display;
-};
-
-#endif /* _VA_EGL_PRIVATE_H_ */
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/glx/va_glx_impl.c b/va/glx/va_glx_impl.c
index 049be09..f317961 100644
--- a/va/glx/va_glx_impl.c
+++ b/va/glx/va_glx_impl.c
@@ -340,8 +340,14 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
if (!cs)
goto error;
- cs->display = ctx->native_dpy;
- cs->window = parent ? parent->window : None;
+ if (parent) {
+ cs->display = parent->display;
+ cs->window = parent->window;
+ }
+ else {
+ cs->display = ctx->native_dpy;
+ cs->window = None;
+ }
cs->context = NULL;
if (parent && parent->context) {
@@ -357,8 +363,8 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
goto choose_fbconfig;
fbconfigs = glXGetFBConfigs(
- ctx->native_dpy,
- ctx->x11_screen,
+ parent->display,
+ DefaultScreen(parent->display),
&n_fbconfigs
);
if (!fbconfigs)
@@ -367,7 +373,7 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
/* Find out a GLXFBConfig compatible with the parent context */
for (n = 0; n < n_fbconfigs; n++) {
status = glXGetFBConfigAttrib(
- ctx->native_dpy,
+ cs->display,
fbconfigs[n],
GLX_FBCONFIG_ID, &val
);
@@ -392,7 +398,7 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
}
cs->context = glXCreateNewContext(
- ctx->native_dpy,
+ cs->display,
fbconfigs[n],
GLX_RGBA_TYPE,
parent ? parent->context : NULL,
diff --git a/va/sysdeps.h b/va/sysdeps.h
index 0752b17..4de764d 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.1.0"
+
+/* 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 fdbe044..ddd105e 100644
--- a/va/va.c
+++ b/va/va.c
@@ -47,10 +47,6 @@
#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
-#define Bool int
-#define True 1
-#define False 0
-
/*
* read a config "env" for libva.conf or from environment setting
* liva.conf has higher priority
@@ -107,49 +103,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
diff --git a/va/va.h b/va/va.h
index 471004e..914cf8d 100644
--- a/va/va.h
+++ b/va/va.h
@@ -631,94 +631,7 @@ typedef struct _VAEncPictureParameterBufferJPEG
VABufferID coded_buf;
} VAEncPictureParameterBufferJPEG;
-/* data struct for JPEG decoding */
-
-/* Quantization table */
-typedef struct _VAIQMatrixBufferJPEG
-{
- int precision[4]; /* valid value: 0(8-bits) , 1(16-bits), precision[Tq](Tq=0,1,2,3)
- * specifies precision for destination Tq
- */
- unsigned char quantiser_matrix[4][128]; /* quantiser_matrix[Tq](Tq=0,1,2,3) specifies a
- * quantization table for destination Tq in zig-zag
- * scan order. Only the first 64 bytes are valid for each
- * table if precision is 0(8-bits).
- */
-} VAIQMatrixBufferJPEG;
-
-#define VA_JPEG_SOF0 0xC0
-#define VA_JPEG_SOF1 0xC1
-#define VA_JPEG_SOF2 0xC2
-#define VA_JPEG_SOF3 0xC3
-#define VA_JPEG_SOF5 0xC5
-#define VA_JPEG_SOF6 0xC6
-#define VA_JPEG_SOF7 0xC7
-#define VA_JPEG_SOF9 0xC9
-#define VA_JPEG_SOF10 0xCA
-#define VA_JPEG_SOF11 0xCB
-#define VA_JPEG_SOF13 0xCD
-#define VA_JPEG_SOF14 0xCE
-
-/* JPEG Picture Parameter Buffer */
-typedef struct _VAPictureParameterBufferJPEG
-{
- unsigned int type; /* SOFn */
- unsigned int sample_precision;
- unsigned int image_width;
- unsigned int image_height;
- unsigned int num_components;
- struct {
- unsigned char component_id; /* Ci, the range is 0-255, see B.2.2 */
- unsigned char h_sampling_factor;
- unsigned char v_sampling_factor;
- unsigned char quantiser_table_selector; /* Tqi, quantization table destination selector */
- } components[4];
-
- /* ROI (region of interest), for JPEG2000 */
- struct {
- int enabled;
- int start_x;
- int start_y;
- int end_x;
- int end_y;
- } roi;
-
- int rotation;
-} VAPictureParameterBufferJPEG;
-
-typedef struct _VAHuffmanTableBufferJPEG
-{
- struct {
- unsigned char dc_bits[16]; /* Number of Huffman codes of length i for DC */
- unsigned char dc_huffval[20]; /* Value associated with each Huffman code for DC */
- unsigned char ac_bits[16]; /* Number of Huffman codes of length i for AC */
- unsigned char ac_huffval[256]; /* Value associated with each Huffman code for AC */
- } huffman_table[4]; /* Up to 4 huffman tables, huffman_table[Th](Th=0,1,2,3)
- * specifies a buffman table for destination Th.
- */
-
-} VAHuffmanTableBufferJPEG;
-
-/* JPEG Scan Parameter Buffer, The Scan of is similar to
- * the Slice of other codecs */
-typedef struct _VASliceParameterBufferJPEG
-{
- unsigned int slice_data_size; /* number of bytes in the slice data buffer for this slice */
- unsigned int slice_data_offset; /* the offset to the first byte of slice data */
- unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX definitions */
- unsigned int slice_horizontal_position;
- unsigned int slice_vertical_position;
-
- unsigned int num_components;
- struct {
- int component_id; /* Csj, it must match one of component_ids specified in VAPictureParameterBufferJPEG */
- int dc_selector; /* Tdj(0,1,2,3) */
- int ac_selector; /* Taj(0,1,2,3) */
- } components[4];
-
- int restart_interval; /* specifies the number of MCUs in restart interval, defined in DRI marker */
- int num_mcus; /* indicates the number of MCUs in a scan */
-} VASliceParameterBufferJPEG;
+#include <va/va_dec_jpeg.h>
/****************************
* MPEG-2 data structures
diff --git a/va/va_android.h b/va/va_android.h
index 7b98949..ca73b84 100644
--- a/va/va_android.h
+++ b/va/va_android.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_ANDROID_H_
#define _VA_ANDROID_H_
diff --git a/va/va_backend.h b/va/va_backend.h
index 47ca719..a0c408d 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -35,6 +35,23 @@
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 );
@@ -427,11 +444,36 @@ 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 */
- void *egl;
- 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[43]; /* reserve for future add-ins, decrease the subscript accordingly */
};
#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
@@ -456,16 +498,6 @@ struct VADisplayContext
);
void *opaque; /* opaque for display extensions (e.g. GLX) */
-
- VAStatus (*vaCreateNativePixmap) (
- VADisplayContextP pDisplayContext,
- unsigned int width,
- unsigned int height,
- void **native_pixmap);
-
- VAStatus (*vaFreeNativePixmap) (
- VADisplayContextP pDisplayContext,
- void *native_pixmap);
};
typedef VAStatus (*VADriverInit) (
diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h
new file mode 100644
index 0000000..9936692
--- /dev/null
+++ b/va/va_dec_jpeg.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2007-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_dec_jpeg.h
+ * \brief The JPEG decoding API
+ *
+ * This file contains the \ref api_dec_jpeg "JPEG decoding API".
+ */
+
+#ifndef VA_DEC_JPEG_H
+#define VA_DEC_JPEG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <va/va.h>
+
+/**
+ * \defgroup api_dec_jpeg JPEG decoding API
+ *
+ * This JPEG decoding API supports Baseline profile only.
+ *
+ * @{
+ */
+
+/**
+ * \brief Picture parameter for JPEG decoding.
+ *
+ * This structure holds information from the frame header, along with
+ * definitions from additional segments.
+ */
+typedef struct _VAPictureParameterBufferJPEGBaseline {
+ /** \brief Picture width in pixels. */
+ unsigned short picture_width;
+ /** \brief Picture height in pixels. */
+ unsigned short picture_height;
+
+ struct {
+ /** \brief Component identifier (Ci). */
+ unsigned char component_id;
+ /** \brief Horizontal sampling factor (Hi). */
+ unsigned char h_sampling_factor;
+ /** \brief Vertical sampling factor (Vi). */
+ unsigned char v_sampling_factor;
+ /* \brief Quantization table selector (Tqi). */
+ unsigned char quantiser_table_selector;
+ } components[255];
+ /** \brief Number of components in frame (Nf). */
+ unsigned char num_components;
+} VAPictureParameterBufferJPEGBaseline;
+
+/**
+ * \brief Quantization table for JPEG decoding.
+ *
+ * This structure holds the complete quantization tables. This is an
+ * aggregation of all quantization table (DQT) segments maintained by
+ * the application. i.e. up to 4 quantization tables are stored in
+ * there for baseline profile.
+ *
+ * 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.
+ */
+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];
+} VAIQMatrixBufferJPEGBaseline;
+
+/**
+ * \brief Huffman table for JPEG decoding.
+ *
+ * This structure holds the complete Huffman tables. This is an
+ * aggregation of all Huffman table (DHT) segments maintained by the
+ * application. i.e. up to 2 Huffman tables are stored in there for
+ * baseline profile.
+ *
+ * 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.
+ */
+typedef struct _VAHuffmanTableBufferJPEGBaseline {
+ /** \brief Specifies which #huffman_table is valid. */
+ unsigned char load_huffman_table[2];
+ /** \brief Huffman tables indexed by table identifier (Th). */
+ struct {
+ /** @name DC table (up to 12 categories) */
+ /**@{*/
+ /** \brief Number of Huffman codes of length i + 1 (Li). */
+ unsigned char num_dc_codes[16];
+ /** \brief Value associated with each Huffman code (Vij). */
+ unsigned char dc_values[12];
+ /**@}*/
+ /** @name AC table (2 special codes + up to 16 * 10 codes) */
+ /**@{*/
+ /** \brief Number of Huffman codes of length i + 1 (Li). */
+ 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];
+} VAHuffmanTableBufferJPEGBaseline;
+
+/**
+ * \brief Slice parameter for JPEG decoding.
+ *
+ * This structure holds information from the scan header, along with
+ * definitions from additional segments. The associated slice data
+ * buffer holds all entropy coded segments (ECS) in the scan.
+ */
+typedef struct _VASliceParameterBufferJPEGBaseline {
+ /** @name Codec-independent Slice Parameter Buffer base. */
+ /**@{*/
+ /** \brief Number of bytes in the slice data buffer for this slice. */
+ unsigned int slice_data_size;
+ /** \brief The offset to the first byte of the first MCU. */
+ unsigned int slice_data_offset;
+ /** \brief Slice data buffer flags. See \c VA_SLICE_DATA_FLAG_xxx. */
+ unsigned int slice_data_flag;
+ /**@}*/
+
+ /** \brief Scan horizontal position. */
+ unsigned int slice_horizontal_position;
+ /** \brief Scan vertical position. */
+ unsigned int slice_vertical_position;
+
+ struct {
+ /** \brief Scan component selector (Csj). */
+ unsigned char component_selector;
+ /** \brief DC entropy coding table selector (Tdj). */
+ unsigned char dc_table_selector;
+ /** \brief AC entropy coding table selector (Taj). */
+ unsigned char ac_table_selector;
+ } components[4];
+ /** \brief Number of components in scan (Ns). */
+ unsigned char num_components;
+
+ /** \brief Restart interval definition (Ri). */
+ unsigned short restart_interval;
+ /** \brief Number of MCUs in a scan. */
+ unsigned int num_mcus;
+} VASliceParameterBufferJPEGBaseline;
+
+/**@}*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* VA_DEC_JPEG_H */
diff --git a/va/va_drmcommon.h b/va/va_drmcommon.h
new file mode 100644
index 0000000..bb00fd4
--- /dev/null
+++ b/va/va_drmcommon.h
@@ -0,0 +1,71 @@
+/*
+ * 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;
+};
+
+#endif /* VA_DRM_COMMON_H */
diff --git a/va/va_dummy.h b/va/va_dummy.h
deleted file mode 120000
index 69128f8..0000000
--- a/va/va_dummy.h
+++ /dev/null
@@ -1 +0,0 @@
-va_android.h
\ No newline at end of file
diff --git a/va/va_egl.h b/va/va_egl.h
deleted file mode 100644
index c9bd16f..0000000
--- a/va/va_egl.h
+++ /dev/null
@@ -1,179 +0,0 @@
-#ifndef _VA_EGL_H_
-#define _VA_EGL_H_
-
-#include <va/va.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *VASurfaceEGL;
-
-/*This function is used to get EGLClientBuffer
- * (lower 16bits is buffer index, upper 16bits
- * is BC device id.) from surface id. Application
- * should maintain EGLClientBuffer itself.*/
-
-VAStatus vaGetEGLClientBufferFromSurface (
- VADisplay dpy,
- VASurfaceID surface,
- EGLClientBuffer *buffer /* out*/
-);
-
-/**
- * Return a suitable VADisplay for VA API
- *
- * @param[in] native_dpy the native display
- * @param[in] egl_dpy the EGL display
- * @return a VADisplay
- */
-VADisplay vaGetDisplayEGL(
- VANativeDisplay native_dpy,
- EGLDisplay egl_dpy
-);
-
-/**
- * Return maximum number of EGL targets supported by the implementation
- *
- * @param[in] dpy the VADisplay
- * @return the maximum number of EGL Target
- */
-int vaMaxNumSurfaceTargetsEGL(
- VADisplay dpy
-);
-
-/**
- * Return maximum number of EGL surface attributes supported by the implementation
- *
- * @param[in] dpy the VADisplay
- * @return the maximum number of EGL surface attributes
- */
-int vaMaxNumSurfaceAttributesEGL(
- VADisplay dpy
-);
-
-/**
- * Query supported EGL targets for eglCreateImageKHR().
- *
- * The caller must provide a "target_list" array that can hold at
- * least vaMaxNumSurfaceTargetsEGL() entries. The actual number of
- * targets returned in "target_list" is returned in "num_targets".
- *
- * @param[in]] dpy the VADisplay
- * @param[out] target_list the array to hold target entries
- * @param[out] num_targets the actual number of targets
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaQuerySurfaceTargetsEGL(
- VADisplay dpy,
- EGLenum *target_list, /* out */
- int *num_targets /* out */
-);
-
-/**
- * Creates a VA/EGL surface with the specified target
- *
- * If target is 0, this means the best efficient target by default.
- *
- * @param[in] dpy the VADisplay
- * @param[in] target the specified EGL target
- * @param[in] width the surface width
- * @param[in] height the surface height
- * @param[out] gl_surface the VA/EGL surface
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaCreateSurfaceEGL(
- VADisplay dpy,
- EGLenum target,
- unsigned int width,
- unsigned int height,
- VASurfaceEGL *gl_surface
-);
-
-/**
- * Destroy a VA/EGL surface
- *
- * The application shall maintain the live EGL context itself.
- *
- * @param[in] dpy the VA display
- * @param[in] gl_surface the VA surface
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaDestroySurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL gl_surface
-);
-
-/**
- * Associate a EGL surface with a VA surface
- *
- * @param[in] dpy the VA display
- * @param[in] egl_surface the VA/EGL destination surface
- * @param[in] surface the VA surface
- * @param[in] flags the flags to PutSurface
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaAssociateSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- VASurfaceID surface,
- unsigned int flags
-);
-
-/**
- * Update the content of a VA/EGL surface
- *
- * Changes to VA surface are committed to VA/EGL surface at this point.
- *
- * @param[in] dpy the VA display
- * @param[in] egl_surface the VA/EGL surface that has been associated with a VA surface
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaSyncSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-);
-
-/**
- * Get the necessary information for eglCreateImageKHR()
- *
- * The caller must provide a "attrib_list" array that can hold at
- * least (2 * vaMaxNumSurfaceAttributesEGL()) entries. The last attribute
- * specified in attrib_list must be EGL_NONE
- *
- * @param[in] dpy the VA display
- * @param[in] egl_surface the VA/EGL surface that has been associated with a VA surface
- * @param[out] target the type of <buffer> for eglCreateImageKHR()
- * @param[out] buffer the EGLClientBuffer for eglCreateImageKHR()
- * @param[out] attrib_list the list of attribute-value pairs for eglCreateImageKHR()
- * @param[in/out] num_attribs input: the number of allocated attribute-value pairs in attrib_list; output: the actual number of attribute-value pairs
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaGetSurfaceInfoEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface,
- EGLenum *target, /* out, the type of <buffer> */
- EGLClientBuffer *buffer, /* out */
- EGLint *attrib_list, /* out, the last attribute must be EGL_NONE */
- int *num_attribs /* in/out, the number of attribute-value pairs */
-);
-
-/**
- * Deassociate a EGL surface
- *
- * @param[in] dpy the VA display
- * @param[in] egl_surface the VA/EGL destination surface
- * @return VA_STATUS_SUCCESS if successful
- */
-VAStatus vaDeassociateSurfaceEGL(
- VADisplay dpy,
- VASurfaceEGL egl_surface
-);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _VA_EGL_H_ */
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/doc/Makefile.am b/va/wayland/Makefile.am
similarity index 59%
copy from doc/Makefile.am
copy to va/wayland/Makefile.am
index 36c3905..a9f9546 100644
--- a/doc/Makefile.am
+++ b/va/wayland/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved.
+# 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
@@ -7,11 +7,11 @@
# 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.
@@ -20,33 +20,47 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-all: html
-install-data-local: install-html
+SUBDIRS = protocol
-EXTRA_DIST = \
- Doxyfile \
+INCLUDES = \
+ -DLINUX \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/va \
+ $(WAYLAND_CFLAGS) \
+ $(DRM_CFLAGS) \
$(NULL)
-VA_HEADER_DIR = $(top_srcdir)/va
-VA_HEADER_FILES = \
+source_c = \
+ va_wayland.c \
+ va_wayland_drm.c \
+ va_wayland_emgd.c \
+ $(top_srcdir)/va/drm/va_drm_utils.c \
$(NULL)
-export VA_HEADER_DIR
-export VA_HEADER_FILES
-html-out/index.html: Doxyfile $(VA_HEADER_FILES)
- $(DOXYGEN) $<
-
-if ENABLE_DOCS
-html: html-out/index.html
-install-html-local:
- install -d $(DESTDIR)$(docdir)/html
- install -m 0644 html-out/* $(DESTDIR)$(docdir)/html
-uninstall-local:
- rm -rf $(DESTDIR)$(docdir)/html
-endif
-
-clean-local:
- rm -rf html-out
+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)
+ at wayland_scanner_rules@
# Extra clean files so that maintainer-clean removes *everything*
MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/Makefile.am b/va/wayland/protocol/Makefile.am
similarity index 79%
copy from test/Makefile.am
copy to va/wayland/protocol/Makefile.am
index 1ee87c9..614d8a4 100644
--- a/test/Makefile.am
+++ b/va/wayland/protocol/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+# 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
@@ -20,13 +20,9 @@
# 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)
-AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11
-
-SUBDIRS = basic decode encode putsurface vainfo v4l_h264
-
-if BUILD_EGL_TEST
-SUBDIRS += egl
-endif
-
-EXTRA_DIST = loadsurface.h loadsurface_yuv.h
\ No newline at end of file
+# 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/glx/va_backend_glx.h b/va/wayland/va_backend_wayland.h
similarity index 51%
copy from va/glx/va_backend_glx.h
copy to va/wayland/va_backend_wayland.h
index d110485..b33e3a1 100644
--- a/va/glx/va_backend_glx.h
+++ b/va/wayland/va_backend_wayland.h
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved.
+ * 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
@@ -16,39 +18,48 @@
* 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
+ * 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_GLX_H
-#define VA_BACKEND_GLX_H
+#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;
-struct VADriverVTableGLX {
- /* Optional: create a surface used for display to OpenGL */
- VAStatus (*vaCreateSurfaceGLX)(
- struct VADriverContext *ctx,
- unsigned int gl_target,
- unsigned int gl_texture,
- void **gl_surface
- );
+/** \brief VA/Wayland implementation hooks. */
+struct VADriverVTableWayland {
+ /**
+ * \brief Interface version.
+ *
+ * Implementations shall set this field to \ref VA_WAYLAND_API_VERSION.
+ */
+ unsigned int version;
- /* Optional: destroy a VA/GLX surface */
- VAStatus (*vaDestroySurfaceGLX)(
+ /** \brief Hook to return Wayland buffer associated with the VA surface. */
+ VAStatus (*vaGetSurfaceBufferWl)(
struct VADriverContext *ctx,
- void *gl_surface
+ VASurfaceID surface,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
);
- /* Optional: copy a VA surface to a VA/GLX surface */
- VAStatus (*vaCopySurfaceGLX)(
+ /** \brief Hook to return Wayland buffer associated with the VA image. */
+ VAStatus (*vaGetImageBufferWl)(
struct VADriverContext *ctx,
- void *gl_surface,
- VASurfaceID surface,
- unsigned int flags
+ VAImageID image,
+ unsigned int flags,
+ struct wl_buffer **out_buffer
);
};
-#endif /* VA_BACKEND_GLX_H */
+#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..30c3953
--- /dev/null
+++ b/va/wayland/va_wayland_drm.c
@@ -0,0 +1,202 @@
+/*
+ * 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;
+ 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;
+ }
+}
+
+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;
+
+ id = wl_display_get_global(ctx->native_dpy, "wl_drm", 1);
+ if (!id) {
+ wl_display_roundtrip(ctx->native_dpy);
+ id = wl_display_get_global(ctx->native_dpy, "wl_drm", 1);
+ if (!id)
+ return false;
+ }
+
+ 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->drm =
+ wl_display_bind(ctx->native_dpy, id, wl_drm_ctx->drm_interface);
+ 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/sysdeps.h b/va/wayland/va_wayland_drm.h
similarity index 61%
copy from va/sysdeps.h
copy to va/wayland/va_wayland_drm.h
index 0752b17..6fb8f52 100644
--- a/va/sysdeps.h
+++ b/va/wayland/va_wayland_drm.h
@@ -1,5 +1,7 @@
/*
- * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,23 +24,29 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef SYSDEPS_H
-#define SYSDEPS_H
+#ifndef VA_WAYLAND_DRM_H
+#define VA_WAYLAND_DRM_H
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <stdbool.h>
+#include "va_wayland.h"
+#include "va_backend.h"
+#include "va_backend_wayland.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.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);
-#ifdef ANDROID
-# define Bool int
-# define True 1
-# define False 0
-#endif
+DLL_HIDDEN
+void
+va_wayland_drm_destroy(VADisplayContextP pDisplayContext);
-#endif /* SYSDEPS_H */
+#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..73e6802
--- /dev/null
+++ b/va/wayland/va_wayland_emgd.c
@@ -0,0 +1,137 @@
+/*
+ * 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;
+} 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;
+ }
+}
+
+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;
+
+ id = wl_display_get_global(ctx->native_dpy, "wl_emgd", 1);
+ if (!id) {
+ wl_display_roundtrip(ctx->native_dpy);
+ id = wl_display_get_global(ctx->native_dpy, "wl_emgd", 1);
+ if (!id)
+ return false;
+ }
+
+ 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->emgd =
+ wl_display_bind(ctx->native_dpy, id, wl_emgd_ctx->emgd_interface);
+ if (!wl_emgd_ctx->emgd)
+ return false;
+ return true;
+}
diff --git a/va/sysdeps.h b/va/wayland/va_wayland_emgd.h
similarity index 61%
copy from va/sysdeps.h
copy to va/wayland/va_wayland_emgd.h
index 0752b17..053b6b4 100644
--- a/va/sysdeps.h
+++ b/va/wayland/va_wayland_emgd.h
@@ -1,5 +1,7 @@
/*
- * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,23 +24,29 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef SYSDEPS_H
-#define SYSDEPS_H
+#ifndef VA_WAYLAND_EMGD_H
+#define VA_WAYLAND_EMGD_H
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <stdbool.h>
+#include "va_wayland.h"
+#include "va_backend.h"
+#include "va_backend_wayland.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.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);
-#ifdef ANDROID
-# define Bool int
-# define True 1
-# define False 0
-#endif
+DLL_HIDDEN
+void
+va_wayland_emgd_destroy(VADisplayContextP pDisplayContext);
-#endif /* SYSDEPS_H */
+#endif /* VA_WAYLAND_EMGD_H */
diff --git a/va/sysdeps.h b/va/wayland/va_wayland_private.h
similarity index 64%
copy from va/sysdeps.h
copy to va/wayland/va_wayland_private.h
index 0752b17..f09f4b7 100644
--- a/va/sysdeps.h
+++ b/va/wayland/va_wayland_private.h
@@ -1,5 +1,7 @@
/*
- * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved.
+ * 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
@@ -22,23 +24,21 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef SYSDEPS_H
-#define SYSDEPS_H
+#ifndef VA_WAYLAND_PRIVATE_H
+#define VA_WAYLAND_PRIVATE_H
+
+struct va_wayland_context;
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+typedef bool (*VADisplayContextCreateFunc)(VADisplayContextP pDisplayContext);
+typedef void (*VADisplayContextDestroyFunc)(VADisplayContextP pDisplayContext);
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdint.h>
-#include <assert.h>
+/* VA/Wayland base display context */
+typedef struct va_wayland_context {
+ VADisplayContextDestroyFunc destroy;
+} VADisplayContextWayland, *VADisplayContextWaylandP;
-#ifdef ANDROID
-# define Bool int
-# define True 1
-# define False 0
-#endif
+DLL_HIDDEN
+void
+va_wayland_error(const char *format, ...);
-#endif /* SYSDEPS_H */
+#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 fc20f02..c38cd58 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 = \
dri2_util.c \
diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c
index a00df7b..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,26 +164,26 @@ 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;
@@ -172,20 +195,20 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name)
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;
@@ -205,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 f863004..eb6ddad 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
@@ -48,8 +72,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
struct dri_drawable *drawable_hash[DRAWABLE_HASH_SZ];
diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c
index a593712..625ab7e 100644
--- a/va/x11/va_x11.c
+++ b/va/x11/va_x11.c
@@ -62,12 +62,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);
}
@@ -145,47 +145,6 @@ static VAStatus va_DisplayContextGetDriverName (
return vaStatus;
}
-static VAStatus va_CreateNativePixmap(
- VADisplayContextP pDisplayContext,
- unsigned int width,
- unsigned int height,
- void **native_pixmap)
-{
- VADriverContextP ctx = pDisplayContext->pDriverContext;
- Window root_window;
- XWindowAttributes wattr;
- Pixmap pixmap = None;
-
- root_window = RootWindow(ctx->native_dpy, ctx->x11_screen);
- XGetWindowAttributes(ctx->native_dpy, root_window, &wattr);
-
- if (wattr.depth != 24 && wattr.depth != 32)
- return VA_STATUS_ERROR_INVALID_DISPLAY;
-
- pixmap = XCreatePixmap(
- ctx->native_dpy,
- root_window,
- width,
- height,
- wattr.depth
- );
-
- *native_pixmap = (void *)pixmap;
-
- return !pixmap ? VA_STATUS_ERROR_UNKNOWN : VA_STATUS_SUCCESS;
-}
-
-static VAStatus va_FreeNativePixmap(
- VADisplayContextP pDisplayContext,
- void *native_pixmap)
-{
- VADriverContextP ctx = pDisplayContext->pDriverContext;
- Pixmap pixmap = (Pixmap)native_pixmap;
-
- XFreePixmap(ctx->native_dpy, pixmap);
-
- return VA_STATUS_SUCCESS;
-}
VADisplay vaGetDisplay (
Display *native_dpy /* implementation specific */
@@ -210,14 +169,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;
- pDisplayContext->vaCreateNativePixmap = va_CreateNativePixmap;
- pDisplayContext->vaFreeNativePixmap = va_FreeNativePixmap;
- pDriverContext->dri_state = dri_state;
+ pDriverContext->drm_state = dri_state;
dpy = (VADisplay)pDisplayContext;
}
else
--
libva packaging
More information about the pkg-multimedia-commits
mailing list