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