]> git.neil.brown.name Git - history.git/commitdiff
Fix bits that have fallen out when merging input-based keyboard.c
authorVojtech Pavlik <vojtech@suse.cz>
Tue, 27 Aug 2002 04:28:38 +0000 (06:28 +0200)
committerVojtech Pavlik <vojtech@suse.cz>
Tue, 27 Aug 2002 04:28:38 +0000 (06:28 +0200)
into 2.5 - kbd0 init, sysrq support, show_regs, show_mem, show_state
support, correct handling of shifts across vt switches, console
blanking, console callback. Hope that's all.

drivers/char/keyboard.c
drivers/input/serio/i8042.c

index 5a23661357912c05345d9680f2c8448050415979..e3f5c89da56c78e49e75746de535b8a3a7ebbcb9 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/kbd_diacr.h>
 #include <linux/vt_kern.h>
 #include <linux/sysrq.h>
-#include <linux/pm.h>
 #include <linux/input.h>
 
 static void kbd_disconnect(struct input_handle *handle);
@@ -50,6 +49,22 @@ extern void ctrl_alt_del(void);
  * Exported functions/variables
  */
 
+#ifndef KBD_DEFMODE
+#define KBD_DEFMODE ((1 << VC_REPEAT) | (1 << VC_META))
+#endif
+
+#ifndef KBD_DEFLEDS
+/*
+ * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on.
+ * This seems a good reason to start with NumLock off.
+ */
+#define KBD_DEFLEDS 0
+#endif
+
+#ifndef KBD_DEFLOCK
+#define KBD_DEFLOCK 0
+#endif
+
 struct pt_regs *kbd_pt_regs;
 void compute_shiftstate(void);
 
@@ -94,6 +109,7 @@ const int NR_TYPES = ARRAY_SIZE(max_vals);
 
 struct kbd_struct kbd_table[MAX_NR_CONSOLES];
 static struct kbd_struct *kbd = kbd_table;
+static struct kbd_struct kbd0;
 
 int spawnpid, spawnsig;
 
@@ -124,6 +140,21 @@ static struct ledptr {
        unsigned char valid:1;
 } ledptrs[3];
 
+/* Simple translation table for the SysRq keys */
+
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char kbd_sysrq_xlate[128] =
+        "\000\0331234567890-=\177\t"                    /* 0x00 - 0x0f */
+        "qwertyuiop[]\r\000as"                          /* 0x10 - 0x1f */
+        "dfghjkl;'`\000\\zxcv"                          /* 0x20 - 0x2f */
+        "bnm,./\000*\000 \000\201\202\203\204\205"      /* 0x30 - 0x3f */
+        "\206\207\210\211\212\000\000789-456+1"         /* 0x40 - 0x4f */
+        "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+        "\r\000/";                                      /* 0x60 - 0x6f */
+static int sysrq_down;
+#endif
+static int sysrq_alt;
+
 /*
  * Translation of scancodes to keycodes. We set them on only the first attached
  * keyboard - for per-keyboard setting, /dev/input/event is more useful.
@@ -314,7 +345,7 @@ void compute_shiftstate(void)
                if (!key_down[i])
                        continue;
 
-               k = i*BITS_PER_LONG;
+               k = i * BITS_PER_LONG;
 
                for (j = 0; j < BITS_PER_LONG; j++, k++) {
 
@@ -861,8 +892,6 @@ DECLARE_TASKLET_DISABLED(keyboard_tasklet, kbd_bh, 0);
 
 #if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) || defined(CONFIG_MIPS) || defined(CONFIG_PPC)
 
-static int x86_sysrq_alt = 0;
-
 static unsigned short x86_keycodes[256] =
        { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
         16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
@@ -902,7 +931,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
                return 0;
        } 
 
-       if (keycode == KEY_SYSRQ && x86_sysrq_alt) {
+       if (keycode == KEY_SYSRQ && sysrq_alt) {
                put_queue(vc, 0x54 | up_flag);
                return 0;
        }
@@ -917,9 +946,6 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
                put_queue(vc, 0x37 | up_flag);
        }
 
-       if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
-               x86_sysrq_alt = !up_flag;
-
        return 0;
 }
 
@@ -957,10 +983,26 @@ void kbd_keycode(unsigned int keycode, int down)
 
        kbd = kbd_table + fg_console;
 
+       if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
+               sysrq_alt = down;
+
+       rep = (down == 2);
+
        if ((raw_mode = (kbd->kbdmode == VC_RAW)))
                if (emulate_raw(vc, keycode, !down << 7))
                        printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
 
+#ifdef CONFIG_MAGIC_SYSRQ             /* Handle the SysRq Hack */
+       if (keycode == KEY_SYSRQ && !rep) {
+               sysrq_down = sysrq_alt && down;
+               return;
+       }
+       if (sysrq_down && down && !rep) {
+               handle_sysrq(kbd_sysrq_xlate[keycode], kbd_pt_regs, tty);
+               return;
+       }
+#endif
+
        if (kbd->kbdmode == VC_MEDIUMRAW) {
                /*
                 * This is extended medium raw mode, with keys above 127
@@ -981,7 +1023,10 @@ void kbd_keycode(unsigned int keycode, int down)
                raw_mode = 1;
        }
 
-       rep = (down == 2);
+       if (down)
+               set_bit(keycode, key_down);
+       else
+               clear_bit(keycode, key_down);
 
        if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty && 
                (!L_ECHO(tty) && tty->driver.chars_in_buffer(tty))))) {
@@ -1037,6 +1082,8 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type,
                return;
        kbd_keycode(keycode, down);
        tasklet_schedule(&keyboard_tasklet);
+       do_poke_blanked_console = 1;
+       schedule_console_callback();
 }
 
 static char kbd_name[] = "kbd";
@@ -1105,6 +1152,18 @@ static struct input_handler kbd_handler = {
 
 int __init kbd_init(void)
 {
+       int i;
+
+        kbd0.ledflagstate = kbd0.default_ledflagstate = KBD_DEFLEDS;
+        kbd0.ledmode = LED_SHOW_FLAGS;
+        kbd0.lockstate = KBD_DEFLOCK;
+        kbd0.slockstate = 0;
+        kbd0.modeflags = KBD_DEFMODE;
+        kbd0.kbdmode = VC_XLATE;
+
+        for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
+                kbd_table[i] = kbd0;
+
        tasklet_enable(&keyboard_tasklet);
        tasklet_schedule(&keyboard_tasklet);
        input_register_handler(&kbd_handler);
index 6c577b4c756d292d348d562a2c5a89d281c0ef29..1df8d64e8a0077597926809c6a60285e92c3b8a3 100644 (file)
@@ -61,6 +61,8 @@ struct timer_list i8042_timer;
 static unsigned long i8042_start;
 #endif
 
+extern struct pt_regs *kbd_pt_regs;
+
 static unsigned long i8042_unxlate_seen[128 / BITS_PER_LONG];
 static unsigned char i8042_unxlate_table[128] = {
          0,118, 22, 30, 38, 37, 46, 54, 61, 62, 70, 69, 78, 85,102, 13,
@@ -346,6 +348,10 @@ static void i8042_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        unsigned char str, data;
        unsigned int dfl;
 
+#ifdef CONFIG_VT
+       kbd_pt_regs = regs;
+#endif
+
        spin_lock_irqsave(&i8042_lock, flags);
 
        while ((str = i8042_read_status()) & I8042_STR_OBF) {