1/*
2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
3 *
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:
11 *
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.
15 *
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.
23 */
24
25/*
26 * Video Decode Acceleration -Backend API
27 */
28
29#ifndef _VA_BACKEND_H_
30#define _VA_BACKEND_H_
31
32#include <va/va.h>
33
34typedef struct VADriverContext *VADriverContextP;
35typedef struct VADisplayContext *VADisplayContextP;
36
37/** \brief VA display types. */
38enum {
39 /** \brief Mask to major identifier for VA display type. */
40 VA_DISPLAY_MAJOR_MASK = 0xf0,
41
42 /** \brief VA/X11 API is used, through vaGetDisplay() entry-point. */
43 VA_DISPLAY_X11 = 0x10,
44 /** \brief VA/GLX API is used, through vaGetDisplayGLX() entry-point. */
45 VA_DISPLAY_GLX = (VA_DISPLAY_X11 | (1 << 0)),
46 /** \brief VA/Android API is used, through vaGetDisplay() entry-point. */
47 VA_DISPLAY_ANDROID = 0x20,
48 /** \brief VA/DRM API is used, through vaGetDisplayDRM() entry-point. */
49 VA_DISPLAY_DRM = 0x30,
50 /** \brief VA/DRM API is used, with a render-node device path */
51 VA_DISPLAY_DRM_RENDERNODES = (VA_DISPLAY_DRM | (1 << 0)),
52 /** \brief VA/Wayland API is used, through vaGetDisplayWl() entry-point. */
53 VA_DISPLAY_WAYLAND = 0x40,
54};
55
56struct VADriverVTable {
57 VAStatus(*vaTerminate)(VADriverContextP ctx);
58
59 VAStatus(*vaQueryConfigProfiles)(
60 VADriverContextP ctx,
61 VAProfile *profile_list, /* out */
62 int *num_profiles /* out */
63 );
64
65 VAStatus(*vaQueryConfigEntrypoints)(
66 VADriverContextP ctx,
67 VAProfile profile,
68 VAEntrypoint *entrypoint_list, /* out */
69 int *num_entrypoints /* out */
70 );
71
72 VAStatus(*vaGetConfigAttributes)(
73 VADriverContextP ctx,
74 VAProfile profile,
75 VAEntrypoint entrypoint,
76 VAConfigAttrib *attrib_list, /* in/out */
77 int num_attribs
78 );
79
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 */
87 );
88
89 VAStatus(*vaDestroyConfig)(
90 VADriverContextP ctx,
91 VAConfigID config_id
92 );
93
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 */
101 );
102
103 VAStatus(*vaCreateSurfaces)(
104 VADriverContextP ctx,
105 int width,
106 int height,
107 int format,
108 int num_surfaces,
109 VASurfaceID *surfaces /* out */
110 );
111
112 VAStatus(*vaDestroySurfaces)(
113 VADriverContextP ctx,
114 VASurfaceID *surface_list,
115 int num_surfaces
116 );
117
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 */
127 );
128
129 VAStatus(*vaDestroyContext)(
130 VADriverContextP ctx,
131 VAContextID context
132 );
133
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
142 );
143
144 VAStatus(*vaBufferSetNumElements)(
145 VADriverContextP ctx,
146 VABufferID buf_id, /* in */
147 unsigned int num_elements /* in */
148 );
149
150 VAStatus(*vaMapBuffer)(
151 VADriverContextP ctx,
152 VABufferID buf_id, /* in */
153 void **pbuf /* out */
154 );
155
156 VAStatus(*vaUnmapBuffer)(
157 VADriverContextP ctx,
158 VABufferID buf_id /* in */
159 );
160
161 VAStatus(*vaDestroyBuffer)(
162 VADriverContextP ctx,
163 VABufferID buffer_id
164 );
165
166 VAStatus(*vaBeginPicture)(
167 VADriverContextP ctx,
168 VAContextID context,
169 VASurfaceID render_target
170 );
171
172 VAStatus(*vaRenderPicture)(
173 VADriverContextP ctx,
174 VAContextID context,
175 VABufferID *buffers,
176 int num_buffers
177 );
178
179 VAStatus(*vaEndPicture)(
180 VADriverContextP ctx,
181 VAContextID context
182 );
183
184 VAStatus(*vaSyncSurface)(
185 VADriverContextP ctx,
186 VASurfaceID render_target
187 );
188
189 VAStatus(*vaQuerySurfaceStatus)(
190 VADriverContextP ctx,
191 VASurfaceID render_target,
192 VASurfaceStatus *status /* out */
193 );
194
195 VAStatus(*vaQuerySurfaceError)(
196 VADriverContextP ctx,
197 VASurfaceID render_target,
198 VAStatus error_status,
199 void **error_info /*out*/
200 );
201
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 */
217 );
218
219 VAStatus(*vaQueryImageFormats)(
220 VADriverContextP ctx,
221 VAImageFormat *format_list, /* out */
222 int *num_formats /* out */
223 );
224
225 VAStatus(*vaCreateImage)(
226 VADriverContextP ctx,
227 VAImageFormat *format,
228 int width,
229 int height,
230 VAImage *image /* out */
231 );
232
233 VAStatus(*vaDeriveImage)(
234 VADriverContextP ctx,
235 VASurfaceID surface,
236 VAImage *image /* out */
237 );
238
239 VAStatus(*vaDestroyImage)(
240 VADriverContextP ctx,
241 VAImageID image
242 );
243
244 VAStatus(*vaSetImagePalette)(
245 VADriverContextP ctx,
246 VAImageID image,
247 /*
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
251 */
252 unsigned char *palette
253 );
254
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
263 );
264
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
277 );
278
279 VAStatus(*vaQuerySubpictureFormats)(
280 VADriverContextP ctx,
281 VAImageFormat *format_list, /* out */
282 unsigned int *flags, /* out */
283 unsigned int *num_formats /* out */
284 );
285
286 VAStatus(*vaCreateSubpicture)(
287 VADriverContextP ctx,
288 VAImageID image,
289 VASubpictureID *subpicture /* out */
290 );
291
292 VAStatus(*vaDestroySubpicture)(
293 VADriverContextP ctx,
294 VASubpictureID subpicture
295 );
296
297 VAStatus(*vaSetSubpictureImage)(
298 VADriverContextP ctx,
299 VASubpictureID subpicture,
300 VAImageID image
301 );
302
303 VAStatus(*vaSetSubpictureChromakey)(
304 VADriverContextP ctx,
305 VASubpictureID subpicture,
306 unsigned int chromakey_min,
307 unsigned int chromakey_max,
308 unsigned int chromakey_mask
309 );
310
311 VAStatus(*vaSetSubpictureGlobalAlpha)(
312 VADriverContextP ctx,
313 VASubpictureID subpicture,
314 float global_alpha
315 );
316
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,
330 /*
331 * whether to enable chroma-keying or global-alpha
332 * see VA_SUBPICTURE_XXX values
333 */
334 unsigned int flags
335 );
336
337 VAStatus(*vaDeassociateSubpicture)(
338 VADriverContextP ctx,
339 VASubpictureID subpicture,
340 VASurfaceID *target_surfaces,
341 int num_surfaces
342 );
343
344 VAStatus(*vaQueryDisplayAttributes)(
345 VADriverContextP ctx,
346 VADisplayAttribute *attr_list, /* out */
347 int *num_attributes /* out */
348 );
349
350 VAStatus(*vaGetDisplayAttributes)(
351 VADriverContextP ctx,
352 VADisplayAttribute *attr_list, /* in/out */
353 int num_attributes
354 );
355
356 VAStatus(*vaSetDisplayAttributes)(
357 VADriverContextP ctx,
358 VADisplayAttribute *attr_list,
359 int num_attributes
360 );
361
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 */
369 );
370
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
384 */
385 void **buffer /* if it is not NULL, map the surface buffer for
386 * CPU access
387 */
388 );
389
390 VAStatus(*vaUnlockSurface)(
391 VADriverContextP ctx,
392 VASurfaceID surface
393 );
394
395 /* DEPRECATED */
396 VAStatus
397 (*vaGetSurfaceAttributes)(
398 VADriverContextP dpy,
399 VAConfigID config,
400 VASurfaceAttrib *attrib_list,
401 unsigned int num_attribs
402 );
403
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
414 );
415
416 VAStatus
417 (*vaQuerySurfaceAttributes)(
418 VADriverContextP dpy,
419 VAConfigID config,
420 VASurfaceAttrib *attrib_list,
421 unsigned int *num_attribs
422 );
423
424 VAStatus
425 (*vaAcquireBufferHandle)(
426 VADriverContextP ctx,
427 VABufferID buf_id, /* in */
428 VABufferInfo * buf_info /* in/out */
429 );
430
431 VAStatus
432 (*vaReleaseBufferHandle)(
433 VADriverContextP ctx,
434 VABufferID buf_id /* in */
435 );
436
437 VAStatus(*vaCreateMFContext)(
438 VADriverContextP ctx,
439 VAMFContextID *mfe_context /* out */
440 );
441
442 VAStatus(*vaMFAddContext)(
443 VADriverContextP ctx,
444 VAMFContextID mf_context,
445 VAContextID context
446 );
447
448 VAStatus(*vaMFReleaseContext)(
449 VADriverContextP ctx,
450 VAMFContextID mf_context,
451 VAContextID context
452 );
453
454 VAStatus(*vaMFSubmit)(
455 VADriverContextP ctx,
456 VAMFContextID mf_context,
457 VAContextID *contexts,
458 int num_contexts
459 );
460 VAStatus(*vaCreateBuffer2)(
461 VADriverContextP ctx,
462 VAContextID context, /* in */
463 VABufferType type, /* in */
464 unsigned int width, /* in */
465 unsigned int height, /* in */
466 unsigned int *unit_size, /* out */
467 unsigned int *pitch, /* out */
468 VABufferID *buf_id /* out */
469 );
470
471 VAStatus(*vaQueryProcessingRate)(
472 VADriverContextP ctx, /* in */
473 VAConfigID config_id, /* in */
474 VAProcessingRateParameter *proc_buf,/* in */
475 unsigned int *processing_rate /* out */
476 );
477
478 VAStatus
479 (*vaExportSurfaceHandle)(
480 VADriverContextP ctx,
481 VASurfaceID surface_id, /* in */
482 uint32_t mem_type, /* in */
483 uint32_t flags, /* in */
484 void *descriptor /* out */
485 );
486 VAStatus(*vaSyncSurface2)(
487 VADriverContextP ctx,
488 VASurfaceID surface,
489 uint64_t timeout_ns
490 );
491
492 VAStatus(*vaSyncBuffer)(
493 VADriverContextP ctx,
494 VABufferID buf_id,
495 uint64_t timeout_ns
496 );
497
498 VAStatus
499 (*vaCopy)(
500 VADriverContextP ctx, /* in */
501 VACopyObject *dst, /* in */
502 VACopyObject *src, /* in */
503 VACopyOption option /* in */
504 );
505 /** \brief Reserved bytes for future use, must be zero */
506 unsigned long reserved[54];
507};
508
509struct VADriverContext {
510 void *pDriverData;
511
512 /**
513 * The core VA implementation hooks.
514 *
515 * This structure is allocated from libva with calloc().
516 */
517 struct VADriverVTable *vtable;
518
519 /**
520 * The VA/GLX implementation hooks.
521 *
522 * This structure is intended for drivers that implement the
523 * VA/GLX API. The driver implementation is responsible for the
524 * allocation and deallocation of this structure.
525 */
526 struct VADriverVTableGLX *vtable_glx;
527
528 /**
529 * The VA/EGL implementation hooks.
530 *
531 * This structure is intended for drivers that implement the
532 * VA/EGL API. The driver implementation is responsible for the
533 * allocation and deallocation of this structure.
534 */
535 struct VADriverVTableEGL *vtable_egl;
536
537 /**
538 * The third-party/private implementation hooks.
539 *
540 * This structure is intended for drivers that implement the
541 * private API. The driver implementation is responsible for the
542 * allocation and deallocation of this structure.
543 */
544 void *vtable_tpi;
545
546 void *native_dpy;
547 int x11_screen;
548 int version_major;
549 int version_minor;
550 int max_profiles;
551 int max_entrypoints;
552 int max_attributes;
553 int max_image_formats;
554 int max_subpic_formats;
555 int max_display_attributes;
556 const char *str_vendor;
557
558 void *handle; /* dlopen handle */
559
560 /**
561 * \brief DRM state.
562 *
563 * This field holds driver specific data for DRM-based
564 * drivers. This structure is allocated from libva with
565 * calloc(). Do not deallocate from within VA driver
566 * implementations.
567 *
568 * All structures shall be derived from struct drm_state. So, for
569 * instance, this field holds a dri_state structure for VA/X11
570 * drivers that use the DRM protocol.
571 */
572 void *drm_state;
573
574 void *glx; /* opaque for GLX code */
575
576 /** \brief VA display type. */
577 unsigned long display_type;
578
579 /**
580 * The VA/Wayland implementation hooks.
581 *
582 * This structure is intended for drivers that implement the
583 * VA/Wayland API. libVA allocates this structure with calloc()
584 * and owns the resulting memory.
585 */
586 struct VADriverVTableWayland *vtable_wayland;
587
588 /**
589 * \brief The VA/VPP implementation hooks.
590 *
591 * This structure is allocated from libva with calloc().
592 */
593 struct VADriverVTableVPP *vtable_vpp;
594
595 char *override_driver_name;
596
597 void *pDisplayContext;
598
599 /**
600 * Error callback.
601 *
602 * This is set by libva when the driver is opened, and will not be
603 * changed thereafter. The driver can call it with an error message,
604 * which will be propagated to the API user through their error
605 * callbacks, or sent to a default output if no callback is available.
606 *
607 * It is expected that end users will always be able to see these
608 * messages, so it should be called only for serious errors. For
609 * example, hardware problems or fatal configuration errors.
610 *
611 * @param pDriverContext Pointer to the driver context structure
612 * being used by the current driver.
613 * @param message Message to send to the API user. This must be a
614 * null-terminated string.
615 */
616 void (*error_callback)(VADriverContextP pDriverContext,
617 const char *message);
618 /**
619 * Info callback.
620 *
621 * This has the same behaviour as the error callback, but has its
622 * own set of callbacks to the API user.
623 *
624 * It should be used for informational messages which may be useful
625 * for an application programmer or for debugging. For example, minor
626 * configuration errors, or information about the reason when another
627 * API call generates an error return. It is not expected that end
628 * users will see these messages.
629 *
630 * @param pDriverContext Pointer to the driver context structure
631 * being used by the current driver.
632 * @param message Message to send to the API user. This must be a
633 * null-terminated string.
634 */
635 void (*info_callback)(VADriverContextP pDriverContext,
636 const char *message);
637
638 /**
639 * \brief The VA/Protected implementation hooks.
640 *
641 * This structure is allocated from libva with calloc().
642 */
643 struct VADriverVTableProt *vtable_prot;
644
645 unsigned long reserved[37]; /* reserve for future add-ins, decrease the subscript accordingly */
646};
647
648#define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */
649struct VADisplayContext {
650 int vadpy_magic;
651
652 VADisplayContextP pNext;
653 VADriverContextP pDriverContext;
654
655 int (*vaIsValid)(
656 VADisplayContextP ctx
657 );
658
659 void (*vaDestroy)(
660 VADisplayContextP ctx
661 );
662
663 VAStatus(*vaGetDriverName)(
664 VADisplayContextP ctx,
665 char **driver_name
666 );
667
668 void *opaque; /* opaque for display extensions (e.g. GLX) */
669 void *vatrace; /* opaque for VA trace context */
670 void *vafool; /* opaque for VA fool context */
671
672 VAMessageCallback error_callback;
673 void *error_callback_user_context;
674 VAMessageCallback info_callback;
675 void *info_callback_user_context;
676 VAStatus(*vaGetNumCandidates)(
677 VADisplayContextP ctx,
678 int * num_candidates
679 );
680
681 VAStatus(*vaGetDriverNameByIndex)(
682 VADisplayContextP ctx,
683 char **driver_name,
684 int candidate_index
685 );
686
687 /** \brief Reserved bytes for future use, must be zero */
688 unsigned long reserved[30];
689};
690
691typedef VAStatus(*VADriverInit)(
692 VADriverContextP driver_context
693);
694
695#endif /* _VA_BACKEND_H_ */
696

source code of include/va/va_backend.h