lkml.org 
[lkml]   [2000]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] to allow SYSRQ to work with odd keyboards.
Attached is a patch for 2.2.14 to allow SYSRQ to work on odd
keyboards that send the SYSRQ make and break codes simultaneously
when the key is pressed, and send nothing when the key is
released. The M-Tek K208 keyboard that I own works in this
fashion for example, and because of that I have not ever been
able to use SYSRQ - until now.

I tried various solutions to this problem, and believe I've come
up with the simplest solution which allows my keyboard to work
with SYSRQ, in addition to keeping the existing behavior.

I'd like it if as many of you as possible can please apply this
patch to 2.2.14 and test it out. If there are any problems,
report them to me, perhaps with a suggested solution. If all
goes well, which I suspect it will, I'll tidy it up as per
suggestions, and submit it for 2.2.1[56], and port to 2.3.4[78]
as well.

echo 1 > /proc/sys/kernel/sysrq - gives the existing behavior,
in which my keyboard does not work with SYSRQ.

echo 2 > /proc/sys/kernel/sysrq - changes the behavior so that
the SYSRQ "break" code is ignored, and the ALT key's break code
is used instead to break out of SYSRQ.

Normal keyboards work ok with either 1 or 2, however broken
keyboards like mine only work with "2".

I have tested the patch out on 2 different systems, with a good
keyboard and a bad one, both with echo 1, and echo 2, and all
appears to work well. I haven't had any problems so far, so if
anyone else does, I'd like to hear about it.

Check for KERN_DEBUG messages in your logs if you have problems,
and please send them to me.


--
Mike A. Harris Linux advocate
Computer Consultant GNU advocate
Capslock Consulting Open Source advocate

Suspicious Anagram #4:
Word: PRESIDENT CLINTON OF THE USA
Anagram: TO COPULATE HE FINDS INTERNS


diff -urN linux-2.2.14.orig/Documentation/sysrq.txt linux/Documentation/sysrq.txt
--- linux-2.2.14.orig/Documentation/sysrq.txt Sat Feb 26 06:43:05 2000
+++ linux/Documentation/sysrq.txt Sat Feb 26 08:53:37 2000
@@ -1,6 +1,6 @@
- MAGIC SYSRQ KEY DOCUMENTATION v1.2
+ MAGIC SYSRQ KEY DOCUMENTATION v1.21
------------------------------------
- [Sat May 16 01:09:21 EDT 1998]
+ [Sat Feb 26 8:09:49 EDT 2000]

* What is the magic SysRQ key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -11,7 +11,16 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when
configuring the kernel. This option is only available in 2.1.x or later
-kernels.
+kernels. Also, you can enable/disable SysRq at runtime by echoing one of
+the following values into /proc/sys/kernel/sysrq:
+
+0 - disable SysRq
+1 - enable SysRq
+2 - enable SysRq for broken keyboards like the Mtek K208 that send both
+ the make and break scancode simultaneously when the key is pressed
+ down, and nothing when the key is released. Non-broken keyboards
+ will still function properly with sysrq set to 2 as well. In this
+ case, ALT must be kept held down, but SysRq can be released.

* How do I use the magic SysRQ key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff -urN linux-2.2.14.orig/drivers/char/keyboard.c linux/drivers/char/keyboard.c
--- linux-2.2.14.orig/drivers/char/keyboard.c Sat Feb 26 06:42:45 2000
+++ linux/drivers/char/keyboard.c Sat Feb 26 09:56:39 2000
@@ -21,6 +21,10 @@
*
* 27-05-97: Added support for the Magic SysRq Key (Martin Mares)
* 30-07-98: Dead keys redone, aeb@cwi.nl.
+ *
+ * Feb 26, 2000: Modified SysRq to work on broken keyboards that send
+ * make/break simultaneously on make. Activated by setting
+ * sysrq_enabled=2. Mike A. Harris <mharris@meteng.on.ca>
*/

#include <linux/config.h>
@@ -243,9 +247,29 @@
} else
rep = test_and_set_bit(keycode, key_down);

-#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
- if (keycode == SYSRQ_KEY) {
+#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
+ /*
+ * Some broken keyboards such as the Mtek K208 send both the
+ * make and break scancodes for the SYSRQ key simultaneously
+ * when the key is pressed down, and nothing when it is released,
+ * thus preventing SYSRQ from working on such a keyboard.
+ * If sysrq_enabled is set to "2" via /proc, the SYSRQ break
+ * code is ignored, and the ALT key's break code is used in place
+ * of it. - Mike A. Harris <mharris@meteng.on.ca>
+ */
+
+ if (keycode == SYSRQ_KEY) {
+ if(sysrq_enabled == 1 || (sysrq_enabled == 2 && !sysrq_pressed) ) {
+ sysrq_pressed = !up_flag;
+ printk(KERN_DEBUG "keyboard.c: L1 SE=%d SP=%04x keycode=%02x up_flag%02x\n",
+ sysrq_enabled, sysrq_pressed, keycode, up_flag);
+ }
+ return;
+#define ALT_BREAK 0xb8
+ } else if (sysrq_enabled == 2 && sysrq_pressed && scancode == ALT_BREAK) {
sysrq_pressed = !up_flag;
+ printk(KERN_DEBUG "keyboard.c: L2 SE=%d SP=%04x keycode=%02x up_flag%02x\n",
+ sysrq_enabled, sysrq_pressed, keycode, up_flag);
return;
} else if (sysrq_pressed) {
if (!up_flag && sysrq_enabled)
@@ -253,7 +277,7 @@
return;
}
#endif
-
+
if (kbd->kbdmode == VC_MEDIUMRAW) {
/* soon keycodes will require more than one byte */
put_queue(keycode + up_flag);
\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.113 / U:1.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site