Do not do powerhint if current governor is not supported

Bug: 62913269
Test: Boot and verify powerhint works
Change-Id: If2638ae5f107534b46412ca8cce9f02e9eb5d215
This commit is contained in:
Wei Wang
2017-06-22 23:04:55 -07:00
committed by Thierry Strudel
parent dfc34ea32b
commit f31c67caa8
4 changed files with 27 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ LOCAL_SRC_FILES += power-8998.c
LOCAL_CFLAGS += -DINTERACTION_BOOST -Werror
LOCAL_SHARED_LIBRARIES := \
libbase \
liblog \
libcutils \
libdl \

View File

@@ -17,6 +17,8 @@
#define LOG_TAG "android.hardware.power@1.1-service.wahoo"
#include <android/log.h>
#include <android-base/file.h>
#include <android-base/strings.h>
#include <utils/Log.h>
#include "Power.h"
#include "power-common.h"
@@ -49,12 +51,18 @@ Power::Power() {
// Methods from ::android::hardware::power::V1_0::IPower follow.
Return<void> Power::setInteractive(bool interactive) {
if (!isSupportedGovernor()) {
return Void();
}
power_set_interactive(interactive ? 1 : 0);
return Void();
}
Return<void> Power::powerHint(PowerHint hint, int32_t data) {
power_hint_t h = static_cast<power_hint_t>(hint);
if (!isSupportedGovernor()) {
return Void();
}
if (h == POWER_HINT_INTERACTION) {
mInteractionHandler.Acquire(data);
return Void();
@@ -169,6 +177,20 @@ done:
return Void();
}
bool Power::isSupportedGovernor() {
std::string buf;
if (android::base::ReadFileToString(SCALING_GOVERNOR_PATH, &buf)) {
buf = android::base::Trim(buf);
}
// Only support EAS 1.2, legacy EAS and HMP
if (buf == SCHEDUTIL_GOVERNOR || buf == SCHED_GOVERNOR || buf == INTERACTIVE_GOVERNOR) {
return true;
} else {
ALOGE("Governor not supported by powerHAL, skipping");
return false;
}
}
} // namespace implementation
} // namespace V1_1
} // namespace power

View File

@@ -54,6 +54,7 @@ struct Power : public IPower {
private:
InteractionHandler mInteractionHandler;
static bool isSupportedGovernor();
};
} // namespace implementation

View File

@@ -36,6 +36,9 @@
#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
#define ONDEMAND_GOVERNOR "ondemand"
#define INTERACTIVE_GOVERNOR "interactive"
#define SCHEDUTIL_GOVERNOR "schedutil"
#define SCHED_GOVERNOR "sched"
#define MSMDCVS_GOVERNOR "msm-dcvs"
#define SCHED_GOVERNOR "sched"