Bug 2808 - atkbd.c: wrong asumption: SysRq == Alt-PrintScreen
Summary: atkbd.c: wrong asumption: SysRq == Alt-PrintScreen
Status: CLOSED PATCH_ALREADY_AVAILABLE
Alias: None
Product: Drivers
Classification: Unclassified
Component: Input Devices (show other bugs)
Hardware: i386 Linux
: P2 low
Assignee: Vojtech Pavlik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-01 01:02 UTC by LEE Sau Dan
Modified: 2004-06-01 02:17 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.0 -- 2.6.7-rc1
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
First half of the fix: removes the wrong assumption in atkbd.c (1.07 KB, patch)
2004-06-01 01:11 UTC, LEE Sau Dan
Details | Diff
Second half of bug fix: keyboard handler no longer require Alt to be pressed with SysRq (2.69 KB, patch)
2004-06-01 02:04 UTC, LEE Sau Dan
Details | Diff

Description LEE Sau Dan 2004-06-01 01:02:56 UTC
Distribution: Irrelevant, but it's Debian woody stable+testing
Hardware Environment: Fujitsu Lifebook B142
Software Environment: Irrelevant
Problem Description:

The kernel keyboard driver and handler wrongly
assume that SysRq (on PC) must be equivalent to Alt-PrintScreen.
This is unfortunately a wrong assumption on my
notebook's keyboard, which provides a [Fn]- key combo for SysRq.
A bug in the keyboard driver atkbd.c makes the
the kernel unable to distinguish PrintScreen
(also provided by a [Fn]- key combo in my notebook) and
SysRq.  Both generate the same input_event's.

What's worse: the sysrq handler deep inside the kernel also assumes that
Alt must be pressed (and not yet released) when SysRq is pressed.  So, it
refuses to work unless I press Alt-SysRq.  I consider this a bug.


Steps to reproduce:

Compile kernel with keyboard support (CONFIG_SERIO_I8042,
CONFIG_KEYBOARD_ATKBD), either as module or built-in.
Then, use the [Fn] key combos!  e.g.

modprobe evbug

Now, press PrintScreen using the [Fn] key combo.  dmesg shows:

evbug.c: Connected device: "AT Translated Set 2 keyboard", isa0060/serio0/input0
evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 99, Value: 1
evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0
evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 99, Value: 0
evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0

NOTE: Code: 99 means SysRq!!!

Pressing SysRq using the [Fn] key combo, dmesg shows the same things.


Please don't ask me for the results of 'showkey -s'.  It is faked by
the input driver, and hence unreliable.  I used the SERIO_USERDEV patch
and did a "od -t x1 /dev/misc/isa0060/serio0" and got the following:

Pressing PrintScreen: 0xe0 0x2a 0xe0 0x37 0xe0 0xb7 0xe0 0xaa
Pressing SysRq: 0x54 0xd4

whereas showkey -s showed the same thing for PrintScreen whether I'm
realling pressing PrintScreen or SysRq.
Comment 1 LEE Sau Dan 2004-06-01 01:11:24 UTC
Created attachment 3030 [details]
First half of the fix: removes the wrong assumption in atkbd.c

This fixes atkbd.c, so that SysRq and PrintScreen now generated distinct
events:

Now, PrintScreen *correctly* generates:
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 55, Value: 1
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 55, Value: 0
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0

and SysRq *correctly* generates:
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 99, Value: 1
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 1, Code: 99, Value: 0
  evbug.c: Event. Dev: isa0060/serio0/input0, Type: 0, Code: 0, Value: 0
Comment 2 LEE Sau Dan 2004-06-01 02:04:35 UTC
Created attachment 3031 [details]
Second half of bug fix: keyboard handler no longer require Alt to be pressed with SysRq

This fixes the wrong assumption in the kernel's keyboard event handler, so that
it no longer assumes that Alt (either one) must be pressed before SysRq can be
pressed.
Comment 3 Vojtech Pavlik 2004-06-01 02:04:50 UTC
I'm sorry you can't use the fn+printscreen function on your LifeBook, but
such is life. Is using Alt+printscreen such a big difference? 

On USB keyboards (and many others, too), there is no specific
SysRq keycode, and thus the kernel magic-sysrq handler uses the alt-printscreen
combination, to make it work on ALL keyboards. This is intentional.

Further, keycode 99 is KEY_SYSRQ, as defined in input.h, and is used for the
PrtScr/SysRq key. Keycode 55 is KEY_KPASTERISK. Keycodes are NOT the same
as raw scancodes.

So your patch won't be applied, because current behavior is intended and
not a bug.

Note You need to log in before you can comment on or make changes to this bug.