[Haifux] preventing caps lock at the kernel level

boazg boaz.gezer at gmail.com
Tue Mar 30 16:47:05 MSD 2010

sorry for the slow update.
my controller is indeed the i8042. however, the current version of ubuntu
has kernel 2.6.31 which does not have the i8042_filter() function yet. the
advantige of keeping the kernel with ubutu's configuration is that all the
tuning they've done to get esoteric hardware to work out of the box remains.
as my laptop is mostly esoteric hardware (HP tx2000), it made more sense
then to try a new kernel and both try to debug my changes and the kernel
config options at the same time.

after some useful information from this
article<http://gunnarwrobel.de/wiki/Linux-and-the-keyboard.html> and
the specification links it led to, i concluded that the scancode in my
system for caps lock is 0x3a, and placed the following code near the
beginning of the function i8042_interrupt().
        if(data == 0x3a)
                goto out;
while this fixed the caps-lock, it made the mouse and tablet go crazy. upon
further thought, i changed it to this:
          if(data == 0x3a && port_no == I8042_KBD_PORT_NO)
                goto out;
a vast improvement. still, some "special" keys acted wrong, so i ended up
moving it to near the end of the code.

and thanks to rami for pointing me in the right direction.

On Sat, Mar 20, 2010 at 13:49, Rami Rosen <rosenrami at gmail.com> wrote:

> Hi, Boaz,
> I suggest that you'll look at the interrupt handler of the keyboard.
> Usually, the i8042 chip family is the keyboard controller in desktops
> and laptops.
> First make sure that i8042 is indeed the driver you are using; run cat
> /proc/interrupts and see whether
> interrupt number 1 (the keyboard interrupt) is handled by i8042.
> Then goto drivers/input/serio/i8042.c; i8042_interrupt() is the
> handler for  keyboard interrupts. You can try add a filter there for
> Caps Lock.
> Even better is try to add code in i8042_filter() method, which is
> called from i8042_interrupt(); this way you can be sure about locking.
> I think that you should **not** try to write a simple module which
> hookskeyboard interrupts. While this solution is usually better (you
> don't change kernel code), I think it won't work in this case.
> Namely, if you try something like this, in a kernel module:
> free_irq (1, NULL);
> res = request_irq (1, mykbdhandler, IRQF_SHARED, "mykbd", dev_id);
> I think you will get an error, since
> interrupt 1 (the PC keyboard interrupt) is edge-triggered (see cat
> /proc/interrupts;
> for interrupt 1 it says:"IO-APIC-edge" ). In
> case of level-triggered interrupts this might have been OK.
> Rgs,
> Rami Rosen
> On Sat, Mar 20, 2010 at 3:19 AM, boazg <boaz.gezer at gmail.com> wrote:
> > hi,
> > i have a laptop in which due to a hardware problem, computer thinks the
> caps
> > lock key is pressed about 5 times a second, at random. i've disabled caps
> > lock at the X11 level, and it's now usable. however, a few programs still
> > have problems with the fact that a key is pressed (regardless of it being
> > caps lock). also, i can't use the consoles at ctrl+alt+f[1..6].
> > i wanted to have the kernel filter out caps lock and have the userland
> never
> > see that is was pressed. to this end i edited drivers/char/keyboard.c and
> > added a few spots where i return if the key is caps lock. this doesn't
> seem
> > to work.
> > anyone have any better ideas as to where i should be looking?
> >
> > thanks
> >
> > boazg
> >
> > _______________________________________________
> > Haifux mailing list
> > Haifux at haifux.org
> > http://hamakor.org.il/cgi-bin/mailman/listinfo/haifux
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://haifux.org/pipermail/haifux/attachments/20100330/c428e985/attachment.html 

More information about the Haifux mailing list