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 1eb51a0..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:
@@ -149,8 +148,6 @@ VAStatus dummy_GetConfigAttributes(
                int num_attribs
        )
 {
-    INIT_DRIVER_DATA
-
     int i;
 
     /* Other attributes don't seem to be defined */
@@ -431,8 +428,6 @@ VAStatus dummy_QueryImageFormats(
        int *num_formats           /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -445,8 +440,6 @@ VAStatus dummy_CreateImage(
        VAImage *image     /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -457,8 +450,6 @@ VAStatus dummy_DeriveImage(
        VAImage *image     /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -468,8 +459,6 @@ VAStatus dummy_DestroyImage(
        VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -480,8 +469,6 @@ VAStatus dummy_SetImagePalette(
        unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -496,31 +483,12 @@ VAStatus dummy_GetImage(
        VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus dummy_PutImage(
-       VADriverContextP ctx,
-       VASurfaceID surface,
-       VAImageID image,
-       int src_x,
-       int src_y,
-       unsigned int width,
-       unsigned int height,
-       int dest_x,
-       int dest_y 
-)
-{
-    INIT_DRIVER_DATA
-    
-    /* TODO */
-    return VA_STATUS_SUCCESS;
-}
 
-VAStatus dummy_PutImage2(
+VAStatus dummy_PutImage(
        VADriverContextP ctx,
        VASurfaceID surface,
        VAImageID image,
@@ -534,8 +502,6 @@ VAStatus dummy_PutImage2(
        unsigned int dest_height
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -547,8 +513,6 @@ VAStatus dummy_QuerySubpictureFormats(
        unsigned int *num_formats  /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -559,8 +523,6 @@ VAStatus dummy_CreateSubpicture(
        VASubpictureID *subpicture   /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -570,8 +532,6 @@ VAStatus dummy_DestroySubpicture(
        VASubpictureID subpicture
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -582,8 +542,6 @@ VAStatus dummy_SetSubpictureImage(
         VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -599,8 +557,6 @@ VAStatus dummy_SetSubpicturePalette(
        unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -613,8 +569,6 @@ VAStatus dummy_SetSubpictureChromakey(
        unsigned int chromakey_mask
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -625,37 +579,12 @@ VAStatus dummy_SetSubpictureGlobalAlpha(
        float global_alpha 
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus dummy_AssociateSubpicture(
-       VADriverContextP 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
-)
-{
-    INIT_DRIVER_DATA
-    
-    /* TODO */
-    return VA_STATUS_SUCCESS;
-}
 
-VAStatus dummy_AssociateSubpicture2(
+VAStatus dummy_AssociateSubpicture(
        VADriverContextP ctx,
        VASubpictureID subpicture,
        VASurfaceID *target_surfaces,
@@ -675,8 +604,6 @@ VAStatus dummy_AssociateSubpicture2(
        unsigned int flags
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -688,8 +615,6 @@ VAStatus dummy_DeassociateSubpicture(
        int num_surfaces
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -1045,24 +970,16 @@ VAStatus dummy_EndPicture(
 
 VAStatus dummy_SyncSurface(
                VADriverContextP ctx,
-               VAContextID context,
                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);
-    ASSERT(obj_context);
-
     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;
 }
 
@@ -1087,7 +1004,7 @@ VAStatus dummy_QuerySurfaceStatus(
 VAStatus dummy_PutSurface(
                VADriverContextP ctx,
                VASurfaceID surface,
-               Drawable draw, /* X Drawable */
+               void *draw, /* X Drawable */
                short srcx,
                short srcy,
                unsigned short srcw,
@@ -1154,7 +1071,21 @@ VAStatus dummy_SetDisplayAttributes (
 }
 
 
-VAStatus dummy_CopySurfaceToBuffer(
+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 */
@@ -1164,19 +1095,27 @@ VAStatus dummy_CopySurfaceToBuffer(
                 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_UNKNOWN;
+    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;
 
@@ -1211,12 +1150,11 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus __vaDriverInit_0_30(  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 = VA_MAJOR_VERSION;
     ctx->version_minor = VA_MINOR_VERSION;
@@ -1228,51 +1166,50 @@ VAStatus __vaDriverInit_0_30(  VADriverContextP ctx )
     ctx->max_display_attributes = DUMMY_MAX_DISPLAY_ATTRIBUTES;
     ctx->str_vendor = DUMMY_STR_VENDOR;
 
-    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.vaDestroyConfig = dummy_DestroyConfig;
-    ctx->vtable.vaGetConfigAttributes = dummy_GetConfigAttributes;
-    ctx->vtable.vaCreateSurfaces = dummy_CreateSurfaces;
-    ctx->vtable.vaDestroySurfaces = dummy_DestroySurfaces;
-    ctx->vtable.vaCreateContext = dummy_CreateContext;
-    ctx->vtable.vaDestroyContext = dummy_DestroyContext;
-    ctx->vtable.vaCreateBuffer = dummy_CreateBuffer;
-    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.vaQueryImageFormats = dummy_QueryImageFormats;
-    ctx->vtable.vaCreateImage = dummy_CreateImage;
-    ctx->vtable.vaDeriveImage = dummy_DeriveImage;
-    ctx->vtable.vaDestroyImage = dummy_DestroyImage;
-    ctx->vtable.vaSetImagePalette = dummy_SetImagePalette;
-    ctx->vtable.vaGetImage = dummy_GetImage;
-    ctx->vtable.vaPutImage = dummy_PutImage;
-    ctx->vtable.vaPutImage2 = dummy_PutImage2;
-    ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
-    ctx->vtable.vaCreateSubpicture = dummy_CreateSubpicture;
-    ctx->vtable.vaDestroySubpicture = dummy_DestroySubpicture;
-    ctx->vtable.vaSetSubpictureImage = dummy_SetSubpictureImage;
-    ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
-    ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
-    ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
-    ctx->vtable.vaAssociateSubpicture2 = dummy_AssociateSubpicture2;
-    ctx->vtable.vaDeassociateSubpicture = dummy_DeassociateSubpicture;
-    ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes;
-    ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes;
-    ctx->vtable.vaSetDisplayAttributes = dummy_SetDisplayAttributes;
-    
-    ctx->vtable.vaCopySurfaceToBuffer = dummy_CopySurfaceToBuffer;
+    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;