OSDN Git Service

Upload latest libVA library
authorAustin Yuan <shengquan.yuan@intel.com>
Fri, 12 Jun 2009 23:18:20 +0000 (07:18 +0800)
committerAustin Yuan <shengquan.yuan@intel.com>
Fri, 12 Jun 2009 23:18:20 +0000 (07:18 +0800)
    1. Upgrade VAAPI to version 0.30 which has encode support
    2. Incorporate Gwenole Beauchesne's patches 102, 103, 104. 105, 106, 107, 109 and part of 202
       (see http://www.splitted-desktop.com/~gbeauchesne/libva/patches/)
    3. DRI2 support

Signed-off-by: Austin Yuan <shengquan.yuan@intel.com>
57 files changed:
libva/.cvsignore [new file with mode: 0644]
libva/COPYING [moved from COPYING with 100% similarity]
libva/Makefile.am [moved from Makefile.am with 99% similarity]
libva/autogen.sh [moved from autogen.sh with 100% similarity]
libva/configure.ac [moved from configure.ac with 75% similarity]
libva/debian/README.Debian [new file with mode: 0644]
libva/debian/changelog [new file with mode: 0644]
libva/debian/compat [new file with mode: 0644]
libva/debian/control [new file with mode: 0644]
libva/debian/copyright [new file with mode: 0644]
libva/debian/dirs [new file with mode: 0644]
libva/debian/files [new file with mode: 0644]
libva/debian/libva-dev.dirs [new file with mode: 0644]
libva/debian/libva-dev.install [new file with mode: 0644]
libva/debian/libva-dev.substvars [new file with mode: 0644]
libva/debian/libva1.dirs [new file with mode: 0644]
libva/debian/libva1.install [new file with mode: 0644]
libva/debian/libva1.substvars [new file with mode: 0644]
libva/debian/rules [new file with mode: 0644]
libva/dummy_drv_video/Makefile.am [moved from dummy_drv_video/Makefile.am with 91% similarity]
libva/dummy_drv_video/dummy_drv_video.c [moved from dummy_drv_video/dummy_drv_video.c with 99% similarity]
libva/dummy_drv_video/dummy_drv_video.h [moved from dummy_drv_video/dummy_drv_video.h with 100% similarity]
libva/dummy_drv_video/object_heap.c [moved from dummy_drv_video/object_heap.c with 99% similarity]
libva/dummy_drv_video/object_heap.h [moved from dummy_drv_video/object_heap.h with 100% similarity]
libva/libva.pc.in [moved from libva.pc.in with 73% similarity]
libva/src/Makefile.am [moved from src/Makefile.am with 66% similarity]
libva/src/X11/Makefile.am [new file with mode: 0644]
libva/src/X11/va_dri.c [moved from src/va_dri.c with 100% similarity]
libva/src/X11/va_dri.h [moved from src/va_dri.h with 100% similarity]
libva/src/X11/va_dri2.c [new file with mode: 0644]
libva/src/X11/va_dri2.h [new file with mode: 0644]
libva/src/X11/va_dri2str.h [new file with mode: 0644]
libva/src/X11/va_dri2tokens.h [new file with mode: 0644]
libva/src/X11/va_dristr.h [moved from src/va_dristr.h with 100% similarity]
libva/src/X11/va_x11.c [new file with mode: 0644]
libva/src/X11/va_x11.h [moved from src/va_x11.h with 50% similarity, mode: 0644]
libva/src/va.c [moved from src/va.c with 79% similarity]
libva/src/va.h [moved from src/va.h with 84% similarity]
libva/src/va_backend.h [moved from src/va_backend.h with 89% similarity]
libva/test/Makefile.am [moved from test/Makefile.am with 98% similarity]
libva/test/test.c [moved from test/test.c with 99% similarity]
libva/test/test_01.c [moved from test/test_01.c with 100% similarity]
libva/test/test_02.c [moved from test/test_02.c with 100% similarity]
libva/test/test_03.c [moved from test/test_03.c with 100% similarity]
libva/test/test_04.c [moved from test/test_04.c with 100% similarity]
libva/test/test_05.c [moved from test/test_05.c with 100% similarity]
libva/test/test_06.c [moved from test/test_06.c with 100% similarity]
libva/test/test_07.c [moved from test/test_07.c with 100% similarity]
libva/test/test_08.c [moved from test/test_08.c with 100% similarity]
libva/test/test_09.c [moved from test/test_09.c with 100% similarity]
libva/test/test_10.c [moved from test/test_10.c with 100% similarity]
libva/test/test_11.c [moved from test/test_11.c with 100% similarity]
libva/test/test_12.c [moved from test/test_12.c with 99% similarity]
libva/test/test_common.c [moved from test/test_common.c with 99% similarity]
libva/test/testplan.txt [moved from test/testplan.txt with 100% similarity]
libva/test/vainfo.c [new file with mode: 0644]
test/vainfo.c [deleted file]

diff --git a/libva/.cvsignore b/libva/.cvsignore
new file mode 100644 (file)
index 0000000..68156f9
--- /dev/null
@@ -0,0 +1,3 @@
+*~
+Makefile.in
+Makefile
similarity index 100%
rename from COPYING
rename to libva/COPYING
similarity index 99%
rename from Makefile.am
rename to libva/Makefile.am
index 8fe40e2..5470b69 100644 (file)
@@ -27,4 +27,3 @@ pkgconfigdir = @pkgconfigdir@
 pkgconfig_DATA = libva.pc
 
 EXTRA_DIST = libva.pc.in
-
similarity index 100%
rename from autogen.sh
rename to libva/autogen.sh
similarity index 75%
rename from configure.ac
rename to libva/configure.ac
index 1aba565..4dc72e1 100644 (file)
@@ -21,7 +21,7 @@
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 AC_PREREQ(2.57)
-AC_INIT([libva], 0.29, [waldo.bastian@intel.com], libva)
+AC_INIT([libva], 0.30, [waldo.bastian@intel.com], libva)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 
@@ -34,9 +34,24 @@ AC_PROG_CC
 AC_HEADER_STDC
 AC_SYS_LARGEFILE
 
-PKG_CHECK_MODULES([libva_la], [libdrm])
+PKG_CHECK_MODULES([X11], [x11])
+PKG_CHECK_MODULES([XEXT],[xext])
+PKG_CHECK_MODULES([DRM], [libdrm])
+PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm])
+
+# We only need the headers, we don't link against the DRM libraries
+LIBVA_CFLAGS="$LIBDRM_DEPS_CFLAGS"
+AC_SUBST(LIBVA_CFLAGS)
+AC_SUBST(LIBVA_LIBS)
 
 pkgconfigdir=${libdir}/pkgconfig
 AC_SUBST(pkgconfigdir)
 
-AC_OUTPUT([Makefile src/Makefile dummy_drv_video/Makefile test/Makefile libva.pc])
+AC_OUTPUT([
+       Makefile
+       src/Makefile
+       src/X11/Makefile
+       dummy_drv_video/Makefile
+       test/Makefile
+       libva.pc
+])
diff --git a/libva/debian/README.Debian b/libva/debian/README.Debian
new file mode 100644 (file)
index 0000000..d10d702
--- /dev/null
@@ -0,0 +1,7 @@
+libva for Debian
+----------------
+
+This library implements the Video Acceleration (VA) API for Linux.
+It will load a hardware dependendent video acceleration driver.
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Mon, 18 Jun 2007 21:35:31 -0700
diff --git a/libva/debian/changelog b/libva/debian/changelog
new file mode 100644 (file)
index 0000000..1f60620
--- /dev/null
@@ -0,0 +1,27 @@
+libva (0.24-1) unstable; urgency=low
+
+  * Updated to v0.24
+  * Display attributes added
+  * H264 parameter fixes
+  * Swapped vaGetConfigAttributes and vaQueryConfigAttributes
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Thu, 20 Sep 2007 15:08:04 -0700
+
+  * Updated to v0.22
+  * VAImage and VASubpicture added
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Fri, 07 Sep 2007 04:32:28 -0700
+
+  * Updated to v0.20
+  * Clean up & exporting DRI interface
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Thu, 09 Aug 2007 11:49:43 -0700
+
+  * Add VA_INVALID_SURFACE
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Wed, 11 Jul 2007 17:24:10 -0700
+
+  * Initial release of libva
+
+ -- Waldo Bastian <waldo.bastian@intel.com>  Mon, 18 Jun 2007 21:35:31 -0700
+
diff --git a/libva/debian/compat b/libva/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/libva/debian/control b/libva/debian/control
new file mode 100644 (file)
index 0000000..7ad39bc
--- /dev/null
@@ -0,0 +1,36 @@
+Source: libva
+Priority: extra
+Maintainer: Waldo Bastian <waldo.bastian@intel.com>
+Build-Depends: debhelper (>= 5),
+               autotools-dev,
+               libdrm-dev (>= 2.3.0),
+               mesa-common-dev,
+               x11proto-gl-dev,
+               x11proto-xext-dev,
+               libxext-dev,
+               pkg-config
+Standards-Version: 3.7.2
+Section: libs
+
+Package: libva-dev
+Section: libdevel
+Architecture: any
+Depends: libva1 (= ${binary:Version}),
+         libdrm-dev (>= 2.3.0),
+         pkg-config
+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
+Section: libs
+Architecture: any
+Depends: libx11-6,
+         libxext6, 
+         libdrm2 (>= 2.3.0)
+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.
+
diff --git a/libva/debian/copyright b/libva/debian/copyright
new file mode 100644 (file)
index 0000000..38b60ef
--- /dev/null
@@ -0,0 +1,44 @@
+This package was debianized by Waldo Bastian <waldo.bastian@intel.com> on
+Mon, 18 Jun 2007 21:35:31 -0700.
+
+It was downloaded from <url://example.com>
+
+Upstream Author(s): 
+
+    Waldo Bastian <waldo.bastian@intel.com>
+    Jonathan Bian <jonathan.bian@intel.com>
+
+Copyright: 
+
+    (C) Copyright IBM Corporation 2004
+    Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+    Copyright 2000 VA Linux Systems, Inc.
+    Copyright 2007 Intel Corportation
+
+License:
+
+    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.
+
+The Debian packaging is (C) 2007, Intel Corporation and
+is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
diff --git a/libva/debian/dirs b/libva/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/libva/debian/files b/libva/debian/files
new file mode 100644 (file)
index 0000000..bbaff89
--- /dev/null
@@ -0,0 +1,2 @@
+libva-dev_0.24-1_i386.deb libdevel extra
+libva1_0.24-1_i386.deb libs extra
diff --git a/libva/debian/libva-dev.dirs b/libva/debian/libva-dev.dirs
new file mode 100644 (file)
index 0000000..4418816
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/libva/debian/libva-dev.install b/libva/debian/libva-dev.install
new file mode 100644 (file)
index 0000000..d86b3bf
--- /dev/null
@@ -0,0 +1,8 @@
+debian/tmp/usr/include/va.h
+debian/tmp/usr/include/va_x11.h
+debian/tmp/usr/include/va_backend.h
+debian/tmp/usr/include/va_dri.h
+debian/tmp/usr/X11R6/lib/modules/dri/dummy_drv_video.*
+debian/tmp/usr/lib/libva.la
+debian/tmp/usr/lib/libva.so
+debian/tmp/usr/lib/pkgconfig/libva.pc
diff --git a/libva/debian/libva-dev.substvars b/libva/debian/libva-dev.substvars
new file mode 100644 (file)
index 0000000..17c2baa
--- /dev/null
@@ -0,0 +1 @@
+shlibs:Depends=libc6 (>= 2.6-1)
diff --git a/libva/debian/libva1.dirs b/libva/debian/libva1.dirs
new file mode 100644 (file)
index 0000000..6845771
--- /dev/null
@@ -0,0 +1 @@
+usr/lib
diff --git a/libva/debian/libva1.install b/libva/debian/libva1.install
new file mode 100644 (file)
index 0000000..499e94b
--- /dev/null
@@ -0,0 +1,2 @@
+debian/tmp/usr/lib/libva.so.*
+debian/tmp/usr/bin/vainfo
diff --git a/libva/debian/libva1.substvars b/libva/debian/libva1.substvars
new file mode 100644 (file)
index 0000000..9e3d1d8
--- /dev/null
@@ -0,0 +1 @@
+shlibs:Depends=libc6 (>= 2.6-1), libx11-6, libxext6
diff --git a/libva/debian/rules b/libva/debian/rules
new file mode 100644 (file)
index 0000000..60fbc95
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+# shared library versions, option 1
+#version=2.0.5
+#major=2
+# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
+version=`ls src/.libs/lib*.so.* | \
+ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
+#major=`ls src/.libs/lib*.so.* | \
+# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
+
+config.status: configure
+       dh_testdir
+       # Add here commands to configure the package.
+ifneq "$(wildcard /usr/share/misc/config.sub)" ""
+       cp -f /usr/share/misc/config.sub config.sub
+endif
+ifneq "$(wildcard /usr/share/misc/config.guess)" ""
+       cp -f /usr/share/misc/config.guess config.guess
+endif
+       ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
+
+
+build: build-stamp
+build-stamp:  config.status
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp 
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) distclean
+       rm -f config.sub config.guess
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/tmp
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_python
+#      dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install 
similarity index 91%
rename from dummy_drv_video/Makefile.am
rename to libva/dummy_drv_video/Makefile.am
index 643f53c..f782c71 100644 (file)
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 dummy_drv_video_la_LTLIBRARIES = dummy_drv_video.la
-dummy_drv_video_ladir = /usr/X11R6/lib/modules/dri
+dummy_drv_video_ladir = /usr/lib/dri
 dummy_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined
 dummy_drv_video_la_LIBADD = ../src/libva.la
 
-AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/../../include/kmd
+AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/../../include/kmd -DIN_LIBVA
 dummy_drv_video_la_SOURCES = dummy_drv_video.c object_heap.c
 
+noinst_HEADERS = dummy_drv_video.h object_heap.h
similarity index 99%
rename from dummy_drv_video/dummy_drv_video.c
rename to libva/dummy_drv_video/dummy_drv_video.c
index 3ba1ee9..4db2e46 100644 (file)
@@ -736,6 +736,12 @@ VAStatus dummy_CreateContext(
     obj_context->picture_height = picture_height;
     obj_context->num_render_targets = num_render_targets;
     obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
+    if (obj_context->render_targets == NULL)
+    {
+        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+        return vaStatus;
+    }
+    
     for(i = 0; i < num_render_targets; i++)
     {
         if (NULL == SURFACE(render_targets[i]))
@@ -1251,7 +1257,6 @@ VAStatus __vaDriverInit_0_29(  VADriverContextP ctx )
     ctx->vtable.vaCreateSubpicture = dummy_CreateSubpicture;
     ctx->vtable.vaDestroySubpicture = dummy_DestroySubpicture;
     ctx->vtable.vaSetSubpictureImage = dummy_SetSubpictureImage;
-    ctx->vtable.vaSetSubpicturePalette = dummy_SetSubpicturePalette;
     ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
     ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
     ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
similarity index 99%
rename from dummy_drv_video/object_heap.c
rename to libva/dummy_drv_video/object_heap.c
index 5e85064..e867139 100644 (file)
@@ -27,6 +27,7 @@
 #include "assert.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 #define ASSERT assert
 
similarity index 73%
rename from libva.pc.in
rename to libva/libva.pc.in
index d46f53c..16fb6aa 100644 (file)
@@ -4,7 +4,7 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: libva
-Description: Userspace Video Acceleration (VA) interface
+Description: Userspace Video Acceleration (VA) core interface
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lva
 Cflags: -I${includedir}
similarity index 66%
rename from src/Makefile.am
rename to libva/src/Makefile.am
index 11d9e77..6767bfc 100644 (file)
 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
+INCLUDES = \
+       $(LIBVA_CFLAGS) \
+       -DIN_LIBVA
+
 libva_la_LTLIBRARIES = libva.la
 libva_ladir = $(libdir)
-libva_la_LDFLAGS = -version-number 0:29:0 -no-undefined
-libva_la_LIBADD = -ldl -lX11 -lXext -lXfixes -lXdamage
+libva_la_LDFLAGS = -version-number 0:30:0 -no-undefined
+libva_la_LIBADD = $(LIBVA_LIBS) -ldl -lX11 -lXext X11/libva_X11.la
+CFLAGS = -ansi -O2 
+
+nodist_libva_la_SOURCES = va_version.h
+BUILT_SOURCES = va_version.h
+
+CLEANFILES = va_version.h
+
+va_version.h: Makefile
+       echo "#define VA_BUILD_DATE \"$(shell date +'%Y%m%d') $(shell date +'1%H%M%S') \"" > va_version.h
+       echo "#define VA_BUILD_GIT  \"($(shell git log  | head -n1 | cut -f2 -d' ')) \" "    >> va_version.h
+
 
-libva_la_SOURCES = va_dri.c va.c va_dristr.h
+SUBDIRS = X11
 
-libvaincludedir = ${includedir}
-libvainclude_HEADERS = va.h va_x11.h va_dri.h va_backend.h
+libva_la_SOURCES = va.c 
 
-EXTRA_DIST = ChangeLog TODO
+libvaincludedir = ${includedir}/va
+libvainclude_HEADERS = va.h va_backend.h
diff --git a/libva/src/X11/Makefile.am b/libva/src/X11/Makefile.am
new file mode 100644 (file)
index 0000000..155920f
--- /dev/null
@@ -0,0 +1,29 @@
+# INTEL CONFIDENTIAL
+# Copyright 2007 Intel Corporation. All Rights Reserved.
+#
+# The source code contained or described herein and all documents related to
+# the source code ("Material") are owned by Intel Corporation or its suppliers
+# or licensors. Title to the Material remains with Intel Corporation or its
+# suppliers and licensors. The Material may contain trade secrets and
+# proprietary and confidential information of Intel Corporation and its
+# suppliers and licensors, and is protected by worldwide copyright and trade
+# secret laws and treaty provisions. No part of the Material may be used,
+# copied, reproduced, modified, published, uploaded, posted, transmitted,
+# distributed, or disclosed in any way without Intel's prior express written
+# permission. 
+# 
+# No license under any patent, copyright, trade secret or other intellectual
+# property right is granted to or conferred upon you by disclosure or delivery
+# of the Materials, either expressly, by implication, inducement, estoppel or
+# otherwise. Any license under such intellectual property rights must be
+# express and approved by Intel in writing.
+
+AM_CFLAGS = -DLINUX -DIN_LIBVA -I$(top_srcdir)/src $(DRM_CFLAGS)
+
+noinst_LTLIBRARIES = libva_X11.la      
+
+libva_X11includedir =  ${includedir}/va
+libva_X11include_HEADERS = va_x11.h va_dri.h va_dri2.h
+
+libva_X11_la_SOURCES = va_x11.c va_dri.c va_dri2.c
+CFLAGS = -ansi -O2 
similarity index 100%
rename from src/va_dri.c
rename to libva/src/X11/va_dri.c
similarity index 100%
rename from src/va_dri.h
rename to libva/src/X11/va_dri.h
diff --git a/libva/src/X11/va_dri2.c b/libva/src/X11/va_dri2.c
new file mode 100644 (file)
index 0000000..c602bba
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "xf86drm.h"
+#include "va_dri2.h"
+#include "va_dri2str.h"
+#include "va_dri2tokens.h"
+
+#ifndef DRI2DriverDRI
+#define DRI2DriverDRI 0
+#endif
+
+static char va_dri2ExtensionName[] = DRI2_NAME;
+static XExtensionInfo _va_dri2_info_data;
+static XExtensionInfo *va_dri2Info = &_va_dri2_info_data;
+static XEXT_GENERATE_CLOSE_DISPLAY (VA_DRI2CloseDisplay, va_dri2Info)
+static /* const */ XExtensionHooks va_dri2ExtensionHooks = {
+    NULL,                              /* create_gc */
+    NULL,                              /* copy_gc */
+    NULL,                              /* flush_gc */
+    NULL,                              /* free_gc */
+    NULL,                              /* create_font */
+    NULL,                              /* free_font */
+    VA_DRI2CloseDisplay,               /* close_display */
+    NULL,                              /* wire_to_event */
+    NULL,                              /* event_to_wire */
+    NULL,                              /* error */
+    NULL,                              /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, va_dri2Info, 
+                                  va_dri2ExtensionName, 
+                                  &va_dri2ExtensionHooks, 
+                                  0, NULL)
+
+Bool VA_DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+
+    if (XextHasExtension(info)) {
+       *eventBase = info->codes->first_event;
+       *errorBase = info->codes->first_error;
+       return True;
+    }
+
+    return False;
+}
+
+Bool VA_DRI2QueryVersion(Display *dpy, int *major, int *minor)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay (dpy);
+    xDRI2QueryVersionReply rep;
+    xDRI2QueryVersionReq *req;
+
+    XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2QueryVersion, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2QueryVersion;
+    req->majorVersion = DRI2_MAJOR;
+    req->minorVersion = DRI2_MINOR;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    *major = rep.majorVersion;
+    *minor = rep.minorVersion;
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+
+Bool VA_DRI2Connect(Display *dpy, XID window,
+                char **driverName, char **deviceName)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2ConnectReply rep;
+    xDRI2ConnectReq *req;
+
+    XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2Connect, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2Connect;
+    req->window = window;
+    req->driverType = DRI2DriverDRI;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    *driverName = Xmalloc(rep.driverNameLength + 1);
+    if (*driverName == NULL) {
+       _XEatData(dpy, 
+                 ((rep.driverNameLength + 3) & ~3) +
+                 ((rep.deviceNameLength + 3) & ~3));
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    _XReadPad(dpy, *driverName, rep.driverNameLength);
+    (*driverName)[rep.driverNameLength] = '\0';
+
+    *deviceName = Xmalloc(rep.deviceNameLength + 1);
+    if (*deviceName == NULL) {
+       Xfree(*driverName);
+       _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    _XReadPad(dpy, *deviceName, rep.deviceNameLength);
+    (*deviceName)[rep.deviceNameLength] = '\0';
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+
+Bool VA_DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2AuthenticateReq *req;
+    xDRI2AuthenticateReply rep;
+
+    XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2Authenticate, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2Authenticate;
+    req->window = window;
+    req->magic = magic;
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return rep.authenticated;
+}
+
+void VA_DRI2CreateDrawable(Display *dpy, XID drawable)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2CreateDrawableReq *req;
+
+    XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2CreateDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2CreateDrawable;
+    req->drawable = drawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void VA_DRI2DestroyDrawable(Display *dpy, XID drawable)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2DestroyDrawableReq *req;
+
+    XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+    XSync(dpy, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2DestroyDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2DestroyDrawable;
+    req->drawable = drawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+VA_DRI2Buffer *VA_DRI2GetBuffers(Display *dpy, XID drawable,
+                          int *width, int *height,
+                          unsigned int *attachments, int count,
+                          int *outCount)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2GetBuffersReply rep;
+    xDRI2GetBuffersReq *req;
+    VA_DRI2Buffer *buffers;
+    xDRI2Buffer repBuffer;
+    CARD32 *p;
+    int i;
+
+    XextCheckExtension (dpy, info, va_dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReqExtra(DRI2GetBuffers, count * 4, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2GetBuffers;
+    req->drawable = drawable;
+    req->count = count;
+    p = (CARD32 *) &req[1];
+    for (i = 0; i < count; i++)
+       p[i] = attachments[i];
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return NULL;
+    }
+
+    *width = rep.width;
+    *height = rep.height;
+    *outCount = rep.count;
+
+    buffers = Xmalloc(rep.count * sizeof buffers[0]);
+    if (buffers == NULL) {
+       _XEatData(dpy, rep.count * sizeof repBuffer);
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return NULL;
+    }
+
+    for (i = 0; i < rep.count; i++) {
+       _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+       buffers[i].attachment = repBuffer.attachment;
+       buffers[i].name = repBuffer.name;
+       buffers[i].pitch = repBuffer.pitch;
+       buffers[i].cpp = repBuffer.cpp;
+       buffers[i].flags = repBuffer.flags;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return buffers;
+}
+
+void VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+                   CARD32 dest, CARD32 src)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2CopyRegionReq *req;
+    xDRI2CopyRegionReply rep;
+
+    XextSimpleCheckExtension (dpy, info, va_dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2CopyRegion, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2CopyRegion;
+    req->drawable = drawable;
+    req->region = region;
+    req->dest = dest;
+    req->src = src;
+
+    _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
diff --git a/libva/src/X11/va_dri2.h b/libva/src/X11/va_dri2.h
new file mode 100644 (file)
index 0000000..a26a839
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright Â© 2007,2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _VA_DRI2_H_
+#define _VA_DRI2_H_
+
+#include <X11/extensions/Xfixes.h>
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+typedef struct {
+    unsigned int attachment;
+    unsigned int name;
+    unsigned int pitch;
+    unsigned int cpp;
+    unsigned int flags;
+} VA_DRI2Buffer;
+
+extern Bool
+VA_DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
+extern Bool
+VA_DRI2QueryVersion(Display *display, int *major, int *minor);
+extern Bool
+VA_DRI2Connect(Display *display, XID window,
+           char **driverName, char **deviceName);
+extern Bool
+VA_DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
+extern void
+VA_DRI2CreateDrawable(Display *display, XID drawable);
+extern void
+VA_DRI2DestroyDrawable(Display *display, XID handle);
+extern VA_DRI2Buffer *
+VA_DRI2GetBuffers(Display *dpy, XID drawable,
+              int *width, int *height,
+              unsigned int *attachments, int count,
+              int *outCount);
+#if 0
+extern void
+VA_DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+              CARD32 dest, CARD32 src);
+#endif
+#endif
diff --git a/libva/src/X11/va_dri2str.h b/libva/src/X11/va_dri2str.h
new file mode 100644 (file)
index 0000000..dc3f2d1
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _DRI2_PROTO_H_
+#define _DRI2_PROTO_H_
+
+#define DRI2_NAME                      "DRI2"
+#define DRI2_MAJOR                     1
+#define DRI2_MINOR                     0
+
+#define DRI2NumberErrors               0
+#define DRI2NumberEvents               0
+#define DRI2NumberRequests             7
+
+#define X_DRI2QueryVersion             0
+#define X_DRI2Connect                  1
+#define X_DRI2Authenticate             2
+#define X_DRI2CreateDrawable           3
+#define X_DRI2DestroyDrawable          4
+#define X_DRI2GetBuffers               5
+#define X_DRI2CopyRegion               6
+
+typedef struct {
+    CARD32  attachment B32;
+    CARD32  name B32;
+    CARD32  pitch B32;
+    CARD32  cpp B32;
+    CARD32  flags B32;
+} xDRI2Buffer;
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  majorVersion B32;
+    CARD32  minorVersion B32;
+} xDRI2QueryVersionReq;
+#define sz_xDRI2QueryVersionReq   12
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  majorVersion B32;
+    CARD32  minorVersion B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+} xDRI2QueryVersionReply;
+#define sz_xDRI2QueryVersionReply      32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  window B32;
+    CARD32  driverType B32;
+} xDRI2ConnectReq;
+#define sz_xDRI2ConnectReq     12
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  driverNameLength B32;
+    CARD32  deviceNameLength B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+} xDRI2ConnectReply;
+#define sz_xDRI2ConnectReply   32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  window B32;
+    CARD32  magic B32;
+} xDRI2AuthenticateReq;
+#define sz_xDRI2AuthenticateReq   12
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  authenticated B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+    CARD32  pad6 B32;
+} xDRI2AuthenticateReply;
+#define sz_xDRI2AuthenticateReply      32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+} xDRI2CreateDrawableReq;
+#define sz_xDRI2CreateDrawableReq   8
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+} xDRI2DestroyDrawableReq;
+#define sz_xDRI2DestroyDrawableReq   8
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  count B32;
+} xDRI2GetBuffersReq;
+#define sz_xDRI2GetBuffersReq   12
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  width B32;
+    CARD32  height B32;
+    CARD32  count B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+} xDRI2GetBuffersReply;
+#define sz_xDRI2GetBuffersReply        32
+
+typedef struct {
+    CARD8   reqType;
+    CARD8   dri2ReqType;
+    CARD16  length B16;
+    CARD32  drawable B32;
+    CARD32  region B32;
+    CARD32  dest B32;
+    CARD32  src B32;
+} xDRI2CopyRegionReq;
+#define sz_xDRI2CopyRegionReq   20
+
+typedef struct {
+    BYTE    type;   /* X_Reply */
+    BYTE    pad1;
+    CARD16  sequenceNumber B16;
+    CARD32  length B32;
+    CARD32  pad2 B32;
+    CARD32  pad3 B32;
+    CARD32  pad4 B32;
+    CARD32  pad5 B32;
+    CARD32  pad6 B32;
+    CARD32  pad7 B32;
+} xDRI2CopyRegionReply;
+#define sz_xDRI2CopyRegionReply        32
+
+#endif
diff --git a/libva/src/X11/va_dri2tokens.h b/libva/src/X11/va_dri2tokens.h
new file mode 100644 (file)
index 0000000..087159f
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _DRI2_TOKENS_H_
+#define _DRI2_TOKENS_H_
+
+#define DRI2BufferFrontLeft            0
+#define DRI2BufferBackLeft             1
+#define DRI2BufferFrontRight           2
+#define DRI2BufferBackRight            3
+#define DRI2BufferDepth                        4
+#define DRI2BufferStencil              5
+#define DRI2BufferAccum                        6
+#define DRI2BufferFakeFrontLeft                7
+#define DRI2BufferFakeFrontRight       8
+
+#define DRI2DriverDRI                  0
+
+#endif
similarity index 100%
rename from src/va_dristr.h
rename to libva/src/X11/va_dristr.h
diff --git a/libva/src/X11/va_x11.c b/libva/src/X11/va_x11.c
new file mode 100644 (file)
index 0000000..85b21d5
--- /dev/null
@@ -0,0 +1,304 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "va.h"
+#include "va_backend.h"
+#include "va_x11.h"
+#include "va_dri.h"
+#include "va_dri2.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+static VADisplayContextP pDisplayContexts = NULL;
+
+static void va_errorMessage(const char *msg, ...)
+{
+    va_list args;
+
+    fprintf(stderr, "libva error: ");
+    va_start(args, msg);
+    vfprintf(stderr, msg, args);
+    va_end(args);
+}
+
+static void va_infoMessage(const char *msg, ...)
+{
+    va_list args;
+
+    fprintf(stderr, "libva: ");
+    va_start(args, msg);
+    vfprintf(stderr, msg, args);
+    va_end(args);
+}
+
+static int va_DisplayContextIsValid (
+    VADisplayContextP pDisplayContext
+)
+{
+    VADisplayContextP ctx = pDisplayContexts;
+
+    while (ctx)
+    {
+       if (ctx == pDisplayContext && pDisplayContext->pDriverContext)
+           return 1;
+       ctx = ctx->pNext;
+    }
+    return 0;
+}
+
+static void va_DisplayContextDestroy (
+    VADisplayContextP pDisplayContext
+)
+{
+    VADisplayContextP *ctx = &pDisplayContexts;
+
+    /* Throw away pDisplayContext */
+    while (*ctx)
+    {
+       if (*ctx == pDisplayContext)
+       {
+           *ctx = pDisplayContext->pNext;
+           pDisplayContext->pNext = NULL;
+           break;
+       }
+       ctx = &((*ctx)->pNext);
+    }
+    free(pDisplayContext->pDriverContext);
+    free(pDisplayContext);
+}
+
+
+static VAStatus va_DRI2GetDriverName (
+    VADisplayContextP pDisplayContext,
+    char **driver_name
+)
+{
+    VADriverContextP ctx = pDisplayContext->pDriverContext;
+    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+    int eventBase, errorBase;
+    char *device_name;
+    int driver_major;
+    int driver_minor;
+    int driver_patch;
+    Bool result = True;
+
+    if (!VA_DRI2QueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) {
+        va_infoMessage("DRI2 extension isn't present\n");
+        return VA_STATUS_ERROR_UNKNOWN;
+    }
+
+    if (!VA_DRI2QueryVersion(ctx->x11_dpy, &driver_major, &driver_minor)) {
+        va_errorMessage("VA_DRI2QueryVersion failed\n");
+        return VA_STATUS_ERROR_UNKNOWN;
+    }
+    
+    if (!VA_DRI2Connect(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen),
+                    driver_name, &device_name)) {
+        va_infoMessage("DRI2 isn't enabled, fallback to DRI1\n");
+        return VA_STATUS_ERROR_UNKNOWN;
+    }
+
+    va_infoMessage("VA_DRI2Connect: %d.%d.%d %s (screen %d)\n",
+                   driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
+    ctx->dri2 = 1;
+    
+    return VA_STATUS_SUCCESS;
+}
+
+static VAStatus va_DRIGetDriverName (
+    VADisplayContextP pDisplayContext,
+    char **driver_name
+)
+{
+    VADriverContextP ctx = pDisplayContext->pDriverContext;
+    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+    int eventBase, errorBase;
+    int direct_capable;
+    int driver_major;
+    int driver_minor;
+    int driver_patch;
+    Bool result = True;
+    char *x_driver_name = NULL;
+
+    if (!VA_DRIQueryExtension(ctx->x11_dpy, &eventBase, &errorBase)) {
+        va_errorMessage("VA_DRIQueryExtension failed\n");
+        return VA_STATUS_ERROR_UNKNOWN;
+    }
+    
+    if (result)
+    {
+        result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
+        if (!result)
+        {
+            va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
+        }
+    }
+    if (result)
+    {
+        result = direct_capable;
+        if (!result)
+        {
+            va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
+        }
+    }
+    if (result)
+    {
+        result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
+                                            &driver_patch, &x_driver_name);
+        if (!result)
+        {
+            va_errorMessage("VA_DRIGetClientDriverName returned false\n");
+        }
+    }
+    if (result)
+    {
+        vaStatus = VA_STATUS_SUCCESS;
+        va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
+            driver_major, driver_minor, driver_patch, x_driver_name, ctx->x11_screen);
+        if (driver_name)
+           *driver_name = strdup(x_driver_name);
+    }
+    if (x_driver_name)
+        XFree(x_driver_name);
+
+    return vaStatus;
+}
+
+static VAStatus va_DisplayContextGetDriverName (
+    VADisplayContextP pDisplayContext,
+    char **driver_name
+)
+{
+    VADriverContextP ctx = pDisplayContext->pDriverContext;
+    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
+    int direct_capable;
+    int driver_major;
+    int driver_minor;
+    int driver_patch;
+    Bool result = True;
+    char *x_driver_name = NULL;
+
+    if (driver_name)
+       *driver_name = NULL;
+    
+    vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name);
+    if (vaStatus != VA_STATUS_SUCCESS)
+        vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name);
+
+    if ((vaStatus == VA_STATUS_SUCCESS)
+        && geteuid() == getuid())
+    {
+        /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
+        if (getenv("LIBVA_DRIVER_NAME"))
+        {
+            /* For easier debugging */
+            if (*driver_name)
+                XFree(*driver_name);
+            
+            *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
+            return VA_STATUS_SUCCESS;
+        }
+    }
+    
+    return vaStatus;
+}
+
+int vaDisplayIsValid(VADisplay dpy)
+{
+  VADisplayContextP tmp=NULL;
+  VADisplayContextP pDisplayContext = pDisplayContexts;
+
+  while (pDisplayContext)
+  {
+      if (pDisplayContext == (VADisplayContextP)dpy)
+      {
+          tmp = (VADisplay)pDisplayContext;
+          break;
+      }
+      pDisplayContext = pDisplayContext->pNext;
+  }
+
+  if (!tmp)
+      return 0;
+  
+  return tmp->vaIsValid(pDisplayContext);
+}
+
+
+VADisplay vaGetDisplay (
+    Display *native_dpy /* implementation specific */
+)
+{
+  VADisplay dpy = NULL;
+  VADisplayContextP pDisplayContext = pDisplayContexts;
+
+  if (!native_dpy)
+      return NULL;
+
+  while (pDisplayContext)
+  {
+      if (pDisplayContext->pDriverContext &&
+         pDisplayContext->pDriverContext->x11_dpy == native_dpy)
+      {
+          dpy = (VADisplay)pDisplayContext;
+          break;
+      }
+      pDisplayContext = pDisplayContext->pNext;
+  }
+
+  if (!dpy)
+  {
+      /* create new entry */
+      VADriverContextP pDriverContext;
+      pDisplayContext = calloc(1, sizeof(*pDisplayContext));
+      pDriverContext  = calloc(1, sizeof(*pDriverContext));
+      if (pDisplayContext && pDriverContext)
+      {
+         pDriverContext->old_pNext        = (void *)(unsigned long)0xdeadbeef;
+         pDriverContext->x11_dpy          = native_dpy;
+         pDisplayContext->pNext           = pDisplayContexts;
+         pDisplayContext->pDriverContext  = pDriverContext;
+         pDisplayContext->vaIsValid       = va_DisplayContextIsValid;
+         pDisplayContext->vaDestroy       = va_DisplayContextDestroy;
+         pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName;
+         pDisplayContexts                 = pDisplayContext;
+         dpy                              = (VADisplay)pDisplayContext;
+      }
+      else
+      {
+         if (pDisplayContext)
+             free(pDisplayContext);
+         if (pDriverContext)
+             free(pDriverContext);
+      }
+  }
+  
+  return dpy;
+}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 50%
rename from src/va_x11.h
rename to libva/src/X11/va_x11.h
index a316162..2171ac6
@@ -1,28 +1,24 @@
-/*
- * Video Decode Acceleration API, X11 specific functions
- *
- * Rev. 0.15
- * <jonathan.bian@intel.com>
- *
- * Revision History:
- * rev 0.1 (12/10/06 Jonathan Bian) - Initial draft
- * rev 0.11 (12/15/06 Jonathan Bian) - Fixed some errors
- * rev 0.12 (02/05/07 Jonathan Bian) - Added VC-1 data structures
- * rev 0.13 (02/28/07 Jonathan Bian) - Added GetDisplay()
- * rev 0.14 (04/13/07 Jonathan Bian) - Fixed MPEG-2 PictureParameter struct, cleaned up a few funcs.
- * rev 0.15 (04/20/07 Jonathan Bian) - Overhauled buffer management  
- *
- */
-
 #ifndef _VA_X11_H_
 #define _VA_X11_H_
 
+#ifdef IN_LIBVA
 #include "va.h"
+#else
+#include <va/va.h>
+#endif
 #include <X11/Xlib.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+/*
+ * Returns a suitable VADisplay for VA API
+ */
+VADisplay vaGetDisplay (
+    Display *dpy
+);
+
 /*
  * Output rendering
  * Following is the rendering interface for X windows, 
@@ -31,21 +27,25 @@ extern "C" {
  * color space conversion and scaling to the destination
  * rectangle
  */
+/* de-interlacing flags for vaPutSurface */
+#define VA_FRAME_PICTURE       0x00000000 
+#define VA_TOP_FIELD           0x00000001
+#define VA_BOTTOM_FIELD                0x00000002
 
-/* de-interlace flags for vaPutSurface */
-#define VA_FRAME_PICTURE        0x00000000 
-#define VA_TOP_FIELD            0x00000001
-#define VA_BOTTOM_FIELD         0x00000002
 /* 
  * clears the drawable with background color.
  * for hardware overlay based implementation this flag
  * can be used to turn off the overlay
  */
-#define VA_CLEAR_DRAWABLE       0x00000008 
+#define VA_CLEAR_DRAWABLE      0x00000008 
+
+/* color space conversion flags for vaPutSurface */
+#define VA_SRC_BT601           0x00000010
+#define VA_SRC_BT709           0x00000020
 
 VAStatus vaPutSurface (
     VADisplay dpy,
-    VASurfaceID surface,
+    VASurfaceID surface,       
     Drawable draw, /* X Drawable */
     short srcx,
     short srcy,
@@ -55,9 +55,9 @@ VAStatus vaPutSurface (
     short desty,
     unsigned short destw,
     unsigned short desth,
-    VARectangle *cliprects, /* client supplied clip list */
+    VARectangle *cliprects, /* client supplied destination clip list */
     unsigned int number_cliprects, /* number of clip rects in the clip list */
-    unsigned int flags /* de-interlacing flags */
+    unsigned int flags /* PutSurface flags */
 );
 
 #ifdef __cplusplus
similarity index 79%
rename from src/va.c
rename to libva/src/va.c
index 2da7e18..60ecb4f 100644 (file)
--- a/src/va.c
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "X11/Xlib.h"
 #include "va.h"
 #include "va_backend.h"
 
-#include "assert.h"
+#include "va_version.h"
+
+#include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <dlfcn.h>
 #include <unistd.h>
-#include "va_dri.h"
+
+#define VA_STR_VERSION         VA_BUILD_DATE VA_BUILD_GIT
 
 #define VA_MAJOR_VERSION       0
-#define VA_MINOR_VERSION       29
-#define DRIVER_INIT_FUNC       "__vaDriverInit_0_29"
+#define VA_MINOR_VERSION       30
+#define DRIVER_INIT_FUNC       "__vaDriverInit_0_30"
 
-#define DEFAULT_DRIVER_DIR     "/usr/X11R6/lib/modules/dri"
+#define DEFAULT_DRIVER_DIR     "/usr/lib/dri/"
 #define DRIVER_EXTENSION       "_drv_video.so"
 
-#define CTX(dpy) ((VADriverContextP) dpy );
-#define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
+#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
+#define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
+
 #define ASSERT         assert
 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
 
 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
 
-static VADriverContextP pDriverContexts = NULL;
 static int va_debug_trace = 0;
 
-static Bool vaContextIsValid(VADriverContextP arg_ctx)
-{
-  VADriverContextP ctx = pDriverContexts;
-  
-  while (ctx)
-  {
-      if (ctx == arg_ctx)
-      {
-          return True;
-      }
-      ctx = ctx->pNext;
-  }
-  return False;
-}
-
-VADisplay vaGetDisplay (
-    NativeDisplay native_dpy    /* implementation specific */
-)
-{
-  VADisplay dpy = NULL;
-  VADriverContextP ctx = pDriverContexts;
-
-  if (!native_dpy)
-  {
-      return NULL;
-  }
-
-  while (ctx)
-  {
-      if (ctx->x11_dpy == (Display *)native_dpy)
-      {
-          dpy = (VADisplay) ctx;
-          break;
-      }
-      ctx = ctx->pNext;
-  }
-  
-  if (!dpy)
-  {
-      /* create new entry */
-      ctx = (VADriverContextP) calloc(1, sizeof(struct VADriverContext));
-      ctx->pNext = pDriverContexts;
-      ctx->x11_dpy = (Display *) native_dpy;
-      pDriverContexts = ctx;
-      dpy = (VADisplay) ctx;
-  }
-  
-  return dpy;
-}
+int vaDisplayIsValid(VADisplay dpy);
 
 static void va_errorMessage(const char *msg, ...)
 {
@@ -153,63 +107,15 @@ static Bool va_checkString(const char* value, char *variable)
     return True;
 }
 
-static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
+static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
 {
-    VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
-    int direct_capable;
-    int driver_major;
-    int driver_minor;
-    int driver_patch;
-    Bool result = True;
-    
-    *driver_name = NULL;
-    if (geteuid() == getuid())
-    {
-        /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
-        if (getenv("LIBVA_DRIVER_NAME"))
-        {
-            /* For easier debugging */
-            *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
-            return VA_STATUS_SUCCESS;
-        }
-    }
-    if (result)
-    {
-        result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
-        if (!result)
-        {
-            va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
-        }
-    }
-    if (result)
-    {
-        result = direct_capable;
-        if (!result)
-        {
-            va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
-        }
-    }
-    if (result)
-    {
-        result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
-                                            &driver_patch, driver_name);
-        if (!result)
-        {
-            va_errorMessage("VA_DRIGetClientDriverName returned false\n");
-        }
-    }
-    if (result)
-    {
-        vaStatus = VA_STATUS_SUCCESS;
-        va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
-            driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
-    }
-
-    return vaStatus;
+    VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
+    return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
 }
 
-static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
+static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
 {
+    VADriverContextP ctx = CTX(dpy);
     VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
     char *search_path = NULL;
     char *saveptr;
@@ -237,14 +143,14 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
         char *driver_path = (char *) malloc( strlen(driver_dir) +
                                              strlen(driver_name) +
                                              strlen(DRIVER_EXTENSION) + 2 );
-        strcpy( driver_path, driver_dir );
-        strcat( driver_path, "/" );
-        strcat( driver_path, driver_name );
-        strcat( driver_path, DRIVER_EXTENSION );
+        strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
+        strncat( driver_path, "/", strlen("/") );
+        strncat( driver_path, driver_name, strlen(driver_name) );
+        strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
         
         va_infoMessage("Trying to open %s\n", driver_path);
 
-        handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
+        handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
         if (!handle)
         {
             /* Don't give errors for non-existing files */
@@ -309,7 +215,6 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
                     CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
                     CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
                     CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
-                    CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
                     CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
                     CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
                     CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
@@ -345,9 +250,10 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
 
 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
 {
-    VADriverContextP ctx = CTX(dpy);
-    if( !vaContextIsValid(ctx) )
+    VADriverContextP ctx;
+    if( !vaDisplayIsValid(dpy) )
         return NULL;
+    ctx = CTX(dpy);
 
     if (NULL == ctx->handle)
         return NULL;
@@ -415,20 +321,21 @@ VAStatus vaInitialize (
     int *minor_version          /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
   char *driver_name = NULL;
   VAStatus vaStatus;
   
-  CHECK_CONTEXT(ctx);
+  CHECK_DISPLAY(dpy);
 
   va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
 
-  vaStatus = va_getDriverName(ctx, &driver_name);
+  va_infoMessage("libva build on %s\n", VA_STR_VERSION);
+
+  vaStatus = va_getDriverName(dpy, &driver_name);
   va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
   
   if (VA_STATUS_SUCCESS == vaStatus)
   {
-      vaStatus = va_openDriver(ctx, driver_name);
+      vaStatus = va_openDriver(dpy, driver_name);
       va_infoMessage("va_openDriver() returns %d\n", vaStatus);
       
       *major_version = VA_MAJOR_VERSION;
@@ -436,9 +343,7 @@ VAStatus vaInitialize (
   }
 
   if (driver_name)
-  {
-      XFree(driver_name);
-  }
+      free(driver_name);
   return vaStatus;
 }
 
@@ -451,8 +356,11 @@ VAStatus vaTerminate (
 )
 {
   VAStatus vaStatus = VA_STATUS_SUCCESS;
-  VADriverContextP old_ctx = CTX(dpy);
-  CHECK_CONTEXT(old_ctx);
+  VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
+  VADriverContextP old_ctx;
+
+  CHECK_DISPLAY(dpy);
+  old_ctx = CTX(dpy);
 
   if (old_ctx->handle)
   {
@@ -462,22 +370,7 @@ VAStatus vaTerminate (
   }
 
   if (VA_STATUS_SUCCESS == vaStatus)
-  {
-      VADriverContextP *ctx = &pDriverContexts;
-
-      /* Throw away old_ctx */
-      while (*ctx)
-      {
-          if (*ctx == old_ctx)
-          {
-              *ctx = old_ctx->pNext;
-              old_ctx->pNext = NULL;
-              break;
-          }
-          ctx = &((*ctx)->pNext);
-      }
-      free(old_ctx);
-  }
+      pDisplayContext->vaDestroy(pDisplayContext);
   return vaStatus;
 }
 
@@ -493,13 +386,10 @@ const char *vaQueryVendorString (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return NULL;
-  }
   
-  return ctx->str_vendor;
+  return CTX(dpy)->str_vendor;
 }
 
 
@@ -508,13 +398,10 @@ int vaMaxNumProfiles (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_profiles;
+  return CTX(dpy)->max_profiles;
 }
 
 /* Get maximum number of entrypoints supported by the implementation */
@@ -522,13 +409,10 @@ int vaMaxNumEntrypoints (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_entrypoints;
+  return CTX(dpy)->max_entrypoints;
 }
 
 
@@ -537,13 +421,10 @@ int vaMaxNumConfigAttributes (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_attributes;
+  return CTX(dpy)->max_attributes;
 }
 
 VAStatus vaQueryConfigEntrypoints (
@@ -553,8 +434,9 @@ VAStatus vaQueryConfigEntrypoints (
     int *num_entrypoints       /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQueryConfigEntrypoints);
   return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
@@ -568,8 +450,9 @@ VAStatus vaGetConfigAttributes (
     int num_attribs
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaGetConfigAttributes);
   return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
@@ -581,8 +464,9 @@ VAStatus vaQueryConfigProfiles (
     int *num_profiles          /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQueryConfigProfiles);
   return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
@@ -597,8 +481,9 @@ VAStatus vaCreateConfig (
     VAConfigID *config_id /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateConfig);
   return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
@@ -609,8 +494,9 @@ VAStatus vaDestroyConfig (
     VAConfigID config_id
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroyConfig);
   return ctx->vtable.vaDestroyConfig ( ctx, config_id );
@@ -625,8 +511,9 @@ VAStatus vaQueryConfigAttributes (
     int *num_attribs           /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQueryConfigAttributes);
   return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
@@ -641,21 +528,38 @@ VAStatus vaCreateSurfaces (
     VASurfaceID *surfaces      /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateSurfaces);
   return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
 }
 
+
+VAStatus vaCreateSurfaceFromCIFrame (
+    VADisplay dpy,
+    unsigned long frame_id,
+    VASurfaceID *surface       /* out */
+)
+{
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
+
+  TRACE(vaCreateSurfacesFromCIFrame);
+  return ctx->vtable.vaCreateSurfaceFromCIFrame( ctx, frame_id, surface );
+}
+
 VAStatus vaDestroySurfaces (
     VADisplay dpy,
     VASurfaceID *surface_list,
     int num_surfaces
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroySurfaces);
   return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
@@ -672,8 +576,9 @@ VAStatus vaCreateContext (
     VAContextID *context               /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateContext);
   return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
@@ -685,8 +590,9 @@ VAStatus vaDestroyContext (
     VAContextID context
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroyContext);
   return ctx->vtable.vaDestroyContext( ctx, context );
@@ -702,8 +608,9 @@ VAStatus vaCreateBuffer (
     VABufferID *buf_id         /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateBuffer);
   return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
@@ -715,8 +622,9 @@ VAStatus vaBufferSetNumElements (
     unsigned int num_elements /* in */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaBufferSetNumElements);
   return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
@@ -729,8 +637,9 @@ VAStatus vaMapBuffer (
     void **pbuf        /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaMapBuffer);
   return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
@@ -741,8 +650,9 @@ VAStatus vaUnmapBuffer (
     VABufferID buf_id  /* in */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaUnmapBuffer);
   return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
@@ -753,8 +663,9 @@ VAStatus vaDestroyBuffer (
     VABufferID buffer_id
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroyBuffer);
   return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
@@ -766,8 +677,9 @@ VAStatus vaBeginPicture (
     VASurfaceID render_target
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaBeginPicture);
   return ctx->vtable.vaBeginPicture( ctx, context, render_target );
@@ -780,8 +692,9 @@ VAStatus vaRenderPicture (
     int num_buffers
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaRenderPicture);
   return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
@@ -792,8 +705,9 @@ VAStatus vaEndPicture (
     VAContextID context
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaEndPicture);
   return ctx->vtable.vaEndPicture( ctx, context );
@@ -805,8 +719,9 @@ VAStatus vaSyncSurface (
     VASurfaceID render_target
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSyncSurface);
   return ctx->vtable.vaSyncSurface( ctx, context, render_target );
@@ -818,8 +733,9 @@ VAStatus vaQuerySurfaceStatus (
     VASurfaceStatus *status    /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQuerySurfaceStatus);
   return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
@@ -842,8 +758,9 @@ VAStatus vaPutSurface (
     unsigned int flags /* de-interlacing flags */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaPutSurface);
   return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
@@ -856,13 +773,10 @@ int vaMaxNumImageFormats (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_image_formats;
+  return CTX(dpy)->max_image_formats;
 }
 
 VAStatus vaQueryImageFormats (
@@ -871,8 +785,9 @@ VAStatus vaQueryImageFormats (
     int *num_formats           /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQueryImageFormats);
   return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
@@ -894,8 +809,9 @@ VAStatus vaCreateImage (
     VAImage *image     /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateImage);
   return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
@@ -909,8 +825,9 @@ VAStatus vaDestroyImage (
     VAImageID image
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroyImage);
   return ctx->vtable.vaDestroyImage ( ctx, image);
@@ -922,8 +839,9 @@ VAStatus vaSetImagePalette (
     unsigned char *palette
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSetImagePalette);
   return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
@@ -943,8 +861,9 @@ VAStatus vaGetImage (
     VAImageID image
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaGetImage);
   return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
@@ -966,8 +885,9 @@ VAStatus vaPutImage (
     int dest_y
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaPutImage);
   return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
@@ -991,8 +911,9 @@ VAStatus vaPutImage2 (
     unsigned int dest_height
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaPutImage2);
   return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
@@ -1035,8 +956,9 @@ VAStatus vaDeriveImage (
     VAImage *image     /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDeriveImage);
   return ctx->vtable.vaDeriveImage ( ctx, surface, image );
@@ -1048,13 +970,10 @@ int vaMaxNumSubpictureFormats (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_subpic_formats;
+  return CTX(dpy)->max_subpic_formats;
 }
 
 /* 
@@ -1071,8 +990,9 @@ VAStatus vaQuerySubpictureFormats (
     unsigned int *num_formats  /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQuerySubpictureFormats);
   return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
@@ -1087,8 +1007,9 @@ VAStatus vaCreateSubpicture (
     VASubpictureID *subpicture /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaCreateSubpicture);
   return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
@@ -1102,8 +1023,9 @@ VAStatus vaDestroySubpicture (
     VASubpictureID subpicture
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDestroySubpicture);
   return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
@@ -1115,31 +1037,14 @@ VAStatus vaSetSubpictureImage (
     VAImageID image
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSetSubpictureImage);
   return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
 }
 
-#warning TODO: Remove vaSetSubpicturePalette in rev 0.29
-VAStatus vaSetSubpicturePalette (
-    VADisplay dpy,
-    VASubpictureID subpicture,
-    /* 
-     * pointer to an array holding the palette data.  The size of the array is 
-     * num_palette_entries * entry_bytes in size.  The order of the components
-     * in the palette is described by the component_order in VASubpicture struct
-     */
-    unsigned char *palette 
-)
-{
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
-
-  TRACE(vaSetSubpicturePalette);
-  return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
-}
 
 /*
  * If chromakey is enabled, then the area where the source value falls within
@@ -1153,8 +1058,9 @@ VAStatus vaSetSubpictureChromakey (
     unsigned int chromakey_mask
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSetSubpictureChromakey);
   return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
@@ -1172,8 +1078,9 @@ VAStatus vaSetSubpictureGlobalAlpha (
     float global_alpha 
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSetSubpictureGlobalAlpha);
   return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
@@ -1204,8 +1111,9 @@ VAStatus vaAssociateSubpicture (
     unsigned int flags
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaAssociateSubpicture);
   return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
@@ -1231,8 +1139,9 @@ VAStatus vaAssociateSubpicture2 (
     unsigned int flags
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaAssociateSubpicture2);
   return ctx->vtable.vaAssociateSubpicture2 ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags );
@@ -1248,8 +1157,9 @@ VAStatus vaDeassociateSubpicture (
     int num_surfaces
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDeassociateSubpicture);
   return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
@@ -1261,13 +1171,10 @@ int vaMaxNumDisplayAttributes (
     VADisplay dpy
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  if( !vaContextIsValid(ctx) )
-  {
+  if( !vaDisplayIsValid(dpy) )
       return 0;
-  }
   
-  return ctx->max_display_attributes;
+  return CTX(dpy)->max_display_attributes;
 }
 
 /* 
@@ -1282,8 +1189,9 @@ VAStatus vaQueryDisplayAttributes (
     int *num_attributes                        /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaQueryDisplayAttributes);
   return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1301,8 +1209,9 @@ VAStatus vaGetDisplayAttributes (
     int num_attributes
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaGetDisplayAttributes);
   return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1320,8 +1229,9 @@ VAStatus vaSetDisplayAttributes (
     int num_attributes
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaSetDisplayAttributes);
   return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
@@ -1335,10 +1245,35 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
     unsigned int *stride /* out */
 )
 {
-  VADriverContextP ctx = CTX(dpy);
-  CHECK_CONTEXT(ctx);
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
 
   TRACE(vaDbgCopySurfaceToBuffer);
   return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );
 }
 
+#warning TODO: Remove vaDbgCreateSurfaceFromMrstV4L2Buf in rev 0.29
+VAStatus vaDbgCreateSurfaceFromMrstV4L2Buf(
+    VADisplay dpy,
+    unsigned int width,
+    unsigned int height,
+    unsigned int size,
+    unsigned int fourcc,
+    unsigned int luma_stride,
+    unsigned int chroma_u_stride,
+    unsigned int chroma_v_stride,
+    unsigned int luma_offset,
+    unsigned int chroma_u_offset,
+    unsigned int chroma_v_offset,
+    VASurfaceID *surface       /* out */
+)
+{
+  VADriverContextP ctx;
+  CHECK_DISPLAY(dpy);
+  ctx = CTX(dpy);
+
+  TRACE(vtable.vaDbgCreateSurfaceFromMrstV4L2Buf);
+  return ctx->vtable.vaDbgCreateSurfaceFromMrstV4L2Buf( ctx, width, height, size, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, surface );
+}
+
similarity index 84%
rename from src/va.h
rename to libva/src/va.h
index 739af99..2c2cbe6 100755 (executable)
--- a/src/va.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
+ * Copyright (c) 2007-2009 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
  * 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.
  */
 /*
- * Video Decode Acceleration API Specification
+ * Video Acceleration (VA) API Specification
  *
- * Rev. 0.29
+ * Rev. 0.30
  * <jonathan.bian@intel.com>
  *
  * Revision History:
  * rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types.
  * rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics
  * rev 0.27 (11/19/2007 Matt Sottek)   - Added DeriveImage
- * rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture
+ * rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture 
  *                                       to enable scaling
- * rev 0.29 (02/07/2007 Jonathan Bian) - VC1 parameter fixes,
+ * rev 0.29 (02/07/2008 Jonathan Bian) - VC1 parameter fixes,
  *                                       added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED
+ * rev 0.30 (03/01/2009 Jonathan Bian) - Added encoding support for H.264 BP and MPEG-4 SP and fixes
+ *                                       for ISO C conformance.
  *
  * Acknowledgements:
  *  Some concepts borrowed from XvMC and XvImage.
- *  Thanks to Waldo Bastian, Matt Sottek and Austin Yuan at Intel for many valuable feedbacks.
+ *  Waldo Bastian (Intel), Matt Sottek (Intel),  Austin Yuan (Intel), and Gwenole Beauchesne (SDS)
+ *  contributed to various aspects of the API.
  */
 
 #ifndef _VA_H_
@@ -67,9 +70,9 @@ extern "C" {
 /* 
 Overview 
 
-This API is intended to provide an interface between a video decode
-application (client) and a hardware decode accelerator (server), to off-load 
-video decode operations from the host to the hardware accelerator at various 
+The VA API is intended to provide an interface between a video decode/encode/display
+application (client) and a hardware accelerator (server), to off-load 
+video decode/encode/display operations from the host to the hardware accelerator at various 
 entry-points.
 
 The basic operation steps are:
@@ -132,10 +135,6 @@ const char *vaErrorStr(VAStatus error_status);
  */
 typedef void* NativeDisplay;   /* window system dependent */
 
-VADisplay vaGetDisplay (
-    NativeDisplay native_dpy   /* implementation specific */
-);
-
 /*
  * Initialize the library 
  */
@@ -157,7 +156,7 @@ VAStatus vaTerminate (
  * describing some aspects of the VA implemenation on a specific    
  * hardware accelerator. The format of the returned string is vendor
  * specific and at the discretion of the implementer.
- * e.g. for the Intel GMA500 implementation, an example would be:   
+ * e.g. for the Intel GMA500 implementation, an example would be:
  * "Intel GMA500 - 2.0.0.32L.0005"
  */
 const char *vaQueryVendorString (
@@ -189,6 +188,7 @@ typedef enum
     VAProfileVC1Simple                 = 8,
     VAProfileVC1Main                   = 9,
     VAProfileVC1Advanced               = 10,
+    VAProfileH263Baseline              = 11
 } VAProfile;
 
 /* 
@@ -201,6 +201,7 @@ typedef enum
     VAEntrypointIDCT           = 3,
     VAEntrypointMoComp         = 4,
     VAEntrypointDeblocking     = 5,
+    VAEntrypointEncSlice       = 6     /* slice level encode */
 } VAEntrypoint;
 
 /* Currently defined configuration attribute types */
@@ -211,6 +212,7 @@ typedef enum
     VAConfigAttribSpatialClipping      = 2,
     VAConfigAttribIntraResidual                = 3,
     VAConfigAttribEncryption           = 4,
+    VAConfigAttribRateControl          = 5
 } VAConfigAttribType;
 
 /*
@@ -228,6 +230,12 @@ typedef struct _VAConfigAttrib {
 #define VA_RT_FORMAT_YUV420    0x00000001      
 #define VA_RT_FORMAT_YUV422    0x00000002
 #define VA_RT_FORMAT_YUV444    0x00000004
+#define VA_RT_FORMAT_PROTECTED 0x80000000
+
+/* attribute value for VAConfigAttribRateControl */
+#define VA_RC_NONE     0x00000001      
+#define VA_RC_CBR      0x00000002      
+#define VA_RC_VBR      0x00000004      
 
 /*
  * if an attribute is not applicable for a given
@@ -445,9 +453,18 @@ typedef enum
     VAMacroblockParameterBufferType    = 6,
     VAResidualDataBufferType           = 7,
     VADeblockingParameterBufferType    = 8,
-    VAImageBufferType                  = 9
+    VAImageBufferType                  = 9,
+    VAProtectedSliceDataBufferType     = 10,
+/* Following are encode buffer types */
+    VAEncCodedBufferType               = 21,
+    VAEncSequenceParameterBufferType   = 22,
+    VAEncPictureParameterBufferType    = 23,
+    VAEncSliceParameterBufferType      = 24,
+    VAEncH264VUIBufferType             = 25,
+    VAEncH264SEIBufferType             = 26,
 } VABufferType;
 
+
 /****************************
  * MPEG-2 data structures
  ****************************/
@@ -468,22 +485,22 @@ typedef struct _VAPictureParameterBufferMPEG2
     int f_code; /* pack all four fcode into this */
     union {
         struct {
-            unsigned char intra_dc_precision           : 2; 
-            unsigned char picture_structure            : 2; 
-            unsigned char top_field_first              : 1; 
-            unsigned char frame_pred_frame_dct         : 1; 
-            unsigned char concealment_motion_vectors   : 1;
-            unsigned char q_scale_type                 : 1;
-            unsigned char intra_vlc_format             : 1;
-            unsigned char alternate_scan               : 1;
-            unsigned char repeat_first_field           : 1;
-            unsigned char progressive_frame            : 1;
-            unsigned char is_first_field               : 1; /* indicate whether the current field
+            unsigned int intra_dc_precision            : 2; 
+            unsigned int picture_structure             : 2; 
+            unsigned int top_field_first               : 1; 
+            unsigned int frame_pred_frame_dct          : 1; 
+            unsigned int concealment_motion_vectors    : 1;
+            unsigned int q_scale_type                  : 1;
+            unsigned int intra_vlc_format              : 1;
+            unsigned int alternate_scan                        : 1;
+            unsigned int repeat_first_field            : 1;
+            unsigned int progressive_frame             : 1;
+            unsigned int is_first_field                        : 1; /* indicate whether the current field
                                                               * is the first field for field picture
                                                               */
-        };
-        unsigned int picture_coding_extension;
-    };
+        } bits;
+        unsigned int value;
+    } picture_coding_extension;
 } VAPictureParameterBufferMPEG2;
 
 /* MPEG-2 Inverse Quantization Matrix Buffer */
@@ -536,12 +553,12 @@ typedef struct _VAMacroblockParameterBufferMPEG2
     unsigned char macroblock_type;  /* see definition below */
     union {
         struct {
-            unsigned char frame_motion_type            : 2; 
-            unsigned char field_motion_type            : 2; 
-            unsigned char dct_type                     : 1; 
-        };
-        unsigned char macroblock_modes;
-    };
+            unsigned int frame_motion_type             : 2; 
+            unsigned int field_motion_type             : 2; 
+            unsigned int dct_type                      : 1; 
+        } bits;
+        unsigned char value;
+    } macroblock_modes;
     unsigned char motion_vertical_field_select; 
     /* 
      * motion_vertical_field_select:
@@ -601,12 +618,12 @@ typedef struct _VAPictureParameterBufferMPEG4
             unsigned char sprite_enable                        : 2; 
             unsigned char sprite_warping_accuracy      : 2; 
             unsigned char quant_type                   : 1; 
-            unsigned char quarter_sample               : 1; 
+            unsigned char quarter_sample                       : 1; 
             unsigned char data_partitioned             : 1; 
-            unsigned char reversible_vlc               : 1; 
-        };
-        unsigned short vol_fields;
-    };
+            unsigned char reversible_vlc                       : 1; 
+        } bits;
+        unsigned short value;
+    } vol_fields;
     unsigned char no_of_sprite_warping_points;
     short sprite_trajectory_du[3];
     short sprite_trajectory_dv[3];
@@ -619,9 +636,9 @@ typedef struct _VAPictureParameterBufferMPEG4
             unsigned char intra_dc_vlc_thr             : 3; 
             unsigned char top_field_first              : 1; 
             unsigned char alternate_vertical_scan_flag : 1; 
-        };
-        unsigned short vop_fields;
-    };
+        } bits;
+        unsigned short value;
+    } vop_fields;
     unsigned char vop_fcode_forward;
     unsigned char vop_fcode_backward;
     /* short header related */
@@ -693,9 +710,9 @@ typedef struct _VAPictureParameterBufferVC1
             unsigned char interlace    : 1; /* SEQUENCE_LAYER::INTERLACE */
             unsigned char syncmarker   : 1;/* METADATA::SYNCMARKER */
             unsigned char overlap      : 1;/* METADATA::OVERLAP */
-        };
-        unsigned char sequence_fields;
-    };
+        } bits;
+        unsigned char value;
+    } sequence_fields;
 
     unsigned short coded_width;                /* ENTRY_POINT_LAYER::CODED_WIDTH */
     unsigned short coded_height;       /* ENTRY_POINT_LAYER::CODED_HEIGHT */
@@ -706,13 +723,13 @@ typedef struct _VAPictureParameterBufferVC1
     unsigned char fast_uvmc_flag;      /* ENTRY_POINT_LAYER::FASTUVMC */
     union {
         struct {
-            unsigned char range_mapping_luma_flag:     1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
-            unsigned char range_mapping_luma:          3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
-            unsigned char range_mapping_chroma_flag:   1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
-            unsigned char range_mapping_chroma:                3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
-        };
-        unsigned char range_mapping_fields;
-    };
+            unsigned char luma_flag    : 1; /* ENTRY_POINT_LAYER::RANGE_MAPY_FLAG */
+            unsigned char luma         : 3; /* ENTRY_POINT_LAYER::RANGE_MAPY */
+            unsigned char chroma_flag  : 1; /* ENTRY_POINT_LAYER::RANGE_MAPUV_FLAG */
+            unsigned char chroma               : 3; /* ENTRY_POINT_LAYER::RANGE_MAPUV */
+        } bits;
+        unsigned char value;
+    } range_mapping_fields;
 
     unsigned char b_picture_fraction;  /* PICTURE_LAYER::BFRACTION */
     unsigned char cbp_table;           /* PICTURE_LAYER::CBPTAB/ICBPTAB */
@@ -725,14 +742,14 @@ typedef struct _VAPictureParameterBufferVC1
     unsigned char luma_shift;          /* PICTURE_LAYER::LUMSHIFT */
     union {
         struct {
-            unsigned char picture_type : 2;    /* PICTURE_LAYER::PTYPE */
-            unsigned char frame_coding_mode    : 3;/* PICTURE_LAYER::FCM */
-            unsigned char top_field_first      : 1;/* PICTURE_LAYER::TFF */
-            unsigned char is_first_field       : 1; /* set to 1 if it is the first field */
-            unsigned char intensity_compensation: 1;/* PICTURE_LAYER::INTCOMP */
-        };
-        unsigned char picture_fields;
-    };
+            unsigned char picture_type         : 2; /* PICTURE_LAYER::PTYPE */
+            unsigned char frame_coding_mode    : 3; /* PICTURE_LAYER::FCM */
+            unsigned char top_field_first      : 1; /* PICTURE_LAYER::TFF */
+            unsigned char is_first_field               : 1; /* set to 1 if it is the first field */
+            unsigned char intensity_compensation       : 1; /* PICTURE_LAYER::INTCOMP */
+        } bits;
+        unsigned char value;
+    } picture_fields;
     union {
         struct {
             unsigned char mv_type_mb   : 1;    /* PICTURE::MVTYPEMB */
@@ -742,9 +759,9 @@ typedef struct _VAPictureParameterBufferVC1
             unsigned char forward_mb   : 1;    /* PICTURE::FORWARDMB */
             unsigned char ac_pred      : 1;    /* PICTURE::ACPRED */
             unsigned char overflags    : 1;    /* PICTURE::OVERFLAGS */
-        };
-        unsigned char raw_coding_flag;
-    };
+        } flags;
+        unsigned char value;
+    } raw_coding;
     union {
         struct {
             unsigned char bp_mv_type_mb   : 1;    /* PICTURE::MVTYPEMB */
@@ -754,33 +771,33 @@ typedef struct _VAPictureParameterBufferVC1
             unsigned char bp_forward_mb   : 1;    /* PICTURE::FORWARDMB */
             unsigned char bp_ac_pred      : 1;    /* PICTURE::ACPRED */   
             unsigned char bp_overflags    : 1;    /* PICTURE::OVERFLAGS */
-        };
-        unsigned char bitplane_present_flag; /* signal what bitplane is being passed via the bitplane buffer */
-    };
+        } flags;
+        unsigned char value;
+    } bitplane_present; /* signal what bitplane is being passed via the bitplane buffer */
     union {
         struct {
             unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
             unsigned char reference_distance   : 5;/* PICTURE_LAYER::REFDIST */
             unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
             unsigned char reference_field_pic_indicator        : 1;/* PICTURE_LAYER::REFFIELD */
-        };
-        unsigned short reference_fields;
-    };
+        } bits;
+        unsigned short value;
+    } reference_fields;
     union {
         struct {
-            VAMvModeVC1 mv_mode              : 3; /* PICTURE_LAYER::MVMODE */
-            VAMvModeVC1 mv_mode2             : 3; /* PICTURE_LAYER::MVMODE2 */
-            unsigned char mv_table           : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
+            unsigned char mv_mode              : 3; /* PICTURE_LAYER::MVMODE */
+            unsigned char mv_mode2             : 3; /* PICTURE_LAYER::MVMODE2 */
+            unsigned char mv_table             : 3; /* PICTURE_LAYER::MVTAB/IMVTAB */
             unsigned char two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */
-            unsigned char four_mv_switch     : 1; /* PICTURE_LAYER::4MVSWITCH */
+            unsigned char four_mv_switch               : 1; /* PICTURE_LAYER::4MVSWITCH */
             unsigned char four_mv_block_pattern_table : 2; /* PICTURE_LAYER::4MVBPTAB */
-            unsigned char extended_mv_flag   : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
-            unsigned char extended_mv_range  : 2; /* PICTURE_LAYER::MVRANGE */
-            unsigned char extended_dmv_flag  : 1; /* ENTRY_POINT_LAYER::EXTENDED_DMV */
-            unsigned char extended_dmv_range : 2; /* PICTURE_LAYER::DMVRANGE */
-        };
-        unsigned int mv_fields;
-    };
+            unsigned char extended_mv_flag     : 1; /* ENTRY_POINT_LAYER::EXTENDED_MV */
+            unsigned char extended_mv_range    : 2; /* PICTURE_LAYER::MVRANGE */
+            unsigned char extended_dmv_flag    : 1; /* ENTRY_POCHAR_LAYER::EXTENDED_DMV */
+            unsigned char extended_dmv_range   : 2; /* PICTURE_LAYER::DMVRANGE */
+        } bits;
+        unsigned int value;
+    } mv_fields;
     union {
         struct {
             unsigned char dquant       : 2;    /* ENTRY_POINT_LAYER::DQUANT */
@@ -794,9 +811,9 @@ typedef struct _VAPictureParameterBufferVC1
             unsigned char dq_db_edge   : 2;    /* VOPDQUANT::DQDBEDGE */
             unsigned char dq_binary_level : 1;         /* VOPDQUANT::DQBILEVEL */
             unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */
-        };
-        unsigned long pic_quantizer_fields;
-    };
+        } bits;
+        unsigned long value;
+    } pic_quantizer_fields;
     union {
         struct {
             unsigned char variable_sized_transform_flag        : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */
@@ -805,9 +822,9 @@ typedef struct _VAPictureParameterBufferVC1
             unsigned char transform_ac_codingset_idx1  : 2;/* PICTURE_LAYER::TRANSACFRM */
             unsigned char transform_ac_codingset_idx2  : 2;/* PICTURE_LAYER::TRANSACFRM2 */
             unsigned char intra_transform_dc_table     : 1;/* PICTURE_LAYER::TRANSDCTAB */
-        };
-        unsigned short transform_fields;
-    };
+        } bits;
+        unsigned short value;
+    } transform_fields;
 } VAPictureParameterBufferVC1;
 
 /* VC-1 Bitplane Buffer 
@@ -878,14 +895,14 @@ typedef struct _VAPictureParameterBufferH264
     union {
         struct {
             unsigned char chroma_format_idc                    : 2; 
-            unsigned char residual_colour_transform_flag       : 1; 
+            unsigned char residual_colour_transform_flag               : 1; 
             unsigned char frame_mbs_only_flag                  : 1; 
             unsigned char mb_adaptive_frame_field_flag         : 1; 
             unsigned char direct_8x8_inference_flag            : 1; 
             unsigned char MinLumaBiPredSize8x8                 : 1; /* see A.3.3.2 */
-        };
-        unsigned char seq_fields;
-    };
+        } bits;
+        unsigned char value;
+    } seq_fields;
     unsigned char num_slice_groups_minus1;
     unsigned char slice_group_map_type;
     signed char pic_init_qp_minus26;
@@ -897,11 +914,11 @@ typedef struct _VAPictureParameterBufferH264
             unsigned char weighted_pred_flag           : 1;
             unsigned char weighted_bipred_idc          : 2;
             unsigned char transform_8x8_mode_flag      : 1;
-            unsigned char field_pic_flag               : 1;
+            unsigned char field_pic_flag                       : 1;
             unsigned char constrained_intra_pred_flag  : 1;
-        };
-        unsigned char pic_fields;
-    };
+        } bits;
+        unsigned char value;
+    } pic_fields;
     unsigned short frame_num;
 } VAPictureParameterBufferH264;
 
@@ -957,6 +974,115 @@ typedef struct _VASliceParameterBufferH264
     short chroma_offset_l1[32][2];
 } VASliceParameterBufferH264;
 
+/****************************
+ * Common encode data structures 
+ ****************************/
+typedef enum
+{
+    VAEncPictureTypeIntra              = 0,
+    VAEncPictureTypePredictive         = 1,
+    VAEncPictureTypeBidirectional      = 2,
+} VAEncPictureType;
+
+/* Encode Slice Parameter Buffer */
+typedef struct _VAEncSliceParameterBuffer
+{
+    unsigned int start_row_number;     /* starting MB row number for this slice */
+    unsigned int slice_height; /* slice height measured in MB */
+    union {
+        struct {
+            unsigned char is_intra     : 1;
+            unsigned char disable_deblocking_filter_idc : 2;
+        } bits;
+        unsigned char value;
+    } slice_flags;
+} VAEncSliceParameterBuffer;
+
+/****************************
+ * H.264 specific encode data structures
+ ****************************/
+
+typedef struct _VAEncSequenceParameterBufferH264
+{
+    unsigned char seq_parameter_set_id;
+    unsigned char level_idc;
+    unsigned int intra_period;
+    unsigned int picture_width_in_mbs;
+    unsigned int picture_height_in_mbs;
+    unsigned int bits_per_second;
+    unsigned int frame_rate;
+    unsigned int initial_qp;
+    unsigned int min_qp;
+    unsigned int basic_unit_size;
+    unsigned char vui_flag;
+} VAEncSequenceParameterBufferH264;
+
+typedef struct _VAEncPictureParameterBufferH264
+{
+    VASurfaceID reference_picture;
+    VASurfaceID reconstructed_picture;
+    VABufferID coded_buf;
+    unsigned short picture_width;
+    unsigned short picture_height;
+    unsigned char last_picture; /* if set to 1 it indicates the last picture in the sequence */
+} VAEncPictureParameterBufferH264;
+
+/****************************
+ * H.263 specific encode data structures
+ ****************************/
+
+typedef struct _VAEncSequenceParameterBufferH263
+{
+    unsigned int intra_period;
+    unsigned int bits_per_second;
+    unsigned int frame_rate;
+    unsigned int initial_qp;
+    unsigned int min_qp;
+} VAEncSequenceParameterBufferH263;
+
+typedef struct _VAEncPictureParameterBufferH263
+{
+    VASurfaceID reference_picture;
+    VASurfaceID reconstructed_picture;
+    VABufferID coded_buf;
+    unsigned short picture_width;
+    unsigned short picture_height;
+    VAEncPictureType picture_type;
+} VAEncPictureParameterBufferH263;
+
+/****************************
+ * MPEG-4 specific encode data structures
+ ****************************/
+
+typedef struct _VAEncSequenceParameterBufferMPEG4
+{
+    unsigned char profile_and_level_indication;
+    unsigned int intra_period;
+    unsigned int video_object_layer_width;
+    unsigned int video_object_layer_height;
+    unsigned int vop_time_increment_resolution;
+    unsigned int fixed_vop_rate;
+    unsigned int fixed_vop_time_increment;
+    unsigned int bits_per_second;
+    unsigned int frame_rate;
+    unsigned int initial_qp;
+    unsigned int min_qp;
+} VAEncSequenceParameterBufferMPEG4;
+
+typedef struct _VAEncPictureParameterBufferMPEG4
+{
+    VASurfaceID reference_picture;
+    VASurfaceID reconstructed_picture;
+    VABufferID coded_buf;
+    unsigned short picture_width;
+    unsigned short picture_height;
+    unsigned int modulo_time_base; /* number of 1s */
+    unsigned int vop_time_increment;
+    VAEncPictureType picture_type;
+} VAEncPictureParameterBufferMPEG4;
+
+
+
 /* Buffer functions */
 
 /*
@@ -1087,7 +1213,8 @@ typedef enum
     VASurfaceDisplaying        = 1, /* Displaying in progress (not safe to render into it) */ 
                              /* this status is useful if surface is used as the source */
                              /* of an overlay */
-    VASurfaceReady     = 2  /* not being rendered or displayed */
+    VASurfaceReady     = 2, /* not being rendered or displayed */
+    VASurfaceSkipped   = 4  /* Indicate a skipped frame during encode */
 } VASurfaceStatus;
 
 /*
@@ -1106,7 +1233,7 @@ VAStatus vaQuerySurfaceStatus (
  * Both images, subpictures and surfaces follow the same 2D coordinate system where origin 
  * is at the upper left corner with positive X to the right and positive Y down
  */
-#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
+#define VA_FOURCC(ch0, ch1, ch2, ch3) \
     ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
     ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
 
@@ -1114,6 +1241,13 @@ VAStatus vaQuerySurfaceStatus (
 #define VA_FOURCC_NV12         0x3231564E
 #define VA_FOURCC_AI44         0x34344149
 #define VA_FOURCC_RGBA         0x41424752
+#define VA_FOURCC_UYVY          0x59565955
+#define VA_FOURCC_YUY2          0x32595559
+#define VA_FOURCC_AYUV          0x56555941
+#define VA_FOURCC_NV11          0x3131564e
+#define VA_FOURCC_YV12          0x32315659
+#define VA_FOURCC_P208          0x38303250
+#define VA_FOURCC_IYUV          0x56555949
 
 /* byte order */
 #define VA_LSB_FIRST           1
@@ -1260,7 +1394,7 @@ VAStatus vaPutImage (
     int dest_y
 );
 
- /*
+/*
  * Similar to vaPutImage but with additional destination width
  * and height arguments to enable scaling
  */
@@ -1315,8 +1449,6 @@ VAStatus vaDeriveImage (
     VAImage *image     /* out */
 );
 
-
-
 /*
  * Subpictures 
  * Subpicture is a special type of image that can be blended 
@@ -1562,148 +1694,3 @@ VAStatus vaSetDisplayAttributes (
 #endif
 
 #endif /* _VA_H_ */
-
-#if 0
-/*****************************************************************************/ 
-
-Sample Program (w/ pseudo code)
-
-Mostly to demonstrate program flow with no error handling ...
-
-/*****************************************************************************/
-
-       /* MPEG-2 VLD decode for a 720x480 frame */
-
-       int major_ver, minor_ver;
-       vaInitialize(dpy, &major_ver, &minor_ver);
-
-       int max_num_profiles, max_num_entrypoints, max_num_attribs;
-       max_num_profiles = vaMaxNumProfiles(dpy);
-       max_num_entrypoints = vaMaxNumEntrypoints(dpy);
-       max_num_attribs = vaMaxNumAttributes(dpy);
-
-       /* find out whether MPEG2 MP is supported */
-       VAProfile *profiles = malloc(sizeof(VAProfile)*max_num_profiles);
-       int num_profiles;
-       vaQueryConfigProfiles(dpy, profiles, &profiles);
-       /*
-        * traverse "profiles" to locate the one that matches VAProfileMPEG2Main
-         */ 
-
-       /* now get the available entrypoints for MPEG2 MP */
-       VAEntrypoint *entrypoints = malloc(sizeof(VAEntrypoint)*max_num_entrypoints);
-       int num_entrypoints;
-       vaQueryConfigEntrypoints(dpy, VAProfileMPEG2Main, entrypoints, &num_entrypoints);
-
-       /* traverse "entrypoints" to see whether VLD is there */
-
-       /* Assuming finding VLD, find out the format for the render target */
-       VAConfigAttrib attrib;
-       attrib.type = VAConfigAttribRTFormat;
-       vaGetConfigAttributes(dpy, VAProfileMPEG2Main, VAEntrypointVLD,
-                                &attrib, 1);
-
-       if (attrib.value & VA_RT_FORMAT_YUV420)
-               /* Found desired RT format, keep going */ 
-
-       VAConfigID config_id;
-       vaCreateConfig(dpy, VAProfileMPEG2Main, VAEntrypointVLD, &attrib, 1,
-                       &config_id);
-
-       /* 
-         * create surfaces for the current target as well as reference frames
-        * we can get by with 4 surfaces for MPEG-2
-        */
-       VASurfaceID surfaces[4];
-       vaCreateSurfaces(dpy, 720, 480, VA_RT_FORMAT_YUV420, 4, surfaces);
-
-       /* 
-         * Create a context for this decode pipe
-        */
-       VAContextID context;
-       vaCreateContext(dpy, config_id, 720, 480, VA_PROGRESSIVE, surfaces,
-                        4, &context);
-
-       /* Create a picture parameter buffer for this frame */
-       VABufferID picture_buf;
-       VAPictureParameterBufferMPEG2 *picture_param;
-       vaCreateBuffer(dpy, context, VAPictureParameterBufferType, sizeof(VAPictureParameterBufferMPEG2), 1, NULL, &picture_buf);
-       vaMapBuffer(dpy, picture_buf, &picture_param);
-       picture_param->horizontal_size = 720;
-       picture_param->vertical_size = 480;
-       picture_param->picture_coding_type = 1; /* I-frame */   
-       /* fill in picture_coding_extension fields here */
-       vaUnmapBuffer(dpy, picture_buf);
-
-       /* Create an IQ matrix buffer for this frame */
-       VABufferID iq_buf;
-       VAIQMatrixBufferMPEG2 *iq_matrix;
-       vaCreateBuffer(dpy, context, VAIQMatrixBufferType, sizeof(VAIQMatrixBufferMPEG2), 1, NULL, &iq_buf);
-       vaMapBuffer(dpy, iq_buf, &iq_matrix);
-       /* fill values for IQ_matrix here */
-       vaUnmapBuffer(dpy, iq_buf);
-
-       /* send the picture and IQ matrix buffers to the server */
-       vaBeginPicture(dpy, context, surfaces[0]);
-
-       vaRenderPicture(dpy, context, &picture_buf, 1);
-       vaRenderPicture(dpy, context, &iq_buf, 1);
-
-       /* 
-         * Send slices in this frame to the server.
-         * For MPEG-2, each slice is one row of macroblocks, and
-         * we have 30 slices for a 720x480 frame 
-         */
-       for (int i = 1; i <= 30; i++) {
-
-               /* Create a slice parameter buffer */
-               VABufferID slice_param_buf;
-               VASliceParameterBufferMPEG2 *slice_param;
-               vaCreateBuffer(dpy, context, VASliceParameterBufferType, sizeof(VASliceParameterBufferMPEG2), 1, NULL, &slice_param_buf);
-               vaMapBuffer(dpy, slice_param_buf, &slice_param);
-               slice_param->slice_data_offset = 0;
-               /* Let's say all slices in this bit-stream has 64-bit header */
-               slice_param->macroblock_offset = 64; 
-               slice_param->vertical_position = i;
-               /* set up the rest based on what is in the slice header ... */
-               vaUnmapBuffer(dpy, slice_param_buf);
-
-               /* send the slice parameter buffer */
-               vaRenderPicture(dpy, context, &slice_param_buf, 1);
-
-               /* Create a slice data buffer */
-               unsigned char *slice_data;
-               VABufferID slice_data_buf;
-               vaCreateBuffer(dpy, context, VASliceDataBufferType, x /* decoder figure out how big */, 1, NULL, &slice_data_buf);
-               vaMapBuffer(dpy, slice_data_buf, &slice_data);
-               /* decoder fill in slice_data */
-               vaUnmapBuffer(dpy, slice_data_buf);
-
-               /* send the slice data buffer */
-               vaRenderPicture(dpy, context, &slice_data_buf, 1);
-       }
-
-       /* all slices have been sent, mark the end for this frame */
-       vaEndPicture(dpy, context);
-
-       /* The following code demonstrates rendering a sub-title with the target surface */
-       /* Find out supported Subpicture formats */
-       VAImageFormat sub_formats[4];
-        int num_formats;
-       vaQuerySubpictureFormats(dpy, sub_formats, &num_formats);
-        /* Assume that we find AI44 as a subpicture format in sub_formats[0] */
-        VAImage sub_image;
-       VASubpictureID subpicture;
-        unsigned char *sub_data;
-        /* create an image for the subtitle */
-       vaCreateImage(dpy, sub_formats, 128, 16, &sub_image);
-       vaMapBuffer(dpy, sub_image->buf, &sub_data);
-        /* fill the image data */
-        vaUnmapBuffer(dpy, sub_image->buf);
-       vaCreateSubpicture(dpy, sub_image, &subpicture);
-       unsigned char palette[3][16];
-       /* fill the palette data */
-       vaSetSubpicturePalette(dpy, subpicture, palette);
-       vaAssociateSubpicture(dpy, subpicture, surfaces, 1, 0, 0, 296, 400, 128, 16);
-       vaPutSurface(dpy, surfaces, win, 0, 0, 720, 480, 100, 100, 640, 480, NULL, 0, 0);
-#endif
similarity index 89%
rename from src/va_backend.h
rename to libva/src/va_backend.h
index 45aee4a..c411201 100755 (executable)
 #ifndef _VA_BACKEND_H_
 #define _VA_BACKEND_H_
 
+#ifdef IN_LIBVA
 #include "va.h"
-#include "va_x11.h"
+#include "X11/va_x11.h"
+#else
+#include <va/va.h>
+#include <va/va_x11.h>
+#endif
 
 #include <stdlib.h>
 
 
 typedef struct VADriverContext *VADriverContextP;
+typedef struct VADisplayContext *VADisplayContextP;
 
 struct VADriverVTable
 {
@@ -94,6 +100,12 @@ struct VADriverVTable
                VASurfaceID *surfaces           /* out */
        );
 
+       VAStatus (*vaCreateSurfaceFromCIFrame) (
+               VADriverContextP ctx,
+               unsigned long frame_id,
+               VASurfaceID *surface            /* out */
+       );
+    
        VAStatus (*vaDestroySurfaces) (
                VADriverContextP ctx,
                VASurfaceID *surface_list,
@@ -291,17 +303,6 @@ struct VADriverVTable
                 VAImageID image
         );
         
-       VAStatus (*vaSetSubpicturePalette) (
-               VADriverContextP ctx,
-               VASubpictureID subpicture,
-               /*
-                * pointer to an array holding the palette data.  The size of the array is
-                * num_palette_entries * entry_bytes in size.  The order of the components
-                * in the palette is described by the component_order in VASubpicture struct
-                */
-               unsigned char *palette
-       );
-
        VAStatus (*vaSetSubpictureChromakey) (
                VADriverContextP ctx,
                VASubpictureID subpicture,
@@ -386,18 +387,32 @@ struct VADriverVTable
                void **buffer, /* out */
                unsigned int *stride /* out */
        );
+        VAStatus (*vaDbgCreateSurfaceFromMrstV4L2Buf) (
+               VADriverContextP ctx,
+                unsigned int width,
+                unsigned int height,
+                unsigned int size,
+                unsigned int fourcc,
+                unsigned int luma_stride,
+                unsigned int chroma_u_stride,
+                unsigned int chroma_v_stride,
+                unsigned int luma_offset,
+                unsigned int chroma_u_offset,
+                unsigned int chroma_v_offset,
+                VASurfaceID *surface   /* out */
+        );
 };
 
 struct VADriverContext
 {
-    VADriverContextP pNext;
+    void *old_pNext;                   /* preserved for binary compatibility */
 
     void *pDriverData;
     struct VADriverVTable vtable;
 
     Display *x11_dpy;
     int x11_screen;
-
+    int dri2;
     int version_major;
     int version_minor;
     int max_profiles;
@@ -411,6 +426,25 @@ struct VADriverContext
     void *handle;                      /* dlopen handle */
 };
 
+struct VADisplayContext
+{
+    VADisplayContextP pNext;
+    VADriverContextP pDriverContext;
+
+    int (*vaIsValid) (
+       VADisplayContextP ctx
+    );
+
+    void (*vaDestroy) (
+       VADisplayContextP ctx
+    );
+
+    VAStatus (*vaGetDriverName) (
+       VADisplayContextP ctx,
+       char **driver_name
+    );
+};
+
 typedef VAStatus (*VADriverInit) (
     VADriverContextP driver_context
 );
similarity index 98%
rename from test/Makefile.am
rename to libva/test/Makefile.am
index aeb89fe..22e2a5d 100644 (file)
@@ -27,7 +27,7 @@ bin_PROGRAMS = vainfo
 
 testdir = $(bindir)
 
-AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src
+AM_CFLAGS = -I$(top_srcdir)/../../include/external/ -I$(top_srcdir)/src -DIN_LIBVA
 
 TESTS = $(check_PROGRAMS)
 
@@ -72,6 +72,7 @@ test_11_SOURCES = test_11.c
 test_12_LDADD = $(TEST_LIBS)
 test_12_SOURCES = test_12.c
 
+EXTRA_DIST = test_common.c
 
 valgrind:      $(check_PROGRAMS)
        for a in $(check_PROGRAMS); do \
similarity index 99%
rename from test/test.c
rename to libva/test/test.c
index b088487..41972c7 100644 (file)
@@ -22,8 +22,7 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "va.h"
-#include "X11/Xlib.h"
+#include <va_x11.h>
 
 #include "assert.h"
 #include <stdarg.h>
similarity index 100%
rename from test/test_01.c
rename to libva/test/test_01.c
similarity index 100%
rename from test/test_02.c
rename to libva/test/test_02.c
similarity index 100%
rename from test/test_03.c
rename to libva/test/test_03.c
similarity index 100%
rename from test/test_04.c
rename to libva/test/test_04.c
similarity index 100%
rename from test/test_05.c
rename to libva/test/test_05.c
similarity index 100%
rename from test/test_06.c
rename to libva/test/test_06.c
similarity index 100%
rename from test/test_07.c
rename to libva/test/test_07.c
similarity index 100%
rename from test/test_08.c
rename to libva/test/test_08.c
similarity index 100%
rename from test/test_09.c
rename to libva/test/test_09.c
similarity index 100%
rename from test/test_10.c
rename to libva/test/test_10.c
similarity index 100%
rename from test/test_11.c
rename to libva/test/test_11.c
similarity index 99%
rename from test/test_12.c
rename to libva/test/test_12.c
index dcc7021..9bdc1ef 100644 (file)
 
 #define TEST_DESCRIPTION       "Sample MPEG2 VLD Decoding"
 
+#include <va_x11.h>
 #include "test_common.c"
 
-#include <X11/Xlib.h>
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include "va_x11.h"
-
 void pre()
 {
     test_init();
@@ -228,12 +225,10 @@ void test()
     XMapWindow(dpy, win);
     XSync(dpy, False);
 
-#if 0
     va_status = vaPutSurface(va_dpy, vaSurface, win,
                             0,0,surf_width,surf_height,
                             0,0,win_width,win_height,
                             NULL,0,0);
-#endif
     ASSERT( VA_STATUS_SUCCESS == va_status );
 
     printf("press any key to exit\n");
similarity index 99%
rename from test/test_common.c
rename to libva/test/test_common.c
index b3b4ccb..6b63748 100644 (file)
@@ -22,8 +22,7 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "va.h"
-#include "X11/Xlib.h"
+#include <va_x11.h>
 
 #include "assert.h"
 #include <stdarg.h>
similarity index 100%
rename from test/testplan.txt
rename to libva/test/testplan.txt
diff --git a/libva/test/vainfo.c b/libva/test/vainfo.c
new file mode 100644 (file)
index 0000000..a886815
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+
+#include <X11/va_x11.h>
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+
+#define CHECK_VASTATUS(va_status,func, ret)                             \
+if (va_status != VA_STATUS_SUCCESS) {                                   \
+    fprintf(stderr,"%s failed with error code %d (%s),exit\n",func, vaErrorStr(va_status)); \
+    exit(ret);                                                          \
+}
+
+static char * profile_string(VAProfile profile)
+{
+    switch (profile) {
+            case VAProfileMPEG2Simple: return "VAProfileMPEG2Simple";
+            case VAProfileMPEG2Main: return "VAProfileMPEG2Main";
+            case VAProfileMPEG4Simple: return "VAProfileMPEG4Simple";
+            case VAProfileMPEG4AdvancedSimple: return "VAProfileMPEG4AdvancedSimple";
+            case VAProfileMPEG4Main: return "VAProfileMPEG4Main";
+            case VAProfileH264Baseline: return "VAProfileH264Baseline";
+            case VAProfileH264Main: return "VAProfileH264Main";
+            case VAProfileH264High: return "VAProfileH264High";
+            case VAProfileVC1Simple: return "VAProfileVC1Simple";
+            case VAProfileVC1Main: return "VAProfileVC1Main";
+            case VAProfileVC1Advanced: return "VAProfileVC1Advanced";
+            case VAProfileH263Baseline: return "VAProfileH263Baseline";
+    }
+}
+
+
+static char * entrypoint_string(VAEntrypoint entrypoint)
+{
+    switch (entrypoint) {
+            case VAEntrypointVLD:return "VAEntrypointVLD";
+            case VAEntrypointIZZ:return "VAEntrypointIZZ";
+            case VAEntrypointIDCT:return "VAEntrypointIDCT";
+            case VAEntrypointMoComp:return "VAEntrypointMoComp";
+            case VAEntrypointDeblocking:return "VAEntrypointDeblocking";
+            case VAEntrypointEncSlice:return "VAEntrypointEncSlice";
+    }
+}
+
+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 = rindex(argv[0], '/'); 
+  VAProfile profile;
+  VAEntrypoint entrypoint, entrypoints[10];
+  int num_entrypoint;
+  
+  if (name)
+      name++;
+  else
+      name = argv[0];
+
+  dpy = XOpenDisplay(":0.0");
+  if (NULL == dpy)
+  {
+      fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
+      return 1;
+  }
+  
+  va_dpy = vaGetDisplay(dpy);
+  if (NULL == va_dpy)
+  {
+      fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
+      return 2;
+  }
+  
+  va_status = vaInitialize(va_dpy, &major_version, &minor_version);
+  CHECK_VASTATUS(va_status, "vaInitialize", 3);
+  
+  printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
+
+  driver = vaQueryVendorString(va_dpy);
+  printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
+
+  printf("%s: Supported profile and entrypoints\n", name);
+  for  (profile = VAProfileMPEG2Simple; profile <= VAProfileH263Baseline; profile++) {
+      char *profile_str;
+
+      va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, 
+                                           &num_entrypoint);
+      if (va_status == VA_STATUS_ERROR_UNSUPPORTED_PROFILE)
+       continue;
+
+      CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints", 4);
+
+      profile_str = profile_string(profile);
+      for (entrypoint = 0; entrypoint < num_entrypoint; entrypoint++)
+          printf("      %-32s: %s\n", profile_str, entrypoint_string(entrypoints[entrypoint]));
+  }
+  
+  vaTerminate(va_dpy);
+  
+  return 0;
+}
diff --git a/test/vainfo.c b/test/vainfo.c
deleted file mode 100644 (file)
index 09d34f6..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.
- */
-
-#include "va.h"
-#include "X11/Xlib.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-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 = rindex(argv[0], '/');
-
-  if (name)
-      name++;
-  else
-      name = argv[0];
-
-  dpy = XOpenDisplay(NULL);
-  if (NULL == dpy)
-  {
-      fprintf(stderr, "%s: Error, can't open display: '%s'\n", name, display ? display : "");
-      return 1;
-  }
-  
-  va_dpy = vaGetDisplay(dpy);
-  if (NULL == va_dpy)
-  {
-      fprintf(stderr, "%s: vaGetDisplay() failed\n", name);
-      return 2;
-  }
-  
-  va_status = vaInitialize(va_dpy, &major_version, &minor_version);
-  if (VA_STATUS_SUCCESS != va_status )
-  {
-      fprintf(stderr, "%s: vaInitialize failed with error code %d (%s)\n", 
-              name, va_status, vaErrorStr(va_status));
-      return 3;
-  }
-  printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
-
-  driver = vaQueryVendorString(va_dpy);
-  printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
-  vaTerminate(va_dpy);
-  return 0;
-}