RDK Documentation (Open Sourced RDK Components)
pwrMgr.h
Go to the documentation of this file.
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  * @file pwrMgr.h
22  *
23  * @brief IARM-Bus Power Manager Public API.
24  *
25  * This API defines the structures and functions for the IARM-Bus Power Manager interface.
26  */
27 
28 /**
29 * @defgroup iarmmgrs
30 * @{
31 * @defgroup hal
32 * @{
33 **/
34 
35 #ifndef _IARM_BUS_PWRMGR_H
36 #define _IARM_BUS_PWRMGR_H
37 
38 #include "libIARM.h"
39 #include "libIBusDaemon.h"
40 
41 #include <stdint.h>
42 #include <stdbool.h>
43 
44 #ifdef __cplusplus
45 extern "C"
46 {
47 #endif
48 
49 /**
50  * @addtogroup IARM_PLAT_POWER_API
51  * @{
52  */
53 
54 #define IARM_BUS_PWRMGR_NAME "PWRMgr" /*!< Power manager IARM bus name */
55 
56 /**
57  * @brief Represents the published Events from PWR Manager
58  */
59 typedef enum _PWRMgr_EventId_t {
60  IARM_BUS_PWRMGR_EVENT_MODECHANGED = 0, /*!< Event to notify power mode change */
61  IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT, /*!< Event to notify deepsleep timeout */
62  IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE, /*!< Event to notify progress of reset key sequence*/
63  IARM_BUS_PWRMGR_EVENT_REBOOTING, /*!< Event to notify that the device is about to reboot.*/
64  IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED, /*!< Event to notify temperature level change */
65  IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED, /*!< Event to notify ware house operation status changed */
66  IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED, /*!< Event to notify that the network standby mode changed.*/
67  IARM_BUS_PWRMGR_EVENT_MAX, /*!< Max event id from this module */
69 
70 
71 /**
72  * @brief Enumerator which represents the possible temeperature states
73  */
75  IARM_BUS_PWRMGR_TEMPERATURE_NORMAL = 0, /* Temp is within normal operating range */
76  IARM_BUS_PWRMGR_TEMPERATURE_HIGH, /* Temp is high, but just a warning as device can still operate */
77  IARM_BUS_PWRMGR_TEMPERATURE_CRITICAL /* Temp is critical, should trigger a thermal reset */
79 
80 /**
81  * @brief Enumerator which represents the possible warehouse ops
82  */
84  IARM_BUS_PWRMGR_WAREHOUSE_RESET = 0, /* warehouse reset */
85  IARM_BUS_PWRMGR_WAREHOUSE_CLEAR, /* warehouse clear*/
87 
88 /**
89  * @brief Enumerator which represents the possible warehouse ops
90  */
92  IARM_BUS_PWRMGR_WAREHOUSE_COMPLETED = 0, /* warehouse operation completed sucessfully */
93  IARM_BUS_PWRMGR_WAREHOUSE_INPROGRESS, /* warehouse operation in progress*/
94  IARM_BUS_PWRMGR_WAREHOUSE_FAILED, /* warehouse operation failed.*/
96 
97 #ifdef ENABLE_SET_WAKEUP_SRC_CONFIG
98 /**
99  * @brief Enumerator which represents the possible wakeup sources
100  */
101 typedef enum _WakeupSrcType_t {
102  WAKEUPSRC_VOICE = 0,
103  WAKEUPSRC_PRESENCE_DETECTION,
104  WAKEUPSRC_BLUETOOTH,
105  WAKEUPSRC_WIFI,
106  WAKEUPSRC_IR,
107  WAKEUPSRC_POWER_KEY,
108  WAKEUPSRC_TIMER,
109  WAKEUPSRC_CEC,
110  WAKEUPSRC_LAN
111 } WakeupSrcType_t;
112 #endif
113 
114 /**
115  * @brief Structure which holds the event data.
116  */
117 typedef struct _PWRMgr_EventData_t {
118  union {
119  struct _MODE_DATA{
120  /* Declare Event Data structure for PWRMGR_EVENT_DUMMY0 */
121  IARM_Bus_PWRMgr_PowerState_t curState; /*!< Power manager current power state */
122  IARM_Bus_PWRMgr_PowerState_t newState; /*!< Power manager new power state */
123  #ifdef ENABLE_DEEP_SLEEP
124  uint32_t deep_sleep_timeout;
125  #endif
126  bool nwStandbyMode;
127  } state;
128  #ifdef ENABLE_THERMAL_PROTECTION
129  struct _THERM_DATA{
132  float curTemperature;
133  } therm;
134  #endif
135  bool bNetworkStandbyMode;
136  int32_t reset_sequence_progress;
137  } data;
139 
140 /**
141  * @brief Structure which holds the Deep sleep timeout value.
142  */
144  unsigned int timeout; /*!< Timeout for deep sleep in seconds*/
146 
147 /**
148  * @brief Structure which holds warehouse opn status value.
149  */
151  IARM_Bus_PWRMgr_WareHouseOps_t wareHouseOpn; /*!< WareHouse operation*/
152  IARM_Bus_PWRMgr_WareHouseOpsStatus_t status; /*!< WareHouse operation status*/
154 
155 /**
156  * Declare RPC API names and their arguments
157  */
158 #define IARM_BUS_PWRMGR_API_SetPowerState "SetPowerState" /*!< Sets the powerstate of the device*/
159 
160 /**
161  * @brief Structure which holds the new powerstate to be set to the device.
162  */
164  IARM_Bus_PWRMgr_PowerState_t newState; /*!< [in] New powerstate to be set */
165  int keyCode; /*!< [in] Key code for the last key Pressed */
167 
168 #define IARM_BUS_PWRMGR_API_GetPowerState "GetPowerState" /*!< Retrives current power state of the box*/
169 
170 /**
171  * @brief Structure which holds the current power state of the CPE.
172  */
174  IARM_Bus_PWRMgr_PowerState_t curState; /*!< Current powerstate of the box*/
175  IARM_Bus_PWRMgr_PowerState_t prevState; /*!< Current powerstate of the box*/
177 
178 #define IARM_BUS_PWRMGR_API_WareHouseReset "WareHouseReset" /*!< Reset the box to warehouse state*/
179 
180 /**
181  * @brief Structure which holds the ware house reset time.
182  */
184  bool suppressReboot; /*!< STB should not be rebooted */
186 
187 #define IARM_BUS_PWRMGR_API_WareHouseClear "WarehouseClear" /*!< */
188 
189 #define IARM_BUS_PWRMGR_API_ColdFactoryReset "ColdFactoryReset" /*!< Reset the box to cold factory state*/
190 #define IARM_BUS_PWRMGR_API_FactoryReset "FactoryReset" /*!< Reset the box to factory state*/
191 #define IARM_BUS_PWRMGR_API_UserFactoryReset "UserFactoryReset" /*!< Reset the box to user factory state*/
192 
193 #define IARM_BUS_PWRMGR_API_SetDeepSleepTimeOut "SetDeepSleepTimeOut" /*!< Sets the timeout for deep sleep*/
194 
195 /**
196  * @brief Structure which holds the timeout value to set for Deep sleep.
197  */
199  unsigned int timeout; /*!< Timeout for deep sleep in seconds*/
201 
202 #define IARM_BUS_PWRMGR_API_SetSleepTimer "SetSleepTimer" /*!< Sets sleep timer state and timeout*/
203 #define IARM_BUS_PWRMGR_API_GetSleepTimer "GetSleepTimer" /*!< Gets sleep timer state and remaining */
204 
205 /**
206  * @brief Structure which holds the sleep timer information.
207  */
209  double time; /*!< timer duration*/
210  int start; /*!< timer state, started=1 or stopped=0*/
212 
213 #ifdef ENABLE_THERMAL_PROTECTION
214 
215 /**
216  * @brief Structure which holds the data associated with thermal level.
217  */
218 typedef struct _IARM_Bus_PWRMgr_GetThermalState_Param_t{
219  IARM_Bus_PWRMgr_ThermalState_t curLevel; /*!< Current Thermal level */
220  float curTemperature; /* !< Current temperature value */
221 } IARM_Bus_PWRMgr_GetThermalState_Param_t;
222 
223 #define IARM_BUS_PWRMGR_API_GetThermalState "GetThermalState" /*!< Retrieves current thermal level of the box*/
224 
225 /**
226  * @brief Structure which holds the thermal threshold value to be set to the device.
227  */
228 typedef struct _IARM_Bus_PWRMgr_SetTempThresholds_Param_t{
229  float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */
230  float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */
231 } IARM_Bus_PWRMgr_SetTempThresholds_Param_t;
232 
233 #define IARM_BUS_PWRMGR_API_SetTemperatureThresholds "SetTemperatureThresholds" /*!< Sets the thermal threshold for the device*/
234 
235 
236 /**
237  * @brief Structure which holds the data associated with current temperature threshold.
238  */
239 typedef struct _IARM_Bus_PWRMgr_GetTempThresholds_Param_t{
240  float tempHigh; /*!< New threshold at which TEMPERATURE_HIGH will be reported */
241  float tempCritical; /*!< New threshold at which TEMPERATURE_CRITICAL will be reported */
242 } IARM_Bus_PWRMgr_GetTempThresholds_Param_t;
243 
244 #define IARM_BUS_PWRMGR_API_GetTemperatureThresholds "GetTemperatureThresholds" /*!< Gets the thermal threshold for the device*/
245 
246 /**
247  * @brief Structure which holds the grace interval value to be set to the device.
248  */
249 typedef struct _IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t{
250  int graceInterval; /*!< New over teamparature grace interval */
251 } IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t;
252 
253 #define IARM_BUS_PWRMGR_API_SetOvertempGraceInterval "SetOvertempGraceInterval" /*!< Sets the over temparature grace interval for the device*/
254 
255 /**
256  * @brief Structure which holds the data associated with current over temparature grace interval.
257  */
258 typedef struct _IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t{
259  int graceInterval; /*!< New over temparature grace interval */
260 } IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t;
261 
262 #define IARM_BUS_PWRMGR_API_GetOvertempGraceInterval "GetOvertempGraceInterval" /*!< Gets the over temparature grace interval for the device*/
263 
264 /** @brief This function will be used to initialize thermal protection thread */
265 extern void initializeThermalProtection();
266 #endif //ENABLE_THERMAL_PROTECTION
267 
268 /**
269  * @brief Structure which holds the setting for whether video port is enabled in standby.
270  */
271 
272 #define PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH 16
275  int isEnabled;
276  int result;
278 #define IARM_BUS_PWRMGR_API_SetStandbyVideoState "SetStandbyVideoState"
279 #define IARM_BUS_PWRMGR_API_GetStandbyVideoState "GetStandbyVideoState"
280 
281 #define IARM_BUS_PWRMGR_API_SetNetworkStandbyMode "SetNetworkStandbyMode"
282 #define IARM_BUS_PWRMGR_API_GetNetworkStandbyMode "GetNetworkStandbyMode"
284  bool bStandbyMode; /*!< Standby mode to set and get*/
286 
287 #define MAX_PWR_STATE_BEF_REBOOR_STR_LEN (32)
288 #define IARM_BUS_PWRMGR_API_GetPowerStateBeforeReboot "GetPowerStateBeforeReboot" /*!< Retrives power state before reboot*/
289 /**
290  * @brief Structure which holds the power state before reboot of the CPE.
291  */
293  char powerStateBeforeReboot [MAX_PWR_STATE_BEF_REBOOR_STR_LEN]; /*!< Powerstate before reboot of the box*/
295 
296 
297 #define PWRMGR_MAX_REBOOT_REASON_LENGTH 100
298 #define PWRMGR_REBOOT_REASON_MAINTENANCE "MAINTENANCE_REBOOT"
299 /**
300  * @brief Structure to pass reboot reason argument with the reboot call.
301  */
303  char reboot_reason_custom[PWRMGR_MAX_REBOOT_REASON_LENGTH];
304  char reboot_reason_other[PWRMGR_MAX_REBOOT_REASON_LENGTH];
305  char requestor[PWRMGR_MAX_REBOOT_REASON_LENGTH];
307 #define IARM_BUS_PWRMGR_API_Reboot "performReboot" /*!< Reboots device.*/
308 
309 #ifdef ENABLE_SET_WAKEUP_SRC_CONFIG
310 /**
311  * @brief Structure which holds the wakeup source type and the value to be set.
312  */
313 typedef struct _IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t{
314  WakeupSrcType_t srcType;
315  bool config;
316 } IARM_Bus_PWRMgr_SetWakeupSrcConfig_Param_t;
317 #define IARM_BUS_PWRMGR_API_SetWakeupSrcConfig "setWakeupSrcConfig" /*!< sets wakup configuration*/
318 #endif
319 
320 /**
321  * Declare RPC API names and their arguments
322  */
323 #define IARM_BUS_PWRMGR_API_handleDeepsleepTimeoutWakeup "handleDeepsleepTimeoutWakeup" /*!< Invoke when deepsleep timeout occurs*/
324 
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 #endif
330 
331 /** @} */ // End of Doxygen Tag
332 
333 /** @} */
334 /** @} */
_IARM_Bus_PWRMgr_WareHouseOps_t
_IARM_Bus_PWRMgr_WareHouseOps_t
Enumerator which represents the possible warehouse ops.
Definition: pwrMgr.h:83
IARM_Bus_PWRMgr_EventId_t
enum _PWRMgr_EventId_t IARM_Bus_PWRMgr_EventId_t
Represents the published Events from PWR Manager.
_IARM_Bus_PWRMgr_SetPowerState_Param_t
Structure which holds the new powerstate to be set to the device.
Definition: pwrMgr.h:163
_IARM_Bus_PWRMgr_RebootParam_t
Structure to pass reboot reason argument with the reboot call.
Definition: pwrMgr.h:302
IARM_Bus_PWRMgr_EventData_t
struct _PWRMgr_EventData_t IARM_Bus_PWRMgr_EventData_t
Structure which holds the event data.
IARM_Bus_PWRMgr_WareHouseReset_Param_t
struct _IARM_Bus_PWRMgr_WareHouseReset_Param_t IARM_Bus_PWRMgr_WareHouseReset_Param_t
Structure which holds the ware house reset time.
IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t
struct _IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t
Structure which holds the Deep sleep timeout value.
_IARM_Bus_PWRMgr_GetPowerState_Param_t::prevState
IARM_Bus_PWRMgr_PowerState_t prevState
Definition: pwrMgr.h:175
_IARM_Bus_PWRMgr_SleepTimer_Param_t::start
int start
Definition: pwrMgr.h:210
_IARM_Bus_PWRMgr_StandbyVideoState_Param_t
Definition: pwrMgr.h:273
_IARM_Bus_PWRMgr_GetPowerState_Param_t
Structure which holds the current power state of the CPE.
Definition: pwrMgr.h:173
IARM_Bus_PWRMgr_SleepTimer_Param_t
struct _IARM_Bus_PWRMgr_SleepTimer_Param_t IARM_Bus_PWRMgr_SleepTimer_Param_t
Structure which holds the sleep timer information.
_PWRMgr_EventData_t
Structure which holds the event data.
Definition: pwrMgr.h:117
_IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t
Definition: pwrMgr.h:283
IARM_BUS_PWRMGR_EVENT_REBOOTING
@ IARM_BUS_PWRMGR_EVENT_REBOOTING
Definition: pwrMgr.h:63
_IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t::powerStateBeforeReboot
char powerStateBeforeReboot[(32)]
Definition: pwrMgr.h:293
_IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t::timeout
unsigned int timeout
Definition: pwrMgr.h:199
IARM_Bus_PWRMgr_GetPowerState_Param_t
struct _IARM_Bus_PWRMgr_GetPowerState_Param_t IARM_Bus_PWRMgr_GetPowerState_Param_t
Structure which holds the current power state of the CPE.
IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED
@ IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED
Definition: pwrMgr.h:65
IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t
struct _IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t
Structure which holds the timeout value to set for Deep sleep.
IARM_Bus_PWRMgr_SetPowerState_Param_t
struct _IARM_Bus_PWRMgr_SetPowerState_Param_t IARM_Bus_PWRMgr_SetPowerState_Param_t
Structure which holds the new powerstate to be set to the device.
_IARM_Bus_PWRMgr_GetPowerState_Param_t::curState
IARM_Bus_PWRMgr_PowerState_t curState
Definition: pwrMgr.h:174
_IARM_Bus_PWRMgr_ThermalState_t
_IARM_Bus_PWRMgr_ThermalState_t
Enumerator which represents the possible temeperature states.
Definition: pwrMgr.h:74
_PWRMgr_EventId_t
_PWRMgr_EventId_t
Represents the published Events from PWR Manager.
Definition: pwrMgr.h:59
_IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t::bStandbyMode
bool bStandbyMode
Definition: pwrMgr.h:284
IARM_Bus_PWRMgr_RebootParam_t
struct _IARM_Bus_PWRMgr_RebootParam_t IARM_Bus_PWRMgr_RebootParam_t
Structure to pass reboot reason argument with the reboot call.
_IARM_BUS_PWRMgr_WareHouseOpn_EventData_t::wareHouseOpn
IARM_Bus_PWRMgr_WareHouseOps_t wareHouseOpn
Definition: pwrMgr.h:151
IARM_Bus_PWRMgr_WareHouseOpsStatus_t
enum _IARM_Bus_PWRMgr_WareHouseOpsStatus_t IARM_Bus_PWRMgr_WareHouseOpsStatus_t
Enumerator which represents the possible warehouse ops.
IARM_Bus_PWRMgr_WareHouseOps_t
enum _IARM_Bus_PWRMgr_WareHouseOps_t IARM_Bus_PWRMgr_WareHouseOps_t
Enumerator which represents the possible warehouse ops.
IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t
struct _IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t
Structure which holds the power state before reboot of the CPE.
IARM_Bus_PWRMgr_ThermalState_t
enum _IARM_Bus_PWRMgr_ThermalState_t IARM_Bus_PWRMgr_ThermalState_t
Enumerator which represents the possible temeperature states.
_IARM_Bus_PWRMgr_WareHouseReset_Param_t::suppressReboot
bool suppressReboot
Definition: pwrMgr.h:184
IARM_BUS_PWRMGR_EVENT_MODECHANGED
@ IARM_BUS_PWRMGR_EVENT_MODECHANGED
Definition: pwrMgr.h:60
IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE
@ IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE
Definition: pwrMgr.h:62
IARM_BUS_PWRMGR_EVENT_MAX
@ IARM_BUS_PWRMGR_EVENT_MAX
Definition: pwrMgr.h:67
PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH
#define PWRMGR_MAX_VIDEO_PORT_NAME_LENGTH
Structure which holds the setting for whether video port is enabled in standby.
Definition: pwrMgr.h:272
_IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t
Structure which holds the power state before reboot of the CPE.
Definition: pwrMgr.h:292
_IARM_Bus_PWRMgr_WareHouseOpsStatus_t
_IARM_Bus_PWRMgr_WareHouseOpsStatus_t
Enumerator which represents the possible warehouse ops.
Definition: pwrMgr.h:91
_IARM_BUS_PWRMgr_WareHouseOpn_EventData_t::status
IARM_Bus_PWRMgr_WareHouseOpsStatus_t status
Definition: pwrMgr.h:152
_IARM_Bus_PWRMgr_SleepTimer_Param_t
Structure which holds the sleep timer information.
Definition: pwrMgr.h:208
IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT
@ IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT
Definition: pwrMgr.h:61
_IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t
Structure which holds the Deep sleep timeout value.
Definition: pwrMgr.h:143
_IARM_Bus_PWRMgr_SetPowerState_Param_t::newState
IARM_Bus_PWRMgr_PowerState_t newState
Definition: pwrMgr.h:164
IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED
@ IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED
Definition: pwrMgr.h:64
_IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t
Structure which holds the timeout value to set for Deep sleep.
Definition: pwrMgr.h:198
_IARM_BUS_PWRMgr_WareHouseOpn_EventData_t
Structure which holds warehouse opn status value.
Definition: pwrMgr.h:150
IARM_BUS_PWRMgr_WareHouseOpn_EventData_t
struct _IARM_BUS_PWRMgr_WareHouseOpn_EventData_t IARM_BUS_PWRMgr_WareHouseOpn_EventData_t
Structure which holds warehouse opn status value.
_IARM_Bus_PWRMgr_WareHouseReset_Param_t
Structure which holds the ware house reset time.
Definition: pwrMgr.h:183
_IARM_Bus_PWRMgr_SleepTimer_Param_t::time
double time
Definition: pwrMgr.h:209
_IARM_Bus_PWRMgr_SetPowerState_Param_t::keyCode
int keyCode
Definition: pwrMgr.h:165
_IARM_BUS_PWRMgr_DeepSleepTimeout_EventData_t::timeout
unsigned int timeout
Definition: pwrMgr.h:144
IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED
@ IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED
Definition: pwrMgr.h:66