power: elevate iot-headless power plugin to core
[platform/core/system/deviced.git] / src / power / power-state-manager.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2022 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_STATE_MANAGER_H__
20 #define __POWER_STATE_MANAGER_H__
21
22 #include <stdio.h>
23 #include <libsyscommon/ini-parser.h>
24
25 #include "shared/log.h"
26
27 enum psm_state {
28         PSM_START,
29         PSM_NORMAL,
30         PSM_SLEEP,
31         PSM_POWEROFF,
32         PSM_REBOOT,
33         PSM_MAX,
34 };
35 extern char *psm_name[PSM_MAX];
36
37 struct trans_info {
38         int reason;
39         enum psm_state curr;
40         enum psm_state next;
41 };
42
43 typedef void (*psm_transfunc) (const struct trans_info *info);
44 void power_state_manager_init(void *data);
45
46 static inline enum psm_state convert_action_string_to_psm_state(const char *str)
47 {
48         if (MATCH(str, "start"))
49                 return PSM_START;
50         else if (MATCH(str, "sleep"))
51                 return PSM_SLEEP;
52         else if (MATCH(str, "normal"))
53                 return PSM_NORMAL;
54         else if (MATCH(str, "poweroff"))
55                 return PSM_POWEROFF;
56
57         _W("Invalid psm_state=%s", str);
58
59         return PSM_MAX;
60 }
61
62 #endif //__POWER_STATE_MANAGER_H__