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.
28 #include "va_backend.h"
29 #include "va_backend_vpp.h"
30 #include "va_internal.h"
43 /* support versions < JellyBean */
52 #define DRIVER_EXTENSION "_drv_video.so"
55 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(dpy, ctx->vtable->va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
56 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(dpy, ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
57 #define CHECK_STRING(s, ctx, var) if (!va_checkString(dpy, ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
60 * read a config "env" for libva.conf or from environment setting
61 * libva.conf has higher priority
62 * return 0: the "env" is set, and the value is copied into env_value
63 * 1: the env is not set
65 int va_parseConfig(char *env, char *env_value)
67 char *token, *value, *saveptr;
74 fp = fopen("/etc/libva.conf", "r");
75 while (fp && (fgets(oneline, 1024, fp) != NULL)) {
76 if (strlen(oneline) == 1)
78 token = strtok_r(oneline, "=\n", &saveptr);
79 value = strtok_r(NULL, "=\n", &saveptr);
81 if (NULL == token || NULL == value)
84 if (strcmp(token, env) == 0) {
86 strncpy(env_value,value, 1024);
87 env_value[1023] = '\0';
98 /* no setting in config file, use env setting */
102 strncpy(env_value, value, 1024);
103 env_value[1023] = '\0';
111 int vaDisplayIsValid(VADisplay dpy)
113 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
114 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
118 * Global log level configured from the config file or environment, which sets
119 * whether default logging appears or not (always overridden by explicitly
120 * user-configured logging).
122 static int default_log_level = 2;
124 static void default_log_error(void *user_context, const char *buffer)
126 if (default_log_level < 1)
131 fprintf(stderr, "libva error: %s", buffer);
135 static void default_log_info(void *user_context, const char *buffer)
137 if (default_log_level < 2)
142 fprintf(stderr, "libva info: %s", buffer);
147 * Set the callback for error messages, or NULL for no logging.
148 * Returns the previous one, or NULL if it was disabled.
150 VAMessageCallback vaSetErrorCallback(VADisplay dpy, VAMessageCallback callback, void *user_context)
152 VADisplayContextP dctx;
153 VAMessageCallback old_callback;
155 if (!vaDisplayIsValid(dpy))
158 dctx = (VADisplayContextP)dpy;
159 old_callback = dctx->error_callback;
161 dctx->error_callback = callback;
162 dctx->error_callback_user_context = user_context;
168 * Set the callback for info messages, or NULL for no logging.
169 * Returns the previous one, or NULL if it was disabled.
171 VAMessageCallback vaSetInfoCallback(VADisplay dpy, VAMessageCallback callback, void *user_context)
173 VADisplayContextP dctx;
174 VAMessageCallback old_callback;
176 if (!vaDisplayIsValid(dpy))
179 dctx = (VADisplayContextP)dpy;
180 old_callback = dctx->info_callback;
182 dctx->info_callback = callback;
183 dctx->info_callback_user_context = user_context;
188 static void va_MessagingInit()
190 #if ENABLE_VA_MESSAGING
191 char env_value[1024];
194 if (va_parseConfig("LIBVA_MESSAGING_LEVEL", &env_value[0]) == 0) {
195 ret = sscanf(env_value, "%d", &default_log_level);
196 if (ret < 1 || default_log_level < 0 || default_log_level > 2)
197 default_log_level = 2;
202 void va_errorMessage(VADisplay dpy, const char *msg, ...)
204 #if ENABLE_VA_MESSAGING
205 VADisplayContextP dctx = (VADisplayContextP)dpy;
206 char buf[512], *dynbuf;
210 if (dctx->error_callback == NULL)
214 len = vsnprintf(buf, sizeof(buf), msg, args);
217 if (len >= (int)sizeof(buf)) {
218 dynbuf = malloc(len + 1);
222 n = vsnprintf(dynbuf, len + 1, msg, args);
225 dctx->error_callback(dctx->error_callback_user_context, dynbuf);
229 dctx->error_callback(dctx->error_callback_user_context, buf);
233 void va_infoMessage(VADisplay dpy, const char *msg, ...)
235 #if ENABLE_VA_MESSAGING
236 VADisplayContextP dctx = (VADisplayContextP)dpy;
237 char buf[512], *dynbuf;
241 if (dctx->info_callback == NULL)
245 len = vsnprintf(buf, sizeof(buf), msg, args);
248 if (len >= (int)sizeof(buf)) {
249 dynbuf = malloc(len + 1);
253 n = vsnprintf(dynbuf, len + 1, msg, args);
256 dctx->info_callback(dctx->info_callback_user_context, dynbuf);
260 dctx->info_callback(dctx->info_callback_user_context, buf);
264 static void va_driverErrorCallback(VADriverContextP ctx,
267 VADisplayContextP dctx = ctx->pDisplayContext;
270 dctx->error_callback(dctx->error_callback_user_context, message);
273 static void va_driverInfoCallback(VADriverContextP ctx,
276 VADisplayContextP dctx = ctx->pDisplayContext;
279 dctx->info_callback(dctx->info_callback_user_context, message);
282 VADisplayContextP va_newDisplayContext(void)
284 VADisplayContextP dctx = calloc(1, sizeof(*dctx));
288 dctx->vadpy_magic = VA_DISPLAY_MAGIC;
290 dctx->error_callback = default_log_error;
291 dctx->info_callback = default_log_info;
296 VADriverContextP va_newDriverContext(VADisplayContextP dctx)
298 VADriverContextP ctx = calloc(1, sizeof(*ctx));
302 dctx->pDriverContext = ctx;
303 ctx->pDisplayContext = dctx;
305 ctx->error_callback = va_driverErrorCallback;
306 ctx->info_callback = va_driverInfoCallback;
311 static bool va_checkVtable(VADisplay dpy, void *ptr, char *function)
314 va_errorMessage(dpy, "No valid vtable entry for va%s\n", function);
320 static bool va_checkMaximum(VADisplay dpy, int value, char *variable)
323 va_errorMessage(dpy, "Failed to define max_%s in init\n", variable);
329 static bool va_checkString(VADisplay dpy, const char* value, char *variable)
332 va_errorMessage(dpy, "Failed to define str_%s in init\n", variable);
339 va_getDriverInitName(char *name, int namelen, int major, int minor)
341 int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor);
342 return ret > 0 && ret < namelen;
345 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
347 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
349 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
352 static char *va_getDriverPath(const char *driver_dir, const char *driver_name)
354 int n = snprintf(0, 0, "%s/%s%s", driver_dir, driver_name, DRIVER_EXTENSION);
357 char *driver_path = (char *) malloc(n + 1);
360 n = snprintf(driver_path, n + 1, "%s/%s%s",
361 driver_dir, driver_name, DRIVER_EXTENSION);
369 static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
371 VADriverContextP ctx = CTX(dpy);
372 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
373 char *search_path = NULL;
377 if (geteuid() == getuid())
378 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
379 search_path = getenv("LIBVA_DRIVERS_PATH");
381 search_path = VA_DRIVERS_PATH;
383 search_path = strdup((const char *)search_path);
384 driver_dir = strtok_r(search_path, ":", &saveptr);
387 char *driver_path = va_getDriverPath(driver_dir, driver_name);
389 va_errorMessage(dpy, "%s L%d Out of memory\n",
390 __FUNCTION__, __LINE__);
392 return VA_STATUS_ERROR_ALLOCATION_FAILED;
395 va_infoMessage(dpy, "Trying to open %s\n", driver_path);
397 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
399 handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
402 /* Don't give errors for non-existing files */
403 if (0 == access( driver_path, F_OK))
404 va_errorMessage(dpy, "dlopen of %s failed: %s\n", driver_path, dlerror());
406 VADriverInit init_func = NULL;
407 char init_func_s[256];
410 static const struct {
413 } compatible_versions[] = {
414 { VA_MAJOR_VERSION, VA_MINOR_VERSION },
415 { VA_MAJOR_VERSION, 3 },
416 { VA_MAJOR_VERSION, 2 },
417 { VA_MAJOR_VERSION, 1 },
418 { VA_MAJOR_VERSION, 0 },
422 for (i = 0; compatible_versions[i].major >= 0; i++) {
423 if (va_getDriverInitName(init_func_s, sizeof(init_func_s),
424 compatible_versions[i].major,
425 compatible_versions[i].minor)) {
426 init_func = (VADriverInit)dlsym(handle, init_func_s);
428 va_infoMessage(dpy, "Found init function %s\n", init_func_s);
434 if (compatible_versions[i].major < 0) {
435 va_errorMessage(dpy, "%s has no function %s\n",
436 driver_path, init_func_s);
439 struct VADriverVTable *vtable = ctx->vtable;
440 struct VADriverVTableVPP *vtable_vpp = ctx->vtable_vpp;
442 vaStatus = VA_STATUS_SUCCESS;
444 vtable = calloc(1, sizeof(*vtable));
446 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
448 ctx->vtable = vtable;
451 vtable_vpp = calloc(1, sizeof(*vtable_vpp));
453 vtable_vpp->version = VA_DRIVER_VTABLE_VPP_VERSION;
455 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
457 ctx->vtable_vpp = vtable_vpp;
459 if (init_func && VA_STATUS_SUCCESS == vaStatus)
460 vaStatus = (*init_func)(ctx);
462 if (VA_STATUS_SUCCESS == vaStatus) {
463 CHECK_MAXIMUM(vaStatus, ctx, profiles);
464 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
465 CHECK_MAXIMUM(vaStatus, ctx, attributes);
466 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
467 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
468 CHECK_STRING(vaStatus, ctx, vendor);
469 CHECK_VTABLE(vaStatus, ctx, Terminate);
470 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
471 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
472 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
473 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
474 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
475 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
476 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
477 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
478 CHECK_VTABLE(vaStatus, ctx, CreateContext);
479 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
480 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
481 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
482 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
483 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
484 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
485 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
486 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
487 CHECK_VTABLE(vaStatus, ctx, EndPicture);
488 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
489 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
490 CHECK_VTABLE(vaStatus, ctx, PutSurface);
491 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
492 CHECK_VTABLE(vaStatus, ctx, CreateImage);
493 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
494 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
495 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
496 CHECK_VTABLE(vaStatus, ctx, GetImage);
497 CHECK_VTABLE(vaStatus, ctx, PutImage);
498 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
499 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
500 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
501 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
502 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
503 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
504 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
505 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
506 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
507 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
508 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
510 if (VA_STATUS_SUCCESS != vaStatus) {
511 va_errorMessage(dpy, "%s init failed\n", driver_path);
514 if (VA_STATUS_SUCCESS == vaStatus)
515 ctx->handle = handle;
522 driver_dir = strtok_r(NULL, ":", &saveptr);
530 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
532 VADriverContextP ctx;
533 if (!vaDisplayIsValid(dpy))
537 if (NULL == ctx->handle)
540 return (VAPrivFunc) dlsym(ctx->handle, func);
545 * Returns a short english description of error_status
547 const char *vaErrorStr(VAStatus error_status)
549 switch(error_status) {
550 case VA_STATUS_SUCCESS:
551 return "success (no error)";
552 case VA_STATUS_ERROR_OPERATION_FAILED:
553 return "operation failed";
554 case VA_STATUS_ERROR_ALLOCATION_FAILED:
555 return "resource allocation failed";
556 case VA_STATUS_ERROR_INVALID_DISPLAY:
557 return "invalid VADisplay";
558 case VA_STATUS_ERROR_INVALID_CONFIG:
559 return "invalid VAConfigID";
560 case VA_STATUS_ERROR_INVALID_CONTEXT:
561 return "invalid VAContextID";
562 case VA_STATUS_ERROR_INVALID_SURFACE:
563 return "invalid VASurfaceID";
564 case VA_STATUS_ERROR_INVALID_BUFFER:
565 return "invalid VABufferID";
566 case VA_STATUS_ERROR_INVALID_IMAGE:
567 return "invalid VAImageID";
568 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
569 return "invalid VASubpictureID";
570 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
571 return "attribute not supported";
572 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
573 return "list argument exceeds maximum number";
574 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
575 return "the requested VAProfile is not supported";
576 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
577 return "the requested VAEntryPoint is not supported";
578 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
579 return "the requested RT Format is not supported";
580 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
581 return "the requested VABufferType is not supported";
582 case VA_STATUS_ERROR_SURFACE_BUSY:
583 return "surface is in use";
584 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
585 return "flag not supported";
586 case VA_STATUS_ERROR_INVALID_PARAMETER:
587 return "invalid parameter";
588 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
589 return "resolution not supported";
590 case VA_STATUS_ERROR_UNIMPLEMENTED:
591 return "the requested function is not implemented";
592 case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
593 return "surface is in displaying (may by overlay)" ;
594 case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT:
595 return "invalid VAImageFormat";
596 case VA_STATUS_ERROR_DECODING_ERROR:
597 return "internal decoding error";
598 case VA_STATUS_ERROR_ENCODING_ERROR:
599 return "internal encoding error";
600 case VA_STATUS_ERROR_INVALID_VALUE:
601 return "an invalid/unsupported value was supplied";
602 case VA_STATUS_ERROR_UNSUPPORTED_FILTER:
603 return "the requested filter is not supported";
604 case VA_STATUS_ERROR_INVALID_FILTER_CHAIN:
605 return "an invalid filter chain was supplied";
606 case VA_STATUS_ERROR_HW_BUSY:
607 return "HW busy now";
608 case VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE:
609 return "an unsupported memory type was supplied";
610 case VA_STATUS_ERROR_NOT_ENOUGH_BUFFER:
611 return "allocated memory size is not enough for input or output";
612 case VA_STATUS_ERROR_UNKNOWN:
613 return "unknown libva error";
615 return "unknown libva error / description missing";
618 VAStatus vaSetDriverName(
623 VADriverContextP ctx;
624 VAStatus vaStatus = VA_STATUS_SUCCESS;
625 char *override_driver_name = NULL;
628 if (strlen(driver_name) == 0 || strlen(driver_name) >=256) {
629 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
630 va_errorMessage(dpy, "vaSetDriverName returns %s\n",
631 vaErrorStr(vaStatus));
635 override_driver_name = strdup(driver_name);
636 if (!override_driver_name) {
637 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
638 va_errorMessage(dpy, "vaSetDriverName returns %s. Out of Memory\n",
639 vaErrorStr(vaStatus));
643 ctx->override_driver_name = override_driver_name;
644 return VA_STATUS_SUCCESS;
647 VAStatus vaInitialize (
649 int *major_version, /* out */
650 int *minor_version /* out */
653 const char *driver_name_env = NULL;
654 char *driver_name = NULL;
656 VADriverContextP ctx;
668 va_infoMessage(dpy, "VA-API version %s\n", VA_VERSION_S);
670 vaStatus = va_getDriverName(dpy, &driver_name);
672 if (!ctx->override_driver_name) {
673 va_infoMessage(dpy, "va_getDriverName() returns %d\n", vaStatus);
675 driver_name_env = getenv("LIBVA_DRIVER_NAME");
676 } else if (vaStatus == VA_STATUS_SUCCESS) {
680 driver_name = strdup(ctx->override_driver_name);
682 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
683 va_errorMessage(dpy, "vaInitialize() failed with %s, out of memory\n",
684 vaErrorStr(vaStatus));
687 va_infoMessage(dpy, "User requested driver '%s'\n", driver_name);
690 if (driver_name_env && (geteuid() == getuid())) {
691 /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
692 if (driver_name) /* memory is allocated in va_getDriverName */
695 driver_name = strdup(driver_name_env);
696 vaStatus = VA_STATUS_SUCCESS;
697 va_infoMessage(dpy, "User requested driver '%s'\n", driver_name);
700 if ((VA_STATUS_SUCCESS == vaStatus) && (driver_name != NULL)) {
701 vaStatus = va_openDriver(dpy, driver_name);
702 va_infoMessage(dpy, "va_openDriver() returns %d\n", vaStatus);
704 *major_version = VA_MAJOR_VERSION;
705 *minor_version = VA_MINOR_VERSION;
707 va_errorMessage(dpy, "va_getDriverName() failed with %s,driver_name=%s\n",
708 vaErrorStr(vaStatus), driver_name);
713 VA_TRACE_LOG(va_TraceInitialize, dpy, major_version, minor_version);
720 * After this call, all library internal resources will be cleaned up
722 VAStatus vaTerminate (
726 VAStatus vaStatus = VA_STATUS_SUCCESS;
727 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
728 VADriverContextP old_ctx;
733 if (old_ctx->handle) {
734 vaStatus = old_ctx->vtable->vaTerminate(old_ctx);
735 dlclose(old_ctx->handle);
736 old_ctx->handle = NULL;
738 free(old_ctx->vtable);
739 old_ctx->vtable = NULL;
740 free(old_ctx->vtable_vpp);
741 old_ctx->vtable_vpp = NULL;
743 if (old_ctx->override_driver_name) {
744 free(old_ctx->override_driver_name);
745 old_ctx->override_driver_name = NULL;
748 VA_TRACE_LOG(va_TraceTerminate, dpy);
754 if (VA_STATUS_SUCCESS == vaStatus)
755 pDisplayContext->vaDestroy(pDisplayContext);
761 * vaQueryVendorString returns a pointer to a zero-terminated string
762 * describing some aspects of the VA implemenation on a specific
763 * hardware accelerator. The format of the returned string is:
764 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
765 * e.g. for the Intel GMA500 implementation, an example would be:
766 * "IntelGMA500-1.0-0.2-patch3
768 const char *vaQueryVendorString (
772 if (!vaDisplayIsValid(dpy))
775 return CTX(dpy)->str_vendor;
779 /* Get maximum number of profiles supported by the implementation */
780 int vaMaxNumProfiles (
784 if (!vaDisplayIsValid(dpy))
787 return CTX(dpy)->max_profiles;
790 /* Get maximum number of entrypoints supported by the implementation */
791 int vaMaxNumEntrypoints (
795 if (!vaDisplayIsValid(dpy))
798 return CTX(dpy)->max_entrypoints;
802 /* Get maximum number of attributs supported by the implementation */
803 int vaMaxNumConfigAttributes (
807 if (!vaDisplayIsValid(dpy))
810 return CTX(dpy)->max_attributes;
813 VAStatus vaQueryConfigEntrypoints (
816 VAEntrypoint *entrypoints, /* out */
817 int *num_entrypoints /* out */
820 VADriverContextP ctx;
824 return ctx->vtable->vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
827 VAStatus vaGetConfigAttributes (
830 VAEntrypoint entrypoint,
831 VAConfigAttrib *attrib_list, /* in/out */
835 VADriverContextP ctx;
839 return ctx->vtable->vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
842 VAStatus vaQueryConfigProfiles (
844 VAProfile *profile_list, /* out */
845 int *num_profiles /* out */
848 VADriverContextP ctx;
852 return ctx->vtable->vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
855 VAStatus vaCreateConfig (
858 VAEntrypoint entrypoint,
859 VAConfigAttrib *attrib_list,
861 VAConfigID *config_id /* out */
864 VADriverContextP ctx;
865 VAStatus vaStatus = VA_STATUS_SUCCESS;
870 vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
872 /* record the current entrypoint for further trace/fool determination */
873 VA_TRACE_ALL(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
874 VA_FOOL_FUNC(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
879 VAStatus vaDestroyConfig (
884 VADriverContextP ctx;
885 VAStatus vaStatus = VA_STATUS_SUCCESS;
890 vaStatus = ctx->vtable->vaDestroyConfig ( ctx, config_id );
892 VA_TRACE_ALL(va_TraceDestroyConfig, dpy, config_id);
897 VAStatus vaQueryConfigAttributes (
899 VAConfigID config_id,
900 VAProfile *profile, /* out */
901 VAEntrypoint *entrypoint, /* out */
902 VAConfigAttrib *attrib_list,/* out */
903 int *num_attribs /* out */
906 VADriverContextP ctx;
910 return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
913 VAStatus vaQueryProcessingRate (
915 VAConfigID config_id,
916 VAProcessingRateParameter *proc_buf,
917 unsigned int *processing_rate /* out */
920 VADriverContextP ctx;
923 if(!ctx->vtable->vaQueryProcessingRate)
924 return VA_STATUS_ERROR_UNIMPLEMENTED;
925 return ctx->vtable->vaQueryProcessingRate( ctx, config_id, proc_buf, processing_rate);
928 /* XXX: this is a slow implementation that will be removed */
930 va_impl_query_surface_attributes(
931 VADriverContextP ctx,
933 VASurfaceAttrib *out_attribs,
934 unsigned int *out_num_attribs_ptr
937 VASurfaceAttrib *attribs = NULL;
938 unsigned int num_attribs, n;
939 VASurfaceAttrib *out_attrib;
940 unsigned int out_num_attribs;
941 VAImageFormat *image_formats = NULL;
942 int num_image_formats, i;
945 /* List of surface attributes to query */
946 struct va_surface_attrib_map {
947 VASurfaceAttribType type;
948 VAGenericValueType value_type;
950 static const struct va_surface_attrib_map attribs_map[] = {
951 { VASurfaceAttribMinWidth, VAGenericValueTypeInteger },
952 { VASurfaceAttribMaxWidth, VAGenericValueTypeInteger },
953 { VASurfaceAttribMinHeight, VAGenericValueTypeInteger },
954 { VASurfaceAttribMaxHeight, VAGenericValueTypeInteger },
955 { VASurfaceAttribMemoryType, VAGenericValueTypeInteger },
956 { VASurfaceAttribNone, VAGenericValueTypeInteger }
959 if (!out_attribs || !out_num_attribs_ptr)
960 return VA_STATUS_ERROR_INVALID_PARAMETER;
961 if (!ctx->vtable->vaGetSurfaceAttributes)
962 return VA_STATUS_ERROR_UNIMPLEMENTED;
964 num_image_formats = ctx->max_image_formats;
965 image_formats = malloc(num_image_formats * sizeof(*image_formats));
966 if (!image_formats) {
967 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
971 va_status = ctx->vtable->vaQueryImageFormats(
972 ctx, image_formats, &num_image_formats);
973 if (va_status != VA_STATUS_SUCCESS)
976 num_attribs = VASurfaceAttribCount + num_image_formats;
977 attribs = malloc(num_attribs * sizeof(*attribs));
979 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
983 /* Initialize with base surface attributes, except pixel-formats */
984 for (n = 0; attribs_map[n].type != VASurfaceAttribNone; n++) {
985 VASurfaceAttrib * const attrib = &attribs[n];
986 attrib->type = attribs_map[n].type;
987 attrib->flags = VA_SURFACE_ATTRIB_GETTABLE;
988 attrib->value.type = attribs_map[n].value_type;
991 /* Append image formats */
992 for (i = 0; i < num_image_formats; i++) {
993 VASurfaceAttrib * const attrib = &attribs[n];
994 attrib->type = VASurfaceAttribPixelFormat;
995 attrib->flags = VA_SURFACE_ATTRIB_GETTABLE|VA_SURFACE_ATTRIB_SETTABLE;
996 attrib->value.type = VAGenericValueTypeInteger;
997 attrib->value.value.i = image_formats[i].fourcc;
998 if (++n == num_attribs) {
999 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
1005 va_status = ctx->vtable->vaGetSurfaceAttributes(
1006 ctx, config, attribs, num_attribs);
1007 if (va_status != VA_STATUS_SUCCESS)
1010 /* Remove invalid entries */
1011 out_num_attribs = 0;
1012 for (n = 0; n < num_attribs; n++) {
1013 VASurfaceAttrib * const attrib = &attribs[n];
1015 if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED)
1018 // Accept all surface attributes that are not pixel-formats
1019 if (attrib->type != VASurfaceAttribPixelFormat) {
1024 // Drop invalid pixel-format attribute
1025 if (!attrib->value.value.i) {
1026 attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
1030 // Check for duplicates
1031 int is_duplicate = 0;
1032 for (i = n - 1; i >= 0 && !is_duplicate; i--) {
1033 const VASurfaceAttrib * const prev_attrib = &attribs[i];
1034 if (prev_attrib->type != VASurfaceAttribPixelFormat)
1036 is_duplicate = prev_attrib->value.value.i == attrib->value.value.i;
1039 attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
1044 if (*out_num_attribs_ptr < out_num_attribs) {
1045 *out_num_attribs_ptr = out_num_attribs;
1046 va_status = VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
1050 out_attrib = out_attribs;
1051 for (n = 0; n < num_attribs; n++) {
1052 const VASurfaceAttrib * const attrib = &attribs[n];
1053 if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED)
1055 *out_attrib++ = *attrib;
1060 free(image_formats);
1065 vaQuerySurfaceAttributes(
1068 VASurfaceAttrib *attrib_list,
1069 unsigned int *num_attribs
1072 VADriverContextP ctx;
1078 return VA_STATUS_ERROR_INVALID_DISPLAY;
1080 if (!ctx->vtable->vaQuerySurfaceAttributes)
1081 vaStatus = va_impl_query_surface_attributes(ctx, config,
1082 attrib_list, num_attribs);
1084 vaStatus = ctx->vtable->vaQuerySurfaceAttributes(ctx, config,
1085 attrib_list, num_attribs);
1087 VA_TRACE_LOG(va_TraceQuerySurfaceAttributes, dpy, config, attrib_list, num_attribs);
1095 unsigned int format,
1097 unsigned int height,
1098 VASurfaceID *surfaces,
1099 unsigned int num_surfaces,
1100 VASurfaceAttrib *attrib_list,
1101 unsigned int num_attribs
1104 VADriverContextP ctx;
1110 return VA_STATUS_ERROR_INVALID_DISPLAY;
1112 if (ctx->vtable->vaCreateSurfaces2)
1113 vaStatus = ctx->vtable->vaCreateSurfaces2(ctx, format, width, height,
1114 surfaces, num_surfaces,
1115 attrib_list, num_attribs);
1116 else if (attrib_list && num_attribs > 0)
1117 vaStatus = VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
1119 vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format,
1120 num_surfaces, surfaces);
1121 VA_TRACE_LOG(va_TraceCreateSurfaces,
1122 dpy, width, height, format, num_surfaces, surfaces,
1123 attrib_list, num_attribs);
1129 VAStatus vaDestroySurfaces (
1131 VASurfaceID *surface_list,
1135 VADriverContextP ctx;
1141 VA_TRACE_LOG(va_TraceDestroySurfaces,
1142 dpy, surface_list, num_surfaces);
1144 vaStatus = ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces );
1149 VAStatus vaCreateContext (
1151 VAConfigID config_id,
1155 VASurfaceID *render_targets,
1156 int num_render_targets,
1157 VAContextID *context /* out */
1160 VADriverContextP ctx;
1166 vaStatus = ctx->vtable->vaCreateContext( ctx, config_id, picture_width, picture_height,
1167 flag, render_targets, num_render_targets, context );
1169 /* keep current encode/decode resoluton */
1170 VA_TRACE_ALL(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
1175 VAStatus vaDestroyContext (
1180 VADriverContextP ctx;
1186 vaStatus = ctx->vtable->vaDestroyContext( ctx, context );
1188 VA_TRACE_ALL(va_TraceDestroyContext, dpy, context);
1193 VAStatus vaCreateMFContext (
1195 VAMFContextID *mf_context /* out */
1198 VADriverContextP ctx;
1203 if(ctx->vtable->vaCreateMFContext == NULL)
1204 vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
1207 vaStatus = ctx->vtable->vaCreateMFContext( ctx, mf_context);
1208 VA_TRACE_ALL(va_TraceCreateMFContext, dpy, mf_context);
1214 VAStatus vaMFAddContext (
1216 VAMFContextID mf_context,
1220 VADriverContextP ctx;
1226 if(ctx->vtable->vaMFAddContext == NULL)
1227 vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
1230 vaStatus = ctx->vtable->vaMFAddContext( ctx, context, mf_context);
1231 VA_TRACE_ALL(va_TraceMFAddContext, dpy, context, mf_context);
1237 VAStatus vaMFReleaseContext (
1239 VAMFContextID mf_context,
1243 VADriverContextP ctx;
1248 if(ctx->vtable->vaMFReleaseContext == NULL)
1249 vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
1252 vaStatus = ctx->vtable->vaMFReleaseContext( ctx, context, mf_context);
1253 VA_TRACE_ALL(va_TraceMFReleaseContext, dpy, context, mf_context);
1259 VAStatus vaMFSubmit (
1261 VAMFContextID mf_context,
1262 VAContextID *contexts,
1266 VADriverContextP ctx;
1271 CHECK_VTABLE(vaStatus, ctx, MFSubmit);
1272 if(ctx->vtable->vaMFSubmit == NULL)
1273 vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
1276 vaStatus = ctx->vtable->vaMFSubmit( ctx, mf_context, contexts, num_contexts);
1277 VA_TRACE_ALL(va_TraceMFSubmit, dpy, mf_context, contexts, num_contexts);
1283 VAStatus vaCreateBuffer (
1285 VAContextID context, /* in */
1286 VABufferType type, /* in */
1287 unsigned int size, /* in */
1288 unsigned int num_elements, /* in */
1289 void *data, /* in */
1290 VABufferID *buf_id /* out */
1293 VADriverContextP ctx;
1299 VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
1301 vaStatus = ctx->vtable->vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
1303 VA_TRACE_LOG(va_TraceCreateBuffer,
1304 dpy, context, type, size, num_elements, data, buf_id);
1309 VAStatus vaCreateBuffer2 (
1311 VAContextID context,
1314 unsigned int height,
1315 unsigned int *unit_size,
1316 unsigned int *pitch,
1320 VADriverContextP ctx;
1325 if(!ctx->vtable->vaCreateBuffer2)
1326 return VA_STATUS_ERROR_UNIMPLEMENTED;
1328 vaStatus = ctx->vtable->vaCreateBuffer2( ctx, context, type, width, height ,unit_size, pitch, buf_id);
1330 VA_TRACE_LOG(va_TraceCreateBuffer,
1331 dpy, context, type, *pitch, height, NULL, buf_id);
1336 VAStatus vaBufferSetNumElements (
1338 VABufferID buf_id, /* in */
1339 unsigned int num_elements /* in */
1342 VADriverContextP ctx;
1346 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1348 return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements );
1352 VAStatus vaMapBuffer (
1354 VABufferID buf_id, /* in */
1355 void **pbuf /* out */
1358 VADriverContextP ctx;
1364 VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
1366 va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
1368 VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
1373 VAStatus vaUnmapBuffer (
1375 VABufferID buf_id /* in */
1378 VADriverContextP ctx;
1382 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1384 return ctx->vtable->vaUnmapBuffer( ctx, buf_id );
1387 VAStatus vaDestroyBuffer (
1389 VABufferID buffer_id
1392 VADriverContextP ctx;
1396 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1398 VA_TRACE_LOG(va_TraceDestroyBuffer,
1401 return ctx->vtable->vaDestroyBuffer( ctx, buffer_id );
1404 VAStatus vaBufferInfo (
1406 VAContextID context, /* in */
1407 VABufferID buf_id, /* in */
1408 VABufferType *type, /* out */
1409 unsigned int *size, /* out */
1410 unsigned int *num_elements /* out */
1413 VADriverContextP ctx;
1418 VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements);
1420 return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements );
1423 /* Locks buffer for external API usage */
1425 vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info)
1427 VADriverContextP ctx;
1432 if (!ctx->vtable->vaAcquireBufferHandle)
1433 return VA_STATUS_ERROR_UNIMPLEMENTED;
1434 return ctx->vtable->vaAcquireBufferHandle(ctx, buf_id, buf_info);
1437 /* Unlocks buffer after usage from external API */
1439 vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id)
1441 VADriverContextP ctx;
1446 if (!ctx->vtable->vaReleaseBufferHandle)
1447 return VA_STATUS_ERROR_UNIMPLEMENTED;
1448 return ctx->vtable->vaReleaseBufferHandle(ctx, buf_id);
1452 vaExportSurfaceHandle(VADisplay dpy, VASurfaceID surface_id,
1453 uint32_t mem_type, uint32_t flags,
1456 VADriverContextP ctx;
1461 if (!ctx->vtable->vaExportSurfaceHandle)
1462 return VA_STATUS_ERROR_UNIMPLEMENTED;
1463 return ctx->vtable->vaExportSurfaceHandle(ctx, surface_id,
1468 VAStatus vaBeginPicture (
1470 VAContextID context,
1471 VASurfaceID render_target
1474 VADriverContextP ctx;
1480 VA_TRACE_ALL(va_TraceBeginPicture, dpy, context, render_target);
1481 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1483 va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target );
1488 VAStatus vaRenderPicture (
1490 VAContextID context,
1491 VABufferID *buffers,
1495 VADriverContextP ctx;
1500 VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
1501 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1503 return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers );
1506 VAStatus vaEndPicture (
1511 VAStatus va_status = VA_STATUS_SUCCESS;
1512 VADriverContextP ctx;
1517 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1519 va_status = ctx->vtable->vaEndPicture( ctx, context );
1521 /* dump surface content */
1522 VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 1);
1527 VAStatus vaSyncSurface (
1529 VASurfaceID render_target
1533 VADriverContextP ctx;
1538 va_status = ctx->vtable->vaSyncSurface( ctx, render_target );
1539 VA_TRACE_LOG(va_TraceSyncSurface, dpy, render_target);
1544 VAStatus vaQuerySurfaceStatus (
1546 VASurfaceID render_target,
1547 VASurfaceStatus *status /* out */
1551 VADriverContextP ctx;
1555 va_status = ctx->vtable->vaQuerySurfaceStatus( ctx, render_target, status );
1557 VA_TRACE_LOG(va_TraceQuerySurfaceStatus, dpy, render_target, status);
1562 VAStatus vaQuerySurfaceError (
1564 VASurfaceID surface,
1565 VAStatus error_status,
1566 void **error_info /*out*/
1570 VADriverContextP ctx;
1574 va_status = ctx->vtable->vaQuerySurfaceError( ctx, surface, error_status, error_info );
1576 VA_TRACE_LOG(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info);
1581 /* Get maximum number of image formats supported by the implementation */
1582 int vaMaxNumImageFormats (
1586 if (!vaDisplayIsValid(dpy))
1589 return CTX(dpy)->max_image_formats;
1592 VAStatus vaQueryImageFormats (
1594 VAImageFormat *format_list, /* out */
1595 int *num_formats /* out */
1598 VADriverContextP ctx;
1602 return ctx->vtable->vaQueryImageFormats ( ctx, format_list, num_formats);
1606 * The width and height fields returned in the VAImage structure may get
1607 * enlarged for some YUV formats. The size of the data buffer that needs
1608 * to be allocated will be given in the "data_size" field in VAImage.
1609 * Image data is not allocated by this function. The client should
1610 * allocate the memory and fill in the VAImage structure's data field
1611 * after looking at "data_size" returned from the library.
1613 VAStatus vaCreateImage (
1615 VAImageFormat *format,
1618 VAImage *image /* out */
1621 VADriverContextP ctx;
1625 return ctx->vtable->vaCreateImage ( ctx, format, width, height, image);
1629 * Should call DestroyImage before destroying the surface it is bound to
1631 VAStatus vaDestroyImage (
1636 VADriverContextP ctx;
1640 return ctx->vtable->vaDestroyImage ( ctx, image);
1643 VAStatus vaSetImagePalette (
1646 unsigned char *palette
1649 VADriverContextP ctx;
1653 return ctx->vtable->vaSetImagePalette ( ctx, image, palette);
1657 * Retrieve surface data into a VAImage
1658 * Image must be in a format supported by the implementation
1660 VAStatus vaGetImage (
1662 VASurfaceID surface,
1663 int x, /* coordinates of the upper left source pixel */
1665 unsigned int width, /* width and height of the region */
1666 unsigned int height,
1670 VADriverContextP ctx;
1674 return ctx->vtable->vaGetImage ( ctx, surface, x, y, width, height, image);
1678 * Copy data from a VAImage to a surface
1679 * Image must be in a format supported by the implementation
1681 VAStatus vaPutImage (
1683 VASurfaceID surface,
1687 unsigned int src_width,
1688 unsigned int src_height,
1691 unsigned int dest_width,
1692 unsigned int dest_height
1695 VADriverContextP ctx;
1699 return ctx->vtable->vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
1703 * Derive an VAImage from an existing surface.
1704 * This interface will derive a VAImage and corresponding image buffer from
1705 * an existing VA Surface. The image buffer can then be mapped/unmapped for
1706 * direct CPU access. This operation is only possible on implementations with
1707 * direct rendering capabilities and internal surface formats that can be
1708 * represented with a VAImage. When the operation is not possible this interface
1709 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
1710 * to using vaCreateImage + vaPutImage to accomplish the same task in an
1713 * Implementations should only return success when the resulting image buffer
1714 * would be useable with vaMap/Unmap.
1716 * When directly accessing a surface special care must be taken to insure
1717 * proper synchronization with the graphics hardware. Clients should call
1718 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
1719 * rendering or currently being displayed by an overlay.
1721 * Additionally nothing about the contents of a surface should be assumed
1722 * following a vaPutSurface. Implementations are free to modify the surface for
1723 * scaling or subpicture blending within a call to vaPutImage.
1725 * Calls to vaPutImage or vaGetImage using the same surface from which the image
1726 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
1727 * vaGetImage with other surfaces is supported.
1729 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
1730 * image and image buffer structures will be destroyed; however, the underlying
1731 * surface will remain unchanged until freed with vaDestroySurfaces.
1733 VAStatus vaDeriveImage (
1735 VASurfaceID surface,
1736 VAImage *image /* out */
1739 VADriverContextP ctx;
1743 return ctx->vtable->vaDeriveImage ( ctx, surface, image );
1747 /* Get maximum number of subpicture formats supported by the implementation */
1748 int vaMaxNumSubpictureFormats (
1752 if (!vaDisplayIsValid(dpy))
1755 return CTX(dpy)->max_subpic_formats;
1759 * Query supported subpicture formats
1760 * The caller must provide a "format_list" array that can hold at
1761 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
1762 * for each format to indicate additional capabilities for that format. The actual
1763 * number of formats returned in "format_list" is returned in "num_formats".
1765 VAStatus vaQuerySubpictureFormats (
1767 VAImageFormat *format_list, /* out */
1768 unsigned int *flags, /* out */
1769 unsigned int *num_formats /* out */
1772 VADriverContextP ctx;
1777 return ctx->vtable->vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
1781 * Subpictures are created with an image associated.
1783 VAStatus vaCreateSubpicture (
1786 VASubpictureID *subpicture /* out */
1789 VADriverContextP ctx;
1793 return ctx->vtable->vaCreateSubpicture ( ctx, image, subpicture );
1797 * Destroy the subpicture before destroying the image it is assocated to
1799 VAStatus vaDestroySubpicture (
1801 VASubpictureID subpicture
1804 VADriverContextP ctx;
1808 return ctx->vtable->vaDestroySubpicture ( ctx, subpicture);
1811 VAStatus vaSetSubpictureImage (
1813 VASubpictureID subpicture,
1817 VADriverContextP ctx;
1821 return ctx->vtable->vaSetSubpictureImage ( ctx, subpicture, image);
1826 * If chromakey is enabled, then the area where the source value falls within
1827 * the chromakey [min, max] range is transparent
1829 VAStatus vaSetSubpictureChromakey (
1831 VASubpictureID subpicture,
1832 unsigned int chromakey_min,
1833 unsigned int chromakey_max,
1834 unsigned int chromakey_mask
1837 VADriverContextP ctx;
1841 return ctx->vtable->vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1846 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1847 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1848 * the overall alpha is per-pixel alpha multiplied by the global alpha
1850 VAStatus vaSetSubpictureGlobalAlpha (
1852 VASubpictureID subpicture,
1856 VADriverContextP ctx;
1860 return ctx->vtable->vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1864 vaAssociateSubpicture associates the subpicture with the target_surface.
1865 It defines the region mapping between the subpicture and the target
1866 surface through source and destination rectangles (with the same width and height).
1867 Both will be displayed at the next call to vaPutSurface. Additional
1868 associations before the call to vaPutSurface simply overrides the association.
1870 VAStatus vaAssociateSubpicture (
1872 VASubpictureID subpicture,
1873 VASurfaceID *target_surfaces,
1875 short src_x, /* upper left offset in subpicture */
1877 unsigned short src_width,
1878 unsigned short src_height,
1879 short dest_x, /* upper left offset in surface */
1881 unsigned short dest_width,
1882 unsigned short dest_height,
1884 * whether to enable chroma-keying or global-alpha
1885 * see VA_SUBPICTURE_XXX values
1890 VADriverContextP ctx;
1894 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 );
1898 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1900 VAStatus vaDeassociateSubpicture (
1902 VASubpictureID subpicture,
1903 VASurfaceID *target_surfaces,
1907 VADriverContextP ctx;
1911 return ctx->vtable->vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1915 /* Get maximum number of display attributes supported by the implementation */
1916 int vaMaxNumDisplayAttributes (
1922 if (!vaDisplayIsValid(dpy))
1925 tmp = CTX(dpy)->max_display_attributes;
1927 VA_TRACE_LOG(va_TraceMaxNumDisplayAttributes, dpy, tmp);
1933 * Query display attributes
1934 * The caller must provide a "attr_list" array that can hold at
1935 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1936 * returned in "attr_list" is returned in "num_attributes".
1938 VAStatus vaQueryDisplayAttributes (
1940 VADisplayAttribute *attr_list, /* out */
1941 int *num_attributes /* out */
1944 VADriverContextP ctx;
1949 va_status = ctx->vtable->vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1951 VA_TRACE_LOG(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
1958 * Get display attributes
1959 * This function returns the current attribute values in "attr_list".
1960 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1961 * from vaQueryDisplayAttributes() can have their values retrieved.
1963 VAStatus vaGetDisplayAttributes (
1965 VADisplayAttribute *attr_list, /* in/out */
1969 VADriverContextP ctx;
1974 va_status = ctx->vtable->vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1976 VA_TRACE_LOG(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
1982 * Set display attributes
1983 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1984 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1985 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1987 VAStatus vaSetDisplayAttributes (
1989 VADisplayAttribute *attr_list,
1993 VADriverContextP ctx;
1998 va_status = ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1999 VA_TRACE_LOG(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
2004 VAStatus vaLockSurface(VADisplay dpy,
2005 VASurfaceID surface,
2006 unsigned int *fourcc, /* following are output argument */
2007 unsigned int *luma_stride,
2008 unsigned int *chroma_u_stride,
2009 unsigned int *chroma_v_stride,
2010 unsigned int *luma_offset,
2011 unsigned int *chroma_u_offset,
2012 unsigned int *chroma_v_offset,
2013 unsigned int *buffer_name,
2017 VADriverContextP ctx;
2021 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);
2025 VAStatus vaUnlockSurface(VADisplay dpy,
2029 VADriverContextP ctx;
2033 return ctx->vtable->vaUnlockSurface( ctx, surface );
2036 /* Video Processing */
2037 #define VA_VPP_INIT_CONTEXT(ctx, dpy) do { \
2038 CHECK_DISPLAY(dpy); \
2041 return VA_STATUS_ERROR_INVALID_DISPLAY; \
2044 #define VA_VPP_INVOKE(dpy, func, args) do { \
2045 if (!ctx->vtable_vpp->va##func) \
2046 return VA_STATUS_ERROR_UNIMPLEMENTED; \
2047 status = ctx->vtable_vpp->va##func args; \
2051 vaQueryVideoProcFilters(
2053 VAContextID context,
2054 VAProcFilterType *filters,
2055 unsigned int *num_filters
2058 VADriverContextP ctx;
2061 VA_VPP_INIT_CONTEXT(ctx, dpy);
2064 QueryVideoProcFilters,
2065 (ctx, context, filters, num_filters)
2071 vaQueryVideoProcFilterCaps(
2073 VAContextID context,
2074 VAProcFilterType type,
2076 unsigned int *num_filter_caps
2079 VADriverContextP ctx;
2082 VA_VPP_INIT_CONTEXT(ctx, dpy);
2085 QueryVideoProcFilterCaps,
2086 (ctx, context, type, filter_caps, num_filter_caps)
2092 vaQueryVideoProcPipelineCaps(
2094 VAContextID context,
2095 VABufferID *filters,
2096 unsigned int num_filters,
2097 VAProcPipelineCaps *pipeline_caps
2100 VADriverContextP ctx;
2103 VA_VPP_INIT_CONTEXT(ctx, dpy);
2106 QueryVideoProcPipelineCaps,
2107 (ctx, context, filters, num_filters, pipeline_caps)