OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2007 Intel Corporation. All Rights Reserved. |
| 3 * |
| 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: |
| 11 * |
| 12 * The above copyright notice and this permission notice (including the |
| 13 * next paragraph) shall be included in all copies or substantial portions |
| 14 * of the Software. |
| 15 * |
| 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. |
| 23 */ |
| 24 |
| 25 #define _GNU_SOURCE 1 |
| 26 #include "sysdeps.h" |
| 27 #include "va.h" |
| 28 #include "va_backend.h" |
| 29 #include "va_trace.h" |
| 30 #include "va_fool.h" |
| 31 |
| 32 #include <assert.h> |
| 33 #include <stdarg.h> |
| 34 #include <stdio.h> |
| 35 #include <stdlib.h> |
| 36 #include <string.h> |
| 37 #include <dlfcn.h> |
| 38 #include <unistd.h> |
| 39 |
| 40 #define DRIVER_EXTENSION "_drv_video.so" |
| 41 |
| 42 #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
| 43 #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR
_INVALID_DISPLAY; } |
| 44 |
| 45 #define ASSERT assert |
| 46 #define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable->va##func, #f
unc)) s = VA_STATUS_ERROR_UNKNOWN; |
| 47 #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s
= VA_STATUS_ERROR_UNKNOWN; |
| 48 #define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s =
VA_STATUS_ERROR_UNKNOWN; |
| 49 |
| 50 #define Bool int |
| 51 #define True 1 |
| 52 #define False 0 |
| 53 |
| 54 /* |
| 55 * read a config "env" for libva.conf or from environment setting |
| 56 * liva.conf has higher priority |
| 57 * return 0: the "env" is set, and the value is copied into env_value |
| 58 * 1: the env is not set |
| 59 */ |
| 60 int va_parseConfig(char *env, char *env_value) |
| 61 { |
| 62 char *token, *value, *saveptr; |
| 63 char oneline[1024]; |
| 64 FILE *fp=NULL; |
| 65 |
| 66 if (env == NULL) |
| 67 return 1; |
| 68 |
| 69 fp = fopen("/etc/libva.conf", "r"); |
| 70 while (fp && (fgets(oneline, 1024, fp) != NULL)) { |
| 71 if (strlen(oneline) == 1) |
| 72 continue; |
| 73 token = strtok_r(oneline, "=\n", &saveptr); |
| 74 value = strtok_r(NULL, "=\n", &saveptr); |
| 75 |
| 76 if (NULL == token || NULL == value) |
| 77 continue; |
| 78 |
| 79 if (strcmp(token, env) == 0) { |
| 80 if (env_value) |
| 81 strncpy(env_value,value, 1024); |
| 82 |
| 83 fclose(fp); |
| 84 |
| 85 return 0; |
| 86 } |
| 87 } |
| 88 if (fp) |
| 89 fclose(fp); |
| 90 |
| 91 /* no setting in config file, use env setting */ |
| 92 if (getenv(env)) { |
| 93 if (env_value) |
| 94 strncpy(env_value, getenv(env), 1024); |
| 95 |
| 96 return 0; |
| 97 } |
| 98 |
| 99 return 1; |
| 100 } |
| 101 |
| 102 int vaDisplayIsValid(VADisplay dpy) |
| 103 { |
| 104 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; |
| 105 return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC)
&& pDisplayContext->vaIsValid(pDisplayContext); |
| 106 } |
| 107 |
| 108 void va_errorMessage(const char *msg, ...) |
| 109 { |
| 110 va_list args; |
| 111 |
| 112 fprintf(stderr, "libva error: "); |
| 113 va_start(args, msg); |
| 114 vfprintf(stderr, msg, args); |
| 115 va_end(args); |
| 116 } |
| 117 |
| 118 void va_infoMessage(const char *msg, ...) |
| 119 { |
| 120 va_list args; |
| 121 |
| 122 fprintf(stderr, "libva: "); |
| 123 va_start(args, msg); |
| 124 vfprintf(stderr, msg, args); |
| 125 va_end(args); |
| 126 } |
| 127 |
| 128 static Bool va_checkVtable(void *ptr, char *function) |
| 129 { |
| 130 if (!ptr) { |
| 131 va_errorMessage("No valid vtable entry for va%s\n", function); |
| 132 return False; |
| 133 } |
| 134 return True; |
| 135 } |
| 136 |
| 137 static Bool va_checkMaximum(int value, char *variable) |
| 138 { |
| 139 if (!value) { |
| 140 va_errorMessage("Failed to define max_%s in init\n", variable); |
| 141 return False; |
| 142 } |
| 143 return True; |
| 144 } |
| 145 |
| 146 static Bool va_checkString(const char* value, char *variable) |
| 147 { |
| 148 if (!value) { |
| 149 va_errorMessage("Failed to define str_%s in init\n", variable); |
| 150 return False; |
| 151 } |
| 152 return True; |
| 153 } |
| 154 |
| 155 static inline int |
| 156 va_getDriverInitName(char *name, int namelen, int major, int minor) |
| 157 { |
| 158 int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor); |
| 159 return ret > 0 && ret < namelen; |
| 160 } |
| 161 |
| 162 static VAStatus va_getDriverName(VADisplay dpy, char **driver_name) |
| 163 { |
| 164 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; |
| 165 |
| 166 return pDisplayContext->vaGetDriverName(pDisplayContext, driver_name); |
| 167 } |
| 168 |
| 169 static VAStatus va_openDriver(VADisplay dpy, char *driver_name) |
| 170 { |
| 171 VADriverContextP ctx = CTX(dpy); |
| 172 VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; |
| 173 char *search_path = NULL; |
| 174 char *saveptr; |
| 175 char *driver_dir; |
| 176 |
| 177 if (geteuid() == getuid()) |
| 178 /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */ |
| 179 search_path = getenv("LIBVA_DRIVERS_PATH"); |
| 180 if (!search_path) |
| 181 search_path = VA_DRIVERS_PATH; |
| 182 |
| 183 search_path = strdup((const char *)search_path); |
| 184 driver_dir = strtok_r(search_path, ":", &saveptr); |
| 185 while (driver_dir) { |
| 186 void *handle = NULL; |
| 187 char *driver_path = (char *) malloc( strlen(driver_dir) + |
| 188 strlen(driver_name) + |
| 189 strlen(DRIVER_EXTENSION) + 2 ); |
| 190 strncpy( driver_path, driver_dir, strlen(driver_dir) + 1); |
| 191 strncat( driver_path, "/", strlen("/") ); |
| 192 strncat( driver_path, driver_name, strlen(driver_name) ); |
| 193 strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) ); |
| 194 |
| 195 va_infoMessage("Trying to open %s\n", driver_path); |
| 196 #ifndef ANDROID |
| 197 handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE ); |
| 198 #else |
| 199 handle = dlopen( driver_path, RTLD_NOW| RTLD_GLOBAL); |
| 200 #endif |
| 201 if (!handle) { |
| 202 /* Don't give errors for non-existing files */ |
| 203 if (0 == access( driver_path, F_OK)) |
| 204 va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerro
r()); |
| 205 } else { |
| 206 VADriverInit init_func = NULL; |
| 207 char init_func_s[256]; |
| 208 int i; |
| 209 |
| 210 static const struct { |
| 211 int major; |
| 212 int minor; |
| 213 } compatible_versions[] = { |
| 214 { VA_MAJOR_VERSION, VA_MINOR_VERSION }, |
| 215 { 0, 32 }, |
| 216 { -1, } |
| 217 }; |
| 218 |
| 219 for (i = 0; compatible_versions[i].major >= 0; i++) { |
| 220 if (va_getDriverInitName(init_func_s, sizeof(init_func_s), |
| 221 compatible_versions[i].major, |
| 222 compatible_versions[i].minor)) { |
| 223 init_func = (VADriverInit)dlsym(handle, init_func_s); |
| 224 if (init_func) { |
| 225 va_infoMessage("Found init function %s\n", init_func_s); |
| 226 break; |
| 227 } |
| 228 } |
| 229 } |
| 230 |
| 231 if (compatible_versions[i].major < 0) { |
| 232 va_errorMessage("%s has no function %s\n", |
| 233 driver_path, init_func_s); |
| 234 dlclose(handle); |
| 235 } else { |
| 236 struct VADriverVTable *vtable = ctx->vtable; |
| 237 |
| 238 vaStatus = VA_STATUS_SUCCESS; |
| 239 if (!vtable) { |
| 240 vtable = calloc(1, sizeof(*vtable)); |
| 241 if (!vtable) |
| 242 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 243 } |
| 244 ctx->vtable = vtable; |
| 245 |
| 246 if (VA_STATUS_SUCCESS == vaStatus) |
| 247 vaStatus = (*init_func)(ctx); |
| 248 |
| 249 if (VA_STATUS_SUCCESS == vaStatus) { |
| 250 CHECK_MAXIMUM(vaStatus, ctx, profiles); |
| 251 CHECK_MAXIMUM(vaStatus, ctx, entrypoints); |
| 252 CHECK_MAXIMUM(vaStatus, ctx, attributes); |
| 253 CHECK_MAXIMUM(vaStatus, ctx, image_formats); |
| 254 CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); |
| 255 CHECK_MAXIMUM(vaStatus, ctx, display_attributes); |
| 256 CHECK_STRING(vaStatus, ctx, vendor); |
| 257 CHECK_VTABLE(vaStatus, ctx, Terminate); |
| 258 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); |
| 259 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); |
| 260 CHECK_VTABLE(vaStatus, ctx, QueryConfigAttributes); |
| 261 CHECK_VTABLE(vaStatus, ctx, CreateConfig); |
| 262 CHECK_VTABLE(vaStatus, ctx, DestroyConfig); |
| 263 CHECK_VTABLE(vaStatus, ctx, GetConfigAttributes); |
| 264 CHECK_VTABLE(vaStatus, ctx, CreateSurfaces); |
| 265 CHECK_VTABLE(vaStatus, ctx, DestroySurfaces); |
| 266 CHECK_VTABLE(vaStatus, ctx, CreateContext); |
| 267 CHECK_VTABLE(vaStatus, ctx, DestroyContext); |
| 268 CHECK_VTABLE(vaStatus, ctx, CreateBuffer); |
| 269 CHECK_VTABLE(vaStatus, ctx, BufferSetNumElements); |
| 270 CHECK_VTABLE(vaStatus, ctx, MapBuffer); |
| 271 CHECK_VTABLE(vaStatus, ctx, UnmapBuffer); |
| 272 CHECK_VTABLE(vaStatus, ctx, DestroyBuffer); |
| 273 CHECK_VTABLE(vaStatus, ctx, BeginPicture); |
| 274 CHECK_VTABLE(vaStatus, ctx, RenderPicture); |
| 275 CHECK_VTABLE(vaStatus, ctx, EndPicture); |
| 276 CHECK_VTABLE(vaStatus, ctx, SyncSurface); |
| 277 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus); |
| 278 CHECK_VTABLE(vaStatus, ctx, PutSurface); |
| 279 CHECK_VTABLE(vaStatus, ctx, QueryImageFormats); |
| 280 CHECK_VTABLE(vaStatus, ctx, CreateImage); |
| 281 CHECK_VTABLE(vaStatus, ctx, DeriveImage); |
| 282 CHECK_VTABLE(vaStatus, ctx, DestroyImage); |
| 283 CHECK_VTABLE(vaStatus, ctx, SetImagePalette); |
| 284 CHECK_VTABLE(vaStatus, ctx, GetImage); |
| 285 CHECK_VTABLE(vaStatus, ctx, PutImage); |
| 286 CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats); |
| 287 CHECK_VTABLE(vaStatus, ctx, CreateSubpicture); |
| 288 CHECK_VTABLE(vaStatus, ctx, DestroySubpicture); |
| 289 CHECK_VTABLE(vaStatus, ctx, SetSubpictureImage); |
| 290 CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey); |
| 291 CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha); |
| 292 CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture); |
| 293 CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture); |
| 294 CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes); |
| 295 CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes); |
| 296 CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); |
| 297 } |
| 298 if (VA_STATUS_SUCCESS != vaStatus) { |
| 299 va_errorMessage("%s init failed\n", driver_path); |
| 300 dlclose(handle); |
| 301 } |
| 302 if (VA_STATUS_SUCCESS == vaStatus) |
| 303 ctx->handle = handle; |
| 304 free(driver_path); |
| 305 break; |
| 306 } |
| 307 } |
| 308 free(driver_path); |
| 309 |
| 310 driver_dir = strtok_r(NULL, ":", &saveptr); |
| 311 } |
| 312 |
| 313 free(search_path); |
| 314 |
| 315 return vaStatus; |
| 316 } |
| 317 |
| 318 VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func) |
| 319 { |
| 320 VADriverContextP ctx; |
| 321 if (!vaDisplayIsValid(dpy)) |
| 322 return NULL; |
| 323 ctx = CTX(dpy); |
| 324 |
| 325 if (NULL == ctx->handle) |
| 326 return NULL; |
| 327 |
| 328 return (VAPrivFunc) dlsym(ctx->handle, func); |
| 329 } |
| 330 |
| 331 |
| 332 /* |
| 333 * Returns a short english description of error_status |
| 334 */ |
| 335 const char *vaErrorStr(VAStatus error_status) |
| 336 { |
| 337 switch(error_status) { |
| 338 case VA_STATUS_SUCCESS: |
| 339 return "success (no error)"; |
| 340 case VA_STATUS_ERROR_OPERATION_FAILED: |
| 341 return "operation failed"; |
| 342 case VA_STATUS_ERROR_ALLOCATION_FAILED: |
| 343 return "resource allocation failed"; |
| 344 case VA_STATUS_ERROR_INVALID_DISPLAY: |
| 345 return "invalid VADisplay"; |
| 346 case VA_STATUS_ERROR_INVALID_CONFIG: |
| 347 return "invalid VAConfigID"; |
| 348 case VA_STATUS_ERROR_INVALID_CONTEXT: |
| 349 return "invalid VAContextID"; |
| 350 case VA_STATUS_ERROR_INVALID_SURFACE: |
| 351 return "invalid VASurfaceID"; |
| 352 case VA_STATUS_ERROR_INVALID_BUFFER: |
| 353 return "invalid VABufferID"; |
| 354 case VA_STATUS_ERROR_INVALID_IMAGE: |
| 355 return "invalid VAImageID"; |
| 356 case VA_STATUS_ERROR_INVALID_SUBPICTURE: |
| 357 return "invalid VASubpictureID"; |
| 358 case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED: |
| 359 return "attribute not supported"; |
| 360 case VA_STATUS_ERROR_MAX_NUM_EXCEEDED: |
| 361 return "list argument exceeds maximum number"; |
| 362 case VA_STATUS_ERROR_UNSUPPORTED_PROFILE: |
| 363 return "the requested VAProfile is not supported"; |
| 364 case VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT: |
| 365 return "the requested VAEntryPoint is not supported"; |
| 366 case VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT: |
| 367 return "the requested RT Format is not supported"; |
| 368 case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE: |
| 369 return "the requested VABufferType is not supported"; |
| 370 case VA_STATUS_ERROR_SURFACE_BUSY: |
| 371 return "surface is in use"; |
| 372 case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED: |
| 373 return "flag not supported"; |
| 374 case VA_STATUS_ERROR_INVALID_PARAMETER: |
| 375 return "invalid parameter"; |
| 376 case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED: |
| 377 return "resolution not supported"; |
| 378 case VA_STATUS_ERROR_UNIMPLEMENTED: |
| 379 return "the requested function is not implemented"; |
| 380 case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING: |
| 381 return "surface is in displaying (may by overlay)" ; |
| 382 case VA_STATUS_ERROR_INVALID_IMAGE_FORMAT: |
| 383 return "invalid VAImageFormat"; |
| 384 case VA_STATUS_ERROR_UNKNOWN: |
| 385 return "unknown libva error"; |
| 386 } |
| 387 return "unknown libva error / description missing"; |
| 388 } |
| 389 |
| 390 VAStatus vaInitialize ( |
| 391 VADisplay dpy, |
| 392 int *major_version, /* out */ |
| 393 int *minor_version /* out */ |
| 394 ) |
| 395 { |
| 396 const char *driver_name_env = NULL; |
| 397 char *driver_name = NULL; |
| 398 VAStatus vaStatus; |
| 399 |
| 400 CHECK_DISPLAY(dpy); |
| 401 |
| 402 va_TraceInit(dpy); |
| 403 |
| 404 va_FoolInit(dpy); |
| 405 |
| 406 va_infoMessage("VA-API version %s\n", VA_VERSION_S); |
| 407 |
| 408 driver_name_env = getenv("LIBVA_DRIVER_NAME"); |
| 409 if (driver_name_env && geteuid() == getuid()) { |
| 410 /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ |
| 411 driver_name = strdup(driver_name_env); |
| 412 vaStatus = VA_STATUS_SUCCESS; |
| 413 va_infoMessage("User requested driver '%s'\n", driver_name); |
| 414 } else { |
| 415 vaStatus = va_getDriverName(dpy, &driver_name); |
| 416 va_infoMessage("va_getDriverName() returns %d\n", vaStatus); |
| 417 } |
| 418 |
| 419 if (VA_STATUS_SUCCESS == vaStatus) { |
| 420 vaStatus = va_openDriver(dpy, driver_name); |
| 421 va_infoMessage("va_openDriver() returns %d\n", vaStatus); |
| 422 |
| 423 *major_version = VA_MAJOR_VERSION; |
| 424 *minor_version = VA_MINOR_VERSION; |
| 425 } |
| 426 |
| 427 if (driver_name) |
| 428 free(driver_name); |
| 429 |
| 430 VA_TRACE_LOG(va_TraceInitialize, dpy, major_version, minor_version); |
| 431 |
| 432 return vaStatus; |
| 433 } |
| 434 |
| 435 |
| 436 /* |
| 437 * After this call, all library internal resources will be cleaned up |
| 438 */ |
| 439 VAStatus vaTerminate ( |
| 440 VADisplay dpy |
| 441 ) |
| 442 { |
| 443 VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 444 VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; |
| 445 VADriverContextP old_ctx; |
| 446 |
| 447 CHECK_DISPLAY(dpy); |
| 448 old_ctx = CTX(dpy); |
| 449 |
| 450 if (old_ctx->handle) { |
| 451 vaStatus = old_ctx->vtable->vaTerminate(old_ctx); |
| 452 dlclose(old_ctx->handle); |
| 453 old_ctx->handle = NULL; |
| 454 } |
| 455 free(old_ctx->vtable); |
| 456 old_ctx->vtable = NULL; |
| 457 |
| 458 if (VA_STATUS_SUCCESS == vaStatus) |
| 459 pDisplayContext->vaDestroy(pDisplayContext); |
| 460 |
| 461 VA_TRACE_LOG(va_TraceTerminate, dpy); |
| 462 |
| 463 va_TraceEnd(dpy); |
| 464 |
| 465 va_FoolEnd(dpy); |
| 466 |
| 467 return vaStatus; |
| 468 } |
| 469 |
| 470 /* |
| 471 * vaQueryVendorString returns a pointer to a zero-terminated string |
| 472 * describing some aspects of the VA implemenation on a specific |
| 473 * hardware accelerator. The format of the returned string is: |
| 474 * <vendorname>-<major_version>-<minor_version>-<addtional_info> |
| 475 * e.g. for the Intel GMA500 implementation, an example would be: |
| 476 * "IntelGMA500-1.0-0.2-patch3 |
| 477 */ |
| 478 const char *vaQueryVendorString ( |
| 479 VADisplay dpy |
| 480 ) |
| 481 { |
| 482 if (!vaDisplayIsValid(dpy)) |
| 483 return NULL; |
| 484 |
| 485 return CTX(dpy)->str_vendor; |
| 486 } |
| 487 |
| 488 |
| 489 /* Get maximum number of profiles supported by the implementation */ |
| 490 int vaMaxNumProfiles ( |
| 491 VADisplay dpy |
| 492 ) |
| 493 { |
| 494 if (!vaDisplayIsValid(dpy)) |
| 495 return 0; |
| 496 |
| 497 return CTX(dpy)->max_profiles; |
| 498 } |
| 499 |
| 500 /* Get maximum number of entrypoints supported by the implementation */ |
| 501 int vaMaxNumEntrypoints ( |
| 502 VADisplay dpy |
| 503 ) |
| 504 { |
| 505 if (!vaDisplayIsValid(dpy)) |
| 506 return 0; |
| 507 |
| 508 return CTX(dpy)->max_entrypoints; |
| 509 } |
| 510 |
| 511 |
| 512 /* Get maximum number of attributs supported by the implementation */ |
| 513 int vaMaxNumConfigAttributes ( |
| 514 VADisplay dpy |
| 515 ) |
| 516 { |
| 517 if (!vaDisplayIsValid(dpy)) |
| 518 return 0; |
| 519 |
| 520 return CTX(dpy)->max_attributes; |
| 521 } |
| 522 |
| 523 VAStatus vaQueryConfigEntrypoints ( |
| 524 VADisplay dpy, |
| 525 VAProfile profile, |
| 526 VAEntrypoint *entrypoints, /* out */ |
| 527 int *num_entrypoints /* out */ |
| 528 ) |
| 529 { |
| 530 VADriverContextP ctx; |
| 531 CHECK_DISPLAY(dpy); |
| 532 ctx = CTX(dpy); |
| 533 |
| 534 return ctx->vtable->vaQueryConfigEntrypoints ( ctx, profile, entrypoints, num_
entrypoints); |
| 535 } |
| 536 |
| 537 VAStatus vaGetConfigAttributes ( |
| 538 VADisplay dpy, |
| 539 VAProfile profile, |
| 540 VAEntrypoint entrypoint, |
| 541 VAConfigAttrib *attrib_list, /* in/out */ |
| 542 int num_attribs |
| 543 ) |
| 544 { |
| 545 VADriverContextP ctx; |
| 546 CHECK_DISPLAY(dpy); |
| 547 ctx = CTX(dpy); |
| 548 |
| 549 return ctx->vtable->vaGetConfigAttributes ( ctx, profile, entrypoint, attrib_l
ist, num_attribs ); |
| 550 } |
| 551 |
| 552 VAStatus vaQueryConfigProfiles ( |
| 553 VADisplay dpy, |
| 554 VAProfile *profile_list, /* out */ |
| 555 int *num_profiles /* out */ |
| 556 ) |
| 557 { |
| 558 VADriverContextP ctx; |
| 559 CHECK_DISPLAY(dpy); |
| 560 ctx = CTX(dpy); |
| 561 |
| 562 return ctx->vtable->vaQueryConfigProfiles ( ctx, profile_list, num_profiles ); |
| 563 } |
| 564 |
| 565 VAStatus vaCreateConfig ( |
| 566 VADisplay dpy, |
| 567 VAProfile profile, |
| 568 VAEntrypoint entrypoint, |
| 569 VAConfigAttrib *attrib_list, |
| 570 int num_attribs, |
| 571 VAConfigID *config_id /* out */ |
| 572 ) |
| 573 { |
| 574 VADriverContextP ctx; |
| 575 VAStatus vaStatus = VA_STATUS_SUCCESS; |
| 576 int ret = 0; |
| 577 |
| 578 CHECK_DISPLAY(dpy); |
| 579 ctx = CTX(dpy); |
| 580 |
| 581 vaStatus = ctx->vtable->vaCreateConfig ( ctx, profile, entrypoint, attrib_list
, num_attribs, config_id ); |
| 582 |
| 583 /* record the current entrypoint for further trace/fool determination */ |
| 584 VA_TRACE_FUNC(va_TraceCreateConfig, dpy, profile, entrypoint, attrib_list, num
_attribs, config_id); |
| 585 VA_FOOL_FUNC(va_FoolCreateConfig, dpy, profile, entrypoint, attrib_list, num_a
ttribs, config_id); |
| 586 |
| 587 return vaStatus; |
| 588 } |
| 589 |
| 590 VAStatus vaDestroyConfig ( |
| 591 VADisplay dpy, |
| 592 VAConfigID config_id |
| 593 ) |
| 594 { |
| 595 VADriverContextP ctx; |
| 596 CHECK_DISPLAY(dpy); |
| 597 ctx = CTX(dpy); |
| 598 |
| 599 return ctx->vtable->vaDestroyConfig ( ctx, config_id ); |
| 600 } |
| 601 |
| 602 VAStatus vaQueryConfigAttributes ( |
| 603 VADisplay dpy, |
| 604 VAConfigID config_id, |
| 605 VAProfile *profile, /* out */ |
| 606 VAEntrypoint *entrypoint, /* out */ |
| 607 VAConfigAttrib *attrib_list,/* out */ |
| 608 int *num_attribs /* out */ |
| 609 ) |
| 610 { |
| 611 VADriverContextP ctx; |
| 612 CHECK_DISPLAY(dpy); |
| 613 ctx = CTX(dpy); |
| 614 |
| 615 return ctx->vtable->vaQueryConfigAttributes( ctx, config_id, profile, entrypoi
nt, attrib_list, num_attribs); |
| 616 } |
| 617 |
| 618 VAStatus vaCreateSurfaces ( |
| 619 VADisplay dpy, |
| 620 int width, |
| 621 int height, |
| 622 int format, |
| 623 int num_surfaces, |
| 624 VASurfaceID *surfaces /* out */ |
| 625 ) |
| 626 { |
| 627 VADriverContextP ctx; |
| 628 VAStatus vaStatus; |
| 629 |
| 630 CHECK_DISPLAY(dpy); |
| 631 ctx = CTX(dpy); |
| 632 |
| 633 vaStatus = ctx->vtable->vaCreateSurfaces( ctx, width, height, format, num_surf
aces, surfaces ); |
| 634 |
| 635 VA_TRACE_LOG(va_TraceCreateSurface, dpy, width, height, format, num_surfaces,
surfaces); |
| 636 |
| 637 return vaStatus; |
| 638 } |
| 639 |
| 640 |
| 641 VAStatus vaDestroySurfaces ( |
| 642 VADisplay dpy, |
| 643 VASurfaceID *surface_list, |
| 644 int num_surfaces |
| 645 ) |
| 646 { |
| 647 VADriverContextP ctx; |
| 648 CHECK_DISPLAY(dpy); |
| 649 ctx = CTX(dpy); |
| 650 |
| 651 return ctx->vtable->vaDestroySurfaces( ctx, surface_list, num_surfaces ); |
| 652 } |
| 653 |
| 654 VAStatus vaCreateContext ( |
| 655 VADisplay dpy, |
| 656 VAConfigID config_id, |
| 657 int picture_width, |
| 658 int picture_height, |
| 659 int flag, |
| 660 VASurfaceID *render_targets, |
| 661 int num_render_targets, |
| 662 VAContextID *context /* out */ |
| 663 ) |
| 664 { |
| 665 VADriverContextP ctx; |
| 666 VAStatus vaStatus; |
| 667 |
| 668 CHECK_DISPLAY(dpy); |
| 669 ctx = CTX(dpy); |
| 670 |
| 671 vaStatus = ctx->vtable->vaCreateContext( ctx, config_id, picture_width, pictur
e_height, |
| 672 flag, render_targets, num_render_targets,
context ); |
| 673 |
| 674 /* keep current encode/decode resoluton */ |
| 675 VA_TRACE_FUNC(va_TraceCreateContext, dpy, config_id, picture_width, picture_he
ight, flag, render_targets, num_render_targets, context); |
| 676 |
| 677 return vaStatus; |
| 678 } |
| 679 |
| 680 VAStatus vaDestroyContext ( |
| 681 VADisplay dpy, |
| 682 VAContextID context |
| 683 ) |
| 684 { |
| 685 VADriverContextP ctx; |
| 686 CHECK_DISPLAY(dpy); |
| 687 ctx = CTX(dpy); |
| 688 |
| 689 return ctx->vtable->vaDestroyContext( ctx, context ); |
| 690 } |
| 691 |
| 692 VAStatus vaCreateBuffer ( |
| 693 VADisplay dpy, |
| 694 VAContextID context, /* in */ |
| 695 VABufferType type, /* in */ |
| 696 unsigned int size, /* in */ |
| 697 unsigned int num_elements, /* in */ |
| 698 void *data, /* in */ |
| 699 VABufferID *buf_id /* out */ |
| 700 ) |
| 701 { |
| 702 VADriverContextP ctx; |
| 703 CHECK_DISPLAY(dpy); |
| 704 ctx = CTX(dpy); |
| 705 int ret = 0; |
| 706 |
| 707 VA_FOOL_FUNC(va_FoolCreateBuffer, dpy, context, type, size, num_elements, data
, buf_id); |
| 708 if (ret) |
| 709 return VA_STATUS_SUCCESS; |
| 710 |
| 711 return ctx->vtable->vaCreateBuffer( ctx, context, type, size, num_elements, da
ta, buf_id); |
| 712 } |
| 713 |
| 714 VAStatus vaBufferSetNumElements ( |
| 715 VADisplay dpy, |
| 716 VABufferID buf_id, /* in */ |
| 717 unsigned int num_elements /* in */ |
| 718 ) |
| 719 { |
| 720 VADriverContextP ctx; |
| 721 CHECK_DISPLAY(dpy); |
| 722 ctx = CTX(dpy); |
| 723 |
| 724 VA_FOOL_RETURN(); |
| 725 |
| 726 return ctx->vtable->vaBufferSetNumElements( ctx, buf_id, num_elements ); |
| 727 } |
| 728 |
| 729 |
| 730 VAStatus vaMapBuffer ( |
| 731 VADisplay dpy, |
| 732 VABufferID buf_id, /* in */ |
| 733 void **pbuf /* out */ |
| 734 ) |
| 735 { |
| 736 VADriverContextP ctx; |
| 737 VAStatus va_status; |
| 738 int ret = 0; |
| 739 |
| 740 CHECK_DISPLAY(dpy); |
| 741 ctx = CTX(dpy); |
| 742 |
| 743 VA_FOOL_FUNC(va_FoolMapBuffer, dpy, buf_id, pbuf); |
| 744 if (ret) |
| 745 return VA_STATUS_SUCCESS; |
| 746 |
| 747 va_status = ctx->vtable->vaMapBuffer( ctx, buf_id, pbuf ); |
| 748 |
| 749 VA_TRACE_LOG(va_TraceMapBuffer, dpy, buf_id, pbuf); |
| 750 |
| 751 return va_status; |
| 752 } |
| 753 |
| 754 VAStatus vaUnmapBuffer ( |
| 755 VADisplay dpy, |
| 756 VABufferID buf_id /* in */ |
| 757 ) |
| 758 { |
| 759 VADriverContextP ctx; |
| 760 CHECK_DISPLAY(dpy); |
| 761 ctx = CTX(dpy); |
| 762 int ret = 0; |
| 763 |
| 764 VA_FOOL_FUNC(va_FoolUnmapBuffer, dpy, buf_id); |
| 765 if (ret) |
| 766 return VA_STATUS_SUCCESS; |
| 767 |
| 768 return ctx->vtable->vaUnmapBuffer( ctx, buf_id ); |
| 769 } |
| 770 |
| 771 VAStatus vaDestroyBuffer ( |
| 772 VADisplay dpy, |
| 773 VABufferID buffer_id |
| 774 ) |
| 775 { |
| 776 VADriverContextP ctx; |
| 777 CHECK_DISPLAY(dpy); |
| 778 ctx = CTX(dpy); |
| 779 |
| 780 VA_FOOL_RETURN(); |
| 781 |
| 782 return ctx->vtable->vaDestroyBuffer( ctx, buffer_id ); |
| 783 } |
| 784 |
| 785 VAStatus vaBufferInfo ( |
| 786 VADisplay dpy, |
| 787 VAContextID context, /* in */ |
| 788 VABufferID buf_id, /* in */ |
| 789 VABufferType *type, /* out */ |
| 790 unsigned int *size, /* out */ |
| 791 unsigned int *num_elements /* out */ |
| 792 ) |
| 793 { |
| 794 VADriverContextP ctx; |
| 795 int ret = 0; |
| 796 |
| 797 CHECK_DISPLAY(dpy); |
| 798 ctx = CTX(dpy); |
| 799 |
| 800 VA_FOOL_FUNC(va_FoolBufferInfo, dpy, buf_id, type, size, num_elements); |
| 801 if (ret) |
| 802 return VA_STATUS_SUCCESS; |
| 803 |
| 804 return ctx->vtable->vaBufferInfo( ctx, buf_id, type, size, num_elements ); |
| 805 } |
| 806 |
| 807 VAStatus vaBeginPicture ( |
| 808 VADisplay dpy, |
| 809 VAContextID context, |
| 810 VASurfaceID render_target |
| 811 ) |
| 812 { |
| 813 VADriverContextP ctx; |
| 814 VAStatus va_status; |
| 815 |
| 816 CHECK_DISPLAY(dpy); |
| 817 ctx = CTX(dpy); |
| 818 |
| 819 VA_TRACE_FUNC(va_TraceBeginPicture, dpy, context, render_target); |
| 820 VA_FOOL_RETURN(); |
| 821 |
| 822 va_status = ctx->vtable->vaBeginPicture( ctx, context, render_target ); |
| 823 |
| 824 return va_status; |
| 825 } |
| 826 |
| 827 VAStatus vaRenderPicture ( |
| 828 VADisplay dpy, |
| 829 VAContextID context, |
| 830 VABufferID *buffers, |
| 831 int num_buffers |
| 832 ) |
| 833 { |
| 834 VADriverContextP ctx; |
| 835 |
| 836 CHECK_DISPLAY(dpy); |
| 837 ctx = CTX(dpy); |
| 838 |
| 839 VA_TRACE_LOG(va_TraceRenderPicture, dpy, context, buffers, num_buffers); |
| 840 VA_FOOL_RETURN(); |
| 841 |
| 842 return ctx->vtable->vaRenderPicture( ctx, context, buffers, num_buffers ); |
| 843 } |
| 844 |
| 845 VAStatus vaEndPicture ( |
| 846 VADisplay dpy, |
| 847 VAContextID context |
| 848 ) |
| 849 { |
| 850 VAStatus va_status; |
| 851 VADriverContextP ctx; |
| 852 |
| 853 CHECK_DISPLAY(dpy); |
| 854 ctx = CTX(dpy); |
| 855 |
| 856 /* dump encode source surface */ |
| 857 VA_TRACE_SURFACE(va_TraceEndPicture, dpy, context, 0); |
| 858 /* return directly if do dummy operation */ |
| 859 VA_FOOL_RETURN(); |
| 860 |
| 861 va_status = ctx->vtable->vaEndPicture( ctx, context ); |
| 862 /* dump decode dest surface */ |
| 863 VA_TRACE_SURFACE(va_TraceEndPicture, dpy, context, 1); |
| 864 |
| 865 return va_status; |
| 866 } |
| 867 |
| 868 VAStatus vaSyncSurface ( |
| 869 VADisplay dpy, |
| 870 VASurfaceID render_target |
| 871 ) |
| 872 { |
| 873 VAStatus va_status; |
| 874 VADriverContextP ctx; |
| 875 |
| 876 CHECK_DISPLAY(dpy); |
| 877 ctx = CTX(dpy); |
| 878 |
| 879 va_status = ctx->vtable->vaSyncSurface( ctx, render_target ); |
| 880 VA_TRACE_LOG(va_TraceSyncSurface, dpy, render_target); |
| 881 |
| 882 return va_status; |
| 883 } |
| 884 |
| 885 VAStatus vaQuerySurfaceStatus ( |
| 886 VADisplay dpy, |
| 887 VASurfaceID render_target, |
| 888 VASurfaceStatus *status /* out */ |
| 889 ) |
| 890 { |
| 891 VAStatus va_status; |
| 892 VADriverContextP ctx; |
| 893 CHECK_DISPLAY(dpy); |
| 894 ctx = CTX(dpy); |
| 895 |
| 896 va_status = ctx->vtable->vaQuerySurfaceStatus( ctx, render_target, status ); |
| 897 |
| 898 VA_TRACE_LOG(va_TraceQuerySurfaceStatus, dpy, render_target, status); |
| 899 |
| 900 return va_status; |
| 901 } |
| 902 |
| 903 VAStatus vaQuerySurfaceError ( |
| 904 VADisplay dpy, |
| 905 VASurfaceID surface, |
| 906 VAStatus error_status, |
| 907 void **error_info /*out*/ |
| 908 ) |
| 909 { |
| 910 VAStatus va_status; |
| 911 VADriverContextP ctx; |
| 912 CHECK_DISPLAY(dpy); |
| 913 ctx = CTX(dpy); |
| 914 |
| 915 va_status = ctx->vtable->vaQuerySurfaceError( ctx, surface, error_status, erro
r_info ); |
| 916 |
| 917 VA_TRACE_LOG(va_TraceQuerySurfaceError, dpy, surface, error_status, error_info
); |
| 918 |
| 919 return va_status; |
| 920 } |
| 921 |
| 922 /* Get maximum number of image formats supported by the implementation */ |
| 923 int vaMaxNumImageFormats ( |
| 924 VADisplay dpy |
| 925 ) |
| 926 { |
| 927 if (!vaDisplayIsValid(dpy)) |
| 928 return 0; |
| 929 |
| 930 return CTX(dpy)->max_image_formats; |
| 931 } |
| 932 |
| 933 VAStatus vaQueryImageFormats ( |
| 934 VADisplay dpy, |
| 935 VAImageFormat *format_list, /* out */ |
| 936 int *num_formats /* out */ |
| 937 ) |
| 938 { |
| 939 VADriverContextP ctx; |
| 940 CHECK_DISPLAY(dpy); |
| 941 ctx = CTX(dpy); |
| 942 |
| 943 return ctx->vtable->vaQueryImageFormats ( ctx, format_list, num_formats); |
| 944 } |
| 945 |
| 946 /* |
| 947 * The width and height fields returned in the VAImage structure may get |
| 948 * enlarged for some YUV formats. The size of the data buffer that needs |
| 949 * to be allocated will be given in the "data_size" field in VAImage. |
| 950 * Image data is not allocated by this function. The client should |
| 951 * allocate the memory and fill in the VAImage structure's data field |
| 952 * after looking at "data_size" returned from the library. |
| 953 */ |
| 954 VAStatus vaCreateImage ( |
| 955 VADisplay dpy, |
| 956 VAImageFormat *format, |
| 957 int width, |
| 958 int height, |
| 959 VAImage *image /* out */ |
| 960 ) |
| 961 { |
| 962 VADriverContextP ctx; |
| 963 CHECK_DISPLAY(dpy); |
| 964 ctx = CTX(dpy); |
| 965 |
| 966 return ctx->vtable->vaCreateImage ( ctx, format, width, height, image); |
| 967 } |
| 968 |
| 969 /* |
| 970 * Should call DestroyImage before destroying the surface it is bound to |
| 971 */ |
| 972 VAStatus vaDestroyImage ( |
| 973 VADisplay dpy, |
| 974 VAImageID image |
| 975 ) |
| 976 { |
| 977 VADriverContextP ctx; |
| 978 CHECK_DISPLAY(dpy); |
| 979 ctx = CTX(dpy); |
| 980 |
| 981 return ctx->vtable->vaDestroyImage ( ctx, image); |
| 982 } |
| 983 |
| 984 VAStatus vaSetImagePalette ( |
| 985 VADisplay dpy, |
| 986 VAImageID image, |
| 987 unsigned char *palette |
| 988 ) |
| 989 { |
| 990 VADriverContextP ctx; |
| 991 CHECK_DISPLAY(dpy); |
| 992 ctx = CTX(dpy); |
| 993 |
| 994 return ctx->vtable->vaSetImagePalette ( ctx, image, palette); |
| 995 } |
| 996 |
| 997 /* |
| 998 * Retrieve surface data into a VAImage |
| 999 * Image must be in a format supported by the implementation |
| 1000 */ |
| 1001 VAStatus vaGetImage ( |
| 1002 VADisplay dpy, |
| 1003 VASurfaceID surface, |
| 1004 int x, /* coordinates of the upper left source pixel */ |
| 1005 int y, |
| 1006 unsigned int width, /* width and height of the region */ |
| 1007 unsigned int height, |
| 1008 VAImageID image |
| 1009 ) |
| 1010 { |
| 1011 VADriverContextP ctx; |
| 1012 CHECK_DISPLAY(dpy); |
| 1013 ctx = CTX(dpy); |
| 1014 |
| 1015 return ctx->vtable->vaGetImage ( ctx, surface, x, y, width, height, image); |
| 1016 } |
| 1017 |
| 1018 /* |
| 1019 * Copy data from a VAImage to a surface |
| 1020 * Image must be in a format supported by the implementation |
| 1021 */ |
| 1022 VAStatus vaPutImage ( |
| 1023 VADisplay dpy, |
| 1024 VASurfaceID surface, |
| 1025 VAImageID image, |
| 1026 int src_x, |
| 1027 int src_y, |
| 1028 unsigned int src_width, |
| 1029 unsigned int src_height, |
| 1030 int dest_x, |
| 1031 int dest_y, |
| 1032 unsigned int dest_width, |
| 1033 unsigned int dest_height |
| 1034 ) |
| 1035 { |
| 1036 VADriverContextP ctx; |
| 1037 CHECK_DISPLAY(dpy); |
| 1038 ctx = CTX(dpy); |
| 1039 |
| 1040 return ctx->vtable->vaPutImage ( ctx, surface, image, src_x, src_y, src_width,
src_height, dest_x, dest_y, dest_width, dest_height ); |
| 1041 } |
| 1042 |
| 1043 /* |
| 1044 * Derive an VAImage from an existing surface. |
| 1045 * This interface will derive a VAImage and corresponding image buffer from |
| 1046 * an existing VA Surface. The image buffer can then be mapped/unmapped for |
| 1047 * direct CPU access. This operation is only possible on implementations with |
| 1048 * direct rendering capabilities and internal surface formats that can be |
| 1049 * represented with a VAImage. When the operation is not possible this interface |
| 1050 * will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back |
| 1051 * to using vaCreateImage + vaPutImage to accomplish the same task in an |
| 1052 * indirect manner. |
| 1053 * |
| 1054 * Implementations should only return success when the resulting image buffer |
| 1055 * would be useable with vaMap/Unmap. |
| 1056 * |
| 1057 * When directly accessing a surface special care must be taken to insure |
| 1058 * proper synchronization with the graphics hardware. Clients should call |
| 1059 * vaQuerySurfaceStatus to insure that a surface is not the target of concurrent |
| 1060 * rendering or currently being displayed by an overlay. |
| 1061 * |
| 1062 * Additionally nothing about the contents of a surface should be assumed |
| 1063 * following a vaPutSurface. Implementations are free to modify the surface for |
| 1064 * scaling or subpicture blending within a call to vaPutImage. |
| 1065 * |
| 1066 * Calls to vaPutImage or vaGetImage using the same surface from which the image |
| 1067 * has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or |
| 1068 * vaGetImage with other surfaces is supported. |
| 1069 * |
| 1070 * An image created with vaDeriveImage should be freed with vaDestroyImage. The |
| 1071 * image and image buffer structures will be destroyed; however, the underlying |
| 1072 * surface will remain unchanged until freed with vaDestroySurfaces. |
| 1073 */ |
| 1074 VAStatus vaDeriveImage ( |
| 1075 VADisplay dpy, |
| 1076 VASurfaceID surface, |
| 1077 VAImage *image /* out */ |
| 1078 ) |
| 1079 { |
| 1080 VADriverContextP ctx; |
| 1081 CHECK_DISPLAY(dpy); |
| 1082 ctx = CTX(dpy); |
| 1083 |
| 1084 return ctx->vtable->vaDeriveImage ( ctx, surface, image ); |
| 1085 } |
| 1086 |
| 1087 |
| 1088 /* Get maximum number of subpicture formats supported by the implementation */ |
| 1089 int vaMaxNumSubpictureFormats ( |
| 1090 VADisplay dpy |
| 1091 ) |
| 1092 { |
| 1093 if (!vaDisplayIsValid(dpy)) |
| 1094 return 0; |
| 1095 |
| 1096 return CTX(dpy)->max_subpic_formats; |
| 1097 } |
| 1098 |
| 1099 /* |
| 1100 * Query supported subpicture formats |
| 1101 * The caller must provide a "format_list" array that can hold at |
| 1102 * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag |
| 1103 * for each format to indicate additional capabilities for that format. The actu
al |
| 1104 * number of formats returned in "format_list" is returned in "num_formats". |
| 1105 */ |
| 1106 VAStatus vaQuerySubpictureFormats ( |
| 1107 VADisplay dpy, |
| 1108 VAImageFormat *format_list, /* out */ |
| 1109 unsigned int *flags, /* out */ |
| 1110 unsigned int *num_formats /* out */ |
| 1111 ) |
| 1112 { |
| 1113 VADriverContextP ctx; |
| 1114 |
| 1115 CHECK_DISPLAY(dpy); |
| 1116 ctx = CTX(dpy); |
| 1117 |
| 1118 return ctx->vtable->vaQuerySubpictureFormats ( ctx, format_list, flags, num_fo
rmats); |
| 1119 } |
| 1120 |
| 1121 /* |
| 1122 * Subpictures are created with an image associated. |
| 1123 */ |
| 1124 VAStatus vaCreateSubpicture ( |
| 1125 VADisplay dpy, |
| 1126 VAImageID image, |
| 1127 VASubpictureID *subpicture /* out */ |
| 1128 ) |
| 1129 { |
| 1130 VADriverContextP ctx; |
| 1131 CHECK_DISPLAY(dpy); |
| 1132 ctx = CTX(dpy); |
| 1133 |
| 1134 return ctx->vtable->vaCreateSubpicture ( ctx, image, subpicture ); |
| 1135 } |
| 1136 |
| 1137 /* |
| 1138 * Destroy the subpicture before destroying the image it is assocated to |
| 1139 */ |
| 1140 VAStatus vaDestroySubpicture ( |
| 1141 VADisplay dpy, |
| 1142 VASubpictureID subpicture |
| 1143 ) |
| 1144 { |
| 1145 VADriverContextP ctx; |
| 1146 CHECK_DISPLAY(dpy); |
| 1147 ctx = CTX(dpy); |
| 1148 |
| 1149 return ctx->vtable->vaDestroySubpicture ( ctx, subpicture); |
| 1150 } |
| 1151 |
| 1152 VAStatus vaSetSubpictureImage ( |
| 1153 VADisplay dpy, |
| 1154 VASubpictureID subpicture, |
| 1155 VAImageID image |
| 1156 ) |
| 1157 { |
| 1158 VADriverContextP ctx; |
| 1159 CHECK_DISPLAY(dpy); |
| 1160 ctx = CTX(dpy); |
| 1161 |
| 1162 return ctx->vtable->vaSetSubpictureImage ( ctx, subpicture, image); |
| 1163 } |
| 1164 |
| 1165 |
| 1166 /* |
| 1167 * If chromakey is enabled, then the area where the source value falls within |
| 1168 * the chromakey [min, max] range is transparent |
| 1169 */ |
| 1170 VAStatus vaSetSubpictureChromakey ( |
| 1171 VADisplay dpy, |
| 1172 VASubpictureID subpicture, |
| 1173 unsigned int chromakey_min, |
| 1174 unsigned int chromakey_max, |
| 1175 unsigned int chromakey_mask |
| 1176 ) |
| 1177 { |
| 1178 VADriverContextP ctx; |
| 1179 CHECK_DISPLAY(dpy); |
| 1180 ctx = CTX(dpy); |
| 1181 |
| 1182 return ctx->vtable->vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min,
chromakey_max, chromakey_mask ); |
| 1183 } |
| 1184 |
| 1185 |
| 1186 /* |
| 1187 * Global alpha value is between 0 and 1. A value of 1 means fully opaque and |
| 1188 * a value of 0 means fully transparent. If per-pixel alpha is also specified th
en |
| 1189 * the overall alpha is per-pixel alpha multiplied by the global alpha |
| 1190 */ |
| 1191 VAStatus vaSetSubpictureGlobalAlpha ( |
| 1192 VADisplay dpy, |
| 1193 VASubpictureID subpicture, |
| 1194 float global_alpha |
| 1195 ) |
| 1196 { |
| 1197 VADriverContextP ctx; |
| 1198 CHECK_DISPLAY(dpy); |
| 1199 ctx = CTX(dpy); |
| 1200 |
| 1201 return ctx->vtable->vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha
); |
| 1202 } |
| 1203 |
| 1204 /* |
| 1205 vaAssociateSubpicture associates the subpicture with the target_surface. |
| 1206 It defines the region mapping between the subpicture and the target |
| 1207 surface through source and destination rectangles (with the same width and hei
ght). |
| 1208 Both will be displayed at the next call to vaPutSurface. Additional |
| 1209 associations before the call to vaPutSurface simply overrides the association. |
| 1210 */ |
| 1211 VAStatus vaAssociateSubpicture ( |
| 1212 VADisplay dpy, |
| 1213 VASubpictureID subpicture, |
| 1214 VASurfaceID *target_surfaces, |
| 1215 int num_surfaces, |
| 1216 short src_x, /* upper left offset in subpicture */ |
| 1217 short src_y, |
| 1218 unsigned short src_width, |
| 1219 unsigned short src_height, |
| 1220 short dest_x, /* upper left offset in surface */ |
| 1221 short dest_y, |
| 1222 unsigned short dest_width, |
| 1223 unsigned short dest_height, |
| 1224 /* |
| 1225 * whether to enable chroma-keying or global-alpha |
| 1226 * see VA_SUBPICTURE_XXX values |
| 1227 */ |
| 1228 unsigned int flags |
| 1229 ) |
| 1230 { |
| 1231 VADriverContextP ctx; |
| 1232 CHECK_DISPLAY(dpy); |
| 1233 ctx = CTX(dpy); |
| 1234 |
| 1235 return ctx->vtable->vaAssociateSubpicture ( ctx, subpicture, target_surfaces,
num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, d
est_height, flags ); |
| 1236 } |
| 1237 |
| 1238 /* |
| 1239 * vaDeassociateSubpicture removes the association of the subpicture with target
_surfaces. |
| 1240 */ |
| 1241 VAStatus vaDeassociateSubpicture ( |
| 1242 VADisplay dpy, |
| 1243 VASubpictureID subpicture, |
| 1244 VASurfaceID *target_surfaces, |
| 1245 int num_surfaces |
| 1246 ) |
| 1247 { |
| 1248 VADriverContextP ctx; |
| 1249 CHECK_DISPLAY(dpy); |
| 1250 ctx = CTX(dpy); |
| 1251 |
| 1252 return ctx->vtable->vaDeassociateSubpicture ( ctx, subpicture, target_surfaces
, num_surfaces ); |
| 1253 } |
| 1254 |
| 1255 |
| 1256 /* Get maximum number of display attributes supported by the implementation */ |
| 1257 int vaMaxNumDisplayAttributes ( |
| 1258 VADisplay dpy |
| 1259 ) |
| 1260 { |
| 1261 int tmp; |
| 1262 |
| 1263 if (!vaDisplayIsValid(dpy)) |
| 1264 return 0; |
| 1265 |
| 1266 tmp = CTX(dpy)->max_display_attributes; |
| 1267 |
| 1268 VA_TRACE_LOG(va_TraceMaxNumDisplayAttributes, dpy, tmp); |
| 1269 |
| 1270 return tmp; |
| 1271 } |
| 1272 |
| 1273 /* |
| 1274 * Query display attributes |
| 1275 * The caller must provide a "attr_list" array that can hold at |
| 1276 * least vaMaxNumDisplayAttributes() entries. The actual number of attributes |
| 1277 * returned in "attr_list" is returned in "num_attributes". |
| 1278 */ |
| 1279 VAStatus vaQueryDisplayAttributes ( |
| 1280 VADisplay dpy, |
| 1281 VADisplayAttribute *attr_list, /* out */ |
| 1282 int *num_attributes /* out */ |
| 1283 ) |
| 1284 { |
| 1285 VADriverContextP ctx; |
| 1286 VAStatus va_status; |
| 1287 |
| 1288 CHECK_DISPLAY(dpy); |
| 1289 ctx = CTX(dpy); |
| 1290 va_status = ctx->vtable->vaQueryDisplayAttributes ( ctx, attr_list, num_attrib
utes ); |
| 1291 |
| 1292 VA_TRACE_LOG(va_TraceQueryDisplayAttributes, dpy, attr_list, num_attributes); |
| 1293 |
| 1294 return va_status; |
| 1295 |
| 1296 } |
| 1297 |
| 1298 /* |
| 1299 * Get display attributes |
| 1300 * This function returns the current attribute values in "attr_list". |
| 1301 * Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" f
ield |
| 1302 * from vaQueryDisplayAttributes() can have their values retrieved. |
| 1303 */ |
| 1304 VAStatus vaGetDisplayAttributes ( |
| 1305 VADisplay dpy, |
| 1306 VADisplayAttribute *attr_list, /* in/out */ |
| 1307 int num_attributes |
| 1308 ) |
| 1309 { |
| 1310 VADriverContextP ctx; |
| 1311 VAStatus va_status; |
| 1312 |
| 1313 CHECK_DISPLAY(dpy); |
| 1314 ctx = CTX(dpy); |
| 1315 va_status = ctx->vtable->vaGetDisplayAttributes ( ctx, attr_list, num_attribut
es ); |
| 1316 |
| 1317 VA_TRACE_LOG(va_TraceGetDisplayAttributes, dpy, attr_list, num_attributes); |
| 1318 |
| 1319 return va_status; |
| 1320 } |
| 1321 |
| 1322 /* |
| 1323 * Set display attributes |
| 1324 * Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" f
ield |
| 1325 * from vaQueryDisplayAttributes() can be set. If the attribute is not settable
or |
| 1326 * the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPP
ORTED |
| 1327 */ |
| 1328 VAStatus vaSetDisplayAttributes ( |
| 1329 VADisplay dpy, |
| 1330 VADisplayAttribute *attr_list, |
| 1331 int num_attributes |
| 1332 ) |
| 1333 { |
| 1334 VADriverContextP ctx; |
| 1335 VAStatus va_status; |
| 1336 CHECK_DISPLAY(dpy); |
| 1337 ctx = CTX(dpy); |
| 1338 |
| 1339 va_status = ctx->vtable->vaSetDisplayAttributes ( ctx, attr_list, num_attribut
es ); |
| 1340 VA_TRACE_LOG(va_TraceSetDisplayAttributes, dpy, attr_list, num_attributes); |
| 1341 |
| 1342 return va_status; |
| 1343 } |
| 1344 |
| 1345 VAStatus vaLockSurface(VADisplay dpy, |
| 1346 VASurfaceID surface, |
| 1347 unsigned int *fourcc, /* following are output argument */ |
| 1348 unsigned int *luma_stride, |
| 1349 unsigned int *chroma_u_stride, |
| 1350 unsigned int *chroma_v_stride, |
| 1351 unsigned int *luma_offset, |
| 1352 unsigned int *chroma_u_offset, |
| 1353 unsigned int *chroma_v_offset, |
| 1354 unsigned int *buffer_name, |
| 1355 void **buffer |
| 1356 ) |
| 1357 { |
| 1358 VADriverContextP ctx; |
| 1359 CHECK_DISPLAY(dpy); |
| 1360 ctx = CTX(dpy); |
| 1361 |
| 1362 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); |
| 1363 } |
| 1364 |
| 1365 |
| 1366 VAStatus vaUnlockSurface(VADisplay dpy, |
| 1367 VASurfaceID surface |
| 1368 ) |
| 1369 { |
| 1370 VADriverContextP ctx; |
| 1371 CHECK_DISPLAY(dpy); |
| 1372 ctx = CTX(dpy); |
| 1373 |
| 1374 return ctx->vtable->vaUnlockSurface( ctx, surface ); |
| 1375 } |
OLD | NEW |