diff options
| author | alial_99 <alasadi56@gmail.com> | 2017-03-11 14:52:56 +0100 |
|---|---|---|
| committer | alial_99 <alasadi56@gmail.com> | 2017-03-11 14:52:56 +0100 |
| commit | db49ecdce879acea2f09db20d91835a77e13fc56 (patch) | |
| tree | aac247358ac0dea063a222c61399f1ae43538986 | |
| parent | d69ea2d8f6b74d3d7e1e698af4f67953d5ac8874 (diff) | |
i9300: power: split HINT_INTERACTION and HINT_LAUNCH
* use framework-suggested boost time if present
i9300: power: switch to POWER_HINT_LAUNCH
POWER_HINT_LAUNCH_BOOST is no longer supported, and has been replaced by
POWER_HINT_LAUNCH in N.
Change-Id: Ib74a1cb532015d9a9c9365a1112351b62163cf67
| -rw-r--r-- | BoardConfig.mk | 2 | ||||
| -rw-r--r-- | power/power.c | 419 | ||||
| -rw-r--r-- | power/power.h | 395 |
3 files changed, 418 insertions, 398 deletions
diff --git a/BoardConfig.mk b/BoardConfig.mk index 8439551..088d6f4 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -26,7 +26,7 @@ LIBART_IMG_BASE := 0x30000000 # RIL BOARD_PROVIDES_LIBRIL := true BOARD_MODEM_TYPE := xmm6262 -TARGET_SPECIFIC_HEADER_PATH := device/samsung/i9300/include +TARGET_SPECIFIC_HEADER_PATH += device/samsung/i9300/include BOARD_GLOBAL_CFLAGS += -DDISABLE_ASHMEM_TRACKING BOARD_RIL_CLASS := ../../../device/samsung/i9300/ril diff --git a/power/power.c b/power/power.c index 278994e..3e93ef1 100644 --- a/power/power.c +++ b/power/power.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 The CyanogenMod Project <http://www.cyanogenmod.org> + * (C) 2017 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,60 +45,60 @@ static bool is_low_power = false; static bool is_vsync_active = false; static int sysfs_write_str(char *path, char *s) { - char buf[80]; - int len; - int ret = 0; - int fd; - - fd = open(path, O_WRONLY); - if (fd < 0) { - strerror_r(errno, buf, sizeof(buf)); - ALOGE("Error opening %s: %s\n", path, buf); - return -1 ; - } - - len = write(fd, s, strlen(s)); - if (len < 0) { - strerror_r(errno, buf, sizeof(buf)); - ALOGE("Error writing to %s: %s\n", path, buf); - ret = -1; - } - - close(fd); - - return ret; + char buf[80]; + int len; + int ret = 0; + int fd; + + fd = open(path, O_WRONLY); + if (fd < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", path, buf); + return -1 ; + } + + len = write(fd, s, strlen(s)); + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", path, buf); + ret = -1; + } + + close(fd); + + return ret; } static int sysfs_write_int(char *path, int value) { - char buf[80]; - snprintf(buf, 80, "%d", value); - return sysfs_write_str(path, buf); + char buf[80]; + snprintf(buf, 80, "%d", value); + return sysfs_write_str(path, buf); } static int sysfs_write_long(char *path, long value) { - char buf[80]; - snprintf(buf, 80, "%ld", value); - return sysfs_write_str(path, buf); + char buf[80]; + snprintf(buf, 80, "%ld", value); + return sysfs_write_str(path, buf); } #ifdef LOG_NDEBUG #define WRITE_PEGASUSQ_PARAM(profile, param) do { \ ALOGV("%s: WRITE_PEGASUSQ_PARAM(profile=%d, param=%s): new val => %d", __func__, profile, #param, profiles[profile].param); \ sysfs_write_int(PEGASUSQ_PATH #param, profiles[profile].param); \ -} while (0) + } while (0) #define WRITE_LOW_POWER_PARAM(profile, param) do { \ ALOGV("%s: WRITE_LOW_POWER_PARAM(profile=%d, param=%s): new val => %d", \ - __func__, profile, #param, profiles_low_power[profile].param); \ + __func__, profile, #param, profiles_low_power[profile].param); \ sysfs_write_int(PEGASUSQ_PATH #param, profiles_low_power[profile].param); \ -} while (0) + } while (0) #define WRITE_PEGASUSQ_VALUE(param, value) do { \ ALOGV("%s: WRITE_PEGASUSQ_VALUE(param=%s, value=%d)", __func__, #param, value); \ sysfs_write_int(PEGASUSQ_PATH #param, value); \ -} while (0) + } while (0) #define WRITE_MINMAX_CPU(param, value) do { \ ALOGV("%s: WRITE_MINMAX_CPU(param=%s, value=%d)", __func__, #param, value); \ sysfs_write_int(MINMAX_CPU_PATH #param, value); \ -} while(0) + } while(0) #else #define WRITE_PEGASUSQ_PARAM(profile, param) sysfs_write_int(PEGASUSQ_PATH #param, profiles[profile].param) #define WRITE_LOW_POWER_PARAM(profile, param) sysfs_write_int(PEGASUSQ_PATH #param, profiles_low_power[profile].param) @@ -105,136 +106,136 @@ static int sysfs_write_long(char *path, long value) { #define WRITE_MINMAX_CPU(param, value) sysfs_write_int(MINMAX_CPU_PATH #param, value) #endif static bool check_governor() { - struct stat s; - int err = stat(PEGASUSQ_PATH, &s); - if (err != 0) return false; - return S_ISDIR(s.st_mode); + struct stat s; + int err = stat(PEGASUSQ_PATH, &s); + if (err != 0) return false; + return S_ISDIR(s.st_mode); } static bool is_profile_valid(int profile) { - return profile >= 0 && profile < PROFILE_MAX; + return profile >= 0 && profile < PROFILE_MAX; } static void set_power_profile(int profile) { - if (!is_profile_valid(profile)) { - ALOGE("%s: unknown profile: %d", __func__, profile); - return; - } - - if (!check_governor()) return; - - if (profile == current_power_profile) return; - - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_1_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_2_0); - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_2_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_3_0); - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_3_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_4_0); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_1_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_2_0); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_2_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_3_0); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_3_1); - WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_4_0); - WRITE_MINMAX_CPU(cpufreq_max_limit, profiles[profile].max_freq); - WRITE_MINMAX_CPU(cpufreq_min_limit, profiles[profile].min_freq); - WRITE_PEGASUSQ_PARAM(profile, up_threshold); - WRITE_PEGASUSQ_PARAM(profile, down_differential); - WRITE_PEGASUSQ_PARAM(profile, min_cpu_lock); - WRITE_PEGASUSQ_PARAM(profile, max_cpu_lock); - WRITE_PEGASUSQ_PARAM(profile, cpu_down_rate); - WRITE_PEGASUSQ_PARAM(profile, sampling_rate); - WRITE_PEGASUSQ_PARAM(profile, io_is_busy); - WRITE_PEGASUSQ_PARAM(profile, boost_freq); - WRITE_PEGASUSQ_PARAM(profile, boost_mincpus); - - current_power_profile = profile; - - ALOGV("%s: %d", __func__, profile); + if (!is_profile_valid(profile)) { + ALOGE("%s: unknown profile: %d", __func__, profile); + return; + } + + if (!check_governor()) return; + + if (profile == current_power_profile) return; + + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_1_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_2_0); + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_2_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_3_0); + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_3_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_freq_4_0); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_1_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_2_0); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_2_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_3_0); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_3_1); + WRITE_PEGASUSQ_PARAM(profile, hotplug_rq_4_0); + WRITE_MINMAX_CPU(cpufreq_max_limit, profiles[profile].max_freq); + WRITE_MINMAX_CPU(cpufreq_min_limit, profiles[profile].min_freq); + WRITE_PEGASUSQ_PARAM(profile, up_threshold); + WRITE_PEGASUSQ_PARAM(profile, down_differential); + WRITE_PEGASUSQ_PARAM(profile, min_cpu_lock); + WRITE_PEGASUSQ_PARAM(profile, max_cpu_lock); + WRITE_PEGASUSQ_PARAM(profile, cpu_down_rate); + WRITE_PEGASUSQ_PARAM(profile, sampling_rate); + WRITE_PEGASUSQ_PARAM(profile, io_is_busy); + WRITE_PEGASUSQ_PARAM(profile, boost_freq); + WRITE_PEGASUSQ_PARAM(profile, boost_mincpus); + + current_power_profile = profile; + + ALOGV("%s: %d", __func__, profile); } static void boost(long boost_time) { -#ifdef USE_PEGASUSQ_BOOSTING - if (is_vsync_active) return; - if (boost_time == -1) { - sysfs_write_int(PEGASUSQ_PATH "boost_lock_time", -1); - } else { - sysfs_write_long(PEGASUSQ_PATH "boost_lock_time", boost_time); - } -#endif + #ifdef USE_PEGASUSQ_BOOSTING + if (is_vsync_active || !check_governor()) return; + if (boost_time == -1) { + sysfs_write_int(PEGASUSQ_PATH "boost_lock_time", -1); + } else { + sysfs_write_long(PEGASUSQ_PATH "boost_lock_time", boost_time); + } + #endif } static void end_boost() { -#ifdef USE_PEGASUSQ_BOOSTING - if (is_vsync_active) return; - sysfs_write_int(PEGASUSQ_PATH "boost_lock_time", 0); -#endif + #ifdef USE_PEGASUSQ_BOOSTING + if (is_vsync_active || !check_governor()) return; + sysfs_write_int(PEGASUSQ_PATH "boost_lock_time", 0); + #endif } static void set_low_power(bool low_power) { - if (!is_profile_valid(current_power_profile)) { - ALOGV("%s: current_power_profile not set yet", __func__); - return; - } - - if (!check_governor()) return; - - if (is_low_power == low_power) return; - - if (low_power) { - end_boost(); - - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_1_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_2_0); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_2_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_3_0); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_3_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_4_0); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_1_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_2_0); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_2_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_3_0); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_3_1); - WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_4_0); - WRITE_MINMAX_CPU(cpufreq_max_limit, profiles_low_power[current_power_profile].max_freq); - WRITE_MINMAX_CPU(cpufreq_min_limit, profiles_low_power[current_power_profile].min_freq); - WRITE_LOW_POWER_PARAM(current_power_profile, up_threshold); - WRITE_LOW_POWER_PARAM(current_power_profile, down_differential); - WRITE_LOW_POWER_PARAM(current_power_profile, min_cpu_lock); - WRITE_LOW_POWER_PARAM(current_power_profile, max_cpu_lock); - WRITE_LOW_POWER_PARAM(current_power_profile, cpu_down_rate); - WRITE_LOW_POWER_PARAM(current_power_profile, sampling_rate); - WRITE_LOW_POWER_PARAM(current_power_profile, io_is_busy); - is_low_power = true; - } else { - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_1_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_2_0); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_2_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_3_0); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_3_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_4_0); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_1_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_2_0); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_2_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_3_0); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_3_1); - WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_4_0); - WRITE_MINMAX_CPU(cpufreq_max_limit, profiles[current_power_profile].max_freq); - WRITE_MINMAX_CPU(cpufreq_min_limit, profiles[current_power_profile].min_freq); - WRITE_PEGASUSQ_PARAM(current_power_profile, up_threshold); - WRITE_PEGASUSQ_PARAM(current_power_profile, down_differential); - WRITE_PEGASUSQ_PARAM(current_power_profile, min_cpu_lock); - WRITE_PEGASUSQ_PARAM(current_power_profile, max_cpu_lock); - WRITE_PEGASUSQ_PARAM(current_power_profile, cpu_down_rate); - WRITE_PEGASUSQ_PARAM(current_power_profile, sampling_rate); - WRITE_PEGASUSQ_PARAM(current_power_profile, io_is_busy); - WRITE_PEGASUSQ_PARAM(current_power_profile, boost_freq); - WRITE_PEGASUSQ_PARAM(current_power_profile, boost_mincpus); - - is_low_power = false; - } + if (!is_profile_valid(current_power_profile)) { + ALOGV("%s: current_power_profile not set yet", __func__); + return; + } + + if (!check_governor()) return; + + if (is_low_power == low_power) return; + + if (low_power) { + end_boost(); + + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_1_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_2_0); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_2_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_3_0); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_3_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_freq_4_0); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_1_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_2_0); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_2_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_3_0); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_3_1); + WRITE_LOW_POWER_PARAM(current_power_profile, hotplug_rq_4_0); + WRITE_MINMAX_CPU(cpufreq_max_limit, profiles_low_power[current_power_profile].max_freq); + WRITE_MINMAX_CPU(cpufreq_min_limit, profiles_low_power[current_power_profile].min_freq); + WRITE_LOW_POWER_PARAM(current_power_profile, up_threshold); + WRITE_LOW_POWER_PARAM(current_power_profile, down_differential); + WRITE_LOW_POWER_PARAM(current_power_profile, min_cpu_lock); + WRITE_LOW_POWER_PARAM(current_power_profile, max_cpu_lock); + WRITE_LOW_POWER_PARAM(current_power_profile, cpu_down_rate); + WRITE_LOW_POWER_PARAM(current_power_profile, sampling_rate); + WRITE_LOW_POWER_PARAM(current_power_profile, io_is_busy); + is_low_power = true; + } else { + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_1_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_2_0); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_2_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_3_0); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_3_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_freq_4_0); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_1_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_2_0); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_2_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_3_0); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_3_1); + WRITE_PEGASUSQ_PARAM(current_power_profile, hotplug_rq_4_0); + WRITE_MINMAX_CPU(cpufreq_max_limit, profiles[current_power_profile].max_freq); + WRITE_MINMAX_CPU(cpufreq_min_limit, profiles[current_power_profile].min_freq); + WRITE_PEGASUSQ_PARAM(current_power_profile, up_threshold); + WRITE_PEGASUSQ_PARAM(current_power_profile, down_differential); + WRITE_PEGASUSQ_PARAM(current_power_profile, min_cpu_lock); + WRITE_PEGASUSQ_PARAM(current_power_profile, max_cpu_lock); + WRITE_PEGASUSQ_PARAM(current_power_profile, cpu_down_rate); + WRITE_PEGASUSQ_PARAM(current_power_profile, sampling_rate); + WRITE_PEGASUSQ_PARAM(current_power_profile, io_is_busy); + WRITE_PEGASUSQ_PARAM(current_power_profile, boost_freq); + WRITE_PEGASUSQ_PARAM(current_power_profile, boost_mincpus); + + is_low_power = false; + } } @@ -246,8 +247,8 @@ static void set_low_power(bool low_power) { * PowerManagerService. */ static void power_init(__attribute__((unused)) struct power_module *module) { - set_power_profile(PROFILE_BALANCED); - ALOGV("%s", __func__); + set_power_profile(PROFILE_BALANCED); + ALOGV("%s", __func__); } /* @@ -274,16 +275,16 @@ static void power_init(__attribute__((unused)) struct power_module *module) { * on the screen. */ static void power_set_interactive(__attribute__((unused)) struct power_module *module, int on) { - if (!is_profile_valid(current_power_profile)) { - ALOGD("%s: no power profile selected", __func__); - return; - } - - if (!check_governor()) return; - ALOGV("%s: setting interactive => %d", __func__, on); - pthread_mutex_lock(&lock); - set_low_power(!on); - pthread_mutex_unlock(&lock); + if (!is_profile_valid(current_power_profile)) { + ALOGD("%s: no power profile selected", __func__); + return; + } + + if (!check_governor()) return; + ALOGV("%s: setting interactive => %d", __func__, on); + pthread_mutex_lock(&lock); + set_low_power(!on); + pthread_mutex_unlock(&lock); } /* @@ -323,28 +324,38 @@ static void power_set_interactive(__attribute__((unused)) struct power_module *m * integer value of the boost duration in microseconds. */ static void power_hint(__attribute__((unused)) struct power_module *module, power_hint_t hint, void *data) { - if (hint == POWER_HINT_SET_PROFILE) { - ALOGV("%s: set profile %d", __func__, *(int32_t *)data); - pthread_mutex_lock(&lock); - if (is_vsync_active) { - is_vsync_active = false; - end_boost(); - } - set_power_profile(*(int32_t *)data); - pthread_mutex_unlock(&lock); + int32_t val; + + if (hint == POWER_HINT_SET_PROFILE) { + ALOGV("%s: set profile %d", __func__, *(int32_t *)data); + pthread_mutex_lock(&lock); + if (is_vsync_active) { + is_vsync_active = false; + end_boost(); } + set_power_profile(*(int32_t *)data); + pthread_mutex_unlock(&lock); + } - if (current_power_profile == PROFILE_POWER_SAVE) return; + if (current_power_profile == PROFILE_POWER_SAVE) return; - pthread_mutex_lock(&lock); + pthread_mutex_lock(&lock); - switch (hint) { - case POWER_HINT_INTERACTION: - case POWER_HINT_LAUNCH_BOOST: - ALOGV("%s: interaction/launch", __func__); - boost(profiles[current_power_profile].interaction_boost_time); - break; -/* case POWER_HINT_VSYNC: + switch (hint) { + case POWER_HINT_INTERACTION: + ALOGV("%s: interaction", __func__); + val = *(int32_t *)data; + if (val != 0) { + boost(val * US_TO_NS); + } else { + boost(profiles[current_power_profile].interaction_boost_time); + } + break; + case POWER_HINT_LAUNCH: + ALOGV("%s: launch", __func__); + boost(profiles[current_power_profile].launch_boost_time); + break; + /* case POWER_HINT_VSYNC: if (*(int32_t *)data) { ALOGV("%s: vsync", __func__); boost(-1); @@ -354,13 +365,13 @@ static void power_hint(__attribute__((unused)) struct power_module *module, powe end_boost(); } break;*/ - case POWER_HINT_CPU_BOOST: - ALOGV("%s: cpu_boost", __func__); - boost((*(int32_t *)data) * US_TO_NS); - break; - } + case POWER_HINT_CPU_BOOST: + ALOGV("%s: cpu_boost", __func__); + boost((*(int32_t *)data) * US_TO_NS); + break; + } - pthread_mutex_unlock(&lock); + pthread_mutex_unlock(&lock); } /* @@ -368,31 +379,31 @@ static void power_hint(__attribute__((unused)) struct power_module *module, powe * feature or capability from the hardware or PowerHAL */ static int power_get_feature(__attribute__((unused)) struct power_module *module, feature_t feature) { - ALOGV("%s: %d", __func__, feature); - if (feature == POWER_FEATURE_SUPPORTED_PROFILES) { - return PROFILE_MAX; - } - ALOGV("%s: unknown feature %d", __func__, feature); - return -1; + ALOGV("%s: %d", __func__, feature); + if (feature == POWER_FEATURE_SUPPORTED_PROFILES) { + return PROFILE_MAX; + } + ALOGV("%s: unknown feature %d", __func__, feature); + return -1; } static struct hw_module_methods_t power_module_methods = { - .open = NULL, + .open = NULL, }; struct power_module HAL_MODULE_INFO_SYM = { - .common = { - .tag = HARDWARE_MODULE_TAG, - .module_api_version = POWER_MODULE_API_VERSION_0_2, - .hal_api_version = HARDWARE_HAL_API_VERSION, - .id = POWER_HARDWARE_MODULE_ID, - .name = "smdk4x12 Power HAL", - .author = "The CyanogenMod Project", - .methods = &power_module_methods, - }, - - .init = power_init, - .setInteractive = power_set_interactive, - .powerHint = power_hint, - .getFeature = power_get_feature + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = POWER_MODULE_API_VERSION_0_2, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = POWER_HARDWARE_MODULE_ID, + .name = "smdk4x12 Power HAL", + .author = "The CyanogenMod Project", + .methods = &power_module_methods, + }, + + .init = power_init, + .setInteractive = power_set_interactive, + .powerHint = power_hint, + .getFeature = power_get_feature }; diff --git a/power/power.h b/power/power.h index 08ceb51..5e35538 100644 --- a/power/power.h +++ b/power/power.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2016 The CyanogenMod Project <http://www.cyanogenmod.org> + * (C) 2017 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,209 +18,217 @@ #define MS_TO_NS (1000000L) enum { - PROFILE_POWER_SAVE = 0, - PROFILE_BALANCED, - PROFILE_PERFORMANCE, - PROFILE_MAX + PROFILE_POWER_SAVE = 0, + PROFILE_BALANCED, + PROFILE_PERFORMANCE, + PROFILE_MAX }; typedef struct governor_settings { - // freq values for core up/down - int hotplug_freq_1_1; - int hotplug_freq_2_0; - int hotplug_freq_2_1; - int hotplug_freq_3_0; - int hotplug_freq_3_1; - int hotplug_freq_4_0; - // rq sizes for up/down - int hotplug_rq_1_1; - int hotplug_rq_2_0; - int hotplug_rq_2_1; - int hotplug_rq_3_0; - int hotplug_rq_3_1; - int hotplug_rq_4_0; - // max/min freqs (-1 for default) - int max_freq; - int min_freq; - // load at which to start scaling up - int up_threshold; - // higher down_differential == slower downscaling - int down_differential; - // min/max num of cpus to have online - int min_cpu_lock; - int max_cpu_lock; - // wait sampling_rate * cpu_down_rate us before trying to downscale - int cpu_down_rate; - int sampling_rate; // in microseconds - int io_is_busy; - // boosting - int boost_freq; - int boost_mincpus; - long interaction_boost_time; + // freq values for core up/down + int hotplug_freq_1_1; + int hotplug_freq_2_0; + int hotplug_freq_2_1; + int hotplug_freq_3_0; + int hotplug_freq_3_1; + int hotplug_freq_4_0; + // rq sizes for up/down + int hotplug_rq_1_1; + int hotplug_rq_2_0; + int hotplug_rq_2_1; + int hotplug_rq_3_0; + int hotplug_rq_3_1; + int hotplug_rq_4_0; + // max/min freqs (-1 for default) + int max_freq; + int min_freq; + // load at which to start scaling up + int up_threshold; + // higher down_differential == slower downscaling + int down_differential; + // min/max num of cpus to have online + int min_cpu_lock; + int max_cpu_lock; + // wait sampling_rate * cpu_down_rate us before trying to downscale + int cpu_down_rate; + int sampling_rate; // in microseconds + int io_is_busy; + // boosting + int boost_freq; + int boost_mincpus; + long interaction_boost_time; + long launch_boost_time; } power_profile; static power_profile profiles[PROFILE_MAX] = { - [PROFILE_POWER_SAVE] = { - .hotplug_freq_1_1 = 800000, - .hotplug_freq_2_0 = 700000, - .hotplug_freq_2_1 = 1000000, - .hotplug_freq_3_0 = 900000, - .hotplug_freq_3_1 = 1200000, - .hotplug_freq_4_0 = 1100000, - .hotplug_rq_1_1 = 200, - .hotplug_rq_2_0 = 200, - .hotplug_rq_2_1 = 300, - .hotplug_rq_3_0 = 300, - .hotplug_rq_3_1 = 400, - .hotplug_rq_4_0 = 400, - .max_freq = 1000000, - .min_freq = -1, - .up_threshold = 95, - .down_differential = 2, - .min_cpu_lock = 0, - .max_cpu_lock = 3, - .cpu_down_rate = 5, - .sampling_rate = 200000, - .io_is_busy = 0, - // nb: boosting power hints are ignored for PROFILE_POWER_SAVE - .boost_freq = 0, - .boost_mincpus = 0, - .interaction_boost_time = 0, - }, - [PROFILE_BALANCED] = { - .hotplug_freq_1_1 = 500000, - .hotplug_freq_2_0 = 500000, - .hotplug_freq_2_1 = 700000, - .hotplug_freq_3_0 = 700000, - .hotplug_freq_3_1 = 900000, - .hotplug_freq_4_0 = 900000, - .hotplug_rq_1_1 = 150, - .hotplug_rq_2_0 = 150, - .hotplug_rq_2_1 = 250, - .hotplug_rq_3_0 = 250, - .hotplug_rq_3_1 = 350, - .hotplug_rq_4_0 = 350, - .max_freq = -1, - .min_freq = -1, - .up_threshold = 90, - .down_differential = 3, - .min_cpu_lock = 0, - .max_cpu_lock = 0, - .cpu_down_rate = 10, - .sampling_rate = 200000, - .io_is_busy = 0, - .boost_freq = 700000, - .boost_mincpus = 0, - .interaction_boost_time = 60 * (MS_TO_NS), - }, - [PROFILE_PERFORMANCE] = { - .hotplug_freq_1_1 = 500000, - .hotplug_freq_2_0 = 200000, - .hotplug_freq_2_1 = 500000, - .hotplug_freq_3_0 = 200000, - .hotplug_freq_3_1 = 700000, - .hotplug_freq_4_0 = 200000, - .hotplug_rq_1_1 = 150, - .hotplug_rq_2_0 = 100, - .hotplug_rq_2_1 = 200, - .hotplug_rq_3_0 = 150, - .hotplug_rq_3_1 = 250, - .hotplug_rq_4_0 = 200, - .min_freq = -1, - .max_freq = -1, - .up_threshold = 80, - .down_differential = 5, - .min_cpu_lock = 0, - .max_cpu_lock = 0, - .cpu_down_rate = 20, - .sampling_rate = 200000, - .io_is_busy = 1, - .boost_freq = 900000, - .boost_mincpus = 2, - .interaction_boost_time = 90 * (MS_TO_NS), - }, + [PROFILE_POWER_SAVE] = { + .hotplug_freq_1_1 = 800000, + .hotplug_freq_2_0 = 700000, + .hotplug_freq_2_1 = 1000000, + .hotplug_freq_3_0 = 900000, + .hotplug_freq_3_1 = 1200000, + .hotplug_freq_4_0 = 1100000, + .hotplug_rq_1_1 = 200, + .hotplug_rq_2_0 = 200, + .hotplug_rq_2_1 = 300, + .hotplug_rq_3_0 = 300, + .hotplug_rq_3_1 = 400, + .hotplug_rq_4_0 = 400, + .max_freq = 1000000, + .min_freq = -1, + .up_threshold = 95, + .down_differential = 2, + .min_cpu_lock = 0, + .max_cpu_lock = 3, + .cpu_down_rate = 5, + .sampling_rate = 200000, + .io_is_busy = 0, + // nb: boosting power hints are ignored for PROFILE_POWER_SAVE + .boost_freq = 0, + .boost_mincpus = 0, + .interaction_boost_time = 0, + .launch_boost_time = 0, + }, + [PROFILE_BALANCED] = { + .hotplug_freq_1_1 = 500000, + .hotplug_freq_2_0 = 500000, + .hotplug_freq_2_1 = 700000, + .hotplug_freq_3_0 = 700000, + .hotplug_freq_3_1 = 900000, + .hotplug_freq_4_0 = 900000, + .hotplug_rq_1_1 = 150, + .hotplug_rq_2_0 = 150, + .hotplug_rq_2_1 = 250, + .hotplug_rq_3_0 = 250, + .hotplug_rq_3_1 = 350, + .hotplug_rq_4_0 = 350, + .max_freq = -1, + .min_freq = -1, + .up_threshold = 90, + .down_differential = 3, + .min_cpu_lock = 0, + .max_cpu_lock = 0, + .cpu_down_rate = 10, + .sampling_rate = 200000, + .io_is_busy = 0, + .boost_freq = 700000, + .boost_mincpus = 0, + .interaction_boost_time = 60 * (MS_TO_NS), + .launch_boost_time = 2000 * (MS_TO_NS), + }, + [PROFILE_PERFORMANCE] = { + .hotplug_freq_1_1 = 500000, + .hotplug_freq_2_0 = 200000, + .hotplug_freq_2_1 = 500000, + .hotplug_freq_3_0 = 200000, + .hotplug_freq_3_1 = 700000, + .hotplug_freq_4_0 = 200000, + .hotplug_rq_1_1 = 150, + .hotplug_rq_2_0 = 100, + .hotplug_rq_2_1 = 200, + .hotplug_rq_3_0 = 150, + .hotplug_rq_3_1 = 250, + .hotplug_rq_4_0 = 200, + .min_freq = -1, + .max_freq = -1, + .up_threshold = 80, + .down_differential = 5, + .min_cpu_lock = 0, + .max_cpu_lock = 0, + .cpu_down_rate = 20, + .sampling_rate = 200000, + .io_is_busy = 1, + .boost_freq = 900000, + .boost_mincpus = 2, + .interaction_boost_time = 90 * (MS_TO_NS), + .launch_boost_time = 3000 * (MS_TO_NS), + }, }; // for non-interactive profiles we don't need to worry about // boosting as it (should) only occur while the screen is on static power_profile profiles_low_power[PROFILE_MAX] = { - [PROFILE_POWER_SAVE] = { - .hotplug_freq_1_1 = 800000, - .hotplug_freq_2_0 = 800000, - .hotplug_freq_2_1 = 900000, - .hotplug_freq_3_0 = 900000, - .hotplug_freq_3_1 = 1200000, - .hotplug_freq_4_0 = 1100000, - .hotplug_rq_1_1 = 200, - .hotplug_rq_2_0 = 200, - .hotplug_rq_2_1 = 300, - .hotplug_rq_3_0 = 300, - .hotplug_rq_3_1 = 400, - .hotplug_rq_4_0 = 400, - .max_freq = 900000, - .min_freq = -1, - .up_threshold = 95, - .down_differential = 1, - .min_cpu_lock = 0, - .max_cpu_lock = 2, - .cpu_down_rate = 5, - .sampling_rate = 200000, - .io_is_busy = 0, - .boost_freq = 0, - .boost_mincpus = 0, - .interaction_boost_time = 0, - }, - [PROFILE_BALANCED] = { - .hotplug_freq_1_1 = 700000, - .hotplug_freq_2_0 = 700000, - .hotplug_freq_2_1 = 900000, - .hotplug_freq_3_0 = 900000, - .hotplug_freq_3_1 = 1100000, - .hotplug_freq_4_0 = 1100000, - .hotplug_rq_1_1 = 150, - .hotplug_rq_2_0 = 150, - .hotplug_rq_2_1 = 250, - .hotplug_rq_3_0 = 250, - .hotplug_rq_3_1 = 350, - .hotplug_rq_4_0 = 350, - .max_freq = 1200000, - .min_freq = -1, - .up_threshold = 90, - .down_differential = 2, - .min_cpu_lock = 0, - .max_cpu_lock = 0, - .cpu_down_rate = 8, - .sampling_rate = 200000, - .io_is_busy = 0, - .boost_freq = 0, - .boost_mincpus = 0, - .interaction_boost_time = 0, - }, - [PROFILE_PERFORMANCE] = { - .hotplug_freq_1_1 = 800000, - .hotplug_freq_2_0 = 500000, - .hotplug_freq_2_1 = 800000, - .hotplug_freq_3_0 = 500000, - .hotplug_freq_3_1 = 1000000, - .hotplug_freq_4_0 = 700000, - .hotplug_rq_1_1 = 150, - .hotplug_rq_2_0 = 100, - .hotplug_rq_2_1 = 200, - .hotplug_rq_3_0 = 150, - .hotplug_rq_3_1 = 250, - .hotplug_rq_4_0 = 200, - .min_freq = -1, - .max_freq = -1, - .up_threshold = 85, - .down_differential = 5, - .min_cpu_lock = 0, - .max_cpu_lock = 0, - .cpu_down_rate = 15, - .sampling_rate = 200000, - .io_is_busy = 1, - .boost_freq = 0, - .boost_mincpus = 0, - .interaction_boost_time = 0, - }, + [PROFILE_POWER_SAVE] = { + .hotplug_freq_1_1 = 800000, + .hotplug_freq_2_0 = 800000, + .hotplug_freq_2_1 = 900000, + .hotplug_freq_3_0 = 900000, + .hotplug_freq_3_1 = 1200000, + .hotplug_freq_4_0 = 1100000, + .hotplug_rq_1_1 = 200, + .hotplug_rq_2_0 = 200, + .hotplug_rq_2_1 = 300, + .hotplug_rq_3_0 = 300, + .hotplug_rq_3_1 = 400, + .hotplug_rq_4_0 = 400, + .max_freq = 900000, + .min_freq = -1, + .up_threshold = 95, + .down_differential = 1, + .min_cpu_lock = 0, + .max_cpu_lock = 2, + .cpu_down_rate = 5, + .sampling_rate = 200000, + .io_is_busy = 0, + .boost_freq = 0, + .boost_mincpus = 0, + .interaction_boost_time = 0, + .launch_boost_time = 0, + }, + [PROFILE_BALANCED] = { + .hotplug_freq_1_1 = 700000, + .hotplug_freq_2_0 = 700000, + .hotplug_freq_2_1 = 900000, + .hotplug_freq_3_0 = 900000, + .hotplug_freq_3_1 = 1100000, + .hotplug_freq_4_0 = 1100000, + .hotplug_rq_1_1 = 150, + .hotplug_rq_2_0 = 150, + .hotplug_rq_2_1 = 250, + .hotplug_rq_3_0 = 250, + .hotplug_rq_3_1 = 350, + .hotplug_rq_4_0 = 350, + .max_freq = 1200000, + .min_freq = -1, + .up_threshold = 90, + .down_differential = 2, + .min_cpu_lock = 0, + .max_cpu_lock = 0, + .cpu_down_rate = 8, + .sampling_rate = 200000, + .io_is_busy = 0, + .boost_freq = 0, + .boost_mincpus = 0, + .interaction_boost_time = 0, + .launch_boost_time = 0, + }, + [PROFILE_PERFORMANCE] = { + .hotplug_freq_1_1 = 800000, + .hotplug_freq_2_0 = 500000, + .hotplug_freq_2_1 = 800000, + .hotplug_freq_3_0 = 500000, + .hotplug_freq_3_1 = 1000000, + .hotplug_freq_4_0 = 700000, + .hotplug_rq_1_1 = 150, + .hotplug_rq_2_0 = 100, + .hotplug_rq_2_1 = 200, + .hotplug_rq_3_0 = 150, + .hotplug_rq_3_1 = 250, + .hotplug_rq_4_0 = 200, + .min_freq = -1, + .max_freq = -1, + .up_threshold = 85, + .down_differential = 5, + .min_cpu_lock = 0, + .max_cpu_lock = 0, + .cpu_down_rate = 15, + .sampling_rate = 200000, + .io_is_busy = 1, + .boost_freq = 0, + .boost_mincpus = 0, + .interaction_boost_time = 0, + .launch_boost_time = 0, + }, }; + |
