2.0 alpha
[platform/core/system/devman.git] / include / devman.h
1 /*
2  *  devman
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: DongGi Jang <dg0402.jang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20 */
21
22
23 #ifndef __DEVMAN_H__
24 #define __DEVMAN_H__
25
26 #ifndef DEPRECATED
27 #define DEPRECATED __attribute__((deprecated))
28 #endif
29
30 #include "devman_error.h"
31 /** START: This code related to the opensource api will be removed */
32 #include "devman_managed.h"
33 /** END: Will be remved */
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /**
40  * @file        devman.h
41  * @ingroup     DEVICE_MANAGER
42  * @brief       This file contains the API for the status of devices
43  * @author      SLP2.0
44  * @date        2010-01-24
45  * @version     0.1
46  */
47
48 /**
49  * @defgroup DEVICE_MANAGER             Device Manager
50  * @ingroup SYSTEM_FRAMEWORK
51  * @brief Device Manager library
52  *
53  * Device manager provides APIs to control devices or to get the status of devices.
54  * <br> Use devman.pc and include devman.h and devman_haptic.h files
55  *
56  * @addtogroup DEVICE_MANAGER
57  * @{
58  */
59
60 /**
61  * @par Description:
62  *      device type enum
63  */
64         typedef enum devtype_list {
65                 DEVTYPE_POWERSUPPLY,            /**< battery, PMIC, etc about power */
66                 DEVTYPE_DISPLAY0,               /**< main screen */
67                 DEVTYPE_DISPLAY1,               /**< sub screen */
68                 DEVTYPE_HAPTIC,                 /**< motor */
69                 DEVTYPE_LED,                    /**< LED */
70                 DEVTYPE_JACK,                   /**< jack - Micro USB, 3.5 pi jack etc */
71                 DEVTYPE_TOUCHSCREEN,            /**< main touch screen */
72                 DEVTYPE_TOUCHKEY,               /**< touchkey */
73                 DEVTYPE_GPS,
74                 DEVTYPE_UART,
75                 DEVTYPE_MMC,                    /**< MMC card(Micro SD) */
76                 DEVTYPE_EFFECT_HAPTIC,          /**< extended touchsense */
77                 DEVTYPE_POWER,
78
79                 DEVTYPE_MAX
80         } devtype_t;
81
82 /**
83  * @par Description:
84  *      DEVTYPE_POWER property for generic APIs
85  */
86         enum {
87                 POWER_PROP_STATE,
88                 POWER_PROP_WAKEUP_COUNT,
89         };
90
91 /**
92  * @par Description:
93  *      DEVTYPE_POWERSUPPLY property for generic APIs
94  */
95         enum {
96                 /**< Battery is full-charged.*/
97                 POWER_SUPPLY_PROP_CHARGE_FULL,
98                 /**< Battery is being charged now */
99                 POWER_SUPPLY_PROP_CHARGE_NOW,
100                 /**< Current remaining battery */
101                 POWER_SUPPLY_PROP_CAPACITY,
102                 /**< iBattery status about cahrge */
103                 POWER_SUPPLY_PROP_BATTERY_HEALTH,
104                 /**< Current remaining battery expressed 1/10000 */
105                 POWER_SUPPLY_PROP_CAPACITY_RAW,
106         };
107
108 /**
109  * @par Description:
110  *      DEVTYPE_DISPLAY0 and DEVTYPE_DISPLAY1 property for generic APIs
111  */
112         enum {
113                 DISPLAY_PROP_ONOFF,
114                 DISPLAY_PROP_BRIGHTNESS,
115                 DISPLAY_PROP_MIN_BRIGHTNESS,
116                 DISPLAY_PROP_MAX_BRIGHTNESS,
117                 DISPLAY_PROP_GAMMA,
118                 DISPLAY_PROP_DISPLAY_COUNT,
119                 DISPLAY_PROP_ACL_CONTROL,
120                 DISPLAY_PROP_IMAGE_ENHANCE_MODE,
121                 DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO,
122                 DISPLAY_PROP_IMAGE_ENHANCE_TONE,
123                 DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR,
124                 DISPLAY_PROP_IMAGE_ENHANCE_INFO,
125         };
126
127 /**
128  * @par Description:
129  *  DEVTYPE_LED property for generic APIs
130  */
131         enum {
132                 LED_PROP_BRIGHTNESS,
133                 LED_PROP_MAX_BRIGHTNESS,
134         };
135
136 /**
137  * @par Description:
138  *      DEVTYPE_JACK property for generic APIs
139  */
140         enum {
141                 JACK_PROP_EARJACK_ONLINE,
142                                         /**< Earjack */
143                 JACK_PROP_MIC_ONLINE,   /**< Microphone */
144                 JACK_PROP_TVOUT_ONLINE, /**< analog tvout */
145                 JACK_PROP_USB_ONLINE,   /**< USB connection */
146                 JACK_PROP_TA_ONLINE,    /**< Travel Adapter(Charger) */
147                 JACK_PROP_HDMI_ONLINE,  /**< Digital tvout */
148                 JACK_PROP_USB_PATH,             /**< */
149                 JACK_PROP_EARKEY_PRESS, /**< */
150                 JACK_PROP_CRADLE_ONLINE,/**< Cradle connection */
151         };
152
153 /**
154  * @par Description:
155  *      DEVTYPE_TOUCHKEY property for generic APIs
156  */
157         enum {
158                 TCKEY_PROP_FIRST,
159                                 /**< */
160                 TCKEY_PROP_SECOND,
161                                 /**< */
162                 TCKEY_PROP_THIRD,
163                                 /**< */
164         };
165
166 /**
167  * @par Description:
168  *      DEVTYPE_UART property for generic APIs
169  */
170         enum {
171                 UART_PROP_SELECT_PATH,
172         };
173
174 /**
175  * @par Description:
176  *      DEVTYPE_MMC property for generic APIs
177  */
178         enum {
179                 MMC_PROP_FORMAT,
180         };
181
182 /**
183  * @fn int device_get_property(devtype_t devtype, int property, int *value)
184  * @par Description:
185  *      This generic API is used to get the property values of supported devices.\n
186  *      If the caller process does not have permission, it returns failure.
187  * @param[in] devtype device type that you want to get the value
188  * @param[in] property value property that you want to get the value
189  * @param[out] *value current value of device property
190  * @return 0 on success, -1 if failed
191  * @see device_set_property()
192  * @par Example:
193  * @code
194  *      ...
195  *      if( device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CAPACITY, &val) < 0 )
196  *              printf("Fail to get property\n");
197  *      else
198  *              printf("Property is %d\n", val);
199  *      ...
200  * @endcode
201  */
202         int device_get_property(devtype_t devtype, int property, int *value);
203
204 /**
205  * @fn int device_set_property(devtype_t devtype, int property, int value)
206  * @par Description:
207  *      This generic API is used to set the property values of supported devices.\n
208  *      If the caller process does not have permission, it returns failure.
209  * @param[in] devtype device type that you want to set the value
210  * @param[in] property value property that you want to set the value
211  * @param[in] value value that you want to set
212  * @return 0 on success, -1 if failed
213  * @see device_get_property()
214  * @par Example
215  * @code
216  *      ...
217  *      if( device_set_property(DEVTYPE_DISPLAY0, DISPLAY_PROP_BRIGHTNESS, val) < 0 )
218  *              printf("Fail to set property\n");
219  *      else
220  *              printf("Property is set %d\n", val);
221  *      ...
222  * @endcode
223  */
224         int device_set_property(devtype_t devtype, int property, int value);
225
226 /* Application level interfaces */
227
228 /**
229  * @par Description:
230  *      This API is used to get the remaining battery percentage.\n
231  *      It gets the Battery percentage by calling device_get_property() function.\n
232  *      It returns integer value(0~100) that indicate remaining batterty percentage on success.\n
233  *      Or a negative value(-1) is returned on failure.
234  * @return On success, integer value(0~100) is returned.
235  *  Or a negative value(-1) is returned on failure.
236  * @see device_is_battery_full(), device_get_battery_pct_raw()
237  * @par Example
238  * @code
239  *      ...
240  *      int battery;
241  *      battery = device_get_battery_pct();
242  *      if( battery < 0 )
243  *              printf("Fail to get the remaining battery percentage.\n");
244  *      else
245  *              printf("remaining battery percentage : %d\n", battery);
246  *      ...
247  * @endcode
248  */
249         int device_get_battery_pct(void);
250
251 /**
252  * @par Description:
253  *      This API is used to get the remaining battery percentage expressed 1/10000.\n
254  *      It gets the Battery percentage by calling device_get_property() function.\n
255  *      It returns integer value(0~10000) that indicate remaining batterty percentage on success.\n
256  *      Or a negative value(-1) is returned on failure.
257  * @return On success, integer value(0~10000) is returned.
258  *  Or a negative value(-1) is returned on failure.
259  * @see device_is_battery_full(), device_get_battery_pct()
260  * @par Example
261  * @code
262  *      ...
263  *      int battery;
264  *      battery = device_get_battery_pct_raw();
265  *      if( battery < 0 )
266  *              printf("Fail to get the remaining battery percentage.\n");
267  *      else
268  *              printf("remaining battery percentage expressed 1/10000 : %d\n", battery);
269  *      ...
270  * @endcode
271  */
272         int device_get_battery_pct_raw(void);
273
274 /**
275  * @par Description:
276  *      This API is used to get the fully charged status of battery.\n
277  *  It gets the fully charged status of Battery by calling device_get_property() function.\n
278  *      If the status of battery is full, it returns 1.\n
279  *      Or a negative value(-1) is returned, if the status of battery is not full.
280  * @return 1 with battery full, or 0 on not full-charged, -1 if failed
281  * @see device_get_battery_pct()
282  * @par Example
283  * @code
284  *      ...
285  *      if ( device_is_battery_full() > 0 )
286  *              printf("battery fully chared\n");
287  *      ...
288  * @endcode
289  */
290         int device_is_battery_full(void);
291
292 /**
293  * @par Description:
294  *  Battery health status
295  */
296         enum {
297                 BAT_UNKNOWN = 0,        /**< */
298                 BAT_GOOD,                       /**< */
299                 BAT_OVERHEAT,           /**< */
300                 BAT_DEAD,                       /**< */
301                 BAT_OVERVOLTAGE,        /**< */
302                 BAT_UNSPECIFIED,        /**< */
303                 BAT_COLD,                       /**< */
304                 BAT_HEALTH_MAX,         /**< */
305         };
306
307 /**
308  * @par Description:
309  *  This API is used to get the battery health status.\n
310  *  It gets the battery health status by calling device_get_property() function.\n
311  *      It returns integer value(0~6) that indicate battery health status on success.\n
312  *  Or a negative value(-1) is returned, if the status of battery is not full.
313  * @return interger value, -1 if failed\n
314  * (0 BATTERY_UNKNOWN, 1 GOOD, 2 OVERHEAT, 3 DEAD, 4 OVERVOLTAGE, 5 UNSPECIFIED, 6 COLD)
315  * @par Example
316  * @code
317  *  ...
318  *  int bat_health;
319  *  bat_health =device_get_battery_health();
320  *  if(bat_health != BAT_GOOD)
321  *      printf("battery health is not good\n");
322  *  ...
323  * @endcode
324  */
325         int device_get_battery_health(void);
326
327 /**
328  * @par Description:
329  *      Display number
330  */
331         typedef enum {
332                 DEV_DISPLAY_0,  /**< */
333                 DEV_DISPLAY_1,  /**< */
334                 DEV_MAIN_DISPLAY = DEV_DISPLAY_0,       /**< */
335         } display_num_t;
336
337 /**
338  * @par Description:
339  *      This API is used to get the current brightness of the display.\n
340  *      It gets the current brightness of the display by calling device_get_property() function.\n
341  *      It returns integer value which is the current brightness on success.\n
342  *      Or a negative value(-1) is returned on failure.
343  * @param[in] num display number that you want to get the brightness value
344  * @return current brightness value on success, -1 if failed
345  * @see device_set_diplay_brt()
346  * @par Example
347  * @code
348  *      ...
349  *      int cur_brt;
350  *      cur_brt = device_get_display_brt(0);
351  *      if( cur_brt < 0 )
352  *              printf("Fail to get the current brightness of the display.\n");
353  *      else
354  *              printf("Current brightness of the display is %d\n", cur_brt);
355  *      ...
356  * @endcode
357  */
358         int device_get_display_brt(display_num_t num);
359
360 /**
361  * @par Description:
362  *      This API is used to set the current brightness of the display.\n
363  *  It sets the current brightness of the display by calling device_set_property() function.\n
364  *      MUST use this API very carefully. \n
365  *      you MUST set original brightness by device_release_brt_ctrl(),
366  *      after you finish your job using this API.
367  * @param[in] num display number that you want to set the brightness value
368  * @param[in] val brightness value that you want to set
369  * @return 0 on success, -1 if failed
370  * @see device_get_diplay_brt(), device_release_brt_ctrl()
371  * @par Example
372  * @code
373  *      ...
374  *      if( device_set_display_brt(0,6) < 0 )
375  *          printf("Fail to set the current brightness of the display0\n");
376  *      else
377  *          printf("The current brightness of the display0 is set 6\n");
378  *      ...
379  * @endcode
380  */
381         int device_set_display_brt(display_num_t num, int val);
382
383 /**
384  * @par Description:
385  *      This API is used to release brightness control.\n
386  *  It sets the current brightness of the display by calling device_set_property() function.\n
387  *      MUST call this API after you finished the job which need to change the brightness.
388  * @param[in] num display number
389  * @return 0 on success, -1 if failed
390  * @see device_set_display_brt()
391  * @par Example
392  * @code
393  *      ...
394  *      org_val = device_get_display_brt(0);
395  *      device_set_display_brt(0,1);
396  *      ...
397  *      ret = device_release_brt_ctrl(0);
398  *      if( ret < 0 )
399  *              printf("Fail to release brightness control\n");
400  *      ...
401  * @endcode
402  */
403         int device_release_brt_ctrl(display_num_t num);
404
405 /**
406  * @par Description:
407  *  This API is used to get the min brightness of the display.\n
408  *  It gets the current brightness of the display by calling device_get_property() function.\n
409  *  It returns integer value which is the min brightness on success.\n
410  *  Or a negative value(-1) is returned on failure
411  * @param[in] num display number
412  * @return min brightness value on success, -1 if failed
413  * @par Example
414  * @code
415  *  ...
416  *  int min_brt;
417  *  min_brt = device_get_min_brt(0);
418  *  if( min_brt < 0 )
419  *      printf("Fail to get the min brightness of the display.\n");
420  *  else
421  *      printf("Min brightness of the display is %d\n", min_brt);
422  *  ...
423  * @endcode
424  */
425         int device_get_min_brt(display_num_t num);
426
427 /**
428  * @par Description:
429  *  This API is used to get the max brightness of the display.\n
430  *  It gets the current brightness of the display by calling device_get_property() function.\n
431  *  It returns integer value which is the max brightness on success.\n
432  *  Or a negative value(-1) is returned on failure
433  * @param[in] num display number
434  * @return max brightness value on success, -1 if failed
435  * @par Example
436  * @code
437  *  ...
438  *  int max_brt;
439  *  max_brt = device_get_max_brt(0);
440  *  if( max_brt < 0 )
441  *      printf("Fail to get the max brightness of the display.\n");
442  *  else
443  *      printf("Max brightness of the display is %d\n", max_brt);
444  *  ...
445  * @endcode
446  */
447         int device_get_max_brt(display_num_t num);
448
449 /**
450  * @par Description:
451  *      LCD gamma values
452  */
453         typedef enum {
454                 LCD_GAMMA_22 = 1,                       /**< 8500K , 2.2 GAMMA*/
455                 LCD_GAMMA_19 = 2,                       /**< 8500K , 1.9 GAMMA*/
456                 LCD_GAMMA_17 = 3,                       /**< 8500K , 1.7 GAMMA*/
457                 LCD_GAMMA_NORMAL = LCD_GAMMA_22,                        /**< Normal screen */
458                 LCD_GAMMA_PLAY_RECORD = LCD_GAMMA_19,           /**< Playing or recording cam */
459                 LCD_GAMMA_PREVIEW = LCD_GAMMA_17,                       /**< Preview */
460                 LCD_GAMMA_MOVIE = LCD_GAMMA_19,                         /**< Movie */
461                 LCD_GAMMA_CAMERA = 11,                                                  /**< Camera */
462         } display_gamma_t;
463
464 /**
465  * @par Description:
466  *      This API is used to get the current gamma of the display.\n
467  *  It gets the current gamma of the display by calling device_get_property() function.\n
468  *  It returns enum value which is the current gamma on success.\n
469  *  Or a negative value(-1) is returned on failure.
470  * @param[in] num display number that you want to get the gamma value
471  * @return current gamma enum value on success, -1 if failed
472  * @see device_set_diplay_gamma()
473  * @par Example
474  * @code
475  *  ...
476  *  int cur_brt;
477  *  cur_brt = device_get_display_gamma(0);
478  *  if( cur_brt < 0 )
479  *     printf("Fail to get the current gamma of the display.\n");
480  *  else
481  *     printf("Current gamma of the display is %d\n", cer_brt);
482  *  ...
483  * @endcode
484  */
485         int device_get_display_gamma(display_num_t num);
486
487 /**
488  * @par Description:
489  *      This API is used to set the specific gamma value of the display .\n
490  *  It sets the specific gamma value of the display by calling device_set_property() function.\n
491  *  MUST use this API very carefully. \n
492  *  you MUST set original gamma by device_release_gamma_ctrl(),
493  *  after you finish your job using this API.
494  * @param[in] num display number that you want to set the gamma value
495  * @param[in] new_val lcd gamma enum value that you want to set
496  * @return 0 on success, -1 if failed
497  * @see device_get_diplay_gammat(), device_release_gamma_ctrl()
498  * @par Example
499  * @code
500  *  ...
501  *  if( device_set_display_gamma(0,1) < 0 )
502  *      printf("Fail to set the specific gamma of the display0\n");
503  *  else
504  *      printf("The gamma of the display0 is set 1(LCD_GAMMA_22)\n");
505  *  ...
506  * @endcode
507  */
508         int device_set_display_gamma(display_num_t num,
509                         display_gamma_t new_val);
510
511 /**
512  * @par Description:
513  *      This API is used to release gamma control.\n
514  *  It sets the gamma of the display by calling device_set_property() function.\n
515  *  MUST call this API after you finished the job which need to change the gamma.
516  * @param[in] num display number
517  * @param[in] org_val original gamma enums value before you control the gamma
518  * @return 0 on success, -1 if failed
519  * @see device_set_display_gamma()
520  * @par Example
521  * @code
522  *  ...
523  *  org_val = device_get_display_gamma(0);
524  *  device_set_display_gamma(0,2);
525  *  ...
526  *  ret = device_release_gamma_ctrl(0, org_val);
527  *  if( ret < 0 )
528  *      printf("Fail to release gamma control\n");
529  *  ...
530  * @endcode
531  */
532         int device_release_gamma_ctrl(display_num_t num,
533                         display_gamma_t org_val);
534
535 /**
536  * @par Description:
537  *      This API is used to get number of displays on the phone.\n
538  *  It gets the current number of displays by calling device_get_display_count() function.\n
539  *  It returns enum value which is the current number on success.\n
540  *  Or a negative value(-1) is returned on failure.
541  * @return 0 on success, -1 if failed
542  * @par Example
543  * @code
544  *      ...
545  *      ret = device_get_display_count();
546  *      if( ret < 0 )
547  *      printf("Fail to get number of displays\n");
548  *  ...
549  * @endcode
550  */
551         int device_get_display_count(void);
552
553 /**
554  * @par Description:
555  *      This API is used to make the phone go to a suspend (sleep) state. \n
556  *      The suspend state consumes little battery power. \n
557  *      If the caller process does not have permission, it returns failure.
558  * @return 0 on success, -1 if failed
559  * @par Example
560  * @code
561  *      ...
562  *      ret = device_power_suspend();
563  *      if( ret < 0 )
564  *      printf("Fail to make the phone go to a suspend (sleep) state\n");
565  *  ...
566  * @endcode
567  */
568         int device_power_suspend(void);
569
570 /**
571  * @par Description:
572  *  This API is used to get the current brightness of the led.\n
573  *  It gets the current brightness of the led by calling device_get_property() function.\n
574  *  It returns integer value which is the current brightness on success.\n
575  *  Or a negative value(-1) is returned on failure.
576  * @return current brightness value on success, -1 if failed
577  * @see device_set_led_brt()
578  * @par Example
579  * @code
580  *  ...
581  *  int cur_brt;
582  *  cur_brt = device_get_led_brt();
583  *  if( cur_brt < 0 )
584  *      printf("Fail to get the current brightness of the led.\n");
585  *  else
586  *      printf("Current brightness of the led is %d\n", cur_brt);
587  *  ...
588  * @endcode
589  */
590         int device_get_led_brt(void);
591
592 /**
593  * @par Description:
594  *  This API is used to set the current brightness of the led.\n
595  *      It sets the current brightness of the led by calling device_set_property() function.\n
596  * @param[in] val brightness value that you want to set
597  * @return 0 on success, -1 if failed
598  * @see device_get_led_brt()
599  * @par Example
600  * @code
601  *  ...
602  *  if( device_set_led_brt(1) < 0 )
603  *     printf("Fail to set the brightness of the led\n");
604  * @endcode
605  */
606         int device_set_led_brt(int val);
607
608 /**
609  * @par Description:
610  *  This API is used to get the max brightness of the led.\n
611  *  It gets the current brightness of the led by calling device_get_property() function.\n
612  *  It returns integer value which is the max brightness on success.\n
613  *  Or a negative value(-1) is returned on failure
614  * @return max brightness value on success, -1 if failed
615  * @par Example
616  * @code
617  *  ...
618  *  int max_brt;
619  *  max_brt = device_get_max_led(0);
620  *  if( max_brt < 0 )
621  *      printf("Fail to get the max brightness of the led.\n");
622  *  ...
623  * @endcode
624  */
625         int device_get_max_led(void);
626
627 /**
628  * @par Description:
629  *  This API is used to get the current state for acl.\n
630  *  It gets the current state for acl by calling device_get_property() function.\n
631  * @param[in] num display number that you want to set the gamma value
632  * @return current status for acl(1 on, 0 off) on success, -1 if failed
633  * @see device_set_acl_control_status()
634  * @par Example
635  * @code
636  *  ...
637  *  int acl_stat;
638  *  acl_stat = device_get_acl_control_status(0);
639  *  if( acl_stat < 0 )
640  *      printf("Fail to get the current status for acl.\n");
641  *  else
642  *      printf("Current status for acl is %d\n", cur_brt);
643  *  ...
644  * @endcode
645  */
646         int device_get_acl_control_status(display_num_t num);
647
648 /**
649  * @par Description:
650  *  This API is used to set the current status for acl.\n
651  *  It sets the current status for acl by calling device_set_property() function.\n
652  * @param[in] num display number that you want to set the brightness value
653  * @param[in] val status for acl(1 on, 0 off) that you want to set
654  * @return 0 on success, -1 if failed
655  * @see device_get_acl_control_status()
656  * @par Example
657  * @code
658  *  ...
659  *  if( device_set_acl_control_status(0, 1) < 0 )
660  *      printf("Fail to set the current status for acl\n");
661  *  else
662  *      printf("The current status for acl is set 6\n");
663  *  ...
664  * @endcode
665  */
666         int device_set_acl_control_status(display_num_t num, int val);
667
668 /**
669  * @} // end of internal APIs
670  */
671
672 #ifdef __cplusplus
673 }
674 #endif
675 #endif