Commit | Line | Data |
---|---|---|
abbca718 LOK |
1 | /* |
2 | * This file is part of the libCEC(R) library. | |
3 | * | |
b492c10e | 4 | * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. |
abbca718 LOK |
5 | * libCEC(R) is an original work, containing original code. |
6 | * | |
7 | * libCEC(R) is a trademark of Pulse-Eight Limited. | |
8 | * | |
9 | * This program is dual-licensed; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 | * | |
23 | * | |
24 | * Alternatively, you can license this library under a commercial license, | |
25 | * please contact Pulse-Eight Licensing for more information. | |
26 | * | |
27 | * For more information contact: | |
28 | * Pulse-Eight Licensing <license@pulse-eight.com> | |
29 | * http://www.pulse-eight.com/ | |
30 | * http://www.pulse-eight.net/ | |
31 | */ | |
32 | ||
2abe74eb | 33 | #include "CECProcessor.h" |
abbca718 | 34 | |
7bb4ed43 | 35 | #include "adapter/USBCECAdapterCommunication.h" |
eafa9d46 | 36 | #include "devices/CECBusDevice.h" |
51b2a094 LOK |
37 | #include "devices/CECAudioSystem.h" |
38 | #include "devices/CECPlaybackDevice.h" | |
39 | #include "devices/CECRecordingDevice.h" | |
40 | #include "devices/CECTuner.h" | |
41 | #include "devices/CECTV.h" | |
62f5527d | 42 | #include "implementations/CECCommandHandler.h" |
2abe74eb | 43 | #include "LibCEC.h" |
ba65909d | 44 | #include "platform/util/timeutils.h" |
abbca718 LOK |
45 | |
46 | using namespace CEC; | |
47 | using namespace std; | |
f00ff009 | 48 | using namespace PLATFORM; |
abbca718 | 49 | |
caca2d81 LOK |
50 | CCECProcessor::CCECProcessor(CLibCEC *controller, const libcec_configuration *configuration) : |
51 | m_bInitialised(false), | |
52 | m_iPhysicalAddress(configuration->iPhysicalAddress), | |
53 | m_iHDMIPort(configuration->iHDMIPort), | |
54 | m_iBaseDevice(configuration->baseDevice), | |
55 | m_strDeviceName(configuration->strDeviceName), | |
56 | m_types(configuration->deviceTypes), | |
57 | m_communication(NULL), | |
58 | m_controller(controller), | |
59 | m_bMonitor(false), | |
60 | m_iStandardLineTimeout(3), | |
61 | m_iRetryLineTimeout(3), | |
62 | m_iLastTransmission(0), | |
63 | m_clientVersion(configuration->clientVersion) | |
64 | { | |
65 | m_logicalAddresses.Clear(); | |
66 | CreateBusDevices(); | |
67 | } | |
68 | ||
69 | CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, const cec_device_type_list &types, uint16_t iPhysicalAddress, cec_client_version clientVersion) : | |
b64db02e | 70 | m_bInitialised(false), |
4f362964 | 71 | m_iPhysicalAddress(iPhysicalAddress), |
16b1e052 | 72 | m_iHDMIPort(CEC_DEFAULT_HDMI_PORT), |
d2f1c157 | 73 | m_iBaseDevice((cec_logical_address)CEC_DEFAULT_BASE_DEVICE), |
f8513317 LOK |
74 | m_strDeviceName(strDeviceName), |
75 | m_types(types), | |
99666519 | 76 | m_communication(NULL), |
f8513317 | 77 | m_controller(controller), |
dcd240b2 LOK |
78 | m_bMonitor(false), |
79 | m_iStandardLineTimeout(3), | |
5f316715 | 80 | m_iRetryLineTimeout(3), |
caca2d81 LOK |
81 | m_iLastTransmission(0), |
82 | m_clientVersion(clientVersion) | |
f8513317 | 83 | { |
ab1469a0 | 84 | m_logicalAddresses.Clear(); |
caca2d81 LOK |
85 | CreateBusDevices(); |
86 | } | |
87 | ||
88 | void CCECProcessor::CreateBusDevices(void) | |
89 | { | |
f8513317 | 90 | for (int iPtr = 0; iPtr < 16; iPtr++) |
51b2a094 LOK |
91 | { |
92 | switch(iPtr) | |
93 | { | |
94 | case CECDEVICE_AUDIOSYSTEM: | |
5d5a2dc2 | 95 | m_busDevices[iPtr] = new CCECAudioSystem(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
96 | break; |
97 | case CECDEVICE_PLAYBACKDEVICE1: | |
98 | case CECDEVICE_PLAYBACKDEVICE2: | |
99 | case CECDEVICE_PLAYBACKDEVICE3: | |
5d5a2dc2 | 100 | m_busDevices[iPtr] = new CCECPlaybackDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
101 | break; |
102 | case CECDEVICE_RECORDINGDEVICE1: | |
103 | case CECDEVICE_RECORDINGDEVICE2: | |
104 | case CECDEVICE_RECORDINGDEVICE3: | |
5d5a2dc2 | 105 | m_busDevices[iPtr] = new CCECRecordingDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
106 | break; |
107 | case CECDEVICE_TUNER1: | |
108 | case CECDEVICE_TUNER2: | |
109 | case CECDEVICE_TUNER3: | |
110 | case CECDEVICE_TUNER4: | |
5d5a2dc2 | 111 | m_busDevices[iPtr] = new CCECTuner(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
112 | break; |
113 | case CECDEVICE_TV: | |
114 | m_busDevices[iPtr] = new CCECTV(this, (cec_logical_address) iPtr, 0); | |
115 | break; | |
116 | default: | |
5d5a2dc2 | 117 | m_busDevices[iPtr] = new CCECBusDevice(this, (cec_logical_address) iPtr, 0xFFFF); |
51b2a094 LOK |
118 | break; |
119 | } | |
120 | } | |
f8513317 LOK |
121 | } |
122 | ||
2abe74eb | 123 | CCECProcessor::~CCECProcessor(void) |
abbca718 | 124 | { |
eca71746 | 125 | Close(); |
7c63a480 | 126 | |
d1998c7b LOK |
127 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) |
128 | delete m_busDevices[iPtr]; | |
abbca718 LOK |
129 | } |
130 | ||
eca71746 LOK |
131 | void CCECProcessor::Close(void) |
132 | { | |
133 | StopThread(); | |
134 | ||
135 | CLockObject lock(m_mutex); | |
136 | if (m_communication) | |
137 | { | |
138 | m_communication->Close(); | |
139 | delete m_communication; | |
140 | m_communication = NULL; | |
141 | } | |
142 | } | |
143 | ||
578c3905 | 144 | bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint32_t iTimeoutMs) |
abbca718 | 145 | { |
a674fd68 | 146 | bool bReturn(false); |
578c3905 | 147 | CLockObject lock(m_mutex); |
99666519 | 148 | if (m_communication) |
578c3905 | 149 | { |
9f9c8c82 LOK |
150 | CLibCEC::AddLog(CEC_LOG_WARNING, "existing connection handler found, deleting it"); |
151 | m_communication->Close(); | |
152 | delete m_communication; | |
578c3905 | 153 | } |
1113cb7d | 154 | |
7bb4ed43 | 155 | m_communication = new CUSBCECAdapterCommunication(this, strPort, iBaudRate); |
99666519 | 156 | |
578c3905 LOK |
157 | /* check for an already opened connection */ |
158 | if (m_communication->IsOpen()) | |
1113cb7d | 159 | { |
5477a250 | 160 | CLibCEC::AddLog(CEC_LOG_ERROR, "connection already opened"); |
578c3905 LOK |
161 | return bReturn; |
162 | } | |
abbca718 | 163 | |
c520af4f LOK |
164 | uint64_t iNow = GetTimeMs(); |
165 | uint64_t iTarget = iTimeoutMs > 0 ? iNow + iTimeoutMs : iNow + CEC_DEFAULT_TRANSMIT_WAIT; | |
166 | ||
578c3905 | 167 | /* open a new connection */ |
efed01e1 LOK |
168 | unsigned iConnectTry(0); |
169 | while (iNow < iTarget && (bReturn = m_communication->Open(this, iTimeoutMs)) == false) | |
3d78df91 LOK |
170 | { |
171 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not open a connection (try %d)", ++iConnectTry); | |
172 | Sleep(500); | |
173 | iNow = GetTimeMs(); | |
174 | } | |
56035c86 | 175 | |
efed01e1 | 176 | if (bReturn) |
caca2d81 | 177 | CLibCEC::AddLog(CEC_LOG_NOTICE, "connected to the CEC adapter. firmware version = %d, client version = %s", m_communication->GetFirmwareVersion(), ToString(m_clientVersion)); |
3d78df91 | 178 | |
578c3905 LOK |
179 | return bReturn; |
180 | } | |
181 | ||
0cfdeb5a LOK |
182 | bool CCECProcessor::IsInitialised(void) |
183 | { | |
184 | CLockObject lock(m_mutex); | |
185 | return m_bInitialised; | |
186 | } | |
187 | ||
2db8981f | 188 | void CCECProcessor::SetInitialised(bool bSetTo /* = true */) |
578c3905 | 189 | { |
578c3905 | 190 | CLockObject lock(m_mutex); |
2db8981f LOK |
191 | m_bInitialised = bSetTo; |
192 | } | |
578c3905 | 193 | |
2db8981f LOK |
194 | bool CCECProcessor::Initialise(void) |
195 | { | |
196 | bool bReturn(false); | |
578c3905 | 197 | { |
2db8981f LOK |
198 | CLockObject lock(m_mutex); |
199 | if (!m_logicalAddresses.IsEmpty()) | |
200 | m_logicalAddresses.Clear(); | |
578c3905 | 201 | |
2db8981f LOK |
202 | if (!FindLogicalAddresses()) |
203 | { | |
5477a250 | 204 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not detect our logical addresses"); |
2db8981f LOK |
205 | return bReturn; |
206 | } | |
207 | ||
208 | /* only set our OSD name for the primary device */ | |
209 | m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName; | |
210 | } | |
578c3905 LOK |
211 | |
212 | /* get the vendor id from the TV, so we are using the correct handler */ | |
213 | m_busDevices[CECDEVICE_TV]->RequestVendorId(); | |
578c3905 | 214 | |
4f362964 LOK |
215 | if (m_iPhysicalAddress != 0) |
216 | { | |
217 | m_busDevices[m_logicalAddresses.primary]->m_iPhysicalAddress = m_iPhysicalAddress; | |
218 | if ((bReturn = m_busDevices[m_logicalAddresses.primary]->TransmitPhysicalAddress()) == false) | |
219 | CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set the physical address to %4x", m_iPhysicalAddress); | |
220 | } | |
221 | else if (m_iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true)) == false) | |
5477a250 | 222 | CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_iHDMIPort, ToString(m_iBaseDevice), (uint8_t)m_iBaseDevice); |
2db8981f LOK |
223 | |
224 | SetInitialised(bReturn); | |
578c3905 LOK |
225 | |
226 | return bReturn; | |
227 | } | |
228 | ||
229 | bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */, uint32_t iTimeoutMs /* = 10000 */) | |
230 | { | |
231 | bool bReturn(false); | |
232 | ||
233 | { | |
234 | CLockObject lock(m_mutex); | |
235 | if (!OpenConnection(strPort, iBaudRate, iTimeoutMs)) | |
a674fd68 | 236 | return bReturn; |
994dbaaa | 237 | |
a674fd68 | 238 | /* create the processor thread */ |
8e57f83c | 239 | if (!CreateThread()) |
a674fd68 | 240 | { |
5477a250 | 241 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread"); |
a674fd68 | 242 | return bReturn; |
994dbaaa | 243 | } |
a674fd68 LOK |
244 | } |
245 | ||
578c3905 | 246 | if ((bReturn = Initialise()) == false) |
a674fd68 | 247 | { |
5477a250 | 248 | CLibCEC::AddLog(CEC_LOG_ERROR, "could not create a processor thread"); |
578c3905 | 249 | StopThread(true); |
a674fd68 LOK |
250 | } |
251 | else | |
252 | { | |
5477a250 | 253 | CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); |
a674fd68 LOK |
254 | } |
255 | ||
256 | return bReturn; | |
abbca718 LOK |
257 | } |
258 | ||
b58d9277 | 259 | bool CCECProcessor::TryLogicalAddress(cec_logical_address address) |
f8513317 | 260 | { |
93fff5c1 | 261 | if (m_busDevices[address]->TryLogicalAddress()) |
f8513317 | 262 | { |
ab1469a0 | 263 | m_logicalAddresses.Set(address); |
f8513317 LOK |
264 | return true; |
265 | } | |
266 | ||
f8513317 LOK |
267 | return false; |
268 | } | |
269 | ||
b58d9277 | 270 | bool CCECProcessor::FindLogicalAddressRecordingDevice(void) |
f8513317 | 271 | { |
5477a250 | 272 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'recording device'"); |
b58d9277 LOK |
273 | return TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1) || |
274 | TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2) || | |
275 | TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3); | |
f8513317 LOK |
276 | } |
277 | ||
b58d9277 | 278 | bool CCECProcessor::FindLogicalAddressTuner(void) |
f8513317 | 279 | { |
5477a250 | 280 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'tuner'"); |
b58d9277 LOK |
281 | return TryLogicalAddress(CECDEVICE_TUNER1) || |
282 | TryLogicalAddress(CECDEVICE_TUNER2) || | |
283 | TryLogicalAddress(CECDEVICE_TUNER3) || | |
284 | TryLogicalAddress(CECDEVICE_TUNER4); | |
f8513317 LOK |
285 | } |
286 | ||
b58d9277 | 287 | bool CCECProcessor::FindLogicalAddressPlaybackDevice(void) |
f8513317 | 288 | { |
5477a250 | 289 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'playback device'"); |
b58d9277 LOK |
290 | return TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1) || |
291 | TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2) || | |
292 | TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3); | |
f8513317 LOK |
293 | } |
294 | ||
b58d9277 | 295 | bool CCECProcessor::FindLogicalAddressAudioSystem(void) |
f8513317 | 296 | { |
5477a250 | 297 | CLibCEC::AddLog(CEC_LOG_DEBUG, "detecting logical address for type 'audio'"); |
b58d9277 | 298 | return TryLogicalAddress(CECDEVICE_AUDIOSYSTEM); |
f8513317 LOK |
299 | } |
300 | ||
3e61b350 LOK |
301 | bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to) |
302 | { | |
303 | bool bChanged(false); | |
304 | ||
5477a250 | 305 | CLibCEC::AddLog(CEC_LOG_NOTICE, "changing device type '%s' into '%s'", ToString(from), ToString(to)); |
3e61b350 | 306 | |
f00ff009 | 307 | CLockObject lock(m_mutex); |
3e61b350 LOK |
308 | CCECBusDevice *previousDevice = GetDeviceByType(from); |
309 | m_logicalAddresses.primary = CECDEVICE_UNKNOWN; | |
310 | ||
311 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
312 | { | |
313 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RESERVED) | |
314 | continue; | |
315 | ||
316 | if (m_types.types[iPtr] == from) | |
317 | { | |
318 | bChanged = true; | |
319 | m_types.types[iPtr] = to; | |
320 | } | |
321 | else if (m_types.types[iPtr] == to && bChanged) | |
322 | { | |
323 | m_types.types[iPtr] = CEC_DEVICE_TYPE_RESERVED; | |
324 | } | |
325 | } | |
326 | ||
327 | if (bChanged) | |
328 | { | |
329 | FindLogicalAddresses(); | |
330 | ||
331 | CCECBusDevice *newDevice = GetDeviceByType(to); | |
332 | if (previousDevice && newDevice) | |
333 | { | |
334 | newDevice->SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC); | |
4478bc79 | 335 | previousDevice->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); |
3e61b350 LOK |
336 | |
337 | newDevice->SetCecVersion(previousDevice->GetCecVersion(false)); | |
338 | previousDevice->SetCecVersion(CEC_VERSION_UNKNOWN); | |
339 | ||
340 | newDevice->SetMenuLanguage(previousDevice->GetMenuLanguage(false)); | |
341 | cec_menu_language lang; | |
342 | lang.device = previousDevice->GetLogicalAddress(); | |
343 | for (unsigned int iPtr = 0; iPtr < 4; iPtr++) | |
344 | lang.language[iPtr] = '?'; | |
345 | lang.language[3] = 0; | |
346 | previousDevice->SetMenuLanguage(lang); | |
347 | ||
348 | newDevice->SetMenuState(previousDevice->GetMenuState()); | |
349 | previousDevice->SetMenuState(CEC_MENU_STATE_DEACTIVATED); | |
350 | ||
351 | newDevice->SetOSDName(previousDevice->GetOSDName(false)); | |
352 | previousDevice->SetOSDName(ToString(previousDevice->GetLogicalAddress())); | |
353 | ||
354 | newDevice->SetPhysicalAddress(previousDevice->GetPhysicalAddress(false)); | |
355 | previousDevice->SetPhysicalAddress(0xFFFF); | |
356 | ||
357 | newDevice->SetPowerStatus(previousDevice->GetPowerStatus(false)); | |
358 | previousDevice->SetPowerStatus(CEC_POWER_STATUS_UNKNOWN); | |
359 | ||
360 | newDevice->SetVendorId(previousDevice->GetVendorId(false)); | |
361 | previousDevice->SetVendorId(CEC_VENDOR_UNKNOWN); | |
362 | ||
363 | if ((from == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || from == CEC_DEVICE_TYPE_RECORDING_DEVICE) && | |
364 | (to == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || to == CEC_DEVICE_TYPE_RECORDING_DEVICE)) | |
365 | { | |
366 | ((CCECPlaybackDevice *) newDevice)->SetDeckControlMode(((CCECPlaybackDevice *) previousDevice)->GetDeckControlMode()); | |
367 | ((CCECPlaybackDevice *) previousDevice)->SetDeckControlMode(CEC_DECK_CONTROL_MODE_STOP); | |
368 | ||
369 | ((CCECPlaybackDevice *) newDevice)->SetDeckStatus(((CCECPlaybackDevice *) previousDevice)->GetDeckStatus()); | |
370 | ((CCECPlaybackDevice *) previousDevice)->SetDeckStatus(CEC_DECK_INFO_STOP); | |
371 | } | |
372 | } | |
373 | } | |
374 | ||
375 | return true; | |
376 | } | |
377 | ||
f8513317 LOK |
378 | bool CCECProcessor::FindLogicalAddresses(void) |
379 | { | |
380 | bool bReturn(true); | |
ab1469a0 | 381 | m_logicalAddresses.Clear(); |
f8513317 LOK |
382 | |
383 | for (unsigned int iPtr = 0; iPtr < 5; iPtr++) | |
384 | { | |
385 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RESERVED) | |
386 | continue; | |
387 | ||
5477a250 | 388 | CLibCEC::AddLog(CEC_LOG_DEBUG, "%s - device %d: type %d", __FUNCTION__, iPtr, m_types.types[iPtr]); |
f8513317 LOK |
389 | |
390 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_RECORDING_DEVICE) | |
b58d9277 | 391 | bReturn &= FindLogicalAddressRecordingDevice(); |
f8513317 | 392 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_TUNER) |
b58d9277 | 393 | bReturn &= FindLogicalAddressTuner(); |
f8513317 | 394 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE) |
b58d9277 | 395 | bReturn &= FindLogicalAddressPlaybackDevice(); |
f8513317 | 396 | if (m_types.types[iPtr] == CEC_DEVICE_TYPE_AUDIO_SYSTEM) |
b58d9277 | 397 | bReturn &= FindLogicalAddressAudioSystem(); |
f8513317 LOK |
398 | } |
399 | ||
a674fd68 LOK |
400 | if (bReturn) |
401 | SetAckMask(m_logicalAddresses.AckMask()); | |
402 | ||
f8513317 LOK |
403 | return bReturn; |
404 | } | |
405 | ||
a3ffc068 LOK |
406 | void CCECProcessor::ReplaceHandlers(void) |
407 | { | |
0cfdeb5a LOK |
408 | if (!IsInitialised()) |
409 | return; | |
a3ffc068 | 410 | for (uint8_t iPtr = 0; iPtr <= CECDEVICE_PLAYBACKDEVICE3; iPtr++) |
591170fd | 411 | m_busDevices[iPtr]->ReplaceHandler(m_bInitialised); |
a3ffc068 LOK |
412 | } |
413 | ||
b1f94db1 LOK |
414 | bool CCECProcessor::OnCommandReceived(const cec_command &command) |
415 | { | |
416 | m_commandBuffer.Push(command); | |
417 | return true; | |
418 | } | |
419 | ||
2abe74eb | 420 | void *CCECProcessor::Process(void) |
f99bc831 | 421 | { |
8e57f83c LOK |
422 | cec_command command; |
423 | CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started"); | |
abbca718 | 424 | |
b1f94db1 | 425 | while (!IsStopped() && m_communication->IsOpen()) |
abbca718 | 426 | { |
591170fd | 427 | ReplaceHandlers(); |
b1f94db1 | 428 | if (m_commandBuffer.Pop(command)) |
9dee1670 | 429 | ParseCommand(command); |
b5f34cf9 | 430 | |
13fd6a66 | 431 | m_controller->CheckKeypressTimeout(); |
b1f94db1 | 432 | Sleep(5); |
abbca718 LOK |
433 | } |
434 | ||
60fa4578 | 435 | return NULL; |
abbca718 LOK |
436 | } |
437 | ||
18203d17 | 438 | bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RESERVED */) |
abbca718 | 439 | { |
8ac9c610 LOK |
440 | bool bReturn(false); |
441 | ||
60fa4578 | 442 | if (!IsRunning()) |
8ac9c610 | 443 | return bReturn; |
f99bc831 | 444 | |
18203d17 | 445 | cec_logical_address addr = m_logicalAddresses.primary; |
04437dcf | 446 | |
18203d17 LOK |
447 | if (type != CEC_DEVICE_TYPE_RESERVED) |
448 | { | |
90ea9066 | 449 | for (uint8_t iPtr = 0; iPtr <= 11; iPtr++) |
18203d17 LOK |
450 | { |
451 | if (m_logicalAddresses[iPtr] && m_busDevices[iPtr]->m_type == type) | |
452 | { | |
453 | addr = (cec_logical_address) iPtr; | |
454 | break; | |
455 | } | |
456 | } | |
457 | } | |
458 | ||
37b0c572 | 459 | m_busDevices[addr]->SetActiveSource(); |
d383d6d0 | 460 | if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF) |
e046c7bf | 461 | { |
96b887ec | 462 | bReturn = m_busDevices[addr]->TransmitActiveSource(); |
e046c7bf | 463 | |
4478bc79 LOK |
464 | if (bReturn) |
465 | { | |
466 | m_busDevices[addr]->SetMenuState(CEC_MENU_STATE_ACTIVATED); | |
467 | m_busDevices[addr]->TransmitMenuState(CECDEVICE_TV); | |
468 | } | |
469 | ||
e046c7bf LOK |
470 | if (bReturn && (m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || |
471 | m_busDevices[addr]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && | |
472 | m_busDevices[addr]->GetHandler()->SendDeckStatusUpdateOnActiveSource()) | |
473 | { | |
474 | bReturn = ((CCECPlaybackDevice *)m_busDevices[addr])->TransmitDeckStatus(CECDEVICE_TV); | |
475 | } | |
476 | } | |
8d915412 LOK |
477 | |
478 | return bReturn; | |
18203d17 LOK |
479 | } |
480 | ||
37b0c572 LOK |
481 | bool CCECProcessor::SetActiveSource(uint16_t iStreamPath) |
482 | { | |
483 | bool bReturn(false); | |
484 | ||
485 | CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath); | |
486 | if (device) | |
487 | { | |
488 | device->SetActiveSource(); | |
489 | bReturn = true; | |
490 | } | |
491 | ||
492 | return bReturn; | |
493 | } | |
494 | ||
dcd240b2 LOK |
495 | void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout) |
496 | { | |
f00ff009 | 497 | CLockObject lock(m_mutex); |
dcd240b2 LOK |
498 | m_iStandardLineTimeout = iTimeout; |
499 | } | |
500 | ||
501 | void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout) | |
502 | { | |
f00ff009 | 503 | CLockObject lock(m_mutex); |
dcd240b2 LOK |
504 | m_iRetryLineTimeout = iTimeout; |
505 | } | |
506 | ||
18203d17 LOK |
507 | bool CCECProcessor::SetActiveView(void) |
508 | { | |
4a870dc8 | 509 | return SetActiveSource(m_types.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED : m_types[0]); |
8ac9c610 LOK |
510 | } |
511 | ||
28fa6c97 | 512 | bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode, bool bSendUpdate /* = true */) |
a9232a79 LOK |
513 | { |
514 | bool bReturn(false); | |
515 | ||
516 | CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); | |
517 | if (device) | |
518 | { | |
519 | ((CCECPlaybackDevice *) device)->SetDeckControlMode(mode); | |
28fa6c97 LOK |
520 | if (bSendUpdate) |
521 | ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV); | |
a9232a79 LOK |
522 | bReturn = true; |
523 | } | |
524 | ||
525 | return bReturn; | |
526 | } | |
527 | ||
28fa6c97 | 528 | bool CCECProcessor::SetDeckInfo(cec_deck_info info, bool bSendUpdate /* = true */) |
a9232a79 LOK |
529 | { |
530 | bool bReturn(false); | |
531 | ||
532 | CCECBusDevice *device = GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE); | |
533 | if (device) | |
534 | { | |
535 | ((CCECPlaybackDevice *) device)->SetDeckStatus(info); | |
28fa6c97 LOK |
536 | if (bSendUpdate) |
537 | ((CCECPlaybackDevice *) device)->TransmitDeckStatus(CECDEVICE_TV); | |
a9232a79 LOK |
538 | bReturn = true; |
539 | } | |
540 | ||
541 | return bReturn; | |
542 | } | |
543 | ||
d2f1c157 | 544 | bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort, bool bForce /* = false */) |
16b1e052 LOK |
545 | { |
546 | bool bReturn(false); | |
f00ff009 | 547 | CLockObject lock(m_mutex); |
16b1e052 | 548 | |
89b3c9df LOK |
549 | m_iBaseDevice = iBaseDevice; |
550 | m_iHDMIPort = iPort; | |
8e57f83c | 551 | if (!IsRunning() && !bForce) |
89b3c9df | 552 | return true; |
16b1e052 | 553 | |
5477a250 | 554 | CLibCEC::AddLog(CEC_LOG_DEBUG, "setting HDMI port to %d on device %s (%d)", iPort, ToString(iBaseDevice), (int)iBaseDevice); |
56035c86 | 555 | |
16b1e052 | 556 | uint16_t iPhysicalAddress(0); |
1e7afacd | 557 | if (iBaseDevice > CECDEVICE_TV) |
5d0c1164 | 558 | { |
f00ff009 | 559 | lock.Unlock(); |
1e7afacd | 560 | iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress(); |
5d0c1164 LOK |
561 | lock.Lock(); |
562 | } | |
1e7afacd | 563 | |
a674fd68 | 564 | if (iPhysicalAddress < 0xffff) |
1e7afacd | 565 | { |
1e7afacd | 566 | if (iPhysicalAddress == 0) |
5d355340 | 567 | iPhysicalAddress += 0x1000 * iPort; |
1e7afacd | 568 | else if (iPhysicalAddress % 0x1000 == 0) |
5d355340 | 569 | iPhysicalAddress += 0x100 * iPort; |
1e7afacd | 570 | else if (iPhysicalAddress % 0x100 == 0) |
5d355340 | 571 | iPhysicalAddress += 0x10 * iPort; |
1e7afacd | 572 | else if (iPhysicalAddress % 0x10 == 0) |
5d355340 | 573 | iPhysicalAddress += iPort; |
1e7afacd | 574 | |
5d355340 | 575 | bReturn = true; |
16b1e052 LOK |
576 | } |
577 | ||
a674fd68 | 578 | if (!bReturn) |
5477a250 | 579 | CLibCEC::AddLog(CEC_LOG_ERROR, "failed to set the physical address"); |
f070564b LOK |
580 | else |
581 | { | |
f00ff009 | 582 | lock.Unlock(); |
f070564b LOK |
583 | SetPhysicalAddress(iPhysicalAddress); |
584 | } | |
a674fd68 | 585 | |
16b1e052 LOK |
586 | return bReturn; |
587 | } | |
588 | ||
45b97de7 | 589 | bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress) |
16b1e052 | 590 | { |
9fd73dd4 | 591 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
16b1e052 LOK |
592 | { |
593 | if (m_busDevices[iPtr]->GetPhysicalAddress(false) == iPhysicalAddress) | |
594 | return true; | |
595 | } | |
596 | return false; | |
597 | } | |
598 | ||
ab27363d | 599 | bool CCECProcessor::TransmitInactiveSource(void) |
abbca718 | 600 | { |
60fa4578 | 601 | if (!IsRunning()) |
f99bc831 LOK |
602 | return false; |
603 | ||
ab1469a0 | 604 | if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary]) |
ab27363d | 605 | return m_busDevices[m_logicalAddresses.primary]->TransmitInactiveSource(); |
cc60ab1c | 606 | return false; |
abbca718 LOK |
607 | } |
608 | ||
9dee1670 | 609 | void CCECProcessor::LogOutput(const cec_command &data) |
abbca718 | 610 | { |
1d3ca3de | 611 | CStdString strTx; |
57f45e6c LOK |
612 | strTx.Format("<< %02x", ((uint8_t)data.initiator << 4) + (uint8_t)data.destination); |
613 | if (data.opcode_set) | |
614 | strTx.AppendFormat(":%02x", (uint8_t)data.opcode); | |
9dee1670 | 615 | |
06a1f7ce | 616 | for (uint8_t iPtr = 0; iPtr < data.parameters.size; iPtr++) |
1d3ca3de | 617 | strTx.AppendFormat(":%02x", data.parameters[iPtr]); |
5477a250 | 618 | CLibCEC::AddLog(CEC_LOG_TRAFFIC, strTx.c_str()); |
9dee1670 | 619 | } |
2abe74eb | 620 | |
06bfd4d7 | 621 | bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress) |
abbca718 | 622 | { |
f00ff009 | 623 | CLockObject lock(m_mutex); |
f8513317 | 624 | if (m_logicalAddresses.primary != iLogicalAddress) |
06775107 | 625 | { |
5477a250 | 626 | CLibCEC::AddLog(CEC_LOG_NOTICE, "<< setting primary logical address to %1x", iLogicalAddress); |
f8513317 | 627 | m_logicalAddresses.primary = iLogicalAddress; |
ab1469a0 LOK |
628 | m_logicalAddresses.Set(iLogicalAddress); |
629 | return SetAckMask(m_logicalAddresses.AckMask()); | |
06775107 | 630 | } |
2abe74eb | 631 | |
06bfd4d7 | 632 | return true; |
abbca718 | 633 | } |
825ddb96 | 634 | |
28fa6c97 LOK |
635 | bool CCECProcessor::SetMenuState(cec_menu_state state, bool bSendUpdate /* = true */) |
636 | { | |
637 | for (uint8_t iPtr = 0; iPtr < 16; iPtr++) | |
638 | { | |
639 | if (m_logicalAddresses[iPtr]) | |
640 | m_busDevices[iPtr]->SetMenuState(state); | |
641 | } | |
642 | ||
643 | if (bSendUpdate) | |
644 | m_busDevices[m_logicalAddresses.primary]->TransmitMenuState(CECDEVICE_TV); | |
645 | ||
646 | return true; | |
647 | } | |
648 | ||
bebb19dc | 649 | bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress, bool bSendUpdate /* = true */) |
2492216a | 650 | { |
f070564b LOK |
651 | bool bSendActiveView(false); |
652 | bool bReturn(false); | |
4d6f5ac7 | 653 | cec_logical_addresses sendUpdatesTo; |
ded7e7ce | 654 | sendUpdatesTo.Clear(); |
ff684fef | 655 | |
f070564b | 656 | { |
f00ff009 | 657 | CLockObject lock(m_mutex); |
4f362964 LOK |
658 | m_iPhysicalAddress = iPhysicalAddress; |
659 | ||
f070564b LOK |
660 | if (!m_logicalAddresses.IsEmpty()) |
661 | { | |
662 | bool bWasActiveSource(false); | |
663 | for (uint8_t iPtr = 0; iPtr < 15; iPtr++) | |
664 | if (m_logicalAddresses[iPtr]) | |
665 | { | |
666 | bWasActiveSource |= m_busDevices[iPtr]->IsActiveSource(); | |
667 | m_busDevices[iPtr]->SetInactiveSource(); | |
668 | m_busDevices[iPtr]->SetPhysicalAddress(iPhysicalAddress); | |
669 | if (bSendUpdate) | |
4d6f5ac7 | 670 | sendUpdatesTo.Set((cec_logical_address)iPtr); |
f070564b LOK |
671 | } |
672 | ||
673 | bSendActiveView = bWasActiveSource && bSendUpdate; | |
674 | bReturn = true; | |
675 | } | |
cc60ab1c | 676 | } |
f070564b | 677 | |
4d6f5ac7 LOK |
678 | for (uint8_t iPtr = 0; iPtr < 15; iPtr++) |
679 | if (sendUpdatesTo[iPtr]) | |
680 | m_busDevices[iPtr]->TransmitPhysicalAddress(); | |
681 | ||
f070564b LOK |
682 | if (bSendActiveView) |
683 | SetActiveView(); | |
684 | ||
685 | return bReturn; | |
1969b140 LOK |
686 | } |
687 | ||
8b7e5ff6 LOK |
688 | bool CCECProcessor::SwitchMonitoring(bool bEnable) |
689 | { | |
5477a250 | 690 | CLibCEC::AddLog(CEC_LOG_NOTICE, "== %s monitoring mode ==", bEnable ? "enabling" : "disabling"); |
8b7e5ff6 | 691 | |
855a3a98 | 692 | { |
f00ff009 | 693 | CLockObject lock(m_mutex); |
855a3a98 | 694 | m_bMonitor = bEnable; |
855a3a98 LOK |
695 | } |
696 | ||
8b7e5ff6 | 697 | if (bEnable) |
06bfd4d7 | 698 | return SetAckMask(0); |
8b7e5ff6 | 699 | else |
ab1469a0 | 700 | return SetAckMask(m_logicalAddresses.AckMask()); |
8b7e5ff6 LOK |
701 | } |
702 | ||
57f45e6c LOK |
703 | bool CCECProcessor::PollDevice(cec_logical_address iAddress) |
704 | { | |
705 | if (iAddress != CECDEVICE_UNKNOWN && m_busDevices[iAddress]) | |
95a73fa7 LOK |
706 | { |
707 | return m_logicalAddresses.primary == CECDEVICE_UNKNOWN ? | |
708 | m_busDevices[iAddress]->TransmitPoll(iAddress) : | |
709 | m_busDevices[m_logicalAddresses.primary]->TransmitPoll(iAddress); | |
710 | } | |
57f45e6c LOK |
711 | return false; |
712 | } | |
713 | ||
5c73f7f7 | 714 | uint8_t CCECProcessor::VolumeUp(bool bSendRelease /* = true */) |
04e637f9 LOK |
715 | { |
716 | uint8_t status = 0; | |
37b0c572 | 717 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 718 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeUp(bSendRelease); |
04e637f9 LOK |
719 | |
720 | return status; | |
721 | } | |
722 | ||
5c73f7f7 | 723 | uint8_t CCECProcessor::VolumeDown(bool bSendRelease /* = true */) |
04e637f9 LOK |
724 | { |
725 | uint8_t status = 0; | |
37b0c572 | 726 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 727 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->VolumeDown(bSendRelease); |
04e637f9 LOK |
728 | |
729 | return status; | |
730 | } | |
731 | ||
5c73f7f7 | 732 | uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */) |
04e637f9 LOK |
733 | { |
734 | uint8_t status = 0; | |
37b0c572 | 735 | if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM)) |
5c73f7f7 | 736 | status = ((CCECAudioSystem *)m_busDevices[CECDEVICE_AUDIOSYSTEM])->MuteAudio(bSendRelease); |
04e637f9 LOK |
737 | |
738 | return status; | |
739 | } | |
740 | ||
16b1e052 | 741 | CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */) const |
8ac9c610 | 742 | { |
16b1e052 | 743 | if (m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress) |
b58d9277 | 744 | return m_busDevices[m_logicalAddresses.primary]; |
8ac9c610 | 745 | |
b58d9277 | 746 | CCECBusDevice *device = NULL; |
8ac9c610 LOK |
747 | for (unsigned int iPtr = 0; iPtr < 16; iPtr++) |
748 | { | |
16b1e052 | 749 | if (m_busDevices[iPtr]->GetPhysicalAddress(bRefresh) == iPhysicalAddress) |
8ac9c610 LOK |
750 | { |
751 | device = m_busDevices[iPtr]; | |
752 | break; | |
753 | } | |
754 | } | |
755 | ||
756 | return device; | |
757 | } | |
758 | ||
a9232a79 LOK |
759 | CCECBusDevice *CCECProcessor::GetDeviceByType(cec_device_type type) const |
760 | { | |
761 | CCECBusDevice *device = NULL; | |
762 | ||
7619faad | 763 | for (uint8_t iPtr = 0; iPtr < 16; iPtr++) |
a9232a79 | 764 | { |
b64db02e | 765 | if (m_busDevices[iPtr]->m_type == type && m_logicalAddresses[iPtr]) |
a9232a79 LOK |
766 | { |
767 | device = m_busDevices[iPtr]; | |
768 | break; | |
769 | } | |
770 | } | |
771 | ||
772 | return device; | |
773 | } | |
774 | ||
842262d8 LOK |
775 | CCECBusDevice *CCECProcessor::GetPrimaryDevice(void) const |
776 | { | |
777 | CCECBusDevice *device(NULL); | |
778 | cec_logical_address primary = m_logicalAddresses.primary; | |
779 | if (primary != CECDEVICE_UNKNOWN) | |
780 | device = m_busDevices[primary]; | |
781 | return device; | |
782 | } | |
783 | ||
6a1c0009 LOK |
784 | cec_version CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress) |
785 | { | |
786 | return m_busDevices[iAddress]->GetCecVersion(); | |
787 | } | |
788 | ||
ed21be2a LOK |
789 | cec_osd_name CCECProcessor::GetDeviceOSDName(cec_logical_address iAddress) |
790 | { | |
791 | CStdString strOSDName = m_busDevices[iAddress]->GetOSDName(); | |
792 | cec_osd_name retVal; | |
793 | ||
794 | snprintf(retVal.name, sizeof(retVal.name), "%s", strOSDName.c_str()); | |
795 | retVal.device = iAddress; | |
796 | ||
797 | return retVal; | |
798 | } | |
799 | ||
a3269a0a LOK |
800 | bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language) |
801 | { | |
cc60ab1c LOK |
802 | if (m_busDevices[iAddress]) |
803 | { | |
804 | *language = m_busDevices[iAddress]->GetMenuLanguage(); | |
5744fbba | 805 | return (strcmp(language->language, "???") != 0); |
cc60ab1c LOK |
806 | } |
807 | return false; | |
a3269a0a LOK |
808 | } |
809 | ||
44c74256 LOK |
810 | uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress) |
811 | { | |
cc60ab1c LOK |
812 | if (m_busDevices[iAddress]) |
813 | return m_busDevices[iAddress]->GetVendorId(); | |
814 | return false; | |
44c74256 LOK |
815 | } |
816 | ||
eab72c40 LOK |
817 | uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress) |
818 | { | |
819 | if (m_busDevices[iAddress]) | |
820 | return m_busDevices[iAddress]->GetPhysicalAddress(false); | |
821 | return false; | |
822 | } | |
823 | ||
e55f3f70 LOK |
824 | cec_power_status CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress) |
825 | { | |
cc60ab1c LOK |
826 | if (m_busDevices[iAddress]) |
827 | return m_busDevices[iAddress]->GetPowerStatus(); | |
828 | return CEC_POWER_STATUS_UNKNOWN; | |
e55f3f70 LOK |
829 | } |
830 | ||
b4b1b49b LOK |
831 | cec_logical_address CCECProcessor::GetActiveSource(void) |
832 | { | |
833 | for (uint8_t iPtr = 0; iPtr <= 11; iPtr++) | |
834 | { | |
835 | if (m_busDevices[iPtr]->IsActiveSource()) | |
836 | return (cec_logical_address)iPtr; | |
837 | } | |
838 | ||
839 | return CECDEVICE_UNKNOWN; | |
840 | } | |
841 | ||
842 | bool CCECProcessor::IsActiveSource(cec_logical_address iAddress) | |
843 | { | |
844 | return m_busDevices[iAddress]->IsActiveSource(); | |
845 | } | |
846 | ||
8d84e2c0 | 847 | bool CCECProcessor::Transmit(const cec_command &data) |
825ddb96 | 848 | { |
7bb4ed43 | 849 | cec_adapter_message_state retVal(ADAPTER_MESSAGE_STATE_UNKNOWN); |
eb35e4ca | 850 | { |
7bb4ed43 LOK |
851 | CLockObject lock(m_mutex); |
852 | LogOutput(data); | |
5f316715 | 853 | m_iLastTransmission = GetTimeMs(); |
7bb4ed43 LOK |
854 | if (!m_communication) |
855 | return false; | |
856 | uint8_t iMaxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1; | |
857 | retVal = m_communication->Write(data, iMaxTries, m_iLineTimeout, m_iRetryLineTimeout); | |
2abe74eb LOK |
858 | } |
859 | ||
7bb4ed43 LOK |
860 | /* set to "not present" on failed ack */ |
861 | if (retVal == ADAPTER_MESSAGE_STATE_SENT_NOT_ACKED && | |
862 | data.destination != CECDEVICE_BROADCAST) | |
863 | m_busDevices[data.destination]->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT); | |
9902f4e8 | 864 | |
7bb4ed43 | 865 | return retVal == ADAPTER_MESSAGE_STATE_SENT_ACKED; |
825ddb96 | 866 | } |
abbca718 | 867 | |
22b4e74a | 868 | void CCECProcessor::TransmitAbort(cec_logical_address address, cec_opcode opcode, cec_abort_reason reason /* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */) |
abbca718 | 869 | { |
5477a250 | 870 | CLibCEC::AddLog(CEC_LOG_DEBUG, "<< transmitting abort message"); |
9dee1670 | 871 | |
06a1f7ce | 872 | cec_command command; |
f8513317 | 873 | // TODO |
ab1469a0 LOK |
874 | cec_command::Format(command, m_logicalAddresses.primary, address, CEC_OPCODE_FEATURE_ABORT); |
875 | command.parameters.PushBack((uint8_t)opcode); | |
876 | command.parameters.PushBack((uint8_t)reason); | |
9dee1670 LOK |
877 | |
878 | Transmit(command); | |
abbca718 LOK |
879 | } |
880 | ||
b1f94db1 | 881 | void CCECProcessor::ParseCommand(const cec_command &command) |
abbca718 | 882 | { |
e9de9629 | 883 | CStdString dataStr; |
1d3ca3de | 884 | dataStr.Format(">> %1x%1x:%02x", command.initiator, command.destination, command.opcode); |
e9de9629 LOK |
885 | for (uint8_t iPtr = 0; iPtr < command.parameters.size; iPtr++) |
886 | dataStr.AppendFormat(":%02x", (unsigned int)command.parameters[iPtr]); | |
5477a250 | 887 | CLibCEC::AddLog(CEC_LOG_TRAFFIC, dataStr.c_str()); |
dc113aca | 888 | |
7871d66e | 889 | if (!m_bMonitor && command.initiator >= CECDEVICE_TV && command.initiator <= CECDEVICE_BROADCAST) |
e9de9629 | 890 | m_busDevices[(uint8_t)command.initiator]->HandleCommand(command); |
dc113aca LOK |
891 | } |
892 | ||
6d858ba4 LOK |
893 | cec_logical_addresses CCECProcessor::GetActiveDevices(void) |
894 | { | |
895 | cec_logical_addresses addresses; | |
988de7b9 | 896 | addresses.Clear(); |
6d858ba4 LOK |
897 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
898 | { | |
899 | if (m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
900 | addresses.Set((cec_logical_address) iPtr); | |
901 | } | |
902 | return addresses; | |
903 | } | |
904 | ||
37b0c572 | 905 | bool CCECProcessor::IsPresentDevice(cec_logical_address address) |
6d858ba4 LOK |
906 | { |
907 | return m_busDevices[address]->GetStatus() == CEC_DEVICE_STATUS_PRESENT; | |
908 | } | |
909 | ||
37b0c572 | 910 | bool CCECProcessor::IsPresentDeviceType(cec_device_type type) |
6d858ba4 | 911 | { |
6d858ba4 | 912 | for (unsigned int iPtr = 0; iPtr < 15; iPtr++) |
2813bd07 LOK |
913 | { |
914 | if (m_busDevices[iPtr]->GetType() == type && m_busDevices[iPtr]->GetStatus() == CEC_DEVICE_STATUS_PRESENT) | |
6d858ba4 | 915 | return true; |
2813bd07 LOK |
916 | } |
917 | ||
6d858ba4 LOK |
918 | return false; |
919 | } | |
920 | ||
0f23c85c LOK |
921 | uint16_t CCECProcessor::GetPhysicalAddress(void) const |
922 | { | |
ab1469a0 | 923 | if (!m_logicalAddresses.IsEmpty() && m_busDevices[m_logicalAddresses.primary]) |
16b1e052 | 924 | return m_busDevices[m_logicalAddresses.primary]->GetPhysicalAddress(false); |
cc60ab1c | 925 | return false; |
0f23c85c LOK |
926 | } |
927 | ||
06bfd4d7 LOK |
928 | bool CCECProcessor::SetAckMask(uint16_t iMask) |
929 | { | |
5dcf9f25 | 930 | return m_communication->SetAckMask(iMask); |
06bfd4d7 | 931 | } |
a33794d8 | 932 | |
4bec9d79 | 933 | bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait /* = true */) |
a33794d8 | 934 | { |
86869f8f | 935 | return m_busDevices[iDestination]->TransmitKeypress(key, bWait); |
a33794d8 LOK |
936 | } |
937 | ||
4bec9d79 | 938 | bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination, bool bWait /* = true */) |
a33794d8 | 939 | { |
86869f8f | 940 | return m_busDevices[iDestination]->TransmitKeyRelease(bWait); |
a33794d8 | 941 | } |
7c63a480 | 942 | |
3e61b350 LOK |
943 | const char *CCECProcessor::ToString(const cec_device_type type) |
944 | { | |
945 | switch (type) | |
946 | { | |
947 | case CEC_DEVICE_TYPE_AUDIO_SYSTEM: | |
948 | return "audio system"; | |
949 | case CEC_DEVICE_TYPE_PLAYBACK_DEVICE: | |
950 | return "playback device"; | |
951 | case CEC_DEVICE_TYPE_RECORDING_DEVICE: | |
952 | return "recording device"; | |
953 | case CEC_DEVICE_TYPE_RESERVED: | |
954 | return "reserved"; | |
955 | case CEC_DEVICE_TYPE_TUNER: | |
956 | return "tuner"; | |
957 | case CEC_DEVICE_TYPE_TV: | |
958 | return "TV"; | |
959 | default: | |
960 | return "unknown"; | |
961 | } | |
962 | } | |
963 | ||
03ae897d LOK |
964 | const char *CCECProcessor::ToString(const cec_menu_state state) |
965 | { | |
966 | switch (state) | |
967 | { | |
968 | case CEC_MENU_STATE_ACTIVATED: | |
969 | return "activated"; | |
970 | case CEC_MENU_STATE_DEACTIVATED: | |
971 | return "deactivated"; | |
972 | default: | |
973 | return "unknown"; | |
974 | } | |
975 | } | |
976 | ||
977 | const char *CCECProcessor::ToString(const cec_version version) | |
978 | { | |
979 | switch (version) | |
980 | { | |
981 | case CEC_VERSION_1_2: | |
982 | return "1.2"; | |
983 | case CEC_VERSION_1_2A: | |
984 | return "1.2a"; | |
985 | case CEC_VERSION_1_3: | |
986 | return "1.3"; | |
987 | case CEC_VERSION_1_3A: | |
988 | return "1.3a"; | |
989 | case CEC_VERSION_1_4: | |
990 | return "1.4"; | |
991 | default: | |
992 | return "unknown"; | |
993 | } | |
994 | } | |
995 | ||
996 | const char *CCECProcessor::ToString(const cec_power_status status) | |
997 | { | |
998 | switch (status) | |
999 | { | |
1000 | case CEC_POWER_STATUS_ON: | |
1001 | return "on"; | |
1002 | case CEC_POWER_STATUS_STANDBY: | |
1003 | return "standby"; | |
1004 | case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY: | |
1005 | return "in transition from on to standby"; | |
1006 | case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON: | |
1007 | return "in transition from standby to on"; | |
1008 | default: | |
1009 | return "unknown"; | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | const char *CCECProcessor::ToString(const cec_logical_address address) | |
1014 | { | |
1015 | switch(address) | |
1016 | { | |
1017 | case CECDEVICE_AUDIOSYSTEM: | |
1018 | return "Audio"; | |
1019 | case CECDEVICE_BROADCAST: | |
1020 | return "Broadcast"; | |
1021 | case CECDEVICE_FREEUSE: | |
1022 | return "Free use"; | |
1023 | case CECDEVICE_PLAYBACKDEVICE1: | |
1024 | return "Playback 1"; | |
1025 | case CECDEVICE_PLAYBACKDEVICE2: | |
1026 | return "Playback 2"; | |
1027 | case CECDEVICE_PLAYBACKDEVICE3: | |
1028 | return "Playback 3"; | |
1029 | case CECDEVICE_RECORDINGDEVICE1: | |
1030 | return "Recorder 1"; | |
1031 | case CECDEVICE_RECORDINGDEVICE2: | |
1032 | return "Recorder 2"; | |
1033 | case CECDEVICE_RECORDINGDEVICE3: | |
1034 | return "Recorder 3"; | |
1035 | case CECDEVICE_RESERVED1: | |
1036 | return "Reserved 1"; | |
1037 | case CECDEVICE_RESERVED2: | |
1038 | return "Reserved 2"; | |
1039 | case CECDEVICE_TUNER1: | |
1040 | return "Tuner 1"; | |
1041 | case CECDEVICE_TUNER2: | |
1042 | return "Tuner 2"; | |
1043 | case CECDEVICE_TUNER3: | |
1044 | return "Tuner 3"; | |
1045 | case CECDEVICE_TUNER4: | |
1046 | return "Tuner 4"; | |
1047 | case CECDEVICE_TV: | |
1048 | return "TV"; | |
1049 | default: | |
1050 | return "unknown"; | |
1051 | } | |
1052 | } | |
1053 | ||
1054 | const char *CCECProcessor::ToString(const cec_deck_control_mode mode) | |
1055 | { | |
1056 | switch (mode) | |
1057 | { | |
1058 | case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND: | |
1059 | return "skip forward wind"; | |
1060 | case CEC_DECK_CONTROL_MODE_EJECT: | |
1061 | return "eject"; | |
1062 | case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND: | |
1063 | return "reverse rewind"; | |
1064 | case CEC_DECK_CONTROL_MODE_STOP: | |
1065 | return "stop"; | |
1066 | default: | |
1067 | return "unknown"; | |
1068 | } | |
1069 | } | |
1070 | ||
1071 | const char *CCECProcessor::ToString(const cec_deck_info status) | |
1072 | { | |
1073 | switch (status) | |
1074 | { | |
1075 | case CEC_DECK_INFO_PLAY: | |
1076 | return "play"; | |
1077 | case CEC_DECK_INFO_RECORD: | |
1078 | return "record"; | |
1079 | case CEC_DECK_INFO_PLAY_REVERSE: | |
1080 | return "play reverse"; | |
1081 | case CEC_DECK_INFO_STILL: | |
1082 | return "still"; | |
1083 | case CEC_DECK_INFO_SLOW: | |
1084 | return "slow"; | |
1085 | case CEC_DECK_INFO_SLOW_REVERSE: | |
1086 | return "slow reverse"; | |
1087 | case CEC_DECK_INFO_FAST_FORWARD: | |
1088 | return "fast forward"; | |
1089 | case CEC_DECK_INFO_FAST_REVERSE: | |
1090 | return "fast reverse"; | |
1091 | case CEC_DECK_INFO_NO_MEDIA: | |
1092 | return "no media"; | |
1093 | case CEC_DECK_INFO_STOP: | |
1094 | return "stop"; | |
1095 | case CEC_DECK_INFO_SKIP_FORWARD_WIND: | |
1096 | return "info skip forward wind"; | |
1097 | case CEC_DECK_INFO_SKIP_REVERSE_REWIND: | |
1098 | return "info skip reverse rewind"; | |
1099 | case CEC_DECK_INFO_INDEX_SEARCH_FORWARD: | |
1100 | return "info index search forward"; | |
1101 | case CEC_DECK_INFO_INDEX_SEARCH_REVERSE: | |
1102 | return "info index search reverse"; | |
1103 | case CEC_DECK_INFO_OTHER_STATUS: | |
1104 | return "other"; | |
1105 | default: | |
1106 | return "unknown"; | |
1107 | } | |
1108 | } | |
1109 | ||
1110 | const char *CCECProcessor::ToString(const cec_opcode opcode) | |
1111 | { | |
1112 | switch (opcode) | |
1113 | { | |
1114 | case CEC_OPCODE_ACTIVE_SOURCE: | |
1115 | return "active source"; | |
1116 | case CEC_OPCODE_IMAGE_VIEW_ON: | |
1117 | return "image view on"; | |
1118 | case CEC_OPCODE_TEXT_VIEW_ON: | |
1119 | return "text view on"; | |
1120 | case CEC_OPCODE_INACTIVE_SOURCE: | |
1121 | return "inactive source"; | |
1122 | case CEC_OPCODE_REQUEST_ACTIVE_SOURCE: | |
1123 | return "request active source"; | |
1124 | case CEC_OPCODE_ROUTING_CHANGE: | |
1125 | return "routing change"; | |
1126 | case CEC_OPCODE_ROUTING_INFORMATION: | |
1127 | return "routing information"; | |
1128 | case CEC_OPCODE_SET_STREAM_PATH: | |
1129 | return "set stream path"; | |
1130 | case CEC_OPCODE_STANDBY: | |
1131 | return "standby"; | |
1132 | case CEC_OPCODE_RECORD_OFF: | |
1133 | return "record off"; | |
1134 | case CEC_OPCODE_RECORD_ON: | |
1135 | return "record on"; | |
1136 | case CEC_OPCODE_RECORD_STATUS: | |
1137 | return "record status"; | |
1138 | case CEC_OPCODE_RECORD_TV_SCREEN: | |
1139 | return "record tv screen"; | |
1140 | case CEC_OPCODE_CLEAR_ANALOGUE_TIMER: | |
1141 | return "clear analogue timer"; | |
1142 | case CEC_OPCODE_CLEAR_DIGITAL_TIMER: | |
1143 | return "clear digital timer"; | |
1144 | case CEC_OPCODE_CLEAR_EXTERNAL_TIMER: | |
1145 | return "clear external timer"; | |
1146 | case CEC_OPCODE_SET_ANALOGUE_TIMER: | |
1147 | return "set analogue timer"; | |
1148 | case CEC_OPCODE_SET_DIGITAL_TIMER: | |
1149 | return "set digital timer"; | |
1150 | case CEC_OPCODE_SET_EXTERNAL_TIMER: | |
1151 | return "set external timer"; | |
1152 | case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE: | |
1153 | return "set timer program title"; | |
1154 | case CEC_OPCODE_TIMER_CLEARED_STATUS: | |
1155 | return "timer cleared status"; | |
1156 | case CEC_OPCODE_TIMER_STATUS: | |
1157 | return "timer status"; | |
1158 | case CEC_OPCODE_CEC_VERSION: | |
1159 | return "cec version"; | |
1160 | case CEC_OPCODE_GET_CEC_VERSION: | |
1161 | return "get cec version"; | |
1162 | case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS: | |
1163 | return "give physical address"; | |
1164 | case CEC_OPCODE_GET_MENU_LANGUAGE: | |
1165 | return "get menu language"; | |
1166 | case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS: | |
1167 | return "report physical address"; | |
1168 | case CEC_OPCODE_SET_MENU_LANGUAGE: | |
1169 | return "set menu language"; | |
1170 | case CEC_OPCODE_DECK_CONTROL: | |
1171 | return "deck control"; | |
1172 | case CEC_OPCODE_DECK_STATUS: | |
1173 | return "deck status"; | |
1174 | case CEC_OPCODE_GIVE_DECK_STATUS: | |
1175 | return "give deck status"; | |
1176 | case CEC_OPCODE_PLAY: | |
1177 | return "play"; | |
1178 | case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS: | |
1179 | return "give tuner status"; | |
1180 | case CEC_OPCODE_SELECT_ANALOGUE_SERVICE: | |
1181 | return "select analogue service"; | |
1182 | case CEC_OPCODE_SELECT_DIGITAL_SERVICE: | |
1183 | return "set digital service"; | |
1184 | case CEC_OPCODE_TUNER_DEVICE_STATUS: | |
1185 | return "tuner device status"; | |
1186 | case CEC_OPCODE_TUNER_STEP_DECREMENT: | |
1187 | return "tuner step decrement"; | |
1188 | case CEC_OPCODE_TUNER_STEP_INCREMENT: | |
1189 | return "tuner step increment"; | |
1190 | case CEC_OPCODE_DEVICE_VENDOR_ID: | |
1191 | return "device vendor id"; | |
1192 | case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID: | |
1193 | return "give device vendor id"; | |
1194 | case CEC_OPCODE_VENDOR_COMMAND: | |
1195 | return "vendor command"; | |
1196 | case CEC_OPCODE_VENDOR_COMMAND_WITH_ID: | |
1197 | return "vendor command with id"; | |
1198 | case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN: | |
1199 | return "vendor remote button down"; | |
1200 | case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP: | |
1201 | return "vendor remote button up"; | |
1202 | case CEC_OPCODE_SET_OSD_STRING: | |
1203 | return "set osd string"; | |
1204 | case CEC_OPCODE_GIVE_OSD_NAME: | |
1205 | return "give osd name"; | |
1206 | case CEC_OPCODE_SET_OSD_NAME: | |
1207 | return "set osd name"; | |
1208 | case CEC_OPCODE_MENU_REQUEST: | |
1209 | return "menu request"; | |
1210 | case CEC_OPCODE_MENU_STATUS: | |
1211 | return "menu status"; | |
1212 | case CEC_OPCODE_USER_CONTROL_PRESSED: | |
1213 | return "user control pressed"; | |
1214 | case CEC_OPCODE_USER_CONTROL_RELEASE: | |
1215 | return "user control release"; | |
1216 | case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS: | |
1217 | return "give device power status"; | |
1218 | case CEC_OPCODE_REPORT_POWER_STATUS: | |
1219 | return "report power status"; | |
1220 | case CEC_OPCODE_FEATURE_ABORT: | |
1221 | return "feature abort"; | |
1222 | case CEC_OPCODE_ABORT: | |
1223 | return "abort"; | |
1224 | case CEC_OPCODE_GIVE_AUDIO_STATUS: | |
1225 | return "give audio status"; | |
1226 | case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS: | |
1227 | return "give audio mode status"; | |
1228 | case CEC_OPCODE_REPORT_AUDIO_STATUS: | |
1229 | return "report audio status"; | |
1230 | case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE: | |
1231 | return "set system audio mode"; | |
1232 | case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST: | |
1233 | return "system audio mode request"; | |
1234 | case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS: | |
1235 | return "system audio mode status"; | |
1236 | case CEC_OPCODE_SET_AUDIO_RATE: | |
1237 | return "set audio rate"; | |
1238 | default: | |
1239 | return "UNKNOWN"; | |
1240 | } | |
1241 | } | |
1242 | ||
1243 | const char *CCECProcessor::ToString(const cec_system_audio_status mode) | |
1244 | { | |
1245 | switch(mode) | |
1246 | { | |
1247 | case CEC_SYSTEM_AUDIO_STATUS_ON: | |
1248 | return "on"; | |
1249 | case CEC_SYSTEM_AUDIO_STATUS_OFF: | |
1250 | return "off"; | |
1251 | default: | |
1252 | return "unknown"; | |
1253 | } | |
1254 | } | |
1255 | ||
1de6617c | 1256 | const char *CCECProcessor::ToString(const cec_audio_status UNUSED(status)) |
03ae897d LOK |
1257 | { |
1258 | // TODO this is a mask | |
1259 | return "TODO"; | |
1260 | } | |
1261 | ||
1262 | const char *CCECProcessor::ToString(const cec_vendor_id vendor) | |
1263 | { | |
1264 | switch (vendor) | |
1265 | { | |
1266 | case CEC_VENDOR_SAMSUNG: | |
1267 | return "Samsung"; | |
1268 | case CEC_VENDOR_LG: | |
1269 | return "LG"; | |
1270 | case CEC_VENDOR_PANASONIC: | |
1271 | return "Panasonic"; | |
1272 | case CEC_VENDOR_PIONEER: | |
1273 | return "Pioneer"; | |
1274 | case CEC_VENDOR_ONKYO: | |
1275 | return "Onkyo"; | |
1276 | case CEC_VENDOR_YAMAHA: | |
1277 | return "Yamaha"; | |
ec0deac1 LOK |
1278 | case CEC_VENDOR_PHILIPS: |
1279 | return "Philips"; | |
1a87cacc LOK |
1280 | case CEC_VENDOR_SONY: |
1281 | return "Sony"; | |
03ae897d LOK |
1282 | default: |
1283 | return "Unknown"; | |
1284 | } | |
1285 | } | |
1286 | ||
caca2d81 LOK |
1287 | const char *CCECProcessor::ToString(const cec_client_version version) |
1288 | { | |
1289 | switch (version) | |
1290 | { | |
1291 | case CEC_CLIENT_VERSION_PRE_1_5: | |
1292 | return "pre-1.5"; | |
1293 | case CEC_CLIENT_VERSION_1_5_0: | |
1294 | return "1.5.0"; | |
1295 | default: | |
1296 | return "Unknown"; | |
1297 | } | |
1298 | } | |
1299 | ||
7c63a480 LOK |
1300 | void *CCECBusScan::Process(void) |
1301 | { | |
1302 | CCECBusDevice *device(NULL); | |
fe6f8e37 | 1303 | uint8_t iCounter(0); |
5f316715 | 1304 | |
5e5637c6 | 1305 | while (!IsStopped()) |
7c63a480 | 1306 | { |
bdb0f7f4 | 1307 | if (++iCounter < 10) |
fe6f8e37 LOK |
1308 | { |
1309 | Sleep(1000); | |
1310 | continue; | |
1311 | } | |
5f316715 | 1312 | for (unsigned int iPtr = 0; iPtr <= 11 && !IsStopped(); iPtr++) |
7c63a480 | 1313 | { |
5f316715 LOK |
1314 | device = m_processor->m_busDevices[iPtr]; |
1315 | WaitUntilIdle(); | |
1316 | if (device && device->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT) | |
5e5637c6 | 1317 | { |
5f316715 LOK |
1318 | WaitUntilIdle(); |
1319 | if (!IsStopped()) | |
1320 | device->GetVendorId(); | |
1321 | ||
1322 | WaitUntilIdle(); | |
1323 | if (!IsStopped()) | |
1324 | device->GetPowerStatus(true); | |
5e5637c6 | 1325 | } |
7c63a480 LOK |
1326 | } |
1327 | } | |
5f316715 | 1328 | |
7c63a480 LOK |
1329 | return NULL; |
1330 | } | |
1113cb7d | 1331 | |
5f316715 LOK |
1332 | void CCECBusScan::WaitUntilIdle(void) |
1333 | { | |
1334 | if (IsStopped()) | |
1335 | return; | |
1336 | ||
701f753b | 1337 | int32_t iWaitTime = 3000 - (int32_t)(GetTimeMs() - m_processor->GetLastTransmission()); |
5f316715 LOK |
1338 | while (iWaitTime > 0) |
1339 | { | |
1340 | Sleep(iWaitTime); | |
701f753b | 1341 | iWaitTime = 3000 - (int32_t)(GetTimeMs() - m_processor->GetLastTransmission()); |
5f316715 LOK |
1342 | } |
1343 | } | |
1344 | ||
1113cb7d LOK |
1345 | bool CCECProcessor::StartBootloader(void) |
1346 | { | |
1347 | return m_communication->StartBootloader(); | |
1348 | } | |
1349 | ||
1350 | bool CCECProcessor::PingAdapter(void) | |
1351 | { | |
1352 | return m_communication->PingAdapter(); | |
1353 | } | |
6729ac71 LOK |
1354 | |
1355 | void CCECProcessor::HandlePoll(cec_logical_address initiator, cec_logical_address destination) | |
1356 | { | |
0cfdeb5a | 1357 | m_busDevices[initiator]->HandlePoll(destination); |
6729ac71 LOK |
1358 | } |
1359 | ||
7bb4ed43 | 1360 | bool CCECProcessor::HandleReceiveFailed(cec_logical_address initiator) |
6729ac71 | 1361 | { |
0cfdeb5a | 1362 | return !m_busDevices[initiator]->HandleReceiveFailed(); |
6729ac71 | 1363 | } |
f42d3e0f LOK |
1364 | |
1365 | bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress) | |
1366 | { | |
1367 | // stream path changes are sent by the TV | |
1368 | return m_busDevices[CECDEVICE_TV]->GetHandler()->TransmitSetStreamPath(iPhysicalAddress); | |
1369 | } | |
d40928b5 LOK |
1370 | |
1371 | bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration) | |
1372 | { | |
1373 | configuration->iPhysicalAddress = m_iPhysicalAddress; | |
1374 | configuration->iHDMIPort = m_iHDMIPort; | |
1375 | configuration->baseDevice = m_iBaseDevice; | |
39b1216c | 1376 | snprintf(configuration->strDeviceName, 13, "%s", m_strDeviceName.c_str()); |
d40928b5 LOK |
1377 | configuration->deviceTypes = m_types; |
1378 | return true; | |
1379 | } | |
224ea877 LOK |
1380 | |
1381 | bool CCECProcessor::CanPersistConfiguration(void) | |
1382 | { | |
1383 | return m_communication->GetFirmwareVersion() >= 2; | |
1384 | } | |
1385 | ||
1386 | bool CCECProcessor::PersistConfiguration(libcec_configuration *configuration) | |
1387 | { | |
1388 | return m_communication->PersistConfiguration(configuration); | |
1389 | } |