c4112018faad95e7c4a862625a32ed1a9c2814c6
[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 (*vaCreateSurfaceFromCIFrame) (
104                 VADriverContextP ctx,
105                 unsigned long frame_id,
106                 VASurfaceID *surface            /* out */
107         );
108     
109         VAStatus (*vaDestroySurfaces) (
110                 VADriverContextP ctx,
111                 VASurfaceID *surface_list,
112                 int num_surfaces
113         );
114
115         VAStatus (*vaCreateContext) (
116                 VADriverContextP ctx,
117                 VAConfigID config_id,
118                 int picture_width,
119                 int picture_height,
120                 int flag,
121                 VASurfaceID *render_targets,
122                 int num_render_targets,
123                 VAContextID *context            /* out */
124         );
125
126         VAStatus (*vaDestroyContext) (
127                 VADriverContextP ctx,
128                 VAContextID context
129         );
130
131         VAStatus (*vaCreateBuffer) (
132                 VADriverContextP ctx,
133                 VAContextID context,            /* in */
134                 VABufferType type,              /* in */
135                 unsigned int size,              /* in */
136                 unsigned int num_elements,      /* in */
137                 void *data,                     /* in */
138                 VABufferID *buf_id              /* out */
139         );
140
141         VAStatus (*vaBufferSetNumElements) (
142                 VADriverContextP ctx,
143                 VABufferID buf_id,      /* in */
144                 unsigned int num_elements       /* in */
145         );
146
147         VAStatus (*vaMapBuffer) (
148                 VADriverContextP ctx,
149                 VABufferID buf_id,      /* in */
150                 void **pbuf         /* out */
151         );
152
153         VAStatus (*vaUnmapBuffer) (
154                 VADriverContextP ctx,
155                 VABufferID buf_id       /* in */
156         );
157
158         VAStatus (*vaDestroyBuffer) (
159                 VADriverContextP ctx,
160                 VABufferID buffer_id
161         );
162
163         VAStatus (*vaBeginPicture) (
164                 VADriverContextP ctx,
165                 VAContextID context,
166                 VASurfaceID render_target
167         );
168
169         VAStatus (*vaRenderPicture) (
170                 VADriverContextP ctx,
171                 VAContextID context,
172                 VABufferID *buffers,
173                 int num_buffers
174         );
175
176         VAStatus (*vaEndPicture) (
177                 VADriverContextP ctx,
178                 VAContextID context
179         );
180
181         VAStatus (*vaSyncSurface) (
182                 VADriverContextP ctx,
183                 VAContextID context,
184                 VASurfaceID render_target
185         );
186
187         VAStatus (*vaQuerySurfaceStatus) (
188                 VADriverContextP ctx,
189                 VASurfaceID render_target,
190                 VASurfaceStatus *status /* out */
191         );
192
193         VAStatus (*vaPutSurface) (
194                 VADriverContextP ctx,
195                 VASurfaceID surface,
196                 Drawable draw, /* X Drawable */
197                 short srcx,
198                 short srcy,
199                 unsigned short srcw,
200                 unsigned short srch,
201                 short destx,
202                 short desty,
203                 unsigned short destw,
204                 unsigned short desth,
205                 VARectangle *cliprects, /* client supplied clip list */
206                 unsigned int number_cliprects, /* number of clip rects in the clip list */
207                 unsigned int flags /* de-interlacing flags */
208         );
209
210         VAStatus (*vaQueryImageFormats) (
211                 VADriverContextP ctx,
212                 VAImageFormat *format_list,        /* out */
213                 int *num_formats           /* out */
214         );
215
216         VAStatus (*vaCreateImage) (
217                 VADriverContextP ctx,
218                 VAImageFormat *format,
219                 int width,
220                 int height,
221                 VAImage *image     /* out */
222         );
223
224         VAStatus (*vaDeriveImage) (
225                 VADriverContextP ctx,
226                 VASurfaceID surface,
227                 VAImage *image     /* out */
228         );
229
230         VAStatus (*vaDestroyImage) (
231                 VADriverContextP ctx,
232                 VAImageID image
233         );
234         
235         VAStatus (*vaSetImagePalette) (
236                 VADriverContextP ctx,
237                 VAImageID image,
238                 /*
239                  * pointer to an array holding the palette data.  The size of the array is
240                  * num_palette_entries * entry_bytes in size.  The order of the components
241                  * in the palette is described by the component_order in VAImage struct
242                  */
243                 unsigned char *palette
244         );
245         
246         VAStatus (*vaGetImage) (
247                 VADriverContextP ctx,
248                 VASurfaceID surface,
249                 int x,     /* coordinates of the upper left source pixel */
250                 int y,
251                 unsigned int width, /* width and height of the region */
252                 unsigned int height,
253                 VAImageID image
254         );
255
256         VAStatus (*vaPutImage) (
257                 VADriverContextP ctx,
258                 VASurfaceID surface,
259                 VAImageID image,
260                 int src_x,
261                 int src_y,
262                 unsigned int width,
263                 unsigned int height,
264                 int dest_x,
265                 int dest_y 
266         );
267
268         VAStatus (*vaPutImage2) (
269                 VADriverContextP ctx,
270                 VASurfaceID surface,
271                 VAImageID image,
272                 int src_x,
273                 int src_y,
274                 unsigned int src_width,
275                 unsigned int src_height,
276                 int dest_x,
277                 int dest_y,
278                 unsigned int dest_width,
279                 unsigned int dest_height
280         );
281
282         VAStatus (*vaQuerySubpictureFormats) (
283                 VADriverContextP ctx,
284                 VAImageFormat *format_list,        /* out */
285                 unsigned int *flags,       /* out */
286                 unsigned int *num_formats  /* out */
287         );
288
289         VAStatus (*vaCreateSubpicture) (
290                 VADriverContextP ctx,
291                 VAImageID image,
292                 VASubpictureID *subpicture   /* out */
293         );
294
295         VAStatus (*vaDestroySubpicture) (
296                 VADriverContextP ctx,
297                 VASubpictureID subpicture
298         );
299
300         VAStatus (*vaSetSubpictureImage) (
301                 VADriverContextP ctx,
302                 VASubpictureID subpicture,
303                 VAImageID image
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         VAStatus (*vaDbgCreateSurfaceFromMrstV4L2Buf) (
391                 VADriverContextP ctx,
392                 unsigned int width,
393                 unsigned int height,
394                 unsigned int size,
395                 unsigned int fourcc,
396                 unsigned int luma_stride,
397                 unsigned int chroma_u_stride,
398                 unsigned int chroma_v_stride,
399                 unsigned int luma_offset,
400                 unsigned int chroma_u_offset,
401                 unsigned int chroma_v_offset,
402                 VASurfaceID *surface    /* out */
403         );
404 };
405
406 struct VADriverContext
407 {
408     void *old_pNext;                    /* preserved for binary compatibility */
409
410     void *pDriverData;
411     struct VADriverVTable vtable;
412
413     Display *x11_dpy;
414     int x11_screen;
415     int dri2;
416     int version_major;
417     int version_minor;
418     int max_profiles;
419     int max_entrypoints;
420     int max_attributes;
421     int max_image_formats;
422     int max_subpic_formats;
423     int max_display_attributes;
424     const char *str_vendor;
425
426     void *handle;                       /* dlopen handle */
427 };
428
429 struct VADisplayContext
430 {
431     VADisplayContextP pNext;
432     VADriverContextP pDriverContext;
433
434     int (*vaIsValid) (
435         VADisplayContextP ctx
436     );
437
438     void (*vaDestroy) (
439         VADisplayContextP ctx
440     );
441
442     VAStatus (*vaGetDriverName) (
443         VADisplayContextP ctx,
444         char **driver_name
445     );
446 };
447
448 typedef VAStatus (*VADriverInit) (
449     VADriverContextP driver_context
450 );
451
452
453 #endif /* _VA_BACKEND_H_ */