From d3a2867ae807c9a78115d7e2b613a402c019ef2b Mon Sep 17 00:00:00 2001 From: Arun P Madhavan <54109113+arun-madhavan-013@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:04:16 -0500 Subject: [PATCH 01/66] RDKEMW-11168, RDKEMW-4848: pass the proper handle to dsEnableHDCP (#182) * RDKEMW-4848: pass the proper handle to dsEnableHDCP --- ds/videoOutputPortType.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ds/videoOutputPortType.cpp b/ds/videoOutputPortType.cpp index 87ebbaa6..2e112058 100644 --- a/ds/videoOutputPortType.cpp +++ b/ds/videoOutputPortType.cpp @@ -36,7 +36,7 @@ #include "illegalArgumentException.hpp" #include "videoOutputPortConfig.hpp" #include "dslogger.h" - +#include "dsVideoPort.h" #include @@ -209,19 +209,26 @@ void VideoOutputPortType::enabledDTCP() */ void VideoOutputPortType::enabledHDCP(bool contentProtect , char *hdcpKey , size_t keySize ) { - dsError_t ret = dsERR_NONE; - if (device::Host::getInstance().isHDMIOutPortPresent()){ - ret = dsEnableHDCP(dsVIDEOPORT_TYPE_HDMI, contentProtect, hdcpKey, keySize); + dsError_t ret = dsERR_NONE; + intptr_t handle = -1; + + // Assuming isHDMIOutPortPresent() will only be 'true' for Source devices + dsVideoPortType_t portType = device::Host::getInstance().isHDMIOutPortPresent() + ? dsVIDEOPORT_TYPE_HDMI + : dsVIDEOPORT_TYPE_INTERNAL; + ret = dsGetVideoPort(portType, 0, &handle); + if ((ret == dsERR_NONE) && (handle != -1)) { + ret = dsEnableHDCP(handle, contentProtect, hdcpKey, keySize); + } else { + INT_ERROR("VideoOutputPortType::enabledHDCP: Error type %d, handle=%p, error code=%d", portType, (void *)handle, ret); + // Set ret to an error code on dsGetVideoPort failure or invalid handle to ensure exception is thrown + ret = dsERR_GENERAL; } - else{ - ret = dsEnableHDCP(dsVIDEOPORT_TYPE_INTERNAL , contentProtect, hdcpKey, keySize); + + if (ret != dsERR_NONE) { + throw IllegalArgumentException(); } - - if (ret != dsERR_NONE) - { - throw IllegalArgumentException(); - } - _hdcpSupported = true; + _hdcpSupported = true; } From 6abd42423efc7c80dfad66ec29def87099457e7e Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 30 Oct 2025 11:43:36 +0000 Subject: [PATCH 02/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 160 +++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index c3ab1cc6..28822598 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -35,6 +35,13 @@ #include "stdlib.h" #include "dslogger.h" +#define DEBUG 1 + +static dsAudioTypeConfig_t *kConfigs1 = NULL; +static dsAudioPortConfig_t *kPorts1 = NULL; +int *pKConSize, *pKPortSize; +static int kConfig_size_local = -1, kPort_size_local = -1; + namespace device { //To Make the instance as thread-safe, using = default, that can request special methods from the compiler. They are Special because only compiler can create them. @@ -108,6 +115,117 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } +bool searchConfigs() +{ + IARM_BUS_Lock(lock); + + void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + if (dllib) { + kConfigs1 = (dsAudioTypeConfig_t *) dlsym(dllib, "kAudioConfigs"); + if (kConfigs1) { + INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", kConfigs1); + printf("%d:%s: kAudioConfigs is defined and loaded kConfigs1 = %p\n", __LINE__, __func__, kConfigs1); + } + else { + INT_ERROR("kAudioConfigs is not defined\r\n"); + INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); + } + + pKConSize = (int *) dlsym(dllib, "kAudioConfigs_size"); + if(pKConSize) + { + kConfig_size_local = *pKConSize; + INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, kConfig_size_local); + } + else + { + INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); + kConfig_size_local = -1; + } + + kPorts1 = (dsAudioPortConfig_t *) dlsym(dllib, "kAudioPorts"); + if (kPorts1) { + INT_INFO("kAudioPorts is defined and loaded kPorts1 = %p\r\n", kPorts1); + INT_INFO("%d:%s: kAudioPorts is defined and loaded kPorts1 = %p\n", __LINE__, __func__, kPorts1); + } + else { + INT_ERROR("kAudioPorts is not defined\r\n"); + INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); + } + + pKPortSize = (int *) dlsym(dllib, "kAudioPorts_size"); + if(pKPortSize) + { + kPort_size_local = *pKPortSize; + INT_INFO("%d:%s: kAudioPorts_size is defined and loaded kPort_size_local = %d\n", __LINE__, __func__, kPort_size_local); + } + else + { + INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); + kPort_size_local = -1; + } + dlclose(dllib); + } + else { + INT_ERROR("Opening libdshalsrv.so failed\r\n"); + INT_ERROR("%d:%s: Opening libdshalsrv.so failed\n", __LINE__, __func__); + } + IARM_BUS_Unlock(lock); +#if DEBUG + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); + //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); + //kConfig_size_local = kConfig_size; + //kPort_size_local = kPort_size; + + if(kConfigs1 != NULL && kConfig_size_local != -1) + { + for (size_t i = 0; i < kConfig_size_local; i++) { + const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; + //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + //aPortType.enable(); + INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); + INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); + INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); + INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); + INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); + } + } + else + { + INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); + } + if(kPorts1 != NULL && kPort_size_local != -1) + { + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < kPort_size_local; i++) { + const dsAudioPortConfig_t *port = &kPorts1[i]; + INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); + INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); + } + } + else + { + INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); + } + INT_INFO("\n\n=========================================================================================================================\n\n"); +#endif + if(kConfigs1 == NULL || kConfig_size_local == -1 || kPorts1 == NULL || kPort_size_local == -1) + { + printf("Either kAudioConfigs or kAudioPorts is NULL and kConfig_size_local is -1, kPort_size_local is -1\n"); + return false; + } + else + { + printf("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); + return true; + } + //return (kConfigs1 && kPorts1); +} + + void AudioOutputPortConfig::load() { try { @@ -133,6 +251,47 @@ void AudioOutputPortConfig::load() } + if(searchConfigs() == true) + { + /* + * Initialize Audio portTypes (encodings, compressions etc.) + * and its port instances (db, level etc) + */ + if(kConfigs1 != NULL) + { + for (size_t i = 0; i < kConfig_size_local; i++) { + const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; + AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + aPortType.enable(); + for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { + aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); + _aEncodings.at(typeCfg->encodings[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { + aPortType.addCompression(typeCfg->compressions[j]); + _aCompressions.at(typeCfg->compressions[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { + aPortType.addStereoMode(typeCfg->stereoModes[j]); + _aStereoModes.at(typeCfg->stereoModes[j]).enable(); + } + } + + /* + * set up ports based on kPorts[] + */ + if(kPorts1 != NULL) + { + for (size_t i = 0; i < kPort_size_local; i++) { + const dsAudioPortConfig_t *port = &kPorts1[i]; + _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); + _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); + } + } + } + + } + else{ /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) @@ -165,6 +324,7 @@ void AudioOutputPortConfig::load() _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } + } } catch(const Exception &e) { From 59bbd5caa69647354e6028b565ffd8c2280d2a64 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 30 Oct 2025 12:15:11 +0000 Subject: [PATCH 03/66] fix build issue --- ds/audioOutputPortConfig.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 28822598..ac53db0a 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -36,11 +36,14 @@ #include "dslogger.h" #define DEBUG 1 +#define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock) +#define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock) static dsAudioTypeConfig_t *kConfigs1 = NULL; static dsAudioPortConfig_t *kPorts1 = NULL; int *pKConSize, *pKPortSize; static int kConfig_size_local = -1, kPort_size_local = -1; +static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; namespace device { From b08a24dcefddc6082f7dd1fe394db2302229a3df Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 30 Oct 2025 12:36:56 +0000 Subject: [PATCH 04/66] fix build issue Signed-off-by: grandhi_santoshkumar --- ds/audioOutputPortConfig.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index ac53db0a..89a0ec18 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -34,10 +34,9 @@ #include "dsUtl.h" #include "stdlib.h" #include "dslogger.h" +#include #define DEBUG 1 -#define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock) -#define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock) static dsAudioTypeConfig_t *kConfigs1 = NULL; static dsAudioPortConfig_t *kPorts1 = NULL; @@ -120,7 +119,7 @@ List AudioOutputPortConfig::getSupportedTypes() bool searchConfigs() { - IARM_BUS_Lock(lock); + pthread_mutex_lock(&dsLock); void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); if (dllib) { @@ -173,7 +172,7 @@ bool searchConfigs() INT_ERROR("Opening libdshalsrv.so failed\r\n"); INT_ERROR("%d:%s: Opening libdshalsrv.so failed\n", __LINE__, __func__); } - IARM_BUS_Unlock(lock); + pthread_mutex_unlock(&dsLock); #if DEBUG INT_INFO("\n\n=========================================================================================================================\n\n"); INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); From 9cc6b5f593c2a1b564433e135e46d18c9b83db0d Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 07:58:54 +0000 Subject: [PATCH 05/66] addressed review comments --- ds/audioOutputPortConfig.cpp | 179 +++++++++++++++++++++++++++++++++-- 1 file changed, 172 insertions(+), 7 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 89a0ec18..ba9fda68 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -38,12 +38,16 @@ #define DEBUG 1 -static dsAudioTypeConfig_t *kConfigs1 = NULL; -static dsAudioPortConfig_t *kPorts1 = NULL; -int *pKConSize, *pKPortSize; -static int kConfig_size_local = -1, kPort_size_local = -1; static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; +typedef struct Configs +{ + dsAudioTypeConfig_t *pKConfigs; + dsAudioPortConfig_t *pKPorts; + int *pKConfigSize; + int *pKPortSize; +}Configs_t; + namespace device { //To Make the instance as thread-safe, using = default, that can request special methods from the compiler. They are Special because only compiler can create them. @@ -117,6 +121,115 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } +bool searchConfigs(Configs_t *config, char *searchVaribles) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, &searchVaribles[0]); + INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, &searchVaribles[1]); + INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, &searchVaribles[2]); + INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, &searchVaribles[4]); + + pthread_mutex_lock(&dsLock); + + void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + if (dllib) { + config->pKConfigs = (dsAudioTypeConfig_t *) dlsym(dllib, searchVaribles[0]); + if (config->pKConfigs) { + INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", config->pKConfigs); + else { + INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); + } + + config->pKConfigSize = (int *) dlsym(dllib, searchVaribles[2]); + if(config->pKConfigSize) + { + //kConfig_size_local = *pKConSize; + INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, *config->pKConfigSize); + } + else + { + INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); + config->pKConfigSize = -1; + } + + config->pKPorts = (dsAudioPortConfig_t *) dlsym(dllib, searchVaribles[1]); + if (config->pKPorts) {; + INT_INFO("%d:%s: kAudioPorts is defined and loaded config->pKPorts = %p\n", __LINE__, __func__, config->pKPorts); + } + else { + INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); + } + + config->pKPortSize = (int *) dlsym(dllib, searchVaribles[3]); + if(config->pKPortSize) + { + INT_INFO("%d:%s: kAudioPorts_size is defined and loaded config->pKPortSize = %d\n", __LINE__, __func__, *config->pKPortSize); + } + else + { + INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); + config->pKPortSize = -1; + } + dlclose(dllib); + } + else { + INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); + } + pthread_mutex_unlock(&dsLock); +#if DEBUG + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); + //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); + //kConfig_size_local = kConfig_size; + //kPort_size_local = kPort_size; + + if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) + { + for (size_t i = 0; i < *(config->pKConfigSize); i++) { + const dsAudioTypeConfig_t *typeCfg = &config->pKConfigs[i]; + //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + //aPortType.enable(); + INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); + INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); + INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); + INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); + INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); + } + } + else + { + INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); + } + if(configuration->pKPorts != NULL && *(configuration->pKPortSize) != -1) + { + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < *(configuration->pKPortSize); i++) { + const dsAudioPortConfig_t *port = &configuration->pKPorts[i]; + INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); + INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); + } + } + else + { + INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); + } + INT_INFO("\n\n=========================================================================================================================\n\n"); +#endif + if(kConfigs1 == NULL || kConfig_size_local == -1 || kPorts1 == NULL || kPort_size_local == -1) + { + printf("Either kAudioConfigs or kAudioPorts is NULL and kConfig_size_local is -1, kPort_size_local is -1\n"); + return false; + } + else + { + printf("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); + return true; + } +} + +#if 0 bool searchConfigs() { pthread_mutex_lock(&dsLock); @@ -169,8 +282,7 @@ bool searchConfigs() dlclose(dllib); } else { - INT_ERROR("Opening libdshalsrv.so failed\r\n"); - INT_ERROR("%d:%s: Opening libdshalsrv.so failed\n", __LINE__, __func__); + INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); } pthread_mutex_unlock(&dsLock); #if DEBUG @@ -226,10 +338,17 @@ bool searchConfigs() } //return (kConfigs1 && kPorts1); } - +#endif void AudioOutputPortConfig::load() { + dsAudioTypeConfig_t *pKConfigs = NULL; + dsAudioPortConfig_t *pKPorts = NULL; + int *pKConfigSize, *pKPortSize; + Configs_t configuration = {0}; + char searchVaribles[][30] = { "kAudioConfigs", "kAudioPorts", "kAudioConfigs_size", "kAudioPorts_size" }; + bool ret; + //static int kConfig_size_local = -1, kPort_size_local = -1; try { /* * Load Constants First. @@ -253,6 +372,51 @@ void AudioOutputPortConfig::load() } + ret = searchConfigs(&configuration, searchVaribles); + if (ret == true) + { + INT_INFO("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); + } + else + { + INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); + config.pKConfigs = kConfigs; + config.pKConfigSize = dsUTL_DIM(kConfigs); + config.pKPorts = kPorts; + config.pKPortSize = dsUTL_DIM(kPorts); + } + /* + * Initialize Audio portTypes (encodings, compressions etc.) + * and its port instances (db, level etc) + */ + for (size_t i = 0; i < configuration->pKConfigSize; i++) { + const dsAudioTypeConfig_t *typeCfg = &(configuration->pKConfigs[i]); + AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + aPortType.enable(); + for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { + aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); + _aEncodings.at(typeCfg->encodings[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { + aPortType.addCompression(typeCfg->compressions[j]); + _aCompressions.at(typeCfg->compressions[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { + aPortType.addStereoMode(typeCfg->stereoModes[j]); + _aStereoModes.at(typeCfg->stereoModes[j]).enable(); + } + } + + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < configuration->pKPortSize; i++) { + const dsAudioPortConfig_t *port = &configuration->pKPorts[i]; + _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); + _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); + } + +#if 0 if(searchConfigs() == true) { /* @@ -327,6 +491,7 @@ void AudioOutputPortConfig::load() _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } } + #endif } catch(const Exception &e) { From ade5a61c62cb030b5709730f86384ca2a6b77523 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 09:52:33 +0000 Subject: [PATCH 06/66] fix build issue --- ds/audioOutputPortConfig.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index ba9fda68..09dc337a 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -121,7 +121,7 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } -bool searchConfigs(Configs_t *config, char *searchVaribles) +bool searchConfigs(Configs_t *config, const char *searchVaribles[]) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, &searchVaribles[0]); @@ -136,6 +136,7 @@ bool searchConfigs(Configs_t *config, char *searchVaribles) config->pKConfigs = (dsAudioTypeConfig_t *) dlsym(dllib, searchVaribles[0]); if (config->pKConfigs) { INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", config->pKConfigs); + } else { INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); } @@ -149,11 +150,11 @@ bool searchConfigs(Configs_t *config, char *searchVaribles) else { INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); - config->pKConfigSize = -1; + *(config->pKConfigSize) = -1; } config->pKPorts = (dsAudioPortConfig_t *) dlsym(dllib, searchVaribles[1]); - if (config->pKPorts) {; + if (config->pKPorts) { INT_INFO("%d:%s: kAudioPorts is defined and loaded config->pKPorts = %p\n", __LINE__, __func__, config->pKPorts); } else { @@ -168,7 +169,7 @@ bool searchConfigs(Configs_t *config, char *searchVaribles) else { INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); - config->pKPortSize = -1; + *(config->pKPortSize) = -1; } dlclose(dllib); } @@ -200,13 +201,13 @@ bool searchConfigs(Configs_t *config, char *searchVaribles) { INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); } - if(configuration->pKPorts != NULL && *(configuration->pKPortSize) != -1) + if(config->pKPorts != NULL && *(config->pKPortSize) != -1) { /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < *(configuration->pKPortSize); i++) { - const dsAudioPortConfig_t *port = &configuration->pKPorts[i]; + for (size_t i = 0; i < *(config->pKPortSize); i++) { + const dsAudioPortConfig_t *port = &(config->pKPorts[i]); INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); } @@ -217,14 +218,14 @@ bool searchConfigs(Configs_t *config, char *searchVaribles) } INT_INFO("\n\n=========================================================================================================================\n\n"); #endif - if(kConfigs1 == NULL || kConfig_size_local == -1 || kPorts1 == NULL || kPort_size_local == -1) + if(config->pKConfigs == NULL || config->pKConfigSize == -1 || config->pKPorts == NULL || config->pKPortSize == -1) { - printf("Either kAudioConfigs or kAudioPorts is NULL and kConfig_size_local is -1, kPort_size_local is -1\n"); + printf("Either kAudioConfigs or kAudioPorts is NULL and pKConfigSize is -1, pKPortSize is -1\n"); return false; } else { - printf("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); + printf("Both kAudioConfigs and kAudioPorts, pKConfigSize, pKPortSize are valid\n"); return true; } } @@ -389,8 +390,8 @@ void AudioOutputPortConfig::load() * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) */ - for (size_t i = 0; i < configuration->pKConfigSize; i++) { - const dsAudioTypeConfig_t *typeCfg = &(configuration->pKConfigs[i]); + for (size_t i = 0; i < configuration.pKConfigSize; i++) { + const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); aPortType.enable(); for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { @@ -410,8 +411,8 @@ void AudioOutputPortConfig::load() /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < configuration->pKPortSize; i++) { - const dsAudioPortConfig_t *port = &configuration->pKPorts[i]; + for (size_t i = 0; i < configuration.pKPortSize; i++) { + const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } From 6ac6e5000127a71b4c958f894c4eb4d8139e99b7 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 10:01:47 +0000 Subject: [PATCH 07/66] fix build issue --- ds/audioOutputPortConfig.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 09dc337a..3398f862 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -218,7 +218,7 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) } INT_INFO("\n\n=========================================================================================================================\n\n"); #endif - if(config->pKConfigs == NULL || config->pKConfigSize == -1 || config->pKPorts == NULL || config->pKPortSize == -1) + if(config->pKConfigs == NULL || *(config->pKConfigSize) == -1 || config->pKPorts == NULL || *(config->pKPortSize) == -1) { printf("Either kAudioConfigs or kAudioPorts is NULL and pKConfigSize is -1, pKPortSize is -1\n"); return false; @@ -381,16 +381,17 @@ void AudioOutputPortConfig::load() else { INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); - config.pKConfigs = kConfigs; - config.pKConfigSize = dsUTL_DIM(kConfigs); - config.pKPorts = kPorts; - config.pKPortSize = dsUTL_DIM(kPorts); + configuration.pKConfigs = kConfigs; + *(configuration.pKConfigSize) = dsUTL_DIM(kConfigs); + configuration.pKPorts = kPorts; + *(configuration.pKPortSize) = dsUTL_DIM(kPorts); } + INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) */ - for (size_t i = 0; i < configuration.pKConfigSize; i++) { + for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); aPortType.enable(); @@ -411,7 +412,7 @@ void AudioOutputPortConfig::load() /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < configuration.pKPortSize; i++) { + for (size_t i = 0; i < *(configuration.pKPortSize); i++) { const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); From 2dc944b2417c477ce3c9c8f9d34cfdfcda172164 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 10:28:49 +0000 Subject: [PATCH 08/66] fix build issue --- ds/audioOutputPortConfig.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 3398f862..20f24e45 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -42,8 +42,8 @@ static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; typedef struct Configs { - dsAudioTypeConfig_t *pKConfigs; - dsAudioPortConfig_t *pKPorts; + const dsAudioTypeConfig_t *pKConfigs; + const dsAudioPortConfig_t *pKPorts; int *pKConfigSize; int *pKPortSize; }Configs_t; @@ -187,7 +187,7 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) { for (size_t i = 0; i < *(config->pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &config->pKConfigs[i]; + const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); //aPortType.enable(); INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); @@ -347,9 +347,12 @@ void AudioOutputPortConfig::load() dsAudioPortConfig_t *pKPorts = NULL; int *pKConfigSize, *pKPortSize; Configs_t configuration = {0}; - char searchVaribles[][30] = { "kAudioConfigs", "kAudioPorts", "kAudioConfigs_size", "kAudioPorts_size" }; - bool ret; - //static int kConfig_size_local = -1, kPort_size_local = -1; + const char* searchVaribles[] = { + "kAudioConfigs", + "kAudioPorts", + "kAudioConfigs_size", + "kAudioPorts_size" + }; try { /* * Load Constants First. @@ -385,9 +388,9 @@ void AudioOutputPortConfig::load() *(configuration.pKConfigSize) = dsUTL_DIM(kConfigs); configuration.pKPorts = kPorts; *(configuration.pKPortSize) = dsUTL_DIM(kPorts); + INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); } - INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); - /* + /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) */ From f6f3d48c0d83024282574fce79114e95114c3585 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 11:10:04 +0000 Subject: [PATCH 09/66] fix build issue --- ds/audioOutputPortConfig.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 20f24e45..5005ff4c 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -353,6 +353,8 @@ void AudioOutputPortConfig::load() "kAudioConfigs_size", "kAudioPorts_size" }; + bool ret = false; + try { /* * Load Constants First. From 441361bc18ce501eee3c4c430457983609b96d83 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 13:05:35 +0000 Subject: [PATCH 10/66] fix build issue --- ds/audioOutputPortConfig.cpp | 128 +++-------------------------------- 1 file changed, 9 insertions(+), 119 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 5005ff4c..478b6e8b 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -124,10 +124,11 @@ List AudioOutputPortConfig::getSupportedTypes() bool searchConfigs(Configs_t *config, const char *searchVaribles[]) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, &searchVaribles[0]); - INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, &searchVaribles[1]); - INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, &searchVaribles[2]); - INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, &searchVaribles[4]); + INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, searchVaribles[0]); + INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, searchVaribles[1]); + INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, searchVaribles[2]); + INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, searchVaribles[4]); + static int invalidsize = -1; pthread_mutex_lock(&dsLock); @@ -149,8 +150,8 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) } else { - INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); - *(config->pKConfigSize) = -1; + config->pKConfigSize = &invalidsize; + INT_ERROR("%d:%s: kAudioConfigs_size is not defined *(config->pKConfigSize)= %d\n", __LINE__, __func__, *config->pKConfigSize); } config->pKPorts = (dsAudioPortConfig_t *) dlsym(dllib, searchVaribles[1]); @@ -168,8 +169,8 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) } else { - INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); - *(config->pKPortSize) = -1; + config->pKPortSize = &invalidsize; + INT_ERROR("%d:%s: kAudioPorts_size is not defined *(config->pKPortSize)= %d\n", __LINE__, __func__, *config->pKPortSize); } dlclose(dllib); } @@ -230,117 +231,6 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) } } -#if 0 -bool searchConfigs() -{ - pthread_mutex_lock(&dsLock); - - void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - if (dllib) { - kConfigs1 = (dsAudioTypeConfig_t *) dlsym(dllib, "kAudioConfigs"); - if (kConfigs1) { - INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", kConfigs1); - printf("%d:%s: kAudioConfigs is defined and loaded kConfigs1 = %p\n", __LINE__, __func__, kConfigs1); - } - else { - INT_ERROR("kAudioConfigs is not defined\r\n"); - INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); - } - - pKConSize = (int *) dlsym(dllib, "kAudioConfigs_size"); - if(pKConSize) - { - kConfig_size_local = *pKConSize; - INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, kConfig_size_local); - } - else - { - INT_ERROR("%d:%s: kAudioConfigs_size is not defined\n", __LINE__, __func__); - kConfig_size_local = -1; - } - - kPorts1 = (dsAudioPortConfig_t *) dlsym(dllib, "kAudioPorts"); - if (kPorts1) { - INT_INFO("kAudioPorts is defined and loaded kPorts1 = %p\r\n", kPorts1); - INT_INFO("%d:%s: kAudioPorts is defined and loaded kPorts1 = %p\n", __LINE__, __func__, kPorts1); - } - else { - INT_ERROR("kAudioPorts is not defined\r\n"); - INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); - } - - pKPortSize = (int *) dlsym(dllib, "kAudioPorts_size"); - if(pKPortSize) - { - kPort_size_local = *pKPortSize; - INT_INFO("%d:%s: kAudioPorts_size is defined and loaded kPort_size_local = %d\n", __LINE__, __func__, kPort_size_local); - } - else - { - INT_ERROR("%d:%s: kAudioPorts_size is not defined\n", __LINE__, __func__); - kPort_size_local = -1; - } - dlclose(dllib); - } - else { - INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); - } - pthread_mutex_unlock(&dsLock); -#if DEBUG - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); - //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); - //kConfig_size_local = kConfig_size; - //kPort_size_local = kPort_size; - - if(kConfigs1 != NULL && kConfig_size_local != -1) - { - for (size_t i = 0; i < kConfig_size_local; i++) { - const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; - //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - //aPortType.enable(); - INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); - INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); - INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); - INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); - INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); - } - } - else - { - INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); - } - if(kPorts1 != NULL && kPort_size_local != -1) - { - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < kPort_size_local; i++) { - const dsAudioPortConfig_t *port = &kPorts1[i]; - INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); - INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); - } - } - else - { - INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); - } - INT_INFO("\n\n=========================================================================================================================\n\n"); -#endif - if(kConfigs1 == NULL || kConfig_size_local == -1 || kPorts1 == NULL || kPort_size_local == -1) - { - printf("Either kAudioConfigs or kAudioPorts is NULL and kConfig_size_local is -1, kPort_size_local is -1\n"); - return false; - } - else - { - printf("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); - return true; - } - //return (kConfigs1 && kPorts1); -} -#endif - void AudioOutputPortConfig::load() { dsAudioTypeConfig_t *pKConfigs = NULL; From 8d36de9ddaf279be0440fbb4851ef7e310c4b34e Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 13:26:27 +0000 Subject: [PATCH 11/66] fix coverity issue and removed unwanted code. --- ds/audioOutputPortConfig.cpp | 127 +++++++---------------------------- 1 file changed, 26 insertions(+), 101 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 478b6e8b..c26a20cf 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -127,7 +127,7 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, searchVaribles[0]); INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, searchVaribles[1]); INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, searchVaribles[2]); - INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, searchVaribles[4]); + INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, searchVaribles[3]); static int invalidsize = -1; pthread_mutex_lock(&dsLock); @@ -233,9 +233,9 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) void AudioOutputPortConfig::load() { - dsAudioTypeConfig_t *pKConfigs = NULL; - dsAudioPortConfig_t *pKPorts = NULL; - int *pKConfigSize, *pKPortSize; + //dsAudioTypeConfig_t *pKConfigs = NULL; + //dsAudioPortConfig_t *pKPorts = NULL; + int configSize, portSize; Configs_t configuration = {0}; const char* searchVaribles[] = { "kAudioConfigs", @@ -268,99 +268,28 @@ void AudioOutputPortConfig::load() } - ret = searchConfigs(&configuration, searchVaribles); - if (ret == true) - { - INT_INFO("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); - } - else - { - INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); - configuration.pKConfigs = kConfigs; - *(configuration.pKConfigSize) = dsUTL_DIM(kConfigs); - configuration.pKPorts = kPorts; - *(configuration.pKPortSize) = dsUTL_DIM(kPorts); - INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); - } - /* - * Initialize Audio portTypes (encodings, compressions etc.) - * and its port instances (db, level etc) - */ - for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); - AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - aPortType.enable(); - for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { - aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); - _aEncodings.at(typeCfg->encodings[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { - aPortType.addCompression(typeCfg->compressions[j]); - _aCompressions.at(typeCfg->compressions[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { - aPortType.addStereoMode(typeCfg->stereoModes[j]); - _aStereoModes.at(typeCfg->stereoModes[j]).enable(); + ret = searchConfigs(&configuration, searchVaribles); + if (ret == true) + { + INT_INFO("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); } - } - - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(configuration.pKPortSize); i++) { - const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; - _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); - _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); - } - -#if 0 - if(searchConfigs() == true) + else { - /* - * Initialize Audio portTypes (encodings, compressions etc.) - * and its port instances (db, level etc) - */ - if(kConfigs1 != NULL) - { - for (size_t i = 0; i < kConfig_size_local; i++) { - const dsAudioTypeConfig_t *typeCfg = &kConfigs1[i]; - AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - aPortType.enable(); - for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { - aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); - _aEncodings.at(typeCfg->encodings[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { - aPortType.addCompression(typeCfg->compressions[j]); - _aCompressions.at(typeCfg->compressions[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { - aPortType.addStereoMode(typeCfg->stereoModes[j]); - _aStereoModes.at(typeCfg->stereoModes[j]).enable(); - } - } - - /* - * set up ports based on kPorts[] - */ - if(kPorts1 != NULL) - { - for (size_t i = 0; i < kPort_size_local; i++) { - const dsAudioPortConfig_t *port = &kPorts1[i]; - _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); - _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); - } - } - } - + INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); + configuration.pKConfigs = kConfigs; + configSize = dsUTL_DIM(kConfigs); + *(configuration.pKConfigSize) = &configSize; + configuration.pKPorts = kPorts; + portSize = dsUTL_DIM(kPorts); + *(configuration.pKPortSize) = &portSize; + INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); } - else{ /* - * Initialize Audio portTypes (encodings, compressions etc.) - * and its port instances (db, level etc) - */ - for (size_t i = 0; i < dsUTL_DIM(kConfigs); i++) { - const dsAudioTypeConfig_t *typeCfg = &kConfigs[i]; + * Initialize Audio portTypes (encodings, compressions etc.) + * and its port instances (db, level etc) + */ + for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { + const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); aPortType.enable(); for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { @@ -370,25 +299,21 @@ void AudioOutputPortConfig::load() for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { aPortType.addCompression(typeCfg->compressions[j]); _aCompressions.at(typeCfg->compressions[j]).enable(); - } for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { aPortType.addStereoMode(typeCfg->stereoModes[j]); _aStereoModes.at(typeCfg->stereoModes[j]).enable(); - } } /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < dsUTL_DIM(kPorts); i++) { - const dsAudioPortConfig_t *port = &kPorts[i]; + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < *(configuration.pKPortSize); i++) { + const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } - } - #endif } catch(const Exception &e) { From c676229dad9eb3e13cd7a8e0af0b4d56c30ae0f6 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 5 Nov 2025 13:32:41 +0000 Subject: [PATCH 12/66] Fix build issue. --- ds/audioOutputPortConfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index c26a20cf..98d51c7b 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -278,10 +278,10 @@ void AudioOutputPortConfig::load() INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); configuration.pKConfigs = kConfigs; configSize = dsUTL_DIM(kConfigs); - *(configuration.pKConfigSize) = &configSize; + configuration.pKConfigSize = &configSize; configuration.pKPorts = kPorts; portSize = dsUTL_DIM(kPorts); - *(configuration.pKPortSize) = &portSize; + configuration.pKPortSize = &portSize; INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); } /* From 968901dd4effe3ba0afe37e100620ceff52490aa Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 6 Nov 2025 11:47:11 +0000 Subject: [PATCH 13/66] Addressed review comments. --- ds/audioOutputPortConfig.cpp | 116 ++++++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 98d51c7b..e87dabbc 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -121,6 +121,80 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } +bool searchConfigs(void *pConfigVar, char *searchConfigStr) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); + + static int invalidsize = -1; + + pthread_mutex_lock(&dsLock); + + void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + if (dllib) { + pConfigVar = (void *) dlsym(dllib, searchConfigStr); + if (pConfigVar != NULL) { + INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, pConfigVar); + } + else { + INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); + } + + dlclose(dllib); + } + else { + INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME); + } + pthread_mutex_unlock(&dsLock); + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); +} + +void dumpconfig(Configs_t *config) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); + INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); + INT_INFO("%d:%s: pKConfigSize = %p\n", __LINE__, __func__, config->pKConfigSize); + INT_INFO("%d:%s: pKPortSize = %p\n", __LINE__, __func__, config->pKPortSize); + + INT_INFO("\n\n=========================================================================================================================\n\n"); + if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) + { + for (size_t i = 0; i < *(config->pKConfigSize); i++) { + const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); + //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + //aPortType.enable(); + INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); + INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); + INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); + INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); + INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); + } + } + else + { + INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); + } + if(config->pKPorts != NULL && *(config->pKPortSize) != -1) + { + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < *(config->pKPortSize); i++) { + const dsAudioPortConfig_t *port = &(config->pKPorts[i]); + INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); + INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); + } + } + else + { + INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); + } + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); +} + +#if 0 bool searchConfigs(Configs_t *config, const char *searchVaribles[]) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); @@ -230,6 +304,7 @@ bool searchConfigs(Configs_t *config, const char *searchVaribles[]) return true; } } +#endif void AudioOutputPortConfig::load() { @@ -267,7 +342,7 @@ void AudioOutputPortConfig::load() _aPortTypes.push_back(AudioOutputPortType(i)); } - +#if 0 ret = searchConfigs(&configuration, searchVaribles); if (ret == true) { @@ -284,6 +359,45 @@ void AudioOutputPortConfig::load() configuration.pKPortSize = &portSize; INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); } +#endif + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs(configuration.pKConfigs, searchVaribles[0]); + if(ret == true) + { + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs(configuration.pKConfigSize, (char *)searchVaribles[2]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs(configuration.pKPorts, searchVaribles[1]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs((void *)configuration.pKPortSize, (char *)searchVaribles[3]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + } + } + else + { + INT_ERROR("Invalid kAudioConfigs or kAudioPorts, pKConfigSize, pKPortSize\n"); + configuration.pKConfigs = kConfigs; + configSize = dsUTL_DIM(kConfigs); + configuration.pKConfigSize = &configSize; + configuration.pKPorts = kPorts; + portSize = dsUTL_DIM(kPorts); + configuration.pKPortSize = &portSize; + INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); + } + #if DEBUG + dumpconfig(&configuration); + #endif + /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) From 513b3c74c4a35e488c40f2d80b3574c0543a60cf Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 6 Nov 2025 12:43:46 +0000 Subject: [PATCH 14/66] Addressed review comments. --- ds/audioOutputPortConfig.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index e87dabbc..2aa7ad9c 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -121,7 +121,7 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } -bool searchConfigs(void *pConfigVar, char *searchConfigStr) +bool searchConfigs(void **pConfigVar, const char *searchConfigStr) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); @@ -132,9 +132,9 @@ bool searchConfigs(void *pConfigVar, char *searchConfigStr) void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); if (dllib) { - pConfigVar = (void *) dlsym(dllib, searchConfigStr); - if (pConfigVar != NULL) { - INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, pConfigVar); + *pConfigVar = (void *) dlsym(dllib, searchConfigStr); + if (*pConfigVar != NULL) { + INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); } else { INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); @@ -145,8 +145,9 @@ bool searchConfigs(void *pConfigVar, char *searchConfigStr) else { INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME); } - pthread_mutex_unlock(&dsLock); + pthread_mutex_unlock(&dsLock); INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + return (*pConfigVar != NULL); } void dumpconfig(Configs_t *config) @@ -312,7 +313,7 @@ void AudioOutputPortConfig::load() //dsAudioPortConfig_t *pKPorts = NULL; int configSize, portSize; Configs_t configuration = {0}; - const char* searchVaribles[] = { + const char* searchVaribles[] = { "kAudioConfigs", "kAudioPorts", "kAudioConfigs_size", @@ -361,23 +362,23 @@ void AudioOutputPortConfig::load() } #endif INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(configuration.pKConfigs, searchVaribles[0]); + ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(configuration.pKConfigSize, (char *)searchVaribles[2]); + ret = searchConfigs((void **)&configuration.pKConfigSize, (char *)searchVaribles[2]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[2]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(configuration.pKPorts, searchVaribles[1]); + ret = searchConfigs((void **)&configuration.pKPorts, searchVaribles[1]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs((void *)configuration.pKPortSize, (char *)searchVaribles[3]); + ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); From fb4785de74e505e09aa7f64255f221e96a95c734 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 10 Nov 2025 14:11:02 +0000 Subject: [PATCH 15/66] addressed review comments. --- ds/audioOutputPortConfig.cpp | 154 ++------------------------- ds/include/manager.hpp | 2 + ds/manager.cpp | 36 +++++++ ds/videoDeviceConfig.cpp | 64 ++++++++++- ds/videoOutputPortConfig.cpp | 198 +++++++++++++++++++++++++++++++++-- 5 files changed, 299 insertions(+), 155 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 2aa7ad9c..d01e78b6 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -35,18 +35,18 @@ #include "stdlib.h" #include "dslogger.h" #include +#include "manager.hpp" -#define DEBUG 1 -static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; +#define DEBUG 1 // Using for dumpconfig -typedef struct Configs +typedef struct audioConfigs { const dsAudioTypeConfig_t *pKConfigs; const dsAudioPortConfig_t *pKPorts; int *pKConfigSize; int *pKPortSize; -}Configs_t; +}audioConfigs_t; namespace device { @@ -121,6 +121,7 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } +#if 0 bool searchConfigs(void **pConfigVar, const char *searchConfigStr) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); @@ -149,8 +150,8 @@ bool searchConfigs(void **pConfigVar, const char *searchConfigStr) INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); return (*pConfigVar != NULL); } - -void dumpconfig(Configs_t *config) +#endif +void dumpconfig(audioConfigs_t *config) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); @@ -163,8 +164,6 @@ void dumpconfig(Configs_t *config) { for (size_t i = 0; i < *(config->pKConfigSize); i++) { const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); - //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - //aPortType.enable(); INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); @@ -178,9 +177,6 @@ void dumpconfig(Configs_t *config) } if(config->pKPorts != NULL && *(config->pKPortSize) != -1) { - /* - * set up ports based on kPorts[] - */ for (size_t i = 0; i < *(config->pKPortSize); i++) { const dsAudioPortConfig_t *port = &(config->pKPorts[i]); INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); @@ -195,124 +191,11 @@ void dumpconfig(Configs_t *config) INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); } -#if 0 -bool searchConfigs(Configs_t *config, const char *searchVaribles[]) -{ - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: searchVaribles[0] = %s\n", __LINE__, __func__, searchVaribles[0]); - INT_INFO("%d:%s: searchVaribles[1] = %s\n", __LINE__, __func__, searchVaribles[1]); - INT_INFO("%d:%s: searchVaribles[2] = %s\n", __LINE__, __func__, searchVaribles[2]); - INT_INFO("%d:%s: searchVaribles[3] = %s\n", __LINE__, __func__, searchVaribles[3]); - static int invalidsize = -1; - - pthread_mutex_lock(&dsLock); - - void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - if (dllib) { - config->pKConfigs = (dsAudioTypeConfig_t *) dlsym(dllib, searchVaribles[0]); - if (config->pKConfigs) { - INT_INFO("kAudioConfigs is defined and loaded kConfigs1 = %p\r\n", config->pKConfigs); - } - else { - INT_ERROR("%d:%s: kAudioConfigs is not defined\n", __LINE__, __func__); - } - - config->pKConfigSize = (int *) dlsym(dllib, searchVaribles[2]); - if(config->pKConfigSize) - { - //kConfig_size_local = *pKConSize; - INT_INFO("%d:%s: kAudioConfigs_size is defined and loaded kConfig_size_local = %d\n", __LINE__, __func__, *config->pKConfigSize); - } - else - { - config->pKConfigSize = &invalidsize; - INT_ERROR("%d:%s: kAudioConfigs_size is not defined *(config->pKConfigSize)= %d\n", __LINE__, __func__, *config->pKConfigSize); - } - - config->pKPorts = (dsAudioPortConfig_t *) dlsym(dllib, searchVaribles[1]); - if (config->pKPorts) { - INT_INFO("%d:%s: kAudioPorts is defined and loaded config->pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - } - else { - INT_ERROR("%d:%s: kAudioPorts is not defined\n", __LINE__, __func__); - } - - config->pKPortSize = (int *) dlsym(dllib, searchVaribles[3]); - if(config->pKPortSize) - { - INT_INFO("%d:%s: kAudioPorts_size is defined and loaded config->pKPortSize = %d\n", __LINE__, __func__, *config->pKPortSize); - } - else - { - config->pKPortSize = &invalidsize; - INT_ERROR("%d:%s: kAudioPorts_size is not defined *(config->pKPortSize)= %d\n", __LINE__, __func__, *config->pKPortSize); - } - dlclose(dllib); - } - else { - INT_ERROR("%d:%s: Opening libds-hal.so failed\n", __LINE__, __func__); - } - pthread_mutex_unlock(&dsLock); -#if DEBUG - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("\n%d:%s print configs using extern\n", __LINE__, __func__); - //printf("%d:%s: size of(kConfig_audio) = %d size of(kPort_audio) = %d\n", __LINE__, __func__, kConfig_size, kPort_size); - //kConfig_size_local = kConfig_size; - //kPort_size_local = kPort_size; - - if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) - { - for (size_t i = 0; i < *(config->pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); - //AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - //aPortType.enable(); - INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); - INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); - INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); - INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); - INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); - } - } - else - { - INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); - } - if(config->pKPorts != NULL && *(config->pKPortSize) != -1) - { - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(config->pKPortSize); i++) { - const dsAudioPortConfig_t *port = &(config->pKPorts[i]); - INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); - INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); - } - } - else - { - INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); - } - INT_INFO("\n\n=========================================================================================================================\n\n"); -#endif - if(config->pKConfigs == NULL || *(config->pKConfigSize) == -1 || config->pKPorts == NULL || *(config->pKPortSize) == -1) - { - printf("Either kAudioConfigs or kAudioPorts is NULL and pKConfigSize is -1, pKPortSize is -1\n"); - return false; - } - else - { - printf("Both kAudioConfigs and kAudioPorts, pKConfigSize, pKPortSize are valid\n"); - return true; - } -} -#endif void AudioOutputPortConfig::load() { - //dsAudioTypeConfig_t *pKConfigs = NULL; - //dsAudioPortConfig_t *pKPorts = NULL; int configSize, portSize; - Configs_t configuration = {0}; + audioConfigs_t configuration = {0}; const char* searchVaribles[] = { "kAudioConfigs", "kAudioPorts", @@ -343,24 +226,7 @@ void AudioOutputPortConfig::load() _aPortTypes.push_back(AudioOutputPortType(i)); } -#if 0 - ret = searchConfigs(&configuration, searchVaribles); - if (ret == true) - { - INT_INFO("Both kAudioConfigs and kAudioPorts, kConfig_size_local, kPort_size_local are valid\n"); - } - else - { - INT_ERROR("Invalid kAudioConfigs or kAudioPorts, kConfig_size_local, kPort_size_local\n"); - configuration.pKConfigs = kConfigs; - configSize = dsUTL_DIM(kConfigs); - configuration.pKConfigSize = &configSize; - configuration.pKPorts = kPorts; - portSize = dsUTL_DIM(kPorts); - configuration.pKPortSize = &portSize; - INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); - } -#endif + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]); if(ret == true) @@ -386,7 +252,7 @@ void AudioOutputPortConfig::load() } else { - INT_ERROR("Invalid kAudioConfigs or kAudioPorts, pKConfigSize, pKPortSize\n"); + INT_ERROR("Read Old Configs\n"); configuration.pKConfigs = kConfigs; configSize = dsUTL_DIM(kConfigs); configuration.pKConfigSize = &configSize; diff --git a/ds/include/manager.hpp b/ds/include/manager.hpp index 2539569a..089e0e49 100644 --- a/ds/include/manager.hpp +++ b/ds/include/manager.hpp @@ -156,6 +156,8 @@ */ namespace device { +// Forward declaration for searchConfigs function +bool searchConfigs(void **pConfigVar, const char *searchConfigStr); /** * @class Manager diff --git a/ds/manager.cpp b/ds/manager.cpp index eedcd8b2..2fc92ad2 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -43,6 +43,12 @@ #include "exception.hpp" #include #include +#include +#include "dsHALConfig.h" + + +static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; + /** * @file manager.cpp @@ -154,6 +160,36 @@ void Manager::load() printf("%d:%s load completed\n", __LINE__, __FUNCTION__); } +bool searchConfigs(void **pConfigVar, const char *searchConfigStr) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); + + static int invalidsize = -1; + + pthread_mutex_lock(&dsLock); + + void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + if (dllib) { + *pConfigVar = (void *) dlsym(dllib, searchConfigStr); + if (*pConfigVar != NULL) { + INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); + } + else { + INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); + } + + dlclose(dllib); + } + else { + INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME); + } + pthread_mutex_unlock(&dsLock); + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + return (*pConfigVar != NULL); +} + + /** * @fn void Manager::DeInitialize() * @brief This API is used to deinitialize the device settings module. diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 0a25b478..c612e125 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -33,7 +33,9 @@ #include "videoDFC.hpp" #include #include "dslogger.h" +#include "manager.hpp" +#define DEBUG 1 // Using for dumpconfig namespace device { @@ -86,8 +88,42 @@ VideoDFC & VideoDeviceConfig::getDefaultDFC() return _vDFCs.back(); } +void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_size) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); + INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); + + INT_INFO("\n\n=========================================================================================================================\n\n"); + if(pKVideoDeviceConfigs != NULL && videoDeviceConfigs_size != -1) + { + for (size_t i = 0; i < videoDeviceConfigs_size; i++) { + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %d\n ", i, pKVideoDeviceConfigs[i]->numSupportedDFCs); + for (size_t j = 0; j < pKVideoDeviceConfigs[i]->numSupportedDFCs; j++) { + INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, pKVideoDeviceConfigs[i]->supportedDFCs[j]); + } + } + } + else + { + INT_ERROR("%d:%s: kVideoDeviceConfigs is NULL and videoDeviceConfigs_size is -1\n", __LINE__, __func__); + } + + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); +} + void VideoDeviceConfig::load() { + int configSize, portSize, invalid_size = -1; + dsVideoConfig_t *pKVideoDeviceConfigs = NULL; + int *pKVideoDeviceConfigs_size = NULL; + const char* searchVaribles[] = { + "kVideoDeviceConfigs", + "kVideoDeviceConfigs_size", + }; + bool ret = false; + /* * Load Constants First. */ @@ -95,16 +131,38 @@ void VideoDeviceConfig::load() _vDFCs.push_back(VideoDFC(i)); } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs((void **)&pKVideoDeviceConfigs, searchVaribles[0]); + if(ret == true) + { + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs((void **)&pKVideoDeviceConfigs_size, (char *)searchVaribles[1]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + } + } + else + { + pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; + *pKVideoDeviceConfigs_size = dsUTL_DIM(kConfigs); + } + #if DEBUG + dumpconfig(pKVideoDeviceConfigs, *pKVideoDeviceConfigs_size); + #endif + /* * Initialize Video Devices (supported DFCs etc.) */ - for (size_t i = 0; i < dsUTL_DIM(kConfigs); i++) { + for (size_t i = 0; i < *pKVideoDeviceConfigs_size; i++) { _vDevices.push_back(VideoDevice(i)); - for (size_t j = 0; j < kConfigs[i].numSupportedDFCs; j++) { - _vDevices.at(i).addDFC(VideoDFC::getInstance(kConfigs[i].supportedDFCs[j])); + for (size_t j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { + _vDevices.at(i).addDFC(VideoDFC::getInstance(pKVideoDeviceConfigs[i].supportedDFCs[j])); } } + + } void VideoDeviceConfig::release() diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 8f1e475c..55482f80 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -50,6 +50,18 @@ #include using namespace std; +#define DEBUG 1 // Using for dumpconfig + +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKConfigs; + int *pKVideoPortConfigs_size; + const kVideoPortPorts *pKPorts; + int *pKVideoPortPorts_size; + const dsVideoPortResolution_t *pKResolutionsSettings; + int *pKResolutionsSettings_size; +}videoPortConfigs_t; + namespace device { static VideoResolution* defaultVideoResolution; @@ -263,10 +275,124 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn return supportedResolutions; } +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKConfigs; + int *pKVideoPortConfigs_size; + const kVideoPortPorts *pKPorts; + int *pKVideoPortPorts_size; + const dsVideoPortResolution_t *pKResolutionsSettings; + int *pKResolutionsSettings_size; +}videoPortConfigs_t; + +void dumpconfig(videoPortConfigs_t *config) +{ + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); + INT_INFO("%d:%s: pKConfigSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortConfigs_size, *(config->pKVideoPortConfigs_size)); + INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); + INT_INFO("%d:%s: pKPortSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortPorts_size, *(config->pKVideoPortPorts_size)); + INT_INFO("%d:%s: pKResolutionsSettings = %p\n", __LINE__, __func__, config->pKResolutionsSettings); + INT_INFO("%d:%s: pKResolutionsSettingsSize pointer %p = %d\n", __LINE__, __func__, config->pKResolutionsSettings_size, *(config->pKResolutionsSettings_size)); + + INT_INFO("\n\n=========================================================================================================================\n\n"); + if(config->pKConfigs != NULL && *(config->pKVideoPortConfigs_size) != -1 && + config->pKPorts != NULL && *(config->pKVideoPortPorts_size) != -1 && + config->pKResolutionsSettings != NULL && *(config->pKResolutionsSettings_size) != -1 ) + { + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("%d:%s: Dumping Resolutions Settings\n", __LINE__, __func__); + for (size_t i = 0; i < *(config->pKResolutionsSettings_size); i++) { + dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); + INT_INFO("%d:%s: resolution->name = %s\n", __LINE__, __func__, resolution->name); + INT_INFO("%d:%s: resolution->pixelResolution= %d\n", __LINE__, __func__, resolution->pixelResolution); + INT_INFO("%d:%s: resolution->aspectRatio= %d\n", __LINE__, __func__, resolution->aspectRatio); + INT_INFO("%d:%s: resolution->stereoScopicMode= %d\n", __LINE__, __func__, resolution->stereoScopicMode); + INT_INFO("%d:%s: resolution->frameRate= %d\n", __LINE__, __func__, resolution->frameRate); + INT_INFO("%d:%s: resolution->interlaced= %d\n", __LINE__, __func__, resolution->interlaced); + } + INT_INFO("\n\n####################################################################### \n\n"); + #if 0 + /*.typeId = */ dsVIDEOPORT_TYPE_INTERNAL, + /*.name = */ "INTERNAL", + /*.dtcpSupported = */ false, + /*.hdcpSupported = */ true, + /*.restrictedResollution = */ -1, + /*.numSupportedResolutions = */ dsUTL_DIM(kResolutions), // 0 means "Info available at runtime" + /*.supportedResolutons = */ kResolutions, + #endif + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("%d:%s: Dumping Video Port Configurations\n", __LINE__, __func__); + for (size_t i = 0; i < *(config->pKVideoPortConfigs_size); i++) + { + const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); + INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); + INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); + INT_INFO("%d:%s: typeCfg->dtcpSupported= %d\n", __LINE__, __func__, typeCfg->dtcpSupported); + INT_INFO("%d:%s: typeCfg->hdcpSupported = %d\n", __LINE__, __func__, typeCfg->hdcpSupported); + INT_INFO("%d:%s: typeCfg->restrictedResollution = %d\n", __LINE__, __func__, typeCfg->restrictedResollution); + INT_INFO("%d:%s: typeCfg->numSupportedResolutions= %d\n", __LINE__, __func__, typeCfg->numSupportedResolutions); + #if 0 + typedef struct _dsVideoPortResolution_t { + char name[32]; ///< Name the resolution + dsVideoResolution_t pixelResolution; ///< The resolution associated with the name + dsVideoAspectRatio_t aspectRatio; ///< The associated aspect ratio + dsVideoStereoScopicMode_t stereoScopicMode; ///< The associated stereoscopic mode + dsVideoFrameRate_t frameRate; ///< The associated frame rate + bool interlaced; ///< The associated scan mode( @a true if interlaced, @a false if progressive ) + }dsVideoPortResolution_t; + #endif + INT_INFO("%d:%s: typeCfg->supportedResolutons = %p\n", __LINE__, __func__, typeCfg->supportedResolutons); + INT_INFO("%d:%s: typeCfg->supportedResolutons->name = %s\n", __LINE__, __func__, typeCfg->supportedResolutons->name); + INT_INFO("%d:%s: typeCfg->supportedResolutons->pixelResolution= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->pixelResolution); + INT_INFO("%d:%s: typeCfg->supportedResolutons->aspectRatio= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->aspectRatio); + INT_INFO("%d:%s: typeCfg->supportedResolutons->stereoScopicMode= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->stereoScopicMode); + INT_INFO("%d:%s: typeCfg->supportedResolutons->frameRate= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->frameRate); + INT_INFO("%d:%s: typeCfg->supportedResolutons->interlaced= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->interlaced); + } + INT_INFO("\n\n####################################################################### \n\n"); + #if 0 + { + /*.typeId = */ {dsVIDEOPORT_TYPE_INTERNAL, 0}, + /* connectedAOP */ {dsAUDIOPORT_TYPE_SPEAKER, 0}, + /*.defaultResolution = */ "1080i50" + } + #endif + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("%d:%s: Dumping Video Port Connections\n", __LINE__, __func__); + for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { + const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); + INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); + INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); + INT_INFO("%d:%s: port->connectedAOP.type = %d\n", __LINE__, __func__, port->connectedAOP.type); + INT_INFO("%d:%s: port->connectedAOP.index = %d\n", __LINE__, __func__, port->connectedAOP.index); + INT_INFO("%d:%s: port->defaultResolution = %s\n", __LINE__, __func__, port->defaultResolution); + } + INT_INFO("\n\n####################################################################### \n\n"); + } + else + { + INT_ERROR("%d:%s: pKConfigs or pKPorts or pKResolutionsSettings is NULL, and pKVideoPortConfigs_size or pKVideoPortPorts_size or pKResolutionsSettings_size is -1\n", __LINE__, __func__); + } + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); +} void VideoOutputPortConfig::load() { + int configSize, portSize, resolutionSize; + videoPortConfigs_t configuration = {0}; + const char* searchVaribles[] = { + "kVideoPortConfigs", + "kVideoPortConfigs_size", + "kVideoPortPorts", + "kVideoPortPorts_size", + "kResolutionsSettings", + "kResolutionsSettings_size" + }; + bool ret = false; + try { /* * Load Constants First. @@ -288,12 +414,68 @@ void VideoOutputPortConfig::load() _vPortTypes.push_back(VideoOutputPortType((int)i)); } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]); + if(ret == true) + { + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs((void **)&configuration.pKConfigSize, (char *)searchVaribles[1]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs((void **)&configuration.pKPorts, searchVaribles[2]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + } + // Resolutions + ret = searchConfigs((void **)&configuration.pKResolutionsSettings, searchVaribles[4]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[4]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); + ret = searchConfigs((void **)&configuration.pKResolutionsSettings_size, (char *)searchVaribles[5]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[5]); + } + } + else + { + INT_ERROR("Read Old Configs\n"); + configuration.pKConfigs = kConfigs; + configSize = dsUTL_DIM(kConfigs); + configuration.pKConfigSize = &configSize; + configuration.pKPorts = kPorts; + portSize = dsUTL_DIM(kPorts); + configuration.pKPortSize = &portSize; + configuration.pKResolutionsSettings = kResolutions; + resolutionSize = dsUTL_DIM(kResolutions); + configuration.pKResolutionsSettings_size = &resolutionSize; + INT_INFO("configuration.pKConfigs =%p, *(configuration.pKConfigSize) = %d\n", configuration.pKConfigs, *(configuration.pKConfigSize)); + INT_INFO("configuration.pKPorts =%p, *(configuration.pKPortSize) = %d\n", configuration.pKPorts, *(configuration.pKPortSize)); + INT_INFO("configuration.pKResolutionsSettings =%p, *(configuration.pKResolutionsSettings_size) = %d\n", configuration.pKResolutionsSettings, *(configuration.pKResolutionsSettings_size)); + } + #if DEBUG + dumpconfig(&configuration); + #endif + + /* Initialize a set of supported resolutions * */ - size_t numResolutions = dsUTL_DIM(kResolutions); - for (size_t i = 0; i < numResolutions; i++) { - dsVideoPortResolution_t *resolution = &kResolutions[i]; + //size_t numResolutions = dsUTL_DIM(kResolutions); + for (size_t i = 0; i < *(configuration.pKResolutionsSettings_size); i++) { + dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); {std::lock_guard lock(gSupportedResolutionsMutex); _supportedResolutions.push_back( VideoResolution( @@ -312,9 +494,9 @@ void VideoOutputPortConfig::load() * Initialize Video portTypes (Only Enable POrts) * and its port instances (curr resolution) */ - for (size_t i = 0; i < dsUTL_DIM(kConfigs); i++) + for (size_t i = 0; i < *(configuration.pKVideoPortConfigs_size); i++) { - const dsVideoPortTypeConfig_t *typeCfg = &kConfigs[i]; + const dsVideoPortTypeConfig_t *typeCfg = &()configuration.pKConfigs[i]; VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); vPortType.enable(); vPortType.setRestrictedResolution(typeCfg->restrictedResollution); @@ -323,12 +505,12 @@ void VideoOutputPortConfig::load() /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < dsUTL_DIM(kPorts); i++) { - const dsVideoPortPortConfig_t *port = &kPorts[i]; + for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { + const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); _vPorts.push_back( VideoOutputPort((port->id.type), port->id.index, i, - AudioOutputPortType::getInstance(kPorts[i].connectedAOP.type).getPort(kPorts[i].connectedAOP.index).getId(), + AudioOutputPortType::getInstance(configuration.pKPorts[i].connectedAOP.type).getPort(configuration.pKPorts[i].connectedAOP.index).getId(), std::string(port->defaultResolution))); _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); From 35661b4d646fc30e3a90aaea6ed01c597c071aad Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 11 Nov 2025 15:27:31 +0000 Subject: [PATCH 16/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/videoDeviceConfig.cpp | 14 +++++++-- ds/videoOutputPortConfig.cpp | 57 +++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index c612e125..965aecf2 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -88,19 +88,27 @@ VideoDFC & VideoDeviceConfig::getDefaultDFC() return _vDFCs.back(); } + void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_size) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); + #if 0 + typedef struct _dsVideoConfig_t { + size_t numSupportedDFCs; /*!< Number of zoom modes supported */ + const dsVideoZoom_t *supportedDFCs; /*!< List of zoom modes supported */ + dsVideoZoom_t defaultDFC; /*!< The default zoom mode */ + } dsVideoConfig_t; + #endif INT_INFO("\n\n=========================================================================================================================\n\n"); if(pKVideoDeviceConfigs != NULL && videoDeviceConfigs_size != -1) { for (size_t i = 0; i < videoDeviceConfigs_size; i++) { - INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %d\n ", i, pKVideoDeviceConfigs[i]->numSupportedDFCs); - for (size_t j = 0; j < pKVideoDeviceConfigs[i]->numSupportedDFCs; j++) { - INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, pKVideoDeviceConfigs[i]->supportedDFCs[j]); + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %d\n ", i, pKVideoDeviceConfigs[i].numSupportedDFCs); + for (size_t j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { + INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, pKVideoDeviceConfigs[i].supportedDFCs[j]); } } } diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 55482f80..9fbe7637 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -42,6 +42,7 @@ #include "videoResolution.hpp" #include "dslogger.h" #include "host.hpp" +#include "manager.hpp" #include @@ -56,9 +57,9 @@ typedef struct videoPortConfigs { const dsVideoPortTypeConfig_t *pKConfigs; int *pKVideoPortConfigs_size; - const kVideoPortPorts *pKPorts; + const dsVideoPortPortConfig_t *pKPorts; int *pKVideoPortPorts_size; - const dsVideoPortResolution_t *pKResolutionsSettings; + dsVideoPortResolution_t *pKResolutionsSettings; int *pKResolutionsSettings_size; }videoPortConfigs_t; @@ -275,15 +276,6 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn return supportedResolutions; } -typedef struct videoPortConfigs -{ - const dsVideoPortTypeConfig_t *pKConfigs; - int *pKVideoPortConfigs_size; - const kVideoPortPorts *pKPorts; - int *pKVideoPortPorts_size; - const dsVideoPortResolution_t *pKResolutionsSettings; - int *pKResolutionsSettings_size; -}videoPortConfigs_t; void dumpconfig(videoPortConfigs_t *config) { @@ -327,6 +319,17 @@ void dumpconfig(videoPortConfigs_t *config) for (size_t i = 0; i < *(config->pKVideoPortConfigs_size); i++) { const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); + #if 0 + typedef struct _dsVideoPortTypeConfig_t { + dsVideoPortType_t typeId; ///< The video output type + const char *name; ///< Name of the video output port + bool dtcpSupported; ///< Is DTCP supported? + bool hdcpSupported; ///< Is HDCP supported? + int32_t restrictedResollution; ///< Any restricted resolution; -1 if no. + size_t numSupportedResolutions; ///< Number of supported resolutions + dsVideoPortResolution_t *supportedResolutions; ///< List of supported resolutions + } dsVideoPortTypeConfig_t; + #endif INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); INT_INFO("%d:%s: typeCfg->dtcpSupported= %d\n", __LINE__, __func__, typeCfg->dtcpSupported); @@ -343,13 +346,13 @@ void dumpconfig(videoPortConfigs_t *config) bool interlaced; ///< The associated scan mode( @a true if interlaced, @a false if progressive ) }dsVideoPortResolution_t; #endif - INT_INFO("%d:%s: typeCfg->supportedResolutons = %p\n", __LINE__, __func__, typeCfg->supportedResolutons); - INT_INFO("%d:%s: typeCfg->supportedResolutons->name = %s\n", __LINE__, __func__, typeCfg->supportedResolutons->name); - INT_INFO("%d:%s: typeCfg->supportedResolutons->pixelResolution= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->pixelResolution); - INT_INFO("%d:%s: typeCfg->supportedResolutons->aspectRatio= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->aspectRatio); - INT_INFO("%d:%s: typeCfg->supportedResolutons->stereoScopicMode= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->stereoScopicMode); - INT_INFO("%d:%s: typeCfg->supportedResolutons->frameRate= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->frameRate); - INT_INFO("%d:%s: typeCfg->supportedResolutons->interlaced= %d\n", __LINE__, __func__, typeCfg->supportedResolutons->interlaced); + INT_INFO("%d:%s: typeCfg->supportedResolutions = %p\n", __LINE__, __func__, typeCfg->supportedResolutions); + INT_INFO("%d:%s: typeCfg->supportedResolutions->name = %s\n", __LINE__, __func__, typeCfg->supportedResolutions->name); + INT_INFO("%d:%s: typeCfg->supportedResolutions->pixelResolution= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->pixelResolution); + INT_INFO("%d:%s: typeCfg->supportedResolutions->aspectRatio= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->aspectRatio); + INT_INFO("%d:%s: typeCfg->supportedResolutions->stereoScopicMode= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("%d:%s: typeCfg->supportedResolutions->frameRate= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->frameRate); + INT_INFO("%d:%s: typeCfg->supportedResolutions->interlaced= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->interlaced); } INT_INFO("\n\n####################################################################### \n\n"); #if 0 @@ -361,8 +364,8 @@ void dumpconfig(videoPortConfigs_t *config) #endif INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("%d:%s: Dumping Video Port Connections\n", __LINE__, __func__); - for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { - const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); + for (size_t i = 0; i < *(config->pKVideoPortPorts_size); i++) { + const dsVideoPortPortConfig_t *port = &(config->pKPorts[i]); INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); INT_INFO("%d:%s: port->connectedAOP.type = %d\n", __LINE__, __func__, port->connectedAOP.type); @@ -419,7 +422,7 @@ void VideoOutputPortConfig::load() if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&configuration.pKConfigSize, (char *)searchVaribles[1]); + ret = searchConfigs((void **)&configuration.pKVideoPortConfigs_size, (char *)searchVaribles[1]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); @@ -431,7 +434,7 @@ void VideoOutputPortConfig::load() INT_ERROR("%s is not defined\n", searchVaribles[2]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]); + ret = searchConfigs((void **)&configuration.pKVideoPortPorts_size, (char *)searchVaribles[3]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); @@ -454,15 +457,15 @@ void VideoOutputPortConfig::load() INT_ERROR("Read Old Configs\n"); configuration.pKConfigs = kConfigs; configSize = dsUTL_DIM(kConfigs); - configuration.pKConfigSize = &configSize; + configuration.pKVideoPortConfigs_size = &configSize; configuration.pKPorts = kPorts; portSize = dsUTL_DIM(kPorts); - configuration.pKPortSize = &portSize; + configuration.pKVideoPortPorts_size = &portSize; configuration.pKResolutionsSettings = kResolutions; resolutionSize = dsUTL_DIM(kResolutions); configuration.pKResolutionsSettings_size = &resolutionSize; - INT_INFO("configuration.pKConfigs =%p, *(configuration.pKConfigSize) = %d\n", configuration.pKConfigs, *(configuration.pKConfigSize)); - INT_INFO("configuration.pKPorts =%p, *(configuration.pKPortSize) = %d\n", configuration.pKPorts, *(configuration.pKPortSize)); + INT_INFO("configuration.pKConfigs =%p, *(configuration.pKConfigSize) = %d\n", configuration.pKConfigs, *(configuration.pKVideoPortConfigs_size)); + INT_INFO("configuration.pKPorts =%p, *(configuration.pKPortSize) = %d\n", configuration.pKPorts, *(configuration.pKVideoPortPorts_size)); INT_INFO("configuration.pKResolutionsSettings =%p, *(configuration.pKResolutionsSettings_size) = %d\n", configuration.pKResolutionsSettings, *(configuration.pKResolutionsSettings_size)); } #if DEBUG @@ -496,7 +499,7 @@ void VideoOutputPortConfig::load() */ for (size_t i = 0; i < *(configuration.pKVideoPortConfigs_size); i++) { - const dsVideoPortTypeConfig_t *typeCfg = &()configuration.pKConfigs[i]; + const dsVideoPortTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); vPortType.enable(); vPortType.setRestrictedResolution(typeCfg->restrictedResollution); From 4c52eebc34c6b8d6b08f096fc51cb0ddbe0922ae Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 12 Nov 2025 10:46:22 +0000 Subject: [PATCH 17/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/frontPanelConfig.cpp | 99 ++++++++++++++++++++++++++++++++++++---- ds/videoDeviceConfig.cpp | 35 +++++++++----- 2 files changed, 115 insertions(+), 19 deletions(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index e8c932b2..2a1a6ee0 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -41,9 +41,18 @@ #include "frontPanelSettings.hpp" #include "illegalArgumentException.hpp" #include "dslogger.h" +#include "manager.hpp" using namespace std; +typedef struct fpdConfigs +{ + const dsFPDColorConfig_t *pKFPDIndicatorColors; + const dsFPDIndicatorConfig_t *pKIndicators; + int *pKFPDIndicatorColors_size; + int *pKIndicators_size; +}fpdConfigs_t; + namespace device { /** @@ -337,6 +346,27 @@ List FrontPanelConfig::getTextDisplays() return rTexts; } +void dumpconfig(fpdConfigs_t *configuration) +{ + // Dump the configuration details + printf("Dumping Front Panel Configuration Details:\n"); + printf("Indicator Colors:\n"); + for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { + printf(" Color ID: %d, Name: %s\n", + configuration->pKFPDIndicatorColors[i].id, + configuration->pKFPDIndicatorColors[i].name); + } + + printf("Indicators:\n"); + for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) { + printf(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", + configuration->pKIndicators[i].id, + configuration->pKIndicators[i].maxBrightness, + configuration->pKIndicators[i].maxCycleRate, + configuration->pKIndicators[i].levels, + configuration->pKIndicators[i].colorMode); + } +} /** * @fn FrontPanelConfig::load() @@ -352,18 +382,71 @@ void FrontPanelConfig::load() * 1. Create Supported Colors. * 2. Create Indicators. */ + int indicatorSize, indicatorColorSize, invalid_size = -1; + fpdConfigs_t configuration = {0}; + + const char* searchVaribles[] = { + "kFPDIndicatorColors", + "kFPDIndicatorColors_size", + "kIndicators", + "kIndicators_size" + }; + bool ret = false; + + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors, searchVaribles[0]); + if(ret == true) + { + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors_size, (char *)searchVaribles[1]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + configuration.pKFPDIndicatorColors_size = &invalid_size; + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs((void **)&configuration.pKIndicators, searchVaribles[2]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs((void **)&configuration.pKIndicators_size, (char *)searchVaribles[3]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKIndicators_size = &invalid_size; + } + } + else + { + INT_ERROR("Read Old Configs\n"); + configuration.pKFPDIndicatorColors = kIndicatorColors; + indicatorColorSize = dsUTL_DIM(kIndicatorColors); + configuration.pKFPDIndicatorColors_size = &indicatorColorSize; + configuration.pKIndicators = kIndicators; + indicatorSize = dsUTL_DIM(kIndicators); + configuration.pKIndicators_size = &indicatorSize; + + INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); + INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); + } + #if DEBUG + //dumpconfig(&configuration); + #endif + { - for (size_t i = 0; i < dsUTL_DIM(kIndicatorColors); i++) { - _colors.push_back(FrontPanelIndicator::Color(kIndicatorColors[i].id)); + for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { + _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); } - for (size_t i = 0; i < dsUTL_DIM(kIndicators); i++) { + for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { /* All indicators support a same set of colors */ - _indicators.push_back(FrontPanelIndicator(kIndicators[i].id, - kIndicators[i].maxBrightness, - kIndicators[i].maxCycleRate, - kIndicators[i].levels, - kIndicators[i].colorMode)); + _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, + configuration.pKIndicators[i].maxBrightness, + configuration.pKIndicators[i].maxCycleRate, + configuration.pKIndicators[i].levels, + configuration.pKIndicators[i].colorMode)); } } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 965aecf2..3c69e421 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -121,11 +121,18 @@ void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_si INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); } +typedef struct videoDeviceConfig +{ + dsVideoConfig_t *pKVideoDeviceConfigs; + int *pKVideoDeviceConfigs_size; +}videoDeviceConfig_t; + void VideoDeviceConfig::load() { - int configSize, portSize, invalid_size = -1; - dsVideoConfig_t *pKVideoDeviceConfigs = NULL; - int *pKVideoDeviceConfigs_size = NULL; + int configSize, invalid_size = -1; + //dsVideoConfig_t *pKVideoDeviceConfigs = NULL; + //int *pKVideoDeviceConfigs_size = NULL; + videoDeviceConfig_t videoDeviceConfig = {0}; const char* searchVaribles[] = { "kVideoDeviceConfigs", "kVideoDeviceConfigs_size", @@ -140,33 +147,39 @@ void VideoDeviceConfig::load() } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs((void **)&pKVideoDeviceConfigs, searchVaribles[0]); + //ret = searchConfigs((void **)&pKVideoDeviceConfigs, searchVaribles[0]); + ret = searchConfigs((void **)&(videoDeviceConfig.pKVideoDeviceConfigs), searchVaribles[0]); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&pKVideoDeviceConfigs_size, (char *)searchVaribles[1]); + ret = searchConfigs((void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size), (char *)searchVaribles[1]); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); + videoDeviceConfig.pKVideoDeviceConfigs_size = &invalid_size; } } else { - pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; - *pKVideoDeviceConfigs_size = dsUTL_DIM(kConfigs); + //pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; + //*pKVideoDeviceConfigs_size = dsUTL_DIM(kConfigs); + INT_INFO("Read Old Configs\n"); + videoDeviceConfig.pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; + configSize = dsUTL_DIM(kConfigs); + videoDeviceConfig.pKVideoDeviceConfigs_size = &configSize; } #if DEBUG - dumpconfig(pKVideoDeviceConfigs, *pKVideoDeviceConfigs_size); + dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); #endif /* * Initialize Video Devices (supported DFCs etc.) */ - for (size_t i = 0; i < *pKVideoDeviceConfigs_size; i++) { + for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { _vDevices.push_back(VideoDevice(i)); - for (size_t j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { - _vDevices.at(i).addDFC(VideoDFC::getInstance(pKVideoDeviceConfigs[i].supportedDFCs[j])); + for (size_t j = 0; j < videoDeviceConfig.pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { + _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceConfig.pKVideoDeviceConfigs[i].supportedDFCs[j])); } } From e6456851f5d162e01158f52d06ed7496e40d2e98 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 12 Nov 2025 12:23:41 +0000 Subject: [PATCH 18/66] fix build issue --- ds/frontPanelConfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 2a1a6ee0..6b439c42 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -352,9 +352,9 @@ void dumpconfig(fpdConfigs_t *configuration) printf("Dumping Front Panel Configuration Details:\n"); printf("Indicator Colors:\n"); for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { - printf(" Color ID: %d, Name: %s\n", + printf(" Color ID: %d, color: %d\n", configuration->pKFPDIndicatorColors[i].id, - configuration->pKFPDIndicatorColors[i].name); + configuration->pKFPDIndicatorColors[i].color); } printf("Indicators:\n"); From db4fa61d02adb64416f7109e823d3b9b5a4c295a Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 13 Nov 2025 06:40:11 +0000 Subject: [PATCH 19/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/frontPanelConfig.cpp | 75 ++++++++++++++++++++++++++++++++--------- 1 file changed, 59 insertions(+), 16 deletions(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 6b439c42..fc3be5b3 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -43,14 +43,18 @@ #include "dslogger.h" #include "manager.hpp" +#define DEBUG 1 // Using for dumpconfig + using namespace std; typedef struct fpdConfigs { const dsFPDColorConfig_t *pKFPDIndicatorColors; const dsFPDIndicatorConfig_t *pKIndicators; + const dsFPDTextDisplayConfig_t *pKTextDisplays; int *pKFPDIndicatorColors_size; int *pKIndicators_size; + int *pKTextDisplays_size; }fpdConfigs_t; namespace device { @@ -349,23 +353,43 @@ List FrontPanelConfig::getTextDisplays() void dumpconfig(fpdConfigs_t *configuration) { // Dump the configuration details - printf("Dumping Front Panel Configuration Details:\n"); - printf("Indicator Colors:\n"); + INT_INFO("\n\n===========================================================================\n\n"); + INT_INFO("Start of Front Panel Configuration Details:\n"); + INT_INFO("configuration->pKFPDIndicatorColors_size: %d\n", *(configuration->pKFPDIndicatorColors_size)); + INT_INFO("configuration->pKIndicators_size: %d\n", *(configuration->pKIndicators_size)); + INT_INFO("configuration->pKTextDisplays_size: %d\n", *(configuration->pKTextDisplays_size)); + INT_INFO("Dumping Front Panel Configuration Details:\n"); + INT_INFO("Indicator Colors:\n"); for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { - printf(" Color ID: %d, color: %d\n", + INT_INFO(" Color ID: %d, color: %d\n", configuration->pKFPDIndicatorColors[i].id, configuration->pKFPDIndicatorColors[i].color); } - printf("Indicators:\n"); + INT_INFO("Indicators:\n"); for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) { - printf(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", + INT_INFO(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", configuration->pKIndicators[i].id, configuration->pKIndicators[i].maxBrightness, configuration->pKIndicators[i].maxCycleRate, configuration->pKIndicators[i].levels, configuration->pKIndicators[i].colorMode); } + INT_INFO("Text Displays:\n"); + + for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { + INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %d, Color Mode: %d\n", + configuration->pKTextDisplays[i].id, + configuration->pKTextDisplays[i].maxBrightness, + configuration->pKTextDisplays[i].maxCycleRate, + configuration->pKTextDisplays[i].levels, + configuration->pKTextDisplays[i].maxHorizontalIterations, + configuration->pKTextDisplays[i].maxVerticalIterations, + configuration->pKTextDisplays[i].supportedCharacters, + configuration->pKTextDisplays[i].colorMode); + } + INT_INFO("End of Front Panel Configuration Details.\n"); + INT_INFO("\n\n===========================================================================\n\n"); } /** @@ -389,7 +413,9 @@ void FrontPanelConfig::load() "kFPDIndicatorColors", "kFPDIndicatorColors_size", "kIndicators", - "kIndicators_size" + "kIndicators_size", + "kTextDisplays", + "kTextDisplays_size" }; bool ret = false; @@ -417,6 +443,19 @@ void FrontPanelConfig::load() INT_ERROR("%s is not defined\n", searchVaribles[3]); configuration.pKIndicators_size = &invalid_size; } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[4]); + ret = searchConfigs((void **)&configuration.pKTextDisplays, searchVaribles[4]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[4]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); + ret = searchConfigs((void **)&configuration.pKTextDisplays_size, (char *)searchVaribles[5]); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[5]); + configuration.pKTextDisplays_size = &invalid_size; + } } else { @@ -427,12 +466,16 @@ void FrontPanelConfig::load() configuration.pKIndicators = kIndicators; indicatorSize = dsUTL_DIM(kIndicators); configuration.pKIndicators_size = &indicatorSize; + configuration.pKTextDisplays = kTextDisplays; + indicatorSize = dsUTL_DIM(kTextDisplays); + configuration.pKTextDisplays_size = &indicatorSize; INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); + INT_INFO("configuration.pKTextDisplays =%p, *(configuration.pKTextDisplays_size) = %d\n", configuration.pKTextDisplays, *(configuration.pKTextDisplays_size)); } #if DEBUG - //dumpconfig(&configuration); + dumpconfig(&configuration); #endif { @@ -457,16 +500,16 @@ void FrontPanelConfig::load() * 1. Use Supported Colors created for indicators. * 2. Create Text Displays. */ - for (size_t i = 0; i < dsUTL_DIM(kTextDisplays); i++) { + for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { _textDisplays.push_back( - FrontPanelTextDisplay(kTextDisplays[i].id, - kTextDisplays[i].maxBrightness, - kTextDisplays[i].maxCycleRate, - kTextDisplays[i].levels, - kTextDisplays[i].maxHorizontalIterations, - kTextDisplays[i].maxVerticalIterations, - kTextDisplays[i].supportedCharacters, - kTextDisplays[i].colorMode)); + FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, + configuration.pKTextDisplays[i].maxBrightness, + configuration.pKTextDisplays[i].maxCycleRate, + configuration.pKTextDisplays[i].levels, + configuration.pKTextDisplays[i].maxHorizontalIterations, + configuration.pKTextDisplays[i].maxVerticalIterations, + configuration.pKTextDisplays[i].supportedCharacters, + configuration.pKTextDisplays[i].colorMode)); } } } From f5838f430ad3f659a2c1f29e5f9c58cf16247689 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Fri, 14 Nov 2025 11:29:45 +0000 Subject: [PATCH 20/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 104 ++++++++++++++--------------------- ds/frontPanelConfig.cpp | 2 +- ds/videoDeviceConfig.cpp | 18 +----- ds/videoOutputPortConfig.cpp | 42 ++------------ 4 files changed, 49 insertions(+), 117 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index d01e78b6..38fd672e 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -121,44 +121,14 @@ List AudioOutputPortConfig::getSupportedTypes() return supportedTypes; } -#if 0 -bool searchConfigs(void **pConfigVar, const char *searchConfigStr) -{ - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); - - static int invalidsize = -1; - - pthread_mutex_lock(&dsLock); - - void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - if (dllib) { - *pConfigVar = (void *) dlsym(dllib, searchConfigStr); - if (*pConfigVar != NULL) { - INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); - } - else { - INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); - } - - dlclose(dllib); - } - else { - INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME); - } - pthread_mutex_unlock(&dsLock); - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); - return (*pConfigVar != NULL); -} -#endif void dumpconfig(audioConfigs_t *config) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - INT_INFO("%d:%s: pKConfigSize = %p\n", __LINE__, __func__, config->pKConfigSize); - INT_INFO("%d:%s: pKPortSize = %p\n", __LINE__, __func__, config->pKPortSize); - + INT_INFO("%d:%s: pKConfigSize %p = %d \n", __LINE__, __func__, config->pKConfigSize, *(config->pKConfigSize)); + INT_INFO("%d:%s: pKPortSize %p = %d \n", __LINE__, __func__, config->pKPortSize, *(config->pKPortSize)); + INT_INFO("\n\n=========================================================================================================================\n\n"); if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) { @@ -261,41 +231,49 @@ void AudioOutputPortConfig::load() configuration.pKPortSize = &portSize; INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); } - #if DEBUG - dumpconfig(&configuration); - #endif - /* - * Initialize Audio portTypes (encodings, compressions etc.) - * and its port instances (db, level etc) - */ - for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); - AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - aPortType.enable(); - for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { - aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); - _aEncodings.at(typeCfg->encodings[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { - aPortType.addCompression(typeCfg->compressions[j]); - _aCompressions.at(typeCfg->compressions[j]).enable(); + * Check if configs are loaded properly + */ + if ( configuration.pKConfigs != NULL || configuration.pKPorts != NULL || + configuration.pKConfigSize != NULL || configuration.pKPortSize != NULL) { + #if DEBUG + dumpconfig(&configuration); + #endif + INT_INFO("%d:%s: Audio Configs loaded successfully\n", __LINE__, __func__); + /* + * Initialize Audio portTypes (encodings, compressions etc.) + * and its port instances (db, level etc) + */ + for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { + const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); + AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + aPortType.enable(); + for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { + aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); + _aEncodings.at(typeCfg->encodings[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { + aPortType.addCompression(typeCfg->compressions[j]); + _aCompressions.at(typeCfg->compressions[j]).enable(); + } + for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { + aPortType.addStereoMode(typeCfg->stereoModes[j]); + _aStereoModes.at(typeCfg->stereoModes[j]).enable(); + } } - for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { - aPortType.addStereoMode(typeCfg->stereoModes[j]); - _aStereoModes.at(typeCfg->stereoModes[j]).enable(); + + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < *(configuration.pKPortSize); i++) { + const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; + _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); + _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } } - - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(configuration.pKPortSize); i++) { - const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; - _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); - _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); + else { + INT_ERROR("%d:%s: Audio Configs loading failed\n", __LINE__, __func__); } - } catch(const Exception &e) { throw e; diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index fc3be5b3..186949ac 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -378,7 +378,7 @@ void dumpconfig(fpdConfigs_t *configuration) INT_INFO("Text Displays:\n"); for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { - INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %d, Color Mode: %d\n", + INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", configuration->pKTextDisplays[i].id, configuration->pKTextDisplays[i].maxBrightness, configuration->pKTextDisplays[i].maxCycleRate, diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 3c69e421..ca154b6e 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -95,19 +95,12 @@ void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_si INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); - #if 0 - typedef struct _dsVideoConfig_t { - size_t numSupportedDFCs; /*!< Number of zoom modes supported */ - const dsVideoZoom_t *supportedDFCs; /*!< List of zoom modes supported */ - dsVideoZoom_t defaultDFC; /*!< The default zoom mode */ - } dsVideoConfig_t; - #endif INT_INFO("\n\n=========================================================================================================================\n\n"); if(pKVideoDeviceConfigs != NULL && videoDeviceConfigs_size != -1) { - for (size_t i = 0; i < videoDeviceConfigs_size; i++) { - INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %d\n ", i, pKVideoDeviceConfigs[i].numSupportedDFCs); - for (size_t j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { + for (int i = 0; i < videoDeviceConfigs_size; i++) { + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu\n ", i, pKVideoDeviceConfigs[i].numSupportedDFCs); + for (int j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, pKVideoDeviceConfigs[i].supportedDFCs[j]); } } @@ -130,8 +123,6 @@ typedef struct videoDeviceConfig void VideoDeviceConfig::load() { int configSize, invalid_size = -1; - //dsVideoConfig_t *pKVideoDeviceConfigs = NULL; - //int *pKVideoDeviceConfigs_size = NULL; videoDeviceConfig_t videoDeviceConfig = {0}; const char* searchVaribles[] = { "kVideoDeviceConfigs", @@ -147,7 +138,6 @@ void VideoDeviceConfig::load() } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - //ret = searchConfigs((void **)&pKVideoDeviceConfigs, searchVaribles[0]); ret = searchConfigs((void **)&(videoDeviceConfig.pKVideoDeviceConfigs), searchVaribles[0]); if(ret == true) { @@ -161,8 +151,6 @@ void VideoDeviceConfig::load() } else { - //pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; - //*pKVideoDeviceConfigs_size = dsUTL_DIM(kConfigs); INT_INFO("Read Old Configs\n"); videoDeviceConfig.pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; configSize = dsUTL_DIM(kConfigs); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 9fbe7637..8e43e593 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -305,47 +305,19 @@ void dumpconfig(videoPortConfigs_t *config) } INT_INFO("\n\n####################################################################### \n\n"); - #if 0 - /*.typeId = */ dsVIDEOPORT_TYPE_INTERNAL, - /*.name = */ "INTERNAL", - /*.dtcpSupported = */ false, - /*.hdcpSupported = */ true, - /*.restrictedResollution = */ -1, - /*.numSupportedResolutions = */ dsUTL_DIM(kResolutions), // 0 means "Info available at runtime" - /*.supportedResolutons = */ kResolutions, - #endif INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("%d:%s: Dumping Video Port Configurations\n", __LINE__, __func__); for (size_t i = 0; i < *(config->pKVideoPortConfigs_size); i++) { const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); - #if 0 - typedef struct _dsVideoPortTypeConfig_t { - dsVideoPortType_t typeId; ///< The video output type - const char *name; ///< Name of the video output port - bool dtcpSupported; ///< Is DTCP supported? - bool hdcpSupported; ///< Is HDCP supported? - int32_t restrictedResollution; ///< Any restricted resolution; -1 if no. - size_t numSupportedResolutions; ///< Number of supported resolutions - dsVideoPortResolution_t *supportedResolutions; ///< List of supported resolutions - } dsVideoPortTypeConfig_t; - #endif + INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); INT_INFO("%d:%s: typeCfg->dtcpSupported= %d\n", __LINE__, __func__, typeCfg->dtcpSupported); INT_INFO("%d:%s: typeCfg->hdcpSupported = %d\n", __LINE__, __func__, typeCfg->hdcpSupported); INT_INFO("%d:%s: typeCfg->restrictedResollution = %d\n", __LINE__, __func__, typeCfg->restrictedResollution); - INT_INFO("%d:%s: typeCfg->numSupportedResolutions= %d\n", __LINE__, __func__, typeCfg->numSupportedResolutions); - #if 0 - typedef struct _dsVideoPortResolution_t { - char name[32]; ///< Name the resolution - dsVideoResolution_t pixelResolution; ///< The resolution associated with the name - dsVideoAspectRatio_t aspectRatio; ///< The associated aspect ratio - dsVideoStereoScopicMode_t stereoScopicMode; ///< The associated stereoscopic mode - dsVideoFrameRate_t frameRate; ///< The associated frame rate - bool interlaced; ///< The associated scan mode( @a true if interlaced, @a false if progressive ) - }dsVideoPortResolution_t; - #endif + INT_INFO("%d:%s: typeCfg->numSupportedResolutions= %lu\n", __LINE__, __func__, typeCfg->numSupportedResolutions); + INT_INFO("%d:%s: typeCfg->supportedResolutions = %p\n", __LINE__, __func__, typeCfg->supportedResolutions); INT_INFO("%d:%s: typeCfg->supportedResolutions->name = %s\n", __LINE__, __func__, typeCfg->supportedResolutions->name); INT_INFO("%d:%s: typeCfg->supportedResolutions->pixelResolution= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->pixelResolution); @@ -355,13 +327,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("%d:%s: typeCfg->supportedResolutions->interlaced= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->interlaced); } INT_INFO("\n\n####################################################################### \n\n"); - #if 0 - { - /*.typeId = */ {dsVIDEOPORT_TYPE_INTERNAL, 0}, - /* connectedAOP */ {dsAUDIOPORT_TYPE_SPEAKER, 0}, - /*.defaultResolution = */ "1080i50" - } - #endif + INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("%d:%s: Dumping Video Port Connections\n", __LINE__, __func__); for (size_t i = 0; i < *(config->pKVideoPortPorts_size); i++) { From 82e1bf40d22b34777e916297762a0a6028e02902 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 17 Nov 2025 07:25:05 +0000 Subject: [PATCH 21/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by: grandhi_santoshkumar --- ds/audioOutputPortConfig.cpp | 24 ++++++++++++------------ ds/frontPanelConfig.cpp | 25 +++++++++++++++++-------- ds/include/manager.hpp | 2 +- ds/manager.cpp | 2 +- ds/videoDeviceConfig.cpp | 30 ++++++++++++++++++------------ ds/videoOutputPortConfig.cpp | 24 ++++++++++++++++++------ 6 files changed, 67 insertions(+), 40 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 38fd672e..7baecbda 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -38,8 +38,6 @@ #include "manager.hpp" -#define DEBUG 1 // Using for dumpconfig - typedef struct audioConfigs { const dsAudioTypeConfig_t *pKConfigs; @@ -164,7 +162,7 @@ void dumpconfig(audioConfigs_t *config) void AudioOutputPortConfig::load() { - int configSize, portSize; + static int configSize, portSize, invalidSize = -1; audioConfigs_t configuration = {0}; const char* searchVaribles[] = { "kAudioConfigs", @@ -198,26 +196,28 @@ void AudioOutputPortConfig::load() } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]); + ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKConfigs); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs((void **)&configuration.pKConfigSize, (char *)searchVaribles[2]); + ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKConfigSize); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[2]); + configuration.pKConfigSize = &invalidSize; } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&configuration.pKPorts, searchVaribles[1]); + ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKPorts); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]); + ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKPortSize); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKPortSize = &invalidSize; } } else @@ -234,12 +234,11 @@ void AudioOutputPortConfig::load() /* * Check if configs are loaded properly */ - if ( configuration.pKConfigs != NULL || configuration.pKPorts != NULL || - configuration.pKConfigSize != NULL || configuration.pKPortSize != NULL) { - #if DEBUG + if ( configuration.pKConfigs != NULL && configuration.pKPorts != NULL && + configuration.pKConfigSize != NULL && (*(configuration.pKConfigSize) > 0 ) && + configuration.pKPortSize != NULL && (*(configuration.pKPortSize) > 0 )) + { dumpconfig(&configuration); - #endif - INT_INFO("%d:%s: Audio Configs loaded successfully\n", __LINE__, __func__); /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) @@ -270,6 +269,7 @@ void AudioOutputPortConfig::load() _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); } + INT_INFO("%d:%s: Audio Configs loaded successfully\n", __LINE__, __func__); } else { INT_ERROR("%d:%s: Audio Configs loading failed\n", __LINE__, __func__); diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 186949ac..d56f25f9 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -406,7 +406,7 @@ void FrontPanelConfig::load() * 1. Create Supported Colors. * 2. Create Indicators. */ - int indicatorSize, indicatorColorSize, invalid_size = -1; + static int indicatorSize, indicatorColorSize, invalid_size = -1; fpdConfigs_t configuration = {0}; const char* searchVaribles[] = { @@ -420,37 +420,37 @@ void FrontPanelConfig::load() bool ret = false; INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors, searchVaribles[0]); + ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKFPDIndicatorColors ); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors_size, (char *)searchVaribles[1]); + ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKFPDIndicatorColors_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); configuration.pKFPDIndicatorColors_size = &invalid_size; } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs((void **)&configuration.pKIndicators, searchVaribles[2]); + ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKIndicators); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[2]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs((void **)&configuration.pKIndicators_size, (char *)searchVaribles[3]); + ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKIndicators_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); configuration.pKIndicators_size = &invalid_size; } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[4]); - ret = searchConfigs((void **)&configuration.pKTextDisplays, searchVaribles[4]); + ret = searchConfigs(searchVaribles[4], (void **)&configuration.pKTextDisplays); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[4]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs((void **)&configuration.pKTextDisplays_size, (char *)searchVaribles[5]); + ret = searchConfigs(searchVaribles[5], (void **)&configuration.pKTextDisplays_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[5]); @@ -474,6 +474,11 @@ void FrontPanelConfig::load() INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); INT_INFO("configuration.pKTextDisplays =%p, *(configuration.pKTextDisplays_size) = %d\n", configuration.pKTextDisplays, *(configuration.pKTextDisplays_size)); } + if (configuration.pKFPDIndicatorColors != NULL && configuration.pKFPDIndicatorColors_size != NULL && + *(configuration.pKFPDIndicatorColors_size) > 0 && + configuration.pKIndicators != NULL && configuration.pKIndicators_size != NULL && + *(configuration.pKIndicators_size) > 0) + { #if DEBUG dumpconfig(&configuration); #endif @@ -494,6 +499,8 @@ void FrontPanelConfig::load() } + if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL && + *(configuration.pKTextDisplays_size) > 0) { /* * Create TextDisplays @@ -512,10 +519,12 @@ void FrontPanelConfig::load() configuration.pKTextDisplays[i].colorMode)); } } + } else { + INT_ERROR("No valid front panel configuration found\n"); + } } } - /** @} */ /** @} */ diff --git a/ds/include/manager.hpp b/ds/include/manager.hpp index 089e0e49..0b9408d7 100644 --- a/ds/include/manager.hpp +++ b/ds/include/manager.hpp @@ -157,7 +157,7 @@ namespace device { // Forward declaration for searchConfigs function -bool searchConfigs(void **pConfigVar, const char *searchConfigStr); +bool searchConfigs(const char *searchConfigStr, void **pConfigVar); /** * @class Manager diff --git a/ds/manager.cpp b/ds/manager.cpp index 2fc92ad2..e6b4dcc8 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -160,7 +160,7 @@ void Manager::load() printf("%d:%s load completed\n", __LINE__, __FUNCTION__); } -bool searchConfigs(void **pConfigVar, const char *searchConfigStr) +bool searchConfigs(const char *searchConfigStr, void **pConfigVar) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index ca154b6e..aa931224 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -138,11 +138,11 @@ void VideoDeviceConfig::load() } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs((void **)&(videoDeviceConfig.pKVideoDeviceConfigs), searchVaribles[0]); + ret = searchConfigs(searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size), (char *)searchVaribles[1]); + ret = searchConfigs(searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); @@ -156,22 +156,28 @@ void VideoDeviceConfig::load() configSize = dsUTL_DIM(kConfigs); videoDeviceConfig.pKVideoDeviceConfigs_size = &configSize; } - #if DEBUG - dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); - #endif /* * Initialize Video Devices (supported DFCs etc.) */ - for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { - _vDevices.push_back(VideoDevice(i)); - - for (size_t j = 0; j < videoDeviceConfig.pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { - _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceConfig.pKVideoDeviceConfigs[i].supportedDFCs[j])); + if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL && + *(videoDeviceConfig.pKVideoDeviceConfigs_size) > 0) + { + #if DEBUG + dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); + #endif + for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { + _vDevices.push_back(VideoDevice(i)); + + for (size_t j = 0; j < videoDeviceConfig.pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { + _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceConfig.pKVideoDeviceConfigs[i].supportedDFCs[j])); + } } } - - + else + { + INT_ERROR("%d:%s: Congigs are NULL and config size are -1\n", __LINE__, __func__); + } } void VideoDeviceConfig::release() diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 8e43e593..97cf9f91 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -384,35 +384,35 @@ void VideoOutputPortConfig::load() } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]); + ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKConfigs); if(ret == true) { INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs((void **)&configuration.pKVideoPortConfigs_size, (char *)searchVaribles[1]); + ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKVideoPortConfigs_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs((void **)&configuration.pKPorts, searchVaribles[2]); + ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKPorts); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[2]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs((void **)&configuration.pKVideoPortPorts_size, (char *)searchVaribles[3]); + ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKVideoPortPorts_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); } // Resolutions - ret = searchConfigs((void **)&configuration.pKResolutionsSettings, searchVaribles[4]); + ret = searchConfigs(searchVaribles[4], (void **)&configuration.pKResolutionsSettings); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[4]); } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs((void **)&configuration.pKResolutionsSettings_size, (char *)searchVaribles[5]); + ret = searchConfigs(searchVaribles[5], (void **)&configuration.pKResolutionsSettings_size); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[5]); @@ -434,6 +434,12 @@ void VideoOutputPortConfig::load() INT_INFO("configuration.pKPorts =%p, *(configuration.pKPortSize) = %d\n", configuration.pKPorts, *(configuration.pKVideoPortPorts_size)); INT_INFO("configuration.pKResolutionsSettings =%p, *(configuration.pKResolutionsSettings_size) = %d\n", configuration.pKResolutionsSettings, *(configuration.pKResolutionsSettings_size)); } + + if(configuration.pKConfigs == NULL && configuration.pKVideoPortConfigs_size == NULL && + configuration.pKPorts == NULL && configuration.pKVideoPortPorts_size == NULL && + configuration.pKResolutionsSettings == NULL && configuration.pKResolutionsSettings_size == NULL) + { + #if DEBUG dumpconfig(&configuration); #endif @@ -485,7 +491,13 @@ void VideoOutputPortConfig::load() _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); } + } + else + { + cout << "Video Outport Configs or Ports or Resolutions is NULL. ..."< Date: Mon, 17 Nov 2025 10:14:29 +0000 Subject: [PATCH 22/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/frontPanelConfig.cpp | 6 +-- ds/manager.cpp | 2 - ds/videoOutputPortConfig.cpp | 90 ++++++++++++++++++------------------ 3 files changed, 48 insertions(+), 50 deletions(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index d56f25f9..bf83d49a 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -406,7 +406,7 @@ void FrontPanelConfig::load() * 1. Create Supported Colors. * 2. Create Indicators. */ - static int indicatorSize, indicatorColorSize, invalid_size = -1; + static int indicatorSize, indicatorColorSize, textDisplaySize, invalid_size = -1; fpdConfigs_t configuration = {0}; const char* searchVaribles[] = { @@ -467,8 +467,8 @@ void FrontPanelConfig::load() indicatorSize = dsUTL_DIM(kIndicators); configuration.pKIndicators_size = &indicatorSize; configuration.pKTextDisplays = kTextDisplays; - indicatorSize = dsUTL_DIM(kTextDisplays); - configuration.pKTextDisplays_size = &indicatorSize; + textDisplaySize = dsUTL_DIM(kTextDisplays); + configuration.pKTextDisplays_size = &textDisplaySize; INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); diff --git a/ds/manager.cpp b/ds/manager.cpp index e6b4dcc8..dd9aaa58 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -165,8 +165,6 @@ bool searchConfigs(const char *searchConfigStr, void **pConfigVar) INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); - static int invalidsize = -1; - pthread_mutex_lock(&dsLock); void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 97cf9f91..4e37c5ea 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -350,7 +350,7 @@ void dumpconfig(videoPortConfigs_t *config) void VideoOutputPortConfig::load() { - int configSize, portSize, resolutionSize; + static int configSize, portSize, resolutionSize, invalid_size = -1; videoPortConfigs_t configuration = {0}; const char* searchVaribles[] = { "kVideoPortConfigs", @@ -392,6 +392,7 @@ void VideoOutputPortConfig::load() if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); + configuration.pKVideoPortConfigs_size = &invalid_size; } INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKPorts); @@ -404,6 +405,7 @@ void VideoOutputPortConfig::load() if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKVideoPortPorts_size = &invalid_size; } // Resolutions ret = searchConfigs(searchVaribles[4], (void **)&configuration.pKResolutionsSettings); @@ -416,6 +418,7 @@ void VideoOutputPortConfig::load() if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[5]); + configuration.pKResolutionsSettings_size = &invalid_size; } } else @@ -440,57 +443,54 @@ void VideoOutputPortConfig::load() configuration.pKResolutionsSettings == NULL && configuration.pKResolutionsSettings_size == NULL) { - #if DEBUG - dumpconfig(&configuration); - #endif - - - /* Initialize a set of supported resolutions - * - */ - //size_t numResolutions = dsUTL_DIM(kResolutions); - for (size_t i = 0; i < *(configuration.pKResolutionsSettings_size); i++) { - dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); - {std::lock_guard lock(gSupportedResolutionsMutex); - _supportedResolutions.push_back( - VideoResolution( - i, /* id */ - std::string(resolution->name), - resolution->pixelResolution, - resolution->aspectRatio, - resolution->stereoScopicMode, - resolution->frameRate, - resolution->interlaced)); + #if DEBUG + dumpconfig(&configuration); + #endif + /* Initialize a set of supported resolutions + * + */ + for (size_t i = 0; i < *(configuration.pKResolutionsSettings_size); i++) { + dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); + {std::lock_guard lock(gSupportedResolutionsMutex); + _supportedResolutions.push_back( + VideoResolution( + i, /* id */ + std::string(resolution->name), + resolution->pixelResolution, + resolution->aspectRatio, + resolution->stereoScopicMode, + resolution->frameRate, + resolution->interlaced)); + } } - } - /* - * Initialize Video portTypes (Only Enable POrts) - * and its port instances (curr resolution) - */ - for (size_t i = 0; i < *(configuration.pKVideoPortConfigs_size); i++) - { - const dsVideoPortTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); - VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); - vPortType.enable(); - vPortType.setRestrictedResolution(typeCfg->restrictedResollution); - } + /* + * Initialize Video portTypes (Only Enable POrts) + * and its port instances (curr resolution) + */ + for (size_t i = 0; i < *(configuration.pKVideoPortConfigs_size); i++) + { + const dsVideoPortTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); + VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); + vPortType.enable(); + vPortType.setRestrictedResolution(typeCfg->restrictedResollution); + } - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { - const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { + const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); - _vPorts.push_back( - VideoOutputPort((port->id.type), port->id.index, i, - AudioOutputPortType::getInstance(configuration.pKPorts[i].connectedAOP.type).getPort(configuration.pKPorts[i].connectedAOP.index).getId(), - std::string(port->defaultResolution))); + _vPorts.push_back( + VideoOutputPort((port->id.type), port->id.index, i, + AudioOutputPortType::getInstance(configuration.pKPorts[i].connectedAOP.type).getPort(configuration.pKPorts[i].connectedAOP.index).getId(), + std::string(port->defaultResolution))); - _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); + _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); - } + } } else { From f68259bdd4306553fa77b1411f8e884de914ca64 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 17 Nov 2025 12:52:23 +0000 Subject: [PATCH 23/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/videoOutputPortConfig.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 4e37c5ea..8496b3a5 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -433,14 +433,14 @@ void VideoOutputPortConfig::load() configuration.pKResolutionsSettings = kResolutions; resolutionSize = dsUTL_DIM(kResolutions); configuration.pKResolutionsSettings_size = &resolutionSize; - INT_INFO("configuration.pKConfigs =%p, *(configuration.pKConfigSize) = %d\n", configuration.pKConfigs, *(configuration.pKVideoPortConfigs_size)); - INT_INFO("configuration.pKPorts =%p, *(configuration.pKPortSize) = %d\n", configuration.pKPorts, *(configuration.pKVideoPortPorts_size)); + INT_INFO("configuration.pKConfigs =%p, *(configuration.pKVideoPortConfigs_size) = %d\n", configuration.pKConfigs, *(configuration.pKVideoPortConfigs_size)); + INT_INFO("configuration.pKPorts =%p, *(configuration.pKVideoPortPorts_size) = %d\n", configuration.pKPorts, *(configuration.pKVideoPortPorts_size)); INT_INFO("configuration.pKResolutionsSettings =%p, *(configuration.pKResolutionsSettings_size) = %d\n", configuration.pKResolutionsSettings, *(configuration.pKResolutionsSettings_size)); } - if(configuration.pKConfigs == NULL && configuration.pKVideoPortConfigs_size == NULL && - configuration.pKPorts == NULL && configuration.pKVideoPortPorts_size == NULL && - configuration.pKResolutionsSettings == NULL && configuration.pKResolutionsSettings_size == NULL) + if((configuration.pKConfigs != NULL) && (configuration.pKVideoPortConfigs_size != NULL) && + (configuration.pKPorts != NULL) && (configuration.pKVideoPortPorts_size != NULL) && + (configuration.pKResolutionsSettings != NULL) && (configuration.pKResolutionsSettings_size != NULL)) { #if DEBUG @@ -491,13 +491,12 @@ void VideoOutputPortConfig::load() _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); } - } - else - { - cout << "Video Outport Configs or Ports or Resolutions is NULL. ..."< Date: Thu, 20 Nov 2025 06:39:16 +0000 Subject: [PATCH 24/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/frontPanelConfig.cpp | 104 ++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index bf83d49a..c898c401 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -375,18 +375,24 @@ void dumpconfig(fpdConfigs_t *configuration) configuration->pKIndicators[i].levels, configuration->pKIndicators[i].colorMode); } - INT_INFO("Text Displays:\n"); - - for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { - INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", - configuration->pKTextDisplays[i].id, - configuration->pKTextDisplays[i].maxBrightness, - configuration->pKTextDisplays[i].maxCycleRate, - configuration->pKTextDisplays[i].levels, - configuration->pKTextDisplays[i].maxHorizontalIterations, - configuration->pKTextDisplays[i].maxVerticalIterations, - configuration->pKTextDisplays[i].supportedCharacters, - configuration->pKTextDisplays[i].colorMode); + + if(configuration->pKTextDisplays == NULL && configuration->pKTextDisplays_size == NULL && *(configuration->pKTextDisplays_size) > 0){ + INT_INFO("Text Displays:\n"); + + for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { + INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", + configuration->pKTextDisplays[i].id, + configuration->pKTextDisplays[i].maxBrightness, + configuration->pKTextDisplays[i].maxCycleRate, + configuration->pKTextDisplays[i].levels, + configuration->pKTextDisplays[i].maxHorizontalIterations, + configuration->pKTextDisplays[i].maxVerticalIterations, + configuration->pKTextDisplays[i].supportedCharacters, + configuration->pKTextDisplays[i].colorMode); + } + } + else { + INT_INFO(" No Text Displays configured.\n"); } INT_INFO("End of Front Panel Configuration Details.\n"); INT_INFO("\n\n===========================================================================\n\n"); @@ -414,8 +420,8 @@ void FrontPanelConfig::load() "kFPDIndicatorColors_size", "kIndicators", "kIndicators_size", - "kTextDisplays", - "kTextDisplays_size" + "kFPDTextDisplays", + "kFPDTextDisplays_size" }; bool ret = false; @@ -483,43 +489,49 @@ void FrontPanelConfig::load() dumpconfig(&configuration); #endif - { - for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { - _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); - } + { + for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { + _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); + } - for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { - /* All indicators support a same set of colors */ - _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, - configuration.pKIndicators[i].maxBrightness, - configuration.pKIndicators[i].maxCycleRate, - configuration.pKIndicators[i].levels, - configuration.pKIndicators[i].colorMode)); + for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { + /* All indicators support a same set of colors */ + _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, + configuration.pKIndicators[i].maxBrightness, + configuration.pKIndicators[i].maxCycleRate, + configuration.pKIndicators[i].levels, + configuration.pKIndicators[i].colorMode)); + } } - } - - if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL && - *(configuration.pKTextDisplays_size) > 0) - { - /* - * Create TextDisplays - * 1. Use Supported Colors created for indicators. - * 2. Create Text Displays. - */ - for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { - _textDisplays.push_back( - FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, - configuration.pKTextDisplays[i].maxBrightness, - configuration.pKTextDisplays[i].maxCycleRate, - configuration.pKTextDisplays[i].levels, - configuration.pKTextDisplays[i].maxHorizontalIterations, - configuration.pKTextDisplays[i].maxVerticalIterations, - configuration.pKTextDisplays[i].supportedCharacters, - configuration.pKTextDisplays[i].colorMode)); + if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL && + *(configuration.pKTextDisplays_size) > 0) + { + /* + * Create TextDisplays + * 1. Use Supported Colors created for indicators. + * 2. Create Text Displays. + */ + INT_DEBUG("Text Displays \n"); + for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { + _textDisplays.push_back( + FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, + configuration.pKTextDisplays[i].maxBrightness, + configuration.pKTextDisplays[i].maxCycleRate, + configuration.pKTextDisplays[i].levels, + configuration.pKTextDisplays[i].maxHorizontalIterations, + configuration.pKTextDisplays[i].maxVerticalIterations, + configuration.pKTextDisplays[i].supportedCharacters, + configuration.pKTextDisplays[i].colorMode)); + } } + else + { + INT_ERROR("No valid text display configuration found\n"); + } } - } else { + else + { INT_ERROR("No valid front panel configuration found\n"); } } From 43ad5adc9d71e429cc863b49d88e0cd5c900d34e Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 20 Nov 2025 07:10:44 +0000 Subject: [PATCH 25/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 3 +-- ds/frontPanelConfig.cpp | 9 ++++----- ds/videoDeviceConfig.cpp | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 7baecbda..113e4f41 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -235,8 +235,7 @@ void AudioOutputPortConfig::load() * Check if configs are loaded properly */ if ( configuration.pKConfigs != NULL && configuration.pKPorts != NULL && - configuration.pKConfigSize != NULL && (*(configuration.pKConfigSize) > 0 ) && - configuration.pKPortSize != NULL && (*(configuration.pKPortSize) > 0 )) + configuration.pKConfigSize != NULL && configuration.pKPortSize != NULL) { dumpconfig(&configuration); /* diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index c898c401..6637b685 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -357,7 +357,7 @@ void dumpconfig(fpdConfigs_t *configuration) INT_INFO("Start of Front Panel Configuration Details:\n"); INT_INFO("configuration->pKFPDIndicatorColors_size: %d\n", *(configuration->pKFPDIndicatorColors_size)); INT_INFO("configuration->pKIndicators_size: %d\n", *(configuration->pKIndicators_size)); - INT_INFO("configuration->pKTextDisplays_size: %d\n", *(configuration->pKTextDisplays_size)); + INT_INFO("configuration->pKTextDisplays_size: %p\n", configuration->pKTextDisplays_size); INT_INFO("Dumping Front Panel Configuration Details:\n"); INT_INFO("Indicator Colors:\n"); for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { @@ -376,8 +376,8 @@ void dumpconfig(fpdConfigs_t *configuration) configuration->pKIndicators[i].colorMode); } - if(configuration->pKTextDisplays == NULL && configuration->pKTextDisplays_size == NULL && *(configuration->pKTextDisplays_size) > 0){ - INT_INFO("Text Displays:\n"); + if(configuration->pKTextDisplays == NULL && configuration->pKTextDisplays_size == NULL){ + INT_INFO("Text Displays:*(configuration->pKTextDisplays_size) =%d\n", *(configuration->pKTextDisplays_size)); for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", @@ -504,8 +504,7 @@ void FrontPanelConfig::load() } } - if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL && - *(configuration.pKTextDisplays_size) > 0) + if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL) { /* * Create TextDisplays diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index aa931224..5f514c52 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -160,8 +160,7 @@ void VideoDeviceConfig::load() /* * Initialize Video Devices (supported DFCs etc.) */ - if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL && - *(videoDeviceConfig.pKVideoDeviceConfigs_size) > 0) + if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL) { #if DEBUG dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); From de32c1b68655deb323f0c4e2c135b1d1d37e6aad Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 20 Nov 2025 07:32:50 +0000 Subject: [PATCH 26/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: consume the config variables using dlsym() in MW. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/frontPanelConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 6637b685..54b60f2b 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -376,7 +376,7 @@ void dumpconfig(fpdConfigs_t *configuration) configuration->pKIndicators[i].colorMode); } - if(configuration->pKTextDisplays == NULL && configuration->pKTextDisplays_size == NULL){ + if(configuration->pKTextDisplays != NULL && configuration->pKTextDisplays_size != NULL){ INT_INFO("Text Displays:*(configuration->pKTextDisplays_size) =%d\n", *(configuration->pKTextDisplays_size)); for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { From efe2f4347b542fbcf02d764304fd198812db9d42 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 9 Dec 2025 17:57:17 +0000 Subject: [PATCH 27/66] debug. disable dumpconfig and add logs --- ds/audioOutputPortConfig.cpp | 7 +++++-- ds/frontPanelConfig.cpp | 9 ++++++--- ds/videoDeviceConfig.cpp | 7 +++++-- ds/videoOutputPortConfig.cpp | 7 +++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 113e4f41..b2071401 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -163,7 +163,7 @@ void dumpconfig(audioConfigs_t *config) void AudioOutputPortConfig::load() { static int configSize, portSize, invalidSize = -1; - audioConfigs_t configuration = {0}; + static audioConfigs_t configuration = {0}; const char* searchVaribles[] = { "kAudioConfigs", "kAudioPorts", @@ -172,6 +172,7 @@ void AudioOutputPortConfig::load() }; bool ret = false; + INT_INFO("Enter function\n"); try { /* * Load Constants First. @@ -237,7 +238,8 @@ void AudioOutputPortConfig::load() if ( configuration.pKConfigs != NULL && configuration.pKPorts != NULL && configuration.pKConfigSize != NULL && configuration.pKPortSize != NULL) { - dumpconfig(&configuration); + //dumpconfig(&configuration); + INT_INFO("disable the dumpconfig()\n"); /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) @@ -277,6 +279,7 @@ void AudioOutputPortConfig::load() catch(const Exception &e) { throw e; } + INT_INFO("Exit funcation\n"); } void AudioOutputPortConfig::release() diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 54b60f2b..9d85e537 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -413,7 +413,7 @@ void FrontPanelConfig::load() * 2. Create Indicators. */ static int indicatorSize, indicatorColorSize, textDisplaySize, invalid_size = -1; - fpdConfigs_t configuration = {0}; + static fpdConfigs_t configuration = {0}; const char* searchVaribles[] = { "kFPDIndicatorColors", @@ -424,7 +424,8 @@ void FrontPanelConfig::load() "kFPDTextDisplays_size" }; bool ret = false; - + + INT_INFO("Enter function\n"); INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKFPDIndicatorColors ); if(ret == true) @@ -486,7 +487,8 @@ void FrontPanelConfig::load() *(configuration.pKIndicators_size) > 0) { #if DEBUG - dumpconfig(&configuration); + //dumpconfig(&configuration); + INT_INFO("disable the dumpconfig()\n"); #endif { @@ -533,6 +535,7 @@ void FrontPanelConfig::load() { INT_ERROR("No valid front panel configuration found\n"); } + INT_INFO("Exit function\n"); } } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 5f514c52..e51c3ba5 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -123,13 +123,14 @@ typedef struct videoDeviceConfig void VideoDeviceConfig::load() { int configSize, invalid_size = -1; - videoDeviceConfig_t videoDeviceConfig = {0}; + static videoDeviceConfig_t videoDeviceConfig = {0}; const char* searchVaribles[] = { "kVideoDeviceConfigs", "kVideoDeviceConfigs_size", }; bool ret = false; + INT_INFO("Enter function\n"); /* * Load Constants First. */ @@ -163,7 +164,8 @@ void VideoDeviceConfig::load() if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL) { #if DEBUG - dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); + //dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); + INT_INFO("disable the dumpconfig()\n"); #endif for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { _vDevices.push_back(VideoDevice(i)); @@ -177,6 +179,7 @@ void VideoDeviceConfig::load() { INT_ERROR("%d:%s: Congigs are NULL and config size are -1\n", __LINE__, __func__); } + INT_INFO("Exit function\n"); } void VideoDeviceConfig::release() diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 8496b3a5..ddb4de30 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -351,7 +351,7 @@ void dumpconfig(videoPortConfigs_t *config) void VideoOutputPortConfig::load() { static int configSize, portSize, resolutionSize, invalid_size = -1; - videoPortConfigs_t configuration = {0}; + static videoPortConfigs_t configuration = {0}; const char* searchVaribles[] = { "kVideoPortConfigs", "kVideoPortConfigs_size", @@ -362,6 +362,7 @@ void VideoOutputPortConfig::load() }; bool ret = false; + INT_INFO("Enter function\n"); try { /* * Load Constants First. @@ -444,7 +445,8 @@ void VideoOutputPortConfig::load() { #if DEBUG - dumpconfig(&configuration); + //dumpconfig(&configuration); + INT_INFO("disable the dumpconfig()\n"); #endif /* Initialize a set of supported resolutions * @@ -502,6 +504,7 @@ void VideoOutputPortConfig::load() cout << "VIdeo Outport Exception Thrown. ..."< Date: Wed, 10 Dec 2025 02:10:08 +0000 Subject: [PATCH 28/66] enable debugconfig Signed-off-by: grandhi_santoshkumar --- ds/audioOutputPortConfig.cpp | 14 ++++++++------ ds/frontPanelConfig.cpp | 4 ++-- ds/videoDeviceConfig.cpp | 4 ++-- ds/videoOutputPortConfig.cpp | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index b2071401..4e40ad5e 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -124,8 +124,10 @@ void dumpconfig(audioConfigs_t *config) INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - INT_INFO("%d:%s: pKConfigSize %p = %d \n", __LINE__, __func__, config->pKConfigSize, *(config->pKConfigSize)); - INT_INFO("%d:%s: pKPortSize %p = %d \n", __LINE__, __func__, config->pKPortSize, *(config->pKPortSize)); + INT_INFO("%d:%s: pKConfigSize addr =%p \n", __LINE__, __func__, config->pKConfigSize); + INT_INFO("%d:%s: pKConfigSize value = %d \n", __LINE__, __func__, *(config->pKConfigSize)); + INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); + INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); INT_INFO("\n\n=========================================================================================================================\n\n"); if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) @@ -141,7 +143,7 @@ void dumpconfig(audioConfigs_t *config) } else { - INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__); + INT_ERROR("%d:%s: kAudioConfigs is NULL and *(config->pKConfigSize) is -1\n", __LINE__, __func__); } if(config->pKPorts != NULL && *(config->pKPortSize) != -1) { @@ -153,7 +155,7 @@ void dumpconfig(audioConfigs_t *config) } else { - INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__); + INT_ERROR("%d:%s: kAudioPorts is NULL and *(config->pKPortSize) is -1\n", __LINE__, __func__); } INT_INFO("\n\n=========================================================================================================================\n\n"); INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); @@ -238,8 +240,8 @@ void AudioOutputPortConfig::load() if ( configuration.pKConfigs != NULL && configuration.pKPorts != NULL && configuration.pKConfigSize != NULL && configuration.pKPortSize != NULL) { - //dumpconfig(&configuration); - INT_INFO("disable the dumpconfig()\n"); + dumpconfig(&configuration); + //INT_INFO("disable the dumpconfig()\n"); /* * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 9d85e537..9edbbdc4 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -487,8 +487,8 @@ void FrontPanelConfig::load() *(configuration.pKIndicators_size) > 0) { #if DEBUG - //dumpconfig(&configuration); - INT_INFO("disable the dumpconfig()\n"); + dumpconfig(&configuration); + //INT_INFO("disable the dumpconfig()\n"); #endif { diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index e51c3ba5..e95c4dae 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -164,8 +164,8 @@ void VideoDeviceConfig::load() if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL) { #if DEBUG - //dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); - INT_INFO("disable the dumpconfig()\n"); + dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); + //INT_INFO("disable the dumpconfig()\n"); #endif for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { _vDevices.push_back(VideoDevice(i)); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index ddb4de30..ab0cd3e6 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -445,8 +445,8 @@ void VideoOutputPortConfig::load() { #if DEBUG - //dumpconfig(&configuration); - INT_INFO("disable the dumpconfig()\n"); + dumpconfig(&configuration); + //INT_INFO("disable the dumpconfig()\n"); #endif /* Initialize a set of supported resolutions * From 2b96a083d99e6545604fab94ef7fbd545b7c06d3 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 10 Dec 2025 03:49:18 +0000 Subject: [PATCH 29/66] move the debug prints within if condtion for all config dumpconfig Signed-off-by: grandhi_santoshkumar --- ds/audioOutputPortConfig.cpp | 7 +++---- ds/frontPanelConfig.cpp | 14 +++++++++----- ds/videoOutputPortConfig.cpp | 14 +++++++------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 4e40ad5e..31bf728c 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -121,6 +121,9 @@ List AudioOutputPortConfig::getSupportedTypes() void dumpconfig(audioConfigs_t *config) { + INT_INFO("\n\n=========================================================================================================================\n\n"); + if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) + { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); @@ -128,10 +131,6 @@ void dumpconfig(audioConfigs_t *config) INT_INFO("%d:%s: pKConfigSize value = %d \n", __LINE__, __func__, *(config->pKConfigSize)); INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); - - INT_INFO("\n\n=========================================================================================================================\n\n"); - if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) - { for (size_t i = 0; i < *(config->pKConfigSize); i++) { const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 9edbbdc4..b2eb6406 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -355,11 +355,12 @@ void dumpconfig(fpdConfigs_t *configuration) // Dump the configuration details INT_INFO("\n\n===========================================================================\n\n"); INT_INFO("Start of Front Panel Configuration Details:\n"); - INT_INFO("configuration->pKFPDIndicatorColors_size: %d\n", *(configuration->pKFPDIndicatorColors_size)); - INT_INFO("configuration->pKIndicators_size: %d\n", *(configuration->pKIndicators_size)); - INT_INFO("configuration->pKTextDisplays_size: %p\n", configuration->pKTextDisplays_size); - INT_INFO("Dumping Front Panel Configuration Details:\n"); - INT_INFO("Indicator Colors:\n"); + if((configuration->pKFPDIndicatorColors !=NULL) && *(configuration->pKFPDIndicatorColors_size) != -1 && (configuration->pKIndicators != NULL) && *(configuration->pKIndicators_size) != -1) + { + INT_INFO("configuration->pKFPDIndicatorColors_size addr: %p\n", (configuration->pKFPDIndicatorColors_size)); + INT_INFO("configuration->pKFPDIndicatorColors_size data: %d\n", *(configuration->pKFPDIndicatorColors_size)); + INT_INFO("configuration->pKIndicators_size addr: %p\n", (configuration->pKIndicators_size)); + INT_INFO("configuration->pKIndicators_size data: %d\n", *(configuration->pKIndicators_size)); for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { INT_INFO(" Color ID: %d, color: %d\n", configuration->pKFPDIndicatorColors[i].id, @@ -375,10 +376,13 @@ void dumpconfig(fpdConfigs_t *configuration) configuration->pKIndicators[i].levels, configuration->pKIndicators[i].colorMode); } + } if(configuration->pKTextDisplays != NULL && configuration->pKTextDisplays_size != NULL){ + INT_INFO("configuration->pKTextDisplays_size: %p\n", configuration->pKTextDisplays_size); INT_INFO("Text Displays:*(configuration->pKTextDisplays_size) =%d\n", *(configuration->pKTextDisplays_size)); + for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", configuration->pKTextDisplays[i].id, diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index ab0cd3e6..fcbd45ae 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -280,13 +280,6 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn void dumpconfig(videoPortConfigs_t *config) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); - INT_INFO("%d:%s: pKConfigSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortConfigs_size, *(config->pKVideoPortConfigs_size)); - INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - INT_INFO("%d:%s: pKPortSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortPorts_size, *(config->pKVideoPortPorts_size)); - INT_INFO("%d:%s: pKResolutionsSettings = %p\n", __LINE__, __func__, config->pKResolutionsSettings); - INT_INFO("%d:%s: pKResolutionsSettingsSize pointer %p = %d\n", __LINE__, __func__, config->pKResolutionsSettings_size, *(config->pKResolutionsSettings_size)); - INT_INFO("\n\n=========================================================================================================================\n\n"); if(config->pKConfigs != NULL && *(config->pKVideoPortConfigs_size) != -1 && config->pKPorts != NULL && *(config->pKVideoPortPorts_size) != -1 && @@ -294,6 +287,13 @@ void dumpconfig(videoPortConfigs_t *config) { INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("%d:%s: Dumping Resolutions Settings\n", __LINE__, __func__); + INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); + INT_INFO("%d:%s: pKConfigSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortConfigs_size, *(config->pKVideoPortConfigs_size)); + INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); + INT_INFO("%d:%s: pKPortSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortPorts_size, *(config->pKVideoPortPorts_size)); + INT_INFO("%d:%s: pKResolutionsSettings = %p\n", __LINE__, __func__, config->pKResolutionsSettings); + INT_INFO("%d:%s: pKResolutionsSettingsSize pointer %p = %d\n", __LINE__, __func__, config->pKResolutionsSettings_size, *(config->pKResolutionsSettings_size)); + for (size_t i = 0; i < *(config->pKResolutionsSettings_size); i++) { dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); INT_INFO("%d:%s: resolution->name = %s\n", __LINE__, __func__, resolution->name); From 703701efabfdd91801013bcdaebd0a8805521dcd Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 10 Dec 2025 07:07:20 +0000 Subject: [PATCH 30/66] added few more logs, lock_guard in searchconfig Signed-off-by: grandhi_santoshkumar --- ds/audioOutputPortConfig.cpp | 5 +++-- ds/manager.cpp | 13 +++++++++---- ds/videoDeviceConfig.cpp | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 31bf728c..f8003e83 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -129,8 +129,7 @@ void dumpconfig(audioConfigs_t *config) INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); INT_INFO("%d:%s: pKConfigSize addr =%p \n", __LINE__, __func__, config->pKConfigSize); INT_INFO("%d:%s: pKConfigSize value = %d \n", __LINE__, __func__, *(config->pKConfigSize)); - INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); - INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); + for (size_t i = 0; i < *(config->pKConfigSize); i++) { const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); @@ -146,6 +145,8 @@ void dumpconfig(audioConfigs_t *config) } if(config->pKPorts != NULL && *(config->pKPortSize) != -1) { + INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); + INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); for (size_t i = 0; i < *(config->pKPortSize); i++) { const dsAudioPortConfig_t *port = &(config->pKPorts[i]); INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); diff --git a/ds/manager.cpp b/ds/manager.cpp index dd9aaa58..fda317e1 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -68,6 +68,7 @@ namespace device { int Manager::IsInitialized = 0; //!< Indicates the application has initialized with devicettings modules. static std::mutex gManagerInitMutex; +static std::mutex gSearchMutex; Manager::Manager() { // TODO Auto-generated constructor stub @@ -164,9 +165,12 @@ bool searchConfigs(const char *searchConfigStr, void **pConfigVar) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); + INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); - pthread_mutex_lock(&dsLock); - + //pthread_mutex_lock(&dsLock); + std::lock_guard lock(gSearchMutex); + INT_INFO("%d:%s: using lock_guard() instead pthread_mutex_lock \n", __LINE__, __func__); + dlerror(); // clear old error void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); if (dllib) { *pConfigVar = (void *) dlsym(dllib, searchConfigStr); @@ -180,9 +184,10 @@ bool searchConfigs(const char *searchConfigStr, void **pConfigVar) dlclose(dllib); } else { - INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME); + const char* err = dlerror(); + INT_ERROR("%d:%s: Open %s failed with error err= %s\n", __LINE__, __func__, RDK_DSHAL_NAME, err ? err: "unknown"); } - pthread_mutex_unlock(&dsLock); + //pthread_mutex_unlock(&dsLock); INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); return (*pConfigVar != NULL); } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index e95c4dae..bdc74453 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -92,12 +92,12 @@ VideoDFC & VideoDeviceConfig::getDefaultDFC() void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_size) { INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); - INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); INT_INFO("\n\n=========================================================================================================================\n\n"); if(pKVideoDeviceConfigs != NULL && videoDeviceConfigs_size != -1) { + INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); + INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); for (int i = 0; i < videoDeviceConfigs_size; i++) { INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu\n ", i, pKVideoDeviceConfigs[i].numSupportedDFCs); for (int j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { From 0ba55bf9d9dced3f85b35ae3ffe5a69e3cb8e6e1 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 10 Dec 2025 11:42:26 +0000 Subject: [PATCH 31/66] add delay while every load --- ds/include/manager.hpp | 4 +++ ds/manager.cpp | 71 ++++++++++++++++++++++++++++++++++++++++-- sample/dsMgr-test.c | 31 ++++++++++++++++++ 3 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 sample/dsMgr-test.c diff --git a/ds/include/manager.hpp b/ds/include/manager.hpp index 0b9408d7..fab1e96c 100644 --- a/ds/include/manager.hpp +++ b/ds/include/manager.hpp @@ -149,6 +149,9 @@ #ifndef _DS_MANAGER_HPP_ #define _DS_MANAGER_HPP_ +#include + +using namespace std; /** * @file manager.hpp @@ -158,6 +161,7 @@ namespace device { // Forward declaration for searchConfigs function bool searchConfigs(const char *searchConfigStr, void **pConfigVar); +std::string parse_opt_flag( std::string file_name , bool integer_check= false , bool debugStats = true); /** * @class Manager diff --git a/ds/manager.cpp b/ds/manager.cpp index fda317e1..81ac241e 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -44,10 +44,11 @@ #include #include #include +#include #include "dsHALConfig.h" -static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; +//static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; /** @@ -86,6 +87,62 @@ Manager::~Manager() { }\ } +std::string parse_opt_flag( std::string file_name , bool integer_check , bool debugStats ) +{ + std::string return_buffer = ""; + std::ifstream parse_opt_flag_file( file_name.c_str()); + + if (!parse_opt_flag_file) + { + if ( debugStats ){ + INT_INFO("Failed to open [%s] file",file_name.c_str()); + } + } + else + { + std::string line = ""; + if (std::getline(parse_opt_flag_file, line)) + { + if ( debugStats ){ + INT_INFO("Content in [%s] is [%s]",file_name.c_str(),line.c_str()); + } + } + else + { + if ( debugStats ){ + INT_INFO("No Content in [%s]",file_name.c_str()); + } + } + parse_opt_flag_file.close(); + + return_buffer = line; + + if (integer_check) + { + if (line.empty()) + { + integer_check = false; + } + else + { + for (char c : line) { + if (!isdigit(c)) + { + integer_check = false; + break; + } + } + } + + if ( false == integer_check ) + { + return_buffer = ""; + } + } + } + return return_buffer; +} + /** * @addtogroup dssettingsmanagerapi * @{ @@ -113,6 +170,8 @@ Manager::~Manager() { void Manager::Initialize() { {std::lock_guard lock(gManagerInitMutex); + + int delay = 1; printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); try { @@ -138,9 +197,17 @@ void Manager::Initialize() CHECK_RET_VAL(err); err = dsVideoDeviceInit(); CHECK_RET_VAL(err); + std::string delaystr = parse_opt_flag("/opt/delay", true, true); + if (!delaystr.empty()) + { + INT_INFO("dealy: [%s]", delaystr.c_str()); + delay = std::stoi(delaystr); + } AudioOutputPortConfig::getInstance().load(); + sleep(delay); VideoOutputPortConfig::getInstance().load(); - VideoDeviceConfig::getInstance().load(); + sleep(delay); + VideoDeviceConfig::getInstance().load(); } IsInitialized++; } diff --git a/sample/dsMgr-test.c b/sample/dsMgr-test.c new file mode 100644 index 00000000..467a75ec --- /dev/null +++ b/sample/dsMgr-test.c @@ -0,0 +1,31 @@ + +#include +#include +#include +#include +#include "exception.hpp" +#include "host.hpp" +#include "manager.hpp" + + +int main(int argc, char *argv[]) +{ + printf("%d:%s: enter\n", __LINE__, __func__); + try { + device::Manager::Initialize(); + } catch (const device::Exception& e) { + printf("Exception caught %s", e.what()); + } catch (const std::exception& e) { + printf("Exception caught %s", e.what()); + } catch (...) { + printf("Exception caught unknown"); + } + printf("%d:%s: Exit\n", __LINE__, __func__); + return 0; +} + + + + +/** @} */ +/** @} */ From b69cb639619d9471cd4e706cb8ca430a99c154cb Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Thu, 11 Dec 2025 08:14:20 +0000 Subject: [PATCH 32/66] RDKEMW-8587: Fix dl symbol crash issue Signed-off-by: yuvaramachandran_gurusamy --- ds/audioOutputPortConfig.cpp | 65 +++++---- ds/frontPanelConfig.cpp | 249 +++++++++++++++++--------------- ds/include/frontPanelConfig.hpp | 3 +- ds/include/manager.hpp | 3 +- ds/manager.cpp | 155 +++++++------------- ds/videoOutputPortConfig.cpp | 93 ++++++------ ds/videoOutputPortConfig.hpp | 2 +- 7 files changed, 277 insertions(+), 293 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index f8003e83..238e9937 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -162,7 +162,7 @@ void dumpconfig(audioConfigs_t *config) } -void AudioOutputPortConfig::load() +void AudioOutputPortConfig::load(void* pDLHandle) { static int configSize, portSize, invalidSize = -1; static audioConfigs_t configuration = {0}; @@ -172,7 +172,7 @@ void AudioOutputPortConfig::load() "kAudioConfigs_size", "kAudioPorts_size" }; - bool ret = false; + bool isDynamicConfigLoad = false; INT_INFO("Enter function\n"); try { @@ -198,34 +198,41 @@ void AudioOutputPortConfig::load() } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKConfigs); - if(ret == true) + if ( nullptr != pDLHandle ) { + bool ret = false; + + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKConfigs); + if(ret == true) + { + // Considering Dynamic config loading is enabled since 1st symbol got + isDynamicConfigLoad = true; + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKConfigSize); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + configuration.pKConfigSize = &invalidSize; + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKPorts); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKPortSize); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKPortSize = &invalidSize; + } + } + } + if ( false == isDynamicConfigLoad) { - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKConfigSize); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - configuration.pKConfigSize = &invalidSize; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKPorts); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKPortSize); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKPortSize = &invalidSize; - } - } - else - { - INT_ERROR("Read Old Configs\n"); + INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); configuration.pKConfigs = kConfigs; configSize = dsUTL_DIM(kConfigs); configuration.pKConfigSize = &configSize; diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index b2eb6406..28bf9c42 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -69,6 +69,7 @@ namespace device { FrontPanelConfig::FrontPanelConfig() { m_isFPInitialized = false; + m_isFPConfigLoaded = false; } @@ -82,6 +83,7 @@ FrontPanelConfig::~FrontPanelConfig() { //dsFPTerm(); m_isFPInitialized = false; + m_isFPConfigLoaded = false; } @@ -105,7 +107,6 @@ FrontPanelConfig & FrontPanelConfig::getInstance() errorCode = dsFPInit(); if (dsERR_NONE == errorCode) { - _singleton.load(); _singleton.m_isFPInitialized = true; INT_INFO("dsFPInit success\n"); } @@ -409,7 +410,7 @@ void dumpconfig(fpdConfigs_t *configuration) * * @return None */ -void FrontPanelConfig::load() +void FrontPanelConfig::load(void* pDLHandle) { /* * Create Indicators @@ -418,128 +419,144 @@ void FrontPanelConfig::load() */ static int indicatorSize, indicatorColorSize, textDisplaySize, invalid_size = -1; static fpdConfigs_t configuration = {0}; + bool isDynamicConfigLoad = false; + INT_INFO("Enter function\n"); + if (( false == m_isFPInitialized) || (true == m_isFPConfigLoaded)) { + INT_ERROR("%d:%s: '%s'\n", __LINE__, __func__, (!m_isFPInitialized) ? "Front Panel not initialized" : "Front Panel Config already loaded"); + return; + } - const char* searchVaribles[] = { + if ( false == m_isFPConfigLoaded) { + const char* searchVaribles[] = { "kFPDIndicatorColors", "kFPDIndicatorColors_size", "kIndicators", "kIndicators_size", - "kFPDTextDisplays", - "kFPDTextDisplays_size" + "kFPDTextDisplays", + "kFPDTextDisplays_size" }; - bool ret = false; - - INT_INFO("Enter function\n"); - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKFPDIndicatorColors ); - if(ret == true) - { - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKFPDIndicatorColors_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - configuration.pKFPDIndicatorColors_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKIndicators); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKIndicators_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKIndicators_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[4]); - ret = searchConfigs(searchVaribles[4], (void **)&configuration.pKTextDisplays); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[4]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs(searchVaribles[5], (void **)&configuration.pKTextDisplays_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[5]); - configuration.pKTextDisplays_size = &invalid_size; - } - } - else - { - INT_ERROR("Read Old Configs\n"); - configuration.pKFPDIndicatorColors = kIndicatorColors; - indicatorColorSize = dsUTL_DIM(kIndicatorColors); - configuration.pKFPDIndicatorColors_size = &indicatorColorSize; - configuration.pKIndicators = kIndicators; - indicatorSize = dsUTL_DIM(kIndicators); - configuration.pKIndicators_size = &indicatorSize; - configuration.pKTextDisplays = kTextDisplays; - textDisplaySize = dsUTL_DIM(kTextDisplays); - configuration.pKTextDisplays_size = &textDisplaySize; - - INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); - INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); - INT_INFO("configuration.pKTextDisplays =%p, *(configuration.pKTextDisplays_size) = %d\n", configuration.pKTextDisplays, *(configuration.pKTextDisplays_size)); - } - if (configuration.pKFPDIndicatorColors != NULL && configuration.pKFPDIndicatorColors_size != NULL && - *(configuration.pKFPDIndicatorColors_size) > 0 && - configuration.pKIndicators != NULL && configuration.pKIndicators_size != NULL && - *(configuration.pKIndicators_size) > 0) - { - #if DEBUG - dumpconfig(&configuration); - //INT_INFO("disable the dumpconfig()\n"); - #endif - - { - for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { - _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); - } - - for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { - /* All indicators support a same set of colors */ - _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, - configuration.pKIndicators[i].maxBrightness, - configuration.pKIndicators[i].maxCycleRate, - configuration.pKIndicators[i].levels, - configuration.pKIndicators[i].colorMode)); - } - } - if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL) - { - /* - * Create TextDisplays - * 1. Use Supported Colors created for indicators. - * 2. Create Text Displays. - */ - INT_DEBUG("Text Displays \n"); - for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { - _textDisplays.push_back( - FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, - configuration.pKTextDisplays[i].maxBrightness, - configuration.pKTextDisplays[i].maxCycleRate, - configuration.pKTextDisplays[i].levels, - configuration.pKTextDisplays[i].maxHorizontalIterations, - configuration.pKTextDisplays[i].maxVerticalIterations, - configuration.pKTextDisplays[i].supportedCharacters, - configuration.pKTextDisplays[i].colorMode)); - } - } - else - { - INT_ERROR("No valid text display configuration found\n"); - } - } - else - { - INT_ERROR("No valid front panel configuration found\n"); - } + if (pDLHandle) + { + bool ret = false; + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKFPDIndicatorColors ); + if(ret == true) + { + // Considering Dynamic config loading is enabled since 1st symbol got + isDynamicConfigLoad = true; + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKFPDIndicatorColors_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + configuration.pKFPDIndicatorColors_size = &invalid_size; + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKIndicators); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKIndicators_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKIndicators_size = &invalid_size; + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[4]); + ret = searchConfigs(pDLHandle, searchVaribles[4], (void **)&configuration.pKTextDisplays); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[4]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); + ret = searchConfigs(pDLHandle, searchVaribles[5], (void **)&configuration.pKTextDisplays_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[5]); + configuration.pKTextDisplays_size = &invalid_size; + } + } + } + + if ( false == isDynamicConfigLoad) + { + INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); + configuration.pKFPDIndicatorColors = kIndicatorColors; + indicatorColorSize = dsUTL_DIM(kIndicatorColors); + configuration.pKFPDIndicatorColors_size = &indicatorColorSize; + configuration.pKIndicators = kIndicators; + indicatorSize = dsUTL_DIM(kIndicators); + configuration.pKIndicators_size = &indicatorSize; + configuration.pKTextDisplays = kTextDisplays; + textDisplaySize = dsUTL_DIM(kTextDisplays); + configuration.pKTextDisplays_size = &textDisplaySize; + + INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); + INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); + INT_INFO("configuration.pKTextDisplays =%p, *(configuration.pKTextDisplays_size) = %d\n", configuration.pKTextDisplays, *(configuration.pKTextDisplays_size)); + } + + if (configuration.pKFPDIndicatorColors != NULL && configuration.pKFPDIndicatorColors_size != NULL && + *(configuration.pKFPDIndicatorColors_size) > 0 && + configuration.pKIndicators != NULL && configuration.pKIndicators_size != NULL && + *(configuration.pKIndicators_size) > 0) + { + #if DEBUG + dumpconfig(&configuration); + //INT_INFO("disable the dumpconfig()\n"); + #endif + + { + for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { + _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); + } + + for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { + /* All indicators support a same set of colors */ + _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, + configuration.pKIndicators[i].maxBrightness, + configuration.pKIndicators[i].maxCycleRate, + configuration.pKIndicators[i].levels, + configuration.pKIndicators[i].colorMode)); + } + } + + if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL) + { + /* + * Create TextDisplays + * 1. Use Supported Colors created for indicators. + * 2. Create Text Displays. + */ + INT_DEBUG("Text Displays \n"); + for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { + _textDisplays.push_back( + FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, + configuration.pKTextDisplays[i].maxBrightness, + configuration.pKTextDisplays[i].maxCycleRate, + configuration.pKTextDisplays[i].levels, + configuration.pKTextDisplays[i].maxHorizontalIterations, + configuration.pKTextDisplays[i].maxVerticalIterations, + configuration.pKTextDisplays[i].supportedCharacters, + configuration.pKTextDisplays[i].colorMode)); + } + } + else + { + INT_ERROR("No valid text display configuration found\n"); + } + } + else + { + INT_ERROR("No valid front panel configuration found\n"); + } + m_isFPConfigLoaded = true; INT_INFO("Exit function\n"); + return; } } diff --git a/ds/include/frontPanelConfig.hpp b/ds/include/frontPanelConfig.hpp index 77c243ba..b22a0fa1 100644 --- a/ds/include/frontPanelConfig.hpp +++ b/ds/include/frontPanelConfig.hpp @@ -59,11 +59,12 @@ class FrontPanelConfig { std::vector _textDisplays; //!< Container to hold all the FrontPanelTextDisplay instances. std::vector _colors; //!< Container to hold all the Color instances. bool m_isFPInitialized; + bool m_isFPConfigLoaded; FrontPanelConfig(); virtual ~FrontPanelConfig(); - void load(); + void load(void* pDLHandle); public: static FrontPanelConfig & getInstance(); diff --git a/ds/include/manager.hpp b/ds/include/manager.hpp index fab1e96c..e65ff68f 100644 --- a/ds/include/manager.hpp +++ b/ds/include/manager.hpp @@ -160,8 +160,7 @@ using namespace std; namespace device { // Forward declaration for searchConfigs function -bool searchConfigs(const char *searchConfigStr, void **pConfigVar); -std::string parse_opt_flag( std::string file_name , bool integer_check= false , bool debugStats = true); +bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar); /** * @class Manager diff --git a/ds/manager.cpp b/ds/manager.cpp index 81ac241e..9ce77a01 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -69,7 +69,8 @@ namespace device { int Manager::IsInitialized = 0; //!< Indicates the application has initialized with devicettings modules. static std::mutex gManagerInitMutex; -static std::mutex gSearchMutex; +static std::mutex gDLMutex; +static void* gDLHandle = nullptr; Manager::Manager() { // TODO Auto-generated constructor stub @@ -87,62 +88,6 @@ Manager::~Manager() { }\ } -std::string parse_opt_flag( std::string file_name , bool integer_check , bool debugStats ) -{ - std::string return_buffer = ""; - std::ifstream parse_opt_flag_file( file_name.c_str()); - - if (!parse_opt_flag_file) - { - if ( debugStats ){ - INT_INFO("Failed to open [%s] file",file_name.c_str()); - } - } - else - { - std::string line = ""; - if (std::getline(parse_opt_flag_file, line)) - { - if ( debugStats ){ - INT_INFO("Content in [%s] is [%s]",file_name.c_str(),line.c_str()); - } - } - else - { - if ( debugStats ){ - INT_INFO("No Content in [%s]",file_name.c_str()); - } - } - parse_opt_flag_file.close(); - - return_buffer = line; - - if (integer_check) - { - if (line.empty()) - { - integer_check = false; - } - else - { - for (char c : line) { - if (!isdigit(c)) - { - integer_check = false; - break; - } - } - } - - if ( false == integer_check ) - { - return_buffer = ""; - } - } - } - return return_buffer; -} - /** * @addtogroup dssettingsmanagerapi * @{ @@ -171,7 +116,6 @@ void Manager::Initialize() { {std::lock_guard lock(gManagerInitMutex); - int delay = 1; printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); try { @@ -197,17 +141,14 @@ void Manager::Initialize() CHECK_RET_VAL(err); err = dsVideoDeviceInit(); CHECK_RET_VAL(err); - std::string delaystr = parse_opt_flag("/opt/delay", true, true); - if (!delaystr.empty()) - { - INT_INFO("dealy: [%s]", delaystr.c_str()); - delay = std::stoi(delaystr); - } - AudioOutputPortConfig::getInstance().load(); - sleep(delay); - VideoOutputPortConfig::getInstance().load(); - sleep(delay); - VideoDeviceConfig::getInstance().load(); + void* pDLHandle = getDLInstance(); + AudioOutputPortConfig::getInstance().load(pDLHandle); + VideoOutputPortConfig::getInstance().load(pDLHandle); + VideoDeviceConfig::getInstance().load(pDLHandle); + FrontPanelConfig::getInstance().load(pDLHandle); + if ( nullptr != pDLHandle ) { + releaseDLInstance(); + } } IsInitialized++; } @@ -222,43 +163,59 @@ void Manager::Initialize() void Manager::load() { printf("%d:%s load start\n", __LINE__, __FUNCTION__); - device::AudioOutputPortConfig::getInstance().load(); - device::VideoOutputPortConfig::getInstance().load(); - device::VideoDeviceConfig::getInstance().load(); + void* pDLHandle = getDLInstance(); + device::AudioOutputPortConfig::getInstance().load(pDLHandle); + device::VideoOutputPortConfig::getInstance().load(pDLHandle); + device::VideoDeviceConfig::getInstance().load(pDLHandle); + if ( nullptr != pDLHandle ) { + releaseDLInstance(); + } printf("%d:%s load completed\n", __LINE__, __FUNCTION__); } -bool searchConfigs(const char *searchConfigStr, void **pConfigVar) +void* Manager::getDLInstance() { - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); - INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); - - //pthread_mutex_lock(&dsLock); - std::lock_guard lock(gSearchMutex); - INT_INFO("%d:%s: using lock_guard() instead pthread_mutex_lock \n", __LINE__, __func__); - dlerror(); // clear old error - void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - if (dllib) { - *pConfigVar = (void *) dlsym(dllib, searchConfigStr); - if (*pConfigVar != NULL) { - INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); - } - else { - INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); - } + std::lock_guard lock(gDLMutex); + dlerror(); // clear old error + if (nullptr == gDLHandle){ + gDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + } + INT_INFO("%d:%s: DL Instance '%s'\n", __LINE__, __func__, (nullptr == gDLHandle ? "NULL" : "Valid")); + return gDLHandle; +} - dlclose(dllib); - } - else { - const char* err = dlerror(); - INT_ERROR("%d:%s: Open %s failed with error err= %s\n", __LINE__, __func__, RDK_DSHAL_NAME, err ? err: "unknown"); - } - //pthread_mutex_unlock(&dsLock); - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); - return (*pConfigVar != NULL); +void Manager::releaseDLInstance() +{ + std::lock_guard lock(gDLMutex); + if (nullptr != gDLHandle) { + dlclose(gDLHandle); + gDLHandle = nullptr; + } } +bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar) +{ + bool returnValue = false; + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + if ((nullptr == searchConfigStr) || (nullptr == pConfigVar) || (nullptr == pDLHandle)) { + INT_ERROR("%d:%s: Invalid parameters passed\n", __LINE__, __func__); + } + else { + INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); + INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); + + *pConfigVar = (void *) dlsym(pDLHandle, searchConfigStr); + if (*pConfigVar != NULL) { + INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); + returnValue = true; + } + else { + INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); + } + } + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + return returnValue; +} /** * @fn void Manager::DeInitialize() diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index fcbd45ae..702275d0 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -348,7 +348,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); } -void VideoOutputPortConfig::load() +void VideoOutputPortConfig::load(void* pDLHandle) { static int configSize, portSize, resolutionSize, invalid_size = -1; static videoPortConfigs_t configuration = {0}; @@ -360,6 +360,7 @@ void VideoOutputPortConfig::load() "kResolutionsSettings", "kResolutionsSettings_size" }; + bool isDynamicConfigLoad = false; bool ret = false; INT_INFO("Enter function\n"); @@ -384,47 +385,53 @@ void VideoOutputPortConfig::load() _vPortTypes.push_back(VideoOutputPortType((int)i)); } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(searchVaribles[0], (void **)&configuration.pKConfigs); - if(ret == true) + if (nullptr != pDLHandle) { + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKConfigs); + if(ret == true) + { + // Considering Dynamic config loading is enabled since 1st symbol got + isDynamicConfigLoad = true; + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKVideoPortConfigs_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + configuration.pKVideoPortConfigs_size = &invalid_size; + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); + ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKPorts); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[2]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); + ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKVideoPortPorts_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[3]); + configuration.pKVideoPortPorts_size = &invalid_size; + } + // Resolutions + ret = searchConfigs(pDLHandle, searchVaribles[4], (void **)&configuration.pKResolutionsSettings); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[4]); + } + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); + ret = searchConfigs(pDLHandle, searchVaribles[5], (void **)&configuration.pKResolutionsSettings_size); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[5]); + configuration.pKResolutionsSettings_size = &invalid_size; + } + } + } + + if ( false == isDynamicConfigLoad ) { - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(searchVaribles[1], (void **)&configuration.pKVideoPortConfigs_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - configuration.pKVideoPortConfigs_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(searchVaribles[2], (void **)&configuration.pKPorts); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(searchVaribles[3], (void **)&configuration.pKVideoPortPorts_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKVideoPortPorts_size = &invalid_size; - } - // Resolutions - ret = searchConfigs(searchVaribles[4], (void **)&configuration.pKResolutionsSettings); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[4]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs(searchVaribles[5], (void **)&configuration.pKResolutionsSettings_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[5]); - configuration.pKResolutionsSettings_size = &invalid_size; - } - } - else - { - INT_ERROR("Read Old Configs\n"); + INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); configuration.pKConfigs = kConfigs; configSize = dsUTL_DIM(kConfigs); configuration.pKVideoPortConfigs_size = &configSize; @@ -443,11 +450,7 @@ void VideoOutputPortConfig::load() (configuration.pKPorts != NULL) && (configuration.pKVideoPortPorts_size != NULL) && (configuration.pKResolutionsSettings != NULL) && (configuration.pKResolutionsSettings_size != NULL)) { - - #if DEBUG dumpconfig(&configuration); - //INT_INFO("disable the dumpconfig()\n"); - #endif /* Initialize a set of supported resolutions * */ diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index 4b011e02..269656a1 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -74,7 +74,7 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); - void load(); + void load(void* pDLHandle); void release(); }; From 0b96ee226477ad9525b277ed0126d7769d789014 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Thu, 11 Dec 2025 08:17:24 +0000 Subject: [PATCH 33/66] RDKEMW-8587: Fix dl symbol crash issue Signed-off-by: yuvaramachandran_gurusamy --- ds/audioOutputPortConfig.hpp | 2 +- ds/videoDeviceConfig.cpp | 36 ++++++++++++++++++++++-------------- ds/videoDeviceConfig.hpp | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ds/audioOutputPortConfig.hpp b/ds/audioOutputPortConfig.hpp index 90526b99..6370df40 100644 --- a/ds/audioOutputPortConfig.hpp +++ b/ds/audioOutputPortConfig.hpp @@ -66,7 +66,7 @@ class AudioOutputPortConfig { List getPorts(); List getSupportedTypes(); - void load(); + void load(void* pDLHandle); void release(); }; diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index bdc74453..2f6c50f3 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -120,7 +120,7 @@ typedef struct videoDeviceConfig int *pKVideoDeviceConfigs_size; }videoDeviceConfig_t; -void VideoDeviceConfig::load() +void VideoDeviceConfig::load(void* pDLHandle) { int configSize, invalid_size = -1; static videoDeviceConfig_t videoDeviceConfig = {0}; @@ -128,6 +128,7 @@ void VideoDeviceConfig::load() "kVideoDeviceConfigs", "kVideoDeviceConfigs_size", }; + bool isDynamicConfigLoad = false; bool ret = false; INT_INFO("Enter function\n"); @@ -138,19 +139,26 @@ void VideoDeviceConfig::load() _vDFCs.push_back(VideoDFC(i)); } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); - if(ret == true) - { - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - videoDeviceConfig.pKVideoDeviceConfigs_size = &invalid_size; - } - } - else + if ( nullptr != pDLHandle ) + { + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); + ret = searchConfigs(searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); + if(ret == true) + { + // Considering Dynamic config loading is enabled since 1st symbol got + isDynamicConfigLoad = true; + INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); + ret = searchConfigs(searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); + if(ret == false) + { + INT_ERROR("%s is not defined\n", searchVaribles[1]); + videoDeviceConfig.pKVideoDeviceConfigs_size = &invalid_size; + } + } + } + + if ( false == isDynamicConfigLoad) { INT_INFO("Read Old Configs\n"); videoDeviceConfig.pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; diff --git a/ds/videoDeviceConfig.hpp b/ds/videoDeviceConfig.hpp index 65fcf791..0673c9e3 100644 --- a/ds/videoDeviceConfig.hpp +++ b/ds/videoDeviceConfig.hpp @@ -55,7 +55,7 @@ class VideoDeviceConfig { VideoDFC & getDFC(int id); VideoDFC & getDefaultDFC(); - void load(); + void load(void* pDLHandle); void release(); }; From 32d57fbfaf703dd78628154e3b72ee4951f261fd Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Thu, 11 Dec 2025 08:19:54 +0000 Subject: [PATCH 34/66] RDKEMW-8587: Fix dl symbol crash issue Signed-off-by: yuvaramachandran_gurusamy --- ds/manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ds/manager.cpp b/ds/manager.cpp index 9ce77a01..38ccdd3b 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -173,7 +173,7 @@ void Manager::load() printf("%d:%s load completed\n", __LINE__, __FUNCTION__); } -void* Manager::getDLInstance() +void* getDLInstance() { std::lock_guard lock(gDLMutex); dlerror(); // clear old error @@ -184,7 +184,7 @@ void* Manager::getDLInstance() return gDLHandle; } -void Manager::releaseDLInstance() +void releaseDLInstance() { std::lock_guard lock(gDLMutex); if (nullptr != gDLHandle) { From 7ae4eb69c42dd499e750f7e887cee8386e8dc7c6 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Thu, 11 Dec 2025 08:52:13 +0000 Subject: [PATCH 35/66] RDKEMW-8587: Fix build error Signed-off-by: yuvaramachandran_gurusamy --- ds/audioOutputPortConfig.cpp | 12 ++--- ds/frontPanelConfig.cpp | 49 ++++++++---------- ds/include/frontPanelConfig.hpp | 11 ++-- ds/manager.cpp | 90 ++++++++++++++++----------------- ds/videoDeviceConfig.cpp | 15 +++--- ds/videoOutputPortConfig.cpp | 19 +++---- 6 files changed, 96 insertions(+), 100 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 238e9937..fdf6ebe5 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -166,12 +166,6 @@ void AudioOutputPortConfig::load(void* pDLHandle) { static int configSize, portSize, invalidSize = -1; static audioConfigs_t configuration = {0}; - const char* searchVaribles[] = { - "kAudioConfigs", - "kAudioPorts", - "kAudioConfigs_size", - "kAudioPorts_size" - }; bool isDynamicConfigLoad = false; INT_INFO("Enter function\n"); @@ -199,6 +193,12 @@ void AudioOutputPortConfig::load(void* pDLHandle) } if ( nullptr != pDLHandle ) { + const char* searchVaribles[] = { + "kAudioConfigs", + "kAudioPorts", + "kAudioConfigs_size", + "kAudioPorts_size" + }; bool ret = false; INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 28bf9c42..36bc3c63 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -362,28 +362,25 @@ void dumpconfig(fpdConfigs_t *configuration) INT_INFO("configuration->pKFPDIndicatorColors_size data: %d\n", *(configuration->pKFPDIndicatorColors_size)); INT_INFO("configuration->pKIndicators_size addr: %p\n", (configuration->pKIndicators_size)); INT_INFO("configuration->pKIndicators_size data: %d\n", *(configuration->pKIndicators_size)); - for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { - INT_INFO(" Color ID: %d, color: %d\n", - configuration->pKFPDIndicatorColors[i].id, - configuration->pKFPDIndicatorColors[i].color); - } - - INT_INFO("Indicators:\n"); - for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) { - INT_INFO(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", - configuration->pKIndicators[i].id, - configuration->pKIndicators[i].maxBrightness, - configuration->pKIndicators[i].maxCycleRate, - configuration->pKIndicators[i].levels, - configuration->pKIndicators[i].colorMode); - } + for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { + INT_INFO(" Color ID: %d, color: %d\n", + configuration->pKFPDIndicatorColors[i].id, + configuration->pKFPDIndicatorColors[i].color); + } + INT_INFO("Indicators:\n"); + for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) { + INT_INFO(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", + configuration->pKIndicators[i].id, + configuration->pKIndicators[i].maxBrightness, + configuration->pKIndicators[i].maxCycleRate, + configuration->pKIndicators[i].levels, + configuration->pKIndicators[i].colorMode); + } } if(configuration->pKTextDisplays != NULL && configuration->pKTextDisplays_size != NULL){ INT_INFO("configuration->pKTextDisplays_size: %p\n", configuration->pKTextDisplays_size); INT_INFO("Text Displays:*(configuration->pKTextDisplays_size) =%d\n", *(configuration->pKTextDisplays_size)); - - for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", configuration->pKTextDisplays[i].id, @@ -426,18 +423,16 @@ void FrontPanelConfig::load(void* pDLHandle) return; } - if ( false == m_isFPConfigLoaded) { - const char* searchVaribles[] = { - "kFPDIndicatorColors", - "kFPDIndicatorColors_size", - "kIndicators", - "kIndicators_size", - "kFPDTextDisplays", - "kFPDTextDisplays_size" - }; - if (pDLHandle) { + const char* searchVaribles[] = { + "kFPDIndicatorColors", + "kFPDIndicatorColors_size", + "kIndicators", + "kIndicators_size", + "kFPDTextDisplays", + "kFPDTextDisplays_size" + }; bool ret = false; INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); diff --git a/ds/include/frontPanelConfig.hpp b/ds/include/frontPanelConfig.hpp index b22a0fa1..be82ae60 100644 --- a/ds/include/frontPanelConfig.hpp +++ b/ds/include/frontPanelConfig.hpp @@ -64,8 +64,6 @@ class FrontPanelConfig { FrontPanelConfig(); virtual ~FrontPanelConfig(); - void load(void* pDLHandle); - public: static FrontPanelConfig & getInstance(); @@ -81,11 +79,12 @@ class FrontPanelConfig { List getIndicators(); List getTextDisplays(); - /* Initialize Front Panel */ - void fPInit(); - /* Terminate Front Panel */ - void fPTerm(); + /* Initialize Front Panel */ + void fPInit(); + /* Terminate Front Panel */ + void fPTerm(); + void load(void* pDLHandle); }; } diff --git a/ds/manager.cpp b/ds/manager.cpp index 38ccdd3b..dcad6adf 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -46,7 +46,7 @@ #include #include #include "dsHALConfig.h" - +#include "frontPanelConfig.hpp" //static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; @@ -72,6 +72,50 @@ static std::mutex gManagerInitMutex; static std::mutex gDLMutex; static void* gDLHandle = nullptr; +void* getDLInstance() +{ + std::lock_guard lock(gDLMutex); + dlerror(); // clear old error + if (nullptr == gDLHandle){ + gDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + } + INT_INFO("%d:%s: DL Instance '%s'\n", __LINE__, __func__, (nullptr == gDLHandle ? "NULL" : "Valid")); + return gDLHandle; +} + +void releaseDLInstance() +{ + std::lock_guard lock(gDLMutex); + if (nullptr != gDLHandle) { + dlclose(gDLHandle); + gDLHandle = nullptr; + } +} + +bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar) +{ + bool returnValue = false; + INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + if ((nullptr == searchConfigStr) || (nullptr == pConfigVar) || (nullptr == pDLHandle)) { + INT_ERROR("%d:%s: Invalid parameters passed\n", __LINE__, __func__); + } + else { + INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); + INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); + + *pConfigVar = (void *) dlsym(pDLHandle, searchConfigStr); + if (*pConfigVar != NULL) { + INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); + returnValue = true; + } + else { + INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); + } + } + INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + return returnValue; +} + Manager::Manager() { // TODO Auto-generated constructor stub @@ -173,50 +217,6 @@ void Manager::load() printf("%d:%s load completed\n", __LINE__, __FUNCTION__); } -void* getDLInstance() -{ - std::lock_guard lock(gDLMutex); - dlerror(); // clear old error - if (nullptr == gDLHandle){ - gDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - } - INT_INFO("%d:%s: DL Instance '%s'\n", __LINE__, __func__, (nullptr == gDLHandle ? "NULL" : "Valid")); - return gDLHandle; -} - -void releaseDLInstance() -{ - std::lock_guard lock(gDLMutex); - if (nullptr != gDLHandle) { - dlclose(gDLHandle); - gDLHandle = nullptr; - } -} - -bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar) -{ - bool returnValue = false; - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - if ((nullptr == searchConfigStr) || (nullptr == pConfigVar) || (nullptr == pDLHandle)) { - INT_ERROR("%d:%s: Invalid parameters passed\n", __LINE__, __func__); - } - else { - INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); - INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); - - *pConfigVar = (void *) dlsym(pDLHandle, searchConfigStr); - if (*pConfigVar != NULL) { - INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); - returnValue = true; - } - else { - INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); - } - } - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); - return returnValue; -} - /** * @fn void Manager::DeInitialize() * @brief This API is used to deinitialize the device settings module. diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 2f6c50f3..055ad2a9 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -124,12 +124,7 @@ void VideoDeviceConfig::load(void* pDLHandle) { int configSize, invalid_size = -1; static videoDeviceConfig_t videoDeviceConfig = {0}; - const char* searchVaribles[] = { - "kVideoDeviceConfigs", - "kVideoDeviceConfigs_size", - }; bool isDynamicConfigLoad = false; - bool ret = false; INT_INFO("Enter function\n"); /* @@ -141,15 +136,21 @@ void VideoDeviceConfig::load(void* pDLHandle) if ( nullptr != pDLHandle ) { + const char* searchVaribles[] = { + "kVideoDeviceConfigs", + "kVideoDeviceConfigs_size", + }; + bool ret = false; + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); + ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); if(ret == true) { // Considering Dynamic config loading is enabled since 1st symbol got isDynamicConfigLoad = true; INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); + ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); if(ret == false) { INT_ERROR("%s is not defined\n", searchVaribles[1]); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 702275d0..0010ba63 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -352,16 +352,7 @@ void VideoOutputPortConfig::load(void* pDLHandle) { static int configSize, portSize, resolutionSize, invalid_size = -1; static videoPortConfigs_t configuration = {0}; - const char* searchVaribles[] = { - "kVideoPortConfigs", - "kVideoPortConfigs_size", - "kVideoPortPorts", - "kVideoPortPorts_size", - "kResolutionsSettings", - "kResolutionsSettings_size" - }; bool isDynamicConfigLoad = false; - bool ret = false; INT_INFO("Enter function\n"); try { @@ -386,6 +377,16 @@ void VideoOutputPortConfig::load(void* pDLHandle) } if (nullptr != pDLHandle) { + const char* searchVaribles[] = { + "kVideoPortConfigs", + "kVideoPortConfigs_size", + "kVideoPortPorts", + "kVideoPortPorts_size", + "kResolutionsSettings", + "kResolutionsSettings_size" + }; + bool ret = false; + INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKConfigs); From cca37835cce3490344d38f4603dc0bee40ff80c2 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Fri, 12 Dec 2025 22:24:52 +0000 Subject: [PATCH 36/66] RDKEMW-8587: Fix FPD std::logical_error crash issue and enhanced the logging format Signed-off-by: yuvaramachandran_gurusamy --- ds/audioOutputPortConfig.cpp | 302 +++++++++++------------ ds/audioOutputPortConfig.hpp | 10 +- ds/dslogger.cpp | 41 ++-- ds/frontPanelConfig.cpp | 293 ++++++++++------------ ds/frontPanelIndicator.cpp | 2 - ds/hdmiIn.cpp | 62 ++--- ds/host.cpp | 2 +- ds/include/dslogger.h | 15 +- ds/include/frontPanelConfig.hpp | 14 +- ds/include/manager.hpp | 23 +- ds/manager.cpp | 169 ++++++++----- ds/videoDeviceConfig.cpp | 113 ++++----- ds/videoDeviceConfig.hpp | 8 +- ds/videoOutputPort.cpp | 14 +- ds/videoOutputPortConfig.cpp | 413 ++++++++++++++------------------ ds/videoOutputPortConfig.hpp | 16 +- sample/dsMgr-test.c | 31 --- 17 files changed, 739 insertions(+), 789 deletions(-) delete mode 100644 sample/dsMgr-test.c diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index fdf6ebe5..66da8072 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -37,15 +37,6 @@ #include #include "manager.hpp" - -typedef struct audioConfigs -{ - const dsAudioTypeConfig_t *pKConfigs; - const dsAudioPortConfig_t *pKPorts; - int *pKConfigSize; - int *pKPortSize; -}audioConfigs_t; - namespace device { //To Make the instance as thread-safe, using = default, that can request special methods from the compiler. They are Special because only compiler can create them. @@ -121,174 +112,161 @@ List AudioOutputPortConfig::getSupportedTypes() void dumpconfig(audioConfigs_t *config) { - INT_INFO("\n\n=========================================================================================================================\n\n"); - if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1) - { - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); - INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - INT_INFO("%d:%s: pKConfigSize addr =%p \n", __LINE__, __func__, config->pKConfigSize); - INT_INFO("%d:%s: pKConfigSize value = %d \n", __LINE__, __func__, *(config->pKConfigSize)); - - for (size_t i = 0; i < *(config->pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); - INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); - INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); - INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings); - INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions); - INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes); - } - } - else - { - INT_ERROR("%d:%s: kAudioConfigs is NULL and *(config->pKConfigSize) is -1\n", __LINE__, __func__); - } - if(config->pKPorts != NULL && *(config->pKPortSize) != -1) - { - INT_INFO("%d:%s: pKPortSize addr = %p \n", __LINE__, __func__, config->pKPortSize); - INT_INFO("%d:%s: pKPortSize value = %d \n", __LINE__, __func__, *(config->pKPortSize)); - for (size_t i = 0; i < *(config->pKPortSize); i++) { - const dsAudioPortConfig_t *port = &(config->pKPorts[i]); - INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); - INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); - } - } - else - { - INT_ERROR("%d:%s: kAudioPorts is NULL and *(config->pKPortSize) is -1\n", __LINE__, __func__); - } - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + if (nullptr == config) { + INT_ERROR("Audio config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + + int configSize = -1, portSize = -1; + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("Starting to Dump Audio Configs"); + if( nullptr != config->pKConfigs ) + { + configSize = (config->pKConfigSize) ? *(config->pKConfigSize) : -1; + INT_INFO("pKConfigs = %p", config->pKConfigs); + INT_INFO("pKPorts = %p", config->pKPorts); + INT_INFO("pKConfigSize addr =%p ", config->pKConfigSize); + INT_INFO("pKConfigSize value = %d ", configSize); + + for (int i = 0; i < configSize; i++) { + const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); + INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); + INT_INFO("typeCfg->name = %s", typeCfg->name); + INT_INFO("typeCfg->numSupportedEncodings = %zu", typeCfg->numSupportedEncodings); + INT_INFO("typeCfg->numSupportedCompressions = %zu", typeCfg->numSupportedCompressions); + INT_INFO("typeCfg->numSupportedStereoModes = %zu", typeCfg->numSupportedStereoModes); + } + } + else + { + INT_ERROR("kAudioConfigs is NULL"); + } + + if( nullptr != config->pKPorts ) + { + portSize = (config->pKPortSize) ? *(config->pKPortSize) : -1; + INT_INFO("pKPorts = %p", config->pKPorts); + INT_INFO("pKPortSize addr = %p ", config->pKPortSize); + INT_INFO("pKPortSize value = %d ", portSize); + for (int i = 0; i < portSize; i++) { + const dsAudioPortConfig_t *portCfg = &(config->pKPorts[i]); + INT_INFO("portCfg->id.type = %d", portCfg->id.type); + INT_INFO("portCfg->id.index = %d", portCfg->id.index); + } + } + else + { + INT_ERROR("kAudioPorts is NULL"); + } + INT_INFO("Dump Audio Configs done"); + INT_INFO("\n\n=========================================================================================================================\n\n"); } - -void AudioOutputPortConfig::load(void* pDLHandle) +void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) { - static int configSize, portSize, invalidSize = -1; - static audioConfigs_t configuration = {0}; - bool isDynamicConfigLoad = false; + int configSize = -1, portSize = -1; + audioConfigs_t configuration = {0}; + + INT_INFO("Enter function"); + try { + /* + * Load Constants First. + */ + for (int i = 0; i < dsAUDIO_ENC_MAX; i++) { + _aEncodings.push_back(AudioEncoding(i)); + } - INT_INFO("Enter function\n"); - try { - /* - * Load Constants First. - */ - for (int i = 0; i < dsAUDIO_ENC_MAX; i++) { - _aEncodings.push_back(AudioEncoding(i)); - } + for (int i = 0; i < dsAUDIO_CMP_MAX; i++) { + _aCompressions.push_back(AudioCompression(i)); - for (int i = 0; i < dsAUDIO_CMP_MAX; i++) { - _aCompressions.push_back(AudioCompression(i)); + } - } + for (int i = 0; i < dsAUDIO_STEREO_MAX; i++) { + _aStereoModes.push_back(AudioStereoMode(i)); - for (int i = 0; i < dsAUDIO_STEREO_MAX; i++) { - _aStereoModes.push_back(AudioStereoMode(i)); + } - } + for (int i = 0; i < dsAUDIOPORT_TYPE_MAX; i++) { + _aPortTypes.push_back(AudioOutputPortType(i)); - for (int i = 0; i < dsAUDIOPORT_TYPE_MAX; i++) { - _aPortTypes.push_back(AudioOutputPortType(i)); + } - } + INT_INFO("Using '%s' config", dynamicAudioConfigs ? "dynamic" : "static"); + if ( nullptr != dynamicAudioConfigs ) + { + configuration = *dynamicAudioConfigs; + configSize = (configuration.pKConfigSize) ? *(configuration.pKConfigSize) : -1; + portSize = (configuration.pKPortSize) ? *(configuration.pKPortSize) : -1; + } + else { + configuration.pKConfigs = kConfigs; + configSize = dsUTL_DIM(kConfigs); + configuration.pKConfigSize = &configSize; + configuration.pKPorts = kPorts; + portSize = dsUTL_DIM(kPorts); + configuration.pKPortSize = &portSize; + } - if ( nullptr != pDLHandle ) { - const char* searchVaribles[] = { - "kAudioConfigs", - "kAudioPorts", - "kAudioConfigs_size", - "kAudioPorts_size" - }; - bool ret = false; - - INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKConfigs); - if(ret == true) - { - // Considering Dynamic config loading is enabled since 1st symbol got - isDynamicConfigLoad = true; - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKConfigSize); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - configuration.pKConfigSize = &invalidSize; + INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]", + configuration.pKConfigs, + configSize, + configuration.pKPorts, + portSize); + + dumpconfig(&configuration); + + /* + * Check if configs are loaded properly + */ + if (( nullptr != configuration.pKConfigs ) && ( nullptr != configuration.pKPorts )) + { + /* + * Initialize Audio portTypes (encodings, compressions etc.) + * and its port instances (db, level etc) + */ + for (size_t i = 0; i < configSize; i++) { + const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); + AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); + aPortType.enable(); + for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { + const dsAudioEncoding_t* encoding = &typeCfg->encodings[j]; + aPortType.addEncoding(AudioEncoding::getInstance(*encoding)); + _aEncodings.at(*encoding).enable(); } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKPorts); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); + for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { + const dsAudioCompression_t* compression = &typeCfg->compressions[j]; + aPortType.addCompression(*compression); + _aCompressions.at(*compression).enable(); } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKPortSize); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKPortSize = &invalidSize; + for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { + const dsAudioStereoMode_t *stereoMode = &typeCfg->stereoModes[j]; + aPortType.addStereoMode(*stereoMode); + _aStereoModes.at(*stereoMode).enable(); } - } + } + + /* + * set up ports based on kPorts[] + */ + for (size_t i = 0; i < portSize; i++) { + const dsAudioPortConfig_t *portCfg = &configuration.pKPorts[i]; + _aPorts.push_back(AudioOutputPort((portCfg->id.type), portCfg->id.index, i)); + _aPortTypes.at(portCfg->id.type).addPort(_aPorts.at(i)); + } + INT_INFO("Audio Configs loaded successfully"); } - if ( false == isDynamicConfigLoad) - { - INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); - configuration.pKConfigs = kConfigs; - configSize = dsUTL_DIM(kConfigs); - configuration.pKConfigSize = &configSize; - configuration.pKPorts = kPorts; - portSize = dsUTL_DIM(kPorts); - configuration.pKPortSize = &portSize; - INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize)); - } - /* - * Check if configs are loaded properly - */ - if ( configuration.pKConfigs != NULL && configuration.pKPorts != NULL && - configuration.pKConfigSize != NULL && configuration.pKPortSize != NULL) - { - dumpconfig(&configuration); - //INT_INFO("disable the dumpconfig()\n"); - /* - * Initialize Audio portTypes (encodings, compressions etc.) - * and its port instances (db, level etc) - */ - for (size_t i = 0; i < *(configuration.pKConfigSize); i++) { - const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); - AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); - aPortType.enable(); - for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { - aPortType.addEncoding(AudioEncoding::getInstance(typeCfg->encodings[j])); - _aEncodings.at(typeCfg->encodings[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { - aPortType.addCompression(typeCfg->compressions[j]); - _aCompressions.at(typeCfg->compressions[j]).enable(); - } - for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { - aPortType.addStereoMode(typeCfg->stereoModes[j]); - _aStereoModes.at(typeCfg->stereoModes[j]).enable(); - } - } - - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(configuration.pKPortSize); i++) { - const dsAudioPortConfig_t *port = &configuration.pKPorts[i]; - _aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i)); - _aPortTypes.at(port->id.type).addPort(_aPorts.at(i)); - } - INT_INFO("%d:%s: Audio Configs loaded successfully\n", __LINE__, __func__); - } - else { - INT_ERROR("%d:%s: Audio Configs loading failed\n", __LINE__, __func__); - } - } - catch(const Exception &e) { - throw e; - } - INT_INFO("Exit funcation\n"); + else { + INT_ERROR("Audio Configs loading failed"); + } + } + catch(const Exception &e) { + throw e; + } + INT_INFO("Exit function"); } void AudioOutputPortConfig::release() diff --git a/ds/audioOutputPortConfig.hpp b/ds/audioOutputPortConfig.hpp index 6370df40..b4a1acb3 100644 --- a/ds/audioOutputPortConfig.hpp +++ b/ds/audioOutputPortConfig.hpp @@ -38,6 +38,14 @@ #include #include +typedef struct audioConfigs +{ + const dsAudioTypeConfig_t *pKConfigs; + const dsAudioPortConfig_t *pKPorts; + int *pKConfigSize; + int *pKPortSize; +}audioConfigs_t; + namespace device { class AudioOutputPortConfig { @@ -66,7 +74,7 @@ class AudioOutputPortConfig { List getPorts(); List getSupportedTypes(); - void load(void* pDLHandle); + void load(audioConfigs_t* pDLHandle); void release(); }; diff --git a/ds/dslogger.cpp b/ds/dslogger.cpp index 2fd2f81e..9cdb7322 100644 --- a/ds/dslogger.cpp +++ b/ds/dslogger.cpp @@ -30,8 +30,12 @@ #include "dslogger.h" +#include // for SYS_gettid +#include // for syscall + #define unlikely(x) (__builtin_expect(!!(x), 0)) -#define MAX_LOG_BUFF 512 +#define MAX_LOG_BUFF 1024 +#define kFormatMessageSize (MAX_LOG_BUFF - 128) DS_LogCb logCb = NULL; @@ -40,29 +44,34 @@ void DS_RegisterForLog(DS_LogCb cb) logCb = cb; } -int ds_log(int priority, const char* fileName, int lineNum, const char *format, ...) +int ds_log(LogLevel priority, const char* fileName, int lineNum, const char *func, const char *format, ...) { - char tmp_buff[MAX_LOG_BUFF] = {'\0'}; - - int offset = snprintf(tmp_buff, MAX_LOG_BUFF, "[%s:%d] ", fileName, lineNum); + char formatted[MAX_LOG_BUFF] = {'\0'}; + enum LogLevel {INFO_LEVEL = 0, WARN_LEVEL, ERROR_LEVEL, DEBUG_LEVEL, TRACE_LEVEL}; + const char *levelMap[] = { "INFO", "WARN", "ERROR", "DEBUG", "TRACE"}; - // formatting error - if (unlikely(offset < 0)) { - offset = 0; - tmp_buff[0] = '\0'; // Ensure buffer is null-terminated if snprintf fails + if (!func || !fileName || !format) + { + return -1; } - va_list args; - va_start(args, format); - vsnprintf(tmp_buff + offset, MAX_LOG_BUFF - offset, format, args); - va_end(args); + va_list argptr; + va_start(argptr, format); + vsnprintf(formatted, kFormatMessageSize, format, argptr); + va_end(argptr); if (nullptr != logCb) { - logCb(priority, tmp_buff); + logCb(priority, formatted); } else { - return printf("%s\n", tmp_buff); + fprintf(stderr, "[DS][%d] %s [%s:%d] %s: %s \n", + (int)syscall(SYS_gettid), + levelMap[static_cast(priority)], + fileName, + lineNum, + func, + formatted); + fflush(stderr); } - return 0; } diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index 36bc3c63..c2feec6a 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -47,16 +47,6 @@ using namespace std; -typedef struct fpdConfigs -{ - const dsFPDColorConfig_t *pKFPDIndicatorColors; - const dsFPDIndicatorConfig_t *pKIndicators; - const dsFPDTextDisplayConfig_t *pKTextDisplays; - int *pKFPDIndicatorColors_size; - int *pKIndicators_size; - int *pKTextDisplays_size; -}fpdConfigs_t; - namespace device { /** @@ -353,51 +343,66 @@ List FrontPanelConfig::getTextDisplays() void dumpconfig(fpdConfigs_t *configuration) { - // Dump the configuration details - INT_INFO("\n\n===========================================================================\n\n"); - INT_INFO("Start of Front Panel Configuration Details:\n"); - if((configuration->pKFPDIndicatorColors !=NULL) && *(configuration->pKFPDIndicatorColors_size) != -1 && (configuration->pKIndicators != NULL) && *(configuration->pKIndicators_size) != -1) - { - INT_INFO("configuration->pKFPDIndicatorColors_size addr: %p\n", (configuration->pKFPDIndicatorColors_size)); - INT_INFO("configuration->pKFPDIndicatorColors_size data: %d\n", *(configuration->pKFPDIndicatorColors_size)); - INT_INFO("configuration->pKIndicators_size addr: %p\n", (configuration->pKIndicators_size)); - INT_INFO("configuration->pKIndicators_size data: %d\n", *(configuration->pKIndicators_size)); - for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) { - INT_INFO(" Color ID: %d, color: %d\n", - configuration->pKFPDIndicatorColors[i].id, - configuration->pKFPDIndicatorColors[i].color); + if (nullptr == configuration) { + INT_ERROR("configuration is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + int indicatorSize = -1; + int indicatorColorSize = -1; + int textDisplaySize = (configuration->pKTextDisplays_size) ? *(configuration->pKTextDisplays_size) : -1; + // Dump the configuration details + INT_INFO("\n\n===========================================================================\n\n"); + INT_INFO("Starting to Dump FrontPanel Configs"); + if (( nullptr != configuration->pKFPDIndicatorColors) && ( nullptr != configuration->pKIndicators)) + { + int indicatorSize = (configuration->pKIndicators_size) ? *(configuration->pKIndicators_size) : -1; + int indicatorColorSize = (configuration->pKFPDIndicatorColors_size) ? *(configuration->pKFPDIndicatorColors_size) : -1; + + INT_INFO("configuration->pKFPDIndicatorColors_size addr: %p", (configuration->pKFPDIndicatorColors_size)); + INT_INFO("configuration->pKFPDIndicatorColors_size data: %d", indicatorColorSize); + INT_INFO("configuration->pKIndicators_size addr: %p", (configuration->pKIndicators_size)); + INT_INFO("configuration->pKIndicators_size data: %d", indicatorSize); + for (int i = 0; i < indicatorColorSize; i++) { + const dsFPDColorConfig_t* fpdColorCfg = &configuration->pKFPDIndicatorColors[i]; + INT_INFO(" Color ID: %d, color: %d", fpdColorCfg->id, fpdColorCfg->color); } - INT_INFO("Indicators:\n"); - for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) { - INT_INFO(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n", - configuration->pKIndicators[i].id, - configuration->pKIndicators[i].maxBrightness, - configuration->pKIndicators[i].maxCycleRate, - configuration->pKIndicators[i].levels, - configuration->pKIndicators[i].colorMode); + INT_INFO("Indicators:"); + for (int i = 0; i < indicatorSize; i++) { + const dsFPDIndicatorConfig_t* fpdIndicatorCfg = &configuration->pKIndicators[i]; + INT_INFO(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d", + fpdIndicatorCfg->id, + fpdIndicatorCfg->maxBrightness, + fpdIndicatorCfg->maxCycleRate, + fpdIndicatorCfg->levels, + fpdIndicatorCfg->colorMode); } - } + } - if(configuration->pKTextDisplays != NULL && configuration->pKTextDisplays_size != NULL){ - INT_INFO("configuration->pKTextDisplays_size: %p\n", configuration->pKTextDisplays_size); - INT_INFO("Text Displays:*(configuration->pKTextDisplays_size) =%d\n", *(configuration->pKTextDisplays_size)); - for (size_t i = 0; i < *(configuration->pKTextDisplays_size); i++) { - INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d\n", - configuration->pKTextDisplays[i].id, - configuration->pKTextDisplays[i].maxBrightness, - configuration->pKTextDisplays[i].maxCycleRate, - configuration->pKTextDisplays[i].levels, - configuration->pKTextDisplays[i].maxHorizontalIterations, - configuration->pKTextDisplays[i].maxVerticalIterations, - configuration->pKTextDisplays[i].supportedCharacters, - configuration->pKTextDisplays[i].colorMode); - } - } - else { - INT_INFO(" No Text Displays configured.\n"); - } - INT_INFO("End of Front Panel Configuration Details.\n"); - INT_INFO("\n\n===========================================================================\n\n"); + if ( nullptr != configuration->pKTextDisplays) { + int textDisplaySize = (configuration->pKTextDisplays_size) ? *(configuration->pKTextDisplays_size) : -1; + INT_INFO("Text Displays: textDisplaySize =%d", textDisplaySize); + for (int i = 0; i < textDisplaySize; i++) { + const dsFPDTextDisplayConfig_t* fpdTextDisplayCfg = &configuration->pKTextDisplays[i]; + INT_INFO(" Text Display ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Max Horizontal Iterations: %d, Max Vertical Iterations: %d, Supported Characters: %s, Color Mode: %d", + fpdTextDisplayCfg->id, + fpdTextDisplayCfg->maxBrightness, + fpdTextDisplayCfg->maxCycleRate, + fpdTextDisplayCfg->levels, + fpdTextDisplayCfg->maxHorizontalIterations, + fpdTextDisplayCfg->maxVerticalIterations, + (fpdTextDisplayCfg->supportedCharacters) ? fpdTextDisplayCfg->supportedCharacters : "NULL", + fpdTextDisplayCfg->colorMode); + } + } + else { + INT_INFO(" No Text Displays configured."); + } + INT_INFO("Dump FrontPanel Configs done"); + INT_INFO("\n\n===========================================================================\n\n"); } /** @@ -407,79 +412,30 @@ void dumpconfig(fpdConfigs_t *configuration) * * @return None */ -void FrontPanelConfig::load(void* pDLHandle) +void FrontPanelConfig::load(fpdConfigs_t* dynamicFPDConfigs) { - /* - * Create Indicators - * 1. Create Supported Colors. - * 2. Create Indicators. - */ - static int indicatorSize, indicatorColorSize, textDisplaySize, invalid_size = -1; - static fpdConfigs_t configuration = {0}; - bool isDynamicConfigLoad = false; - INT_INFO("Enter function\n"); + /* + * Create Indicators + * 1. Create Supported Colors. + * 2. Create Indicators. + */ + int indicatorSize, indicatorColorSize, textDisplaySize; + fpdConfigs_t configuration = {0}; + INT_INFO("Enter function"); if (( false == m_isFPInitialized) || (true == m_isFPConfigLoaded)) { - INT_ERROR("%d:%s: '%s'\n", __LINE__, __func__, (!m_isFPInitialized) ? "Front Panel not initialized" : "Front Panel Config already loaded"); + INT_ERROR("'%s'", (!m_isFPInitialized) ? "Front Panel not initialized" : "Front Panel Config already loaded"); return; } - if (pDLHandle) + INT_INFO("Using '%s' config", dynamicFPDConfigs ? "dynamic" : "static"); + if ( nullptr != dynamicFPDConfigs ) { - const char* searchVaribles[] = { - "kFPDIndicatorColors", - "kFPDIndicatorColors_size", - "kIndicators", - "kIndicators_size", - "kFPDTextDisplays", - "kFPDTextDisplays_size" - }; - bool ret = false; - INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKFPDIndicatorColors ); - if(ret == true) - { - // Considering Dynamic config loading is enabled since 1st symbol got - isDynamicConfigLoad = true; - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKFPDIndicatorColors_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - configuration.pKFPDIndicatorColors_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKIndicators); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKIndicators_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKIndicators_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[4]); - ret = searchConfigs(pDLHandle, searchVaribles[4], (void **)&configuration.pKTextDisplays); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[4]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs(pDLHandle, searchVaribles[5], (void **)&configuration.pKTextDisplays_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[5]); - configuration.pKTextDisplays_size = &invalid_size; - } - } + configuration = *dynamicFPDConfigs; + indicatorSize = (configuration.pKIndicators_size) ? *(configuration.pKIndicators_size) : -1; + indicatorColorSize = (configuration.pKFPDIndicatorColors_size) ? *(configuration.pKFPDIndicatorColors_size) : -1; + textDisplaySize = (configuration.pKTextDisplays_size) ? *(configuration.pKTextDisplays_size) : -1; } - - if ( false == isDynamicConfigLoad) - { - INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); + else { configuration.pKFPDIndicatorColors = kIndicatorColors; indicatorColorSize = dsUTL_DIM(kIndicatorColors); configuration.pKFPDIndicatorColors_size = &indicatorColorSize; @@ -489,68 +445,69 @@ void FrontPanelConfig::load(void* pDLHandle) configuration.pKTextDisplays = kTextDisplays; textDisplaySize = dsUTL_DIM(kTextDisplays); configuration.pKTextDisplays_size = &textDisplaySize; - - INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size)); - INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size)); - INT_INFO("configuration.pKTextDisplays =%p, *(configuration.pKTextDisplays_size) = %d\n", configuration.pKTextDisplays, *(configuration.pKTextDisplays_size)); } - if (configuration.pKFPDIndicatorColors != NULL && configuration.pKFPDIndicatorColors_size != NULL && - *(configuration.pKFPDIndicatorColors_size) > 0 && - configuration.pKIndicators != NULL && configuration.pKIndicators_size != NULL && - *(configuration.pKIndicators_size) > 0) - { - #if DEBUG - dumpconfig(&configuration); - //INT_INFO("disable the dumpconfig()\n"); - #endif + INT_INFO("FPD IndicatorColors[%p] IndicatorColors_size[%d] Indicators[%p] Indicators_size[%d] TextDisplays[%p] TextDisplays_size[%d]", + configuration.pKFPDIndicatorColors, + indicatorColorSize, + configuration.pKIndicators, + indicatorSize, + configuration.pKTextDisplays, + textDisplaySize); - { - for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) { - _colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id)); - } + dumpconfig(&configuration); - for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) { - /* All indicators support a same set of colors */ - _indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id, - configuration.pKIndicators[i].maxBrightness, - configuration.pKIndicators[i].maxCycleRate, - configuration.pKIndicators[i].levels, - configuration.pKIndicators[i].colorMode)); - } + if (( nullptr != configuration.pKFPDIndicatorColors ) && ( nullptr != configuration.pKIndicators)) + { + for (int i = 0; i < indicatorColorSize; i++) { + const dsFPDColorConfig_t* fpdColorCfg = &configuration.pKFPDIndicatorColors[i]; + _colors.push_back(FrontPanelIndicator::Color(fpdColorCfg->id)); } - if(configuration.pKTextDisplays != NULL && configuration.pKTextDisplays_size != NULL) - { - /* - * Create TextDisplays - * 1. Use Supported Colors created for indicators. - * 2. Create Text Displays. - */ - INT_DEBUG("Text Displays \n"); - for (size_t i = 0; i < *(configuration.pKTextDisplays_size); i++) { - _textDisplays.push_back( - FrontPanelTextDisplay(configuration.pKTextDisplays[i].id, - configuration.pKTextDisplays[i].maxBrightness, - configuration.pKTextDisplays[i].maxCycleRate, - configuration.pKTextDisplays[i].levels, - configuration.pKTextDisplays[i].maxHorizontalIterations, - configuration.pKTextDisplays[i].maxVerticalIterations, - configuration.pKTextDisplays[i].supportedCharacters, - configuration.pKTextDisplays[i].colorMode)); + for (int i = 0; i < indicatorSize; i++) { + const dsFPDIndicatorConfig_t* fpdIndicatorCfg = &configuration.pKIndicators[i]; + /* All indicators support a same set of colors */ + _indicators.push_back(FrontPanelIndicator(fpdIndicatorCfg->id, + fpdIndicatorCfg->maxBrightness, + fpdIndicatorCfg->maxCycleRate, + fpdIndicatorCfg->levels, + fpdIndicatorCfg->colorMode)); + } + } + else { + INT_ERROR("No valid indicator configuration found\n"); + } + + if ( nullptr != configuration.pKTextDisplays ) + { + /* + * Create TextDisplays + * 1. Use Supported Colors created for indicators. + * 2. Create Text Displays. + */ + INT_DEBUG("Text Displays \n"); + for (int i = 0; i < textDisplaySize; i++) { + const dsFPDTextDisplayConfig_t* fpdTextDisplayCfg = &configuration.pKTextDisplays[i]; + if (nullptr == fpdTextDisplayCfg->supportedCharacters) { + INT_ERROR("supportedCharacters is NULL at %d, using '%s' string...", i, DEFAULT_FPD_TEXT_DISPLAY_SUPPORTED_CHARACTERS); } + _textDisplays.push_back( + FrontPanelTextDisplay(fpdTextDisplayCfg->id, + fpdTextDisplayCfg->maxBrightness, + fpdTextDisplayCfg->maxCycleRate, + fpdTextDisplayCfg->levels, + fpdTextDisplayCfg->maxHorizontalIterations, + fpdTextDisplayCfg->maxVerticalIterations, + (fpdTextDisplayCfg->supportedCharacters) ? std::string(fpdTextDisplayCfg->supportedCharacters) : std::string(DEFAULT_FPD_TEXT_DISPLAY_SUPPORTED_CHARACTERS), + fpdTextDisplayCfg->colorMode)); } - else - { - INT_ERROR("No valid text display configuration found\n"); - } } - else + else { - INT_ERROR("No valid front panel configuration found\n"); + INT_ERROR("No valid text display configuration found\n"); } m_isFPConfigLoaded = true; - INT_INFO("Exit function\n"); + INT_INFO("Exit function"); return; } diff --git a/ds/frontPanelIndicator.cpp b/ds/frontPanelIndicator.cpp index 7a4d0202..68bae9a9 100644 --- a/ds/frontPanelIndicator.cpp +++ b/ds/frontPanelIndicator.cpp @@ -67,7 +67,6 @@ int stringToNumber (std::string text) return number; } - namespace { const char *_colorNames[] = { "Blue", @@ -100,7 +99,6 @@ namespace { }; - inline bool isIndicatorValid(int id) { return dsFPDIndicator_isValid(id); } diff --git a/ds/hdmiIn.cpp b/ds/hdmiIn.cpp index 514cff14..2e518a14 100755 --- a/ds/hdmiIn.cpp +++ b/ds/hdmiIn.cpp @@ -341,7 +341,7 @@ static std::string getResolutionStr (dsVideoResolution_t resolution) break; } - printf ("%s:%d - ResolutionStr: %s\n", __PRETTY_FUNCTION__,__LINE__, resolutionStr.c_str()); + INT_INFO("ResolutionStr: %s", resolutionStr.c_str()); return resolutionStr; } @@ -412,20 +412,20 @@ static std::string getFrameRateStr (dsVideoFrameRate_t frameRate) break; } - printf ("%s:%d - FrameRateStr: %s\n", __PRETTY_FUNCTION__,__LINE__, FrameRateStr.c_str()); + INT_INFO("FrameRateStr: %s", FrameRateStr.c_str()); return FrameRateStr; } static std::string getInterlacedStr (bool interlaced) { std::string InterlacedStr = (interlaced) ? "i" : "p"; - printf ("%s:%d - InterlacedStr: %s\n", __PRETTY_FUNCTION__,__LINE__, InterlacedStr.c_str()); + INT_INFO("InterlacedStr: %s", InterlacedStr.c_str()); return InterlacedStr; } static std::string CreateResolutionStr (const dsVideoPortResolution_t &resolution) { - printf("%s ---> \n", __PRETTY_FUNCTION__); + INT_INFO("--->"); std::string resolutionStr = getResolutionStr(resolution.pixelResolution); if(resolutionStr.compare("unknown") != 0){ @@ -433,7 +433,7 @@ static std::string CreateResolutionStr (const dsVideoPortResolution_t &resolutio getInterlacedStr(resolution.interlaced) + getFrameRateStr(resolution.frameRate); } - printf ("%s <--- %s\n", __PRETTY_FUNCTION__, resolutionStr.c_str()); + INT_INFO("<--- %s", resolutionStr.c_str()); return resolutionStr; } @@ -461,7 +461,7 @@ std::string HdmiInput::getCurrentVideoMode () const } std::string resolutionStr = CreateResolutionStr (resolution); - printf("%s:%d - Resolution =%s\n", __PRETTY_FUNCTION__,__LINE__, resolutionStr.c_str()); + INT_INFO("Resolution =%s", resolutionStr.c_str()); return resolutionStr; } @@ -478,13 +478,13 @@ void HdmiInput::getCurrentVideoModeObj (dsVideoPortResolution_t& resolution) throw Exception(eError); } - printf("%s:%d - pixelResolution =%d interlaced:%d frameRate:%d\n", __PRETTY_FUNCTION__, __LINE__, resolution.pixelResolution, resolution.interlaced, resolution.frameRate); + INT_INFO("pixelResolution =%d interlaced:%d frameRate:%d", resolution.pixelResolution, resolution.interlaced, resolution.frameRate); } void HdmiInput::getEDIDBytesInfo (int iHdmiPort, std::vector &edidArg) const { - printf("HdmiInput::getEDIDBytesInfo \r\n"); + INT_INFO("HdmiInput::getEDIDBytesInfo"); dsError_t ret = dsERR_NONE; int length = 0; @@ -493,10 +493,10 @@ void HdmiInput::getEDIDBytesInfo (int iHdmiPort, std::vector &edidArg) const char* exceptionstr = ""; ret = dsGetEDIDBytesInfo (static_cast(iHdmiPort), edid, &length); - printf("HdmiInput::getEDIDBytesInfo has ret %d\r\n", ret); + INT_INFO("HdmiInput::getEDIDBytesInfo has ret %d", ret); if (ret == dsERR_NONE) { if (length <= MAX_EDID_BYTES_LEN) { - printf("HdmiInput::getEDIDBytesInfo has %d bytes\r\n", length); + INT_INFO("HdmiInput::getEDIDBytesInfo has %d bytes", length); if (edid_parser::EDID_STATUS_OK == edid_parser::EDID_Verify(edid, length)) { edidArg.clear(); edidArg.insert(edidArg.begin(), edid, edid + length); @@ -518,17 +518,17 @@ void HdmiInput::getEDIDBytesInfo (int iHdmiPort, std::vector &edidArg) } void HdmiInput::getHDMISPDInfo (int iHdmiPort, std::vector &data) { - printf("HdmiInput::getHDMISPDInfo \r\n"); + INT_INFO("HdmiInput::getHDMISPDInfo"); unsigned char spdinfo[sizeof(struct dsSpd_infoframe_st)] = {0}; const char* exceptionstr = ""; dsError_t ret = dsGetHDMISPDInfo (static_cast(iHdmiPort), spdinfo); - printf("HdmiInput::getHDMISPDInfo has ret %d\r\n", ret); + INT_INFO("HdmiInput::getHDMISPDInfo has ret %d", ret); data.clear(); if (ret == dsERR_NONE) { if (sizeof(spdinfo) <= sizeof(struct dsSpd_infoframe_st)) { - printf("HdmiInput::getHDMISPDInfo has %d bytes\r\n", sizeof(spdinfo)); + INT_INFO("HdmiInput::getHDMISPDInfo has %d bytes", sizeof(spdinfo)); data.insert(data.begin(), spdinfo, spdinfo + sizeof(struct dsSpd_infoframe_st)); } else { ret = dsERR_OPERATION_NOT_SUPPORTED; @@ -537,11 +537,11 @@ void HdmiInput::getHDMISPDInfo (int iHdmiPort, std::vector &data) { } else { exceptionstr = "getHDMISPDInfo failed"; } - printf("HdmiInput::getHDMISPDInfo data: \r\n"); + INT_INFO("HdmiInput::getHDMISPDInfo data:"); for (int itr = 0; itr < data.size(); itr++) { printf("%02X ", data[itr]); } - printf("\n"); + INT_INFO(""); if (ret != dsERR_NONE) { throw Exception(ret, exceptionstr); @@ -550,17 +550,17 @@ void HdmiInput::getHDMISPDInfo (int iHdmiPort, std::vector &data) { } void HdmiInput::setEdidVersion (int iHdmiPort, int iEdidVersion) { - printf ("HdmiInput::setEdidVersion \r\n"); + INT_INFO("HdmiInput::setEdidVersion"); dsError_t ret = dsSetEdidVersion (static_cast(iHdmiPort), static_cast(iEdidVersion)); if (ret != dsERR_NONE) { throw Exception(ret); } - printf ("%s:%d - Set EDID Version = %d\n", __PRETTY_FUNCTION__, __LINE__, iEdidVersion); + INT_INFO("Set EDID Version = %d", iEdidVersion); } void HdmiInput::getEdidVersion (int iHdmiPort, int *iEdidVersion) { - printf ("HdmiInput::getEdidVersion \r\n"); + INT_INFO("HdmiInput::getEdidVersion"); tv_hdmi_edid_version_t EdidVersion; dsError_t ret = dsGetEdidVersion (static_cast(iHdmiPort), &EdidVersion); if (ret != dsERR_NONE) @@ -569,7 +569,7 @@ void HdmiInput::getEdidVersion (int iHdmiPort, int *iEdidVersion) { } int tmp = static_cast(EdidVersion); *iEdidVersion = tmp; - printf ("%s:%d - EDID Version = %d\n", __PRETTY_FUNCTION__, __LINE__, *iEdidVersion); + INT_INFO("EDID Version = %d", *iEdidVersion); } void HdmiInput::setVRRSupport(int iHdmiPort, bool vrrSupport) @@ -579,7 +579,7 @@ void HdmiInput::setVRRSupport(int iHdmiPort, bool vrrSupport) { throw Exception(ret); } - printf ("%s:%d - Set VRR Support = %d\n", __PRETTY_FUNCTION__, __LINE__, vrrSupport); + INT_INFO("Set VRR Support = %d", vrrSupport); } void HdmiInput::getVRRSupport (int iHdmiPort, bool *vrrSupport) { @@ -588,7 +588,7 @@ void HdmiInput::getVRRSupport (int iHdmiPort, bool *vrrSupport) { { throw Exception(ret); } - printf ("%s:%d - EDID VRR Support = %d\n", __PRETTY_FUNCTION__, __LINE__, *vrrSupport); + INT_INFO("EDID VRR Support = %d", *vrrSupport); } void HdmiInput::getVRRStatus (int iHdmiPort, dsHdmiInVrrStatus_t *vrrStatus) { @@ -597,17 +597,17 @@ void HdmiInput::getVRRStatus (int iHdmiPort, dsHdmiInVrrStatus_t *vrrStatus) { { throw Exception(ret); } - printf ("%s:%d - VRR Type = %d , VRR FrameRate = %f\n", __FUNCTION__, __LINE__, vrrStatus->vrrType,vrrStatus->vrrAmdfreesyncFramerate_Hz); + INT_INFO("VRR Type = %d , VRR FrameRate = %f", vrrStatus->vrrType,vrrStatus->vrrAmdfreesyncFramerate_Hz); } void HdmiInput::getHdmiALLMStatus (int iHdmiPort, bool *allmStatus) { - printf ("HdmiInput::getHdmiALLMStatus \r\n"); + INT_INFO("HdmiInput::getHdmiALLMStatus"); dsError_t ret = dsGetAllmStatus (static_cast(iHdmiPort), allmStatus); if (ret != dsERR_NONE) { throw Exception(ret); } - printf ("%s:%d - ALLM Status = %d\n", __FUNCTION__, __LINE__, *allmStatus); + INT_INFO("ALLM Status = %d", *allmStatus); } void HdmiInput::getSupportedGameFeatures (std::vector &featureList) { @@ -629,7 +629,7 @@ void HdmiInput::getSupportedGameFeatures (std::vector &featureList) } if(featureList.size() != feList.gameFeatureCount){ - printf ("%s:%d - Number of Supported Game Features in list doesn't match with count from HAL", __FUNCTION__, __LINE__); + INT_ERROR("Number of Supported Game Features in list doesn't match with count from HAL"); throw Exception(dsERR_GENERAL); } } @@ -637,7 +637,7 @@ void HdmiInput::getSupportedGameFeatures (std::vector &featureList) void HdmiInput::getAVLatency (int *audio_output_delay,int *video_latency) { dsError_t ret = dsGetAVLatency (audio_output_delay,video_latency); - printf ("HdmiInput::getHdmiDAL_ - VideoLatency: %d , Audio Latency: %d \r\n",*video_latency,*audio_output_delay); + INT_INFO("VideoLatency: %d , Audio Latency: %d",*video_latency,*audio_output_delay); if (ret != dsERR_NONE) { throw Exception(ret); @@ -646,24 +646,24 @@ void HdmiInput::getAVLatency (int *audio_output_delay,int *video_latency) { void HdmiInput::setEdid2AllmSupport(int iHdmiPort,bool allmSupport) { - printf ("HdmiInput::setEdid2AllmSupport \r\n"); + INT_INFO("HdmiInput::setEdid2AllmSupport"); dsError_t ret = dsSetEdid2AllmSupport (static_cast(iHdmiPort), allmSupport); if (ret != dsERR_NONE) { throw Exception(ret); } - printf ("%s:%d - Set EDID Allm Support = %d\n", __PRETTY_FUNCTION__, __LINE__, allmSupport); + INT_INFO("Set EDID Allm Support = %d", allmSupport); } void HdmiInput::getEdid2AllmSupport (int iHdmiPort, bool *allmSupport) { - printf ("HdmiInput::getEdid2AllmSupport \r\n"); + INT_INFO("HdmiInput::getEdid2AllmSupport"); dsError_t ret = dsGetEdid2AllmSupport (static_cast(iHdmiPort), allmSupport); if (ret != dsERR_NONE) { throw Exception(ret); } - printf ("%s:%d - EDID allm Support = %d\n", __PRETTY_FUNCTION__, __LINE__, *allmSupport); + INT_INFO("EDID allm Support = %d", *allmSupport); } void HdmiInput::getHdmiVersion (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *capversion) { @@ -675,7 +675,7 @@ void HdmiInput::getHdmiVersion (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *cap throw Exception(ret); } - printf ("%s:%d - HDMI Compatibility Version = %d\n", __PRETTY_FUNCTION__, __LINE__, *capversion); + INT_INFO("HDMI Compatibility Version = %d", *capversion); } dsError_t HdmiInput::getHDMIARCPortId(int &portId) { diff --git a/ds/host.cpp b/ds/host.cpp index e2475e14..98d0a071 100644 --- a/ds/host.cpp +++ b/ds/host.cpp @@ -758,7 +758,7 @@ Host::~Host() { throw Exception(ret); } - printf ("%s:%d - Set Audio Mixer levels for audio input: %d with volume = %d\n", __PRETTY_FUNCTION__, __LINE__,aInput, volume); + INT_INFO("Set Audio Mixer levels for audio input: %d with volume = %d",aInput, volume); } DefaultImpl& Host::impl() diff --git a/ds/include/dslogger.h b/ds/include/dslogger.h index e356979d..de8fb822 100644 --- a/ds/include/dslogger.h +++ b/ds/include/dslogger.h @@ -33,12 +33,9 @@ #include "dsregisterlog.h" -int ds_log(int priority, const char* fileName, int lineNum, const char *format, ...); +enum LogLevel {INFO_LEVEL = 0, WARN_LEVEL, ERROR_LEVEL, DEBUG_LEVEL, TRACE_LEVEL}; -#define INFO_LEVEL 0 -#define WARN_LEVEL 1 -#define ERROR_LEVEL 2 -#define DEBUG_LEVEL 3 +int ds_log(LogLevel level, const char* fileName, int lineNum, const char *func, const char *format, ...); // Helper to extract filename from full path // E.g. "/path/to/file.cpp" -> "file.cpp" @@ -52,13 +49,13 @@ static inline const char* fileName(const char* path) { #define DS_LOG_LEVEL ERROR_LEVEL #endif -#define INT_INFO(FORMAT, ...) ds_log(INFO_LEVEL, fileName(__FILE__), __LINE__, FORMAT, ##__VA_ARGS__ ) -#define INT_WARN(FORMAT, ...) ds_log(WARN_LEVEL, fileName(__FILE__), __LINE__, FORMAT, ##__VA_ARGS__ ) -#define INT_ERROR(FORMAT, ...) ds_log(ERROR_LEVEL, fileName(__FILE__), __LINE__, FORMAT, ##__VA_ARGS__ ) +#define INT_INFO(FORMAT, ...) ds_log(INFO_LEVEL, fileName(__FILE__), __LINE__, __FUNCTION__, FORMAT, ##__VA_ARGS__ ) +#define INT_WARN(FORMAT, ...) ds_log(WARN_LEVEL, fileName(__FILE__), __LINE__, __FUNCTION__, FORMAT, ##__VA_ARGS__ ) +#define INT_ERROR(FORMAT, ...) ds_log(ERROR_LEVEL, fileName(__FILE__), __LINE__, __FUNCTION__, FORMAT, ##__VA_ARGS__ ) // conditionally enable debug logs, based on DS_LOG_LEVEL #if DS_LOG_LEVEL >= DEBUG_LEVEL -#define INT_DEBUG(FORMAT, ...) ds_log(DEBUG_LEVEL, fileName(__FILE__), __LINE__, FORMAT, ##__VA_ARGS__ ) +#define INT_DEBUG(FORMAT, ...) ds_log(DEBUG_LEVEL, fileName(__FILE__), __LINE__, __FUNCTION__, FORMAT, ##__VA_ARGS__ ) #else #define INT_DEBUG(FORMAT, ...) ((void)0) #endif diff --git a/ds/include/frontPanelConfig.hpp b/ds/include/frontPanelConfig.hpp index be82ae60..74df3b32 100644 --- a/ds/include/frontPanelConfig.hpp +++ b/ds/include/frontPanelConfig.hpp @@ -44,6 +44,18 @@ */ using namespace std; +typedef struct fpdConfigs +{ + const dsFPDColorConfig_t *pKFPDIndicatorColors; + const dsFPDIndicatorConfig_t *pKIndicators; + const dsFPDTextDisplayConfig_t *pKTextDisplays; + int *pKFPDIndicatorColors_size; + int *pKIndicators_size; + int *pKTextDisplays_size; +}fpdConfigs_t; + +#define DEFAULT_FPD_TEXT_DISPLAY_SUPPORTED_CHARACTERS "ABCEDFG" + namespace device { @@ -84,7 +96,7 @@ class FrontPanelConfig { /* Terminate Front Panel */ void fPTerm(); - void load(void* pDLHandle); + void load(fpdConfigs_t* pDLHandle); }; } diff --git a/ds/include/manager.hpp b/ds/include/manager.hpp index e65ff68f..bcf53014 100644 --- a/ds/include/manager.hpp +++ b/ds/include/manager.hpp @@ -150,6 +150,7 @@ #define _DS_MANAGER_HPP_ #include +#include // for access API using namespace std; @@ -159,8 +160,24 @@ using namespace std; */ namespace device { -// Forward declaration for searchConfigs function -bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar); +typedef enum DeviceCapabilityTypes { + DEVICE_CAPABILITY_INVALID = 0x00000000, + DEVICE_CAPABILITY_AUDIO_PORT = 0x00000001, + DEVICE_CAPABILITY_VIDEO_PORT = 0x00000002, + DEVICE_CAPABILITY_VIDEO_DEVICE = 0x00000004, + DEVICE_CAPABILITY_FRONT_PANEL = 0x00000008, + DEVICE_CAPABILITY_MAX = 0xFFFFFFFF +} +DeviceCapabilityTypes; + +typedef struct dlSymbolLookup { + const char* name; + void** dataptr; +} +dlSymbolLookup; + +bool LoadDLSymbols(void* pDLHandle, const dlSymbolLookup* symbols, int numberOfSymbols); +void loadDeviceCapabilities(unsigned int capabilityType); /** * @class Manager @@ -174,7 +191,7 @@ class Manager { static void Initialize(); static void DeInitialize(); static void load(); //!< This function is being used for loading configure in-process DSMgr. - static int IsInitialized; //!< Indicates the application has initialized with devicettings modules. + static int IsInitialized; //!< Indicates the application has initialized with devicettings modules. }; } diff --git a/ds/manager.cpp b/ds/manager.cpp index dcad6adf..a5ac1216 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -69,51 +69,118 @@ namespace device { int Manager::IsInitialized = 0; //!< Indicates the application has initialized with devicettings modules. static std::mutex gManagerInitMutex; -static std::mutex gDLMutex; -static void* gDLHandle = nullptr; -void* getDLInstance() +bool LoadDLSymbols(void* pDLHandle, const dlSymbolLookup* symbols, int numberOfSymbols) { - std::lock_guard lock(gDLMutex); - dlerror(); // clear old error - if (nullptr == gDLHandle){ - gDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + int currentSymbols = 0; + bool isAllSymbolsLoaded = false; + if ((nullptr == pDLHandle) || (nullptr == symbols)) { + INT_ERROR("Invalid DL Handle or symbolsPtr"); + } + else { + INT_INFO("numberOfSymbols = %d",numberOfSymbols); + for (int i = 0; i < numberOfSymbols; i++) { + if (( nullptr == symbols[i].dataptr) || ( nullptr == symbols[i].name)) { + INT_ERROR("Invalid symbol entry at index [%d]", i); + continue; + } + *(symbols[i].dataptr) = dlsym(pDLHandle, symbols[i].name); + if (nullptr == *(symbols[i].dataptr)) { + INT_ERROR("[%s] is not defined", symbols[i].name); + } + else { + currentSymbols++; + INT_INFO("[%s] is defined and loaded, data[%p]", symbols[i].name, *(symbols[i].dataptr)); + } + } + isAllSymbolsLoaded = (numberOfSymbols) ? (currentSymbols == numberOfSymbols) : false; } - INT_INFO("%d:%s: DL Instance '%s'\n", __LINE__, __func__, (nullptr == gDLHandle ? "NULL" : "Valid")); - return gDLHandle; + return isAllSymbolsLoaded; } -void releaseDLInstance() +void loadDeviceCapabilities(unsigned int capabilityType) { - std::lock_guard lock(gDLMutex); - if (nullptr != gDLHandle) { - dlclose(gDLHandle); - gDLHandle = nullptr; + void* pDLHandle = nullptr; + bool isSymbolsLoaded = false; + + INT_INFO("Entering capabilityType = 0x%08X", capabilityType); + dlerror(); // clear old error + pDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + INT_INFO("DL Instance '%s'", (nullptr == pDLHandle ? "NULL" : "Valid")); + + // Audio Port Config + if (DEVICE_CAPABILITY_AUDIO_PORT & capabilityType) { + audioConfigs_t dynamicAudioConfigs = {0 }; + dlSymbolLookup audioConfigSymbols[] = { + {"kAudioConfigs", (void**)&dynamicAudioConfigs.pKConfigs}, + {"kAudioPorts", (void**)&dynamicAudioConfigs.pKPorts}, + {"kAudioConfigs_size", (void**)&dynamicAudioConfigs.pKConfigSize}, + {"kAudioPorts_size", (void**)&dynamicAudioConfigs.pKPortSize} + }; + + isSymbolsLoaded = false; + if (nullptr != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, audioConfigSymbols, sizeof(audioConfigSymbols)/sizeof(dlSymbolLookup)); + } + AudioOutputPortConfig::getInstance().load(isSymbolsLoaded ? &dynamicAudioConfigs : nullptr); } -} -bool searchConfigs(void* pDLHandle, const char *searchConfigStr, void **pConfigVar) -{ - bool returnValue = false; - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - if ((nullptr == searchConfigStr) || (nullptr == pConfigVar) || (nullptr == pDLHandle)) { - INT_ERROR("%d:%s: Invalid parameters passed\n", __LINE__, __func__); + // Video Port Config + if (DEVICE_CAPABILITY_VIDEO_PORT & capabilityType) { + videoPortConfigs_t dynamicVideoPortConfigs = {0}; + dlSymbolLookup videoPortConfigSymbols[] = { + {"kVideoPortConfigs", (void**)&dynamicVideoPortConfigs.pKConfigs}, + {"kVideoPortConfigs_size", (void**)&dynamicVideoPortConfigs.pKVideoPortConfigs_size}, + {"kVideoPortPorts", (void**)&dynamicVideoPortConfigs.pKPorts}, + {"kVideoPortPorts_size", (void**)&dynamicVideoPortConfigs.pKVideoPortPorts_size}, + {"kResolutionsSettings", (void**)&dynamicVideoPortConfigs.pKResolutionsSettings}, + {"kResolutionsSettings_size", (void**)&dynamicVideoPortConfigs.pKResolutionsSettings_size} + }; + + isSymbolsLoaded = false; + if (nullptr != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoPortConfigSymbols, sizeof(videoPortConfigSymbols)/sizeof(dlSymbolLookup)); + } + VideoOutputPortConfig::getInstance().load(isSymbolsLoaded ? &dynamicVideoPortConfigs : nullptr); } - else { - INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr); - INT_INFO("%d:%s: RDK_DSHAL_NAME = %s\n", __LINE__, __func__, RDK_DSHAL_NAME); - *pConfigVar = (void *) dlsym(pDLHandle, searchConfigStr); - if (*pConfigVar != NULL) { - INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar); - returnValue = true; + // Video Device Config + if (DEVICE_CAPABILITY_VIDEO_DEVICE & capabilityType) { + videoDeviceConfig_t dynamicVideoDeviceConfigs = {0}; + dlSymbolLookup videoDeviceConfigSymbols[] = { + {"kVideoDeviceConfigs", (void**)&dynamicVideoDeviceConfigs.pKVideoDeviceConfigs}, + {"kVideoDeviceConfigs_size", (void**)&dynamicVideoDeviceConfigs.pKVideoDeviceConfigs_size} + }; + isSymbolsLoaded = false; + if (nullptr != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoDeviceConfigSymbols, sizeof(videoDeviceConfigSymbols)/sizeof(dlSymbolLookup)); } - else { - INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr); + VideoDeviceConfig::getInstance().load(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : nullptr); + } + + // Front Panel Config + if (DEVICE_CAPABILITY_FRONT_PANEL & capabilityType) { + fpdConfigs_t dynamicFPDConfigs = {0}; + dlSymbolLookup fpdConfigSymbols[] = { + {"kFPDIndicatorColors", (void**)&dynamicFPDConfigs.pKFPDIndicatorColors}, + {"kFPDIndicatorColors_size", (void**)&dynamicFPDConfigs.pKFPDIndicatorColors_size}, + {"kIndicators", (void**)&dynamicFPDConfigs.pKIndicators}, + {"kIndicators_size", (void**)&dynamicFPDConfigs.pKIndicators_size}, + {"kFPDTextDisplays", (void**)&dynamicFPDConfigs.pKTextDisplays}, + {"kFPDTextDisplays_size", (void**)&dynamicFPDConfigs.pKTextDisplays_size} + }; + isSymbolsLoaded = false; + if (nullptr != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, fpdConfigSymbols, sizeof(fpdConfigSymbols)/sizeof(dlSymbolLookup)); } + FrontPanelConfig::getInstance().load(isSymbolsLoaded ? &dynamicFPDConfigs : nullptr); } - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); - return returnValue; + + if (nullptr != pDLHandle) { + dlclose(pDLHandle); + pDLHandle = nullptr; + } + INT_INFO("Exiting ..."); } Manager::Manager() { @@ -160,7 +227,7 @@ void Manager::Initialize() { {std::lock_guard lock(gManagerInitMutex); - printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + INT_INFO("Entering ... count %d with thread id %lu\n",IsInitialized,pthread_self()); try { if (0 == IsInitialized) { @@ -174,7 +241,7 @@ void Manager::Initialize() // That's why the retry logic is applied only for dsDisplayInit. do { err = dsDisplayInit(); - printf ("Manager::Initialize: result :%d retryCount :%d\n", err, retryCount); + INT_INFO("dsDisplayInit returned %d, retryCount %d", err, retryCount); if (dsERR_NONE == err) break; usleep(100000); } while(( dsERR_INVALID_STATE == err) && (retryCount++ < 25)); @@ -185,14 +252,11 @@ void Manager::Initialize() CHECK_RET_VAL(err); err = dsVideoDeviceInit(); CHECK_RET_VAL(err); - void* pDLHandle = getDLInstance(); - AudioOutputPortConfig::getInstance().load(pDLHandle); - VideoOutputPortConfig::getInstance().load(pDLHandle); - VideoDeviceConfig::getInstance().load(pDLHandle); - FrontPanelConfig::getInstance().load(pDLHandle); - if ( nullptr != pDLHandle ) { - releaseDLInstance(); - } + + loadDeviceCapabilities(device::DEVICE_CAPABILITY_VIDEO_PORT | + device::DEVICE_CAPABILITY_AUDIO_PORT | + device::DEVICE_CAPABILITY_VIDEO_DEVICE | + device::DEVICE_CAPABILITY_FRONT_PANEL); } IsInitialized++; } @@ -201,20 +265,16 @@ void Manager::Initialize() throw e; } } - printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); + INT_INFO("Exiting ... with thread id %lu",pthread_self()); } void Manager::load() { - printf("%d:%s load start\n", __LINE__, __FUNCTION__); - void* pDLHandle = getDLInstance(); - device::AudioOutputPortConfig::getInstance().load(pDLHandle); - device::VideoOutputPortConfig::getInstance().load(pDLHandle); - device::VideoDeviceConfig::getInstance().load(pDLHandle); - if ( nullptr != pDLHandle ) { - releaseDLInstance(); - } - printf("%d:%s load completed\n", __LINE__, __FUNCTION__); + INT_INFO("Enter function"); + loadDeviceCapabilities( device::DEVICE_CAPABILITY_VIDEO_PORT | + device::DEVICE_CAPABILITY_AUDIO_PORT | + device::DEVICE_CAPABILITY_VIDEO_DEVICE); + INT_INFO("Exit function"); } /** @@ -239,7 +299,7 @@ void Manager::load() void Manager::DeInitialize() { {std::lock_guard lock(gManagerInitMutex); - printf("Entering %s count %d with thread id: %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + INT_INFO("Entering ... count %d with thread id %lu",IsInitialized,pthread_self()); if(IsInitialized>0)IsInitialized--; if (0 == IsInitialized) { @@ -253,8 +313,7 @@ void Manager::DeInitialize() dsDisplayTerm(); } } - printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); - + INT_INFO("Exiting ... with thread %lu",pthread_self()); } } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 055ad2a9..102e805b 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -88,45 +88,46 @@ VideoDFC & VideoDeviceConfig::getDefaultDFC() return _vDFCs.back(); } - -void dumpconfig(dsVideoConfig_t *pKVideoDeviceConfigs, int videoDeviceConfigs_size) +void dumpconfig(videoDeviceConfig_t *config) { - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); + if (nullptr == config) { + INT_ERROR("Video config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } - INT_INFO("\n\n=========================================================================================================================\n\n"); - if(pKVideoDeviceConfigs != NULL && videoDeviceConfigs_size != -1) + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("Starting to Dump VideoDevice Configs"); + if( nullptr != config->pKVideoDeviceConfigs ) { - INT_INFO("%d:%s: pKVideoDeviceConfigs = %p\n", __LINE__, __func__, pKVideoDeviceConfigs); - INT_INFO("%d:%s: videoDeviceConfigs_size = %d\n", __LINE__, __func__, videoDeviceConfigs_size); - for (int i = 0; i < videoDeviceConfigs_size; i++) { - INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu\n ", i, pKVideoDeviceConfigs[i].numSupportedDFCs); - for (int j = 0; j < pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { - INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, pKVideoDeviceConfigs[i].supportedDFCs[j]); + int configSize = (config->pKVideoDeviceConfigs_size) ? *(config->pKVideoDeviceConfigs_size) : -1; + INT_INFO("pKVideoDeviceConfigs = %p", config->pKVideoDeviceConfigs); + INT_INFO("videoDeviceConfigs_size = %d", configSize); + for (int i = 0; i < configSize; i++) { + dsVideoConfig_t* videoDeviceConfig = &config->pKVideoDeviceConfigs[i]; + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu ", i, videoDeviceConfig->numSupportedDFCs); + for (int j = 0; j < videoDeviceConfig->numSupportedDFCs; j++) { + INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, videoDeviceConfig->supportedDFCs[j]); } } } else { - INT_ERROR("%d:%s: kVideoDeviceConfigs is NULL and videoDeviceConfigs_size is -1\n", __LINE__, __func__); + INT_ERROR(" kVideoDeviceConfigs is NULL"); } - + INT_INFO("Dump VideoDevice Configs done"); INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); } -typedef struct videoDeviceConfig -{ - dsVideoConfig_t *pKVideoDeviceConfigs; - int *pKVideoDeviceConfigs_size; -}videoDeviceConfig_t; - -void VideoDeviceConfig::load(void* pDLHandle) +void VideoDeviceConfig::load(videoDeviceConfig_t* dynamicVideoDeviceConfigs) { - int configSize, invalid_size = -1; - static videoDeviceConfig_t videoDeviceConfig = {0}; - bool isDynamicConfigLoad = false; + int configSize = -1; + videoDeviceConfig_t configuration = {0}; - INT_INFO("Enter function\n"); + INT_INFO("Enter function"); /* * Load Constants First. */ @@ -134,61 +135,41 @@ void VideoDeviceConfig::load(void* pDLHandle) _vDFCs.push_back(VideoDFC(i)); } - if ( nullptr != pDLHandle ) + INT_INFO("Using '%s' config", dynamicVideoDeviceConfigs ? "dynamic" : "static"); + if ( nullptr != dynamicVideoDeviceConfigs ) { - const char* searchVaribles[] = { - "kVideoDeviceConfigs", - "kVideoDeviceConfigs_size", - }; - bool ret = false; - - INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs)); - if(ret == true) - { - // Considering Dynamic config loading is enabled since 1st symbol got - isDynamicConfigLoad = true; - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&(videoDeviceConfig.pKVideoDeviceConfigs_size)); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - videoDeviceConfig.pKVideoDeviceConfigs_size = &invalid_size; - } - } + configuration = *dynamicVideoDeviceConfigs; + configSize = (configuration.pKVideoDeviceConfigs_size) ? *(configuration.pKVideoDeviceConfigs_size) : -1; } - - if ( false == isDynamicConfigLoad) - { - INT_INFO("Read Old Configs\n"); - videoDeviceConfig.pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; + else { + configuration.pKVideoDeviceConfigs = (dsVideoConfig_t *)kConfigs; configSize = dsUTL_DIM(kConfigs); - videoDeviceConfig.pKVideoDeviceConfigs_size = &configSize; - } + configuration.pKVideoDeviceConfigs_size = &configSize; + } + + INT_INFO("VideoDevice Config[%p] ConfigSize[%d]", configuration.pKVideoDeviceConfigs, configSize); + + dumpconfig(&configuration); /* * Initialize Video Devices (supported DFCs etc.) */ - if (videoDeviceConfig.pKVideoDeviceConfigs != NULL && videoDeviceConfig.pKVideoDeviceConfigs_size != NULL) + if ( nullptr != configuration.pKVideoDeviceConfigs ) { - #if DEBUG - dumpconfig(videoDeviceConfig.pKVideoDeviceConfigs, *(videoDeviceConfig.pKVideoDeviceConfigs_size)); - //INT_INFO("disable the dumpconfig()\n"); - #endif - for (size_t i = 0; i < *(videoDeviceConfig.pKVideoDeviceConfigs_size); i++) { - _vDevices.push_back(VideoDevice(i)); - - for (size_t j = 0; j < videoDeviceConfig.pKVideoDeviceConfigs[i].numSupportedDFCs; j++) { - _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceConfig.pKVideoDeviceConfigs[i].supportedDFCs[j])); + for (size_t i = 0; i < configSize; i++) { + dsVideoConfig_t* videoDeviceCfg = &configuration.pKVideoDeviceConfigs[i]; + _vDevices.push_back(VideoDevice(i)); + + for (size_t j = 0; j < videoDeviceCfg->numSupportedDFCs; j++) { + _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceCfg->supportedDFCs[j])); } } } else { - INT_ERROR("%d:%s: Congigs are NULL and config size are -1\n", __LINE__, __func__); + INT_ERROR(" Configs are NULL and config size are -1"); } - INT_INFO("Exit function\n"); + INT_INFO("Exit function"); } void VideoDeviceConfig::release() diff --git a/ds/videoDeviceConfig.hpp b/ds/videoDeviceConfig.hpp index 0673c9e3..71a42a96 100644 --- a/ds/videoDeviceConfig.hpp +++ b/ds/videoDeviceConfig.hpp @@ -35,6 +35,12 @@ #include "videoDevice.hpp" #include +typedef struct videoDeviceConfig +{ + dsVideoConfig_t *pKVideoDeviceConfigs; + int *pKVideoDeviceConfigs_size; +}videoDeviceConfig_t; + namespace device { class VideoDeviceConfig { @@ -55,7 +61,7 @@ class VideoDeviceConfig { VideoDFC & getDFC(int id); VideoDFC & getDefaultDFC(); - void load(void* pDLHandle); + void load(videoDeviceConfig_t* pDLHandle); void release(); }; diff --git a/ds/videoOutputPort.cpp b/ds/videoOutputPort.cpp index c77aa5c4..a5b29674 100644 --- a/ds/videoOutputPort.cpp +++ b/ds/videoOutputPort.cpp @@ -128,7 +128,7 @@ VideoOutputPort::VideoOutputPort(const int type, const int index, const int id, _resolution(resolution), _display(*this) { - dsError_t ret = dsGetVideoPort((dsVideoPortType_t)_type, _index, &_handle); + dsError_t ret = dsGetVideoPort((dsVideoPortType_t)_type, _index, &_handle); { std::stringstream out; @@ -138,25 +138,25 @@ VideoOutputPort::VideoOutputPort(const int type, const int index, const int id, if (ret == dsERR_NONE) { bool enabled = false; - ret = dsIsVideoPortEnabled(_handle, &enabled); + ret = dsIsVideoPortEnabled(_handle, &enabled); if (ret == dsERR_NONE) { _enabled = enabled; _contentProtected = false; bool connected = false; - ret = dsIsDisplayConnected(_handle, &connected); + ret = dsIsDisplayConnected(_handle, &connected); if (ret == dsERR_NONE) { - _displayConnected = connected; + _displayConnected = connected; } else { - throw IllegalArgumentException(); + throw IllegalArgumentException(); } } else { } } else { - throw IllegalArgumentException(); + throw IllegalArgumentException(); } } @@ -465,7 +465,7 @@ bool VideoOutputPort::isDynamicResolutionSupported() const */ void VideoOutputPort::setResolution(const std::string &resolutionName, bool persist/* = true*/, bool isIgnoreEdid/* = false*/) { - printf("ResOverride VideoOutputPort::setResolution resolutionName:%s persist:%d isIgnoreEdid:%d line:%d\r\n", resolutionName.c_str(), persist, isIgnoreEdid, __LINE__); + INT_INFO("ResOverride VideoOutputPort::setResolution resolutionName:%s persist:%d isIgnoreEdid:%d", resolutionName.c_str(), persist, isIgnoreEdid); if (0 && resolutionName.compare(_resolution) == 0) { return; } diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 0010ba63..12cb54a8 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -53,16 +53,6 @@ using namespace std; #define DEBUG 1 // Using for dumpconfig -typedef struct videoPortConfigs -{ - const dsVideoPortTypeConfig_t *pKConfigs; - int *pKVideoPortConfigs_size; - const dsVideoPortPortConfig_t *pKPorts; - int *pKVideoPortPorts_size; - dsVideoPortResolution_t *pKResolutionsSettings; - int *pKResolutionsSettings_size; -}videoPortConfigs_t; - namespace device { static VideoResolution* defaultVideoResolution; @@ -279,237 +269,200 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn void dumpconfig(videoPortConfigs_t *config) { - INT_INFO("%d:%s: Entering function\n", __LINE__, __func__); - INT_INFO("\n\n=========================================================================================================================\n\n"); - if(config->pKConfigs != NULL && *(config->pKVideoPortConfigs_size) != -1 && - config->pKPorts != NULL && *(config->pKVideoPortPorts_size) != -1 && - config->pKResolutionsSettings != NULL && *(config->pKResolutionsSettings_size) != -1 ) - { - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("%d:%s: Dumping Resolutions Settings\n", __LINE__, __func__); - INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs); - INT_INFO("%d:%s: pKConfigSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortConfigs_size, *(config->pKVideoPortConfigs_size)); - INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts); - INT_INFO("%d:%s: pKPortSize pointer %p = %d\n", __LINE__, __func__, config->pKVideoPortPorts_size, *(config->pKVideoPortPorts_size)); - INT_INFO("%d:%s: pKResolutionsSettings = %p\n", __LINE__, __func__, config->pKResolutionsSettings); - INT_INFO("%d:%s: pKResolutionsSettingsSize pointer %p = %d\n", __LINE__, __func__, config->pKResolutionsSettings_size, *(config->pKResolutionsSettings_size)); - - for (size_t i = 0; i < *(config->pKResolutionsSettings_size); i++) { - dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); - INT_INFO("%d:%s: resolution->name = %s\n", __LINE__, __func__, resolution->name); - INT_INFO("%d:%s: resolution->pixelResolution= %d\n", __LINE__, __func__, resolution->pixelResolution); - INT_INFO("%d:%s: resolution->aspectRatio= %d\n", __LINE__, __func__, resolution->aspectRatio); - INT_INFO("%d:%s: resolution->stereoScopicMode= %d\n", __LINE__, __func__, resolution->stereoScopicMode); - INT_INFO("%d:%s: resolution->frameRate= %d\n", __LINE__, __func__, resolution->frameRate); - INT_INFO("%d:%s: resolution->interlaced= %d\n", __LINE__, __func__, resolution->interlaced); - - } - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("%d:%s: Dumping Video Port Configurations\n", __LINE__, __func__); - for (size_t i = 0; i < *(config->pKVideoPortConfigs_size); i++) - { - const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); - - INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId); - INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name); - INT_INFO("%d:%s: typeCfg->dtcpSupported= %d\n", __LINE__, __func__, typeCfg->dtcpSupported); - INT_INFO("%d:%s: typeCfg->hdcpSupported = %d\n", __LINE__, __func__, typeCfg->hdcpSupported); - INT_INFO("%d:%s: typeCfg->restrictedResollution = %d\n", __LINE__, __func__, typeCfg->restrictedResollution); - INT_INFO("%d:%s: typeCfg->numSupportedResolutions= %lu\n", __LINE__, __func__, typeCfg->numSupportedResolutions); - - INT_INFO("%d:%s: typeCfg->supportedResolutions = %p\n", __LINE__, __func__, typeCfg->supportedResolutions); - INT_INFO("%d:%s: typeCfg->supportedResolutions->name = %s\n", __LINE__, __func__, typeCfg->supportedResolutions->name); - INT_INFO("%d:%s: typeCfg->supportedResolutions->pixelResolution= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->pixelResolution); - INT_INFO("%d:%s: typeCfg->supportedResolutions->aspectRatio= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->aspectRatio); - INT_INFO("%d:%s: typeCfg->supportedResolutions->stereoScopicMode= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->stereoScopicMode); - INT_INFO("%d:%s: typeCfg->supportedResolutions->frameRate= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->frameRate); - INT_INFO("%d:%s: typeCfg->supportedResolutions->interlaced= %d\n", __LINE__, __func__, typeCfg->supportedResolutions->interlaced); - } - INT_INFO("\n\n####################################################################### \n\n"); - - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("%d:%s: Dumping Video Port Connections\n", __LINE__, __func__); - for (size_t i = 0; i < *(config->pKVideoPortPorts_size); i++) { - const dsVideoPortPortConfig_t *port = &(config->pKPorts[i]); - INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type); - INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index); - INT_INFO("%d:%s: port->connectedAOP.type = %d\n", __LINE__, __func__, port->connectedAOP.type); - INT_INFO("%d:%s: port->connectedAOP.index = %d\n", __LINE__, __func__, port->connectedAOP.index); - INT_INFO("%d:%s: port->defaultResolution = %s\n", __LINE__, __func__, port->defaultResolution); - } - INT_INFO("\n\n####################################################################### \n\n"); - } - else - { - INT_ERROR("%d:%s: pKConfigs or pKPorts or pKResolutionsSettings is NULL, and pKVideoPortConfigs_size or pKVideoPortPorts_size or pKResolutionsSettings_size is -1\n", __LINE__, __func__); - } - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("%d:%s: Exit function\n", __LINE__, __func__); + if (nullptr == config) { + INT_ERROR("Video config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("Starting to Dump VideoPort Configs"); + int configSize = -1, portSize = -1, resolutionSize = -1; + if (( nullptr != config->pKConfigs ) && ( nullptr != config->pKPorts ) && ( nullptr != config->pKResolutionsSettings )) + { + configSize = (config->pKVideoPortConfigs_size) ? *(config->pKVideoPortConfigs_size) : -1; + portSize = (config->pKVideoPortPorts_size) ? *(config->pKVideoPortPorts_size) : -1; + resolutionSize = (config->pKResolutionsSettings_size) ? *(config->pKResolutionsSettings_size) : -1; + INT_INFO("pKConfigs = %p", config->pKConfigs); + INT_INFO("pKConfigSize pointer %p = %d", config->pKVideoPortConfigs_size, configSize); + INT_INFO("pKPorts = %p", config->pKPorts); + INT_INFO("pKPortSize pointer %p = %d", config->pKVideoPortPorts_size, portSize); + INT_INFO("pKResolutionsSettings = %p", config->pKResolutionsSettings); + INT_INFO("pKResolutionsSettingsSize pointer %p = %d", config->pKResolutionsSettings_size, resolutionSize); + + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("Dumping Video Resolutions Settings"); + for (size_t i = 0; i < resolutionSize; i++) { + dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); + INT_INFO("resolution->name = %s", (resolution->name) ? resolution->name : "NULL"); + INT_INFO("resolution->pixelResolution= %d", resolution->pixelResolution); + INT_INFO("resolution->aspectRatio= %d", resolution->aspectRatio); + INT_INFO("resolution->stereoScopicMode= %d", resolution->stereoScopicMode); + INT_INFO("resolution->frameRate= %d", resolution->frameRate); + INT_INFO("resolution->interlaced= %d", resolution->interlaced); + } + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("Dumping Video Port Configurations"); + for (size_t i = 0; i < configSize; i++) + { + const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); + INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); + INT_INFO("typeCfg->name = %s", (typeCfg->name) ? typeCfg->name : "NULL"); + INT_INFO("typeCfg->dtcpSupported= %d", typeCfg->dtcpSupported); + INT_INFO("typeCfg->hdcpSupported = %d", typeCfg->hdcpSupported); + INT_INFO("typeCfg->restrictedResollution = %d", typeCfg->restrictedResollution); + INT_INFO("typeCfg->numSupportedResolutions= %lu", typeCfg->numSupportedResolutions); + + INT_INFO("typeCfg->supportedResolutions = %p", typeCfg->supportedResolutions); + INT_INFO("typeCfg->supportedResolutions->name = %s", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); + INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d", typeCfg->supportedResolutions->pixelResolution); + INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d", typeCfg->supportedResolutions->aspectRatio); + INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d", typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); + INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); + } + INT_INFO("\n\n####################################################################### \n\n"); + + INT_INFO("\n\n####################################################################### \n\n"); + INT_INFO("Dumping Video Port Connections"); + for (size_t i = 0; i < portSize; i++) { + const dsVideoPortPortConfig_t *portCfg = &(config->pKPorts[i]); + INT_INFO("portCfg->id.type = %d", portCfg->id.type); + INT_INFO("portCfg->id.index = %d", portCfg->id.index); + INT_INFO("portCfg->connectedAOP.type = %d", portCfg->connectedAOP.type); + INT_INFO("portCfg->connectedAOP.index = %d", portCfg->connectedAOP.index); + INT_INFO("portCfg->defaultResolution = %s", (portCfg->defaultResolution) ? portCfg->defaultResolution : "NULL"); + } + INT_INFO("\n\n####################################################################### \n\n"); + } + else + { + INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); + } + INT_INFO("Dump VideoPort Configs done"); + INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("Exit function"); } -void VideoOutputPortConfig::load(void* pDLHandle) +void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) { - static int configSize, portSize, resolutionSize, invalid_size = -1; - static videoPortConfigs_t configuration = {0}; - bool isDynamicConfigLoad = false; + int configSize, portSize, resolutionSize; + videoPortConfigs_t configuration = {0}; + + INT_INFO("Enter function"); + try { + /* + * Load Constants First. + */ + for (size_t i = 0; i < dsVIDEO_PIXELRES_MAX; i++) { + _vPixelResolutions.push_back(PixelResolution(i)); + } + for (size_t i = 0; i < dsVIDEO_ASPECT_RATIO_MAX; i++) { + _vAspectRatios.push_back(AspectRatio(i)); + } + for (size_t i = 0; i < dsVIDEO_SSMODE_MAX; i++) { + _vStereoScopieModes.push_back(StereoScopicMode(i)); + } + for (size_t i = 0; i < dsVIDEO_FRAMERATE_MAX; i++) { + _vFrameRates.push_back(FrameRate((int)i)); + } - INT_INFO("Enter function\n"); - try { - /* - * Load Constants First. - */ - for (size_t i = 0; i < dsVIDEO_PIXELRES_MAX; i++) { - _vPixelResolutions.push_back(PixelResolution(i)); - } - for (size_t i = 0; i < dsVIDEO_ASPECT_RATIO_MAX; i++) { - _vAspectRatios.push_back(AspectRatio(i)); - } - for (size_t i = 0; i < dsVIDEO_SSMODE_MAX; i++) { - _vStereoScopieModes.push_back(StereoScopicMode(i)); - } - for (size_t i = 0; i < dsVIDEO_FRAMERATE_MAX; i++) { - _vFrameRates.push_back(FrameRate((int)i)); - } + for (size_t i = 0; i < dsVIDEOPORT_TYPE_MAX; i++) { + _vPortTypes.push_back(VideoOutputPortType((int)i)); + } - for (size_t i = 0; i < dsVIDEOPORT_TYPE_MAX; i++) { - _vPortTypes.push_back(VideoOutputPortType((int)i)); - } + INT_INFO("Using '%s' config", dynamicVideoPortConfigs ? "dynamic" : "static"); + if ( nullptr != dynamicVideoPortConfigs ) + { + configuration = *dynamicVideoPortConfigs; + configSize = (configuration.pKVideoPortConfigs_size) ? *(configuration.pKVideoPortConfigs_size) : -1; + portSize = (configuration.pKVideoPortPorts_size) ? *(configuration.pKVideoPortPorts_size) : -1; + resolutionSize = (configuration.pKResolutionsSettings_size) ? *(configuration.pKResolutionsSettings_size) : -1; + } + else { + configuration.pKConfigs = kConfigs; + configSize = dsUTL_DIM(kConfigs); + configuration.pKVideoPortConfigs_size = &configSize; + configuration.pKPorts = kPorts; + portSize = dsUTL_DIM(kPorts); + configuration.pKVideoPortPorts_size = &portSize; + configuration.pKResolutionsSettings = kResolutions; + resolutionSize = dsUTL_DIM(kResolutions); + configuration.pKResolutionsSettings_size = &resolutionSize; + } - if (nullptr != pDLHandle) { - const char* searchVaribles[] = { - "kVideoPortConfigs", - "kVideoPortConfigs_size", - "kVideoPortPorts", - "kVideoPortPorts_size", - "kResolutionsSettings", - "kResolutionsSettings_size" - }; - bool ret = false; - - INT_INFO("%d:%s: Using dynamic library handle for config loading\n", __LINE__, __func__); - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]); - ret = searchConfigs(pDLHandle, searchVaribles[0], (void **)&configuration.pKConfigs); - if(ret == true) - { - // Considering Dynamic config loading is enabled since 1st symbol got - isDynamicConfigLoad = true; - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]); - ret = searchConfigs(pDLHandle, searchVaribles[1], (void **)&configuration.pKVideoPortConfigs_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[1]); - configuration.pKVideoPortConfigs_size = &invalid_size; - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]); - ret = searchConfigs(pDLHandle, searchVaribles[2], (void **)&configuration.pKPorts); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[2]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]); - ret = searchConfigs(pDLHandle, searchVaribles[3], (void **)&configuration.pKVideoPortPorts_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[3]); - configuration.pKVideoPortPorts_size = &invalid_size; - } - // Resolutions - ret = searchConfigs(pDLHandle, searchVaribles[4], (void **)&configuration.pKResolutionsSettings); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[4]); - } - INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[5]); - ret = searchConfigs(pDLHandle, searchVaribles[5], (void **)&configuration.pKResolutionsSettings_size); - if(ret == false) - { - INT_ERROR("%s is not defined\n", searchVaribles[5]); - configuration.pKResolutionsSettings_size = &invalid_size; + INT_INFO("VideoPort Config[%p] ConfigSize[%d] Port[%p] PortSize[%d] Resolutions[%p] ResolutionsSize[%d]", + configuration.pKConfigs, + configSize, + configuration.pKPorts, + portSize, + configuration.pKResolutionsSettings, + resolutionSize); + + dumpconfig(&configuration); + + if (( nullptr != configuration.pKConfigs ) && ( nullptr != configuration.pKPorts) && ( nullptr != configuration.pKResolutionsSettings)) + { + /* Initialize a set of supported resolutions */ + for (int i = 0; i < resolutionSize; i++) { + dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); + {std::lock_guard lock(gSupportedResolutionsMutex); + if (nullptr == resolution->name) { + INT_ERROR("resolution name is NULL at %d, using empty string...", i); + } + _supportedResolutions.push_back( + VideoResolution( + i, /* id */ + (resolution->name) ? std::string(resolution->name) : std::string(""), + resolution->pixelResolution, + resolution->aspectRatio, + resolution->stereoScopicMode, + resolution->frameRate, + resolution->interlaced)); } } - } - - if ( false == isDynamicConfigLoad ) - { - INT_INFO("%d:%s: Using OLD config loading\n", __LINE__, __func__); - configuration.pKConfigs = kConfigs; - configSize = dsUTL_DIM(kConfigs); - configuration.pKVideoPortConfigs_size = &configSize; - configuration.pKPorts = kPorts; - portSize = dsUTL_DIM(kPorts); - configuration.pKVideoPortPorts_size = &portSize; - configuration.pKResolutionsSettings = kResolutions; - resolutionSize = dsUTL_DIM(kResolutions); - configuration.pKResolutionsSettings_size = &resolutionSize; - INT_INFO("configuration.pKConfigs =%p, *(configuration.pKVideoPortConfigs_size) = %d\n", configuration.pKConfigs, *(configuration.pKVideoPortConfigs_size)); - INT_INFO("configuration.pKPorts =%p, *(configuration.pKVideoPortPorts_size) = %d\n", configuration.pKPorts, *(configuration.pKVideoPortPorts_size)); - INT_INFO("configuration.pKResolutionsSettings =%p, *(configuration.pKResolutionsSettings_size) = %d\n", configuration.pKResolutionsSettings, *(configuration.pKResolutionsSettings_size)); - } - - if((configuration.pKConfigs != NULL) && (configuration.pKVideoPortConfigs_size != NULL) && - (configuration.pKPorts != NULL) && (configuration.pKVideoPortPorts_size != NULL) && - (configuration.pKResolutionsSettings != NULL) && (configuration.pKResolutionsSettings_size != NULL)) - { - dumpconfig(&configuration); - /* Initialize a set of supported resolutions - * - */ - for (size_t i = 0; i < *(configuration.pKResolutionsSettings_size); i++) { - dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); - {std::lock_guard lock(gSupportedResolutionsMutex); - _supportedResolutions.push_back( - VideoResolution( - i, /* id */ - std::string(resolution->name), - resolution->pixelResolution, - resolution->aspectRatio, - resolution->stereoScopicMode, - resolution->frameRate, - resolution->interlaced)); - } - } - - - /* - * Initialize Video portTypes (Only Enable POrts) - * and its port instances (curr resolution) - */ - for (size_t i = 0; i < *(configuration.pKVideoPortConfigs_size); i++) - { - const dsVideoPortTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); - VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); - vPortType.enable(); - vPortType.setRestrictedResolution(typeCfg->restrictedResollution); - } - - /* - * set up ports based on kPorts[] - */ - for (size_t i = 0; i < *(configuration.pKVideoPortPorts_size); i++) { - const dsVideoPortPortConfig_t *port = &(configuration.pKPorts[i]); - _vPorts.push_back( - VideoOutputPort((port->id.type), port->id.index, i, - AudioOutputPortType::getInstance(configuration.pKPorts[i].connectedAOP.type).getPort(configuration.pKPorts[i].connectedAOP.index).getId(), - std::string(port->defaultResolution))); - - _vPortTypes.at(port->id.type).addPort(_vPorts.at(i)); + /* + * Initialize Video portTypes (Only Enable POrts) + * and its port instances (curr resolution) + */ + for (int i = 0; i < configSize; i++) + { + const dsVideoPortTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); + VideoOutputPortType &vPortType = VideoOutputPortType::getInstance(typeCfg->typeId); + vPortType.enable(); + vPortType.setRestrictedResolution(typeCfg->restrictedResollution); + } - } - } - else - { - cout << "Video Outport Configs or Ports or Resolutions is NULL. ..."<defaultResolution) { + INT_ERROR("defaultResolution is NULL at %d, using empty string...", i); + } + _vPorts.push_back( + VideoOutputPort((portCfg->id.type), portCfg->id.index, i, + AudioOutputPortType::getInstance(portCfg->connectedAOP.type).getPort(portCfg->connectedAOP.index).getId(), + (portCfg->defaultResolution) ? std::string(portCfg->defaultResolution) : std::string(""))); + _vPortTypes.at(portCfg->id.type).addPort(_vPorts.at(i)); + } + } + else + { + cout << "Video Outport Configs or Ports or Resolutions is NULL. ..."< #include +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKConfigs; + int *pKVideoPortConfigs_size; + const dsVideoPortPortConfig_t *pKPorts; + int *pKVideoPortPorts_size; + dsVideoPortResolution_t *pKResolutionsSettings; + int *pKResolutionsSettings_size; +}videoPortConfigs_t; + namespace device { class VideoOutputPortConfig { @@ -74,7 +80,7 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); - void load(void* pDLHandle); + void load(videoPortConfigs_t* pDLHandle); void release(); }; diff --git a/sample/dsMgr-test.c b/sample/dsMgr-test.c deleted file mode 100644 index 467a75ec..00000000 --- a/sample/dsMgr-test.c +++ /dev/null @@ -1,31 +0,0 @@ - -#include -#include -#include -#include -#include "exception.hpp" -#include "host.hpp" -#include "manager.hpp" - - -int main(int argc, char *argv[]) -{ - printf("%d:%s: enter\n", __LINE__, __func__); - try { - device::Manager::Initialize(); - } catch (const device::Exception& e) { - printf("Exception caught %s", e.what()); - } catch (const std::exception& e) { - printf("Exception caught %s", e.what()); - } catch (...) { - printf("Exception caught unknown"); - } - printf("%d:%s: Exit\n", __LINE__, __func__); - return 0; -} - - - - -/** @} */ -/** @} */ From 01776ad723ae8d894cca5fb5b831b37b8d08e154 Mon Sep 17 00:00:00 2001 From: yuvaramachandran_gurusamy Date: Fri, 12 Dec 2025 22:57:34 +0000 Subject: [PATCH 37/66] RDKEMW-8587: Fixed the coverity issues Signed-off-by: yuvaramachandran_gurusamy --- ds/audioOutputPortConfig.cpp | 10 +++++----- ds/videoDeviceConfig.cpp | 4 ++-- ds/videoOutputPortConfig.cpp | 16 ++++++---------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 66da8072..cac37ac4 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -228,21 +228,21 @@ void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) * Initialize Audio portTypes (encodings, compressions etc.) * and its port instances (db, level etc) */ - for (size_t i = 0; i < configSize; i++) { + for (int i = 0; i < configSize; i++) { const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]); AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId); aPortType.enable(); - for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) { + for (int j = 0; j < typeCfg->numSupportedEncodings; j++) { const dsAudioEncoding_t* encoding = &typeCfg->encodings[j]; aPortType.addEncoding(AudioEncoding::getInstance(*encoding)); _aEncodings.at(*encoding).enable(); } - for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) { + for (int j = 0; j < typeCfg->numSupportedCompressions; j++) { const dsAudioCompression_t* compression = &typeCfg->compressions[j]; aPortType.addCompression(*compression); _aCompressions.at(*compression).enable(); } - for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) { + for (int j = 0; j < typeCfg->numSupportedStereoModes; j++) { const dsAudioStereoMode_t *stereoMode = &typeCfg->stereoModes[j]; aPortType.addStereoMode(*stereoMode); _aStereoModes.at(*stereoMode).enable(); @@ -252,7 +252,7 @@ void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < portSize; i++) { + for (int i = 0; i < portSize; i++) { const dsAudioPortConfig_t *portCfg = &configuration.pKPorts[i]; _aPorts.push_back(AudioOutputPort((portCfg->id.type), portCfg->id.index, i)); _aPortTypes.at(portCfg->id.type).addPort(_aPorts.at(i)); diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 102e805b..290aa6cb 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -156,11 +156,11 @@ void VideoDeviceConfig::load(videoDeviceConfig_t* dynamicVideoDeviceConfigs) */ if ( nullptr != configuration.pKVideoDeviceConfigs ) { - for (size_t i = 0; i < configSize; i++) { + for (int i = 0; i < configSize; i++) { dsVideoConfig_t* videoDeviceCfg = &configuration.pKVideoDeviceConfigs[i]; _vDevices.push_back(VideoDevice(i)); - for (size_t j = 0; j < videoDeviceCfg->numSupportedDFCs; j++) { + for (int j = 0; j < videoDeviceCfg->numSupportedDFCs; j++) { _vDevices.at(i).addDFC(VideoDFC::getInstance(videoDeviceCfg->supportedDFCs[j])); } } diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 12cb54a8..9d27bd33 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -294,9 +294,9 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("Dumping Video Resolutions Settings"); - for (size_t i = 0; i < resolutionSize; i++) { + for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); - INT_INFO("resolution->name = %s", (resolution->name) ? resolution->name : "NULL"); + INT_INFO("resolution->name = %s", resolution->name); INT_INFO("resolution->pixelResolution= %d", resolution->pixelResolution); INT_INFO("resolution->aspectRatio= %d", resolution->aspectRatio); INT_INFO("resolution->stereoScopicMode= %d", resolution->stereoScopicMode); @@ -306,7 +306,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("Dumping Video Port Configurations"); - for (size_t i = 0; i < configSize; i++) + for (int i = 0; i < configSize; i++) { const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); @@ -328,7 +328,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("\n\n####################################################################### \n\n"); INT_INFO("Dumping Video Port Connections"); - for (size_t i = 0; i < portSize; i++) { + for (int i = 0; i < portSize; i++) { const dsVideoPortPortConfig_t *portCfg = &(config->pKPorts[i]); INT_INFO("portCfg->id.type = %d", portCfg->id.type); INT_INFO("portCfg->id.index = %d", portCfg->id.index); @@ -369,7 +369,6 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) for (size_t i = 0; i < dsVIDEO_FRAMERATE_MAX; i++) { _vFrameRates.push_back(FrameRate((int)i)); } - for (size_t i = 0; i < dsVIDEOPORT_TYPE_MAX; i++) { _vPortTypes.push_back(VideoOutputPortType((int)i)); } @@ -410,13 +409,10 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); {std::lock_guard lock(gSupportedResolutionsMutex); - if (nullptr == resolution->name) { - INT_ERROR("resolution name is NULL at %d, using empty string...", i); - } _supportedResolutions.push_back( VideoResolution( i, /* id */ - (resolution->name) ? std::string(resolution->name) : std::string(""), + std::string(resolution->name), resolution->pixelResolution, resolution->aspectRatio, resolution->stereoScopicMode, @@ -440,7 +436,7 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) /* * set up ports based on kPorts[] */ - for (size_t i = 0; i < portSize; i++) { + for (int i = 0; i < portSize; i++) { const dsVideoPortPortConfig_t *portCfg = &(configuration.pKPorts[i]); if (nullptr == portCfg->defaultResolution) { INT_ERROR("defaultResolution is NULL at %d, using empty string...", i); From 17564c6ae5d706496b14a50618ec4111543c164a Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 16 Dec 2025 11:48:58 +0000 Subject: [PATCH 38/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: Address review comments. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 9 ++++----- ds/frontPanelConfig.cpp | 15 ++++++--------- ds/manager.cpp | 3 ++- ds/videoDeviceConfig.cpp | 10 +++++----- ds/videoOutputPortConfig.cpp | 21 ++++++++++----------- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index cac37ac4..d163e43b 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -122,8 +122,7 @@ void dumpconfig(audioConfigs_t *config) } int configSize = -1, portSize = -1; - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("Starting to Dump Audio Configs"); + INT_INFO("\n\n====================================== Starting to Dump Audio Configs ===================================================================================\n\n"); if( nullptr != config->pKConfigs ) { configSize = (config->pKConfigSize) ? *(config->pKConfigSize) : -1; @@ -162,13 +161,13 @@ void dumpconfig(audioConfigs_t *config) { INT_ERROR("kAudioPorts is NULL"); } - INT_INFO("Dump Audio Configs done"); - INT_INFO("\n\n=========================================================================================================================\n\n"); + + INT_INFO("\n\n=================================================== Dump Audio Configs done ======================================================================\n\n"); } void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) { - int configSize = -1, portSize = -1; + static int configSize = -1, portSize = -1; audioConfigs_t configuration = {0}; INT_INFO("Enter function"); diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index c2feec6a..dcff37ee 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -43,8 +43,6 @@ #include "dslogger.h" #include "manager.hpp" -#define DEBUG 1 // Using for dumpconfig - using namespace std; namespace device { @@ -353,10 +351,10 @@ void dumpconfig(fpdConfigs_t *configuration) } int indicatorSize = -1; int indicatorColorSize = -1; - int textDisplaySize = (configuration->pKTextDisplays_size) ? *(configuration->pKTextDisplays_size) : -1; + // Dump the configuration details - INT_INFO("\n\n===========================================================================\n\n"); - INT_INFO("Starting to Dump FrontPanel Configs"); + INT_INFO("\n\n================================== Starting to Dump FrontPanel Configs =========================================\n\n"); + if (( nullptr != configuration->pKFPDIndicatorColors) && ( nullptr != configuration->pKIndicators)) { int indicatorSize = (configuration->pKIndicators_size) ? *(configuration->pKIndicators_size) : -1; @@ -394,15 +392,14 @@ void dumpconfig(fpdConfigs_t *configuration) fpdTextDisplayCfg->levels, fpdTextDisplayCfg->maxHorizontalIterations, fpdTextDisplayCfg->maxVerticalIterations, - (fpdTextDisplayCfg->supportedCharacters) ? fpdTextDisplayCfg->supportedCharacters : "NULL", + (fpdTextDisplayCfg->supportedCharacters) ? fpdTextDisplayCfg->supportedCharacters : DEFAULT_FPD_TEXT_DISPLAY_SUPPORTED_CHARACTERS, fpdTextDisplayCfg->colorMode); } } else { INT_INFO(" No Text Displays configured."); } - INT_INFO("Dump FrontPanel Configs done"); - INT_INFO("\n\n===========================================================================\n\n"); + INT_INFO("\n\n================================== Dump FrontPanel Configs done =========================================\n\n"); } /** @@ -419,7 +416,7 @@ void FrontPanelConfig::load(fpdConfigs_t* dynamicFPDConfigs) * 1. Create Supported Colors. * 2. Create Indicators. */ - int indicatorSize, indicatorColorSize, textDisplaySize; + static int indicatorSize, indicatorColorSize, textDisplaySize; fpdConfigs_t configuration = {0}; INT_INFO("Enter function"); if (( false == m_isFPInitialized) || (true == m_isFPConfigLoaded)) { diff --git a/ds/manager.cpp b/ds/manager.cpp index a5ac1216..d8ecc85f 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -273,7 +273,8 @@ void Manager::load() INT_INFO("Enter function"); loadDeviceCapabilities( device::DEVICE_CAPABILITY_VIDEO_PORT | device::DEVICE_CAPABILITY_AUDIO_PORT | - device::DEVICE_CAPABILITY_VIDEO_DEVICE); + device::DEVICE_CAPABILITY_VIDEO_DEVICE | + device::DEVICE_CAPABILITY_FRONT_PANEL); INT_INFO("Exit function"); } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 290aa6cb..4a36dba1 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -99,8 +99,8 @@ void dumpconfig(videoDeviceConfig_t *config) return; } - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("Starting to Dump VideoDevice Configs"); + INT_INFO("\n\n============================================== Starting to Dump VideoDevice Configs ===========================================================================\n\n"); + if( nullptr != config->pKVideoDeviceConfigs ) { int configSize = (config->pKVideoDeviceConfigs_size) ? *(config->pKVideoDeviceConfigs_size) : -1; @@ -118,13 +118,13 @@ void dumpconfig(videoDeviceConfig_t *config) { INT_ERROR(" kVideoDeviceConfigs is NULL"); } - INT_INFO("Dump VideoDevice Configs done"); - INT_INFO("\n\n=========================================================================================================================\n\n"); + + INT_INFO("\n\n===================================== Dump VideoDevice Configs done ====================================================================================\n\n"); } void VideoDeviceConfig::load(videoDeviceConfig_t* dynamicVideoDeviceConfigs) { - int configSize = -1; + static int configSize = -1; videoDeviceConfig_t configuration = {0}; INT_INFO("Enter function"); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 9d27bd33..4c35b1e5 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -277,8 +277,8 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("Dumping of Device configs is disabled"); return; } - INT_INFO("\n\n=========================================================================================================================\n\n"); - INT_INFO("Starting to Dump VideoPort Configs"); + INT_INFO("\n\n============================================== Starting to Dump VideoPort Configs ===========================================================================\n\n"); + int configSize = -1, portSize = -1, resolutionSize = -1; if (( nullptr != config->pKConfigs ) && ( nullptr != config->pKPorts ) && ( nullptr != config->pKResolutionsSettings )) { @@ -292,8 +292,8 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("pKResolutionsSettings = %p", config->pKResolutionsSettings); INT_INFO("pKResolutionsSettingsSize pointer %p = %d", config->pKResolutionsSettings_size, resolutionSize); - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("Dumping Video Resolutions Settings"); + INT_INFO("\n\n################################# Dumping Video Resolutions Settings ###################################### \n\n"); + for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); INT_INFO("resolution->name = %s", resolution->name); @@ -304,8 +304,8 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("resolution->interlaced= %d", resolution->interlaced); } INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("Dumping Video Port Configurations"); + INT_INFO("\n\n################################ Dumping Video Port Configurations ####################################### \n\n"); + for (int i = 0; i < configSize; i++) { const dsVideoPortTypeConfig_t *typeCfg = &(config->pKConfigs[i]); @@ -326,8 +326,8 @@ void dumpconfig(videoPortConfigs_t *config) } INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("Dumping Video Port Connections"); + INT_INFO("\n\n################################## Dumping Video Port Connections ##################################### \n\n"); + for (int i = 0; i < portSize; i++) { const dsVideoPortPortConfig_t *portCfg = &(config->pKPorts[i]); INT_INFO("portCfg->id.type = %d", portCfg->id.type); @@ -342,14 +342,13 @@ void dumpconfig(videoPortConfigs_t *config) { INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); } - INT_INFO("Dump VideoPort Configs done"); - INT_INFO("\n\n=========================================================================================================================\n\n"); + INT_INFO("\n\n============================================= Dump VideoPort Configs done ============================================================================\n\n"); INT_INFO("Exit function"); } void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) { - int configSize, portSize, resolutionSize; + static int configSize, portSize, resolutionSize; videoPortConfigs_t configuration = {0}; INT_INFO("Enter function"); From b8cdf9991c6129ebbebf0434836fe6c563d5b257 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 16 Dec 2025 16:46:06 +0000 Subject: [PATCH 39/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: Addressed review comments. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 13 +++---------- ds/audioOutputPortConfig.hpp | 2 +- ds/frontPanelConfig.cpp | 10 +++------- ds/include/frontPanelConfig.hpp | 2 +- ds/manager.cpp | 3 +-- ds/videoDeviceConfig.cpp | 6 +++--- ds/videoDeviceConfig.hpp | 2 +- ds/videoOutputPortConfig.cpp | 19 +++++++------------ ds/videoOutputPortConfig.hpp | 2 +- 9 files changed, 21 insertions(+), 38 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index d163e43b..aab6d682 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -122,14 +122,10 @@ void dumpconfig(audioConfigs_t *config) } int configSize = -1, portSize = -1; - INT_INFO("\n\n====================================== Starting to Dump Audio Configs ===================================================================================\n\n"); + INT_INFO("\n=============== Starting to Dump Audio Configs ===============\n"); if( nullptr != config->pKConfigs ) { configSize = (config->pKConfigSize) ? *(config->pKConfigSize) : -1; - INT_INFO("pKConfigs = %p", config->pKConfigs); - INT_INFO("pKPorts = %p", config->pKPorts); - INT_INFO("pKConfigSize addr =%p ", config->pKConfigSize); - INT_INFO("pKConfigSize value = %d ", configSize); for (int i = 0; i < configSize; i++) { const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]); @@ -148,9 +144,6 @@ void dumpconfig(audioConfigs_t *config) if( nullptr != config->pKPorts ) { portSize = (config->pKPortSize) ? *(config->pKPortSize) : -1; - INT_INFO("pKPorts = %p", config->pKPorts); - INT_INFO("pKPortSize addr = %p ", config->pKPortSize); - INT_INFO("pKPortSize value = %d ", portSize); for (int i = 0; i < portSize; i++) { const dsAudioPortConfig_t *portCfg = &(config->pKPorts[i]); INT_INFO("portCfg->id.type = %d", portCfg->id.type); @@ -162,12 +155,12 @@ void dumpconfig(audioConfigs_t *config) INT_ERROR("kAudioPorts is NULL"); } - INT_INFO("\n\n=================================================== Dump Audio Configs done ======================================================================\n\n"); + INT_INFO("\n=============== Dump Audio Configs done ===============\n"); } void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) { - static int configSize = -1, portSize = -1; + int configSize = -1, portSize = -1; audioConfigs_t configuration = {0}; INT_INFO("Enter function"); diff --git a/ds/audioOutputPortConfig.hpp b/ds/audioOutputPortConfig.hpp index b4a1acb3..54db385a 100644 --- a/ds/audioOutputPortConfig.hpp +++ b/ds/audioOutputPortConfig.hpp @@ -74,7 +74,7 @@ class AudioOutputPortConfig { List getPorts(); List getSupportedTypes(); - void load(audioConfigs_t* pDLHandle); + void load(audioConfigs_t* dynamicAudioConfigs); void release(); }; diff --git a/ds/frontPanelConfig.cpp b/ds/frontPanelConfig.cpp index dcff37ee..5d4d1030 100644 --- a/ds/frontPanelConfig.cpp +++ b/ds/frontPanelConfig.cpp @@ -353,17 +353,13 @@ void dumpconfig(fpdConfigs_t *configuration) int indicatorColorSize = -1; // Dump the configuration details - INT_INFO("\n\n================================== Starting to Dump FrontPanel Configs =========================================\n\n"); + INT_INFO("\n=============== Starting to Dump FrontPanel Configs ===============\n"); if (( nullptr != configuration->pKFPDIndicatorColors) && ( nullptr != configuration->pKIndicators)) { int indicatorSize = (configuration->pKIndicators_size) ? *(configuration->pKIndicators_size) : -1; int indicatorColorSize = (configuration->pKFPDIndicatorColors_size) ? *(configuration->pKFPDIndicatorColors_size) : -1; - INT_INFO("configuration->pKFPDIndicatorColors_size addr: %p", (configuration->pKFPDIndicatorColors_size)); - INT_INFO("configuration->pKFPDIndicatorColors_size data: %d", indicatorColorSize); - INT_INFO("configuration->pKIndicators_size addr: %p", (configuration->pKIndicators_size)); - INT_INFO("configuration->pKIndicators_size data: %d", indicatorSize); for (int i = 0; i < indicatorColorSize; i++) { const dsFPDColorConfig_t* fpdColorCfg = &configuration->pKFPDIndicatorColors[i]; INT_INFO(" Color ID: %d, color: %d", fpdColorCfg->id, fpdColorCfg->color); @@ -399,7 +395,7 @@ void dumpconfig(fpdConfigs_t *configuration) else { INT_INFO(" No Text Displays configured."); } - INT_INFO("\n\n================================== Dump FrontPanel Configs done =========================================\n\n"); + INT_INFO("\n=============== Dump FrontPanel Configs done ===============\n"); } /** @@ -416,7 +412,7 @@ void FrontPanelConfig::load(fpdConfigs_t* dynamicFPDConfigs) * 1. Create Supported Colors. * 2. Create Indicators. */ - static int indicatorSize, indicatorColorSize, textDisplaySize; + int indicatorSize, indicatorColorSize, textDisplaySize; fpdConfigs_t configuration = {0}; INT_INFO("Enter function"); if (( false == m_isFPInitialized) || (true == m_isFPConfigLoaded)) { diff --git a/ds/include/frontPanelConfig.hpp b/ds/include/frontPanelConfig.hpp index 74df3b32..a85d4c0f 100644 --- a/ds/include/frontPanelConfig.hpp +++ b/ds/include/frontPanelConfig.hpp @@ -96,7 +96,7 @@ class FrontPanelConfig { /* Terminate Front Panel */ void fPTerm(); - void load(fpdConfigs_t* pDLHandle); + void load(fpdConfigs_t* dynamicFPDConfigs); }; } diff --git a/ds/manager.cpp b/ds/manager.cpp index d8ecc85f..a5ac1216 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -273,8 +273,7 @@ void Manager::load() INT_INFO("Enter function"); loadDeviceCapabilities( device::DEVICE_CAPABILITY_VIDEO_PORT | device::DEVICE_CAPABILITY_AUDIO_PORT | - device::DEVICE_CAPABILITY_VIDEO_DEVICE | - device::DEVICE_CAPABILITY_FRONT_PANEL); + device::DEVICE_CAPABILITY_VIDEO_DEVICE); INT_INFO("Exit function"); } diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index 4a36dba1..fab33f59 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -99,7 +99,7 @@ void dumpconfig(videoDeviceConfig_t *config) return; } - INT_INFO("\n\n============================================== Starting to Dump VideoDevice Configs ===========================================================================\n\n"); + INT_INFO("\n=============== Starting to Dump VideoDevice Configs ===============\n"); if( nullptr != config->pKVideoDeviceConfigs ) { @@ -119,12 +119,12 @@ void dumpconfig(videoDeviceConfig_t *config) INT_ERROR(" kVideoDeviceConfigs is NULL"); } - INT_INFO("\n\n===================================== Dump VideoDevice Configs done ====================================================================================\n\n"); + INT_INFO("\n=============== Dump VideoDevice Configs done ===============\n"); } void VideoDeviceConfig::load(videoDeviceConfig_t* dynamicVideoDeviceConfigs) { - static int configSize = -1; + int configSize = -1; videoDeviceConfig_t configuration = {0}; INT_INFO("Enter function"); diff --git a/ds/videoDeviceConfig.hpp b/ds/videoDeviceConfig.hpp index 71a42a96..c6b0659d 100644 --- a/ds/videoDeviceConfig.hpp +++ b/ds/videoDeviceConfig.hpp @@ -61,7 +61,7 @@ class VideoDeviceConfig { VideoDFC & getDFC(int id); VideoDFC & getDefaultDFC(); - void load(videoDeviceConfig_t* pDLHandle); + void load(videoDeviceConfig_t* dynamicVideoDeviceConfigs); void release(); }; diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 4c35b1e5..64759527 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -51,8 +51,6 @@ #include using namespace std; -#define DEBUG 1 // Using for dumpconfig - namespace device { static VideoResolution* defaultVideoResolution; @@ -277,7 +275,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("Dumping of Device configs is disabled"); return; } - INT_INFO("\n\n============================================== Starting to Dump VideoPort Configs ===========================================================================\n\n"); + INT_INFO("\n=============== Starting to Dump VideoPort Configs ===============\n"); int configSize = -1, portSize = -1, resolutionSize = -1; if (( nullptr != config->pKConfigs ) && ( nullptr != config->pKPorts ) && ( nullptr != config->pKResolutionsSettings )) @@ -292,7 +290,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("pKResolutionsSettings = %p", config->pKResolutionsSettings); INT_INFO("pKResolutionsSettingsSize pointer %p = %d", config->pKResolutionsSettings_size, resolutionSize); - INT_INFO("\n\n################################# Dumping Video Resolutions Settings ###################################### \n\n"); + INT_INFO("\n\n############### Dumping Video Resolutions Settings ############### \n\n"); for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(config->pKResolutionsSettings[i]); @@ -303,8 +301,8 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("resolution->frameRate= %d", resolution->frameRate); INT_INFO("resolution->interlaced= %d", resolution->interlaced); } - INT_INFO("\n\n####################################################################### \n\n"); - INT_INFO("\n\n################################ Dumping Video Port Configurations ####################################### \n\n"); + + INT_INFO("\n ############### Dumping Video Port Configurations ############### \n"); for (int i = 0; i < configSize; i++) { @@ -324,9 +322,7 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); } - INT_INFO("\n\n####################################################################### \n\n"); - - INT_INFO("\n\n################################## Dumping Video Port Connections ##################################### \n\n"); + INT_INFO("\n############### Dumping Video Port Connections ###############\n"); for (int i = 0; i < portSize; i++) { const dsVideoPortPortConfig_t *portCfg = &(config->pKPorts[i]); @@ -336,19 +332,18 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("portCfg->connectedAOP.index = %d", portCfg->connectedAOP.index); INT_INFO("portCfg->defaultResolution = %s", (portCfg->defaultResolution) ? portCfg->defaultResolution : "NULL"); } - INT_INFO("\n\n####################################################################### \n\n"); } else { INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); } - INT_INFO("\n\n============================================= Dump VideoPort Configs done ============================================================================\n\n"); + INT_INFO("\n=============== Dump VideoPort Configs done ===============\n"); INT_INFO("Exit function"); } void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) { - static int configSize, portSize, resolutionSize; + int configSize, portSize, resolutionSize; videoPortConfigs_t configuration = {0}; INT_INFO("Enter function"); diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index 435b7b41..b8047c3e 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -80,7 +80,7 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); - void load(videoPortConfigs_t* pDLHandle); + void load(videoPortConfigs_t* dynamicVideoPortConfigs); void release(); }; From 898b0bbcbc5e16bd1c5f4bcf2e881b8ef037c8af Mon Sep 17 00:00:00 2001 From: apatel859 Date: Thu, 8 Jan 2026 19:54:01 +0000 Subject: [PATCH 40/66] 1.0.26 release change log updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5dc9e7c..fe1d704f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.26](https://github.com/rdkcentral/devicesettings/compare/1.0.25...1.0.26) + +- RDKEMW-11168, RDKEMW-4848: pass the proper handle to dsEnableHDCP [`#182`](https://github.com/rdkcentral/devicesettings/pull/182) +- Merge tag '1.0.25' into develop [`ce8af83`](https://github.com/rdkcentral/devicesettings/commit/ce8af8303729b6a01fe4d8240de74fe365cdafe4) + #### [1.0.25](https://github.com/rdkcentral/devicesettings/compare/1.0.24...1.0.25) +> 20 November 2025 + - Feature/rdkemw 7496 [`#134`](https://github.com/rdkcentral/devicesettings/pull/134) +- 1.0.25 release change log updates [`75b7563`](https://github.com/rdkcentral/devicesettings/commit/75b7563fc461eeaa31bd68140f29ccf0900a6655) - Merge tag '1.0.24' into develop [`4e94421`](https://github.com/rdkcentral/devicesettings/commit/4e94421d193d4d5e7dea28ccf49198c7dc2bf1d4) #### [1.0.24](https://github.com/rdkcentral/devicesettings/compare/1.0.23...1.0.24) From 5dd27d7b49abd23da7e1baadc1f28e565b6f1c44 Mon Sep 17 00:00:00 2001 From: kiruba115 Date: Mon, 12 Jan 2026 16:17:24 -0500 Subject: [PATCH 41/66] RDKEMW-11232 getAudioFormatApi issue on Xione-UK (#188) * RDKEMW-11232 getAudioFormatApi issue on Xione-UK * Add priority-based audio output port selection Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: apatel859 <48992974+apatel859@users.noreply.github.com> --- ds/host.cpp | 51 ++++++++++++++++++++++++++++++++-- ds/include/audioOutputPort.hpp | 1 + ds/include/host.hpp | 1 + rpc/srv/dsAudio.c | 9 ++++-- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/ds/host.cpp b/ds/host.cpp index e2475e14..aae3453b 100644 --- a/ds/host.cpp +++ b/ds/host.cpp @@ -385,6 +385,53 @@ Host::~Host() return std::string(socID); } + intptr_t Host::getAudioPortHandle() + { + try + { + if (isHDMIOutPortPresent()) + { + //STB profile with single audio output port + AudioOutputPort aPort = getAudioOutputPort("HDMI0"); + return aPort.getOutputPortHandle(); + } + else + { + //TV profile with multiple audio output ports + // First check the ports which are dynamically conected and finally fallback to SPEAKER0 which is always connected. + const std::string audio_ports[] = {"HDMI_ARC0", "HEADPHONE0", "SPDIF0", "SPEAKER0"}; + + // Try each port in priority order + for (const auto& portName : audio_ports) + { + try + { + AudioOutputPort aPort = getAudioOutputPort(portName); + cout << "Checking audio port: " << portName << " isEnabled: " << aPort.isEnabled() << " isConnected: " << aPort.isConnected() << "\n"; + // Check if port is enabled and connected + if (aPort.isEnabled() && aPort.isConnected()) + { + cout << "Using audio port: " << portName << "\n"; + return aPort.getOutputPortHandle(); + } + } + catch(const std::exception& e) + { + // Port not found or error accessing it, log and continue to next port + cout << "Exception while accessing audio port " << portName << ": " << e.what() << "\n"; + continue; + } + } + } + } + catch(const std::exception& e) + { + cout << " Exception Thrown in getAudioPortHandle().. returning NULL...: " << e.what() << "\n"; + } + + return NULL; + } + /** * Host::getCurrentAudioFormat(dsAudioFormat_t &audioFormat) * @brief @@ -397,8 +444,8 @@ Host::~Host() { dsError_t ret = dsERR_NONE; dsAudioFormat_t aFormat; - - ret = dsGetAudioFormat(NULL, &aFormat); + intptr_t audioPortHandle = getAudioPortHandle(); + ret = dsGetAudioFormat(audioPortHandle, &aFormat); if (ret == dsERR_NONE) { diff --git a/ds/include/audioOutputPort.hpp b/ds/include/audioOutputPort.hpp index 9dec5126..0d050ffd 100644 --- a/ds/include/audioOutputPort.hpp +++ b/ds/include/audioOutputPort.hpp @@ -93,6 +93,7 @@ class AudioOutputPort : public Enumerable { const AudioOutputPortType & getType() const; int getId() const {return _id;}; int getIndex() const {return _index; }; + intptr_t getOutputPortHandle() const { return _handle;}; /** diff --git a/ds/include/host.hpp b/ds/include/host.hpp index 02adbfa8..a6a9ce53 100644 --- a/ds/include/host.hpp +++ b/ds/include/host.hpp @@ -431,6 +431,7 @@ class Host { void setSecondaryLanguage(const std::string sLang); void getSecondaryLanguage(std::string& sLang); bool isHDMIOutPortPresent(); + intptr_t getAudioPortHandle(); std::string getDefaultVideoPortName(); std::string getDefaultAudioPortName(); void getCurrentAudioFormat(dsAudioFormat_t& audioFormat); diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index 7d085ffd..e08428a5 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -3707,12 +3707,17 @@ IARM_Result_t _dsGetAudioFormat(void *arg) { dsAudioFormat_t aFormat = dsAUDIO_FORMAT_NONE; param->audioFormat = dsAUDIO_FORMAT_NONE; - - if (func(param->handle, &aFormat) == dsERR_NONE) + dsError_t ret = dsERR_NONE; + ret = func(param->handle, &aFormat); + if (ret == dsERR_NONE) { param->audioFormat = aFormat; result = IARM_RESULT_SUCCESS; } + else + { + INT_INFO("%s dsGetAudioFormat failed ret=%d\n",__FUNCTION__, ret); + } } IARM_BUS_Unlock(lock); From 6594764c3fde44fdb313576482cd7c2589fe1493 Mon Sep 17 00:00:00 2001 From: apatel859 Date: Mon, 12 Jan 2026 22:10:46 +0000 Subject: [PATCH 42/66] 1.0.27 release change log updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1d704f..c374a0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.27](https://github.com/rdkcentral/devicesettings/compare/1.0.26...1.0.27) + +- RDKEMW-11232 getAudioFormatApi issue on Xione-UK [`#188`](https://github.com/rdkcentral/devicesettings/pull/188) +- Merge tag '1.0.26' into develop [`62858d9`](https://github.com/rdkcentral/devicesettings/commit/62858d954e5871070b4e0433c9e06abaf8ff97d1) + #### [1.0.26](https://github.com/rdkcentral/devicesettings/compare/1.0.25...1.0.26) +> 8 January 2026 + - RDKEMW-11168, RDKEMW-4848: pass the proper handle to dsEnableHDCP [`#182`](https://github.com/rdkcentral/devicesettings/pull/182) +- 1.0.26 release change log updates [`898b0bb`](https://github.com/rdkcentral/devicesettings/commit/898b0bbcbc5e16bd1c5f4bcf2e881b8ef037c8af) - Merge tag '1.0.25' into develop [`ce8af83`](https://github.com/rdkcentral/devicesettings/commit/ce8af8303729b6a01fe4d8240de74fe365cdafe4) #### [1.0.25](https://github.com/rdkcentral/devicesettings/compare/1.0.24...1.0.25) From 8f0dd0f25d30cb022fc0fc90f1c07fa85ad0be18 Mon Sep 17 00:00:00 2001 From: dkumar798 Date: Tue, 13 Jan 2026 08:08:57 +0530 Subject: [PATCH 43/66] RDKEMW-12054: Fix Coverity identified issues (#190) * RDKEMW-12054: Fix Coverity identified issues --- ds/audioOutputPort.cpp | 8 ++++---- ds/edid-parser.cpp | 3 --- ds/hdmiIn.cpp | 2 +- ds/include/exception.hpp | 2 +- ds/manager.cpp | 18 +++++++++++++----- ds/videoDevice.cpp | 2 +- rpc/cli/dsVideoPort.c | 4 ++-- rpc/srv/dsAudio.c | 15 ++++++++++++--- sample/testFrontPanel.cpp | 7 ++++++- 9 files changed, 40 insertions(+), 21 deletions(-) mode change 100755 => 100644 sample/testFrontPanel.cpp diff --git a/ds/audioOutputPort.cpp b/ds/audioOutputPort.cpp index e5c8fabc..2d5fde04 100644 --- a/ds/audioOutputPort.cpp +++ b/ds/audioOutputPort.cpp @@ -131,7 +131,7 @@ AudioOutputPort::AudioOutputPort(const int type, const int index, const int id) out << getType().getName() << _index; _name = out.str(); } - printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%d\n", _type, _index, _handle); + printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%ld\n", _type, _index, (long)_handle); if (dsERR_NONE == ret) { //dsGetAudioCompression (_handle, (dsAudioCompression_t *)&_compression); dsGetAudioEncoding (_handle, (dsAudioEncoding_t *)&_encoding); @@ -184,7 +184,7 @@ dsError_t AudioOutputPort::reInitializeAudioOutputPort() _name = out.str(); } - printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%d\n", _type, _index, _handle); + printf ("\nAudioOutputPort init: _type:%d _index:%d _handle:%ld\n", _type, _index,(long)_handle); if (dsERR_NONE == ret) { //dsGetAudioCompression>(_handle, (dsAudioCompression_t *)&_compression); dsGetAudioEncoding(_handle, (dsAudioEncoding_t *)&_encoding); @@ -1422,11 +1422,11 @@ void AudioOutputPort::setAudioDelay(const uint32_t audioDelayMs) dsError_t ret = dsERR_NONE; uint32_t ms = audioDelayMs; - INT_INFO("AudioOutputPort [%s], setting delay to [%lu] ms\n", _name.c_str(), audioDelayMs); + INT_INFO("AudioOutputPort [%s], setting delay to [%u] ms\n", _name.c_str(), audioDelayMs); if (ms > audioDelayMsMax) { - INT_ERROR("AudioOutputPort [%s], delay [%lu] ms, exceeds max [%lu]. Setting Max \n", + INT_ERROR("AudioOutputPort [%s], delay [%u] ms, exceeds max [%u]. Setting Max \n", _name.c_str(), audioDelayMs, audioDelayMsMax); diff --git a/ds/edid-parser.cpp b/ds/edid-parser.cpp index 728a735c..9d51077c 100644 --- a/ds/edid-parser.cpp +++ b/ds/edid-parser.cpp @@ -55,7 +55,6 @@ static void parse_std_timing(unsigned char* bytes, edid_data_t* data_ptr) { case 1: v = (h * 3) / 4; break; case 2: v = (h * 4) / 5; break; case 3: v = (h * 9) / 16; break; - default: return; } int r = (bytes[idx + 1] & 0x3F) + 60; INT_DEBUG("STD %dx%d@%d\n", h, v, r); @@ -381,8 +380,6 @@ static void parse_ext_timing(unsigned char* bytes, edid_data_t* data_ptr) { case 6: break; // 'Use Extended Tag' case 7: parse_extended_db(&bytes[idx], data_ptr); break; - // default - unsupported - default: INT_DEBUG("Unsupported extension tag: 0x%X\n", tag); } idx += len + 1; } diff --git a/ds/hdmiIn.cpp b/ds/hdmiIn.cpp index 514cff14..f107bba0 100755 --- a/ds/hdmiIn.cpp +++ b/ds/hdmiIn.cpp @@ -528,7 +528,7 @@ void HdmiInput::getHDMISPDInfo (int iHdmiPort, std::vector &data) { data.clear(); if (ret == dsERR_NONE) { if (sizeof(spdinfo) <= sizeof(struct dsSpd_infoframe_st)) { - printf("HdmiInput::getHDMISPDInfo has %d bytes\r\n", sizeof(spdinfo)); + printf("HdmiInput::getHDMISPDInfo has %zu bytes\r\n", sizeof(spdinfo)); data.insert(data.begin(), spdinfo, spdinfo + sizeof(struct dsSpd_infoframe_st)); } else { ret = dsERR_OPERATION_NOT_SUPPORTED; diff --git a/ds/include/exception.hpp b/ds/include/exception.hpp index 463435c7..bbb9836e 100644 --- a/ds/include/exception.hpp +++ b/ds/include/exception.hpp @@ -64,7 +64,7 @@ class Exception : public std::exception { * * @return None */ - Exception(const char *msg = "No Message for this exception") throw() : _msg(msg) { + Exception(const char *msg = "No Message for this exception") throw() : _err(0), _msg(msg) { } diff --git a/ds/manager.cpp b/ds/manager.cpp index eedcd8b2..bd18233e 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -105,11 +105,18 @@ Manager::~Manager() { */ void Manager::Initialize() { + bool needInit = false; + {std::lock_guard lock(gManagerInitMutex); - printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + if (IsInitialized == 0) { + needInit = true; + } + IsInitialized++; + } try { - if (0 == IsInitialized) { + if (needInit) { dsError_t err = dsERR_GENERAL; unsigned int retryCount = 0; @@ -134,14 +141,15 @@ void Manager::Initialize() AudioOutputPortConfig::getInstance().load(); VideoOutputPortConfig::getInstance().load(); VideoDeviceConfig::getInstance().load(); - } - IsInitialized++; + } } catch(const Exception &e) { cout << "Caught exception during Initialization" << e.what() << endl; + std::lock_guard lock(gManagerInitMutex); + IsInitialized--; throw e; } - } + printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); } diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 37452a0c..88726d9d 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -101,7 +101,7 @@ VideoDevice & VideoDevice::getInstance(int id) * @param[in] id Port id. * @return None. */ -VideoDevice::VideoDevice(int id) +VideoDevice::VideoDevice(int id): _dfc(0) { dsError_t ret = dsGetVideoDevice(id, &_handle); diff --git a/rpc/cli/dsVideoPort.c b/rpc/cli/dsVideoPort.c index 5ff4c9e4..d8e15541 100644 --- a/rpc/cli/dsVideoPort.c +++ b/rpc/cli/dsVideoPort.c @@ -82,7 +82,7 @@ dsError_t dsGetVideoPort(dsVideoPortType_t type, int index, intptr_t *handle) ¶m, sizeof(param)); - printf("%s..%d-%d\n",__func__,param.type,param.handle); + printf("%s..%d-%ld\n",__func__,param.type,(long)param.handle); if (IARM_RESULT_SUCCESS == rpcRet) { @@ -530,7 +530,7 @@ dsError_t dsEnableHDCP(intptr_t handle, bool contentProtect, char *hdcpKey, siz } } - printf("IARM:CLI:dsEnableHDCP %d, %p, %d\r\n", contentProtect, hdcpKey, keySize); + printf("IARM:CLI:dsEnableHDCP %d, %p, %zu\r\n", contentProtect, hdcpKey, keySize); IARM_Result_t rpcRet = IARM_RESULT_SUCCESS; rpcRet = IARM_Bus_Call(IARM_BUS_DSMGR_NAME, diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index e08428a5..40d696f7 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -1624,7 +1624,7 @@ void AudioConfigInit() m_volumeLeveller.level = atoi(_volLevellerLevel.c_str()); //SPEAKER init handle = 0; - INT_DEBUG("bDolbyVolumeOverrideCheck value: %d\n", bDolbyVolumeOverrideCheck); + INT_DEBUG("bDolbyVolumeOverrideCheck value: %d\n", (int)bDolbyVolumeOverrideCheck); if(bDolbyVolumeOverrideCheck && dsGetAudioPort(dsAUDIOPORT_TYPE_SPEAKER,0,&handle) == dsERR_NONE) { if (dsSetVolumeLevellerFunc(handle, m_volumeLeveller) == dsERR_NONE) { INT_INFO("Port %s: Initialized Volume Leveller : Mode: %d, Level: %d\n","SPEAKER0", m_volumeLeveller.mode, m_volumeLeveller.level); @@ -2357,10 +2357,18 @@ IARM_Result_t dsAudioMgr_init() IARM_Result_t dsAudioMgr_term() { #ifdef DS_AUDIO_SETTINGS_PERSISTENCE - if(persist_audioLevel_timer_threadIsAlive){ + bool shouldJoin = false; + pthread_t threadId; + IARM_BUS_Lock(lock); + shouldJoin = persist_audioLevel_timer_threadIsAlive; + if(shouldJoin){ persist_audioLevel_timer_threadIsAlive=false; + threadId = persist_audioLevel_timer_threadId; pthread_cond_signal(&audioLevelTimerCV); - pthread_join(persist_audioLevel_timer_threadId,NULL); + } + IARM_BUS_Unlock(lock); + if(shouldJoin){ + pthread_join(threadId,NULL); } #endif return IARM_RESULT_SUCCESS; @@ -7227,6 +7235,7 @@ static void* persist_audioLevel_timer_threadFunc(void* arg) { break; } // wait for 3 sec, then update the latest audio level from cache variable + /* coverity[sleep : FALSE] */ if(audioLevel_timer_set){ sleep(3); diff --git a/sample/testFrontPanel.cpp b/sample/testFrontPanel.cpp old mode 100755 new mode 100644 index b1bddee4..fec714bf --- a/sample/testFrontPanel.cpp +++ b/sample/testFrontPanel.cpp @@ -118,7 +118,12 @@ int main(int argc, char *argv[]) printf("Exception Caught during [%s]\r\n", argv[0]); } - device::Manager::DeInitialize(); + try { + device::Manager::DeInitialize(); + } + catch (...) { + printf("Unknown exception during DeInitialize\n"); + } IARM_Bus_Disconnect(); From f90a986f35eed33fdf6ac7338c6f4f454fb278ea Mon Sep 17 00:00:00 2001 From: kiruba115 Date: Tue, 13 Jan 2026 14:01:05 -0500 Subject: [PATCH 44/66] RDKEMW-9781: Video format issue on MTK (#199) * implement retry logic for dsVideoPortInit Enhance the retry mechanism for AudioPort and VideoDeviceInit as well --- ds/manager.cpp | 92 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 31 deletions(-) diff --git a/ds/manager.cpp b/ds/manager.cpp index bd18233e..f94b9da1 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -43,6 +43,7 @@ #include "exception.hpp" #include #include +#include /** * @file manager.cpp @@ -62,6 +63,7 @@ namespace device { int Manager::IsInitialized = 0; //!< Indicates the application has initialized with devicettings modules. static std::mutex gManagerInitMutex; +static dsError_t initializeFunctionWithRetry(const char* functionName, std::function initFunc); Manager::Manager() { // TODO Auto-generated constructor stub @@ -79,6 +81,41 @@ Manager::~Manager() { }\ } +/** + * @brief Retry initialization function with configurable retry logic. + * + * This helper function attempts to initialize a device settings component by calling + * the provided initialization function. It retries the operation with a delay between + * attempts until either the operation succeeds, the maximum retry count is reached, + * or (optionally) a specific error state is encountered. + * + * @param[in] functionName Name of the initialization function being called. Used for logging + * purposes to identify which component is being initialized. + * @param[in] initFunc Lambda or function object that performs the actual initialization. + * Should return dsError_t indicating success (dsERR_NONE) or an error code. + * + * @return dsERR_NONE on successful initialization, or the last error code encountered after + * all retry attempts are exhausted. When checkInvalidState is true, also returns + * immediately with the error code if a non-dsERR_INVALID_STATE error occurs. + */ +dsError_t initializeFunctionWithRetry(const char* functionName, + std::function initFunc) +{ + dsError_t err = dsERR_GENERAL; + unsigned int retryCount = 0; + unsigned int maxRetries = 25; + + do { + err = initFunc(); + printf("Manager::Initialize:%s result :%d retryCount :%d\n", + functionName, err, retryCount); + if (dsERR_NONE == err) break; + usleep(100000); + } while (retryCount++ < maxRetries); + + return err; +} + /** * @addtogroup dssettingsmanagerapi * @{ @@ -107,50 +144,43 @@ void Manager::Initialize() { bool needInit = false; - {std::lock_guard lock(gManagerInitMutex); + {std::lock_guard lock(gManagerInitMutex); printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); - if (IsInitialized == 0) { + if (IsInitialized == 0) { needInit = true; } IsInitialized++; - } + } - try { - if (needInit) { - - dsError_t err = dsERR_GENERAL; - unsigned int retryCount = 0; - // This retry logic will wait for the device manager initialization from the client side - // until the device manager service initialization is completed. The retry mechanism checks - // only for dsERR_INVALID_STATE, which is reported if the underlying service is not ready. - // Once the service is ready, other port initializations can be called directly without any delay. - // That's why the retry logic is applied only for dsDisplayInit. - do { - err = dsDisplayInit(); - printf ("Manager::Initialize: result :%d retryCount :%d\n", err, retryCount); - if (dsERR_NONE == err) break; - usleep(100000); - } while(( dsERR_INVALID_STATE == err) && (retryCount++ < 25)); + try { + if (needInit) { + dsError_t err = dsERR_GENERAL; + + err = initializeFunctionWithRetry("dsDisplayInit", dsDisplayInit); + CHECK_RET_VAL(err); + + err = initializeFunctionWithRetry("dsAudioPortInit", dsAudioPortInit); CHECK_RET_VAL(err); - err = dsAudioPortInit(); + + err = initializeFunctionWithRetry("dsVideoPortInit", dsVideoPortInit); CHECK_RET_VAL(err); - err = dsVideoPortInit(); + + err = initializeFunctionWithRetry("dsVideoDeviceInit", dsVideoDeviceInit); CHECK_RET_VAL(err); - err = dsVideoDeviceInit(); - CHECK_RET_VAL(err); - AudioOutputPortConfig::getInstance().load(); - VideoOutputPortConfig::getInstance().load(); - VideoDeviceConfig::getInstance().load(); - } + + AudioOutputPortConfig::getInstance().load(); + VideoOutputPortConfig::getInstance().load(); + VideoDeviceConfig::getInstance().load(); + } } catch(const Exception &e) { - cout << "Caught exception during Initialization" << e.what() << endl; + cout << "Caught exception during Initialization" << e.what() << endl; std::lock_guard lock(gManagerInitMutex); IsInitialized--; - throw e; - } + throw e; + } - printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); + printf("Exiting %s with thread %lu\n",__FUNCTION__,pthread_self()); } void Manager::load() From f11f7de47304fbf0a8669d1894c243dc86c76e02 Mon Sep 17 00:00:00 2001 From: apatel859 Date: Tue, 13 Jan 2026 19:24:00 +0000 Subject: [PATCH 45/66] 1.0.28 release change log updates --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c374a0ec..864cb2a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.28](https://github.com/rdkcentral/devicesettings/compare/1.0.27...1.0.28) + +- RDKEMW-9781: Video format issue on MTK [`#199`](https://github.com/rdkcentral/devicesettings/pull/199) +- RDKEMW-12054: Fix Coverity identified issues [`#190`](https://github.com/rdkcentral/devicesettings/pull/190) +- Merge tag '1.0.27' into develop [`56fabff`](https://github.com/rdkcentral/devicesettings/commit/56fabffd8576c37eedb03dac31c3238fa318977d) + #### [1.0.27](https://github.com/rdkcentral/devicesettings/compare/1.0.26...1.0.27) +> 12 January 2026 + - RDKEMW-11232 getAudioFormatApi issue on Xione-UK [`#188`](https://github.com/rdkcentral/devicesettings/pull/188) +- 1.0.27 release change log updates [`6594764`](https://github.com/rdkcentral/devicesettings/commit/6594764c3fde44fdb313576482cd7c2589fe1493) - Merge tag '1.0.26' into develop [`62858d9`](https://github.com/rdkcentral/devicesettings/commit/62858d954e5871070b4e0433c9e06abaf8ff97d1) #### [1.0.26](https://github.com/rdkcentral/devicesettings/compare/1.0.25...1.0.26) From 2540d7957f309357eaea1fe3ce94dbdb7990d2df Mon Sep 17 00:00:00 2001 From: Yuvaramachandran Gurusamy <123441336+yuvaramachandran-gurusamy@users.noreply.github.com> Date: Wed, 21 Jan 2026 00:43:37 +0530 Subject: [PATCH 46/66] RDKEMW-10899: Adding IARMBus dependency during Build Time (#205) Signed-off-by: yuvaramachandran_gurusamy --- ds/Makefile | 4 ++-- rpc/cli/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ds/Makefile b/ds/Makefile index d69caba9..3000c0f2 100644 --- a/ds/Makefile +++ b/ds/Makefile @@ -59,8 +59,8 @@ all: install library: $(OBJS) @echo "Building $(LIBNAMEFULL) ...." - $(CXX) $(OBJS) $(CFLAGS) $(DSHAL_LDFLAGS) -L$(INSTALL)/lib -ldshalcli -shared -o $(LIBNAMEFULL) - $(CXX) $(OBJS) $(CFLAGS) -L$(INSTALL)/lib -ldshalcli -shared -o $(LIBNAMECLI) + $(CXX) $(OBJS) $(CFLAGS) $(DSHAL_LDFLAGS) -L$(INSTALL)/lib -lIARMBus -ldshalcli -shared -o $(LIBNAMEFULL) + $(CXX) $(OBJS) $(CFLAGS) -L$(INSTALL)/lib -lIARMBus -ldshalcli -shared -o $(LIBNAMECLI) %.o: %.cpp @echo "Building $@ ...." diff --git a/rpc/cli/Makefile b/rpc/cli/Makefile index 8acae1df..ab24c14f 100644 --- a/rpc/cli/Makefile +++ b/rpc/cli/Makefile @@ -37,7 +37,7 @@ all: install library: $(OBJS) @echo "Building $(LIBNAMEFULL) ...." - $(CXX) $(OBJS) $(CFLAGS) -shared -o $(LIBNAMEFULL) + $(CXX) $(OBJS) $(CFLAGS) -lIARMBus -shared -o $(LIBNAMEFULL) %.o: %.cpp @echo "Building $@ ...." From 9e5074b87bbf8466532f9dea9e1a21faddd9b507 Mon Sep 17 00:00:00 2001 From: apatel859 Date: Wed, 21 Jan 2026 17:10:43 +0000 Subject: [PATCH 47/66] 1.0.29 release change log updates --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 864cb2a0..65db12a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.0.29](https://github.com/rdkcentral/devicesettings/compare/1.0.28...1.0.29) + +- RDKEMW-10899: Adding IARMBus dependency during Build Time [`#205`](https://github.com/rdkcentral/devicesettings/pull/205) +- Merge tag '1.0.28' into develop [`05c2d95`](https://github.com/rdkcentral/devicesettings/commit/05c2d95b7b413f3322c3a0b746fd9ccf260d3ad2) + #### [1.0.28](https://github.com/rdkcentral/devicesettings/compare/1.0.27...1.0.28) +> 13 January 2026 + - RDKEMW-9781: Video format issue on MTK [`#199`](https://github.com/rdkcentral/devicesettings/pull/199) - RDKEMW-12054: Fix Coverity identified issues [`#190`](https://github.com/rdkcentral/devicesettings/pull/190) +- 1.0.28 release change log updates [`f11f7de`](https://github.com/rdkcentral/devicesettings/commit/f11f7de47304fbf0a8669d1894c243dc86c76e02) - Merge tag '1.0.27' into develop [`56fabff`](https://github.com/rdkcentral/devicesettings/commit/56fabffd8576c37eedb03dac31c3238fa318977d) #### [1.0.27](https://github.com/rdkcentral/devicesettings/compare/1.0.26...1.0.27) From 664fd4fedc461c0a6db6c23d95d20c6f3e76d267 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 12 Feb 2026 10:44:04 +0000 Subject: [PATCH 48/66] RDKEMW-8587: consume the config variables using dlsym() in MW. Reason for change: Address the other static config read places. Test Procedure: refer RDKEMW-8587 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 25 ++++++++- ds/audioOutputPortConfig.hpp | 1 + ds/include/videoDevice.hpp | 1 + ds/videoDevice.cpp | 16 +++--- ds/videoOutputPortConfig.cpp | 103 ++++++++++++++++++++++++++++++----- ds/videoOutputPortConfig.hpp | 4 +- rpc/srv/dsAudio.c | 14 +++-- rpc/srv/dsDisplay.c | 47 +++++++++++++--- rpc/srv/dsVideoPort.c | 69 +++++++++++++++++++---- 9 files changed, 236 insertions(+), 44 deletions(-) diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index aab6d682..6fcfb2eb 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -37,6 +37,7 @@ #include #include "manager.hpp" + namespace device { //To Make the instance as thread-safe, using = default, that can request special methods from the compiler. They are Special because only compiler can create them. @@ -261,6 +262,25 @@ void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) INT_INFO("Exit function"); } +void AudioOutputPortConfig::getAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts) +{ + if (nullptr == pPortSize) { + INT_ERROR("pPortSize is NULL"); + return; + } + + *pPortSize = _aPorts.size(); + + if (nullptr != pkAudioPorts) { + // Reverse logic: Create pKPorts from _aPorts + for (size_t i = 0; i < _aPorts.size(); i++) { + pkAudioPorts[i].id.type = (dsAudioPortType_t)_aPorts[i].getType().getId(); + pkAudioPorts[i].id.index = _aPorts[i].getIndex(); + } + INT_INFO("Populated %zu audio ports to pkAudioPorts", _aPorts.size()); + } +} + void AudioOutputPortConfig::release() { try { @@ -277,7 +297,10 @@ void AudioOutputPortConfig::release() } } - +extern "C" void dsGetAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts) +{ + device::AudioOutputPortConfig::getInstance().getAudioConfigs(pPortSize, pkAudioPorts); +} /** @} */ /** @} */ diff --git a/ds/audioOutputPortConfig.hpp b/ds/audioOutputPortConfig.hpp index 54db385a..0c6389da 100644 --- a/ds/audioOutputPortConfig.hpp +++ b/ds/audioOutputPortConfig.hpp @@ -73,6 +73,7 @@ class AudioOutputPortConfig { AudioOutputPort &getPort(const std::string &name); List getPorts(); List getSupportedTypes(); + void getAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts); void load(audioConfigs_t* dynamicAudioConfigs); void release(); diff --git a/ds/include/videoDevice.hpp b/ds/include/videoDevice.hpp index 61ec375d..331105fb 100644 --- a/ds/include/videoDevice.hpp +++ b/ds/include/videoDevice.hpp @@ -33,6 +33,7 @@ #include "dsConstant.hpp" #include "videoDFC.hpp" #include "videoResolution.hpp" +#include "videoOutputPortConfig.hpp" #include "list.hpp" #include #include diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 37452a0c..040e8b3a 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -33,6 +33,7 @@ #include "illegalArgumentException.hpp" #include "exception.hpp" #include "videoDeviceConfig.hpp" +#include "videoOutputPortConfig.hpp" #include "dsVideoResolutionSettings.h" #include "host.hpp" @@ -258,16 +259,17 @@ void VideoDevice::getHDRCapabilities(int *capabilities) dsGetHDRCapabilities(_handle, capabilities); } + void VideoDevice::getSettopSupportedResolutions(std::list& stbSupportedResoltuions) { - size_t numResolutions = dsUTL_DIM(kResolutions); - for (size_t i = 0; i < numResolutions; i++) - { - dsVideoPortResolution_t *resolution = &kResolutions[i]; - stbSupportedResoltuions.push_back(std::string(resolution->name)); + stbSupportedResoltuions.clear(); + + // Get cached supported resolutions directly from _supportedResolutions + const std::vector& resolutions = VideoOutputPortConfig::getInstance()._supportedResolutions; + + for (const VideoResolution& resolution : resolutions) { + stbSupportedResoltuions.push_back(resolution.getName()); } - - return; } unsigned int VideoDevice::getSupportedVideoCodingFormats() const diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 64759527..7c25847d 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -217,20 +217,17 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn //If isIgnoreEdid is true isDynamicList is zero. Edid logic is skipped. if (0 == isDynamicList ) { - size_t numResolutions = dsUTL_DIM(kResolutions); - for (size_t i = 0; i < numResolutions; i++) - { - dsVideoPortResolution_t *resolution = &kResolutions[i]; - tmpsupportedResolutions.push_back( - VideoResolution( - i, /* id */ - std::string(resolution->name), - resolution->pixelResolution, - resolution->aspectRatio, - resolution->stereoScopicMode, - resolution->frameRate, - resolution->interlaced)); - } + cout << "[DsMgr] Copying _supportedResolutions to tmpsupportedResolutions, size: " << _supportedResolutions.size() << endl; + for (size_t idx = 0; idx < _supportedResolutions.size(); idx++) { + const VideoResolution& res = _supportedResolutions[idx]; + cout << "[DsMgr] [" << idx << "] " << res.getName() + << " pixelRes=" << res.getPixelResolution().getId() + << " aspectRatio=" << res.getAspectRatio().getId() + << " frameRate=" << res.getFrameRate().getId() << endl; + } + for (const VideoResolution& resolution : _supportedResolutions) { + tmpsupportedResolutions.push_back(resolution); + } } if (!isIgnoreEdid) { try { @@ -260,6 +257,14 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn for (VideoResolution resolution : tmpsupportedResolutions){ _supportedResolutions.push_back(resolution); } + cout << "[DsMgr] _supportedResolutions cache after update, size: " << _supportedResolutions.size() << endl; + for (size_t idx = 0; idx < _supportedResolutions.size(); idx++) { + const VideoResolution& res = _supportedResolutions[idx]; + cout << "[DsMgr] [" << idx << "] " << res.getName() + << " pixelRes=" << res.getPixelResolution().getId() + << " aspectRatio=" << res.getAspectRatio().getId() + << " frameRate=" << res.getFrameRate().getId() << endl; + } } return supportedResolutions; } @@ -455,6 +460,67 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) INT_INFO("Exit function"); } +void VideoOutputPortConfig::getVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions) +{ + if (nullptr == pResolutionCount) { + INT_ERROR("pResolutionCount is NULL"); + return; + } + + std::lock_guard lock(gSupportedResolutionsMutex); + *pResolutionCount = _supportedResolutions.size(); + + if (nullptr != pResolutions) { + // Reverse logic: Create pResolutions from _supportedResolutions + for (size_t i = 0; i < _supportedResolutions.size(); i++) { + const VideoResolution& resolution = _supportedResolutions[i]; + + // Copy resolution name + strncpy(pResolutions[i].name, resolution.getName().c_str(), sizeof(pResolutions[i].name) - 1); + pResolutions[i].name[sizeof(pResolutions[i].name) - 1] = '\0'; + + // Populate resolution properties + pResolutions[i].pixelResolution = (dsVideoResolution_t)resolution.getPixelResolution().getId(); + pResolutions[i].aspectRatio = (dsVideoAspectRatio_t)resolution.getAspectRatio().getId(); + pResolutions[i].stereoScopicMode = (dsVideoStereoScopicMode_t)resolution.getStereoscopicMode().getId(); + pResolutions[i].frameRate = (dsVideoFrameRate_t)resolution.getFrameRate().getId(); + pResolutions[i].interlaced = resolution.isInterlaced(); + } + INT_INFO("Populated %zu video resolutions to pResolutions", _supportedResolutions.size()); + } +} + +void VideoOutputPortConfig::getVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts) +{ + if (nullptr == pPortCount) { + INT_ERROR("pPortCount is NULL"); + return; + } + + *pPortCount = _vPorts.size(); + + if (nullptr != pPorts) { + // Reverse logic: Create pPorts from _vPorts + for (size_t i = 0; i < _vPorts.size(); i++) { + VideoOutputPort& port = _vPorts.at(i); + + // Populate port ID + pPorts[i].id.type = (dsVideoPortType_t)port.getType().getId(); + pPorts[i].id.index = port.getIndex(); + + // Populate connected audio output port + AudioOutputPort& audioPort = port.getAudioOutputPort(); + pPorts[i].connectedAOP.type = (dsAudioPortType_t)audioPort.getType().getId(); + pPorts[i].connectedAOP.index = audioPort.getIndex(); + + // Get default resolution name - pointer to persistent string in VideoResolution object + const VideoResolution& defaultRes = port.getDefaultResolution(); + pPorts[i].defaultResolution = defaultRes.getName().c_str(); + } + INT_INFO("Populated %zu video ports to pPorts", _vPorts.size()); + } +} + void VideoOutputPortConfig::release() { try { @@ -474,6 +540,15 @@ void VideoOutputPortConfig::release() } } +extern "C" void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions) +{ + device::VideoOutputPortConfig::getInstance().getVideoPortResolutions(pResolutionCount, pResolutions); +} + +extern "C" void dsGetVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts) +{ + device::VideoOutputPortConfig::getInstance().getVideoPortVPorts(pPortCount, pPorts); +} /** @} */ /** @} */ diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index b8047c3e..264b39c8 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -55,7 +55,6 @@ class VideoOutputPortConfig { std::vector _vPixelResolutions; std::vector _vAspectRatios; std::vector _vStereoScopieModes; - std::vector _supportedResolutions; std::vector _vFrameRates; std::vector _vPortTypes; std::vector _vPorts; @@ -65,6 +64,7 @@ class VideoOutputPortConfig { ~VideoOutputPortConfig(); public: + std::vector _supportedResolutions; static VideoOutputPortConfig & getInstance(); const PixelResolution &getPixelResolution(int id) const; @@ -79,6 +79,8 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); + void getVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); + void getVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts); void load(videoPortConfigs_t* dynamicVideoPortConfigs); void release(); diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index 7d085ffd..b27b0fae 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -53,6 +53,9 @@ #include "safec_lib.h" +// Forward declaration for C++ function +extern void dsGetAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts); + static int m_isInitialized = 0; static int m_isPlatInitialized = 0; @@ -3777,17 +3780,20 @@ IARM_Result_t _dsGetEncoding(void *arg) static dsAudioPortType_t _GetAudioPortType(intptr_t handle) { - int numPorts,i; + int numPorts = 0; + int i; intptr_t halhandle = 0; + dsAudioPortConfig_t kAudioPorts[16] = {}; // Allocate enough space for audio ports - numPorts = dsUTL_DIM(kSupportedPortTypes); + // Get audio port configurations from AudioOutputPortConfig + dsGetAudioConfigs(&numPorts, kAudioPorts); for(i=0; i< numPorts; i++) { - if(dsGetAudioPort (kPorts[i].id.type, kPorts[i].id.index, &halhandle) == dsERR_NONE) { + if(dsGetAudioPort (kAudioPorts[i].id.type, kAudioPorts[i].id.index, &halhandle) == dsERR_NONE) { if (handle == halhandle) { - return kPorts[i].id.type; + return kAudioPorts[i].id.type; } } } diff --git a/rpc/srv/dsDisplay.c b/rpc/srv/dsDisplay.c index 982a8b57..d466d38f 100644 --- a/rpc/srv/dsDisplay.c +++ b/rpc/srv/dsDisplay.c @@ -53,6 +53,10 @@ #include "safec_lib.h" #include +// Forward declaration for C++ function +extern void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); +extern void getVideoPortVPorts(int *pPortSize, dsVideoPortPortConfig_t *pkVideoPorts); + static int m_isInitialized = 0; static int m_isPlatInitialized = 0; static bool isEdidCached = false; @@ -578,7 +582,7 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) { errno_t rc = -1; dsVideoPortResolution_t *edidResn = NULL; - dsVideoPortResolution_t *presolution = NULL; + dsVideoPortResolution_t *presolution = NULL, kVidoeResolutionsSettings[16] = { } ; dsDisplayEDID_t *edidData = (dsDisplayEDID_t*)malloc(sizeof(dsDisplayEDID_t)); dsVideoPortType_t _VPortType = _GetDisplayPortType(handle); if (edid == NULL) { @@ -590,7 +594,21 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) if(_VPortType == dsVIDEOPORT_TYPE_HDMI) { INT_DEBUG("EDID for HDMI Port\r\n"); - size_t iCount = dsUTL_DIM(kResolutions); + //size_t iCount = dsUTL_DIM(kResolutions); + int iCount = 0; + //Get details from libds + dsGetVideoPortResolutions(&iCount, kVidoeResolutionsSettings); + + // Print kVidoeResolutionsSettings array + INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array ==========\r\n"); + INT_INFO("[DsMgr] Total resolutions retrieved: %d\r\n", iCount); + for (int k = 0; k < iCount; k++) { + dsVideoPortResolution_t *res = &kVidoeResolutionsSettings[k]; + INT_INFO("[DsMgr] [%d] name=%s, pixelRes=%d, aspectRatio=%d, stereoMode=%d, frameRate=%d, interlaced=%d\r\n", + k, res->name, res->pixelResolution, res->aspectRatio, + res->stereoScopicMode, res->frameRate, res->interlaced); + } + INT_INFO("[DsMgr] ========== End of kVidoeResolutionsSettings Dump ==========\r\n"); /*Initialize the struct*/ memset(edidData,0,sizeof(*edidData)); @@ -604,14 +622,14 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) edid->numOfSupportedResolution = 0; for (size_t i = 0; i < iCount; i++) { - presolution = &kResolutions[i]; + presolution = &kVidoeResolutionsSettings[i]; for (size_t j = 0; j < edidData->numOfSupportedResolution; j++) { edidResn = &(edidData->suppResolutionList[j]); if (0 == (strcmp(presolution->name,edidResn->name))) { - edid->suppResolutionList[edid->numOfSupportedResolution] = kResolutions[i]; + edid->suppResolutionList[edid->numOfSupportedResolution] = kVidoeResolutionsSettings[i]; edid->numOfSupportedResolution++; numOfSupportedResolution++; INT_DEBUG("[DsMgr] presolution->name : %s, resolution count : %d\r\n",presolution->name,numOfSupportedResolution); @@ -646,14 +664,29 @@ static dsVideoPortType_t _GetDisplayPortType(intptr_t handle) { int numPorts,i; intptr_t halhandle = 0; + dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + + //numPorts = dsUTL_DIM(kSupportedPortTypes); + getVideoPortVPorts(&numPorts, kVideoPortPorts); + + // Print kVideoPortPorts array + INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array ==========\r\n"); + INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); + for (int k = 0; k < numPorts; k++) { + dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", + k, port->id.type, port->id.index, + port->connectedAOP.type, port->connectedAOP.index, + port->defaultResolution); + } + INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); - numPorts = dsUTL_DIM(kSupportedPortTypes); for(i=0; i< numPorts; i++) { - dsGetDisplay(kPorts[i].id.type, kPorts[i].id.index, &halhandle); + dsGetDisplay(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); if (handle == halhandle) { - return kPorts[i].id.type; + return kVideoPortPorts[i].id.type; } } INT_INFO("Error: The Requested Display is not part of Platform Port Configuration \r\n"); diff --git a/rpc/srv/dsVideoPort.c b/rpc/srv/dsVideoPort.c index 21ffdcd2..d8d9fa47 100644 --- a/rpc/srv/dsVideoPort.c +++ b/rpc/srv/dsVideoPort.c @@ -79,6 +79,10 @@ static dsDisplayColorDepth_t hdmiColorDept = DEFAULT_COLOR_DEPTH; #define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock) #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock) +// Forward declaration for C++ functions +extern void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); +extern void getVideoPortVPorts(int *pPortSize, dsVideoPortPortConfig_t *pkVideoPorts); + IARM_Result_t _dsVideoPortInit(void *arg); IARM_Result_t _dsGetVideoPort(void *arg); IARM_Result_t _dsIsVideoPortEnabled(void *arg); @@ -1703,14 +1707,28 @@ static dsVideoPortType_t _GetVideoPortType(intptr_t handle) { int numPorts,i; intptr_t halhandle = 0; + dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + + getVideoPortVPorts(&numPorts, kVideoPortPorts); + + // Print kVideoPortPorts array + INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in _GetVideoPortType ==========\r\n"); + INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); + for (int k = 0; k < numPorts; k++) { + dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", + k, port->id.type, port->id.index, + port->connectedAOP.type, port->connectedAOP.index, + port->defaultResolution ? port->defaultResolution : "NULL"); + } + INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); - numPorts = dsUTL_DIM(kSupportedPortTypes); for(i=0; i< numPorts; i++) { - dsGetVideoPort(kPorts[i].id.type, kPorts[i].id.index, &halhandle); + dsGetVideoPort(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); if (handle == halhandle) { - return kPorts[i].id.type; + return kVideoPortPorts[i].id.type; } } INT_ERROR("Error: The Requested Video Port is not part of Platform Port Configuration \r\n"); @@ -1916,11 +1934,26 @@ static bool IsCompatibleResolution(dsVideoResolution_t pixelResolution1,dsVideo static dsVideoResolution_t getPixelResolution(std::string &resolution ) { - dsVideoPortResolution_t *Resn = &kResolutions[kDefaultResIndex]; + dsVideoPortResolution_t kVidoeResolutionsSettings[16] = {}; + int iCount = 0; + dsGetVideoPortResolutions(&iCount, kVidoeResolutionsSettings); + + // Print kVidoeResolutionsSettings array + INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array in getPixelResolution ==========\r\n"); + INT_INFO("[DsMgr] Total resolutions retrieved: %d\r\n", iCount); + for (int k = 0; k < iCount; k++) { + dsVideoPortResolution_t *res = &kVidoeResolutionsSettings[k]; + INT_INFO("[DsMgr] [%d] name=%s, pixelRes=%d, aspectRatio=%d, stereoMode=%d, frameRate=%d, interlaced=%d\r\n", + k, res->name, res->pixelResolution, res->aspectRatio, + res->stereoScopicMode, res->frameRate, res->interlaced); + } + INT_INFO("[DsMgr] ========== End of kVidoeResolutionsSettings Dump ==========\r\n"); - for (unsigned int i = 0; i < dsUTL_DIM(kResolutions); i++) + dsVideoPortResolution_t *Resn = &kVidoeResolutionsSettings[0]; + + for (int i = 0; i < iCount; i++) { - Resn = &kResolutions[i]; + Resn = &kVidoeResolutionsSettings[i]; if (resolution.compare(Resn->name) == 0 ) { break; @@ -2251,6 +2284,7 @@ static dsError_t _dsVideoFormatUpdateRegisterCB (dsVideoFormatUpdateCB_t cbFun) return eRet; } +//This funcation does not have any caller. bool isComponentPortPresent() { bool componentPortPresent = false; @@ -2387,12 +2421,27 @@ intptr_t dsGetDefaultPortHandle() { int numPorts,i; intptr_t halhandle = 0; - numPorts = dsUTL_DIM(kSupportedPortTypes); + dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + + getVideoPortVPorts(&numPorts, kVideoPortPorts); + + // Print kVideoPortPorts array + INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in dsGetDefaultPortHandle ==========\r\n"); + INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); + for (int k = 0; k < numPorts; k++) { + dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", + k, port->id.type, port->id.index, + port->connectedAOP.type, port->connectedAOP.index, + port->defaultResolution ? port->defaultResolution : "NULL"); + } + INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); + for(i=0; i< numPorts; i++) { - dsGetVideoPort(kPorts[i].id.type, kPorts[i].id.index, &halhandle); - if (dsVIDEOPORT_TYPE_HDMI == kPorts[i].id.type || - dsVIDEOPORT_TYPE_INTERNAL == kPorts[i].id.type) + dsGetVideoPort(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); + if (dsVIDEOPORT_TYPE_HDMI == kVideoPortPorts[i].id.type || + dsVIDEOPORT_TYPE_INTERNAL == kVideoPortPorts[i].id.type) { return halhandle; } From c1e17e46347beed2239c41061223d2d3ab484acc Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 16 Feb 2026 15:32:16 +0000 Subject: [PATCH 49/66] RDKEMW-8587, RDKEMW-12193 : consume the config variables using dlsym() in MW. Reason for change: Implemented logic to load both dynamic and static configurations on the server side and removed unnecessary code. Test Procedure: refer RDKEMW-8587, RDKEMW-12193 Risks: High Signed-off-by:gsanto722 --- ds/audioOutputPortConfig.cpp | 25 --- ds/audioOutputPortConfig.hpp | 1 - ds/videoOutputPortConfig.cpp | 74 +------- ds/videoOutputPortConfig.hpp | 2 - rpc/include/dsAudioConfig.h | 75 ++++++++ rpc/include/dsConfigs.h | 78 ++++++++ rpc/include/dsVideoDeviceConfig.h | 65 +++++++ rpc/include/dsVideoPortConfig.h | 93 ++++++++++ rpc/srv/dsAudio.c | 10 +- rpc/srv/dsAudioConfig.c | 199 +++++++++++++++++++++ rpc/srv/dsDisplay.c | 20 +-- rpc/srv/dsMgr.c | 4 + rpc/srv/dsVideoDeviceConfig.c | 136 ++++++++++++++ rpc/srv/dsVideoPort.c | 56 +++--- rpc/srv/dsVideoPortConfig.c | 286 ++++++++++++++++++++++++++++++ 15 files changed, 983 insertions(+), 141 deletions(-) create mode 100644 rpc/include/dsAudioConfig.h create mode 100644 rpc/include/dsConfigs.h create mode 100644 rpc/include/dsVideoDeviceConfig.h create mode 100644 rpc/include/dsVideoPortConfig.h create mode 100644 rpc/srv/dsAudioConfig.c create mode 100644 rpc/srv/dsVideoDeviceConfig.c create mode 100644 rpc/srv/dsVideoPortConfig.c diff --git a/ds/audioOutputPortConfig.cpp b/ds/audioOutputPortConfig.cpp index 6fcfb2eb..2b1664fd 100644 --- a/ds/audioOutputPortConfig.cpp +++ b/ds/audioOutputPortConfig.cpp @@ -262,25 +262,6 @@ void AudioOutputPortConfig::load(audioConfigs_t* dynamicAudioConfigs) INT_INFO("Exit function"); } -void AudioOutputPortConfig::getAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts) -{ - if (nullptr == pPortSize) { - INT_ERROR("pPortSize is NULL"); - return; - } - - *pPortSize = _aPorts.size(); - - if (nullptr != pkAudioPorts) { - // Reverse logic: Create pKPorts from _aPorts - for (size_t i = 0; i < _aPorts.size(); i++) { - pkAudioPorts[i].id.type = (dsAudioPortType_t)_aPorts[i].getType().getId(); - pkAudioPorts[i].id.index = _aPorts[i].getIndex(); - } - INT_INFO("Populated %zu audio ports to pkAudioPorts", _aPorts.size()); - } -} - void AudioOutputPortConfig::release() { try { @@ -296,11 +277,5 @@ void AudioOutputPortConfig::release() } } - -extern "C" void dsGetAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts) -{ - device::AudioOutputPortConfig::getInstance().getAudioConfigs(pPortSize, pkAudioPorts); -} - /** @} */ /** @} */ diff --git a/ds/audioOutputPortConfig.hpp b/ds/audioOutputPortConfig.hpp index 0c6389da..54db385a 100644 --- a/ds/audioOutputPortConfig.hpp +++ b/ds/audioOutputPortConfig.hpp @@ -73,7 +73,6 @@ class AudioOutputPortConfig { AudioOutputPort &getPort(const std::string &name); List getPorts(); List getSupportedTypes(); - void getAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts); void load(audioConfigs_t* dynamicAudioConfigs); void release(); diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 7c25847d..d5394c64 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -257,7 +257,7 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn for (VideoResolution resolution : tmpsupportedResolutions){ _supportedResolutions.push_back(resolution); } - cout << "[DsMgr] _supportedResolutions cache after update, size: " << _supportedResolutions.size() << endl; + cout << "[DsMgr] _supportedResolutions cache after update, size: " << _supportedResolutions.size() << endl; for (size_t idx = 0; idx < _supportedResolutions.size(); idx++) { const VideoResolution& res = _supportedResolutions[idx]; cout << "[DsMgr] [" << idx << "] " << res.getName() @@ -460,67 +460,6 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) INT_INFO("Exit function"); } -void VideoOutputPortConfig::getVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions) -{ - if (nullptr == pResolutionCount) { - INT_ERROR("pResolutionCount is NULL"); - return; - } - - std::lock_guard lock(gSupportedResolutionsMutex); - *pResolutionCount = _supportedResolutions.size(); - - if (nullptr != pResolutions) { - // Reverse logic: Create pResolutions from _supportedResolutions - for (size_t i = 0; i < _supportedResolutions.size(); i++) { - const VideoResolution& resolution = _supportedResolutions[i]; - - // Copy resolution name - strncpy(pResolutions[i].name, resolution.getName().c_str(), sizeof(pResolutions[i].name) - 1); - pResolutions[i].name[sizeof(pResolutions[i].name) - 1] = '\0'; - - // Populate resolution properties - pResolutions[i].pixelResolution = (dsVideoResolution_t)resolution.getPixelResolution().getId(); - pResolutions[i].aspectRatio = (dsVideoAspectRatio_t)resolution.getAspectRatio().getId(); - pResolutions[i].stereoScopicMode = (dsVideoStereoScopicMode_t)resolution.getStereoscopicMode().getId(); - pResolutions[i].frameRate = (dsVideoFrameRate_t)resolution.getFrameRate().getId(); - pResolutions[i].interlaced = resolution.isInterlaced(); - } - INT_INFO("Populated %zu video resolutions to pResolutions", _supportedResolutions.size()); - } -} - -void VideoOutputPortConfig::getVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts) -{ - if (nullptr == pPortCount) { - INT_ERROR("pPortCount is NULL"); - return; - } - - *pPortCount = _vPorts.size(); - - if (nullptr != pPorts) { - // Reverse logic: Create pPorts from _vPorts - for (size_t i = 0; i < _vPorts.size(); i++) { - VideoOutputPort& port = _vPorts.at(i); - - // Populate port ID - pPorts[i].id.type = (dsVideoPortType_t)port.getType().getId(); - pPorts[i].id.index = port.getIndex(); - - // Populate connected audio output port - AudioOutputPort& audioPort = port.getAudioOutputPort(); - pPorts[i].connectedAOP.type = (dsAudioPortType_t)audioPort.getType().getId(); - pPorts[i].connectedAOP.index = audioPort.getIndex(); - - // Get default resolution name - pointer to persistent string in VideoResolution object - const VideoResolution& defaultRes = port.getDefaultResolution(); - pPorts[i].defaultResolution = defaultRes.getName().c_str(); - } - INT_INFO("Populated %zu video ports to pPorts", _vPorts.size()); - } -} - void VideoOutputPortConfig::release() { try { @@ -539,16 +478,5 @@ void VideoOutputPortConfig::release() } } } - -extern "C" void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions) -{ - device::VideoOutputPortConfig::getInstance().getVideoPortResolutions(pResolutionCount, pResolutions); -} - -extern "C" void dsGetVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts) -{ - device::VideoOutputPortConfig::getInstance().getVideoPortVPorts(pPortCount, pPorts); -} - /** @} */ /** @} */ diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index 264b39c8..aaddf911 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -79,8 +79,6 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); - void getVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); - void getVideoPortVPorts(int *pPortCount, dsVideoPortPortConfig_t *pPorts); void load(videoPortConfigs_t* dynamicVideoPortConfigs); void release(); diff --git a/rpc/include/dsAudioConfig.h b/rpc/include/dsAudioConfig.h new file mode 100644 index 00000000..427d20a1 --- /dev/null +++ b/rpc/include/dsAudioConfig.h @@ -0,0 +1,75 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#ifndef _DS_AUDIO_CONFIG_H_ +#define _DS_AUDIO_CONFIG_H_ + +#include "dsTypes.h" +//#include "dsAudioSettings.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct audioConfigs +{ + const dsAudioTypeConfig_t *pKAudioConfigs; + const dsAudioPortConfig_t *pKAudioPorts; + int *pKConfigSize; + int *pKPortSize; +}audioConfigs_t; + +/** + * @brief Load audio output port configuration + * + * @param[in] dynamicAudioConfigs Pointer to dynamic audio configuration, or NULL for static config + */ +void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs); + +/** + * @brief Get audio type configurations + * + * @param[out] outConfigSize Pointer to store the number of audio type configs, or NULL + * @param[out] outConfigs Pointer to store the audio type configs array, or NULL + */ +void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs); + +/** + * @brief Get audio port configurations + * + * @param[out] outPortSize Pointer to store the number of audio port configs, or NULL + * @param[out] outPorts Pointer to store the audio port configs array, or NULL + */ +void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts); + +#ifdef __cplusplus +} +#endif + +#endif /* _DS_AUDIO_CONFIG_H_ */ + +/** @} */ +/** @} */ diff --git a/rpc/include/dsConfigs.h b/rpc/include/dsConfigs.h new file mode 100644 index 00000000..b7e2fb7a --- /dev/null +++ b/rpc/include/dsConfigs.h @@ -0,0 +1,78 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#ifndef _DS_CONFIGS_H_ +#define _DS_CONFIGS_H_ + +#include "dsTypes.h" +//#include "dsAudioSettings.h" +//#include "dsVideoPortSettings.h" +//#include "dsVideoDeviceSettings.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct audioConfigs +{ + const dsAudioTypeConfig_t *pKAudioConfigs; + const dsAudioPortConfig_t *pKAudioPorts; + int *pKConfigSize; + int *pKPortSize; +}audioConfigs_t; + +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKVideoPortConfigs; + int *pKVideoPortConfigs_size; + const dsVideoPortPortConfig_t *pKVideoPortPorts; + int *pKVideoPortPorts_size; + dsVideoPortResolution_t *pKVideoPortResolutionsSettings; + int *pKResolutionsSettings_size; + int *pKDefaultResIndex; +}videoPortConfigs_t; + +typedef struct videoDeviceConfig +{ + dsVideoConfig_t *pKVideoDeviceConfigs; + int *pKVideoDeviceConfigs_size; +}videoDeviceConfig_t; + +/** + * @brief Load all device settings configurations + * + * Loads audio, video port, and video device configurations from HAL library + */ +void dsLoadConfigs(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _DS_CONFIGS_H_ */ + +/** @} */ +/** @} */ diff --git a/rpc/include/dsVideoDeviceConfig.h b/rpc/include/dsVideoDeviceConfig.h new file mode 100644 index 00000000..d35c2664 --- /dev/null +++ b/rpc/include/dsVideoDeviceConfig.h @@ -0,0 +1,65 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#ifndef _DS_VIDEO_DEVICE_CONFIG_H_ +#define _DS_VIDEO_DEVICE_CONFIG_H_ + +#include "dsTypes.h" +//#include "dsVideoDeviceSettings.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct videoDeviceConfig +{ + dsVideoConfig_t *pKVideoDeviceConfigs; + int *pKVideoDeviceConfigs_size; +}videoDeviceConfig_t; + +/** + * @brief Load video device configuration + * + * @param[in] dynamicVideoDeviceConfigs Pointer to dynamic video device configuration, or NULL for static config + */ +void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs); + +/** + * @brief Get video device configurations + * + * @param[out] outConfigSize Pointer to store the number of video device configs, or NULL + * @param[out] outConfigs Pointer to store the video device configs array, or NULL + */ +void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs); + +#ifdef __cplusplus +} +#endif + +#endif /* _DS_VIDEO_DEVICE_CONFIG_H_ */ + +/** @} */ +/** @} */ diff --git a/rpc/include/dsVideoPortConfig.h b/rpc/include/dsVideoPortConfig.h new file mode 100644 index 00000000..17de96dd --- /dev/null +++ b/rpc/include/dsVideoPortConfig.h @@ -0,0 +1,93 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#ifndef _DS_VIDEO_PORT_CONFIG_H_ +#define _DS_VIDEO_PORT_CONFIG_H_ + +#include "dsTypes.h" +//#include "dsVideoPortSettings.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKVideoPortConfigs; + int *pKVideoPortConfigs_size; + const dsVideoPortPortConfig_t *pKVideoPortPorts; + int *pKVideoPortPorts_size; + dsVideoPortResolution_t *pKVideoPortResolutionsSettings; + int *pKResolutionsSettings_size; + int *pKDefaultResIndex; +}videoPortConfigs_t; + +/** + * @brief Load video output port configuration + * + * @param[in] dynamicVideoPortConfigs Pointer to dynamic video port configuration, or NULL for static config + */ +void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); + +/** + * @brief Get video port type configurations + * + * @param[out] outConfigSize Pointer to store the number of video port type configs, or NULL + * @param[out] outConfigs Pointer to store the video port type configs array, or NULL + */ +void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs); + +/** + * @brief Get video port port configurations + * + * @param[out] outPortSize Pointer to store the number of video port port configs, or NULL + * @param[out] outPorts Pointer to store the video port port configs array, or NULL + */ +void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts); + +/** + * @brief Get video port resolutions + * + * @param[out] outResolutionSize Pointer to store the number of video port resolutions, or NULL + * @param[out] outResolutions Pointer to store the video port resolutions array, or NULL + */ +void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions); + +/** + * @brief Get default resolution index + * + * @param[out] outDefaultIndex Pointer to store the default resolution index, or NULL + */ +void dsGetDefaultResolutionIndex(int* outDefaultIndex); + +#ifdef __cplusplus +} +#endif + +#endif /* _DS_VIDEO_PORT_CONFIG_H_ */ + +/** @} */ +/** @} */ diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index b27b0fae..8ec09aee 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -49,13 +49,11 @@ #include "dsMgr.h" #include "hostPersistence.hpp" #include "dsserverlogger.h" -#include "dsAudioSettings.h" +//#include "dsAudioSettings.h" +#include "dsAudioConfig.h" #include "safec_lib.h" -// Forward declaration for C++ function -extern void dsGetAudioConfigs(int *pPortSize, dsAudioPortConfig_t *pkAudioPorts); - static int m_isInitialized = 0; static int m_isPlatInitialized = 0; @@ -3783,10 +3781,10 @@ static dsAudioPortType_t _GetAudioPortType(intptr_t handle) int numPorts = 0; int i; intptr_t halhandle = 0; - dsAudioPortConfig_t kAudioPorts[16] = {}; // Allocate enough space for audio ports + const dsAudioPortConfig_t *kAudioPorts = NULL; // Get audio port configurations from AudioOutputPortConfig - dsGetAudioConfigs(&numPorts, kAudioPorts); + dsGetAudioPortConfigs(&numPorts, &kAudioPorts); for(i=0; i< numPorts; i++) { diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c new file mode 100644 index 00000000..4e789380 --- /dev/null +++ b/rpc/srv/dsAudioConfig.c @@ -0,0 +1,199 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#include +#include +#include +#include "dsserverlogger.h" +#include "dsTypes.h" +#include "dsAudioSettings.h" + +typedef struct audioConfigs +{ + const dsAudioTypeConfig_t *pKAudioConfigs; + const dsAudioPortConfig_t *pKAudioPorts; + int *pKConfigSize; + int *pKPortSize; +}audioConfigs_t; + +audioConfigs_t audioConfiguration = {0}; +static dsAudioTypeConfig_t* allocatedAudioConfigs = NULL; +static dsAudioPortConfig_t* allocatedAudioPorts = NULL; +static int g_audioConfigSize = -1; +static int g_audioPortSize = -1; + +void dumpconfig(audioConfigs_t *config) +{ + if (nullptr == config) { + INT_ERROR("Audio config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + + int configSize = -1, portSize = -1; + INT_INFO("\n=============== Starting to Dump Audio Configs ===============\n"); + if( NULL != config->pKAudioConfigs ) + { + configSize = (config->pKConfigSize) ? *(config->pKConfigSize) : -1; + + for (int i = 0; i < configSize; i++) { + const dsAudioTypeConfig_t *typeCfg = &(config->pKAudioConfigs[i]); + INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); + INT_INFO("typeCfg->name = %s", typeCfg->name); + INT_INFO("typeCfg->numSupportedEncodings = %zu", typeCfg->numSupportedEncodings); + INT_INFO("typeCfg->numSupportedCompressions = %zu", typeCfg->numSupportedCompressions); + INT_INFO("typeCfg->numSupportedStereoModes = %zu", typeCfg->numSupportedStereoModes); + } + } + else + { + INT_ERROR("kAudioConfigs is NULL"); + } + + if( NULL != config->pKAudioPorts ) + { + portSize = (config->pKPortSize) ? *(config->pKPortSize) : -1; + for (int i = 0; i < portSize; i++) { + const dsAudioPortConfig_t *portCfg = &(config->pKAudioPorts[i]); + INT_INFO("portCfg->id.type = %d", portCfg->id.type); + INT_INFO("portCfg->id.index = %d", portCfg->id.index); + } + } + else + { + INT_ERROR("kAudioPorts is NULL"); + } + + INT_INFO("\n=============== Dump Audio Configs done ===============\n"); +} + +static int allocateAndCopyAudioConfigs(const dsAudioTypeConfig_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s config size: %d\n", configType, size); + return -1; + } + + allocatedAudioConfigs = (dsAudioTypeConfig_t*)malloc(size * sizeof(dsAudioTypeConfig_t)); + if (allocatedAudioConfigs == NULL) { + INT_ERROR("Failed to allocate memory for %s audio configs\n", configType); + return -1; + } + + memcpy(allocatedAudioConfigs, source, size * sizeof(dsAudioTypeConfig_t)); + audioConfiguration.pKAudioConfigs = allocatedAudioConfigs; + INT_INFO("Allocated and copied %d audio configs (%s)", size, configType); + return size; +} + +static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s port size: %d\n", configType, size); + return -1; + } + + allocatedAudioPorts = (dsAudioPortConfig_t*)malloc(size * sizeof(dsAudioPortConfig_t)); + if (allocatedAudioPorts == NULL) { + INT_ERROR("Failed to allocate memory for %s audio ports\n", configType); + // Free previously allocated configs if allocation fails + if (allocatedAudioConfigs != NULL) { + free(allocatedAudioConfigs); + allocatedAudioConfigs = NULL; + audioConfiguration.pKAudioConfigs = NULL; + } + return -1; + } + + memcpy(allocatedAudioPorts, source, size * sizeof(dsAudioPortConfig_t)); + audioConfiguration.pKAudioPorts = allocatedAudioPorts; + INT_INFO("Allocated and copied %d audio ports (%s)", size, configType); + return size; +} + +void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) +{ + int configSize = -1, portSize = -1; + + INT_INFO("Using '%s' config", dynamicAudioConfigs ? "dynamic" : "static"); + + if (NULL != dynamicAudioConfigs) + { + // Reading Audio type configs + configSize = (dynamicAudioConfigs->pKConfigSize) ? *(dynamicAudioConfigs->pKConfigSize) : -1; + configSize = allocateAndCopyAudioConfigs(dynamicAudioConfigs->pKAudioConfigs, configSize, "dynamic"); + + // Reading Audio port configs + portSize = (dynamicAudioConfigs->pKPortSize) ? *(dynamicAudioConfigs->pKPortSize) : -1; + portSize = allocateAndCopyAudioPorts(dynamicAudioConfigs->pKAudioPorts, portSize, "dynamic"); + } + else { + // Using static configuration + configSize = dsUTL_DIM(kConfigs); + configSize = allocateAndCopyAudioConfigs(kConfigs, configSize, "static"); + + portSize = dsUTL_DIM(kPorts); + portSize = allocateAndCopyAudioPorts(kPorts, portSize, "static"); + } + + // Store sizes for getter functions + g_audioConfigSize = configSize; + g_audioPortSize = portSize; + + INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]", + audioConfiguration.pKAudioConfigs, + configSize, + audioConfiguration.pKAudioPorts, + portSize); + dumpconfig(&audioConfiguration); +} + +// Getter functions for use across srv code +void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs) +{ + if (outConfigSize != NULL) { + *outConfigSize = g_audioConfigSize; + } + if (outConfigs != NULL) { + *outConfigs = audioConfiguration.pKAudioConfigs; + } +} + +void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts) +{ + if (outPortSize != NULL) { + *outPortSize = g_audioPortSize; + } + if (outPorts != NULL) { + *outPorts = audioConfiguration.pKAudioPorts; + } +} + +/** @} */ +/** @} */ diff --git a/rpc/srv/dsDisplay.c b/rpc/srv/dsDisplay.c index d466d38f..91a89dc4 100644 --- a/rpc/srv/dsDisplay.c +++ b/rpc/srv/dsDisplay.c @@ -46,17 +46,15 @@ #include "dsMgr.h" #include "dsserverlogger.h" #include "dsVideoPort.h" -#include "dsVideoPortSettings.h" -#include "dsVideoResolutionSettings.h" +//#include "dsVideoPortSettings.h" +//#include "dsVideoResolutionSettings.h" +#include "dsVideoPortConfig.h" +//#include "dsConfigs.h" #include "dsInternal.h" #include "safec_lib.h" #include -// Forward declaration for C++ function -extern void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); -extern void getVideoPortVPorts(int *pPortSize, dsVideoPortPortConfig_t *pkVideoPorts); - static int m_isInitialized = 0; static int m_isPlatInitialized = 0; static bool isEdidCached = false; @@ -582,7 +580,7 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) { errno_t rc = -1; dsVideoPortResolution_t *edidResn = NULL; - dsVideoPortResolution_t *presolution = NULL, kVidoeResolutionsSettings[16] = { } ; + dsVideoPortResolution_t *presolution = NULL, *kVidoeResolutionsSettings = NULL; dsDisplayEDID_t *edidData = (dsDisplayEDID_t*)malloc(sizeof(dsDisplayEDID_t)); dsVideoPortType_t _VPortType = _GetDisplayPortType(handle); if (edid == NULL) { @@ -597,7 +595,7 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) //size_t iCount = dsUTL_DIM(kResolutions); int iCount = 0; //Get details from libds - dsGetVideoPortResolutions(&iCount, kVidoeResolutionsSettings); + dsGetVideoPortResolutions(&iCount, &kVidoeResolutionsSettings); // Print kVidoeResolutionsSettings array INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array ==========\r\n"); @@ -664,16 +662,16 @@ static dsVideoPortType_t _GetDisplayPortType(intptr_t handle) { int numPorts,i; intptr_t halhandle = 0; - dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; //numPorts = dsUTL_DIM(kSupportedPortTypes); - getVideoPortVPorts(&numPorts, kVideoPortPorts); + dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); // Print kVideoPortPorts array INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array ==========\r\n"); INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); for (int k = 0; k < numPorts; k++) { - dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", k, port->id.type, port->id.index, port->connectedAOP.type, port->connectedAOP.index, diff --git a/rpc/srv/dsMgr.c b/rpc/srv/dsMgr.c index 9de34e5a..3bf6e2a5 100755 --- a/rpc/srv/dsMgr.c +++ b/rpc/srv/dsMgr.c @@ -41,6 +41,7 @@ #include "hostPersistence.hpp" #include "dsInternal.h" +#include "dsConfigs.h" profile_t profileType = PROFILE_INVALID; @@ -124,6 +125,9 @@ IARM_Result_t dsMgr_init() dsHostMgr_init(); dsHdmiInMgr_init(); dsCompositeInMgr_init(); + + INT_INFO("[%s]: Loading device configurations\r\n", __FUNCTION__); + dsLoadConfigs(); return ret; } diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c new file mode 100644 index 00000000..8835559b --- /dev/null +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -0,0 +1,136 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#include +#include +#include +#include "dsserverlogger.h" +#include "dsTypes.h" +#include "dsVideoDeviceSettings.h" + +typedef struct videoDeviceConfig +{ + dsVideoConfig_t *pKVideoDeviceConfigs; + int *pKVideoDeviceConfigs_size; +}videoDeviceConfig_t; + +static videoDeviceConfig_t videoDeviceConfiguration = {0}; +static dsVideoConfig_t* allocatedVideoDeviceConfigs = NULL; +static int g_videoDeviceConfigSize = -1; + +void dumpconfig(videoDeviceConfig_t *config) +{ + if (nullptr == config) { + INT_ERROR("Video config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + + INT_INFO("\n=============== Starting to Dump VideoDevice Configs ===============\n"); + + if( nullptr != config->pKVideoDeviceConfigs ) + { + int configSize = (config->pKVideoDeviceConfigs_size) ? *(config->pKVideoDeviceConfigs_size) : -1; + INT_INFO("pKVideoDeviceConfigs = %p", config->pKVideoDeviceConfigs); + INT_INFO("videoDeviceConfigs_size = %d", configSize); + for (int i = 0; i < configSize; i++) { + dsVideoConfig_t* videoDeviceConfig = &config->pKVideoDeviceConfigs[i]; + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu ", i, videoDeviceConfig->numSupportedDFCs); + for (int j = 0; j < videoDeviceConfig->numSupportedDFCs; j++) { + INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, videoDeviceConfig->supportedDFCs[j]); + } + } + } + else + { + INT_ERROR(" kVideoDeviceConfigs is NULL"); + } + + INT_INFO("\n=============== Dump VideoDevice Configs done ===============\n"); +} + +static int allocateAndCopyVideoDeviceConfigs(const dsVideoConfig_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s video device config size: %d\n", configType, size); + return -1; + } + + allocatedVideoDeviceConfigs = (dsVideoConfig_t*)malloc(size * sizeof(dsVideoConfig_t)); + if (allocatedVideoDeviceConfigs == NULL) { + INT_ERROR("Failed to allocate memory for %s video device configs\n", configType); + return -1; + } + + memcpy(allocatedVideoDeviceConfigs, source, size * sizeof(dsVideoConfig_t)); + videoDeviceConfiguration.pKVideoDeviceConfigs = allocatedVideoDeviceConfigs; + INT_INFO("Allocated and copied %d video device configs (%s)", size, configType); + return size; +} + +void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) +{ + int configSize = -1; + + INT_INFO("Using '%s' config", dynamicVideoDeviceConfigs ? "dynamic" : "static"); + + if (NULL != dynamicVideoDeviceConfigs) + { + // Reading Video Device configs + configSize = (dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) ? *(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) : -1; + configSize = allocateAndCopyVideoDeviceConfigs(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs, configSize, "dynamic"); + } + else { + // Using static configuration + configSize = dsUTL_DIM(kConfigs); + configSize = allocateAndCopyVideoDeviceConfigs(kConfigs, configSize, "static"); + } + + // Store size for getter functions + g_videoDeviceConfigSize = configSize; + + INT_INFO("VideoDevice Config[%p] ConfigSize[%d]", + videoDeviceConfiguration.pKVideoDeviceConfigs, + configSize); + dumpconfig(&videoDeviceConfiguration); +} + +// Getter functions for use across srv code +void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) +{ + if (outConfigSize != NULL) { + *outConfigSize = g_videoDeviceConfigSize; + } + if (outConfigs != NULL) { + *outConfigs = videoDeviceConfiguration.pKVideoDeviceConfigs; + } +} + +/** @} */ +/** @} */ diff --git a/rpc/srv/dsVideoPort.c b/rpc/srv/dsVideoPort.c index d8d9fa47..0aa50bc9 100644 --- a/rpc/srv/dsVideoPort.c +++ b/rpc/srv/dsVideoPort.c @@ -51,7 +51,9 @@ #include "hostPersistence.hpp" #include "dsserverlogger.h" #include "dsTypes.h" -#include "dsVideoPortSettings.h" +//#include "dsVideoPortSettings.h" +#include "dsVideoPortConfig.h" +//#include "dsConfigs.h" #include "dsInternal.h" #include "safec_lib.h" #include @@ -79,10 +81,6 @@ static dsDisplayColorDepth_t hdmiColorDept = DEFAULT_COLOR_DEPTH; #define IARM_BUS_Lock(lock) pthread_mutex_lock(&dsLock) #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&dsLock) -// Forward declaration for C++ functions -extern void dsGetVideoPortResolutions(int *pResolutionCount, dsVideoPortResolution_t *pResolutions); -extern void getVideoPortVPorts(int *pPortSize, dsVideoPortPortConfig_t *pkVideoPorts); - IARM_Result_t _dsVideoPortInit(void *arg); IARM_Result_t _dsGetVideoPort(void *arg); IARM_Result_t _dsIsVideoPortEnabled(void *arg); @@ -1705,17 +1703,17 @@ IARM_Result_t _dsSupportedTvResolutions(void *arg) static dsVideoPortType_t _GetVideoPortType(intptr_t handle) { - int numPorts,i; + int numPorts = 0, i; intptr_t halhandle = 0; - dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; - getVideoPortVPorts(&numPorts, kVideoPortPorts); + dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); // Print kVideoPortPorts array INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in _GetVideoPortType ==========\r\n"); INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); for (int k = 0; k < numPorts; k++) { - dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", k, port->id.type, port->id.index, port->connectedAOP.type, port->connectedAOP.index, @@ -1912,7 +1910,16 @@ static std::string getCompatibleResolution(dsVideoPortResolution_t *SrcResn) case dsVIDEO_PIXELRES_4096x2160: case dsVIDEO_PIXELRES_MAX: default: - return resolution.assign(kResolutions[kDefaultResIndex].name); + { + int numResolutions = 0; + dsVideoPortResolution_t* resolutions = NULL; + int defaultIndex = 0; + dsGetVideoPortResolutions(&numResolutions, &resolutions); + dsGetDefaultResolutionIndex(&defaultIndex); + if (resolutions && defaultIndex >= 0 && defaultIndex < numResolutions) { + return resolution.assign(resolutions[defaultIndex].name); + } + } break; } } @@ -1934,9 +1941,9 @@ static bool IsCompatibleResolution(dsVideoResolution_t pixelResolution1,dsVideo static dsVideoResolution_t getPixelResolution(std::string &resolution ) { - dsVideoPortResolution_t kVidoeResolutionsSettings[16] = {}; + dsVideoPortResolution_t *kVidoeResolutionsSettings = NULL; int iCount = 0; - dsGetVideoPortResolutions(&iCount, kVidoeResolutionsSettings); + dsGetVideoPortResolutions(&iCount, &kVidoeResolutionsSettings); // Print kVidoeResolutionsSettings array INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array in getPixelResolution ==========\r\n"); @@ -2288,14 +2295,17 @@ static dsError_t _dsVideoFormatUpdateRegisterCB (dsVideoFormatUpdateCB_t cbFun) bool isComponentPortPresent() { bool componentPortPresent = false; - int numPorts,i; - - numPorts = dsUTL_DIM(kSupportedPortTypes); - for(i=0; i< numPorts; i++) - { - if (kSupportedPortTypes[i] == dsVIDEOPORT_TYPE_COMPONENT) + int numTypeConfigs = 0; + const dsVideoPortTypeConfig_t* typeConfigs = NULL; + + dsGetVideoPortTypeConfigs(&numTypeConfigs, &typeConfigs); + if (typeConfigs) { + for(int i=0; i< numTypeConfigs; i++) { - componentPortPresent = true;; + if (typeConfigs[i].typeId == dsVIDEOPORT_TYPE_COMPONENT) + { + componentPortPresent = true; + } } } INT_INFO(" componentPortPresent :%d\n",componentPortPresent); @@ -2419,17 +2429,17 @@ void _dsSyncHdmiStatus(const std::string& key, int val) { intptr_t dsGetDefaultPortHandle() { - int numPorts,i; + int numPorts = 0, i; intptr_t halhandle = 0; - dsVideoPortPortConfig_t kVideoPortPorts[16] = {}; + const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; - getVideoPortVPorts(&numPorts, kVideoPortPorts); + dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); // Print kVideoPortPorts array INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in dsGetDefaultPortHandle ==========\r\n"); INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); for (int k = 0; k < numPorts; k++) { - dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; + const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", k, port->id.type, port->id.index, port->connectedAOP.type, port->connectedAOP.index, diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c new file mode 100644 index 00000000..56b80c27 --- /dev/null +++ b/rpc/srv/dsVideoPortConfig.c @@ -0,0 +1,286 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#include +#include +#include +#include "dsserverlogger.h" +#include "dsTypes.h" +#include "dsVideoPortSettings.h" + +typedef struct videoPortConfigs +{ + const dsVideoPortTypeConfig_t *pKVideoPortConfigs; + int *pKVideoPortConfigs_size; + const dsVideoPortPortConfig_t *pKVideoPortPorts; + int *pKVideoPortPorts_size; + dsVideoPortResolution_t *pKVideoPortResolutionsSettings; + int *pKResolutionsSettings_size; + int *pKDefaultResIndex; +}videoPortConfigs_t; + +static videoPortConfigs_t videoPortConfiguration = {0}; +static dsVideoPortTypeConfig_t* allocatedVideoPortConfigs = NULL; +static dsVideoPortPortConfig_t* allocatedVideoPortPorts = NULL; +static dsVideoPortResolution_t* allocatedVideoPortResolutions = NULL; +static int g_videoPortConfigSize = -1; +static int g_videoPortPortSize = -1; +static int g_videoPortResolutionSize = -1; +static int g_defaultResIndex = -1; + +void dumpconfig(videoPortConfigs_t *config) +{ + if (nullptr == config) { + INT_ERROR("Video config is NULL"); + return; + } + if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { + INT_INFO("Dumping of Device configs is disabled"); + return; + } + INT_INFO("\n=============== Starting to Dump VideoPort Configs ===============\n"); + + int configSize = -1, portSize = -1, resolutionSize = -1; + if (( NULL != config->pKVideoPortConfigs ) && ( NULL != config->pKVideoPortPorts ) && ( nullptr != config->pKVideoPortResolutionsSettings )) + { + configSize = (config->pKVideoPortConfigs_size) ? *(config->pKVideoPortConfigs_size) : -1; + portSize = (config->pKVideoPortPorts_size) ? *(config->pKVideoPortPorts_size) : -1; + resolutionSize = (config->pKResolutionsSettings_size) ? *(config->pKResolutionsSettings_size) : -1; + INT_INFO("pKVideoPortConfigs = %p", config->pKVideoPortConfigs); + INT_INFO("pKConfigSize pointer %p = %d", config->pKVideoPortConfigs_size, configSize); + INT_INFO("pKVideoPortPorts = %p", config->pKVideoPortPorts); + INT_INFO("pKPortSize pointer %p = %d", config->pKVideoPortPorts_size, portSize); + INT_INFO("pKResolutionsSettings = %p", config->pKVideoPortResolutionsSettings); + INT_INFO("pKResolutionsSettingsSize pointer %p = %d", config->pKResolutionsSettings_size, resolutionSize); + + INT_INFO("\n\n############### Dumping Video Resolutions Settings ############### \n\n"); + + for (int i = 0; i < resolutionSize; i++) { + dsVideoPortResolution_t *resolution = &(config->pKVideoPortResolutionsSettings[i]); + INT_INFO("resolution->name = %s", resolution->name); + INT_INFO("resolution->pixelResolution= %d", resolution->pixelResolution); + INT_INFO("resolution->aspectRatio= %d", resolution->aspectRatio); + INT_INFO("resolution->stereoScopicMode= %d", resolution->stereoScopicMode); + INT_INFO("resolution->frameRate= %d", resolution->frameRate); + INT_INFO("resolution->interlaced= %d", resolution->interlaced); + } + + INT_INFO("\n ############### Dumping Video Port Configurations ############### \n"); + + for (int i = 0; i < configSize; i++) + { + const dsVideoPortTypeConfig_t *typeCfg = &(config->pKVideoPortConfigs[i]); + INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); + INT_INFO("typeCfg->name = %s", (typeCfg->name) ? typeCfg->name : "NULL"); + INT_INFO("typeCfg->dtcpSupported= %d", typeCfg->dtcpSupported); + INT_INFO("typeCfg->hdcpSupported = %d", typeCfg->hdcpSupported); + INT_INFO("typeCfg->restrictedResollution = %d", typeCfg->restrictedResollution); + INT_INFO("typeCfg->numSupportedResolutions= %lu", typeCfg->numSupportedResolutions); + + INT_INFO("typeCfg->supportedResolutions = %p", typeCfg->supportedResolutions); + INT_INFO("typeCfg->supportedResolutions->name = %s", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); + INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d", typeCfg->supportedResolutions->pixelResolution); + INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d", typeCfg->supportedResolutions->aspectRatio); + INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d", typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); + INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); + } + INT_INFO("\n############### Dumping Video Port Connections ###############\n"); + + for (int i = 0; i < portSize; i++) { + const dsVideoPortPortConfig_t *portCfg = &(config->pKVideoPortPorts[i]); + INT_INFO("portCfg->id.type = %d", portCfg->id.type); + INT_INFO("portCfg->id.index = %d", portCfg->id.index); + INT_INFO("portCfg->connectedAOP.type = %d", portCfg->connectedAOP.type); + INT_INFO("portCfg->connectedAOP.index = %d", portCfg->connectedAOP.index); + INT_INFO("portCfg->defaultResolution = %s", (portCfg->defaultResolution) ? portCfg->defaultResolution : "NULL"); + } + } + else + { + INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); + } + INT_INFO("\n=============== Dump VideoPort Configs done ===============\n"); + INT_INFO("Exit function"); +} + +static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s video port config size: %d\n", configType, size); + return -1; + } + + allocatedVideoPortConfigs = (dsVideoPortTypeConfig_t*)malloc(size * sizeof(dsVideoPortTypeConfig_t)); + if (allocatedVideoPortConfigs == NULL) { + INT_ERROR("Failed to allocate memory for %s video port configs\n", configType); + return -1; + } + + memcpy(allocatedVideoPortConfigs, source, size * sizeof(dsVideoPortTypeConfig_t)); + videoPortConfiguration.pKVideoPortConfigs = allocatedVideoPortConfigs; + INT_INFO("Allocated and copied %d video port configs (%s)", size, configType); + return size; +} + +static int allocateAndCopyVideoPortPorts(const dsVideoPortPortConfig_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s video port port size: %d\n", configType, size); + return -1; + } + + allocatedVideoPortPorts = (dsVideoPortPortConfig_t*)malloc(size * sizeof(dsVideoPortPortConfig_t)); + if (allocatedVideoPortPorts == NULL) { + INT_ERROR("Failed to allocate memory for %s video port ports\n", configType); + return -1; + } + + memcpy(allocatedVideoPortPorts, source, size * sizeof(dsVideoPortPortConfig_t)); + videoPortConfiguration.pKVideoPortPorts = allocatedVideoPortPorts; + INT_INFO("Allocated and copied %d video port ports (%s)", size, configType); + return size; +} + +static int allocateAndCopyVideoPortResolutions(const dsVideoPortResolution_t* source, int size, const char* configType) +{ + if (size <= 0) { + INT_ERROR("Invalid %s video port resolution size: %d\n", configType, size); + return -1; + } + + allocatedVideoPortResolutions = (dsVideoPortResolution_t*)malloc(size * sizeof(dsVideoPortResolution_t)); + if (allocatedVideoPortResolutions == NULL) { + INT_ERROR("Failed to allocate memory for %s video port resolutions\n", configType); + return -1; + } + + memcpy(allocatedVideoPortResolutions, source, size * sizeof(dsVideoPortResolution_t)); + videoPortConfiguration.pKVideoPortResolutionsSettings = allocatedVideoPortResolutions; + INT_INFO("Allocated and copied %d video port resolutions (%s)", size, configType); + return size; +} + +void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) +{ + int configSize = -1, portSize = -1, resolutionSize = -1; + + INT_INFO("Using '%s' config", dynamicVideoPortConfigs ? "dynamic" : "static"); + + if (NULL != dynamicVideoPortConfigs) + { + // Reading Video Port Type configs + configSize = (dynamicVideoPortConfigs->pKVideoPortConfigs_size) ? *(dynamicVideoPortConfigs->pKVideoPortConfigs_size) : -1; + configSize = allocateAndCopyVideoPortConfigs(dynamicVideoPortConfigs->pKVideoPortConfigs, configSize, "dynamic"); + + // Reading Video Port Port configs + portSize = (dynamicVideoPortConfigs->pKVideoPortPorts_size) ? *(dynamicVideoPortConfigs->pKVideoPortPorts_size) : -1; + portSize = allocateAndCopyVideoPortPorts(dynamicVideoPortConfigs->pKVideoPortPorts, portSize, "dynamic"); + + // Reading Video Port Resolutions + resolutionSize = (dynamicVideoPortConfigs->pKResolutionsSettings_size) ? *(dynamicVideoPortConfigs->pKResolutionsSettings_size) : -1; + resolutionSize = allocateAndCopyVideoPortResolutions(dynamicVideoPortConfigs->pKVideoPortResolutionsSettings, resolutionSize, "dynamic"); + + // Reading Default Resolution Index + if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { + g_defaultResIndex = *(dynamicVideoPortConfigs->pKDefaultResIndex); + videoPortConfiguration.pKDefaultResIndex = &g_defaultResIndex; + INT_INFO("Read default resolution index: %d (dynamic)", g_defaultResIndex); + } else { + INT_INFO("Default resolution index not available in dynamic config"); + } + } + else { + // Using static configuration + configSize = dsUTL_DIM(kConfigs); + configSize = allocateAndCopyVideoPortConfigs(kConfigs, configSize, "static"); + + portSize = dsUTL_DIM(kPorts); + portSize = allocateAndCopyVideoPortPorts(kPorts, portSize, "static"); + + resolutionSize = dsUTL_DIM(kResolutions); + resolutionSize = allocateAndCopyVideoPortResolutions(kResolutions, resolutionSize, "static"); + + // Using static default resolution index + g_defaultResIndex = kDefaultResIndex; + videoPortConfiguration.pKDefaultResIndex = &g_defaultResIndex; + INT_INFO("Using static default resolution index: %d", g_defaultResIndex); + } + + // Store sizes for getter functions + g_videoPortConfigSize = configSize; + g_videoPortPortSize = portSize; + g_videoPortResolutionSize = resolutionSize; + + INT_INFO("VideoPort Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d] Resolutions[%p] ResolutionSize[%d] DefaultResIndex[%d]", + videoPortConfiguration.pKVideoPortConfigs, + configSize, + videoPortConfiguration.pKVideoPortPorts, + portSize, + videoPortConfiguration.pKVideoPortResolutionsSettings, + resolutionSize, + g_defaultResIndex); + dumpconfig(&videoPortConfiguration); +} + +// Getter functions for use across srv code +void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) +{ + if (outConfigSize != NULL) { + *outConfigSize = g_videoPortConfigSize; + } + if (outConfigs != NULL) { + *outConfigs = videoPortConfiguration.pKVideoPortConfigs; + } +} + +void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) +{ + if (outPortSize != NULL) { + *outPortSize = g_videoPortPortSize; + } + if (outPorts != NULL) { + *outPorts = videoPortConfiguration.pKVideoPortPorts; + } +} + +void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) +{ + if (outResolutionSize != NULL) { + *outResolutionSize = g_videoPortResolutionSize; + } + if (outResolutions != NULL) { + *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; + } +} + +int dsGetDefaultResolutionIndex(void) +{ + return g_defaultResIndex; +} + +/** @} */ +/** @} */ From e3b7b2b759ccaf79565f9c195b0b78c3de0a16e1 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 17 Feb 2026 06:04:50 +0000 Subject: [PATCH 50/66] Added missing dsConfigs.c file --- rpc/srv/dsConfigs.c | 168 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 rpc/srv/dsConfigs.c diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c new file mode 100644 index 00000000..eca3c7dd --- /dev/null +++ b/rpc/srv/dsConfigs.c @@ -0,0 +1,168 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2016 RDK Management + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +/** +* @defgroup devicesettings +* @{ +* @defgroup rpc +* @{ +**/ + +#include +#include +#include +#include +#include "dsserverlogger.h" +#include "dsAudioConfig.h" +#include "dsVideoPortConfig.h" +#include "dsVideoDeviceConfig.h" + +#ifndef RDK_DSHAL_NAME +#define RDK_DSHAL_NAME "libdshal.so" +#endif + +#define DEVICE_CAPABILITY_VIDEO_PORT 0x01 +#define DEVICE_CAPABILITY_AUDIO_PORT 0x02 +#define DEVICE_CAPABILITY_VIDEO_DEVICE 0x04 +#define DEVICE_CAPABILITY_FRONT_PANEL 0x08 + +typedef struct { + const char* name; + void** dataptr; +} dlSymbolLookup_t; + + +static int LoadDLSymbols(void* pDLHandle, const dlSymbolLookup_t* symbols, int numberOfSymbols) +{ + int currentSymbols = 0; + int isAllSymbolsLoaded = 0; + + if ((NULL == pDLHandle) || (NULL == symbols)) { + INT_ERROR("Invalid DL Handle or symbolsPtr"); + return 0; + } + + INT_INFO("numberOfSymbols = %d", numberOfSymbols); + for (int i = 0; i < numberOfSymbols; i++) { + if ((NULL == symbols[i].dataptr) || (NULL == symbols[i].name)) { + INT_ERROR("Invalid symbol entry at index [%d]", i); + continue; + } + *(symbols[i].dataptr) = dlsym(pDLHandle, symbols[i].name); + if (NULL == *(symbols[i].dataptr)) { + INT_ERROR("[%s] is not defined", symbols[i].name); + } + else { + currentSymbols++; + INT_INFO("[%s] is defined and loaded, data[%p]", symbols[i].name, *(symbols[i].dataptr)); + } + } + isAllSymbolsLoaded = (numberOfSymbols) ? (currentSymbols == numberOfSymbols) : 0; + return isAllSymbolsLoaded; +} + +static void loadDeviceCapabilities(unsigned int capabilityType) +{ + void* pDLHandle = NULL; + int isSymbolsLoaded = 0; + + INT_INFO("Entering capabilityType = 0x%08X", capabilityType); + dlerror(); /* clear old error */ + pDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + INT_INFO("DL Instance '%s'", (NULL == pDLHandle ? "NULL" : "Valid")); + + /* Audio Port Config */ + if (DEVICE_CAPABILITY_AUDIO_PORT & capabilityType) { + audioConfigs_t dynamicAudioConfigs; + memset(&dynamicAudioConfigs, 0, sizeof(audioConfigs_t)); + + dlSymbolLookup_t audioConfigSymbols[] = { + {"kAudioConfigs", (void**)&dynamicAudioConfigs.pKAudioConfigs}, + {"kAudioPorts", (void**)&dynamicAudioConfigs.pKAudioPorts}, + {"kAudioConfigs_size", (void**)&dynamicAudioConfigs.pKConfigSize}, + {"kAudioPorts_size", (void**)&dynamicAudioConfigs.pKPortSize} + }; + + isSymbolsLoaded = 0; + if (NULL != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, audioConfigSymbols, + sizeof(audioConfigSymbols)/sizeof(dlSymbolLookup_t)); + } + dsLoadAudioOutputPortConfig(isSymbolsLoaded ? &dynamicAudioConfigs : NULL); + } + + /* Video Port Config */ + if (DEVICE_CAPABILITY_VIDEO_PORT & capabilityType) { + videoPortConfigs_t dynamicVideoPortConfigs; + memset(&dynamicVideoPortConfigs, 0, sizeof(videoPortConfigs_t)); + + dlSymbolLookup_t videoPortConfigSymbols[] = { + {"kVideoPortConfigs", (void**)&dynamicVideoPortConfigs.pKVideoPortConfigs}, + {"kVideoPortConfigs_size", (void**)&dynamicVideoPortConfigs.pKVideoPortConfigs_size}, + {"kVideoPortPorts", (void**)&dynamicVideoPortConfigs.pKVideoPortPorts}, + {"kVideoPortPorts_size", (void**)&dynamicVideoPortConfigs.pKVideoPortPorts_size}, + {"kResolutionsSettings", (void**)&dynamicVideoPortConfigs.pKVideoPortResolutionsSettings}, + {"kResolutionsSettings_size", (void**)&dynamicVideoPortConfigs.pKResolutionsSettings_size}, + {"kDefaultResIndex", (void**)&dynamicVideoPortConfigs.pKDefaultResIndex} + }; + + isSymbolsLoaded = 0; + if (NULL != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoPortConfigSymbols, + sizeof(videoPortConfigSymbols)/sizeof(dlSymbolLookup_t)); + } + dsLoadVideoOutputPortConfig(isSymbolsLoaded ? &dynamicVideoPortConfigs : NULL); + } + + /* Video Device Config */ + if (DEVICE_CAPABILITY_VIDEO_DEVICE & capabilityType) { + videoDeviceConfig_t dynamicVideoDeviceConfigs; + memset(&dynamicVideoDeviceConfigs, 0, sizeof(videoDeviceConfig_t)); + + dlSymbolLookup_t videoDeviceConfigSymbols[] = { + {"kVideoDeviceConfigs", (void**)&dynamicVideoDeviceConfigs.pKVideoDeviceConfigs}, + {"kVideoDeviceConfigs_size", (void**)&dynamicVideoDeviceConfigs.pKVideoDeviceConfigs_size} + }; + + isSymbolsLoaded = 0; + if (NULL != pDLHandle) { + isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoDeviceConfigSymbols, + sizeof(videoDeviceConfigSymbols)/sizeof(dlSymbolLookup_t)); + } + dsLoadVideoDeviceConfig(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : NULL); + } + + if (NULL != pDLHandle) { + dlclose(pDLHandle); + pDLHandle = NULL; + } + INT_INFO("Exiting ..."); +} + +void dsLoadConfigs(void) +{ + INT_INFO("Enter function"); + loadDeviceCapabilities(DEVICE_CAPABILITY_VIDEO_PORT | + DEVICE_CAPABILITY_AUDIO_PORT | + DEVICE_CAPABILITY_VIDEO_DEVICE); + INT_INFO("Exit function"); +} + +/** @} */ +/** @} */ From f8c568ee0a8fa332efe8a875ea879cece3424ec0 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 17 Feb 2026 12:55:02 +0000 Subject: [PATCH 51/66] addressed internal review comments and cleanup code. --- rpc/srv/dsAudioConfig.c | 95 +++++++++++--------- rpc/srv/dsVideoDeviceConfig.c | 49 ++++++----- rpc/srv/dsVideoPortConfig.c | 158 +++++++++++++++++++--------------- 3 files changed, 168 insertions(+), 134 deletions(-) diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index 4e789380..64069919 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -33,19 +33,15 @@ typedef struct audioConfigs { - const dsAudioTypeConfig_t *pKAudioConfigs; - const dsAudioPortConfig_t *pKAudioPorts; + dsAudioTypeConfig_t *pKAudioConfigs; + dsAudioPortConfig_t *pKAudioPorts; int *pKConfigSize; int *pKPortSize; }audioConfigs_t; audioConfigs_t audioConfiguration = {0}; -static dsAudioTypeConfig_t* allocatedAudioConfigs = NULL; -static dsAudioPortConfig_t* allocatedAudioPorts = NULL; -static int g_audioConfigSize = -1; -static int g_audioPortSize = -1; -void dumpconfig(audioConfigs_t *config) +void audioDumpconfig(audioConfigs_t *config) { if (nullptr == config) { INT_ERROR("Audio config is NULL"); @@ -93,53 +89,50 @@ void dumpconfig(audioConfigs_t *config) INT_INFO("\n=============== Dump Audio Configs done ===============\n"); } -static int allocateAndCopyAudioConfigs(const dsAudioTypeConfig_t* source, int size, const char* configType) +static int allocateAndCopyAudioConfigs(const dsAudioTypeConfig_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s config size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s config numElements: %d\n", configType, numElements); return -1; } - allocatedAudioConfigs = (dsAudioTypeConfig_t*)malloc(size * sizeof(dsAudioTypeConfig_t)); - if (allocatedAudioConfigs == NULL) { + audioConfiguration.pKAudioConfigs = (dsAudioTypeConfig_t*)malloc(numElements * sizeof(dsAudioTypeConfig_t)); + if (audioConfiguration.pKAudioConfigs == NULL) { INT_ERROR("Failed to allocate memory for %s audio configs\n", configType); return -1; } - memcpy(allocatedAudioConfigs, source, size * sizeof(dsAudioTypeConfig_t)); - audioConfiguration.pKAudioConfigs = allocatedAudioConfigs; - INT_INFO("Allocated and copied %d audio configs (%s)", size, configType); - return size; + memcpy(audioConfiguration.pKAudioConfigs, source, numElements * sizeof(dsAudioTypeConfig_t)); + INT_INFO("Allocated and copied %d audio configs (%s)", numElements, configType); + return numElements; } -static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int size, const char* configType) +static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s port size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s port numElements: %d\n", configType, numElements); return -1; } - allocatedAudioPorts = (dsAudioPortConfig_t*)malloc(size * sizeof(dsAudioPortConfig_t)); - if (allocatedAudioPorts == NULL) { + audioConfiguration.pKAudioPorts = (dsAudioPortConfig_t*)malloc(numElements * sizeof(dsAudioPortConfig_t)); + if (audioConfiguration.pKAudioPorts == NULL) { INT_ERROR("Failed to allocate memory for %s audio ports\n", configType); - // Free previously allocated configs if allocation fails - if (allocatedAudioConfigs != NULL) { - free(allocatedAudioConfigs); - allocatedAudioConfigs = NULL; - audioConfiguration.pKAudioConfigs = NULL; - } return -1; } - memcpy(allocatedAudioPorts, source, size * sizeof(dsAudioPortConfig_t)); - audioConfiguration.pKAudioPorts = allocatedAudioPorts; - INT_INFO("Allocated and copied %d audio ports (%s)", size, configType); - return size; + memcpy(audioConfiguration.pKAudioPorts, source, numElements * sizeof(dsAudioPortConfig_t)); + INT_INFO("Allocated and copied %d audio ports (%s)", numElements, configType); + return numElements; } void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) { int configSize = -1, portSize = -1; + int ret = -1; INT_INFO("Using '%s' config", dynamicAudioConfigs ? "dynamic" : "static"); @@ -147,38 +140,54 @@ void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) { // Reading Audio type configs configSize = (dynamicAudioConfigs->pKConfigSize) ? *(dynamicAudioConfigs->pKConfigSize) : -1; - configSize = allocateAndCopyAudioConfigs(dynamicAudioConfigs->pKAudioConfigs, configSize, "dynamic"); + ret = allocateAndCopyAudioConfigs(dynamicAudioConfigs->pKAudioConfigs, configSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } // Reading Audio port configs portSize = (dynamicAudioConfigs->pKPortSize) ? *(dynamicAudioConfigs->pKPortSize) : -1; - portSize = allocateAndCopyAudioPorts(dynamicAudioConfigs->pKAudioPorts, portSize, "dynamic"); + ret = allocateAndCopyAudioPorts(dynamicAudioConfigs->pKAudioPorts, portSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } } else { // Using static configuration configSize = dsUTL_DIM(kConfigs); - configSize = allocateAndCopyAudioConfigs(kConfigs, configSize, "static"); - + ret = allocateAndCopyAudioConfigs(kConfigs, configSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + portSize = dsUTL_DIM(kPorts); - portSize = allocateAndCopyAudioPorts(kPorts, portSize, "static"); + ret = allocateAndCopyAudioPorts(kPorts, portSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } } // Store sizes for getter functions - g_audioConfigSize = configSize; - g_audioPortSize = portSize; + *(audioConfiguration.pKConfigSize) = configSize; + *(audioConfiguration.pKPortSize) = portSize; INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]", audioConfiguration.pKAudioConfigs, - configSize, + *(audioConfiguration.pKConfigSize), audioConfiguration.pKAudioPorts, - portSize); - dumpconfig(&audioConfiguration); + *(audioConfiguration.pKPortSize)); + audioDumpconfig(&audioConfiguration); } // Getter functions for use across srv code void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = g_audioConfigSize; + *outConfigSize = *(audioConfiguration.pKConfigSize); } if (outConfigs != NULL) { *outConfigs = audioConfiguration.pKAudioConfigs; @@ -188,7 +197,7 @@ void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outCo void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts) { if (outPortSize != NULL) { - *outPortSize = g_audioPortSize; + *outPortSize = *(audioConfiguration.pKPortSize); } if (outPorts != NULL) { *outPorts = audioConfiguration.pKAudioPorts; diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index 8835559b..98ba96c9 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -38,12 +38,10 @@ typedef struct videoDeviceConfig }videoDeviceConfig_t; static videoDeviceConfig_t videoDeviceConfiguration = {0}; -static dsVideoConfig_t* allocatedVideoDeviceConfigs = NULL; -static int g_videoDeviceConfigSize = -1; -void dumpconfig(videoDeviceConfig_t *config) +void videoDeviceDumpconfig(videoDeviceConfig_t *config) { - if (nullptr == config) { + if (NULL == config) { INT_ERROR("Video config is NULL"); return; } @@ -54,7 +52,7 @@ void dumpconfig(videoDeviceConfig_t *config) INT_INFO("\n=============== Starting to Dump VideoDevice Configs ===============\n"); - if( nullptr != config->pKVideoDeviceConfigs ) + if( NULL != config->pKVideoDeviceConfigs ) { int configSize = (config->pKVideoDeviceConfigs_size) ? *(config->pKVideoDeviceConfigs_size) : -1; INT_INFO("pKVideoDeviceConfigs = %p", config->pKVideoDeviceConfigs); @@ -75,28 +73,29 @@ void dumpconfig(videoDeviceConfig_t *config) INT_INFO("\n=============== Dump VideoDevice Configs done ===============\n"); } -static int allocateAndCopyVideoDeviceConfigs(const dsVideoConfig_t* source, int size, const char* configType) +static int allocateAndCopyVideoDeviceConfigs(const dsVideoConfig_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s video device config size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s video device config numElements: %d\n", configType, numElements); return -1; } - allocatedVideoDeviceConfigs = (dsVideoConfig_t*)malloc(size * sizeof(dsVideoConfig_t)); - if (allocatedVideoDeviceConfigs == NULL) { + videoDeviceConfiguration.pKVideoDeviceConfigs = (dsVideoConfig_t*)malloc(numElements * sizeof(dsVideoConfig_t)); + if (videoDeviceConfiguration.pKVideoDeviceConfigs == NULL) { INT_ERROR("Failed to allocate memory for %s video device configs\n", configType); return -1; } - memcpy(allocatedVideoDeviceConfigs, source, size * sizeof(dsVideoConfig_t)); - videoDeviceConfiguration.pKVideoDeviceConfigs = allocatedVideoDeviceConfigs; - INT_INFO("Allocated and copied %d video device configs (%s)", size, configType); - return size; + memcpy(videoDeviceConfiguration.pKVideoDeviceConfigs, source, numElements * sizeof(dsVideoConfig_t)); + INT_INFO("Allocated and copied %d video device configs (%s)", numElements, configType); + return numElements; } void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) { - int configSize = -1; + int configSize = -1, ret = -1; INT_INFO("Using '%s' config", dynamicVideoDeviceConfigs ? "dynamic" : "static"); @@ -104,28 +103,36 @@ void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfig { // Reading Video Device configs configSize = (dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) ? *(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) : -1; - configSize = allocateAndCopyVideoDeviceConfigs(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs, configSize, "dynamic"); + ret = allocateAndCopyVideoDeviceConfigs(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs, configSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } } else { // Using static configuration configSize = dsUTL_DIM(kConfigs); - configSize = allocateAndCopyVideoDeviceConfigs(kConfigs, configSize, "static"); + ret = allocateAndCopyVideoDeviceConfigs(kConfigs, configSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } } // Store size for getter functions - g_videoDeviceConfigSize = configSize; + *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) = configSize; INT_INFO("VideoDevice Config[%p] ConfigSize[%d]", videoDeviceConfiguration.pKVideoDeviceConfigs, - configSize); - dumpconfig(&videoDeviceConfiguration); + *(videoDeviceConfiguration.pKVideoDeviceConfigs_size)); + videoDeviceDumpconfig(&videoDeviceConfiguration); } // Getter functions for use across srv code void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = g_videoDeviceConfigSize; + *outConfigSize = *(videoDeviceConfiguration.pKVideoDeviceConfigs_size); } if (outConfigs != NULL) { *outConfigs = videoDeviceConfiguration.pKVideoDeviceConfigs; diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index 56b80c27..a6f0b080 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -33,9 +33,9 @@ typedef struct videoPortConfigs { - const dsVideoPortTypeConfig_t *pKVideoPortConfigs; + dsVideoPortTypeConfig_t *pKVideoPortConfigs; int *pKVideoPortConfigs_size; - const dsVideoPortPortConfig_t *pKVideoPortPorts; + dsVideoPortPortConfig_t *pKVideoPortPorts; int *pKVideoPortPorts_size; dsVideoPortResolution_t *pKVideoPortResolutionsSettings; int *pKResolutionsSettings_size; @@ -43,17 +43,10 @@ typedef struct videoPortConfigs }videoPortConfigs_t; static videoPortConfigs_t videoPortConfiguration = {0}; -static dsVideoPortTypeConfig_t* allocatedVideoPortConfigs = NULL; -static dsVideoPortPortConfig_t* allocatedVideoPortPorts = NULL; -static dsVideoPortResolution_t* allocatedVideoPortResolutions = NULL; -static int g_videoPortConfigSize = -1; -static int g_videoPortPortSize = -1; -static int g_videoPortResolutionSize = -1; -static int g_defaultResIndex = -1; -void dumpconfig(videoPortConfigs_t *config) +void videoPortDumpconfig(videoPortConfigs_t *config) { - if (nullptr == config) { + if (NULL == config) { INT_ERROR("Video config is NULL"); return; } @@ -127,66 +120,68 @@ void dumpconfig(videoPortConfigs_t *config) INT_INFO("Exit function"); } -static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source, int size, const char* configType) +static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s video port config size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s video port config numElements: %d\n", configType, numElements); return -1; } - allocatedVideoPortConfigs = (dsVideoPortTypeConfig_t*)malloc(size * sizeof(dsVideoPortTypeConfig_t)); - if (allocatedVideoPortConfigs == NULL) { + videoPortConfiguration.pKVideoPortConfigs = (dsVideoPortTypeConfig_t*)malloc(numElements * sizeof(dsVideoPortTypeConfig_t)); + if (videoPortConfiguration.pKVideoPortConfigs == NULL) { INT_ERROR("Failed to allocate memory for %s video port configs\n", configType); return -1; } - memcpy(allocatedVideoPortConfigs, source, size * sizeof(dsVideoPortTypeConfig_t)); - videoPortConfiguration.pKVideoPortConfigs = allocatedVideoPortConfigs; - INT_INFO("Allocated and copied %d video port configs (%s)", size, configType); - return size; + memcpy(videoPortConfiguration.pKVideoPortConfigs, source, numElements * sizeof(dsVideoPortTypeConfig_t)); + return numElements; } -static int allocateAndCopyVideoPortPorts(const dsVideoPortPortConfig_t* source, int size, const char* configType) +static int allocateAndCopyVideoPortPorts(const dsVideoPortPortConfig_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s video port port size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s video port port numElements: %d\n", configType, numElements); return -1; } - allocatedVideoPortPorts = (dsVideoPortPortConfig_t*)malloc(size * sizeof(dsVideoPortPortConfig_t)); - if (allocatedVideoPortPorts == NULL) { + videoPortConfiguration.pKVideoPortPorts = (dsVideoPortPortConfig_t*)malloc(numElements * sizeof(dsVideoPortPortConfig_t)); + if (videoPortConfiguration.pKVideoPortPorts == NULL) { INT_ERROR("Failed to allocate memory for %s video port ports\n", configType); return -1; } - memcpy(allocatedVideoPortPorts, source, size * sizeof(dsVideoPortPortConfig_t)); - videoPortConfiguration.pKVideoPortPorts = allocatedVideoPortPorts; - INT_INFO("Allocated and copied %d video port ports (%s)", size, configType); - return size; + memcpy(videoPortConfiguration.pKVideoPortPorts, source, numElements * sizeof(dsVideoPortPortConfig_t)); + INT_INFO("Allocated and copied %d video port ports (%s)", numElements, configType); + return numElements; } -static int allocateAndCopyVideoPortResolutions(const dsVideoPortResolution_t* source, int size, const char* configType) +static int allocateAndCopyVideoPortResolutions(const dsVideoPortResolution_t* source, int numElements, bool isDynamic) { - if (size <= 0) { - INT_ERROR("Invalid %s video port resolution size: %d\n", configType, size); + const char* configType = isDynamic ? "dynamic" : "static"; + + if (numElements <= 0) { + INT_ERROR("Invalid %s video port resolution numElements: %d\n", configType, numElements); return -1; } - allocatedVideoPortResolutions = (dsVideoPortResolution_t*)malloc(size * sizeof(dsVideoPortResolution_t)); - if (allocatedVideoPortResolutions == NULL) { + videoPortConfiguration.pKVideoPortResolutionsSettings = (dsVideoPortResolution_t*)malloc(numElements * sizeof(dsVideoPortResolution_t)); + if (videoPortConfiguration.pKVideoPortResolutionsSettings == NULL) { INT_ERROR("Failed to allocate memory for %s video port resolutions\n", configType); return -1; } - memcpy(allocatedVideoPortResolutions, source, size * sizeof(dsVideoPortResolution_t)); - videoPortConfiguration.pKVideoPortResolutionsSettings = allocatedVideoPortResolutions; - INT_INFO("Allocated and copied %d video port resolutions (%s)", size, configType); - return size; + memcpy(videoPortConfiguration.pKVideoPortResolutionsSettings, source, numElements * sizeof(dsVideoPortResolution_t)); + INT_INFO("Allocated and copied %d video port resolutions (%s)", numElements, configType); + return numElements; } void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) { - int configSize = -1, portSize = -1, resolutionSize = -1; + int configSize = -1, portSize = -1, resolutionSize = -1, ret = -1; INT_INFO("Using '%s' config", dynamicVideoPortConfigs ? "dynamic" : "static"); @@ -194,21 +189,31 @@ void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfi { // Reading Video Port Type configs configSize = (dynamicVideoPortConfigs->pKVideoPortConfigs_size) ? *(dynamicVideoPortConfigs->pKVideoPortConfigs_size) : -1; - configSize = allocateAndCopyVideoPortConfigs(dynamicVideoPortConfigs->pKVideoPortConfigs, configSize, "dynamic"); - + ret = allocateAndCopyVideoPortConfigs(dynamicVideoPortConfigs->pKVideoPortConfigs, configSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + // Reading Video Port Port configs portSize = (dynamicVideoPortConfigs->pKVideoPortPorts_size) ? *(dynamicVideoPortConfigs->pKVideoPortPorts_size) : -1; - portSize = allocateAndCopyVideoPortPorts(dynamicVideoPortConfigs->pKVideoPortPorts, portSize, "dynamic"); - + ret = allocateAndCopyVideoPortPorts(dynamicVideoPortConfigs->pKVideoPortPorts, portSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + // Reading Video Port Resolutions resolutionSize = (dynamicVideoPortConfigs->pKResolutionsSettings_size) ? *(dynamicVideoPortConfigs->pKResolutionsSettings_size) : -1; - resolutionSize = allocateAndCopyVideoPortResolutions(dynamicVideoPortConfigs->pKVideoPortResolutionsSettings, resolutionSize, "dynamic"); - + ret = allocateAndCopyVideoPortResolutions(dynamicVideoPortConfigs->pKVideoPortResolutionsSettings, resolutionSize, true); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } // Reading Default Resolution Index if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { - g_defaultResIndex = *(dynamicVideoPortConfigs->pKDefaultResIndex); - videoPortConfiguration.pKDefaultResIndex = &g_defaultResIndex; - INT_INFO("Read default resolution index: %d (dynamic)", g_defaultResIndex); + *(videoPortConfiguration.pKDefaultResIndex) = *(dynamicVideoPortConfigs->pKDefaultResIndex); + INT_INFO("Read default resolution index: %d (dynamic)", *(videoPortConfiguration.pKDefaultResIndex)); } else { INT_INFO("Default resolution index not available in dynamic config"); } @@ -216,41 +221,52 @@ void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfi else { // Using static configuration configSize = dsUTL_DIM(kConfigs); - configSize = allocateAndCopyVideoPortConfigs(kConfigs, configSize, "static"); - + ret = allocateAndCopyVideoPortConfigs(kConfigs, configSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + portSize = dsUTL_DIM(kPorts); - portSize = allocateAndCopyVideoPortPorts(kPorts, portSize, "static"); - + ret = allocateAndCopyVideoPortPorts(kPorts, portSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + resolutionSize = dsUTL_DIM(kResolutions); - resolutionSize = allocateAndCopyVideoPortResolutions(kResolutions, resolutionSize, "static"); - + ret = allocateAndCopyVideoPortResolutions(kResolutions, resolutionSize, false); + if(ret == -1) + { + INT_ERROR("failed to create dynamic memory\n"); + } + // Using static default resolution index - g_defaultResIndex = kDefaultResIndex; - videoPortConfiguration.pKDefaultResIndex = &g_defaultResIndex; - INT_INFO("Using static default resolution index: %d", g_defaultResIndex); + *(videoPortConfiguration.pKDefaultResIndex) = kDefaultResIndex; + INT_INFO("Using static default resolution index: %d", *(videoPortConfiguration.pKDefaultResIndex)); } // Store sizes for getter functions - g_videoPortConfigSize = configSize; - g_videoPortPortSize = portSize; - g_videoPortResolutionSize = resolutionSize; + *(videoPortConfiguration.pKVideoPortConfigs_size) = configSize; + *(videoPortConfiguration.pKVideoPortPorts_size) = portSize; + *(videoPortConfiguration.pKResolutionsSettings_size) = resolutionSize; INT_INFO("VideoPort Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d] Resolutions[%p] ResolutionSize[%d] DefaultResIndex[%d]", videoPortConfiguration.pKVideoPortConfigs, - configSize, + *(videoPortConfiguration.pKVideoPortConfigs_size), videoPortConfiguration.pKVideoPortPorts, - portSize, + *(videoPortConfiguration.pKVideoPortPorts_size), videoPortConfiguration.pKVideoPortResolutionsSettings, - resolutionSize, - g_defaultResIndex); - dumpconfig(&videoPortConfiguration); + *(videoPortConfiguration.pKResolutionsSettings_size), + *(videoPortConfiguration.pKDefaultResIndex)); + videoPortDumpconfig(&videoPortConfiguration); } // Getter functions for use across srv code void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = g_videoPortConfigSize; + *outConfigSize = *(videoPortConfiguration.pKVideoPortConfigs_size); } if (outConfigs != NULL) { *outConfigs = videoPortConfiguration.pKVideoPortConfigs; @@ -260,7 +276,7 @@ void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) { if (outPortSize != NULL) { - *outPortSize = g_videoPortPortSize; + *outPortSize = *(videoPortConfiguration.pKVideoPortPorts_size); } if (outPorts != NULL) { *outPorts = videoPortConfiguration.pKVideoPortPorts; @@ -270,16 +286,18 @@ void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) { if (outResolutionSize != NULL) { - *outResolutionSize = g_videoPortResolutionSize; + *outResolutionSize = *(videoPortConfiguration.pKResolutionsSettings_size); } if (outResolutions != NULL) { *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; } } -int dsGetDefaultResolutionIndex(void) +void dsGetDefaultResolutionIndex(int* outDefaultIndex) { - return g_defaultResIndex; + if (outDefaultIndex != NULL) { + *outDefaultIndex = *(videoPortConfiguration.pKDefaultResIndex); + } } /** @} */ From 901a227dae995e033a59ff91b0728c0ac6b435c7 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 18 Feb 2026 07:03:22 +0000 Subject: [PATCH 52/66] fix build linking issue --- rpc/srv/dsAudioConfig.c | 8 ++++++++ rpc/srv/dsConfigs.c | 8 ++++++++ rpc/srv/dsVideoDeviceConfig.c | 8 ++++++++ rpc/srv/dsVideoPortConfig.c | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index 64069919..b880a2a0 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -31,6 +31,10 @@ #include "dsTypes.h" #include "dsAudioSettings.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct audioConfigs { dsAudioTypeConfig_t *pKAudioConfigs; @@ -204,5 +208,9 @@ void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPort } } +#ifdef __cplusplus +} +#endif + /** @} */ /** @} */ diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c index eca3c7dd..6aedbd61 100644 --- a/rpc/srv/dsConfigs.c +++ b/rpc/srv/dsConfigs.c @@ -33,6 +33,10 @@ #include "dsVideoPortConfig.h" #include "dsVideoDeviceConfig.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef RDK_DSHAL_NAME #define RDK_DSHAL_NAME "libdshal.so" #endif @@ -164,5 +168,9 @@ void dsLoadConfigs(void) INT_INFO("Exit function"); } +#ifdef __cplusplus +} +#endif + /** @} */ /** @} */ diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index 98ba96c9..32f8d0dd 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -31,6 +31,10 @@ #include "dsTypes.h" #include "dsVideoDeviceSettings.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct videoDeviceConfig { dsVideoConfig_t *pKVideoDeviceConfigs; @@ -139,5 +143,9 @@ void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) } } +#ifdef __cplusplus +} +#endif + /** @} */ /** @} */ diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index a6f0b080..14bf6a88 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -31,6 +31,10 @@ #include "dsTypes.h" #include "dsVideoPortSettings.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct videoPortConfigs { dsVideoPortTypeConfig_t *pKVideoPortConfigs; @@ -300,5 +304,9 @@ void dsGetDefaultResolutionIndex(int* outDefaultIndex) } } +#ifdef __cplusplus +} +#endif + /** @} */ /** @} */ From ef6597aa9aed2dbdfaa0e77d475714c819cdcaa2 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 19 Feb 2026 12:28:27 +0000 Subject: [PATCH 53/66] Fix run time errors. --- rpc/srv/dsAudioConfig.c | 32 ++++++++++++----- rpc/srv/dsMgr.c | 8 ++--- rpc/srv/dsVideoDeviceConfig.c | 13 +++++-- rpc/srv/dsVideoPortConfig.c | 65 +++++++++++++++++++++++++++++------ 4 files changed, 91 insertions(+), 27 deletions(-) diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index b880a2a0..caefb12a 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -43,7 +43,7 @@ typedef struct audioConfigs int *pKPortSize; }audioConfigs_t; -audioConfigs_t audioConfiguration = {0}; +static audioConfigs_t audioConfiguration; void audioDumpconfig(audioConfigs_t *config) { @@ -175,15 +175,29 @@ void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) } } - // Store sizes for getter functions - *(audioConfiguration.pKConfigSize) = configSize; - *(audioConfiguration.pKPortSize) = portSize; - + INT_INFO("Store sizes configSize =%d, portSize =%d\n", configSize, portSize); + audioConfiguration.pKConfigSize = (int*)malloc(sizeof(int)); + if (audioConfiguration.pKConfigSize == NULL) { + INT_ERROR("Failed to allocate memory for pKConfigSize\n"); + } + else { + *(audioConfiguration.pKConfigSize) = configSize; + INT_INFO("Store sizes *(audioConfiguration.pKConfigSize) =%d\n", *(audioConfiguration.pKConfigSize)); + } + audioConfiguration.pKPortSize = (int*)malloc(sizeof(int)); + if (audioConfiguration.pKPortSize == NULL) { + INT_ERROR("Failed to allocate memory for pKPortSize\n"); + } + else { + *(audioConfiguration.pKPortSize) = configSize; + INT_INFO("Store sizes *(audioConfiguration.pKPortSize) =%d\n", *(audioConfiguration.pKPortSize)); + } + INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]", - audioConfiguration.pKAudioConfigs, - *(audioConfiguration.pKConfigSize), - audioConfiguration.pKAudioPorts, - *(audioConfiguration.pKPortSize)); + audioConfiguration.pKAudioConfigs ? audioConfiguration.pKAudioConfigs : NULL, + audioConfiguration.pKConfigSize ? *(audioConfiguration.pKConfigSize) : -1, + audioConfiguration.pKAudioPorts? audioConfiguration.pKAudioPorts : NULL, + audioConfiguration.pKPortSize ? *(audioConfiguration.pKPortSize) : -1); audioDumpconfig(&audioConfiguration); } diff --git a/rpc/srv/dsMgr.c b/rpc/srv/dsMgr.c index 3bf6e2a5..b4217861 100755 --- a/rpc/srv/dsMgr.c +++ b/rpc/srv/dsMgr.c @@ -114,7 +114,9 @@ IARM_Result_t dsMgr_init() profileType = searchRdkProfile(); INT_INFO("[%s]: profileType=%d\r\n", __FUNCTION__, profileType); - device::HostPersistence::getInstance().load(); + INT_INFO("[%s]: Loading device configurations\r\n", __FUNCTION__); + dsLoadConfigs(); + device::HostPersistence::getInstance().load(); dsServer_Rdklogger_Init(); dsHostInit(); dsDisplayMgr_init(); @@ -125,9 +127,7 @@ IARM_Result_t dsMgr_init() dsHostMgr_init(); dsHdmiInMgr_init(); dsCompositeInMgr_init(); - - INT_INFO("[%s]: Loading device configurations\r\n", __FUNCTION__); - dsLoadConfigs(); + return ret; } diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index 32f8d0dd..ea5199b4 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -41,7 +41,7 @@ typedef struct videoDeviceConfig int *pKVideoDeviceConfigs_size; }videoDeviceConfig_t; -static videoDeviceConfig_t videoDeviceConfiguration = {0}; +static videoDeviceConfig_t videoDeviceConfiguration; void videoDeviceDumpconfig(videoDeviceConfig_t *config) { @@ -123,8 +123,15 @@ void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfig } } - // Store size for getter functions - *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) = configSize; + INT_INFO("Store sizes configSize =%d\n", configSize); + videoDeviceConfiguration.pKVideoDeviceConfigs_size = (int*)malloc(sizeof(int)); + if (videoDeviceConfiguration.pKVideoDeviceConfigs_size == NULL) { + INT_ERROR("Failed to allocate memory for pKConfigSize\n"); + } + else { + *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) = configSize; + INT_INFO("Store sizes *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) =%d\n", *(videoDeviceConfiguration.pKVideoDeviceConfigs_size)); + } INT_INFO("VideoDevice Config[%p] ConfigSize[%d]", videoDeviceConfiguration.pKVideoDeviceConfigs, diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index 14bf6a88..8153fcf6 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -46,7 +46,7 @@ typedef struct videoPortConfigs int *pKDefaultResIndex; }videoPortConfigs_t; -static videoPortConfigs_t videoPortConfiguration = {0}; +static videoPortConfigs_t videoPortConfiguration; void videoPortDumpconfig(videoPortConfigs_t *config) { @@ -140,6 +140,7 @@ static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source } memcpy(videoPortConfiguration.pKVideoPortConfigs, source, numElements * sizeof(dsVideoPortTypeConfig_t)); + INT_INFO("Allocated and copied %d video port configs (%s)", numElements, configType); return numElements; } @@ -216,10 +217,18 @@ void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfi } // Reading Default Resolution Index if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { - *(videoPortConfiguration.pKDefaultResIndex) = *(dynamicVideoPortConfigs->pKDefaultResIndex); - INT_INFO("Read default resolution index: %d (dynamic)", *(videoPortConfiguration.pKDefaultResIndex)); + INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); + videoPortConfiguration.pKDefaultResIndex = (int*)malloc(sizeof(int)); + if (videoPortConfiguration.pKDefaultResIndex == NULL) { + INT_ERROR("Failed to allocate memory for pKConfigSize\n"); + } + else + { + *(videoPortConfiguration.pKDefaultResIndex) = *(dynamicVideoPortConfigs->pKDefaultResIndex); + INT_INFO("Store sizes *(videoPortConfiguration.pKDefaultResIndex) =%d (dynamic)\n", *(videoPortConfiguration.pKDefaultResIndex)); + } } else { - INT_INFO("Default resolution index not available in dynamic config"); + INT_INFO("Default pKDefaultResIndex not available in dynamic config"); } } else { @@ -246,15 +255,49 @@ void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfi } // Using static default resolution index - *(videoPortConfiguration.pKDefaultResIndex) = kDefaultResIndex; - INT_INFO("Using static default resolution index: %d", *(videoPortConfiguration.pKDefaultResIndex)); + if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { + INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); + videoPortConfiguration.pKDefaultResIndex = (int*)malloc(sizeof(int)); + if (videoPortConfiguration.pKDefaultResIndex == NULL) { + INT_ERROR("Failed to allocate memory for pKConfigSize\n"); + } + else + { + *(videoPortConfiguration.pKDefaultResIndex) = kDefaultResIndex; + INT_INFO("Store sizes *(videoPortConfiguration.pKDefaultResIndex) =%d (static)\n", *(videoPortConfiguration.pKDefaultResIndex)); + } + } } - // Store sizes for getter functions - *(videoPortConfiguration.pKVideoPortConfigs_size) = configSize; - *(videoPortConfiguration.pKVideoPortPorts_size) = portSize; - *(videoPortConfiguration.pKResolutionsSettings_size) = resolutionSize; - + INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); + videoPortConfiguration.pKVideoPortConfigs_size = (int*)malloc(sizeof(int)); + if (videoPortConfiguration.pKVideoPortConfigs_size == NULL) { + INT_ERROR("Failed to allocate memory for pKConfigSize\n"); + } + else + { + *(videoPortConfiguration.pKVideoPortConfigs_size) = configSize; + INT_INFO("Store sizes *(videoPortConfiguration.pKVideoPortConfigs_size) =%d\n", *(videoPortConfiguration.pKVideoPortConfigs_size)); + } + videoPortConfiguration.pKVideoPortPorts_size = (int*)malloc(sizeof(int)); + if (videoPortConfiguration.pKVideoPortPorts_size == NULL) { + INT_ERROR("Failed to allocate memory for pKPortSize\n"); + } + else + { + *(videoPortConfiguration.pKVideoPortPorts_size) = portSize; + INT_INFO("Store sizes *(videoPortConfiguration.pKVideoPortPorts_size) =%d\n", *(videoPortConfiguration.pKVideoPortPorts_size)); + } + videoPortConfiguration.pKResolutionsSettings_size = (int*)malloc(sizeof(int)); + if (videoPortConfiguration.pKResolutionsSettings_size == NULL) { + INT_ERROR("Failed to allocate memory for pKPortSize\n"); + } + else + { + *(videoPortConfiguration.pKResolutionsSettings_size) = resolutionSize; + INT_INFO("Store sizes *(videoPortConfiguration.pKResolutionsSettings_size) =%d\n", *(videoPortConfiguration.pKResolutionsSettings_size)); + } + INT_INFO("VideoPort Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d] Resolutions[%p] ResolutionSize[%d] DefaultResIndex[%d]", videoPortConfiguration.pKVideoPortConfigs, *(videoPortConfiguration.pKVideoPortConfigs_size), From 2a0902b552cabf62e6292c5da2701c6944173a15 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 23 Feb 2026 15:59:58 +0000 Subject: [PATCH 54/66] Add free() funcation while dsTerm and addressing review comments. --- rpc/include/dsVideoPortConfig.h | 2 +- rpc/srv/dsAudioConfig.c | 164 +++++++++-------- rpc/srv/dsConfigs.c | 20 +- rpc/srv/dsMgr.c | 7 + rpc/srv/dsVideoDeviceConfig.c | 102 ++++++----- rpc/srv/dsVideoPortConfig.c | 314 ++++++++++++++++---------------- 6 files changed, 321 insertions(+), 288 deletions(-) diff --git a/rpc/include/dsVideoPortConfig.h b/rpc/include/dsVideoPortConfig.h index 17de96dd..add0ea93 100644 --- a/rpc/include/dsVideoPortConfig.h +++ b/rpc/include/dsVideoPortConfig.h @@ -50,7 +50,7 @@ typedef struct videoPortConfigs * * @param[in] dynamicVideoPortConfigs Pointer to dynamic video port configuration, or NULL for static config */ -void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); +int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); /** * @brief Get video port type configurations diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index caefb12a..db022fcf 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -29,30 +29,32 @@ #include #include "dsserverlogger.h" #include "dsTypes.h" +#include "dsAudioConfig.h" #include "dsAudioSettings.h" + #ifdef __cplusplus extern "C" { #endif -typedef struct audioConfigs +typedef struct audioConfigsLocal { dsAudioTypeConfig_t *pKAudioConfigs; dsAudioPortConfig_t *pKAudioPorts; - int *pKConfigSize; - int *pKPortSize; -}audioConfigs_t; + int kConfigSize; + int kPortSize; +}audioConfigsLocal_t; -static audioConfigs_t audioConfiguration; +static audioConfigsLocal_t audioConfiguration = {0}; -void audioDumpconfig(audioConfigs_t *config) +void audioDumpconfig(audioConfigsLocal_t *config) { if (nullptr == config) { - INT_ERROR("Audio config is NULL"); + INT_ERROR("Audio config is NULL\n"); return; } if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { - INT_INFO("Dumping of Device configs is disabled"); + INT_INFO("Dumping of Device configs is disabled\n"); return; } @@ -60,34 +62,34 @@ void audioDumpconfig(audioConfigs_t *config) INT_INFO("\n=============== Starting to Dump Audio Configs ===============\n"); if( NULL != config->pKAudioConfigs ) { - configSize = (config->pKConfigSize) ? *(config->pKConfigSize) : -1; + configSize = config->kConfigSize; for (int i = 0; i < configSize; i++) { const dsAudioTypeConfig_t *typeCfg = &(config->pKAudioConfigs[i]); - INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); - INT_INFO("typeCfg->name = %s", typeCfg->name); - INT_INFO("typeCfg->numSupportedEncodings = %zu", typeCfg->numSupportedEncodings); - INT_INFO("typeCfg->numSupportedCompressions = %zu", typeCfg->numSupportedCompressions); - INT_INFO("typeCfg->numSupportedStereoModes = %zu", typeCfg->numSupportedStereoModes); + INT_INFO("typeCfg->typeId = %d\n", typeCfg->typeId); + INT_INFO("typeCfg->name = %s\n", typeCfg->name); + INT_INFO("typeCfg->numSupportedEncodings = %zu\n", typeCfg->numSupportedEncodings); + INT_INFO("typeCfg->numSupportedCompressions = %zu\n", typeCfg->numSupportedCompressions); + INT_INFO("typeCfg->numSupportedStereoModes = %zu\n", typeCfg->numSupportedStereoModes); } } else { - INT_ERROR("kAudioConfigs is NULL"); + INT_ERROR("kAudioConfigs is NULL\n"); } if( NULL != config->pKAudioPorts ) { - portSize = (config->pKPortSize) ? *(config->pKPortSize) : -1; + portSize = config->kPortSize; for (int i = 0; i < portSize; i++) { const dsAudioPortConfig_t *portCfg = &(config->pKAudioPorts[i]); - INT_INFO("portCfg->id.type = %d", portCfg->id.type); - INT_INFO("portCfg->id.index = %d", portCfg->id.index); + INT_INFO("portCfg->id.type = %d\n", portCfg->id.type); + INT_INFO("portCfg->id.index = %d\n", portCfg->id.index); } } else { - INT_ERROR("kAudioPorts is NULL"); + INT_ERROR("kAudioPorts is NULL\n"); } INT_INFO("\n=============== Dump Audio Configs done ===============\n"); @@ -133,71 +135,60 @@ static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numE return numElements; } -void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) +int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) { - int configSize = -1, portSize = -1; - int ret = -1; + int configSize, portSize; + const dsAudioTypeConfig_t* audioConfigs; + const dsAudioPortConfig_t* audioPorts; + bool isDynamic; - INT_INFO("Using '%s' config", dynamicAudioConfigs ? "dynamic" : "static"); + INT_INFO("Using '%s' config\n", dynamicAudioConfigs ? "dynamic" : "static"); - if (NULL != dynamicAudioConfigs) - { - // Reading Audio type configs - configSize = (dynamicAudioConfigs->pKConfigSize) ? *(dynamicAudioConfigs->pKConfigSize) : -1; - ret = allocateAndCopyAudioConfigs(dynamicAudioConfigs->pKAudioConfigs, configSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - - // Reading Audio port configs - portSize = (dynamicAudioConfigs->pKPortSize) ? *(dynamicAudioConfigs->pKPortSize) : -1; - ret = allocateAndCopyAudioPorts(dynamicAudioConfigs->pKAudioPorts, portSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - } - else { - // Using static configuration + // Set up parameters based on config source + if (NULL != dynamicAudioConfigs) { + configSize = *(dynamicAudioConfigs->pKConfigSize); + portSize = *(dynamicAudioConfigs->pKPortSize); + audioConfigs = dynamicAudioConfigs->pKAudioConfigs; + audioPorts = dynamicAudioConfigs->pKAudioPorts; + isDynamic = true; + } else { configSize = dsUTL_DIM(kConfigs); - ret = allocateAndCopyAudioConfigs(kConfigs, configSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - portSize = dsUTL_DIM(kPorts); - ret = allocateAndCopyAudioPorts(kPorts, portSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } + audioConfigs = kConfigs; + audioPorts = kPorts; + isDynamic = false; } - INT_INFO("Store sizes configSize =%d, portSize =%d\n", configSize, portSize); - audioConfiguration.pKConfigSize = (int*)malloc(sizeof(int)); - if (audioConfiguration.pKConfigSize == NULL) { - INT_ERROR("Failed to allocate memory for pKConfigSize\n"); - } - else { - *(audioConfiguration.pKConfigSize) = configSize; - INT_INFO("Store sizes *(audioConfiguration.pKConfigSize) =%d\n", *(audioConfiguration.pKConfigSize)); - } - audioConfiguration.pKPortSize = (int*)malloc(sizeof(int)); - if (audioConfiguration.pKPortSize == NULL) { - INT_ERROR("Failed to allocate memory for pKPortSize\n"); + // Allocate and copy audio type configs + if (allocateAndCopyAudioConfigs(audioConfigs, configSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate audio type configs\n"); + return; } - else { - *(audioConfiguration.pKPortSize) = configSize; - INT_INFO("Store sizes *(audioConfiguration.pKPortSize) =%d\n", *(audioConfiguration.pKPortSize)); + + // Allocate and copy audio port configs + if (allocateAndCopyAudioPorts(audioPorts, portSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate audio port configs\n"); + // Clean up previously allocated memory + if (audioConfiguration.pKAudioConfigs != NULL) { + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + } + return; } + + INT_INFO("Store sizes configSize =%d, portSize =%d\n", configSize, portSize); + + audioConfiguration.kConfigSize = configSize; + audioConfiguration.kPortSize = portSize; + INT_INFO("Store sizes audioConfiguration.kConfigSize = %d\n", audioConfiguration.kConfigSize); + INT_INFO("Store sizes audioConfiguration.kPortSize = %d\n", audioConfiguration.kPortSize); - INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]", + INT_INFO("Audio Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d]\n", audioConfiguration.pKAudioConfigs ? audioConfiguration.pKAudioConfigs : NULL, - audioConfiguration.pKConfigSize ? *(audioConfiguration.pKConfigSize) : -1, + audioConfiguration.kConfigSize, audioConfiguration.pKAudioPorts? audioConfiguration.pKAudioPorts : NULL, - audioConfiguration.pKPortSize ? *(audioConfiguration.pKPortSize) : -1); + audioConfiguration.kPortSize); + audioDumpconfig(&audioConfiguration); } @@ -205,7 +196,7 @@ void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = *(audioConfiguration.pKConfigSize); + *outConfigSize = audioConfiguration.kConfigSize; } if (outConfigs != NULL) { *outConfigs = audioConfiguration.pKAudioConfigs; @@ -215,13 +206,38 @@ void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outCo void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts) { if (outPortSize != NULL) { - *outPortSize = *(audioConfiguration.pKPortSize); + *outPortSize = audioConfiguration.kPortSize; } if (outPorts != NULL) { *outPorts = audioConfiguration.pKAudioPorts; } } +void dsAudioConfigFree(void) +{ + INT_INFO("Freeing Audio configuration resources\n"); + + // Free audio configs + if (audioConfiguration.pKAudioConfigs != NULL) { + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + INT_INFO("Freed pKAudioConfigs\n"); + } + + // Free audio ports + if (audioConfiguration.pKAudioPorts != NULL) { + free(audioConfiguration.pKAudioPorts); + audioConfiguration.pKAudioPorts = NULL; + INT_INFO("Freed pKAudioPorts\n"); + } + + // Reset size variables + audioConfiguration.kConfigSize = 0; + audioConfiguration.kPortSize = 0; + + INT_INFO("Audio configuration freed successfully\n"); +} + #ifdef __cplusplus } #endif diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c index 6aedbd61..c0170b30 100644 --- a/rpc/srv/dsConfigs.c +++ b/rpc/srv/dsConfigs.c @@ -58,23 +58,23 @@ static int LoadDLSymbols(void* pDLHandle, const dlSymbolLookup_t* symbols, int n int isAllSymbolsLoaded = 0; if ((NULL == pDLHandle) || (NULL == symbols)) { - INT_ERROR("Invalid DL Handle or symbolsPtr"); + INT_ERROR("Invalid DL Handle or symbolsPtr\n"); return 0; } - INT_INFO("numberOfSymbols = %d", numberOfSymbols); + INT_INFO("numberOfSymbols = %d\n", numberOfSymbols); for (int i = 0; i < numberOfSymbols; i++) { if ((NULL == symbols[i].dataptr) || (NULL == symbols[i].name)) { - INT_ERROR("Invalid symbol entry at index [%d]", i); + INT_ERROR("Invalid symbol entry at index [%d]\n", i); continue; } *(symbols[i].dataptr) = dlsym(pDLHandle, symbols[i].name); if (NULL == *(symbols[i].dataptr)) { - INT_ERROR("[%s] is not defined", symbols[i].name); + INT_ERROR("[%s] is not defined\n", symbols[i].name); } else { currentSymbols++; - INT_INFO("[%s] is defined and loaded, data[%p]", symbols[i].name, *(symbols[i].dataptr)); + INT_INFO("[%s] is defined and loaded, data[%p]\n", symbols[i].name, *(symbols[i].dataptr)); } } isAllSymbolsLoaded = (numberOfSymbols) ? (currentSymbols == numberOfSymbols) : 0; @@ -86,10 +86,10 @@ static void loadDeviceCapabilities(unsigned int capabilityType) void* pDLHandle = NULL; int isSymbolsLoaded = 0; - INT_INFO("Entering capabilityType = 0x%08X", capabilityType); + INT_INFO("Entering capabilityType = 0x%08X\n", capabilityType); dlerror(); /* clear old error */ pDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); - INT_INFO("DL Instance '%s'", (NULL == pDLHandle ? "NULL" : "Valid")); + INT_INFO("DL Instance '%s'\n", (NULL == pDLHandle ? "NULL" : "Valid")); /* Audio Port Config */ if (DEVICE_CAPABILITY_AUDIO_PORT & capabilityType) { @@ -156,16 +156,16 @@ static void loadDeviceCapabilities(unsigned int capabilityType) dlclose(pDLHandle); pDLHandle = NULL; } - INT_INFO("Exiting ..."); + INT_INFO("Exiting ...\n"); } void dsLoadConfigs(void) { - INT_INFO("Enter function"); + INT_INFO("Enter function\n"); loadDeviceCapabilities(DEVICE_CAPABILITY_VIDEO_PORT | DEVICE_CAPABILITY_AUDIO_PORT | DEVICE_CAPABILITY_VIDEO_DEVICE); - INT_INFO("Exit function"); + INT_INFO("Exit function\n"); } #ifdef __cplusplus diff --git a/rpc/srv/dsMgr.c b/rpc/srv/dsMgr.c index b4217861..51d54104 100755 --- a/rpc/srv/dsMgr.c +++ b/rpc/srv/dsMgr.c @@ -143,6 +143,13 @@ IARM_Result_t dsMgr_term() dsHostMgr_term(); dsHdmiInMgr_term(); dsCompositeInMgr_term(); + + // Free dynamically allocated configuration memory + INT_INFO("Freeing device configuration resources\n"); + dsAudioConfigFree(); + dsVideoDeviceConfigFree(); + dsVideoPortConfigFree(); + return ret; } diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index ea5199b4..c2518d1d 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -29,28 +29,29 @@ #include #include "dsserverlogger.h" #include "dsTypes.h" +#include "dsVideoDeviceConfig.h" #include "dsVideoDeviceSettings.h" #ifdef __cplusplus extern "C" { #endif -typedef struct videoDeviceConfig +typedef struct videoDeviceConfigLocal { dsVideoConfig_t *pKVideoDeviceConfigs; - int *pKVideoDeviceConfigs_size; -}videoDeviceConfig_t; + int kVideoDeviceConfigs_size; +}videoDeviceConfigLocal_t; -static videoDeviceConfig_t videoDeviceConfiguration; +static videoDeviceConfigLocal_t videoDeviceConfiguration = {0}; -void videoDeviceDumpconfig(videoDeviceConfig_t *config) +void videoDeviceDumpconfig(videoDeviceConfigLocal_t *config) { if (NULL == config) { - INT_ERROR("Video config is NULL"); + INT_ERROR("Video config is NULL\n"); return; } if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { - INT_INFO("Dumping of Device configs is disabled"); + INT_INFO("Dumping of Device configs is disabled\n"); return; } @@ -58,20 +59,20 @@ void videoDeviceDumpconfig(videoDeviceConfig_t *config) if( NULL != config->pKVideoDeviceConfigs ) { - int configSize = (config->pKVideoDeviceConfigs_size) ? *(config->pKVideoDeviceConfigs_size) : -1; - INT_INFO("pKVideoDeviceConfigs = %p", config->pKVideoDeviceConfigs); - INT_INFO("videoDeviceConfigs_size = %d", configSize); + int configSize = config->kVideoDeviceConfigs_size; + INT_INFO("pKVideoDeviceConfigs = %p\n", config->pKVideoDeviceConfigs); + INT_INFO("videoDeviceConfigs_size = %d\n", configSize); for (int i = 0; i < configSize; i++) { dsVideoConfig_t* videoDeviceConfig = &config->pKVideoDeviceConfigs[i]; - INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu ", i, videoDeviceConfig->numSupportedDFCs); + INT_INFO("pKVideoDeviceConfigs[%d].numSupportedDFCs = %lu\n", i, videoDeviceConfig->numSupportedDFCs); for (int j = 0; j < videoDeviceConfig->numSupportedDFCs; j++) { - INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d", i, j, videoDeviceConfig->supportedDFCs[j]); + INT_INFO(" Address of pKVideoDeviceConfigs[%d].supportedDFCs[%d] = %d\n", i, j, videoDeviceConfig->supportedDFCs[j]); } } } else { - INT_ERROR(" kVideoDeviceConfigs is NULL"); + INT_ERROR(" kVideoDeviceConfigs is NULL\n"); } INT_INFO("\n=============== Dump VideoDevice Configs done ===============\n"); @@ -93,63 +94,74 @@ static int allocateAndCopyVideoDeviceConfigs(const dsVideoConfig_t* source, int } memcpy(videoDeviceConfiguration.pKVideoDeviceConfigs, source, numElements * sizeof(dsVideoConfig_t)); - INT_INFO("Allocated and copied %d video device configs (%s)", numElements, configType); + INT_INFO("Allocated and copied %d video device configs (%s)\n", numElements, configType); return numElements; } -void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) +int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) { - int configSize = -1, ret = -1; + int configSize; + const dsVideoConfig_t* videoConfigs; + bool isDynamic; - INT_INFO("Using '%s' config", dynamicVideoDeviceConfigs ? "dynamic" : "static"); + INT_INFO("Using '%s' config\n", dynamicVideoDeviceConfigs ? "dynamic" : "static"); - if (NULL != dynamicVideoDeviceConfigs) - { - // Reading Video Device configs - configSize = (dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) ? *(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size) : -1; - ret = allocateAndCopyVideoDeviceConfigs(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs, configSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - } - else { - // Using static configuration + // Set up parameters based on config source + if (NULL != dynamicVideoDeviceConfigs) { + configSize = *(dynamicVideoDeviceConfigs->pKVideoDeviceConfigs_size); + videoConfigs = dynamicVideoDeviceConfigs->pKVideoDeviceConfigs; + isDynamic = true; + } else { configSize = dsUTL_DIM(kConfigs); - ret = allocateAndCopyVideoDeviceConfigs(kConfigs, configSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } + videoConfigs = kConfigs; + isDynamic = false; } - INT_INFO("Store sizes configSize =%d\n", configSize); - videoDeviceConfiguration.pKVideoDeviceConfigs_size = (int*)malloc(sizeof(int)); - if (videoDeviceConfiguration.pKVideoDeviceConfigs_size == NULL) { - INT_ERROR("Failed to allocate memory for pKConfigSize\n"); - } - else { - *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) = configSize; - INT_INFO("Store sizes *(videoDeviceConfiguration.pKVideoDeviceConfigs_size) =%d\n", *(videoDeviceConfiguration.pKVideoDeviceConfigs_size)); + // Allocate and copy video device configs + if (allocateAndCopyVideoDeviceConfigs(videoConfigs, configSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate video device configs\n"); + return; } - INT_INFO("VideoDevice Config[%p] ConfigSize[%d]", + INT_INFO("Store sizes configSize =%d\n", configSize); + videoDeviceConfiguration.kVideoDeviceConfigs_size = configSize; + INT_INFO("Store sizes videoDeviceConfiguration.kVideoDeviceConfigs_size = %d\n", videoDeviceConfiguration.kVideoDeviceConfigs_size); + + INT_INFO("VideoDevice Config[%p] ConfigSize[%d]\n", videoDeviceConfiguration.pKVideoDeviceConfigs, - *(videoDeviceConfiguration.pKVideoDeviceConfigs_size)); + videoDeviceConfiguration.kVideoDeviceConfigs_size); videoDeviceDumpconfig(&videoDeviceConfiguration); + return 0; } // Getter functions for use across srv code void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = *(videoDeviceConfiguration.pKVideoDeviceConfigs_size); + *outConfigSize = videoDeviceConfiguration.kVideoDeviceConfigs_size; } if (outConfigs != NULL) { *outConfigs = videoDeviceConfiguration.pKVideoDeviceConfigs; } } +void dsVideoDeviceConfigFree(void) +{ + INT_INFO("Freeing VideoDevice configuration resources\n"); + + // Free video device configs + if (videoDeviceConfiguration.pKVideoDeviceConfigs != NULL) { + free(videoDeviceConfiguration.pKVideoDeviceConfigs); + videoDeviceConfiguration.pKVideoDeviceConfigs = NULL; + INT_INFO("Freed pKVideoDeviceConfigs\n"); + } + + // Reset size variable + videoDeviceConfiguration.kVideoDeviceConfigs_size = 0; + + INT_INFO("VideoDevice configuration freed successfully\n"); +} + #ifdef __cplusplus } #endif diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index 8153fcf6..e01b6fca 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -30,32 +30,34 @@ #include "dsserverlogger.h" #include "dsTypes.h" #include "dsVideoPortSettings.h" +#include "dsVideoResolutionSettings.h" +#include "dsVideoPortConfig.h" #ifdef __cplusplus extern "C" { #endif -typedef struct videoPortConfigs +typedef struct videoPortConfigsLocal { dsVideoPortTypeConfig_t *pKVideoPortConfigs; - int *pKVideoPortConfigs_size; + int kVideoPortConfigs_size; dsVideoPortPortConfig_t *pKVideoPortPorts; - int *pKVideoPortPorts_size; + int kVideoPortPorts_size; dsVideoPortResolution_t *pKVideoPortResolutionsSettings; - int *pKResolutionsSettings_size; - int *pKDefaultResIndex; -}videoPortConfigs_t; + int kResolutionsSettings_size; + int kDefaultResIndex; +}videoPortConfigsLocal_t; -static videoPortConfigs_t videoPortConfiguration; +static videoPortConfigsLocal_t videoPortConfiguration = {0}; -void videoPortDumpconfig(videoPortConfigs_t *config) +void videoPortDumpconfig(videoPortConfigsLocal_t *config) { if (NULL == config) { - INT_ERROR("Video config is NULL"); + INT_ERROR("Video config is NULL\n"); return; } if ( -1 == access("/opt/dsMgrDumpDeviceConfigs", F_OK) ) { - INT_INFO("Dumping of Device configs is disabled"); + INT_INFO("Dumping of Device configs is disabled\n"); return; } INT_INFO("\n=============== Starting to Dump VideoPort Configs ===============\n"); @@ -63,26 +65,26 @@ void videoPortDumpconfig(videoPortConfigs_t *config) int configSize = -1, portSize = -1, resolutionSize = -1; if (( NULL != config->pKVideoPortConfigs ) && ( NULL != config->pKVideoPortPorts ) && ( nullptr != config->pKVideoPortResolutionsSettings )) { - configSize = (config->pKVideoPortConfigs_size) ? *(config->pKVideoPortConfigs_size) : -1; - portSize = (config->pKVideoPortPorts_size) ? *(config->pKVideoPortPorts_size) : -1; - resolutionSize = (config->pKResolutionsSettings_size) ? *(config->pKResolutionsSettings_size) : -1; - INT_INFO("pKVideoPortConfigs = %p", config->pKVideoPortConfigs); - INT_INFO("pKConfigSize pointer %p = %d", config->pKVideoPortConfigs_size, configSize); - INT_INFO("pKVideoPortPorts = %p", config->pKVideoPortPorts); - INT_INFO("pKPortSize pointer %p = %d", config->pKVideoPortPorts_size, portSize); - INT_INFO("pKResolutionsSettings = %p", config->pKVideoPortResolutionsSettings); - INT_INFO("pKResolutionsSettingsSize pointer %p = %d", config->pKResolutionsSettings_size, resolutionSize); + configSize = config->kVideoPortConfigs_size; + portSize = config->kVideoPortPorts_size; + resolutionSize = config->kResolutionsSettings_size; + INT_INFO("pKVideoPortConfigs = %p\n", config->pKVideoPortConfigs); + INT_INFO("kVideoPortConfigs_size = %d\n", configSize); + INT_INFO("pKVideoPortPorts = %p\n", config->pKVideoPortPorts); + INT_INFO("kVideoPortPorts_size = %d\n", portSize); + INT_INFO("pKResolutionsSettings = %p\n", config->pKVideoPortResolutionsSettings); + INT_INFO("kResolutionsSettings_size = %d\n", resolutionSize); INT_INFO("\n\n############### Dumping Video Resolutions Settings ############### \n\n"); for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(config->pKVideoPortResolutionsSettings[i]); - INT_INFO("resolution->name = %s", resolution->name); - INT_INFO("resolution->pixelResolution= %d", resolution->pixelResolution); - INT_INFO("resolution->aspectRatio= %d", resolution->aspectRatio); - INT_INFO("resolution->stereoScopicMode= %d", resolution->stereoScopicMode); - INT_INFO("resolution->frameRate= %d", resolution->frameRate); - INT_INFO("resolution->interlaced= %d", resolution->interlaced); + INT_INFO("resolution->name = %s\n", resolution->name); + INT_INFO("resolution->pixelResolution= %d\n", resolution->pixelResolution); + INT_INFO("resolution->aspectRatio= %d\n", resolution->aspectRatio); + INT_INFO("resolution->stereoScopicMode= %d\n", resolution->stereoScopicMode); + INT_INFO("resolution->frameRate= %d\n", resolution->frameRate); + INT_INFO("resolution->interlaced= %d\n", resolution->interlaced); } INT_INFO("\n ############### Dumping Video Port Configurations ############### \n"); @@ -90,38 +92,38 @@ void videoPortDumpconfig(videoPortConfigs_t *config) for (int i = 0; i < configSize; i++) { const dsVideoPortTypeConfig_t *typeCfg = &(config->pKVideoPortConfigs[i]); - INT_INFO("typeCfg->typeId = %d", typeCfg->typeId); - INT_INFO("typeCfg->name = %s", (typeCfg->name) ? typeCfg->name : "NULL"); - INT_INFO("typeCfg->dtcpSupported= %d", typeCfg->dtcpSupported); - INT_INFO("typeCfg->hdcpSupported = %d", typeCfg->hdcpSupported); - INT_INFO("typeCfg->restrictedResollution = %d", typeCfg->restrictedResollution); - INT_INFO("typeCfg->numSupportedResolutions= %lu", typeCfg->numSupportedResolutions); + INT_INFO("typeCfg->typeId = %d\n", typeCfg->typeId); + INT_INFO("typeCfg->name = %s\n", (typeCfg->name) ? typeCfg->name : "NULL"); + INT_INFO("typeCfg->dtcpSupported= %d\n", typeCfg->dtcpSupported); + INT_INFO("typeCfg->hdcpSupported = %d\n", typeCfg->hdcpSupported); + INT_INFO("typeCfg->restrictedResollution = %d\n", typeCfg->restrictedResollution); + INT_INFO("typeCfg->numSupportedResolutions= %lu\n", typeCfg->numSupportedResolutions); - INT_INFO("typeCfg->supportedResolutions = %p", typeCfg->supportedResolutions); - INT_INFO("typeCfg->supportedResolutions->name = %s", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); - INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d", typeCfg->supportedResolutions->pixelResolution); - INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d", typeCfg->supportedResolutions->aspectRatio); - INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d", typeCfg->supportedResolutions->stereoScopicMode); - INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); - INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); + INT_INFO("typeCfg->supportedResolutions = %p\n", typeCfg->supportedResolutions); + INT_INFO("typeCfg->supportedResolutions->name = %s\n", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); + INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d\n", typeCfg->supportedResolutions->pixelResolution); + INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d\n", typeCfg->supportedResolutions->aspectRatio); + INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d\n", typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("typeCfg->supportedResolutions->frameRate= %d\n", typeCfg->supportedResolutions->frameRate); + INT_INFO("typeCfg->supportedResolutions->interlaced= %d\n", typeCfg->supportedResolutions->interlaced); } INT_INFO("\n############### Dumping Video Port Connections ###############\n"); for (int i = 0; i < portSize; i++) { const dsVideoPortPortConfig_t *portCfg = &(config->pKVideoPortPorts[i]); - INT_INFO("portCfg->id.type = %d", portCfg->id.type); - INT_INFO("portCfg->id.index = %d", portCfg->id.index); - INT_INFO("portCfg->connectedAOP.type = %d", portCfg->connectedAOP.type); - INT_INFO("portCfg->connectedAOP.index = %d", portCfg->connectedAOP.index); - INT_INFO("portCfg->defaultResolution = %s", (portCfg->defaultResolution) ? portCfg->defaultResolution : "NULL"); + INT_INFO("portCfg->id.type = %d\n", portCfg->id.type); + INT_INFO("portCfg->id.index = %d\n", portCfg->id.index); + INT_INFO("portCfg->connectedAOP.type = %d\n", portCfg->connectedAOP.type); + INT_INFO("portCfg->connectedAOP.index = %d\n", portCfg->connectedAOP.index); + INT_INFO("portCfg->defaultResolution = %s\n", (portCfg->defaultResolution) ? portCfg->defaultResolution : "NULL"); } } else { - INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); + INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL\n"); } INT_INFO("\n=============== Dump VideoPort Configs done ===============\n"); - INT_INFO("Exit function"); + INT_INFO("Exit function\n"); } static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source, int numElements, bool isDynamic) @@ -140,7 +142,7 @@ static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source } memcpy(videoPortConfiguration.pKVideoPortConfigs, source, numElements * sizeof(dsVideoPortTypeConfig_t)); - INT_INFO("Allocated and copied %d video port configs (%s)", numElements, configType); + INT_INFO("Allocated and copied %d video port configs (%s)\n", numElements, configType); return numElements; } @@ -160,7 +162,7 @@ static int allocateAndCopyVideoPortPorts(const dsVideoPortPortConfig_t* source, } memcpy(videoPortConfiguration.pKVideoPortPorts, source, numElements * sizeof(dsVideoPortPortConfig_t)); - INT_INFO("Allocated and copied %d video port ports (%s)", numElements, configType); + INT_INFO("Allocated and copied %d video port ports (%s)\n", numElements, configType); return numElements; } @@ -180,140 +182,102 @@ static int allocateAndCopyVideoPortResolutions(const dsVideoPortResolution_t* so } memcpy(videoPortConfiguration.pKVideoPortResolutionsSettings, source, numElements * sizeof(dsVideoPortResolution_t)); - INT_INFO("Allocated and copied %d video port resolutions (%s)", numElements, configType); + INT_INFO("Allocated and copied %d video port resolutions (%s)\n", numElements, configType); return numElements; } -void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) +int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) { - int configSize = -1, portSize = -1, resolutionSize = -1, ret = -1; + int configSize, portSize, resolutionSize, defaultResIndex; + const dsVideoPortTypeConfig_t* videoPortConfigs; + const dsVideoPortPortConfig_t* videoPortPorts; + const dsVideoPortResolution_t* videoPortResolutions; + bool isDynamic; - INT_INFO("Using '%s' config", dynamicVideoPortConfigs ? "dynamic" : "static"); + INT_INFO("Using '%s' config\n", dynamicVideoPortConfigs ? "dynamic" : "static"); - if (NULL != dynamicVideoPortConfigs) - { - // Reading Video Port Type configs - configSize = (dynamicVideoPortConfigs->pKVideoPortConfigs_size) ? *(dynamicVideoPortConfigs->pKVideoPortConfigs_size) : -1; - ret = allocateAndCopyVideoPortConfigs(dynamicVideoPortConfigs->pKVideoPortConfigs, configSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - - // Reading Video Port Port configs - portSize = (dynamicVideoPortConfigs->pKVideoPortPorts_size) ? *(dynamicVideoPortConfigs->pKVideoPortPorts_size) : -1; - ret = allocateAndCopyVideoPortPorts(dynamicVideoPortConfigs->pKVideoPortPorts, portSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - - // Reading Video Port Resolutions - resolutionSize = (dynamicVideoPortConfigs->pKResolutionsSettings_size) ? *(dynamicVideoPortConfigs->pKResolutionsSettings_size) : -1; - ret = allocateAndCopyVideoPortResolutions(dynamicVideoPortConfigs->pKVideoPortResolutionsSettings, resolutionSize, true); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - // Reading Default Resolution Index - if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { - INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); - videoPortConfiguration.pKDefaultResIndex = (int*)malloc(sizeof(int)); - if (videoPortConfiguration.pKDefaultResIndex == NULL) { - INT_ERROR("Failed to allocate memory for pKConfigSize\n"); - } - else - { - *(videoPortConfiguration.pKDefaultResIndex) = *(dynamicVideoPortConfigs->pKDefaultResIndex); - INT_INFO("Store sizes *(videoPortConfiguration.pKDefaultResIndex) =%d (dynamic)\n", *(videoPortConfiguration.pKDefaultResIndex)); - } - } else { - INT_INFO("Default pKDefaultResIndex not available in dynamic config"); - } - } - else { - // Using static configuration + // Set up parameters based on config source + if (NULL != dynamicVideoPortConfigs) { + configSize = *(dynamicVideoPortConfigs->pKVideoPortConfigs_size); + portSize = *(dynamicVideoPortConfigs->pKVideoPortPorts_size); + resolutionSize = *(dynamicVideoPortConfigs->pKResolutionsSettings_size); + defaultResIndex = *(dynamicVideoPortConfigs->pKDefaultResIndex); + videoPortConfigs = dynamicVideoPortConfigs->pKVideoPortConfigs; + videoPortPorts = dynamicVideoPortConfigs->pKVideoPortPorts; + videoPortResolutions = dynamicVideoPortConfigs->pKVideoPortResolutionsSettings; + isDynamic = true; + } else { configSize = dsUTL_DIM(kConfigs); - ret = allocateAndCopyVideoPortConfigs(kConfigs, configSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - portSize = dsUTL_DIM(kPorts); - ret = allocateAndCopyVideoPortPorts(kPorts, portSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); - } - resolutionSize = dsUTL_DIM(kResolutions); - ret = allocateAndCopyVideoPortResolutions(kResolutions, resolutionSize, false); - if(ret == -1) - { - INT_ERROR("failed to create dynamic memory\n"); + defaultResIndex = kDefaultResIndex; + videoPortConfigs = kConfigs; + videoPortPorts = kPorts; + videoPortResolutions = kResolutions; + isDynamic = false; + } + + // Allocate and copy video port type configs + if (allocateAndCopyVideoPortConfigs(videoPortConfigs, configSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate video port configs\n"); + return -1; + } + + // Allocate and copy video port ports + if (allocateAndCopyVideoPortPorts(videoPortPorts, portSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate video port ports\n"); + // Clean up previously allocated memory + if (videoPortConfiguration.pKVideoPortConfigs != NULL) { + free(videoPortConfiguration.pKVideoPortConfigs); + videoPortConfiguration.pKVideoPortConfigs = NULL; } + return -1; + } - // Using static default resolution index - if (dynamicVideoPortConfigs->pKDefaultResIndex != NULL) { - INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); - videoPortConfiguration.pKDefaultResIndex = (int*)malloc(sizeof(int)); - if (videoPortConfiguration.pKDefaultResIndex == NULL) { - INT_ERROR("Failed to allocate memory for pKConfigSize\n"); - } - else - { - *(videoPortConfiguration.pKDefaultResIndex) = kDefaultResIndex; - INT_INFO("Store sizes *(videoPortConfiguration.pKDefaultResIndex) =%d (static)\n", *(videoPortConfiguration.pKDefaultResIndex)); - } + // Allocate and copy video port resolutions + if (allocateAndCopyVideoPortResolutions(videoPortResolutions, resolutionSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate video port resolutions\n"); + // Clean up previously allocated memory + if (videoPortConfiguration.pKVideoPortConfigs != NULL) { + free(videoPortConfiguration.pKVideoPortConfigs); + videoPortConfiguration.pKVideoPortConfigs = NULL; + } + if (videoPortConfiguration.pKVideoPortPorts != NULL) { + free(videoPortConfiguration.pKVideoPortPorts); + videoPortConfiguration.pKVideoPortPorts = NULL; } + return -1; } INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); - videoPortConfiguration.pKVideoPortConfigs_size = (int*)malloc(sizeof(int)); - if (videoPortConfiguration.pKVideoPortConfigs_size == NULL) { - INT_ERROR("Failed to allocate memory for pKConfigSize\n"); - } - else - { - *(videoPortConfiguration.pKVideoPortConfigs_size) = configSize; - INT_INFO("Store sizes *(videoPortConfiguration.pKVideoPortConfigs_size) =%d\n", *(videoPortConfiguration.pKVideoPortConfigs_size)); - } - videoPortConfiguration.pKVideoPortPorts_size = (int*)malloc(sizeof(int)); - if (videoPortConfiguration.pKVideoPortPorts_size == NULL) { - INT_ERROR("Failed to allocate memory for pKPortSize\n"); - } - else - { - *(videoPortConfiguration.pKVideoPortPorts_size) = portSize; - INT_INFO("Store sizes *(videoPortConfiguration.pKVideoPortPorts_size) =%d\n", *(videoPortConfiguration.pKVideoPortPorts_size)); - } - videoPortConfiguration.pKResolutionsSettings_size = (int*)malloc(sizeof(int)); - if (videoPortConfiguration.pKResolutionsSettings_size == NULL) { - INT_ERROR("Failed to allocate memory for pKPortSize\n"); - } - else - { - *(videoPortConfiguration.pKResolutionsSettings_size) = resolutionSize; - INT_INFO("Store sizes *(videoPortConfiguration.pKResolutionsSettings_size) =%d\n", *(videoPortConfiguration.pKResolutionsSettings_size)); - } + videoPortConfiguration.kDefaultResIndex = defaultResIndex; + INT_INFO("Store sizes videoPortConfiguration.kDefaultResIndex = %d\n", videoPortConfiguration.kDefaultResIndex); + + INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); + videoPortConfiguration.kVideoPortConfigs_size = configSize; + videoPortConfiguration.kVideoPortPorts_size = portSize; + videoPortConfiguration.kResolutionsSettings_size = resolutionSize; + INT_INFO("Store sizes kVideoPortConfigs_size = %d\n", videoPortConfiguration.kVideoPortConfigs_size); + INT_INFO("Store sizes kVideoPortPorts_size = %d\n", videoPortConfiguration.kVideoPortPorts_size); + INT_INFO("Store sizes kResolutionsSettings_size = %d\n", videoPortConfiguration.kResolutionsSettings_size); - INT_INFO("VideoPort Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d] Resolutions[%p] ResolutionSize[%d] DefaultResIndex[%d]", + INT_INFO("VideoPort Config[%p] ConfigSize[%d] Ports[%p] PortSize[%d] Resolutions[%p] ResolutionSize[%d] DefaultResIndex[%d]\n", videoPortConfiguration.pKVideoPortConfigs, - *(videoPortConfiguration.pKVideoPortConfigs_size), + videoPortConfiguration.kVideoPortConfigs_size, videoPortConfiguration.pKVideoPortPorts, - *(videoPortConfiguration.pKVideoPortPorts_size), + videoPortConfiguration.kVideoPortPorts_size, videoPortConfiguration.pKVideoPortResolutionsSettings, - *(videoPortConfiguration.pKResolutionsSettings_size), - *(videoPortConfiguration.pKDefaultResIndex)); + videoPortConfiguration.kResolutionsSettings_size, + videoPortConfiguration.kDefaultResIndex); videoPortDumpconfig(&videoPortConfiguration); + return 0; } // Getter functions for use across srv code void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) { if (outConfigSize != NULL) { - *outConfigSize = *(videoPortConfiguration.pKVideoPortConfigs_size); + *outConfigSize = videoPortConfiguration.kVideoPortConfigs_size; } if (outConfigs != NULL) { *outConfigs = videoPortConfiguration.pKVideoPortConfigs; @@ -323,7 +287,7 @@ void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) { if (outPortSize != NULL) { - *outPortSize = *(videoPortConfiguration.pKVideoPortPorts_size); + *outPortSize = videoPortConfiguration.kVideoPortPorts_size; } if (outPorts != NULL) { *outPorts = videoPortConfiguration.pKVideoPortPorts; @@ -333,7 +297,7 @@ void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) { if (outResolutionSize != NULL) { - *outResolutionSize = *(videoPortConfiguration.pKResolutionsSettings_size); + *outResolutionSize = videoPortConfiguration.kResolutionsSettings_size; } if (outResolutions != NULL) { *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; @@ -343,8 +307,42 @@ void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** void dsGetDefaultResolutionIndex(int* outDefaultIndex) { if (outDefaultIndex != NULL) { - *outDefaultIndex = *(videoPortConfiguration.pKDefaultResIndex); + *outDefaultIndex = videoPortConfiguration.kDefaultResIndex; + } +} + +void dsVideoPortConfigFree(void) +{ + INT_INFO("Freeing VideoPort configuration resources\n"); + + // Free video port configs + if (videoPortConfiguration.pKVideoPortConfigs != NULL) { + free(videoPortConfiguration.pKVideoPortConfigs); + videoPortConfiguration.pKVideoPortConfigs = NULL; + INT_INFO("Freed pKVideoPortConfigs\n"); } + + // Free video port ports + if (videoPortConfiguration.pKVideoPortPorts != NULL) { + free(videoPortConfiguration.pKVideoPortPorts); + videoPortConfiguration.pKVideoPortPorts = NULL; + INT_INFO("Freed pKVideoPortPorts\n"); + } + + // Free video port resolutions + if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { + free(videoPortConfiguration.pKVideoPortResolutionsSettings); + videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; + INT_INFO("Freed pKVideoPortResolutionsSettings\n"); + } + + // Reset size variables + videoPortConfiguration.kVideoPortConfigs_size = 0; + videoPortConfiguration.kVideoPortPorts_size = 0; + videoPortConfiguration.kResolutionsSettings_size = 0; + videoPortConfiguration.kDefaultResIndex = 0; + + INT_INFO("VideoPort configuration freed successfully\n"); } #ifdef __cplusplus From b4a0fbafa6a585c2feb06722b210379018dac93d Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 23 Feb 2026 16:15:11 +0000 Subject: [PATCH 55/66] Add missing headrfile changes --- rpc/include/dsAudioConfig.h | 7 ++++++- rpc/include/dsVideoDeviceConfig.h | 5 +++++ rpc/include/dsVideoPortConfig.h | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/rpc/include/dsAudioConfig.h b/rpc/include/dsAudioConfig.h index 427d20a1..7e7d7bc9 100644 --- a/rpc/include/dsAudioConfig.h +++ b/rpc/include/dsAudioConfig.h @@ -47,7 +47,7 @@ typedef struct audioConfigs * * @param[in] dynamicAudioConfigs Pointer to dynamic audio configuration, or NULL for static config */ -void dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs); +int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs); /** * @brief Get audio type configurations @@ -65,6 +65,11 @@ void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outCo */ void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts); +/** + * @brief Free audio configuration resources + */ +void dsAudioConfigFree(void); + #ifdef __cplusplus } #endif diff --git a/rpc/include/dsVideoDeviceConfig.h b/rpc/include/dsVideoDeviceConfig.h index d35c2664..14dbd2ac 100644 --- a/rpc/include/dsVideoDeviceConfig.h +++ b/rpc/include/dsVideoDeviceConfig.h @@ -55,6 +55,11 @@ void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfig */ void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs); +/** + * @brief Free video device configuration resources + */ +void dsVideoDeviceConfigFree(void); + #ifdef __cplusplus } #endif diff --git a/rpc/include/dsVideoPortConfig.h b/rpc/include/dsVideoPortConfig.h index add0ea93..09ea0b78 100644 --- a/rpc/include/dsVideoPortConfig.h +++ b/rpc/include/dsVideoPortConfig.h @@ -50,7 +50,7 @@ typedef struct videoPortConfigs * * @param[in] dynamicVideoPortConfigs Pointer to dynamic video port configuration, or NULL for static config */ -int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); +void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); /** * @brief Get video port type configurations @@ -83,6 +83,11 @@ void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** */ void dsGetDefaultResolutionIndex(int* outDefaultIndex); +/** + * @brief Free video port configuration resources + */ +void dsVideoPortConfigFree(void); + #ifdef __cplusplus } #endif From 31735bd86c4edfab0c945b7a98e5074af31a20b5 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 23 Feb 2026 16:50:55 +0000 Subject: [PATCH 56/66] Fix build errors. --- rpc/include/dsConfigs.h | 5 +++++ rpc/srv/dsAudioConfig.c | 5 +++-- rpc/srv/dsConfigs.c | 29 +++++++++++++++++++++++++---- rpc/srv/dsMgr.c | 6 +----- rpc/srv/dsVideoDeviceConfig.c | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) mode change 100755 => 100644 rpc/srv/dsMgr.c diff --git a/rpc/include/dsConfigs.h b/rpc/include/dsConfigs.h index b7e2fb7a..5bee2220 100644 --- a/rpc/include/dsConfigs.h +++ b/rpc/include/dsConfigs.h @@ -68,6 +68,11 @@ typedef struct videoDeviceConfig */ void dsLoadConfigs(void); +/** + * Free the config dynamic pointers + */ +void dsFreeConfig(); + #ifdef __cplusplus } #endif diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index db022fcf..d0c90fad 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -162,7 +162,7 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) // Allocate and copy audio type configs if (allocateAndCopyAudioConfigs(audioConfigs, configSize, isDynamic) == -1) { INT_ERROR("Failed to allocate audio type configs\n"); - return; + return -1; } // Allocate and copy audio port configs @@ -173,7 +173,7 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) free(audioConfiguration.pKAudioConfigs); audioConfiguration.pKAudioConfigs = NULL; } - return; + return -1; } INT_INFO("Store sizes configSize =%d, portSize =%d\n", configSize, portSize); @@ -190,6 +190,7 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) audioConfiguration.kPortSize); audioDumpconfig(&audioConfiguration); + return 0; } // Getter functions for use across srv code diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c index c0170b30..849653a0 100644 --- a/rpc/srv/dsConfigs.c +++ b/rpc/srv/dsConfigs.c @@ -84,7 +84,7 @@ static int LoadDLSymbols(void* pDLHandle, const dlSymbolLookup_t* symbols, int n static void loadDeviceCapabilities(unsigned int capabilityType) { void* pDLHandle = NULL; - int isSymbolsLoaded = 0; + int isSymbolsLoaded = 0, ret = -1; INT_INFO("Entering capabilityType = 0x%08X\n", capabilityType); dlerror(); /* clear old error */ @@ -108,7 +108,11 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, audioConfigSymbols, sizeof(audioConfigSymbols)/sizeof(dlSymbolLookup_t)); } - dsLoadAudioOutputPortConfig(isSymbolsLoaded ? &dynamicAudioConfigs : NULL); + ret = dsLoadAudioOutputPortConfig(isSymbolsLoaded ? &dynamicAudioConfigs : NULL); + if(ret == -1) + { + INT_ERROR("dsLoadAudioOutputPortConfig() failed"); + } } /* Video Port Config */ @@ -131,7 +135,11 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoPortConfigSymbols, sizeof(videoPortConfigSymbols)/sizeof(dlSymbolLookup_t)); } - dsLoadVideoOutputPortConfig(isSymbolsLoaded ? &dynamicVideoPortConfigs : NULL); + ret = dsLoadVideoOutputPortConfig(isSymbolsLoaded ? &dynamicVideoPortConfigs : NULL); + if(ret == -1) + { + INT_ERROR("dsLoadVideoOutputPortConfig() failed"); + } } /* Video Device Config */ @@ -149,7 +157,11 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoDeviceConfigSymbols, sizeof(videoDeviceConfigSymbols)/sizeof(dlSymbolLookup_t)); } - dsLoadVideoDeviceConfig(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : NULL); + ret = dsLoadVideoDeviceConfig(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : NULL); + if(ret == -1) + { + INT_ERROR("dsLoadVideoDeviceConfig() failed"); + } } if (NULL != pDLHandle) { @@ -168,6 +180,15 @@ void dsLoadConfigs(void) INT_INFO("Exit function\n"); } +void dsFreeConfig() +{ + // Free dynamically allocated configuration memory + INT_INFO("Freeing device configuration resources\n"); + dsAudioConfigFree(); + dsVideoDeviceConfigFree(); + dsVideoPortConfigFree(); +} + #ifdef __cplusplus } #endif diff --git a/rpc/srv/dsMgr.c b/rpc/srv/dsMgr.c old mode 100755 new mode 100644 index 51d54104..9aeec6f5 --- a/rpc/srv/dsMgr.c +++ b/rpc/srv/dsMgr.c @@ -144,11 +144,7 @@ IARM_Result_t dsMgr_term() dsHdmiInMgr_term(); dsCompositeInMgr_term(); - // Free dynamically allocated configuration memory - INT_INFO("Freeing device configuration resources\n"); - dsAudioConfigFree(); - dsVideoDeviceConfigFree(); - dsVideoPortConfigFree(); + dsFreeConfig(); return ret; } diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index c2518d1d..7a655f9e 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -120,7 +120,7 @@ int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs // Allocate and copy video device configs if (allocateAndCopyVideoDeviceConfigs(videoConfigs, configSize, isDynamic) == -1) { INT_ERROR("Failed to allocate video device configs\n"); - return; + return -1; } INT_INFO("Store sizes configSize =%d\n", configSize); From f2369dd4d197476ba47b2cc1e8b5c8c72d209b73 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 23 Feb 2026 18:11:08 +0000 Subject: [PATCH 57/66] fix build issue --- rpc/include/dsVideoDeviceConfig.h | 2 +- rpc/include/dsVideoPortConfig.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/include/dsVideoDeviceConfig.h b/rpc/include/dsVideoDeviceConfig.h index 14dbd2ac..845c2637 100644 --- a/rpc/include/dsVideoDeviceConfig.h +++ b/rpc/include/dsVideoDeviceConfig.h @@ -45,7 +45,7 @@ typedef struct videoDeviceConfig * * @param[in] dynamicVideoDeviceConfigs Pointer to dynamic video device configuration, or NULL for static config */ -void dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs); +int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs); /** * @brief Get video device configurations diff --git a/rpc/include/dsVideoPortConfig.h b/rpc/include/dsVideoPortConfig.h index 09ea0b78..7c7dd97f 100644 --- a/rpc/include/dsVideoPortConfig.h +++ b/rpc/include/dsVideoPortConfig.h @@ -50,7 +50,7 @@ typedef struct videoPortConfigs * * @param[in] dynamicVideoPortConfigs Pointer to dynamic video port configuration, or NULL for static config */ -void dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); +int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); /** * @brief Get video port type configurations From 45343999d70a3e5166fb6bb3d1eb9e525fdd397d Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Wed, 25 Feb 2026 17:25:03 +0000 Subject: [PATCH 58/66] addresss all review comments --- ds/manager.cpp | 55 ++++---- rpc/include/dsAudioConfig.h | 19 ++- rpc/include/dsConfigs.h | 10 +- rpc/include/dsVideoDeviceConfig.h | 15 +-- rpc/include/dsVideoPortConfig.h | 28 ++-- rpc/include/dsserverlogger.h | 20 ++- rpc/srv/dsAudio.c | 12 +- rpc/srv/dsAudioConfig.c | 33 ++++- rpc/srv/dsConfigs.c | 58 +++++++-- rpc/srv/dsDisplay.c | 49 ++----- rpc/srv/dsMgr.c | 10 +- rpc/srv/dsVideoDeviceConfig.c | 63 ++++++++- rpc/srv/dsVideoPort.c | 96 ++++++-------- rpc/srv/dsVideoPortConfig.c | 208 +++++++++++++++++++++++++----- 14 files changed, 446 insertions(+), 230 deletions(-) diff --git a/ds/manager.cpp b/ds/manager.cpp index babc2a2e..535da298 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -43,11 +43,13 @@ #include "exception.hpp" #include #include +#include #include #include #include "dsHALConfig.h" #include "frontPanelConfig.hpp" + //static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; @@ -261,26 +263,21 @@ dsError_t initializeFunctionWithRetry(const char* functionName, */ void Manager::Initialize() { - {std::lock_guard lock(gManagerInitMutex); - - INT_INFO("Entering ... count %d with thread id %lu\n",IsInitialized,pthread_self()); + bool needInit = false; + + {std::lock_guard lock(gManagerInitMutex); + printf("Entering %s count %d with thread id %lu\n",__FUNCTION__,IsInitialized,pthread_self()); + if (IsInitialized == 0) { + needInit = true; + } + IsInitialized++; + } - try { - if (0 == IsInitialized) { - - dsError_t err = dsERR_GENERAL; - unsigned int retryCount = 0; - // This retry logic will wait for the device manager initialization from the client side - // until the device manager service initialization is completed. The retry mechanism checks - // only for dsERR_INVALID_STATE, which is reported if the underlying service is not ready. - // Once the service is ready, other port initializations can be called directly without any delay. - // That's why the retry logic is applied only for dsDisplayInit. - do { - err = dsDisplayInit(); - INT_INFO("dsDisplayInit returned %d, retryCount %d", err, retryCount); - if (dsERR_NONE == err) break; - usleep(100000); - } while(( dsERR_INVALID_STATE == err) && (retryCount++ < 25)); + try { + if (needInit) { + dsError_t err = dsERR_GENERAL; + + err = initializeFunctionWithRetry("dsDisplayInit", dsDisplayInit); CHECK_RET_VAL(err); err = initializeFunctionWithRetry("dsAudioPortInit", dsAudioPortInit); @@ -288,21 +285,23 @@ void Manager::Initialize() err = initializeFunctionWithRetry("dsVideoPortInit", dsVideoPortInit); CHECK_RET_VAL(err); - err = dsVideoDeviceInit(); - CHECK_RET_VAL(err); - + + err = initializeFunctionWithRetry("dsVideoDeviceInit", dsVideoDeviceInit); + CHECK_RET_VAL(err); + loadDeviceCapabilities(device::DEVICE_CAPABILITY_VIDEO_PORT | device::DEVICE_CAPABILITY_AUDIO_PORT | device::DEVICE_CAPABILITY_VIDEO_DEVICE | device::DEVICE_CAPABILITY_FRONT_PANEL); - } - IsInitialized++; + } } catch(const Exception &e) { - cout << "Caught exception during Initialization" << e.what() << endl; - throw e; - } - } + cout << "Caught exception during Initialization" << e.what() << endl; + std::lock_guard lock(gManagerInitMutex); + IsInitialized--; + throw e; + } + INT_INFO("Exiting ... with thread id %lu",pthread_self()); } diff --git a/rpc/include/dsAudioConfig.h b/rpc/include/dsAudioConfig.h index 7e7d7bc9..9723d79c 100644 --- a/rpc/include/dsAudioConfig.h +++ b/rpc/include/dsAudioConfig.h @@ -28,42 +28,39 @@ #define _DS_AUDIO_CONFIG_H_ #include "dsTypes.h" -//#include "dsAudioSettings.h" +#include "dsError.h" +#include "dsConfigs.h" #ifdef __cplusplus extern "C" { #endif -typedef struct audioConfigs -{ - const dsAudioTypeConfig_t *pKAudioConfigs; - const dsAudioPortConfig_t *pKAudioPorts; - int *pKConfigSize; - int *pKPortSize; -}audioConfigs_t; /** * @brief Load audio output port configuration * * @param[in] dynamicAudioConfigs Pointer to dynamic audio configuration, or NULL for static config + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs); +dsError_t dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs); /** * @brief Get audio type configurations * * @param[out] outConfigSize Pointer to store the number of audio type configs, or NULL * @param[out] outConfigs Pointer to store the audio type configs array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs); +dsError_t _dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs); /** * @brief Get audio port configurations * * @param[out] outPortSize Pointer to store the number of audio port configs, or NULL * @param[out] outPorts Pointer to store the audio port configs array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts); +dsError_t _dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts); /** * @brief Free audio configuration resources diff --git a/rpc/include/dsConfigs.h b/rpc/include/dsConfigs.h index 5bee2220..5bea4ca8 100644 --- a/rpc/include/dsConfigs.h +++ b/rpc/include/dsConfigs.h @@ -28,9 +28,7 @@ #define _DS_CONFIGS_H_ #include "dsTypes.h" -//#include "dsAudioSettings.h" -//#include "dsVideoPortSettings.h" -//#include "dsVideoDeviceSettings.h" +#include "dsError.h" #ifdef __cplusplus extern "C" { @@ -65,13 +63,15 @@ typedef struct videoDeviceConfig * @brief Load all device settings configurations * * Loads audio, video port, and video device configurations from HAL library + * @return dsERR_NONE on success, dsERR_GENERAL on failure */ -void dsLoadConfigs(void); +dsError_t dsLoadConfigs(void); /** * Free the config dynamic pointers + * @return dsERR_NONE on success, dsERR_GENERAL on failure */ -void dsFreeConfig(); +dsError_t dsFreeConfig(); #ifdef __cplusplus } diff --git a/rpc/include/dsVideoDeviceConfig.h b/rpc/include/dsVideoDeviceConfig.h index 845c2637..f95ef795 100644 --- a/rpc/include/dsVideoDeviceConfig.h +++ b/rpc/include/dsVideoDeviceConfig.h @@ -28,32 +28,29 @@ #define _DS_VIDEO_DEVICE_CONFIG_H_ #include "dsTypes.h" -//#include "dsVideoDeviceSettings.h" +#include "dsError.h" +#include "dsConfigs.h" #ifdef __cplusplus extern "C" { #endif -typedef struct videoDeviceConfig -{ - dsVideoConfig_t *pKVideoDeviceConfigs; - int *pKVideoDeviceConfigs_size; -}videoDeviceConfig_t; - /** * @brief Load video device configuration * * @param[in] dynamicVideoDeviceConfigs Pointer to dynamic video device configuration, or NULL for static config + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs); +dsError_t dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs); /** * @brief Get video device configurations * * @param[out] outConfigSize Pointer to store the number of video device configs, or NULL * @param[out] outConfigs Pointer to store the video device configs array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs); +dsError_t _dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs); /** * @brief Free video device configuration resources diff --git a/rpc/include/dsVideoPortConfig.h b/rpc/include/dsVideoPortConfig.h index 7c7dd97f..be525120 100644 --- a/rpc/include/dsVideoPortConfig.h +++ b/rpc/include/dsVideoPortConfig.h @@ -28,60 +28,56 @@ #define _DS_VIDEO_PORT_CONFIG_H_ #include "dsTypes.h" -//#include "dsVideoPortSettings.h" +#include "dsError.h" +#include "dsConfigs.h" #ifdef __cplusplus extern "C" { #endif -typedef struct videoPortConfigs -{ - const dsVideoPortTypeConfig_t *pKVideoPortConfigs; - int *pKVideoPortConfigs_size; - const dsVideoPortPortConfig_t *pKVideoPortPorts; - int *pKVideoPortPorts_size; - dsVideoPortResolution_t *pKVideoPortResolutionsSettings; - int *pKResolutionsSettings_size; - int *pKDefaultResIndex; -}videoPortConfigs_t; /** * @brief Load video output port configuration * * @param[in] dynamicVideoPortConfigs Pointer to dynamic video port configuration, or NULL for static config + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); +dsError_t dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs); /** * @brief Get video port type configurations * * @param[out] outConfigSize Pointer to store the number of video port type configs, or NULL * @param[out] outConfigs Pointer to store the video port type configs array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs); +dsError_t _dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs); /** * @brief Get video port port configurations * * @param[out] outPortSize Pointer to store the number of video port port configs, or NULL * @param[out] outPorts Pointer to store the video port port configs array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts); +dsError_t _dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts); /** * @brief Get video port resolutions * * @param[out] outResolutionSize Pointer to store the number of video port resolutions, or NULL * @param[out] outResolutions Pointer to store the video port resolutions array, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions); +dsError_t _dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions); /** * @brief Get default resolution index * * @param[out] outDefaultIndex Pointer to store the default resolution index, or NULL + * @return dsERR_NONE on success, dsERR_GENERAL on error */ -void dsGetDefaultResolutionIndex(int* outDefaultIndex); +dsError_t _dsGetDefaultResolutionIndex(int* outDefaultIndex); /** * @brief Free video port configuration resources diff --git a/rpc/include/dsserverlogger.h b/rpc/include/dsserverlogger.h index b2df3944..d33d3973 100644 --- a/rpc/include/dsserverlogger.h +++ b/rpc/include/dsserverlogger.h @@ -30,22 +30,30 @@ #define _DS_SERVER_LOGGER_H_ #include +#include #include "dsserverregisterlog.h" int ds_server_log(int priority,const char *format, ...); +// Helper to extract filename from full path +// E.g. "/path/to/file.cpp" -> "file.cpp" +// IMPORTANT: This will work for Unix style paths only +static inline const char* fileName(const char* path) { + const char* slash = strrchr(path, '/'); + return slash ? slash + 1 : path; +} #if (defined(DSMGR_LOGGER_ENABLED)) #include "rdk_debug.h" void dsServer_Rdklogger_Init(); -#define INT_ERROR(FORMAT, ...) LOG_ERROR(PREFIX(FORMAT), __LINE__, __FUNCTION__, ##__VA_ARGS__) -#define INT_WARNING(FORMAT, ...) LOG_WARNING(PREFIX(FORMAT), __LINE__, __FUNCTION__, ##__VA_ARGS__) -#define INT_INFO(FORMAT, ...) LOG_INFO(PREFIX(FORMAT), __LINE__, __FUNCTION__, ##__VA_ARGS__) -#define INT_DEBUG(FORMAT, ...) LOG_DEBUG(PREFIX(FORMAT), __LINE__, __FUNCTION__, ##__VA_ARGS__) -#define INT_TRACE(FORMAT, ...) LOG_TRACE(PREFIX(FORMAT), __LINE__, __FUNCTION__, ##__VA_ARGS__) +#define INT_ERROR(FORMAT, ...) LOG_ERROR(PREFIX(FORMAT), fileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) +#define INT_WARNING(FORMAT, ...) LOG_WARNING(PREFIX(FORMAT), fileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) +#define INT_INFO(FORMAT, ...) LOG_INFO(PREFIX(FORMAT), fileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) +#define INT_DEBUG(FORMAT, ...) LOG_DEBUG(PREFIX(FORMAT), fileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) +#define INT_TRACE(FORMAT, ...) LOG_TRACE(PREFIX(FORMAT), fileName(__FILE__), __LINE__, __FUNCTION__, ##__VA_ARGS__) -#define PREFIX(FORMAT) "%d\t: %s - " FORMAT +#define PREFIX(FORMAT) "[%s:%d] %s: " FORMAT extern int b_rdk_logger_enabled; diff --git a/rpc/srv/dsAudio.c b/rpc/srv/dsAudio.c index 2e20ff1b..fb6f95b8 100755 --- a/rpc/srv/dsAudio.c +++ b/rpc/srv/dsAudio.c @@ -49,7 +49,6 @@ #include "dsMgr.h" #include "hostPersistence.hpp" #include "dsserverlogger.h" -//#include "dsAudioSettings.h" #include "dsAudioConfig.h" #include "safec_lib.h" @@ -3794,17 +3793,20 @@ static dsAudioPortType_t _GetAudioPortType(intptr_t handle) int numPorts = 0; int i; intptr_t halhandle = 0; - const dsAudioPortConfig_t *kAudioPorts = NULL; + const dsAudioPortConfig_t *pAudioPorts = NULL; // Get audio port configurations from AudioOutputPortConfig - dsGetAudioPortConfigs(&numPorts, &kAudioPorts); + if (_dsGetAudioPortConfigs(&numPorts, &pAudioPorts) != dsERR_NONE) { + INT_ERROR("Failed to get audio port configurations\n"); + return dsAUDIOPORT_TYPE_MAX; + } for(i=0; i< numPorts; i++) { - if(dsGetAudioPort (kAudioPorts[i].id.type, kAudioPorts[i].id.index, &halhandle) == dsERR_NONE) { + if(dsGetAudioPort (pAudioPorts[i].id.type, pAudioPorts[i].id.index, &halhandle) == dsERR_NONE) { if (handle == halhandle) { - return kAudioPorts[i].id.type; + return pAudioPorts[i].id.type; } } } diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index d0c90fad..9c430d87 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * - * Copyright 2016 RDK Management + * Copyright 2026 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ #include #include "dsserverlogger.h" #include "dsTypes.h" +#include "dsError.h" #include "dsAudioConfig.h" #include "dsAudioSettings.h" @@ -135,13 +136,14 @@ static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numE return numElements; } -int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) +dsError_t dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) { int configSize, portSize; const dsAudioTypeConfig_t* audioConfigs; const dsAudioPortConfig_t* audioPorts; bool isDynamic; + INT_INFO("Using '%s' config\n", dynamicAudioConfigs ? "dynamic" : "static"); // Set up parameters based on config source @@ -162,7 +164,7 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) // Allocate and copy audio type configs if (allocateAndCopyAudioConfigs(audioConfigs, configSize, isDynamic) == -1) { INT_ERROR("Failed to allocate audio type configs\n"); - return -1; + return dsERR_GENERAL; } // Allocate and copy audio port configs @@ -173,7 +175,7 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) free(audioConfiguration.pKAudioConfigs); audioConfiguration.pKAudioConfigs = NULL; } - return -1; + return dsERR_GENERAL; } INT_INFO("Store sizes configSize =%d, portSize =%d\n", configSize, portSize); @@ -190,28 +192,45 @@ int dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) audioConfiguration.kPortSize); audioDumpconfig(&audioConfiguration); - return 0; + return dsERR_NONE; } // Getter functions for use across srv code -void dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs) +dsError_t _dsGetAudioTypeConfigs(int* outConfigSize, const dsAudioTypeConfig_t** outConfigs) { + + if((outConfigSize == NULL) && (outConfigs == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } + if (outConfigSize != NULL) { *outConfigSize = audioConfiguration.kConfigSize; } if (outConfigs != NULL) { *outConfigs = audioConfiguration.pKAudioConfigs; } + + return dsERR_NONE; } -void dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts) +dsError_t _dsGetAudioPortConfigs(int* outPortSize, const dsAudioPortConfig_t** outPorts) { + + if((outPortSize == NULL) && (outPorts == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } if (outPortSize != NULL) { *outPortSize = audioConfiguration.kPortSize; } if (outPorts != NULL) { *outPorts = audioConfiguration.pKAudioPorts; } + + return dsERR_NONE; } void dsAudioConfigFree(void) diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c index 849653a0..7fd6214c 100644 --- a/rpc/srv/dsConfigs.c +++ b/rpc/srv/dsConfigs.c @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * - * Copyright 2016 RDK Management + * Copyright 2026 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,8 @@ typedef struct { void** dataptr; } dlSymbolLookup_t; +static int configsLoaded = 0; + static int LoadDLSymbols(void* pDLHandle, const dlSymbolLookup_t* symbols, int numberOfSymbols) { @@ -81,10 +83,11 @@ static int LoadDLSymbols(void* pDLHandle, const dlSymbolLookup_t* symbols, int n return isAllSymbolsLoaded; } -static void loadDeviceCapabilities(unsigned int capabilityType) +static dsError_t loadDeviceCapabilities(unsigned int capabilityType) { void* pDLHandle = NULL; - int isSymbolsLoaded = 0, ret = -1; + int isSymbolsLoaded = 0; + dsError_t ret = dsERR_GENERAL, audioRet = dsERR_GENERAL, videoRet = dsERR_GENERAL, videoPortRet = dsERR_GENERAL; INT_INFO("Entering capabilityType = 0x%08X\n", capabilityType); dlerror(); /* clear old error */ @@ -108,8 +111,8 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, audioConfigSymbols, sizeof(audioConfigSymbols)/sizeof(dlSymbolLookup_t)); } - ret = dsLoadAudioOutputPortConfig(isSymbolsLoaded ? &dynamicAudioConfigs : NULL); - if(ret == -1) + audioRet = dsLoadAudioOutputPortConfig(isSymbolsLoaded ? &dynamicAudioConfigs : NULL); + if(audioRet == dsERR_GENERAL) { INT_ERROR("dsLoadAudioOutputPortConfig() failed"); } @@ -135,8 +138,8 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoPortConfigSymbols, sizeof(videoPortConfigSymbols)/sizeof(dlSymbolLookup_t)); } - ret = dsLoadVideoOutputPortConfig(isSymbolsLoaded ? &dynamicVideoPortConfigs : NULL); - if(ret == -1) + videoPortRet = dsLoadVideoOutputPortConfig(isSymbolsLoaded ? &dynamicVideoPortConfigs : NULL); + if(videoPortRet == dsERR_GENERAL) { INT_ERROR("dsLoadVideoOutputPortConfig() failed"); } @@ -157,8 +160,8 @@ static void loadDeviceCapabilities(unsigned int capabilityType) isSymbolsLoaded = LoadDLSymbols(pDLHandle, videoDeviceConfigSymbols, sizeof(videoDeviceConfigSymbols)/sizeof(dlSymbolLookup_t)); } - ret = dsLoadVideoDeviceConfig(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : NULL); - if(ret == -1) + videoRet = dsLoadVideoDeviceConfig(isSymbolsLoaded ? &dynamicVideoDeviceConfigs : NULL); + if(videoRet == dsERR_GENERAL) { INT_ERROR("dsLoadVideoDeviceConfig() failed"); } @@ -168,25 +171,56 @@ static void loadDeviceCapabilities(unsigned int capabilityType) dlclose(pDLHandle); pDLHandle = NULL; } + + if(audioRet == dsERR_GENERAL || videoRet == dsERR_GENERAL || videoPortRet == dsERR_GENERAL) + { + INT_ERROR("Failed to load device capabilities: audioRet=%d, videoRet=%d, videoPortRet=%d\n", audioRet, videoRet, videoPortRet); + return dsERR_GENERAL; + } INT_INFO("Exiting ...\n"); + return dsERR_NONE; } -void dsLoadConfigs(void) +dsError_t dsLoadConfigs(void) { + dsError_t ret = dsERR_GENERAL; + INT_INFO("Enter function\n"); - loadDeviceCapabilities(DEVICE_CAPABILITY_VIDEO_PORT | + + // Check if configs are already loaded + if (configsLoaded) { + INT_INFO("Configs already loaded, skipping reload\n"); + return dsERR_NONE; + } + + //TODO:Add the mutex lock handel in future + ret = loadDeviceCapabilities(DEVICE_CAPABILITY_VIDEO_PORT | DEVICE_CAPABILITY_AUDIO_PORT | DEVICE_CAPABILITY_VIDEO_DEVICE); + if (ret == dsERR_GENERAL) + { + INT_ERROR("[srv] load failed\n "); + return ret; + } + + // Mark configs as loaded + configsLoaded = 1; INT_INFO("Exit function\n"); + return dsERR_NONE; } -void dsFreeConfig() +dsError_t dsFreeConfig() { // Free dynamically allocated configuration memory INT_INFO("Freeing device configuration resources\n"); dsAudioConfigFree(); dsVideoDeviceConfigFree(); dsVideoPortConfigFree(); + + // Reset loaded flag so configs can be reloaded if needed + configsLoaded = 0; + INT_INFO("Config freed and reload flag reset\n"); + return dsERR_NONE; } #ifdef __cplusplus diff --git a/rpc/srv/dsDisplay.c b/rpc/srv/dsDisplay.c index 91a89dc4..1388be29 100644 --- a/rpc/srv/dsDisplay.c +++ b/rpc/srv/dsDisplay.c @@ -46,10 +46,7 @@ #include "dsMgr.h" #include "dsserverlogger.h" #include "dsVideoPort.h" -//#include "dsVideoPortSettings.h" -//#include "dsVideoResolutionSettings.h" #include "dsVideoPortConfig.h" -//#include "dsConfigs.h" #include "dsInternal.h" #include "safec_lib.h" @@ -580,7 +577,7 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) { errno_t rc = -1; dsVideoPortResolution_t *edidResn = NULL; - dsVideoPortResolution_t *presolution = NULL, *kVidoeResolutionsSettings = NULL; + dsVideoPortResolution_t *presolution = NULL, *pVideoResolutionsSettings = NULL; dsDisplayEDID_t *edidData = (dsDisplayEDID_t*)malloc(sizeof(dsDisplayEDID_t)); dsVideoPortType_t _VPortType = _GetDisplayPortType(handle); if (edid == NULL) { @@ -592,22 +589,12 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) if(_VPortType == dsVIDEOPORT_TYPE_HDMI) { INT_DEBUG("EDID for HDMI Port\r\n"); - //size_t iCount = dsUTL_DIM(kResolutions); int iCount = 0; //Get details from libds - dsGetVideoPortResolutions(&iCount, &kVidoeResolutionsSettings); - - // Print kVidoeResolutionsSettings array - INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array ==========\r\n"); - INT_INFO("[DsMgr] Total resolutions retrieved: %d\r\n", iCount); - for (int k = 0; k < iCount; k++) { - dsVideoPortResolution_t *res = &kVidoeResolutionsSettings[k]; - INT_INFO("[DsMgr] [%d] name=%s, pixelRes=%d, aspectRatio=%d, stereoMode=%d, frameRate=%d, interlaced=%d\r\n", - k, res->name, res->pixelResolution, res->aspectRatio, - res->stereoScopicMode, res->frameRate, res->interlaced); + if (_dsGetVideoPortResolutions(&iCount, &pVideoResolutionsSettings) != dsERR_NONE) { + INT_ERROR("Failed to get video port resolutions\n"); } - INT_INFO("[DsMgr] ========== End of kVidoeResolutionsSettings Dump ==========\r\n"); - + /*Initialize the struct*/ memset(edidData,0,sizeof(*edidData)); /*Copy the content */ @@ -620,14 +607,14 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) edid->numOfSupportedResolution = 0; for (size_t i = 0; i < iCount; i++) { - presolution = &kVidoeResolutionsSettings[i]; + presolution = &pVideoResolutionsSettings[i]; for (size_t j = 0; j < edidData->numOfSupportedResolution; j++) { edidResn = &(edidData->suppResolutionList[j]); if (0 == (strcmp(presolution->name,edidResn->name))) { - edid->suppResolutionList[edid->numOfSupportedResolution] = kVidoeResolutionsSettings[i]; + edid->suppResolutionList[edid->numOfSupportedResolution] = pVideoResolutionsSettings[i]; edid->numOfSupportedResolution++; numOfSupportedResolution++; INT_DEBUG("[DsMgr] presolution->name : %s, resolution count : %d\r\n",presolution->name,numOfSupportedResolution); @@ -662,29 +649,19 @@ static dsVideoPortType_t _GetDisplayPortType(intptr_t handle) { int numPorts,i; intptr_t halhandle = 0; - const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; + const dsVideoPortPortConfig_t *pVideoPortPorts = NULL; - //numPorts = dsUTL_DIM(kSupportedPortTypes); - dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); - - // Print kVideoPortPorts array - INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array ==========\r\n"); - INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); - for (int k = 0; k < numPorts; k++) { - const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; - INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", - k, port->id.type, port->id.index, - port->connectedAOP.type, port->connectedAOP.index, - port->defaultResolution); + if (_dsGetVideoPortPortConfigs(&numPorts, &pVideoPortPorts) != dsERR_NONE) { + INT_ERROR("Failed to get video port port configurations\n"); + return dsVIDEOPORT_TYPE_MAX; } - INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); - + for(i=0; i< numPorts; i++) { - dsGetDisplay(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); + dsGetDisplay(pVideoPortPorts[i].id.type, pVideoPortPorts[i].id.index, &halhandle); if (handle == halhandle) { - return kVideoPortPorts[i].id.type; + return pVideoPortPorts[i].id.type; } } INT_INFO("Error: The Requested Display is not part of Platform Port Configuration \r\n"); diff --git a/rpc/srv/dsMgr.c b/rpc/srv/dsMgr.c index 9aeec6f5..3939bee7 100644 --- a/rpc/srv/dsMgr.c +++ b/rpc/srv/dsMgr.c @@ -115,7 +115,10 @@ IARM_Result_t dsMgr_init() INT_INFO("[%s]: profileType=%d\r\n", __FUNCTION__, profileType); INT_INFO("[%s]: Loading device configurations\r\n", __FUNCTION__); - dsLoadConfigs(); + if (dsLoadConfigs() != dsERR_NONE) { + INT_ERROR("[%s]: Failed to load device configurations\r\n", __FUNCTION__); + return IARM_RESULT_INVALID_STATE; + } device::HostPersistence::getInstance().load(); dsServer_Rdklogger_Init(); dsHostInit(); @@ -144,7 +147,10 @@ IARM_Result_t dsMgr_term() dsHdmiInMgr_term(); dsCompositeInMgr_term(); - dsFreeConfig(); + if (dsFreeConfig() != dsERR_NONE) { + INT_ERROR("[%s]: Failed to free device configurations\r\n", __FUNCTION__); + ret = IARM_RESULT_INVALID_STATE; + } return ret; } diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index 7a655f9e..7bead769 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * - * Copyright 2016 RDK Management + * Copyright 2026 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ #include #include "dsserverlogger.h" #include "dsTypes.h" +#include "dsError.h" #include "dsVideoDeviceConfig.h" #include "dsVideoDeviceSettings.h" @@ -93,12 +94,48 @@ static int allocateAndCopyVideoDeviceConfigs(const dsVideoConfig_t* source, int return -1; } + /* First copy the structures themselves. Pointer fields (such as 'supportedDFCs') will be + * fixed up below to avoid shallow copies into HAL-owned memory. */ memcpy(videoDeviceConfiguration.pKVideoDeviceConfigs, source, numElements * sizeof(dsVideoConfig_t)); + + /* Deep copy the 'supportedDFCs' array for each config so it does not reference + * memory owned by the HAL library, which may be unloaded. */ + for (int i = 0; i < numElements; ++i) + { + if (source[i].supportedDFCs != NULL && source[i].numSupportedDFCs > 0) + { + size_t dfcArraySize = source[i].numSupportedDFCs * sizeof(dsVideoZoom_t); + dsVideoZoom_t *dupDFCs = (dsVideoZoom_t*)malloc(dfcArraySize); + if (dupDFCs == NULL) + { + INT_ERROR("Failed to duplicate %s video device config supportedDFCs at index %d\n", configType, i); + /* Clean up any DFCs already duplicated and the configs array itself. */ + for (int j = 0; j < i; ++j) + { + if (videoDeviceConfiguration.pKVideoDeviceConfigs[j].supportedDFCs != NULL) + { + free((void*)videoDeviceConfiguration.pKVideoDeviceConfigs[j].supportedDFCs); + videoDeviceConfiguration.pKVideoDeviceConfigs[j].supportedDFCs = NULL; + } + } + free(videoDeviceConfiguration.pKVideoDeviceConfigs); + videoDeviceConfiguration.pKVideoDeviceConfigs = NULL; + return -1; + } + memcpy(dupDFCs, source[i].supportedDFCs, dfcArraySize); + videoDeviceConfiguration.pKVideoDeviceConfigs[i].supportedDFCs = dupDFCs; + } + else + { + videoDeviceConfiguration.pKVideoDeviceConfigs[i].supportedDFCs = NULL; + } + } + INT_INFO("Allocated and copied %d video device configs (%s)\n", numElements, configType); return numElements; } -int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) +dsError_t dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs) { int configSize; const dsVideoConfig_t* videoConfigs; @@ -120,7 +157,7 @@ int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs // Allocate and copy video device configs if (allocateAndCopyVideoDeviceConfigs(videoConfigs, configSize, isDynamic) == -1) { INT_ERROR("Failed to allocate video device configs\n"); - return -1; + return dsERR_GENERAL; } INT_INFO("Store sizes configSize =%d\n", configSize); @@ -131,18 +168,26 @@ int dsLoadVideoDeviceConfig(const videoDeviceConfig_t* dynamicVideoDeviceConfigs videoDeviceConfiguration.pKVideoDeviceConfigs, videoDeviceConfiguration.kVideoDeviceConfigs_size); videoDeviceDumpconfig(&videoDeviceConfiguration); - return 0; + return dsERR_NONE; } // Getter functions for use across srv code -void dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) +dsError_t _dsGetVideoDeviceConfigs(int* outConfigSize, dsVideoConfig_t** outConfigs) { + + if((outConfigSize == NULL) && (outConfigs == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } if (outConfigSize != NULL) { *outConfigSize = videoDeviceConfiguration.kVideoDeviceConfigs_size; } if (outConfigs != NULL) { *outConfigs = videoDeviceConfiguration.pKVideoDeviceConfigs; } + + return dsERR_NONE; } void dsVideoDeviceConfigFree(void) @@ -151,6 +196,14 @@ void dsVideoDeviceConfigFree(void) // Free video device configs if (videoDeviceConfiguration.pKVideoDeviceConfigs != NULL) { + // Free each supportedDFCs array + for (int i = 0; i < videoDeviceConfiguration.kVideoDeviceConfigs_size; ++i) { + if (videoDeviceConfiguration.pKVideoDeviceConfigs[i].supportedDFCs != NULL) { + free((void*)videoDeviceConfiguration.pKVideoDeviceConfigs[i].supportedDFCs); + videoDeviceConfiguration.pKVideoDeviceConfigs[i].supportedDFCs = NULL; + INT_INFO("Freed pKVideoDeviceConfigs[%d].supportedDFCs\n", i); + } + } free(videoDeviceConfiguration.pKVideoDeviceConfigs); videoDeviceConfiguration.pKVideoDeviceConfigs = NULL; INT_INFO("Freed pKVideoDeviceConfigs\n"); diff --git a/rpc/srv/dsVideoPort.c b/rpc/srv/dsVideoPort.c index 0aa50bc9..696a6f2f 100644 --- a/rpc/srv/dsVideoPort.c +++ b/rpc/srv/dsVideoPort.c @@ -51,9 +51,7 @@ #include "hostPersistence.hpp" #include "dsserverlogger.h" #include "dsTypes.h" -//#include "dsVideoPortSettings.h" #include "dsVideoPortConfig.h" -//#include "dsConfigs.h" #include "dsInternal.h" #include "safec_lib.h" #include @@ -1705,28 +1703,19 @@ static dsVideoPortType_t _GetVideoPortType(intptr_t handle) { int numPorts = 0, i; intptr_t halhandle = 0; - const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; + const dsVideoPortPortConfig_t *pVideoPortPorts = NULL; + + if (_dsGetVideoPortPortConfigs(&numPorts, &pVideoPortPorts) != dsERR_NONE) { + INT_ERROR("Failed to get video port port configurations\n"); + return dsVIDEOPORT_TYPE_MAX; + } - dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); - - // Print kVideoPortPorts array - INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in _GetVideoPortType ==========\r\n"); - INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); - for (int k = 0; k < numPorts; k++) { - const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; - INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", - k, port->id.type, port->id.index, - port->connectedAOP.type, port->connectedAOP.index, - port->defaultResolution ? port->defaultResolution : "NULL"); - } - INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); - for(i=0; i< numPorts; i++) { - dsGetVideoPort(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); + dsGetVideoPort(pVideoPortPorts[i].id.type, pVideoPortPorts[i].id.index, &halhandle); if (handle == halhandle) { - return kVideoPortPorts[i].id.type; + return pVideoPortPorts[i].id.type; } } INT_ERROR("Error: The Requested Video Port is not part of Platform Port Configuration \r\n"); @@ -1914,9 +1903,15 @@ static std::string getCompatibleResolution(dsVideoPortResolution_t *SrcResn) int numResolutions = 0; dsVideoPortResolution_t* resolutions = NULL; int defaultIndex = 0; - dsGetVideoPortResolutions(&numResolutions, &resolutions); - dsGetDefaultResolutionIndex(&defaultIndex); - if (resolutions && defaultIndex >= 0 && defaultIndex < numResolutions) { + if (_dsGetVideoPortResolutions(&numResolutions, &resolutions) != dsERR_NONE) { + INT_ERROR("Failed to get video port resolutions\n"); + break; + } + if (_dsGetDefaultResolutionIndex(&defaultIndex) != dsERR_NONE) { + INT_ERROR("Failed to get default resolution index\n"); + break; + } + if ((resolutions != NULL) && (defaultIndex >= 0) && (defaultIndex < numResolutions)) { return resolution.assign(resolutions[defaultIndex].name); } } @@ -1941,26 +1936,23 @@ static bool IsCompatibleResolution(dsVideoResolution_t pixelResolution1,dsVideo static dsVideoResolution_t getPixelResolution(std::string &resolution ) { - dsVideoPortResolution_t *kVidoeResolutionsSettings = NULL; + dsVideoPortResolution_t *pVidoeResolutionsSettings = NULL; int iCount = 0; - dsGetVideoPortResolutions(&iCount, &kVidoeResolutionsSettings); - - // Print kVidoeResolutionsSettings array - INT_INFO("[DsMgr] ========== Dumping kVidoeResolutionsSettings Array in getPixelResolution ==========\r\n"); - INT_INFO("[DsMgr] Total resolutions retrieved: %d\r\n", iCount); - for (int k = 0; k < iCount; k++) { - dsVideoPortResolution_t *res = &kVidoeResolutionsSettings[k]; - INT_INFO("[DsMgr] [%d] name=%s, pixelRes=%d, aspectRatio=%d, stereoMode=%d, frameRate=%d, interlaced=%d\r\n", - k, res->name, res->pixelResolution, res->aspectRatio, - res->stereoScopicMode, res->frameRate, res->interlaced); + if (_dsGetVideoPortResolutions(&iCount, &pVidoeResolutionsSettings) != dsERR_NONE) { + INT_ERROR("Failed to get video port resolutions\n"); + return dsVIDEO_PIXELRES_MAX; + } + + if (iCount <= 0 || pVidoeResolutionsSettings == NULL) { + INT_ERROR("_dsGetVideoPortResolutions returned invalid values (iCount=%d, pVidoeResolutionsSettings=%p)\n", iCount, pVidoeResolutionsSettings); + return dsVIDEO_PIXELRES_MAX; } - INT_INFO("[DsMgr] ========== End of kVidoeResolutionsSettings Dump ==========\r\n"); - - dsVideoPortResolution_t *Resn = &kVidoeResolutionsSettings[0]; + dsVideoPortResolution_t *Resn = &pVidoeResolutionsSettings[0]; + for (int i = 0; i < iCount; i++) { - Resn = &kVidoeResolutionsSettings[i]; + Resn = &pVidoeResolutionsSettings[i]; if (resolution.compare(Resn->name) == 0 ) { break; @@ -2298,7 +2290,10 @@ bool isComponentPortPresent() int numTypeConfigs = 0; const dsVideoPortTypeConfig_t* typeConfigs = NULL; - dsGetVideoPortTypeConfigs(&numTypeConfigs, &typeConfigs); + if (_dsGetVideoPortTypeConfigs(&numTypeConfigs, &typeConfigs) != dsERR_NONE) { + INT_ERROR("Failed to get video port type configurations\n"); + return false; + } if (typeConfigs) { for(int i=0; i< numTypeConfigs; i++) { @@ -2431,27 +2426,18 @@ intptr_t dsGetDefaultPortHandle() { int numPorts = 0, i; intptr_t halhandle = 0; - const dsVideoPortPortConfig_t *kVideoPortPorts = NULL; - - dsGetVideoPortPortConfigs(&numPorts, &kVideoPortPorts); + const dsVideoPortPortConfig_t *pVideoPortPorts = NULL; - // Print kVideoPortPorts array - INT_INFO("[DsMgr] ========== Dumping kVideoPortPorts Array in dsGetDefaultPortHandle ==========\r\n"); - INT_INFO("[DsMgr] Total ports retrieved: %d\r\n", numPorts); - for (int k = 0; k < numPorts; k++) { - const dsVideoPortPortConfig_t *port = &kVideoPortPorts[k]; - INT_INFO("[DsMgr] [%d] type=%d, index=%d, connectedAOP_type=%d, connectedAOP_index=%d, defaultResolution=%s\r\n", - k, port->id.type, port->id.index, - port->connectedAOP.type, port->connectedAOP.index, - port->defaultResolution ? port->defaultResolution : "NULL"); - } - INT_INFO("[DsMgr] ========== End of kVideoPortPorts Dump ==========\r\n"); + if (_dsGetVideoPortPortConfigs(&numPorts, &pVideoPortPorts) != dsERR_NONE) { + INT_ERROR("Failed to get video port port configurations\n"); + return NULL; + } for(i=0; i< numPorts; i++) { - dsGetVideoPort(kVideoPortPorts[i].id.type, kVideoPortPorts[i].id.index, &halhandle); - if (dsVIDEOPORT_TYPE_HDMI == kVideoPortPorts[i].id.type || - dsVIDEOPORT_TYPE_INTERNAL == kVideoPortPorts[i].id.type) + dsGetVideoPort(pVideoPortPorts[i].id.type, pVideoPortPorts[i].id.index, &halhandle); + if (dsVIDEOPORT_TYPE_HDMI == pVideoPortPorts[i].id.type || + dsVIDEOPORT_TYPE_INTERNAL == pVideoPortPorts[i].id.type) { return halhandle; } diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index e01b6fca..34df8693 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -2,7 +2,7 @@ * If not stated otherwise in this file or this component's LICENSE file the * following copyright and licenses apply: * - * Copyright 2016 RDK Management + * Copyright 2026 RDK Management * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ #include #include "dsserverlogger.h" #include "dsTypes.h" +#include "dsError.h" #include "dsVideoPortSettings.h" #include "dsVideoResolutionSettings.h" #include "dsVideoPortConfig.h" @@ -63,7 +64,7 @@ void videoPortDumpconfig(videoPortConfigsLocal_t *config) INT_INFO("\n=============== Starting to Dump VideoPort Configs ===============\n"); int configSize = -1, portSize = -1, resolutionSize = -1; - if (( NULL != config->pKVideoPortConfigs ) && ( NULL != config->pKVideoPortPorts ) && ( nullptr != config->pKVideoPortResolutionsSettings )) + if (( NULL != config->pKVideoPortConfigs ) && ( NULL != config->pKVideoPortPorts ) && ( NULL != config->pKVideoPortResolutionsSettings )) { configSize = config->kVideoPortConfigs_size; portSize = config->kVideoPortPorts_size; @@ -79,7 +80,7 @@ void videoPortDumpconfig(videoPortConfigsLocal_t *config) for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(config->pKVideoPortResolutionsSettings[i]); - INT_INFO("resolution->name = %s\n", resolution->name); + INT_INFO("resolution->name = %s\n", (resolution->name)? resolution->name : "NULL"); INT_INFO("resolution->pixelResolution= %d\n", resolution->pixelResolution); INT_INFO("resolution->aspectRatio= %d\n", resolution->aspectRatio); INT_INFO("resolution->stereoScopicMode= %d\n", resolution->stereoScopicMode); @@ -99,13 +100,27 @@ void videoPortDumpconfig(videoPortConfigsLocal_t *config) INT_INFO("typeCfg->restrictedResollution = %d\n", typeCfg->restrictedResollution); INT_INFO("typeCfg->numSupportedResolutions= %lu\n", typeCfg->numSupportedResolutions); - INT_INFO("typeCfg->supportedResolutions = %p\n", typeCfg->supportedResolutions); - INT_INFO("typeCfg->supportedResolutions->name = %s\n", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); - INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d\n", typeCfg->supportedResolutions->pixelResolution); - INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d\n", typeCfg->supportedResolutions->aspectRatio); - INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d\n", typeCfg->supportedResolutions->stereoScopicMode); - INT_INFO("typeCfg->supportedResolutions->frameRate= %d\n", typeCfg->supportedResolutions->frameRate); - INT_INFO("typeCfg->supportedResolutions->interlaced= %d\n", typeCfg->supportedResolutions->interlaced); + if ((typeCfg->supportedResolutions != NULL) && (typeCfg->numSupportedResolutions > 0)) + { + INT_INFO("typeCfg->supportedResolutions->name = %s\n", + (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); + INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d\n", + typeCfg->supportedResolutions->pixelResolution); + INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d\n", + typeCfg->supportedResolutions->aspectRatio); + INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d\n", + typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("typeCfg->supportedResolutions->frameRate= %d\n", + typeCfg->supportedResolutions->frameRate); + INT_INFO("typeCfg->supportedResolutions->interlaced= %d\n", + typeCfg->supportedResolutions->interlaced); + } + else + { + INT_INFO("typeCfg has no supportedResolutions entries to dump (pointer is %p, numSupportedResolutions = %lu)\n", + typeCfg->supportedResolutions, + typeCfg->numSupportedResolutions); + } } INT_INFO("\n############### Dumping Video Port Connections ###############\n"); @@ -141,7 +156,41 @@ static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source return -1; } + /* First copy the structures themselves. Pointer fields (such as 'name') will be + * fixed up below to avoid shallow copies into HAL-owned memory. */ memcpy(videoPortConfiguration.pKVideoPortConfigs, source, numElements * sizeof(dsVideoPortTypeConfig_t)); + + /* Deep copy the 'name' pointer for each config so it does not reference + * memory owned by the HAL library, which may be unloaded. */ + for (int i = 0; i < numElements; ++i) + { + if (source[i].name != NULL) + { + char *dupName = strdup(source[i].name); + if (dupName == NULL) + { + INT_ERROR("Failed to duplicate %s video port config name at index %d\n", configType, i); + /* Clean up any names already duplicated and the configs array itself. */ + for (int j = 0; j < i; ++j) + { + if (videoPortConfiguration.pKVideoPortConfigs[j].name != NULL) + { + free((void*)videoPortConfiguration.pKVideoPortConfigs[j].name); + videoPortConfiguration.pKVideoPortConfigs[j].name = "NULL"; + } + } + free(videoPortConfiguration.pKVideoPortConfigs); + videoPortConfiguration.pKVideoPortConfigs = NULL; + return -1; + } + videoPortConfiguration.pKVideoPortConfigs[i].name = dupName; + } + else + { + videoPortConfiguration.pKVideoPortConfigs[i].name = NULL; + } + } + INT_INFO("Allocated and copied %d video port configs (%s)\n", numElements, configType); return numElements; } @@ -161,7 +210,41 @@ static int allocateAndCopyVideoPortPorts(const dsVideoPortPortConfig_t* source, return -1; } + /* First copy the structures themselves. Pointer fields (such as 'defaultResolution') will be + * fixed up below to avoid shallow copies into HAL-owned memory. */ memcpy(videoPortConfiguration.pKVideoPortPorts, source, numElements * sizeof(dsVideoPortPortConfig_t)); + + /* Deep copy the 'defaultResolution' pointer for each port so it does not reference + * memory owned by the HAL library, which may be unloaded. */ + for (int i = 0; i < numElements; ++i) + { + if (source[i].defaultResolution != NULL) + { + char *dupResolution = strdup(source[i].defaultResolution); + if (dupResolution == NULL) + { + INT_ERROR("Failed to duplicate %s video port default resolution at index %d\n", configType, i); + /* Clean up any resolutions already duplicated and the ports array itself. */ + for (int j = 0; j < i; ++j) + { + if (videoPortConfiguration.pKVideoPortPorts[j].defaultResolution != NULL) + { + free((void*)videoPortConfiguration.pKVideoPortPorts[j].defaultResolution); + videoPortConfiguration.pKVideoPortPorts[j].defaultResolution = NULL; + } + } + free(videoPortConfiguration.pKVideoPortPorts); + videoPortConfiguration.pKVideoPortPorts = NULL; + return -1; + } + videoPortConfiguration.pKVideoPortPorts[i].defaultResolution = dupResolution; + } + else + { + videoPortConfiguration.pKVideoPortPorts[i].defaultResolution = NULL; + } + } + INT_INFO("Allocated and copied %d video port ports (%s)\n", numElements, configType); return numElements; } @@ -181,12 +264,14 @@ static int allocateAndCopyVideoPortResolutions(const dsVideoPortResolution_t* so return -1; } + /* Copy the structures. The 'name' field is a fixed array (char[32]), + * so memcpy correctly copies the entire content, not just a pointer. */ memcpy(videoPortConfiguration.pKVideoPortResolutionsSettings, source, numElements * sizeof(dsVideoPortResolution_t)); INT_INFO("Allocated and copied %d video port resolutions (%s)\n", numElements, configType); return numElements; } -int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) +dsError_t dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfigs) { int configSize, portSize, resolutionSize, defaultResIndex; const dsVideoPortTypeConfig_t* videoPortConfigs; @@ -217,10 +302,36 @@ int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfig isDynamic = false; } + // Allocate and copy video port resolutions FIRST (needed by configs) + if (allocateAndCopyVideoPortResolutions(videoPortResolutions, resolutionSize, isDynamic) == -1) { + INT_ERROR("Failed to allocate video port resolutions\n"); + return dsERR_GENERAL; + } + // Allocate and copy video port type configs if (allocateAndCopyVideoPortConfigs(videoPortConfigs, configSize, isDynamic) == -1) { INT_ERROR("Failed to allocate video port configs\n"); - return -1; + // Clean up previously allocated memory + if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { + for (int i = 0; i < videoPortConfiguration.kResolutionsSettings_size; ++i) { + if (videoPortConfiguration.pKVideoPortResolutionsSettings[i].name != NULL) { + free(videoPortConfiguration.pKVideoPortResolutionsSettings[i].name); + } + } + free(videoPortConfiguration.pKVideoPortResolutionsSettings); + videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; + } + return dsERR_GENERAL; + } + + // Update supportedResolutions pointers to point to our copied resolutions array + for (int i = 0; i < configSize; ++i) { + if (videoPortConfiguration.pKVideoPortConfigs[i].supportedResolutions != NULL) { + videoPortConfiguration.pKVideoPortConfigs[i].supportedResolutions = + videoPortConfiguration.pKVideoPortResolutionsSettings; + INT_INFO("Updated config[%d] supportedResolutions pointer to %p\n", + i, videoPortConfiguration.pKVideoPortResolutionsSettings); + } } // Allocate and copy video port ports @@ -228,25 +339,24 @@ int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfig INT_ERROR("Failed to allocate video port ports\n"); // Clean up previously allocated memory if (videoPortConfiguration.pKVideoPortConfigs != NULL) { + for (int i = 0; i < configSize; ++i) { + if (videoPortConfiguration.pKVideoPortConfigs[i].name != NULL) { + free((void*)videoPortConfiguration.pKVideoPortConfigs[i].name); + } + } free(videoPortConfiguration.pKVideoPortConfigs); videoPortConfiguration.pKVideoPortConfigs = NULL; } - return -1; - } - - // Allocate and copy video port resolutions - if (allocateAndCopyVideoPortResolutions(videoPortResolutions, resolutionSize, isDynamic) == -1) { - INT_ERROR("Failed to allocate video port resolutions\n"); - // Clean up previously allocated memory - if (videoPortConfiguration.pKVideoPortConfigs != NULL) { - free(videoPortConfiguration.pKVideoPortConfigs); - videoPortConfiguration.pKVideoPortConfigs = NULL; - } - if (videoPortConfiguration.pKVideoPortPorts != NULL) { - free(videoPortConfiguration.pKVideoPortPorts); - videoPortConfiguration.pKVideoPortPorts = NULL; + if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { + for (int i = 0; i < resolutionSize; ++i) { + if (videoPortConfiguration.pKVideoPortResolutionsSettings[i].name != NULL) { + free(videoPortConfiguration.pKVideoPortResolutionsSettings[i].name); + } + } + free(videoPortConfiguration.pKVideoPortResolutionsSettings); + videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; } - return -1; + return dsERR_GENERAL; } INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); @@ -270,51 +380,83 @@ int dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPortConfig videoPortConfiguration.kResolutionsSettings_size, videoPortConfiguration.kDefaultResIndex); videoPortDumpconfig(&videoPortConfiguration); - return 0; + return dsERR_NONE; } // Getter functions for use across srv code -void dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) +dsError_t _dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) { + + if((outConfigSize == NULL) && (outConfigs == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } if (outConfigSize != NULL) { *outConfigSize = videoPortConfiguration.kVideoPortConfigs_size; } if (outConfigs != NULL) { *outConfigs = videoPortConfiguration.pKVideoPortConfigs; } + + return dsERR_NONE; } -void dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) +dsError_t _dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) { + + if((outPortSize == NULL) && (outPorts == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } if (outPortSize != NULL) { *outPortSize = videoPortConfiguration.kVideoPortPorts_size; } if (outPorts != NULL) { *outPorts = videoPortConfiguration.pKVideoPortPorts; } + + return dsERR_NONE; } -void dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) +dsError_t _dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) { + + if((outResolutionSize == NULL) && (outResolutions == NULL)) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } if (outResolutionSize != NULL) { *outResolutionSize = videoPortConfiguration.kResolutionsSettings_size; } if (outResolutions != NULL) { *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; } + + return dsERR_NONE; } -void dsGetDefaultResolutionIndex(int* outDefaultIndex) +dsError_t _dsGetDefaultResolutionIndex(int* outDefaultIndex) { + + if(outDefaultIndex == NULL) + { + INT_ERROR("Invalid argument pointer\n"); + return dsERR_GENERAL; + } + if (outDefaultIndex != NULL) { *outDefaultIndex = videoPortConfiguration.kDefaultResIndex; } + + return dsERR_NONE; } void dsVideoPortConfigFree(void) { INT_INFO("Freeing VideoPort configuration resources\n"); - // Free video port configs if (videoPortConfiguration.pKVideoPortConfigs != NULL) { free(videoPortConfiguration.pKVideoPortConfigs); From 0cdf7e06dcebccef7d3e6402e3a9b15702265b52 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 26 Feb 2026 15:41:06 +0000 Subject: [PATCH 59/66] address copilt review and fix setresolution issue --- ds/Makefile | 8 ++++---- ds/include/videoDevice.hpp | 1 - ds/videoDevice.cpp | 4 ++-- ds/videoDeviceConfig.cpp | 2 -- ds/videoOutputPortConfig.cpp | 27 +++++++-------------------- ds/videoOutputPortConfig.hpp | 1 + rpc/srv/dsVideoPort.c | 17 ++++++++++++++--- 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/ds/Makefile b/ds/Makefile index 3000c0f2..e27e1bcc 100644 --- a/ds/Makefile +++ b/ds/Makefile @@ -33,17 +33,17 @@ INCLUDE := -I$(PWD) \ -I$(PWD)/config \ -I$(PWD)/hal/include \ -I$(PWD)/hal/src \ + -I$(PWD)/ds/include \ -I$(PWD)/ds \ - -I$(PWD)/rpc/include \ - -I$(PWD)/ds/include + -I$(PWD)/rpc/include else INCLUDE := -I$(PWD) \ -I$(LOG4C_INSTALL_DIR)/include \ -I$(PWD)/config \ -I$(PWD)/hal/include \ + -I$(PWD)/ds/include \ -I$(PWD)/ds \ - -I$(PWD)/rpc/include \ - -I$(PWD)/ds/include + -I$(PWD)/rpc/include endif diff --git a/ds/include/videoDevice.hpp b/ds/include/videoDevice.hpp index 331105fb..61ec375d 100644 --- a/ds/include/videoDevice.hpp +++ b/ds/include/videoDevice.hpp @@ -33,7 +33,6 @@ #include "dsConstant.hpp" #include "videoDFC.hpp" #include "videoResolution.hpp" -#include "videoOutputPortConfig.hpp" #include "list.hpp" #include #include diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 1cc790bd..9215f880 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -264,8 +264,8 @@ void VideoDevice::getSettopSupportedResolutions(std::list& stbSuppo { stbSupportedResoltuions.clear(); - // Get cached supported resolutions directly from _supportedResolutions - const std::vector& resolutions = VideoOutputPortConfig::getInstance()._supportedResolutions; + // Get cached supported resolutions directly from _originalSupportedResolutions + const std::vector& resolutions = VideoOutputPortConfig::getInstance()._originalSupportedResolutions; for (const VideoResolution& resolution : resolutions) { stbSupportedResoltuions.push_back(resolution.getName()); diff --git a/ds/videoDeviceConfig.cpp b/ds/videoDeviceConfig.cpp index fab33f59..491d93c5 100644 --- a/ds/videoDeviceConfig.cpp +++ b/ds/videoDeviceConfig.cpp @@ -35,8 +35,6 @@ #include "dslogger.h" #include "manager.hpp" -#define DEBUG 1 // Using for dumpconfig - namespace device { VideoDeviceConfig::VideoDeviceConfig() { diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index d5394c64..3e2e132d 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -217,14 +217,6 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn //If isIgnoreEdid is true isDynamicList is zero. Edid logic is skipped. if (0 == isDynamicList ) { - cout << "[DsMgr] Copying _supportedResolutions to tmpsupportedResolutions, size: " << _supportedResolutions.size() << endl; - for (size_t idx = 0; idx < _supportedResolutions.size(); idx++) { - const VideoResolution& res = _supportedResolutions[idx]; - cout << "[DsMgr] [" << idx << "] " << res.getName() - << " pixelRes=" << res.getPixelResolution().getId() - << " aspectRatio=" << res.getAspectRatio().getId() - << " frameRate=" << res.getFrameRate().getId() << endl; - } for (const VideoResolution& resolution : _supportedResolutions) { tmpsupportedResolutions.push_back(resolution); } @@ -257,14 +249,6 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn for (VideoResolution resolution : tmpsupportedResolutions){ _supportedResolutions.push_back(resolution); } - cout << "[DsMgr] _supportedResolutions cache after update, size: " << _supportedResolutions.size() << endl; - for (size_t idx = 0; idx < _supportedResolutions.size(); idx++) { - const VideoResolution& res = _supportedResolutions[idx]; - cout << "[DsMgr] [" << idx << "] " << res.getName() - << " pixelRes=" << res.getPixelResolution().getId() - << " aspectRatio=" << res.getAspectRatio().getId() - << " frameRate=" << res.getFrameRate().getId() << endl; - } } return supportedResolutions; } @@ -407,17 +391,20 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) /* Initialize a set of supported resolutions */ for (int i = 0; i < resolutionSize; i++) { dsVideoPortResolution_t *resolution = &(configuration.pKResolutionsSettings[i]); - {std::lock_guard lock(gSupportedResolutionsMutex); - _supportedResolutions.push_back( - VideoResolution( + VideoResolution vidRes = VideoResolution( i, /* id */ std::string(resolution->name), resolution->pixelResolution, resolution->aspectRatio, resolution->stereoScopicMode, resolution->frameRate, - resolution->interlaced)); + resolution->interlaced); + {std::lock_guard lock(gSupportedResolutionsMutex); + _supportedResolutions.push_back(vidRes); + _originalSupportedResolutions.push_back(vidRes); } + INT_INFO("[DsMgr] Loaded resolution[%d]: name='%s' pixelRes=%d aspectRatio=%d frameRate=%d", + i, resolution->name, resolution->pixelResolution, resolution->aspectRatio, resolution->frameRate); } /* diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index aaddf911..351f9533 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -65,6 +65,7 @@ class VideoOutputPortConfig { public: std::vector _supportedResolutions; + std::vector _originalSupportedResolutions; static VideoOutputPortConfig & getInstance(); const PixelResolution &getPixelResolution(int id) const; diff --git a/rpc/srv/dsVideoPort.c b/rpc/srv/dsVideoPort.c index 696a6f2f..9bd9ff53 100644 --- a/rpc/srv/dsVideoPort.c +++ b/rpc/srv/dsVideoPort.c @@ -1937,7 +1937,8 @@ static bool IsCompatibleResolution(dsVideoResolution_t pixelResolution1,dsVideo static dsVideoResolution_t getPixelResolution(std::string &resolution ) { dsVideoPortResolution_t *pVidoeResolutionsSettings = NULL; - int iCount = 0; + dsVideoPortResolution_t *Resn = NULL; + int iCount = 0, defaultIndex = 0; if (_dsGetVideoPortResolutions(&iCount, &pVidoeResolutionsSettings) != dsERR_NONE) { INT_ERROR("Failed to get video port resolutions\n"); return dsVIDEO_PIXELRES_MAX; @@ -1947,8 +1948,18 @@ static dsVideoResolution_t getPixelResolution(std::string &resolution ) INT_ERROR("_dsGetVideoPortResolutions returned invalid values (iCount=%d, pVidoeResolutionsSettings=%p)\n", iCount, pVidoeResolutionsSettings); return dsVIDEO_PIXELRES_MAX; } - - dsVideoPortResolution_t *Resn = &pVidoeResolutionsSettings[0]; + + if (_dsGetDefaultResolutionIndex(&defaultIndex) != dsERR_NONE) { + INT_ERROR("Failed to get default resolution index using first element of array\n"); + } + + if ((defaultIndex >= 0) && (defaultIndex < iCount)) { + Resn = &pVidoeResolutionsSettings[defaultIndex]; + } + else + { + Resn = &pVidoeResolutionsSettings[0]; + } for (int i = 0; i < iCount; i++) { From 55f0c7954068d4632af041a588c17370b80a385b Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Thu, 26 Feb 2026 16:50:28 +0000 Subject: [PATCH 60/66] add use of orginal resolutions --- ds/videoOutputPortConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 3e2e132d..23a4a85a 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -217,7 +217,8 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn //If isIgnoreEdid is true isDynamicList is zero. Edid logic is skipped. if (0 == isDynamicList ) { - for (const VideoResolution& resolution : _supportedResolutions) { + INT_INFO("_originalSupportedResolutions size: %zu", _originalSupportedResolutions.size()); + for (const VideoResolution& resolution : _originalSupportedResolutions) { tmpsupportedResolutions.push_back(resolution); } } From 07a40d8e1a6de62f54efb8bb67723bd5467ec399 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 2 Mar 2026 17:26:19 +0000 Subject: [PATCH 61/66] address all the review comments --- ds/manager.cpp | 14 ++++--- ds/videoOutputPortConfig.cpp | 44 ++++++++++++--------- rpc/srv/dsAudioConfig.c | 6 +-- rpc/srv/dsMgr.c | 2 +- rpc/srv/dsVideoDeviceConfig.c | 12 ++---- rpc/srv/dsVideoPort.c | 16 ++++---- rpc/srv/dsVideoPortConfig.c | 72 +++++++++++++++-------------------- 7 files changed, 80 insertions(+), 86 deletions(-) diff --git a/ds/manager.cpp b/ds/manager.cpp index 535da298..7c88ed71 100644 --- a/ds/manager.cpp +++ b/ds/manager.cpp @@ -45,14 +45,9 @@ #include #include #include -#include #include "dsHALConfig.h" #include "frontPanelConfig.hpp" - -//static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER; - - /** * @file manager.cpp * @brief RDK Device Settings module is a cross-platform device for controlling the following hardware configurations: @@ -109,6 +104,15 @@ void loadDeviceCapabilities(unsigned int capabilityType) INT_INFO("Entering capabilityType = 0x%08X", capabilityType); dlerror(); // clear old error pDLHandle = dlopen(RDK_DSHAL_NAME, RTLD_LAZY); + + if (nullptr == pDLHandle) { + const char* dlError = dlerror(); + INT_WARN("Failed to dlopen '%s': %s - Falling back to static configurations", + RDK_DSHAL_NAME, dlError ? dlError : "Unknown error"); + } else { + INT_INFO("Successfully opened dynamic library '%s'", RDK_DSHAL_NAME); + } + INT_INFO("DL Instance '%s'", (nullptr == pDLHandle ? "NULL" : "Valid")); // Audio Port Config diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 23a4a85a..faf80a23 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -100,7 +100,7 @@ const VideoResolution &VideoOutputPortConfig::getVideoResolution (int id) const return _supportedResolutions.at(id); } else { - cout<<"returns default resolution 720p"< VideoOutputPortConfig::getSupportedResolutions(bool isIgn intptr_t _handle = 0; //CID:98922 - Uninit bool force_disable_4K = true; - printf ("\nResOverride VideoOutputPortConfig::getSupportedResolutions isIgnoreEdid:%d\n", isIgnoreEdid); + INT_INFO("VideoOutputPortConfig::getSupportedResolutions isIgnoreEdid=%d", isIgnoreEdid); if (!isIgnoreEdid) { try { std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName(); @@ -185,11 +185,11 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn dsError = dsGetEDID(_handle, edid); if(dsError != dsERR_NONE) { - cout <<" dsGetEDID failed so setting edid->numOfSupportedResolution to 0"<< endl; + INT_ERROR("dsGetEDID failed with error %d, setting edid->numOfSupportedResolution to 0", dsError); edid->numOfSupportedResolution = 0; } - cout <<" EDID Num of Resolution ......."<< edid->numOfSupportedResolution << endl; + INT_INFO("EDID reports %d supported resolutions", edid->numOfSupportedResolution); for (size_t i = 0; i < edid->numOfSupportedResolution; i++) { dsVideoPortResolution_t *resolution = &edid->suppResolutionList[i]; @@ -211,7 +211,7 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn }catch (...) { isDynamicList = 0; - cout << "VideoOutputPortConfig::getSupportedResolutions Thrown. Exception..."< VideoOutputPortConfig::getSupportedResolutions(bool isIgn } catch(...) { - cout<<"Failed to get status of forceDisable4K!"<::iterator it = tmpsupportedResolutions.begin(); it != tmpsupportedResolutions.end(); it++) { if (it->isEnabled()) { @@ -245,7 +245,7 @@ List VideoOutputPortConfig::getSupportedResolutions(bool isIgn } } {std::lock_guard lock(gSupportedResolutionsMutex); - cout<<"_supportedResolutions cache updated"<restrictedResollution = %d", typeCfg->restrictedResollution); INT_INFO("typeCfg->numSupportedResolutions= %lu", typeCfg->numSupportedResolutions); - INT_INFO("typeCfg->supportedResolutions = %p", typeCfg->supportedResolutions); - INT_INFO("typeCfg->supportedResolutions->name = %s", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); - INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d", typeCfg->supportedResolutions->pixelResolution); - INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d", typeCfg->supportedResolutions->aspectRatio); - INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d", typeCfg->supportedResolutions->stereoScopicMode); - INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); - INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); + if ((typeCfg->supportedResolutions != NULL) && (typeCfg->numSupportedResolutions > 0)) + { + INT_INFO("typeCfg->supportedResolutions = %p", typeCfg->supportedResolutions); + INT_INFO("typeCfg->supportedResolutions->name = %s", (typeCfg->supportedResolutions->name) ? typeCfg->supportedResolutions->name : "NULL"); + INT_INFO("typeCfg->supportedResolutions->pixelResolution= %d", typeCfg->supportedResolutions->pixelResolution); + INT_INFO("typeCfg->supportedResolutions->aspectRatio= %d", typeCfg->supportedResolutions->aspectRatio); + INT_INFO("typeCfg->supportedResolutions->stereoScopicMode= %d", typeCfg->supportedResolutions->stereoScopicMode); + INT_INFO("typeCfg->supportedResolutions->frameRate= %d", typeCfg->supportedResolutions->frameRate); + INT_INFO("typeCfg->supportedResolutions->interlaced= %d", typeCfg->supportedResolutions->interlaced); + } + else + { + INT_INFO("typeCfg has no supportedResolutions entries to dump (pointer is %p, numSupportedResolutions = %lu)", + typeCfg->supportedResolutions, + typeCfg->numSupportedResolutions); + } } INT_INFO("\n############### Dumping Video Port Connections ###############\n"); @@ -328,7 +337,6 @@ void dumpconfig(videoPortConfigs_t *config) INT_ERROR("pKConfigs or pKPorts or pKResolutionsSettings is NULL"); } INT_INFO("\n=============== Dump VideoPort Configs done ===============\n"); - INT_INFO("Exit function"); } void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) @@ -336,7 +344,6 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) int configSize, portSize, resolutionSize; videoPortConfigs_t configuration = {0}; - INT_INFO("Enter function"); try { /* * Load Constants First. @@ -437,15 +444,14 @@ void VideoOutputPortConfig::load(videoPortConfigs_t* dynamicVideoPortConfigs) } else { - cout << "Video Outport Configs or Ports or Resolutions is NULL. ..."<= 0) && (defaultIndex < iCount)) { - Resn = &pVidoeResolutionsSettings[defaultIndex]; + Resn = &pVideoResolutionsSettings[defaultIndex]; } else { - Resn = &pVidoeResolutionsSettings[0]; + Resn = &pVideoResolutionsSettings[0]; } for (int i = 0; i < iCount; i++) { - Resn = &pVidoeResolutionsSettings[i]; + Resn = &pVideoResolutionsSettings[i]; if (resolution.compare(Resn->name) == 0 ) { break; @@ -2294,7 +2294,7 @@ static dsError_t _dsVideoFormatUpdateRegisterCB (dsVideoFormatUpdateCB_t cbFun) return eRet; } -//This funcation does not have any caller. +//This function does not have any caller. bool isComponentPortPresent() { bool componentPortPresent = false; diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index 34df8693..aef065a3 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -176,7 +176,7 @@ static int allocateAndCopyVideoPortConfigs(const dsVideoPortTypeConfig_t* source if (videoPortConfiguration.pKVideoPortConfigs[j].name != NULL) { free((void*)videoPortConfiguration.pKVideoPortConfigs[j].name); - videoPortConfiguration.pKVideoPortConfigs[j].name = "NULL"; + videoPortConfiguration.pKVideoPortConfigs[j].name = NULL; } } free(videoPortConfiguration.pKVideoPortConfigs); @@ -313,11 +313,6 @@ dsError_t dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPort INT_ERROR("Failed to allocate video port configs\n"); // Clean up previously allocated memory if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { - for (int i = 0; i < videoPortConfiguration.kResolutionsSettings_size; ++i) { - if (videoPortConfiguration.pKVideoPortResolutionsSettings[i].name != NULL) { - free(videoPortConfiguration.pKVideoPortResolutionsSettings[i].name); - } - } free(videoPortConfiguration.pKVideoPortResolutionsSettings); videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; } @@ -348,18 +343,12 @@ dsError_t dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPort videoPortConfiguration.pKVideoPortConfigs = NULL; } if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { - for (int i = 0; i < resolutionSize; ++i) { - if (videoPortConfiguration.pKVideoPortResolutionsSettings[i].name != NULL) { - free(videoPortConfiguration.pKVideoPortResolutionsSettings[i].name); - } - } free(videoPortConfiguration.pKVideoPortResolutionsSettings); videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; } return dsERR_GENERAL; } - INT_INFO("Store sizes configSize =%d, portSize =%d, resolutionSize = %d\n", configSize, portSize, resolutionSize); videoPortConfiguration.kDefaultResIndex = defaultResIndex; INT_INFO("Store sizes videoPortConfiguration.kDefaultResIndex = %d\n", videoPortConfiguration.kDefaultResIndex); @@ -386,54 +375,42 @@ dsError_t dsLoadVideoOutputPortConfig(const videoPortConfigs_t* dynamicVideoPort // Getter functions for use across srv code dsError_t _dsGetVideoPortTypeConfigs(int* outConfigSize, const dsVideoPortTypeConfig_t** outConfigs) { - - if((outConfigSize == NULL) && (outConfigs == NULL)) + if((outConfigSize == NULL) || (outConfigs == NULL)) { INT_ERROR("Invalid argument pointer\n"); return dsERR_GENERAL; - } - if (outConfigSize != NULL) { - *outConfigSize = videoPortConfiguration.kVideoPortConfigs_size; - } - if (outConfigs != NULL) { - *outConfigs = videoPortConfiguration.pKVideoPortConfigs; } + + *outConfigSize = videoPortConfiguration.kVideoPortConfigs_size; + *outConfigs = videoPortConfiguration.pKVideoPortConfigs; return dsERR_NONE; } dsError_t _dsGetVideoPortPortConfigs(int* outPortSize, const dsVideoPortPortConfig_t** outPorts) { - - if((outPortSize == NULL) && (outPorts == NULL)) + if((outPortSize == NULL) || (outPorts == NULL)) { INT_ERROR("Invalid argument pointer\n"); return dsERR_GENERAL; } - if (outPortSize != NULL) { - *outPortSize = videoPortConfiguration.kVideoPortPorts_size; - } - if (outPorts != NULL) { - *outPorts = videoPortConfiguration.pKVideoPortPorts; - } + + *outPortSize = videoPortConfiguration.kVideoPortPorts_size; + *outPorts = videoPortConfiguration.pKVideoPortPorts; return dsERR_NONE; } dsError_t _dsGetVideoPortResolutions(int* outResolutionSize, dsVideoPortResolution_t** outResolutions) { - - if((outResolutionSize == NULL) && (outResolutions == NULL)) + if((outResolutionSize == NULL) || (outResolutions == NULL)) { INT_ERROR("Invalid argument pointer\n"); return dsERR_GENERAL; } - if (outResolutionSize != NULL) { - *outResolutionSize = videoPortConfiguration.kResolutionsSettings_size; - } - if (outResolutions != NULL) { - *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; - } + + *outResolutionSize = videoPortConfiguration.kResolutionsSettings_size; + *outResolutions = videoPortConfiguration.pKVideoPortResolutionsSettings; return dsERR_NONE; } @@ -447,9 +424,7 @@ dsError_t _dsGetDefaultResolutionIndex(int* outDefaultIndex) return dsERR_GENERAL; } - if (outDefaultIndex != NULL) { - *outDefaultIndex = videoPortConfiguration.kDefaultResIndex; - } + *outDefaultIndex = videoPortConfiguration.kDefaultResIndex; return dsERR_NONE; } @@ -457,21 +432,34 @@ dsError_t _dsGetDefaultResolutionIndex(int* outDefaultIndex) void dsVideoPortConfigFree(void) { INT_INFO("Freeing VideoPort configuration resources\n"); - // Free video port configs + + // Free video port configs and their allocated name strings if (videoPortConfiguration.pKVideoPortConfigs != NULL) { + for (int i = 0; i < videoPortConfiguration.kVideoPortConfigs_size; ++i) { + if (videoPortConfiguration.pKVideoPortConfigs[i].name != NULL) { + free((void*)videoPortConfiguration.pKVideoPortConfigs[i].name); + videoPortConfiguration.pKVideoPortConfigs[i].name = NULL; + } + } free(videoPortConfiguration.pKVideoPortConfigs); videoPortConfiguration.pKVideoPortConfigs = NULL; INT_INFO("Freed pKVideoPortConfigs\n"); } - // Free video port ports + // Free video port ports and their allocated defaultResolution strings if (videoPortConfiguration.pKVideoPortPorts != NULL) { + for (int i = 0; i < videoPortConfiguration.kVideoPortPorts_size; ++i) { + if (videoPortConfiguration.pKVideoPortPorts[i].defaultResolution != NULL) { + free((void*)videoPortConfiguration.pKVideoPortPorts[i].defaultResolution); + videoPortConfiguration.pKVideoPortPorts[i].defaultResolution = NULL; + } + } free(videoPortConfiguration.pKVideoPortPorts); videoPortConfiguration.pKVideoPortPorts = NULL; INT_INFO("Freed pKVideoPortPorts\n"); } - // Free video port resolutions + // Free video port resolutions (name is embedded array, not allocated) if (videoPortConfiguration.pKVideoPortResolutionsSettings != NULL) { free(videoPortConfiguration.pKVideoPortResolutionsSettings); videoPortConfiguration.pKVideoPortResolutionsSettings = NULL; From 88716e5af9f26ab6236d9c2f4d8845d8f60e2d25 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Mon, 2 Mar 2026 18:47:14 +0000 Subject: [PATCH 62/66] address the copilot review --- rpc/srv/dsAudioConfig.c | 199 ++++++++++++++++++++++++++++++++-- rpc/srv/dsVideoDeviceConfig.c | 1 + rpc/srv/dsVideoPortConfig.c | 1 + 3 files changed, 192 insertions(+), 9 deletions(-) diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index 95431109..bfcf6149 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" @@ -111,8 +112,111 @@ static int allocateAndCopyAudioConfigs(const dsAudioTypeConfig_t* source, int nu return -1; } - memcpy(audioConfiguration.pKAudioConfigs, source, numElements * sizeof(dsAudioTypeConfig_t)); - INT_INFO("Allocated and copied %d audio configs (%s)", numElements, configType); + // Deep copy each audio type config + for (int i = 0; i < numElements; i++) { + dsAudioTypeConfig_t *dest = &audioConfiguration.pKAudioConfigs[i]; + const dsAudioTypeConfig_t *src = &source[i]; + + // Copy primitive fields + dest->typeId = src->typeId; + dest->numSupportedCompressions = src->numSupportedCompressions; + dest->numSupportedEncodings = src->numSupportedEncodings; + dest->numSupportedStereoModes = src->numSupportedStereoModes; + + // Deep copy name string + if (src->name != NULL) { + dest->name = strdup(src->name); + if (dest->name == NULL) { + INT_ERROR("Failed to duplicate name for audio config %d\n", i); + // Cleanup previously allocated items + for (int j = 0; j < i; j++) { + free((void*)audioConfiguration.pKAudioConfigs[j].name); + free((void*)audioConfiguration.pKAudioConfigs[j].compressions); + free((void*)audioConfiguration.pKAudioConfigs[j].encodings); + free((void*)audioConfiguration.pKAudioConfigs[j].stereoModes); + } + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + return -1; + } + } else { + dest->name = NULL; + } + + // Deep copy compressions array + if (src->compressions != NULL && src->numSupportedCompressions > 0) { + size_t size = src->numSupportedCompressions * sizeof(dsAudioCompression_t); + dest->compressions = (dsAudioCompression_t*)malloc(size); + if (dest->compressions == NULL) { + INT_ERROR("Failed to allocate compressions for audio config %d\n", i); + free((void*)dest->name); + // Cleanup previously allocated items + for (int j = 0; j < i; j++) { + free((void*)audioConfiguration.pKAudioConfigs[j].name); + free((void*)audioConfiguration.pKAudioConfigs[j].compressions); + free((void*)audioConfiguration.pKAudioConfigs[j].encodings); + free((void*)audioConfiguration.pKAudioConfigs[j].stereoModes); + } + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + return -1; + } + memcpy((void*)dest->compressions, src->compressions, size); + } else { + dest->compressions = NULL; + } + + // Deep copy encodings array + if (src->encodings != NULL && src->numSupportedEncodings > 0) { + size_t size = src->numSupportedEncodings * sizeof(dsAudioEncoding_t); + dest->encodings = (dsAudioEncoding_t*)malloc(size); + if (dest->encodings == NULL) { + INT_ERROR("Failed to allocate encodings for audio config %d\n", i); + free((void*)dest->name); + free((void*)dest->compressions); + // Cleanup previously allocated items + for (int j = 0; j < i; j++) { + free((void*)audioConfiguration.pKAudioConfigs[j].name); + free((void*)audioConfiguration.pKAudioConfigs[j].compressions); + free((void*)audioConfiguration.pKAudioConfigs[j].encodings); + free((void*)audioConfiguration.pKAudioConfigs[j].stereoModes); + } + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + return -1; + } + memcpy((void*)dest->encodings, src->encodings, size); + } else { + dest->encodings = NULL; + } + + // Deep copy stereoModes array + if (src->stereoModes != NULL && src->numSupportedStereoModes > 0) { + size_t size = src->numSupportedStereoModes * sizeof(dsAudioStereoMode_t); + dest->stereoModes = (dsAudioStereoMode_t*)malloc(size); + if (dest->stereoModes == NULL) { + INT_ERROR("Failed to allocate stereoModes for audio config %d\n", i); + free((void*)dest->name); + free((void*)dest->compressions); + free((void*)dest->encodings); + // Cleanup previously allocated items + for (int j = 0; j < i; j++) { + free((void*)audioConfiguration.pKAudioConfigs[j].name); + free((void*)audioConfiguration.pKAudioConfigs[j].compressions); + free((void*)audioConfiguration.pKAudioConfigs[j].encodings); + free((void*)audioConfiguration.pKAudioConfigs[j].stereoModes); + } + free(audioConfiguration.pKAudioConfigs); + audioConfiguration.pKAudioConfigs = NULL; + return -1; + } + memcpy((void*)dest->stereoModes, src->stereoModes, size); + } else { + dest->stereoModes = NULL; + } + } + + INT_INFO("Deep copied %d audio configs (%s)", numElements, configType); return numElements; } @@ -131,8 +235,37 @@ static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numE return -1; } - memcpy(audioConfiguration.pKAudioPorts, source, numElements * sizeof(dsAudioPortConfig_t)); - INT_INFO("Allocated and copied %d audio ports (%s)", numElements, configType); + // Deep copy each audio port config + for (int i = 0; i < numElements; i++) { + dsAudioPortConfig_t *dest = &audioConfiguration.pKAudioPorts[i]; + const dsAudioPortConfig_t *src = &source[i]; + + // Copy port ID + dest->id = src->id; + + // Deep copy connectedVOPs array if present + // Note: We need to know the size of connectedVOPs array + // For now, assuming it's NULL or a single element (common case) + // A proper implementation would need size information + if (src->connectedVOPs != NULL) { + dest->connectedVOPs = (dsVideoPortPortId_t*)malloc(sizeof(dsVideoPortPortId_t)); + if (dest->connectedVOPs == NULL) { + INT_ERROR("Failed to allocate connectedVOPs for audio port %d\n", i); + // Cleanup previously allocated items + for (int j = 0; j < i; j++) { + free((void*)audioConfiguration.pKAudioPorts[j].connectedVOPs); + } + free(audioConfiguration.pKAudioPorts); + audioConfiguration.pKAudioPorts = NULL; + return -1; + } + memcpy((void*)dest->connectedVOPs, src->connectedVOPs, sizeof(dsVideoPortPortId_t)); + } else { + dest->connectedVOPs = NULL; + } + } + + INT_INFO("Deep copied %d audio ports (%s)", numElements, configType); return numElements; } @@ -170,8 +303,23 @@ dsError_t dsLoadAudioOutputPortConfig(const audioConfigs_t* dynamicAudioConfigs) // Allocate and copy audio port configs if (allocateAndCopyAudioPorts(audioPorts, portSize, isDynamic) == -1) { INT_ERROR("Failed to allocate audio port configs\n"); - // Clean up previously allocated memory + // Clean up previously allocated audio configs with their deep-copied fields if (audioConfiguration.pKAudioConfigs != NULL) { + for (int i = 0; i < configSize; i++) { + dsAudioTypeConfig_t *config = &audioConfiguration.pKAudioConfigs[i]; + if (config->name != NULL) { + free((void*)config->name); + } + if (config->compressions != NULL) { + free((void*)config->compressions); + } + if (config->encodings != NULL) { + free((void*)config->encodings); + } + if (config->stereoModes != NULL) { + free((void*)config->stereoModes); + } + } free(audioConfiguration.pKAudioConfigs); audioConfiguration.pKAudioConfigs = NULL; } @@ -237,18 +385,51 @@ void dsAudioConfigFree(void) { INT_INFO("Freeing Audio configuration resources\n"); - // Free audio configs + // Free audio configs and their deep-copied fields if (audioConfiguration.pKAudioConfigs != NULL) { + for (int i = 0; i < audioConfiguration.kConfigSize; i++) { + dsAudioTypeConfig_t *config = &audioConfiguration.pKAudioConfigs[i]; + + // Free name string + if (config->name != NULL) { + free((void*)config->name); + } + + // Free compressions array + if (config->compressions != NULL) { + free((void*)config->compressions); + } + + // Free encodings array + if (config->encodings != NULL) { + free((void*)config->encodings); + } + + // Free stereoModes array + if (config->stereoModes != NULL) { + free((void*)config->stereoModes); + } + } + free(audioConfiguration.pKAudioConfigs); audioConfiguration.pKAudioConfigs = NULL; - INT_INFO("Freed pKAudioConfigs\n"); + INT_INFO("Freed pKAudioConfigs and all deep-copied fields\n"); } - // Free audio ports + // Free audio ports and their deep-copied fields if (audioConfiguration.pKAudioPorts != NULL) { + for (int i = 0; i < audioConfiguration.kPortSize; i++) { + dsAudioPortConfig_t *port = &audioConfiguration.pKAudioPorts[i]; + + // Free connectedVOPs array + if (port->connectedVOPs != NULL) { + free((void*)port->connectedVOPs); + } + } + free(audioConfiguration.pKAudioPorts); audioConfiguration.pKAudioPorts = NULL; - INT_INFO("Freed pKAudioPorts\n"); + INT_INFO("Freed pKAudioPorts and all deep-copied fields\n"); } // Reset size variables diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index a082b808..e56db9b0 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index aef065a3..0aa58b7b 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" From d074e1d5eceef33917a9f9e665cd12c3fbdf5717 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 3 Mar 2026 02:21:55 +0000 Subject: [PATCH 63/66] fix native build issue --- rpc/srv/dsAudioConfig.c | 2 +- rpc/srv/dsVideoDeviceConfig.c | 2 +- rpc/srv/dsVideoPortConfig.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index bfcf6149..af348269 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" diff --git a/rpc/srv/dsVideoDeviceConfig.c b/rpc/srv/dsVideoDeviceConfig.c index e56db9b0..5257c531 100644 --- a/rpc/srv/dsVideoDeviceConfig.c +++ b/rpc/srv/dsVideoDeviceConfig.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" diff --git a/rpc/srv/dsVideoPortConfig.c b/rpc/srv/dsVideoPortConfig.c index 0aa58b7b..cbafb7b7 100644 --- a/rpc/srv/dsVideoPortConfig.c +++ b/rpc/srv/dsVideoPortConfig.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "dsserverlogger.h" #include "dsTypes.h" #include "dsError.h" From 04933789ab8d8fe97ca0925863fe16f99f4cfb23 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 3 Mar 2026 03:24:47 +0000 Subject: [PATCH 64/66] address copilot review comments --- ds/videoDevice.cpp | 8 ++++---- ds/videoOutputPortConfig.cpp | 9 +++++++++ ds/videoOutputPortConfig.hpp | 5 +++-- rpc/srv/Makefile.am | 3 ++- rpc/srv/dsAudioConfig.c | 10 ++++------ 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 9215f880..4705edf0 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -264,11 +264,11 @@ void VideoDevice::getSettopSupportedResolutions(std::list& stbSuppo { stbSupportedResoltuions.clear(); - // Get cached supported resolutions directly from _originalSupportedResolutions - const std::vector& resolutions = VideoOutputPortConfig::getInstance()._originalSupportedResolutions; + // Get cached supported resolutions through const accessor + List resolutions = VideoOutputPortConfig::getInstance().getOriginalSupportedResolutions(); - for (const VideoResolution& resolution : resolutions) { - stbSupportedResoltuions.push_back(resolution.getName()); + for (size_t i = 0; i < resolutions.size(); i++) { + stbSupportedResoltuions.push_back(resolutions.at(i).getName()); } } diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index faf80a23..71baa5fa 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -156,6 +156,15 @@ List VideoOutputPortConfig::getSupportedTypes() return supportedTypes; } +List VideoOutputPortConfig::getOriginalSupportedResolutions() const +{ + List resolutions; + for (const VideoResolution& res : _originalSupportedResolutions) { + resolutions.push_back(res); + } + return resolutions; +} + List VideoOutputPortConfig::getSupportedResolutions(bool isIgnoreEdid) { List supportedResolutions; diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index 351f9533..e3eef9eb 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -55,6 +55,8 @@ class VideoOutputPortConfig { std::vector _vPixelResolutions; std::vector _vAspectRatios; std::vector _vStereoScopieModes; + std::vector _supportedResolutions; + std::vector _originalSupportedResolutions; std::vector _vFrameRates; std::vector _vPortTypes; std::vector _vPorts; @@ -64,8 +66,6 @@ class VideoOutputPortConfig { ~VideoOutputPortConfig(); public: - std::vector _supportedResolutions; - std::vector _originalSupportedResolutions; static VideoOutputPortConfig & getInstance(); const PixelResolution &getPixelResolution(int id) const; @@ -80,6 +80,7 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); + List getOriginalSupportedResolutions() const; void load(videoPortConfigs_t* dynamicVideoPortConfigs); void release(); diff --git a/rpc/srv/Makefile.am b/rpc/srv/Makefile.am index c1bfadf1..5d5018e7 100644 --- a/rpc/srv/Makefile.am +++ b/rpc/srv/Makefile.am @@ -29,4 +29,5 @@ lib_LTLIBRARIES = libdshalsrv.la libdshalsrv_la_CPPFLAGS = $(INCLUDE_FILES) libdshalsrv_la_CXXFLAGS= -std=c++0x -g -fPIC -D_REENTRANT -Wall libdshalsrv_la_CFLAGS = -x c++ -g -fPIC -D_REENTRANT -Wall -libdshalsrv_la_SOURCES = dsHost.cpp hostPersistence.cpp dsAudio.c dsDisplay.c dsFPD.c dsMgr.c dsVideoDevice.c dsVideoPort.c dsserverlogger.c +libdshalsrv_la_SOURCES = dsHost.cpp hostPersistence.cpp dsAudio.c dsDisplay.c dsFPD.c dsMgr.c dsVideoDevice.c dsVideoPort.c dsserverlogger.c \ + dsConfigs.c dsAudioConfig.c dsVideoPortConfig.c dsVideoDeviceConfig.c dsCompositeIn.c dsHdmiIn.c diff --git a/rpc/srv/dsAudioConfig.c b/rpc/srv/dsAudioConfig.c index af348269..cab63ec1 100644 --- a/rpc/srv/dsAudioConfig.c +++ b/rpc/srv/dsAudioConfig.c @@ -243,12 +243,10 @@ static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numE // Copy port ID dest->id = src->id; - // Deep copy connectedVOPs array if present - // Note: We need to know the size of connectedVOPs array - // For now, assuming it's NULL or a single element (common case) - // A proper implementation would need size information + // Deep copy connectedVOPs array - it's an array of size dsVIDEOPORT_TYPE_MAX if (src->connectedVOPs != NULL) { - dest->connectedVOPs = (dsVideoPortPortId_t*)malloc(sizeof(dsVideoPortPortId_t)); + size_t arraySize = dsVIDEOPORT_TYPE_MAX * sizeof(dsVideoPortPortId_t); + dest->connectedVOPs = (dsVideoPortPortId_t*)malloc(arraySize); if (dest->connectedVOPs == NULL) { INT_ERROR("Failed to allocate connectedVOPs for audio port %d\n", i); // Cleanup previously allocated items @@ -259,7 +257,7 @@ static int allocateAndCopyAudioPorts(const dsAudioPortConfig_t* source, int numE audioConfiguration.pKAudioPorts = NULL; return -1; } - memcpy((void*)dest->connectedVOPs, src->connectedVOPs, sizeof(dsVideoPortPortId_t)); + memcpy((void*)dest->connectedVOPs, src->connectedVOPs, arraySize); } else { dest->connectedVOPs = NULL; } From ffe1449d5cded396bebfd54934d38735df14b474 Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 3 Mar 2026 06:36:30 +0000 Subject: [PATCH 65/66] fix native build issue --- ds/videoDevice.cpp | 7 +++---- ds/videoOutputPortConfig.cpp | 9 --------- ds/videoOutputPortConfig.hpp | 3 +-- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/ds/videoDevice.cpp b/ds/videoDevice.cpp index 4705edf0..494a8d93 100644 --- a/ds/videoDevice.cpp +++ b/ds/videoDevice.cpp @@ -264,11 +264,10 @@ void VideoDevice::getSettopSupportedResolutions(std::list& stbSuppo { stbSupportedResoltuions.clear(); - // Get cached supported resolutions through const accessor - List resolutions = VideoOutputPortConfig::getInstance().getOriginalSupportedResolutions(); + const std::vector& resolutions = VideoOutputPortConfig::getInstance()._originalSupportedResolutions; - for (size_t i = 0; i < resolutions.size(); i++) { - stbSupportedResoltuions.push_back(resolutions.at(i).getName()); + for (const VideoResolution& res : resolutions) { + stbSupportedResoltuions.push_back(res.getName()); } } diff --git a/ds/videoOutputPortConfig.cpp b/ds/videoOutputPortConfig.cpp index 71baa5fa..faf80a23 100644 --- a/ds/videoOutputPortConfig.cpp +++ b/ds/videoOutputPortConfig.cpp @@ -156,15 +156,6 @@ List VideoOutputPortConfig::getSupportedTypes() return supportedTypes; } -List VideoOutputPortConfig::getOriginalSupportedResolutions() const -{ - List resolutions; - for (const VideoResolution& res : _originalSupportedResolutions) { - resolutions.push_back(res); - } - return resolutions; -} - List VideoOutputPortConfig::getSupportedResolutions(bool isIgnoreEdid) { List supportedResolutions; diff --git a/ds/videoOutputPortConfig.hpp b/ds/videoOutputPortConfig.hpp index e3eef9eb..2dec0d53 100644 --- a/ds/videoOutputPortConfig.hpp +++ b/ds/videoOutputPortConfig.hpp @@ -56,7 +56,6 @@ class VideoOutputPortConfig { std::vector _vAspectRatios; std::vector _vStereoScopieModes; std::vector _supportedResolutions; - std::vector _originalSupportedResolutions; std::vector _vFrameRates; std::vector _vPortTypes; std::vector _vPorts; @@ -66,6 +65,7 @@ class VideoOutputPortConfig { ~VideoOutputPortConfig(); public: + std::vector _originalSupportedResolutions; static VideoOutputPortConfig & getInstance(); const PixelResolution &getPixelResolution(int id) const; @@ -80,7 +80,6 @@ class VideoOutputPortConfig { List getSupportedTypes(); List getSupportedResolutions(bool isIgnoreEdid=false); - List getOriginalSupportedResolutions() const; void load(videoPortConfigs_t* dynamicVideoPortConfigs); void release(); From 69f17edc95dc76ce2463b5336ad435548c028e2a Mon Sep 17 00:00:00 2001 From: grandhi_santoshkumar Date: Tue, 3 Mar 2026 09:28:59 +0000 Subject: [PATCH 66/66] addressing copilot review --- rpc/srv/Makefile.am | 1 + rpc/srv/dsConfigs.c | 7 +++++-- rpc/srv/dsDisplay.c | 19 ++++++++++++++----- rpc/srv/dsVideoPort.c | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/rpc/srv/Makefile.am b/rpc/srv/Makefile.am index 5d5018e7..1a700b1f 100644 --- a/rpc/srv/Makefile.am +++ b/rpc/srv/Makefile.am @@ -31,3 +31,4 @@ libdshalsrv_la_CXXFLAGS= -std=c++0x -g -fPIC -D_REENTRANT -Wall libdshalsrv_la_CFLAGS = -x c++ -g -fPIC -D_REENTRANT -Wall libdshalsrv_la_SOURCES = dsHost.cpp hostPersistence.cpp dsAudio.c dsDisplay.c dsFPD.c dsMgr.c dsVideoDevice.c dsVideoPort.c dsserverlogger.c \ dsConfigs.c dsAudioConfig.c dsVideoPortConfig.c dsVideoDeviceConfig.c dsCompositeIn.c dsHdmiIn.c +libdshalsrv_la_LIBADD = -ldl diff --git a/rpc/srv/dsConfigs.c b/rpc/srv/dsConfigs.c index 7fd6214c..15aff0d2 100644 --- a/rpc/srv/dsConfigs.c +++ b/rpc/srv/dsConfigs.c @@ -87,7 +87,7 @@ static dsError_t loadDeviceCapabilities(unsigned int capabilityType) { void* pDLHandle = NULL; int isSymbolsLoaded = 0; - dsError_t ret = dsERR_GENERAL, audioRet = dsERR_GENERAL, videoRet = dsERR_GENERAL, videoPortRet = dsERR_GENERAL; + dsError_t ret = dsERR_GENERAL, audioRet = dsERR_NONE, videoRet = dsERR_NONE, videoPortRet = dsERR_NONE; INT_INFO("Entering capabilityType = 0x%08X\n", capabilityType); dlerror(); /* clear old error */ @@ -172,7 +172,10 @@ static dsError_t loadDeviceCapabilities(unsigned int capabilityType) pDLHandle = NULL; } - if(audioRet == dsERR_GENERAL || videoRet == dsERR_GENERAL || videoPortRet == dsERR_GENERAL) + // Only check error codes for capabilities that were requested + if (((capabilityType & DEVICE_CAPABILITY_AUDIO_PORT) && (audioRet == dsERR_GENERAL)) || + ((capabilityType & DEVICE_CAPABILITY_VIDEO_DEVICE) && (videoRet == dsERR_GENERAL)) || + ((capabilityType & DEVICE_CAPABILITY_VIDEO_PORT) && (videoPortRet == dsERR_GENERAL))) { INT_ERROR("Failed to load device capabilities: audioRet=%d, videoRet=%d, videoPortRet=%d\n", audioRet, videoRet, videoPortRet); return dsERR_GENERAL; diff --git a/rpc/srv/dsDisplay.c b/rpc/srv/dsDisplay.c index 1388be29..4eab1afe 100644 --- a/rpc/srv/dsDisplay.c +++ b/rpc/srv/dsDisplay.c @@ -578,12 +578,19 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) errno_t rc = -1; dsVideoPortResolution_t *edidResn = NULL; dsVideoPortResolution_t *presolution = NULL, *pVideoResolutionsSettings = NULL; - dsDisplayEDID_t *edidData = (dsDisplayEDID_t*)malloc(sizeof(dsDisplayEDID_t)); - dsVideoPortType_t _VPortType = _GetDisplayPortType(handle); + if (edid == NULL) { - free(edidData); - return; // Handle malloc failure + INT_ERROR("Invalid EDID parameter\n"); + return; + } + + dsVideoPortType_t _VPortType = _GetDisplayPortType(handle); + dsDisplayEDID_t *edidData = (dsDisplayEDID_t*)malloc(sizeof(dsDisplayEDID_t)); + if (edidData == NULL) { + INT_ERROR("Failed to allocate memory for EDID data\n"); + return; } + int numOfSupportedResolution = 0; if(_VPortType == dsVIDEOPORT_TYPE_HDMI) @@ -592,7 +599,9 @@ static void filterEDIDResolution(intptr_t handle, dsDisplayEDID_t *edid) int iCount = 0; //Get details from libds if (_dsGetVideoPortResolutions(&iCount, &pVideoResolutionsSettings) != dsERR_NONE) { - INT_ERROR("Failed to get video port resolutions\n"); + INT_ERROR("Failed to get video port resolutions, leaving EDID unchanged\n"); + free(edidData); + return; } /*Initialize the struct*/ diff --git a/rpc/srv/dsVideoPort.c b/rpc/srv/dsVideoPort.c index 00040a9b..a397a5b9 100644 --- a/rpc/srv/dsVideoPort.c +++ b/rpc/srv/dsVideoPort.c @@ -2441,7 +2441,7 @@ intptr_t dsGetDefaultPortHandle() if (_dsGetVideoPortPortConfigs(&numPorts, &pVideoPortPorts) != dsERR_NONE) { INT_ERROR("Failed to get video port port configurations\n"); - return NULL; + return halhandle; } for(i=0; i< numPorts; i++)