This repository was archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtkperf_inputflinger_perfboost.patch
More file actions
103 lines (96 loc) · 3.33 KB
/
mtkperf_inputflinger_perfboost.patch
File metadata and controls
103 lines (96 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index dd0082c..af1bc8c 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -67,6 +67,10 @@ static constexpr bool DEBUG_FOCUS = false;
#include <powermanager/PowerManager.h>
#include <utils/Trace.h>
+/// M:PerfBoost include @{
+#include <dlfcn.h>
+/// @}
+
#define INDENT " "
#define INDENT2 " "
#define INDENT3 " "
@@ -103,6 +107,16 @@ constexpr std::chrono::nanoseconds KEY_WAITING_FOR_EVENTS_TIMEOUT = 500ms;
// Number of recent events to keep for debugging purposes.
constexpr size_t RECENT_QUEUE_MAX_SIZE = 10;
+/// M:PerfBoost define @{
+#define MTK_POWERHAL "libpowerhalwrap.so"
+
+int (*powerTouchBoost)(int) = NULL;
+
+typedef int (*boost)(int);
+
+void *pwr_handle = NULL;
+/// @}
+
static inline nsecs_t now() {
return systemTime(SYSTEM_TIME_MONOTONIC);
}
@@ -404,12 +418,33 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
// initialize it here anyways.
mInTouchMode(true),
mFocusedDisplayId(ADISPLAY_ID_DEFAULT) {
+ /// M:PerfBoost init @{
+ void *func;
+ /// @}
mLooper = new Looper(false);
mReporter = createInputReporter();
mKeyRepeatState.lastKeyEntry = nullptr;
policy->getDispatcherConfiguration(&mConfig);
+
+ /// M:PerfBoost init @{
+ pwr_handle = dlopen(MTK_POWERHAL, RTLD_NOW);
+
+ if (pwr_handle == NULL) {
+ ALOGI("Cant load Mediatek Power HAL wrapper (libpowerhalwrap not included in the device tree?)");
+ } else {
+ ALOGI("Successfully loaded Mediatek Power HAL wrapper");
+ }
+
+ if (pwr_handle != NULL) {
+ func = dlsym(pwr_handle, "PowerHal_TouchBoost");
+ powerTouchBoost = reinterpret_cast<boost>(func);
+ if (powerTouchBoost == NULL) {
+ ALOGE("Cant find PowerHal_TouchBoost symbol in libpowerhalwrap");
+ }
+ }
+ /// @}
}
InputDispatcher::~InputDispatcher() {
@@ -425,6 +460,12 @@ InputDispatcher::~InputDispatcher() {
sp<Connection> connection = mConnectionsByFd.begin()->second;
unregisterInputChannel(connection->inputChannel);
}
+
+ /// M:PerfBoost close @{
+ if (pwr_handle != NULL) {
+ dlclose(pwr_handle);
+ }
+ /// @}
}
status_t InputDispatcher::start() {
@@ -770,10 +811,23 @@ bool InputDispatcher::enqueueInboundEventLocked(EventEntry* entry) {
}
case EventEntry::Type::MOTION: {
+ const MotionEntry& motionEntry = static_cast<const MotionEntry&>(*entry);
+
if (shouldPruneInboundQueueLocked(static_cast<MotionEntry&>(*entry))) {
mNextUnblockedEvent = entry;
needWake = true;
}
+
+ /// M:PerfBoost enable/disable @{
+ if (motionEntry.action == AMOTION_EVENT_ACTION_DOWN) {
+ if (powerTouchBoost)
+ powerTouchBoost(10000); // boost 10sec. at most
+ } else if (motionEntry.action == AMOTION_EVENT_ACTION_CANCEL || motionEntry.action == AMOTION_EVENT_ACTION_UP) {
+ if (powerTouchBoost)
+ powerTouchBoost(0); // disable boost
+ }
+ /// @}
+
break;
}
case EventEntry::Type::FOCUS: {