OSDN Git Service

Fix build issue
[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 (*vaPutSurface) (
182                 VADriverContextP ctx,
183                 VASurfaceID surface,
184                 void* draw, /* Drawable of window system */
185                 short srcx,
186                 short srcy,
187                 unsigned short srcw,
188                 unsigned short srch,
189                 short destx,
190                 short desty,
191                 unsigned short destw,
192                 unsigned short desth,
193                 VARectangle *cliprects, /* client supplied clip list */
194                 unsigned int number_cliprects, /* number of clip rects in the clip list */
195                 unsigned int flags /* de-interlacing flags */
196         );
197
198         VAStatus (*vaQueryImageFormats) (
199                 VADriverContextP ctx,
200                 VAImageFormat *format_list,        /* out */
201                 int *num_formats           /* out */
202         );
203
204         VAStatus (*vaCreateImage) (
205                 VADriverContextP ctx,
206                 VAImageFormat *format,
207                 int width,
208                 int height,
209                 VAImage *image     /* out */
210         );
211
212         VAStatus (*vaDeriveImage) (
213                 VADriverContextP ctx,
214                 VASurfaceID surface,
215                 VAImage *image     /* out */
216         );
217
218         VAStatus (*vaDestroyImage) (
219                 VADriverContextP ctx,
220                 VAImageID image
221         );
222         
223         VAStatus (*vaSetImagePalette) (
224                 VADriverContextP ctx,
225                 VAImageID image,
226                 /*
227                  * pointer to an array holding the palette data.  The size of the array is
228                  * num_palette_entries * entry_bytes in size.  The order of the components
229                  * in the palette is described by the component_order in VAImage struct
230                  */
231                 unsigned char *palette
232         );
233         
234         VAStatus (*vaGetImage) (
235                 VADriverContextP ctx,
236                 VASurfaceID surface,
237                 int x,     /* coordinates of the upper left source pixel */
238                 int y,
239                 unsigned int width, /* width and height of the region */
240                 unsigned int height,
241                 VAImageID image
242         );
243
244         VAStatus (*vaPutImage) (
245                 VADriverContextP ctx,
246                 VASurfaceID surface,
247                 VAImageID image,
248                 int src_x,
249                 int src_y,
250                 unsigned int src_width,
251                 unsigned int src_height,
252                 int dest_x,
253                 int dest_y,
254                 unsigned int dest_width,
255                 unsigned int dest_height
256         );
257
258         VAStatus (*vaQuerySubpictureFormats) (
259                 VADriverContextP ctx,
260                 VAImageFormat *format_list,        /* out */
261                 unsigned int *flags,       /* out */
262                 unsigned int *num_formats  /* out */
263         );
264
265         VAStatus (*vaCreateSubpicture) (
266                 VADriverContextP ctx,
267                 VAImageID image,
268                 VASubpictureID *subpicture   /* out */
269         );
270
271         VAStatus (*vaDestroySubpicture) (
272                 VADriverContextP ctx,
273                 VASubpictureID subpicture
274         );
275
276         VAStatus (*vaSetSubpictureImage) (
277                 VADriverContextP ctx,
278                 VASubpictureID subpicture,
279                 VAImageID image
280         );
281
282         VAStatus (*vaSetSubpictureChromakey) (
283                 VADriverContextP ctx,
284                 VASubpictureID subpicture,
285                 unsigned int chromakey_min,
286                 unsigned int chromakey_max,
287                 unsigned int chromakey_mask
288         );
289
290         VAStatus (*vaSetSubpictureGlobalAlpha) (
291                 VADriverContextP ctx,
292                 VASubpictureID subpicture,
293                 float global_alpha 
294         );
295
296         VAStatus (*vaAssociateSubpicture) (
297                 VADriverContextP ctx,
298                 VASubpictureID subpicture,
299                 VASurfaceID *target_surfaces,
300                 int num_surfaces,
301                 short src_x, /* upper left offset in subpicture */
302                 short src_y,
303                 unsigned short src_width,
304                 unsigned short src_height,
305                 short dest_x, /* upper left offset in surface */
306                 short dest_y,
307                 unsigned short dest_width,
308                 unsigned short dest_height,
309                 /*
310                  * whether to enable chroma-keying or global-alpha
311                  * see VA_SUBPICTURE_XXX values
312                  */
313                 unsigned int flags
314         );
315
316         VAStatus (*vaDeassociateSubpicture) (
317                 VADriverContextP ctx,
318                 VASubpictureID subpicture,
319                 VASurfaceID *target_surfaces,
320                 int num_surfaces
321         );
322
323         VAStatus (*vaQueryDisplayAttributes) (
324                 VADriverContextP ctx,
325                 VADisplayAttribute *attr_list,  /* out */
326                 int *num_attributes             /* out */
327         );
328
329         VAStatus (*vaGetDisplayAttributes) (
330                 VADriverContextP ctx,
331                 VADisplayAttribute *attr_list,  /* in/out */
332                 int num_attributes
333         );
334         
335         VAStatus (*vaSetDisplayAttributes) (
336                 VADriverContextP ctx,
337                 VADisplayAttribute *attr_list,
338                 int num_attributes
339         );
340
341         /* used by va trace */        
342         VAStatus (*vaBufferInfo) (
343                    VADriverContextP ctx,
344                    VAContextID context, /* in */
345                    VABufferID buf_id, /* in */
346                    VABufferType *type,    /* out */
347                    unsigned int *size,    /* out */
348                    unsigned int *num_elements /* out */
349         );
350
351         /* lock/unlock surface for external access */    
352         VAStatus (*vaLockSurface) (
353                 VADriverContextP ctx,
354                 VASurfaceID surface,
355                 unsigned int *fourcc, /* out  for follow argument */
356                 unsigned int *luma_stride,
357                 unsigned int *chroma_u_stride,
358                 unsigned int *chroma_v_stride,
359                 unsigned int *luma_offset,
360                 unsigned int *chroma_u_offset,
361                 unsigned int *chroma_v_offset,
362                 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
363                                             * surface buffer name
364                                             */
365                 void **buffer /* if it is not NULL, map the surface buffer for
366                                 * CPU access
367                                 */
368         );
369     
370         VAStatus (*vaUnlockSurface) (
371                 VADriverContextP ctx,
372                 VASurfaceID surface
373         );
374
375         /* Optional: GLX support hooks */
376         struct VADriverVTableGLX *glx;
377 };
378
379 struct VADriverContext
380 {
381     void *pDriverData;
382     struct VADriverVTable vtable;
383     void *vtable_tpi; /* the structure is malloc-ed */
384
385     void *native_dpy;
386     int x11_screen;
387     int version_major;
388     int version_minor;
389     int max_profiles;
390     int max_entrypoints;
391     int max_attributes;
392     int max_image_formats;
393     int max_subpic_formats;
394     int max_display_attributes;
395     const char *str_vendor;
396
397     void *handle;                       /* dlopen handle */
398     
399     void *dri_state;
400     void *glx;  /* opaque for GLX code */
401 };
402
403 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
404 struct VADisplayContext
405 {
406     int vadpy_magic;
407     
408     VADisplayContextP pNext;
409     VADriverContextP pDriverContext;
410
411     int (*vaIsValid) (
412         VADisplayContextP ctx
413     );
414
415     void (*vaDestroy) (
416         VADisplayContextP ctx
417     );
418
419     VAStatus (*vaGetDriverName) (
420         VADisplayContextP ctx,
421         char **driver_name
422     );
423
424     void *opaque; /* opaque for display extensions (e.g. GLX) */
425 };
426
427 typedef VAStatus (*VADriverInit) (
428     VADriverContextP driver_context
429 );
430
431 #endif /* _VA_BACKEND_H_ */