diff options
author | Todd Poynor <toddpoynor@google.com> | 2012-05-03 15:12:33 -0700 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2012-05-11 12:23:01 -0700 |
commit | a04beadf67938ea83d806e65f04be0be8603f0ce (patch) | |
tree | 7a5b42fada97a632a50a7668ad51c90ddc623c01 /power/power_tuna.c | |
parent | 4a1d1b0cfb00be3bb8b1266f7a77fa49f196ddb8 (diff) | |
download | device_samsung_tuna-a04beadf67938ea83d806e65f04be0be8603f0ce.zip device_samsung_tuna-a04beadf67938ea83d806e65f04be0be8603f0ce.tar.gz device_samsung_tuna-a04beadf67938ea83d806e65f04be0be8603f0ce.tar.bz2 |
tuna: Power HAL: Boost pulse CPU speeds on POWER_HINT_INTERACTION
And no longer request in-kernel touchscreen boost.
Change-Id: I0d276c5188a7c7b9fb0c3c445b4e1229d26b15a5
Diffstat (limited to 'power/power_tuna.c')
-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, }; |