32 #include <sys/types.h>
46 #include "dsserverlogger.h"
47 #include "hostPersistence.hpp"
49 #ifdef HAS_HDMI_IN_SUPPORT
53 static int m_isInitialized = 0;
54 static int m_isPlatInitialized = 0;
55 static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER;
57 static bool force_disable_hdr =
true;
58 bool enableHDRDVStatus =
false;
60 #define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock)
61 #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock)
63 IARM_Result_t _dsVideoDeviceInit(
void *arg);
64 IARM_Result_t _dsGetVideoDevice(
void *arg);
65 IARM_Result_t _dsSetDFC(
void *arg);
66 IARM_Result_t _dsGetDFC(
void *arg);
67 IARM_Result_t _dsVideoDeviceTerm(
void *arg);
68 IARM_Result_t _dsGetHDRCapabilities(
void *arg);
69 IARM_Result_t _dsGetSupportedVideoCodingFormats(
void *arg);
70 IARM_Result_t _dsGetVideoCodecInfo(
void *arg);
71 IARM_Result_t _dsForceDisableHDR(
void *arg);
73 IARM_Result_t _dsSetFRFMode(
void *arg);
74 IARM_Result_t _dsGetFRFMode(
void *arg);
75 IARM_Result_t _dsGetCurrentDisframerate(
void *arg);
76 IARM_Result_t _dsSetDisplayframerate(
void *arg);
78 void _dsFramerateStatusPostChangeCB(
unsigned int inputStatus);
79 void _dsFramerateStatusPreChangeCB(
unsigned int inputStatus);
80 static bool get_HDR_DV_RFC_config();
82 IARM_Result_t dsVideoDeviceMgr_init()
89 std::string _ZoomSettings(
"Full");
92 if (_ZoomSettings.compare(
"None") == 0)
96 #ifdef HAS_HDMI_IN_SUPPORT
102 printf(
"Exception in Getting the Zoom settings on Startup..... \r\n");
107 std::string _hdr_setting(
"false");
109 if (_hdr_setting.compare(
"false") == 0)
111 force_disable_hdr =
false;
115 force_disable_hdr =
true;
116 printf(
"HDR support in disabled configuration.\n");
121 printf(
"Exception in getting force-disable-HDR setting at start up.\r\n");
124 enableHDRDVStatus = get_HDR_DV_RFC_config();
125 printf(
"HDR DV support status is: %s.\n", (
true == enableHDRDVStatus?
"enabled" :
"disabled"));
128 if (!m_isPlatInitialized) {
132 m_isPlatInitialized++;
133 IARM_BUS_Unlock(lock);
135 return IARM_RESULT_SUCCESS;
138 IARM_Result_t dsVideoDeviceMgr_term()
140 return IARM_RESULT_SUCCESS;
143 IARM_Result_t _dsVideoDeviceInit(
void *arg)
147 if (!m_isInitialized) {
154 IARM_Bus_RegisterCall(IARM_BUS_DSMGR_API_dsGetSupportedVideoCodingFormats, _dsGetSupportedVideoCodingFormats);
162 typedef dsError_t (*_dsFramerateStatusPreChangeCB_t)(dsRegisterFrameratePreChangeCB_t CBFunc);
163 static _dsFramerateStatusPreChangeCB_t frameratePreChangeCB = 0;
164 if (frameratePreChangeCB == 0) {
165 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
167 frameratePreChangeCB = (_dsFramerateStatusPreChangeCB_t) dlsym(dllib,
"dsRegisterFrameratePreChangeCB");
168 if(frameratePreChangeCB == 0) {
169 printf(
"dsRegisterFrameratePreChangeCB(dsHdmiInStatusChangeCB_t) is not defined\r\n");
174 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
178 if(frameratePreChangeCB) {
179 frameratePreChangeCB(_dsFramerateStatusPreChangeCB);
182 typedef dsError_t (*dsRegisterFrameratePostChangeCB_t)(dsRegisterFrameratePostChangeCB_t CBFunc);
183 static dsRegisterFrameratePostChangeCB_t frameratePostChangeCB = 0;
184 if (frameratePostChangeCB == 0) {
185 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
187 frameratePostChangeCB = (dsRegisterFrameratePostChangeCB_t) dlsym(dllib,
"dsRegisterFrameratePostChangeCB");
188 if(frameratePostChangeCB == 0) {
189 printf(
"dsRegisterFrameratePostChangeCB(dsHdmiInStatusChangeCB_t) is not defined\r\n");
194 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
198 if(frameratePostChangeCB) {
199 frameratePostChangeCB(_dsFramerateStatusPostChangeCB);
205 if (!m_isPlatInitialized) {
209 m_isPlatInitialized++;
211 IARM_BUS_Unlock(lock);
213 return IARM_RESULT_SUCCESS;
217 IARM_Result_t _dsGetVideoDevice(
void *arg)
227 IARM_BUS_Unlock(lock);
229 return IARM_RESULT_SUCCESS;
232 IARM_Result_t _dsSetDFC(
void *arg)
247 printf(
"\n Call Zoom setting NONE\n");
250 srv_dfc = param->dfc;
256 printf(
"\n Call Zoom setting FULL\n");
259 srv_dfc = param->dfc;
266 printf(
"\n Call Zoom setting dsVIDEO_ZOOM_16_9_ZOOM\n");
269 srv_dfc = param->dfc;
275 printf(
"\n ERROR: unsupported Zoom setting %d\n", param->dfc);
278 #ifdef HAS_HDMI_IN_SUPPORT
284 printf(
"Error in Setting the Video Resolution..... \r\n");
289 IARM_BUS_Unlock(lock);
290 return IARM_RESULT_SUCCESS;
296 IARM_Result_t _dsGetDFC(
void *arg)
306 param->dfc = srv_dfc;
307 INT_INFO(
"The Zoom Settings value is %d \r\n",param->dfc);
310 IARM_BUS_Unlock(lock);
312 return IARM_RESULT_SUCCESS;
316 IARM_Result_t _dsVideoDeviceTerm(
void *arg)
322 m_isPlatInitialized --;
324 if (0 == m_isPlatInitialized)
329 IARM_BUS_Unlock(lock);
331 return IARM_RESULT_SUCCESS;
334 IARM_Result_t _dsGetHDRCapabilities(
void *arg)
340 typedef dsError_t (*dsGetHDRCapabilitiesFunc_t)(intptr_t handle,
int *capabilities);
341 static dsGetHDRCapabilitiesFunc_t func = 0;
343 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
345 func = (dsGetHDRCapabilitiesFunc_t)dlsym(dllib,
"dsGetHDRCapabilities");
347 printf(
"dsGetHDRCapabilities() is defined and loaded\r\n");
350 printf(
"dsGetHDRCapabilities() is not defined\r\n");
355 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
359 if((0 != func) && (
false == force_disable_hdr)) {
360 param->result = func(param->handle, ¶m->capabilities);
364 printf(
"dsGetHDRCapabilities() DolbyVision Disabled param->capabilities:%x\r\n",param->capabilities);
371 IARM_BUS_Unlock(lock);
372 return IARM_RESULT_SUCCESS;
375 IARM_Result_t _dsGetSupportedVideoCodingFormats(
void *arg)
381 typedef dsError_t (*dsGetSupportedVideoCodingFormatsFunc_t)(intptr_t handle,
unsigned int *supported_formats);
382 static dsGetSupportedVideoCodingFormatsFunc_t func = 0;
384 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
386 func = (dsGetSupportedVideoCodingFormatsFunc_t)dlsym(dllib,
"dsGetSupportedVideoCodingFormats");
388 printf(
"dsGetSupportedVideoCodingFormats() is defined and loaded\r\n");
391 printf(
"dsGetSupportedVideoCodingFormats() is not defined\r\n");
396 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
401 param->result = func(param->handle, ¶m->supported_formats);
404 param->supported_formats = 0x0;
407 IARM_BUS_Unlock(lock);
408 return IARM_RESULT_SUCCESS;
411 IARM_Result_t _dsGetVideoCodecInfo(
void *arg)
418 static dsGetVideoCodecInfoFunc_t func = 0;
420 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
422 func = (dsGetVideoCodecInfoFunc_t)dlsym(dllib,
"dsGetVideoCodecInfo");
424 printf(
"dsGetVideoCodecInfo() is defined and loaded\r\n");
427 printf(
"dsGetVideoCodecInfo() is not defined\r\n");
432 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
438 param->result = func(param->handle, param->format, ¶m->info);
444 IARM_BUS_Unlock(lock);
445 return IARM_RESULT_SUCCESS;
448 IARM_Result_t _dsForceDisableHDR(
void *arg)
454 typedef dsError_t (*dsDisableHDRSupportFunc_t)(intptr_t handle,
bool enable);
455 static dsDisableHDRSupportFunc_t func = 0;
457 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
459 func = (dsDisableHDRSupportFunc_t)dlsym(dllib,
"dsForceDisableHDRSupport");
461 printf(
"dsForceDisableHDRSupport() is defined and loaded\r\n");
464 printf(
"dsForceDisableHDRSupport() is not defined\r\n");
469 printf(
"dsForceDisableHDRSupport() Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
478 param->result = func(param->handle, param->disable);
479 printf(
"dsForceDisableHDRSupport() enable:%d \n",param->disable);
485 force_disable_hdr = param->disable;
486 if(force_disable_hdr)
495 IARM_BUS_Unlock(lock);
496 return IARM_RESULT_SUCCESS;
499 #define RFC_BUFFER_SIZE 100
500 static bool get_HDR_DV_RFC_config()
502 bool is_enabled =
false;
503 const char * cmd =
"tr181Set -g Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.DolbyVision.Enable 2>&1 1>/dev/null";
505 printf(
"%s: getting RFC config using command \"%s\"\n", __FUNCTION__, cmd);
506 FILE * pipe = popen(cmd,
"r");
509 char buffer[RFC_BUFFER_SIZE];
510 if(NULL == fgets(buffer, RFC_BUFFER_SIZE, pipe))
512 printf(
"%s: could not parse output of command <%s>.\n", __FUNCTION__, cmd);
516 printf(
"%s: read output \"%s\"\n", __FUNCTION__, buffer);
517 if(0 == strncasecmp(buffer,
"true", 4))
524 printf(
"%s: the feature is %s.\n", __FUNCTION__, (
true == is_enabled?
"enabled" :
"disabled"));
528 IARM_Result_t _dsSetFRFMode(
void *arg)
534 typedef dsError_t (*dsSetFRFModeFunc_t)(intptr_t handle,
int frfmode);
535 static dsSetFRFModeFunc_t func = 0;
537 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
539 func = (dsSetFRFModeFunc_t)dlsym(dllib,
"dsSetFRFMode");
541 printf(
"dsSetFRFMode is defined and loaded\r\n");
544 printf(
"dsSetFRFMode is not defined\r\n");
549 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
554 func(param->handle, param->frfmode);
556 IARM_BUS_Unlock(lock);
557 return IARM_RESULT_SUCCESS;
560 IARM_Result_t _dsGetFRFMode(
void *arg)
566 typedef dsError_t (*dsGetFRFModeFunc_t)(intptr_t handle,
int *frfmode);
567 static dsGetFRFModeFunc_t func = 0;
569 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
571 func = (dsGetFRFModeFunc_t)dlsym(dllib,
"dsGetFRFMode");
573 printf(
"dsGetFRFMode() is defined and loaded\r\n");
576 printf(
"dsGetFRFMode() is not defined\r\n");
581 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
586 func(param->handle, ¶m->frfmode);
589 IARM_BUS_Unlock(lock);
590 return IARM_RESULT_SUCCESS;
593 IARM_Result_t _dsGetCurrentDisframerate(
void *arg)
599 typedef dsError_t (*dsGetCurrentDisframerateFunc_t)(intptr_t handle,
char *framerate);
600 static dsGetCurrentDisframerateFunc_t func = 0;
602 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
604 func = (dsGetCurrentDisframerateFunc_t)dlsym(dllib,
"dsGetCurrentDisplayframerate");
606 printf(
"dsGetCurrentDisframerate() is defined and loaded\r\n");
609 printf(
"dsGetCurrentDisframerate() is not defined\r\n");
614 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
620 func(param->handle, param->framerate);
623 IARM_BUS_Unlock(lock);
624 return IARM_RESULT_SUCCESS;
627 IARM_Result_t _dsSetDisplayframerate(
void *arg)
633 typedef dsError_t (*dsSetDisplayframerateFunc_t)(intptr_t handle,
char *frfmode);
634 static dsSetDisplayframerateFunc_t func = 0;
636 void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
638 func = (dsSetDisplayframerateFunc_t)dlsym(dllib,
"dsSetDisplayframerate");
640 printf(
"dsSetDisplayframerate() is defined and loaded\r\n");
643 printf(
"dsSetDisplayframerate() is not defined\r\n");
648 printf(
"Opening RDK_DSHAL_NAME [%s] failed\r\n", RDK_DSHAL_NAME);
654 func(param->handle, param->framerate);
657 IARM_BUS_Unlock(lock);
658 return IARM_RESULT_SUCCESS;
661 void _dsFramerateStatusPreChangeCB(
unsigned int inputStatus)
665 printf(
"%s:%d - Framerate status prechange update!!!!!! \r\n", __PRETTY_FUNCTION__,__LINE__);
674 void _dsFramerateStatusPostChangeCB(
unsigned int inputStatus)
678 printf(
"%s:%d - Framerate status changed update!!!!!! \r\n", __PRETTY_FUNCTION__,__LINE__);