From: Lars Op den Kamp Date: Fri, 18 Nov 2011 22:09:45 +0000 (+0100) Subject: cec: attempt to imitate SL when connected to an LG tv X-Git-Tag: upstream/2.2.0~1^2~44^2~127 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=e54fd7d2a2bdb442b5913de9de213518198f92b6 cec: attempt to imitate SL when connected to an LG tv --- diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 144cfc9..181e6fc 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -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; +} diff --git a/src/lib/implementations/SLCommandHandler.h b/src/lib/implementations/SLCommandHandler.h index 76a9970..bc917dc 100644 --- a/src/lib/implementations/SLCommandHandler.h +++ b/src/lib/implementations/SLCommandHandler.h @@ -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); }; };