1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 #ifndef _LIBSUSPEND_AUTOSUSPEND_H_
18 #define _LIBSUSPEND_AUTOSUSPEND_H_
19 
20 #include <sys/cdefs.h>
21 #include <stdbool.h>
22 
23 __BEGIN_DECLS
24 
25 /*
26  * autosuspend_enable
27  *
28  * Turn on autosuspend in the kernel, allowing it to enter suspend if no
29  * wakelocks/wakeup_sources are held.
30  *
31  *
32  *
33  * Returns 0 on success, -1 if autosuspend was not enabled.
34  */
35 int autosuspend_enable(void);
36 
37 /*
38  * autosuspend_disable
39  *
40  * Turn off autosuspend in the kernel, preventing suspend and synchronizing
41  * with any in-progress resume.
42  *
43  * Returns 0 on success, -1 if autosuspend was not disabled.
44  */
45 int autosuspend_disable(void);
46 
47 /*
48  * force_suspend
49  *
50  * Forces suspend to happen.  timeout_ms is used to give system a chance to suspend gracefully.
51  * When timeout expires, suspend will be forced via mem --> /sys/power/state.  timeout_ms of 0
52  * will force suspend immediately.
53  *
54  * Returns 0 if system suspended, -1 if suspend did not occur.
55  */
56 int autosuspend_force_suspend(int timeout_ms);
57 
58 /*
59  * set_wakeup_callback
60  *
61  * Set a function to be called each time the device returns from suspend.
62  * success is true if the suspend was sucessful and false if the suspend
63  * aborted due to some reason.
64  */
65 void autosuspend_set_wakeup_callback(void (*func)(bool success));
66 
67 __END_DECLS
68 
69 #endif
70