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"
44 #define DRIVER_INIT_FUNC "__vaDriverInit_0_31"
46 #define DRIVER_EXTENSION "_drv_video.so"
48 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
49 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
52 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
53 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
54 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
56 extern int trace_flag;
57 #define VA_TRACE(trace_func,...) \
59 va_TraceMsg("========%s========\n", __func__); \
60 trace_func(__VA_ARGS__); \
63 int vaDisplayIsValid(VADisplay dpy)
65 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
66 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
69 static void va_errorMessage(const char *msg, ...)
73 fprintf(stderr, "libva error: ");
75 vfprintf(stderr, msg, args);
79 static void va_infoMessage(const char *msg, ...)
83 fprintf(stderr, "libva: ");
85 vfprintf(stderr, msg, args);
89 static Bool va_checkVtable(void *ptr, char *function)
93 va_errorMessage("No valid vtable entry for va%s\n", function);
99 static Bool va_checkMaximum(int value, char *variable)
103 va_errorMessage("Failed to define max_%s in init\n", variable);
109 static Bool va_checkString(const char* value, char *variable)
113 va_errorMessage("Failed to define str_%s in init\n", variable);
119 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
121 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
123 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
126 static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
128 VADriverContextP ctx = CTX(dpy);
129 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
130 char *search_path = NULL;
134 if (geteuid() == getuid())
136 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
137 search_path = getenv("LIBVA_DRIVERS_PATH");
141 search_path = VA_DRIVERS_PATH;
144 search_path = strdup((const char *)search_path);
145 driver_dir = strtok_r((const char *)search_path, ":", &saveptr);
149 char *driver_path = (char *) malloc( strlen(driver_dir) +
150 strlen(driver_name) +
151 strlen(DRIVER_EXTENSION) + 2 );
152 strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
153 strncat( driver_path, "/", strlen("/") );
154 strncat( driver_path, driver_name, strlen(driver_name) );
155 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
157 va_infoMessage("Trying to open %s\n", driver_path);
159 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
161 handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
165 /* Don't give errors for non-existing files */
166 if (0 == access( driver_path, F_OK))
168 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
173 VADriverInit init_func;
174 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
177 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
182 vaStatus = (*init_func)(ctx);
184 if (VA_STATUS_SUCCESS == vaStatus)
186 CHECK_MAXIMUM(vaStatus, ctx, profiles);
187 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
188 CHECK_MAXIMUM(vaStatus, ctx, attributes);
189 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
190 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
191 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
192 CHECK_STRING(vaStatus, ctx, vendor);
193 CHECK_VTABLE(vaStatus, ctx, Terminate);
194 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
195 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
196 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
197 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
198 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
199 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
200 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
201 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
202 CHECK_VTABLE(vaStatus, ctx, CreateContext);
203 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
204 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
205 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
206 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
207 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
208 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
209 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
210 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
211 CHECK_VTABLE(vaStatus, ctx, EndPicture);
212 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
213 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
214 CHECK_VTABLE(vaStatus, ctx, PutSurface);
215 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
216 CHECK_VTABLE(vaStatus, ctx, CreateImage);
217 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
218 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
219 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
220 CHECK_VTABLE(vaStatus, ctx, GetImage);
221 CHECK_VTABLE(vaStatus, ctx, PutImage);
222 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
223 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
224 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
225 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
226 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
227 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
228 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
229 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
230 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
231 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
232 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
234 if (VA_STATUS_SUCCESS != vaStatus)
236 va_errorMessage("%s init failed\n", driver_path);
239 if (VA_STATUS_SUCCESS == vaStatus)
241 ctx->handle = handle;
249 driver_dir = strtok_r(NULL, ":", &saveptr);
257 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
259 VADriverContextP ctx;
260 if( !vaDisplayIsValid(dpy) )
264 if (NULL == ctx->handle)
267 return (VAPrivFunc) dlsym(ctx->handle, func);
272 * Returns a short english description of error_status
274 const char *vaErrorStr(VAStatus error_status)
278 case VA_STATUS_SUCCESS:
279 return "success (no error)";
280 case VA_STATUS_ERROR_OPERATION_FAILED:
281 return "operation failed";
282 case VA_STATUS_ERROR_ALLOCATION_FAILED:
283 return "resource allocation failed";
284 case VA_STATUS_ERROR_INVALID_DISPLAY:
285 return "invalid VADisplay";
286 case VA_STATUS_ERROR_INVALID_CONFIG:
287 return "invalid VAConfigID";
288 case VA_STATUS_ERROR_INVALID_CONTEXT:
289 return "invalid VAContextID";
290 case VA_STATUS_ERROR_INVALID_SURFACE:
291 return "invalid VASurfaceID";
292 case VA_STATUS_ERROR_INVALID_BUFFER:
293 return "invalid VABufferID";
294 case VA_STATUS_ERROR_INVALID_IMAGE:
295 return "invalid VAImageID";
296 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
297 return "invalid VASubpictureID";
298 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
299 return "attribute not supported";
300 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
301 return "list argument exceeds maximum number";
302 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
303 return "the requested VAProfile is not supported";
304 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
305 return "the requested VAEntryPoint is not supported";
306 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
307 return "the requested RT Format is not supported";
308 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
309 return "the requested VABufferType is not supported";
310 case VA_STATUS_ERROR_SURFACE_BUSY:
311 return "surface is in use";
312 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
313 return "flag not supported";
314 case VA_STATUS_ERROR_INVALID_PARAMETER:
315 return "invalid parameter";
316 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
317 return "resolution not supported";
318 case VA_STATUS_ERROR_UNIMPLEMENTED:
319 return "the requested function is not implemented";
320 case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
321 return "surface is in displaying (may by overlay)" ;
322 case VA_STATUS_ERROR_UNKNOWN:
323 return "unknown libva error";
325 return "unknown libva error / description missing";
328 VAStatus vaInitialize (
330 int *major_version, /* out */
331 int *minor_version /* out */
334 const char *driver_name_env = NULL;
335 char *driver_name = NULL;
342 va_infoMessage("libva version %s\n", VA_VERSION_S);
344 driver_name_env = getenv("LIBVA_DRIVER_NAME");
345 if (driver_name_env && geteuid() == getuid())
347 /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
348 driver_name = strdup(driver_name_env);
349 vaStatus = VA_STATUS_SUCCESS;
350 va_infoMessage("User requested driver '%s'\n", driver_name);
354 vaStatus = va_getDriverName(dpy, &driver_name);
355 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
358 if (VA_STATUS_SUCCESS == vaStatus)
360 vaStatus = va_openDriver(dpy, driver_name);
361 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
363 *major_version = VA_MAJOR_VERSION;
364 *minor_version = VA_MINOR_VERSION;
374 * After this call, all library internal resources will be cleaned up
376 VAStatus vaTerminate (
380 VAStatus vaStatus = VA_STATUS_SUCCESS;
381 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
382 VADriverContextP old_ctx;
389 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
390 dlclose(old_ctx->handle);
391 old_ctx->handle = NULL;
394 if (VA_STATUS_SUCCESS == vaStatus)
395 pDisplayContext->vaDestroy(pDisplayContext);
403 * vaQueryVendorString returns a pointer to a zero-terminated string
404 * describing some aspects of the VA implemenation on a specific
405 * hardware accelerator. The format of the returned string is:
406 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
407 * e.g. for the Intel GMA500 implementation, an example would be:
408 * "IntelGMA500-1.0-0.2-patch3
410 const char *vaQueryVendorString (
414 if( !vaDisplayIsValid(dpy) )
417 return CTX(dpy)->str_vendor;
421 /* Get maximum number of profiles supported by the implementation */
422 int vaMaxNumProfiles (
426 if( !vaDisplayIsValid(dpy) )
429 return CTX(dpy)->max_profiles;
432 /* Get maximum number of entrypoints supported by the implementation */
433 int vaMaxNumEntrypoints (
437 if( !vaDisplayIsValid(dpy) )
440 return CTX(dpy)->max_entrypoints;
444 /* Get maximum number of attributs supported by the implementation */
445 int vaMaxNumConfigAttributes (
449 if( !vaDisplayIsValid(dpy) )
452 return CTX(dpy)->max_attributes;
455 VAStatus vaQueryConfigEntrypoints (
458 VAEntrypoint *entrypoints, /* out */
459 int *num_entrypoints /* out */
462 VADriverContextP ctx;
466 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
469 VAStatus vaGetConfigAttributes (
472 VAEntrypoint entrypoint,
473 VAConfigAttrib *attrib_list, /* in/out */
477 VADriverContextP ctx;
481 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
484 VAStatus vaQueryConfigProfiles (
486 VAProfile *profile_list, /* out */
487 int *num_profiles /* out */
490 VADriverContextP ctx;
494 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
497 VAStatus vaCreateConfig (
500 VAEntrypoint entrypoint,
501 VAConfigAttrib *attrib_list,
503 VAConfigID *config_id /* out */
506 VADriverContextP ctx;
510 VA_TRACE(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
511 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
514 VAStatus vaDestroyConfig (
519 VADriverContextP ctx;
523 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
526 VAStatus vaQueryConfigAttributes (
528 VAConfigID config_id,
529 VAProfile *profile, /* out */
530 VAEntrypoint *entrypoint, /* out */
531 VAConfigAttrib *attrib_list,/* out */
532 int *num_attribs /* out */
535 VADriverContextP ctx;
539 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
542 VAStatus vaCreateSurfaces (
548 VASurfaceID *surfaces /* out */
551 VADriverContextP ctx;
555 VA_TRACE(va_TraceCreateSurface, dpy, width, height, format, num_surfaces, surfaces);
556 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
560 VAStatus vaDestroySurfaces (
562 VASurfaceID *surface_list,
566 VADriverContextP ctx;
570 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
573 VAStatus vaCreateContext (
575 VAConfigID config_id,
579 VASurfaceID *render_targets,
580 int num_render_targets,
581 VAContextID *context /* out */
584 VADriverContextP ctx;
588 VA_TRACE(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
589 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
590 flag, render_targets, num_render_targets, context );
593 VAStatus vaDestroyContext (
598 VADriverContextP ctx;
602 return ctx->vtable.vaDestroyContext( ctx, context );
605 VAStatus vaCreateBuffer (
607 VAContextID context, /* in */
608 VABufferType type, /* in */
609 unsigned int size, /* in */
610 unsigned int num_elements, /* in */
612 VABufferID *buf_id /* out */
615 VADriverContextP ctx;
619 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
622 VAStatus vaBufferSetNumElements (
624 VABufferID buf_id, /* in */
625 unsigned int num_elements /* in */
628 VADriverContextP ctx;
632 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
636 VAStatus vaMapBuffer (
638 VABufferID buf_id, /* in */
639 void **pbuf /* out */
642 VADriverContextP ctx;
646 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
649 VAStatus vaUnmapBuffer (
651 VABufferID buf_id /* in */
654 VADriverContextP ctx;
658 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
661 VAStatus vaDestroyBuffer (
666 VADriverContextP ctx;
670 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
673 VAStatus vaBufferInfo (
675 VAContextID context, /* in */
676 VABufferID buf_id, /* in */
677 VABufferType *type, /* out */
678 unsigned int *size, /* out */
679 unsigned int *num_elements /* out */
682 VADriverContextP ctx;
686 return ctx->vtable.vaBufferInfo( ctx, context, buf_id, type, size, num_elements );
689 VAStatus vaBeginPicture (
692 VASurfaceID render_target
695 VADriverContextP ctx;
699 VA_TRACE(va_TraceBeginPicture, ctx, context, render_target);
700 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
703 VAStatus vaRenderPicture (
710 VADriverContextP ctx;
714 VA_TRACE(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
715 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
718 VAStatus vaEndPicture (
724 VADriverContextP ctx;
728 va_status = ctx->vtable.vaEndPicture( ctx, context );
729 VA_TRACE(va_TraceEndPicture, dpy, context);
733 VAStatus vaSyncSurface (
735 VASurfaceID render_target
738 VADriverContextP ctx;
742 return ctx->vtable.vaSyncSurface( ctx, render_target );
745 VAStatus vaQuerySurfaceStatus (
747 VASurfaceID render_target,
748 VASurfaceStatus *status /* out */
751 VADriverContextP ctx;
755 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
758 /* Get maximum number of image formats supported by the implementation */
759 int vaMaxNumImageFormats (
763 if( !vaDisplayIsValid(dpy) )
766 return CTX(dpy)->max_image_formats;
769 VAStatus vaQueryImageFormats (
771 VAImageFormat *format_list, /* out */
772 int *num_formats /* out */
775 VADriverContextP ctx;
779 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
783 * The width and height fields returned in the VAImage structure may get
784 * enlarged for some YUV formats. The size of the data buffer that needs
785 * to be allocated will be given in the "data_size" field in VAImage.
786 * Image data is not allocated by this function. The client should
787 * allocate the memory and fill in the VAImage structure's data field
788 * after looking at "data_size" returned from the library.
790 VAStatus vaCreateImage (
792 VAImageFormat *format,
795 VAImage *image /* out */
798 VADriverContextP ctx;
802 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
806 * Should call DestroyImage before destroying the surface it is bound to
808 VAStatus vaDestroyImage (
813 VADriverContextP ctx;
817 return ctx->vtable.vaDestroyImage ( ctx, image);
820 VAStatus vaSetImagePalette (
823 unsigned char *palette
826 VADriverContextP ctx;
830 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
834 * Retrieve surface data into a VAImage
835 * Image must be in a format supported by the implementation
837 VAStatus vaGetImage (
840 int x, /* coordinates of the upper left source pixel */
842 unsigned int width, /* width and height of the region */
847 VADriverContextP ctx;
851 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
855 * Copy data from a VAImage to a surface
856 * Image must be in a format supported by the implementation
858 VAStatus vaPutImage (
864 unsigned int src_width,
865 unsigned int src_height,
868 unsigned int dest_width,
869 unsigned int dest_height
872 VADriverContextP ctx;
876 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
880 * Derive an VAImage from an existing surface.
881 * This interface will derive a VAImage and corresponding image buffer from
882 * an existing VA Surface. The image buffer can then be mapped/unmapped for
883 * direct CPU access. This operation is only possible on implementations with
884 * direct rendering capabilities and internal surface formats that can be
885 * represented with a VAImage. When the operation is not possible this interface
886 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
887 * to using vaCreateImage + vaPutImage to accomplish the same task in an
890 * Implementations should only return success when the resulting image buffer
891 * would be useable with vaMap/Unmap.
893 * When directly accessing a surface special care must be taken to insure
894 * proper synchronization with the graphics hardware. Clients should call
895 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
896 * rendering or currently being displayed by an overlay.
898 * Additionally nothing about the contents of a surface should be assumed
899 * following a vaPutSurface. Implementations are free to modify the surface for
900 * scaling or subpicture blending within a call to vaPutImage.
902 * Calls to vaPutImage or vaGetImage using the same surface from which the image
903 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
904 * vaGetImage with other surfaces is supported.
906 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
907 * image and image buffer structures will be destroyed; however, the underlying
908 * surface will remain unchanged until freed with vaDestroySurfaces.
910 VAStatus vaDeriveImage (
913 VAImage *image /* out */
916 VADriverContextP ctx;
920 return ctx->vtable.vaDeriveImage ( ctx, surface, image );
924 /* Get maximum number of subpicture formats supported by the implementation */
925 int vaMaxNumSubpictureFormats (
929 if( !vaDisplayIsValid(dpy) )
932 return CTX(dpy)->max_subpic_formats;
936 * Query supported subpicture formats
937 * The caller must provide a "format_list" array that can hold at
938 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
939 * for each format to indicate additional capabilities for that format. The actual
940 * number of formats returned in "format_list" is returned in "num_formats".
942 VAStatus vaQuerySubpictureFormats (
944 VAImageFormat *format_list, /* out */
945 unsigned int *flags, /* out */
946 unsigned int *num_formats /* out */
949 VADriverContextP ctx;
953 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
957 * Subpictures are created with an image associated.
959 VAStatus vaCreateSubpicture (
962 VASubpictureID *subpicture /* out */
965 VADriverContextP ctx;
969 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
973 * Destroy the subpicture before destroying the image it is assocated to
975 VAStatus vaDestroySubpicture (
977 VASubpictureID subpicture
980 VADriverContextP ctx;
984 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
987 VAStatus vaSetSubpictureImage (
989 VASubpictureID subpicture,
993 VADriverContextP ctx;
997 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1002 * If chromakey is enabled, then the area where the source value falls within
1003 * the chromakey [min, max] range is transparent
1005 VAStatus vaSetSubpictureChromakey (
1007 VASubpictureID subpicture,
1008 unsigned int chromakey_min,
1009 unsigned int chromakey_max,
1010 unsigned int chromakey_mask
1013 VADriverContextP ctx;
1017 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1022 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1023 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1024 * the overall alpha is per-pixel alpha multiplied by the global alpha
1026 VAStatus vaSetSubpictureGlobalAlpha (
1028 VASubpictureID subpicture,
1032 VADriverContextP ctx;
1036 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1040 vaAssociateSubpicture associates the subpicture with the target_surface.
1041 It defines the region mapping between the subpicture and the target
1042 surface through source and destination rectangles (with the same width and height).
1043 Both will be displayed at the next call to vaPutSurface. Additional
1044 associations before the call to vaPutSurface simply overrides the association.
1046 VAStatus vaAssociateSubpicture (
1048 VASubpictureID subpicture,
1049 VASurfaceID *target_surfaces,
1051 short src_x, /* upper left offset in subpicture */
1053 unsigned short src_width,
1054 unsigned short src_height,
1055 short dest_x, /* upper left offset in surface */
1057 unsigned short dest_width,
1058 unsigned short dest_height,
1060 * whether to enable chroma-keying or global-alpha
1061 * see VA_SUBPICTURE_XXX values
1066 VADriverContextP ctx;
1070 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 );
1074 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1076 VAStatus vaDeassociateSubpicture (
1078 VASubpictureID subpicture,
1079 VASurfaceID *target_surfaces,
1083 VADriverContextP ctx;
1087 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1091 /* Get maximum number of display attributes supported by the implementation */
1092 int vaMaxNumDisplayAttributes (
1096 if( !vaDisplayIsValid(dpy) )
1099 return CTX(dpy)->max_display_attributes;
1103 * Query display attributes
1104 * The caller must provide a "attr_list" array that can hold at
1105 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1106 * returned in "attr_list" is returned in "num_attributes".
1108 VAStatus vaQueryDisplayAttributes (
1110 VADisplayAttribute *attr_list, /* out */
1111 int *num_attributes /* out */
1114 VADriverContextP ctx;
1118 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1122 * Get display attributes
1123 * This function returns the current attribute values in "attr_list".
1124 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1125 * from vaQueryDisplayAttributes() can have their values retrieved.
1127 VAStatus vaGetDisplayAttributes (
1129 VADisplayAttribute *attr_list, /* in/out */
1133 VADriverContextP ctx;
1137 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1141 * Set display attributes
1142 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1143 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1144 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1146 VAStatus vaSetDisplayAttributes (
1148 VADisplayAttribute *attr_list,
1152 VADriverContextP ctx;
1156 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1159 VAStatus vaLockSurface(VADisplay dpy,
1160 VASurfaceID surface,
1161 unsigned int *fourcc, /* following are output argument */
1162 unsigned int *luma_stride,
1163 unsigned int *chroma_u_stride,
1164 unsigned int *chroma_v_stride,
1165 unsigned int *luma_offset,
1166 unsigned int *chroma_u_offset,
1167 unsigned int *chroma_v_offset,
1168 unsigned int *buffer_name,
1172 VADriverContextP ctx;
1176 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);
1180 VAStatus vaUnlockSurface(VADisplay dpy,
1184 VADriverContextP ctx;
1188 return ctx->vtable.vaUnlockSurface( ctx, surface );