commit 483bc9e67afa9bcd8f99f08a74a78e7dfad4651f
Author: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Date:   Thu Jul 2 09:24:04 2009 +0000

    Fix make dist (va_compat_template.h).

commit 0e0da9ea861f14e8129767dbf6f11be5c051d85f
Author: Gwenole Beauchesne <gbeauchesne@splitted-desktop.com>
Date:   Wed Jun 24 11:40:56 2009 +0000

    Add compatibility layer with original libva 0.29.

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,7 +44,7 @@ libva_x11_la_DEPENDENCIES = $(libvacorelib)
 libva_x11_la_DEPENDENCIES = $(libvacorelib)
 
 
-libva_la_SOURCES = va.c
+libva_la_SOURCES = va.c va_compat.c
 
 libvaincludedir = ${includedir}/va
 libvainclude_HEADERS = va.h va_backend.h va_version.h
@@ -53,4 +53,8 @@ DISTCLEANFILES = \
 	va_version.h
 
 EXTRA_DIST = \
-	va_version.h.in
+	va_version.h.in \
+	va_compat.h \
+	va_compat_template.h
+
+va_compat.c: va_compat_template.h
--- a/src/va.c
+++ b/src/va.c
@@ -25,6 +25,7 @@
 #define _GNU_SOURCE 1
 #include "va.h"
 #include "va_backend.h"
+#include "va_compat.h"
 
 #include <assert.h>
 #include <stdarg.h>
@@ -41,6 +42,8 @@
 
 #define DRIVER_INIT_FUNC	"__vaDriverInit_0_31"
 #define DRIVER_INIT_FUNC_SDS	"__vaDriverInit_0_31_sds"
+#define DRIVER_INIT_FUNC_0_29	"__vaDriverInit_0_29"
+#define DRIVER_INIT_FUNC_0_30	"__vaDriverInit_0_30"
 
 #define DRIVER_EXTENSION	"_drv_video.so"
 
@@ -168,11 +171,22 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
         else
         {
             VADriverInit init_func;
-            init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
+            int compat_version = 0;
+            /* First, try SDS extensions (VDPAU and XvBA backends) */
+            init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_SDS);
             if (!init_func)
             {
-                /* Then try SDS extensions (VDPAU and XvBA backends) */
-                init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC_SDS);
+                /* 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)
             {
@@ -181,7 +195,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)
                 {
@@ -377,6 +422,8 @@ VAStatus vaTerminate (
       old_ctx->handle = NULL;
   }
 
+  va_compat_fini(dpy);
+
   if (VA_STATUS_SUCCESS == vaStatus)
       pDisplayContext->vaDestroy(pDisplayContext);
   return vaStatus;
--- a/src/va_backend.h
+++ b/src/va_backend.h
@@ -426,6 +426,7 @@ struct VADriverContext
     
     void *dri_state;
     void *glx;                          /* opaque for GLX code */
+    void *compat;			/* opaque for compat code */
 };
 
 struct VADisplayContext
