X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FPulse-Eight%2FUSBCECAdapterCommands.cpp;h=f70c8ef76f80582955fd9222e85552241824a2b3;hb=8f69060da89a711b1a45bc7d5958a3436b71ac4a;hp=457889cf3b555d9baffba9ed786ad2e813880ed0;hpb=a38292a3c2ec93a21d74da778516276e92d431c0;p=deb_libcec.git diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp index 457889c..f70c8ef 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterCommands.cpp @@ -1,7 +1,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -54,7 +54,8 @@ CUSBCECAdapterCommands::CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm m_iSettingLAMask(0), m_bNeedsWrite(false), m_iBuildDate(CEC_FW_BUILD_UNKNOWN), - m_bControlledMode(false) + m_bControlledMode(false), + m_adapterType(P8_ADAPTERTYPE_UNKNOWN) { m_persistedConfiguration.Clear(); } @@ -84,13 +85,15 @@ uint16_t CUSBCECAdapterCommands::RequestFirmwareVersion(void) while (m_persistedConfiguration.iFirmwareVersion == CEC_FW_VERSION_UNKNOWN && iFwVersionTry++ < 3) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting the firmware version"); +#endif cec_datapacket response = RequestSetting(MSGCODE_FIRMWARE_VERSION); if (response.size == 2) m_persistedConfiguration.iFirmwareVersion = (response[0] << 8 | response[1]); else { - LIB_CEC->AddLog(CEC_LOG_WARNING, "the adapter did not respond with a correct firmware version (try %d)", iFwVersionTry); + LIB_CEC->AddLog(CEC_LOG_WARNING, "the adapter did not respond with a correct firmware version (try %d, size = %d)", iFwVersionTry, response.size); CEvent::Sleep(500); } } @@ -101,12 +104,18 @@ uint16_t CUSBCECAdapterCommands::RequestFirmwareVersion(void) m_persistedConfiguration.iFirmwareVersion = 1; } + // firmware versions < 2 don't have an autonomous mode + if (m_persistedConfiguration.iFirmwareVersion < 2) + m_bControlledMode = true; + return m_persistedConfiguration.iFirmwareVersion; } bool CUSBCECAdapterCommands::RequestSettingAutoEnabled(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting autonomous mode setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_AUTO_ENABLED); if (response.size == 1) @@ -120,7 +129,9 @@ bool CUSBCECAdapterCommands::RequestSettingAutoEnabled(void) bool CUSBCECAdapterCommands::RequestSettingCECVersion(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting CEC version setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_HDMI_VERSION); if (response.size == 1) @@ -132,11 +143,28 @@ bool CUSBCECAdapterCommands::RequestSettingCECVersion(void) return false; } +p8_cec_adapter_type CUSBCECAdapterCommands::RequestAdapterType(void) +{ + if (m_adapterType == P8_ADAPTERTYPE_UNKNOWN) + { +#ifdef CEC_DEBUGGING + LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting adapter type"); +#endif + + cec_datapacket response = RequestSetting(MSGCODE_GET_ADAPTER_TYPE); + if (response.size == 1) + m_adapterType = (p8_cec_adapter_type)response[0]; + } + return m_adapterType; +} + uint32_t CUSBCECAdapterCommands::RequestBuildDate(void) { if (m_iBuildDate == CEC_FW_BUILD_UNKNOWN) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting firmware build date"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_BUILDDATE); if (response.size == 4) @@ -147,7 +175,9 @@ uint32_t CUSBCECAdapterCommands::RequestBuildDate(void) bool CUSBCECAdapterCommands::RequestSettingDefaultLogicalAddress(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting default logical address setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_DEFAULT_LOGICAL_ADDRESS); if (response.size == 1) @@ -161,7 +191,9 @@ bool CUSBCECAdapterCommands::RequestSettingDefaultLogicalAddress(void) bool CUSBCECAdapterCommands::RequestSettingDeviceType(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting device type setting"); +#endif m_persistedConfiguration.deviceTypes.Clear(); cec_datapacket response = RequestSetting(MSGCODE_GET_DEVICE_TYPE); @@ -177,7 +209,9 @@ bool CUSBCECAdapterCommands::RequestSettingDeviceType(void) bool CUSBCECAdapterCommands::RequestSettingLogicalAddressMask(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting logical address mask setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_LOGICAL_ADDRESS_MASK); if (response.size == 2) @@ -191,7 +225,9 @@ bool CUSBCECAdapterCommands::RequestSettingLogicalAddressMask(void) bool CUSBCECAdapterCommands::RequestSettingOSDName(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting OSD name setting"); +#endif memset(m_persistedConfiguration.strDeviceName, 0, 13); cec_datapacket response = RequestSetting(MSGCODE_GET_OSD_NAME); @@ -213,7 +249,9 @@ bool CUSBCECAdapterCommands::RequestSettingOSDName(void) bool CUSBCECAdapterCommands::RequestSettingPhysicalAddress(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting physical address setting"); +#endif cec_datapacket response = RequestSetting(MSGCODE_GET_PHYSICAL_ADDRESS); if (response.size == 2) @@ -530,7 +568,9 @@ bool CUSBCECAdapterCommands::GetConfiguration(libcec_configuration &configuratio bool CUSBCECAdapterCommands::PingAdapter(void) { +#ifdef CEC_DEBUGGING LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending ping"); +#endif CCECAdapterMessage params; CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_PING, params); @@ -552,6 +592,19 @@ bool CUSBCECAdapterCommands::SetAckMask(uint16_t iMask) return bReturn; } +void CUSBCECAdapterCommands::SetActiveSource(bool bSetTo, bool bClientUnregistered) +{ + if (bClientUnregistered) return; + if (m_persistedConfiguration.iFirmwareVersion >= 3) + { + LIB_CEC->AddLog(CEC_LOG_DEBUG, "marking the adapter as %s source", bSetTo ? "active" : "inactive"); + CCECAdapterMessage params; + params.PushEscaped(bSetTo ? 1 : 0); + CCECAdapterMessage *message = m_comm->SendCommand(MSGCODE_SET_ACTIVE_SOURCE, params); + delete message; + } +} + bool CUSBCECAdapterCommands::StartBootloader(void) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "starting the bootloader");