From 6739f7a43a016e82f6c580d1e07dce15d040f074 Mon Sep 17 00:00:00 2001 From: arjunbinu <51983664+arjunbinu@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:40:21 +0000 Subject: [PATCH] Remove ODM specific apis from tvsettings HAL to make it generic- phase1 --- AVOutput/AVOutputTV.cpp | 29 +++--- AVOutput/AVOutputTV.h | 49 +++++++++ AVOutput/AVOutputTVHelper.cpp | 189 +++++++++++++++++++++++++++++----- 3 files changed, 226 insertions(+), 41 deletions(-) diff --git a/AVOutput/AVOutputTV.cpp b/AVOutput/AVOutputTV.cpp index 9dec3bc134..4a835dd01e 100644 --- a/AVOutput/AVOutputTV.cpp +++ b/AVOutput/AVOutputTV.cpp @@ -375,13 +375,6 @@ namespace Plugin { } else { LOGINFO("Platform Init successful...\n"); - ret = TvSyncCalibrationInfoODM(); - if(ret != tvERROR_NONE) { - LOGERR(" SD3 <->cri_data sync failed, ret: %s \n", getErrorString(ret).c_str()); - } - else { - LOGERR(" SD3 <->cri_data sync success, ret: %s \n", getErrorString(ret).c_str()); - } } tvVideoFormatCallbackData callbackData = {this,tvVideoFormatChangeHandler}; @@ -2280,11 +2273,15 @@ namespace Plugin { uint32_t AVOutputTV::getSupportedDolbyVisionModes(const JsonObject& parameters, JsonObject& response) { - LOGINFO("Entry\n"); - pic_modes_t *dvModes; + tvDolbyMode_t dvModes[tvMode_Max]; + tvDolbyMode_t *dvModesPtr = dvModes; // Pointer to statically allocated tvDolbyMode_t array unsigned short totalAvailable = 0; - tvError_t ret = GetTVSupportedDolbyVisionModesODM(&dvModes,&totalAvailable); + + // Set an initial value to indicate the mode type + dvModes[0] = tvDolbyMode_Dark; + + tvError_t ret = GetTVSupportedDolbyVisionModes(&dvModesPtr, &totalAvailable); if(ret != tvERROR_NONE) { returnResponse(false); } @@ -2292,16 +2289,16 @@ namespace Plugin { JsonArray SupportedDVModes; for(int count = 0;count +#include +#include #include "tvTypes.h" #include "tvSettings.h" @@ -67,6 +69,49 @@ #define STRING_DEFAULT "Default" #define STRING_SOURCE "Source." #define CREATE_DIRTY(__X__) (__X__+=STRING_DIRTY) +#define CAPABLITY_FILE_NAME "pq_capabilities.ini" + + +class CIniFile +{ + std::string m_path; + std::string opt_path; + boost::property_tree::ptree m_data; + +public: + CIniFile(const std::string & filename, const std::string & filepath = "/etc/" ) + { + opt_path = "/opt/panel/"; + m_path = filepath; + m_path.append(filename); + opt_path.append(filename); + + if(!boost::filesystem::exists( opt_path)) { + std::cout << "AVOutput : Using " << m_path < + T Get(const std::string & key) + { + return m_data.get(key); + } + + template + void Set(const std::string & key, const T & value){ + //TODO DD: Not required currently + //m_data.put(key, value); + } +}; namespace WPEFramework { namespace Plugin { @@ -217,10 +262,14 @@ class AVOutputTV : public AVOutputBase { tvError_t getParamsCaps(std::vector &range, std::vector &pqmode, std::vector &source, std::vector &format,std::string param , std::string & isPlatformSupport, std::vector & index); + int GetPanelID(char *panelid); + int ConvertHDRFormatToContentFormat(tvhdr_type_t hdrFormat); + int ReadCapablitiesFromConf(std::string &rangeInfo,std::string &pqmodeInfo,std::string &formatInfo,std::string &sourceInfo,std::string param, std::string & isPlatformSupport, std::string & indexInfo); void getDimmingModeStringFromEnum(int value, std::string &toStore); void getColorTempStringFromEnum(int value, std::string &toStore); int getCurrentPictureMode(char *picMode); int getDolbyParamToSync(int sourceIndex, int formatIndex, int& value); + tvDolbyMode_t GetDolbyVisionEnumFromModeString(const char* modeString); std::string getDolbyModeStringFromEnum( tvDolbyMode_t mode); JsonArray getSupportedVideoSource(void); int getAvailableCapabilityModesWrapper(std::string param, std::string & outparam); diff --git a/AVOutput/AVOutputTVHelper.cpp b/AVOutput/AVOutputTVHelper.cpp index 7f878fbe3d..3035a877e6 100644 --- a/AVOutput/AVOutputTVHelper.cpp +++ b/AVOutput/AVOutputTVHelper.cpp @@ -192,7 +192,7 @@ namespace Plugin { if( source.compare("none") == 0 || source.compare("Current") == 0 ) { tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - GetCurrentSource(¤tSource); + GetCurrentVideoSource(¤tSource); sourceIndex = (int)currentSource; } else { @@ -237,23 +237,25 @@ namespace Plugin { int AVOutputTV::getDolbyModeIndex(const char * dolbyMode) { int mode = 0; - pic_modes_t *dolbyModes ; + tvDolbyMode_t dolbyModes[tvMode_Max]; + tvDolbyMode_t *dolbyModesPtr = dolbyModes; // Pointer to statically allocated tvDolbyMode_t array unsigned short totalAvailable = 0; - tvError_t ret = GetTVSupportedDolbyVisionModesODM(&dolbyModes,&totalAvailable); - if(ret == tvERROR_NONE) { - for(int count = 0;count formatInputSet; std::set sourceInputSet; - if( ReadCapablitiesFromConfODM( rangeCapInfo, pqmodeCapInfo, formatCapInfo, sourceCapInfo,param, isPlatformSupport, indexInfo) ) { + if( ReadCapablitiesFromConf( rangeCapInfo, pqmodeCapInfo, formatCapInfo, sourceCapInfo,param, isPlatformSupport, indexInfo) ) { LOGINFO( "%s: readCapablitiesFromConf Failed !!!\n",__FUNCTION__); return false; } @@ -635,7 +637,7 @@ namespace Plugin { PQFileName = std::string(AVOUTPUT_RFC_CALLERID_OVERRIDE); } else { - int val=GetPanelIDODM(panelId); + int val=GetPanelID(panelId); if(val==0) { LOGINFO("%s : panel id read is : %s\n",__FUNCTION__,panelId); if(strncmp(panelId,AVOUTPUT_CONVERTERBOARD_PANELID,strlen(AVOUTPUT_CONVERTERBOARD_PANELID))!=0) { @@ -655,7 +657,6 @@ namespace Plugin { } } strncpy(rfc_caller_id,PQFileName.c_str(),PQFileName.size()); - rfc_caller_id[sizeof(rfc_caller_id) - 1] = '\0'; LOGINFO("%s : Default tvsettings file : %s\n",__FUNCTION__,rfc_caller_id); } @@ -672,7 +673,7 @@ namespace Plugin { current_format = VIDEO_FORMAT_SDR; } // get current source - GetCurrentSource(¤t_source); + GetCurrentVideoSource(¤t_source); tr181_param_name += std::string(AVOUTPUT_SOURCE_PICTUREMODE_STRING_RFC_PARAM); tr181_param_name += "."+convertSourceIndexToString(current_source)+"."+"Format."+convertVideoFormatToString(current_format)+"."+"PictureModeString"; @@ -749,10 +750,10 @@ namespace Plugin { } else if (source == "Current") { tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - tvError_t ret = GetCurrentSource(¤tSource); + tvError_t ret = GetCurrentVideoSource(¤tSource); if(ret != tvERROR_NONE) { - LOGWARN("%s: GetCurrentSource( ) Failed \n",__FUNCTION__); + LOGWARN("%s: GetCurrentVideoSource( ) Failed \n",__FUNCTION__); return -1; } source = convertSourceIndexToString(currentSource); @@ -1281,7 +1282,7 @@ namespace Plugin { sourceIndex = (tvVideoSrcType_t)getSourceIndex(source); } else { - GetCurrentSource(&sourceIndex); + GetCurrentVideoSource(&sourceIndex); } char picMode[PIC_MODE_NAME_MAX]={0}; @@ -1304,7 +1305,7 @@ namespace Plugin { tr181ErrorCode_t err = getLocalParam(rfc_caller_id, rfc_param.c_str(), ¶m); if ( tr181Success != err) { tvError_t retVal = GetDefaultPQParams(pqmodeIndex,(tvVideoSrcType_t)sourceIndex, - (tvVideoFormatType_t)ConvertHDRFormatToContentFormatODM((tvhdr_type_t)format), + (tvVideoFormatType_t)ConvertHDRFormatToContentFormat((tvhdr_type_t)format), PQ_PARAM_DOLBY_MODE,&dolby_mode_value); if( retVal != tvERROR_NONE ) { LOGERR("%s : failed\n",__FUNCTION__); @@ -1334,7 +1335,7 @@ namespace Plugin { std::string indexInfo; std::vector localIndex; - if( ReadCapablitiesFromConfODM( rangeInfo, pqmodeInfo, formatInfo ,sourceInfo,param, platformsupport, indexInfo)) { + if( ReadCapablitiesFromConf( rangeInfo, pqmodeInfo, formatInfo ,sourceInfo,param, platformsupport, indexInfo)) { LOGERR( "%s: ReadCapablitiesFromConf Failed !!!\n",__FUNCTION__); return tvERROR_GENERAL; } @@ -1357,7 +1358,7 @@ namespace Plugin { std::string pqmodeInfo; std::string indexInfo; - if( ReadCapablitiesFromConfODM( rangeInfo, pqmodeInfo, formatInfo ,sourceInfo,param, isPlatformSupport, indexInfo)) { + if( ReadCapablitiesFromConf( rangeInfo, pqmodeInfo, formatInfo ,sourceInfo,param, isPlatformSupport, indexInfo)) { LOGERR( "%s: ReadCapablitiesFromConf Failed !!!\n",__FUNCTION__); return tvERROR_GENERAL; } @@ -1368,6 +1369,119 @@ namespace Plugin { return ret; } + int AVOutputTV::GetPanelID(char *panelId) + { + if (panelId == NULL) { + printf("Invalid buffer provided for panel ID\n"); + return -1; + } + + const char *command = "/usr/bin/panelIDConfig -i"; + FILE *fp; + + // Execute the binary + fp = popen(command, "r"); + if (fp == NULL) { + printf("Failed to execute command: %s\n", command); + return -1; + } + + // Read the panel ID from the binary's output + if (fgets(panelId, 20, fp) != NULL) { + size_t len = strlen(panelId); + if (len > 0 && panelId[len - 1] == '\n') { + panelId[len - 1] = '\0'; + } + } else { + printf("Failed to read panel ID from panelIDConfig binary\n"); + pclose(fp); + return -1; + } + + pclose(fp); + return 0; + } + + int AVOutputTV::ConvertHDRFormatToContentFormat(tvhdr_type_t hdrFormat) + { + int ret=tvContentFormatType_SDR; + switch(hdrFormat) + { + case HDR_TYPE_SDR: + ret=tvContentFormatType_SDR; + break; + case HDR_TYPE_HDR10: + ret=tvContentFormatType_HDR10; + break; + case HDR_TYPE_HDR10PLUS: + ret=tvContentFormatType_HDR10PLUS; + break; + case HDR_TYPE_DOVI: + ret=tvContentFormatType_DOVI; + break; + case HDR_TYPE_HLG: + ret=tvContentFormatType_HLG; + break; + default: + break; + } + return ret; + } + + + int AVOutputTV::ReadCapablitiesFromConf(std::string &rangeInfo,std::string &pqmodeInfo,std::string &formatInfo,std::string &sourceInfo, + std::string param, std::string & isPlatformSupport, std::string & indexInfo) + { + int ret = 0; + + try { + CIniFile inFile(CAPABLITY_FILE_NAME); + std::string configString; + if ((param == "DolbyVisionMode") || (param == "Backlight") ) { + configString = param + ".platformsupport"; + isPlatformSupport = inFile.Get(configString); + printf(" platfromsupport : %s\n",isPlatformSupport.c_str() ); + } + + if ( (param == "ColorTemperature") || (param == "DimmingMode") || + ( param == "AutoBacklightControl") || (param == "DolbyVisionMode") || + (param == "HDR10Mode") || (param == "HLGMode") || (param == "AspectRatio") || + (param == "PictureMode") || (param == "VideoSource") || (param == "VideoFormat") || + (param == "VideoFrameRate") ) { + configString = param + ".range"; + rangeInfo = inFile.Get(configString); + printf(" String Range info : %s\n",rangeInfo.c_str() ); + } else { + configString = param + ".range_from"; + rangeInfo = inFile.Get(configString); + configString = param + ".range_to"; + rangeInfo += ","+inFile.Get(configString); + printf(" Integer Range Info : %s\n",rangeInfo.c_str() ); + } + + if ((param == "VideoSource") || (param == "PictureMode") || (param == "VideoFormat") ) { + configString.clear(); + configString = param + ".index"; + indexInfo = inFile.Get(configString); + printf("Index value %s\n", indexInfo.c_str()); + } + + configString.clear(); + configString = param + ".pqmode"; + pqmodeInfo = inFile.Get(configString); + configString = param + ".format"; + formatInfo = inFile.Get(configString); + configString = param + ".source"; + sourceInfo = inFile.Get(configString); + ret = 0; + } + catch(const boost::property_tree::ptree_error &e) { + printf("%s: error %s::config table entry not found in ini file\n",__FUNCTION__,e.what()); + ret = -1; + } + return ret; + } + void AVOutputTV::getDimmingModeStringFromEnum(int value, std::string &toStore) { const char *color_temp_string[] = { @@ -1398,9 +1512,9 @@ namespace Plugin { std::string tr181_param_name; tvVideoSrcType_t currentSource = VIDEO_SOURCE_IP; - ret = GetCurrentSource(¤tSource); + ret = GetCurrentVideoSource(¤tSource); if(ret != tvERROR_NONE) { - LOGERR("GetCurrentSource() Failed set source to default\n"); + LOGERR("GetCurrentVideoSource() Failed set source to default\n"); return 0; } @@ -1418,7 +1532,6 @@ namespace Plugin { tr181ErrorCode_t err = getLocalParam(rfc_caller_id, tr181_param_name.c_str(), ¶m); if ( err == tr181Success ) { strncpy(picMode, param.value, strlen(param.value)+1); - picMode[strlen(param.value)] = '\0'; LOGINFO("getLocalParam success, mode = %s\n", picMode); return 1; } @@ -1461,6 +1574,32 @@ namespace Plugin { return ret; } + tvDolbyMode_t AVOutputTV::GetDolbyVisionEnumFromModeString(const char* modeString) + { + if (strcmp(modeString, "Invalid") == 0) { + return tvDolbyMode_Invalid; + } else if (strcmp(modeString, "Dark") == 0) { + return tvDolbyMode_Dark; + } else if (strcmp(modeString, "Bright") == 0) { + return tvDolbyMode_Bright; + } else if (strcmp(modeString, "Game") == 0) { + return tvDolbyMode_Game; + } else if (strcmp(modeString, "HDR10 Dark") == 0) { + return tvHDR10Mode_Dark; + } else if (strcmp(modeString, "HDR10 Bright") == 0) { + return tvHDR10Mode_Bright; + } else if (strcmp(modeString, "HDR10 Game") == 0) { + return tvHDR10Mode_Game; + } else if (strcmp(modeString, "HLG Dark") == 0) { + return tvHLGMode_Dark; + } else if (strcmp(modeString, "HLG Bright") == 0) { + return tvHLGMode_Bright; + } else if (strcmp(modeString, "HLG Game") == 0) { + return tvHLGMode_Game; + } + + return tvDolbyMode_Invalid; // Default case for invalid input + } std::string AVOutputTV::getDolbyModeStringFromEnum( tvDolbyMode_t mode)