cec: mark the active source as active and other devices as inactive. removed duplicat...
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
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"
34 #include "../devices/CECBusDevice.h"
35 #include "../devices/CECAudioSystem.h"
36 #include "../devices/CECPlaybackDevice.h"
37 #include "../CECProcessor.h"
38
39 using namespace CEC;
40 using namespace std;
41
42 CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice)
43 {
44 m_busDevice = busDevice;
45 }
46
47 bool CCECCommandHandler::HandleCommand(const cec_command &command)
48 {
49 bool bHandled(true);
50
51 CStdString strLog;
52 strLog.Format(">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
53 m_busDevice->AddLog(CEC_LOG_NOTICE, strLog);
54
55 if (m_busDevice->MyLogicalAddressContains(command.destination))
56 {
57 switch(command.opcode)
58 {
59 case CEC_OPCODE_REPORT_POWER_STATUS:
60 HandleReportPowerStatus(command);
61 break;
62 case CEC_OPCODE_CEC_VERSION:
63 HandleDeviceCecVersion(command);
64 break;
65 case CEC_OPCODE_SET_MENU_LANGUAGE:
66 HandleSetMenuLanguage(command);
67 /* pass to listeners */
68 m_busDevice->GetProcessor()->AddCommand(command);
69 break;
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;
103 case CEC_OPCODE_GIVE_AUDIO_STATUS:
104 HandleGiveAudioStatus(command);
105 break;
106 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
107 HandleGiveSystemAudioModeStatus(command);
108 break;
109 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
110 HandleSetSystemAudioModeRequest(command);
111 break;
112 default:
113 UnhandledCommand(command);
114 /* pass to listeners */
115 m_busDevice->GetProcessor()->AddCommand(command);
116 bHandled = false;
117 break;
118 }
119 }
120 else if (command.destination == CECDEVICE_BROADCAST)
121 {
122 CStdString strLog;
123 switch (command.opcode)
124 {
125 case CEC_OPCODE_SET_MENU_LANGUAGE:
126 HandleSetMenuLanguage(command);
127 /* pass to listeners */
128 m_busDevice->GetProcessor()->AddCommand(command);
129 break;
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;
145 case CEC_OPCODE_STANDBY:
146 HandleStandby(command);
147 /* pass to listeners */
148 m_busDevice->GetProcessor()->AddCommand(command);
149 break;
150 default:
151 UnhandledCommand(command);
152 /* pass to listeners */
153 m_busDevice->GetProcessor()->AddCommand(command);
154 bHandled = false;
155 break;
156 }
157 }
158 else
159 {
160 CStdString strLog;
161 strLog.Format("ignoring frame: we're not at destination %x", command.destination);
162 m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str());
163 bHandled = false;
164 }
165
166 return bHandled;
167 }
168
169 bool 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
181 bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
182 {
183 SetVendorId(command);
184 return true;
185 }
186
187 bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
188 {
189 SetVendorId(command);
190 return true;
191 }
192
193 bool CCECCommandHandler::HandleGetCecVersion(const cec_command &command)
194 {
195 CCECBusDevice *device = GetDevice(command.destination);
196 if (device)
197 return device->TransmitCECVersion(command.initiator);
198
199 return false;
200 }
201
202 bool 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
211 bool CCECCommandHandler::HandleGiveDeckStatus(const cec_command &command)
212 {
213 CCECBusDevice *device = GetDevice(command.destination);
214 if (device && device->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE)
215 return ((CCECPlaybackDevice *) device)->TransmitDeckStatus(command.initiator);
216
217 return false;
218 }
219
220 bool CCECCommandHandler::HandleGiveDevicePowerStatus(const cec_command &command)
221 {
222 CCECBusDevice *device = GetDevice(command.destination);
223 if (device)
224 return device->TransmitPowerState(command.initiator);
225
226 return false;
227 }
228
229 bool CCECCommandHandler::HandleGiveDeviceVendorId(const cec_command &command)
230 {
231 CCECBusDevice *device = GetDevice(command.destination);
232 if (device)
233 return device->TransmitVendorID(command.initiator);
234
235 return false;
236 }
237
238 bool CCECCommandHandler::HandleGiveOSDName(const cec_command &command)
239 {
240 CCECBusDevice *device = GetDevice(command.destination);
241 if (device)
242 return device->TransmitOSDName(command.initiator);
243
244 return false;
245 }
246
247 bool CCECCommandHandler::HandleGivePhysicalAddress(const cec_command &command)
248 {
249 CCECBusDevice *device = GetDevice(command.destination);
250 if (device)
251 return device->TransmitPhysicalAddress();
252
253 return false;
254 }
255
256 bool CCECCommandHandler::HandleMenuRequest(const cec_command &command)
257 {
258 if (command.parameters[0] == CEC_MENU_REQUEST_TYPE_QUERY)
259 {
260 CCECBusDevice *device = GetDevice(command.destination);
261 if (device)
262 return device->TransmitMenuState(command.initiator);
263 }
264 return false;
265 }
266
267 bool 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
278 bool 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());
283
284 vector<CCECBusDevice *> devices;
285 for (int iDevicePtr = (int)GetMyDevices(devices)-1; iDevicePtr >=0; iDevicePtr--)
286 devices[iDevicePtr]->TransmitActiveSource();
287 return true;
288 }
289
290 bool 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]);
296
297 CCECBusDevice *device = GetDevice(command.initiator);
298 if (device)
299 device->SetStreamPath(iNewAddress, iOldAddress);
300 }
301 return true;
302 }
303
304 bool 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;
313 for (uint8_t iPtr = 0; iPtr < 4; iPtr++)
314 language.language[iPtr] = command.parameters[iPtr];
315 language.language[3] = 0;
316 device->SetMenuLanguage(language);
317 }
318 }
319 return true;
320 }
321
322 bool 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());
330 CCECBusDevice *device = GetDeviceByPhysicalAddress(streamaddr);
331 if (device)
332 return device->TransmitActiveSource();
333 }
334 return true;
335 }
336
337 bool 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
348 bool 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
356 bool 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
365 bool 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
383 bool CCECCommandHandler::HandleUserControlRelease(const cec_command &command)
384 {
385 m_busDevice->GetProcessor()->AddKey();
386 return true;
387 }
388
389 void CCECCommandHandler::UnhandledCommand(const cec_command &command)
390 {
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);
394 }
395
396 unsigned 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
413 CCECBusDevice *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;
421 }
422
423 CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const
424 {
425 return m_busDevice->GetProcessor()->GetDeviceByPhysicalAddress(iPhysicalAddress);
426 }
427
428 void 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
436 uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
437 ((uint64_t)command.parameters[1] << 8) +
438 (uint64_t)command.parameters[2];
439
440 CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
441 if (device)
442 device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0);
443 }
444
445 const 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
486 const 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
525 const 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 }