diff options
author | nico <nicorg2529@gmail.com> | 2018-12-13 05:58:17 +0000 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-10-23 01:12:57 +0300 |
commit | 7075241133d606a11966eb9517bc727c4b7115ae (patch) | |
tree | 5391cd2cef4a01b29fc8e3b5b44bb1ea20d3a3ef /utils.c | |
parent | 11a94e360a53939a0a66e67e0b975a9d47e115e1 (diff) | |
download | vendor_qcom_opensource_power-7075241133d606a11966eb9517bc727c4b7115ae.tar.gz vendor_qcom_opensource_power-7075241133d606a11966eb9517bc727c4b7115ae.tar.bz2 vendor_qcom_opensource_power-7075241133d606a11966eb9517bc727c4b7115ae.zip |
power: Find online CPU core and get scaling governor
Change-Id: I90aed1aaee8d3819d1de921674da924efd0a6c4f
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 25 |
1 files changed, 12 insertions, 13 deletions
@@ -46,10 +46,14 @@ #define SOC_ID_0 "/sys/devices/soc0/soc_id" #define SOC_ID_1 "/sys/devices/system/soc/soc0/id" -const char* scaling_gov_path[4] = {"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", +const char* scaling_gov_path[8] = {"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor", "/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor", - "/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"}; + "/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu4/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu5/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu6/cpufreq/scaling_governor", + "/sys/devices/system/cpu/cpu7/cpufreq/scaling_governor"}; #define PERF_HAL_PATH "libqti-perfd-client.so" static void* qcopt_handle; @@ -170,19 +174,14 @@ int sysfs_write(const char* path, char* s) { } int get_scaling_governor(char governor[], int size) { - if (sysfs_read(SCALING_GOVERNOR_PATH, governor, size) == -1) { - // Can't obtain the scaling governor. Return. - return -1; - } else { - // Strip newline at the end. - int len = strlen(governor); - - len--; - - while (len >= 0 && (governor[len] == '\n' || governor[len] == '\r')) governor[len--] = '\0'; + for (size_t i = 0; i < ARRAY_SIZE(scaling_gov_path); i++) { + if (get_scaling_governor_check_cores(governor, size, i) == 0) { + // Obtained the scaling governor. Return. + return 0; + } } - return 0; + return -1; } int get_scaling_governor_check_cores(char governor[], int size, int core_num) { |