fix OS-X build
[deb_libcec.git] / src / lib / adapter / USBCECAdapterCommunication.cpp
index d6d9b5c0fab383d2023f5a62ddee1a129fda80d6..b3f0f7da7ba3209806b402c2e6e839d4c0b2648f 100644 (file)
@@ -36,6 +36,9 @@
 #include "../platform/sockets/serialport.h"
 #include "../platform/util/timeutils.h"
 #include "../platform/util/util.h"
+#include "../platform/util/edid.h"
+#include "../platform/adl/adl-edid.h"
+#include "../platform/nvidia/nv-edid.h"
 #include "../LibCEC.h"
 #include "../CECProcessor.h"
 
@@ -509,7 +512,7 @@ bool CUSBCECAdapterCommunication::SetAckMask(uint16_t iMask)
     return true;
   }
 
-  LIB_CEC->AddLog(CEC_LOG_ERROR, "couldn't change the ackmask: the connection is closed");
+  LIB_CEC->AddLog(CEC_LOG_DEBUG, "couldn't change the ackmask: the connection is closed");
   return false;
 }
 
@@ -526,12 +529,12 @@ bool CUSBCECAdapterCommunication::PingAdapter(void)
 
 uint16_t CUSBCECAdapterCommunication::GetFirmwareVersion(void)
 {
-  return IsOpen() ? m_commands->GetFirmwareVersion() : CEC_FW_VERSION_UNKNOWN;
+  return m_commands ? m_commands->GetFirmwareVersion() : CEC_FW_VERSION_UNKNOWN;
 }
 
 uint32_t CUSBCECAdapterCommunication::GetFirmwareBuildDate(void)
 {
-  return IsOpen() ? m_commands->RequestBuildDate() : 0;
+  return IsOpen() ? m_commands->RequestBuildDate() : m_commands ? m_commands->GetPersistedBuildDate() : 0;
 }
 
 bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void)
@@ -560,6 +563,42 @@ bool CUSBCECAdapterCommunication::SetControlledMode(bool controlled)
   return IsOpen() ? m_commands->SetControlledMode(controlled) : false;
 }
 
+uint16_t CUSBCECAdapterCommunication::GetPhysicalAddress(void)
+{
+  uint16_t iPA(0);
+
+  // try to get the PA from ADL
+#if defined(HAS_ADL_EDID_PARSER)
+  {
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - trying to get the physical address via ADL", __FUNCTION__);
+    CADLEdidParser adl;
+    iPA = adl.GetPhysicalAddress();
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - ADL returned physical address %04x", __FUNCTION__, iPA);
+  }
+#endif
+
+  // try to get the PA from the nvidia driver
+#if defined(HAS_NVIDIA_EDID_PARSER)
+  if (iPA == 0)
+  {
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - trying to get the physical address via nvidia driver", __FUNCTION__);
+    CNVEdidParser nv;
+    iPA = nv.GetPhysicalAddress();
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - nvidia driver returned physical address %04x", __FUNCTION__, iPA);
+  }
+#endif
+
+  // try to get the PA from the OS
+  if (iPA == 0)
+  {
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - trying to get the physical address from the OS", __FUNCTION__);
+    iPA = CEDIDParser::GetPhysicalAddress();
+    LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - OS returned physical address %04x", __FUNCTION__, iPA);
+  }
+
+  return iPA;
+}
+
 void *CAdapterPingThread::Process(void)
 {
   while (!IsStopped())