Remote controllers-V4L

From LinuxTVWiki
Revision as of 13:59, 6 May 2005 by Kraxel (Talk | contribs)

Jump to: navigation, search


Several remote controllers are now supported in the mainline Linux kernel.

Others are still only supported by the lirc project.

Winfast and Hauppauge remotes supported in kernel

Kernel version remote control support for Leadtek Winfast remote controls, shipped with both bttv and cx88 cards, and for Hauppauge Remote Control (the newer, gray remotes; seems there are multiple slightly different versions), shipped with cx88 and ivtv cards, was added in 2.6.12:

Infrared remote control support in video4linux drivers

Documentation/video4linux/ (from 2.6.12-rc2)


Current versions use the linux input layer to support infrared remote controls. I suggest to download my input layer tools from<date>.tar.gz

Modules you have to load:

 saa7134       statically built in, i.e. just the driver :)
 bttv          ir-kbd-gpio or ir-kbd-i2c depending on your card.

ir-kbd-gpio and ir-kbd-i2c don't support all the cards that lirc supports (yet), mainly for the reason that the code of lirc_i2c and lirc_gpio was very confusing and I decided to basically start over from scratch. Feel free to contact me in case of trouble. Note that the ir-kbd-* modules work on 2.6.x kernels only through ...

How it works

The modules register the remote as keyboard within the linux input layer, i.e. you'll see the keys of the remote as normal key strokes (if CONFIG_INPUT_KEYBOARD is enabled).

Using the event devices (CONFIG_INPUT_EVDEV) it is possible for applications to access the remote via /dev/input/event<n> devices. You might have to create the special files using "/sbin/MAKEDEV input". The input layer tools mentioned above use the event device.

The input layer tools are nice for trouble shooting, i.e. to check whenever the input device is really present, which of the devices it is, check whenever pressing keys on the remote actually generates events and the like. You can also use the kbd utility to change the keymaps (2.6.x kernels only through).

Using with lircd

lircd versions newer than 0.7.0 support reading events from the linux input layer (via event device). The input layer tools tarball comes with a lircd config file.

Using without lircd

XFree86 likely can be configured to recognise the remote keys. Once I simply tried to configure one of the multimedia keyboards as input device, which had the effect that XFree86 recognised some of the keys of my remote control and passed volume up/down key presses as XF86AudioRaiseVolume and XF86AudioLowerVolume key events to the X11 clients.

It likely is possible to make that fly with a nice xkb config file, I know next to nothing about that through.

Note that the linux keyboard driver interface (the _really_ old one, not the linux input layer added in 2.4) has a limitation on the number of keys it can disturgish, it's 200 plus something. That is inherited from PS/2. As long as X11 still used the old kbd driver instead of the linux input layer it will have problems supporting all keys :-/

Have fun,


-- Gerd Knorr <>

How to add remote control support to a card

The operation is as follows (at least it is how i did it):

  1. you make detinitions of your board to have remote control (in saa7134-cards.c).
  2. in saa7134-input.c, you add a case for it into the switch statement, with mask_keycode=0. Use any ir_codes array for the start. Well, you should also determine whenever polling is needed, too.
  3. Load saa7134 module with ir_debug=1 parameter.
  4. press the keys on your remote control and watch syslog (dmesg). You will see something like
build_key gpio=0x12345 mask=0x0 data=0

in dmesg output after each key press/release.

Pay attention to gpio=0x... stuff. You will see some bits which does not change, and some which do. The ones which changes should be in your mask_keycode and mask_keydown (mask_keycode should contain not more than 8 bits set to 1, others should be set to 0). Mask_keyup and mask_keydown - those are easy to determine if you see some bit is always on when you press a key and off when you release it, or the reverse.

Ie, you will have to determine which bits in gpio value represents the key# pressed/released, and which indicate whenever it is the press or release.

After this, recompile saa7134 module with correct mask_* stuff in your saa7134_input_init1() routine. Now, the dmesg output should look like

build_key gpio=0x12345 mask=0x<mask_value> data=5

Ensure the data= value is different for each key, if not, you'll have to modify mask_keycode again.

Next, build the key table, by writing a file with one line for every of your key, with two fields -- key name and the data=value assotiated with it.

Try to find existing table matching your one. If there's one, use it. If none is found, build your own.

That's basically it.