LIRC

Many media players and set-top boxes based on A1x SoCs features a built-in standard IrDA infra-red receiver for 38KHz based IR controllers that has LIRC software support which is compatible with most know media center remotes made for computers and media players.

LIRC (Linux Infrared Remote Control) supports this integrated infra-red receiver, and it acts as a middleware between the hardware and the software applications that supports LIRC, which most media player and media center applications does.

What is LIRC?
LIRC (Linux Infrared Remote Control) is an open source (GPL) package that allows users to receive and send infrared signals with a Linux-based computer system and applications.

With LIRC and an IR receiver the user can control their computer with almost any infrared remote control (e.g. a TV remote control). The user may for instance control video or music playback software with their remote control.

One GUI frontend is KDELirc, built on the KDE libraries.

Using LIRC with Mele A2000
To get Mele's IR-Receiver work you have to make lirc listening at /dev/input/event, because the IR-receiver emulates keyboard input. The following steps are necessary to get Mele's IR work with the supplied remote: input: sun4i-ir as /devices/virtual/input/input4 IR Initial OK REMOTE_DRIVER="devinput" REMOTE_DEVICE="/dev/input/event4" START_LIRCD="true"
 * Install lirc
 * Be sure to have sun4i-ir.ko compiled and do a "modprobe sun4i_ir". This should result in something like:
 * cat /proc/bus/input/devices may give you the right event
 * Edit /etc/lirc/hardware.conf:
 * Copy a suitable lircd.conf to /etc/lirc/lircd.conf
 * Start lirc, and test input with irw
 * Further steps to be done ...

Mele A1000/A2000 IR-receiver udev rule
To use always the same name instead of looking for event create udev rule (/etc/udev/rules.d/10-meleir.rules): SUBSYSTEM=="input", ACTION=="add", KERNEL=="event*", ATTRS{name}=="sun4i-ir", SYMLINK+="input/meleir" REMOTE_DEVICE="/dev/input/meleir" # rmmod sun4i_ir # /etc/init.d/udev restart # /etc/init.d/lirc restart # modprobe sun4i_ir
 * Edit /etc/lirc/hardware.conf:
 * reboot or

drwxr-xr-x 2 root root    60 Jan 11 13:44 by-path crw-r- 1 root root 13, 64 Jan 11 13:44 event0 crw-r- 1 root root 13, 65 Jan 11 15:19 event1 lrwxrwxrwx 1 root root     6 Jan 11 15:19 meleir -> event1 crw-r- 1 root root 13, 63 Jan 11 13:44 mice
 * ls -l /dev/input

irrecord to record remote control key
irrecord should do the job by recording your remote keys. http://linux.die.net/man/1/irrecord

For example, to teach LIRC about a Syabas Popcorn Hour A-100 Remote Control. Note that lircd can not be running;

Don't stop pressing buttons until two lines of dots (2x80) have been generated. Press RETURN now to start recording. ................................................................................ Found const length: 107344 Please keep on pressing buttons like described above. ................................................................................ Space/pulse encoded remote control found. Signal length is 67. Found possible header: 8977 4440 Found trail pulse: 591 Found repeat code: 8977 2201 Signals are space encoded. Signal length is 32 Now enter the names for the buttons. Please enter the name for the next button (press  to finish recording) KEY_PLAY Now hold down button "KEY_PLAY". [continue for all buttons]
 * 1) /etc/init.d/lirc stop     # or pkill lircd
 * 2) irrecord -d /dev/lirc0 a100.conf

Using existing remote definitions
A large repository of known remote controls are available at http://lirc.sourceforge.net/remotes/

In this example case we will pick Syabas A-100 Remote Control (which is used with Syabas Popcorn Hour series of media player and other Networked Media Tank clones).

REMOTE="None" REMOTE_MODULES="" REMOTE_DRIVER="" REMOTE_DEVICE="/dev/lirc0" REMOTE_SOCKET="/dev/lircd" REMOTE_LIRCD_CONF="" REMOTE_LIRCD_ARGS="" START_LIRCD="true"
 * 1) cd /etc/lirc/
 * 2) wget http://lirc.sourceforge.net/remotes/syabas/A-100
 * 3) cp A-100 lircd.conf
 * 4) vi hardware.conf

* Starting remote control daemon(s) : LIRC ...done.
 * 1) /etc/init.d/lirc start     # Or reboot

If you run something like; # tail -f /var/log/daemon.log &

You can see the messages from lircd. Test that your remote now works with:

# irw /dev/lircd Nov 1 02:48:26 a1x lircd-0.8.6[814]: accepted new client on /dev/lircd 0000000020d30af5 00 KEY_PLAY Syabas_A-100 0000000020d30af5 01 KEY_PLAY Syabas_A-100

Now when you start xbmc the remote control should work. You can check that it works by viewing the xbmc.log log file:

Nov 1 02:44:26 a1x lircd-0.8.6[814]: accepted new client on /dev/lircd 02:44:46 T:1100938672  DEBUG: LIRC: Update - NEW at 20549:0000000020d350af 00 KEY_DOWN Syabas_A-100 (KEY_DOWN) 02:44:46 T:1100938672  DEBUG: SDLKeyboard: scancode: 74, sym: 0112, unicode: 0000, modifier: 0 02:44:46 T:1100938672  DEBUG: OnKey: down (f081) pressed, action is Down
 * 1) tail -f /home/a1x/.xbmc/temp/xbmc.log

We still need to tell xbmc to use the remote inputs, the best way to do that is to copy the default, and modify as needed:


 * 1) cd /home/a1x/.xbmc/userdata
 * 2) cp /usr/local/share/xbmc/system/Lircmap.xml.
 * 3) vi Lircmap.xml

Change the remote name to that of what is in the lircd.conf you download/setup, (it is also printed in the xbmc.log output). Restart xbmc.

InfraRed Remote Controls tested with standard IrDA recievers for 38KHz based IR controllers
This only lists infra-red remote controls that are compatible with standard IrDA infra-red receiver for 38KHz based IR controllers.
 * 1) Syabas Popcorn Hour A-100 Remote Control works with LIRC 0.9.0 and Linux Kernel 2.6.32 on Ubuntu 10.04 or later.
 * 2) Example #1 (works with LIRC 0.9.0 and Linux Kernel 2.6.32 on Ubuntu 10.04)
 * 3) Example #2 (works with LIRC 0.9.0 and Linux Kernel 3.0 on Ubuntu 11.10)
 * 4) Example #?

Troubleshooting
Some of the remote configuration files on sourceforge are seriously out of date. If lircd seems to be starting up, but none of the tools is getting any events, try running lircd manually:

lircd-0.9.0[17422]: lircd(devinput) ready, using /dev/lircd
 * 1) /etc/init.d/lirc stop
 * 2) /usr/sbin/lircd -n --output=/dev/lircd --driver=devinput --device=/dev/input/event1 

Now from another window, run irw:


 * 1) irw /dev/lircd

You should see something like this from lircd:

lircd-0.9.0[17422]: accepted new client on /dev/lircd lircd-0.9.0[17422]: initializing '/dev/input/event1'

and when you press a button on the remote:

lircd-0.9.0[17422]: you are using an obsolete devinput config file: Success lircd-0.9.0[17422]: get the new version at http://lirc.sourceforge.net/remotes/devinput/lircd.conf.devinput: Success

You'll have to get this new devinput file from sourceforge and use irrecord to create your own remote configuration file. Note that you can't just use an empty config file; irrecord appears to need some global values from the config file's header in order to capture the remote's signals.

The configuration files generated by irrecord also seem to have extra garbage at the end of the key codes. For example, this was generated from a Sound-Fly Bluetooth remote:

KEY_UP                  0x01001200000001 0x000000BED7A9ED KEY_DOWN                0x01001100000001 0x000000BED7A9ED

The third field confused lircd, causing it to ignore these keys; removing the 0x000000BED7A9ED from each line fixed it. Not sure if these values are necessary under special conditions (they had to be removed from the .conf files of 5 different remotes to get them to work), though, so you should first try lircd with them and then remove them if it doesn't seem to be working.