sdm710-common: power: Use monotonic time for interaction boost
Using the wall clock will cause boosts to be disabled when/if the clock is adjusted backward. Bug: 29191415 Bug: 29208304 Change-Id: I8af5f40b46d996ce7bccb8324fc186e2f3a5b267 Signed-off-by: SamarV-121 <samarvispute121@gmail.com>
This commit is contained in:
parent
3d731adb1f
commit
f945859627
3 changed files with 23 additions and 11 deletions
|
@ -201,11 +201,11 @@ static int process_activity_launch_hint(void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_interaction_hint(void* data) {
|
static int process_interaction_hint(void* data) {
|
||||||
struct timeval cur_boost_timeval = {0, 0};
|
static struct timespec s_previous_boost_timespec;
|
||||||
static unsigned long long previous_boost_time = 0;
|
static int s_previous_duration = 0;
|
||||||
static unsigned long long previous_duration = 0;
|
|
||||||
unsigned long long cur_boost_time;
|
struct timespec cur_boost_timespec;
|
||||||
double elapsed_time;
|
long long elapsed_time;
|
||||||
int duration = kMinInteractiveDuration;
|
int duration = kMinInteractiveDuration;
|
||||||
|
|
||||||
if (current_mode != NORMAL_MODE) {
|
if (current_mode != NORMAL_MODE) {
|
||||||
|
@ -221,15 +221,15 @@ static int process_interaction_hint(void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&cur_boost_timeval, NULL);
|
clock_gettime(CLOCK_MONOTONIC, &cur_boost_timespec);
|
||||||
cur_boost_time = cur_boost_timeval.tv_sec * 1000000 + cur_boost_timeval.tv_usec;
|
|
||||||
elapsed_time = (double) (cur_boost_time - previous_boost_time);
|
elapsed_time = calc_timespan_us(s_previous_boost_timespec, cur_boost_timespec);
|
||||||
// don't hint if previous hint's duration covers this hint's duration
|
// don't hint if previous hint's duration covers this hint's duration
|
||||||
if ((previous_duration * 1000) > (elapsed_time + duration * 1000)) {
|
if ((s_previous_duration * 1000) > (elapsed_time + duration * 1000)) {
|
||||||
return HINT_HANDLED;
|
return HINT_HANDLED;
|
||||||
}
|
}
|
||||||
previous_boost_time = cur_boost_time;
|
s_previous_boost_timespec = cur_boost_timespec;
|
||||||
previous_duration = duration;
|
s_previous_duration = duration;
|
||||||
|
|
||||||
if (duration >= kMinFlingDuration) {
|
if (duration >= kMinFlingDuration) {
|
||||||
perf_hint_enable_with_type(VENDOR_HINT_SCROLL_BOOST, -1, SCROLL_PREFILING);
|
perf_hint_enable_with_type(VENDOR_HINT_SCROLL_BOOST, -1, SCROLL_PREFILING);
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
#define LOG_TAG "QCOM PowerHAL"
|
#define LOG_TAG "QCOM PowerHAL"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
|
#define USINSEC 1000000L
|
||||||
|
#define NSINUS 1000L
|
||||||
|
|
||||||
char scaling_gov_path[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
|
char scaling_gov_path[4][80] = {"sys/devices/system/cpu/cpu0/cpufreq/scaling_governor",
|
||||||
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
|
"sys/devices/system/cpu/cpu1/cpufreq/scaling_governor",
|
||||||
"sys/devices/system/cpu/cpu2/cpufreq/scaling_governor",
|
"sys/devices/system/cpu/cpu2/cpufreq/scaling_governor",
|
||||||
|
@ -331,3 +334,10 @@ void undo_initial_hint_action() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long long calc_timespan_us(struct timespec start, struct timespec end) {
|
||||||
|
long long diff_in_us = 0;
|
||||||
|
diff_in_us += (end.tv_sec - start.tv_sec) * USINSEC;
|
||||||
|
diff_in_us += (end.tv_nsec - start.tv_nsec) / NSINUS;
|
||||||
|
return diff_in_us;
|
||||||
|
}
|
||||||
|
|
|
@ -45,3 +45,5 @@ void release_request(int lock_handle);
|
||||||
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
|
int interaction_with_handle(int lock_handle, int duration, int num_args, int opt_list[]);
|
||||||
int perf_hint_enable(int hint_id, int duration);
|
int perf_hint_enable(int hint_id, int duration);
|
||||||
int perf_hint_enable_with_type(int hint_id, int duration, int type);
|
int perf_hint_enable_with_type(int hint_id, int duration, int type);
|
||||||
|
|
||||||
|
long long calc_timespan_us(struct timespec start, struct timespec end);
|
||||||
|
|
Loading…
Reference in a new issue