OSDN Git Service

Merge branch 'powervr_iep_lite'
[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 #include <X11/Xlib.h>
34 #include <linux/videodev2.h>
35
36
37 typedef struct VADriverContext *VADriverContextP;
38 typedef struct VADisplayContext *VADisplayContextP;
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                 VASurfaceID render_target
172         );
173
174         VAStatus (*vaQuerySurfaceStatus) (
175                 VADriverContextP ctx,
176                 VASurfaceID render_target,
177                 VASurfaceStatus *status /* out */
178         );
179
180         VAStatus (*vaPutSurface) (
181                 VADriverContextP ctx,
182                 VASurfaceID surface,
183                 Drawable draw, /* X Drawable */
184                 short srcx,
185                 short srcy,
186                 unsigned short srcw,
187                 unsigned short srch,
188                 short destx,
189                 short desty,
190                 unsigned short destw,
191                 unsigned short desth,
192                 VARectangle *cliprects, /* client supplied clip list */
193                 unsigned int number_cliprects, /* number of clip rects in the clip list */
194                 unsigned int flags /* de-interlacing flags */
195         );
196
197         VAStatus (*vaQueryImageFormats) (
198                 VADriverContextP ctx,
199                 VAImageFormat *format_list,        /* out */
200                 int *num_formats           /* out */
201         );
202
203         VAStatus (*vaCreateImage) (
204                 VADriverContextP ctx,
205                 VAImageFormat *format,
206                 int width,
207                 int height,
208                 VAImage *image     /* out */
209         );
210
211         VAStatus (*vaDeriveImage) (
212                 VADriverContextP ctx,
213                 VASurfaceID surface,
214                 VAImage *image     /* out */
215         );
216
217         VAStatus (*vaDestroyImage) (
218                 VADriverContextP ctx,
219                 VAImageID image
220         );
221         
222         VAStatus (*vaSetImagePalette) (
223                 VADriverContextP ctx,
224                 VAImageID image,
225                 /*
226                  * pointer to an array holding the palette data.  The size of the array is
227                  * num_palette_entries * entry_bytes in size.  The order of the components
228                  * in the palette is described by the component_order in VAImage struct
229                  */
230                 unsigned char *palette
231         );
232         
233         VAStatus (*vaGetImage) (
234                 VADriverContextP ctx,
235                 VASurfaceID surface,
236                 int x,     /* coordinates of the upper left source pixel */
237                 int y,
238                 unsigned int width, /* width and height of the region */
239                 unsigned int height,
240                 VAImageID image
241         );
242
243         VAStatus (*vaPutImage) (
244                 VADriverContextP ctx,
245                 VASurfaceID surface,
246                 VAImageID image,
247                 int src_x,
248                 int src_y,
249                 unsigned int src_width,
250                 unsigned int src_height,
251                 int dest_x,
252                 int dest_y,
253                 unsigned int dest_width,
254                 unsigned int dest_height
255         );
256
257         VAStatus (*vaQuerySubpictureFormats) (
258                 VADriverContextP ctx,
259                 VAImageFormat *format_list,        /* out */
260                 unsigned int *flags,       /* out */
261                 unsigned int *num_formats  /* out */
262         );
263
264         VAStatus (*vaCreateSubpicture) (
265                 VADriverContextP ctx,
266                 VAImageID image,
267                 VASubpictureID *subpicture   /* out */
268         );
269
270         VAStatus (*vaDestroySubpicture) (
271                 VADriverContextP ctx,
272                 VASubpictureID subpicture
273         );
274
275         VAStatus (*vaSetSubpictureImage) (
276                 VADriverContextP ctx,
277                 VASubpictureID subpicture,
278                 VAImageID image
279         );
280
281         VAStatus (*vaSetSubpictureChromakey) (
282                 VADriverContextP ctx,
283                 VASubpictureID subpicture,
284                 unsigned int chromakey_min,
285                 unsigned int chromakey_max,
286                 unsigned int chromakey_mask
287         );
288
289         VAStatus (*vaSetSubpictureGlobalAlpha) (
290                 VADriverContextP ctx,
291                 VASubpictureID subpicture,
292                 float global_alpha 
293         );
294
295         VAStatus (*vaAssociateSubpicture) (
296                 VADriverContextP ctx,
297                 VASubpictureID subpicture,
298                 VASurfaceID *target_surfaces,
299                 int num_surfaces,
300                 short src_x, /* upper left offset in subpicture */
301                 short src_y,
302                 unsigned short src_width,
303                 unsigned short src_height,
304                 short dest_x, /* upper left offset in surface */
305                 short dest_y,
306                 unsigned short dest_width,
307                 unsigned short dest_height,
308                 /*
309                  * whether to enable chroma-keying or global-alpha
310                  * see VA_SUBPICTURE_XXX values
311                  */
312                 unsigned int flags
313         );
314
315         VAStatus (*vaDeassociateSubpicture) (
316                 VADriverContextP ctx,
317                 VASubpictureID subpicture,
318                 VASurfaceID *target_surfaces,
319                 int num_surfaces
320         );
321
322         VAStatus (*vaQueryDisplayAttributes) (
323                 VADriverContextP ctx,
324                 VADisplayAttribute *attr_list,  /* out */
325                 int *num_attributes             /* out */
326         );
327
328         VAStatus (*vaGetDisplayAttributes) (
329                 VADriverContextP ctx,
330                 VADisplayAttribute *attr_list,  /* in/out */
331                 int num_attributes
332         );
333         
334         VAStatus (*vaSetDisplayAttributes) (
335                 VADriverContextP ctx,
336                 VADisplayAttribute *attr_list,
337                 int num_attributes
338         );
339
340         /* device specific */
341         VAStatus (*vaCreateSurfaceFromCIFrame) (
342                 VADriverContextP ctx,
343                 unsigned long frame_id,
344                 VASurfaceID *surface            /* out */
345         );
346     
347     
348         VAStatus (*vaCreateSurfaceFromV4L2Buf) (
349                 VADriverContextP ctx,
350                 int v4l2_fd,         /* file descriptor of V4L2 device */
351                 struct v4l2_format *v4l2_fmt,       /* format of V4L2 */
352                 struct v4l2_buffer *v4l2_buf,       /* V4L2 buffer */
353                 VASurfaceID *surface               /* out */
354         );
355     
356         VAStatus (*vaCopySurfaceToBuffer) (
357                 VADriverContextP ctx,
358                 VASurfaceID surface,
359                 unsigned int *fourcc, /* out  for follow argument */
360                 unsigned int *luma_stride,
361                 unsigned int *chroma_u_stride,
362                 unsigned int *chroma_v_stride,
363                 unsigned int *luma_offset,
364                 unsigned int *chroma_u_offset,
365                 unsigned int *chroma_v_offset,
366                 void **buffer
367         );
368 };
369
370 struct VADriverContext
371 {
372     void *pDriverData;
373     struct VADriverVTable vtable;
374
375     Display *x11_dpy;
376     int x11_screen;
377     int version_major;
378     int version_minor;
379     int max_profiles;
380     int max_entrypoints;
381     int max_attributes;
382     int max_image_formats;
383     int max_subpic_formats;
384     int max_display_attributes;
385     const char *str_vendor;
386
387     void *handle;                       /* dlopen handle */
388     
389     void *dri_state;
390 };
391
392 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
393 struct VADisplayContext
394 {
395     int vadpy_magic;
396     
397     VADisplayContextP pNext;
398     VADriverContextP pDriverContext;
399
400     int (*vaIsValid) (
401         VADisplayContextP ctx
402     );
403
404     void (*vaDestroy) (
405         VADisplayContextP ctx
406     );
407
408     VAStatus (*vaGetDriverName) (
409         VADisplayContextP ctx,
410         char **driver_name
411     );
412 };
413
414 typedef VAStatus (*VADriverInit) (
415     VADriverContextP driver_context
416 );
417
418
419 #endif /* _VA_BACKEND_H_ */