Difference between revisions of "How to make use of IrDA"

From ThinkWiki
Jump to: navigation, search
(dead link)
m (LIRC and IrDA: english)
 
(41 intermediate revisions by 5 users not shown)
Line 10: Line 10:
 
SIR is limited to serial datarates up to 115.2Kb/s
 
SIR is limited to serial datarates up to 115.2Kb/s
  
To use it, run {{cmdroot|irattach /dev/ttyS1 -s; modprobe ircomm-tty}}  (on {{Fedora}} 5 just run {{cmdroot|service irda start}}). Then turn on your IrDA-capable device and put it within range, and point your software (e.g., <tt>minicom</tt>) to {{path|/dev/irda0}}.
+
On modern distributions all configuration might be taken care of automatically by starting the irda service {{cmdroot|service irda start}}. If not try the following;
  
===Kernel configuration===
+
To use it, run {{cmdroot|irattach /dev/ttyS1 -s; modprobe ircomm-tty}} 
  
Some distributions (e.g., {{Fedora}} 5) already include the equvialent of the following.
+
Then turn on your IrDA-capable device and put it within range, and point your software (e.g., <tt>minicom</tt>) to {{path|/dev/irda0}}.
  
==== Linux 2.4 kernel config ====
+
===Kernel configuration===
Edit {{path|/etc/modules.conf}} and add the following lines
 
alias tty-ldisc-11 irtty
 
alias char-major-161 ircomm-tty
 
  
==== Linux 2.6 kernel config ====
 
 
Edit {{path|/etc/modprobe.conf}} and add the following lines
 
Edit {{path|/etc/modprobe.conf}} and add the following lines
 
  alias tty-ldisc-11 irtty-sir
 
  alias tty-ldisc-11 irtty-sir
Line 27: Line 23:
  
 
== Fast IR (FIR) ==
 
== Fast IR (FIR) ==
FIR is the preferred mode of IrDA operation and operates at a bandwidth of 4 Mbps
+
FIR is the preferred mode of IrDA operation and operates at a maximum bandwidth of 4 Mbps
 
 
The chips FIR mode first needs to be activated using the ISA PnP or BIOS method.
 
 
 
{{HINT|Regardless of which method you use, you will still have to set the dongle_id and run setserial as shown further below}}
 
=== ISA PnP support for nsc-ircc ===
 
 
 
ISA PnP support is '''necessary''' in some cases, as without it the kernel doesn't manage to enable the device by itself in many ThinkPads.
 
 
 
Starting with the 2.6.17-rc1 kernel, the nsc-ircc driver has ISA PnP support.  For older kernels you will need patches to allow the loading of the driver without the below BIOS change.
 
 
 
* [http://shamrock.dyndns.org/~ln/linux/nsc-ircc-pnp.2.6.12-rc6.diff 2.6.12-rc6 patch]
 
* [http://shamrock.dyndns.org/~ln/linux/nsc-ircc-pnp.2.6.12.diff 2.6.12 patch (applies cleanly to 2.6.12 through 2.6.15)]
 
 
 
=== NS PC8394T support ===
 
 
 
Thinkpads {{T43}}, {{T43p}} and {{R52}} [http://bugzilla.kernel.org/attachment.cgi?id=8247 needed an extra patch] to detect their [[NS PC8394T]]-based FIR device on kernels before 2.6.18.  They also require ISA PnP support in the driver to work, which is available since 2.6.17 (and can be added to 2.6.16 with the patches above).
 
  
=== Changing BIOS settings ===
+
On modern distributions this should all be automatically handled by simply starting the idra service {{cmdroot|service irda start}}. If not try the following;
For older kernels (prior to 2.6.17-rc1), the easiest way to activate FIR mode is by entering BIOS setup during boot-up by pressing {{key|F1}} when prompted.
 
Then, selecting 'Config' followed by 'Infrared' will allow you to control the IrDA operation. Here you will need to select the option to Enable the infra-red port, and ensure the proper resources are set (typically: IO 0x2f8 and IRQ 3). Be sure to save the changes, and then Exit.
 
 
 
{{NOTE|Changing these BIOS settings does not affect Windows 2000 or XP operating systems, but may cause resource issues in older windows versions, or other legacy operating systems.}}
 
 
 
{{WARN|If you change the BIOS settings for IO, IRQ or DMA of the IrDA port, remember to do so accordingly on all examples in this page when applying them to your ThinkPad.}}
 
  
 
===Kernel configuration===
 
===Kernel configuration===
==== Linux 2.4 kernel config ====
 
Edit {{path|/etc/modules.conf}} and add the following lines
 
 
alias irda0 nsc-ircc
 
options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3
 
pre-install nsc-ircc setserial /dev/ttyS1 uart none port 0 irq 0
 
 
==== Linux 2.6 kernel config ====
 
 
Edit {{path|/etc/modprobe.conf}} and add the following lines
 
Edit {{path|/etc/modprobe.conf}} and add the following lines
  
 
  alias irda0 nsc-ircc
 
  alias irda0 nsc-ircc
options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3
 
install nsc-ircc /bin/setserial /dev/ttyS1 uart none port 0 irq 0; /sbin/modprobe --ignore-install nsc-ircc
 
  
 
Make sure that setserial is in right directory (e.g not in /usr/bin/setserial).After that if irdadump still gives nothing try:  
 
Make sure that setserial is in right directory (e.g not in /usr/bin/setserial).After that if irdadump still gives nothing try:  
 
  echo 1 > /proc/sys/net/irda/discovery
 
  echo 1 > /proc/sys/net/irda/discovery
The install line is a work-around for the 8250 serial driver taking over the device, and may not be needed in certain distributions.
 
Another way to do this is to set this kernel config option:
 
  
1. {{kernelconf|CONFIG_SERIAL_8250_RUNTIME_UARTS|(1)|Number of 8250/16550 serial ports to register at runtime|Serial drivers|Character devices|Device Drivers|}}
+
== Known problems ==
 +
* If you read something like "ttyS1: LSR safety check engaged!" and "irattach: tcgetattr: Input/output error" in the system log, try limiting the FIR max baud rate (echo 57600 > /proc/sys/net/irda/max_baud_rate). This did the trick for me when I was trying to synchronize my Ericsson T39m with my Thinkpad R51 (multisync, evolution-2.8, KDE 3.5.5, openSUSE 10.2).
 +
* If you get an error in syslog like "nsc_ircc_open(), can't get iobase of 0x2f8" it probably means you have manually specified resources for IrDA in the BIOS. When you do that you effectively allow the serial driver to take control, and as a result the nsc_ircc driver can no longer take control of the resources. Options are to either restore the BIOS settings for IrDA to factory default, or you can work around it by using setserial to clear the resources before loading the nsc_ircc kernel module
 +
setserial /dev/ttyS1 uart none port 0 irq 0; modprobe nsc_ircc
  
2. {{kernelconf|CONFIG_SERIAL_8250_NR_UARTS|(4)|Maximum number of 8250/16550 serial ports|Serial drivers|Character devices|Device Drivers|}}
+
== Some other things you might want to do with IrDA ==
 +
* add fast PPP support:
 +
:{{cmdroot|modprobe irnet}}
 +
* if needed, limit further the size of the transmit window
 +
:{{cmdroot|echo 1 > /proc/sys/net/irda/max_tx_window}}
 +
* set the connection speed to 4Mbit in FIR mode:
 +
:{{cmdroot|echo 4000000 > /proc/sys/net/irda/max_baud_rate}}
  
This will prevent the 8250 driver from grabbing any other than the first serial port at boot time or when the module is loaded. You can still add more ports later for example from PC-Card modems, up to CONFIG_SERIAL_8250_NR_UARTS.
+
==LIRC and IrDA==
 +
LIRC allows the use of infrared remote controls with Linux as input devices. This can be especially useful to control applications like mplayer, xine, mythtv or boxee. Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir, as follows;
 +
{{NOTE|lirc_sir is incompatible with the regular Linux IrDA drivers (nsc_ircc). You can only use one at a time, and will have to reboot before you can switch}}
 +
{{NOTE|Even if you are successful in getting this to work, you might find that the distance between remote control and receiver on the ThinkPad cannot exceed ~50cm, rendering it effectively useless. This can vary depending on Remote and ThinkPad used, there has been one successful report of a T60 with >2M}}
  
Another possible option is to try the patches from Bjorn Helgaas that convert the legacy x86 and x86_64 serial code to use the platform device, and in doing so prevent the 8250 serial driver from claiming the IrDA port [http://groups.google.com/group/linux.kernel/browse_thread/thread/f24b4fa81f927b8d/c52027e2ec1c7069]. Hopefully this will be merged soon.
+
====Success reports====
 +
* R40
 +
* T41
 +
* T60
 +
* 600
 +
* Z61m (the distance between remote control and receiver highly depends on the remote control used. With an Acer STRC-100 I get only 80 cm compared to 180 cm with a Sony RM-SRG440)
  
==== {{Gentoo}} kernel config ====
+
====Failure reports====
Edit / Create {{path|/etc/modules.d/nsc-irrc}} and add the following lines
+
lirc_sir does not always work, particular on newer machines it seems the module loads when following these instructions, but the device {{path|/dev/lirc0}} cannot be opened and returns a device or resource busy. You can simply test this by typing {{cmdroot|cat /dev/lirc0}}
 +
* T60
  
alias irda0 nsc-ircc
+
===Configuring lirc_sir===
options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3
+
Go into your BIOS setup, and ensure that Infrared is fully enabled and that resources are assigned. I suggest using IO 2f8 and IRQ 3.
  
and then run modules-update
+
Boot into Linux, and first ensure the setserial program is installed. Running {{cmdroot|/bin/setserial /dev/ttyS1}} should return at this point:
 +
/dev/ttyS1, UART: undefined, Port: 0x02f8, IRQ: 3
 +
If setserial cannot be found, install the setserial package with your distributions package management software
  
Edit {{path|/etc/modules.autoload.d/kernel-2.6}} and add the following lines
+
Then create a file {{path|/etc/modprobe.d/lirc.conf}} with the following content:
 +
# prevent nsc_ircc from loading (blacklist might not be enough)
 +
blacklist nsc_ircc
 +
install nsc_ircc /bin/true
 +
# pass options to lirc_sir to load it on ttyS1
 +
options lirc_sir io=0x2f8 irq=3
 +
# ensure serial resources are cleared before loading lirc_sir
 +
# not doing so can result in a device busy error, or can even hang your system
 +
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; /sbin/modprobe --ignore-install lirc_sir
  
nsc-ircc
+
At this point it is best to reboot, to ensure that nsc_ircc was never loaded. Several things can go wrong if the steps are not followed accurately. You might get an error when loading lirc_sir that the device is busy, or your system may even hang.
  
If you have serial support build in the kernel, switch it to a module and add it after nsc-ircc to advoid io base and irq conflict. For kernel 2.4, same as 2.6 changing the path to modules.autoload.d/kernel-2.4.
+
Now do a {{cmdroot|modprobe lirc_sir}} and check {{cmdroot|dmesg}} output. You should see something like this:
 
+
lirc_dev: IR Remote Control driver registered, major 61
==== {{Debian}} Sarge/Etch kernel config ====
+
  lirc_dev: lirc_register_plugin: sample_rate: 0
Install irda-utils and set it up for serial port emulation. Edit {{path|/etc/modprobe.d/irda-utils}} and add/change the following lines:
+
  lirc_sir: I/O port 0x02f8, IRQ 3.
 
+
  lirc_sir: Installed.
  alias irda0 nsc-ircc
 
  options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3
 
 
 
Edit / create {{path|/etc/modules.conf}} and add the following line before any references to 8250*, if any:
 
 
 
  nsc-ircc
 
 
 
Make sure that module-init-tools has a chance to iterate over {{path|/etc/modules.conf}} before udev does the initial pci hotplug (this is a problem at least in Debian Sarge, when using backported udev packages):
 
  
{{cmdroot|cp /etc/rcS.d/S20module-init-tools /etc/rcS.d/S03module-init-tools}}
+
===Configuring LIRC===
 +
If you did not yet install LIRC, then do so now using your distributions package management system.
  
Note that at S03, module-init-tools cannot run depmod for you, so either do it manually before you reboot into a new kernel, or reboot twice to get it to work right.  This is also the reason for using cp instead of mv.
+
====Ubuntu====
 +
{{NOTE|Successfully tested under Ubuntu 10.04}}
  
If you have the regular serial port drivers as modules, that's itOtherwise, try adding the install line described in the Linux 2.6 kernel config section, above, or compile them as modules instead of built-in.
+
Make sure your {{path|/etc/lirc/hardware.conf}} looks like this:
 +
  REMOTE="SIR IrDA (built-in IR ports)"
 +
REMOTE_MODULES="lirc_dev lirc_sir"
 +
REMOTE_DRIVER=""
 +
REMOTE_DEVICE="/dev/lirc0"
 +
REMOTE_LIRCD_CONF=""
 +
REMOTE_LIRCD_ARGS=""
 +
TRANSMITTER="None"
 +
TRANSMITTER_MODULES=""
 +
TRANSMITTER_DRIVER=""
 +
TRANSMITTER_DEVICE=""
 +
TRANSMITTER_LIRCD_CONF=""
 +
TRANSMITTER_LIRCD_ARGS=""
 +
START_LIRCD="true"
 +
START_LIRCMD=""
 +
LOAD_MODULES=""
 +
LIRCMD_CONF=""
 +
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
  
== Known problems ==
+
After this, start (or re-start) the lirc daemon, and set it to automatically start on bootup.
* If the FIR mode is not activated, attempts to load the <tt>nsc-ircc</tt> module will result in an error in syslog of "Wrong chip version ff".
 
* After suspend the <tt>nsc-ircc</tt> module needs to be manually reloaded
 
* If module reloading does not work after a suspend, try reactivating the IrDA port as well:
 
rmmod nsc_ircc
 
echo disable > /sys/devices/pnp0/00\:0d/resources
 
echo activate > /sys/devices/pnp0/00\:0d/resources
 
modprobe nsc_ircc
 
:The value <tt>pnp0/00\:0d</tt> can vary - look for a id file containing IBM0071 or PNP0511, or for a resources file containing the appropriate irq/dma/io values, e.g., using {{cmdroot|grep 0x2f8 /sys/devices/pnp*/*/resources}} .
 
{{NOTE|The power management issues should be resolved starting with the 2.6.17-rc1 kernel.}}
 
  
{{NOTE|Don't understand after inserting modules use irattach irda0 -s and after this you can use eg. minicom over /dev/ircomm0 and test link with irdadump  with this I get working FIR on A21m with 2.6.18}}
+
{{cmdroot|sudo service lirc restart}}<br>
* If you read something like "ttyS1: LSR safety check engaged!" and "irattach: tcgetattr: Input/output error" in the system log, try limiting the FIR max baud rate (echo 57600 > /proc/sys/net/irda/max_baud_rate). This did the trick for me when I was trying to synchronize my Ericsson T39m with my Thinkpad R51 (multisync, evolution-2.8, KDE 3.5.5, openSUSE 10.2).  
+
{{cmdroot|sudo update-rc.d lirc defaults}}
  
== Some other things you might want to do with IrDA ==
+
====Fedora====
* add fast PPP support:
+
On Fedora the default LIRC device is already set to /dev/lirc0
:{{cmdroot|modprobe irnet}}
 
* if needed, limit further the size of the transmit window
 
:{{cmdroot|echo 1 > /proc/sys/net/irda/max_tx_window}}
 
* set the connection speed to 4Mbit in FIR mode:
 
:{{cmdroot|echo 4000000 > /proc/sys/net/irda/max_baud_rate}}
 
 
 
==LIRC and IrDA==
 
Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir.
 
 
 
If loading the <tt>lirc_sir</tt> module shows something like the following in {{cmdroot|dmesg}} output, you are lucky and can use LIRC with the IrDA port to remote control your ThinkPad.
 
lirc_sir: I/O port 0x02f8, IRQ 3.
 
lirc_sir: Installed.
 
  
You might need to force the io and irq settings. For instance, if in your BIOS your Infrared IO is 0x03f8 and IRQ is 4, do the following when inserting the module:
+
{{Todo|best way of ensuring lirc_sir is loaded before lircd is started? The config file /etc/sysconfig/lirc does not seem to help. Perhaps an alias line in the modules config file if someone knows the correct syntax?}}
  
modprobe lirc_sir io=0x03f8 irq=4
+
{{cmdroot|service lirc restart}}<br>
 +
{{cmdroot|chkconfig lirc on}}
  
If it fails with "Device or resource busy", you may want to install the setserial tool and run it with {{cmdroot|setserial /dev/ttyS0 uart none}} or {{cmdroot|setserial /dev/ttyS1 uart none}}. After that lirc_sir should be loadable.
+
===Testing LIRC===
 +
Now we are ready to test if we can receive IR data from a remote control.
  
On a Thinkpad R40 running Ubuntu Feisty, I had to disable the nsc-ircc driver to
+
Try running {{cmdroot|irrecord -d /dev/lirc0 foo}} and follow the onscreen instructions. When asked keep a button on a remote pressed while pointing at the ThinkPad IR port and you should see dots appear. After having configured your specific remote control, copy {{path|foo}} to {{path|/etc/lirc/lircd.conf}} and restart LIRC. You can use '''irw''' to check whether the remote control is working properly.  
give lirc first access to the IR port. I created a file in /etc/modprobe.d with
 
  
  blacklist nsc-ircc
+
To make it perform something useful, try '''irexec'''. It looks for a {{path|.lircrc}} in your home directory. If you don't have one, here is an example which maps KEY_UP and KEY_DOWN (key names can be chosen while performing '''irrecord''') to Up and Down.
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; \
+
<pre>
    /sbin/modprobe --ignore-install lirc_sir
+
  begin
 +
          button = KEY_UP
 +
          prog = irexec
 +
          config = /usr/bin/xvkbd -xsendevent -text "\\[Up]"
 +
          mode = order
 +
          flags = quit
 +
  end
  
You might also need to {{cmdroot|modprobe actisys-sir}},   {{cmdroot|modprobe tekram-sir}}, and {{cmdroot|modprobe lirc-sir}} if you are using the SIR on the thinkpad (modules are from kernel 2.6).
+
begin
 +
          button = KEY_DOWN
 +
          prog = irexec
 +
          config = /usr/bin/xvkbd -xsendevent -text "\\[Down]"
 +
          mode = order
 +
          flags = quit
 +
   end
 +
</pre>
  
Also, do not forget to start the lirc daemon, otherwise no output will be given (you better try running it not as a daemon first, so you can see the output).
+
Configuring remote controls is out of scope for this document and you should check the LIRC website for detailed instructions. But if your using Gnome you might want to try {{cmd|gnome-lirc-properties|$}}, or in the case of KDE {{cmd|kdelirc|$}}.
  lircd -d /dev/lirc0 /etc/lircd.conf --nodaemon
 
You should see:
 
  lircd: lircd(serial) ready
 
This means you are good to start {{cmdroot|irrecord}} or {{cmdroot|xmode2}} and check for input.
 
  
Once that shows a good output you can configure your remote control.
+
{{NOTE|Current versions of gnome-lirc-properties (at least up to 0.3.1) do not support lirc_sir, you need to first edit {{path|/usr/share/gnome-lirc-properties/receivers.conf}} and add the following:<br><pre>[Generic: IrDA SIR Receiver]
then use it in applications like mplayer, xine, or KDE's remote controls server.
+
kernel-module = lirc_sir
 +
device-nodes  = /dev/lirc0</pre>
 +
After this you can select Generic - IrDA SIR Receiver from the drop down menus (autodetect will not pick it up)}}
  
 
== External Sources ==
 
== External Sources ==
Line 170: Line 162:
 
*[http://pcmcia-cs.sourceforge.net/ Linux PCMCIA Project] (External)
 
*[http://pcmcia-cs.sourceforge.net/ Linux PCMCIA Project] (External)
 
*[http://tpctl.sourceforge.net/ tpctl homepage] (External)
 
*[http://tpctl.sourceforge.net/ tpctl homepage] (External)
*[http://www.lirc.org/ Linux Infrared Remote Control] (External)
+
*[http://www.lirc.org/ Linux Infrared Remote Control (LIRC)] (External)

Latest revision as of 18:07, 26 July 2011

The purpose of this document is to get the IrDA hardware in your ThinkPad operational, setting up communication to other devices is not covered. However, the external links section can prove useful for this.

Serial IR (SIR)

SIR is limited to serial datarates up to 115.2Kb/s

On modern distributions all configuration might be taken care of automatically by starting the irda service # service irda start. If not try the following;

To use it, run # irattach /dev/ttyS1 -s; modprobe ircomm-tty

Then turn on your IrDA-capable device and put it within range, and point your software (e.g., minicom) to /dev/irda0.

Kernel configuration

Edit /etc/modprobe.conf and add the following lines

alias tty-ldisc-11 irtty-sir
alias char-major-161 ircomm-tty

Fast IR (FIR)

FIR is the preferred mode of IrDA operation and operates at a maximum bandwidth of 4 Mbps

On modern distributions this should all be automatically handled by simply starting the idra service # service irda start. If not try the following;

Kernel configuration

Edit /etc/modprobe.conf and add the following lines

alias irda0 nsc-ircc

Make sure that setserial is in right directory (e.g not in /usr/bin/setserial).After that if irdadump still gives nothing try:

echo 1 > /proc/sys/net/irda/discovery

Known problems

  • If you read something like "ttyS1: LSR safety check engaged!" and "irattach: tcgetattr: Input/output error" in the system log, try limiting the FIR max baud rate (echo 57600 > /proc/sys/net/irda/max_baud_rate). This did the trick for me when I was trying to synchronize my Ericsson T39m with my Thinkpad R51 (multisync, evolution-2.8, KDE 3.5.5, openSUSE 10.2).
  • If you get an error in syslog like "nsc_ircc_open(), can't get iobase of 0x2f8" it probably means you have manually specified resources for IrDA in the BIOS. When you do that you effectively allow the serial driver to take control, and as a result the nsc_ircc driver can no longer take control of the resources. Options are to either restore the BIOS settings for IrDA to factory default, or you can work around it by using setserial to clear the resources before loading the nsc_ircc kernel module
setserial /dev/ttyS1 uart none port 0 irq 0; modprobe nsc_ircc

Some other things you might want to do with IrDA

  • add fast PPP support:
# modprobe irnet
  • if needed, limit further the size of the transmit window
# echo 1 > /proc/sys/net/irda/max_tx_window
  • set the connection speed to 4Mbit in FIR mode:
# echo 4000000 > /proc/sys/net/irda/max_baud_rate

LIRC and IrDA

LIRC allows the use of infrared remote controls with Linux as input devices. This can be especially useful to control applications like mplayer, xine, mythtv or boxee. Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir, as follows;

NOTE!
lirc_sir is incompatible with the regular Linux IrDA drivers (nsc_ircc). You can only use one at a time, and will have to reboot before you can switch
NOTE!
Even if you are successful in getting this to work, you might find that the distance between remote control and receiver on the ThinkPad cannot exceed ~50cm, rendering it effectively useless. This can vary depending on Remote and ThinkPad used, there has been one successful report of a T60 with >2M

Success reports

  • R40
  • T41
  • T60
  • 600
  • Z61m (the distance between remote control and receiver highly depends on the remote control used. With an Acer STRC-100 I get only 80 cm compared to 180 cm with a Sony RM-SRG440)

Failure reports

lirc_sir does not always work, particular on newer machines it seems the module loads when following these instructions, but the device /dev/lirc0 cannot be opened and returns a device or resource busy. You can simply test this by typing # cat /dev/lirc0

  • T60

Configuring lirc_sir

Go into your BIOS setup, and ensure that Infrared is fully enabled and that resources are assigned. I suggest using IO 2f8 and IRQ 3.

Boot into Linux, and first ensure the setserial program is installed. Running # /bin/setserial /dev/ttyS1 should return at this point:

/dev/ttyS1, UART: undefined, Port: 0x02f8, IRQ: 3

If setserial cannot be found, install the setserial package with your distributions package management software

Then create a file /etc/modprobe.d/lirc.conf with the following content:

# prevent nsc_ircc from loading (blacklist might not be enough)
blacklist nsc_ircc
install nsc_ircc /bin/true
# pass options to lirc_sir to load it on ttyS1
options lirc_sir io=0x2f8 irq=3
# ensure serial resources are cleared before loading lirc_sir
# not doing so can result in a device busy error, or can even hang your system
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; /sbin/modprobe --ignore-install lirc_sir

At this point it is best to reboot, to ensure that nsc_ircc was never loaded. Several things can go wrong if the steps are not followed accurately. You might get an error when loading lirc_sir that the device is busy, or your system may even hang.

Now do a # modprobe lirc_sir and check # dmesg output. You should see something like this:

lirc_dev: IR Remote Control driver registered, major 61
lirc_dev: lirc_register_plugin: sample_rate: 0
lirc_sir: I/O port 0x02f8, IRQ 3.
lirc_sir: Installed.

Configuring LIRC

If you did not yet install LIRC, then do so now using your distributions package management system.

Ubuntu

NOTE!
Successfully tested under Ubuntu 10.04

Make sure your /etc/lirc/hardware.conf looks like this:

REMOTE="SIR IrDA (built-in IR ports)"
REMOTE_MODULES="lirc_dev lirc_sir"
REMOTE_DRIVER=""
REMOTE_DEVICE="/dev/lirc0"
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER=""
TRANSMITTER_DEVICE=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""
START_LIRCD="true"
START_LIRCMD=""
LOAD_MODULES=""
LIRCMD_CONF=""
FORCE_NONINTERACTIVE_RECONFIGURATION="false"

After this, start (or re-start) the lirc daemon, and set it to automatically start on bootup.

# sudo service lirc restart
# sudo update-rc.d lirc defaults

Fedora

On Fedora the default LIRC device is already set to /dev/lirc0

TODO
best way of ensuring lirc_sir is loaded before lircd is started? The config file /etc/sysconfig/lirc does not seem to help. Perhaps an alias line in the modules config file if someone knows the correct syntax?

# service lirc restart
# chkconfig lirc on

Testing LIRC

Now we are ready to test if we can receive IR data from a remote control.

Try running # irrecord -d /dev/lirc0 foo and follow the onscreen instructions. When asked keep a button on a remote pressed while pointing at the ThinkPad IR port and you should see dots appear. After having configured your specific remote control, copy foo to /etc/lirc/lircd.conf and restart LIRC. You can use irw to check whether the remote control is working properly.

To make it perform something useful, try irexec. It looks for a .lircrc in your home directory. If you don't have one, here is an example which maps KEY_UP and KEY_DOWN (key names can be chosen while performing irrecord) to Up and Down.

 begin
           button = KEY_UP
           prog = irexec
           config = /usr/bin/xvkbd -xsendevent -text "\\[Up]"
           mode = order
           flags = quit
  end

 begin
           button = KEY_DOWN
           prog = irexec
           config = /usr/bin/xvkbd -xsendevent -text "\\[Down]"
           mode = order
           flags = quit
  end

Configuring remote controls is out of scope for this document and you should check the LIRC website for detailed instructions. But if your using Gnome you might want to try $ gnome-lirc-properties, or in the case of KDE $ kdelirc.

NOTE!
Current versions of gnome-lirc-properties (at least up to 0.3.1) do not support lirc_sir, you need to first edit /usr/share/gnome-lirc-properties/receivers.conf and add the following:
[Generic: IrDA SIR Receiver]
kernel-module = lirc_sir
device-nodes  = /dev/lirc0
After this you can select Generic - IrDA SIR Receiver from the drop down menus (autodetect will not pick it up)

External Sources