diff options
author | Todd Poynor <toddpoynor@google.com> | 2017-08-25 13:41:07 -0700 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2017-09-20 18:05:25 +0000 |
commit | 3ae03f7e092da5c29c39b70098d5063693aaea40 (patch) | |
tree | 3a0884b2826ec7b5e986bbc9a5f6fd3d31ddd768 | |
parent | f16a701e6b15ea3af962c354992bdaa1cc52ddb6 (diff) | |
download | wahoo-3ae03f7e092da5c29c39b70098d5063693aaea40.tar.gz |
thermal: add private methods for thermal-engine use
Add private HAL implementation methods for use in interacting with
the thermal-engine daemon:
* getSkinSensorType returns the "type" (name) of the skin sensor
for walleye vs. taimen
* notifyThrottling pushes throttling start/stop events to the HAL
for forwarding to IThermalCallback in the generic framework.
Bug: 30982366
Test: manual on walleye (with artifically low threshold)
Change-Id: I082c100df22880bfd53c2cb5c78b0be47c58894e
-rw-r--r-- | thermal/Thermal.cpp | 26 | ||||
-rw-r--r-- | thermal/Thermal.h | 3 | ||||
-rw-r--r-- | thermal/thermal-helper.cpp | 8 | ||||
-rw-r--r-- | thermal/thermal-helper.h | 4 |
4 files changed, 41 insertions, 0 deletions
diff --git a/thermal/Thermal.cpp b/thermal/Thermal.cpp index d397901b..a9bd3715 100644 --- a/thermal/Thermal.cpp +++ b/thermal/Thermal.cpp @@ -150,6 +150,32 @@ Return<void> Thermal::registerThermalCallback( return Void(); } +// Local functions used internally by thermal-engine follow. + +std::string Thermal::getSkinSensorType() { + return getTargetSkinSensorType(); +} + +void Thermal::notifyThrottling( + bool isThrottling, const Temperature& temperature) { + if (gThermalCallback != nullptr) { + Return<void> ret = + gThermalCallback->notifyThrottling(isThrottling, temperature); + if (!ret.isOk()) { + if (ret.isDeadObject()) { + gThermalCallback = nullptr; + LOG(WARNING) << "Dropped throttling event, ThermalCallback died"; + } else { + LOG(WARNING) << + "Failed to send throttling event to ThermalCallback"; + } + } + } else { + LOG(WARNING) << + "Dropped throttling event, no ThermalCallback registered"; + } +} + } // namespace implementation } // namespace V1_1 } // namespace thermal diff --git a/thermal/Thermal.h b/thermal/Thermal.h index 5a75c258..a62b9e32 100644 --- a/thermal/Thermal.h +++ b/thermal/Thermal.h @@ -43,6 +43,9 @@ using ::android::hidl::base::V1_0::IBase; using ::android::sp; struct Thermal : public IThermal { + // Local functions used internally by thermal-engine follow. + std::string getSkinSensorType(); + void notifyThrottling(bool isThrottling, const Temperature& temperature); Thermal(); // Methods from ::android::hardware::thermal::V1_0::IThermal follow. Return<void> getTemperatures(getTemperatures_cb _hidl_cb) override; diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp index 6f61a989..878c82f5 100644 --- a/thermal/thermal-helper.cpp +++ b/thermal/thermal-helper.cpp @@ -36,6 +36,7 @@ namespace implementation { using ::android::hardware::thermal::V1_0::TemperatureType; static unsigned int gSkinSensorNum; +static std::string gSkinSensorType; static unsigned int gTsensOffset; static unsigned int gSkinThrottlingThreshold; static unsigned int gSkinShutdownThreshold; @@ -51,6 +52,7 @@ bool initThermal() { if (hardware == "walleye") { LOG(ERROR) << "Initialization on Walleye"; gSkinSensorNum = kWalleyeSkinSensorNum; + gSkinSensorType = kWalleyeSkinSensorType; gTsensOffset = kWalleyeTsensOffset; gSkinThrottlingThreshold = kWalleyeSkinThrottlingThreshold; gSkinShutdownThreshold = kWalleyeSkinShutdownThreshold; @@ -60,6 +62,7 @@ bool initThermal() { if (rev == "rev_a" || rev == "rev_b") { LOG(ERROR) << "Initialization on Taimen pre revision C"; gSkinSensorNum = kTaimenRabSkinSensorNum; + gSkinSensorType = kTaimenRabSkinSensorType; gTsensOffset = kTaimenRabTsensOffset; gSkinThrottlingThreshold = kTaimenRabSkinThrottlingThreshold; gSkinShutdownThreshold = kTaimenRabSkinShutdownThreshold; @@ -67,6 +70,7 @@ bool initThermal() { } else { LOG(ERROR) << "Initialization on Taimen revision C and later"; gSkinSensorNum = kTaimenRcSkinSensorNum; + gSkinSensorType = kTaimenRcSkinSensorType; gTsensOffset = kTaimenRcTsensOffset; gSkinThrottlingThreshold = kTaimenRcSkinThrottlingThreshold; gSkinShutdownThreshold = kTaimenRcSkinShutdownThreshold; @@ -288,6 +292,10 @@ ssize_t fillCpuUsages(hidl_vec<CpuUsage> *cpuUsages) { return kCpuNum; } +std::string getTargetSkinSensorType() { + return gSkinSensorType; +} + } // namespace implementation } // namespace V1_1 } // namespace thermal diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h index 9fd013b4..311a67d8 100644 --- a/thermal/thermal-helper.h +++ b/thermal/thermal-helper.h @@ -47,18 +47,21 @@ constexpr const char *kCpuOnlineFileFormat = "/sys/devices/system/cpu/cpu%d/onli // thermal-engine.conf constexpr unsigned int kWalleyeSkinSensorNum = 9; +constexpr auto kWalleyeSkinSensorType = "back_therm"; constexpr unsigned int kWalleyeTsensOffset = 11; constexpr unsigned int kWalleyeSkinThrottlingThreshold = 40; constexpr unsigned int kWalleyeSkinShutdownThreshold = 56; constexpr unsigned int kWalleyeVrThrottledBelowMin = 52; constexpr unsigned int kTaimenRabSkinSensorNum = 8; +constexpr auto kTaimenRabSkinSensorType = "bd_therm"; constexpr unsigned int kTaimenRabTsensOffset = 9; constexpr unsigned int kTaimenRabSkinThrottlingThreshold = 49; constexpr unsigned int kTaimenRabSkinShutdownThreshold = 66; constexpr unsigned int kTaimenRabVrThrottledBelowMin = 62; constexpr unsigned int kTaimenRcSkinSensorNum = 8; +constexpr auto kTaimenRcSkinSensorType = "bd_therm2"; constexpr unsigned int kTaimenRcTsensOffset = 9; constexpr unsigned int kTaimenRcSkinThrottlingThreshold = 38; constexpr unsigned int kTaimenRcSkinShutdownThreshold = 54; @@ -90,6 +93,7 @@ constexpr unsigned int kBatteryShutdownThreshold = 60; bool initThermal(); ssize_t fillTemperatures(hidl_vec<Temperature> *temperatures); ssize_t fillCpuUsages(hidl_vec<CpuUsage> *cpuUsages); +std::string getTargetSkinSensorType(); } // namespace implementation } // namespace V1_1 |