tizen 2.3 release
[framework/system/deviced.git] / src / display / core.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        core.h
22  * @brief        Power manager main loop header file
23  */
24 #ifndef __POWER_MANAGER_H__
25 #define __POWER_MANAGER_H__
26
27 #include "poll.h"
28 #include "device-interface.h"
29 #include "setting.h"
30
31 #define WITHOUT_STARTNOTI       0x1
32 #define MASK_BIT 0x7            /* 111 */
33 #define MASK_DIM 0x1            /* 001 */
34 #define MASK_OFF 0x2            /* 010 */
35 #define MASK_SLP 0x4            /* 100 */
36
37 #define VCALL_FLAG              0x00000001
38 #define LOWBT_FLAG              0x00000100
39 #define CHRGR_FLAG              0x00000200
40 #define PWRSV_FLAG              0x00000400
41 #define SMAST_FLAG              0x00001000
42 #define BRTCH_FLAG              0x00002000
43 #define PWROFF_FLAG             0x00004000
44 #define DIMSTAY_FLAG            0x00008000
45
46 #define DEFAULT_NORMAL_TIMEOUT  30000
47 #define DEFAULT_DIM_TIMEOUT     5000
48 #define DEFAULT_OFF_TIMEOUT     1000
49
50 #define MASK32                  0xffffffff
51
52 #define CHECK_OPS(d, op) (d != NULL && d->op != NULL)
53
54 #ifdef ENABLE_PM_LOG
55 #define MAX_LOG_COUNT 250
56
57 enum pm_log_type {
58         PM_LOG_MIN = 0,
59         PM_LOG_KEY_PRESS = PM_LOG_MIN,  /* key log */
60         PM_LOG_KEY_LONG_PRESS,
61         PM_LOG_KEY_RELEASE,
62         PM_LOG_LCD_ON,                  /* lcd log */
63         PM_LOG_LCD_ON_FAIL,
64         PM_LOG_LCD_DIM,
65         PM_LOG_LCD_DIM_FAIL,
66         PM_LOG_LCD_OFF,
67         PM_LOG_LCD_OFF_FAIL,
68         PM_LOG_SLEEP,
69         PM_LOG_MAX
70 };
71
72 void pm_history_save(enum pm_log_type, int);
73 #endif
74
75 extern unsigned int pm_status_flag;
76
77 /*
78  * State enumeration
79  */
80 enum state_t {
81         S_START = 0,
82         S_NORMAL,               /*< normal state */
83         S_LCDDIM,               /*< LCD dimming */
84         S_LCDOFF,               /*< LCD off */
85         S_SLEEP,                /*< system suspend */
86         S_END
87 };
88
89 /*
90  * Global variables
91  *   pm_cur_state   : current state
92  *   states      : state definitions
93  *   trans_table : state transition table
94  */
95 int pm_cur_state;
96 int pm_old_state;
97
98 /*
99  * @brief State structure
100  */
101 struct state {
102         enum state_t state;                                     /**< state number */
103         int (*trans) (int evt);         /**< transition function pointer */
104         int (*action) (int timeout);    /**< enter action */
105         int (*check) (int next);        /**< transition check function */
106         int timeout;
107 } states[S_END];
108
109 /*
110  * @brief Configuration structure
111  */
112 struct display_config {
113         double lock_wait_time;
114         double longpress_interval;
115         double lightsensor_interval;
116         int lcdoff_timeout;
117         int brightness_change_step;
118         int hbm_lux_threshold;
119         int lcd_always_on;
120         int framerate_app[4];
121         int control_display;
122         int powerkey_doublepress;
123         int alpm_on;
124         int accel_sensor_on;
125         int continuous_sampling;
126 };
127
128 /*
129  * Global variables
130  *   display_conf : configuration of display
131  */
132 extern struct display_config display_conf;
133
134 /*
135  * @brief Display Extension features
136  */
137 struct display_function_info {
138         void (*update_auto_brightness)(bool);
139         int (*set_autobrightness_min)(int, char *);
140         int (*reset_autobrightness_min)(char *, enum watch_id);
141         int (*face_detection)(int, int, int);
142 };
143
144 extern struct display_function_info display_info;
145
146 struct display_keyfilter_ops {
147         void (*init)(void);
148         void (*exit)(void);
149         int (*check)(int, char[], int);
150         void (*set_powerkey_ignore)(int);
151         int (*powerkey_lcdoff)(void);
152         void (*backlight_enable)(bool);
153 };
154
155 extern const struct display_keyfilter_ops *keyfilter_ops;
156
157 /* If the bit in a condition variable is set,
158  *  we cannot transit the state until clear this bit. */
159 int trans_condition;
160 pid_t idle_pid;
161 int check_processes(enum state_t prohibit_state);
162 extern struct state state[S_END];
163 int reset_lcd_timeout(char *name, enum watch_id id);
164 int check_lcdoff_lock_state(void);
165 /**
166  * @}
167  */
168
169 #endif