From: Lars Op den Kamp Date: Tue, 6 Dec 2011 23:16:53 +0000 (+0100) Subject: cec: and more LG hacks X-Git-Tag: upstream/2.2.0~1^2~44^2~27 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=fe6f8e370bff46ba50defc31698f369763c68455;p=deb_libcec.git cec: and more LG hacks --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index d995345..4df840d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -268,7 +268,9 @@ void *CCECProcessor::Process(void) } else { - m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress(); + m_busDevices[CECDEVICE_TV]->GetVendorId(); + m_busDevices[m_logicalAddresses.primary]->TransmitVendorID(CECDEVICE_TV, false); + CLockObject lock(&m_mutex); m_bStarted = true; m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started"); @@ -353,11 +355,6 @@ void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout) m_iRetryLineTimeout = iTimeout; } -bool CCECProcessor::SetActiveSource(cec_logical_address iAddress) -{ - return SetStreamPath(m_busDevices[iAddress]->GetPhysicalAddress(false)); -} - bool CCECProcessor::SetActiveView(void) { return SetActiveSource(m_types.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED : m_types[0]); @@ -524,7 +521,10 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) { for (uint8_t iPtr = 0; iPtr < 15; iPtr++) if (m_logicalAddresses[iPtr]) + { m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); + m_busDevices[iPtr]->TransmitPhysicalAddress(); + } return SetActiveView(); } return false; @@ -540,7 +540,7 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable) CLockObject lock(&m_mutex); m_bMonitor = bEnable; - if (bEnable) + if (!bEnable) { if (!m_busScan) { @@ -1297,9 +1297,15 @@ const char *CCECProcessor::ToString(const cec_vendor_id vendor) void *CCECBusScan::Process(void) { CCECBusDevice *device(NULL); + uint8_t iCounter(0); while (!IsStopped()) { + if (++iCounter < 30) + { + Sleep(1000); + continue; + } for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++) { device = m_processor->m_busDevices[iPtr]; diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 24dd5b1..6d775f5 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -77,7 +77,6 @@ namespace CEC virtual bool SetActiveView(void); virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED); - virtual bool SetActiveSource(cec_logical_address iAddress); virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true); virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true); virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce = false); diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 4c25e61..1793cc4 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -118,19 +118,20 @@ bool CCECBusDevice::PowerOn(void) { { CLockObject lock(&m_mutex); - m_powerStatus = CEC_POWER_STATUS_UNKNOWN; - } - cec_power_status status = GetPowerStatus(); - if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN) - { - /* sending the normal power on command appears to have failed */ - CStdString strLog; - strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); - AddLog(CEC_LOG_DEBUG, strLog.c_str()); - - TransmitKeypress(CEC_USER_CONTROL_CODE_POWER); - return TransmitKeyRelease(); +// m_powerStatus = CEC_POWER_STATUS_UNKNOWN; + m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; } +// cec_power_status status = GetPowerStatus(); +// if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN) +// { +// /* sending the normal power on command appears to have failed */ +// CStdString strLog; +// strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); +// AddLog(CEC_LOG_DEBUG, strLog.c_str()); +// +// TransmitKeypress(CEC_USER_CONTROL_CODE_POWER); +// return TransmitKeyRelease(); +// } return true; } @@ -749,7 +750,7 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest) return m_handler->TransmitPowerState(m_iLogicalAddress, dest, state); } -bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) +bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort /* = true */) { uint64_t iVendorId; { @@ -759,11 +760,14 @@ bool CCECBusDevice::TransmitVendorID(cec_logical_address dest) if (iVendorId == CEC_VENDOR_UNKNOWN) { - CStdString strLog; - strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); - AddLog(CEC_LOG_NOTICE, strLog); + if (bSendAbort) + { + CStdString strLog; + strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest); + AddLog(CEC_LOG_NOTICE, strLog); - m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID); + } return false; } else diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 6806df0..80576b4 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -39,10 +39,12 @@ namespace CEC { class CCECProcessor; class CCECCommandHandler; + class CSLCommandHandler; class CCECBusDevice { friend class CCECProcessor; + friend class CSLCommandHandler; public: CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0); @@ -94,7 +96,7 @@ namespace CEC virtual bool TransmitPhysicalAddress(void); virtual bool TransmitPowerState(cec_logical_address dest); virtual bool TransmitPoll(cec_logical_address dest); - virtual bool TransmitVendorID(cec_logical_address dest); + virtual bool TransmitVendorID(cec_logical_address dest, bool bSendAbort = true); virtual bool TransmitKeypress(cec_user_control_code key); virtual bool TransmitKeyRelease(void); diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 2fe0308..c58a606 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -319,7 +319,7 @@ bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &comm bool CCECCommandHandler::HandleImageViewOn(const cec_command &command) { - m_processor->SetActiveSource(command.initiator); + m_processor->SetStreamPath(m_processor->m_busDevices[command.initiator]->GetPhysicalAddress(false)); return true; } @@ -491,7 +491,7 @@ bool CCECCommandHandler::HandleSystemAudioModeRequest(const cec_command &command uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); CCECBusDevice *newActiveDevice = GetDeviceByPhysicalAddress(iNewAddress); if (newActiveDevice) - m_processor->SetActiveSource(newActiveDevice->GetLogicalAddress()); + m_processor->SetStreamPath(newActiveDevice->GetPhysicalAddress(false)); return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator); } else @@ -545,7 +545,7 @@ bool CCECCommandHandler::HandleSetSystemAudioMode(const cec_command &command) bool CCECCommandHandler::HandleTextViewOn(const cec_command &command) { - m_processor->SetActiveSource(command.initiator); + m_processor->SetStreamPath(m_processor->m_busDevices[command.initiator]->GetPhysicalAddress(false)); return true; } diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index f9892d8..b1f1644 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -53,6 +53,7 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) : m_bSLEnabled(false), m_bVendorIdSent(false) { + m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary]->m_powerStatus = CEC_POWER_STATUS_STANDBY; } bool CSLCommandHandler::HandleVendorCommand(const cec_command &command) @@ -103,17 +104,28 @@ bool CSLCommandHandler::HandleGiveDeckStatus(const cec_command &command) } void CSLCommandHandler::HandleVendorCommand01(const cec_command &command) +{ + TransmitVendorCommand0205(command.destination, command.initiator); +} + +void CSLCommandHandler::TransmitVendorCommand0205(const cec_logical_address iSource, const cec_logical_address iDestination) { cec_command response; - cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND); + cec_command::Format(response, iSource, iDestination, CEC_OPCODE_VENDOR_COMMAND); response.PushBack(SL_COMMAND_UNKNOWN_02); response.PushBack(SL_COMMAND_UNKNOWN_03); Transmit(response); +} - /* transmit power status */ - if (command.destination != CECDEVICE_BROADCAST) - m_processor->m_busDevices[command.destination]->TransmitPowerState(command.initiator); +void CSLCommandHandler::TransmitVendorCommand04(const cec_logical_address iSource, const cec_logical_address iDestination) +{ + m_bSLEnabled = true; + cec_command response; + cec_command::Format(response, iSource, iDestination, CEC_OPCODE_VENDOR_COMMAND); + response.PushBack(SL_COMMAND_CONNECT_ACCEPT); + response.PushBack((uint8_t)iSource); + Transmit(response); } void CSLCommandHandler::HandleVendorCommand03(const cec_command &command) @@ -121,26 +133,18 @@ 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); + m_bSLEnabled = true; + device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); device->TransmitPowerState(command.initiator); - device->TransmitPhysicalAddress(); + device->TransmitVendorID(command.initiator); 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; - cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND); - response.PushBack(SL_COMMAND_CONNECT_ACCEPT); - response.PushBack((uint8_t)m_processor->GetLogicalAddresses().primary); - Transmit(response); - + m_bSLEnabled = true; + TransmitVendorCommand04(command.destination, command.initiator); TransmitDeckStatus(command.initiator); } @@ -192,8 +196,8 @@ bool CSLCommandHandler::HandleCommand(const cec_command &command) { bool bHandled(false); - if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination) || - command.destination == CECDEVICE_BROADCAST) + if (m_processor->IsStarted() && (m_busDevice->MyLogicalAddressContains(command.destination) || + command.destination == CECDEVICE_BROADCAST)) { switch(command.opcode) { @@ -207,8 +211,6 @@ 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; default: @@ -241,10 +243,6 @@ bool CSLCommandHandler::HandleReceiveFailed(void) bool CSLCommandHandler::InitHandler(void) { - if (m_bSLEnabled) - return true; - m_bSLEnabled = true; - m_processor->SetStandardLineTimeout(3); m_processor->SetRetryLineTimeout(3); @@ -271,7 +269,8 @@ bool CSLCommandHandler::InitHandler(void) if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) { - m_processor->SetActiveSource(m_processor->GetLogicalAddresses().primary); + m_processor->SetActiveSource(); + /* LG TVs only route keypresses when the deck status is set to 0x20 */ cec_logical_addresses addr = m_processor->GetLogicalAddresses(); for (uint8_t iPtr = 0; iPtr < 15; iPtr++) @@ -307,3 +306,4 @@ bool CSLCommandHandler::TransmitPowerOn(const cec_logical_address iInitiator, co return CCECCommandHandler::TransmitPowerOn(iInitiator, iDestination); } + diff --git a/src/lib/implementations/SLCommandHandler.h b/src/lib/implementations/SLCommandHandler.h index 6a91df4..d00f2cd 100644 --- a/src/lib/implementations/SLCommandHandler.h +++ b/src/lib/implementations/SLCommandHandler.h @@ -55,6 +55,8 @@ namespace CEC virtual void HandleVendorCommand04(const cec_command &command); virtual void HandleVendorCommandA0(const cec_command &command); + virtual void TransmitVendorCommand0205(const cec_logical_address iSource, const cec_logical_address iDestination); + virtual void TransmitVendorCommand04(const cec_logical_address iSource, const cec_logical_address iDestination); virtual void TransmitDeckStatus(const cec_logical_address iDestination); virtual bool HandleGiveDeviceVendorId(const cec_command &command); virtual bool HandleVendorCommand(const cec_command &command);