Skip to content

Commit 0bb7596

Browse files
slkanthiarjunbinu
authored andcommitted
Update implementation for getPictureModeCapsV2
1 parent 22a29f5 commit 0bb7596

File tree

3 files changed

+127
-61
lines changed

3 files changed

+127
-61
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,18 @@ namespace Plugin {
515515
uint32_t AVOutputTV::getBacklightV2(const JsonObject& parameters, JsonObject& response)
516516
{
517517
LOGINFO("Entry: %s", __FUNCTION__);
518+
#define TODO_MOVE_TO_INIT 1
519+
#if TODO_MOVE_TO_INIT
520+
// Retrieve Backlight Caps (Initialization)
521+
LOGINFO("Calling GetBacklightCaps\n");
522+
tvError_t error = GetBacklightCaps(&m_maxBacklight, &m_backlightCaps);
523+
if (error == tvERROR_NONE) {
524+
LOGINFO("Backlight capabilities retrieved successfully. Max: %d\n", m_maxBacklight);
525+
} else {
526+
LOGERR("Failed to retrieve backlight capabilities. Error code: %d\n", error);
527+
returnResponse(false);
528+
}
529+
#endif
518530
std::vector<tvConfigContext_t> validContexts = getValidContextsFromParameters(parameters);
519531
if (validContexts.empty()) {
520532
LOGERR("%s: No valid context found for the given parameters", __FUNCTION__);
@@ -581,30 +593,22 @@ namespace Plugin {
581593
}
582594

583595
uint32_t AVOutputTV::getCapsV2(
584-
const std::function<tvError_t( tvContextCaps_t**,int*, std::vector<std::string>&)>& getCapsFunc,
596+
const std::function<tvError_t( tvContextCaps_t**,int*)>& getCapsFunc,
585597
const char* key,
586598
const JsonObject& parameters,
587599
JsonObject& response)
588600
{
589601
int max_value = 0;
590602
tvContextCaps_t* context_caps = nullptr;
591-
std::vector<std::string> options;
592603
// Call the HAL function
593-
tvError_t result = getCapsFunc( &context_caps, &max_value, options);
604+
tvError_t result = getCapsFunc( &context_caps, &max_value);
594605
LOGWARN("AVOutputPlugins: %s: result: %d", __FUNCTION__, result);
595606
if (result != tvERROR_NONE) {
596607
returnResponse(false);
597608
}
598609
JsonObject capsInfo;
599610
JsonObject rangeInfo;
600-
if (!options.empty()) {
601-
JsonArray optionsArray;
602-
for (const auto& option : options) {
603-
optionsArray.Add(option);
604-
}
605-
rangeInfo["options"] = optionsArray;
606-
capsInfo["rangeInfo"] = rangeInfo;
607-
} else if (max_value){
611+
if (max_value){
608612
rangeInfo["from"] = 0;
609613
rangeInfo["to"] = max_value;
610614
capsInfo["rangeInfo"] = rangeInfo;
@@ -665,55 +669,55 @@ namespace Plugin {
665669
}
666670

667671
uint32_t AVOutputTV::getBacklightCapsV2(const JsonObject& parameters, JsonObject& response) {
668-
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_backlight, std::vector<std::string>&) {
672+
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_backlight) {
669673
return this->GetBacklightCaps(max_backlight, context_caps);
670674
}, "Backlight", parameters, response);
671675
}
672676

673677
uint32_t AVOutputTV::getBrightnessCapsV2(const JsonObject& parameters, JsonObject& response) {
674-
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_brightness, std::vector<std::string>& options) {
678+
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_brightness) {
675679
return this->GetBrightnessCaps(max_brightness, context_caps);
676680
},
677681
"Brightness", parameters, response);
678682
}
679683

680684
uint32_t AVOutputTV::getContrastCapsV2(const JsonObject& parameters, JsonObject& response) {
681-
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_contrast, std::vector<std::string>& options) {
685+
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_contrast) {
682686
return this->GetContrastCaps(max_contrast, context_caps);
683687
},
684688
"Contrast", parameters, response);
685689
}
686690

687691
uint32_t AVOutputTV::getSharpnessCapsV2(const JsonObject& parameters, JsonObject& response) {
688-
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_sharpness, std::vector<std::string>& options) {
692+
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_sharpness) {
689693
return this->GetSharpnessCaps(max_sharpness, context_caps);
690694
},
691695
"Sharpness", parameters, response);
692696
}
693697

694698
uint32_t AVOutputTV::getSaturationCapsV2(const JsonObject& parameters, JsonObject& response) {
695-
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_saturation, std::vector<std::string>& options) {
699+
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_saturation) {
696700
return this->GetSaturationCaps(max_saturation, context_caps);
697701
},
698702
"Saturation", parameters, response);
699703
}
700704

701705
uint32_t AVOutputTV::getHueCapsV2(const JsonObject& parameters, JsonObject& response) {
702-
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_hue, std::vector<std::string>& options) {
706+
return getCapsV2([this]( tvContextCaps_t** context_caps, int* max_hue) {
703707
return this->GetHueCaps(max_hue, context_caps);
704708
},
705709
"Hue", parameters, response);
706710
}
707711

708712
uint32_t AVOutputTV::getPrecisionDetailCapsV2(const JsonObject& parameters, JsonObject& response) {
709-
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_precision, std::vector<std::string>& options) {
713+
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_precision) {
710714
return this->GetPrecisionDetailCaps(max_precision, context_caps);
711715
},
712716
"PrecisionDetails", parameters, response);
713717
}
714718

715719
uint32_t AVOutputTV::getLowLatencyStateCapsV2(const JsonObject& parameters, JsonObject& response) {
716-
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_latency, std::vector<std::string>& options) {
720+
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_latency) {
717721
return this->GetLowLatencyStateCaps(max_latency, context_caps);
718722
},
719723
"LowLatencyState", parameters, response);
@@ -860,10 +864,45 @@ namespace Plugin {
860864
}
861865

862866
uint32_t AVOutputTV::getPictureModeCapsV2(const JsonObject& parameters, JsonObject& response) {
863-
return getCapsV2([this](tvContextCaps_t** context_caps, int* options_count) {
864-
return this->GetTVPictureModeCaps(context_caps);
865-
},
866-
"PictureMode", parameters, response);
867+
tvPQModeIndex_t* modes = nullptr;
868+
size_t num_pic_modes = 0;
869+
tvContextCaps_t* context_caps = nullptr;
870+
871+
tvError_t err = GetTVPictureModeCaps(&modes, &num_pic_modes, &context_caps);
872+
if (err != tvERROR_NONE) {
873+
return err;
874+
}
875+
876+
JsonObject pictureModeJson;
877+
JsonObject rangeInfo;
878+
JsonArray optionsArray;
879+
880+
for (size_t i = 0; i < num_pic_modes; ++i) {
881+
switch (modes[i]) {
882+
case PQ_MODE_STANDARD: optionsArray.Add("Standard"); break;
883+
case PQ_MODE_VIVID: optionsArray.Add("Vivid"); break;
884+
case PQ_MODE_ENERGY_SAVING: optionsArray.Add("EnergySaving"); break;
885+
case PQ_MODE_CUSTOM: optionsArray.Add("Custom"); break;
886+
case PQ_MODE_THEATER: optionsArray.Add("Theater"); break;
887+
case PQ_MODE_GAME: optionsArray.Add("Game"); break;
888+
case PQ_MODE_SPORTS: optionsArray.Add("Sports"); break;
889+
case PQ_MODE_AIPQ: optionsArray.Add("AI PQ"); break;
890+
case PQ_MODE_DARK: optionsArray.Add("Dark"); break;
891+
case PQ_MODE_BRIGHT: optionsArray.Add("Bright"); break;
892+
case PQ_MODE_DVIQ: optionsArray.Add("IQ"); break;
893+
default: break; // Skip invalid/unsupported modes
894+
}
895+
}
896+
897+
rangeInfo["options"] = optionsArray;
898+
pictureModeJson["rangeInfo"] = rangeInfo;
899+
pictureModeJson["platformSupport"] = true;
900+
pictureModeJson["context"] = parseContextCaps(context_caps); // Assuming same parser works
901+
902+
response["PictureMode"] = pictureModeJson;
903+
904+
free(modes);
905+
returnResponse(true);
867906
}
868907

869908
uint32_t AVOutputTV::getDVCalibrationCapsV2(const JsonObject& parameters, JsonObject& response) {

AVOutput/AVOutputTV.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ class AVOutputTV : public AVOutputBase {
437437

438438
tvError_t ReadJsonFile(JsonObject& root);
439439
tvError_t ExtractContextCaps(const JsonObject& data, tvContextCaps_t** context_caps);
440-
tvError_t ExtractRangeInfo(const JsonObject& data, int* max_value, std::vector<std::string>& options);
440+
tvError_t ExtractRangeInfo(const JsonObject& data, int* max_value);
441441
std::vector<tvConfigContext_t> ParseContextCaps(const JsonObject& context);
442442
tvContextCaps_t* AllocateContextCaps(const std::vector<tvConfigContext_t>& contexts);
443-
tvError_t GetCaps(const std::string& key, int* max_value, tvContextCaps_t** context_caps, std::vector<std::string>& options);
443+
tvError_t GetCaps(const std::string& key, int* max_value, tvContextCaps_t** context_caps);
444444
tvError_t GetBacklightCaps(int *max_backlight, tvContextCaps_t **context_caps);
445445
tvError_t GetBrightnessCaps(int *max_brightness, tvContextCaps_t **context_caps);
446446
tvError_t GetContrastCaps(int* max_contrast, tvContextCaps_t** context_caps);
@@ -454,9 +454,9 @@ class AVOutputTV : public AVOutputBase {
454454
tvError_t GetTVDimmingModeCaps(tvDimmingMode_t** dimming_mode, size_t* num_dimming_mode, tvContextCaps_t** context_caps);
455455
tvError_t GetAspectRatioCaps(tvDisplayMode_t** aspect_ratio, size_t* num_aspect_ratio, tvContextCaps_t** context_caps);
456456
tvError_t GetDVCalibrationCaps(tvDVCalibrationSettings_t **min_values, tvDVCalibrationSettings_t **max_values, tvContextCaps_t **context_caps);
457-
tvError_t GetTVPictureModeCaps( tvContextCaps_t** context_caps);
457+
tvError_t GetTVPictureModeCaps(tvPQModeIndex_t** mode, size_t* num_pic_modes, tvContextCaps_t** context_caps);
458458
uint32_t getCapsV2(
459-
const std::function<tvError_t(tvContextCaps_t**, int*, std::vector<std::string>&)>& getCapsFunc,
459+
const std::function<tvError_t(tvContextCaps_t**, int*)>& getCapsFunc,
460460
const char* key,
461461
const JsonObject& parameters,
462462
JsonObject& response);

AVOutput/AVOutputTVHelper.cpp

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,7 +2591,7 @@ tvError_t AVOutputTV::ReadJsonFile(JsonObject& root) {
25912591
return tvERROR_NONE;
25922592
}
25932593

2594-
tvError_t AVOutputTV::ExtractRangeInfo(const JsonObject& data, int* max_value, std::vector<std::string>& options) {
2594+
tvError_t AVOutputTV::ExtractRangeInfo(const JsonObject& data, int* max_value) {
25952595
if (!data.HasLabel("rangeInfo")) {
25962596
LOGWARN("AVOutputPlugins: %s: 'rangeInfo' not available", __FUNCTION__);
25972597
return tvERROR_NONE;
@@ -2605,17 +2605,6 @@ tvError_t AVOutputTV::ExtractRangeInfo(const JsonObject& data, int* max_value, s
26052605
}
26062606
*max_value = rangeInfo["to"].Number();
26072607
return tvERROR_NONE;
2608-
} else if (rangeInfo.HasLabel("options")) {
2609-
JsonArray optionsArray = rangeInfo["options"].Array();
2610-
*max_value = optionsArray.Length();
2611-
if (!optionsArray.IsSet() || optionsArray.Length() == 0) {
2612-
LOGWARN("AVOutputPlugins: %s: 'options' field is missing or empty", __FUNCTION__);
2613-
return tvERROR_GENERAL;
2614-
}
2615-
for (size_t i = 0; i < optionsArray.Length(); ++i) {
2616-
options.push_back(optionsArray[i].String());
2617-
}
2618-
return tvERROR_NONE;
26192608
}
26202609

26212610
LOGWARN("AVOutputPlugins: %s: Invalid 'rangeInfo' format", __FUNCTION__);
@@ -2698,7 +2687,7 @@ tvContextCaps_t* AVOutputTV::AllocateContextCaps(const std::vector<tvConfigConte
26982687
return context_caps;
26992688
}
27002689

2701-
tvError_t AVOutputTV::GetCaps(const std::string& key, int* max_value, tvContextCaps_t** context_caps, std::vector<std::string>& options) {
2690+
tvError_t AVOutputTV::GetCaps(const std::string& key, int* max_value, tvContextCaps_t** context_caps) {
27022691
LOGINFO("Entry\n");
27032692
JsonObject root;
27042693
if (ReadJsonFile(root) != tvERROR_NONE) {
@@ -2716,7 +2705,7 @@ tvError_t AVOutputTV::GetCaps(const std::string& key, int* max_value, tvContextC
27162705
return tvERROR_OPERATION_NOT_SUPPORTED;
27172706
}
27182707

2719-
if (ExtractRangeInfo(data, max_value, options) != tvERROR_NONE) {
2708+
if (ExtractRangeInfo(data, max_value) != tvERROR_NONE) {
27202709
return tvERROR_GENERAL;
27212710
}
27222711

@@ -2728,42 +2717,34 @@ tvError_t AVOutputTV::GetCaps(const std::string& key, int* max_value, tvContextC
27282717
}
27292718

27302719
tvError_t AVOutputTV::GetBacklightCaps(int* max_backlight, tvContextCaps_t** context_caps) {
2731-
std::vector<std::string> emptyOptions;
2732-
return GetCaps("Backlight", max_backlight, context_caps, emptyOptions);
2720+
return GetCaps("Backlight", max_backlight, context_caps);
27332721
}
27342722

27352723
tvError_t AVOutputTV::GetBrightnessCaps(int* max_brightness, tvContextCaps_t** context_caps) {
2736-
std::vector<std::string> emptyOptions;
2737-
return GetCaps("Brightness", max_brightness, context_caps, emptyOptions);
2724+
return GetCaps("Brightness", max_brightness, context_caps);
27382725
}
27392726

27402727
tvError_t AVOutputTV::GetContrastCaps(int* max_contrast, tvContextCaps_t** context_caps) {
2741-
std::vector<std::string> emptyOptions;
2742-
return GetCaps("Contrast", max_contrast, context_caps, emptyOptions);
2728+
return GetCaps("Contrast", max_contrast, context_caps);
27432729
}
27442730

27452731
tvError_t AVOutputTV::GetSharpnessCaps(int* max_sharpness, tvContextCaps_t** context_caps) {
2746-
std::vector<std::string> emptyOptions;
2747-
return GetCaps("Sharpness", max_sharpness, context_caps, emptyOptions);
2732+
return GetCaps("Sharpness", max_sharpness, context_caps);
27482733
}
27492734

27502735
tvError_t AVOutputTV::GetSaturationCaps(int* max_saturation, tvContextCaps_t** context_caps) {
2751-
std::vector<std::string> emptyOptions;
2752-
return GetCaps("Saturation", max_saturation, context_caps, emptyOptions);
2736+
return GetCaps("Saturation", max_saturation, context_caps);
27532737
}
27542738

27552739
tvError_t AVOutputTV::GetHueCaps(int* max_hue, tvContextCaps_t** context_caps) {
2756-
std::vector<std::string> emptyOptions;
2757-
return GetCaps("Hue", max_hue, context_caps, emptyOptions);
2740+
return GetCaps("Hue", max_hue, context_caps);
27582741
}
27592742

27602743
tvError_t AVOutputTV::GetPrecisionDetailCaps(int* max_precision, tvContextCaps_t** context_caps) {
2761-
std::vector<std::string> emptyOptions;
2762-
return GetCaps("PrecisionDetails", max_precision, context_caps, emptyOptions);
2744+
return GetCaps("PrecisionDetails", max_precision, context_caps);
27632745
}
27642746
tvError_t AVOutputTV::GetLowLatencyStateCaps(int* max_latency, tvContextCaps_t ** context_caps){
2765-
std::vector<std::string> emptyOptions;
2766-
return GetCaps("LowLatencyState", max_latency, context_caps, emptyOptions);
2747+
return GetCaps("LowLatencyState", max_latency, context_caps);
27672748
}
27682749

27692750
tvError_t AVOutputTV::GetColorTemperatureCaps(tvColorTemp_t** color_temp, size_t* num_color_temp, tvContextCaps_t** context_caps) {
@@ -2956,10 +2937,56 @@ tvError_t AVOutputTV::GetAspectRatioCaps(tvDisplayMode_t** aspect_ratio, size_t*
29562937
return tvERROR_NONE;
29572938
}
29582939

2959-
tvError_t AVOutputTV::GetTVPictureModeCaps( tvContextCaps_t** context_caps){
2960-
std::vector<std::string> emptyOptions;
2961-
int* options_count = nullptr;
2962-
return GetCaps("PictureMode", options_count, context_caps, emptyOptions);
2940+
tvError_t AVOutputTV::GetTVPictureModeCaps(tvPQModeIndex_t** mode, size_t* num_pic_modes, tvContextCaps_t** context_caps) {
2941+
LOGINFO("Entry\n");
2942+
JsonObject root;
2943+
if (ReadJsonFile(root) != tvERROR_NONE) {
2944+
return tvERROR_GENERAL;
2945+
}
2946+
2947+
std::string key = "PictureMode";
2948+
if (!root.HasLabel(key.c_str())) {
2949+
LOGWARN("AVOutputPlugins: %s: Missing '%s' label", __FUNCTION__, key.c_str());
2950+
return tvERROR_GENERAL;
2951+
}
2952+
2953+
JsonObject data = root[key.c_str()].Object();
2954+
if (!data.HasLabel("platformSupport") || !data["platformSupport"].Boolean()) {
2955+
LOGWARN("AVOutputPlugins: %s: Platform support is false", __FUNCTION__);
2956+
return tvERROR_OPERATION_NOT_SUPPORTED;
2957+
}
2958+
2959+
JsonObject rangeInfo = data["rangeInfo"].Object();
2960+
JsonArray optionsArray = rangeInfo["options"].Array();
2961+
2962+
*num_pic_modes = optionsArray.Length();
2963+
*mode = static_cast<tvPQModeIndex_t*>(malloc(*num_pic_modes * sizeof(tvPQModeIndex_t)));
2964+
if (!(*mode)) {
2965+
return tvERROR_GENERAL;
2966+
}
2967+
2968+
for (size_t i = 0; i < *num_pic_modes; ++i) {
2969+
std::string modeStr = optionsArray[i].String();
2970+
2971+
if (modeStr == "Standard") (*mode)[i] = PQ_MODE_STANDARD;
2972+
else if (modeStr == "Vivid") (*mode)[i] = PQ_MODE_VIVID;
2973+
else if (modeStr == "EnergySaving" || modeStr == "Energy Saving") (*mode)[i] = PQ_MODE_ENERGY_SAVING;
2974+
else if (modeStr == "Theater") (*mode)[i] = PQ_MODE_THEATER;
2975+
else if (modeStr == "Game") (*mode)[i] = PQ_MODE_GAME;
2976+
else if (modeStr == "Sports") (*mode)[i] = PQ_MODE_SPORTS;
2977+
else if (modeStr == "AI PQ") (*mode)[i] = PQ_MODE_AIPQ;
2978+
else if (modeStr == "Dark") (*mode)[i] = PQ_MODE_DARK;
2979+
else if (modeStr == "Bright") (*mode)[i] = PQ_MODE_BRIGHT;
2980+
else if (modeStr == "IQ") (*mode)[i] = PQ_MODE_DVIQ;
2981+
else (*mode)[i] = PQ_MODE_INVALID;
2982+
}
2983+
2984+
if (ExtractContextCaps(data, context_caps) != tvERROR_NONE) {
2985+
free(*mode);
2986+
return tvERROR_GENERAL;
2987+
}
2988+
2989+
return tvERROR_NONE;
29632990
}
29642991

29652992
/*

0 commit comments

Comments
 (0)