Delete patches_treble_td/platform_frameworks_native/0006-powermanager-Add-support-Samsung-miscpower-HAL.patch
This commit is contained in:
parent
3750ff0cd0
commit
98beb8602f
@ -1,301 +0,0 @@
|
|||||||
From 4eca6bb36b071de20f2defe141ff7a880596114c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Pierre-Hugues Husson <phh@phh.me>
|
|
||||||
Date: Mon, 27 Dec 2021 18:00:43 -0500
|
|
||||||
Subject: [PATCH 06/10] powermanager: Add support Samsung miscpower HAL
|
|
||||||
|
|
||||||
Several various configurations need to be supported:
|
|
||||||
- Android Pie vendors have a android.hardware.power HIDL default + "miscpower"
|
|
||||||
- Android Q vendors have default HIDL android.hardware.power +
|
|
||||||
ISehMiscPower
|
|
||||||
- Android R vendors have default AIDL android.hardware.power +
|
|
||||||
ISehMiscPower
|
|
||||||
|
|
||||||
ISehMiscPower is always in addition to android.hardware.power, not as a
|
|
||||||
substituion
|
|
||||||
|
|
||||||
Only tested configuration ATM is the latest one
|
|
||||||
|
|
||||||
Change-Id: I182a91ccb0a89f9d0d7d41f36eccab218b553bbc
|
|
||||||
---
|
|
||||||
include/powermanager/PowerHalLoader.h | 5 ++
|
|
||||||
include/powermanager/PowerHalWrapper.h | 36 +++++++++-
|
|
||||||
services/powermanager/Android.bp | 1 +
|
|
||||||
services/powermanager/PowerHalController.cpp | 7 +-
|
|
||||||
services/powermanager/PowerHalLoader.cpp | 17 ++++-
|
|
||||||
services/powermanager/PowerHalWrapper.cpp | 70 ++++++++++++++++++++
|
|
||||||
6 files changed, 133 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/powermanager/PowerHalLoader.h b/include/powermanager/PowerHalLoader.h
|
|
||||||
index ed6f6f35f5..cf1d76e3d1 100644
|
|
||||||
--- a/include/powermanager/PowerHalLoader.h
|
|
||||||
+++ b/include/powermanager/PowerHalLoader.h
|
|
||||||
@@ -20,6 +20,8 @@
|
|
||||||
#include <android-base/thread_annotations.h>
|
|
||||||
#include <android/hardware/power/1.1/IPower.h>
|
|
||||||
#include <android/hardware/power/IPower.h>
|
|
||||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
|
||||||
+
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
@@ -32,12 +34,15 @@ public:
|
|
||||||
static sp<hardware::power::IPower> loadAidl();
|
|
||||||
static sp<hardware::power::V1_0::IPower> loadHidlV1_0();
|
|
||||||
static sp<hardware::power::V1_1::IPower> loadHidlV1_1();
|
|
||||||
+ static sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> loadHidlSeh();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::mutex gHalMutex;
|
|
||||||
static sp<hardware::power::IPower> gHalAidl GUARDED_BY(gHalMutex);
|
|
||||||
static sp<hardware::power::V1_0::IPower> gHalHidlV1_0 GUARDED_BY(gHalMutex);
|
|
||||||
static sp<hardware::power::V1_1::IPower> gHalHidlV1_1 GUARDED_BY(gHalMutex);
|
|
||||||
+ static sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> gHalHidlSeh GUARDED_BY(gHalMutex);
|
|
||||||
+
|
|
||||||
|
|
||||||
static sp<hardware::power::V1_0::IPower> loadHidlV1_0Locked()
|
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(gHalMutex);
|
|
||||||
diff --git a/include/powermanager/PowerHalWrapper.h b/include/powermanager/PowerHalWrapper.h
|
|
||||||
index dfb0ff59a0..9ad805dfcd 100644
|
|
||||||
--- a/include/powermanager/PowerHalWrapper.h
|
|
||||||
+++ b/include/powermanager/PowerHalWrapper.h
|
|
||||||
@@ -23,6 +23,8 @@
|
|
||||||
#include <android/hardware/power/IPower.h>
|
|
||||||
#include <android/hardware/power/IPowerHintSession.h>
|
|
||||||
#include <android/hardware/power/Mode.h>
|
|
||||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
|
||||||
+
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
|
|
||||||
@@ -181,7 +183,10 @@ private:
|
|
||||||
// Wrapper for the AIDL Power HAL.
|
|
||||||
class AidlHalWrapper : public HalWrapper {
|
|
||||||
public:
|
|
||||||
- explicit AidlHalWrapper(sp<hardware::power::IPower> handle) : mHandle(std::move(handle)) {}
|
|
||||||
+ explicit AidlHalWrapper(sp<hardware::power::IPower> handle,
|
|
||||||
+ sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> sehHandle)
|
|
||||||
+ : mHandle(std::move(handle)),
|
|
||||||
+ mHandleSeh(std::move(sehHandle)) {}
|
|
||||||
virtual ~AidlHalWrapper() = default;
|
|
||||||
|
|
||||||
virtual HalResult<void> setBoost(hardware::power::Boost boost, int32_t durationMs) override;
|
|
||||||
@@ -196,6 +201,7 @@ private:
|
|
||||||
std::mutex mBoostMutex;
|
|
||||||
std::mutex mModeMutex;
|
|
||||||
sp<hardware::power::IPower> mHandle;
|
|
||||||
+ sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> mHandleSeh;
|
|
||||||
// Android framework only sends boost upto DISPLAY_UPDATE_IMMINENT.
|
|
||||||
// Need to increase the array size if more boost supported.
|
|
||||||
std::array<std::atomic<HalSupport>,
|
|
||||||
@@ -206,6 +212,34 @@ private:
|
|
||||||
mModeSupportedArray GUARDED_BY(mModeMutex) = {HalSupport::UNKNOWN};
|
|
||||||
};
|
|
||||||
|
|
||||||
+class HidlHalWrapperSeh : public HalWrapper {
|
|
||||||
+public:
|
|
||||||
+ explicit HidlHalWrapperSeh(sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> hal1,
|
|
||||||
+ sp<android::hardware::power::V1_1::IPower> hal2,
|
|
||||||
+ sp<android::hardware::power::V1_0::IPower> hal3)
|
|
||||||
+ : mHandleSeh(std::move(hal1)),
|
|
||||||
+ mHandle11(std::move(hal2)),
|
|
||||||
+ mHandle10(std::move(hal3)) {}
|
|
||||||
+ virtual ~HidlHalWrapperSeh() = default;
|
|
||||||
+
|
|
||||||
+ virtual HalResult<void> setBoost(hardware::power::Boost boost, int32_t durationMs) override;
|
|
||||||
+ virtual HalResult<void> setMode(hardware::power::Mode mode, bool enabled) override;
|
|
||||||
+ virtual HalResult<sp<hardware::power::IPowerHintSession>> createHintSession(
|
|
||||||
+ int32_t tgid, int32_t uid, const std::vector<int32_t>& threadIds,
|
|
||||||
+ int64_t durationNanos) override;
|
|
||||||
+ virtual HalResult<int64_t> getHintSessionPreferredRate() override;
|
|
||||||
+
|
|
||||||
+protected:
|
|
||||||
+ virtual HalResult<void> sendPowerHint(hardware::power::V1_0::PowerHint hintId, uint32_t data);
|
|
||||||
+
|
|
||||||
+private:
|
|
||||||
+ sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> mHandleSeh;
|
|
||||||
+ sp<android::hardware::power::V1_1::IPower> mHandle11;
|
|
||||||
+ sp<android::hardware::power::V1_0::IPower> mHandle10;
|
|
||||||
+ HalResult<void> setInteractive(bool enabled);
|
|
||||||
+ HalResult<void> setFeature(hardware::power::V1_0::Feature feature, bool enabled);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
}; // namespace power
|
|
||||||
|
|
||||||
}; // namespace android
|
|
||||||
diff --git a/services/powermanager/Android.bp b/services/powermanager/Android.bp
|
|
||||||
index 6fbba3f568..08280dd20f 100644
|
|
||||||
--- a/services/powermanager/Android.bp
|
|
||||||
+++ b/services/powermanager/Android.bp
|
|
||||||
@@ -39,6 +39,7 @@ cc_library_shared {
|
|
||||||
"android.hardware.power@1.0",
|
|
||||||
"android.hardware.power@1.1",
|
|
||||||
"android.hardware.power-V3-cpp",
|
|
||||||
+ "vendor.samsung.hardware.miscpower@2.0",
|
|
||||||
],
|
|
||||||
|
|
||||||
cflags: [
|
|
||||||
diff --git a/services/powermanager/PowerHalController.cpp b/services/powermanager/PowerHalController.cpp
|
|
||||||
index 8c225d5d02..f67fbae08b 100644
|
|
||||||
--- a/services/powermanager/PowerHalController.cpp
|
|
||||||
+++ b/services/powermanager/PowerHalController.cpp
|
|
||||||
@@ -20,6 +20,7 @@
|
|
||||||
#include <android/hardware/power/IPower.h>
|
|
||||||
#include <android/hardware/power/IPowerHintSession.h>
|
|
||||||
#include <android/hardware/power/Mode.h>
|
|
||||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
|
||||||
#include <powermanager/PowerHalController.h>
|
|
||||||
#include <powermanager/PowerHalLoader.h>
|
|
||||||
#include <utils/Log.h>
|
|
||||||
@@ -34,11 +35,15 @@ namespace power {
|
|
||||||
|
|
||||||
std::unique_ptr<HalWrapper> HalConnector::connect() {
|
|
||||||
sp<IPower> halAidl = PowerHalLoader::loadAidl();
|
|
||||||
+ sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> halHidlSeh = PowerHalLoader::loadHidlSeh();
|
|
||||||
if (halAidl) {
|
|
||||||
- return std::make_unique<AidlHalWrapper>(halAidl);
|
|
||||||
+ return std::make_unique<AidlHalWrapper>(halAidl, halHidlSeh);
|
|
||||||
}
|
|
||||||
sp<V1_0::IPower> halHidlV1_0 = PowerHalLoader::loadHidlV1_0();
|
|
||||||
sp<V1_1::IPower> halHidlV1_1 = PowerHalLoader::loadHidlV1_1();
|
|
||||||
+ if (halHidlSeh) {
|
|
||||||
+ return std::make_unique<HidlHalWrapperSeh>(halHidlSeh, halHidlV1_1, halHidlV1_0);
|
|
||||||
+ }
|
|
||||||
if (halHidlV1_1) {
|
|
||||||
return std::make_unique<HidlHalWrapperV1_1>(halHidlV1_0, halHidlV1_1);
|
|
||||||
}
|
|
||||||
diff --git a/services/powermanager/PowerHalLoader.cpp b/services/powermanager/PowerHalLoader.cpp
|
|
||||||
index 1f1b43a607..9b20e67f7a 100644
|
|
||||||
--- a/services/powermanager/PowerHalLoader.cpp
|
|
||||||
+++ b/services/powermanager/PowerHalLoader.cpp
|
|
||||||
@@ -18,6 +18,7 @@
|
|
||||||
|
|
||||||
#include <android/hardware/power/1.1/IPower.h>
|
|
||||||
#include <android/hardware/power/IPower.h>
|
|
||||||
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
|
|
||||||
#include <binder/IServiceManager.h>
|
|
||||||
#include <hardware/power.h>
|
|
||||||
#include <hardware_legacy/power.h>
|
|
||||||
@@ -55,6 +56,8 @@ std::mutex PowerHalLoader::gHalMutex;
|
|
||||||
sp<IPower> PowerHalLoader::gHalAidl = nullptr;
|
|
||||||
sp<V1_0::IPower> PowerHalLoader::gHalHidlV1_0 = nullptr;
|
|
||||||
sp<V1_1::IPower> PowerHalLoader::gHalHidlV1_1 = nullptr;
|
|
||||||
+sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> PowerHalLoader::gHalHidlSeh = nullptr;
|
|
||||||
+
|
|
||||||
|
|
||||||
void PowerHalLoader::unloadAll() {
|
|
||||||
std::lock_guard<std::mutex> lock(gHalMutex);
|
|
||||||
@@ -82,10 +85,22 @@ sp<V1_1::IPower> PowerHalLoader::loadHidlV1_1() {
|
|
||||||
return loadHal<V1_1::IPower>(gHalExists, gHalHidlV1_1, loadFn, "HIDL v1.1");
|
|
||||||
}
|
|
||||||
|
|
||||||
+sp<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower> PowerHalLoader::loadHidlSeh() {
|
|
||||||
+ std::lock_guard<std::mutex> lock(gHalMutex);
|
|
||||||
+ static bool gHalExists = true;
|
|
||||||
+ static auto loadFn = []() { return vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower::getService(); };
|
|
||||||
+ return loadHal<vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower>(gHalExists, gHalHidlSeh, loadFn, "HIDL SEH v1.1");
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
sp<V1_0::IPower> PowerHalLoader::loadHidlV1_0Locked() {
|
|
||||||
static bool gHalExists = true;
|
|
||||||
+ static auto loadFnSec = []() { return V1_0::IPower::getService("power"); };
|
|
||||||
+ auto hal = loadHal<V1_0::IPower>(gHalExists, gHalHidlV1_0, loadFnSec, "HIDL v1.0");
|
|
||||||
+
|
|
||||||
static auto loadFn = []() { return V1_0::IPower::getService(); };
|
|
||||||
- return loadHal<V1_0::IPower>(gHalExists, gHalHidlV1_0, loadFn, "HIDL v1.0");
|
|
||||||
+ if(hal == nullptr)
|
|
||||||
+ hal = loadHal<V1_0::IPower>(gHalExists, gHalHidlV1_0, loadFn, "HIDL v1.0");
|
|
||||||
+ return hal;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
diff --git a/services/powermanager/PowerHalWrapper.cpp b/services/powermanager/PowerHalWrapper.cpp
|
|
||||||
index d74bd23a8d..a83990f2a4 100644
|
|
||||||
--- a/services/powermanager/PowerHalWrapper.cpp
|
|
||||||
+++ b/services/powermanager/PowerHalWrapper.cpp
|
|
||||||
@@ -209,6 +209,10 @@ HalResult<void> AidlHalWrapper::setMode(Mode mode, bool enabled) {
|
|
||||||
std::unique_lock<std::mutex> lock(mModeMutex);
|
|
||||||
size_t idx = static_cast<size_t>(mode);
|
|
||||||
|
|
||||||
+ if (mHandleSeh != nullptr && mode == Mode::INTERACTIVE) {
|
|
||||||
+ mHandleSeh->setInteractiveAsync(enabled, false);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
// Quick return if mode is not supported by HAL
|
|
||||||
if (idx >= mModeSupportedArray.size() || mModeSupportedArray[idx] == HalSupport::OFF) {
|
|
||||||
ALOGV("Skipped setMode %s because Power HAL doesn't support it", toString(mode).c_str());
|
|
||||||
@@ -248,6 +252,72 @@ HalResult<int64_t> AidlHalWrapper::getHintSessionPreferredRate() {
|
|
||||||
return HalResult<int64_t>::fromStatus(result, rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
+HalResult<void> HidlHalWrapperSeh::setBoost(Boost boost, int32_t durationMs) {
|
|
||||||
+ if (boost == Boost::INTERACTION) {
|
|
||||||
+ return sendPowerHint(V1_0::PowerHint::INTERACTION, durationMs);
|
|
||||||
+ } else {
|
|
||||||
+ ALOGV("Skipped setBoost %s because Power HAL AIDL not available", toString(boost).c_str());
|
|
||||||
+ return HalResult<void>::unsupported();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<void> HidlHalWrapperSeh::setMode(Mode mode, bool enabled) {
|
|
||||||
+ uint32_t data = enabled ? 1 : 0;
|
|
||||||
+ switch (mode) {
|
|
||||||
+ case Mode::LAUNCH:
|
|
||||||
+ return sendPowerHint(V1_0::PowerHint::LAUNCH, data);
|
|
||||||
+ case Mode::LOW_POWER:
|
|
||||||
+ return sendPowerHint(V1_0::PowerHint::LOW_POWER, data);
|
|
||||||
+ case Mode::SUSTAINED_PERFORMANCE:
|
|
||||||
+ return sendPowerHint(V1_0::PowerHint::SUSTAINED_PERFORMANCE, data);
|
|
||||||
+ case Mode::VR:
|
|
||||||
+ return sendPowerHint(V1_0::PowerHint::VR_MODE, data);
|
|
||||||
+ case Mode::INTERACTIVE:
|
|
||||||
+ return setInteractive(enabled);
|
|
||||||
+ case Mode::DOUBLE_TAP_TO_WAKE:
|
|
||||||
+ return setFeature(V1_0::Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE, enabled);
|
|
||||||
+ default:
|
|
||||||
+ ALOGV("Skipped setMode %s because Power HAL AIDL not available",
|
|
||||||
+ toString(mode).c_str());
|
|
||||||
+ return HalResult<void>::unsupported();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<void> HidlHalWrapperSeh::sendPowerHint(V1_0::PowerHint hintId, uint32_t data) {
|
|
||||||
+ if(mHandle11 != nullptr) {
|
|
||||||
+ auto ret = mHandle11->powerHintAsync(hintId, data);
|
|
||||||
+ return HalResult<void>::fromReturn(ret);
|
|
||||||
+ } else {
|
|
||||||
+ auto ret = mHandle10->powerHint(hintId, data);
|
|
||||||
+ return HalResult<void>::fromReturn(ret);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<void> HidlHalWrapperSeh::setInteractive(bool enabled) {
|
|
||||||
+ if(mHandleSeh != nullptr) {
|
|
||||||
+ mHandleSeh->setInteractiveAsync(enabled, false);
|
|
||||||
+ }
|
|
||||||
+ auto ret = mHandle10->setInteractive(enabled);
|
|
||||||
+ return HalResult<void>::fromReturn(ret);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<void> HidlHalWrapperSeh::setFeature(V1_0::Feature feature, bool enabled) {
|
|
||||||
+ auto ret = mHandle10->setFeature(feature, enabled);
|
|
||||||
+ return HalResult<void>::fromReturn(ret);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<sp<Aidl::IPowerHintSession>> HidlHalWrapperSeh::createHintSession(
|
|
||||||
+ int32_t, int32_t, const std::vector<int32_t>& threadIds, int64_t) {
|
|
||||||
+ ALOGV("Skipped createHintSession(task num=%zu) because Power HAL not available",
|
|
||||||
+ threadIds.size());
|
|
||||||
+ return HalResult<sp<Aidl::IPowerHintSession>>::unsupported();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+HalResult<int64_t> HidlHalWrapperSeh::getHintSessionPreferredRate() {
|
|
||||||
+ ALOGV("Skipped getHintSessionPreferredRate because Power HAL not available");
|
|
||||||
+ return HalResult<int64_t>::unsupported();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
// -------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
} // namespace power
|
|
||||||
--
|
|
||||||
2.34.1
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user