1 /*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef HWC_DEBUG_H
17 #define HWC_DEBUG_H
18
19 #include <utils/String8.h>
20 #include <utils/Trace.h>
21
22 #include "ExynosHWC.h"
23 #include "ExynosHWCHelper.h"
24
25 enum {
26 eDebugDefault = 0x00000001,
27 eDebugWindowUpdate = 0x00000002,
28 eDebugWinConfig = 0x00000004,
29 eDebugSkipStaicLayer = 0x00000008,
30 eDebugOverlaySupported = 0x00000010,
31 eDebugResourceAssigning = 0x00000020,
32 eDebugFence = 0x00000040,
33 eDebugResourceManager = 0x00000080,
34 eDebugMPP = 0x00000100,
35 eDebugHWC = 0x00000200,
36 eDebugLayer = 0x00000400,
37 eDebugBuf = 0x00000800,
38 eDebugVirtualDisplay = 0x00001000,
39 eDebugCapacity = 0x00002000,
40 eDebugExternalDisplay = 0x00004000,
41 eDebugSkipResourceAssign = 0x00008000,
42 eDebugSkipValidate = 0x00010000,
43 eDebugDynamicRecomp = 0x00020000,
44 eDebugDisplayInterfaceConfig = 0x00040000,
45 eDebugColorManagement = 0x00080000,
46 eDebugAttrSetting = 0x00100000,
47 eDebugDisplayConfig = 0x00400000,
48 eDebugTDM = 0x00800000,
49 eDebugLoadBalancing = 0x01000000,
50 eDebugOperationRate = 0x02000000,
51 };
52
53 class ExynosDisplay;
54
55 extern int hwcDebug;
56 extern int hwcFenceDebug[FENCE_IP_ALL];
57
hwcCheckDebugMessages(uint32_t type)58 inline bool hwcCheckDebugMessages(uint32_t type)
59 {
60 return hwcDebug & type;
61 }
62
hwcCheckFenceDebug(ExynosDisplay * display,uint32_t fence_type,uint32_t ip_type,int fence)63 inline int hwcCheckFenceDebug(ExynosDisplay *display, uint32_t fence_type, uint32_t ip_type, int fence)
64 {
65 if ((hwcFenceDebug[ip_type] & (1 << fence_type)) && fence_valid(fence))
66 return fence_close(fence, display, FENCE_TYPE_ALL, FENCE_IP_ALL);
67 else
68 return fence;
69 }
70
71 int32_t saveErrorLog(const android::String8& errString, const ExynosDisplay* display = NULL);
72
73 #if defined(DISABLE_HWC_DEBUG)
74 #define ALOGD_AND_ATRACE_NAME(debugFlag, fmt, ...)
75 #else
76 #define ALOGD_AND_ATRACE_NAME(debugFlag, fmt, ...) \
77 if (hwcCheckDebugMessages(debugFlag) || CC_UNLIKELY(ATRACE_ENABLED())) { \
78 String8 log; \
79 log.appendFormat((fmt), ##__VA_ARGS__); \
80 ALOGD("%s", log.c_str()); \
81 if (CC_UNLIKELY(ATRACE_ENABLED())) ATRACE_NAME(log.c_str()); \
82 }
83 #endif
84
85 #if defined(DISABLE_HWC_DEBUG)
86 #define HDEBUGLOGD(...)
87 #define HDEBUGLOGV(type,...) \
88 ALOGV(__VA_ARGS__);
89 #define HDEBUGLOGE(type,...) \
90 ALOGE(__VA_ARGS__);
91 #else
92 #define HDEBUGLOGD(type, ...) \
93 {\
94 if (hwcCheckDebugMessages(type)) \
95 ALOGD(__VA_ARGS__); \
96 }
97 #define HDEBUGLOGV(type, ...) \
98 ALOGV(__VA_ARGS__);
99 #define HDEBUGLOGE(type, ...) \
100 ALOGE(__VA_ARGS__);
101 #endif
102
103 #if defined(DISABLE_HWC_DEBUG)
104 #define DISPLAY_LOGD(...)
105 #define DISPLAY_STR_LOGD(...)
106 #define MPP_LOGD(...)
107 #else
108 #define DISPLAY_LOGD(type, msg, ...) \
109 {\
110 if (hwcCheckDebugMessages(type)) \
111 ALOGD("%s:: [%s] " msg, __func__, mDisplayName.c_str(), ##__VA_ARGS__); \
112 }
113 #define DISPLAY_STR_LOGD(dispString, type, msg, ...) \
114 {\
115 if (hwcCheckDebugMessages(type)) \
116 ALOGD("%s:: [%s] " msg, __func__, dispString, ##__VA_ARGS__); \
117 }
118 #define MPP_LOGD(type, msg, ...) \
119 {\
120 if (hwcCheckDebugMessages(type)) \
121 ALOGD("%s:: [%s][%d] " msg, __func__, mName.c_str(), mLogicalIndex, ##__VA_ARGS__); \
122 }
123 #endif
124 #define DISPLAY_LOGV(msg, ...) ALOGV("[%s] " msg, mDisplayName.c_str(), ##__VA_ARGS__)
125 #define DISPLAY_LOGI(msg, ...) ALOGI("[%s] " msg, mDisplayName.c_str(), ##__VA_ARGS__)
126 #define DISPLAY_LOGW(msg, ...) ALOGW("[%s] " msg, mDisplayName.c_str(), ##__VA_ARGS__)
127 #define DISPLAY_LOGE(msg, ...) \
128 {\
129 ALOGE("[%s] " msg, mDisplayName.c_str(), ##__VA_ARGS__); \
130 String8 saveString; \
131 saveString.appendFormat(msg, ##__VA_ARGS__); \
132 saveErrorLog(saveString, this); \
133 }
134
135 #define DISPLAY_DRM_LOGI(msg, ...) \
136 ALOGI("[%s] " msg, mExynosDisplay->mDisplayName.c_str(), ##__VA_ARGS__)
137 #define DISPLAY_DRM_LOGW(msg, ...) \
138 ALOGW("[%s] " msg, mExynosDisplay->mDisplayName.c_str(), ##__VA_ARGS__)
139 #define DISPLAY_DRM_LOGE(msg, ...) \
140 ALOGE("[%s] " msg, mExynosDisplay->mDisplayName.c_str(), ##__VA_ARGS__)
141
142 #define MPP_LOGV(msg, ...) ALOGV("[%s][%d] " msg, mName.c_str(), mLogicalIndex, ##__VA_ARGS__)
143 #define MPP_LOGI(msg, ...) ALOGI("[%s][%d] " msg, mName.c_str(), mLogicalIndex, ##__VA_ARGS__)
144 #define MPP_LOGW(msg, ...) ALOGW("[%s][%d] " msg, mName.c_str(), mLogicalIndex, ##__VA_ARGS__)
145 #define MPP_LOGE(msg, ...) \
146 {\
147 ALOGE("[%s][%d] " msg, mName.c_str(), mLogicalIndex, ##__VA_ARGS__); \
148 String8 saveString; \
149 saveString.appendFormat(msg, ##__VA_ARGS__); \
150 saveErrorLog(saveString, mAssignedDisplay); \
151 }
152
153 #define HWC_LOGE(display, msg, ...) \
154 {\
155 ALOGE(msg, ##__VA_ARGS__); \
156 String8 saveString; \
157 saveString.appendFormat(msg, ##__VA_ARGS__); \
158 saveErrorLog(saveString, display); \
159 }
160
161 class ScopedTraceEnder {
162 public:
~ScopedTraceEnder()163 ~ScopedTraceEnder() { ATRACE_END(); }
164 };
165
166 #define ATRACE_FORMAT(fmt, ...) \
167 if (CC_UNLIKELY(ATRACE_ENABLED())) { \
168 String8 traceName; \
169 traceName.appendFormat(fmt, ##__VA_ARGS__); \
170 ATRACE_BEGIN(traceName.c_str()); \
171 } \
172 ScopedTraceEnder traceEnder
173
174 #define DISPLAY_ATRACE_NAME(name) ATRACE_FORMAT("%s for %s", name, mDisplayTraceName.c_str())
175 #define DISPLAY_ATRACE_CALL() DISPLAY_ATRACE_NAME(__func__)
176 #define DISPLAY_ATRACE_INT(name, value) \
177 if (CC_UNLIKELY(ATRACE_ENABLED())) { \
178 ATRACE_INT(String8::format("%s for %s", name, mDisplayTraceName.c_str()).c_str(), \
179 value); \
180 }
181 #define DISPLAY_ATRACE_INT64(name, value) \
182 if (CC_UNLIKELY(ATRACE_ENABLED())) { \
183 ATRACE_INT64(String8::format("%s for %s", name, mDisplayTraceName.c_str()).c_str(), \
184 value); \
185 }
186
187 #define DISPLAY_LOGD_AND_ATRACE_NAME(debugFlag, fmt, ...) \
188 if (hwcCheckDebugMessages(debugFlag) || CC_UNLIKELY(ATRACE_ENABLED())) { \
189 String8 log; \
190 log.appendFormat((fmt), ##__VA_ARGS__); \
191 DISPLAY_LOGD(debugFlag, "%s", log.c_str()); \
192 if (CC_UNLIKELY(ATRACE_ENABLED())) ATRACE_NAME(log.c_str()); \
193 }
194
195 #endif
196