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.
26 #include "va_backend.h"
35 #define VA_MAJOR_VERSION 0
36 #define VA_MINOR_VERSION 30
37 #define DRIVER_INIT_FUNC "__vaDriverInit_0_30"
39 #define DEFAULT_DRIVER_DIR "/usr/lib/dri/"
40 #define DRIVER_EXTENSION "_drv_video.so"
42 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
43 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
46 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
47 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
48 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
50 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
52 static int va_debug_trace = 0;
54 static int vaDisplayIsValid(VADisplay dpy)
56 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
57 return pDisplayContext && pDisplayContext->vaIsValid(pDisplayContext);
60 static void va_errorMessage(const char *msg, ...)
64 fprintf(stderr, "libva error: ");
66 vfprintf(stderr, msg, args);
70 static void va_infoMessage(const char *msg, ...)
74 fprintf(stderr, "libva: ");
76 vfprintf(stderr, msg, args);
80 static Bool va_checkVtable(void *ptr, char *function)
84 va_errorMessage("No valid vtable entry for va%s\n", function);
90 static Bool va_checkMaximum(int value, char *variable)
94 va_errorMessage("Failed to define max_%s in init\n", variable);
100 static Bool va_checkString(const char* value, char *variable)
104 va_errorMessage("Failed to define str_%s in init\n", variable);
110 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
112 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
113 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
116 static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
118 VADriverContextP ctx = CTX(dpy);
119 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
120 char *search_path = NULL;
124 if (geteuid() == getuid())
126 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
127 search_path = getenv("LIBVA_DRIVERS_PATH");
130 search_path = getenv("LIBGL_DRIVERS_PATH");
135 search_path = DEFAULT_DRIVER_DIR;
138 search_path = strdup(search_path);
139 driver_dir = strtok_r(search_path, ":", &saveptr);
143 char *driver_path = (char *) malloc( strlen(driver_dir) +
144 strlen(driver_name) +
145 strlen(DRIVER_EXTENSION) + 2 );
146 strcpy( driver_path, driver_dir );
147 strcat( driver_path, "/" );
148 strcat( driver_path, driver_name );
149 strcat( driver_path, DRIVER_EXTENSION );
151 va_infoMessage("Trying to open %s\n", driver_path);
153 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
156 /* Don't give errors for non-existing files */
157 if (0 == access( driver_path, F_OK))
159 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
164 VADriverInit init_func;
165 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
168 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
173 vaStatus = (*init_func)(ctx);
175 if (VA_STATUS_SUCCESS == vaStatus)
177 CHECK_MAXIMUM(vaStatus, ctx, profiles);
178 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
179 CHECK_MAXIMUM(vaStatus, ctx, attributes);
180 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
181 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
182 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
183 CHECK_STRING(vaStatus, ctx, vendor);
184 CHECK_VTABLE(vaStatus, ctx, Terminate);
185 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
186 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
187 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
188 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
189 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
190 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
191 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
192 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
193 CHECK_VTABLE(vaStatus, ctx, CreateContext);
194 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
195 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
196 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
197 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
198 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
199 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
200 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
201 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
202 CHECK_VTABLE(vaStatus, ctx, EndPicture);
203 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
204 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
205 CHECK_VTABLE(vaStatus, ctx, PutSurface);
206 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
207 CHECK_VTABLE(vaStatus, ctx, CreateImage);
208 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
209 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
210 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
211 CHECK_VTABLE(vaStatus, ctx, GetImage);
212 CHECK_VTABLE(vaStatus, ctx, PutImage);
213 CHECK_VTABLE(vaStatus, ctx, PutImage2);
214 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
215 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
216 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
217 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
218 CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
219 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
220 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
221 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
222 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture2);
223 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
224 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
225 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
226 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
227 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
229 if (VA_STATUS_SUCCESS != vaStatus)
231 va_errorMessage("%s init failed\n", driver_path);
234 if (VA_STATUS_SUCCESS == vaStatus)
236 ctx->handle = handle;
244 driver_dir = strtok_r(NULL, ":", &saveptr);
252 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
254 VADriverContextP ctx;
255 if( !vaDisplayIsValid(dpy) )
259 if (NULL == ctx->handle)
262 return (VAPrivFunc) dlsym(ctx->handle, func);
267 * Returns a short english description of error_status
269 const char *vaErrorStr(VAStatus error_status)
273 case VA_STATUS_SUCCESS:
274 return "success (no error)";
275 case VA_STATUS_ERROR_OPERATION_FAILED:
276 return "operation failed";
277 case VA_STATUS_ERROR_ALLOCATION_FAILED:
278 return "resource allocation failed";
279 case VA_STATUS_ERROR_INVALID_DISPLAY:
280 return "invalid VADisplay";
281 case VA_STATUS_ERROR_INVALID_CONFIG:
282 return "invalid VAConfigID";
283 case VA_STATUS_ERROR_INVALID_CONTEXT:
284 return "invalid VAContextID";
285 case VA_STATUS_ERROR_INVALID_SURFACE:
286 return "invalid VASurfaceID";
287 case VA_STATUS_ERROR_INVALID_BUFFER:
288 return "invalid VABufferID";
289 case VA_STATUS_ERROR_INVALID_IMAGE:
290 return "invalid VAImageID";
291 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
292 return "invalid VASubpictureID";
293 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
294 return "attribute not supported";
295 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
296 return "list argument exceeds maximum number";
297 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
298 return "the requested VAProfile is not supported";
299 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
300 return "the requested VAEntryPoint is not supported";
301 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
302 return "the requested RT Format is not supported";
303 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
304 return "the requested VABufferType is not supported";
305 case VA_STATUS_ERROR_SURFACE_BUSY:
306 return "surface is in use";
307 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
308 return "flag not supported";
309 case VA_STATUS_ERROR_INVALID_PARAMETER:
310 return "invalid parameter";
311 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
312 return "resolution not supported";
313 case VA_STATUS_ERROR_UNKNOWN:
314 return "unknown libva error";
316 return "unknown libva error / description missing";
319 VAStatus vaInitialize (
321 int *major_version, /* out */
322 int *minor_version /* out */
325 char *driver_name = NULL;
330 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
332 vaStatus = va_getDriverName(dpy, &driver_name);
333 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
335 if (VA_STATUS_SUCCESS == vaStatus)
337 vaStatus = va_openDriver(dpy, driver_name);
338 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
340 *major_version = VA_MAJOR_VERSION;
341 *minor_version = VA_MINOR_VERSION;
351 * After this call, all library internal resources will be cleaned up
353 VAStatus vaTerminate (
357 VAStatus vaStatus = VA_STATUS_SUCCESS;
358 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
359 VADriverContextP old_ctx;
366 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
367 dlclose(old_ctx->handle);
368 old_ctx->handle = NULL;
371 if (VA_STATUS_SUCCESS == vaStatus)
372 pDisplayContext->vaDestroy(pDisplayContext);
377 * vaQueryVendorString returns a pointer to a zero-terminated string
378 * describing some aspects of the VA implemenation on a specific
379 * hardware accelerator. The format of the returned string is:
380 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
381 * e.g. for the Intel GMA500 implementation, an example would be:
382 * "IntelGMA500-1.0-0.2-patch3
384 const char *vaQueryVendorString (
388 if( !vaDisplayIsValid(dpy) )
391 return CTX(dpy)->str_vendor;
395 /* Get maximum number of profiles supported by the implementation */
396 int vaMaxNumProfiles (
400 if( !vaDisplayIsValid(dpy) )
403 return CTX(dpy)->max_profiles;
406 /* Get maximum number of entrypoints supported by the implementation */
407 int vaMaxNumEntrypoints (
411 if( !vaDisplayIsValid(dpy) )
414 return CTX(dpy)->max_entrypoints;
418 /* Get maximum number of attributs supported by the implementation */
419 int vaMaxNumConfigAttributes (
423 if( !vaDisplayIsValid(dpy) )
426 return CTX(dpy)->max_attributes;
429 VAStatus vaQueryConfigEntrypoints (
432 VAEntrypoint *entrypoints, /* out */
433 int *num_entrypoints /* out */
436 VADriverContextP ctx;
440 TRACE(vaQueryConfigEntrypoints);
441 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
444 VAStatus vaGetConfigAttributes (
447 VAEntrypoint entrypoint,
448 VAConfigAttrib *attrib_list, /* in/out */
452 VADriverContextP ctx;
456 TRACE(vaGetConfigAttributes);
457 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
460 VAStatus vaQueryConfigProfiles (
462 VAProfile *profile_list, /* out */
463 int *num_profiles /* out */
466 VADriverContextP ctx;
470 TRACE(vaQueryConfigProfiles);
471 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
474 VAStatus vaCreateConfig (
477 VAEntrypoint entrypoint,
478 VAConfigAttrib *attrib_list,
480 VAConfigID *config_id /* out */
483 VADriverContextP ctx;
487 TRACE(vaCreateConfig);
488 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
491 VAStatus vaDestroyConfig (
496 VADriverContextP ctx;
500 TRACE(vaDestroyConfig);
501 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
504 VAStatus vaQueryConfigAttributes (
506 VAConfigID config_id,
507 VAProfile *profile, /* out */
508 VAEntrypoint *entrypoint, /* out */
509 VAConfigAttrib *attrib_list,/* out */
510 int *num_attribs /* out */
513 VADriverContextP ctx;
517 TRACE(vaQueryConfigAttributes);
518 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
521 VAStatus vaCreateSurfaces (
527 VASurfaceID *surfaces /* out */
530 VADriverContextP ctx;
534 TRACE(vaCreateSurfaces);
535 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
538 VAStatus vaDestroySurfaces (
540 VASurfaceID *surface_list,
544 VADriverContextP ctx;
548 TRACE(vaDestroySurfaces);
549 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
552 VAStatus vaCreateContext (
554 VAConfigID config_id,
558 VASurfaceID *render_targets,
559 int num_render_targets,
560 VAContextID *context /* out */
563 VADriverContextP ctx;
567 TRACE(vaCreateContext);
568 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
569 flag, render_targets, num_render_targets, context );
572 VAStatus vaDestroyContext (
577 VADriverContextP ctx;
581 TRACE(vaDestroyContext);
582 return ctx->vtable.vaDestroyContext( ctx, context );
585 VAStatus vaCreateBuffer (
587 VAContextID context, /* in */
588 VABufferType type, /* in */
589 unsigned int size, /* in */
590 unsigned int num_elements, /* in */
592 VABufferID *buf_id /* out */
595 VADriverContextP ctx;
599 TRACE(vaCreateBuffer);
600 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
603 VAStatus vaBufferSetNumElements (
605 VABufferID buf_id, /* in */
606 unsigned int num_elements /* in */
609 VADriverContextP ctx;
613 TRACE(vaBufferSetNumElements);
614 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
618 VAStatus vaMapBuffer (
620 VABufferID buf_id, /* in */
621 void **pbuf /* out */
624 VADriverContextP ctx;
629 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
632 VAStatus vaUnmapBuffer (
634 VABufferID buf_id /* in */
637 VADriverContextP ctx;
641 TRACE(vaUnmapBuffer);
642 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
645 VAStatus vaDestroyBuffer (
650 VADriverContextP ctx;
654 TRACE(vaDestroyBuffer);
655 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
658 VAStatus vaBeginPicture (
661 VASurfaceID render_target
664 VADriverContextP ctx;
668 TRACE(vaBeginPicture);
669 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
672 VAStatus vaRenderPicture (
679 VADriverContextP ctx;
683 TRACE(vaRenderPicture);
684 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
687 VAStatus vaEndPicture (
692 VADriverContextP ctx;
697 return ctx->vtable.vaEndPicture( ctx, context );
700 VAStatus vaSyncSurface (
703 VASurfaceID render_target
706 VADriverContextP ctx;
710 TRACE(vaSyncSurface);
711 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
714 VAStatus vaQuerySurfaceStatus (
716 VASurfaceID render_target,
717 VASurfaceStatus *status /* out */
720 VADriverContextP ctx;
724 TRACE(vaQuerySurfaceStatus);
725 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
728 VAStatus vaPutSurface (
731 Drawable draw, /* X Drawable */
738 unsigned short destw,
739 unsigned short desth,
740 VARectangle *cliprects, /* client supplied clip list */
741 unsigned int number_cliprects, /* number of clip rects in the clip list */
742 unsigned int flags /* de-interlacing flags */
745 VADriverContextP ctx;
750 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
751 destx, desty, destw, desth,
752 cliprects, number_cliprects, flags );
755 /* Get maximum number of image formats supported by the implementation */
756 int vaMaxNumImageFormats (
760 if( !vaDisplayIsValid(dpy) )
763 return CTX(dpy)->max_image_formats;
766 VAStatus vaQueryImageFormats (
768 VAImageFormat *format_list, /* out */
769 int *num_formats /* out */
772 VADriverContextP ctx;
776 TRACE(vaQueryImageFormats);
777 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
781 * The width and height fields returned in the VAImage structure may get
782 * enlarged for some YUV formats. The size of the data buffer that needs
783 * to be allocated will be given in the "data_size" field in VAImage.
784 * Image data is not allocated by this function. The client should
785 * allocate the memory and fill in the VAImage structure's data field
786 * after looking at "data_size" returned from the library.
788 VAStatus vaCreateImage (
790 VAImageFormat *format,
793 VAImage *image /* out */
796 VADriverContextP ctx;
800 TRACE(vaCreateImage);
801 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
805 * Should call DestroyImage before destroying the surface it is bound to
807 VAStatus vaDestroyImage (
812 VADriverContextP ctx;
816 TRACE(vaDestroyImage);
817 return ctx->vtable.vaDestroyImage ( ctx, image);
820 VAStatus vaSetImagePalette (
823 unsigned char *palette
826 VADriverContextP ctx;
830 TRACE(vaSetImagePalette);
831 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
835 * Retrieve surface data into a VAImage
836 * Image must be in a format supported by the implementation
838 VAStatus vaGetImage (
841 int x, /* coordinates of the upper left source pixel */
843 unsigned int width, /* width and height of the region */
848 VADriverContextP ctx;
853 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
857 * Copy data from a VAImage to a surface
858 * Image must be in a format supported by the implementation
860 VAStatus vaPutImage (
872 VADriverContextP ctx;
877 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
881 * Similar to vaPutImage but with additional destination width
882 * and height arguments to enable scaling
884 VAStatus vaPutImage2 (
890 unsigned int src_width,
891 unsigned int src_height,
894 unsigned int dest_width,
895 unsigned int dest_height
898 VADriverContextP ctx;
903 return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
907 * Derive an VAImage from an existing surface.
908 * This interface will derive a VAImage and corresponding image buffer from
909 * an existing VA Surface. The image buffer can then be mapped/unmapped for
910 * direct CPU access. This operation is only possible on implementations with
911 * direct rendering capabilities and internal surface formats that can be
912 * represented with a VAImage. When the operation is not possible this interface
913 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
914 * to using vaCreateImage + vaPutImage to accomplish the same task in an
917 * Implementations should only return success when the resulting image buffer
918 * would be useable with vaMap/Unmap.
920 * When directly accessing a surface special care must be taken to insure
921 * proper synchronization with the graphics hardware. Clients should call
922 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
923 * rendering or currently being displayed by an overlay.
925 * Additionally nothing about the contents of a surface should be assumed
926 * following a vaPutSurface. Implementations are free to modify the surface for
927 * scaling or subpicture blending within a call to vaPutImage.
929 * Calls to vaPutImage or vaGetImage using the same surface from which the image
930 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
931 * vaGetImage with other surfaces is supported.
933 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
934 * image and image buffer structures will be destroyed; however, the underlying
935 * surface will remain unchanged until freed with vaDestroySurfaces.
937 VAStatus vaDeriveImage (
940 VAImage *image /* out */
943 VADriverContextP ctx;
947 TRACE(vaDeriveImage);
948 return ctx->vtable.vaDeriveImage ( ctx, surface, image );
952 /* Get maximum number of subpicture formats supported by the implementation */
953 int vaMaxNumSubpictureFormats (
957 if( !vaDisplayIsValid(dpy) )
960 return CTX(dpy)->max_subpic_formats;
964 * Query supported subpicture formats
965 * The caller must provide a "format_list" array that can hold at
966 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
967 * for each format to indicate additional capabilities for that format. The actual
968 * number of formats returned in "format_list" is returned in "num_formats".
970 VAStatus vaQuerySubpictureFormats (
972 VAImageFormat *format_list, /* out */
973 unsigned int *flags, /* out */
974 unsigned int *num_formats /* out */
977 VADriverContextP ctx;
981 TRACE(vaQuerySubpictureFormats);
982 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
986 * Subpictures are created with an image associated.
988 VAStatus vaCreateSubpicture (
991 VASubpictureID *subpicture /* out */
994 VADriverContextP ctx;
998 TRACE(vaCreateSubpicture);
999 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
1003 * Destroy the subpicture before destroying the image it is assocated to
1005 VAStatus vaDestroySubpicture (
1007 VASubpictureID subpicture
1010 VADriverContextP ctx;
1014 TRACE(vaDestroySubpicture);
1015 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1018 VAStatus vaSetSubpictureImage (
1020 VASubpictureID subpicture,
1024 VADriverContextP ctx;
1028 TRACE(vaSetSubpictureImage);
1029 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1032 #warning TODO: Remove vaSetSubpicturePalette in rev 0.29
1033 VAStatus vaSetSubpicturePalette (
1035 VASubpictureID subpicture,
1037 * pointer to an array holding the palette data. The size of the array is
1038 * num_palette_entries * entry_bytes in size. The order of the components
1039 * in the palette is described by the component_order in VASubpicture struct
1041 unsigned char *palette
1044 VADriverContextP ctx;
1048 TRACE(vaSetSubpicturePalette);
1049 return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
1053 * If chromakey is enabled, then the area where the source value falls within
1054 * the chromakey [min, max] range is transparent
1056 VAStatus vaSetSubpictureChromakey (
1058 VASubpictureID subpicture,
1059 unsigned int chromakey_min,
1060 unsigned int chromakey_max,
1061 unsigned int chromakey_mask
1064 VADriverContextP ctx;
1068 TRACE(vaSetSubpictureChromakey);
1069 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1074 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1075 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1076 * the overall alpha is per-pixel alpha multiplied by the global alpha
1078 VAStatus vaSetSubpictureGlobalAlpha (
1080 VASubpictureID subpicture,
1084 VADriverContextP ctx;
1088 TRACE(vaSetSubpictureGlobalAlpha);
1089 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1093 vaAssociateSubpicture associates the subpicture with the target_surface.
1094 It defines the region mapping between the subpicture and the target
1095 surface through source and destination rectangles (with the same width and height).
1096 Both will be displayed at the next call to vaPutSurface. Additional
1097 associations before the call to vaPutSurface simply overrides the association.
1099 VAStatus vaAssociateSubpicture (
1101 VASubpictureID subpicture,
1102 VASurfaceID *target_surfaces,
1104 short src_x, /* upper left offset in subpicture */
1106 short dest_x, /* upper left offset in surface */
1108 unsigned short width,
1109 unsigned short height,
1111 * whether to enable chroma-keying or global-alpha
1112 * see VA_SUBPICTURE_XXX values
1117 VADriverContextP ctx;
1121 TRACE(vaAssociateSubpicture);
1122 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1125 VAStatus vaAssociateSubpicture2 (
1127 VASubpictureID subpicture,
1128 VASurfaceID *target_surfaces,
1130 short src_x, /* upper left offset in subpicture */
1132 unsigned short src_width,
1133 unsigned short src_height,
1134 short dest_x, /* upper left offset in surface */
1136 unsigned short dest_width,
1137 unsigned short dest_height,
1139 * whether to enable chroma-keying or global-alpha
1140 * see VA_SUBPICTURE_XXX values
1145 VADriverContextP ctx;
1149 TRACE(vaAssociateSubpicture2);
1150 return ctx->vtable.vaAssociateSubpicture2 ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags );
1154 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1156 VAStatus vaDeassociateSubpicture (
1158 VASubpictureID subpicture,
1159 VASurfaceID *target_surfaces,
1163 VADriverContextP ctx;
1167 TRACE(vaDeassociateSubpicture);
1168 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1172 /* Get maximum number of display attributes supported by the implementation */
1173 int vaMaxNumDisplayAttributes (
1177 if( !vaDisplayIsValid(dpy) )
1180 return CTX(dpy)->max_display_attributes;
1184 * Query display attributes
1185 * The caller must provide a "attr_list" array that can hold at
1186 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1187 * returned in "attr_list" is returned in "num_attributes".
1189 VAStatus vaQueryDisplayAttributes (
1191 VADisplayAttribute *attr_list, /* out */
1192 int *num_attributes /* out */
1195 VADriverContextP ctx;
1199 TRACE(vaQueryDisplayAttributes);
1200 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1204 * Get display attributes
1205 * This function returns the current attribute values in "attr_list".
1206 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1207 * from vaQueryDisplayAttributes() can have their values retrieved.
1209 VAStatus vaGetDisplayAttributes (
1211 VADisplayAttribute *attr_list, /* in/out */
1215 VADriverContextP ctx;
1219 TRACE(vaGetDisplayAttributes);
1220 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1224 * Set display attributes
1225 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1226 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1227 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1229 VAStatus vaSetDisplayAttributes (
1231 VADisplayAttribute *attr_list,
1235 VADriverContextP ctx;
1239 TRACE(vaSetDisplayAttributes);
1240 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1244 #warning TODO: Remove vaDbgCopySurfaceToBuffer in rev 0.29
1245 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1246 VASurfaceID surface,
1247 void **buffer, /* out */
1248 unsigned int *stride /* out */
1251 VADriverContextP ctx;
1255 TRACE(vaDbgCopySurfaceToBuffer);
1256 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );