3 * This file is part of the libCEC(R) library.
5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
10 * This program is dual-licensed; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
28 * For more information contact:
29 * Pulse-Eight Licensing <license@pulse-eight.com>
30 * http://www.pulse-eight.com/
31 * http://www.pulse-eight.net/
34 #if defined(HAVE_TDA995X_API)
36 #include "lib/platform/threads/mutex.h"
37 #include "lib/platform/threads/threads.h"
38 #include "lib/platform/sockets/socket.h"
39 #include "lib/adapter/AdapterCommunication.h"
51 class CAdapterMessageQueueEntry
;
53 class CNxpCECAdapterCommunication
: public IAdapterCommunication
, public PLATFORM::CThread
57 * @brief Create a new USB-CEC communication handler.
58 * @param callback The callback to use for incoming CEC commands.
60 CNxpCECAdapterCommunication(IAdapterCommunicationCallback
*callback
);
61 virtual ~CNxpCECAdapterCommunication(void);
63 /** @name IAdapterCommunication implementation */
65 bool Open(uint32_t iTimeoutMs
= CEC_DEFAULT_CONNECT_TIMEOUT
, bool bSkipChecks
= false, bool bStartListening
= true);
68 std::string
GetError(void) const;
69 cec_adapter_message_state
Write(const cec_command
&data
, bool &bRetry
, uint8_t iLineTimeout
, bool bIsReply
);
71 bool SetLineTimeout(uint8_t UNUSED(iTimeout
)) { return true; }
72 bool StartBootloader(void) { return false; }
73 bool SetLogicalAddresses(const cec_logical_addresses
&addresses
);
74 cec_logical_addresses
GetLogicalAddresses(void);
75 bool PingAdapter(void) { return IsInitialised(); }
76 uint16_t GetFirmwareVersion(void);
77 uint32_t GetFirmwareBuildDate(void) { return 0; }
78 bool IsRunningLatestFirmware(void) { return true; }
79 bool PersistConfiguration(const libcec_configuration
& UNUSED(configuration
)) { return false; }
80 bool GetConfiguration(libcec_configuration
& UNUSED(configuration
)) { return false; }
81 std::string
GetPortName(void) { return std::string("NXP"); }
82 uint16_t GetPhysicalAddress(void);
83 bool SetControlledMode(bool UNUSED(controlled
)) { return true; }
84 cec_vendor_id
GetVendorId(void);
85 bool SupportsSourceLogicalAddress(const cec_logical_address address
) { return address
> CECDEVICE_TV
&& address
<= CECDEVICE_BROADCAST
; }
86 cec_adapter_type
GetAdapterType(void) { return ADAPTERTYPE_TDA995x
; }
87 void HandleLogicalAddressLost(cec_logical_address oldAddress
);
90 /** @name PLATFORM::CThread implementation */
96 bool IsInitialised(void) const { return m_dev
!= 0; };
98 std::string m_strError
; /**< current error message */
100 bool m_bLogicalAddressChanged
;
101 cec_logical_addresses m_logicalAddresses
;
103 PLATFORM::CMutex m_mutex
;
104 PLATFORM::CCDevSocket
*m_dev
; /**< the device connection */
106 PLATFORM::CMutex m_messageMutex
;
107 uint32_t m_iNextMessage
;
108 std::map
<uint32_t, CAdapterMessageQueueEntry
*> m_messages
;