4 * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @brief Power manager main loop header file
24 #ifndef __POWER_MANAGER_H__
25 #define __POWER_MANAGER_H__
30 #include "display-config.h"
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 */
38 #define DEFAULT_NORMAL_TIMEOUT 30
40 #define DIM_MASK 0x000f0000
41 #define MASK32 0xffffffff
43 #define CHECK_OPS(d, op) (d != NULL && d->op != NULL)
46 #include "power/power-suspend.h"
47 #define MAX_LOG_COUNT 250
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 */
67 * @brief State structure
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;
79 struct state *state_st(enum state_t state);
83 * display_conf : configuration of display
85 const struct display_config* get_var_display_config();
88 * @brief Display Extension features
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);
98 extern struct display_function_info display_info;
100 struct display_keyfilter_ops {
103 int (*check)(void *, int);
104 void (*set_powerkey_ignore)(int);
105 int (*powerkey_lcdoff)(void);
106 void (*backlight_enable)(bool);
109 extern const struct display_keyfilter_ops *keyfilter_ops;
114 unsigned int timeout;
115 unsigned int timeout2;
117 extern int poll_callback(int condition, PMMsg *data);
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,
125 const gchar *unique_name,
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);
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);
150 /* auto-brightness.c */
151 void set_brightness_changed_state(void);
154 int check_dimstay(int next_state, int flag);
157 int init_pm_dbus(void);
159 /* slave-logging.c */
160 int save_pmlock(enum state_t state, bool on, pid_t pid);