From: Lars Op den Kamp Date: Sun, 30 Oct 2011 17:11:25 +0000 (+0100) Subject: cec: make the vendor name available on the interface X-Git-Tag: upstream/2.2.0~1^2~159 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0500da96dfbf6f09aabb944b4127b5d2ea1b076f;p=deb_libcec.git cec: make the vendor name available on the interface --- diff --git a/include/cectypes.h b/include/cectypes.h index 53418ab..df9af81 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -690,7 +690,25 @@ typedef enum cec_vendor_id CEC_VENDOR_SAMSUNG = 0x00F0, CEC_VENDOR_LG = 0xE091, CEC_VENDOR_UNKNOWN = 0 -} vendor_id; +} cec_vendor_id; + +typedef struct cec_vendor +{ + const char *AsString(void) const + { + switch (vendor) + { + case CEC_VENDOR_SAMSUNG: + return "Samsung"; + case CEC_VENDOR_LG: + return "LG"; + default: + return "Unknown"; + } + } + + cec_vendor_id vendor; +} cec_vendor; //default physical address 1.0.0.0, HDMI port 1 #define CEC_DEFAULT_PHYSICAL_ADDRESS 0x1000 diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index dc9e620..05a8cdb 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -44,7 +44,6 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_iLogicalAddress(iLogicalAddress), m_powerStatus(CEC_POWER_STATUS_UNKNOWN), m_processor(processor), - m_iVendorId(0), m_iVendorClass(CEC_VENDOR_UNKNOWN), m_iLastActive(0), m_cecVersion(CEC_VERSION_UNKNOWN) @@ -54,6 +53,7 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi m_menuLanguage.language[iPtr] = '?'; m_menuLanguage.language[3] = 0; m_menuLanguage.device = iLogicalAddress; + m_vendor.vendor = CEC_VENDOR_UNKNOWN; } CCECBusDevice::~CCECBusDevice(void) @@ -140,7 +140,7 @@ void CCECBusDevice::SetVendorId(const cec_datapacket &data) void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */) { - m_iVendorId = iVendorId; + m_vendor.vendor = (cec_vendor_id)iVendorId; m_iVendorClass = iVendorClass; switch (iVendorId) @@ -182,9 +182,9 @@ bool CCECBusDevice::HandleCommand(const cec_command &command) return true; } -uint64_t CCECBusDevice::GetVendorId(void) +const cec_vendor &CCECBusDevice::GetVendor(void) { - if (m_iVendorId == CEC_VENDOR_UNKNOWN) + if (m_vendor.vendor == CEC_VENDOR_UNKNOWN) { AddLog(CEC_LOG_NOTICE, "<< requesting vendor ID"); cec_command command; @@ -195,14 +195,14 @@ uint64_t CCECBusDevice::GetVendorId(void) m_condition.Wait(&m_mutex, 1000); } - return m_iVendorId; + return m_vendor; } void CCECBusDevice::PollVendorId(void) { CLockObject lock(&m_mutex); if (m_iLastActive > 0 && m_iLogicalAddress != CECDEVICE_BROADCAST && - m_iVendorId == CEC_VENDOR_UNKNOWN && + m_vendor.vendor == CEC_VENDOR_UNKNOWN && GetTimeMs() - m_iLastActive > 5000) { m_iLastActive = GetTimeMs(); @@ -430,16 +430,3 @@ cec_power_status CCECBusDevice::GetPowerStatus(void) return m_powerStatus; } - -const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId) -{ - switch (iVendorId) - { - case CEC_VENDOR_SAMSUNG: - return "Samsung"; - case CEC_VENDOR_LG: - return "LG"; - default: - return "Unknown"; - } -} diff --git a/src/lib/devices/CECBusDevice.h b/src/lib/devices/CECBusDevice.h index db89f40..66948ad 100644 --- a/src/lib/devices/CECBusDevice.h +++ b/src/lib/devices/CECBusDevice.h @@ -48,8 +48,9 @@ namespace CEC virtual cec_logical_address GetMyLogicalAddress(void) const; virtual uint16_t GetMyPhysicalAddress(void) const; - virtual const char * GetVendorName(void) const { return CECVendorIdToString(m_iVendorId); } - virtual uint64_t GetVendorId(void); + virtual const char * GetVendorName(void) { return GetVendor().AsString(); } + virtual cec_vendor_id GetVendorId(void) { return GetVendor().vendor; }; + virtual const cec_vendor & GetVendor(void); virtual uint8_t GetVendorClass(void) const { return m_iVendorClass; } virtual uint64_t GetLastActive(void) const { return m_iLastActive; } virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; } @@ -88,8 +89,6 @@ namespace CEC virtual bool BroadcastPhysicalAddress(void); virtual bool BroadcastActiveSource(void); - static const char *CECVendorIdToString(const uint64_t iVendorId); - protected: uint16_t m_iPhysicalAddress; cec_logical_address m_iLogicalAddress; @@ -97,7 +96,7 @@ namespace CEC cec_menu_language m_menuLanguage; CCECProcessor *m_processor; CCECCommandHandler *m_handler; - uint64_t m_iVendorId; + cec_vendor m_vendor; uint8_t m_iVendorClass; uint64_t m_iLastActive; cec_version m_cecVersion;