diff options
author | Todd Poynor <toddpoynor@google.com> | 2012-05-14 07:48:39 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-05-14 07:48:39 -0700 |
commit | d146f95fd8cc95c501bacbf4f53e169d9bcdfe26 (patch) | |
tree | 13e50508dc222f2e861328c48522513a6d11294e | |
parent | bf3b4d4b8e7371aa093e9f462283388d0e35450c (diff) | |
parent | 1962689125e73cf4331c59956bdffa2f7e6350fd (diff) | |
download | device_samsung_tuna-d146f95fd8cc95c501bacbf4f53e169d9bcdfe26.zip device_samsung_tuna-d146f95fd8cc95c501bacbf4f53e169d9bcdfe26.tar.gz device_samsung_tuna-d146f95fd8cc95c501bacbf4f53e169d9bcdfe26.tar.bz2 |
am 60b56618: am 07e0ce8d: Merge "tuna: Power HAL: Boost pulse CPU speeds on POWER_HINT_INTERACTION" into jb-dev
* commit '1962689125e73cf4331c59956bdffa2f7e6350fd':
tuna: Power HAL: Boost pulse CPU speeds on POWER_HINT_INTERACTION
-rw-r--r-- | power/power_tuna.c | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/power/power_tuna.c b/power/power_tuna.c index 2eb580f..7d06093 100644 --- a/power/power_tuna.c +++ b/power/power_tuna.c @@ -25,6 +25,15 @@ #include <hardware/hardware.h> #include <hardware/power.h> +#define BOOSTPULSE_PATH "/sys/devices/system/cpu/cpufreq/interactive/boostpulse" + +struct tuna_power_module { + struct power_module base; + pthread_mutex_t lock; + int boostpulse_fd; + int boostpulse_warned; +}; + static void sysfs_write(char *path, char *s) { char buf[80]; @@ -50,7 +59,7 @@ static void tuna_power_init(struct power_module *module) { /* * cpufreq interactive governor: timer 20ms, min sample 60ms, - * hispeed 700MHz at load 50%, input boost enabled. + * hispeed 700MHz at load 50%. */ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate", @@ -63,7 +72,28 @@ static void tuna_power_init(struct power_module *module) "50"); sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay", "100000"); - sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/input_boost", "1"); +} + +static int boostpulse_open(struct tuna_power_module *tuna) +{ + char buf[80]; + + pthread_mutex_lock(&tuna->lock); + + if (tuna->boostpulse_fd < 0) { + tuna->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY); + + if (tuna->boostpulse_fd < 0) { + if (!tuna->boostpulse_warned) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", BOOSTPULSE_PATH, buf); + tuna->boostpulse_warned = 1; + } + } + } + + pthread_mutex_unlock(&tuna->lock); + return tuna->boostpulse_fd; } static void tuna_power_set_interactive(struct power_module *module, int on) @@ -80,10 +110,22 @@ static void tuna_power_set_interactive(struct power_module *module, int on) static void tuna_power_hint(struct power_module *module, power_hint_t hint, void *data) { + struct tuna_power_module *tuna = (struct tuna_power_module *) module; char buf[80]; int len; switch (hint) { + case POWER_HINT_INTERACTION: + if (boostpulse_open(tuna) >= 0) { + len = write(tuna->boostpulse_fd, "1", 1); + + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", BOOSTPULSE_PATH, buf); + } + } + break; + case POWER_HINT_VSYNC: break; @@ -96,18 +138,24 @@ static struct hw_module_methods_t power_module_methods = { .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 = "Tuna Power HAL", - .author = "The Android Open Source Project", - .methods = &power_module_methods, +struct tuna_power_module HAL_MODULE_INFO_SYM = { + base: { + 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: "Tuna Power HAL", + author: "The Android Open Source Project", + methods: &power_module_methods, + }, + + init: tuna_power_init, + setInteractive: tuna_power_set_interactive, + powerHint: tuna_power_hint, }, - .init = tuna_power_init, - .setInteractive = tuna_power_set_interactive, - .powerHint = tuna_power_hint, + lock: PTHREAD_MUTEX_INITIALIZER, + boostpulse_fd: -1, + boostpulse_warned: 0, }; |