Skip to content

Commit e5079c8

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

File tree

3 files changed

+102
-9
lines changed

3 files changed

+102
-9
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 51 additions & 4 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__);
@@ -860,10 +872,45 @@ namespace Plugin {
860872
}
861873

862874
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);
875+
tvPQModeIndex_t* modes = nullptr;
876+
size_t num_pic_modes = 0;
877+
tvContextCaps_t* context_caps = nullptr;
878+
879+
tvError_t err = GetTVPictureModeCaps(&modes, &num_pic_modes, &context_caps);
880+
if (err != tvERROR_NONE) {
881+
return err;
882+
}
883+
884+
JsonObject pictureModeJson;
885+
JsonObject rangeInfo;
886+
JsonArray optionsArray;
887+
888+
for (size_t i = 0; i < num_pic_modes; ++i) {
889+
switch (modes[i]) {
890+
case PQ_MODE_STANDARD: optionsArray.Add("Standard"); break;
891+
case PQ_MODE_VIVID: optionsArray.Add("Vivid"); break;
892+
case PQ_MODE_ENERGY_SAVING: optionsArray.Add("EnergySaving"); break;
893+
case PQ_MODE_CUSTOM: optionsArray.Add("Custom"); break;
894+
case PQ_MODE_THEATER: optionsArray.Add("Theater"); break;
895+
case PQ_MODE_GAME: optionsArray.Add("Game"); break;
896+
case PQ_MODE_SPORTS: optionsArray.Add("Sports"); break;
897+
case PQ_MODE_AIPQ: optionsArray.Add("AI PQ"); break;
898+
case PQ_MODE_DARK: optionsArray.Add("Dark"); break;
899+
case PQ_MODE_BRIGHT: optionsArray.Add("Bright"); break;
900+
case PQ_MODE_DVIQ: optionsArray.Add("IQ"); break;
901+
default: break; // Skip invalid/unsupported modes
902+
}
903+
}
904+
905+
rangeInfo["options"] = optionsArray;
906+
pictureModeJson["rangeInfo"] = rangeInfo;
907+
pictureModeJson["platformSupport"] = true;
908+
pictureModeJson["context"] = parseContextCaps(context_caps); // Assuming same parser works
909+
910+
response["PictureMode"] = pictureModeJson;
911+
912+
free(modes);
913+
returnResponse(true);
867914
}
868915

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

AVOutput/AVOutputTV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ 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(
459459
const std::function<tvError_t(tvContextCaps_t**, int*, std::vector<std::string>&)>& getCapsFunc,
460460
const char* key,

AVOutput/AVOutputTVHelper.cpp

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,10 +2956,56 @@ tvError_t AVOutputTV::GetAspectRatioCaps(tvDisplayMode_t** aspect_ratio, size_t*
29562956
return tvERROR_NONE;
29572957
}
29582958

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);
2959+
tvError_t AVOutputTV::GetTVPictureModeCaps(tvPQModeIndex_t** mode, size_t* num_pic_modes, tvContextCaps_t** context_caps) {
2960+
LOGINFO("Entry\n");
2961+
JsonObject root;
2962+
if (ReadJsonFile(root) != tvERROR_NONE) {
2963+
return tvERROR_GENERAL;
2964+
}
2965+
2966+
std::string key = "PictureMode";
2967+
if (!root.HasLabel(key.c_str())) {
2968+
LOGWARN("AVOutputPlugins: %s: Missing '%s' label", __FUNCTION__, key.c_str());
2969+
return tvERROR_GENERAL;
2970+
}
2971+
2972+
JsonObject data = root[key.c_str()].Object();
2973+
if (!data.HasLabel("platformSupport") || !data["platformSupport"].Boolean()) {
2974+
LOGWARN("AVOutputPlugins: %s: Platform support is false", __FUNCTION__);
2975+
return tvERROR_OPERATION_NOT_SUPPORTED;
2976+
}
2977+
2978+
JsonObject rangeInfo = data["rangeInfo"].Object();
2979+
JsonArray optionsArray = rangeInfo["options"].Array();
2980+
2981+
*num_pic_modes = optionsArray.Length();
2982+
*mode = static_cast<tvPQModeIndex_t*>(malloc(*num_pic_modes * sizeof(tvPQModeIndex_t)));
2983+
if (!(*mode)) {
2984+
return tvERROR_GENERAL;
2985+
}
2986+
2987+
for (size_t i = 0; i < *num_pic_modes; ++i) {
2988+
std::string modeStr = optionsArray[i].String();
2989+
2990+
if (modeStr == "Standard") (*mode)[i] = PQ_MODE_STANDARD;
2991+
else if (modeStr == "Vivid") (*mode)[i] = PQ_MODE_VIVID;
2992+
else if (modeStr == "EnergySaving" || modeStr == "Energy Saving") (*mode)[i] = PQ_MODE_ENERGY_SAVING;
2993+
else if (modeStr == "Theater") (*mode)[i] = PQ_MODE_THEATER;
2994+
else if (modeStr == "Game") (*mode)[i] = PQ_MODE_GAME;
2995+
else if (modeStr == "Sports") (*mode)[i] = PQ_MODE_SPORTS;
2996+
else if (modeStr == "AI PQ") (*mode)[i] = PQ_MODE_AIPQ;
2997+
else if (modeStr == "Dark") (*mode)[i] = PQ_MODE_DARK;
2998+
else if (modeStr == "Bright") (*mode)[i] = PQ_MODE_BRIGHT;
2999+
else if (modeStr == "IQ") (*mode)[i] = PQ_MODE_DVIQ;
3000+
else (*mode)[i] = PQ_MODE_INVALID;
3001+
}
3002+
3003+
if (ExtractContextCaps(data, context_caps) != tvERROR_NONE) {
3004+
free(*mode);
3005+
return tvERROR_GENERAL;
3006+
}
3007+
3008+
return tvERROR_NONE;
29633009
}
29643010

29653011
/*

0 commit comments

Comments
 (0)