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.
27 #include "va_backend.h"
37 #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
38 #define DRIVER_EXTENSION "_drv_video.so"
39 #define DRIVER_INIT_FUNC "__vaDriverInit_0_26"
41 #define CTX(dpy) ((VADriverContextP) dpy );
42 #define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
44 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
45 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
46 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
48 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
50 static VADriverContextP pDriverContexts = NULL;
51 static int va_debug_trace = 0;
53 static Bool vaContextIsValid(VADriverContextP arg_ctx)
55 VADriverContextP ctx = pDriverContexts;
68 VADisplay vaGetDisplay (
69 NativeDisplay native_dpy /* implementation specific */
73 VADriverContextP ctx = pDriverContexts;
82 if (ctx->x11_dpy == (Display *)native_dpy)
84 dpy = (VADisplay) ctx;
92 /* create new entry */
93 ctx = (VADriverContextP) calloc(1, sizeof(struct VADriverContext));
94 ctx->pNext = pDriverContexts;
95 ctx->x11_dpy = (Display *) native_dpy;
96 pDriverContexts = ctx;
97 dpy = (VADisplay) ctx;
103 static void va_errorMessage(const char *msg, ...)
107 fprintf(stderr, "libva error: ");
109 vfprintf(stderr, msg, args);
113 static void va_infoMessage(const char *msg, ...)
117 fprintf(stderr, "libva: ");
119 vfprintf(stderr, msg, args);
123 static Bool va_checkVtable(void *ptr, char *function)
127 va_errorMessage("No valid vtable entry for va%s\n", function);
133 static Bool va_checkMaximum(int value, char *variable)
137 va_errorMessage("Failed to define max_%s in init\n", variable);
143 static Bool va_checkString(const char* value, char *variable)
147 va_errorMessage("Failed to define str_%s in init\n", variable);
153 static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
155 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
163 if (geteuid() == getuid())
165 /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
166 if (getenv("LIBVA_DRIVER_NAME"))
168 /* For easier debugging */
169 *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
170 return VA_STATUS_SUCCESS;
175 result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
178 va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
183 result = direct_capable;
186 va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
191 result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
192 &driver_patch, driver_name);
195 va_errorMessage("VA_DRIGetClientDriverName returned false\n");
200 vaStatus = VA_STATUS_SUCCESS;
201 va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
202 driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
208 static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
210 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
215 if (geteuid() == getuid())
217 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
218 search_path = getenv("LIBVA_DRIVERS_PATH");
221 search_path = getenv("LIBGL_DRIVERS_PATH");
226 search_path = DEFAULT_DRIVER_DIR;
229 search_path = strdup(search_path);
230 driver_dir = strtok_r(search_path, ":", &saveptr);
234 char *driver_path = (char *) malloc( strlen(driver_dir) +
235 strlen(driver_name) +
236 strlen(DRIVER_EXTENSION) + 2 );
237 strcpy( driver_path, driver_dir );
238 strcat( driver_path, "/" );
239 strcat( driver_path, driver_name );
240 strcat( driver_path, DRIVER_EXTENSION );
242 va_infoMessage("Trying to open %s\n", driver_path);
244 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
247 /* Don't give errors for non-existing files */
248 if (0 == access( driver_path, F_OK))
250 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
255 VADriverInit init_func;
256 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
259 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
264 vaStatus = (*init_func)(ctx);
266 if (VA_STATUS_SUCCESS == vaStatus)
268 CHECK_MAXIMUM(vaStatus, ctx, profiles);
269 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
270 CHECK_MAXIMUM(vaStatus, ctx, attributes);
271 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
272 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
273 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
274 CHECK_STRING(vaStatus, ctx, vendor);
275 CHECK_VTABLE(vaStatus, ctx, Terminate);
276 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
277 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
278 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
279 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
280 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
281 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
282 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
283 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
284 CHECK_VTABLE(vaStatus, ctx, CreateContext);
285 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
286 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
287 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
288 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
289 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
290 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
291 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
292 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
293 CHECK_VTABLE(vaStatus, ctx, EndPicture);
294 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
295 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
296 CHECK_VTABLE(vaStatus, ctx, PutSurface);
297 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
298 CHECK_VTABLE(vaStatus, ctx, CreateImage);
299 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
300 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
301 CHECK_VTABLE(vaStatus, ctx, GetImage);
302 CHECK_VTABLE(vaStatus, ctx, PutImage);
303 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
304 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
305 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
306 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
307 CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
308 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
309 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
310 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
311 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
312 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
313 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
314 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
315 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
317 if (VA_STATUS_SUCCESS != vaStatus)
319 va_errorMessage("%s init failed\n", driver_path);
322 if (VA_STATUS_SUCCESS == vaStatus)
324 ctx->handle = handle;
332 driver_dir = strtok_r(NULL, ":", &saveptr);
342 * Returns a short english description of error_status
344 const char *vaErrorStr(VAStatus error_status)
348 case VA_STATUS_SUCCESS:
349 return "success (no error)";
350 case VA_STATUS_ERROR_ALLOCATION_FAILED:
351 return "resource allocation failed";
352 case VA_STATUS_ERROR_INVALID_CONFIG:
353 return "invalid VAConfigID";
354 case VA_STATUS_ERROR_INVALID_CONTEXT:
355 return "invalid VAContextID";
356 case VA_STATUS_ERROR_INVALID_SURFACE:
357 return "invalid VASurfaceID";
358 case VA_STATUS_ERROR_INVALID_BUFFER:
359 return "invalid VABufferID";
360 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
361 return "attribute not supported";
362 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
363 return "list argument exceeds maximum number";
364 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
365 return "the requested VAProfile is not supported";
366 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
367 return "the requested VAEntryPoint is not supported";
368 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
369 return "the requested RT Format is not supported";
370 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
371 return "the requested VABufferType is not supported";
372 case VA_STATUS_ERROR_UNKNOWN:
373 return "unknown libva error";
375 return "unknown libva error / description missing";
378 VAStatus vaInitialize (
380 int *major_version, /* out */
381 int *minor_version /* out */
384 VADriverContextP ctx = CTX(dpy);
385 char *driver_name = NULL;
390 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
392 vaStatus = va_getDriverName(ctx, &driver_name);
393 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
395 if (VA_STATUS_SUCCESS == vaStatus)
397 vaStatus = va_openDriver(ctx, driver_name);
398 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
400 *major_version = ctx->version_major;
401 *minor_version = ctx->version_minor;
413 * After this call, all library internal resources will be cleaned up
415 VAStatus vaTerminate (
419 VAStatus vaStatus = VA_STATUS_SUCCESS;
420 VADriverContextP old_ctx = CTX(dpy);
421 CHECK_CONTEXT(old_ctx);
425 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
426 dlclose(old_ctx->handle);
427 old_ctx->handle = NULL;
430 if (VA_STATUS_SUCCESS == vaStatus)
432 VADriverContextP *ctx = &pDriverContexts;
434 /* Throw away old_ctx */
439 *ctx = old_ctx->pNext;
440 old_ctx->pNext = NULL;
443 ctx = &((*ctx)->pNext);
451 * vaQueryVendorString returns a pointer to a zero-terminated string
452 * describing some aspects of the VA implemenation on a specific
453 * hardware accelerator. The format of the returned string is:
454 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
455 * e.g. for the Intel GMA500 implementation, an example would be:
456 * "IntelGMA500-1.0-0.2-patch3
458 const char *vaQueryVendorString (
462 VADriverContextP ctx = CTX(dpy);
463 if( !vaContextIsValid(ctx) )
468 return ctx->str_vendor;
472 /* Get maximum number of profiles supported by the implementation */
473 int vaMaxNumProfiles (
477 VADriverContextP ctx = CTX(dpy);
478 if( !vaContextIsValid(ctx) )
483 return ctx->max_profiles;
486 /* Get maximum number of entrypoints supported by the implementation */
487 int vaMaxNumEntrypoints (
491 VADriverContextP ctx = CTX(dpy);
492 if( !vaContextIsValid(ctx) )
497 return ctx->max_entrypoints;
501 /* Get maximum number of attributs supported by the implementation */
502 int vaMaxNumConfigAttributes (
506 VADriverContextP ctx = CTX(dpy);
507 if( !vaContextIsValid(ctx) )
512 return ctx->max_attributes;
515 VAStatus vaQueryConfigEntrypoints (
518 VAEntrypoint *entrypoints, /* out */
519 int *num_entrypoints /* out */
522 VADriverContextP ctx = CTX(dpy);
525 TRACE(vaQueryConfigEntrypoints);
526 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
529 VAStatus vaGetConfigAttributes (
532 VAEntrypoint entrypoint,
533 VAConfigAttrib *attrib_list, /* in/out */
537 VADriverContextP ctx = CTX(dpy);
540 TRACE(vaGetConfigAttributes);
541 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
544 VAStatus vaQueryConfigProfiles (
546 VAProfile *profile_list, /* out */
547 int *num_profiles /* out */
550 VADriverContextP ctx = CTX(dpy);
553 TRACE(vaQueryConfigProfiles);
554 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
557 VAStatus vaCreateConfig (
560 VAEntrypoint entrypoint,
561 VAConfigAttrib *attrib_list,
563 VAConfigID *config_id /* out */
566 VADriverContextP ctx = CTX(dpy);
569 TRACE(vaCreateConfig);
570 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
573 VAStatus vaDestroyConfig (
578 VADriverContextP ctx = CTX(dpy);
581 TRACE(vaDestroyConfig);
582 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
585 VAStatus vaQueryConfigAttributes (
587 VAConfigID config_id,
588 VAProfile *profile, /* out */
589 VAEntrypoint *entrypoint, /* out */
590 VAConfigAttrib *attrib_list,/* out */
591 int *num_attribs /* out */
594 VADriverContextP ctx = CTX(dpy);
597 TRACE(vaQueryConfigAttributes);
598 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
601 VAStatus vaCreateSurfaces (
607 VASurfaceID *surfaces /* out */
610 VADriverContextP ctx = CTX(dpy);
613 TRACE(vaCreateSurfaces);
614 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
617 VAStatus vaDestroySurfaces (
619 VASurfaceID *surface_list,
623 VADriverContextP ctx = CTX(dpy);
626 TRACE(vaDestroySurfaces);
627 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
630 VAStatus vaCreateContext (
632 VAConfigID config_id,
636 VASurfaceID *render_targets,
637 int num_render_targets,
638 VAContextID *context /* out */
641 VADriverContextP ctx = CTX(dpy);
644 TRACE(vaCreateContext);
645 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
646 flag, render_targets, num_render_targets, context );
649 VAStatus vaDestroyContext (
654 VADriverContextP ctx = CTX(dpy);
657 TRACE(vaDestroyContext);
658 return ctx->vtable.vaDestroyContext( ctx, context );
661 VAStatus vaCreateBuffer (
663 VAContextID context, /* in */
664 VABufferType type, /* in */
665 unsigned int size, /* in */
666 unsigned int num_elements, /* in */
668 VABufferID *buf_id /* out */
671 VADriverContextP ctx = CTX(dpy);
674 TRACE(vaCreateBuffer);
675 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
678 VAStatus vaBufferSetNumElements (
680 VABufferID buf_id, /* in */
681 unsigned int num_elements /* in */
684 VADriverContextP ctx = CTX(dpy);
687 TRACE(vaBufferSetNumElements);
688 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
692 VAStatus vaMapBuffer (
694 VABufferID buf_id, /* in */
695 void **pbuf /* out */
698 VADriverContextP ctx = CTX(dpy);
702 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
705 VAStatus vaUnmapBuffer (
707 VABufferID buf_id /* in */
710 VADriverContextP ctx = CTX(dpy);
713 TRACE(vaUnmapBuffer);
714 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
717 VAStatus vaDestroyBuffer (
722 VADriverContextP ctx = CTX(dpy);
725 TRACE(vaDestroyBuffer);
726 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
729 VAStatus vaBeginPicture (
732 VASurfaceID render_target
735 VADriverContextP ctx = CTX(dpy);
738 TRACE(vaBeginPicture);
739 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
742 VAStatus vaRenderPicture (
749 VADriverContextP ctx = CTX(dpy);
752 TRACE(vaRenderPicture);
753 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
756 VAStatus vaEndPicture (
761 VADriverContextP ctx = CTX(dpy);
765 return ctx->vtable.vaEndPicture( ctx, context );
768 VAStatus vaSyncSurface (
771 VASurfaceID render_target
774 VADriverContextP ctx = CTX(dpy);
777 TRACE(vaSyncSurface);
778 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
781 VAStatus vaQuerySurfaceStatus (
783 VASurfaceID render_target,
784 VASurfaceStatus *status /* out */
787 VADriverContextP ctx = CTX(dpy);
790 TRACE(vaQuerySurfaceStatus);
791 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
794 VAStatus vaPutSurface (
797 Drawable draw, /* X Drawable */
804 unsigned short destw,
805 unsigned short desth,
806 VARectangle *cliprects, /* client supplied clip list */
807 unsigned int number_cliprects, /* number of clip rects in the clip list */
808 unsigned int flags /* de-interlacing flags */
811 VADriverContextP ctx = CTX(dpy);
815 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
816 destx, desty, destw, desth,
817 cliprects, number_cliprects, flags );
820 /* Get maximum number of image formats supported by the implementation */
821 int vaMaxNumImageFormats (
825 VADriverContextP ctx = CTX(dpy);
826 if( !vaContextIsValid(ctx) )
831 return ctx->max_image_formats;
834 VAStatus vaQueryImageFormats (
836 VAImageFormat *format_list, /* out */
837 int *num_formats /* out */
840 VADriverContextP ctx = CTX(dpy);
843 TRACE(vaQueryImageFormats);
844 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
848 * The width and height fields returned in the VAImage structure may get
849 * enlarged for some YUV formats. The size of the data buffer that needs
850 * to be allocated will be given in the "data_size" field in VAImage.
851 * Image data is not allocated by this function. The client should
852 * allocate the memory and fill in the VAImage structure's data field
853 * after looking at "data_size" returned from the library.
855 VAStatus vaCreateImage (
857 VAImageFormat *format,
860 VAImage *image /* out */
863 VADriverContextP ctx = CTX(dpy);
866 TRACE(vaCreateImage);
867 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
871 * Should call DestroyImage before destroying the surface it is bound to
873 VAStatus vaDestroyImage (
878 VADriverContextP ctx = CTX(dpy);
881 TRACE(vaDestroyImage);
882 return ctx->vtable.vaDestroyImage ( ctx, image);
885 VAStatus vaSetImagePalette (
888 unsigned char *palette
891 VADriverContextP ctx = CTX(dpy);
894 TRACE(vaSetImagePalette);
895 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
899 * Retrieve surface data into a VAImage
900 * Image must be in a format supported by the implementation
902 VAStatus vaGetImage (
905 int x, /* coordinates of the upper left source pixel */
907 unsigned int width, /* width and height of the region */
912 VADriverContextP ctx = CTX(dpy);
916 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
920 * Copy data from a VAImage to a surface
921 * Image must be in a format supported by the implementation
923 VAStatus vaPutImage (
935 VADriverContextP ctx = CTX(dpy);
939 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
942 /* Get maximum number of subpicture formats supported by the implementation */
943 int vaMaxNumSubpictureFormats (
947 VADriverContextP ctx = CTX(dpy);
948 if( !vaContextIsValid(ctx) )
953 return ctx->max_subpic_formats;
957 * Query supported subpicture formats
958 * The caller must provide a "format_list" array that can hold at
959 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
960 * for each format to indicate additional capabilities for that format. The actual
961 * number of formats returned in "format_list" is returned in "num_formats".
963 VAStatus vaQuerySubpictureFormats (
965 VAImageFormat *format_list, /* out */
966 unsigned int *flags, /* out */
967 unsigned int *num_formats /* out */
970 VADriverContextP ctx = CTX(dpy);
973 TRACE(vaQuerySubpictureFormats);
974 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
978 * Subpictures are created with an image associated.
980 VAStatus vaCreateSubpicture (
983 VASubpictureID *subpicture /* out */
986 VADriverContextP ctx = CTX(dpy);
989 TRACE(vaCreateSubpicture);
990 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
994 * Destroy the subpicture before destroying the image it is assocated to
996 VAStatus vaDestroySubpicture (
998 VASubpictureID subpicture
1001 VADriverContextP ctx = CTX(dpy);
1004 TRACE(vaDestroySubpicture);
1005 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1008 VAStatus vaSetSubpictureImage (
1010 VASubpictureID subpicture,
1014 VADriverContextP ctx = CTX(dpy);
1017 TRACE(vaSetSubpictureImage);
1018 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1022 VAStatus vaSetSubpicturePalette (
1024 VASubpictureID subpicture,
1026 * pointer to an array holding the palette data. The size of the array is
1027 * num_palette_entries * entry_bytes in size. The order of the components
1028 * in the palette is described by the component_order in VASubpicture struct
1030 unsigned char *palette
1033 VADriverContextP ctx = CTX(dpy);
1036 TRACE(vaSetSubpicturePalette);
1037 return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
1041 * If chromakey is enabled, then the area where the source value falls within
1042 * the chromakey [min, max] range is transparent
1044 VAStatus vaSetSubpictureChromakey (
1046 VASubpictureID subpicture,
1047 unsigned int chromakey_min,
1048 unsigned int chromakey_max,
1049 unsigned int chromakey_mask
1052 VADriverContextP ctx = CTX(dpy);
1055 TRACE(vaSetSubpictureChromakey);
1056 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1061 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1062 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1063 * the overall alpha is per-pixel alpha multiplied by the global alpha
1065 VAStatus vaSetSubpictureGlobalAlpha (
1067 VASubpictureID subpicture,
1071 VADriverContextP ctx = CTX(dpy);
1074 TRACE(vaSetSubpictureGlobalAlpha);
1075 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1079 vaAssociateSubpicture associates the subpicture with the target_surface.
1080 It defines the region mapping between the subpicture and the target
1081 surface through source and destination rectangles (with the same width and height).
1082 Both will be displayed at the next call to vaPutSurface. Additional
1083 associations before the call to vaPutSurface simply overrides the association.
1085 VAStatus vaAssociateSubpicture (
1087 VASubpictureID subpicture,
1088 VASurfaceID *target_surfaces,
1090 short src_x, /* upper left offset in subpicture */
1092 short dest_x, /* upper left offset in surface */
1094 unsigned short width,
1095 unsigned short height,
1097 * whether to enable chroma-keying or global-alpha
1098 * see VA_SUBPICTURE_XXX values
1103 VADriverContextP ctx = CTX(dpy);
1106 TRACE(vaAssociateSubpicture);
1107 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1111 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1113 VAStatus vaDeassociateSubpicture (
1115 VASubpictureID subpicture,
1116 VASurfaceID *target_surfaces,
1120 VADriverContextP ctx = CTX(dpy);
1123 TRACE(vaDeassociateSubpicture);
1124 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1128 /* Get maximum number of display attributes supported by the implementation */
1129 int vaMaxNumDisplayAttributes (
1133 VADriverContextP ctx = CTX(dpy);
1134 if( !vaContextIsValid(ctx) )
1139 return ctx->max_display_attributes;
1143 * Query display attributes
1144 * The caller must provide a "attr_list" array that can hold at
1145 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1146 * returned in "attr_list" is returned in "num_attributes".
1148 VAStatus vaQueryDisplayAttributes (
1150 VADisplayAttribute *attr_list, /* out */
1151 int *num_attributes /* out */
1154 VADriverContextP ctx = CTX(dpy);
1157 TRACE(vaQueryDisplayAttributes);
1158 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1162 * Get display attributes
1163 * This function returns the current attribute values in "attr_list".
1164 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1165 * from vaQueryDisplayAttributes() can have their values retrieved.
1167 VAStatus vaGetDisplayAttributes (
1169 VADisplayAttribute *attr_list, /* in/out */
1173 VADriverContextP ctx = CTX(dpy);
1176 TRACE(vaGetDisplayAttributes);
1177 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1181 * Set display attributes
1182 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1183 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1184 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1186 VAStatus vaSetDisplayAttributes (
1188 VADisplayAttribute *attr_list,
1192 VADriverContextP ctx = CTX(dpy);
1195 TRACE(vaSetDisplayAttributes);
1196 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1201 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1202 VASurfaceID surface,
1203 void **buffer, /* out */
1204 unsigned int *stride /* out */
1207 VADriverContextP ctx = CTX(dpy);
1210 TRACE(vaDbgCopySurfaceToBuffer);
1211 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );