power: Spring cleanup
* Cleanup SoC specific files:
- Fix code spacing and indentation
- Remove dead code
- Remove useless comments
- Remove useless logs
- Make code uniform between the files so it's easier to diff
- Use declared enums when possible for power hints
Change-Id: Ie1378c94c53b33299927c5eb1bfc19f1a42b8743
diff --git a/power-660.c b/power-660.c
index d6a3003..f9d41d8 100644
--- a/power-660.c
+++ b/power-660.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -52,8 +53,6 @@
static int video_encode_hint_sent;
-static void process_video_encode_hint(void *metadata);
-
/**
* If target is SDM630:
* return true
@@ -72,94 +71,6 @@
return is_SDM630;
}
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
- case POWER_HINT_VSYNC:
- break;
- case POWER_HINT_VIDEO_ENCODE:
- {
- process_video_encode_hint(data);
- return HINT_HANDLED;
- }
- default:
- break;
- }
- return HINT_NONE;
-}
-
-int set_interactive_override(int on)
-{
- char governor[80];
- int resource_values[20];
- int num_resources;
-
- ALOGI("Got set_interactive hint");
-
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- return HINT_HANDLED;
- }
- }
- }
- }
-
- if (!on) {
- /* Display off. */
- if (is_interactive_governor(governor)) {
- /*
- 1. CPUfreq params
- - hispeed freq for big - 1113Mhz
- - go hispeed load for big - 95
- - above_hispeed_delay for big - 40ms
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- */
- if(is_target_SDM630()){
- int res[] = { 0x41414000, 0x459,
- 0x41410000, 0x5F,
- 0x41400000, 0x4,
- 0x41820000, 0xA };
- memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = ARRAY_SIZE(res);
- }
- /*
- 1. CPUfreq params
- - hispeed freq for little - 902Mhz
- - go hispeed load for little - 95
- - above_hispeed_delay for little - 40ms
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- 3. Sched group upmigrate - 500
- */
- else{
- int res[] = { 0x41414100, 0x386,
- 0x41410100, 0x5F,
- 0x41400100, 0x4,
- 0x41820000, 0xA,
- 0x40C54000, 0x1F4};
- memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
- num_resources = ARRAY_SIZE(res);
-
- }
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, num_resources);
- }
- } else {
- /* Display on. */
- if (is_interactive_governor(governor)) {
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- }
- }
- return HINT_HANDLED;
-}
-
-
-/* Video Encode Hint */
static void process_video_encode_hint(void *metadata)
{
char governor[80];
@@ -167,21 +78,19 @@
int num_resources;
struct video_encode_metadata_t video_encode_metadata;
- ALOGI("Got process_video_encode_hint");
-
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- // return HINT_HANDLED;
- }
- }
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ return;
+ }
}
+ }
+ }
+
+ if (!metadata) {
+ return;
}
/* Initialize encode metadata struct fields. */
@@ -189,52 +98,50 @@
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
- if (metadata) {
- if (parse_video_encode_metadata((char *)metadata,
+ if (parse_video_encode_metadata((char *)metadata,
&video_encode_metadata) == -1) {
- ALOGE("Error occurred while parsing metadata.");
- return;
- }
- } else {
+ ALOGE("Error occurred while parsing metadata.");
return;
}
if (video_encode_metadata.state == 1) {
if (is_interactive_governor(governor)) {
- /*
- 1. CPUfreq params
- - hispeed freq for big - 1113Mhz
- - go hispeed load for big - 95
- - above_hispeed_delay for big - 40ms
- - target loads - 95
- - nr_run - 5
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- */
- if(is_target_SDM630()){
- int res[] = { 0x41414000, 0x459,
- 0x41410000, 0x5F,
- 0x41400000, 0x4,
- 0x41420000, 0x5F,
- 0x40C2C000, 0X5,
- 0x41820000, 0xA};
+ if (is_target_SDM630()) {
+ /*
+ 1. CPUfreq params
+ - hispeed freq for big - 1113Mhz
+ - go hispeed load for big - 95
+ - above_hispeed_delay for big - 40ms
+ - target loads - 95
+ - nr_run - 5
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ */
+ int res[] = {
+ HISPEED_FREQ_BIG, 0x459,
+ GO_HISPEED_LOAD_BIG, 0x5F,
+ ABOVE_HISPEED_DELAY_BIG, 0x4,
+ TARGET_LOADS_BIG, 0x5F,
+ SCHED_IDLE_NR_RUN, 0X5,
+ CPUBW_HWMON_SAMPLE_MS, 0xA
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);
-
- }
- /*
- 1. CPUfreq params
- - hispeed freq for little - 902Mhz
- - go hispeed load for little - 95
- - above_hispeed_delay for little - 40ms
- 2. BusDCVS V2 params
- - Sample_ms of 10ms
- */
- else{
- int res[] = { 0x41414100, 0x386,
- 0x41410100, 0x5F,
- 0x41400100, 0x4,
- 0x41820000, 0xA};
+ } else {
+ /*
+ 1. CPUfreq params
+ - hispeed freq for little - 902Mhz
+ - go hispeed load for little - 95
+ - above_hispeed_delay for little - 40ms
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ */
+ int res[] = {
+ HISPEED_FREQ_LITTLE, 0x386,
+ GO_HISPEED_LOAD_LITTLE, 0x5F,
+ ABOVE_HISPEED_DELAY_LITTLE, 0x4,
+ CPUBW_HWMON_SAMPLE_MS, 0xA
+ };
memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
num_resources = ARRAY_SIZE(res);
}
@@ -250,5 +157,88 @@
video_encode_hint_sent = 0;
}
}
- return;
+}
+
+int power_hint_override(power_hint_t hint, void *data)
+{
+ switch (hint) {
+ case POWER_HINT_VSYNC:
+ break;
+ case POWER_HINT_VIDEO_ENCODE:
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
+ default:
+ break;
+ }
+ return HINT_NONE;
+}
+
+int set_interactive_override(int on)
+{
+ char governor[80];
+ int resource_values[20];
+ int num_resources;
+
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ return HINT_NONE;
+ }
+ }
+ }
+ }
+
+ if (!on) {
+ /* Display off. */
+ if (is_interactive_governor(governor)) {
+ if (is_target_SDM630()) {
+ /*
+ 1. CPUfreq params
+ - hispeed freq for big - 1113Mhz
+ - go hispeed load for big - 95
+ - above_hispeed_delay for big - 40ms
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ */
+ int res[] = {
+ HISPEED_FREQ_BIG, 0x459,
+ GO_HISPEED_LOAD_BIG, 0x5F,
+ ABOVE_HISPEED_DELAY_BIG, 0x4,
+ CPUBW_HWMON_SAMPLE_MS, 0xA
+ };
+ memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
+ num_resources = ARRAY_SIZE(res);
+ } else {
+ /*
+ 1. CPUfreq params
+ - hispeed freq for little - 902Mhz
+ - go hispeed load for little - 95
+ - above_hispeed_delay for little - 40ms
+ 2. BusDCVS V2 params
+ - Sample_ms of 10ms
+ 3. Sched group upmigrate - 500
+ */
+ int res[] = {
+ HISPEED_FREQ_LITTLE, 0x386,
+ GO_HISPEED_LOAD_LITTLE, 0x5F,
+ ABOVE_HISPEED_DELAY_LITTLE, 0x4,
+ CPUBW_HWMON_SAMPLE_MS, 0xA,
+ SCHED_GROUP_UP_MIGRATE, 0x1F4
+ };
+ memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
+ num_resources = ARRAY_SIZE(res);
+
+ }
+ perform_hint_action(DISPLAY_STATE_HINT_ID,
+ resource_values, num_resources);
+ }
+ } else {
+ /* Display on. */
+ if (is_interactive_governor(governor)) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ }
+ }
+ return HINT_HANDLED;
}
diff --git a/power-8084.c b/power-8084.c
index 0555981..2065e66 100644
--- a/power-8084.c
+++ b/power-8084.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -86,13 +87,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 5;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -122,7 +124,6 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
@@ -173,7 +174,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -200,15 +200,11 @@
resources_interaction_boost);
}
return HINT_HANDLED;
- }
case POWER_HINT_LAUNCH:
- {
duration = 2000;
-
interaction(duration, ARRAY_SIZE(resources_launch),
resources_launch);
return HINT_HANDLED;
- }
default:
break;
}
@@ -221,7 +217,6 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -239,25 +234,23 @@
undo_hint_action(DISPLAY_STATE_HINT_ID_2);
if (is_ondemand_governor(governor)) {
- int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF};
-
+ int resource_values[] = {
+ MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
-
- return HINT_HANDLED;
}
} else {
/* Display on */
- int resource_values2[] = { CPUS_ONLINE_MIN_2 };
+ int resource_values2[] = {
+ CPUS_ONLINE_MIN_2
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
resource_values2, ARRAY_SIZE(resource_values2));
if (is_ondemand_governor(governor)) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
-
- return HINT_HANDLED;
}
}
-
- return HINT_NONE;
+ return HINT_HANDLED;
}
diff --git a/power-8226.c b/power-8226.c
index 1d8850d..5339fe5 100644
--- a/power-8226.c
+++ b/power-8226.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -67,13 +68,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 3;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -93,7 +95,6 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance,
ARRAY_SIZE(profile_high_performance));
ALOGD("%s: Set performance mode", __func__);
-
}
current_power_profile = profile;
@@ -126,7 +127,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -148,7 +148,6 @@
interaction(duration, ARRAY_SIZE(resources_interaction_boost),
resources_interaction_boost);
return HINT_HANDLED;
- }
default:
break;
}
diff --git a/power-845.c b/power-845.c
index 1bc290f..0307ca9 100644
--- a/power-845.c
+++ b/power-845.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -27,7 +28,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+#define LOG_NIDEBUG 0
#include <errno.h>
#include <string.h>
@@ -48,21 +49,22 @@
#include "performance.h"
#include "power-common.h"
-static int display_fd;
#define SYS_DISPLAY_PWR "/sys/kernel/hbtp/display_pwr"
+static int display_fd;
+
int power_hint_override(power_hint_t hint, void *UNUSED(data))
{
int ret_val = HINT_NONE;
- switch(hint) {
+ switch (hint) {
case POWER_HINT_INTERACTION:
- {
- int resources[] = {0x40800100, 0x553};
+ int resources[] = {
+ MIN_FREQ_LITTLE_CORE_0, 0x553
+ };
int duration = 100;
interaction(duration, ARRAY_SIZE(resources), resources);
ret_val = HINT_HANDLED;
- }
- break;
+ break;
default:
break;
}
@@ -75,40 +77,33 @@
static const char *display_off = "0";
char err_buf[80];
static int init_interactive_hint = 0;
- static int set_i_count = 0;
int rc = 0;
- set_i_count ++;
- ALOGI("Got set_interactive hint on= %d, count= %d\n", on, set_i_count);
-
- if (init_interactive_hint == 0)
- {
- //First time the display is turned off
+ if (init_interactive_hint == 0) {
+ // First time the display is turned off
display_fd = TEMP_FAILURE_RETRY(open(SYS_DISPLAY_PWR, O_RDWR));
if (display_fd < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error opening %s: %s\n", SYS_DISPLAY_PWR, err_buf);
- }
- else
+ } else {
init_interactive_hint = 1;
- }
- else
- if (!on ) {
+ }
+ } else {
+ if (!on) {
/* Display off. */
rc = TEMP_FAILURE_RETRY(write(display_fd, display_off, strlen(display_off)));
if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error writing %s to %s: %s\n", display_off, SYS_DISPLAY_PWR, err_buf);
}
- }
- else {
+ } else {
/* Display on */
rc = TEMP_FAILURE_RETRY(write(display_fd, display_on, strlen(display_on)));
if (rc < 0) {
- strerror_r(errno,err_buf,sizeof(err_buf));
+ strerror_r(errno, err_buf, sizeof(err_buf));
ALOGE("Error writing %s to %s: %s\n", display_on, SYS_DISPLAY_PWR, err_buf);
}
}
-
- return HINT_HANDLED; /* Don't excecute this code path, not in use */
+ }
+ return HINT_HANDLED;
}
diff --git a/power-8610.c b/power-8610.c
index b0313df..10f002b 100644
--- a/power-8610.c
+++ b/power-8610.c
@@ -63,13 +63,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 3;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -89,7 +90,6 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance,
ARRAY_SIZE(profile_high_performance));
ALOGD("%s: Set performance mode", __func__);
-
}
current_power_profile = profile;
@@ -122,7 +122,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -144,7 +143,6 @@
interaction(duration, ARRAY_SIZE(resources_interaction_boost),
resources_interaction_boost);
return HINT_HANDLED;
- }
default:
break;
}
diff --git a/power-8909.c b/power-8909.c
index a5c4994..cf2056b 100644
--- a/power-8909.c
+++ b/power-8909.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -47,7 +49,6 @@
#include "performance.h"
#include "power-common.h"
-
static void process_video_encode_hint(void *metadata)
{
char governor[80];
@@ -55,7 +56,10 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
+ return;
+ }
+ if (!metadata) {
return;
}
@@ -64,41 +68,35 @@
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
- if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return;
- }
- } else {
+ if (parse_video_encode_metadata((char *)metadata,
+ &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
return;
}
if (video_encode_metadata.state == 1) {
if (is_interactive_governor(governor)) {
- int resource_values[] = {HS_FREQ_800, THREAD_MIGRATION_SYNC_OFF};
+ int resource_values[] = {
+ HS_FREQ_800, THREAD_MIGRATION_SYNC_OFF
+ };
perform_hint_action(video_encode_metadata.hint_id,
resource_values, ARRAY_SIZE(resource_values));
}
} else if (video_encode_metadata.state == 0) {
if (is_interactive_governor(governor)) {
- undo_hint_action(video_encode_metadata.hint_id);
+ undo_hint_action(video_encode_metadata.hint_id);
}
}
}
int power_hint_override(power_hint_t hint, void *data)
{
- switch(hint) {
+ switch (hint) {
case POWER_HINT_VIDEO_ENCODE:
- {
- process_video_encode_hint(data);
- return HINT_HANDLED;
- }
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
default:
- {
break;
- }
}
return HINT_NONE;
}
diff --git a/power-8916.c b/power-8916.c
index affb2a2..923cfd4 100644
--- a/power-8916.c
+++ b/power-8916.c
@@ -102,13 +102,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 3;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -128,6 +129,7 @@
ARRAY_SIZE(profile_power_save_8939));
}
ALOGD("%s: Set powersave mode", __func__);
+
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
if (is_target_8916()) {
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_high_performance_8916,
@@ -137,7 +139,6 @@
ARRAY_SIZE(profile_power_save_8939));
}
ALOGD("%s: Set performance mode", __func__);
-
}
current_power_profile = profile;
@@ -188,7 +189,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -215,15 +215,11 @@
resources_interaction_boost);
}
return HINT_HANDLED;
- }
case POWER_HINT_LAUNCH:
- {
duration = 2000;
-
interaction(duration, ARRAY_SIZE(resources_launch),
resources_launch);
return HINT_HANDLED;
- }
case POWER_HINT_VIDEO_ENCODE: /* Do nothing for encode case */
return HINT_HANDLED;
case POWER_HINT_VIDEO_DECODE: /* Do nothing for decode case */
@@ -239,13 +235,12 @@
char governor[80];
char tmp_str[NODE_MAX];
- ALOGI("Got set_interactive hint");
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
ALOGE("Can't obtain scaling governor.");
- return HINT_HANDLED;
+ return HINT_NONE;
}
}
}
@@ -255,14 +250,17 @@
/* Display off. */
if (is_target_8916()) {
if (is_interactive_governor(governor)) {
- int resource_values[] = {TR_MS_50, THREAD_MIGRATION_SYNC_OFF};
+ int resource_values[] = {
+ TR_MS_50, THREAD_MIGRATION_SYNC_OFF
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
- } /* Perf time rate set for 8916 target */
- /* End of display hint for 8916 */
+ }
} else {
if (is_interactive_governor(governor)) {
- int resource_values[] = {TR_MS_CPU0_50,TR_MS_CPU4_50, THREAD_MIGRATION_SYNC_OFF};
+ int resource_values[] = {
+ TR_MS_CPU0_50, TR_MS_CPU4_50, THREAD_MIGRATION_SYNC_OFF
+ };
/* Set CPU0 MIN FREQ to 400Mhz avoid extra peak power
impact in volume key press */
@@ -278,8 +276,8 @@
}
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
- } /* Perf time rate set for CORE0,CORE4 8939 target */
- } /* End of display hint for 8939 */
+ }
+ }
} else {
/* Display on. */
if (is_target_8916()) {
@@ -301,7 +299,7 @@
}
undo_hint_action(DISPLAY_STATE_HINT_ID);
}
- } /* End of check condition during the DISPLAY ON case */
+ }
}
return HINT_HANDLED;
}
diff --git a/power-8952.c b/power-8952.c
index 41398cf..acac98d 100644
--- a/power-8952.c
+++ b/power-8952.c
@@ -124,8 +124,6 @@
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
- ALOGI("Got process_video_encode_hint");
-
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
@@ -147,14 +145,13 @@
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
if (parse_video_encode_metadata((char *)metadata,
- &video_encode_metadata) == -1) {
+ &video_encode_metadata) == -1) {
ALOGE("Error occurred while parsing metadata.");
return;
}
if (video_encode_metadata.state == 1) {
if (is_interactive_governor(governor)) {
- /* Sched_load and migration_notif */
int resource_values[] = {
INT_OP_CLUSTER0_USE_SCHED_LOAD, 0x1,
INT_OP_CLUSTER1_USE_SCHED_LOAD, 0x1,
@@ -204,8 +201,6 @@
{
char governor[80];
- ALOGI("Got set_interactive hint");
-
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
@@ -225,12 +220,9 @@
INT_OP_CLUSTER1_TIMER_RATE, BIG_LITTLE_TR_MS_50,
INT_OP_NOTIFY_ON_MIGRATE, 0x00
};
-
- perform_hint_action(
- DISPLAY_STATE_HINT_ID,
- resource_values,
- ARRAY_SIZE(resource_values));
- } /* Perf time rate set for CORE0,CORE4 8952 target */
+ perform_hint_action(DISPLAY_STATE_HINT_ID,
+ resource_values, ARRAY_SIZE(resource_values));
+ }
} else {
/* Display on. */
if (is_interactive_governor(governor)) {
diff --git a/power-8953.c b/power-8953.c
index bf9b777..8031302 100644
--- a/power-8953.c
+++ b/power-8953.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -50,82 +51,24 @@
static int video_encode_hint_sent;
-static void process_video_encode_hint(void *metadata);
-
-int power_hint_override(power_hint_t hint, void *data)
-{
-
- switch(hint) {
- case POWER_HINT_VSYNC:
- break;
- case POWER_HINT_VIDEO_ENCODE:
- {
- process_video_encode_hint(data);
- return HINT_HANDLED;
- }
- default:
- break;
- }
- return HINT_NONE;
-}
-
-int set_interactive_override(int on)
-{
- char governor[80];
-
- ALOGI("Got set_interactive hint");
-
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor, sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- return HINT_HANDLED;
- }
- }
- }
- }
-
- if (!on) {
- /* Display off. */
- if (is_interactive_governor(governor)) {
- /* timer rate - 40mS*/
- int resource_values[] = {0x41424000, 0x28,
- };
- perform_hint_action(DISPLAY_STATE_HINT_ID,
- resource_values, ARRAY_SIZE(resource_values));
- } /* Perf time rate set for CORE0,CORE4 8952 target*/
- } else {
- /* Display on. */
- if (is_interactive_governor(governor)) {
- undo_hint_action(DISPLAY_STATE_HINT_ID);
- }
- }
- return HINT_HANDLED;
-}
-
-
-/* Video Encode Hint */
static void process_video_encode_hint(void *metadata)
{
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
- ALOGI("Got process_video_encode_hint");
-
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU0) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU1) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU2) == -1) {
- if (get_scaling_governor_check_cores(governor,
- sizeof(governor),CPU3) == -1) {
- ALOGE("Can't obtain scaling governor.");
- // return HINT_HANDLED;
- }
- }
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ return;
+ }
}
+ }
+ }
+
+ if (!metadata) {
+ return;
}
/* Initialize encode metadata struct fields. */
@@ -133,24 +76,19 @@
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
- if (metadata) {
- if (parse_video_encode_metadata((char *)metadata,
+ if (parse_video_encode_metadata((char *)metadata,
&video_encode_metadata) == -1) {
- ALOGE("Error occurred while parsing metadata.");
- return;
- }
- } else {
+ ALOGE("Error occurred while parsing metadata.");
return;
}
if (video_encode_metadata.state == 1) {
if (is_interactive_governor(governor)) {
- /* Sched_load and migration_notification disable
- * timer rate - 40mS*/
- int resource_values[] = {0x41430000, 0x1,
- 0x41434000, 0x1,
- 0x41424000, 0x28,
- };
+ int resource_values[] = {
+ INT_OP_CLUSTER0_USE_SCHED_LOAD, 0x1,
+ INT_OP_CLUSTER0_USE_MIGRATION_NOTIF, 0x1,
+ INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_40,
+ };
if (!video_encode_hint_sent) {
perform_hint_action(video_encode_metadata.hint_id,
resource_values, ARRAY_SIZE(resource_values));
@@ -163,5 +101,51 @@
video_encode_hint_sent = 0;
}
}
- return;
+}
+
+int power_hint_override(power_hint_t hint, void *data)
+{
+ switch (hint) {
+ case POWER_HINT_VSYNC:
+ break;
+ case POWER_HINT_VIDEO_ENCODE:
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
+ default:
+ break;
+ }
+ return HINT_NONE;
+}
+
+int set_interactive_override(int on)
+{
+ char governor[80];
+
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU0) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU1) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU2) == -1) {
+ if (get_scaling_governor_check_cores(governor, sizeof(governor), CPU3) == -1) {
+ ALOGE("Can't obtain scaling governor.");
+ return HINT_NONE;
+ }
+ }
+ }
+ }
+
+ if (!on) {
+ /* Display off. */
+ if (is_interactive_governor(governor)) {
+ int resource_values[] = {
+ INT_OP_CLUSTER0_TIMER_RATE, BIG_LITTLE_TR_MS_40
+ };
+ perform_hint_action(DISPLAY_STATE_HINT_ID,
+ resource_values, ARRAY_SIZE(resource_values));
+ }
+ } else {
+ /* Display on. */
+ if (is_interactive_governor(governor)) {
+ undo_hint_action(DISPLAY_STATE_HINT_ID);
+ }
+ }
+ return HINT_HANDLED;
}
diff --git a/power-8974.c b/power-8974.c
index 212f3ec..f5b2970 100644
--- a/power-8974.c
+++ b/power-8974.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -104,13 +105,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 5;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -140,7 +142,6 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
@@ -191,7 +192,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -218,15 +218,11 @@
resources_interaction_boost);
}
return HINT_HANDLED;
- }
case POWER_HINT_LAUNCH:
- {
duration = 2000;
-
interaction(duration, ARRAY_SIZE(resources_launch),
resources_launch);
return HINT_HANDLED;
- }
default:
break;
}
@@ -239,7 +235,6 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -259,27 +254,25 @@
}
if (is_ondemand_governor(governor)) {
- int resource_values[] = {MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF};
-
+ int resource_values[] = {
+ MS_500, SYNC_FREQ_600, OPTIMAL_FREQ_600, THREAD_MIGRATION_SYNC_OFF
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
-
- return HINT_HANDLED;
}
} else {
/* Display on */
if (is_target_8974pro()) {
- int resource_values2[] = {CPUS_ONLINE_MIN_2};
+ int resource_values2[] = {
+ CPUS_ONLINE_MIN_2
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID_2,
resource_values2, ARRAY_SIZE(resource_values2));
}
if (is_ondemand_governor(governor)) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
-
- return HINT_HANDLED;
}
}
-
- return HINT_NONE;
+ return HINT_HANDLED;
}
diff --git a/power-8992.c b/power-8992.c
index 0f02cd6..274adb1 100644
--- a/power-8992.c
+++ b/power-8992.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -88,13 +89,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 5;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -124,36 +126,34 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
}
-static int process_video_encode_hint(void *metadata)
+static void process_video_encode_hint(void *metadata)
{
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
- return HINT_NONE;
+ return;
}
- /* Initialize encode metadata struct fields */
+ if (!metadata) {
+ return;
+ }
+
+ /* Initialize encode metadata struct fields. */
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
- if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return HINT_NONE;
- }
- } else {
- return HINT_NONE;
+ if (parse_video_encode_metadata((char *)metadata,
+ &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
+ return;
}
if (video_encode_metadata.state == 1) {
@@ -164,19 +164,17 @@
* above_hispeed_delay - 40ms
* sched_small_tsk - 50
*/
- int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
-
+ int resource_values[] = {
+ 0x2C07, 0x2F5A, 0x2704, 0x4032
+ };
perform_hint_action(video_encode_metadata.hint_id,
resource_values, ARRAY_SIZE(resource_values));
- return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
if (is_interactive_governor(governor)) {
undo_hint_action(video_encode_metadata.hint_id);
- return HINT_HANDLED;
}
}
- return HINT_NONE;
}
static int resources_interaction_fling_boost[] = {
@@ -216,7 +214,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -243,17 +240,14 @@
resources_interaction_boost);
}
return HINT_HANDLED;
- }
case POWER_HINT_LAUNCH:
- {
duration = 2000;
-
interaction(duration, ARRAY_SIZE(resources_launch),
resources_launch);
return HINT_HANDLED;
- }
case POWER_HINT_VIDEO_ENCODE:
- return process_video_encode_hint(data);
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
default:
break;
}
@@ -266,7 +260,6 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -275,17 +268,17 @@
if (is_interactive_governor(governor)) {
// sched upmigrate = 99, sched downmigrate = 95
// keep the big cores around, but make them very hard to use
- int resource_values[] = { 0x4E63, 0x4F5F };
+ int resource_values[] = {
+ 0x4E63, 0x4F5F
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
- return HINT_HANDLED;
}
} else {
/* Display on */
if (is_interactive_governor(governor)) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
- return HINT_HANDLED;
}
}
- return HINT_NONE;
+ return HINT_HANDLED;
}
diff --git a/power-8994.c b/power-8994.c
index 66c8fff..41af86c 100644
--- a/power-8994.c
+++ b/power-8994.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -96,13 +97,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 5;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -132,36 +134,34 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
}
-static int process_video_encode_hint(void *metadata)
+static void process_video_encode_hint(void *metadata)
{
char governor[80];
struct video_encode_metadata_t video_encode_metadata;
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
- return HINT_NONE;
+ return;
}
- /* Initialize encode metadata struct fields */
+ if (!metadata) {
+ return;
+ }
+
+ /* Initialize encode metadata struct fields. */
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
- if (metadata) {
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return HINT_NONE;
- }
- } else {
- return HINT_NONE;
+ if (parse_video_encode_metadata((char *)metadata,
+ &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
+ return;
}
if (video_encode_metadata.state == 1) {
@@ -172,19 +172,17 @@
* above_hispeed_delay - 40ms
* sched_small_tsk - 50
*/
- int resource_values[] = {0x2C07, 0x2F5A, 0x2704, 0x4032};
-
+ int resource_values[] = {
+ 0x2C07, 0x2F5A, 0x2704, 0x4032
+ };
perform_hint_action(video_encode_metadata.hint_id,
resource_values, ARRAY_SIZE(resource_values));
- return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
if (is_interactive_governor(governor)) {
undo_hint_action(video_encode_metadata.hint_id);
- return HINT_HANDLED;
}
}
- return HINT_NONE;
}
static int resources_interaction_fling_boost[] = {
@@ -224,7 +222,6 @@
switch (hint) {
case POWER_HINT_INTERACTION:
- {
duration = 500; // 500ms by default
if (data) {
int input_duration = *((int*)data);
@@ -251,17 +248,14 @@
resources_interaction_boost);
}
return HINT_HANDLED;
- }
case POWER_HINT_LAUNCH:
- {
duration = 2000;
-
interaction(duration, ARRAY_SIZE(resources_launch),
resources_launch);
return HINT_HANDLED;
- }
case POWER_HINT_VIDEO_ENCODE:
- return process_video_encode_hint(data);
+ process_video_encode_hint(data);
+ return HINT_HANDLED;
default:
break;
}
@@ -274,7 +268,6 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -283,17 +276,17 @@
if (is_interactive_governor(governor)) {
// sched upmigrate = 99, sched downmigrate = 95
// keep the big cores around, but make them very hard to use
- int resource_values[] = { 0x4E63, 0x4F5F };
+ int resource_values[] = {
+ 0x4E63, 0x4F5F
+ };
perform_hint_action(DISPLAY_STATE_HINT_ID,
resource_values, ARRAY_SIZE(resource_values));
- return HINT_HANDLED;
}
} else {
/* Display on */
if (is_interactive_governor(governor)) {
undo_hint_action(DISPLAY_STATE_HINT_ID);
- return HINT_HANDLED;
}
}
- return HINT_NONE;
+ return HINT_HANDLED;
}
diff --git a/power-8996.c b/power-8996.c
index 201fb63..4bd1a58 100644
--- a/power-8996.c
+++ b/power-8996.c
@@ -27,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -48,6 +49,9 @@
#include "performance.h"
#include "power-common.h"
+#define CHECK_HANDLE(x) ((x)>0)
+#define NUM_PERF_MODES 3
+
static int current_power_profile = PROFILE_BALANCED;
static int profile_high_performance[] = {
@@ -77,13 +81,14 @@
};
#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
+int get_number_of_profiles()
+{
return 5;
}
#endif
-static void set_power_profile(int profile) {
-
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -113,15 +118,11 @@
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
}
-#define CHECK_HANDLE(x) ((x)>0)
-#define NUM_PERF_MODES 3
-
typedef enum {
NORMAL_MODE = 0,
SUSTAINED_MODE = 1,
@@ -143,7 +144,7 @@
static int current_mode = NORMAL_MODE;
-static inline int get_perfd_hint_id(perf_mode_type_t type) {
+static inline int get_perfd_hint_id(perf_mode_type_t type) {
int i;
for (i = 0; i < NUM_PERF_MODES; i++) {
if (perf_modes[i].type == type) {
@@ -156,7 +157,6 @@
}
static int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -180,17 +180,16 @@
}
static int process_perf_hint(void *data, perf_mode_type_t mode) {
-
// enable
- if (*(int32_t *)data){
+ if (*(int32_t *)data) {
ALOGI("Enable request for mode: 0x%x", mode);
// check if mode is current mode
- if ( current_mode & mode ) {
+ if (current_mode & mode) {
ALOGD("Mode 0x%x already enabled", mode);
return HINT_HANDLED;
}
// enable requested mode
- if ( 0 != switch_mode(current_mode | mode)) {
+ if (0 != switch_mode(current_mode | mode)) {
ALOGE("Couldn't enable mode 0x%x", mode);
return HINT_NONE;
}
@@ -200,12 +199,12 @@
} else {
ALOGI("Disable request for mode: 0x%x", mode);
// check if mode is enabled
- if ( !(current_mode & mode) ) {
+ if (!(current_mode & mode)) {
ALOGD("Mode 0x%x already disabled", mode);
return HINT_HANDLED;
}
- //disable requested mode
- if ( 0 != switch_mode(current_mode & ~mode)) {
+ // disable requested mode
+ if (0 != switch_mode(current_mode & ~mode)) {
ALOGE("Couldn't disable mode 0x%x", mode);
return HINT_NONE;
}
@@ -228,7 +227,6 @@
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -250,7 +248,6 @@
} else if (video_encode_metadata.state == 0) {
if (is_interactive_governor(governor)) {
release_request(video_encode_handle);
- ALOGI("Video Encode hint stop");
return HINT_HANDLED;
}
}
diff --git a/power-8998.c b/power-8998.c
index bb03ff5..356b68d 100644
--- a/power-8998.c
+++ b/power-8998.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2018 The LineageOS Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,6 +27,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#define LOG_NIDEBUG 0
#include <errno.h>
@@ -47,19 +49,12 @@
#include "hint-data.h"
#include "performance.h"
#include "power-common.h"
-#include "powerhintparser.h"
#define CHECK_HANDLE(x) ((x)>0)
#define NUM_PERF_MODES 3
static int current_power_profile = PROFILE_BALANCED;
-#ifdef INTERACTION_BOOST
-int get_number_of_profiles() {
- return 5;
-}
-#endif
-
static int profile_high_performance[] = {
SCHED_BOOST_ON_V3, 0x1,
MIN_FREQ_BIG_CORE_0, 0xFFF,
@@ -81,8 +76,15 @@
MIN_FREQ_BIG_CORE_0, 0x578,
};
-static void set_power_profile(int profile) {
+#ifdef INTERACTION_BOOST
+int get_number_of_profiles()
+{
+ return 5;
+}
+#endif
+static void set_power_profile(int profile)
+{
if (profile == current_power_profile)
return;
@@ -95,7 +97,7 @@
if (profile == PROFILE_POWER_SAVE) {
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_power_save,
- ARRAY_SIZE(profile_power_save));
+ ARRAY_SIZE(profile_power_save));
ALOGD("%s: Set powersave mode", __func__);
} else if (profile == PROFILE_HIGH_PERFORMANCE) {
@@ -105,14 +107,13 @@
} else if (profile == PROFILE_BIAS_POWER) {
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_power,
- ARRAY_SIZE(profile_bias_power));
+ ARRAY_SIZE(profile_bias_power));
ALOGD("%s: Set bias power mode", __func__);
} else if (profile == PROFILE_BIAS_PERFORMANCE) {
perform_hint_action(DEFAULT_PROFILE_HINT_ID, profile_bias_performance,
ARRAY_SIZE(profile_bias_performance));
ALOGD("%s: Set bias perf mode", __func__);
-
}
current_power_profile = profile;
@@ -124,22 +125,24 @@
VR_MODE = 2,
VR_SUSTAINED_MODE = (SUSTAINED_MODE|VR_MODE),
INVALID_MODE = 0xFF
-}perf_mode_type_t;
+} perf_mode_type_t;
typedef struct perf_mode {
perf_mode_type_t type;
int perf_hint_id;
-}perf_mode_t;
+} perf_mode_t;
-perf_mode_t perf_modes[NUM_PERF_MODES] = { { SUSTAINED_MODE, SUSTAINED_PERF_HINT },
- { VR_MODE, VR_MODE_HINT },
- { VR_SUSTAINED_MODE, VR_MODE_SUSTAINED_PERF_HINT } };
+perf_mode_t perf_modes[NUM_PERF_MODES] = {
+ { SUSTAINED_MODE, SUSTAINED_PERF_HINT },
+ { VR_MODE, VR_MODE_HINT },
+ { VR_SUSTAINED_MODE, VR_MODE_SUSTAINED_PERF_HINT }
+};
static int current_mode = NORMAL_MODE;
-static inline int get_perfd_hint_id(perf_mode_type_t type) {
+static inline int get_perfd_hint_id(perf_mode_type_t type) {
int i;
- for(i=0; i<NUM_PERF_MODES; i++) {
+ for (i = 0; i < NUM_PERF_MODES; i++) {
if (perf_modes[i].type == type) {
ALOGD("Hint id is 0x%x for mode 0x%x", perf_modes[i].perf_hint_id, type);
return perf_modes[i].perf_hint_id;
@@ -150,7 +153,6 @@
}
static int switch_mode(perf_mode_type_t mode) {
-
int hint_id = 0;
static int perfd_mode_handle = -1;
@@ -162,7 +164,7 @@
}
// switch to a perf mode
hint_id = get_perfd_hint_id(mode);
- if(hint_id != 0) {
+ if (hint_id != 0) {
perfd_mode_handle = perf_hint_enable(hint_id, 0);
if (!CHECK_HANDLE(perfd_mode_handle)) {
ALOGE("Failed perf_hint_interaction for mode: 0x%x", mode);
@@ -174,17 +176,16 @@
}
static int process_perf_hint(void *data, perf_mode_type_t mode) {
-
// enable
- if (*(int32_t *)data){
+ if (*(int32_t *)data) {
ALOGI("Enable request for mode: 0x%x", mode);
// check if mode is current mode
- if ( current_mode & mode ) {
+ if (current_mode & mode) {
ALOGD("Mode 0x%x already enabled", mode);
return HINT_HANDLED;
}
// enable requested mode
- if ( 0 != switch_mode(current_mode | mode)) {
+ if (0 != switch_mode(current_mode | mode)) {
ALOGE("Couldn't enable mode 0x%x", mode);
return HINT_NONE;
}
@@ -194,12 +195,12 @@
} else {
ALOGI("Disable request for mode: 0x%x", mode);
// check if mode is enabled
- if ( !(current_mode & mode) ) {
+ if (!(current_mode & mode)) {
ALOGD("Mode 0x%x already disabled", mode);
return HINT_HANDLED;
}
- //disable requested mode
- if ( 0 != switch_mode(current_mode & ~mode)) {
+ // disable requested mode
+ if (0 != switch_mode(current_mode & ~mode)) {
ALOGE("Couldn't disable mode 0x%x", mode);
return HINT_NONE;
}
@@ -216,12 +217,12 @@
struct video_encode_metadata_t video_encode_metadata;
static int video_encode_handle = 0;
- if(!metadata)
- return HINT_NONE;
+ if (!metadata) {
+ return HINT_NONE;
+ }
if (get_scaling_governor(governor, sizeof(governor)) == -1) {
ALOGE("Can't obtain scaling governor.");
-
return HINT_NONE;
}
@@ -229,22 +230,20 @@
memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
video_encode_metadata.state = -1;
- if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) ==
- -1) {
- ALOGE("Error occurred while parsing metadata.");
- return HINT_NONE;
+ if (parse_video_encode_metadata((char *)metadata, &video_encode_metadata) == -1) {
+ ALOGE("Error occurred while parsing metadata.");
+ return HINT_NONE;
}
if (video_encode_metadata.state == 1) {
- if (is_interactive_governor(governor)) {
- video_encode_handle = perf_hint_enable(
- VIDEO_ENCODE_HINT, 0);
- return HINT_HANDLED;
+ if (is_interactive_governor(governor)) {
+ video_encode_handle = perf_hint_enable(
+ VIDEO_ENCODE_HINT, 0);
+ return HINT_HANDLED;
}
} else if (video_encode_metadata.state == 0) {
- if (is_interactive_governor(governor)) {
+ if (is_interactive_governor(governor)) {
release_request(video_encode_handle);
- ALOGI("Video Encode hint stop");
return HINT_HANDLED;
}
}