1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef THERMAL_UTILS_CONFIG_PARSER_H__
18 #define THERMAL_UTILS_CONFIG_PARSER_H__
19 
20 #include <map>
21 #include <string>
22 
23 #include <android/hardware/thermal/2.0/IThermal.h>
24 
25 namespace android {
26 namespace hardware {
27 namespace thermal {
28 namespace V2_0 {
29 namespace implementation {
30 
31 using ::android::hardware::hidl_enum_range;
32 using ::android::hardware::thermal::V2_0::CoolingType;
33 using TemperatureType_2_0 = ::android::hardware::thermal::V2_0::TemperatureType;
34 using ::android::hardware::thermal::V2_0::ThrottlingSeverity;
35 constexpr size_t kThrottlingSeverityCount = std::distance(
36     hidl_enum_range<ThrottlingSeverity>().begin(), hidl_enum_range<ThrottlingSeverity>().end());
37 using ThrottlingArray = std::array<float, static_cast<size_t>(kThrottlingSeverityCount)>;
38 
39 struct SensorInfo {
40     TemperatureType_2_0 type;
41     ThrottlingArray hot_thresholds;
42     ThrottlingArray cold_thresholds;
43     ThrottlingArray hot_hysteresis;
44     ThrottlingArray cold_hysteresis;
45     float vr_threshold;
46     float multiplier;
47     bool is_monitor;
48 };
49 
50 std::map<std::string, SensorInfo> ParseSensorInfo(std::string_view config_path);
51 std::map<std::string, CoolingType> ParseCoolingDevice(std::string_view config_path);
52 
53 }  // namespace implementation
54 }  // namespace V2_0
55 }  // namespace thermal
56 }  // namespace hardware
57 }  // namespace android
58 
59 #endif  // THERMAL_UTILS_CONFIG_PARSER_H__
60