How to make use of IrDA

From ThinkWiki
Revision as of 11:33, 11 March 2009 by Tonko (Talk | contribs) (Kernel configuration)
Jump to: navigation, search

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

To use it, run # irattach /dev/ttyS1 -s; modprobe ircomm-tty (on Fedora 5 just run # service irda start). Then turn on your IrDA-capable device and put it within range, and point your software (e.g., minicom) to /dev/irda0.

Kernel configuration

Some distributions (e.g., Fedora 5) already include the equivalent of the following.

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 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.

NS PC8394T support

Thinkpads T43, T43p and R52 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

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 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.
ATTENTION!
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

Linux 2.4 kernel config

Edit /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 /etc/modprobe.conf and add the following lines

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:

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. Device Drivers → Character devices → Serial drivers → (1)Number of 8250/16550 serial ports to register at runtime (CONFIG_SERIAL_8250_RUNTIME_UARTS)

2. Device Drivers → Character devices → Serial drivers → (4)Maximum number of 8250/16550 serial ports (CONFIG_SERIAL_8250_NR_UARTS)

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.

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 [1]. Hopefully this will be merged soon.

Gentoo kernel config

Edit / Create /etc/modules.d/nsc-irrc and add the following lines

alias irda0 nsc-ircc
options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3

and then run modules-update

Edit /etc/modules.autoload.d/kernel-2.6 and add the following lines

nsc-ircc

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.

Debian Sarge/Etch kernel config

Install irda-utils and set it up for serial port emulation. Edit /etc/modprobe.d/irda-utils and add/change the following lines:

alias irda0 nsc-ircc
options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3

Edit / create /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 /etc/modules.conf before udev does the initial pci hotplug (this is a problem at least in Debian Sarge, when using backported udev packages):

# cp /etc/rcS.d/S20module-init-tools /etc/rcS.d/S03module-init-tools

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.

If you have the regular serial port drivers as modules, that's it. Otherwise, try adding the install line described in the Linux 2.6 kernel config section, above, or compile them as modules instead of built-in.

Known problems

  • If the FIR mode is not activated, attempts to load the nsc-ircc module will result in an error in syslog of "Wrong chip version ff".
  • After suspend the nsc-ircc 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 pnp0/00\:0d 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 # 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
  • 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).

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

Usually, IrDA ports are not compatible with LIRC, but you may have luck using lirc_sir. For some Laptops it is important, that you never try to load the nsc-ircc. Even when loading fails or you unload the module mode2 will not work.

If loading the lirc_sir module shows something like the following in # 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:

modprobe lirc_sir io=0x03f8 irq=4

If it fails with "Device or resource busy", you may want to install the setserial tool and run it with # setserial /dev/ttyS0 uart none or # setserial /dev/ttyS1 uart none. After that lirc_sir should be loadable.

On a Thinkpad R40 running Ubuntu Feisty, I had to disable the nsc-ircc driver to give lirc first access to the IR port. I created a file in /etc/modprobe.d with

blacklist nsc-ircc
install lirc_sir /bin/setserial /dev/ttyS1 uart none port 0 irq 0; \
    /sbin/modprobe --ignore-install lirc_sir

You might also need to # modprobe actisys-sir, # modprobe tekram-sir, and # modprobe lirc-sir if you are using the SIR on the thinkpad (modules are from kernel 2.6).

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).

 lircd -d /dev/lirc0 /etc/lircd.conf --nodaemon

You should see:

 lircd: lircd(serial) ready

This means you are good to start # irrecord or # xmode2 and check for input.

Once that shows a good output you can configure your remote control. then use it in applications like mplayer, xine, or KDE's remote controls server.

External Sources