not include header at right directory, Compile error fixed
[profile/ivi/libva.git] / src / 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.h"
33 #include "x11/va_x11.h"
34
35 #include <stdlib.h>
36
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                 VAContextID context,
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 width,
252                 unsigned int height,
253                 int dest_x,
254                 int dest_y 
255         );
256
257         VAStatus (*vaPutImage2) (
258                 VADriverContextP ctx,
259                 VASurfaceID surface,
260                 VAImageID image,
261                 int src_x,
262                 int src_y,
263                 unsigned int src_width,
264                 unsigned int src_height,
265                 int dest_x,
266                 int dest_y,
267                 unsigned int dest_width,
268                 unsigned int dest_height
269         );
270
271         VAStatus (*vaQuerySubpictureFormats) (
272                 VADriverContextP ctx,
273                 VAImageFormat *format_list,        /* out */
274                 unsigned int *flags,       /* out */
275                 unsigned int *num_formats  /* out */
276         );
277
278         VAStatus (*vaCreateSubpicture) (
279                 VADriverContextP ctx,
280                 VAImageID image,
281                 VASubpictureID *subpicture   /* out */
282         );
283
284         VAStatus (*vaDestroySubpicture) (
285                 VADriverContextP ctx,
286                 VASubpictureID subpicture
287         );
288
289         VAStatus (*vaSetSubpictureImage) (
290                 VADriverContextP ctx,
291                 VASubpictureID subpicture,
292                 VAImageID image
293         );
294         
295         VAStatus (*vaSetSubpicturePalette) (
296                 VADriverContextP ctx,
297                 VASubpictureID subpicture,
298                 /*
299                  * pointer to an array holding the palette data.  The size of the array is
300                  * num_palette_entries * entry_bytes in size.  The order of the components
301                  * in the palette is described by the component_order in VASubpicture struct
302                  */
303                 unsigned char *palette
304         );
305
306         VAStatus (*vaSetSubpictureChromakey) (
307                 VADriverContextP ctx,
308                 VASubpictureID subpicture,
309                 unsigned int chromakey_min,
310                 unsigned int chromakey_max,
311                 unsigned int chromakey_mask
312         );
313
314         VAStatus (*vaSetSubpictureGlobalAlpha) (
315                 VADriverContextP ctx,
316                 VASubpictureID subpicture,
317                 float global_alpha 
318         );
319
320         VAStatus (*vaAssociateSubpicture) (
321                 VADriverContextP ctx,
322                 VASubpictureID subpicture,
323                 VASurfaceID *target_surfaces,
324                 int num_surfaces,
325                 short src_x, /* upper left offset in subpicture */
326                 short src_y,
327                 short dest_x, /* upper left offset in surface */
328                 short dest_y,
329                 unsigned short width,
330                 unsigned short height,
331                 /*
332                  * whether to enable chroma-keying or global-alpha
333                  * see VA_SUBPICTURE_XXX values
334                  */
335                 unsigned int flags
336         );
337
338         VAStatus (*vaAssociateSubpicture2) (
339                 VADriverContextP ctx,
340                 VASubpictureID subpicture,
341                 VASurfaceID *target_surfaces,
342                 int num_surfaces,
343                 short src_x, /* upper left offset in subpicture */
344                 short src_y,
345                 unsigned short src_width,
346                 unsigned short src_height,
347                 short dest_x, /* upper left offset in surface */
348                 short dest_y,
349                 unsigned short dest_width,
350                 unsigned short dest_height,
351                 /*
352                  * whether to enable chroma-keying or global-alpha
353                  * see VA_SUBPICTURE_XXX values
354                  */
355                 unsigned int flags
356         );
357
358         VAStatus (*vaDeassociateSubpicture) (
359                 VADriverContextP ctx,
360                 VASubpictureID subpicture,
361                 VASurfaceID *target_surfaces,
362                 int num_surfaces
363         );
364
365         VAStatus (*vaQueryDisplayAttributes) (
366                 VADriverContextP ctx,
367                 VADisplayAttribute *attr_list,  /* out */
368                 int *num_attributes             /* out */
369         );
370
371         VAStatus (*vaGetDisplayAttributes) (
372                 VADriverContextP ctx,
373                 VADisplayAttribute *attr_list,  /* in/out */
374                 int num_attributes
375         );
376         
377         VAStatus (*vaSetDisplayAttributes) (
378                 VADriverContextP ctx,
379                 VADisplayAttribute *attr_list,
380                 int num_attributes
381         );
382
383
384         VAStatus (*vaDbgCopySurfaceToBuffer) (
385                 VADriverContextP ctx,
386                 VASurfaceID surface,
387                 void **buffer, /* out */
388                 unsigned int *stride /* out */
389         );
390 };
391
392 struct VADriverContext
393 {
394     void *old_pNext;                    /* preserved for binary compatibility */
395
396     void *pDriverData;
397     struct VADriverVTable vtable;
398
399     Display *x11_dpy;
400     int x11_screen;
401
402     int version_major;
403     int version_minor;
404     int max_profiles;
405     int max_entrypoints;
406     int max_attributes;
407     int max_image_formats;
408     int max_subpic_formats;
409     int max_display_attributes;
410     const char *str_vendor;
411
412     void *handle;                       /* dlopen handle */
413 };
414
415 struct VADisplayContext
416 {
417     VADisplayContextP pNext;
418     VADriverContextP pDriverContext;
419
420     int (*vaIsValid) (
421         VADisplayContextP ctx
422     );
423
424     void (*vaDestroy) (
425         VADisplayContextP ctx
426     );
427
428     VAStatus (*vaGetDriverName) (
429         VADisplayContextP ctx,
430         char **driver_name
431     );
432 };
433
434 typedef VAStatus (*VADriverInit) (
435     VADriverContextP driver_context
436 );
437
438
439 #endif /* _VA_BACKEND_H_ */