1 /*
2 * Copyright (c) 2014 - 2018, 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 #include <stdlib.h>
31 #include <utils/debug.h>
32 #include <utils/constants.h>
33 #include <string>
34 #include <algorithm>
35
36 namespace sdm {
37
GetSimulationFlag()38 int Debug::GetSimulationFlag() {
39 int value = 0;
40 DebugHandler::Get()->GetProperty(COMPOSITION_MASK_PROP, &value);
41
42 return value;
43 }
44
GetExternalResolution(char * value)45 bool Debug::GetExternalResolution(char *value) {
46 uint32_t retval = 0;
47 DebugHandler::Get()->GetProperty(HDMI_CONFIG_INDEX_PROP, value);
48 if (value[0]) {
49 retval = 1;
50 }
51
52 return retval;
53 }
54
GetIdleTimeoutMs(uint32_t * active_ms,uint32_t * inactive_ms)55 void Debug::GetIdleTimeoutMs(uint32_t *active_ms, uint32_t *inactive_ms) {
56 int active_val = IDLE_TIMEOUT_ACTIVE_MS;
57 int inactive_val = IDLE_TIMEOUT_INACTIVE_MS;
58
59 DebugHandler::Get()->GetProperty(IDLE_TIME_PROP, &active_val);
60 DebugHandler::Get()->GetProperty(IDLE_TIME_INACTIVE_PROP, &inactive_val);
61
62 *active_ms = UINT32(active_val);
63 *inactive_ms = UINT32(inactive_val);
64 }
65
GetBootAnimLayerCount()66 int Debug::GetBootAnimLayerCount() {
67 int value = 0;
68 DebugHandler::Get()->GetProperty(BOOT_ANIMATION_LAYER_COUNT_PROP, &value);
69
70 return value;
71 }
72
IsRotatorDownScaleDisabled()73 bool Debug::IsRotatorDownScaleDisabled() {
74 int value = 0;
75 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_DOWNSCALE_PROP, &value);
76
77 return (value == 1);
78 }
79
IsDecimationDisabled()80 bool Debug::IsDecimationDisabled() {
81 int value = 0;
82 DebugHandler::Get()->GetProperty(DISABLE_DECIMATION_PROP, &value);
83
84 return (value == 1);
85 }
86
GetMaxPipesPerMixer(DisplayType display_type)87 int Debug::GetMaxPipesPerMixer(DisplayType display_type) {
88 int value = -1;
89 switch (display_type) {
90 case kBuiltIn:
91 DebugHandler::Get()->GetProperty(PRIMARY_MIXER_STAGES_PROP, &value);
92 break;
93 case kPluggable:
94 DebugHandler::Get()->GetProperty(EXTERNAL_MIXER_STAGES_PROP, &value);
95 break;
96 case kVirtual:
97 DebugHandler::Get()->GetProperty(VIRTUAL_MIXER_STAGES_PROP, &value);
98 break;
99 default:
100 break;
101 }
102
103 return value;
104 }
105
GetMaxUpscale()106 int Debug::GetMaxUpscale() {
107 int value = 0;
108 DebugHandler::Get()->GetProperty(MAX_UPSCALE_PROP, &value);
109
110 return value;
111 }
112
IsVideoModeEnabled()113 bool Debug::IsVideoModeEnabled() {
114 int value = 0;
115 DebugHandler::Get()->GetProperty(VIDEO_MODE_PANEL_PROP, &value);
116
117 return (value == 1);
118 }
119
IsRotatorUbwcDisabled()120 bool Debug::IsRotatorUbwcDisabled() {
121 int value = 0;
122 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_UBWC_PROP, &value);
123
124 return (value == 1);
125 }
126
IsRotatorSplitDisabled()127 bool Debug::IsRotatorSplitDisabled() {
128 int value = 0;
129 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_SPLIT_PROP, &value);
130
131 return (value == 1);
132 }
133
IsScalarDisabled()134 bool Debug::IsScalarDisabled() {
135 int value = 0;
136 DebugHandler::Get()->GetProperty(DISABLE_SCALER_PROP, &value);
137
138 return (value == 1);
139 }
140
IsUbwcTiledFrameBuffer()141 bool Debug::IsUbwcTiledFrameBuffer() {
142 int ubwc_disabled = 0;
143 int ubwc_framebuffer = 0;
144
145 DebugHandler::Get()->GetProperty(DISABLE_UBWC_PROP, &ubwc_disabled);
146
147 if (!ubwc_disabled) {
148 DebugHandler::Get()->GetProperty(ENABLE_FB_UBWC_PROP, &ubwc_framebuffer);
149 }
150
151 return (ubwc_framebuffer == 1);
152 }
153
IsAVRDisabled()154 bool Debug::IsAVRDisabled() {
155 int value = 0;
156 DebugHandler::Get()->GetProperty(DISABLE_AVR_PROP, &value);
157
158 return (value == 1);
159 }
160
IsExtAnimDisabled()161 bool Debug::IsExtAnimDisabled() {
162 int value = 0;
163 DebugHandler::Get()->GetProperty(DISABLE_EXTERNAL_ANIMATION_PROP, &value);
164
165 return (value == 1);
166 }
167
IsPartialSplitDisabled()168 bool Debug::IsPartialSplitDisabled() {
169 int value = 0;
170 DebugHandler::Get()->GetProperty(DISABLE_PARTIAL_SPLIT_PROP, &value);
171
172 return (value == 1);
173 }
174
IsSrcSplitPreferred()175 bool Debug::IsSrcSplitPreferred() {
176 int value = 0;
177 DebugHandler::Get()->GetProperty(PREFER_SOURCE_SPLIT_PROP, &value);
178
179 return (value == 1);
180 }
181
GetMixerResolution(uint32_t * width,uint32_t * height)182 DisplayError Debug::GetMixerResolution(uint32_t *width, uint32_t *height) {
183 char value[64] = {};
184
185 int error = DebugHandler::Get()->GetProperty(MIXER_RESOLUTION_PROP, value);
186 if (error != 0) {
187 return kErrorUndefined;
188 }
189
190 std::string str(value);
191
192 *width = UINT32(stoi(str));
193 *height = UINT32(stoi(str.substr(str.find('x') + 1)));
194
195 return kErrorNone;
196 }
197
GetReducedConfig(uint32_t * num_vig_pipes,uint32_t * num_dma_pipes)198 DisplayError Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) {
199 char value[64] = {};
200
201 int error = DebugHandler::Get()->GetProperty(SIMULATED_CONFIG_PROP, value);
202 if (error != 0) {
203 return kErrorUndefined;
204 }
205
206 std::string str(value);
207
208 *num_vig_pipes = UINT32(stoi(str));
209 *num_dma_pipes = UINT32(stoi(str.substr(str.find('x') + 1)));
210
211 return kErrorNone;
212 }
213
GetExtMaxlayers()214 int Debug::GetExtMaxlayers() {
215 int max_external_layers = 0;
216 DebugHandler::Get()->GetProperty(MAX_EXTERNAL_LAYERS_PROP, &max_external_layers);
217
218 return std::max(max_external_layers, 2);
219 }
220
GetProperty(const char * property_name,char * value)221 DisplayError Debug::GetProperty(const char *property_name, char *value) {
222 if (DebugHandler::Get()->GetProperty(property_name, value)) {
223 return kErrorUndefined;
224 }
225
226 return kErrorNone;
227 }
228
GetProperty(const char * property_name,int * value)229 DisplayError Debug::GetProperty(const char *property_name, int *value) {
230 if (DebugHandler::Get()->GetProperty(property_name, value)) {
231 return kErrorUndefined;
232 }
233
234 return kErrorNone;
235 }
236
237 } // namespace sdm
238
239