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