xref: /trueos/include/libkern/OSThermalNotification.h (revision 0f8eb4123024ffec2f2cfcdb493793aea43f0cac)
1 /*
2  * Copyright (c) 2007 Apple Inc. All rights reserved.
3  *
4  * @APPLE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. Please obtain a copy of the License at
10  * http://www.opensource.apple.com/apsl/ and read it before using this
11  * file.
12  *
13  * The Original Code and all software distributed under the License are
14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18  * Please see the License for the specific language governing rights and
19  * limitations under the License.
20  *
21  * @APPLE_LICENSE_HEADER_END@
22  */
23 
24 #ifndef _OSTHERMALNOTIFICATION_H_
25 #define _OSTHERMALNOTIFICATION_H_
26 
27 #include <sys/cdefs.h>
28 #include <Availability.h>
29 
30 /*
31 **  OSThermalNotification.h
32 **
33 **  Notification mechanism to alert registered tasks when device thermal conditions
34 **  reach certain thresholds. Notifications are triggered in both directions
35 **  so clients can manage their memory usage more and less aggressively.
36 **
37 */
38 
39 __BEGIN_DECLS
40 
41 /* Define pressure levels usable by OSThermalPressureLevel */
42 typedef enum {
43 	kOSThermalPressureLevelNominal = 0,
44 	kOSThermalPressureLevelModerate,
45 	kOSThermalPressureLevelHeavy,
46 	kOSThermalPressureLevelTrapping,
47 	kOSThermalPressureLevelSleeping
48 } OSThermalPressureLevel;
49 
50 /*
51  ** External notify(3) string for thermal pressure level notification
52  */
53 __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0)
54 extern const char * const kOSThermalNotificationPressureLevelName;
55 
56 
57 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
58 	__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0
59 
60 typedef enum {
61 	OSThermalNotificationLevelAny      = -1,
62 	OSThermalNotificationLevelNormal   =  0,
63 } OSThermalNotificationLevel;
64 
65 extern OSThermalNotificationLevel _OSThermalNotificationLevelForBehavior(int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
66 extern void _OSThermalNotificationSetLevelForBehavior(int, int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
67 
68 enum {
69 	kOSThermalMitigationNone,
70 	kOSThermalMitigation70PercentTorch,
71 	kOSThermalMitigation70PercentBacklight,
72 	kOSThermalMitigation50PercentTorch,
73 	kOSThermalMitigation50PercentBacklight,
74 	kOSThermalMitigationDisableTorch,
75 	kOSThermalMitigation25PercentBacklight,
76 	kOSThermalMitigationDisableMapsHalo,
77 	kOSThermalMitigationAppTerminate,
78 	kOSThermalMitigationDeviceRestart,
79 	kOSThermalMitigationThermalTableReady,
80 	kOSThermalMitigationCount
81 };
82 
83 #define OSThermalNotificationLevel70PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentTorch)
84 #define OSThermalNotificationLevel70PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentBacklight)
85 #define OSThermalNotificationLevel50PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentTorch)
86 #define OSThermalNotificationLevel50PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentBacklight)
87 #define OSThermalNotificationLevelDisableTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableTorch)
88 #define OSThermalNotificationLevel25PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation25PercentBacklight)
89 #define OSThermalNotificationLevelDisableMapsHalo _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableMapsHalo)
90 #define OSThermalNotificationLevelAppTerminate _OSThermalNotificationLevelForBehavior(kOSThermalMitigationAppTerminate)
91 #define OSThermalNotificationLevelDeviceRestart _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDeviceRestart)
92 
93 /* Backwards compatibility */
94 #define OSThermalNotificationLevelWarning OSThermalNotificationLevel70PercentBacklight
95 #define OSThermalNotificationLevelUrgent OSThermalNotificationLevelAppTerminate
96 #define OSThermalNotificationLevelCritical OSThermalNotificationLevelDeviceRestart
97 
98 /*
99 ** Simple polling interface to detect current thermal level
100 */
101 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
102 extern OSThermalNotificationLevel OSThermalNotificationCurrentLevel(void);
103 
104 /*
105 ** External notify(3) string for manual notification setup
106 */
107 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
108 extern const char * const kOSThermalNotificationName;
109 
110 /*
111 ** External notify(3) string for alerting user of a thermal condition
112 */
113 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
114 extern const char * const kOSThermalNotificationAlert;
115 
116 /*
117 ** External notify(3) string for notifying system the options taken to resolve thermal condition
118 */
119 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
120 extern const char * const kOSThermalNotificationDecision;
121 
122 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED
123 
124 __END_DECLS
125 
126 #endif /* _OSTHERMALNOTIFICATION_H_ */
127