world leader in high performance signal processing
Trace: » lirc

LIRC - Linux Infrared Remote Control

From the LIRC homepage, LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls.

Here we'll go over the uClinux-dist integration of LIRC, the Blackfin drivers that are available, and a few quick examples. For full documentation, you should of course refer to the upstream LIRC documentation.

Blackfin Drivers

The LIRC Linux kernel drivers are not integrated into the Linux kernel. They are currently part of the lirc distribution. When you enable the LIRC tools (see below), the lirc helper driver (lirc_dev.ko) as well as the Blackfin LIRC timer (lirc_bfin_timer.ko) are automatically compiled and installed into the romfs directory.

The Blackfin LIRC driver can be found in uClinux-dist/user/lirc/lirc_bfin_timer/. It uses the Blackfin General Purpose Timer API to capture the incoming signal from an IR receiver. This means you need to enable support for the gptimer api in the Linux kernel configuration menu.

Blackfin Processor Options  --->
  <*> Enable Blackfin General Purpose Timers API

The driver needs just 1 input timer pin to work. For now, the configuration needs to be done manually in the lirc_bfin_timer.c file. Simply edit the file, locate the timer5 variable, and tweak the values to the timer you wish to use.

At runtime, simply do:

root:~> modprobe lirc_bfin_timer

This will automatically load the lirc_dev and lirc_bfin_timer drivers and create the /dev/lirc0 device node for the LIRC programs to use.

uClinux-dist Settings

In the Vendor/User settings menu, you can enable different pieces of LIRC:

Miscellaneous Applications  --->
  --- LIRC
  [*] Enable LIRC tools
  [*]   lircd
  [*]   irrecord
  [*]   lircmd
  [*]   irexec
  [*]   irw
  [*]   mode2

Generally speaking, the lircd daemon is only needed in a production system as it is used to handle multiple LIRC clients and talking with the LIRC Linux kernel drivers. The other utilities are used during development to test and validate the driver↔lircd interaction at different stages.

For information on specific programs, see the upstream LIRC program descriptions page.

LIRC Config File

Before you can run the lircd daemon, you need a configuration file. The aforementioned tools help with this generation step. If you do not have a configuration file and none of the ones included with the LIRC distribution are applicable, see the upstream configuring lircd program page.

We'll assume you have a valid file installed at the default location /etc/lircd.conf.

lircd Startup

One way of starting up lircd automatically is to simply add it to the /etc/rc file. Just add this line:

lircd &

Now the server is ready for clients to connect and send them key presses the LIRC drivers detect from remotes.

Example Client

Once the lircd server is started, we can use the irw program to detect remote presses.

root:~> irw
00000000000f2dd3 00 Play test.conf
00000000000f2dd3 01 Play test.conf
00000000000f2dd3 00 Play test.conf
00000000000f2dd3 00 Play test.conf
00000000000f2dd3 01 Play test.conf
00000000000e2def 00 Plus test.conf
00000000000e2def 01 Plus test.conf
00000000000e2dee 00 Minus test.conf
00000000000e2dee 01 Minus test.conf
00000000000e2dde 00 Previous test.conf
00000000000e2dde 01 Previous test.conf
00000000000e2dde 02 Previous test.conf
00000000000e2dde 03 Previous test.conf
00000000000f2df3 00 Power test.conf
00000000000f2df3 00 Power test.conf
00000000000f2df3 01 Power test.conf
00000000000f2df3 02 Power test.conf

More examples can obviously be found in the upstream LIRC example applications documentation.