From d1a2ed70eb2d1a535cbd9edf2903b1de3c83ee97 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Sun, 7 Oct 2012 14:20:23 +0200 Subject: [PATCH] rpi: current firmware first sends a change to logical address 'broadcast' and then signals us that the address was lost. libCEC then failed to re-register, because it didn't know any client at this address --- src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp | 8 +++++--- src/lib/adapter/RPi/RPiCECAdapterCommunication.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp index 5d13368..daaa72a 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp +++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp @@ -61,7 +61,8 @@ void rpi_cec_callback(void *callback_data, uint32_t p0, uint32_t p1, uint32_t p2 CRPiCECAdapterCommunication::CRPiCECAdapterCommunication(IAdapterCommunicationCallback *callback) : IAdapterCommunication(callback), m_logicalAddress(CECDEVICE_UNKNOWN), - m_bLogicalAddressChanged(false) + m_bLogicalAddressChanged(false), + m_previousLogicalAddress(CECDEVICE_FREEUSE) { m_queue = new CRPiCECAdapterMessageQueue(this); } @@ -174,6 +175,7 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u case VC_CEC_LOGICAL_ADDR: { CLockObject lock(m_mutex); + m_previousLogicalAddress = m_logicalAddress; if (CEC_CB_RC(header) == VCHIQ_SUCCESS) { m_bLogicalAddressChanged = true; @@ -182,7 +184,7 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u } else { - m_logicalAddress = CECDEVICE_BROADCAST; + m_logicalAddress = CECDEVICE_FREEUSE; LIB_CEC->AddLog(CEC_LOG_DEBUG, "failed to change the logical address, reset to %s (%x)", LIB_CEC->ToString(m_logicalAddress), m_logicalAddress); } m_logicalAddressCondition.Signal(); @@ -191,7 +193,7 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u case VC_CEC_LOGICAL_ADDR_LOST: { // the logical address was taken by another device - cec_logical_address previousAddress = m_logicalAddress; + cec_logical_address previousAddress = m_logicalAddress == CECDEVICE_BROADCAST ? m_previousLogicalAddress : m_logicalAddress; m_logicalAddress = CECDEVICE_UNKNOWN; // notify libCEC that we lost our LA when the connection was initialised diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h index 7400916..3cbbdde 100644 --- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h +++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h @@ -31,6 +31,7 @@ * http://www.pulse-eight.net/ */ +#include "env.h" #if defined(HAVE_RPI_API) #include "lib/adapter/AdapterCommunication.h" @@ -107,6 +108,7 @@ namespace CEC PLATFORM::CMutex m_mutex; VCHI_INSTANCE_T m_vchi_instance; VCHI_CONNECTION_T * m_vchi_connection; + cec_logical_address m_previousLogicalAddress; }; }; -- 2.34.1