cec: mark the active source as active and other devices as inactive. removed duplicat...
[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;
88 case CEC_OPCODE_MENU_REQUEST:
89 HandleMenuRequest(command);
90 break;
91 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
92 HandleGiveDevicePowerStatus(command);
93 break;
94 case CEC_OPCODE_GET_CEC_VERSION:
95 HandleGetCecVersion(command);
96 break;
97 case CEC_OPCODE_USER_CONTROL_PRESSED:
98 HandleUserControlPressed(command);
99 break;
100 case CEC_OPCODE_USER_CONTROL_RELEASE:
101 HandleUserControlRelease(command);
102 break;
a1f8fb1b
LOK
103 case CEC_OPCODE_GIVE_AUDIO_STATUS:
104 HandleGiveAudioStatus(command);
105 break;
cf0ecd85
LOK
106 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
107 HandleGiveSystemAudioModeStatus(command);
108 break;
e5e86c76
LOK
109 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
110 HandleSetSystemAudioModeRequest(command);
111 break;
e9de9629
LOK
112 default:
113 UnhandledCommand(command);
4d6b4433 114 /* pass to listeners */
a9e03a86 115 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
116 bHandled = false;
117 break;
118 }
119 }
120 else if (command.destination == CECDEVICE_BROADCAST)
121 {
122 CStdString strLog;
123 switch (command.opcode)
124 {
a3269a0a
LOK
125 case CEC_OPCODE_SET_MENU_LANGUAGE:
126 HandleSetMenuLanguage(command);
4d6b4433 127 /* pass to listeners */
a9e03a86 128 m_busDevice->GetProcessor()->AddCommand(command);
a3269a0a 129 break;
e9de9629
LOK
130 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
131 HandleRequestActiveSource(command);
132 break;
133 case CEC_OPCODE_SET_STREAM_PATH:
134 HandleSetStreamPath(command);
135 break;
136 case CEC_OPCODE_ROUTING_CHANGE:
137 HandleRoutingChange(command);
138 break;
139 case CEC_OPCODE_DEVICE_VENDOR_ID:
140 HandleDeviceVendorId(command);
141 break;
142 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
143 HandleDeviceVendorCommandWithId(command);
144 break;
4d6b4433
LOK
145 case CEC_OPCODE_STANDBY:
146 HandleStandby(command);
147 /* pass to listeners */
148 m_busDevice->GetProcessor()->AddCommand(command);
149 break;
e9de9629
LOK
150 default:
151 UnhandledCommand(command);
4d6b4433 152 /* pass to listeners */
a9e03a86 153 m_busDevice->GetProcessor()->AddCommand(command);
e9de9629
LOK
154 bHandled = false;
155 break;
156 }
157 }
158 else
159 {
160 CStdString strLog;
f8513317 161 strLog.Format("ignoring frame: we're not at destination %x", command.destination);
e9de9629
LOK
162 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
163 bHandled = false;
164 }
165
166 return bHandled;
167}
168
6a1c0009
LOK
169bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
170{
171 if (command.parameters.size == 1)
172 {
173 CCECBusDevice *device = GetDevice(command.initiator);
174 if (device)
175 device->SetCecVersion((cec_version) command.parameters[0]);
176 }
177
178 return true;
179}
180
e9de9629
LOK
181bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
182{
181b3475 183 SetVendorId(command);
6a1c0009 184 return true;
e9de9629
LOK
185}
186
187bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
188{
181b3475 189 SetVendorId(command);
6a1c0009 190 return true;
e9de9629
LOK
191}
192
193bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
194{
f8513317 195 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 196 if (device)
29912296 197 return device->TransmitCECVersion(command.initiator);
0f23c85c
LOK
198
199 return false;
e9de9629
LOK
200}
201
a1f8fb1b
LOK
202bool CCECCommandHandler::HandleGiveAudioStatus(const cec_command &command)
203{
204 CCECBusDevice *device = GetDevice(command.destination);
205 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
206 return ((CCECAudioSystem *) device)->TransmitAudioStatus(command.initiator);
207
208 return false;
209}
210
e9de9629
LOK
211bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
212{
f8513317 213 CCECBusDevice *device = GetDevice(command.destination);
28089abc
LOK
214 if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE)
215 return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
0f23c85c
LOK
216
217 return false;
e9de9629
LOK
218}
219
220bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
221{
f8513317 222 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 223 if (device)
29912296 224 return device->TransmitPowerState(command.initiator);
0f23c85c
LOK
225
226 return false;
e9de9629
LOK
227}
228
229bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
230{
f8513317 231 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 232 if (device)
29912296 233 return device->TransmitVendorID(command.initiator);
0f23c85c
LOK
234
235 return false;
e9de9629
LOK
236}
237
238bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
239{
f8513317 240 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 241 if (device)
29912296 242 return device->TransmitOSDName(command.initiator);
0f23c85c
LOK
243
244 return false;
e9de9629
LOK
245}
246
247bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
248{
f8513317 249 CCECBusDevice *device = GetDevice(command.destination);
09c10b66 250 if (device)
29912296 251 return device->TransmitPhysicalAddress();
09c10b66
LOK
252
253 return false;
e9de9629
LOK
254}
255
256bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
257{
258 if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
0f23c85c 259 {
f8513317 260 CCECBusDevice *device = GetDevice(command.destination);
0f23c85c 261 if (device)
29912296 262 return device->TransmitMenuState(command.initiator);
0f23c85c
LOK
263 }
264 return false;
e9de9629
LOK
265}
266
e55f3f70
LOK
267bool CCECCommandHandler::HandleReportPowerStatus(const cec_command &command)
268{
269 if (command.parameters.size == 1)
270 {
271 CCECBusDevice *device = GetDevice(command.initiator);
272 if (device)
273 device->SetPowerStatus((cec_power_status) command.parameters[0]);
274 }
275 return true;
276}
277
e9de9629
LOK
278bool CCECCommandHandler::HandleRequestActiveSource(const cec_command &command)
279{
280 CStdString strLog;
281 strLog.Format(">> %i requests active source", (uint8_t) command.initiator);
282 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
8747dd4f
LOK
283
284 vector<CCECBusDevice *> devices;
285 for (int iDevicePtr = (int)GetMyDevices(devices)-1; iDevicePtr >=0; iDevicePtr--)
286 devices[iDevicePtr]->TransmitActiveSource();
287 return true;
e9de9629
LOK
288}
289
290bool CCECCommandHandler::HandleRoutingChange(const cec_command &command)
291{
292 if (command.parameters.size == 4)
293 {
294 uint16_t iOldAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
295 uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]);
e9de9629 296
0f23c85c
LOK
297 CCECBusDevice *device = GetDevice(command.initiator);
298 if (device)
9dc04b07 299 device->SetStreamPath(iNewAddress, iOldAddress);
e9de9629
LOK
300 }
301 return true;
302}
303
a3269a0a
LOK
304bool CCECCommandHandler::HandleSetMenuLanguage(const cec_command &command)
305{
306 if (command.parameters.size == 3)
307 {
308 CCECBusDevice *device = GetDevice(command.initiator);
309 if (device)
310 {
311 cec_menu_language language;
312 language.device = command.initiator;
56701628 313 for (uint8_t iPtr = 0; iPtr < 4; iPtr++)
a3269a0a
LOK
314 language.language[iPtr] = command.parameters[iPtr];
315 language.language[3] = 0;
316 device->SetMenuLanguage(language);
317 }
318 }
319 return true;
320}
321
e9de9629
LOK
322bool CCECCommandHandler::HandleSetStreamPath(const cec_command &command)
323{
324 if (command.parameters.size >= 2)
325 {
326 int streamaddr = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
327 CStdString strLog;
328 strLog.Format(">> %i requests stream path from physical address %04x", command.initiator, streamaddr);
329 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
6685ae07
LOK
330 CCECBusDevice *device = GetDeviceByPhysicalAddress(streamaddr);
331 if (device)
332 return device->TransmitActiveSource();
e9de9629
LOK
333 }
334 return true;
335}
336
e5e86c76
LOK
337bool CCECCommandHandler::HandleSetSystemAudioModeRequest(const cec_command &command)
338{
339 if (command.parameters.size >= 1)
340 {
341 CCECBusDevice *device = GetDevice(command.destination);
342 if (device&& device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
343 return ((CCECAudioSystem *) device)->SetSystemAudioMode(command);
344 }
345 return true;
346}
347
4d6b4433
LOK
348bool CCECCommandHandler::HandleStandby(const cec_command &command)
349{
350 CCECBusDevice *device = GetDevice(command.initiator);
351 if (device)
352 device->SetPowerStatus(CEC_POWER_STATUS_STANDBY);
353 return true;
354}
355
cf0ecd85
LOK
356bool CCECCommandHandler::HandleGiveSystemAudioModeStatus(const cec_command &command)
357{
358 CCECBusDevice *device = GetDevice(command.destination);
359 if (device && device->GetType() == CEC_DEVICE_TYPE_AUDIO_SYSTEM)
360 return ((CCECAudioSystem *) device)->TransmitSystemAudioModeStatus(command.initiator);
361
362 return false;
363}
364
e9de9629
LOK
365bool CCECCommandHandler::HandleUserControlPressed(const cec_command &command)
366{
367 if (command.parameters.size > 0)
368 {
369 m_busDevice->GetProcessor()->AddKey();
370
371 if (command.parameters[0] <= CEC_USER_CONTROL_CODE_MAX)
372 {
373 CStdString strLog;
374 strLog.Format("key pressed: %1x", command.parameters[0]);
375 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
376
377 m_busDevice->GetProcessor()->SetCurrentButton((cec_user_control_code) command.parameters[0]);
378 }
379 }
380 return true;
381}
382
383bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command)
384{
385 m_busDevice->GetProcessor()->AddKey();
386 return true;
387}
388
389void CCECCommandHandler::UnhandledCommand(const cec_command &command)
390{
b5b53c7d
LOK
391 CStdString strLog;
392 strLog.Format("unhandled command with opcode %02x from address %d", command.opcode, command.initiator);
393 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog);
0f23c85c
LOK
394}
395
8747dd4f
LOK
396unsigned int CCECCommandHandler::GetMyDevices(vector<CCECBusDevice *> &devices) const
397{
398 unsigned int iReturn(0);
399
400 cec_logical_addresses addresses = m_busDevice->GetProcessor()->GetLogicalAddresses();
401 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
402 {
403 if (addresses[iPtr])
404 {
405 devices.push_back(GetDevice((cec_logical_address) iPtr));
406 ++iReturn;
407 }
408 }
409
410 return iReturn;
411}
412
0f23c85c
LOK
413CCECBusDevice *CCECCommandHandler::GetDevice(cec_logical_address iLogicalAddress) const
414{
415 CCECBusDevice *device = NULL;
416
417 if (iLogicalAddress >= CECDEVICE_TV && iLogicalAddress <= CECDEVICE_BROADCAST)
418 device = m_busDevice->GetProcessor()->m_busDevices[iLogicalAddress];
419
420 return device;
e9de9629 421}
6685ae07
LOK
422
423CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
424{
8ac9c610 425 return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress);
6685ae07 426}
181b3475 427
181b3475
LOK
428void CCECCommandHandler::SetVendorId(const cec_command &command)
429{
430 if (command.parameters.size < 3)
431 {
432 m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
433 return;
434 }
435
bae71306
LOK
436 uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
437 ((uint64_t)command.parameters[1] << 8) +
181b3475
LOK
438 (uint64_t)command.parameters[2];
439
440 CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
441 if (device)
a7bed660 442 device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0);
181b3475 443}
5e822b09 444
62f5527d
LOK
445const char *CCECCommandHandler::ToString(const cec_logical_address address)
446{
447 switch(address)
448 {
449 case CECDEVICE_AUDIOSYSTEM:
450 return "Audio";
451 case CECDEVICE_BROADCAST:
452 return "Broadcast";
453 case CECDEVICE_FREEUSE:
454 return "Free use";
455 case CECDEVICE_PLAYBACKDEVICE1:
456 return "Playback 1";
457 case CECDEVICE_PLAYBACKDEVICE2:
458 return "Playback 2";
459 case CECDEVICE_PLAYBACKDEVICE3:
460 return "Playback 3";
461 case CECDEVICE_RECORDINGDEVICE1:
462 return "Recorder 1";
463 case CECDEVICE_RECORDINGDEVICE2:
464 return "Recorder 2";
465 case CECDEVICE_RECORDINGDEVICE3:
466 return "Recorder 3";
467 case CECDEVICE_RESERVED1:
468 return "Reserved 1";
469 case CECDEVICE_RESERVED2:
470 return "Reserved 2";
471 case CECDEVICE_TUNER1:
472 return "Tuner 1";
473 case CECDEVICE_TUNER2:
474 return "Tuner 2";
475 case CECDEVICE_TUNER3:
476 return "Tuner 3";
477 case CECDEVICE_TUNER4:
478 return "Tuner 4";
479 case CECDEVICE_TV:
480 return "TV";
481 default:
482 return "unknown";
483 }
484}
485
8ac9c610
LOK
486const char *CCECCommandHandler::ToString(const cec_deck_info status)
487{
488 switch (status)
489 {
490 case CEC_DECK_INFO_PLAY:
491 return "play";
492 case CEC_DECK_INFO_RECORD:
493 return "record";
494 case CEC_DECK_INFO_PLAY_REVERSE:
495 return "play reverse";
496 case CEC_DECK_INFO_STILL:
497 return "still";
498 case CEC_DECK_INFO_SLOW:
499 return "slow";
500 case CEC_DECK_INFO_SLOW_REVERSE:
501 return "slow reverse";
502 case CEC_DECK_INFO_FAST_FORWARD:
503 return "fast forward";
504 case CEC_DECK_INFO_FAST_REVERSE:
505 return "fast reverse";
506 case CEC_DECK_INFO_NO_MEDIA:
507 return "no media";
508 case CEC_DECK_INFO_STOP:
509 return "stop";
510 case CEC_DECK_INFO_SKIP_FORWARD_WIND:
511 return "info skip forward wind";
512 case CEC_DECK_INFO_SKIP_REVERSE_REWIND:
513 return "info skip reverse rewind";
514 case CEC_DECK_INFO_INDEX_SEARCH_FORWARD:
515 return "info index search forward";
516 case CEC_DECK_INFO_INDEX_SEARCH_REVERSE:
517 return "info index search reverse";
518 case CEC_DECK_INFO_OTHER_STATUS:
519 return "other";
520 default:
521 return "unknown";
522 }
523}
524
5e822b09
LOK
525const char *CCECCommandHandler::ToString(const cec_opcode opcode)
526{
527 switch (opcode)
528 {
529 case CEC_OPCODE_ACTIVE_SOURCE:
530 return "active source";
531 case CEC_OPCODE_IMAGE_VIEW_ON:
532 return "image view on";
533 case CEC_OPCODE_TEXT_VIEW_ON:
534 return "text view on";
535 case CEC_OPCODE_INACTIVE_SOURCE:
536 return "inactive source";
537 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
538 return "request active source";
539 case CEC_OPCODE_ROUTING_CHANGE:
540 return "routing change";
541 case CEC_OPCODE_ROUTING_INFORMATION:
542 return "routing information";
543 case CEC_OPCODE_SET_STREAM_PATH:
544 return "set stream path";
545 case CEC_OPCODE_STANDBY:
546 return "standby";
547 case CEC_OPCODE_RECORD_OFF:
548 return "record off";
549 case CEC_OPCODE_RECORD_ON:
550 return "record on";
551 case CEC_OPCODE_RECORD_STATUS:
552 return "record status";
553 case CEC_OPCODE_RECORD_TV_SCREEN:
554 return "record tv screen";
555 case CEC_OPCODE_CLEAR_ANALOGUE_TIMER:
556 return "clear analogue timer";
557 case CEC_OPCODE_CLEAR_DIGITAL_TIMER:
558 return "clear digital timer";
559 case CEC_OPCODE_CLEAR_EXTERNAL_TIMER:
560 return "clear external timer";
561 case CEC_OPCODE_SET_ANALOGUE_TIMER:
562 return "set analogue timer";
563 case CEC_OPCODE_SET_DIGITAL_TIMER:
564 return "set digital timer";
565 case CEC_OPCODE_SET_EXTERNAL_TIMER:
566 return "set external timer";
567 case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE:
568 return "set timer program title";
569 case CEC_OPCODE_TIMER_CLEARED_STATUS:
570 return "timer cleared status";
571 case CEC_OPCODE_TIMER_STATUS:
572 return "timer status";
573 case CEC_OPCODE_CEC_VERSION:
574 return "cec version";
575 case CEC_OPCODE_GET_CEC_VERSION:
576 return "get cec version";
577 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
578 return "give physical address";
579 case CEC_OPCODE_GET_MENU_LANGUAGE:
580 return "get menu language";
581 case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
582 return "report physical address";
583 case CEC_OPCODE_SET_MENU_LANGUAGE:
584 return "set menu language";
585 case CEC_OPCODE_DECK_CONTROL:
586 return "deck control";
587 case CEC_OPCODE_DECK_STATUS:
588 return "deck status";
589 case CEC_OPCODE_GIVE_DECK_STATUS:
590 return "give deck status";
591 case CEC_OPCODE_PLAY:
592 return "play";
593 case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS:
594 return "give tuner status";
595 case CEC_OPCODE_SELECT_ANALOGUE_SERVICE:
596 return "select analogue service";
597 case CEC_OPCODE_SELECT_DIGITAL_SERVICE:
598 return "set digital service";
599 case CEC_OPCODE_TUNER_DEVICE_STATUS:
600 return "tuner device status";
601 case CEC_OPCODE_TUNER_STEP_DECREMENT:
602 return "tuner step decrement";
603 case CEC_OPCODE_TUNER_STEP_INCREMENT:
604 return "tuner step increment";
605 case CEC_OPCODE_DEVICE_VENDOR_ID:
606 return "device vendor id";
607 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
608 return "give device vendor id";
609 case CEC_OPCODE_VENDOR_COMMAND:
610 return "vendor command";
611 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
612 return "vendor command with id";
613 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN:
614 return "vendor remote button down";
615 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP:
616 return "vendor remote button up";
617 case CEC_OPCODE_SET_OSD_STRING:
618 return "set osd string";
619 case CEC_OPCODE_GIVE_OSD_NAME:
620 return "give osd name";
621 case CEC_OPCODE_SET_OSD_NAME:
622 return "set osd name";
623 case CEC_OPCODE_MENU_REQUEST:
624 return "menu request";
625 case CEC_OPCODE_MENU_STATUS:
626 return "menu status";
627 case CEC_OPCODE_USER_CONTROL_PRESSED:
628 return "user control pressed";
629 case CEC_OPCODE_USER_CONTROL_RELEASE:
630 return "user control release";
631 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
632 return "give device power status";
633 case CEC_OPCODE_REPORT_POWER_STATUS:
634 return "report power status";
635 case CEC_OPCODE_FEATURE_ABORT:
636 return "feature abort";
637 case CEC_OPCODE_ABORT:
638 return "abort";
639 case CEC_OPCODE_GIVE_AUDIO_STATUS:
640 return "give audio status";
641 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
642 return "give audio mode status";
643 case CEC_OPCODE_REPORT_AUDIO_STATUS:
644 return "report audio status";
645 case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE:
646 return "set system audio mode";
647 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
648 return "system audio mode request";
649 case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
650 return "system audio mode status";
651 case CEC_OPCODE_SET_AUDIO_RATE:
652 return "set audio rate";
653 default:
654 return "UNKNOWN";
655 }
656}