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_
33 #include <linux/videodev2.h>
35 typedef struct VADriverContext *VADriverContextP;
36 typedef struct VADisplayContext *VADisplayContextP;
40 VAStatus (*vaTerminate) ( VADriverContextP ctx );
42 VAStatus (*vaQueryConfigProfiles) (
44 VAProfile *profile_list, /* out */
45 int *num_profiles /* out */
48 VAStatus (*vaQueryConfigEntrypoints) (
51 VAEntrypoint *entrypoint_list, /* out */
52 int *num_entrypoints /* out */
55 VAStatus (*vaGetConfigAttributes) (
58 VAEntrypoint entrypoint,
59 VAConfigAttrib *attrib_list, /* in/out */
63 VAStatus (*vaCreateConfig) (
66 VAEntrypoint entrypoint,
67 VAConfigAttrib *attrib_list,
69 VAConfigID *config_id /* out */
72 VAStatus (*vaDestroyConfig) (
77 VAStatus (*vaQueryConfigAttributes) (
80 VAProfile *profile, /* out */
81 VAEntrypoint *entrypoint, /* out */
82 VAConfigAttrib *attrib_list, /* out */
83 int *num_attribs /* out */
86 VAStatus (*vaCreateSurfaces) (
92 VASurfaceID *surfaces /* out */
95 VAStatus (*vaDestroySurfaces) (
97 VASurfaceID *surface_list,
101 VAStatus (*vaCreateContext) (
102 VADriverContextP ctx,
103 VAConfigID config_id,
107 VASurfaceID *render_targets,
108 int num_render_targets,
109 VAContextID *context /* out */
112 VAStatus (*vaDestroyContext) (
113 VADriverContextP ctx,
117 VAStatus (*vaCreateBuffer) (
118 VADriverContextP ctx,
119 VAContextID context, /* in */
120 VABufferType type, /* in */
121 unsigned int size, /* in */
122 unsigned int num_elements, /* in */
124 VABufferID *buf_id /* out */
127 VAStatus (*vaBufferSetNumElements) (
128 VADriverContextP ctx,
129 VABufferID buf_id, /* in */
130 unsigned int num_elements /* in */
133 VAStatus (*vaMapBuffer) (
134 VADriverContextP ctx,
135 VABufferID buf_id, /* in */
136 void **pbuf /* out */
139 VAStatus (*vaUnmapBuffer) (
140 VADriverContextP ctx,
141 VABufferID buf_id /* in */
144 VAStatus (*vaDestroyBuffer) (
145 VADriverContextP ctx,
149 VAStatus (*vaBeginPicture) (
150 VADriverContextP ctx,
152 VASurfaceID render_target
155 VAStatus (*vaRenderPicture) (
156 VADriverContextP ctx,
162 VAStatus (*vaEndPicture) (
163 VADriverContextP ctx,
167 VAStatus (*vaSyncSurface) (
168 VADriverContextP ctx,
169 VASurfaceID render_target
172 VAStatus (*vaQuerySurfaceStatus) (
173 VADriverContextP ctx,
174 VASurfaceID render_target,
175 VASurfaceStatus *status /* out */
178 VAStatus (*vaQuerySurfaceError) (
179 VADriverContextP ctx,
180 VASurfaceID render_target,
181 VAStatus error_status,
182 void **error_info /*out*/
185 VAStatus (*vaPutSurface) (
186 VADriverContextP ctx,
188 void* draw, /* Drawable of window system */
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 */
202 VAStatus (*vaQueryImageFormats) (
203 VADriverContextP ctx,
204 VAImageFormat *format_list, /* out */
205 int *num_formats /* out */
208 VAStatus (*vaCreateImage) (
209 VADriverContextP ctx,
210 VAImageFormat *format,
213 VAImage *image /* out */
216 VAStatus (*vaDeriveImage) (
217 VADriverContextP ctx,
219 VAImage *image /* out */
222 VAStatus (*vaDestroyImage) (
223 VADriverContextP ctx,
227 VAStatus (*vaSetImagePalette) (
228 VADriverContextP ctx,
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
235 unsigned char *palette
238 VAStatus (*vaGetImage) (
239 VADriverContextP ctx,
241 int x, /* coordinates of the upper left source pixel */
243 unsigned int width, /* width and height of the region */
248 VAStatus (*vaPutImage) (
249 VADriverContextP ctx,
254 unsigned int src_width,
255 unsigned int src_height,
258 unsigned int dest_width,
259 unsigned int dest_height
262 VAStatus (*vaQuerySubpictureFormats) (
263 VADriverContextP ctx,
264 VAImageFormat *format_list, /* out */
265 unsigned int *flags, /* out */
266 unsigned int *num_formats /* out */
269 VAStatus (*vaCreateSubpicture) (
270 VADriverContextP ctx,
272 VASubpictureID *subpicture /* out */
275 VAStatus (*vaDestroySubpicture) (
276 VADriverContextP ctx,
277 VASubpictureID subpicture
280 VAStatus (*vaSetSubpictureImage) (
281 VADriverContextP ctx,
282 VASubpictureID subpicture,
286 VAStatus (*vaSetSubpictureChromakey) (
287 VADriverContextP ctx,
288 VASubpictureID subpicture,
289 unsigned int chromakey_min,
290 unsigned int chromakey_max,
291 unsigned int chromakey_mask
294 VAStatus (*vaSetSubpictureGlobalAlpha) (
295 VADriverContextP ctx,
296 VASubpictureID subpicture,
300 VAStatus (*vaAssociateSubpicture) (
301 VADriverContextP ctx,
302 VASubpictureID subpicture,
303 VASurfaceID *target_surfaces,
305 short src_x, /* upper left offset in subpicture */
307 unsigned short src_width,
308 unsigned short src_height,
309 short dest_x, /* upper left offset in surface */
311 unsigned short dest_width,
312 unsigned short dest_height,
314 * whether to enable chroma-keying or global-alpha
315 * see VA_SUBPICTURE_XXX values
320 VAStatus (*vaDeassociateSubpicture) (
321 VADriverContextP ctx,
322 VASubpictureID subpicture,
323 VASurfaceID *target_surfaces,
327 VAStatus (*vaQueryDisplayAttributes) (
328 VADriverContextP ctx,
329 VADisplayAttribute *attr_list, /* out */
330 int *num_attributes /* out */
333 VAStatus (*vaGetDisplayAttributes) (
334 VADriverContextP ctx,
335 VADisplayAttribute *attr_list, /* in/out */
339 VAStatus (*vaSetDisplayAttributes) (
340 VADriverContextP ctx,
341 VADisplayAttribute *attr_list,
345 /* used by va trace */
346 VAStatus (*vaBufferInfo) (
347 VADriverContextP ctx, /* in */
348 VABufferID buf_id, /* in */
349 VABufferType *type, /* out */
350 unsigned int *size, /* out */
351 unsigned int *num_elements /* out */
354 /* lock/unlock surface for external access */
355 VAStatus (*vaLockSurface) (
356 VADriverContextP ctx,
358 unsigned int *fourcc, /* out for follow argument */
359 unsigned int *luma_stride,
360 unsigned int *chroma_u_stride,
361 unsigned int *chroma_v_stride,
362 unsigned int *luma_offset,
363 unsigned int *chroma_u_offset,
364 unsigned int *chroma_v_offset,
365 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
366 * surface buffer name
368 void **buffer /* if it is not NULL, map the surface buffer for
373 VAStatus (*vaUnlockSurface) (
374 VADriverContextP ctx,
379 struct VADriverContext
384 * The core VA implementation hooks.
386 * This structure is allocated from libva with calloc().
388 struct VADriverVTable *vtable;
391 * The VA/GLX implementation hooks.
393 * This structure is intended for drivers that implement the
394 * VA/GLX API. The driver implementation is responsible for the
395 * allocation and deallocation of this structure.
397 struct VADriverVTableGLX *vtable_glx;
400 * The VA/EGL implementation hooks.
402 * This structure is intended for drivers that implement the
403 * VA/EGL API. The driver implementation is responsible for the
404 * allocation and deallocation of this structure.
406 struct VADriverVTableEGL *vtable_egl;
409 * The third-party/private implementation hooks.
411 * This structure is intended for drivers that implement the
412 * private API. The driver implementation is responsible for the
413 * allocation and deallocation of this structure.
424 int max_image_formats;
425 int max_subpic_formats;
426 int max_display_attributes;
427 const char *str_vendor;
429 void *handle; /* dlopen handle */
432 void *glx; /* opaque for GLX code */
434 unsigned long reserved[45]; /* reserve for future add-ins, decrease the subscript accordingly */
437 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
438 struct VADisplayContext
442 VADisplayContextP pNext;
443 VADriverContextP pDriverContext;
446 VADisplayContextP ctx
450 VADisplayContextP ctx
453 VAStatus (*vaGetDriverName) (
454 VADisplayContextP ctx,
458 void *opaque; /* opaque for display extensions (e.g. GLX) */
461 typedef VAStatus (*VADriverInit) (
462 VADriverContextP driver_context
465 #endif /* _VA_BACKEND_H_ */