power: Handle launch and interaction hints

Co-authored-by: dianlujitao <dianlujitao@lineageos.org>
Co-authored-by: Michael Bestas <mkbestas@lineageos.org>
Co-authored-by: Quallenauge <Hamsi2k@freenet.de>
Co-authored-by: tomascus <arbiter1000@gmail.com>
Co-authored-by: Wei Wang <wvw@google.com>
Change-Id: I472a177e0a13b0c4201cf0b1e5ddee18a785b683
This commit is contained in:
Vladimir Mikhailov
2016-06-07 18:44:31 -07:00
committed by Michael Bestas
parent b5dbefb18a
commit 7c575afade
11 changed files with 137 additions and 89 deletions

24
utils.c
View File

@@ -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"
@@ -258,6 +261,20 @@ int perf_hint_enable(int hint_id, int duration) {
return lock_handle;
}
// Same as perf_hint_enable, but with the ability to
// choose the type
int perf_hint_enable_with_type(int hint_id, int duration, int type) {
int lock_handle = 0;
if (qcopt_handle) {
if (perf_hint) {
lock_handle = perf_hint(hint_id, NULL, duration, type);
if (lock_handle == -1) ALOGE("Failed to acquire lock.");
}
}
return lock_handle;
}
void release_request(int lock_handle) {
if (qcopt_handle && perf_lock_rel) perf_lock_rel(lock_handle);
}
@@ -364,3 +381,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;
}