OSDN Git Service

Make VADriverContext.vtable a pointer.
[android-x86/hardware-intel-common-libva.git] / va / va_backend.h
1 /*
2  * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24
25 /*
26  * Video Decode Acceleration -Backend API
27  */
28
29 #ifndef _VA_BACKEND_H_
30 #define _VA_BACKEND_H_
31
32 #include <va/va.h>
33 #ifndef ANDROID
34 #include <X11/Xlib.h>
35 #endif
36 #include <linux/videodev2.h>
37
38 typedef struct VADriverContext *VADriverContextP;
39 typedef struct VADisplayContext *VADisplayContextP;
40
41 struct VADriverVTable
42 {
43         VAStatus (*vaTerminate) ( VADriverContextP ctx );
44
45         VAStatus (*vaQueryConfigProfiles) (
46                 VADriverContextP ctx,
47                 VAProfile *profile_list,        /* out */
48                 int *num_profiles                       /* out */
49         );
50
51         VAStatus (*vaQueryConfigEntrypoints) (
52                 VADriverContextP ctx,
53                 VAProfile profile,
54                 VAEntrypoint  *entrypoint_list, /* out */
55                 int *num_entrypoints                    /* out */
56         );
57
58         VAStatus (*vaGetConfigAttributes) (
59                 VADriverContextP ctx,
60                 VAProfile profile,
61                 VAEntrypoint entrypoint,
62                 VAConfigAttrib *attrib_list,    /* in/out */
63                 int num_attribs
64         );
65
66         VAStatus (*vaCreateConfig) (
67                 VADriverContextP ctx,
68                 VAProfile profile, 
69                 VAEntrypoint entrypoint, 
70                 VAConfigAttrib *attrib_list,
71                 int num_attribs,
72                 VAConfigID *config_id           /* out */
73         );
74
75         VAStatus (*vaDestroyConfig) (
76                 VADriverContextP ctx,
77                 VAConfigID config_id
78         );
79
80         VAStatus (*vaQueryConfigAttributes) (
81                 VADriverContextP ctx,
82                 VAConfigID config_id, 
83                 VAProfile *profile,             /* out */
84                 VAEntrypoint *entrypoint,       /* out */
85                 VAConfigAttrib *attrib_list,    /* out */
86                 int *num_attribs                /* out */
87         );
88
89         VAStatus (*vaCreateSurfaces) (
90                 VADriverContextP ctx,
91                 int width,
92                 int height,
93                 int format,
94                 int num_surfaces,
95                 VASurfaceID *surfaces           /* out */
96         );
97
98         VAStatus (*vaDestroySurfaces) (
99                 VADriverContextP ctx,
100                 VASurfaceID *surface_list,
101                 int num_surfaces
102         );
103
104         VAStatus (*vaCreateContext) (
105                 VADriverContextP ctx,
106                 VAConfigID config_id,
107                 int picture_width,
108                 int picture_height,
109                 int flag,
110                 VASurfaceID *render_targets,
111                 int num_render_targets,
112                 VAContextID *context            /* out */
113         );
114
115         VAStatus (*vaDestroyContext) (
116                 VADriverContextP ctx,
117                 VAContextID context
118         );
119
120         VAStatus (*vaCreateBuffer) (
121                 VADriverContextP ctx,
122                 VAContextID context,            /* in */
123                 VABufferType type,              /* in */
124                 unsigned int size,              /* in */
125                 unsigned int num_elements,      /* in */
126                 void *data,                     /* in */
127                 VABufferID *buf_id              /* out */
128         );
129
130         VAStatus (*vaBufferSetNumElements) (
131                 VADriverContextP ctx,
132                 VABufferID buf_id,      /* in */
133                 unsigned int num_elements       /* in */
134         );
135
136         VAStatus (*vaMapBuffer) (
137                 VADriverContextP ctx,
138                 VABufferID buf_id,      /* in */
139                 void **pbuf         /* out */
140         );
141
142         VAStatus (*vaUnmapBuffer) (
143                 VADriverContextP ctx,
144                 VABufferID buf_id       /* in */
145         );
146
147         VAStatus (*vaDestroyBuffer) (
148                 VADriverContextP ctx,
149                 VABufferID buffer_id
150         );
151
152         VAStatus (*vaBeginPicture) (
153                 VADriverContextP ctx,
154                 VAContextID context,
155                 VASurfaceID render_target
156         );
157
158         VAStatus (*vaRenderPicture) (
159                 VADriverContextP ctx,
160                 VAContextID context,
161                 VABufferID *buffers,
162                 int num_buffers
163         );
164
165         VAStatus (*vaEndPicture) (
166                 VADriverContextP ctx,
167                 VAContextID context
168         );
169
170         VAStatus (*vaSyncSurface) (
171                 VADriverContextP ctx,
172                 VASurfaceID render_target
173         );
174
175         VAStatus (*vaQuerySurfaceStatus) (
176                 VADriverContextP ctx,
177                 VASurfaceID render_target,
178                 VASurfaceStatus *status /* out */
179         );
180
181         VAStatus (*vaQuerySurfaceError) (
182                 VADriverContextP ctx,
183                 VASurfaceID render_target,
184         VAStatus error_status,
185         void **error_info /*out*/
186         );
187
188         VAStatus (*vaPutSurface) (
189                 VADriverContextP ctx,
190                 VASurfaceID surface,
191                 void* draw, /* Drawable of window system */
192                 short srcx,
193                 short srcy,
194                 unsigned short srcw,
195                 unsigned short srch,
196                 short destx,
197                 short desty,
198                 unsigned short destw,
199                 unsigned short desth,
200                 VARectangle *cliprects, /* client supplied clip list */
201                 unsigned int number_cliprects, /* number of clip rects in the clip list */
202                 unsigned int flags /* de-interlacing flags */
203         );
204
205         VAStatus (*vaQueryImageFormats) (
206                 VADriverContextP ctx,
207                 VAImageFormat *format_list,        /* out */
208                 int *num_formats           /* out */
209         );
210
211         VAStatus (*vaCreateImage) (
212                 VADriverContextP ctx,
213                 VAImageFormat *format,
214                 int width,
215                 int height,
216                 VAImage *image     /* out */
217         );
218
219         VAStatus (*vaDeriveImage) (
220                 VADriverContextP ctx,
221                 VASurfaceID surface,
222                 VAImage *image     /* out */
223         );
224
225         VAStatus (*vaDestroyImage) (
226                 VADriverContextP ctx,
227                 VAImageID image
228         );
229         
230         VAStatus (*vaSetImagePalette) (
231                 VADriverContextP ctx,
232                 VAImageID image,
233                 /*
234                  * pointer to an array holding the palette data.  The size of the array is
235                  * num_palette_entries * entry_bytes in size.  The order of the components
236                  * in the palette is described by the component_order in VAImage struct
237                  */
238                 unsigned char *palette
239         );
240         
241         VAStatus (*vaGetImage) (
242                 VADriverContextP ctx,
243                 VASurfaceID surface,
244                 int x,     /* coordinates of the upper left source pixel */
245                 int y,
246                 unsigned int width, /* width and height of the region */
247                 unsigned int height,
248                 VAImageID image
249         );
250
251         VAStatus (*vaPutImage) (
252                 VADriverContextP ctx,
253                 VASurfaceID surface,
254                 VAImageID image,
255                 int src_x,
256                 int src_y,
257                 unsigned int src_width,
258                 unsigned int src_height,
259                 int dest_x,
260                 int dest_y,
261                 unsigned int dest_width,
262                 unsigned int dest_height
263         );
264
265         VAStatus (*vaQuerySubpictureFormats) (
266                 VADriverContextP ctx,
267                 VAImageFormat *format_list,        /* out */
268                 unsigned int *flags,       /* out */
269                 unsigned int *num_formats  /* out */
270         );
271
272         VAStatus (*vaCreateSubpicture) (
273                 VADriverContextP ctx,
274                 VAImageID image,
275                 VASubpictureID *subpicture   /* out */
276         );
277
278         VAStatus (*vaDestroySubpicture) (
279                 VADriverContextP ctx,
280                 VASubpictureID subpicture
281         );
282
283         VAStatus (*vaSetSubpictureImage) (
284                 VADriverContextP ctx,
285                 VASubpictureID subpicture,
286                 VAImageID image
287         );
288
289         VAStatus (*vaSetSubpictureChromakey) (
290                 VADriverContextP ctx,
291                 VASubpictureID subpicture,
292                 unsigned int chromakey_min,
293                 unsigned int chromakey_max,
294                 unsigned int chromakey_mask
295         );
296
297         VAStatus (*vaSetSubpictureGlobalAlpha) (
298                 VADriverContextP ctx,
299                 VASubpictureID subpicture,
300                 float global_alpha 
301         );
302
303         VAStatus (*vaAssociateSubpicture) (
304                 VADriverContextP ctx,
305                 VASubpictureID subpicture,
306                 VASurfaceID *target_surfaces,
307                 int num_surfaces,
308                 short src_x, /* upper left offset in subpicture */
309                 short src_y,
310                 unsigned short src_width,
311                 unsigned short src_height,
312                 short dest_x, /* upper left offset in surface */
313                 short dest_y,
314                 unsigned short dest_width,
315                 unsigned short dest_height,
316                 /*
317                  * whether to enable chroma-keying or global-alpha
318                  * see VA_SUBPICTURE_XXX values
319                  */
320                 unsigned int flags
321         );
322
323         VAStatus (*vaDeassociateSubpicture) (
324                 VADriverContextP ctx,
325                 VASubpictureID subpicture,
326                 VASurfaceID *target_surfaces,
327                 int num_surfaces
328         );
329
330         VAStatus (*vaQueryDisplayAttributes) (
331                 VADriverContextP ctx,
332                 VADisplayAttribute *attr_list,  /* out */
333                 int *num_attributes             /* out */
334         );
335
336         VAStatus (*vaGetDisplayAttributes) (
337                 VADriverContextP ctx,
338                 VADisplayAttribute *attr_list,  /* in/out */
339                 int num_attributes
340         );
341         
342         VAStatus (*vaSetDisplayAttributes) (
343                 VADriverContextP ctx,
344                 VADisplayAttribute *attr_list,
345                 int num_attributes
346         );
347
348         /* used by va trace */        
349         VAStatus (*vaBufferInfo) (
350                    VADriverContextP ctx,
351                    VAContextID context, /* in */
352                    VABufferID buf_id, /* in */
353                    VABufferType *type,    /* out */
354                    unsigned int *size,    /* out */
355                    unsigned int *num_elements /* out */
356         );
357
358         /* lock/unlock surface for external access */    
359         VAStatus (*vaLockSurface) (
360                 VADriverContextP ctx,
361                 VASurfaceID surface,
362                 unsigned int *fourcc, /* out  for follow argument */
363                 unsigned int *luma_stride,
364                 unsigned int *chroma_u_stride,
365                 unsigned int *chroma_v_stride,
366                 unsigned int *luma_offset,
367                 unsigned int *chroma_u_offset,
368                 unsigned int *chroma_v_offset,
369                 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
370                                             * surface buffer name
371                                             */
372                 void **buffer /* if it is not NULL, map the surface buffer for
373                                 * CPU access
374                                 */
375         );
376     
377         VAStatus (*vaUnlockSurface) (
378                 VADriverContextP ctx,
379                 VASurfaceID surface
380         );
381 };
382
383 struct VADriverContext
384 {
385     void *pDriverData;
386
387     /**
388      * The core VA implementation hooks.
389      *
390      * This structure is allocated from libva with calloc().
391      */
392     struct VADriverVTable *vtable;
393
394     /**
395      * The VA/GLX implementation hooks.
396      *
397      * This structure is intended for drivers that implement the
398      * VA/GLX API. The driver implementation is responsible for the
399      * allocation and deallocation of this structure.
400      */
401     struct VADriverVTableGLX *vtable_glx;
402
403     void *vtable_tpi; /* the structure is malloc-ed */
404
405     void *native_dpy;
406     int x11_screen;
407     int version_major;
408     int version_minor;
409     int max_profiles;
410     int max_entrypoints;
411     int max_attributes;
412     int max_image_formats;
413     int max_subpic_formats;
414     int max_display_attributes;
415     const char *str_vendor;
416
417     void *handle;                       /* dlopen handle */
418     
419     void *dri_state;
420     void *glx;                          /* opaque for GLX code */
421 };
422
423 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
424 struct VADisplayContext
425 {
426     int vadpy_magic;
427     
428     VADisplayContextP pNext;
429     VADriverContextP pDriverContext;
430
431     int (*vaIsValid) (
432         VADisplayContextP ctx
433     );
434
435     void (*vaDestroy) (
436         VADisplayContextP ctx
437     );
438
439     VAStatus (*vaGetDriverName) (
440         VADisplayContextP ctx,
441         char **driver_name
442     );
443
444     void *opaque; /* opaque for display extensions (e.g. GLX) */
445 };
446
447 typedef VAStatus (*VADriverInit) (
448     VADriverContextP driver_context
449 );
450
451 #endif /* _VA_BACKEND_H_ */