1 /* 2 * Copyright (c) 2013-2020, 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_interfaces_mhw.h 24 //! \brief Gen-specific factory creation of the mhw interfaces 25 //! 26 27 #ifndef __MEDIA_INTERFACES_MHW_H__ 28 #define __MEDIA_INTERFACES_MHW_H__ 29 30 #include "media_interfaces.h" 31 #include "igfxfmid.h" 32 #include "mos_utilities.h" 33 #include "mos_os.h" 34 35 // forward declarations 36 class MhwCpInterface; 37 class MhwMiInterface; 38 class MhwRenderInterface; 39 class MhwSfcInterface; 40 class XMHW_STATE_HEAP_INTERFACE; 41 class MhwVeboxInterface; 42 class MhwVeboxInterface; 43 class MhwVdboxMfxInterface; 44 class MhwVdboxHcpInterface; 45 class MhwVdboxHucInterface; 46 class MhwVdboxVdencInterface; 47 class MhwBltInterface; 48 49 //! 50 //! \class MhwInterfaces 51 //! \brief MHW interfaces 52 //! 53 class MhwInterfaces 54 { 55 public: ~MhwInterfaces()56 virtual ~MhwInterfaces() {} 57 58 //! \brief Determines which interfaces are created 59 struct CreateParams 60 { CreateParamsCreateParams61 CreateParams() 62 { 63 Flags.m_value = 0; 64 } 65 66 union 67 { 68 struct 69 { 70 uint32_t m_render : 1; 71 uint32_t m_sfc : 1; 72 uint32_t m_stateHeap : 1; 73 uint32_t m_vebox : 1; 74 uint32_t m_vdboxAll : 1; 75 uint32_t m_mfx : 1; 76 uint32_t m_hcp : 1; 77 uint32_t m_huc : 1; 78 uint32_t m_vdenc : 1; 79 uint32_t m_blt : 1; 80 uint32_t m_avp : 1; 81 uint32_t m_reserved : 21; 82 }; 83 uint32_t m_value; 84 } Flags; 85 86 uint8_t m_heapMode = 0; //!< To be deprecated when heap management unified 87 bool m_isDecode = false; //!< Whether or not decode is in use, only valid for VDBOX creation 88 bool m_isCp = false; //!< Whether or not CP is in use, CP only need mi and cp interface. 89 }; 90 91 //! \brief These interfaces are responsible for constructing instructions, 92 //! structures, and registers for hardware. 93 MhwCpInterface *m_cpInterface = nullptr; 94 MhwMiInterface *m_miInterface = nullptr; 95 MhwRenderInterface *m_renderInterface = nullptr; 96 MhwSfcInterface *m_sfcInterface = nullptr; 97 XMHW_STATE_HEAP_INTERFACE *m_stateHeapInterface = nullptr; 98 MhwVeboxInterface *m_veboxInterface = nullptr; 99 MhwVdboxMfxInterface *m_mfxInterface = nullptr; 100 MhwVdboxHcpInterface *m_hcpInterface = nullptr; 101 MhwVdboxHucInterface *m_hucInterface = nullptr; 102 MhwVdboxVdencInterface *m_vdencInterface = nullptr; 103 MhwBltInterface *m_bltInterface = nullptr; 104 105 //! 106 //! \brief Calls the factory function to initialize all requested interfaces. 107 //! \param [in] params 108 //! Configuration flags for the creation of MHW interfaces. 109 //! \param [in] osInterface 110 //! OS interface 111 //! \return MhwInterfaces* 112 //! returns a valid pointer if successful and nullptr if failed. 113 //! 114 static MhwInterfaces* CreateFactory( 115 CreateParams params, 116 PMOS_INTERFACE osInterface); 117 118 //! 119 //! \brief Creates requested MHW interfaces. 120 //! \param [in] params 121 //! Configuration flags for the creation of MHW interfaces. 122 //! \param [in] osInterface 123 //! OS interface 124 //! \return MOS_STATUS_SUCCESS if succeeded, else error code. 125 //! 126 virtual MOS_STATUS Initialize( 127 CreateParams params, 128 PMOS_INTERFACE osInterface) = 0; 129 130 //! 131 //! \brief Destroys all created MHW interfaces 132 //! \details If the HAL creation fails, this is used for cleanup 133 //! 134 virtual void Destroy(); 135 136 //! 137 //! \brief Set Interfaces Destroy State 138 //! \details If the interfaces has destroyed, set this state value on 139 //! SetDestroyState(bool destorystate)140 void SetDestroyState(bool destorystate) { m_isDestroyed = destorystate; }; GetDestroyState()141 bool GetDestroyState() { return m_isDestroyed; }; 142 143 private: 144 bool m_isDestroyed = false; 145 }; 146 147 extern template class MediaInterfacesFactory<MhwInterfaces>; 148 149 #endif // __MEDIA_INTERFACES_MHW_H__ 150