cec: attempt to imitate SL when connected to an LG tv
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 18 Nov 2011 22:09:45 +0000 (23:09 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 18 Nov 2011 22:19:22 +0000 (23:19 +0100)
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/SLCommandHandler.h

index 144cfc92d933bd033f4d7ac79908f30eef03770e..181e6fcf02a1cc8ade153ba738e72034db9f0d0a 100644 (file)
@@ -31,6 +31,8 @@
  */
 
 #include "SLCommandHandler.h"
+#include "../devices/CECBusDevice.h"
+#include "../CECProcessor.h"
 
 using namespace CEC;
 
@@ -38,3 +40,51 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) :
     CCECCommandHandler(busDevice)
 {
 }
+
+bool CSLCommandHandler::HandleVendorCommand(const cec_command &command)
+{
+  if (command.parameters.size == 1 &&
+      command.parameters[0] == 0xA0)
+  {
+    /* enable SL */
+    cec_command response;
+    cec_command::Format(response, m_busDevice->GetLogicalAddress(), command.initiator, CEC_OPCODE_VENDOR_COMMAND);
+    response.PushBack(0x02);
+    response.PushBack(0x05);
+
+    return m_busDevice->GetProcessor()->Transmit(response);
+  }
+
+  return false;
+}
+
+bool CSLCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
+{
+  /* imitate LG devices */
+  CCECBusDevice *device = GetDevice(command.destination);
+  if (device)
+    device->SetVendorId(CEC_VENDOR_LG);
+
+  return CCECCommandHandler::HandleGiveDeviceVendorId(command);
+}
+
+bool CSLCommandHandler::HandleCommand(const cec_command &command)
+{
+  bool bHandled(false);
+  if (m_busDevice->MyLogicalAddressContains(command.destination))
+  {
+    switch(command.opcode)
+    {
+    case CEC_OPCODE_VENDOR_COMMAND:
+      bHandled = HandleVendorCommand(command);
+      break;
+    default:
+      break;
+    }
+  }
+
+  if (!bHandled)
+    bHandled = CCECCommandHandler::HandleCommand(command);
+
+  return bHandled;
+}
index 76a99701c0db91386a3492bb6bb2283b34e72e5b..bc917dccf4976b81e3d8290ccd0e0c4b8cc18251 100644 (file)
@@ -41,5 +41,11 @@ namespace CEC
     CSLCommandHandler(CCECBusDevice *busDevice);
     virtual ~CSLCommandHandler(void) {};
     virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_LG; };
+
+    virtual bool HandleCommand(const cec_command &command);
+
+  protected:
+    virtual bool HandleGiveDeviceVendorId(const cec_command &command);
+    virtual bool HandleVendorCommand(const cec_command &command);
   };
 };