| /* |
| * Copyright (c) 2014 - 2018, 2020 The Linux Foundation. All rights reserved. |
| * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions are |
| * met: |
| * * Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * * Redistributions in binary form must reproduce the above |
| * copyright notice, this list of conditions and the following |
| * disclaimer in the documentation and/or other materials provided |
| * with the distribution. |
| * * Neither the name of The Linux Foundation nor the names of its |
| * contributors may be used to endorse or promote products derived |
| * from this software without specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| /* |
| * Changes from Qualcomm Innovation Center are provided under the following license: |
| * |
| * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted (subject to the limitations in the |
| * disclaimer below) provided that the following conditions are met: |
| * |
| * * Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * |
| * * Redistributions in binary form must reproduce the above |
| * copyright notice, this list of conditions and the following |
| * disclaimer in the documentation and/or other materials provided |
| * with the distribution. |
| * |
| * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its |
| * contributors may be used to endorse or promote products derived |
| * from this software without specific prior written permission. |
| * |
| * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE |
| * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT |
| * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
| * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| #include <stdlib.h> |
| #include <utils/debug.h> |
| #include <utils/constants.h> |
| #include <string> |
| #include <algorithm> |
| |
| #ifdef PROFILE_COVERAGE_DATA |
| extern "C" { |
| |
| int __llvm_profile_runtime = 0; |
| |
| void __llvm_profile_try_write_file(void); |
| |
| } |
| #endif |
| |
| namespace sdm { |
| |
| int Debug::GetSimulationFlag() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(COMPOSITION_MASK_PROP, &value); |
| |
| return value; |
| } |
| |
| bool Debug::GetExternalResolution(char *value) { |
| uint32_t retval = 0; |
| DebugHandler::Get()->GetProperty(HDMI_CONFIG_INDEX_PROP, value); |
| if (value[0]) { |
| retval = 1; |
| } |
| |
| return retval; |
| } |
| |
| void Debug::GetIdleTimeoutMs(uint32_t *active_ms, uint32_t *inactive_ms) { |
| int active_val = IDLE_TIMEOUT_ACTIVE_MS; |
| int inactive_val = IDLE_TIMEOUT_INACTIVE_MS; |
| |
| DebugHandler::Get()->GetProperty(IDLE_TIME_PROP, &active_val); |
| DebugHandler::Get()->GetProperty(IDLE_TIME_INACTIVE_PROP, &inactive_val); |
| |
| *active_ms = UINT32(active_val); |
| *inactive_ms = UINT32(inactive_val); |
| } |
| |
| bool Debug::IsRotatorDownScaleDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_DOWNSCALE_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsRotatorEnabledForUi() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(ENABLE_ROTATOR_UI_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsDecimationDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_DECIMATION_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| int Debug::GetMaxPipesPerMixer(DisplayType display_type) { |
| int value = -1; |
| switch (display_type) { |
| case kBuiltIn: |
| DebugHandler::Get()->GetProperty(PRIMARY_MIXER_STAGES_PROP, &value); |
| break; |
| case kPluggable: |
| DebugHandler::Get()->GetProperty(EXTERNAL_MIXER_STAGES_PROP, &value); |
| break; |
| case kVirtual: |
| DebugHandler::Get()->GetProperty(VIRTUAL_MIXER_STAGES_PROP, &value); |
| break; |
| default: |
| break; |
| } |
| |
| return value; |
| } |
| |
| int Debug::GetMaxUpscale() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(MAX_UPSCALE_PROP, &value); |
| |
| return value; |
| } |
| |
| bool Debug::IsVideoModeEnabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(VIDEO_MODE_PANEL_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsRotatorUbwcDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_UBWC_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsRotatorSplitDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_ROTATOR_SPLIT_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsScalarDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_SCALER_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsUbwcTiledFrameBuffer() { |
| int ubwc_disabled = 0; |
| |
| DebugHandler::Get()->GetProperty(DISABLE_UBWC_PROP, &ubwc_disabled); |
| |
| return (ubwc_disabled == 0); |
| } |
| |
| bool Debug::IsAVRDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_AVR_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsExtAnimDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_EXTERNAL_ANIMATION_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsPartialSplitDisabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(DISABLE_PARTIAL_SPLIT_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| bool Debug::IsSrcSplitPreferred() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(PREFER_SOURCE_SPLIT_PROP, &value); |
| |
| return (value == 1); |
| } |
| |
| int Debug::GetMixerResolution(uint32_t *width, uint32_t *height) { |
| char value[64] = {}; |
| |
| int error = DebugHandler::Get()->GetProperty(MIXER_RESOLUTION_PROP, value); |
| if (error != 0) { |
| return -ENOTSUP; |
| } |
| |
| std::string str(value); |
| |
| *width = UINT32(stoi(str)); |
| *height = UINT32(stoi(str.substr(str.find('x') + 1))); |
| |
| return 0; |
| } |
| |
| int Debug::GetWindowRect(bool primary, float *left, float *top, float *right, float *bottom) { |
| char value[64] = {}; |
| int error = -EINVAL; |
| if (primary) { |
| error = DebugHandler::Get()->GetProperty(WINDOW_RECT_PROP, value); |
| } else { |
| error = DebugHandler::Get()->GetProperty(WINDOW_RECT_PROP_SECONDARY, value); |
| } |
| |
| if (error != 0) { |
| return -EINVAL; |
| } |
| |
| std::string str(value); |
| *left = FLOAT(stof(str)); |
| str = (str.substr(str.find(',') + 1)); |
| *top = FLOAT(stof(str)); |
| str = (str.substr(str.find(',') + 1)); |
| *right = FLOAT(stof(str)); |
| str = (str.substr(str.find(',') + 1)); |
| *bottom = FLOAT(stof(str)); |
| |
| if (*left < 0 || *top < 0 || *right < 0 || *bottom < 0) { |
| *left = *top = *right = *bottom = 0; |
| } |
| |
| return 0; |
| } |
| |
| int Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) { |
| char value[64] = {}; |
| |
| int error = DebugHandler::Get()->GetProperty(SIMULATED_CONFIG_PROP, value); |
| if (error != 0) { |
| return -ENOTSUP; |
| } |
| |
| std::string str(value); |
| |
| *num_vig_pipes = UINT32(stoi(str)); |
| *num_dma_pipes = UINT32(stoi(str.substr(str.find('x') + 1))); |
| |
| return 0; |
| } |
| |
| int Debug::GetSecondaryMaxFetchLayers() { |
| int max_secondary_fetch_layers = 0; |
| DebugHandler::Get()->GetProperty(MAX_SECONDARY_FETCH_LAYERS_PROP, &max_secondary_fetch_layers); |
| |
| return std::max(max_secondary_fetch_layers, 2); |
| } |
| |
| bool Debug::IsIWEEnabled() { |
| int value = 0; |
| DebugHandler::Get()->GetProperty(ENABLE_INLINE_WRITEBACK, &value); |
| |
| return (value == 1); |
| } |
| |
| int Debug::GetProperty(const char *property_name, char *value) { |
| if (DebugHandler::Get()->GetProperty(property_name, value)) { |
| return -ENOTSUP; |
| } |
| |
| return 0; |
| } |
| |
| #ifdef PROFILE_COVERAGE_DATA |
| void Debug::DumpCodeCoverage() { |
| __llvm_profile_try_write_file(); |
| } |
| #endif |
| |
| int Debug::GetProperty(const char *property_name, int *value) { |
| if (DebugHandler::Get()->GetProperty(property_name, value)) { |
| return -ENOTSUP; |
| } |
| |
| return 0; |
| } |
| |
| bool Debug::GetPropertyDisableInlineMode() { |
| char value[64] = "0"; |
| Debug::GetProperty(DISABLE_INLINE_ROTATOR_PROP, value); |
| return (atoi(value) == 1); |
| } |
| |
| bool Debug::GetPropertyDisableOfflineMode() { |
| char value[64] = "0"; |
| Debug::GetProperty(DISABLE_OFFLINE_ROTATOR_PROP, value); |
| return (atoi(value) == 1); |
| } |
| |
| } // namespace sdm |
| |