--- libva-0.31.0+latest2.orig/debian/dirs +++ libva-0.31.0+latest2/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin --- libva-0.31.0+latest2.orig/debian/compat +++ libva-0.31.0+latest2/debian/compat @@ -0,0 +1 @@ +5 --- libva-0.31.0+latest2.orig/debian/libva-dev.install +++ libva-0.31.0+latest2/debian/libva-dev.install @@ -0,0 +1,6 @@ +debian/tmp/usr/include/va/va*.h +debian/tmp/usr/lib/va/drivers/dummy_drv_video.so +debian/tmp/usr/lib/libva.so +debian/tmp/usr/lib/libva-x11.so +debian/tmp/usr/lib/libva-glx.so +debian/tmp/usr/lib/pkgconfig/libva*.pc --- libva-0.31.0+latest2.orig/debian/changelog +++ libva-0.31.0+latest2/debian/changelog @@ -0,0 +1,343 @@ +libva (0.31.0+latest2-1+sds11~multimediappa1) karmic; urgency=low + + * New upstream release. Altered packaging scripts once again to enable + Intel i965_drv_video.so. + + -- Brandon Snider Tue, 23 Mar 2010 21:44:57 -0400 + +libva (0.31.0-1+sds11) hardy; urgency=low + + * G45 updates: + - Add vaDeriveImage(). + - Fix YV12 image format. + * OpenGL extensions updates: + - Dynamically allocate VA/GLX vtable. + - Fix display context destruction chain. + * Upgrade to GIT snapshot 2010/03/08: + - Merge SDS patches 010, 320. + - Fix test/encode/h264encode.c issue. + + -- Gwenole Beauchesne Fri, 26 Feb 2010 10:26:13 +0000 + +libva (0.31.0-1+sds10) hardy; urgency=low + + * Add detection of Broadcom Crystal HD chip. + * Require vaDriverInit() function to include SDS API version. + * OpenGL extensions updates: + - Drop the 'bind' API. Only keep vaCopySurfaceGLX(). + - Fix FBO check for the generic implementation with TFP. + * Compat: strip vaPutSurface() flags to match older API. + - This fixes deinterlacing support with GMA500 "psb" driver. + * Upgrade to GIT snapshot 2009/12/17: + - Add a "magic" number to VADisplayContext. + - Add more test programs, including h264 encoding. + + -- Gwenole Beauchesne Tue, 23 Feb 2010 11:29:52 +0000 + +libva (0.31.0-1+sds9) hardy; urgency=low + + * Add extra picture info for VDPAU/MPEG-4. + + -- Gwenole Beauchesne Mon, 23 Nov 2009 09:48:39 +0000 + +libva (0.31.0-1+sds8) hardy; urgency=low + + * Fix detection of ATI chipsets with fglrx >= 8.69-Beta1. + * Upgrade to GIT snapshot 2009/11/20: + - Merge in some G45 fixes and additions. + - Add VA_STATUS_ERROR_SURFACE_IN_DISPLAYING. + + -- Gwenole Beauchesne Fri, 20 Nov 2009 10:44:07 +0000 + +libva (0.31.0-1+sds7) hardy; urgency=low + + * G45 updates: + - Add RGBA subpicture formats. + - Add YV12 vaGetImage() and vaPutImage(). + - Fix subpicture rendering (flickering). + - Fix return value for unimplemented functions. + - Fix vaPutSurface() to handle cliprects (up to 80). + + -- Gwenole Beauchesne Wed, 04 Nov 2009 12:16:11 +0000 + +libva (0.31.0-1+sds6) hardy; urgency=low + + * Fix compatibility with older programs linked against libva.so.0. + * G45 updates: + - Fix vaCreateImage() and vaDestroyImage(). + - Fix subpictures association to parent surfaces. + - Fix rendering of subpictures (extra level of scaling). + - Fix subpicture palette upload (IA44 and AI44 formats for now). + + -- Gwenole Beauchesne Fri, 30 Oct 2009 14:17:00 +0000 + +libva (0.31.0-1+sds5) hardy; urgency=low + + * G45 updates: + - Fix VA driver version. + - Fix vaAssociateSubpicture() arguments. + - Add vaQueryDisplayAttributes() as a no-op. + - Fix vaQueryImageFormats() to return 0 formats at this time. + + -- Gwenole Beauchesne Thu, 24 Sep 2009 12:23:49 +0000 + +libva (0.31.0-1+sds4) hardy; urgency=low + + * Fix chek for GLX extensions. + * Fix libva pkgconfig dependencies. + * Fix vainfo dependencies (Konstantin Pavlov). + * Add C++ guards to . + * Don't search LIBGL_DRIVERS_PATH, stick to extra LIBVA_DRIVERS_PATH. + * Upgrade to GIT snapshot 2009/09/22: + - Merge in SDS patches 001, 201, 202. + - i965_drv_driver: use the horizontal position of a slice. + + -- Gwenole Beauchesne Tue, 22 Sep 2009 13:15:40 +0000 + +libva (0.31.0-1+sds3) hardy; urgency=low + + * Fix detection of ATI chipsets with fglrx >= 8.66-RC1. + * Add VASliceParameterBufferMPEG2.slice_horizontal_position for i965 driver. + + -- Gwenole Beauchesne Thu, 10 Sep 2009 13:42:05 +0000 + +libva (0.31.0-1+sds2) hardy; urgency=low + + * Upgrade to GIT snapshot 2009/09/07. + * Add generic VA/GLX implementation with TFP and FBO. + + -- Gwenole Beauchesne Tue, 08 Sep 2009 12:26:18 +0000 + +libva (0.31.0-1+sds1) hardy; urgency=low + + * Upgrade to VA API version 0.31 (2009/09/02 snapshot). + * Add drmOpenOnce() / drmCloseOnce() replacements for libdrm < 2.3. + + -- Gwenole Beauchesne Wed, 02 Sep 2009 12:06:45 +0000 + +libva (0.30.4-1+sds6) hardy; urgency=low + + * Add OpenGL extensions (v3). + + -- Gwenole Beauchesne Fri, 28 Aug 2009 11:16:11 +0000 + +libva (0.30.4-1+sds5) hardy; urgency=low + + * Add VA_STATUS_ERROR_UNIMPLEMENTED. + * Add vaBindSurfaceToTextureGLX() and vaReleaseSurfaceFromTextureGLX(). + + -- Gwenole Beauchesne Wed, 26 Aug 2009 12:40:31 +0000 + +libva (0.30.4-1+sds4) hardy; urgency=low + + * Add OpenGL extensions. + * Fix NVIDIA driver version check. + * Fix libva-x11-VERSION.so.* build dependencies. + + -- Gwenole Beauchesne Tue, 18 Aug 2009 08:38:56 +0000 + +libva (0.30.4-1+sds3) hardy; urgency=low + + * Fix build of i965_drv_video.so (Paul Bender). + * Check for libdrm >= 2.4 prior to allowing build of i965_drv_video.so. + + -- Gwenole Beauchesne Mon, 06 Jul 2009 10:58:19 +0000 + +libva (0.30.4-1+sds2) hardy; urgency=low + + * Drop obsolete struct fields. + * Add VA_INVALID_ID helper macro. + * Fix memory leak (VADriverContext.dri_state). + * Fix VAEncSliceParameterBuffer compat thunk for 0.30 drivers. + * Make the libva1 package own /usr/lib/va/drivers/ directory. + + -- Gwenole Beauchesne Thu, 02 Jul 2009 13:29:38 +0000 + +libva (0.30.4-1+sds1) hardy; urgency=low + + * Upgrade to VA API version 0.30.4. + + -- Gwenole Beauchesne Thu, 02 Jul 2009 09:30:15 +0000 + +libva (0.30-1+sds1) hardy; urgency=low + + * Upgrade to VA API version 0.30. + * Fix vainfo and few build issues. + + -- Gwenole Beauchesne Thu, 25 Jun 2009 15:31:07 +0000 + +libva (0.29-2+sds12) hardy; urgency=low + + * Add debug package (libva1-dbg). + * Fix va_IsIntelBuffer() for IEGD. + + -- Gwenole Beauchesne Thu, 16 Apr 2009 11:16:31 +0000 + +libva (0.29-2+sds11) hardy; urgency=low + + * Add VASliceParameterBufferBase. + * Add new bit to signal VC-1 skipped P-frames. + + -- Gwenole Beauchesne Fri, 20 Mar 2009 13:23:59 +0000 + +libva (0.29-2+sds10) hardy; urgency=low + + * Rework library SONAME patch. + * Rename MAKEFOURCC to VA_FOURCC. + + -- Gwenole Beauchesne Mon, 02 Mar 2009 15:50:54 +0000 + +libva (0.29-2+sds9) hardy; urgency=low + + * Lower libdrm-dev requirements. Drop libgl-dev build-dep. + * Add H.264 reference_pic_flag (nal_ref_idc != 0) for VDPAU and XvBA. + + -- Gwenole Beauchesne Thu, 05 Feb 2009 13:34:49 +0000 + +libva (0.29-2+sds8) hardy; urgency=low + + * Add extra H.264 info for XvBA backend. + * Set drivers path to LIBDIR/va-API_VERSION/drivers. + * Drop drivers info retrieval through GLX. + + -- Gwenole Beauchesne Wed, 28 Jan 2009 09:56:13 +0000 + +libva (0.29-2+sds7) hardy; urgency=low + + * Add extra VC-1 info for VDPAU backend. + * Make the API change clear in VAPictureH264 too. + + -- Gwenole Beauchesne Tue, 20 Jan 2009 12:26:16 +0000 + +libva (0.29-2+sds6) hardy; urgency=low + + * The H.264 additions require an ABI change. + * Add compatibility layer with upstream libVA 0.29 buffers. + + -- Gwenole Beauchesne Fri, 16 Jan 2009 10:18:55 +0000 + +libva (0.29-2+sds5) hardy; urgency=low + + * Improve detection of NVIDIA driver. + * Add extra H.264 info for VDPAU backend. + * Add for versioning helpers. + + -- Gwenole Beauchesne Tue, 13 Jan 2009 16:56:49 +0000 + +libva (0.29-2+sds4) hardy; urgency=low + + * Split libVA for Core and Display interfaces. + * Allow X11 backend to gather driver info through GLX. + + -- Gwenole Beauchesne Fri, 09 Jan 2009 14:25:03 +0000 + +libva (0.29-2+sds3) unstable; urgency=low + + * Migrate SONAME to libva-VERSION.so.MAJOR. + + -- Gwenole Beauchesne Thu, 08 Jan 2009 16:53:51 +0000 + +libva (0.29-2+sds2) hardy; urgency=low + + * Add MIT license file. + * Add new testcase from upstream (actual MPEG-2 decoding). + + -- Gwenole Beauchesne Thu, 20 Nov 2008 13:07:36 +0000 + +libva (0.29-2+sds1) unstable; urgency=low + + * Allow SMP build. + * Set drivers path to /usr/lib/xorg/modules/drivers + + -- Gwenole Beauchesne Fri, 31 Oct 2008 15:29:41 +0000 + +libva (0.29-2) gaston; urgency=low + + * force rebuild + + -- Inuka Gunawardana Mon, 31 Mar 2008 21:09:28 -0700 + +libva (0.29-1) gaston; urgency=low + + * Beta09 + + -- Inuka Gunawardana Thu, 13 Mar 2008 17:31:44 -0700 + +libva (0.26-4) gaston; urgency=low + + * Force rebuild with Beta06 + + -- Inuka Gunawardana Sun, 20 Jan 2008 21:36:06 -0800 + +libva (0.26-3) gaston; urgency=low + + * Beta6 + + -- Inuka Gunawardana Sun, 20 Jan 2008 21:21:18 -0800 + +libva (0.26-2) gaston; urgency=low + + * Beta3 + + -- Inuka Gunawardana Fri, 7 Dec 2007 18:49:40 -0800 + +libva (0.26-1) unstable; urgency=low + + * Update to API v0.26 + * Replaced vaCreateBuffer / vaBufferData with new single vaCreateBuffer call + + -- Waldo Bastian Thu, 08 Nov 2007 18:23:17 -0800 + +libva (0.25-2) unstable; urgency=low + + * Define VA_LSB_FIRST/VA_MSB_FIRST + + -- Waldo Bastian Tue, 06 Nov 2007 13:01:09 -0700 + +libva (0.25-1) unstable; urgency=low + + * Update to API v0.25 + * Replaced use of VASurface* with VASurfaceID + * Replaced use of VAContext* with VAContextID + * vaDestroySurface renamed to vaDestroySurfaces for consistency + + -- Waldo Bastian Wed, 31 Oct 2007 10:01:09 -0700 + +libva (0.24-3) unstable; urgency=low + + * Improve input argument validation & error reporting + * Adjustment of VC1 field widths + + -- Waldo Bastian Thu, 25 Oct 2007 14:40:16 -0700 + +libva (0.24-2) unstable; urgency=low + + * Minor updates to dummy_video_drv and test cases + + -- Waldo Bastian Thu, 04 Oct 2007 17:09:23 -0700 + + * Updated to v0.24 + * Display attributes added + * H264 parameter fixes + * Swapped vaGetConfigAttributes and vaQueryConfigAttributes + + -- Waldo Bastian Thu, 20 Sep 2007 15:08:04 -0700 + + * Updated to v0.22 + * VAImage and VASubpicture added + + -- Waldo Bastian Fri, 07 Sep 2007 04:32:28 -0700 + + * Updated to v0.20 + * Clean up & exporting DRI interface + + -- Waldo Bastian Thu, 09 Aug 2007 11:49:43 -0700 + + * Add VA_INVALID_SURFACE + + -- Waldo Bastian Wed, 11 Jul 2007 17:24:10 -0700 + + * Initial release of libva + + -- Waldo Bastian Mon, 18 Jun 2007 21:35:31 -0700 + --- libva-0.31.0+latest2.orig/debian/libva1.install +++ libva-0.31.0+latest2/debian/libva1.install @@ -0,0 +1,4 @@ +debian/tmp/usr/lib/libva.so.* +debian/tmp/usr/lib/libva-*.so.* +debian/tmp/usr/bin/vainfo +debian/tmp/usr/lib/va/drivers/i965_drv_video.so --- libva-0.31.0+latest2.orig/debian/copyright +++ libva-0.31.0+latest2/debian/copyright @@ -0,0 +1,44 @@ +This package was debianized by Waldo Bastian on +Mon, 18 Jun 2007 21:35:31 -0700. + +It was downloaded from + +Upstream Author(s): + + Waldo Bastian + Jonathan Bian + +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. --- libva-0.31.0+latest2.orig/debian/rules +++ libva-0.31.0+latest2/debian/rules @@ -0,0 +1,48 @@ +#!/usr/bin/make -f + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/autotools.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk +include /usr/share/cdbs/1/rules/utils.mk + +# Version inforamtion +VA_MAJOR_VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | cut -d'.' -f1) +VA_MINOR_VERSION := $(shell echo $(DEB_UPSTREAM_VERSION) | cut -d'.' -f2) + +# Optimisation flags +CFLAGS = -Wall -g +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +# Allow SMP build +ifeq ($(DEBIAN_BUILD_NCPUS),) + DEBIAN_BUILD_NCPUS = $(shell /usr/bin/getconf _NPROCESSORS_ONLN) +endif +ifneq ($(DEBIAN_BUILD_NCPUS),) + EXTRA_MAKE_FLAGS += -j$(DEBIAN_BUILD_NCPUS) +endif +MAKE += $(EXTRA_MAKE_FLAGS) + +# Extra configure flags +DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS="-Wl,-z,defs" +DEB_CONFIGURE_USER_FLAGS += --enable-i965-driver + +update-config:: run-autoreconf +common-binary-predeb-arch:: list-missing + +run-autoreconf: stamp-autoreconf +stamp-autoreconf: + autoreconf -i + touch $@ + +# Compatibility with older packaging (and SONAME) +install/libva1:: + echo ".text"|gcc -xassembler - -o debian/tmp/usr/lib/libva.so.0.29 -shared -Wl,-soname,libva.so.0 -Ldebian/tmp/usr/lib -lva-compat + echo ".text"|gcc -xassembler - -o debian/tmp/usr/lib/libva.so.1.0.0 -shared -Wl,-soname,libva.so.1 -Ldebian/tmp/usr/lib -lva-x11 + /sbin/ldconfig -n debian/tmp/usr/lib --- libva-0.31.0+latest2.orig/debian/control +++ libva-0.31.0+latest2/debian/control @@ -0,0 +1,51 @@ +Source: libva +Priority: extra +Maintainer: Waldo Bastian +Build-Depends: cdbs, + debhelper (>= 5), + autotools-dev, + libdrm-dev, + x11proto-xext-dev, + libxext-dev, + libxfixes-dev, + libgl1-mesa-dev, + pkg-config, + automake1.9, libtool +Standards-Version: 3.7.2 +Section: libs + +Package: libva-dev +Section: libdevel +Architecture: i386 amd64 +Depends: libva1 (= ${binary:Version}), + libdrm-dev, + pkg-config +Conflicts: libva-0.29-dev +Replaces: libva-0.29-dev +Description: Video Acceleration (VA) API for Linux -- development files + The libva library implements the Video Acceleration (VA) API for Linux. + The library loads a hardware dependendent driver. + . + This package provides the development environment for libva. + +Package: libva1 +Section: libs +Architecture: i386 amd64 +Depends: ${shlibs:Depends} +Conflicts: libva-0.29-0 +Replaces: libva-0.29-0 +Provides: libva-0.29-0 +Description: Video Acceleration (VA) API for Linux -- runtime + The libva library implements the Video Acceleration (VA) API for Linux. + The library loads a hardware dependendent driver. + +Package: libva1-dbg +Section: libdevel +Architecture: i386 amd64 +Depends: libva1 (= ${Source-Version}) +Description: Video Acceleration (VA) API for Linux -- runtime + The libva library implements the Video Acceleration (VA) API for Linux. + The library loads a hardware dependendent driver. + . + This package contains the debug files. + --- libva-0.31.0+latest2.orig/debian/README.Debian +++ libva-0.31.0+latest2/debian/README.Debian @@ -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 Mon, 18 Jun 2007 21:35:31 -0700 --- libva-0.31.0+latest2.orig/debian/libva-dev.dirs +++ libva-0.31.0+latest2/debian/libva-dev.dirs @@ -0,0 +1,2 @@ +usr/lib +usr/include --- libva-0.31.0+latest2.orig/debian/libva1.dirs +++ libva-0.31.0+latest2/debian/libva1.dirs @@ -0,0 +1,2 @@ +usr/lib +usr/lib/va/drivers --- libva-0.31.0+latest2.orig/debian/patches/391_compat.patch +++ libva-0.31.0+latest2/debian/patches/391_compat.patch @@ -0,0 +1,3214 @@ +commit 94db34ae392a7787afac9087799bb0421c844b83 +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:40:56 2009 +0000 + + Add compatibility layer with original VA-API 0.29 to 0.31. + +diff --git a/va/Makefile.am b/va/Makefile.am +index ebff3d5..1752526 100644 +diff --git a/va/va.c b/va/va.c +index 0d208d8..ad201fa 100644 +diff --git a/va/va_backend.h b/va/va_backend.h +index 06fef7f..9cf8911 100644 +diff --git a/va/va_compat.c b/va/va_compat.c +new file mode 100644 +index 0000000..af43188 +--- /dev/null ++++ b/va/va_compat.c +@@ -0,0 +1,1178 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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_compat.h" ++#include "va_backend.h" ++#include ++#include ++#include ++#include ++ ++#define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) ++#define COMPAT_CTX(ctx) ((VACompatContextP)(ctx)->compat) ++#define ASSERT assert ++ ++/* Invoke the normal VA API entry-point. This one can be replaced with ++ one of the va_compat_*() functions */ ++#define VA_INVOKE(FUNC, CTX, ...) \ ++ (CTX)->vtable.FUNC(CTX, __VA_ARGS__) ++ ++/* Invoke the real VA API entry-point. That is, the driver's function */ ++#define VA_INVOKE_COMPAT_ARGS(CTX, ...) \ ++ (COMPAT_CTX(CTX)->compat_ctx, __VA_ARGS__) ++#define VA_INVOKE_COMPAT(FUNC, CTX, ...) \ ++ COMPAT_CTX(CTX)->vtable.FUNC VA_INVOKE_COMPAT_ARGS(CTX, __VA_ARGS__) ++ ++typedef struct VACompatContext *VACompatContextP; ++ ++typedef VAStatus (*VABufferTranslateFunc)(VACompatContextP ctx, void *dest, const void *src); ++ ++typedef enum { ++ VA_DRIVER_ID_UNKNOWN, ++ VA_DRIVER_ID_POULSBO, ++ VA_DRIVER_ID_IEGD ++} VADriverID; ++ ++typedef struct { ++ VABufferID id; ++ VABufferType type; ++ unsigned int size; ++ unsigned int num_elements; ++ unsigned char *data; ++ VABufferTranslateFunc translate; ++ VABufferID compat_id; ++ unsigned int compat_size; ++ unsigned char *compat_data; ++ unsigned int map_count; ++} VABufferCompat; ++ ++typedef struct VAContextMap *VAContextMapP; ++typedef struct VAContextMap { ++ VASurfaceID surface; ++ VAContextID context; ++ VAContextMapP next; ++} VAContextMap; ++ ++typedef struct { ++ VAStatus (*vaTerminate)(void *); ++ VAStatus (*vaQueryConfigProfiles)(void *, VAProfile *, int *); ++ VAStatus (*vaQueryConfigEntrypoints)(void *, VAProfile, VAEntrypoint *, int *); ++ VAStatus (*vaGetConfigAttributes)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int); ++ VAStatus (*vaCreateConfig)(void *, VAProfile, VAEntrypoint, VAConfigAttrib *, int, VAConfigID *); ++ VAStatus (*vaDestroyConfig)(void *, VAConfigID); ++ VAStatus (*vaQueryConfigAttributes)(void *, VAConfigID, VAProfile *, VAEntrypoint *, VAConfigAttrib *, int *); ++ VAStatus (*vaCreateSurfaces)(void *, int, int, int, int, VASurfaceID *); ++ VAStatus (*vaDestroySurfaces)(void *, VASurfaceID *, int); ++ VAStatus (*vaCreateContext)(void *, VAConfigID, int, int, int, VASurfaceID *, int, VAContextID *); ++ VAStatus (*vaDestroyContext)(void *, VAContextID); ++ VAStatus (*vaCreateBuffer)(void *, VAContextID, VABufferType, unsigned int, unsigned int, void *, VABufferID *); ++ VAStatus (*vaBufferSetNumElements)(void *, VABufferID, unsigned int); ++ VAStatus (*vaMapBuffer)(void *, VABufferID, void **); ++ VAStatus (*vaUnmapBuffer)(void *, VABufferID); ++ VAStatus (*vaDestroyBuffer)(void *, VABufferID); ++ VAStatus (*vaBeginPicture)(void *, VAContextID, VASurfaceID); ++ VAStatus (*vaRenderPicture)(void *, VAContextID, VABufferID *, int); ++ VAStatus (*vaEndPicture)(void *, VAContextID); ++ VAStatus (*vaSyncSurface_pre31)(void *, VAContextID, VASurfaceID); ++ VAStatus (*vaQuerySurfaceStatus)(void *, VASurfaceID, VASurfaceStatus *); ++ VAStatus (*vaPutSurface)(void *, VASurfaceID, unsigned long, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, VARectangle *, unsigned int, unsigned int); ++ VAStatus (*vaQueryImageFormats)(void *, VAImageFormat *, int *); ++ VAStatus (*vaCreateImage)(void *, VAImageFormat *, int, int, VAImage *); ++ VAStatus (*vaDeriveImage)(void *, VASurfaceID, VAImage *); ++ VAStatus (*vaDestroyImage)(void *, VAImageID); ++ VAStatus (*vaSetImagePalette)(void *, VAImageID, unsigned char *); ++ VAStatus (*vaGetImage)(void *, VASurfaceID, int, int, unsigned int, unsigned int, VAImageID); ++ VAStatus (*vaPutImage_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int); ++ VAStatus (*vaPutImage2_pre31)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); ++ VAStatus (*vaQuerySubpictureFormats)(void *, VAImageFormat *, unsigned int *, unsigned int *); ++ VAStatus (*vaCreateSubpicture)(void *, VAImageID, VASubpictureID *); ++ VAStatus (*vaDestroySubpicture)(void *, VASubpictureID); ++ VAStatus (*vaSetSubpictureImage)(void *, VASubpictureID, VAImageID); ++ VAStatus (*vaSetSubpictureChromakey)(void *, VASubpictureID, unsigned int, unsigned int, unsigned int); ++ VAStatus (*vaSetSubpictureGlobalAlpha)(void *, VASubpictureID, float); ++ VAStatus (*vaAssociateSubpicture_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaAssociateSubpicture2_pre31)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaDeassociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int); ++ VAStatus (*vaQueryDisplayAttributes)(void *, VADisplayAttribute *, int *); ++ VAStatus (*vaGetDisplayAttributes)(void *, VADisplayAttribute *, int); ++ VAStatus (*vaSetDisplayAttributes)(void *, VADisplayAttribute *, int); ++ ++ /* 0.29 hooks */ ++ VAStatus (*vaSetSubpicturePalette)(void *, VASubpictureID, unsigned char *); ++ VAStatus (*vaDbgCopySurfaceToBuffer)(void *, VASurfaceID, void **, unsigned int *); ++ ++ /* 0.30 hooks */ ++ VAStatus (*vaCreateSurfaceFromCIFrame)(void *, unsigned long, VASurfaceID *); ++ VAStatus (*vaCreateSurfaceFromV4L2Buf)(void *, int, struct v4l2_format *, struct v4l2_buffer *, VASurfaceID *); ++ VAStatus (*vaCopySurfaceToBuffer)(void *, VASurfaceID, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, unsigned int *, void **); ++ ++ /* 0.31 hooks */ ++ VAStatus (*vaPutImage)(void *, VASurfaceID, VAImageID, int, int, unsigned int, unsigned int, int, int, unsigned int, unsigned int); ++ VAStatus (*vaAssociateSubpicture)(void *, VASubpictureID, VASurfaceID *, int, short, short, unsigned short, unsigned short, short, short, unsigned short, unsigned short, unsigned int); ++ VAStatus (*vaSyncSurface)(void *, VASurfaceID); ++} VACompatDriverVTable; ++ ++typedef struct VACompatContext { ++ VABufferCompat *buffers; ++ unsigned int buffers_count_max; ++ unsigned int compat_version; ++ void *compat_ctx; ++ VACompatDriverVTable vtable; /* original vtable */ ++ VADriverID driver_id; ++ char *driver_name; ++ VAContextMapP context_map; ++ VAContextMapP last_context_map_match; ++ unsigned int skip_frame : 1; ++} VACompatContext; ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 29 ++#include "va_compat_template.h" ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 30 ++#include "va_compat_template.h" ++ ++#define COMPAT_MAJOR 0 ++#define COMPAT_MINOR 31 ++#include "va_compat_template.h" ++ ++static inline int va_IsIntelBuffer(VADriverContextP ctx, VABufferID id) ++{ ++ VACompatContextP compat = ctx->compat; ++ ++ if (compat->driver_id == VA_DRIVER_ID_POULSBO) { ++ /* There were only Intel implementations for VA API. Besides, the ++ returned buffer IDs had the following format [ 0 BASE ID ] where ++ BASE is the 7-bit value 0x04 and ID an index into the heap of ++ objects */ ++ return (id & 0x7f000000) == 0x04000000; ++ } ++ ++ if (compat->driver_id == VA_DRIVER_ID_IEGD) { ++ /* XXX: there is no means to differentiate the buffers, they ++ are linearly generated (IEGD 10.0 build 1335) */ ++ return 1; ++ } ++ ++ return 0; ++} ++ ++static VAContextMapP va_context_map_lookup_p( ++ VACompatContextP ctx, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m = ctx->context_map; ++ ++ while (m) { ++ if (m->surface == surface) ++ return m; ++ m = m->next; ++ } ++ return NULL; ++} ++ ++static VAContextID va_context_map_lookup( ++ VACompatContextP ctx, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m; ++ ++ /* Lookup in cached */ ++ m = ctx->last_context_map_match; ++ if (m && m->surface == surface) ++ return m->context; ++ ++ /* Full (slow) lookup */ ++ m = va_context_map_lookup_p(ctx, surface); ++ if (m) { ++ ctx->last_context_map_match = m; ++ return m->context; ++ } ++ return VA_INVALID_ID; ++} ++ ++static void va_context_map_add( ++ VACompatContextP ctx, ++ VAContextID context, ++ VASurfaceID surface ++) ++{ ++ VAContextMapP m; ++ ++ /* Update existing entry */ ++ m = va_context_map_lookup_p(ctx, surface); ++ if (m) { ++ m->context = context; ++ return; ++ } ++ ++ /* Create new mapping */ ++ m = malloc(sizeof(*m)); ++ ASSERT(m); ++ if (m) { ++ m->surface = surface; ++ m->context = context; ++ m->next = ctx->context_map; ++ ctx->context_map = m; ++ } ++} ++ ++static void va_context_map_remove( ++ VACompatContextP ctx, ++ VAContextID context ++) ++{ ++ VAContextMapP p = NULL; ++ VAContextMapP m = ctx->context_map; ++ VAContextMapP d; ++ ++ while (m) { ++ if (m->context == context) { ++ d = m; ++ ++ /* Unlink current node */ ++ if (p) ++ p->next = m->next; ++ else ++ ctx->context_map = m->next; ++ m = m->next; ++ ++ /* Reset cache */ ++ if (ctx->last_context_map_match == d) ++ ctx->last_context_map_match = NULL; ++ ++ free(d); ++ } ++ else { ++ p = m; ++ m = m->next; ++ } ++ } ++} ++ ++static VABufferCompat *va_GetBufferCompat ( ++ VADriverContextP ctx, ++ VABufferID id ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ int index; ++ ++ if (!va_IsIntelBuffer(ctx, id)) ++ return NULL; ++ ++ index = id & 0x00ffffff; ++ if (index >= compat->buffers_count_max) ++ return NULL; ++ ++ if (compat->buffers[index].id != id) ++ return NULL; ++ ++ return &compat->buffers[index]; ++} ++ ++static VAStatus va_TranslateBufferCompat ( ++ VADriverContextP ctx, ++ VABufferCompat *compat_buffer ++) ++{ ++ VAStatus status; ++ unsigned char *src, *dest; ++ int i; ++ ++ status = VA_INVOKE(vaMapBuffer, ctx, compat_buffer->id, (void **)&src); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ ASSERT(compat_buffer->data); ++ ASSERT(src == compat_buffer->data); ++ ASSERT(compat_buffer->compat_data); ++ dest = compat_buffer->compat_data; ++ for (i = 0; i < compat_buffer->num_elements; i++) ++ { ++ /* XXX: check errors */ ++ status = compat_buffer->translate(ctx->compat, dest, src); ++ ++ src += compat_buffer->size; ++ dest += compat_buffer->compat_size; ++ } ++ ++ return VA_INVOKE(vaUnmapBuffer, ctx, compat_buffer->id); ++} ++ ++static VAStatus va_CreateBufferCompat ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VABufferID id, ++ VABufferType type, ++ unsigned int size, ++ unsigned int num_elements, ++ unsigned int compat_size, ++ VABufferTranslateFunc translate_func ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VABufferCompat *compat_buffer; ++ int index; ++ ++ if (!va_IsIntelBuffer(ctx, id)) ++ return VA_STATUS_ERROR_INVALID_BUFFER; ++ index = id & 0x00ffffff; ++ ++ /* XXX: this allocation strategy is not really space efficient... */ ++ if (index >= compat->buffers_count_max) ++ { ++ compat->buffers_count_max = index + 1; ++ compat->buffers = realloc(compat->buffers, ++ (compat->buffers_count_max * ++ sizeof(VABufferCompat))); ++ if (compat->buffers == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ } ++ ++ compat_buffer = &compat->buffers[index]; ++ compat_buffer->id = id; ++ compat_buffer->type = type; ++ compat_buffer->size = size; ++ compat_buffer->num_elements = num_elements; ++ compat_buffer->data = NULL; ++ compat_buffer->translate = translate_func; ++ compat_buffer->compat_size = compat_size; ++ compat_buffer->compat_data = NULL; ++ compat_buffer->map_count = 0; ++ ++ return VA_INVOKE_COMPAT(vaCreateBuffer, ++ ctx, ++ context, ++ type, ++ compat_size, ++ num_elements, ++ NULL, ++ &compat_buffer->compat_id); ++} ++ ++static VAStatus va_DestroyBufferCompat ( ++ VADriverContextP ctx, ++ VABufferID id ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, id)) == NULL) ++ return VA_STATUS_SUCCESS; ++ ++ /* Force unmap if there were more maps than unmaps */ ++ if (compat_buffer->map_count > 1) ++ compat_buffer->map_count = 1; ++ if (compat_buffer->map_count > 1) ++ { ++ if ((status = VA_INVOKE(vaUnmapBuffer, ctx, id)) != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ compat_buffer->id = 0; ++ return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->compat_id); ++} ++ ++static VAStatus va_compat_CreateBuffer ( ++ VADriverContextP ctx, ++ VAContextID context, /* in */ ++ VABufferType type, /* in */ ++ unsigned int size, /* in */ ++ unsigned int num_elements, /* in */ ++ void *data, /* in */ ++ VABufferID *buf_id /* out */ ++) ++{ ++ VABufferTranslateFunc translate_func = NULL; ++ unsigned int compat_size = 0; ++ VAStatus status; ++ ++ status = VA_INVOKE_COMPAT(vaCreateBuffer, ++ ctx, ++ context, ++ type, ++ size, ++ num_elements, ++ data, ++ buf_id); ++ ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++#define INIT_TRANSLATE_FUNC_(STRUCT, MAJOR, MINOR) do { \ ++ translate_func = va_compat_translate_VA##STRUCT##_##MAJOR##_##MINOR; \ ++ compat_size = sizeof(VA##STRUCT##_##MAJOR##_##MINOR); \ ++} while (0) ++#define INIT_TRANSLATE_FUNC(BUFFER, CODEC, MAJOR, MINOR) \ ++ INIT_TRANSLATE_FUNC_(BUFFER##Buffer##CODEC, MAJOR, MINOR) ++ ++ /* XXX: this assumes all structures have different sizes from each other */ ++ switch (size) { ++ case sizeof(VAPictureParameterBufferH264): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,H264, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VASliceParameterBufferH264): ++ if (type == VASliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(SliceParameter,H264, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferVC1): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,VC1, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferMPEG2): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG2, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VASliceParameterBufferMPEG2): ++ if (type == VASliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(SliceParameter,MPEG2, 0,30); break; ++ } ++ } ++ break; ++ case sizeof(VAPictureParameterBufferMPEG4): ++ if (type == VAPictureParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 29: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,29); break; ++ case 30: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,30); break; ++ case 31: INIT_TRANSLATE_FUNC(PictureParameter,MPEG4, 0,31); break; ++ } ++ } ++ break; ++ case sizeof(VAEncSliceParameterBuffer): ++ if (type == VAEncSliceParameterBufferType && ctx->version_major == 0) ++ { ++ switch (ctx->version_minor) { ++ case 30: INIT_TRANSLATE_FUNC_(EncSliceParameterBuffer, 0,30); break; ++ } ++ } ++ break; ++ } ++ ++#undef INIT_TRANSLATE_FUNC ++ ++ /* Create thunk */ ++ if (buf_id && translate_func) ++ { ++ ASSERT(compat_size > 0); ++ ++ status = va_CreateBufferCompat(ctx, ++ context, ++ *buf_id, ++ type, ++ size, ++ num_elements, ++ compat_size, ++ translate_func); ++ } ++ ++ return status; ++} ++ ++static VAStatus va_compat_BufferSetNumElements ( ++ VADriverContextP ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ status = VA_INVOKE_COMPAT(vaBufferSetNumElements, ctx, buf_id, num_elements); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) != NULL) ++ { ++ compat_buffer->num_elements = num_elements; ++ status = VA_INVOKE_COMPAT(vaBufferSetNumElements, ++ ctx, ++ compat_buffer->compat_id, ++ num_elements); ++ } ++ ++ return status; ++} ++ ++static VAStatus va_compat_DestroyBuffer ( ++ VADriverContextP ctx, ++ VABufferID buffer_id ++) ++{ ++ VAStatus status; ++ if ((status = va_DestroyBufferCompat(ctx, buffer_id)) != VA_STATUS_SUCCESS) ++ return status; ++ ++ return VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, buffer_id); ++} ++ ++static VAStatus va_compat_MapBuffer ( ++ VADriverContextP ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) ++ return VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, pbuf); ++ ++ if (compat_buffer->map_count++ == 0) ++ { ++ status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, buf_id, (void **)&compat_buffer->data); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ status = VA_INVOKE_COMPAT(vaMapBuffer, ctx, compat_buffer->compat_id, (void **)&compat_buffer->compat_data); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ if (pbuf) ++ *pbuf = compat_buffer->data; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus va_compat_UnmapBuffer ( ++ VADriverContextP ctx, ++ VABufferID buf_id /* in */ ++) ++{ ++ VABufferCompat *compat_buffer; ++ VAStatus status; ++ ++ if ((compat_buffer = va_GetBufferCompat(ctx, buf_id)) == NULL) ++ return VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, buf_id); ++ ++ if (--compat_buffer->map_count == 0) ++ { ++ status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->compat_id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer->compat_data = NULL; ++ ++ status = VA_INVOKE_COMPAT(vaUnmapBuffer, ctx, compat_buffer->id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer->data = NULL; ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus va_compat_BeginPicture ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VASurfaceID render_target ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ compat->skip_frame = 0; ++ return VA_INVOKE_COMPAT(vaBeginPicture, ctx, context, render_target); ++} ++ ++static VAStatus va_compat_EndPicture ( ++ VADriverContextP ctx, ++ VAContextID context ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VAStatus status = VA_INVOKE_COMPAT(vaEndPicture, ctx, context); ++ ++ /* Ignore errors if the HW decoder did not handle VC-1 skipped P-frames */ ++ if (compat->skip_frame && status == VA_STATUS_ERROR_UNKNOWN) ++ status = VA_STATUS_SUCCESS; ++ ++ return status; ++} ++ ++static VAStatus va_compat_RenderPicture ( ++ VADriverContextP ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++) ++{ ++ VACompatContextP compat = ctx->compat; ++ VABufferCompat *compat_buffer; ++ VABufferID *compat_buffer_ids; ++ VAStatus status; ++ int i, n; ++ ++ if ((n = num_buffers) < 1) ++ n = 1; ++ compat_buffer_ids = alloca(n * sizeof(compat_buffer_ids[0])); ++ ++ for (i = 0; i < num_buffers; i++) ++ { ++ if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) == NULL) ++ compat_buffer_ids[i] = buffers[i]; ++ else ++ { ++ status = va_TranslateBufferCompat(ctx, compat_buffer); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ compat_buffer_ids[i] = compat_buffer->compat_id; ++ } ++ } ++ ++ if (!compat->skip_frame) ++ { ++ status = VA_INVOKE_COMPAT(vaRenderPicture, ctx, context, compat_buffer_ids, num_buffers); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ /* Buffers are automatically destroyed afterwards */ ++ for (i = 0; i < num_buffers; i++) ++ { ++ if ((compat_buffer = va_GetBufferCompat(ctx, buffers[i])) != NULL) ++ { ++ status = VA_INVOKE_COMPAT(vaDestroyBuffer, ctx, compat_buffer->id); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++#define DEFINE_VTABLE_ENTRY_(RETVAL, PROC, ARGS, COMPAT_PROC, COMPAT_ARGS, COMPAT_PRE, COMPAT_POST) \ ++static RETVAL va_compat_##PROC ARGS \ ++{ \ ++ if (COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC == NULL) \ ++ return VA_STATUS_ERROR_OPERATION_FAILED; \ ++ COMPAT_PRE; \ ++ RETVAL ret = COMPAT_CTX(ctx)->vtable.va##COMPAT_PROC VA_INVOKE_COMPAT_ARGS COMPAT_ARGS; \ ++ COMPAT_POST; \ ++ return ret; \ ++} ++ ++#define DEFINE_VTABLE_ENTRY(RETVAL, PROC, DECL_ARGS, CALL_ARGS) \ ++DEFINE_VTABLE_ENTRY_(RETVAL, PROC, DECL_ARGS, PROC, CALL_ARGS, {}, {}) ++ ++static VAStatus va_compat_Terminate(VADriverContextP ctx) ++{ ++ if (COMPAT_CTX(ctx)->vtable.vaTerminate == NULL) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ return COMPAT_CTX(ctx)->vtable.vaTerminate(COMPAT_CTX(ctx)->compat_ctx); ++} ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigProfiles, ++ (VADriverContextP ctx, VAProfile *profile_list, int *num_profiles), ++ (ctx, profile_list, num_profiles)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigEntrypoints, ++ (VADriverContextP ctx, VAProfile profile, ++ VAEntrypoint *entrypoint_list, int *num_entrypoints), ++ (ctx, profile, entrypoint_list, num_entrypoints)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetConfigAttributes, ++ (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, int num_attribs), ++ (ctx, profile, entrypoint, attrib_list, num_attribs)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateConfig, ++ (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id), ++ (ctx, profile, entrypoint, attrib_list, num_attribs, config_id)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyConfig, ++ (VADriverContextP ctx, VAConfigID config_id), ++ (ctx, config_id)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryConfigAttributes, ++ (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, ++ VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs), ++ (ctx, config_id, profile, entrypoint, attrib_list, num_attribs)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaces, ++ (VADriverContextP ctx, int width, int height, int format, ++ int num_surfaces, VASurfaceID *surfaces), ++ (ctx, width, height, format, num_surfaces, surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroySurfaces, ++ (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces), ++ (ctx, surface_list, num_surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateContext, ++ (VADriverContextP ctx, VAConfigID config_id, ++ int picture_width, int picture_height, int flag, ++ VASurfaceID *render_targets, int num_render_targets, VAContextID *context), ++ (ctx, config_id, picture_width, picture_height, flag, ++ render_targets, num_render_targets, context)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyContext, ++ (VADriverContextP ctx, VAContextID context), ++ (ctx, context)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SyncSurface, ++ (VADriverContextP ctx, VASurfaceID render_target), ++ (ctx, render_target)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QuerySurfaceStatus, ++ (VADriverContextP ctx, VASurfaceID render_target, VASurfaceStatus *status), ++ (ctx, render_target, status)) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, PutSurface, ++ (VADriverContextP ctx, VASurfaceID surface, Drawable draw, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ VARectangle *cliprects, unsigned int number_cliprects, unsigned int flags), ++ PutSurface, ++ (ctx, surface, draw, srcx, srcy, srcw, srch, destx, desty, destw, desth, ++ cliprects, number_cliprects, flags), ++ { ++ if (COMPAT_CTX(ctx)->compat_version < 30) /* 0.30 */ ++ flags &= (VA_TOP_FIELD|VA_BOTTOM_FIELD|VA_CLEAR_DRAWABLE); ++ }, ++ {}) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryImageFormats, ++ (VADriverContextP ctx, VAImageFormat *format_list, int *num_formats), ++ (ctx, format_list, num_formats)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateImage, ++ (VADriverContextP ctx, VAImageFormat *format, ++ int width, int height, VAImage *image), ++ (ctx, format, width, height, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DeriveImage, ++ (VADriverContextP ctx, VASurfaceID surface, VAImage *image), ++ (ctx, surface, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroyImage, ++ (VADriverContextP ctx, VAImageID image), ++ (ctx, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetImagePalette, ++ (VADriverContextP ctx, VAImageID image, unsigned char *palette), ++ (ctx, image, palette)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetImage, ++ (VADriverContextP ctx, VASurfaceID surface, ++ int x, int y, unsigned int width, unsigned int height, VAImageID image), ++ (ctx, surface, x, y, width, height, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, PutImage, ++ (VADriverContextP ctx, VASurfaceID surface, VAImageID image, ++ int srcx, int srcy, unsigned int srcw, unsigned int srch, ++ int destx, int desty, unsigned int destw, unsigned int desth), ++ (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QuerySubpictureFormats, ++ (VADriverContextP ctx, VAImageFormat *format_list, ++ unsigned int *flags, unsigned int *num_formats), ++ (ctx, format_list, flags, num_formats)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSubpicture, ++ (VADriverContextP ctx, VAImageID image, VASubpictureID *subpicture), ++ (ctx, image, subpicture)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DestroySubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture), ++ (ctx, subpicture)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureImage, ++ (VADriverContextP ctx, VASubpictureID subpicture, VAImageID image), ++ (ctx, subpicture, image)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureChromakey, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask), ++ (ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetSubpictureGlobalAlpha, ++ (VADriverContextP ctx, VASubpictureID subpicture, float global_alpha), ++ (ctx, subpicture, global_alpha)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, AssociateSubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ unsigned int flags), ++ (ctx, subpicture, target_surfaces, num_surfaces, ++ srcx, srcy, srcw, srch, destx, desty, destw, desth, flags)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, DeassociateSubpicture, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces), ++ (ctx, subpicture, target_surfaces, num_surfaces)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, QueryDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, GetDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, SetDisplayAttributes, ++ (VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes), ++ (ctx, attr_list, num_attributes)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaceFromCIFrame, ++ (VADriverContextP ctx, unsigned long frame_id, VASurfaceID *surface), ++ (ctx, frame_id, surface)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CreateSurfaceFromV4L2Buf, ++ (VADriverContextP ctx, int v4l2_fd, ++ struct v4l2_format *v4l2_fmt, struct v4l2_buffer *v4l2_buf, ++ VASurfaceID *surface), ++ (ctx, v4l2_fd, v4l2_fmt, v4l2_buf, surface)) ++ ++DEFINE_VTABLE_ENTRY( ++ VAStatus, CopySurfaceToBuffer, ++ (VADriverContextP ctx, VASurfaceID surface, 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, ++ void **buffer), ++ (ctx, surface, fourcc, ++ luma_stride, chroma_u_stride, chroma_v_stride, ++ luma_offset, chroma_u_offset, chroma_v_offset, ++ buffer)) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, SyncSurface_pre31, ++ (VADriverContextP ctx, VASurfaceID render_target), ++ SyncSurface_pre31, ++ (ctx, va_context_map_lookup(COMPAT_CTX(ctx), render_target), render_target), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, PutImage_pre31, ++ (VADriverContextP ctx, VASurfaceID surface, VAImageID image, ++ int srcx, int srcy, unsigned int srcw, unsigned int srch, ++ int destx, int desty, unsigned int destw, unsigned int desth), ++ PutImage2_pre31, ++ (ctx, surface, image, srcx, srcy, srcw, srch, destx, desty, destw, desth), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, AssociateSubpicture_pre31, ++ (VADriverContextP ctx, VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, int num_surfaces, ++ short srcx, short srcy, unsigned short srcw, unsigned short srch, ++ short destx, short desty, unsigned short destw, unsigned short desth, ++ unsigned int flags), ++ AssociateSubpicture2_pre31, ++ (ctx, subpicture, target_surfaces, num_surfaces, ++ srcx, srcy, srcw, srch, destx, desty, destw, desth, flags), ++ {}, {}) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, CreateContext_pre31, ++ (VADriverContextP ctx, VAConfigID config_id, ++ int picture_width, int picture_height, int flag, ++ VASurfaceID *render_targets, int num_render_targets, VAContextID *context), ++ CreateContext, ++ (ctx, config_id, picture_width, picture_height, flag, ++ render_targets, num_render_targets, context), ++ {}, { ++ VACompatContextP const compat_ctx = COMPAT_CTX(ctx); ++ int i; ++ for (i = 0; i < num_render_targets; i++) ++ va_context_map_add(compat_ctx, *context, render_targets[i]); ++ }) ++ ++DEFINE_VTABLE_ENTRY_( ++ VAStatus, DestroyContext_pre31, ++ (VADriverContextP ctx, VAContextID context), ++ DestroyContext, ++ (ctx, context), ++ {}, { va_context_map_remove(COMPAT_CTX(ctx), context); }) ++ ++#undef DEFINE_VTABLE_ENTRY ++#undef DEFINE_VTABLE_ENTRY_ ++ ++static void va_compat_init_VADriverVTable(VADriverContextP ctx, int compat_version) ++{ ++#define INIT_VTABLE_(CTX, DST_PROC, SRC_PROC) \ ++ (CTX)->vtable.va##DST_PROC = va_compat_##SRC_PROC ++#define INIT_VTABLE(CTX, PROC) \ ++ INIT_VTABLE_(CTX, PROC, PROC) ++ ++ INIT_VTABLE(ctx, Terminate); ++ INIT_VTABLE(ctx, QueryConfigProfiles); ++ INIT_VTABLE(ctx, QueryConfigEntrypoints); ++ INIT_VTABLE(ctx, GetConfigAttributes); ++ INIT_VTABLE(ctx, CreateConfig); ++ INIT_VTABLE(ctx, DestroyConfig); ++ INIT_VTABLE(ctx, QueryConfigAttributes); ++ INIT_VTABLE(ctx, CreateSurfaces); ++ INIT_VTABLE(ctx, DestroySurfaces); ++ INIT_VTABLE(ctx, CreateContext); ++ INIT_VTABLE(ctx, DestroyContext); ++ INIT_VTABLE(ctx, CreateBuffer); ++ INIT_VTABLE(ctx, BufferSetNumElements); ++ INIT_VTABLE(ctx, MapBuffer); ++ INIT_VTABLE(ctx, UnmapBuffer); ++ INIT_VTABLE(ctx, DestroyBuffer); ++ INIT_VTABLE(ctx, BeginPicture); ++ INIT_VTABLE(ctx, RenderPicture); ++ INIT_VTABLE(ctx, EndPicture); ++ INIT_VTABLE(ctx, SyncSurface); ++ INIT_VTABLE(ctx, QuerySurfaceStatus); ++ INIT_VTABLE(ctx, PutSurface); ++ INIT_VTABLE(ctx, QueryImageFormats); ++ INIT_VTABLE(ctx, CreateImage); ++ INIT_VTABLE(ctx, DeriveImage); ++ INIT_VTABLE(ctx, DestroyImage); ++ INIT_VTABLE(ctx, SetImagePalette); ++ INIT_VTABLE(ctx, GetImage); ++ INIT_VTABLE(ctx, PutImage); ++ INIT_VTABLE(ctx, QuerySubpictureFormats); ++ INIT_VTABLE(ctx, CreateSubpicture); ++ INIT_VTABLE(ctx, DestroySubpicture); ++ INIT_VTABLE(ctx, SetSubpictureImage); ++ INIT_VTABLE(ctx, SetSubpictureChromakey); ++ INIT_VTABLE(ctx, SetSubpictureGlobalAlpha); ++ INIT_VTABLE(ctx, AssociateSubpicture); ++ INIT_VTABLE(ctx, DeassociateSubpicture); ++ INIT_VTABLE(ctx, QueryDisplayAttributes); ++ INIT_VTABLE(ctx, GetDisplayAttributes); ++ INIT_VTABLE(ctx, SetDisplayAttributes); ++ INIT_VTABLE(ctx, CreateSurfaceFromCIFrame); ++ INIT_VTABLE(ctx, CreateSurfaceFromV4L2Buf); ++ INIT_VTABLE(ctx, CopySurfaceToBuffer); ++ ++ if (compat_version && compat_version < 31) { ++ INIT_VTABLE_(ctx, CreateContext, CreateContext_pre31); ++ INIT_VTABLE_(ctx, DestroyContext, DestroyContext_pre31); ++ INIT_VTABLE_(ctx, SyncSurface, SyncSurface_pre31); ++ INIT_VTABLE_(ctx, PutImage, PutImage_pre31); ++ INIT_VTABLE_(ctx, AssociateSubpicture, AssociateSubpicture_pre31); ++ } ++ ++#undef INIT_VTABLE ++#undef INIT_VTABLE__ ++} ++ ++VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx) ++{ ++ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; ++ VADriverContextP ctx = CTX(dpy); ++ VADriverContextP_0_29 ctx_0_29; ++ VADriverContextP_0_30 ctx_0_30; ++ VACompatContextP compat; ++ VAStatus status; ++ char *driver_name; ++ ++ ctx->compat = NULL; ++ ++ if (compat_version == 0) ++ return VA_STATUS_SUCCESS; ++ ++ ASSERT(compat_ctx); ++ if (compat_ctx == NULL) ++ return VA_STATUS_ERROR_UNKNOWN; ++ ++ driver_name = NULL; ++ status = pDisplayContext->vaGetDriverName(pDisplayContext, &driver_name); ++ ASSERT(status == VA_STATUS_SUCCESS); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if ((compat = malloc(sizeof(*compat))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ compat->buffers = NULL; ++ compat->buffers_count_max = 0; ++ compat->compat_version = compat_version; ++ compat->compat_ctx = NULL; ++ compat->driver_name = driver_name; ++ compat->context_map = NULL; ++ compat->last_context_map_match = NULL; ++ ctx->compat = compat; ++ ++ if (strcmp(driver_name, "psb") == 0) ++ compat->driver_id = VA_DRIVER_ID_POULSBO; ++ else if (strcmp(driver_name, "iegd") == 0) ++ compat->driver_id = VA_DRIVER_ID_IEGD; ++ else ++ compat->driver_id = VA_DRIVER_ID_UNKNOWN; ++ ++ switch (compat_version) { ++ case 29: ++ if ((ctx_0_29 = malloc(sizeof(*ctx_0_29))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ memcpy(ctx_0_29, compat_ctx, sizeof(*ctx_0_29)); ++ va_compat_translate_VADriverContext_0_29(compat, ctx_0_29); ++ compat->compat_ctx = ctx_0_29; ++ COPY_FIELD(ctx, ctx_0_29, version_major); ++ COPY_FIELD(ctx, ctx_0_29, version_minor); ++ COPY_FIELD(ctx, ctx_0_29, max_profiles); ++ COPY_FIELD(ctx, ctx_0_29, max_entrypoints); ++ COPY_FIELD(ctx, ctx_0_29, max_attributes); ++ COPY_FIELD(ctx, ctx_0_29, max_image_formats); ++ COPY_FIELD(ctx, ctx_0_29, max_subpic_formats); ++ COPY_FIELD(ctx, ctx_0_29, max_display_attributes); ++ COPY_FIELD(ctx, ctx_0_29, str_vendor); ++ break; ++ case 30: ++ if ((ctx_0_30 = malloc(sizeof(*ctx_0_30))) == NULL) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ memcpy(ctx_0_30, compat_ctx, sizeof(*ctx_0_30)); ++ va_compat_translate_VADriverContext_0_30(compat, ctx_0_30); ++ compat->compat_ctx = ctx_0_30; ++ COPY_FIELD(ctx, ctx_0_30, version_major); ++ COPY_FIELD(ctx, ctx_0_30, version_minor); ++ COPY_FIELD(ctx, ctx_0_30, max_profiles); ++ COPY_FIELD(ctx, ctx_0_30, max_entrypoints); ++ COPY_FIELD(ctx, ctx_0_30, max_attributes); ++ COPY_FIELD(ctx, ctx_0_30, max_image_formats); ++ COPY_FIELD(ctx, ctx_0_30, max_subpic_formats); ++ COPY_FIELD(ctx, ctx_0_30, max_display_attributes); ++ COPY_FIELD(ctx, ctx_0_30, str_vendor); ++ break; ++ case VA_MINOR_VERSION: ++ va_compat_translate_VADriverContext(compat, compat_ctx); ++ compat->compat_ctx = compat_ctx; ++ break; ++ default: ++ ASSERT(compat_version == 0); ++ return VA_STATUS_ERROR_UNKNOWN; ++ } ++ ++ va_compat_init_VADriverVTable(ctx, compat_version); ++ return VA_STATUS_SUCCESS; ++} ++ ++VAStatus va_compat_fini(VADisplay dpy) ++{ ++ VADriverContextP ctx = CTX(dpy); ++ VACompatContextP compat = ctx->compat; ++ int i; ++ ++ if (compat == NULL) ++ return VA_STATUS_SUCCESS; ++ ++ if (compat->driver_name) ++ { ++ free(compat->driver_name); ++ compat->driver_name = NULL; ++ } ++ ++ if (compat->buffers) ++ { ++ for (i = 0; i < compat->buffers_count_max; i++) ++ { ++ if (compat->buffers[i].id) ++ va_DestroyBufferCompat(ctx, compat->buffers[i].id); ++ } ++ free(compat->buffers); ++ compat->buffers = NULL; ++ } ++ ++ if (compat->compat_ctx && compat->compat_version != VA_MINOR_VERSION) ++ { ++ free(compat->compat_ctx); ++ compat->compat_ctx = NULL; ++ } ++ ++ if (compat->context_map) ++ { ++ VAContextMapP d, m = compat->context_map; ++ while (m) { ++ d = m; ++ m = m->next; ++ free(d); ++ } ++ } ++ compat->last_context_map_match = NULL; ++ ++ free(compat); ++ ctx->compat = NULL; ++ return VA_STATUS_SUCCESS; ++} +diff --git a/va/va_compat.h b/va/va_compat.h +new file mode 100644 +index 0000000..2c9d801 +--- /dev/null ++++ b/va/va_compat.h +@@ -0,0 +1,1467 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_COMPAT_H ++#define VA_COMPAT_H ++ ++VAStatus va_compat_init(VADisplay dpy, int compat_version, void *compat_ctx); ++VAStatus va_compat_fini(VADisplay dpy); ++ ++/* H.264 Picture (0.29) */ ++typedef struct _VAPictureH264_0_29 ++{ ++ VASurfaceID picture_id; ++ unsigned int flags; ++ unsigned int TopFieldOrderCnt; ++ unsigned int BottomFieldOrderCnt; ++} VAPictureH264_0_29; ++ ++/* H.264 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferH264_0_29 ++{ ++ VAPictureH264_0_29 CurrPic; ++ VAPictureH264_0_29 ReferenceFrames[16]; /* in DPB */ ++ unsigned short picture_width_in_mbs_minus1; ++ unsigned short picture_height_in_mbs_minus1; ++ unsigned char bit_depth_luma_minus8; ++ unsigned char bit_depth_chroma_minus8; ++ unsigned char num_ref_frames; ++ union { ++ struct { ++ unsigned char chroma_format_idc : 2; ++ 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; ++ }; ++ unsigned char num_slice_groups_minus1; ++ unsigned char slice_group_map_type; ++ signed char pic_init_qp_minus26; ++ signed char chroma_qp_index_offset; ++ signed char second_chroma_qp_index_offset; ++ union { ++ struct { ++ unsigned char entropy_coding_mode_flag : 1; ++ 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 constrained_intra_pred_flag : 1; ++ }; ++ unsigned char pic_fields; ++ }; ++ unsigned short frame_num; ++} VAPictureParameterBufferH264_0_29; ++ ++/* H.264 Slice Parameter Buffer (0.29) */ ++typedef struct _VASliceParameterBufferH264_0_29 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ ++ unsigned short first_mb_in_slice; ++ unsigned char slice_type; ++ unsigned char direct_spatial_mv_pred_flag; ++ unsigned char num_ref_idx_l0_active_minus1; ++ unsigned char num_ref_idx_l1_active_minus1; ++ unsigned char cabac_init_idc; ++ char slice_qp_delta; ++ unsigned char disable_deblocking_filter_idc; ++ char slice_alpha_c0_offset_div2; ++ char slice_beta_offset_div2; ++ VAPictureH264_0_29 RefPicList0[32]; /* See 8.2.4.2 */ ++ VAPictureH264_0_29 RefPicList1[32]; /* See 8.2.4.2 */ ++ unsigned char luma_log2_weight_denom; ++ unsigned char chroma_log2_weight_denom; ++ unsigned char luma_weight_l0_flag; ++ short luma_weight_l0[32]; ++ short luma_offset_l0[32]; ++ unsigned char chroma_weight_l0_flag; ++ short chroma_weight_l0[32][2]; ++ short chroma_offset_l0[32][2]; ++ unsigned char luma_weight_l1_flag; ++ short luma_weight_l1[32]; ++ short luma_offset_l1[32]; ++ unsigned char chroma_weight_l1_flag; ++ short chroma_weight_l1[32][2]; ++ short chroma_offset_l1[32][2]; ++} VASliceParameterBufferH264_0_29; ++ ++/* VC-1 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferVC1_0_29 ++{ ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* if out-of-loop post-processing is done on the render ++ target, then we need to keep the in-loop decoded ++ picture as a reference picture */ ++ VASurfaceID inloop_decoded_picture; ++ ++ /* sequence layer for AP or meta data for SP and MP */ ++ union { ++ struct { ++ unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ ++ unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ ++ unsigned char overlap : 1;/* METADATA::OVERLAP */ ++ }; ++ unsigned char sequence_fields; ++ }; ++ ++ unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ ++ unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ ++ unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ ++ unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ ++ unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ ++ unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ ++ 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 b_picture_fraction; /* PICTURE_LAYER::BFRACTION */ ++ unsigned char cbp_table; /* PICTURE_LAYER::CBPTAB/ICBPTAB */ ++ unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ ++ unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ ++ unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ ++ unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ ++ unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ ++ unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ ++ 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; ++ }; ++ union { ++ struct { ++ unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char field_tx : 1; /* PICTURE::FIELDTX */ ++ 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; ++ }; ++ union { ++ struct { ++ unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ ++ 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 */ ++ }; ++ 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; ++ }; ++ 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 two_mv_block_pattern_table: 2; /* PICTURE_LAYER::2MVBPTAB */ ++ 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; ++ }; ++ union { ++ struct { ++ unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */ ++ unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ ++ unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ ++ unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ ++ unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ ++ unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ ++ unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ ++ unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ ++ 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; ++ }; ++ union { ++ struct { ++ unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ ++ unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ ++ unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ ++ 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; ++ }; ++} VAPictureParameterBufferVC1_0_29; ++ ++/* MPEG-2 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferMPEG2_0_29 ++{ ++ unsigned short horizontal_size; ++ unsigned short vertical_size; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* meanings of the following fields are the same as in the standard */ ++ int picture_coding_type; ++ 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 ++ * is the first field for field picture ++ */ ++ }; ++ unsigned int picture_coding_extension; ++ }; ++} VAPictureParameterBufferMPEG2_0_29; ++ ++/* MPEG-2 Slice Parameter Buffer (0.29) */ ++typedef struct _VASliceParameterBufferMPEG2_0_29 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the first byte of slice data */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ ++ unsigned int slice_vertical_position; ++ int quantiser_scale_code; ++ int intra_slice_flag; ++} VASliceParameterBufferMPEG2_0_29; ++ ++/* MPEG-4 Picture Parameter Buffer (0.29) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_29 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned char short_video_header : 1; ++ unsigned char chroma_format : 2; ++ unsigned char interlaced : 1; ++ unsigned char obmc_disable : 1; ++ unsigned char sprite_enable : 2; ++ unsigned char sprite_warping_accuracy : 2; ++ unsigned char quant_type : 1; ++ unsigned char quarter_sample : 1; ++ unsigned char data_partitioned : 1; ++ unsigned char reversible_vlc : 1; ++ }; ++ unsigned short vol_fields; ++ }; ++ unsigned char no_of_sprite_warping_points; ++ short sprite_trajectory_du[3]; ++ short sprite_trajectory_dv[3]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned char vop_coding_type : 2; ++ unsigned char backward_reference_vop_coding_type : 2; ++ unsigned char vop_rounding_type : 1; ++ unsigned char intra_dc_vlc_thr : 3; ++ unsigned char top_field_first : 1; ++ unsigned char alternate_vertical_scan_flag : 1; ++ }; ++ unsigned short vop_fields; ++ }; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_29; ++ ++/* H.264 Picture (0.30) */ ++typedef struct _VAPictureH264_0_30 ++{ ++ VASurfaceID picture_id; ++ unsigned int flags; ++ unsigned int TopFieldOrderCnt; ++ unsigned int BottomFieldOrderCnt; ++} VAPictureH264_0_30; ++ ++/* H.264 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferH264_0_30 ++{ ++ VAPictureH264 CurrPic; ++ VAPictureH264 ReferenceFrames[16]; /* in DPB */ ++ unsigned short picture_width_in_mbs_minus1; ++ unsigned short picture_height_in_mbs_minus1; ++ unsigned char bit_depth_luma_minus8; ++ unsigned char bit_depth_chroma_minus8; ++ unsigned char num_ref_frames; ++ union { ++ struct { ++ unsigned char chroma_format_idc : 2; ++ 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 */ ++ } bits; ++ unsigned char value; ++ } seq_fields; ++ unsigned char num_slice_groups_minus1; ++ unsigned char slice_group_map_type; ++ signed char pic_init_qp_minus26; ++ signed char chroma_qp_index_offset; ++ signed char second_chroma_qp_index_offset; ++ union { ++ struct { ++ unsigned char entropy_coding_mode_flag : 1; ++ 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 constrained_intra_pred_flag : 1; ++ } bits; ++ unsigned char value; ++ } pic_fields; ++ unsigned short frame_num; ++} VAPictureParameterBufferH264_0_30; ++ ++/* H.264 Slice Parameter Buffer (0.30) */ ++typedef struct _VASliceParameterBufferH264_0_30 ++{ ++ unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */ ++ unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */ ++ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ ++ unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */ ++ unsigned short first_mb_in_slice; ++ unsigned char slice_type; ++ unsigned char direct_spatial_mv_pred_flag; ++ unsigned char num_ref_idx_l0_active_minus1; ++ unsigned char num_ref_idx_l1_active_minus1; ++ unsigned char cabac_init_idc; ++ char slice_qp_delta; ++ unsigned char disable_deblocking_filter_idc; ++ char slice_alpha_c0_offset_div2; ++ char slice_beta_offset_div2; ++ VAPictureH264 RefPicList0[32]; /* See 8.2.4.2 */ ++ VAPictureH264 RefPicList1[32]; /* See 8.2.4.2 */ ++ unsigned char luma_log2_weight_denom; ++ unsigned char chroma_log2_weight_denom; ++ unsigned char luma_weight_l0_flag; ++ short luma_weight_l0[32]; ++ short luma_offset_l0[32]; ++ unsigned char chroma_weight_l0_flag; ++ short chroma_weight_l0[32][2]; ++ short chroma_offset_l0[32][2]; ++ unsigned char luma_weight_l1_flag; ++ short luma_weight_l1[32]; ++ short luma_offset_l1[32]; ++ unsigned char chroma_weight_l1_flag; ++ short chroma_weight_l1[32][2]; ++ short chroma_offset_l1[32][2]; ++} VASliceParameterBufferH264_0_30; ++ ++/* VC-1 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferVC1_0_30 ++{ ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* if out-of-loop post-processing is done on the render ++ target, then we need to keep the in-loop decoded ++ picture as a reference picture */ ++ VASurfaceID inloop_decoded_picture; ++ ++ /* sequence layer for AP or meta data for SP and MP */ ++ union { ++ struct { ++ unsigned char interlace : 1; /* SEQUENCE_LAYER::INTERLACE */ ++ unsigned char syncmarker : 1;/* METADATA::SYNCMARKER */ ++ unsigned char overlap : 1;/* METADATA::OVERLAP */ ++ } bits; ++ unsigned char value; ++ } sequence_fields; ++ ++ unsigned short coded_width; /* ENTRY_POINT_LAYER::CODED_WIDTH */ ++ unsigned short coded_height; /* ENTRY_POINT_LAYER::CODED_HEIGHT */ ++ unsigned char closed_entry; /* ENTRY_POINT_LAYER::CLOSED_ENTRY */ ++ unsigned char broken_link; /* ENTRY_POINT_LAYER::BROKEN_LINK */ ++ unsigned char loopfilter; /* ENTRY_POINT_LAYER::LOOPFILTER */ ++ unsigned char conditional_overlap_flag; /* ENTRY_POINT_LAYER::CONDOVER */ ++ unsigned char fast_uvmc_flag; /* ENTRY_POINT_LAYER::FASTUVMC */ ++ union { ++ struct { ++ 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 */ ++ unsigned char mb_mode_table; /* PICTURE_LAYER::MBMODETAB */ ++ unsigned char range_reduction_frame;/* PICTURE_LAYER::RANGEREDFRM */ ++ unsigned char rounding_control; /* PICTURE_LAYER::RNDCTRL */ ++ unsigned char post_processing; /* PICTURE_LAYER::POSTPROC */ ++ unsigned char picture_resolution_index; /* PICTURE_LAYER::RESPIC */ ++ unsigned char luma_scale; /* PICTURE_LAYER::LUMSCALE */ ++ 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 */ ++ } bits; ++ unsigned char value; ++ } picture_fields; ++ union { ++ struct { ++ unsigned char mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char overflags : 1; /* PICTURE::OVERFLAGS */ ++ } flags; ++ unsigned char value; ++ } raw_coding; ++ union { ++ struct { ++ unsigned char bp_mv_type_mb : 1; /* PICTURE::MVTYPEMB */ ++ unsigned char bp_direct_mb : 1; /* PICTURE::DIRECTMB */ ++ unsigned char bp_skip_mb : 1; /* PICTURE::SKIPMB */ ++ unsigned char bp_field_tx : 1; /* PICTURE::FIELDTX */ ++ unsigned char bp_forward_mb : 1; /* PICTURE::FORWARDMB */ ++ unsigned char bp_ac_pred : 1; /* PICTURE::ACPRED */ ++ unsigned char bp_overflags : 1; /* PICTURE::OVERFLAGS */ ++ } 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 */ ++ } bits; ++ unsigned short value; ++ } reference_fields; ++ union { ++ struct { ++ 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_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_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 */ ++ unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */ ++ unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */ ++ unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */ ++ unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */ ++ unsigned char dq_frame : 1; /* VOPDQUANT::DQUANTFRM */ ++ unsigned char dq_profile : 2; /* VOPDQUANT::DQPROFILE */ ++ unsigned char dq_sb_edge : 2; /* VOPDQUANT::DQSBEDGE */ ++ unsigned char dq_db_edge : 2; /* VOPDQUANT::DQDBEDGE */ ++ unsigned char dq_binary_level : 1; /* VOPDQUANT::DQBILEVEL */ ++ unsigned char alt_pic_quantizer : 5;/* VOPDQUANT::ALTPQUANT */ ++ } bits; ++ unsigned long value; ++ } pic_quantizer_fields; ++ union { ++ struct { ++ unsigned char variable_sized_transform_flag : 1;/* ENTRY_POINT_LAYER::VSTRANSFORM */ ++ unsigned char mb_level_transform_type_flag : 1;/* PICTURE_LAYER::TTMBF */ ++ unsigned char frame_level_transform_type : 2;/* PICTURE_LAYER::TTFRM */ ++ 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 */ ++ } bits; ++ unsigned short value; ++ } transform_fields; ++} VAPictureParameterBufferVC1_0_30; ++ ++/* MPEG-2 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferMPEG2_0_30 ++{ ++ unsigned short horizontal_size; ++ unsigned short vertical_size; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ /* meanings of the following fields are the same as in the standard */ ++ int picture_coding_type; ++ int f_code; /* pack all four fcode into this */ ++ union { ++ struct { ++ 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 ++ */ ++ } bits; ++ unsigned int value; ++ } picture_coding_extension; ++} VAPictureParameterBufferMPEG2_0_30; ++ ++/* MPEG-2 Slice Parameter Buffer (0.29) */ ++typedef VASliceParameterBufferMPEG2_0_29 VASliceParameterBufferMPEG2_0_30; ++ ++/* MPEG-4 Picture Parameter Buffer (0.30) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_30 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned char short_video_header : 1; ++ unsigned char chroma_format : 2; ++ unsigned char interlaced : 1; ++ unsigned char obmc_disable : 1; ++ unsigned char sprite_enable : 2; ++ unsigned char sprite_warping_accuracy : 2; ++ unsigned char quant_type : 1; ++ unsigned char quarter_sample : 1; ++ unsigned char data_partitioned : 1; ++ 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]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned char vop_coding_type : 2; ++ unsigned char backward_reference_vop_coding_type : 2; ++ unsigned char vop_rounding_type : 1; ++ unsigned char intra_dc_vlc_thr : 3; ++ unsigned char top_field_first : 1; ++ unsigned char alternate_vertical_scan_flag : 1; ++ } bits; ++ unsigned short value; ++ } vop_fields; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_30; ++ ++/* Encode Slice Parameter Buffer (0.30) */ ++typedef struct _VAEncSliceParameterBuffer_0_30 ++{ ++ 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_0_30; ++ ++/* MPEG-4 Picture Parameter Buffer (0.31) */ ++typedef struct _VAPictureParameterBufferMPEG4_0_31 ++{ ++ unsigned short vop_width; ++ unsigned short vop_height; ++ VASurfaceID forward_reference_picture; ++ VASurfaceID backward_reference_picture; ++ union { ++ struct { ++ unsigned int short_video_header : 1; ++ unsigned int chroma_format : 2; ++ unsigned int interlaced : 1; ++ unsigned int obmc_disable : 1; ++ unsigned int sprite_enable : 2; ++ unsigned int sprite_warping_accuracy : 2; ++ unsigned int quant_type : 1; ++ unsigned int quarter_sample : 1; ++ unsigned int data_partitioned : 1; ++ unsigned int reversible_vlc : 1; ++ } bits; ++ unsigned int value; ++ } vol_fields; ++ unsigned char no_of_sprite_warping_points; ++ short sprite_trajectory_du[3]; ++ short sprite_trajectory_dv[3]; ++ unsigned char quant_precision; ++ union { ++ struct { ++ unsigned int vop_coding_type : 2; ++ unsigned int backward_reference_vop_coding_type : 2; ++ unsigned int vop_rounding_type : 1; ++ unsigned int intra_dc_vlc_thr : 3; ++ unsigned int top_field_first : 1; ++ unsigned int alternate_vertical_scan_flag : 1; ++ } bits; ++ unsigned int value; ++ } vop_fields; ++ unsigned char vop_fcode_forward; ++ unsigned char vop_fcode_backward; ++ /* short header related */ ++ unsigned char num_gobs_in_vop; ++ unsigned char num_macroblocks_in_gob; ++ /* for direct mode prediction */ ++ short TRB; ++ short TRD; ++} VAPictureParameterBufferMPEG4_0_31; ++ ++typedef struct VADriverContext_0_29 *VADriverContextP_0_29; ++ ++/* Driver VTable (0.29) */ ++struct VADriverVTable_0_29 ++{ ++ VAStatus (*vaTerminate) ( VADriverContextP_0_29 ctx ); ++ ++ VAStatus (*vaQueryConfigProfiles) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile *profile_list, /* out */ ++ int *num_profiles /* out */ ++ ); ++ ++ VAStatus (*vaQueryConfigEntrypoints) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint *entrypoint_list, /* out */ ++ int *num_entrypoints /* out */ ++ ); ++ ++ VAStatus (*vaGetConfigAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, /* in/out */ ++ int num_attribs ++ ); ++ ++ VAStatus (*vaCreateConfig) ( ++ VADriverContextP_0_29 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, ++ int num_attribs, ++ VAConfigID *config_id /* out */ ++ ); ++ ++ VAStatus (*vaDestroyConfig) ( ++ VADriverContextP_0_29 ctx, ++ VAConfigID config_id ++ ); ++ ++ VAStatus (*vaQueryConfigAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VAConfigID config_id, ++ VAProfile *profile, /* out */ ++ VAEntrypoint *entrypoint, /* out */ ++ VAConfigAttrib *attrib_list, /* out */ ++ int *num_attribs /* out */ ++ ); ++ ++ VAStatus (*vaCreateSurfaces) ( ++ VADriverContextP_0_29 ctx, ++ int width, ++ int height, ++ int format, ++ int num_surfaces, ++ VASurfaceID *surfaces /* out */ ++ ); ++ ++ VAStatus (*vaDestroySurfaces) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID *surface_list, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaCreateContext) ( ++ VADriverContextP_0_29 ctx, ++ VAConfigID config_id, ++ int picture_width, ++ int picture_height, ++ int flag, ++ VASurfaceID *render_targets, ++ int num_render_targets, ++ VAContextID *context /* out */ ++ ); ++ ++ VAStatus (*vaDestroyContext) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaCreateBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, /* in */ ++ VABufferType type, /* in */ ++ unsigned int size, /* in */ ++ unsigned int num_elements, /* in */ ++ void *data, /* in */ ++ VABufferID *buf_id /* out */ ++ ); ++ ++ VAStatus (*vaBufferSetNumElements) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++ ); ++ ++ VAStatus (*vaMapBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++ ); ++ ++ VAStatus (*vaUnmapBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buf_id /* in */ ++ ); ++ ++ VAStatus (*vaDestroyBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VABufferID buffer_id ++ ); ++ ++ VAStatus (*vaBeginPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaRenderPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++ ); ++ ++ VAStatus (*vaEndPicture) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaSyncSurface) ( ++ VADriverContextP_0_29 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaQuerySurfaceStatus) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID render_target, ++ VASurfaceStatus *status /* out */ ++ ); ++ ++ VAStatus (*vaPutSurface) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ unsigned long draw, /* X Drawable */ ++ short srcx, ++ short srcy, ++ unsigned short srcw, ++ unsigned short srch, ++ short destx, ++ short desty, ++ unsigned short destw, ++ unsigned short desth, ++ VARectangle *cliprects, /* client supplied clip list */ ++ unsigned int number_cliprects, /* number of clip rects in the clip list */ ++ unsigned int flags /* de-interlacing flags */ ++ ); ++ ++ VAStatus (*vaQueryImageFormats) ( ++ VADriverContextP_0_29 ctx, ++ VAImageFormat *format_list, /* out */ ++ int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateImage) ( ++ VADriverContextP_0_29 ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDeriveImage) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDestroyImage) ( ++ VADriverContextP_0_29 ctx, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetImagePalette) ( ++ VADriverContextP_0_29 ctx, ++ VAImageID image, ++ /* ++ * 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 VAImage struct ++ */ ++ unsigned char *palette ++ ); ++ ++ VAStatus (*vaGetImage) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ int x, /* coordinates of the upper left source pixel */ ++ int y, ++ unsigned int width, /* width and height of the region */ ++ unsigned int height, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaPutImage) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++ ); ++ ++ VAStatus (*vaPutImage2) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int src_width, ++ unsigned int src_height, ++ int dest_x, ++ int dest_y, ++ unsigned int dest_width, ++ unsigned int dest_height ++ ); ++ ++ VAStatus (*vaQuerySubpictureFormats) ( ++ VADriverContextP_0_29 ctx, ++ VAImageFormat *format_list, /* out */ ++ unsigned int *flags, /* out */ ++ unsigned int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateSubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VAImageID image, ++ VASubpictureID *subpicture /* out */ ++ ); ++ ++ VAStatus (*vaDestroySubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture ++ ); ++ ++ VAStatus (*vaSetSubpictureImage) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetSubpicturePalette) ( ++ VADriverContextP_0_29 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_0_29 ctx, ++ VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask ++ ); ++ ++ VAStatus (*vaSetSubpictureGlobalAlpha) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ float global_alpha ++ ); ++ ++ VAStatus (*vaAssociateSubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaAssociateSubpicture2) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ unsigned short src_width, ++ unsigned short src_height, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short dest_width, ++ unsigned short dest_height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaDeassociateSubpicture) ( ++ VADriverContextP_0_29 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaQueryDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, /* out */ ++ int *num_attributes /* out */ ++ ); ++ ++ VAStatus (*vaGetDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, /* in/out */ ++ int num_attributes ++ ); ++ ++ VAStatus (*vaSetDisplayAttributes) ( ++ VADriverContextP_0_29 ctx, ++ VADisplayAttribute *attr_list, ++ int num_attributes ++ ); ++ ++ ++ VAStatus (*vaDbgCopySurfaceToBuffer) ( ++ VADriverContextP_0_29 ctx, ++ VASurfaceID surface, ++ void **buffer, /* out */ ++ unsigned int *stride /* out */ ++ ); ++}; ++ ++/* Driver context (0.29) */ ++struct VADriverContext_0_29 ++{ ++ void *old_pNext; /* preserved for binary compatibility */ ++ ++ void *pDriverData; ++ struct VADriverVTable_0_29 vtable; ++ ++ void *x11_dpy; ++ int x11_screen; ++ ++ int version_major; ++ int version_minor; ++ int max_profiles; ++ int max_entrypoints; ++ int max_attributes; ++ int max_image_formats; ++ int max_subpic_formats; ++ int max_display_attributes; ++ const char *str_vendor; ++ ++ void *handle; /* dlopen handle */ ++}; ++ ++/* Forward declarations for VA API 0.30 */ ++struct v4l2_format; ++struct v4l2_buffer; ++typedef struct VADriverContext_0_30 *VADriverContextP_0_30; ++ ++/* Driver VTable (0.30) */ ++struct VADriverVTable_0_30 ++{ ++ VAStatus (*vaTerminate) ( VADriverContextP_0_30 ctx ); ++ ++ VAStatus (*vaQueryConfigProfiles) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile *profile_list, /* out */ ++ int *num_profiles /* out */ ++ ); ++ ++ VAStatus (*vaQueryConfigEntrypoints) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint *entrypoint_list, /* out */ ++ int *num_entrypoints /* out */ ++ ); ++ ++ VAStatus (*vaGetConfigAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, /* in/out */ ++ int num_attribs ++ ); ++ ++ VAStatus (*vaCreateConfig) ( ++ VADriverContextP_0_30 ctx, ++ VAProfile profile, ++ VAEntrypoint entrypoint, ++ VAConfigAttrib *attrib_list, ++ int num_attribs, ++ VAConfigID *config_id /* out */ ++ ); ++ ++ VAStatus (*vaDestroyConfig) ( ++ VADriverContextP_0_30 ctx, ++ VAConfigID config_id ++ ); ++ ++ VAStatus (*vaQueryConfigAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VAConfigID config_id, ++ VAProfile *profile, /* out */ ++ VAEntrypoint *entrypoint, /* out */ ++ VAConfigAttrib *attrib_list, /* out */ ++ int *num_attribs /* out */ ++ ); ++ ++ VAStatus (*vaCreateSurfaces) ( ++ VADriverContextP_0_30 ctx, ++ int width, ++ int height, ++ int format, ++ int num_surfaces, ++ VASurfaceID *surfaces /* out */ ++ ); ++ ++ VAStatus (*vaDestroySurfaces) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID *surface_list, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaCreateContext) ( ++ VADriverContextP_0_30 ctx, ++ VAConfigID config_id, ++ int picture_width, ++ int picture_height, ++ int flag, ++ VASurfaceID *render_targets, ++ int num_render_targets, ++ VAContextID *context /* out */ ++ ); ++ ++ VAStatus (*vaDestroyContext) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaCreateBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, /* in */ ++ VABufferType type, /* in */ ++ unsigned int size, /* in */ ++ unsigned int num_elements, /* in */ ++ void *data, /* in */ ++ VABufferID *buf_id /* out */ ++ ); ++ ++ VAStatus (*vaBufferSetNumElements) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buf_id, /* in */ ++ unsigned int num_elements /* in */ ++ ); ++ ++ VAStatus (*vaMapBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buf_id, /* in */ ++ void **pbuf /* out */ ++ ); ++ ++ VAStatus (*vaUnmapBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buf_id /* in */ ++ ); ++ ++ VAStatus (*vaDestroyBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VABufferID buffer_id ++ ); ++ ++ VAStatus (*vaBeginPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaRenderPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VABufferID *buffers, ++ int num_buffers ++ ); ++ ++ VAStatus (*vaEndPicture) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context ++ ); ++ ++ VAStatus (*vaSyncSurface) ( ++ VADriverContextP_0_30 ctx, ++ VAContextID context, ++ VASurfaceID render_target ++ ); ++ ++ VAStatus (*vaQuerySurfaceStatus) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID render_target, ++ VASurfaceStatus *status /* out */ ++ ); ++ ++ VAStatus (*vaPutSurface) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ unsigned long draw, /* X Drawable */ ++ short srcx, ++ short srcy, ++ unsigned short srcw, ++ unsigned short srch, ++ short destx, ++ short desty, ++ unsigned short destw, ++ unsigned short desth, ++ VARectangle *cliprects, /* client supplied clip list */ ++ unsigned int number_cliprects, /* number of clip rects in the clip list */ ++ unsigned int flags /* de-interlacing flags */ ++ ); ++ ++ VAStatus (*vaQueryImageFormats) ( ++ VADriverContextP_0_30 ctx, ++ VAImageFormat *format_list, /* out */ ++ int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateImage) ( ++ VADriverContextP_0_30 ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDeriveImage) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ VAImage *image /* out */ ++ ); ++ ++ VAStatus (*vaDestroyImage) ( ++ VADriverContextP_0_30 ctx, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetImagePalette) ( ++ VADriverContextP_0_30 ctx, ++ VAImageID image, ++ /* ++ * 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 VAImage struct ++ */ ++ unsigned char *palette ++ ); ++ ++ VAStatus (*vaGetImage) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ int x, /* coordinates of the upper left source pixel */ ++ int y, ++ unsigned int width, /* width and height of the region */ ++ unsigned int height, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaPutImage) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++ ); ++ ++ VAStatus (*vaPutImage2) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int src_width, ++ unsigned int src_height, ++ int dest_x, ++ int dest_y, ++ unsigned int dest_width, ++ unsigned int dest_height ++ ); ++ ++ VAStatus (*vaQuerySubpictureFormats) ( ++ VADriverContextP_0_30 ctx, ++ VAImageFormat *format_list, /* out */ ++ unsigned int *flags, /* out */ ++ unsigned int *num_formats /* out */ ++ ); ++ ++ VAStatus (*vaCreateSubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VAImageID image, ++ VASubpictureID *subpicture /* out */ ++ ); ++ ++ VAStatus (*vaDestroySubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture ++ ); ++ ++ VAStatus (*vaSetSubpictureImage) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VAImageID image ++ ); ++ ++ VAStatus (*vaSetSubpictureChromakey) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ unsigned int chromakey_min, ++ unsigned int chromakey_max, ++ unsigned int chromakey_mask ++ ); ++ ++ VAStatus (*vaSetSubpictureGlobalAlpha) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ float global_alpha ++ ); ++ ++ VAStatus (*vaAssociateSubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaAssociateSubpicture2) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, /* upper left offset in subpicture */ ++ short src_y, ++ unsigned short src_width, ++ unsigned short src_height, ++ short dest_x, /* upper left offset in surface */ ++ short dest_y, ++ unsigned short dest_width, ++ unsigned short dest_height, ++ /* ++ * whether to enable chroma-keying or global-alpha ++ * see VA_SUBPICTURE_XXX values ++ */ ++ unsigned int flags ++ ); ++ ++ VAStatus (*vaDeassociateSubpicture) ( ++ VADriverContextP_0_30 ctx, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces ++ ); ++ ++ VAStatus (*vaQueryDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, /* out */ ++ int *num_attributes /* out */ ++ ); ++ ++ VAStatus (*vaGetDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, /* in/out */ ++ int num_attributes ++ ); ++ ++ VAStatus (*vaSetDisplayAttributes) ( ++ VADriverContextP_0_30 ctx, ++ VADisplayAttribute *attr_list, ++ int num_attributes ++ ); ++ ++ /* device specific */ ++ VAStatus (*vaCreateSurfaceFromCIFrame) ( ++ VADriverContextP_0_30 ctx, ++ unsigned long frame_id, ++ VASurfaceID *surface /* out */ ++ ); ++ ++ ++ VAStatus (*vaCreateSurfaceFromV4L2Buf) ( ++ VADriverContextP_0_30 ctx, ++ int v4l2_fd, /* file descriptor of V4L2 device */ ++ struct v4l2_format *v4l2_fmt, /* format of V4L2 */ ++ struct v4l2_buffer *v4l2_buf, /* V4L2 buffer */ ++ VASurfaceID *surface /* out */ ++ ); ++ ++ VAStatus (*vaCopySurfaceToBuffer) ( ++ VADriverContextP_0_30 ctx, ++ VASurfaceID surface, ++ unsigned int *fourcc, /* out for follow argument */ ++ 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, ++ void **buffer ++ ); ++}; ++ ++/* Driver context (0.30) */ ++struct VADriverContext_0_30 ++{ ++ void *pDriverData; ++ struct VADriverVTable_0_30 vtable; ++ ++ void *x11_dpy; ++ int x11_screen; ++ int version_major; ++ int version_minor; ++ int max_profiles; ++ int max_entrypoints; ++ int max_attributes; ++ int max_image_formats; ++ int max_subpic_formats; ++ int max_display_attributes; ++ const char *str_vendor; ++ ++ void *handle; /* dlopen handle */ ++ ++ void *dri_state; ++}; ++ ++/* Driver VTable and context (0.31) */ ++#define VADriverVTable_0_31 VADriverVTable ++#define VADriverContext_0_31 VADriverContext ++ ++#endif /* VA_COMPAT_H */ +diff --git a/va/va_compat_template.h b/va/va_compat_template.h +new file mode 100644 +index 0000000..18349de +--- /dev/null ++++ b/va/va_compat_template.h +@@ -0,0 +1,539 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ */ ++ ++#undef CONCAT_ ++#define CONCAT_(x, y) x##y ++#undef CONCAT ++#define CONCAT(x, y) CONCAT_(x, y) ++#undef MKCOMPAT_ ++#define MKCOMPAT_(NAME,MINOR) CONCAT(CONCAT(NAME,_0_),MINOR) ++#undef MKCOMPAT ++#define MKCOMPAT(NAME) MKCOMPAT_(NAME,COMPAT_MINOR) ++#undef STRUCT ++#define STRUCT(BUFFER, CODEC) MKCOMPAT(VA##BUFFER##Buffer##CODEC) ++#undef TRANSLATE_1 ++#define TRANSLATE_1(NAME) CONCAT(va_compat_translate_,NAME) ++#undef TRANSLATE_ ++#define TRANSLATE_(NAME) TRANSLATE_1(MKCOMPAT(NAME)) ++#undef TRANSLATE ++#define TRANSLATE(BUFFER, CODEC) TRANSLATE_1(STRUCT(BUFFER,CODEC)) ++ ++#undef COPY_ARRAY ++#define COPY_ARRAY(DST, SRC, ARRAY) \ ++ memcpy((DST)->ARRAY, (SRC)->ARRAY, sizeof((DST)->ARRAY)) ++ ++#undef COPY_FIELD ++#define COPY_FIELD(DST, SRC, MEMBER) \ ++ (DST)->MEMBER = (SRC)->MEMBER ++ ++#undef COPY_VTABLE__ ++#define COPY_VTABLE__(DST, DST_MEMBER, SRC, SRC_MEMBER) \ ++ (DST##_vtable)->DST_MEMBER = (SRC##_vtable)->SRC_MEMBER ++ ++#undef COPY_VTABLE_ ++#define COPY_VTABLE_(DST, DST_SUFFIX, SRC, MEMBER) \ ++ COPY_VTABLE__(DST, MEMBER##_##DST_SUFFIX, SRC, MEMBER) ++ ++#undef COPY_VTABLE ++#define COPY_VTABLE(DST, SRC, MEMBER) \ ++ COPY_VTABLE__(DST, MEMBER, SRC, MEMBER) ++ ++/* 0.29 */ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 ++#undef BFV ++#define BFV(a, b) a ++#undef BFM ++#define BFM(a, b, c) c ++#undef COPY_BIT_FIELD ++#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ ++ (DST)->MEMBER = (SRC)->FIELD.bits.MEMBER ++#undef COPY_BIT_FLAG ++#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ ++ (DST)->MEMBER = (SRC)->FIELD.flags.MEMBER ++#endif ++ ++/* 0.29 glue to match 0.30 names */ ++#undef M_raw_coding ++#undef M_bitplane_present ++#undef M_luma_flag ++#undef M_luma ++#undef M_chroma_flag ++#undef M_chroma ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 29 ++#define M_raw_coding raw_coding_flag ++#define M_bitplane_present bitplane_present_flag ++#define M_luma_flag range_mapping_luma_flag ++#define M_luma range_mapping_luma ++#define M_chroma_flag range_mapping_chroma_flag ++#define M_chroma range_mapping_chroma ++#else ++#define M_raw_coding raw_coding ++#define M_bitplane_present bitplane_present ++#define M_luma_flag luma_flag ++#define M_luma luma ++#define M_chroma_flag chroma_flag ++#define M_chroma chroma ++#endif ++ ++/* 0.30 */ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++#undef BFV ++#define BFV(a, b) a.b ++#undef BFM ++#define BFM(a, b, c) a.b.c ++#undef COPY_BIT_FIELD ++#define COPY_BIT_FIELD(DST, SRC, FIELD, MEMBER) \ ++ (DST)->FIELD.bits.MEMBER = (SRC)->FIELD.bits.MEMBER ++#undef COPY_BIT_FLAG ++#define COPY_BIT_FLAG(DST, SRC, FIELD, MEMBER) \ ++ (DST)->FIELD.flags.MEMBER = (SRC)->FIELD.flags.MEMBER ++#endif ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR < 31 ++static VAStatus TRANSLATE_(VAPictureH264)( ++ VACompatContextP ctx, ++ void *dest_pic, ++ const void *src_pic ++) ++{ ++ MKCOMPAT(VAPictureH264) *dest = dest_pic; ++ const VAPictureH264 *src = src_pic; ++ ++ COPY_FIELD(dest, src, picture_id); ++ COPY_FIELD(dest, src, flags); ++ COPY_FIELD(dest, src, TopFieldOrderCnt); ++ COPY_FIELD(dest, src, BottomFieldOrderCnt); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,H264)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,H264) *dest = dest_buffer; ++ const VAPictureParameterBufferH264 *src = src_buffer; ++ VAStatus status; ++ int i; ++ ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->CurrPic, &src->CurrPic); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ for (i = 0; i < 16; i++) { ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->ReferenceFrames[i], ++ &src->ReferenceFrames[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ ++ COPY_FIELD(dest, src, picture_width_in_mbs_minus1); ++ COPY_FIELD(dest, src, picture_height_in_mbs_minus1); ++ COPY_FIELD(dest, src, bit_depth_luma_minus8); ++ COPY_FIELD(dest, src, bit_depth_chroma_minus8); ++ COPY_FIELD(dest, src, num_ref_frames); ++ dest->BFV(seq_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, seq_fields, chroma_format_idc); ++ COPY_BIT_FIELD(dest, src, seq_fields, residual_colour_transform_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, frame_mbs_only_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, mb_adaptive_frame_field_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, direct_8x8_inference_flag); ++ COPY_BIT_FIELD(dest, src, seq_fields, MinLumaBiPredSize8x8); ++ COPY_FIELD(dest, src, num_slice_groups_minus1); ++ COPY_FIELD(dest, src, slice_group_map_type); ++ COPY_FIELD(dest, src, pic_init_qp_minus26); ++ COPY_FIELD(dest, src, chroma_qp_index_offset); ++ COPY_FIELD(dest, src, second_chroma_qp_index_offset); ++ dest->BFV(pic_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, pic_fields, entropy_coding_mode_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, weighted_pred_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, weighted_bipred_idc); ++ COPY_BIT_FIELD(dest, src, pic_fields, transform_8x8_mode_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, field_pic_flag); ++ COPY_BIT_FIELD(dest, src, pic_fields, constrained_intra_pred_flag); ++ COPY_FIELD(dest, src, frame_num); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(SliceParameter,H264)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(SliceParameter,H264) *dest = dest_buffer; ++ const VASliceParameterBufferH264 *src = src_buffer; ++ VAStatus status; ++ int i; ++ ++ COPY_FIELD(dest, src, slice_data_size); ++ COPY_FIELD(dest, src, slice_data_offset); ++ COPY_FIELD(dest, src, slice_data_flag); ++ COPY_FIELD(dest, src, slice_data_bit_offset); ++ COPY_FIELD(dest, src, first_mb_in_slice); ++ COPY_FIELD(dest, src, slice_type); ++ COPY_FIELD(dest, src, direct_spatial_mv_pred_flag); ++ COPY_FIELD(dest, src, num_ref_idx_l0_active_minus1); ++ COPY_FIELD(dest, src, num_ref_idx_l1_active_minus1); ++ COPY_FIELD(dest, src, cabac_init_idc); ++ COPY_FIELD(dest, src, slice_qp_delta); ++ COPY_FIELD(dest, src, disable_deblocking_filter_idc); ++ COPY_FIELD(dest, src, slice_alpha_c0_offset_div2); ++ COPY_FIELD(dest, src, slice_beta_offset_div2); ++ for (i = 0; i < 32; i++) { ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->RefPicList0[i], ++ &src->RefPicList0[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ status = TRANSLATE_(VAPictureH264)(ctx, ++ &dest->RefPicList1[i], ++ &src->RefPicList1[i]); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ } ++ COPY_FIELD(dest, src, luma_log2_weight_denom); ++ COPY_FIELD(dest, src, chroma_log2_weight_denom); ++ COPY_FIELD(dest, src, luma_weight_l0_flag); ++ COPY_ARRAY(dest, src, luma_weight_l0); ++ COPY_ARRAY(dest, src, luma_offset_l0); ++ COPY_FIELD(dest, src, chroma_weight_l0_flag); ++ COPY_ARRAY(dest, src, chroma_weight_l0); ++ COPY_ARRAY(dest, src, chroma_offset_l0); ++ COPY_FIELD(dest, src, luma_weight_l1_flag); ++ COPY_ARRAY(dest, src, luma_weight_l1); ++ COPY_ARRAY(dest, src, luma_offset_l1); ++ COPY_FIELD(dest, src, chroma_weight_l1_flag); ++ COPY_ARRAY(dest, src, chroma_weight_l1); ++ COPY_ARRAY(dest, src, chroma_offset_l1); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,VC1)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,VC1) *dest = dest_buffer; ++ const VAPictureParameterBufferVC1 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ COPY_FIELD(dest, src, inloop_decoded_picture); ++ dest->BFV(sequence_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, sequence_fields, interlace); ++ COPY_BIT_FIELD(dest, src, sequence_fields, syncmarker); ++ COPY_BIT_FIELD(dest, src, sequence_fields, overlap); ++ COPY_FIELD(dest, src, coded_width); ++ COPY_FIELD(dest, src, coded_height); ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++ dest->closed_entry = src->entrypoint_fields.bits.closed_entry; ++ dest->broken_link = src->entrypoint_fields.bits.broken_link; ++ dest->loopfilter = src->entrypoint_fields.bits.loopfilter; ++#else ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, closed_entry); ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, broken_link); ++ COPY_BIT_FIELD(dest, src, entrypoint_fields, loopfilter); ++#endif ++ COPY_FIELD(dest, src, conditional_overlap_flag); ++ COPY_FIELD(dest, src, fast_uvmc_flag); ++ dest->BFV(range_mapping_fields, value) = 0; /* reset all bits */ ++ dest->BFM(range_mapping_fields, bits, M_luma_flag) = ++ src->range_mapping_fields.bits.luma_flag; ++ dest->BFM(range_mapping_fields, bits, M_luma) = ++ src->range_mapping_fields.bits.luma; ++ dest->BFM(range_mapping_fields, bits, M_chroma_flag) = ++ src->range_mapping_fields.bits.chroma_flag; ++ dest->BFM(range_mapping_fields, bits, M_chroma) = ++ src->range_mapping_fields.bits.chroma; ++ COPY_FIELD(dest, src, b_picture_fraction); ++ COPY_FIELD(dest, src, cbp_table); ++ COPY_FIELD(dest, src, mb_mode_table); ++ COPY_FIELD(dest, src, range_reduction_frame); ++ COPY_FIELD(dest, src, rounding_control); ++ COPY_FIELD(dest, src, post_processing); ++ COPY_FIELD(dest, src, picture_resolution_index); ++ COPY_FIELD(dest, src, luma_scale); ++ COPY_FIELD(dest, src, luma_shift); ++ dest->BFV(picture_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, picture_fields, picture_type); ++ COPY_BIT_FIELD(dest, src, picture_fields, frame_coding_mode); ++ COPY_BIT_FIELD(dest, src, picture_fields, top_field_first); ++ COPY_BIT_FIELD(dest, src, picture_fields, is_first_field); ++ COPY_BIT_FIELD(dest, src, picture_fields, intensity_compensation); ++ dest->BFV(M_raw_coding, value) = 0; /* reset all bits */ ++ COPY_BIT_FLAG(dest, src, raw_coding, mv_type_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, direct_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, skip_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, field_tx); ++ COPY_BIT_FLAG(dest, src, raw_coding, forward_mb); ++ COPY_BIT_FLAG(dest, src, raw_coding, ac_pred); ++ COPY_BIT_FLAG(dest, src, raw_coding, overflags); ++ dest->BFV(M_bitplane_present, value) = 0; /* reset all bits */ ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_mv_type_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_direct_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_skip_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_field_tx); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_forward_mb); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_ac_pred); ++ COPY_BIT_FLAG(dest, src, bitplane_present, bp_overflags); ++ dest->BFV(reference_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_distance_flag); ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_distance); ++ COPY_BIT_FIELD(dest, src, reference_fields, num_reference_pictures); ++ COPY_BIT_FIELD(dest, src, reference_fields, reference_field_pic_indicator); ++ dest->BFV(mv_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_mode); ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_mode2); ++ COPY_BIT_FIELD(dest, src, mv_fields, mv_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, two_mv_block_pattern_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, four_mv_switch); ++ COPY_BIT_FIELD(dest, src, mv_fields, four_mv_block_pattern_table); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_flag); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_mv_range); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_flag); ++ COPY_BIT_FIELD(dest, src, mv_fields, extended_dmv_range); ++ dest->BFV(pic_quantizer_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dquant); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, quantizer); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, half_qp); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_scale); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, pic_quantizer_type); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_frame); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_profile); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_sb_edge); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_db_edge); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, dq_binary_level); ++ COPY_BIT_FIELD(dest, src, pic_quantizer_fields, alt_pic_quantizer); ++ dest->BFV(transform_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, transform_fields, variable_sized_transform_flag); ++ COPY_BIT_FIELD(dest, src, transform_fields, mb_level_transform_type_flag); ++ COPY_BIT_FIELD(dest, src, transform_fields, frame_level_transform_type); ++ COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx1); ++ COPY_BIT_FIELD(dest, src, transform_fields, transform_ac_codingset_idx2); ++ COPY_BIT_FIELD(dest, src, transform_fields, intra_transform_dc_table); ++ ++ if (src->picture_fields.bits.picture_type == 4) { ++ dest->BFM(picture_fields, bits, picture_type) = 1; /* P-frame */ ++ ctx->skip_frame = 1; ++ } ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(PictureParameter,MPEG2)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,MPEG2) *dest = dest_buffer; ++ const VAPictureParameterBufferMPEG2 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, horizontal_size); ++ COPY_FIELD(dest, src, vertical_size); ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ COPY_FIELD(dest, src, picture_coding_type); ++ COPY_FIELD(dest, src, f_code); ++ dest->BFV(picture_coding_extension, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_dc_precision); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, picture_structure); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, top_field_first); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, frame_pred_frame_dct); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, concealment_motion_vectors); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, q_scale_type); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, intra_vlc_format); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, alternate_scan); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, repeat_first_field); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, progressive_frame); ++ COPY_BIT_FIELD(dest, src, picture_coding_extension, is_first_field); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus TRANSLATE(SliceParameter,MPEG2)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(SliceParameter,MPEG2) *dest = dest_buffer; ++ const VASliceParameterBufferMPEG2 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, slice_data_size); ++ COPY_FIELD(dest, src, slice_data_offset); ++ COPY_FIELD(dest, src, slice_data_flag); ++ COPY_FIELD(dest, src, macroblock_offset); ++ COPY_FIELD(dest, src, slice_vertical_position); ++ COPY_FIELD(dest, src, quantiser_scale_code); ++ COPY_FIELD(dest, src, intra_slice_flag); ++ ++ return VA_STATUS_SUCCESS; ++} ++#endif ++ ++static VAStatus TRANSLATE(PictureParameter,MPEG4)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ STRUCT(PictureParameter,MPEG4) *dest = dest_buffer; ++ const VAPictureParameterBufferMPEG4 *src = src_buffer; ++ ++ COPY_FIELD(dest, src, vop_width); ++ COPY_FIELD(dest, src, vop_height); ++ COPY_FIELD(dest, src, forward_reference_picture); ++ COPY_FIELD(dest, src, backward_reference_picture); ++ dest->BFV(vol_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, vol_fields, short_video_header); ++ COPY_BIT_FIELD(dest, src, vol_fields, chroma_format); ++ COPY_BIT_FIELD(dest, src, vol_fields, interlaced); ++ COPY_BIT_FIELD(dest, src, vol_fields, obmc_disable); ++ COPY_BIT_FIELD(dest, src, vol_fields, sprite_enable); ++ COPY_BIT_FIELD(dest, src, vol_fields, sprite_warping_accuracy); ++ COPY_BIT_FIELD(dest, src, vol_fields, quant_type); ++ COPY_BIT_FIELD(dest, src, vol_fields, quarter_sample); ++ COPY_BIT_FIELD(dest, src, vol_fields, data_partitioned); ++ COPY_BIT_FIELD(dest, src, vol_fields, reversible_vlc); ++ COPY_FIELD(dest, src, no_of_sprite_warping_points); ++ COPY_ARRAY(dest, src, sprite_trajectory_du); ++ COPY_ARRAY(dest, src, sprite_trajectory_dv); ++ COPY_FIELD(dest, src, quant_precision); ++ dest->BFV(vop_fields, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, vop_fields, vop_coding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, backward_reference_vop_coding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, vop_rounding_type); ++ COPY_BIT_FIELD(dest, src, vop_fields, intra_dc_vlc_thr); ++ COPY_BIT_FIELD(dest, src, vop_fields, top_field_first); ++ COPY_BIT_FIELD(dest, src, vop_fields, alternate_vertical_scan_flag); ++ COPY_FIELD(dest, src, vop_fcode_forward); ++ COPY_FIELD(dest, src, vop_fcode_backward); ++ COPY_FIELD(dest, src, num_gobs_in_vop); ++ COPY_FIELD(dest, src, num_macroblocks_in_gob); ++ COPY_FIELD(dest, src, TRB); ++ COPY_FIELD(dest, src, TRD); ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR == 30 ++static VAStatus TRANSLATE_(VAEncSliceParameterBuffer)( ++ VACompatContextP ctx, ++ void *dest_buffer, ++ const void *src_buffer ++) ++{ ++ MKCOMPAT(VAEncSliceParameterBuffer) * const dest = dest_buffer; ++ const VAEncSliceParameterBuffer * const src = src_buffer; ++ ++ COPY_FIELD(dest, src, start_row_number); ++ COPY_FIELD(dest, src, slice_height); ++ dest->BFV(slice_flags, value) = 0; /* reset all bits */ ++ COPY_BIT_FIELD(dest, src, slice_flags, is_intra); ++ COPY_BIT_FIELD(dest, src, slice_flags, disable_deblocking_filter_idc); ++ ++ return VA_STATUS_SUCCESS; ++} ++#endif ++ ++static void TRANSLATE_(VADriverContext)( ++ VACompatContext *dest, ++ const struct MKCOMPAT(VADriverContext) *src ++) ++{ ++ VACompatDriverVTable *dest_vtable = &dest->vtable; ++ const struct MKCOMPAT(VADriverVTable) *src_vtable = &src->vtable; ++ ++ memset(dest_vtable, 0, sizeof(*dest_vtable)); ++ COPY_VTABLE(dest, src, vaTerminate); ++ COPY_VTABLE(dest, src, vaQueryConfigProfiles); ++ COPY_VTABLE(dest, src, vaQueryConfigEntrypoints); ++ COPY_VTABLE(dest, src, vaGetConfigAttributes); ++ COPY_VTABLE(dest, src, vaCreateConfig); ++ COPY_VTABLE(dest, src, vaDestroyConfig); ++ COPY_VTABLE(dest, src, vaQueryConfigAttributes); ++ COPY_VTABLE(dest, src, vaCreateSurfaces); ++ COPY_VTABLE(dest, src, vaDestroySurfaces); ++ COPY_VTABLE(dest, src, vaCreateContext); ++ COPY_VTABLE(dest, src, vaDestroyContext); ++ COPY_VTABLE(dest, src, vaCreateBuffer); ++ COPY_VTABLE(dest, src, vaBufferSetNumElements); ++ COPY_VTABLE(dest, src, vaMapBuffer); ++ COPY_VTABLE(dest, src, vaUnmapBuffer); ++ COPY_VTABLE(dest, src, vaDestroyBuffer); ++ COPY_VTABLE(dest, src, vaBeginPicture); ++ COPY_VTABLE(dest, src, vaRenderPicture); ++ COPY_VTABLE(dest, src, vaEndPicture); ++ COPY_VTABLE(dest, src, vaQuerySurfaceStatus); ++ COPY_VTABLE(dest, src, vaPutSurface); ++ COPY_VTABLE(dest, src, vaQueryImageFormats); ++ COPY_VTABLE(dest, src, vaCreateImage); ++ COPY_VTABLE(dest, src, vaDeriveImage); ++ COPY_VTABLE(dest, src, vaDestroyImage); ++ COPY_VTABLE(dest, src, vaSetImagePalette); ++ COPY_VTABLE(dest, src, vaGetImage); ++ COPY_VTABLE(dest, src, vaQuerySubpictureFormats); ++ COPY_VTABLE(dest, src, vaCreateSubpicture); ++ COPY_VTABLE(dest, src, vaDestroySubpicture); ++ COPY_VTABLE(dest, src, vaSetSubpictureImage); ++ COPY_VTABLE(dest, src, vaSetSubpictureChromakey); ++ COPY_VTABLE(dest, src, vaSetSubpictureGlobalAlpha); ++ COPY_VTABLE(dest, src, vaDeassociateSubpicture); ++ COPY_VTABLE(dest, src, vaQueryDisplayAttributes); ++ COPY_VTABLE(dest, src, vaGetDisplayAttributes); ++ COPY_VTABLE(dest, src, vaSetDisplayAttributes); ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR <= 29 ++ COPY_VTABLE(dest, src, vaSetSubpicturePalette); ++ COPY_VTABLE(dest, src, vaDbgCopySurfaceToBuffer); ++#endif ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 30 ++ COPY_VTABLE(dest, src, vaCreateSurfaceFromCIFrame); ++ COPY_VTABLE(dest, src, vaCreateSurfaceFromV4L2Buf); ++ COPY_VTABLE(dest, src, vaCopySurfaceToBuffer); ++#endif ++#if COMPAT_MAJOR == 0 && COMPAT_MINOR >= 31 ++ COPY_VTABLE(dest, src, vaSyncSurface); ++ COPY_VTABLE(dest, src, vaPutImage); ++ COPY_VTABLE(dest, src, vaAssociateSubpicture); ++#else ++ COPY_VTABLE_(dest, pre31, src, vaSyncSurface); ++ COPY_VTABLE_(dest, pre31, src, vaPutImage); ++ COPY_VTABLE_(dest, pre31, src, vaPutImage2); ++ COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture); ++ COPY_VTABLE_(dest, pre31, src, vaAssociateSubpicture2); ++#endif ++} ++ ++#undef COMPAT_MAJOR ++#undef COMPAT_MINOR --- libva-0.31.0+latest2.orig/debian/patches/036_g45_add_vaGetImage.patch +++ libva-0.31.0+latest2/debian/patches/036_g45_add_vaGetImage.patch @@ -0,0 +1,62 @@ +commit c833a4ef4efa20ab8df18d13bdab1e5c5e4671a8 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:16:34 2009 +0000 + + [G45] Implement vaGetImage() for full-sized surface readback. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index ebaf1ae..59ebdd7 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -1392,7 +1392,50 @@ i965_GetImage(VADriverContextP ctx, + unsigned int height, + VAImageID image) + { +- return VA_STATUS_SUCCESS; ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(image); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ /* XXX: we only support full-size surface readback */ ++ if (x != 0 || ++ y != 0 || ++ width != obj_surface->width || ++ height != obj_surface->height) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ /* XXX: we only support 1:1 image copies */ ++ if (width != obj_image->image.width || ++ height != obj_image->image.height) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ VAStatus va_status; ++ void *image_data = NULL; ++ ++ va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); ++ if (va_status != VA_STATUS_SUCCESS) ++ return va_status; ++ ++ dri_bo_map(obj_surface->bo, 0); ++ ++ switch (obj_image->image.format.fourcc) { ++ case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ memcpy(image_data, obj_surface->bo->virtual, obj_surface->bo->size); ++ break; ++ default: ++ va_status = VA_STATUS_ERROR_OPERATION_FAILED; ++ break; ++ } ++ ++ dri_bo_unmap(obj_surface->bo); ++ ++ i965_UnmapBuffer(ctx, obj_image->image.buf); ++ return va_status; + } + + VAStatus --- libva-0.31.0+latest2.orig/debian/patches/322_libva_glx.patch +++ libva-0.31.0+latest2/debian/patches/322_libva_glx.patch @@ -0,0 +1,1625 @@ +commit 37f6246890b10be4ee57916c7a028205637c17d6 +Author: Gwenole Beauchesne +Date: Mon Mar 8 09:44:25 2010 +0100 + + Add OpenGL extensions (v3) and generic implementation with TFP and FBO. + +diff --git a/Makefile.am b/Makefile.am +index 459660b..e75a2db 100644 +diff --git a/configure.ac b/configure.ac +index 95cf992..86366e9 100644 +diff --git a/libva-glx.pc.in b/libva-glx.pc.in +new file mode 100644 +index 0000000..2019915 +diff --git a/va/Makefile.am b/va/Makefile.am +index 99f6bbf..ebff3d5 100644 +diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am +new file mode 100644 +index 0000000..337f34e +--- /dev/null ++++ b/va/glx/Makefile.am +@@ -0,0 +1,41 @@ ++# Copyright (C) 2009 Splitted-Desktop Systems. 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. ++ ++AM_CFLAGS = -DLINUX -I$(top_srcdir)/va -I$(top_srcdir)/va/x11 ++ ++source_c = \ ++ va_glx.c \ ++ va_glx_impl.c ++ ++source_h = \ ++ va_glx.h \ ++ va_backend_glx.h ++ ++source_h_priv = \ ++ va_glx_impl.h \ ++ va_glx_private.h ++ ++noinst_LTLIBRARIES = libva_glx.la ++libva_glxincludedir = ${includedir}/va ++libva_glxinclude_HEADERS = $(source_h) ++libva_glx_la_SOURCES = $(source_c) ++noinst_HEADERS = $(source_h_priv) +diff --git a/va/glx/va_backend_glx.h b/va/glx/va_backend_glx.h +new file mode 100644 +index 0000000..d110485 +--- /dev/null ++++ b/va/glx/va_backend_glx.h +@@ -0,0 +1,54 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_BACKEND_GLX_H ++#define VA_BACKEND_GLX_H ++ ++struct VADriverContext; ++ ++struct VADriverVTableGLX { ++ /* Optional: create a surface used for display to OpenGL */ ++ VAStatus (*vaCreateSurfaceGLX)( ++ struct VADriverContext *ctx, ++ unsigned int gl_target, ++ unsigned int gl_texture, ++ void **gl_surface ++ ); ++ ++ /* Optional: destroy a VA/GLX surface */ ++ VAStatus (*vaDestroySurfaceGLX)( ++ struct VADriverContext *ctx, ++ void *gl_surface ++ ); ++ ++ /* Optional: copy a VA surface to a VA/GLX surface */ ++ VAStatus (*vaCopySurfaceGLX)( ++ struct VADriverContext *ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++ ); ++}; ++ ++#endif /* VA_BACKEND_GLX_H */ +diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c +new file mode 100644 +index 0000000..96efafd +--- /dev/null ++++ b/va/glx/va_glx.c +@@ -0,0 +1,202 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. 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 ++#include "va_glx_private.h" ++#include "va_glx_impl.h" ++ ++#define INIT_CONTEXT(ctx, dpy) do { \ ++ if (!vaDisplayIsValid(dpy)) \ ++ return VA_STATUS_ERROR_INVALID_DISPLAY; \ ++ \ ++ ctx = ((VADisplayContextP)(dpy))->pDriverContext; \ ++ if (!(ctx)) \ ++ return VA_STATUS_ERROR_INVALID_DISPLAY; \ ++ \ ++ VAStatus status = va_glx_init_context(ctx); \ ++ if (status != VA_STATUS_SUCCESS) \ ++ return status; \ ++ } while (0) ++ ++#define INIT_SURFACE(surface, surface_arg) do { \ ++ surface = (VASurfaceGLXP)(surface_arg); \ ++ if (!vaSurfaceIsValid(surface)) \ ++ return VA_STATUS_ERROR_INVALID_SURFACE; \ ++ } while (0) ++ ++#define INVOKE(ctx, func, args) do { \ ++ VADriverVTableGLXP vtable; \ ++ vtable = &VA_DRIVER_CONTEXT_GLX(ctx)->vtable; \ ++ if (!vtable->va##func##GLX) \ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; \ ++ status = vtable->va##func##GLX args; \ ++ } while (0) ++ ++// Check VADisplay is valid ++static inline int vaDisplayIsValid(VADisplay dpy) ++{ ++ VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; ++ ++ return (pDisplayContext && ++ pDisplayContext->vaIsValid && ++ pDisplayContext->vaIsValid(pDisplayContext)); ++} ++ ++// Check VASurfaceGLX is valid ++static inline int vaSurfaceIsValid(VASurfaceGLXP pSurfaceGLX) ++{ ++ return pSurfaceGLX && pSurfaceGLX->magic == VA_SURFACE_GLX_MAGIC; ++} ++ ++// Destroy VA/GLX display context ++static void va_DisplayContextDestroy(VADisplayContextP pDisplayContext) ++{ ++ VADisplayContextGLXP pDisplayContextGLX; ++ VADriverContextP pDriverContext; ++ VADriverContextGLXP pDriverContextGLX; ++ ++ if (!pDisplayContext) ++ return; ++ ++ pDriverContext = pDisplayContext->pDriverContext; ++ pDriverContextGLX = pDriverContext->glx; ++ if (pDriverContextGLX) { ++ free(pDriverContextGLX); ++ pDriverContext->glx = NULL; ++ } ++ ++ pDisplayContextGLX = pDisplayContext->opaque; ++ if (pDisplayContextGLX) { ++ vaDestroyFunc vaDestroy = pDisplayContextGLX->vaDestroy; ++ free(pDisplayContextGLX); ++ pDisplayContext->opaque = NULL; ++ if (vaDestroy) ++ vaDestroy(pDisplayContext); ++ } ++} ++ ++// Return a suitable VADisplay for VA API ++VADisplay vaGetDisplayGLX(Display *native_dpy) ++{ ++ VADisplay dpy = NULL; ++ VADisplayContextP pDisplayContext = NULL; ++ VADisplayContextGLXP pDisplayContextGLX = NULL; ++ VADriverContextP pDriverContext; ++ VADriverContextGLXP pDriverContextGLX = NULL; ++ ++ dpy = vaGetDisplay(native_dpy); ++ if (!dpy) ++ return NULL; ++ pDisplayContext = (VADisplayContextP)dpy; ++ pDriverContext = pDisplayContext->pDriverContext; ++ ++ pDisplayContextGLX = calloc(1, sizeof(*pDisplayContextGLX)); ++ if (!pDisplayContextGLX) ++ goto error; ++ ++ pDriverContextGLX = calloc(1, sizeof(*pDriverContextGLX)); ++ if (!pDriverContextGLX) ++ goto error; ++ ++ pDisplayContextGLX->vaDestroy = pDisplayContext->vaDestroy; ++ pDisplayContext->vaDestroy = va_DisplayContextDestroy; ++ pDisplayContext->opaque = pDisplayContextGLX; ++ pDriverContext->glx = pDriverContextGLX; ++ return dpy; ++ ++error: ++ free(pDriverContextGLX); ++ free(pDisplayContextGLX); ++ pDisplayContext->vaDestroy(pDisplayContext); ++ return NULL; ++} ++ ++// Create a surface used for display to OpenGL ++VAStatus vaCreateSurfaceGLX( ++ VADisplay dpy, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ VADriverContextP ctx; ++ VASurfaceGLXP pSurfaceGLX; ++ VAStatus status; ++ ++ /* Make sure it is a valid GL texture object */ ++ if (!glIsTexture(texture)) ++ return VA_STATUS_ERROR_INVALID_PARAMETER; ++ ++ INIT_CONTEXT(ctx, dpy); ++ ++ pSurfaceGLX = va_glx_create_surface(ctx, target, texture); ++ if (!pSurfaceGLX) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ ++ INVOKE(ctx, CreateSurface, (ctx, target, texture, &pSurfaceGLX->priv)); ++ ++ if (status != VA_STATUS_SUCCESS) ++ va_glx_destroy_surface(ctx, &pSurfaceGLX); ++ ++ *gl_surface = pSurfaceGLX; ++ return status; ++} ++ ++// Destroy a VA/GLX surface ++VAStatus vaDestroySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface ++) ++{ ++ VADriverContextP ctx; ++ VASurfaceGLXP pSurfaceGLX; ++ VAStatus status; ++ ++ INIT_CONTEXT(ctx, dpy); ++ INIT_SURFACE(pSurfaceGLX, gl_surface); ++ ++ INVOKE(ctx, DestroySurface, (ctx, pSurfaceGLX)); ++ ++ free(pSurfaceGLX); ++ return status; ++} ++ ++// Copy a VA surface to a VA/GLX surface ++VAStatus vaCopySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VADriverContextP ctx; ++ VASurfaceGLXP pSurfaceGLX; ++ VAStatus status; ++ ++ INIT_CONTEXT(ctx, dpy); ++ INIT_SURFACE(pSurfaceGLX, gl_surface); ++ ++ INVOKE(ctx, CopySurface, (ctx, pSurfaceGLX, surface, flags)); ++ return status; ++} +diff --git a/va/glx/va_glx.h b/va/glx/va_glx.h +new file mode 100644 +index 0000000..1a0624d +--- /dev/null ++++ b/va/glx/va_glx.h +@@ -0,0 +1,109 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_GLX_H ++#define VA_GLX_H ++ ++#include ++#include ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/** ++ * Return a suitable VADisplay for VA API ++ * ++ * @param[in] dpy the X11 display ++ * @return a VADisplay ++ */ ++VADisplay vaGetDisplayGLX( ++ Display *dpy ++); ++ ++/** ++ * Create a surface used for display to OpenGL ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] target the GL target to which the texture needs to be bound ++ * @param[in] texture the GL texture ++ * @param[out] gl_surface the VA/GLX surface ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaCreateSurfaceGLX( ++ VADisplay dpy, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++); ++ ++/** ++ * Destroy a VA/GLX surface ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] gl_surface the VA surface ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaDestroySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface ++); ++ ++/** ++ * Copy a VA surface to a VA/GLX surface ++ * ++ * This function will not return until the copy is completed. At this ++ * point, the underlying GL texture will contain the surface pixels ++ * in an RGB format defined by the user. ++ * ++ * The application shall maintain the live GLX context itself. ++ * Implementations are free to use glXGetCurrentContext() and ++ * glXGetCurrentDrawable() functions for internal purposes. ++ * ++ * @param[in] dpy the VA display ++ * @param[in] gl_surface the VA/GLX destination surface ++ * @param[in] surface the VA source surface ++ * @param[in] flags the PutSurface flags ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus vaCopySurfaceGLX( ++ VADisplay dpy, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++); ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* VA_GLX_H */ +diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c +new file mode 100644 +index 0000000..6fd7057 +--- /dev/null ++++ b/va/glx/va_glx_impl.c +@@ -0,0 +1,1013 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#define _GNU_SOURCE 1 ++#include "va_glx_private.h" ++#include "va_glx_impl.h" ++#include ++#include ++#include ++#include ++#include ++#include ++ ++static void va_glx_error_message(const char *format, ...) ++{ ++ va_list args; ++ va_start(args, format); ++ fprintf(stderr, "[%s] ", PACKAGE_NAME); ++ vfprintf(stderr, format, args); ++ va_end(args); ++} ++ ++// X error trap ++static int x11_error_code = 0; ++static int (*old_error_handler)(Display *, XErrorEvent *); ++ ++static int error_handler(Display *dpy, XErrorEvent *error) ++{ ++ x11_error_code = error->error_code; ++ return 0; ++} ++ ++static void x11_trap_errors(void) ++{ ++ x11_error_code = 0; ++ old_error_handler = XSetErrorHandler(error_handler); ++} ++ ++static int x11_untrap_errors(void) ++{ ++ XSetErrorHandler(old_error_handler); ++ return x11_error_code; ++} ++ ++// Returns a string representation of an OpenGL error ++static const char *gl_get_error_string(GLenum error) ++{ ++ static const struct { ++ GLenum val; ++ const char *str; ++ } ++ gl_errors[] = { ++ { GL_NO_ERROR, "no error" }, ++ { GL_INVALID_ENUM, "invalid enumerant" }, ++ { GL_INVALID_VALUE, "invalid value" }, ++ { GL_INVALID_OPERATION, "invalid operation" }, ++ { GL_STACK_OVERFLOW, "stack overflow" }, ++ { GL_STACK_UNDERFLOW, "stack underflow" }, ++ { GL_OUT_OF_MEMORY, "out of memory" }, ++#ifdef GL_INVALID_FRAMEBUFFER_OPERATION_EXT ++ { GL_INVALID_FRAMEBUFFER_OPERATION_EXT, "invalid framebuffer operation" }, ++#endif ++ { ~0, NULL } ++ }; ++ ++ int i; ++ for (i = 0; gl_errors[i].str; i++) { ++ if (gl_errors[i].val == error) ++ return gl_errors[i].str; ++ } ++ return "unknown"; ++} ++ ++static inline int gl_do_check_error(int report) ++{ ++ GLenum error; ++ int is_error = 0; ++ while ((error = glGetError()) != GL_NO_ERROR) { ++ if (report) ++ va_glx_error_message("glError: %s caught\n", ++ gl_get_error_string(error)); ++ is_error = 1; ++ } ++ return is_error; ++} ++ ++static inline void gl_purge_errors(void) ++{ ++ gl_do_check_error(0); ++} ++ ++static inline int gl_check_error(void) ++{ ++ return gl_do_check_error(1); ++} ++ ++// glGetFloatv() wrapper ++static int gl_get_current_color(float color[4]) ++{ ++ gl_purge_errors(); ++ glGetFloatv(GL_CURRENT_COLOR, color); ++ if (gl_check_error()) ++ return -1; ++ return 0; ++} ++ ++// glGetIntegerv() wrapper ++static int gl_get_param(GLenum param, unsigned int *pval) ++{ ++ GLint val; ++ ++ gl_purge_errors(); ++ glGetIntegerv(param, &val); ++ if (gl_check_error()) ++ return -1; ++ if (pval) ++ *pval = val; ++ return 0; ++} ++ ++// glGetTexLevelParameteriv() wrapper ++static int gl_get_texture_param(GLenum param, unsigned int *pval) ++{ ++ GLint val; ++ ++ gl_purge_errors(); ++ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, param, &val); ++ if (gl_check_error()) ++ return -1; ++ if (pval) ++ *pval = val; ++ return 0; ++} ++ ++// Returns the OpenGL VTable ++static inline VAOpenGLVTableP gl_get_vtable(VADriverContextP ctx) ++{ ++ return &VA_DRIVER_CONTEXT_GLX(ctx)->gl_vtable; ++} ++ ++// Lookup for a GLX function ++typedef void (*GLFuncPtr)(void); ++typedef GLFuncPtr (*GLXGetProcAddressProc)(const char *); ++ ++static GLFuncPtr get_proc_address_default(const char *name) ++{ ++ return NULL; ++} ++ ++static GLXGetProcAddressProc get_proc_address_func(void) ++{ ++ GLXGetProcAddressProc get_proc_func; ++ ++ dlerror(); ++ get_proc_func = (GLXGetProcAddressProc) ++ dlsym(RTLD_DEFAULT, "glXGetProcAddress"); ++ if (dlerror() == NULL) ++ return get_proc_func; ++ ++ get_proc_func = (GLXGetProcAddressProc) ++ dlsym(RTLD_DEFAULT, "glXGetProcAddressARB"); ++ if (dlerror() == NULL) ++ return get_proc_func; ++ ++ return get_proc_address_default; ++} ++ ++static inline GLFuncPtr get_proc_address(const char *name) ++{ ++ static GLXGetProcAddressProc get_proc_func = NULL; ++ if (get_proc_func == NULL) ++ get_proc_func = get_proc_address_func(); ++ return get_proc_func(name); ++} ++ ++// Check for GLX extensions (TFP, FBO) ++static int check_extension(const char *name, const char *ext) ++{ ++ const char *end; ++ int name_len, n; ++ ++ if (name == NULL || ext == NULL) ++ return 0; ++ ++ end = ext + strlen(ext); ++ name_len = strlen(name); ++ while (ext < end) { ++ n = strcspn(ext, " "); ++ if (n == name_len && strncmp(name, ext, n) == 0) ++ return 1; ++ ext += (n + 1); ++ } ++ return 0; ++} ++ ++static int check_tfp_extensions(VADriverContextP ctx) ++{ ++ const char *gl_extensions; ++ const char *glx_extensions; ++ ++ gl_extensions = (const char *)glGetString(GL_EXTENSIONS); ++ if (!check_extension("GL_ARB_texture_non_power_of_two", gl_extensions)) ++ return 0; ++ ++ glx_extensions = glXQueryExtensionsString(ctx->x11_dpy, ctx->x11_screen); ++ if (!check_extension("GLX_EXT_texture_from_pixmap", glx_extensions)) ++ return 0; ++ return 1; ++} ++ ++static int check_fbo_extensions(VADriverContextP ctx) ++{ ++ const char *gl_extensions; ++ ++ gl_extensions = (const char *)glGetString(GL_EXTENSIONS); ++ if (check_extension("GL_ARB_framebuffer_object", gl_extensions)) ++ return 1; ++ if (check_extension("GL_EXT_framebuffer_object", gl_extensions)) ++ return 1; ++ return 0; ++} ++ ++// Load GLX extensions ++static int load_tfp_extensions(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ pOpenGLVTable->glx_bind_tex_image = (PFNGLXBINDTEXIMAGEEXTPROC) ++ get_proc_address("glXBindTexImageEXT"); ++ if (pOpenGLVTable->glx_bind_tex_image == NULL) ++ return 0; ++ pOpenGLVTable->glx_release_tex_image = (PFNGLXRELEASETEXIMAGEEXTPROC) ++ get_proc_address("glXReleaseTexImageEXT"); ++ if (pOpenGLVTable->glx_release_tex_image == NULL) ++ return 0; ++ return 1; ++} ++ ++static int load_fbo_extensions(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ pOpenGLVTable->gl_gen_framebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC) ++ get_proc_address("glGenFramebuffersEXT"); ++ if (pOpenGLVTable->gl_gen_framebuffers == NULL) ++ return 0; ++ pOpenGLVTable->gl_delete_framebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC) ++ get_proc_address("glDeleteFramebuffersEXT"); ++ if (pOpenGLVTable->gl_delete_framebuffers == NULL) ++ return 0; ++ pOpenGLVTable->gl_bind_framebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC) ++ get_proc_address("glBindFramebufferEXT"); ++ if (pOpenGLVTable->gl_bind_framebuffer == NULL) ++ return 0; ++ pOpenGLVTable->gl_gen_renderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC) ++ get_proc_address("glGenRenderbuffersEXT"); ++ if (pOpenGLVTable->gl_gen_renderbuffers == NULL) ++ return 0; ++ pOpenGLVTable->gl_delete_renderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC) ++ get_proc_address("glDeleteRenderbuffersEXT"); ++ if (pOpenGLVTable->gl_delete_renderbuffers == NULL) ++ return 0; ++ pOpenGLVTable->gl_bind_renderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC) ++ get_proc_address("glBindRenderbufferEXT"); ++ if (pOpenGLVTable->gl_bind_renderbuffer == NULL) ++ return 0; ++ pOpenGLVTable->gl_renderbuffer_storage = (PFNGLRENDERBUFFERSTORAGEEXTPROC) ++ get_proc_address("glRenderbufferStorageEXT"); ++ if (pOpenGLVTable->gl_renderbuffer_storage == NULL) ++ return 0; ++ pOpenGLVTable->gl_framebuffer_renderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) ++ get_proc_address("glFramebufferRenderbufferEXT"); ++ if (pOpenGLVTable->gl_framebuffer_renderbuffer == NULL) ++ return 0; ++ pOpenGLVTable->gl_framebuffer_texture_2d = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) ++ get_proc_address("glFramebufferTexture2DEXT"); ++ if (pOpenGLVTable->gl_framebuffer_texture_2d == NULL) ++ return 0; ++ pOpenGLVTable->gl_check_framebuffer_status = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) ++ get_proc_address("glCheckFramebufferStatusEXT"); ++ if (pOpenGLVTable->gl_check_framebuffer_status == NULL) ++ return 0; ++ return 1; ++} ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX helpers === */ ++/* ========================================================================= */ ++ ++// OpenGL texture state ++typedef struct OpenGLTextureState *OpenGLTextureStateP; ++ ++struct OpenGLTextureState { ++ int was_enabled; ++ int was_bound; ++ GLenum target; ++ GLuint old_texture; ++}; ++ ++// Bind texture, preserve previous texture state ++static int bind_texture(OpenGLTextureStateP ts, GLenum target, GLuint texture) ++{ ++ ts->target = target; ++ ts->old_texture = 0; ++ ts->was_bound = 0; ++ ts->was_enabled = glIsEnabled(target); ++ if (!ts->was_enabled) ++ glEnable(target); ++ ++ GLenum texture_binding; ++ switch (target) { ++ case GL_TEXTURE_1D: ++ texture_binding = GL_TEXTURE_BINDING_1D; ++ break; ++ case GL_TEXTURE_2D: ++ texture_binding = GL_TEXTURE_BINDING_2D; ++ break; ++ case GL_TEXTURE_3D: ++ texture_binding = GL_TEXTURE_BINDING_3D; ++ break; ++ case GL_TEXTURE_RECTANGLE_ARB: ++ texture_binding = GL_TEXTURE_BINDING_RECTANGLE_ARB; ++ break; ++ default: ++ assert(!target); ++ return -1; ++ } ++ ++ if (ts->was_enabled && gl_get_param(texture_binding, &ts->old_texture) < 0) ++ return -1; ++ ++ ts->was_bound = texture == ts->old_texture; ++ if (!ts->was_bound) { ++ gl_purge_errors(); ++ glBindTexture(target, texture); ++ if (gl_check_error()) ++ return -1; ++ } ++ return 0; ++} ++ ++// Unbind texture, restore previous texture state ++static void unbind_texture(OpenGLTextureStateP ts) ++{ ++ if (!ts->was_bound && ts->old_texture) ++ glBindTexture(ts->target, ts->old_texture); ++ if (!ts->was_enabled) ++ glDisable(ts->target); ++} ++ ++// Create Pixmaps for GLX texture-from-pixmap extension ++static int create_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ const unsigned int width = pSurfaceGLX->width; ++ const unsigned int height = pSurfaceGLX->height; ++ Pixmap pixmap = None; ++ GLXFBConfig *fbconfig = NULL; ++ GLXPixmap glx_pixmap = None; ++ Window root_window; ++ XWindowAttributes wattr; ++ int *attrib; ++ int n_fbconfig_attribs, x, y, status; ++ unsigned int border_width, depth, dummy; ++ ++ root_window = RootWindow(ctx->x11_dpy, ctx->x11_screen); ++ XGetWindowAttributes(ctx->x11_dpy, root_window, &wattr); ++ pixmap = XCreatePixmap(ctx->x11_dpy, root_window, ++ width, height, wattr.depth); ++ if (!pixmap) ++ return -1; ++ pSurfaceGLX->pixmap = pixmap; ++ ++ x11_trap_errors(); ++ status = XGetGeometry(ctx->x11_dpy, ++ (Drawable)pixmap, ++ &root_window, ++ &x, ++ &y, ++ &dummy, ++ &dummy, ++ &border_width, ++ &depth); ++ if (x11_untrap_errors() != 0 || status == 0) ++ return -1; ++ if (depth != 24 && depth != 32) ++ return -1; ++ ++ int fbconfig_attribs[32] = { ++ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT, ++ GLX_DOUBLEBUFFER, GL_TRUE, ++ GLX_RENDER_TYPE, GLX_RGBA_BIT, ++ GLX_X_RENDERABLE, GL_TRUE, ++ GLX_Y_INVERTED_EXT, GL_TRUE, ++ GLX_RED_SIZE, 8, ++ GLX_GREEN_SIZE, 8, ++ GLX_BLUE_SIZE, 8, ++ GL_NONE, ++ }; ++ for (attrib = fbconfig_attribs; *attrib != GL_NONE; attrib += 2) ++ ; ++ *attrib++ = GLX_DEPTH_SIZE; *attrib++ = depth; ++ if (depth == 32) { ++ *attrib++ = GLX_ALPHA_SIZE; *attrib++ = 8; ++ *attrib++ = GLX_BIND_TO_TEXTURE_RGBA_EXT; *attrib++ = GL_TRUE; ++ } ++ else { ++ *attrib++ = GLX_BIND_TO_TEXTURE_RGB_EXT; *attrib++ = GL_TRUE; ++ } ++ *attrib++ = GL_NONE; ++ ++ fbconfig = glXChooseFBConfig(ctx->x11_dpy, ctx->x11_screen, fbconfig_attribs, &n_fbconfig_attribs); ++ if (fbconfig == NULL) ++ return -1; ++ ++ int pixmap_attribs[10] = { ++ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, ++ GLX_MIPMAP_TEXTURE_EXT, GL_FALSE, ++ GL_NONE, ++ }; ++ for (attrib = pixmap_attribs; *attrib != GL_NONE; attrib += 2) ++ ; ++ *attrib++ = GLX_TEXTURE_FORMAT_EXT; ++ if (depth == 32) ++ *attrib++ = GLX_TEXTURE_FORMAT_RGBA_EXT; ++ else ++ *attrib++ = GLX_TEXTURE_FORMAT_RGB_EXT; ++ *attrib++ = GL_NONE; ++ ++ x11_trap_errors(); ++ glx_pixmap = glXCreatePixmap(ctx->x11_dpy, ++ fbconfig[0], ++ pixmap, ++ pixmap_attribs); ++ free(fbconfig); ++ if (x11_untrap_errors() != 0) ++ return -1; ++ pSurfaceGLX->glx_pixmap = glx_pixmap; ++ return 0; ++} ++ ++// Destroy Pixmaps used for TFP ++static void destroy_tfp_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ if (pSurfaceGLX->glx_pixmap) { ++ glXDestroyPixmap(ctx->x11_dpy, pSurfaceGLX->glx_pixmap); ++ pSurfaceGLX->glx_pixmap = None; ++ } ++ ++ if (pSurfaceGLX->pixmap) { ++ XFreePixmap(ctx->x11_dpy, pSurfaceGLX->pixmap); ++ pSurfaceGLX->pixmap = None; ++ } ++} ++ ++// Bind GLX Pixmap to texture ++static int bind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (pSurfaceGLX->is_bound) ++ return 0; ++ ++ x11_trap_errors(); ++ pOpenGLVTable->glx_bind_tex_image(ctx->x11_dpy, pSurfaceGLX->glx_pixmap, ++ GLX_FRONT_LEFT_EXT, NULL); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) { ++ va_glx_error_message("failed to bind pixmap\n"); ++ return -1; ++ } ++ ++ pSurfaceGLX->is_bound = 1; ++ return 0; ++} ++ ++// Release GLX Pixmap from texture ++static int unbind_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (!pSurfaceGLX->is_bound) ++ return 0; ++ ++ x11_trap_errors(); ++ pOpenGLVTable->glx_release_tex_image(ctx->x11_dpy, pSurfaceGLX->glx_pixmap, ++ GLX_FRONT_LEFT_EXT); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) { ++ va_glx_error_message("failed to release pixmap\n"); ++ return -1; ++ } ++ ++ pSurfaceGLX->is_bound = 0; ++ return 0; ++} ++ ++// Render GLX Pixmap to texture ++static void render_pixmap(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ const unsigned int w = pSurfaceGLX->width; ++ const unsigned int h = pSurfaceGLX->height; ++ float old_color[4]; ++ ++ gl_get_current_color(old_color); ++ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); ++ glBegin(GL_QUADS); ++ { ++ glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0); ++ glTexCoord2f(0.0f, 1.0f); glVertex2i(0, h); ++ glTexCoord2f(1.0f, 1.0f); glVertex2i(w, h); ++ glTexCoord2f(1.0f, 0.0f); glVertex2i(w, 0); ++ } ++ glEnd(); ++ glColor4fv(old_color); ++} ++ ++// Create offscreen surface ++static int create_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ const GLenum texture = pSurfaceGLX->texture; ++ const unsigned int texture_width = pSurfaceGLX->width; ++ const unsigned int texture_height = pSurfaceGLX->height; ++ GLuint fbo, fbo_buffer, fbo_texture; ++ GLenum status; ++ ++ glGenTextures(1, &fbo_texture); ++ glBindTexture(GL_TEXTURE_2D, fbo_texture); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); ++ glPixelStorei(GL_UNPACK_ALIGNMENT, 4); ++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, texture_height, 0, ++ GL_BGRA, GL_UNSIGNED_BYTE, NULL); ++ ++ pOpenGLVTable->gl_gen_framebuffers(1, &fbo); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, fbo); ++ pOpenGLVTable->gl_gen_renderbuffers(1, &fbo_buffer); ++ pOpenGLVTable->gl_bind_renderbuffer(GL_RENDERBUFFER_EXT, fbo_buffer); ++ ++ glBindTexture(GL_TEXTURE_2D, texture); ++ pOpenGLVTable->gl_framebuffer_texture_2d(GL_FRAMEBUFFER_EXT, ++ GL_COLOR_ATTACHMENT0_EXT, ++ GL_TEXTURE_2D, texture, 0); ++ ++ status = pOpenGLVTable->gl_check_framebuffer_status(GL_DRAW_FRAMEBUFFER_EXT); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); ++ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) ++ return -1; ++ ++ pSurfaceGLX->fbo = fbo; ++ pSurfaceGLX->fbo_buffer = fbo_buffer; ++ pSurfaceGLX->fbo_texture = fbo_texture; ++ return 0; ++} ++ ++// Destroy offscreen surface ++static void destroy_fbo_surface(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ if (pSurfaceGLX->fbo_texture) { ++ glDeleteTextures(1, &pSurfaceGLX->fbo_texture); ++ pSurfaceGLX->fbo_texture = 0; ++ } ++ ++ if (pSurfaceGLX->fbo_buffer) { ++ pOpenGLVTable->gl_delete_renderbuffers(1, &pSurfaceGLX->fbo_buffer); ++ pSurfaceGLX->fbo_buffer = 0; ++ } ++ ++ if (pSurfaceGLX->fbo) { ++ pOpenGLVTable->gl_delete_framebuffers(1, &pSurfaceGLX->fbo); ++ pSurfaceGLX->fbo = 0; ++ } ++} ++ ++// Setup matrices to match the FBO texture dimensions ++static void fbo_enter(VADriverContextP ctx, VASurfaceGLXP pSurfaceGLX) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ const unsigned int width = pSurfaceGLX->width; ++ const unsigned int height = pSurfaceGLX->height; ++ ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, pSurfaceGLX->fbo); ++ glPushAttrib(GL_VIEWPORT_BIT); ++ glMatrixMode(GL_PROJECTION); ++ glPushMatrix(); ++ glLoadIdentity(); ++ glMatrixMode(GL_MODELVIEW); ++ glPushMatrix(); ++ glLoadIdentity(); ++ glViewport(0, 0, width, height); ++ glTranslatef(-1.0f, -1.0f, 0.0f); ++ glScalef(2.0f / width, 2.0f / height, 1.0f); ++ ++ glBindTexture(GL_TEXTURE_2D, pSurfaceGLX->fbo_texture); ++} ++ ++// Restore original OpenGL matrices ++static void fbo_leave(VADriverContextP ctx) ++{ ++ VAOpenGLVTableP pOpenGLVTable = gl_get_vtable(ctx); ++ ++ glPopAttrib(); ++ glMatrixMode(GL_PROJECTION); ++ glPopMatrix(); ++ glMatrixMode(GL_MODELVIEW); ++ glPopMatrix(); ++ pOpenGLVTable->gl_bind_framebuffer(GL_FRAMEBUFFER_EXT, 0); ++} ++ ++// Create VA/GLX surface ++VASurfaceGLXP ++va_glx_create_surface(VADriverContextP ctx, GLenum target, GLuint texture) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX; ++ unsigned int internal_format, border_width, width, height; ++ int is_error = 1; ++ ++ /* Make sure binding succeeds, if texture was not already bound */ ++ struct OpenGLTextureState ts; ++ if (bind_texture(&ts, target, texture) < 0) ++ goto end; ++ ++ pSurfaceGLX = malloc(sizeof(*pSurfaceGLX)); ++ if (!pSurfaceGLX) ++ goto end; ++ ++ pSurfaceGLX->magic = VA_SURFACE_GLX_MAGIC; ++ pSurfaceGLX->target = target; ++ pSurfaceGLX->texture = texture; ++ pSurfaceGLX->surface = VA_INVALID_SURFACE; ++ pSurfaceGLX->is_bound = 0; ++ pSurfaceGLX->pixmap = None; ++ pSurfaceGLX->glx_pixmap = None; ++ pSurfaceGLX->fbo = 0; ++ pSurfaceGLX->fbo_buffer = 0; ++ pSurfaceGLX->fbo_texture = 0; ++ pSurfaceGLX->priv = NULL; ++ ++ /* XXX: we don't support other textures than RGBA */ ++ if (gl_get_texture_param(GL_TEXTURE_INTERNAL_FORMAT, &internal_format) < 0) ++ goto end; ++ if (internal_format != GL_RGBA) ++ goto end; ++ ++ /* Check texture dimensions */ ++ if (gl_get_texture_param(GL_TEXTURE_BORDER, &border_width) < 0) ++ goto end; ++ if (gl_get_texture_param(GL_TEXTURE_WIDTH, &width) < 0) ++ goto end; ++ if (gl_get_texture_param(GL_TEXTURE_HEIGHT, &height) < 0) ++ goto end; ++ ++ width -= 2 * border_width; ++ height -= 2 * border_width; ++ if (width == 0 || height == 0) ++ goto end; ++ ++ pSurfaceGLX->width = width; ++ pSurfaceGLX->height = height; ++ ++ /* Create Pixmaps for TFP */ ++ if (pDriverContextGLX->use_tfp) { ++ if (create_tfp_surface(ctx, pSurfaceGLX) < 0) ++ goto end; ++ } ++ ++ /* Create Pixmaps for FBO */ ++ if (pDriverContextGLX->use_fbo) { ++ if (create_fbo_surface(ctx, pSurfaceGLX) < 0) ++ goto end; ++ } ++ ++ is_error = 0; ++end: ++ if (is_error && pSurfaceGLX) ++ va_glx_destroy_surface(ctx, &pSurfaceGLX); ++ ++ unbind_texture(&ts); ++ return pSurfaceGLX; ++} ++ ++// Destroy VA/GLX surface ++void va_glx_destroy_surface(VADriverContextP ctx, VASurfaceGLXP *ppSurfaceGLX) ++{ ++ VASurfaceGLXP pSurfaceGLX = *ppSurfaceGLX; ++ ++ unbind_pixmap(ctx, pSurfaceGLX); ++ destroy_fbo_surface(ctx, pSurfaceGLX); ++ destroy_tfp_surface(ctx, pSurfaceGLX); ++ ++ free(pSurfaceGLX); ++ *ppSurfaceGLX = NULL; ++} ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX implementation from the driver (fordward calls) === */ ++/* ========================================================================= */ ++ ++#define INVOKE(ctx, func, args) do { \ ++ VADriverVTableGLXP vtable = (ctx)->vtable.glx; \ ++ if (!vtable->va##func##GLX) \ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; \ ++ \ ++ VAStatus status = vtable->va##func##GLX args; \ ++ if (status != VA_STATUS_SUCCESS) \ ++ return status; \ ++ } while (0) ++ ++static VAStatus ++vaCreateSurfaceGLX_impl_driver( ++ VADriverContextP ctx, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ INVOKE(ctx, CreateSurface, (ctx, target, texture, gl_surface)); ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaDestroySurfaceGLX_impl_driver(VADriverContextP ctx, void *gl_surface) ++{ ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ ++ INVOKE(ctx, DestroySurface, (ctx, pSurfaceGLX->priv)); ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaCopySurfaceGLX_impl_driver( ++ VADriverContextP ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ ++ INVOKE(ctx, CopySurface, (ctx, pSurfaceGLX->priv, surface, flags)); ++ return VA_STATUS_SUCCESS; ++} ++ ++#undef INVOKE ++ ++ ++/* ========================================================================= */ ++/* === VA/GLX implementation from libVA (generic and suboptimal path) === */ ++/* ========================================================================= */ ++ ++static VAStatus ++vaCreateSurfaceGLX_impl_libva( ++ VADriverContextP ctx, ++ GLenum target, ++ GLuint texture, ++ void **gl_surface ++) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ *gl_surface = NULL; ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaDestroySurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaDeassociateSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ if (unbind_pixmap(ctx, pSurfaceGLX) < 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ pSurfaceGLX->surface = VA_INVALID_SURFACE; ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaAssociateSurfaceGLX_impl_libva( ++ VADriverContextP ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ VAStatus status; ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ /* XXX: only support VA_FRAME_PICTURE */ ++ if (flags != VA_FRAME_PICTURE) ++ return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED; ++ ++ /* XXX: optimise case where we are associating the same VA surface ++ as before an no changed occurred to it */ ++ status = vaDeassociateSurfaceGLX_impl_libva(ctx, gl_surface); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ x11_trap_errors(); ++ status = ctx->vtable.vaPutSurface(ctx, ++ surface, ++ pSurfaceGLX->pixmap, ++ 0, 0, ++ pSurfaceGLX->width, ++ pSurfaceGLX->height, ++ 0, 0, ++ pSurfaceGLX->width, ++ pSurfaceGLX->height, ++ NULL, 0, ++ flags); ++ XSync(ctx->x11_dpy, False); ++ if (x11_untrap_errors() != 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ pSurfaceGLX->surface = surface; ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaSyncSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ if (pSurfaceGLX->surface == VA_INVALID_SURFACE) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ return ctx->vtable.vaSyncSurface(ctx, pSurfaceGLX->surface); ++} ++ ++static VAStatus ++vaBeginRenderSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ VAStatus status; ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ status = vaSyncSurfaceGLX_impl_libva(ctx, gl_surface); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ if (bind_pixmap(ctx, pSurfaceGLX) < 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaEndRenderSurfaceGLX_impl_libva(VADriverContextP ctx, void *gl_surface) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ ++ if (!pDriverContextGLX->use_tfp) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ if (unbind_pixmap(ctx, pSurfaceGLX) < 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ return VA_STATUS_SUCCESS; ++} ++ ++static VAStatus ++vaCopySurfaceGLX_impl_libva( ++ VADriverContextP ctx, ++ void *gl_surface, ++ VASurfaceID surface, ++ unsigned int flags ++) ++{ ++ VADriverContextGLXP pDriverContextGLX = VA_DRIVER_CONTEXT_GLX(ctx); ++ VASurfaceGLXP pSurfaceGLX = gl_surface; ++ VAStatus status; ++ ++ if (!pDriverContextGLX->use_fbo) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ ++ /* XXX: only support VA_FRAME_PICTURE */ ++ if (flags != VA_FRAME_PICTURE) ++ return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED; ++ ++ /* Associate VA surface */ ++ status = vaAssociateSurfaceGLX_impl_libva(ctx, gl_surface, surface, flags); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ /* Make sure binding succeeds, if texture was not already bound */ ++ struct OpenGLTextureState ts; ++ if (bind_texture(&ts, pSurfaceGLX->target, pSurfaceGLX->texture) < 0) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ /* Render to FBO */ ++ fbo_enter(ctx, pSurfaceGLX); ++ status = vaBeginRenderSurfaceGLX_impl_libva(ctx, gl_surface); ++ if (status == VA_STATUS_SUCCESS) { ++ render_pixmap(ctx, pSurfaceGLX); ++ status = vaEndRenderSurfaceGLX_impl_libva(ctx, gl_surface); ++ } ++ fbo_leave(ctx); ++ unbind_texture(&ts); ++ if (status != VA_STATUS_SUCCESS) ++ return status; ++ ++ return vaDeassociateSurfaceGLX_impl_libva(ctx, gl_surface); ++} ++ ++ ++/* ========================================================================= */ ++/* === Private VA/GLX vtable initialization === */ ++/* ========================================================================= */ ++ ++// Initialize GLX driver context ++VAStatus va_glx_init_context(VADriverContextP ctx) ++{ ++ VADriverContextGLXP glx_ctx = VA_DRIVER_CONTEXT_GLX(ctx); ++ VADriverVTableGLXP vtable = &glx_ctx->vtable; ++ int needs_tfp = 0, needs_fbo = 0; ++ ++ if (glx_ctx->is_initialized) ++ return VA_STATUS_SUCCESS; ++ ++ if (ctx->vtable.glx && ctx->vtable.glx->vaCopySurfaceGLX) { ++ vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_driver; ++ vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_driver; ++ vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_driver; ++ } ++ else { ++ needs_tfp = 1; ++ needs_fbo = 1; ++ vtable->vaCreateSurfaceGLX = vaCreateSurfaceGLX_impl_libva; ++ vtable->vaDestroySurfaceGLX = vaDestroySurfaceGLX_impl_libva; ++ vtable->vaCopySurfaceGLX = vaCopySurfaceGLX_impl_libva; ++ } ++ ++ glx_ctx->has_tfp = 0; ++ glx_ctx->use_tfp = 0; ++ glx_ctx->has_fbo = 0; ++ glx_ctx->use_fbo = 0; ++ ++ if (needs_tfp) { ++ glx_ctx->has_tfp = check_tfp_extensions(ctx); ++ if (!glx_ctx->has_tfp || !load_tfp_extensions(ctx)) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ glx_ctx->use_tfp = 1; ++ } ++ ++ if (needs_fbo) { ++ glx_ctx->has_fbo = check_fbo_extensions(ctx); ++ if (!glx_ctx->has_fbo || !load_fbo_extensions(ctx)) ++ return VA_STATUS_ERROR_UNIMPLEMENTED; ++ glx_ctx->use_fbo = 1; ++ } ++ ++ glx_ctx->is_initialized = 1; ++ return VA_STATUS_SUCCESS; ++} +diff --git a/va/glx/va_glx_impl.h b/va/glx/va_glx_impl.h +new file mode 100644 +index 0000000..977bfcc +--- /dev/null ++++ b/va/glx/va_glx_impl.h +@@ -0,0 +1,46 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_GLX_IMPL_H ++#define VA_GLX_IMPL_H ++ ++/** ++ * Initialize GLX driver context ++ * ++ * @param[in] ctx the VA driver context ++ * @return VA_STATUS_SUCCESS if successful ++ */ ++VAStatus va_glx_init_context(VADriverContextP ctx) ++ ATTRIBUTE_HIDDEN; ++ ++/** Create VA/GLX surface */ ++VASurfaceGLXP ++va_glx_create_surface(VADriverContextP ctx, GLenum target, GLuint texture) ++ ATTRIBUTE_HIDDEN; ++ ++/** Destroy VA/GLX surface */ ++void va_glx_destroy_surface(VADriverContextP ctx, VASurfaceGLXP *pSurfaceGLX) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* VA_GLX_IMPL_H */ +diff --git a/va/glx/va_glx_private.h b/va/glx/va_glx_private.h +new file mode 100644 +index 0000000..b2c44e8 +--- /dev/null ++++ b/va/glx/va_glx_private.h +@@ -0,0 +1,99 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_GLX_PRIVATE_H ++#define VA_GLX_PRIVATE_H ++ ++#include "config.h" ++#include "va.h" ++#include "va_backend.h" ++#include "va_x11.h" ++#include "va_glx.h" ++#include "va_backend_glx.h" ++ ++#if GLX_GLXEXT_VERSION < 18 ++typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *); ++typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int); ++#endif ++ ++typedef struct VAOpenGLVTable *VAOpenGLVTableP; ++ ++struct VAOpenGLVTable { ++ PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image; ++ PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image; ++ PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers; ++ PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers; ++ PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer; ++ PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers; ++ PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers; ++ PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer; ++ PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage; ++ PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer; ++ PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d; ++ PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status; ++}; ++ ++typedef struct VADisplayContextGLX *VADisplayContextGLXP; ++typedef struct VADriverContextGLX *VADriverContextGLXP; ++typedef struct VASurfaceGLX *VASurfaceGLXP; ++typedef struct VADriverVTableGLX *VADriverVTableGLXP; ++ ++typedef void (*vaDestroyFunc)(VADisplayContextP); ++ ++struct VADisplayContextGLX { ++ vaDestroyFunc vaDestroy; ++}; ++ ++#define VA_DRIVER_CONTEXT_GLX(ctx) ((VADriverContextGLXP)((ctx)->glx)) ++ ++struct VADriverContextGLX { ++ struct VADriverVTableGLX vtable; ++ struct VAOpenGLVTable gl_vtable; ++ unsigned int is_initialized : 1; ++ unsigned int has_tfp : 1; ++ unsigned int has_fbo : 1; ++ unsigned int use_tfp : 1; ++ unsigned int use_fbo : 1; ++}; ++ ++/** Unique VASurfaceGLX identifier */ ++#define VA_SURFACE_GLX_MAGIC VA_FOURCC('V','A','G','L') ++ ++struct VASurfaceGLX { ++ uint32_t magic; ///< Magic number identifying a VASurfaceGLX ++ GLenum target; ///< GL target to which the texture is bound ++ GLuint texture; ///< GL texture ++ VASurfaceID surface; ///< Associated VA surface ++ unsigned int width; ++ unsigned int height; ++ int is_bound; ++ Pixmap pixmap; ++ GLXPixmap glx_pixmap; ++ GLuint fbo; ++ GLuint fbo_buffer; ++ GLuint fbo_texture; ++ void *priv; ///< Private VA/GLX surface data from driver ++}; ++ ++#endif /* VA_GLX_PRIVATE_H */ +diff --git a/va/va_backend.h b/va/va_backend.h +index ff86744..06fef7f 100644 +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 71cc36f..6826b31 100644 --- libva-0.31.0+latest2.orig/debian/patches/035_g45_add_yv12_image_format.patch +++ libva-0.31.0+latest2/debian/patches/035_g45_add_yv12_image_format.patch @@ -0,0 +1,95 @@ +commit c5cb995d6cd49f5f2988b1721cb6b5da8a9b2c09 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:01:44 2009 +0000 + + [G45] Add YV12 image format. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 9e8502a..6488570 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -54,6 +54,36 @@ enum { + I965_SURFACETYPE_INDEXED + }; + ++/* List of supported image formats */ ++typedef struct { ++ unsigned int type; ++ VAImageFormat va_format; ++} i965_image_format_map_t; ++ ++static const i965_image_format_map_t ++i965_image_formats_map[I965_MAX_IMAGE_FORMATS + 1] = { ++ { I965_SURFACETYPE_YUV, ++ { VA_FOURCC('Y','V','1','2'), VA_LSB_FIRST, 12, } }, ++}; ++ ++static const i965_image_format_map_t * ++get_image_format(const VAImageFormat *va_format) ++{ ++ unsigned int i; ++ for (i = 0; i965_image_formats_map[i].type != 0; i++) { ++ const i965_image_format_map_t * const m = &i965_image_formats_map[i]; ++ if (m->va_format.fourcc == va_format->fourcc && ++ (m->type == I965_SURFACETYPE_RGBA ? ++ (m->va_format.byte_order == va_format->byte_order && ++ m->va_format.red_mask == va_format->red_mask && ++ m->va_format.green_mask == va_format->green_mask && ++ m->va_format.blue_mask == va_format->blue_mask && ++ m->va_format.alpha_mask == va_format->alpha_mask) : 1)) ++ return m; ++ } ++ return NULL; ++} ++ + /* List of supported subpicture formats */ + typedef struct { + unsigned int type; +@@ -398,8 +428,16 @@ i965_QueryImageFormats(VADriverContextP ctx, + VAImageFormat *format_list, /* out */ + int *num_formats) /* out */ + { ++ int n; ++ ++ for (n = 0; i965_image_formats_map[n].va_format.fourcc != 0; n++) { ++ const i965_image_format_map_t * const m = &i965_image_formats_map[n]; ++ if (format_list) ++ format_list[n] = m->va_format; ++ } ++ + if (num_formats) +- *num_formats = 0; ++ *num_formats = n; + + return VA_STATUS_SUCCESS; + } +@@ -1239,6 +1277,16 @@ i965_CreateImage(VADriverContextP ctx, + image->offsets[0] = 0; + image->data_size = image->offsets[0] + image->pitches[0] * height; + break; ++ case VA_FOURCC('Y','V','1','2'): ++ image->num_planes = 3; ++ image->pitches[0] = width; ++ image->offsets[0] = 0; ++ image->pitches[1] = width2; ++ image->offsets[1] = size + size2; ++ image->pitches[2] = width2; ++ image->offsets[2] = size; ++ image->data_size = size + 2 * size2; ++ break; + default: + goto error; + } +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index 2f538c2..be253ed 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -43,7 +43,7 @@ + #define I965_MAX_PROFILES 11 + #define I965_MAX_ENTRYPOINTS 5 + #define I965_MAX_CONFIG_ATTRIBUTES 10 +-#define I965_MAX_IMAGE_FORMATS 10 ++#define I965_MAX_IMAGE_FORMATS 1 + #define I965_MAX_SUBPIC_FORMATS 4 + #define I965_MAX_DISPLAY_ATTRIBUTES 4 + #define I965_STR_VENDOR "i965 Driver 0.1" --- libva-0.31.0+latest2.orig/debian/patches/039_g45_add_vaDeriveImage.patch +++ libva-0.31.0+latest2/debian/patches/039_g45_add_vaDeriveImage.patch @@ -0,0 +1,305 @@ +commit 962608d194ad59b8dc8d62ac1d69d9d5df033aa4 +Author: Gwenole Beauchesne +Date: Mon Mar 8 17:22:06 2010 +0100 + + [G45] Implement vaDeriveImage(). + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index eb3b49d..c349895 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -336,12 +336,27 @@ VAStatus i965_QueryConfigAttributes(VADriverContextP ctx, + return vaStatus; + } + ++static struct object_image * ++i965_CreateImage_impl( ++ VADriverContextP ctx, ++ const VAImageFormat *format, ++ unsigned int width, ++ unsigned int height, ++ VASurfaceID surface ++); ++ ++static void ++i965_DestroyImage_impl( ++ VADriverContextP ctx, ++ struct object_image *obj_image, ++ int from_surface ++); ++ + static void + i965_destroy_surface(struct object_heap *heap, struct object_base *obj) + { + struct object_surface *obj_surface = (struct object_surface *)obj; + +- dri_bo_unreference(obj_surface->bo); + obj_surface->bo = NULL; + object_heap_free(heap, obj); + } +@@ -358,6 +373,13 @@ i965_CreateSurfaces(VADriverContextP ctx, + int i; + VAStatus vaStatus = VA_STATUS_SUCCESS; + ++ /* Internal format: linear I420 (compatible with YV12 VA image) */ ++ static const VAImageFormat vaFormat = { ++ .fourcc = VA_FOURCC('Y','V','1','2'), ++ .byte_order = VA_LSB_FIRST, ++ .bits_per_pixel = 12 ++ }; ++ + /* We only support one format */ + if (VA_RT_FORMAT_YUV420 != format) { + return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; +@@ -366,28 +388,36 @@ i965_CreateSurfaces(VADriverContextP ctx, + for (i = 0; i < num_surfaces; i++) { + int surfaceID = NEW_SURFACE_ID(); + struct object_surface *obj_surface = SURFACE(surfaceID); ++ struct object_image *obj_image; ++ struct object_buffer *obj_buffer; + + if (NULL == obj_surface) { + vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; + break; + } + ++ obj_image = i965_CreateImage_impl(ctx, &vaFormat, width, height, surfaceID); ++ if (!obj_image) { ++ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; ++ break; ++ } ++ ++ obj_buffer = BUFFER(obj_image->image.buf); ++ if (!obj_buffer) { ++ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; ++ break; ++ } ++ assert(obj_buffer->buffer_store); ++ + surfaces[i] = surfaceID; + obj_surface->status = VASurfaceReady; + obj_surface->subpic = VA_INVALID_ID; + obj_surface->width = width; + obj_surface->height = height; + obj_surface->size = SIZE_YUV420(width, height); +- obj_surface->bo = dri_bo_alloc(i965->intel.bufmgr, +- "vaapi surface", +- obj_surface->size, +- 64); +- +- assert(obj_surface->bo); +- if (NULL == obj_surface->bo) { +- vaStatus = VA_STATUS_ERROR_UNKNOWN; +- break; +- } ++ obj_surface->image = obj_image->image; ++ obj_surface->is_derived = 0; ++ obj_surface->bo = obj_buffer->buffer_store->bo; + } + + /* Error recovery */ +@@ -417,6 +447,7 @@ i965_DestroySurfaces(VADriverContextP ctx, + struct object_surface *obj_surface = SURFACE(surface_list[i]); + + assert(obj_surface); ++ i965_DestroyImage_impl(ctx, IMAGE(obj_surface->image.image_id), 1); + i965_destroy_surface(&i965->surface_heap, (struct object_base *)obj_surface); + } + +@@ -1200,29 +1231,28 @@ i965_destroy_heap(struct object_heap *heap, + VAStatus + i965_DestroyImage(VADriverContextP ctx, VAImageID image); + +-VAStatus +-i965_CreateImage(VADriverContextP ctx, +- VAImageFormat *format, +- int width, +- int height, +- VAImage *out_image) /* out */ ++static struct object_image * ++i965_CreateImage_impl( ++ VADriverContextP ctx, ++ const VAImageFormat *format, ++ unsigned int width, ++ unsigned int height, ++ VASurfaceID surface ++) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_image *obj_image; +- VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED; + VAImageID image_id; + unsigned int width2, height2, size2, size; + +- out_image->image_id = VA_INVALID_ID; +- out_image->buf = VA_INVALID_ID; +- + image_id = NEW_IMAGE_ID(); + if (image_id == VA_INVALID_ID) +- return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ return NULL; + + obj_image = IMAGE(image_id); + if (!obj_image) +- return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ return NULL; ++ obj_image->surface = VA_INVALID_ID; + obj_image->bo = NULL; + obj_image->palette = NULL; + +@@ -1275,9 +1305,9 @@ i965_CreateImage(VADriverContextP ctx, + goto error; + } + +- va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, +- image->data_size, 1, NULL, &image->buf); +- if (va_status != VA_STATUS_SUCCESS) ++ if (i965_CreateBuffer(ctx, 0, VAImageBufferType, ++ image->data_size, 1, NULL, ++ &image->buf) != VA_STATUS_SUCCESS) + goto error; + + obj_image->bo = BUFFER(image->buf)->buffer_store->bo; +@@ -1292,21 +1322,47 @@ i965_CreateImage(VADriverContextP ctx, + image->format = *format; + image->width = width; + image->height = height; +- +- *out_image = *image; +- return VA_STATUS_SUCCESS; ++ return obj_image; + + error: +- i965_DestroyImage(ctx, image_id); +- return va_status; ++ i965_DestroyImage_impl(ctx, obj_image, 0); ++ return NULL; ++} ++ ++VAStatus ++i965_CreateImage(VADriverContextP ctx, ++ VAImageFormat *format, ++ int width, ++ int height, ++ VAImage *out_image) /* out */ ++{ ++ struct object_image *obj_image; ++ ++ obj_image = i965_CreateImage_impl(ctx, format, width, height, VA_INVALID_ID); ++ if (!obj_image) ++ return VA_STATUS_ERROR_ALLOCATION_FAILED; ++ ++ *out_image = obj_image->image; ++ return VA_STATUS_SUCCESS; + } + + VAStatus i965_DeriveImage(VADriverContextP ctx, + VASurfaceID surface, + VAImage *image) /* out */ + { +- /* TODO */ +- return VA_STATUS_ERROR_OPERATION_FAILED; ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(obj_surface->image.image_id); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ obj_surface->is_derived = 1; ++ *image = obj_surface->image; ++ return VA_STATUS_SUCCESS; + } + + static void +@@ -1315,15 +1371,24 @@ i965_destroy_image(struct object_heap *heap, struct object_base *obj) + object_heap_free(heap, obj); + } + +- +-VAStatus +-i965_DestroyImage(VADriverContextP ctx, VAImageID image) ++static void ++i965_DestroyImage_impl( ++ VADriverContextP ctx, ++ struct object_image *obj_image, ++ int from_surface ++) + { +- struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct object_image *obj_image = IMAGE(image); ++ struct i965_driver_data * const i965 = i965_driver_data(ctx); + + if (!obj_image) +- return VA_STATUS_SUCCESS; ++ return; ++ ++ if (!from_surface && obj_image->surface != VA_INVALID_ID) { ++ /* only destroy when called from vaDestroySurfaces() */ ++ struct object_surface *obj_surface = SURFACE(obj_image->surface); ++ obj_surface->is_derived = 0; ++ return; ++ } + + if (obj_image->image.buf != VA_INVALID_ID) { + i965_DestroyBuffer(ctx, obj_image->image.buf); +@@ -1336,6 +1401,15 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) + } + + i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); ++} ++ ++VAStatus ++i965_DestroyImage(VADriverContextP ctx, VAImageID image) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ struct object_image *obj_image = IMAGE(image); ++ ++ i965_DestroyImage_impl(ctx, obj_image, 0); + + return VA_STATUS_SUCCESS; + } +@@ -1382,6 +1456,9 @@ i965_GetImage(VADriverContextP ctx, + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + ++ if (obj_surface->is_derived) ++ return VA_STATUS_ERROR_SURFACE_BUSY; ++ + struct object_image *obj_image = IMAGE(image); + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; +@@ -1441,6 +1518,9 @@ i965_PutImage(VADriverContextP ctx, + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + ++ if (obj_surface->is_derived) ++ return VA_STATUS_ERROR_SURFACE_BUSY; ++ + struct object_image *obj_image = IMAGE(image); + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index be253ed..7f410ab 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -96,6 +96,8 @@ struct object_surface + int width; + int height; + int size; ++ VAImage image; ++ int is_derived; + dri_bo *bo; + }; + +@@ -113,6 +115,7 @@ struct object_image + { + struct object_base base; + VAImage image; ++ VASurfaceID surface; + dri_bo *bo; + unsigned int *palette; + }; --- libva-0.31.0+latest2.orig/debian/patches/390_compat.base.patch +++ libva-0.31.0+latest2/debian/patches/390_compat.base.patch @@ -0,0 +1,143 @@ +commit 94db34ae392a7787afac9087799bb0421c844b83 +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:40:56 2009 +0000 + + Add compatibility layer with original VA-API 0.29 to 0.31. + +diff --git a/va/Makefile.am b/va/Makefile.am +index ebff3d5..1752526 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -57,7 +57,7 @@ SUBDIRS = $(libva_x11_backenddir) $(libva_glx_backenddir) + + DIST_SUBDIRS = x11 glx + +-libva_la_SOURCES = va.c va_crystalhd.c ++libva_la_SOURCES = va.c va_crystalhd.c va_compat.c + + libvaincludedir = ${includedir}/va + libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h +@@ -67,4 +67,8 @@ DISTCLEANFILES = \ + + EXTRA_DIST = \ + va_version.h.in \ +- va_crystalhd.h ++ va_crystalhd.h \ ++ va_compat.h \ ++ va_compat_template.h ++ ++va_compat.c: va_compat_template.h +diff --git a/va/va.c b/va/va.c +index 0d208d8..ad201fa 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -28,6 +28,7 @@ + #include "va.h" + #include "va_backend.h" + #include "va_crystalhd.h" ++#include "va_compat.h" + + #include + #include +@@ -39,6 +40,8 @@ + + + #define DRIVER_INIT_FUNC "__vaDriverInit_0_31" ++#define DRIVER_INIT_FUNC_0_29 "__vaDriverInit_0_29" ++#define DRIVER_INIT_FUNC_0_30 "__vaDriverInit_0_30" + + #define DRIVER_EXTENSION "_drv_video.so" + +@@ -163,13 +166,24 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + { + VADriverInit init_func; + char driver_init_func_sds[32]; ++ int compat_version = 0; + /* First, try SDS extensions (VDPAU and XvBA backends) */ + sprintf(driver_init_func_sds, "%s_%d_sds%d", + DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); + init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); + if (!init_func) + { ++ /* Otherwise, we need the compatibility layer for some buffers */ + init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ compat_version = VA_MINOR_VERSION; ++ if (!init_func) { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_29); ++ compat_version = 29; ++ } ++ if (!init_func) { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_0_30); ++ compat_version = 30; ++ } + } + if (!init_func) + { +@@ -178,7 +192,36 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + } + else + { +- vaStatus = (*init_func)(ctx); ++ struct VADriverContext_0_29 ctx_0_29; ++ struct VADriverContext_0_30 ctx_0_30; ++ void *compat_ctx = NULL; ++ ++ switch (compat_version) { ++ case 29: ++ compat_ctx = &ctx_0_29; ++ ctx_0_29.pDriverData = NULL; ++ ctx_0_29.x11_dpy = ctx->x11_dpy; ++ ctx_0_29.x11_screen = ctx->x11_screen; ++ break; ++ case 30: ++ compat_ctx = &ctx_0_30; ++ ctx_0_30.pDriverData = NULL; ++ ctx_0_30.x11_dpy = ctx->x11_dpy; ++ ctx_0_30.x11_screen = ctx->x11_screen; ++ break; ++ case VA_MINOR_VERSION: ++ compat_ctx = ctx; ++ break; ++ default: ++ ASSERT(compat_version == 0); ++ vaStatus = VA_STATUS_ERROR_UNKNOWN; ++ break; ++ } ++ ++ vaStatus = (*init_func)(compat_ctx ? compat_ctx : ctx); ++ ++ if (VA_STATUS_SUCCESS == vaStatus) ++ vaStatus = va_compat_init(dpy, compat_version, compat_ctx); + + if (VA_STATUS_SUCCESS == vaStatus) + { +@@ -399,6 +442,8 @@ VAStatus vaTerminate ( + old_ctx->handle = NULL; + } + ++ va_compat_fini(dpy); ++ + if (VA_STATUS_SUCCESS == vaStatus) + pDisplayContext->vaDestroy(pDisplayContext); + return vaStatus; +diff --git a/va/va_backend.h b/va/va_backend.h +index 06fef7f..9cf8911 100644 +--- a/va/va_backend.h ++++ b/va/va_backend.h +@@ -391,6 +391,7 @@ struct VADriverContext + + void *dri_state; + void *glx; /* opaque for GLX code */ ++ void *compat; /* opaque for compat code */ + }; + + #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ +diff --git a/va/va_compat.c b/va/va_compat.c +new file mode 100644 +index 0000000..af43188 +diff --git a/va/va_compat.h b/va/va_compat.h +new file mode 100644 +index 0000000..2c9d801 +diff --git a/va/va_compat_template.h b/va/va_compat_template.h +new file mode 100644 +index 0000000..18349de --- libva-0.31.0+latest2.orig/debian/patches/203_fix_fglrx_detection.patch +++ libva-0.31.0+latest2/debian/patches/203_fix_fglrx_detection.patch @@ -0,0 +1,538 @@ +commit 02c2bb46ae11a1674927e6e65f990df1dc9ed1ce +Author: Gwenole Beauchesne +Date: Mon Mar 8 09:17:09 2010 +0100 + + Don't link against libdrm to workaround XvBA / fglrx >= 8.66-RC1 bugs. + +diff --git a/va/Makefile.am b/va/Makefile.am +index f382c0e..3b9ccfc 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -36,7 +36,7 @@ libva_la_LDFLAGS = $(LDADD) -no-undefined + libva_la_LIBADD = $(LIBVA_LIBS) -ldl + + libva_x11_la_SOURCES = +-libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(DRM_LIBS) $(XFIXES_LIBS) ++libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) + libva_x11_la_LDFLAGS = $(LDADD) + libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + +diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am +index 40346f1..7466fda 100644 +--- a/va/x11/Makefile.am ++++ b/va/x11/Makefile.am +@@ -25,6 +25,6 @@ noinst_LTLIBRARIES = libva_x11.la + libva_x11includedir = ${includedir}/va + libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h + +-libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c ++libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c libdrm_glue.c + +-EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h ++EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h libdrm_glue.h +diff --git a/va/x11/dri1_util.c b/va/x11/dri1_util.c +index 3e67e2a..f6ce1ba 100644 +--- a/va/x11/dri1_util.c ++++ b/va/x11/dri1_util.c +@@ -1,10 +1,13 @@ ++#include "config.h" ++#include + #include ++#include /* strcasecmp() */ + #include + #include + #include + #include + +-#include ++#include "libdrm_glue.h" + + #include "X11/Xlib.h" + #include "va.h" +@@ -21,6 +24,75 @@ struct dri1_drawable + int height; + }; + ++static int ++firegl_drmOpenMinor(int minor) ++{ ++ char buf[64]; ++ int fd; ++ ++ sprintf(buf, "/dev/ati/card%d", minor); ++ if ((fd = open(buf, O_RDWR, 0)) >= 0) ++ return fd; ++ return -1; ++} ++ ++static int ++firegl_drmOpenByBusID(const char *busid) ++{ ++ int i, fd; ++ drmSetVersion sv; ++ const char *buf; ++ ++ for (i = 0; i < DRM_MAX_MINOR; i++) { ++ if ((fd = firegl_drmOpenMinor(i)) < 0) ++ continue; ++ sv.drm_di_major = 1; ++ sv.drm_di_minor = 1; ++ sv.drm_dd_major = -1; ++ sv.drm_dd_minor = -1; ++ libdrm_drmSetInterfaceVersion(fd, &sv); ++ buf = libdrm_drmGetBusid(fd); ++ if (buf && strcasecmp(buf, busid) == 0) { /* XXX: drmMatchBusID() */ ++ libdrm_drmFreeBusid(buf); ++ return fd; ++ } ++ if (buf) ++ libdrm_drmFreeBusid(buf); ++ close(fd); ++ } ++ return -1; ++} ++ ++static int ++drm_open_once(struct dri_state *dri_state, const char *BusID, int *newlyopened) ++{ ++ dri_state->driConnectedFlag = VA_NONE; ++ dri_state->fd = libdrm_drmOpenOnce(NULL, BusID, newlyopened); ++ if (dri_state->fd < 0) { ++ dri_state->fd = firegl_drmOpenByBusID(BusID); ++ if (dri_state->fd >= 0) { ++ *newlyopened = 1; ++ dri_state->driConnectedFlag |= VA_DRI_AMD; ++ } ++ } ++ return dri_state->fd; ++} ++ ++static void ++drm_close_once(struct dri_state *dri_state) ++{ ++ /* XXX: dri_state->close() doesn't seem to be called, thus this ++ function is never called either */ ++ if (dri_state->fd < 0) ++ return; ++ if (dri_state->driConnectedFlag & VA_DRI_AMD) ++ close(dri_state->fd); ++ else ++ libdrm_drmCloseOnce(dri_state->fd); ++ dri_state->fd = -1; ++ dri_state->driConnectedFlag = VA_NONE; ++} ++ + static struct dri_drawable * + dri1CreateDrawable(VADriverContextP ctx, XID x_drawable) + { +@@ -64,9 +136,9 @@ dri1Close(VADriverContextP ctx) + free_drawable_hashtable(ctx); + VA_DRIDestroyContext(ctx->x11_dpy, ctx->x11_screen, dri_state->hwContextID); + assert(dri_state->pSAREA != MAP_FAILED); +- drmUnmap(dri_state->pSAREA, SAREA_MAX); ++ libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + assert(dri_state->fd >= 0); +- drmCloseOnce(dri_state->fd); ++ drm_close_once(dri_state); + VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); + } + +@@ -104,21 +176,20 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + &dri_state->hSAREA, &BusID)) + goto err_out0; + +- +- dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened); ++ drm_open_once(dri_state, BusID, &newlyopened); + XFree(BusID); + + if (dri_state->fd < 0) + goto err_out1; + + +- if (drmGetMagic(dri_state->fd, &magic)) ++ if (libdrm_drmGetMagic(dri_state->fd, &magic)) + goto err_out1; + + if (newlyopened && !VA_DRIAuthConnection(ctx->x11_dpy, ctx->x11_screen, magic)) + goto err_out1; + +- if (drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA)) ++ if (libdrm_drmMap(dri_state->fd, dri_state->hSAREA, SAREA_MAX, &dri_state->pSAREA)) + goto err_out1; + + if (!VA_DRICreateContext(ctx->x11_dpy, ctx->x11_screen, +@@ -126,7 +197,8 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + &dri_state->hwContextID, &dri_state->hwContext)) + goto err_out1; + +- dri_state->driConnectedFlag = VA_DRI1; ++ dri_state->driConnectedFlag &= VA_DRI_AMD; /* clear flags but AMD bit */ ++ dri_state->driConnectedFlag |= VA_DRI1; + dri_state->createDrawable = dri1CreateDrawable; + dri_state->destroyDrawable = dri1DestroyDrawable; + dri_state->swapBuffer = dri1SwapBuffer; +@@ -137,10 +209,10 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) + + err_out1: + if (dri_state->pSAREA != MAP_FAILED) +- drmUnmap(dri_state->pSAREA, SAREA_MAX); ++ libdrm_drmUnmap(dri_state->pSAREA, SAREA_MAX); + + if (dri_state->fd >= 0) +- drmCloseOnce(dri_state->fd); ++ drm_close_once(dri_state); + + VA_DRICloseConnection(ctx->x11_dpy, ctx->x11_screen); + +diff --git a/va/x11/dri2_util.c b/va/x11/dri2_util.c +index ebe7a2c..b727e97 100644 +--- a/va/x11/dri2_util.c ++++ b/va/x11/dri2_util.c +@@ -3,7 +3,7 @@ + #include + #include + +-#include ++#include "libdrm_glue.h" + + #include + #include +@@ -166,7 +166,7 @@ isDRI2Connected(VADriverContextP ctx, char **driver_name) + if (dri_state->fd < 0) + goto err_out; + +- if (drmGetMagic(dri_state->fd, &magic)) ++ if (libdrm_drmGetMagic(dri_state->fd, &magic)) + goto err_out; + + if (!VA_DRI2Authenticate(ctx->x11_dpy, RootWindow(ctx->x11_dpy, ctx->x11_screen), +diff --git a/va/x11/libdrm_glue.c b/va/x11/libdrm_glue.c +new file mode 100644 +index 0000000..92c7d60 +--- /dev/null ++++ b/va/x11/libdrm_glue.c +@@ -0,0 +1,209 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#define _GNU_SOURCE 1 ++#include "libdrm_glue.h" ++#include ++#include ++#include ++#include ++#include ++ ++#define LOAD_FUNC_(NAME, RET, ARGS, FALLBACK) \ ++ static RET (*lib_##NAME) ARGS; \ ++ if (lib_##NAME == NULL) { \ ++ lib_##NAME = libdrm_symbol(#NAME); \ ++ if (!lib_##NAME) \ ++ lib_##NAME = FALLBACK; \ ++ } \ ++ assert(lib_##NAME != NULL) ++ ++#define LOAD_FUNC(NAME, RET, ARGS) \ ++ LOAD_FUNC_(NAME, RET, ARGS, NULL) ++ ++static void *libdrm_handle; ++static int libdrm_handle_ok = -1; ++ ++static inline void *libdrm_symbol(const char *name) ++{ ++ if (!libdrm_open()) ++ return NULL; ++ return dlsym(libdrm_handle, name); ++} ++ ++int libdrm_open(void) ++{ ++ if (libdrm_handle_ok < 0) { ++ libdrm_handle = dlopen("libdrm.so.2", RTLD_LOCAL|RTLD_LAZY); ++ libdrm_handle_ok = libdrm_handle != NULL; ++ } ++ assert(libdrm_handle); ++ return libdrm_handle_ok; ++} ++ ++void libdrm_close(void) ++{ ++ if (libdrm_handle) ++ dlclose(libdrm_handle); ++} ++ ++// Default drmOpenOnce() and drmCloseOnce() implementations based on current GIT ++#define DRM_MAX_FDS 16 ++static struct { ++ char *BusID; ++ int fd; ++ int refcount; ++} connection[DRM_MAX_FDS]; ++ ++static int nr_fds = 0; ++ ++// Default implementation for drmOpenOnce() if none exists in the library ++static int ++libdrm_default_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++{ ++ int i; ++ int fd; ++ ++ for (i = 0; i < nr_fds; i++) ++ if (strcmp(BusID, connection[i].BusID) == 0) { ++ connection[i].refcount++; ++ *newlyopened = 0; ++ return connection[i].fd; ++ } ++ ++ fd = libdrm_drmOpen(unused, BusID); ++ if (fd <= 0 || nr_fds == DRM_MAX_FDS) ++ return fd; ++ ++ connection[nr_fds].BusID = strdup(BusID); ++ connection[nr_fds].fd = fd; ++ connection[nr_fds].refcount = 1; ++ *newlyopened = 1; ++ ++ if (0) ++ fprintf(stderr, "saved connection %d for %s %d\n", ++ nr_fds, connection[nr_fds].BusID, ++ strcmp(BusID, connection[nr_fds].BusID)); ++ nr_fds++; ++ return fd; ++} ++ ++// Default implementation for drmCloseOnce() if none exists in the library ++static void libdrm_default_drmCloseOnce(int fd) ++{ ++ int i; ++ ++ for (i = 0; i < nr_fds; i++) { ++ if (fd == connection[i].fd) { ++ if (--connection[i].refcount == 0) { ++ libdrm_drmClose(connection[i].fd); ++ free(connection[i].BusID); ++ if (i < --nr_fds) ++ connection[i] = connection[nr_fds]; ++ return; ++ } ++ } ++ } ++} ++ ++// Determine whether the DRM kernel driver has been loaded ++int libdrm_drmAvailable(void) ++{ ++ LOAD_FUNC(drmAvailable, int, (void)); ++ return lib_drmAvailable(); ++} ++ ++// Open the DRM device ++int libdrm_drmOpen(const char *name, const char *busid) ++{ ++ LOAD_FUNC(drmOpen, int, (const char *, const char *)); ++ return lib_drmOpen(name, busid); ++} ++ ++// Close the device ++int libdrm_drmClose(int fd) ++{ ++ LOAD_FUNC(drmClose, int, (int)); ++ return lib_drmClose(fd); ++} ++ ++// Open the DRM device (re-use an existing connection) ++int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++{ ++ LOAD_FUNC_(drmOpenOnce, int, (void *, const char *, int *), ++ libdrm_default_drmOpenOnce); ++ return lib_drmOpenOnce(unused, BusID, newlyopened); ++} ++ ++// Close the device (unref an existing connection prior to actually closing it) ++void libdrm_drmCloseOnce(int fd) ++{ ++ LOAD_FUNC_(drmCloseOnce, void, (int), libdrm_default_drmCloseOnce); ++ lib_drmCloseOnce(fd); ++} ++ ++// DRM connection cookie ++int libdrm_drmGetMagic(int fd, drm_magic_t * magic) ++{ ++ LOAD_FUNC(drmGetMagic, int, (int, drm_magic_t *)); ++ return lib_drmGetMagic(fd, magic); ++} ++ ++// Issue a set-version ioctl ++int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) ++{ ++ LOAD_FUNC(drmSetInterfaceVersion, int, (int, drmSetVersion *)); ++ return lib_drmSetInterfaceVersion(fd, version); ++} ++ ++// Get the bus ID of the device ++char *libdrm_drmGetBusid(int fd) ++{ ++ LOAD_FUNC(drmGetBusid, char *, (int)); ++ return lib_drmGetBusid(fd); ++} ++ ++// Free the bus ID information ++void libdrm_drmFreeBusid(const char *busid) ++{ ++ LOAD_FUNC(drmFreeBusid, void, (const char *)); ++ lib_drmFreeBusid(busid); ++} ++ ++// Map a region of memory ++int libdrm_drmMap(int fd, ++ drm_handle_t handle, ++ drmSize size, ++ drmAddressPtr address) ++{ ++ LOAD_FUNC(drmMap, int, (int, drm_handle_t, drmSize, drmAddressPtr)); ++ return lib_drmMap(fd, handle, size, address); ++} ++ ++// Unmap mappings obtained with drmMap() ++int libdrm_drmUnmap(drmAddress address, drmSize size) ++{ ++ LOAD_FUNC(drmUnmap, int, (drmAddress, drmSize)); ++ return lib_drmUnmap(address, size); ++} +diff --git a/va/x11/libdrm_glue.h b/va/x11/libdrm_glue.h +new file mode 100644 +index 0000000..878470b +--- /dev/null ++++ b/va/x11/libdrm_glue.h +@@ -0,0 +1,73 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef LIBDRM_GLUE_H ++#define LIBDRM_GLUE_H ++ ++#include "config.h" ++#include ++ ++int libdrm_open(void) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_close(void) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmAvailable(void) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmOpen(const char *name, const char *busid) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmClose(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmOpenOnce(void *unused, const char *BusID, int *newlyopened) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_drmCloseOnce(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmGetMagic(int fd, drm_magic_t * magic) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmSetInterfaceVersion(int fd, drmSetVersion *version) ++ ATTRIBUTE_HIDDEN; ++ ++char *libdrm_drmGetBusid(int fd) ++ ATTRIBUTE_HIDDEN; ++ ++void libdrm_drmFreeBusid(const char *busid) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmMap(int fd, ++ drm_handle_t handle, ++ drmSize size, ++ drmAddressPtr address) ++ ATTRIBUTE_HIDDEN; ++ ++int libdrm_drmUnmap(drmAddress address, drmSize size) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* LIBDRM_GLUE_H */ +diff --git a/va/x11/va_dricommon.h b/va/x11/va_dricommon.h +index b762bd0..5ed7a6a 100644 +--- a/va/x11/va_dricommon.h ++++ b/va/x11/va_dricommon.h +@@ -13,7 +13,8 @@ enum + { + VA_NONE = 0, + VA_DRI1 = 1, +- VA_DRI2 = 2 ++ VA_DRI2 = 2, ++ VA_DRI_AMD = 4 /* AMD DRI implementation */ + }; + + union dri_buffer +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 78e38de..1216093 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -31,6 +31,7 @@ + #include "va_dri2.h" + #include "va_dricommon.h" + #include "va_nvctrl.h" ++#include "libdrm_glue.h" + #include + #include + #include +@@ -75,6 +76,8 @@ static void va_DisplayContextDestroy ( + } + ctx = &((*ctx)->pNext); + } ++ ++ libdrm_close(); + free(pDisplayContext->pDriverContext->dri_state); + free(pDisplayContext->pDriverContext); + free(pDisplayContext); --- libva-0.31.0+latest2.orig/debian/patches/202_check_crystalhd.patch +++ libva-0.31.0+latest2/debian/patches/202_check_crystalhd.patch @@ -0,0 +1,155 @@ +commit 0eeee71bcd334512a6b86702ee612b35feb644b2 +Author: Gwenole Beauchesne +Date: Tue Feb 23 10:05:25 2010 +0000 + + Detect Broadcom Crystal HD chip. + +diff --git a/va/Makefile.am b/va/Makefile.am +index aeaf82f..f382c0e 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -42,7 +42,7 @@ libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + + SUBDIRS = x11 + +-libva_la_SOURCES = va.c ++libva_la_SOURCES = va.c va_crystalhd.c + + libvaincludedir = ${includedir}/va + libvainclude_HEADERS = va.h va_x11.h va_backend.h va_version.h +@@ -51,4 +51,5 @@ DISTCLEANFILES = \ + va_version.h + + EXTRA_DIST = \ +- va_version.h.in ++ va_version.h.in \ ++ va_crystalhd.h +diff --git a/va/va.c b/va/va.c +index b5940e5..fd68481 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -24,8 +24,10 @@ + + #define _GNU_SOURCE 1 + ++#include "config.h" + #include "va.h" + #include "va_backend.h" ++#include "va_crystalhd.h" + + #include + #include +@@ -349,6 +351,15 @@ VAStatus vaInitialize ( + vaStatus = va_openDriver(dpy, driver_name); + va_infoMessage("va_openDriver() returns %d\n", vaStatus); + ++ if (vaStatus != VA_STATUS_SUCCESS && !driver_name_env) ++ { ++ if (va_hasCrystalHD()) ++ { ++ vaStatus = va_openDriver(dpy, "crystalhd"); ++ va_infoMessage("va_openDriver() returns %d\n", vaStatus); ++ } ++ } ++ + *major_version = VA_MAJOR_VERSION; + *minor_version = VA_MINOR_VERSION; + } +diff --git a/va/va_crystalhd.c b/va/va_crystalhd.c +new file mode 100644 +index 0000000..1ddd4fe +--- /dev/null ++++ b/va/va_crystalhd.c +@@ -0,0 +1,54 @@ ++/* ++ * Copyright (C) 2010 Splitted-Desktop Systems. 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 ++#include ++#include ++#include "config.h" ++#include "va_crystalhd.h" ++ ++/* Checks if the Broadcom Crystal HD decoder is available */ ++int va_hasCrystalHD(void) ++{ ++ char line[1024]; ++ int len, vendor, device, dummy, found = 0; ++ FILE *fp; ++ ++ fp = fopen("/proc/bus/pci/devices", "r"); ++ if (!fp) ++ return 0; ++ ++ while (!found && fgets(line, sizeof(line), fp)) { ++ len = strlen(line); ++ if (len == 0) ++ continue; ++ line[len - 1] = 0; ++ if (sscanf(line, "%x %04x%04x", &dummy, &vendor, &device) == 3) { ++ if (vendor == 0x14e4 && device == 0x1612) /* BCM70012 */ ++ found = 1; ++ } ++ } ++ fclose(fp); ++ return found; ++} +diff --git a/va/va_crystalhd.h b/va/va_crystalhd.h +new file mode 100644 +index 0000000..44a39d9 +--- /dev/null ++++ b/va/va_crystalhd.h +@@ -0,0 +1,32 @@ ++/* ++ * Copyright (C) 2010 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_CRYSTALHD_H ++#define VA_CRYSTALHD_H ++ ++/** Checks if the Broadcom Crystal HD decoder is available */ ++int va_hasCrystalHD(void) ++ ATTRIBUTE_HIDDEN; ++ ++#endif /* VA_CRYSTALHD_H */ --- libva-0.31.0+latest2.orig/debian/patches/038_g45_vaPutSurface_cliprects.patch +++ libva-0.31.0+latest2/debian/patches/038_g45_vaPutSurface_cliprects.patch @@ -0,0 +1,523 @@ +commit ab248483d89c6cf7beb7a3a87c9b9a55464023cc +Author: Gwenole Beauchesne +Date: Wed Nov 4 17:34:53 2009 +0000 + + [G45] Handle cliprects in vaPutSurface(). + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 5c15439..d4ad6e1 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -1507,13 +1507,23 @@ i965_PutSurface(VADriverContextP ctx, + union dri_buffer *buffer; + struct intel_region *dest_region; + struct object_surface *obj_surface; +- int ret; ++ int ret; + uint32_t name; ++ VARectangle src_rect, dst_rect; + Bool new_region = False; ++ + /* Currently don't support DRI1 */ + if (dri_state->driConnectedFlag != VA_DRI2) + return VA_STATUS_ERROR_UNKNOWN; + ++ /* XXX: we currently only support up to 64 cliprects */ ++ if (number_cliprects > MAX_CLIP_RECTS) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ + dri_drawable = dri_get_drawable(ctx, draw); + assert(dri_drawable); + +@@ -1552,17 +1562,24 @@ i965_PutSurface(VADriverContextP ctx, + assert(ret == 0); + } + +- i965_render_put_surface(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- obj_surface = SURFACE(surface); +- if(obj_surface->subpic != VA_INVALID_ID) { +- i965_render_put_subpic(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- } +- dri_swap_buffer(ctx, dri_drawable); ++ src_rect.x = srcx; ++ src_rect.y = srcy; ++ src_rect.width = srcw; ++ src_rect.height = srch; ++ ++ dst_rect.x = destx; ++ dst_rect.y = desty; ++ dst_rect.width = destw; ++ dst_rect.height = desth; + ++ i965_render_put_surface(ctx, surface, &src_rect, &dst_rect, ++ cliprects, number_cliprects); ++ ++ if (obj_surface->subpic != VA_INVALID_ID) ++ i965_render_put_subpic(ctx, surface, &src_rect, &dst_rect, ++ cliprects, number_cliprects); ++ ++ dri_swap_buffer(ctx, dri_drawable); + return VA_STATUS_SUCCESS; + } + +diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c +index c738d22..301d51d 100644 +--- a/i965_drv_video/i965_render.c ++++ b/i965_drv_video/i965_render.c +@@ -788,13 +788,81 @@ i965_render_binding_table(VADriverContextP ctx) + dri_bo_unmap(render_state->wm.binding_table); + } + +-static void ++static unsigned int ++i965_render_do_upload_vertex(VADriverContextP ctx, ++ unsigned int width, ++ unsigned int height, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ struct i965_render_state *render_state = &i965->render_state; ++ struct intel_region *dest_region = render_state->draw_region; ++ float *vb, tx1, tx2, ty1, ty2; ++ int x1, x2, y1, y2; ++ unsigned int i, n; ++ ++ if (!cliprects || num_cliprects == 0) { ++ cliprects = dst_rect; ++ num_cliprects = 1; ++ } ++ ++ dri_bo_map(render_state->vb.vertex_buffer, 1); ++ assert(render_state->vb.vertex_buffer->virtual); ++ vb = render_state->vb.vertex_buffer->virtual; ++ ++ for (n = 0, i = 0; i < num_cliprects; i++) { ++ x1 = dest_region->x + cliprects[i].x; ++ y1 = dest_region->y + cliprects[i].y; ++ x2 = x1 + cliprects[i].width; ++ y2 = y1 + cliprects[i].height; ++ x1 = MAX(x1, dst_rect->x); ++ y1 = MAX(y1, dst_rect->y); ++ x2 = MIN(x2, dst_rect->x + dst_rect->width); ++ y2 = MIN(y2, dst_rect->y + dst_rect->height); ++ ++ if (x2 <= x1 || y2 <= y1) ++ continue; ++ ++ const float sx1 = (float)(x1 - dst_rect->x) / (float)dst_rect->width; ++ const float sy1 = (float)(y1 - dst_rect->y) / (float)dst_rect->height; ++ const float sx2 = (float)(x2 - dst_rect->x) / (float)dst_rect->width; ++ const float sy2 = (float)(y2 - dst_rect->y) / (float)dst_rect->height; ++ tx1 = ((float)src_rect->x + sx1 * (float)src_rect->width) / width; ++ ty1 = ((float)src_rect->y + sy1 * (float)src_rect->height) / height; ++ tx2 = ((float)src_rect->x + sx2 * (float)src_rect->width) / width; ++ ty2 = ((float)src_rect->y + sy2 * (float)src_rect->height) / height; ++ ++ vb[n++] = tx2; ++ vb[n++] = ty2; ++ vb[n++] = x2; ++ vb[n++] = y2; ++ ++ vb[n++] = tx1; ++ vb[n++] = ty2; ++ vb[n++] = x1; ++ vb[n++] = y2; ++ ++ vb[n++] = tx1; ++ vb[n++] = ty1; ++ vb[n++] = x1; ++ vb[n++] = y1; ++ } ++ ++ dri_bo_unmap(render_state->vb.vertex_buffer); ++ return n / 12; ++} ++ ++static unsigned int + i965_subpic_render_upload_vertex(VADriverContextP ctx, + VASurfaceID surface, +- const VARectangle *output_rect) +-{ ++ const VARectangle *output_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) ++{ + struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct i965_render_state *render_state = &i965->render_state; + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); + +@@ -804,8 +872,6 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx, + const float ssy = (float)output_rect->height / (float)obj_surface->height; + const float sx = psx * ssx; + const float sy = psy * ssy; +- float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; +- int i = 0; + + VARectangle dst_rect; + dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; +@@ -813,106 +879,38 @@ i965_subpic_render_upload_vertex(VADriverContextP ctx, + dst_rect.width = sx * (float)obj_subpic->dst_rect.width; + dst_rect.height = sy * (float)obj_subpic->dst_rect.height; + +- dri_bo_map(render_state->vb.vertex_buffer, 1); +- assert(render_state->vb.vertex_buffer->virtual); +- vb = render_state->vb.vertex_buffer->virtual; +- +- tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; +- ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; +- tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; +- ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; +- +- x1 = (float)dst_rect.x; +- y1 = (float)dst_rect.y; +- x2 = (float)(dst_rect.x + dst_rect.width); +- y2 = (float)(dst_rect.y + dst_rect.height); +- +- vb[i++] = tx2; +- vb[i++] = ty2; +- vb[i++] = x2; +- vb[i++] = y2; +- +- vb[i++] = tx1; +- vb[i++] = ty2; +- vb[i++] = x1; +- vb[i++] = y2; +- +- vb[i++] = tx1; +- vb[i++] = ty1; +- vb[i++] = x1; +- vb[i++] = y1; +- dri_bo_unmap(render_state->vb.vertex_buffer); ++ return i965_render_do_upload_vertex(ctx, ++ obj_subpic->width, obj_subpic->height, ++ &obj_subpic->src_rect, &dst_rect, ++ cliprects, num_cliprects); + } + +-static void ++static unsigned int + i965_render_upload_vertex(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); +- struct i965_render_state *render_state = &i965->render_state; +- struct intel_region *dest_region = render_state->draw_region; +- struct object_surface *obj_surface; +- float *vb; +- +- float u1, v1, u2, v2; +- int i, width, height; +- int box_x1 = dest_region->x + destx; +- int box_y1 = dest_region->y + desty; +- int box_x2 = box_x1 + destw; +- int box_y2 = box_y1 + desth; +- +- obj_surface = SURFACE(surface); +- assert(surface); +- width = obj_surface->width; +- height = obj_surface->height; +- +- u1 = (float)srcx / width; +- v1 = (float)srcy / height; +- u2 = (float)(srcx + srcw) / width; +- v2 = (float)(srcy + srch) / height; +- +- dri_bo_map(render_state->vb.vertex_buffer, 1); +- assert(render_state->vb.vertex_buffer->virtual); +- vb = render_state->vb.vertex_buffer->virtual; +- +- i = 0; +- vb[i++] = u2; +- vb[i++] = v2; +- vb[i++] = (float)box_x2; +- vb[i++] = (float)box_y2; +- +- vb[i++] = u1; +- vb[i++] = v2; +- vb[i++] = (float)box_x1; +- vb[i++] = (float)box_y2; +- +- vb[i++] = u1; +- vb[i++] = v1; +- vb[i++] = (float)box_x1; +- vb[i++] = (float)box_y1; ++ struct object_surface *obj_surface = SURFACE(surface); ++ assert(obj_surface); + +- dri_bo_unmap(render_state->vb.vertex_buffer); ++ return i965_render_do_upload_vertex(ctx, ++ obj_surface->width, obj_surface->height, ++ src_rect, ++ dst_rect, ++ cliprects, num_cliprects); + } + +-static void ++static unsigned int + i965_surface_render_state_setup(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + i965_render_vs_unit(ctx); + i965_render_sf_unit(ctx); +@@ -923,21 +921,17 @@ i965_surface_render_state_setup(VADriverContextP ctx, + i965_render_cc_viewport(ctx); + i965_render_cc_unit(ctx); + i965_render_binding_table(ctx); +- i965_render_upload_vertex(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); ++ return i965_render_upload_vertex(ctx, surface, src_rect, dst_rect, ++ cliprects, num_cliprects); + } +-static void ++ ++static unsigned int + i965_subpic_render_state_setup(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + i965_render_vs_unit(ctx); + i965_render_sf_unit(ctx); +@@ -948,16 +942,10 @@ i965_subpic_render_state_setup(VADriverContextP ctx, + i965_render_cc_viewport(ctx); + i965_subpic_render_cc_unit(ctx); + i965_render_binding_table(ctx); +- +- VARectangle output_rect; +- output_rect.x = destx; +- output_rect.y = desty; +- output_rect.width = destw; +- output_rect.height = desth; +- i965_subpic_render_upload_vertex(ctx, surface, &output_rect); ++ return i965_subpic_render_upload_vertex(ctx, surface, dst_rect, ++ cliprects, num_cliprects); + } + +- + static void + i965_render_pipeline_select(VADriverContextP ctx) + { +@@ -1193,7 +1181,7 @@ i965_render_upload_image_palette( + } + + static void +-i965_render_startup(VADriverContextP ctx) ++i965_render_startup(VADriverContextP ctx, unsigned int vb_offset) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_render_state *render_state = &i965->render_state; +@@ -1204,7 +1192,7 @@ i965_render_startup(VADriverContextP ctx) + (0 << VB0_BUFFER_INDEX_SHIFT) | + VB0_VERTEXDATA | + ((4 * 4) << VB0_BUFFER_PITCH_SHIFT)); +- OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 0); ++ OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, vb_offset); + + if (IS_IGDNG(i965->intel.device_id)) + OUT_RELOC(ctx, render_state->vb.vertex_buffer, I915_GEM_DOMAIN_VERTEX, 0, 12 * 4); +@@ -1269,8 +1257,10 @@ i965_clear_dest_region(VADriverContextP ctx) + } + + static void +-i965_surface_render_pipeline_setup(VADriverContextP ctx) ++i965_surface_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) + { ++ unsigned int i; ++ + intel_batchbuffer_start_atomic(ctx, 0x1000); + intel_batchbuffer_emit_mi_flush(ctx); + i965_clear_dest_region(ctx); +@@ -1284,13 +1274,16 @@ i965_surface_render_pipeline_setup(VADriverContextP ctx) + i965_render_cs_urb_layout(ctx); + i965_render_drawing_rectangle(ctx); + i965_render_vertex_elements(ctx); +- i965_render_startup(ctx); ++ for (i = 0; i < n_rects; i++) ++ i965_render_startup(ctx, 48 * i); + intel_batchbuffer_end_atomic(ctx); + } + + static void +-i965_subpic_render_pipeline_setup(VADriverContextP ctx) ++i965_subpic_render_pipeline_setup(VADriverContextP ctx, unsigned int n_rects) + { ++ unsigned int i; ++ + intel_batchbuffer_start_atomic(ctx, 0x1000); + intel_batchbuffer_emit_mi_flush(ctx); + i965_render_pipeline_select(ctx); +@@ -1303,7 +1296,8 @@ i965_subpic_render_pipeline_setup(VADriverContextP ctx) + i965_render_cs_urb_layout(ctx); + i965_render_drawing_rectangle(ctx); + i965_render_vertex_elements(ctx); +- i965_render_startup(ctx); ++ for (i = 0; i < n_rects; i++) ++ i965_render_startup(ctx, 48 * i); + intel_batchbuffer_end_atomic(ctx); + } + +@@ -1397,45 +1391,39 @@ i965_render_initialize(VADriverContextP ctx) + void + i965_render_put_surface(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { ++ unsigned int n_rects; ++ + i965_render_initialize(ctx); +- i965_surface_render_state_setup(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- i965_surface_render_pipeline_setup(ctx); ++ n_rects = i965_surface_render_state_setup(ctx, surface, ++ src_rect, dst_rect, ++ cliprects, num_cliprects); ++ i965_surface_render_pipeline_setup(ctx, n_rects); + intel_batchbuffer_flush(ctx); + } + + void + i965_render_put_subpic(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth) ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); ++ unsigned int n_rects; + assert(obj_subpic); + + i965_render_initialize(ctx); +- i965_subpic_render_state_setup(ctx, surface, +- srcx, srcy, srcw, srch, +- destx, desty, destw, desth); +- i965_subpic_render_pipeline_setup(ctx); ++ n_rects = i965_subpic_render_state_setup(ctx, surface, src_rect, dst_rect, ++ cliprects, num_cliprects); ++ i965_subpic_render_pipeline_setup(ctx, n_rects); + i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); + intel_batchbuffer_flush(ctx); + } +diff --git a/i965_drv_video/i965_render.h b/i965_drv_video/i965_render.h +index e3dce02..d2e23f1 100644 +--- a/i965_drv_video/i965_render.h ++++ b/i965_drv_video/i965_render.h +@@ -28,6 +28,7 @@ + #ifndef _I965_RENDER_H_ + #define _I965_RENDER_H_ + ++#define MAX_CLIP_RECTS 80 /* vb_bo:4096 / vb:(3*4*4) */ + #define MAX_RENDER_SURFACES 16 + #define MAX_SAMPLERS 16 + +@@ -65,27 +66,20 @@ struct i965_render_state + + Bool i965_render_init(VADriverContextP ctx); + Bool i965_render_terminate(VADriverContextP ctx); ++ + void i965_render_put_surface(VADriverContextP ctx, + VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth); +- ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects); + + void + i965_render_put_subpic(VADriverContextP ctx, +- VASurfaceID surface, +- short srcx, +- short srcy, +- unsigned short srcw, +- unsigned short srch, +- short destx, +- short desty, +- unsigned short destw, +- unsigned short desth); ++ VASurfaceID surface, ++ const VARectangle *src_rect, ++ const VARectangle *dst_rect, ++ const VARectangle *cliprects, ++ unsigned int num_cliprects); ++ + #endif /* _I965_RENDER_H_ */ --- libva-0.31.0+latest2.orig/debian/patches/037_g45_add_vaPutImage.patch +++ libva-0.31.0+latest2/debian/patches/037_g45_add_vaPutImage.patch @@ -0,0 +1,102 @@ +commit c00ac73b0fa1f5c4ff9cdc76b7556c5db03c5335 +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:36:39 2009 +0000 + + [G45] Implement vaPutImage() for full-sized surface uploads. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 59ebdd7..5c15439 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -443,22 +443,6 @@ i965_QueryImageFormats(VADriverContextP ctx, + } + + VAStatus +-i965_PutImage(VADriverContextP ctx, +- VASurfaceID surface, +- VAImageID image, +- int src_x, +- int src_y, +- unsigned int src_width, +- unsigned int src_height, +- int dest_x, +- int dest_y, +- unsigned int dest_width, +- unsigned int dest_height) +-{ +- return VA_STATUS_SUCCESS; +-} +- +-VAStatus + i965_QuerySubpictureFormats(VADriverContextP ctx, + VAImageFormat *format_list, /* out */ + unsigned int *flags, /* out */ +@@ -1439,6 +1423,68 @@ i965_GetImage(VADriverContextP ctx, + } + + VAStatus ++i965_PutImage(VADriverContextP ctx, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int src_width, ++ unsigned int src_height, ++ int dest_x, ++ int dest_y, ++ unsigned int dest_width, ++ unsigned int dest_height) ++{ ++ struct i965_driver_data *i965 = i965_driver_data(ctx); ++ ++ struct object_surface *obj_surface = SURFACE(surface); ++ if (!obj_surface) ++ return VA_STATUS_ERROR_INVALID_SURFACE; ++ ++ struct object_image *obj_image = IMAGE(image); ++ if (!obj_image) ++ return VA_STATUS_ERROR_INVALID_IMAGE; ++ ++ /* XXX: we don't support partial video surface updates */ ++ if (src_x != 0 || ++ src_y != 0 || ++ src_width != obj_image->image.width || ++ src_height != obj_image->image.height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (dest_x != 0 || ++ dest_y != 0 || ++ dest_width != obj_surface->width || ++ dest_height != obj_surface->height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ if (src_width != dest_width || ++ src_height != dest_height) ++ return VA_STATUS_ERROR_OPERATION_FAILED; ++ ++ VAStatus va_status; ++ void *image_data = NULL; ++ ++ va_status = i965_MapBuffer(ctx, obj_image->image.buf, &image_data); ++ if (va_status != VA_STATUS_SUCCESS) ++ return va_status; ++ ++ dri_bo_map(obj_surface->bo, 1); ++ ++ switch (obj_image->image.format.fourcc) { ++ case VA_FOURCC('Y','V','1','2'): /* YV12 is native format here */ ++ memcpy(obj_surface->bo->virtual, image_data, obj_surface->bo->size); ++ break; ++ default: ++ va_status = VA_STATUS_ERROR_OPERATION_FAILED; ++ break; ++ } ++ ++ dri_bo_unmap(obj_surface->bo); ++ ++ i965_UnmapBuffer(ctx, obj_image->image.buf); ++ return va_status; ++} ++ ++VAStatus + i965_PutSurface(VADriverContextP ctx, + VASurfaceID surface, + Drawable draw, /* X Drawable */ --- libva-0.31.0+latest2.orig/debian/patches/392_compat.dso.patch +++ libva-0.31.0+latest2/debian/patches/392_compat.dso.patch @@ -0,0 +1,183 @@ +commit 23dc87f7a37ea245e9797b947df6fbd3c911dd76 +Author: Gwenole Beauchesne +Date: Fri Oct 16 12:39:06 2009 +0000 + + Fix compatibility with older programs linked against libva.so.0. + +diff --git a/va/Makefile.am b/va/Makefile.am +index 1752526..f92ba8a 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -72,3 +72,8 @@ EXTRA_DIST = \ + va_compat_template.h + + va_compat.c: va_compat_template.h ++ ++lib_LTLIBRARIES += libva-compat.la ++libva_compat_la_SOURCES = va_compat_lib.c ++libva_compat_la_LIBADD = libva-x11.la -ldl ++libva_compat_la_DEPENDENCIES = libva-x11.la +diff --git a/va/va_compat_lib.c b/va/va_compat_lib.c +new file mode 100644 +index 0000000..b7e9ea5 +--- /dev/null ++++ b/va/va_compat_lib.c +@@ -0,0 +1,158 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#define _GNU_SOURCE 1 ++#include ++#include ++#include ++ ++typedef void *VADisplay; ++typedef int VAStatus; ++typedef unsigned int VAGenericID; ++typedef VAGenericID VAContextID; ++typedef VAGenericID VASurfaceID; ++typedef VAGenericID VAImageID; ++typedef VAGenericID VASubpictureID; ++ ++#define PREPARE_FUNC(NAME, RET, ARGS) \ ++ static RET (*lib_##NAME) ARGS; \ ++ if (lib_##NAME == NULL) \ ++ lib_##NAME = dlsym(RTLD_NEXT, #NAME); \ ++ assert(lib_##NAME != NULL) ++ ++VAStatus ++vaSyncSurface( ++ VADisplay dpy, ++ VAContextID context, ++ VASurfaceID render_target ++) ++{ ++ PREPARE_FUNC(vaSyncSurface, VAStatus, (VADisplay, VASurfaceID)); ++ ++ return lib_vaSyncSurface(dpy, render_target); ++} ++ ++VAStatus ++vaPutImage( ++ VADisplay dpy, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int width, ++ unsigned int height, ++ int dest_x, ++ int dest_y ++) ++{ ++ PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, ++ int, int, unsigned int, unsigned int, ++ int, int, unsigned int, unsigned int)); ++ ++ return lib_vaPutImage(dpy, surface, image, ++ src_x, src_y, width, height, ++ dest_x, dest_y, width, height); ++} ++ ++VAStatus ++vaPutImage2( ++ VADisplay dpy, ++ VASurfaceID surface, ++ VAImageID image, ++ int src_x, ++ int src_y, ++ unsigned int src_width, ++ unsigned int src_height, ++ int dest_x, ++ int dest_y, ++ unsigned int dest_width, ++ unsigned int dest_height ++) ++{ ++ PREPARE_FUNC(vaPutImage, VAStatus, (VADisplay, VASurfaceID, VAImageID, ++ int, int, unsigned int, unsigned int, ++ int, int, unsigned int, unsigned int)); ++ ++ return lib_vaPutImage(dpy, surface, image, ++ src_x, src_y, src_width, src_height, ++ dest_x, dest_y, dest_width, dest_height); ++} ++ ++VAStatus ++vaAssociateSubpicture( ++ VADisplay dpy, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, ++ short src_y, ++ short dest_x, ++ short dest_y, ++ unsigned short width, ++ unsigned short height, ++ unsigned int flags ++) ++{ ++ PREPARE_FUNC(vaAssociateSubpicture, ++ VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, ++ short, short, unsigned short, unsigned short, ++ short, short, unsigned short, unsigned short, ++ unsigned int)); ++ ++ return lib_vaAssociateSubpicture(dpy, subpicture, ++ target_surfaces, num_surfaces, ++ src_x, src_y, width, height, ++ dest_x, dest_y, width, height, ++ flags); ++} ++ ++VAStatus ++vaAssociateSubpicture2( ++ VADisplay dpy, ++ VASubpictureID subpicture, ++ VASurfaceID *target_surfaces, ++ int num_surfaces, ++ short src_x, ++ short src_y, ++ unsigned short src_width, ++ unsigned short src_height, ++ short dest_x, ++ short dest_y, ++ unsigned short dest_width, ++ unsigned short dest_height, ++ unsigned int flags ++) ++{ ++ PREPARE_FUNC(vaAssociateSubpicture, ++ VAStatus, (VADisplay, VASubpictureID, VASurfaceID *, int, ++ short, short, unsigned short, unsigned short, ++ short, short, unsigned short, unsigned short, ++ unsigned int)); ++ ++ return lib_vaAssociateSubpicture(dpy, subpicture, ++ target_surfaces, num_surfaces, ++ src_x, src_y, src_width, src_height, ++ dest_x, dest_y, dest_width, dest_height, ++ flags); ++} --- libva-0.31.0+latest2.orig/debian/patches/103_fix_vainfo_deps.patch +++ libva-0.31.0+latest2/debian/patches/103_fix_vainfo_deps.patch @@ -0,0 +1,22 @@ +commit a07468c4f0e30b5f207a2bdf1b362f5584d748a7 +Author: Gwenole Beauchesne +Date: Tue Sep 22 12:29:56 2009 +0000 + + Fix vainfo dependencies (Konstantin Pavlov). + +diff --git a/test/Makefile.am b/test/Makefile.am +index d7e1b1f..8785259 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -25,9 +25,8 @@ bin_PROGRAMS = vainfo + + AM_CFLAGS = -I$(top_srcdir)/va -I$(top_srcdir)/test/basic -I$(top_srcdir)/src/x11 + +- +-vainfo_LDADD = $(top_srcdir)/va/$(libvabackendlib) +-vainfo_DEPENDENCIES = $(top_srcdir)/va/$(libvabackendlib) ++vainfo_LDADD = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) ++vainfo_DEPENDENCIES = $(top_srcdir)/va/libva.la $(top_srcdir)/va/$(libvabackendlib) + vainfo_SOURCES = vainfo.c + + SUBDIRS = basic decode encode putsurface --- libva-0.31.0+latest2.orig/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch +++ libva-0.31.0+latest2/debian/patches/105_dont_search_LIBGL_DRIVERS_PATH.patch @@ -0,0 +1,21 @@ +commit ecc7b5f332674ee57ad11a0d6bb58a252549c762 +Author: Gwenole Beauchesne +Date: Tue Sep 22 13:03:23 2009 +0000 + + Don't search LIBGL_DRIVERS_PATH, stick to LIBVA_DRIVERS_PATH only or the default path. + +diff --git a/va/va.c b/va/va.c +index c8e036e..ada70ce 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -127,10 +127,6 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + { + /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ + search_path = getenv("LIBVA_DRIVERS_PATH"); +- if (!search_path) +- { +- search_path = getenv("LIBGL_DRIVERS_PATH"); +- } + } + if (!search_path) + { --- libva-0.31.0+latest2.orig/debian/patches/102_attribute_visibility.patch +++ libva-0.31.0+latest2/debian/patches/102_attribute_visibility.patch @@ -0,0 +1,41 @@ +commit 26db277f8e028be83d9ab16ef8e4077e9f745c17 +Author: Gwenole Beauchesne +Date: Thu Sep 3 15:46:37 2009 +0000 + + Check for __attribute__((visibility("hidden"))). + +diff --git a/configure.ac b/configure.ac +index eedfe4c..f2d0ea4 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -100,6 +100,30 @@ if test x$enable_i965_driver = xyes && ! $PKG_CONFIG --atleast-version=2.4 libdr + fi + AM_CONDITIONAL(BUILD_I965_DRIVER, test x$enable_i965_driver = xyes) + ++dnl Check for __attribute__((visibility())) ++AC_CACHE_CHECK([whether __attribute__((visibility())) is supported], ++ libva_cv_visibility_attribute, ++ [cat > conftest.c </dev/null 2>&1; then ++ if grep '\.hidden.*foo' conftest.s >/dev/null; then ++ if grep '\.protected.*bar' conftest.s >/dev/null; then ++ libva_cv_visibility_attribute=yes ++ fi ++ fi ++ fi ++ rm -f conftest.[cs] ++]) ++ATTRIBUTE_HIDDEN="" ++if test $libva_cv_visibility_attribute = yes; then ++ ATTRIBUTE_HIDDEN="__attribute__((visibility(\"hidden\")))" ++fi ++AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], ++ [Defined to __attribute__((visibility("hidden"))) when available]) ++ + # We only need the headers, we don't link against the DRM libraries + LIBVA_CFLAGS="$DRM_CFLAGS" + AC_SUBST(LIBVA_CFLAGS) --- libva-0.31.0+latest2.orig/debian/patches/104_fix_libva_pkgconfig_deps.patch +++ libva-0.31.0+latest2/debian/patches/104_fix_libva_pkgconfig_deps.patch @@ -0,0 +1,18 @@ +commit 5f1314d188c4ecc2e0d5be54bcd663013e8b0077 +Author: Gwenole Beauchesne +Date: Tue Sep 22 13:00:34 2009 +0000 + + Fix libva-x11 dependencies. Ensure this grabs libva so that people don't have to check for that themselves. + +diff --git a/libva-x11.pc.in b/libva-x11.pc.in +index 75e4f0b..6dde07f 100644 +--- a/libva-x11.pc.in ++++ b/libva-x11.pc.in +@@ -6,6 +6,7 @@ display=x11 + + Name: libva-${display} + Description: Userspace Video Acceleration (VA) ${display} interface ++Requires: libva + Version: @PACKAGE_VERSION@ + Libs: -L${libdir} -lva-${display} + Cflags: -I${includedir} --- libva-0.31.0+latest2.orig/debian/patches/300_sds_version.patch +++ libva-0.31.0+latest2/debian/patches/300_sds_version.patch @@ -0,0 +1,96 @@ +commit 1821919f68487c5e4fec33bd242208f49cb58c1e +Author: Gwenole Beauchesne +Date: Wed Jun 24 11:32:40 2009 +0000 + + Explicit API extensions from SDS. + +diff --git a/configure.ac b/configure.ac +index ebe5df6..95cf992 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -28,6 +28,9 @@ m4_define([libva_micro_version], [0]) + m4_define([libva_version], + [libva_major_version.libva_minor_version.libva_micro_version]) + ++# increase this number for each API change ++m4_define([libva_sds_version], [6]) ++ + # if the library source code has changed, increment revision + m4_define([libva_lt_revision], [1]) + # if any interface was added/removed/changed, then inc current, reset revision +@@ -52,11 +55,14 @@ AC_SUBST(LIBVA_MINOR_VERSION) + AC_SUBST(LIBVA_MICRO_VERSION) + AC_SUBST(LIBVA_VERSION) + ++LIBVA_SDS_VERSION=libva_sds_version ++AC_SUBST(LIBVA_SDS_VERSION) ++ + LIBVA_LT_CURRENT=libva_lt_current + LIBVA_LT_REV=libva_lt_revision + LIBVA_LT_AGE=libva_lt_age + LIBVA_LT_VERSION="$LIBVA_LT_CURRENT:$LIBVA_LT_REV:$LIBVA_LT_AGE" +-LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION" ++LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA_SDS_VERSION" + AC_SUBST(LIBVA_LT_VERSION) + AC_SUBST(LIBVA_LT_LDFLAGS) + +diff --git a/libva.pc.in b/libva.pc.in +index 60f1483..0b37945 100644 +--- a/libva.pc.in ++++ b/libva.pc.in +@@ -3,6 +3,7 @@ exec_prefix=@exec_prefix@ + libdir=@libdir@ + includedir=@includedir@ + driverdir=@LIBVA_DRIVERS_PATH@ ++sdsversion=@LIBVA_SDS_VERSION@ + + Name: libva + Description: Userspace Video Acceleration (VA) core interface +diff --git a/va/va.c b/va/va.c +index fd68481..0d208d8 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -162,7 +162,15 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) + else + { + VADriverInit init_func; +- init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ char driver_init_func_sds[32]; ++ /* First, try SDS extensions (VDPAU and XvBA backends) */ ++ sprintf(driver_init_func_sds, "%s_%d_sds%d", ++ DRIVER_INIT_FUNC, VA_MICRO_VERSION, VA_SDS_VERSION); ++ init_func = (VADriverInit) dlsym(handle, driver_init_func_sds); ++ if (!init_func) ++ { ++ init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC); ++ } + if (!init_func) + { + va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC); +diff --git a/va/va_version.h.in b/va/va_version.h.in +index c9ea97a..197c482 100644 +--- a/va/va_version.h.in ++++ b/va/va_version.h.in +@@ -47,6 +47,13 @@ + #define VA_MICRO_VERSION (@LIBVA_MICRO_VERSION@) + + /** ++ * VA_SDS_VERSION: ++ * ++ * The version of the SDS API extensions to the VA library ++ */ ++#define VA_SDS_VERSION (@LIBVA_SDS_VERSION@) ++ ++/** + * VA_VERSION: + * + * The full version of the VA library, like 1.2.3 +@@ -59,7 +66,7 @@ + * The full version of the VA library, in string form (suited for + * string concatenation) + */ +-#define VA_VERSION_S "@LIBVA_VERSION@" ++#define VA_VERSION_S "@LIBVA_VERSION@-sds@LIBVA_SDS_VERSION@" + + /** + * VA_VERSION_HEX: --- libva-0.31.0+latest2.orig/debian/patches/033_g45_add_rgba_subpic.patch +++ libva-0.31.0+latest2/debian/patches/033_g45_add_rgba_subpic.patch @@ -0,0 +1,103 @@ +commit 98edda85a2d734763a5f40478a063d3e289e1389 +Author: Gwenole Beauchesne +Date: Wed Nov 4 10:56:54 2009 +0000 + + [G45] Add RGBA subpictures. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index e476ca2..637e304 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -70,6 +70,14 @@ i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = { + { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A4P4_UNORM, + { VA_FOURCC('A','I','4','4'), VA_MSB_FIRST, 8, }, + 0 }, ++ { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_B8G8R8A8_UNORM, ++ { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, ++ 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, ++ 0 }, ++ { I965_SURFACETYPE_RGBA, I965_SURFACEFORMAT_R8G8B8A8_UNORM, ++ { VA_FOURCC('R','G','B','A'), VA_LSB_FIRST, 32, ++ 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, ++ 0 }, + }; + + static const i965_subpic_format_map_t * +@@ -467,6 +475,7 @@ i965_CreateSubpicture(VADriverContextP ctx, + obj_subpic->format = m->format; + obj_subpic->width = obj_image->image.width; + obj_subpic->height = obj_image->image.height; ++ obj_subpic->pitch = obj_image->image.pitches[0]; + obj_subpic->bo = obj_image->bo; + return VA_STATUS_SUCCESS; + } +@@ -1218,6 +1227,15 @@ i965_CreateImage(VADriverContextP ctx, + image->component_order[1] = 'G'; + image->component_order[2] = 'B'; + break; ++ case VA_FOURCC('A','R','G','B'): ++ case VA_FOURCC('A','B','G','R'): ++ case VA_FOURCC('B','G','R','A'): ++ case VA_FOURCC('R','G','B','A'): ++ image->num_planes = 1; ++ image->pitches[0] = width * 4; ++ image->offsets[0] = 0; ++ image->data_size = image->offsets[0] + image->pitches[0] * height; ++ break; + default: + goto error; + } +diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h +index fa09869..2f538c2 100644 +--- a/i965_drv_video/i965_drv_video.h ++++ b/i965_drv_video/i965_drv_video.h +@@ -44,7 +44,7 @@ + #define I965_MAX_ENTRYPOINTS 5 + #define I965_MAX_CONFIG_ATTRIBUTES 10 + #define I965_MAX_IMAGE_FORMATS 10 +-#define I965_MAX_SUBPIC_FORMATS 2 ++#define I965_MAX_SUBPIC_FORMATS 4 + #define I965_MAX_DISPLAY_ATTRIBUTES 4 + #define I965_STR_VENDOR "i965 Driver 0.1" + +@@ -126,6 +126,7 @@ struct object_subpic + unsigned int format; + int width; + int height; ++ int pitch; + dri_bo *bo; + }; + +diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c +index 4a4f041..c738d22 100644 +--- a/i965_drv_video/i965_render.c ++++ b/i965_drv_video/i965_render.c +@@ -587,7 +587,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, + int index, + dri_bo *region, + unsigned long offset, +- int w, int h, int format) ++ int w, int h, int p, int format) + { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_render_state *render_state = &i965->render_state; +@@ -621,7 +621,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, + ss->ss2.mip_count = 0; + ss->ss2.render_target_rotation = 0; + +- ss->ss3.pitch = w - 1; ++ ss->ss3.pitch = p - 1; + + dri_bo_emit_reloc(ss_bo, + I915_GEM_DOMAIN_SAMPLER, 0, +@@ -679,8 +679,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx, + region = obj_surface->bo; + subpic_region = obj_image->bo; + /*subpicture surface*/ +- i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); +- i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); ++ i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); ++ i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->pitch, obj_subpic->format); + } + + static void --- libva-0.31.0+latest2.orig/debian/patches/000_README +++ libva-0.31.0+latest2/debian/patches/000_README @@ -0,0 +1,7 @@ +SDS patches organisation +------------------------ + +0xx - Patches from upstream sources +1xx - Patches that are trivial or fix bugs brought by upstream +2xx - Patches that relate to build system and driver detection +3xx - Patches that provide API extensions to upstream --- libva-0.31.0+latest2.orig/debian/patches/108_drivers_path.patch +++ libva-0.31.0+latest2/debian/patches/108_drivers_path.patch @@ -0,0 +1,19 @@ +commit 43becedcfa2b9b040006868a63c686a131c9ba74 +Author: Gwenole Beauchesne +Date: Wed Jun 24 08:12:13 2009 +0000 + + Install drivers into pkglibdir/va/. + +diff --git a/configure.ac b/configure.ac +index f2d0ea4..ebe5df6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -73,7 +73,7 @@ AC_ARG_ENABLE(i965-driver, + + AC_ARG_WITH(drivers-path, + [AC_HELP_STRING([--with-drivers-path=[[path]]], [drivers path])],, +- [with_drivers_path="$libdir/dri"]) ++ [with_drivers_path="$libdir/va/drivers"]) + + LIBVA_DRIVERS_PATH="$with_drivers_path" + AC_SUBST(LIBVA_DRIVERS_PATH) --- libva-0.31.0+latest2.orig/debian/patches/032_g45_fix_subpic_formats.patch +++ libva-0.31.0+latest2/debian/patches/032_g45_fix_subpic_formats.patch @@ -0,0 +1,19 @@ +commit d6e726b80766c669dffe846fcd31fcfe5dc89847 +Author: Gwenole Beauchesne +Date: Wed Nov 4 12:13:41 2009 +0000 + + [G45] Fix subpictures formats array terminator. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 6a60ecc..e476ca2 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -76,7 +76,7 @@ static const i965_subpic_format_map_t * + get_subpic_format(const VAImageFormat *va_format) + { + unsigned int i; +- for (i = 0; i < sizeof(i965_subpic_formats_map)/sizeof(i965_subpic_formats_map[0]); i++) { ++ for (i = 0; i965_subpic_formats_map[i].type != 0; i++) { + const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[i]; + if (m->va_format.fourcc == va_format->fourcc && + (m->type == I965_SURFACETYPE_RGBA ? --- libva-0.31.0+latest2.orig/debian/patches/204_check_ATIFGLEXTENSION.patch +++ libva-0.31.0+latest2/debian/patches/204_check_ATIFGLEXTENSION.patch @@ -0,0 +1,325 @@ +commit 595a044901ee32acc3212100966f5a1a9e181515 +Author: Gwenole Beauchesne +Date: Fri Nov 20 15:51:22 2009 +0000 + + Fix detection of fglrx. + +diff --git a/va/Makefile.am b/va/Makefile.am +index 3b9ccfc..99f6bbf 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -36,7 +36,7 @@ libva_la_LDFLAGS = $(LDADD) -no-undefined + libva_la_LIBADD = $(LIBVA_LIBS) -ldl + + libva_x11_la_SOURCES = +-libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) ++libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS) $(XEXT_LIBS) $(XFIXES_LIBS) -ldl + libva_x11_la_LDFLAGS = $(LDADD) + libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + +diff --git a/va/x11/Makefile.am b/va/x11/Makefile.am +index 7466fda..a6d9323 100644 +--- a/va/x11/Makefile.am ++++ b/va/x11/Makefile.am +@@ -25,6 +25,23 @@ noinst_LTLIBRARIES = libva_x11.la + libva_x11includedir = ${includedir}/va + libva_x11include_HEADERS = va_dri.h va_dri2.h va_dricommon.h + +-libva_x11_la_SOURCES = va_x11.c va_dri.c va_dri2.c va_dricommon.c dri2_util.c dri1_util.c va_nvctrl.c libdrm_glue.c ++libva_x11_la_SOURCES = \ ++ dri1_util.c \ ++ dri2_util.c \ ++ libdrm_glue.c \ ++ va_dri.c \ ++ va_dri2.c \ ++ va_dricommon.c \ ++ va_fglext.c \ ++ va_nvctrl.c \ ++ va_x11.c \ ++ $(NULL) + +-EXTRA_DIST = va_dristr.h va_dri2str.h va_dri2tokens.h va_nvctrl.h libdrm_glue.h ++EXTRA_DIST = \ ++ libdrm_glue.h \ ++ va_dri2str.h \ ++ va_dri2tokens.h \ ++ va_dristr.h \ ++ va_fglext.h \ ++ va_nvctrl.h \ ++ $(NULL) +diff --git a/va/x11/va_fglext.c b/va/x11/va_fglext.c +new file mode 100644 +index 0000000..add1f28 +--- /dev/null ++++ b/va/x11/va_fglext.c +@@ -0,0 +1,175 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#define _GNU_SOURCE 1 ++#include ++ ++#define NEED_REPLIES ++#include ++#include ++#include ++#include ++#include ++#include "va_fglext.h" ++ ++#define ATIFGL_EXTENSION_NAME "ATIFGLEXTENSION" ++#define ATIFGL_EXTENSION_EVENTS 0 ++ ++typedef struct _FGLGetDriverData { ++ CARD8 reqType; ++ CARD8 fireglReqType; ++ CARD16 length B16; ++ CARD32 screen B32; ++ CARD16 size B16; ++ CARD16 pad1; ++} xFGLGetDriverDataReq; ++#define sz_xFGLGetDriverDataReq sizeof(xFGLGetDriverDataReq) ++ ++typedef struct { ++ BYTE type; ++ BYTE pad1; ++ CARD16 sequenceNumber B16; ++ CARD32 length B32; ++ CARD8 majorVersion; ++ CARD8 minorVersion; ++ CARD8 patchlevel B16; ++ CARD8 BIOSVersionMajor; ++ CARD8 BIOSVersionMinor; ++ CARD8 HasSecondary; ++ CARD16 pad3 B16; ++ CARD32 pad4 B32; ++ CARD32 pad5 B32; ++ CARD32 pad6 B32; ++ CARD32 pad7 B32; ++ // ... there are more fields ++} xFGLGetDriverDataReply; ++#define sz_xFGLGetDriverDataReply sizeof(xFGLGetDriverDataReply) ++ ++#define X_FGLGetDriverData 0 ++ ++static XExtensionInfo _fglext_ext_info_data; ++static XExtensionInfo *fglext_ext_info = &_fglext_ext_info_data; ++static /* const */ char *fglext_extension_name = ATIFGL_EXTENSION_NAME; ++ ++#define xFGLCheckExtension(dpy,i,val) \ ++ XextCheckExtension (dpy, i, fglext_extension_name, val) ++ ++static int close_display(); ++static /* const */ XExtensionHooks fglext_extension_hooks = { ++ NULL, /* create_gc */ ++ NULL, /* copy_gc */ ++ NULL, /* flush_gc */ ++ NULL, /* free_gc */ ++ NULL, /* create_font */ ++ NULL, /* free_font */ ++ close_display, /* close_display */ ++ NULL, /* wire_to_event */ ++ NULL, /* event_to_wire */ ++ NULL, /* error */ ++ NULL, /* error_string */ ++}; ++ ++static XEXT_GENERATE_FIND_DISPLAY (find_display, fglext_ext_info, ++ fglext_extension_name, ++ &fglext_extension_hooks, ++ ATIFGL_EXTENSION_EVENTS, NULL) ++ ++static XEXT_GENERATE_CLOSE_DISPLAY (close_display, fglext_ext_info) ++ ++Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, ++ Bool *isCapable ) ++{ ++ char **extensions; ++ int i, n_extensions, has_fglext = 0, has_fglrxdri = 0; ++ ++ if (isCapable) ++ *isCapable = False; ++ ++ extensions = XListExtensions(dpy, &n_extensions); ++ if (!extensions) ++ return False; ++ ++ for (i = 0; i < n_extensions; i++) { ++ if (strcmp(extensions[i], ATIFGL_EXTENSION_NAME) == 0) ++ has_fglext = 1; ++ if (strcmp(extensions[i], "ATIFGLRXDRI") == 0) ++ has_fglrxdri = 1; ++ } ++ XFreeExtensionList(extensions); ++ ++ if (!has_fglext) ++ return False; ++ ++ if (isCapable) ++ *isCapable = has_fglrxdri; ++ ++ return True; ++} ++ ++Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, ++ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, ++ int *ddxDriverPatchVersion, char **clientDriverName ) ++{ ++ XExtDisplayInfo *info = find_display (dpy); ++ xFGLGetDriverDataReply rep; ++ xFGLGetDriverDataReq *req; ++ ++ if (ddxDriverMajorVersion) ++ *ddxDriverMajorVersion = 0; ++ if (ddxDriverMinorVersion) ++ *ddxDriverMinorVersion = 0; ++ if (ddxDriverPatchVersion) ++ *ddxDriverPatchVersion = 0; ++ if (clientDriverName) ++ *clientDriverName = NULL; ++ ++ if(!XextHasExtension(info)) ++ return False; ++ ++ xFGLCheckExtension (dpy, info, False); ++ ++ LockDisplay (dpy); ++ GetReq (FGLGetDriverData, req); ++ req->reqType = info->codes->major_opcode; ++ req->fireglReqType = X_FGLGetDriverData; ++ req->screen = screen; ++ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { ++ UnlockDisplay (dpy); ++ SyncHandle (); ++ return False; ++ } ++ UnlockDisplay (dpy); ++ SyncHandle (); ++ ++ if (ddxDriverMajorVersion) ++ *ddxDriverMajorVersion = rep.majorVersion; ++ if (ddxDriverMinorVersion) ++ *ddxDriverMinorVersion = rep.minorVersion; ++ if (ddxDriverPatchVersion) ++ *ddxDriverPatchVersion = rep.patchlevel; ++ if (clientDriverName) ++ *clientDriverName = strdup("fglrx"); ++ ++ return True; ++} +diff --git a/va/x11/va_fglext.h b/va/x11/va_fglext.h +new file mode 100644 +index 0000000..f2d87c3 +--- /dev/null ++++ b/va/x11/va_fglext.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (C) 2009 Splitted-Desktop Systems. All Rights Reserved. ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the ++ * "Software"), to deal in the Software without restriction, including ++ * without limitation the rights to use, copy, modify, merge, publish, ++ * distribute, sub license, and/or sell copies of the Software, and to ++ * permit persons to whom the Software is furnished to do so, subject to ++ * the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the ++ * next paragraph) shall be included in all copies or substantial portions ++ * of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ++ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ++ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ++ */ ++ ++#ifndef VA_FGLEXTLIB_H ++#define VA_FGLEXTLIB_H ++ ++#include ++ ++Bool VA_FGLEXTQueryDirectRenderingCapable( Display *dpy, int screen, ++ Bool *isCapable ); ++ ++Bool VA_FGLEXTGetClientDriverName( Display *dpy, int screen, ++ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, ++ int *ddxDriverPatchVersion, char **clientDriverName ); ++ ++#endif /* VA_FGLEXTLIB_H */ +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 1216093..71cc36f 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -31,6 +31,7 @@ + #include "va_dri2.h" + #include "va_dricommon.h" + #include "va_nvctrl.h" ++#include "va_fglext.h" + #include "libdrm_glue.h" + #include + #include +@@ -133,6 +134,29 @@ static VAStatus va_NVCTRL_GetDriverName ( + return VA_STATUS_SUCCESS; + } + ++static VAStatus va_FGLEXT_GetDriverName( ++ VADisplayContextP pDisplayContext, ++ char **driver_name ++) ++{ ++ VADriverContextP ctx = pDisplayContext->pDriverContext; ++ int direct_capable, driver_major, driver_minor, driver_patch; ++ Bool result; ++ ++ result = VA_FGLEXTQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, ++ &direct_capable); ++ if (!result || !direct_capable) ++ return VA_STATUS_ERROR_UNKNOWN; ++ ++ result = VA_FGLEXTGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, ++ &driver_major, &driver_minor, ++ &driver_patch, driver_name); ++ if (!result) ++ return VA_STATUS_ERROR_UNKNOWN; ++ ++ return VA_STATUS_SUCCESS; ++} ++ + static VAStatus va_DisplayContextGetDriverName ( + VADisplayContextP pDisplayContext, + char **driver_name +@@ -148,7 +172,8 @@ static VAStatus va_DisplayContextGetDriverName ( + vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); + if (vaStatus != VA_STATUS_SUCCESS) + vaStatus = va_NVCTRL_GetDriverName(pDisplayContext, driver_name); +- ++ if (vaStatus != VA_STATUS_SUCCESS) ++ vaStatus = va_FGLEXT_GetDriverName(pDisplayContext, driver_name); + return vaStatus; + } + --- libva-0.31.0+latest2.orig/debian/patches/321_libva_glx.base.patch +++ libva-0.31.0+latest2/debian/patches/321_libva_glx.base.patch @@ -0,0 +1,202 @@ +commit e69075435675d356c7c9b4ff734a60e8cd031604 +Author: Gwenole Beauchesne +Date: Mon Mar 8 09:44:25 2010 +0100 + + Add OpenGL extensions (v3) and generic implementation with TFP and FBO. + +diff --git a/Makefile.am b/Makefile.am +index 459660b..e75a2db 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -32,10 +32,13 @@ endif + + pcfiles = libva.pc + pcfiles += libva-x11.pc ++if USE_GLX ++pcfiles += libva-glx.pc ++endif + + pkgconfigdir = @pkgconfigdir@ + pkgconfig_DATA = $(pcfiles) + +-EXTRA_DIST = libva.pc.in libva-x11.pc.in ++EXTRA_DIST = libva.pc.in libva-x11.pc.in libva-glx.pc.in + + CLEANFILES = $(pcfiles) +diff --git a/configure.ac b/configure.ac +index 95cf992..86366e9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -66,6 +66,11 @@ LIBVA_LT_LDFLAGS="-version-info $LIBVA_LT_VERSION -release $LIBVA_VERSION.$LIBVA + AC_SUBST(LIBVA_LT_VERSION) + AC_SUBST(LIBVA_LT_LDFLAGS) + ++AC_ARG_ENABLE(glx, ++ [AC_HELP_STRING([--enable-glx], ++ [build with OpenGL for X11 support])], ++ [], [enable_glx=yes]) ++ + AC_ARG_ENABLE(dummy-driver, + [AC_HELP_STRING([--enable-dummy-driver], + [build dummy video driver])], +@@ -130,6 +135,22 @@ fi + AC_DEFINE_UNQUOTED([ATTRIBUTE_HIDDEN], [$ATTRIBUTE_HIDDEN], + [Defined to __attribute__((visibility("hidden"))) when available]) + ++# Check for OpenGL (X11) ++USE_GLX="no" ++GL_DEPS_CFLAGS="" ++GL_DEPS_LIBS="" ++if test x$enable_glx = xyes; then ++ AC_CHECK_HEADERS([GL/gl.h]) ++ AC_CHECK_HEADERS([GL/glx.h]) ++ AC_CHECK_LIB(GL, glXCreateContext, [ ++ USE_GLX="yes" ++ GL_DEPS_LIBS="-lX11 -lGL" ++ ]) ++fi ++AC_SUBST(GL_DEPS_CFLAGS) ++AC_SUBST(GL_DEPS_LIBS) ++AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") ++ + # We only need the headers, we don't link against the DRM libraries + LIBVA_CFLAGS="$DRM_CFLAGS" + AC_SUBST(LIBVA_CFLAGS) +@@ -149,6 +170,7 @@ AC_OUTPUT([ + va/Makefile + va/va_version.h + va/x11/Makefile ++ va/glx/Makefile + dummy_drv_video/Makefile + i965_drv_video/Makefile + i965_drv_video/shaders/Makefile +@@ -162,5 +184,6 @@ AC_OUTPUT([ + test/encode/Makefile + libva.pc + libva-x11.pc ++ libva-glx.pc + ]) + +diff --git a/libva-glx.pc.in b/libva-glx.pc.in +new file mode 100644 +index 0000000..2019915 +--- /dev/null ++++ b/libva-glx.pc.in +@@ -0,0 +1,12 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++display=glx ++ ++Name: libva-${display} ++Description: Userspace Video Acceleration (VA) ${display} interface ++Requires: libva ++Version: @PACKAGE_VERSION@ ++Libs: -L${libdir} -lva-${display} ++Cflags: -I${includedir} +diff --git a/va/Makefile.am b/va/Makefile.am +index 99f6bbf..ebff3d5 100644 +--- a/va/Makefile.am ++++ b/va/Makefile.am +@@ -27,9 +27,17 @@ INCLUDES = \ + LDADD = \ + $(LIBVA_LT_LDFLAGS) + +-lib_LTLIBRARIES = \ +- libva.la \ +- libva-x11.la ++libva_x11_backend = libva-x11.la ++libva_x11_backenddir = x11 ++if USE_GLX ++libva_glx_backend = libva-glx.la ++libva_glx_backenddir = glx ++else ++libva_glx_backend = ++libva_glx_backenddir = ++endif ++ ++lib_LTLIBRARIES = libva.la $(libva_x11_backend) $(libva_glx_backend) + + libva_ladir = $(libdir) + libva_la_LDFLAGS = $(LDADD) -no-undefined +@@ -40,7 +48,14 @@ libva_x11_la_LIBADD = $(libvacorelib) x11/libva_x11.la $(LIBVA_LIBS) $(X11_LIBS + libva_x11_la_LDFLAGS = $(LDADD) + libva_x11_la_DEPENDENCIES = $(libvacorelib) x11/libva_x11.la + +-SUBDIRS = x11 ++libva_glx_la_SOURCES = ++libva_glx_la_LIBADD = $(libvacorelib) glx/libva_glx.la libva-x11.la $(GL_DEPS_LIBS) -ldl ++libva_glx_la_LDFLAGS = $(LDADD) ++libva_glx_la_DEPENDENCIES = $(libvacorelib) glx/libva_glx.la libva-x11.la ++ ++SUBDIRS = $(libva_x11_backenddir) $(libva_glx_backenddir) ++ ++DIST_SUBDIRS = x11 glx + + libva_la_SOURCES = va.c va_crystalhd.c + +diff --git a/va/glx/Makefile.am b/va/glx/Makefile.am +new file mode 100644 +index 0000000..337f34e +diff --git a/va/glx/va_backend_glx.h b/va/glx/va_backend_glx.h +new file mode 100644 +index 0000000..d110485 +diff --git a/va/glx/va_glx.c b/va/glx/va_glx.c +new file mode 100644 +index 0000000..ec50a0e +diff --git a/va/glx/va_glx.h b/va/glx/va_glx.h +new file mode 100644 +index 0000000..1a0624d +diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c +new file mode 100644 +index 0000000..b0f24bb +diff --git a/va/glx/va_glx_impl.h b/va/glx/va_glx_impl.h +new file mode 100644 +index 0000000..977bfcc +diff --git a/va/glx/va_glx_private.h b/va/glx/va_glx_private.h +new file mode 100644 +index 0000000..d416729 +diff --git a/va/va_backend.h b/va/va_backend.h +index ff86744..06fef7f 100644 +--- a/va/va_backend.h ++++ b/va/va_backend.h +@@ -365,6 +365,9 @@ struct VADriverVTable + unsigned int *chroma_v_offset, + void **buffer + ); ++ ++ /* Optional: GLX support hooks */ ++ struct VADriverVTableGLX *glx; + }; + + struct VADriverContext +@@ -387,6 +390,7 @@ struct VADriverContext + void *handle; /* dlopen handle */ + + void *dri_state; ++ void *glx; /* opaque for GLX code */ + }; + + #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */ +@@ -409,6 +413,8 @@ struct VADisplayContext + VADisplayContextP ctx, + char **driver_name + ); ++ ++ void *opaque; /* opaque for display extensions (e.g. GLX) */ + }; + + typedef VAStatus (*VADriverInit) ( +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 71cc36f..6826b31 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -217,6 +217,7 @@ VADisplay vaGetDisplay ( + pDisplayContext->vaIsValid = va_DisplayContextIsValid; + pDisplayContext->vaDestroy = va_DisplayContextDestroy; + pDisplayContext->vaGetDriverName = va_DisplayContextGetDriverName; ++ pDisplayContext->opaque = NULL; + pDisplayContexts = pDisplayContext; + pDriverContext->dri_state = dri_state; + dpy = (VADisplay)pDisplayContext; --- libva-0.31.0+latest2.orig/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch +++ libva-0.31.0+latest2/debian/patches/201_libva_LIBVA_DRIVER_NAME.patch @@ -0,0 +1,97 @@ +commit 1f9ee94ab4ac60459048bef5a2aa348cdf88c390 +Author: Gwenole Beauchesne +Date: Tue Feb 23 09:11:22 2010 +0000 + + Move LIBVA_DRIVER_NAME check in vaInitialize(). + +diff --git a/va/va.c b/va/va.c +index ada70ce..b5940e5 100644 +--- a/va/va.c ++++ b/va/va.c +@@ -320,30 +320,42 @@ VAStatus vaInitialize ( + int *minor_version /* out */ + ) + { +- char *driver_name = NULL; +- VAStatus vaStatus; +- +- CHECK_DISPLAY(dpy); ++ const char *driver_name_env = NULL; ++ char *driver_name = NULL; ++ VAStatus vaStatus; + +- va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); ++ CHECK_DISPLAY(dpy); + +- va_infoMessage("libva version %s\n", VA_VERSION_S); ++ va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL); + +- vaStatus = va_getDriverName(dpy, &driver_name); +- va_infoMessage("va_getDriverName() returns %d\n", vaStatus); +- +- if (VA_STATUS_SUCCESS == vaStatus) +- { +- vaStatus = va_openDriver(dpy, driver_name); +- va_infoMessage("va_openDriver() returns %d\n", vaStatus); +- +- *major_version = VA_MAJOR_VERSION; +- *minor_version = VA_MINOR_VERSION; +- } ++ va_infoMessage("libva version %s\n", VA_VERSION_S); + +- if (driver_name) +- free(driver_name); +- return vaStatus; ++ driver_name_env = getenv("LIBVA_DRIVER_NAME"); ++ if (driver_name_env && geteuid() == getuid()) ++ { ++ /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ ++ driver_name = strdup(driver_name_env); ++ vaStatus = VA_STATUS_SUCCESS; ++ va_infoMessage("User requested driver '%s'\n", driver_name); ++ } ++ else ++ { ++ vaStatus = va_getDriverName(dpy, &driver_name); ++ va_infoMessage("va_getDriverName() returns %d\n", vaStatus); ++ } ++ ++ if (VA_STATUS_SUCCESS == vaStatus) ++ { ++ vaStatus = va_openDriver(dpy, driver_name); ++ va_infoMessage("va_openDriver() returns %d\n", vaStatus); ++ ++ *major_version = VA_MAJOR_VERSION; ++ *minor_version = VA_MINOR_VERSION; ++ } ++ ++ if (driver_name) ++ free(driver_name); ++ return vaStatus; + } + + +diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c +index 29e81c8..78e38de 100644 +--- a/va/x11/va_x11.c ++++ b/va/x11/va_x11.c +@@ -136,19 +136,10 @@ static VAStatus va_DisplayContextGetDriverName ( + ) + { + VAStatus vaStatus; +- char *driver_name_env; + + if (driver_name) + *driver_name = NULL; + +- if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL +- && geteuid() == getuid()) +- { +- /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ +- *driver_name = strdup(driver_name_env); +- return VA_STATUS_SUCCESS; +- } +- + vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); + if (vaStatus != VA_STATUS_SUCCESS) + vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); --- libva-0.31.0+latest2.orig/debian/patches/034_g45_fix_return_for_unimpl.patch +++ libva-0.31.0+latest2/debian/patches/034_g45_fix_return_for_unimpl.patch @@ -0,0 +1,77 @@ +commit ff263433c32aac08574b58b26f3f4be7abe05bdf +Author: Gwenole Beauchesne +Date: Wed Nov 4 13:23:40 2009 +0000 + + [G45] Don't return VA_STATUS_SUCCESS for unimplemented functions. + +diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c +index 637e304..9e8502a 100644 +--- a/i965_drv_video/i965_drv_video.c ++++ b/i965_drv_video/i965_drv_video.c +@@ -496,7 +496,8 @@ i965_SetSubpictureImage(VADriverContextP ctx, + VASubpictureID subpicture, + VAImageID image) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -506,7 +507,8 @@ i965_SetSubpictureChromakey(VADriverContextP ctx, + unsigned int chromakey_max, + unsigned int chromakey_mask) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -514,7 +516,8 @@ i965_SetSubpictureGlobalAlpha(VADriverContextP ctx, + VASubpictureID subpicture, + float global_alpha) + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -1103,7 +1106,7 @@ i965_GetDisplayAttributes(VADriverContextP ctx, + int num_attributes) + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + /* +@@ -1118,7 +1121,7 @@ i965_SetDisplayAttributes(VADriverContextP ctx, + int num_attributes) + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + VAStatus +@@ -1128,7 +1131,7 @@ i965_DbgCopySurfaceToBuffer(VADriverContextP ctx, + unsigned int *stride) /* out */ + { + /* TODO */ +- return VA_STATUS_ERROR_UNKNOWN; ++ return VA_STATUS_ERROR_UNIMPLEMENTED; + } + + static VAStatus +@@ -1270,7 +1273,8 @@ VAStatus i965_DeriveImage(VADriverContextP ctx, + VASurfaceID surface, + VAImage *image) /* out */ + { +- return VA_STATUS_SUCCESS; ++ /* TODO */ ++ return VA_STATUS_ERROR_OPERATION_FAILED; + } + + static void