1 /* 2 * Copyright (c) 2021-2022, 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.h 24 //! \brief libva interface head file 25 //! 26 27 #ifndef __MEDIA_LIBVA_INTERFACE_H__ 28 #define __MEDIA_LIBVA_INTERFACE_H__ 29 30 #include <va/va.h> 31 #include <va/va_backend.h> 32 #include "va/va_dec_vp8.h" 33 #include <va/va_enc_h264.h> 34 #include <va/va_enc_mpeg2.h> 35 #include <va/va_enc_jpeg.h> 36 #include <va/va_dec_jpeg.h> 37 #include <va/va_enc_vp8.h> 38 #include <va/va_dec_vp9.h> 39 #include <va/va_enc_hevc.h> 40 #include <va/va_vpp.h> 41 #include <va/va_backend_vpp.h> 42 #if VA_CHECK_VERSION(1,11,0) 43 #include <va/va_backend_prot.h> 44 #endif 45 #ifdef ANDROID 46 #if VA_MAJOR_VERSION < 1 47 #include "va_internal_android.h" 48 #endif 49 #endif // ANDROID 50 #include <va/va_dec_hevc.h> 51 52 class MediaLibvaInterface 53 { 54 public: 55 56 //! 57 //! \brief clean up all library internal resources 58 //! 59 //! \param [in] ctx 60 //! Pointer to VA driver context 61 //! 62 //! \return VAStatus 63 //! VA_STATUS_SUCCESS if success, else fail reason 64 //! 65 static VAStatus Terminate (VADriverContextP ctx); 66 67 //! 68 //! \brief Query supported entrypoints for a given profile 69 //! \details The caller must provide an "entrypoint_list" array that can hold at 70 //! least vaMaxNumEntrypoints() entries. The actual number of entrypoints 71 //! returned in "entrypoint_list" is returned in "num_entrypoints". 72 //! 73 //! \param [in] ctx 74 //! Pointer to VA driver context 75 //! \param [in] profile 76 //! VA profile 77 //! \param [out] entrypoint_list 78 //! VA entrypoints 79 //! \param [out] num_entrypoints 80 //! Number of entrypoints 81 //! 82 //! \return VAStatus 83 //! VA_STATUS_SUCCESS if success, else fail reason 84 //! 85 static VAStatus QueryConfigEntrypoints ( 86 VADriverContextP ctx, 87 VAProfile profile, 88 VAEntrypoint *entrypoint_list, 89 int32_t *num_entrypoints 90 ); 91 92 //! 93 //! \brief Query supported profiles 94 //! \details The caller must provide a "profile_list" array that can hold at 95 //! least vaMaxNumProfile() entries. The actual number of profiles 96 //! returned in "profile_list" is returned in "num_profile". 97 //! 98 //! \param [in] ctx 99 //! Pointer to VA driver context 100 //! \param [out] profile_list 101 //! VA profiles 102 //! \param [out] num_profiles 103 //! Number of profiles 104 //! 105 //! \return VAStatus 106 //! VA_STATUS_SUCCESS if success, else fail reason 107 //! 108 static VAStatus QueryConfigProfiles ( 109 VADriverContextP ctx, 110 VAProfile *profile_list, 111 int32_t *num_profiles 112 ); 113 114 //! 115 //! \brief Query all attributes for a given configuration 116 //! \details The profile of the configuration is returned in "profile" 117 //! The entrypoint of the configuration is returned in "entrypoint" 118 //! The caller must provide an "attrib_list" array that can hold at least 119 //! vaMaxNumConfigAttributes() entries. The actual number of attributes 120 //! returned in "attrib_list" is returned in "num_attribs" 121 //! 122 //! \param [in] ctx 123 //! Pointer to VA driver context 124 //! \param [in] config_id 125 //! VA config id 126 //! \param [out] profile 127 //! VA profile of configuration 128 //! \param [out] entrypoint 129 //! VA entrypoint of configuration 130 //! \param [out] attrib_list 131 //! VA attrib list 132 //! \param [out] num_attribs 133 //! Number of attribs 134 //! 135 //! \return VAStatus 136 //! VA_STATUS_SUCCESS if success, else fail reason 137 //! 138 static VAStatus QueryConfigAttributes ( 139 VADriverContextP ctx, 140 VAConfigID config_id, 141 VAProfile *profile, 142 VAEntrypoint *entrypoint, 143 VAConfigAttrib *attrib_list, 144 int32_t *num_attribs 145 ); 146 147 //! 148 //! \brief Create a configuration for the encode/decode/vp pipeline 149 //! \details it passes in the attribute list that specifies the attributes it cares 150 //! about, with the rest taking default values. 151 //! 152 //! \param [in] ctx 153 //! Pointer to VA driver context 154 //! \param [in] profile 155 //! VA profile of configuration 156 //! \param [in] entrypoint 157 //! VA entrypoint of configuration 158 //! \param [out] attrib_list 159 //! VA attrib list 160 //! \param [out] num_attribs 161 //! Number of attribs 162 //! \param [out] config_id 163 //! VA config id 164 //! 165 //! \return VAStatus 166 //! VA_STATUS_SUCCESS if success, else fail reason 167 //! 168 static VAStatus CreateConfig ( 169 VADriverContextP ctx, 170 VAProfile profile, 171 VAEntrypoint entrypoint, 172 VAConfigAttrib *attrib_list, 173 int32_t num_attribs, 174 VAConfigID *config_id 175 ); 176 177 //! 178 //! \brief Free resources associated with a given config 179 //! 180 //! \param [in] ctx 181 //! Pointer to VA driver context 182 //! \param [in] config_id 183 //! VA config id 184 //! 185 //! \return VAStatus 186 //! VA_STATUS_SUCCESS if success, else fail reason 187 //! 188 static VAStatus DestroyConfig ( 189 VADriverContextP ctx, 190 VAConfigID config_id 191 ); 192 193 //! 194 //! \brief Get attributes for a given profile/entrypoint pair 195 //! \details The caller must provide an "attrib_list" with all attributes to be 196 //! retrieved. Upon return, the attributes in "attrib_list" have been 197 //! updated with their value. Unknown attributes or attributes that are 198 //! not supported for the given profile/entrypoint pair will have their 199 //! value set to VA_ATTRIB_NOT_SUPPORTED 200 //! 201 //! \param [in] ctx 202 //! Pointer to VA driver context 203 //! \param [in] profile 204 //! VA profile of configuration 205 //! \param [in] entrypoint 206 //! VA entrypoint of configuration 207 //! \param [out] attrib_list 208 //! VA attrib list 209 //! \param [in] num_attribs 210 //! Number of attribs 211 //! 212 //! \return VAStatus 213 //! VA_STATUS_SUCCESS if success, else fail reason 214 //! 215 static VAStatus GetConfigAttributes ( 216 VADriverContextP ctx, 217 VAProfile profile, 218 VAEntrypoint entrypoint, 219 VAConfigAttrib *attrib_list, 220 int32_t num_attribs 221 ); 222 223 //! 224 //! \brief Create surfaces 225 //! 226 //! \param [in] ctx 227 //! Pointer to VA driver context 228 //! \param [in] width 229 //! Surface width 230 //! \param [in] height 231 //! Surface height 232 //! \param [in] format 233 //! Surface format 234 //! \param [in] num_surfaces 235 //! Number of surfaces 236 //! \param [out] surfaces 237 //! VA created surfaces 238 //! 239 //! \return VAStatus 240 //! VA_STATUS_SUCCESS if success, else fail reason 241 //! 242 static VAStatus CreateSurfaces ( 243 VADriverContextP ctx, 244 int32_t width, 245 int32_t height, 246 int32_t format, 247 int32_t num_surfaces, 248 VASurfaceID *surfaces 249 ); 250 251 //! 252 //! \brief Destroy resources associated with surfaces. 253 //! \details Surfaces can only be destroyed after the context associated has been 254 //! destroyed 255 //! 256 //! \param [in] ctx 257 //! Pointer to VA driver context 258 //! \param [in] surfaces 259 //! VA array of surfaces to destroy 260 //! \param [in] num_surfaces 261 //! Number of surfaces in the array to be destroyed 262 //! 263 //! \return VAStatus 264 //! VA_STATUS_SUCCESS if success, else fail reason 265 //! 266 static VAStatus DestroySurfaces ( 267 VADriverContextP ctx, 268 VASurfaceID *surfaces, 269 int32_t num_surfaces 270 ); 271 272 //! 273 //! \brief Create surfaces2 274 //! 275 //! \param [in] ctx 276 //! Pointer to VA driver context 277 //! \param [in] format 278 //! Surface format 279 //! \param [in] width 280 //! Surface width 281 //! \param [in] height 282 //! Surface height 283 //! \param [out] surfaces 284 //! VA created surfaces 285 //! \param [in] num_surfaces 286 //! Number of surfaces 287 //! \param [out] attrib_list 288 //! VA attrib list 289 //! \param [in] num_attribs 290 //! Number of attribs 291 //! 292 //! \return VAStatus 293 //! VA_STATUS_SUCCESS if success, else fail reason 294 //! 295 static VAStatus CreateSurfaces2 ( 296 VADriverContextP ctx, 297 uint32_t format, 298 uint32_t width, 299 uint32_t height, 300 VASurfaceID *surfaces, 301 uint32_t num_surfaces, 302 VASurfaceAttrib *attrib_list, 303 uint32_t num_attribs 304 ); 305 306 //! 307 //! \brief Create context 308 //! 309 //! \param [in] ctx 310 //! Pointer to VA driver context 311 //! \param [in] config_id 312 //! VA config id 313 //! \param [in] picture_width 314 //! Picture width 315 //! \param [in] picture_height 316 //! Picture height 317 //! \param [out] flag 318 //! Create flag 319 //! \param [in] render_targets 320 //! VA render traget 321 //! \param [in] num_render_targets 322 //! Number of render targets 323 //! \param [out] context 324 //! VA created context 325 //! 326 //! \return VAStatus 327 //! VA_STATUS_SUCCESS if success, else fail reason 328 //! 329 static VAStatus CreateContext ( 330 VADriverContextP ctx, 331 VAConfigID config_id, 332 int32_t picture_width, 333 int32_t picture_height, 334 int32_t flag, 335 VASurfaceID *render_targets, 336 int32_t num_render_targets, 337 VAContextID *context 338 ); 339 340 //! 341 //! \brief Destroy context 342 //! 343 //! \param [in] ctx 344 //! Pointer to VA driver context 345 //! \param [in] context 346 //! VA context to destroy 347 //! 348 //! \return VAStatus 349 //! VA_STATUS_SUCCESS if success, else fail reason 350 //! 351 static VAStatus DestroyContext ( 352 VADriverContextP ctx, 353 VAContextID context 354 ); 355 356 //! 357 //! \brief Create buffer 358 //! 359 //! \param [in] ctx 360 //! Pointer to VA driver context 361 //! \param [in] context 362 //! VA context id 363 //! \param [in] type 364 //! VA buffer type 365 //! \param [in] size 366 //! Buffer size 367 //! \param [out] num_elements 368 //! Number of elements 369 //! \param [in] data 370 //! Buffer data 371 //! \param [out] bufId 372 //! VA buffer id 373 //! 374 //! \return VAStatus 375 //! VA_STATUS_SUCCESS if success, else fail reason 376 //! 377 static VAStatus CreateBuffer ( 378 VADriverContextP ctx, 379 VAContextID context, 380 VABufferType type, 381 uint32_t size, 382 uint32_t num_elements, 383 void *data, 384 VABufferID *bufId 385 ); 386 387 //! 388 //! \brief Convey to the server how many valid elements are in the buffer 389 //! \details e.g. if multiple slice parameters are being held in a single buffer, 390 //! this will communicate to the server the number of slice parameters 391 //! that are valid in the buffer. 392 //! 393 //! \param [in] ctx 394 //! Pointer to VA driver context 395 //! \param [in] buf_id 396 //! VA buffer id 397 //! \param [in] num_elements 398 //! Number of elements in buffer 399 //! 400 //! \return VAStatus 401 //! VA_STATUS_SUCCESS if success, else fail reason 402 //! 403 static VAStatus BufferSetNumElements ( 404 VADriverContextP ctx, 405 VABufferID buf_id, 406 uint32_t num_elements 407 ); 408 409 //! 410 //! \brief Map buffer 411 //! 412 //! \param [in] ctx 413 //! Pointer to VA driver context 414 //! \param [in] buf_id 415 //! VA buffer id 416 //! \param [in] pbuf 417 //! Address of buffer 418 //! 419 //! \return VAStatus 420 //! VA_STATUS_SUCCESS if success, else fail reason 421 //! 422 static VAStatus MapBuffer ( 423 VADriverContextP ctx, 424 VABufferID buf_id, 425 void **pbuf 426 ); 427 428 //! 429 //! \brief Unmap buffer 430 //! \details After client making changes to a mapped data store, it needs to 431 //! "Unmap" it to let the server know that the data is ready to be 432 //! consumed by the server 433 //! \param [in] ctx 434 //! Pointer to VA driver context 435 //! \param [in] buf_id 436 //! VA buffer id 437 //! 438 //! \return VAStatus 439 //! VA_STATUS_SUCCESS if success, else fail reason 440 //! 441 static VAStatus UnmapBuffer ( 442 VADriverContextP ctx, 443 VABufferID buf_id 444 ); 445 446 //! 447 //! \brief Destroy buffer 448 //! \details After this call, the buffer is deleted and this buffer_id is no longer valid 449 //! Only call this if the buffer is not going to be passed to vaRenderBuffer 450 //! \param [in] ctx 451 //! Pointer to VA driver context 452 //! \param [in] buf_id 453 //! VA buffer id 454 //! 455 //! \return VAStatus 456 //! VA_STATUS_SUCCESS if success, else fail reason 457 //! 458 static VAStatus DestroyBuffer ( 459 VADriverContextP ctx, 460 VABufferID buffer_id 461 ); 462 463 //! 464 //! \brief Get ready to decode a picture to a target surface 465 //! 466 //! \param [in] ctx 467 //! Pointer to VA driver context 468 //! \param [in] context 469 //! VA context id 470 //! \param [in] render_target 471 //! VA render target surface 472 //! 473 //! \return VAStatus 474 //! VA_STATUS_SUCCESS if success, else fail reason 475 //! 476 static VAStatus BeginPicture ( 477 VADriverContextP ctx, 478 VAContextID context, 479 VASurfaceID render_target 480 ); 481 482 //! 483 //! \brief Send decode buffers to the server 484 //! \details Buffers are automatically destroyed afterwards 485 //! \param [in] ctx 486 //! Pointer to VA driver context 487 //! \param [in] context 488 //! VA buffer id 489 //! \param [in] buffer 490 //! Pointer to VA buffer id 491 //! \param [in] num_buffers 492 //! number of buffers 493 //! 494 //! \return VAStatus 495 //! VA_STATUS_SUCCESS if success, else fail reason 496 //! 497 static VAStatus RenderPicture ( 498 VADriverContextP ctx, 499 VAContextID context, 500 VABufferID *buffers, 501 int32_t num_buffers 502 ); 503 504 //! 505 //! \brief Make the end of rendering for a picture 506 //! \details The server should start processing all pending operations for this 507 //! surface. This call is non-blocking. The client can start another 508 //! Begin/Render/End sequence on a different render target 509 //! \param [in] ctx 510 //! Pointer to VA driver context 511 //! \param [in] context 512 //! VA buffer id 513 //! 514 //! \return VAStatus 515 //! VA_STATUS_SUCCESS if success, else fail reason 516 //! 517 static VAStatus EndPicture ( 518 VADriverContextP ctx, 519 VAContextID context 520 ); 521 522 //! 523 //! \brief Sync surface 524 //! \details This function blocks until all pending operations on the render target 525 //! have been completed. Upon return it is safe to use the render target for a 526 //! different picture 527 //! \param [in] ctx 528 //! Pointer to VA driver context 529 //! \param [in] render_target 530 //! VA render target surface id 531 //! 532 //! \return VAStatus 533 //! VA_STATUS_SUCCESS if success, else fail reason 534 //! 535 static VAStatus SyncSurface ( 536 VADriverContextP ctx, 537 VASurfaceID render_target 538 ); 539 540 #if VA_CHECK_VERSION(1, 9, 0) 541 //! 542 //! \brief Sync surface 543 //! \details This function blocks until all pending operations on the render target 544 //! have been completed. Upon return it is safe to use the render target for a 545 //! different picture 546 //! \param [in] ctx 547 //! Pointer to VA driver context 548 //! \param [in] surface_id 549 //! VA render target surface id 550 //! \param [in] timeout_ns 551 //! time out period 552 //! 553 //! \return VAStatus 554 //! VA_STATUS_SUCCESS if success, else fail reason 555 //! 556 static VAStatus SyncSurface2 ( 557 VADriverContextP ctx, 558 VASurfaceID surface_id, 559 uint64_t timeout_ns 560 ); 561 562 //! 563 //! \brief Sync buffer 564 //! \details This function blocks until all pending operations on the render target 565 //! have been completed. Upon return it is safe to use the render target for a 566 //! different picture 567 //! \param [in] ctx 568 //! Pointer to VA driver context 569 //! \param [in] buf_id 570 //! VA buffer id 571 //! \param [in] timeout_ns 572 //! time out period 573 //! 574 //! \return VAStatus 575 //! VA_STATUS_SUCCESS if success, else fail reason 576 //! 577 static VAStatus SyncBuffer ( 578 VADriverContextP ctx, 579 VABufferID buf_id, 580 uint64_t timeout_ns 581 ); 582 #endif 583 584 //! 585 //! \brief Query surface status 586 //! 587 //! \param [in] ctx 588 //! Pointer to VA driver context 589 //! \param [in] render_target 590 //! VA surface ID 591 //! \param [out] status 592 //! VA surface status 593 //! 594 //! \return VAStatus 595 //! VA_STATUS_SUCCESS if success, else fail reason 596 //! 597 static VAStatus QuerySurfaceStatus ( 598 VADriverContextP ctx, 599 VASurfaceID render_target, 600 VASurfaceStatus *status 601 ); 602 603 //! 604 //! \brief Report MB error info 605 //! 606 //! \param [in] ctx 607 //! Pointer to VA driver context 608 //! \param [in] render_target 609 //! VA surface ID 610 //! \param [in] error_status 611 //! Error status 612 //! \param [out] error_info 613 //! Information on error 614 //! 615 //! \return VAStatus 616 //! VA_STATUS_SUCCESS if success, else fail reason 617 //! 618 static VAStatus QuerySurfaceError ( 619 VADriverContextP ctx, 620 VASurfaceID render_target, 621 VAStatus error_status, 622 void **error_info 623 ); 624 625 //! 626 //! \brief Query surface attributes for the supplied config 627 //! 628 //! \param [in] ctx 629 //! Pointer to VA driver context 630 //! \param [in] config_id 631 //! VA config id 632 //! \param [out] attrib_list 633 //! VA surface attrib 634 //! \param [out] num_attribs 635 //! Number of attribs 636 //! 637 //! \return VAStatus 638 //! VA_STATUS_SUCCESS if success, else fail reason 639 //! 640 static VAStatus QuerySurfaceAttributes ( 641 VADriverContextP ctx, 642 VAConfigID config_id, 643 VASurfaceAttrib *attrib_list, 644 uint32_t *num_attribs 645 ); 646 647 //! 648 //! \brief Put surface 649 //! 650 //! \param [in] ctx 651 //! Pointer to VA driver context 652 //! \param [in] surface 653 //! VA surface ID 654 //! \param [in] draw 655 //! Drawable of window system 656 //! \param [in] srcx 657 //! X offset of src image 658 //! \param [in] srcy 659 //! Y offset of src image 660 //! \param [in] srcw 661 //! Width offset of src image 662 //! \param [in] srch 663 //! Height offset of src image 664 //! \param [in] destx 665 //! X offset of dst image 666 //! \param [in] desty 667 //! Y offset of dst image 668 //! \param [in] destw 669 //! Width offset of dst image 670 //! \param [in] desth 671 //! Height offset of dst image 672 //! \param [in] cliprects 673 //! Client supplied clip list 674 //! \param [in] number_cliprects 675 //! Number of clip rects in the clip list 676 //! \param [in] flags 677 //! de-interlacing flags 678 //! 679 //! \return VAStatus 680 //! VA_STATUS_SUCCESS if success, else fail reason 681 //! 682 static VAStatus PutSurface ( 683 VADriverContextP ctx, 684 VASurfaceID surface, 685 void* draw, 686 int16_t srcx, 687 int16_t srcy, 688 uint16_t srcw, 689 uint16_t srch, 690 int16_t destx, 691 int16_t desty, 692 uint16_t destw, 693 uint16_t desth, 694 VARectangle *cliprects, 695 uint32_t number_cliprects, 696 uint32_t flags 697 ); 698 699 //! 700 //! \brief Query supported image formats 701 //! \details The caller must provide a "format_list" array that can hold at 702 //! least vaMaxNumImageFormats() entries. The actual number of formats 703 //! returned in "format_list" is returned in "num_formats" 704 //! 705 //! \param [in] ctx 706 //! Driver context 707 //! \param [out] format_list 708 //! The format of image 709 //! \param [out] num_formats 710 //! The number of the formats 711 //! 712 //! \return VAStatus 713 //! VA_STATUS_SUCCESS if success, else fail reason 714 //! 715 static VAStatus QueryImageFormats ( 716 VADriverContextP ctx, 717 VAImageFormat *format_list, 718 int32_t *num_formats 719 ); 720 721 //! 722 //! \brief Create an image 723 //! 724 //! \param [in] ctx 725 //! Driver context 726 //! \param [in] format 727 //! The format of image 728 //! \param [in] width 729 //! The width of the image 730 //! \param [in] height 731 //! The height of the image 732 //! \param [out] image 733 //! The generated image 734 //! 735 //! \return VAStatus 736 //! VA_STATUS_SUCCESS if success, else fail reason 737 //! 738 static VAStatus CreateImage ( 739 VADriverContextP ctx, 740 VAImageFormat *format, 741 int32_t width, 742 int32_t height, 743 VAImage *image 744 ); 745 746 //! 747 //! \brief Derive image 748 //! 749 //! \param [in] ctx 750 //! Pointer to VA driver context 751 //! \param [in] surface 752 //! VA surface ID 753 //! \param [in] image 754 //! VA image 755 //! 756 //! \return VAStatus 757 //! VA_STATUS_SUCCESS if success, else fail reason 758 //! 759 static VAStatus DeriveImage ( 760 VADriverContextP ctx, 761 VASurfaceID surface, 762 VAImage *image 763 ); 764 765 //! 766 //! \brief Free allocated surfaceheap elements 767 //! 768 //! \param [in] ctx 769 //! Pointer to VA driver context 770 //! \param [in] image 771 //! VA image ID 772 //! 773 //! \return VAStatus 774 //! VA_STATUS_SUCCESS if success, else fail reason 775 //! 776 static VAStatus DestroyImage ( 777 VADriverContextP ctx, 778 VAImageID image 779 ); 780 781 //! 782 //! \brief Retrive surface data into a VAImage 783 //! \details Image must be in a format supported by the implementation 784 //! 785 //! \param [in] ctx 786 //! Input driver context 787 //! \param [in] surface 788 //! Input surface ID of source 789 //! \param [in] x 790 //! X offset of the wanted region 791 //! \param [in] y 792 //! Y offset of the wanted region 793 //! \param [in] width 794 //! Width of the wanted region 795 //! \param [in] height 796 //! Height of the wanted region 797 //! \param [in] image 798 //! The image ID of the source image 799 //! 800 //! \return VAStatus 801 //! VA_STATUS_SUCCESS if success, else fail reason 802 //! 803 static VAStatus GetImage ( 804 VADriverContextP ctx, 805 VASurfaceID surface, 806 int32_t x, 807 int32_t y, 808 uint32_t width, 809 uint32_t height, 810 VAImageID image 811 ); 812 813 //! 814 //! \brief Copy data from a VAImage to a surface 815 //! \details Image must be in a format supported by the implementation 816 //! 817 //! \param [in] ctx 818 //! Input driver context 819 //! \param [in] surface 820 //! Surface ID of destination 821 //! \param [in] image 822 //! The image ID of the destination image 823 //! \param [in] src_x 824 //! Source x offset of the image region 825 //! \param [in] src_y 826 //! Source y offset of the image region 827 //! \param [in] src_width 828 //! Source width offset of the image region 829 //! \param [in] src_height 830 //! Source height offset of the image region 831 //! \param [in] dest_x 832 //! Destination x offset of the surface region 833 //! \param [in] dest_y 834 //! Destination y offset of the surface region 835 //! \param [in] dest_width 836 //! Destination width offset of the surface region 837 //! \param [in] dest_height 838 //! Destination height offset of the surface region 839 //! 840 //! \return VAStatus 841 //! VA_STATUS_SUCCESS if success, else fail reason 842 //! 843 static VAStatus PutImage ( 844 VADriverContextP ctx, 845 VASurfaceID surface, 846 VAImageID image, 847 int32_t src_x, 848 int32_t src_y, 849 uint32_t src_width, 850 uint32_t src_height, 851 int32_t dest_x, 852 int32_t dest_y, 853 uint32_t dest_width, 854 uint32_t dest_height 855 ); 856 857 //! 858 //! \brief Query display attributes 859 //! 860 //! \param [in] ctx 861 //! Pointer to VA driver context 862 //! \param [in] attr_list 863 //! VA display attribute 864 //! \param [in] num_attributes 865 //! Number of attributes 866 //! 867 //! \return VAStatus 868 //! VA_STATUS_SUCCESS if success, else fail reason 869 //! 870 static VAStatus QueryDisplayAttributes ( 871 VADriverContextP ctx, 872 VADisplayAttribute *attr_list, 873 int32_t *num_attributes 874 ); 875 876 //! 877 //! \brief Get display attributes 878 //! \details This function returns the current attribute values in "attr_list". 879 //! Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field 880 //! from vaQueryDisplayAttributes() can have their values retrieved. 881 //! 882 //! \param [in] ctx 883 //! Pointer to VA driver context 884 //! \param [in] attr_list 885 //! VA display attribute 886 //! \param [in] num_attributes 887 //! Number of attributes 888 //! 889 //! \return VAStatus 890 //! VA_STATUS_ERROR_UNIMPLEMENTED 891 //! 892 static VAStatus GetDisplayAttributes ( 893 VADriverContextP ctx, 894 VADisplayAttribute *attr_list, 895 int32_t num_attributes 896 ); 897 898 //! 899 //! \brief Query processing rate 900 //! 901 //! \param [in] ctx 902 //! Pointer to VA driver context 903 //! \param [in] config_id 904 //! VA configuration ID 905 //! \param [in] proc_buf 906 //! VA processing rate parameter 907 //! \param [out] processing_rate 908 //! Processing rate 909 //! 910 //! \return VAStatus 911 //! VA_STATUS_SUCCESS if success, else fail reason 912 //! 913 static VAStatus QueryProcessingRate ( 914 VADriverContextP ctx, 915 VAConfigID config_id, 916 VAProcessingRateParameter *proc_buf, 917 uint32_t *processing_rate 918 ); 919 920 #if VA_CHECK_VERSION(1,10,0) 921 //! 922 //! \brief media copy 923 //! 924 //! \param [in] ctx 925 //! Pointer to VA driver context 926 //! \param [in] dst_obj 927 //! VA copy object dst. 928 //! \param [in] src_obj 929 //! VA copy object src. 930 //! \param [in] option 931 //! VA copy option, copy mode. 932 //! \param [in] sync_handle 933 //! VA copy sync handle 934 //! 935 //! \return VAStatus 936 //! VA_STATUS_SUCCESS if success, else fail reason 937 //! 938 static VAStatus Copy ( 939 VADriverContextP ctx, 940 VACopyObject *dst_obj, 941 VACopyObject *src_obj, 942 VACopyOption option 943 ); 944 #endif 945 946 //! 947 //! \brief Check for buffer info 948 //! 949 //! \param [in] ctx 950 //! Pointer to VA driver context 951 //! \param [in] buf_id 952 //! VA buffer ID 953 //! \param [out] type 954 //! VA buffer type 955 //! \param [out] size 956 //! Size 957 //! \param [out] num_elements 958 //! Number of elements 959 //! 960 //! \return VAStatus 961 //! VA_STATUS_SUCCESS if success, else fail reason 962 //! 963 static VAStatus BufferInfo ( 964 VADriverContextP ctx, 965 VABufferID buf_id, 966 VABufferType *type, 967 uint32_t *size, 968 uint32_t *num_elements 969 ); 970 971 //! 972 //! \brief Lock surface 973 //! 974 //! \param [in] ctx 975 //! Pointer to VA driver context 976 //! \param [in] surface 977 //! VA surface ID 978 //! \param [out] fourcc 979 //! FourCC 980 //! \param [out] luma_stride 981 //! Luma stride 982 //! \param [out] chroma_u_stride 983 //! Chroma U stride 984 //! \param [out] chroma_v_stride 985 //! Chroma V stride 986 //! \param [out] luma_offset 987 //! Luma offset 988 //! \param [out] chroma_u_offset 989 //! Chroma U offset 990 //! \param [out] chroma_v_offset 991 //! Chroma V offset 992 //! \param [out] buffer_name 993 //! Buffer name 994 //! \param [out] buffer 995 //! Buffer 996 //! 997 //! \return VAStatus 998 //! VA_STATUS_SUCCESS if success, else fail reason 999 //! 1000 static VAStatus LockSurface ( 1001 VADriverContextP ctx, 1002 VASurfaceID surface, 1003 uint32_t *fourcc, 1004 uint32_t *luma_stride, 1005 uint32_t *chroma_u_stride, 1006 uint32_t *chroma_v_stride, 1007 uint32_t *luma_offset, 1008 uint32_t *chroma_u_offset, 1009 uint32_t *chroma_v_offset, 1010 uint32_t *buffer_name, 1011 void **buffer 1012 ); 1013 1014 //! 1015 //! \brief Unlock surface 1016 //! 1017 //! \param [in] ctx 1018 //! Pointer to VA driver context 1019 //! \param [in] surface 1020 //! VA surface ID 1021 //! 1022 //! \return VAStatus 1023 //! VA_STATUS_SUCCESS if success, else fail reason 1024 //! 1025 static VAStatus UnlockSurface ( 1026 VADriverContextP ctx, 1027 VASurfaceID surface 1028 ); 1029 1030 //! 1031 //! \brief Query video proc filters 1032 //! 1033 //! \param [in] ctx 1034 //! Pointer to VA driver context 1035 //! \param [in] context 1036 //! VA context ID 1037 //! \param [in] filters 1038 //! VA proc filter type 1039 //! \param [in] num_filters 1040 //! Number of filters 1041 //! 1042 //! \return VAStatus 1043 //! VA_STATUS_SUCCESS if success, else fail reason 1044 //! 1045 static VAStatus QueryVideoProcFilters ( 1046 VADriverContextP ctx, 1047 VAContextID context, 1048 VAProcFilterType *filters, 1049 uint32_t *num_filters 1050 ); 1051 1052 //! 1053 //! \brief Query video processing filter capabilities. 1054 //! The real implementation is in media_libva_vp.c, since it needs to use some definitions in vphal.h. 1055 //! 1056 //! \param [in] ctx 1057 //! Pointer to VA driver context 1058 //! \param [in] context 1059 //! VA context ID 1060 //! \param [in] type 1061 //! VA proc filter type 1062 //! \param [inout] filter_caps 1063 //! FIlter caps 1064 //! \param [inout] num_filter_caps 1065 //! Number of filter caps 1066 //! 1067 //! \return VAStatus 1068 //! VA_STATUS_SUCCESS if success, else fail reason 1069 //! 1070 static VAStatus QueryVideoProcFilterCaps ( 1071 VADriverContextP ctx, 1072 VAContextID context, 1073 VAProcFilterType type, 1074 void *filter_caps, 1075 uint32_t *num_filter_caps 1076 ); 1077 1078 //! 1079 //! \brief Query video proc pipeline caps 1080 //! 1081 //! \param [in] ctx 1082 //! Pointer to VA driver context 1083 //! \param [in] context 1084 //! VA context ID 1085 //! \param [in] filters 1086 //! VA buffer ID 1087 //! \param [in] num_filters 1088 //! Number of filters 1089 //! \param [in] pipeline_caps 1090 //! VA proc pipeline caps 1091 //! 1092 //! \return VAStatus 1093 //! VA_STATUS_SUCCESS if success, else fail reason 1094 //! 1095 static VAStatus QueryVideoProcPipelineCaps ( 1096 VADriverContextP ctx, 1097 VAContextID context, 1098 VABufferID *filters, 1099 uint32_t num_filters, 1100 VAProcPipelineCaps *pipeline_caps 1101 ); 1102 1103 #if VA_CHECK_VERSION(1,11,0) 1104 //! 1105 //! \brief Create protected session 1106 //! 1107 //! \param [in] ctx 1108 //! Pointer to VA driver context 1109 //! \param [in] configId 1110 //! VA configuration ID 1111 //! \param [out] protected_session 1112 //! VA protected session ID 1113 //! 1114 //! \return VAStatus 1115 //! VA_STATUS_SUCCESS if success, else fail reason 1116 //! 1117 static VAStatus CreateProtectedSession ( 1118 VADriverContextP ctx, 1119 VAConfigID config_id, 1120 VAProtectedSessionID *protected_session 1121 ); 1122 1123 //! 1124 //! \brief Destroy protected session 1125 //! 1126 //! \param [in] ctx 1127 //! Pointer to VA driver context 1128 //! \param [in] protected_session 1129 //! VA protected session ID 1130 //! 1131 //! \return VAStatus 1132 //! VA_STATUS_SUCCESS if success, else fail reason 1133 //! 1134 static VAStatus DestroyProtectedSession ( 1135 VADriverContextP ctx, 1136 VAProtectedSessionID protected_session 1137 ); 1138 1139 //! 1140 //! \brief Attach protected session to display or context 1141 //! 1142 //! \param [in] ctx 1143 //! Pointer to VA driver context 1144 //! \param [in] context 1145 //! VA context ID to be attached if not 0. 1146 //! \param [in] protected_session 1147 //! VA protected session ID 1148 //! 1149 //! \return VAStatus 1150 //! VA_STATUS_SUCCESS if success, else fail reason 1151 //! 1152 static VAStatus AttachProtectedSession ( 1153 VADriverContextP ctx, 1154 VAContextID context, 1155 VAProtectedSessionID protected_session 1156 ); 1157 1158 //! 1159 //! \brief Detach protected session from display or context 1160 //! 1161 //! \param [in] ctx 1162 //! Pointer to VA driver context 1163 //! \param [in] context 1164 //! VA context ID to be Detached if not 0. 1165 //! 1166 //! \return VAStatus 1167 //! VA_STATUS_SUCCESS if success, else fail reason 1168 //! 1169 static VAStatus DetachProtectedSession ( 1170 VADriverContextP ctx, 1171 VAContextID context 1172 ); 1173 1174 //! 1175 //! \brief TEE execution for the particular protected session 1176 //! 1177 //! \param [in] ctx 1178 //! Pointer to VA driver context 1179 //! \param [in] protected_session 1180 //! VA protected session ID 1181 //! \param [in] data 1182 //! VA buffer ID 1183 //! 1184 //! \return VAStatus 1185 //! VA_STATUS_SUCCESS if success, else fail reason 1186 //! 1187 static VAStatus ProtectedSessionExecute ( 1188 VADriverContextP ctx, 1189 VAProtectedSessionID protected_session, 1190 VABufferID data 1191 ); 1192 #endif 1193 1194 //! 1195 //! \brief Get surface attributes for the supplied config 1196 //! \details This function retrieves the surface attributes matching the supplied config. 1197 //! 1198 //! \param [in] ctx 1199 //! VA display 1200 //! \param [in] config 1201 //! Config identifying a codec or a video processing pipeline 1202 //! \param [out] attrib_list 1203 //! List of attributes on output 1204 //! \param [in] num_attributes 1205 //! Number of attributes 1206 //! 1207 //! \return VAStatus 1208 //! VA_STATUS_ERROR_UNIMPLEMENTED 1209 //! 1210 static VAStatus GetSurfaceAttributes ( 1211 VADriverContextP ctx, 1212 VAConfigID config, 1213 VASurfaceAttrib *attrib_list, 1214 uint32_t num_attribs 1215 ); 1216 1217 //! 1218 //! \brief Aquire buffer handle 1219 //! 1220 //! \param [in] ctx 1221 //! Pointer to VA driver context 1222 //! \param [in] buf_id 1223 //! VA buffer ID 1224 //! \param [in] buf_info 1225 //! VA buffer Info 1226 //! 1227 //! \return VAStatus 1228 //! VA_STATUS_SUCCESS if success, else fail reason 1229 //! 1230 static VAStatus AcquireBufferHandle ( 1231 VADriverContextP ctx, 1232 VABufferID buf_id, 1233 VABufferInfo *buf_info 1234 ); 1235 1236 //! 1237 //! \brief Release buffer handle 1238 //! 1239 //! \param [in] ctx 1240 //! Pointer to VA driver context 1241 //! \param [in] buf_id 1242 //! VA bufferID 1243 //! 1244 //! \return VAStatus 1245 //! VA_STATUS_SUCCESS if success, else fail reason 1246 //! 1247 static VAStatus ReleaseBufferHandle ( 1248 VADriverContextP ctx, 1249 VABufferID buf_id 1250 ); 1251 1252 //! 1253 //! \brief API for export surface handle to other component 1254 //! 1255 //! \param [in] dpy 1256 //! VA display. 1257 //! \param [in] surface_id 1258 //! Surface to export. 1259 //! \param [in] mem_type 1260 //! Memory type to export to. 1261 //! \param [in] flags 1262 //! Combination of flags to apply 1263 //! \param [out] descriptor 1264 //! Pointer to the descriptor structure to fill 1265 //! with the handle details. The type of this structure depends on 1266 //! the value of mem_type. 1267 //! \return VAStatus 1268 //! VA_STATUS_SUCCESS if success, else fail reason 1269 //! 1270 static VAStatus ExportSurfaceHandle ( 1271 VADriverContextP ctx, 1272 VASurfaceID surface_id, 1273 uint32_t mem_type, 1274 uint32_t flags, 1275 void *descriptor 1276 ); 1277 1278 #ifndef ANDROID 1279 //! 1280 //! \brief Create Mfe Context 1281 //! 1282 //! \param [in] ctx 1283 //! Pointer to VA driver context 1284 //! \param [out] mfe_context 1285 //! VA MF context ID 1286 //! 1287 //! \return VAStatus 1288 //! VA_STATUS_SUCCESS if success, else fail reason 1289 //! 1290 static VAStatus CreateMfeContextInternal ( 1291 VADriverContextP ctx, 1292 VAMFContextID *mfe_context 1293 ); 1294 1295 //! 1296 //! \brief Add context 1297 //! 1298 //! \param [in] ctx 1299 //! Pointer to VA driver context 1300 //! \param [in] contexts 1301 //! VA context ID 1302 //! \param [in] mfe_context 1303 //! VA MF context ID 1304 //! 1305 //! \return VAStatus 1306 //! VA_STATUS_SUCCESS if success, else fail reason 1307 //! 1308 static VAStatus AddContextInternal ( 1309 VADriverContextP ctx, 1310 VAContextID context, 1311 VAMFContextID mfe_context 1312 ); 1313 1314 //! 1315 //! \brief Release context 1316 //! 1317 //! \param [in] ctx 1318 //! Pointer to VA driver context 1319 //! \param [in] contexts 1320 //! VA context ID 1321 //! \param [in] mfe_context 1322 //! VA MF context ID 1323 //! 1324 //! \return VAStatus 1325 //! VA_STATUS_SUCCESS if success, else fail reason 1326 //! 1327 static VAStatus ReleaseContextInternal ( 1328 VADriverContextP ctx, 1329 VAContextID context, 1330 VAMFContextID mfe_context 1331 ); 1332 1333 //! 1334 //! \brief MFE submit 1335 //! 1336 //! \param [in] ctx 1337 //! Pointer to VA driver context 1338 //! \param [in] mfe_context 1339 //! VA MF context ID 1340 //! \param [in] contexts 1341 //! VA context ID 1342 //! \param [in] num_contexts 1343 //! Number of contexts 1344 //! 1345 //! \return VAStatus 1346 //! VA_STATUS_SUCCESS if success, else fail reason 1347 //! 1348 static VAStatus MfeSubmit ( 1349 VADriverContextP ctx, 1350 VAMFContextID mfe_context, 1351 VAContextID *contexts, 1352 int32_t num_contexts 1353 ); 1354 #endif 1355 1356 //! 1357 //! \brief Load DDI function pointer 1358 //! 1359 //! \param [in] ctx 1360 //! Pointer to VA driver context 1361 //! 1362 //! \return VAStatus 1363 //! VA_STATUS_SUCCESS if success, else fail reason 1364 //! 1365 static VAStatus LoadFunction(VADriverContextP ctx); 1366 1367 //! 1368 //! \brief Initialize 1369 //! 1370 //! \param [in] ctx 1371 //! Pointer to VA driver context 1372 //! \param [in] devicefd 1373 //! Devoce fd 1374 //! \param [out] major_version 1375 //! Major version 1376 //! \param [out] minor_version 1377 //! Minor version 1378 //! 1379 //! \return VAStatus 1380 //! VA_STATUS_SUCCESS if success, else fail reason 1381 //! 1382 static VAStatus InitMediaContext ( 1383 VADriverContextP ctx, 1384 int32_t devicefd, 1385 int32_t *major_version, 1386 int32_t *minor_version 1387 ); 1388 1389 }; 1390 1391 #endif //__MEDIA_LIBVA_INTERFACE_H__