1 /* 2 * Copyright (c) 2015 - 2017, The Linux Foundation. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 13 * * Neither the name of The Linux Foundation nor the names of its 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 /*! @file debug_interface.h 31 @brief This file provides the debug interface for display manager. 32 */ 33 #ifndef __DEBUG_INTERFACE_H__ 34 #define __DEBUG_INTERFACE_H__ 35 36 namespace sdm { 37 38 /*! @brief This enum represents different modules/logical unit tags that a log message may 39 be associated with. Client may use this to filter messages for dynamic logging. 40 41 @sa DebugHandler 42 */ 43 enum DebugTag { 44 kTagNone, //!< Debug log is not tagged. This type of logs should always be printed. 45 kTagResources, //!< Debug log is tagged for resource management. 46 kTagStrategy, //!< Debug log is tagged for strategy decisions. 47 kTagCompManager, //!< Debug log is tagged for composition manager. 48 kTagDriverConfig, //!< Debug log is tagged for driver config. 49 kTagRotator, //!< Debug log is tagged for rotator. 50 kTagScalar, //!< Debug log is tagged for Scalar Helper. 51 kTagQDCM, //!< Debug log is tagged for display QDCM color managing. 52 kTagQOSClient, //!< Debug log is tagged for Qos client 53 }; 54 55 /*! @brief Display debug handler class. 56 57 @details This class defines display debug handler. The handle contains methods which client 58 should implement to get different levels of logging/tracing from display manager. Display manager 59 will call into these methods at appropriate times to send logging/tracing information. 60 61 @sa CoreInterface::CreateCore 62 */ 63 class DebugHandler { 64 public: 65 /*! @brief Method to handle error messages. 66 67 @param[in] tag \link DebugTag \endlink 68 @param[in] format \link message format with variable argument list \endlink 69 */ 70 virtual void Error(DebugTag tag, const char *format, ...) = 0; 71 72 /*! @brief Method to handle warning messages. 73 74 @param[in] tag \link DebugTag \endlink 75 @param[in] format \link message format with variable argument list \endlink 76 */ 77 virtual void Warning(DebugTag tag, const char *format, ...) = 0; 78 79 /*! @brief Method to handle informative messages. 80 81 @param[in] tag \link DebugTag \endlink 82 @param[in] format \link message format with variable argument list \endlink 83 */ 84 virtual void Info(DebugTag tag, const char *format, ...) = 0; 85 86 /*! @brief Method to handle debug messages. 87 88 @param[in] tag \link DebugTag \endlink 89 @param[in] format \link message format with variable argument list \endlink 90 */ 91 virtual void Debug(DebugTag tag, const char *format, ...) = 0; 92 93 /*! @brief Method to handle verbose messages. 94 95 @param[in] tag \link DebugTag \endlink 96 @param[in] format \link message format with variable argument list \endlink 97 */ 98 virtual void Verbose(DebugTag tag, const char *format, ...) = 0; 99 100 /*! @brief Method to begin trace for a module/logical unit. 101 102 @param[in] class_name \link name of the class that the function belongs to \endlink 103 @param[in] function_name \link name of the function to be traced \endlink 104 @param[in] custom_string \link custom string for multiple traces within a function \endlink 105 */ 106 virtual void BeginTrace(const char *class_name, const char *function_name, 107 const char *custom_string) = 0; 108 109 /*! @brief Method to end trace for a module/logical unit. 110 */ 111 virtual void EndTrace() = 0; 112 113 /*! @brief Method to get property value corresponding to give string. 114 115 @param[in] property_name name of the property 116 @param[out] integer converted value corresponding to the property name 117 118 @return \link DisplayError \endlink 119 */ 120 virtual DisplayError GetProperty(const char *property_name, int *value) = 0; 121 122 /*! @brief Method to get property value corresponding to give string. 123 124 @param[in] property_name name of the property 125 @param[out] string value corresponding to the property name 126 127 @return \link DisplayError \endlink 128 */ 129 virtual DisplayError GetProperty(const char *property_name, char *value) = 0; 130 131 /*! @brief Method to set a property to a given string value. 132 133 @param[in] property_name name of the property 134 @param[in] value new value of the property name 135 136 @return \link DisplayError \endlink 137 */ 138 virtual DisplayError SetProperty(const char *property_name, const char *value) = 0; 139 140 protected: 141 virtual ~DebugHandler() { } 142 }; 143 144 /*! @brief Scope tracer template class. 145 146 @details This class template implements the funtionality to capture the trace for function/ 147 module. It starts the trace upon object creation and ends the trace upon object destruction. 148 */ 149 template <class T> 150 class ScopeTracer { 151 public: 152 ScopeTracer(const char *class_name, const char *function_name) { 153 T::Get()->BeginTrace(class_name, function_name, ""); 154 } 155 156 ~ScopeTracer() { T::Get()->EndTrace(); } 157 }; 158 159 } // namespace sdm 160 161 #endif // __DEBUG_INTERFACE_H__ 162 163 164 165