OSDN Git Service

restore old va_DisplayContextGetDriverName
[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                 Surface* 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 (*vaQueryImageFormats) (
203                 VADriverContextP ctx,
204                 VAImageFormat *format_list,        /* out */
205                 int *num_formats           /* out */
206         );
207
208         VAStatus (*vaCreateImage) (
209                 VADriverContextP ctx,
210                 VAImageFormat *format,
211                 int width,
212                 int height,
213                 VAImage *image     /* out */
214         );
215
216         VAStatus (*vaDeriveImage) (
217                 VADriverContextP ctx,
218                 VASurfaceID surface,
219                 VAImage *image     /* out */
220         );
221
222         VAStatus (*vaDestroyImage) (
223                 VADriverContextP ctx,
224                 VAImageID image
225         );
226         
227         VAStatus (*vaSetImagePalette) (
228                 VADriverContextP ctx,
229                 VAImageID image,
230                 /*
231                  * pointer to an array holding the palette data.  The size of the array is
232                  * num_palette_entries * entry_bytes in size.  The order of the components
233                  * in the palette is described by the component_order in VAImage struct
234                  */
235                 unsigned char *palette
236         );
237         
238         VAStatus (*vaGetImage) (
239                 VADriverContextP ctx,
240                 VASurfaceID surface,
241                 int x,     /* coordinates of the upper left source pixel */
242                 int y,
243                 unsigned int width, /* width and height of the region */
244                 unsigned int height,
245                 VAImageID image
246         );
247
248         VAStatus (*vaPutImage) (
249                 VADriverContextP ctx,
250                 VASurfaceID surface,
251                 VAImageID image,
252                 int src_x,
253                 int src_y,
254                 unsigned int src_width,
255                 unsigned int src_height,
256                 int dest_x,
257                 int dest_y,
258                 unsigned int dest_width,
259                 unsigned int dest_height
260         );
261
262         VAStatus (*vaQuerySubpictureFormats) (
263                 VADriverContextP ctx,
264                 VAImageFormat *format_list,        /* out */
265                 unsigned int *flags,       /* out */
266                 unsigned int *num_formats  /* out */
267         );
268
269         VAStatus (*vaCreateSubpicture) (
270                 VADriverContextP ctx,
271                 VAImageID image,
272                 VASubpictureID *subpicture   /* out */
273         );
274
275         VAStatus (*vaDestroySubpicture) (
276                 VADriverContextP ctx,
277                 VASubpictureID subpicture
278         );
279
280         VAStatus (*vaSetSubpictureImage) (
281                 VADriverContextP ctx,
282                 VASubpictureID subpicture,
283                 VAImageID image
284         );
285
286         VAStatus (*vaSetSubpictureChromakey) (
287                 VADriverContextP ctx,
288                 VASubpictureID subpicture,
289                 unsigned int chromakey_min,
290                 unsigned int chromakey_max,
291                 unsigned int chromakey_mask
292         );
293
294         VAStatus (*vaSetSubpictureGlobalAlpha) (
295                 VADriverContextP ctx,
296                 VASubpictureID subpicture,
297                 float global_alpha 
298         );
299
300         VAStatus (*vaAssociateSubpicture) (
301                 VADriverContextP ctx,
302                 VASubpictureID subpicture,
303                 VASurfaceID *target_surfaces,
304                 int num_surfaces,
305                 short src_x, /* upper left offset in subpicture */
306                 short src_y,
307                 unsigned short src_width,
308                 unsigned short src_height,
309                 short dest_x, /* upper left offset in surface */
310                 short dest_y,
311                 unsigned short dest_width,
312                 unsigned short dest_height,
313                 /*
314                  * whether to enable chroma-keying or global-alpha
315                  * see VA_SUBPICTURE_XXX values
316                  */
317                 unsigned int flags
318         );
319
320         VAStatus (*vaDeassociateSubpicture) (
321                 VADriverContextP ctx,
322                 VASubpictureID subpicture,
323                 VASurfaceID *target_surfaces,
324                 int num_surfaces
325         );
326
327         VAStatus (*vaQueryDisplayAttributes) (
328                 VADriverContextP ctx,
329                 VADisplayAttribute *attr_list,  /* out */
330                 int *num_attributes             /* out */
331         );
332
333         VAStatus (*vaGetDisplayAttributes) (
334                 VADriverContextP ctx,
335                 VADisplayAttribute *attr_list,  /* in/out */
336                 int num_attributes
337         );
338         
339         VAStatus (*vaSetDisplayAttributes) (
340                 VADriverContextP ctx,
341                 VADisplayAttribute *attr_list,
342                 int num_attributes
343         );
344
345         /* device specific */
346         VAStatus (*vaCreateSurfaceFromCIFrame) (
347                 VADriverContextP ctx,
348                 unsigned long frame_id,
349                 VASurfaceID *surface            /* out */
350         );
351     
352     
353         VAStatus (*vaCreateSurfaceFromV4L2Buf) (
354                 VADriverContextP ctx,
355                 int v4l2_fd,         /* file descriptor of V4L2 device */
356                 struct v4l2_format *v4l2_fmt,       /* format of V4L2 */
357                 struct v4l2_buffer *v4l2_buf,       /* V4L2 buffer */
358                 VASurfaceID *surface               /* out */
359         );
360
361         VAStatus (*vaBufferInfo) (
362                    VADriverContextP ctx,
363                    VAContextID context, /* in */
364                    VABufferID buf_id, /* in */
365                    VABufferType *type,    /* out */
366                    unsigned int *size,    /* out */
367                    unsigned int *num_elements /* out */
368         );
369
370     
371         VAStatus (*vaCopySurfaceToBuffer) (
372                 VADriverContextP ctx,
373                 VASurfaceID surface,
374                 unsigned int *fourcc, /* out  for follow argument */
375                 unsigned int *luma_stride,
376                 unsigned int *chroma_u_stride,
377                 unsigned int *chroma_v_stride,
378                 unsigned int *luma_offset,
379                 unsigned int *chroma_u_offset,
380                 unsigned int *chroma_v_offset,
381                 void **buffer
382         );
383 };
384
385 struct VADriverContext
386 {
387     void *pDriverData;
388     struct VADriverVTable vtable;
389
390     void *native_dpy;
391     int x11_screen;
392     int version_major;
393     int version_minor;
394     int max_profiles;
395     int max_entrypoints;
396     int max_attributes;
397     int max_image_formats;
398     int max_subpic_formats;
399     int max_display_attributes;
400     const char *str_vendor;
401
402     void *handle;                       /* dlopen handle */
403     
404     void *dri_state;
405 };
406
407 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
408 struct VADisplayContext
409 {
410     int vadpy_magic;
411     
412     VADisplayContextP pNext;
413     VADriverContextP pDriverContext;
414
415     int (*vaIsValid) (
416         VADisplayContextP ctx
417     );
418
419     void (*vaDestroy) (
420         VADisplayContextP ctx
421     );
422
423     VAStatus (*vaGetDriverName) (
424         VADisplayContextP ctx,
425         char **driver_name
426     );
427 };
428
429 typedef VAStatus (*VADriverInit) (
430     VADriverContextP driver_context
431 );
432
433
434 #endif /* _VA_BACKEND_H_ */