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