device: Change profile version from header files
[platform/core/api/device.git] / include / power.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
18 #ifndef __TIZEN_SYSTEM_POWER_H__
19 #define __TIZEN_SYSTEM_POWER_H__
20
21
22 #include <stdbool.h>
23 #include "device-error.h"
24
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30
31 /**
32  * @addtogroup CAPI_SYSTEM_DEVICE_POWER_MODULE
33  * @{
34  */
35
36
37 /**
38  * @brief Enumeration for lock type.
39  * @details Each enum ensures that the suitable device is on until all the lock requests have been released or after a timeout.
40  * <TABLE>
41  * <TR><TH>Enum Type</TH><TH>CPU</TH><TH>Brightness(Display)</TH></TR>
42  * <TR><TD>POWER_LOCK_CPU</TD><TD>ON</TD><TD>OFF</TD></TR>
43  * <TR><TD>POWER_LOCK_DISPLAY</TD><TD>ON</TD><TD>ON(Normal)</TD></TR>
44  * <TR><TD>POWER_LOCK_DISPLAY_DIM</TD><TD>ON</TD><TD>ON(Dim)</TD></TR>
45  * </TABLE>
46  * @since_tizen 2.3
47  * @remarks An application can lock the specific type.
48  * @remarks These enums are mutually exclusive.
49  * @remarks You cannot combine with an enum below.
50  * @remarks #POWER_LOCK_DISPLAY_DIM may be ignored if the DIM state is disabled on the platform.
51  */
52 typedef enum {
53     POWER_LOCK_CPU, /**< CPU lock */
54     POWER_LOCK_DISPLAY, /**< Display normal lock */
55     POWER_LOCK_DISPLAY_DIM, /**< Display dim lock */
56 } power_lock_e;
57
58
59 /**
60  * @brief Locks the given lock state for a specified time.
61  * @details After the given @a timeout_ms (in milliseconds), unlock the given lock state automatically.
62  * @since_tizen 2.3
63  * @privlevel public
64  * @privilege %http://tizen.org/privilege/display
65  * @remarks If the process dies, then every lock will be removed.
66  * @param[in] type The power type to request lock
67  * @param[in] timeout_ms The positive number in milliseconds or @c 0 for permanent lock \n
68  *                       So you must release the permanent lock of power state with #device_power_release_lock() if @a timeout_ms is zero
69  * @return @c 0 on success,
70  *         otherwise a negative error value
71  * @retval #DEVICE_ERROR_NONE Successful
72  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
73  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
74  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
75  * @see device_power_release_lock()
76  */
77 int device_power_request_lock(power_lock_e type, int timeout_ms);
78
79
80 /**
81  * @brief Releases the given lock state which was locked before.
82  * @since_tizen 2.3
83  * @privlevel public
84  * @privilege %http://tizen.org/privilege/display
85  * @param[in] type The power type to release lock
86  * @return @c 0 on success,
87  *         otherwise a negative error value
88  * @retval #DEVICE_ERROR_NONE Successful
89  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
90  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
91  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
92  * @see device_power_request_lock()
93  */
94 int device_power_release_lock(power_lock_e type);
95
96
97 /**
98  * @deprecated Deprecated Since 2.4
99  * @brief Changes the current power state to the normal/dim state.
100  * @since_tizen 2.3
101  * @privlevel public
102  * @privilege %http://tizen.org/privilege/display
103  * @remarks This API triggers turn on process and then updates the status when it completes. While the operation is on-going, the device_display_get_state() function returns previous display state.
104  * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display.state.
105  * @param[in] dim Set @c true to set the dim state,
106  *                otherwise set @c false to not set the dim state
107  * @return @c 0 on success,
108  *         otherwise a negative error value
109  * @retval #DEVICE_ERROR_NONE Successful
110  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
111  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
112  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
113  * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
114  * @post The device will be in #DISPLAY_STATE_NORMAL state.
115  */
116 int device_power_wakeup(bool dim) TIZEN_DEPRECATED_API;
117
118
119 /**
120  * @platform
121  * @brief Reboots the device.
122  * @details Will not return if the reboot is successful. \n
123  *          It operates asynchronously.
124  * @since_tizen 2.3.1
125  * @privlevel platform
126  * @privilege %http://tizen.org/privilege/reboot
127  * @param[in] reason Pass to the platform and kernel to request special reboot reason, or null
128  * @return @c 0 on success,
129  *         otherwise a negative error value
130  * @retval #DEVICE_ERROR_NONE Successful
131  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
132  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
133  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
134  */
135 int device_power_reboot(const char *reason);
136
137
138 /**
139  * @}
140  */
141
142
143 #ifdef __cplusplus
144 }
145 #endif
146
147
148 #endif  // __TIZEN_SYSTEM_POWER_H__