diff options
author | Todd Poynor <toddpoynor@google.com> | 2012-04-24 13:58:25 -0700 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2012-04-25 20:27:24 -0700 |
commit | 5f1af6b2180133f2866698d3ce0329007c919a88 (patch) | |
tree | b2147dc393bb87f3a91b320c9809e23e2c07a55c | |
parent | 647908fa72cfacec568f85b0300fa946bc5b25f3 (diff) | |
download | device_samsung_tuna-5f1af6b2180133f2866698d3ce0329007c919a88.zip device_samsung_tuna-5f1af6b2180133f2866698d3ce0329007c919a88.tar.gz device_samsung_tuna-5f1af6b2180133f2866698d3ce0329007c919a88.tar.bz2 |
tuna: Power HAL: Add VSYNC power hint -- DO NOT MERGE
Change-Id: I3a0c72e843c4d9c7a9129a35ed8bbee59acb5599
Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r-- | power/power_tuna.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/power/power_tuna.c b/power/power_tuna.c index eb38410..bff028d 100644 --- a/power/power_tuna.c +++ b/power/power_tuna.c @@ -34,6 +34,10 @@ static int sPowerStatefd; static const char *pwr_states[] = { "mem", "on" }; +#define BOOST_PATH "/sys/devices/system/cpu/cpufreq/interactive/boost" +static int boost_fd = -1; +static int boost_warned; + static void sysfs_write(char *path, char *s) { char buf[80]; @@ -103,6 +107,37 @@ 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) +{ + char buf[80]; + int len; + + switch (hint) { + case POWER_HINT_VSYNC: + if (boost_fd < 0) + boost_fd = open(BOOST_PATH, O_WRONLY); + + if (boost_fd < 0) { + if (!boost_warned) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error opening %s: %s\n", BOOST_PATH, buf); + boost_warned = 1; + } + break; + } + + len = write(boost_fd, (int) data ? "1" : "0", 1); + if (len < 0) { + strerror_r(errno, buf, sizeof(buf)); + ALOGE("Error writing to %s: %s\n", BOOST_PATH, buf); + } + break; + + default: + break; + } +} static struct hw_module_methods_t power_module_methods = { .open = NULL, @@ -121,4 +156,5 @@ struct power_module HAL_MODULE_INFO_SYM = { .init = tuna_power_init, .setInteractive = tuna_power_set_interactive, + .powerHint = tuna_power_hint, }; |