}
lock.Leave();
- if (SetAckMask(m_logicalAddresses.AckMask()) &&
- SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
+
+ m_busDevices[CECDEVICE_TV]->GetVendorId();
+
+ if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
{
m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
m_busScan = new CCECBusScan(this);
}
else
{
- m_busDevices[CECDEVICE_TV]->GetVendorId();
- m_busDevices[m_logicalAddresses.primary]->TransmitVendorID(CECDEVICE_TV, false);
+ SetAckMask(m_logicalAddresses.AckMask());
CLockObject lock(&m_mutex);
m_bStarted = true;
{
bool bReturn(false);
- CStdString strLog;
- strLog.Format("setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
- AddLog(CEC_LOG_DEBUG, strLog);
-
m_iBaseDevice = iBaseDevice;
m_iHDMIPort = iPort;
if (!m_bStarted && !bForce)
return true;
+ CStdString strLog;
+ strLog.Format("setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice);
+ AddLog(CEC_LOG_DEBUG, strLog);
+
uint16_t iPhysicalAddress(0);
- iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress();
- uint16_t iPos = 0;
- if (iPhysicalAddress == 0)
- iPos = 0x1000;
- else if (iPhysicalAddress % 0x1000 == 0)
- iPos = 0x100;
- else if (iPhysicalAddress % 0x100 == 0)
- iPos = 0x10;
- else if (iPhysicalAddress % 0x10 == 0)
- iPos = 0x1;
-
- while(!bReturn && iPos > 0)
+ if (iBaseDevice > CECDEVICE_TV)
+ iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress();
+
+ if (iPhysicalAddress == 0xffff)
{
- iPhysicalAddress += (uint16_t)(iPort * iPos);
- strLog.Format("checking physical address %4x", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- if (PhysicalAddressInUse(iPhysicalAddress))
- {
- strLog.Format("physical address %4x is in use", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- iPos = (iPos == 1) ? 0 : iPos / 0x10;
- }
- else
+ SetPhysicalAddress((uint16_t)iPort * 0x1000);
+ bReturn = false;
+ }
+ else
+ {
+ uint16_t iPos = 0;
+ if (iPhysicalAddress == 0)
+ iPos = 0x1000;
+ else if (iPhysicalAddress % 0x1000 == 0)
+ iPos = 0x100;
+ else if (iPhysicalAddress % 0x100 == 0)
+ iPos = 0x10;
+ else if (iPhysicalAddress % 0x10 == 0)
+ iPos = 0x1;
+
+ while(!bReturn && iPos > 0)
{
- strLog.Format("physical address %4x is free", iPhysicalAddress);
+ iPhysicalAddress += (uint16_t)(iPort * iPos);
+ strLog.Format("checking physical address %4x", iPhysicalAddress);
AddLog(CEC_LOG_DEBUG, strLog);
- SetPhysicalAddress(iPhysicalAddress);
- bReturn = true;
+ if (PhysicalAddressInUse(iPhysicalAddress))
+ {
+ strLog.Format("physical address %4x is in use", iPhysicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog);
+ iPos = (iPos == 1) ? 0 : iPos / 0x10;
+ }
+ else
+ {
+ strLog.Format("physical address %4x is free", iPhysicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog);
+ SetPhysicalAddress(iPhysicalAddress);
+ bReturn = true;
+ }
}
}
for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
if (m_logicalAddresses[iPtr])
{
+ m_busDevices[iPtr]->SetInactiveDevice();
m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
m_busDevices[iPtr]->TransmitPhysicalAddress();
}
return false;
}
+uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress)
+{
+ if (m_busDevices[iAddress])
+ return m_busDevices[iAddress]->GetPhysicalAddress(false);
+ return false;
+}
+
cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress)
{
if (m_busDevices[iAddress])
return CEC_POWER_STATUS_UNKNOWN;
}
+cec_logical_address CCECProcessor::GetActiveSource(void)
+{
+ for (uint8_t iPtr = 0; iPtr <= 11; iPtr++)
+ {
+ if (m_busDevices[iPtr]->IsActiveSource())
+ return (cec_logical_address)iPtr;
+ }
+
+ return CECDEVICE_UNKNOWN;
+}
+
+bool CCECProcessor::IsActiveSource(cec_logical_address iAddress)
+{
+ return m_busDevices[iAddress]->IsActiveSource();
+}
+
bool CCECProcessor::Transmit(const cec_command &data)
{
bool bReturn(false);
LogOutput(data);
CCECAdapterMessage *output = new CCECAdapterMessage(data);
+
+ /* set the number of retries */
+ if (data.opcode == CEC_OPCODE_NONE)
+ output->maxTries = 1;
+ else if (data.initiator != CECDEVICE_BROADCAST)
+ output->maxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1;
+
bReturn = Transmit(output);
/* set to "not present" on failed ack */
while (!IsStopped())
{
- if (++iCounter < 30)
+ if (++iCounter < 10)
{
Sleep(1000);
continue;