[mythtvnz] Pulse eight hdmi cec adapter

Mark markk at kc.net.nz
Sun Jul 14 10:05:51 BST 2013


Hi all

I recently decided to buy a usb hdmi cec adapter from nicegear.co.nz
(who provided fantastic dispatch and delivery speed) and have got it
largely working under mythtv so thought I'd share what I've done.

If any others have played around with CEC under MythTv I'd be keen to
here how you got on.

>From what I read it didn't look like standard MythTv 0.26 would give
much functionality so I ended up setting up libcec along with
libcec-daemon (http://bramp.net/blog/2012/10/21/libcec-daemon/ and
https://github.com/bramp/libcec-daemon )

I've had a few problems to work around
1) One of the biggest problems is that mythtv doesn't support keycodes
greater than 255 so I had to edit main.cpp of libcec-daemon to change
mappings to work with my panasonic vierra tv remote. 
An alternative to editing the code would be to use lirc and it's
mappings but I didn't go down this track as I already have a remote
setup that will need to remain usable until the cec passthrough is
proved absolutely rock solid (to the wife's satisfaction).  With some
modifications you can get two remotes working with lirc but I didn't
want to change to many of my distros files as it's a nuisance reviewing
and merging changes after system updates, and also would have made the
wife unhappy if it broke.

An example of one set of changes to main.cpp was
{code}
/* The following commented/replaced so it will work with MythTv
uinputCecMap[CEC_USER_CONTROL_CODE_F1_BLUE                     ] =
KEY_BLUE;               uinputCecMap[CEC_USER_CONTROL_CODE_F2_RED
] = KEY_RED;               uinputCecMap[CEC_USER_CONTROL_CODE_F3_GREEN
] = KEY_GREEN;
uinputCecMap[CEC_USER_CONTROL_CODE_F4_YELLOW                   ] =
KEY_YELLOW;
*/
uinputCecMap[CEC_USER_CONTROL_CODE_F1_BLUE                     ] =
KEY_F13;
uinputCecMap[CEC_USER_CONTROL_CODE_F2_RED                      ] =
KEY_F14;
uinputCecMap[CEC_USER_CONTROL_CODE_F3_GREEN                    ] =
KEY_F15;
uinputCecMap[CEC_USER_CONTROL_CODE_F4_YELLOW                   ] =
KEY_F16;
{code}

2) I had some problems with the media TV remote button presses not being
detected as key presses (at all) on the PC, these were play/rewind/pause
etc, they magically started working at some point though.

3) There is still at least one button (the stop button) that does not
pass key presses through which is quite annoying.  I suspect with a bit
of debugging and time I'll be able to find out why this is and hopefully
fix libcec-daemon but with a toddler and young baby at home it could be
quite a while before I get onto it.

4) The cec adapter reports it has version 2 firmware but the firmware
upgrade tool for linux says it installed version 4.

5) libcec-daemon has stopped unexpectedly, I have it running in a
upstart script with respawn so this shouldn't be overly noticeable now.

Here are the scripts I've written to get it working, first being the
upstart script which I tried to get to work with autostart on usb being
plugged in but failed so simpley created a udev rule that starts the
service.
 
vi /etc/init/libcec-daemon.conf
{code}
description     "Run hdmi cec libcec-daemon"

#start on (usb-device-added and PRODUCT="USB-CEC Adapter")
#start on (usb-device-added and (ID_VENDOR_ID=2548 or ID_VENDOR=2548 or
ID_IDVENDOR=2548 or IDVENDOR=2548)

stop on runlevel [!2345]

# if you want it to automatically restart if it crashes, leave the next
line in
respawn

script
    /home/markk/sandbox/libcec-daemon/libcec-daemon -q -a
end script

{code}


Create a udev rule so that libcec-daemon always creates a consistent
device name (
vi /etc/udev/rules.d/66-libcec-daemon.rules
{code}
KERNEL=="event*", ATTRS{name}=="libcec-daemon", SYMLINK
+="input/libcec-daemon"
{code}

vi /etc/udev/rules.d/65-usb-cec-add.rules
{code}
SUBSYSTEM=="usb", ACTION=="add", ATTR{product}=="USB-CEC Adapter", RUN
+="/home/markk/sandbox/start-libcec-daemon.sh"
{code}

vi /home/markk/sandbox/start-libcec-daemon.sh
#!/bin/bash
start libcec-daemon
{code}

chmod +x /home/markk/sandbox/start-libcec-daemon.sh



Mark





More information about the mythtvnz mailing list