uint16_t CCECClient::GetDevicePhysicalAddress(const cec_logical_address iAddress) { CCECBusDevice *device = m_processor->GetDevice(iAddress); if (device) return device->GetPhysicalAddress(GetPrimaryLogicalAdddress()); return CEC_INVALID_PHYSICAL_ADDRESS; }
bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice, const uint8_t iPort, bool bForce /* = false */) { bool bReturn(false); // limit the HDMI port range to 1-15 if (iPort < CEC_MIN_HDMI_PORTNUMBER || iPort > CEC_MAX_HDMI_PORTNUMBER) return bReturn; LIB_CEC->AddLog(CEC_LOG_NOTICE, "setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice); // update the configuration { CLockObject lock(m_mutex); m_configuration.baseDevice = iBaseDevice; m_configuration.iHDMIPort = iPort; } // don't continue if the connection isn't opened if (!m_processor->CECInitialised() && !bForce) return true; // get the PA of the base device uint16_t iPhysicalAddress(CEC_INVALID_PHYSICAL_ADDRESS); CCECBusDevice *baseDevice = m_processor->GetDevice(iBaseDevice); if (baseDevice) iPhysicalAddress = baseDevice->GetPhysicalAddress(GetPrimaryLogicalAdddress()); // add our port number if (iPhysicalAddress <= CEC_MAX_PHYSICAL_ADDRESS) { if (iPhysicalAddress == 0) iPhysicalAddress += 0x1000 * iPort; else if (iPhysicalAddress % 0x1000 == 0) iPhysicalAddress += 0x100 * iPort; else if (iPhysicalAddress % 0x100 == 0) iPhysicalAddress += 0x10 * iPort; else if (iPhysicalAddress % 0x10 == 0) iPhysicalAddress += iPort; bReturn = true; } // set the default address when something went wrong if (!bReturn) { LIB_CEC->AddLog(CEC_LOG_WARNING, "failed to set the physical address to %04X, setting it to the default value %04X", iPhysicalAddress, CEC_DEFAULT_PHYSICAL_ADDRESS); iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS; } // and set the address SetDevicePhysicalAddress(iPhysicalAddress); CallbackConfigurationChanged(m_configuration); return bReturn; }