OSDN Git Service

Fix memory leak issue in open_display func
[android-x86/hardware-intel-common-libva.git] / dummy_drv_video / dummy_drv_video.c
index ce600aa..282f208 100644 (file)
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "va_backend.h"
+#include "config.h"
+#include <va/va_backend.h>
 
 #include "dummy_drv_video.h"
 
 #include "assert.h"
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
 
 #define ASSERT assert
 
-#define INIT_DRIVER_DATA       struct dummy_driver_data *driver_data = (struct dummy_driver_data *) ctx->pDriverData;
+#define INIT_DRIVER_DATA       struct dummy_driver_data * const driver_data = (struct dummy_driver_data *) ctx->pDriverData;
 
 #define CONFIG(id)  ((object_config_p) object_heap_lookup( &driver_data->config_heap, id ))
 #define CONTEXT(id) ((object_context_p) object_heap_lookup( &driver_data->context_heap, id ))
@@ -71,7 +73,6 @@ VAStatus dummy_QueryConfigProfiles(
                int *num_profiles                       /* out */
        )
 {
-    INIT_DRIVER_DATA
     int i = 0;
 
     profile_list[i++] = VAProfileMPEG2Simple;
@@ -100,8 +101,6 @@ VAStatus dummy_QueryConfigEntrypoints(
                int *num_entrypoints            /* out */
        )
 {
-    INIT_DRIVER_DATA
-
     switch (profile) {
         case VAProfileMPEG2Simple:
         case VAProfileMPEG2Main:
@@ -141,7 +140,7 @@ VAStatus dummy_QueryConfigEntrypoints(
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus dummy_QueryConfigAttributes(
+VAStatus dummy_GetConfigAttributes(
                VADriverContextP ctx,
                VAProfile profile,
                VAEntrypoint entrypoint,
@@ -149,8 +148,6 @@ VAStatus dummy_QueryConfigAttributes(
                int num_attribs
        )
 {
-    INIT_DRIVER_DATA
-
     int i;
 
     /* Other attributes don't seem to be defined */
@@ -312,7 +309,27 @@ VAStatus dummy_CreateConfig(
     return vaStatus;
 }
 
-VAStatus dummy_GetConfigAttributes(
+VAStatus dummy_DestroyConfig(
+               VADriverContextP ctx,
+               VAConfigID config_id
+       )
+{
+    INIT_DRIVER_DATA
+    VAStatus vaStatus;
+    object_config_p obj_config;
+
+    obj_config = CONFIG(config_id);
+    if (NULL == obj_config)
+    {
+        vaStatus = VA_STATUS_ERROR_INVALID_CONFIG;
+        return vaStatus;
+    }
+
+    object_heap_free( &driver_data->config_heap, (object_base_p) obj_config);
+    return VA_STATUS_SUCCESS;
+}
+
+VAStatus dummy_QueryConfigAttributes(
                VADriverContextP ctx,
                VAConfigID config_id,
                VAProfile *profile,             /* out */
@@ -346,7 +363,7 @@ VAStatus dummy_CreateSurfaces(
                int height,
                int format,
                int num_surfaces,
-               VASurface *surfaces             /* out */
+               VASurfaceID *surfaces           /* out */
        )
 {
     INIT_DRIVER_DATA
@@ -368,13 +385,8 @@ VAStatus dummy_CreateSurfaces(
             vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
             break;
         }
-        obj_surface->surface = &(surfaces[i]);
-        obj_surface->surface->surface_id = surfaceID;
-        obj_surface->surface->context_id = -1;
-        obj_surface->surface->width = width;
-        obj_surface->surface->height = height;
-        obj_surface->surface->format = format;
-        obj_surface->surface->privData = NULL;
+        obj_surface->surface_id = surfaceID;
+        surfaces[i] = surfaceID;
     }
 
     /* Error recovery */
@@ -383,8 +395,8 @@ VAStatus dummy_CreateSurfaces(
         /* surfaces[i-1] was the last successful allocation */
         for(; i--; )
         {
-            object_surface_p obj_surface = SURFACE(surfaces[i].surface_id);
-            surfaces[i].surface_id = -1;
+            object_surface_p obj_surface = SURFACE(surfaces[i]);
+            surfaces[i] = VA_INVALID_SURFACE;
             ASSERT(obj_surface);
             object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
         }
@@ -393,9 +405,9 @@ VAStatus dummy_CreateSurfaces(
     return vaStatus;
 }
 
-VAStatus dummy_DestroySurface(
+VAStatus dummy_DestroySurfaces(
                VADriverContextP ctx,
-               VASurface *surface_list,
+               VASurfaceID *surface_list,
                int num_surfaces
        )
 {
@@ -403,7 +415,7 @@ VAStatus dummy_DestroySurface(
     int i;
     for(i = num_surfaces; i--; )
     {
-        object_surface_p obj_surface = SURFACE(surface_list[i].surface_id);
+        object_surface_p obj_surface = SURFACE(surface_list[i]);
         ASSERT(obj_surface);
         object_heap_free( &driver_data->surface_heap, (object_base_p) obj_surface);
     }
@@ -416,8 +428,6 @@ VAStatus dummy_QueryImageFormats(
        int *num_formats           /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -430,53 +440,68 @@ VAStatus dummy_CreateImage(
        VAImage *image     /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
+    /* TODO */
+    return VA_STATUS_SUCCESS;
+}
+
+VAStatus dummy_DeriveImage(
+       VADriverContextP ctx,
+       VASurfaceID surface,
+       VAImage *image     /* out */
+)
+{
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_DestroyImage(
        VADriverContextP ctx,
-       VAImage *image
+       VAImageID image
+)
+{
+    /* TODO */
+    return VA_STATUS_SUCCESS;
+}
+
+VAStatus dummy_SetImagePalette(
+       VADriverContextP ctx,
+       VAImageID image,
+       unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_GetImage(
        VADriverContextP ctx,
-       VASurface *surface,
+       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,
-       VAImage *image
+       VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
+
 VAStatus dummy_PutImage(
        VADriverContextP ctx,
-       VASurface *surface,
-       VAImage *image,
+       VASurfaceID surface,
+       VAImageID image,
        int src_x,
        int src_y,
-       unsigned int width,
-       unsigned int height,
+       unsigned int src_width,
+       unsigned int src_height,
        int dest_x,
-       int dest_y 
+       int dest_y,
+       unsigned int dest_width,
+       unsigned int dest_height
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -488,50 +513,42 @@ VAStatus dummy_QuerySubpictureFormats(
        unsigned int *num_formats  /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_CreateSubpicture(
        VADriverContextP ctx,
-       VAImage *image,
-       VASubpicture *subpicture   /* out */
+       VAImageID image,
+       VASubpictureID *subpicture   /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_DestroySubpicture(
        VADriverContextP ctx,
-       VASubpicture *subpicture
+       VASubpictureID subpicture
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_SetSubpictureImage(
         VADriverContextP ctx,
-        VASubpicture *subpicture,
-        VAImage *image
+        VASubpictureID subpicture,
+        VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_SetSubpicturePalette(
        VADriverContextP ctx,
-       VASubpicture *subpicture,
+       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
@@ -540,47 +557,46 @@ VAStatus dummy_SetSubpicturePalette(
        unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_SetSubpictureChromakey(
        VADriverContextP ctx,
-       VASubpicture *subpicture,
+       VASubpictureID subpicture,
        unsigned int chromakey_min,
-       unsigned int chromakey_max
+       unsigned int chromakey_max,
+       unsigned int chromakey_mask
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
 VAStatus dummy_SetSubpictureGlobalAlpha(
        VADriverContextP ctx,
-       VASubpicture *subpicture,
+       VASubpictureID subpicture,
        float global_alpha 
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
+
 VAStatus dummy_AssociateSubpicture(
        VADriverContextP ctx,
-       VASurface *target_surface,
-       VASubpicture *subpicture,
+       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 width,
-       unsigned short height,
+       unsigned short dest_width,
+       unsigned short dest_height,
        /*
         * whether to enable chroma-keying or global-alpha
         * see VA_SUBPICTURE_XXX values
@@ -588,8 +604,17 @@ VAStatus dummy_AssociateSubpicture(
        unsigned int flags
 )
 {
-    INIT_DRIVER_DATA
-    
+    /* TODO */
+    return VA_STATUS_SUCCESS;
+}
+
+VAStatus dummy_DeassociateSubpicture(
+       VADriverContextP ctx,
+       VASubpictureID subpicture,
+       VASurfaceID *target_surfaces,
+       int num_surfaces
+)
+{
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -600,9 +625,9 @@ VAStatus dummy_CreateContext(
                int picture_width,
                int picture_height,
                int flag,
-               VASurface *render_targets,
+               VASurfaceID *render_targets,
                int num_render_targets,
-               VAContext *context              /* out */
+               VAContextID *context            /* out */
        )
 {
     INIT_DRIVER_DATA
@@ -628,41 +653,40 @@ VAStatus dummy_CreateContext(
         return vaStatus;
     }
 
-    obj_context->context = context;
+    obj_context->context_id  = contextID;
+    *context = contextID;
     obj_context->current_render_target = -1;
-
-    obj_context->context->context_id = contextID;
-    obj_context->context->config_id = config_id;
-    obj_context->context->picture_width = picture_width;
-    obj_context->context->picture_height = picture_height;
-    obj_context->context->num_render_targets = num_render_targets;
-    obj_context->context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
+    obj_context->config_id = config_id;
+    obj_context->picture_width = picture_width;
+    obj_context->picture_height = picture_height;
+    obj_context->num_render_targets = num_render_targets;
+    obj_context->render_targets = (VASurfaceID *) malloc(num_render_targets * sizeof(VASurfaceID));
+    if (obj_context->render_targets == NULL)
+    {
+        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+        return vaStatus;
+    }
+    
     for(i = 0; i < num_render_targets; i++)
     {
-        if (NULL == SURFACE(render_targets[i].surface_id))
+        if (NULL == SURFACE(render_targets[i]))
         {
             vaStatus = VA_STATUS_ERROR_INVALID_SURFACE;
             break;
         }
-        obj_context->context->render_targets[i] = render_targets[i].surface_id;
+        obj_context->render_targets[i] = render_targets[i];
     }
-    obj_context->context->flags = flag;
-    obj_context->context->privData = NULL;
+    obj_context->flags = flag;
 
     /* Error recovery */
     if (VA_STATUS_SUCCESS != vaStatus)
     {
-        free(obj_context->context->render_targets);
-        obj_context->context->render_targets = NULL;
-        obj_context->context->context_id = -1;
-        obj_context->context->config_id = -1;
-        obj_context->context->picture_width = 0;
-        obj_context->context->picture_height = 0;
-        free(obj_context->context->render_targets);
-        obj_context->context->render_targets = NULL;
-        obj_context->context->num_render_targets = 0;
-        obj_context->context->flags = 0;
-        obj_context->context->privData = NULL;
+        obj_context->context_id = -1;
+        obj_context->config_id = -1;
+        free(obj_context->render_targets);
+        obj_context->render_targets = NULL;
+        obj_context->num_render_targets = 0;
+        obj_context->flags = 0;
         object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
     }
 
@@ -672,27 +696,25 @@ VAStatus dummy_CreateContext(
 
 VAStatus dummy_DestroyContext(
                VADriverContextP ctx,
-               VAContext *context
+               VAContextID context
        )
 {
     INIT_DRIVER_DATA
-    object_context_p obj_context = CONTEXT(context->context_id);
+    object_context_p obj_context = CONTEXT(context);
     ASSERT(obj_context);
 
-    obj_context->context->context_id = -1;
-    obj_context->context->config_id = -1;
-    obj_context->context->picture_width = 0;
-    obj_context->context->picture_height = 0;
-    if (obj_context->context->render_targets)
+    obj_context->context_id = -1;
+    obj_context->config_id = -1;
+    obj_context->picture_width = 0;
+    obj_context->picture_height = 0;
+    if (obj_context->render_targets)
     {
-        free(obj_context->context->render_targets);
+        free(obj_context->render_targets);
     }
-    obj_context->context->render_targets = NULL;
-    obj_context->context->num_render_targets = 0;
-    obj_context->context->flags = 0;
-    obj_context->context->privData = NULL;
+    obj_context->render_targets = NULL;
+    obj_context->num_render_targets = 0;
+    obj_context->flags = 0;
 
-    obj_context->context = NULL;
     obj_context->current_render_target = -1;
 
     object_heap_free( &driver_data->context_heap, (object_base_p) obj_context);
@@ -701,11 +723,28 @@ VAStatus dummy_DestroyContext(
 }
 
 
+
+static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size)
+{
+    VAStatus vaStatus = VA_STATUS_SUCCESS;
+
+    obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size);
+    if (NULL == obj_buffer->buffer_data)
+    {
+        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+    }
+    return vaStatus;
+}
+
 VAStatus dummy_CreateBuffer(
                VADriverContextP ctx,
-               VABufferType type,  /* in */
-               VABufferID *buf_desc    /* out */
-       )
+                VAContextID context,   /* in */
+                VABufferType type,     /* in */
+                unsigned int size,             /* in */
+                unsigned int num_elements,     /* in */
+                void *data,                    /* in */
+                VABufferID *buf_id             /* out */
+)
 {
     INIT_DRIVER_DATA
     VAStatus vaStatus = VA_STATUS_SUCCESS;
@@ -717,11 +756,14 @@ VAStatus dummy_CreateBuffer(
     {
         case VAPictureParameterBufferType:
         case VAIQMatrixBufferType:
+        case VABitPlaneBufferType:
+        case VASliceGroupMapBufferType:
         case VASliceParameterBufferType:
         case VASliceDataBufferType:
         case VAMacroblockParameterBufferType:
         case VAResidualDataBufferType:
         case VADeblockingParameterBufferType:
+        case VAImageBufferType:
             /* Ok */
             break;
         default:
@@ -739,36 +781,6 @@ VAStatus dummy_CreateBuffer(
 
     obj_buffer->buffer_data = NULL;
 
-    *buf_desc = bufferID;
-
-    return vaStatus;
-}
-
-static VAStatus dummy__allocate_buffer(object_buffer_p obj_buffer, int size)
-{
-    VAStatus vaStatus = VA_STATUS_SUCCESS;
-
-    obj_buffer->buffer_data = realloc(obj_buffer->buffer_data, size);
-    if (NULL == obj_buffer->buffer_data)
-    {
-        vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
-    }
-    return vaStatus;
-}
-
-VAStatus dummy_BufferData(
-               VADriverContextP ctx,
-               VABufferID buf_id,      /* in */
-        unsigned int size,     /* in */
-        unsigned int num_elements,     /* in */
-        void *data             /* in */
-       )
-{
-    INIT_DRIVER_DATA
-    VAStatus vaStatus = VA_STATUS_SUCCESS;
-    object_buffer_p obj_buffer = BUFFER(buf_id);
-    ASSERT(obj_buffer);
-
     vaStatus = dummy__allocate_buffer(obj_buffer, size * num_elements);
     if (VA_STATUS_SUCCESS == vaStatus)
     {
@@ -780,9 +792,15 @@ VAStatus dummy_BufferData(
         }
     }
 
+    if (VA_STATUS_SUCCESS == vaStatus)
+    {
+        *buf_id = bufferID;
+    }
+
     return vaStatus;
 }
 
+
 VAStatus dummy_BufferSetNumElements(
                VADriverContextP ctx,
                VABufferID buf_id,      /* in */
@@ -865,8 +883,8 @@ VAStatus dummy_DestroyBuffer(
 
 VAStatus dummy_BeginPicture(
                VADriverContextP ctx,
-               VAContext *context,
-               VASurface *render_target
+               VAContextID context,
+               VASurfaceID render_target
        )
 {
     INIT_DRIVER_DATA
@@ -874,10 +892,10 @@ VAStatus dummy_BeginPicture(
     object_context_p obj_context;
     object_surface_p obj_surface;
 
-    obj_context = CONTEXT(context->context_id);
+    obj_context = CONTEXT(context);
     ASSERT(obj_context);
 
-    obj_surface = SURFACE(render_target->surface_id);
+    obj_surface = SURFACE(render_target);
     ASSERT(obj_surface);
 
     obj_context->current_render_target = obj_surface->base.id;
@@ -887,7 +905,7 @@ VAStatus dummy_BeginPicture(
 
 VAStatus dummy_RenderPicture(
                VADriverContextP ctx,
-               VAContext *context,
+               VAContextID context,
                VABufferID *buffers,
                int num_buffers
        )
@@ -898,7 +916,7 @@ VAStatus dummy_RenderPicture(
     object_surface_p obj_surface;
     int i;
 
-    obj_context = CONTEXT(context->context_id);
+    obj_context = CONTEXT(context);
     ASSERT(obj_context);
 
     obj_surface = SURFACE(obj_context->current_render_target);
@@ -915,13 +933,21 @@ VAStatus dummy_RenderPicture(
             break;
         }
     }
+    
+    /* Release buffers */
+    for(i = 0; i < num_buffers; i++)
+    {
+        object_buffer_p obj_buffer = BUFFER(buffers[i]);
+        ASSERT(obj_buffer);
+        dummy__destroy_buffer(driver_data, obj_buffer);
+    }
 
     return vaStatus;
 }
 
 VAStatus dummy_EndPicture(
                VADriverContextP ctx,
-               VAContext *context
+               VAContextID context
        )
 {
     INIT_DRIVER_DATA
@@ -929,7 +955,7 @@ VAStatus dummy_EndPicture(
     object_context_p obj_context;
     object_surface_p obj_surface;
 
-    obj_context = CONTEXT(context->context_id);
+    obj_context = CONTEXT(context);
     ASSERT(obj_context);
 
     obj_surface = SURFACE(obj_context->current_render_target);
@@ -944,62 +970,41 @@ VAStatus dummy_EndPicture(
 
 VAStatus dummy_SyncSurface(
                VADriverContextP ctx,
-               VAContext *context,
-               VASurface *render_target
+               VASurfaceID render_target
        )
 {
     INIT_DRIVER_DATA
     VAStatus vaStatus = VA_STATUS_SUCCESS;
-    object_context_p obj_context;
     object_surface_p obj_surface;
 
-    obj_context = CONTEXT(context->context_id);
-    ASSERT(obj_context);
-
-    obj_surface = SURFACE(render_target->surface_id);
+    obj_surface = SURFACE(render_target);
     ASSERT(obj_surface);
 
-    /* Assume that this shouldn't be called before vaEndPicture() */
-    ASSERT( obj_context->current_render_target != obj_surface->base.id );
-
     return vaStatus;
 }
 
 VAStatus dummy_QuerySurfaceStatus(
                VADriverContextP ctx,
-               VAContext *context,
-               VASurface *render_target,
+               VASurfaceID render_target,
                VASurfaceStatus *status /* out */
        )
 {
     INIT_DRIVER_DATA
     VAStatus vaStatus = VA_STATUS_SUCCESS;
-    object_context_p obj_context;
     object_surface_p obj_surface;
 
-    obj_context = CONTEXT(context->context_id);
-    ASSERT(obj_context);
-
-    obj_surface = SURFACE(render_target->surface_id);
+    obj_surface = SURFACE(render_target);
     ASSERT(obj_surface);
 
-    /* Assume that we are busy until vaEndPicture() is called */
-    if ( obj_context->current_render_target == obj_surface->base.id )
-    {
-        *status = VASurfaceRendering;
-    }
-    else
-    {
-        *status = VASurfaceReady;
-    }
+    *status = VASurfaceReady;
 
     return vaStatus;
 }
 
 VAStatus dummy_PutSurface(
                VADriverContextP ctx,
-               VASurface *surface,
-               Drawable draw, /* X Drawable */
+               VASurfaceID surface,
+               void *draw, /* X Drawable */
                short srcx,
                short srcy,
                unsigned short srcw,
@@ -1010,49 +1015,107 @@ VAStatus dummy_PutSurface(
                unsigned short desth,
                VARectangle *cliprects, /* client supplied clip list */
                unsigned int number_cliprects, /* number of clip rects in the clip list */
-               int flags /* de-interlacing flags */
+               unsigned int flags /* de-interlacing flags */
        )
 {
     /* TODO */
     return VA_STATUS_ERROR_UNKNOWN;
 }
 
+/* 
+ * Query display attributes 
+ * The caller must provide a "attr_list" array that can hold at
+ * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
+ * returned in "attr_list" is returned in "num_attributes".
+ */
+VAStatus dummy_QueryDisplayAttributes (
+               VADriverContextP ctx,
+               VADisplayAttribute *attr_list,  /* out */
+               int *num_attributes             /* out */
+       )
+{
+    /* TODO */
+    return VA_STATUS_ERROR_UNKNOWN;
+}
 
-VAStatus dummy_CopySurfaceToGLXPbuffer (
-               VADriverContextP ctx,
-               VASurface *surface,     
-               XID pbuffer_id,
-               short srcx,
-               short srcy,
-               unsigned short width,
-               unsigned short height,
-               short destx,
-               short desty,
-               unsigned int draw_buffer,
-               unsigned int flags /* de-interlacing flags */
-)
+/* 
+ * Get display attributes 
+ * This function returns the current attribute values in "attr_list".
+ * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
+ * from vaQueryDisplayAttributes() can have their values retrieved.  
+ */
+VAStatus dummy_GetDisplayAttributes (
+               VADriverContextP ctx,
+               VADisplayAttribute *attr_list,  /* in/out */
+               int num_attributes
+       )
 {
     /* TODO */
     return VA_STATUS_ERROR_UNKNOWN;
 }
 
-VAStatus dummy_DbgCopySurfaceToBuffer(
+/* 
+ * Set display attributes 
+ * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
+ * from vaQueryDisplayAttributes() can be set.  If the attribute is not settable or 
+ * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
+ */
+VAStatus dummy_SetDisplayAttributes (
                VADriverContextP ctx,
-               VASurface *surface,
-               void **buffer, /* out */
-               unsigned int *stride /* out */
+               VADisplayAttribute *attr_list,
+               int num_attributes
        )
 {
     /* TODO */
     return VA_STATUS_ERROR_UNKNOWN;
 }
 
+
+VAStatus dummy_BufferInfo(
+        VADriverContextP ctx,
+        VABufferID buf_id,     /* in */
+        VABufferType *type,    /* out */
+        unsigned int *size,            /* out */
+        unsigned int *num_elements /* out */
+    )
+{
+    /* TODO */
+    return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+    
+
+VAStatus dummy_LockSurface(
+               VADriverContextP ctx,
+               VASurfaceID surface,
+                unsigned int *fourcc, /* following are output 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,
+                unsigned int *buffer_name,
+               void **buffer
+       )
+{
+    /* TODO */
+    return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus dummy_UnlockSurface(
+               VADriverContextP ctx,
+               VASurfaceID surface
+       )
+{
+    /* TODO */
+    return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
 VAStatus dummy_Terminate( VADriverContextP ctx )
 {
     INIT_DRIVER_DATA
     object_buffer_p obj_buffer;
-    object_surface_p obj_surface;
-    object_context_p obj_context;
     object_config_p obj_config;
     object_heap_iterator iter;
 
@@ -1087,59 +1150,66 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus __vaDriverInit_0_23(  VADriverContextP ctx )
+VAStatus VA_DRIVER_INIT_FUNC(  VADriverContextP ctx )
 {
-    object_base_p obj;
+    struct VADriverVTable * const vtable = ctx->vtable;
     int result;
     struct dummy_driver_data *driver_data;
-    int i;
 
-    ctx->version_major = 0;
-    ctx->version_minor = 22;
+    ctx->version_major = VA_MAJOR_VERSION;
+    ctx->version_minor = VA_MINOR_VERSION;
     ctx->max_profiles = DUMMY_MAX_PROFILES;
     ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
     ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
     ctx->max_image_formats = DUMMY_MAX_IMAGE_FORMATS;
     ctx->max_subpic_formats = DUMMY_MAX_SUBPIC_FORMATS;
-
-    ctx->vtable.vaTerminate = dummy_Terminate;
-    ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
-    ctx->vtable.vaQueryConfigProfiles = dummy_QueryConfigProfiles;
-    ctx->vtable.vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
-    ctx->vtable.vaQueryConfigAttributes = dummy_QueryConfigAttributes;
-    ctx->vtable.vaCreateConfig = dummy_CreateConfig;
-    ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes;
-    ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces;
-    ctx->vtable.vaDestroySurface = dummy_DestroySurface;
-    ctx->vtable.vaCreateContext = dummy_CreateContext;
-    ctx->vtable.vaDestroyContext = dummy_DestroyContext;
-    ctx->vtable.vaCreateBuffer = dummy_CreateBuffer;
-    ctx->vtable.vaBufferData = dummy_BufferData;
-    ctx->vtable.vaBufferSetNumElements = dummy_BufferSetNumElements;
-    ctx->vtable.vaMapBuffer = dummy_MapBuffer;
-    ctx->vtable.vaUnmapBuffer = dummy_UnmapBuffer;
-    ctx->vtable.vaDestroyBuffer = dummy_DestroyBuffer;
-    ctx->vtable.vaBeginPicture = dummy_BeginPicture;
-    ctx->vtable.vaRenderPicture = dummy_RenderPicture;
-    ctx->vtable.vaEndPicture = dummy_EndPicture;
-    ctx->vtable.vaSyncSurface = dummy_SyncSurface;
-    ctx->vtable.vaQuerySurfaceStatus = dummy_QuerySurfaceStatus;
-    ctx->vtable.vaPutSurface = dummy_PutSurface;
-    ctx->vtable.vaCopySurfaceToGLXPbuffer = dummy_CopySurfaceToGLXPbuffer;
-    ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats;
-    ctx->vtable.vaCreateImage = dummy_CreateImage;
-    ctx->vtable.vaDestroyImage = dummy_DestroyImage;
-    ctx->vtable.vaGetImage = dummy_GetImage;
-    ctx->vtable.vaPutImage = dummy_PutImage;
-    ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
-    ctx->vtable.vaCreateSubpicture = dummy_CreateSubpicture;
-    ctx->vtable.vaDestroySubpicture = dummy_DestroySubpicture;
-    ctx->vtable.vaSetSubpictureImage = dummy_SetSubpictureImage;
-    ctx->vtable.vaSetSubpicturePalette = dummy_SetSubpicturePalette;
-    ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
-    ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
-    ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
-    ctx->vtable.vaDbgCopySurfaceToBuffer = dummy_DbgCopySurfaceToBuffer;
+    ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES;
+    ctx->str_vendor = DUMMY_STR_VENDOR;
+
+    vtable->vaTerminate = dummy_Terminate;
+    vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
+    vtable->vaQueryConfigProfiles = dummy_QueryConfigProfiles;
+    vtable->vaQueryConfigEntrypoints = dummy_QueryConfigEntrypoints;
+    vtable->vaQueryConfigAttributes = dummy_QueryConfigAttributes;
+    vtable->vaCreateConfig = dummy_CreateConfig;
+    vtable->vaDestroyConfig = dummy_DestroyConfig;
+    vtable->vaGetConfigAttributes = dummy_GetConfigAttributes;
+    vtable->vaCreateSurfaces = dummy_CreateSurfaces;
+    vtable->vaDestroySurfaces = dummy_DestroySurfaces;
+    vtable->vaCreateContext = dummy_CreateContext;
+    vtable->vaDestroyContext = dummy_DestroyContext;
+    vtable->vaCreateBuffer = dummy_CreateBuffer;
+    vtable->vaBufferSetNumElements = dummy_BufferSetNumElements;
+    vtable->vaMapBuffer = dummy_MapBuffer;
+    vtable->vaUnmapBuffer = dummy_UnmapBuffer;
+    vtable->vaDestroyBuffer = dummy_DestroyBuffer;
+    vtable->vaBeginPicture = dummy_BeginPicture;
+    vtable->vaRenderPicture = dummy_RenderPicture;
+    vtable->vaEndPicture = dummy_EndPicture;
+    vtable->vaSyncSurface = dummy_SyncSurface;
+    vtable->vaQuerySurfaceStatus = dummy_QuerySurfaceStatus;
+    vtable->vaPutSurface = dummy_PutSurface;
+    vtable->vaQueryImageFormats = dummy_QueryImageFormats;
+    vtable->vaCreateImage = dummy_CreateImage;
+    vtable->vaDeriveImage = dummy_DeriveImage;
+    vtable->vaDestroyImage = dummy_DestroyImage;
+    vtable->vaSetImagePalette = dummy_SetImagePalette;
+    vtable->vaGetImage = dummy_GetImage;
+    vtable->vaPutImage = dummy_PutImage;
+    vtable->vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
+    vtable->vaCreateSubpicture = dummy_CreateSubpicture;
+    vtable->vaDestroySubpicture = dummy_DestroySubpicture;
+    vtable->vaSetSubpictureImage = dummy_SetSubpictureImage;
+    vtable->vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
+    vtable->vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
+    vtable->vaAssociateSubpicture = dummy_AssociateSubpicture;
+    vtable->vaDeassociateSubpicture = dummy_DeassociateSubpicture;
+    vtable->vaQueryDisplayAttributes = dummy_QueryDisplayAttributes;
+    vtable->vaGetDisplayAttributes = dummy_GetDisplayAttributes;
+    vtable->vaSetDisplayAttributes = dummy_SetDisplayAttributes;
+    vtable->vaLockSurface = dummy_LockSurface;
+    vtable->vaUnlockSurface = dummy_UnlockSurface;
+    vtable->vaBufferInfo = dummy_BufferInfo;
 
     driver_data = (struct dummy_driver_data *) malloc( sizeof(*driver_data) );
     ctx->pDriverData = (void *) driver_data;