power: refactor power operations
[platform/core/system/deviced.git] / src / power / power-control.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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 #ifndef __POWER_CONTROL_H__
20 #define __POWER_CONTROL_H__
21
22 #include "display/core.h"
23
24 #define POWER_AUTOSLEEP_PATH    "/sys/power/autosleep"
25 #define POWER_LOCK_PATH         "/sys/power/wake_lock"
26 #define POWER_UNLOCK_PATH       "/sys/power/wake_unlock"
27 #define POWER_WAKEUP_PATH       "/sys/power/wakeup_count"
28 #define POWER_STATE_PATH        "/sys/power/state"
29
30 #define FREEZER_VITAL_WAKEUP_CGROUP "/sys/fs/cgroup/freezer/vital_wakeup/freezer.state"
31
32 #define SET_SUSPEND_TIME                0.5
33
34 enum mainlock_state {
35         POWER_UNLOCK = 0,
36         POWER_LOCK,
37 };
38
39 /*
40  * Vital state enumeration
41  */
42 enum vital_state {
43         VITAL_SLEEP,    /* suspend state */
44         VITAL_WAKEUP,   /* resume state */
45         VITAL_DISPLAY_WAKEUP,
46         VITAL_EXIT,
47 };
48
49 enum pm_log_type {
50         PM_LOG_MIN = 0,
51         PM_LOG_KEY_PRESS = PM_LOG_MIN,  /* key log */
52         PM_LOG_KEY_LONG_PRESS,
53         PM_LOG_KEY_RELEASE,
54         PM_LOG_LCD_ON,                  /* lcd log */
55         PM_LOG_LCD_ON_COMPLETE,
56         PM_LOG_LCD_ON_FAIL,
57         PM_LOG_LCD_DIM,
58         PM_LOG_LCD_DIM_FAIL,
59         PM_LOG_LCD_OFF,
60         PM_LOG_LCD_OFF_COMPLETE,
61         PM_LOG_LCD_OFF_FAIL,
62         PM_LOG_LCD_CONTROL_FAIL,
63         PM_LOG_SLEEP,
64         PM_LOG_MAX
65 };
66
67
68 extern bool timeout_sleep_support;
69
70 #ifdef ENABLE_PM_LOG
71 void pm_history_init(void);
72 void pm_history_save(enum pm_log_type log_type, int code);
73 void pm_history_print(int fd, int count);
74 #endif
75 bool vital_mode(void);
76 int vital_state_changed(void *data);
77 int pm_suspend(void);
78 int power_enable_autosleep(void);
79 int power_disable_autosleep(void);
80 int power_acquire_wakelock(void);
81 int power_release_wakelock(void);
82 int pm_get_power_lock(void);
83 int pm_get_power_lock_support(void);
84 int check_wakeup_src(void);
85 int get_wakeup_count(int *cnt);
86 int set_wakeup_count(int cnt);
87 int suspend_other_process(int type);
88 #endif /* __POWER_CONTROL_H__ */