Skip to content

Commit 89b9466

Browse files
committed
Added getAutoBacklightModeCapsV2 and corrected getSDRGammaCaps
1 parent b40882f commit 89b9466

File tree

3 files changed

+98
-7
lines changed

3 files changed

+98
-7
lines changed

AVOutput/AVOutputTV.cpp

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,9 @@ namespace Plugin {
404404
registerMethod("getPrecisionDetailCaps", &AVOutputTV::getPrecisionDetailCaps, this);
405405
registerMethod("getLowLatencyStateCapsV2", &AVOutputTV::getLowLatencyStateCapsV2, this);
406406
registerMethod("getColorTemperatureCapsV2", &AVOutputTV::getColorTemperatureCapsV2, this);
407-
registerMethod("getSdrGammaCaps", &AVOutputTV::getSdrGammaCaps, this);
407+
registerMethod("getSDRGammaCaps", &AVOutputTV::getSDRGammaCaps, this);
408408
registerMethod("getBacklightDimmingModeCapsV2", &AVOutputTV::getBacklightDimmingModeCapsV2, this);
409+
registerMethod("getAutoBacklightModeCapsV2", &AVOutputTV::getAutoBacklightModeCapsV2, this);
409410
registerMethod("getZoomModeCapsV2", &AVOutputTV::getZoomModeCapsV2, this);
410411
registerMethod("getDVCalibrationCaps", &AVOutputTV::getDVCalibrationCaps, this);
411412
registerMethod("getPictureModeCapsV2", &AVOutputTV::getPictureModeCapsV2, this);
@@ -711,7 +712,7 @@ namespace Plugin {
711712
return getCapsV2([this](tvContextCaps_t** context_caps, int* max_precision) {
712713
return this->GetPrecisionDetailCaps(max_precision, context_caps);
713714
},
714-
"PrecisionDetails", parameters, response);
715+
"PrecisionDetail", parameters, response);
715716
}
716717

717718
uint32_t AVOutputTV::getLowLatencyStateCapsV2(const JsonObject& parameters, JsonObject& response) {
@@ -759,12 +760,12 @@ namespace Plugin {
759760
returnResponse(true);
760761
}
761762

762-
uint32_t AVOutputTV::getSdrGammaCaps(const JsonObject& parameters, JsonObject& response) {
763+
uint32_t AVOutputTV::getSDRGammaCaps(const JsonObject& parameters, JsonObject& response) {
763764
tvSdrGamma_t* sdr_gamma = nullptr;
764765
size_t num_sdr_gamma = 0;
765766
tvContextCaps_t* context_caps = nullptr;
766767

767-
tvError_t err = GetSdrGammaCaps(&sdr_gamma, &num_sdr_gamma, &context_caps);
768+
tvError_t err = GetSDRGammaCaps(&sdr_gamma, &num_sdr_gamma, &context_caps);
768769
if (err != tvERROR_NONE) {
769770
return err;
770771
}
@@ -826,6 +827,48 @@ namespace Plugin {
826827
returnResponse(true);
827828
}
828829

830+
uint32_t AVOutputTV::getAutoBacklightModeCapsV2(const JsonObject& parameters, JsonObject& response)
831+
{
832+
tvBacklightMode_t* m_backlightModes = nullptr;
833+
size_t m_numBacklightModes = 0;
834+
tvContextCaps_t* m_backlightModeCaps = nullptr;
835+
836+
JsonObject backlightModeJson;
837+
JsonObject rangeInfo;
838+
JsonArray optionsArray;
839+
tvError_t err = GetBacklightModeCaps(&m_backlightModes, &m_numBacklightModes, &m_backlightModeCaps);
840+
if (err != tvERROR_NONE) {
841+
return err;
842+
}
843+
for (size_t i = 0; i < m_numBacklightModes; ++i) {
844+
switch (m_backlightModes[i]) {
845+
case tvBacklightMode_MANUAL:
846+
optionsArray.Add("Manual");
847+
break;
848+
case tvBacklightMode_AMBIENT:
849+
optionsArray.Add("Ambient");
850+
break;
851+
case tvBacklightMode_ECO:
852+
optionsArray.Add("Eco");
853+
break;
854+
default:
855+
LOGINFO("Unknown backlightMode option \n");
856+
break;
857+
}
858+
}
859+
860+
rangeInfo["options"] = optionsArray;
861+
backlightModeJson["rangeInfo"] = rangeInfo;
862+
backlightModeJson["platformSupport"] = true;
863+
864+
backlightModeJson["context"] = parseContextCaps(m_backlightModeCaps);
865+
response["BacklightMode"] = backlightModeJson;
866+
867+
// TODO:: Review cleanup once HAL is available, as memory will be allocated in HAL.
868+
free(m_backlightModes);
869+
returnResponse(true);
870+
}
871+
829872
uint32_t AVOutputTV::getZoomModeCapsV2(const JsonObject& parameters, JsonObject& response) {
830873
tvDisplayMode_t* aspect_ratio = nullptr;
831874
size_t num_aspect_ratio = 0;

AVOutput/AVOutputTV.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,9 @@ class AVOutputTV : public AVOutputBase {
255255
DECLARE_JSON_RPC_METHOD(getPrecisionDetailCaps)
256256
DECLARE_JSON_RPC_METHOD(getLowLatencyStateCapsV2)
257257
DECLARE_JSON_RPC_METHOD(getColorTemperatureCapsV2)
258-
DECLARE_JSON_RPC_METHOD(getSdrGammaCaps)
258+
DECLARE_JSON_RPC_METHOD(getSDRGammaCaps)
259259
DECLARE_JSON_RPC_METHOD(getBacklightDimmingModeCapsV2)
260+
DECLARE_JSON_RPC_METHOD(getAutoBacklightModeCapsV2)
260261
DECLARE_JSON_RPC_METHOD(getZoomModeCapsV2)
261262
DECLARE_JSON_RPC_METHOD(getDVCalibrationCaps)
262263
DECLARE_JSON_RPC_METHOD(getPictureModeCapsV2)
@@ -448,8 +449,9 @@ class AVOutputTV : public AVOutputBase {
448449
tvError_t GetPrecisionDetailCaps(int* max_precision, tvContextCaps_t** context_caps);
449450
tvError_t GetLowLatencyStateCaps(int* max_latency, tvContextCaps_t ** context_caps);
450451
tvError_t GetColorTemperatureCaps(tvColorTemp_t** color_temp, size_t* num_color_temp, tvContextCaps_t** context_caps);
451-
tvError_t GetSdrGammaCaps(tvSdrGamma_t** sdr_gamma, size_t* num_sdr_gamma, tvContextCaps_t** context_caps);
452+
tvError_t GetSDRGammaCaps(tvSdrGamma_t** sdr_gamma, size_t* num_sdr_gamma, tvContextCaps_t** context_caps);
452453
tvError_t GetTVDimmingModeCaps(tvDimmingMode_t** dimming_mode, size_t* num_dimming_mode, tvContextCaps_t** context_caps);
454+
tvError_t GetBacklightModeCaps(tvBacklightMode_t** backlight_mode, size_t* num_backlight_mode, tvContextCaps_t** context_caps);
453455
tvError_t GetAspectRatioCaps(tvDisplayMode_t** aspect_ratio, size_t* num_aspect_ratio, tvContextCaps_t** context_caps);
454456
tvError_t GetDVCalibrationCaps(tvDVCalibrationSettings_t **min_values, tvDVCalibrationSettings_t **max_values, tvContextCaps_t **context_caps);
455457
tvError_t GetTVPictureModeCaps(tvPQModeIndex_t** mode, size_t* num_pic_modes, tvContextCaps_t** context_caps);

AVOutput/AVOutputTVHelper.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ tvError_t AVOutputTV::GetColorTemperatureCaps(tvColorTemp_t** color_temp, size_t
27992799
}
28002800

28012801

2802-
tvError_t AVOutputTV::GetSdrGammaCaps(tvSdrGamma_t** sdr_gamma, size_t* num_sdr_gamma, tvContextCaps_t** context_caps) {
2802+
tvError_t AVOutputTV::GetSDRGammaCaps(tvSdrGamma_t** sdr_gamma, size_t* num_sdr_gamma, tvContextCaps_t** context_caps) {
28032803
LOGINFO("Entry\n");
28042804
JsonObject root;
28052805
if (ReadJsonFile(root) != tvERROR_NONE) {
@@ -2889,6 +2889,52 @@ tvError_t AVOutputTV::GetTVDimmingModeCaps(tvDimmingMode_t** dimming_mode, size_
28892889

28902890
}
28912891

2892+
tvError_t AVOutputTV::GetBacklightModeCaps(tvBacklightMode_t** backlight_mode, size_t* num_backlight_mode, tvContextCaps_t** context_caps)
2893+
{
2894+
LOGINFO("Entry\n");
2895+
2896+
JsonObject root;
2897+
if (ReadJsonFile(root) != tvERROR_NONE) {
2898+
return tvERROR_GENERAL;
2899+
}
2900+
2901+
std::string key = "BacklightMode";
2902+
if (!root.HasLabel(key.c_str())) {
2903+
LOGWARN("AVOutputPlugins: %s: Missing '%s' label", __FUNCTION__, key.c_str());
2904+
return tvERROR_GENERAL;
2905+
}
2906+
2907+
JsonObject data = root[key.c_str()].Object();
2908+
if (!data.HasLabel("platformSupport") || !data["platformSupport"].Boolean()) {
2909+
LOGWARN("AVOutputPlugins: %s: Platform support is false", __FUNCTION__);
2910+
return tvERROR_OPERATION_NOT_SUPPORTED;
2911+
}
2912+
2913+
JsonObject rangeInfo = data["rangeInfo"].Object();
2914+
JsonArray optionsArray = rangeInfo["options"].Array();
2915+
2916+
*num_backlight_mode = optionsArray.Length();
2917+
*backlight_mode = static_cast<tvBacklightMode_t*>(malloc(*num_backlight_mode * sizeof(tvBacklightMode_t)));
2918+
if (!(*backlight_mode)) {
2919+
return tvERROR_GENERAL;
2920+
}
2921+
2922+
for (size_t i = 0; i < *num_backlight_mode; ++i) {
2923+
std::string modeStr = optionsArray[i].String();
2924+
2925+
if (modeStr == "Manual") (*backlight_mode)[i] = tvBacklightMode_MANUAL ;
2926+
else if (modeStr == "Ambient") (*backlight_mode)[i] = tvBacklightMode_AMBIENT ;
2927+
else (*backlight_mode)[i] = tvBacklightMode_INVALID ; //tvBacklightMode_MAX
2928+
}
2929+
2930+
if (ExtractContextCaps(data, context_caps) != tvERROR_NONE) {
2931+
free(*backlight_mode);
2932+
return tvERROR_GENERAL;
2933+
}
2934+
2935+
return tvERROR_NONE;
2936+
}
2937+
28922938
tvError_t AVOutputTV::GetAspectRatioCaps(tvDisplayMode_t** aspect_ratio, size_t* num_aspect_ratio, tvContextCaps_t** context_caps) {
28932939
LOGINFO("Entry\n");
28942940
JsonObject root;

0 commit comments

Comments
 (0)