RDKEMW-13117: Use IARM for PowerManager clients#378
RDKEMW-13117: Use IARM for PowerManager clients#378yuvaramachandran-gurusamy wants to merge 5 commits into
Conversation
Signed-off-by: apatel859 <amit_patel5@comcast.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates HDMI-CEC and HDCP components away from the Thunder org.rdk.PowerManager COM-RPC client usage to using IARM PowerManager APIs/events for power state queries and mode-change notifications.
Changes:
- Replace PowerManager plugin (COM-RPC) power-state queries with
IARM_Bus_Call(IARM_BUS_PWRMGR_API_GetPowerState, ...). - Replace PowerManager mode-change notification registration with IARM
IARM_BUS_PWRMGR_EVENT_MODECHANGEDevent handlers. - Remove PowerManager interface headers/notification plumbing from affected headers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| HdmiCecSource/HdmiCecSourceImplementation.h | Removes PowerManager includes/notification class, adds IARM power-mode handler declaration (currently leaves the header structurally inconsistent). |
| HdmiCecSource/HdmiCecSourceImplementation.cpp | Switches power-state retrieval + mode-change handling to IARM (currently mismatched handler definition and leftover COM-RPC lifecycle code). |
| HdmiCecSink/HdmiCecSink.h | Removes PowerManager plugin interface usage and notification declarations. |
| HdmiCecSink/HdmiCecSink.cpp | Switches power-state retrieval + mode-change handling to IARM and registers/unregisters IARM power-mode events. |
| HdcpProfile/HdcpProfileImplementation.h | Removes PowerManager plugin declarations/includes in preparation for IARM usage. |
| HdcpProfile/HdcpProfileImplementation.cpp | Switches HDCP-status handling to query power state via IARM (currently has compile/logic errors and a leftover call to removed InitializePowerManager). |
| void HdmiCecSource::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) | ||
| { | ||
| if(!HdmiCecSourceImplementation::_instance) | ||
| return; | ||
|
|
||
| LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", | ||
| currentState, newState); | ||
| if (WPEFramework::Exchange::IPowerManager::POWER_STATE_ON == newState) | ||
| { | ||
| powerState = 0; | ||
| HdmiCecSourceImplementation::_instance->getLogicalAddress(); // get the updated LA after wakeup | ||
| } | ||
| else | ||
| powerState = 1; | ||
| if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0) { | ||
| if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED ) { | ||
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; |
There was a problem hiding this comment.
The new IARM handler is defined as HdmiCecSource::pwrMgrModeChangeEventHandler(...), but the declaration in the header is HdmiCecSourceImplementation::pwrMgrModeChangeEventHandler(...) (and this file is in WPEFramework::Plugin). This mismatch will cause a compile/link failure; update the function definition to match the class/namespace declaration.
| void HdmiCecSink::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) | ||
| { | ||
| if(!HdmiCecSink::_instance) | ||
| return; | ||
|
|
||
| LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", | ||
| currentState, newState); | ||
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); | ||
| if(newState == WPEFramework::Exchange::IPowerManager::POWER_STATE_ON) | ||
| { | ||
| powerState = DEVICE_POWER_STATE_ON; | ||
| } | ||
| else | ||
| { | ||
| powerState = DEVICE_POWER_STATE_OFF; | ||
| if((_instance->m_currentArcRoutingState == ARC_STATE_REQUEST_ARC_INITIATION) || (_instance->m_currentArcRoutingState == ARC_STATE_ARC_INITIATED)) | ||
| if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0) { | ||
| if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED ) { | ||
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | ||
| LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", | ||
| param->data.state.curState, param->data.state.newState); | ||
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); |
There was a problem hiding this comment.
The new pwrMgrModeChangeEventHandler drives several behaviors (updating powerState, stopping ARC when transitioning off, triggering poll thread). There is existing L1 test scaffolding for power mode change in Tests/L1Tests/tests/test_HdmiCecSink.cpp, but it is currently commented out; adding/reenabling a test that invokes this handler would help prevent regressions in ARC/power-state behavior.
| IARM_Bus_PWRMgr_GetPowerState_Param_t param; | ||
| check_ret = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_GetPowerState, (void *)¶m, sizeof(param)); | ||
| if(check_ret != IARM_RESULT_SUCCESS) | ||
| LOGWARN("Failed to Invoke RPC method: GetPowerState"); | ||
| IARM_Bus_DSMgr_EventData_t *eventData = (IARM_Bus_DSMgr_EventData_t *)data; | ||
| int hdcpStatus = eventData->data.hdmi_hdcp.hdcpStatus; | ||
| LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDCP_STATUS event data:%d param.curState: %d \r\n", hdcpStatus,pwrStateCur); | ||
| HdcpProfileImplementation::_instance->onHdmiOutputHDCPStatusEvent(hdcpStatus); |
There was a problem hiding this comment.
dsHdmiEventHandler has multiple compile/logic issues after switching to IARM power manager:
check_retis not declared.- The
if(check_ret != IARM_RESULT_SUCCESS)lacks braces, so the HDCP handling runs even on failure. - The log still references
pwrStateCur, which was removed; it should useparam.curState(or drop the power-state log).
Also,Configure()still callsInitializePowerManager(service)even though that function was removed, which will not compile (see around line ~226).
|
|
||
| //CEC plugin functionalities will only work if CECmgr is available. If plugin Initialize failure upper layer will call dtor directly. | ||
| InitializeIARM(); | ||
| InitializePowerManager(service); | ||
|
|
There was a problem hiding this comment.
InitializePowerManager(service) was removed, but the class still has PowerManager COM-RPC lifecycle code (constructor init list / destructor unregister+Reset). With the PowerManager members removed from the header, this will fail to compile; even if restored, _powerManagerPlugin would never be created anymore. Either fully remove the COM-RPC PowerManager plumbing from the implementation or keep it consistently initialized/declared.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
HdmiCecSource/HdmiCecSourceImplementation.h:228
- Orphaned class member. The
_parentmember on line 226 appears to be a leftover from the removed PowerManagerNotification inner class. This private section and the _parent member should be removed as they are no longer associated with any class after the PowerManagerNotification removal.
private:
HdmiCecSourceImplementation& _parent;
};
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | ||
| LOGINFO("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED: State Changed %d -- > %d\r", | ||
| param->data.state.curState, param->data.state.newState); | ||
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); |
There was a problem hiding this comment.
Inconsistent indentation. This line mixes tabs and spaces. The leading whitespace should be consistent with the surrounding code.
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); | |
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); |
| } | ||
|
|
||
| void HdmiCecSourceImplementation::onPowerModeChanged(const PowerState currentState, const PowerState newState) | ||
| void HdmiCecSource::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) |
There was a problem hiding this comment.
Incorrect namespace prefix. The function should be defined as HdmiCecSourceImplementation::pwrMgrModeChangeEventHandler not HdmiCecSource::pwrMgrModeChangeEventHandler. This will cause a compilation error as there is no HdmiCecSource class or namespace defined in the codebase.
| void HdmiCecSource::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) | |
| void HdmiCecSourceImplementation::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len) |
| IARM_Result_t check_ret; | ||
|
|
There was a problem hiding this comment.
Variable check_ret is declared twice: once at line 135 and again at line 151. The second declaration shadows the first one. The declaration at line 135 should be removed as it's unused before being redeclared.
| IARM_Result_t check_ret; |
| _instance->stopArc(); | ||
| } | ||
| powerState = DEVICE_POWER_STATE_ON; | ||
| } |
There was a problem hiding this comment.
Inconsistent indentation. This line uses tabs and spaces inconsistently. Line 925 uses tabs for the closing brace while the surrounding code uses spaces for indentation. This should be consistent with the rest of the codebase.
| } | |
| } |
| powerState = DEVICE_POWER_STATE_ON; | ||
| } | ||
| else | ||
| { |
There was a problem hiding this comment.
Inconsistent indentation. This line uses tab characters for indentation while the surrounding code uses spaces. The indentation should be consistent throughout the file.
| { | |
| { |
| { | ||
| LOGINFO("%s: Stop ARC \n",__FUNCTION__); | ||
| _instance->stopArc(); | ||
| } |
There was a problem hiding this comment.
Inconsistent indentation. Line 933 and other lines in this block mix tabs and spaces for indentation. The entire block should use consistent indentation style.
| param->data.state.curState, param->data.state.newState); | ||
| if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||
| { | ||
| powerState = 0; |
There was a problem hiding this comment.
Trailing whitespace at the end of this line. This should be removed for code cleanliness.
| powerState = 0; | |
| powerState = 0; |
| if(check_ret != IARM_RESULT_SUCCESS) | ||
| { | ||
| LOGWARN("Failed to Invoke RPC method: GetPowerState"); | ||
| } |
There was a problem hiding this comment.
Inconsistent indentation using tabs instead of spaces. Lines 153-155 use tabs for indentation which is inconsistent with the rest of the file that uses spaces. This should be changed to use spaces for consistency.
| HdmiCecSourceImplementation(); | ||
| virtual ~HdmiCecSourceImplementation(); | ||
| void onPowerModeChanged(const PowerState currentState, const PowerState newState); | ||
| void registerEventHandlers(); |
There was a problem hiding this comment.
Declaration for removed function registerEventHandlers() should be deleted. The implementation of registerEventHandlers() was removed from the .cpp file as part of this change, but the function declaration remains in the header file at line 195. This creates an inconsistency where the function is declared but never defined, which could lead to linker errors if called.
| void registerEventHandlers(); |
| powerState = 1; | ||
| if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0) { | ||
| if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED ) { | ||
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; |
There was a problem hiding this comment.
Missing null check for data parameter before dereferencing. The function directly casts and uses the data pointer without checking if it's null. Similar event handlers like dsHdmiEventHandler include a null check (line 741) before accessing the event data. Add a null check for param before accessing param->data.state.curState and param->data.state.newState to prevent potential null pointer dereference.
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | |
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | |
| if (!param) | |
| { | |
| LOGINFO("pwrMgrModeChangeEventHandler: Received null event data for MODECHANGED event\r"); | |
| return; | |
| } |
| if((_instance->m_currentArcRoutingState == ARC_STATE_REQUEST_ARC_INITIATION) || (_instance->m_currentArcRoutingState == ARC_STATE_ARC_INITIATED)) | ||
| if (strcmp(owner, IARM_BUS_PWRMGR_NAME) == 0) { | ||
| if (eventId == IARM_BUS_PWRMGR_EVENT_MODECHANGED ) { | ||
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; |
There was a problem hiding this comment.
Missing null check for data parameter before dereferencing. The function directly casts and uses the data pointer without checking if it's null. Similar event handlers like dsHdmiEventHandler (line 903) include implicit checks. Add a null check for param before accessing param->data.state.curState and param->data.state.newState to prevent potential null pointer dereference.
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | |
| IARM_Bus_PWRMgr_EventData_t *param = (IARM_Bus_PWRMgr_EventData_t *)data; | |
| if (param == nullptr) { | |
| LOGWARN("Event IARM_BUS_PWRMGR_EVENT_MODECHANGED received with null data pointer\r"); | |
| return; | |
| } |
| param->data.state.curState, param->data.state.newState); | ||
| if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||
| { | ||
| powerState = 0; |
There was a problem hiding this comment.
Missing call to getLogicalAddress() when power state changes to ON. In the previous implementation, when the power state changed to POWER_STATE_ON, there was a call to HdmiCecSourceImplementation::_instance->getLogicalAddress() to get the updated logical address after wakeup. This functionality has been removed and should be restored to maintain the same behavior.
| powerState = 0; | |
| powerState = 0; | |
| HdmiCecSourceImplementation::_instance->getLogicalAddress(); |
| LOGWARN(" m_logicalAddressAllocated 0x%x CEC enable status %d \n",_instance->m_logicalAddressAllocated,_instance->cecEnableStatus); | ||
| if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON) | ||
| { | ||
| LOGINFO("%s: Stop ARC \n",__FUNCTION__); | ||
| _instance->stopArc(); | ||
| } | ||
| powerState = DEVICE_POWER_STATE_ON; | ||
| } | ||
| else | ||
| { | ||
| powerState = DEVICE_POWER_STATE_OFF; | ||
| if((_instance->m_currentArcRoutingState == ARC_STATE_REQUEST_ARC_INITIATION) || (_instance->m_currentArcRoutingState == ARC_STATE_ARC_INITIATED)) | ||
| { | ||
| LOGINFO("%s: Stop ARC \n",__FUNCTION__); | ||
| _instance->stopArc(); | ||
| } | ||
|
|
||
| } | ||
| if (_instance->cecEnableStatus) | ||
| { | ||
| if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED ) | ||
| { | ||
| _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState); | ||
|
|
||
| if ( powerState != DEVICE_POWER_STATE_ON ) | ||
| { | ||
| /* reset the current active source when TV on going to standby */ | ||
| HdmiCecSink::_instance->m_currentActiveSource = -1; | ||
| } | ||
| /* Initiate a ping straight away */ | ||
| HdmiCecSink::_instance->m_pollNextState = POLL_THREAD_STATE_PING; | ||
| HdmiCecSink::_instance->m_ThreadExitCV.notify_one(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| LOGWARN("CEC not Enabled\n"); | ||
| } | ||
| } | ||
| if (_instance->cecEnableStatus) | ||
| { | ||
| if ( _instance->m_logicalAddressAllocated != LogicalAddress::UNREGISTERED ) | ||
| { | ||
| _instance->deviceList[_instance->m_logicalAddressAllocated].m_powerStatus = PowerStatus(powerState); | ||
|
|
||
| if ( powerState != DEVICE_POWER_STATE_ON ) | ||
| { | ||
| /* reset the current active source when TV on going to standby */ | ||
| HdmiCecSink::_instance->m_currentActiveSource = -1; | ||
| } | ||
| /* Initiate a ping straight away */ | ||
| HdmiCecSink::_instance->m_pollNextState = POLL_THREAD_STATE_PING; | ||
| HdmiCecSink::_instance->m_ThreadExitCV.notify_one(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| LOGWARN("CEC not Enabled\n"); | ||
| } |
There was a problem hiding this comment.
Inconsistent indentation using a mixture of tabs and spaces. Throughout this function (lines 921-955), there is inconsistent use of tabs and spaces for indentation. Lines 921, 925, 927, 933, 937, 951-955 appear to use tabs while the surrounding code uses spaces. This should be standardized to use only spaces for indentation to maintain consistency with the rest of the codebase.
No description provided.