1 /* 2 * Copyright (c) 2021, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file media_libva_interface_next.h 24 //! \brief libva interface next head file 25 //! 26 27 #ifndef __MEDIA_LIBVA_INTERFACE_NEXT_H__ 28 #define __MEDIA_LIBVA_INTERFACE_NEXT_H__ 29 30 #include <va/va.h> 31 #include <va/va_backend.h> 32 #include <va/va_drmcommon.h> 33 #include "media_libva_common_next.h" 34 #include "ddi_media_functions.h" 35 36 class MediaLibvaInterfaceNext 37 { 38 public: 39 40 //! 41 //! \brief Init component list 42 //! 43 //! \param [in] mediaCtx 44 //! Pointer to ddi media context 45 //! 46 //! \return VAStatus 47 //! VA_STATUS_SUCCESS if success, else fail reason 48 //! 49 static VAStatus InitCompList(PDDI_MEDIA_CONTEXT mediaCtx); 50 51 //! 52 //! \brief Release component list 53 //! 54 //! \param [in] mediaCtx 55 //! Pointer to ddi media context 56 //! 57 static void ReleaseCompList(PDDI_MEDIA_CONTEXT mediaCtx); 58 59 //! 60 //! \brief Initialize 61 //! 62 //! \param [in] ctx 63 //! Pointer to VA driver context 64 //! \param [in] devicefd 65 //! Devoce fd 66 //! \param [out] major_version 67 //! Major version 68 //! \param [out] minor_version 69 //! Minor version 70 //! 71 //! \return VAStatus 72 //! VA_STATUS_SUCCESS if success, else fail reason 73 //! 74 static VAStatus Initialize ( 75 VADriverContextP ctx, 76 int32_t devicefd, 77 int32_t *major_version, /* out */ 78 int32_t *minor_version /* out */ 79 ); 80 81 //! 82 //! \brief clean up all library internal resources 83 //! 84 //! \param [in] ctx 85 //! Pointer to VA driver context 86 //! 87 //! \return VAStatus 88 //! VA_STATUS_SUCCESS if success, else fail reason 89 //! 90 static VAStatus Terminate(VADriverContextP ctx); 91 92 //! 93 //! \brief Create context 94 //! 95 //! \param [in] ctx 96 //! Pointer to VA driver context 97 //! \param [in] configId 98 //! VA config id 99 //! \param [in] pictureWidth 100 //! Picture width 101 //! \param [in] pictureHeight 102 //! Picture height 103 //! \param [out] flag 104 //! Create flag 105 //! \param [in] renderTargets 106 //! VA render traget 107 //! \param [in] renderTargetsNum 108 //! Number of render targets 109 //! \param [out] context 110 //! VA created context 111 //! 112 //! \return VAStatus 113 //! VA_STATUS_SUCCESS if success, else fail reason 114 //! 115 static VAStatus CreateContext ( 116 VADriverContextP ctx, 117 VAConfigID configId, 118 int32_t pictureWidth, 119 int32_t pictureHeight, 120 int32_t flag, 121 VASurfaceID *renderTargets, 122 int32_t rendertargetsNum, 123 VAContextID *context 124 ); 125 126 //! 127 //! \brief Destroy context 128 //! 129 //! \param [in] ctx 130 //! Pointer to VA driver context 131 //! \param [in] context 132 //! VA context to destroy 133 //! 134 //! \return VAStatus 135 //! VA_STATUS_SUCCESS if success, else fail reason 136 //! 137 static VAStatus DestroyContext ( 138 VADriverContextP ctx, 139 VAContextID context 140 ); 141 142 //! 143 //! \brief Create buffer 144 //! 145 //! \param [in] ctx 146 //! Pointer to VA driver context 147 //! \param [in] context 148 //! VA context id 149 //! \param [in] type 150 //! VA buffer type 151 //! \param [in] size 152 //! Buffer size 153 //! \param [out] elementsNum 154 //! Number of elements 155 //! \param [in] data 156 //! Buffer data 157 //! \param [out] bufId 158 //! VA buffer id 159 //! 160 //! \return VAStatus 161 //! VA_STATUS_SUCCESS if success, else fail reason 162 //! 163 static VAStatus CreateBuffer ( 164 VADriverContextP ctx, 165 VAContextID context, 166 VABufferType type, 167 uint32_t size, 168 uint32_t elementsNum, 169 void *data, 170 VABufferID *bufId 171 ); 172 173 //! 174 //! \brief Destroy buffer 175 //! 176 //! \param [in] ctx 177 //! Pointer to VA driver context 178 //! \param [in] buf_id 179 //! VA buffer ID 180 //! 181 //! \return VAStatus 182 //! VA_STATUS_SUCCESS if success, else fail reason 183 //! 184 static VAStatus DestroyBuffer( 185 VADriverContextP ctx, 186 VABufferID buf_id 187 ); 188 189 //! 190 //! \brief Get ready to decode a picture to a target surface 191 //! 192 //! \param [in] ctx 193 //! Pointer to VA driver context 194 //! \param [in] context 195 //! VA context id 196 //! \param [in] renderTarget 197 //! VA render target surface 198 //! 199 //! \return VAStatus 200 //! VA_STATUS_SUCCESS if success, else fail reason 201 //! 202 static VAStatus BeginPicture ( 203 VADriverContextP ctx, 204 VAContextID context, 205 VASurfaceID renderTarget 206 ); 207 208 //! 209 //! \brief Send decode buffers to the server 210 //! \details Buffers are automatically destroyed afterwards 211 //! \param [in] ctx 212 //! Pointer to VA driver context 213 //! \param [in] context 214 //! VA buffer id 215 //! \param [in] buffer 216 //! Pointer to VA buffer id 217 //! \param [in] buffersNum 218 //! number of buffers 219 //! 220 //! \return VAStatus 221 //! VA_STATUS_SUCCESS if success, else fail reason 222 //! 223 static VAStatus RenderPicture ( 224 VADriverContextP ctx, 225 VAContextID context, 226 VABufferID *buffers, 227 int32_t buffersNum 228 ); 229 230 //! 231 //! \brief Make the end of rendering for a picture 232 //! \details The server should start processing all pending operations for this 233 //! surface. This call is non-blocking. The client can start another 234 //! Begin/Render/End sequence on a different render target 235 //! \param [in] ctx 236 //! Pointer to VA driver context 237 //! \param [in] context 238 //! VA buffer id 239 //! 240 //! \return VAStatus 241 //! VA_STATUS_SUCCESS if success, else fail reason 242 //! 243 static VAStatus EndPicture ( 244 VADriverContextP ctx, 245 VAContextID context 246 ); 247 248 //! 249 //! \brief Query supported entrypoints for a given profile 250 //! 251 //! \param [in] ctx 252 //! Pointer to VA driver context 253 //! \param [in] profile 254 //! VA profile 255 //! \param [in] entrypointList 256 //! Pointer to VAEntrypoint array that can hold at least vaMaxNumEntrypoints() entries 257 //! \param [out] numEntryPoints 258 //! It returns the actual number of supported VAEntrypoints. 259 //! 260 //! \return VAStatus 261 //! VA_STATUS_SUCCESS if success 262 //! 263 static VAStatus QueryConfigEntrypoints( 264 VADriverContextP ctx, 265 VAProfile profile, 266 VAEntrypoint *entrypointList, 267 int32_t *entrypointsNum); 268 269 //! 270 //! \brief Query supported profiles 271 //! 272 //! \param [in] ctx 273 //! Pointer to VA driver context 274 //! \param [in] profileList 275 //! Pointer to VAProfile array that can hold at least vaMaxNumProfile() entries 276 //! \param [out] numProfiles 277 //! Pointer to int32_t. It returns the actual number of supported profiles. 278 //! 279 //! \return VAStatus 280 //! VA_STATUS_SUCCESS if success 281 //! 282 static VAStatus QueryConfigProfiles( 283 VADriverContextP ctx, 284 VAProfile *profileList, 285 int32_t *profilesNum); 286 287 //! 288 //! \brief Query all attributes for a given configuration 289 //! 290 //! \param [in] ctx 291 //! Pointer to VA driver context 292 //! \param [in] configId 293 //! VA configuration 294 //! \param [in,out] profile 295 //! Pointer to VAProfile of the configuration 296 //! \param [in,out] entrypoint 297 //! Pointer to VAEntrypoint of the configuration 298 //! \param [in,out] attribList 299 //! Pointer to VAConfigAttrib array that can hold at least 300 //! vaMaxNumConfigAttributes() entries. 301 //! \param [in,out] numAttribs 302 //! The actual number of VAConfigAttrib returned in the array attribList 303 //! 304 //! \return VAStatus 305 //! VA_STATUS_SUCCESS if success 306 //! 307 static VAStatus QueryConfigAttributes( 308 VADriverContextP ctx, 309 VAConfigID configId, 310 VAProfile *profile, 311 VAEntrypoint *entrypoint, 312 VAConfigAttrib *attribList, 313 int32_t *numAttribs); 314 315 //! 316 //! \brief Create a configuration 317 //! \details It passes in the attribute list that specifies the attributes it 318 //! cares about, with the rest taking default values. 319 //! 320 //! \param [in] ctx 321 //! Pointer to VA driver context 322 //! \param [in] profile 323 //! VA profile 324 //! \param [in] entrypoint 325 //! VA entrypoint 326 //! \param [in] attribList 327 //! Pointer to VAConfigAttrib array that specifies the attributes 328 //! \param [in] numAttribs 329 //! Number of VAConfigAttrib in the array attribList 330 //! \param [out] configId 331 //! Pointer to returned VAConfigID if success 332 //! 333 //! \return VAStatus 334 //! VA_STATUS_SUCCESS if success 335 //! 336 static VAStatus CreateConfig( 337 VADriverContextP ctx, 338 VAProfile profile, 339 VAEntrypoint entrypoint, 340 VAConfigAttrib *attribList, 341 int32_t numAttribs, 342 VAConfigID *configId); 343 344 //! 345 //! \brief Destory the VAConfigID 346 //! 347 //! \param [in] ctx 348 //! Pointer to VA driver context 349 //! \param [in] configId 350 //! Specify the VAConfigID 351 //! 352 //! \return VAStatus 353 //! VA_STATUS_SUCCESS if succeed 354 //! VA_STATUS_ERROR_INVALID_CONFIG if the conifgId is invalid 355 //! 356 static VAStatus DestroyConfig( 357 VADriverContextP ctx, 358 VAConfigID configId); 359 360 //! 361 //! \brief Get attributes for a given profile/entrypoint pair 362 //! \details The caller must provide an "attribList" with all attributes to be 363 //! retrieved. Upon return, the attributes in "attribList" have been 364 //! updated with their value. Unknown attributes or attributes that are 365 //! not supported for the given profile/entrypoint pair will have their 366 //! value set to VA_ATTRIB_NOT_SUPPORTED. 367 //! 368 //! \param [in] ctx 369 //! Pointer to VA driver context 370 //! \param [in] profile 371 //! VA profile 372 //! \param [in] entrypoint 373 //! VA entrypoint 374 //! \param [in,out] attribList 375 //! Pointer to VAConfigAttrib array. The attribute type is set by caller and 376 //! attribute value is set by this function. 377 //! \param [in] numAttribs 378 //! Number of VAConfigAttrib in the array attribList 379 //! 380 //! \return VAStatus 381 //! VA_STATUS_SUCCESS if success 382 //! 383 static VAStatus GetConfigAttributes( 384 VADriverContextP ctx, 385 VAProfile profile, 386 VAEntrypoint entrypoint, 387 VAConfigAttrib *attribList, 388 int32_t numAttribs); 389 390 //! 391 //! \brief Get surface attributes for a given config ID 392 //! 393 //! \param [in] ctx 394 //! Pointer to VA driver context 395 //! \param [in] configId 396 //! VA configuration 397 //! \param [in,out] attribList 398 //! Pointer to VASurfaceAttrib array. It returns 399 //! the supported surface attributes 400 //! \param [in,out] numAttribs 401 //! The number of elements allocated on input 402 //! Return the number of elements actually filled in output 403 //! 404 //! \return VAStatus 405 //! VA_STATUS_SUCCESS if success 406 //! VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small 407 //! 408 static VAStatus QuerySurfaceAttributes( 409 VADriverContextP ctx, 410 VAConfigID configId, 411 VASurfaceAttrib *attribList, 412 uint32_t *numAttribs); 413 414 //! 415 //! \brief Query the suppported image formats 416 //! 417 //! \param [in] ctx 418 //! Pointer to VA driver context 419 //! \param [in,out] formatList 420 //! Pointer to a VAImageFormat array. The array size shouldn't be less than vaMaxNumImageFormats 421 //! It will return the supported image formats. 422 //! \param [in,out] num_formats 423 //! Pointer to a integer that will return the real size of formatList. 424 //! 425 //! \return VAStatus 426 //! VA_STATUS_SUCCESS if succeed 427 //! 428 static VAStatus QueryImageFormats( 429 VADriverContextP ctx, 430 VAImageFormat *formatList, 431 int32_t *numFormats); 432 433 //! 434 //! \brief Set image palette 435 //! 436 //! \param [in] ctx 437 //! Pointer to VA driver context 438 //! \param [in] image 439 //! VA image ID 440 //! \param [in] palette 441 //! Palette 442 //! 443 //! \return VAStatus 444 //! VA_STATUS_ERROR_UNIMPLEMENTED if call success, else fail reason 445 //! 446 static VAStatus SetImagePalette( 447 VADriverContextP ctx, 448 VAImageID image, 449 unsigned char *palette); 450 451 //! 452 //! \brief Query subpicture formats 453 //! 454 //! \param [in] ctx 455 //! Pointer to VA driver context 456 //! \param [in] formatList 457 //! VA image format 458 //! \param [in] flags 459 //! Flags 460 //! \param [in] formatsNum 461 //! Number of formats 462 //! 463 //! \return VAStatus 464 //! VA_STATUS_SUCCESS if success, else fail reason 465 //! 466 static VAStatus QuerySubpictureFormats( 467 VADriverContextP ctx, 468 VAImageFormat *formatList, 469 uint32_t *flags, 470 uint32_t *formatsNum); 471 472 //! 473 //! \brief Create subpicture 474 //! 475 //! \param [in] ctx 476 //! Pointer to VA driver context 477 //! \param [in] image 478 //! VA image ID 479 //! \param [out] subpicture 480 //! VA subpicture ID 481 //! 482 //! \return VAStatus 483 //! VA_STATUS_ERROR_UNIMPLEMENTED 484 //! 485 static VAStatus CreateSubpicture( 486 VADriverContextP ctx, 487 VAImageID image, 488 VASubpictureID *subpicture); 489 490 //! 491 //! \brief Destroy subpicture 492 //! 493 //! \param [in] ctx 494 //! Pointer to VA driver context 495 //! \param [in] subpicture 496 //! VA subpicture ID 497 //! 498 //! \return VAStatus 499 //! VA_STATUS_ERROR_UNIMPLEMENTED 500 //! 501 static VAStatus DestroySubpicture( 502 VADriverContextP ctx, 503 VASubpictureID subpicture); 504 505 //! 506 //! \brief Set subpicture image 507 //! 508 //! \param [in] ctx 509 //! Pointer to VA driver context 510 //! \param [in] subpicture 511 //! VA subpicture ID 512 //! \param [in] image 513 //! VA image ID 514 //! 515 //! \return VAStatus 516 //! VA_STATUS_ERROR_UNIMPLEMENTED 517 //! 518 static VAStatus SetSubpictureImage( 519 VADriverContextP ctx, 520 VASubpictureID subpicture, 521 VAImageID image); 522 523 //! 524 //! \brief Set subpicture chrome key 525 //! 526 //! \param [in] ctx 527 //! Pointer to VA driver context 528 //! \param [in] subpicture 529 //! VA subpicture ID 530 //! \param [in] chromakeyMin 531 //! Minimum chroma key 532 //! \param [in] chromakeyMax 533 //! Maximum chroma key 534 //! \param [in] chromakeyMask 535 //! Chromakey mask 536 //! 537 //! \return VAStatus 538 //! VA_STATUS_ERROR_UNIMPLEMENTED 539 //! 540 static VAStatus SetSubpictureChromakey( 541 VADriverContextP ctx, 542 VASubpictureID subpicture, 543 uint32_t chromakeyMin, 544 uint32_t chromakeyMax, 545 uint32_t chromakeyMask); 546 547 //! 548 //! \brief set subpicture global alpha 549 //! 550 //! \param [in] ctx 551 //! Pointer to VA driver context 552 //! \param [in] subpicture 553 //! VA subpicture ID 554 //! \param [in] globalAlpha 555 //! Global alpha 556 //! 557 //! \return VAStatus 558 //! VA_STATUS_ERROR_UNIMPLEMENTED 559 //! 560 static VAStatus SetSubpictureGlobalAlpha( 561 VADriverContextP ctx, 562 VASubpictureID subpicture, 563 float globalAlpha); 564 565 //! 566 //! \brief Associate subpicture 567 //! 568 //! \param [in] ctx 569 //! Pointer to VA driver context 570 //! \param [in] subpicture 571 //! VA subpicture ID 572 //! \param [in] targetSurfaces 573 //! VA surface ID 574 //! \param [in] surfacesNum 575 //! Number of surfaces 576 //! \param [in] srcX 577 //! Source x of the region 578 //! \param [in] srcY 579 //! Source y of the region 580 //! \param [in] srcWidth 581 //! Source width of the region 582 //! \param [in] srcHeight 583 //! Source height of the region 584 //! \param [in] destX 585 //! Destination x 586 //! \param [in] destY 587 //! Destination y 588 //! \param [in] destWidth 589 //! Destination width 590 //! \param [in] destHeight 591 //! Destination height 592 //! \param [in] flags 593 //! Flags 594 //! 595 //! \return VAStatus 596 //! VA_STATUS_ERROR_UNIMPLEMENTED 597 //! 598 static VAStatus AssociateSubpicture( 599 VADriverContextP ctx, 600 VASubpictureID subpicture, 601 VASurfaceID *targetSurfaces, 602 int32_t surfacesNum, 603 int16_t srcX, /* upper left offset in subpicture */ 604 int16_t srcY, 605 uint16_t srcWidth, 606 uint16_t srcHeight, 607 int16_t destX, /* upper left offset in surface */ 608 int16_t destY, 609 uint16_t destWidth, 610 uint16_t destHeight, 611 uint32_t flags); 612 613 //! 614 //! \brief Deassociate subpicture 615 //! 616 //! \param [in] ctx 617 //! Pointer to VA driver context 618 //! \param [in] subpicture 619 //! VA subpicture ID 620 //! \param [in] targetSurfaces 621 //! VA surface ID 622 //! \param [in] surfacesNum 623 //! Number of surfaces 624 //! 625 //! \return VAStatus 626 //! VA_STATUS_ERROR_UNIMPLEMENTED 627 //! 628 static VAStatus DeassociateSubpicture( 629 VADriverContextP ctx, 630 VASubpictureID subpicture, 631 VASurfaceID *targetSurfaces, 632 int32_t surfacesNum); 633 634 //! 635 //! \brief Set display attributes 636 //! \details Only attributes returned with VA_DISPLAY_ATTRIB_SETTABLE set in the "flags" field 637 //! from vaQueryDisplayAttributes() can be set. If the attribute is not settable or 638 //! the value is out of range, the function returns VA_STATUS_ERROR_ATTR_NOT_SUPPORTED 639 //! 640 //! \param [in] ctx 641 //! Pointer to VA driver context 642 //! \param [in] attrList 643 //! VA display attribute 644 //! \param [in] attributesNum 645 //! Number of attributes 646 //! 647 //! \return VAStatus 648 //! VA_STATUS_ERROR_UNIMPLEMENTED 649 //! 650 static VAStatus SetDisplayAttributes( 651 VADriverContextP ctx, 652 VADisplayAttribute *attrList, 653 int32_t attributesNum); 654 655 //! 656 //! \brief Query display attributes 657 //! 658 //! \param [in] ctx 659 //! Pointer to VA driver context 660 //! \param [in] attrList 661 //! VA display attribute 662 //! \param [in] attributesNum 663 //! Number of attributes 664 //! 665 //! \return VAStatus 666 //! VA_STATUS_SUCCESS if success, else fail reason 667 //! 668 static VAStatus QueryDisplayAttributes( 669 VADriverContextP ctx, 670 VADisplayAttribute *attrList, 671 int32_t *attributesNum); 672 673 //! 674 //! \brief Get display attributes 675 //! \details This function returns the current attribute values in "attr_list". 676 //! Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field 677 //! from vaQueryDisplayAttributes() can have their values retrieved. 678 //! 679 //! \param [in] ctx 680 //! Pointer to VA driver context 681 //! \param [in] attrList 682 //! VA display attribute 683 //! \param [in] attributesNum 684 //! Number of attributes 685 //! 686 //! \return VAStatus 687 //! VA_STATUS_ERROR_UNIMPLEMENTED 688 //! 689 static VAStatus GetDisplayAttributes( 690 VADriverContextP ctx, 691 VADisplayAttribute *attrList, 692 int32_t attributesNum); 693 694 //! 695 //! \brief Convey to the server how many valid elements are in the buffer 696 //! \details e.g. if multiple slice parameters are being held in a single buffer, 697 //! this will communicate to the server the number of slice parameters 698 //! that are valid in the buffer. 699 //! 700 //! \param [in] ctx 701 //! Pointer to VA driver context 702 //! \param [in] bufId 703 //! VA buffer id 704 //! \param [in] elementsNum 705 //! Number of elements in buffer 706 //! 707 //! \return VAStatus 708 //! VA_STATUS_SUCCESS if success, else fail reason 709 //! 710 static VAStatus BufferSetNumElements( 711 VADriverContextP ctx, 712 VABufferID bufId, 713 uint32_t elementsNum); 714 715 //! 716 //! \brief Get process rate for a given config ID 717 //! 718 //! \param [in] ctx 719 //! Pointer to VA driver context 720 //! \param [in] configId 721 //! VA configuration 722 //! \param [in,out] procBuf 723 //! Pointer to VAProcessingRateParameter 724 //! \param [in,out] processingRate 725 //! Return the process rate 726 //! 727 //! \return VAStatus 728 //! VA_STATUS_SUCCESS if success 729 //! 730 static VAStatus QueryProcessingRate( 731 VADriverContextP ctx, 732 VAConfigID configId, 733 VAProcessingRateParameter *procBuf, 734 uint32_t *processingRate); 735 736 //! 737 //! \brief Query video proc filters 738 //! 739 //! \param [in] ctx 740 //! Pointer to VA driver context 741 //! \param [in] context 742 //! VA context ID 743 //! \param [in] filters 744 //! VA proc filter type 745 //! \param [in] filtersNum 746 //! Number of filters 747 //! 748 //! \return VAStatus 749 //! VA_STATUS_SUCCESS if success, else fail reason 750 //! 751 static VAStatus QueryVideoProcFilters ( 752 VADriverContextP ctx, 753 VAContextID context, 754 VAProcFilterType *filters, 755 uint32_t *filtersNum 756 ); 757 758 //! 759 //! \brief Query video processing filter capabilities. 760 //! The real implementation is in media_libva_vp.c, since it needs to use some definitions in vphal.h. 761 //! 762 //! \param [in] ctx 763 //! Pointer to VA driver context 764 //! \param [in] context 765 //! VA context ID 766 //! \param [in] type 767 //! VA proc filter type 768 //! \param [inout] filterCaps 769 //! FIlter caps 770 //! \param [inout] filterCapsNum 771 //! Number of filter caps 772 //! 773 //! \return VAStatus 774 //! VA_STATUS_SUCCESS if success, else fail reason 775 //! 776 static VAStatus QueryVideoProcFilterCaps ( 777 VADriverContextP ctx, 778 VAContextID context, 779 VAProcFilterType type, 780 void *filterCaps, 781 uint32_t *filterCapsNum 782 ); 783 784 //! 785 //! \brief Query video proc pipeline caps 786 //! 787 //! \param [in] ctx 788 //! Pointer to VA driver context 789 //! \param [in] context 790 //! VA context ID 791 //! \param [in] filters 792 //! VA buffer ID 793 //! \param [in] filtersNum 794 //! Number of filters 795 //! \param [in] pipelineCaps 796 //! VA proc pipeline caps 797 //! 798 //! \return VAStatus 799 //! VA_STATUS_SUCCESS if success, else fail reason 800 //! 801 static VAStatus QueryVideoProcPipelineCaps ( 802 VADriverContextP ctx, 803 VAContextID context, 804 VABufferID *filters, 805 uint32_t filtersNum, 806 VAProcPipelineCaps *pipelineCaps 807 ); 808 809 //! 810 //! \brief Create an image 811 //! 812 //! \param [in] ctx 813 //! Driver context 814 //! \param [in] format 815 //! The format of image 816 //! \param [in] width 817 //! The width of the image 818 //! \param [in] height 819 //! The height of the image 820 //! \param [out] image 821 //! The generated image 822 //! 823 //! \return VAStatus 824 //! VA_STATUS_SUCCESS if success, else fail reason 825 //! 826 static VAStatus CreateImage ( 827 VADriverContextP ctx, 828 VAImageFormat *format, 829 int32_t width, 830 int32_t height, 831 VAImage *image 832 ); 833 834 //! 835 //! \brief Derive image 836 //! 837 //! \param [in] ctx 838 //! Pointer to VA driver context 839 //! \param [in] surface 840 //! VA surface ID 841 //! \param [in] image 842 //! VA image 843 //! 844 //! \return VAStatus 845 //! VA_STATUS_SUCCESS if success, else fail reason 846 //! 847 static VAStatus DeriveImage ( 848 VADriverContextP ctx, 849 VASurfaceID surface, 850 VAImage *image 851 ); 852 853 //! 854 //! \brief Create surfaces 855 //! 856 //! \param [in] ctx 857 //! Pointer to VA driver context 858 //! \param [in] width 859 //! Surface width 860 //! \param [in] height 861 //! Surface height 862 //! \param [in] format 863 //! Surface format 864 //! \param [in] surfacesNum 865 //! Number of surfaces 866 //! \param [out] surfaces 867 //! VA created surfaces 868 //! 869 //! \return VAStatus 870 //! VA_STATUS_SUCCESS if success, else fail reason 871 //! 872 static VAStatus CreateSurfaces ( 873 VADriverContextP ctx, 874 int32_t width, 875 int32_t height, 876 int32_t format, 877 int32_t surfacesNum, 878 VASurfaceID *surfaces 879 ); 880 881 //! 882 //! \brief Destroy resources associated with surfaces. 883 //! \details Surfaces can only be destroyed after the context associated has been 884 //! destroyed 885 //! 886 //! \param [in] ctx 887 //! Pointer to VA driver context 888 //! \param [in] surfaces 889 //! VA array of surfaces to destroy 890 //! \param [in] surfacesNum 891 //! Number of surfaces in the array to be destroyed 892 //! 893 //! \return VAStatus 894 //! VA_STATUS_SUCCESS if success, else fail reason 895 //! 896 static VAStatus DestroySurfaces ( 897 VADriverContextP ctx, 898 VASurfaceID *surfaces, 899 int32_t surfacesNum 900 ); 901 902 //! 903 //! \brief Create surfaces2 904 //! 905 //! \param [in] ctx 906 //! Pointer to VA driver context 907 //! \param [in] format 908 //! Surface format 909 //! \param [in] width 910 //! Surface width 911 //! \param [in] height 912 //! Surface height 913 //! \param [out] surfaces 914 //! VA created surfaces 915 //! \param [in] surfacesNum 916 //! Number of surfaces 917 //! \param [out] attribList 918 //! VA attrib list 919 //! \param [in] attribsNum 920 //! Number of attribs 921 //! 922 //! \return VAStatus 923 //! VA_STATUS_SUCCESS if success, else fail reason 924 //! 925 static VAStatus CreateSurfaces2 ( 926 VADriverContextP ctx, 927 uint32_t format, 928 uint32_t width, 929 uint32_t height, 930 VASurfaceID *surfaces, 931 uint32_t surfacesNum, 932 VASurfaceAttrib *attribList, 933 uint32_t attribsNum 934 ); 935 936 #if VA_CHECK_VERSION(1, 9, 0) 937 //! 938 //! \brief Sync Surface 939 //! \details Sync surface 940 //! \param [in] ctx 941 //! Pointer to VA driver context 942 //! \param [in] surfaceId 943 //! VA surface id 944 //! \param [in] timeoutNs 945 //! time out period 946 //! 947 //! \return VAStatus 948 //! VA_STATUS_SUCCESS if success, else fail reason 949 //! 950 static VAStatus SyncSurface2 ( 951 VADriverContextP ctx, 952 VASurfaceID surfaceId, 953 uint64_t timeoutNs 954 ); 955 956 //! 957 //! \brief Sync buffer 958 //! \details This function blocks until all pending operations on the render target 959 //! have been completed. Upon return it is safe to use the render target for a 960 //! different picture 961 //! \param [in] ctx 962 //! Pointer to VA driver context 963 //! \param [in] bufId 964 //! VA buffer id 965 //! \param [in] timeoutNs 966 //! time out period 967 //! 968 //! \return VAStatus 969 //! VA_STATUS_SUCCESS if success, else fail reason 970 //! 971 static VAStatus SyncBuffer ( 972 VADriverContextP ctx, 973 VABufferID bufId, 974 uint64_t timeoutNs 975 ); 976 #endif 977 978 //! 979 //! \brief Check for buffer info 980 //! 981 //! \param [in] ctx 982 //! Pointer to VA driver context 983 //! \param [in] buf_id 984 //! VA buffer ID 985 //! \param [out] type 986 //! VA buffer type 987 //! \param [out] size 988 //! Size 989 //! \param [out] num_elements 990 //! Number of elements 991 //! 992 //! \return VAStatus 993 //! VA_STATUS_SUCCESS if success, else fail reason 994 //! 995 static VAStatus BufferInfo ( 996 VADriverContextP ctx, 997 VABufferID bufId, 998 VABufferType *type, 999 uint32_t *size, 1000 uint32_t *elementsNum); 1001 1002 //! 1003 //! \brief Query surface status 1004 //! 1005 //! \param [in] ctx 1006 //! Pointer to VA driver context 1007 //! \param [in] renderTarget 1008 //! VA surface ID 1009 //! \param [out] status 1010 //! VA surface status 1011 static VAStatus QuerySurfaceStatus ( 1012 VADriverContextP ctx, 1013 VASurfaceID renderTarget, 1014 VASurfaceStatus *status); 1015 1016 //! 1017 //! \brief Get surface attributes for the supplied config. 1018 //! 1019 //! This function retrieves the surface attributes matching the supplied 1020 //! config. The caller shall provide an \c attrib_list with all attributes 1021 //! to be retrieved. Upon successful return, the attributes in \c attrib_list 1022 //! are updated with the requested value. Unknown attributes or attributes 1023 //! that are not supported for the given config will have their \c flags 1024 //! field set to \c VA_SURFACE_ATTRIB_NOT_SUPPORTED. 1025 //! 1026 //! \param [in] ctx 1027 //! VA display 1028 //! \param [in] config 1029 //! the config identifying a codec or a video processing pipeline 1030 //! \param [out] attribList 1031 //! the list of attributes on output, with at least \c type fields filled in, 1032 //! and possibly \c value fields whenever necessary.The updated list of attributes and flags on output 1033 //! \param [in] attribsNum 1034 //! the number of attributes supplied in the \c attrib_list array 1035 //! 1036 //! \return VAStatus 1037 //! VA_STATUS_SUCCESS if success, else fail reason 1038 //! 1039 static VAStatus GetSurfaceAttributes ( 1040 VADriverContextP ctx, 1041 VAConfigID config, 1042 VASurfaceAttrib *attribList, 1043 uint32_t attribsNum); 1044 1045 //! 1046 //! \brief Aquire buffer handle 1047 //! 1048 //! \param [in] ctx 1049 //! Pointer to VA driver context 1050 //! \param [in] bufId 1051 //! VA buffer ID 1052 //! \param [in] bufInfo 1053 //! VA buffer Info 1054 //! 1055 //! \return VAStatus 1056 //! VA_STATUS_SUCCESS if success, else fail reason 1057 //! 1058 static VAStatus AcquireBufferHandle ( 1059 VADriverContextP ctx, 1060 VABufferID bufId, 1061 VABufferInfo *bufInfo); 1062 1063 //! 1064 //! \brief Release buffer handle 1065 //! 1066 //! \param [in] ctx 1067 //! Pointer to VA driver context 1068 //! \param [in] bufId 1069 //! VA bufferID 1070 //! 1071 //! \return VAStatus 1072 //! VA_STATUS_SUCCESS if success, else fail reason 1073 //! 1074 static VAStatus ReleaseBufferHandle( 1075 VADriverContextP ctx, 1076 VABufferID bufId); 1077 1078 //! 1079 //! \brief API for export surface handle to other component 1080 //! 1081 //! \param [in] dpy 1082 //! VA display. 1083 //! \param [in] surfaceId 1084 //! Surface to export. 1085 //! \param [in] memType 1086 //! Memory type to export to. 1087 //! \param [in] flags 1088 //! Combination of flags to apply 1089 //! \param [out] descriptor 1090 //! Pointer to the descriptor structure to fill 1091 //! with the handle details. The type of this structure depends on 1092 //! the value of mem_type. 1093 //! 1094 //! \return VAStatus 1095 //! VA_STATUS_SUCCESS if success, else fail reason 1096 //! 1097 static VAStatus ExportSurfaceHandle( 1098 VADriverContextP ctx, 1099 VASurfaceID surfaceId, 1100 uint32_t memType, 1101 uint32_t flags, 1102 void *descriptor); 1103 1104 //! 1105 //! \brief media copy internal 1106 //! 1107 //! \param [in] mosCtx 1108 //! Pointer to mos context 1109 //! \param [in] src 1110 //! VA copy mos resource src. 1111 //! \param [in] dst 1112 //! VA copy mos resrouce dst. 1113 //! \param [in] option 1114 //! VA copy option, copy mode. 1115 //! 1116 //! \return VAStatus 1117 //! VA_STATUS_SUCCESS if success, else fail reason 1118 //! 1119 static VAStatus CopyInternal( 1120 PMOS_CONTEXT mosCtx, 1121 PMOS_RESOURCE src, 1122 PMOS_RESOURCE dst, 1123 uint32_t copy_mode 1124 ); 1125 1126 #if VA_CHECK_VERSION(1,10,0) 1127 //! 1128 //! \brief media copy 1129 //! 1130 //! \param [in] ctx 1131 //! Pointer to VA driver context 1132 //! \param [in] dst_obj 1133 //! VA copy object dst. 1134 //! \param [in] src_obj 1135 //! VA copy object src. 1136 //! \param [in] option 1137 //! VA copy option, copy mode. 1138 //! \param [in] sync_handle 1139 //! VA copy sync handle 1140 //! 1141 //! \return VAStatus 1142 //! VA_STATUS_SUCCESS if success, else fail reason 1143 //! 1144 static VAStatus Copy ( 1145 VADriverContextP ctx, 1146 VACopyObject *dst_obj, 1147 VACopyObject *src_obj, 1148 VACopyOption option 1149 ); 1150 #endif 1151 1152 #if VA_CHECK_VERSION(1,11,0) 1153 1154 //! 1155 //! \brief Create protected session 1156 //! 1157 //! \param [in] ctx 1158 //! Pointer to VA driver context 1159 //! \param [in] configId 1160 //! VA configuration ID 1161 //! \param [out] protectedSession 1162 //! VA protected session ID 1163 //! 1164 //! \return VAStatus 1165 //! VA_STATUS_SUCCESS if success, else fail reason 1166 //! 1167 static VAStatus CreateProtectedSession ( 1168 VADriverContextP ctx, 1169 VAConfigID configId, 1170 VAProtectedSessionID *protectedSession 1171 ); 1172 1173 //! 1174 //! \brief Destroy protected session 1175 //! 1176 //! \param [in] ctx 1177 //! Pointer to VA driver context 1178 //! \param [in] protectedSession 1179 //! VA protected session ID 1180 //! 1181 //! \return VAStatus 1182 //! VA_STATUS_SUCCESS if success, else fail reason 1183 //! 1184 static VAStatus DestroyProtectedSession ( 1185 VADriverContextP ctx, 1186 VAProtectedSessionID protectedSession 1187 ); 1188 1189 //! 1190 //! \brief Attach protected session to display or context 1191 //! 1192 //! \param [in] ctx 1193 //! Pointer to VA driver context 1194 //! \param [in] context 1195 //! VA context ID to be attached if not 0. 1196 //! \param [in] protectedSession 1197 //! VA protected session ID 1198 //! 1199 //! \return VAStatus 1200 //! VA_STATUS_SUCCESS if success, else fail reason 1201 //! 1202 static VAStatus AttachProtectedSession ( 1203 VADriverContextP ctx, 1204 VAContextID context, 1205 VAProtectedSessionID protectedSession 1206 ); 1207 1208 //! 1209 //! \brief Detach protected session from display or context 1210 //! 1211 //! \param [in] ctx 1212 //! Pointer to VA driver context 1213 //! \param [in] context 1214 //! VA context ID to be Detached if not 0. 1215 //! 1216 //! \return VAStatus 1217 //! VA_STATUS_SUCCESS if success, else fail reason 1218 //! 1219 static VAStatus DetachProtectedSession ( 1220 VADriverContextP ctx, 1221 VAContextID context 1222 ); 1223 1224 //! 1225 //! \brief TEE execution for the particular protected session 1226 //! 1227 //! \param [in] ctx 1228 //! Pointer to VA driver context 1229 //! \param [in] protectedSession 1230 //! VA protected session ID 1231 //! \param [in] data 1232 //! VA buffer ID 1233 //! 1234 //! \return VAStatus 1235 //! VA_STATUS_SUCCESS if success, else fail reason 1236 //! 1237 static VAStatus ProtectedSessionExecute ( 1238 VADriverContextP ctx, 1239 VAProtectedSessionID protectedSession, 1240 VABufferID data 1241 ); 1242 #endif 1243 1244 //! 1245 //! \brief Convert media format to OS format 1246 //! 1247 //! \param [in] format 1248 //! Ddi media format 1249 //! 1250 //! \return Os format if call sucesss,else 1251 //! VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT if fail 1252 //! 1253 static int32_t MediaFormatToOsFormat(DDI_MEDIA_FORMAT format); 1254 1255 //! 1256 //! \brief Destroy buffer from VA buffer ID 1257 //! 1258 //! \param [in] mediaCtx 1259 //! Pointer to ddi media context 1260 //! \param [in] bufferID 1261 //! VA buffer ID 1262 //! 1263 //! \return bool 1264 //! true if destroy buffer from VA buffer ID, else false 1265 //! 1266 static bool DestroyBufFromVABufferID( 1267 PDDI_MEDIA_CONTEXT mediaCtx, 1268 VABufferID bufferID); 1269 1270 //! 1271 //! \brief Sync Surface 1272 //! \details Sync surface 1273 //! \param [in] ctx 1274 //! Pointer to VA driver context 1275 //! \param [in] surfaceId 1276 //! VA surface id 1277 //! \param [in] timeoutNs 1278 //! time out period 1279 //! 1280 //! \return VAStatus 1281 //! VA_STATUS_SUCCESS if success, else fail reason 1282 //! 1283 static VAStatus SyncSurface( 1284 VADriverContextP ctx, 1285 VASurfaceID renderTarget); 1286 1287 //! 1288 //! \brief Query Surface Error 1289 //! 1290 //! \param [in] ctx 1291 //! Pointer to VA driver context 1292 //! \param [in] renderTarget 1293 //! VASurfaceID 1294 //! \param [in] errorStatus 1295 //! error Status 1296 //! \param [in] errorInfo 1297 //! error info 1298 //! 1299 //! \return VAStatus 1300 //! VA_STATUS_SUCCESS if success, else fail reason 1301 //! 1302 static VAStatus QuerySurfaceError( 1303 VADriverContextP ctx, 1304 VASurfaceID renderTarget, 1305 VAStatus errorStatus, 1306 void **errorInfo); 1307 1308 //! 1309 //! \brief Copy data from a VAImage to a surface 1310 //! \details Image must be in a format supported by the implementation 1311 //! 1312 //! \param [in] ctx 1313 //! Input driver context 1314 //! \param [in] surface 1315 //! Surface ID of destination 1316 //! \param [in] draw 1317 //! Drawable of window system 1318 //! \param [in] image 1319 //! The image ID of the destination image 1320 //! \param [in] srcx 1321 //! Source x offset of the image region 1322 //! \param [in] srcy 1323 //! Source y offset of the image region 1324 //! \param [in] srcw 1325 //! Source width offset of the image region 1326 //! \param [in] srch 1327 //! Source height offset of the image region 1328 //! \param [in] destx 1329 //! Destination x offset of the surface region 1330 //! \param [in] desty 1331 //! Destination y offset of the surface region 1332 //! \param [in] destw 1333 //! Destination width offset of the surface region 1334 //! \param [in] desth 1335 //! Destination height offset of the surface region 1336 //! \param [in] cliprects 1337 //! client supplied clip list 1338 //! \param [in] numberCliprects 1339 //! number of clip rects in the clip list 1340 //! \param [in] flags 1341 //! de-interlacing flags 1342 //! 1343 //! \return VAStatus 1344 //! VA_STATUS_SUCCESS if success, else fail reason 1345 //! 1346 static VAStatus PutSurface( 1347 VADriverContextP ctx, 1348 VASurfaceID surface, 1349 void *draw, 1350 int16_t srcx, 1351 int16_t srcy, 1352 uint16_t srcw, 1353 uint16_t srch, 1354 int16_t destx, 1355 int16_t desty, 1356 uint16_t destw, 1357 uint16_t desth, 1358 VARectangle *cliprects, /* client supplied clip list */ 1359 uint32_t numberCliprects, /* number of clip rects in the clip list */ 1360 uint32_t flags /* de-interlacing flags */ 1361 ); 1362 1363 //! 1364 //! \brief Destroy Image 1365 //! \details Destroy VA Image 1366 //! 1367 //! \param [in] ctx 1368 //! Input driver context 1369 //! \param [in] image 1370 //! VA image ID 1371 //! 1372 //! \return VAStatus 1373 //! VA_STATUS_SUCCESS if success, else fail reason 1374 //! 1375 static VAStatus DestroyImage( 1376 VADriverContextP ctx, 1377 VAImageID image); 1378 1379 //! 1380 //! \brief Retrive surface data into a VAImage 1381 //! \details Image must be in a format supported by the implementation 1382 //! 1383 //! \param [in] ctx 1384 //! Input driver context 1385 //! \param [in] surface 1386 //! Input surface ID of source 1387 //! \param [in] x 1388 //! X offset of the wanted region 1389 //! \param [in] y 1390 //! Y offset of the wanted region 1391 //! \param [in] width 1392 //! Width of the wanted region 1393 //! \param [in] height 1394 //! Height of the wanted region 1395 //! \param [in] image 1396 //! The image ID of the source image 1397 //! 1398 //! \return VAStatus 1399 //! VA_STATUS_SUCCESS if success, else fail reason 1400 //! 1401 static VAStatus GetImage( 1402 VADriverContextP ctx, 1403 VASurfaceID surface, 1404 int32_t x, /* coordinates of the upper left source pixel */ 1405 int32_t y, 1406 uint32_t width, /* width and height of the region */ 1407 uint32_t height, 1408 VAImageID image 1409 ); 1410 1411 //! 1412 //! \brief Copy data from a VAImage to a surface 1413 //! \details Image must be in a format supported by the implementation 1414 //! 1415 //! \param [in] ctx 1416 //! Input driver context 1417 //! \param [in] surface 1418 //! Surface ID of destination 1419 //! \param [in] image 1420 //! The image ID of the destination image 1421 //! \param [in] srcX 1422 //! Source x offset of the image region 1423 //! \param [in] srcY 1424 //! Source y offset of the image region 1425 //! \param [in] srcWidth 1426 //! Source width offset of the image region 1427 //! \param [in] srcHeight 1428 //! Source height offset of the image region 1429 //! \param [in] destX 1430 //! Destination x offset of the surface region 1431 //! \param [in] destY 1432 //! Destination y offset of the surface region 1433 //! \param [in] destWidth 1434 //! Destination width offset of the surface region 1435 //! \param [in] destHeight 1436 //! Destination height offset of the surface region 1437 //! 1438 //! \return VAStatus 1439 //! VA_STATUS_SUCCESS if success, else fail reason 1440 //! 1441 static VAStatus PutImage( 1442 VADriverContextP ctx, 1443 VASurfaceID surface, 1444 VAImageID image, 1445 int32_t srcX, 1446 int32_t srcY, 1447 uint32_t srcWidth, 1448 uint32_t srcHeight, 1449 int32_t destX, 1450 int32_t destY, 1451 uint32_t destWidth, 1452 uint32_t destHeight 1453 ); 1454 1455 //! 1456 //! \brief Lock surface 1457 //! 1458 //! \param [in] ctx 1459 //! Pointer to VA driver context 1460 //! \param [in] surface 1461 //! VA surface ID 1462 //! \param [out] fourcc 1463 //! FourCC 1464 //! \param [out] lumaStride 1465 //! Luma stride 1466 //! \param [out] chromaUStride 1467 //! Chroma U stride 1468 //! \param [out] chromaVStride 1469 //! Chroma V stride 1470 //! \param [out] lumaOffset 1471 //! Luma offset 1472 //! \param [out] chromaUOffset 1473 //! Chroma U offset 1474 //! \param [out] chromaVOffset 1475 //! Chroma V offset 1476 //! \param [out] bufferName 1477 //! Buffer name 1478 //! \param [out] buffer 1479 //! Buffer 1480 //! 1481 //! \return VAStatus 1482 //! VA_STATUS_SUCCESS if success, else fail reason 1483 //! 1484 static VAStatus LockSurface( 1485 VADriverContextP ctx, 1486 VASurfaceID surface, 1487 uint32_t *fourcc, 1488 uint32_t *lumaStride, 1489 uint32_t *chromaUStride, 1490 uint32_t *chromaVStride, 1491 uint32_t *lumaOffset, 1492 uint32_t *chromaUOffset, 1493 uint32_t *chromaVOffset, 1494 uint32_t *bufferName, 1495 void **buffer); 1496 1497 //! 1498 //! \brief Unlock surface 1499 //! 1500 //! \param [in] ctx 1501 //! Pointer to VA driver context 1502 //! \param [in] surface 1503 //! VA surface ID 1504 //! 1505 //! \return VAStatus 1506 //! VA_STATUS_SUCCESS if success, else fail reason 1507 //! 1508 static VAStatus UnlockSurface( 1509 VADriverContextP ctx, 1510 VASurfaceID surface); 1511 private: 1512 1513 //! 1514 //! \brief Copy Surface To Image 1515 //! 1516 //! \param [in] ctx 1517 //! Pointer to VA driver context 1518 //! \param [in] surface 1519 //! Input surface 1520 //! \param [in] image 1521 //! Output image 1522 //! 1523 //! \return VAStatus 1524 //! VA_STATUS_SUCCESS if success, else fail reason 1525 //! 1526 static VAStatus CopySurfaceToImage( 1527 VADriverContextP ctx, 1528 DDI_MEDIA_SURFACE *surface, 1529 VAImage *image); 1530 1531 //! 1532 //! \brief Copy plane from src to dst row by row when src and dst strides are different 1533 //! 1534 //! \param [in] dst 1535 //! Destination plane 1536 //! \param [in] dstPitch 1537 //! Destination plane pitch 1538 //! \param [in] src 1539 //! Source plane 1540 //! \param [in] srcPitch 1541 //! Source plane pitch 1542 //! \param [in] height 1543 //! Plane hight 1544 //! 1545 static void CopyPlane( 1546 uint8_t *dst, 1547 uint32_t dstPitch, 1548 uint8_t *src, 1549 uint32_t srcPitch, 1550 uint32_t height); 1551 1552 //! 1553 //! \brief Map CompType from entrypoint 1554 //! 1555 //! \param [in] entrypoint 1556 //! VAEntrypoint 1557 //! 1558 //! \return CompType 1559 //! 1560 static CompType MapCompTypeFromEntrypoint(VAEntrypoint entrypoint); 1561 1562 //! 1563 //! \brief Map CompType from CtxType 1564 //! 1565 //! \param [in] ctxType 1566 //! context type 1567 //! 1568 //! \return CompType 1569 //! 1570 static CompType MapComponentFromCtxType(uint32_t ctxType); 1571 1572 //! 1573 //! \brief Load DDI function pointer 1574 //! 1575 //! \param [in] ctx 1576 //! Pointer to VA driver context 1577 //! 1578 //! \return VAStatus 1579 //! VA_STATUS_SUCCESS if success, else fail reason 1580 //! 1581 static VAStatus LoadFunction(VADriverContextP ctx); 1582 1583 //! 1584 //! \brief Free for media context 1585 //! 1586 //! \param [in] mediaCtx 1587 //! Pointer to ddi media context 1588 //! 1589 static void FreeForMediaContext(PDDI_MEDIA_CONTEXT mediaCtx); 1590 1591 //! 1592 //! \brief Free for media context 1593 //! 1594 //! \param [in] mediaCtx 1595 //! Pointer to ddi media context mutex 1596 //! 1597 static void DestroyMediaContextMutex(PDDI_MEDIA_CONTEXT mediaCtx); 1598 1599 //! 1600 //! \brief Create media context 1601 //! 1602 //! 1603 static PDDI_MEDIA_CONTEXT CreateMediaDriverContext(); 1604 1605 //! 1606 //! \brief Initialize 1607 //! 1608 //! \param [in] mediaCtx 1609 //! Pointer to DDI media driver context 1610 //! 1611 //! \return VAStatus 1612 //! VA_STATUS_SUCCESS if success, else fail reason 1613 //! 1614 static VAStatus HeapInitialize(PDDI_MEDIA_CONTEXT mediaCtx); 1615 1616 //! 1617 //! \brief Get Plane Num 1618 //! 1619 //! \param [in] mediaSurface 1620 //! Pointer to DDI media surface 1621 //! \param [in] hasAuxPlane 1622 //! if has Aus Plane 1623 //! 1624 //! \return uint32_t 1625 //! Plane num 1626 //! 1627 static uint32_t GetPlaneNum(PDDI_MEDIA_SURFACE mediaSurface, bool hasAuxPlane); 1628 1629 //! 1630 //! \brief Get Drm Format Of Separate Plane 1631 //! 1632 //! \param [in] fourcc 1633 //! Format 1634 //! \param [in] plane 1635 //! Plane 1636 //! 1637 //! \return uint32_t 1638 //! Drmformat 1639 //! 1640 static uint32_t GetDrmFormatOfSeparatePlane(uint32_t fourcc, int plane); 1641 1642 //! 1643 //! \brief Get Drm Format Of Separate Plane 1644 //! 1645 //! \param [in] fourcc 1646 //! Format 1647 //! 1648 //! \return uint32_t 1649 //! Drmformat 1650 //! 1651 static uint32_t GetDrmFormatOfCompositeObject(uint32_t fourcc); 1652 1653 //! 1654 //! \brief Get Chroma Pitch and Height 1655 //! 1656 //! \param [in] fourcc 1657 //! Format 1658 //! \param [in] pitch 1659 //! Pitch 1660 //! \param [in] height 1661 //! Height 1662 //! \param [out] chromaPitch 1663 //! ChromaPitch 1664 //! \param [out] chromaHeight 1665 //! ChromaHeight 1666 //! 1667 //! \return VAStatus 1668 //! VA_STATUS_SUCCESS if success, else fail reason 1669 //! 1670 static VAStatus GetChromaPitchHeight( 1671 uint32_t fourcc, 1672 uint32_t pitch, 1673 uint32_t height, 1674 uint32_t *chromaPitch, 1675 uint32_t *chromaHeight); 1676 1677 //! 1678 //! \brief Get VA image from VA image ID 1679 //! 1680 //! \param [in] mediaCtx 1681 //! Pointer to ddi media context 1682 //! \param [in] imageID 1683 //! VA image ID 1684 //! 1685 //! \return VAImage* 1686 //! Pointer to VAImage 1687 //! 1688 static VAImage* GetVAImageFromVAImageID (PDDI_MEDIA_CONTEXT mediaCtx, VAImageID imageID); 1689 1690 //! 1691 //! \brief Destroy image from VA image ID 1692 //! 1693 //! \param [in] mediaCtx 1694 //! Pointer to ddi media context 1695 //! \param [in] imageID 1696 //! VA image ID 1697 //! 1698 //! \return bool 1699 //! True if destroy image from VA image ID, else fail 1700 //! 1701 static bool DestroyImageFromVAImageID (PDDI_MEDIA_CONTEXT mediaCtx, VAImageID imageID); 1702 1703 #ifdef _MMC_SUPPORTED 1704 //! 1705 //! \brief Decompress internal media memory 1706 //! 1707 //! \param [in] mosCtx 1708 //! Pointer to mos context 1709 //! \param [in] osResource 1710 //! Pointer mos resource 1711 //! 1712 static void MediaMemoryDecompressInternal( 1713 PMOS_CONTEXT mosCtx, 1714 PMOS_RESOURCE osResource); 1715 1716 //! 1717 //! \brief copy internal media surface to another surface 1718 //! 1719 //! \param [in] mosCtx 1720 //! Pointer to mos context 1721 //! \param [in] inputOsResource 1722 //! Pointer input mos resource 1723 //! \param [in] outputOsResource 1724 //! Pointer output mos resource 1725 //! \param [in] boutputcompressed 1726 //! output can be compressed or not 1727 //! 1728 static void MediaMemoryCopyInternal( 1729 PMOS_CONTEXT mosCtx, 1730 PMOS_RESOURCE inputOsResource, 1731 PMOS_RESOURCE outputOsResource, 1732 bool boutputcompressed); 1733 1734 //! 1735 //! \brief copy internal media surface/buffer to another surface/buffer 1736 //! 1737 //! \param [in] mosCtx 1738 //! Pointer to mos context 1739 //! \param [in] inputOsResource 1740 //! Pointer input mos resource 1741 //! \param [in] outputOsResource 1742 //! Pointer output mos resource 1743 //! \param [in] boutputcompressed 1744 //! output can be compressed or not 1745 //! \param [in] copyWidth 1746 //! The 2D surface Width 1747 //! \param [in] copyHeight 1748 //! The 2D surface height 1749 //! \param [in] copyInputOffset 1750 //! The offset of copied surface from 1751 //! \param [in] copyOutputOffset 1752 //! The offset of copied to 1753 //! 1754 static void MediaMemoryCopy2DInternal( 1755 PMOS_CONTEXT mosCtx, 1756 PMOS_RESOURCE inputOsResource, 1757 PMOS_RESOURCE outputOsResource, 1758 uint32_t copyWidth, 1759 uint32_t copyHeight, 1760 uint32_t copyInputOffset, 1761 uint32_t copyOutputOffset, 1762 uint32_t bpp, 1763 bool boutputcompressed); 1764 1765 //! 1766 //! \brief Tile/Linear format conversion for media surface/buffer 1767 //! 1768 //! \param [in] mosCtx 1769 //! Pointer to mos context 1770 //! \param [in] inputOsResource 1771 //! Pointer input mos resource 1772 //! \param [in] outputOsResource 1773 //! Pointer output mos resource 1774 //! \param [in] copyWidth 1775 //! The 2D surface Width 1776 //! \param [in] copyHeight 1777 //! The 2D surface height 1778 //! \param [in] copyInputOffset 1779 //! The offset of copied surface from 1780 //! \param [in] copyOutputOffset 1781 //! The offset of copied to 1782 //! \param [in] isTileToLinear 1783 //! Convertion direction, true: tile->linear, false: linear->tile 1784 //! \param [in] outputCompressed 1785 //! output can be compressed or not 1786 //! 1787 static VAStatus MediaMemoryTileConvertInternal( 1788 PMOS_CONTEXT mosCtx, 1789 PMOS_RESOURCE inputOsResource, 1790 PMOS_RESOURCE outputOsResource, 1791 uint32_t copyWidth, 1792 uint32_t copyHeight, 1793 uint32_t copyInputOffset, 1794 uint32_t copyOutputOffset, 1795 bool isTileToLinear, 1796 bool outputCompressed); 1797 1798 #endif 1799 1800 #if defined(X11_FOUND) 1801 #define X11_LIB_NAME "libX11.so.6" 1802 //! 1803 //! \brief Close opened libX11.so lib, free related function table. 1804 //! 1805 //! \param [in] mediaCtx 1806 //! Pointer to media context 1807 //! 1808 static void DestroyX11Connection( 1809 PDDI_MEDIA_CONTEXT mediaCtx); 1810 1811 //! 1812 //! \brief dlopen libX11.so, setup the function table 1813 //! 1814 //! \param [in] mediaCtx 1815 //! Pointer to media context 1816 //! 1817 static VAStatus ConnectX11( 1818 PDDI_MEDIA_CONTEXT mediaCtx); 1819 1820 //! 1821 //! \brief Output driver initialization 1822 //! 1823 //! \param [in] ctx 1824 //! Pointer to VA driver context 1825 //! 1826 //! \return bool 1827 //! true if call success, else false 1828 //! 1829 static bool OutputDriInit(VADriverContextP ctx); 1830 1831 //! 1832 //! \brief Get dso symbols 1833 //! 1834 //! \param [in] h 1835 //! Pointer dso handle 1836 //! \param [in] vtable 1837 //! Pointer to VA driver table 1838 //! \param [in] vtable_length 1839 //! VA driver table length 1840 //! \param [in] symbols 1841 //! dso symbols 1842 //! 1843 //! \return bool 1844 //! true if call success, else false 1845 //! 1846 static bool DsoGetSymbols( 1847 struct dso_handle *h, 1848 void *vtable, 1849 uint32_t vtable_length, 1850 const struct dso_symbol *symbols); 1851 1852 //! 1853 //! \brief Open dso 1854 //! 1855 //! \param [in] path 1856 //! dso path 1857 //! 1858 //! \return dso_handle 1859 //! dso handle struct 1860 //! 1861 static struct dso_handle* DsoOpen(const char *path); 1862 1863 //! 1864 //! \brief Get symbol 1865 //! 1866 //! \param [in] h 1867 //! Pointer dso handle 1868 //! \param [in] func_vptr 1869 //! Pointer to function 1870 //! \param [in] name 1871 //! Functions name 1872 //! 1873 //! \return bool 1874 //! true if call success, else false 1875 //! 1876 static bool GetSymbol( 1877 struct dso_handle *h, 1878 void *func_vptr, 1879 const char *name); 1880 #endif 1881 1882 //! 1883 //! \brief Free allocated surfaceheap elements 1884 //! 1885 //! \param [in] mediaCtx 1886 //! Pointer to media context 1887 //! 1888 static void FreeSurfaceHeapElements(PDDI_MEDIA_CONTEXT mediaCtx); 1889 1890 //! 1891 //! \brief Free allocated bufferheap elements 1892 //! 1893 //! \param [in] ctx 1894 //! VA Driver Context 1895 //! 1896 static void FreeBufferHeapElements(VADriverContextP ctx); 1897 1898 //! 1899 //! \brief Free allocated Imageheap elements 1900 //! 1901 //! \param [in] ctx 1902 //! VA Driver Context 1903 //! 1904 static void FreeImageHeapElements(VADriverContextP ctx); 1905 1906 //! 1907 //! \brief Free allocated contextheap elements 1908 //! 1909 //! \param [in] ctx 1910 //! VA Driver Context 1911 //! 1912 static void FreeContextHeapElements(VADriverContextP ctx); 1913 1914 //! 1915 //! \brief Free allocated ContextCM elements 1916 //! 1917 //! \param [in] ctx 1918 //! VA Driver Context 1919 //! 1920 static void FreeContextCMElements(VADriverContextP ctx); 1921 1922 //! 1923 //! \brief Free allocated heap elements 1924 //! 1925 //! \param [in] mediaCtx 1926 //! Pointer to media context 1927 //! \return VAStatus 1928 //! VA_STATUS_SUCCESS if success, else fail reason 1929 //! 1930 static VAStatus HeapDestroy(PDDI_MEDIA_CONTEXT mediaCtx); 1931 1932 //! 1933 //! \brief Execute free allocated bufferheap elements for FreeContextHeapElements function 1934 //! 1935 //! \param [in] ctx 1936 //! VA Driver Context 1937 //! \param [in] contextHeap 1938 //! context heap 1939 //! \param [in] vaContextOffset 1940 //! context heap 1941 //! \param [in] ctxNums 1942 //! context numbers 1943 //! 1944 static void FreeContextHeap( 1945 VADriverContextP ctx, 1946 PDDI_MEDIA_HEAP contextHeap, 1947 int32_t vaContextOffset, 1948 int32_t ctxNums); 1949 1950 //! 1951 //! \brief DestroyCMContext 1952 //! 1953 //! \param [in] ctx 1954 //! VA Driver Context 1955 //! \param [in] ctxID 1956 //! context ID 1957 //! 1958 //! \return VAStatus 1959 //! VA_STATUS_SUCCESS if success, else fail reason 1960 //! 1961 static VAStatus DestroyContextCM( 1962 VADriverContextP ctx, 1963 VAContextID ctxID); 1964 1965 //! 1966 //! \brief Init SurfaceDescriptor Without AuxTableMgr 1967 //! 1968 //! \param [out] desc 1969 //! SurfaceDescriptor 1970 //! \param [in] formats 1971 //! DRM format 1972 //! \param [in] compositeObject 1973 //! compostie layer flag 1974 //! \param [in] planesNum 1975 //! planes num 1976 //! \param [in] offsetY 1977 //! Y channel offset 1978 //! \param [in] offsetU 1979 //! U channel offset 1980 //! \param [in] offsetV 1981 //! V channel offset 1982 //! \param [in] pitch 1983 //! surface pitch 1984 //! \param [in] chromaPitch 1985 //! chromaPitch pitch 1986 //! 1987 //! \return VAStatus 1988 //! VA_STATUS_SUCCESS if success, else fail reason 1989 //! 1990 static VAStatus InitSurfaceDescriptorWithoutAuxTableMgr( 1991 VADRMPRIMESurfaceDescriptor *desc, 1992 uint32_t *formats, 1993 int compositeObject, 1994 uint32_t planesNum, 1995 uint32_t offsetY, 1996 uint32_t offsetU, 1997 uint32_t offsetV, 1998 uint32_t pitch, 1999 uint32_t chromaPitch); 2000 2001 //! 2002 //! \brief Init SurfaceDescriptor With AuxTableMgr 2003 //! 2004 //! \param [out] desc 2005 //! SurfaceDescriptor 2006 //! \param [in] formats 2007 //! DRM format 2008 //! \param [in] compositeObject 2009 //! compostie layer flag 2010 //! \param [in] planesNum 2011 //! planes num 2012 //! \param [in] offsetY 2013 //! Y channel offset 2014 //! \param [in] offsetU 2015 //! U channel offset 2016 //! \param [in] offsetv 2017 //! U channel offset 2018 //! \param [in] auxOffsetY 2019 //! Y channel aux offset 2020 //! \param [in] auxOffsetUV 2021 //! UV channel aux offset 2022 //! \param [in] pitch 2023 //! surface pitch 2024 //! 2025 //! \return VAStatus 2026 //! VA_STATUS_SUCCESS if success, else fail reason 2027 //! 2028 static VAStatus InitSurfaceDescriptorWithAuxTableMgr( 2029 VADRMPRIMESurfaceDescriptor *desc, 2030 uint32_t *formats, 2031 int compositeObject, 2032 uint32_t planesNum, 2033 uint32_t offsetY, 2034 uint32_t offsetU, 2035 uint32_t offsetV, 2036 uint32_t auxOffsetY, 2037 uint32_t auxOffsetUV, 2038 int32_t pitch); 2039 2040 //! 2041 //! \brief Generate Vaimg From input Media format 2042 //! 2043 //! \param [in] mediaSurface 2044 //! Media surface 2045 //! \param [in] mediaCtx 2046 //! Media context 2047 //! \param [out] vaimg 2048 //! vaimg 2049 //! 2050 //! \return VAStatus 2051 //! VA_STATUS_SUCCESS if success, else fail reason 2052 //! 2053 static VAStatus GenerateVaImgFromMediaFormat( 2054 DDI_MEDIA_SURFACE *mediaSurface, 2055 PDDI_MEDIA_CONTEXT mediaCtx, 2056 VAImage *vaimg); 2057 2058 //! 2059 //! \brief Generate Vaimg From input OS format 2060 //! 2061 //! \param [in] format 2062 //! Os format type 2063 //! \param [out] vaimg 2064 //! vaimg 2065 //! 2066 //! \return VAStatus 2067 //! VA_STATUS_SUCCESS if success, else fail reason 2068 //! 2069 static VAStatus GenerateVaImgFromOsFormat( 2070 VAImageFormat format, 2071 int32_t width, 2072 int32_t height, 2073 GMM_RESOURCE_INFO *gmmResourceInfo, 2074 VAImage *vaimg); 2075 2076 //! 2077 //! \brief Convert Rt format to OS format 2078 //! 2079 //! \param [in] format 2080 //! RT format type 2081 //! \param [out] expectedFourcc 2082 //! Os format type 2083 //! 2084 //! \return VAStatus 2085 //! VA_STATUS_SUCCESS if success, else fail reason 2086 //! 2087 static VAStatus RtFormatToOsFormat(uint32_t format, int32_t &expectedFourcc); 2088 2089 //! 2090 //! \brief Convert Os format to media format 2091 //! 2092 //! \param [in] fourcc 2093 //! FourCC 2094 //! \param [in] rtformatType 2095 //! Rt format type 2096 //! 2097 //! \return DDI_MEDIA_FORMAT 2098 //! Ddi media format 2099 //! 2100 static DDI_MEDIA_FORMAT OsFormatToMediaFormat(int32_t fourcc, int32_t rtformatType); 2101 2102 //! 2103 //! \brief create render target 2104 //! 2105 //! \param [in] mediaDrvCtx 2106 //! Pointer to media context 2107 //! \param [in] mediaFormat 2108 //! media format 2109 //! \param [in] width 2110 //! width 2111 //! \param [in] height 2112 //! height 2113 //! \param [in] surfDesc 2114 //! media surface descriptor 2115 //! \param [in] surfaceUsageHint 2116 //! surface usage hint 2117 //! \param [in] memType 2118 //! memory type 2119 //! \return uint_32 2120 //! surface ID 2121 //! 2122 static uint32_t CreateRenderTarget( 2123 PDDI_MEDIA_CONTEXT mediaDrvCtx, 2124 DDI_MEDIA_FORMAT mediaFormat, 2125 uint32_t width, 2126 uint32_t height, 2127 DDI_MEDIA_SURFACE_DESCRIPTOR *surfDesc, 2128 uint32_t surfaceUsageHint, 2129 int memType); 2130 2131 public: 2132 //! 2133 //! \brief Map buffer 2134 //! 2135 //! \param [in] ctx 2136 //! Pointer to VA driver context 2137 //! \param [in] buf_id 2138 //! VA buffer id 2139 //! \param [in] pbuf 2140 //! Address of buffer 2141 //! 2142 //! \return VAStatus 2143 //! VA_STATUS_SUCCESS if success, else fail reason 2144 //! 2145 static VAStatus MapBuffer( 2146 VADriverContextP ctx, 2147 VABufferID buf_id, 2148 void **pbuf); 2149 2150 //! 2151 //! \brief Map data store of the buffer into the client's address space 2152 //! vaCreateBuffer() needs to be called with "data" set to nullptr before calling vaMapBuffer() 2153 //! 2154 //! \param [in] ctx 2155 //! Pointer to VA driver context 2156 //! \param [in] bufId 2157 //! VA buffer ID 2158 //! \param [out] buf 2159 //! Pointer to buffer 2160 //! \param [in] flag 2161 //! Flag 2162 //! 2163 //! \return VAStatus 2164 //! VA_STATUS_SUCCESS if success, else fail reason 2165 //! 2166 static VAStatus MapBufferInternal( 2167 VADriverContextP ctx, 2168 VABufferID bufId, 2169 void **buf, 2170 uint32_t flag); 2171 2172 //! \brief Unmap buffer 2173 //! 2174 //! \param [in] ctx 2175 //! Pointer to VA driver context 2176 //! \param [in] bufId 2177 //! VA buffer ID 2178 //! 2179 //! \return VAStatus 2180 //! VA_STATUS_SUCCESS if success, else fail reason 2181 //! 2182 static VAStatus UnmapBuffer( 2183 VADriverContextP ctx, 2184 VABufferID bufId); 2185 2186 //! 2187 //! \brief Decompress a compressed surface. 2188 //! 2189 //! \param [in] mediaCtx 2190 //! Pointer to ddi media context 2191 //! \param [in] mediaSurface 2192 //! Ddi media surface 2193 //! 2194 //! \return VAStatus 2195 //! VA_STATUS_SUCCESS if success, else fail reason 2196 //! 2197 static VAStatus MediaMemoryDecompress( 2198 PDDI_MEDIA_CONTEXT mediaCtx, 2199 DDI_MEDIA_SURFACE *mediaSurface); 2200 2201 public: 2202 // Global mutex 2203 static MEDIA_MUTEX_T m_GlobalMutex; 2204 MEDIA_CLASS_DEFINE_END(MediaLibvaInterfaceNext) 2205 }; 2206 2207 #endif //__MEDIA_LIBVA_INTERFACE_NEXT_H__