Update to VA API 0.26
[platform/upstream/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 "va_x11.h"
34
35 #include <stdlib.h>
36
37
38 typedef struct VADriverContext *VADriverContextP;
39
40 struct VADriverVTable
41 {
42         VAStatus (*vaTerminate) ( VADriverContextP ctx );
43
44         VAStatus (*vaQueryConfigProfiles) (
45                 VADriverContextP ctx,
46                 VAProfile *profile_list,        /* out */
47                 int *num_profiles                       /* out */
48         );
49
50         VAStatus (*vaQueryConfigEntrypoints) (
51                 VADriverContextP ctx,
52                 VAProfile profile,
53                 VAEntrypoint  *entrypoint_list, /* out */
54                 int *num_entrypoints                    /* out */
55         );
56
57         VAStatus (*vaGetConfigAttributes) (
58                 VADriverContextP ctx,
59                 VAProfile profile,
60                 VAEntrypoint entrypoint,
61                 VAConfigAttrib *attrib_list,    /* in/out */
62                 int num_attribs
63         );
64
65         VAStatus (*vaCreateConfig) (
66                 VADriverContextP ctx,
67                 VAProfile profile, 
68                 VAEntrypoint entrypoint, 
69                 VAConfigAttrib *attrib_list,
70                 int num_attribs,
71                 VAConfigID *config_id           /* out */
72         );
73
74         VAStatus (*vaDestroyConfig) (
75                 VADriverContextP ctx,
76                 VAConfigID config_id
77         );
78
79         VAStatus (*vaQueryConfigAttributes) (
80                 VADriverContextP ctx,
81                 VAConfigID config_id, 
82                 VAProfile *profile,             /* out */
83                 VAEntrypoint *entrypoint,       /* out */
84                 VAConfigAttrib *attrib_list,    /* out */
85                 int *num_attribs                /* out */
86         );
87
88         VAStatus (*vaCreateSurfaces) (
89                 VADriverContextP ctx,
90                 int width,
91                 int height,
92                 int format,
93                 int num_surfaces,
94                 VASurfaceID *surfaces           /* out */
95         );
96
97         VAStatus (*vaDestroySurfaces) (
98                 VADriverContextP ctx,
99                 VASurfaceID *surface_list,
100                 int num_surfaces
101         );
102
103         VAStatus (*vaCreateContext) (
104                 VADriverContextP ctx,
105                 VAConfigID config_id,
106                 int picture_width,
107                 int picture_height,
108                 int flag,
109                 VASurfaceID *render_targets,
110                 int num_render_targets,
111                 VAContextID *context            /* out */
112         );
113
114         VAStatus (*vaDestroyContext) (
115                 VADriverContextP ctx,
116                 VAContextID context
117         );
118
119         VAStatus (*vaCreateBuffer) (
120                 VADriverContextP ctx,
121                 VAContextID context,            /* in */
122                 VABufferType type,              /* in */
123                 unsigned int size,              /* in */
124                 unsigned int num_elements,      /* in */
125                 void *data,                     /* in */
126                 VABufferID *buf_id              /* out */
127         );
128
129         VAStatus (*vaBufferSetNumElements) (
130                 VADriverContextP ctx,
131                 VABufferID buf_id,      /* in */
132                 unsigned int num_elements       /* in */
133         );
134
135         VAStatus (*vaMapBuffer) (
136                 VADriverContextP ctx,
137                 VABufferID buf_id,      /* in */
138                 void **pbuf         /* out */
139         );
140
141         VAStatus (*vaUnmapBuffer) (
142                 VADriverContextP ctx,
143                 VABufferID buf_id       /* in */
144         );
145
146         VAStatus (*vaDestroyBuffer) (
147                 VADriverContextP ctx,
148                 VABufferID buffer_id
149         );
150
151         VAStatus (*vaBeginPicture) (
152                 VADriverContextP ctx,
153                 VAContextID context,
154                 VASurfaceID render_target
155         );
156
157         VAStatus (*vaRenderPicture) (
158                 VADriverContextP ctx,
159                 VAContextID context,
160                 VABufferID *buffers,
161                 int num_buffers
162         );
163
164         VAStatus (*vaEndPicture) (
165                 VADriverContextP ctx,
166                 VAContextID context
167         );
168
169         VAStatus (*vaSyncSurface) (
170                 VADriverContextP ctx,
171                 VAContextID context,
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                 Drawable draw, /* X Drawable */
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 (*vaDestroyImage) (
213                 VADriverContextP ctx,
214                 VAImageID image
215         );
216         
217         VAStatus (*vaSetImagePalette) (
218                 VADriverContextP ctx,
219                 VAImageID image,
220                 /*
221                  * pointer to an array holding the palette data.  The size of the array is
222                  * num_palette_entries * entry_bytes in size.  The order of the components
223                  * in the palette is described by the component_order in VAImage struct
224                  */
225                 unsigned char *palette
226         );
227         
228         VAStatus (*vaGetImage) (
229                 VADriverContextP ctx,
230                 VASurfaceID surface,
231                 int x,     /* coordinates of the upper left source pixel */
232                 int y,
233                 unsigned int width, /* width and height of the region */
234                 unsigned int height,
235                 VAImageID image
236         );
237
238         VAStatus (*vaPutImage) (
239                 VADriverContextP ctx,
240                 VASurfaceID surface,
241                 VAImageID image,
242                 int src_x,
243                 int src_y,
244                 unsigned int width,
245                 unsigned int height,
246                 int dest_x,
247                 int dest_y 
248         );
249
250         VAStatus (*vaQuerySubpictureFormats) (
251                 VADriverContextP ctx,
252                 VAImageFormat *format_list,        /* out */
253                 unsigned int *flags,       /* out */
254                 unsigned int *num_formats  /* out */
255         );
256
257         VAStatus (*vaCreateSubpicture) (
258                 VADriverContextP ctx,
259                 VAImageID image,
260                 VASubpictureID *subpicture   /* out */
261         );
262
263         VAStatus (*vaDestroySubpicture) (
264                 VADriverContextP ctx,
265                 VASubpictureID subpicture
266         );
267
268         VAStatus (*vaSetSubpictureImage) (
269                 VADriverContextP ctx,
270                 VASubpictureID subpicture,
271                 VAImageID image
272         );
273         
274         VAStatus (*vaSetSubpicturePalette) (
275                 VADriverContextP ctx,
276                 VASubpictureID subpicture,
277                 /*
278                  * pointer to an array holding the palette data.  The size of the array is
279                  * num_palette_entries * entry_bytes in size.  The order of the components
280                  * in the palette is described by the component_order in VASubpicture struct
281                  */
282                 unsigned char *palette
283         );
284
285         VAStatus (*vaSetSubpictureChromakey) (
286                 VADriverContextP ctx,
287                 VASubpictureID subpicture,
288                 unsigned int chromakey_min,
289                 unsigned int chromakey_max,
290                 unsigned int chromakey_mask
291         );
292
293         VAStatus (*vaSetSubpictureGlobalAlpha) (
294                 VADriverContextP ctx,
295                 VASubpictureID subpicture,
296                 float global_alpha 
297         );
298
299         VAStatus (*vaAssociateSubpicture) (
300                 VADriverContextP ctx,
301                 VASubpictureID subpicture,
302                 VASurfaceID *target_surfaces,
303                 int num_surfaces,
304                 short src_x, /* upper left offset in subpicture */
305                 short src_y,
306                 short dest_x, /* upper left offset in surface */
307                 short dest_y,
308                 unsigned short width,
309                 unsigned short 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
343         VAStatus (*vaDbgCopySurfaceToBuffer) (
344                 VADriverContextP ctx,
345                 VASurfaceID surface,
346                 void **buffer, /* out */
347                 unsigned int *stride /* out */
348         );
349 };
350
351 struct VADriverContext
352 {
353     VADriverContextP pNext;
354
355     void *pDriverData;
356     struct VADriverVTable vtable;
357
358     Display *x11_dpy;
359     int x11_screen;
360
361     int version_major;
362     int version_minor;
363     int max_profiles;
364     int max_entrypoints;
365     int max_attributes;
366     int max_image_formats;
367     int max_subpic_formats;
368     int max_display_attributes;
369     const char *str_vendor;
370
371     void *handle;                       /* dlopen handle */
372 };
373
374 typedef VAStatus (*VADriverInit) (
375     VADriverContextP driver_context
376 );
377
378
379 #endif /* _VA_BACKEND_H_ */