Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cd rfc
autoreconf -i
./configure --enable-rfctool=yes --enable-tr181set=yes
cd rfcapi
make librfcapi_la_CPPFLAGS="-I/usr/include/cjson"
make CXXFLAGS="-DUSE_IARMBUS" librfcapi_la_CPPFLAGS="-I/usr/include/cjson"
make install
export RFC_PATH=$ROOT/rfc

Expand Down
2 changes: 1 addition & 1 deletion cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ find $WORKDIR -iname "*.o" -exec rm -v {} \;
find $WORKDIR -iname "*.so*" -exec rm -v {} \;

echo "##### Triggering make"
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DDS_ENABLE_IARM_PATH -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/ds/include/iarm -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"
35 changes: 35 additions & 0 deletions ds/hdmiIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "dsUtl.h"
#include "edid-parser.hpp"
#include "dsInternal.h"
#include "iarmHdmiIn.hpp"


namespace device
Expand All @@ -82,6 +83,7 @@ namespace device
* @callergraph
*/
HdmiInput::HdmiInput()
: implHdmiIn(std::unique_ptr<IarmHdmiInput>(new IarmHdmiInput()))
{
dsHdmiInInit();
}
Expand All @@ -98,6 +100,7 @@ HdmiInput::HdmiInput()
HdmiInput::~HdmiInput()
{
dsHdmiInTerm();
implHdmiIn.reset();
}

/**
Expand Down Expand Up @@ -678,6 +681,38 @@ void HdmiInput::getHdmiVersion (int iHdmiPort, dsHdmiMaxCapabilityVersion_t *cap
printf ("%s:%d - HDMI Compatibility Version = %d\n", __PRETTY_FUNCTION__, __LINE__, *capversion);
}

uint32_t HdmiInput::Register(IEvent *listener)
{
uint32_t retStatus=FAIL;

INT_INFO("HdmiInput::Register Entry \n");
if(implHdmiIn)
{
retStatus = implHdmiIn->Register(listener);
}
else
{
INT_INFO("HdmiInput::Register impl is null\n");
}
return retStatus;
}

uint32_t HdmiInput::UnRegister(IEvent *listener)
{
uint32_t retStatus=FAIL;

INT_INFO("HdmiInput::UnRegister Entry \n");
if(implHdmiIn)
{
retStatus = implHdmiIn->UnRegister(listener);
}
else
{
INT_INFO("HdmiInput::UnRegister impl is null\n");
}
return retStatus;
}

}


Expand Down
185 changes: 185 additions & 0 deletions ds/iarmHdmiIn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in ds/iarmHdmiIn.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 'ds/iarmHdmiIn.cpp' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2.1-20161031, 43 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/2.1-20161031.tar.gz, file: ds/hdmiIn.cpp)
*
* Copyright 2025 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/**
* @file IarmHdmiIn.cpp
* @brief Configuration of HDMI Input
*/

/**
* @defgroup devicesettings
* @{
* @defgroup ds
* @{
**/


#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "hdmiIn.hpp"
#include "illegalArgumentException.hpp"
#include "host.hpp"

#include "dslogger.h"
#include "dsError.h"
#include "dsTypes.h"
#include "dsHdmiIn.h"
#include "dsUtl.h"
#include "edid-parser.hpp"
#include "dsInternal.h"

#include "utils.h" // for Utils::IARM and IARM_CHECK


#include "iarmHdmiIn.hpp"
#include <algorithm>
#include <cstring>

// Static data definitions
std::mutex IarmHdmiInput::s_mutex;
std::vector<device::HdmiInput::IEvent*> IarmHdmiInput::hdmiInListener;

constexpr IarmHdmiInput::EventHandlerMapping IarmHdmiInput::eventHandlers[] = {
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, IarmHdmiInput::OnHDMIInEventHotPlug },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, IarmHdmiInput::OnHDMIInEventSignalStatus },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, IarmHdmiInput::OnHDMIInEventStatus },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, IarmHdmiInput::OnHDMInVideoModeUpdate },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, IarmHdmiInput::OnHDMInAllmStatus },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, IarmHdmiInput::OnHDMInAVIContentType },
{ IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY, IarmHdmiInput::OnHDMInAVLatency },
{ IARM_BUS_DSMGR_EVENT_ZOOM_SETTINGS, IarmHdmiInput::OnHDMInVRRStatus },
{ IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, IarmHdmiInput::OnHDMIHotPlug }
};

const char* IarmHdmiInput::OWNER_NAME = IARM_BUS_DSMGR_NAME;

IarmHdmiInput::IarmHdmiInput() {}
IarmHdmiInput::~IarmHdmiInput() {}


uint32_t IarmHdmiInput::Register(device::HdmiInput::IEvent* listener) {
std::lock_guard<std::mutex> lock(s_mutex);

// First listener, register all handlers
if (hdmiInListener.empty()) {
for (auto& eh : eventHandlers) {
IARM_Bus_RegisterEventHandler(OWNER_NAME, eh.eventId, eh.handler);
}
}

// Add to listener list if not already present
if (std::find(hdmiInListener.begin(), hdmiInListener.end(), listener) == hdmiInListener.end()) {
hdmiInListener.push_back(listener);
}

return 0; // Success
}

// Unregister a listener and remove IARM handlers if last listener
uint32_t IarmHdmiInput::UnRegister(device::HdmiInput::IEvent* listener) {
std::lock_guard<std::mutex> lock(s_mutex);

auto it = std::remove(hdmiInListener.begin(), hdmiInListener.end(), listener);
if (it != hdmiInListener.end()) {
hdmiInListener.erase(it, hdmiInListener.end());
}

// If no more listeners, unregister all handlers
if (hdmiInListener.empty()) {
for (auto& eh : eventHandlers) {
IARM_Bus_UnRegisterEventHandler(OWNER_NAME, eh.eventId);
}
}

return 0; // Success
}



template<typename F>

void IarmHdmiInput::Dispatch(F&& fn) {
std::lock_guard<std::mutex> lock(s_mutex);
for (auto* listener : hdmiInListener) {
fn(listener);
}
}

// === Handlers Implementation ===

// Each handler receives the event and dispatches to all listeners
void IarmHdmiInput::OnHDMIInEventHotPlug(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
// Cast data to the expected struct
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t port = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_connect.port);
bool isConnected = eventData->data.hdmi_in_connect.isPortConnected;
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMIInEventHotPlug(port, isConnected); });
}

void IarmHdmiInput::OnHDMIInEventSignalStatus(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t port = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_sig_status.port);
dsHdmiInSignalStatus_t status = static_cast<dsHdmiInSignalStatus_t>(eventData->data.hdmi_in_sig_status.status);
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMIInEventSignalStatus(port, status); });
}

void IarmHdmiInput::OnHDMIInEventStatus(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t activePort = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_status.activePort);
bool isPresented = eventData->data.hdmi_in_status.isPresented;
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMIInEventStatus(activePort, isPresented); });
}

void IarmHdmiInput::OnHDMInVideoModeUpdate(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t port = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_videomode.port);
const dsVideoPortResolution_t& res = eventData->data.hdmi_in_videomode.resolution;
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMInVideoModeUpdate(port, res); });
}

void IarmHdmiInput::OnHDMInAllmStatus(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t port = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_allm.port);
bool status = eventData->data.hdmi_in_allm.status;
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMInAllmStatus(port, status); });
}

void IarmHdmiInput::OnHDMInAVIContentType(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsHdmiInPort_t port = static_cast<dsHdmiInPort_t>(eventData->data.hdmi_in_avi_ct.port);
dsAviContentType_t type = static_cast<dsAviContentType_t>(eventData->data.hdmi_in_avi_ct.avi_ct);
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMInAVIContentType(port, type); });
}

void IarmHdmiInput::OnHDMInAVLatency(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
int audioDelay = eventData->data.hdmi_in_av_latency.audio_latency;
int videoDelay = eventData->data.hdmi_in_av_latency.video_latency;
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnHDMInAVLatency(audioDelay, videoDelay); });
}

void IarmHdmiInput::OnHDMInVRRStatus(const char* owner, IARM_EventId_t eventId, void *data, size_t len) {
IARM_Bus_DSMgr_EventData_t* eventData = static_cast<IARM_Bus_DSMgr_EventData_t*>(data);
dsVideoZoom_t zoom = static_cast<dsVideoZoom_t>(eventData->data.zoomSettings.zoomSetting);
Dispatch([&](device::HdmiInput::IEvent* l) { l->OnZoomSettingsChanged(zoom); });
}

Loading
Loading