+ CCECCommandHandler(busDevice),
+ m_bActiveSourcePending(false),
+ m_bPowerUpEventReceived(false)
+{
+ m_vendorId = CEC_VENDOR_PANASONIC;
+
+ /* use the VL commandhandler for the primary device that is handled by libCEC */
+ if (busDevice->GetLogicalAddress() == CECDEVICE_TV)
+ {
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+ {
+ primary->SetVendorId(CEC_VENDOR_PANASONIC);
+ primary->ReplaceHandler(false);
+ }
+ }
+}
+
+bool CVLCommandHandler::InitHandler(void)
+{
+ CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+ if (primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
+ return m_processor->GetPrimaryClient()->ChangeDeviceType(CEC_DEVICE_TYPE_RECORDING_DEVICE, CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
+
+ return CCECCommandHandler::InitHandler();
+}
+
+bool CVLCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
+{
+ if (command.initiator == CECDEVICE_TV &&
+ command.destination == CECDEVICE_BROADCAST &&
+ command.parameters.At(3) == VL_POWER_CHANGE)
+ {
+ if (command.parameters.At(4) == VL_POWERED_UP)
+ {
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV powered up");
+ {
+ CLockObject lock(m_mutex);
+ m_bPowerUpEventReceived = true;
+ }
+ m_processor->TransmitPendingActiveSourceCommands();
+ }
+ else if (command.parameters.At(4) == VL_POWERED_DOWN)
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "TV powered down");
+ else if (command.parameters.At(4) == VL_POWERED_DOWN)
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "unknown vendor command");
+
+ return true;
+ }
+
+ return CCECCommandHandler::HandleDeviceVendorCommandWithId(command);
+}
+
+bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiator, uint16_t iPhysicalAddress)
+{
+ bool bPowerUpEventReceived(false);
+
+ CCECBusDevice *tv = m_processor->GetDevice(CECDEVICE_TV);
+ if (tv && tv->GetCurrentVendorId() == CEC_VENDOR_PANASONIC)
+ {
+ CVLCommandHandler *handler = static_cast<CVLCommandHandler *>(tv->GetHandler());
+ bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false;
+ }
+
+ if (!bPowerUpEventReceived)
+ {
+ CLockObject lock(m_mutex);
+ // wait until we received the event
+ m_bActiveSourcePending = true;
+ return true;
+ }
+ else
+ {
+ // transmit standard active source message
+ return CCECCommandHandler::TransmitActiveSource(iInitiator, iPhysicalAddress);
+ }
+}
+
+bool CVLCommandHandler::TransmitPendingActiveSourceCommands(void)