]> git.saurik.com Git - apple/libc.git/blob - include/libkern/OSThermalNotification.h
9fe603e9cff18248ecc126e34cdba4d493c20bdc
[apple/libc.git] / include / libkern / OSThermalNotification.h
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 #if TARGET_OS_IPHONE
43 typedef enum {
44 kOSThermalPressureLevelNominal = 0,
45 kOSThermalPressureLevelLight = 10,
46 kOSThermalPressureLevelModerate = 20,
47 kOSThermalPressureLevelHeavy = 30,
48 kOSThermalPressureLevelTrapping = 40,
49 kOSThermalPressureLevelSleeping = 50
50 } OSThermalPressureLevel;
51 #else
52 typedef enum {
53 kOSThermalPressureLevelNominal = 0,
54 kOSThermalPressureLevelModerate,
55 kOSThermalPressureLevelHeavy,
56 kOSThermalPressureLevelTrapping,
57 kOSThermalPressureLevelSleeping
58 } OSThermalPressureLevel;
59 #endif
60
61 /*
62 ** External notify(3) string for thermal pressure level notification
63 */
64 __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_7_0)
65 extern const char * const kOSThermalNotificationPressureLevelName;
66
67
68 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
69 __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0
70
71 typedef enum {
72 OSThermalNotificationLevelAny = -1,
73 OSThermalNotificationLevelNormal = 0,
74 } OSThermalNotificationLevel;
75
76 extern OSThermalNotificationLevel _OSThermalNotificationLevelForBehavior(int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
77 extern void _OSThermalNotificationSetLevelForBehavior(int, int) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_4_2);
78
79 enum {
80 kOSThermalMitigationNone,
81 kOSThermalMitigation70PercentTorch,
82 kOSThermalMitigation70PercentBacklight,
83 kOSThermalMitigation50PercentTorch,
84 kOSThermalMitigation50PercentBacklight,
85 kOSThermalMitigationDisableTorch,
86 kOSThermalMitigation25PercentBacklight,
87 kOSThermalMitigationDisableMapsHalo,
88 kOSThermalMitigationAppTerminate,
89 kOSThermalMitigationDeviceRestart,
90 kOSThermalMitigationThermalTableReady,
91 kOSThermalMitigationCount
92 };
93
94 #define OSThermalNotificationLevel70PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentTorch)
95 #define OSThermalNotificationLevel70PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation70PercentBacklight)
96 #define OSThermalNotificationLevel50PercentTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentTorch)
97 #define OSThermalNotificationLevel50PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation50PercentBacklight)
98 #define OSThermalNotificationLevelDisableTorch _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableTorch)
99 #define OSThermalNotificationLevel25PercentBacklight _OSThermalNotificationLevelForBehavior(kOSThermalMitigation25PercentBacklight)
100 #define OSThermalNotificationLevelDisableMapsHalo _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDisableMapsHalo)
101 #define OSThermalNotificationLevelAppTerminate _OSThermalNotificationLevelForBehavior(kOSThermalMitigationAppTerminate)
102 #define OSThermalNotificationLevelDeviceRestart _OSThermalNotificationLevelForBehavior(kOSThermalMitigationDeviceRestart)
103
104 /* Backwards compatibility */
105 #define OSThermalNotificationLevelWarning OSThermalNotificationLevel70PercentBacklight
106 #define OSThermalNotificationLevelUrgent OSThermalNotificationLevelAppTerminate
107 #define OSThermalNotificationLevelCritical OSThermalNotificationLevelDeviceRestart
108
109 /*
110 ** Simple polling interface to detect current thermal level
111 */
112 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
113 extern OSThermalNotificationLevel OSThermalNotificationCurrentLevel(void);
114
115 /*
116 ** External notify(3) string for manual notification setup
117 */
118 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_2_0)
119 extern const char * const kOSThermalNotificationName;
120
121 /*
122 ** External notify(3) string for alerting user of a thermal condition
123 */
124 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
125 extern const char * const kOSThermalNotificationAlert;
126
127 /*
128 ** External notify(3) string for notifying system the options taken to resolve thermal condition
129 */
130 __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_6_0)
131 extern const char * const kOSThermalNotificationDecision;
132
133 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED
134
135 __END_DECLS
136
137 #endif /* _OSTHERMALNOTIFICATION_H_ */