segfault.info
 Navigation
|Actions
 ->Home Cinema
 ->GPS and GSM session
 ->Mosix Cluster
 ->SiS 630
 ->Oracle9i
 ->C-Media PCI
 ->qemu-i386 on ppc
 ->IBM Rapid Access II
|Software
|Pictures
|Girls
|Authors

Using all special keys of the IBM Rapid Access II keyboard with Linux 2.6

If you're running Linux 2.6 and want to use all special keys on the IBM Rapid Access II keyboard the kernel claims about unknown keycodes. It works out of the box with Linux 2.4.

Use "rapidaccess2" as XkbModel in your XF86Config-4. To declare the missing keycodes execute following setkeycodes commands after system startup. I put them at the end of /etc/init.d/bootmish.sh.

setkeycodes e025 205
setkeycodes e026 154
setkeycodes e017 149
setkeycodes e012 152
setkeycodes e023 160
setkeycodes e01e 139

That's it. Now you can use the keys for shortcuts in applications or run a daemon like khotkeys or lineakd to give them functionality.

To switch the additionally LED on the white standby button you can use this simple C program.

/* gcc -O2 -s -Wall -o ibm_led ibm_led.c */
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  int i;
  int send[2] = { 0xEB, 0x70 };

  if (argc != 2) {
    printf("usage %s <0|1>\n", argv[0]);
    return -1;
  }

  i = strtol(argv[1], 0, 16);
  if (i != 0 && i != 1) {
    printf("usage %s <0|1>\n", argv[0]);
    return -1;
  }

  if (i)
    send[1]++;

  i = ioperm(0x60, 3, 1);
  if (i != 0) {
    printf("ioperm failed!\n");
    return i;
  }

  for (i = 0; i < 2; i++) {
    usleep(300);
    outb(send[i], 0x60);
  }

  return 0;
}

If you use this program the kernel will claim about "Spurious ACK on isa0060/serio0.", it still works. It's a dirty hack but I haven't found a clean solution (without modifying the kernel itself) yet.

2005-03-13 Update
I noticed that the above code can have very bad impact if its executed during a key press.
Therefore I wrote a simple kernel patch [0]. To trigger the LED just send an event through the kernel event interface to the keyboard. Event type EV_LED and code LED_SUSPEND of course. This simple program [1] does the job. The program needs permissions to the keyboard event interface (/dev/input/event2 in my case) you can grant them by giving the user write permission to the device or by setting the program setuid root. If you use a self compiled kernel make sure you activated the "Event interface" (CONFIG_INPUT_EVDEV).

For more information on this topic take a look at [2].

References

[0] IBM Rapid Access II Suspend LED kernel patch
[1] C program to switch the LED on/off
[2] Keyboard scancodes

© Copyleft 2001-2005 (segfault.info)