OSDN Git Service

add new va_DisplayContextGetDriverName, remove 'x11/XX' include folder name
[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 #ifdef ANDROID
42 #define Surface void
43 #endif
44
45 struct VADriverVTable
46 {
47         VAStatus (*vaTerminate) ( VADriverContextP ctx );
48
49         VAStatus (*vaQueryConfigProfiles) (
50                 VADriverContextP ctx,
51                 VAProfile *profile_list,        /* out */
52                 int *num_profiles                       /* out */
53         );
54
55         VAStatus (*vaQueryConfigEntrypoints) (
56                 VADriverContextP ctx,
57                 VAProfile profile,
58                 VAEntrypoint  *entrypoint_list, /* out */
59                 int *num_entrypoints                    /* out */
60         );
61
62         VAStatus (*vaGetConfigAttributes) (
63                 VADriverContextP ctx,
64                 VAProfile profile,
65                 VAEntrypoint entrypoint,
66                 VAConfigAttrib *attrib_list,    /* in/out */
67                 int num_attribs
68         );
69
70         VAStatus (*vaCreateConfig) (
71                 VADriverContextP ctx,
72                 VAProfile profile, 
73                 VAEntrypoint entrypoint, 
74                 VAConfigAttrib *attrib_list,
75                 int num_attribs,
76                 VAConfigID *config_id           /* out */
77         );
78
79         VAStatus (*vaDestroyConfig) (
80                 VADriverContextP ctx,
81                 VAConfigID config_id
82         );
83
84         VAStatus (*vaQueryConfigAttributes) (
85                 VADriverContextP ctx,
86                 VAConfigID config_id, 
87                 VAProfile *profile,             /* out */
88                 VAEntrypoint *entrypoint,       /* out */
89                 VAConfigAttrib *attrib_list,    /* out */
90                 int *num_attribs                /* out */
91         );
92
93         VAStatus (*vaCreateSurfaces) (
94                 VADriverContextP ctx,
95                 int width,
96                 int height,
97                 int format,
98                 int num_surfaces,
99                 VASurfaceID *surfaces           /* out */
100         );
101
102         VAStatus (*vaDestroySurfaces) (
103                 VADriverContextP ctx,
104                 VASurfaceID *surface_list,
105                 int num_surfaces
106         );
107
108         VAStatus (*vaCreateContext) (
109                 VADriverContextP ctx,
110                 VAConfigID config_id,
111                 int picture_width,
112                 int picture_height,
113                 int flag,
114                 VASurfaceID *render_targets,
115                 int num_render_targets,
116                 VAContextID *context            /* out */
117         );
118
119         VAStatus (*vaDestroyContext) (
120                 VADriverContextP ctx,
121                 VAContextID context
122         );
123
124         VAStatus (*vaCreateBuffer) (
125                 VADriverContextP ctx,
126                 VAContextID context,            /* in */
127                 VABufferType type,              /* in */
128                 unsigned int size,              /* in */
129                 unsigned int num_elements,      /* in */
130                 void *data,                     /* in */
131                 VABufferID *buf_id              /* out */
132         );
133
134         VAStatus (*vaBufferSetNumElements) (
135                 VADriverContextP ctx,
136                 VABufferID buf_id,      /* in */
137                 unsigned int num_elements       /* in */
138         );
139
140         VAStatus (*vaMapBuffer) (
141                 VADriverContextP ctx,
142                 VABufferID buf_id,      /* in */
143                 void **pbuf         /* out */
144         );
145
146         VAStatus (*vaUnmapBuffer) (
147                 VADriverContextP ctx,
148                 VABufferID buf_id       /* in */
149         );
150
151         VAStatus (*vaDestroyBuffer) (
152                 VADriverContextP ctx,
153                 VABufferID buffer_id
154         );
155
156         VAStatus (*vaBeginPicture) (
157                 VADriverContextP ctx,
158                 VAContextID context,
159                 VASurfaceID render_target
160         );
161
162         VAStatus (*vaRenderPicture) (
163                 VADriverContextP ctx,
164                 VAContextID context,
165                 VABufferID *buffers,
166                 int num_buffers
167         );
168
169         VAStatus (*vaEndPicture) (
170                 VADriverContextP ctx,
171                 VAContextID context
172         );
173
174         VAStatus (*vaSyncSurface) (
175                 VADriverContextP ctx,
176                 VASurfaceID render_target
177         );
178
179         VAStatus (*vaQuerySurfaceStatus) (
180                 VADriverContextP ctx,
181                 VASurfaceID render_target,
182                 VASurfaceStatus *status /* out */
183         );
184
185         VAStatus (*vaPutSurface) (
186                 VADriverContextP ctx,
187                 VASurfaceID surface,
188 #ifdef ANDROID
189                 Surface* draw, /* Drawable of window system */
190 #else
191                 Drawable draw,
192 #endif
193                 short srcx,
194                 short srcy,
195                 unsigned short srcw,
196                 unsigned short srch,
197                 short destx,
198                 short desty,
199                 unsigned short destw,
200                 unsigned short desth,
201                 VARectangle *cliprects, /* client supplied clip list */
202                 unsigned int number_cliprects, /* number of clip rects in the clip list */
203                 unsigned int flags /* de-interlacing flags */
204         );
205
206         VAStatus (*vaQueryImageFormats) (
207                 VADriverContextP ctx,
208                 VAImageFormat *format_list,        /* out */
209                 int *num_formats           /* out */
210         );
211
212         VAStatus (*vaCreateImage) (
213                 VADriverContextP ctx,
214                 VAImageFormat *format,
215                 int width,
216                 int height,
217                 VAImage *image     /* out */
218         );
219
220         VAStatus (*vaDeriveImage) (
221                 VADriverContextP ctx,
222                 VASurfaceID surface,
223                 VAImage *image     /* out */
224         );
225
226         VAStatus (*vaDestroyImage) (
227                 VADriverContextP ctx,
228                 VAImageID image
229         );
230         
231         VAStatus (*vaSetImagePalette) (
232                 VADriverContextP ctx,
233                 VAImageID image,
234                 /*
235                  * pointer to an array holding the palette data.  The size of the array is
236                  * num_palette_entries * entry_bytes in size.  The order of the components
237                  * in the palette is described by the component_order in VAImage struct
238                  */
239                 unsigned char *palette
240         );
241         
242         VAStatus (*vaGetImage) (
243                 VADriverContextP ctx,
244                 VASurfaceID surface,
245                 int x,     /* coordinates of the upper left source pixel */
246                 int y,
247                 unsigned int width, /* width and height of the region */
248                 unsigned int height,
249                 VAImageID image
250         );
251
252         VAStatus (*vaPutImage) (
253                 VADriverContextP ctx,
254                 VASurfaceID surface,
255                 VAImageID image,
256                 int src_x,
257                 int src_y,
258                 unsigned int src_width,
259                 unsigned int src_height,
260                 int dest_x,
261                 int dest_y,
262                 unsigned int dest_width,
263                 unsigned int dest_height
264         );
265
266         VAStatus (*vaQuerySubpictureFormats) (
267                 VADriverContextP ctx,
268                 VAImageFormat *format_list,        /* out */
269                 unsigned int *flags,       /* out */
270                 unsigned int *num_formats  /* out */
271         );
272
273         VAStatus (*vaCreateSubpicture) (
274                 VADriverContextP ctx,
275                 VAImageID image,
276                 VASubpictureID *subpicture   /* out */
277         );
278
279         VAStatus (*vaDestroySubpicture) (
280                 VADriverContextP ctx,
281                 VASubpictureID subpicture
282         );
283
284         VAStatus (*vaSetSubpictureImage) (
285                 VADriverContextP ctx,
286                 VASubpictureID subpicture,
287                 VAImageID image
288         );
289
290         VAStatus (*vaSetSubpictureChromakey) (
291                 VADriverContextP ctx,
292                 VASubpictureID subpicture,
293                 unsigned int chromakey_min,
294                 unsigned int chromakey_max,
295                 unsigned int chromakey_mask
296         );
297
298         VAStatus (*vaSetSubpictureGlobalAlpha) (
299                 VADriverContextP ctx,
300                 VASubpictureID subpicture,
301                 float global_alpha 
302         );
303
304         VAStatus (*vaAssociateSubpicture) (
305                 VADriverContextP ctx,
306                 VASubpictureID subpicture,
307                 VASurfaceID *target_surfaces,
308                 int num_surfaces,
309                 short src_x, /* upper left offset in subpicture */
310                 short src_y,
311                 unsigned short src_width,
312                 unsigned short src_height,
313                 short dest_x, /* upper left offset in surface */
314                 short dest_y,
315                 unsigned short dest_width,
316                 unsigned short dest_height,
317                 /*
318                  * whether to enable chroma-keying or global-alpha
319                  * see VA_SUBPICTURE_XXX values
320                  */
321                 unsigned int flags
322         );
323
324         VAStatus (*vaDeassociateSubpicture) (
325                 VADriverContextP ctx,
326                 VASubpictureID subpicture,
327                 VASurfaceID *target_surfaces,
328                 int num_surfaces
329         );
330
331         VAStatus (*vaQueryDisplayAttributes) (
332                 VADriverContextP ctx,
333                 VADisplayAttribute *attr_list,  /* out */
334                 int *num_attributes             /* out */
335         );
336
337         VAStatus (*vaGetDisplayAttributes) (
338                 VADriverContextP ctx,
339                 VADisplayAttribute *attr_list,  /* in/out */
340                 int num_attributes
341         );
342         
343         VAStatus (*vaSetDisplayAttributes) (
344                 VADriverContextP ctx,
345                 VADisplayAttribute *attr_list,
346                 int num_attributes
347         );
348
349         /* device specific */
350         VAStatus (*vaCreateSurfaceFromCIFrame) (
351                 VADriverContextP ctx,
352                 unsigned long frame_id,
353                 VASurfaceID *surface            /* out */
354         );
355     
356     
357         VAStatus (*vaCreateSurfaceFromV4L2Buf) (
358                 VADriverContextP ctx,
359                 int v4l2_fd,         /* file descriptor of V4L2 device */
360                 struct v4l2_format *v4l2_fmt,       /* format of V4L2 */
361                 struct v4l2_buffer *v4l2_buf,       /* V4L2 buffer */
362                 VASurfaceID *surface               /* out */
363         );
364
365         VAStatus (*vaBufferInfo) (
366                    VADriverContextP ctx,
367                    VAContextID context, /* in */
368                    VABufferID buf_id, /* in */
369                    VABufferType *type,    /* out */
370                    unsigned int *size,    /* out */
371                    unsigned int *num_elements /* out */
372         );
373
374     
375         VAStatus (*vaCopySurfaceToBuffer) (
376                 VADriverContextP ctx,
377                 VASurfaceID surface,
378                 unsigned int *fourcc, /* out  for follow argument */
379                 unsigned int *luma_stride,
380                 unsigned int *chroma_u_stride,
381                 unsigned int *chroma_v_stride,
382                 unsigned int *luma_offset,
383                 unsigned int *chroma_u_offset,
384                 unsigned int *chroma_v_offset,
385                 void **buffer
386         );
387 };
388
389 struct VADriverContext
390 {
391     void *pDriverData;
392     struct VADriverVTable vtable;
393
394     void *native_dpy;
395     int x11_screen;
396     int version_major;
397     int version_minor;
398     int max_profiles;
399     int max_entrypoints;
400     int max_attributes;
401     int max_image_formats;
402     int max_subpic_formats;
403     int max_display_attributes;
404     const char *str_vendor;
405
406     void *handle;                       /* dlopen handle */
407     
408     void *dri_state;
409 };
410
411 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
412 struct VADisplayContext
413 {
414     int vadpy_magic;
415     
416     VADisplayContextP pNext;
417     VADriverContextP pDriverContext;
418
419     int (*vaIsValid) (
420         VADisplayContextP ctx
421     );
422
423     void (*vaDestroy) (
424         VADisplayContextP ctx
425     );
426
427     VAStatus (*vaGetDriverName) (
428         VADisplayContextP ctx,
429         char **driver_name
430     );
431 };
432
433 typedef VAStatus (*VADriverInit) (
434     VADriverContextP driver_context
435 );
436
437
438 #endif /* _VA_BACKEND_H_ */