cec: read the persisted settings from the ROM, and update it in libcec_configuration...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 7c658a35d17f6a67baa238575230286413a0358f..1f4678245fe49e699c40fb68771ee7dcdaab8d73 100644 (file)
@@ -57,10 +57,9 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, libcec_configuration *configur
     m_iRetryLineTimeout(3),
     m_iLastTransmission(0)
 {
-  m_logicalAddresses.Clear();
   CreateBusDevices();
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion = configuration->serverVersion;
   SetConfiguration(configuration);
 
   if (m_configuration.tvVendor != CEC_VENDOR_UNKNOWN)
@@ -78,7 +77,7 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
     m_iLastTransmission(0)
 {
   m_configuration.Clear();
-  m_configuration.serverVersion = CEC_SERVER_VERSION_1_5_0;
+  m_configuration.serverVersion    = CEC_SERVER_VERSION_1_5_2;
 
   // client version < 1.5.0
   m_configuration.clientVersion    = (uint32_t)CEC_CLIENT_VERSION_PRE_1_5;
@@ -90,7 +89,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
 
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
-  m_logicalAddresses.Clear();
   CreateBusDevices();
 }
 
@@ -152,6 +150,7 @@ void CCECProcessor::Close(void)
 
   if (bClose && m_communication)
   {
+    m_communication->PersistConfiguration(&m_configuration);
     m_communication->Close();
     delete m_communication;
     m_communication = NULL;
@@ -181,21 +180,23 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
     return bReturn;
   }
 
-  uint64_t iNow = GetTimeMs();
-  uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT;
+  CTimeout timeout(iTimeoutMs > 0 ? iTimeoutMs : CEC_DEFAULT_TRANSMIT_WAIT);
 
   /* open a new connection */
   unsigned iConnectTry(0);
-  while (iNow < iTarget && (bReturn = m_communication->Open(this, iTimeoutMs)) == false)
+  while (timeout.TimeLeft() > 0 && (bReturn = m_communication->Open(this, (timeout.TimeLeft() / CEC_CONNECT_TRIES))) == false)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
-    Sleep(500);
-    iNow = GetTimeMs();
+    m_communication->Close();
+    CEvent::Sleep(1000);
   }
 
   if (bReturn)
     CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_communication->GetFirmwareVersion(), ToString((cec_client_version)m_configuration.clientVersion));
 
+  if (m_configuration.bGetSettingsFromROM == 1)
+    m_communication->GetConfiguration(&m_configuration);
+
   return bReturn;
 }
 
@@ -216,8 +217,8 @@ bool CCECProcessor::Initialise(void)
   bool bReturn(false);
   {
     CLockObject lock(m_mutex);
-    if (!m_logicalAddresses.IsEmpty())
-      m_logicalAddresses.Clear();
+    if (!m_configuration.logicalAddresses.IsEmpty())
+      m_configuration.logicalAddresses.Clear();
 
     if (!FindLogicalAddresses())
     {
@@ -226,11 +227,11 @@ bool CCECProcessor::Initialise(void)
     }
 
     /* only set our OSD name for the primary device */
-    m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_configuration.strDeviceName;
+    m_busDevices[m_configuration.logicalAddresses.primary]->m_strDeviceName = m_configuration.strDeviceName;
 
     /* make the primary device the active source if the option is set */
     if (m_configuration.bActivateSource == 1)
-      m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true;
+      m_busDevices[m_configuration.logicalAddresses.primary]->m_bActiveSource = true;
   }
 
   /* get the vendor id from the TV, so we are using the correct handler */
@@ -239,15 +240,15 @@ bool CCECProcessor::Initialise(void)
   if (m_configuration.iPhysicalAddress != 0)
   {
     CLibCEC::AddLog(CEC_LOG_NOTICE, "setting the physical address to %4x", m_configuration.iPhysicalAddress);
-    m_busDevices[m_logicalAddresses.primary]->m_iPhysicalAddress = m_configuration.iPhysicalAddress;
-    if ((bReturn = m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress()) == false)
+    m_busDevices[m_configuration.logicalAddresses.primary]->m_iPhysicalAddress = m_configuration.iPhysicalAddress;
+    if ((bReturn = m_busDevices[m_configuration.logicalAddresses.primary]->TransmitPhysicalAddress()) == false)
       CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set the physical address to %4x", m_configuration.iPhysicalAddress);
   }
   else if (m_configuration.iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort, true)) == false)
     CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_configuration.iHDMIPort, ToString(m_configuration.baseDevice), (uint8_t)m_configuration.baseDevice);
 
   if (m_configuration.bActivateSource == 1)
-    m_busDevices[m_logicalAddresses.primary]->ActivateSource();
+    m_busDevices[m_configuration.logicalAddresses.primary]->ActivateSource();
 
   SetInitialised(bReturn);
   if (bReturn)
@@ -290,7 +291,7 @@ bool CCECProcessor::TryLogicalAddress(cec_logical_address address)
 {
   if (m_busDevices[address]->TryLogicalAddress())
   {
-    m_logicalAddresses.Set(address);
+    m_configuration.logicalAddresses.Set(address);
     return true;
   }
 
@@ -336,7 +337,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to)
 
   CLockObject lock(m_mutex);
   CCECBusDevice *previousDevice = GetDeviceByType(from);
-  m_logicalAddresses.primary = CECDEVICE_UNKNOWN;
+  m_configuration.logicalAddresses.primary = CECDEVICE_UNKNOWN;
 
   for (unsigned int iPtr = 0; iPtr < 5; iPtr++)
   {
@@ -408,7 +409,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to)
 bool CCECProcessor::FindLogicalAddresses(void)
 {
   bool bReturn(true);
-  m_logicalAddresses.Clear();
+  m_configuration.logicalAddresses.Clear();
 
   if (m_configuration.deviceTypes.IsEmpty())
   {
@@ -434,7 +435,7 @@ bool CCECProcessor::FindLogicalAddresses(void)
   }
 
   if (bReturn)
-    SetAckMask(m_logicalAddresses.AckMask());
+    SetAckMask(m_configuration.logicalAddresses.AckMask());
 
   return bReturn;
 }
@@ -478,13 +479,13 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
   if (!IsRunning())
     return bReturn;
 
-  cec_logical_address addr = m_logicalAddresses.primary;
+  cec_logical_address addr = m_configuration.logicalAddresses.primary;
 
   if (type != CEC_DEVICE_TYPE_RESERVED)
   {
     for (uint8_t iPtr = 0; iPtr <= 11; iPtr++)
     {
-      if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type)
+      if (m_configuration.logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type)
       {
         addr = (cec_logical_address) iPtr;
         break;
@@ -571,7 +572,6 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort,
     CLockObject lock(m_mutex);
     m_configuration.baseDevice = iBaseDevice;
     m_configuration.iHDMIPort = iPort;
-    m_configuration.bAutodetectAddress = false;
   }
 
   if (!IsRunning() && !bForce)
@@ -622,8 +622,8 @@ bool CCECProcessor::TransmitInactiveSource(void)
   if (!IsRunning())
     return false;
 
-  if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary])
-    return m_busDevices[m_logicalAddresses.primary]->TransmitInactiveSource();
+  if (!m_configuration.logicalAddresses.IsEmpty() && m_busDevices[m_configuration.logicalAddresses.primary])
+    return m_busDevices[m_configuration.logicalAddresses.primary]->TransmitInactiveSource();
   return false;
 }
 
@@ -642,12 +642,12 @@ void CCECProcessor::LogOutput(const cec_command &data)
 bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress)
 {
   CLockObject lock(m_mutex);
-  if (m_logicalAddresses.primary != iLogicalAddress)
+  if (m_configuration.logicalAddresses.primary != iLogicalAddress)
   {
     CLibCEC::AddLog(CEC_LOG_NOTICE, "<< setting primary logical address to %1x", iLogicalAddress);
-    m_logicalAddresses.primary = iLogicalAddress;
-    m_logicalAddresses.Set(iLogicalAddress);
-    return SetAckMask(m_logicalAddresses.AckMask());
+    m_configuration.logicalAddresses.primary = iLogicalAddress;
+    m_configuration.logicalAddresses.Set(iLogicalAddress);
+    return SetAckMask(m_configuration.logicalAddresses.AckMask());
   }
 
   return true;
@@ -657,12 +657,12 @@ bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = tru
 {
   for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
   {
-    if (m_logicalAddresses[iPtr])
+    if (m_configuration.logicalAddresses[iPtr])
       m_busDevices[iPtr]->SetMenuState(state);
   }
 
   if (bSendUpdate)
-    m_busDevices[m_logicalAddresses.primary]->TransmitMenuState(CECDEVICE_TV);
+    m_busDevices[m_configuration.logicalAddresses.primary]->TransmitMenuState(CECDEVICE_TV);
 
   return true;
 }
@@ -677,17 +677,13 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress, bool bSendUpda
   {
     CLockObject lock(m_mutex);
     m_configuration.iPhysicalAddress = iPhysicalAddress;
-    if (m_configuration.bAutodetectAddress)
-    {
-      m_configuration.baseDevice = CECDEVICE_UNKNOWN;
-      m_configuration.iHDMIPort = 0;
-    }
+    CLibCEC::AddLog(CEC_LOG_DEBUG, "setting physical address to '%4x'", iPhysicalAddress);
 
-    if (!m_logicalAddresses.IsEmpty())
+    if (!m_configuration.logicalAddresses.IsEmpty())
     {
       bool bWasActiveSource(false);
       for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
-        if (m_logicalAddresses[iPtr])
+        if (m_configuration.logicalAddresses[iPtr])
         {
           bWasActiveSource |= m_busDevices[iPtr]->IsActiveSource();
           m_busDevices[iPtr]->SetInactiveSource();
@@ -726,16 +722,16 @@ bool CCECProcessor::SwitchMonitoring(bool bEnable)
   if (bEnable)
     return SetAckMask(0);
   else
-    return SetAckMask(m_logicalAddresses.AckMask());
+    return SetAckMask(m_configuration.logicalAddresses.AckMask());
 }
 
 bool CCECProcessor::PollDevice(cec_logical_address iAddress)
 {
   if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress])
   {
-    return m_logicalAddresses.primary == CECDEVICE_UNKNOWN ?
+    return m_configuration.logicalAddresses.primary == CECDEVICE_UNKNOWN ?
         m_busDevices[iAddress]->TransmitPoll(iAddress) :
-        m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress);
+        m_busDevices[m_configuration.logicalAddresses.primary]->TransmitPoll(iAddress);
   }
   return false;
 }
@@ -769,8 +765,8 @@ uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */)
 
 CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */) const
 {
-  if (m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress)
-    return m_busDevices[m_logicalAddresses.primary];
+  if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress)
+    return m_busDevices[m_configuration.logicalAddresses.primary];
 
   CCECBusDevice *device = NULL;
   for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
@@ -791,7 +787,7 @@ CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const
 
   for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
   {
-    if (m_busDevices[iPtr]->m_type == type && m_logicalAddresses[iPtr])
+    if (m_busDevices[iPtr]->m_type == type && m_configuration.logicalAddresses[iPtr])
     {
       device = m_busDevices[iPtr];
       break;
@@ -804,7 +800,7 @@ CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const
 CCECBusDevice *CCECProcessor::GetPrimaryDevice(void) const
 {
   CCECBusDevice *device(NULL);
-  cec_logical_address primary = m_logicalAddresses.primary;
+  cec_logical_address primary = m_configuration.logicalAddresses.primary;
   if (primary != CECDEVICE_UNKNOWN)
     device = m_busDevices[primary];
   return device;
@@ -875,7 +871,7 @@ bool CCECProcessor::IsActiveSource(cec_logical_address iAddress)
 
 bool CCECProcessor::Transmit(const cec_command &data)
 {
-  if (m_logicalAddresses[(uint8_t)data.destination])
+  if (m_configuration.logicalAddresses[(uint8_t)data.destination])
   {
     CLibCEC::AddLog(CEC_LOG_WARNING, "not sending data to myself!");
     return false;
@@ -906,7 +902,7 @@ void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode
 
   cec_command command;
   // TODO
-  cec_command::Format(command, m_logicalAddresses.primary, address, CEC_OPCODE_FEATURE_ABORT);
+  cec_command::Format(command, m_configuration.logicalAddresses.primary, address, CEC_OPCODE_FEATURE_ABORT);
   command.parameters.PushBack((uint8_t)opcode);
   command.parameters.PushBack((uint8_t)reason);
 
@@ -955,8 +951,8 @@ bool CCECProcessor::IsPresentDeviceType(cec_device_type type)
 
 uint16_t CCECProcessor::GetPhysicalAddress(void) const
 {
-  if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary])
-    return m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress(false);
+  if (!m_configuration.logicalAddresses.IsEmpty() && m_busDevices[m_configuration.logicalAddresses.primary])
+    return m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false);
   return false;
 }
 
@@ -1378,6 +1374,10 @@ const char *CCECProcessor::ToString(const cec_client_version version)
     return "pre-1.5";
   case CEC_CLIENT_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_CLIENT_VERSION_1_5_1:
+    return "1.5.1";
+  case CEC_CLIENT_VERSION_1_5_2:
+    return "1.5.2";
   default:
     return "Unknown";
   }
@@ -1391,6 +1391,10 @@ const char *CCECProcessor::ToString(const cec_server_version version)
     return "pre-1.5";
   case CEC_SERVER_VERSION_1_5_0:
     return "1.5.0";
+  case CEC_SERVER_VERSION_1_5_1:
+    return "1.5.1";
+  case CEC_SERVER_VERSION_1_5_2:
+    return "1.5.2";
   default:
     return "Unknown";
   }
@@ -1441,9 +1445,31 @@ void CCECBusScan::WaitUntilIdle(void)
   }
 }
 
-bool CCECProcessor::StartBootloader(void)
+bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
 {
-  return m_communication->StartBootloader();
+  if (!m_communication && strPort)
+  {
+    bool bReturn(false);
+    IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort);
+    CTimeout timeout(10000);
+    int iConnectTry(0);
+    while (timeout.TimeLeft() > 0 && (bReturn = comm->Open(NULL, (timeout.TimeLeft() / CEC_CONNECT_TRIES)), true) == false)
+    {
+      CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry);
+      comm->Close();
+      Sleep(500);
+    }
+    if (comm->IsOpen())
+    {
+      bReturn = comm->StartBootloader();
+      delete comm;
+    }
+    return bReturn;
+  }
+  else
+  {
+    return m_communication->StartBootloader();
+  }
 }
 
 bool CCECProcessor::PingAdapter(void)
@@ -1469,9 +1495,9 @@ bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
 
 bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
 {
-       bool bReinit(false);
+  bool bReinit(false);
   CCECBusDevice *primary = IsRunning() ? GetPrimaryDevice() : NULL;
-       cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
+  cec_device_type oldPrimaryType = primary ? primary->GetType() : CEC_DEVICE_TYPE_RECORDING_DEVICE;
   m_configuration.clientVersion  = configuration->clientVersion;
 
   // client version 1.5.0
@@ -1480,51 +1506,59 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   bool bDeviceTypeChanged = IsRunning () && m_configuration.deviceTypes != configuration->deviceTypes;
   m_configuration.deviceTypes = configuration->deviceTypes;
 
+  bool bPhysicalAddressChanged(false);
+
   // autodetect address
-  uint16_t iPhysicalAddress = IsRunning() && configuration->bAutodetectAddress ? m_communication->GetPhysicalAddress() : 0;
-  bool bPhysicalAutodetected = IsRunning() && configuration->bAutodetectAddress && iPhysicalAddress != m_configuration.iPhysicalAddress && iPhysicalAddress != 0;
-  if (bPhysicalAutodetected)
+  bool bPhysicalAutodetected(false);
+  if (IsRunning() && configuration->bAutodetectAddress == 1)
   {
-    m_configuration.iPhysicalAddress = iPhysicalAddress;
-    m_configuration.bAutodetectAddress = true;
-  }
-  else
-  {
-    m_configuration.bAutodetectAddress = false;
+    uint16_t iPhysicalAddress = m_communication->GetPhysicalAddress();
+    if (iPhysicalAddress != 0)
+    {
+      if (IsRunning())
+        CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - autodetected physical address '%4x'", __FUNCTION__, iPhysicalAddress);
+      bPhysicalAddressChanged = (m_configuration.iPhysicalAddress != iPhysicalAddress);
+      m_configuration.iPhysicalAddress = iPhysicalAddress;
+      m_configuration.iHDMIPort = 0;
+      m_configuration.baseDevice = CECDEVICE_UNKNOWN;
+      bPhysicalAutodetected = true;
+    }
   }
 
   // physical address
-  bool bPhysicalAddressChanged(false);
   if (!bPhysicalAutodetected)
   {
-    bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
+    if (configuration->iPhysicalAddress != 0)
+      bPhysicalAddressChanged = IsRunning() && m_configuration.iPhysicalAddress != configuration->iPhysicalAddress;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using physical address '%4x'", __FUNCTION__, configuration->iPhysicalAddress);
     m_configuration.iPhysicalAddress = configuration->iPhysicalAddress;
   }
 
-  // base device
   bool bHdmiPortChanged(false);
   if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
   {
+    // base device
     bHdmiPortChanged = IsRunning() && m_configuration.baseDevice != configuration->baseDevice;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using base device '%x'", __FUNCTION__, (int)configuration->baseDevice);
     m_configuration.baseDevice = configuration->baseDevice;
-  }
-  else
-  {
-    m_configuration.baseDevice = CECDEVICE_UNKNOWN;
-  }
 
-  // hdmi port
-  if (!bPhysicalAutodetected && !bPhysicalAddressChanged)
-  {
+    // hdmi port
     bHdmiPortChanged |= IsRunning() && m_configuration.iHDMIPort != configuration->iHDMIPort;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - using HDMI port '%d'", __FUNCTION__, configuration->iHDMIPort);
     m_configuration.iHDMIPort = configuration->iHDMIPort;
   }
   else
   {
-    m_configuration.iHDMIPort = 0;
+    if (IsRunning())
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - resetting HDMI port and base device to defaults", __FUNCTION__);
+    m_configuration.baseDevice = CECDEVICE_UNKNOWN;
+    m_configuration.iHDMIPort  = 0;
   }
 
-       bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged || bPhysicalAutodetected;
+  bReinit = bPhysicalAddressChanged || bHdmiPortChanged || bDeviceTypeChanged;
 
   // device name
   snprintf(m_configuration.strDeviceName, 13, "%s", configuration->strDeviceName);
@@ -1558,6 +1592,10 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
   m_configuration.bPowerOffScreensaver = configuration->bPowerOffScreensaver;
   m_configuration.bPowerOffOnStandby   = configuration->bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    m_configuration.bSendInactiveSource = configuration->bSendInactiveSource;
+
   // ensure that there is at least 1 device type set
   if (m_configuration.deviceTypes.IsEmpty())
     m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
@@ -1571,6 +1609,11 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
     else
       return SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort);
   }
+  else if (m_configuration.bActivateSource == 1 && IsRunning() && !IsActiveSource(m_configuration.logicalAddresses.primary))
+  {
+    // activate the source if we're not already the active source
+    SetActiveSource(m_configuration.deviceTypes.types[0]);
+  }
 
   return true;
 }
@@ -1596,6 +1639,14 @@ bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
   configuration->bPowerOffScreensaver = m_configuration.bPowerOffScreensaver;
   configuration->bPowerOffOnStandby   = m_configuration.bPowerOffOnStandby;
 
+  // client version 1.5.1
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_1)
+    configuration->bSendInactiveSource = m_configuration.bSendInactiveSource;
+
+  // client version 1.5.3
+  if (configuration->clientVersion >= CEC_CLIENT_VERSION_1_5_3)
+    configuration->logicalAddresses    = m_configuration.logicalAddresses;
+
   return true;
 }