mirror of
https://github.com/PixelExperience-Devices/device_xiaomi_sm6250-common.git
synced 2025-07-01 15:29:53 +09:00
sm6250-common: Update thermal HAL
* From hardware/google/pixel at d774cbb949e98627e4172bf8fc11e8d954599aa7. Change-Id: I3a3a0c29575d0595e71a30f1e64e33ca34d2eb27
This commit is contained in:
@ -14,11 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef THERMAL_UTILS_CONFIG_PARSER_H__
|
||||
#define THERMAL_UTILS_CONFIG_PARSER_H__
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <android/hardware/thermal/2.0/IThermal.h>
|
||||
|
||||
@ -29,12 +28,73 @@ namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::hidl_enum_range;
|
||||
using ::android::hardware::thermal::V2_0::CoolingType;
|
||||
using CoolingType_2_0 = ::android::hardware::thermal::V2_0::CoolingType;
|
||||
using TemperatureType_2_0 = ::android::hardware::thermal::V2_0::TemperatureType;
|
||||
using ::android::hardware::thermal::V2_0::ThrottlingSeverity;
|
||||
constexpr size_t kThrottlingSeverityCount = std::distance(
|
||||
hidl_enum_range<ThrottlingSeverity>().begin(), hidl_enum_range<ThrottlingSeverity>().end());
|
||||
using ThrottlingArray = std::array<float, static_cast<size_t>(kThrottlingSeverityCount)>;
|
||||
using CdevArray = std::array<int, static_cast<size_t>(kThrottlingSeverityCount)>;
|
||||
constexpr std::chrono::milliseconds kMinPollIntervalMs = std::chrono::milliseconds(2000);
|
||||
constexpr std::chrono::milliseconds kUeventPollTimeoutMs = std::chrono::milliseconds(300000);
|
||||
|
||||
enum FormulaOption : uint32_t {
|
||||
COUNT_THRESHOLD = 0,
|
||||
WEIGHTED_AVG,
|
||||
MAXIMUM,
|
||||
MINIMUM,
|
||||
};
|
||||
|
||||
struct VirtualSensorInfo {
|
||||
std::vector<std::string> linked_sensors;
|
||||
std::vector<float> coefficients;
|
||||
float offset;
|
||||
std::string trigger_sensor;
|
||||
FormulaOption formula;
|
||||
};
|
||||
|
||||
struct VirtualPowerRailInfo {
|
||||
std::vector<std::string> linked_power_rails;
|
||||
std::vector<float> coefficients;
|
||||
float offset;
|
||||
FormulaOption formula;
|
||||
};
|
||||
|
||||
// The method when the ODPM power is lower than threshold
|
||||
enum ReleaseLogic : uint32_t {
|
||||
INCREASE = 0, // Increase throttling by step
|
||||
DECREASE, // Decrease throttling by step
|
||||
STEPWISE, // Support both increase and decrease logix
|
||||
RELEASE_TO_FLOOR, // Release throttling to floor directly
|
||||
NONE,
|
||||
};
|
||||
|
||||
struct BindedCdevInfo {
|
||||
CdevArray limit_info;
|
||||
ThrottlingArray power_thresholds;
|
||||
ReleaseLogic release_logic;
|
||||
ThrottlingArray cdev_weight_for_pid;
|
||||
CdevArray cdev_ceiling;
|
||||
CdevArray cdev_floor_with_power_link;
|
||||
std::string power_rail;
|
||||
// The flag for activate release logic when power is higher than power threshold
|
||||
bool high_power_check;
|
||||
// The flag for only triggering throttling until all power samples are collected
|
||||
bool throttling_with_power_link;
|
||||
};
|
||||
|
||||
struct ThrottlingInfo {
|
||||
ThrottlingArray k_po;
|
||||
ThrottlingArray k_pu;
|
||||
ThrottlingArray k_i;
|
||||
ThrottlingArray k_d;
|
||||
ThrottlingArray i_max;
|
||||
ThrottlingArray max_alloc_power;
|
||||
ThrottlingArray min_alloc_power;
|
||||
ThrottlingArray s_power;
|
||||
ThrottlingArray i_cutoff;
|
||||
std::unordered_map<std::string, BindedCdevInfo> binded_cdev_info_map;
|
||||
};
|
||||
|
||||
struct SensorInfo {
|
||||
TemperatureType_2_0 type;
|
||||
@ -42,19 +102,38 @@ struct SensorInfo {
|
||||
ThrottlingArray cold_thresholds;
|
||||
ThrottlingArray hot_hysteresis;
|
||||
ThrottlingArray cold_hysteresis;
|
||||
std::string temp_path;
|
||||
float vr_threshold;
|
||||
float multiplier;
|
||||
bool is_monitor;
|
||||
std::chrono::milliseconds polling_delay;
|
||||
std::chrono::milliseconds passive_delay;
|
||||
bool send_cb;
|
||||
bool send_powerhint;
|
||||
bool is_monitor;
|
||||
std::unique_ptr<VirtualSensorInfo> virtual_sensor_info;
|
||||
std::unique_ptr<ThrottlingInfo> throttling_info;
|
||||
};
|
||||
|
||||
std::map<std::string, SensorInfo> ParseSensorInfo(std::string_view config_path);
|
||||
std::map<std::string, CoolingType> ParseCoolingDevice(std::string_view config_path);
|
||||
struct CdevInfo {
|
||||
CoolingType_2_0 type;
|
||||
std::string read_path;
|
||||
std::string write_path;
|
||||
std::vector<float> state2power;
|
||||
int max_state;
|
||||
};
|
||||
struct PowerRailInfo {
|
||||
std::string rail;
|
||||
int power_sample_count;
|
||||
std::chrono::milliseconds power_sample_delay;
|
||||
std::unique_ptr<VirtualPowerRailInfo> virtual_power_rail_info;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, SensorInfo> ParseSensorInfo(std::string_view config_path);
|
||||
std::unordered_map<std::string, CdevInfo> ParseCoolingDevice(std::string_view config_path);
|
||||
std::unordered_map<std::string, PowerRailInfo> ParsePowerRailInfo(std::string_view config_path);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace thermal
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // THERMAL_UTILS_CONFIG_PARSER_H__
|
||||
|
Reference in New Issue
Block a user