1 /* 2 * Copyright (c) 2011-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 codechal_debug.h 24 //! \brief Defines the debug interface shared by codec only. 25 //! \details The debug interface dumps output from Media based on in input config file. 26 //! 27 #ifndef __CODEC_DEBUG_H__ 28 #define __CODEC_DEBUG_H__ 29 30 #include "media_debug_interface.h" 31 32 #if USE_MEDIA_DEBUG_TOOL 33 34 #define USE_CODECHAL_DEBUG_TOOL 1 35 #define CODECHAL_DEBUG_TOOL(expr) expr; 36 37 typedef struct _CODECHAL_DBG_CFG CODECHAL_DBG_CFG, *PCODECHAL_DBG_CFG; 38 39 namespace CodechalDbgFieldType = MediaDbgFieldType; 40 namespace CodechalDbgExtType = MediaDbgExtType; 41 namespace CodechalDbgSurfaceType = MediaDbgSurfaceType; 42 namespace CodechalDbgBufferType = MediaDbgBufferType; 43 namespace CodechalDbgAttr = MediaDbgAttr; 44 namespace CodechalDbgKernel = MediaDbgKernel; 45 46 //------------------------------------------------------------------------------ 47 // Macros specific to MOS_CODEC_SUBCOMP_DEBUG sub-comp 48 //------------------------------------------------------------------------------ 49 #define CODECHAL_DEBUG_ASSERT(_expr) \ 50 MOS_ASSERT(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _expr) 51 52 #define CODECHAL_DEBUG_ASSERTMESSAGE(_message, ...) \ 53 MOS_ASSERTMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _message, ##__VA_ARGS__) 54 55 #define CODECHAL_DEBUG_NORMALMESSAGE(_message, ...) \ 56 MOS_NORMALMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _message, ##__VA_ARGS__) 57 58 #define CODECHAL_DEBUG_VERBOSEMESSAGE(_message, ...) \ 59 MOS_VERBOSEMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _message, ##__VA_ARGS__) 60 61 #define CODECHAL_DEBUG_FUNCTION_ENTER \ 62 MOS_FUNCTION_ENTER(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG) 63 64 #define CODECHAL_DEBUG_CHK_STATUS(_stmt) \ 65 MOS_CHK_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _stmt) 66 67 #define CODECHAL_DEBUG_CHK_STATUS_MESSAGE(_stmt, _message, ...) \ 68 MOS_CHK_STATUS_MESSAGE_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _stmt, _message, ##__VA_ARGS__) 69 70 #define CODECHAL_DEBUG_CHK_NULL(_ptr) \ 71 MOS_CHK_NULL_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _ptr) 72 73 #define CODECHAL_DEBUG_CHK_NULL_NO_STATUS(_ptr) \ 74 MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DEBUG, _ptr) 75 76 enum CodechalHucRegionDumpType 77 { 78 hucRegionDumpDefault = 0, 79 hucRegionDumpInit = 1, 80 hucRegionDumpUpdate = 2, 81 hucRegionDumpRegionLocked = 3, 82 hucRegionDumpCmdInitializer = 4, 83 hucRegionDumpPakIntegrate = 5, 84 hucRegionDumpHpu = 6, 85 hucRegionDumpBackAnnotation = 7, 86 hucRegionDumpHpuSuperFrame = 8 87 }; 88 89 typedef struct _CODECHAL_ME_OUTPUT_PARAMS 90 { 91 PMOS_SURFACE psMeMvBuffer; 92 PMOS_SURFACE psMeBrcDistortionBuffer; 93 PMOS_SURFACE psMeDistortionBuffer; 94 PMOS_RESOURCE pResVdenStreamInBuffer; 95 bool b16xMeInUse; 96 bool b32xMeInUse; 97 bool bVdencStreamInInUse; 98 } CODECHAL_ME_OUTPUT_PARAMS, *PCODECHAL_ME_OUTPUT_PARAMS; 99 100 class MediaDebugInterface; 101 class CodechalDebugInterface : public MediaDebugInterface 102 { 103 public: 104 CodechalDebugInterface(); 105 virtual ~CodechalDebugInterface(); 106 107 virtual MOS_STATUS Initialize( 108 CodechalHwInterface *hwInterface, 109 CODECHAL_FUNCTION codecFunction); 110 111 MOS_STATUS DumpHucDmem( 112 PMOS_RESOURCE dmemResource, 113 uint32_t dmemSize, 114 uint32_t hucPassNum, 115 CodechalHucRegionDumpType dumpType); 116 117 MOS_STATUS DumpHucRegion( 118 PMOS_RESOURCE region, 119 uint32_t regionOffset, 120 uint32_t regionSize, 121 uint32_t regionNum, 122 const char * regionName, 123 bool inputBuffer, 124 uint32_t hucPassNum, 125 CodechalHucRegionDumpType dumpType); 126 127 MOS_STATUS DetectCorruptionSw(std::vector<MOS_RESOURCE>& vResource, PMOS_RESOURCE frameCntRes, uint8_t *buf, uint32_t &size, uint32_t frameNum); 128 129 MOS_STATUS DumpEncodeStatusReport( 130 void* report); 131 132 MOS_STATUS DumpEncodeStatusReport( 133 const struct EncodeStatusReport *report); 134 135 void CheckGoldenReferenceExist(); 136 137 CodechalHwInterface *m_hwInterface = nullptr; 138 CODECHAL_FUNCTION m_codecFunction = CODECHAL_FUNCTION_INVALID; 139 PCODECHAL_DBG_CFG m_dbgCfgHead = nullptr; 140 141 protected: 142 MOS_USER_FEATURE_VALUE_ID SetOutputPathKey() override; 143 MOS_USER_FEATURE_VALUE_ID InitDefaultOutput() override; 144 uint8_t *m_decodeOutputBuf = nullptr; 145 }; 146 147 class CodechalDebugInterfaceG12 :public CodechalDebugInterface 148 { 149 public: 150 CodechalDebugInterfaceG12(); 151 virtual ~CodechalDebugInterfaceG12(); 152 153 MOS_STATUS DumpYUVSurface( 154 PMOS_SURFACE surface, 155 const char * attrName, 156 const char * surfName, 157 MEDIA_DEBUG_STATE_TYPE mediaState = CODECHAL_NUM_MEDIA_STATES, 158 uint32_t width_in = 0, 159 uint32_t height_in = 0) override; 160 }; 161 #else 162 #define USE_CODECHAL_DEBUG_TOOL 0 163 #define CODECHAL_DEBUG_TOOL(expr) ; 164 165 #endif // USE_MEDIA_DEBUG_TOOL 166 #endif /* __MEDIA_DEBUG_H__ */ 167