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"
46 #define DRIVER_INIT_FUNC "__vaDriverInit_0_31"
48 #define DRIVER_EXTENSION "_drv_video.so"
50 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
51 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
54 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
55 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
56 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
58 extern int trace_flag;
59 #define VA_TRACE(trace_func,...) \
61 trace_func(__VA_ARGS__); \
65 * read a config "env" for libva.conf or from environment setting
66 * liva.conf has higher priority
67 * return 0: the "env" is set, and the value is copied into env_value
68 * 1: the env is not set
70 int va_parseConfig(char *env, char *env_value)
72 char *token, *value, *saveptr;
80 fp = fopen("/etc/libva.conf", "r");
81 while (fp && (fgets(oneline, 1024, fp) != NULL)) {
82 if (strlen(oneline) == 1)
84 token = strtok_r(oneline, "=\n", &saveptr);
85 value = strtok_r(NULL, "=\n", &saveptr);
87 if (NULL == token || NULL == value)
90 if (strcmp(token, env) == 0) {
92 strncpy(env_value,value, 1024);
102 /* no setting in config file, use env setting */
105 strncpy(env_value, getenv(env), 1024);
113 int vaDisplayIsValid(VADisplay dpy)
115 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
116 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
119 void va_errorMessage(const char *msg, ...)
123 fprintf(stderr, "libva error: ");
125 vfprintf(stderr, msg, args);
129 void va_infoMessage(const char *msg, ...)
133 fprintf(stderr, "libva: ");
135 vfprintf(stderr, msg, args);
139 static Bool va_checkVtable(void *ptr, char *function)
143 va_errorMessage("No valid vtable entry for va%s\n", function);
149 static Bool va_checkMaximum(int value, char *variable)
153 va_errorMessage("Failed to define max_%s in init\n", variable);
159 static Bool va_checkString(const char* value, char *variable)
163 va_errorMessage("Failed to define str_%s in init\n", variable);
169 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
171 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
173 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
176 static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
178 VADriverContextP ctx = CTX(dpy);
179 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
180 char *search_path = NULL;
184 if (geteuid() == getuid())
186 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
187 search_path = getenv("LIBVA_DRIVERS_PATH");
191 search_path = VA_DRIVERS_PATH;
194 search_path = strdup((const char *)search_path);
195 driver_dir = strtok_r((const char *)search_path, ":", &saveptr);
199 char *driver_path = (char *) malloc( strlen(driver_dir) +
200 strlen(driver_name) +
201 strlen(DRIVER_EXTENSION) + 2 );
202 strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
203 strncat( driver_path, "/", strlen("/") );
204 strncat( driver_path, driver_name, strlen(driver_name) );
205 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
207 va_infoMessage("Trying to open %s\n", driver_path);
209 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
211 handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
215 /* Don't give errors for non-existing files */
216 if (0 == access( driver_path, F_OK))
218 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
223 VADriverInit init_func;
224 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
227 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
232 vaStatus = (*init_func)(ctx);
234 if (VA_STATUS_SUCCESS == vaStatus)
236 CHECK_MAXIMUM(vaStatus, ctx, profiles);
237 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
238 CHECK_MAXIMUM(vaStatus, ctx, attributes);
239 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
240 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
241 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
242 CHECK_STRING(vaStatus, ctx, vendor);
243 CHECK_VTABLE(vaStatus, ctx, Terminate);
244 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
245 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
246 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
247 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
248 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
249 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
250 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
251 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
252 CHECK_VTABLE(vaStatus, ctx, CreateContext);
253 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
254 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
255 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
256 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
257 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
258 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
259 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
260 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
261 CHECK_VTABLE(vaStatus, ctx, EndPicture);
262 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
263 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
264 CHECK_VTABLE(vaStatus, ctx, PutSurface);
265 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
266 CHECK_VTABLE(vaStatus, ctx, CreateImage);
267 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
268 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
269 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
270 CHECK_VTABLE(vaStatus, ctx, GetImage);
271 CHECK_VTABLE(vaStatus, ctx, PutImage);
272 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
273 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
274 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
275 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
276 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
277 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
278 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
279 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
280 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
281 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
282 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
284 if (VA_STATUS_SUCCESS != vaStatus)
286 va_errorMessage("%s init failed\n", driver_path);
289 if (VA_STATUS_SUCCESS == vaStatus)
291 ctx->handle = handle;
299 driver_dir = strtok_r(NULL, ":", &saveptr);
307 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
309 VADriverContextP ctx;
310 if( !vaDisplayIsValid(dpy) )
314 if (NULL == ctx->handle)
317 return (VAPrivFunc) dlsym(ctx->handle, func);
322 * Returns a short english description of error_status
324 const char *vaErrorStr(VAStatus error_status)
328 case VA_STATUS_SUCCESS:
329 return "success (no error)";
330 case VA_STATUS_ERROR_OPERATION_FAILED:
331 return "operation failed";
332 case VA_STATUS_ERROR_ALLOCATION_FAILED:
333 return "resource allocation failed";
334 case VA_STATUS_ERROR_INVALID_DISPLAY:
335 return "invalid VADisplay";
336 case VA_STATUS_ERROR_INVALID_CONFIG:
337 return "invalid VAConfigID";
338 case VA_STATUS_ERROR_INVALID_CONTEXT:
339 return "invalid VAContextID";
340 case VA_STATUS_ERROR_INVALID_SURFACE:
341 return "invalid VASurfaceID";
342 case VA_STATUS_ERROR_INVALID_BUFFER:
343 return "invalid VABufferID";
344 case VA_STATUS_ERROR_INVALID_IMAGE:
345 return "invalid VAImageID";
346 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
347 return "invalid VASubpictureID";
348 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
349 return "attribute not supported";
350 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
351 return "list argument exceeds maximum number";
352 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
353 return "the requested VAProfile is not supported";
354 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
355 return "the requested VAEntryPoint is not supported";
356 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
357 return "the requested RT Format is not supported";
358 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
359 return "the requested VABufferType is not supported";
360 case VA_STATUS_ERROR_SURFACE_BUSY:
361 return "surface is in use";
362 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
363 return "flag not supported";
364 case VA_STATUS_ERROR_INVALID_PARAMETER:
365 return "invalid parameter";
366 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
367 return "resolution not supported";
368 case VA_STATUS_ERROR_UNIMPLEMENTED:
369 return "the requested function is not implemented";
370 case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
371 return "surface is in displaying (may by overlay)" ;
372 case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT:
373 return "invalid VAImageFormat";
374 case VA_STATUS_ERROR_UNKNOWN:
375 return "unknown libva error";
377 return "unknown libva error / description missing";
380 VAStatus vaInitialize (
382 int *major_version, /* out */
383 int *minor_version /* out */
386 const char *driver_name_env = NULL;
387 char *driver_name = NULL;
396 va_infoMessage("libva version %s\n", VA_VERSION_S);
398 driver_name_env = getenv("LIBVA_DRIVER_NAME");
399 if (driver_name_env && geteuid() == getuid())
401 /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
402 driver_name = strdup(driver_name_env);
403 vaStatus = VA_STATUS_SUCCESS;
404 va_infoMessage("User requested driver '%s'\n", driver_name);
408 vaStatus = va_getDriverName(dpy, &driver_name);
409 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
412 if (VA_STATUS_SUCCESS == vaStatus)
414 vaStatus = va_openDriver(dpy, driver_name);
415 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
417 *major_version = VA_MAJOR_VERSION;
418 *minor_version = VA_MINOR_VERSION;
428 * After this call, all library internal resources will be cleaned up
430 VAStatus vaTerminate (
434 VAStatus vaStatus = VA_STATUS_SUCCESS;
435 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
436 VADriverContextP old_ctx;
443 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
444 dlclose(old_ctx->handle);
445 old_ctx->handle = NULL;
448 if (VA_STATUS_SUCCESS == vaStatus)
449 pDisplayContext->vaDestroy(pDisplayContext);
459 * vaQueryVendorString returns a pointer to a zero-terminated string
460 * describing some aspects of the VA implemenation on a specific
461 * hardware accelerator. The format of the returned string is:
462 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
463 * e.g. for the Intel GMA500 implementation, an example would be:
464 * "IntelGMA500-1.0-0.2-patch3
466 const char *vaQueryVendorString (
470 if( !vaDisplayIsValid(dpy) )
473 return CTX(dpy)->str_vendor;
477 /* Get maximum number of profiles supported by the implementation */
478 int vaMaxNumProfiles (
482 if( !vaDisplayIsValid(dpy) )
485 return CTX(dpy)->max_profiles;
488 /* Get maximum number of entrypoints supported by the implementation */
489 int vaMaxNumEntrypoints (
493 if( !vaDisplayIsValid(dpy) )
496 return CTX(dpy)->max_entrypoints;
500 /* Get maximum number of attributs supported by the implementation */
501 int vaMaxNumConfigAttributes (
505 if( !vaDisplayIsValid(dpy) )
508 return CTX(dpy)->max_attributes;
511 VAStatus vaQueryConfigEntrypoints (
514 VAEntrypoint *entrypoints, /* out */
515 int *num_entrypoints /* out */
518 VADriverContextP ctx;
522 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
525 VAStatus vaGetConfigAttributes (
528 VAEntrypoint entrypoint,
529 VAConfigAttrib *attrib_list, /* in/out */
533 VADriverContextP ctx;
537 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
540 VAStatus vaQueryConfigProfiles (
542 VAProfile *profile_list, /* out */
543 int *num_profiles /* out */
546 VADriverContextP ctx;
550 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
553 VAStatus vaCreateConfig (
556 VAEntrypoint entrypoint,
557 VAConfigAttrib *attrib_list,
559 VAConfigID *config_id /* out */
562 VADriverContextP ctx;
566 VA_TRACE(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
567 va_FoolCreateConfig(dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
568 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
571 VAStatus vaDestroyConfig (
576 VADriverContextP ctx;
580 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
583 VAStatus vaQueryConfigAttributes (
585 VAConfigID config_id,
586 VAProfile *profile, /* out */
587 VAEntrypoint *entrypoint, /* out */
588 VAConfigAttrib *attrib_list,/* out */
589 int *num_attribs /* out */
592 VADriverContextP ctx;
596 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
599 VAStatus vaCreateSurfaces (
605 VASurfaceID *surfaces /* out */
608 VADriverContextP ctx;
613 VA_TRACE(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
615 ret = ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
616 va_FoolCreateSurfaces(dpy, width, height, format, num_surfaces, surfaces);
621 VAStatus vaDestroySurfaces (
623 VASurfaceID *surface_list,
627 VADriverContextP ctx;
631 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
634 VAStatus vaCreateContext (
636 VAConfigID config_id,
640 VASurfaceID *render_targets,
641 int num_render_targets,
642 VAContextID *context /* out */
645 VADriverContextP ctx;
649 VA_TRACE(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
650 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
651 flag, render_targets, num_render_targets, context );
654 VAStatus vaDestroyContext (
659 VADriverContextP ctx;
663 return ctx->vtable.vaDestroyContext( ctx, context );
666 VAStatus vaCreateBuffer (
668 VAContextID context, /* in */
669 VABufferType type, /* in */
670 unsigned int size, /* in */
671 unsigned int num_elements, /* in */
673 VABufferID *buf_id /* out */
676 VADriverContextP ctx;
680 if (va_FoolCreateBuffer(dpy, context, type, size, num_elements, data, buf_id))
681 return VA_STATUS_SUCCESS;
682 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
685 VAStatus vaBufferSetNumElements (
687 VABufferID buf_id, /* in */
688 unsigned int num_elements /* in */
691 VADriverContextP ctx;
695 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
699 VAStatus vaMapBuffer (
701 VABufferID buf_id, /* in */
702 void **pbuf /* out */
705 VADriverContextP ctx;
711 if (va_FoolMapBuffer(dpy, buf_id, pbuf))
712 return VA_STATUS_SUCCESS;
713 va_status = ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
715 if (va_status == VA_STATUS_SUCCESS)
716 VA_TRACE(va_TraceMapBuffer, dpy, buf_id, pbuf);
721 VAStatus vaUnmapBuffer (
723 VABufferID buf_id /* in */
726 VADriverContextP ctx;
730 if (va_FoolUnmapBuffer(dpy, buf_id))
731 return VA_STATUS_SUCCESS;
732 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
735 VAStatus vaDestroyBuffer (
740 VADriverContextP ctx;
744 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
747 VAStatus vaBufferInfo (
749 VAContextID context, /* in */
750 VABufferID buf_id, /* in */
751 VABufferType *type, /* out */
752 unsigned int *size, /* out */
753 unsigned int *num_elements /* out */
756 VADriverContextP ctx;
760 return ctx->vtable.vaBufferInfo( ctx, context, buf_id, type, size, num_elements );
763 VAStatus vaBeginPicture (
766 VASurfaceID render_target
769 VADriverContextP ctx;
773 VA_TRACE(va_TraceBeginPicture, dpy, context, render_target);
775 if (va_FoolBeginPicture(dpy, context, render_target))
776 return VA_STATUS_SUCCESS;
778 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
781 VAStatus vaRenderPicture (
788 VADriverContextP ctx;
792 if (va_FoolRenderPicture(dpy, context, buffers, num_buffers))
793 return VA_STATUS_SUCCESS;
795 VA_TRACE(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
797 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
800 VAStatus vaEndPicture (
806 VADriverContextP ctx;
810 if (va_FoolEndPicture(dpy, context)) {
811 VA_TRACE(va_TraceEndPicture, dpy, context);
812 return VA_STATUS_SUCCESS;
815 va_status = ctx->vtable.vaEndPicture( ctx, context );
817 VA_TRACE(va_TraceEndPicture, dpy, context);
822 VAStatus vaSyncSurface (
824 VASurfaceID render_target
827 VADriverContextP ctx;
831 if (va_FoolSyncSurface( dpy, render_target))
832 return VA_STATUS_SUCCESS;
834 return ctx->vtable.vaSyncSurface( ctx, render_target );
837 VAStatus vaQuerySurfaceStatus (
839 VASurfaceID render_target,
840 VASurfaceStatus *status /* out */
843 VADriverContextP ctx;
847 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
850 /* Get maximum number of image formats supported by the implementation */
851 int vaMaxNumImageFormats (
855 if( !vaDisplayIsValid(dpy) )
858 return CTX(dpy)->max_image_formats;
861 VAStatus vaQueryImageFormats (
863 VAImageFormat *format_list, /* out */
864 int *num_formats /* out */
867 VADriverContextP ctx;
871 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
875 * The width and height fields returned in the VAImage structure may get
876 * enlarged for some YUV formats. The size of the data buffer that needs
877 * to be allocated will be given in the "data_size" field in VAImage.
878 * Image data is not allocated by this function. The client should
879 * allocate the memory and fill in the VAImage structure's data field
880 * after looking at "data_size" returned from the library.
882 VAStatus vaCreateImage (
884 VAImageFormat *format,
887 VAImage *image /* out */
890 VADriverContextP ctx;
894 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
898 * Should call DestroyImage before destroying the surface it is bound to
900 VAStatus vaDestroyImage (
905 VADriverContextP ctx;
909 return ctx->vtable.vaDestroyImage ( ctx, image);
912 VAStatus vaSetImagePalette (
915 unsigned char *palette
918 VADriverContextP ctx;
922 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
926 * Retrieve surface data into a VAImage
927 * Image must be in a format supported by the implementation
929 VAStatus vaGetImage (
932 int x, /* coordinates of the upper left source pixel */
934 unsigned int width, /* width and height of the region */
939 VADriverContextP ctx;
943 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
947 * Copy data from a VAImage to a surface
948 * Image must be in a format supported by the implementation
950 VAStatus vaPutImage (
956 unsigned int src_width,
957 unsigned int src_height,
960 unsigned int dest_width,
961 unsigned int dest_height
964 VADriverContextP ctx;
968 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
972 * Derive an VAImage from an existing surface.
973 * This interface will derive a VAImage and corresponding image buffer from
974 * an existing VA Surface. The image buffer can then be mapped/unmapped for
975 * direct CPU access. This operation is only possible on implementations with
976 * direct rendering capabilities and internal surface formats that can be
977 * represented with a VAImage. When the operation is not possible this interface
978 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
979 * to using vaCreateImage + vaPutImage to accomplish the same task in an
982 * Implementations should only return success when the resulting image buffer
983 * would be useable with vaMap/Unmap.
985 * When directly accessing a surface special care must be taken to insure
986 * proper synchronization with the graphics hardware. Clients should call
987 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
988 * rendering or currently being displayed by an overlay.
990 * Additionally nothing about the contents of a surface should be assumed
991 * following a vaPutSurface. Implementations are free to modify the surface for
992 * scaling or subpicture blending within a call to vaPutImage.
994 * Calls to vaPutImage or vaGetImage using the same surface from which the image
995 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
996 * vaGetImage with other surfaces is supported.
998 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
999 * image and image buffer structures will be destroyed; however, the underlying
1000 * surface will remain unchanged until freed with vaDestroySurfaces.
1002 VAStatus vaDeriveImage (
1004 VASurfaceID surface,
1005 VAImage *image /* out */
1008 VADriverContextP ctx;
1012 return ctx->vtable.vaDeriveImage ( ctx, surface, image );
1016 /* Get maximum number of subpicture formats supported by the implementation */
1017 int vaMaxNumSubpictureFormats (
1021 if( !vaDisplayIsValid(dpy) )
1024 return CTX(dpy)->max_subpic_formats;
1028 * Query supported subpicture formats
1029 * The caller must provide a "format_list" array that can hold at
1030 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
1031 * for each format to indicate additional capabilities for that format. The actual
1032 * number of formats returned in "format_list" is returned in "num_formats".
1034 VAStatus vaQuerySubpictureFormats (
1036 VAImageFormat *format_list, /* out */
1037 unsigned int *flags, /* out */
1038 unsigned int *num_formats /* out */
1041 VADriverContextP ctx;
1045 if (va_FoolQuerySubpictureFormats(dpy, format_list, flags, num_formats))
1046 return VA_STATUS_SUCCESS;
1047 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
1051 * Subpictures are created with an image associated.
1053 VAStatus vaCreateSubpicture (
1056 VASubpictureID *subpicture /* out */
1059 VADriverContextP ctx;
1063 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
1067 * Destroy the subpicture before destroying the image it is assocated to
1069 VAStatus vaDestroySubpicture (
1071 VASubpictureID subpicture
1074 VADriverContextP ctx;
1078 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1081 VAStatus vaSetSubpictureImage (
1083 VASubpictureID subpicture,
1087 VADriverContextP ctx;
1091 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1096 * If chromakey is enabled, then the area where the source value falls within
1097 * the chromakey [min, max] range is transparent
1099 VAStatus vaSetSubpictureChromakey (
1101 VASubpictureID subpicture,
1102 unsigned int chromakey_min,
1103 unsigned int chromakey_max,
1104 unsigned int chromakey_mask
1107 VADriverContextP ctx;
1111 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1116 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1117 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1118 * the overall alpha is per-pixel alpha multiplied by the global alpha
1120 VAStatus vaSetSubpictureGlobalAlpha (
1122 VASubpictureID subpicture,
1126 VADriverContextP ctx;
1130 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1134 vaAssociateSubpicture associates the subpicture with the target_surface.
1135 It defines the region mapping between the subpicture and the target
1136 surface through source and destination rectangles (with the same width and height).
1137 Both will be displayed at the next call to vaPutSurface. Additional
1138 associations before the call to vaPutSurface simply overrides the association.
1140 VAStatus vaAssociateSubpicture (
1142 VASubpictureID subpicture,
1143 VASurfaceID *target_surfaces,
1145 short src_x, /* upper left offset in subpicture */
1147 unsigned short src_width,
1148 unsigned short src_height,
1149 short dest_x, /* upper left offset in surface */
1151 unsigned short dest_width,
1152 unsigned short dest_height,
1154 * whether to enable chroma-keying or global-alpha
1155 * see VA_SUBPICTURE_XXX values
1160 VADriverContextP ctx;
1164 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags );
1168 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1170 VAStatus vaDeassociateSubpicture (
1172 VASubpictureID subpicture,
1173 VASurfaceID *target_surfaces,
1177 VADriverContextP ctx;
1181 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1185 /* Get maximum number of display attributes supported by the implementation */
1186 int vaMaxNumDisplayAttributes (
1192 if( !vaDisplayIsValid(dpy) )
1195 tmp = CTX(dpy)->max_display_attributes;
1197 VA_TRACE(va_TraceMaxNumDisplayAttributes, dpy, tmp);
1203 * Query display attributes
1204 * The caller must provide a "attr_list" array that can hold at
1205 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1206 * returned in "attr_list" is returned in "num_attributes".
1208 VAStatus vaQueryDisplayAttributes (
1210 VADisplayAttribute *attr_list, /* out */
1211 int *num_attributes /* out */
1214 VADriverContextP ctx;
1220 va_status = ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1222 VA_TRACE(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
1229 * Get display attributes
1230 * This function returns the current attribute values in "attr_list".
1231 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1232 * from vaQueryDisplayAttributes() can have their values retrieved.
1234 VAStatus vaGetDisplayAttributes (
1236 VADisplayAttribute *attr_list, /* in/out */
1240 VADriverContextP ctx;
1246 va_status = ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1248 VA_TRACE(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
1254 * Set display attributes
1255 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1256 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1257 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1259 VAStatus vaSetDisplayAttributes (
1261 VADisplayAttribute *attr_list,
1265 VADriverContextP ctx;
1269 VA_TRACE(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
1272 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1275 VAStatus vaLockSurface(VADisplay dpy,
1276 VASurfaceID surface,
1277 unsigned int *fourcc, /* following are output argument */
1278 unsigned int *luma_stride,
1279 unsigned int *chroma_u_stride,
1280 unsigned int *chroma_v_stride,
1281 unsigned int *luma_offset,
1282 unsigned int *chroma_u_offset,
1283 unsigned int *chroma_v_offset,
1284 unsigned int *buffer_name,
1288 VADriverContextP ctx;
1292 return ctx->vtable.vaLockSurface( ctx, surface, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, buffer_name, buffer);
1296 VAStatus vaUnlockSurface(VADisplay dpy,
1300 VADriverContextP ctx;
1304 return ctx->vtable.vaUnlockSurface( ctx, surface );