Skip to content

Commit a910bca

Browse files
slkanthiarjunbinu
authored andcommitted
RDKEVD-281: PQCaps V2 Implementation
1 parent 8ea443f commit a910bca

File tree

3 files changed

+531
-2
lines changed

3 files changed

+531
-2
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,17 @@ namespace Plugin {
393393
registerMethod("setMEMC", &AVOutputTV::setMEMC, this);
394394
registerMethod("resetMEMC", &AVOutputTV::resetMEMC, this);
395395
registerMethod("getMEMCCaps", &AVOutputTV::getMEMCCaps, this);
396+
397+
registerMethod("getBacklightCapsV2", &AVOutputTV::getBacklightCapsV2, this);
398+
registerMethod("getBrightnessCapsV2", &AVOutputTV::getBrightnessCapsV2, this);
399+
registerMethod("getContrastCapsV2", &AVOutputTV::getContrastCapsV2, this);
400+
registerMethod("getSharpnessCapsV2", &AVOutputTV::getSharpnessCapsV2, this);
401+
registerMethod("getSaturationCapsV2", &AVOutputTV::getSaturationCapsV2, this);
402+
registerMethod("getHueCapsV2", &AVOutputTV::getHueCapsV2, this);
403+
registerMethod("getPrecisionDetailCapsV2", &AVOutputTV::getPrecisionDetailCapsV2, this);
404+
registerMethod("getColorTemperatureCapsV2", &AVOutputTV::getColorTemperatureCapsV2, this);
405+
registerMethod("getSdrGammaCapsV2", &AVOutputTV::getSdrGammaCapsV2, this);
406+
registerMethod("getDVCalibrationCapsV2", &AVOutputTV::getDVCalibrationCapsV2, this);
396407

397408
LOGINFO("Exit\n");
398409
}
@@ -495,6 +506,186 @@ namespace Plugin {
495506
LOGINFO("Exit\n");
496507
}
497508

509+
uint32_t AVOutputTV::getCapsV2(
510+
const std::function<tvError_t(int*, tvContextCaps_t**, std::vector<std::string>&)>& getCapsFunc,
511+
const char* key,
512+
const JsonObject& parameters,
513+
JsonObject& response)
514+
{
515+
int max_value = 0;
516+
tvContextCaps_t* context_caps = nullptr;
517+
std::vector<std::string> options;
518+
// Call the HAL function
519+
tvError_t result = getCapsFunc(&max_value, &context_caps, options);
520+
LOGWARN("AVOutputPlugins: %s: result: %d", __FUNCTION__, result);
521+
if (result != tvERROR_NONE) {
522+
returnResponse(false);
523+
}
524+
JsonObject capsInfo;
525+
JsonObject rangeInfo;
526+
if (!options.empty()) {
527+
JsonArray optionsArray;
528+
for (const auto& option : options) {
529+
optionsArray.Add(option);
530+
}
531+
rangeInfo["options"] = optionsArray;
532+
} else {
533+
rangeInfo["from"] = 0;
534+
rangeInfo["to"] = max_value;
535+
}
536+
capsInfo["rangeInfo"] = rangeInfo;
537+
capsInfo["platformSupport"] = true;
538+
capsInfo["context"] = parseContextCaps(context_caps);
539+
response[key] = capsInfo;
540+
returnResponse(true);
541+
}
542+
543+
JsonObject AVOutputTV::parseContextCaps(tvContextCaps_t* context_caps) {
544+
JsonObject contextObj;
545+
if (context_caps && context_caps->num_contexts > 0) {
546+
for (size_t i = 0; i < context_caps->num_contexts; ++i) {
547+
int pqMode = context_caps->contexts[i].pq_mode;
548+
int videoFormat = context_caps->contexts[i].videoFormatType;
549+
int videoSource = context_caps->contexts[i].videoSrcType;
550+
551+
auto pqModeIt = AVOutputTV::pqModeMap.find(pqMode);
552+
auto videoFormatIt = AVOutputTV::videoFormatMap.find(videoFormat);
553+
auto videoSrcIt = AVOutputTV::videoSrcMap.find(videoSource);
554+
555+
if (pqModeIt != AVOutputTV::pqModeMap.end() &&
556+
videoFormatIt != AVOutputTV::videoFormatMap.end() &&
557+
videoSrcIt != AVOutputTV::videoSrcMap.end()) {
558+
559+
const char* pqModeStr = pqModeIt->second.c_str();
560+
const char* videoFormatStr = videoFormatIt->second.c_str();
561+
const char* videoSrcStr = videoSrcIt->second.c_str();
562+
563+
if (!contextObj.HasLabel(pqModeStr)) {
564+
contextObj[pqModeStr] = JsonObject();
565+
}
566+
JsonObject pqModeObj = contextObj[pqModeStr].Object();
567+
568+
if (!pqModeObj.HasLabel(videoFormatStr)) {
569+
pqModeObj[videoFormatStr] = JsonArray();
570+
}
571+
JsonArray formatArray = pqModeObj[videoFormatStr].Array();
572+
// **Manually check for existence before adding**
573+
bool exists = false;
574+
for (size_t j = 0; j < formatArray.Length(); ++j) {
575+
if (strcmp(formatArray[j].String().c_str(), videoSrcStr) == 0) {
576+
exists = true;
577+
break;
578+
}
579+
}
580+
if (!exists) {
581+
formatArray.Add(videoSrcStr);
582+
}
583+
// Update objects
584+
pqModeObj[videoFormatStr] = formatArray;
585+
contextObj[pqModeStr] = pqModeObj;
586+
}
587+
}
588+
}
589+
return contextObj;
590+
}
591+
592+
uint32_t AVOutputTV::getBacklightCapsV2(const JsonObject& parameters, JsonObject& response) {
593+
return getCapsV2([this](int* max_backlight, tvContextCaps_t** context_caps, std::vector<std::string>&) {
594+
return this->GetBacklightCaps(max_backlight, context_caps);
595+
}, "Backlight", parameters, response);
596+
}
597+
598+
uint32_t AVOutputTV::getBrightnessCapsV2(const JsonObject& parameters, JsonObject& response) {
599+
return getCapsV2([this](int* max_brightness, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
600+
return this->GetBrightnessCaps(max_brightness, context_caps);
601+
},
602+
"Brightness", parameters, response);
603+
}
604+
605+
uint32_t AVOutputTV::getContrastCapsV2(const JsonObject& parameters, JsonObject& response) {
606+
return getCapsV2([this](int* max_contrast, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
607+
return this->GetContrastCaps(max_contrast, context_caps);
608+
},
609+
"Contrast", parameters, response);
610+
}
611+
612+
uint32_t AVOutputTV::getSharpnessCapsV2(const JsonObject& parameters, JsonObject& response) {
613+
return getCapsV2([this](int* max_sharpness, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
614+
return this->GetSharpnessCaps(max_sharpness, context_caps);
615+
},
616+
"Sharpness", parameters, response);
617+
}
618+
619+
uint32_t AVOutputTV::getSaturationCapsV2(const JsonObject& parameters, JsonObject& response) {
620+
return getCapsV2([this](int* max_saturation, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
621+
return this->GetSaturationCaps(max_saturation, context_caps);
622+
},
623+
"Saturation", parameters, response);
624+
}
625+
626+
uint32_t AVOutputTV::getHueCapsV2(const JsonObject& parameters, JsonObject& response) {
627+
return getCapsV2([this](int* max_hue, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
628+
return this->GetHueCaps(max_hue, context_caps);
629+
},
630+
"Hue", parameters, response);
631+
}
632+
633+
uint32_t AVOutputTV::getPrecisionDetailCapsV2(const JsonObject& parameters, JsonObject& response) {
634+
return getCapsV2([this](int* max_precision, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
635+
return this->GetPrecisionDetailCaps(max_precision, context_caps);
636+
},
637+
"PrecisionDetails", parameters, response);
638+
}
639+
640+
uint32_t AVOutputTV::getColorTemperatureCapsV2(const JsonObject& parameters, JsonObject& response) {
641+
return getCapsV2([this](int* options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
642+
return this->GetColorTemperatureCaps(options_count, context_caps, options);
643+
},
644+
"ColorTemperature", parameters, response);
645+
}
646+
647+
uint32_t AVOutputTV::getSdrGammaCapsV2(const JsonObject& parameters, JsonObject& response) {
648+
return getCapsV2([this](int* options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
649+
return this->GetSdrGammaCaps(options_count, context_caps, options);
650+
},
651+
"SDRGamma", parameters, response);
652+
}
653+
654+
uint32_t AVOutputTV::getDVCalibrationCapsV2(const JsonObject& parameters, JsonObject& response) {
655+
tvDVCalibrationSettings_t *min_values = nullptr;
656+
tvDVCalibrationSettings_t *max_values = nullptr;
657+
tvContextCaps_t *context_caps = nullptr;
658+
659+
if (GetDVCalibrationCaps(&min_values, &max_values, &context_caps) != tvERROR_NONE) {
660+
returnResponse(false);
661+
}
662+
663+
JsonObject capsInfo;
664+
JsonObject rangeInfo;
665+
666+
rangeInfo["Tmax"] = JsonObject({{"from", min_values->Tmax}, {"to", max_values->Tmax}});
667+
rangeInfo["Tmin"] = JsonObject({{"from", min_values->Tmin}, {"to", max_values->Tmin}});
668+
rangeInfo["Tgamma"] = JsonObject({{"from", min_values->Tgamma}, {"to", max_values->Tgamma}});
669+
rangeInfo["Rx"] = JsonObject({{"from", min_values->Rx}, {"to", max_values->Rx}});
670+
rangeInfo["Ry"] = JsonObject({{"from", min_values->Ry}, {"to", max_values->Ry}});
671+
rangeInfo["Gx"] = JsonObject({{"from", min_values->Gx}, {"to", max_values->Gx}});
672+
rangeInfo["Gy"] = JsonObject({{"from", min_values->Gy}, {"to", max_values->Gy}});
673+
rangeInfo["Bx"] = JsonObject({{"from", min_values->Bx}, {"to", max_values->Bx}});
674+
rangeInfo["By"] = JsonObject({{"from", min_values->By}, {"to", max_values->By}});
675+
rangeInfo["Wx"] = JsonObject({{"from", min_values->Wx}, {"to", max_values->Wx}});
676+
rangeInfo["Wy"] = JsonObject({{"from", min_values->Wy}, {"to", max_values->Wy}});
677+
678+
capsInfo["rangeInfo"] = rangeInfo;
679+
capsInfo["platformSupport"] = true;
680+
capsInfo["context"] = parseContextCaps(context_caps);
681+
682+
response["DolbyVisionCalibration"] = capsInfo;
683+
684+
delete min_values;
685+
delete max_values;
686+
returnResponse(true);
687+
}
688+
498689
uint32_t AVOutputTV::getZoomModeCaps(const JsonObject& parameters, JsonObject& response)
499690
{
500691
LOGINFO("Entry");

AVOutput/AVOutputTV.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ class AVOutputTV : public AVOutputBase {
247247
DECLARE_JSON_RPC_METHOD(getDigitalNoiseReductionCaps)
248248
DECLARE_JSON_RPC_METHOD(getAISuperResolutionCaps)
249249
DECLARE_JSON_RPC_METHOD(getMEMCCaps)
250+
DECLARE_JSON_RPC_METHOD(getBacklightCapsV2)
251+
DECLARE_JSON_RPC_METHOD(getBrightnessCapsV2)
252+
DECLARE_JSON_RPC_METHOD(getContrastCapsV2)
253+
DECLARE_JSON_RPC_METHOD(getSharpnessCapsV2)
254+
DECLARE_JSON_RPC_METHOD(getSaturationCapsV2)
255+
DECLARE_JSON_RPC_METHOD(getHueCapsV2)
256+
DECLARE_JSON_RPC_METHOD(getPrecisionDetailCapsV2)
257+
DECLARE_JSON_RPC_METHOD(getColorTemperatureCapsV2)
258+
DECLARE_JSON_RPC_METHOD(getSdrGammaCapsV2)
259+
DECLARE_JSON_RPC_METHOD(getDVCalibrationCapsV2)
250260

251261
/*Set API's*/
252262
DECLARE_JSON_RPC_METHOD(setBacklight)
@@ -374,6 +384,7 @@ class AVOutputTV : public AVOutputBase {
374384
tvError_t getParamsCaps(std::string param, capVectors_t &vecInfo);
375385
int GetPanelID(char *panelid);
376386
int ReadCapablitiesFromConf(std::string param, capDetails_t& info);
387+
377388
void getDimmingModeStringFromEnum(int value, std::string &toStore);
378389
void getColorTempStringFromEnum(int value, std::string &toStore);
379390
int getCurrentPictureMode(char *picMode);
@@ -418,13 +429,41 @@ class AVOutputTV : public AVOutputBase {
418429
const char* getSDRGammaStringFromEnum(SDRGammaType gammaType);
419430
int convertToValidInputParameterAdvanced(std::string pqparam, capDetails_t& info);
420431

432+
tvError_t ReadJsonFile(JsonObject& root);
433+
tvError_t ExtractContextCaps(const JsonObject& data, tvContextCaps_t** context_caps);
434+
tvError_t ExtractRangeInfo(const JsonObject& data, int* max_value, std::vector<std::string>& options);
435+
std::vector<tvConfigContext_t> ParseContextCaps(const JsonObject& context);
436+
tvContextCaps_t* AllocateContextCaps(const std::vector<tvConfigContext_t>& contexts);
437+
tvError_t GetCaps(const std::string& key, int* max_value, tvContextCaps_t** context_caps, std::vector<std::string>& options);
438+
tvError_t GetBacklightCaps(int *max_backlight, tvContextCaps_t **context_caps);
439+
tvError_t GetBrightnessCaps(int *max_brightness, tvContextCaps_t **context_caps);
440+
tvError_t GetContrastCaps(int* max_contrast, tvContextCaps_t** context_caps);
441+
tvError_t GetSharpnessCaps(int *max_sharpness, tvContextCaps_t **context_caps);
442+
tvError_t GetSaturationCaps(int* max_saturation, tvContextCaps_t** context_caps);
443+
tvError_t GetHueCaps(int* max_hue, tvContextCaps_t** context_caps);
444+
tvError_t GetPrecisionDetailCaps(int* max_precision, tvContextCaps_t** context_caps);
445+
tvError_t GetColorTemperatureCaps(int* options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options);
446+
tvError_t GetSdrGammaCaps(int* options_count, tvContextCaps_t** context_caps, std::vector<std::string>& options);
447+
tvError_t GetDVCalibrationCaps(tvDVCalibrationSettings_t **min_values, tvDVCalibrationSettings_t **max_values, tvContextCaps_t **context_caps);
448+
uint32_t getCapsV2(
449+
const std::function<tvError_t(int*, tvContextCaps_t**, std::vector<std::string>&)>& getCapsFunc,
450+
const char* key,
451+
const JsonObject& parameters,
452+
JsonObject& response);
453+
JsonObject parseContextCaps(tvContextCaps_t* context_caps);
454+
455+
421456
public:
422457
int m_currentHdmiInResoluton;
423458
int m_videoZoomMode;
424459
bool m_isDisabledHdmiIn4KZoom;
425460
char rfc_caller_id[RFC_BUFF_MAX];
426461
bool appUsesGlobalBackLightFactor;
427462
int pic_mode_index[PIC_MODES_SUPPORTED_MAX];
463+
464+
static const std::map<int, std::string> pqModeMap;
465+
static const std::map<int, std::string> videoFormatMap;
466+
static const std::map<int, std::string> videoSrcMap;
428467

429468
AVOutputTV();
430469
~AVOutputTV();
@@ -436,7 +475,6 @@ class AVOutputTV : public AVOutputBase {
436475
void NotifyFilmMakerModeChange(tvContentType_t mode);
437476
void NotifyVideoResolutionChange(tvResolutionParam_t resolution);
438477
void NotifyVideoFrameRateChange(tvVideoFrameRate_t frameRate);
439-
440478
//override API
441479
static void dsHdmiVideoModeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
442480
static void dsHdmiStatusEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);

0 commit comments

Comments
 (0)