From Fedora Project Wiki

Better LIRC support

Summary

LIRC is used in many media applications to provide support for Infra-red remote controls. This feature makes it easy to connect to remote controls and have them just work in many applications.

LIRC itself

LIRC does not use the Linux input layer available in the kernel. Instead, an LIRC daemon accesses the hardware directly (sometimes through a serial port, sometimes through a kernel module with a proprietary protocol), and acts as a broker to the applications.

Applications, instead of getting key events through X11 (which is fed by the Linux input layer), listen for events fed by the LIRC daemon, using an LIRC specific library. The main problems are:

  • The user must set up the receiver and remote correctly in LIRC (not all receivers are shipped with a remote, and it's possible to use a number of different remotes with a single receiver). gnome-lirc-properties solves that problem allowing the user to set up receiver and remote
  • The user must assign remote keys to events that the applications will understand. LIRC event are strings such as "|<<" for rewind. LIRC has a number of de-facto events existing, but some more uncommon remotes will have buttons for which no events have been agreed upon. gnome-lirc-properties allows users to modify which event is assigned to which button, but doesn't mention whether specific applications support the event (other than Elisa, for which the program was created in the first place).
  • Applications then need to be set up with a configuration file that will transform the LIRC events (such as "|<<") into strings that the program can parse itself.

Owner

  • Name: BastienNocera

Current status

  • Targeted release: Fedora 10
  • Last updated: 26 August 2008
  • Percentage of completion: 100%

LIRC is used in many media applications to provide support for Infra-red remote controls. Any Windows Media Center supported remote should work fine in lirc itself. The complete list of supported devices is too long to list. LIRC has a list sorted by hardware vendor.

LIRC, before gnome-lirc-properties, was very hard to configure, and it was tricky to configure the applications to use it.

All the required lirc patches are in lirc upstream and in rawhide. Upstream work on gnome-lirc-properties is finished, and gnome-lirc-properties was accepted in Fedora.

Keycodes specified in the remotes definitions are now based on the standard definitions, which means they should work out-of-the-box with a majority of applications.

Detailed Description

Currently setting up LIRC remote controls requires a lot of editing, by hand, with little or no hand-holding. It should be possible to use an infra-red remote control without needing to use a terminal, or edit text files by hand.

Benefit to Fedora

Fedora becomes easier to use in media-center scenarios where a remote control may come handy.

Scope

Will require changes to lirc, as well as inclusion of gnome-lirc-properties. We also need to modify some applications to be setup out of the box.

Test Plan

0. Update / install gnome-lirc-properties and lirc: yum update gnome-lirc-properties lirc

1. Check that (if necessary) kernel modules are automatically loaded for the receiver. Typically, drivers for all usb-based receivers should be automatically loaded. Serial-based receivers and receivers built into devices such as tv capture cards likely require some manual configuration to get properly loaded. If your driver auto-loaded, you should typically see two lirc kernel modules loaded:

$ lsmod | grep lirc
lirc_streamzap         22020  0 
lirc_dev               21208  1 lirc_streamzap

This is not necessary for devices that use the input layer, or devices that have a userspace driver (such as the CommandIR unit). You can check whether your device is an input device by looking in the output of lshal and then plugging in the device. For example:

$ lshal --monitor --long
[snip]
Start monitoring devicelist:
-------------------------------------------------
[snip]
*** 00:12:55.484: lshal: device_added, udi='/org/freedesktop/Hal/devices/usb_device_6cd_420_noserial_if1_logicaldev_input'
 info.addons.singleton = {'hald-addon-input'} (string list)
 info.capabilities = {'input', 'input.keys', 'input.mouse', 'button'} (string list)
 info.category = 'input'  (string)
 info.parent = '/org/freedesktop/Hal/devices/usb_device_6cd_420_noserial_if1'  (string)
 info.product = 'Keyspan  RF Remote for Front Row'  (string)
[snip]
 linux.device_file = '/dev/input/event7'  (string)
[snip]

Many television capture cards, such as the Hauppauge WinTV PVR-250 and similar, have an IR port direction on the back panel of the card, and provide an IR receiver dongle. These ports are supported by the lirc_i2c driver, and while they do typically require manual loading of the module, they tend to Just Work without any fuss beyond that.

In the case of serial-based receivers, you'll have to manually load most likely either the lirc_serial driver or the lirc_sir driver. The lirc_serial driver is for home-brew type receivers, as detailed on the lirc web site here. Some commercially available serial receivers also use this driver. Receivers that use the lirc_sir driver are IrDA-based devices capable of operating in Serial IR mode. These include many laptops' onboard IrDA port and IrDA dongles from Tekram and Actisys. Getting the I/O port and IRQ right for these devices is often the trickiest part of configuring them.

With any of the receivers that require loading an lirc_* module, dmesg typically contains valuable information as to success or failure of the driver to attach to your hardware, so be sure to grep through your dmesg output after attempting a driver load. Most drivers can also be loaded with a 'debug=1' parameter on the modprobe line to increase their verbosity, should you run into issues.

2. If your device is already seen as an input, you can skip this step. Launch gnome-lirc-properties (System -> Preferences -> Hardware -> Infrared Remote Control). Click on the big "Auto-detect" button. If no devices are discovered, then your device isn't supported out of the box. You will need to file a new bug for gnome-lirc-properties in the upstream bugzilla.

gnome-lirc-properties uses a separate file from LIRC for remotes definition (/usr/share/gnome-lirc-properties/receivers.conf). You can usually take the actual data from /usr/share/lirc/lirc.hwdb and re-arrange it according to the syntax explained at the top of the file. So for example, a bug report to add support for the Igor Cesko's USB IR Receiver would read (note that this is custom hardware, and the data is completely bogus):

In /usr/share/lirc/lirc.hwdb, the Igor Cesko's USB IR Receiver remote is defined as:
Igor Cesko's USB IR Receiver;igorplugusb;lirc_dev lirc_igorplugusb;hw_default;igor/usbirreceiver.conf;
This means the following lines should be added to /usr/share/gnome-lirc-properties/receivers.conf:
[Igor Cesko: USB IR Receiver]
kernel-module = lirc_igorplugusb
compatible-remotes = Igor_IR_Receiver
lirc-driver   = igorplugusb
vendor-id     = 0x0000
product-id    = 0x0000
I do not have the vendor-id and product-id available, but this is the output of lsusb that shows the device:
[insert lsusb output]
The compatible-remotes value is taken from the name line of the /usr/share/lirc-remotes/igor/usbirreceiver.conf file.

3. If your remote control is an input device, file a new bug upstream, and include the output of lshal --monitor --long mentioned above. This will require modifications to /usr/share/hal/fdi/policy/10osvendor/20-x11-remotes.fdi.

4. Once all that is double-checked, click on keys on your remote, the keys should appear at the bottom of the gnome-lirc-properties window. If any key appear with "(Custom key code)" at the end, please file a bug under lirc in the Fedora bugzilla, and mention which keys show up with that value, as well as attaching the contents of /etc/lircd.conf.gnome to your bug.

User Experience

After launching the "Infrared Remote Control" preferences in the menus, clicking "Auto-detect" should be enough to get the remote working. See for screenshots.

Applications should have a default configuration which makes them work with a large number of remote controls without any further configuration changes. This is achieved by:

  • Making applications load a default application installed lirc configuration using lirc_readconfig()
  • Making applications not fail if they can't load the user and system configurations (when passing NULL as the first argument of lirc_readconfig(), it will try to read ~/.lircrc and /etc/lirrc)
  • The application installed lirc configuration must use keys listed in this document
  • Remote definitions need to use those definitions as well (see bugzilla)

See this example of how it was done for Totem (and as well), or for Rhythmbox.

Dependencies

Contingency Plan

This feature does not affect any other parts of the system, so no contingency plans are required.

Documentation

Release Notes

gnome-lirc-properties is a new graphical frontend to LIRC that makes it easy to connect and configure Infra-Red remote controls. Multimedia applications such as rhythmbox and totem can be remotely controlled in this way. To access the graphical frontend, use the "Infrared Remote Control" item in the menus.

If you had a previous setup with lirc, it is recommended you regenerate the configuration files with gnome-lirc-properties, so that a majority of applications work with your new setup.

Comments and Discussion

See Talk:Features/BetterLIRCSupport