added the type of adapter to libcec_configuration, and display the type in cec-client...
[deb_libcec.git] / src / lib / adapter / Pulse-Eight / USBCECAdapterCommands.h
CommitLineData
a75e3a5a
LOK
1#pragma once
2/*
3 * This file is part of the libCEC(R) library.
4 *
5 * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved.
6 * libCEC(R) is an original work, containing original code.
7 *
8 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 *
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.
14 *
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.
19 *
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.
23 *
24 *
25 * Alternatively, you can license this library under a commercial license,
26 * please contact Pulse-Eight Licensing for more information.
27 *
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/
32 */
33
c8b0c13a 34#include "lib/platform/threads/mutex.h"
cb8feb41 35#include "USBCECAdapterMessage.h"
c8b0c13a 36
a75e3a5a
LOK
37namespace CEC
38{
2b44051c
LOK
39 class CUSBCECAdapterCommunication;
40
a75e3a5a
LOK
41 class CUSBCECAdapterCommands
42 {
43 public:
7c5c5bf4 44 CUSBCECAdapterCommands(CUSBCECAdapterCommunication *comm);
a75e3a5a
LOK
45
46 /*!
47 * @brief Request the firmware version from the adapter.
48 * @return The firmware version, or 1 (default) if it couldn't be retrieved.
49 */
50 uint16_t RequestFirmwareVersion(void);
51
7c5c5bf4
LOK
52 /*!
53 * @return The firmware version of the adapter, retrieved when the connection is opened.
54 */
55 uint16_t GetFirmwareVersion(void) const { return m_persistedConfiguration.iFirmwareVersion; };
56
57 /*!
2b44051c 58 * @brief Update the current configuration in the adapter. Does not do an eeprom update.
7c5c5bf4
LOK
59 * @attention Not all settings are persisted at this time.
60 * @param configuration The configuration to persist.
2b44051c 61 * @return True when something changed, false otherwise.
7c5c5bf4 62 */
c0152c09 63 bool PersistConfiguration(const libcec_configuration &configuration);
7c5c5bf4
LOK
64
65 /*!
66 * @brief Get the persisted configuration from the EEPROM.
67 * @param configuration The persisted configuration.
68 * @return True when retrieved, false otherwise.
69 */
c0152c09 70 bool GetConfiguration(libcec_configuration &configuration);
7c5c5bf4
LOK
71
72 /*!
73 * @brief Send a ping command to the adapter.
74 * @return True when acked by the adapter, false otherwise.
75 */
76 bool PingAdapter(void);
77
78 /*!
79 * @brief Change the ackmask of the adapter.
80 * @param iMask The new mask.
81 * @return True when the change was acked by the adapter, false otherwise.
82 */
83 bool SetAckMask(uint16_t iMask);
84
85 /*!
86 * @brief Put the adapter in bootloader mode.
87 * @attention The connection needs to be closed after this call, since the adapter will no longer be available.
88 * @return True when the command was sent, false otherwise.
89 */
90 bool StartBootloader(void);
91
92 /*!
93 * @brief Change the current CEC line timeout.
94 * @param iTimeout The new timeout.
95 * @return True when the change was acked by the adapter, false otherwise.
96 */
97 bool SetLineTimeout(uint8_t iTimeout);
98
99 /*!
100 * @brief Put the adapter in controlled or autonomous mode.
101 * @param controlled True to switch to controlled mode, false to switch to auto mode.
102 * @return True when acked by the controller, false otherwise.
103 */
104 bool SetControlledMode(bool controlled);
105
b2f56d35
LOK
106 /*!
107 * @brief Request the firmware build date from the device.
108 * @return The build date in seconds since epoch, or 0 when no (valid) reply was received.
109 */
110 uint32_t RequestBuildDate(void);
111
5943b9d1
LOK
112 /*!
113 * @return The persisted build date.
114 */
115 uint32_t GetPersistedBuildDate(void) const { return m_iBuildDate; };
116
2d418322
LOK
117 /*!
118 * @brief Request the adapter type.
119 * @return The type
120 */
121 p8_cec_adapter_type RequestAdapterType(void);
122
123 /*!
124 * @return The persisted build date.
125 */
126 p8_cec_adapter_type GetPersistedAdapterType(void) const { return m_adapterType; };
127
2b44051c
LOK
128 /*!
129 * @brief Persist the current settings in the EEPROM
130 * @return True when persisted, false otherwise.
131 */
132 bool WriteEEPROM(void);
133
7c5c5bf4
LOK
134 private:
135 /*!
136 * @brief Reads all settings from the eeprom.
137 * @return True when read, false otherwise.
138 */
139 bool RequestSettings(void);
140
a75e3a5a
LOK
141 /*!
142 * @brief Request a setting value from the adapter.
143 * @param msgCode The setting to retrieve.
144 * @return The response from the adapter.
145 */
146 cec_datapacket RequestSetting(cec_adapter_messagecode msgCode);
147
148 /*!
149 * @brief Change the value of the "auto enabled" setting.
150 * @param enabled The new value.
2b44051c 151 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
152 */
153 bool SetSettingAutoEnabled(bool enabled);
154
155 /*!
156 * @brief Request the value of the "auto enabled" setting from the adapter.
a75e3a5a
LOK
157 * @return True when retrieved, false otherwise.
158 */
7c5c5bf4 159 bool RequestSettingAutoEnabled(void);
a75e3a5a
LOK
160
161 /*!
162 * @brief Change the value of the "device type" setting, used when the device is in autonomous mode.
163 * @param type The new value.
2b44051c 164 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
165 */
166 bool SetSettingDeviceType(cec_device_type type);
167
168 /*!
169 * @brief Request the value of the "device type" setting from the adapter.
a75e3a5a
LOK
170 * @return True when retrieved, false otherwise.
171 */
7c5c5bf4 172 bool RequestSettingDeviceType(void);
a75e3a5a
LOK
173
174 /*!
175 * @brief Change the value of the "default logical address" setting, used when the device is in autonomous mode.
176 * @param address The new value.
2b44051c 177 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
178 */
179 bool SetSettingDefaultLogicalAddress(cec_logical_address address);
180
181 /*!
182 * @brief Request the value of the "default logical address" setting from the adapter.
a75e3a5a
LOK
183 * @return True when retrieved, false otherwise.
184 */
7c5c5bf4 185 bool RequestSettingDefaultLogicalAddress(void);
a75e3a5a
LOK
186
187 /*!
188 * @brief Change the value of the "logical address mask" setting, used when the device is in autonomous mode.
189 * @param iMask The new value.
2b44051c 190 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
191 */
192 bool SetSettingLogicalAddressMask(uint16_t iMask);
193
194 /*!
195 * @brief Request the value of the "logical address mask" setting from the adapter.
a75e3a5a
LOK
196 * @return True when retrieved, false otherwise.
197 */
7c5c5bf4 198 bool RequestSettingLogicalAddressMask(void);
a75e3a5a
LOK
199
200 /*!
201 * @brief Change the value of the "physical address" setting, used when the device is in autonomous mode.
202 * @param iPhysicalAddress The new value.
2b44051c 203 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
204 */
205 bool SetSettingPhysicalAddress(uint16_t iPhysicalAddress);
206
207 /*!
208 * @brief Request the value of the "physical address" setting from the adapter.
a75e3a5a
LOK
209 * @return True when retrieved, false otherwise.
210 */
7c5c5bf4 211 bool RequestSettingPhysicalAddress(void);
a75e3a5a
LOK
212
213 /*!
214 * @brief Change the value of the "CEC version" setting, used when the device is in autonomous mode.
215 * @param version The new value.
2b44051c 216 * @return True when changed and set, false otherwise.
a75e3a5a
LOK
217 */
218 bool SetSettingCECVersion(cec_version version);
219
220 /*!
221 * @brief Request the value of the "CEC version" setting from the adapter.
a75e3a5a
LOK
222 * @return True when retrieved, false otherwise.
223 */
7c5c5bf4 224 bool RequestSettingCECVersion(void);
a75e3a5a
LOK
225
226 /*!
227 * @brief Change the value of the "OSD name" setting, used when the device is in autonomous mode.
228 * @param strOSDName The new value.
229 * @return True when set, false otherwise.
230 */
231 bool SetSettingOSDName(const char *strOSDName);
232
233 /*!
234 * @brief Request the value of the "OSD name" setting from the adapter.
a75e3a5a
LOK
235 * @return True when retrieved, false otherwise.
236 */
7c5c5bf4 237 bool RequestSettingOSDName(void);
a75e3a5a 238
7c5c5bf4
LOK
239 CUSBCECAdapterCommunication *m_comm; /**< the communication handler */
240 bool m_bSettingsRetrieved; /**< true when the settings were read from the eeprom, false otherwise */
241 bool m_bSettingAutoEnabled; /**< the value of the auto-enabled setting */
242 cec_version m_settingCecVersion; /**< the value of the cec version setting */
243 uint16_t m_iSettingLAMask; /**< the value of the LA mask setting */
244 bool m_bNeedsWrite; /**< true when we sent changed settings to the adapter that have not been persisted */
245 libcec_configuration m_persistedConfiguration; /**< the configuration that is persisted in the eeprom */
b2f56d35 246 uint32_t m_iBuildDate; /**< the build date of the firmware */
a38292a3 247 bool m_bControlledMode; /**< current value of the controlled mode feature */
2d418322 248 p8_cec_adapter_type m_adapterType; /**< the type of the adapter that we're connected to */
c8b0c13a 249 PLATFORM::CMutex m_mutex;
a75e3a5a
LOK
250 };
251}