From 50e2792889c9cd53093f23dcce5b56c5530245f9 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 12 Feb 2012 15:34:53 +0100 Subject: [PATCH] cec: fix loop when initialising LG --- src/lib/devices/CECPlaybackDevice.cpp | 2 +- src/lib/implementations/SLCommandHandler.cpp | 30 ++++++++++++++------ src/lib/implementations/SLCommandHandler.h | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/lib/devices/CECPlaybackDevice.cpp b/src/lib/devices/CECPlaybackDevice.cpp index 6f0a848..3e255bf 100644 --- a/src/lib/devices/CECPlaybackDevice.cpp +++ b/src/lib/devices/CECPlaybackDevice.cpp @@ -57,7 +57,7 @@ cec_deck_info CCECPlaybackDevice::GetDeckStatus(void) void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus) { CLockObject lock(m_mutex); - if (m_deckStatus != deckStatus && m_deckStatus != CEC_DECK_INFO_OTHER_STATUS_LG) + if (m_deckStatus != deckStatus) { CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckStatus), ToString(deckStatus)); m_deckStatus = deckStatus; diff --git a/src/lib/implementations/SLCommandHandler.cpp b/src/lib/implementations/SLCommandHandler.cpp index 0de151d..fef6a4a 100644 --- a/src/lib/implementations/SLCommandHandler.cpp +++ b/src/lib/implementations/SLCommandHandler.cpp @@ -57,7 +57,7 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) : /* imitate LG devices */ if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress()) primary->SetVendorId(CEC_VENDOR_LG); - SetLGDeckStatus(); + SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG); /* LG TVs don't always reply to CEC version requests, so just set it to 1.3a */ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV) @@ -196,7 +196,7 @@ void CSLCommandHandler::HandleVendorCommandPowerOn(const cec_command &command) device->TransmitPowerState(command.initiator); device->SetPowerStatus(CEC_POWER_STATUS_ON); - SetLGDeckStatus(); + SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG); device->SetActiveSource(); TransmitImageViewOn(device->GetLogicalAddress(), command.initiator); } @@ -215,12 +215,25 @@ void CSLCommandHandler::HandleVendorCommandPowerOnStatus(const cec_command &comm void CSLCommandHandler::HandleVendorCommandSLConnect(const cec_command &command) { m_bSLEnabled = true; - SetLGDeckStatus(); - CCECBusDevice *primary = m_processor->GetPrimaryDevice(); - primary->SetActiveSource(); TransmitVendorCommand05(primary->GetLogicalAddress(), command.initiator); + + CCECPlaybackDevice *playback = (primary->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) ? + (CCECPlaybackDevice *)primary : NULL; + if (playback) + { + SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS); + playback->TransmitDeckStatus(CECDEVICE_TV); + PLATFORM::CEvent::Sleep(2000); + } + + primary->SetActiveSource(); + primary->TransmitImageViewOn(); + + SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG); + if (playback) + playback->TransmitDeckStatus(CECDEVICE_TV); } void CSLCommandHandler::TransmitVendorCommand05(const cec_logical_address iSource, const cec_logical_address iDestination) @@ -232,14 +245,13 @@ void CSLCommandHandler::TransmitVendorCommand05(const cec_logical_address iSourc Transmit(response, false); } -void CSLCommandHandler::SetLGDeckStatus(void) +void CSLCommandHandler::SetDeckStatus(cec_deck_info deckStatus) { - /* LG TVs only route keypresses when the deck status is set to 0x20 */ CCECBusDevice *device = m_processor->GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); if (device) - ((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG); + ((CCECPlaybackDevice *)device)->SetDeckStatus(deckStatus); device = m_processor->GetDeviceByType(CEC_DEVICE_TYPE_RECORDING_DEVICE); if (device) - ((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG); + ((CCECPlaybackDevice *)device)->SetDeckStatus(deckStatus); } diff --git a/src/lib/implementations/SLCommandHandler.h b/src/lib/implementations/SLCommandHandler.h index 8b00696..55f1bea 100644 --- a/src/lib/implementations/SLCommandHandler.h +++ b/src/lib/implementations/SLCommandHandler.h @@ -60,7 +60,7 @@ namespace CEC virtual void HandleVendorCommandSLConnect(const cec_command &command); virtual void TransmitVendorCommand05(const cec_logical_address iSource, const cec_logical_address iDestination); - virtual void SetLGDeckStatus(void); + virtual void SetDeckStatus(cec_deck_info deckStatus); bool m_bSLEnabled; bool m_bPowerStateReset; -- 2.34.1