cec: fix simplink reconnect via the TV source selector (after vendor command 0x03)
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 6 Dec 2011 20:27:50 +0000 (21:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 6 Dec 2011 20:32:26 +0000 (21:32 +0100)
src/lib/CECProcessor.cpp
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/SLCommandHandler.h

index 84b9bafcbc451ba5e4881cd80f2e66107d5234bd..d995345c01df94c3f144d21bb4962a4a90404c68 100644 (file)
@@ -329,8 +329,7 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
     }
   }
 
-  bReturn = m_busDevices[CECDEVICE_TV]->PowerOn() &&
-      m_busDevices[addr]->TransmitActiveSource() &&
+  bReturn = m_busDevices[addr]->TransmitActiveSource() &&
       SetStreamPath(m_busDevices[addr]->GetPhysicalAddress(false));
 
   if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
index 7cf4399612f99c3b9a279869b7663a1413418e4c..f9892d8dab82299ef94fb6e2ccafde81151f666b 100644 (file)
@@ -43,7 +43,7 @@ using namespace CEC;
 #define SL_COMMAND_UNKNOWN_03           0x05
 
 #define SL_COMMAND_REQUEST_POWER_STATUS 0xa0
-#define SL_COMMAND_POWER_ON             0x0300
+#define SL_COMMAND_POWER_ON             0x03
 #define SL_COMMAND_CONNECT_REQUEST      0x04
 #define SL_COMMAND_CONNECT_ACCEPT       0x05
 
@@ -63,6 +63,12 @@ bool CSLCommandHandler::HandleVendorCommand(const cec_command &command)
     HandleVendorCommand01(command);
     return true;
   }
+  else if (command.parameters.size == 2 &&
+      command.parameters[0] == SL_COMMAND_POWER_ON)
+  {
+    HandleVendorCommand03(command);
+    return true;
+  }
   else if (command.parameters.size == 2 &&
       command.parameters[0] == SL_COMMAND_CONNECT_REQUEST)
   {
@@ -110,6 +116,23 @@ void CSLCommandHandler::HandleVendorCommand01(const cec_command &command)
     m_processor->m_busDevices[command.destination]->TransmitPowerState(command.initiator);
 }
 
+void CSLCommandHandler::HandleVendorCommand03(const cec_command &command)
+{
+  CCECBusDevice *device = m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary];
+  if (device)
+  {
+    device->SetPowerStatus(CEC_POWER_STATUS_ON);
+    device->TransmitPowerState(command.initiator);
+    device->TransmitPhysicalAddress();
+    TransmitPowerOn(device->GetLogicalAddress(), command.initiator);
+    if (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
+        device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
+    {
+      ((CCECPlaybackDevice *)device)->TransmitDeckStatus(command.initiator);
+    }
+  }
+}
+
 void CSLCommandHandler::HandleVendorCommand04(const cec_command &command)
 {
   cec_command response;
@@ -184,6 +207,7 @@ bool CSLCommandHandler::HandleCommand(const cec_command &command)
           m_bVendorIdSent = true;
           TransmitLGVendorId(m_processor->GetLogicalAddresses().primary, CECDEVICE_BROADCAST);
         }
+        m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary]->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
         m_bSLEnabled = false;
       }
       bHandled = true;
@@ -235,9 +259,6 @@ bool CSLCommandHandler::InitHandler(void)
 
   if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
   {
-    primary->TransmitVendorID(CECDEVICE_TV);
-    primary->TransmitPhysicalAddress();
-
     /* LG TVs don't always reply to CEC version requests, so just set it to 1.3a */
     m_busDevice->SetCecVersion(CEC_VERSION_1_3A);
   }
@@ -263,7 +284,6 @@ bool CSLCommandHandler::InitHandler(void)
                        device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
         {
           ((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
-          TransmitDeckStatus(CECDEVICE_TV);
         }
       }
     }
@@ -275,12 +295,13 @@ bool CSLCommandHandler::InitHandler(void)
 bool CSLCommandHandler::TransmitPowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
 {
   if (iDestination != CECDEVICE_BROADCAST &&
-      m_processor->m_busDevices[iDestination]->GetVendorId(false) == CEC_VENDOR_LG);
+      iDestination != CECDEVICE_TV &&
+      m_processor->m_busDevices[iDestination]->GetVendorId(false) == CEC_VENDOR_LG)
   {
     cec_command command;
     cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_VENDOR_COMMAND);
-    command.parameters.PushBack((uint8_t) (((uint16_t)SL_COMMAND_POWER_ON >> 8) & 0xFF));
-    command.parameters.PushBack((uint8_t) ((uint16_t)SL_COMMAND_POWER_ON & 0xFF));
+    command.parameters.PushBack((uint8_t)SL_COMMAND_POWER_ON);
+    command.parameters.PushBack(0x00);
     return Transmit(command);
   }
 
index b40c2ef37912570fd6c9c4286a127be560650140..6a91df4c1e7a6d1d62c4e8dd2ef20543141e342a 100644 (file)
@@ -51,6 +51,7 @@ namespace CEC
 
   protected:
     virtual void HandleVendorCommand01(const cec_command &command);
+    virtual void HandleVendorCommand03(const cec_command &command);
     virtual void HandleVendorCommand04(const cec_command &command);
     virtual void HandleVendorCommandA0(const cec_command &command);