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,
55 VAStatus (*vaTerminate) ( VADriverContextP ctx );
57 VAStatus (*vaQueryConfigProfiles) (
59 VAProfile *profile_list, /* out */
60 int *num_profiles /* out */
63 VAStatus (*vaQueryConfigEntrypoints) (
66 VAEntrypoint *entrypoint_list, /* out */
67 int *num_entrypoints /* out */
70 VAStatus (*vaGetConfigAttributes) (
73 VAEntrypoint entrypoint,
74 VAConfigAttrib *attrib_list, /* in/out */
78 VAStatus (*vaCreateConfig) (
81 VAEntrypoint entrypoint,
82 VAConfigAttrib *attrib_list,
84 VAConfigID *config_id /* out */
87 VAStatus (*vaDestroyConfig) (
92 VAStatus (*vaQueryConfigAttributes) (
95 VAProfile *profile, /* out */
96 VAEntrypoint *entrypoint, /* out */
97 VAConfigAttrib *attrib_list, /* out */
98 int *num_attribs /* out */
101 VAStatus (*vaCreateSurfaces) (
102 VADriverContextP ctx,
107 VASurfaceID *surfaces /* out */
110 VAStatus (*vaDestroySurfaces) (
111 VADriverContextP ctx,
112 VASurfaceID *surface_list,
116 VAStatus (*vaCreateContext) (
117 VADriverContextP ctx,
118 VAConfigID config_id,
122 VASurfaceID *render_targets,
123 int num_render_targets,
124 VAContextID *context /* out */
127 VAStatus (*vaDestroyContext) (
128 VADriverContextP ctx,
132 VAStatus (*vaCreateBuffer) (
133 VADriverContextP ctx,
134 VAContextID context, /* in */
135 VABufferType type, /* in */
136 unsigned int size, /* in */
137 unsigned int num_elements, /* in */
139 VABufferID *buf_id /* out */
142 VAStatus (*vaBufferSetNumElements) (
143 VADriverContextP ctx,
144 VABufferID buf_id, /* in */
145 unsigned int num_elements /* in */
148 VAStatus (*vaMapBuffer) (
149 VADriverContextP ctx,
150 VABufferID buf_id, /* in */
151 void **pbuf /* out */
154 VAStatus (*vaUnmapBuffer) (
155 VADriverContextP ctx,
156 VABufferID buf_id /* in */
159 VAStatus (*vaDestroyBuffer) (
160 VADriverContextP ctx,
164 VAStatus (*vaBeginPicture) (
165 VADriverContextP ctx,
167 VASurfaceID render_target
170 VAStatus (*vaRenderPicture) (
171 VADriverContextP ctx,
177 VAStatus (*vaEndPicture) (
178 VADriverContextP ctx,
182 VAStatus (*vaSyncSurface) (
183 VADriverContextP ctx,
184 VASurfaceID render_target
187 VAStatus (*vaQuerySurfaceStatus) (
188 VADriverContextP ctx,
189 VASurfaceID render_target,
190 VASurfaceStatus *status /* out */
193 VAStatus (*vaQuerySurfaceError) (
194 VADriverContextP ctx,
195 VASurfaceID render_target,
196 VAStatus error_status,
197 void **error_info /*out*/
200 VAStatus (*vaPutSurface) (
201 VADriverContextP ctx,
203 void* draw, /* Drawable of window system */
210 unsigned short destw,
211 unsigned short desth,
212 VARectangle *cliprects, /* client supplied clip list */
213 unsigned int number_cliprects, /* number of clip rects in the clip list */
214 unsigned int flags /* de-interlacing flags */
217 VAStatus (*vaQueryImageFormats) (
218 VADriverContextP ctx,
219 VAImageFormat *format_list, /* out */
220 int *num_formats /* out */
223 VAStatus (*vaCreateImage) (
224 VADriverContextP ctx,
225 VAImageFormat *format,
228 VAImage *image /* out */
231 VAStatus (*vaDeriveImage) (
232 VADriverContextP ctx,
234 VAImage *image /* out */
237 VAStatus (*vaDestroyImage) (
238 VADriverContextP ctx,
242 VAStatus (*vaSetImagePalette) (
243 VADriverContextP ctx,
246 * pointer to an array holding the palette data. The size of the array is
247 * num_palette_entries * entry_bytes in size. The order of the components
248 * in the palette is described by the component_order in VAImage struct
250 unsigned char *palette
253 VAStatus (*vaGetImage) (
254 VADriverContextP ctx,
256 int x, /* coordinates of the upper left source pixel */
258 unsigned int width, /* width and height of the region */
263 VAStatus (*vaPutImage) (
264 VADriverContextP ctx,
269 unsigned int src_width,
270 unsigned int src_height,
273 unsigned int dest_width,
274 unsigned int dest_height
277 VAStatus (*vaQuerySubpictureFormats) (
278 VADriverContextP ctx,
279 VAImageFormat *format_list, /* out */
280 unsigned int *flags, /* out */
281 unsigned int *num_formats /* out */
284 VAStatus (*vaCreateSubpicture) (
285 VADriverContextP ctx,
287 VASubpictureID *subpicture /* out */
290 VAStatus (*vaDestroySubpicture) (
291 VADriverContextP ctx,
292 VASubpictureID subpicture
295 VAStatus (*vaSetSubpictureImage) (
296 VADriverContextP ctx,
297 VASubpictureID subpicture,
301 VAStatus (*vaSetSubpictureChromakey) (
302 VADriverContextP ctx,
303 VASubpictureID subpicture,
304 unsigned int chromakey_min,
305 unsigned int chromakey_max,
306 unsigned int chromakey_mask
309 VAStatus (*vaSetSubpictureGlobalAlpha) (
310 VADriverContextP ctx,
311 VASubpictureID subpicture,
315 VAStatus (*vaAssociateSubpicture) (
316 VADriverContextP ctx,
317 VASubpictureID subpicture,
318 VASurfaceID *target_surfaces,
320 short src_x, /* upper left offset in subpicture */
322 unsigned short src_width,
323 unsigned short src_height,
324 short dest_x, /* upper left offset in surface */
326 unsigned short dest_width,
327 unsigned short dest_height,
329 * whether to enable chroma-keying or global-alpha
330 * see VA_SUBPICTURE_XXX values
335 VAStatus (*vaDeassociateSubpicture) (
336 VADriverContextP ctx,
337 VASubpictureID subpicture,
338 VASurfaceID *target_surfaces,
342 VAStatus (*vaQueryDisplayAttributes) (
343 VADriverContextP ctx,
344 VADisplayAttribute *attr_list, /* out */
345 int *num_attributes /* out */
348 VAStatus (*vaGetDisplayAttributes) (
349 VADriverContextP ctx,
350 VADisplayAttribute *attr_list, /* in/out */
354 VAStatus (*vaSetDisplayAttributes) (
355 VADriverContextP ctx,
356 VADisplayAttribute *attr_list,
360 /* used by va trace */
361 VAStatus (*vaBufferInfo) (
362 VADriverContextP ctx, /* in */
363 VABufferID buf_id, /* in */
364 VABufferType *type, /* out */
365 unsigned int *size, /* out */
366 unsigned int *num_elements /* out */
369 /* lock/unlock surface for external access */
370 VAStatus (*vaLockSurface) (
371 VADriverContextP ctx,
373 unsigned int *fourcc, /* out for follow argument */
374 unsigned int *luma_stride,
375 unsigned int *chroma_u_stride,
376 unsigned int *chroma_v_stride,
377 unsigned int *luma_offset,
378 unsigned int *chroma_u_offset,
379 unsigned int *chroma_v_offset,
380 unsigned int *buffer_name, /* if it is not NULL, assign the low lever
381 * surface buffer name
383 void **buffer /* if it is not NULL, map the surface buffer for
388 VAStatus (*vaUnlockSurface) (
389 VADriverContextP ctx,
394 struct VADriverContext
399 * The core VA implementation hooks.
401 * This structure is allocated from libva with calloc().
403 struct VADriverVTable *vtable;
406 * The VA/GLX implementation hooks.
408 * This structure is intended for drivers that implement the
409 * VA/GLX API. The driver implementation is responsible for the
410 * allocation and deallocation of this structure.
412 struct VADriverVTableGLX *vtable_glx;
415 * The VA/EGL implementation hooks.
417 * This structure is intended for drivers that implement the
418 * VA/EGL API. The driver implementation is responsible for the
419 * allocation and deallocation of this structure.
421 struct VADriverVTableEGL *vtable_egl;
424 * The third-party/private implementation hooks.
426 * This structure is intended for drivers that implement the
427 * private API. The driver implementation is responsible for the
428 * allocation and deallocation of this structure.
439 int max_image_formats;
440 int max_subpic_formats;
441 int max_display_attributes;
442 const char *str_vendor;
444 void *handle; /* dlopen handle */
449 * This field holds driver specific data for DRM-based
450 * drivers. This structure is allocated from libva with
451 * calloc(). Do not deallocate from within VA driver
454 * All structures shall be derived from struct drm_state. So, for
455 * instance, this field holds a dri_state structure for VA/X11
456 * drivers that use the DRM protocol.
460 void *glx; /* opaque for GLX code */
462 /** \brief VA display type. */
463 unsigned long display_type;
465 unsigned long reserved[44]; /* reserve for future add-ins, decrease the subscript accordingly */
468 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
469 struct VADisplayContext
473 VADisplayContextP pNext;
474 VADriverContextP pDriverContext;
477 VADisplayContextP ctx
481 VADisplayContextP ctx
484 VAStatus (*vaGetDriverName) (
485 VADisplayContextP ctx,
489 void *opaque; /* opaque for display extensions (e.g. GLX) */
492 typedef VAStatus (*VADriverInit) (
493 VADriverContextP driver_context
496 #endif /* _VA_BACKEND_H_ */