Lines Matching +full:led +full:- +full:cur

1 // SPDX-License-Identifier: GPL-2.0
12 * dynamic function/string keys, led setting, Sept 1994
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)
116 [ KT_FN ] = ARRAY_SIZE(func_table) - 1,
117 [ KT_SPEC ] = ARRAY_SIZE(fn_handler) - 1,
118 [ KT_PAD ] = NR_PAD - 1,
119 [ KT_DEAD ] = NR_DEAD - 1,
122 [ KT_SHIFT ] = NR_SHIFT - 1,
124 [ KT_ASCII ] = NR_ASCII - 1,
125 [ KT_LOCK ] = NR_LOCK - 1,
127 [ KT_SLOCK ] = NR_LOCK - 1,
129 [ KT_BRL ] = NR_BRL - 1,
154 static unsigned int ledstate = -1U; /* undefined */
194 d->error = input_get_keycode(handle->dev, &d->ke); in getkeycode_helper()
196 return d->error == 0; /* stop as soon as we successfully get one */ in getkeycode_helper()
207 .error = -ENODEV, in getkeycode()
221 d->error = input_set_keycode(handle->dev, &d->ke); in setkeycode_helper()
223 return d->error == 0; /* stop as soon as we successfully set one */ in setkeycode_helper()
234 .error = -ENODEV, in setkeycode()
252 struct input_dev *dev = handle->dev; in kd_sound_helper()
254 if (test_bit(EV_SND, dev->evbit)) { in kd_sound_helper()
255 if (test_bit(SND_TONE, dev->sndbit)) { in kd_sound_helper()
260 if (test_bit(SND_BELL, dev->sndbit)) in kd_sound_helper()
293 struct input_dev *dev = handle->dev; in kbd_rate_helper()
296 if (test_bit(EV_REP, dev->evbit)) { in kbd_rate_helper()
305 rpt[1].delay = dev->rep[REP_DELAY]; in kbd_rate_helper()
306 rpt[1].period = dev->rep[REP_PERIOD]; in kbd_rate_helper()
327 tty_insert_flip_char(&vc->port, ch, 0); in put_queue()
328 tty_flip_buffer_push(&vc->port); in put_queue()
333 tty_insert_flip_string(&vc->port, cp, strlen(cp)); in puts_queue()
334 tty_flip_buffer_push(&vc->port); in puts_queue()
348 * they produce ASCII, or they produce some user-assigned
350 * in utf-8 already.
386 * Called after returning from RAW mode or when changing consoles - recompute
419 * When VT is switched, the keyboard led needs to be set once. in vt_set_leds_compute_shiftstate()
421 * keyboard LED is consistent with the state of the keyboard lock. in vt_set_leds_compute_shiftstate()
457 if (kbd->kbdmode == VC_UNICODE) in handle_diacr()
461 if (c != -1) in handle_diacr()
474 if (kbd->kbdmode == VC_UNICODE) in fn_enter()
478 if (c != -1) in fn_enter()
515 struct tty_struct *tty = vc->port.tty; in fn_hold()
525 if (tty->flow.stopped) in fn_hold()
540 * Bind this to Shift-NumLock if you work in application keypad mode
559 int i, cur = fg_console; in fn_dec_console() local
562 if (want_console != -1) in fn_dec_console()
563 cur = want_console; in fn_dec_console()
565 for (i = cur - 1; i != cur; i--) { in fn_dec_console()
566 if (i == -1) in fn_dec_console()
567 i = MAX_NR_CONSOLES - 1; in fn_dec_console()
576 int i, cur = fg_console; in fn_inc_console() local
579 if (want_console != -1) in fn_inc_console()
580 cur = want_console; in fn_inc_console()
582 for (i = cur+1; i != cur; i++) { in fn_inc_console()
593 tty_insert_flip_char(&vc->port, 0, TTY_BREAK); in fn_send_intr()
594 tty_flip_buffer_push(&vc->port); in fn_send_intr()
662 if ((kbd->kbdmode == VC_RAW || in k_spec()
663 kbd->kbdmode == VC_MEDIUMRAW || in k_spec()
664 kbd->kbdmode == VC_OFF) && in k_spec()
672 pr_err("k_lowercase was called - impossible\n"); in k_lowercase()
688 if (kbd->kbdmode == VC_UNICODE) in k_unicode()
692 if (c != -1) in k_unicode()
721 * Obsolete - for backwards compatibility only
745 '-', /* dead_stroke */ in k_dead()
795 static const char pad_chars[] = "0123456789+-*/\015,.?()#"; in k_pad()
874 shift_down[value]--; in k_shift()
885 if (kbd->kbdmode == VC_UNICODE) in k_shift()
917 value -= 10; in k_ascii()
945 if (!key_maps[kbd->lockstate ^ kbd->slockstate]) { in k_slock()
946 kbd->slockstate = 0; in k_slock()
983 if (kbd->kbdmode != VC_UNICODE) { in k_brl()
998 pressed |= BIT(value - 1); in k_brl()
1008 pressed &= ~BIT(value - 1); in k_brl()
1018 pressed &= ~BIT(value - 1); in k_brl()
1032 container_of(cdev->trigger, struct kbd_led_trigger, trigger); in kbd_led_trigger_activate()
1035 if (ledstate != -1U) in kbd_led_trigger_activate()
1036 led_trigger_event(&trigger->trigger, in kbd_led_trigger_activate()
1037 ledstate & trigger->mask ? in kbd_led_trigger_activate()
1056 KBD_LED_TRIGGER(VC_SCROLLOCK, "kbd-scrolllock"),
1057 KBD_LED_TRIGGER(VC_NUMLOCK, "kbd-numlock"),
1058 KBD_LED_TRIGGER(VC_CAPSLOCK, "kbd-capslock"),
1059 KBD_LED_TRIGGER(VC_KANALOCK, "kbd-kanalock"),
1061 KBD_LOCKSTATE_TRIGGER(VC_SHIFTLOCK, "kbd-shiftlock"),
1062 KBD_LOCKSTATE_TRIGGER(VC_ALTGRLOCK, "kbd-altgrlock"),
1063 KBD_LOCKSTATE_TRIGGER(VC_CTRLLOCK, "kbd-ctrllock"),
1064 KBD_LOCKSTATE_TRIGGER(VC_ALTLOCK, "kbd-altlock"),
1065 KBD_LOCKSTATE_TRIGGER(VC_SHIFTLLOCK, "kbd-shiftllock"),
1066 KBD_LOCKSTATE_TRIGGER(VC_SHIFTRLOCK, "kbd-shiftrlock"),
1067 KBD_LOCKSTATE_TRIGGER(VC_CTRLLLOCK, "kbd-ctrlllock"),
1068 KBD_LOCKSTATE_TRIGGER(VC_CTRLRLOCK, "kbd-ctrlrlock"),
1081 if (changed & trigger->mask) in kbd_propagate_led_state()
1082 led_trigger_event(&trigger->trigger, in kbd_propagate_led_state()
1083 new_state & trigger->mask ? in kbd_propagate_led_state()
1092 if (test_bit(EV_LED, handle->dev->evbit)) in kbd_update_leds_helper()
1117 if (test_bit(EV_LED, handle->dev->evbit)) { in kbd_update_leds_helper()
1150 void setledstate(struct kbd_struct *kb, unsigned int led) in setledstate() argument
1154 if (!(led & ~7)) { in setledstate()
1155 ledioctl = led; in setledstate()
1156 kb->ledmode = LED_SHOW_IOCTL; in setledstate()
1158 kb->ledmode = LED_SHOW_FLAGS; in setledstate()
1168 if (kb->ledmode == LED_SHOW_IOCTL) in getleds()
1171 return kb->ledflagstate; in getleds()
1175 * vt_get_leds - helper for braille console
1179 * Check the status of a keyboard led flag and report it back
1196 * vt_set_led_state - set LED state of a console
1198 * @leds: LED bits
1210 * vt_kbd_con_start - Keyboard side of console start
1217 * the LED updating. We can't do it yet because fn_hold calls stop_tty
1219 * don't hold the lock. We probably need to split out an LED lock
1220 * but not during an -rc release!
1233 * vt_kbd_con_stop - Keyboard side of console stop
1250 * This is the tasklet that updates LED state of LEDs using standard
1253 * but we already getting updates from the VT to update led state.
1262 leds |= (unsigned int)kbd->lockstate << 8; in kbd_bh()
1283 if (!test_bit(EV_MSC, dev->evbit) || !test_bit(MSC_RAW, dev->mscbit)) in kbd_is_hw_raw()
1286 return dev->id.bustype == BUS_I8042 && in kbd_is_hw_raw()
1287 dev->id.vendor == 0x0001 && dev->id.product == 0x0001; in kbd_is_hw_raw()
1355 return -1; in emulate_raw()
1359 return -1; in emulate_raw()
1381 return -1; in emulate_raw()
1392 kbd = &kbd_table[vc->vc_num]; in kbd_rawcode()
1393 if (kbd->kbdmode == VC_RAW) in kbd_rawcode()
1408 tty = vc->port.tty; in kbd_keycode()
1410 if (tty && (!tty->driver_data)) { in kbd_keycode()
1412 tty->driver_data = vc; in kbd_keycode()
1415 kbd = &kbd_table[vc->vc_num]; in kbd_keycode()
1424 raw_mode = (kbd->kbdmode == VC_RAW); in kbd_keycode()
1438 if (kbd->kbdmode == VC_MEDIUMRAW) { in kbd_keycode()
1471 param.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate; in kbd_keycode()
1472 param.ledstate = kbd->ledflagstate; in kbd_keycode()
1481 kbd->slockstate = 0; in kbd_keycode()
1488 keysym = U(K(KT_BRL, keycode - KEY_BRL_DOT1 + 1)); in kbd_keycode()
1504 type -= 0xf0; in kbd_keycode()
1521 if ((raw_mode || kbd->kbdmode == VC_OFF) && type != KT_SPEC && type != KT_SHIFT) in kbd_keycode()
1526 param.ledstate = kbd->ledflagstate; in kbd_keycode()
1530 kbd->slockstate = 0; in kbd_keycode()
1540 kbd_is_hw_raw(handle->dev)) in kbd_event()
1543 kbd_keycode(event_code, value, kbd_is_hw_raw(handle->dev)); in kbd_event()
1554 if (test_bit(EV_SND, dev->evbit)) in kbd_match()
1557 if (test_bit(EV_KEY, dev->evbit)) { in kbd_match()
1558 if (find_next_bit(dev->keybit, BTN_MISC, KEY_RESERVED) < in kbd_match()
1561 if (find_next_bit(dev->keybit, KEY_BRL_DOT10 + 1, in kbd_match()
1583 return -ENOMEM; in kbd_connect()
1585 handle->dev = dev; in kbd_connect()
1586 handle->handler = handler; in kbd_connect()
1587 handle->name = "kbd"; in kbd_connect()
1614 * Start keyboard handler on the new keyboard by refreshing LED state to
1621 if (ledstate != -1U) in kbd_start()
1683 * vt_do_diacrit - diacritical table updates
1707 return -ENOMEM; in vt_do_diacrit()
1724 if (put_user(asize, &a->kb_cnt)) in vt_do_diacrit()
1725 ret = -EFAULT; in vt_do_diacrit()
1726 else if (copy_to_user(a->kbdiacr, dia, in vt_do_diacrit()
1728 ret = -EFAULT; in vt_do_diacrit()
1740 return -ENOMEM; in vt_do_diacrit()
1751 if (put_user(asize, &a->kb_cnt)) in vt_do_diacrit()
1752 ret = -EFAULT; in vt_do_diacrit()
1753 else if (copy_to_user(a->kbdiacruc, buf, in vt_do_diacrit()
1755 ret = -EFAULT; in vt_do_diacrit()
1768 return -EPERM; in vt_do_diacrit()
1769 if (get_user(ct, &a->kb_cnt)) in vt_do_diacrit()
1770 return -EFAULT; in vt_do_diacrit()
1772 return -EINVAL; in vt_do_diacrit()
1776 dia = memdup_user(a->kbdiacr, in vt_do_diacrit()
1805 return -EPERM; in vt_do_diacrit()
1807 if (get_user(ct, &a->kb_cnt)) in vt_do_diacrit()
1808 return -EFAULT; in vt_do_diacrit()
1811 return -EINVAL; in vt_do_diacrit()
1814 buf = memdup_user(a->kbdiacruc, in vt_do_diacrit()
1833 * vt_do_kdskbmode - set keyboard mode ioctl
1849 kb->kbdmode = VC_RAW; in vt_do_kdskbmode()
1852 kb->kbdmode = VC_MEDIUMRAW; in vt_do_kdskbmode()
1855 kb->kbdmode = VC_XLATE; in vt_do_kdskbmode()
1859 kb->kbdmode = VC_UNICODE; in vt_do_kdskbmode()
1863 kb->kbdmode = VC_OFF; in vt_do_kdskbmode()
1866 ret = -EINVAL; in vt_do_kdskbmode()
1873 * vt_do_kdskbmeta - set keyboard meta state
1895 ret = -EINVAL; in vt_do_kdskbmeta()
1908 return -EFAULT; in vt_do_kbkeycode_ioctl()
1913 kc = put_user(kc, &user_kbkc->keycode); in vt_do_kbkeycode_ioctl()
1917 return -EPERM; in vt_do_kbkeycode_ioctl()
1958 keymap_count--; in vt_kdskbent()
1968 return -EINVAL; in vt_kdskbent()
1970 return -EINVAL; in vt_kdskbent()
1972 /* ++Geert: non-PC keyboards may generate keycode zero */ in vt_kdskbent()
1981 return -ENOMEM; in vt_kdskbent()
1992 return -EPERM; in vt_kdskbent()
2010 return -EPERM; in vt_kdskbent()
2029 return -EFAULT; in vt_do_kdsk_ioctl()
2033 return put_user(vt_kdgkbent(kb->kbdmode, kbe.kb_index, in vt_do_kdsk_ioctl()
2035 &user_kbe->kb_value); in vt_do_kdsk_ioctl()
2038 return -EPERM; in vt_do_kdsk_ioctl()
2039 return vt_kdskbent(kb->kbdmode, kbe.kb_index, kbe.kb_table, in vt_do_kdsk_ioctl()
2045 static char *vt_kdskbsent(char *kbs, unsigned char cur) in vt_kdskbsent() argument
2048 char *cur_f = func_table[cur]; in vt_kdskbsent()
2055 func_table[cur] = kbs; in vt_kdskbsent()
2057 return __test_and_set_bit(cur, is_kmalloc) ? cur_f : NULL; in vt_kdskbsent()
2067 if (get_user(kb_func, &user_kdgkb->kb_func)) in vt_do_kdgkb_ioctl()
2068 return -EFAULT; in vt_do_kdgkb_ioctl()
2075 ssize_t len = sizeof(user_kdgkb->kb_string); in vt_do_kdgkb_ioctl()
2079 return -ENOMEM; in vt_do_kdgkb_ioctl()
2085 ret = copy_to_user(user_kdgkb->kb_string, kbs, len + 1) ? in vt_do_kdgkb_ioctl()
2086 -EFAULT : 0; in vt_do_kdgkb_ioctl()
2092 return -EPERM; in vt_do_kdgkb_ioctl()
2094 kbs = strndup_user(user_kdgkb->kb_string, in vt_do_kdgkb_ioctl()
2095 sizeof(user_kdgkb->kb_string)); in vt_do_kdgkb_ioctl()
2120 /* don't use them - they will go away without warning */ in vt_do_kdskled()
2123 ucval = kb->ledflagstate | (kb->default_ledflagstate << 4); in vt_do_kdskled()
2129 return -EPERM; in vt_do_kdskled()
2131 return -EINVAL; in vt_do_kdskled()
2133 kb->ledflagstate = (arg & 7); in vt_do_kdskled()
2134 kb->default_ledflagstate = ((arg >> 4) & 7); in vt_do_kdskled()
2147 return -EPERM; in vt_do_kdskled()
2151 return -ENOIOCTLCMD; in vt_do_kdskled()
2158 switch (kb->kbdmode) { in vt_do_kdgkbmode()
2173 * vt_do_kdgkbmeta - report meta status
2186 * vt_reset_unicode - reset the unicode status
2201 * vt_get_shift_state - shift bit state
2213 * vt_reset_keyboard - reset keyboard state
2229 kb->lockstate = 0; in vt_reset_keyboard()
2230 kb->slockstate = 0; in vt_reset_keyboard()
2232 kb->ledmode = LED_SHOW_FLAGS; in vt_reset_keyboard()
2233 kb->ledflagstate = kb->default_ledflagstate; in vt_reset_keyboard()
2241 * vt_get_kbd_mode_bit - read keyboard status bits
2256 * vt_set_kbd_mode_bit - read keyboard status bits
2275 * vt_clr_kbd_mode_bit - read keyboard status bits