diff options
author | Corinna Vinschen <xda@vinschen.de> | 2018-08-26 22:11:49 +0200 |
---|---|---|
committer | Bruno Martins <bgcngm@gmail.com> | 2018-10-02 19:50:36 +0100 |
commit | 8599e3c63a9bd515894672b3b5b223818705abff (patch) | |
tree | 8be6f674d86a1bd0011be6ed0aefb92c7bd1f73a /power-8953.c | |
parent | 282e889e556e65c326238ffb8243c626d4b3c4a5 (diff) | |
download | android_hardware_qcom_power-8599e3c63a9bd515894672b3b5b223818705abff.tar.gz android_hardware_qcom_power-8599e3c63a9bd515894672b3b5b223818705abff.tar.bz2 android_hardware_qcom_power-8599e3c63a9bd515894672b3b5b223818705abff.zip |
power: set_power_profile: handle errors
* Make sure current_power_profile reflects actual setting.
* Propagate error condition up to caller.
* Handle error from set_power_profile in power_hint_override.
Change-Id: I8518d921a94c912c75f59fbf993a8f44116bdca9
Signed-off-by: Corinna Vinschen <xda@vinschen.de>
Diffstat (limited to 'power-8953.c')
-rw-r--r-- | power-8953.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/power-8953.c b/power-8953.c index 64c9638..d272a23 100644 --- a/power-8953.c +++ b/power-8953.c @@ -90,40 +90,51 @@ int get_number_of_profiles() } #endif -static void set_power_profile(int profile) +static int set_power_profile(int profile) { + int ret = -EINVAL; + const char *profile_name = NULL; + if (profile == current_power_profile) - return; + return 0; ALOGV("%s: Profile=%d", __func__, profile); if (current_power_profile != PROFILE_BALANCED) { undo_hint_action(DEFAULT_PROFILE_HINT_ID); ALOGV("%s: Hint undone", __func__); + current_power_profile = PROFILE_BALANCED; } if (profile == PROFILE_POWER_SAVE) { - perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save, + ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save, ARRAY_SIZE(profile_power_save)); - ALOGD("%s: Set powersave mode", __func__); + profile_name = "powersave"; } else if (profile == PROFILE_HIGH_PERFORMANCE) { - perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance, - ARRAY_SIZE(profile_high_performance)); - ALOGD("%s: Set performance mode", __func__); + ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, + profile_high_performance, ARRAY_SIZE(profile_high_performance)); + profile_name = "performance"; } else if (profile == PROFILE_BIAS_POWER) { - perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power, + ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power, ARRAY_SIZE(profile_bias_power)); - ALOGD("%s: Set bias power mode", __func__); + profile_name = "bias power"; } else if (profile == PROFILE_BIAS_PERFORMANCE) { - perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance, - ARRAY_SIZE(profile_bias_performance)); - ALOGD("%s: Set bias perf mode", __func__); + ret = perform_hint_action(DEFAULT_PROFILE_HINT_ID, + profile_bias_performance, ARRAY_SIZE(profile_bias_performance)); + profile_name = "bias perf"; + } else if (profile == PROFILE_BALANCED) { + ret = 0; + profile_name = "balanced"; } - current_power_profile = profile; + if (ret == 0) { + current_power_profile = profile; + ALOGD("%s: Set %s mode", __func__, profile_name); + } + return ret; } typedef enum { @@ -268,7 +279,8 @@ int power_hint_override(power_hint_t hint, void *data) int ret_val = HINT_NONE; if (hint == POWER_HINT_SET_PROFILE) { - set_power_profile(*(int32_t *)data); + if (set_power_profile(*(int32_t *)data) < 0) + ALOGE("Setting power profile failed. perf HAL not started?"); return HINT_HANDLED; } |