sunxi-3.4 ("legacy" kernel)
The sunxi-3.4 IR is exposed as a a keyboard on the Linux input device interface. For example, the following simple keybinder application might be used to run arbitrary commands when receiving a specific keycode via IR. You can install it by
$ git clone https://github.com/elopez/keybinder.git $ cd keybinder $ sudo make install
Configuration is handled on /etc/keybinder.conf, as a "keycode,command" pair per line. The application prints every keycode received, so you may as well use it to figure out the keycodes you want to use.
To execute the application, run
$ sudo keybinder /dev/input/event0
mainline kernel (4.x) and sunxi-cir
For devices that feature a standard (38 kHz) CIR receiver, the mainline kernel can be configured with
CONFIG_IR_SUNXI. The kernel option is located under "Device drivers", "Multimedia support", "Remote Controller devices", "SUNXI IR remote control"; the driver is named sunxi-cir.
If you compiled the driver as a module, the first step is to make sure that module gets loaded - either by adding it to the autoloaded modules (depends on your distribution), or manually:
Once the driver is initialized, your kernel log (
dmesg) should show something similar to
[ 110.032464] Registered IR keymap rc-empty [ 110.033667] input: sunxi-ir as [email protected]/1c21800.ir/rc/rc0/input1 [ 110.033729] rc0: sunxi-ir as [email protected]/1c21800.ir/rc/rc0 [ 110.066201] IR NEC protocol handler initialized [ 110.083973] IR RC5(x/sz) protocol handler initialized [ 110.101950] IR Sony protocol handler initialized [ 110.103835] IR JVC protocol handler initialized [ 110.107900] IR RC6 protocol handler initialized [ 110.114389] IR SANYO protocol handler initialized [ 110.116697] IR MCE Keyboard/mouse protocol handler initialized [ 110.119481] input: MCE IR Keyboard/Mouse (sunxi-ir) as /devices/virtual/input/input2 [ 110.119720] sunxi-ir 1c21800.ir: initialized sunXi IR driver [ 110.120865] IR Sharp protocol handler initialized [ 110.130851] IR XMP protocol handler initialized
Check that the sunxi IR shows up in
cat /proc/bus/input/devices :
I: Bus=0019 Vendor=0001 Product=0001 Version=0100 N: Name="sunxi-ir" P: Phys=sunxi-ir/input0 S: [email protected]/1c21800.ir/rc/rc0/input1 U: Uniq= H: Handlers=kbd event1 B: PROP=0 B: EV=100013 B: KEY=1000000 0 0 0 0 B: MSC=10 I: Bus=0000 Vendor=0000 Product=0000 Version=0000 N: Name="MCE IR Keyboard/Mouse (sunxi-ir)" P: Phys=/input0 S: Sysfs=/devices/virtual/input/input2 U: Uniq= H: Handlers=kbd event2 B: PROP=0 B: EV=100017 B: KEY=30000 0 7 ff87207a c14057ff febeffdf ffefffff ffffffff fffffffe B: REL=3 B: MSC=10
- Note: Make sure those "H: Handlers=" lines list the event nodes associated with the devices. In case they are missing, there's a chance your kernel may be misconfigured - check that CONFIG_INPUT_EVDEV=y is set!
The device should also be available in /sys/class/rc/, usually as rc0:
~ # cat /sys/class/rc/rc0/protocols other [unknown] rc-5 nec rc-6 jvc sony rc-5-sz sanyo sharp mce_kbd [lirc] xmp
The above command lists the available IR protocols. At this point it may be necessary to select a specific protocol that corresponds to the remote you intend to use. You do so by writing to the sysfs node. For example, I have a universal remote control that works with the "nec" protocol - so to configure it, I use:
echo nec > /sys/class/rc/rc0/protocols
When you're set, run the
evtest program to check if everything works. Either start it without arguments to get prompted, or pass the input (event) node that corresponds to the Name="sunxi-ir" device. In the above example, that would be
If all goes well, evtest will now report events for key presses that you do on your infrared remote.