summaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2016-06-07 18:44:31 -0700
committerMichael Bestas <mkbestas@lineageos.org>2019-10-23 01:12:57 +0300
commit2c5b2b8afe66195d926adc0e4085b36625f2f4b0 (patch)
treee1f1a419da3e2a63e1072d54d6ba4255b5095ecb /utils.c
parent6102e6812c9437dc7a5fda88554d73ea923702cb (diff)
downloadvendor_qcom_opensource_power-2c5b2b8afe66195d926adc0e4085b36625f2f4b0.tar.gz
vendor_qcom_opensource_power-2c5b2b8afe66195d926adc0e4085b36625f2f4b0.tar.bz2
vendor_qcom_opensource_power-2c5b2b8afe66195d926adc0e4085b36625f2f4b0.zip
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 (cherry picked from commit 2bf13f822cf39123ee0e97e40caf1288ba4f457a)
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index ce2f2a9..38b5803 100644
--- a/utils.c
+++ b/utils.c
@@ -43,6 +43,9 @@
#define LOG_TAG "QTI PowerHAL"
#include <log/log.h>
+#define USINSEC 1000000L
+#define NSINUS 1000L
+
#define SOC_ID_0 "/sys/devices/soc0/soc_id"
#define SOC_ID_1 "/sys/devices/system/soc/soc0/id"
@@ -359,3 +362,10 @@ int get_soc_id(void) {
close(fd);
return soc_id;
}
+
+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;
+}