-
Notifications
You must be signed in to change notification settings - Fork 9
/
cec.cpp
647 lines (543 loc) · 19.2 KB
/
cec.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
/**
* Copyright © 2012 Ola Jeppsson
*
* Subject to the conditions below, you may, without charge:
*
* · Use, copy, modify and/or merge copies of this software and
* associated documentation files (the "Software")
*
* · Publish, distribute, sub-licence and/or sell new software
* derived from or incorporating the Software.
*
*
* This file, unmodified, shall be included with all copies or
* substantial portions
* of the Software that are distributed in source code form.
*
* Any person dealing with the Software shall not misrepresent
* the source of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
* KIND.
*/
extern "C" {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#include <unistd.h>
#include <interface/vmcs_host/vc_cecservice.h>
#include <interface/vchiq_arm/vchiq_if.h>
#include <interface/vmcs_host/vc_tvservice.h>
}
#include "config.h"
#include "xbmcclient.h"
#include "cecxbmckeymap.h"
#ifndef VC_TRUE
#define VC_TRUE 1
#endif
#ifndef VC_FALSE
#define VC_FALSE 0
#endif
#ifndef VC_CEC_VENDOR_ID_NODEVICE
#define VC_CEC_VENDOR_ID_NODEVICE 0xffffff
#endif
#ifndef VC_CEC_VENDOR_ID_UNKNOWN
#define VC_CEC_VENDOR_ID_UNKNOWN 0
#endif
#define CEC_VENDOR_ID_LG 0xe091
#define SL_COMMAND_UNKNOWN_01 0x01
#define SL_COMMAND_UNKNOWN_02 0x02
#define SL_COMMAND_REQUEST_POWER_STATUS 0xa0
#define SL_COMMAND_POWER_ON 0x03
#define SL_COMMAND_CONNECT_REQUEST 0x04
#define SL_COMMAND_SET_DEVICE_MODE 0x05
#define CEC_VENDOR_BUTTON_SAMSUNG_BACK 0x91
#define XBMC_KEY_ASCII 0xF100
class CECXBMCClient : public CXBMCClient
{
public:
void SendButton(const char* Button,
unsigned short Flags=(BTN_USE_NAME|BTN_NO_REPEAT))
{
// Simplest approach seems to be to emulate an XBOX R1 Remote.
// The ideal solution imo is to send 'raw' CEC events
// ie. "CEC_User_Control_Select" ... and then let XBMC
// decide what to do.
static char DeviceMap[] = "R1";
CXBMCClient::SendButton(Button, DeviceMap, Flags);
}
void ping()
{
CXBMCClient::SendButton(XBMC_KEY_ASCII, BTN_NO_REPEAT);
}
};
struct CECMessage {
CECMessage(uint32_t param0, uint32_t param1, uint32_t param2,
uint32_t param3, uint32_t param4)
{
reason = (VC_CEC_NOTIFY_T) CEC_CB_REASON(param0);
retval = CEC_CB_RC(param0);
VC_CEC_MESSAGE_T tmp;
int res;
res = vc_cec_param2message(param0, param1, param2, param3, param4, &tmp);
if (res || tmp.length > CEC_MAX_XMIT_LENGTH) {
length = 0;
initiator = CEC_AllDevices_eUnRegistered;
follower = CEC_AllDevices_eUnRegistered;
memset(&payload[0], 0, sizeof(payload));
} else {
length = tmp.length;
initiator = tmp.initiator;
follower = tmp.follower;
memcpy(&payload[0], &tmp.payload[0], sizeof(payload));
}
}
VC_CEC_NOTIFY_T reason;
uint8_t retval;
uint32_t length;
CEC_AllDevices_T initiator;
CEC_AllDevices_T follower;
uint8_t payload[CEC_MAX_XMIT_LENGTH+1];
CEC_OPCODE_T opcode() const { return (CEC_OPCODE_T) payload[0]; }
uint8_t operand1() const { return payload[1]; }
uint8_t operand2() const { return payload[2]; }
};
CECXBMCClient xbmc;
volatile uint32_t tvVendorId = VC_CEC_VENDOR_ID_UNKNOWN;
volatile uint32_t myVendorId = CEC_VENDOR_ID_BROADCOM;
volatile CEC_POWER_STATUS_T myPowerState = CEC_POWER_STATUS_ON_PENDING;
volatile uint16_t physicalAddress;
//Needed by HandleComboKeys
volatile uint8_t prevcode = 0xFF;
volatile uint8_t curcode = 0xFF;
volatile uint8_t AlarmFunctionSet = 0xFF;
//Local functions
void vc_cec_report_power_status(uint8_t dest, CEC_POWER_STATUS_T status);
void vc_cec_report_physicalAddress(uint8_t dest);
void debug(const char* s, const CECMessage& msg);
void LgCecInit();
void HandleComboKeys(int sig)
{
//LG HACK to send back key
if(CEC_User_Control_Stop == prevcode && CEC_User_Control_Select == curcode)
{
// We will use combination of STOP and select key to simulate back operation
printf("UserControlPressed: combo key detected sending back\n");
prevcode=0xff;
curcode=0xff;
xbmc.SendButton("back");
AlarmFunctionSet=0xff;
return;
}
else if(CEC_User_Control_Stop == prevcode && CEC_User_Control_Pause == curcode)
{
// We will use combination of STOP and pause key to simulate home operation
printf("UserControlPressed: combo key detected sending home\n");
prevcode=0xff;
curcode=0xff;
xbmc.SendButton("menu");
AlarmFunctionSet=0xff;
return;
}
else
{
prevcode=0xff;
curcode=0xff;
xbmc.SendButton("stop");
AlarmFunctionSet=0xff;
}
}
void UserControlPressed(const CECMessage& msg)
{
uint8_t keycode = msg.operand1();
const char *xbmcKey = NULL;
for (unsigned int i=0; i < CECXBMCKeymapElements; ++i) {
if (CECXBMCKeymap[i].cec == keycode) {
xbmcKey = CECXBMCKeymap[i].xbmc;
break;
}
}
if (xbmcKey != NULL) {
if (tvVendorId == CEC_VENDOR_ID_LG) {
//LG Hack to support back and menu keys
prevcode= curcode;
curcode = keycode;
if(CEC_User_Control_Stop == curcode)
{
//set alarm handler and raise a alarm after a delay
signal(SIGALRM, HandleComboKeys);
AlarmFunctionSet = 0x1;
alarm(1);
}
else if(AlarmFunctionSet != 1) // End LG Hack
xbmc.SendButton(xbmcKey);
} else {
xbmc.SendButton(xbmcKey);
}
} else {
printf("UserControlPressed: keycode=0x%x has no binding\n", keycode);
}
}
void MenuRequest(const CECMessage& msg)
{
if (msg.operand1() == CEC_MENU_STATE_QUERY) {
vc_cec_send_MenuStatus(msg.initiator, CEC_MENU_STATE_ACTIVATED,
VC_TRUE);
} else {
printf("MenuRequest: operand1=0x%x unknown\n", msg.operand1());
// TODO: send FeatureAbort?
}
}
void Play(const CECMessage& msg) {
switch (msg.operand1()) {
case CEC_PLAY_FORWARD: xbmc.SendButton("play"); break;
case CEC_PLAY_STILL: xbmc.SendButton("pause"); break;
default:
printf("Play: operand1=0x%x not implemented\n", msg.operand1());
}
}
void DeckControl(const CECMessage& msg) {
if (msg.operand1() == CEC_DECK_CTRL_STOP) {
xbmc.SendButton("stop");
} else {
printf("DeckControl: operand1=0x%x not implemented\n", msg.operand1());
}
}
void VendorCommand_LG(const CECMessage& msg)
{
uint8_t response[8];
switch (msg.operand1()) {
case SL_COMMAND_UNKNOWN_01:
printf("VendorCommand_LG: SL_COMMAND_UNKNOWN_01 received\n");
// Send 0205
response[0] = CEC_Opcode_VendorCommand;
response[1] = 0x02;
response[2] = 0x01;
vc_cec_send_message(msg.initiator, response, 3, VC_TRUE);
printf("VendorCommand_LG: Sent 0205\n");
break;
case SL_COMMAND_CONNECT_REQUEST:
printf("VendorCommand_LG:SL_COMMAND_CONNECT_REQUEST\n");
// Set device mode
response[0] = CEC_Opcode_VendorCommand;
response[1] = SL_COMMAND_SET_DEVICE_MODE;
response[2] = CEC_DeviceType_Rec ;
vc_cec_send_message(msg.initiator, response, 3, VC_TRUE);
// Opcode 04 : ImageViewOn
response[0] = CEC_Opcode_ImageViewOn ;
vc_cec_send_message(CEC_TV_ADDRESS, response, 1, VC_FALSE);
// Active source
response[0] =CEC_Opcode_ActiveSource ;
response[1] = (uint8_t) ((physicalAddress) >> 8 & 0xff);
response[2] = (uint8_t) ((physicalAddress) >> 0 & 0xff);
vc_cec_send_message(CEC_BROADCAST_ADDR, response, 3, VC_FALSE);
vc_cec_set_osd_name("XBMC");
break;
case SL_COMMAND_POWER_ON:
printf("VendorCommand_LG: TODO HandleVendorCommandPowerOn(command)\n");
break;
case SL_COMMAND_REQUEST_POWER_STATUS:
printf("VendorCommand_LG: TODO HandleVendorCommandPowerOnStatus(command) \n");
break;
default:
printf("VendorCommand_LG: unhandled command operand1=0x%x\n", msg.operand1());
}
}
void VendorCommand(const CECMessage& msg)
{
if (myVendorId == CEC_VENDOR_ID_LG) {
VendorCommand_LG(msg);
} else {
printf("VendorCommand: unhandled vendor command operand1=0x%x "
"for vendor=0x%x\n", msg.operand1(), tvVendorId);
}
}
void VendorRemoteButtonDown(const CECMessage& msg)
{
char str[64];
snprintf(str, 63, "VendorRemoteButtonDown(vendor=0x%x, operand1=0x%x):",
tvVendorId, msg.operand1());
debug(str, msg);
// Temporary fix
if (msg.operand1() == CEC_VENDOR_BUTTON_SAMSUNG_BACK) {
xbmc.SendButton("back");
}
}
void GiveDeviceVendorID(const CECMessage& msg) {
uint8_t response[4];
response[0] = CEC_Opcode_DeviceVendorID;
response[1] = (uint8_t) ((myVendorId >> 16) & 0xff);
response[2] = (uint8_t) ((myVendorId >> 8) & 0xff);
response[3] = (uint8_t) ((myVendorId >> 0) & 0xff);
vc_cec_send_message(msg.initiator, response, 4, VC_TRUE);
}
void GiveDevicePowerStatus(const CECMessage& msg)
{
printf("cec_callback: received power status query \n");
// Send CEC_Opcode_ReportPowerStatus
uint8_t response[2];
response[0] = CEC_Opcode_ReportPowerStatus;
response[1] = myPowerState;
vc_cec_send_message(msg.initiator, response, 2, VC_TRUE);
printf("cec_callback: sent powerstatus on\n");
}
void SetStreamPath(const CECMessage& msg)
{
debug("SetStreamPath:", msg);
uint16_t requestedAddress;
requestedAddress = (msg.payload[1] << 8) + msg.payload[2];
printf("requestedAddress: 0x%x\n", requestedAddress);
if (requestedAddress != physicalAddress) {
printf("Requested Address does not match Physical Address, ignoring message\n");
return;
}
vc_cec_send_ActiveSource(physicalAddress, VC_FALSE);
// According to the spec. this shouldn't be necessary
vc_cec_send_MenuStatus(msg.initiator, CEC_MENU_STATE_ACTIVATED,
VC_TRUE);
xbmc.ping();
}
void VendorCommandWithID(const CECMessage& msg)
{
debug("VendorCommandWithID:", msg);
}
void DeviceVendorID(const CECMessage& msg) {
debug("DeviceVendorID:", msg);
uint32_t vendor = (msg.payload[1] << 16) + (msg.payload[2] << 8) + (msg.payload[3] << 0);
if (msg.initiator != CEC_AllDevices_eTV) {
return;
}
// Only run initialization once
if (vendor == tvVendorId) {
return;
}
tvVendorId = vendor;
printf("TV Vendor: 0x%06x\n", tvVendorId);
if (tvVendorId == CEC_VENDOR_ID_LG) {
//Do LG specific intialization
LgCecInit();
// only use this for temporary debugging
vc_cec_register_all();
} else {
myVendorId = CEC_VENDOR_ID_BROADCOM;
vc_cec_set_vendor_id(myVendorId);
}
myPowerState = CEC_POWER_STATUS_ON;
vc_cec_report_power_status(CEC_TV_ADDRESS, myPowerState);
vc_cec_set_osd_name("XBMC");
}
void debug(const char *s, const CECMessage& msg)
{
#ifdef DEBUG
static char standard[] = "CEC Message:";
if (s == NULL) {
s = &standard[0];
}
printf("%s reason=0x%04x, length=0x%02x, retval=0x%02x, initiator=0x%x, "
"follower=0x%x, opcode=0x%02x, operand1=0x%02x, operand2=0x%02x",
s, msg.reason, msg.length, msg.retval, msg.initiator,
msg.follower, msg.opcode(), msg.operand1(), msg.operand2());
printf(" payload=[(%x%x)", msg.initiator, msg.follower);
for (unsigned int i=0; i < msg.length; ++i) {
printf(":%02x", msg.payload[i]);
}
printf("]\n");
#endif
}
void vc_cec_send_deck_status(uint8_t dest, uint8_t status)
{
uint8_t msg[4];
msg[0] = CEC_Opcode_DeckStatus;
msg[1] = status;
vc_cec_send_message( dest, msg, 2, VC_TRUE);
}
void vc_cec_report_physicalAddress(uint8_t dest)
{
uint8_t msg[4];
msg[0] = CEC_Opcode_ReportPhysicalAddress;
msg[1] = (uint8_t) ((physicalAddress) >> 8 & 0xff);
msg[2] = (uint8_t) ((physicalAddress) >> 0 & 0xff);
if (myVendorId == CEC_VENDOR_ID_LG) {
msg[3] = CEC_DeviceType_Rec;
}
else {
msg[3] = CEC_DeviceType_Tuner;
}
vc_cec_send_message(dest, msg, 4, VC_TRUE);
}
void vc_cec_report_power_status(uint8_t dest, CEC_POWER_STATUS_T status)
{
uint8_t msg[4];
msg[0] = CEC_Opcode_ReportPowerStatus;
msg[1] = status;
vc_cec_send_message( dest, msg, 2, VC_FALSE);
}
void LgCecInit()
{
uint8_t msg[4];
vc_cec_report_power_status(CEC_TV_ADDRESS,CEC_POWER_STATUS_ON_PENDING);
printf("Setting Vendor Id to LG\n");
myVendorId = CEC_VENDOR_ID_LG;
vc_cec_set_vendor_id(myVendorId);
msg[0] = CEC_Opcode_DeviceVendorID;
msg[1] = (uint8_t) ((myVendorId) >> 16 & 0xff);
msg[2] = (uint8_t) ((myVendorId) >> 8 & 0xff);
msg[3] = (uint8_t) ((myVendorId) >> 0 & 0xff);
vc_cec_send_message(CEC_BROADCAST_ADDR, msg, 4, VC_FALSE);
// Report Physical Address
msg[0] = CEC_Opcode_ReportPhysicalAddress;
msg[1] = (uint8_t) ((physicalAddress) >> 8 & 0xff);
msg[2] = (uint8_t) ((physicalAddress) >> 0 & 0xff);
msg[3] = CEC_DeviceType_Rec;
vc_cec_send_message(CEC_BROADCAST_ADDR, msg, 4, VC_FALSE);
vc_cec_report_power_status(CEC_TV_ADDRESS,CEC_POWER_STATUS_ON);
// Opcode 04 : ImageViewOn
msg[0] = CEC_Opcode_ImageViewOn ;
vc_cec_send_message(CEC_TV_ADDRESS, msg, 1, VC_FALSE);
// Active source
msg[0] =CEC_Opcode_ActiveSource ;
msg[1] = (uint8_t) ((physicalAddress) >> 8 & 0xff);
msg[2] = (uint8_t) ((physicalAddress) >> 0 & 0xff);
vc_cec_send_message(CEC_BROADCAST_ADDR, msg, 3, VC_FALSE);
}
void cec_callback(void *callback_data, uint32_t param0,
uint32_t param1, uint32_t param2,
uint32_t param3, uint32_t param4)
{
CECMessage msg(param0, param1, param2, param3, param4);
if (msg.reason == VC_CEC_TX) {
if (msg.retval) {
debug("cec_callback: failed transmission:", msg);
}
return;
}
debug("cec_callback: debug:", msg);
switch (msg.opcode()) {
case CEC_Opcode_UserControlPressed: UserControlPressed(msg); break;
case CEC_Opcode_UserControlReleased: /* NOP */ break;
case CEC_Opcode_MenuRequest: MenuRequest(msg); break;
case CEC_Opcode_Play: Play(msg); break;
case CEC_Opcode_DeckControl: DeckControl(msg); break;
case CEC_Opcode_VendorRemoteButtonDown: VendorRemoteButtonDown(msg); break;
case CEC_Opcode_GiveDeviceVendorID: GiveDeviceVendorID(msg); break;
case CEC_Opcode_GiveDevicePowerStatus: GiveDevicePowerStatus(msg); break;
case CEC_Opcode_SetStreamPath: SetStreamPath(msg); break;
case CEC_Opcode_VendorCommandWithID: VendorCommandWithID(msg); break;
case CEC_Opcode_GivePhysicalAddress: vc_cec_report_physicalAddress(msg.initiator); break;
case CEC_Opcode_VendorCommand: VendorCommand(msg); break;
case CEC_Opcode_DeviceVendorID: DeviceVendorID(msg); break;
case CEC_Opcode_GiveDeckStatus:
//Status code is invalid as per CEC standard but seems to be required for LG
if (tvVendorId == CEC_VENDOR_ID_LG) {
vc_cec_send_deck_status(CEC_TV_ADDRESS,0x20);
} else {
vc_cec_send_deck_status(CEC_TV_ADDRESS,CEC_DECK_INFO_PLAY);
}
break;
default:
debug("cec_callback: unknown event:", msg);
}
}
int main(int argc, char **argv)
{
int res = 0;
VCHI_INSTANCE_T vchiq_instance;
VCHI_CONNECTION_T *vchi_connection;
CEC_AllDevices_T logical_address;
/* Make sure logs are written to disk */
setlinebuf(stdout);
setlinebuf(stderr);
printf(
"rpi-cecd starting\n"
"Use http://www.cec-o-matic.com to debug the payload. Remove the\n"
"parantheses surrounding the first byte. (it's the header)\n"
);
// Do not call bcm_host_init() or vcos_init()
// Otherwise we'll stop receiving CEC data
res = vchi_initialise(&vchiq_instance);
if ( res != VCHIQ_SUCCESS ) {
printf("failed to open vchiq instance\n");
return -1;
}
res = vchi_connect( NULL, 0, vchiq_instance );
if ( res != 0 ) {
printf( "VCHI connection failed\n" );
return -1;
}
res = vc_vchi_tv_init(vchiq_instance, &vchi_connection, 1);
if ( res != 0 ) {
printf( "TV init failed\n");
return -1;
}
TV_GET_STATE_RESP_T tvstate;
res = vc_tv_get_state(&tvstate);
if (res != 0) {
printf("Could not get TV state\n");
return -1;
}
printf("TV tvstate.state: 0x%x\n", tvstate.state);
if (!(tvstate.state & (VC_HDMI_STANDBY | VC_HDMI_DVI | VC_HDMI_HDMI))) {
printf("No HDMI.\n");
return -1;
}
// vc_vchi_cec_init sets vchi_connection to NULL. Thats fine
vc_vchi_cec_init(vchiq_instance, &vchi_connection, 1);
physicalAddress = CEC_CLEAR_ADDR;
while (physicalAddress == CEC_CLEAR_ADDR) {
res = vc_cec_get_physical_address((uint16_t*)&physicalAddress);
if (res != 0) {
printf("failed to get physical address");
return -1;
}
if (physicalAddress != CEC_CLEAR_ADDR) {
break;
}
printf("CEC is currently disabled. Will retry in 60 seconds. "
"Make sure the TV is on and connected to the RPi\n");
sleep(60);
}
printf("Physical Address: 0x%x\n", physicalAddress);
sleep(1);
logical_address = CEC_AllDevices_eUnRegistered;
while (logical_address == CEC_AllDevices_eUnRegistered) {
vc_cec_get_logical_address(&logical_address);
if (logical_address != CEC_AllDevices_eUnRegistered) {
break;
}
printf("No logical address. Will retry in 60s"
"Make sure the TV is on and connected to the RPi\n");
vc_cec_alloc_logical_address();
sleep(60);
}
printf("Logical Address: 0x%x\n", logical_address);
#if 0
// only use this for temporary debugging
vc_cec_register_all();
#endif
vc_cec_register_callback(((CECSERVICE_CALLBACK_T) cec_callback), NULL);
vc_cec_register_command(CEC_Opcode_MenuRequest);
vc_cec_register_command(CEC_Opcode_Play);
vc_cec_register_command(CEC_Opcode_DeckControl);
vc_cec_register_command(CEC_Opcode_GiveDeviceVendorID);
vc_cec_register_command(CEC_Opcode_VendorCommand);
vc_cec_register_command(CEC_Opcode_GiveDevicePowerStatus);
vc_cec_register_command(CEC_Opcode_VendorRemoteButtonDown);
vc_cec_register_command(CEC_Opcode_SetStreamPath);
vc_cec_register_command(CEC_Opcode_VendorCommandWithID);
vc_cec_register_command(CEC_Opcode_DeviceVendorID);
while (1) {
if (tvVendorId == VC_CEC_VENDOR_ID_UNKNOWN ||
tvVendorId == VC_CEC_VENDOR_ID_NODEVICE) {
uint8_t payload[1];
payload[0] = CEC_Opcode_GiveDeviceVendorID;
vc_cec_send_message(CEC_AllDevices_eTV, payload, 1, VC_FALSE);
} else {
xbmc.SendHELO("rpi-cecd", ICON_NONE);
}
sleep(10);
}
vc_vchi_cec_stop();
return 0;
}