cec: implemented power up for LG devices other than a TV
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 13 Feb 2012 17:07:24 +0000 (18:07 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 13 Feb 2012 17:41:01 +0000 (18:41 +0100)
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/SLCommandHandler.h

index ad65063ef1f8945dff985a03c701e715522d4309..14e39fcee3d11f54c8b67f48f1d0231f4c97a815 100644 (file)
@@ -56,6 +56,7 @@ namespace CEC
     virtual bool ActivateSource(void);
     virtual uint8_t GetTransmitRetries(void) const { return m_iTransmitRetries; }
 
+    virtual bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination) { return TransmitImageViewOn(iInitiator, iDestination); }
     virtual bool TransmitImageViewOn(const cec_logical_address iInitiator, const cec_logical_address iDestination);
     virtual bool TransmitStandby(const cec_logical_address iInitiator, const cec_logical_address iDestination);
     virtual bool TransmitRequestCecVersion(const cec_logical_address iInitiator, const cec_logical_address iDestination);
index 2ed05afcf2e8b816147b1cd4dbec0accb5fe55e6..83fc268e6fa1b95bf1b009d8f9b0d5a66a489f30 100644 (file)
@@ -80,9 +80,10 @@ bool CSLCommandHandler::InitHandler(void)
     return true;
   m_bHandlerInited = true;
 
-  CCECBusDevice *primary = m_processor->GetPrimaryDevice();
-  if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+  if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
   {
+    CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
     /* start as 'in transition standby->on' */
     primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
     primary->TransmitPowerState(CECDEVICE_TV);
@@ -134,7 +135,7 @@ bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command)
 {
   SetVendorId(command);
 
-  if (!SLInitialised())
+  if (!SLInitialised() && command.initiator == CECDEVICE_TV)
   {
     cec_command response;
     cec_command::Format(response, m_processor->GetLogicalAddress(), command.initiator, CEC_OPCODE_FEATURE_ABORT);
@@ -203,6 +204,9 @@ void CSLCommandHandler::TransmitVendorCommand0205(const cec_logical_address iSou
 
 void CSLCommandHandler::HandleVendorCommandPowerOn(const cec_command &command)
 {
+  if (command.initiator != CECDEVICE_TV)
+    return;
+
   CCECBusDevice *device = m_processor->GetPrimaryDevice();
   if (device)
   {
@@ -276,7 +280,7 @@ bool CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command)
 bool CSLCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
 {
   bool bReturn(false);
-  if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination))
+  if (m_processor->IsRunning() && m_busDevice->MyLogicalAddressContains(command.destination) && command.initiator == CECDEVICE_TV)
   {
     CCECBusDevice *device = GetDevice(command.destination);
     if (device && device->GetPowerStatus(false) != CEC_POWER_STATUS_ON)
@@ -328,7 +332,8 @@ bool CSLCommandHandler::HandleRequestActiveSource(const cec_command &command)
 
 bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command)
 {
-  if (command.parameters.size == 0 && m_processor->GetPrimaryDevice()->GetPowerStatus() == CEC_POWER_STATUS_ON && !SLInitialised())
+  if (command.parameters.size == 0 && m_processor->GetPrimaryDevice()->GetPowerStatus() == CEC_POWER_STATUS_ON && !SLInitialised() &&
+      command.initiator == CECDEVICE_TV)
   {
     m_processor->GetPrimaryDevice()->TransmitPowerState(command.initiator);
     m_processor->GetPrimaryDevice()->TransmitVendorID(CECDEVICE_BROADCAST, false);
@@ -372,3 +377,17 @@ bool CSLCommandHandler::ActiveSourceSent(void)
   CLockObject lock(m_SLMutex);
   return m_bActiveSourceSent;
 }
+
+bool CSLCommandHandler::PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+{
+  if (iDestination != CECDEVICE_TV)
+  {
+    cec_command command;
+    cec_command::Format(command, CECDEVICE_TV, iDestination, CEC_OPCODE_VENDOR_COMMAND);
+    command.PushBack(SL_COMMAND_POWER_ON);
+    command.PushBack(0);
+    return Transmit(command);
+  }
+
+  return CCECCommandHandler::PowerOn(iInitiator, iDestination);
+}
index 4ea6a05b24d5413d0c9b6bf8ea8af0e06f614be0..a0ea25a329cb3d49bc9716212ce0f8983b26908b 100644 (file)
@@ -66,6 +66,7 @@ namespace CEC
     virtual bool HandleFeatureAbort(const cec_command &command);
     virtual bool HandleStandby(const cec_command &command);
     virtual bool TransmitMenuState(const cec_logical_address UNUSED(iInitiator), const cec_logical_address UNUSED(iDestination), cec_menu_state UNUSED(menuState)) { return true; }
+    virtual bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination);
 
     virtual void ResetSLState(void);
     virtual bool SLInitialised(void);