cec: moved TransmitDeckStatus() to CCECPlaybackDevice
[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{
425 CCECBusDevice *device = NULL;
426
427 for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
428 {
429 if (m_busDevice->GetProcessor()->m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress)
430 {
431 device = m_busDevice->GetProcessor()->m_busDevices[iPtr];
432 break;
433 }
434 }
435
436 return device;
437}
181b3475 438
181b3475
LOK
439void CCECCommandHandler::SetVendorId(const cec_command &command)
440{
441 if (command.parameters.size < 3)
442 {
443 m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
444 return;
445 }
446
bae71306
LOK
447 uint64_t iVendorId = ((uint64_t)command.parameters[0] << 16) +
448 ((uint64_t)command.parameters[1] << 8) +
181b3475
LOK
449 (uint64_t)command.parameters[2];
450
451 CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
452 if (device)
a7bed660 453 device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0);
181b3475 454}
5e822b09 455
62f5527d
LOK
456const char *CCECCommandHandler::ToString(const cec_logical_address address)
457{
458 switch(address)
459 {
460 case CECDEVICE_AUDIOSYSTEM:
461 return "Audio";
462 case CECDEVICE_BROADCAST:
463 return "Broadcast";
464 case CECDEVICE_FREEUSE:
465 return "Free use";
466 case CECDEVICE_PLAYBACKDEVICE1:
467 return "Playback 1";
468 case CECDEVICE_PLAYBACKDEVICE2:
469 return "Playback 2";
470 case CECDEVICE_PLAYBACKDEVICE3:
471 return "Playback 3";
472 case CECDEVICE_RECORDINGDEVICE1:
473 return "Recorder 1";
474 case CECDEVICE_RECORDINGDEVICE2:
475 return "Recorder 2";
476 case CECDEVICE_RECORDINGDEVICE3:
477 return "Recorder 3";
478 case CECDEVICE_RESERVED1:
479 return "Reserved 1";
480 case CECDEVICE_RESERVED2:
481 return "Reserved 2";
482 case CECDEVICE_TUNER1:
483 return "Tuner 1";
484 case CECDEVICE_TUNER2:
485 return "Tuner 2";
486 case CECDEVICE_TUNER3:
487 return "Tuner 3";
488 case CECDEVICE_TUNER4:
489 return "Tuner 4";
490 case CECDEVICE_TV:
491 return "TV";
492 default:
493 return "unknown";
494 }
495}
496
5e822b09
LOK
497const char *CCECCommandHandler::ToString(const cec_opcode opcode)
498{
499 switch (opcode)
500 {
501 case CEC_OPCODE_ACTIVE_SOURCE:
502 return "active source";
503 case CEC_OPCODE_IMAGE_VIEW_ON:
504 return "image view on";
505 case CEC_OPCODE_TEXT_VIEW_ON:
506 return "text view on";
507 case CEC_OPCODE_INACTIVE_SOURCE:
508 return "inactive source";
509 case CEC_OPCODE_REQUEST_ACTIVE_SOURCE:
510 return "request active source";
511 case CEC_OPCODE_ROUTING_CHANGE:
512 return "routing change";
513 case CEC_OPCODE_ROUTING_INFORMATION:
514 return "routing information";
515 case CEC_OPCODE_SET_STREAM_PATH:
516 return "set stream path";
517 case CEC_OPCODE_STANDBY:
518 return "standby";
519 case CEC_OPCODE_RECORD_OFF:
520 return "record off";
521 case CEC_OPCODE_RECORD_ON:
522 return "record on";
523 case CEC_OPCODE_RECORD_STATUS:
524 return "record status";
525 case CEC_OPCODE_RECORD_TV_SCREEN:
526 return "record tv screen";
527 case CEC_OPCODE_CLEAR_ANALOGUE_TIMER:
528 return "clear analogue timer";
529 case CEC_OPCODE_CLEAR_DIGITAL_TIMER:
530 return "clear digital timer";
531 case CEC_OPCODE_CLEAR_EXTERNAL_TIMER:
532 return "clear external timer";
533 case CEC_OPCODE_SET_ANALOGUE_TIMER:
534 return "set analogue timer";
535 case CEC_OPCODE_SET_DIGITAL_TIMER:
536 return "set digital timer";
537 case CEC_OPCODE_SET_EXTERNAL_TIMER:
538 return "set external timer";
539 case CEC_OPCODE_SET_TIMER_PROGRAM_TITLE:
540 return "set timer program title";
541 case CEC_OPCODE_TIMER_CLEARED_STATUS:
542 return "timer cleared status";
543 case CEC_OPCODE_TIMER_STATUS:
544 return "timer status";
545 case CEC_OPCODE_CEC_VERSION:
546 return "cec version";
547 case CEC_OPCODE_GET_CEC_VERSION:
548 return "get cec version";
549 case CEC_OPCODE_GIVE_PHYSICAL_ADDRESS:
550 return "give physical address";
551 case CEC_OPCODE_GET_MENU_LANGUAGE:
552 return "get menu language";
553 case CEC_OPCODE_REPORT_PHYSICAL_ADDRESS:
554 return "report physical address";
555 case CEC_OPCODE_SET_MENU_LANGUAGE:
556 return "set menu language";
557 case CEC_OPCODE_DECK_CONTROL:
558 return "deck control";
559 case CEC_OPCODE_DECK_STATUS:
560 return "deck status";
561 case CEC_OPCODE_GIVE_DECK_STATUS:
562 return "give deck status";
563 case CEC_OPCODE_PLAY:
564 return "play";
565 case CEC_OPCODE_GIVE_TUNER_DEVICE_STATUS:
566 return "give tuner status";
567 case CEC_OPCODE_SELECT_ANALOGUE_SERVICE:
568 return "select analogue service";
569 case CEC_OPCODE_SELECT_DIGITAL_SERVICE:
570 return "set digital service";
571 case CEC_OPCODE_TUNER_DEVICE_STATUS:
572 return "tuner device status";
573 case CEC_OPCODE_TUNER_STEP_DECREMENT:
574 return "tuner step decrement";
575 case CEC_OPCODE_TUNER_STEP_INCREMENT:
576 return "tuner step increment";
577 case CEC_OPCODE_DEVICE_VENDOR_ID:
578 return "device vendor id";
579 case CEC_OPCODE_GIVE_DEVICE_VENDOR_ID:
580 return "give device vendor id";
581 case CEC_OPCODE_VENDOR_COMMAND:
582 return "vendor command";
583 case CEC_OPCODE_VENDOR_COMMAND_WITH_ID:
584 return "vendor command with id";
585 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN:
586 return "vendor remote button down";
587 case CEC_OPCODE_VENDOR_REMOTE_BUTTON_UP:
588 return "vendor remote button up";
589 case CEC_OPCODE_SET_OSD_STRING:
590 return "set osd string";
591 case CEC_OPCODE_GIVE_OSD_NAME:
592 return "give osd name";
593 case CEC_OPCODE_SET_OSD_NAME:
594 return "set osd name";
595 case CEC_OPCODE_MENU_REQUEST:
596 return "menu request";
597 case CEC_OPCODE_MENU_STATUS:
598 return "menu status";
599 case CEC_OPCODE_USER_CONTROL_PRESSED:
600 return "user control pressed";
601 case CEC_OPCODE_USER_CONTROL_RELEASE:
602 return "user control release";
603 case CEC_OPCODE_GIVE_DEVICE_POWER_STATUS:
604 return "give device power status";
605 case CEC_OPCODE_REPORT_POWER_STATUS:
606 return "report power status";
607 case CEC_OPCODE_FEATURE_ABORT:
608 return "feature abort";
609 case CEC_OPCODE_ABORT:
610 return "abort";
611 case CEC_OPCODE_GIVE_AUDIO_STATUS:
612 return "give audio status";
613 case CEC_OPCODE_GIVE_SYSTEM_AUDIO_MODE_STATUS:
614 return "give audio mode status";
615 case CEC_OPCODE_REPORT_AUDIO_STATUS:
616 return "report audio status";
617 case CEC_OPCODE_SET_SYSTEM_AUDIO_MODE:
618 return "set system audio mode";
619 case CEC_OPCODE_SYSTEM_AUDIO_MODE_REQUEST:
620 return "system audio mode request";
621 case CEC_OPCODE_SYSTEM_AUDIO_MODE_STATUS:
622 return "system audio mode status";
623 case CEC_OPCODE_SET_AUDIO_RATE:
624 return "set audio rate";
625 default:
626 return "UNKNOWN";
627 }
628}