Skip to content

Commit

Permalink
Merge pull request #5729 from aishwariya15/hdmiversion_main_final
Browse files Browse the repository at this point in the history
RDK-52048: RDKServices changes - getHdmiVersion
  • Loading branch information
ddevad authored Sep 25, 2024
2 parents e5ee64b + 0d3dd46 commit 22b1fff
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 5 deletions.
51 changes: 50 additions & 1 deletion AVInput/AVInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <algorithm>

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 6
#define API_VERSION_NUMBER_MINOR 7
#define API_VERSION_NUMBER_PATCH 0

#define HDMI 0
Expand All @@ -48,6 +48,7 @@
#define AVINPUT_METHOD_GET_EDID_VERSION "getEdidVersion"
#define AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT "setEdid2AllmSupport"
#define AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT "getEdid2AllmSupport"
#define AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion"
#define AVINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels"
#define AVINPUT_METHOD_START_INPUT "startInput"
#define AVINPUT_METHOD_STOP_INPUT "stopInput"
Expand Down Expand Up @@ -223,6 +224,7 @@ void AVInput::RegisterAll()
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SET_MIXER_LEVELS), &AVInput::setMixerLevels, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SET_EDID_ALLM_SUPPORT), &AVInput::setEdid2AllmSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_EDID_ALLM_SUPPORT), &AVInput::getEdid2AllmSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION), &AVInput::getHdmiVersionWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_START_INPUT), &AVInput::startInput, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_STOP_INPUT), &AVInput::stopInput, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_SCALE_INPUT), &AVInput::setVideoRectangleWrapper, this);
Expand Down Expand Up @@ -1362,6 +1364,53 @@ uint32_t AVInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject
}
}

uint32_t AVInput::getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
returnIfParamNotFound(parameters, "portId");
string sPortId = parameters["portId"].String();
int portId = 0;

try {
portId = stoi(sPortId);
}catch (const std::exception& err) {
LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str());
returnResponse(false);
}

dsHdmiMaxCapabilityVersion_t hdmiCapVersion = HDMI_COMPATIBILITY_VERSION_14;

try {
device::HdmiInput::getInstance().getHdmiVersion(portId, &(hdmiCapVersion));
LOGWARN("AVInput::getHdmiVersion Hdmi Version:%d", hdmiCapVersion);
}
catch (const device::Exception& err) {
LOG_DEVICE_EXCEPTION1(std::to_string(portId));
returnResponse(false);
}


switch ((int)hdmiCapVersion){
case HDMI_COMPATIBILITY_VERSION_14:
response["HdmiCapabilityVersion"] = "1.4";
break;
case HDMI_COMPATIBILITY_VERSION_20:
response["HdmiCapabilityVersion"] = "2.0";
break;
case HDMI_COMPATIBILITY_VERSION_21:
response["HdmiCapabilityVersion"] = "2.1";
break;
}


if(hdmiCapVersion == HDMI_COMPATIBILITY_VERSION_MAX)
{
returnResponse(false);
}else{
returnResponse(true);
}
}

int AVInput::setEdidVersion(int iPort, int iEdidVer)
{
bool ret = true;
Expand Down
1 change: 1 addition & 0 deletions AVInput/AVInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC
uint32_t getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response);
uint32_t getGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t setMixerLevels(const JsonObject& parameters, JsonObject& response);
uint32_t getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response);
//End methods

JsonArray getInputDevices(int iType);
Expand Down
29 changes: 28 additions & 1 deletion AVInput/AVInput.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,34 @@
}
]
},
"getSupportedGameFeatures":{
"getHdmiVersion": {
"summary": "Gets the maximum hdmi compatibility version supported for the given port",
"params": {
"type":"object",
"properties": {
"portId":{
"$ref": "#/definitions/portId"
}
},
"required": [
"portId"
]
},
"result": {
"type": "object",
"properties": {
"HdmiCapabilityVersion": {
"summary": "The Maximum Hdmi compatibility version supported by the given port",
"type": "string",
"example": "2.0"
},
"success": {
"$ref": "#/common/success"
}
}
}
},
"getSupportedGameFeatures":{
"summary": "Returns the list of supported game features.",
"result": {
"type": "object",
Expand Down
4 changes: 4 additions & 0 deletions AVInput/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

##[1.7.0] - 2024-09-24
###Added
- Added support for Getting the Maximum HDMI Compatibility version for the given port.

##[1.6.0] - 2024-04-02
###Changed
- Added support for Setting the Audio Mixer level for the given audio input
Expand Down
4 changes: 4 additions & 0 deletions HdmiInput/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.

##[1.4.0] - 2024-09-24
### Added
- Added support for Getting the Maximum HDMI compatibility version for the given port.

##[1.3.0] - 2024-04-02
### Changed
- Added support for setting the audio mixer level for given audio input
Expand Down
53 changes: 51 additions & 2 deletions HdmiInput/HdmiInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#define HDMIINPUT_EVENT_ON_AVI_CONTENT_TYPE_CHANGED "hdmiContentTypeUpdate"
#define HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE "getTVLowLatencyMode"
#define HDMIINPUT_METHOD_GET_AV_LATENCY "getAVLatency"
#define HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion"

#define HDMICECSINK_CALLSIGN "org.rdk.HdmiCecSink"
#define HDMICECSINK_CALLSIGN_VER HDMICECSINK_CALLSIGN".1"
Expand All @@ -66,7 +67,7 @@
#define registerMethod(...) for (uint8_t i = 1; GetHandler(i); i++) GetHandler(i)->Register<JsonObject, JsonObject>(__VA_ARGS__)

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 3
#define API_VERSION_NUMBER_MINOR 4
#define API_VERSION_NUMBER_PATCH 0

static int audio_output_delay = 100;
Expand Down Expand Up @@ -126,7 +127,8 @@ namespace WPEFramework
registerMethod(HDMIINPUT_METHOD_GAME_FEATURE_STATUS, &HdmiInput::getHdmiGameFeatureStatusWrapper, this);
registerMethod(HDMIINPUT_METHOD_GET_AV_LATENCY, &HdmiInput::getAVLatency, this);
registerMethod(HDMIINPUT_METHOD_GET_LOW_LATENCY_MODE, &HdmiInput::getTVLowLatencyMode, this);
m_primVolume = DEFAULT_PRIM_VOL_LEVEL;
registerMethod(HDMIINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION, &HdmiInput::getHdmiVersionWrapper, this);
m_primVolume = DEFAULT_PRIM_VOL_LEVEL;
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
}

Expand Down Expand Up @@ -1198,6 +1200,53 @@ namespace WPEFramework
}

}
uint32_t HdmiInput::getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
returnIfParamNotFound(parameters, "portId");
string sPortId = parameters["portId"].String();
int portId = 0;

try {
portId = stoi(sPortId);
}catch (const std::exception& err) {
LOGWARN("sPortId invalid paramater: %s ", sPortId.c_str());
returnResponse(false);
}

dsHdmiMaxCapabilityVersion_t hdmiCapVersion = HDMI_COMPATIBILITY_VERSION_14;

try {
device::HdmiInput::getInstance().getHdmiVersion(portId, &(hdmiCapVersion));
LOGWARN("HdmiInput::getHdmiVersion Hdmi Version:%d", hdmiCapVersion);
}
catch (const device::Exception& err) {
LOG_DEVICE_EXCEPTION1(std::to_string(portId));
returnResponse(false);
}


switch ((int)hdmiCapVersion){
case HDMI_COMPATIBILITY_VERSION_14:
response["HdmiCapabilityVersion"] = "1.4";
break;
case HDMI_COMPATIBILITY_VERSION_20:
response["HdmiCapabilityVersion"] = "2.0";
break;
case HDMI_COMPATIBILITY_VERSION_21:
response["HdmiCapabilityVersion"] = "2.1";
break;
}


if(hdmiCapVersion == HDMI_COMPATIBILITY_VERSION_MAX)
{
returnResponse(false);
}else{
returnResponse(true);
}
}

uint32_t HdmiInput::getServiceState(PluginHost::IShell* shell, const string& callsign, PluginHost::IShell::state& state)
{
LOGINFO("entering getServiceState\n");
Expand Down
1 change: 1 addition & 0 deletions HdmiInput/HdmiInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace WPEFramework {
uint32_t getHdmiGameFeatureStatusWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getAVLatency(const JsonObject& parameters, JsonObject& response);
uint32_t getTVLowLatencyMode(const JsonObject& parameters, JsonObject& response);
uint32_t getHdmiVersionWrapper(const JsonObject& parameters, JsonObject& response);
//End methods

JsonArray getHDMIInputDevices();
Expand Down
29 changes: 28 additions & 1 deletion HdmiInput/HdmiInput.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,34 @@
"$ref": "#/common/result"
}
},
"setVideoRectangle": {
"getHdmiVersion": {
"summary": "Gets the maximum hdmi compatibility version supported for the given port",
"params": {
"type":"object",
"properties": {
"portId":{
"$ref": "#/definitions/portId"
}
},
"required": [
"portId"
]
},
"result": {
"type": "object",
"properties": {
"HdmiCapabilityVersion": {
"summary": "The Maximum Hdmi compatibility version supported by the given port",
"type": "string",
"example": "2.0"
},
"success": {
"$ref": "#/common/success"
}
}
}
},
"setVideoRectangle": {
"deprecated" : true,
"referenceUrl" : "https://rdkcentral.github.io/rdkservices/#/api/AVInputPlugin?id=setvideorectangle",
"summary": "Sets an HDMI Input video window.",
Expand Down
5 changes: 5 additions & 0 deletions Tests/mocks/devicesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ void HdmiInput::getSupportedGameFeatures(std::vector<std::string>& featureList)
impl->getEdid2AllmSupport(iport,allmSupport);
}

void HdmiInput::getHdmiVersion(int iport, dsHdmiMaxCapabilityVersion_t *capVersion) const {
EXPECT_NE(impl, nullptr);
impl->getHdmiVersion(iport,capVersion);
}

SleepModeImpl* SleepMode::impl = nullptr;

SleepMode::SleepMode() {}
Expand Down
9 changes: 9 additions & 0 deletions Tests/mocks/devicesettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ typedef enum _dsCompositeInPort_t {
dsCOMPOSITE_IN_PORT_MAX
} dsCompositeInPort_t;

typedef enum dsHdmiMaxCapabilityVersion{
HDMI_COMPATIBILITY_VERSION_14 = 0, /*!< Hdmi Compatibility Version 1.4 */
HDMI_COMPATIBILITY_VERSION_20, /*!< Hdmi Compatibility Version 2.0 */
HDMI_COMPATIBILITY_VERSION_21, /*!< Hdmi Compatibility Version 2.1 */
HDMI_COMPATIBILITY_VERSION_MAX /*!< Out of bounds */
}dsHdmiMaxCapabilityVersion_t;

/*! DS Manager Event Data */
typedef struct _DSMgr_EventData_t {
union {
Expand Down Expand Up @@ -577,6 +584,7 @@ class HdmiInputImpl {
virtual void getAVLatency(int *audio_output_delay, int *video_latency) const = 0;
virtual void setEdid2AllmSupport(int iHdmiPort, bool allmsupport) const = 0;
virtual void getEdid2AllmSupport(int iHdmiPort, bool *allmsupport) const = 0;
virtual void getHdmiVersion (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *capversion) const = 0;
};

class HdmiInput {
Expand All @@ -603,6 +611,7 @@ class HdmiInput {
void getAVLatency(int *audio_output_delay, int *video_latency)const;
void setEdid2AllmSupport(int iport, bool allmSupport) const;
void getEdid2AllmSupport(int iport, bool *allmSupport) const;
void getHdmiVersion (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *capversion) const;
};

}
Expand Down
1 change: 1 addition & 0 deletions Tests/mocks/devicesettings/HdmiInputMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ class HdmiInputImplMock : public device::HdmiInputImpl {
MOCK_METHOD(void, getHdmiALLMStatus, (int iHdmiPort, bool *allmStatus), (const, override));
MOCK_METHOD(void, getSupportedGameFeatures, (std::vector<std::string> &featureList), (const, override));
MOCK_METHOD(void, getAVLatency, (int *audio_output_delay,int *video_latency), (const, override));
MOCK_METHOD(void, getHdmiVersion, (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *capVersion), (const, override));
};

0 comments on commit 22b1fff

Please sign in to comment.