Skip to content

Commit 5b1743f

Browse files
committed
CEC source and sink changes
1 parent 7268514 commit 5b1743f

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

HdmiCecSink/HdmiCecSink.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,11 @@ namespace WPEFramework
753753

754754
int err;
755755
dsHdmiInGetNumberOfInputsParam_t hdmiInput;
756+
#ifdef IO_HCEC_ENABLE_IARM
756757
InitializeIARM();
758+
#else
759+
device::Host::getInstance().Register(this, "WPE[HdmiCecSink]");
760+
#endif /* IO_HCEC_ENABLE_IARM */
757761
m_sendKeyEventThreadExit = false;
758762
m_sendKeyEventThread = std::thread(threadSendKeyEvent);
759763

@@ -879,7 +883,12 @@ namespace WPEFramework
879883
}
880884

881885
HdmiCecSink::_instance = nullptr;
882-
DeinitializeIARM();
886+
#ifdef IO_HCEC_ENABLE_IARM
887+
DeinitializeIARM();
888+
#else
889+
device::Host::getInstance().UnRegister(this);
890+
#endif /* IO_HCEC_ENABLE_IARM */
891+
883892
LOGWARN(" HdmiCecSink Deinitialize() Done");
884893
}
885894

@@ -920,6 +929,7 @@ namespace WPEFramework
920929
}
921930
}
922931

932+
#ifdef IO_HCEC_ENABLE_IARM
923933
void HdmiCecSink::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
924934
{
925935
if(!HdmiCecSink::_instance)
@@ -934,6 +944,16 @@ namespace WPEFramework
934944
HdmiCecSink::_instance->onHdmiHotPlug(portId,isHdmiConnected);
935945
}
936946
}
947+
#else
948+
void HdmiCecSink::OnHdmiInEventHotPlug(dsHdmiInPort_t port, bool isConnected)
949+
{
950+
if(!HdmiCecSink::_instance)
951+
return;
952+
953+
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG event port: %d isConnected: %d \r\n", port, isConnected);
954+
HdmiCecSink::_instance->onHdmiHotPlug((int) port, (int) isConnected);
955+
}
956+
#endif /* IO_HCEC_ENABLE_IARM */
937957

938958
void HdmiCecSink::onPowerModeChanged(const PowerState currentState, const PowerState newState)
939959
{

HdmiCecSink/HdmiCecSink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ namespace WPEFramework {
482482
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
483483
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
484484
// will receive a JSONRPC message as a notification, in case this method is called.
485-
class HdmiCecSink : public PluginHost::IPlugin, public PluginHost::JSONRPC {
485+
class HdmiCecSink : public PluginHost::IPlugin, public PluginHost::JSONRPC, device::Host::IHdmiInEvents {
486486

487487
enum {
488488
POLL_THREAD_STATE_NONE,
@@ -530,6 +530,7 @@ namespace WPEFramework {
530530
virtual const string Initialize(PluginHost::IShell* shell) override;
531531
virtual void Deinitialize(PluginHost::IShell* service) override;
532532
virtual string Information() const override { return {}; }
533+
virtual void OnHdmiInEventHotPlug(dsHdmiInPort_t port, bool isConnected) override;
533534
static HdmiCecSink* _instance;
534535
CECDeviceParams deviceList[16];
535536
std::vector<HdmiPortMap> hdmiInputs;

HdmiCecSource/HdmiCecSourceImplementation.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,12 @@ namespace WPEFramework
390390
}
391391
_registeredEventHandlers = false;
392392

393+
#ifdef IO_HCEC_ENABLE_IARM
393394
DeinitializeIARM();
395+
#else
396+
device::Host::getInstance().UnRegister(this);
397+
#endif /* IO_HCEC_ENABLE_IARM */
398+
394399
}
395400

396401
Core::hresult HdmiCecSourceImplementation::Configure(PluginHost::IShell* service)
@@ -409,7 +414,9 @@ namespace WPEFramework
409414
logicalAddress = 0xFF;
410415

411416
//CEC plugin functionalities will only work if CECmgr is available. If plugin Initialize failure upper layer will call dtor directly.
417+
#ifdef IO_HCEC_ENABLE_IARM
412418
InitializeIARM();
419+
#endif /* IO_HCEC_ENABLE_IARM */
413420
InitializePowerManager(service);
414421

415422
// load persistence setting
@@ -418,6 +425,11 @@ namespace WPEFramework
418425
{
419426
//TODO(MROLLINS) this is probably per process so we either need to be running in our own process or be carefull no other plugin is calling it
420427
device::Manager::Initialize();
428+
429+
#ifndef IO_HCEC_ENABLE_IARM
430+
device::Host::getInstance().Register(this, "WPE[HdmiCecSource]");
431+
#endif /* IO_HCEC_ENABLE_IARM */
432+
421433
std::string strVideoPort = device::Host::getInstance().getDefaultVideoPortName();
422434
device::VideoOutputPort vPort = device::Host::getInstance().getVideoOutputPort(strVideoPort.c_str());
423435
if (vPort.isDisplayConnected())
@@ -759,6 +771,7 @@ namespace WPEFramework
759771
LOGINFO("Exit threadHotPlugEventHandler \r\n");
760772
}
761773

774+
#ifdef IO_HCEC_ENABLE_IARM
762775
void HdmiCecSourceImplementation::dsHdmiEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
763776
{
764777
if(!HdmiCecSourceImplementation::_instance || !_instance->cecEnableStatus)
@@ -779,7 +792,24 @@ namespace WPEFramework
779792
}
780793
}
781794
}
795+
#else
796+
void HdmiCecSourceImplementation::OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent)
797+
{
798+
LOGINFO("OnDisplayHDMIHotPlug : displayEvent = %d ", displayEvent);
782799

800+
if(!HdmiCecSourceImplementation::_instance || !_instance->cecEnableStatus)
801+
{
802+
LOGINFO("Return from dsHdmiEventHandler due HdmiCecSourceImplementation::_instance:%p cecEnableStatus:%d \r\n", HdmiCecSourceImplementation::_instance, _instance->cecEnableStatus);
803+
return;
804+
}
805+
806+
int hdmi_hotplug_event = (int) displayEvent;
807+
LOGINFO("Received IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG event data:%d \r\n", hdmi_hotplug_event);
808+
std::thread worker(threadHotPlugEventHandler,hdmi_hotplug_event);
809+
worker.detach();
810+
811+
}
812+
#endif /* IO_HCEC_ENABLE_IARM */
783813
void HdmiCecSourceImplementation::onPowerModeChanged(const PowerState currentState, const PowerState newState)
784814
{
785815
if(!HdmiCecSourceImplementation::_instance)

HdmiCecSource/HdmiCecSourceImplementation.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include <interfaces/IPowerManager.h>
4343
#include "PowerManagerInterface.h"
4444
#include <interfaces/IHdmiCecSource.h>
45+
#include "host.hpp"
46+
4547

4648
using namespace WPEFramework;
4749
using PowerState = WPEFramework::Exchange::IPowerManager::PowerState;
@@ -170,7 +172,7 @@ namespace WPEFramework {
170172
// As the registration/unregistration of notifications is realized by the class PluginHost::JSONRPC,
171173
// this class exposes a public method called, Notify(), using this methods, all subscribed clients
172174
// will receive a JSONRPC message as a notification, in case this method is called.
173-
class HdmiCecSourceImplementation : public Exchange::IHdmiCecSource {
175+
class HdmiCecSourceImplementation : public Exchange::IHdmiCecSource, device::Host::IDisplayDeviceEvents {
174176
enum {
175177
VOLUME_UP = 0x41,
176178
VOLUME_DOWN = 0x42,
@@ -196,6 +198,7 @@ namespace WPEFramework {
196198
public:
197199
HdmiCecSourceImplementation();
198200
virtual ~HdmiCecSourceImplementation();
201+
virtual void OnDisplayHDMIHotPlug(dsDisplayEvent_t displayEvent) override;
199202
void onPowerModeChanged(const PowerState currentState, const PowerState newState);
200203
void registerEventHandlers();
201204
static HdmiCecSourceImplementation* _instance;

0 commit comments

Comments
 (0)