summaryrefslogtreecommitdiff
path: root/power-libperfmgr/InteractionHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'power-libperfmgr/InteractionHandler.cpp')
-rw-r--r--power-libperfmgr/InteractionHandler.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/power-libperfmgr/InteractionHandler.cpp b/power-libperfmgr/InteractionHandler.cpp
index 79754823..da6a9173 100644
--- a/power-libperfmgr/InteractionHandler.cpp
+++ b/power-libperfmgr/InteractionHandler.cpp
@@ -28,12 +28,14 @@
#include "InteractionHandler.h"
-#define FB_IDLE_PATH "/sys/class/drm/card0/device/idle_state"
#define MAX_LENGTH 64
#define MSINSEC 1000L
#define USINMS 1000000L
+static const std::vector<std::string> fb_idle_patch = {"/sys/class/drm/card0/device/idle_state",
+ "/sys/class/graphics/fb0/idle_state"};
+
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const &hint_manager)
: mState(INTERACTION_STATE_UNINITIALIZED),
mWaitMs(100),
@@ -46,17 +48,27 @@ InteractionHandler::~InteractionHandler() {
Exit();
}
+static int fb_idle_open(void) {
+ int fd;
+ for (auto &path : fb_idle_patch) {
+ fd = open(path.c_str(), O_RDONLY);
+ if (fd >= 0)
+ return fd;
+ }
+ ALOGE("Unable to open fb idle state path (%d)", errno);
+ return -1;
+}
+
bool InteractionHandler::Init() {
std::lock_guard<std::mutex> lk(mLock);
if (mState != INTERACTION_STATE_UNINITIALIZED)
return true;
- mIdleFd = open(FB_IDLE_PATH, O_RDONLY);
- if (mIdleFd < 0) {
- ALOGE("Unable to open idle state path (%d)", errno);
+ int fd = fb_idle_open();
+ if (fd < 0)
return false;
- }
+ mIdleFd = fd;
mEventFd = eventfd(0, EFD_NONBLOCK);
if (mEventFd < 0) {