+ CCECCommandHandler(busDevice),
+ m_bAwaitingReceiveFailed(false),
+ m_bSLEnabled(false),
+ m_bPowerStateReset(false)
+{
+ m_vendorId = CEC_VENDOR_LG;
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
+ /* imitate LG devices */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ primary->SetVendorId(CEC_VENDOR_LG);
+ SetLGDeckStatus();
+
+ /* LG TVs don't always reply to CEC version requests, so just set it to 1.3a */
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ m_busDevice->SetCecVersion(CEC_VERSION_1_3A);
+
+ /* LG devices always return "korean" as language */
+ cec_menu_language lang;
+ lang.device = m_busDevice->GetLogicalAddress();
+ snprintf(lang.language, 4, "eng");
+ m_busDevice->SetMenuLanguage(lang);
+}
+
+
+void CSLCommandHandler::HandlePoll(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+{
+ CCECCommandHandler::HandlePoll(iInitiator, iDestination);
+ m_bAwaitingReceiveFailed = true;
+}
+
+bool CSLCommandHandler::HandleReceiveFailed(void)
+{
+ if (m_bAwaitingReceiveFailed)
+ {
+ m_bAwaitingReceiveFailed = false;
+ return false;
+ }
+
+ return true;
+}
+
+bool CSLCommandHandler::InitHandler(void)
+{
+ if (m_bHandlerInited)
+ return true;
+ m_bHandlerInited = true;
+
+ /* reply with LGs vendor id */
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ primary->TransmitVendorID(CECDEVICE_TV, false);
+
+ primary->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
+ return true;
+}
+
+bool CSLCommandHandler::ActivateSource(void)
+{
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ primary->SetActiveSource();
+ primary->TransmitActiveSource();
+ return true;
+}
+
+bool CSLCommandHandler::HandleActiveSource(const cec_command &command)
+{
+ if (command.parameters.size == 2)
+ {
+ uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
+ if (iAddress != m_busDevice->GetPhysicalAddress(false))
+ m_bSLEnabled = false;
+ return m_processor->SetActiveSource(iAddress);
+ }
+
+ return true;
+}
+
+bool CSLCommandHandler::HandleFeatureAbort(const cec_command &command)
+{
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary->GetPowerStatus(false) == CEC_POWER_STATUS_ON && !m_bPowerStateReset && !m_bSLEnabled)
+ {
+ m_bPowerStateReset = true;
+ primary->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
+ }
+
+ return CCECCommandHandler::HandleFeatureAbort(command);
+}
+
+bool CSLCommandHandler::HandleGivePhysicalAddress(const cec_command &command)