OSDN Git Service

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