#include "cectypes.h"
-#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_1_8_1
+#define LIBCEC_VERSION_CURRENT CEC_SERVER_VERSION_1_8_2
namespace CEC
{
* Should be called as first call to libCEC, directly after CECInitialise() and before using Open()
*/
virtual void InitVideoStandalone(void) = 0;
+
+ virtual const char *ToString(const cec_adapter_type type) = 0;
};
};
CEC_VENDOR_UNKNOWN = 0
} cec_vendor_id;
+typedef enum cec_adapter_type
+{
+ ADAPTERTYPE_UNKNOWN = 0,
+ ADAPTERTYPE_P8_EXTERNAL = 0x1,
+ ADAPTERTYPE_P8_DAUGHTERBOARD = 0x2,
+ ADAPTERTYPE_RPI = 0x100
+} cec_adapter_type;
+
typedef struct cec_menu_language
{
char language[4]; /**< the iso language code. @bug the language code is only 3 chars long, not 4. will be changed in v2.0, because changing it now would break backwards compat */
CEC_CLIENT_VERSION_1_7_1 = 0x1701,
CEC_CLIENT_VERSION_1_7_2 = 0x1702,
CEC_CLIENT_VERSION_1_8_0 = 0x1800,
- CEC_CLIENT_VERSION_1_8_1 = 0x1801
+ CEC_CLIENT_VERSION_1_8_1 = 0x1801,
+ CEC_CLIENT_VERSION_1_8_2 = 0x1802
} cec_client_version;
typedef enum cec_server_version
CEC_SERVER_VERSION_1_7_1 = 0x1701,
CEC_SERVER_VERSION_1_7_2 = 0x1702,
CEC_SERVER_VERSION_1_8_0 = 0x1800,
- CEC_SERVER_VERSION_1_8_1 = 0x1801
+ CEC_SERVER_VERSION_1_8_1 = 0x1801,
+ CEC_SERVER_VERSION_1_8_2 = 0x1802
} cec_server_version;
typedef struct libcec_configuration
uint32_t iFirmwareBuildDate; /*!< (read-only) the build date of the firmware, in seconds since epoch. if not available, this value will be set to 0. added in 1.6.2 */
uint8_t bMonitorOnly; /*!< won't allocate a CCECClient when starting the connection when set (same as monitor mode). added in 1.6.3 */
cec_version cecVersion; /*!< CEC spec version to use by libCEC. defaults to v1.4. added in 1.8.0 */
+ cec_adapter_type adapterType; /*!< type of the CEC adapter that we're connected to. added in 1.8.2 */
#ifdef __cplusplus
// @todo re-add in v2.0 (breaks ABI)
/* libcec 1.6.3+ */
(other.clientVersion < CEC_CLIENT_VERSION_1_6_3 || bMonitorOnly == other.bMonitorOnly) &&
/* libcec 1.8.0+ */
- (other.clientVersion < CEC_CLIENT_VERSION_1_8_0 || cecVersion == other.cecVersion));
+ (other.clientVersion < CEC_CLIENT_VERSION_1_8_0 || cecVersion == other.cecVersion) &&
+ /* libcec 1.8.2+ */
+ (other.clientVersion < CEC_CLIENT_VERSION_1_8_2 || adapterType == other.adapterType));
}
bool operator!=(const libcec_configuration &other) const
iFirmwareBuildDate = CEC_FW_BUILD_UNKNOWN;
bMonitorOnly = 0;
cecVersion = (cec_version)CEC_DEFAULT_SETTING_CEC_VERSION;
+ adapterType = ADAPTERTYPE_UNKNOWN;
memset(strDeviceName, 0, 13);
deviceTypes.clear();
configuration.bMonitorOnly = m_configuration.bMonitorOnly;
}
+ // client version 1.8.0
+ if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0)
+ configuration.cecVersion = m_configuration.cecVersion;
+
+ // client version 1.8.2
+ if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_2)
+ configuration.adapterType = m_configuration.adapterType;
+
return true;
}
m_configuration.bMonitorOnly = configuration.bMonitorOnly;
}
+ // client version 1.8.0
+ if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_0)
+ m_configuration.cecVersion = configuration.cecVersion;
+
+ // client version 1.8.2
+ if (configuration.clientVersion >= CEC_CLIENT_VERSION_1_8_2)
+ m_configuration.adapterType = configuration.adapterType;
+
// ensure that there is at least 1 device type set
if (m_configuration.deviceTypes.IsEmpty())
m_configuration.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
config->iFirmwareVersion = m_communication->GetFirmwareVersion();
config->iPhysicalAddress = m_communication->GetPhysicalAddress();
config->iFirmwareBuildDate = m_communication->GetFirmwareBuildDate();
+ config->adapterType = m_communication->GetAdapterType();
return true;
}
configuration.serverVersion = LIBCEC_VERSION_CURRENT;
configuration.iFirmwareVersion = m_communication->GetFirmwareVersion();
configuration.iFirmwareBuildDate = m_communication->GetFirmwareBuildDate();
+ configuration.adapterType = m_communication->GetAdapterType();
// mark the client as registered
client->SetRegistered(true);
return "1.8.0";
case CEC_CLIENT_VERSION_1_8_1:
return "1.8.1";
+ case CEC_CLIENT_VERSION_1_8_2:
+ return "1.8.2";
default:
return "Unknown";
}
return "1.8.0";
case CEC_SERVER_VERSION_1_8_1:
return "1.8.1";
+ case CEC_SERVER_VERSION_1_8_2:
+ return "1.8.2";
default:
return "Unknown";
}
return "unknown";
}
}
+
+ static const char *ToString(const cec_adapter_type type)
+ {
+ switch (type)
+ {
+ case ADAPTERTYPE_P8_EXTERNAL:
+ return "Pulse-Eight USB-CEC Adapter";
+ case ADAPTERTYPE_P8_DAUGHTERBOARD:
+ return "Pulse-Eight USB-CEC Daughterboard";
+ case ADAPTERTYPE_RPI:
+ return "Raspberry Pi";
+ default:
+ return "unknown";
+ }
+ }
};
}
CAdapterFactory::InitVideoStandalone();
}
+const char *CLibCEC::ToString(const cec_adapter_type type)
+{
+ return CCECTypeUtils::ToString(type);
+}
+
// no longer being used
void CLibCEC::AddKey(const cec_keypress &UNUSED(key)) {}
void CLibCEC::ConfigurationChanged(const libcec_configuration &UNUSED(config)) {}
const char *GetLibInfo(void);
const char *ToString(const cec_user_control_code key);
void InitVideoStandalone(void);
+ const char *ToString(const cec_adapter_type type);
CCECProcessor * m_cec;
*/
virtual bool SupportsSourceLogicalAddress(const cec_logical_address address) = 0;
+ /*!
+ * @return The type of adapter that this instance is connected to.
+ */
+ virtual cec_adapter_type GetAdapterType(void) = 0;
+
IAdapterCommunicationCallback *m_callback;
};
};
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();
}
return false;
}
+p8_cec_adapter_type CUSBCECAdapterCommands::RequestAdapterType(void)
+{
+ if (m_adapterType == P8_ADAPTERTYPE_UNKNOWN)
+ {
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "requesting adapter type");
+
+ 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)
*/
uint32_t GetPersistedBuildDate(void) const { return m_iBuildDate; };
+ /*!
+ * @brief Request the adapter type.
+ * @return The type
+ */
+ p8_cec_adapter_type RequestAdapterType(void);
+
+ /*!
+ * @return The persisted build date.
+ */
+ p8_cec_adapter_type GetPersistedAdapterType(void) const { return m_adapterType; };
+
/*!
* @brief Persist the current settings in the EEPROM
* @return True when persisted, false otherwise.
libcec_configuration m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */
uint32_t m_iBuildDate; /**< the build date of the firmware */
bool m_bControlledMode; /**< current value of the controlled mode feature */
+ p8_cec_adapter_type m_adapterType; /**< the type of the adapter that we're connected to */
PLATFORM::CMutex m_mutex;
};
}
else
bReturn = true;
- /* try to read the build date */
- m_commands->RequestBuildDate();
+ if (m_commands->GetFirmwareVersion() >= 2)
+ {
+ /* try to read the build date */
+ m_commands->RequestBuildDate();
+
+ /* try to read the adapter type */
+ m_commands->RequestAdapterType();
+ }
SetInitialised(bReturn);
return bReturn;
return iBuildDate;
}
+cec_adapter_type CUSBCECAdapterCommunication::GetAdapterType(void)
+{
+ cec_adapter_type type(ADAPTERTYPE_UNKNOWN);
+ if (m_commands)
+ type = (cec_adapter_type)m_commands->GetPersistedAdapterType();
+ if (type == ADAPTERTYPE_UNKNOWN && IsOpen())
+ type = (cec_adapter_type)m_commands->RequestAdapterType();
+
+ return type;
+}
+
bool CUSBCECAdapterCommunication::ProvidesExtendedResponse(void)
{
uint32_t iBuildDate(0);
bool SetControlledMode(bool controlled);
cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; }
bool SupportsSourceLogicalAddress(const cec_logical_address UNUSED(address)) { return true; }
+ cec_adapter_type GetAdapterType(void);
///}
bool ProvidesExtendedResponse(void);
return "SET_OSD_NAME";
case MSGCODE_WRITE_EEPROM:
return "WRITE_EEPROM";
+ case MSGCODE_GET_ADAPTER_TYPE:
+ return "GET_ADAPTER_TYPE";
default:
break;
}
MSGCODE_GET_OSD_NAME,
MSGCODE_SET_OSD_NAME,
MSGCODE_WRITE_EEPROM,
+ MSGCODE_GET_ADAPTER_TYPE,
MSGCODE_FRAME_EOM = 0x80,
MSGCODE_FRAME_ACK = 0x40,
} cec_adapter_messagecode;
+ typedef enum p8_cec_adapter_type
+ {
+ P8_ADAPTERTYPE_UNKNOWN = 0,
+ P8_ADAPTERTYPE_EXTERNAL,
+ P8_ADAPTERTYPE_DAUGHTERBOARD,
+ } p8_cec_adapter_type;
+
class CCECAdapterMessage
{
public:
bool SetControlledMode(bool UNUSED(controlled)) { return true; };
cec_vendor_id GetVendorId(void) { return CEC_VENDOR_BROADCOM; }
bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address < CECDEVICE_BROADCAST; }
+ cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_RPI; };
///}
bool IsInitialised(void);
using namespace std;
using namespace PLATFORM;
-#define CEC_CONFIG_VERSION CEC_CLIENT_VERSION_1_8_1;
+#define CEC_CONFIG_VERSION CEC_CLIENT_VERSION_1_8_2;
#include <cecloader.h>
time_t buildTime = (time_t)config.iFirmwareBuildDate;
strDeviceInfo.AppendFormat("firmware build date: %s", asctime(gmtime(&buildTime)));
strDeviceInfo = strDeviceInfo.Left(strDeviceInfo.length() > 1 ? (unsigned)(strDeviceInfo.length() - 1) : 0); // strip \n added by asctime
- strDeviceInfo.append(" +0000");
+ strDeviceInfo.append(" +0000\n");
+ }
+
+ if (config.adapterType != ADAPTERTYPE_UNKNOWN)
+ {
+ strDeviceInfo.AppendFormat("type: %s\n", parser->ToString(config.adapterType));
}
}
strDeviceInfo.append("\n");