From a99a360496be855103a51ef6891385cb1897b1ef Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Fri, 31 Oct 2014 22:05:16 +0100 Subject: [PATCH] libcec: update to libcec-2.2.0 Signed-off-by: Stephan Raue --- packages/devel/libcec/package.mk | 6 +- .../patches/libcec-mk01-RPi-fixes.patch | 462 ------ .../patches/libcec-mk01-imx6-supprt.patch | 1428 +++++------------ .../patches/libcec-mk01-libCEC-fixes.patch | 37 - 4 files changed, 369 insertions(+), 1564 deletions(-) delete mode 100644 packages/devel/libcec/patches/libcec-mk01-RPi-fixes.patch delete mode 100644 packages/devel/libcec/patches/libcec-mk01-libCEC-fixes.patch diff --git a/packages/devel/libcec/package.mk b/packages/devel/libcec/package.mk index 0aeee1b448..dd86c04d6b 100644 --- a/packages/devel/libcec/package.mk +++ b/packages/devel/libcec/package.mk @@ -17,12 +17,12 @@ ################################################################################ PKG_NAME="libcec" -PKG_VERSION="2.1.4" +PKG_VERSION="2.2.0" PKG_REV="1" PKG_ARCH="any" PKG_LICENSE="GPL" PKG_SITE="http://libcec.pulse-eight.com/" -PKG_URL="http://packages.pulse-eight.net/pulse/sources/libcec/$PKG_NAME-$PKG_VERSION.tar.gz" +PKG_URL="http://mirrors.xbmc.org/build-deps/sources/$PKG_NAME-$PKG_VERSION-2.tar.gz" PKG_DEPENDS_TARGET="toolchain systemd lockdev" PKG_PRIORITY="optional" PKG_SECTION="system" @@ -32,7 +32,7 @@ PKG_LONGDESC="libCEC is an open-source dual licensed library designed for commun PKG_IS_ADDON="no" PKG_AUTORECONF="yes" -PKG_CONFIGURE_OPTS_TARGET="--disable-cubox" +PKG_CONFIGURE_OPTS_TARGET="--disable-cubox --disable-exynos" if [ "$KODIPLAYER_DRIVER" = "bcm2835-driver" ]; then PKG_DEPENDS_TARGET="$PKG_DEPENDS_TARGET bcm2835-driver" diff --git a/packages/devel/libcec/patches/libcec-mk01-RPi-fixes.patch b/packages/devel/libcec/patches/libcec-mk01-RPi-fixes.patch deleted file mode 100644 index aeaa490e2b..0000000000 --- a/packages/devel/libcec/patches/libcec-mk01-RPi-fixes.patch +++ /dev/null @@ -1,462 +0,0 @@ -From 38b8eaae3ef151943595c4033b628a7c98d90c64 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Tue, 15 Apr 2014 11:07:00 +0200 -Subject: [PATCH 1/5] fix RPI POLL during LA address negotiation - ---- - src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp | 13 +++++++++---- - 1 file changed, 9 insertions(+), 4 deletions(-) - -diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -index 76c61b3..2905c56 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -+++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -@@ -382,13 +382,18 @@ cec_adapter_message_state CRPiCECAdapterCommunication::Write(const cec_command & - return (data.initiator == data.destination) ? ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED : ADAPTER_MESSAGE_STATE_ERROR; - } - -- if (!data.opcode_set && data.initiator == data.destination) -+ if (!m_queue->Write(data, bIsReply)) - { -- // registration of the logical address would have failed -- return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; -+ if (!data.opcode_set) -+ { -+ return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; -+ } -+ -+ return ADAPTER_MESSAGE_STATE_SENT; - } - -- return m_queue->Write(data, bIsReply) ? ADAPTER_MESSAGE_STATE_SENT_ACKED : ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; -+ return ADAPTER_MESSAGE_STATE_SENT_ACKED; -+ - } - - uint16_t CRPiCECAdapterCommunication::GetFirmwareVersion(void) - -From 485660f88df81ef5e535a074b1385c49bc687489 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Sun, 20 Apr 2014 22:24:03 +0200 -Subject: [PATCH 2/5] fix assertion on XBMC exit - ---- - src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -index 2905c56..243223d 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -+++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -@@ -353,7 +353,8 @@ void CRPiCECAdapterCommunication::Close(void) - else - return; - } -- vc_tv_unregister_callback(rpi_tv_callback); -+ if (m_bInitialised) -+ vc_tv_unregister_callback(rpi_tv_callback); - - UnregisterLogicalAddress(); - - -From f9c4a2de412487b78c333dc21d9b7e41a5fe69e3 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Mon, 26 May 2014 20:56:10 +0200 -Subject: [PATCH 4/5] RPI updates with fixes - losing device from TVs menu on - source changes - XBMC Input Device settings change will not freeze XBMC (or - disable adapter) - TV auto connection to adapter properly upon AS command - - imposibility to switch back to RPI even if listed by TV - -it is possible it fixes some others as well ---- - src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp | 97 +++++++--------------- - src/lib/adapter/RPi/RPiCECAdapterCommunication.h | 2 +- - src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp | 50 ++++++++--- - src/lib/adapter/RPi/RPiCECAdapterMessageQueue.h | 13 ++- - 4 files changed, 79 insertions(+), 83 deletions(-) - -diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -index 243223d..9af5357 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -+++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.cpp -@@ -78,7 +78,9 @@ CRPiCECAdapterCommunication::CRPiCECAdapterCommunication(IAdapterCommunicationCa - CRPiCECAdapterCommunication::~CRPiCECAdapterCommunication(void) - { - delete(m_queue); -+ UnregisterLogicalAddress(); - Close(); -+ vc_cec_set_passive(false); - } - - const char *ToString(const VC_CEC_ERROR_T error) -@@ -212,6 +214,7 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u - { - m_bLogicalAddressChanged = true; - m_logicalAddress = (cec_logical_address)(p0 & 0xF); -+ m_bLogicalAddressRegistered = true; - LIB_CEC->AddLog(CEC_LOG_DEBUG, "logical address changed to %s (%x)", LIB_CEC->ToString(m_logicalAddress), m_logicalAddress); - } - else -@@ -224,8 +227,9 @@ void CRPiCECAdapterCommunication::OnDataReceived(uint32_t header, uint32_t p0, u - break; - case VC_CEC_LOGICAL_ADDR_LOST: - { -+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "logical %s (%x) address lost", LIB_CEC->ToString(m_logicalAddress), m_logicalAddress); - // the logical address was taken by another device -- cec_logical_address previousAddress = m_logicalAddress == CECDEVICE_BROADCAST ? m_previousLogicalAddress : m_logicalAddress; -+ cec_logical_address previousAddress = m_logicalAddress == CECDEVICE_FREEUSE ? m_previousLogicalAddress : m_logicalAddress; - m_logicalAddress = CECDEVICE_UNKNOWN; - - // notify libCEC that we lost our LA when the connection was initialised -@@ -305,23 +309,18 @@ bool CRPiCECAdapterCommunication::Open(uint32_t iTimeoutMs /* = CEC_DEFAULT_CONN - vc_cec_register_callback(rpi_cec_callback, (void*)this); - vc_tv_register_callback(rpi_tv_callback, (void*)this); - -- // release previous LA -- vc_cec_release_logical_address(); -- if (!m_logicalAddressCondition.Wait(m_mutex, m_bLogicalAddressChanged, iTimeoutMs)) -- { -- LIB_CEC->AddLog(CEC_LOG_ERROR, "failed to release the previous LA"); -- return false; -- } -- - // register LA "freeuse" -- if (RegisterLogicalAddress(CECDEVICE_FREEUSE)) -+ if (RegisterLogicalAddress(CECDEVICE_FREEUSE, iTimeoutMs)) - { - LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - vc_cec initialised", __FUNCTION__); - CLockObject lock(m_mutex); - m_bInitialised = true; - } - else -+ { - LIB_CEC->AddLog(CEC_LOG_ERROR, "%s - vc_cec could not be initialised", __FUNCTION__); -+ return false; -+ } - } - - return true; -@@ -346,20 +345,10 @@ uint16_t CRPiCECAdapterCommunication::GetPhysicalAddress(void) - - void CRPiCECAdapterCommunication::Close(void) - { -- { -- CLockObject lock(m_mutex); -- if (m_bInitialised) -- m_bInitialised = false; -- else -- return; -- } -- if (m_bInitialised) -+ if (m_bInitialised) { - vc_tv_unregister_callback(rpi_tv_callback); -- -- UnregisterLogicalAddress(); -- -- // disable passive mode -- vc_cec_set_passive(false); -+ m_bInitialised = false; -+ } - - if (!g_bHostInited) - { -@@ -374,27 +363,16 @@ std::string CRPiCECAdapterCommunication::GetError(void) const - return strError; - } - --cec_adapter_message_state CRPiCECAdapterCommunication::Write(const cec_command &data, bool &UNUSED(bRetry), uint8_t UNUSED(iLineTimeout), bool bIsReply) -+cec_adapter_message_state CRPiCECAdapterCommunication::Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool bIsReply) - { -- // ensure that the source LA is registered -- if (!RegisterLogicalAddress(data.initiator)) -- { -- LIB_CEC->AddLog(CEC_LOG_DEBUG, "failed to register logical address %s (%X)", CCECTypeUtils::ToString(data.initiator), data.initiator); -- return (data.initiator == data.destination) ? ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED : ADAPTER_MESSAGE_STATE_ERROR; -- } -- -- if (!m_queue->Write(data, bIsReply)) -- { -- if (!data.opcode_set) -- { -- return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; -- } -- -- return ADAPTER_MESSAGE_STATE_SENT; -- } -- -- return ADAPTER_MESSAGE_STATE_SENT_ACKED; -+ VC_CEC_ERROR_T vcAnswer; -+ uint32_t iTimeout = (data.transmit_timeout ? data.transmit_timeout : iLineTimeout*1000); - -+ cec_adapter_message_state rc = m_queue->Write(data, bRetry, iTimeout, bIsReply, vcAnswer); -+#ifdef CEC_DEBUGGING -+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending data: result %s", ToString(vcAnswer)); -+#endif -+ return rc; - } - - uint16_t CRPiCECAdapterCommunication::GetFirmwareVersion(void) -@@ -404,22 +382,15 @@ uint16_t CRPiCECAdapterCommunication::GetFirmwareVersion(void) - - cec_logical_address CRPiCECAdapterCommunication::GetLogicalAddress(void) - { -- { -- CLockObject lock(m_mutex); -- if (m_logicalAddress != CECDEVICE_UNKNOWN) -- return m_logicalAddress; -- } -+ CLockObject lock(m_mutex); - -- CEC_AllDevices_T address; -- return (vc_cec_get_logical_address(&address) == VCHIQ_SUCCESS) ? -- (cec_logical_address)address : CECDEVICE_UNKNOWN; -+ return m_logicalAddress; - } - - bool CRPiCECAdapterCommunication::UnregisterLogicalAddress(void) - { - CLockObject lock(m_mutex); -- if (m_logicalAddress == CECDEVICE_UNKNOWN || -- m_logicalAddress == CECDEVICE_BROADCAST) -+ if (!m_bInitialised) - return true; - - LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - releasing previous logical address", __FUNCTION__); -@@ -434,34 +405,25 @@ bool CRPiCECAdapterCommunication::UnregisterLogicalAddress(void) - return m_logicalAddressCondition.Wait(m_mutex, m_bLogicalAddressChanged); - } - --bool CRPiCECAdapterCommunication::RegisterLogicalAddress(const cec_logical_address address) -+bool CRPiCECAdapterCommunication::RegisterLogicalAddress(const cec_logical_address address, uint32_t iTimeoutMs) - { - { - CLockObject lock(m_mutex); -- if (m_logicalAddress == address) -+ if ((m_logicalAddress == address) && m_bLogicalAddressRegistered) - return true; - } - -- if (!UnregisterLogicalAddress()) -- return false; -- -- LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s - registering address %x", __FUNCTION__, address); -- -- CLockObject lock(m_mutex); - m_bLogicalAddressChanged = false; -- vc_cec_poll_address((CEC_AllDevices_T)address); - - // register the new LA - int iRetval = vc_cec_set_logical_address((CEC_AllDevices_T)address, (CEC_DEVICE_TYPE_T)CCECTypeUtils::GetType(address), CEC_VENDOR_ID_BROADCOM); - if (iRetval != VCHIQ_SUCCESS) - { - LIB_CEC->AddLog(CEC_LOG_ERROR, "%s - vc_cec_set_logical_address(%X) returned %s (%d)", __FUNCTION__, address, ToString((VC_CEC_ERROR_T)iRetval), iRetval); -- return false; -+ UnregisterLogicalAddress(); - } -- -- if (m_logicalAddressCondition.Wait(m_mutex, m_bLogicalAddressChanged)) -+ else if (m_logicalAddressCondition.Wait(m_mutex, m_bLogicalAddressChanged, iTimeoutMs)) - { -- m_bLogicalAddressRegistered = true; - return true; - } - return false; -@@ -470,9 +432,8 @@ bool CRPiCECAdapterCommunication::RegisterLogicalAddress(const cec_logical_addre - cec_logical_addresses CRPiCECAdapterCommunication::GetLogicalAddresses(void) - { - cec_logical_addresses addresses; addresses.Clear(); -- cec_logical_address current = GetLogicalAddress(); -- if (current != CECDEVICE_UNKNOWN) -- addresses.Set(current); -+ if (m_bLogicalAddressRegistered) -+ addresses.primary = GetLogicalAddress(); - - return addresses; - } -diff --git a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h -index 7fbc105..e6a6446 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterCommunication.h -+++ b/src/lib/adapter/RPi/RPiCECAdapterCommunication.h -@@ -97,7 +97,7 @@ namespace CEC - private: - cec_logical_address GetLogicalAddress(void); - bool UnregisterLogicalAddress(void); -- bool RegisterLogicalAddress(const cec_logical_address address); -+ bool RegisterLogicalAddress(const cec_logical_address address, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); - int InitHostCEC(void); - - bool m_bInitialised; /**< true when the connection is initialised, false otherwise */ -diff --git a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp -index aa9701d..cb9fed0 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp -+++ b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.cpp -@@ -71,9 +71,12 @@ void CRPiCECAdapterMessageQueueEntry::Broadcast(void) - - bool CRPiCECAdapterMessageQueueEntry::MessageReceived(cec_opcode opcode, cec_logical_address initiator, cec_logical_address destination, uint32_t response) - { -- if ((!m_command.opcode_set || m_command.opcode == opcode) && -- m_command.initiator == initiator && -- m_command.destination == destination) -+ if ((m_command.opcode_set && m_command.opcode == opcode && -+ m_command.initiator == initiator && -+ m_command.destination == destination) -+ || -+ (!m_command.opcode_set && -+ m_command.destination == destination)) - { - CLockObject lock(m_mutex); - m_retval = response; -@@ -93,9 +96,6 @@ bool CRPiCECAdapterMessageQueueEntry::Wait(uint32_t iTimeout) - CLockObject lock(m_mutex); - bReturn = m_bSucceeded ? true : m_condition.Wait(m_mutex, m_bSucceeded, iTimeout); - m_bWaiting = false; -- -- if (bReturn) -- bReturn = m_retval == VCHIQ_SUCCESS; - } - return bReturn; - } -@@ -124,7 +124,12 @@ void CRPiCECAdapterMessageQueue::MessageReceived(cec_opcode opcode, cec_logical_ - LIB_CEC->AddLog(CEC_LOG_WARNING, "unhandled response received: opcode=%x initiator=%x destination=%x response=%x", (int)opcode, (int)initiator, (int)destination, response); - } - --bool CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool bIsReply) -+uint32_t CRPiCECAdapterMessageQueueEntry::Result() const -+{ -+ return m_retval; -+} -+ -+cec_adapter_message_state CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool &bRetry, uint32_t iLineTimeout, bool bIsReply, VC_CEC_ERROR_T &vcReply) - { - CRPiCECAdapterMessageQueueEntry *entry = new CRPiCECAdapterMessageQueueEntry(this, command); - uint64_t iEntryId(0); -@@ -182,24 +187,43 @@ bool CRPiCECAdapterMessageQueue::Write(const cec_command &command, bool bIsReply - LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending data: %s", strDump.c_str()); - #endif - -- int iReturn = vc_cec_send_message((uint32_t)command.destination, (uint8_t*)&payload, iLength, bIsReply); -+ int iReturn = vc_cec_send_message((uint32_t)command.destination, command.opcode_set ? (uint8_t*)&payload : NULL, iLength, bIsReply); - #endif - -+ bRetry = false; - if (iReturn != VCHIQ_SUCCESS) - { - LIB_CEC->AddLog(CEC_LOG_DEBUG, "sending command '%s' failed (%d)", command.opcode_set ? CCECTypeUtils::ToString(command.opcode) : "POLL", iReturn); - delete (entry); -- return false; -+ return ADAPTER_MESSAGE_STATE_ERROR; - } - -- bool bReturn(true); -+ cec_adapter_message_state bReturn(ADAPTER_MESSAGE_STATE_ERROR); - if (entry) - { -- if (!entry->Wait(CEC_DEFAULT_TRANSMIT_WAIT)) -+ if (entry->Wait(iLineTimeout)) - { -- LIB_CEC->AddLog(CEC_LOG_DEBUG, "command '%s' was not acked by the controller", command.opcode_set ? CCECTypeUtils::ToString(command.opcode) : "POLL"); -- bReturn = false; -+ int status = entry->Result(); -+ -+ if (status == VC_CEC_ERROR_NO_ACK) -+ bReturn = ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; -+ else if (status == VC_CEC_SUCCESS) -+ bReturn = ADAPTER_MESSAGE_STATE_SENT_ACKED; -+ else -+ bReturn = ADAPTER_MESSAGE_STATE_SENT; - } -+ else -+ { -+ if (command.opcode_set) -+ { -+ bRetry = true; -+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "command '%s' timeout", command.opcode_set ? CCECTypeUtils::ToString(command.opcode) : "POLL"); -+ sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT); -+ } -+ bReturn = ADAPTER_MESSAGE_STATE_WAITING_TO_BE_SENT; -+ } -+ -+ vcReply = (VC_CEC_ERROR_T)entry->Result(); - - CLockObject lock(m_mutex); - m_messages.erase(iEntryId); -diff --git a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.h b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.h -index af5756b..a6f4d7e 100644 ---- a/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.h -+++ b/src/lib/adapter/RPi/RPiCECAdapterMessageQueue.h -@@ -33,6 +33,12 @@ - - #include "lib/platform/util/buffer.h" - #include -+#include "lib/adapter/AdapterCommunication.h" -+ -+extern "C" { -+#include -+#include -+} - - namespace CEC - { -@@ -65,6 +71,11 @@ namespace CEC - bool IsWaiting(void); - - /*! -+ * @brief Query result from worker thread -+ */ -+ uint32_t Result() const; -+ -+ /*! - * @return The command that was sent in human readable form. - */ - const char *ToString(void) const { return "CEC transmission"; } -@@ -106,7 +117,7 @@ namespace CEC - - void MessageReceived(cec_opcode opcode, cec_logical_address initiator, cec_logical_address destination, uint32_t response); - -- bool Write(const cec_command &command, bool bIsReply); -+ cec_adapter_message_state Write(const cec_command &command, bool &bRetry, uint32_t iLineTimeout, bool bIsReply, VC_CEC_ERROR_T &vcReply); - - private: - CRPiCECAdapterCommunication * m_com; /**< the communication handler */ - -From 0ba92c2d4fb9088e52c9a0d80169fd86d48156b8 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Mon, 26 May 2014 20:59:17 +0200 -Subject: [PATCH 5/5] probably ugly hack to help with some newer Samsung TVs - and activating source - ---- - src/lib/implementations/ANCommandHandler.cpp | 10 ++++++++++ - src/lib/implementations/ANCommandHandler.h | 1 + - 2 files changed, 11 insertions(+) - -diff --git a/src/lib/implementations/ANCommandHandler.cpp b/src/lib/implementations/ANCommandHandler.cpp -index 7e0e9b9..93e8c92 100644 ---- a/src/lib/implementations/ANCommandHandler.cpp -+++ b/src/lib/implementations/ANCommandHandler.cpp -@@ -116,3 +116,13 @@ int CANCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &comman - } - return CEC_ABORT_REASON_INVALID_OPERAND; - } -+ -+int CANCommandHandler::HandleSetMenuLanguage(const cec_command &command) -+{ -+ if (m_processor->CECInitialised() && command.initiator == CECDEVICE_TV && command.destination == CECDEVICE_BROADCAST) -+ { -+ m_processor->GetDevice(command.initiator)->SetPowerStatus(CEC_POWER_STATUS_ON); -+ } -+ -+ return CCECCommandHandler::HandleSetMenuLanguage(command); -+} -diff --git a/src/lib/implementations/ANCommandHandler.h b/src/lib/implementations/ANCommandHandler.h -index 595170a..73d3cae 100644 ---- a/src/lib/implementations/ANCommandHandler.h -+++ b/src/lib/implementations/ANCommandHandler.h -@@ -47,6 +47,7 @@ namespace CEC - - int HandleVendorRemoteButtonDown(const cec_command &command); - int HandleDeviceVendorCommandWithId(const cec_command &command); -+ int HandleSetMenuLanguage(const cec_command &command); - - protected: - bool PowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination); diff --git a/packages/devel/libcec/patches/libcec-mk01-imx6-supprt.patch b/packages/devel/libcec/patches/libcec-mk01-imx6-supprt.patch index 18d98ed915..ebb78de8d4 100644 --- a/packages/devel/libcec/patches/libcec-mk01-imx6-supprt.patch +++ b/packages/devel/libcec/patches/libcec-mk01-imx6-supprt.patch @@ -1,34 +1,7 @@ -From 36a63772ea697682613b71e8b578fe005e309d68 Mon Sep 17 00:00:00 2001 -From: wolfgar -Date: Sat, 28 Sep 2013 13:31:13 +0200 -Subject: [PATCH 1/2] Early support for i.MX6 - -Fix compiler warning (or even error depending on fpermissive flag) - -Fix adapter thanks to geexbox and rudi (0003-fix-adapter-factory.patch) ---- - configure.ac | 19 ++ - include/cectypes.h | 14 +- - src/lib/CECTypeUtils.h | 2 + - src/lib/Makefile.am | 5 + - src/lib/adapter/AdapterFactory.cpp | 29 ++- - src/lib/adapter/IMX/AdapterMessageQueue.h | 134 ++++++++++ - src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp | 279 +++++++++++++++++++++ - src/lib/adapter/IMX/IMXCECAdapterCommunication.h | 114 +++++++++ - src/lib/adapter/IMX/IMXCECAdapterDetection.cpp | 42 ++++ - src/lib/adapter/IMX/IMXCECAdapterDetection.h | 36 +++ - 10 files changed, 671 insertions(+), 3 deletions(-) - create mode 100644 src/lib/adapter/IMX/AdapterMessageQueue.h - create mode 100644 src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp - create mode 100644 src/lib/adapter/IMX/IMXCECAdapterCommunication.h - create mode 100644 src/lib/adapter/IMX/IMXCECAdapterDetection.cpp - create mode 100644 src/lib/adapter/IMX/IMXCECAdapterDetection.h - -diff --git a/configure.ac b/configure.ac -index 510d851..923d7e5 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -93,6 +93,14 @@ if test "x$use_rpi" != "xno"; then +diff -Naur libcec-2.2-8d84f8b/configure.ac libcec-2.2-8d84f8b.patch/configure.ac +--- libcec-2.2-8d84f8b/configure.ac 2014-10-27 12:55:30.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/configure.ac 2014-10-27 13:11:03.726445999 +0100 +@@ -100,6 +100,14 @@ esac fi @@ -43,10 +16,10 @@ index 510d851..923d7e5 100644 ## add the top dir and include to the include path, so we can include config.h and cec.h CPPFLAGS="$CPPFLAGS -I\$(abs_top_srcdir)/src -I\$(abs_top_srcdir)/include" -@@ -270,6 +278,17 @@ else - features="$features\n TDA995x support :\t\t\tno" +@@ -305,6 +313,17 @@ fi + +## mark i.MX6 support as available +if test "x$use_imx6" != "xno"; then + AC_DEFINE([HAVE_IMX_API],[1],[Define to 1 to include i.MX6 support]) @@ -61,12 +34,11 @@ index 510d851..923d7e5 100644 ## check if our build system is complete AC_CHECK_HEADER(algorithm,,AC_MSG_ERROR($msg_required_header_missing)) AC_CHECK_HEADER(ctype.h,,AC_MSG_ERROR($msg_required_header_missing)) -diff --git a/include/cectypes.h b/include/cectypes.h -index 9f86253..7fabf00 100644 ---- a/include/cectypes.h -+++ b/include/cectypes.h -@@ -295,6 +295,17 @@ namespace CEC { - #define CEC_TDA995x_VIRTUAL_COM "CuBox" +diff -Naur libcec-2.2-8d84f8b/include/cectypes.h libcec-2.2-8d84f8b.patch/include/cectypes.h +--- libcec-2.2-8d84f8b/include/cectypes.h 2014-10-27 12:55:30.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/include/cectypes.h 2014-10-27 13:12:22.785470074 +0100 +@@ -306,6 +306,17 @@ + #define CEC_EXYNOS_VIRTUAL_COM "Exynos" /*! + * the path to use for the i.MX CEC wire @@ -83,50 +55,21 @@ index 9f86253..7fabf00 100644 * Mimimum client version */ #define CEC_MIN_LIB_VERSION 2 -@@ -858,7 +869,8 @@ typedef enum cec_adapter_type - ADAPTERTYPE_P8_EXTERNAL = 0x1, +@@ -887,7 +898,8 @@ ADAPTERTYPE_P8_DAUGHTERBOARD = 0x2, ADAPTERTYPE_RPI = 0x100, -- ADAPTERTYPE_TDA995x = 0x200 -+ ADAPTERTYPE_TDA995x = 0x200, -+ ADAPTERTYPE_IMX = 0x300, + ADAPTERTYPE_TDA995x = 0x200, +- ADAPTERTYPE_EXYNOS = 0x300 ++ ADAPTERTYPE_EXYNOS = 0x300, ++ ADAPTERTYPE_IMX = 0x400 } cec_adapter_type; typedef struct cec_menu_language -diff --git a/src/lib/CECTypeUtils.h b/src/lib/CECTypeUtils.h -index dc4e5f1..1cf7ef1 100644 ---- a/src/lib/CECTypeUtils.h -+++ b/src/lib/CECTypeUtils.h -@@ -858,6 +858,8 @@ namespace CEC - return "Raspberry Pi"; - case ADAPTERTYPE_TDA995x: - return "TDA995x"; -+ case ADAPTERTYPE_IMX: -+ return "i.MX"; - default: - return "unknown"; - } -diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am -index 9117d8e..6788303 100644 ---- a/src/lib/Makefile.am -+++ b/src/lib/Makefile.am -@@ -59,5 +59,10 @@ libcec_la_SOURCES += adapter/TDA995x/TDA995xCECAdapterDetection.cpp \ - adapter/TDA995x/TDA995xCECAdapterCommunication.cpp - endif - -+## i.MX6 support -+if USE_IMX_API -+libcec_la_SOURCES += adapter/IMX/IMXCECAdapterDetection.cpp \ -+ adapter/IMX/IMXCECAdapterCommunication.cpp -+endif - - libcec_la_LDFLAGS = @LIBS_LIBCEC@ -version-info @VERSION@ -diff --git a/src/lib/adapter/AdapterFactory.cpp b/src/lib/adapter/AdapterFactory.cpp -index 42cdd0b..576589f 100644 ---- a/src/lib/adapter/AdapterFactory.cpp -+++ b/src/lib/adapter/AdapterFactory.cpp -@@ -52,6 +52,11 @@ - #include "TDA995x/TDA995xCECAdapterCommunication.h" +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/AdapterFactory.cpp libcec-2.2-8d84f8b.patch/src/lib/adapter/AdapterFactory.cpp +--- libcec-2.2-8d84f8b/src/lib/adapter/AdapterFactory.cpp 2014-10-27 12:55:30.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/AdapterFactory.cpp 2014-10-27 13:16:07.856765188 +0100 +@@ -57,6 +57,11 @@ + #include "Exynos/ExynosCECAdapterCommunication.h" #endif +#if defined(HAVE_IMX_API) @@ -137,10 +80,10 @@ index 42cdd0b..576589f 100644 using namespace std; using namespace CEC; -@@ -109,7 +114,22 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8 - } +@@ -127,7 +132,22 @@ #endif + -#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) + +#if defined(HAVE_IMX_API) @@ -161,170 +104,24 @@ index 42cdd0b..576589f 100644 #error "libCEC doesn't have support for any type of adapter. please check your build system or configuration" #endif -@@ -128,11 +148,16 @@ IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_ - return new CRPiCECAdapterCommunication(m_lib->m_cec); +@@ -155,7 +175,12 @@ + return new CUSBCECAdapterCommunication(m_lib->m_cec, strPort, iBaudRate); #endif +-#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_EXYNOS_API) +#if defined(HAVE_IMX_API) + if (!strcmp(strPort, CEC_IMX_VIRTUAL_COM)) + return new CIMXCECAdapterCommunication(m_lib->m_cec); +#endif + - #if defined(HAVE_P8_USB) - return new CUSBCECAdapterCommunication(m_lib->m_cec, strPort, iBaudRate); - #endif - --#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) -+#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_IMX_API) ++#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_EXYNOS_API) && !defined(HAVE_IMX_API) return NULL; #endif } -diff --git a/src/lib/adapter/IMX/AdapterMessageQueue.h b/src/lib/adapter/IMX/AdapterMessageQueue.h -new file mode 100644 -index 0000000..c8bcf71 ---- /dev/null -+++ b/src/lib/adapter/IMX/AdapterMessageQueue.h -@@ -0,0 +1,134 @@ -+#pragma once -+/* -+ * This file is part of the libCEC(R) library. -+ * -+ * 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. -+ * -+ * This program is dual-licensed; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * -+ * Alternatively, you can license this library under a commercial license, -+ * please contact Pulse-Eight Licensing for more information. -+ * -+ * For more information contact: -+ * Pulse-Eight Licensing -+ * http://www.pulse-eight.com/ -+ * http://www.pulse-eight.net/ -+ */ -+ -+#include "lib/platform/threads/mutex.h" -+ -+namespace CEC -+{ -+ using namespace PLATFORM; -+ -+ class CAdapterMessageQueueEntry -+ { -+ public: -+ CAdapterMessageQueueEntry(const cec_command &command) -+ : m_bWaiting(true), m_retval((uint32_t)-1), m_bSucceeded(false) -+ { -+ m_hash = hashValue( -+ uint32_t(command.opcode_set ? command.opcode : CEC_OPCODE_NONE), -+ command.initiator, command.destination); -+ } -+ -+ virtual ~CAdapterMessageQueueEntry(void) {} -+ -+ /*! -+ * @brief Query result from worker thread -+ */ -+ uint32_t Result() const -+ { -+ return m_retval; -+ } -+ -+ /*! -+ * @brief Signal waiting threads -+ */ -+ void Broadcast(void) -+ { -+ CLockObject lock(m_mutex); -+ m_condition.Broadcast(); -+ } -+ -+ /*! -+ * @brief Signal waiting thread(s) when message matches this entry -+ */ -+ bool CheckMatch(uint32_t opcode, cec_logical_address initiator, -+ cec_logical_address destination, uint32_t response) -+ { -+ uint32_t hash = hashValue(opcode, initiator, destination); -+ -+ if (hash == m_hash) -+ { -+ CLockObject lock(m_mutex); -+ -+ m_retval = response; -+ m_bSucceeded = true; -+ m_condition.Signal(); -+ return true; -+ } -+ -+ return false; -+ } -+ -+ /*! -+ * @brief Wait for a response to this command. -+ * @param iTimeout The timeout to use while waiting. -+ * @return True when a response was received before the timeout passed, false otherwise. -+ */ -+ bool Wait(uint32_t iTimeout) -+ { -+ CLockObject lock(m_mutex); -+ -+ bool bReturn = m_bSucceeded ? true : m_condition.Wait(m_mutex, m_bSucceeded, iTimeout); -+ m_bWaiting = false; -+ return bReturn; -+ } -+ -+ /*! -+ * @return True while a thread is waiting for a signal or isn't waiting yet, false otherwise. -+ */ -+ bool IsWaiting(void) -+ { -+ CLockObject lock(m_mutex); -+ return m_bWaiting; -+ } -+ -+ /*! -+ * @return Hash value for given cec_command -+ */ -+ static uint32_t hashValue(uint32_t opcode, -+ cec_logical_address initiator, -+ cec_logical_address destination) -+ { -+ return 1 | ((uint32_t)initiator << 8) | -+ ((uint32_t)destination << 16) | ((uint32_t)opcode << 16); -+ } -+ -+ private: -+ bool m_bWaiting; /**< true while a thread is waiting or when it hasn't started waiting yet */ -+ PLATFORM::CCondition m_condition; /**< the condition to wait on */ -+ PLATFORM::CMutex m_mutex; /**< mutex for changes to this class */ -+ uint32_t m_hash; -+ uint32_t m_retval; -+ bool m_bSucceeded; -+ }; -+ -+}; -diff --git a/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp -new file mode 100644 -index 0000000..54e5662 ---- /dev/null -+++ b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp -@@ -0,0 +1,279 @@ +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp 2014-10-27 13:11:03.735446822 +0100 +@@ -0,0 +1,367 @@ +/* + * This file is part of the libCEC(R) library. + * @@ -334,6 +131,7 @@ index 0000000..54e5662 + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * IMX adpater port is Copyright (C) 2013 by Stephan Rafin ++ * Copyright (C) 2014 by Matus Kral + * + * You can redistribute this file and/or modify + * it under the terms of the GNU General Public License as published by @@ -361,37 +159,12 @@ index 0000000..54e5662 +#include "lib/LibCEC.h" +#include "lib/platform/sockets/cdevsocket.h" +#include "lib/platform/util/StdString.h" -+#include "lib/platform/util/buffer.h" -+ -+/* -+ * Ioctl definitions from kernel header -+ */ -+#define HDMICEC_IOC_MAGIC 'H' -+#define HDMICEC_IOC_SETLOGICALADDRESS _IOW(HDMICEC_IOC_MAGIC, 1, unsigned char) -+#define HDMICEC_IOC_STARTDEVICE _IO(HDMICEC_IOC_MAGIC, 2) -+#define HDMICEC_IOC_STOPDEVICE _IO(HDMICEC_IOC_MAGIC, 3) -+#define HDMICEC_IOC_GETPHYADDRESS _IOR(HDMICEC_IOC_MAGIC, 4, unsigned char[4]) -+ -+#define MAX_CEC_MESSAGE_LEN 17 -+ -+#define MESSAGE_TYPE_RECEIVE_SUCCESS 1 -+#define MESSAGE_TYPE_NOACK 2 -+#define MESSAGE_TYPE_DISCONNECTED 3 -+#define MESSAGE_TYPE_CONNECTED 4 -+#define MESSAGE_TYPE_SEND_SUCCESS 5 -+ -+typedef struct hdmi_cec_event{ -+ int event_type; -+ int msg_len; -+ unsigned char msg[MAX_CEC_MESSAGE_LEN]; -+}hdmi_cec_event; -+ + +using namespace std; +using namespace CEC; +using namespace PLATFORM; + -+#include "AdapterMessageQueue.h" ++#include "IMXCECAdapterMessageQueue.h" + +#define LIB_CEC m_callback->GetLib() + @@ -405,16 +178,15 @@ index 0000000..54e5662 +#define CEC_MSG_FAIL_DEST_NOT_ACK 0x85 /*Message transmisson failed: Destination Address not aknowledged*/ +#define CEC_MSG_FAIL_DATA_NOT_ACK 0x86 /*Message transmisson failed: Databyte not acknowledged*/ + -+ +CIMXCECAdapterCommunication::CIMXCECAdapterCommunication(IAdapterCommunicationCallback *callback) : -+ IAdapterCommunication(callback)/*, -+ m_bLogicalAddressChanged(false)*/ ++ IAdapterCommunication(callback) +{ + CLockObject lock(m_mutex); + + m_iNextMessage = 0; -+ //m_logicalAddresses.Clear(); -+ m_logicalAddress = CECDEVICE_UNKNOWN; ++ m_logicalAddress = CECDEVICE_UNKNOWN; ++ m_bLogicalAddressRegistered = false; ++ m_bInitialised = false; + m_dev = new CCDevSocket(CEC_IMX_PATH); +} + @@ -437,10 +209,12 @@ index 0000000..54e5662 + if (m_dev->Open(iTimeoutMs)) + { + if (!bStartListening || CreateThread()) { -+ if (m_dev->Ioctl(HDMICEC_IOC_STARTDEVICE, NULL) != 0) { -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to start device\n", __func__); ++ if (m_dev->Ioctl(HDMICEC_IOC_STARTDEVICE, NULL) == 0) { ++ m_bInitialised = true; ++ RegisterLogicalAddress(CECDEVICE_BROADCAST); ++ return true; + } -+ return true; ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to start device\n", __func__); + } + m_dev->Close(); + } @@ -451,9 +225,16 @@ index 0000000..54e5662 + +void CIMXCECAdapterCommunication::Close(void) +{ -+ StopThread(0); -+ if (m_dev->Ioctl(HDMICEC_IOC_STOPDEVICE, NULL) != 0) { -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to stop device\n", __func__); ++ StopThread(-1); ++ if (m_bInitialised) ++ { ++ m_bInitialised = false; ++ UnregisterLogicalAddress(); ++ ++ if (m_dev->Ioctl(HDMICEC_IOC_STOPDEVICE, NULL) != 0) ++ { ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to stop device\n", __func__); ++ } + } + m_dev->Close(); +} @@ -467,17 +248,19 @@ index 0000000..54e5662 + + +cec_adapter_message_state CIMXCECAdapterCommunication::Write( -+ const cec_command &data, bool &UNUSED(bRetry), uint8_t UNUSED(iLineTimeout), bool UNUSED(bIsReply)) ++ const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool UNUSED(bIsReply)) +{ -+ //cec_frame frame; -+ unsigned char message[MAX_CEC_MESSAGE_LEN]; ++ unsigned char message[MAX_MESSAGE_LEN]; ++ CIMXCECAdapterMessageQueueEntry *entry; + int msg_len = 1; + cec_adapter_message_state rc = ADAPTER_MESSAGE_STATE_ERROR; + ++ bRetry = true; + if ((size_t)data.parameters.size + data.opcode_set + 1 > sizeof(message)) + { + LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: data size too large !", __func__); -+ return ADAPTER_MESSAGE_STATE_ERROR; ++ bRetry = false; ++ return rc; + } + + message[0] = (data.initiator << 4) | (data.destination & 0x0f); @@ -489,625 +272,6 @@ index 0000000..54e5662 + msg_len+=data.parameters.size; + } + -+ if (m_dev->Write(message, msg_len) == msg_len) -+ { -+ rc = ADAPTER_MESSAGE_STATE_SENT_ACKED; -+ } -+ else -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: sent command error !", __func__); -+ -+ return rc; -+} -+ -+ -+uint16_t CIMXCECAdapterCommunication::GetFirmwareVersion(void) -+{ -+ /* FIXME add ioctl ? */ -+ return 0; -+} -+ -+ -+cec_vendor_id CIMXCECAdapterCommunication::GetVendorId(void) -+{ -+ return CEC_VENDOR_UNKNOWN; -+} -+ -+ -+uint16_t CIMXCECAdapterCommunication::GetPhysicalAddress(void) -+{ -+ uint32_t info; -+ -+ if (m_dev->Ioctl(HDMICEC_IOC_GETPHYADDRESS, &info) != 0) -+ { -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_GETPHYADDRESS failed !", __func__); -+ return CEC_INVALID_PHYSICAL_ADDRESS; -+ } -+ -+ return info; -+} -+ -+ -+cec_logical_addresses CIMXCECAdapterCommunication::GetLogicalAddresses(void) -+{ -+ cec_logical_addresses addresses; -+ addresses.Clear(); -+ -+ CLockObject lock(m_mutex); -+ if ( m_logicalAddress != CECDEVICE_UNKNOWN) -+ addresses.Set(m_logicalAddress); -+ -+ return addresses; -+} -+ -+ -+bool CIMXCECAdapterCommunication::SetLogicalAddresses(const cec_logical_addresses &addresses) -+{ -+ int log_addr = addresses.primary; -+ -+ CLockObject lock(m_mutex); -+ if (m_logicalAddress == log_addr) -+ return true; -+ -+ if (m_dev->Ioctl(HDMICEC_IOC_SETLOGICALADDRESS, (void *)log_addr) != 0) -+ { -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_SETLOGICALADDRESS failed !", __func__); -+ return false; -+ } -+ -+ m_logicalAddress = (cec_logical_address)log_addr; -+ return true; -+} -+ -+ -+void *CIMXCECAdapterCommunication::Process(void) -+{ -+ bool bHandled; -+ hdmi_cec_event event; -+ int ret; -+ -+ uint32_t opcode, status; -+ cec_logical_address initiator, destination; -+ -+ while (!IsStopped()) -+ { -+ ret = m_dev->Read((char *)&event, sizeof(event), 5000); -+ if (ret > 0) -+ { -+ -+ initiator = cec_logical_address(event.msg[0] >> 4); -+ destination = cec_logical_address(event.msg[0] & 0x0f); -+ -+ //LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s: Read data : type : %d initiator %d dest %d", __func__, event.event_type, initiator, destination); -+ if (event.event_type == MESSAGE_TYPE_RECEIVE_SUCCESS) -+ /* Message received */ -+ { -+ cec_command cmd; -+ -+ cec_command::Format( -+ cmd, initiator, destination, -+ ( event.msg_len > 1 ) ? cec_opcode(event.msg[1]) : CEC_OPCODE_NONE); -+ -+ for( uint8_t i = 2; i < event.msg_len; i++ ) -+ cmd.parameters.PushBack(event.msg[i]); -+ -+ if (!IsStopped()) -+ m_callback->OnCommandReceived(cmd); -+ } -+ /* We are not interested in other events */ -+ } /*else { -+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s: Read returned %d", __func__, ret); -+ }*/ -+ -+ } -+ -+ return 0; -+} -+ -+#endif // HAVE_IMX_API -diff --git a/src/lib/adapter/IMX/IMXCECAdapterCommunication.h b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h -new file mode 100644 -index 0000000..910dd39 ---- /dev/null -+++ b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h -@@ -0,0 +1,114 @@ -+#pragma once -+/* -+ * This file is part of the libCEC(R) library. -+ * -+ * 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. -+ * -+ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin -+ * -+ * You can redistribute this file and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * -+ */ -+ -+#if defined(HAVE_IMX_API) -+ -+#include "lib/platform/threads/mutex.h" -+#include "lib/platform/threads/threads.h" -+#include "lib/platform/sockets/socket.h" -+#include "lib/adapter/AdapterCommunication.h" -+#include -+ -+#define IMX_ADAPTER_VID 0x0471 /*FIXME TBD*/ -+#define IMX_ADAPTER_PID 0x1001 -+ -+ -+ -+namespace PLATFORM -+{ -+ class CCDevSocket; -+}; -+ -+ -+namespace CEC -+{ -+ class CAdapterMessageQueueEntry; -+ -+ class CIMXCECAdapterCommunication : public IAdapterCommunication, public PLATFORM::CThread -+ { -+ public: -+ /*! -+ * @brief Create a new USB-CEC communication handler. -+ * @param callback The callback to use for incoming CEC commands. -+ */ -+ CIMXCECAdapterCommunication(IAdapterCommunicationCallback *callback); -+ virtual ~CIMXCECAdapterCommunication(void); -+ -+ /** @name IAdapterCommunication implementation */ -+ ///{ -+ bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true); -+ void Close(void); -+ bool IsOpen(void); -+ std::string GetError(void) const; -+ cec_adapter_message_state Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool bIsReply); -+ -+ bool SetLineTimeout(uint8_t UNUSED(iTimeout)) { return true; } -+ bool StartBootloader(void) { return false; } -+ bool SetLogicalAddresses(const cec_logical_addresses &addresses); -+ cec_logical_addresses GetLogicalAddresses(void); -+ bool PingAdapter(void) { return IsInitialised(); } -+ uint16_t GetFirmwareVersion(void); -+ uint32_t GetFirmwareBuildDate(void) { return 0; } -+ bool IsRunningLatestFirmware(void) { return true; } -+ bool PersistConfiguration(const libcec_configuration & UNUSED(configuration)) { return false; } -+ bool GetConfiguration(libcec_configuration & UNUSED(configuration)) { return false; } -+ std::string GetPortName(void) { return std::string("IMX"); } -+ uint16_t GetPhysicalAddress(void); -+ bool SetControlledMode(bool UNUSED(controlled)) { return true; } -+ cec_vendor_id GetVendorId(void); -+ bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address <= CECDEVICE_BROADCAST; } -+ cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_IMX; } -+ uint16_t GetAdapterVendorId(void) const { return IMX_ADAPTER_VID; } -+ uint16_t GetAdapterProductId(void) const { return IMX_ADAPTER_PID; } -+ void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) {} -+ ///} -+ -+ /** @name PLATFORM::CThread implementation */ -+ ///{ -+ void *Process(void); -+ ///} -+ -+ private: -+ bool IsInitialised(void) const { return m_dev != 0; }; -+ -+ std::string m_strError; /**< current error message */ -+ -+ //cec_logical_addresses m_logicalAddresses; -+ cec_logical_address m_logicalAddress; -+ -+ PLATFORM::CMutex m_mutex; -+ PLATFORM::CCDevSocket *m_dev; /**< the device connection */ -+ -+ PLATFORM::CMutex m_messageMutex; -+ uint32_t m_iNextMessage; -+ std::map m_messages; -+ }; -+ -+}; -+ -+#endif -diff --git a/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp b/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp -new file mode 100644 -index 0000000..6c93c45 ---- /dev/null -+++ b/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp -@@ -0,0 +1,42 @@ -+/* -+ * This file is part of the libCEC(R) library. -+ * -+ * 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. -+ * -+ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin -+ * -+ * You can redistribute this file and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * -+ */ -+ -+#include "env.h" -+#include -+ -+#if defined(HAVE_IMX_API) -+#include "IMXCECAdapterDetection.h" -+ -+ -+using namespace CEC; -+ -+bool CIMXCECAdapterDetection::FindAdapter(void) -+{ -+ return access(CEC_IMX_PATH, 0) == 0; -+} -+ -+#endif -diff --git a/src/lib/adapter/IMX/IMXCECAdapterDetection.h b/src/lib/adapter/IMX/IMXCECAdapterDetection.h -new file mode 100644 -index 0000000..d54891d ---- /dev/null -+++ b/src/lib/adapter/IMX/IMXCECAdapterDetection.h -@@ -0,0 +1,36 @@ -+#pragma once -+/* -+ * This file is part of the libCEC(R) library. -+ * -+ * 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. -+ * -+ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin -+ * -+ * You can redistribute this file and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -+ * -+ * -+ */ -+ -+namespace CEC -+{ -+ class CIMXCECAdapterDetection -+ { -+ public: -+ static bool FindAdapter(void); -+ }; -+} - -From b15d8de0993286abc2551b2d7d66b7f1f193c044 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Wed, 10 Sep 2014 22:23:37 +0200 -Subject: [PATCH 2/2] update to IMX6 support - ---- - src/lib/adapter/IMX/AdapterMessageQueue.h | 134 ----------- - src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp | 246 ++++++++++++++------- - src/lib/adapter/IMX/IMXCECAdapterCommunication.h | 22 +- - src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h | 118 ++++++++++ - src/lib/adapter/IMX/mxc_hdmi-cec.h | 47 ++++ - 5 files changed, 349 insertions(+), 218 deletions(-) - delete mode 100644 src/lib/adapter/IMX/AdapterMessageQueue.h - create mode 100644 src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h - create mode 100644 src/lib/adapter/IMX/mxc_hdmi-cec.h - -diff --git a/src/lib/adapter/IMX/AdapterMessageQueue.h b/src/lib/adapter/IMX/AdapterMessageQueue.h -deleted file mode 100644 -index c8bcf71..0000000 ---- a/src/lib/adapter/IMX/AdapterMessageQueue.h -+++ /dev/null -@@ -1,134 +0,0 @@ --#pragma once --/* -- * This file is part of the libCEC(R) library. -- * -- * 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. -- * -- * This program is dual-licensed; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation; either version 2 of the License, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with this program; if not, write to the Free Software -- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- * -- * -- * Alternatively, you can license this library under a commercial license, -- * please contact Pulse-Eight Licensing for more information. -- * -- * For more information contact: -- * Pulse-Eight Licensing -- * http://www.pulse-eight.com/ -- * http://www.pulse-eight.net/ -- */ -- --#include "lib/platform/threads/mutex.h" -- --namespace CEC --{ -- using namespace PLATFORM; -- -- class CAdapterMessageQueueEntry -- { -- public: -- CAdapterMessageQueueEntry(const cec_command &command) -- : m_bWaiting(true), m_retval((uint32_t)-1), m_bSucceeded(false) -- { -- m_hash = hashValue( -- uint32_t(command.opcode_set ? command.opcode : CEC_OPCODE_NONE), -- command.initiator, command.destination); -- } -- -- virtual ~CAdapterMessageQueueEntry(void) {} -- -- /*! -- * @brief Query result from worker thread -- */ -- uint32_t Result() const -- { -- return m_retval; -- } -- -- /*! -- * @brief Signal waiting threads -- */ -- void Broadcast(void) -- { -- CLockObject lock(m_mutex); -- m_condition.Broadcast(); -- } -- -- /*! -- * @brief Signal waiting thread(s) when message matches this entry -- */ -- bool CheckMatch(uint32_t opcode, cec_logical_address initiator, -- cec_logical_address destination, uint32_t response) -- { -- uint32_t hash = hashValue(opcode, initiator, destination); -- -- if (hash == m_hash) -- { -- CLockObject lock(m_mutex); -- -- m_retval = response; -- m_bSucceeded = true; -- m_condition.Signal(); -- return true; -- } -- -- return false; -- } -- -- /*! -- * @brief Wait for a response to this command. -- * @param iTimeout The timeout to use while waiting. -- * @return True when a response was received before the timeout passed, false otherwise. -- */ -- bool Wait(uint32_t iTimeout) -- { -- CLockObject lock(m_mutex); -- -- bool bReturn = m_bSucceeded ? true : m_condition.Wait(m_mutex, m_bSucceeded, iTimeout); -- m_bWaiting = false; -- return bReturn; -- } -- -- /*! -- * @return True while a thread is waiting for a signal or isn't waiting yet, false otherwise. -- */ -- bool IsWaiting(void) -- { -- CLockObject lock(m_mutex); -- return m_bWaiting; -- } -- -- /*! -- * @return Hash value for given cec_command -- */ -- static uint32_t hashValue(uint32_t opcode, -- cec_logical_address initiator, -- cec_logical_address destination) -- { -- return 1 | ((uint32_t)initiator << 8) | -- ((uint32_t)destination << 16) | ((uint32_t)opcode << 16); -- } -- -- private: -- bool m_bWaiting; /**< true while a thread is waiting or when it hasn't started waiting yet */ -- PLATFORM::CCondition m_condition; /**< the condition to wait on */ -- PLATFORM::CMutex m_mutex; /**< mutex for changes to this class */ -- uint32_t m_hash; -- uint32_t m_retval; -- bool m_bSucceeded; -- }; -- --}; -diff --git a/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp -index 54e5662..8467ba7 100644 ---- a/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp -+++ b/src/lib/adapter/IMX/IMXCECAdapterCommunication.cpp -@@ -7,6 +7,7 @@ - * libCEC(R) is a trademark of Pulse-Eight Limited. - * - * IMX adpater port is Copyright (C) 2013 by Stephan Rafin -+ * Copyright (C) 2014 by Matus Kral - * - * You can redistribute this file and/or modify - * it under the terms of the GNU General Public License as published by -@@ -34,37 +35,12 @@ - #include "lib/LibCEC.h" - #include "lib/platform/sockets/cdevsocket.h" - #include "lib/platform/util/StdString.h" --#include "lib/platform/util/buffer.h" -- --/* -- * Ioctl definitions from kernel header -- */ --#define HDMICEC_IOC_MAGIC 'H' --#define HDMICEC_IOC_SETLOGICALADDRESS _IOW(HDMICEC_IOC_MAGIC, 1, unsigned char) --#define HDMICEC_IOC_STARTDEVICE _IO(HDMICEC_IOC_MAGIC, 2) --#define HDMICEC_IOC_STOPDEVICE _IO(HDMICEC_IOC_MAGIC, 3) --#define HDMICEC_IOC_GETPHYADDRESS _IOR(HDMICEC_IOC_MAGIC, 4, unsigned char[4]) -- --#define MAX_CEC_MESSAGE_LEN 17 -- --#define MESSAGE_TYPE_RECEIVE_SUCCESS 1 --#define MESSAGE_TYPE_NOACK 2 --#define MESSAGE_TYPE_DISCONNECTED 3 --#define MESSAGE_TYPE_CONNECTED 4 --#define MESSAGE_TYPE_SEND_SUCCESS 5 -- --typedef struct hdmi_cec_event{ -- int event_type; -- int msg_len; -- unsigned char msg[MAX_CEC_MESSAGE_LEN]; --}hdmi_cec_event; -- - - using namespace std; - using namespace CEC; - using namespace PLATFORM; - --#include "AdapterMessageQueue.h" -+#include "IMXCECAdapterMessageQueue.h" - - #define LIB_CEC m_callback->GetLib() - -@@ -78,16 +54,15 @@ using namespace PLATFORM; - #define CEC_MSG_FAIL_DEST_NOT_ACK 0x85 /*Message transmisson failed: Destination Address not aknowledged*/ - #define CEC_MSG_FAIL_DATA_NOT_ACK 0x86 /*Message transmisson failed: Databyte not acknowledged*/ - -- - CIMXCECAdapterCommunication::CIMXCECAdapterCommunication(IAdapterCommunicationCallback *callback) : -- IAdapterCommunication(callback)/*, -- m_bLogicalAddressChanged(false)*/ -+ IAdapterCommunication(callback) - { - CLockObject lock(m_mutex); - - m_iNextMessage = 0; -- //m_logicalAddresses.Clear(); -- m_logicalAddress = CECDEVICE_UNKNOWN; -+ m_logicalAddress = CECDEVICE_UNKNOWN; -+ m_bLogicalAddressRegistered = false; -+ m_bInitialised = false; - m_dev = new CCDevSocket(CEC_IMX_PATH); - } - -@@ -110,10 +85,12 @@ bool CIMXCECAdapterCommunication::Open(uint32_t iTimeoutMs, bool UNUSED(bSkipChe - if (m_dev->Open(iTimeoutMs)) - { - if (!bStartListening || CreateThread()) { -- if (m_dev->Ioctl(HDMICEC_IOC_STARTDEVICE, NULL) != 0) { -- LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to start device\n", __func__); -+ if (m_dev->Ioctl(HDMICEC_IOC_STARTDEVICE, NULL) == 0) { -+ m_bInitialised = true; -+ RegisterLogicalAddress(CECDEVICE_BROADCAST); -+ return true; - } -- return true; -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to start device\n", __func__); - } - m_dev->Close(); - } -@@ -124,9 +101,16 @@ bool CIMXCECAdapterCommunication::Open(uint32_t iTimeoutMs, bool UNUSED(bSkipChe - - void CIMXCECAdapterCommunication::Close(void) - { -- StopThread(0); -- if (m_dev->Ioctl(HDMICEC_IOC_STOPDEVICE, NULL) != 0) { -- LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to stop device\n", __func__); -+ StopThread(-1); -+ if (m_bInitialised) -+ { -+ m_bInitialised = false; -+ UnregisterLogicalAddress(); -+ -+ if (m_dev->Ioctl(HDMICEC_IOC_STOPDEVICE, NULL) != 0) -+ { -+ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to stop device\n", __func__); -+ } - } - m_dev->Close(); - } -@@ -140,17 +124,19 @@ std::string CIMXCECAdapterCommunication::GetError(void) const - - - cec_adapter_message_state CIMXCECAdapterCommunication::Write( -- const cec_command &data, bool &UNUSED(bRetry), uint8_t UNUSED(iLineTimeout), bool UNUSED(bIsReply)) -+ const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool UNUSED(bIsReply)) - { -- //cec_frame frame; -- unsigned char message[MAX_CEC_MESSAGE_LEN]; -+ unsigned char message[MAX_MESSAGE_LEN]; -+ CIMXCECAdapterMessageQueueEntry *entry; - int msg_len = 1; - cec_adapter_message_state rc = ADAPTER_MESSAGE_STATE_ERROR; - -+ bRetry = true; - if ((size_t)data.parameters.size + data.opcode_set + 1 > sizeof(message)) - { - LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: data size too large !", __func__); -- return ADAPTER_MESSAGE_STATE_ERROR; -+ bRetry = false; -+ return rc; - } - - message[0] = (data.initiator << 4) | (data.destination & 0x0f); -@@ -162,12 +148,46 @@ cec_adapter_message_state CIMXCECAdapterCommunication::Write( - msg_len+=data.parameters.size; - } - -- if (m_dev->Write(message, msg_len) == msg_len) + entry = new CIMXCECAdapterMessageQueueEntry(message[0], data.opcode); + m_messageMutex.Lock(); + uint32_t msgKey = ++m_iNextMessage; @@ -1136,72 +300,76 @@ index 54e5662..8467ba7 100644 + } + } + else - { -- rc = ADAPTER_MESSAGE_STATE_SENT_ACKED; ++ { + Sleep(CEC_DEFAULT_TRANSMIT_RETRY_WAIT); +#ifdef CEC_DEBUGGING + LIB_CEC->AddLog(CEC_LOG_WARNING, "%s: write failed !", __func__); +#endif - } -- else -- LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: sent command error !", __func__); ++ } + + m_messageMutex.Lock(); + m_messages.erase(msgKey); + m_messageMutex.Unlock(); + + delete entry; - - return rc; - } -@@ -188,15 +208,16 @@ cec_vendor_id CIMXCECAdapterCommunication::GetVendorId(void) - - uint16_t CIMXCECAdapterCommunication::GetPhysicalAddress(void) - { -- uint32_t info; ++ ++ return rc; ++} ++ ++ ++uint16_t CIMXCECAdapterCommunication::GetFirmwareVersion(void) ++{ ++ /* FIXME add ioctl ? */ ++ return 0; ++} ++ ++ ++cec_vendor_id CIMXCECAdapterCommunication::GetVendorId(void) ++{ ++ return CEC_VENDOR_UNKNOWN; ++} ++ ++ ++uint16_t CIMXCECAdapterCommunication::GetPhysicalAddress(void) ++{ + uint8_t phy_addr[4]; - -- if (m_dev->Ioctl(HDMICEC_IOC_GETPHYADDRESS, &info) != 0) ++ + if (m_dev->Ioctl(HDMICEC_IOC_GETPHYADDRESS, &phy_addr) != 0) - { - LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_GETPHYADDRESS failed !", __func__); - return CEC_INVALID_PHYSICAL_ADDRESS; - } - -- return info; ++ { ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_GETPHYADDRESS failed !", __func__); ++ return CEC_INVALID_PHYSICAL_ADDRESS; ++ } ++ + m_physicalAddress = ((phy_addr[0] << 4 | phy_addr[1]) << 8) | (phy_addr[2] << 4 | phy_addr[3]); + return m_physicalAddress; - } - - -@@ -206,31 +227,72 @@ cec_logical_addresses CIMXCECAdapterCommunication::GetLogicalAddresses(void) - addresses.Clear(); - - CLockObject lock(m_mutex); -- if ( m_logicalAddress != CECDEVICE_UNKNOWN) ++} ++ ++ ++cec_logical_addresses CIMXCECAdapterCommunication::GetLogicalAddresses(void) ++{ ++ cec_logical_addresses addresses; ++ addresses.Clear(); ++ ++ CLockObject lock(m_mutex); + if (m_bLogicalAddressRegistered) - addresses.Set(m_logicalAddress); - - return addresses; - } - ++ addresses.Set(m_logicalAddress); ++ ++ return addresses; ++} ++ +void CIMXCECAdapterCommunication::HandleLogicalAddressLost(cec_logical_address UNUSED(oldAddress)) +{ + UnregisterLogicalAddress(); +} - --bool CIMXCECAdapterCommunication::SetLogicalAddresses(const cec_logical_addresses &addresses) ++ +bool CIMXCECAdapterCommunication::UnregisterLogicalAddress(void) - { -- int log_addr = addresses.primary; ++{ + { + CLockObject lock(m_mutex); + if (!m_bLogicalAddressRegistered) + return true; + } - -- CLockObject lock(m_mutex); -- if (m_logicalAddress == log_addr) ++ + if (m_dev->Ioctl(HDMICEC_IOC_SETLOGICALADDRESS, (void *)CECDEVICE_BROADCAST) != 0) + { + LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_SETLOGICALADDRESS failed !", __func__); @@ -1221,18 +389,16 @@ index 54e5662..8467ba7 100644 + CLockObject lock(m_mutex); + if (m_logicalAddress == address && m_bLogicalAddressRegistered) + { - return true; ++ return true; + } + } - -- if (m_dev->Ioctl(HDMICEC_IOC_SETLOGICALADDRESS, (void *)log_addr) != 0) ++ + if (m_dev->Ioctl(HDMICEC_IOC_SETLOGICALADDRESS, (void *)address) != 0) - { - LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_SETLOGICALADDRESS failed !", __func__); - return false; - } - -- m_logicalAddress = (cec_logical_address)log_addr; ++ { ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_SETLOGICALADDRESS failed !", __func__); ++ return false; ++ } ++ + CLockObject lock(m_mutex); + +#ifdef CEC_DEBUGGING @@ -1241,9 +407,9 @@ index 54e5662..8467ba7 100644 + + m_logicalAddress = address; + m_bLogicalAddressRegistered = (address != CECDEVICE_BROADCAST) ? true : false; - return true; - } - ++ return true; ++} ++ +bool CIMXCECAdapterCommunication::SetLogicalAddresses(const cec_logical_addresses &addresses) +{ + int log_addr = addresses.primary; @@ -1251,47 +417,23 @@ index 54e5662..8467ba7 100644 + return RegisterLogicalAddress((cec_logical_address)log_addr); +} + - - void *CIMXCECAdapterCommunication::Process(void) - { -@@ -238,39 +300,65 @@ void *CIMXCECAdapterCommunication::Process(void) - hdmi_cec_event event; - int ret; - -- uint32_t opcode, status; - cec_logical_address initiator, destination; - - while (!IsStopped()) - { -- ret = m_dev->Read((char *)&event, sizeof(event), 5000); -- if (ret > 0) ++ ++void *CIMXCECAdapterCommunication::Process(void) ++{ ++ bool bHandled; ++ hdmi_cec_event event; ++ int ret; ++ ++ cec_logical_address initiator, destination; ++ ++ while (!IsStopped()) ++ { + if (IsInitialised() && (ret = m_dev->Read((char *)&event, sizeof(event), 5000)) > 0) - { - - initiator = cec_logical_address(event.msg[0] >> 4); - destination = cec_logical_address(event.msg[0] & 0x0f); - -- //LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s: Read data : type : %d initiator %d dest %d", __func__, event.event_type, initiator, destination); -- if (event.event_type == MESSAGE_TYPE_RECEIVE_SUCCESS) -- /* Message received */ -- { -- cec_command cmd; -- -- cec_command::Format( -- cmd, initiator, destination, -- ( event.msg_len > 1 ) ? cec_opcode(event.msg[1]) : CEC_OPCODE_NONE); -- -- for( uint8_t i = 2; i < event.msg_len; i++ ) -- cmd.parameters.PushBack(event.msg[i]); -- -- if (!IsStopped()) -- m_callback->OnCommandReceived(cmd); -- } -- /* We are not interested in other events */ -- } /*else { -- LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s: Read returned %d", __func__, ret); -- }*/ -- ++ { ++ ++ initiator = cec_logical_address(event.msg[0] >> 4); ++ destination = cec_logical_address(event.msg[0] & 0x0f); ++ + if (event.event_type == MESSAGE_TYPE_RECEIVE_SUCCESS) + { + cec_command cmd; @@ -1341,93 +483,231 @@ index 54e5662..8467ba7 100644 + else + LIB_CEC->AddLog(CEC_LOG_WARNING, "%s: unhandled response received %d!", __func__, event.event_type); + } - } - - return 0; -diff --git a/src/lib/adapter/IMX/IMXCECAdapterCommunication.h b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h -index 910dd39..f551122 100644 ---- a/src/lib/adapter/IMX/IMXCECAdapterCommunication.h -+++ b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h -@@ -8,6 +8,7 @@ - * libCEC(R) is a trademark of Pulse-Eight Limited. - * - * IMX adpater port is Copyright (C) 2013 by Stephan Rafin ++ } ++ ++ return 0; ++} ++ ++#endif // HAVE_IMX_API +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterCommunication.h +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterCommunication.h 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterCommunication.h 2014-10-27 13:11:03.736446898 +0100 +@@ -0,0 +1,126 @@ ++#pragma once ++/* ++ * This file is part of the libCEC(R) library. ++ * ++ * 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. ++ * ++ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin + * Copyright (C) 2014 by Matus Kral - * - * You can redistribute this file and/or modify - * it under the terms of the GNU General Public License as published by -@@ -31,12 +32,18 @@ - #include "lib/platform/threads/mutex.h" - #include "lib/platform/threads/threads.h" - #include "lib/platform/sockets/socket.h" ++ * ++ * You can redistribute this file and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ * ++ */ ++ ++#if defined(HAVE_IMX_API) ++ ++#include "lib/platform/threads/mutex.h" ++#include "lib/platform/threads/threads.h" ++#include "lib/platform/sockets/socket.h" +#include "lib/adapter/IMX/mxc_hdmi-cec.h" - #include "lib/adapter/AdapterCommunication.h" - #include - - #define IMX_ADAPTER_VID 0x0471 /*FIXME TBD*/ - #define IMX_ADAPTER_PID 0x1001 - ++#include "lib/adapter/AdapterCommunication.h" ++#include ++ ++#define IMX_ADAPTER_VID 0x0471 /*FIXME TBD*/ ++#define IMX_ADAPTER_PID 0x1001 ++ +typedef struct hdmi_cec_event{ + int event_type; + int msg_len; + unsigned char msg[MAX_MESSAGE_LEN]; +}hdmi_cec_event; - - - namespace PLATFORM -@@ -44,10 +51,9 @@ namespace PLATFORM - class CCDevSocket; - }; - -- - namespace CEC - { -- class CAdapterMessageQueueEntry; ++ ++ ++namespace PLATFORM ++{ ++ class CCDevSocket; ++}; ++ ++namespace CEC ++{ + class CIMXCECAdapterMessageQueueEntry; - - class CIMXCECAdapterCommunication : public IAdapterCommunication, public PLATFORM::CThread - { -@@ -81,6 +87,7 @@ namespace CEC - uint16_t GetPhysicalAddress(void); - bool SetControlledMode(bool UNUSED(controlled)) { return true; } - cec_vendor_id GetVendorId(void); ++ ++ class CIMXCECAdapterCommunication : public IAdapterCommunication, public PLATFORM::CThread ++ { ++ public: ++ /*! ++ * @brief Create a new USB-CEC communication handler. ++ * @param callback The callback to use for incoming CEC commands. ++ */ ++ CIMXCECAdapterCommunication(IAdapterCommunicationCallback *callback); ++ virtual ~CIMXCECAdapterCommunication(void); ++ ++ /** @name IAdapterCommunication implementation */ ++ ///{ ++ bool Open(uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT, bool bSkipChecks = false, bool bStartListening = true); ++ void Close(void); ++ bool IsOpen(void); ++ std::string GetError(void) const; ++ cec_adapter_message_state Write(const cec_command &data, bool &bRetry, uint8_t iLineTimeout, bool bIsReply); ++ ++ bool SetLineTimeout(uint8_t UNUSED(iTimeout)) { return true; } ++ bool StartBootloader(void) { return false; } ++ bool SetLogicalAddresses(const cec_logical_addresses &addresses); ++ cec_logical_addresses GetLogicalAddresses(void); ++ bool PingAdapter(void) { return IsInitialised(); } ++ uint16_t GetFirmwareVersion(void); ++ uint32_t GetFirmwareBuildDate(void) { return 0; } ++ bool IsRunningLatestFirmware(void) { return true; } ++ bool PersistConfiguration(const libcec_configuration & UNUSED(configuration)) { return false; } ++ bool GetConfiguration(libcec_configuration & UNUSED(configuration)) { return false; } ++ std::string GetPortName(void) { return std::string("IMX"); } ++ uint16_t GetPhysicalAddress(void); ++ bool SetControlledMode(bool UNUSED(controlled)) { return true; } ++ cec_vendor_id GetVendorId(void); + void HandleLogicalAddressLost(cec_logical_address UNUSED(oldAddress)); - bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address <= CECDEVICE_BROADCAST; } - cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_IMX; } - uint16_t GetAdapterVendorId(void) const { return IMX_ADAPTER_VID; } -@@ -94,19 +101,24 @@ namespace CEC - ///} - - private: -- bool IsInitialised(void) const { return m_dev != 0; }; ++ bool SupportsSourceLogicalAddress(const cec_logical_address address) { return address > CECDEVICE_TV && address <= CECDEVICE_BROADCAST; } ++ cec_adapter_type GetAdapterType(void) { return ADAPTERTYPE_IMX; } ++ uint16_t GetAdapterVendorId(void) const { return IMX_ADAPTER_VID; } ++ uint16_t GetAdapterProductId(void) const { return IMX_ADAPTER_PID; } ++ void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) {} ++ ///} ++ ++ /** @name PLATFORM::CThread implementation */ ++ ///{ ++ void *Process(void); ++ ///} ++ ++ private: + bool IsInitialised(void) { return m_bInitialised; }; + bool RegisterLogicalAddress(const cec_logical_address address); + bool UnregisterLogicalAddress(void); - - std::string m_strError; /**< current error message */ - -- //cec_logical_addresses m_logicalAddresses; - cec_logical_address m_logicalAddress; ++ ++ std::string m_strError; /**< current error message */ ++ ++ cec_logical_address m_logicalAddress; + uint16_t m_physicalAddress; - - PLATFORM::CMutex m_mutex; - PLATFORM::CCDevSocket *m_dev; /**< the device connection */ - - PLATFORM::CMutex m_messageMutex; - uint32_t m_iNextMessage; -- std::map m_messages; ++ ++ PLATFORM::CMutex m_mutex; ++ PLATFORM::CCDevSocket *m_dev; /**< the device connection */ ++ ++ PLATFORM::CMutex m_messageMutex; ++ uint32_t m_iNextMessage; + std::map m_messages; + + bool m_bLogicalAddressRegistered; + bool m_bInitialised; - }; - - }; -diff --git a/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h b/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h -new file mode 100644 -index 0000000..340b702 ---- /dev/null -+++ b/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h ++ }; ++ ++}; ++ ++#endif +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterDetection.cpp 2014-10-27 13:11:03.733446659 +0100 +@@ -0,0 +1,42 @@ ++/* ++ * This file is part of the libCEC(R) library. ++ * ++ * 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. ++ * ++ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin ++ * ++ * You can redistribute this file and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ * ++ */ ++ ++#include "env.h" ++#include ++ ++#if defined(HAVE_IMX_API) ++#include "IMXCECAdapterDetection.h" ++ ++ ++using namespace CEC; ++ ++bool CIMXCECAdapterDetection::FindAdapter(void) ++{ ++ return access(CEC_IMX_PATH, 0) == 0; ++} ++ ++#endif +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterDetection.h libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterDetection.h +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterDetection.h 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterDetection.h 2014-10-27 13:11:03.734446742 +0100 +@@ -0,0 +1,36 @@ ++#pragma once ++/* ++ * This file is part of the libCEC(R) library. ++ * ++ * 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. ++ * ++ * IMX adpater port is Copyright (C) 2013 by Stephan Rafin ++ * ++ * You can redistribute this file and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ * ++ * ++ */ ++ ++namespace CEC ++{ ++ class CIMXCECAdapterDetection ++ { ++ public: ++ static bool FindAdapter(void); ++ }; ++} +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/IMXCECAdapterMessageQueue.h 2014-10-27 13:11:03.736446898 +0100 @@ -0,0 +1,118 @@ +#pragma once +/* @@ -1547,11 +827,9 @@ index 0000000..340b702 + }; + +}; -diff --git a/src/lib/adapter/IMX/mxc_hdmi-cec.h b/src/lib/adapter/IMX/mxc_hdmi-cec.h -new file mode 100644 -index 0000000..bc5bbce ---- /dev/null -+++ b/src/lib/adapter/IMX/mxc_hdmi-cec.h +diff -Naur libcec-2.2-8d84f8b/src/lib/adapter/IMX/mxc_hdmi-cec.h libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/mxc_hdmi-cec.h +--- libcec-2.2-8d84f8b/src/lib/adapter/IMX/mxc_hdmi-cec.h 1970-01-01 01:00:00.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/adapter/IMX/mxc_hdmi-cec.h 2014-10-27 13:11:03.736446898 +0100 @@ -0,0 +1,47 @@ +/* + * Copyright 2005-2013 Freescale Semiconductor, Inc. All Rights Reserved. @@ -1600,3 +878,29 @@ index 0000000..bc5bbce + +#endif /* !_HDMICEC_H_ */ + +diff -Naur libcec-2.2-8d84f8b/src/lib/CECTypeUtils.h libcec-2.2-8d84f8b.patch/src/lib/CECTypeUtils.h +--- libcec-2.2-8d84f8b/src/lib/CECTypeUtils.h 2014-10-27 12:55:30.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/CECTypeUtils.h 2014-10-27 13:11:03.729446299 +0100 +@@ -877,6 +877,8 @@ + return "Raspberry Pi"; + case ADAPTERTYPE_TDA995x: + return "TDA995x"; ++ case ADAPTERTYPE_IMX: ++ return "i.MX"; + default: + return "unknown"; + } +diff -Naur libcec-2.2-8d84f8b/src/lib/Makefile.am libcec-2.2-8d84f8b.patch/src/lib/Makefile.am +--- libcec-2.2-8d84f8b/src/lib/Makefile.am 2014-10-27 12:55:30.000000000 +0100 ++++ libcec-2.2-8d84f8b.patch/src/lib/Makefile.am 2014-10-27 13:14:08.229600205 +0100 +@@ -69,4 +69,10 @@ + adapter/Exynos/ExynosCECAdapterCommunication.cpp + endif + ++## i.MX6 support ++if USE_IMX_API ++libcec_la_SOURCES += adapter/IMX/IMXCECAdapterDetection.cpp \ ++ adapter/IMX/IMXCECAdapterCommunication.cpp ++endif ++ + libcec_la_LDFLAGS = @LIBS_LIBCEC@ -version-info @VERSION@ diff --git a/packages/devel/libcec/patches/libcec-mk01-libCEC-fixes.patch b/packages/devel/libcec/patches/libcec-mk01-libCEC-fixes.patch deleted file mode 100644 index 33cffc74ad..0000000000 --- a/packages/devel/libcec/patches/libcec-mk01-libCEC-fixes.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 2a579cc8641a4cf2aba9c03274de68064508ff06 Mon Sep 17 00:00:00 2001 -From: Matus Kral -Date: Sun, 25 May 2014 07:03:32 +0200 -Subject: [PATCH] this solves problem with device dissapearing from TV's menu - when source is changed to another device. - -(needs fix on adapter side to correctly mark devices with -"ishandledbycec"). ---- - src/lib/implementations/CECCommandHandler.cpp | 13 ++++++++----- - 1 file changed, 8 insertions(+), 5 deletions(-) - -diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp -index 29d1ffb..a89ebe6 100644 ---- a/src/lib/implementations/CECCommandHandler.cpp -+++ b/src/lib/implementations/CECCommandHandler.cpp -@@ -592,12 +592,15 @@ int CCECCommandHandler::HandleSetStreamPath(const cec_command &command) - CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress); - if (device) - { -- if (device->IsHandledByLibCEC() && !device->IsActiveSource()) -- device->ActivateSource(); -- else -+ if (device->IsHandledByLibCEC()) - { -- device->MarkAsActiveSource(); -- device->TransmitActiveSource(true); -+ if (!device->IsActiveSource()) -+ device->ActivateSource(); -+ else -+ { -+ device->MarkAsActiveSource(); -+ device->TransmitActiveSource(true); -+ } - } - return COMMAND_HANDLED; - }