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