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;
38 /** \brief VA display types. */
40 /** \brief Mask to major identifier for VA display type. */
41 VA_DISPLAY_MAJOR_MASK = 0xf0,
43 /** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */
44 VA_DISPLAY_X11 = 0x10,
45 /** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */
46 VA_DISPLAY_GLX = (VA_DISPLAY_X11 | (1 << 0)),
47 /** \brief VA/Android API is used, through vaGetDisplay() entry-point. */
48 VA_DISPLAY_ANDROID = 0x20,
49 /** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
50 VA_DISPLAY_DRM = 0x30,
51 /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
52 VA_DISPLAY_WAYLAND = 0x40,
57 VAStatus (*vaTerminate) ( VADriverContextP ctx );
59 VAStatus (*vaQueryConfigProfiles) (
61 VAProfile *profile_list, /* out */
62 int *num_profiles /* out */
65 VAStatus (*vaQueryConfigEntrypoints) (
68 VAEntrypoint *entrypoint_list, /* out */
69 int *num_entrypoints /* out */
72 VAStatus (*vaGetConfigAttributes) (
75 VAEntrypoint entrypoint,
76 VAConfigAttrib *attrib_list, /* in/out */
80 VAStatus (*vaCreateConfig) (
83 VAEntrypoint entrypoint,
84 VAConfigAttrib *attrib_list,
86 VAConfigID *config_id /* out */
89 VAStatus (*vaDestroyConfig) (
94 VAStatus (*vaQueryConfigAttributes) (
97 VAProfile *profile, /* out */
98 VAEntrypoint *entrypoint, /* out */
99 VAConfigAttrib *attrib_list, /* out */
100 int *num_attribs /* out */
103 VAStatus (*vaCreateSurfaces) (
104 VADriverContextP ctx,
109 VASurfaceID *surfaces /* out */
112 VAStatus (*vaDestroySurfaces) (
113 VADriverContextP ctx,
114 VASurfaceID *surface_list,
118 VAStatus (*vaCreateContext) (
119 VADriverContextP ctx,
120 VAConfigID config_id,
124 VASurfaceID *render_targets,
125 int num_render_targets,
126 VAContextID *context /* out */
129 VAStatus (*vaDestroyContext) (
130 VADriverContextP ctx,
134 VAStatus (*vaCreateBuffer) (
135 VADriverContextP ctx,
136 VAContextID context, /* in */
137 VABufferType type, /* in */
138 unsigned int size, /* in */
139 unsigned int num_elements, /* in */
141 VABufferID *buf_id /* out */
144 VAStatus (*vaBufferSetNumElements) (
145 VADriverContextP ctx,
146 VABufferID buf_id, /* in */
147 unsigned int num_elements /* in */
150 VAStatus (*vaMapBuffer) (
151 VADriverContextP ctx,
152 VABufferID buf_id, /* in */
153 void **pbuf /* out */
156 VAStatus (*vaUnmapBuffer) (
157 VADriverContextP ctx,
158 VABufferID buf_id /* in */
161 VAStatus (*vaDestroyBuffer) (
162 VADriverContextP ctx,
166 VAStatus (*vaBeginPicture) (
167 VADriverContextP ctx,
169 VASurfaceID render_target
172 VAStatus (*vaRenderPicture) (
173 VADriverContextP ctx,
179 VAStatus (*vaEndPicture) (
180 VADriverContextP ctx,
184 VAStatus (*vaSyncSurface) (
185 VADriverContextP ctx,
186 VASurfaceID render_target
189 VAStatus (*vaQuerySurfaceStatus) (
190 VADriverContextP ctx,
191 VASurfaceID render_target,
192 VASurfaceStatus *status /* out */
195 VAStatus (*vaQuerySurfaceError) (
196 VADriverContextP ctx,
197 VASurfaceID render_target,
198 VAStatus error_status,
199 void **error_info /*out*/
202 VAStatus (*vaPutSurface) (
203 VADriverContextP ctx,
205 void* draw, /* Drawable of window system */
212 unsigned short destw,
213 unsigned short desth,
214 VARectangle *cliprects, /* client supplied clip list */
215 unsigned int number_cliprects, /* number of clip rects in the clip list */
216 unsigned int flags /* de-interlacing flags */
219 VAStatus (*vaQueryImageFormats) (
220 VADriverContextP ctx,
221 VAImageFormat *format_list, /* out */
222 int *num_formats /* out */
225 VAStatus (*vaCreateImage) (
226 VADriverContextP ctx,
227 VAImageFormat *format,
230 VAImage *image /* out */
233 VAStatus (*vaDeriveImage) (
234 VADriverContextP ctx,
236 VAImage *image /* out */
239 VAStatus (*vaDestroyImage) (
240 VADriverContextP ctx,
244 VAStatus (*vaSetImagePalette) (
245 VADriverContextP ctx,
248 * pointer to an array holding the palette data. The size of the array is
249 * num_palette_entries * entry_bytes in size. The order of the components
250 * in the palette is described by the component_order in VAImage struct
252 unsigned char *palette
255 VAStatus (*vaGetImage) (
256 VADriverContextP ctx,
258 int x, /* coordinates of the upper left source pixel */
260 unsigned int width, /* width and height of the region */
265 VAStatus (*vaPutImage) (
266 VADriverContextP ctx,
271 unsigned int src_width,
272 unsigned int src_height,
275 unsigned int dest_width,
276 unsigned int dest_height
279 VAStatus (*vaQuerySubpictureFormats) (
280 VADriverContextP ctx,
281 VAImageFormat *format_list, /* out */
282 unsigned int *flags, /* out */
283 unsigned int *num_formats /* out */
286 VAStatus (*vaCreateSubpicture) (
287 VADriverContextP ctx,
289 VASubpictureID *subpicture /* out */
292 VAStatus (*vaDestroySubpicture) (
293 VADriverContextP ctx,
294 VASubpictureID subpicture
297 VAStatus (*vaSetSubpictureImage) (
298 VADriverContextP ctx,
299 VASubpictureID subpicture,
303 VAStatus (*vaSetSubpictureChromakey) (
304 VADriverContextP ctx,
305 VASubpictureID subpicture,
306 unsigned int chromakey_min,
307 unsigned int chromakey_max,
308 unsigned int chromakey_mask
311 VAStatus (*vaSetSubpictureGlobalAlpha) (
312 VADriverContextP ctx,
313 VASubpictureID subpicture,
317 VAStatus (*vaAssociateSubpicture) (
318 VADriverContextP ctx,
319 VASubpictureID subpicture,
320 VASurfaceID *target_surfaces,
322 short src_x, /* upper left offset in subpicture */
324 unsigned short src_width,
325 unsigned short src_height,
326 short dest_x, /* upper left offset in surface */
328 unsigned short dest_width,
329 unsigned short dest_height,
331 * whether to enable chroma-keying or global-alpha
332 * see VA_SUBPICTURE_XXX values
337 VAStatus (*vaDeassociateSubpicture) (
338 VADriverContextP ctx,
339 VASubpictureID subpicture,
340 VASurfaceID *target_surfaces,
344 VAStatus (*vaQueryDisplayAttributes) (
345 VADriverContextP ctx,
346 VADisplayAttribute *attr_list, /* out */
347 int *num_attributes /* out */
350 VAStatus (*vaGetDisplayAttributes) (
351 VADriverContextP ctx,
352 VADisplayAttribute *attr_list, /* in/out */
356 VAStatus (*vaSetDisplayAttributes) (
357 VADriverContextP ctx,
358 VADisplayAttribute *attr_list,
362 /* used by va trace */
363 VAStatus (*vaBufferInfo) (
364 VADriverContextP ctx, /* in */
365 VABufferID buf_id, /* in */
366 VABufferType *type, /* out */
367 unsigned int *size, /* out */
368 unsigned int *num_elements /* out */
371 /* lock/unlock surface for external access */
372 VAStatus (*vaLockSurface) (
373 VADriverContextP ctx,
375 unsigned int *fourcc, /* out for follow argument */
376 unsigned int *luma_stride,
377 unsigned int *chroma_u_stride,
378 unsigned int *chroma_v_stride,
379 unsigned int *luma_offset,
380 unsigned int *chroma_u_offset,
381 unsigned int *chroma_v_offset,
382 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
383 * surface buffer name
385 void **buffer /* if it is not NULL, map the surface buffer for
390 VAStatus (*vaUnlockSurface) (
391 VADriverContextP ctx,
396 (*vaGetSurfaceAttributes)(
397 VADriverContextP dpy,
399 VASurfaceAttrib *attrib_list,
400 unsigned int num_attribs
404 (*vaCreateSurfaces2)(
405 VADriverContextP ctx,
409 VASurfaceID *surfaces,
410 unsigned int num_surfaces,
411 VASurfaceAttrib *attrib_list,
412 unsigned int num_attribs
416 struct VADriverContext
421 * The core VA implementation hooks.
423 * This structure is allocated from libva with calloc().
425 struct VADriverVTable *vtable;
428 * The VA/GLX implementation hooks.
430 * This structure is intended for drivers that implement the
431 * VA/GLX API. The driver implementation is responsible for the
432 * allocation and deallocation of this structure.
434 struct VADriverVTableGLX *vtable_glx;
437 * The VA/EGL implementation hooks.
439 * This structure is intended for drivers that implement the
440 * VA/EGL API. The driver implementation is responsible for the
441 * allocation and deallocation of this structure.
443 struct VADriverVTableEGL *vtable_egl;
446 * The third-party/private implementation hooks.
448 * This structure is intended for drivers that implement the
449 * private API. The driver implementation is responsible for the
450 * allocation and deallocation of this structure.
461 int max_image_formats;
462 int max_subpic_formats;
463 int max_display_attributes;
464 const char *str_vendor;
466 void *handle; /* dlopen handle */
471 * This field holds driver specific data for DRM-based
472 * drivers. This structure is allocated from libva with
473 * calloc(). Do not deallocate from within VA driver
476 * All structures shall be derived from struct drm_state. So, for
477 * instance, this field holds a dri_state structure for VA/X11
478 * drivers that use the DRM protocol.
482 void *glx; /* opaque for GLX code */
485 * \brief The VA/VPP implementation hooks.
487 * This structure is allocated from libva with calloc().
489 struct VADriverVTableVPP *vtable_vpp;
491 /** \brief VA display type. */
492 unsigned long display_type;
495 * The VA/Wayland implementation hooks.
497 * This structure is intended for drivers that implement the
498 * VA/Wayland API. libVA allocates this structure with calloc()
499 * and owns the resulting memory.
501 struct VADriverVTableWayland *vtable_wayland;
503 unsigned long reserved[42]; /* reserve for future add-ins, decrease the subscript accordingly */
506 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
507 struct VADisplayContext
511 VADisplayContextP pNext;
512 VADriverContextP pDriverContext;
515 VADisplayContextP ctx
519 VADisplayContextP ctx
522 VAStatus (*vaGetDriverName) (
523 VADisplayContextP ctx,
527 void *opaque; /* opaque for display extensions (e.g. GLX) */
530 typedef VAStatus (*VADriverInit) (
531 VADriverContextP driver_context
534 #endif /* _VA_BACKEND_H_ */