display: display-state-transition: Relocate fuctions related to transition timer...
[platform/core/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 "setting.h"
29 #include "display.h"
30 #include "display-config.h"
31
32 #define WITHOUT_STARTNOTI       0x1
33 #define MASK_BIT    0x7         /* 111 */
34 #define MASK_NORMAL 0x1         /* 001 */
35 #define MASK_DIM    0x2         /* 010 */
36 #define MASK_OFF    0x4         /* 100 */
37
38 #define DEFAULT_NORMAL_TIMEOUT  30
39
40 #define DIM_MASK                0x000f0000
41 #define MASK32                  0xffffffff
42
43 #define CHECK_OPS(d, op) (d != NULL && d->op != NULL)
44
45 #ifdef ENABLE_PM_LOG
46 #include "power/power-suspend.h"
47 #define MAX_LOG_COUNT 250
48 #endif
49
50 /*
51  * State enumeration
52  */
53 enum state_t {
54         S_START,
55         S_NORMAL,               /*< normal state */
56         S_LCDON = S_NORMAL, /*< LCD on == normal state*/
57         S_LCDDIM,               /*< LCD dimming */
58         S_LCDOFF,               /*< LCD off */
59         S_STANDBY,              /*< Standby */
60         S_SLEEP,                /*< system suspend */
61         S_SUSPEND = S_SLEEP, /*< Suspend == Sleep state */
62         S_POWEROFF,             /*< Power off */
63         S_END
64 };
65
66 /*
67  * @brief State structure
68  */
69 struct state {
70         enum state_t state;           /**< state number */
71         const char *name;                   /**< state name (string) */
72         int (*trans) (int evt);       /**< transition function pointer */
73         int (*action) (int timeout);  /**< enter action */
74         int (*check) (int curr, int next); /**< transition check function */
75         GSourceFunc timeout_cb;
76         int timeout;
77 };
78
79 struct state *state_st(enum state_t state);
80
81 /*
82  * Global variables
83  *   display_conf : configuration of display
84  */
85 const struct display_config* get_var_display_config();
86
87 /*
88  * @brief Display Extension features
89  */
90 struct display_function_info {
91         void (*update_auto_brightness)(bool);
92         int (*set_autobrightness_min)(int, char *);
93         GBusNameAppearedCallback reset_autobrightness_min;
94         int (*face_detection)(int, int, int);
95         void (*set_brightness_level)(int);
96 };
97
98 extern struct display_function_info display_info;
99
100 struct display_keyfilter_ops {
101         void (*init)(void);
102         void (*exit)(void);
103         int (*check)(void *, int);
104         void (*set_powerkey_ignore)(int);
105         int (*powerkey_lcdoff)(void);
106         void (*backlight_enable)(bool);
107 };
108
109 extern const struct display_keyfilter_ops *keyfilter_ops;
110
111 typedef struct {
112         pid_t pid;
113         unsigned int cond;
114         unsigned int timeout;
115         unsigned int timeout2;
116 } PMMsg;
117 extern int poll_callback(int condition, PMMsg *data);
118
119 /* If the bit in a condition variable is set,
120  *  we cannot transit the state until clear this bit. */
121 int check_processes(enum state_t prohibit_state);
122 extern struct state state[S_END];
123 void reset_lcd_timeout(GDBusConnection *conn,
124                                                 const gchar *sender,
125                                                 const gchar *unique_name,
126                                                 gpointer data);
127
128 /* setting.c */
129 int get_lock_screen_bg_state(void);
130 int set_custom_lcdon_timeout(int timeout);
131 void set_lock_screen_state(int state);
132 void set_lock_screen_bg_state(bool state);
133
134 /* core.c */
135 int delete_condition(enum state_t state);
136 int custom_lcdoff(enum device_flags flag);
137 int display_on_by_reason(const char *reason, int timeout);
138 int display_off_by_reason(const char *reason);
139 void update_lcdoff_source(int source);
140 int set_lcd_timeout(int on, int dim, int holdkey_block, const char *name);
141 void save_display_log(const char *path);
142 int custom_lcdon(int timeout);
143 void lcd_on_direct(enum device_flags flags);
144 void lcd_on_procedure(int state, enum device_flags flag);
145 void lcd_off_procedure(enum device_flags flag);
146 bool touch_event_blocked(void);
147 void broadcast_lcd_off_late(enum device_flags flags);
148 void set_dim_state(bool on);
149
150 /* auto-brightness.c */
151 void set_brightness_changed_state(void);
152
153 /* poll.c */
154 int check_dimstay(int next_state, int flag);
155
156 /* display-dbus.c */
157 int init_pm_dbus(void);
158
159 /* slave-logging.c */
160 int save_pmlock(enum state_t state, bool on, pid_t pid);
161
162 /**
163  * @}
164  */
165
166 #endif