2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "va_backend.h"
37 #define VA_MAJOR_VERSION 0
38 #define VA_MINOR_VERSION 29
39 #define DRIVER_INIT_FUNC "__vaDriverInit_0_29"
41 #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
42 #define DRIVER_EXTENSION "_drv_video.so"
44 #define CTX(dpy) ((VADriverContextP) dpy );
45 #define CHECK_CONTEXT(dpy) if( !vaContextIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
47 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable.va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
48 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
49 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
51 #define TRACE(func) if (va_debug_trace) va_infoMessage("[TR] %s\n", #func);
53 static VADriverContextP pDriverContexts = NULL;
54 static int va_debug_trace = 0;
56 static Bool vaContextIsValid(VADriverContextP arg_ctx)
58 VADriverContextP ctx = pDriverContexts;
71 VADisplay vaGetDisplay (
72 NativeDisplay native_dpy /* implementation specific */
76 VADriverContextP ctx = pDriverContexts;
85 if (ctx->x11_dpy == (Display *)native_dpy)
87 dpy = (VADisplay) ctx;
95 /* create new entry */
96 ctx = (VADriverContextP) calloc(1, sizeof(struct VADriverContext));
97 ctx->pNext = pDriverContexts;
98 ctx->x11_dpy = (Display *) native_dpy;
99 pDriverContexts = ctx;
100 dpy = (VADisplay) ctx;
106 static void va_errorMessage(const char *msg, ...)
110 fprintf(stderr, "libva error: ");
112 vfprintf(stderr, msg, args);
116 static void va_infoMessage(const char *msg, ...)
120 fprintf(stderr, "libva: ");
122 vfprintf(stderr, msg, args);
126 static Bool va_checkVtable(void *ptr, char *function)
130 va_errorMessage("No valid vtable entry for va%s\n", function);
136 static Bool va_checkMaximum(int value, char *variable)
140 va_errorMessage("Failed to define max_%s in init\n", variable);
146 static Bool va_checkString(const char* value, char *variable)
150 va_errorMessage("Failed to define str_%s in init\n", variable);
156 static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
158 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
166 if (geteuid() == getuid())
168 /* don't allow setuid apps to use LIBVA_DRIVER_NAME */
169 if (getenv("LIBVA_DRIVER_NAME"))
171 /* For easier debugging */
172 *driver_name = strdup(getenv("LIBVA_DRIVER_NAME"));
173 return VA_STATUS_SUCCESS;
178 result = VA_DRIQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable);
181 va_errorMessage("VA_DRIQueryDirectRenderingCapable failed\n");
186 result = direct_capable;
189 va_errorMessage("VA_DRIQueryDirectRenderingCapable returned false\n");
194 result = VA_DRIGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor,
195 &driver_patch, driver_name);
198 va_errorMessage("VA_DRIGetClientDriverName returned false\n");
203 vaStatus = VA_STATUS_SUCCESS;
204 va_infoMessage("VA_DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
205 driver_major, driver_minor, driver_patch, *driver_name, ctx->x11_screen);
211 static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
213 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
214 char *search_path = NULL;
218 if (geteuid() == getuid())
220 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
221 search_path = getenv("LIBVA_DRIVERS_PATH");
224 search_path = getenv("LIBGL_DRIVERS_PATH");
229 search_path = DEFAULT_DRIVER_DIR;
232 search_path = strdup(search_path);
233 driver_dir = strtok_r(search_path, ":", &saveptr);
237 char *driver_path = (char *) malloc( strlen(driver_dir) +
238 strlen(driver_name) +
239 strlen(DRIVER_EXTENSION) + 2 );
240 strcpy( driver_path, driver_dir );
241 strcat( driver_path, "/" );
242 strcat( driver_path, driver_name );
243 strcat( driver_path, DRIVER_EXTENSION );
245 va_infoMessage("Trying to open %s\n", driver_path);
247 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL );
250 /* Don't give errors for non-existing files */
251 if (0 == access( driver_path, F_OK))
253 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
258 VADriverInit init_func;
259 init_func = (VADriverInit) dlsym(handle, DRIVER_INIT_FUNC);
262 va_errorMessage("%s has no function %s\n", driver_path, DRIVER_INIT_FUNC);
267 vaStatus = (*init_func)(ctx);
269 if (VA_STATUS_SUCCESS == vaStatus)
271 CHECK_MAXIMUM(vaStatus, ctx, profiles);
272 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
273 CHECK_MAXIMUM(vaStatus, ctx, attributes);
274 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
275 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
276 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
277 CHECK_STRING(vaStatus, ctx, vendor);
278 CHECK_VTABLE(vaStatus, ctx, Terminate);
279 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
280 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
281 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
282 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
283 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
284 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
285 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
286 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
287 CHECK_VTABLE(vaStatus, ctx, CreateContext);
288 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
289 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
290 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
291 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
292 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
293 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
294 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
295 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
296 CHECK_VTABLE(vaStatus, ctx, EndPicture);
297 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
298 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
299 CHECK_VTABLE(vaStatus, ctx, PutSurface);
300 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
301 CHECK_VTABLE(vaStatus, ctx, CreateImage);
302 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
303 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
304 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
305 CHECK_VTABLE(vaStatus, ctx, GetImage);
306 CHECK_VTABLE(vaStatus, ctx, PutImage);
307 CHECK_VTABLE(vaStatus, ctx, PutImage2);
308 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
309 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
310 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
311 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
312 CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
313 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
314 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
315 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
316 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture2);
317 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
318 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
319 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
320 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
321 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
323 if (VA_STATUS_SUCCESS != vaStatus)
325 va_errorMessage("%s init failed\n", driver_path);
328 if (VA_STATUS_SUCCESS == vaStatus)
330 ctx->handle = handle;
338 driver_dir = strtok_r(NULL, ":", &saveptr);
346 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
348 VADriverContextP ctx = CTX(dpy);
349 if( !vaContextIsValid(ctx) )
352 if (NULL == ctx->handle)
355 return (VAPrivFunc) dlsym(ctx->handle, func);
360 * Returns a short english description of error_status
362 const char *vaErrorStr(VAStatus error_status)
366 case VA_STATUS_SUCCESS:
367 return "success (no error)";
368 case VA_STATUS_ERROR_ALLOCATION_FAILED:
369 return "resource allocation failed";
370 case VA_STATUS_ERROR_INVALID_CONFIG:
371 return "invalid VAConfigID";
372 case VA_STATUS_ERROR_INVALID_CONTEXT:
373 return "invalid VAContextID";
374 case VA_STATUS_ERROR_INVALID_SURFACE:
375 return "invalid VASurfaceID";
376 case VA_STATUS_ERROR_INVALID_BUFFER:
377 return "invalid VABufferID";
378 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
379 return "attribute not supported";
380 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
381 return "list argument exceeds maximum number";
382 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
383 return "the requested VAProfile is not supported";
384 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
385 return "the requested VAEntryPoint is not supported";
386 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
387 return "the requested RT Format is not supported";
388 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
389 return "the requested VABufferType is not supported";
390 case VA_STATUS_ERROR_SURFACE_BUSY:
391 return "surface is in use";
392 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
393 return "flag not supported";
394 case VA_STATUS_ERROR_UNKNOWN:
395 return "unknown libva error";
397 return "unknown libva error / description missing";
400 VAStatus vaInitialize (
402 int *major_version, /* out */
403 int *minor_version /* out */
406 VADriverContextP ctx = CTX(dpy);
407 char *driver_name = NULL;
412 va_debug_trace = (getenv("LIBVA_DEBUG_TRACE") != NULL);
414 vaStatus = va_getDriverName(ctx, &driver_name);
415 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
417 if (VA_STATUS_SUCCESS == vaStatus)
419 vaStatus = va_openDriver(ctx, driver_name);
420 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
422 *major_version = VA_MAJOR_VERSION;
423 *minor_version = VA_MINOR_VERSION;
435 * After this call, all library internal resources will be cleaned up
437 VAStatus vaTerminate (
441 VAStatus vaStatus = VA_STATUS_SUCCESS;
442 VADriverContextP old_ctx = CTX(dpy);
443 CHECK_CONTEXT(old_ctx);
447 vaStatus = old_ctx->vtable.vaTerminate(old_ctx);
448 dlclose(old_ctx->handle);
449 old_ctx->handle = NULL;
452 if (VA_STATUS_SUCCESS == vaStatus)
454 VADriverContextP *ctx = &pDriverContexts;
456 /* Throw away old_ctx */
461 *ctx = old_ctx->pNext;
462 old_ctx->pNext = NULL;
465 ctx = &((*ctx)->pNext);
473 * vaQueryVendorString returns a pointer to a zero-terminated string
474 * describing some aspects of the VA implemenation on a specific
475 * hardware accelerator. The format of the returned string is:
476 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
477 * e.g. for the Intel GMA500 implementation, an example would be:
478 * "IntelGMA500-1.0-0.2-patch3
480 const char *vaQueryVendorString (
484 VADriverContextP ctx = CTX(dpy);
485 if( !vaContextIsValid(ctx) )
490 return ctx->str_vendor;
494 /* Get maximum number of profiles supported by the implementation */
495 int vaMaxNumProfiles (
499 VADriverContextP ctx = CTX(dpy);
500 if( !vaContextIsValid(ctx) )
505 return ctx->max_profiles;
508 /* Get maximum number of entrypoints supported by the implementation */
509 int vaMaxNumEntrypoints (
513 VADriverContextP ctx = CTX(dpy);
514 if( !vaContextIsValid(ctx) )
519 return ctx->max_entrypoints;
523 /* Get maximum number of attributs supported by the implementation */
524 int vaMaxNumConfigAttributes (
528 VADriverContextP ctx = CTX(dpy);
529 if( !vaContextIsValid(ctx) )
534 return ctx->max_attributes;
537 VAStatus vaQueryConfigEntrypoints (
540 VAEntrypoint *entrypoints, /* out */
541 int *num_entrypoints /* out */
544 VADriverContextP ctx = CTX(dpy);
547 TRACE(vaQueryConfigEntrypoints);
548 return ctx->vtable.vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
551 VAStatus vaGetConfigAttributes (
554 VAEntrypoint entrypoint,
555 VAConfigAttrib *attrib_list, /* in/out */
559 VADriverContextP ctx = CTX(dpy);
562 TRACE(vaGetConfigAttributes);
563 return ctx->vtable.vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
566 VAStatus vaQueryConfigProfiles (
568 VAProfile *profile_list, /* out */
569 int *num_profiles /* out */
572 VADriverContextP ctx = CTX(dpy);
575 TRACE(vaQueryConfigProfiles);
576 return ctx->vtable.vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
579 VAStatus vaCreateConfig (
582 VAEntrypoint entrypoint,
583 VAConfigAttrib *attrib_list,
585 VAConfigID *config_id /* out */
588 VADriverContextP ctx = CTX(dpy);
591 TRACE(vaCreateConfig);
592 return ctx->vtable.vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
595 VAStatus vaDestroyConfig (
600 VADriverContextP ctx = CTX(dpy);
603 TRACE(vaDestroyConfig);
604 return ctx->vtable.vaDestroyConfig ( ctx, config_id );
607 VAStatus vaQueryConfigAttributes (
609 VAConfigID config_id,
610 VAProfile *profile, /* out */
611 VAEntrypoint *entrypoint, /* out */
612 VAConfigAttrib *attrib_list,/* out */
613 int *num_attribs /* out */
616 VADriverContextP ctx = CTX(dpy);
619 TRACE(vaQueryConfigAttributes);
620 return ctx->vtable.vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
623 VAStatus vaCreateSurfaces (
629 VASurfaceID *surfaces /* out */
632 VADriverContextP ctx = CTX(dpy);
635 TRACE(vaCreateSurfaces);
636 return ctx->vtable.vaCreateSurfaces( ctx, width, height, format, num_surfaces, surfaces );
639 VAStatus vaDestroySurfaces (
641 VASurfaceID *surface_list,
645 VADriverContextP ctx = CTX(dpy);
648 TRACE(vaDestroySurfaces);
649 return ctx->vtable.vaDestroySurfaces( ctx, surface_list, num_surfaces );
652 VAStatus vaCreateContext (
654 VAConfigID config_id,
658 VASurfaceID *render_targets,
659 int num_render_targets,
660 VAContextID *context /* out */
663 VADriverContextP ctx = CTX(dpy);
666 TRACE(vaCreateContext);
667 return ctx->vtable.vaCreateContext( ctx, config_id, picture_width, picture_height,
668 flag, render_targets, num_render_targets, context );
671 VAStatus vaDestroyContext (
676 VADriverContextP ctx = CTX(dpy);
679 TRACE(vaDestroyContext);
680 return ctx->vtable.vaDestroyContext( ctx, context );
683 VAStatus vaCreateBuffer (
685 VAContextID context, /* in */
686 VABufferType type, /* in */
687 unsigned int size, /* in */
688 unsigned int num_elements, /* in */
690 VABufferID *buf_id /* out */
693 VADriverContextP ctx = CTX(dpy);
696 TRACE(vaCreateBuffer);
697 return ctx->vtable.vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
700 VAStatus vaBufferSetNumElements (
702 VABufferID buf_id, /* in */
703 unsigned int num_elements /* in */
706 VADriverContextP ctx = CTX(dpy);
709 TRACE(vaBufferSetNumElements);
710 return ctx->vtable.vaBufferSetNumElements( ctx, buf_id, num_elements );
714 VAStatus vaMapBuffer (
716 VABufferID buf_id, /* in */
717 void **pbuf /* out */
720 VADriverContextP ctx = CTX(dpy);
724 return ctx->vtable.vaMapBuffer( ctx, buf_id, pbuf );
727 VAStatus vaUnmapBuffer (
729 VABufferID buf_id /* in */
732 VADriverContextP ctx = CTX(dpy);
735 TRACE(vaUnmapBuffer);
736 return ctx->vtable.vaUnmapBuffer( ctx, buf_id );
739 VAStatus vaDestroyBuffer (
744 VADriverContextP ctx = CTX(dpy);
747 TRACE(vaDestroyBuffer);
748 return ctx->vtable.vaDestroyBuffer( ctx, buffer_id );
751 VAStatus vaBeginPicture (
754 VASurfaceID render_target
757 VADriverContextP ctx = CTX(dpy);
760 TRACE(vaBeginPicture);
761 return ctx->vtable.vaBeginPicture( ctx, context, render_target );
764 VAStatus vaRenderPicture (
771 VADriverContextP ctx = CTX(dpy);
774 TRACE(vaRenderPicture);
775 return ctx->vtable.vaRenderPicture( ctx, context, buffers, num_buffers );
778 VAStatus vaEndPicture (
783 VADriverContextP ctx = CTX(dpy);
787 return ctx->vtable.vaEndPicture( ctx, context );
790 VAStatus vaSyncSurface (
793 VASurfaceID render_target
796 VADriverContextP ctx = CTX(dpy);
799 TRACE(vaSyncSurface);
800 return ctx->vtable.vaSyncSurface( ctx, context, render_target );
803 VAStatus vaQuerySurfaceStatus (
805 VASurfaceID render_target,
806 VASurfaceStatus *status /* out */
809 VADriverContextP ctx = CTX(dpy);
812 TRACE(vaQuerySurfaceStatus);
813 return ctx->vtable.vaQuerySurfaceStatus( ctx, render_target, status );
816 VAStatus vaPutSurface (
819 Drawable draw, /* X Drawable */
826 unsigned short destw,
827 unsigned short desth,
828 VARectangle *cliprects, /* client supplied clip list */
829 unsigned int number_cliprects, /* number of clip rects in the clip list */
830 unsigned int flags /* de-interlacing flags */
833 VADriverContextP ctx = CTX(dpy);
837 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
838 destx, desty, destw, desth,
839 cliprects, number_cliprects, flags );
842 /* Get maximum number of image formats supported by the implementation */
843 int vaMaxNumImageFormats (
847 VADriverContextP ctx = CTX(dpy);
848 if( !vaContextIsValid(ctx) )
853 return ctx->max_image_formats;
856 VAStatus vaQueryImageFormats (
858 VAImageFormat *format_list, /* out */
859 int *num_formats /* out */
862 VADriverContextP ctx = CTX(dpy);
865 TRACE(vaQueryImageFormats);
866 return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
870 * The width and height fields returned in the VAImage structure may get
871 * enlarged for some YUV formats. The size of the data buffer that needs
872 * to be allocated will be given in the "data_size" field in VAImage.
873 * Image data is not allocated by this function. The client should
874 * allocate the memory and fill in the VAImage structure's data field
875 * after looking at "data_size" returned from the library.
877 VAStatus vaCreateImage (
879 VAImageFormat *format,
882 VAImage *image /* out */
885 VADriverContextP ctx = CTX(dpy);
888 TRACE(vaCreateImage);
889 return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
893 * Should call DestroyImage before destroying the surface it is bound to
895 VAStatus vaDestroyImage (
900 VADriverContextP ctx = CTX(dpy);
903 TRACE(vaDestroyImage);
904 return ctx->vtable.vaDestroyImage ( ctx, image);
907 VAStatus vaSetImagePalette (
910 unsigned char *palette
913 VADriverContextP ctx = CTX(dpy);
916 TRACE(vaSetImagePalette);
917 return ctx->vtable.vaSetImagePalette ( ctx, image, palette);
921 * Retrieve surface data into a VAImage
922 * Image must be in a format supported by the implementation
924 VAStatus vaGetImage (
927 int x, /* coordinates of the upper left source pixel */
929 unsigned int width, /* width and height of the region */
934 VADriverContextP ctx = CTX(dpy);
938 return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
942 * Copy data from a VAImage to a surface
943 * Image must be in a format supported by the implementation
945 VAStatus vaPutImage (
957 VADriverContextP ctx = CTX(dpy);
961 return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
965 * Similar to vaPutImage but with additional destination width
966 * and height arguments to enable scaling
968 VAStatus vaPutImage2 (
974 unsigned int src_width,
975 unsigned int src_height,
978 unsigned int dest_width,
979 unsigned int dest_height
982 VADriverContextP ctx = CTX(dpy);
986 return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
990 * Derive an VAImage from an existing surface.
991 * This interface will derive a VAImage and corresponding image buffer from
992 * an existing VA Surface. The image buffer can then be mapped/unmapped for
993 * direct CPU access. This operation is only possible on implementations with
994 * direct rendering capabilities and internal surface formats that can be
995 * represented with a VAImage. When the operation is not possible this interface
996 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
997 * to using vaCreateImage + vaPutImage to accomplish the same task in an
1000 * Implementations should only return success when the resulting image buffer
1001 * would be useable with vaMap/Unmap.
1003 * When directly accessing a surface special care must be taken to insure
1004 * proper synchronization with the graphics hardware. Clients should call
1005 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
1006 * rendering or currently being displayed by an overlay.
1008 * Additionally nothing about the contents of a surface should be assumed
1009 * following a vaPutSurface. Implementations are free to modify the surface for
1010 * scaling or subpicture blending within a call to vaPutImage.
1012 * Calls to vaPutImage or vaGetImage using the same surface from which the image
1013 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
1014 * vaGetImage with other surfaces is supported.
1016 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
1017 * image and image buffer structures will be destroyed; however, the underlying
1018 * surface will remain unchanged until freed with vaDestroySurfaces.
1020 VAStatus vaDeriveImage (
1022 VASurfaceID surface,
1023 VAImage *image /* out */
1026 VADriverContextP ctx = CTX(dpy);
1029 TRACE(vaDeriveImage);
1030 return ctx->vtable.vaDeriveImage ( ctx, surface, image );
1034 /* Get maximum number of subpicture formats supported by the implementation */
1035 int vaMaxNumSubpictureFormats (
1039 VADriverContextP ctx = CTX(dpy);
1040 if( !vaContextIsValid(ctx) )
1045 return ctx->max_subpic_formats;
1049 * Query supported subpicture formats
1050 * The caller must provide a "format_list" array that can hold at
1051 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
1052 * for each format to indicate additional capabilities for that format. The actual
1053 * number of formats returned in "format_list" is returned in "num_formats".
1055 VAStatus vaQuerySubpictureFormats (
1057 VAImageFormat *format_list, /* out */
1058 unsigned int *flags, /* out */
1059 unsigned int *num_formats /* out */
1062 VADriverContextP ctx = CTX(dpy);
1065 TRACE(vaQuerySubpictureFormats);
1066 return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
1070 * Subpictures are created with an image associated.
1072 VAStatus vaCreateSubpicture (
1075 VASubpictureID *subpicture /* out */
1078 VADriverContextP ctx = CTX(dpy);
1081 TRACE(vaCreateSubpicture);
1082 return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
1086 * Destroy the subpicture before destroying the image it is assocated to
1088 VAStatus vaDestroySubpicture (
1090 VASubpictureID subpicture
1093 VADriverContextP ctx = CTX(dpy);
1096 TRACE(vaDestroySubpicture);
1097 return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
1100 VAStatus vaSetSubpictureImage (
1102 VASubpictureID subpicture,
1106 VADriverContextP ctx = CTX(dpy);
1109 TRACE(vaSetSubpictureImage);
1110 return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
1113 #warning TODO: Remove vaSetSubpicturePalette in rev 0.29
1114 VAStatus vaSetSubpicturePalette (
1116 VASubpictureID subpicture,
1118 * pointer to an array holding the palette data. The size of the array is
1119 * num_palette_entries * entry_bytes in size. The order of the components
1120 * in the palette is described by the component_order in VASubpicture struct
1122 unsigned char *palette
1125 VADriverContextP ctx = CTX(dpy);
1128 TRACE(vaSetSubpicturePalette);
1129 return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
1133 * If chromakey is enabled, then the area where the source value falls within
1134 * the chromakey [min, max] range is transparent
1136 VAStatus vaSetSubpictureChromakey (
1138 VASubpictureID subpicture,
1139 unsigned int chromakey_min,
1140 unsigned int chromakey_max,
1141 unsigned int chromakey_mask
1144 VADriverContextP ctx = CTX(dpy);
1147 TRACE(vaSetSubpictureChromakey);
1148 return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1153 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1154 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1155 * the overall alpha is per-pixel alpha multiplied by the global alpha
1157 VAStatus vaSetSubpictureGlobalAlpha (
1159 VASubpictureID subpicture,
1163 VADriverContextP ctx = CTX(dpy);
1166 TRACE(vaSetSubpictureGlobalAlpha);
1167 return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1171 vaAssociateSubpicture associates the subpicture with the target_surface.
1172 It defines the region mapping between the subpicture and the target
1173 surface through source and destination rectangles (with the same width and height).
1174 Both will be displayed at the next call to vaPutSurface. Additional
1175 associations before the call to vaPutSurface simply overrides the association.
1177 VAStatus vaAssociateSubpicture (
1179 VASubpictureID subpicture,
1180 VASurfaceID *target_surfaces,
1182 short src_x, /* upper left offset in subpicture */
1184 short dest_x, /* upper left offset in surface */
1186 unsigned short width,
1187 unsigned short height,
1189 * whether to enable chroma-keying or global-alpha
1190 * see VA_SUBPICTURE_XXX values
1195 VADriverContextP ctx = CTX(dpy);
1198 TRACE(vaAssociateSubpicture);
1199 return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
1202 VAStatus vaAssociateSubpicture2 (
1204 VASubpictureID subpicture,
1205 VASurfaceID *target_surfaces,
1207 short src_x, /* upper left offset in subpicture */
1209 unsigned short src_width,
1210 unsigned short src_height,
1211 short dest_x, /* upper left offset in surface */
1213 unsigned short dest_width,
1214 unsigned short dest_height,
1216 * whether to enable chroma-keying or global-alpha
1217 * see VA_SUBPICTURE_XXX values
1222 VADriverContextP ctx = CTX(dpy);
1225 TRACE(vaAssociateSubpicture2);
1226 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 );
1230 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1232 VAStatus vaDeassociateSubpicture (
1234 VASubpictureID subpicture,
1235 VASurfaceID *target_surfaces,
1239 VADriverContextP ctx = CTX(dpy);
1242 TRACE(vaDeassociateSubpicture);
1243 return ctx->vtable.vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1247 /* Get maximum number of display attributes supported by the implementation */
1248 int vaMaxNumDisplayAttributes (
1252 VADriverContextP ctx = CTX(dpy);
1253 if( !vaContextIsValid(ctx) )
1258 return ctx->max_display_attributes;
1262 * Query display attributes
1263 * The caller must provide a "attr_list" array that can hold at
1264 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1265 * returned in "attr_list" is returned in "num_attributes".
1267 VAStatus vaQueryDisplayAttributes (
1269 VADisplayAttribute *attr_list, /* out */
1270 int *num_attributes /* out */
1273 VADriverContextP ctx = CTX(dpy);
1276 TRACE(vaQueryDisplayAttributes);
1277 return ctx->vtable.vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1281 * Get display attributes
1282 * This function returns the current attribute values in "attr_list".
1283 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1284 * from vaQueryDisplayAttributes() can have their values retrieved.
1286 VAStatus vaGetDisplayAttributes (
1288 VADisplayAttribute *attr_list, /* in/out */
1292 VADriverContextP ctx = CTX(dpy);
1295 TRACE(vaGetDisplayAttributes);
1296 return ctx->vtable.vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1300 * Set display attributes
1301 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1302 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1303 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1305 VAStatus vaSetDisplayAttributes (
1307 VADisplayAttribute *attr_list,
1311 VADriverContextP ctx = CTX(dpy);
1314 TRACE(vaSetDisplayAttributes);
1315 return ctx->vtable.vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1319 #warning TODO: Remove vaDbgCopySurfaceToBuffer in rev 0.29
1320 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
1321 VASurfaceID surface,
1322 void **buffer, /* out */
1323 unsigned int *stride /* out */
1326 VADriverContextP ctx = CTX(dpy);
1329 TRACE(vaDbgCopySurfaceToBuffer);
1330 return ctx->vtable.vaDbgCopySurfaceToBuffer( ctx, surface, buffer, stride );