1 /* 2 * Copyright (c) 2013-2017, 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 //! \file codechal_memdecomp.h 23 //! \brief Defines data structures and interfaces for media memory decompression. 24 //! \details 25 //! 26 27 #ifndef __CODECHAL_MEDIAMEMCOMP_H__ 28 #define __CODECHAL_MEDIAMEMCOMP_H__ 29 30 #include "mhw_render.h" 31 #include "mos_os.h" 32 #include "mediamemdecomp.h" 33 34 //! 35 //! \class MediaMemDecompState 36 //! \brief Media memory decompression state. This class defines the member fields 37 //! functions etc used by memory decompression. 38 //! 39 class MediaMemDecompState : public MediaMemDecompBaseState 40 { 41 public: 42 //! 43 //! \brief Constructor 44 //! 45 MediaMemDecompState(); 46 47 //! 48 //! \brief Copy constructor 49 //! 50 MediaMemDecompState(const MediaMemDecompState&) = delete; 51 52 //! 53 //! \brief Copy assignment operator 54 //! 55 MediaMemDecompState& operator=(const MediaMemDecompState&) = delete; 56 57 //! 58 //! \brief Destructor 59 //! 60 virtual ~MediaMemDecompState(); 61 62 //! 63 //! \brief Media memory decompression 64 //! \details Entry point to decompress media memory 65 //! \param targetResource 66 //! [in] The surface will be decompressed 67 //! 68 //! \return MOS_STATUS 69 //! MOS_STATUS_SUCCESS if success, else fail reason 70 //! 71 MOS_STATUS MemoryDecompress( 72 PMOS_RESOURCE targetResource); 73 74 //! 75 //! \brief Initialize memory decompress state 76 //! \details Initialize memory decompress state 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 MOS_STATUS Initialize( 81 PMOS_INTERFACE osInterface, 82 MhwCpInterface *cpInterface, 83 MhwMiInterface *miInterface, 84 MhwRenderInterface *renderInterface); 85 86 protected: 87 88 //! 89 //! \enum DecompKernelStateIdx 90 //! \brief Decompress kernel state index 91 //! 92 enum DecompKernelStateIdx 93 { 94 decompKernelStatePa = 0, 95 decompKernelStatePl2, 96 decompKernelStateMax 97 }; 98 99 //! 100 //! \enum CopyBindingTableOffset 101 //! \brief Decompress copy kernel binding table offset 102 //! 103 enum CopyBindingTableOffset 104 { 105 copySurfaceSrcY = 0, 106 copySurfaceSrcU = 1, 107 copySurfaceSrcV = 2, 108 copySurfaceDstY = 3, 109 copySurfaceDstU = 4, 110 copySurfaceDstV = 5, 111 copySurfaceNum = 6 112 }; 113 114 //! 115 //! \brief Initialize kernel state 116 //! \details Initialize kernel state 117 //! \param kernelStateIdx 118 //! [in] Kernel state index 119 //! 120 //! \return MOS_STATUS 121 //! MOS_STATUS_SUCCESS if success, else fail reason 122 //! 123 virtual MOS_STATUS InitKernelState(uint32_t kernelStateIdx); 124 125 //! 126 //! \brief Gets a kernel information for a specific unique kernel identifier 127 //! \details Gets a kernel information for a specific unique kernel identifier 128 //! from the combined kernel 129 //! \param kernelBase 130 //! [in] The combined kernel 131 //! \param krnUniId 132 //! [in] The unique kernel identifier in the combined kernel 133 //! \param kernelBinary 134 //! [in,out] The binary of the kernel specified by krnUniId 135 //! \param kernelSize 136 //! [in,out] The size of the kernel specified by krnUniId 137 //! \return MOS_STATUS 138 //! MOS_STATUS_SUCCESS if success, else fail reason 139 //! 140 MOS_STATUS GetKernelBinaryAndSize( 141 uint8_t *kernelBase, 142 uint32_t krnUniId, 143 uint8_t **kernelBinary, 144 uint32_t *kernelSize); 145 146 //! 147 //! \brief Sets up the CURBE data for MMC and loads it into the DSH 148 //! \details Calculates the kernel binary location and size and saves this information to either the 149 //! state heap interface or the provided kernel state 150 //! \param kernelStateIdx 151 //! [in] The type of copy kernel (PA or PL2) 152 //! \return MOS_STATUS 153 //! MOS_STATUS_SUCCESS if success, else fail reason 154 //! 155 MOS_STATUS SetMediaObjectCopyCurbe( 156 DecompKernelStateIdx kernelStateIdx); 157 158 //! 159 //! \brief Set copy kernel states parameters 160 //! \details Set copy kernel states parameters for MMC 161 //! \return MOS_STATUS 162 //! MOS_STATUS_SUCCESS if success, else fail reason 163 //! 164 MOS_STATUS SetKernelStateParams(); 165 166 //! 167 //! \brief Get resource information 168 //! \details Get resource information for the specifc surface 169 //! \param surface 170 //! [in] Surface pointer 171 //! \return MOS_STATUS 172 //! MOS_STATUS_SUCCESS if success, else fail reason 173 //! 174 MOS_STATUS GetResourceInfo(PMOS_SURFACE surface); 175 176 //! 177 //! \brief Get the surface width in bytes 178 //! \details Get the suface width in bytes 179 //! \param surface 180 //! [in] Surface pointer 181 //! \return uint32_t 182 //! Output the surface width 183 //! 184 uint32_t GetSurfaceWidthInBytes(PMOS_SURFACE surface); 185 186 //! 187 //! \brief Updates GPU Sync Tag (H/W Tag) using MI_STORE_DATA_IMM command. 188 //! \details Updates GPU Sync Tag (H/W Tag) using MI_STORE_DATA_IMM command. 189 //! \param cmdBuffer 190 //! [in] Resource to decompress 191 //! \return MOS_STATUS 192 //! MOS_STATUS_SUCCESS if success, else fail reason 193 //! 194 MOS_STATUS WriteSyncTagToResourceCmd( 195 PMOS_COMMAND_BUFFER cmdBuffer); 196 197 static constexpr uint32_t m_numMemDecompSyncTags = 8; //!< Number of memory decompress sync tags 198 199 PMOS_INTERFACE m_osInterface = nullptr; //!< Pointer to Os Inteface 200 MhwCpInterface *m_cpInterface = nullptr; //!< Pointer to Cp Interface 201 MhwMiInterface *m_miInterface = nullptr; //!< Pointer to MhwMiInterface 202 MhwRenderInterface *m_renderInterface = nullptr; //!< Pointer to MhwRenderInterface 203 PMHW_STATE_HEAP_INTERFACE m_stateHeapInterface = nullptr; //!< Pointer to PMHW_STATE_HEAP_INTERFACE 204 uint8_t *m_kernelBase = nullptr; //!< Pointer to kernel base address 205 MHW_STATE_HEAP_SETTINGS m_stateHeapSettings; //!< State heap setting 206 uint32_t m_krnUniId[decompKernelStateMax]; //!< Kernel unique ID 207 uint8_t *m_kernelBinary[decompKernelStateMax]; //!< Kernel binary 208 uint32_t m_kernelSize[decompKernelStateMax]; //!< Kernel size 209 MHW_KERNEL_STATE m_kernelStates[decompKernelStateMax]; //!< Kernel state 210 MOS_GPU_CONTEXT m_renderContext; //!< Render GPU context 211 bool m_renderContextUsesNullHw = false; //!< Indicate if render context use null hw or not 212 bool m_disableDecodeSyncLock = false; //!< Indicate if decode sync lock disabled or not 213 bool m_disableLockForTranscode = false; //!< Indicate if lock is disabled for transcode or not 214 uint32_t *m_cmdBufIdGlobal = nullptr; //!< Pointer to command buffer global Id 215 MOS_RESOURCE m_resCmdBufIdGlobal; //!< Resource for command buffer global Id 216 uint32_t m_currCmdBufId; //!< Current command buffer Id 217 }; 218 219 #endif //__CODECHAL_MEDIAMEMCOMP_H__ 220