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"
41 #include <cutils/log.h>
42 /* support versions < JellyBean */
51 #define DRIVER_EXTENSION "_drv_video.so"
53 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext)
54 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; }
57 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable->va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN;
58 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
59 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
62 * read a config "env" for libva.conf or from environment setting
63 * libva.conf has higher priority
64 * return 0: the "env" is set, and the value is copied into env_value
65 * 1: the env is not set
67 int va_parseConfig(char *env, char *env_value)
69 char *token, *value, *saveptr;
76 fp = fopen("/etc/libva.conf", "r");
77 while (fp && (fgets(oneline, 1024, fp) != NULL)) {
78 if (strlen(oneline) == 1)
80 token = strtok_r(oneline, "=\n", &saveptr);
81 value = strtok_r(NULL, "=\n", &saveptr);
83 if (NULL == token || NULL == value)
86 if (strcmp(token, env) == 0) {
88 strncpy(env_value,value, 1024);
89 env_value[1023] = '\0';
100 /* no setting in config file, use env setting */
104 strncpy(env_value, value, 1024);
105 env_value[1023] = '\0';
113 int vaDisplayIsValid(VADisplay dpy)
115 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
116 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
119 static void default_log_error(const char *buffer)
124 fprintf(stderr, "libva error: %s", buffer);
128 static void default_log_info(const char *buffer)
133 fprintf(stderr, "libva info: %s", buffer);
137 static vaMessageCallback va_log_error = default_log_error;
138 static vaMessageCallback va_log_info = default_log_info;
141 * Set the callback for error messages, or NULL for no logging.
142 * Returns the previous one, or NULL if it was disabled.
144 vaMessageCallback vaSetErrorCallback(vaMessageCallback callback)
146 vaMessageCallback old_callback = va_log_error;
147 va_log_error = callback;
152 * Set the callback for info messages, or NULL for no logging.
153 * Returns the previous one, or NULL if it was disabled.
155 vaMessageCallback vaSetInfoCallback(vaMessageCallback callback)
157 vaMessageCallback old_callback = va_log_info;
158 va_log_info = callback;
162 void va_MessagingInit()
164 #if ENABLE_VA_MESSAGING
165 char env_value[1024];
167 if (va_parseConfig("LIBVA_MESSAGING_LEVEL", &env_value[0]) == 0) {
168 if (strcmp(env_value, "0") == 0) {
169 vaSetInfoCallback(NULL);
170 vaSetErrorCallback(NULL);
173 if (strcmp(env_value, "1") == 0) {
174 vaSetInfoCallback(NULL);
180 void va_errorMessage(const char *msg, ...)
182 #if ENABLE_VA_MESSAGING
183 char buf[512], *dynbuf;
187 if (va_log_error == NULL)
191 len = vsnprintf(buf, sizeof(buf), msg, args);
194 if (len >= (int)sizeof(buf)) {
195 dynbuf = malloc(len + 1);
199 n = vsnprintf(dynbuf, len + 1, msg, args);
202 va_log_error(dynbuf);
210 void va_infoMessage(const char *msg, ...)
212 #if ENABLE_VA_MESSAGING
213 char buf[512], *dynbuf;
217 if (va_log_info == NULL)
221 len = vsnprintf(buf, sizeof(buf), msg, args);
224 if (len >= (int)sizeof(buf)) {
225 dynbuf = malloc(len + 1);
229 n = vsnprintf(dynbuf, len + 1, msg, args);
240 static bool va_checkVtable(void *ptr, char *function)
243 va_errorMessage("No valid vtable entry for va%s\n", function);
249 static bool va_checkMaximum(int value, char *variable)
252 va_errorMessage("Failed to define max_%s in init\n", variable);
258 static bool va_checkString(const char* value, char *variable)
261 va_errorMessage("Failed to define str_%s in init\n", variable);
268 va_getDriverInitName(char *name, int namelen, int major, int minor)
270 int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor);
271 return ret > 0 && ret < namelen;
274 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name)
276 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
278 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name);
281 static VAStatus va_openDriver(VADisplay dpy, char *driver_name)
283 VADriverContextP ctx = CTX(dpy);
284 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
285 char *search_path = NULL;
289 if (geteuid() == getuid())
290 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
291 search_path = getenv("LIBVA_DRIVERS_PATH");
293 search_path = VA_DRIVERS_PATH;
295 search_path = strdup((const char *)search_path);
296 driver_dir = strtok_r(search_path, ":", &saveptr);
299 char *driver_path = (char *) malloc( strlen(driver_dir) +
300 strlen(driver_name) +
301 strlen(DRIVER_EXTENSION) + 2 );
303 va_errorMessage("%s L%d Out of memory!n",
304 __FUNCTION__, __LINE__);
306 return VA_STATUS_ERROR_ALLOCATION_FAILED;
309 strncpy( driver_path, driver_dir, strlen(driver_dir) + 1);
310 strncat( driver_path, "/", strlen("/") );
311 strncat( driver_path, driver_name, strlen(driver_name) );
312 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) );
314 va_infoMessage("Trying to open %s\n", driver_path);
316 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE );
318 handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL);
321 /* Don't give errors for non-existing files */
322 if (0 == access( driver_path, F_OK))
323 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror());
325 VADriverInit init_func = NULL;
326 char init_func_s[256];
329 static const struct {
332 } compatible_versions[] = {
333 { VA_MAJOR_VERSION, VA_MINOR_VERSION },
345 for (i = 0; compatible_versions[i].major >= 0; i++) {
346 if (va_getDriverInitName(init_func_s, sizeof(init_func_s),
347 compatible_versions[i].major,
348 compatible_versions[i].minor)) {
349 init_func = (VADriverInit)dlsym(handle, init_func_s);
351 va_infoMessage("Found init function %s\n", init_func_s);
357 if (compatible_versions[i].major < 0) {
358 va_errorMessage("%s has no function %s\n",
359 driver_path, init_func_s);
362 struct VADriverVTable *vtable = ctx->vtable;
363 struct VADriverVTableVPP *vtable_vpp = ctx->vtable_vpp;
365 vaStatus = VA_STATUS_SUCCESS;
367 vtable = calloc(1, sizeof(*vtable));
369 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
371 ctx->vtable = vtable;
374 vtable_vpp = calloc(1, sizeof(*vtable_vpp));
376 vtable_vpp->version = VA_DRIVER_VTABLE_VPP_VERSION;
378 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
380 ctx->vtable_vpp = vtable_vpp;
382 if (init_func && VA_STATUS_SUCCESS == vaStatus)
383 vaStatus = (*init_func)(ctx);
385 if (VA_STATUS_SUCCESS == vaStatus) {
386 CHECK_MAXIMUM(vaStatus, ctx, profiles);
387 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
388 CHECK_MAXIMUM(vaStatus, ctx, attributes);
389 CHECK_MAXIMUM(vaStatus, ctx, image_formats);
390 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
391 CHECK_MAXIMUM(vaStatus, ctx, display_attributes);
392 CHECK_STRING(vaStatus, ctx, vendor);
393 CHECK_VTABLE(vaStatus, ctx, Terminate);
394 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
395 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
396 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes);
397 CHECK_VTABLE(vaStatus, ctx, CreateConfig);
398 CHECK_VTABLE(vaStatus, ctx, DestroyConfig);
399 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes);
400 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces);
401 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces);
402 CHECK_VTABLE(vaStatus, ctx, CreateContext);
403 CHECK_VTABLE(vaStatus, ctx, DestroyContext);
404 CHECK_VTABLE(vaStatus, ctx, CreateBuffer);
405 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements);
406 CHECK_VTABLE(vaStatus, ctx, MapBuffer);
407 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer);
408 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer);
409 CHECK_VTABLE(vaStatus, ctx, BeginPicture);
410 CHECK_VTABLE(vaStatus, ctx, RenderPicture);
411 CHECK_VTABLE(vaStatus, ctx, EndPicture);
412 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
413 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
414 CHECK_VTABLE(vaStatus, ctx, PutSurface);
415 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
416 CHECK_VTABLE(vaStatus, ctx, CreateImage);
417 CHECK_VTABLE(vaStatus, ctx, DeriveImage);
418 CHECK_VTABLE(vaStatus, ctx, DestroyImage);
419 CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
420 CHECK_VTABLE(vaStatus, ctx, GetImage);
421 CHECK_VTABLE(vaStatus, ctx, PutImage);
422 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
423 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
424 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
425 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage);
426 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
427 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
428 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
429 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
430 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
431 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
432 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes);
434 if (VA_STATUS_SUCCESS != vaStatus) {
435 va_errorMessage("%s init failed\n", driver_path);
438 if (VA_STATUS_SUCCESS == vaStatus)
439 ctx->handle = handle;
446 driver_dir = strtok_r(NULL, ":", &saveptr);
454 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
456 VADriverContextP ctx;
457 if (!vaDisplayIsValid(dpy))
461 if (NULL == ctx->handle)
464 return (VAPrivFunc) dlsym(ctx->handle, func);
469 * Returns a short english description of error_status
471 const char *vaErrorStr(VAStatus error_status)
473 switch(error_status) {
474 case VA_STATUS_SUCCESS:
475 return "success (no error)";
476 case VA_STATUS_ERROR_OPERATION_FAILED:
477 return "operation failed";
478 case VA_STATUS_ERROR_ALLOCATION_FAILED:
479 return "resource allocation failed";
480 case VA_STATUS_ERROR_INVALID_DISPLAY:
481 return "invalid VADisplay";
482 case VA_STATUS_ERROR_INVALID_CONFIG:
483 return "invalid VAConfigID";
484 case VA_STATUS_ERROR_INVALID_CONTEXT:
485 return "invalid VAContextID";
486 case VA_STATUS_ERROR_INVALID_SURFACE:
487 return "invalid VASurfaceID";
488 case VA_STATUS_ERROR_INVALID_BUFFER:
489 return "invalid VABufferID";
490 case VA_STATUS_ERROR_INVALID_IMAGE:
491 return "invalid VAImageID";
492 case VA_STATUS_ERROR_INVALID_SUBPICTURE:
493 return "invalid VASubpictureID";
494 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
495 return "attribute not supported";
496 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
497 return "list argument exceeds maximum number";
498 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE:
499 return "the requested VAProfile is not supported";
500 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT:
501 return "the requested VAEntryPoint is not supported";
502 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT:
503 return "the requested RT Format is not supported";
504 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
505 return "the requested VABufferType is not supported";
506 case VA_STATUS_ERROR_SURFACE_BUSY:
507 return "surface is in use";
508 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
509 return "flag not supported";
510 case VA_STATUS_ERROR_INVALID_PARAMETER:
511 return "invalid parameter";
512 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
513 return "resolution not supported";
514 case VA_STATUS_ERROR_UNIMPLEMENTED:
515 return "the requested function is not implemented";
516 case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING:
517 return "surface is in displaying (may by overlay)" ;
518 case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT:
519 return "invalid VAImageFormat";
520 case VA_STATUS_ERROR_INVALID_VALUE:
521 return "an invalid/unsupported value was supplied";
522 case VA_STATUS_ERROR_UNSUPPORTED_FILTER:
523 return "the requested filter is not supported";
524 case VA_STATUS_ERROR_INVALID_FILTER_CHAIN:
525 return "an invalid filter chain was supplied";
526 case VA_STATUS_ERROR_UNKNOWN:
527 return "unknown libva error";
529 return "unknown libva error / description missing";
532 const static char *prefer_driver_list[4] = {
539 VAStatus vaSetDriverName(
544 VADriverContextP ctx;
545 VAStatus vaStatus = VA_STATUS_SUCCESS;
546 char *override_driver_name = NULL;
550 if (geteuid() != getuid()) {
551 vaStatus = VA_STATUS_ERROR_OPERATION_FAILED;
552 va_errorMessage("no permission to vaSetDriverName\n");
556 if (strlen(driver_name) == 0 || strlen(driver_name) >=256) {
557 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
558 va_errorMessage("vaSetDriverName returns %s\n",
559 vaErrorStr(vaStatus));
564 for (i = 0; i < sizeof(prefer_driver_list) / sizeof(char *); i++) {
565 if (strlen(prefer_driver_list[i]) != strlen(driver_name))
567 if (!strncmp(prefer_driver_list[i], driver_name, strlen(driver_name))) {
574 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
575 va_errorMessage("vaSetDriverName returns %s. Incorrect parameter\n",
576 vaErrorStr(vaStatus));
580 override_driver_name = strdup(driver_name);
582 if (!override_driver_name) {
583 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
584 va_errorMessage("vaSetDriverName returns %s. Out of Memory\n",
585 vaErrorStr(vaStatus));
589 ctx->override_driver_name = override_driver_name;
590 return VA_STATUS_SUCCESS;
593 VAStatus vaInitialize (
595 int *major_version, /* out */
596 int *minor_version /* out */
599 const char *driver_name_env = NULL;
600 char *driver_name = NULL;
602 VADriverContextP ctx;
614 va_infoMessage("VA-API version %s\n", VA_VERSION_S);
616 vaStatus = va_getDriverName(dpy, &driver_name);
618 if (!ctx->override_driver_name) {
619 va_infoMessage("va_getDriverName() returns %d\n", vaStatus);
621 driver_name_env = getenv("LIBVA_DRIVER_NAME");
622 } else if (vaStatus == VA_STATUS_SUCCESS) {
626 driver_name = strdup(ctx->override_driver_name);
628 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
629 va_errorMessage("vaInitialize() failed with %s, out of memory\n",
630 vaErrorStr(vaStatus));
633 va_infoMessage("User requested driver '%s'\n", driver_name);
636 if (driver_name_env && (geteuid() == getuid())) {
637 /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */
638 if (driver_name) /* memory is allocated in va_getDriverName */
641 driver_name = strdup(driver_name_env);
642 vaStatus = VA_STATUS_SUCCESS;
643 va_infoMessage("User requested driver '%s'\n", driver_name);
646 if ((VA_STATUS_SUCCESS == vaStatus) && (driver_name != NULL)) {
647 vaStatus = va_openDriver(dpy, driver_name);
648 va_infoMessage("va_openDriver() returns %d\n", vaStatus);
650 *major_version = VA_MAJOR_VERSION;
651 *minor_version = VA_MINOR_VERSION;
653 va_errorMessage("va_getDriverName() failed with %s,driver_name=%s\n",
654 vaErrorStr(vaStatus), driver_name);
659 VA_TRACE_LOG(va_TraceInitialize, dpy, major_version, minor_version);
666 * After this call, all library internal resources will be cleaned up
668 VAStatus vaTerminate (
672 VAStatus vaStatus = VA_STATUS_SUCCESS;
673 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy;
674 VADriverContextP old_ctx;
679 if (old_ctx->handle) {
680 vaStatus = old_ctx->vtable->vaTerminate(old_ctx);
681 dlclose(old_ctx->handle);
682 old_ctx->handle = NULL;
684 free(old_ctx->vtable);
685 old_ctx->vtable = NULL;
686 free(old_ctx->vtable_vpp);
687 old_ctx->vtable_vpp = NULL;
689 if (old_ctx->override_driver_name) {
690 free(old_ctx->override_driver_name);
691 old_ctx->override_driver_name = NULL;
694 VA_TRACE_LOG(va_TraceTerminate, dpy);
700 if (VA_STATUS_SUCCESS == vaStatus)
701 pDisplayContext->vaDestroy(pDisplayContext);
707 * vaQueryVendorString returns a pointer to a zero-terminated string
708 * describing some aspects of the VA implemenation on a specific
709 * hardware accelerator. The format of the returned string is:
710 * <vendorname>-<major_version>-<minor_version>-<addtional_info>
711 * e.g. for the Intel GMA500 implementation, an example would be:
712 * "IntelGMA500-1.0-0.2-patch3
714 const char *vaQueryVendorString (
718 if (!vaDisplayIsValid(dpy))
721 return CTX(dpy)->str_vendor;
725 /* Get maximum number of profiles supported by the implementation */
726 int vaMaxNumProfiles (
730 if (!vaDisplayIsValid(dpy))
733 return CTX(dpy)->max_profiles;
736 /* Get maximum number of entrypoints supported by the implementation */
737 int vaMaxNumEntrypoints (
741 if (!vaDisplayIsValid(dpy))
744 return CTX(dpy)->max_entrypoints;
748 /* Get maximum number of attributs supported by the implementation */
749 int vaMaxNumConfigAttributes (
753 if (!vaDisplayIsValid(dpy))
756 return CTX(dpy)->max_attributes;
759 VAStatus vaQueryConfigEntrypoints (
762 VAEntrypoint *entrypoints, /* out */
763 int *num_entrypoints /* out */
766 VADriverContextP ctx;
770 return ctx->vtable->vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_entrypoints);
773 VAStatus vaGetConfigAttributes (
776 VAEntrypoint entrypoint,
777 VAConfigAttrib *attrib_list, /* in/out */
781 VADriverContextP ctx;
785 return ctx->vtable->vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_list, num_attribs );
788 VAStatus vaQueryConfigProfiles (
790 VAProfile *profile_list, /* out */
791 int *num_profiles /* out */
794 VADriverContextP ctx;
798 return ctx->vtable->vaQueryConfigProfiles ( ctx, profile_list, num_profiles );
801 VAStatus vaCreateConfig (
804 VAEntrypoint entrypoint,
805 VAConfigAttrib *attrib_list,
807 VAConfigID *config_id /* out */
810 VADriverContextP ctx;
811 VAStatus vaStatus = VA_STATUS_SUCCESS;
816 vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list, num_attribs, config_id );
818 /* record the current entrypoint for further trace/fool determination */
819 VA_TRACE_ALL(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
820 VA_FOOL_FUNC(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_attribs, config_id);
825 VAStatus vaDestroyConfig (
830 VADriverContextP ctx;
831 VAStatus vaStatus = VA_STATUS_SUCCESS;
836 vaStatus = ctx->vtable->vaDestroyConfig ( ctx, config_id );
838 VA_TRACE_ALL(va_TraceDestroyConfig, dpy, config_id);
843 VAStatus vaQueryConfigAttributes (
845 VAConfigID config_id,
846 VAProfile *profile, /* out */
847 VAEntrypoint *entrypoint, /* out */
848 VAConfigAttrib *attrib_list,/* out */
849 int *num_attribs /* out */
852 VADriverContextP ctx;
856 return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoint, attrib_list, num_attribs);
859 /* XXX: this is a slow implementation that will be removed */
861 va_impl_query_surface_attributes(
862 VADriverContextP ctx,
864 VASurfaceAttrib *out_attribs,
865 unsigned int *out_num_attribs_ptr
868 VASurfaceAttrib *attribs = NULL;
869 unsigned int num_attribs, n;
870 VASurfaceAttrib *out_attrib;
871 unsigned int out_num_attribs;
872 VAImageFormat *image_formats = NULL;
873 int num_image_formats, i;
876 /* List of surface attributes to query */
877 struct va_surface_attrib_map {
878 VASurfaceAttribType type;
879 VAGenericValueType value_type;
881 static const struct va_surface_attrib_map attribs_map[] = {
882 { VASurfaceAttribMinWidth, VAGenericValueTypeInteger },
883 { VASurfaceAttribMaxWidth, VAGenericValueTypeInteger },
884 { VASurfaceAttribMinHeight, VAGenericValueTypeInteger },
885 { VASurfaceAttribMaxHeight, VAGenericValueTypeInteger },
886 { VASurfaceAttribMemoryType, VAGenericValueTypeInteger },
887 { VASurfaceAttribNone, }
890 if (!out_attribs || !out_num_attribs_ptr)
891 return VA_STATUS_ERROR_INVALID_PARAMETER;
892 if (!ctx->vtable->vaGetSurfaceAttributes)
893 return VA_STATUS_ERROR_UNIMPLEMENTED;
895 num_image_formats = ctx->max_image_formats;
896 image_formats = malloc(num_image_formats * sizeof(*image_formats));
897 if (!image_formats) {
898 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
902 va_status = ctx->vtable->vaQueryImageFormats(
903 ctx, image_formats, &num_image_formats);
904 if (va_status != VA_STATUS_SUCCESS)
907 num_attribs = VASurfaceAttribCount + num_image_formats;
908 attribs = malloc(num_attribs * sizeof(*attribs));
910 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
914 /* Initialize with base surface attributes, except pixel-formats */
915 for (n = 0; attribs_map[n].type != VASurfaceAttribNone; n++) {
916 VASurfaceAttrib * const attrib = &attribs[n];
917 attrib->type = attribs_map[n].type;
918 attrib->flags = VA_SURFACE_ATTRIB_GETTABLE;
919 attrib->value.type = attribs_map[n].value_type;
922 /* Append image formats */
923 for (i = 0; i < num_image_formats; i++) {
924 VASurfaceAttrib * const attrib = &attribs[n];
925 attrib->type = VASurfaceAttribPixelFormat;
926 attrib->flags = VA_SURFACE_ATTRIB_GETTABLE|VA_SURFACE_ATTRIB_SETTABLE;
927 attrib->value.type = VAGenericValueTypeInteger;
928 attrib->value.value.i = image_formats[i].fourcc;
929 if (++n == num_attribs) {
930 va_status = VA_STATUS_ERROR_ALLOCATION_FAILED;
936 va_status = ctx->vtable->vaGetSurfaceAttributes(
937 ctx, config, attribs, num_attribs);
938 if (va_status != VA_STATUS_SUCCESS)
941 /* Remove invalid entries */
943 for (n = 0; n < num_attribs; n++) {
944 VASurfaceAttrib * const attrib = &attribs[n];
946 if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED)
949 // Accept all surface attributes that are not pixel-formats
950 if (attrib->type != VASurfaceAttribPixelFormat) {
955 // Drop invalid pixel-format attribute
956 if (!attrib->value.value.i) {
957 attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
961 // Check for duplicates
962 int is_duplicate = 0;
963 for (i = n - 1; i >= 0 && !is_duplicate; i--) {
964 const VASurfaceAttrib * const prev_attrib = &attribs[i];
965 if (prev_attrib->type != VASurfaceAttribPixelFormat)
967 is_duplicate = prev_attrib->value.value.i == attrib->value.value.i;
970 attrib->flags = VA_SURFACE_ATTRIB_NOT_SUPPORTED;
975 if (*out_num_attribs_ptr < out_num_attribs) {
976 *out_num_attribs_ptr = out_num_attribs;
977 va_status = VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
981 out_attrib = out_attribs;
982 for (n = 0; n < num_attribs; n++) {
983 const VASurfaceAttrib * const attrib = &attribs[n];
984 if (attrib->flags == VA_SURFACE_ATTRIB_NOT_SUPPORTED)
986 *out_attrib++ = *attrib;
996 vaQuerySurfaceAttributes(
999 VASurfaceAttrib *attrib_list,
1000 unsigned int *num_attribs
1003 VADriverContextP ctx;
1009 return VA_STATUS_ERROR_INVALID_DISPLAY;
1011 if (!ctx->vtable->vaQuerySurfaceAttributes)
1012 vaStatus = va_impl_query_surface_attributes(ctx, config,
1013 attrib_list, num_attribs);
1015 vaStatus = ctx->vtable->vaQuerySurfaceAttributes(ctx, config,
1016 attrib_list, num_attribs);
1018 VA_TRACE_LOG(va_TraceQuerySurfaceAttributes, dpy, config, attrib_list, num_attribs);
1026 unsigned int format,
1028 unsigned int height,
1029 VASurfaceID *surfaces,
1030 unsigned int num_surfaces,
1031 VASurfaceAttrib *attrib_list,
1032 unsigned int num_attribs
1035 VADriverContextP ctx;
1041 return VA_STATUS_ERROR_INVALID_DISPLAY;
1043 if (ctx->vtable->vaCreateSurfaces2)
1044 vaStatus = ctx->vtable->vaCreateSurfaces2(ctx, format, width, height,
1045 surfaces, num_surfaces,
1046 attrib_list, num_attribs);
1047 else if (attrib_list && num_attribs > 0)
1048 vaStatus = VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
1050 vaStatus = ctx->vtable->vaCreateSurfaces(ctx, width, height, format,
1051 num_surfaces, surfaces);
1052 VA_TRACE_LOG(va_TraceCreateSurfaces,
1053 dpy, width, height, format, num_surfaces, surfaces,
1054 attrib_list, num_attribs);
1060 VAStatus vaDestroySurfaces (
1062 VASurfaceID *surface_list,
1066 VADriverContextP ctx;
1072 VA_TRACE_LOG(va_TraceDestroySurfaces,
1073 dpy, surface_list, num_surfaces);
1075 vaStatus = ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces );
1080 VAStatus vaCreateContext (
1082 VAConfigID config_id,
1086 VASurfaceID *render_targets,
1087 int num_render_targets,
1088 VAContextID *context /* out */
1091 VADriverContextP ctx;
1097 vaStatus = ctx->vtable->vaCreateContext( ctx, config_id, picture_width, picture_height,
1098 flag, render_targets, num_render_targets, context );
1100 /* keep current encode/decode resoluton */
1101 VA_TRACE_ALL(va_TraceCreateContext, dpy, config_id, picture_width, picture_height, flag, render_targets, num_render_targets, context);
1106 VAStatus vaDestroyContext (
1111 VADriverContextP ctx;
1117 vaStatus = ctx->vtable->vaDestroyContext( ctx, context );
1119 VA_TRACE_ALL(va_TraceDestroyContext, dpy, context);
1124 VAStatus vaCreateBuffer (
1126 VAContextID context, /* in */
1127 VABufferType type, /* in */
1128 unsigned int size, /* in */
1129 unsigned int num_elements, /* in */
1130 void *data, /* in */
1131 VABufferID *buf_id /* out */
1134 VADriverContextP ctx;
1140 VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data, buf_id);
1142 vaStatus = ctx->vtable->vaCreateBuffer( ctx, context, type, size, num_elements, data, buf_id);
1144 VA_TRACE_LOG(va_TraceCreateBuffer,
1145 dpy, context, type, size, num_elements, data, buf_id);
1150 VAStatus vaBufferSetNumElements (
1152 VABufferID buf_id, /* in */
1153 unsigned int num_elements /* in */
1156 VADriverContextP ctx;
1160 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1162 return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements );
1166 VAStatus vaMapBuffer (
1168 VABufferID buf_id, /* in */
1169 void **pbuf /* out */
1172 VADriverContextP ctx;
1178 VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf);
1180 va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf );
1182 VA_TRACE_ALL(va_TraceMapBuffer, dpy, buf_id, pbuf);
1187 VAStatus vaUnmapBuffer (
1189 VABufferID buf_id /* in */
1192 VADriverContextP ctx;
1196 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1198 return ctx->vtable->vaUnmapBuffer( ctx, buf_id );
1201 VAStatus vaDestroyBuffer (
1203 VABufferID buffer_id
1206 VADriverContextP ctx;
1210 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1212 VA_TRACE_LOG(va_TraceDestroyBuffer,
1215 return ctx->vtable->vaDestroyBuffer( ctx, buffer_id );
1218 VAStatus vaBufferInfo (
1220 VAContextID context, /* in */
1221 VABufferID buf_id, /* in */
1222 VABufferType *type, /* out */
1223 unsigned int *size, /* out */
1224 unsigned int *num_elements /* out */
1227 VADriverContextP ctx;
1232 VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements);
1234 return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements );
1237 /* Locks buffer for external API usage */
1239 vaAcquireBufferHandle(VADisplay dpy, VABufferID buf_id, VABufferInfo *buf_info)
1241 VADriverContextP ctx;
1246 if (!ctx->vtable->vaAcquireBufferHandle)
1247 return VA_STATUS_ERROR_UNIMPLEMENTED;
1248 return ctx->vtable->vaAcquireBufferHandle(ctx, buf_id, buf_info);
1251 /* Unlocks buffer after usage from external API */
1253 vaReleaseBufferHandle(VADisplay dpy, VABufferID buf_id)
1255 VADriverContextP ctx;
1260 if (!ctx->vtable->vaReleaseBufferHandle)
1261 return VA_STATUS_ERROR_UNIMPLEMENTED;
1262 return ctx->vtable->vaReleaseBufferHandle(ctx, buf_id);
1265 VAStatus vaBeginPicture (
1267 VAContextID context,
1268 VASurfaceID render_target
1271 VADriverContextP ctx;
1277 VA_TRACE_ALL(va_TraceBeginPicture, dpy, context, render_target);
1278 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1280 va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target );
1285 VAStatus vaRenderPicture (
1287 VAContextID context,
1288 VABufferID *buffers,
1292 VADriverContextP ctx;
1297 VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers);
1298 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1300 return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers );
1303 VAStatus vaEndPicture (
1308 VAStatus va_status = VA_STATUS_SUCCESS;
1309 VADriverContextP ctx;
1314 VA_FOOL_FUNC(va_FoolCheckContinuity, dpy);
1316 va_status = ctx->vtable->vaEndPicture( ctx, context );
1318 /* dump surface content */
1319 VA_TRACE_ALL(va_TraceEndPicture, dpy, context, 1);
1324 VAStatus vaSyncSurface (
1326 VASurfaceID render_target
1330 VADriverContextP ctx;
1335 va_status = ctx->vtable->vaSyncSurface( ctx, render_target );
1336 VA_TRACE_LOG(va_TraceSyncSurface, dpy, render_target);
1341 VAStatus vaQuerySurfaceStatus (
1343 VASurfaceID render_target,
1344 VASurfaceStatus *status /* out */
1348 VADriverContextP ctx;
1352 va_status = ctx->vtable->vaQuerySurfaceStatus( ctx, render_target, status );
1354 VA_TRACE_LOG(va_TraceQuerySurfaceStatus, dpy, render_target, status);
1359 VAStatus vaQuerySurfaceError (
1361 VASurfaceID surface,
1362 VAStatus error_status,
1363 void **error_info /*out*/
1367 VADriverContextP ctx;
1371 va_status = ctx->vtable->vaQuerySurfaceError( ctx, surface, error_status, error_info );
1373 VA_TRACE_LOG(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info);
1378 /* Get maximum number of image formats supported by the implementation */
1379 int vaMaxNumImageFormats (
1383 if (!vaDisplayIsValid(dpy))
1386 return CTX(dpy)->max_image_formats;
1389 VAStatus vaQueryImageFormats (
1391 VAImageFormat *format_list, /* out */
1392 int *num_formats /* out */
1395 VADriverContextP ctx;
1399 return ctx->vtable->vaQueryImageFormats ( ctx, format_list, num_formats);
1403 * The width and height fields returned in the VAImage structure may get
1404 * enlarged for some YUV formats. The size of the data buffer that needs
1405 * to be allocated will be given in the "data_size" field in VAImage.
1406 * Image data is not allocated by this function. The client should
1407 * allocate the memory and fill in the VAImage structure's data field
1408 * after looking at "data_size" returned from the library.
1410 VAStatus vaCreateImage (
1412 VAImageFormat *format,
1415 VAImage *image /* out */
1418 VADriverContextP ctx;
1422 return ctx->vtable->vaCreateImage ( ctx, format, width, height, image);
1426 * Should call DestroyImage before destroying the surface it is bound to
1428 VAStatus vaDestroyImage (
1433 VADriverContextP ctx;
1437 return ctx->vtable->vaDestroyImage ( ctx, image);
1440 VAStatus vaSetImagePalette (
1443 unsigned char *palette
1446 VADriverContextP ctx;
1450 return ctx->vtable->vaSetImagePalette ( ctx, image, palette);
1454 * Retrieve surface data into a VAImage
1455 * Image must be in a format supported by the implementation
1457 VAStatus vaGetImage (
1459 VASurfaceID surface,
1460 int x, /* coordinates of the upper left source pixel */
1462 unsigned int width, /* width and height of the region */
1463 unsigned int height,
1467 VADriverContextP ctx;
1471 return ctx->vtable->vaGetImage ( ctx, surface, x, y, width, height, image);
1475 * Copy data from a VAImage to a surface
1476 * Image must be in a format supported by the implementation
1478 VAStatus vaPutImage (
1480 VASurfaceID surface,
1484 unsigned int src_width,
1485 unsigned int src_height,
1488 unsigned int dest_width,
1489 unsigned int dest_height
1492 VADriverContextP ctx;
1496 return ctx->vtable->vaPutImage ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
1500 * Derive an VAImage from an existing surface.
1501 * This interface will derive a VAImage and corresponding image buffer from
1502 * an existing VA Surface. The image buffer can then be mapped/unmapped for
1503 * direct CPU access. This operation is only possible on implementations with
1504 * direct rendering capabilities and internal surface formats that can be
1505 * represented with a VAImage. When the operation is not possible this interface
1506 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
1507 * to using vaCreateImage + vaPutImage to accomplish the same task in an
1510 * Implementations should only return success when the resulting image buffer
1511 * would be useable with vaMap/Unmap.
1513 * When directly accessing a surface special care must be taken to insure
1514 * proper synchronization with the graphics hardware. Clients should call
1515 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
1516 * rendering or currently being displayed by an overlay.
1518 * Additionally nothing about the contents of a surface should be assumed
1519 * following a vaPutSurface. Implementations are free to modify the surface for
1520 * scaling or subpicture blending within a call to vaPutImage.
1522 * Calls to vaPutImage or vaGetImage using the same surface from which the image
1523 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
1524 * vaGetImage with other surfaces is supported.
1526 * An image created with vaDeriveImage should be freed with vaDestroyImage. The
1527 * image and image buffer structures will be destroyed; however, the underlying
1528 * surface will remain unchanged until freed with vaDestroySurfaces.
1530 VAStatus vaDeriveImage (
1532 VASurfaceID surface,
1533 VAImage *image /* out */
1536 VADriverContextP ctx;
1540 return ctx->vtable->vaDeriveImage ( ctx, surface, image );
1544 /* Get maximum number of subpicture formats supported by the implementation */
1545 int vaMaxNumSubpictureFormats (
1549 if (!vaDisplayIsValid(dpy))
1552 return CTX(dpy)->max_subpic_formats;
1556 * Query supported subpicture formats
1557 * The caller must provide a "format_list" array that can hold at
1558 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
1559 * for each format to indicate additional capabilities for that format. The actual
1560 * number of formats returned in "format_list" is returned in "num_formats".
1562 VAStatus vaQuerySubpictureFormats (
1564 VAImageFormat *format_list, /* out */
1565 unsigned int *flags, /* out */
1566 unsigned int *num_formats /* out */
1569 VADriverContextP ctx;
1574 return ctx->vtable->vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
1578 * Subpictures are created with an image associated.
1580 VAStatus vaCreateSubpicture (
1583 VASubpictureID *subpicture /* out */
1586 VADriverContextP ctx;
1590 return ctx->vtable->vaCreateSubpicture ( ctx, image, subpicture );
1594 * Destroy the subpicture before destroying the image it is assocated to
1596 VAStatus vaDestroySubpicture (
1598 VASubpictureID subpicture
1601 VADriverContextP ctx;
1605 return ctx->vtable->vaDestroySubpicture ( ctx, subpicture);
1608 VAStatus vaSetSubpictureImage (
1610 VASubpictureID subpicture,
1614 VADriverContextP ctx;
1618 return ctx->vtable->vaSetSubpictureImage ( ctx, subpicture, image);
1623 * If chromakey is enabled, then the area where the source value falls within
1624 * the chromakey [min, max] range is transparent
1626 VAStatus vaSetSubpictureChromakey (
1628 VASubpictureID subpicture,
1629 unsigned int chromakey_min,
1630 unsigned int chromakey_max,
1631 unsigned int chromakey_mask
1634 VADriverContextP ctx;
1638 return ctx->vtable->vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max, chromakey_mask );
1643 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1644 * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1645 * the overall alpha is per-pixel alpha multiplied by the global alpha
1647 VAStatus vaSetSubpictureGlobalAlpha (
1649 VASubpictureID subpicture,
1653 VADriverContextP ctx;
1657 return ctx->vtable->vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
1661 vaAssociateSubpicture associates the subpicture with the target_surface.
1662 It defines the region mapping between the subpicture and the target
1663 surface through source and destination rectangles (with the same width and height).
1664 Both will be displayed at the next call to vaPutSurface. Additional
1665 associations before the call to vaPutSurface simply overrides the association.
1667 VAStatus vaAssociateSubpicture (
1669 VASubpictureID subpicture,
1670 VASurfaceID *target_surfaces,
1672 short src_x, /* upper left offset in subpicture */
1674 unsigned short src_width,
1675 unsigned short src_height,
1676 short dest_x, /* upper left offset in surface */
1678 unsigned short dest_width,
1679 unsigned short dest_height,
1681 * whether to enable chroma-keying or global-alpha
1682 * see VA_SUBPICTURE_XXX values
1687 VADriverContextP ctx;
1691 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 );
1695 * vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
1697 VAStatus vaDeassociateSubpicture (
1699 VASubpictureID subpicture,
1700 VASurfaceID *target_surfaces,
1704 VADriverContextP ctx;
1708 return ctx->vtable->vaDeassociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces );
1712 /* Get maximum number of display attributes supported by the implementation */
1713 int vaMaxNumDisplayAttributes (
1719 if (!vaDisplayIsValid(dpy))
1722 tmp = CTX(dpy)->max_display_attributes;
1724 VA_TRACE_LOG(va_TraceMaxNumDisplayAttributes, dpy, tmp);
1730 * Query display attributes
1731 * The caller must provide a "attr_list" array that can hold at
1732 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes
1733 * returned in "attr_list" is returned in "num_attributes".
1735 VAStatus vaQueryDisplayAttributes (
1737 VADisplayAttribute *attr_list, /* out */
1738 int *num_attributes /* out */
1741 VADriverContextP ctx;
1746 va_status = ctx->vtable->vaQueryDisplayAttributes ( ctx, attr_list, num_attributes );
1748 VA_TRACE_LOG(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes);
1755 * Get display attributes
1756 * This function returns the current attribute values in "attr_list".
1757 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
1758 * from vaQueryDisplayAttributes() can have their values retrieved.
1760 VAStatus vaGetDisplayAttributes (
1762 VADisplayAttribute *attr_list, /* in/out */
1766 VADriverContextP ctx;
1771 va_status = ctx->vtable->vaGetDisplayAttributes ( ctx, attr_list, num_attributes );
1773 VA_TRACE_LOG(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes);
1779 * Set display attributes
1780 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field
1781 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable or
1782 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED
1784 VAStatus vaSetDisplayAttributes (
1786 VADisplayAttribute *attr_list,
1790 VADriverContextP ctx;
1795 va_status = ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attributes );
1796 VA_TRACE_LOG(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes);
1801 VAStatus vaLockSurface(VADisplay dpy,
1802 VASurfaceID surface,
1803 unsigned int *fourcc, /* following are output argument */
1804 unsigned int *luma_stride,
1805 unsigned int *chroma_u_stride,
1806 unsigned int *chroma_v_stride,
1807 unsigned int *luma_offset,
1808 unsigned int *chroma_u_offset,
1809 unsigned int *chroma_v_offset,
1810 unsigned int *buffer_name,
1814 VADriverContextP ctx;
1818 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);
1822 VAStatus vaUnlockSurface(VADisplay dpy,
1826 VADriverContextP ctx;
1830 return ctx->vtable->vaUnlockSurface( ctx, surface );
1833 /* Video Processing */
1834 #define VA_VPP_INIT_CONTEXT(ctx, dpy) do { \
1835 CHECK_DISPLAY(dpy); \
1838 return VA_STATUS_ERROR_INVALID_DISPLAY; \
1841 #define VA_VPP_INVOKE(dpy, func, args) do { \
1842 if (!ctx->vtable_vpp->va##func) \
1843 return VA_STATUS_ERROR_UNIMPLEMENTED; \
1844 status = ctx->vtable_vpp->va##func args; \
1848 vaQueryVideoProcFilters(
1850 VAContextID context,
1851 VAProcFilterType *filters,
1852 unsigned int *num_filters
1855 VADriverContextP ctx;
1858 VA_VPP_INIT_CONTEXT(ctx, dpy);
1861 QueryVideoProcFilters,
1862 (ctx, context, filters, num_filters)
1868 vaQueryVideoProcFilterCaps(
1870 VAContextID context,
1871 VAProcFilterType type,
1873 unsigned int *num_filter_caps
1876 VADriverContextP ctx;
1879 VA_VPP_INIT_CONTEXT(ctx, dpy);
1882 QueryVideoProcFilterCaps,
1883 (ctx, context, type, filter_caps, num_filter_caps)
1889 vaQueryVideoProcPipelineCaps(
1891 VAContextID context,
1892 VABufferID *filters,
1893 unsigned int num_filters,
1894 VAProcPipelineCaps *pipeline_caps
1897 VADriverContextP ctx;
1900 VA_VPP_INIT_CONTEXT(ctx, dpy);
1903 QueryVideoProcPipelineCaps,
1904 (ctx, context, filters, num_filters, pipeline_caps)