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