[PATCH] chardev: GPIO for SCx200 & PC-8736x: use dev_dbg in common module
[firefly-linux-kernel-4.4.55.git] / drivers / char / keyboard.c
index 935670a3cd987a2ea13e4412873b9ed8ca41e17d..4bb3d22726046fbcc4cd7cbbb4dbd69ce15b9edb 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/vt_kern.h>
 #include <linux/sysrq.h>
 #include <linux/input.h>
+#include <linux/reboot.h>
 
 static void kbd_disconnect(struct input_handle *handle);
 extern void ctrl_alt_del(void);
@@ -150,6 +151,7 @@ unsigned char kbd_sysrq_xlate[KEY_MAX + 1] =
         "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;
+static int sysrq_alt_use;
 #endif
 static int sysrq_alt;
 
@@ -672,7 +674,7 @@ static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struc
  */
 static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
 {
-       static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
+       static const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
        value = ret_diacr[value];
        k_deadunicode(vc, value, up_flag, regs);
 }
@@ -709,8 +711,8 @@ static void k_cur(struct vc_data *vc, unsigned char value, char up_flag, struct
 
 static void k_pad(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
 {
-       static const char *pad_chars = "0123456789+-*/\015,.?()#";
-       static const char *app_map = "pqrstuvwxylSRQMnnmPQS";
+       static const char pad_chars[] = "0123456789+-*/\015,.?()#";
+       static const char app_map[] = "pqrstuvwxylSRQMnnmPQS";
 
        if (up_flag)
                return;         /* no action, if this is a key release */
@@ -860,9 +862,32 @@ static void k_slock(struct vc_data *vc, unsigned char value, char up_flag, struc
 }
 
 /* by default, 300ms interval for combination release */
-static long brl_timeout = 300;
-MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for combination on first release, < 0 for dead characters)");
-module_param(brl_timeout, long, 0644);
+static unsigned brl_timeout = 300;
+MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for commit on first key release)");
+module_param(brl_timeout, uint, 0644);
+
+static unsigned brl_nbchords = 1;
+MODULE_PARM_DESC(brl_nbchords, "Number of chords that produce a braille pattern (0 for dead chords)");
+module_param(brl_nbchords, uint, 0644);
+
+static void k_brlcommit(struct vc_data *vc, unsigned int pattern, char up_flag, struct pt_regs *regs)
+{
+       static unsigned long chords;
+       static unsigned committed;
+
+       if (!brl_nbchords)
+               k_deadunicode(vc, BRL_UC_ROW | pattern, up_flag, regs);
+       else {
+               committed |= pattern;
+               chords++;
+               if (chords == brl_nbchords) {
+                       k_unicode(vc, BRL_UC_ROW | committed, up_flag, regs);
+                       chords = 0;
+                       committed = 0;
+               }
+       }
+}
+
 static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
 {
        static unsigned pressed,committing;
@@ -882,11 +907,6 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct
        if (value > 8)
                return;
 
-       if (brl_timeout < 0) {
-               k_deadunicode(vc, BRL_UC_ROW | (1 << (value - 1)), up_flag, regs);
-               return;
-       }
-
        if (up_flag) {
                if (brl_timeout) {
                        if (!committing ||
@@ -897,13 +917,13 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct
                        pressed &= ~(1 << (value - 1));
                        if (!pressed) {
                                if (committing) {
-                                       k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
+                                       k_brlcommit(vc, committing, 0, regs);
                                        committing = 0;
                                }
                        }
                } else {
                        if (committing) {
-                               k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
+                               k_brlcommit(vc, committing, 0, regs);
                                committing = 0;
                        }
                        pressed &= ~(1 << (value - 1));
@@ -1017,7 +1037,7 @@ static void kbd_refresh_leds(struct input_handle *handle)
 #define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
                        ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
 
-static unsigned short x86_keycodes[256] =
+static const 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,
         32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
@@ -1055,11 +1075,13 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode,
                        put_queue(vc, 0x1d | up_flag);
                        put_queue(vc, 0x45 | up_flag);
                        return 0;
-               case KEY_HANGUEL:
-                       if (!up_flag) put_queue(vc, 0xf1);
+               case KEY_HANGEUL:
+                       if (!up_flag)
+                               put_queue(vc, 0xf2);
                        return 0;
                case KEY_HANJA:
-                       if (!up_flag) put_queue(vc, 0xf2);
+                       if (!up_flag)
+                               put_queue(vc, 0xf1);
                        return 0;
        }
 
@@ -1124,7 +1146,7 @@ static void kbd_keycode(unsigned int keycode, int down,
        kbd = kbd_table + fg_console;
 
        if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
-               sysrq_alt = down;
+               sysrq_alt = down ? keycode : 0;
 #ifdef CONFIG_SPARC
        if (keycode == KEY_STOP)
                sparc_l1_a_state = down;
@@ -1144,9 +1166,14 @@ static void kbd_keycode(unsigned int keycode, int down,
 
 #ifdef CONFIG_MAGIC_SYSRQ             /* Handle the SysRq Hack */
        if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
-               sysrq_down = down;
+               if (!sysrq_down) {
+                       sysrq_down = down;
+                       sysrq_alt_use = sysrq_alt;
+               }
                return;
        }
+       if (sysrq_down && !down && keycode == sysrq_alt_use)
+               sysrq_down = 0;
        if (sysrq_down && down && !rep) {
                handle_sysrq(kbd_sysrq_xlate[keycode], regs, tty);
                return;