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.
20 #ifndef __TIZEN_SYSTEM_DEVICE_H__
21 #define __TIZEN_SYSTEM_DEVICE_H__
24 #include "device-error.h"
32 * @addtogroup CAPI_SYSTEM_DEVICE_MODULE
37 * @brief Enumerations of the battery warning status
41 DEVICE_BATTERY_WARN_EMPTY, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */
42 DEVICE_BATTERY_WARN_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */
43 DEVICE_BATTERY_WARN_LOW, /**< The battery has little charge left. */
44 DEVICE_BATTERY_WARN_NORMAL, /**< The battery status is not to be careful. */
45 DEVICE_BATTERY_WARN_FULL, /**< The battery status is full. */
46 } device_battery_warn_e;
49 * @brief Enumerations of the battery remaining time type
53 DEVICE_BATTERY_REMAINING_TIME_TO_FULLY_CHARGED,
54 DEVICE_BATTERY_REMAINING_TIME_TO_DISCHARGED
55 } device_battery_remaining_time_type_e;
58 * @brief Enumerations of the battery level status
62 DEVICE_BATTERY_LEVEL_EMPTY = 0, /**< The battery goes empty. Prepare for the safe termination of the application, because the device starts a shutdown process soon after entering this level. */
63 DEVICE_BATTERY_LEVEL_CRITICAL, /**< The battery charge is at a critical state. You may have to stop using multimedia features, because they are not guaranteed to work correctly at this battery status. */
64 DEVICE_BATTERY_LEVEL_LOW, /**< The battery has little charge left. */
65 DEVICE_BATTERY_LEVEL_HIGH, /**< The battery status is not to be careful. */
66 DEVICE_BATTERY_LEVEL_FULL, /**< The battery status is full. */
67 } device_battery_level_e;
71 * @brief Structure of the time information system spent, measured in units of USER_HZ
74 unsigned long long total;
75 unsigned long long user;
76 unsigned long long nice;
77 unsigned long long system;
78 unsigned long long idle;
79 unsigned long long iowait;
80 unsigned long long irq;
81 unsigned long long softirq;
82 } device_system_time_s;
89 * @addtogroup CAPI_SYSTEM_DEVICE_MODULE
94 * @brief Called when an battery charge percentage changed
96 * @param[in] percent The remaining battery charge percentage (0 ~ 100)
97 * @param[in] user_data The user data passed from the callback registration function
100 typedef void (*device_battery_cb)(int percent, void *user_data);
103 * @brief Called when the device warn about the battery status.
105 * @param[in] status The battery warning status
106 * @param[in] user_data The user data passed from the callback registration function
109 typedef void (*device_battery_warn_cb)(device_battery_warn_e status, void *user_data);
112 * @brief This callback take remained time for fully charged or discharged.
114 * @param[in] time The battery remainig seconds to fully chagred or discharged
115 * @param[in] user_data The user data passed from the callback registration function
118 typedef void (*device_battery_remaining_time_changed_cb)(int time, void* user_data);
121 * @brief Called when an battery level changed
123 * @param[in] status The remaining battery level (empty[0~1] critical[2~5] low[6~15] high[16~94] full[95~100])
124 * @param[in] user_data The user data passed from the callback registration function
127 typedef void (*device_battery_level_cb)(device_battery_level_e status, void *user_data);
130 * @brief Gets the battery warning status.
132 * @param[out] status The battery warning status.
133 * @return 0 on success, otherwise a negative error value.
134 * @retval #DEVICE_ERROR_NONE Successful
135 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
136 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
138 * @see device_battery_status_e
139 * @see device_battery_status_set_cb()
141 int device_battery_get_warning_status(device_battery_warn_e *status);
144 * @brief Set callback to be observing battery warning.
146 * @param[in] callback The callback function to set
147 * @param[in] user_data The user data to be passed to the callback function
149 * @return 0 on success, otherwise a negative error value.
150 * @retval #DEVICE_ERROR_NONE Successful
151 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
152 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
154 * @see device_battery_status_e
155 * @see device_battery_get_status()
157 int device_battery_warning_set_cb(device_battery_warn_cb callback, void* user_data);
160 * @brief Unset battery warning callback function.
162 * @return 0 on success, otherwise a negative error value.
163 * @retval #DEVICE_ERROR_NONE Successful
164 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
166 int device_battery_warning_unset_cb(void);
169 * @brief Gets the battery charge percentage.
170 * @details It returns integer value from 0 to 100 that indicates remaining battery charge
171 * as a percentage of the maximum level.
172 * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
174 * @param[out] percent The remaining battery charge percentage (0 ~ 100)
176 * @return 0 on success, otherwise a negative error value.
177 * @retval #DEVICE_ERROR_NONE Successful
178 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
179 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
181 * @see device_battery_is_full()
182 * @see device_battery_get_detail()
183 * @see device_battery_set_cb()
185 int device_battery_get_percent(int *percent);
188 * @brief Gets the battery detail charge as a per ten thousand.
189 * @details It return integer value from 0 to 10000 that indicates remaining battery charge as a per ten thousand of the maximum level.
190 * @remarks this function return #DEVICE_ERROR_NOT_SUPPORTED when device can not be supported detail battery information.
192 * @param[out] detail The remaining battery charge as a per ten thousand. (0 ~ 10000)
194 * @return 0 on success, otherwise a negative error value.
195 * @retval #DEVICE_ERROR_NONE Successful
196 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
197 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
198 * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
200 * @see device_battery_is_full()
201 * @see device_battery_get_percent()
202 * @see device_battery_set_cb()
204 int device_battery_get_detail(int *detail);
207 * @brief Get charging state
209 * @param[out] charging The battery charging state.
211 * @return 0 on success, otherwise a negative error value.
212 * @retval #DEVICE_ERROR_NONE Successful
213 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
214 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
217 int device_battery_is_charging(bool *charging);
220 * @brief Set callback to be observing battery charge percentage.
222 * @param[in] callback The callback function to set
223 * @param[in] user_data The user data to be passed to the callback function
225 * @return 0 on success, otherwise a negative error value.
226 * @retval #DEVICE_ERROR_NONE Successful
227 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
228 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
230 int device_battery_set_cb(device_battery_cb callback, void* user_data);
233 * @brief Unset battery charge percentage callback function.
235 * @return 0 on success, otherwise a negative error value.
236 * @retval #DEVICE_ERROR_NONE Successful
237 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
239 int device_battery_unset_cb(void);
242 * @brief Checks whether the battery is fully charged.
243 * @remarks In order to be notified when the battery state changes, use system_info_set_changed_cb().
245 * @param[out] full @c true when the battery is fully charged, otherwise @c false.
247 * @return 0 on success, otherwise a negative error value.
248 * @retval #DEVICE_ERROR_NONE Successful
249 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
250 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
252 * @see device_battery_get_percent()
253 * @see system_info_set_changed_cb()
254 * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_PERCENTAGE, ...)
255 * @see system_info_get_value_int(SYSTEM_INFO_KEY_BATTERY_CHARGE, ...)
257 int device_battery_is_full(bool *full);
260 * @brief Retrive the remaining time for fully charged or discharged.
262 * @remark @a time will be retrieved the time to fully charged or discharged depending on @a type
264 * @param[in] type The type of battery remaining time
265 * @param[out] time battery remainig seconds to fully chagred or discharged
267 * @return 0 on success, otherwise a negative error value.
268 * @retval #DEVICE_ERROR_NONE Successful
269 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
270 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
272 * @see device_battery_set_remaining_time_changed_cb()
273 * @see device_battery_unset_remaining_time_changed_cb()
275 int device_battery_get_remaining_time(device_battery_remaining_time_type_e type, int* time);
278 * @brief Set callback to be return battery remaining time to fully charged or discharged.
280 * @remark @a callback will be retrieved the time to fully charged or discharged depending on @a type
282 * @param[in] callback The callback function to set
283 * @param[in] user_data The user data to be passed to the callback function
285 * @return 0 on success, otherwise a negative error value.
286 * @retval #DEVICE_ERROR_NONE Successful
287 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
288 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
291 int device_battery_set_remaining_time_changed_cb(
292 device_battery_remaining_time_type_e type,
293 device_battery_remaining_time_changed_cb callback, void* user_data);
296 * @brief Unset battery remaining time callback function.
298 * @param[in] type The type of battery remainig time
300 * @return 0 on success, otherwise a negative error value.
301 * @retval #DEVICE_ERROR_NONE Successful
302 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
304 int device_battery_unset_remaining_time_changed_cb(device_battery_remaining_time_type_e type);
307 * @brief Gets the battery level status.
309 * @param[out] status The battery level status.
310 * @return 0 on success, otherwise a negative error value.
311 * @retval #DEVICE_ERROR_NONE Successful
312 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
313 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
315 * @see device_battery_level_e
316 * @see device_battery_level_set_cb()
318 int device_battery_get_level_status(device_battery_level_e *status);
321 * @brief Set/Unset callback to be observing battery level.
323 * @param[in] callback The callback function to set, if you input NULL, observing is disabled
324 * @param[in] user_data The user data to be passed to the callback function
326 * @return 0 on success, otherwise a negative error value.
327 * @retval #DEVICE_ERROR_NONE Successful
328 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
330 * @see device_battery_level_e
331 * @see device_battery_get_level_status()
333 int device_battery_level_set_cb(device_battery_level_cb callback, void* user_data);
336 * @brief Gets the number of display devices.
338 * @return The number of display devices that the device provides.
339 * @retval #DEVICE_ERROR_NONE Successful
340 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
342 * @see device_get_brightness()
343 * @see device_set_brightness()
344 * @see device_get_max_brightness()
345 * @see device_set_brightness_from_settings()
346 * @see device_set_brightness_to_settings()
348 int device_get_display_numbers(int* device_number);
351 * @brief Gets the display brightness value.
353 * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
354 * the number of displays returned by device_get_display_numbers().\n
355 * The index zero is always assigned to the main display.
356 * @param[out] brightness The current brightness value of the display
358 * @return 0 on success, otherwise a negative error value.
359 * @retval #DEVICE_ERROR_NONE Successful
360 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
361 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
363 * @see device_get_display_numbers()
364 * @see device_set_brightness()
365 * @see device_get_max_brightness()
366 * @see device_set_brightness_from_settings()
367 * @see device_set_brightness_to_settings()
369 int device_get_brightness(int display_index, int *brightness);
372 * @brief Sets the display brightness value.
374 * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
375 * the number of displays returned by device_get_display_numbers().\n
376 * The index zero is always assigned to the main display.
377 * @param[in] brightness The new brightness value to set \n
378 * The maximum value can be represented by device_get_max_brightness()
380 * @return 0 on success, otherwise a negative error value.
381 * @retval #DEVICE_ERROR_NONE Successful
382 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
383 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
385 * @see device_get_display_numbers()
386 * @see device_get_max_brightness()
387 * @see device_get_brightness()
388 * @see device_set_brightness_from_settings()
389 * @see device_set_brightness_to_settings()
391 int device_set_brightness(int display_index, int brightness);
394 * @brief Gets the maximum brightness value that can be set.
396 * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
397 * the number of displays returned by device_get_display_numbers().\n
398 * The index zero is always assigned to the main display.
399 * @param[out] max_brightness The maximum brightness value of the display
401 * @return 0 on success, otherwise a negative error value.
402 * @retval #DEVICE_ERROR_NONE Successful
403 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
404 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
406 * @see device_get_display_numbers()
407 * @see device_set_brightness()
408 * @see device_get_brightness()
409 * @see device_set_brightness_from_settings()
410 * @see device_set_brightness_to_settings()
412 int device_get_max_brightness(int display_index, int *max_brightness);
415 * @brief Sets the display brightness value from registed in settings.
418 * This function set display brightness to condition in the settings.
419 * if auto brightness option is enabled in setting, display's brightness will be changed automatically.
421 * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
422 * the number of displays returned by device_get_display_numbers().\n
423 * The index zero is always assigned to the main display.
425 * @return 0 on success, otherwise a negative error value.
426 * @retval #DEVICE_ERROR_NONE Successful
427 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
428 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
430 * @see device_get_display_numbers()
431 * @see device_get_max_brightness()
432 * @see device_set_brightness()
433 * @see device_get_brightness()
434 * @see device_set_brightness_to_settings()
436 int device_set_brightness_from_settings(int display_index);
439 * @brief Sets the display brightness value to specific display and set to variable in settings.
442 * This function set given brightness value to given index of display.
443 * And also brightness variable in settings will be changed to given brightness value too.
445 * @param[in] display_index The index of the display, it be greater than or equal to 0 and less than \n
446 * the number of displays returned by device_get_display_numbers().\n
447 * The index zero is always assigned to the main display.
448 * @param[in] brightness The new brightness value to set \n
449 * The maximum value can be represented by device_get_max_brightness()
451 * @return 0 on success, otherwise a negative error value.
452 * @retval #DEVICE_ERROR_NONE Successful
453 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
454 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
456 * @see device_get_display_numbers()
457 * @see device_get_max_brightness()
458 * @see device_set_brightness()
459 * @see device_get_brightness()
460 * @see device_set_brightness_from_settings()
462 int device_set_brightness_to_settings(int display_index, int brightness);
465 * @brief Get brightness value of LED that placed to camera flash.
467 * @param[out] brightness brightness value of LED (0 ~ MAX)
469 * @return 0 on success, otherwise a negative error value.
470 * @retval #DEVICE_ERROR_NONE Successful
471 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
472 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
474 int device_flash_get_brightness(int *brightness);
477 * @brief Set brightness value of LED that placed to camera flash.
479 * @param[in] brightness brightness value of LED (0 ~ MAX)
481 * @return 0 on success, otherwise a negative error value.
482 * @retval #DEVICE_ERROR_NONE Successful
483 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
484 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
486 int device_flash_set_brightness(int brightness);
489 * @brief Get max brightness value of LED that placed to camera flash.
492 * Brightness control does not support yet. so this functioon always return 1. \n
493 * Set function can only use to switch on/off the flash. \n
494 * Get function can only use to retrive on/off state of flash.
496 * @param[out] max_brightness max brightness value of LED
498 * @return 0 on success, otherwise a negative error value.
499 * @retval #DEVICE_ERROR_NONE Successful
500 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
501 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
503 int device_flash_get_max_brightness(int *max_brightness);
506 * @brief Get total amount of physical RAM, in kilobytes
510 * @param[out] total_mem total amount of physical RAM
512 * @return 0 on success, otherwise a negative error value.
513 * @retval #DEVICE_ERROR_NONE Successful
514 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
515 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
517 int device_memory_get_total(unsigned int *total_mem);
520 * @brief Get available amount of physical RAM, in kilobytes
523 * Available amount is defined by following formula currently.
524 * available mem = MemFree+Buffers+Cached+SwapCached-Shmem
526 * @param[out] avail_mem available amount of physical RAM
528 * @return 0 on success, otherwise a negative error value.
529 * @retval #DEVICE_ERROR_NONE Successful
530 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
531 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
533 int device_memory_get_available(unsigned int *avail_mem);
536 * @brief Get time information the CPU has spent performing work.
539 * Time units are in USER_HZ (typically hundredths of a second).
541 * @param[out] time structure of time information the CPU has spent
543 * @return 0 on success, otherwise a negative error value.
544 * @retval #DEVICE_ERROR_NONE Successful
545 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
546 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
548 int device_cpu_get_system_time(device_system_time_s *time);
551 * @brief Get all of CPU count
555 * @param[out] cpu_cnt total count of CPU
557 * @return 0 on success, otherwise a negative error value.
558 * @retval #DEVICE_ERROR_NONE Successful
559 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
560 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
562 int device_cpu_get_count(int *cpu_cnt);
565 * @brief Get currently frequency of CPU
569 * @param[in] cpu the index of CPU which want to know
570 * @param[out] cur_freq currently frequency value of CPU
572 * @return 0 on success, otherwise a negative error value.
573 * @retval #DEVICE_ERROR_NONE Successful
574 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
575 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
577 int device_cpu_get_current_freq(int cpu, unsigned int *cur_freq);
580 * @brief Get max frequency of CPU
584 * @param[in] cpu the index of CPU which want to know
585 * @param[out] max_freq max frequency value of CPU
587 * @return 0 on success, otherwise a negative error value.
588 * @retval #DEVICE_ERROR_NONE Successful
589 * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
590 * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
592 int device_cpu_get_max_freq(int cpu, unsigned int *max_freq);
602 #endif // __TIZEN_SYSTEM_DEVICE_H__