tizen 2.3 release
[framework/system/deviced.git] / src / display / poll.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19
20 /**
21  * @file        poll.h
22  * @brief       Power Manager input device poll implementation
23  *
24  * This file includes the input device poll implementation.
25  * Default input devices are /dev/event0 and /dev/event1
26  * User can use "PM_INPUT_DEV" for setting another input device poll in an environment file (/etc/profile).
27  * (ex: PM_INPUT_DEV=/dev/event0:/dev/event1:/dev/event5 )
28  */
29
30 #ifndef __PM_POLL_H__
31 #define __PM_POLL_H__
32
33 #include <Ecore.h>
34 #include "core/edbus-handler.h"
35 /**
36  * @addtogroup POWER_MANAGER
37  * @{
38  */
39
40 enum {
41         INPUT_POLL_EVENT = -9,
42         SIDEKEY_POLL_EVENT,
43         PWRKEY_POLL_EVENT,
44         PM_CONTROL_EVENT,
45 };
46
47 enum {
48         INTERNAL_LOCK_BASE = 100000,
49         INTERNAL_LOCK_ALPM,
50         INTERNAL_LOCK_BATTERY,
51         INTERNAL_LOCK_BOOTING,
52         INTERNAL_LOCK_DUMPMODE,
53         INTERNAL_LOCK_HDMI,
54         INTERNAL_LOCK_ODE,
55         INTERNAL_LOCK_POPUP,
56         INTERNAL_LOCK_SOUNDDOCK,
57         INTERNAL_LOCK_TA,
58         INTERNAL_LOCK_TIME,
59         INTERNAL_LOCK_USB,
60         INTERNAL_LOCK_POWEROFF,
61         INTERNAL_LOCK_COOL_DOWN,
62 };
63
64 #define SIGNAL_NAME_LCD_CONTROL         "lcdcontol"
65
66 #define LCD_NORMAL      0x1             /**< NORMAL state */
67 #define LCD_DIM         0x2             /**< LCD dimming state */
68 #define LCD_OFF         0x4             /**< LCD off state */
69 #define SUSPEND         0x8             /**< Suspend state */
70 #define POWER_OFF       0x16    /**< Sleep state */
71
72 #define STAY_CUR_STATE  0x1
73 #define GOTO_STATE_NOW  0x2
74 #define HOLD_KEY_BLOCK  0x4
75 #define STANDBY_MODE    0x8
76
77 #define PM_SLEEP_MARGIN 0x0     /**< keep guard time for unlock */
78 #define PM_RESET_TIMER  0x1     /**< reset timer for unlock */
79 #define PM_KEEP_TIMER           0x2     /**< keep timer for unlock */
80
81 #define PM_LOCK_STR     "lock"
82 #define PM_UNLOCK_STR   "unlock"
83 #define PM_CHANGE_STR   "change"
84
85 #define PM_LCDOFF_STR   "lcdoff"
86 #define PM_LCDDIM_STR   "lcddim"
87 #define PM_LCDON_STR    "lcdon"
88 #define PM_SUSPEND_STR  "suspend"
89
90 #define STAYCURSTATE_STR "staycurstate"
91 #define GOTOSTATENOW_STR "gotostatenow"
92
93 #define HOLDKEYBLOCK_STR "holdkeyblock"
94 #define STANDBYMODE_STR  "standbymode"
95
96 #define SLEEP_MARGIN_STR "sleepmargin"
97 #define RESET_TIMER_STR  "resettimer"
98 #define KEEP_TIMER_STR   "keeptimer"
99
100 typedef struct {
101         pid_t pid;
102         unsigned int cond;
103         unsigned int timeout;
104         unsigned int timeout2;
105 } PMMsg;
106
107 typedef struct {
108         char *dev_path;
109         int fd;
110         Ecore_Fd_Handler *dev_fd;
111         int pre_install;
112 } indev;
113
114 Eina_List *indev_list;
115
116 PMMsg recv_data;
117 int (*g_pm_callback) (int, PMMsg *);
118
119 extern int init_pm_poll(int (*pm_callback) (int, PMMsg *));
120 extern int exit_pm_poll();
121 extern int init_pm_poll_input(int (*pm_callback)(int , PMMsg * ), const char *path);
122
123 extern int pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout);
124 extern int pm_unlock_internal(pid_t pid, int s_bits, int flag);
125 extern int pm_change_internal(pid_t pid, int s_bits);
126
127 /**
128  * @}
129  */
130
131 #endif                          /*__PM_POLL_H__ */