From be2ed11266296db3c486642a22db9326c67fdc70 Mon Sep 17 00:00:00 2001 From: Miguel de Dios Date: Wed, 7 Mar 2018 17:21:45 -0800 Subject: [PATCH] Expose USB-C thermistor in ThermalHAL for Wahoo. Expose USB-C to calls to getTemperatures() in ThermalHAL for wahoo. Bug: 67749183 Test: VtsHalThermalV1_0TargetTest pass Change-Id: Ic45dea1c990e0c71a6ac621145b93cb0f7aa9519 (cherry picked from commit 51872d4950d3ce0ce66ff6ea9c3bd81301b53ad8) --- thermal/thermal-helper.cpp | 12 ++++++++++++ thermal/thermal-helper.h | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/thermal/thermal-helper.cpp b/thermal/thermal-helper.cpp index 878c82f5..163f0fd0 100644 --- a/thermal/thermal-helper.cpp +++ b/thermal/thermal-helper.cpp @@ -200,6 +200,18 @@ ssize_t fillTemperatures(hidl_vec *temperatures) { } current_index++; } + + // USB-C temperature. + if (current_index < temperatures->size()) { + // temperature in Celsius. + result = readTemperature( + kUsbcSensorNum, TemperatureType::UNKNOWN, kUsbcLabel, 0.1, NAN, NAN, + NAN, &(*temperatures)[current_index]); + if (result < 0) { + return result; + } + current_index++; + } return kTemperatureNum; } diff --git a/thermal/thermal-helper.h b/thermal/thermal-helper.h index 311a67d8..3b86efe2 100644 --- a/thermal/thermal-helper.h +++ b/thermal/thermal-helper.h @@ -69,17 +69,19 @@ constexpr unsigned int kTaimenRcVrThrottledBelowMin = 50; constexpr unsigned int kBatterySensorNum = 0; +constexpr unsigned int kUsbcSensorNum = 5; constexpr unsigned int kGpuTsensOffset = 11; constexpr unsigned int kCpuNum = 8; constexpr const char *kGpuLabel = "GPU"; constexpr const char *kBatteryLabel = "battery"; constexpr const char *kSkinLabel = "skin"; +constexpr const char *kUsbcLabel = "usbc"; constexpr const char *kCpuLabel[kCpuNum] = {"CPU0", "CPU1", "CPU2", "CPU3", "CPU4", "CPU5", "CPU6", "CPU7"}; constexpr int kCpuTsensOffset[kCpuNum] = {1, 2, 4, 3, 5, 6, 7, 8}; -// Sum of kCpuNum + 3 for GPU, BATTERY, and SKIN. -constexpr unsigned int kTemperatureNum = 3 + kCpuNum; +// Sum of kCpuNum + 4 for GPU, BATTERY, SKIN, and USB-C. +constexpr unsigned int kTemperatureNum = 4 + kCpuNum; // qcom, therm-reset-temp constexpr unsigned int kCpuShutdownThreshold = 115;