Lines Matching +full:standard +full:- +full:vt
1 // SPDX-License-Identifier: GPL-2.0
15 * 11-11-96: SAK should now work in the raw mode (Martin Mares)
18 * Merge with the m68k keyboard driver and split-off of the PC low-level
21 * 27-05-97: Added support for the Magic SysRq Key (Martin Mares)
22 * 30-07-98: Dead keys redone, aeb@cwi.nl.
23 * 21-08-02: Converted to input API, major cleanup. (Vojtech Pavlik)
117 255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1,
118 NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1,
119 255, NR_LOCK - 1, 255, NR_BRL - 1
141 static unsigned int ledstate = -1U; /* undefined */
180 d->error = input_get_keycode(handle->dev, &d->ke); in getkeycode_helper()
182 return d->error == 0; /* stop as soon as we successfully get one */ in getkeycode_helper()
193 .error = -ENODEV, in getkeycode()
207 d->error = input_set_keycode(handle->dev, &d->ke); in setkeycode_helper()
209 return d->error == 0; /* stop as soon as we successfully set one */ in setkeycode_helper()
220 .error = -ENODEV, in setkeycode()
238 struct input_dev *dev = handle->dev; in kd_sound_helper()
240 if (test_bit(EV_SND, dev->evbit)) { in kd_sound_helper()
241 if (test_bit(SND_TONE, dev->sndbit)) { in kd_sound_helper()
246 if (test_bit(SND_BELL, dev->sndbit)) in kd_sound_helper()
279 struct input_dev *dev = handle->dev; in kbd_rate_helper()
282 if (test_bit(EV_REP, dev->evbit)) { in kbd_rate_helper()
291 rpt[1].delay = dev->rep[REP_DELAY]; in kbd_rate_helper()
292 rpt[1].period = dev->rep[REP_PERIOD]; in kbd_rate_helper()
313 tty_insert_flip_char(&vc->port, ch, 0); in put_queue()
314 tty_schedule_flip(&vc->port); in put_queue()
320 tty_insert_flip_char(&vc->port, *cp, 0); in puts_queue()
323 tty_schedule_flip(&vc->port); in puts_queue()
337 * they produce ASCII, or they produce some user-assigned
339 * in utf-8 already.
369 * Called after returning from RAW mode or when changing consoles - recompute
396 /* We still have to export this method to vt.c */
431 if (kbd->kbdmode == VC_UNICODE) in handle_diacr()
435 if (c != -1) in handle_diacr()
448 if (kbd->kbdmode == VC_UNICODE) in fn_enter()
452 if (c != -1) in fn_enter()
489 struct tty_struct *tty = vc->port.tty; in fn_hold()
499 if (tty->stopped) in fn_hold()
514 * Bind this to Shift-NumLock if you work in application keypad mode
536 if (want_console != -1) in fn_dec_console()
539 for (i = cur - 1; i != cur; i--) { in fn_dec_console()
540 if (i == -1) in fn_dec_console()
541 i = MAX_NR_CONSOLES - 1; in fn_dec_console()
553 if (want_console != -1) in fn_inc_console()
567 tty_insert_flip_char(&vc->port, 0, TTY_BREAK); in fn_send_intr()
568 tty_schedule_flip(&vc->port); in fn_send_intr()
636 if ((kbd->kbdmode == VC_RAW || in k_spec()
637 kbd->kbdmode == VC_MEDIUMRAW || in k_spec()
638 kbd->kbdmode == VC_OFF) && in k_spec()
646 pr_err("k_lowercase was called - impossible\n"); in k_lowercase()
662 if (kbd->kbdmode == VC_UNICODE) in k_unicode()
666 if (c != -1) in k_unicode()
695 * Obsolete - for backwards compatibility only
719 '-', /* dead_stroke */ in k_dead()
769 static const char pad_chars[] = "0123456789+-*/\015,.?()#"; in k_pad()
848 shift_down[value]--; in k_shift()
859 if (kbd->kbdmode == VC_UNICODE) in k_shift()
891 value -= 10; in k_ascii()
919 if (!key_maps[kbd->lockstate ^ kbd->slockstate]) { in k_slock()
920 kbd->slockstate = 0; in k_slock()
957 if (kbd->kbdmode != VC_UNICODE) { in k_brl()
972 pressed |= 1 << (value - 1); in k_brl()
982 pressed &= ~(1 << (value - 1)); in k_brl()
992 pressed &= ~(1 << (value - 1)); in k_brl()
1006 container_of(cdev->trigger, struct kbd_led_trigger, trigger); in kbd_led_trigger_activate()
1009 if (ledstate != -1U) in kbd_led_trigger_activate()
1010 led_trigger_event(&trigger->trigger, in kbd_led_trigger_activate()
1011 ledstate & trigger->mask ? in kbd_led_trigger_activate()
1030 KBD_LED_TRIGGER(VC_SCROLLOCK, "kbd-scrolllock"),
1031 KBD_LED_TRIGGER(VC_NUMLOCK, "kbd-numlock"),
1032 KBD_LED_TRIGGER(VC_CAPSLOCK, "kbd-capslock"),
1033 KBD_LED_TRIGGER(VC_KANALOCK, "kbd-kanalock"),
1035 KBD_LOCKSTATE_TRIGGER(VC_SHIFTLOCK, "kbd-shiftlock"),
1036 KBD_LOCKSTATE_TRIGGER(VC_ALTGRLOCK, "kbd-altgrlock"),
1037 KBD_LOCKSTATE_TRIGGER(VC_CTRLLOCK, "kbd-ctrllock"),
1038 KBD_LOCKSTATE_TRIGGER(VC_ALTLOCK, "kbd-altlock"),
1039 KBD_LOCKSTATE_TRIGGER(VC_SHIFTLLOCK, "kbd-shiftllock"),
1040 KBD_LOCKSTATE_TRIGGER(VC_SHIFTRLOCK, "kbd-shiftrlock"),
1041 KBD_LOCKSTATE_TRIGGER(VC_CTRLLLOCK, "kbd-ctrlllock"),
1042 KBD_LOCKSTATE_TRIGGER(VC_CTRLRLOCK, "kbd-ctrlrlock"),
1055 if (changed & trigger->mask) in kbd_propagate_led_state()
1056 led_trigger_event(&trigger->trigger, in kbd_propagate_led_state()
1057 new_state & trigger->mask ? in kbd_propagate_led_state()
1066 if (test_bit(EV_LED, handle->dev->evbit)) in kbd_update_leds_helper()
1091 if (test_bit(EV_LED, handle->dev->evbit)) { in kbd_update_leds_helper()
1130 kb->ledmode = LED_SHOW_IOCTL; in setledstate()
1132 kb->ledmode = LED_SHOW_FLAGS; in setledstate()
1142 if (kb->ledmode == LED_SHOW_IOCTL) in getleds()
1145 return kb->ledflagstate; in getleds()
1149 * vt_get_leds - helper for braille console
1170 * vt_set_led_state - set LED state of a console
1174 * Set the LEDs on a console. This is a wrapper for the VT layer
1184 * vt_kbd_con_start - Keyboard side of console start
1187 * Handle console start. This is a wrapper for the VT layer
1194 * but not during an -rc release!
1207 * vt_kbd_con_stop - Keyboard side of console stop
1210 * Handle console stop. This is a wrapper for the VT layer
1224 * This is the tasklet that updates LED state of LEDs using standard
1227 * but we already getting updates from the VT to update led state.
1236 leds |= (unsigned int)kbd->lockstate << 8; in kbd_bh()
1252 #define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
1253 … ((dev)->id.bustype == BUS_I8042) && ((dev)->id.vendor == 0x0001) && ((dev)->id.product == 0x0001))
1320 return -1; in emulate_raw()
1324 return -1; in emulate_raw()
1343 return -1; in emulate_raw()
1354 kbd = kbd_table + vc->vc_num; in kbd_rawcode()
1355 if (kbd->kbdmode == VC_RAW) in kbd_rawcode()
1370 tty = vc->port.tty; in kbd_keycode()
1372 if (tty && (!tty->driver_data)) { in kbd_keycode()
1374 tty->driver_data = vc; in kbd_keycode()
1377 kbd = kbd_table + vc->vc_num; in kbd_keycode()
1386 raw_mode = (kbd->kbdmode == VC_RAW); in kbd_keycode()
1400 if (kbd->kbdmode == VC_MEDIUMRAW) { in kbd_keycode()
1436 param.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate; in kbd_keycode()
1437 param.ledstate = kbd->ledflagstate; in kbd_keycode()
1446 kbd->slockstate = 0; in kbd_keycode()
1453 keysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1)); in kbd_keycode()
1469 type -= 0xf0; in kbd_keycode()
1486 if ((raw_mode || kbd->kbdmode == VC_OFF) && type != KT_SPEC && type != KT_SHIFT) in kbd_keycode()
1491 param.ledstate = kbd->ledflagstate; in kbd_keycode()
1495 kbd->slockstate = 0; in kbd_keycode()
1504 if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) in kbd_event()
1507 kbd_keycode(event_code, value, HW_RAW(handle->dev)); in kbd_event()
1520 if (test_bit(EV_SND, dev->evbit)) in kbd_match()
1523 if (test_bit(EV_KEY, dev->evbit)) { in kbd_match()
1525 if (test_bit(i, dev->keybit)) in kbd_match()
1528 if (test_bit(i, dev->keybit)) in kbd_match()
1539 * function, we should decide which VT to bind that keyboard to initially.
1549 return -ENOMEM; in kbd_connect()
1551 handle->dev = dev; in kbd_connect()
1552 handle->handler = handler; in kbd_connect()
1553 handle->name = "kbd"; in kbd_connect()
1587 if (ledstate != -1U) in kbd_start()
1649 * vt_do_diacrit - diacritical table updates
1673 return -ENOMEM; in vt_do_diacrit()
1690 if (put_user(asize, &a->kb_cnt)) in vt_do_diacrit()
1691 ret = -EFAULT; in vt_do_diacrit()
1692 else if (copy_to_user(a->kbdiacr, dia, in vt_do_diacrit()
1694 ret = -EFAULT; in vt_do_diacrit()
1706 return -ENOMEM; in vt_do_diacrit()
1717 if (put_user(asize, &a->kb_cnt)) in vt_do_diacrit()
1718 ret = -EFAULT; in vt_do_diacrit()
1719 else if (copy_to_user(a->kbdiacruc, buf, in vt_do_diacrit()
1721 ret = -EFAULT; in vt_do_diacrit()
1734 return -EPERM; in vt_do_diacrit()
1735 if (get_user(ct, &a->kb_cnt)) in vt_do_diacrit()
1736 return -EFAULT; in vt_do_diacrit()
1738 return -EINVAL; in vt_do_diacrit()
1742 dia = memdup_user(a->kbdiacr, in vt_do_diacrit()
1771 return -EPERM; in vt_do_diacrit()
1773 if (get_user(ct, &a->kb_cnt)) in vt_do_diacrit()
1774 return -EFAULT; in vt_do_diacrit()
1777 return -EINVAL; in vt_do_diacrit()
1780 buf = memdup_user(a->kbdiacruc, in vt_do_diacrit()
1799 * vt_do_kdskbmode - set keyboard mode ioctl
1815 kb->kbdmode = VC_RAW; in vt_do_kdskbmode()
1818 kb->kbdmode = VC_MEDIUMRAW; in vt_do_kdskbmode()
1821 kb->kbdmode = VC_XLATE; in vt_do_kdskbmode()
1825 kb->kbdmode = VC_UNICODE; in vt_do_kdskbmode()
1829 kb->kbdmode = VC_OFF; in vt_do_kdskbmode()
1832 ret = -EINVAL; in vt_do_kdskbmode()
1839 * vt_do_kdskbmeta - set keyboard meta state
1861 ret = -EINVAL; in vt_do_kdskbmeta()
1874 return -EFAULT; in vt_do_kbkeycode_ioctl()
1879 kc = put_user(kc, &user_kbkc->keycode); in vt_do_kbkeycode_ioctl()
1883 return -EPERM; in vt_do_kbkeycode_ioctl()
1903 return -EFAULT; in vt_do_kdsk_ioctl()
1915 if (kb->kbdmode != VC_UNICODE && KTYP(val) >= NR_TYPES) in vt_do_kdsk_ioctl()
1920 return put_user(val, &user_kbe->kb_value); in vt_do_kdsk_ioctl()
1923 return -EPERM; in vt_do_kdsk_ioctl()
1932 keymap_count--; in vt_do_kdsk_ioctl()
1941 return -EINVAL; in vt_do_kdsk_ioctl()
1943 if (kb->kbdmode != VC_UNICODE) in vt_do_kdsk_ioctl()
1944 return -EINVAL; in vt_do_kdsk_ioctl()
1946 /* ++Geert: non-PC keyboards may generate keycode zero */ in vt_do_kdsk_ioctl()
1955 return -ENOMEM; in vt_do_kdsk_ioctl()
1965 return -EPERM; in vt_do_kdsk_ioctl()
1984 return -EPERM; in vt_do_kdsk_ioctl()
2016 ret = -ENOMEM; in vt_do_kdgkb_ioctl()
2022 ret = -EFAULT; in vt_do_kdgkb_ioctl()
2025 kbs->kb_string[sizeof(kbs->kb_string)-1] = '\0'; in vt_do_kdgkb_ioctl()
2026 i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC); in vt_do_kdgkb_ioctl()
2031 ssize_t len = sizeof(user_kdgkb->kb_string); in vt_do_kdgkb_ioctl()
2034 len = strlcpy(kbs->kb_string, func_table[i] ? : "", len); in vt_do_kdgkb_ioctl()
2037 ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string, in vt_do_kdgkb_ioctl()
2038 len + 1) ? -EFAULT : 0; in vt_do_kdgkb_ioctl()
2044 ret = -EPERM; in vt_do_kdgkb_ioctl()
2056 first_free = funcbufptr + (funcbufsize - funcbufleft); in vt_do_kdgkb_ioctl()
2064 delta = (q ? -strlen(q) : 1) + strlen(kbs->kb_string); in vt_do_kdgkb_ioctl()
2069 memmove(fj + delta, fj, first_free - fj); in vt_do_kdgkb_ioctl()
2076 funcbufleft -= delta; in vt_do_kdgkb_ioctl()
2079 while (sz < funcbufsize - funcbufleft + delta) in vt_do_kdgkb_ioctl()
2087 ret = -ENOMEM; in vt_do_kdgkb_ioctl()
2097 memmove(fnw, funcbufptr, fj - funcbufptr); in vt_do_kdgkb_ioctl()
2100 func_table[k] = fnw + (func_table[k] - funcbufptr); in vt_do_kdgkb_ioctl()
2104 memmove(fnw + (fj - funcbufptr) + delta, fj, first_free - fj); in vt_do_kdgkb_ioctl()
2107 func_table[k] = fnw + (func_table[k] - funcbufptr) + delta; in vt_do_kdgkb_ioctl()
2112 funcbufleft = funcbufleft - delta + sz - funcbufsize; in vt_do_kdgkb_ioctl()
2116 strcpy(func_table[i], kbs->kb_string); in vt_do_kdgkb_ioctl()
2134 /* don't use them - they will go away without warning */ in vt_do_kdskled()
2137 ucval = kb->ledflagstate | (kb->default_ledflagstate << 4); in vt_do_kdskled()
2143 return -EPERM; in vt_do_kdskled()
2145 return -EINVAL; in vt_do_kdskled()
2147 kb->ledflagstate = (arg & 7); in vt_do_kdskled()
2148 kb->default_ledflagstate = ((arg >> 4) & 7); in vt_do_kdskled()
2161 return -EPERM; in vt_do_kdskled()
2165 return -ENOIOCTLCMD; in vt_do_kdskled()
2172 switch (kb->kbdmode) { in vt_do_kdgkbmode()
2187 * vt_do_kdgkbmeta - report meta status
2200 * vt_reset_unicode - reset the unicode status
2215 * vt_get_shiftstate - shift bit state
2218 * this to support some oddities in the vt layer.
2227 * vt_reset_keyboard - reset keyboard state
2243 kb->lockstate = 0; in vt_reset_keyboard()
2244 kb->slockstate = 0; in vt_reset_keyboard()
2246 kb->ledmode = LED_SHOW_FLAGS; in vt_reset_keyboard()
2247 kb->ledflagstate = kb->default_ledflagstate; in vt_reset_keyboard()
2255 * vt_get_kbd_mode_bit - read keyboard status bits
2259 * Report back a vt mode bit. We do this without locking so the
2270 * vt_set_kbd_mode_bit - read keyboard status bits
2274 * Set a vt mode bit. We do this without locking so the
2289 * vt_clr_kbd_mode_bit - read keyboard status bits
2293 * Report back a vt mode bit. We do this without locking so the