@@ -1648,11 +1648,11 @@ namespace Plugin {
1648
1648
}
1649
1649
1650
1650
uint32_t AVOutputTV::setContextPQParam (const JsonObject& parameters, JsonObject& response,
1651
- const std::string& inputParamName,
1652
- const std::string& tr181ParamName,
1653
- int maxAllowedValue,
1654
- tvPQParameterIndex_t pqParamType,
1655
- std::function<tvError_t(tvVideoSrcType_t, tvPQModeIndex_t, tvVideoFormatType_t, int )> halSetter)
1651
+ const std::string& inputParamName,
1652
+ const std::string& tr181ParamName,
1653
+ int maxAllowedValue,
1654
+ tvPQParameterIndex_t pqParamType,
1655
+ std::function<tvError_t(tvVideoSrcType_t, tvPQModeIndex_t, tvVideoFormatType_t, int )> halSetter)
1656
1656
{
1657
1657
LOGINFO (" Entry" );
1658
1658
@@ -1662,11 +1662,30 @@ namespace Plugin {
1662
1662
}
1663
1663
1664
1664
std::string valueStr = parameters[inputParamName.c_str ()].String ();
1665
- int value = std::stoi (valueStr) ;
1665
+ int enumValue = - 1 ;
1666
1666
1667
- if (value < 0 || value > maxAllowedValue) {
1668
- LOGERR (" Input value %d is out of range for %s" , value, inputParamName.c_str ());
1669
- returnResponse (false );
1667
+ // Handle special map-based params
1668
+ if (pqParamType == PQ_PARAM_SDR_GAMMA) {
1669
+ auto it = sdrGammaMap.find (valueStr);
1670
+ if (it == sdrGammaMap.end ()) {
1671
+ LOGERR (" Invalid SDRGamma value: %s" , valueStr.c_str ());
1672
+ returnResponse (false );
1673
+ }
1674
+ enumValue = it->second ;
1675
+ }
1676
+ else {
1677
+ // default: numeric parsing
1678
+ try {
1679
+ enumValue = std::stoi (valueStr);
1680
+ } catch (const std::exception& e) {
1681
+ LOGERR (" Failed to parse %s as integer: %s" , inputParamName.c_str (), e.what ());
1682
+ returnResponse (false );
1683
+ }
1684
+
1685
+ if (enumValue < 0 || enumValue > maxAllowedValue) {
1686
+ LOGERR (" Input value %d is out of range for %s" , enumValue, inputParamName.c_str ());
1687
+ returnResponse (false );
1688
+ }
1670
1689
}
1671
1690
1672
1691
// Get current context
@@ -1680,41 +1699,36 @@ namespace Plugin {
1680
1699
currentFmt = VIDEO_FORMAT_SDR;
1681
1700
1682
1701
char picMode[PIC_MODE_NAME_MAX] = {0 };
1683
- if (getCurrentPictureMode (picMode))
1684
- {
1702
+ if (getCurrentPictureMode (picMode)) {
1685
1703
auto it = pqModeReverseMap.find (picMode);
1686
- if (it != pqModeReverseMap.end ())
1687
- {
1704
+ if (it != pqModeReverseMap.end ()) {
1688
1705
currentPQMode = static_cast <tvPQModeIndex_t>(it->second );
1689
- }
1690
- else
1691
- {
1706
+ } else {
1692
1707
LOGERR (" Unknown picture mode" );
1693
1708
}
1694
- }
1695
- else
1696
- {
1709
+ } else {
1697
1710
LOGERR (" Failed to get current picture mode" );
1698
1711
}
1699
1712
1700
1713
LOGINFO (" currentPQMode: %d, currentFmt: %d, currentSrc: %d" , currentPQMode, currentFmt, currentSrc);
1701
1714
1715
+ // Call HAL if required
1702
1716
if (isSetRequiredForParam (parameters, tr181ParamName)) {
1703
- tvError_t ret = halSetter (currentSrc, currentPQMode, currentFmt, value );
1717
+ tvError_t ret = halSetter (currentSrc, currentPQMode, currentFmt, enumValue );
1704
1718
if (ret != tvERROR_NONE) {
1705
1719
LOGERR (" HAL setter failed for %s" , inputParamName.c_str ());
1706
1720
returnResponse (false );
1707
1721
}
1708
1722
}
1709
1723
1710
- // Persist
1711
- int retval = updateAVoutputTVParamV2 (" set" , tr181ParamName, parameters, pqParamType, value );
1724
+ // Persist enum/int
1725
+ int retval = updateAVoutputTVParamV2 (" set" , tr181ParamName, parameters, pqParamType, enumValue );
1712
1726
if (retval != 0 ) {
1713
- LOGERR (" Failed to save %s to ssm_data " , inputParamName.c_str ());
1727
+ LOGERR (" Failed to save %s to driver " , inputParamName.c_str ());
1714
1728
returnResponse (false );
1715
1729
}
1716
1730
1717
- LOGINFO (" Exit: %s set successfully to %d" , inputParamName.c_str (), value );
1731
+ LOGINFO (" Exit: %s set successfully to %d" , inputParamName.c_str (), enumValue );
1718
1732
returnResponse (true );
1719
1733
}
1720
1734
@@ -3776,7 +3790,7 @@ namespace Plugin {
3776
3790
return setContextPQParam (
3777
3791
parameters, response,
3778
3792
" sdrGamma" , " SDRGamma" ,
3779
- tvSdrGamma_MAX,
3793
+ tvSdrGamma_MAX- 1 ,
3780
3794
PQ_PARAM_SDR_GAMMA,
3781
3795
[](tvVideoSrcType_t src, tvPQModeIndex_t mode, tvVideoFormatType_t /* fmt*/ , int val) {
3782
3796
return SetSdrGamma (src, mode, static_cast <tvSdrGamma_t>(val));
0 commit comments