Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 246 additions & 2 deletions AVInput/AVInput.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in AVInput/AVInput.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'AVInput/AVInput.cpp' (Match: rdkcentral/rdkservices/1, 1765 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: AVInput/AVInput.cpp)

Check failure on line 1 in AVInput/AVInput.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'AVInput/AVInput.cpp' (Match: rdkcentral/rdkservices/5.1.0, 1765 lines, url: https://github.com/rdkcentral/rdkservices/archive/AML_BSP_REL_VERSION_RDK5.1.0.tar.gz, file: AVInput/AVInput.cpp)

Check failure on line 1 in AVInput/AVInput.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'AVInput/AVInput.cpp' (Match: rdkcentral/rdkservices/1, 1765 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: HdmiInput/HdmiInput.cpp)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -48,6 +48,9 @@
#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_SET_VRR_SUPPORT "setVRRSupport"
#define AVINPUT_METHOD_GET_VRR_SUPPORT "getVRRSupport"
#define AVINPUT_METHOD_GET_VRR_FRAME_RATE "getVRRFrameRate"
#define AVINPUT_METHOD_GET_HDMI_COMPATIBILITY_VERSION "getHdmiVersion"
#define AVINPUT_METHOD_SET_MIXER_LEVELS "setMixerLevels"
#define AVINPUT_METHOD_START_INPUT "startInput"
Expand Down Expand Up @@ -156,7 +159,11 @@
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS,
dsAVGameFeatureStatusEventHandler));
IARM_CHECK(IARM_Bus_RegisterEventHandler(
IARM_CHECK(IARM_Bus_RegisterEventHandler(
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS,
dsAVGameFeatureStatusEventHandler));
IARM_CHECK(IARM_Bus_RegisterEventHandler(
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG,
dsAVEventHandler));
Expand Down Expand Up @@ -198,6 +205,9 @@
IARM_CHECK(IARM_Bus_RemoveEventHandler(
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, dsAVGameFeatureStatusEventHandler));
IARM_CHECK(IARM_Bus_RemoveEventHandler(
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS, dsAVGameFeatureStatusEventHandler));
IARM_CHECK(IARM_Bus_RemoveEventHandler(
IARM_BUS_DSMGR_NAME,
IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, dsAVEventHandler));
Expand Down Expand Up @@ -231,6 +241,9 @@
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_SET_VRR_SUPPORT), &AVInput::setVRRSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_VRR_SUPPORT), &AVInput::getVRRSupportWrapper, this);
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GET_VRR_FRAME_RATE), &AVInput::getVRRFrameRateWrapper, 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);
Expand All @@ -239,6 +252,7 @@
Register<JsonObject, JsonObject>(_T(AVINPUT_METHOD_GAME_FEATURE_STATUS), &AVInput::getGameFeatureStatusWrapper, this);
m_primVolume = DEFAULT_PRIM_VOL_LEVEL;
m_inputVolume = DEFAULT_INPUT_VOL_LEVEL;
m_currentVrrType = dsVRR_NONE;
}

void AVInput::UnregisterAll()
Expand All @@ -251,6 +265,9 @@
Unregister(_T(AVINPUT_METHOD_READ_EDID));
Unregister(_T(AVINPUT_METHOD_READ_RAWSPD));
Unregister(_T(AVINPUT_METHOD_READ_SPD));
Unregister(_T(AVINPUT_METHOD_SET_VRR_SUPPORT));
Unregister(_T(AVINPUT_METHOD_GET_VRR_SUPPORT));
Unregister(_T(AVINPUT_METHOD_GET_VRR_FRAME_RATE));
Unregister(_T(AVINPUT_METHOD_SET_EDID_VERSION));
Unregister(_T(AVINPUT_METHOD_GET_EDID_VERSION));
Unregister(_T(AVINPUT_METHOD_START_INPUT));
Expand Down Expand Up @@ -1001,6 +1018,28 @@

AVInput::_instance->AVInputALLMChange(hdmi_in_port, allm_mode);
}
if (IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS == eventId)
{
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
int hdmi_in_port = eventData->data.hdmi_in_vrr_mode.port;
dsVRRType_t new_vrrType = eventData->data.hdmi_in_vrr_mode.vrr_type;
LOGWARN("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_VRR_STATUS event port: %d, VRR Type: %d", hdmi_in_port,new_vrrType);

if(new_vrrType == dsVRR_NONE)
{
if(AVInput::_instance->m_currentVrrType != dsVRR_NONE){
AVInput::_instance->AVInputVRRChange(hdmi_in_port, AVInput::_instance->m_currentVrrType, false);
}
}
else
{
if(AVInput::_instance->m_currentVrrType != dsVRR_NONE){
AVInput::_instance->AVInputVRRChange(hdmi_in_port, AVInput::_instance->m_currentVrrType, false);
}
AVInput::_instance->AVInputVRRChange(hdmi_in_port, new_vrrType, true);
}
AVInput::_instance->m_currentVrrType = new_vrrType;
}
}

void AVInput::AVInputALLMChange( int port , bool allm_mode)
Expand All @@ -1013,6 +1052,37 @@
sendNotify(AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params);
}

void AVInput::AVInputVRRChange( int port , dsVRRType_t vrr_type, bool vrr_mode)
{
JsonObject params;
switch(vrr_type)
{
case dsVRR_HDMI_VRR:
params["id"] = port;
params["gameFeature"] = "VRR-HDMI";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we #define for this string as it is used multiple places

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also update the docuementation for all 3 newley added API in entservices-apis

params["mode"] = vrr_mode;
break;
case dsVRR_AMD_FREESYNC:
params["id"] = port;
params["gameFeature"] = "VRR-FREESYNC";
params["mode"] = vrr_mode;
break;
case dsVRR_AMD_FREESYNC_PREMIUM:
params["id"] = port;
params["gameFeature"] = "VRR-FREESYNC-PREMIUM";
params["mode"] = vrr_mode;
break;
case dsVRR_AMD_FREESYNC_PREMIUM_PRO:
params["id"] = port;
params["gameFeature"] = "VRR-FREESYNC-PREMIUM-PRO";
params["mode"] = vrr_mode;
break;
default:
break;
}
sendNotify(AVINPUT_EVENT_ON_GAME_FEATURE_STATUS_CHANGED, params);
}

uint32_t AVInput::getSupportedGameFeatures(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
Expand Down Expand Up @@ -1067,9 +1137,49 @@
LOGWARN("AVInput::getGameFeatureStatusWrapper ALLM MODE:%d", allm);
response["mode"] = allm;
}
else if(strcmp (sGameFeature.c_str(), "VRR-HDMI") == 0)
{
bool hdmi_vrr = false;
dsHdmiInVrrStatus_t vrrStatus;
getVRRStatus(portId, &vrrStatus);
if(vrrStatus.vrrType == dsVRR_HDMI_VRR)
hdmi_vrr = true;
LOGWARN("AVInput::getGameFeatureStatusWrapper HDMI VRR MODE:%d", hdmi_vrr);
response["mode"] = hdmi_vrr;
}
else if(strcmp (sGameFeature.c_str(), "VRR-FREESYNC") == 0)
{
bool freesync = false;
dsHdmiInVrrStatus_t vrrStatus;
getVRRStatus(portId, &vrrStatus);
if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC)
freesync = true;
LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC MODE:%d", freesync);
response["mode"] = freesync;
}
else if(strcmp (sGameFeature.c_str(), "VRR-FREESYNC-PREMIUM") == 0)
{
bool freesync_premium = false;
dsHdmiInVrrStatus_t vrrStatus;
getVRRStatus(portId, &vrrStatus);
if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC_PREMIUM)
freesync_premium = true;
LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC PREMIUM MODE:%d", freesync_premium);
response["mode"] = freesync_premium;
}
else if(strcmp (sGameFeature.c_str(), "VRR-FREESYNC-PREMIUM-PRO") == 0)
{
bool freesync_premium_pro = false;
dsHdmiInVrrStatus_t vrrStatus;
getVRRStatus(portId, &vrrStatus);
if(vrrStatus.vrrType == dsVRR_AMD_FREESYNC_PREMIUM_PRO)
freesync_premium_pro = true;
LOGWARN("AVInput::getGameFeatureStatusWrapper FREESYNC PREMIUM PRO MODE:%d", freesync_premium_pro);
response["mode"] = freesync_premium_pro;
}
else
{
LOGWARN("AVInput::getGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM");
LOGWARN("AVInput::getGameFeatureStatusWrapper Mode is not supported. Supported mode: ALLM, VRR-HDMI, VRR-FREESYNC-PREMIUM");
returnResponse(false);
}
returnResponse(true);
Expand All @@ -1091,6 +1201,22 @@
return allm;
}

bool AVInput::getVRRStatus(int iPort, dsHdmiInVrrStatus_t *vrrStatus)
{
bool ret = true;
try
{
device::HdmiInput::getInstance().getVRRStatus (iPort, vrrStatus);
LOGWARN("AVInput::getVRRStatus VRR TYPE: %d, VRR FRAMERATE: %f", vrrStatus->vrrType,vrrStatus->vrrAmdfreesyncFramerate_Hz);
}
catch (const device::Exception& err)
{
LOG_DEVICE_EXCEPTION1(std::to_string(iPort));
ret = false;
}
return ret;
}

uint32_t AVInput::getRawSPDWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
Expand Down Expand Up @@ -1363,6 +1489,124 @@
}
}

bool AVInput::getVRRSupport(int portId,bool *vrrSupportValue)
{
bool ret = true;
try
{
device::HdmiInput::getInstance().getVRRSupport (portId, vrrSupportValue);
LOGINFO("AVInput - getVRRSupport:%d", *vrrSupportValue);
}
catch (const device::Exception& err)
{
LOG_DEVICE_EXCEPTION1(std::to_string(portId));
ret = false;
}
return ret;
}

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

int portId = 0;
bool vrrSupport = true;

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

bool result = getVRRSupport(portId, &vrrSupport);
if(result == true)
{
response["vrrSupport"] = vrrSupport;
returnResponse(true);
}
else
{
returnResponse(false);
}
}

bool AVInput::setVRRSupport(int portId, bool vrrSupport)
{
bool ret = true;
try
{
device::HdmiInput::getInstance().setVRRSupport (portId, vrrSupport);
LOGWARN("AVInput - vrrSupport:%d", vrrSupport);
}
catch (const device::Exception& err)
{
LOG_DEVICE_EXCEPTION1(std::to_string(portId));
ret = false;
}
return ret;

}

uint32_t AVInput::setVRRSupportWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();

returnIfParamNotFound(parameters, "portId");
returnIfParamNotFound(parameters, "vrrSupport");

int portId = 0;
string sPortId = parameters["portId"].String();
bool vrrSupport = parameters["vrrSupport"].Boolean();

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

bool result = setVRRSupport(portId, vrrSupport);
if(result == true)
{
returnResponse(true);
}
else
{
returnResponse(false);
}
}

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

int portId = 0;
dsHdmiInVrrStatus_t vrrStatus;

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

bool result = getVRRStatus(portId, &vrrStatus);
if(result == true)
{
response["currentVRRVideoFrameRate"] = vrrStatus.vrrAmdfreesyncFramerate_Hz;
returnResponse(true);
}
else
{
returnResponse(false);
}
}

uint32_t AVInput::setEdidVersionWrapper(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
Expand Down
9 changes: 9 additions & 0 deletions AVInput/AVInput.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in AVInput/AVInput.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'AVInput/AVInput.h' (Match: rdkcentral/rdkservices/1, 131 lines, url: https://github.com/rdkcentral/rdkservices/archive/GRT_v1.tar.gz, file: AVInput/AVInput.h)
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
Expand Down Expand Up @@ -47,6 +47,8 @@

int m_primVolume;
int m_inputVolume; //Player Volume

dsVRRType_t m_currentVrrType;
public:
// IPlugin methods
// -------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -79,6 +81,9 @@
uint32_t getEdidVersionWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t setEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getEdid2AllmSupportWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t setVRRSupportWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getVRRSupportWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t getVRRFrameRateWrapper(const JsonObject& parameters, JsonObject& response);
uint32_t startInput(const JsonObject& parameters, JsonObject& response);
uint32_t stopInput(const JsonObject& parameters, JsonObject& response);
uint32_t setVideoRectangleWrapper(const JsonObject& parameters, JsonObject& response);
Expand All @@ -95,10 +100,14 @@
std::string getSPD(int iPort);
int setEdidVersion(int iPort, int iEdidVer);
int getEdidVersion(int iPort);
bool setVRRSupport(int portId, bool vrrSupport);
bool getVRRSupport(int portId, bool *vrrSupportValue);
bool setVideoRectangle(int x, int y, int width, int height, int type);
bool getALLMStatus(int iPort);
bool getVRRStatus(int iPort, dsHdmiInVrrStatus_t *vrrStatus);

void AVInputHotplug(int input , int connect, int type);
void AVInputVRRChange( int port , dsVRRType_t vrr_type, bool vrr_mode);
static void dsAVEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);

void AVInputSignalChange( int port , int signalStatus, int type);
Expand Down
Loading