OSDN Git Service

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