2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
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.
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.
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.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
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/
33 #include "CECProcessor.h"
35 #include "AdapterCommunication.h"
36 #include "devices/CECBusDevice.h"
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"
42 #include "implementations/CECCommandHandler.h"
47 using namespace PLATFORM
;
49 CCECProcessor::CCECProcessor(CLibCEC
*controller
, const char *strDeviceName
, cec_logical_address iLogicalAddress
/* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress
/* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) :
51 m_bInitialised(false),
52 m_iHDMIPort(CEC_DEFAULT_HDMI_PORT
),
53 m_iBaseDevice((cec_logical_address
)CEC_DEFAULT_BASE_DEVICE
),
54 m_lastInitiator(CECDEVICE_UNKNOWN
),
55 m_strDeviceName(strDeviceName
),
56 m_controller(controller
),
58 m_iStandardLineTimeout(3),
59 m_iRetryLineTimeout(3),
60 m_iLastTransmission(0)
62 m_communication
= new CAdapterCommunication(this);
63 m_logicalAddresses
.Clear();
64 m_logicalAddresses
.Set(iLogicalAddress
);
66 for (int iPtr
= 0; iPtr
<= 16; iPtr
++)
67 m_busDevices
[iPtr
] = new CCECBusDevice(this, (cec_logical_address
) iPtr
, iPtr
== iLogicalAddress
? iPhysicalAddress
: 0);
70 CCECProcessor::CCECProcessor(CLibCEC
*controller
, const char *strDeviceName
, const cec_device_type_list
&types
) :
72 m_bInitialised(false),
73 m_iHDMIPort(CEC_DEFAULT_HDMI_PORT
),
74 m_iBaseDevice((cec_logical_address
)CEC_DEFAULT_BASE_DEVICE
),
75 m_strDeviceName(strDeviceName
),
77 m_controller(controller
),
79 m_iStandardLineTimeout(3),
80 m_iRetryLineTimeout(3),
81 m_iLastTransmission(0)
83 m_communication
= new CAdapterCommunication(this);
84 m_logicalAddresses
.Clear();
85 for (int iPtr
= 0; iPtr
< 16; iPtr
++)
89 case CECDEVICE_AUDIOSYSTEM
:
90 m_busDevices
[iPtr
] = new CCECAudioSystem(this, (cec_logical_address
) iPtr
, 0xFFFF);
92 case CECDEVICE_PLAYBACKDEVICE1
:
93 case CECDEVICE_PLAYBACKDEVICE2
:
94 case CECDEVICE_PLAYBACKDEVICE3
:
95 m_busDevices
[iPtr
] = new CCECPlaybackDevice(this, (cec_logical_address
) iPtr
, 0xFFFF);
97 case CECDEVICE_RECORDINGDEVICE1
:
98 case CECDEVICE_RECORDINGDEVICE2
:
99 case CECDEVICE_RECORDINGDEVICE3
:
100 m_busDevices
[iPtr
] = new CCECRecordingDevice(this, (cec_logical_address
) iPtr
, 0xFFFF);
102 case CECDEVICE_TUNER1
:
103 case CECDEVICE_TUNER2
:
104 case CECDEVICE_TUNER3
:
105 case CECDEVICE_TUNER4
:
106 m_busDevices
[iPtr
] = new CCECTuner(this, (cec_logical_address
) iPtr
, 0xFFFF);
109 m_busDevices
[iPtr
] = new CCECTV(this, (cec_logical_address
) iPtr
, 0);
112 m_busDevices
[iPtr
] = new CCECBusDevice(this, (cec_logical_address
) iPtr
, 0xFFFF);
118 CCECProcessor::~CCECProcessor(void)
121 m_startCondition
.Broadcast();
124 delete m_communication
;
125 m_communication
= NULL
;
127 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
128 delete m_busDevices
[iPtr
];
131 bool CCECProcessor::OpenConnection(const char *strPort
, uint16_t iBaudRate
, uint32_t iTimeoutMs
)
134 CLockObject
lock(m_mutex
);
135 if (!m_communication
)
137 m_controller
->AddLog(CEC_LOG_ERROR
, "no connection handler found");
141 /* check for an already opened connection */
142 if (m_communication
->IsOpen())
144 m_controller
->AddLog(CEC_LOG_ERROR
, "connection already opened");
148 /* open a new connection */
149 if ((bReturn
= m_communication
->Open(strPort
, iBaudRate
, iTimeoutMs
)) == false)
150 m_controller
->AddLog(CEC_LOG_ERROR
, "could not open a connection");
155 bool CCECProcessor::Initialise(void)
158 CLockObject
lock(m_mutex
);
159 if (!m_logicalAddresses
.IsEmpty())
160 m_logicalAddresses
.Clear();
162 if (!FindLogicalAddresses())
164 m_controller
->AddLog(CEC_LOG_ERROR
, "could not detect our logical addresses");
168 /* only set our OSD name for the primary device */
169 m_busDevices
[m_logicalAddresses
.primary
]->m_strDeviceName
= m_strDeviceName
;
171 /* get the vendor id from the TV, so we are using the correct handler */
172 m_busDevices
[CECDEVICE_TV
]->RequestVendorId();
175 if ((bReturn
= SetHDMIPort(m_iBaseDevice
, m_iHDMIPort
, true)) == false)
178 strLog
.Format("unable to set the correct HDMI port (HDMI %d on %s(%x)", m_iHDMIPort
, ToString(m_iBaseDevice
), (uint8_t)m_iBaseDevice
);
179 m_controller
->AddLog(CEC_LOG_ERROR
, strLog
);
182 m_bInitialised
= true;
187 bool CCECProcessor::Start(const char *strPort
, uint16_t iBaudRate
/* = 38400 */, uint32_t iTimeoutMs
/* = 10000 */)
192 CLockObject
lock(m_mutex
);
193 if (!OpenConnection(strPort
, iBaudRate
, iTimeoutMs
))
196 /* create the processor thread */
197 if (!CreateThread() || !m_startCondition
.Wait(m_mutex
) || !m_bStarted
)
199 m_controller
->AddLog(CEC_LOG_ERROR
, "could not create a processor thread");
204 if ((bReturn
= Initialise()) == false)
206 m_controller
->AddLog(CEC_LOG_ERROR
, "could not create a processor thread");
211 m_controller
->AddLog(CEC_LOG_DEBUG
, "processor thread started");
217 bool CCECProcessor::TryLogicalAddress(cec_logical_address address
)
219 if (m_busDevices
[address
]->TryLogicalAddress())
221 m_logicalAddresses
.Set(address
);
228 bool CCECProcessor::FindLogicalAddressRecordingDevice(void)
230 AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'recording device'");
231 return TryLogicalAddress(CECDEVICE_RECORDINGDEVICE1
) ||
232 TryLogicalAddress(CECDEVICE_RECORDINGDEVICE2
) ||
233 TryLogicalAddress(CECDEVICE_RECORDINGDEVICE3
);
236 bool CCECProcessor::FindLogicalAddressTuner(void)
238 AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'tuner'");
239 return TryLogicalAddress(CECDEVICE_TUNER1
) ||
240 TryLogicalAddress(CECDEVICE_TUNER2
) ||
241 TryLogicalAddress(CECDEVICE_TUNER3
) ||
242 TryLogicalAddress(CECDEVICE_TUNER4
);
245 bool CCECProcessor::FindLogicalAddressPlaybackDevice(void)
247 AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'playback device'");
248 return TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE1
) ||
249 TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE2
) ||
250 TryLogicalAddress(CECDEVICE_PLAYBACKDEVICE3
);
253 bool CCECProcessor::FindLogicalAddressAudioSystem(void)
255 AddLog(CEC_LOG_DEBUG
, "detecting logical address for type 'audio'");
256 return TryLogicalAddress(CECDEVICE_AUDIOSYSTEM
);
259 bool CCECProcessor::ChangeDeviceType(cec_device_type from
, cec_device_type to
)
261 bool bChanged(false);
264 strLog
.Format("changing device type '%s' into '%s'", ToString(from
), ToString(to
));
265 AddLog(CEC_LOG_NOTICE
, strLog
);
267 CLockObject
lock(m_mutex
);
268 CCECBusDevice
*previousDevice
= GetDeviceByType(from
);
269 m_logicalAddresses
.primary
= CECDEVICE_UNKNOWN
;
271 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
273 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
276 if (m_types
.types
[iPtr
] == from
)
279 m_types
.types
[iPtr
] = to
;
281 else if (m_types
.types
[iPtr
] == to
&& bChanged
)
283 m_types
.types
[iPtr
] = CEC_DEVICE_TYPE_RESERVED
;
289 FindLogicalAddresses();
291 CCECBusDevice
*newDevice
= GetDeviceByType(to
);
292 if (previousDevice
&& newDevice
)
294 newDevice
->SetDeviceStatus(CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC
);
295 previousDevice
->SetDeviceStatus(CEC_DEVICE_STATUS_UNKNOWN
);
297 newDevice
->SetCecVersion(previousDevice
->GetCecVersion(false));
298 previousDevice
->SetCecVersion(CEC_VERSION_UNKNOWN
);
300 newDevice
->SetMenuLanguage(previousDevice
->GetMenuLanguage(false));
301 cec_menu_language lang
;
302 lang
.device
= previousDevice
->GetLogicalAddress();
303 for (unsigned int iPtr
= 0; iPtr
< 4; iPtr
++)
304 lang
.language
[iPtr
] = '?';
305 lang
.language
[3] = 0;
306 previousDevice
->SetMenuLanguage(lang
);
308 newDevice
->SetMenuState(previousDevice
->GetMenuState());
309 previousDevice
->SetMenuState(CEC_MENU_STATE_DEACTIVATED
);
311 newDevice
->SetOSDName(previousDevice
->GetOSDName(false));
312 previousDevice
->SetOSDName(ToString(previousDevice
->GetLogicalAddress()));
314 newDevice
->SetPhysicalAddress(previousDevice
->GetPhysicalAddress(false));
315 previousDevice
->SetPhysicalAddress(0xFFFF);
317 newDevice
->SetPowerStatus(previousDevice
->GetPowerStatus(false));
318 previousDevice
->SetPowerStatus(CEC_POWER_STATUS_UNKNOWN
);
320 newDevice
->SetVendorId(previousDevice
->GetVendorId(false));
321 previousDevice
->SetVendorId(CEC_VENDOR_UNKNOWN
);
323 if ((from
== CEC_DEVICE_TYPE_PLAYBACK_DEVICE
|| from
== CEC_DEVICE_TYPE_RECORDING_DEVICE
) &&
324 (to
== CEC_DEVICE_TYPE_PLAYBACK_DEVICE
|| to
== CEC_DEVICE_TYPE_RECORDING_DEVICE
))
326 ((CCECPlaybackDevice
*) newDevice
)->SetDeckControlMode(((CCECPlaybackDevice
*) previousDevice
)->GetDeckControlMode());
327 ((CCECPlaybackDevice
*) previousDevice
)->SetDeckControlMode(CEC_DECK_CONTROL_MODE_STOP
);
329 ((CCECPlaybackDevice
*) newDevice
)->SetDeckStatus(((CCECPlaybackDevice
*) previousDevice
)->GetDeckStatus());
330 ((CCECPlaybackDevice
*) previousDevice
)->SetDeckStatus(CEC_DECK_INFO_STOP
);
338 bool CCECProcessor::FindLogicalAddresses(void)
341 m_logicalAddresses
.Clear();
344 for (unsigned int iPtr
= 0; iPtr
< 5; iPtr
++)
346 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_RESERVED
)
349 strLog
.Format("%s - device %d: type %d", __FUNCTION__
, iPtr
, m_types
.types
[iPtr
]);
350 AddLog(CEC_LOG_DEBUG
, strLog
);
352 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_RECORDING_DEVICE
)
353 bReturn
&= FindLogicalAddressRecordingDevice();
354 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_TUNER
)
355 bReturn
&= FindLogicalAddressTuner();
356 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_PLAYBACK_DEVICE
)
357 bReturn
&= FindLogicalAddressPlaybackDevice();
358 if (m_types
.types
[iPtr
] == CEC_DEVICE_TYPE_AUDIO_SYSTEM
)
359 bReturn
&= FindLogicalAddressAudioSystem();
363 SetAckMask(m_logicalAddresses
.AckMask());
368 void CCECProcessor::ReplaceHandlers(void)
370 for (uint8_t iPtr
= 0; iPtr
<= CECDEVICE_PLAYBACKDEVICE3
; iPtr
++)
371 m_busDevices
[iPtr
]->ReplaceHandler(m_bInitialised
);
374 void *CCECProcessor::Process(void)
376 bool bParseFrame(false);
378 CCECAdapterMessage msg
;
381 CLockObject
lock(m_mutex
);
383 m_controller
->AddLog(CEC_LOG_DEBUG
, "processor thread started");
384 m_startCondition
.Signal();
394 CLockObject
lock(m_mutex
);
395 if (m_commandBuffer
.Pop(command
))
399 else if (m_communication
->IsOpen() && m_communication
->Read(msg
, 50))
401 if ((bParseFrame
= (ParseMessage(msg
) && !IsStopped())) == true)
402 command
= m_currentframe
;
407 ParseCommand(command
);
412 m_controller
->CheckKeypressTimeout();
416 m_communication
->Close();
421 bool CCECProcessor::SetActiveSource(cec_device_type type
/* = CEC_DEVICE_TYPE_RESERVED */)
428 cec_logical_address addr
= m_logicalAddresses
.primary
;
430 if (type
!= CEC_DEVICE_TYPE_RESERVED
)
432 for (uint8_t iPtr
= 0; iPtr
<= 11; iPtr
++)
434 if (m_logicalAddresses
[iPtr
] && m_busDevices
[iPtr
]->m_type
== type
)
436 addr
= (cec_logical_address
) iPtr
;
442 m_busDevices
[addr
]->SetActiveSource();
443 if (m_busDevices
[addr
]->GetPhysicalAddress(false) != 0xFFFF)
445 bReturn
= m_busDevices
[addr
]->TransmitActiveSource();
447 if (bReturn
&& (m_busDevices
[addr
]->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE
||
448 m_busDevices
[addr
]->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE
) &&
449 m_busDevices
[addr
]->GetHandler()->SendDeckStatusUpdateOnActiveSource())
451 bReturn
= ((CCECPlaybackDevice
*)m_busDevices
[addr
])->TransmitDeckStatus(CECDEVICE_TV
);
458 bool CCECProcessor::SetActiveSource(uint16_t iStreamPath
)
462 CCECBusDevice
*device
= GetDeviceByPhysicalAddress(iStreamPath
);
465 device
->SetActiveSource();
472 void CCECProcessor::SetStandardLineTimeout(uint8_t iTimeout
)
474 CLockObject
lock(m_mutex
);
475 m_iStandardLineTimeout
= iTimeout
;
478 void CCECProcessor::SetRetryLineTimeout(uint8_t iTimeout
)
480 CLockObject
lock(m_mutex
);
481 m_iRetryLineTimeout
= iTimeout
;
484 bool CCECProcessor::SetActiveView(void)
486 return SetActiveSource(m_types
.IsEmpty() ? CEC_DEVICE_TYPE_RESERVED
: m_types
[0]);
489 bool CCECProcessor::SetDeckControlMode(cec_deck_control_mode mode
, bool bSendUpdate
/* = true */)
493 CCECBusDevice
*device
= GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE
);
496 ((CCECPlaybackDevice
*) device
)->SetDeckControlMode(mode
);
498 ((CCECPlaybackDevice
*) device
)->TransmitDeckStatus(CECDEVICE_TV
);
505 bool CCECProcessor::SetDeckInfo(cec_deck_info info
, bool bSendUpdate
/* = true */)
509 CCECBusDevice
*device
= GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE
);
512 ((CCECPlaybackDevice
*) device
)->SetDeckStatus(info
);
514 ((CCECPlaybackDevice
*) device
)->TransmitDeckStatus(CECDEVICE_TV
);
521 bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice
, uint8_t iPort
, bool bForce
/* = false */)
524 CLockObject
lock(m_mutex
);
526 m_iBaseDevice
= iBaseDevice
;
528 if (!m_bStarted
&& !bForce
)
532 strLog
.Format("setting HDMI port to %d on device %s (%d)", iPort
, ToString(iBaseDevice
), (int)iBaseDevice
);
533 AddLog(CEC_LOG_DEBUG
, strLog
);
535 uint16_t iPhysicalAddress(0);
536 if (iBaseDevice
> CECDEVICE_TV
)
539 iPhysicalAddress
= m_busDevices
[iBaseDevice
]->GetPhysicalAddress();
543 if (iPhysicalAddress
< 0xffff)
545 if (iPhysicalAddress
== 0)
546 iPhysicalAddress
+= 0x1000 * iPort
;
547 else if (iPhysicalAddress
% 0x1000 == 0)
548 iPhysicalAddress
+= 0x100 * iPort
;
549 else if (iPhysicalAddress
% 0x100 == 0)
550 iPhysicalAddress
+= 0x10 * iPort
;
551 else if (iPhysicalAddress
% 0x10 == 0)
552 iPhysicalAddress
+= iPort
;
558 m_controller
->AddLog(CEC_LOG_ERROR
, "failed to set the physical address");
562 SetPhysicalAddress(iPhysicalAddress
);
568 bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress
)
570 for (unsigned int iPtr
= 0; iPtr
< 15; iPtr
++)
572 if (m_busDevices
[iPtr
]->GetPhysicalAddress(false) == iPhysicalAddress
)
578 bool CCECProcessor::TransmitInactiveSource(void)
583 if (!m_logicalAddresses
.IsEmpty() && m_busDevices
[m_logicalAddresses
.primary
])
584 return m_busDevices
[m_logicalAddresses
.primary
]->TransmitInactiveSource();
588 void CCECProcessor::LogOutput(const cec_command
&data
)
591 strTx
.Format("<< %02x", ((uint8_t)data
.initiator
<< 4) + (uint8_t)data
.destination
);
593 strTx
.AppendFormat(":%02x", (uint8_t)data
.opcode
);
595 for (uint8_t iPtr
= 0; iPtr
< data
.parameters
.size
; iPtr
++)
596 strTx
.AppendFormat(":%02x", data
.parameters
[iPtr
]);
597 m_controller
->AddLog(CEC_LOG_TRAFFIC
, strTx
.c_str());
600 bool CCECProcessor::SetLogicalAddress(cec_logical_address iLogicalAddress
)
602 CLockObject
lock(m_mutex
);
603 if (m_logicalAddresses
.primary
!= iLogicalAddress
)
606 strLog
.Format("<< setting primary logical address to %1x", iLogicalAddress
);
607 m_controller
->AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
608 m_logicalAddresses
.primary
= iLogicalAddress
;
609 m_logicalAddresses
.Set(iLogicalAddress
);
610 return SetAckMask(m_logicalAddresses
.AckMask());
616 bool CCECProcessor::SetMenuState(cec_menu_state state
, bool bSendUpdate
/* = true */)
618 for (uint8_t iPtr
= 0; iPtr
< 16; iPtr
++)
620 if (m_logicalAddresses
[iPtr
])
621 m_busDevices
[iPtr
]->SetMenuState(state
);
625 m_busDevices
[m_logicalAddresses
.primary
]->TransmitMenuState(CECDEVICE_TV
);
630 bool CCECProcessor::SetPhysicalAddress(uint16_t iPhysicalAddress
, bool bSendUpdate
/* = true */)
632 bool bSendActiveView(false);
634 cec_logical_addresses sendUpdatesTo
;
637 CLockObject
lock(m_mutex
);
638 if (!m_logicalAddresses
.IsEmpty())
640 bool bWasActiveSource(false);
641 for (uint8_t iPtr
= 0; iPtr
< 15; iPtr
++)
642 if (m_logicalAddresses
[iPtr
])
644 bWasActiveSource
|= m_busDevices
[iPtr
]->IsActiveSource();
645 m_busDevices
[iPtr
]->SetInactiveSource();
646 m_busDevices
[iPtr
]->SetPhysicalAddress(iPhysicalAddress
);
648 sendUpdatesTo
.Set((cec_logical_address
)iPtr
);
651 bSendActiveView
= bWasActiveSource
&& bSendUpdate
;
656 for (uint8_t iPtr
= 0; iPtr
< 15; iPtr
++)
657 if (sendUpdatesTo
[iPtr
])
658 m_busDevices
[iPtr
]->TransmitPhysicalAddress();
666 bool CCECProcessor::SwitchMonitoring(bool bEnable
)
669 strLog
.Format("== %s monitoring mode ==", bEnable
? "enabling" : "disabling");
670 m_controller
->AddLog(CEC_LOG_NOTICE
, strLog
.c_str());
673 CLockObject
lock(m_mutex
);
674 m_bMonitor
= bEnable
;
678 return SetAckMask(0);
680 return SetAckMask(m_logicalAddresses
.AckMask());
683 bool CCECProcessor::PollDevice(cec_logical_address iAddress
)
685 if (iAddress
!= CECDEVICE_UNKNOWN
&& m_busDevices
[iAddress
])
687 return m_logicalAddresses
.primary
== CECDEVICE_UNKNOWN
?
688 m_busDevices
[iAddress
]->TransmitPoll(iAddress
) :
689 m_busDevices
[m_logicalAddresses
.primary
]->TransmitPoll(iAddress
);
694 uint8_t CCECProcessor::VolumeUp(bool bSendRelease
/* = true */)
697 if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM
))
698 status
= ((CCECAudioSystem
*)m_busDevices
[CECDEVICE_AUDIOSYSTEM
])->VolumeUp(bSendRelease
);
703 uint8_t CCECProcessor::VolumeDown(bool bSendRelease
/* = true */)
706 if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM
))
707 status
= ((CCECAudioSystem
*)m_busDevices
[CECDEVICE_AUDIOSYSTEM
])->VolumeDown(bSendRelease
);
712 uint8_t CCECProcessor::MuteAudio(bool bSendRelease
/* = true */)
715 if (IsPresentDevice(CECDEVICE_AUDIOSYSTEM
))
716 status
= ((CCECAudioSystem
*)m_busDevices
[CECDEVICE_AUDIOSYSTEM
])->MuteAudio(bSendRelease
);
721 CCECBusDevice
*CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress
, bool bRefresh
/* = false */) const
723 if (m_busDevices
[m_logicalAddresses
.primary
]->GetPhysicalAddress(false) == iPhysicalAddress
)
724 return m_busDevices
[m_logicalAddresses
.primary
];
726 CCECBusDevice
*device
= NULL
;
727 for (unsigned int iPtr
= 0; iPtr
< 16; iPtr
++)
729 if (m_busDevices
[iPtr
]->GetPhysicalAddress(bRefresh
) == iPhysicalAddress
)
731 device
= m_busDevices
[iPtr
];
739 CCECBusDevice
*CCECProcessor::GetDeviceByType(cec_device_type type
) const
741 CCECBusDevice
*device
= NULL
;
743 for (uint8_t iPtr
= 0; iPtr
< 16; iPtr
++)
745 if (m_busDevices
[iPtr
]->m_type
== type
&& m_logicalAddresses
[iPtr
])
747 device
= m_busDevices
[iPtr
];
755 CCECBusDevice
*CCECProcessor::GetPrimaryDevice(void) const
757 CCECBusDevice
*device(NULL
);
758 cec_logical_address primary
= m_logicalAddresses
.primary
;
759 if (primary
!= CECDEVICE_UNKNOWN
)
760 device
= m_busDevices
[primary
];
764 cec_version
CCECProcessor::GetDeviceCecVersion(cec_logical_address iAddress
)
766 return m_busDevices
[iAddress
]->GetCecVersion();
769 cec_osd_name
CCECProcessor::GetDeviceOSDName(cec_logical_address iAddress
)
771 CStdString strOSDName
= m_busDevices
[iAddress
]->GetOSDName();
774 snprintf(retVal
.name
, sizeof(retVal
.name
), "%s", strOSDName
.c_str());
775 retVal
.device
= iAddress
;
780 bool CCECProcessor::GetDeviceMenuLanguage(cec_logical_address iAddress
, cec_menu_language
*language
)
782 if (m_busDevices
[iAddress
])
784 *language
= m_busDevices
[iAddress
]->GetMenuLanguage();
785 return (strcmp(language
->language
, "???") != 0);
790 uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress
)
792 if (m_busDevices
[iAddress
])
793 return m_busDevices
[iAddress
]->GetVendorId();
797 uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress
)
799 if (m_busDevices
[iAddress
])
800 return m_busDevices
[iAddress
]->GetPhysicalAddress(false);
804 cec_power_status
CCECProcessor::GetDevicePowerStatus(cec_logical_address iAddress
)
806 if (m_busDevices
[iAddress
])
807 return m_busDevices
[iAddress
]->GetPowerStatus();
808 return CEC_POWER_STATUS_UNKNOWN
;
811 cec_logical_address
CCECProcessor::GetActiveSource(void)
813 for (uint8_t iPtr
= 0; iPtr
<= 11; iPtr
++)
815 if (m_busDevices
[iPtr
]->IsActiveSource())
816 return (cec_logical_address
)iPtr
;
819 return CECDEVICE_UNKNOWN
;
822 bool CCECProcessor::IsActiveSource(cec_logical_address iAddress
)
824 return m_busDevices
[iAddress
]->IsActiveSource();
827 bool CCECProcessor::Transmit(const cec_command
&data
)
832 CCECAdapterMessage
*output
= new CCECAdapterMessage(data
);
834 /* set the number of retries */
835 if (data
.opcode
== CEC_OPCODE_NONE
)
836 output
->maxTries
= 1;
837 else if (data
.initiator
!= CECDEVICE_BROADCAST
)
838 output
->maxTries
= m_busDevices
[data
.initiator
]->GetHandler()->GetTransmitRetries() + 1;
840 bReturn
= Transmit(output
);
842 /* set to "not present" on failed ack */
843 if (output
->is_error() && output
->reply
== MSGCODE_TRANSMIT_FAILED_ACK
&&
844 output
->destination() != CECDEVICE_BROADCAST
)
845 m_busDevices
[output
->destination()]->SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT
);
851 bool CCECProcessor::Transmit(CCECAdapterMessage
*output
)
854 CLockObject
lock(m_mutex
);
856 m_iLastTransmission
= GetTimeMs();
857 m_communication
->SetLineTimeout(m_iStandardLineTimeout
);
862 if (output
->tries
> 0)
863 m_communication
->SetLineTimeout(m_iRetryLineTimeout
);
865 CLockObject
msgLock(output
->mutex
);
866 if (!m_communication
|| !m_communication
->Write(output
))
870 output
->condition
.Wait(output
->mutex
);
871 if (output
->state
!= ADAPTER_MESSAGE_STATE_SENT
)
873 m_controller
->AddLog(CEC_LOG_ERROR
, "command was not sent");
878 if (output
->transmit_timeout
> 0)
880 if ((bReturn
= WaitForTransmitSucceeded(output
)) == false)
881 m_controller
->AddLog(CEC_LOG_DEBUG
, "did not receive ack");
885 }while (output
->transmit_timeout
> 0 && output
->needs_retry() && ++output
->tries
< output
->maxTries
);
888 m_communication
->SetLineTimeout(m_iStandardLineTimeout
);
893 void CCECProcessor::TransmitAbort(cec_logical_address address
, cec_opcode opcode
, cec_abort_reason reason
/* = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE */)
895 m_controller
->AddLog(CEC_LOG_DEBUG
, "<< transmitting abort message");
899 cec_command::Format(command
, m_logicalAddresses
.primary
, address
, CEC_OPCODE_FEATURE_ABORT
);
900 command
.parameters
.PushBack((uint8_t)opcode
);
901 command
.parameters
.PushBack((uint8_t)reason
);
906 bool CCECProcessor::WaitForTransmitSucceeded(CCECAdapterMessage
*message
)
909 bool bTransmitSucceeded(false);
910 uint8_t iPacketsLeft(message
->size() / 4);
912 int64_t iNow
= GetTimeMs();
913 int64_t iTargetTime
= iNow
+ message
->transmit_timeout
;
915 while (!bTransmitSucceeded
&& !bError
&& (message
->transmit_timeout
== 0 || iNow
< iTargetTime
))
917 CCECAdapterMessage msg
;
919 if (!m_communication
->Read(msg
, message
->transmit_timeout
> 0 ? (int32_t)(iTargetTime
- iNow
) : 1000))
925 if (msg
.message() == MSGCODE_FRAME_START
&& msg
.ack())
927 m_busDevices
[msg
.initiator()]->GetHandler()->HandlePoll(msg
.initiator(), msg
.destination());
928 m_lastInitiator
= msg
.initiator();
933 bError
= msg
.is_error();
934 if (msg
.message() == MSGCODE_RECEIVE_FAILED
&&
935 m_lastInitiator
!= CECDEVICE_UNKNOWN
&&
936 !m_busDevices
[m_lastInitiator
]->GetHandler()->HandleReceiveFailed())
944 message
->reply
= msg
.message();
945 m_controller
->AddLog(CEC_LOG_DEBUG
, msg
.ToString());
949 switch(msg
.message())
951 case MSGCODE_COMMAND_ACCEPTED
:
952 m_controller
->AddLog(CEC_LOG_DEBUG
, msg
.ToString());
953 if (iPacketsLeft
> 0)
956 case MSGCODE_TRANSMIT_SUCCEEDED
:
957 m_controller
->AddLog(CEC_LOG_DEBUG
, msg
.ToString());
958 bTransmitSucceeded
= (iPacketsLeft
== 0);
959 bError
= !bTransmitSucceeded
;
960 message
->reply
= MSGCODE_TRANSMIT_SUCCEEDED
;
963 // ignore other data while waiting
971 return bTransmitSucceeded
&& !bError
;
974 bool CCECProcessor::ParseMessage(const CCECAdapterMessage
&msg
)
977 bool bIsError(msg
.is_error());
982 switch(msg
.message())
984 case MSGCODE_FRAME_START
:
986 m_currentframe
.Clear();
989 m_currentframe
.initiator
= msg
.initiator();
990 m_currentframe
.destination
= msg
.destination();
991 m_currentframe
.ack
= msg
.ack();
992 m_currentframe
.eom
= msg
.eom();
994 if (m_currentframe
.ack
== 0x1)
996 m_lastInitiator
= m_currentframe
.initiator
;
997 m_busDevices
[m_lastInitiator
]->GetHandler()->HandlePoll(m_currentframe
.initiator
, m_currentframe
.destination
);
1001 case MSGCODE_RECEIVE_FAILED
:
1003 if (m_lastInitiator
!= CECDEVICE_UNKNOWN
)
1004 bIsError
= m_busDevices
[m_lastInitiator
]->GetHandler()->HandleReceiveFailed();
1007 case MSGCODE_FRAME_DATA
:
1009 if (msg
.size() >= 2)
1011 m_currentframe
.PushBack(msg
[1]);
1012 m_currentframe
.eom
= msg
.eom();
1021 m_controller
->AddLog(bIsError
? CEC_LOG_WARNING
: CEC_LOG_DEBUG
, msg
.ToString());
1025 void CCECProcessor::ParseCommand(cec_command
&command
)
1028 dataStr
.Format(">> %1x%1x:%02x", command
.initiator
, command
.destination
, command
.opcode
);
1029 for (uint8_t iPtr
= 0; iPtr
< command
.parameters
.size
; iPtr
++)
1030 dataStr
.AppendFormat(":%02x", (unsigned int)command
.parameters
[iPtr
]);
1031 m_controller
->AddLog(CEC_LOG_TRAFFIC
, dataStr
.c_str());
1033 if (!m_bMonitor
&& command
.initiator
>= CECDEVICE_TV
&& command
.initiator
<= CECDEVICE_BROADCAST
)
1034 m_busDevices
[(uint8_t)command
.initiator
]->HandleCommand(command
);
1037 cec_logical_addresses
CCECProcessor::GetActiveDevices(void)
1039 cec_logical_addresses addresses
;
1041 for (unsigned int iPtr
= 0; iPtr
< 15; iPtr
++)
1043 if (m_busDevices
[iPtr
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
1044 addresses
.Set((cec_logical_address
) iPtr
);
1049 bool CCECProcessor::IsPresentDevice(cec_logical_address address
)
1051 return m_busDevices
[address
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
;
1054 bool CCECProcessor::IsPresentDeviceType(cec_device_type type
)
1056 for (unsigned int iPtr
= 0; iPtr
< 15; iPtr
++)
1058 if (m_busDevices
[iPtr
]->GetType() == type
&& m_busDevices
[iPtr
]->GetStatus() == CEC_DEVICE_STATUS_PRESENT
)
1065 uint16_t CCECProcessor::GetPhysicalAddress(void) const
1067 if (!m_logicalAddresses
.IsEmpty() && m_busDevices
[m_logicalAddresses
.primary
])
1068 return m_busDevices
[m_logicalAddresses
.primary
]->GetPhysicalAddress(false);
1072 void CCECProcessor::SetCurrentButton(cec_user_control_code iButtonCode
)
1074 m_controller
->SetCurrentButton(iButtonCode
);
1077 void CCECProcessor::AddCommand(const cec_command
&command
)
1079 m_controller
->AddCommand(command
);
1082 void CCECProcessor::AddKey(cec_keypress
&key
)
1084 m_controller
->AddKey(key
);
1087 void CCECProcessor::AddKey(void)
1089 m_controller
->AddKey();
1092 void CCECProcessor::AddLog(cec_log_level level
, const CStdString
&strMessage
)
1094 m_controller
->AddLog(level
, strMessage
);
1097 bool CCECProcessor::SetAckMask(uint16_t iMask
)
1099 bool bReturn(false);
1101 strLog
.Format("setting ackmask to %2x", iMask
);
1102 m_controller
->AddLog(CEC_LOG_DEBUG
, strLog
.c_str());
1104 CCECAdapterMessage
*output
= new CCECAdapterMessage
;
1106 output
->push_back(MSGSTART
);
1107 output
->push_escaped(MSGCODE_SET_ACK_MASK
);
1108 output
->push_escaped(iMask
>> 8);
1109 output
->push_escaped((uint8_t)iMask
);
1110 output
->push_back(MSGEND
);
1112 if ((bReturn
= Transmit(output
)) == false)
1113 m_controller
->AddLog(CEC_LOG_ERROR
, "could not set the ackmask");
1120 bool CCECProcessor::TransmitKeypress(cec_logical_address iDestination
, cec_user_control_code key
, bool bWait
/* = true */)
1122 return m_busDevices
[iDestination
]->TransmitKeypress(key
, bWait
);
1125 bool CCECProcessor::TransmitKeyRelease(cec_logical_address iDestination
, bool bWait
/* = true */)
1127 return m_busDevices
[iDestination
]->TransmitKeyRelease(bWait
);
1130 const char *CCECProcessor::ToString(const cec_device_type type
)
1134 case CEC_DEVICE_TYPE_AUDIO_SYSTEM
:
1135 return "audio system";
1136 case CEC_DEVICE_TYPE_PLAYBACK_DEVICE
:
1137 return "playback device";
1138 case CEC_DEVICE_TYPE_RECORDING_DEVICE
:
1139 return "recording device";
1140 case CEC_DEVICE_TYPE_RESERVED
:
1142 case CEC_DEVICE_TYPE_TUNER
:
1144 case CEC_DEVICE_TYPE_TV
:
1151 const char *CCECProcessor::ToString(const cec_menu_state state
)
1155 case CEC_MENU_STATE_ACTIVATED
:
1157 case CEC_MENU_STATE_DEACTIVATED
:
1158 return "deactivated";
1164 const char *CCECProcessor::ToString(const cec_version version
)
1168 case CEC_VERSION_1_2
:
1170 case CEC_VERSION_1_2A
:
1172 case CEC_VERSION_1_3
:
1174 case CEC_VERSION_1_3A
:
1176 case CEC_VERSION_1_4
:
1183 const char *CCECProcessor::ToString(const cec_power_status status
)
1187 case CEC_POWER_STATUS_ON
:
1189 case CEC_POWER_STATUS_STANDBY
:
1191 case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY
:
1192 return "in transition from on to standby";
1193 case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON
:
1194 return "in transition from standby to on";
1200 const char *CCECProcessor::ToString(const cec_logical_address address
)
1204 case CECDEVICE_AUDIOSYSTEM
:
1206 case CECDEVICE_BROADCAST
:
1208 case CECDEVICE_FREEUSE
:
1210 case CECDEVICE_PLAYBACKDEVICE1
:
1211 return "Playback 1";
1212 case CECDEVICE_PLAYBACKDEVICE2
:
1213 return "Playback 2";
1214 case CECDEVICE_PLAYBACKDEVICE3
:
1215 return "Playback 3";
1216 case CECDEVICE_RECORDINGDEVICE1
:
1217 return "Recorder 1";
1218 case CECDEVICE_RECORDINGDEVICE2
:
1219 return "Recorder 2";
1220 case CECDEVICE_RECORDINGDEVICE3
:
1221 return "Recorder 3";
1222 case CECDEVICE_RESERVED1
:
1223 return "Reserved 1";
1224 case CECDEVICE_RESERVED2
:
1225 return "Reserved 2";
1226 case CECDEVICE_TUNER1
:
1228 case CECDEVICE_TUNER2
:
1230 case CECDEVICE_TUNER3
:
1232 case CECDEVICE_TUNER4
:
1241 const char *CCECProcessor::ToString(const cec_deck_control_mode mode
)
1245 case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND
:
1246 return "skip forward wind";
1247 case CEC_DECK_CONTROL_MODE_EJECT
:
1249 case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND
:
1250 return "reverse rewind";
1251 case CEC_DECK_CONTROL_MODE_STOP
:
1258 const char *CCECProcessor::ToString(const cec_deck_info status
)
1262 case CEC_DECK_INFO_PLAY
:
1264 case CEC_DECK_INFO_RECORD
:
1266 case CEC_DECK_INFO_PLAY_REVERSE
:
1267 return "play reverse";
1268 case CEC_DECK_INFO_STILL
:
1270 case CEC_DECK_INFO_SLOW
:
1272 case CEC_DECK_INFO_SLOW_REVERSE
:
1273 return "slow reverse";
1274 case CEC_DECK_INFO_FAST_FORWARD
:
1275 return "fast forward";
1276 case CEC_DECK_INFO_FAST_REVERSE
:
1277 return "fast reverse";
1278 case CEC_DECK_INFO_NO_MEDIA
:
1280 case CEC_DECK_INFO_STOP
:
1282 case CEC_DECK_INFO_SKIP_FORWARD_WIND
:
1283 return "info skip forward wind";
1284 case CEC_DECK_INFO_SKIP_REVERSE_REWIND
:
1285 return "info skip reverse rewind";
1286 case CEC_DECK_INFO_INDEX_SEARCH_FORWARD
:
1287 return "info index search forward";
1288 case CEC_DECK_INFO_INDEX_SEARCH_REVERSE
:
1289 return "info index search reverse";
1290 case CEC_DECK_INFO_OTHER_STATUS
:
1297 const char *CCECProcessor::ToString(const cec_opcode opcode
)
1301 case CEC_OPCODE_ACTIVE_SOURCE
:
1302 return "active source";
1303 case CEC_OPCODE_IMAGE_VIEW_ON
:
1304 return "image view on";
1305 case CEC_OPCODE_TEXT_VIEW_ON
:
1306 return "text view on";
1307 case CEC_OPCODE_INACTIVE_SOURCE
:
1308 return "inactive source";
1309 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE
:
1310 return "request active source";
1311 case CEC_OPCODE_ROUTING_CHANGE
:
1312 return "routing change";
1313 case CEC_OPCODE_ROUTING_INFORMATION
:
1314 return "routing information";
1315 case CEC_OPCODE_SET_STREAM_PATH
:
1316 return "set stream path";
1317 case CEC_OPCODE_STANDBY
:
1319 case CEC_OPCODE_RECORD_OFF
:
1320 return "record off";
1321 case CEC_OPCODE_RECORD_ON
:
1323 case CEC_OPCODE_RECORD_STATUS
:
1324 return "record status";
1325 case CEC_OPCODE_RECORD_TV_SCREEN
:
1326 return "record tv screen";
1327 case CEC_OPCODE_CLEAR_ANALOGUE_TIMER
:
1328 return "clear analogue timer";
1329 case CEC_OPCODE_CLEAR_DIGITAL_TIMER
:
1330 return "clear digital timer";
1331 case CEC_OPCODE_CLEAR_EXTERNAL_TIMER
:
1332 return "clear external timer";
1333 case CEC_OPCODE_SET_ANALOGUE_TIMER
:
1334 return "set analogue timer";
1335 case CEC_OPCODE_SET_DIGITAL_TIMER
:
1336 return "set digital timer";
1337 case CEC_OPCODE_SET_EXTERNAL_TIMER
:
1338 return "set external timer";
1339 case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE
:
1340 return "set timer program title";
1341 case CEC_OPCODE_TIMER_CLEARED_STATUS
:
1342 return "timer cleared status";
1343 case CEC_OPCODE_TIMER_STATUS
:
1344 return "timer status";
1345 case CEC_OPCODE_CEC_VERSION
:
1346 return "cec version";
1347 case CEC_OPCODE_GET_CEC_VERSION
:
1348 return "get cec version";
1349 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS
:
1350 return "give physical address";
1351 case CEC_OPCODE_GET_MENU_LANGUAGE
:
1352 return "get menu language";
1353 case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS
:
1354 return "report physical address";
1355 case CEC_OPCODE_SET_MENU_LANGUAGE
:
1356 return "set menu language";
1357 case CEC_OPCODE_DECK_CONTROL
:
1358 return "deck control";
1359 case CEC_OPCODE_DECK_STATUS
:
1360 return "deck status";
1361 case CEC_OPCODE_GIVE_DECK_STATUS
:
1362 return "give deck status";
1363 case CEC_OPCODE_PLAY
:
1365 case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS
:
1366 return "give tuner status";
1367 case CEC_OPCODE_SELECT_ANALOGUE_SERVICE
:
1368 return "select analogue service";
1369 case CEC_OPCODE_SELECT_DIGITAL_SERVICE
:
1370 return "set digital service";
1371 case CEC_OPCODE_TUNER_DEVICE_STATUS
:
1372 return "tuner device status";
1373 case CEC_OPCODE_TUNER_STEP_DECREMENT
:
1374 return "tuner step decrement";
1375 case CEC_OPCODE_TUNER_STEP_INCREMENT
:
1376 return "tuner step increment";
1377 case CEC_OPCODE_DEVICE_VENDOR_ID
:
1378 return "device vendor id";
1379 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID
:
1380 return "give device vendor id";
1381 case CEC_OPCODE_VENDOR_COMMAND
:
1382 return "vendor command";
1383 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID
:
1384 return "vendor command with id";
1385 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN
:
1386 return "vendor remote button down";
1387 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP
:
1388 return "vendor remote button up";
1389 case CEC_OPCODE_SET_OSD_STRING
:
1390 return "set osd string";
1391 case CEC_OPCODE_GIVE_OSD_NAME
:
1392 return "give osd name";
1393 case CEC_OPCODE_SET_OSD_NAME
:
1394 return "set osd name";
1395 case CEC_OPCODE_MENU_REQUEST
:
1396 return "menu request";
1397 case CEC_OPCODE_MENU_STATUS
:
1398 return "menu status";
1399 case CEC_OPCODE_USER_CONTROL_PRESSED
:
1400 return "user control pressed";
1401 case CEC_OPCODE_USER_CONTROL_RELEASE
:
1402 return "user control release";
1403 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS
:
1404 return "give device power status";
1405 case CEC_OPCODE_REPORT_POWER_STATUS
:
1406 return "report power status";
1407 case CEC_OPCODE_FEATURE_ABORT
:
1408 return "feature abort";
1409 case CEC_OPCODE_ABORT
:
1411 case CEC_OPCODE_GIVE_AUDIO_STATUS
:
1412 return "give audio status";
1413 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS
:
1414 return "give audio mode status";
1415 case CEC_OPCODE_REPORT_AUDIO_STATUS
:
1416 return "report audio status";
1417 case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE
:
1418 return "set system audio mode";
1419 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST
:
1420 return "system audio mode request";
1421 case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS
:
1422 return "system audio mode status";
1423 case CEC_OPCODE_SET_AUDIO_RATE
:
1424 return "set audio rate";
1430 const char *CCECProcessor::ToString(const cec_system_audio_status mode
)
1434 case CEC_SYSTEM_AUDIO_STATUS_ON
:
1436 case CEC_SYSTEM_AUDIO_STATUS_OFF
:
1443 const char *CCECProcessor::ToString(const cec_audio_status
UNUSED(status
))
1445 // TODO this is a mask
1449 const char *CCECProcessor::ToString(const cec_vendor_id vendor
)
1453 case CEC_VENDOR_SAMSUNG
:
1457 case CEC_VENDOR_PANASONIC
:
1459 case CEC_VENDOR_PIONEER
:
1461 case CEC_VENDOR_ONKYO
:
1463 case CEC_VENDOR_YAMAHA
:
1465 case CEC_VENDOR_PHILIPS
:
1467 case CEC_VENDOR_SONY
:
1474 void *CCECBusScan::Process(void)
1476 CCECBusDevice
*device(NULL
);
1477 uint8_t iCounter(0);
1479 while (!IsStopped())
1481 if (++iCounter
< 10)
1486 for (unsigned int iPtr
= 0; iPtr
<= 11 && !IsStopped(); iPtr
++)
1488 device
= m_processor
->m_busDevices
[iPtr
];
1490 if (device
&& device
->GetStatus(true) == CEC_DEVICE_STATUS_PRESENT
)
1494 device
->GetVendorId();
1498 device
->GetPowerStatus(true);
1506 void CCECBusScan::WaitUntilIdle(void)
1511 int32_t iWaitTime
= 3000 - (int32_t)(GetTimeMs() - m_processor
->GetLastTransmission());
1512 while (iWaitTime
> 0)
1515 iWaitTime
= 3000 - (int32_t)(GetTimeMs() - m_processor
->GetLastTransmission());
1519 bool CCECProcessor::StartBootloader(void)
1521 return m_communication
->StartBootloader();
1524 bool CCECProcessor::PingAdapter(void)
1526 return m_communication
->PingAdapter();