1 /* 2 * Copyright (c) 2011-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 codechal_hw.h 24 //! \brief This modules implements HW interface layer to be used on all platforms on all operating systems/DDIs, across CODECHAL components. 25 //! 26 27 #ifndef __CODECHAL_HW_H__ 28 #define __CODECHAL_HW_H__ 29 30 #include "codechal.h" 31 #include "renderhal_legacy.h" 32 #include "mhw_mi.h" 33 #include "mhw_render_legacy.h" 34 #include "mhw_state_heap.h" 35 #include "mhw_vdbox.h" 36 #include "mhw_vebox.h" 37 #include "mhw_sfc.h" 38 #include "mhw_cp_interface.h" 39 #include "media_copy.h" 40 #include "media_blt_copy.h" 41 42 #include "mhw_vdbox_mfx_interface.h" 43 #include "mhw_vdbox_hcp_interface.h" 44 #include "mhw_vdbox_avp_interface.h" 45 #include "mhw_vdbox_huc_interface.h" 46 #include "mhw_vdbox_vdenc_interface.h" 47 #include "mhw_vdbox_hcp_itf.h" 48 49 #include "media_interfaces_mhw.h" 50 #include "media_sfc_interface.h" 51 52 #include "gfxmacro.h" 53 54 #include "codec_hw_next.h" 55 56 //------------------------------------------------------------------------------ 57 // Macros specific to MOS_CODEC_SUBCOMP_HW sub-comp 58 //------------------------------------------------------------------------------ 59 #define CODECHAL_HW_ASSERT(_expr) \ 60 MOS_ASSERT(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _expr) 61 62 #define CODECHAL_HW_ASSERTMESSAGE(_message, ...) \ 63 MOS_ASSERTMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _message, ##__VA_ARGS__) 64 65 #define CODECHAL_HW_NORMALMESSAGE(_message, ...) \ 66 MOS_NORMALMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _message, ##__VA_ARGS__) 67 68 #define CODECHAL_HW_VERBOSEMESSAGE(_message, ...) \ 69 MOS_VERBOSEMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _message, ##__VA_ARGS__) 70 71 #define CODECHAL_HW_FUNCTION_ENTER \ 72 MOS_FUNCTION_ENTER(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW) 73 74 #define CODECHAL_HW_CHK_STATUS(_stmt) \ 75 MOS_CHK_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _stmt) 76 77 #define CODECHAL_HW_CHK_STATUS_RETURN(_stmt) \ 78 MOS_CHK_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _stmt) 79 80 #define CODECHAL_HW_CHK_STATUS_MESSAGE(_stmt, _message, ...) \ 81 MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _stmt, _message, ##__VA_ARGS__) 82 83 #define CODECHAL_HW_CHK_NULL(_ptr) \ 84 MOS_CHK_NULL(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _ptr) 85 86 #define CODECHAL_HW_CHK_NULL_RETURN(_ptr) \ 87 MOS_CHK_NULL_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _ptr) 88 89 #define CODECHAL_HW_CHK_NULL_NO_STATUS(_ptr) \ 90 MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW, _ptr) 91 92 #define CODECHAL_HW_CHK_COND_RETURN(_expr, _message, ...) \ 93 MOS_CHK_COND_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_HW,_expr,_message, ##__VA_ARGS__) 94 95 #define CODECHAL_SURFACE_PITCH_ALIGNMENT 128 96 97 #define CODECHAL_MEDIA_WALKER_MAX_COLORS 16 // 4 Bits for color field gives max 16 colors 98 99 #define CODECHAL_VDIRECTION_FRAME 2 100 #define CODECHAL_VDIRECTION_TOP_FIELD 1 101 #define CODECHAL_VDIRECTION_BOT_FIELD 3 102 #define CODECHAL_VLINESTRIDE_FRAME 0 103 #define CODECHAL_VLINESTRIDE_FIELD 1 104 #define CODECHAL_VLINESTRIDEOFFSET_TOP_FIELD 0 105 #define CODECHAL_VLINESTRIDEOFFSET_BOT_FIELD 1 106 107 #define CODECHAL_MAX_DEPENDENCY_COUNT 8 108 109 #define CODECHAL_INVALID_BINDING_TABLE_IDX 0xFFFFFFFF 110 111 //! 112 //! \enum MoTargetCache 113 //! \brief Mo target cache 114 //! 115 enum MoTargetCache 116 { 117 CODECHAL_MO_TARGET_CACHE_ELLC = 0x0, 118 CODECHAL_MO_TARGET_CACHE_LLC = 0x1, 119 CODECHAL_MO_TARGET_CACHE_LLC_ELLC = 0x2, 120 CODECHAL_MO_TARGET_CACHE_L3_LLC_ELLC = 0x3 121 }; 122 123 //! 124 //! \enum CodechalCacheabilityType 125 //! \brief Codechal cacheability type 126 //! 127 enum CodechalCacheabilityType 128 { 129 codechalUncacheable = 0, 130 codechalLLC = 1, 131 codechalL3 = 2, 132 codechalUncacheableWa = 8 133 }; 134 135 //! 136 //! \enum CodechalWalkingPattern 137 //! \brief Codechal walking pattern 138 //! 139 enum CodechalWalkingPattern 140 { 141 codechalHorizontal26DegreeScan = 0, 142 codechalHorizontal45DegreeScan = 1, 143 codechalHorizontal26DegreeScanMbaff = 2, 144 codechalHorizontalRasterScan = 3, 145 codechalVerticalRasterScan = 4 146 }; 147 148 typedef enum _CODECHAL_SLICE_STATE 149 { 150 CODECHAL_SLICE_SHUTDOWN_DEFAULT = 0, 151 CODECHAL_SLICE_SHUTDOWN_ONE_SLICE = 1, 152 CODECHAL_SLICE_SHUTDOWN_TWO_SLICES = 2 153 } CODECHAL_SLICE_STATE; 154 155 //! 156 //! \struct CodechalQpStatusCount 157 //! \brief Codechal qp status count 158 //! 159 struct CodechalQpStatusCount 160 { 161 union{ 162 struct{ 163 uint32_t cumulativeQP : 24; 164 uint32_t cumulativeQPAdjust : 8; 165 }; 166 167 struct 168 { 169 // DW0 170 uint32_t hcpCumulativeQP : 24; 171 uint32_t : 8; 172 173 // DW1 174 uint32_t hcpFrameMinCUQp : 6; 175 uint32_t hcpFrameMaxCUQp : 6; 176 uint32_t : 20; 177 }; 178 179 struct 180 { 181 uint32_t value[2]; 182 }; 183 }; 184 }; 185 186 //! 187 //! \struct CodechalDataCopyParams 188 //! \brief Codechal data copy parameters 189 //! 190 struct CodechalDataCopyParams 191 { 192 // Src params 193 PMOS_RESOURCE srcResource; 194 uint32_t srcSize; 195 uint32_t srcOffset; 196 197 // Dst params 198 PMOS_RESOURCE dstResource; 199 uint32_t dstSize; 200 uint32_t dstOffset; 201 }; 202 203 //! 204 //! \struct BrcPakStatsReadParams 205 //! \brief Read brc pak states parameters 206 //! 207 struct BrcPakStatsReadParams 208 { 209 PMOS_RESOURCE presBrcPakStatisticBuffer; 210 uint32_t bitstreamBytecountFrameOffset; 211 uint32_t bitstreamBytecountFrameNoHeaderOffset; 212 uint32_t imageStatusCtrlOffset; 213 214 PMOS_RESOURCE presStatusBuffer; 215 uint32_t dwStatusBufNumPassesOffset; 216 uint8_t ucPass; 217 MOS_GPU_CONTEXT VideoContext; 218 }; 219 220 //! Codechal hw interface 221 /*! 222 This class defines the interfaces for hardware dependent settings and functions used in Codechal 223 */ 224 class CodechalHwInterface 225 { 226 protected: 227 // Slice Shutdown Threshold 228 static const uint32_t m_sliceShutdownAvcTargetUsageThreshold = 2; //!< slice shutdown AVC target usage threshold 229 static const uint32_t m_sliceShutdownAvcResolutionThreshold = 2073600; //!< slice shutdown AVC resolution threshold: 1080p - 1920x1080 230 static const uint32_t m_sliceShutdownMpeg2ResolutionThreshold = 8294400; //!< slice shutdown MPEG2 resolution threshold: 4K - 3840x2160 231 232 // States 233 PMOS_INTERFACE m_osInterface; //!< Pointer to OS interface 234 235 // Auxiliary 236 PLATFORM m_platform; //!< Platform information 237 MEDIA_FEATURE_TABLE *m_skuTable = nullptr; //!< Pointer to SKU table 238 MEDIA_WA_TABLE *m_waTable = nullptr; //!< Pointer to WA table 239 240 MHW_STATE_HEAP_SETTINGS m_stateHeapSettings; //!< State heap Mhw settings 241 MhwMiInterface *m_miInterface = nullptr; //!< Pointer to Mhw mi interface 242 MhwCpInterface *m_cpInterface = nullptr; //!< Pointer to Mhw cp interface 243 MhwRenderInterface *m_renderInterface = nullptr; //!< Pointer to Mhw render interface 244 RENDERHAL_INTERFACE *m_renderHal = nullptr; //!< RenderHal interface 245 MhwCpInterface *m_renderHalCpInterface = nullptr;//!< Pointer to RenderHal cp interface 246 MhwVeboxInterface *m_veboxInterface = nullptr; //!< Pointer to Mhw vebox interface 247 MhwSfcInterface *m_sfcInterface = nullptr; //!< Pointer to Mhw sfc interface 248 MhwVdboxMfxInterface *m_mfxInterface = nullptr; //!< Pointer to Mhw mfx interface 249 MhwVdboxHcpInterface *m_hcpInterface = nullptr; //!< Pointer to Mhw hcp interface 250 MhwVdboxAvpInterface *m_avpInterface = nullptr; //!< Pointer to Mhw avp interface 251 MhwVdboxHucInterface *m_hucInterface = nullptr; //!< Pointer to Mhw huc interface 252 MhwVdboxVdencInterface *m_vdencInterface = nullptr; //!< Pointer to Mhw vdenc interface 253 std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpItf = nullptr; 254 std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencItf = nullptr; 255 std::shared_ptr<MediaSfcInterface> m_mediaSfcItf = nullptr; 256 std::shared_ptr<mhw::render::Itf> m_renderItf = nullptr; 257 258 CODECHAL_SSEU_SETTING const *m_ssEuTable = nullptr; //!< Pointer to the default SSEU settings table 259 uint16_t m_numMediaStates = CODECHAL_NUM_MEDIA_STATES; //!< number of media states 260 261 MHW_MEMORY_OBJECT_CONTROL_PARAMS m_cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC]; //!< Cacheability Settings list 262 263 // HuC WA implementation 264 MOS_RESOURCE m_dummyStreamIn; //!> Resource of dummy stream in 265 MOS_RESOURCE m_dummyStreamOut; //!> Resource of dummy stream out 266 MOS_RESOURCE m_hucDmemDummy; //!> Resource of Huc DMEM for dummy streamout WA 267 uint32_t m_dmemBufSize = 0; //!> 268 269 // COND BBE WA 270 MOS_RESOURCE m_conditionalBbEndDummy; //!> Dummy Resource for conditional batch buffer end WA 271 272 uint32_t m_maxKernelLoadCmdSize = 0; //!> Max kernel load cmd size 273 bool m_checkTargetCache = false; //!> Used to check L3 cache enable 274 bool m_checkBankCount = false; //!> Used to check L3 cache enable 275 276 uint32_t m_sizeOfCmdMediaObject = 0; //!> Size of media object cmd 277 uint32_t m_sizeOfCmdMediaStateFlush = 0; //!> Size of media state flush cmd 278 279 bool m_noSeparateL3LlcCacheabilitySettings = false; // No separate L3 LLC cacheability settings 280 281 bool m_disableScalability = false; //!> Flag to indicate if disable scalability by default 282 283 public: 284 // Hardware dependent parameters 285 bool m_turboMode = false; //!> Turbo mode info to pass in cmdBuf 286 bool m_isVdencSuperSliceEnabled = false; //!> Flag indicating Vdenc super slice is enabled 287 bool m_noHuC = false; //!> This flag to indicate HuC present on Linux 288 uint16_t m_sizeOfCmdBatchBufferEnd = 0; //!> Size of batch buffer end cmd 289 uint16_t m_sizeOfCmdMediaReset = 0; //!> Size of media reset cmd 290 uint32_t m_vdencBrcImgStateBufferSize = 0; //!> vdenc brc img state buffer size 291 uint32_t m_vdencBatchBuffer1stGroupSize = 0; //!> vdenc batch buffer 1st group size 292 uint32_t m_vdencBatchBuffer2ndGroupSize = 0; //!> vdenc batch buffer 2nd group size 293 uint32_t m_vdencReadBatchBufferSize = 0; //!> vdenc read batch buffer size for group1 and group2 294 uint32_t m_vdencGroup3BatchBufferSize = 0; //!> vdenc read batch buffer size for group3 295 uint32_t m_vdencCopyBatchBufferSize = 0; //!> vdenc copy batch buffer size 296 uint32_t m_vdenc2ndLevelBatchBufferSize = 0; //!> vdenc 2nd level batch buffer size 297 uint32_t m_vdencBatchBufferPerSliceConstSize = 0; //!> vdenc batch buffer per slice const size 298 uint32_t m_HucStitchCmdBatchBufferSize = 0; //!> huc stitch cmd 2nd level batch buffer size 299 uint32_t m_mpeg2BrcConstantSurfaceWidth = 64; //!> mpeg2 brc constant surface width 300 uint32_t m_mpeg2BrcConstantSurfaceHeight = 43; //!> mpeg2 brc constant surface height 301 uint32_t m_avcMbStatBufferSize = 0; //!> AVC Mb status buffer size 302 uint32_t m_pakIntTileStatsSize = 0; //!> Size of combined statistics across all tiles 303 uint32_t m_pakIntAggregatedFrameStatsSize = 0; //!> Size of HEVC/ VP9 PAK Stats, HEVC Slice Streamout, VDEnc Stats 304 uint32_t m_tileRecordSize = 0; //!> Tile record size 305 uint32_t m_hucCommandBufferSize = 0; //!> Size of a single HuC command buffer 306 307 // Slice/Sub-slice/EU Shutdown Parameters 308 uint32_t m_numRequestedEuSlices = 0; //!> Number of requested Slices 309 uint32_t m_numRequestedSubSlices = 0; //!> Number of requested Sub-slices 310 uint32_t m_numRequestedEus = 0; //!> Number of requested EUs 311 #if (_DEBUG || _RELEASE_INTERNAL) 312 bool m_numRequestedOverride = false; //!> Flag to indicate whether these params are set by Reg 313 uint32_t m_numRequestedEuSlicesOverride = 0; //!> Number of requested Slices set by Reg 314 uint32_t m_numRequestedSubSlicesOverride = 0; //!> Number of requested Sub-slices set by Reg 315 uint32_t m_numRequestedEusOverride = 0; //!> Number of requested EUs set by Reg 316 #endif 317 318 uint32_t m_ssdResolutionThreshold = 0; //!> Slice shutdown resolution threshold 319 uint32_t m_ssdTargetUsageThreshold = 0; //!> Slice shutdown target usage threshold 320 uint32_t m_mpeg2SSDResolutionThreshold = 0; //!> Slice shutdown resolution threshold for MPEG2 321 322 bool m_slicePowerGate = false; //!> Slice power gate 323 324 bool m_enableCodecMmc = false; //!> Flag to indicate if enable codec MMC by default or not 325 326 //! 327 //! \brief Constructor 328 //! 329 CodechalHwInterface( 330 PMOS_INTERFACE osInterface, 331 CODECHAL_FUNCTION codecFunction, 332 MhwInterfaces *mhwInterfaces, 333 bool disableScalability = false); 334 335 static CodechalHwInterface *Create( 336 PMOS_INTERFACE osInterface, 337 CODECHAL_FUNCTION codecFunction, 338 MhwInterfaces *mhwInterfaces, 339 bool disableScalability); 340 341 //! 342 //! \brief Get avp interface 343 //! \details Get avp interface in codechal hw interface next 344 //! 345 //! \return pointer to new AVP interface 346 //! GetAvpInterfaceNext()347 inline std::shared_ptr<mhw::vdbox::avp::Itf> GetAvpInterfaceNext() 348 { 349 if (m_hwInterfaceNext) 350 { 351 return m_hwInterfaceNext->GetAvpInterfaceNext(); 352 } 353 else 354 { 355 return nullptr; 356 } 357 } 358 359 //! 360 //! \brief Get vdenc interface 361 //! \details Get vdenc interface in codechal hw interface next 362 //! 363 //! \return pointer to new Vdenc interface 364 //! GetVdencInterfaceNext()365 inline std::shared_ptr<mhw::vdbox::vdenc::Itf> GetVdencInterfaceNext() 366 { 367 if (m_hwInterfaceNext) 368 { 369 return m_hwInterfaceNext->GetVdencInterfaceNext(); 370 } 371 else 372 { 373 return nullptr; 374 } 375 } 376 377 //! \brief Get huc interface 378 //! \details Get huc interface in codechal hw interface next 379 //! 380 //! \return pointer to new HUC interface 381 //! GetHucInterfaceNext()382 inline std::shared_ptr<mhw::vdbox::huc::Itf> GetHucInterfaceNext() 383 { 384 if (m_hwInterfaceNext) 385 { 386 return m_hwInterfaceNext->GetHucInterfaceNext(); 387 } 388 else 389 { 390 return nullptr; 391 } 392 } 393 394 //! 395 //! \brief Get mi interface 396 //! \details Get mi interface in codechal hw interface next 397 //! 398 //! \return pointer to new MI interface 399 //! GetMiInterfaceNext()400 inline std::shared_ptr<mhw::mi::Itf> GetMiInterfaceNext() 401 { 402 if (m_hwInterfaceNext) 403 { 404 return m_hwInterfaceNext->GetMiInterfaceNext(); 405 } 406 else 407 { 408 return nullptr; 409 } 410 } 411 412 //! 413 //! \brief Get hcp interface 414 //! \details Get hcp interface in codechal hw interface next 415 //! 416 //! \return pointer to new HCP interface 417 //! GetHcpInterfaceNext()418 inline std::shared_ptr<mhw::vdbox::hcp::Itf> GetHcpInterfaceNext() 419 { 420 if (m_hwInterfaceNext) 421 { 422 return m_hwInterfaceNext->GetHcpInterfaceNext(); 423 } 424 else 425 { 426 return nullptr; 427 } 428 } 429 430 //! 431 //! \brief Get mfx interface 432 //! \details Get mfx interface in codechal hw interface next 433 //! 434 //! \return pointer to new MFX interface 435 //! GetMfxInterfaceNext()436 inline std::shared_ptr<mhw::vdbox::mfx::Itf> GetMfxInterfaceNext() 437 { 438 if (m_hwInterfaceNext) 439 { 440 return m_hwInterfaceNext->GetMfxInterfaceNext(); 441 } 442 else 443 { 444 return nullptr; 445 } 446 } 447 //! 448 //! \brief Get render interface 449 //! \details Get render interface in codechal hw interface next 450 //! 451 //! \return pointer to new HCP interface 452 //! GetRenderInterfaceNext()453 inline std::shared_ptr<mhw::render::Itf> GetRenderInterfaceNext() 454 { 455 if (m_hwInterfaceNext) 456 { 457 return m_hwInterfaceNext->GetRenderInterfaceNext(); 458 } 459 else 460 { 461 return nullptr; 462 } 463 } 464 //! 465 //! \brief Copy constructor 466 //! 467 CodechalHwInterface(const CodechalHwInterface&) = delete; 468 469 //! 470 //! \brief Copy assignment operator 471 //! 472 CodechalHwInterface& operator=(const CodechalHwInterface&) = delete; 473 474 //! 475 //! \brief Destructor 476 //! ~CodechalHwInterface()477 virtual ~CodechalHwInterface() 478 { 479 CODECHAL_HW_FUNCTION_ENTER; 480 481 if (MEDIA_IS_WA(m_waTable, WaHucStreamoutEnable) && m_osInterface) 482 { 483 m_osInterface->pfnFreeResource( 484 m_osInterface, 485 &m_hucDmemDummy); 486 m_osInterface->pfnFreeResource( 487 m_osInterface, 488 &m_dummyStreamIn); 489 m_osInterface->pfnFreeResource( 490 m_osInterface, 491 &m_dummyStreamOut); 492 } 493 494 if (m_osInterface) 495 { 496 m_osInterface->pfnFreeResource(m_osInterface, &m_conditionalBbEndDummy); 497 498 m_osInterface->pfnDeleteMhwCpInterface(m_cpInterface); 499 m_cpInterface = nullptr; 500 } 501 502 if (m_miInterface) 503 { 504 MOS_Delete(m_miInterface); 505 m_miInterface = nullptr; 506 } 507 508 if (m_renderInterface) 509 { 510 MOS_Delete(m_renderInterface); 511 m_renderInterface = nullptr; 512 } 513 514 if (m_veboxInterface) 515 { 516 m_veboxInterface->DestroyHeap(); 517 MOS_Delete(m_veboxInterface); 518 m_veboxInterface = nullptr; 519 } 520 521 if (m_mfxInterface) 522 { 523 MOS_Delete(m_mfxInterface); 524 m_mfxInterface = nullptr; 525 } 526 if (m_hcpInterface) 527 { 528 MOS_Delete(m_hcpInterface); 529 m_hcpInterface = nullptr; 530 } 531 if (m_hucInterface) 532 { 533 MOS_Delete(m_hucInterface); 534 m_hucInterface = nullptr; 535 } 536 if (m_vdencInterface) 537 { 538 MOS_Delete(m_vdencInterface); 539 m_vdencInterface = nullptr; 540 } 541 542 if (m_sfcInterface) 543 { 544 MOS_Delete(m_sfcInterface); 545 m_sfcInterface = nullptr; 546 } 547 548 if (m_hwInterfaceNext) 549 { 550 MOS_Delete(m_hwInterfaceNext); 551 m_hwInterfaceNext = nullptr; 552 } 553 554 #if MHW_HWCMDPARSER_ENABLED 555 mhw::HwcmdParser::DestroyInstance(); 556 #endif 557 } 558 559 //! 560 //! \brief Get Os interface 561 //! \details Get Os interface in codechal hw interface 562 //! 563 //! \return [out] PMOS_INTERFACE 564 //! Interface got. 565 //! GetOsInterface()566 inline PMOS_INTERFACE GetOsInterface() 567 { 568 return m_osInterface; 569 } 570 GetMediaSfcInterface()571 inline std::shared_ptr<MediaSfcInterface> GetMediaSfcInterface() 572 { 573 return m_mediaSfcItf; 574 } 575 576 //! 577 //! \brief Get State Heap Settings 578 //! \details Get State Heap Settings in codechal hw interface 579 //! 580 //! \return [out] MHW_STATE_HEAP_SETTINGS* 581 //! Settings got. 582 //! GetStateHeapSettings()583 inline MHW_STATE_HEAP_SETTINGS *GetStateHeapSettings() 584 { 585 return &m_stateHeapSettings; 586 } 587 588 //! 589 //! \brief Get mi interface 590 //! \details Get mi interface in codechal hw interface 591 //! 592 //! \return [out] MhwMiInterface* 593 //! Interface got. 594 //! GetMiInterface()595 inline MhwMiInterface *GetMiInterface() 596 { 597 return m_miInterface; 598 } 599 600 //! 601 //! \brief Get cp interface 602 //! \details Get cp interface in codechal hw interface 603 //! 604 //! \return [out] MhwCpInterface* 605 //! Interface got. 606 //! GetCpInterface()607 inline MhwCpInterface *GetCpInterface() 608 { 609 return m_cpInterface; 610 } 611 612 //! 613 //! \brief Get render interface 614 //! \details Get render interface in codechal hw interface 615 //! 616 //! \return [out] MhwRenderInterface* 617 //! Interface got. 618 //! GetRenderInterface()619 inline MhwRenderInterface *GetRenderInterface() 620 { 621 return m_renderInterface; 622 } 623 624 //! 625 //! \brief Get renderHal interface 626 //! \details Get renderHal interface in codechal hw interface 627 //! 628 //! \return [out] RENDERHAL_INTERFACE* 629 //! Interface got. 630 //! GetRenderHalInterface()631 inline RENDERHAL_INTERFACE *GetRenderHalInterface() 632 { 633 return m_renderHal; 634 } 635 636 //! 637 //! \brief Get vebox interface 638 //! \details Get vebox interface in codechal hw interface 639 //! 640 //! \return [out] MhwVeboxInterface* 641 //! Interface got. 642 //! GetVeboxInterface()643 inline MhwVeboxInterface *GetVeboxInterface() 644 { 645 return m_veboxInterface; 646 } 647 648 //! 649 //! \brief Get SFC interface 650 //! \details Get SFC interface in codechal hw interface 651 //! 652 //! \return [out] MhwSfcInterface* 653 //! Interface got. 654 //! GetSfcInterface()655 inline MhwSfcInterface *GetSfcInterface() 656 { 657 return m_sfcInterface; 658 } 659 660 //! 661 //! \brief Get mfx interface 662 //! \details Get mfx interface in codechal hw interface 663 //! 664 //! \return [out] MhwVdboxMfxInterface* 665 //! Interface got. 666 //! GetMfxInterface()667 inline MhwVdboxMfxInterface *GetMfxInterface() 668 { 669 return m_mfxInterface; 670 } 671 672 //! 673 //! \brief Get hcp interface 674 //! \details Get hcp interface in codechal hw interface 675 //! 676 //! \return [out] MhwVdboxHcpInterface* 677 //! Interface got. 678 //! GetHcpInterface()679 inline MhwVdboxHcpInterface *GetHcpInterface() 680 { 681 return m_hcpInterface; 682 } 683 684 //! 685 //! \brief Get avp interface 686 //! \details Get avp interface in codechal hw interface 687 //! 688 //! \return [out] MhwVdboxAvpInterface* 689 //! Interface got. 690 //! GetAvpInterface()691 MhwVdboxAvpInterface *GetAvpInterface() 692 { 693 return m_avpInterface; 694 } 695 696 //! 697 //! \brief Get huc interface 698 //! \details Get huc interface in codechal hw interface 699 //! 700 //! \return [out] MhwVdboxHucInterface* 701 //! Interface got. 702 //! GetHucInterface()703 inline MhwVdboxHucInterface *GetHucInterface() 704 { 705 return m_hucInterface; 706 } 707 708 //! 709 //! \brief Get vdenc interface 710 //! \details Get vdenc interface in codechal hw interface 711 //! 712 //! \return [out] MhwVdboxVdencInterface* 713 //! Interface got. 714 //! GetVdencInterface()715 inline MhwVdboxVdencInterface *GetVdencInterface() 716 { 717 return m_vdencInterface; 718 } 719 720 //! 721 //! \brief Get platform 722 //! \details Get platform in codechal hw interface 723 //! 724 //! \return [out] PLATFORM 725 //! Platform got. 726 //! GetPlatform()727 inline PLATFORM GetPlatform() 728 { 729 return m_platform; 730 } 731 732 //! 733 //! \brief Get Sku table 734 //! \details Get Sku table in codechal hw interface 735 //! 736 //! \return [out] MEDIA_FEATURE_TABLE * 737 //! Sku table got. 738 //! GetSkuTable()739 inline MEDIA_FEATURE_TABLE *GetSkuTable() 740 { 741 return m_skuTable; 742 } 743 744 //! 745 //! \brief Get Wa table 746 //! \details Get Wa table in codechal hw interface 747 //! 748 //! \return [out] MEDIA_WA_TABLE 749 //! Wa table got. 750 //! GetWaTable()751 inline MEDIA_WA_TABLE *GetWaTable() 752 { 753 return m_waTable; 754 } 755 756 //! 757 //! \brief Get Cacheability Settings 758 //! \details Get Cacheability Settings in codechal hw interface 759 //! 760 //! \return [out] MHW_MEMORY_OBJECT_CONTROL_PARAMS* 761 //! Cachebility Settings got. 762 //! GetCacheabilitySettings()763 inline MHW_MEMORY_OBJECT_CONTROL_PARAMS *GetCacheabilitySettings() 764 { 765 return m_cacheabilitySettings; 766 } 767 768 //! \brief Create media copy 769 //! \details Create media copy instance. 770 //! \param osInterface 771 //! [in] Pointer to MOS_INTERFACE. 772 //! \return MediaCopyBaseState* 773 //! Pointer to MediaCopyBaseState 774 //! CreateMediaCopy(PMOS_INTERFACE mosInterface)775 virtual MediaCopyBaseState* CreateMediaCopy(PMOS_INTERFACE mosInterface) 776 { 777 return nullptr; 778 } 779 780 //! \brief Get blt state 781 //! \details Get blt interface in codechal hw interface 782 //! 783 //! \return [out] BltState* 784 //! Interface got. 785 //! GetBltState()786 virtual BltState *GetBltState() 787 { 788 return nullptr; 789 } 790 791 //! 792 //! \brief Set Cacheability Settings 793 //! \details Set Cacheability Settings in sub interfaces in codechal hw interface 794 //! 795 //! \param [in] cacheabilitySettings 796 //! cacheability Settings to set into sub mhw intefaces in hw interface 797 //! 798 //! \return MOS_STATUS 799 //! MOS_STATUS_SUCCESS if success, else fail reason 800 //! 801 virtual MOS_STATUS SetCacheabilitySettings( 802 MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC]); 803 804 //! 805 //! \brief Set Rowstore Cache offsets 806 //! \details Set Rowstore Cache offsets in sub interfaces in codechal hw interface 807 //! 808 //! \param [in] rowstoreParams 809 //! parameters to set rowstore cache offsets 810 //! 811 //! \return MOS_STATUS 812 //! MOS_STATUS_SUCCESS if success, else fail reason 813 //! 814 virtual MOS_STATUS SetRowstoreCachingOffsets( 815 PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams); 816 817 //! 818 //! \brief Init Cacheability Control Settings 819 //! \details Init Cacheability Control Settings in codechal hw interface 820 //! 821 //! \param [in] codecFunction 822 //! codec function used to judge how to setup cacheability control settings 823 //! 824 //! \return MOS_STATUS 825 //! MOS_STATUS_SUCCESS if success, else fail reason 826 //! 827 MOS_STATUS InitCacheabilityControlSettings( 828 CODECHAL_FUNCTION codecFunction); 829 830 //! 831 //! \brief Init L3 Cache Settings 832 //! 833 //! \return MOS_STATUS 834 //! MOS_STATUS_SUCCESS if success, else fail reason 835 //! 836 virtual MOS_STATUS InitL3CacheSettings(); 837 838 //! 839 //! \brief Get memory object of GMM Cacheability control settings 840 //! \details Internal function to get memory object of GMM Cacheability control settings 841 //! 842 //! \param [in] mosUsage 843 //! Codec usages in mos type 844 //! 845 //! \return MOS_STATUS 846 //! MOS_STATUS_SUCCESS if success, else fail reason 847 //! 848 MOS_STATUS CachePolicyGetMemoryObject( 849 MOS_HW_RESOURCE_DEF mosUsage); 850 851 //! 852 //! \brief Calculates the maximum size for all picture level commands 853 //! \details Client facing function to calculate the maximum size for all picture level commands in mfx pipline 854 //! 855 //! \param [in] mode 856 //! codec mode 857 //! \param [out] commandsSize 858 //! The maximum command buffer size 859 //! \param [out] patchListSize 860 //! The maximum command patch list size 861 //! \param [in] shortFormat 862 //! True if short format, false long format 863 //! 864 //! \return MOS_STATUS 865 //! MOS_STATUS_SUCCESS if success, else fail reason 866 //! 867 MOS_STATUS GetMfxStateCommandsDataSize( 868 uint32_t mode, 869 uint32_t *commandsSize, 870 uint32_t *patchListSize, 871 bool shortFormat); 872 873 //! 874 //! \brief Calculates maximum size for all slice/MB level commands 875 //! \details Client facing function to calculate maximum size for all slice/MB level commands in mfx pipeline 876 //! 877 //! \param [in] mode 878 //! Codec mode 879 //! \param [out] commandsSize 880 //! The maximum command buffer size 881 //! \param [out] patchListSize 882 //! The maximum command patch list size 883 //! \param [in] modeSpecific 884 //! Indicate the long or short format for decoder or single take phase for encoder 885 //! 886 //! \return MOS_STATUS 887 //! MOS_STATUS_SUCCESS if success, else fail reason 888 //! 889 MOS_STATUS GetMfxPrimitiveCommandsDataSize( 890 uint32_t mode, 891 uint32_t *commandsSize, 892 uint32_t *patchListSize, 893 bool modeSpecific); 894 895 //! 896 //! \brief Calculates the maximum size for HCP/HUC picture level commands 897 //! \details Client facing function to calculate the maximum size for HCP/HUC picture level commands 898 //! \param [in] mode 899 //! Indicate the codec mode 900 //! \param [out] commandsSize 901 //! The maximum command buffer size 902 //! \param [out] patchListSize 903 //! The maximum command patch list size 904 //! \param [in] params 905 //! Indicate the command size parameters 906 //! \return MOS_STATUS 907 //! MOS_STATUS_SUCCESS if success, else fail reason 908 //! 909 MOS_STATUS GetHxxStateCommandSize( 910 uint32_t mode, 911 uint32_t *commandsSize, 912 uint32_t *patchListSize, 913 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params); 914 915 //! 916 //! \brief Calculates maximum size for HCP/HUC slice/MB level commands 917 //! \details Client facing function to calculate maximum size for HCP/HUC slice/MB level commands 918 //! \param [in] mode 919 //! Indicate the codec mode 920 //! \param [out] commandsSize 921 //! The maximum command buffer size 922 //! \param [out] patchListSize 923 //! The maximum command patch list size 924 //! \param [in] modeSpecific 925 //! Indicate the long or short format 926 //! \return MOS_STATUS 927 //! MOS_STATUS_SUCCESS if success, else fail reason 928 //! 929 MOS_STATUS GetHxxPrimitiveCommandSize( 930 uint32_t mode, 931 uint32_t *commandsSize, 932 uint32_t *patchListSize, 933 bool modeSpecific); 934 935 //! 936 //! \brief Calculates the maximum size for HCP picture level commands 937 //! \details Client facing function to calculate the maximum size for HCP picture level commands 938 //! \param [in] mode 939 //! Indicate the codec mode 940 //! \param [out] commandsSize 941 //! The maximum command buffer size 942 //! \param [out] patchListSize 943 //! The maximum command patch list size 944 //! \param [in] params 945 //! Indicate the command size parameters 946 //! \return MOS_STATUS 947 //! MOS_STATUS_SUCCESS if success, else fail reason 948 //! 949 MOS_STATUS GetHcpStateCommandSize( 950 uint32_t mode, 951 uint32_t * commandsSize, 952 uint32_t * patchListSize, 953 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params); 954 955 //! 956 //! \brief Calculates maximum size for HCP slice/MB level commands 957 //! \details Client facing function to calculate maximum size for HCP slice/MB level commands 958 //! \param [in] mode 959 //! Indicate the codec mode 960 //! \param [out] commandsSize 961 //! The maximum command buffer size 962 //! \param [out] patchListSize 963 //! The maximum command patch list size 964 //! \param [in] modeSpecific 965 //! Indicate the long or short format 966 //! \return MOS_STATUS 967 //! MOS_STATUS_SUCCESS if success, else fail reason 968 //! 969 MOS_STATUS GetHcpPrimitiveCommandSize( 970 uint32_t mode, 971 uint32_t *commandsSize, 972 uint32_t *patchListSize, 973 bool modeSpecific); 974 975 //! 976 //! \brief Calculates the maximum size for Huc picture level commands 977 //! \details Client facing function to calculate the maximum size for HUC picture level commands 978 //! \param [in] mode 979 //! Indicate the codec mode 980 //! \param [out] commandsSize 981 //! The maximum command buffer size 982 //! \param [out] patchListSize 983 //! The maximum command patch list size 984 //! \param [in] params 985 //! Indicate the command size parameters 986 //! \return MOS_STATUS 987 //! MOS_STATUS_SUCCESS if success, else fail reason 988 //! 989 MOS_STATUS GetHucStateCommandSize( 990 uint32_t mode, 991 uint32_t *commandsSize, 992 uint32_t *patchListSize, 993 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params); 994 995 //! 996 //! \brief Calculates maximum size for Huc slice/MB level commands 997 //! \details Client facing function to calculate maximum size for Huc slice/MB level commands 998 //! \param [in] mode 999 //! Indicate the codec mode 1000 //! \param [out] commandsSize 1001 //! The maximum command buffer size 1002 //! \param [out] patchListSize 1003 //! The maximum command patch list size 1004 //! \return MOS_STATUS 1005 //! MOS_STATUS_SUCCESS if success, else fail reason 1006 //! 1007 MOS_STATUS GetHucPrimitiveCommandSize( 1008 uint32_t mode, 1009 uint32_t *commandsSize, 1010 uint32_t *patchListSize); 1011 1012 //! 1013 //! \brief Calculates the maximum size for Vdenc state level commands 1014 //! \details Client facing function to calculate the maximum size for Vdenc state level commands 1015 //! \param [in] mode 1016 //! Indicate the codec mode 1017 //! \param [out] commandsSize 1018 //! The maximum command buffer size 1019 //! \param [out] patchListSize 1020 //! The maximum command patch list size 1021 //! \return MOS_STATUS 1022 //! MOS_STATUS_SUCCESS if success, else fail reason 1023 //! 1024 MOS_STATUS GetVdencStateCommandsDataSize( 1025 uint32_t mode, 1026 uint32_t *commandsSize, 1027 uint32_t *patchListSize); 1028 1029 //! 1030 //! \brief Calculates maximum size for all slice level VDEnc commands 1031 //! \details Client facing function to calculate the maximum size for Vdenc slice level commands 1032 //! \param [in] mode 1033 //! Indicate the codec mode 1034 //! \param [out] commandsSize 1035 //! The maximum command buffer size 1036 //! \param [out] patchListSize 1037 //! The maximum command patch list size 1038 //! \return MOS_STATUS 1039 //! MOS_STATUS_SUCCESS if success, else fail reason 1040 //! 1041 MOS_STATUS GetVdencPrimitiveCommandsDataSize( 1042 uint32_t mode, 1043 uint32_t *commandsSize, 1044 uint32_t *patchListSize); 1045 1046 //! 1047 //! \brief Calculates the maximum size for Vdenc picture 2nd level commands 1048 //! \details Client facing function to calculate the maximum size for Vdenc picture 2nd level commands 1049 //! \param [in] mode 1050 //! Indicate the codec mode 1051 //! \param [out] commandsSize 1052 //! The maximum command buffer size 1053 //! \return MOS_STATUS 1054 //! MOS_STATUS_SUCCESS if success, else fail reason 1055 //! 1056 virtual MOS_STATUS GetVdencPictureSecondLevelCommandsSize( 1057 uint32_t mode, 1058 uint32_t *commandsSize); 1059 1060 //! 1061 //! \brief Calculates the maximum size for Huc Streamout commands 1062 //! \details Client facing function to calculate the maximum size for Huc Streamout commands 1063 //! \param [out] commandsSize 1064 //! The maximum command buffer size 1065 //! \param [out] patchListSize 1066 //! The maximum command patch list size 1067 //! \return MOS_STATUS 1068 //! MOS_STATUS_SUCCESS if success, else fail reason 1069 //! 1070 virtual MOS_STATUS GetStreamoutCommandSize( 1071 uint32_t *commandsSize, 1072 uint32_t *patchListSize); 1073 1074 //! 1075 //! \brief Get max vdbox index 1076 //! 1077 //! \return MHW_VDBOX_NODE_IND 1078 //! max vdbox index got 1079 //! GetMaxVdboxIndex()1080 inline MHW_VDBOX_NODE_IND GetMaxVdboxIndex() 1081 { 1082 return MEDIA_IS_SKU(m_skuTable, FtrVcs2) ? MHW_VDBOX_NODE_2 : MHW_VDBOX_NODE_1; 1083 } 1084 1085 //! 1086 //! \brief Initialize the codechal hw interface 1087 //! \details Initialize the interface before using 1088 //! 1089 //! \param [in] settings 1090 //! Settings for initialization 1091 //! 1092 //! \return MOS_STATUS 1093 //! MOS_STATUS_SUCCESS if success, else fail reason 1094 //! 1095 virtual MOS_STATUS Initialize( 1096 CodechalSetting *settings); 1097 1098 //! 1099 //! \brief Get meida object buffer size 1100 //! \details Calculate the 2nd level BB size for media object BBs used with kernels 1101 //! 1102 //! \param [in] numMbs 1103 //! Number of MBs for calculation 1104 //! \param [in] inlineDataSize 1105 //! Inline data size used 1106 //! 1107 //! \return uint32_t 1108 //! Buffer size got. 1109 //! 1110 uint32_t GetMediaObjectBufferSize( 1111 uint32_t numMbs, 1112 uint32_t inlineDataSize); 1113 1114 //! 1115 //! \brief Add vdenc brc img buffer 1116 //! \details Add vdenc bitrate control image buffer into cmdbuffer 1117 //! 1118 //! \param [in] vdencBrcImgBuffer 1119 //! Resource of vdenc brc img buffer 1120 //! \param [in] params 1121 //! parameter used for AVC img parameters 1122 //! 1123 //! \return MOS_STATUS 1124 //! MOS_STATUS_SUCCESS if success, else fail reason 1125 //! 1126 MOS_STATUS AddVdencBrcImgBuffer( 1127 PMOS_RESOURCE vdencBrcImgBuffer, 1128 PMHW_VDBOX_AVC_IMG_PARAMS params); 1129 1130 //! 1131 //! \brief Add vdenc sfd img buffer 1132 //! \details Add vdenc static frame detection image buffer into cmdbuffer 1133 //! 1134 //! \param [in] vdencSfdImgBuffer 1135 //! Resource of vdenc brc img buffer 1136 //! \param [in] params 1137 //! parameter used for AVC img parameters 1138 //! 1139 //! \return MOS_STATUS 1140 //! MOS_STATUS_SUCCESS if success, else fail reason 1141 //! 1142 MOS_STATUS AddVdencSfdImgBuffer( 1143 PMOS_RESOURCE vdencSfdImgBuffer, 1144 PMHW_VDBOX_AVC_IMG_PARAMS params); 1145 1146 //! 1147 //! \brief Calculates the maximum size for all kernel loading commands 1148 //! \details Client facing function to calculate the maximum size for all kernel loading commands 1149 //! \param [in] maxNumSurfaces 1150 //! maximum surface number 1151 //! \return uint32_t 1152 //! Returns the maximum size for all kernel loading commands 1153 //! 1154 uint32_t GetKernelLoadCommandSize( 1155 uint32_t maxNumSurfaces); 1156 1157 //! 1158 //! \brief Resizes the cmd buffer and patch list 1159 //! \details Resizes the buffer to be used for rendering GPU commands 1160 //! 1161 //! \param [in] requestedCommandBufferSize 1162 //! Requested resize command buffer size 1163 //! \param [in] requestedPatchListSize 1164 //! Requested resize patchlist size 1165 //! 1166 //! \return MOS_STATUS 1167 //! MOS_STATUS_SUCCESS if success, else fail reason 1168 //! 1169 MOS_STATUS ResizeCommandBufferAndPatchList( 1170 uint32_t requestedCommandBufferSize, 1171 uint32_t requestedPatchListSize); 1172 1173 //! 1174 //! \brief Resizes the cmd buffer and patch list with cmd buffer header 1175 //! \details Resizes the buffer to be used for rendering GPU commands with cmd buffer header 1176 //! 1177 //! \param [in] requestedCommandBufferSize 1178 //! Requested resize command buffer size 1179 //! \param [in] requestedPatchListSize 1180 //! Requested resize patchlist size 1181 //! 1182 //! \return MOS_STATUS 1183 //! MOS_STATUS_SUCCESS if success, else fail reason 1184 //! 1185 MOS_STATUS ResizeCommandBufferAndPatchListCmd( 1186 uint32_t requestedCommandBufferSize, 1187 uint32_t requestedPatchListSize); 1188 1189 //! 1190 //! \brief Resizes the cmd buffer and patch list without cmd buffer header 1191 //! \details Resizes the buffer to be used for rendering GPU commands without cmd buffer header 1192 //! 1193 //! \param [in] requestedCommandBufferSize 1194 //! Requested resize command buffer size 1195 //! \param [in] requestedPatchListSize 1196 //! Requested resize patchlist size 1197 //! 1198 //! \return MOS_STATUS 1199 //! MOS_STATUS_SUCCESS if success, else fail reason 1200 //! 1201 MOS_STATUS ResizeCommandBufferAndPatchListOs( 1202 uint32_t requestedCommandBufferSize, 1203 uint32_t requestedPatchListSize); 1204 1205 // Synchronization Functions 1206 1207 //! 1208 //! \brief Write sync tag to resource 1209 //! 1210 //! \param [in,out] cmdBuffer 1211 //! command buffer used 1212 //! \param [in] syncParams 1213 //! sync parameters used to add tag 1214 //! 1215 //! \return MOS_STATUS 1216 //! MOS_STATUS_SUCCESS if success, else fail reason 1217 //! 1218 MOS_STATUS WriteSyncTagToResource( 1219 PMOS_COMMAND_BUFFER cmdBuffer, 1220 PMOS_SYNC_PARAMS syncParams); 1221 1222 //! 1223 //! \brief Helper function composes SURFACE_STATE cacheability settings 1224 //! \details Helper function composes SURFACE_STATE cacheability settings with LLC and L3 values 1225 //! 1226 //! \param [in] cacheabiltySettingIdx 1227 //! which module needs to be set caching control 1228 //! \param [in] cacheabilityTypeRequested 1229 //! cacheability type 1230 //! 1231 //! \return uint32_t 1232 //! cacheability settings result 1233 //! 1234 uint32_t ComposeSurfaceCacheabilityControl( 1235 uint32_t cacheabiltySettingIdx, 1236 uint32_t cacheabilityTypeRequested); 1237 1238 //! 1239 //! \brief Add Huc stream out copy cmds 1240 //! \details Prepare and add Huc stream out copy cmds 1241 //! 1242 //! \param [in,out] cmdBuffer 1243 //! Command buffer 1244 //! 1245 //! \return MOS_STATUS 1246 //! MOS_STATUS_SUCCESS if success, else fail reason 1247 //! 1248 virtual MOS_STATUS AddHucDummyStreamOut( 1249 PMOS_COMMAND_BUFFER cmdBuffer); 1250 1251 //! 1252 //! \brief Perform Huc stream out copy 1253 //! \details Implement the copy using huc stream out 1254 //! 1255 //! \param [in] hucStreamOutParams 1256 //! Huc stream out parameters 1257 //! \param [in,out] cmdBuffer 1258 //! Command buffer 1259 //! 1260 //! \return MOS_STATUS 1261 //! MOS_STATUS_SUCCESS if success, else fail reason 1262 //! 1263 MOS_STATUS PerformHucStreamOut( 1264 CodechalHucStreamoutParams *hucStreamOutParams, 1265 PMOS_COMMAND_BUFFER cmdBuffer); 1266 1267 //! 1268 //! \brief Update the number of Slices, Sub-slices and EUs in the command buffer 1269 //! \details Update the number of Slices, Sub-slices and EUs in the command buffer 1270 //! with the final value from the HwInterface structure 1271 //! 1272 //! \param [in,out] cmdBuffer 1273 //! Command buffer 1274 //! \param [in] singleTaskPhaseSupported 1275 //! Indicate if single task phase supported 1276 //! \param [in] lastTaskInPhase 1277 //! Indicate if it is last task phase 1278 //! 1279 //! \return MOS_STATUS 1280 //! MOS_STATUS_SUCCESS if success, else fail reason 1281 //! 1282 MOS_STATUS UpdateSSEuForCmdBuffer( 1283 PMOS_COMMAND_BUFFER cmdBuffer, 1284 bool singleTaskPhaseSupported, 1285 bool lastTaskInPhase); 1286 1287 //! 1288 //! \brief Set the default number of Slice, Sub-slice, EUs 1289 //! \details Set the default number of Slice, Sub-slice, EUs recommended for 1290 //! the given kernel type in the HwInterface structure 1291 //! 1292 //! \param [in] mediaStateType 1293 //! Media state type 1294 //! \param [in] setRequestedSlices 1295 //! Slices requested to set 1296 //! \param [in] setRequestedSubSlices 1297 //! SubSlices requested to set 1298 //! \param [in] setRequestedEus 1299 //! Eu numbers requested to set 1300 //! 1301 //! \return MOS_STATUS 1302 //! MOS_STATUS_SUCCESS if success, else fail reason 1303 //! 1304 MOS_STATUS GetDefaultSSEuSetting( 1305 CODECHAL_MEDIA_STATE_TYPE mediaStateType, 1306 bool setRequestedSlices, 1307 bool setRequestedSubSlices, 1308 bool setRequestedEus); 1309 1310 //! 1311 //! \brief Copy data source with drv 1312 //! 1313 //! \param [in] dataCopyParams 1314 //! Parameters for data copy 1315 //! 1316 //! \return MOS_STATUS 1317 //! MOS_STATUS_SUCCESS if success, else fail reason 1318 //! 1319 MOS_STATUS CopyDataSourceWithDrv( 1320 CodechalDataCopyParams *dataCopyParams); 1321 1322 #if (_DEBUG || _RELEASE_INTERNAL) 1323 //! 1324 //! \brief Initialize L3 control user feature settings 1325 //! 1326 //! \param [in] l3CacheConfig 1327 //! L3 cache configuration 1328 //! \param [in] l3Overrides 1329 //! L3 overrides 1330 //! 1331 //! \return MOS_STATUS 1332 //! MOS_STATUS_SUCCESS if success, else fail reason 1333 //! 1334 MOS_STATUS InitL3ControlUserFeatureSettings( 1335 MHW_RENDER_ENGINE_L3_CACHE_CONFIG *l3CacheConfig, 1336 MHW_RENDER_ENGINE_L3_CACHE_SETTINGS *l3Overrides); 1337 #endif // _DEBUG || _RELEASE_INTERNAL 1338 1339 //! 1340 //! \brief Send hw semphore wait cmd 1341 //! \details Send hw semphore wait cmd for sync perpose 1342 //! 1343 //! \param [in] semaMem 1344 //! Reource of Hw semphore 1345 //! \param [in] semaData 1346 //! Data of Hw semphore 1347 //! \param [in] opCode 1348 //! Operation code 1349 //! \param [in,out] cmdBuffer 1350 //! command buffer 1351 //! 1352 //! \return MOS_STATUS 1353 //! MOS_STATUS_SUCCESS if success, else fail reason 1354 //! 1355 MOS_STATUS SendHwSemaphoreWaitCmd( 1356 PMOS_RESOURCE semaMem, 1357 uint32_t semaData, 1358 MHW_COMMON_MI_SEMAPHORE_COMPARE_OPERATION opCode, 1359 PMOS_COMMAND_BUFFER cmdBuffer, 1360 uint32_t semaMemOffset = 0); 1361 1362 //! 1363 //! \brief Send mi atomic dword cmd 1364 //! \details Send mi atomic dword cmd for sync perpose 1365 //! 1366 //! \param [in] resource 1367 //! Reource used in mi atomic dword cmd 1368 //! \param [in] immData 1369 //! Immediate data 1370 //! \param [in] opCode 1371 //! Operation code 1372 //! \param [in,out] cmdBuffer 1373 //! command buffer 1374 //! 1375 //! \return MOS_STATUS 1376 //! MOS_STATUS_SUCCESS if success, else fail reason 1377 //! 1378 MOS_STATUS SendMiAtomicDwordCmd( 1379 PMOS_RESOURCE resource, 1380 uint32_t immData, 1381 MHW_COMMON_MI_ATOMIC_OPCODE opCode, 1382 PMOS_COMMAND_BUFFER cmdBuffer); 1383 1384 //! 1385 //! \brief Send conditional batch buffer end cmd 1386 //! \details Send conditional batch buffer end cmd 1387 //! 1388 //! \param [in] resource 1389 //! Reource used in conditional batch buffer end cmd 1390 //! \param [in] offset 1391 //! Reource offset used in mi atomic dword cmd 1392 //! \param [in] compData 1393 //! Compare data 1394 //! \param [in] disableCompMask 1395 //! Indicate disabling compare mask 1396 //! \param [in,out] cmdBuffer 1397 //! command buffer 1398 //! 1399 //! \return MOS_STATUS 1400 //! MOS_STATUS_SUCCESS if success, else fail reason 1401 //! 1402 MOS_STATUS SendCondBbEndCmd( 1403 PMOS_RESOURCE resource, 1404 uint32_t offset, 1405 uint32_t compData, 1406 bool disableCompMask, 1407 PMOS_COMMAND_BUFFER cmdBuffer); 1408 1409 //! 1410 //! \brief Loads kernel data into the ISH 1411 //! \details Uses the data described in the kernel state to assign an ISH block and load the kernel data into it 1412 //! \param stateHeapInterface 1413 //! [in] State heap interface 1414 //! \param kernelState 1415 //! [in] Kernel state describing the kernel data to be loaded 1416 //! \return MOS_STATUS 1417 //! MOS_STATUS_SUCCESS if success, else fail reason 1418 //! 1419 static MOS_STATUS MhwInitISH( 1420 PMHW_STATE_HEAP_INTERFACE stateHeapInterface, 1421 PMHW_KERNEL_STATE kernelState); 1422 1423 //! 1424 //! \brief Assigns space in both DSH and SSH to the kernel state 1425 //! \details Uses input parameters to assign DSH/SSH regions to the kernel state 1426 //! \param stateHeapInterface 1427 //! [in] State heap interface 1428 //! \param kernelState 1429 //! [in] The kernel state to assign the new DSH/ISH regions 1430 //! \param noDshSpaceRequested 1431 //! [in] No DSH space should be assigned in this call 1432 //! \param forcedDshSize 1433 //! [in] The size of the DSH space required for this kernel state. 1434 //! If this value is 0, the size is calculated from the kernel state. 1435 //! \param noSshSpaceRequested 1436 //! [in] No SSH space should be assigned in this call 1437 //! \param currCmdBufId 1438 //! [in] Command buffer Id to keep track of the state heap resource 1439 //! \return MOS_STATUS 1440 //! MOS_STATUS_SUCCESS if success, else fail reason 1441 //! 1442 static MOS_STATUS AssignDshAndSshSpace( 1443 PMHW_STATE_HEAP_INTERFACE stateHeapInterface, 1444 PMHW_KERNEL_STATE kernelState, 1445 bool noDshSpaceRequested, 1446 uint32_t forcedDshSize, 1447 bool noSshSpaceRequested, 1448 uint32_t currCmdBufId); 1449 //! 1450 //! \brief Select Vdbox by index and get MMIO register 1451 //! \details Uses input parameters to Select VDBOX from KMD and get MMIO register 1452 //! \param index 1453 //! [in] vdbox index interface 1454 //! \param pCmdBuffer 1455 //! [in] get mos vdbox id from cmd buffer 1456 //! \return MmioRegistersMfx 1457 //! return the vdbox mmio register 1458 //! 1459 MmioRegistersMfx * SelectVdboxAndGetMmioRegister( 1460 MHW_VDBOX_NODE_IND index, 1461 PMOS_COMMAND_BUFFER pCmdBuffer); 1462 1463 //! 1464 //! \brief Send mi store data imm cmd 1465 //! \param [in] resource 1466 //! Reource used in mi store data imm cmd 1467 //! \param [in] immData 1468 //! Immediate data 1469 //! \param [in,out] cmdBuffer 1470 //! command buffer 1471 //! 1472 //! \return MOS_STATUS 1473 //! MOS_STATUS_SUCCESS if success, else fail reason 1474 //! 1475 MOS_STATUS SendMiStoreDataImm( 1476 PMOS_RESOURCE resource, 1477 uint32_t immData, 1478 PMOS_COMMAND_BUFFER cmdBuffer); 1479 1480 //! 1481 //! \brief Read MFC status for status report 1482 //! \param vdboxIndex 1483 //! [in] the vdbox index 1484 //! \param params 1485 //! [in] the parameters for Mfc status read 1486 //! \param cmdBuffer 1487 //! [in, out] the command buffer 1488 //! \return MOS_STATUS 1489 //! MOS_STATUS_SUCCESS if success, else fail reason 1490 //! 1491 MOS_STATUS ReadMfcStatus( 1492 MHW_VDBOX_NODE_IND vdboxIndex, 1493 const EncodeStatusReadParams ¶ms, 1494 PMOS_COMMAND_BUFFER cmdBuffer); 1495 1496 //! 1497 //! \brief Read Image status for status report 1498 //! \param vdboxIndex 1499 //! [in] the vdbox index 1500 //! \param params 1501 //! [in] the parameters for Image status read 1502 //! \param cmdBuffer 1503 //! [in, out] the command buffer 1504 //! \return MOS_STATUS 1505 //! MOS_STATUS_SUCCESS if success, else fail reason 1506 //! 1507 MOS_STATUS ReadImageStatus( 1508 MHW_VDBOX_NODE_IND vdboxIndex, 1509 const EncodeStatusReadParams ¶ms, 1510 PMOS_COMMAND_BUFFER cmdBuffer); 1511 1512 //! 1513 //! \brief Read BRC PAK statistics for status report 1514 //! \param vdboxIndex 1515 //! [in] the vdbox index 1516 //! \param params 1517 //! [in] the parameters for BRC PAK statistics specific 1518 //! \param cmdBuffer 1519 //! [in, out] the command buffer 1520 //! \return MOS_STATUS 1521 //! MOS_STATUS_SUCCESS if success, else fail reason 1522 //! 1523 MOS_STATUS ReadBrcPakStatistics( 1524 MHW_VDBOX_NODE_IND vdboxIndex, 1525 const BrcPakStatsReadParams ¶ms, 1526 PMOS_COMMAND_BUFFER cmdBuffer); 1527 1528 //! 1529 //! \brief Read HCP status for status report 1530 //! \param vdboxIndex 1531 //! [in] the vdbox index 1532 //! \param params 1533 //! [in] the parameters for HCP status read 1534 //! \param cmdBuffer 1535 //! [in, out] the command buffer 1536 //! \return MOS_STATUS 1537 //! MOS_STATUS_SUCCESS if success, else fail reason 1538 //! 1539 MOS_STATUS ReadHcpStatus( 1540 MHW_VDBOX_NODE_IND vdboxIndex, 1541 const EncodeStatusReadParams ¶ms, 1542 PMOS_COMMAND_BUFFER cmdBuffer); 1543 1544 //! 1545 //! \brief Read HCP specific image status for status report 1546 //! \param vdboxIndex 1547 //! [in] the vdbox index 1548 //! \param params 1549 //! [in] the parameters for HCP IMG status read 1550 //! \param cmdBuffer 1551 //! [in, out] the command buffer 1552 //! \return MOS_STATUS 1553 //! MOS_STATUS_SUCCESS if success, else fail reason 1554 //! 1555 MOS_STATUS ReadImageStatusForHcp( 1556 MHW_VDBOX_NODE_IND vdboxIndex, 1557 const EncodeStatusReadParams ¶ms, 1558 PMOS_COMMAND_BUFFER cmdBuffer); 1559 1560 //! 1561 //! \brief Read HCP specific BRC PAK statistics for status report 1562 //! \param vdboxIndex 1563 //! [in] the vdbox index 1564 //! \param params 1565 //! [in] the parameters for BRC PAK statistics specific 1566 //! \param cmdBuffer 1567 //! [in, out] the command buffer 1568 //! \return MOS_STATUS 1569 //! MOS_STATUS_SUCCESS if success, else fail reason 1570 //! 1571 MOS_STATUS ReadBrcPakStatisticsForHcp( 1572 MHW_VDBOX_NODE_IND vdboxIndex, 1573 const BrcPakStatsReadParams ¶ms, 1574 PMOS_COMMAND_BUFFER cmdBuffer); 1575 1576 //! 1577 //! \brief Set the status tag(start/end) for status report by PIPE contol command, 1578 //! this function is for render engine. 1579 //! \param osResource 1580 //! [in] Reource used in the cmd 1581 //! \param offset 1582 //! [in] Reource offset used the cmd 1583 //! \param tag 1584 //! [in] queryStart/queryEnd defined in the media_status_report.h 1585 //! \param needFlushCache 1586 //! [in] whether need to flush the cache or not. For queryStart, need to flush cache, otherwise 1587 //! don't need. 1588 //! \param cmdBuffer 1589 //! [in, out] the command buffer 1590 //! \return MOS_STATUS 1591 //! MOS_STATUS_SUCCESS if success, else fail reason 1592 //! 1593 MOS_STATUS SetStatusTagByPipeCtrl( 1594 PMOS_RESOURCE osResource, 1595 uint32_t offset, 1596 uint32_t tag, 1597 bool needFlushCache, 1598 PMOS_COMMAND_BUFFER cmdBuffer); 1599 1600 //! 1601 //! \brief Set the status tag(start/end) for status report by MI command 1602 //! this function is for vdbox. 1603 //! \param osResource 1604 //! [in] Reource used in the cmd 1605 //! \param offset 1606 //! [in] Reource offset used the cmd 1607 //! \param tag 1608 //! [in] queryStart/queryEnd defined in the media_status_report.h 1609 //! \param cmdBuffer 1610 //! [in, out] the command buffer 1611 //! \return MOS_STATUS 1612 //! MOS_STATUS_SUCCESS if success, else fail reason 1613 //! 1614 MOS_STATUS SetStatusTagByMiCommand( 1615 MOS_RESOURCE *osResource, 1616 uint32_t offset, 1617 uint32_t tag, 1618 PMOS_COMMAND_BUFFER cmdBuffer); 1619 1620 //! 1621 //! \brief Check if simulation/emulation is active 1622 //! \return bool 1623 //! True if simulation/emulation is active, else false. 1624 //! IsSimActive()1625 bool IsSimActive() 1626 { 1627 return m_osInterface ? m_osInterface->bSimIsActive : false; 1628 } 1629 1630 //! 1631 //! \brief Check if disable scalability by default 1632 //! \return bool 1633 //! True if it is to disable scalability by default, else it is not. 1634 //! IsDisableScalability()1635 bool IsDisableScalability() 1636 { 1637 return m_disableScalability; 1638 } 1639 1640 virtual bool UsesRenderEngine(CODECHAL_FUNCTION codecFunction, uint32_t standard); 1641 Uses2PlanesInputSurfaceFilmGrain()1642 virtual bool Uses2PlanesInputSurfaceFilmGrain() 1643 { 1644 return false; 1645 } 1646 1647 //! 1648 //! \brief Get film grain kernel info 1649 //! \details Get kernel base and size 1650 //! 1651 //! \param [out] kernelBase 1652 //! base addr of film grain kernels 1653 //! 1654 //! \param [out] kernelSize 1655 //! size of film grain kernels 1656 //! 1657 //! \return MOS_STATUS 1658 //! MOS_STATUS_SUCCESS if success, else fail reason 1659 //! 1660 virtual MOS_STATUS GetFilmGrainKernelInfo( 1661 uint8_t* &kernelBase, 1662 uint32_t &kernelSize); 1663 1664 //! 1665 //! \brief Calculates the maximum size for AVP picture level commands 1666 //! \details Client facing function to calculate the maximum size for AVP picture level commands 1667 //! \param [in] mode 1668 //! Indicate the codec mode 1669 //! \param [out] commandsSize 1670 //! The maximum command buffer size 1671 //! \param [out] patchListSize 1672 //! The maximum command patch list size 1673 //! \param [in] params 1674 //! Indicate the command size parameters 1675 //! \return MOS_STATUS 1676 //! MOS_STATUS_SUCCESS if success, else fail reason 1677 //! GetAvpStateCommandSize(uint32_t mode,uint32_t * commandsSize,uint32_t * patchListSize,PMHW_VDBOX_STATE_CMDSIZE_PARAMS params)1678 virtual MOS_STATUS GetAvpStateCommandSize( 1679 uint32_t mode, 1680 uint32_t *commandsSize, 1681 uint32_t *patchListSize, 1682 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params) 1683 { 1684 return MOS_STATUS_SUCCESS; 1685 }; 1686 1687 //! 1688 //! \brief Calculates maximum size for AVP tile level commands 1689 //! \details Client facing function to calculate maximum size for AVP tile level commands 1690 //! \param [in] mode 1691 //! Indicate the codec mode 1692 //! \param [out] commandsSize 1693 //! The maximum command buffer size 1694 //! \param [out] patchListSize 1695 //! The maximum command patch list size 1696 //! \return MOS_STATUS 1697 //! MOS_STATUS_SUCCESS if success, else fail reason 1698 //! GetAvpPrimitiveCommandSize(uint32_t mode,uint32_t * commandsSize,uint32_t * patchListSize)1699 virtual MOS_STATUS GetAvpPrimitiveCommandSize( 1700 uint32_t mode, 1701 uint32_t *commandsSize, 1702 uint32_t *patchListSize) 1703 { 1704 return MOS_STATUS_SUCCESS; 1705 }; 1706 1707 1708 //! \brief default disable vdbox balancing by UMD 1709 bool bEnableVdboxBalancingbyUMD = false; 1710 1711 //! \brief default disable the get vdbox node by UMD, decided by MHW and MOS 1712 bool m_getVdboxNodeByUMD = false; 1713 1714 operator CodechalHwInterfaceNext &() 1715 { 1716 if (m_hwInterfaceNext == nullptr) 1717 { 1718 CODECHAL_HW_ASSERTMESSAGE("Conversion cannot succeed due to null pointer of m_hwInterfaceNext."); 1719 } 1720 return *m_hwInterfaceNext; 1721 } 1722 1723 operator CodechalHwInterfaceNext *() 1724 { 1725 return m_hwInterfaceNext; 1726 } 1727 1728 CodechalHwInterfaceNext *m_hwInterfaceNext = nullptr; 1729 1730 }; 1731 1732 extern const MOS_SYNC_PARAMS g_cInitSyncParams; 1733 1734 #endif // __CODECHAL_HW_H__ 1735