Difference between revisions of "LIRC"

From ArchWiki
Jump to: navigation, search
m (Configure xine to use LIRC)
(Configuration change: remove completely since this is _not_ the way to fix things)
Line 455: Line 455:
  
 
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{filename|/etc/rc.conf}}, as it is no longer present.}}
 
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{filename|/etc/rc.conf}}, as it is no longer present.}}
 
====Configuration change====
 
With a recent update, the configuration file for mceusb uses different names for the buttons. Existing ''lircrc'' configurations will fail as they are expecting different file names. If you don't want to change your button mappings in ''lircrc'', then simply replace the contents of {{filename|/etc/lirc/lircd.conf}} with the following configuration:
 
{{file|name=/etc/lirc/lircd.conf|content=<nowiki>
 
#
 
# brand:                        HP
 
# model no. of remote control:  TSGH-IR01
 
# devices being controlled by this remote: HP Slimline S3100y
 
#
 
# RC-6 config file
 
#
 
# source: http://home.hccnet.nl/m.majoor/projects_remote_control.htm
 
#        http://home.hccnet.nl/m.majoor/pronto.pdf
 
#
 
# used by: Philips
 
#
 
#########
 
#
 
# Philips Media Center Edition remote control
 
# For use with the USB MCE ir receiver
 
#
 
# Dan Conti  dconti|acm.wwu.edu
 
#
 
# Updated with codes for MCE 2005 Remote additional buttons
 
# *, #, Teletext, Red, Green, Yellow & Blue Buttons
 
# Note: TV power button transmits no code until programmed.
 
# Updated 12th September 2005
 
# Graham Auld - mce|graham.auld.me.uk
 
#
 
# Radio, Print, RecTV are only available on the HP Media Center remote control
 
#
 
#
 
# Updated with codes for MCE 2007 Remote additional buttons
 
# Visualization, Aspect, SlideShow, Eject
 
# Note:
 
# Renamed some buttons: DVD->DVDMenu, More->MoreInfo, Star->Asterisk, Hash->Pound
 
# Note:
 
# Blue, Yellow, Green, Red, and Teletext buttons do not exist on the HP remote
 
 
begin remote
 
 
  name        mceusb
 
  bits                16
 
  flags  RC6|CONST_LENGTH
 
  eps                  30
 
  aeps                100
 
 
  header      2667  889
 
  one          444  444
 
  zero          444  444
 
  pre_data_bits        21
 
  pre_data        0x37FF0
 
  gap              105000
 
  toggle_bit          22
 
  rc6_mask    0x100000000
 
 
 
      begin codes
 
 
#seen on HP Pavilion dv3t remote  --Tim Mann, 3 Nov 2009
 
Media        0x00007b7f
 
PlayPause    0x00007b91
 
 
 
#unused by HP remote
 
Blue       0x00007ba1
 
Yellow       0x00007ba2
 
Green       0x00007ba3
 
Red       0x00007ba4
 
Teletext      0x00007ba5
 
 
#ba6 - bae unused
 
        BA6          0x00007ba6
 
        BA7          0x00007ba7
 
        BA8          0x00007ba8
 
        BA9          0x00007ba9
 
        BAA          0x00007baa
 
        BAB          0x00007bab
 
        BAC          0x00007bac
 
        BAD          0x00007bad
 
        BAE          0x00007bae
 
 
        Radio        0x00007baf
 
        Print        0x00007bb1
 
 
#bb2 - bb4 unused 
 
        BB2          0x00007bb2
 
        BB3          0x00007bb3
 
        BB4          0x00007bb4
 
 
        Videos        0x00007bb5
 
        Pictures      0x00007bb6
 
        RecTV        0x00007bb7
 
        Music        0x00007bb8
 
        TV            0x00007bb9
 
 
#bba - bbf unused
 
        BBA          0x00007bba
 
        BBB          0x00007bbb
 
        BBC          0x00007bbc
 
        BBD          0x00007bbd
 
        BBE          0x00007bbe
 
        BBF          0x00007bbf
 
#bc1 - bca unused
 
        BC1          0x00007bc1
 
        BC2          0x00007bc2
 
        BC3          0x00007bc3
 
        BC4          0x00007bc4
 
        BC5          0x00007bc5
 
        BC6          0x00007bc6
 
        BC7          0x00007bc7
 
        BC8          0x00007bc8
 
        BC9          0x00007bc9
 
        BCA          0x00007bca
 
 
        Eject        0x00007bcb
 
        SlideShow    0x00007bcc
 
        Visualization 0x00007bcd
 
 
#bce - bcf unused
 
        BCE          0x00007bce
 
        BCF          0x00007bcf
 
#bd1 - bd7 unused
 
        BD1          0x00007bd1
 
        BD2          0x00007bd2
 
        BD3          0x00007bd3
 
        BD4          0x00007bd4
 
        BD5          0x00007bd5
 
        BD6          0x00007bd6
 
        BD7          0x00007bd7
 
 
        Aspect        0x00007bd8
 
        Guide        0x00007bd9
 
        LiveTV        0x00007bda
 
        DVD          0x00007bdb
 
#NoGap
 
        Back          0x00007bdc
 
        OK            0x00007bdd
 
        Right        0x00007bde
 
        Left          0x00007bdf
 
        Down          0x00007be0
 
        Up            0x00007be1
 
#NoGap
 
        Star          0x00007be2
 
        Hash          0x00007be3
 
#NoGap
 
        Replay        0x00007be4
 
        Skip          0x00007be5
 
        Stop          0x00007be6
 
        Pause        0x00007be7
 
        Record        0x00007be8
 
        Play          0x00007be9
 
        Rewind        0x00007bea
 
        Forward      0x00007beb
 
#NoGap
 
        ChanDown      0x00007bec
 
        ChanUp        0x00007bed
 
        VolDown      0x00007bee
 
        VolUp        0x00007bef
 
#NoGap
 
        More          0x00007bf0
 
        Mute          0x00007bf1
 
        Home          0x00007bf2
 
        Power        0x00007bf3
 
#NoGap
 
        Enter        0x00007bf4
 
        Clear        0x00007bf5
 
#NoGap
 
        Nine          0x00007bf6
 
        Eight        0x00007bf7
 
        Seven        0x00007bf8
 
        Six          0x00007bf9
 
        Five          0x00007bfa
 
        Four          0x00007bfb
 
        Three        0x00007bfc
 
        Two          0x00007bfd
 
        One          0x00007bfe
 
        Zero          0x00007bff
 
      end codes
 
 
end remote
 
#
 
# this config file was automatically generated
 
# using lirc-0.8.4a(default) on Mon Feb 23 23:55:04 2009
 
#
 
# contributed by
 
#
 
# brand:                      Hauppauge
 
# model no. of remote control:
 
# devices being controlled by this remote: PVR-150 Remote (MCE kit)
 
# SMK dongle 0609:031d
 
#
 
 
begin remote
 
 
  name  mceusb_hauppauge
 
  bits          13
 
  flags RC6|CONST_LENGTH
 
  eps            30
 
  aeps          100
 
 
  header      2674  870
 
  one          455  427
 
  zero          455  427
 
  pre_data_bits  24
 
  pre_data      0x1BFF82
 
  gap          106288
 
  min_repeat      1
 
  toggle_bit_mask 0x8000
 
  rc6_mask    0x100000000
 
 
      begin codes
 
          TV                      0x1BB9
 
          Music                    0x1BB8
 
          Pictures                0x1BB6
 
          Videos                  0x1BB5
 
          Power                    0x1BF3
 
          Stop                    0x1BE6
 
          Record                  0x1BE8
 
          Pause                    0x1BE7
 
          Play                    0x1BE9
 
          Rewind                  0x1BEA
 
          Foward                  0x1BEB
 
          Replay                  0x1BE4
 
          Skip                    0x1BE5
 
          Back                    0x1BDC
 
          More                    0x1BF0
 
          Up                      0x1BE1
 
          Left                    0x1BDF
 
          Right                    0x1BDE
 
          OK                      0x1BDD
 
          Down                    0x1BE0
 
          VolUp                    0x1BEF
 
          VolDown                  0x1BEE
 
          Home                    0x1BF2
 
          ChanDown                0x1BED
 
          ChanUp                  0x1BEC
 
          Mute                    0x1BF1
 
          RecTV                    0x1BB7
 
          Guide                    0x1BD9
 
          LiveTV                  0x1BDA
 
          DVD                      0x1BDB
 
          One                      0x1BFE
 
          Two                      0x1BFD
 
          Three                    0x1BFC
 
          Four                    0x1BFB
 
          Five                    0x1BFA
 
          Six                      0x1BF9
 
          Seven                    0x1BF8
 
          Eight                    0x1BF7
 
          Nine                    0x1BF6
 
          Star                    0x1BE2
 
          Zero                    0x1BFF
 
          Hash                    0x1BE3
 
          Clear                    0x1BF5
 
          Enter                    0x1BF4
 
      end codes
 
 
end remote
 
 
 
#
 
# this config file was automatically generated
 
# using lirc-0.8.4a(default) on Tue Mar 10 19:27:09 2009
 
#
 
# contributed by
 
#
 
# brand:  SIIG Vista MCE remote
 
# model no. of remote control:
 
# devices being controlled by this remote:
 
#
 
 
begin remote
 
 
  name  vista_mce
 
  bits          16
 
  flags RC6
 
  eps            30
 
  aeps          100
 
 
  header      2654  889
 
  one          427  427
 
  zero          427  427
 
  pre_data_bits  21
 
  pre_data      0x37FF0
 
  gap          69850
 
  toggle_bit_mask 0x8000
 
  rc6_mask    0x100000000
 
 
      begin codes
 
          Power                    0xEBF3
 
          Pictures                0x6BB6
 
          Radio                    0xEBAF
 
          Videos                  0x6BB5
 
          Music                    0xEBB8
 
          Rec                      0x6BE8
 
          Pause                    0xEBE7
 
          Stop                    0x6BE6
 
          Skipback                0xEBE4
 
          Play                    0x6BE9
 
          Skipfwd                  0xEBE5
 
          Rwd                      0x6BEA
 
          Fwd                      0xEBEB
 
          Start                    0x6BF2
 
          Back                    0xEBDC
 
          More                    0x6BF0
 
          Volup                    0xEBEF
 
          Voldown                  0x6BEE
 
          Chup                    0xEBED
 
          Chdown                  0x6BEC
 
          Up                      0xEBE1
 
          Down                    0x6BE0
 
          Left                    0xEBDF
 
          Right                    0x6BDE
 
          Mute                    0xEBF1
 
          Rectv                    0x6BB7
 
          Guide                    0xEBD9
 
          Livetv                  0x6BDA
 
          Dvdmenu                  0xEBDB
 
          1                        0x6BFE
 
          2                        0xEBFD
 
          3                        0x6BFC
 
          4                        0xEBFB
 
          5                        0x6BFA
 
          6                        0xEBF9
 
          7                        0x6BF8
 
          8                        0xEBF7
 
          9                        0x6BF6
 
          *                        0xEBE2
 
          0                        0x6BFF
 
          #                        0xEBE3
 
          Clear                    0x6BF5
 
          Enter                    0xEBF4
 
      end codes
 
 
end remote
 
</nowiki>}}
 
  
 
==External Resources==
 
==External Resources==

Revision as of 17:18, 30 July 2011

LIRC stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.

This article covers using LIRC with serial or USB infrared devices.

Installation

First install LIRC with pacman:

# pacman -S lirc

This will also install the lirc-utils package as a dependency.

Serial receivers

Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device isn't connected to ttyS0, you'll have to either change the module-options or rebuild the LIRC module. If your device is connected to ttyS0, you can skip this step

To change the options for the lirc_serial module, you edit Template:Filename and add this line:

options lirc_serial io=0x2f8 irq=3

You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:

$ dmesg | grep ttyS

Building the lirc_serial module for another ttySx

Update abs

# abs

Copy the LIRC files to a directory you choose yourself:

$ cp /var/abs/extra/system/lirc /some/dir
$ cd /some/dir

Edit the PKGBUILD in that directory.

Replace the line:

./configure --enable-sandboxed --prefix=/usr \
    --with-driver=all \\
    return 1[/code]

with:

./configure --enable-sandboxed --prefix=/usr \
    --with-driver=com2 \
    || return 1[/code]

Where you replace com2 with the com-port you need.

Build and install the package:

$ makepkg
# pacman -U lirc-version.pkg.tar.gz

Loading

Now try to load the serial module:

# modprobe lirc_serial

If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)

If it's build into the kernel you'll have to do the following (remember that it is build into the kernel, you will need to make some changes later too)

You'll have to release the serial port:

# setserial /dev/ttySx uart none

(Replace x with your port number)

Load the module again:

# modprobe lirc_serial

Now it shouldn't show any errors, and the modules lirc_serial should be listed in lsmod

USB receivers including most onboard devices

This outlines the general procedure, the mceusb module which is used by many devices is used as an example.

# modprobe mceusb

Start the LIRC daemon:

$ /etc/rc.d/lircd start

Test it with irw, it will output the commands received by the IR receiver that match your Template:Filename file. So start irw, point your remote and start pressing buttons.

$ irw
000000037ff07bfe 00 One mceusb
000000037ff07bfd 00 Two mceusb
000000037ff07bfd 01 Two mceusb
000000037ff07bf2 00 Home mceusb
000000037ff07bf2 01 Home mceusb

The above procedure however has been simplified and may won't work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in Template:Filename. Try "man lircd" for more information.

Continue with #Making a configuration file

Setup a HID device with LIRC

Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own Template:Filename files become standard HID devices.

Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to Template:Filename.

First we need the Template:Filename device for our remote:

 $ cat /sys/class/rc/rc0

One of the files should be input#, where the number matches the event# of the device. (To clarify you can check that directory, it will have an event# file.

Note: If you have more than one ir device then there may be multiple directories under Template:Filename. Under event# cat name to verify which device you are looking at.

then go to Template:Filename

 $ ls -l /dev/input/by-id

You should find a file that symlinks to the input# above, and possibly others with a similar names for mouse events.

 lrwxrwxrwx 1 root root  9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9
 lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10

Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.

Then, we need to edit Template:Filename. This file contains the parameters for LIRC daemon

 #
 #Parameters for daemon
 #
 
 LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"
 LIRC_DRIVER="devinput"
 LIRC_EXTRAOPS=""
 LIRC_CONFIGFILE="/etc/lirc/lircd.conf"
Note: Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.

The latest version of the config file for HID remotes exists in the LIRC git repository [1]. Simply save it as Template:Filename.

In order to launch the LIRC daemon for HID remote, You must enable evdev module first

# modprobe evdev
Note: LIRC 0.8.6 has changed the default socket location from Template:Filename to Template:Filename, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the Template:Filename script creates a symlink from Template:Filename to the Template:Filename socket when it starts the lircd daemon and removes the link when the daemon is stopped.

Making a configuration file

You need a configuration file for your remote control copied or symlinked to Template:Filename. A number of devices have already been included with the lirc package, they can be found in Template:Filename. If your specific device is not included, the LIRC site offers configuration files for a large number of extra devices.

If your device doesn't have already a config file, you can create it yourself with the command:

# irrecord -d /dev/lirc0 /tmp/my_remote

Just follow the instructions. The resulting file, Template:Filename, should then be copied to Template:Filename. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into Template:Filename:

# cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf
Note: As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to Template:Filename, Template:Filename and Template:Filename. If the config files are not found in that location, they are still searched at the old location in Template:Filename

Testing

First start the lircd daemon:

# /etc/rc.d/lircd start

A good way to see if LIRC is running is to run irw.

$ irw

When you press a button, you should see something like this:

0000000000000001 00 play sony2
0000000000000001 01 play sony2
0000000000000001 02 play sony2
0000000000000001 03 play sony2

In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.

Run LIRC at bootup

Remember if you had to execute the setserial command while loading the module?

If so, your serial port support is compiled into the kernel

Your serial port support is compiled as a module in the kernel

This is rather easy: you'll just have to add lirc_serial to the modules list and lircd to the daemons list in Template:Filename

Your serial port support is compiled into the kernel

This is more complicated, you can't just add the lirc_serial to the modules list in Template:Filename, as the serial port should be released first.

So I created a custom startup script to fix this problem.

Template:File

Now load the daemons: add "start_lirc" and "lircd" to the daemons list in Template:Filename

Program specific configuration

Generate your own lircrc with Mythbuntu's lircrc-generator

mythbuntu-lircrc-generator is intended to be started from a system with LIRC installed. It requires that you choose a remote via the LIRC package or have a Template:Filename handy prior to running. It will then produce a sane Template:Filename for the current user.

Mythbuntu's Lirc/Lircrc Generator is available on AUR
Man page

Enable LIRC support in xine

Now LIRC works, but you have no program that can communicate with LIRC. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.

Compile xine with LIRC support

Download the xine-ui pkgbuild from the cvs tree.

Add " --enable-lirc" to the Template:Filename line

Compile:

$ makepkg

Uninstall old xine-ui and install the new one

# pacman -R xine-ui
# pacman -U xine-filename.pkg.tar.gz

Configure xine to use LIRC

Let xine produce a default Template:Filename file. In your home directory, type:

$ xine --keymap=lirc>.lircrc

Now, in order to have a functioning xine+lirc, edit the Template:Filename file to your preferences.

However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the Template:Filename file, and add elements.

Xine-ui Mplayer Totem Vlc Rhythmbox

All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!

Configure Amarok2 to use LIRC

Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.

Template:File

Configure Audacious(2) to use LIRC

Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.

Template:File

Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:

Template:File

Device Specific Examples

X10

There is a dedicated wiki page with information about X10

Asus DH Deluxe series motherboard

Check the output of:

$ cat /dev/usb/hiddevX

where X is 0,1 or bigger, and press some buttons on remote. If you can see reply, device works fine, follow steps:

1. In file Template:Filename add:

LIRC_DRIVER="dvico"

2. Reload LIRC:

/etc/rc.d/lircd restart

ASRock ION series (Nuvoton) quickstart

$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf
$ /etc/rc.d/lircd restart

Streamzap PC Remote (USB)

  1. Install both packages (lirc lirc-utils)
  2. Modprobe both kernel mods (lirc_dev and lirc_streamzap) (add these to your MODULES array in Template:Filename to survive a reboot)
  3. Create your Template:Filename (for this remote, copy Template:Filename to Template:Filename)
  4. Start lircd via /etc/rc.d/lircd start (add lircd to your DAEMONS array in Template:Filename to survive a reboot)
  5. Test the remote/lirc with irw
$ irw
00000000000028cc 00 CH_UP Streamzap_PC_Remote
00000000000028ce 00 CH_DOWN Streamzap_PC_Remote
00000000000028c8 00 8 Streamzap_PC_Remote
00000000000028c5 00 5 Streamzap_PC_Remote
00000000000028d2 00 OK Streamzap_PC_Remote
00000000000028d1 00 LEFT Streamzap_PC_Remote
00000000000028d1 01 LEFT Streamzap_PC_Remote
00000000000028d1 00 LEFT Streamzap_PC_Remote
00000000000028d3 00 RIGHT Streamzap_PC_Remote
00000000000028d3 00 RIGHT Streamzap_PC_Remote
00000000000028d3 00 RIGHT Streamzap_PC_Remote
00000000000028d3 00 RIGHT Streamzap_PC_Remote
00000000000028d4 00 DOWN Streamzap_PC_Remote
00000000000028d4 00 DOWN Streamzap_PC_Remote
00000000000028d4 00 DOWN Streamzap_PC_Remote
Note: When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!

Troubleshooting

Buttons processed several times when pressed

Problem in module ir_core which processes IR commands with LIRC at the same time. Simple blacklist it by creating the following file:

Template:File

After upgrading or installing Arch, an existing configuration stopped working

Kernel module change

As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's lirc package has included the older kernel modules, which work with lircd without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to Template:Filename: Template:File You may also run that command as root to enable LIRC for your current session.

Note: It is also a good idea to remove the old LIRC kernel module from your MODULES array in Template:Filename, as it is no longer present.

External Resources

http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article

http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes

http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to

http://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator