blob: 05d5c7b4cbdfba4da9c632dbaf1d0ecddcba2f40 [file] [log] [blame]
Dileep Marchyae2a59082015-05-21 13:29:05 -07001/*
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +05302* Copyright (c) 2014 - 2018, 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>
Prabhanjan Kandulaa61a5f82016-08-10 18:42:19 +053034#include <algorithm>
Dileep Marchyae2a59082015-05-21 13:29:05 -070035
36namespace sdm {
37
Naseer Ahmedb3b0a332015-06-05 19:14:32 -040038int Debug::GetSimulationFlag() {
Dileep Marchyae2a59082015-05-21 13:29:05 -070039 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053040 DebugHandler::Get()->GetProperty(COMPOSITION_MASK_PROP, &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070041
42 return value;
43}
44
srikanth rajagopalan5d320c62017-06-05 21:08:57 -070045bool Debug::GetExternalResolution(char *value) {
46 uint32_t retval = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053047 DebugHandler::Get()->GetProperty(HDMI_CONFIG_INDEX_PROP, value);
srikanth rajagopalan5d320c62017-06-05 21:08:57 -070048 if (value[0]) {
49 retval = 1;
50 }
Dileep Marchyae2a59082015-05-21 13:29:05 -070051
srikanth rajagopalan5d320c62017-06-05 21:08:57 -070052 return retval;
Dileep Marchyae2a59082015-05-21 13:29:05 -070053}
54
Dileep Marchyab06308d2017-02-13 09:45:01 +053055void 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;
Dileep Marchyae2a59082015-05-21 13:29:05 -070058
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053059 DebugHandler::Get()->GetProperty(IDLE_TIME_PROP, &active_val);
60 DebugHandler::Get()->GetProperty(IDLE_TIME_INACTIVE_PROP, &inactive_val);
Dileep Marchyab06308d2017-02-13 09:45:01 +053061
62 *active_ms = UINT32(active_val);
63 *inactive_ms = UINT32(inactive_val);
Dileep Marchyae2a59082015-05-21 13:29:05 -070064}
65
Siddharth Zaveri918435f2016-01-12 01:05:14 -050066int Debug::GetBootAnimLayerCount() {
67 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053068 DebugHandler::Get()->GetProperty(BOOT_ANIMATION_LAYER_COUNT_PROP, &value);
Siddharth Zaveri918435f2016-01-12 01:05:14 -050069
70 return value;
71}
72
Dileep Marchyae2a59082015-05-21 13:29:05 -070073bool Debug::IsRotatorDownScaleDisabled() {
74 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053075 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_DOWNSCALE_PROP, &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070076
77 return (value == 1);
78}
79
80bool Debug::IsDecimationDisabled() {
81 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053082 DebugHandler::Get()->GetProperty(DISABLE_DECIMATION_PROP, &value);
Dileep Marchyae2a59082015-05-21 13:29:05 -070083
84 return (value == 1);
85}
86
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070087int Debug::GetMaxPipesPerMixer(DisplayType display_type) {
Tatenda Chipeperekwa45b11d22015-05-08 12:12:52 -070088 int value = -1;
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070089 switch (display_type) {
90 case kPrimary:
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053091 DebugHandler::Get()->GetProperty(PRIMARY_MIXER_STAGES_PROP, &value);
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070092 break;
93 case kHDMI:
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053094 DebugHandler::Get()->GetProperty(EXTERNAL_MIXER_STAGES_PROP, &value);
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070095 break;
96 case kVirtual:
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +053097 DebugHandler::Get()->GetProperty(VIRTUAL_MIXER_STAGES_PROP, &value);
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -070098 break;
99 default:
100 break;
101 }
Tatenda Chipeperekwa45b11d22015-05-08 12:12:52 -0700102
103 return value;
104}
105
Rajavenu Kyatham8c305cc2017-03-16 20:17:26 +0530106int Debug::GetMaxUpscale() {
Dileep Marchya694e4b32016-08-08 22:54:13 +0530107 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530108 DebugHandler::Get()->GetProperty(MAX_UPSCALE_PROP, &value);
Dileep Marchya694e4b32016-08-08 22:54:13 +0530109
110 return value;
111}
112
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -0700113bool Debug::IsVideoModeEnabled() {
114 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530115 DebugHandler::Get()->GetProperty(VIDEO_MODE_PANEL_PROP, &value);
Tatenda Chipeperekwa299b0302015-05-27 15:42:49 -0700116
117 return (value == 1);
118}
119
Sushil Chauhanb5e45c42015-06-12 16:50:26 -0700120bool Debug::IsRotatorUbwcDisabled() {
121 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530122 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_UBWC_PROP, &value);
Sushil Chauhanb5e45c42015-06-12 16:50:26 -0700123
124 return (value == 1);
125}
126
Ramkumar Radhakrishnan34508112015-05-28 19:02:05 -0700127bool Debug::IsRotatorSplitDisabled() {
128 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530129 DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_SPLIT_PROP, &value);
Ramkumar Radhakrishnan34508112015-05-28 19:02:05 -0700130
131 return (value == 1);
132}
133
Dileep Marchya511fb6d2015-07-06 11:37:06 -0700134bool Debug::IsScalarDisabled() {
135 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530136 DebugHandler::Get()->GetProperty(DISABLE_SCALER_PROP, &value);
Dileep Marchya511fb6d2015-07-06 11:37:06 -0700137
138 return (value == 1);
139}
140
Sushil Chauhanee1fc7e2015-07-09 17:43:21 -0700141bool Debug::IsUbwcTiledFrameBuffer() {
142 int ubwc_disabled = 0;
143 int ubwc_framebuffer = 0;
144
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530145 DebugHandler::Get()->GetProperty(DISABLE_UBWC_PROP, &ubwc_disabled);
Sushil Chauhanee1fc7e2015-07-09 17:43:21 -0700146
147 if (!ubwc_disabled) {
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530148 DebugHandler::Get()->GetProperty(ENABLE_FB_UBWC_PROP, &ubwc_framebuffer);
Sushil Chauhanee1fc7e2015-07-09 17:43:21 -0700149 }
150
151 return (ubwc_framebuffer == 1);
152}
153
Ramkumar Radhakrishnan14a1fc62016-07-14 20:29:12 -0700154bool Debug::IsAVRDisabled() {
155 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530156 DebugHandler::Get()->GetProperty(DISABLE_AVR_PROP, &value);
Ramkumar Radhakrishnan14a1fc62016-07-14 20:29:12 -0700157
158 return (value == 1);
159}
160
Ray Zhangf2ecade2016-08-12 21:50:53 +0800161bool Debug::IsExtAnimDisabled() {
162 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530163 DebugHandler::Get()->GetProperty(DISABLE_EXTERNAL_ANIMATION_PROP, &value);
Ray Zhangf2ecade2016-08-12 21:50:53 +0800164
165 return (value == 1);
166}
167
Pullakavi Srinivasc1a71ca2017-02-21 11:54:42 +0530168bool Debug::IsPartialSplitDisabled() {
169 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530170 DebugHandler::Get()->GetProperty(DISABLE_PARTIAL_SPLIT_PROP, &value);
Pullakavi Srinivasc1a71ca2017-02-21 11:54:42 +0530171
172 return (value == 1);
173}
174
Sushil Chauhan3d66b2b2017-07-14 13:24:39 -0700175bool Debug::IsSrcSplitPreferred() {
176 int value = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530177 DebugHandler::Get()->GetProperty(PREFER_SOURCE_SPLIT_PROP, &value);
Sushil Chauhan3d66b2b2017-07-14 13:24:39 -0700178
179 return (value == 1);
180}
181
Ramkumar Radhakrishnand3b4c062016-10-06 18:12:21 -0700182DisplayError Debug::GetMixerResolution(uint32_t *width, uint32_t *height) {
Ramkumar Radhakrishnan249e03b2016-10-12 14:13:53 -0700183 char value[64] = {};
Ramkumar Radhakrishnand3b4c062016-10-06 18:12:21 -0700184
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530185 int error = DebugHandler::Get()->GetProperty(MIXER_RESOLUTION_PROP, value);
Dileep Marchya2d586442018-03-09 16:42:40 +0530186 if (error != 0) {
187 return kErrorUndefined;
Ramkumar Radhakrishnand3b4c062016-10-06 18:12:21 -0700188 }
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
Anjaneya Prasad Musunuri0a481102017-07-08 11:17:55 +0530198DisplayError Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) {
199 char value[64] = {};
200
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530201 int error = DebugHandler::Get()->GetProperty(SIMULATED_CONFIG_PROP, value);
Dileep Marchya2d586442018-03-09 16:42:40 +0530202 if (error != 0) {
203 return kErrorUndefined;
Anjaneya Prasad Musunuri0a481102017-07-08 11:17:55 +0530204 }
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
Prabhanjan Kandulaa61a5f82016-08-10 18:42:19 +0530214int Debug::GetExtMaxlayers() {
215 int max_external_layers = 0;
Uday Kiran Pichika2c7883a2018-03-08 20:57:56 +0530216 DebugHandler::Get()->GetProperty(MAX_EXTERNAL_LAYERS_PROP, &max_external_layers);
Prabhanjan Kandulaa61a5f82016-08-10 18:42:19 +0530217
218 return std::max(max_external_layers, 2);
219}
220
Dileep Marchya2d586442018-03-09 16:42:40 +0530221DisplayError Debug::GetProperty(const char *property_name, char *value) {
222 if (DebugHandler::Get()->GetProperty(property_name, value)) {
223 return kErrorUndefined;
Arun Kumar K.R55fe3042015-10-07 00:13:15 -0700224 }
225
Dileep Marchya2d586442018-03-09 16:42:40 +0530226 return kErrorNone;
Arun Kumar K.R55fe3042015-10-07 00:13:15 -0700227}
228
Dileep Marchya2d586442018-03-09 16:42:40 +0530229DisplayError Debug::GetProperty(const char *property_name, int *value) {
230 if (DebugHandler::Get()->GetProperty(property_name, value)) {
231 return kErrorUndefined;
Tatenda Chipeperekwaca8b2f32016-04-27 19:53:22 -0700232 }
233
Dileep Marchya2d586442018-03-09 16:42:40 +0530234 return kErrorNone;
Tatenda Chipeperekwaca8b2f32016-04-27 19:53:22 -0700235}
236
Dileep Marchyae2a59082015-05-21 13:29:05 -0700237} // namespace sdm
238