power: add PowerHintSession for ADPF implementation
Adapted from PoC from ag/13100800 Added more ATRACE for further tuning and debug Test: APPPID=$(adb shell pidof com.prefabulated.touchlatency); watch -n 1 adb shell grep uclamp /proc/${APPPID}/sched Test: atest VtsHalPowerTargetTest Bug: 177492680 Change-Id: I6bfd61b21dc1cde04f6ba9ae8d3533cd263ad814 Signed-off-by: Wei Wang <wvw@google.com>
This commit is contained in:
parent
9cdb8059e5
commit
3a50977117
@ -24,7 +24,8 @@ include $(CLEAR_VARS)
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
android.hardware.power-V1-ndk_platform \
|
||||
android.hardware.power-V2-ndk_platform \
|
||||
libadpf-pixel \
|
||||
libbase \
|
||||
libbinder_ndk \
|
||||
libcutils \
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
#define LOG_TAG "android.hardware.power-service.xiaomi-libperfmgr"
|
||||
#define LOG_TAG "powerhal-libperfmgr"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
#define LOG_TAG "android.hardware.power-service.xiaomi-libperfmgr"
|
||||
#define LOG_TAG "powerhal-libperfmgr"
|
||||
|
||||
#include "Power.h"
|
||||
|
||||
@ -26,10 +26,13 @@
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include "adpf/PowerHintSession.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
@ -37,6 +40,8 @@ namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
using ::aidl::google::hardware::power::impl::pixel::adpf::PowerHintSession;
|
||||
|
||||
#ifdef MODE_EXT
|
||||
extern bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return);
|
||||
extern bool setDeviceSpecificMode(Mode type, bool enabled);
|
||||
@ -45,37 +50,40 @@ extern bool setDeviceSpecificMode(Mode type, bool enabled);
|
||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||
constexpr char kPowerHalAdpfRateProp[] = "vendor.powerhal.adpf.rate";
|
||||
constexpr int64_t kPowerHalAdpfRateDefault = -1;
|
||||
|
||||
Power::Power(std::shared_ptr<HintManager> hm)
|
||||
: mHintManager(hm),
|
||||
mInteractionHandler(nullptr),
|
||||
mSustainedPerfModeOn(false) {
|
||||
mSustainedPerfModeOn(false),
|
||||
mAdpfRate(::android::base::GetIntProperty(kPowerHalAdpfRateProp, kPowerHalAdpfRateDefault)) {
|
||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
||||
mInteractionHandler->Init();
|
||||
|
||||
std::string state = ::android::base::GetProperty(kPowerHalStateProp, "");
|
||||
if (state == "SUSTAINED_PERFORMANCE") {
|
||||
ALOGI("Initialize with SUSTAINED_PERFORMANCE on");
|
||||
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
} else {
|
||||
ALOGI("Initialize PowerHAL");
|
||||
LOG(INFO) << "Initialize PowerHAL";
|
||||
}
|
||||
|
||||
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
||||
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
||||
ALOGI("Initialize with AUDIO_LOW_LATENCY on");
|
||||
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
|
||||
mHintManager->DoHint(state);
|
||||
}
|
||||
|
||||
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||
if (state == "EXPENSIVE_RENDERING") {
|
||||
ALOGI("Initialize with EXPENSIVE_RENDERING on");
|
||||
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
|
||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||
}
|
||||
|
||||
// Now start to take powerhint
|
||||
ALOGI("PowerHAL ready to process hints");
|
||||
LOG(INFO) << "PowerHAL ready to take hints, Adpf update rate: " << mAdpfRate;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||
@ -208,6 +216,34 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
|
||||
const std::vector<int32_t> &threadIds,
|
||||
int64_t durationNanos,
|
||||
std::shared_ptr<IPowerHintSession> *_aidl_return) {
|
||||
if (mAdpfRate == -1) {
|
||||
*_aidl_return = nullptr;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
if (threadIds.size() == 0) {
|
||||
LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size();
|
||||
*_aidl_return = nullptr;
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
std::shared_ptr<IPowerHintSession> session =
|
||||
ndk::SharedRefBase::make<PowerHintSession>(tgid, uid, threadIds, durationNanos);
|
||||
*_aidl_return = session;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t *outNanoseconds) {
|
||||
*outNanoseconds = mAdpfRate;
|
||||
if (mAdpfRate == -1) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace pixel
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
|
@ -33,6 +33,7 @@ namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
using ::aidl::android::hardware::power::Boost;
|
||||
using ::aidl::android::hardware::power::IPowerHintSession;
|
||||
using ::aidl::android::hardware::power::Mode;
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
@ -43,12 +44,18 @@ class Power : public ::aidl::android::hardware::power::BnPower {
|
||||
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus createHintSession(int32_t tgid, int32_t uid,
|
||||
const std::vector<int32_t> &threadIds,
|
||||
int64_t durationNanos,
|
||||
std::shared_ptr<IPowerHintSession> *_aidl_return) override;
|
||||
ndk::ScopedAStatus getHintSessionPreferredRate(int64_t *outNanoseconds) override;
|
||||
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
||||
std::atomic<bool> mSustainedPerfModeOn;
|
||||
const int64_t mAdpfRate;
|
||||
};
|
||||
|
||||
} // namespace pixel
|
||||
|
@ -1,6 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.power</name>
|
||||
<version>2</version>
|
||||
<fqname>IPower/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power-service.xiaomi-libperfmgr"
|
||||
#define LOG_TAG "powerhal-libperfmgr"
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user