From: Lars Op den Kamp Date: Mon, 12 Nov 2012 15:04:12 +0000 (+0100) Subject: mark the adapter as (in)active source for firmware v3+ X-Git-Tag: upstream/2.2.0~1^2~12^2~33 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a582c2bb93a3f186e083efb12ff54d143aa7d920;p=deb_libcec.git mark the adapter as (in)active source for firmware v3+ --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 73c921d..6b93b3d 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -260,6 +260,12 @@ bool CCECProcessor::ActivateSource(uint16_t iStreamPath) return bReturn; } +void CCECProcessor::SetActiveSource(bool bSetTo, bool bClientUnregistered) +{ + if (m_communication) + m_communication->SetActiveSource(bSetTo, bClientUnregistered); +} + void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout) { CLockObject lock(m_mutex); @@ -863,7 +869,7 @@ bool CCECProcessor::UnregisterClient(CCECClient *client) m_clients.erase(entry); // reset the device status - (*it)->ResetDeviceStatus(); + (*it)->ResetDeviceStatus(true); } } diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 5593a2c..69586a7 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -110,6 +110,7 @@ namespace CEC bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true); bool ActivateSource(uint16_t iStreamPath); + void SetActiveSource(bool bSetTo, bool bClientUnregistered); bool PollDevice(cec_logical_address iAddress); void SetStandardLineTimeout(uint8_t iTimeout); uint8_t GetStandardLineTimeout(void); diff --git a/src/lib/adapter/AdapterCommunication.h b/src/lib/adapter/AdapterCommunication.h index 7dd56b7..b1762b7 100644 --- a/src/lib/adapter/AdapterCommunication.h +++ b/src/lib/adapter/AdapterCommunication.h @@ -221,6 +221,13 @@ namespace CEC */ virtual uint16_t GetAdapterProductId(void) const = 0; + /*! + * @brief Marks the adapter as active or inactive source + * @param bSetTo True to mark as active source, false to mark as inactive source + * @param bClientUnregistered True when the client was unregistered, false when the device was explicitly marked as (in)active source + */ + virtual void SetActiveSource(bool bSetTo, bool bClientUnregistered) = 0; + IAdapterCommunicationCallback *m_callback; }; }; diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp index 9448068..b037e1c 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp @@ -592,6 +592,19 @@ bool CUSBCECAdapterCommands::SetAckMask(uint16_t iMask) return bReturn; } +void CUSBCECAdapterCommands::SetActiveSource(bool bSetTo, bool bClientUnregistered) +{ + if (bClientUnregistered) return; + if (m_persistedConfiguration.iFirmwareVersion >= 3) + { + LIB_CEC->AddLog(CEC_LOG_DEBUG, "marking the adapter as %s source", bSetTo ? "active" : "inactive"); + CCECAdapterMessage params; + params.PushEscaped(bSetTo ? 1 : 0); + CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_ACTIVE_SOURCE, params); + delete message; + } +} + bool CUSBCECAdapterCommands::StartBootloader(void) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "starting the bootloader"); diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h index fa7f543..e0bfb1f 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.h @@ -131,6 +131,8 @@ namespace CEC */ bool WriteEEPROM(void); + void SetActiveSource(bool bSetTo, bool bClientUnregistered); + private: /*! * @brief Reads all settings from the eeprom. diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp index 9c6743f..ae40458 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.cpp @@ -628,6 +628,12 @@ uint16_t CUSBCECAdapterCommunication::GetAdapterProductId(void) const return iBuildDate >= CEC_FW_DATE_DESCRIPTOR2 ? CEC_PID2 : CEC_PID; } +void CUSBCECAdapterCommunication::SetActiveSource(bool bSetTo, bool bClientUnregistered) +{ + if (m_commands) + m_commands->SetActiveSource(bSetTo, bClientUnregistered); +} + bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void) { return GetFirmwareBuildDate() >= CEC_LATEST_ADAPTER_FW_DATE && diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.h b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.h index 04199e2..0c473ea 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.h +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommunication.h @@ -90,6 +90,7 @@ namespace CEC cec_adapter_type GetAdapterType(void); uint16_t GetAdapterVendorId(void) const; uint16_t GetAdapterProductId(void) const; + void SetActiveSource(bool bSetTo, bool bClientUnregistered); ///} bool ProvidesExtendedResponse(void); diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h index 89005e8..ec45bb9 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h @@ -78,6 +78,8 @@ namespace CEC MSGCODE_SET_OSD_NAME, MSGCODE_WRITE_EEPROM, MSGCODE_GET_ADAPTER_TYPE, + MSGCODE_SET_ACTIVE_SOURCE, + MSGCODE_FRAME_EOM = 0x80, MSGCODE_FRAME_ACK = 0x40, } cec_adapter_messagecode; diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp index 9fca017..4e4c2cb 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp @@ -164,7 +164,8 @@ bool CCECAdapterMessageQueueEntry::IsResponse(const CCECAdapterMessage &msg) thisMsgCode == MSGCODE_SET_HDMI_VERSION || thisMsgCode == MSGCODE_SET_OSD_NAME || thisMsgCode == MSGCODE_WRITE_EEPROM || - thisMsgCode == MSGCODE_TRANSMIT_IDLETIME) + thisMsgCode == MSGCODE_TRANSMIT_IDLETIME || + thisMsgCode == MSGCODE_SET_ACTIVE_SOURCE) return thisMsgCode == msgResponse; if (!m_message->IsTranmission()) diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h index 3cbbdde..92b7157 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h +++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h @@ -85,6 +85,7 @@ namespace CEC cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_RPI; }; uint16_t GetAdapterVendorId(void) const { return RPI_ADAPTER_VID; } uint16_t GetAdapterProductId(void) const { return RPI_ADAPTER_PID; } + void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) {} ///} bool IsInitialised(void); diff --git a/src/lib/adapter/TDA995x/TDA995xCECAdapterCommunication.h b/src/lib/adapter/TDA995x/TDA995xCECAdapterCommunication.h index 9476383..2adc1f8 100644 --- a/src/lib/adapter/TDA995x/TDA995xCECAdapterCommunication.h +++ b/src/lib/adapter/TDA995x/TDA995xCECAdapterCommunication.h @@ -89,6 +89,7 @@ namespace CEC uint16_t GetAdapterVendorId(void) const { return TDA995X_ADAPTER_VID; } uint16_t GetAdapterProductId(void) const { return TDA995X_ADAPTER_PID; } void HandleLogicalAddressLost(cec_logical_address oldAddress); + void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) {} ///} /** @name PLATFORM::CThread implementation */ diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 1176089..3be7adf 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -793,7 +793,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_v if (m_deviceStatus != newStatus) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'not present'", GetLogicalAddressName(), m_iLogicalAddress); - ResetDeviceStatus(); + ResetDeviceStatus(true); m_deviceStatus = newStatus; } break; @@ -804,7 +804,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_v } } -void CCECBusDevice::ResetDeviceStatus(void) +void CCECBusDevice::ResetDeviceStatus(bool bClientUnregistered /* = false */) { CLockObject lock(m_mutex); SetPowerStatus (CEC_POWER_STATUS_UNKNOWN); @@ -813,7 +813,7 @@ void CCECBusDevice::ResetDeviceStatus(void) SetCecVersion (CEC_VERSION_UNKNOWN); SetStreamPath (CEC_INVALID_PHYSICAL_ADDRESS); SetOSDName (ToString(m_iLogicalAddress)); - MarkAsInactiveSource(); + MarkAsInactiveSource(bClientUnregistered); m_iLastActive = 0; m_bVendorIdRequested = false; @@ -966,13 +966,14 @@ void CCECBusDevice::MarkAsActiveSource(void) if (bWasActivated) { + m_processor->SetActiveSource(true, false); CCECClient *client = GetClient(); if (client) client->SourceActivated(m_iLogicalAddress); } } -void CCECBusDevice::MarkAsInactiveSource(void) +void CCECBusDevice::MarkAsInactiveSource(bool bClientUnregistered /* = false */) { bool bWasDeactivated(false); { @@ -987,6 +988,7 @@ void CCECBusDevice::MarkAsInactiveSource(void) if (bWasDeactivated) { + m_processor->SetActiveSource(false, bClientUnregistered); CCECClient *client = GetClient(); if (client) client->SourceDeactivated(m_iLogicalAddress); diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index 6cba39f..1abf488 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -205,7 +205,7 @@ namespace CEC virtual cec_bus_device_status GetCurrentStatus(void) { return GetStatus(false, true); } virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false); virtual void SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion = CEC_VERSION_1_4); - virtual void ResetDeviceStatus(void); + virtual void ResetDeviceStatus(bool bClientUnregistered = false); virtual bool TransmitPoll(const cec_logical_address destination, bool bUpdateDeviceStatus); virtual void HandlePoll(const cec_logical_address destination); virtual void HandlePollFrom(const cec_logical_address initiator); @@ -219,7 +219,7 @@ namespace CEC virtual bool IsActiveSource(void) const { return m_bActiveSource; } virtual bool RequestActiveSource(bool bWaitForResponse = true); virtual void MarkAsActiveSource(void); - virtual void MarkAsInactiveSource(void); + virtual void MarkAsInactiveSource(bool bClientUnregistered = false); virtual bool TransmitActiveSource(bool bIsReply); virtual bool TransmitImageViewOn(void); virtual bool TransmitInactiveSource(void);