aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/keyboard.c')
-rw-r--r--drivers/char/keyboard.c325
1 files changed, 155 insertions, 170 deletions
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index ada25bb8941e..54109dc9240c 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -24,6 +24,8 @@
24 * 21-08-02: Converted to input API, major cleanup. (Vojtech Pavlik) 24 * 21-08-02: Converted to input API, major cleanup. (Vojtech Pavlik)
25 */ 25 */
26 26
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
27#include <linux/consolemap.h> 29#include <linux/consolemap.h>
28#include <linux/module.h> 30#include <linux/module.h>
29#include <linux/sched.h> 31#include <linux/sched.h>
@@ -38,7 +40,6 @@
38#include <linux/kbd_kern.h> 40#include <linux/kbd_kern.h>
39#include <linux/kbd_diacr.h> 41#include <linux/kbd_diacr.h>
40#include <linux/vt_kern.h> 42#include <linux/vt_kern.h>
41#include <linux/sysrq.h>
42#include <linux/input.h> 43#include <linux/input.h>
43#include <linux/reboot.h> 44#include <linux/reboot.h>
44#include <linux/notifier.h> 45#include <linux/notifier.h>
@@ -82,8 +83,7 @@ void compute_shiftstate(void);
82typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, 83typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
83 char up_flag); 84 char up_flag);
84static k_handler_fn K_HANDLERS; 85static k_handler_fn K_HANDLERS;
85k_handler_fn *k_handler[16] = { K_HANDLERS }; 86static k_handler_fn *k_handler[16] = { K_HANDLERS };
86EXPORT_SYMBOL_GPL(k_handler);
87 87
88#define FN_HANDLERS\ 88#define FN_HANDLERS\
89 fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ 89 fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\
@@ -133,7 +133,7 @@ static struct input_handler kbd_handler;
133static DEFINE_SPINLOCK(kbd_event_lock); 133static DEFINE_SPINLOCK(kbd_event_lock);
134static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */ 134static unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; /* keyboard key bitmap */
135static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ 135static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
136static int dead_key_next; 136static bool dead_key_next;
137static int npadch = -1; /* -1 or number assembled on pad */ 137static int npadch = -1; /* -1 or number assembled on pad */
138static unsigned int diacr; 138static unsigned int diacr;
139static char rep; /* flag telling character repeat */ 139static char rep; /* flag telling character repeat */
@@ -147,22 +147,6 @@ static struct ledptr {
147 unsigned char valid:1; 147 unsigned char valid:1;
148} ledptrs[3]; 148} ledptrs[3];
149 149
150/* Simple translation table for the SysRq keys */
151
152#ifdef CONFIG_MAGIC_SYSRQ
153unsigned char kbd_sysrq_xlate[KEY_MAX + 1] =
154 "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
155 "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
156 "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
157 "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
158 "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
159 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
160 "\r\000/"; /* 0x60 - 0x6f */
161static int sysrq_down;
162static int sysrq_alt_use;
163#endif
164static int sysrq_alt;
165
166/* 150/*
167 * Notifier list for console keyboard events 151 * Notifier list for console keyboard events
168 */ 152 */
@@ -361,8 +345,8 @@ static void to_utf8(struct vc_data *vc, uint c)
361 /* 110***** 10****** */ 345 /* 110***** 10****** */
362 put_queue(vc, 0xc0 | (c >> 6)); 346 put_queue(vc, 0xc0 | (c >> 6));
363 put_queue(vc, 0x80 | (c & 0x3f)); 347 put_queue(vc, 0x80 | (c & 0x3f));
364 } else if (c < 0x10000) { 348 } else if (c < 0x10000) {
365 if (c >= 0xD800 && c < 0xE000) 349 if (c >= 0xD800 && c < 0xE000)
366 return; 350 return;
367 if (c == 0xFFFF) 351 if (c == 0xFFFF)
368 return; 352 return;
@@ -370,7 +354,7 @@ static void to_utf8(struct vc_data *vc, uint c)
370 put_queue(vc, 0xe0 | (c >> 12)); 354 put_queue(vc, 0xe0 | (c >> 12));
371 put_queue(vc, 0x80 | ((c >> 6) & 0x3f)); 355 put_queue(vc, 0x80 | ((c >> 6) & 0x3f));
372 put_queue(vc, 0x80 | (c & 0x3f)); 356 put_queue(vc, 0x80 | (c & 0x3f));
373 } else if (c < 0x110000) { 357 } else if (c < 0x110000) {
374 /* 11110*** 10****** 10****** 10****** */ 358 /* 11110*** 10****** 10****** 10****** */
375 put_queue(vc, 0xf0 | (c >> 18)); 359 put_queue(vc, 0xf0 | (c >> 18));
376 put_queue(vc, 0x80 | ((c >> 12) & 0x3f)); 360 put_queue(vc, 0x80 | ((c >> 12) & 0x3f));
@@ -469,6 +453,7 @@ static void fn_enter(struct vc_data *vc)
469 } 453 }
470 diacr = 0; 454 diacr = 0;
471 } 455 }
456
472 put_queue(vc, 13); 457 put_queue(vc, 13);
473 if (vc_kbd_mode(kbd, VC_CRLF)) 458 if (vc_kbd_mode(kbd, VC_CRLF))
474 put_queue(vc, 10); 459 put_queue(vc, 10);
@@ -478,6 +463,7 @@ static void fn_caps_toggle(struct vc_data *vc)
478{ 463{
479 if (rep) 464 if (rep)
480 return; 465 return;
466
481 chg_vc_kbd_led(kbd, VC_CAPSLOCK); 467 chg_vc_kbd_led(kbd, VC_CAPSLOCK);
482} 468}
483 469
@@ -485,12 +471,14 @@ static void fn_caps_on(struct vc_data *vc)
485{ 471{
486 if (rep) 472 if (rep)
487 return; 473 return;
474
488 set_vc_kbd_led(kbd, VC_CAPSLOCK); 475 set_vc_kbd_led(kbd, VC_CAPSLOCK);
489} 476}
490 477
491static void fn_show_ptregs(struct vc_data *vc) 478static void fn_show_ptregs(struct vc_data *vc)
492{ 479{
493 struct pt_regs *regs = get_irq_regs(); 480 struct pt_regs *regs = get_irq_regs();
481
494 if (regs) 482 if (regs)
495 show_regs(regs); 483 show_regs(regs);
496} 484}
@@ -515,7 +503,7 @@ static void fn_hold(struct vc_data *vc)
515 503
516static void fn_num(struct vc_data *vc) 504static void fn_num(struct vc_data *vc)
517{ 505{
518 if (vc_kbd_mode(kbd,VC_APPLIC)) 506 if (vc_kbd_mode(kbd, VC_APPLIC))
519 applkey(vc, 'P', 1); 507 applkey(vc, 'P', 1);
520 else 508 else
521 fn_bare_num(vc); 509 fn_bare_num(vc);
@@ -610,7 +598,7 @@ static void fn_boot_it(struct vc_data *vc)
610 598
611static void fn_compose(struct vc_data *vc) 599static void fn_compose(struct vc_data *vc)
612{ 600{
613 dead_key_next = 1; 601 dead_key_next = true;
614} 602}
615 603
616static void fn_spawn_con(struct vc_data *vc) 604static void fn_spawn_con(struct vc_data *vc)
@@ -657,7 +645,7 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
657 645
658static void k_lowercase(struct vc_data *vc, unsigned char value, char up_flag) 646static void k_lowercase(struct vc_data *vc, unsigned char value, char up_flag)
659{ 647{
660 printk(KERN_ERR "keyboard.c: k_lowercase was called - impossible\n"); 648 pr_err("k_lowercase was called - impossible\n");
661} 649}
662 650
663static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag) 651static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag)
@@ -669,7 +657,7 @@ static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag)
669 value = handle_diacr(vc, value); 657 value = handle_diacr(vc, value);
670 658
671 if (dead_key_next) { 659 if (dead_key_next) {
672 dead_key_next = 0; 660 dead_key_next = false;
673 diacr = value; 661 diacr = value;
674 return; 662 return;
675 } 663 }
@@ -691,6 +679,7 @@ static void k_deadunicode(struct vc_data *vc, unsigned int value, char up_flag)
691{ 679{
692 if (up_flag) 680 if (up_flag)
693 return; 681 return;
682
694 diacr = (diacr ? handle_diacr(vc, value) : value); 683 diacr = (diacr ? handle_diacr(vc, value) : value);
695} 684}
696 685
@@ -710,29 +699,28 @@ static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag)
710static void k_dead(struct vc_data *vc, unsigned char value, char up_flag) 699static void k_dead(struct vc_data *vc, unsigned char value, char up_flag)
711{ 700{
712 static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; 701 static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
713 value = ret_diacr[value]; 702
714 k_deadunicode(vc, value, up_flag); 703 k_deadunicode(vc, ret_diacr[value], up_flag);
715} 704}
716 705
717static void k_cons(struct vc_data *vc, unsigned char value, char up_flag) 706static void k_cons(struct vc_data *vc, unsigned char value, char up_flag)
718{ 707{
719 if (up_flag) 708 if (up_flag)
720 return; 709 return;
710
721 set_console(value); 711 set_console(value);
722} 712}
723 713
724static void k_fn(struct vc_data *vc, unsigned char value, char up_flag) 714static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
725{ 715{
726 unsigned v;
727
728 if (up_flag) 716 if (up_flag)
729 return; 717 return;
730 v = value; 718
731 if (v < ARRAY_SIZE(func_table)) { 719 if ((unsigned)value < ARRAY_SIZE(func_table)) {
732 if (func_table[value]) 720 if (func_table[value])
733 puts_queue(vc, func_table[value]); 721 puts_queue(vc, func_table[value]);
734 } else 722 } else
735 printk(KERN_ERR "k_fn called with value=%d\n", value); 723 pr_err("k_fn called with value=%d\n", value);
736} 724}
737 725
738static void k_cur(struct vc_data *vc, unsigned char value, char up_flag) 726static void k_cur(struct vc_data *vc, unsigned char value, char up_flag)
@@ -741,6 +729,7 @@ static void k_cur(struct vc_data *vc, unsigned char value, char up_flag)
741 729
742 if (up_flag) 730 if (up_flag)
743 return; 731 return;
732
744 applkey(vc, cur_chars[value], vc_kbd_mode(kbd, VC_CKMODE)); 733 applkey(vc, cur_chars[value], vc_kbd_mode(kbd, VC_CKMODE));
745} 734}
746 735
@@ -758,43 +747,45 @@ static void k_pad(struct vc_data *vc, unsigned char value, char up_flag)
758 return; 747 return;
759 } 748 }
760 749
761 if (!vc_kbd_led(kbd, VC_NUMLOCK)) 750 if (!vc_kbd_led(kbd, VC_NUMLOCK)) {
751
762 switch (value) { 752 switch (value) {
763 case KVAL(K_PCOMMA): 753 case KVAL(K_PCOMMA):
764 case KVAL(K_PDOT): 754 case KVAL(K_PDOT):
765 k_fn(vc, KVAL(K_REMOVE), 0); 755 k_fn(vc, KVAL(K_REMOVE), 0);
766 return; 756 return;
767 case KVAL(K_P0): 757 case KVAL(K_P0):
768 k_fn(vc, KVAL(K_INSERT), 0); 758 k_fn(vc, KVAL(K_INSERT), 0);
769 return; 759 return;
770 case KVAL(K_P1): 760 case KVAL(K_P1):
771 k_fn(vc, KVAL(K_SELECT), 0); 761 k_fn(vc, KVAL(K_SELECT), 0);
772 return; 762 return;
773 case KVAL(K_P2): 763 case KVAL(K_P2):
774 k_cur(vc, KVAL(K_DOWN), 0); 764 k_cur(vc, KVAL(K_DOWN), 0);
775 return; 765 return;
776 case KVAL(K_P3): 766 case KVAL(K_P3):
777 k_fn(vc, KVAL(K_PGDN), 0); 767 k_fn(vc, KVAL(K_PGDN), 0);
778 return; 768 return;
779 case KVAL(K_P4): 769 case KVAL(K_P4):
780 k_cur(vc, KVAL(K_LEFT), 0); 770 k_cur(vc, KVAL(K_LEFT), 0);
781 return; 771 return;
782 case KVAL(K_P6): 772 case KVAL(K_P6):
783 k_cur(vc, KVAL(K_RIGHT), 0); 773 k_cur(vc, KVAL(K_RIGHT), 0);
784 return; 774 return;
785 case KVAL(K_P7): 775 case KVAL(K_P7):
786 k_fn(vc, KVAL(K_FIND), 0); 776 k_fn(vc, KVAL(K_FIND), 0);
787 return; 777 return;
788 case KVAL(K_P8): 778 case KVAL(K_P8):
789 k_cur(vc, KVAL(K_UP), 0); 779 k_cur(vc, KVAL(K_UP), 0);
790 return; 780 return;
791 case KVAL(K_P9): 781 case KVAL(K_P9):
792 k_fn(vc, KVAL(K_PGUP), 0); 782 k_fn(vc, KVAL(K_PGUP), 0);
793 return; 783 return;
794 case KVAL(K_P5): 784 case KVAL(K_P5):
795 applkey(vc, 'G', vc_kbd_mode(kbd, VC_APPLIC)); 785 applkey(vc, 'G', vc_kbd_mode(kbd, VC_APPLIC));
796 return; 786 return;
797 } 787 }
788 }
798 789
799 put_queue(vc, pad_chars[value]); 790 put_queue(vc, pad_chars[value]);
800 if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF)) 791 if (value == KVAL(K_PENTER) && vc_kbd_mode(kbd, VC_CRLF))
@@ -880,6 +871,7 @@ static void k_lock(struct vc_data *vc, unsigned char value, char up_flag)
880{ 871{
881 if (up_flag || rep) 872 if (up_flag || rep)
882 return; 873 return;
874
883 chg_vc_kbd_lock(kbd, value); 875 chg_vc_kbd_lock(kbd, value);
884} 876}
885 877
@@ -888,6 +880,7 @@ static void k_slock(struct vc_data *vc, unsigned char value, char up_flag)
888 k_shift(vc, value, up_flag); 880 k_shift(vc, value, up_flag);
889 if (up_flag || rep) 881 if (up_flag || rep)
890 return; 882 return;
883
891 chg_vc_kbd_slock(kbd, value); 884 chg_vc_kbd_slock(kbd, value);
892 /* try to make Alt, oops, AltGr and such work */ 885 /* try to make Alt, oops, AltGr and such work */
893 if (!key_maps[kbd->lockstate ^ kbd->slockstate]) { 886 if (!key_maps[kbd->lockstate ^ kbd->slockstate]) {
@@ -925,12 +918,12 @@ static void k_brlcommit(struct vc_data *vc, unsigned int pattern, char up_flag)
925 918
926static void k_brl(struct vc_data *vc, unsigned char value, char up_flag) 919static void k_brl(struct vc_data *vc, unsigned char value, char up_flag)
927{ 920{
928 static unsigned pressed,committing; 921 static unsigned pressed, committing;
929 static unsigned long releasestart; 922 static unsigned long releasestart;
930 923
931 if (kbd->kbdmode != VC_UNICODE) { 924 if (kbd->kbdmode != VC_UNICODE) {
932 if (!up_flag) 925 if (!up_flag)
933 printk("keyboard mode must be unicode for braille patterns\n"); 926 pr_warning("keyboard mode must be unicode for braille patterns\n");
934 return; 927 return;
935 } 928 }
936 929
@@ -942,32 +935,28 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag)
942 if (value > 8) 935 if (value > 8)
943 return; 936 return;
944 937
945 if (up_flag) { 938 if (!up_flag) {
946 if (brl_timeout) {
947 if (!committing ||
948 time_after(jiffies,
949 releasestart + msecs_to_jiffies(brl_timeout))) {
950 committing = pressed;
951 releasestart = jiffies;
952 }
953 pressed &= ~(1 << (value - 1));
954 if (!pressed) {
955 if (committing) {
956 k_brlcommit(vc, committing, 0);
957 committing = 0;
958 }
959 }
960 } else {
961 if (committing) {
962 k_brlcommit(vc, committing, 0);
963 committing = 0;
964 }
965 pressed &= ~(1 << (value - 1));
966 }
967 } else {
968 pressed |= 1 << (value - 1); 939 pressed |= 1 << (value - 1);
969 if (!brl_timeout) 940 if (!brl_timeout)
970 committing = pressed; 941 committing = pressed;
942 } else if (brl_timeout) {
943 if (!committing ||
944 time_after(jiffies,
945 releasestart + msecs_to_jiffies(brl_timeout))) {
946 committing = pressed;
947 releasestart = jiffies;
948 }
949 pressed &= ~(1 << (value - 1));
950 if (!pressed && committing) {
951 k_brlcommit(vc, committing, 0);
952 committing = 0;
953 }
954 } else {
955 if (committing) {
956 k_brlcommit(vc, committing, 0);
957 committing = 0;
958 }
959 pressed &= ~(1 << (value - 1));
971 } 960 }
972} 961}
973 962
@@ -988,6 +977,7 @@ void setledstate(struct kbd_struct *kbd, unsigned int led)
988 kbd->ledmode = LED_SHOW_IOCTL; 977 kbd->ledmode = LED_SHOW_IOCTL;
989 } else 978 } else
990 kbd->ledmode = LED_SHOW_FLAGS; 979 kbd->ledmode = LED_SHOW_FLAGS;
980
991 set_leds(); 981 set_leds();
992} 982}
993 983
@@ -1075,7 +1065,7 @@ static const unsigned short x86_keycodes[256] =
1075 332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 }; 1065 332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 };
1076 1066
1077#ifdef CONFIG_SPARC 1067#ifdef CONFIG_SPARC
1078static int sparc_l1_a_state = 0; 1068static int sparc_l1_a_state;
1079extern void sun_do_break(void); 1069extern void sun_do_break(void);
1080#endif 1070#endif
1081 1071
@@ -1085,52 +1075,54 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
1085 int code; 1075 int code;
1086 1076
1087 switch (keycode) { 1077 switch (keycode) {
1088 case KEY_PAUSE:
1089 put_queue(vc, 0xe1);
1090 put_queue(vc, 0x1d | up_flag);
1091 put_queue(vc, 0x45 | up_flag);
1092 break;
1093 1078
1094 case KEY_HANGEUL: 1079 case KEY_PAUSE:
1095 if (!up_flag) 1080 put_queue(vc, 0xe1);
1096 put_queue(vc, 0xf2); 1081 put_queue(vc, 0x1d | up_flag);
1097 break; 1082 put_queue(vc, 0x45 | up_flag);
1083 break;
1098 1084
1099 case KEY_HANJA: 1085 case KEY_HANGEUL:
1100 if (!up_flag) 1086 if (!up_flag)
1101 put_queue(vc, 0xf1); 1087 put_queue(vc, 0xf2);
1102 break; 1088 break;
1103 1089
1104 case KEY_SYSRQ: 1090 case KEY_HANJA:
1105 /* 1091 if (!up_flag)
1106 * Real AT keyboards (that's what we're trying 1092 put_queue(vc, 0xf1);
1107 * to emulate here emit 0xe0 0x2a 0xe0 0x37 when 1093 break;
1108 * pressing PrtSc/SysRq alone, but simply 0x54
1109 * when pressing Alt+PrtSc/SysRq.
1110 */
1111 if (sysrq_alt) {
1112 put_queue(vc, 0x54 | up_flag);
1113 } else {
1114 put_queue(vc, 0xe0);
1115 put_queue(vc, 0x2a | up_flag);
1116 put_queue(vc, 0xe0);
1117 put_queue(vc, 0x37 | up_flag);
1118 }
1119 break;
1120 1094
1121 default: 1095 case KEY_SYSRQ:
1122 if (keycode > 255) 1096 /*
1123 return -1; 1097 * Real AT keyboards (that's what we're trying
1098 * to emulate here emit 0xe0 0x2a 0xe0 0x37 when
1099 * pressing PrtSc/SysRq alone, but simply 0x54
1100 * when pressing Alt+PrtSc/SysRq.
1101 */
1102 if (test_bit(KEY_LEFTALT, key_down) ||
1103 test_bit(KEY_RIGHTALT, key_down)) {
1104 put_queue(vc, 0x54 | up_flag);
1105 } else {
1106 put_queue(vc, 0xe0);
1107 put_queue(vc, 0x2a | up_flag);
1108 put_queue(vc, 0xe0);
1109 put_queue(vc, 0x37 | up_flag);
1110 }
1111 break;
1124 1112
1125 code = x86_keycodes[keycode]; 1113 default:
1126 if (!code) 1114 if (keycode > 255)
1127 return -1; 1115 return -1;
1128 1116
1129 if (code & 0x100) 1117 code = x86_keycodes[keycode];
1130 put_queue(vc, 0xe0); 1118 if (!code)
1131 put_queue(vc, (code & 0x7f) | up_flag); 1119 return -1;
1132 1120
1133 break; 1121 if (code & 0x100)
1122 put_queue(vc, 0xe0);
1123 put_queue(vc, (code & 0x7f) | up_flag);
1124
1125 break;
1134 } 1126 }
1135 1127
1136 return 0; 1128 return 0;
@@ -1153,6 +1145,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, unsigned char u
1153static void kbd_rawcode(unsigned char data) 1145static void kbd_rawcode(unsigned char data)
1154{ 1146{
1155 struct vc_data *vc = vc_cons[fg_console].d; 1147 struct vc_data *vc = vc_cons[fg_console].d;
1148
1156 kbd = kbd_table + vc->vc_num; 1149 kbd = kbd_table + vc->vc_num;
1157 if (kbd->kbdmode == VC_RAW) 1150 if (kbd->kbdmode == VC_RAW)
1158 put_queue(vc, data); 1151 put_queue(vc, data);
@@ -1162,10 +1155,12 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1162{ 1155{
1163 struct vc_data *vc = vc_cons[fg_console].d; 1156 struct vc_data *vc = vc_cons[fg_console].d;
1164 unsigned short keysym, *key_map; 1157 unsigned short keysym, *key_map;
1165 unsigned char type, raw_mode; 1158 unsigned char type;
1159 bool raw_mode;
1166 struct tty_struct *tty; 1160 struct tty_struct *tty;
1167 int shift_final; 1161 int shift_final;
1168 struct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down }; 1162 struct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down };
1163 int rc;
1169 1164
1170 tty = vc->vc_tty; 1165 tty = vc->vc_tty;
1171 1166
@@ -1176,8 +1171,6 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1176 1171
1177 kbd = kbd_table + vc->vc_num; 1172 kbd = kbd_table + vc->vc_num;
1178 1173
1179 if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
1180 sysrq_alt = down ? keycode : 0;
1181#ifdef CONFIG_SPARC 1174#ifdef CONFIG_SPARC
1182 if (keycode == KEY_STOP) 1175 if (keycode == KEY_STOP)
1183 sparc_l1_a_state = down; 1176 sparc_l1_a_state = down;
@@ -1185,29 +1178,16 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1185 1178
1186 rep = (down == 2); 1179 rep = (down == 2);
1187 1180
1188 if ((raw_mode = (kbd->kbdmode == VC_RAW)) && !hw_raw) 1181 raw_mode = (kbd->kbdmode == VC_RAW);
1182 if (raw_mode && !hw_raw)
1189 if (emulate_raw(vc, keycode, !down << 7)) 1183 if (emulate_raw(vc, keycode, !down << 7))
1190 if (keycode < BTN_MISC && printk_ratelimit()) 1184 if (keycode < BTN_MISC && printk_ratelimit())
1191 printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode); 1185 pr_warning("can't emulate rawmode for keycode %d\n",
1186 keycode);
1192 1187
1193#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
1194 if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
1195 if (!sysrq_down) {
1196 sysrq_down = down;
1197 sysrq_alt_use = sysrq_alt;
1198 }
1199 return;
1200 }
1201 if (sysrq_down && !down && keycode == sysrq_alt_use)
1202 sysrq_down = 0;
1203 if (sysrq_down && down && !rep) {
1204 handle_sysrq(kbd_sysrq_xlate[keycode], tty);
1205 return;
1206 }
1207#endif
1208#ifdef CONFIG_SPARC 1188#ifdef CONFIG_SPARC
1209 if (keycode == KEY_A && sparc_l1_a_state) { 1189 if (keycode == KEY_A && sparc_l1_a_state) {
1210 sparc_l1_a_state = 0; 1190 sparc_l1_a_state = false;
1211 sun_do_break(); 1191 sun_do_break();
1212 } 1192 }
1213#endif 1193#endif
@@ -1229,7 +1209,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1229 put_queue(vc, (keycode >> 7) | 0x80); 1209 put_queue(vc, (keycode >> 7) | 0x80);
1230 put_queue(vc, keycode | 0x80); 1210 put_queue(vc, keycode | 0x80);
1231 } 1211 }
1232 raw_mode = 1; 1212 raw_mode = true;
1233 } 1213 }
1234 1214
1235 if (down) 1215 if (down)
@@ -1252,29 +1232,32 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1252 param.ledstate = kbd->ledflagstate; 1232 param.ledstate = kbd->ledflagstate;
1253 key_map = key_maps[shift_final]; 1233 key_map = key_maps[shift_final];
1254 1234
1255 if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_KEYCODE, &param) == NOTIFY_STOP || !key_map) { 1235 rc = atomic_notifier_call_chain(&keyboard_notifier_list,
1256 atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNBOUND_KEYCODE, &param); 1236 KBD_KEYCODE, &param);
1237 if (rc == NOTIFY_STOP || !key_map) {
1238 atomic_notifier_call_chain(&keyboard_notifier_list,
1239 KBD_UNBOUND_KEYCODE, &param);
1257 compute_shiftstate(); 1240 compute_shiftstate();
1258 kbd->slockstate = 0; 1241 kbd->slockstate = 0;
1259 return; 1242 return;
1260 } 1243 }
1261 1244
1262 if (keycode >= NR_KEYS) 1245 if (keycode < NR_KEYS)
1263 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
1264 keysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1));
1265 else
1266 return;
1267 else
1268 keysym = key_map[keycode]; 1246 keysym = key_map[keycode];
1247 else if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
1248 keysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1));
1249 else
1250 return;
1269 1251
1270 type = KTYP(keysym); 1252 type = KTYP(keysym);
1271 1253
1272 if (type < 0xf0) { 1254 if (type < 0xf0) {
1273 param.value = keysym; 1255 param.value = keysym;
1274 if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_UNICODE, &param) == NOTIFY_STOP) 1256 rc = atomic_notifier_call_chain(&keyboard_notifier_list,
1275 return; 1257 KBD_UNICODE, &param);
1276 if (down && !raw_mode) 1258 if (rc != NOTIFY_STOP)
1277 to_utf8(vc, keysym); 1259 if (down && !raw_mode)
1260 to_utf8(vc, keysym);
1278 return; 1261 return;
1279 } 1262 }
1280 1263
@@ -1288,9 +1271,11 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1288 keysym = key_map[keycode]; 1271 keysym = key_map[keycode];
1289 } 1272 }
1290 } 1273 }
1291 param.value = keysym;
1292 1274
1293 if (atomic_notifier_call_chain(&keyboard_notifier_list, KBD_KEYSYM, &param) == NOTIFY_STOP) 1275 param.value = keysym;
1276 rc = atomic_notifier_call_chain(&keyboard_notifier_list,
1277 KBD_KEYSYM, &param);
1278 if (rc == NOTIFY_STOP)
1294 return; 1279 return;
1295 1280
1296 if (raw_mode && type != KT_SPEC && type != KT_SHIFT) 1281 if (raw_mode && type != KT_SPEC && type != KT_SHIFT)