aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Coucheron <arco68@gmail.com>2017-06-23 07:55:01 +0200
committerdoc HD <doc.divxm@gmail.com>2017-06-26 17:41:39 +0300
commit06428a0d89bcb57b2aaf395497d04dcbd1090bc9 (patch)
treee1020842b6e60d177246a194f2d0522aa87dc04e
parentb3e1f20b5b9d9ba5cf04cade26af955f0281a9c4 (diff)
serrano-common: Run clang-format on source files
Add .clang-format file and run clang-format on source files. Change-Id: I28a707d19fcdaf45d9e752fa08cce51236ca6dca
-rw-r--r--.clang-format11
-rw-r--r--liblights/lights.c181
-rw-r--r--power/power.c196
-rw-r--r--power/power.h154
4 files changed, 243 insertions, 299 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ae4a451
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,11 @@
+BasedOnStyle: Google
+AccessModifierOffset: -2
+AllowShortFunctionsOnASingleLine: Inline
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+UseTab: Never
+PenaltyExcessCharacter: 32
diff --git a/liblights/lights.c b/liblights/lights.c
index 6f53b26..ca1c051 100644
--- a/liblights/lights.c
+++ b/liblights/lights.c
@@ -15,18 +15,17 @@
* limitations under the License.
*/
-
// #define LOG_NDEBUG 0
#include <cutils/log.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <malloc.h>
#include <pthread.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -38,43 +37,36 @@
static pthread_once_t g_init = PTHREAD_ONCE_INIT;
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
-char const*const LCD_FILE
- = "/sys/class/leds/lcd-backlight/brightness";
+char const* const LCD_FILE = "/sys/class/leds/lcd-backlight/brightness";
-char const*const BUTTON_FILE
- = "/sys/class/leds/button-backlight/brightness";
+char const* const BUTTON_FILE = "/sys/class/leds/button-backlight/brightness";
#ifdef GENERIC_BLN
-char const*const NOTIFICATION_FILE
- = "/sys/class/misc/backlightnotification/notification_led";
+char const* const NOTIFICATION_FILE = "/sys/class/misc/backlightnotification/notification_led";
#endif
#ifdef MULTI_COLOR_LED
-char const*const LED_BLINK
- = "/sys/class/sec/led/led_blink";
+char const* const LED_BLINK = "/sys/class/sec/led/led_blink";
struct led_config {
unsigned int color;
int delay_on, delay_off;
};
-static struct led_config g_leds[3]; // For battery, notifications, and attention.
-static int g_cur_led = -1; // Presently showing LED of the above.
+static struct led_config g_leds[3]; // For battery, notifications, and attention.
+static int g_cur_led = -1; // Presently showing LED of the above.
#endif
/**
* device methods
*/
-void init_globals(void)
-{
+void init_globals(void) {
// init the mutex
pthread_mutex_init(&g_lock, NULL);
}
-static int
-write_int(char const* path, int value)
-{
+static int write_int(char const* path, int value) {
int fd;
static int already_warned = 0;
@@ -95,9 +87,7 @@ write_int(char const* path, int value)
}
#ifdef MULTI_COLOR_LED
-static int
-write_str(char const *path, const char* value)
-{
+static int write_str(char const* path, const char* value) {
int fd;
static int already_warned;
@@ -120,47 +110,41 @@ write_str(char const *path, const char* value)
}
#endif
-static int
-is_lit(struct light_state_t const* state)
-{
+static int is_lit(struct light_state_t const* state) {
return state->color & 0x00ffffff;
}
-static int
-rgb_to_brightness(struct light_state_t const* state)
-{
+static int rgb_to_brightness(struct light_state_t const* state) {
int color = state->color & 0x00ffffff;
- return ((77*((color>>16)&0x00ff))
- + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
+ return ((77 * ((color >> 16) & 0x00ff)) + (150 * ((color >> 8) & 0x00ff)) +
+ (29 * (color & 0x00ff))) >>
+ 8;
}
#ifdef MULTI_COLOR_LED
/* LEDs */
-static int
-write_leds(const struct led_config *led)
-{
+static int write_leds(const struct led_config* led) {
static const struct led_config led_off = {0, 0, 0};
char blink[32];
int count, err;
- if (led == NULL)
- led = &led_off;
+ if (led == NULL) led = &led_off;
- if ((count = snprintf(blink, sizeof(blink)-1, "0x%08x %d %d", led->color,
- led->delay_on, led->delay_off)) < 0) {
+ if ((count = snprintf(blink, sizeof(blink) - 1, "0x%08x %d %d", led->color, led->delay_on,
+ led->delay_off)) < 0) {
return -errno;
- } else if ((unsigned int)count >= sizeof(blink)-1) {
+ } else if ((unsigned int)count >= sizeof(blink) - 1) {
ALOGE("%s: Truncated string: blink=\"%s\".", __func__, blink);
return -EINVAL;
}
- ALOGD("%s: color=0x%08x, delay_on=%d, delay_off=%d, blink=\"%s\".",
- __func__, led->color, led->delay_on, led->delay_off, blink);
+ ALOGD("%s: color=0x%08x, delay_on=%d, delay_off=%d, blink=\"%s\".", __func__, led->color,
+ led->delay_on, led->delay_off, blink);
/* Add '\n' here to make the above log message clean. */
- blink[count] = '\n';
- blink[count+1] = '\0';
+ blink[count] = '\n';
+ blink[count + 1] = '\0';
pthread_mutex_lock(&g_lock);
err = write_str(LED_BLINK, blink);
@@ -169,17 +153,14 @@ write_leds(const struct led_config *led)
return err;
}
-static int
-set_light_leds(struct light_state_t const *state, int type)
-{
- struct led_config *led;
+static int set_light_leds(struct light_state_t const* state, int type) {
+ struct led_config* led;
int err = 0;
- ALOGD("%s: type=%d, color=0x%010x, fM=%d, fOnMS=%d, fOffMs=%d.", __func__,
- type, state->color,state->flashMode, state->flashOnMS, state->flashOffMS);
+ ALOGD("%s: type=%d, color=0x%010x, fM=%d, fOnMS=%d, fOffMs=%d.", __func__, type, state->color,
+ state->flashMode, state->flashOnMS, state->flashOffMS);
- if (type < 0 || (unsigned int)type >= sizeof(g_leds)/sizeof(g_leds[0]))
- return -EINVAL;
+ if (type < 0 || (unsigned int)type >= sizeof(g_leds) / sizeof(g_leds[0])) return -EINVAL;
/* type is one of:
* 0. battery
@@ -189,17 +170,17 @@ set_light_leds(struct light_state_t const *state, int type)
led = &g_leds[type];
switch (state->flashMode) {
- case LIGHT_FLASH_NONE:
- /* Set LED to a solid color, spec is unclear on the exact behavior here. */
- led->delay_on = led->delay_off = 0;
- break;
- case LIGHT_FLASH_TIMED:
- case LIGHT_FLASH_HARDWARE:
- led->delay_on = state->flashOnMS;
- led->delay_off = state->flashOffMS;
- break;
- default:
- return -EINVAL;
+ case LIGHT_FLASH_NONE:
+ /* Set LED to a solid color, spec is unclear on the exact behavior here. */
+ led->delay_on = led->delay_off = 0;
+ break;
+ case LIGHT_FLASH_TIMED:
+ case LIGHT_FLASH_HARDWARE:
+ led->delay_on = state->flashOnMS;
+ led->delay_off = state->flashOffMS;
+ break;
+ default:
+ return -EINVAL;
}
led->color = state->color & 0x00ffffff;
@@ -217,7 +198,7 @@ set_light_leds(struct light_state_t const *state, int type)
/* But it is currently showing, switch to a lower-priority LED. */
int i;
- for (i = type-1; i >= 0; i--) {
+ for (i = type - 1; i >= 0; i--) {
if (g_leds[i].color > 0) {
/* Found a lower-priority LED to switch to. */
err = write_leds(&g_leds[i]);
@@ -227,7 +208,7 @@ set_light_leds(struct light_state_t const *state, int type)
/* No LEDs are lit, turn off. */
err = write_leds(NULL);
-switched:
+ switched:
g_cur_led = i;
}
}
@@ -235,24 +216,16 @@ switched:
return err;
}
-static int
-set_light_leds_battery(struct light_device_t *dev,
- struct light_state_t const *state)
-{
+static int set_light_leds_battery(struct light_device_t* dev, struct light_state_t const* state) {
return set_light_leds(state, 0);
}
-static int
-set_light_leds_notifications(struct light_device_t *dev,
- struct light_state_t const *state)
-{
+static int set_light_leds_notifications(struct light_device_t* dev,
+ struct light_state_t const* state) {
return set_light_leds(state, 1);
}
-static int
-set_light_leds_attention(struct light_device_t *dev,
- struct light_state_t const *state)
-{
+static int set_light_leds_attention(struct light_device_t* dev, struct light_state_t const* state) {
struct light_state_t fixed;
memcpy(&fixed, state, sizeof(fixed));
@@ -260,16 +233,15 @@ set_light_leds_attention(struct light_device_t *dev,
/* The framework does odd things with the attention lights, fix them up to
* do something sensible here. */
switch (fixed.flashMode) {
- case LIGHT_FLASH_NONE:
- /* LightsService.Light::stopFlashing calls with non-zero color. */
- fixed.color = 0;
- break;
- case LIGHT_FLASH_HARDWARE:
- /* PowerManagerService::setAttentionLight calls with onMS=3, offMS=0, which
- * just makes for a slightly-dimmer LED. */
- if (fixed.flashOnMS > 0 && fixed.flashOffMS == 0)
- fixed.flashMode = LIGHT_FLASH_NONE;
- break;
+ case LIGHT_FLASH_NONE:
+ /* LightsService.Light::stopFlashing calls with non-zero color. */
+ fixed.color = 0;
+ break;
+ case LIGHT_FLASH_HARDWARE:
+ /* PowerManagerService::setAttentionLight calls with onMS=3, offMS=0, which
+ * just makes for a slightly-dimmer LED. */
+ if (fixed.flashOnMS > 0 && fixed.flashOffMS == 0) fixed.flashMode = LIGHT_FLASH_NONE;
+ break;
}
return set_light_leds(&fixed, 2);
@@ -277,32 +249,27 @@ set_light_leds_attention(struct light_device_t *dev,
#endif
#ifdef GENERIC_BLN
-static int
-set_light_leds_notifications(struct light_device_t *dev,
- struct light_state_t const* state)
-{
+static int set_light_leds_notifications(struct light_device_t* dev,
+ struct light_state_t const* state) {
int err = 0;
int on = is_lit(state);
- if(!dev) {
+ if (!dev) {
return -1;
}
pthread_mutex_lock(&g_lock);
- err = write_int(NOTIFICATION_FILE, on?1:0);
+ err = write_int(NOTIFICATION_FILE, on ? 1 : 0);
pthread_mutex_unlock(&g_lock);
return err;
}
#endif
-static int
-set_light_backlight(struct light_device_t *dev,
- struct light_state_t const* state)
-{
+static int set_light_backlight(struct light_device_t* dev, struct light_state_t const* state) {
int err = 0;
int brightness = rgb_to_brightness(state);
- if(!dev) {
+ if (!dev) {
return -1;
}
@@ -312,13 +279,10 @@ set_light_backlight(struct light_device_t *dev,
return err;
}
-static int
-set_light_buttons(struct light_device_t *dev,
- struct light_state_t const* state)
-{
+static int set_light_buttons(struct light_device_t* dev, struct light_state_t const* state) {
int err = 0;
- if(!dev) {
+ if (!dev) {
return -1;
}
@@ -329,9 +293,7 @@ set_light_buttons(struct light_device_t *dev,
}
/** Close the lights device */
-static int
-close_lights(struct light_device_t *dev)
-{
+static int close_lights(struct light_device_t* dev) {
if (dev) {
free(dev);
}
@@ -346,10 +308,8 @@ close_lights(struct light_device_t *dev)
/** Open a new instance of a lights device using name */
static int open_lights(const struct hw_module_t* module, char const* name,
- struct hw_device_t** device)
-{
- int (*set_light)(struct light_device_t *dev,
- struct light_state_t const* state);
+ struct hw_device_t** device) {
+ int (*set_light)(struct light_device_t * dev, struct light_state_t const* state);
if (0 == strcmp(LIGHT_ID_BACKLIGHT, name))
set_light = set_light_backlight;
@@ -370,10 +330,9 @@ static int open_lights(const struct hw_module_t* module, char const* name,
pthread_once(&g_init, init_globals);
- struct light_device_t *dev = malloc(sizeof(struct light_device_t));
+ struct light_device_t* dev = malloc(sizeof(struct light_device_t));
- if(!dev)
- return -ENOMEM;
+ if (!dev) return -ENOMEM;
memset(dev, 0, sizeof(*dev));
diff --git a/power/power.c b/power/power.c
index 78c82a9..ae1006f 100644
--- a/power/power.c
+++ b/power/power.c
@@ -19,13 +19,13 @@
#include <hardware/hardware.h>
#include <hardware/power.h>
-#include <stdbool.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <utils/Log.h>
@@ -43,8 +43,7 @@ static int boostpulse_fd = -1;
static int current_power_profile = -1;
static int requested_power_profile = -1;
-static int sysfs_write_str(char *path, char *s)
-{
+static int sysfs_write_str(char* path, char* s) {
char buf[80];
int len;
int ret = 0;
@@ -54,7 +53,7 @@ static int sysfs_write_str(char *path, char *s)
if (fd < 0) {
strerror_r(errno, buf, sizeof(buf));
ALOGE("Error opening %s: %s\n", path, buf);
- return -1 ;
+ return -1;
}
len = write(fd, s, strlen(s));
@@ -69,15 +68,13 @@ static int sysfs_write_str(char *path, char *s)
return ret;
}
-static int sysfs_write_int(char *path, int value)
-{
+static int sysfs_write_int(char* path, int value) {
char buf[80];
snprintf(buf, 80, "%d", value);
return sysfs_write_str(path, buf);
}
-static bool check_governor(void)
-{
+static bool check_governor(void) {
struct stat s;
int err = stat(INTERACTIVE_PATH, &s);
if (err != 0) return false;
@@ -85,18 +82,15 @@ static bool check_governor(void)
return false;
}
-static int is_profile_valid(int profile)
-{
+static int is_profile_valid(int profile) {
return profile >= 0 && profile < PROFILE_MAX;
}
-static void power_init(__attribute__((unused)) struct power_module *module)
-{
+static void power_init(__attribute__((unused)) struct power_module* module) {
ALOGI("%s", __func__);
}
-static int boostpulse_open()
-{
+static int boostpulse_open() {
pthread_mutex_lock(&lock);
if (boostpulse_fd < 0) {
boostpulse_fd = open(INTERACTIVE_PATH "boostpulse", O_WRONLY);
@@ -106,8 +100,7 @@ static int boostpulse_open()
return boostpulse_fd;
}
-static void power_set_interactive(__attribute__((unused)) struct power_module *module, int on)
-{
+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 yet", __func__);
return;
@@ -121,8 +114,7 @@ static void power_set_interactive(__attribute__((unused)) struct power_module *m
profiles[current_power_profile].hispeed_freq);
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
profiles[current_power_profile].go_hispeed_load);
- sysfs_write_int(INTERACTIVE_PATH "timer_rate",
- profiles[current_power_profile].timer_rate);
+ sysfs_write_int(INTERACTIVE_PATH "timer_rate", profiles[current_power_profile].timer_rate);
sysfs_write_str(INTERACTIVE_PATH "target_loads",
profiles[current_power_profile].target_loads);
} else {
@@ -137,8 +129,7 @@ static void power_set_interactive(__attribute__((unused)) struct power_module *m
}
}
-static void set_power_profile(int profile)
-{
+static void set_power_profile(int profile) {
if (!is_profile_valid(profile)) {
ALOGE("%s: unknown profile: %d", __func__, profile);
return;
@@ -147,108 +138,88 @@ static void set_power_profile(int profile)
// break out early if governor is not interactive
if (!check_governor()) return;
- if (profile == current_power_profile)
- return;
+ if (profile == current_power_profile) return;
ALOGD("%s: setting profile %d", __func__, profile);
- sysfs_write_int(INTERACTIVE_PATH "boost",
- profiles[profile].boost);
- sysfs_write_int(INTERACTIVE_PATH "boostpulse_duration",
- profiles[profile].boostpulse_duration);
- sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
- profiles[profile].go_hispeed_load);
- sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
- profiles[profile].hispeed_freq);
- sysfs_write_str(INTERACTIVE_PATH "above_hispeed_delay",
- profiles[profile].above_hispeed_delay);
- sysfs_write_int(INTERACTIVE_PATH "timer_rate",
- profiles[profile].timer_rate);
- sysfs_write_int(INTERACTIVE_PATH "io_is_busy",
- profiles[profile].io_is_busy);
- sysfs_write_int(INTERACTIVE_PATH "min_sample_time",
- profiles[profile].min_sample_time);
- sysfs_write_int(INTERACTIVE_PATH "max_freq_hysteresis",
- profiles[profile].max_freq_hysteresis);
- sysfs_write_str(INTERACTIVE_PATH "target_loads",
- profiles[profile].target_loads);
- sysfs_write_int(CPUFREQ_LIMIT_PATH "limited_min_freq",
- profiles[profile].limited_min_freq);
- sysfs_write_int(CPUFREQ_LIMIT_PATH "limited_max_freq",
- profiles[profile].limited_max_freq);
+ sysfs_write_int(INTERACTIVE_PATH "boost", profiles[profile].boost);
+ sysfs_write_int(INTERACTIVE_PATH "boostpulse_duration", profiles[profile].boostpulse_duration);
+ sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load", profiles[profile].go_hispeed_load);
+ sysfs_write_int(INTERACTIVE_PATH "hispeed_freq", profiles[profile].hispeed_freq);
+ sysfs_write_str(INTERACTIVE_PATH "above_hispeed_delay", profiles[profile].above_hispeed_delay);
+ sysfs_write_int(INTERACTIVE_PATH "timer_rate", profiles[profile].timer_rate);
+ sysfs_write_int(INTERACTIVE_PATH "io_is_busy", profiles[profile].io_is_busy);
+ sysfs_write_int(INTERACTIVE_PATH "min_sample_time", profiles[profile].min_sample_time);
+ sysfs_write_int(INTERACTIVE_PATH "max_freq_hysteresis", profiles[profile].max_freq_hysteresis);
+ sysfs_write_str(INTERACTIVE_PATH "target_loads", profiles[profile].target_loads);
+ sysfs_write_int(CPUFREQ_LIMIT_PATH "limited_min_freq", profiles[profile].limited_min_freq);
+ sysfs_write_int(CPUFREQ_LIMIT_PATH "limited_max_freq", profiles[profile].limited_max_freq);
current_power_profile = profile;
}
-static void process_video_encode_hint(void *metadata)
-{
+static void process_video_encode_hint(void* metadata) {
int on;
- if (!metadata)
- return;
+ if (!metadata) return;
/* Break out early if governor is not interactive */
- if (!check_governor())
- return;
+ if (!check_governor()) return;
on = !strncmp(metadata, STATE_ON, sizeof(STATE_ON));
- sysfs_write_int(INTERACTIVE_PATH "timer_rate", on ?
- VID_ENC_TIMER_RATE :
- profiles[current_power_profile].timer_rate);
+ sysfs_write_int(INTERACTIVE_PATH "timer_rate",
+ on ? VID_ENC_TIMER_RATE : profiles[current_power_profile].timer_rate);
- sysfs_write_int(INTERACTIVE_PATH "io_is_busy", on ?
- VID_ENC_IO_IS_BUSY :
- profiles[current_power_profile].io_is_busy);
+ sysfs_write_int(INTERACTIVE_PATH "io_is_busy",
+ on ? VID_ENC_IO_IS_BUSY : profiles[current_power_profile].io_is_busy);
}
-static void power_hint(__attribute__((unused)) struct power_module *module,
- power_hint_t hint, void *data)
-{
+static void power_hint(__attribute__((unused)) struct power_module* module, power_hint_t hint,
+ void* data) {
char buf[80];
int len;
switch (hint) {
- case POWER_HINT_INTERACTION:
- case POWER_HINT_LAUNCH:
- case POWER_HINT_CPU_BOOST:
- if (!is_profile_valid(current_power_profile)) {
- ALOGD("%s: no power profile selected yet", __func__);
- return;
- }
-
- if (!profiles[current_power_profile].boostpulse_duration)
- return;
-
- // break out early if governor is not interactive
- if (!check_governor()) return;
-
- if (boostpulse_open() >= 0) {
- snprintf(buf, sizeof(buf), "%d", 1);
- len = write(boostpulse_fd, &buf, sizeof(buf));
- if (len < 0) {
- strerror_r(errno, buf, sizeof(buf));
- ALOGE("Error writing to boostpulse: %s\n", buf);
-
- pthread_mutex_lock(&lock);
- close(boostpulse_fd);
- boostpulse_fd = -1;
- pthread_mutex_unlock(&lock);
+ case POWER_HINT_INTERACTION:
+ case POWER_HINT_LAUNCH:
+ case POWER_HINT_CPU_BOOST:
+ if (!is_profile_valid(current_power_profile)) {
+ ALOGD("%s: no power profile selected yet", __func__);
+ return;
+ }
+
+ if (!profiles[current_power_profile].boostpulse_duration) return;
+
+ // break out early if governor is not interactive
+ if (!check_governor()) return;
+
+ if (boostpulse_open() >= 0) {
+ snprintf(buf, sizeof(buf), "%d", 1);
+ len = write(boostpulse_fd, &buf, sizeof(buf));
+ if (len < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error writing to boostpulse: %s\n", buf);
+
+ pthread_mutex_lock(&lock);
+ close(boostpulse_fd);
+ boostpulse_fd = -1;
+ pthread_mutex_unlock(&lock);
+ }
}
- }
- break;
- case POWER_HINT_SET_PROFILE:
- pthread_mutex_lock(&lock);
- set_power_profile(*(int32_t *)data);
- pthread_mutex_unlock(&lock);
- break;
- case POWER_HINT_VIDEO_ENCODE:
- pthread_mutex_lock(&lock);
- process_video_encode_hint(data);
- pthread_mutex_unlock(&lock);
- break;
- default:
- break;
+ break;
+ case POWER_HINT_SET_PROFILE:
+ pthread_mutex_lock(&lock);
+ set_power_profile(*(int32_t*)data);
+ pthread_mutex_unlock(&lock);
+ break;
+ case POWER_HINT_VIDEO_ENCODE:
+ pthread_mutex_lock(&lock);
+ process_video_encode_hint(data);
+ pthread_mutex_unlock(&lock);
+ break;
+ default:
+ break;
}
}
@@ -256,9 +227,7 @@ static struct hw_module_methods_t power_module_methods = {
.open = NULL,
};
-static int get_feature(__attribute__((unused)) struct power_module *module,
- feature_t feature)
-{
+static int get_feature(__attribute__((unused)) struct power_module* module, feature_t feature) {
if (feature == POWER_FEATURE_SUPPORTED_PROFILES) {
return PROFILE_MAX;
}
@@ -266,15 +235,16 @@ static int get_feature(__attribute__((unused)) struct power_module *module,
}
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 = "msm8960 Power HAL",
- .author = "Gabriele M",
- .methods = &power_module_methods,
- },
+ .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 = "msm8960 Power HAL",
+ .author = "Gabriele M",
+ .methods = &power_module_methods,
+ },
.init = power_init,
.setInteractive = power_set_interactive,
diff --git a/power/power.h b/power/power.h
index 1e39cf1..112d569 100644
--- a/power/power.h
+++ b/power/power.h
@@ -37,87 +37,91 @@ typedef struct governor_settings {
int hispeed_freq_off;
int timer_rate;
int timer_rate_off;
- char *above_hispeed_delay;
+ char* above_hispeed_delay;
int io_is_busy;
int min_sample_time;
int max_freq_hysteresis;
- char *target_loads;
- char *target_loads_off;
+ char* target_loads;
+ char* target_loads_off;
int limited_min_freq;
int limited_max_freq;
} power_profile;
static power_profile profiles[PROFILE_MAX] = {
- [PROFILE_POWER_SAVE] = {
- .boost = 0,
- .boostpulse_duration = 40000,
- .go_hispeed_load = 90,
- .go_hispeed_load_off = 110,
- .hispeed_freq = 702000,
- .hispeed_freq_off = 702000,
- .timer_rate = 20000,
- .timer_rate_off = 50000,
- .above_hispeed_delay = "19000 1400000:39000",
- .io_is_busy = 1,
- .min_sample_time = 39000,
- .max_freq_hysteresis = 99000,
- .target_loads = "85 1700000:90",
- .target_loads_off = "95 1728000:99",
- .limited_min_freq = 384000,
- .limited_max_freq = 1026000,
- },
- [PROFILE_BALANCED] = {
- .boost = 0,
- .boostpulse_duration = 40000,
- .go_hispeed_load = 90,
- .go_hispeed_load_off = 110,
- .hispeed_freq = 918000,
- .hispeed_freq_off = 918000,
- .timer_rate = 20000,
- .timer_rate_off = 50000,
- .above_hispeed_delay = "19000 1400000:39000",
- .io_is_busy = 1,
- .min_sample_time = 39000,
- .max_freq_hysteresis = 99000,
- .target_loads = "85 1700000:90",
- .target_loads_off = "95 1728000:99",
- .limited_min_freq = 384000,
- .limited_max_freq = 1728000,
- },
- [PROFILE_HIGH_PERFORMANCE] = {
- .boost = 1,
- .boostpulse_duration = 40000,
- .go_hispeed_load = 50,
- .go_hispeed_load_off = 110,
- .hispeed_freq = 1134000,
- .hispeed_freq_off = 1134000,
- .timer_rate = 20000,
- .timer_rate_off = 50000,
- .above_hispeed_delay = "19000 1400000:39000",
- .io_is_busy = 1,
- .min_sample_time = 39000,
- .max_freq_hysteresis = 99000,
- .target_loads = "80 1700000:90",
- .target_loads_off = "90 1728000:99",
- .limited_min_freq = 384000,
- .limited_max_freq = 1728000,
- },
- [PROFILE_BIAS_POWER_SAVE] = {
- .boost = 0,
- .boostpulse_duration = 40000,
- .go_hispeed_load = 90,
- .go_hispeed_load_off = 110,
- .hispeed_freq = 702000,
- .hispeed_freq_off = 702000,
- .timer_rate = 20000,
- .timer_rate_off = 50000,
- .above_hispeed_delay = "19000 1400000:39000",
- .io_is_busy = 1,
- .min_sample_time = 39000,
- .max_freq_hysteresis = 99000,
- .target_loads = "85 1700000:90",
- .target_loads_off = "95 1728000:99",
- .limited_min_freq = 384000,
- .limited_max_freq = 1242000,
- },
+ [PROFILE_POWER_SAVE] =
+ {
+ .boost = 0,
+ .boostpulse_duration = 40000,
+ .go_hispeed_load = 90,
+ .go_hispeed_load_off = 110,
+ .hispeed_freq = 702000,
+ .hispeed_freq_off = 702000,
+ .timer_rate = 20000,
+ .timer_rate_off = 50000,
+ .above_hispeed_delay = "19000 1400000:39000",
+ .io_is_busy = 1,
+ .min_sample_time = 39000,
+ .max_freq_hysteresis = 99000,
+ .target_loads = "85 1700000:90",
+ .target_loads_off = "95 1728000:99",
+ .limited_min_freq = 384000,
+ .limited_max_freq = 1026000,
+ },
+ [PROFILE_BALANCED] =
+ {
+ .boost = 0,
+ .boostpulse_duration = 40000,
+ .go_hispeed_load = 90,
+ .go_hispeed_load_off = 110,
+ .hispeed_freq = 918000,
+ .hispeed_freq_off = 918000,
+ .timer_rate = 20000,
+ .timer_rate_off = 50000,
+ .above_hispeed_delay = "19000 1400000:39000",
+ .io_is_busy = 1,
+ .min_sample_time = 39000,
+ .max_freq_hysteresis = 99000,
+ .target_loads = "85 1700000:90",
+ .target_loads_off = "95 1728000:99",
+ .limited_min_freq = 384000,
+ .limited_max_freq = 1728000,
+ },
+ [PROFILE_HIGH_PERFORMANCE] =
+ {
+ .boost = 1,
+ .boostpulse_duration = 40000,
+ .go_hispeed_load = 50,
+ .go_hispeed_load_off = 110,
+ .hispeed_freq = 1134000,
+ .hispeed_freq_off = 1134000,
+ .timer_rate = 20000,
+ .timer_rate_off = 50000,
+ .above_hispeed_delay = "19000 1400000:39000",
+ .io_is_busy = 1,
+ .min_sample_time = 39000,
+ .max_freq_hysteresis = 99000,
+ .target_loads = "80 1700000:90",
+ .target_loads_off = "90 1728000:99",
+ .limited_min_freq = 384000,
+ .limited_max_freq = 1728000,
+ },
+ [PROFILE_BIAS_POWER_SAVE] =
+ {
+ .boost = 0,
+ .boostpulse_duration = 40000,
+ .go_hispeed_load = 90,
+ .go_hispeed_load_off = 110,
+ .hispeed_freq = 702000,
+ .hispeed_freq_off = 702000,
+ .timer_rate = 20000,
+ .timer_rate_off = 50000,
+ .above_hispeed_delay = "19000 1400000:39000",
+ .io_is_busy = 1,
+ .min_sample_time = 39000,
+ .max_freq_hysteresis = 99000,
+ .target_loads = "85 1700000:90",
+ .target_loads_off = "95 1728000:99",
+ .limited_min_freq = 384000,
+ .limited_max_freq = 1242000,
+ },
};