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 98561a9..282f208 100644 (file)
@@ -22,6 +22,7 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include "config.h"
 #include <va/va_backend.h>
 
 #include "dummy_drv_video.h"
@@ -34,7 +35,7 @@
 
 #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 ))
@@ -72,7 +73,6 @@ VAStatus dummy_QueryConfigProfiles(
                int *num_profiles                       /* out */
        )
 {
-    INIT_DRIVER_DATA
     int i = 0;
 
     profile_list[i++] = VAProfileMPEG2Simple;
@@ -101,8 +101,6 @@ VAStatus dummy_QueryConfigEntrypoints(
                int *num_entrypoints            /* out */
        )
 {
-    INIT_DRIVER_DATA
-
     switch (profile) {
         case VAProfileMPEG2Simple:
         case VAProfileMPEG2Main:
@@ -150,8 +148,6 @@ VAStatus dummy_GetConfigAttributes(
                int num_attribs
        )
 {
-    INIT_DRIVER_DATA
-
     int i;
 
     /* Other attributes don't seem to be defined */
@@ -432,8 +428,6 @@ VAStatus dummy_QueryImageFormats(
        int *num_formats           /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -446,8 +440,6 @@ VAStatus dummy_CreateImage(
        VAImage *image     /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -458,8 +450,6 @@ VAStatus dummy_DeriveImage(
        VAImage *image     /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -469,8 +459,6 @@ VAStatus dummy_DestroyImage(
        VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -481,8 +469,6 @@ VAStatus dummy_SetImagePalette(
        unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -497,8 +483,6 @@ VAStatus dummy_GetImage(
        VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -518,8 +502,6 @@ VAStatus dummy_PutImage(
        unsigned int dest_height
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -531,8 +513,6 @@ VAStatus dummy_QuerySubpictureFormats(
        unsigned int *num_formats  /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -543,8 +523,6 @@ VAStatus dummy_CreateSubpicture(
        VASubpictureID *subpicture   /* out */
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -554,8 +532,6 @@ VAStatus dummy_DestroySubpicture(
        VASubpictureID subpicture
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -566,8 +542,6 @@ VAStatus dummy_SetSubpictureImage(
         VAImageID image
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -583,8 +557,6 @@ VAStatus dummy_SetSubpicturePalette(
        unsigned char *palette
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -597,8 +569,6 @@ VAStatus dummy_SetSubpictureChromakey(
        unsigned int chromakey_mask
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -609,8 +579,6 @@ VAStatus dummy_SetSubpictureGlobalAlpha(
        float global_alpha 
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -636,8 +604,6 @@ VAStatus dummy_AssociateSubpicture(
        unsigned int flags
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -649,8 +615,6 @@ VAStatus dummy_DeassociateSubpicture(
        int num_surfaces
 )
 {
-    INIT_DRIVER_DATA
-    
     /* TODO */
     return VA_STATUS_SUCCESS;
 }
@@ -1040,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,
@@ -1107,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 */
@@ -1117,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;
 
@@ -1164,12 +1150,11 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
     return VA_STATUS_SUCCESS;
 }
 
-VAStatus __vaDriverInit_0_31(  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;
@@ -1181,49 +1166,50 @@ VAStatus __vaDriverInit_0_31(  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.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.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;