From 449557a61a9f0bcc93c3e5bdcf5f864e34c6486d Mon Sep 17 00:00:00 2001 From: arjunbinu <51983664+arjunbinu@users.noreply.github.com> Date: Tue, 28 Jan 2025 09:53:55 +0000 Subject: [PATCH] Define AVOutput stub apis for advanced PQ and DV IQ features --- AVOutput/AVOutputTV.cpp | 166 ++++++++++++++++++++++++++++++++++ AVOutput/AVOutputTV.h | 42 ++++++++- AVOutput/AVOutputTVHelper.cpp | 119 +++++++++++++++++++++++- 3 files changed, 321 insertions(+), 6 deletions(-) mode change 100644 => 100755 AVOutput/AVOutputTV.cpp mode change 100644 => 100755 AVOutput/AVOutputTV.h mode change 100644 => 100755 AVOutput/AVOutputTVHelper.cpp diff --git a/AVOutput/AVOutputTV.cpp b/AVOutput/AVOutputTV.cpp old mode 100644 new mode 100755 index 94f38fe663..2294bd19ae --- a/AVOutput/AVOutputTV.cpp +++ b/AVOutput/AVOutputTV.cpp @@ -338,6 +338,10 @@ namespace Plugin { registerMethod("resetLowLatencyState", &AVOutputTV::resetLowLatencyState, this); registerMethod("getLowLatencyStateCaps", &AVOutputTV::getLowLatencyStateCaps, this); + registerMethod("getMEMC", &AVOutputTV::getMEMC, this); + registerMethod("setMEMC", &AVOutputTV::setMEMC, this); + registerMethod("resetMEMC", &AVOutputTV::resetMEMC, this); + registerMethod("getMEMCCaps", &AVOutputTV::getMEMCCaps, this); LOGINFO("Exit\n"); } @@ -2149,6 +2153,8 @@ namespace Plugin { ret = SetTVDimmingMode(value.c_str()); } + + if(ret != tvERROR_NONE) { LOGERR("Failed to set DimmingMode\n"); returnResponse(false); @@ -3070,6 +3076,166 @@ namespace Plugin { } } + uint32_t AVOutputTV::getMEMC(const JsonObject& parameters, JsonObject& response) { + LOGINFO("Entry"); + + std::string pqmode; + std::string source; + std::string format; + std::string key; + int sourceIndex=0,pqIndex=0,formatIndex=0; + int memc = 0; + + if (parsingGetInputArgumentAdvanced(parameters, source, pqmode, format) != 0) { + LOGERR("Failed to parse arguments"); + returnResponse(false); + } + + if (getParamIndex(source,pqmode,format,sourceIndex,pqIndex,formatIndex) == -1) { + LOGERR("%s: getParamIndex failed to get \n", __FUNCTION__); + returnResponse(false); + } + + int err = getLocalparam("MEMC",formatIndex,pqIndex,sourceIndex,memc, PQ_PARAM_MEMC); + if( err == 0 ) { + response["memc"] = memc; + LOGINFO("Exit : MEMC Value: %d \n", memc); + returnResponse(true); + } + else { + returnResponse(false); + } + } + + uint32_t AVOutputTV::setMEMC(const JsonObject& parameters, JsonObject& response) { + LOGINFO("Entry"); + + std::string value; + std::string pqmode; + std::string source; + std::string format; + int memc = 0; + tvError_t ret = tvERROR_NONE; + + value = parameters.HasLabel("memc") ? parameters["memc"].String() : ""; + returnIfParamNotFound(parameters,"memc"); + memc = std::stoi(value); + + //Hardcoded value ranges + int from = 0, to = 3; + if (!validateIntegerInputParameterAdvanced(memc, from, to)) { + LOGERR("Failed in MEMC range validation:%s", __FUNCTION__); + returnResponse(false); + } + + LOGINFO("setMEMC value %d is in range", memc); + if (parsingSetInputArgumentAdvanced(parameters, source, pqmode, format) != 0) { + LOGERR("Failed to parse input arguments"); + //response["success"] = false; + returnResponse(false); + } + + if( isSetRequired(pqmode,source,format) ) { + LOGINFO("Proceed with %s \n",__FUNCTION__); + } + + int retval= updateAVoutputTVParam("set","MEMC",pqmode,source,format,PQ_PARAM_MEMC,params); + if(retval != 0 ) { + LOGERR("Failed to Save MEMC to ssm_data\n"); + returnResponse(false); + } + response["success"] = true; + LOGINFO("Exit : setMEMC successful"); + returnResponse(true); + } + + uint32_t AVOutputTV::resetMEMC(const JsonObject& parameters, JsonObject& response) { + LOGINFO("Entry"); + + std::string value; + std::string pqmode; + std::string source; + std::string format; + int sourceIndex=0,pqIndex=0,formatIndex=0,memc=0; + int params[3]={0}; + tvError_t ret = tvERROR_NONE; + + if (parsingSetInputArgumentAdvanced(parameters, source, pqmode, format) != 0) { + LOGERR("Failed to parse arguments"); + // Return false for failure + response["success"] = false; + returnResponse(false); + } + + int retval= updateAVoutputTVParam("reset","MEMC",pqmode,source,format,PQ_PARAM_MEMC,params); + if(retval != 0 ) { + LOGWARN("Failed to reset MEMC\n"); + returnResponse(false); + } + else { + if (isSetRequired(pqmode,source,format)) { + getParamIndex("Current","Current", "Current",sourceIndex,pqIndex,formatIndex); + int err = getLocalparam("MEMC",formatIndex,pqIndex,sourceIndex,memc, PQ_PARAM_MEMC); + if( err == 0 ) { + LOGINFO("%s : getLocalparam success format :%d source : %d format : %d value : %d\n",__FUNCTION__,formatIndex, sourceIndex, pqIndex,memc); + } + else { + LOGERR("%s : GetLocalParam Failed \n",__FUNCTION__); + ret = tvERROR_GENERAL; + } + } + } + + if(ret != tvERROR_NONE) { + returnResponse(false); + } + else { + LOGINFO("Exit : resetMEMC Successful to value : %d \n",brightness); + returnResponse(true); + } + } + + uint32_t AVOutputTV::getMEMCCaps(const JsonObject& parameters, JsonObject& response) { + LOGINFO("Entry"); + + response["jsonrpc"] = "2.0"; + response["id"] = 3; + + JsonObject result = JsonObject(); + result["platformSupport"] = true; + + // Adding options array + JsonArray options; + options.Add("2.0"); + options.Add("2.2"); + options.Add("2.4"); + options.Add("BT.1886"); + result["options"] = options; + + // Creating context object + JsonObject context; + JsonArray values; + values.Add("IP"); + values.Add("Tuner"); + values.Add("HDMI1"); + values.Add("HDMI2"); + values.Add("HDMI3"); + values.Add("Composite1"); + + context["Standard"] = values; + context["Vivid"] = values; + context["Sports"] = values; + context["Movie"] = values; + + result["context"] = context; + result["success"] = true; + + response["result"] = result; + + LOGINFO("Exit : getMEMCCaps successful"); + returnResponse(true); + } + uint32_t AVOutputTV::getVideoSource(const JsonObject& parameters,JsonObject& response) { LOGINFO("Entry\n"); diff --git a/AVOutput/AVOutputTV.h b/AVOutput/AVOutputTV.h old mode 100644 new mode 100755 index feb6f9c2e9..f28f61fc05 --- a/AVOutput/AVOutputTV.h +++ b/AVOutput/AVOutputTV.h @@ -71,6 +71,36 @@ #define CREATE_DIRTY(__X__) (__X__+=STRING_DIRTY) #define CAPABLITY_FILE_NAME "pq_capabilities.ini" +typedef enum tvPQParameterIndex2 { + // Precision Detail Methods + PQ_PARAM_GET_PRECISION_DETAIL = 44, //!< Method to get Precision Detail + + // SDR Gamma Methods + PQ_PARAM_GET_SDR_GAMMA, //!< Method to get SDR Gamma + + // Local Contrast Enhancement Methods + PQ_PARAM_GET_LOCAL_CONTRAST_ENHANCEMENT, //!< Method to get Local Contrast Enhancement + + // MPEG Noise Reduction Methods + PQ_PARAM_GET_MPEG_NOISE_REDUCTION, //!< Method to get MPEG Noise Reduction + + // Digital Noise Reduction Methods + PQ_PARAM_GET_DIGITAL_NOISE_REDUCTION, //!< Method to get Digital Noise Reduction + + // AI Super Resolution Methods + PQ_PARAM_GET_AI_SUPER_RESOLUTION, //!< Method to get AI Super Resolution + + // MEMC Methods + PQ_PARAM_GET_MEMC, //!< Method to get MEMC + + // Multi-Point White Balance Methods + PQ_PARAM_GET_MULTI_POINT_WB, //!< Method to get Multi-Point White Balance + + // Dolby Vision PQ Calibration Methods + PQ_PARAM_GET_DOLBY_VISION_CALIBRATION, //!< Method to get Dolby Vision PQ Calibration + + PQ_PARAM_MAX2 //!< End of enum +}tvPQParameterIndex2_t; class CIniFile { @@ -142,6 +172,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(getLowLatencyState) DECLARE_JSON_RPC_METHOD(getZoomMode) DECLARE_JSON_RPC_METHOD(getVideoContentType) + DECLARE_JSON_RPC_METHOD(getMEMC) /*Get Capability API's*/ @@ -161,6 +192,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(getVideoResolutionCaps) DECLARE_JSON_RPC_METHOD(getLowLatencyStateCaps) DECLARE_JSON_RPC_METHOD(getZoomModeCaps) + DECLARE_JSON_RPC_METHOD(getMEMCCaps) /*Set API's*/ DECLARE_JSON_RPC_METHOD(setBacklight) @@ -177,6 +209,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(setZoomMode) DECLARE_JSON_RPC_METHOD(setWBCtrl ) DECLARE_JSON_RPC_METHOD(signalFilmMakerMode) + DECLARE_JSON_RPC_METHOD(setMEMC) /*Reset API's*/ DECLARE_JSON_RPC_METHOD(resetBacklight) @@ -191,6 +224,7 @@ class AVOutputTV : public AVOutputBase { DECLARE_JSON_RPC_METHOD(resetPictureMode ) DECLARE_JSON_RPC_METHOD(resetLowLatencyState) DECLARE_JSON_RPC_METHOD(resetZoomMode) + DECLARE_JSON_RPC_METHOD(resetMEMC) private: @@ -210,8 +244,7 @@ class AVOutputTV : public AVOutputBase { void spliltCapablities( std::vector &range,std::vector &pqmode,std::vector &format,std::vector &source, std::vector &index,std::string rangeInfo, std::string pqmodeInfo, std::string formatInfo, std::string sourceInfo, std::string indexInfo); bool isCapablityCheckPassed( std::string pqmodeInputInfo,std::string sourceInputInfo,std::string formatInputInfo,std::string param ); - int parsingSetInputArgument(const JsonObject& parameters, std::string pqparam,std::string & source, std::string & pqmode, std::string & format); - int parsingGetInputArgument(const JsonObject& parameters, std::string pqparam,std::string & source, std::string & pqmode, std::string & format); + int parsingSetInputArgument(const JsonObject& parameters, std::string pqparam,std::string & source, std::string & pqmode, std::string & format); int parsingGetInputArgument(const JsonObject& parameters, std::string pqparam,std::string & source, std::string & pqmode, std::string & format); void spliltStringsAndConvertToSet( std::string pqmodeInfo,std::string formatInfo,std::string sourceInfo,std::set &pqmode, std::set &format, std::set &source); int validateIntegerInputParameter(std::string param, int inputValue); int fetchCapablities(string pqparam, string & source, string & pqmode, string & format); @@ -282,6 +315,11 @@ class AVOutputTV : public AVOutputBase { void broadcastLowLatencyModeChangeEvent(bool lowLatencyMode); tvError_t setAspectRatioZoomSettings(tvDisplayMode_t mode); tvError_t setDefaultAspectRatio(std::string pqmode="none",std::string format="none",std::string source="none"); + bool validateIntegerInputParameterAdvanced(int inputValue, int fromValue, int toValue); + bool paramsInRangeCheck(const JsonObject& parameters); + int parsingSetInputArgumentAdvanced(const JsonObject& parameters, std::string & source, std::string & pqmode, std::string & format); + int parsingGetInputArgumentAdvanced(const JsonObject& parameters, std::string & source, std::string & pqmode, std::string & format); + public: int m_currentHdmiInResoluton; diff --git a/AVOutput/AVOutputTVHelper.cpp b/AVOutput/AVOutputTVHelper.cpp old mode 100644 new mode 100755 index 3c112b877b..c1ec3d7e24 --- a/AVOutput/AVOutputTVHelper.cpp +++ b/AVOutput/AVOutputTVHelper.cpp @@ -435,6 +435,28 @@ namespace Plugin { } } + bool AVOutputTV::validateIntegerInputParameter(int inputValue, int fromValue, int toValue) { + return (inputValue >= fromValue && inputValue <= toValue); + } + + bool AVOutputTV::paramsInRangeCheck(const JsonObject& parameters) { + static const std::unordered_map> validStringValues = { + {"pictureMode", {"Global", "Current", "Standard", "Sports", "EnergySaving"}}, + {"videoSource", {"Global", "Current", "Composite1", "HDMI1", "HDMI2", "HDMI3", "IP", "Tuner"}}, + {"videoFormat", {"Global", "Current", "SDR", "HDR10", "HLG", "DV"}} + }; + for (const auto& param : validStringValues) { + if (parameters.HasLabel(param.first.c_str())) { + std::string value = parameters[param.first.c_str()].String(); + if (param.second.find(value) == param.second.end()) { + LOGERR("Invalid %s: %s", param.first.c_str(), value.c_str()); + return false; + } + } + } + return true; + } + int AVOutputTV::parsingSetInputArgument(const JsonObject& parameters, std::string pqparam, std::string & source, std::string & pqmode, std::string & format) { @@ -485,6 +507,56 @@ namespace Plugin { return 0; } + int AVOutputTV::parsingSetInputArgumentAdvanced(const JsonObject& parameters, std::string & source, + std::string & pqmode, std::string & format) { + + JsonArray sourceArray; + JsonArray pqmodeArray; + JsonArray formatArray; + + + pqmodeArray = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].Array() : JsonArray(); + for (int i = 0; i < pqmodeArray.Length(); ++i) { + pqmode += pqmodeArray[i].String(); + if (i != (pqmodeArray.Length() - 1) ) { + pqmode += ","; + } + } + + sourceArray = parameters.HasLabel("videoSource") ? parameters["videoSource"].Array() : JsonArray(); + for (int i = 0; i < sourceArray.Length(); ++i) { + source += sourceArray[i].String(); + if (i != (sourceArray.Length() - 1) ) { + source += ","; + } + } + + formatArray = parameters.HasLabel("videoFormat") ? parameters["videoFormat"].Array() : JsonArray(); + for (int i = 0; i < formatArray.Length(); ++i) { + format += formatArray[i].String(); + if (i != (formatArray.Length() - 1) ) { + format += ","; + } + } + + if (source.empty()) { + source = "Global"; + } + if (pqmode.empty()) { + pqmode = "Global"; + } + if (format.empty()) { + format = "Global"; + } + + if (!paramsInRangeCheck(parameters)) { + LOGERR("Input values are out of range"); + return -1; + } + + return 0; + } + int AVOutputTV::parsingGetInputArgument(const JsonObject& parameters, std::string pqparam, std::string & source, std::string & pqmode, std::string & format) { pqmode = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].String() : ""; @@ -516,6 +588,35 @@ namespace Plugin { return 0; } + int AVOutputTV::parsingGetInputArgumentAdvanced(const JsonObject& parameters, std::string & source, std::string & pqmode, std::string & format) { + pqmode = parameters.HasLabel("pictureMode") ? parameters["pictureMode"].String() : ""; + + source = parameters.HasLabel("videoSource") ? parameters["videoSource"].String() : ""; + + format = parameters.HasLabel("videoFormat") ? parameters["videoFormat"].String() : ""; + + if ( (source.compare("Global") == 0) || (pqmode.compare("Global") == 0) || (format.compare("Global") == 0) ) { + LOGERR("%s: get cannot fetch the Global inputs \n", __FUNCTION__); + return -1; + } + + if (source.empty()) { + source = "Current"; + } + if (pqmode.empty()) { + pqmode = "Current"; + } + if (format.empty()) { + format = "Current"; + } + + if (!paramsInRangeCheck(parameters)) { + LOGERR("Input values are out of range"); + return -1; + } + return 0; + } + void AVOutputTV::spliltStringsAndConvertToSet( std::string pqmodeInfo,std::string formatInfo,std::string sourceInfo,std::set &pqmode, std::set &format, std::set &source) { std::string token; @@ -976,10 +1077,20 @@ namespace Plugin { ret |= SaveTVDimmingMode(source, mode,format,(tvDimmingMode_t)params[0]); break; } - case PQ_PARAM_CMS: - case PQ_PARAM_LDIM: - default: - break; + case PQ_PARAM_CMS: + case PQ_PARAM_LDIM: + case PQ_PARAM_PRECISION_DETAIL: + case PQ_PARAM_SDR_GAMMA: + case PQ_PARAM_LOCAL_CONTRAST_ENHANCEMENT: + case PQ_PARAM_MPEG_NOISE_REDUCTION: + case PQ_PARAM_DIGITAL_NOISE_REDUCTION: + case PQ_PARAM_AI_SUPER_RESOLUTION: + case PQ_PARAM_MEMC: + case PQ_PARAM_MULTI_POINT_WB: + case PQ_PARAM_DOLBY_VISION_CALIBRATION: + // Handle new parameters here + default: + break; } } }