From 0d4c3a7b8260aa20bb5768164e90072a38edf7d2 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 6 Dec 2011 17:11:22 +0100 Subject: [PATCH] cec: fix power on of LG devices --- src/lib/implementations/SLCommandHandler.cpp | 38 +++++++++++++------- src/lib/implementations/SLCommandHandler.h | 1 + 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 6e4b92f..34f703a 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -38,13 +38,14 @@ using namespace CEC; -#define SL_COMMAND_UNKNOWN_01 0x01 -#define SL_COMMAND_UNKNOWN_02 0x02 -#define SL_COMMAND_UNKNOWN_03 0x05 +#define SL_COMMAND_UNKNOWN_01 0x01 +#define SL_COMMAND_UNKNOWN_02 0x02 +#define SL_COMMAND_UNKNOWN_03 0x05 -#define SL_COMMAND_REQUEST_VENDOR_ID 0xa0 -#define SL_COMMAND_CONNECT_REQUEST 0x04 -#define SL_COMMAND_CONNECT_ACCEPT 0x05 +#define SL_COMMAND_REQUEST_POWER_STATUS 0xa0 +#define SL_COMMAND_POWER_ON 0x0300 +#define SL_COMMAND_CONNECT_REQUEST 0x04 +#define SL_COMMAND_CONNECT_ACCEPT 0x05 CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) : CCECCommandHandler(busDevice), @@ -61,7 +62,7 @@ bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) { /* enable SL */ cec_command response; - cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND, m_iTransmitTimeout); + cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND); response.PushBack(SL_COMMAND_UNKNOWN_02); response.PushBack(SL_COMMAND_UNKNOWN_03); @@ -73,7 +74,7 @@ bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) { /* enable SL */ cec_command response; - cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND, m_iTransmitTimeout); + cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND); response.PushBack(SL_COMMAND_CONNECT_ACCEPT); response.PushBack((uint8_t)m_busDevice->GetProcessor()->GetLogicalAddresses().primary); Transmit(response); @@ -83,10 +84,10 @@ bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) return true; } else if (command.parameters.size == 1 && - command.parameters[0] == SL_COMMAND_REQUEST_VENDOR_ID) + command.parameters[0] == SL_COMMAND_REQUEST_POWER_STATUS) { -// if (command.destination != CECDEVICE_BROADCAST) -// m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetProcessor()->GetLogicalAddresses().primary]->TransmitPowerState(command.initiator); + if (command.destination != CECDEVICE_BROADCAST) + m_busDevice->GetProcessor()->m_busDevices[m_busDevice->GetProcessor()->GetLogicalAddresses().primary]->TransmitPowerState(command.initiator); return true; } @@ -107,7 +108,7 @@ void CSLCommandHandler::TransmitDeckStatus(const cec_logical_address iDestinatio bool CSLCommandHandler::TransmitLGVendorId(const cec_logical_address iInitiator, const cec_logical_address iDestination) { cec_command response; - cec_command::Format(response, iInitiator, iDestination, CEC_OPCODE_DEVICE_VENDOR_ID, m_iTransmitTimeout); + cec_command::Format(response, iInitiator, iDestination, CEC_OPCODE_DEVICE_VENDOR_ID); response.parameters.PushBack((uint8_t) (((uint64_t)CEC_VENDOR_LG >> 16) & 0xFF)); response.parameters.PushBack((uint8_t) (((uint64_t)CEC_VENDOR_LG >> 8) & 0xFF)); response.parameters.PushBack((uint8_t) ((uint64_t)CEC_VENDOR_LG & 0xFF)); @@ -216,7 +217,7 @@ bool CSLCommandHandler::InitHandler(void) primary->TransmitPhysicalAddress(); cec_command command; - cec_command::Format(command, m_busDevice->GetProcessor()->GetLogicalAddresses().primary, CECDEVICE_TV, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID, m_iTransmitTimeout); + cec_command::Format(command, m_busDevice->GetProcessor()->GetLogicalAddresses().primary, CECDEVICE_TV, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); Transmit(command); /* LG TVs don't always reply to CEC version requests, so just set it to 1.3a */ @@ -252,3 +253,14 @@ bool CSLCommandHandler::InitHandler(void) return true; } + + +bool CSLCommandHandler::TransmitPowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination) +{ + 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)); + + return Transmit(command); +} diff --git a/src/lib/implementations/SLCommandHandler.h b/src/lib/implementations/SLCommandHandler.h index 5c1130a..d020a14 100644 --- a/src/lib/implementations/SLCommandHandler.h +++ b/src/lib/implementations/SLCommandHandler.h @@ -47,6 +47,7 @@ namespace CEC virtual bool HandleReceiveFailed(void); virtual bool InitHandler(void); virtual bool TransmitLGVendorId(const cec_logical_address iInitiator, const cec_logical_address iDestination); + virtual bool TransmitPowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination); protected: virtual void TransmitDeckStatus(const cec_logical_address iDestination); -- 2.34.1