}
else
{
- m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress();
+ m_busDevices[CECDEVICE_TV]->GetVendorId();
+ m_busDevices[m_logicalAddresses.primary]->TransmitVendorID(CECDEVICE_TV, false);
+
CLockObject lock(&m_mutex);
m_bStarted = true;
m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");
m_iRetryLineTimeout = iTimeout;
}
-bool CCECProcessor::SetActiveSource(cec_logical_address iAddress)
-{
- return SetStreamPath(m_busDevices[iAddress]->GetPhysicalAddress(false));
-}
-
bool CCECProcessor::SetActiveView(void)
{
return SetActiveSource(m_types.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED : m_types[0]);
{
for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
if (m_logicalAddresses[iPtr])
+ {
m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress);
+ m_busDevices[iPtr]->TransmitPhysicalAddress();
+ }
return SetActiveView();
}
return false;
CLockObject lock(&m_mutex);
m_bMonitor = bEnable;
- if (bEnable)
+ if (!bEnable)
{
if (!m_busScan)
{
void *CCECBusScan::Process(void)
{
CCECBusDevice *device(NULL);
+ uint8_t iCounter(0);
while (!IsStopped())
{
+ if (++iCounter < 30)
+ {
+ Sleep(1000);
+ continue;
+ }
for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++)
{
device = m_processor->m_busDevices[iPtr];
virtual bool SetActiveView(void);
virtual bool SetActiveSource(cec_device_type type = CEC_DEVICE_TYPE_RESERVED);
- virtual bool SetActiveSource(cec_logical_address iAddress);
virtual bool SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate = true);
virtual bool SetDeckInfo(cec_deck_info info, bool bSendUpdate = true);
virtual bool SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce = false);
{
{
CLockObject lock(&m_mutex);
- m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
- }
- cec_power_status status = GetPowerStatus();
- if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
- {
- /* sending the normal power on command appears to have failed */
- CStdString strLog;
- strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog.c_str());
-
- TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
- return TransmitKeyRelease();
+// m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
+ m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
}
+// cec_power_status status = GetPowerStatus();
+// if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
+// {
+// /* sending the normal power on command appears to have failed */
+// CStdString strLog;
+// strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+// AddLog(CEC_LOG_DEBUG, strLog.c_str());
+//
+// TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
+// return TransmitKeyRelease();
+// }
return true;
}
return m_handler->TransmitPowerState(m_iLogicalAddress, dest, state);
}
-bool CCECBusDevice::TransmitVendorID(cec_logical_address dest)
+bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort /* = true */)
{
uint64_t iVendorId;
{
if (iVendorId == CEC_VENDOR_UNKNOWN)
{
- CStdString strLog;
- strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
- AddLog(CEC_LOG_NOTICE, strLog);
+ if (bSendAbort)
+ {
+ CStdString strLog;
+ strLog.Format("<< %s (%X) -> %s (%X): vendor id feature abort", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
+ AddLog(CEC_LOG_NOTICE, strLog);
- m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ }
return false;
}
else
{
class CCECProcessor;
class CCECCommandHandler;
+ class CSLCommandHandler;
class CCECBusDevice
{
friend class CCECProcessor;
+ friend class CSLCommandHandler;
public:
CCECBusDevice(CCECProcessor *processor, cec_logical_address address, uint16_t iPhysicalAddress = 0);
virtual bool TransmitPhysicalAddress(void);
virtual bool TransmitPowerState(cec_logical_address dest);
virtual bool TransmitPoll(cec_logical_address dest);
- virtual bool TransmitVendorID(cec_logical_address dest);
+ virtual bool TransmitVendorID(cec_logical_address dest, bool bSendAbort = true);
virtual bool TransmitKeypress(cec_user_control_code key);
virtual bool TransmitKeyRelease(void);
bool CCECCommandHandler::HandleImageViewOn(const cec_command &command)
{
- m_processor->SetActiveSource(command.initiator);
+ m_processor->SetStreamPath(m_processor->m_busDevices[command.initiator]->GetPhysicalAddress(false));
return true;
}
uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
CCECBusDevice *newActiveDevice = GetDeviceByPhysicalAddress(iNewAddress);
if (newActiveDevice)
- m_processor->SetActiveSource(newActiveDevice->GetLogicalAddress());
+ m_processor->SetStreamPath(newActiveDevice->GetPhysicalAddress(false));
return ((CCECAudioSystem *) device)->TransmitSetSystemAudioMode(command.initiator);
}
else
bool CCECCommandHandler::HandleTextViewOn(const cec_command &command)
{
- m_processor->SetActiveSource(command.initiator);
+ m_processor->SetStreamPath(m_processor->m_busDevices[command.initiator]->GetPhysicalAddress(false));
return true;
}
m_bSLEnabled(false),
m_bVendorIdSent(false)
{
+ m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary]->m_powerStatus = CEC_POWER_STATUS_STANDBY;
}
bool CSLCommandHandler::HandleVendorCommand(const cec_command &command)
}
void CSLCommandHandler::HandleVendorCommand01(const cec_command &command)
+{
+ TransmitVendorCommand0205(command.destination, command.initiator);
+}
+
+void CSLCommandHandler::TransmitVendorCommand0205(const cec_logical_address iSource, const cec_logical_address iDestination)
{
cec_command response;
- cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND);
+ cec_command::Format(response, iSource, iDestination, CEC_OPCODE_VENDOR_COMMAND);
response.PushBack(SL_COMMAND_UNKNOWN_02);
response.PushBack(SL_COMMAND_UNKNOWN_03);
Transmit(response);
+}
- /* transmit power status */
- if (command.destination != CECDEVICE_BROADCAST)
- m_processor->m_busDevices[command.destination]->TransmitPowerState(command.initiator);
+void CSLCommandHandler::TransmitVendorCommand04(const cec_logical_address iSource, const cec_logical_address iDestination)
+{
+ m_bSLEnabled = true;
+ cec_command response;
+ cec_command::Format(response, iSource, iDestination, CEC_OPCODE_VENDOR_COMMAND);
+ response.PushBack(SL_COMMAND_CONNECT_ACCEPT);
+ response.PushBack((uint8_t)iSource);
+ Transmit(response);
}
void CSLCommandHandler::HandleVendorCommand03(const cec_command &command)
CCECBusDevice *device = m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary];
if (device)
{
- device->SetPowerStatus(CEC_POWER_STATUS_ON);
+ m_bSLEnabled = true;
+ device->SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
device->TransmitPowerState(command.initiator);
- device->TransmitPhysicalAddress();
+ device->TransmitVendorID(command.initiator);
TransmitPowerOn(device->GetLogicalAddress(), command.initiator);
- if (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE ||
- device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE)
- {
- ((CCECPlaybackDevice *)device)->TransmitDeckStatus(command.initiator);
- }
}
}
void CSLCommandHandler::HandleVendorCommand04(const cec_command &command)
{
- cec_command response;
- cec_command::Format(response, command.destination, command.initiator, CEC_OPCODE_VENDOR_COMMAND);
- response.PushBack(SL_COMMAND_CONNECT_ACCEPT);
- response.PushBack((uint8_t)m_processor->GetLogicalAddresses().primary);
- Transmit(response);
-
+ m_bSLEnabled = true;
+ TransmitVendorCommand04(command.destination, command.initiator);
TransmitDeckStatus(command.initiator);
}
{
bool bHandled(false);
- if (m_processor->IsStarted() && m_busDevice->MyLogicalAddressContains(command.destination) ||
- command.destination == CECDEVICE_BROADCAST)
+ if (m_processor->IsStarted() && (m_busDevice->MyLogicalAddressContains(command.destination) ||
+ command.destination == CECDEVICE_BROADCAST))
{
switch(command.opcode)
{
m_bVendorIdSent = true;
TransmitLGVendorId(m_processor->GetLogicalAddresses().primary, CECDEVICE_BROADCAST);
}
- m_processor->m_busDevices[m_processor->GetLogicalAddresses().primary]->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
- m_bSLEnabled = false;
}
bHandled = true;
default:
bool CSLCommandHandler::InitHandler(void)
{
- if (m_bSLEnabled)
- return true;
- m_bSLEnabled = true;
-
m_processor->SetStandardLineTimeout(3);
m_processor->SetRetryLineTimeout(3);
if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
{
- m_processor->SetActiveSource(m_processor->GetLogicalAddresses().primary);
+ m_processor->SetActiveSource();
+
/* LG TVs only route keypresses when the deck status is set to 0x20 */
cec_logical_addresses addr = m_processor->GetLogicalAddresses();
for (uint8_t iPtr = 0; iPtr < 15; iPtr++)
return CCECCommandHandler::TransmitPowerOn(iInitiator, iDestination);
}
+
virtual void HandleVendorCommand04(const cec_command &command);
virtual void HandleVendorCommandA0(const cec_command &command);
+ virtual void TransmitVendorCommand0205(const cec_logical_address iSource, const cec_logical_address iDestination);
+ virtual void TransmitVendorCommand04(const cec_logical_address iSource, const cec_logical_address iDestination);
virtual void TransmitDeckStatus(const cec_logical_address iDestination);
virtual bool HandleGiveDeviceVendorId(const cec_command &command);
virtual bool HandleVendorCommand(const cec_command &command);