summaryrefslogtreecommitdiff
path: root/thermal
diff options
context:
space:
mode:
authorTeYuan Wang <kamewang@google.com>2018-08-03 20:11:15 +0800
committerJenhao Chen <jenhaochen@google.com>2018-08-14 13:25:52 +0000
commit386c21b33bf2f7ff8dddacc8c1a67d80f534513b (patch)
tree6cbe3d8b4d07581789b8744cc19d4a79c1c56427 /thermal
parent3195ab2e03c89c6b7e141af26c47ffb2f7eafb81 (diff)
downloadbonito-386c21b33bf2f7ff8dddacc8c1a67d80f534513b.tar.gz
b4s4: thermal: bring up thermal hal
Refer from ag/4429203, and ag/4372722 but remove function getSkinSensorType since b4s4 only have 1 tskin sensor. Bug: 110964809 Test: lshal debug android.hardware.thermal@1.1::IThermal/default Change-Id: I223d00b73abe1e700f954ebafe07c49c0d9e1d01
Diffstat (limited to 'thermal')
-rw-r--r--thermal/thermal-helper.cpp42
-rw-r--r--thermal/thermal-helper.h2
2 files changed, 26 insertions, 18 deletions
diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp
index 781e4d11..57764c69 100644
--- a/thermal/thermal-helper.cpp
+++ b/thermal/thermal-helper.cpp
@@ -15,6 +15,7 @@
*/
#include <sstream>
+#include <set>
#include <vector>
#include <android-base/file.h>
@@ -43,6 +44,9 @@ constexpr char kThermalZoneDirSuffix[] = "thermal_zone";
constexpr char kCoolingDeviceDirSuffix[] = "cooling_device";
constexpr unsigned int kMaxCpus = 8;
constexpr unsigned int kMaxSensorSearchNum = 100;
+// The number of available sensors in thermalHAL is:
+// 8 (for each cpu) + 2 (for each gpu) + battery + skin + usb = 13.
+constexpr unsigned int kAvailableSensors = 13;
// This is a golden set of thermal sensor type and their temperature types.
// Used when we read in sensor values.
@@ -61,8 +65,10 @@ kValidThermalSensorTypeMap = {
{"gpu1-usr", TemperatureType::GPU},
// Battery thermal sensor.
{"battery", TemperatureType::BATTERY},
- // Skin thermal sensor.
+ // Skin sensor.
{kSkinSensorType, TemperatureType::SKIN},
+ // USBC thermal sensor.
+ {"usb-therm-adc", TemperatureType::UNKNOWN},
};
namespace {
@@ -101,7 +107,7 @@ void parseCpuUsagesFileAndAssignUsages(hidl_vec<CpuUsage>* cpu_usages) {
if (!android::base::ReadFileToString(
cpu_online_path, &is_online)) {
LOG(ERROR) << "Could not open Cpu online file: "
- << cpu_online_path;
+ << cpu_online_path;
return;
}
is_online = android::base::Trim(is_online);
@@ -145,10 +151,10 @@ kValidCoolingDeviceTypeMap = {
{"thermal-cpufreq-1", "cpu1-silver-usr"}, // CPU1
{"thermal-cpufreq-2", "cpu2-silver-usr"}, // CPU2
{"thermal-cpufreq-3", "cpu3-silver-usr"}, // CPU3
- {"thermal-cpufreq-4", "cpu0-gold-usr"}, // CPU4
- {"thermal-cpufreq-5", "cpu1-gold-usr"}, // CPU5
- {"thermal-cpufreq-6", "cpu2-gold-usr"}, // CPU6
- {"thermal-cpufreq-7", "cpu3-gold-usr"}, // CPU7
+ {"thermal-cpufreq-4", "cpu4-silver-usr"}, // CPU4
+ {"thermal-cpufreq-5", "cpu5-silver-usr"}, // CPU5
+ {"thermal-cpufreq-6", "cpu0-gold-usr"}, // CPU6
+ {"thermal-cpufreq-7", "cpu1-gold-usr"}, // CPU7
};
/*
@@ -216,7 +222,7 @@ bool ThermalHelper::readTemperature(
out->throttlingThreshold = getThresholdFromType(
kValidThermalSensorTypeMap.at(sensor_name), thresholds_);
if (kValidThermalSensorTypeMap.at(sensor_name) == TemperatureType::SKIN) {
- out->throttlingThreshold = mLowTempThresholdAdjuster.adjustThreshold(
+ out->throttlingThreshold = low_temp_threshold_adjuster_.adjustThreshold(
out->throttlingThreshold, out->currentValue);
}
@@ -251,17 +257,18 @@ bool ThermalHelper::initializeSensorMap() {
sensor_name = android::base::Trim(sensor_name);
if (kValidThermalSensorTypeMap.find(sensor_name) !=
kValidThermalSensorTypeMap.end()) {
- if (!thermal_sensors_.addSensor(
- sensor_name, sensor_temp_path)) {
- LOG(ERROR) << "Could not add " << sensor_name
- << "to sensors map";
- }
+
+ if (!thermal_sensors_.addSensor(
+ sensor_name, sensor_temp_path)) {
+ LOG(ERROR) << "Could not add " << sensor_name
+ << "to sensors map";
+ }
}
}
- if (kValidThermalSensorTypeMap.size()
- == thermal_sensors_.getNumSensors()) {
+ }
+ if (kAvailableSensors == thermal_sensors_.getNumSensors() ||
+ kValidThermalSensorTypeMap.size() == thermal_sensors_.getNumSensors()) {
return true;
- }
}
return false;
}
@@ -312,10 +319,11 @@ bool ThermalHelper::initializeCoolingDevices() {
}
bool ThermalHelper::fillTemperatures(hidl_vec<Temperature>* temperatures) {
- temperatures->resize(kValidThermalSensorTypeMap.size());
+ temperatures->resize(kAvailableSensors);
int current_index = 0;
for (const auto& name_type_pair : kValidThermalSensorTypeMap) {
Temperature temp;
+
if (readTemperature(name_type_pair.first, &temp)) {
(*temperatures)[current_index] = temp;
} else {
@@ -385,7 +393,7 @@ bool ThermalHelper::checkThrottlingData(
bool ThermalHelper::fillBatteryThresholdDebugInfo(std::ostringstream& dump_buf)
{
- return mLowTempThresholdAdjuster.fillBatteryThresholdDebugInfo(dump_buf);
+ return low_temp_threshold_adjuster_.fillBatteryThresholdDebugInfo(dump_buf);
}
} // namespace implementation
diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h
index 71885d25..db8b9efd 100644
--- a/thermal/thermal-helper.h
+++ b/thermal/thermal-helper.h
@@ -121,7 +121,7 @@ class ThermalHelper {
ThrottlingThresholds vr_thresholds_;
ThrottlingThresholds shutdown_thresholds_;
const bool is_initialized_;
- const BatteryThresholdLUT mLowTempThresholdAdjuster;
+ const BatteryThresholdLUT low_temp_threshold_adjuster_;
};
} // namespace implementation