2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
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:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
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.
26 * Video Decode Acceleration -Backend API
29 #ifndef _VA_BACKEND_H_
30 #define _VA_BACKEND_H_
36 #include <linux/videodev2.h>
38 typedef struct VADriverContext *VADriverContextP;
39 typedef struct VADisplayContext *VADisplayContextP;
43 VAStatus (*vaTerminate) ( VADriverContextP ctx );
45 VAStatus (*vaQueryConfigProfiles) (
47 VAProfile *profile_list, /* out */
48 int *num_profiles /* out */
51 VAStatus (*vaQueryConfigEntrypoints) (
54 VAEntrypoint *entrypoint_list, /* out */
55 int *num_entrypoints /* out */
58 VAStatus (*vaGetConfigAttributes) (
61 VAEntrypoint entrypoint,
62 VAConfigAttrib *attrib_list, /* in/out */
66 VAStatus (*vaCreateConfig) (
69 VAEntrypoint entrypoint,
70 VAConfigAttrib *attrib_list,
72 VAConfigID *config_id /* out */
75 VAStatus (*vaDestroyConfig) (
80 VAStatus (*vaQueryConfigAttributes) (
83 VAProfile *profile, /* out */
84 VAEntrypoint *entrypoint, /* out */
85 VAConfigAttrib *attrib_list, /* out */
86 int *num_attribs /* out */
89 VAStatus (*vaCreateSurfaces) (
95 VASurfaceID *surfaces /* out */
98 VAStatus (*vaDestroySurfaces) (
100 VASurfaceID *surface_list,
104 VAStatus (*vaCreateContext) (
105 VADriverContextP ctx,
106 VAConfigID config_id,
110 VASurfaceID *render_targets,
111 int num_render_targets,
112 VAContextID *context /* out */
115 VAStatus (*vaDestroyContext) (
116 VADriverContextP ctx,
120 VAStatus (*vaCreateBuffer) (
121 VADriverContextP ctx,
122 VAContextID context, /* in */
123 VABufferType type, /* in */
124 unsigned int size, /* in */
125 unsigned int num_elements, /* in */
127 VABufferID *buf_id /* out */
130 VAStatus (*vaBufferSetNumElements) (
131 VADriverContextP ctx,
132 VABufferID buf_id, /* in */
133 unsigned int num_elements /* in */
136 VAStatus (*vaMapBuffer) (
137 VADriverContextP ctx,
138 VABufferID buf_id, /* in */
139 void **pbuf /* out */
142 VAStatus (*vaUnmapBuffer) (
143 VADriverContextP ctx,
144 VABufferID buf_id /* in */
147 VAStatus (*vaDestroyBuffer) (
148 VADriverContextP ctx,
152 VAStatus (*vaBeginPicture) (
153 VADriverContextP ctx,
155 VASurfaceID render_target
158 VAStatus (*vaRenderPicture) (
159 VADriverContextP ctx,
165 VAStatus (*vaEndPicture) (
166 VADriverContextP ctx,
170 VAStatus (*vaSyncSurface) (
171 VADriverContextP ctx,
172 VASurfaceID render_target
175 VAStatus (*vaQuerySurfaceStatus) (
176 VADriverContextP ctx,
177 VASurfaceID render_target,
178 VASurfaceStatus *status /* out */
181 VAStatus (*vaQuerySurfaceError) (
182 VADriverContextP ctx,
183 VASurfaceID render_target,
184 VAStatus error_status,
185 void **error_info /*out*/
188 VAStatus (*vaPutSurface) (
189 VADriverContextP ctx,
191 void* draw, /* Drawable of window system */
198 unsigned short destw,
199 unsigned short desth,
200 VARectangle *cliprects, /* client supplied clip list */
201 unsigned int number_cliprects, /* number of clip rects in the clip list */
202 unsigned int flags /* de-interlacing flags */
205 VAStatus (*vaQueryImageFormats) (
206 VADriverContextP ctx,
207 VAImageFormat *format_list, /* out */
208 int *num_formats /* out */
211 VAStatus (*vaCreateImage) (
212 VADriverContextP ctx,
213 VAImageFormat *format,
216 VAImage *image /* out */
219 VAStatus (*vaDeriveImage) (
220 VADriverContextP ctx,
222 VAImage *image /* out */
225 VAStatus (*vaDestroyImage) (
226 VADriverContextP ctx,
230 VAStatus (*vaSetImagePalette) (
231 VADriverContextP ctx,
234 * pointer to an array holding the palette data. The size of the array is
235 * num_palette_entries * entry_bytes in size. The order of the components
236 * in the palette is described by the component_order in VAImage struct
238 unsigned char *palette
241 VAStatus (*vaGetImage) (
242 VADriverContextP ctx,
244 int x, /* coordinates of the upper left source pixel */
246 unsigned int width, /* width and height of the region */
251 VAStatus (*vaPutImage) (
252 VADriverContextP ctx,
257 unsigned int src_width,
258 unsigned int src_height,
261 unsigned int dest_width,
262 unsigned int dest_height
265 VAStatus (*vaQuerySubpictureFormats) (
266 VADriverContextP ctx,
267 VAImageFormat *format_list, /* out */
268 unsigned int *flags, /* out */
269 unsigned int *num_formats /* out */
272 VAStatus (*vaCreateSubpicture) (
273 VADriverContextP ctx,
275 VASubpictureID *subpicture /* out */
278 VAStatus (*vaDestroySubpicture) (
279 VADriverContextP ctx,
280 VASubpictureID subpicture
283 VAStatus (*vaSetSubpictureImage) (
284 VADriverContextP ctx,
285 VASubpictureID subpicture,
289 VAStatus (*vaSetSubpictureChromakey) (
290 VADriverContextP ctx,
291 VASubpictureID subpicture,
292 unsigned int chromakey_min,
293 unsigned int chromakey_max,
294 unsigned int chromakey_mask
297 VAStatus (*vaSetSubpictureGlobalAlpha) (
298 VADriverContextP ctx,
299 VASubpictureID subpicture,
303 VAStatus (*vaAssociateSubpicture) (
304 VADriverContextP ctx,
305 VASubpictureID subpicture,
306 VASurfaceID *target_surfaces,
308 short src_x, /* upper left offset in subpicture */
310 unsigned short src_width,
311 unsigned short src_height,
312 short dest_x, /* upper left offset in surface */
314 unsigned short dest_width,
315 unsigned short dest_height,
317 * whether to enable chroma-keying or global-alpha
318 * see VA_SUBPICTURE_XXX values
323 VAStatus (*vaDeassociateSubpicture) (
324 VADriverContextP ctx,
325 VASubpictureID subpicture,
326 VASurfaceID *target_surfaces,
330 VAStatus (*vaQueryDisplayAttributes) (
331 VADriverContextP ctx,
332 VADisplayAttribute *attr_list, /* out */
333 int *num_attributes /* out */
336 VAStatus (*vaGetDisplayAttributes) (
337 VADriverContextP ctx,
338 VADisplayAttribute *attr_list, /* in/out */
342 VAStatus (*vaSetDisplayAttributes) (
343 VADriverContextP ctx,
344 VADisplayAttribute *attr_list,
348 /* used by va trace */
349 VAStatus (*vaBufferInfo) (
350 VADriverContextP ctx, /* in */
351 VABufferID buf_id, /* in */
352 VABufferType *type, /* out */
353 unsigned int *size, /* out */
354 unsigned int *num_elements /* out */
357 /* lock/unlock surface for external access */
358 VAStatus (*vaLockSurface) (
359 VADriverContextP ctx,
361 unsigned int *fourcc, /* out for follow argument */
362 unsigned int *luma_stride,
363 unsigned int *chroma_u_stride,
364 unsigned int *chroma_v_stride,
365 unsigned int *luma_offset,
366 unsigned int *chroma_u_offset,
367 unsigned int *chroma_v_offset,
368 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
369 * surface buffer name
371 void **buffer /* if it is not NULL, map the surface buffer for
376 VAStatus (*vaUnlockSurface) (
377 VADriverContextP ctx,
382 struct VADriverContext
387 * The core VA implementation hooks.
389 * This structure is allocated from libva with calloc().
391 struct VADriverVTable *vtable;
394 * The VA/GLX implementation hooks.
396 * This structure is intended for drivers that implement the
397 * VA/GLX API. The driver implementation is responsible for the
398 * allocation and deallocation of this structure.
400 struct VADriverVTableGLX *vtable_glx;
403 * The VA/EGL implementation hooks.
405 * This structure is intended for drivers that implement the
406 * VA/EGL API. The driver implementation is responsible for the
407 * allocation and deallocation of this structure.
409 struct VADriverVTableEGL *vtable_egl;
412 * The third-party/private implementation hooks.
414 * This structure is intended for drivers that implement the
415 * private API. The driver implementation is responsible for the
416 * allocation and deallocation of this structure.
427 int max_image_formats;
428 int max_subpic_formats;
429 int max_display_attributes;
430 const char *str_vendor;
432 void *handle; /* dlopen handle */
435 void *glx; /* opaque for GLX code */
437 unsigned long reserved[44]; /* reserve for future add-ins, decrease the subscript accordingly */
440 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
441 struct VADisplayContext
445 VADisplayContextP pNext;
446 VADriverContextP pDriverContext;
449 VADisplayContextP ctx
453 VADisplayContextP ctx
456 VAStatus (*vaGetDriverName) (
457 VADisplayContextP ctx,
461 void *opaque; /* opaque for display extensions (e.g. GLX) */
463 VAStatus (*vaCreateNativePixmap) (
464 VADisplayContextP pDisplayContext,
467 void **native_pixmap);
469 VAStatus (*vaFreeNativePixmap) (
470 VADisplayContextP pDisplayContext,
471 void *native_pixmap);
474 typedef VAStatus (*VADriverInit) (
475 VADriverContextP driver_context
478 #endif /* _VA_BACKEND_H_ */