+
+bool CSLCommandHandler::InitHandler(void)
+{
+ if (m_bHandlerInited)
+ return true;
+ m_bHandlerInited = true;
+
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+
+ /* imitate LG devices */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ primary->SetVendorId(CEC_VENDOR_LG, false);
+
+ /* 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);
+
+ /* reply with LGs vendor id */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ primary->TransmitVendorID(CECDEVICE_TV, false);
+
+ return true;
+}
+
+bool CSLCommandHandler::TransmitPowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination)
+{
+ if (iDestination != CECDEVICE_BROADCAST &&
+ iDestination != CECDEVICE_TV &&
+ m_processor->m_busDevices[iDestination]->GetVendorId(false) == CEC_VENDOR_LG)
+ {
+ cec_command command;
+ cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_VENDOR_COMMAND);
+ command.parameters.PushBack((uint8_t)SL_COMMAND_POWER_ON);
+ command.parameters.PushBack(0x00);
+ return Transmit(command, false);
+ }
+
+ return CCECCommandHandler::TransmitImageViewOn(iInitiator, iDestination);
+}
+
+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 == 0)
+ return m_processor->GetPrimaryDevice()->TransmitPhysicalAddress();
+ else
+ return m_processor->SetActiveSource(iAddress);
+ }
+
+ return true;
+}