====== Support Custom Remote Controller ====== **To support custom remote controller with LIRC, your kernel version should be 3.14.29-56 (2016/04/20) or higher.** ===== Install package ===== Install **LIRC** package. While installing **lirc**, you will be asked the device type of IR receiver and transmitter. Since we will set up this later by manual, you can select **None**. $ sudo apt-get install lirc ===== LIRC configuration ===== Now you will need to modify **/etc/lirc/hardware.conf** to specify the configuration to run as a daemon. $ sudo vi /etc/lirc/hardware.conf Specify the kernel driver module and its node to read IR signal. REMOTE_MODULES="meson-ir" REMOTE_DRIVER="default" REMOTE_DEVICE="/dev/lirc0" As well as below to make **lircd** start on boot. START_LIRCD="true" In order to apply key event to whole system, enable **Userspace Input Event** while adding **--uinput** as a parameter of **lircd**. REMOTE_LIRCD_ARGS="--uinput" All necessary configuration is done, you can simply start the service **lirc** by command line or reboot the device. $ sudo service lirc start ==== Default hardware.conf ==== # /etc/lirc/hardware.conf # #Chosen Remote Control REMOTE="None" REMOTE_MODULES="meson-ir" REMOTE_DRIVER="default" REMOTE_DEVICE="/dev/lirc0" REMOTE_SOCKET="" REMOTE_LIRCD_CONF="" REMOTE_LIRCD_ARGS="--uinput" #Chosen IR Transmitter TRANSMITTER="None" TRANSMITTER_MODULES="" TRANSMITTER_DRIVER="" TRANSMITTER_DEVICE="" TRANSMITTER_SOCKET="" TRANSMITTER_LIRCD_CONF="" TRANSMITTER_LIRCD_ARGS="" #Disable kernel support. #Typically, lirc will disable in-kernel support for ir devices in order to #handle them internally. Set to false to prevent lirc from disabling this #in-kernel support. #DISABLE_KERNEL_SUPPORT="true" #Enable lircd START_LIRCD="true" #Don't start lircmd even if there seems to be a good config file #START_LIRCMD="false" #Try to load appropriate kernel modules LOAD_MODULES="true" # Default configuration files for your hardware if any LIRCMD_CONF="" #Forcing noninteractive reconfiguration #If lirc is to be reconfigured by an external application #that doesn't have a debconf frontend available, the noninteractive #frontend can be invoked and set to parse REMOTE and TRANSMITTER #It will then populate all other variables without any user input #If you would like to configure lirc via standard methods, be sure #to leave this set to "false" FORCE_NONINTERACTIVE_RECONFIGURATION="false" START_LIRCMD="" ===== Registering own remote controller ===== Before runing irrecord, please make sure service lircd should release the node, /dev/lirc0. root@odroid64:~# sudo kill `pidof lircd` https://forum.odroid.com/viewtopic.php?f=141&t=27593 **Lirc** package provide a tool, **irrecord**, to help registering the buttons of own remote controller. Once the tool is started, for example, you will be asked to press the buttons and it will analyse the signals of your remote controller like protocol type or headers. After this analysis you can start register the buttons one by one. $ sudo irrecord --device /dev/lirc0 lircd.conf Once signal analysis is done, you will be asked with the message below to enter the button name to register and press the applicable button. In this step, you can register many buttons as much as you expect to register. If you done, just press enter key on the prompt. Please enter the name for the next button (press to finish recording) The tool would ask you more steps to finalize and store the configuration file with the below message. Successfully written config file. For example, if you have done whole steps successfully with Hardkernel's stock remote controller, your will have the configuration file like below very similiary. Now you must copy the configuration file, **lircd.conf**, to **/etc/lirc/** so that **lirc** service can recognize the button. $ sudo cp lircd.conf /etc/lirc/lircd.conf ===== Test ===== If the **Lirc** daemon is running and drivers are loaded properly, you can test if your remote controller is accepted by the tool **irw**. odroid@odroid64:~# irw 000000004db29966 00 KEY_LEFT lircd.conf 000000004db2837c 00 KEY_RIGHT lircd.conf 000000004db253ac 00 KEY_UP lircd.conf 000000004db24bb4 00 KEY_DOWN lircd.conf 000000004db2738c 00 KEY_ENTER lircd.conf You can check if the daemon is running properly. odroid@odroid64:~$ ps -ax | grep lirc 678 ? Ss 0:01 /usr/sbin/lircd --output=/run/lirc/lircd --driver=default --device=/dev/lirc0 --uinput As well as necessary drivers are loaded. odroid@odroid64:~$ lsmod Module Size Used by ir_lirc_codec 4468 3 lirc_dev 8576 1 ir_lirc_codec ir_mce_kbd_decoder 2980 0 ir_sanyo_decoder 1515 0 ir_sony_decoder 1553 0 ir_jvc_decoder 1559 0 ir_rc6_decoder 1911 0 ir_rc5_decoder 1543 0 ir_nec_decoder 1687 0 meson_ir 2927 0 ===== Default lircd configuration for ODROID-C2 ===== Here is the default button configuration for Hardkernel's stock remote controller. begin remote name lircd.conf bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9000 4500 one 563 1688 zero 563 564 ptrail 563 pre_data_bits 16 pre_data 0x4DB2 repeat 9000 2250 toggle_bit_mask 0x0 begin codes KEY_LEFT 0x9966 KEY_RIGHT 0x837C KEY_UP 0x53AC KEY_DOWN 0x4BB4 KEY_ENTER 0x738C KEY_HOME 0x41BE KEY_MUTE 0x11EE KEY_MENU 0xA35C KEY_BACK 0x59A6 KEY_VOLUMEDOWN 0x817E KEY_VOLUMEUP 0x01FE KEY_POWER 0x3BC4 end codes end remote ===== GPIO based IR ===== If you want to use your extra IR receiver by connecting to GPIO port (ex. one of expansion connectors), gpio-ir-recv module with LIRC can be used. ** IR functionality based on GPIO is supported on Ubuntu version 3.14.29-58 (2016/05/18) or higher version. ** === Hardware Example === The below picture is a sample test environment using a IR receiver module, ROM-WT138LM that is the same module built in ODROID-C2 board. ^ IR Receiver ^ C2 Expansion Net ^ Description ^ |IR|Pin#7 GPIOX.BIT21|IR output | |GND|Pin#14 GND|Ground | |3V3|Pin#17 3.3V Power| 3.3V Power| {{:en:c2_gpiobasedir_part_wiki.png?130|}} {{:en:c2_gpiobasedir_wiki.png?350|}} === hardware.conf for GPIO based IR === Before module installation, you need to specify LIRC module configuration. $ sudo vi /etc/lirc/hardware.conf The basic form of hardware.conf is described in the aforementioned 'Default hardware.conf' section of this wiki page, \\ and 'REMOTE_MODULES' must be specified as gpio-ir-recv. # REMOTE_MODULES="meson-ir" REMOTE_MODULES="gpio_ir_recv" === How to install modules and setup GPIO configuration === Let's suppose to connect IR output of your extra IR receiver module to Pin '7' of expansion connectors (J2). \\ (Expandsion net name : GPIOX.BIT21, GPIO number : 249) $ su # modprobe gpio-ir-recv # modprobe gpioplug-ir-recv gpio_nr=249 active_low=1 ('service lirc start' will be executed automatically) To confirm if the LIRC daemon is running based on gpio-ir-recv, check device nodes and protocol name of ir-keytable. # ls /dev/lirc* /dev/lirc0 /dev/lircd # ir-keytable Found /sys/class/rc/rc0/ (/dev/input/event5) with: Driver gpio-rc-recv, table rc-empty Supported protocols: lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 Enabled protocols: lirc Name: gpio_ir_recv bus: 25, vendor/product: 0001:0001, version: 0x0100 Repeat delay = 500 ms, repeat period = 125 ms === Check list in case of no available gpioirq bank for gpio-ir-recv === When the irqs of gpio-ir-recv are requested normally, you can find the information using /proc/interrupts. \\ There are 8 gpio irq banks on S905 chipset so you need to make sure two available gpio irq banks remain. \\ The irq number of gpio irq bank is from '96' to '103' and you can check if it's normally working as following. # cat /proc/interrupts | grep gpio-ir-recv 96: 191 0 0 0 GIC 96 gpio-ir-recv-irq0 97: 191 0 0 0 GIC 97 gpio-ir-recv-irq1 === lircd.conf with Hardkernel IR remote controller === If you use Hardkernel IR remote controller, no modification is needed with the aforementioned default lircd.conf file for ODROID-C2. ===== Known Issue of LIRC on ODROID-C2 ===== During booting, the operation of loading LIRC modules fails frequently, so you can see IR operation doesn't work. Under this situation, the following message comes and there is no input event from IR. # irw connect: Connection refused It seems lirc is stpped by systemd caused by an unknown reason and it causes abnormal termination of lirc process. We are trying to fix it and you can use one of the following workarounds until we've done it. === Workaround (1) === Add sleep count at the following point. **load_modules() of /etc/init.d/lirc** modprobe $mod 2> /dev/null || MODULES_MISSING=true** sleep 1 # vi /etc/init.d/lirc ..... ..... load_modules () { MODULES_MISSING=false log_daemon_msg "Loading LIRC modules" for mod in $*; do if [ $mod = "udev" ]; then log_end_msg 0 log_success_msg "Restarted via udev, don't reload modules" break else modprobe $mod 2> /dev/null || MODULES_MISSING=true sleep 1 fi done log_end_msg $? if $MODULES_MISSING; then log_failure_msg "Unable to load LIRC kernel modules. Verify your" log_failure_msg "selected kernel modules in /etc/lirc/hardware.conf" START_LIRCMD=false START_LIRCD=false fi } === Workaround (2) === Restart lirc service after booting makes LIRC normal. root@odroid64:/home/odroid# irw connect: Connection refused root@odroid64:/home/odroid# service lirc restart root@odroid64:/home/odroid# irw 000000004db2738c 00 KEY_ENTER lircd.conf 000000004db29966 01 KEY_LEFT lircd.conf 000000004db2837c 01 KEY_RIGHT lircd.conf You can add auto start daemon as following. - auto execution "service lirc restart" odroid@odroid64:~$ su root@odroid64:/home/odroid# cd /etc/init.d root@odroid64:/etc/init.d# vi restartlirc #!/bin/sh service lirc restart root@odroid64:/etc/init.d# chmod 755 restartlirc root@odroid64:/etc/init.d# cd ../rcS.d root@odroid64:/etc/rcS.d# ln -s ../init.d/restartlirc S90restartlirc root@odroid64:/etc/rcS.d# reboot