rpi: current firmware first sends a change to logical address 'broadcast' and then...
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 7 Oct 2012 12:20:23 +0000 (14:20 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 7 Oct 2012 12:20:23 +0000 (14:20 +0200)
src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp
src/lib/adapter/RPi/RPiCECAdapterCommunication.h

index 5d13368e50a3c569667ab0b812ed3d824b534c50..daaa72ab17d96eda8c3184c142fa921f05f3de70 100644 (file)
@@ -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
index 740091611b12277b02fd17ba46897b0949fe0560..3cbbdde6551e612870dfbfc153049ec02c3a51a7 100644 (file)
@@ -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;
   };
 };