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 VA_MAJOR_VERSION 0
38 #define VA_MINOR_VERSION 26
39 #define DRIVER_INIT_FUNC "__vaDriverInit_0_26"
41 #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
42 #define DRIVER_EXTENSION "_drv_video.so"
44 #define CTX(dpy) ((VADriverContextP) dpy );
45 #define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
47 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
48 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
49 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
51 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
53 static VADriverContextP pDriverContexts = NULL;
54 static int va_debug_trace = 0;
56 static Bool vaContextIsValid(VADriverContextP arg_ctx)
58 VADriverContextP ctx = pDriverContexts;
71 VADisplay vaGetDisplay (
72 NativeDisplay native_dpy /* implementation specific */
76 VADriverContextP ctx = pDriverContexts;
85 if (ctx->x11_dpy == (Display *)native_dpy)
87 dpy = (VADisplay) ctx;
95 /* create new entry */
96 ctx = (VADriverContextP) calloc(1, sizeof(struct VADriverContext));
97 ctx->pNext = pDriverContexts;
98 ctx->x11_dpy = (Display *) native_dpy;
99 pDriverContexts = ctx;
100 dpy = (VADisplay) ctx;
106 static void va_errorMessage(const char *msg, ...)
110 fprintf(stderr, "libva error: ");
112 vfprintf(stderr, msg, args);
116 static void va_infoMessage(const char *msg, ...)
120 fprintf(stderr, "libva: ");
122 vfprintf(stderr, msg, args);
126 static Bool va_checkVtable(void *ptr, char *function)
130 va_errorMessage("No valid vtable entry for va%s\n", function);
136 static Bool va_checkMaximum(int value, char *variable)
140 va_errorMessage("Failed to define max_%s in init\n", variable);
146 static Bool va_checkString(const char* value, char *variable)
150 va_errorMessage("Failed to define str_%s in init\n", variable);
156 static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
158 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
166 if (geteuid() == getuid())
168 /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
169 if (getenv("LIBVA_DRIVER_NAME"))
171 /* For easier debugging */
172 *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
173 return VA_STATUS_SUCCESS;
178 result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
181 va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
186 result = direct_capable;
189 va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
194 result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
195 &driver_patch, driver_name);
198 va_errorMessage("VA_DRIGetClientDriverName returned false\n");
203 vaStatus = VA_STATUS_SUCCESS;
204 va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
205 driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
211 static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
213 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
218 if (geteuid() == getuid())
220 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
221 search_path = getenv("LIBVA_DRIVERS_PATH");
224 search_path = getenv("LIBGL_DRIVERS_PATH");
229 search_path = DEFAULT_DRIVER_DIR;
232 search_path = strdup(search_path);
233 driver_dir = strtok_r(search_path, ":", &saveptr);
237 char *driver_path = (char *) malloc( strlen(driver_dir) +
238 strlen(driver_name) +
239 strlen(DRIVER_EXTENSION) + 2 );
240 strcpy( driver_path, driver_dir );
241 strcat( driver_path, "/" );
242 strcat( driver_path, driver_name );
243 strcat( driver_path, DRIVER_EXTENSION );
245 va_infoMessage("Trying to open %s\n", driver_path);
247 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
250 /* Don't give errors for non-existing files */
251 if (0 == access( driver_path, F_OK))
253 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
258 VADriverInit init_func;
259 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
262 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
267 vaStatus = (*init_func)(ctx);
269 if (VA_STATUS_SUCCESS == vaStatus)
271 CHECK_MAXIMUM(vaStatus, ctx, profiles);
272 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
273 CHECK_MAXIMUM(vaStatus, ctx, attributes);
274 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
275 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
276 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
277 CHECK_STRING(vaStatus, ctx, vendor);
278 CHECK_VTABLE(vaStatus, ctx, Terminate);
279 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
280 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
281 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
282 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
283 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
284 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
285 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
286 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
287 CHECK_VTABLE(vaStatus, ctx, CreateContext);
288 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
289 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
290 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
291 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
292 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
293 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
294 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
295 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
296 CHECK_VTABLE(vaStatus, ctx, EndPicture);
297 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
298 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
299 CHECK_VTABLE(vaStatus, ctx, PutSurface);
300 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
301 CHECK_VTABLE(vaStatus, ctx, CreateImage);
302 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
303 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
304 CHECK_VTABLE(vaStatus, ctx, GetImage);
305 CHECK_VTABLE(vaStatus, ctx, PutImage);
306 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
307 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
308 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
309 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
310 CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
311 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
312 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
313 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
314 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
315 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
316 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
317 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
318 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
320 if (VA_STATUS_SUCCESS != vaStatus)
322 va_errorMessage("%s init failed\n", driver_path);
325 if (VA_STATUS_SUCCESS == vaStatus)
327 ctx->handle = handle;
335 driver_dir = strtok_r(NULL, ":", &saveptr);
345 * Returns a short english description of error_status
347 const char *vaErrorStr(VAStatus error_status)
351 case VA_STATUS_SUCCESS:
352 return "success (no error)";
353 case VA_STATUS_ERROR_ALLOCATION_FAILED:
354 return "resource allocation failed";
355 case VA_STATUS_ERROR_INVALID_CONFIG:
356 return "invalid VAConfigID";
357 case VA_STATUS_ERROR_INVALID_CONTEXT:
358 return "invalid VAContextID";
359 case VA_STATUS_ERROR_INVALID_SURFACE:
360 return "invalid VASurfaceID";
361 case VA_STATUS_ERROR_INVALID_BUFFER:
362 return "invalid VABufferID";
363 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
364 return "attribute not supported";
365 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
366 return "list argument exceeds maximum number";
367 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
368 return "the requested VAProfile is not supported";
369 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
370 return "the requested VAEntryPoint is not supported";
371 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
372 return "the requested RT Format is not supported";
373 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
374 return "the requested VABufferType is not supported";
375 case VA_STATUS_ERROR_UNKNOWN:
376 return "unknown libva error";
378 return "unknown libva error / description missing";
381 VAStatus vaInitialize (
383 int *major_version, /* out */
384 int *minor_version /* out */
387 VADriverContextP ctx = CTX(dpy);
388 char *driver_name = NULL;
393 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
395 vaStatus = va_getDriverName(ctx, &driver_name);
396 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
398 if (VA_STATUS_SUCCESS == vaStatus)
400 vaStatus = va_openDriver(ctx, driver_name);
401 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
403 *major_version = VA_MAJOR_VERSION;
404 *minor_version = VA_MINOR_VERSION;
416 * After this call, all library internal resources will be cleaned up
418 VAStatus vaTerminate (
422 VAStatus vaStatus = VA_STATUS_SUCCESS;
423 VADriverContextP old_ctx = CTX(dpy);
424 CHECK_CONTEXT(old_ctx);
428 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
429 dlclose(old_ctx->handle);
430 old_ctx->handle = NULL;
433 if (VA_STATUS_SUCCESS == vaStatus)
435 VADriverContextP *ctx = &pDriverContexts;
437 /* Throw away old_ctx */
442 *ctx = old_ctx->pNext;
443 old_ctx->pNext = NULL;
446 ctx = &((*ctx)->pNext);
454 * vaQueryVendorString returns a pointer to a zero-terminated string
455 * describing some aspects of the VA implemenation on a specific
456 * hardware accelerator. The format of the returned string is:
457 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
458 * e.g. for the Intel GMA500 implementation, an example would be:
459 * "IntelGMA500-1.0-0.2-patch3
461 const char *vaQueryVendorString (
465 VADriverContextP ctx = CTX(dpy);
466 if( !vaContextIsValid(ctx) )
471 return ctx->str_vendor;
475 /* Get maximum number of profiles supported by the implementation */
476 int vaMaxNumProfiles (
480 VADriverContextP ctx = CTX(dpy);
481 if( !vaContextIsValid(ctx) )
486 return ctx->max_profiles;
489 /* Get maximum number of entrypoints supported by the implementation */
490 int vaMaxNumEntrypoints (
494 VADriverContextP ctx = CTX(dpy);
495 if( !vaContextIsValid(ctx) )
500 return ctx->max_entrypoints;
504 /* Get maximum number of attributs supported by the implementation */
505 int vaMaxNumConfigAttributes (
509 VADriverContextP ctx = CTX(dpy);
510 if( !vaContextIsValid(ctx) )
515 return ctx->max_attributes;
518 VAStatus vaQueryConfigEntrypoints (
521 VAEntrypoint *entrypoints, /* out */
522 int *num_entrypoints /* out */
525 VADriverContextP ctx = CTX(dpy);
528 TRACE(vaQueryConfigEntrypoints);
529 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
532 VAStatus vaGetConfigAttributes (
535 VAEntrypoint entrypoint,
536 VAConfigAttrib *attrib_list, /* in/out */
540 VADriverContextP ctx = CTX(dpy);
543 TRACE(vaGetConfigAttributes);
544 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
547 VAStatus vaQueryConfigProfiles (
549 VAProfile *profile_list, /* out */
550 int *num_profiles /* out */
553 VADriverContextP ctx = CTX(dpy);
556 TRACE(vaQueryConfigProfiles);
557 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
560 VAStatus vaCreateConfig (
563 VAEntrypoint entrypoint,
564 VAConfigAttrib *attrib_list,
566 VAConfigID *config_id /* out */
569 VADriverContextP ctx = CTX(dpy);
572 TRACE(vaCreateConfig);
573 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
576 VAStatus vaDestroyConfig (
581 VADriverContextP ctx = CTX(dpy);
584 TRACE(vaDestroyConfig);
585 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
588 VAStatus vaQueryConfigAttributes (
590 VAConfigID config_id,
591 VAProfile *profile, /* out */
592 VAEntrypoint *entrypoint, /* out */
593 VAConfigAttrib *attrib_list,/* out */
594 int *num_attribs /* out */
597 VADriverContextP ctx = CTX(dpy);
600 TRACE(vaQueryConfigAttributes);
601 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
604 VAStatus vaCreateSurfaces (
610 VASurfaceID *surfaces /* out */
613 VADriverContextP ctx = CTX(dpy);
616 TRACE(vaCreateSurfaces);
617 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
620 VAStatus vaDestroySurfaces (
622 VASurfaceID *surface_list,
626 VADriverContextP ctx = CTX(dpy);
629 TRACE(vaDestroySurfaces);
630 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
633 VAStatus vaCreateContext (
635 VAConfigID config_id,
639 VASurfaceID *render_targets,
640 int num_render_targets,
641 VAContextID *context /* out */
644 VADriverContextP ctx = CTX(dpy);
647 TRACE(vaCreateContext);
648 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
649 flag, render_targets, num_render_targets, context );
652 VAStatus vaDestroyContext (
657 VADriverContextP ctx = CTX(dpy);
660 TRACE(vaDestroyContext);
661 return ctx->vtable.vaDestroyContext( ctx, context );
664 VAStatus vaCreateBuffer (
666 VAContextID context, /* in */
667 VABufferType type, /* in */
668 unsigned int size, /* in */
669 unsigned int num_elements, /* in */
671 VABufferID *buf_id /* out */
674 VADriverContextP ctx = CTX(dpy);
677 TRACE(vaCreateBuffer);
678 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
681 VAStatus vaBufferSetNumElements (
683 VABufferID buf_id, /* in */
684 unsigned int num_elements /* in */
687 VADriverContextP ctx = CTX(dpy);
690 TRACE(vaBufferSetNumElements);
691 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
695 VAStatus vaMapBuffer (
697 VABufferID buf_id, /* in */
698 void **pbuf /* out */
701 VADriverContextP ctx = CTX(dpy);
705 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
708 VAStatus vaUnmapBuffer (
710 VABufferID buf_id /* in */
713 VADriverContextP ctx = CTX(dpy);
716 TRACE(vaUnmapBuffer);
717 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
720 VAStatus vaDestroyBuffer (
725 VADriverContextP ctx = CTX(dpy);
728 TRACE(vaDestroyBuffer);
729 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
732 VAStatus vaBeginPicture (
735 VASurfaceID render_target
738 VADriverContextP ctx = CTX(dpy);
741 TRACE(vaBeginPicture);
742 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
745 VAStatus vaRenderPicture (
752 VADriverContextP ctx = CTX(dpy);
755 TRACE(vaRenderPicture);
756 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
759 VAStatus vaEndPicture (
764 VADriverContextP ctx = CTX(dpy);
768 return ctx->vtable.vaEndPicture( ctx, context );
771 VAStatus vaSyncSurface (
774 VASurfaceID render_target
777 VADriverContextP ctx = CTX(dpy);
780 TRACE(vaSyncSurface);
781 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
784 VAStatus vaQuerySurfaceStatus (
786 VASurfaceID render_target,
787 VASurfaceStatus *status /* out */
790 VADriverContextP ctx = CTX(dpy);
793 TRACE(vaQuerySurfaceStatus);
794 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
797 VAStatus vaPutSurface (
800 Drawable draw, /* X Drawable */
807 unsigned short destw,
808 unsigned short desth,
809 VARectangle *cliprects, /* client supplied clip list */
810 unsigned int number_cliprects, /* number of clip rects in the clip list */
811 unsigned int flags /* de-interlacing flags */
814 VADriverContextP ctx = CTX(dpy);
818 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
819 destx, desty, destw, desth,
820 cliprects, number_cliprects, flags );
823 /* Get maximum number of image formats supported by the implementation */
824 int vaMaxNumImageFormats (
828 VADriverContextP ctx = CTX(dpy);
829 if( !vaContextIsValid(ctx) )
834 return ctx->max_image_formats;
837 VAStatus vaQueryImageFormats (
839 VAImageFormat *format_list, /* out */
840 int *num_formats /* out */
843 VADriverContextP ctx = CTX(dpy);
846 TRACE(vaQueryImageFormats);
847 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
851 * The width and height fields returned in the VAImage structure may get
852 * enlarged for some YUV formats. The size of the data buffer that needs
853 * to be allocated will be given in the "data_size" field in VAImage.
854 * Image data is not allocated by this function. The client should
855 * allocate the memory and fill in the VAImage structure's data field
856 * after looking at "data_size" returned from the library.
858 VAStatus vaCreateImage (
860 VAImageFormat *format,
863 VAImage *image /* out */
866 VADriverContextP ctx = CTX(dpy);
869 TRACE(vaCreateImage);
870 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
874 * Should call DestroyImage before destroying the surface it is bound to
876 VAStatus vaDestroyImage (
881 VADriverContextP ctx = CTX(dpy);
884 TRACE(vaDestroyImage);
885 return ctx->vtable.vaDestroyImage ( ctx, image);
888 VAStatus vaSetImagePalette (
891 unsigned char *palette
894 VADriverContextP ctx = CTX(dpy);
897 TRACE(vaSetImagePalette);
898 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
902 * Retrieve surface data into a VAImage
903 * Image must be in a format supported by the implementation
905 VAStatus vaGetImage (
908 int x, /* coordinates of the upper left source pixel */
910 unsigned int width, /* width and height of the region */
915 VADriverContextP ctx = CTX(dpy);
919 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
923 * Copy data from a VAImage to a surface
924 * Image must be in a format supported by the implementation
926 VAStatus vaPutImage (
938 VADriverContextP ctx = CTX(dpy);
942 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
945 /* Get maximum number of subpicture formats supported by the implementation */
946 int vaMaxNumSubpictureFormats (
950 VADriverContextP ctx = CTX(dpy);
951 if( !vaContextIsValid(ctx) )
956 return ctx->max_subpic_formats;
960 * Query supported subpicture formats
961 * The caller must provide a "format_list" array that can hold at
962 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
963 * for each format to indicate additional capabilities for that format. The actual
964 * number of formats returned in "format_list" is returned in "num_formats".
966 VAStatus vaQuerySubpictureFormats (
968 VAImageFormat *format_list, /* out */
969 unsigned int *flags, /* out */
970 unsigned int *num_formats /* out */
973 VADriverContextP ctx = CTX(dpy);
976 TRACE(vaQuerySubpictureFormats);
977 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
981 * Subpictures are created with an image associated.
983 VAStatus vaCreateSubpicture (
986 VASubpictureID *subpicture /* out */
989 VADriverContextP ctx = CTX(dpy);
992 TRACE(vaCreateSubpicture);
993 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
997 * Destroy the subpicture before destroying the image it is assocated to
999 VAStatus vaDestroySubpicture (
1001 VASubpictureID subpicture
1004 VADriverContextP ctx = CTX(dpy);
1007 TRACE(vaDestroySubpicture);
1008 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1011 VAStatus vaSetSubpictureImage (
1013 VASubpictureID subpicture,
1017 VADriverContextP ctx = CTX(dpy);
1020 TRACE(vaSetSubpictureImage);
1021 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1025 VAStatus vaSetSubpicturePalette (
1027 VASubpictureID subpicture,
1029 * pointer to an array holding the palette data. The size of the array is
1030 * num_palette_entries * entry_bytes in size. The order of the components
1031 * in the palette is described by the component_order in VASubpicture struct
1033 unsigned char *palette
1036 VADriverContextP ctx = CTX(dpy);
1039 TRACE(vaSetSubpicturePalette);
1040 return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
1044 * If chromakey is enabled, then the area where the source value falls within
1045 * the chromakey [min, max] range is transparent
1047 VAStatus vaSetSubpictureChromakey (
1049 VASubpictureID subpicture,
1050 unsigned int chromakey_min,
1051 unsigned int chromakey_max,
1052 unsigned int chromakey_mask
1055 VADriverContextP ctx = CTX(dpy);
1058 TRACE(vaSetSubpictureChromakey);
1059 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1064 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1065 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1066 * the overall alpha is per-pixel alpha multiplied by the global alpha
1068 VAStatus vaSetSubpictureGlobalAlpha (
1070 VASubpictureID subpicture,
1074 VADriverContextP ctx = CTX(dpy);
1077 TRACE(vaSetSubpictureGlobalAlpha);
1078 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1082 vaAssociateSubpicture associates the subpicture with the target_surface.
1083 It defines the region mapping between the subpicture and the target
1084 surface through source and destination rectangles (with the same width and height).
1085 Both will be displayed at the next call to vaPutSurface. Additional
1086 associations before the call to vaPutSurface simply overrides the association.
1088 VAStatus vaAssociateSubpicture (
1090 VASubpictureID subpicture,
1091 VASurfaceID *target_surfaces,
1093 short src_x, /* upper left offset in subpicture */
1095 short dest_x, /* upper left offset in surface */
1097 unsigned short width,
1098 unsigned short height,
1100 * whether to enable chroma-keying or global-alpha
1101 * see VA_SUBPICTURE_XXX values
1106 VADriverContextP ctx = CTX(dpy);
1109 TRACE(vaAssociateSubpicture);
1110 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1114 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1116 VAStatus vaDeassociateSubpicture (
1118 VASubpictureID subpicture,
1119 VASurfaceID *target_surfaces,
1123 VADriverContextP ctx = CTX(dpy);
1126 TRACE(vaDeassociateSubpicture);
1127 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1131 /* Get maximum number of display attributes supported by the implementation */
1132 int vaMaxNumDisplayAttributes (
1136 VADriverContextP ctx = CTX(dpy);
1137 if( !vaContextIsValid(ctx) )
1142 return ctx->max_display_attributes;
1146 * Query display attributes
1147 * The caller must provide a "attr_list" array that can hold at
1148 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1149 * returned in "attr_list" is returned in "num_attributes".
1151 VAStatus vaQueryDisplayAttributes (
1153 VADisplayAttribute *attr_list, /* out */
1154 int *num_attributes /* out */
1157 VADriverContextP ctx = CTX(dpy);
1160 TRACE(vaQueryDisplayAttributes);
1161 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1165 * Get display attributes
1166 * This function returns the current attribute values in "attr_list".
1167 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1168 * from vaQueryDisplayAttributes() can have their values retrieved.
1170 VAStatus vaGetDisplayAttributes (
1172 VADisplayAttribute *attr_list, /* in/out */
1176 VADriverContextP ctx = CTX(dpy);
1179 TRACE(vaGetDisplayAttributes);
1180 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1184 * Set display attributes
1185 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1186 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1187 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1189 VAStatus vaSetDisplayAttributes (
1191 VADisplayAttribute *attr_list,
1195 VADriverContextP ctx = CTX(dpy);
1198 TRACE(vaSetDisplayAttributes);
1199 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1204 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1205 VASurfaceID surface,
1206 void **buffer, /* out */
1207 unsigned int *stride /* out */
1210 VADriverContextP ctx = CTX(dpy);
1213 TRACE(vaDbgCopySurfaceToBuffer);
1214 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );