1 /* 2 * Copyright (c) 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 hal_oca_interface_next.h 24 //! \brief Implementation of functions for HAL OCA Interface 25 //! 26 27 #ifndef __HAL_OCA_INTERFACE_NEXT_H__ 28 #define __HAL_OCA_INTERFACE_NEXT_H__ 29 30 #include "mhw_mi.h" 31 #include "mos_os_hw.h" 32 #include "mhw_mi_itf.h" 33 #include "media_defs.h" 34 /****************************************************************************************************/ 35 /* HalOcaInterface */ 36 /****************************************************************************************************/ 37 38 class HalOcaInterfaceNext 39 { 40 public: 41 //! 42 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. 43 //! \param [in/out] cmdBuffer 44 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated. 45 //! \param [in] mosContext 46 //! Reference to MOS_CONTEXT. 47 //! \param [in] gpuContextHandle 48 //! Gpu context handle 49 //! \param [in] miItf 50 //! Reference to Mhw MiItf. 51 //! \param [in] mmioRegisters 52 //! mmio registers for current engine. 53 //! \param [in] offsetOf1stLevelBB 54 //! Offset for current BB in cmdBuffer. 55 //! \param [in] bUseSizeOfCmdBuf 56 //! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB. 57 //! \param [in] sizeOf1stLevelBB 58 //! Size of BB. Ignore if bUseSizeOfResource == true. 59 //! \return void 60 //! No return value. Handle all exception inside the function. 61 //! 62 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, 63 uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters, 64 uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0); 65 66 //! 67 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. 68 //! \param [in/out] cmdBuffer 69 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated. 70 //! \param [in] mosContext 71 //! Reference to MOS_CONTEXT. 72 //! \param [in] gpuContextHandle 73 //! Gpu context handle 74 //! \param [in] miItf 75 //! Reference to Mhw MiItf. 76 //! \param [in] mmioRegisters 77 //! mmio registers for current engine. 78 //! \param [in] offsetOf1stLevelBB 79 //! Offset for current BB in cmdBuffer. 80 //! \param [in] bUseSizeOfCmdBuf 81 //! If true, use size of cmdBuffer for batch buffer, else use sizeOf1stLevelBB. 82 //! \param [in] sizeOf1stLevelBB 83 //! Size of BB. Ignore if bUseSizeOfResource == true. 84 //! \return void 85 //! No return value. Handle all exception inside the function. 86 //! 87 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, 88 uint32_t gpuContextHandle, std::shared_ptr<mhw::mi::Itf> miItf, MmioRegistersMfx &mmioRegisters, 89 uint32_t offsetOf1stLevelBB = 0, bool bUseSizeOfCmdBuf = true, uint32_t sizeOf1stLevelBB = 0); 90 91 //! 92 //! \brief Oca operation which should be called before adding batch buffer end command for 1st 93 //! level batch buffer. 94 //! \param [in/out] cmdBuffer 95 //! Command buffer for current BB. hOcaBuf in cmdBuffer will be updated. 96 //! \param [in] osInterface 97 //! Reference to MOS_INTERFACE. 98 //! \return void 99 //! No return value. Handle all exception inside the function. 100 //! 101 static void On1stLevelBBEnd(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface); 102 103 //! 104 //! \brief Oca operation which should be called before sending start sub level batch buffer command. 105 //! \param [in] cmdBuffer 106 //! Command buffer for current BB. 107 //! \param [in] mosContext 108 //! Reference to MOS_CONTEXT. 109 //! \param [in] pMosResource 110 //! Pointer to the MOS_RESOURCE. 111 //! \param [in] offsetOfSubLevelBB 112 //! Offset for current BB in pMosResource. 113 //! \param [in] bUseSizeOfResource 114 //! If true, use size of pMosResource for batch buffer, else use sizeOfIndirectState. 115 //! \param [in] sizeOfSubLevelBB 116 //! Size of BB. Ignore if bUseSizeOfResource == true. 117 //! \return void 118 //! No return value. Handle all exception inside the function. 119 //! 120 static void OnSubLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfSubLevelBB, bool bUseSizeOfResource, uint32_t sizeOfSubLevelBB); 121 122 //! 123 //! \brief Oca operation which should be called when indirect states being added. 124 //! \param [in] cmdBuffer 125 //! Command buffer for current BB. 126 //! \param [in] mosContext 127 //! Reference to MOS_CONTEXT. 128 //! \param [in] pMosResource 129 //! Pointer to the MOS_RESOURCE. 130 //! \param [in] offsetOfIndirectState 131 //! Offset for current state in pMosResource. 132 //! \param [in] bUseSizeOfResource 133 //! If true, use size of pMosResource for indirect state, else use sizeOfIndirectState. 134 //! \param [in] sizeOfIndirectState 135 //! Size of indirect state. Ignore if bUseSizeOfResource == true. 136 //! \return void 137 //! No return value. Handle all exception inside the function. 138 //! 139 static void OnIndirectState(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pMosResource, uint32_t offsetOfIndirectState, bool bUseSizeOfResource, uint32_t sizeOfIndirectState); 140 141 //! 142 //! \brief Oca operation which should be called before adding dispatch states, 143 //! e.g. VEB_DI_IECP_STATE and MEDIA_OBJECT_WALKER. 144 //! \param [in] cmdBuffer 145 //! Command buffer for current BB. 146 //! \param [in] mosContext 147 //! Reference to MOS_CONTEXT. 148 //! \param [in] miItf 149 //! Reference to Mhw MiItf. 150 //! \param [in] mmioRegisters 151 //! mmio registers for current engine. 152 //! \return void 153 //! No return value. Handle all exception inside the function. 154 //! 155 static void OnDispatch(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, std::shared_ptr<mhw::mi::Itf> miItf, MHW_MI_MMIOREGISTERS &mmioRegisters); 156 157 //! 158 //! \brief Add string to oca log section 159 //! \param [in] cmdBuffer 160 //! Command buffer for current BB. 161 //! \param [in] mosContext 162 //! Reference to MOS_CONTEXT. 163 //! \param [in] str 164 //! string to be added. 165 //! \param [in] maxCount 166 //! size of the buffer pointed by str. 167 //! \return void 168 //! No return value. Handle all exception inside the function. 169 //! 170 static void TraceMessage(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, const char *str, uint32_t maxCount); 171 172 //! 173 //! \brief Add vp kernel info to oca log section. 174 //! \param [in] cmdBuffer 175 //! Command buffer for current BB. 176 //! \param [in] osInterface 177 //! Reference to MOS_INTERFACE. 178 //! \param [in] res 179 //! Reference to MOS_RESOURCE. 180 //! \param [in] hwCmdType 181 //! Hw command type. 182 //! \param [in] locationInCmd 183 //! Location in command. 184 //! \param [in] offsetInRes 185 //! Offset in resource. 186 //! \return void 187 //! No return value. Handle all exception inside the function. 188 //! 189 static void DumpResourceInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface, MOS_RESOURCE &res, MOS_HW_COMMAND hwCmdType, uint32_t locationInCmd, uint32_t offsetInRes); 190 191 //! 192 //! \brief Trace OCA Sku Value. 193 //! \param [in] cmdBuffer 194 //! Command buffer for current BB. 195 //! \param [in] osInterface 196 //! Reference to MOS_INTERFACE. 197 //! \return void 198 //! No return value. Handle all exception inside the function. 199 //! 200 static void TraceOcaSkuValue(MOS_COMMAND_BUFFER &cmdBuffer, MOS_INTERFACE &osInterface); 201 202 //! 203 //! \brief Add vp kernel info to oca log section. 204 //! \param [in] cmdBuffer 205 //! Command buffer for current BB. 206 //! \param [in] mosContext 207 //! Reference to MOS_CONTEXT. 208 //! \param [in] vpKernelID 209 //! Value of enum VpKernelID. 210 //! \param [in] fcKernelCount 211 //! If vpKernelID == kernelCombinedFc, fcKernelCount is the kernel count for fc, otherwise, it's not used. 212 //! \param [in] fcKernelList 213 //! If vpKernelID == kernelCombinedFc, fcKernelList is the kernel list for fc, otherwise, it's not used. 214 //! \return void 215 //! No return value. Handle all exception inside the function. 216 //! 217 static void DumpVpKernelInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, int vpKernelID, int fcKernelCount, int *fcKernelList); 218 219 //! 220 //! \brief Add vp kernel info to oca log section. 221 //! \param [in] cmdBuffer 222 //! Command buffer for current BB. 223 //! \param [in] mosContext 224 //! Reference to MOS_CONTEXT. 225 //! \param [in] pControlValues 226 //! Value of user features. 227 //! \return void 228 //! No return value. Handle all exception inside the function. 229 //! 230 static void DumpVpUserFeautreControlInfo(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, PMOS_OCA_LOG_USER_FEATURE_CONTROL_INFO pControlValues); 231 232 //! 233 //! \brief Add vphal parameters to oca log section. 234 //! \param [in] cmdBuffer 235 //! Command buffer for current BB. 236 //! \param [in] mosContext 237 //! Reference to MOS_CONTEXT. 238 //! \param [in] pVphalDumper 239 //! Pointer to vphal dumper object. 240 //! \return void 241 //! No return value. Handle all exception inside the function. 242 //! 243 static void DumpVphalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pVphalDumper); 244 245 //! 246 //! \brief Add codechal parameters to oca log section. 247 //! \param [in] cmdBuffer 248 //! Command buffer for current BB. 249 //! \param [in] mosContext 250 //! Reference to MOS_CONTEXT. 251 //! \param [in] pCodechalDumper 252 //! Pointer to codechal dumper object. 253 //! \return void 254 //! No return value. Handle all exception inside the function. 255 //! 256 static void DumpCodechalParam(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCodechalDumper, CODECHAL_STANDARD codec); 257 258 //! 259 //! \brief Get large resource dump support state 260 //! \return bool 261 //! Return true when support large reource dump 262 //! 263 static bool IsLargeResouceDumpSupported(); 264 265 //! 266 //! \brief Add cp IO Message to oca log section. 267 //! \param [in] ocaInterface 268 //! Reference to MosOcaInterface. 269 //! \param [in] hOcaBuf 270 //! Reference to MOS_OCA_BUFFER_HANDLE. 271 //! \param [in] mosCtx 272 //! DDI device context. 273 //! \param [in] pCpDumper 274 //! Pointer to cp dumper object. 275 //! \param [in] type 276 //! Cp message type. 277 //! \return void 278 //! No return value. Handle all exception inside the function. 279 //! 280 static void DumpCpIoMsg(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext, void *pCpDumper, int type); 281 282 protected: 283 static MOS_STATUS MhwMiLoadRegisterImmCmd( 284 std::shared_ptr<mhw::mi::Itf> miItf, 285 PMOS_COMMAND_BUFFER pCmdBuffer, 286 MHW_MI_LOAD_REGISTER_IMM_PARAMS *params); 287 288 //! 289 //! \brief Error handle function. 290 //! \param [in] mosCtx 291 //! the ddi device context. 292 //! \param [in] status 293 //! The MOS_STATUS for current error. 294 //! \param [in] funcName 295 //! The failure function name. 296 //! \param [in] lineNumber 297 //! The line number where OnOcaError being called in failure function. 298 //! \return void 299 //! No return value. Handle all exception inside the function. 300 //! 301 static void OnOcaError(MOS_CONTEXT_HANDLE mosContext, MOS_STATUS status, const char *functionName, uint32_t lineNumber); 302 //! 303 //! \brief Get OCA buffer handle from pool. 304 //! \param [in] cmdBuffer 305 //! Command buffer for current BB. 306 //! \param [in] mosContext 307 //! Reference to MOS_CONTEXT. 308 //! \return MOS_OCA_BUFFER_HANDLE 309 //! MOS_OCA_BUFFER_HANDLE. 310 //! 311 static MOS_OCA_BUFFER_HANDLE GetOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT_HANDLE mosContext); 312 313 //! 314 //! \brief Remove OCA buffer handle from pool. 315 //! \param [in] cmdBuffer 316 //! Command buffer for current BB. 317 //! \param [in] mosContext 318 //! Reference to MOS_CONTEXT. 319 //! \return void 320 //! No return value. Handle all exception inside the function. 321 //! 322 static void RemoveOcaBufferHandle(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext); 323 324 //! 325 //! \brief Add cp parameters to oca log section. 326 //! \param [in] ocaInterface 327 //! Reference to MosOcaInterface. 328 //! \param [in] hOcaBuf 329 //! Reference to MOS_OCA_BUFFER_HANDLE. 330 //! \param [in] mosCtx 331 //! DDI device context. 332 //! \param [in] pCpDumper 333 //! Pointer to cp dumper object. 334 //! \return void 335 //! No return value. Handle all exception inside the function. 336 //! 337 static void DumpCpParam(MosOcaInterface &ocaInterface, MOS_OCA_BUFFER_HANDLE &hOcaBuf, PMOS_CONTEXT mosCtx, void *pCpDumper); 338 339 //! 340 //! \brief Oca operation which should be called at the beginning of 1st level batch buffer start. 341 //! \param [in/out] cmdBuffer 342 //! Command buffer for current BB. ocaBufHandle in cmdBuffer will be updated. 343 //! \param [in] mosContext 344 //! Reference to MOS_CONTEXT. 345 //! \param [in] gpuContextHandle 346 //! Gpu context handle 347 //! \return void 348 //! No return value. Handle all exception inside the function. 349 //! 350 static void On1stLevelBBStart(MOS_COMMAND_BUFFER &cmdBuffer, MOS_CONTEXT &mosContext, uint32_t gpuContextHandle); 351 352 static void AddRTLogReource(MOS_COMMAND_BUFFER &cmdBuffer, 353 MOS_CONTEXT_HANDLE mosContext, 354 MOS_INTERFACE &osInterface); 355 356 // Private functions to ensure class singleton. 357 HalOcaInterfaceNext(); 358 HalOcaInterfaceNext(HalOcaInterfaceNext &); 359 HalOcaInterfaceNext& operator= (HalOcaInterfaceNext &); 360 361 MEDIA_CLASS_DEFINE_END(HalOcaInterfaceNext) 362 }; 363 364 365 #endif // __RHAL_OCA_INTERFACE_H__ 366