Remove initscripts and add PIDFile to service file
[platform/core/system/power-manager.git] / pm_core.h
1 /*
2  * power-manager
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16 */
17
18
19 /**
20  * @file        pm_core.h
21  * @author      Suchang Woo (suchang.woo@samsung.com)
22  * @modified by Wonil Choi (wonil22.choi@samsung.com)
23  * @version     0.2
24  * @brief        Power manager main loop header file
25  */
26 #ifndef __POWER_MANAGER_H__
27 #define __POWER_MANAGER_H__
28
29 #include "util.h"
30 #include "pm_poll.h"
31 #include "pm_llinterface.h"
32 #include "pm_setting.h"
33 #include "pm_conf.h"
34
35 #define WITHOUT_STARTNOTI       0x1
36 #define MASK_BIT 0x7            /* 111 */
37 #define MASK_DIM 0x1            /* 001 */
38 #define MASK_OFF 0x2            /* 010 */
39 #define MASK_SLP 0x4            /* 100 */
40
41 #define VCALL_FLAG              0x00000001
42 #define LOWBT_FLAG              0x00000100
43 #define CHRGR_FLAG              0x00000200
44 #define PWRSV_FLAG              0x00000400
45 #define BRTCH_FLAG              0x00002000
46
47 #define TOLERANCE_SLOT          2
48
49 unsigned int status_flag;
50
51 /*
52  * State enumeration
53  */
54 enum state_t {
55         S_START = 0,
56         S_NORMAL,               /*< normal state */
57         S_LCDDIM,               /*< LCD dimming */
58         S_LCDOFF,               /*< LCD off */
59         S_SLEEP,                /*< system suspend */
60         S_END
61 };
62
63 /* 
64  * Global variables
65  *   cur_state   : current state
66  *   states      : state definitions
67  *   trans_table : state transition table
68  */
69 int cur_state;
70 int old_state;
71
72 /*
73  * @brief State structure
74  */
75 struct state {
76         enum state_t state;                                     /**< state number */
77         int (*trans) (int evt);         /**< transition function pointer */
78         int (*action) (int timeout);    /**< enter action */
79         int (*check) (int next);        /**< transition check function */
80         int timeout;
81 } states[S_END];
82
83 /* If the bit in a condition variable is set, 
84  *  we cannot transit the state until clear this bit. */
85 int trans_condition;
86 pid_t idle_pid;
87 int (*pm_init_extention) (void *data);          /**< extention init function */
88 void (*pm_exit_extention) (void);               /**< extention exit function */
89 int check_processes(enum state_t prohibit_state);
90
91 /*
92  * Power manager Main loop
93  *
94  * @internal
95  * @param[in] flags If the first bit of this is set, start managing without Start notification.
96  *                                      If the second bit of ths is set, use unified device manager functions.
97  */
98 void start_main(unsigned int flags);
99
100 /**
101  * @}
102  */
103
104 #endif