• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 };
51 
52 class ExynosDisplay;
53 
54 extern int hwcDebug;
55 extern int hwcFenceDebug[FENCE_IP_ALL];
56 
hwcCheckDebugMessages(uint32_t type)57 inline bool hwcCheckDebugMessages(uint32_t type)
58 {
59     return hwcDebug & type;
60 }
61 
hwcCheckFenceDebug(ExynosDisplay * display,uint32_t fence_type,uint32_t ip_type,int fence)62 inline int hwcCheckFenceDebug(ExynosDisplay *display, uint32_t fence_type, uint32_t ip_type, int fence)
63 {
64     if ((hwcFenceDebug[ip_type] & (1 << fence_type)) && fence_valid(fence))
65         return fence_close(fence, display, FENCE_TYPE_ALL, FENCE_IP_ALL);
66     else
67         return fence;
68 }
69 
70 int32_t saveErrorLog(const android::String8 &errString, ExynosDisplay *display = NULL);
71 
72 #if defined(DISABLE_HWC_DEBUG)
73 #define ALOGD_AND_ATRACE_NAME(debugFlag, fmt, ...)
74 #else
75 #define ALOGD_AND_ATRACE_NAME(debugFlag, fmt, ...)                           \
76     if (hwcCheckDebugMessages(debugFlag) || CC_UNLIKELY(ATRACE_ENABLED())) { \
77         String8 log;                                                         \
78         log.appendFormat((fmt), ##__VA_ARGS__);                              \
79         ALOGD("%s", log.string());                                           \
80         if (CC_UNLIKELY(ATRACE_ENABLED())) ATRACE_NAME(log.string());        \
81     }
82 #endif
83 
84 #if defined(DISABLE_HWC_DEBUG)
85 #define HDEBUGLOGD(...)
86 #define HDEBUGLOGV(type,...) \
87         ALOGV(__VA_ARGS__);
88 #define HDEBUGLOGE(type,...) \
89         ALOGE(__VA_ARGS__);
90 #else
91 #define HDEBUGLOGD(type, ...) \
92     {\
93         if (hwcCheckDebugMessages(type)) \
94             ALOGD(__VA_ARGS__); \
95     }
96 #define HDEBUGLOGV(type, ...) \
97         ALOGV(__VA_ARGS__);
98 #define HDEBUGLOGE(type, ...) \
99         ALOGE(__VA_ARGS__);
100 #endif
101 
102 #if defined(DISABLE_HWC_DEBUG)
103 #define DISPLAY_LOGD(...)
104 #define MPP_LOGD(...)
105 #else
106 #define DISPLAY_LOGD(type, msg, ...) \
107     {\
108         if (hwcCheckDebugMessages(type)) \
109             ALOGD("%s:: [%s] " msg, __func__, mDisplayName.string(), ##__VA_ARGS__); \
110     }
111 #define MPP_LOGD(type, msg, ...) \
112     {\
113     if (hwcCheckDebugMessages(type)) \
114         ALOGD("%s:: [%s][%d] " msg, __func__, mName.string(), mLogicalIndex, ##__VA_ARGS__); \
115     }
116 #endif
117 #define DISPLAY_LOGV(msg, ...) ALOGV("[%s] " msg, mDisplayName.string(), ##__VA_ARGS__)
118 #define DISPLAY_LOGI(msg, ...) ALOGI("[%s] " msg, mDisplayName.string(), ##__VA_ARGS__)
119 #define DISPLAY_LOGW(msg, ...) ALOGW("[%s] " msg, mDisplayName.string(), ##__VA_ARGS__)
120 #define DISPLAY_LOGE(msg, ...) \
121     {\
122         ALOGE("[%s] " msg, mDisplayName.string(), ##__VA_ARGS__); \
123         String8 saveString; \
124         saveString.appendFormat(msg, ##__VA_ARGS__); \
125         saveErrorLog(saveString, this); \
126     }
127 
128 #define DISPLAY_DRM_LOGI(msg, ...) \
129     ALOGI("[%s] " msg, mExynosDisplay->mDisplayName.string(), ##__VA_ARGS__)
130 #define DISPLAY_DRM_LOGW(msg, ...) \
131     ALOGW("[%s] " msg, mExynosDisplay->mDisplayName.string(), ##__VA_ARGS__)
132 #define DISPLAY_DRM_LOGE(msg, ...) \
133     ALOGE("[%s] " msg, mExynosDisplay->mDisplayName.string(), ##__VA_ARGS__)
134 
135 #define MPP_LOGV(msg, ...) ALOGV("[%s][%d] " msg, mName.string(), mLogicalIndex, ##__VA_ARGS__)
136 #define MPP_LOGI(msg, ...) ALOGI("[%s][%d] " msg, mName.string(), mLogicalIndex, ##__VA_ARGS__)
137 #define MPP_LOGW(msg, ...) ALOGW("[%s][%d] " msg, mName.string(), mLogicalIndex, ##__VA_ARGS__)
138 #define MPP_LOGE(msg, ...) \
139     {\
140         ALOGE("[%s][%d] " msg, mName.string(), mLogicalIndex, ##__VA_ARGS__); \
141         String8 saveString; \
142         saveString.appendFormat(msg, ##__VA_ARGS__); \
143         saveErrorLog(saveString, mAssignedDisplay); \
144     }
145 
146 #define HWC_LOGE(display, msg, ...) \
147     {\
148         ALOGE(msg, ##__VA_ARGS__); \
149         String8 saveString; \
150         saveString.appendFormat(msg, ##__VA_ARGS__); \
151         saveErrorLog(saveString, display); \
152     }
153 
154 class ScopedTraceEnder {
155 public:
~ScopedTraceEnder()156     ~ScopedTraceEnder() { ATRACE_END(); }
157 };
158 
159 #define ATRACE_FORMAT(fmt, ...)                     \
160     if (CC_UNLIKELY(ATRACE_ENABLED())) {            \
161         String8 traceName;                          \
162         traceName.appendFormat(fmt, ##__VA_ARGS__); \
163         ATRACE_BEGIN(traceName.string());           \
164     }                                               \
165     ScopedTraceEnder traceEnder
166 
167 #define DISPLAY_ATRACE_NAME(name) ATRACE_FORMAT("%s for %s", name, mDisplayTraceName.string())
168 #define DISPLAY_ATRACE_CALL() DISPLAY_ATRACE_NAME(__func__)
169 #define DISPLAY_ATRACE_INT(name, value)                                                     \
170     if (CC_UNLIKELY(ATRACE_ENABLED())) {                                                    \
171         ATRACE_INT(String8::format("%s for %s", name, mDisplayTraceName.string()).string(), \
172                    value);                                                                  \
173     }
174 #define DISPLAY_ATRACE_INT64(name, value)                                                     \
175     if (CC_UNLIKELY(ATRACE_ENABLED())) {                                                      \
176         ATRACE_INT64(String8::format("%s for %s", name, mDisplayTraceName.string()).string(), \
177                      value);                                                                  \
178     }
179 
180 #define DISPLAY_LOGD_AND_ATRACE_NAME(debugFlag, fmt, ...)                    \
181     if (hwcCheckDebugMessages(debugFlag) || CC_UNLIKELY(ATRACE_ENABLED())) { \
182         String8 log;                                                         \
183         log.appendFormat((fmt), ##__VA_ARGS__);                              \
184         DISPLAY_LOGD(debugFlag, "%s", log.string());                         \
185         if (CC_UNLIKELY(ATRACE_ENABLED())) ATRACE_NAME(log.string());        \
186     }
187 
188 #endif
189