Skip to content

Commit

Permalink
Merge pull request rdkcentral#5060 from apatel859/release/qs027
Browse files Browse the repository at this point in the history
DELIA-64830: Device struck in standby
  • Loading branch information
apatel859 authored Mar 25, 2024
2 parents a2e6b8c + 9216fcd commit 3f39499
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 21 deletions.
4 changes: 4 additions & 0 deletions HdmiCecSource/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.0.8] - 2024-03-21
### Changed
- Fixed IARM event handling to process in thread

## [1.0.7] - 2024-02-02
### Changed
- Fixed IARM unregister API call
Expand Down
69 changes: 50 additions & 19 deletions HdmiCecSource/HdmiCecSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

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

enum {
HDMICECSOURCE_EVENT_DEVICE_ADDED=0,
Expand Down Expand Up @@ -687,6 +687,37 @@ namespace WPEFramework
IARM_CHECK( IARM_Bus_RemoveEventHandler(IARM_BUS_PWRMGR_NAME,IARM_BUS_PWRMGR_EVENT_MODECHANGED,pwrMgrModeChangeEventHandler) );
}
}
void HdmiCecSource::threadHotPlugEventHandler(int data)
{
LOGINFO("entry threadHotPlugEventHandler \r\n");
if(!HdmiCecSource::_instance)
return;

LOGINFO("Pocessing IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event status:%d \r\n",data);
HdmiCecSource::_instance->onHdmiHotPlug(data);
//Trigger CEC device poll here
pthread_cond_signal(&(_instance->m_condSig));

LOGINFO("Exit threadHotPlugEventHandler \r\n");
}
void HdmiCecSource::threadCecDaemonInitHandler()
{
if(!HdmiCecSource::_instance)
return;

LOGINFO("Pocessing IARM_BUS_CECMGR_EVENT_DAEMON_INITIALIZED \r\n");
HdmiCecSource::_instance->onCECDaemonInit();
LOGINFO("Exit threadCecDaemonInitHandler \r\n");
}
void HdmiCecSource::threadCecStatusUpdateHandler(int data)
{
if(!HdmiCecSource::_instance)
return;

LOGINFO("Pocessing IARM_BUS_CECMGR_EVENT_STATUS_UPDATED LA:%d \r\n", data);
HdmiCecSource::_instance->cecStatusUpdated(data);
LOGINFO("Exit threadCecStatusUpdateHandler \r\n");
}

void HdmiCecSource::cecMgrEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
Expand All @@ -699,16 +730,17 @@ namespace WPEFramework
{
case IARM_BUS_CECMGR_EVENT_DAEMON_INITIALIZED:
{
HdmiCecSource::_instance->onCECDaemonInit();
std::thread worker(threadCecDaemonInitHandler);
worker.detach();
}
break;
case IARM_BUS_CECMGR_EVENT_STATUS_UPDATED:
{
IARM_Bus_CECMgr_Status_Updated_Param_t *evtData = new IARM_Bus_CECMgr_Status_Updated_Param_t;
if(evtData)
{
memcpy(evtData,data,sizeof(IARM_Bus_CECMgr_Status_Updated_Param_t));
HdmiCecSource::_instance->cecStatusUpdated(evtData);
std::thread worker(threadCecStatusUpdateHandler,evtData->logicalAddress);
worker.detach();
}
}
break;
Expand All @@ -721,17 +753,22 @@ namespace WPEFramework

void HdmiCecSource::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
if(!HdmiCecSource::_instance)
if(!HdmiCecSource::_instance || !_instance->cecEnableStatus)
{
LOGINFO("Return from dsHdmiEventHandler due HdmiCecSource::_instance:%p cecEnableStatus:%d \r\n", HdmiCecSource::_instance, _instance->cecEnableStatus);
return;
}

if (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId)
if (owner && !strcmp(owner, IARM_BUS_DSMGR_NAME) && (IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG == eventId))
{
IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data;
int hdmi_hotplug_event = eventData->data.hdmi_hpd.event;
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);
HdmiCecSource::_instance->onHdmiHotPlug(hdmi_hotplug_event);
//Trigger CEC device poll here
pthread_cond_signal(&(_instance->m_condSig));
if(eventData)
{
int hdmi_hotplug_event = eventData->data.hdmi_hpd.event;
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);
std::thread worker(threadHotPlugEventHandler,hdmi_hotplug_event);
worker.detach();
}
}
}

Expand Down Expand Up @@ -771,20 +808,16 @@ namespace WPEFramework
}
}

void HdmiCecSource::cecStatusUpdated(void *evtStatus)
void HdmiCecSource::cecStatusUpdated(int logicalAddr)
{
if (!IsCecMgrActivated) {
LOGWARN("CEC Mgr not activated CEC communication is not possible");
return;
}
IARM_Bus_CECMgr_Status_Updated_Param_t *evtData = (IARM_Bus_CECMgr_Status_Updated_Param_t *)evtStatus;
if(evtData)
{
try{
getPhysicalAddress();

int logicalAddr = evtData->logicalAddress;
std::string logicalAddrDeviceType = DeviceType(LogicalAddress(evtData->logicalAddress).getType()).toString().c_str();
std::string logicalAddrDeviceType = DeviceType(LogicalAddress(logicalAddr).getType()).toString().c_str();

LOGINFO("cecLogicalAddressUpdated: logical address updated: %d , saved : %d ", logicalAddr, logicalAddress.toInt());
if (logicalAddr != logicalAddress.toInt() || logicalAddrDeviceType != logicalAddressDeviceType)
Expand All @@ -798,8 +831,6 @@ namespace WPEFramework
LOGWARN("CEC exception caught from cecStatusUpdated");
}

delete evtData;
}
return;
}

Expand Down
7 changes: 5 additions & 2 deletions HdmiCecSource/HdmiCecSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ namespace WPEFramework {
pthread_mutex_t m_lock;
pthread_cond_t m_condSigUpdate;
pthread_mutex_t m_lockUpdate;
bool cecEnableStatus;

void SendStandbyMsgEvent(const int logicalAddress);
void sendActiveSourceEvent();
Expand Down Expand Up @@ -238,7 +239,6 @@ namespace WPEFramework {
std::string logicalAddressDeviceType;
bool cecSettingEnabled;
bool cecOTPSettingEnabled;
bool cecEnableStatus;
bool IsCecMgrActivated;
Connection *smConnection;
int m_numberOfDevices;
Expand All @@ -261,7 +261,7 @@ namespace WPEFramework {
static void dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
static void pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len);
void onCECDaemonInit();
void cecStatusUpdated(void *evtStatus);
void cecStatusUpdated(int logicalAddress);
void onHdmiHotPlug(int connectStatus);
bool loadSettings();
void persistSettings(bool enableStatus);
Expand All @@ -287,6 +287,9 @@ namespace WPEFramework {
static void threadRun();
static void threadUpdateCheck();
static void threadSendKeyEvent();
static void threadHotPlugEventHandler(int data);
static void threadCecDaemonInitHandler();
static void threadCecStatusUpdateHandler(int data);
};
} // namespace Plugin
} // namespace WPEFramework
Expand Down

0 comments on commit 3f39499

Please sign in to comment.