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 //! 23 //! \file mos_util_debug_specific.h 24 //! \brief 25 //! 26 //! 27 28 #ifndef __MOS_UTIL_DEBUG_SPECIFIC_H__ 29 #define __MOS_UTIL_DEBUG_SPECIFIC_H__ 30 31 #include "mos_defs.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #if MOS_MESSAGES_ENABLED 38 //! 39 //! \brief Define messaging levels here in the order of importance 40 //! 41 typedef enum 42 { 43 MOS_MESSAGE_LVL_DISABLED = 0, 44 MOS_MESSAGE_LVL_CRITICAL = 1, 45 MOS_MESSAGE_LVL_NORMAL = 2, 46 MOS_MESSAGE_LVL_VERBOSE = 3, 47 MOS_MESSAGE_LVL_FUNCTION_ENTRY = 4, 48 MOS_MESSAGE_LVL_FUNCTION_EXIT = 5, 49 MOS_MESSAGE_LVL_FUNCTION_ENTRY_VERBOSE = 6, 50 MOS_MESSAGE_LVL_MEMNINJA = 7, 51 MOS_MESSAGE_LVL_COUNT 52 } MOS_MESSAGE_LEVEL; 53 54 //! 55 //! \brief Define Component IDs 56 //! When adding a component, need to update 57 //! MOS_COMPONENT_ID, 58 //! MOS_ComponentName, 59 //! pcComponentUserFeatureKeys, 60 //! subComponentCount 61 //! and MOS_MESSAGE_COMPONENT_TAG. 62 //! 63 typedef enum 64 { 65 MOS_COMPONENT_OS, 66 MOS_COMPONENT_HW, 67 MOS_COMPONENT_CODEC, 68 MOS_COMPONENT_VP, 69 MOS_COMPONENT_CP, 70 MOS_COMPONENT_DDI, 71 MOS_COMPONENT_CM, 72 MOS_COMPONENT_CPLIB, 73 MOS_COMPONENT_SCALABILITY, 74 MOS_COMPONENT_MMC, 75 MOS_COMPONENT_MCPY, 76 MOS_COMPONENT_COUNT 77 } MOS_COMPONENT_ID; 78 79 //! 80 //! \brief Prints debug messages in debug mode when enabled 81 //! \details Prints debug messages if the level of the comp and sub-comp is 82 //! set to less than the message level. Nop in release version. 83 //! \param MOS_MESSAGE_LEVEL level 84 //! [in] Level of the message 85 //! \param const PCCHAR logtag 86 //! [in] For Linux only, used for tagging the message. 87 //! \param MOS_COMPONENT_ID compID 88 //! [in] Indicates which component 89 //! \param uint8_t subCompID 90 //! [in] Indicates which sub-component 91 //! \param const char *functionName 92 //! [in] pointer to the function name 93 //! \param int32_t lineNum 94 //! [in] Indicates which line the message locate, -1 for no line output 95 //! \param const char *message 96 //! [in] pointer to the message format string 97 //! \param var_args 98 //! [in] variable list of arguments for the message 99 //! \return void 100 //! 101 void MOS_Message( 102 MOS_MESSAGE_LEVEL level, 103 const PCCHAR logtag, 104 MOS_COMPONENT_ID compID, 105 uint8_t subCompID, 106 const PCCHAR functionName, 107 int32_t lineNum, 108 const PCCHAR message, 109 ...); 110 111 #ifndef LOG_TAG 112 #define LOG_TAG "MOS" 113 #endif 114 115 //! 116 //! When printing from a C++ class, we'd like the class and function to be printed. 117 //! With our current Linux compiler, __FUNCTION__ does not include the class name. 118 //! So we use __PRETTY_FUNCTION__ and MOS_Message will remove extra data. 119 //! This is not needed for prints from C files so they will usually use __FUNCTION__. 120 //! 121 122 #if USE_PRETTY_FUNCTION 123 #define MOS_FUNCTION __PRETTY_FUNCTION__ 124 #else 125 #define MOS_FUNCTION __FUNCTION__ 126 #endif // USE_PRETTY_FUNCTION 127 128 //! 129 //! \def MOS_DEBUGMESSAGE(_compID, _subCompID, _message, ...) 130 //! Output DEBUG message \a _message with \_a _compID and \_a _subCompID info 131 //! 132 #define MOS_DEBUGMESSAGE(_level, _compID, _subCompID, _message, ...) \ 133 MOS_Message(_level, LOG_TAG, _compID, _subCompID, MOS_FUNCTION, __LINE__, _message, ##__VA_ARGS__) 134 135 //! 136 //! \def MOS_DEBUGMESSAGE(_compID, _subCompID, _message, ...) 137 //! Output DEBUG message \a _message with \_a _compID and \_a _subCompID info 138 //! 139 #define MOS_DEBUGMESSAGE_NOLINE(_level, _compID, _subCompID, _message, ...) \ 140 MOS_Message(_level, LOG_TAG, _compID, _subCompID, MOS_FUNCTION, -1, _message, ##__VA_ARGS__) 141 142 #endif //MOS_MESSAGES_ENABLED 143 144 #ifdef __cplusplus 145 } 146 #endif 147 148 //! 149 //! \brief HLT file name template 150 //! 151 #define MOS_LOG_PATH_TEMPLATE "%s/igd_%u.%s" 152 #define MOS_COMPONENT_NAME_DDI_STRING "[LIBVA]:" 153 154 //! 155 //! \def MOS_CHK_NULL_WITH_HR(_compID, _subCompID, _ptr) 156 //! Check if \a _ptr == nullptr, if so assert and return an HRESULT error 157 //! 158 #define MOS_CHK_NULL_WITH_HR(_compID, _subCompID, _ptr) \ 159 { \ 160 if ((_ptr) == nullptr) \ 161 { \ 162 MOS_ASSERTMESSAGE(_compID, _subCompID, "Invalid (nullptr) Pointer."); \ 163 hr = MOS_STATUS_NULL_POINTER; \ 164 goto finish; \ 165 } \ 166 } 167 168 #define MOS_DIRECTORY_DELIMITER '/' 169 170 #ifndef ANDROID 171 #define MOS_DEBUG_DEFAULT_OUTPUT_LOCATION "/tmp/codechal_dump/" 172 #else 173 #define MOS_DEBUG_DEFAULT_OUTPUT_LOCATION "/data/codechal_dump/" 174 #endif 175 176 #endif //__MOS_UTIL_DEBUG_SPECIFIC_H__ 177 178