1 /*
2  * Copyright (C) 2019 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 HARDWARE_GOOGLE_CAMERA_HAL_COMMON_THERMAL_TYPES_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_COMMON_THERMAL_TYPES_H_
19 
20 #include <utils/Errors.h>
21 
22 #include <cstdint>
23 #include <functional>
24 #include <string>
25 
26 namespace android {
27 namespace google_camera_hal {
28 
29 // See the definition of
30 // ::android::hardware::thermal::V2_0::TemperatureType
31 enum class TemperatureType : int32_t {
32   kUnknown = -1,
33   kCpu = 0,
34   kGpu = 1,
35   kBattery = 2,
36   kSkin = 3,
37   kUsbPort = 4,
38   kPowerAmplifier = 5,
39   kBclVoltage = 6,
40   kBclCurrent = 7,
41   kBclPercentage = 8,
42   kNpu = 9,
43 };
44 
45 // See the definition of
46 // ::android::hardware::thermal::V2_0::ThrottlingSeverity
47 enum class ThrottlingSeverity : uint32_t {
48   kNone = 0,
49   kLight,
50   kModerate,
51   kSevere,
52   kCritical,
53   kEmergency,
54   kShutdown,
55 };
56 
57 // See the definition of
58 // ::android::hardware::thermal::V2_0::Temperature
59 struct Temperature {
60   TemperatureType type = TemperatureType::kUnknown;
61   std::string name;
62   float value = 0.0f;
63   ThrottlingSeverity throttling_status = ThrottlingSeverity::kNone;
64 };
65 
66 // Function to invoke when thermal status changes.
67 using NotifyThrottlingFunc =
68     std::function<void(const Temperature& /*temperature*/)>;
69 
70 // Callback to register a thermal throttling notify function.
71 // If filter_type is true, type will be used. If filter_type is false,
72 // type will be ignored and all types will be notified.
73 using RegisterThermalChangedCallbackFunc =
74     std::function<status_t(NotifyThrottlingFunc /*notify_throttling*/,
75                            bool /*filter_type*/, TemperatureType /*type*/)>;
76 
77 // Unregister the thermal callback.
78 using UnregisterThermalChangedCallbackFunc = std::function<void()>;
79 
80 }  // namespace google_camera_hal
81 }  // namespace android
82 
83 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_COMMON_THERMAL_TYPES_H_
84