summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqctecmdr <qctecmdr@localhost>2021-01-04 10:10:15 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2021-01-04 10:10:15 -0800
commit21d4768a4fc8083b621fb90f4c47e7517fa8119f (patch)
tree72f77a01fcf71951e07dedd13acbb1c521508706
parent2658fa6df7570f65a50111b2b6eda6f93020c212 (diff)
parent56329994f1026825cab49517add821a643db8192 (diff)
Merge "thermal-hal: Notify clients when they read temperature"
-rw-r--r--thermalCommon.cpp1
-rw-r--r--thermalUtils.cpp30
-rw-r--r--thermalUtils.h1
3 files changed, 20 insertions, 12 deletions
diff --git a/thermalCommon.cpp b/thermalCommon.cpp
index 638b3b6..2870a7a 100644
--- a/thermalCommon.cpp
+++ b/thermalCommon.cpp
@@ -457,7 +457,6 @@ int ThermalCommon::read_temperature(struct therm_sensor& sensor)
LOG(DEBUG) << "Sensor Name:" << sensor.t.name << ". Temperature:" <<
(float)sensor.t.value << std::endl;
- estimateSeverity(sensor);
return ret;
}
diff --git a/thermalUtils.cpp b/thermalUtils.cpp
index f057e75..4cd94a2 100644
--- a/thermalUtils.cpp
+++ b/thermalUtils.cpp
@@ -66,6 +66,7 @@ ThermalUtils::ThermalUtils(const ueventCB &inp_cb):
for (struct therm_sensor sens: sensorList) {
thermalConfig[sens.sensor_name] = sens;
cmnInst.read_temperature(sens);
+ cmnInst.estimateSeverity(sens);
cmnInst.initThreshold(sens);
}
monitor.start();
@@ -77,10 +78,21 @@ ThermalUtils::ThermalUtils(const ueventCB &inp_cb):
}
}
-void ThermalUtils::ueventParse(std::string sensor_name, int temp)
+void ThermalUtils::Notify(struct therm_sensor& sens)
{
- int severity = 0;
+ int severity = cmnInst.estimateSeverity(sens);
+ if (severity != -1) {
+ LOG(INFO) << "sensor: " << sens.sensor_name <<" temperature: "
+ << sens.t.value << " old: " <<
+ (int)sens.lastThrottleStatus << " new: " <<
+ (int)sens.t.throttlingStatus << std::endl;
+ cb(sens.t);
+ cmnInst.initThreshold(sens);
+ }
+}
+void ThermalUtils::ueventParse(std::string sensor_name, int temp)
+{
LOG(INFO) << "uevent triggered for sensor: " << sensor_name
<< std::endl;
if (thermalConfig.find(sensor_name) == thermalConfig.end()) {
@@ -91,15 +103,7 @@ void ThermalUtils::ueventParse(std::string sensor_name, int temp)
std::lock_guard<std::mutex> _lock(sens_cb_mutex);
struct therm_sensor& sens = thermalConfig[sensor_name];
sens.t.value = (float)temp / (float)sens.mulFactor;
- severity = cmnInst.estimateSeverity(sens);
- if (severity != -1) {
- LOG(INFO) << "sensor: " << sensor_name <<" temperature: "
- << sens.t.value << " old: " <<
- (int)sens.lastThrottleStatus << " new: " <<
- (int)sens.t.throttlingStatus << std::endl;
- cb(sens.t);
- cmnInst.initThreshold(sens);
- }
+ return Notify(sens);
}
int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp)
@@ -110,6 +114,7 @@ int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp)
if (!is_sensor_init)
return 0;
+ std::lock_guard<std::mutex> _lock(sens_cb_mutex);
for (it = thermalConfig.begin(); it != thermalConfig.end();
it++, idx++) {
struct therm_sensor& sens = it->second;
@@ -121,6 +126,7 @@ int ThermalUtils::readTemperatures(hidl_vec<Temperature_1_0>& temp)
ret = cmnInst.read_temperature(sens);
if (ret < 0)
return ret;
+ Notify(sens);
_temp.currentValue = sens.t.value;
_temp.name = sens.t.name;
_temp.type = (TemperatureType_1_0)sens.t.type;
@@ -143,6 +149,7 @@ int ThermalUtils::readTemperatures(bool filterType, TemperatureType type,
int ret = 0;
std::vector<Temperature> _temp;
+ std::lock_guard<std::mutex> _lock(sens_cb_mutex);
for (it = thermalConfig.begin(); it != thermalConfig.end(); it++) {
struct therm_sensor& sens = it->second;
@@ -151,6 +158,7 @@ int ThermalUtils::readTemperatures(bool filterType, TemperatureType type,
ret = cmnInst.read_temperature(sens);
if (ret < 0)
return ret;
+ Notify(sens);
_temp.push_back(sens.t);
}
diff --git a/thermalUtils.h b/thermalUtils.h
index cbf74c2..a02f22f 100644
--- a/thermalUtils.h
+++ b/thermalUtils.h
@@ -80,6 +80,7 @@ class ThermalUtils {
ueventCB cb;
void ueventParse(std::string sensor_name, int temp);
+ void Notify(struct therm_sensor& sens);
};
} // namespace implementation