blob: 4a8e07027afc05a0eefa0a0c2e788d4ed5ca1867 [file] [log] [blame]
Dileep Marchyae2a59082015-05-21 13:29:05 -07001/*
Naseer Ahmedbb069a62016-02-05 20:27:30 -05002* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
Dileep Marchyae2a59082015-05-21 13:29:05 -07003*
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>
Ramkumar Radhakrishnand3b4c062016-10-06 18:12:21 -070033#include <string>
Dileep Marchyae2a59082015-05-21 13:29:05 -070034
35namespace sdm {
36
37Debug Debug::debug_;
38
39Debug::Debug() : debug_handler_(&default_debug_handler_) {
40}
41
Naseer Ahmedb3b0a332015-06-05 19:14:32 -040042int Debug::GetSimulationFlag() {
Dileep Marchyae2a59082015-05-21 13:29:05 -070043 int value = 0;
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070044 debug_.debug_handler_->GetProperty("sdm.composition_simulation", &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070045
46 return value;
47}
48
Naseer Ahmedb3b0a332015-06-05 19:14:32 -040049int Debug::GetHDMIResolution() {
Dileep Marchyae2a59082015-05-21 13:29:05 -070050 int value = 0;
51 debug_.debug_handler_->GetProperty("hw.hdmi.resolution", &value);
52
53 return value;
54}
55
Naseer Ahmedbb069a62016-02-05 20:27:30 -050056uint32_t Debug::GetIdleTimeoutMs() {
Dileep Marchyae2a59082015-05-21 13:29:05 -070057 int value = IDLE_TIMEOUT_DEFAULT_MS;
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070058 debug_.debug_handler_->GetProperty("sdm.idle_time", &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070059
Naseer Ahmedbb069a62016-02-05 20:27:30 -050060 return UINT32(value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070061}
62
Siddharth Zaveri918435f2016-01-12 01:05:14 -050063int Debug::GetBootAnimLayerCount() {
64 int value = 0;
65 debug_.debug_handler_->GetProperty("sdm.boot_anim_layer_count", &value);
66
67 return value;
68}
69
Dileep Marchyae2a59082015-05-21 13:29:05 -070070bool Debug::IsRotatorDownScaleDisabled() {
71 int value = 0;
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070072 debug_.debug_handler_->GetProperty("sdm.debug.rotator_downscale", &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070073
74 return (value == 1);
75}
76
77bool Debug::IsDecimationDisabled() {
78 int value = 0;
79 debug_.debug_handler_->GetProperty("sdm.disable_decimation", &value);
80
81 return (value == 1);
82}
83
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070084int Debug::GetMaxPipesPerMixer(DisplayType display_type) {
Tatenda Chipeperekwa45b11d22015-05-08 12:12:52 -070085 int value = -1;
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070086 switch (display_type) {
87 case kPrimary:
88 debug_.debug_handler_->GetProperty("sdm.primary.mixer_stages", &value);
89 break;
90 case kHDMI:
91 debug_.debug_handler_->GetProperty("sdm.external.mixer_stages", &value);
92 break;
93 case kVirtual:
94 debug_.debug_handler_->GetProperty("sdm.virtual.mixer_stages", &value);
95 break;
96 default:
97 break;
98 }
Tatenda Chipeperekwa45b11d22015-05-08 12:12:52 -070099
100 return value;
101}
102
Dileep Marchya694e4b32016-08-08 22:54:13 +0530103int Debug::GetMaxVideoUpscale() {
104 int value = 0;
105 debug_.debug_handler_->GetProperty("sdm.video_max_upscale", &value);
106
107 return value;
108}
109
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -0700110bool Debug::IsVideoModeEnabled() {
111 int value = 0;
112 debug_.debug_handler_->GetProperty("sdm.video_mode_panel", &value);
113
114 return (value == 1);
115}
116
Sushil Chauhanb5e45c42015-06-12 16:50:26 -0700117bool Debug::IsRotatorUbwcDisabled() {
118 int value = 0;
119 debug_.debug_handler_->GetProperty("sdm.debug.rotator_disable_ubwc", &value);
120
121 return (value == 1);
122}
123
Ramkumar Radhakrishnan34508112015-05-28 19:02:05 -0700124bool Debug::IsRotatorSplitDisabled() {
125 int value = 0;
126 debug_.debug_handler_->GetProperty("sdm.debug.disable_rotator_split", &value);
127
128 return (value == 1);
129}
130
Dileep Marchya511fb6d2015-07-06 11:37:06 -0700131bool Debug::IsScalarDisabled() {
132 int value = 0;
133 debug_.debug_handler_->GetProperty("sdm.debug.disable_scalar", &value);
134
135 return (value == 1);
136}
137
Sushil Chauhanee1fc7e2015-07-09 17:43:21 -0700138bool Debug::IsUbwcTiledFrameBuffer() {
139 int ubwc_disabled = 0;
140 int ubwc_framebuffer = 0;
141
142 debug_.debug_handler_->GetProperty("debug.gralloc.gfx_ubwc_disable", &ubwc_disabled);
143
144 if (!ubwc_disabled) {
145 debug_.debug_handler_->GetProperty("debug.gralloc.enable_fb_ubwc", &ubwc_framebuffer);
146 }
147
148 return (ubwc_framebuffer == 1);
149}
150
Ramkumar Radhakrishnan14a1fc62016-07-14 20:29:12 -0700151bool Debug::IsAVRDisabled() {
152 int value = 0;
153 debug_.debug_handler_->GetProperty("sdm.debug.disable_avr", &value);
154
155 return (value == 1);
156}
157
Ray Zhangf2ecade2016-08-12 21:50:53 +0800158bool Debug::IsExtAnimDisabled() {
159 int value = 0;
160 debug_.debug_handler_->GetProperty("sys.disable_ext_animation", &value);
161
162 return (value == 1);
163}
164
Ramkumar Radhakrishnand3b4c062016-10-06 18:12:21 -0700165DisplayError Debug::GetMixerResolution(uint32_t *width, uint32_t *height) {
166 char value[64];
167
168 DisplayError error = debug_.debug_handler_->GetProperty("sdm.mixer_resolution", value);
169 if (error !=kErrorNone) {
170 return error;
171 }
172
173 std::string str(value);
174
175 *width = UINT32(stoi(str));
176 *height = UINT32(stoi(str.substr(str.find('x') + 1)));
177
178 return kErrorNone;
179}
180
Arun Kumar K.R55fe3042015-10-07 00:13:15 -0700181bool Debug::GetProperty(const char* property_name, char* value) {
182 if (debug_.debug_handler_->GetProperty(property_name, value) != kErrorNone) {
183 return false;
184 }
185
186 return true;
187}
188
Tatenda Chipeperekwaca8b2f32016-04-27 19:53:22 -0700189bool Debug::SetProperty(const char* property_name, const char* value) {
190 if (debug_.debug_handler_->SetProperty(property_name, value) != kErrorNone) {
191 return false;
192 }
193
194 return true;
195}
196
Dileep Marchyae2a59082015-05-21 13:29:05 -0700197} // namespace sdm
198