34 #include <sys/types.h>
38 #include "hostPersistence.hpp"
49 #include "safec_lib.h"
52 static int m_isInitialized = 0;
53 static pthread_mutex_t hostLock = PTHREAD_MUTEX_INITIALIZER;
55 #define IARM_BUS_Lock(lock) pthread_mutex_lock(&hostLock)
56 #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&hostLock)
59 IARM_Result_t _dsGetPreferredSleepMode(
void *arg);
60 IARM_Result_t _dsSetPreferredSleepMode(
void *arg);
61 IARM_Result_t _dsGetCPUTemperature(
void *arg);
62 IARM_Result_t _dsGetVersion(
void *arg);
63 IARM_Result_t _dsSetVersion(
void *arg);
64 IARM_Result_t _dsGetSocIDFromSDK(
void *arg);
65 IARM_Result_t _dsGetHostEDID(
void *arg);
75 #define DSHAL_API_VERSION_MAJOR_DEFAULT 1
76 #define DSHAL_API_VERSION_MINOR_DEFAULT 0
79 IARM_Result_t dsHostMgr_init()
83 string mode=
"LIGHT_SLEEP";
85 printf(
"Sleep mode Persistent value is -> %s\n",mode.c_str());
86 _SleepMode = stringToEnum(mode);
90 printf(
"Error in Reading the Power Mode Persisent \r\n");
93 if (!m_isInitialized) {
103 uint32_t halVersion = 0x10000;
106 halVersion =
dsHAL_APIVER(DSHAL_API_VERSION_MAJOR_DEFAULT, DSHAL_API_VERSION_MINOR_DEFAULT);
112 return IARM_RESULT_SUCCESS;
115 IARM_Result_t dsHostMgr_term()
117 return IARM_RESULT_SUCCESS;
120 IARM_Result_t _dsSetPreferredSleepMode(
void *arg)
122 IARM_Result_t ret = IARM_RESULT_SUCCESS;
127 printf(
"_dsSetPreferredSleepMode called with the mode - %s \r\n", enumToString(param->mode).c_str());
131 _SleepMode = param->mode;
133 eventData.data.sleepModeInfo.sleepMode = _SleepMode;
135 printf(
"callaing IARM_BUS_DSMGR_EVENT_SLEEP_MODE_CHANGED :%d \n",_SleepMode);
136 ret = IARM_RESULT_SUCCESS;
140 printf(
"Error in Persisting the Power Mode\r\n");
142 IARM_BUS_Unlock(lock);
146 IARM_Result_t _dsGetPreferredSleepMode(
void *arg)
148 IARM_Result_t ret = IARM_RESULT_SUCCESS;
155 param->mode =_SleepMode;
157 printf(
"_dsGetPreferredSleepMode: Mode - %s \r\n", enumToString(param->mode).c_str());
159 IARM_BUS_Unlock(lock);
182 if(mode ==
"LIGHT_SLEEP")
186 else if(mode ==
"DEEP_SLEEP")
193 IARM_Result_t _dsGetCPUTemperature(
void *arg)
197 IARM_Result_t ret = IARM_RESULT_SUCCESS;
200 #ifdef HAS_THERMAL_API
204 float temperature = 45.0;
210 param->temperature = temperature;
213 printf(
"Current temperature in SRV is: %+7.2fC\n", param->temperature);
215 IARM_BUS_Unlock(lock);
222 IARM_Result_t _dsGetVersion(
void *arg)
229 IARM_Result_t ret = IARM_RESULT_SUCCESS;
232 uint32_t ver = 0x10000;
237 param->versionNumber = ver;
241 param->versionNumber =
dsHAL_APIVER(DSHAL_API_VERSION_MAJOR_DEFAULT, DSHAL_API_VERSION_MINOR_DEFAULT);
246 IARM_BUS_Unlock(lock);
252 IARM_Result_t _dsSetVersion(
void *arg)
259 IARM_Result_t ret = IARM_RESULT_SUCCESS;
267 __TIMESTAMP();printf(
"Error in Setting versionNumber: 0x%08X \r\n",param->versionNumber);
270 IARM_BUS_Unlock(lock);
275 IARM_Result_t _dsGetSocIDFromSDK(
void *arg)
278 IARM_Result_t ret = IARM_RESULT_SUCCESS;
282 printf(
"dsSRV:_dsGetSocIDFromSDK\r\n");
283 typedef dsError_t (*dsGetSocIDFromSDK_t)(
char* socID);
284 static dsGetSocIDFromSDK_t func = NULL;
286 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
289 func = (dsGetSocIDFromSDK_t) dlsym(dllib,
"dsGetSocIDFromSDK");
291 printf(
"dsSRV: dsGetSocIDFromSDK(char* socID) is defined and loaded\r\n");
294 printf(
"dsSRV: dsGetSocIDFromSDK(char* socID) is not defined\r\n");
299 printf(
"dsSRV: Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
307 param->result = func(param->socID);
310 printf(
"dsSRV: _dsGetSocIDFromSDK SocID : %s\n",param->socID);
312 IARM_BUS_Unlock(lock);
314 return IARM_RESULT_SUCCESS;
317 IARM_Result_t _dsGetHostEDID(
void *arg)
320 #ifndef RDK_DSHAL_NAME
321 #warning "RDK_DSHAL_NAME is not defined"
322 #define RDK_DSHAL_NAME "RDK_DSHAL_NAME is not defined"
329 printf(
"dsSRV::getHostEDID \r\n");
331 typedef dsError_t (*dsGetHostEDID_t)(
unsigned char *edid,
int *length);
332 static dsGetHostEDID_t func = 0;
334 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
336 func = (dsGetHostEDID_t) dlsym(dllib,
"dsGetHostEDID");
338 printf(
"dsGetHostEDID(void) is defined and loaded\r\n");
341 printf(
"dsGetHostEDID(void) is not defined\r\n");
346 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
353 unsigned char edidBytes[EDID_MAX_DATA_SIZE] ;
355 dsError_t ret = func(edidBytes, &length);
357 printf(
"dsSRV ::getHostEDID returns %d bytes\r\n", length);
358 rc = memcpy_s(param->bytes,
sizeof(param->bytes),edidBytes,EDID_MAX_DATA_SIZE);
362 param->length = length;
370 IARM_BUS_Unlock(lock);
372 return IARM_RESULT_SUCCESS;