RPI updates with fixes
[deb_libcec.git] / src / lib / adapter / RPi / RPiCECAdapterCommunication.h
index c874451227ccd0ab503f3a735341995b91027765..e6a644645ec210fa6b3633a0ec4b2e4d7aef0a2a 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * This file is part of the libCEC(R) library.
  *
- * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited.  All rights reserved.
+ * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited.  All rights reserved.
  * libCEC(R) is an original work, containing original code.
  *
  * libCEC(R) is a trademark of Pulse-Eight Limited.
  *     http://www.pulse-eight.net/
  */
 
+#include "env.h"
 #if defined(HAVE_RPI_API)
 
 #include "lib/adapter/AdapterCommunication.h"
 #include "lib/platform/threads/threads.h"
 
+#define RPI_ADAPTER_VID 0x2708
+#define RPI_ADAPTER_PID 0x1001
+
 extern "C" {
 #include <interface/vmcs_host/vc_cecservice.h>
 #include <interface/vchiq_arm/vchiq_if.h>
@@ -44,22 +48,9 @@ extern "C" {
 namespace CEC
 {
   class CRPiCECAdapterMessageQueue;
-  class CRPiCECAdapterCommunication;
-
-  class CRPiCECAdapterFindNewLogicalAddress : public PLATFORM::CThread
-  {
-  public:
-    CRPiCECAdapterFindNewLogicalAddress(CRPiCECAdapterCommunication* communication, const cec_logical_address address);
-    void *Process(void);
-  private:
-    CRPiCECAdapterCommunication* m_communication;
-    cec_logical_address          m_address;
-  };
 
   class CRPiCECAdapterCommunication : public IAdapterCommunication
   {
-    friend class CRPiCECAdapterFindNewLogicalAddress;
-
   public:
     /*!
      * @brief Create a new USB-CEC communication handler.
@@ -92,17 +83,21 @@ namespace CEC
     cec_vendor_id GetVendorId(void) { return CEC_VENDOR_BROADCOM; }
     bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address < CECDEVICE_BROADCAST; }
     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);
     void OnDataReceived(uint32_t p0, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4);
+    void OnTVServiceCallback(uint32_t reason, uint32_t p0, uint32_t p1);
 
     static void InitHost(void);
 
   private:
     cec_logical_address GetLogicalAddress(void);
     bool UnregisterLogicalAddress(void);
-    bool RegisterLogicalAddress(const cec_logical_address address);
+    bool RegisterLogicalAddress(const cec_logical_address address, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT);
     int InitHostCEC(void);
 
     bool m_bInitialised;   /**< true when the connection is initialised, false otherwise */
@@ -115,7 +110,8 @@ namespace CEC
     PLATFORM::CMutex            m_mutex;
     VCHI_INSTANCE_T             m_vchi_instance;
     VCHI_CONNECTION_T *         m_vchi_connection;
-    CRPiCECAdapterFindNewLogicalAddress* m_laLost;
+    cec_logical_address         m_previousLogicalAddress;
+    bool                        m_bLogicalAddressRegistered;
   };
 };