Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 1 | /* |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 2 | * Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved. |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 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> |
Ramkumar Radhakrishnan | d3b4c06 | 2016-10-06 18:12:21 -0700 | [diff] [blame] | 33 | #include <string> |
Prabhanjan Kandula | a61a5f8 | 2016-08-10 18:42:19 +0530 | [diff] [blame] | 34 | #include <algorithm> |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 35 | |
| 36 | namespace sdm { |
| 37 | |
Naseer Ahmed | b3b0a33 | 2015-06-05 19:14:32 -0400 | [diff] [blame] | 38 | int Debug::GetSimulationFlag() { |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 39 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 40 | DebugHandler::Get()->GetProperty(COMPOSITION_MASK_PROP, &value); |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 41 | |
| 42 | return value; |
| 43 | } |
| 44 | |
srikanth rajagopalan | 5d320c6 | 2017-06-05 21:08:57 -0700 | [diff] [blame] | 45 | bool Debug::GetExternalResolution(char *value) { |
| 46 | uint32_t retval = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 47 | DebugHandler::Get()->GetProperty(HDMI_CONFIG_INDEX_PROP, value); |
srikanth rajagopalan | 5d320c6 | 2017-06-05 21:08:57 -0700 | [diff] [blame] | 48 | if (value[0]) { |
| 49 | retval = 1; |
| 50 | } |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 51 | |
srikanth rajagopalan | 5d320c6 | 2017-06-05 21:08:57 -0700 | [diff] [blame] | 52 | return retval; |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Dileep Marchya | b06308d | 2017-02-13 09:45:01 +0530 | [diff] [blame] | 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; |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 58 | |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 59 | DebugHandler::Get()->GetProperty(IDLE_TIME_PROP, &active_val); |
| 60 | DebugHandler::Get()->GetProperty(IDLE_TIME_INACTIVE_PROP, &inactive_val); |
Dileep Marchya | b06308d | 2017-02-13 09:45:01 +0530 | [diff] [blame] | 61 | |
| 62 | *active_ms = UINT32(active_val); |
| 63 | *inactive_ms = UINT32(inactive_val); |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Siddharth Zaveri | 918435f | 2016-01-12 01:05:14 -0500 | [diff] [blame] | 66 | int Debug::GetBootAnimLayerCount() { |
| 67 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 68 | DebugHandler::Get()->GetProperty(BOOT_ANIMATION_LAYER_COUNT_PROP, &value); |
Siddharth Zaveri | 918435f | 2016-01-12 01:05:14 -0500 | [diff] [blame] | 69 | |
| 70 | return value; |
| 71 | } |
| 72 | |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 73 | bool Debug::IsRotatorDownScaleDisabled() { |
| 74 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 75 | DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_DOWNSCALE_PROP, &value); |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 76 | |
| 77 | return (value == 1); |
| 78 | } |
| 79 | |
| 80 | bool Debug::IsDecimationDisabled() { |
| 81 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 82 | DebugHandler::Get()->GetProperty(DISABLE_DECIMATION_PROP, &value); |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 83 | |
| 84 | return (value == 1); |
| 85 | } |
| 86 | |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 87 | int Debug::GetMaxPipesPerMixer(DisplayType display_type) { |
Tatenda Chipeperekwa | 45b11d2 | 2015-05-08 12:12:52 -0700 | [diff] [blame] | 88 | int value = -1; |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 89 | switch (display_type) { |
| 90 | case kPrimary: |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 91 | DebugHandler::Get()->GetProperty(PRIMARY_MIXER_STAGES_PROP, &value); |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 92 | break; |
| 93 | case kHDMI: |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 94 | DebugHandler::Get()->GetProperty(EXTERNAL_MIXER_STAGES_PROP, &value); |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 95 | break; |
| 96 | case kVirtual: |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 97 | DebugHandler::Get()->GetProperty(VIRTUAL_MIXER_STAGES_PROP, &value); |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 98 | break; |
| 99 | default: |
| 100 | break; |
| 101 | } |
Tatenda Chipeperekwa | 45b11d2 | 2015-05-08 12:12:52 -0700 | [diff] [blame] | 102 | |
| 103 | return value; |
| 104 | } |
| 105 | |
Rajavenu Kyatham | 8c305cc | 2017-03-16 20:17:26 +0530 | [diff] [blame] | 106 | int Debug::GetMaxUpscale() { |
Dileep Marchya | 694e4b3 | 2016-08-08 22:54:13 +0530 | [diff] [blame] | 107 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 108 | DebugHandler::Get()->GetProperty(MAX_UPSCALE_PROP, &value); |
Dileep Marchya | 694e4b3 | 2016-08-08 22:54:13 +0530 | [diff] [blame] | 109 | |
| 110 | return value; |
| 111 | } |
| 112 | |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 113 | bool Debug::IsVideoModeEnabled() { |
| 114 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 115 | DebugHandler::Get()->GetProperty(VIDEO_MODE_PANEL_PROP, &value); |
Tatenda Chipeperekwa | 299b030 | 2015-05-27 15:42:49 -0700 | [diff] [blame] | 116 | |
| 117 | return (value == 1); |
| 118 | } |
| 119 | |
Sushil Chauhan | b5e45c4 | 2015-06-12 16:50:26 -0700 | [diff] [blame] | 120 | bool Debug::IsRotatorUbwcDisabled() { |
| 121 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 122 | DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_UBWC_PROP, &value); |
Sushil Chauhan | b5e45c4 | 2015-06-12 16:50:26 -0700 | [diff] [blame] | 123 | |
| 124 | return (value == 1); |
| 125 | } |
| 126 | |
Ramkumar Radhakrishnan | 3450811 | 2015-05-28 19:02:05 -0700 | [diff] [blame] | 127 | bool Debug::IsRotatorSplitDisabled() { |
| 128 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 129 | DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_SPLIT_PROP, &value); |
Ramkumar Radhakrishnan | 3450811 | 2015-05-28 19:02:05 -0700 | [diff] [blame] | 130 | |
| 131 | return (value == 1); |
| 132 | } |
| 133 | |
Dileep Marchya | 511fb6d | 2015-07-06 11:37:06 -0700 | [diff] [blame] | 134 | bool Debug::IsScalarDisabled() { |
| 135 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 136 | DebugHandler::Get()->GetProperty(DISABLE_SCALER_PROP, &value); |
Dileep Marchya | 511fb6d | 2015-07-06 11:37:06 -0700 | [diff] [blame] | 137 | |
| 138 | return (value == 1); |
| 139 | } |
| 140 | |
Sushil Chauhan | ee1fc7e | 2015-07-09 17:43:21 -0700 | [diff] [blame] | 141 | bool Debug::IsUbwcTiledFrameBuffer() { |
| 142 | int ubwc_disabled = 0; |
| 143 | int ubwc_framebuffer = 0; |
| 144 | |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 145 | DebugHandler::Get()->GetProperty(DISABLE_UBWC_PROP, &ubwc_disabled); |
Sushil Chauhan | ee1fc7e | 2015-07-09 17:43:21 -0700 | [diff] [blame] | 146 | |
| 147 | if (!ubwc_disabled) { |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 148 | DebugHandler::Get()->GetProperty(ENABLE_FB_UBWC_PROP, &ubwc_framebuffer); |
Sushil Chauhan | ee1fc7e | 2015-07-09 17:43:21 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | return (ubwc_framebuffer == 1); |
| 152 | } |
| 153 | |
Ramkumar Radhakrishnan | 14a1fc6 | 2016-07-14 20:29:12 -0700 | [diff] [blame] | 154 | bool Debug::IsAVRDisabled() { |
| 155 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 156 | DebugHandler::Get()->GetProperty(DISABLE_AVR_PROP, &value); |
Ramkumar Radhakrishnan | 14a1fc6 | 2016-07-14 20:29:12 -0700 | [diff] [blame] | 157 | |
| 158 | return (value == 1); |
| 159 | } |
| 160 | |
Ray Zhang | f2ecade | 2016-08-12 21:50:53 +0800 | [diff] [blame] | 161 | bool Debug::IsExtAnimDisabled() { |
| 162 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 163 | DebugHandler::Get()->GetProperty(DISABLE_EXTERNAL_ANIMATION_PROP, &value); |
Ray Zhang | f2ecade | 2016-08-12 21:50:53 +0800 | [diff] [blame] | 164 | |
| 165 | return (value == 1); |
| 166 | } |
| 167 | |
Pullakavi Srinivas | c1a71ca | 2017-02-21 11:54:42 +0530 | [diff] [blame] | 168 | bool Debug::IsPartialSplitDisabled() { |
| 169 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 170 | DebugHandler::Get()->GetProperty(DISABLE_PARTIAL_SPLIT_PROP, &value); |
Pullakavi Srinivas | c1a71ca | 2017-02-21 11:54:42 +0530 | [diff] [blame] | 171 | |
| 172 | return (value == 1); |
| 173 | } |
| 174 | |
Sushil Chauhan | 3d66b2b | 2017-07-14 13:24:39 -0700 | [diff] [blame] | 175 | bool Debug::IsSrcSplitPreferred() { |
| 176 | int value = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 177 | DebugHandler::Get()->GetProperty(PREFER_SOURCE_SPLIT_PROP, &value); |
Sushil Chauhan | 3d66b2b | 2017-07-14 13:24:39 -0700 | [diff] [blame] | 178 | |
| 179 | return (value == 1); |
| 180 | } |
| 181 | |
Ramkumar Radhakrishnan | d3b4c06 | 2016-10-06 18:12:21 -0700 | [diff] [blame] | 182 | DisplayError Debug::GetMixerResolution(uint32_t *width, uint32_t *height) { |
Ramkumar Radhakrishnan | 249e03b | 2016-10-12 14:13:53 -0700 | [diff] [blame] | 183 | char value[64] = {}; |
Ramkumar Radhakrishnan | d3b4c06 | 2016-10-06 18:12:21 -0700 | [diff] [blame] | 184 | |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 185 | int error = DebugHandler::Get()->GetProperty(MIXER_RESOLUTION_PROP, value); |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 186 | if (error != 0) { |
| 187 | return kErrorUndefined; |
Ramkumar Radhakrishnan | d3b4c06 | 2016-10-06 18:12:21 -0700 | [diff] [blame] | 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 | |
Anjaneya Prasad Musunuri | 0a48110 | 2017-07-08 11:17:55 +0530 | [diff] [blame] | 198 | DisplayError Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) { |
| 199 | char value[64] = {}; |
| 200 | |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 201 | int error = DebugHandler::Get()->GetProperty(SIMULATED_CONFIG_PROP, value); |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 202 | if (error != 0) { |
| 203 | return kErrorUndefined; |
Anjaneya Prasad Musunuri | 0a48110 | 2017-07-08 11:17:55 +0530 | [diff] [blame] | 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 | |
Prabhanjan Kandula | a61a5f8 | 2016-08-10 18:42:19 +0530 | [diff] [blame] | 214 | int Debug::GetExtMaxlayers() { |
| 215 | int max_external_layers = 0; |
Uday Kiran Pichika | 2c7883a | 2018-03-08 20:57:56 +0530 | [diff] [blame] | 216 | DebugHandler::Get()->GetProperty(MAX_EXTERNAL_LAYERS_PROP, &max_external_layers); |
Prabhanjan Kandula | a61a5f8 | 2016-08-10 18:42:19 +0530 | [diff] [blame] | 217 | |
| 218 | return std::max(max_external_layers, 2); |
| 219 | } |
| 220 | |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 221 | DisplayError Debug::GetProperty(const char *property_name, char *value) { |
| 222 | if (DebugHandler::Get()->GetProperty(property_name, value)) { |
| 223 | return kErrorUndefined; |
Arun Kumar K.R | 55fe304 | 2015-10-07 00:13:15 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 226 | return kErrorNone; |
Arun Kumar K.R | 55fe304 | 2015-10-07 00:13:15 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 229 | DisplayError Debug::GetProperty(const char *property_name, int *value) { |
| 230 | if (DebugHandler::Get()->GetProperty(property_name, value)) { |
| 231 | return kErrorUndefined; |
Tatenda Chipeperekwa | ca8b2f3 | 2016-04-27 19:53:22 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Dileep Marchya | 2d58644 | 2018-03-09 16:42:40 +0530 | [diff] [blame] | 234 | return kErrorNone; |
Tatenda Chipeperekwa | ca8b2f3 | 2016-04-27 19:53:22 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Dileep Marchya | e2a5908 | 2015-05-21 13:29:05 -0700 | [diff] [blame] | 237 | } // namespace sdm |
| 238 | |