Deep Sleep Manager HAL 0.2.0
 
Loading...
Searching...
No Matches
deepSleepMgr.h
Go to the documentation of this file.
1/*
2 * If not stated otherwise in this file or this component's LICENSE file the
3 * following copyright and licenses apply:
4 *
5 * Copyright 2016 RDK Management
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18*/
19
20/**
21 * @addtogroup HPK Hardware Porting Kit
22 * @{
23 * @par The Hardware Porting Kit
24 * HPK is the next evolution of the well-defined Hardware Abstraction Layer
25 * (HAL), but augmented with more comprehensive documentation and test suites
26 * that OEM or SOC vendors can use to self-certify their ports before taking
27 * them to RDKM for validation or to an operator for final integration and
28 * deployment. The Hardware Porting Kit effectively enables an OEM and/or SOC
29 * vendor to self-certify their own Video Accelerator devices, with minimal RDKM
30 * assistance.
31 *
32 */
33
34/**
35 * @defgroup Deepsleep_Manager Deep Sleep Manager
36 * @{
37 * @par Application API Specification
38 * Deep sleep is a power saving mode which turns off STB
39 * subsystems such as A/V, HDMI, front panels, HDD etc.
40 * Provides API defines the structures and functions for the Deep Sleep Manager HAL.
41 * - The main purpose is to bring down the power consumption based on the actual usage
42 * - It can also be triggered in other scenarios such as
43 * thermal shutdown in case of the temperature is above threshold for certain period.
44 * - When the STB goes in a normal power saving mode, it may be woken up
45 * for scheduled maintenance ina predetermined time.
46 */
47
48/**
49 * @defgroup Deepsleep_Manager_HAL Deep Sleep Manager HAL
50 * @{
51 */
52
53/**
54 * @defgroup Deepsleep_Mgr_H Deep Sleep Manager Header
55 * @{
56 */
57
58
59/**
60 * @file deepSleepMgr.h
61 *
62 * @brief Deep Sleep Manager HAL Public API
63 *
64 * This API defines the structures and functions for the Deep Sleep Manager HAL
65 *
66 * @par Abbreviations
67 * - HAL: Hardware Abstraction Layer
68 * - CPE: Customer Premises Equipment
69 * - IR: Infra-Red
70 * - CEC: Consumer Electronic Control
71 * - LAN: Local Area Network
72 * - WLAN: Wireless Local Area Network
73 * - STB: Set-top Box
74 * - RCU: Remote Control Unit
75 * - STR: Suspend To RAM
76 * - HDMI: High-Definition Multimedia Interface
77 * - GPIO: General Purpose Input/Output
78 * - RCU: Remote Control Unit
79 * - BT: Bluetooth
80 * - RF4CE: Radio Frequency for Consumer Electronics
81 */
82
83
84#ifndef _IARM_BUS_DEEPSLEEPMGR_H
85#define _IARM_BUS_DEEPSLEEPMGR_H
86
87#include "libIARM.h"
88#include "libIBusDaemon.h"
89
90
91#ifdef __cplusplus
92extern "C"
93{
94#endif
95
96#define IARM_BUS_DEEPSLEEPMGR_NAME "DEEPSLEEPMgr" /*!< Power manager IARM bus name */
97
98typedef enum _DeepSleepStatus_t {
99 DeepSleepStatus_Failed = -1, /*!< Deepsleep operation failed*/
100 DeepSleepStatus_NotStarted = 0, /*!< Deepsleep operation not started*/
101 DeepSleepStatus_InProgress, /*!< Deepsleep operation in progress */
102 DeepSleepStatus_Completed, /*!< Deepsleep operation completed */
104
105/*
106 * Declare RPC API names and their arguments
107 */
108#ifdef ENABLE_DEEP_SLEEP
109
110/**
111 * @brief Initializes the underlying Deep Sleep Management module
112 *
113 * @return Returns the status of the operation.
114 * @retval 0 if successful, -1 if failure.
115 */
116int PLAT_DS_INIT(void);
117
118/**
119 * @brief Sets the CPE's Power State to Deep Sleep
120 *
121 * @param [in] deep_sleep_timeout - The deep sleep wakeup timeout. Min value 0
122 * @param [out] isGPIOWakeup - Wakeup reason. TRUE for user related wake up, false for not
123 *
124 * @return Returns the status of the operation.
125 * @retval 0 if successful, -1 if failure.
126 *
127 * @note if deep_sleep_timeout is set 0, external intervention to wake up is required. @see DeepSleep_WakeupReason_t
128 *
129 * @pre PLAT_DS_INIT() must be called before calling this API
130 * @post PLAT_DS_DeepSleepWakeup() must be called after calling this API
131 *
132 * @warning This API is Not thread safe
133 *
134 */
135int PLAT_DS_SetDeepSleep(uint32_t deep_sleep_timeout, bool *isGPIOWakeup);
136
137/**
138 * @brief Sets or configures the platform status after deepsleep wake-up
139 *
140 * @pre PLAT_DS_INIT() must be called before calling this API
141 *
142 * @note Calling this API before PLAT_DS_SetDeepSleep() should not result in any unexpected behavior
143 *
144 * @warning This API is Not thread safe
145 *
146 */
148
149/**
150 * @brief Terminates the CPE Deep Sleep Management module.
151 *
152 * All data structures used within Deep Sleep Management module must be reset and any
153 * Deep Sleep Management specific handles and resources must be released
154 */
155void PLAT_DS_TERM(void);
156
157/** Sets the timer for deep sleep ,timer is set explicitly by client of deep sleep manager,
158 * then the STB will accept the timer value, and go to sleep when sleep timer is expired.
159 */
160#define IARM_BUS_DEEPSLEEPMGR_API_SetDeepSleepTimer "SetDeepSleepTimer"
161#define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupReason "GetLastWakeupReason"
162#define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupKeyCode "GetLastWakeupKeycode"
163
164/**
165 * @brief Structure which holds the HAL timeout in seconds
166 */
168 unsigned int timeout; /*!< Timeout for deep sleep in seconds*/
170
171/**
172 * @brief Enum for all possible Wakeup Reasons from DeepSleep State
173 */
175{
176 DEEPSLEEP_WAKEUPREASON_IR = 0, /*!< Deepsleep Wakeup Reason is IR Remote event */
177 DEEPSLEEP_WAKEUPREASON_RCU_BT, /*!< Deepsleep Wakeup Reason is RCU Bluetooth Remote event */
178 DEEPSLEEP_WAKEUPREASON_RCU_RF4CE, /*!< Deepsleep Wakeup Reason is RCU RF4CE Remote event */
179 DEEPSLEEP_WAKEUPREASON_GPIO, /*!< Deepsleep Wakeup Reason is GPIO event */
180 DEEPSLEEP_WAKEUPREASON_LAN, /*!< Deepsleep Wakeup Reason is LAN event */
181 DEEPSLEEP_WAKEUPREASON_WLAN, /*!< Deepsleep Wakeup Reason is Wireless LAN event */
182 DEEPSLEEP_WAKEUPREASON_TIMER, /*!< Deepsleep Wakeup Reason is Clock Timer event */
183 DEEPSLEEP_WAKEUPREASON_FRONT_PANEL, /*!< Deepsleep Wakeup Reason is Front Panel Button event */
184 DEEPSLEEP_WAKEUPREASON_WATCHDOG, /*!< Deepsleep Wakeup Reason is Watchdog Timer event */
185 DEEPSLEEP_WAKEUPREASON_SOFTWARE_RESET, /*!< Deepsleep Wakeup Reason is S/W Reset */
186 DEEPSLEEP_WAKEUPREASON_THERMAL_RESET, /*!< Deepsleep Wakeup Reason is Thermal Reset event */
187 DEEPSLEEP_WAKEUPREASON_WARM_RESET, /*!< Deepsleep Wakeup Reason is Warm Temperature Reset event */
188 DEEPSLEEP_WAKEUPREASON_COLDBOOT, /*!< Deepsleep Wakeup Reason is Cold Boot event */
189 DEEPSLEEP_WAKEUPREASON_STR_AUTH_FAILURE, /*!< Deepsleep Wakeup Reason is STR Authentication Failure event */
190 DEEPSLEEP_WAKEUPREASON_CEC, /*!< Deepsleep Wakeup Reason is HDMI CEC Failure event */
191 DEEPSLEEP_WAKEUPREASON_PRESENCE, /*!< Deepsleep Wakeup Reason is Motion Detection event */
192 DEEPSLEEP_WAKEUPREASON_VOICE, /*!< Deepsleep Wakeup Reason is User Voice event */
193 DEEPSLEEP_WAKEUPREASON_UNKNOWN /*!< Deepsleep Wakeup Reason is Unknown Reason event */
195
196/**
197 * @brief Struct for handling the wake up key code
198 *
199 * The wake up key code is used to identify the wakeup reason.
200 *
201 */
205
206/**
207 * @brief Gets the CPE's Last wakeup reason
208 *
209 *
210 * @param [out] wakeupReason - Reason for CPE's last wake up
211 *
212 * @return Returns the status of the operation.
213 * @retval 0 if successful, -1 if failure.
214 *
215 * @pre PLAT_DS_INIT() must be called before calling this API
216 *
217 * @warning This API is Not thread safe
218 *
219 * @see PLAT_DS_GetLastWakeupKeyCode(), DeepSleep_WakeupReason_t
220 *
221 */
223
224/**
225 * @brief Gets the CPE's Last wakeup key code
226 *
227 * @param [out] wakeupKeyCode - The user wakeup code
228 *
229 * @return Returns the status of the operation.
230 * @retval 0 if successful, -1 if failure.
231 *
232 * @pre PLAT_DS_INIT() must be called before calling this API
233 *
234 * @warning This API is Not thread safe
235 *
236 * @note Caller is responsible for validating the returned keycode
237 *
238 * @see PLAT_DS_GetLastWakeupReason(), DeepSleepMgr_WakeupKeyCode_Param_t
239 *
240 */
242#endif
243
244#ifdef __cplusplus
245}
246#endif
247#endif
248
249/** @} */ // End of Deepsleep_Mgr_H
250/** @} */ // End of Deepsleep_Manager_HAL
251/** @} */ // End Deepsleep_Manager
252/** @} */ // End of HPK
enum _DeepSleep_WakeupReason_t DeepSleep_WakeupReason_t
Enum for all possible Wakeup Reasons from DeepSleep State.
int PLAT_DS_INIT(void)
Initializes the underlying Deep Sleep Management module.
void PLAT_DS_DeepSleepWakeup(void)
Sets or configures the platform status after deepsleep wake-up.
_DeepSleep_WakeupReason_t
Enum for all possible Wakeup Reasons from DeepSleep State.
Definition deepSleepMgr.h:175
int PLAT_DS_SetDeepSleep(uint32_t deep_sleep_timeout, bool *isGPIOWakeup)
Sets the CPE's Power State to Deep Sleep.
int PLAT_DS_GetLastWakeupKeyCode(IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t *wakeupKeyCode)
Gets the CPE's Last wakeup key code.
void PLAT_DS_TERM(void)
Terminates the CPE Deep Sleep Management module.
int PLAT_DS_GetLastWakeupReason(DeepSleep_WakeupReason_t *wakeupReason)
Gets the CPE's Last wakeup reason.
struct _IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t
Struct for handling the wake up key code.
struct _IARM_Bus_DeepSleepMgr_SetDeepSleepTimer_Param_t IARM_Bus_DeepSleepMgr_SetDeepSleepTimer_Param_t
Structure which holds the HAL timeout in seconds.
enum _DeepSleepStatus_t DeepSleepStatus_t
_DeepSleepStatus_t
Definition deepSleepMgr.h:98
@ DEEPSLEEP_WAKEUPREASON_WARM_RESET
Definition deepSleepMgr.h:187
@ DEEPSLEEP_WAKEUPREASON_VOICE
Definition deepSleepMgr.h:192
@ DEEPSLEEP_WAKEUPREASON_CEC
Definition deepSleepMgr.h:190
@ DEEPSLEEP_WAKEUPREASON_UNKNOWN
Definition deepSleepMgr.h:193
@ DEEPSLEEP_WAKEUPREASON_COLDBOOT
Definition deepSleepMgr.h:188
@ DEEPSLEEP_WAKEUPREASON_IR
Definition deepSleepMgr.h:176
@ DEEPSLEEP_WAKEUPREASON_LAN
Definition deepSleepMgr.h:180
@ DEEPSLEEP_WAKEUPREASON_STR_AUTH_FAILURE
Definition deepSleepMgr.h:189
@ DEEPSLEEP_WAKEUPREASON_WATCHDOG
Definition deepSleepMgr.h:184
@ DEEPSLEEP_WAKEUPREASON_GPIO
Definition deepSleepMgr.h:179
@ DEEPSLEEP_WAKEUPREASON_RCU_BT
Definition deepSleepMgr.h:177
@ DEEPSLEEP_WAKEUPREASON_TIMER
Definition deepSleepMgr.h:182
@ DEEPSLEEP_WAKEUPREASON_THERMAL_RESET
Definition deepSleepMgr.h:186
@ DEEPSLEEP_WAKEUPREASON_FRONT_PANEL
Definition deepSleepMgr.h:183
@ DEEPSLEEP_WAKEUPREASON_WLAN
Definition deepSleepMgr.h:181
@ DEEPSLEEP_WAKEUPREASON_PRESENCE
Definition deepSleepMgr.h:191
@ DEEPSLEEP_WAKEUPREASON_RCU_RF4CE
Definition deepSleepMgr.h:178
@ DEEPSLEEP_WAKEUPREASON_SOFTWARE_RESET
Definition deepSleepMgr.h:185
@ DeepSleepStatus_Failed
Definition deepSleepMgr.h:99
@ DeepSleepStatus_InProgress
Definition deepSleepMgr.h:101
@ DeepSleepStatus_Completed
Definition deepSleepMgr.h:102
@ DeepSleepStatus_NotStarted
Definition deepSleepMgr.h:100
Structure which holds the HAL timeout in seconds.
Definition deepSleepMgr.h:167
unsigned int timeout
Definition deepSleepMgr.h:168
Struct for handling the wake up key code.
Definition deepSleepMgr.h:202
unsigned int keyCode
Definition deepSleepMgr.h:203