Git init
[framework/system/devman.git] / 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 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /** 
35  * @file        devman.h
36  * @ingroup     DEVICE_MANAGER
37  * @brief       This file contains the API for the status of devices
38  * @author      SLP2.0
39  * @date        2010-01-24
40  * @version     0.1
41  */
42
43 /**
44  * @defgroup DEVICE_MANAGER             Device Manager
45  * @ingroup SYSTEM_FRAMEWORK
46  * @brief Device Manager library
47  *
48  * Device manager provides APIs to control devices or to get the status of devices.
49  * <br> Use devman.pc and include devman.h and devman_haptic.h files
50  *
51  * @addtogroup DEVICE_MANAGER
52  * @{
53  */
54
55 /**
56  * @par Description:
57  *      device type enum
58  */
59         typedef enum devtype_list {
60                 DEVTYPE_POWERSUPPLY,    /**< battery, PMIC, etc about power */
61                 DEVTYPE_DISPLAY0,               /**< main screen */
62                 DEVTYPE_DISPLAY1,               /**< sub screen */
63                 DEVTYPE_HAPTIC,                 /**< motor */
64                 DEVTYPE_LED,                    /**< LED */
65                 DEVTYPE_JACK,                   /**< jack - Micro USB, 3.5 pi jack etc */
66                 DEVTYPE_TOUCHSCREEN,    /**< main touch screen */
67                 DEVTYPE_TOUCHKEY,               /**< touchkey */
68                 DEVTYPE_GPS,
69                 DEVTYPE_UART,
70                 DEVTYPE_MMC,                    /**< MMC card(Micro SD) */
71                 DEVTYPE_EFFECT_HAPTIC,  /**< extended touchsense */
72
73                 DEVTYPE_MAX
74         } devtype_t;
75
76 /** 
77  * @par Description:
78  *      DEVTYPE_POWERSUPPLY property for generic APIs
79  */
80         enum {
81                 POWER_SUPPLY_PROP_CHARGE_FULL,
82                                         /**< Battery is full-charged.*/
83                 POWER_SUPPLY_PROP_CHARGE_NOW,
84                                         /**< Battery is being charged now */
85                 POWER_SUPPLY_PROP_CAPACITY,     /**< Current remaining battery */
86         };
87
88 /**
89  * @par Description:
90  *      DEVTYPE_DISPLAY0 and DEVTYPE_DISPLAY1 property for generic APIs
91  */
92         enum {
93                 DISPLAY_PROP_ONOFF,
94                 DISPLAY_PROP_BRIGHTNESS,
95                 DISPLAY_PROP_MAX_BRIGHTNESS,
96                 DISPLAY_PROP_GAMMA,
97                 DISPLAY_PROP_DISPLAY_COUNT,
98         };
99
100 /**
101  * @par Description:
102  *  DEVTYPE_LED property for generic APIs
103  */
104         enum {
105                 LED_PROP_BRIGHTNESS,
106                 LED_PROP_MAX_BRIGHTNESS,
107         };
108
109 /**
110  * @par Description:
111  *      DEVTYPE_JACK property for generic APIs
112  */
113         enum {
114                 JACK_PROP_EARJACK_ONLINE,
115                                         /**< Earjack */
116                 JACK_PROP_MIC_ONLINE,   /**< Microphone */
117                 JACK_PROP_TVOUT_ONLINE, /**< analog tvout */
118                 JACK_PROP_USB_ONLINE,   /**< USB connection */
119                 JACK_PROP_TA_ONLINE,    /**< Travel Adapter(Charger) */
120                 JACK_PROP_HDMI_ONLINE,  /**< Digital tvout */
121                 JACK_PROP_USB_PATH,             /**< */
122                 JACK_PROP_EARKEY_PRESS, /**< */
123                 JACK_PROP_CRADLE_ONLINE,/**< Cradle connection */
124         };
125
126 /**
127  * @par Description:
128  *      DEVTYPE_TOUCHKEY property for generic APIs
129  */
130         enum {
131                 TCKEY_PROP_FIRST,
132                                 /**< */
133                 TCKEY_PROP_SECOND,
134                                 /**< */
135                 TCKEY_PROP_THIRD,
136                                 /**< */
137         };
138
139 /**
140  * @par Description:
141  *      DEVTYPE_UART property for generic APIs
142  */
143         enum {
144                 UART_PROP_SELECT_PATH,
145         };
146
147 /**
148  * @par Description:
149  *      DEVTYPE_MMC property for generic APIs
150  */
151         enum {
152                 MMC_PROP_FORMAT,
153         };
154
155 /**
156  * @fn int device_get_property(devtype_t devtype, int property, int *value)
157  * @par Description:
158  *      This generic API is used to get the property values of supported devices.\n
159  *      If the caller process does not have permission, it returns failure.
160  * @param[in] devtype device type that you want to get the value 
161  * @param[in] property value property that you want to get the value
162  * @param[out] *value current value of device property
163  * @return 0 on success, -1 if failed
164  * @see device_set_property()
165  * @par Example:
166  * @code
167  *      ...
168  *      if( device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CAPACITY, &val) < 0 )
169  *              printf("Fail to get property\n");
170  *      else 
171  *              printf("Property is %d\n", val);
172  *      ...
173  * @endcode
174  */
175         int device_get_property(devtype_t devtype, int property, int *value);
176
177 /**
178  * @fn int device_set_property(devtype_t devtype, int property, int value)
179  * @par Description:
180  *      This generic API is used to set the property values of supported devices.\n 
181  *      If the caller process does not have permission, it returns failure.
182  * @param[in] devtype device type that you want to set the value
183  * @param[in] property value property that you want to set the value
184  * @param[in] value value that you want to set
185  * @return 0 on success, -1 if failed
186  * @see device_get_property()
187  * @par Example
188  * @code
189  *      ...
190  *      if( device_set_property(DEVTYPE_DISPLAY0, DISPLAY_PROP_BRIGHTNESS, val) < 0 )
191  *              printf("Fail to set property\n");
192  *      else
193  *              printf("Property is set %d\n", val);
194  *      ...
195  * @endcode
196  */
197         int device_set_property(devtype_t devtype, int property, int value);
198
199 /* Application level interfaces */
200
201 /**
202  * @par Description:
203  *      This API is used to get the remaining battery percentage.\n
204  *      It gets the Battery percentage by calling device_get_property() function.\n
205  *      It returns integer value(0~100) that indicate remaining batterty percentage on success.\n
206  *      Or a negative value(-1) is returned on failure.
207  * @return On success, integer value(0~100) is returned. 
208  *              Or a negative value(-1) is returned on failure.
209  * @see device_is_battery_full()
210  * @par Example
211  * @code
212  *      ...
213  *      int battery;
214  *      battery = device_get_battery_pct();
215  *      if( battery < 0 )
216  *              printf("Fail to get the remaining battery percentage.\n");
217  *      else
218  *              printf("remaining battery percentage : %d\n", battery);
219  *      ...         
220  * @endcode
221  */
222         int device_get_battery_pct(void);
223
224 /**
225  * @par Description:
226  *      This API is used to get the fully charged status of battery.\n
227  *      It gets the fully charged status of Battery by calling device_get_property() function.\n
228  *      If the status of battery is full, it returns 1.\n
229  *      Or a negative value(-1) is returned, if the status of battery is not full.
230  * @return 1 with battery full, or 0 on not full-charged, -1 if failed
231  * @see device_get_battery_pct()
232  * @par Example
233  * @code
234  *      ...
235  *      if ( device_is_battery_full() > 0 )
236  *              printf("battery fully chared\n");
237  *      ...         
238  * @endcode
239  */
240         int device_is_battery_full(void);
241
242 /**
243  * @par Description:
244  *      Display number
245  */
246         typedef enum {
247                 DEV_DISPLAY_0,  /**< */
248                 DEV_DISPLAY_1,  /**< */
249                 DEV_MAIN_DISPLAY = DEV_DISPLAY_0,       /**< */
250         } display_num_t;
251
252 /**
253  * @par Description:
254  *      This API is used to get the current brightness of the display.\n
255  *      It gets the current brightness of the display by calling device_get_property() function.\n
256  *      It returns integer value which is the current brightness on success.\n
257  *      Or a negative value(-1) is returned on failure.
258  * @param[in] num display number that you want to get the brightness value
259  * @return current brightness value on success, -1 if failed
260  * @see device_set_diplay_brt()
261  * @par Example
262  * @code
263  *      ...
264  *      int cur_brt;
265  *      cur_brt = device_get_display_brt(0);
266  *      if( cur_brt < 0 )
267  *              printf("Fail to get the current brightness of the display.\n");
268  *      else
269  *              printf("Current brightness of the display is %d\n", cur_brt);
270  *      ...
271  * @endcode
272  */
273         int device_get_display_brt(display_num_t num);
274
275 /**
276  * @par Description:
277  *      This API is used to set the current brightness of the display.\n 
278  *      It sets the current brightness of the display by calling device_set_property() function.\n
279  *      MUST use this API very carefully. \n
280  *      you MUST set original brightness by device_release_brt_ctrl(), 
281  *      after you finish your job using this API. 
282  * @param[in] num display number that you want to set the brightness value
283  * @param[in] val brightness value that you want to set
284  * @return 0 on success, -1 if failed
285  * @see device_get_diplay_brt(), device_release_brt_ctrl()
286  * @par Example
287  * @code
288  *      ...
289  *      if( device_set_display_brt(0,6) < 0 )
290  *                      printf("Fail to set the current brightness of the display0\n");
291  *      else
292  *                      printf("The current brightness of the display0 is set 6\n");
293  *      ...
294  * @endcode
295  */
296         int device_set_display_brt(display_num_t num, int val);
297
298 /**
299  * @par Description:
300  *      This API is used to release brightness control.\n
301  *      It sets the current brightness of the display by calling device_set_property() function.\n
302  *      MUST call this API after you finished the job which need to change the brightness.
303  * @param[in] num display number
304  * @return 0 on success, -1 if failed
305  * @see device_set_display_brt()
306  * @par Example
307  * @code
308  *      ...
309  *      org_val = device_get_display_brt(0);
310  *      device_set_display_brt(0,1);
311  *      ...
312  *      ret = device_release_brt_ctrl(0);
313  *      if( ret < 0 )
314  *              printf("Fail to release brightness control\n");
315  *      ...
316  * @endcode
317  */
318         int device_release_brt_ctrl(display_num_t num);
319
320 /**
321  * @par Description:
322  *      This API is used to get the max brightness of the display.\n
323  *      It gets the current brightness of the display by calling device_get_property() function.\n
324  *      It returns integer value which is the max brightness on success.\n
325  *      Or a negative value(-1) is returned on failure
326  * @param[in] num display number
327  * @return max brightness value on success, -1 if failed
328  * @par Example
329  * @code
330  *      ...
331  *      int max_brt;
332  *      max_brt = device_get_max_brt(0);
333  *      if( max_brt < 0 )
334  *              printf("Fail to get the max brightness of the display.\n");
335  *      else
336  *              printf("Max brightness of the display is %d\n", max_brt);
337  *      ...
338  * @endcode
339  */
340         int device_get_max_brt(display_num_t num);
341
342 /** 
343  * @par Description:
344  *      LCD gamma values
345  */
346         typedef enum {
347                 LCD_GAMMA_22 = 1,                       /**< 8500K , 2.2 GAMMA*/
348                 LCD_GAMMA_19 = 2,                       /**< 8500K , 1.9 GAMMA*/
349                 LCD_GAMMA_17 = 3,                       /**< 8500K , 1.7 GAMMA*/
350                 LCD_GAMMA_NORMAL = LCD_GAMMA_22,                        /**< Normal screen */
351                 LCD_GAMMA_PLAY_RECORD = LCD_GAMMA_19,           /**< Playing or recording cam */
352                 LCD_GAMMA_PREVIEW = LCD_GAMMA_17,                       /**< Preview */
353                 LCD_GAMMA_MOVIE = LCD_GAMMA_19,                         /**< Movie */
354                 LCD_GAMMA_CAMERA = 11,                                                  /**< Camera */
355         } display_gamma_t;
356
357 /**
358  * @par Description:
359  *      This API is used to get the current gamma of the display.\n
360  *      It gets the current gamma of the display by calling device_get_property() function.\n
361  *      It returns enum value which is the current gamma on success.\n
362  *      Or a negative value(-1) is returned on failure.
363  * @param[in] num display number that you want to get the gamma value
364  * @return current gamma enum value on success, -1 if failed
365  * @see device_set_diplay_gamma()
366  * @par Example
367  * @code
368  *      ...
369  *      int cur_brt;
370  *      cur_brt = device_get_display_gamma(0);
371  *      if( cur_brt < 0 )
372  *              printf("Fail to get the current gamma of the display.\n");
373  *      else
374  *              printf("Current gamma of the display is %d\n", cer_brt);
375  *      ...
376  * @endcode
377  */
378         int device_get_display_gamma(display_num_t num);
379
380 /**
381  * @par Description:
382  *      This API is used to set the specific gamma value of the display .\n 
383  *      It sets the specific gamma value of the display by calling device_set_property() function.\n
384  *      MUST use this API very carefully. \n
385  *      you MUST set original gamma by device_release_gamma_ctrl(), 
386  *      after you finish your job using this API. 
387  * @param[in] num display number that you want to set the gamma value
388  * @param[in] new_val lcd gamma enum value that you want to set
389  * @return 0 on success, -1 if failed
390  * @see device_get_diplay_gammat(), device_release_gamma_ctrl()
391  * @par Example
392  * @code
393  *      ...
394  *      if( device_set_display_gamma(0,1) < 0 )
395  *                      printf("Fail to set the specific gamma of the display0\n");
396  *      else
397  *                      printf("The gamma of the display0 is set 1(LCD_GAMMA_22)\n");
398  *      ...
399  * @endcode
400  */
401         int device_set_display_gamma(display_num_t num,
402                                      display_gamma_t new_val);
403
404 /**
405  * @par Description:
406  *      This API is used to release gamma control.\n
407  *      It sets the gamma of the display by calling device_set_property() function.\n
408  *      MUST call this API after you finished the job which need to change the gamma.
409  * @param[in] num display number
410  * @param[in] org_val original gamma enums value before you control the gamma
411  * @return 0 on success, -1 if failed
412  * @see device_set_display_gamma()
413  * @par Example
414  * @code
415  *      ...
416  *      org_val = device_get_display_gamma(0);
417  *      device_set_display_gamma(0,2);
418  *      ...
419  *      ret = device_release_gamma_ctrl(0, org_val);
420  *      if( ret < 0 )
421  *              printf("Fail to release gamma control\n");
422  *      ...
423  * @endcode
424  */
425        int device_release_gamma_ctrl(display_num_t num,
426                                      display_gamma_t org_val);
427
428 /**
429  * @par Description:
430  *      This API is used to get number of displays on the phone.\n
431  *      It gets the current number of displays by calling device_get_display_count() function.\n
432  *      It returns enum value which is the current number on success.\n
433  *      Or a negative value(-1) is returned on failure.
434  * @return 0 on success, -1 if failed
435  * @par Example
436  * @code
437  *      ...
438  *      ret = device_get_display_count();
439  *      if( ret < 0 )
440  *              printf("Fail to get number of displays\n");
441  *      ...
442  * @endcode
443  */
444         int device_get_display_count(void);
445
446 /**
447  * @par Description:
448  *      This API is used to make the phone go to a suspend (sleep) state. \n
449  *      The suspend state consumes little battery power. \n
450  *      If the caller process does not have permission, it returns failure.
451  * @return 0 on success, -1 if failed
452  * @par Example
453  * @code
454  *      ...
455  *      ret = device_power_suspend();
456  *      if( ret < 0 )
457  *              printf("Fail to make the phone go to a suspend (sleep) state\n");
458  *      ...
459  * @endcode
460  */
461         int device_power_suspend(void);
462
463         int device_get_led_brt(void);
464         int device_set_led_brt(int val);
465         int device_get_max_led(void);
466
467 /**
468  * @} // end of internal APIs
469  */
470
471 #ifdef __cplusplus
472 }
473 #endif
474 #endif