Skip to content

RDKEMW-13117: Use IARM for PowerManager clients#378

Open
yuvaramachandran-gurusamy wants to merge 5 commits into
topic/support-2p16p9_Testfrom
origin/feature-pwrmgr-revert
Open

RDKEMW-13117: Use IARM for PowerManager clients#378
yuvaramachandran-gurusamy wants to merge 5 commits into
topic/support-2p16p9_Testfrom
origin/feature-pwrmgr-revert

Conversation

@yuvaramachandran-gurusamy

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: apatel859 <amit_patel5@comcast.com>
@yuvaramachandran-gurusamy
yuvaramachandran-gurusamy requested a review from a team as a code owner February 19, 2026 10:36
Copilot AI review requested due to automatic review settings February 19, 2026 10:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_MODECHANGED event 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).

Comment on lines +761 to +768
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;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +911 to +921
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);

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +151 to +158
IARM_Bus_PWRMgr_GetPowerState_Param_t param;
check_ret = IARM_Bus_Call(IARM_BUS_PWRMGR_NAME, IARM_BUS_PWRMGR_API_GetPowerState, (void *)&param, 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);

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

dsHdmiEventHandler has multiple compile/logic issues after switching to IARM power manager:

  • check_ret is 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 use param.curState (or drop the power-state log).
    Also, Configure() still calls InitializePowerManager(service) even though that function was removed, which will not compile (see around line ~226).

Copilot uses AI. Check for mistakes.
Comment on lines 409 to 412

//CEC plugin functionalities will only work if CECmgr is available. If plugin Initialize failure upper layer will call dtor directly.
InitializeIARM();
InitializePowerManager(service);

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 19, 2026 19:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 _parent member 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);

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistent indentation. This line mixes tabs and spaces. The leading whitespace should be consistent with the surrounding code.

Suggested change
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);

Copilot uses AI. Check for mistakes.
}

void HdmiCecSourceImplementation::onPowerModeChanged(const PowerState currentState, const PowerState newState)
void HdmiCecSource::pwrMgrModeChangeEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +136
IARM_Result_t check_ret;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
IARM_Result_t check_ret;

Copilot uses AI. Check for mistakes.
_instance->stopArc();
}
powerState = DEVICE_POWER_STATE_ON;
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
powerState = DEVICE_POWER_STATE_ON;
}
else
{

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistent indentation. This line uses tab characters for indentation while the surrounding code uses spaces. The indentation should be consistent throughout the file.

Suggested change
{
{

Copilot uses AI. Check for mistakes.
{
LOGINFO("%s: Stop ARC \n",__FUNCTION__);
_instance->stopArc();
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistent indentation. Line 933 and other lines in this block mix tabs and spaces for indentation. The entire block should use consistent indentation style.

Copilot uses AI. Check for mistakes.
param->data.state.curState, param->data.state.newState);
if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON)
{
powerState = 0;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

Trailing whitespace at the end of this line. This should be removed for code cleanliness.

Suggested change
powerState = 0;
powerState = 0;

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 19, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Comment on lines +152 to +155
if(check_ret != IARM_RESULT_SUCCESS)
{
LOGWARN("Failed to Invoke RPC method: GetPowerState");
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
HdmiCecSourceImplementation();
virtual ~HdmiCecSourceImplementation();
void onPowerModeChanged(const PowerState currentState, const PowerState newState);
void registerEventHandlers();

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
void registerEventHandlers();

Copilot uses AI. Check for mistakes.
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;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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;
}

Copilot uses AI. Check for mistakes.
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;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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;
}

Copilot uses AI. Check for mistakes.
param->data.state.curState, param->data.state.newState);
if(param->data.state.newState == IARM_BUS_PWRMGR_POWERSTATE_ON)
{
powerState = 0;

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
powerState = 0;
powerState = 0;
HdmiCecSourceImplementation::_instance->getLogicalAddress();

Copilot uses AI. Check for mistakes.
Comment on lines +921 to +955
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");
}

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants