RDK Documentation (Open Sourced RDK Components)
deepSleepMgr.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt 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  * @defgroup IARMMGR_HAL HAL Types and Public API
22  * Described herein are the IARM-Bus HAL types and functions that are part of the Power
23  * Manager, Deep Sleep Manager and IR Manager applications.
24  * @ingroup IARM_MGR
25  *
26  * @defgroup IARM_DEEPSLEEP_MGR_API Deep Sleep Manager (HAL Types and Public API)
27  * Deep sleep is a power saving mode which turns off STB subsystems such as A/V, HDMI, front panels, HDD etc.
28  * Provides API defines the structures and functions for the IARM-Bus Deep Sleep Manager interface.
29  * - The main purpose is to bring down the power consumption to about 15% of the actual usage.
30  * - It can also be triggered in other scenarios such as thermal shutdown in case of the temperature
31  * is above threshold for certain period.
32  * - When the STB goes in a normal power saving mode, it may be woken up for scheduled maintenance in
33  * a predetermined time.
34  * @ingroup IARMMGR_HAL
35  */
36 
37 /**
38 * @defgroup iarmmgrs
39 * @{
40 * @defgroup hal
41 * @{
42 **/
43 
44 
45 #ifndef _IARM_BUS_DEEPSLEEPMGR_H
46 #define _IARM_BUS_DEEPSLEEPMGR_H
47 
48 #include "libIARM.h"
49 #include "libIBusDaemon.h"
50 
51 /**
52  * @addtogroup IARM_DEEPSLEEP_MGR_API
53  * @{
54  */
55 
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
61 #define IARM_BUS_DEEPSLEEPMGR_NAME "DEEPSLEEPMgr" /*!< Power manager IARM bus name */
62 
63 typedef enum _DeepSleepStatus_t {
64  DeepSleepStatus_Failed = -1, /*!< Deepsleep operation failed*/
65  DeepSleepStatus_NotStarted = 0, /*!< Deepsleep operation not started*/
66  DeepSleepStatus_InProgress, /*!< Deepsleep operation in progress */
67  DeepSleepStatus_Completed, /*!< Deepsleep operation completed */
68 } DeepSleepStatus_t;
69 
70 /*
71  * Declare RPC API names and their arguments
72  */
73 #ifdef ENABLE_DEEP_SLEEP
74 
75 /**
76  * @brief This API Initializes the underlying Deep Sleep Management module.
77  *
78  * @return Returns the status of the operation.
79  * @retval 0 if successful, appropiate error code otherwise.
80  */
81 int PLAT_DS_INIT(void);
82 
83 /**
84  * @brief This API is used to enter the CPE into Deep Sleep Mode.
85  *
86  * This function sets the CPE's Power State to Deep Sleep.
87  *
88  * @param [in] deep_sleep_timeout The deep sleep wakeup timeout.
89  *
90  * @return Return the status of the operation
91  */
92 int PLAT_DS_SetDeepSleep(uint32_t deep_sleep_timeout, bool *isGPIOWakeup, bool networkStandby);
93 
94 /**
95  * @brief This function wakes up the CPE from deep sleep mode.
96  */
97 void PLAT_DS_DeepSleepWakeup(void);
98 
99 /**
100  * @brief This function terminates the Deep Sleep manager.
101  *
102  * This function must terminate the CPE Deep Sleep Management module. It must reset any data
103  * structures used within Deep Sleep Management module and release any Deep Sleep Management
104  * specific handles and resources.
105  */
106 void PLAT_DS_TERM(void);
107 
108 /** Sets the timer for deep sleep ,timer is set explicitly by client of deep sleep manager,
109  * then the STB will accept the timer value, and go to sleep when sleep timer is expired.
110  */
111 #define IARM_BUS_DEEPSLEEPMGR_API_SetDeepSleepTimer "SetDeepSleepTimer"
112 #define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupReason "GetLastWakeupReason"
113 #define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupKeyCode "GetLastWakeupKeycode"
114 /**
115  * @brief Structure which holds the Deep sleep manager timeout.
116  */
117 typedef struct _IARM_Bus_DeepSleepMgr_SetDeepSleepTimer_Param_t {
118  unsigned int timeout; /*!< Timeout for deep sleep in seconds*/
119 } IARM_Bus_DeepSleepMgr_SetDeepSleepTimer_Param_t;
120 
121 typedef enum _DeepSleep_WakeupReason_t
122 {
123  DEEPSLEEP_WAKEUPREASON_IR = 0,
124  DEEPSLEEP_WAKEUPREASON_RCU_BT,
125  DEEPSLEEP_WAKEUPREASON_RCU_RF4CE,
126  DEEPSLEEP_WAKEUPREASON_GPIO,
127  DEEPSLEEP_WAKEUPREASON_LAN,
128  DEEPSLEEP_WAKEUPREASON_WLAN,
129  DEEPSLEEP_WAKEUPREASON_TIMER,
130  DEEPSLEEP_WAKEUPREASON_FRONT_PANEL,
131  DEEPSLEEP_WAKEUPREASON_WATCHDOG,
132  DEEPSLEEP_WAKEUPREASON_SOFTWARE_RESET,
133  DEEPSLEEP_WAKEUPREASON_THERMAL_RESET,
134  DEEPSLEEP_WAKEUPREASON_WARM_RESET,
135  DEEPSLEEP_WAKEUPREASON_COLDBOOT,
136  DEEPSLEEP_WAKEUPREASON_STR_AUTH_FAILURE,
137  DEEPSLEEP_WAKEUPREASON_CEC,
138  DEEPSLEEP_WAKEUPREASON_PRESENCE,
139  DEEPSLEEP_WAKEUPREASON_VOICE,
140  DEEPSLEEP_WAKEUPREASON_UNKNOWN
141 }DeepSleep_WakeupReason_t;
142 
143 typedef struct _IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t {
144  unsigned int keyCode;
145 } IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t;
146 
147 int PLAT_DS_GetLastWakeupReason(DeepSleep_WakeupReason_t *wakeupReason);
148 int PLAT_DS_GetLastWakeupKeyCode(IARM_Bus_DeepSleepMgr_WakeupKeyCode_Param_t *wakeupKeyCode);
149 /** @} */ //End of Doxygen tag
150 #endif
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 #endif
156 
157 /** @} */
158 /** @} */
DeepSleepStatus_Failed
@ DeepSleepStatus_Failed
Definition: deepSleepMgr.h:64
_DeepSleepStatus_t
_DeepSleepStatus_t
Definition: deepSleepMgr.h:63
DeepSleepStatus_NotStarted
@ DeepSleepStatus_NotStarted
Definition: deepSleepMgr.h:65
DeepSleepStatus_Completed
@ DeepSleepStatus_Completed
Definition: deepSleepMgr.h:67
DeepSleepStatus_InProgress
@ DeepSleepStatus_InProgress
Definition: deepSleepMgr.h:66