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