diff --git a/packages/devel/libcec/package.mk b/packages/devel/libcec/package.mk index 61a5021471..969a6508b1 100644 --- a/packages/devel/libcec/package.mk +++ b/packages/devel/libcec/package.mk @@ -22,6 +22,13 @@ PKG_ARCH="any" PKG_LICENSE="GPL" PKG_SITE="http://libcec.pulse-eight.com/" PKG_URL="https://github.com/Pulse-Eight/libcec/archive/$PKG_VERSION.tar.gz" +if [ "$PROJECT" = "imx6" ]; then + if [ "$LINUX_VERSION" = "sr-3.14" ]; then + PKG_PATCH_DIRS="3.14-sr" + else + PKG_PATCH_DIRS="4.4-xbian" + fi +fi PKG_DEPENDS_TARGET="toolchain systemd lockdev p8-platform" PKG_SECTION="system" PKG_SHORTDESC="libCEC is an open-source dual licensed library designed for communicating with the Pulse-Eight USB - CEC Adaptor" diff --git a/projects/imx6/patches/libcec/3.14-sr/libcec-100-from-openbricks-3.14.patch b/projects/imx6/patches/libcec/3.14-sr/libcec-100-from-openbricks-3.14.patch new file mode 100644 index 0000000000..63f50a4a1f --- /dev/null +++ b/projects/imx6/patches/libcec/3.14-sr/libcec-100-from-openbricks-3.14.patch @@ -0,0 +1,747 @@ +From e9d9bfee5506a7b00312f62722009a0194f81dfd Mon Sep 17 00:00:00 2001 +From: Peter Vicman +Date: Sat, 3 Dec 2016 13:53:30 +0100 +Subject: [PATCH] patch for libcec from openbricks + +libcec base: libcec-209884d +libcec openbricks: + https://github.com/warped-rudi/libcec/tree/libcec4-imx 47e1d6aba475616fc267aa0c2097949b55cfdedc +--- + include/cectypes.h | 11 + + src/libcec/CECTypeUtils.h | 2 + + src/libcec/CMakeLists.txt | 2 + + src/libcec/adapter/AdapterFactory.cpp | 28 +- + .../adapter/IMX/IMXCECAdapterCommunication.cpp | 321 +++++++++++++++++++++ + .../adapter/IMX/IMXCECAdapterCommunication.h | 115 ++++++++ + src/libcec/adapter/IMX/IMXCECAdapterDetection.cpp | 42 +++ + src/libcec/adapter/IMX/IMXCECAdapterDetection.h | 36 +++ + src/libcec/cmake/CheckPlatformSupport.cmake | 13 + + src/libcec/cmake/DisplayPlatformSupport.cmake | 10 +- + src/libcec/env.h.in | 3 + + 11 files changed, 579 insertions(+), 4 deletions(-) + create mode 100644 src/libcec/adapter/IMX/IMXCECAdapterCommunication.cpp + create mode 100644 src/libcec/adapter/IMX/IMXCECAdapterCommunication.h + create mode 100644 src/libcec/adapter/IMX/IMXCECAdapterDetection.cpp + create mode 100644 src/libcec/adapter/IMX/IMXCECAdapterDetection.h + +diff --git a/include/cectypes.h b/include/cectypes.h +index 9c91842..68e90e0 100644 +--- a/include/cectypes.h ++++ b/include/cectypes.h +@@ -292,6 +292,16 @@ namespace CEC { + #define CEC_AOCEC_VIRTUAL_COM "AOCEC" + + /*! ++ * the path to use for the i.MX CEC wire ++ */ ++#define CEC_IMX_PATH "/dev/mxc_hdmi_cec" ++ ++/*! ++ * the name of the virtual COM port to use for the i.MX CEC wire ++ */ ++#define CEC_IMX_VIRTUAL_COM "i.MX" ++ ++/*! + * Mimimum client version + */ + #define CEC_MIN_LIB_VERSION 4 +@@ -861,6 +871,7 @@ typedef enum cec_adapter_type + ADAPTERTYPE_RPI = 0x100, + ADAPTERTYPE_TDA995x = 0x200, + ADAPTERTYPE_EXYNOS = 0x300, ++ ADAPTERTYPE_IMX = 0x400, + ADAPTERTYPE_AOCEC = 0x500 + } cec_adapter_type; + +diff --git a/src/libcec/CECTypeUtils.h b/src/libcec/CECTypeUtils.h +index 0d0cf17..f6c818a 100644 +--- a/src/libcec/CECTypeUtils.h ++++ b/src/libcec/CECTypeUtils.h +@@ -766,6 +766,8 @@ namespace CEC + return "Raspberry Pi"; + case ADAPTERTYPE_TDA995x: + return "TDA995x"; ++ case ADAPTERTYPE_IMX: ++ return "i.MX"; + default: + return "unknown"; + } +diff --git a/src/libcec/CMakeLists.txt b/src/libcec/CMakeLists.txt +index d3eefa3..a8fb9d0 100644 +--- a/src/libcec/CMakeLists.txt ++++ b/src/libcec/CMakeLists.txt +@@ -103,6 +103,8 @@ set(CEC_HEADERS devices/CECRecordingDevice.h + adapter/RPi/RPiCECAdapterMessageQueue.h + adapter/RPi/RPiCECAdapterCommunication.h + adapter/RPi/RPiCECAdapterDetection.h ++ adapter/IMX/IMXCECAdapterCommunication.h ++ adapter/IMX/IMXCECAdapterDetection.h + CECInputBuffer.h + platform/util/baudrate.h + platform/util/edid.h +diff --git a/src/libcec/adapter/AdapterFactory.cpp b/src/libcec/adapter/AdapterFactory.cpp +index 1e946e6..045c93e 100644 +--- a/src/libcec/adapter/AdapterFactory.cpp ++++ b/src/libcec/adapter/AdapterFactory.cpp +@@ -63,6 +63,11 @@ + #include "AOCEC/AOCECAdapterCommunication.h" + #endif + ++#if defined(HAVE_IMX_API) ++#include "IMX/IMXCECAdapterDetection.h" ++#include "IMX/IMXCECAdapterCommunication.h" ++#endif ++ + using namespace CEC; + + int8_t CAdapterFactory::FindAdapters(cec_adapter *deviceList, uint8_t iBufSize, const char *strDevicePath /* = NULL */) +@@ -143,8 +148,21 @@ int8_t CAdapterFactory::DetectAdapters(cec_adapter_descriptor *deviceList, uint8 + } + #endif + ++#if defined(HAVE_IMX_API) ++ if (iAdaptersFound < iBufSize && CIMXCECAdapterDetection::FindAdapter() && ++ (!strDevicePath || !strcmp(strDevicePath, CEC_IMX_VIRTUAL_COM))) ++ { ++ snprintf(deviceList[iAdaptersFound].strComPath, sizeof(deviceList[iAdaptersFound].strComPath), CEC_IMX_PATH); ++ snprintf(deviceList[iAdaptersFound].strComName, sizeof(deviceList[iAdaptersFound].strComName), CEC_IMX_VIRTUAL_COM); ++ deviceList[iAdaptersFound].iVendorId = IMX_ADAPTER_VID; ++ deviceList[iAdaptersFound].iProductId = IMX_ADAPTER_PID; ++ deviceList[iAdaptersFound].adapterType = ADAPTERTYPE_IMX; ++ iAdaptersFound++; ++ } ++#endif + +-#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && !defined(HAVE_AOCEC_API) ++#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && \ ++ !defined(HAVE_EXYNOS_API) && !defined(HAVE_AOCEC_API) && !defined(HAVE_IMX_API) + #error "libCEC doesn't have support for any type of adapter. please check your build system or configuration" + #endif + +@@ -173,11 +191,17 @@ IAdapterCommunication *CAdapterFactory::GetInstance(const char *strPort, uint16_ + return new CRPiCECAdapterCommunication(m_lib->m_cec); + #endif + ++#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) && !defined(HAVE_EXYNOS_API) && !defined(HAVE_AOCEC_API) ++#if !defined(HAVE_RPI_API) && !defined(HAVE_P8_USB) && !defined(HAVE_TDA995X_API) && \ ++ !defined(HAVE_EXYNOS_API) && !defined(HAVE_AOCEC_API) && !defined(HAVE_IMX_API) + return NULL; + #endif + } +diff --git a/src/libcec/adapter/IMX/IMXCECAdapterCommunication.cpp b/src/libcec/adapter/IMX/IMXCECAdapterCommunication.cpp +new file mode 100644 +index 0000000..f433b03 +--- /dev/null ++++ b/src/libcec/adapter/IMX/IMXCECAdapterCommunication.cpp +@@ -0,0 +1,321 @@ ++/* ++ * 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" ++ ++#if defined(HAVE_IMX_API) ++#include "IMXCECAdapterCommunication.h" ++ ++#include "p8-platform/sockets/cdevsocket.h" ++#include "CECTypeUtils.h" ++#include "LibCEC.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 P8PLATFORM; ++ ++#define LIB_CEC m_callback->GetLib() ++ ++// these are defined in nxp private header file ++#define CEC_MSG_SUCCESS 0x00 /*Message transmisson Succeed*/ ++#define CEC_CSP_OFF_STATE 0x80 /*CSP in Off State*/ ++#define CEC_BAD_REQ_SERVICE 0x81 /*Bad .req service*/ ++#define CEC_MSG_FAIL_UNABLE_TO_ACCESS 0x82 /*Message transmisson failed: Unable to access CEC line*/ ++#define CEC_MSG_FAIL_ARBITRATION_ERROR 0x83 /*Message transmisson failed: Arbitration error*/ ++#define CEC_MSG_FAIL_BIT_TIMMING_ERROR 0x84 /*Message transmisson failed: Bit timming error*/ ++#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) ++{ ++ CLockObject lock(m_mutex); ++ ++ m_iNextMessage = 0; ++ m_logicalAddress = CECDEVICE_UNKNOWN; ++ m_bLogicalAddressRegistered = false; ++ m_bInitialised = false; ++ m_dev = new CCDevSocket(CEC_IMX_PATH); ++} ++ ++CIMXCECAdapterCommunication::~CIMXCECAdapterCommunication(void) ++{ ++ Close(); ++ ++ CLockObject lock(m_mutex); ++ delete m_dev; ++ m_dev = 0; ++} ++ ++bool CIMXCECAdapterCommunication::IsOpen(void) ++{ ++ return IsInitialised() && m_dev->IsOpen(); ++} ++ ++bool CIMXCECAdapterCommunication::Open(uint32_t iTimeoutMs, bool UNUSED(bSkipChecks), bool bStartListening) ++{ ++ if (m_dev->Open(iTimeoutMs)) ++ { ++ if (!bStartListening || CreateThread()) { ++ if (m_dev->Ioctl(HDMICEC_IOC_STARTDEVICE, NULL) == 0) { ++ m_bInitialised = true; ++ return true; ++ } ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: Unable to start device\n", __func__); ++ } ++ m_dev->Close(); ++ } ++ ++ return false; ++} ++ ++ ++void CIMXCECAdapterCommunication::Close(void) ++{ ++ StopThread(0); ++ ++ CLockObject lock(m_mutex); ++ if (!m_bInitialised) { ++ return; ++ } ++ 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(); ++ m_bInitialised = false; ++} ++ ++ ++std::string CIMXCECAdapterCommunication::GetError(void) const ++{ ++ std::string strError(m_strError); ++ return strError; ++} ++ ++ ++cec_adapter_message_state CIMXCECAdapterCommunication::Write( ++ const cec_command &data, bool &UNUSED(bRetry), uint8_t UNUSED(iLineTimeout), bool UNUSED(bIsReply)) ++{ ++ int error, msg_len = 1; ++ unsigned char message[MAX_CEC_MESSAGE_LEN]; ++ ++ 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; ++ } ++ ++ message[0] = (data.initiator << 4) | (data.destination & 0x0f); ++ if (data.opcode_set) ++ { ++ message[1] = data.opcode; ++ msg_len++; ++ memcpy(&message[2], data.parameters.data, data.parameters.size); ++ msg_len+=data.parameters.size; ++ } ++ ++ if (m_dev->Write(message, msg_len) == msg_len) ++ return ADAPTER_MESSAGE_STATE_SENT_ACKED; ++ ++ error = m_dev->GetErrorNumber(); ++ if (error == EIO) ++ return ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED; ++ ++ if (error != EAGAIN) ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: write error %d", __func__, error); ++ ++ return ADAPTER_MESSAGE_STATE_ERROR; ++} ++ ++ ++uint16_t CIMXCECAdapterCommunication::GetFirmwareVersion(void) ++{ ++ /* FIXME add ioctl ? */ ++ return 1; ++} ++ ++ ++cec_vendor_id CIMXCECAdapterCommunication::GetVendorId(void) ++{ ++ return CEC_VENDOR_UNKNOWN; ++} ++ ++ ++uint16_t CIMXCECAdapterCommunication::GetPhysicalAddress(void) ++{ ++ uint32_t info; ++ uint16_t phy_addr; ++ ++ 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; ++ } ++ /* Rebuild 16 bit raw value from fsl 32 bits value */ ++ phy_addr = ((info & 0x0f) << 12) | (info & 0x0f00) | ++ ((info & 0x0f0000) >> 12) | ((info & 0x0f000000) >> 24); ++ ++ return phy_addr; ++} ++ ++ ++cec_logical_addresses CIMXCECAdapterCommunication::GetLogicalAddresses(void) ++{ ++ cec_logical_addresses addresses; ++ addresses.Clear(); ++ ++ CLockObject lock(m_mutex); ++ if ((m_logicalAddress & (CECDEVICE_UNKNOWN | CECDEVICE_UNREGISTERED)) == 0) ++ addresses.Set(m_logicalAddress); ++ ++ return addresses; ++} ++ ++void CIMXCECAdapterCommunication::HandleLogicalAddressLost(cec_logical_address UNUSED(oldAddress)) ++{ ++ UnregisterLogicalAddress(); ++} ++ ++bool CIMXCECAdapterCommunication::UnregisterLogicalAddress(void) ++{ ++ CLockObject lock(m_mutex); ++ if (!m_bLogicalAddressRegistered) ++ return true; ++ ++ if (m_dev->Ioctl(HDMICEC_IOC_SETLOGICALADDRESS, (void *)CECDEVICE_BROADCAST) != 0) ++ { ++ LIB_CEC->AddLog(CEC_LOG_ERROR, "%s: HDMICEC_IOC_SETLOGICALADDRESS failed !", __func__); ++ return false; ++ } ++ ++ m_logicalAddress = CECDEVICE_UNKNOWN; ++ m_bLogicalAddressRegistered = false; ++ return true; ++} ++ ++bool CIMXCECAdapterCommunication::RegisterLogicalAddress(const cec_logical_address address) ++{ ++ CLockObject lock(m_mutex); ++ ++ if (m_logicalAddress == address && m_bLogicalAddressRegistered) ++ { ++ return true; ++ } ++ ++ 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 = address; ++ m_bLogicalAddressRegistered = true; ++ return true; ++} ++ ++bool CIMXCECAdapterCommunication::SetLogicalAddresses(const cec_logical_addresses &addresses) ++{ ++ int log_addr = addresses.primary; ++ ++ return RegisterLogicalAddress((cec_logical_address)log_addr); ++} ++ ++void *CIMXCECAdapterCommunication::Process(void) ++{ ++ hdmi_cec_event event; ++ int ret; ++ ++ cec_logical_address initiator, destination; ++ ++ while (!IsStopped()) ++ { ++ ret = m_dev->Read((char *)&event, sizeof(event), 1000); ++ 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); ++ } ++ ++ if (event.event_type == MESSAGE_TYPE_CONNECTED) ++ /* HDMI has just been reconnected - Notify phy address*/ ++ { ++ uint16_t iNewAddress = GetPhysicalAddress(); ++ m_callback->HandlePhysicalAddressChanged(iNewAddress); ++ } ++ /* 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/libcec/adapter/IMX/IMXCECAdapterCommunication.h b/src/libcec/adapter/IMX/IMXCECAdapterCommunication.h +new file mode 100644 +index 0000000..7862656 +--- /dev/null ++++ b/src/libcec/adapter/IMX/IMXCECAdapterCommunication.h +@@ -0,0 +1,115 @@ ++#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 "p8-platform/threads/mutex.h" ++#include "p8-platform/threads/threads.h" ++#include "p8-platform/sockets/socket.h" ++#include "adapter/AdapterCommunication.h" ++#include ++ ++#define IMX_ADAPTER_VID 0x0471 /*FIXME TBD*/ ++#define IMX_ADAPTER_PID 0x1001 ++ ++ ++ ++namespace P8PLATFORM ++{ ++ class CCDevSocket; ++}; ++ ++ ++namespace CEC ++{ ++ class CIMXCECAdapterCommunication : public IAdapterCommunication, public P8PLATFORM::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 HandleLogicalAddressLost(cec_logical_address UNUSED(oldAddress)); ++ void SetActiveSource(bool UNUSED(bSetTo), bool UNUSED(bClientUnregistered)) {} ++ bool RegisterLogicalAddress(const cec_logical_address address); ++ ///} ++ ++ /** @name P8PLATFORM::CThread implementation */ ++ ///{ ++ void *Process(void); ++ ///} ++ ++ private: ++ bool IsInitialised(void) const { return m_bInitialised; }; ++ bool UnregisterLogicalAddress(void); ++ ++ std::string m_strError; /**< current error message */ ++ ++ cec_logical_address m_logicalAddress; ++ ++ P8PLATFORM::CMutex m_mutex; ++ P8PLATFORM::CCDevSocket *m_dev; /**< the device connection */ ++ bool m_bLogicalAddressRegistered; ++ bool m_bInitialised; ++ ++ P8PLATFORM::CMutex m_messageMutex; ++ uint32_t m_iNextMessage; ++ }; ++ ++}; ++ ++#endif +diff --git a/src/libcec/adapter/IMX/IMXCECAdapterDetection.cpp b/src/libcec/adapter/IMX/IMXCECAdapterDetection.cpp +new file mode 100644 +index 0000000..dc4dca0 +--- /dev/null ++++ b/src/libcec/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/libcec/adapter/IMX/IMXCECAdapterDetection.h b/src/libcec/adapter/IMX/IMXCECAdapterDetection.h +new file mode 100644 +index 0000000..14af8d8 +--- /dev/null ++++ b/src/libcec/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); ++ }; ++} +diff --git a/src/libcec/cmake/CheckPlatformSupport.cmake b/src/libcec/cmake/CheckPlatformSupport.cmake +index 532f213..4ef5d75 100644 +--- a/src/libcec/cmake/CheckPlatformSupport.cmake ++++ b/src/libcec/cmake/CheckPlatformSupport.cmake +@@ -10,6 +10,7 @@ + # HAVE_TDA995X_API ON if TDA995X is supported + # HAVE_EXYNOS_API ON if Exynos is supported + # HAVE_AOCEC_API ON if AOCEC is supported ++# HAVE_IMX_API ON if iMX.6 is supported + # HAVE_P8_USB ON if Pulse-Eight devices are supported + # HAVE_P8_USB_DETECT ON if Pulse-Eight devices can be auto-detected + # HAVE_DRM_EDID_PARSER ON if DRM EDID parsing is supported +@@ -148,6 +149,18 @@ else() + else() + set(HAVE_AOCEC_API 0) + endif() ++ ++ # i.MX6 ++ if (${HAVE_IMX_API}) ++ set(LIB_INFO "${LIB_INFO}, 'i.MX6'") ++ set(HAVE_IMX_API 1) ++ set(CEC_SOURCES_ADAPTER_IMX adapter/IMX/IMXCECAdapterCommunication.cpp ++ adapter/IMX/IMXCECAdapterDetection.cpp) ++ source_group("Source Files\\adapter\\IMX" FILES ${CEC_SOURCES_ADAPTER_IMX}) ++ list(APPEND CEC_SOURCES ${CEC_SOURCES_ADAPTER_IMX}) ++ else() ++ set(HAVE_IMX_API 0) ++ endif() + endif() + + # rt +diff --git a/src/libcec/cmake/DisplayPlatformSupport.cmake b/src/libcec/cmake/DisplayPlatformSupport.cmake +index 7ec10f5..2262638 100644 +--- a/src/libcec/cmake/DisplayPlatformSupport.cmake ++++ b/src/libcec/cmake/DisplayPlatformSupport.cmake +@@ -45,9 +45,15 @@ else() + endif() + + if (HAVE_AOCEC_API) +- message(STATUS "AOCEC support: yes") ++ message(STATUS "AOCEC support: yes") + else() +- message(STATUS "AOCEC support: no") ++ message(STATUS "AOCEC support: no") ++endif() ++ ++if (HAVE_IMX_API) ++ message(STATUS "i.MX6 support: yes") ++else() ++ message(STATUS "i.MX6 support: no") + endif() + + if (HAVE_PYTHON) +diff --git a/src/libcec/env.h.in b/src/libcec/env.h.in +index fe6c83d..e96bcd5 100644 +--- a/src/libcec/env.h.in ++++ b/src/libcec/env.h.in +@@ -73,6 +73,9 @@ + /* Define to 1 for TDA995x support */ + #cmakedefine HAVE_TDA995X_API @HAVE_TDA995X_API@ + ++/* Define to 1 for IMX support */ ++#cmakedefine HAVE_IMX_API @HAVE_IMX_API@ ++ + /* Define to 1 for Exynos support */ + #cmakedefine HAVE_EXYNOS_API @HAVE_EXYNOS_API@ + +-- +2.7.1 + diff --git a/projects/imx6/patches/libcec/libcec-100-from-xbian.patch b/projects/imx6/patches/libcec/4.4-xbian/libcec-100-from-xbian.patch similarity index 99% rename from projects/imx6/patches/libcec/libcec-100-from-xbian.patch rename to projects/imx6/patches/libcec/4.4-xbian/libcec-100-from-xbian.patch index d13979c324..943d9f8c24 100644 --- a/projects/imx6/patches/libcec/libcec-100-from-xbian.patch +++ b/projects/imx6/patches/libcec/4.4-xbian/libcec-100-from-xbian.patch @@ -1,11 +1,11 @@ -From bff5c44d1c5deeda77439c0f6d8e0ab1fa76c167 Mon Sep 17 00:00:00 2001 +From 714ce8ee2ba07fe88249b8033d875f58ed21a4ab Mon Sep 17 00:00:00 2001 From: Peter Vicman -Date: Sat, 3 Dec 2016 11:33:39 +0100 +Date: Thu, 12 Jan 2017 09:36:24 +0100 Subject: [PATCH] patch for libcec from xbian -libcec base: libcec-209884d +libcec base: libcec-2fc92b5 libcec xbian: - https://github.com/xbianonpi/xbian-sources-libcec/tree/masterv4 2ff5a0175937d5b190256c679d0b3b6f564f903a + https://github.com/xbianonpi/xbian-sources-libcec/tree/masterv4 e12f92586ccda4fe20814c93d5830ed3a33f3a4e --- CMakeLists.txt | 6 + debian/control | 7 +- @@ -52,12 +52,12 @@ libcec xbian: create mode 100644 src/libcec/implementations/GRCommandHandler.h diff --git a/CMakeLists.txt b/CMakeLists.txt -index 123b3b4..cdf1317 100644 +index 4f01662..7c19dd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ set(LIBCEC_VERSION_MAJOR 4) set(LIBCEC_VERSION_MINOR 0) - set(LIBCEC_VERSION_PATCH 0) + set(LIBCEC_VERSION_PATCH 1) +find_program(CCACHE_FOUND ccache) +if(CCACHE_FOUND) @@ -475,7 +475,7 @@ index 7155926..b9e393b 100644 const char* ToString(const cec_menu_state state) { return CCECTypeUtils::ToString(state); } const char* ToString(const cec_version version) { return CCECTypeUtils::ToString(version); } diff --git a/src/libcec/adapter/AdapterFactory.cpp b/src/libcec/adapter/AdapterFactory.cpp -index 1e946e6..261c60d 100644 +index 91195ea..e2460ad 100644 --- a/src/libcec/adapter/AdapterFactory.cpp +++ b/src/libcec/adapter/AdapterFactory.cpp @@ -63,6 +63,11 @@ @@ -1458,7 +1458,7 @@ index db682c1..15b6a23 100755 commits_since_tag=`git log ${last_tag}..HEAD --oneline | wc -l` git_dirty=`git diff HEAD | wc -l` diff --git a/src/libcec/devices/CECBusDevice.cpp b/src/libcec/devices/CECBusDevice.cpp -index 612be6d..2be9816 100644 +index 99f762c..be72b05 100644 --- a/src/libcec/devices/CECBusDevice.cpp +++ b/src/libcec/devices/CECBusDevice.cpp @@ -44,6 +44,7 @@ @@ -1511,10 +1511,10 @@ index b8255aa..8493d48 100644 static CCECAudioSystem * AsAudioSystem(CCECBusDevice *device); CCECPlaybackDevice * AsPlaybackDevice(void); diff --git a/src/libcec/env.h.in b/src/libcec/env.h.in -index fe6c83d..91c7a27 100644 +index 0774a1c..14c7704 100644 --- a/src/libcec/env.h.in +++ b/src/libcec/env.h.in -@@ -66,6 +66,9 @@ +@@ -70,6 +70,9 @@ /* Define to 1 for Raspberry Pi support */ #cmakedefine HAVE_RPI_API @HAVE_RPI_API@ @@ -1762,5 +1762,5 @@ index 0000000..e01c7fc + }; +}; -- -2.7.1 +2.7.4