+ m_vendorId = CEC_VENDOR_LG;
+
+ /* LG devices don't always reply to CEC version requests, so just set it to 1.3a */
+ 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);
+}
+
+bool CSLCommandHandler::InitHandler(void)
+{
+ if (m_bHandlerInited)
+ return true;
+ m_bHandlerInited = true;
+
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary && primary->GetLogicalAddress() != CECDEVICE_UNREGISTERED)
+ {
+ /* imitate LG devices */
+ if (m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
+ primary->SetVendorId(CEC_VENDOR_LG);
+ primary->ReplaceHandler(false);
+ }
+
+ if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ /* start as 'in transition standby->on' */
+ primary->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
+ primary->TransmitPowerState(CECDEVICE_TV);
+
+ /* send the vendor id */
+ primary->TransmitVendorID(CECDEVICE_BROADCAST);
+ }
+ }
+
+ 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]);
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ bool bSendPowerOffState(iAddress != primary->GetCurrentPhysicalAddress() && primary->IsActiveSource());
+
+ CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iAddress);
+ if (device)
+ device->MarkAsActiveSource();
+ if (bSendPowerOffState)
+ {
+ {
+ CLockObject lock(m_SLMutex);
+ m_bActiveSourceSent = false;
+ }
+ primary->TransmitPowerState(CECDEVICE_TV);
+ }
+ }
+
+ return true;
+
+}
+
+bool CSLCommandHandler::HandleDeviceVendorId(const cec_command &command)
+{
+ SetVendorId(command);
+
+ if (!SLInitialised() && command.initiator == CECDEVICE_TV)
+ {
+ CCECBusDevice *destination = m_processor->GetDevice(command.destination);
+ if (destination && (destination->GetLogicalAddress() == CECDEVICE_BROADCAST || destination->IsHandledByLibCEC()))
+ {
+ cec_logical_address initiator = destination->GetLogicalAddress();
+ if (initiator == CECDEVICE_BROADCAST)
+ initiator = m_processor->GetPrimaryDevice()->GetLogicalAddress();
+
+ cec_command response;
+ cec_command::Format(response, initiator, command.initiator, CEC_OPCODE_FEATURE_ABORT);
+ return Transmit(response);
+ }
+ }
+ return true;