le_pm_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_pm Power Manager
14  *
15  * @ref le_pm_interface.h "API Reference"
16  *
17  * <HR>
18  *
19  * Components need access to the Power Manager to control the system's wake-up state.
20  * Operations that need fast response times (e.g., maintaining call state or playing/recording a
21  * media stream) result in high interrupt rates; keeping the system awake results in better performance
22  * and power efficiency.
23  *
24  * Power Manager uses kernel wakeup sources to keep the system awake when at least one of the
25  * registered components requests a wakeup source to be held. When all wakeup sources are
26  * released, the system may enter a suspend state depending on the status of other (unrelated) wakeup
27  * sources.
28  *
29  * @section le_pm_binding IPC interfaces binding
30  *
31  * All the functions of this API are provided by the @b powerMgr service.
32  *
33  * Here's a code sample binding to Power Manager services:
34  * @verbatim
35  bindings:
36  {
37  clientExe.clientComponent.le_pm -> powerMgr.le_pm
38  }
39  @endverbatim
40  *
41  * @section le_pm_request Requesting and releasing a wakeup source
42  *
43  * The Power Manager service provides basic API for requesting and releasing a wakeup source.
44  * Power Manager's clients call @c le_pm_NewWakeupSource() to create a wakeup source. This function
45  * returns a @ref le_pm_WakeupSourceRef_t type that can later be used to acquire and release a
46  * wakeup source through @c le_pm_StayAwake() and le_pm_Relax(), respectively. Wakeup sources
47  * are not reference-counted, which means multiple calls to le_pm_StayAwake() can be canceled
48  * by a single call to le_pm_Relax().
49  *
50  * To have a reference-counted wakeup-source, set the LE_PM_REF_COUNT bit in the opts argument.
51  * When this bit is set, each le_pm_StayAwake() increments a counter, and multiple calls to
52  * le_pm_Relax() is necessary to release the wakeup source.
53  *
54  * Power Manager service will automatically release and delete all wakeup sources held on behalf
55  * of an exiting or disconnecting client.
56  *
57  * For deterministic behaviour, clients requesting services of Power Manager should have
58  * CAP_EPOLLWAKEUP (or CAP_BLOCK_SUSPEND) capability assigned.
59  *
60  * <HR>
61  *
62  * Copyright (C) Sierra Wireless Inc.
63  */
64 /**
65  * @file le_pm_interface.h
66  *
67  * Legato @ref c_pm include file.
68  *
69  * Copyright (C) Sierra Wireless Inc.
70  */
71 /**
72  * Some useful constants
73  */
74 
75 #ifndef LE_PM_INTERFACE_H_INCLUDE_GUARD
76 #define LE_PM_INTERFACE_H_INCLUDE_GUARD
77 
78 
79 #include "legato.h"
80 
81 
82 //--------------------------------------------------------------------------------------------------
83 /**
84  * Type for handler called when a server disconnects.
85  */
86 //--------------------------------------------------------------------------------------------------
87 typedef void (*le_pm_DisconnectHandler_t)(void *);
88 
89 //--------------------------------------------------------------------------------------------------
90 /**
91  *
92  * Connect the current client thread to the service providing this API. Block until the service is
93  * available.
94  *
95  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
96  * called before any other functions in this API. Normally, ConnectService is automatically called
97  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
98  *
99  * This function is created automatically.
100  */
101 //--------------------------------------------------------------------------------------------------
103 (
104  void
105 );
106 
107 //--------------------------------------------------------------------------------------------------
108 /**
109  *
110  * Try to connect the current client thread to the service providing this API. Return with an error
111  * if the service is not available.
112  *
113  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
114  * called before any other functions in this API. Normally, ConnectService is automatically called
115  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
116  *
117  * This function is created automatically.
118  *
119  * @return
120  * - LE_OK if the client connected successfully to the service.
121  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
122  * bound.
123  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
124  * - LE_COMM_ERROR if the Service Directory cannot be reached.
125  */
126 //--------------------------------------------------------------------------------------------------
128 (
129  void
130 );
131 
132 //--------------------------------------------------------------------------------------------------
133 /**
134  * Set handler called when server disconnection is detected.
135  *
136  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
137  * to continue without exiting, it should call longjmp() from inside the handler.
138  */
139 //--------------------------------------------------------------------------------------------------
141 (
142  le_pm_DisconnectHandler_t disconnectHandler,
143  void *contextPtr
144 );
145 
146 //--------------------------------------------------------------------------------------------------
147 /**
148  *
149  * Disconnect the current client thread from the service providing this API.
150  *
151  * Normally, this function doesn't need to be called. After this function is called, there's no
152  * longer a connection to the service, and the functions in this API can't be used. For details, see
153  * @ref apiFilesC_client.
154  *
155  * This function is created automatically.
156  */
157 //--------------------------------------------------------------------------------------------------
159 (
160  void
161 );
162 
163 
164 //--------------------------------------------------------------------------------------------------
165 /**
166  * Maximum string length for a wake-up source tag (not including the null-terminator)
167  */
168 //--------------------------------------------------------------------------------------------------
169 #define LE_PM_TAG_LEN 31
170 
171 //--------------------------------------------------------------------------------------------------
172 /**
173  * Maximum string length for a wake-up source tag (including the null-terminator)
174  */
175 //--------------------------------------------------------------------------------------------------
176 #define LE_PM_TAG_LEN_BYTES 32
177 
178 //--------------------------------------------------------------------------------------------------
179 /**
180  * Option LE_PM_REF_COUNT to manage a reference counted wakeup source
181  */
182 //--------------------------------------------------------------------------------------------------
183 #define LE_PM_REF_COUNT 1
184 
185 //--------------------------------------------------------------------------------------------------
186 /**
187  * Reference to wakeup source used by StayAwake and Relax function
188  */
189 //--------------------------------------------------------------------------------------------------
190 typedef struct le_pm_WakeupSource* le_pm_WakeupSourceRef_t;
191 
192 
193 //--------------------------------------------------------------------------------------------------
194 /**
195  * Create a wakeup source
196  *
197  * @return
198  * - Reference to wakeup source (to be used later for acquiring/releasing)
199  *
200  * @note The process exits if an invalid or existing tag is passed
201  */
202 //--------------------------------------------------------------------------------------------------
204 (
205  uint32_t createOpts,
206  ///< [IN] Wakeup source options
207  const char* LE_NONNULL wsTag
208  ///< [IN] Context-specific wakeup source tag
209 );
210 
211 //--------------------------------------------------------------------------------------------------
212 /**
213  * Acquire a wakeup source
214  *
215  */
216 //--------------------------------------------------------------------------------------------------
217 void le_pm_StayAwake
218 (
220  ///< [IN] Reference to a created wakeup source
221 );
222 
223 //--------------------------------------------------------------------------------------------------
224 /**
225  * Release a previously acquired wakeup source
226  *
227  */
228 //--------------------------------------------------------------------------------------------------
229 void le_pm_Relax
230 (
232  ///< [IN] Reference to a created wakeup source
233 );
234 
235 #endif // LE_PM_INTERFACE_H_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:35
void le_pm_DisconnectService(void)
void le_pm_ConnectService(void)
void(* le_pm_DisconnectHandler_t)(void *)
Definition: le_pm_interface.h:87
void le_pm_StayAwake(le_pm_WakeupSourceRef_t wsRef)
le_pm_WakeupSourceRef_t le_pm_NewWakeupSource(uint32_t createOpts, const char *LE_NONNULL wsTag)
void le_pm_Relax(le_pm_WakeupSourceRef_t wsRef)
le_result_t le_pm_TryConnectService(void)
void le_pm_SetServerDisconnectHandler(le_pm_DisconnectHandler_t disconnectHandler, void *contextPtr)
struct le_pm_WakeupSource * le_pm_WakeupSourceRef_t
Definition: le_pm_interface.h:190