- 1 Introduction
- 2 Install
- 3 Configuration
- 4 Modules
- 5 Recording the IR-codes
- 6 Testing the receiver
- 7 Configuring ~/.lircrc and irexec
- 8 Setserial
- 9 Using Multiple Devices Simultaneously
- 10 Hardware specific instructions
- 11 Enabling software support
- 12 Tips
- 13 Troubleshooting
- 13.1 Module does not load
- 13.2 Prevent the kernel module from configuring the port
- 13.3 Use setserial to de-configure the port
- 13.4 Use modules configuration to load the LIRC module first
- 13.5 Load serial support as a kernel module
- 13.6 Disable serial support in the kernel
- 13.7 Device /dev/lirc/0 isn't being created
- 13.8 LIRC will not compile
- 13.9 Emerge gives you access violations
- 13.10 udev-rules
- 14 See Also
LIRC stands for Linux Infrared Remote Control. It allows you to receive and send infrared signals. With LIRC and an IR receiver you can control your computer with almost any infrared remote control (e.g. a TV remote control). You may for instance control DVD or music playback with your remote control.
|Linux Kernel Configuration: Linux Kernel Configuration: Kernel 2.6|
Loadable module support ---> [*] Module unloading Device Drivers ---> Input device support ---> [*] Event interface
InstallYou need to set an environmental variable prior to compiling LIRC in order to install the appropriate drivers for your tv capture card. That means you will need to determine which of the following drivers is suitable for your card. For a list of all supported devices, run:
Unfortunately, it is not necessarily straightforward which driver to use in all cases, as neither the LIRC project website nor the installed documentation seem to provide this information. In most cases, however, the product name should be one of the drivers. You should decide what type of receiver you are using. If not, only support for the homebrew serial receiver will be compiled.
Homebrew receiver drivers:
That is a lot of options. For those of you with a homebrew serial receiver, your option will be "serial". If you received a remote with your video card or TV tuner, you will need to choose the most appropriate driver from the list above. You can get some idea of whether your hardware is supported or not by checking the sidebar of the official LIRC website. For using the tvcard integrated controllers like Hauppauge, do not forget to compile your kernel with i2c support.
Once you have selected your driver, you need to set the LIRC_DEVICES environmental variable, or simply edit /etc/make.conf as follows:
If you have a serial IR device, set:
If your device is supported by the kernel, (uses /dev/input/eventX) you will need to use the dev/input driver instead. This works particually well for these devices:
- X10/Medion/ATI remote controls (needs ati_remote kernel module)
- Hauppage NOVA-T
Or, if you don't mind the extra compile time, you can just tell it to compile all of them and let the kernel autoloader figure out which one to use:
Now you are ready to (re-)compile LIRC:
It is useful to set the global USE flag lirc so that all applications are built with LIRC-support. Then recompile all applications whose USE flags have changed:.
Older versions of LIRC apply their sources to the kernel sources. By default configuration, it is not possible for an ebuild to overwrite kernel source files. In case that you are using such an ebuild, you can fix the issue with the following command:.
If the driver you selected is only available in kernel space, LIRC will compile it on installation. All LIRC kernel drivers require lirc_dev. You do not have to load it manually. It is sufficient to only load the LIRC kernel driver module since it has lirc_dev as dependency. If you do not know the exact name, go to /lib/modules/$(uname -r)/misc/.
Depending on your mix of kernel and LIRC versions, you can run into incompatibility issues. Especially the warning "Unknown symbol class_simple_device_add" indicates that you might have to switch versions. Try to get a more recent LIRC ebuild:
If that does not help, upgrade your kernel and recompile LIRC.
LIRC needs to know how to interpret the output from your remote. Codes from the remote are mapped to buttons in /etc/lircd.conf. There are two means of obtaining a lircd.conf file suited to your remote. For many (probably most) remotes you can simply copy the configuration file from the LIRC project website. However, if a prepared lircd.conf file is not available from the LIRC site, you will need to use the irrecord utility that is installed with lirc to capture the signals generated by your remote for each button.
If you want to use your remote control using an input device, add the module name to /etc/modules.autoload.d/kernel-2.6 (e.g. ati_remote) and skip this section.
Before starting LIRC, it is important load the necessary kernel modules.Be sure you have unloaded all kernel modules that allows you to access the signals of your IR device in /dev/input. Use the LIRC modules instead. If you have a ATI/Medion/X10 remote control, you probably have the kernel drivers already loaded. Unload them with:
You may need to use an appropriate kernel module for your hardware to work properly. If so, you will have to add "lirc_driver" to your /etc/modules.autoload.d/kernel-2.6 file so the module can load during boot. Substitute "driver" in "lirc_driver" to the actual driver you are using, which was defined in the LIRC_DEVICES variable in your make.conf above. To enable serial support for instance, you would add "lirc_serial".
The appropriate modules will now be autoloaded when booting, but you should also activate them now:
Recording the IR-codes
You need to have a configuration file for your remote control that tells LIRC how to interpret the IR codes transmitted by your remote. If the key codes were already correct, you can move on with the next section. The easiest way to configure the IR codes is to use an existing config file, try finding your remote in this listing. If your remote is not listed you can try using irrecord to create the file. Or, if you are using a universal remote you can just program it to control for example a Sony TV set and then try any of the files listed under Sony. When you have found a config file save it to /etc/lircd.conf.
You can try to use a pre-configured IR-codes file. They are stored in /usr/share/lirc/remotes and copy the setup you want to try out over to /etc/lircd.conf.
If you do not have any success with this, you can create your own file. Use this command:
This might not work for you if you only compiled LIRC with devinput support. In this case you first have to find out the path for your remote control. It is best to write a command that find it out dynamically because it is very likely that these paths change. For X10, try this:
Now execute it like this instead:
If this will not work for you, try out if your command detected the path correctly by pressing some buttons on your remote control after running:
This should produce output as the buttons are pressed.
Then type in the names for each button (e.g. VOL_DOWN, CHAN_UP, MUTE, etc.). You need them later when running irexec.
If you are done, replace your /etc/lircd.conf with your just-created configuration file:
Testing the receiver
Now it is time to check your configuration.
Stop any running lircd
Ensure that the daemon is not running before starting a new one.
For devinput start lircd, as follows:
Otherwise, just run:
If it does not work, try to set the correct path to your device ():
Please make sure that you use with the correct device above, otherwise you may experience "Connect: Connection refused" errors when trying to access the LIRC device. For example /dev/lirc0 rather than /dev/lirc/0.
If lircd did not print any error messages, you can run either of these 2 methods to test your setup:
If everything is correct this will connect to the lirc device and echo the buttons you have pressed. Press all buttons to check whether all events are triggered properly. It should print your out the codes you set in your lircd.conf.
Verify that you have a new device node:Check that the LIRC device has been created at /dev/lircd. Test that you are actually receiving data from your remote by running: while pressing buttons on the remote. This essentially accomplishes the same thing as method 1. You should see data being received by the device each time you push a button.
Then edit /etc/conf.d/lircd with these parameters. For devices using the input-layer it might look like:
Restart lircd in normal mode
Now start up LIRC and add it to the default runlevel so it starts on the system's start:
Configuring ~/.lircrc and irexec
~/.lircrc is the config file used by programs with native LIRC support (mplayer, xine-ui, ... with USE="lirc") and by irexec for the other applications (tvtime, xmms, ...) to execute commands in response to data captured from the remote. It is your personal button configuration file which maps buttons to commands.
With programs with native LIRC support and without this file, you will generally get only a few working buttons, and that when they can do a lot more. As example, with MPlayer, you can get a list that contains commands that you can use with LIRC:
You can use all the command from this list with LIRC. You just have to add them into ~/.lircrc. It is not necessary to run irexec for applications with native LIRC support.
For the other programs, no button will work and you will have to use irexec.
Before it can do that, however, you will need to create ~/.lircrc and fill it with application specific commands for each button on the remote. Now setup your ~/.lircrc file and you should be able to use LIRC with every applications that supports it. If so, congratulations! Your receiver is working, and you can now start adding support for you remote control. The file follows this format:
There is sufficient document concerning the specifics of this file at the LIRC project site.
Some developers have gone through the trouble for you and put together the necessary information for their applications. For example, the tvtime website has a ~/.lircrc file available.
If it generates an error "connection error: Could not connect to the socket" this generally means that one of the LIRC drivers (lirc_dev lirc_gpio or lircd_modulename) isn't loaded properly, or that you permission problems with the lirc device node. First ensure that /etc/init.d/lircd is loaded without errors. Note that this service tends to not stop well, and may need to be zapped then started again. Then ensure that /dev/lirc0 exists and is receiving data as explained above.
Once you have irexec working, you will want to have it start up with each log in. Be sure to use this command to have irexec fork into the background:
If you are using the serial driver and run into problems on module load, sys-apps/setserial will probably help you.
Enable the serial port
Add setserial to the default runlevel
For setserial to load the module it will need to be added to your startup scripts. First, you need to add a line to /etc/serial.conf:
Now you can set it to run at boot:.
Alternate startup method
|Fix me: Move these instructions to instructions below, merge with hardware specific drivers and Troubleshooting.|
Update: You can simply edit /etc/modprobe.d/lirc and add the following line to lirc-enable the port(s) before loading the lirc_serial module:
You can also set options for the lirc_serial module there like this:
Using Multiple Devices Simultaneously
The only hardware to natively support multiple blasters on Linux is the CommandIR Mini multi-transceiver. Many other LIRC devices will have both an IR blaster and receiver unified into one - but LIRC may not support this feature (ala lirc_mceusb2). The solution is to get a simple serial IR blaster but this can be difficult to set up via LIRC.In order to accomplish this, you must make sure that you have compiled support for both devices. Currently the LIRC_DEVICES environment variable only supports doing one device - to work around this change edit your /etc/make.conf: After this, make sure you add both lirc_* modules into /etc/modules.autoload.d/kernel-2.6. Additionally, make sure you are used the transmitter USE flag when you emerged lirc.
The second step is to run two concurrent processes of LIRC for both devices and have them interact with each other. This can be tricky so I have taken the liberty of posting my own /etc/init.d/lircd:
Essentially what this does is it creates two instances of lircd, one running at /dev/lircd/0 and the other at /dev/lircd/1. Edit the --device=/dev/lirc* line to suit whatever devices you have in your system in whatever order. Since my transmitter is /dev/lirc/1 and my reciever is /dev/lirc/0, /dev/lircd corresponds to my reciever and /dev/lircd1 corresponds to transmitter. This is optimal as some applications may have problems dealing with a non /dev/lircd LIRC device.
Both instances should start when you run:Test them out, one by running: and the other with:
Hardware specific instructions
- ATI All-in-Wonder and X10 Remote Controls (atiusb)
- ATI Remote Wonder II
- Creative Sound Blaster Audigy 4 (with USB Receiver)
- Creative Labs Sound Blaster Audigy 2 Platinum
- Pinnacle PCTV
- DViCO FusionHDTV DVB-T
CommandIR Mini - USB Multi-Transceiver
CommandIR can control up to four devices independently using emitters and contains a built-in universal receiver to integrate all inbound and outbound IR control into a single Linux-native device. Installation instructions for Gentoo can be found in the manufacturers support site.
ALSA audioFirst read about the hardware and the LIRC driver for ALSA. Now you have to tell LIRC what audio device to capture. In order to do it you simply edit the /etc/conf.d/lircd file. Virtually everyone wants to have:
Note: For the lirc_mceusb2 module you need to have the /etc/conf.d/lircd file this this order! Note 2: -> also notice that i am using /dev/lirc/0 not dev/lirc0 -> the latter did not work for me but the former did.
Homebrew Serial Receiver (serial)
Serial receiver is smooth sailing, the only tricky thing to know is that kernel support for the serial port will conflict the driver. The way to fix this is to emerge the setserial utility, and then add "setserial /dev/ttyS0 uart none" (ttyS0 is COM1, ttyS1 is COM2, etc.) to /etc/conf.d/local.start. You will then have to add "modprobe lirc_serial" into /etc/conf.d/local.start afterwards because the script is executed after modules.autoload.d.
Alternatively you may try to add "/dev/ttyS0 uart none" to /etc/serial.conf (after emerging setserial) and run serial at boot "rc-update add serial boot". And have lirc_serial module loaded by adding it to /etc/modules.autoload.d/kernel-2.6 (don't forget to run update-modules afterwards).
If you are using receiver wired in "Igor" way, i.e. like the following one - made for "Girder" with "Igor" plugin, make sure to add type=4 option while loading lirc_serial kernel module:
The whole module loading command may then look like this:
Alternatively you can emerge lirc with serial_igor_cesko module, then putting type=4 in modprobe call is unnecessary.
Enabling software support
Start by adding the lirc USE flag to make.conf. You can then re-emerge your installed packages with remote control support. This will work with:
Some packages have LIRC support by default, without the lirc USE flag:
For multiple remotes you can always concatenate them to one lircd.conf file:
Note that the names for each remote configuration must be different:
.lircrc configurations for programs including MythTV, Xine, Mplayer, VLC and more can be configured for any remote control and any hardware can be found here.
Module does not load
If the kernel modules does not load, there could be a few reasons. If the serial driver in the kernel is being loaded before the LIRC driver, LIRC will fail and complain that the port is already in use.
|Code: dmesg output|
lirc_dev: IR Remote Control driver registered, at major 61 lirc_serial: port 03f8 already in use lirc_serial: use 'setserial /dev/ttySX uart none' lirc_serial: or compile the serial port driver as module and lirc_serial: make sure this module is loaded first
If this happens you have a couple of options.
Prevent the kernel module from configuring the portThe ideal solution is to run: This will append the statement "/dev/ttySX uart none" into /etc/serial.conf. After that you have to enable serial init-script via rc-update add serial default. /etc/init.d/serial will disable the uart for the specified ttySX. Now modprobe lirc_serial should work fine during bootup!
Use setserial to de-configure the port
You can follow the instructions and run the setserial /dev/ttySX uart none command, making sure you have already run emerge setserial. You may need to set this up to run at boot so that it can always take effect.
Use modules configuration to load the LIRC module first
If the above does not work as it didn't for me, you could configure the module loading by the following: Modify /etc/modprobe.d/lirc and uncomment the lines that match your serial port, this will enable the lirc_serial module to be loaded before the kernel modules if built or disable the serial port. No init-script for serial is then required.
Load serial support as a kernel module
Still another option is to compile serial support for your kernel as a module, and the Gentoo boot scripts will take care of things for you during boot, but not necessarilly once the system is already up and running. The following may be useful if the /etc/serial.conf update for preventing the kernel from configuring the port doesn't solve the problem.
Tell the serial module that the lirc_driver module (replace lirc_driver with your particular driver, e.g. lirc_sir) is a dependency so that the lirc_driver module captures the I/O port first. Once the lirc_driver is loaded and attached to the port, the regular serial driver takes whatever is left over.
For example, my serial ports use the 8250 module, so the following works:Now when I modprobe 8250, the lirc_sir module and all dependencies are loaded first, then everything necessary for the remaining serial ports to function.
Disable serial support in the kernel
Another other option is to disable serial port support in the kernel altogether, as the LIRC driver will take care of things for you. Obviously this will be an impractical solution if you have any other serial devices, but if you don't have any, this will also work.
Device /dev/lirc/0 isn't being created
If LIRC seems to compile, and modprobeing the lirc_<driver> works without errors but you aren't seeing a /dev/lirc/0 being created it is likely because udev is unable to complete the creation of the device. If running:
returns an error about udev being unable to read/write from the database becuase there is no such file or directory, re-emerging udev may fix the problem:
After the emerge, udev should re-start and /dev/lirc/0 should now show up.
LIRC will not compile
The following flags may become important if LIRC does not work straight as described in the basic configuration.
- --with-port=port (port number for the lirc device.)
- --with-irq=irq (irq line for the lirc device.)
- --with-timer=value (timer value for the parallel driver)
- --with-tty=file (tty to use (Irman, RemoteMaster, etc.))
- --without-soft-carrier (if your serial hw generates carrier)
- --with-transmitter (if you use a transmitter diode)
If any of these options apply to you, you will have to add them with the appropriate values to your LIRC_OPTS variable in /etc/make.conf.
Emerge gives you access violations
There is a bug in gcc that causes problems with sandbox. if the emerge returns you an error of access violation for /usr/src/linux-..../null.gcda Try emerging with the following command:
As of the date of this edit (November 11, 2005) there is a minor problem with the default gentoo install of lirc. Emerging LIRC will install a set of udev rules to /etc/udev/rules.d/10-lirc.rules that create the device node /dev/lirc/0. However the file /etc/conf.d/lircd starts the lirc daemon with an option that is not compatible with that udev rule. Accordingly, you may need to edit that files as follows:
As of the date of this edit (October 28, 2009) the ebuild won't install udev specific rules if there is no module to load (as far as i know for "lirc_devices_asusdh") so here is what i did. First, get the info from the command line udevadm:
Where "X" is your device number, see dmesg. What you need to get is:
Now, add this rules:
Finnaly, edit the file /etc/conf.d/lircd as follows: