1 /* 2 * Copyright (c) 2018-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 #ifndef __VP_PACKET_PIPE_H__ 23 #define __VP_PACKET_PIPE_H__ 24 25 #include "media_cmd_packet.h" 26 #include "mhw_sfc.h" 27 #include "vp_pipeline_common.h" 28 #include "vp_allocator.h" 29 #include "vp_debug_interface.h" 30 31 #include <vector> 32 #include "hw_filter.h" 33 34 #include "vp_packet_shared_context.h" 35 //#include "vp_kernelset.h" 36 37 class MediaScalability; 38 class MediaContext; 39 class VpDebugInterface; 40 41 namespace vp { 42 43 class VpPlatformInterface; 44 class VpKernelSet; 45 46 class PacketFactory 47 { 48 public: 49 PacketFactory(VpPlatformInterface *vpPlatformInterface); 50 virtual ~PacketFactory(); 51 MOS_STATUS Initialize(MediaTask *pTask, PVP_MHWINTERFACE pHwInterface, PVpAllocator pAllocator, VPMediaMemComp *pMmc, VP_PACKET_SHARED_CONTEXT *packetSharedContext, VpKernelSet *vpKernels, void *debugInterface); 52 VpCmdPacket *CreatePacket(EngineType type); 53 void ReturnPacket(VpCmdPacket *&pPacket); 54 55 VpDebugInterface *m_debugInterface = nullptr; 56 57 protected: 58 VpCmdPacket *CreateVeboxPacket(); 59 VpCmdPacket *CreateRenderPacket(); 60 61 void ClearPacketPool(std::vector<VpCmdPacket *> &pool); 62 63 std::vector<VpCmdPacket *> m_VeboxPacketPool; 64 std::vector<VpCmdPacket *> m_RenderPacketPool; 65 66 MediaTask *m_pTask = nullptr; 67 PVP_MHWINTERFACE m_pHwInterface = nullptr; 68 PVpAllocator m_pAllocator = nullptr; 69 VPMediaMemComp *m_pMmc = nullptr; 70 VpPlatformInterface *m_vpPlatformInterface = nullptr; 71 VpKernelSet *m_kernelSet = nullptr; 72 VP_PACKET_SHARED_CONTEXT *m_packetSharedContext = nullptr; 73 74 MEDIA_CLASS_DEFINE_END(vp__PacketFactory) 75 }; 76 77 class PacketPipe 78 { 79 public: 80 PacketPipe(PacketFactory &packetFactory); 81 virtual ~PacketPipe(); 82 MOS_STATUS Clean(); 83 MOS_STATUS AddPacket(HwFilter &hwFilter); 84 MOS_STATUS Execute(MediaStatusReport *statusReport, MediaScalability *&scalability, MediaContext *mediaContext, bool bEnableVirtualEngine, uint8_t numVebox); GetOutputPipeMode()85 VPHAL_OUTPUT_PIPE_MODE GetOutputPipeMode() 86 { 87 return m_outputPipeMode; 88 } 89 IsVeboxFeatureInuse()90 bool IsVeboxFeatureInuse() 91 { 92 return m_veboxFeatureInuse; 93 } 94 PacketNum()95 uint32_t PacketNum() 96 { 97 return m_Pipe.size(); 98 } 99 GetPacket(uint32_t idx)100 VpCmdPacket *GetPacket(uint32_t idx) 101 { 102 return idx < m_Pipe.size() ? m_Pipe[idx] : nullptr; 103 } 104 105 static MOS_STATUS SwitchContext(PacketType type, MediaScalability *&scalability, MediaContext *mediaContext, bool bEnableVirtualEngine, uint8_t numVebox); 106 107 private: 108 VpCmdPacket *CreatePacket(EngineType type); 109 MOS_STATUS SetOutputPipeMode(EngineType engineType); 110 111 PacketFactory &m_PacketFactory; 112 std::vector<VpCmdPacket *> m_Pipe; 113 VPHAL_OUTPUT_PIPE_MODE m_outputPipeMode = VPHAL_OUTPUT_PIPE_MODE_INVALID; 114 bool m_veboxFeatureInuse = false; 115 116 MEDIA_CLASS_DEFINE_END(vp__PacketPipe) 117 }; 118 119 class PacketPipeFactory 120 { 121 public: 122 PacketPipeFactory(PacketFactory &pPacketFactory); 123 virtual ~PacketPipeFactory(); 124 PacketPipe *CreatePacketPipe(); 125 void ReturnPacketPipe(PacketPipe *&pPipe); 126 127 private: 128 PacketFactory &m_pPacketFactory; 129 std::vector<PacketPipe *> m_Pool; 130 131 MEDIA_CLASS_DEFINE_END(vp__PacketPipeFactory) 132 }; 133 134 } 135 #endif // !__VP_PACKET_PIPE_H__ 136