2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #ifndef __TIZEN_SYSTEM_POWER_H__
22 #define __TIZEN_SYSTEM_POWER_H__
34 * @addtogroup CAPI_SYSTEM_POWER_MODULE
37 * This is a Power API of the System Service.
42 * @addtogroup CAPI_SYSTEM_POWER_MODULE
48 * @brief Enumerations of available power states.
49 * @details An application cannot put the device into the power off state or the suspend state.
53 POWER_STATE_NORMAL, /**< Normal state */
54 POWER_STATE_SCREEN_DIM, /**< Screen dim state */
55 POWER_STATE_SCREEN_OFF, /**< Screen off state */
60 * @brief Enumerations of error code for Power.
64 POWER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
65 POWER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
66 POWER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
76 * @addtogroup CAPI_SYSTEM_POWER_MODULE
81 * @brief Called when an power state changed
83 * @param[in] state The state of power
84 * @param[in] user_data The user data passed from the callback registration function
87 typedef void (*power_changed_cb)(power_state_e state, void *user_data);
90 * @brief Locks the given power state for a specified time.
92 * @details After the given @a timeout_ms (in milliseconds), unlock the given power state automatically.
93 * #SYSTEM_INFO_KEY_POWER_STATE key and associated system information function can give inform about the current state.
95 * @remarks If the process dies, every lock will be removed.
97 * @param[in] power_state The power state to lock
98 * @param[in] timeout_ms The positive number in milliseconds or 0 for permanent lock \n
99 * So you must release the permanent lock of power state with #power_unlock_state() if @a timeout_ms is zero. \n
101 * @return 0 on success, otherwise a negative error value.
102 * @retval #POWER_ERROR_NONE Successful
103 * @retval #POWER_ERROR_INVALID_PARAMETER Invalid parameter
104 * @retval #POWER_ERROR_IO_ERROR I/O error
106 * @see power_unlock_state()
107 * @see system_info_set_changed_cb()
108 * @see system_info_get_value_int(SYSTEM_INFO_KEY_POWER_STATE, ...)
110 int power_lock_state(power_state_e power_state, int timeout_ms);
114 * @brief Releases the given power state locked before.
115 * @param[in] power_state The power state to release
117 * @return 0 on success, otherwise a negative error value.
118 * @retval #POWER_ERROR_NONE Successful
119 * @retval #POWER_ERROR_INVALID_PARAMETER Invalid parameter
120 * @retval #POWER_ERROR_IO_ERROR I/O error
122 * @see power_lock_state()
124 int power_unlock_state(power_state_e power_state);
128 * @brief Changes the current power state to the normal/dim state.
130 * @param[in] dim Determine to go to dim state.
132 * @return 0 on success, otherwise a negative error value.
133 * @retval #POWER_ERROR_NONE Successful
134 * @retval #POWER_ERROR_IO_ERROR I/O error
136 * @post The device will be in #POWER_STATE_NORMAL state.
139 int power_wakeup(bool dim);
142 * @brief Get the current power state.
144 * @return power state enum, otherwise a negative error value.
145 * @retval #POWER_ERROR_NONE Successful
146 * @retval #POWER_ERROR_IO_ERROR I/O error
148 power_state_e power_get_state(void);
151 * @brief Set the callback for getting power changed event.
153 * @param[in] power_changed_cb The power state changed callback function pointer
154 * @param[in] user_data The user data to be passed to the callback function
156 * @return 0 on success, otherwise a negative error value.
157 * @retval #POWER_ERROR_NONE Successful
158 * @retval #POWER_ERROR_INVALID_PARAMETER Invalid parameter
159 * @retval #POWER_ERROR_IO_ERROR I/O error
161 int power_set_changed_cb(power_changed_cb callback, void* user_data);
164 * @brief Unset the callback for getting power changed event.
166 * @return 0 on success, otherwise a negative error value.
167 * @retval #POWER_ERROR_NONE Successful
168 * @retval #POWER_ERROR_IO_ERROR I/O error
170 int power_unset_changed_cb(void);
180 #endif /* __TIZEN_SYSTEM_POWER_H__*/