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"
28 #include "va_version.h"
37 #define VA_STR_VERSION VA_BUILD_DATE VA_BUILD_GIT
39 #define VA_MAJOR_VERSION 0
40 #define VA_MINOR_VERSION 30
41 #define DRIVER_INIT_FUNC "__vaDriverInit_0_30"
43 #define DEFAULT_DRIVER_DIR "/usr/lib/dri/"
44 #define DRIVER_EXTENSION "_drv_video.so"
46 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
47 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
50 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
51 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
52 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
54 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
56 static int va_debug_trace = 0;
58 int vaDisplayIsValid(VADisplay dpy);
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 strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
147 strncat( driver_path, "/", strlen("/") );
148 strncat( driver_path, driver_name, strlen(driver_name) );
149 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
151 va_infoMessage("Trying to open %s\n", driver_path);
153 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
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, SetSubpictureChromakey);
219 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
220 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
221 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture2);
222 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
223 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
224 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
225 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
226 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
228 if (VA_STATUS_SUCCESS != vaStatus)
230 va_errorMessage("%s init failed\n", driver_path);
233 if (VA_STATUS_SUCCESS == vaStatus)
235 ctx->handle = handle;
243 driver_dir = strtok_r(NULL, ":", &saveptr);
251 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
253 VADriverContextP ctx;
254 if( !vaDisplayIsValid(dpy) )
258 if (NULL == ctx->handle)
261 return (VAPrivFunc) dlsym(ctx->handle, func);
266 * Returns a short english description of error_status
268 const char *vaErrorStr(VAStatus error_status)
272 case VA_STATUS_SUCCESS:
273 return "success (no error)";
274 case VA_STATUS_ERROR_OPERATION_FAILED:
275 return "operation failed";
276 case VA_STATUS_ERROR_ALLOCATION_FAILED:
277 return "resource allocation failed";
278 case VA_STATUS_ERROR_INVALID_DISPLAY:
279 return "invalid VADisplay";
280 case VA_STATUS_ERROR_INVALID_CONFIG:
281 return "invalid VAConfigID";
282 case VA_STATUS_ERROR_INVALID_CONTEXT:
283 return "invalid VAContextID";
284 case VA_STATUS_ERROR_INVALID_SURFACE:
285 return "invalid VASurfaceID";
286 case VA_STATUS_ERROR_INVALID_BUFFER:
287 return "invalid VABufferID";
288 case VA_STATUS_ERROR_INVALID_IMAGE:
289 return "invalid VAImageID";
290 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
291 return "invalid VASubpictureID";
292 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
293 return "attribute not supported";
294 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
295 return "list argument exceeds maximum number";
296 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
297 return "the requested VAProfile is not supported";
298 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
299 return "the requested VAEntryPoint is not supported";
300 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
301 return "the requested RT Format is not supported";
302 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
303 return "the requested VABufferType is not supported";
304 case VA_STATUS_ERROR_SURFACE_BUSY:
305 return "surface is in use";
306 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
307 return "flag not supported";
308 case VA_STATUS_ERROR_INVALID_PARAMETER:
309 return "invalid parameter";
310 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
311 return "resolution not supported";
312 case VA_STATUS_ERROR_UNKNOWN:
313 return "unknown libva error";
315 return "unknown libva error / description missing";
318 VAStatus vaInitialize (
320 int *major_version, /* out */
321 int *minor_version /* out */
324 char *driver_name = NULL;
329 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
331 va_infoMessage("libva build on %s\n", VA_STR_VERSION);
333 vaStatus = va_getDriverName(dpy, &driver_name);
334 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
336 if (VA_STATUS_SUCCESS == vaStatus)
338 vaStatus = va_openDriver(dpy, driver_name);
339 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
341 *major_version = VA_MAJOR_VERSION;
342 *minor_version = VA_MINOR_VERSION;
352 * After this call, all library internal resources will be cleaned up
354 VAStatus vaTerminate (
358 VAStatus vaStatus = VA_STATUS_SUCCESS;
359 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
360 VADriverContextP old_ctx;
367 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
368 dlclose(old_ctx->handle);
369 old_ctx->handle = NULL;
372 if (VA_STATUS_SUCCESS == vaStatus)
373 pDisplayContext->vaDestroy(pDisplayContext);
378 * vaQueryVendorString returns a pointer to a zero-terminated string
379 * describing some aspects of the VA implemenation on a specific
380 * hardware accelerator. The format of the returned string is:
381 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
382 * e.g. for the Intel GMA500 implementation, an example would be:
383 * "IntelGMA500-1.0-0.2-patch3
385 const char *vaQueryVendorString (
389 if( !vaDisplayIsValid(dpy) )
392 return CTX(dpy)->str_vendor;
396 /* Get maximum number of profiles supported by the implementation */
397 int vaMaxNumProfiles (
401 if( !vaDisplayIsValid(dpy) )
404 return CTX(dpy)->max_profiles;
407 /* Get maximum number of entrypoints supported by the implementation */
408 int vaMaxNumEntrypoints (
412 if( !vaDisplayIsValid(dpy) )
415 return CTX(dpy)->max_entrypoints;
419 /* Get maximum number of attributs supported by the implementation */
420 int vaMaxNumConfigAttributes (
424 if( !vaDisplayIsValid(dpy) )
427 return CTX(dpy)->max_attributes;
430 VAStatus vaQueryConfigEntrypoints (
433 VAEntrypoint *entrypoints, /* out */
434 int *num_entrypoints /* out */
437 VADriverContextP ctx;
441 TRACE(vaQueryConfigEntrypoints);
442 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
445 VAStatus vaGetConfigAttributes (
448 VAEntrypoint entrypoint,
449 VAConfigAttrib *attrib_list, /* in/out */
453 VADriverContextP ctx;
457 TRACE(vaGetConfigAttributes);
458 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
461 VAStatus vaQueryConfigProfiles (
463 VAProfile *profile_list, /* out */
464 int *num_profiles /* out */
467 VADriverContextP ctx;
471 TRACE(vaQueryConfigProfiles);
472 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
475 VAStatus vaCreateConfig (
478 VAEntrypoint entrypoint,
479 VAConfigAttrib *attrib_list,
481 VAConfigID *config_id /* out */
484 VADriverContextP ctx;
488 TRACE(vaCreateConfig);
489 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
492 VAStatus vaDestroyConfig (
497 VADriverContextP ctx;
501 TRACE(vaDestroyConfig);
502 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
505 VAStatus vaQueryConfigAttributes (
507 VAConfigID config_id,
508 VAProfile *profile, /* out */
509 VAEntrypoint *entrypoint, /* out */
510 VAConfigAttrib *attrib_list,/* out */
511 int *num_attribs /* out */
514 VADriverContextP ctx;
518 TRACE(vaQueryConfigAttributes);
519 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
522 VAStatus vaCreateSurfaces (
528 VASurfaceID *surfaces /* out */
531 VADriverContextP ctx;
535 TRACE(vaCreateSurfaces);
536 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
540 VAStatus vaCreateSurfaceFromCIFrame (
542 unsigned long frame_id,
543 VASurfaceID *surface /* out */
546 VADriverContextP ctx;
550 TRACE(vaCreateSurfacesFromCIFrame);
551 return ctx->vtable.vaCreateSurfaceFromCIFrame( ctx, frame_id, surface );
554 VAStatus vaDestroySurfaces (
556 VASurfaceID *surface_list,
560 VADriverContextP ctx;
564 TRACE(vaDestroySurfaces);
565 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
568 VAStatus vaCreateContext (
570 VAConfigID config_id,
574 VASurfaceID *render_targets,
575 int num_render_targets,
576 VAContextID *context /* out */
579 VADriverContextP ctx;
583 TRACE(vaCreateContext);
584 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
585 flag, render_targets, num_render_targets, context );
588 VAStatus vaDestroyContext (
593 VADriverContextP ctx;
597 TRACE(vaDestroyContext);
598 return ctx->vtable.vaDestroyContext( ctx, context );
601 VAStatus vaCreateBuffer (
603 VAContextID context, /* in */
604 VABufferType type, /* in */
605 unsigned int size, /* in */
606 unsigned int num_elements, /* in */
608 VABufferID *buf_id /* out */
611 VADriverContextP ctx;
615 TRACE(vaCreateBuffer);
616 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
619 VAStatus vaBufferSetNumElements (
621 VABufferID buf_id, /* in */
622 unsigned int num_elements /* in */
625 VADriverContextP ctx;
629 TRACE(vaBufferSetNumElements);
630 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
634 VAStatus vaMapBuffer (
636 VABufferID buf_id, /* in */
637 void **pbuf /* out */
640 VADriverContextP ctx;
645 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
648 VAStatus vaUnmapBuffer (
650 VABufferID buf_id /* in */
653 VADriverContextP ctx;
657 TRACE(vaUnmapBuffer);
658 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
661 VAStatus vaDestroyBuffer (
666 VADriverContextP ctx;
670 TRACE(vaDestroyBuffer);
671 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
674 VAStatus vaBeginPicture (
677 VASurfaceID render_target
680 VADriverContextP ctx;
684 TRACE(vaBeginPicture);
685 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
688 VAStatus vaRenderPicture (
695 VADriverContextP ctx;
699 TRACE(vaRenderPicture);
700 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
703 VAStatus vaEndPicture (
708 VADriverContextP ctx;
713 return ctx->vtable.vaEndPicture( ctx, context );
716 VAStatus vaSyncSurface (
719 VASurfaceID render_target
722 VADriverContextP ctx;
726 TRACE(vaSyncSurface);
727 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
730 VAStatus vaQuerySurfaceStatus (
732 VASurfaceID render_target,
733 VASurfaceStatus *status /* out */
736 VADriverContextP ctx;
740 TRACE(vaQuerySurfaceStatus);
741 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
744 VAStatus vaPutSurface (
747 Drawable draw, /* X Drawable */
754 unsigned short destw,
755 unsigned short desth,
756 VARectangle *cliprects, /* client supplied clip list */
757 unsigned int number_cliprects, /* number of clip rects in the clip list */
758 unsigned int flags /* de-interlacing flags */
761 VADriverContextP ctx;
766 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
767 destx, desty, destw, desth,
768 cliprects, number_cliprects, flags );
771 /* Get maximum number of image formats supported by the implementation */
772 int vaMaxNumImageFormats (
776 if( !vaDisplayIsValid(dpy) )
779 return CTX(dpy)->max_image_formats;
782 VAStatus vaQueryImageFormats (
784 VAImageFormat *format_list, /* out */
785 int *num_formats /* out */
788 VADriverContextP ctx;
792 TRACE(vaQueryImageFormats);
793 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
797 * The width and height fields returned in the VAImage structure may get
798 * enlarged for some YUV formats. The size of the data buffer that needs
799 * to be allocated will be given in the "data_size" field in VAImage.
800 * Image data is not allocated by this function. The client should
801 * allocate the memory and fill in the VAImage structure's data field
802 * after looking at "data_size" returned from the library.
804 VAStatus vaCreateImage (
806 VAImageFormat *format,
809 VAImage *image /* out */
812 VADriverContextP ctx;
816 TRACE(vaCreateImage);
817 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
821 * Should call DestroyImage before destroying the surface it is bound to
823 VAStatus vaDestroyImage (
828 VADriverContextP ctx;
832 TRACE(vaDestroyImage);
833 return ctx->vtable.vaDestroyImage ( ctx, image);
836 VAStatus vaSetImagePalette (
839 unsigned char *palette
842 VADriverContextP ctx;
846 TRACE(vaSetImagePalette);
847 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
851 * Retrieve surface data into a VAImage
852 * Image must be in a format supported by the implementation
854 VAStatus vaGetImage (
857 int x, /* coordinates of the upper left source pixel */
859 unsigned int width, /* width and height of the region */
864 VADriverContextP ctx;
869 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
873 * Copy data from a VAImage to a surface
874 * Image must be in a format supported by the implementation
876 VAStatus vaPutImage (
888 VADriverContextP ctx;
893 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
897 * Similar to vaPutImage but with additional destination width
898 * and height arguments to enable scaling
900 VAStatus vaPutImage2 (
906 unsigned int src_width,
907 unsigned int src_height,
910 unsigned int dest_width,
911 unsigned int dest_height
914 VADriverContextP ctx;
919 return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
923 * Derive an VAImage from an existing surface.
924 * This interface will derive a VAImage and corresponding image buffer from
925 * an existing VA Surface. The image buffer can then be mapped/unmapped for
926 * direct CPU access. This operation is only possible on implementations with
927 * direct rendering capabilities and internal surface formats that can be
928 * represented with a VAImage. When the operation is not possible this interface
929 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
930 * to using vaCreateImage + vaPutImage to accomplish the same task in an
933 * Implementations should only return success when the resulting image buffer
934 * would be useable with vaMap/Unmap.
936 * When directly accessing a surface special care must be taken to insure
937 * proper synchronization with the graphics hardware. Clients should call
938 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
939 * rendering or currently being displayed by an overlay.
941 * Additionally nothing about the contents of a surface should be assumed
942 * following a vaPutSurface. Implementations are free to modify the surface for
943 * scaling or subpicture blending within a call to vaPutImage.
945 * Calls to vaPutImage or vaGetImage using the same surface from which the image
946 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
947 * vaGetImage with other surfaces is supported.
949 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
950 * image and image buffer structures will be destroyed; however, the underlying
951 * surface will remain unchanged until freed with vaDestroySurfaces.
953 VAStatus vaDeriveImage (
956 VAImage *image /* out */
959 VADriverContextP ctx;
963 TRACE(vaDeriveImage);
964 return ctx->vtable.vaDeriveImage ( ctx, surface, image );
968 /* Get maximum number of subpicture formats supported by the implementation */
969 int vaMaxNumSubpictureFormats (
973 if( !vaDisplayIsValid(dpy) )
976 return CTX(dpy)->max_subpic_formats;
980 * Query supported subpicture formats
981 * The caller must provide a "format_list" array that can hold at
982 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
983 * for each format to indicate additional capabilities for that format. The actual
984 * number of formats returned in "format_list" is returned in "num_formats".
986 VAStatus vaQuerySubpictureFormats (
988 VAImageFormat *format_list, /* out */
989 unsigned int *flags, /* out */
990 unsigned int *num_formats /* out */
993 VADriverContextP ctx;
997 TRACE(vaQuerySubpictureFormats);
998 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
1002 * Subpictures are created with an image associated.
1004 VAStatus vaCreateSubpicture (
1007 VASubpictureID *subpicture /* out */
1010 VADriverContextP ctx;
1014 TRACE(vaCreateSubpicture);
1015 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
1019 * Destroy the subpicture before destroying the image it is assocated to
1021 VAStatus vaDestroySubpicture (
1023 VASubpictureID subpicture
1026 VADriverContextP ctx;
1030 TRACE(vaDestroySubpicture);
1031 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1034 VAStatus vaSetSubpictureImage (
1036 VASubpictureID subpicture,
1040 VADriverContextP ctx;
1044 TRACE(vaSetSubpictureImage);
1045 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1050 * If chromakey is enabled, then the area where the source value falls within
1051 * the chromakey [min, max] range is transparent
1053 VAStatus vaSetSubpictureChromakey (
1055 VASubpictureID subpicture,
1056 unsigned int chromakey_min,
1057 unsigned int chromakey_max,
1058 unsigned int chromakey_mask
1061 VADriverContextP ctx;
1065 TRACE(vaSetSubpictureChromakey);
1066 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1071 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1072 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1073 * the overall alpha is per-pixel alpha multiplied by the global alpha
1075 VAStatus vaSetSubpictureGlobalAlpha (
1077 VASubpictureID subpicture,
1081 VADriverContextP ctx;
1085 TRACE(vaSetSubpictureGlobalAlpha);
1086 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1090 vaAssociateSubpicture associates the subpicture with the target_surface.
1091 It defines the region mapping between the subpicture and the target
1092 surface through source and destination rectangles (with the same width and height).
1093 Both will be displayed at the next call to vaPutSurface. Additional
1094 associations before the call to vaPutSurface simply overrides the association.
1096 VAStatus vaAssociateSubpicture (
1098 VASubpictureID subpicture,
1099 VASurfaceID *target_surfaces,
1101 short src_x, /* upper left offset in subpicture */
1103 short dest_x, /* upper left offset in surface */
1105 unsigned short width,
1106 unsigned short height,
1108 * whether to enable chroma-keying or global-alpha
1109 * see VA_SUBPICTURE_XXX values
1114 VADriverContextP ctx;
1118 TRACE(vaAssociateSubpicture);
1119 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1122 VAStatus vaAssociateSubpicture2 (
1124 VASubpictureID subpicture,
1125 VASurfaceID *target_surfaces,
1127 short src_x, /* upper left offset in subpicture */
1129 unsigned short src_width,
1130 unsigned short src_height,
1131 short dest_x, /* upper left offset in surface */
1133 unsigned short dest_width,
1134 unsigned short dest_height,
1136 * whether to enable chroma-keying or global-alpha
1137 * see VA_SUBPICTURE_XXX values
1142 VADriverContextP ctx;
1146 TRACE(vaAssociateSubpicture2);
1147 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 );
1151 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1153 VAStatus vaDeassociateSubpicture (
1155 VASubpictureID subpicture,
1156 VASurfaceID *target_surfaces,
1160 VADriverContextP ctx;
1164 TRACE(vaDeassociateSubpicture);
1165 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1169 /* Get maximum number of display attributes supported by the implementation */
1170 int vaMaxNumDisplayAttributes (
1174 if( !vaDisplayIsValid(dpy) )
1177 return CTX(dpy)->max_display_attributes;
1181 * Query display attributes
1182 * The caller must provide a "attr_list" array that can hold at
1183 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1184 * returned in "attr_list" is returned in "num_attributes".
1186 VAStatus vaQueryDisplayAttributes (
1188 VADisplayAttribute *attr_list, /* out */
1189 int *num_attributes /* out */
1192 VADriverContextP ctx;
1196 TRACE(vaQueryDisplayAttributes);
1197 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1201 * Get display attributes
1202 * This function returns the current attribute values in "attr_list".
1203 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1204 * from vaQueryDisplayAttributes() can have their values retrieved.
1206 VAStatus vaGetDisplayAttributes (
1208 VADisplayAttribute *attr_list, /* in/out */
1212 VADriverContextP ctx;
1216 TRACE(vaGetDisplayAttributes);
1217 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1221 * Set display attributes
1222 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1223 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1224 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1226 VAStatus vaSetDisplayAttributes (
1228 VADisplayAttribute *attr_list,
1232 VADriverContextP ctx;
1236 TRACE(vaSetDisplayAttributes);
1237 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1241 #warning TODO: Remove vaDbgCopySurfaceToBuffer in rev 0.29
1242 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1243 VASurfaceID surface,
1244 void **buffer, /* out */
1245 unsigned int *stride /* out */
1248 VADriverContextP ctx;
1252 TRACE(vaDbgCopySurfaceToBuffer);
1253 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );
1256 #warning TODO: Remove vaDbgCreateSurfaceFromMrstV4L2Buf in rev 0.29
1257 VAStatus vaDbgCreateSurfaceFromMrstV4L2Buf(
1260 unsigned int height,
1262 unsigned int fourcc,
1263 unsigned int luma_stride,
1264 unsigned int chroma_u_stride,
1265 unsigned int chroma_v_stride,
1266 unsigned int luma_offset,
1267 unsigned int chroma_u_offset,
1268 unsigned int chroma_v_offset,
1269 VASurfaceID *surface /* out */
1272 VADriverContextP ctx;
1276 TRACE(vtable.vaDbgCreateSurfaceFromMrstV4L2Buf);
1277 return ctx->vtable.vaDbgCreateSurfaceFromMrstV4L2Buf( ctx, width, height, size, fourcc, luma_stride, chroma_u_stride, chroma_v_stride, luma_offset, chroma_u_offset, chroma_v_offset, surface );