cec: added vendor id detection for Onkyo
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
CommitLineData
e9de9629
LOK
1/*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved.
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
33#include "CECCommandHandler.h"
eafa9d46 34#include "../devices/CECBusDevice.h"
a1f8fb1b 35#include "../devices/CECAudioSystem.h"
28089abc 36#include "../devices/CECPlaybackDevice.h"
387b6f6f 37#include "../CECProcessor.h"
e9de9629
LOK
38
39using namespace CEC;
8747dd4f 40using namespace std;
e9de9629
LOK
41
42CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice)
43{
44 m_busDevice = busDevice;
45}
46
47bool CCECCommandHandler::HandleCommand(const cec_command &command)
48{
49 bool bHandled(true);
50
5e822b09 51 CStdString strLog;
62f5527d 52 strLog.Format(">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
5e822b09
LOK
53 m_busDevice->AddLog(CEC_LOG_NOTICE, strLog);
54
f8513317 55 if (m_busDevice->MyLogicalAddressContains(command.destination))
e9de9629
LOK
56 {
57 switch(command.opcode)
58 {
e55f3f70
LOK
59 case CEC_OPCODE_REPORT_POWER_STATUS:
60 HandleReportPowerStatus(command);
61 break;
6a1c0009
LOK
62 case CEC_OPCODE_CEC_VERSION:
63 HandleDeviceCecVersion(command);
64 break;
a3269a0a
LOK
65 case CEC_OPCODE_SET_MENU_LANGUAGE:
66 HandleSetMenuLanguage(command);
4d6b4433 67 /* pass to listeners */
a9e03a86 68 m_busDevice->GetProcessor()->AddCommand(command);
a3269a0a 69 break;
e9de9629
LOK
70 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
71 HandleGivePhysicalAddress(command);
72 break;
73 case CEC_OPCODE_GIVE_OSD_NAME:
74 HandleGiveOSDName(command);
75 break;
76 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
77 HandleGiveDeviceVendorId(command);
78 break;
79 case CEC_OPCODE_DEVICE_VENDOR_ID:
80 HandleDeviceVendorId(command);
81 break;
82 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
83 HandleDeviceVendorCommandWithId(command);
84 break;
85 case CEC_OPCODE_GIVE_DECK_STATUS:
86 HandleGiveDeckStatus(command);
87 break;
a9232a79
LOK
88 case CEC_OPCODE_DECK_CONTROL:
89 HandleDeckControl(command);
56594657
LOK
90 /* pass to listeners */
91 m_busDevice->GetProcessor()->AddCommand(command);
a9232a79 92 break;
e9de9629 93 case CEC_OPCODE_MENU_REQUEST:
a483a2fb
LOK
94 if (!HandleMenuRequest(command))
95 {
96 /* pass to listeners */
97 m_busDevice->GetProcessor()->AddCommand(command);
98 }
e9de9629
LOK
99 break;
100 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
101 HandleGiveDevicePowerStatus(command);
102 break;
103 case CEC_OPCODE_GET_CEC_VERSION:
104 HandleGetCecVersion(command);
105 break;
106 case CEC_OPCODE_USER_CONTROL_PRESSED:
107 HandleUserControlPressed(command);
108 break;
109 case CEC_OPCODE_USER_CONTROL_RELEASE:
110 HandleUserControlRelease(command);
111 break;
a1f8fb1b
LOK
112 case CEC_OPCODE_GIVE_AUDIO_STATUS:
113 HandleGiveAudioStatus(command);
114 break;
cf0ecd85
LOK
115 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
116 HandleGiveSystemAudioModeStatus(command);
117 break;
e5e86c76
LOK
118 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
119 HandleSetSystemAudioModeRequest(command);
120 break;
e9de9629
LOK
121 default:
122 UnhandledCommand(command);
4d6b4433 123 /* pass to listeners */
a9e03a86 124 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
125 bHandled = false;
126 break;
127 }
128 }
129 else if (command.destination == CECDEVICE_BROADCAST)
130 {
131 CStdString strLog;
132 switch (command.opcode)
133 {
a3269a0a
LOK
134 case CEC_OPCODE_SET_MENU_LANGUAGE:
135 HandleSetMenuLanguage(command);
4d6b4433 136 /* pass to listeners */
a9e03a86 137 m_busDevice->GetProcessor()->AddCommand(command);
a3269a0a 138 break;
e9de9629
LOK
139 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
140 HandleRequestActiveSource(command);
141 break;
142 case CEC_OPCODE_SET_STREAM_PATH:
143 HandleSetStreamPath(command);
144 break;
145 case CEC_OPCODE_ROUTING_CHANGE:
146 HandleRoutingChange(command);
147 break;
148 case CEC_OPCODE_DEVICE_VENDOR_ID:
149 HandleDeviceVendorId(command);
150 break;
151 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
152 HandleDeviceVendorCommandWithId(command);
153 break;
4d6b4433
LOK
154 case CEC_OPCODE_STANDBY:
155 HandleStandby(command);
156 /* pass to listeners */
157 m_busDevice->GetProcessor()->AddCommand(command);
158 break;
be5b0e24
LOK
159 case CEC_OPCODE_ACTIVE_SOURCE:
160 HandleActiveSource(command);
161 /* pass to listeners */
162 m_busDevice->GetProcessor()->AddCommand(command);
163 break;
e9de9629
LOK
164 default:
165 UnhandledCommand(command);
4d6b4433 166 /* pass to listeners */
a9e03a86 167 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
168 bHandled = false;
169 break;
170 }
171 }
172 else
173 {
174 CStdString strLog;
f8513317 175 strLog.Format("ignoring frame: we're not at destination %x", command.destination);
e9de9629
LOK
176 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
177 bHandled = false;
178 }
179
180 return bHandled;
181}
182
be5b0e24
LOK
183bool CCECCommandHandler::HandleActiveSource(const cec_command &command)
184{
185 if (command.parameters.size == 2)
186 {
187 uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
188 return m_busDevice->GetProcessor()->SetStreamPath(iAddress);
189 }
190
191 return true;
192}
193
a9232a79
LOK
194bool CCECCommandHandler::HandleDeckControl(const cec_command &command)
195{
196 CCECBusDevice *device = GetDevice(command.destination);
88e5de6f 197 if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) && command.parameters.size > 0)
a9232a79
LOK
198 {
199 ((CCECPlaybackDevice *) device)->SetDeckControlMode((cec_deck_control_mode) command.parameters[0]);
200 return true;
201 }
202
203 return false;
204}
205
6a1c0009
LOK
206bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
207{
208 if (command.parameters.size == 1)
209 {
210 CCECBusDevice *device = GetDevice(command.initiator);
211 if (device)
212 device->SetCecVersion((cec_version) command.parameters[0]);
213 }
214
215 return true;
216}
217
e9de9629
LOK
218bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
219{
181b3475 220 SetVendorId(command);
c4098482 221 m_busDevice->GetProcessor()->TransmitAbort(command.initiator, command.opcode, CEC_ABORT_REASON_REFUSED);
6a1c0009 222 return true;
e9de9629
LOK
223}
224
225bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
226{
181b3475 227 SetVendorId(command);
6a1c0009 228 return true;
e9de9629
LOK
229}
230
231bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
232{
f8513317 233 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 234 if (device)
29912296 235 return device->TransmitCECVersion(command.initiator);
0f23c85c
LOK
236
237 return false;
e9de9629
LOK
238}
239
a1f8fb1b
LOK
240bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command)
241{
242 CCECBusDevice *device = GetDevice(command.destination);
243 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
244 return ((CCECAudioSystem *) device)->TransmitAudioStatus(command.initiator);
245
246 return false;
247}
248
e9de9629
LOK
249bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
250{
f8513317 251 CCECBusDevice *device = GetDevice(command.destination);
88e5de6f 252 if (device && (device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || device->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE))
28089abc 253 return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
0f23c85c
LOK
254
255 return false;
e9de9629
LOK
256}
257
258bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
259{
f8513317 260 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 261 if (device)
29912296 262 return device->TransmitPowerState(command.initiator);
0f23c85c
LOK
263
264 return false;
e9de9629
LOK
265}
266
267bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
268{
f8513317 269 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 270 if (device)
29912296 271 return device->TransmitVendorID(command.initiator);
0f23c85c
LOK
272
273 return false;
e9de9629
LOK
274}
275
276bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
277{
f8513317 278 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 279 if (device)
29912296 280 return device->TransmitOSDName(command.initiator);
0f23c85c
LOK
281
282 return false;
e9de9629
LOK
283}
284
285bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
286{
f8513317 287 CCECBusDevice *device = GetDevice(command.destination);
09c10b66 288 if (device)
29912296 289 return device->TransmitPhysicalAddress();
09c10b66
LOK
290
291 return false;
e9de9629
LOK
292}
293
294bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
295{
296 if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
0f23c85c 297 {
f8513317 298 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 299 if (device)
29912296 300 return device->TransmitMenuState(command.initiator);
0f23c85c
LOK
301 }
302 return false;
e9de9629
LOK
303}
304
e55f3f70
LOK
305bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command)
306{
307 if (command.parameters.size == 1)
308 {
309 CCECBusDevice *device = GetDevice(command.initiator);
310 if (device)
311 device->SetPowerStatus((cec_power_status) command.parameters[0]);
312 }
313 return true;
314}
315
e9de9629
LOK
316bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command)
317{
318 CStdString strLog;
319 strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
320 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
8747dd4f
LOK
321
322 vector<CCECBusDevice *> devices;
323 for (int iDevicePtr = (int)GetMyDevices(devices)-1; iDevicePtr >=0; iDevicePtr--)
324 devices[iDevicePtr]->TransmitActiveSource();
c4098482 325
8747dd4f 326 return true;
e9de9629
LOK
327}
328
329bool CCECCommandHandler::HandleRoutingChange(const cec_command &command)
330{
331 if (command.parameters.size == 4)
332 {
333 uint16_t iOldAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
334 uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]);
e9de9629 335
0f23c85c
LOK
336 CCECBusDevice *device = GetDevice(command.initiator);
337 if (device)
9dc04b07 338 device->SetStreamPath(iNewAddress, iOldAddress);
e9de9629
LOK
339 }
340 return true;
341}
342
a3269a0a
LOK
343bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command)
344{
345 if (command.parameters.size == 3)
346 {
347 CCECBusDevice *device = GetDevice(command.initiator);
348 if (device)
349 {
350 cec_menu_language language;
351 language.device = command.initiator;
56701628 352 for (uint8_t iPtr = 0; iPtr < 4; iPtr++)
a3269a0a
LOK
353 language.language[iPtr] = command.parameters[iPtr];
354 language.language[3] = 0;
355 device->SetMenuLanguage(language);
356 }
357 }
358 return true;
359}
360
e9de9629
LOK
361bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
362{
363 if (command.parameters.size >= 2)
364 {
b6c7bc94 365 uint16_t iStreamAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
e9de9629 366 CStdString strLog;
b6c7bc94 367 strLog.Format(">> %i sets stream path to physical address %04x", command.initiator, iStreamAddress);
e9de9629 368 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
04437dcf 369
b6c7bc94
LOK
370 if (m_busDevice->GetProcessor()->SetStreamPath(iStreamAddress))
371 {
372 CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamAddress);
373 if (device)
374 {
375 return device->TransmitActiveSource() &&
376 device->TransmitMenuState(command.initiator);
377 }
378 }
379 return false;
e9de9629
LOK
380 }
381 return true;
382}
383
e5e86c76
LOK
384bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command)
385{
386 if (command.parameters.size >= 1)
387 {
388 CCECBusDevice *device = GetDevice(command.destination);
389 if (device&& device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
390 return ((CCECAudioSystem *) device)->SetSystemAudioMode(command);
391 }
392 return true;
393}
394
4d6b4433
LOK
395bool CCECCommandHandler::HandleStandby(const cec_command &command)
396{
397 CCECBusDevice *device = GetDevice(command.initiator);
398 if (device)
399 device->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
400 return true;
401}
402
cf0ecd85
LOK
403bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command)
404{
405 CCECBusDevice *device = GetDevice(command.destination);
406 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
407 return ((CCECAudioSystem *) device)->TransmitSystemAudioModeStatus(command.initiator);
408
409 return false;
410}
411
e9de9629
LOK
412bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
413{
414 if (command.parameters.size > 0)
415 {
416 m_busDevice->GetProcessor()->AddKey();
417
418 if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX)
419 {
420 CStdString strLog;
68391d4f 421 strLog.Format("key pressed: %x", command.parameters[0]);
e9de9629
LOK
422 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
423
68391d4f
LOK
424 if (command.parameters[0] == CEC_USER_CONTROL_CODE_POWER ||
425 command.parameters[0] == CEC_USER_CONTROL_CODE_POWER_ON_FUNCTION)
426 {
427 CCECBusDevice *device = GetDevice(command.destination);
428 if (device)
429 device->SetPowerStatus(CEC_POWER_STATUS_ON);
430 }
431
e9de9629
LOK
432 m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]);
433 }
434 }
435 return true;
436}
437
438bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command)
439{
440 m_busDevice->GetProcessor()->AddKey();
441 return true;
442}
443
444void CCECCommandHandler::UnhandledCommand(const cec_command &command)
445{
b5b53c7d
LOK
446 CStdString strLog;
447 strLog.Format("unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
448 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
0f23c85c
LOK
449}
450
8747dd4f
LOK
451unsigned int CCECCommandHandler::GetMyDevices(vector<CCECBusDevice *> &devices) const
452{
453 unsigned int iReturn(0);
454
455 cec_logical_addresses addresses = m_busDevice->GetProcessor()->GetLogicalAddresses();
f2198ab5 456 for (uint8_t iPtr = 0; iPtr < 16; iPtr++)
8747dd4f
LOK
457 {
458 if (addresses[iPtr])
459 {
460 devices.push_back(GetDevice((cec_logical_address) iPtr));
461 ++iReturn;
462 }
463 }
464
465 return iReturn;
466}
467
0f23c85c
LOK
468CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress) const
469{
470 CCECBusDevice *device = NULL;
471
472 if (iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST)
473 device = m_busDevice->GetProcessor()->m_busDevices[iLogicalAddress];
474
475 return device;
e9de9629 476}
6685ae07
LOK
477
478CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
479{
8ac9c610 480 return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress);
6685ae07 481}
181b3475 482
c4098482
LOK
483CCECBusDevice *CCECCommandHandler::GetDeviceByType(cec_device_type type) const
484{
485 return m_busDevice->GetProcessor()->GetDeviceByType(type);
486}
487
181b3475
LOK
488void CCECCommandHandler::SetVendorId(const cec_command &command)
489{
490 if (command.parameters.size < 3)
491 {
492 m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
493 return;
494 }
495
bae71306
LOK
496 uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
497 ((uint64_t)command.parameters[1] << 8) +
181b3475
LOK
498 (uint64_t)command.parameters[2];
499
500 CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
501 if (device)
c4098482 502 device->SetVendorId(iVendorId);
181b3475 503}
5e822b09 504
28fa6c97
LOK
505const char *CCECCommandHandler::ToString(const cec_menu_state state)
506{
507 switch (state)
508 {
509 case CEC_MENU_STATE_ACTIVATED:
510 return "activated";
511 case CEC_MENU_STATE_DEACTIVATED:
512 return "deactivated";
513 default:
514 return "unknown";
515 }
516}
517
c686413b
LOK
518const char *CCECCommandHandler::ToString(const cec_version version)
519{
520 switch (version)
521 {
522 case CEC_VERSION_1_2:
523 return "1.2";
524 case CEC_VERSION_1_2A:
525 return "1.2a";
526 case CEC_VERSION_1_3:
527 return "1.3";
528 case CEC_VERSION_1_3A:
529 return "1.3a";
c4098482
LOK
530 case CEC_VERSION_1_4:
531 return "1.4";
c686413b
LOK
532 default:
533 return "unknown";
534 }
535}
536
66c16b69
LOK
537const char *CCECCommandHandler::ToString(const cec_power_status status)
538{
539 switch (status)
540 {
541 case CEC_POWER_STATUS_ON:
542 return "on";
543 case CEC_POWER_STATUS_STANDBY:
544 return "standby";
545 case CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY:
546 return "in transition from on to standby";
547 case CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON:
548 return "in transition from standby to on";
549 default:
550 return "unknown";
551 }
552}
553
62f5527d
LOK
554const char *CCECCommandHandler::ToString(const cec_logical_address address)
555{
556 switch(address)
557 {
558 case CECDEVICE_AUDIOSYSTEM:
559 return "Audio";
560 case CECDEVICE_BROADCAST:
561 return "Broadcast";
562 case CECDEVICE_FREEUSE:
563 return "Free use";
564 case CECDEVICE_PLAYBACKDEVICE1:
565 return "Playback 1";
566 case CECDEVICE_PLAYBACKDEVICE2:
567 return "Playback 2";
568 case CECDEVICE_PLAYBACKDEVICE3:
569 return "Playback 3";
570 case CECDEVICE_RECORDINGDEVICE1:
571 return "Recorder 1";
572 case CECDEVICE_RECORDINGDEVICE2:
573 return "Recorder 2";
574 case CECDEVICE_RECORDINGDEVICE3:
575 return "Recorder 3";
576 case CECDEVICE_RESERVED1:
577 return "Reserved 1";
578 case CECDEVICE_RESERVED2:
579 return "Reserved 2";
580 case CECDEVICE_TUNER1:
581 return "Tuner 1";
582 case CECDEVICE_TUNER2:
583 return "Tuner 2";
584 case CECDEVICE_TUNER3:
585 return "Tuner 3";
586 case CECDEVICE_TUNER4:
587 return "Tuner 4";
588 case CECDEVICE_TV:
589 return "TV";
590 default:
591 return "unknown";
592 }
593}
594
a9232a79
LOK
595const char *CCECCommandHandler::ToString(const cec_deck_control_mode mode)
596{
597 switch (mode)
598 {
599 case CEC_DECK_CONTROL_MODE_SKIP_FORWARD_WIND:
600 return "skip forward wind";
601 case CEC_DECK_CONTROL_MODE_EJECT:
602 return "eject";
603 case CEC_DECK_CONTROL_MODE_SKIP_REVERSE_REWIND:
604 return "reverse rewind";
605 case CEC_DECK_CONTROL_MODE_STOP:
606 return "stop";
607 default:
608 return "unknown";
609 }
610}
611
8ac9c610
LOK
612const char *CCECCommandHandler::ToString(const cec_deck_info status)
613{
614 switch (status)
615 {
616 case CEC_DECK_INFO_PLAY:
617 return "play";
618 case CEC_DECK_INFO_RECORD:
619 return "record";
620 case CEC_DECK_INFO_PLAY_REVERSE:
621 return "play reverse";
622 case CEC_DECK_INFO_STILL:
623 return "still";
624 case CEC_DECK_INFO_SLOW:
625 return "slow";
626 case CEC_DECK_INFO_SLOW_REVERSE:
627 return "slow reverse";
628 case CEC_DECK_INFO_FAST_FORWARD:
629 return "fast forward";
630 case CEC_DECK_INFO_FAST_REVERSE:
631 return "fast reverse";
632 case CEC_DECK_INFO_NO_MEDIA:
633 return "no media";
634 case CEC_DECK_INFO_STOP:
635 return "stop";
636 case CEC_DECK_INFO_SKIP_FORWARD_WIND:
637 return "info skip forward wind";
638 case CEC_DECK_INFO_SKIP_REVERSE_REWIND:
639 return "info skip reverse rewind";
640 case CEC_DECK_INFO_INDEX_SEARCH_FORWARD:
641 return "info index search forward";
642 case CEC_DECK_INFO_INDEX_SEARCH_REVERSE:
643 return "info index search reverse";
644 case CEC_DECK_INFO_OTHER_STATUS:
645 return "other";
646 default:
647 return "unknown";
648 }
649}
650
5e822b09
LOK
651const char *CCECCommandHandler::ToString(const cec_opcode opcode)
652{
653 switch (opcode)
654 {
655 case CEC_OPCODE_ACTIVE_SOURCE:
656 return "active source";
657 case CEC_OPCODE_IMAGE_VIEW_ON:
658 return "image view on";
659 case CEC_OPCODE_TEXT_VIEW_ON:
660 return "text view on";
661 case CEC_OPCODE_INACTIVE_SOURCE:
662 return "inactive source";
663 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
664 return "request active source";
665 case CEC_OPCODE_ROUTING_CHANGE:
666 return "routing change";
667 case CEC_OPCODE_ROUTING_INFORMATION:
668 return "routing information";
669 case CEC_OPCODE_SET_STREAM_PATH:
670 return "set stream path";
671 case CEC_OPCODE_STANDBY:
672 return "standby";
673 case CEC_OPCODE_RECORD_OFF:
674 return "record off";
675 case CEC_OPCODE_RECORD_ON:
676 return "record on";
677 case CEC_OPCODE_RECORD_STATUS:
678 return "record status";
679 case CEC_OPCODE_RECORD_TV_SCREEN:
680 return "record tv screen";
681 case CEC_OPCODE_CLEAR_ANALOGUE_TIMER:
682 return "clear analogue timer";
683 case CEC_OPCODE_CLEAR_DIGITAL_TIMER:
684 return "clear digital timer";
685 case CEC_OPCODE_CLEAR_EXTERNAL_TIMER:
686 return "clear external timer";
687 case CEC_OPCODE_SET_ANALOGUE_TIMER:
688 return "set analogue timer";
689 case CEC_OPCODE_SET_DIGITAL_TIMER:
690 return "set digital timer";
691 case CEC_OPCODE_SET_EXTERNAL_TIMER:
692 return "set external timer";
693 case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE:
694 return "set timer program title";
695 case CEC_OPCODE_TIMER_CLEARED_STATUS:
696 return "timer cleared status";
697 case CEC_OPCODE_TIMER_STATUS:
698 return "timer status";
699 case CEC_OPCODE_CEC_VERSION:
700 return "cec version";
701 case CEC_OPCODE_GET_CEC_VERSION:
702 return "get cec version";
703 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
704 return "give physical address";
705 case CEC_OPCODE_GET_MENU_LANGUAGE:
706 return "get menu language";
707 case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
708 return "report physical address";
709 case CEC_OPCODE_SET_MENU_LANGUAGE:
710 return "set menu language";
711 case CEC_OPCODE_DECK_CONTROL:
712 return "deck control";
713 case CEC_OPCODE_DECK_STATUS:
714 return "deck status";
715 case CEC_OPCODE_GIVE_DECK_STATUS:
716 return "give deck status";
717 case CEC_OPCODE_PLAY:
718 return "play";
719 case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS:
720 return "give tuner status";
721 case CEC_OPCODE_SELECT_ANALOGUE_SERVICE:
722 return "select analogue service";
723 case CEC_OPCODE_SELECT_DIGITAL_SERVICE:
724 return "set digital service";
725 case CEC_OPCODE_TUNER_DEVICE_STATUS:
726 return "tuner device status";
727 case CEC_OPCODE_TUNER_STEP_DECREMENT:
728 return "tuner step decrement";
729 case CEC_OPCODE_TUNER_STEP_INCREMENT:
730 return "tuner step increment";
731 case CEC_OPCODE_DEVICE_VENDOR_ID:
732 return "device vendor id";
733 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
734 return "give device vendor id";
735 case CEC_OPCODE_VENDOR_COMMAND:
736 return "vendor command";
737 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
738 return "vendor command with id";
739 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN:
740 return "vendor remote button down";
741 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP:
742 return "vendor remote button up";
743 case CEC_OPCODE_SET_OSD_STRING:
744 return "set osd string";
745 case CEC_OPCODE_GIVE_OSD_NAME:
746 return "give osd name";
747 case CEC_OPCODE_SET_OSD_NAME:
748 return "set osd name";
749 case CEC_OPCODE_MENU_REQUEST:
750 return "menu request";
751 case CEC_OPCODE_MENU_STATUS:
752 return "menu status";
753 case CEC_OPCODE_USER_CONTROL_PRESSED:
754 return "user control pressed";
755 case CEC_OPCODE_USER_CONTROL_RELEASE:
756 return "user control release";
757 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
758 return "give device power status";
759 case CEC_OPCODE_REPORT_POWER_STATUS:
760 return "report power status";
761 case CEC_OPCODE_FEATURE_ABORT:
762 return "feature abort";
763 case CEC_OPCODE_ABORT:
764 return "abort";
765 case CEC_OPCODE_GIVE_AUDIO_STATUS:
766 return "give audio status";
767 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
768 return "give audio mode status";
769 case CEC_OPCODE_REPORT_AUDIO_STATUS:
770 return "report audio status";
771 case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE:
772 return "set system audio mode";
773 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
774 return "system audio mode request";
775 case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
776 return "system audio mode status";
777 case CEC_OPCODE_SET_AUDIO_RATE:
778 return "set audio rate";
779 default:
780 return "UNKNOWN";
781 }
782}
c4098482
LOK
783
784const char *CCECCommandHandler::ToString(const cec_system_audio_status mode)
785{
786 switch(mode)
787 {
788 case CEC_SYSTEM_AUDIO_STATUS_ON:
789 return "on";
790 case CEC_SYSTEM_AUDIO_STATUS_OFF:
791 return "off";
792 default:
793 return "unknown";
794 }
795}
796
797const char *CCECCommandHandler::ToString(const cec_audio_status status)
798{
799 // TODO this is a mask
800 return "TODO";
801}
802
803const char *CCECCommandHandler::ToString(const cec_vendor_id vendor)
804{
805 switch (vendor)
806 {
807 case CEC_VENDOR_SAMSUNG:
808 return "Samsung";
809 case CEC_VENDOR_LG:
810 return "LG";
811 case CEC_VENDOR_PANASONIC:
812 return "Panasonic";
813 case CEC_VENDOR_PIONEER:
814 return "Pioneer";
cd02e9b2
LOK
815 case CEC_VENDOR_ONKYO:
816 return "Onkyo";
c4098482
LOK
817 default:
818 return "Unknown";
819 }
820}