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;
77 if (ctx->x11_dpy == (Display *)native_dpy)
79 dpy = (VADisplay) ctx;
87 /* create new entry */
88 ctx = (VADriverContextP) calloc(1, sizeof(struct VADriverContext));
89 ctx->pNext = pDriverContexts;
90 ctx->x11_dpy = (Display *) native_dpy;
91 pDriverContexts = ctx;
92 dpy = (VADisplay) ctx;
98 static void va_errorMessage(const char *msg, ...)
102 fprintf(stderr, "libva error: ");
104 vfprintf(stderr, msg, args);
108 static void va_infoMessage(const char *msg, ...)
112 fprintf(stderr, "libva: ");
114 vfprintf(stderr, msg, args);
118 static Bool va_checkVtable(void *ptr, char *function)
122 va_errorMessage("No valid vtable entry for va%s\n", function);
128 static Bool va_checkMaximum(int value, char *variable)
132 va_errorMessage("Failed to define max_%s in init\n", variable);
138 static Bool va_checkString(const char* value, char *variable)
142 va_errorMessage("Failed to define str_%s in init\n", variable);
148 static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
150 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
158 if (geteuid() == getuid())
160 /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
161 if (getenv("LIBVA_DRIVER_NAME"))
163 /* For easier debugging */
164 *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
165 return VA_STATUS_SUCCESS;
170 result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
173 va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
178 result = direct_capable;
181 va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
186 result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
187 &driver_patch, driver_name);
190 va_errorMessage("VA_DRIGetClientDriverName returned false\n");
195 vaStatus = VA_STATUS_SUCCESS;
196 va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
197 driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
203 static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
205 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
210 if (geteuid() == getuid())
212 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
213 search_path = getenv("LIBVA_DRIVERS_PATH");
216 search_path = getenv("LIBGL_DRIVERS_PATH");
221 search_path = DEFAULT_DRIVER_DIR;
224 search_path = strdup(search_path);
225 driver_dir = strtok_r(search_path, ":", &saveptr);
229 char *driver_path = (char *) malloc( strlen(driver_dir) +
230 strlen(driver_name) +
231 strlen(DRIVER_EXTENSION) + 2 );
232 strcpy( driver_path, driver_dir );
233 strcat( driver_path, "/" );
234 strcat( driver_path, driver_name );
235 strcat( driver_path, DRIVER_EXTENSION );
237 va_infoMessage("Trying to open %s\n", driver_path);
239 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
242 /* Don't give errors for non-existing files */
243 if (0 == access( driver_path, F_OK))
245 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
250 VADriverInit init_func;
251 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
254 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
259 vaStatus = (*init_func)(ctx);
261 if (VA_STATUS_SUCCESS == vaStatus)
263 CHECK_MAXIMUM(vaStatus, ctx, profiles);
264 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
265 CHECK_MAXIMUM(vaStatus, ctx, attributes);
266 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
267 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
268 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
269 CHECK_STRING(vaStatus, ctx, vendor);
270 CHECK_VTABLE(vaStatus, ctx, Terminate);
271 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
272 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
273 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
274 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
275 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
276 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
277 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
278 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
279 CHECK_VTABLE(vaStatus, ctx, CreateContext);
280 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
281 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
282 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
283 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
284 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
285 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
286 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
287 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
288 CHECK_VTABLE(vaStatus, ctx, EndPicture);
289 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
290 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
291 CHECK_VTABLE(vaStatus, ctx, PutSurface);
292 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
293 CHECK_VTABLE(vaStatus, ctx, CreateImage);
294 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
295 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
296 CHECK_VTABLE(vaStatus, ctx, GetImage);
297 CHECK_VTABLE(vaStatus, ctx, PutImage);
298 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
299 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
300 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
301 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
302 CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
303 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
304 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
305 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
306 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
307 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
308 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
309 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
310 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
312 if (VA_STATUS_SUCCESS != vaStatus)
314 va_errorMessage("%s init failed\n", driver_path);
317 if (VA_STATUS_SUCCESS == vaStatus)
319 ctx->handle = handle;
327 driver_dir = strtok_r(NULL, ":", &saveptr);
337 * Returns a short english description of error_status
339 const char *vaErrorStr(VAStatus error_status)
343 case VA_STATUS_SUCCESS:
344 return "success (no error)";
345 case VA_STATUS_ERROR_ALLOCATION_FAILED:
346 return "resource allocation failed";
347 case VA_STATUS_ERROR_INVALID_CONFIG:
348 return "invalid VAConfigID";
349 case VA_STATUS_ERROR_INVALID_CONTEXT:
350 return "invalid VAContextID";
351 case VA_STATUS_ERROR_INVALID_SURFACE:
352 return "invalid VASurfaceID";
353 case VA_STATUS_ERROR_INVALID_BUFFER:
354 return "invalid VABufferID";
355 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
356 return "attribute not supported";
357 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
358 return "list argument exceeds maximum number";
359 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
360 return "the requested VAProfile is not supported";
361 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
362 return "the requested VAEntryPoint is not supported";
363 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
364 return "the requested RT Format is not supported";
365 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
366 return "the requested VABufferType is not supported";
367 case VA_STATUS_ERROR_UNKNOWN:
368 return "unknown libva error";
370 return "unknown libva error / description missing";
373 VAStatus vaInitialize (
375 int *major_version, /* out */
376 int *minor_version /* out */
379 VADriverContextP ctx = CTX(dpy);
380 char *driver_name = NULL;
385 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
387 vaStatus = va_getDriverName(ctx, &driver_name);
388 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
390 if (VA_STATUS_SUCCESS == vaStatus)
392 vaStatus = va_openDriver(ctx, driver_name);
393 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
395 *major_version = ctx->version_major;
396 *minor_version = ctx->version_minor;
408 * After this call, all library internal resources will be cleaned up
410 VAStatus vaTerminate (
414 VAStatus vaStatus = VA_STATUS_SUCCESS;
415 VADriverContextP old_ctx = CTX(dpy);
416 CHECK_CONTEXT(old_ctx);
420 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
421 dlclose(old_ctx->handle);
422 old_ctx->handle = NULL;
425 if (VA_STATUS_SUCCESS == vaStatus)
427 VADriverContextP *ctx = &pDriverContexts;
429 /* Throw away old_ctx */
434 *ctx = old_ctx->pNext;
435 old_ctx->pNext = NULL;
438 ctx = &((*ctx)->pNext);
446 * vaQueryVendorString returns a pointer to a zero-terminated string
447 * describing some aspects of the VA implemenation on a specific
448 * hardware accelerator. The format of the returned string is:
449 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
450 * e.g. for the Intel GMA500 implementation, an example would be:
451 * "IntelGMA500-1.0-0.2-patch3
453 const char *vaQueryVendorString (
457 VADriverContextP ctx = CTX(dpy);
458 if( !vaContextIsValid(ctx) )
463 return ctx->str_vendor;
467 /* Get maximum number of profiles supported by the implementation */
468 int vaMaxNumProfiles (
472 VADriverContextP ctx = CTX(dpy);
473 if( !vaContextIsValid(ctx) )
478 return ctx->max_profiles;
481 /* Get maximum number of entrypoints supported by the implementation */
482 int vaMaxNumEntrypoints (
486 VADriverContextP ctx = CTX(dpy);
487 if( !vaContextIsValid(ctx) )
492 return ctx->max_entrypoints;
496 /* Get maximum number of attributs supported by the implementation */
497 int vaMaxNumConfigAttributes (
501 VADriverContextP ctx = CTX(dpy);
502 if( !vaContextIsValid(ctx) )
507 return ctx->max_attributes;
510 VAStatus vaQueryConfigEntrypoints (
513 VAEntrypoint *entrypoints, /* out */
514 int *num_entrypoints /* out */
517 VADriverContextP ctx = CTX(dpy);
520 TRACE(vaQueryConfigEntrypoints);
521 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
524 VAStatus vaGetConfigAttributes (
527 VAEntrypoint entrypoint,
528 VAConfigAttrib *attrib_list, /* in/out */
532 VADriverContextP ctx = CTX(dpy);
535 TRACE(vaGetConfigAttributes);
536 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
539 VAStatus vaQueryConfigProfiles (
541 VAProfile *profile_list, /* out */
542 int *num_profiles /* out */
545 VADriverContextP ctx = CTX(dpy);
548 TRACE(vaQueryConfigProfiles);
549 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
552 VAStatus vaCreateConfig (
555 VAEntrypoint entrypoint,
556 VAConfigAttrib *attrib_list,
558 VAConfigID *config_id /* out */
561 VADriverContextP ctx = CTX(dpy);
564 TRACE(vaCreateConfig);
565 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
568 VAStatus vaDestroyConfig (
573 VADriverContextP ctx = CTX(dpy);
576 TRACE(vaDestroyConfig);
577 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
580 VAStatus vaQueryConfigAttributes (
582 VAConfigID config_id,
583 VAProfile *profile, /* out */
584 VAEntrypoint *entrypoint, /* out */
585 VAConfigAttrib *attrib_list,/* out */
586 int *num_attribs /* out */
589 VADriverContextP ctx = CTX(dpy);
592 TRACE(vaQueryConfigAttributes);
593 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
596 VAStatus vaCreateSurfaces (
602 VASurfaceID *surfaces /* out */
605 VADriverContextP ctx = CTX(dpy);
608 TRACE(vaCreateSurfaces);
609 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
612 VAStatus vaDestroySurfaces (
614 VASurfaceID *surface_list,
618 VADriverContextP ctx = CTX(dpy);
621 TRACE(vaDestroySurfaces);
622 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
625 VAStatus vaCreateContext (
627 VAConfigID config_id,
631 VASurfaceID *render_targets,
632 int num_render_targets,
633 VAContextID *context /* out */
636 VADriverContextP ctx = CTX(dpy);
639 TRACE(vaCreateContext);
640 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
641 flag, render_targets, num_render_targets, context );
644 VAStatus vaDestroyContext (
649 VADriverContextP ctx = CTX(dpy);
652 TRACE(vaDestroyContext);
653 return ctx->vtable.vaDestroyContext( ctx, context );
656 VAStatus vaCreateBuffer (
658 VAContextID context, /* in */
659 VABufferType type, /* in */
660 unsigned int size, /* in */
661 unsigned int num_elements, /* in */
663 VABufferID *buf_id /* out */
666 VADriverContextP ctx = CTX(dpy);
669 TRACE(vaCreateBuffer);
670 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
673 VAStatus vaBufferSetNumElements (
675 VABufferID buf_id, /* in */
676 unsigned int num_elements /* in */
679 VADriverContextP ctx = CTX(dpy);
682 TRACE(vaBufferSetNumElements);
683 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
687 VAStatus vaMapBuffer (
689 VABufferID buf_id, /* in */
690 void **pbuf /* out */
693 VADriverContextP ctx = CTX(dpy);
697 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
700 VAStatus vaUnmapBuffer (
702 VABufferID buf_id /* in */
705 VADriverContextP ctx = CTX(dpy);
708 TRACE(vaUnmapBuffer);
709 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
712 VAStatus vaDestroyBuffer (
717 VADriverContextP ctx = CTX(dpy);
720 TRACE(vaDestroyBuffer);
721 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
724 VAStatus vaBeginPicture (
727 VASurfaceID render_target
730 VADriverContextP ctx = CTX(dpy);
733 TRACE(vaBeginPicture);
734 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
737 VAStatus vaRenderPicture (
744 VADriverContextP ctx = CTX(dpy);
747 TRACE(vaRenderPicture);
748 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
751 VAStatus vaEndPicture (
756 VADriverContextP ctx = CTX(dpy);
760 return ctx->vtable.vaEndPicture( ctx, context );
763 VAStatus vaSyncSurface (
766 VASurfaceID render_target
769 VADriverContextP ctx = CTX(dpy);
772 TRACE(vaSyncSurface);
773 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
776 VAStatus vaQuerySurfaceStatus (
778 VASurfaceID render_target,
779 VASurfaceStatus *status /* out */
782 VADriverContextP ctx = CTX(dpy);
785 TRACE(vaQuerySurfaceStatus);
786 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
789 VAStatus vaPutSurface (
792 Drawable draw, /* X Drawable */
799 unsigned short destw,
800 unsigned short desth,
801 VARectangle *cliprects, /* client supplied clip list */
802 unsigned int number_cliprects, /* number of clip rects in the clip list */
803 unsigned int flags /* de-interlacing flags */
806 VADriverContextP ctx = CTX(dpy);
810 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
811 destx, desty, destw, desth,
812 cliprects, number_cliprects, flags );
815 /* Get maximum number of image formats supported by the implementation */
816 int vaMaxNumImageFormats (
820 VADriverContextP ctx = CTX(dpy);
821 if( !vaContextIsValid(ctx) )
826 return ctx->max_image_formats;
829 VAStatus vaQueryImageFormats (
831 VAImageFormat *format_list, /* out */
832 int *num_formats /* out */
835 VADriverContextP ctx = CTX(dpy);
838 TRACE(vaQueryImageFormats);
839 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
843 * The width and height fields returned in the VAImage structure may get
844 * enlarged for some YUV formats. The size of the data buffer that needs
845 * to be allocated will be given in the "data_size" field in VAImage.
846 * Image data is not allocated by this function. The client should
847 * allocate the memory and fill in the VAImage structure's data field
848 * after looking at "data_size" returned from the library.
850 VAStatus vaCreateImage (
852 VAImageFormat *format,
855 VAImage *image /* out */
858 VADriverContextP ctx = CTX(dpy);
861 TRACE(vaCreateImage);
862 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
866 * Should call DestroyImage before destroying the surface it is bound to
868 VAStatus vaDestroyImage (
873 VADriverContextP ctx = CTX(dpy);
876 TRACE(vaDestroyImage);
877 return ctx->vtable.vaDestroyImage ( ctx, image);
880 VAStatus vaSetImagePalette (
883 unsigned char *palette
886 VADriverContextP ctx = CTX(dpy);
889 TRACE(vaSetImagePalette);
890 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
894 * Retrieve surface data into a VAImage
895 * Image must be in a format supported by the implementation
897 VAStatus vaGetImage (
900 int x, /* coordinates of the upper left source pixel */
902 unsigned int width, /* width and height of the region */
907 VADriverContextP ctx = CTX(dpy);
911 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
915 * Copy data from a VAImage to a surface
916 * Image must be in a format supported by the implementation
918 VAStatus vaPutImage (
930 VADriverContextP ctx = CTX(dpy);
934 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
937 /* Get maximum number of subpicture formats supported by the implementation */
938 int vaMaxNumSubpictureFormats (
942 VADriverContextP ctx = CTX(dpy);
943 if( !vaContextIsValid(ctx) )
948 return ctx->max_subpic_formats;
952 * Query supported subpicture formats
953 * The caller must provide a "format_list" array that can hold at
954 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
955 * for each format to indicate additional capabilities for that format. The actual
956 * number of formats returned in "format_list" is returned in "num_formats".
958 VAStatus vaQuerySubpictureFormats (
960 VAImageFormat *format_list, /* out */
961 unsigned int *flags, /* out */
962 unsigned int *num_formats /* out */
965 VADriverContextP ctx = CTX(dpy);
968 TRACE(vaQuerySubpictureFormats);
969 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
973 * Subpictures are created with an image associated.
975 VAStatus vaCreateSubpicture (
978 VASubpictureID *subpicture /* out */
981 VADriverContextP ctx = CTX(dpy);
984 TRACE(vaCreateSubpicture);
985 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
989 * Destroy the subpicture before destroying the image it is assocated to
991 VAStatus vaDestroySubpicture (
993 VASubpictureID subpicture
996 VADriverContextP ctx = CTX(dpy);
999 TRACE(vaDestroySubpicture);
1000 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1003 VAStatus vaSetSubpictureImage (
1005 VASubpictureID subpicture,
1009 VADriverContextP ctx = CTX(dpy);
1012 TRACE(vaSetSubpictureImage);
1013 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1017 VAStatus vaSetSubpicturePalette (
1019 VASubpictureID subpicture,
1021 * pointer to an array holding the palette data. The size of the array is
1022 * num_palette_entries * entry_bytes in size. The order of the components
1023 * in the palette is described by the component_order in VASubpicture struct
1025 unsigned char *palette
1028 VADriverContextP ctx = CTX(dpy);
1031 TRACE(vaSetSubpicturePalette);
1032 return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
1036 * If chromakey is enabled, then the area where the source value falls within
1037 * the chromakey [min, max] range is transparent
1039 VAStatus vaSetSubpictureChromakey (
1041 VASubpictureID subpicture,
1042 unsigned int chromakey_min,
1043 unsigned int chromakey_max,
1044 unsigned int chromakey_mask
1047 VADriverContextP ctx = CTX(dpy);
1050 TRACE(vaSetSubpictureChromakey);
1051 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1056 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1057 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1058 * the overall alpha is per-pixel alpha multiplied by the global alpha
1060 VAStatus vaSetSubpictureGlobalAlpha (
1062 VASubpictureID subpicture,
1066 VADriverContextP ctx = CTX(dpy);
1069 TRACE(vaSetSubpictureGlobalAlpha);
1070 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1074 vaAssociateSubpicture associates the subpicture with the target_surface.
1075 It defines the region mapping between the subpicture and the target
1076 surface through source and destination rectangles (with the same width and height).
1077 Both will be displayed at the next call to vaPutSurface. Additional
1078 associations before the call to vaPutSurface simply overrides the association.
1080 VAStatus vaAssociateSubpicture (
1082 VASubpictureID subpicture,
1083 VASurfaceID *target_surfaces,
1085 short src_x, /* upper left offset in subpicture */
1087 short dest_x, /* upper left offset in surface */
1089 unsigned short width,
1090 unsigned short height,
1092 * whether to enable chroma-keying or global-alpha
1093 * see VA_SUBPICTURE_XXX values
1098 VADriverContextP ctx = CTX(dpy);
1101 TRACE(vaAssociateSubpicture);
1102 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1106 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1108 VAStatus vaDeassociateSubpicture (
1110 VASubpictureID subpicture,
1111 VASurfaceID *target_surfaces,
1115 VADriverContextP ctx = CTX(dpy);
1118 TRACE(vaDeassociateSubpicture);
1119 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1123 /* Get maximum number of display attributes supported by the implementation */
1124 int vaMaxNumDisplayAttributes (
1128 VADriverContextP ctx = CTX(dpy);
1129 if( !vaContextIsValid(ctx) )
1134 return ctx->max_display_attributes;
1138 * Query display attributes
1139 * The caller must provide a "attr_list" array that can hold at
1140 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1141 * returned in "attr_list" is returned in "num_attributes".
1143 VAStatus vaQueryDisplayAttributes (
1145 VADisplayAttribute *attr_list, /* out */
1146 int *num_attributes /* out */
1149 VADriverContextP ctx = CTX(dpy);
1152 TRACE(vaQueryDisplayAttributes);
1153 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1157 * Get display attributes
1158 * This function returns the current attribute values in "attr_list".
1159 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1160 * from vaQueryDisplayAttributes() can have their values retrieved.
1162 VAStatus vaGetDisplayAttributes (
1164 VADisplayAttribute *attr_list, /* in/out */
1168 VADriverContextP ctx = CTX(dpy);
1171 TRACE(vaGetDisplayAttributes);
1172 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1176 * Set display attributes
1177 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1178 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1179 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1181 VAStatus vaSetDisplayAttributes (
1183 VADisplayAttribute *attr_list,
1187 VADriverContextP ctx = CTX(dpy);
1190 TRACE(vaSetDisplayAttributes);
1191 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1196 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1197 VASurfaceID surface,
1198 void **buffer, /* out */
1199 unsigned int *stride /* out */
1202 VADriverContextP ctx = CTX(dpy);
1205 TRACE(vaDbgCopySurfaceToBuffer);
1206 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );