diff options
| author | Max Weffers <rcstar6696@gmail.com> | 2017-05-28 12:59:13 +0200 |
|---|---|---|
| committer | Hemant Sharma <hemantbeast@gmail.com> | 2017-06-03 08:44:49 +0000 |
| commit | 6f5564a7cf9950e812689123c1109cc377a51bd2 (patch) | |
| tree | 8b2af93cc79187f3329d03ef875da36ba294509c | |
| parent | 143672e3e7843b44f484302728cedec3413f370c (diff) | |
s2: power: Add CPUQuiet config as an extension from QCOM Powerhal
Change-Id: I99573312f9294034727ef70e04aa954804462f79
| -rw-r--r-- | BoardConfig.mk | 2 | ||||
| -rw-r--r-- | power/power_ext.c | 111 | ||||
| -rw-r--r-- | rootdir/init.qcom.power.rc | 15 | ||||
| -rwxr-xr-x | rootdir/init.target.rc | 3 | ||||
| -rw-r--r-- | system.prop | 15 |
5 files changed, 143 insertions, 3 deletions
diff --git a/BoardConfig.mk b/BoardConfig.mk index d792545..96af4be 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -87,6 +87,8 @@ TARGET_RECOVERY_DEVICE_MODULES := libinit_s2 BOARD_USES_QCOM_HARDWARE := true BOARD_USES_QC_TIME_SERVICES := true TARGET_POWERHAL_VARIANT := qcom +CM_POWERHAL_EXTENSION := qcom +TARGET_POWERHAL_SET_INTERACTIVE_EXT := device/leeco/s2/power/power_ext.c # RIL BOARD_PROVIDES_LIBRIL := true diff --git a/power/power_ext.c b/power/power_ext.c new file mode 100644 index 0000000..4d5521a --- /dev/null +++ b/power/power_ext.c @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2016 Adam Farden + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <errno.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#define LOG_TAG "CPUQuiet PowerHAL" +#include <cutils/properties.h> +#include <utils/Log.h> + +#include <hardware/hardware.h> +#include <hardware/power.h> + +#define CPUQUIET_MIN_CPUS "/sys/devices/system/cpu/cpuquiet/nr_min_cpus" +#define CPUQUIET_MAX_CPUS "/sys/devices/system/cpu/cpuquiet/nr_power_max_cpus" +#define CPUQUIET_THERMAL_CPUS "/sys/devices/system/cpu/cpuquiet/nr_thermal_max_cpus" +#define RQBALANCE_BALANCE_LEVEL "/sys/devices/system/cpu/cpuquiet/rqbalance/balance_level" +#define RQBALANCE_UP_THRESHOLD "/sys/devices/system/cpu/cpuquiet/rqbalance/nr_run_thresholds" +#define RQBALANCE_DOWN_THRESHOLD "/sys/devices/system/cpu/cpuquiet/rqbalance/nr_down_run_thresholds" + +#define LOW_MIN_CPUS "cpuquiet.low.min_cpus" +#define LOW_MAX_CPUS "cpuquiet.low.max_cpus" +#define LOW_POWER_BALANCE_LEVEL "rqbalance.low.balance_level" +#define LOW_POWER_UP_THRESHOLD "rqbalance.low.up_threshold" +#define LOW_POWER_DOWN_THRESHOLD "rqbalance.low.down_threshold" + +#define NORMAL_MIN_CPUS "cpuquiet.normal.min_cpus" +#define NORMAL_MAX_CPUS "cpuquiet.normal.max_cpus" +#define NORMAL_POWER_BALANCE_LEVEL "rqbalance.normal.balance_level" +#define NORMAL_POWER_UP_THRESHOLD "rqbalance.normal.up_threshold" +#define NORMAL_POWER_DOWN_THRESHOLD "rqbalance.normal.down_threshold" + +#define PROPERTY_VALUE_MAX 128 + +char low_min_cpus[PROPERTY_VALUE_MAX]; +char low_max_cpus[PROPERTY_VALUE_MAX]; +char low_balance[PROPERTY_VALUE_MAX]; +char low_up[PROPERTY_VALUE_MAX]; +char low_down[PROPERTY_VALUE_MAX]; + +char normal_min_cpus[PROPERTY_VALUE_MAX]; +char normal_max_cpus[PROPERTY_VALUE_MAX]; +char normal_balance[PROPERTY_VALUE_MAX]; +char normal_up[PROPERTY_VALUE_MAX]; +char normal_down[PROPERTY_VALUE_MAX]; + +extern int sysfs_write(char *path, char *s); + +void cm_power_set_interactive_ext(int on) { + + ALOGI("CPUQUIET config loaded"); + + property_get(LOW_MIN_CPUS, low_min_cpus, "0"); + ALOGI("LOW_MIN_CPUS: %s", low_min_cpus); + property_get(LOW_MAX_CPUS, low_max_cpus, "0"); + ALOGI("LOW_MAX_CPUS: %s", low_max_cpus); + property_get(LOW_POWER_BALANCE_LEVEL, low_balance, "0"); + ALOGI("LOW_POWER_BALANCE_LEVEL: %s", low_balance); + property_get(LOW_POWER_UP_THRESHOLD, low_up, "0"); + ALOGI("LOW_POWER_UP_THRESHOLD: %s", low_up); + property_get(LOW_POWER_DOWN_THRESHOLD, low_down, "0"); + ALOGI("LOW_POWER_DOWN_THRESHOLD: %s", low_down); + + property_get(NORMAL_MIN_CPUS, normal_min_cpus, "0"); + ALOGI("NORMAL_MIN_CPUS: %s", normal_min_cpus); + property_get(NORMAL_MAX_CPUS, normal_max_cpus, "0"); + ALOGI("NORMAL_MAX_CPUS: %s", normal_max_cpus); + property_get(NORMAL_POWER_BALANCE_LEVEL, normal_balance, "0"); + ALOGI("NORMAL_POWER_BALANCE_LEVEL: %s", normal_balance); + property_get(NORMAL_POWER_UP_THRESHOLD, normal_up, "0"); + ALOGI("NORMAL_POWER_UP_THRESHOLD: %s", normal_up); + property_get(NORMAL_POWER_DOWN_THRESHOLD, normal_down, "0"); + ALOGI("NORMAL_POWER_DOWN_THRESHOLD: %s", normal_down); + + // init thermal maximum prior to setting normal power profile + sysfs_write(CPUQUIET_THERMAL_CPUS, normal_max_cpus); + + if (!on) { + ALOGI("Setting low power mode"); + // MIN before MAX is intentional + sysfs_write(CPUQUIET_MIN_CPUS, low_min_cpus); + sysfs_write(CPUQUIET_MAX_CPUS, low_max_cpus); + sysfs_write(RQBALANCE_BALANCE_LEVEL, low_balance); + sysfs_write(RQBALANCE_UP_THRESHOLD, low_up); + sysfs_write(RQBALANCE_DOWN_THRESHOLD, low_down); + } else { + ALOGI("Setting normal power mode"); + // MAX before MIN is intentional + sysfs_write(CPUQUIET_MAX_CPUS, normal_max_cpus); + sysfs_write(CPUQUIET_MIN_CPUS, normal_min_cpus); + sysfs_write(RQBALANCE_BALANCE_LEVEL, normal_balance); + sysfs_write(RQBALANCE_UP_THRESHOLD, normal_up); + sysfs_write(RQBALANCE_DOWN_THRESHOLD, normal_down); + } +} diff --git a/rootdir/init.qcom.power.rc b/rootdir/init.qcom.power.rc index 5e1c140..37d61ae 100644 --- a/rootdir/init.qcom.power.rc +++ b/rootdir/init.qcom.power.rc @@ -1,3 +1,18 @@ +on init + # cpuquiet rqbalance permissions + chown system system /sys/devices/system/cpu/cpuquiet/nr_min_cpus + chown system system /sys/devices/system/cpu/cpuquiet/nr_power_max_cpus + chown system system /sys/devices/system/cpu/cpuquiet/nr_thermal_max_cpus + chown system system /sys/devices/system/cpu/cpuquiet/rqbalance/balance_level + chown system system /sys/devices/system/cpu/cpuquiet/rqbalance/nr_run_thresholds + chown system system /sys/devices/system/cpu/cpuquiet/rqbalance/nr_down_run_thresholds + chmod 0660 /sys/devices/system/cpu/cpuquiet/nr_min_cpus + chmod 0660 /sys/devices/system/cpu/cpuquiet/nr_power_max_cpus + chmod 0660 /sys/devices/system/cpu/cpuquiet/nr_thermal_max_cpus + chmod 0660 /sys/devices/system/cpu/cpuquiet/rqbalance/balance_level + chmod 0660 /sys/devices/system/cpu/cpuquiet/rqbalance/nr_run_thresholds + chmod 0660 /sys/devices/system/cpu/cpuquiet/rqbalance/nr_down_run_thresholds + on charger mkdir /system diff --git a/rootdir/init.target.rc b/rootdir/init.target.rc index e3ea76b..91e7e93 100755 --- a/rootdir/init.target.rc +++ b/rootdir/init.target.rc @@ -57,9 +57,6 @@ on fs mount vfat /dev/block/bootdevice/by-name/modem /firmware ro context=u:object_r:firmware_file:s0,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337 #write /sys/kernel/boot_adsp/boot 1 - write /sys/devices/system/cpu/cpuquiet/nr_thermal_max_cpus 8 - write /sys/devices/system/cpu/cpuquiet/nr_power_max_cpus 8 - on post-fs-data mkdir /data/tombstones 0771 system system mkdir /tombstones/modem 0771 system system diff --git a/system.prop b/system.prop index 8b93073..95a88fa 100644 --- a/system.prop +++ b/system.prop @@ -242,6 +242,21 @@ ro.qcom.ad.calib.data=/system/etc/ad_calib.cfg # to force call stick on CS (NOT switch to VoLTE) persist.radio.cs_srv_type=1 +# +# rqbalance specific values +# +cpuquiet.low.min_cpus=2 +cpuquiet.low.max_cpus=4 +rqbalance.low.balance_level=80 +rqbalance.low.up_threshold=200 400 600 4294967295 +rqbalance.low.down_threshold=0 100 300 500 + +cpuquiet.normal.min_cpus=4 +cpuquiet.normal.max_cpus=8 +rqbalance.normal.balance_level=40 +rqbalance.normal.up_threshold=100 250 330 4294967295 +rqbalance.normal.down_threshold=0 130 220 300 + # Hardware Info ro.device.chipset=Qualcomm MSM8976 Snapdragon 652 ro.device.cpu=Octa-core (4x1.4 GHz Cortex-A53 & 4x1.8 GHz Cortex-A72) |
