Home | History | Annotate | Download | only in va
      1 /**************************************************************************
      2  *
      3  * Copyright 2010 Thomas Balling Srensen & Orasanu Lucian.
      4  * All Rights Reserved.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the
      8  * "Software"), to deal in the Software without restriction, including
      9  * without limitation the rights to use, copy, modify, merge, publish,
     10  * distribute, sub license, and/or sell copies of the Software, and to
     11  * permit persons to whom the Software is furnished to do so, subject to
     12  * the following conditions:
     13  *
     14  * The above copyright notice and this permission notice (including the
     15  * next paragraph) shall be included in all copies or substantial portions
     16  * of the Software.
     17  *
     18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
     21  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
     22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     25  *
     26  **************************************************************************/
     27 
     28 #ifndef VA_PRIVATE_H
     29 #define VA_PRIVATE_H
     30 
     31 #include <va/va.h>
     32 #include <va/va_backend.h>
     33 
     34 #include "pipe/p_format.h"
     35 #include "pipe/p_state.h"
     36 
     37 #define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__)
     38 #define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__)
     39 #define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__)
     40 #define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__)
     41 
     42 #define VA_MAX_IMAGE_FORMATS_SUPPORTED 2
     43 #define VA_MAX_SUBPIC_FORMATS_SUPPORTED 2
     44 #define VA_MAX_ENTRYPOINTS 1
     45 
     46 #define VL_HANDLES
     47 
     48 typedef struct {
     49    struct vl_screen *vscreen;
     50    struct pipe_surface *backbuffer;
     51 } vlVaDriverContextPriv;
     52 
     53 typedef struct {
     54    unsigned int width;
     55    unsigned int height;
     56    enum pipe_video_chroma_format format;
     57    VADriverContextP ctx;
     58 } vlVaSurfacePriv;
     59 
     60 // Public functions:
     61 VAStatus __vaDriverInit_0_31 (VADriverContextP ctx);
     62 
     63 // Private functions:
     64 struct VADriverVTable vlVaGetVtable();
     65 
     66 bool vlCreateHTAB(void);
     67 void vlDestroyHTAB(void);
     68 VAGenericID vlAddDataHTAB(void *data);
     69 void* vlGetDataHTAB(VAGenericID handle);
     70 
     71 // Vtable functions:
     72 VAStatus vlVaTerminate (VADriverContextP ctx);
     73 VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
     74 VAStatus vlVaQueryConfigEntrypoints (VADriverContextP ctx, VAProfile profile, VAEntrypoint  *entrypoint_list, int *num_entrypoints);
     75 VAStatus vlVaGetConfigAttributes (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs);
     76 VAStatus vlVaCreateConfig (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id);
     77 VAStatus vlVaDestroyConfig (VADriverContextP ctx, VAConfigID config_id);
     78 VAStatus vlVaQueryConfigAttributes (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs);
     79 VAStatus vlVaCreateSurfaces (VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces);
     80 VAStatus vlVaDestroySurfaces (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces);
     81 VAStatus vlVaCreateContext (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context);
     82 VAStatus vlVaDestroyContext (VADriverContextP ctx,VAContextID context);
     83 VAStatus vlVaCreateBuffer (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id);
     84 VAStatus vlVaBufferSetNumElements (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements);
     85 VAStatus vlVaMapBuffer (VADriverContextP ctx,VABufferID buf_id,void **pbuf);
     86 VAStatus vlVaUnmapBuffer (VADriverContextP ctx,VABufferID buf_id);
     87 VAStatus vlVaDestroyBuffer (VADriverContextP ctx,VABufferID buffer_id);
     88 VAStatus vlVaBeginPicture (VADriverContextP ctx,VAContextID context,VASurfaceID render_target);
     89 VAStatus vlVaRenderPicture (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers);
     90 VAStatus vlVaEndPicture (VADriverContextP ctx,VAContextID context);
     91 VAStatus vlVaSyncSurface (VADriverContextP ctx,VASurfaceID render_target);
     92 VAStatus vlVaQuerySurfaceStatus (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status);
     93 VAStatus vlVaPutSurface (VADriverContextP ctx,
     94                          VASurfaceID surface,
     95                          void* draw,
     96                          short srcx,
     97                          short srcy,
     98                          unsigned short srcw,
     99                          unsigned short srch,
    100                          short destx,
    101                          short desty,
    102                          unsigned short destw,
    103                          unsigned short desth,
    104                          VARectangle *cliprects,
    105                          unsigned int number_cliprects,
    106                          unsigned int flags);
    107 VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats);
    108 VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
    109 VAStatus vlVaCreateImage(VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image);
    110 VAStatus vlVaDeriveImage(VADriverContextP ctx,VASurfaceID surface,VAImage *image);
    111 VAStatus vlVaDestroyImage(VADriverContextP ctx,VAImageID image);
    112 VAStatus vlVaSetImagePalette(VADriverContextP ctx,VAImageID image, unsigned char *palette);
    113 VAStatus vlVaGetImage(VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image);
    114 VAStatus vlVaPutImage(VADriverContextP ctx,
    115                       VASurfaceID surface,
    116                       VAImageID image,
    117                       int src_x,
    118                       int src_y,
    119                       unsigned int src_width,
    120                       unsigned int src_height,
    121                       int dest_x,
    122                       int dest_y,
    123                       unsigned int dest_width,
    124                       unsigned int dest_height);
    125 VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
    126 VAStatus vlVaCreateSubpicture(VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture);
    127 VAStatus vlVaDestroySubpicture(VADriverContextP ctx,VASubpictureID subpicture);
    128 VAStatus vlVaSubpictureImage(VADriverContextP ctx,VASubpictureID subpicture,VAImageID image);
    129 VAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask);
    130 VAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx,VASubpictureID subpicture,float global_alpha);
    131 VAStatus vlVaAssociateSubpicture(VADriverContextP ctx,
    132                                  VASubpictureID subpicture,
    133                                  VASurfaceID *target_surfaces,
    134                                  int num_surfaces,
    135                                  short src_x,
    136                                  short src_y,
    137                                  unsigned short src_width,
    138                                  unsigned short src_height,
    139                                  short dest_x,
    140                                  short dest_y,
    141                                  unsigned short dest_width,
    142                                  unsigned short dest_height,
    143                                  unsigned int flags);
    144 VAStatus vlVaDeassociateSubpicture(VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces);
    145 VAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes);
    146 VAStatus vlVaGetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
    147 VAStatus vlVaSetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
    148 VAStatus vlVaBufferInfo(VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements);
    149 VAStatus vlVaLockSurface(VADriverContextP ctx,
    150                          VASurfaceID surface,
    151                          unsigned int *fourcc,
    152                          unsigned int *luma_stride,
    153                          unsigned int *chroma_u_stride,
    154                          unsigned int *chroma_v_stride,
    155                          unsigned int *luma_offset,
    156                          unsigned int *chroma_u_offset,
    157                          unsigned int *chroma_v_offset,
    158                          unsigned int *buffer_name,
    159                          void **buffer);
    160 VAStatus vlVaUnlockSurface(VADriverContextP ctx,VASurfaceID surface);
    161 
    162 #endif //VA_PRIVATE_H
    163