kunlun2: Import Pixel power AIDL HAL
Nuke Powerstats
This commit is contained in:
parent
581940f777
commit
30666f3913
30 changed files with 751 additions and 840 deletions
|
@ -1,5 +1,6 @@
|
|||
soong_namespace {
|
||||
imports: [
|
||||
"hardware/google/interfaces",
|
||||
"hardware/google/pixel",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@
|
|||
"Name": "TASchedtuneBoost",
|
||||
"Path": "/dev/stune/top-app/schedtune.boost",
|
||||
"Values": [
|
||||
"10",
|
||||
"5"
|
||||
"50",
|
||||
"10"
|
||||
],
|
||||
"ResetOnInit": true
|
||||
},
|
||||
|
@ -206,9 +206,6 @@
|
|||
"Name": "PowerHALMainState",
|
||||
"Path": "vendor.powerhal.state",
|
||||
"Values": [
|
||||
"CAMERA_STREAMING",
|
||||
"CAMERA_STREAMING_1080P",
|
||||
"CAMERA_STREAMING_4K",
|
||||
"SUSTAINED_PERFORMANCE",
|
||||
""
|
||||
],
|
||||
|
@ -218,16 +215,7 @@
|
|||
"Name": "PowerHALAudioState",
|
||||
"Path": "vendor.powerhal.audio",
|
||||
"Values": [
|
||||
"AUDIO_LOW_LATENCY",
|
||||
""
|
||||
],
|
||||
"Type": "Property"
|
||||
},
|
||||
{
|
||||
"Name": "PowerHALRenderingState",
|
||||
"Path": "vendor.powerhal.rendering",
|
||||
"Values": [
|
||||
"EXPENSIVE_RENDERING",
|
||||
"AUDIO_STREAMING_LOW_LATENCY",
|
||||
""
|
||||
],
|
||||
"Type": "Property"
|
||||
|
@ -262,19 +250,19 @@
|
|||
"PowerHint": "INTERACTION",
|
||||
"Node": "CPUBigClusterMinFreq",
|
||||
"Duration": 0,
|
||||
"Value": "825600"
|
||||
"Value": "1132800"
|
||||
},
|
||||
{
|
||||
"PowerHint": "INTERACTION",
|
||||
"Node": "CPULittleClusterMinFreq",
|
||||
"Duration": 0,
|
||||
"Value": "576000"
|
||||
"Value": "1209600"
|
||||
},
|
||||
{
|
||||
"PowerHint": "INTERACTION",
|
||||
"Node": "TASchedtuneBoost",
|
||||
"Duration": 0,
|
||||
"Value": "10"
|
||||
"Value": "50"
|
||||
},
|
||||
{
|
||||
"PowerHint": "INTERACTION",
|
||||
|
@ -309,87 +297,93 @@
|
|||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "SchedBoost",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "1"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBigClusterMaxFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "9999999"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBigClusterMinFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "9999999"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPULittleClusterMinFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "9999999"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "PMQoSCpuDmaLatency",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "67"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBWHystTriggerCount",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "0"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBWHystLength",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "0"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBWHistMemory",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "0"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "CPUBWMinFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "6881"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "GPUForceClkOn",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "1"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "GPUForceRailOn",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "1"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "GPUIdleTimer",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "10000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "L3LittleClusterMinFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "1440000000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "LAUNCH",
|
||||
"Node": "L3BigClusterMinFreq",
|
||||
"Duration": 3000,
|
||||
"Duration": 5000,
|
||||
"Value": "1440000000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_LAUNCH",
|
||||
"Node": "SchedBoost",
|
||||
"Duration": 1000,
|
||||
"Value": "1"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_LAUNCH",
|
||||
"Node": "CPUBigClusterMaxFreq",
|
||||
|
@ -421,49 +415,31 @@
|
|||
"Value": "67"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING",
|
||||
"Node": "PowerHALMainState",
|
||||
"Duration": 0,
|
||||
"Value": "CAMERA_STREAMING"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING",
|
||||
"PowerHint": "CAMERA_STREAMING_MID",
|
||||
"Node": "CPUBigClusterMaxFreq",
|
||||
"Duration": 0,
|
||||
"Value": "1996800"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_1080P",
|
||||
"Node": "PowerHALMainState",
|
||||
"Duration": 0,
|
||||
"Value": "CAMERA_STREAMING_1080P"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_1080P",
|
||||
"PowerHint": "CAMERA_STREAMING_HIGH",
|
||||
"Node": "CPUBigClusterMaxFreq",
|
||||
"Duration": 0,
|
||||
"Value": "1996800"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_1080P",
|
||||
"PowerHint": "CAMERA_STREAMING_HIGH",
|
||||
"Node": "GPUMinFreq",
|
||||
"Duration": 0,
|
||||
"Value": "430000000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_1080P",
|
||||
"PowerHint": "CAMERA_STREAMING_HIGH",
|
||||
"Node": "GPUMaxFreq",
|
||||
"Duration": 0,
|
||||
"Value": "430000000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_4K",
|
||||
"Node": "PowerHALMainState",
|
||||
"Duration": 0,
|
||||
"Value": "CAMERA_STREAMING_4K"
|
||||
},
|
||||
{
|
||||
"PowerHint": "CAMERA_STREAMING_4K",
|
||||
"PowerHint": "CAMERA_STREAMING_LOW",
|
||||
"Node": "CPUBigClusterMaxFreq",
|
||||
"Duration": 0,
|
||||
"Value": "1996800"
|
||||
|
@ -499,46 +475,28 @@
|
|||
"Value": "67"
|
||||
},
|
||||
{
|
||||
"PowerHint": "AUDIO_STREAMING",
|
||||
"PowerHint": "AUDIO_LAUNCH",
|
||||
"Node": "CPUBigClusterMinFreq",
|
||||
"Duration": 2000,
|
||||
"Value": "1363200"
|
||||
},
|
||||
{
|
||||
"PowerHint": "AUDIO_STREAMING",
|
||||
"PowerHint": "AUDIO_LAUNCH",
|
||||
"Node": "PMQoSCpuDmaLatency",
|
||||
"Duration": 2000,
|
||||
"Value": "67"
|
||||
},
|
||||
{
|
||||
"PowerHint": "AUDIO_LOW_LATENCY",
|
||||
"PowerHint": "AUDIO_STREAMING_LOW_LATENCY",
|
||||
"Node": "PowerHALAudioState",
|
||||
"Duration": 0,
|
||||
"Value": "AUDIO_LOW_LATENCY"
|
||||
"Value": "AUDIO_STREAMING_LOW_LATENCY"
|
||||
},
|
||||
{
|
||||
"PowerHint": "AUDIO_LOW_LATENCY",
|
||||
"PowerHint": "AUDIO_STREAMING_LOW_LATENCY",
|
||||
"Node": "PMQoSCpuDmaLatency",
|
||||
"Duration": 0,
|
||||
"Value": "67"
|
||||
},
|
||||
{
|
||||
"PowerHint": "EXPENSIVE_RENDERING",
|
||||
"Node": "PowerHALRenderingState",
|
||||
"Duration": 0,
|
||||
"Value": "EXPENSIVE_RENDERING"
|
||||
},
|
||||
{
|
||||
"PowerHint": "EXPENSIVE_RENDERING",
|
||||
"Node": "GPUMinFreq",
|
||||
"Duration": 0,
|
||||
"Value": "355000000"
|
||||
},
|
||||
{
|
||||
"PowerHint": "EXPENSIVE_RENDERING",
|
||||
"Node": "GPUMaxFreq",
|
||||
"Duration": 0,
|
||||
"Value": "430000000"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -108,8 +108,7 @@ PRODUCT_PACKAGES += \
|
|||
|
||||
# Power
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.power@1.3-service.lenovo-libperfmgr \
|
||||
android.hardware.power.stats@1.0-service.lenovo
|
||||
android.hardware.power-service.lenovo
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(LOCAL_PATH)/configs/powerhint.json:$(TARGET_COPY_OUT_SYSTEM)/etc/powerhint.json
|
||||
|
@ -123,6 +122,7 @@ PRODUCT_PACKAGES += \
|
|||
# Soong namespaces
|
||||
PRODUCT_SOONG_NAMESPACES += \
|
||||
$(LOCAL_PATH) \
|
||||
hardware/google/interfaces \
|
||||
hardware/google/pixel
|
||||
|
||||
# System properties
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.power.stats</name>
|
||||
<hal format="hidl" override="true">
|
||||
<name>android.hardware.power</name>
|
||||
<transport>hwbinder</transport>
|
||||
</hal>
|
||||
<hal format="hidl" override="true">
|
||||
<name>vendor.qti.hardware.perf</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IPowerStats</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>vendor.lineage.livedisplay</name>
|
||||
|
|
|
@ -1,44 +1,43 @@
|
|||
//
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
cc_library_headers {
|
||||
name: "lenovo_power_headers",
|
||||
vendor_available: true,
|
||||
export_include_dirs: ["."],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.power@1.3-service.lenovo-libperfmgr",
|
||||
relative_install_path: "hw",
|
||||
vintf_fragments: ["android.hardware.power@1.3-service.lenovo.xml"],
|
||||
init_rc: ["android.hardware.power@1.3-service.lenovo-libperfmgr.rc"],
|
||||
srcs: ["service.cpp", "Power.cpp", "InteractionHandler.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
cc_library {
|
||||
name: "libdisppower-lenovo",
|
||||
srcs: [
|
||||
"disp-power/DisplayLowPower.cpp",
|
||||
"disp-power/InteractionHandler.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
"android.hardware.power@1.0",
|
||||
"android.hardware.power@1.1",
|
||||
"android.hardware.power@1.2",
|
||||
"android.hardware.power@1.3",
|
||||
"liblog",
|
||||
"libperfmgr",
|
||||
"libutils",
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.power-service.lenovo",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["aidl/android.hardware.power-service.lenovo.rc"],
|
||||
vintf_fragments: ["aidl/android.hardware.power-service.lenovo.xml"],
|
||||
shared_libs: [
|
||||
"android.hardware.power-ndk_platform",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libbinder_ndk",
|
||||
"libdisppower-lenovo",
|
||||
"libperfmgr",
|
||||
"pixel-power-ext-ndk_platform",
|
||||
],
|
||||
srcs: [
|
||||
"aidl/service.cpp",
|
||||
"aidl/Power.cpp",
|
||||
"aidl/PowerExt.cpp",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -1,339 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
#define LOG_TAG "android.hardware.power@1.3-service.pixel-libperfmgr"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include "Power.h"
|
||||
|
||||
#ifndef TAP_TO_WAKE_NODE
|
||||
#define TAP_TO_WAKE_NODE "/sys/class/touch/tp_dev/gesture_on"
|
||||
#endif
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace V1_3 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::power::V1_0::Feature;
|
||||
using ::android::hardware::power::V1_0::Status;
|
||||
|
||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||
constexpr char kPowerHalInitProp[] = "vendor.powerhal.init";
|
||||
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||
constexpr char kPowerHalConfigPath[] = "/system/etc/powerhint.json";
|
||||
|
||||
Power::Power()
|
||||
: mHintManager(nullptr),
|
||||
mInteractionHandler(nullptr),
|
||||
mVRModeOn(false),
|
||||
mSustainedPerfModeOn(false),
|
||||
mCameraStreamingMode(false),
|
||||
mReady(false) {
|
||||
mInitThread = std::thread([this]() {
|
||||
android::base::WaitForProperty(kPowerHalInitProp, "1");
|
||||
mHintManager = HintManager::GetFromJSON(kPowerHalConfigPath);
|
||||
if (!mHintManager) {
|
||||
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
|
||||
}
|
||||
mInteractionHandler = std::make_unique<InteractionHandler>(mHintManager);
|
||||
mInteractionHandler->Init();
|
||||
std::string state = android::base::GetProperty(kPowerHalStateProp, "");
|
||||
if (state == "CAMERA_STREAMING") {
|
||||
ALOGI("Initialize with CAMERA_STREAMING on");
|
||||
mHintManager->DoHint("CAMERA_STREAMING");
|
||||
mCameraStreamingMode = true;
|
||||
} else if (state == "SUSTAINED_PERFORMANCE") {
|
||||
ALOGI("Initialize with SUSTAINED_PERFORMANCE on");
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
} else if (state == "VR_MODE") {
|
||||
ALOGI("Initialize with VR_MODE on");
|
||||
mHintManager->DoHint("VR_MODE");
|
||||
mVRModeOn = true;
|
||||
} else if (state == "VR_SUSTAINED_PERFORMANCE") {
|
||||
ALOGI("Initialize with SUSTAINED_PERFORMANCE and VR_MODE on");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
mVRModeOn = true;
|
||||
} else {
|
||||
ALOGI("Initialize PowerHAL");
|
||||
}
|
||||
|
||||
state = android::base::GetProperty(kPowerHalAudioProp, "");
|
||||
if (state == "AUDIO_LOW_LATENCY") {
|
||||
ALOGI("Initialize with AUDIO_LOW_LATENCY on");
|
||||
mHintManager->DoHint("AUDIO_LOW_LATENCY");
|
||||
}
|
||||
|
||||
state = android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||
if (state == "EXPENSIVE_RENDERING") {
|
||||
ALOGI("Initialize with EXPENSIVE_RENDERING on");
|
||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||
}
|
||||
// Now start to take powerhint
|
||||
mReady.store(true);
|
||||
ALOGI("PowerHAL ready to process hints");
|
||||
});
|
||||
mInitThread.detach();
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::power::V1_0::IPower follow.
|
||||
Return<void> Power::setInteractive(bool /* interactive */) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
|
||||
if (!mReady) {
|
||||
return Void();
|
||||
}
|
||||
ATRACE_INT(android::hardware::power::V1_0::toString(hint).c_str(), data);
|
||||
ALOGD_IF(hint != PowerHint_1_0::INTERACTION, "%s: %d",
|
||||
android::hardware::power::V1_0::toString(hint).c_str(), static_cast<int>(data));
|
||||
switch (hint) {
|
||||
case PowerHint_1_0::INTERACTION:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
ALOGV("%s: ignoring due to other active perf hints", __func__);
|
||||
} else {
|
||||
mInteractionHandler->Acquire(data);
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_0::SUSTAINED_PERFORMANCE:
|
||||
if (data && !mSustainedPerfModeOn) {
|
||||
if (!mVRModeOn) { // Sustained mode only.
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
} else { // Sustained + VR mode.
|
||||
mHintManager->EndHint("VR_MODE");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mSustainedPerfModeOn = true;
|
||||
} else if (!data && mSustainedPerfModeOn) {
|
||||
mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
|
||||
if (mVRModeOn) { // Switch back to VR Mode.
|
||||
mHintManager->DoHint("VR_MODE");
|
||||
}
|
||||
mSustainedPerfModeOn = false;
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_0::VR_MODE:
|
||||
if (data && !mVRModeOn) {
|
||||
if (!mSustainedPerfModeOn) { // VR mode only.
|
||||
mHintManager->DoHint("VR_MODE");
|
||||
} else { // Sustained + VR mode.
|
||||
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mVRModeOn = true;
|
||||
} else if (!data && mVRModeOn) {
|
||||
mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mHintManager->EndHint("VR_MODE");
|
||||
if (mSustainedPerfModeOn) { // Switch back to sustained Mode.
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mVRModeOn = false;
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_0::LAUNCH:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
ALOGV("%s: ignoring due to other active perf hints", __func__);
|
||||
} else {
|
||||
if (data) {
|
||||
// Hint until canceled
|
||||
mHintManager->DoHint("LAUNCH");
|
||||
} else {
|
||||
mHintManager->EndHint("LAUNCH");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Power::setFeature(Feature feature, bool activate) {
|
||||
switch (feature) {
|
||||
#ifdef TAP_TO_WAKE_NODE
|
||||
case Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE:
|
||||
::android::base::WriteStringToFile(activate ? "1" : "0", TAP_TO_WAKE_NODE);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
|
||||
LOG(ERROR) << "getPlatformLowPowerStats not supported. Use IPowerStats HAL.";
|
||||
_hidl_cb({}, Status::SUCCESS);
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::power::V1_1::IPower follow.
|
||||
Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
|
||||
LOG(ERROR) << "getSubsystemLowPowerStats not supported. Use IPowerStats HAL.";
|
||||
_hidl_cb({}, Status::SUCCESS);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) {
|
||||
// just call the normal power hint in this oneway function
|
||||
return powerHint(hint, data);
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::power::V1_2::IPower follow.
|
||||
Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
|
||||
if (!mReady) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
ATRACE_INT(android::hardware::power::V1_2::toString(hint).c_str(), data);
|
||||
ALOGD_IF(hint >= PowerHint_1_2::AUDIO_STREAMING, "%s: %d",
|
||||
android::hardware::power::V1_2::toString(hint).c_str(), static_cast<int>(data));
|
||||
|
||||
switch (hint) {
|
||||
case PowerHint_1_2::AUDIO_LOW_LATENCY:
|
||||
if (data) {
|
||||
// Hint until canceled
|
||||
mHintManager->DoHint("AUDIO_LOW_LATENCY");
|
||||
} else {
|
||||
mHintManager->EndHint("AUDIO_LOW_LATENCY");
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_2::AUDIO_STREAMING:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
ALOGV("%s: ignoring due to other active perf hints", __func__);
|
||||
} else {
|
||||
if (data) {
|
||||
mHintManager->DoHint("AUDIO_STREAMING");
|
||||
} else {
|
||||
mHintManager->EndHint("AUDIO_STREAMING");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_2::CAMERA_LAUNCH:
|
||||
if (data > 0) {
|
||||
mHintManager->DoHint("CAMERA_LAUNCH");
|
||||
} else if (data == 0) {
|
||||
mHintManager->EndHint("CAMERA_LAUNCH");
|
||||
} else {
|
||||
ALOGE("CAMERA LAUNCH INVALID DATA: %d", data);
|
||||
}
|
||||
break;
|
||||
case PowerHint_1_2::CAMERA_STREAMING: {
|
||||
if (data > 0) {
|
||||
mHintManager->DoHint("CAMERA_STREAMING");
|
||||
mCameraStreamingMode = true;
|
||||
} else {
|
||||
mHintManager->EndHint("CAMERA_STREAMING");
|
||||
mCameraStreamingMode = false;
|
||||
}
|
||||
|
||||
const auto prop = mCameraStreamingMode
|
||||
? "CAMERA_STREAMING"
|
||||
: "";
|
||||
if (!android::base::SetProperty(kPowerHalStateProp, prop)) {
|
||||
ALOGE("%s: could set powerHAL state %s property", __func__, prop);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PowerHint_1_2::CAMERA_SHOT:
|
||||
if (data > 0) {
|
||||
mHintManager->DoHint("CAMERA_SHOT", std::chrono::milliseconds(data));
|
||||
} else if (data == 0) {
|
||||
mHintManager->EndHint("CAMERA_SHOT");
|
||||
} else {
|
||||
ALOGE("CAMERA SHOT INVALID DATA: %d", data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return powerHint(static_cast<PowerHint_1_0>(hint), data);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::power::V1_3::IPower follow.
|
||||
Return<void> Power::powerHintAsync_1_3(PowerHint_1_3 hint, int32_t data) {
|
||||
if (!mReady) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
if (hint == PowerHint_1_3::EXPENSIVE_RENDERING) {
|
||||
ATRACE_INT(android::hardware::power::V1_3::toString(hint).c_str(), data);
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
ALOGV("%s: ignoring due to other active perf hints", __func__);
|
||||
} else {
|
||||
if (data > 0) {
|
||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||
} else {
|
||||
mHintManager->EndHint("EXPENSIVE_RENDERING");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return powerHintAsync_1_2(static_cast<PowerHint_1_2>(hint), data);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
constexpr const char *boolToString(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
Return<void> Power::debug(const hidl_handle &handle, const hidl_vec<hidl_string> &) {
|
||||
if (handle != nullptr && handle->numFds >= 1 && mReady) {
|
||||
int fd = handle->data[0];
|
||||
|
||||
std::string buf(android::base::StringPrintf(
|
||||
"HintManager Running: %s\n"
|
||||
"VRMode: %s\n"
|
||||
"CameraStreamingMode: %s\n"
|
||||
"SustainedPerformanceMode: %s\n",
|
||||
boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn),
|
||||
boolToString(mCameraStreamingMode),
|
||||
boolToString(mSustainedPerfModeOn)));
|
||||
// Dump nodes through libperfmgr
|
||||
mHintManager->DumpToFd(fd);
|
||||
if (!android::base::WriteStringToFd(buf, fd)) {
|
||||
PLOG(ERROR) << "Failed to dump state to fd";
|
||||
}
|
||||
fsync(fd);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_3
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef POWER_LIBPERFMGR_POWER_H_
|
||||
#define POWER_LIBPERFMGR_POWER_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <android/hardware/power/1.3/IPower.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <perfmgr/HintManager.h>
|
||||
|
||||
#include "InteractionHandler.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace V1_3 {
|
||||
namespace implementation {
|
||||
|
||||
using ::InteractionHandler;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::power::V1_0::Feature;
|
||||
using ::android::hardware::power::V1_3::IPower;
|
||||
using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint;
|
||||
using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint;
|
||||
using PowerHint_1_3 = ::android::hardware::power::V1_3::PowerHint;
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
class Power : public IPower {
|
||||
public:
|
||||
// Methods from ::android::hardware::power::V1_0::IPower follow.
|
||||
|
||||
Power();
|
||||
|
||||
Return<void> setInteractive(bool /* interactive */) override;
|
||||
Return<void> powerHint(PowerHint_1_0 hint, int32_t data) override;
|
||||
Return<void> setFeature(Feature feature, bool activate) override;
|
||||
Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
|
||||
|
||||
// Methods from ::android::hardware::power::V1_1::IPower follow.
|
||||
Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
|
||||
Return<void> powerHintAsync(PowerHint_1_0 hint, int32_t data) override;
|
||||
|
||||
// Methods from ::android::hardware::power::V1_2::IPower follow.
|
||||
Return<void> powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override;
|
||||
|
||||
// Methods from ::android::hardware::power::V1_3::IPower follow.
|
||||
Return<void> powerHintAsync_1_3(PowerHint_1_3 hint, int32_t data) override;
|
||||
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &args) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
||||
std::atomic<bool> mVRModeOn;
|
||||
std::atomic<bool> mSustainedPerfModeOn;
|
||||
std::atomic<bool> mCameraStreamingMode;
|
||||
std::atomic<bool> mReady;
|
||||
std::thread mInitThread;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_3
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // POWER_LIBPERFMGR_POWER_H_
|
256
power-libperfmgr/aidl/Power.cpp
Normal file
256
power-libperfmgr/aidl/Power.cpp
Normal file
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
#define LOG_TAG "android.hardware.power-service.pixel-libperfmgr"
|
||||
|
||||
#include "Power.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
||||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
|
||||
|
||||
Power::Power(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw)
|
||||
: mHintManager(hm),
|
||||
mDisplayLowPower(dlpw),
|
||||
mInteractionHandler(nullptr),
|
||||
mVRModeOn(false),
|
||||
mSustainedPerfModeOn(false) {
|
||||
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");
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
} else if (state == "VR") {
|
||||
ALOGI("Initialize with VR on");
|
||||
mHintManager->DoHint(state);
|
||||
mVRModeOn = true;
|
||||
} else if (state == "VR_SUSTAINED_PERFORMANCE") {
|
||||
ALOGI("Initialize with SUSTAINED_PERFORMANCE and VR on");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mSustainedPerfModeOn = true;
|
||||
mVRModeOn = true;
|
||||
} else {
|
||||
ALOGI("Initialize PowerHAL");
|
||||
}
|
||||
|
||||
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
|
||||
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
|
||||
ALOGI("Initialize with AUDIO_LOW_LATENCY on");
|
||||
mHintManager->DoHint(state);
|
||||
}
|
||||
|
||||
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
|
||||
if (state == "EXPENSIVE_RENDERING") {
|
||||
ALOGI("Initialize with EXPENSIVE_RENDERING on");
|
||||
mHintManager->DoHint("EXPENSIVE_RENDERING");
|
||||
}
|
||||
|
||||
// Now start to take powerhint
|
||||
ALOGI("PowerHAL ready to process hints");
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
||||
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
|
||||
ATRACE_INT(toString(type).c_str(), enabled);
|
||||
switch (type) {
|
||||
case Mode::LOW_POWER:
|
||||
mDisplayLowPower->SetDisplayLowPower(enabled);
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
case Mode::SUSTAINED_PERFORMANCE:
|
||||
if (enabled && !mSustainedPerfModeOn) {
|
||||
if (!mVRModeOn) { // Sustained mode only.
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
} else { // Sustained + VR mode.
|
||||
mHintManager->EndHint("VR");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mSustainedPerfModeOn = true;
|
||||
} else if (!enabled && mSustainedPerfModeOn) {
|
||||
mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
|
||||
if (mVRModeOn) { // Switch back to VR Mode.
|
||||
mHintManager->DoHint("VR");
|
||||
}
|
||||
mSustainedPerfModeOn = false;
|
||||
}
|
||||
break;
|
||||
case Mode::VR:
|
||||
if (enabled && !mVRModeOn) {
|
||||
if (!mSustainedPerfModeOn) { // VR mode only.
|
||||
mHintManager->DoHint("VR");
|
||||
} else { // Sustained + VR mode.
|
||||
mHintManager->EndHint("SUSTAINED_PERFORMANCE");
|
||||
mHintManager->DoHint("VR_SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mVRModeOn = true;
|
||||
} else if (!enabled && mVRModeOn) {
|
||||
mHintManager->EndHint("VR_SUSTAINED_PERFORMANCE");
|
||||
mHintManager->EndHint("VR");
|
||||
if (mSustainedPerfModeOn) { // Switch back to sustained Mode.
|
||||
mHintManager->DoHint("SUSTAINED_PERFORMANCE");
|
||||
}
|
||||
mVRModeOn = false;
|
||||
}
|
||||
break;
|
||||
case Mode::LAUNCH:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case Mode::DOUBLE_TAP_TO_WAKE:
|
||||
[[fallthrough]];
|
||||
case Mode::FIXED_PERFORMANCE:
|
||||
[[fallthrough]];
|
||||
case Mode::EXPENSIVE_RENDERING:
|
||||
[[fallthrough]];
|
||||
case Mode::INTERACTIVE:
|
||||
[[fallthrough]];
|
||||
case Mode::DEVICE_IDLE:
|
||||
[[fallthrough]];
|
||||
case Mode::DISPLAY_INACTIVE:
|
||||
[[fallthrough]];
|
||||
case Mode::AUDIO_STREAMING_LOW_LATENCY:
|
||||
[[fallthrough]];
|
||||
case Mode::CAMERA_STREAMING_SECURE:
|
||||
[[fallthrough]];
|
||||
case Mode::CAMERA_STREAMING_LOW:
|
||||
[[fallthrough]];
|
||||
case Mode::CAMERA_STREAMING_MID:
|
||||
[[fallthrough]];
|
||||
case Mode::CAMERA_STREAMING_HIGH:
|
||||
[[fallthrough]];
|
||||
default:
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
// LOW_POWER handled insides PowerHAL specifically
|
||||
if (type == Mode::LOW_POWER) {
|
||||
supported = true;
|
||||
}
|
||||
LOG(INFO) << "Power mode " << toString(type) << " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
||||
LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs;
|
||||
ATRACE_INT(toString(type).c_str(), durationMs);
|
||||
switch (type) {
|
||||
case Boost::INTERACTION:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
break;
|
||||
}
|
||||
mInteractionHandler->Acquire(durationMs);
|
||||
break;
|
||||
case Boost::DISPLAY_UPDATE_IMMINENT:
|
||||
[[fallthrough]];
|
||||
case Boost::ML_ACC:
|
||||
[[fallthrough]];
|
||||
case Boost::AUDIO_LAUNCH:
|
||||
[[fallthrough]];
|
||||
case Boost::CAMERA_LAUNCH:
|
||||
[[fallthrough]];
|
||||
case Boost::CAMERA_SHOT:
|
||||
[[fallthrough]];
|
||||
default:
|
||||
if (mVRModeOn || mSustainedPerfModeOn) {
|
||||
break;
|
||||
}
|
||||
if (durationMs > 0) {
|
||||
mHintManager->DoHint(toString(type), std::chrono::milliseconds(durationMs));
|
||||
} else if (durationMs == 0) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
constexpr const char *boolToString(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
||||
std::string buf(::android::base::StringPrintf(
|
||||
"HintManager Running: %s\n"
|
||||
"VRMode: %s\n"
|
||||
"SustainedPerformanceMode: %s\n",
|
||||
boolToString(mHintManager->IsRunning()), boolToString(mVRModeOn),
|
||||
boolToString(mSustainedPerfModeOn)));
|
||||
// Dump nodes through libperfmgr
|
||||
mHintManager->DumpToFd(fd);
|
||||
if (!::android::base::WriteStringToFd(buf, fd)) {
|
||||
PLOG(ERROR) << "Failed to dump state to fd";
|
||||
}
|
||||
fsync(fd);
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
||||
} // namespace pixel
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace google
|
||||
} // namespace aidl
|
63
power-libperfmgr/aidl/Power.h
Normal file
63
power-libperfmgr/aidl/Power.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <aidl/android/hardware/power/BnPower.h>
|
||||
#include <perfmgr/HintManager.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
#include "disp-power/InteractionHandler.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
using ::InteractionHandler;
|
||||
using ::aidl::android::hardware::power::Boost;
|
||||
using ::aidl::android::hardware::power::Mode;
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
class Power : public ::aidl::android::hardware::power::BnPower {
|
||||
public:
|
||||
Power(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw);
|
||||
ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
|
||||
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;
|
||||
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
|
||||
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
||||
std::atomic<bool> mVRModeOn;
|
||||
std::atomic<bool> mSustainedPerfModeOn;
|
||||
};
|
||||
|
||||
} // namespace pixel
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace google
|
||||
} // namespace aidl
|
87
power-libperfmgr/aidl/PowerExt.cpp
Normal file
87
power-libperfmgr/aidl/PowerExt.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
#define LOG_TAG "android.hardware.power-service.pixel.ext-libperfmgr"
|
||||
|
||||
#include "PowerExt.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
|
||||
ATRACE_INT(mode.c_str(), enabled);
|
||||
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(mode);
|
||||
} else {
|
||||
mHintManager->EndHint(mode);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(mode);
|
||||
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) {
|
||||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||
ATRACE_INT(boost.c_str(), durationMs);
|
||||
|
||||
if (durationMs > 0) {
|
||||
mHintManager->DoHint(boost, std::chrono::milliseconds(durationMs));
|
||||
} else if (durationMs == 0) {
|
||||
mHintManager->DoHint(boost);
|
||||
} else {
|
||||
mHintManager->EndHint(boost);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(boost);
|
||||
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace pixel
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace google
|
||||
} // namespace aidl
|
56
power-libperfmgr/aidl/PowerExt.h
Normal file
56
power-libperfmgr/aidl/PowerExt.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
|
||||
#include <aidl/google/hardware/power/extension/pixel/BnPowerExt.h>
|
||||
#include <perfmgr/HintManager.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||
public:
|
||||
PowerExt(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw)
|
||||
: mHintManager(hm), mDisplayLowPower(dlpw) {}
|
||||
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
|
||||
};
|
||||
|
||||
} // namespace pixel
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace google
|
||||
} // namespace aidl
|
|
@ -0,0 +1,17 @@
|
|||
service vendor.power-hal-aidl /system/bin/hw/android.hardware.power-service.lenovo
|
||||
class hal
|
||||
user root
|
||||
group system
|
||||
priority -20
|
||||
|
||||
# restart powerHAL when framework died
|
||||
on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
|
||||
setprop vendor.powerhal.state ""
|
||||
setprop vendor.powerhal.audio ""
|
||||
setprop vendor.powerhal.rendering ""
|
||||
restart vendor.power-hal-aidl
|
||||
|
||||
# restart powerHAL when audioHAL died
|
||||
on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.powerhal.audio=AUDIO_STREAMING_LOW_LATENCY
|
||||
setprop vendor.powerhal.audio ""
|
||||
restart vendor.power-hal-aidl
|
|
@ -0,0 +1,6 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.power</name>
|
||||
<fqname>IPower/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
78
power-libperfmgr/aidl/service.cpp
Normal file
78
power-libperfmgr/aidl/service.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power-service.pixel-libperfmgr"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#include "Power.h"
|
||||
#include "PowerExt.h"
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
using aidl::google::hardware::power::impl::pixel::Power;
|
||||
using aidl::google::hardware::power::impl::pixel::PowerExt;
|
||||
using ::android::perfmgr::HintManager;
|
||||
|
||||
constexpr char kPowerHalConfigPath[] = "/system/etc/powerhint.json";
|
||||
constexpr char kPowerHalInitProp[] = "vendor.powerhal.init";
|
||||
|
||||
int main() {
|
||||
LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is starting.";
|
||||
|
||||
// Parse config but do not start the looper
|
||||
std::shared_ptr<HintManager> hm = HintManager::GetFromJSON(kPowerHalConfigPath, false);
|
||||
if (!hm) {
|
||||
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
|
||||
}
|
||||
|
||||
std::shared_ptr<DisplayLowPower> dlpw = std::make_shared<DisplayLowPower>();
|
||||
|
||||
// single thread
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
|
||||
// core service
|
||||
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>(hm, dlpw);
|
||||
ndk::SpAIBinder pwBinder = pw->asBinder();
|
||||
|
||||
// extension service
|
||||
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(hm, dlpw);
|
||||
|
||||
// attach the extension to the same binder we will be registering
|
||||
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
||||
|
||||
const std::string instance = std::string() + Power::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
LOG(INFO) << "Pixel Power HAL AIDL Service with Extension is started.";
|
||||
|
||||
std::thread initThread([&]() {
|
||||
::android::base::WaitForProperty(kPowerHalInitProp, "1");
|
||||
hm->Start();
|
||||
dlpw->Init();
|
||||
});
|
||||
initThread.detach();
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
|
||||
// should not reach
|
||||
LOG(ERROR) << "Pixel Power HAL AIDL Service with Extension just died.";
|
||||
return EXIT_FAILURE;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
service vendor.power-hal-1-3 /system/bin/hw/android.hardware.power@1.3-service.lenovo-libperfmgr
|
||||
class hal
|
||||
user root
|
||||
group system
|
||||
priority -20
|
||||
interface android.hardware.power@1.0::IPower default
|
||||
interface android.hardware.power@1.1::IPower default
|
||||
interface android.hardware.power@1.2::IPower default
|
||||
interface android.hardware.power@1.3::IPower default
|
||||
|
||||
# restart powerHAL when framework died
|
||||
on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
|
||||
setprop vendor.powerhal.state ""
|
||||
setprop vendor.powerhal.audio ""
|
||||
setprop vendor.powerhal.rendering ""
|
||||
restart vendor.power-hal-1-3
|
|
@ -1,11 +0,0 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.power</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.3</version>
|
||||
<interface>
|
||||
<name>IPower</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
73
power-libperfmgr/disp-power/DisplayLowPower.cpp
Normal file
73
power-libperfmgr/disp-power/DisplayLowPower.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power@-service.pixel-libperfmgr"
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cutils/sockets.h>
|
||||
#include <log/log.h>
|
||||
|
||||
#include "DisplayLowPower.h"
|
||||
|
||||
DisplayLowPower::DisplayLowPower() : mFossStatus(false) {}
|
||||
|
||||
void DisplayLowPower::Init() {
|
||||
ConnectPpsDaemon();
|
||||
}
|
||||
|
||||
void DisplayLowPower::SetDisplayLowPower(bool enable) {
|
||||
SetFoss(enable);
|
||||
}
|
||||
|
||||
void DisplayLowPower::ConnectPpsDaemon() {
|
||||
constexpr const char kPpsDaemon[] = "pps";
|
||||
|
||||
mPpsSocket.reset(
|
||||
socket_local_client(kPpsDaemon, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
|
||||
if (mPpsSocket.get() < 0) {
|
||||
ALOGW("Connecting to PPS daemon failed (%s)", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
int DisplayLowPower::SendPpsCommand(const std::string_view cmd) {
|
||||
if (TEMP_FAILURE_RETRY(write(mPpsSocket.get(), cmd.data(), cmd.size())) < 0) {
|
||||
ALOGE("Failed to send pps command '%s' over socket (%s)", cmd.data(), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DisplayLowPower::SetFoss(bool enable) {
|
||||
if (mPpsSocket.get() < 0 || mFossStatus == enable) {
|
||||
return;
|
||||
}
|
||||
|
||||
ALOGI("%s foss", (enable) ? "Enable" : "Disable");
|
||||
|
||||
std::string_view foss_cmd;
|
||||
if (enable) {
|
||||
foss_cmd = "foss:on";
|
||||
} else {
|
||||
foss_cmd = "foss:off";
|
||||
}
|
||||
|
||||
if (!SendPpsCommand(foss_cmd)) {
|
||||
mFossStatus = enable;
|
||||
}
|
||||
}
|
37
power-libperfmgr/disp-power/DisplayLowPower.h
Normal file
37
power-libperfmgr/disp-power/DisplayLowPower.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <android-base/unique_fd.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
class DisplayLowPower {
|
||||
public:
|
||||
DisplayLowPower();
|
||||
~DisplayLowPower() {}
|
||||
void Init();
|
||||
void SetDisplayLowPower(bool enable);
|
||||
|
||||
private:
|
||||
void ConnectPpsDaemon();
|
||||
int SendPpsCommand(const std::string_view cmd);
|
||||
void SetFoss(bool enable);
|
||||
|
||||
android::base::unique_fd mPpsSocket;
|
||||
bool mFossStatus;
|
||||
};
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power@1.3-service.pixel-libperfmgr"
|
||||
#define LOG_TAG "android.hardware.power@-service.pixel-libperfmgr"
|
||||
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
|
||||
|
||||
#include <fcntl.h>
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power@1.3-service.pixel-libperfmgr"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include "Power.h"
|
||||
|
||||
using android::OK;
|
||||
using android::sp;
|
||||
using android::status_t;
|
||||
|
||||
// libhwbinder:
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::power::V1_3::IPower;
|
||||
using android::hardware::power::V1_3::implementation::Power;
|
||||
|
||||
int main(int /* argc */, char ** /* argv */) {
|
||||
ALOGI("Power HAL Service 1.3 for Pixel is starting.");
|
||||
|
||||
android::sp<IPower> service = new Power();
|
||||
if (service == nullptr) {
|
||||
ALOGE("Can not create an instance of Power HAL Iface, exiting.");
|
||||
return 1;
|
||||
}
|
||||
android::hardware::setMinSchedulerPolicy(service, SCHED_NORMAL, -20);
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
status_t status = service->registerAsService();
|
||||
if (status != OK) {
|
||||
ALOGE("Could not register service for Power HAL Iface (%d), exiting.", status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("Power Service is ready");
|
||||
joinRpcThreadpool();
|
||||
|
||||
// In normal operation, we don't expect the thread pool to exit
|
||||
ALOGE("Power Service is shutting down");
|
||||
return 1;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
//
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
cc_binary {
|
||||
name: "android.hardware.power.stats@1.0-service.lenovo",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.power.stats@1.0-service.lenovo.rc"],
|
||||
srcs: ["service.cpp"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
],
|
||||
static_libs: [
|
||||
"libpixelpowerstats",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"libfmq",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.power.stats@1.0",
|
||||
"pixelpowerstats_provider_aidl_interface-cpp",
|
||||
"libbinder",
|
||||
],
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
service vendor.power.stats-hal-1-0 /system/bin/hw/android.hardware.power.stats@1.0-service.lenovo
|
||||
class hal
|
||||
user system
|
||||
group system
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.power.stats@1.0-service.pixel"
|
||||
|
||||
#include <android/log.h>
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include <pixelpowerstats/AidlStateResidencyDataProvider.h>
|
||||
#include <pixelpowerstats/GenericStateResidencyDataProvider.h>
|
||||
#include <pixelpowerstats/PowerStats.h>
|
||||
|
||||
using android::OK;
|
||||
using android::sp;
|
||||
using android::status_t;
|
||||
|
||||
// libhwbinder:
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::power::stats::V1_0::IPowerStats;
|
||||
using android::hardware::power::stats::V1_0::PowerEntityInfo;
|
||||
using android::hardware::power::stats::V1_0::PowerEntityStateSpace;
|
||||
using android::hardware::power::stats::V1_0::PowerEntityType;
|
||||
using android::hardware::power::stats::V1_0::implementation::PowerStats;
|
||||
|
||||
// Pixel specific
|
||||
using android::hardware::google::pixel::powerstats::AidlStateResidencyDataProvider;
|
||||
using android::hardware::google::pixel::powerstats::GenericStateResidencyDataProvider;
|
||||
using android::hardware::google::pixel::powerstats::PowerEntityConfig;
|
||||
using android::hardware::google::pixel::powerstats::StateResidencyConfig;
|
||||
|
||||
int main(int /* argc */, char ** /* argv */) {
|
||||
ALOGE("power.stats service 1.0 is starting.");
|
||||
|
||||
PowerStats *service = new PowerStats();
|
||||
|
||||
// Add power entities related to rpmh
|
||||
const uint64_t RPM_CLK = 19200; // RPM runs at 19.2Mhz. Divide by 19200 for msec
|
||||
std::function<uint64_t(uint64_t)> rpmConvertToMs = [](uint64_t a) { return a / RPM_CLK; };
|
||||
std::vector<StateResidencyConfig> rpmStateResidencyConfigs = {
|
||||
{.name = "Sleep",
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "Sleep Count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "Sleep Accumulated Duration:",
|
||||
.totalTimeTransform = rpmConvertToMs,
|
||||
.lastEntrySupported = true,
|
||||
.lastEntryPrefix = "Sleep Last Entered At:",
|
||||
.lastEntryTransform = rpmConvertToMs}};
|
||||
|
||||
sp<GenericStateResidencyDataProvider> rpmSdp =
|
||||
new GenericStateResidencyDataProvider("/sys/power/rpmh_stats/master_stats");
|
||||
|
||||
uint32_t apssId = service->addPowerEntity("APSS", PowerEntityType::SUBSYSTEM);
|
||||
rpmSdp->addEntity(apssId, PowerEntityConfig("APSS", rpmStateResidencyConfigs));
|
||||
|
||||
uint32_t mpssId = service->addPowerEntity("MPSS", PowerEntityType::SUBSYSTEM);
|
||||
rpmSdp->addEntity(mpssId, PowerEntityConfig("MPSS", rpmStateResidencyConfigs));
|
||||
|
||||
uint32_t adspId = service->addPowerEntity("ADSP", PowerEntityType::SUBSYSTEM);
|
||||
rpmSdp->addEntity(adspId, PowerEntityConfig("ADSP", rpmStateResidencyConfigs));
|
||||
|
||||
uint32_t cdspId = service->addPowerEntity("CDSP", PowerEntityType::SUBSYSTEM);
|
||||
rpmSdp->addEntity(cdspId, PowerEntityConfig("CDSP", rpmStateResidencyConfigs));
|
||||
|
||||
service->addStateResidencyDataProvider(rpmSdp);
|
||||
|
||||
// Add SoC power entity
|
||||
std::vector<StateResidencyConfig> socStateResidencyConfigs = {
|
||||
{.name = "AOSD",
|
||||
.header = "RPM Mode:aosd",
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "actual last sleep(msec):",
|
||||
.lastEntrySupported = false},
|
||||
{.name = "CXSD",
|
||||
.header = "RPM Mode:cxsd",
|
||||
.entryCountSupported = true,
|
||||
.entryCountPrefix = "count:",
|
||||
.totalTimeSupported = true,
|
||||
.totalTimePrefix = "actual last sleep(msec):",
|
||||
.lastEntrySupported = false}};
|
||||
|
||||
sp<GenericStateResidencyDataProvider> socSdp =
|
||||
new GenericStateResidencyDataProvider("/sys/power/system_sleep/stats");
|
||||
|
||||
uint32_t socId = service->addPowerEntity("SoC", PowerEntityType::POWER_DOMAIN);
|
||||
socSdp->addEntity(socId, PowerEntityConfig(socStateResidencyConfigs));
|
||||
|
||||
service->addStateResidencyDataProvider(socSdp);
|
||||
|
||||
// Add Power Entities that require the Aidl data provider
|
||||
sp<AidlStateResidencyDataProvider> aidlSdp = new AidlStateResidencyDataProvider();
|
||||
uint32_t citadelId = service->addPowerEntity("Citadel", PowerEntityType::SUBSYSTEM);
|
||||
aidlSdp->addEntity(citadelId, "Citadel", {"Last-Reset", "Active", "Deep-Sleep"});
|
||||
|
||||
auto serviceStatus = android::defaultServiceManager()->addService(
|
||||
android::String16("power.stats-vendor"), aidlSdp);
|
||||
if (serviceStatus != android::OK) {
|
||||
ALOGE("Unable to register power.stats-vendor service %d", serviceStatus);
|
||||
return 1;
|
||||
}
|
||||
sp<android::ProcessState> ps{android::ProcessState::self()}; // Create non-HW binder threadpool
|
||||
ps->startThreadPool();
|
||||
|
||||
service->addStateResidencyDataProvider(aidlSdp);
|
||||
|
||||
// Configure the threadpool
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
status_t status = service->registerAsService();
|
||||
if (status != OK) {
|
||||
ALOGE("Could not register service for power.stats HAL Iface (%d), exiting.", status);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("power.stats service is ready");
|
||||
joinRpcThreadpool();
|
||||
|
||||
// In normal operation, we don't expect the thread pool to exit
|
||||
ALOGE("power.stats service is shutting down");
|
||||
return 1;
|
||||
}
|
|
@ -10,7 +10,6 @@ type sysfs_graphics, sysfs_type, fs_type;
|
|||
type sysfs_devfreq, sysfs_type, fs_type;
|
||||
type sysfs_kgsl, sysfs_type, fs_type;
|
||||
type sysfs_scsi_devices, sysfs_type, fs_type;
|
||||
type sysfs_power_stats, sysfs_type, fs_type;
|
||||
type debugfs_wlan, debugfs_type, fs_type;
|
||||
type debugfs_sched_features, debugfs_type, fs_type;
|
||||
type proc_sysctl_schedboost, proc_type, fs_type;
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
/persist(/.*)? u:object_r:persist_file:s0
|
||||
|
||||
# HALs
|
||||
/system/bin/hw/android\.hardware\.power@1\.3-service\.lenovo-libperfmgr u:object_r:hal_power_pixel_exec:s0
|
||||
/system/bin/hw/android\.hardware\.power\.stats@1\.0-service\.lenovo u:object_r:hal_powerstats_exec:s0
|
||||
/system/bin/hw/android\.hardware\.power-service\.lenovo u:object_r:hal_power_pixel_exec:s0
|
||||
/system/bin/hw/lineage\.livedisplay@2\.0-service-sdm u:object_r:shal_livedisplay_default_exec:s0
|
||||
/(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.light@2\.0-service u:object_r:hal_light_default_exec:s0
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ genfscon sysfs /devices/platform/soc/1d84000.ufshc/clkgate_enable
|
|||
genfscon sysfs /devices/platform/soc/1d84000.ufshc/hibern8_on_idle_enable u:object_r:sysfs_scsi_devices:s0
|
||||
|
||||
genfscon sysfs /power/rpmh_stats/master_stats u:object_r:sysfs_rpm:s0
|
||||
genfscon sysfs /kernel/wlan/power_stats u:object_r:sysfs_power_stats:s0
|
||||
genfscon sysfs /power/system_sleep/stats u:object_r:sysfs_system_sleep_stats:s0
|
||||
|
||||
genfscon proc /sys/kernel/sched_boost u:object_r:proc_sysctl_schedboost:s0
|
||||
|
|
|
@ -20,7 +20,6 @@ allow hal_power_pixel sysfs_graphics:file r_file_perms;
|
|||
|
||||
allow hal_power_pixel sysfs_rpm:file r_file_perms;
|
||||
allow hal_power_pixel sysfs_system_sleep_stats:file r_file_perms;
|
||||
allow hal_power_pixel sysfs_power_stats:file r_file_perms;
|
||||
|
||||
r_dir_file(hal_power, sysfs_tp)
|
||||
allow hal_power_pixel sysfs_tp:file write;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
type hal_powerstats, domain;
|
||||
type hal_powerstats_exec, system_file_type, exec_type, file_type;
|
||||
init_daemon_domain(hal_powerstats)
|
||||
|
||||
allow hal_powerstats sysfs_rpm:file r_file_perms;
|
||||
allow hal_powerstats sysfs_system_sleep_stats:file r_file_perms;
|
||||
allow hal_powerstats sysfs_power_stats:file r_file_perms;
|
||||
|
||||
allow hal_powerstats default_android_service:service_manager add;
|
||||
allow hal_powerstats hal_power_stats_hwservice:hwservice_manager { add find };
|
||||
allow hal_powerstats hidl_base_hwservice:hwservice_manager add;
|
||||
get_prop(hal_powerstats, hwservicemanager_prop)
|
||||
|
||||
binder_call(hal_powerstats, servicemanager)
|
||||
binder_call(hal_powerstats, hwservicemanager)
|
||||
binder_call(hal_powerstats, system_server)
|
||||
allow hal_powerstats binder_device:chr_file rw_file_perms;
|
||||
|
||||
allow servicemanager hal_powerstats:binder call;
|
|
@ -1,3 +1,2 @@
|
|||
get_prop(system_server, vendor_camera_prop)
|
||||
allow system_server hal_power_pixel:binder call;
|
||||
allow system_server hal_powerstats:binder call;
|
||||
|
|
Loading…
Reference in a new issue