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/DRM API is used, with a render-node device path */
52 VA_DISPLAY_DRM_RENDERNODES
= (VA_DISPLAY_DRM
| (1 << 0)),
53 /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
54 VA_DISPLAY_WAYLAND
= 0x40,
59 VAStatus (*vaTerminate
) ( VADriverContextP ctx
);
61 VAStatus (*vaQueryConfigProfiles
) (
63 VAProfile
*profile_list
, /* out */
64 int *num_profiles
/* out */
67 VAStatus (*vaQueryConfigEntrypoints
) (
70 VAEntrypoint
*entrypoint_list
, /* out */
71 int *num_entrypoints
/* out */
74 VAStatus (*vaGetConfigAttributes
) (
77 VAEntrypoint entrypoint
,
78 VAConfigAttrib
*attrib_list
, /* in/out */
82 VAStatus (*vaCreateConfig
) (
85 VAEntrypoint entrypoint
,
86 VAConfigAttrib
*attrib_list
,
88 VAConfigID
*config_id
/* out */
91 VAStatus (*vaDestroyConfig
) (
96 VAStatus (*vaQueryConfigAttributes
) (
99 VAProfile
*profile
, /* out */
100 VAEntrypoint
*entrypoint
, /* out */
101 VAConfigAttrib
*attrib_list
, /* out */
102 int *num_attribs
/* out */
105 VAStatus (*vaCreateSurfaces
) (
106 VADriverContextP ctx
,
111 VASurfaceID
*surfaces
/* out */
114 VAStatus (*vaDestroySurfaces
) (
115 VADriverContextP ctx
,
116 VASurfaceID
*surface_list
,
120 VAStatus (*vaCreateContext
) (
121 VADriverContextP ctx
,
122 VAConfigID config_id
,
126 VASurfaceID
*render_targets
,
127 int num_render_targets
,
128 VAContextID
*context
/* out */
131 VAStatus (*vaDestroyContext
) (
132 VADriverContextP ctx
,
136 VAStatus (*vaCreateBuffer
) (
137 VADriverContextP ctx
,
138 VAContextID context
, /* in */
139 VABufferType type
, /* in */
140 unsigned int size
, /* in */
141 unsigned int num_elements
, /* in */
143 VABufferID
*buf_id
/* out */
146 VAStatus (*vaBufferSetNumElements
) (
147 VADriverContextP ctx
,
148 VABufferID buf_id
, /* in */
149 unsigned int num_elements
/* in */
152 VAStatus (*vaMapBuffer
) (
153 VADriverContextP ctx
,
154 VABufferID buf_id
, /* in */
155 void **pbuf
/* out */
158 VAStatus (*vaUnmapBuffer
) (
159 VADriverContextP ctx
,
160 VABufferID buf_id
/* in */
163 VAStatus (*vaDestroyBuffer
) (
164 VADriverContextP ctx
,
168 VAStatus (*vaBeginPicture
) (
169 VADriverContextP ctx
,
171 VASurfaceID render_target
174 VAStatus (*vaRenderPicture
) (
175 VADriverContextP ctx
,
181 VAStatus (*vaEndPicture
) (
182 VADriverContextP ctx
,
186 VAStatus (*vaSyncSurface
) (
187 VADriverContextP ctx
,
188 VASurfaceID render_target
191 VAStatus (*vaQuerySurfaceStatus
) (
192 VADriverContextP ctx
,
193 VASurfaceID render_target
,
194 VASurfaceStatus
*status
/* out */
197 VAStatus (*vaQuerySurfaceError
) (
198 VADriverContextP ctx
,
199 VASurfaceID render_target
,
200 VAStatus error_status
,
201 void **error_info
/*out*/
204 VAStatus (*vaPutSurface
) (
205 VADriverContextP ctx
,
207 void* draw
, /* Drawable of window system */
214 unsigned short destw
,
215 unsigned short desth
,
216 VARectangle
*cliprects
, /* client supplied clip list */
217 unsigned int number_cliprects
, /* number of clip rects in the clip list */
218 unsigned int flags
/* de-interlacing flags */
221 VAStatus (*vaQueryImageFormats
) (
222 VADriverContextP ctx
,
223 VAImageFormat
*format_list
, /* out */
224 int *num_formats
/* out */
227 VAStatus (*vaCreateImage
) (
228 VADriverContextP ctx
,
229 VAImageFormat
*format
,
232 VAImage
*image
/* out */
235 VAStatus (*vaDeriveImage
) (
236 VADriverContextP ctx
,
238 VAImage
*image
/* out */
241 VAStatus (*vaDestroyImage
) (
242 VADriverContextP ctx
,
246 VAStatus (*vaSetImagePalette
) (
247 VADriverContextP ctx
,
250 * pointer to an array holding the palette data. The size of the array is
251 * num_palette_entries * entry_bytes in size. The order of the components
252 * in the palette is described by the component_order in VAImage struct
254 unsigned char *palette
257 VAStatus (*vaGetImage
) (
258 VADriverContextP ctx
,
260 int x
, /* coordinates of the upper left source pixel */
262 unsigned int width
, /* width and height of the region */
267 VAStatus (*vaPutImage
) (
268 VADriverContextP ctx
,
273 unsigned int src_width
,
274 unsigned int src_height
,
277 unsigned int dest_width
,
278 unsigned int dest_height
281 VAStatus (*vaQuerySubpictureFormats
) (
282 VADriverContextP ctx
,
283 VAImageFormat
*format_list
, /* out */
284 unsigned int *flags
, /* out */
285 unsigned int *num_formats
/* out */
288 VAStatus (*vaCreateSubpicture
) (
289 VADriverContextP ctx
,
291 VASubpictureID
*subpicture
/* out */
294 VAStatus (*vaDestroySubpicture
) (
295 VADriverContextP ctx
,
296 VASubpictureID subpicture
299 VAStatus (*vaSetSubpictureImage
) (
300 VADriverContextP ctx
,
301 VASubpictureID subpicture
,
305 VAStatus (*vaSetSubpictureChromakey
) (
306 VADriverContextP ctx
,
307 VASubpictureID subpicture
,
308 unsigned int chromakey_min
,
309 unsigned int chromakey_max
,
310 unsigned int chromakey_mask
313 VAStatus (*vaSetSubpictureGlobalAlpha
) (
314 VADriverContextP ctx
,
315 VASubpictureID subpicture
,
319 VAStatus (*vaAssociateSubpicture
) (
320 VADriverContextP ctx
,
321 VASubpictureID subpicture
,
322 VASurfaceID
*target_surfaces
,
324 short src_x
, /* upper left offset in subpicture */
326 unsigned short src_width
,
327 unsigned short src_height
,
328 short dest_x
, /* upper left offset in surface */
330 unsigned short dest_width
,
331 unsigned short dest_height
,
333 * whether to enable chroma-keying or global-alpha
334 * see VA_SUBPICTURE_XXX values
339 VAStatus (*vaDeassociateSubpicture
) (
340 VADriverContextP ctx
,
341 VASubpictureID subpicture
,
342 VASurfaceID
*target_surfaces
,
346 VAStatus (*vaQueryDisplayAttributes
) (
347 VADriverContextP ctx
,
348 VADisplayAttribute
*attr_list
, /* out */
349 int *num_attributes
/* out */
352 VAStatus (*vaGetDisplayAttributes
) (
353 VADriverContextP ctx
,
354 VADisplayAttribute
*attr_list
, /* in/out */
358 VAStatus (*vaSetDisplayAttributes
) (
359 VADriverContextP ctx
,
360 VADisplayAttribute
*attr_list
,
364 /* used by va trace */
365 VAStatus (*vaBufferInfo
) (
366 VADriverContextP ctx
, /* in */
367 VABufferID buf_id
, /* in */
368 VABufferType
*type
, /* out */
369 unsigned int *size
, /* out */
370 unsigned int *num_elements
/* out */
373 /* lock/unlock surface for external access */
374 VAStatus (*vaLockSurface
) (
375 VADriverContextP ctx
,
377 unsigned int *fourcc
, /* out for follow argument */
378 unsigned int *luma_stride
,
379 unsigned int *chroma_u_stride
,
380 unsigned int *chroma_v_stride
,
381 unsigned int *luma_offset
,
382 unsigned int *chroma_u_offset
,
383 unsigned int *chroma_v_offset
,
384 unsigned int *buffer_name
, /* if it is not NULL, assign the low lever
385 * surface buffer name
387 void **buffer
/* if it is not NULL, map the surface buffer for
392 VAStatus (*vaUnlockSurface
) (
393 VADriverContextP ctx
,
399 (*vaGetSurfaceAttributes
)(
400 VADriverContextP dpy
,
402 VASurfaceAttrib
*attrib_list
,
403 unsigned int num_attribs
407 (*vaCreateSurfaces2
)(
408 VADriverContextP ctx
,
412 VASurfaceID
*surfaces
,
413 unsigned int num_surfaces
,
414 VASurfaceAttrib
*attrib_list
,
415 unsigned int num_attribs
419 (*vaQuerySurfaceAttributes
)(
420 VADriverContextP dpy
,
422 VASurfaceAttrib
*attrib_list
,
423 unsigned int *num_attribs
427 (*vaAcquireBufferHandle
)(
428 VADriverContextP ctx
,
429 VABufferID buf_id
, /* in */
430 VABufferInfo
* buf_info
/* in/out */
434 (*vaReleaseBufferHandle
)(
435 VADriverContextP ctx
,
436 VABufferID buf_id
/* in */
440 struct VADriverContext
445 * The core VA implementation hooks.
447 * This structure is allocated from libva with calloc().
449 struct VADriverVTable
*vtable
;
452 * The VA/GLX implementation hooks.
454 * This structure is intended for drivers that implement the
455 * VA/GLX API. The driver implementation is responsible for the
456 * allocation and deallocation of this structure.
458 struct VADriverVTableGLX
*vtable_glx
;
461 * The VA/EGL implementation hooks.
463 * This structure is intended for drivers that implement the
464 * VA/EGL API. The driver implementation is responsible for the
465 * allocation and deallocation of this structure.
467 struct VADriverVTableEGL
*vtable_egl
;
470 * The third-party/private implementation hooks.
472 * This structure is intended for drivers that implement the
473 * private API. The driver implementation is responsible for the
474 * allocation and deallocation of this structure.
485 int max_image_formats
;
486 int max_subpic_formats
;
487 int max_display_attributes
;
488 const char *str_vendor
;
490 void *handle
; /* dlopen handle */
495 * This field holds driver specific data for DRM-based
496 * drivers. This structure is allocated from libva with
497 * calloc(). Do not deallocate from within VA driver
500 * All structures shall be derived from struct drm_state. So, for
501 * instance, this field holds a dri_state structure for VA/X11
502 * drivers that use the DRM protocol.
506 void *glx
; /* opaque for GLX code */
508 /** \brief VA display type. */
509 unsigned long display_type
;
512 * The VA/Wayland implementation hooks.
514 * This structure is intended for drivers that implement the
515 * VA/Wayland API. libVA allocates this structure with calloc()
516 * and owns the resulting memory.
518 struct VADriverVTableWayland
*vtable_wayland
;
521 * \brief The VA/VPP implementation hooks.
523 * This structure is allocated from libva with calloc().
525 struct VADriverVTableVPP
*vtable_vpp
;
527 char *override_driver_name
;
529 unsigned long reserved
[41]; /* reserve for future add-ins, decrease the subscript accordingly */
532 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
533 struct VADisplayContext
537 VADisplayContextP pNext
;
538 VADriverContextP pDriverContext
;
541 VADisplayContextP ctx
545 VADisplayContextP ctx
548 VAStatus (*vaGetDriverName
) (
549 VADisplayContextP ctx
,
553 void *opaque
; /* opaque for display extensions (e.g. GLX) */
554 void *vatrace
; /* opaque for VA trace context */
555 void *vafool
; /* opaque for VA fool context */
558 typedef VAStatus (*VADriverInit
) (
559 VADriverContextP driver_context
562 #endif /* _VA_BACKEND_H_ */