From: Lars Op den Kamp Date: Wed, 7 Dec 2011 21:21:37 +0000 (+0100) Subject: cec: add GetDevicePhysicalAddress()/cec_get_device_physical_address() X-Git-Tag: upstream/2.2.0~1^2~44^2~22 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=eab72c4079c8f106f825f799d1f2f6218066d3ed;p=deb_libcec.git cec: add GetDevicePhysicalAddress()/cec_get_device_physical_address() --- diff --git a/include/cec.h b/include/cec.h index 44bf024..c5f0522 100644 --- a/include/cec.h +++ b/include/cec.h @@ -251,6 +251,13 @@ namespace CEC */ virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress) = 0; + /*! + * @brief Get the physical address of the device with the given logical address. + * @param iLogicalAddress The device to get the vendor id for. + * @return The physical address or 0 if it wasn't found. + */ + virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress) = 0; + /*! * @brief Sends a POLL message to a device. * @param iAddress The device to send the message to. diff --git a/include/cecc.h b/include/cecc.h index d433b3e..6508606 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -173,6 +173,12 @@ extern DECLSPEC uint64_t cec_get_device_vendor_id(CEC::cec_logical_address iLogi extern DECLSPEC uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress); #endif +#ifdef __cplusplus +extern DECLSPEC uint16_t cec_get_device_physical_address(CEC::cec_logical_address iLogicalAddress); +#else +extern DECLSPEC uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress); +#endif + #ifdef __cplusplus extern DECLSPEC CEC::cec_power_status cec_get_device_power_status(CEC::cec_logical_address iLogicalAddress); #else diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 1daa7b6..46e3419 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -521,6 +521,7 @@ bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress) for (uint8_t iPtr = 0; iPtr < 15; iPtr++) if (m_logicalAddresses[iPtr]) { + m_busDevices[iPtr]->SetInactiveDevice(); m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); m_busDevices[iPtr]->TransmitPhysicalAddress(); } @@ -669,6 +670,13 @@ uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress) return false; } +uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress) +{ + if (m_busDevices[iAddress]) + return m_busDevices[iAddress]->GetPhysicalAddress(false); + return false; +} + cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress) { if (m_busDevices[iAddress]) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 75196ea..bdf5233 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -68,6 +68,7 @@ namespace CEC virtual cec_logical_address GetLogicalAddress(void) const { return m_logicalAddresses.primary; } virtual cec_logical_addresses GetLogicalAddresses(void) const { return m_logicalAddresses; } virtual cec_logical_addresses GetActiveDevices(void); + virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress); virtual bool HasLogicalAddress(cec_logical_address address) const { return m_logicalAddresses.IsSet(address); } virtual bool IsActiveDevice(cec_logical_address address); virtual bool IsActiveDeviceType(cec_device_type type); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index ebaae2d..adf0132 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -222,6 +222,13 @@ uint64_t CLibCEC::GetDeviceVendorId(cec_logical_address iAddress) return 0; } +uint16_t CLibCEC::GetDevicePhysicalAddress(cec_logical_address iAddress) +{ + if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST) + return m_cec->GetDevicePhysicalAddress(iAddress); + return 0; +} + cec_power_status CLibCEC::GetDevicePowerStatus(cec_logical_address iAddress) { if (m_cec && iAddress >= CECDEVICE_TV && iAddress < CECDEVICE_BROADCAST) diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index a0a4ddc..9bff00f 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -82,6 +82,7 @@ namespace CEC virtual cec_version GetDeviceCecVersion(cec_logical_address iAddress); virtual bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language); virtual uint64_t GetDeviceVendorId(cec_logical_address iAddress); + virtual uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress); virtual cec_power_status GetDevicePowerStatus(cec_logical_address iAddress); virtual bool PollDevice(cec_logical_address iAddress); virtual cec_logical_addresses GetActiveDevices(void); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index dc63c29..ffa8f55 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -247,6 +247,13 @@ uint64_t cec_get_device_vendor_id(cec_logical_address iLogicalAddress) return 0; } +uint16_t cec_get_device_physical_address(cec_logical_address iLogicalAddress) +{ + if (cec_parser) + return cec_parser->GetDevicePhysicalAddress(iLogicalAddress); + return 0; +} + cec_power_status cec_get_device_power_status(cec_logical_address iLogicalAddress) { if (cec_parser) diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 7837c12..c1f3bf7 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -720,15 +720,19 @@ bool ProcessCommandSCAN(ICECAdapter *parser, const string &command, string &argu { if (addresses[iPtr]) { - uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr); - cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr); - cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr); - cec_osd_name osdName = parser->GetOSDName((cec_logical_address)iPtr); + uint16_t iPhysicalAddress = parser->GetDevicePhysicalAddress((cec_logical_address)iPtr); + uint64_t iVendorId = parser->GetDeviceVendorId((cec_logical_address)iPtr); + cec_version iCecVersion = parser->GetDeviceCecVersion((cec_logical_address)iPtr); + cec_power_status power = parser->GetDevicePowerStatus((cec_logical_address)iPtr); + cec_osd_name osdName = parser->GetOSDName((cec_logical_address)iPtr); + CStdString strAddr; + strAddr.Format("%04x", iPhysicalAddress); cec_menu_language lang; lang.device = CECDEVICE_UNKNOWN; parser->GetDeviceMenuLanguage((cec_logical_address)iPtr, &lang); cout << "device #" << (int)iPtr << ": " << parser->ToString((cec_logical_address)iPtr) << endl; + cout << "address: " << strAddr.c_str() << endl; cout << "vendor: " << parser->ToString((cec_vendor_id)iVendorId) << endl; cout << "osd string: " << osdName.name << endl; cout << "CEC version: " << parser->ToString(iCecVersion) << endl;