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