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
This commit is contained in:
Todd Poynor
2017-08-25 13:41:07 -07:00
parent f16a701e6b
commit 3ae03f7e09
4 changed files with 41 additions and 0 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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