m_processor->AddLog(level, strMessage);
}
+void CCECBusDevice::SetVendorId(const cec_datapacket &data)
+{
+ if (data.size < 3)
+ {
+ AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
+ return;
+ }
+
+ uint64_t iVendorId = ((uint64_t)data[0] << 3) +
+ ((uint64_t)data[1] << 2) +
+ (uint64_t)data[2];
+
+ SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0);
+}
+
void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */)
{
m_iVendorId = iVendorId;
}
CStdString strLog;
- strLog.Format("device %d: vendor = %s (%04x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
+ strLog.Format("device %d: vendor = %s (%06x) class = %2x", m_iLogicalAddress, GetVendorName(), GetVendorId(), GetVendorClass());
m_processor->AddLog(CEC_LOG_DEBUG, strLog.c_str());
}
void CCECBusDevice::PollVendorId(void)
{
CLockObject lock(&m_mutex);
- if (m_iLastActive > 0 && m_iVendorId == CEC_VENDOR_UNKNOWN &&
+ if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST &&
+ m_iVendorId == CEC_VENDOR_UNKNOWN &&
GetTimeMs() - m_iLastActive > 5000)
{
m_iLastActive = GetTimeMs();
m_iPhysicalAddress = iNewAddress;
}
+bool CCECBusDevice::PowerOn(void)
+{
+ CStdString strLog;
+ strLog.Format("<< powering on device with logical address %d", (int8_t)m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::Standby(void)
+{
+ CStdString strLog;
+ strLog.Format("<< putting device with logical address %d in standby mode", (int8_t)m_iLogicalAddress);
+ AddLog(CEC_LOG_DEBUG, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_STANDBY);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::SetOSDString(cec_display_control duration, const char *strMessage)
+{
+ CStdString strLog;
+ strLog.Format("<< display message '%s'", strMessage);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_SET_OSD_STRING);
+ command.parameters.push_back((uint8_t)duration);
+
+ for (unsigned int iPtr = 0; iPtr < strlen(strMessage); iPtr++)
+ command.parameters.push_back(strMessage[iPtr]);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportCECVersion(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< reporting CEC version as 1.3a");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_CEC_VERSION);
+ command.parameters.push_back(CEC_VERSION_1_3A);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportDeckStatus(void)
+{
+ // need to support opcodes play and deck control before doing anything with this
+ AddLog(CEC_LOG_NOTICE, "<< deck status requested, feature abort");
+ m_processor->TransmitAbort(m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ return false;
+}
+
+bool CCECBusDevice::ReportMenuState(bool bActive /* = true */)
+{
+ if (bActive)
+ AddLog(CEC_LOG_NOTICE, "<< reporting menu state as active");
+ else
+ AddLog(CEC_LOG_NOTICE, "<< reporting menu state as inactive");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_MENU_STATUS);
+ command.parameters.push_back(bActive ? (uint8_t) CEC_MENU_STATE_ACTIVATED : (uint8_t) CEC_MENU_STATE_DEACTIVATED);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportOSDName(void)
+{
+ const char *osdname = m_processor->GetDeviceName().c_str();
+ CStdString strLog;
+ strLog.Format("<< reporting OSD name as %s", osdname);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_SET_OSD_NAME);
+ for (unsigned int iPtr = 0; iPtr < strlen(osdname); iPtr++)
+ command.parameters.push_back(osdname[iPtr]);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportPowerState(bool bOn /* = true */)
+{
+ if (bOn)
+ AddLog(CEC_LOG_NOTICE, "<< reporting \"On\" power status");
+ else
+ AddLog(CEC_LOG_NOTICE, "<< reporting \"Off\" power status");
+
+ cec_command command;
+ cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_REPORT_POWER_STATUS);
+ command.parameters.push_back(bOn ? (uint8_t) CEC_POWER_STATUS_ON : (uint8_t) CEC_POWER_STATUS_STANDBY);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::ReportVendorID(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< vendor ID requested, feature abort");
+ m_processor->TransmitAbort(m_iLogicalAddress, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+ return false;
+}
+
+bool CCECBusDevice::BroadcastActiveView(void)
+{
+ AddLog(CEC_LOG_DEBUG, "<< setting active view");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
+ command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
+ command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastInactiveView(void)
+{
+ AddLog(CEC_LOG_DEBUG, "<< setting inactive view");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_INACTIVE_SOURCE);
+ command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
+ command.parameters.push_back(m_iPhysicalAddress & 0xFF);
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastPhysicalAddress(void)
+{
+ CStdString strLog;
+ strLog.Format("<< reporting physical address as %04x", m_iPhysicalAddress);
+ AddLog(CEC_LOG_NOTICE, strLog.c_str());
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_REPORT_PHYSICAL_ADDRESS);
+ command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
+ command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
+ command.parameters.push_back((uint8_t) (CEC_DEVICE_TYPE_PLAYBACK_DEVICE));
+
+ return m_processor->Transmit(command);
+}
+
+bool CCECBusDevice::BroadcastActiveSource(void)
+{
+ AddLog(CEC_LOG_NOTICE, "<< broadcasting active source");
+
+ cec_command command;
+ cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
+ command.parameters.push_back((uint8_t) ((m_iPhysicalAddress >> 8) & 0xFF));
+ command.parameters.push_back((uint8_t) (m_iPhysicalAddress & 0xFF));
+
+ return m_processor->Transmit(command);
+}
+
const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId)
{
switch (iVendorId)