Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / libva / va / va_backend.h
blobbd828497dd9f6e40af90d5a79e746589e032b2eb
1 /*
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
14 * of the Software.
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_
32 #include <va/va.h>
33 #include <linux/videodev2.h>
35 typedef struct VADriverContext *VADriverContextP;
36 typedef struct VADisplayContext *VADisplayContextP;
38 /** \brief VA display types. */
39 enum {
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,
55 struct VADriverVTable
57 VAStatus (*vaTerminate) ( VADriverContextP ctx );
59 VAStatus (*vaQueryConfigProfiles) (
60 VADriverContextP ctx,
61 VAProfile *profile_list, /* out */
62 int *num_profiles /* out */
65 VAStatus (*vaQueryConfigEntrypoints) (
66 VADriverContextP ctx,
67 VAProfile profile,
68 VAEntrypoint *entrypoint_list, /* out */
69 int *num_entrypoints /* out */
72 VAStatus (*vaGetConfigAttributes) (
73 VADriverContextP ctx,
74 VAProfile profile,
75 VAEntrypoint entrypoint,
76 VAConfigAttrib *attrib_list, /* in/out */
77 int num_attribs
80 VAStatus (*vaCreateConfig) (
81 VADriverContextP ctx,
82 VAProfile profile,
83 VAEntrypoint entrypoint,
84 VAConfigAttrib *attrib_list,
85 int num_attribs,
86 VAConfigID *config_id /* out */
89 VAStatus (*vaDestroyConfig) (
90 VADriverContextP ctx,
91 VAConfigID config_id
94 VAStatus (*vaQueryConfigAttributes) (
95 VADriverContextP ctx,
96 VAConfigID config_id,
97 VAProfile *profile, /* out */
98 VAEntrypoint *entrypoint, /* out */
99 VAConfigAttrib *attrib_list, /* out */
100 int *num_attribs /* out */
103 VAStatus (*vaCreateSurfaces) (
104 VADriverContextP ctx,
105 int width,
106 int height,
107 int format,
108 int num_surfaces,
109 VASurfaceID *surfaces /* out */
112 VAStatus (*vaDestroySurfaces) (
113 VADriverContextP ctx,
114 VASurfaceID *surface_list,
115 int num_surfaces
118 VAStatus (*vaCreateContext) (
119 VADriverContextP ctx,
120 VAConfigID config_id,
121 int picture_width,
122 int picture_height,
123 int flag,
124 VASurfaceID *render_targets,
125 int num_render_targets,
126 VAContextID *context /* out */
129 VAStatus (*vaDestroyContext) (
130 VADriverContextP ctx,
131 VAContextID context
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 */
140 void *data, /* 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,
163 VABufferID buffer_id
166 VAStatus (*vaBeginPicture) (
167 VADriverContextP ctx,
168 VAContextID context,
169 VASurfaceID render_target
172 VAStatus (*vaRenderPicture) (
173 VADriverContextP ctx,
174 VAContextID context,
175 VABufferID *buffers,
176 int num_buffers
179 VAStatus (*vaEndPicture) (
180 VADriverContextP ctx,
181 VAContextID context
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,
204 VASurfaceID surface,
205 void* draw, /* Drawable of window system */
206 short srcx,
207 short srcy,
208 unsigned short srcw,
209 unsigned short srch,
210 short destx,
211 short desty,
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,
228 int width,
229 int height,
230 VAImage *image /* out */
233 VAStatus (*vaDeriveImage) (
234 VADriverContextP ctx,
235 VASurfaceID surface,
236 VAImage *image /* out */
239 VAStatus (*vaDestroyImage) (
240 VADriverContextP ctx,
241 VAImageID image
244 VAStatus (*vaSetImagePalette) (
245 VADriverContextP ctx,
246 VAImageID image,
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,
257 VASurfaceID surface,
258 int x, /* coordinates of the upper left source pixel */
259 int y,
260 unsigned int width, /* width and height of the region */
261 unsigned int height,
262 VAImageID image
265 VAStatus (*vaPutImage) (
266 VADriverContextP ctx,
267 VASurfaceID surface,
268 VAImageID image,
269 int src_x,
270 int src_y,
271 unsigned int src_width,
272 unsigned int src_height,
273 int dest_x,
274 int dest_y,
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,
288 VAImageID image,
289 VASubpictureID *subpicture /* out */
292 VAStatus (*vaDestroySubpicture) (
293 VADriverContextP ctx,
294 VASubpictureID subpicture
297 VAStatus (*vaSetSubpictureImage) (
298 VADriverContextP ctx,
299 VASubpictureID subpicture,
300 VAImageID image
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,
314 float global_alpha
317 VAStatus (*vaAssociateSubpicture) (
318 VADriverContextP ctx,
319 VASubpictureID subpicture,
320 VASurfaceID *target_surfaces,
321 int num_surfaces,
322 short src_x, /* upper left offset in subpicture */
323 short src_y,
324 unsigned short src_width,
325 unsigned short src_height,
326 short dest_x, /* upper left offset in surface */
327 short dest_y,
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
334 unsigned int flags
337 VAStatus (*vaDeassociateSubpicture) (
338 VADriverContextP ctx,
339 VASubpictureID subpicture,
340 VASurfaceID *target_surfaces,
341 int num_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 */
353 int num_attributes
356 VAStatus (*vaSetDisplayAttributes) (
357 VADriverContextP ctx,
358 VADisplayAttribute *attr_list,
359 int num_attributes
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,
374 VASurfaceID surface,
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
386 * CPU access
390 VAStatus (*vaUnlockSurface) (
391 VADriverContextP ctx,
392 VASurfaceID surface
395 /* DEPRECATED */
396 VAStatus
397 (*vaGetSurfaceAttributes)(
398 VADriverContextP dpy,
399 VAConfigID config,
400 VASurfaceAttrib *attrib_list,
401 unsigned int num_attribs
404 VAStatus
405 (*vaCreateSurfaces2)(
406 VADriverContextP ctx,
407 unsigned int format,
408 unsigned int width,
409 unsigned int height,
410 VASurfaceID *surfaces,
411 unsigned int num_surfaces,
412 VASurfaceAttrib *attrib_list,
413 unsigned int num_attribs
416 VAStatus
417 (*vaQuerySurfaceAttributes)(
418 VADriverContextP dpy,
419 VAConfigID config,
420 VASurfaceAttrib *attrib_list,
421 unsigned int *num_attribs
425 struct VADriverContext
427 void *pDriverData;
430 * The core VA implementation hooks.
432 * This structure is allocated from libva with calloc().
434 struct VADriverVTable *vtable;
437 * The VA/GLX implementation hooks.
439 * This structure is intended for drivers that implement the
440 * VA/GLX API. The driver implementation is responsible for the
441 * allocation and deallocation of this structure.
443 struct VADriverVTableGLX *vtable_glx;
446 * The VA/EGL implementation hooks.
448 * This structure is intended for drivers that implement the
449 * VA/EGL API. The driver implementation is responsible for the
450 * allocation and deallocation of this structure.
452 struct VADriverVTableEGL *vtable_egl;
455 * The third-party/private implementation hooks.
457 * This structure is intended for drivers that implement the
458 * private API. The driver implementation is responsible for the
459 * allocation and deallocation of this structure.
461 void *vtable_tpi;
463 void *native_dpy;
464 int x11_screen;
465 int version_major;
466 int version_minor;
467 int max_profiles;
468 int max_entrypoints;
469 int max_attributes;
470 int max_image_formats;
471 int max_subpic_formats;
472 int max_display_attributes;
473 const char *str_vendor;
475 void *handle; /* dlopen handle */
478 * \brief DRM state.
480 * This field holds driver specific data for DRM-based
481 * drivers. This structure is allocated from libva with
482 * calloc(). Do not deallocate from within VA driver
483 * implementations.
485 * All structures shall be derived from struct drm_state. So, for
486 * instance, this field holds a dri_state structure for VA/X11
487 * drivers that use the DRM protocol.
489 void *drm_state;
491 void *glx; /* opaque for GLX code */
493 /** \brief VA display type. */
494 unsigned long display_type;
497 * The VA/Wayland implementation hooks.
499 * This structure is intended for drivers that implement the
500 * VA/Wayland API. libVA allocates this structure with calloc()
501 * and owns the resulting memory.
503 struct VADriverVTableWayland *vtable_wayland;
506 * \brief The VA/VPP implementation hooks.
508 * This structure is allocated from libva with calloc().
510 struct VADriverVTableVPP *vtable_vpp;
512 unsigned long reserved[42]; /* reserve for future add-ins, decrease the subscript accordingly */
515 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
516 struct VADisplayContext
518 int vadpy_magic;
520 VADisplayContextP pNext;
521 VADriverContextP pDriverContext;
523 int (*vaIsValid) (
524 VADisplayContextP ctx
527 void (*vaDestroy) (
528 VADisplayContextP ctx
531 VAStatus (*vaGetDriverName) (
532 VADisplayContextP ctx,
533 char **driver_name
536 void *opaque; /* opaque for display extensions (e.g. GLX) */
537 void *vatrace; /* opaque for VA trace context */
538 void *vafool; /* opaque for VA fool context */
541 typedef VAStatus (*VADriverInit) (
542 VADriverContextP driver_context
545 #endif /* _VA_BACKEND_H_ */