Skip to content

Commit

Permalink
Define AVOutput stub apis for advanced PQ and DV IQ features
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunbinu committed Jan 30, 2025
1 parent 5e80c9a commit 449557a
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 6 deletions.
166 changes: 166 additions & 0 deletions AVOutput/AVOutputTV.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -2149,6 +2153,8 @@ namespace Plugin {
ret = SetTVDimmingMode(value.c_str());
}



if(ret != tvERROR_NONE) {
LOGERR("Failed to set DimmingMode\n");
returnResponse(false);
Expand Down Expand Up @@ -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");
Expand Down
42 changes: 40 additions & 2 deletions AVOutput/AVOutputTV.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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*/
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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:

Expand All @@ -210,8 +244,7 @@ class AVOutputTV : public AVOutputBase {

void spliltCapablities( std::vector<std::string> &range,std::vector<std::string> &pqmode,std::vector<std::string> &format,std::vector<std::string> &source, std::vector<string> &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<string> &pqmode, std::set<string> &format, std::set<string> &source);
int validateIntegerInputParameter(std::string param, int inputValue);
int fetchCapablities(string pqparam, string & source, string & pqmode, string & format);
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 449557a

Please sign in to comment.