2 * Copyright (c) 2014 Jakub Wojciech Klama <jceel@FreeBSD.org>
3 * Copyright (c) 2015-2016 Vladimir Kondratyev <wulf@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include "opt_evdev.h"
32 #include <sys/param.h>
33 #include <sys/bitstring.h>
35 #include <sys/kernel.h>
36 #include <sys/malloc.h>
37 #include <sys/module.h>
38 #include <sys/sysctl.h>
39 #include <sys/systm.h>
41 #include <dev/evdev/evdev.h>
42 #include <dev/evdev/evdev_private.h>
43 #include <dev/evdev/input.h>
46 #define debugf(evdev, fmt, args...) printf("evdev: " fmt "\n", ##args)
48 #define debugf(evdev, fmt, args...)
52 FEATURE(evdev, "Input event devices support");
54 FEATURE(evdev_support, "Evdev support in hybrid drivers");
58 enum evdev_sparse_result
60 EV_SKIP_EVENT, /* Event value not changed */
61 EV_REPORT_EVENT, /* Event value changed */
62 EV_REPORT_MT_SLOT, /* Event value and MT slot number changed */
65 MALLOC_DEFINE(M_EVDEV, "evdev", "evdev memory");
67 int evdev_rcpt_mask = EVDEV_RCPT_SYSMOUSE | EVDEV_RCPT_KBDMUX;
68 int evdev_sysmouse_t_axis = 0;
71 SYSCTL_NODE(_kern, OID_AUTO, evdev, CTLFLAG_RW, 0, "Evdev args");
72 SYSCTL_INT(_kern_evdev, OID_AUTO, rcpt_mask, CTLFLAG_RW, &evdev_rcpt_mask, 0,
73 "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, "
74 "bit2 - mouse hardware, bit3 - keyboard hardware");
75 SYSCTL_INT(_kern_evdev, OID_AUTO, sysmouse_t_axis, CTLFLAG_RW,
76 &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm");
79 static void evdev_start_repeat(struct evdev_dev *, uint16_t);
80 static void evdev_stop_repeat(struct evdev_dev *);
81 static int evdev_check_event(struct evdev_dev *, uint16_t, uint16_t, int32_t);
84 bit_change(bitstr_t *bitstr, int bit, int value)
89 bit_clear(bitstr, bit);
96 return malloc(sizeof(struct evdev_dev), M_EVDEV, M_WAITOK | M_ZERO);
100 evdev_free(struct evdev_dev *evdev)
103 if (evdev != NULL && evdev->ev_cdev != NULL &&
104 evdev->ev_cdev->si_drv1 != NULL)
105 evdev_unregister(evdev);
107 free(evdev, M_EVDEV);
110 static struct input_absinfo *
111 evdev_alloc_absinfo(void)
114 return (malloc(sizeof(struct input_absinfo) * ABS_CNT, M_EVDEV,
119 evdev_free_absinfo(struct input_absinfo *absinfo)
122 free(absinfo, M_EVDEV);
126 evdev_set_report_size(struct evdev_dev *evdev, size_t report_size)
128 if (report_size > KEY_CNT + REL_CNT + ABS_CNT + MAX_MT_SLOTS * MT_CNT +
129 MSC_CNT + LED_CNT + SND_CNT + SW_CNT + FF_CNT)
132 evdev->ev_report_size = report_size;
137 evdev_estimate_report_size(struct evdev_dev *evdev)
143 * Keyboards generate one event per report but other devices with
144 * buttons like mouses can report events simultaneously
146 bit_ffs_at(evdev->ev_key_flags, KEY_OK, KEY_CNT - KEY_OK, &res);
148 bit_ffs(evdev->ev_key_flags, BTN_MISC, &res);
150 bit_count(evdev->ev_key_flags, BTN_MISC, KEY_OK - BTN_MISC, &res);
153 /* All relative axes can be reported simultaneously */
154 bit_count(evdev->ev_rel_flags, 0, REL_CNT, &res);
158 * All absolute axes can be reported simultaneously.
159 * Multitouch axes can be reported ABS_MT_SLOT times
161 if (evdev->ev_absinfo != NULL) {
162 bit_count(evdev->ev_abs_flags, 0, ABS_CNT, &res);
164 bit_count(evdev->ev_abs_flags, ABS_MT_FIRST, MT_CNT, &res);
166 res++; /* ABS_MT_SLOT or SYN_MT_REPORT */
167 if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
169 size += res * MAXIMAL_MT_SLOT(evdev);
172 size += res * (MAX_MT_REPORTS - 1);
176 /* All misc events can be reported simultaneously */
177 bit_count(evdev->ev_msc_flags, 0, MSC_CNT, &res);
180 /* All leds can be reported simultaneously */
181 bit_count(evdev->ev_led_flags, 0, LED_CNT, &res);
184 /* Assume other events are generated once per report */
185 bit_ffs(evdev->ev_snd_flags, SND_CNT, &res);
188 bit_ffs(evdev->ev_sw_flags, SW_CNT, &res);
191 /* XXX: FF part is not implemented yet */
193 size++; /* SYN_REPORT */
198 evdev_register_common(struct evdev_dev *evdev)
202 debugf(evdev, "%s: registered evdev provider: %s <%s>\n",
203 evdev->ev_shortname, evdev->ev_name, evdev->ev_serial);
205 /* Initialize internal structures */
206 LIST_INIT(&evdev->ev_clients);
208 if (evdev_event_supported(evdev, EV_REP) &&
209 bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) {
210 /* Initialize callout */
211 callout_init_mtx(&evdev->ev_rep_callout, &evdev->ev_mtx, 0);
213 if (evdev->ev_rep[REP_DELAY] == 0 &&
214 evdev->ev_rep[REP_PERIOD] == 0) {
215 /* Supply default values */
216 evdev->ev_rep[REP_DELAY] = 250;
217 evdev->ev_rep[REP_PERIOD] = 33;
221 /* Initialize multitouch protocol type B states */
222 if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) &&
223 evdev->ev_absinfo != NULL && MAXIMAL_MT_SLOT(evdev) > 0)
224 evdev_mt_init(evdev);
226 /* Estimate maximum report size */
227 if (evdev->ev_report_size == 0) {
228 ret = evdev_set_report_size(evdev,
229 evdev_estimate_report_size(evdev));
234 /* Create char device node */
235 ret = evdev_cdev_create(evdev);
241 evdev_register(struct evdev_dev *evdev)
245 evdev->ev_lock_type = EV_LOCK_INTERNAL;
246 evdev->ev_lock = &evdev->ev_mtx;
247 mtx_init(&evdev->ev_mtx, "evmtx", NULL, MTX_DEF);
249 ret = evdev_register_common(evdev);
251 mtx_destroy(&evdev->ev_mtx);
257 evdev_register_mtx(struct evdev_dev *evdev, struct mtx *mtx)
260 evdev->ev_lock_type = EV_LOCK_MTX;
261 evdev->ev_lock = mtx;
262 return (evdev_register_common(evdev));
266 evdev_unregister(struct evdev_dev *evdev)
268 struct evdev_client *client;
270 debugf(evdev, "%s: unregistered evdev provider: %s\n",
271 evdev->ev_shortname, evdev->ev_name);
274 evdev->ev_cdev->si_drv1 = NULL;
275 /* Wake up sleepers */
276 LIST_FOREACH(client, &evdev->ev_clients, ec_link) {
277 evdev_revoke_client(client);
278 evdev_dispose_client(evdev, client);
279 EVDEV_CLIENT_LOCKQ(client);
280 evdev_notify_event(client);
281 EVDEV_CLIENT_UNLOCKQ(client);
285 /* destroy_dev can sleep so release lock */
286 ret = evdev_cdev_destroy(evdev);
287 evdev->ev_cdev = NULL;
288 if (ret == 0 && evdev->ev_lock_type == EV_LOCK_INTERNAL)
289 mtx_destroy(&evdev->ev_mtx);
291 evdev_free_absinfo(evdev->ev_absinfo);
292 evdev_mt_free(evdev);
298 evdev_set_name(struct evdev_dev *evdev, const char *name)
301 snprintf(evdev->ev_name, NAMELEN, "%s", name);
305 evdev_set_id(struct evdev_dev *evdev, uint16_t bustype, uint16_t vendor,
306 uint16_t product, uint16_t version)
309 evdev->ev_id = (struct input_id) {
318 evdev_set_phys(struct evdev_dev *evdev, const char *name)
321 snprintf(evdev->ev_shortname, NAMELEN, "%s", name);
325 evdev_set_serial(struct evdev_dev *evdev, const char *serial)
328 snprintf(evdev->ev_serial, NAMELEN, "%s", serial);
332 evdev_set_methods(struct evdev_dev *evdev, void *softc,
333 const struct evdev_methods *methods)
336 evdev->ev_methods = methods;
337 evdev->ev_softc = softc;
341 evdev_get_softc(struct evdev_dev *evdev)
344 return (evdev->ev_softc);
348 evdev_support_prop(struct evdev_dev *evdev, uint16_t prop)
351 KASSERT(prop < INPUT_PROP_CNT, ("invalid evdev input property"));
352 bit_set(evdev->ev_prop_flags, prop);
356 evdev_support_event(struct evdev_dev *evdev, uint16_t type)
359 KASSERT(type < EV_CNT, ("invalid evdev event property"));
360 bit_set(evdev->ev_type_flags, type);
364 evdev_support_key(struct evdev_dev *evdev, uint16_t code)
367 KASSERT(code < KEY_CNT, ("invalid evdev key property"));
368 bit_set(evdev->ev_key_flags, code);
372 evdev_support_rel(struct evdev_dev *evdev, uint16_t code)
375 KASSERT(code < REL_CNT, ("invalid evdev rel property"));
376 bit_set(evdev->ev_rel_flags, code);
380 evdev_support_abs(struct evdev_dev *evdev, uint16_t code, int32_t value,
381 int32_t minimum, int32_t maximum, int32_t fuzz, int32_t flat,
384 struct input_absinfo absinfo;
386 KASSERT(code < ABS_CNT, ("invalid evdev abs property"));
388 absinfo = (struct input_absinfo) {
394 .resolution = resolution,
396 evdev_set_abs_bit(evdev, code);
397 evdev_set_absinfo(evdev, code, &absinfo);
401 evdev_set_abs_bit(struct evdev_dev *evdev, uint16_t code)
404 KASSERT(code < ABS_CNT, ("invalid evdev abs property"));
405 if (evdev->ev_absinfo == NULL)
406 evdev->ev_absinfo = evdev_alloc_absinfo();
407 bit_set(evdev->ev_abs_flags, code);
411 evdev_support_msc(struct evdev_dev *evdev, uint16_t code)
414 KASSERT(code < MSC_CNT, ("invalid evdev msc property"));
415 bit_set(evdev->ev_msc_flags, code);
420 evdev_support_led(struct evdev_dev *evdev, uint16_t code)
423 KASSERT(code < LED_CNT, ("invalid evdev led property"));
424 bit_set(evdev->ev_led_flags, code);
428 evdev_support_snd(struct evdev_dev *evdev, uint16_t code)
431 KASSERT(code < SND_CNT, ("invalid evdev snd property"));
432 bit_set(evdev->ev_snd_flags, code);
436 evdev_support_sw(struct evdev_dev *evdev, uint16_t code)
439 KASSERT(code < SW_CNT, ("invalid evdev sw property"));
440 bit_set(evdev->ev_sw_flags, code);
444 evdev_event_supported(struct evdev_dev *evdev, uint16_t type)
447 KASSERT(type < EV_CNT, ("invalid evdev event property"));
448 return (bit_test(evdev->ev_type_flags, type));
452 evdev_set_absinfo(struct evdev_dev *evdev, uint16_t axis,
453 struct input_absinfo *absinfo)
456 KASSERT(axis < ABS_CNT, ("invalid evdev abs property"));
458 if (axis == ABS_MT_SLOT &&
459 (absinfo->maximum < 1 || absinfo->maximum >= MAX_MT_SLOTS))
462 if (evdev->ev_absinfo == NULL)
463 evdev->ev_absinfo = evdev_alloc_absinfo();
465 if (axis == ABS_MT_SLOT)
466 evdev->ev_absinfo[ABS_MT_SLOT].maximum = absinfo->maximum;
468 memcpy(&evdev->ev_absinfo[axis], absinfo,
469 sizeof(struct input_absinfo));
473 evdev_set_repeat_params(struct evdev_dev *evdev, uint16_t property, int value)
476 KASSERT(property < REP_CNT, ("invalid evdev repeat property"));
477 evdev->ev_rep[property] = value;
481 evdev_set_flag(struct evdev_dev *evdev, uint16_t flag)
484 KASSERT(flag < EVDEV_FLAG_CNT, ("invalid evdev flag property"));
485 bit_set(evdev->ev_flags, flag);
489 evdev_check_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
496 /* Allow SYN events implicitly */
497 if (type != EV_SYN && !evdev_event_supported(evdev, type))
509 if (!bit_test(evdev->ev_key_flags, code))
516 if (!bit_test(evdev->ev_rel_flags, code))
523 if (!bit_test(evdev->ev_abs_flags, code))
525 if (code == ABS_MT_SLOT &&
526 (value < 0 || value > MAXIMAL_MT_SLOT(evdev)))
528 if (ABS_IS_MT(code) && evdev->ev_mt == NULL &&
529 bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
536 if (!bit_test(evdev->ev_msc_flags, code))
543 if (!bit_test(evdev->ev_led_flags, code))
550 if (!bit_test(evdev->ev_snd_flags, code))
557 if (!bit_test(evdev->ev_sw_flags, code))
574 evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
578 EVDEV_LOCK_ASSERT(evdev);
582 if (!evdev_event_supported(evdev, EV_REP))
585 if (!bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) {
586 /* Detect driver key repeats. */
587 if (bit_test(evdev->ev_key_states, code) &&
588 *value == KEY_EVENT_DOWN)
589 *value = KEY_EVENT_REPEAT;
591 /* Start/stop callout for evdev repeats */
592 if (bit_test(evdev->ev_key_states, code) == !*value &&
593 !LIST_EMPTY(&evdev->ev_clients)) {
594 if (*value == KEY_EVENT_DOWN)
595 evdev_start_repeat(evdev, code);
597 evdev_stop_repeat(evdev);
603 /* TBD: implement fuzz */
608 static enum evdev_sparse_result
609 evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
612 int32_t last_mt_slot;
614 EVDEV_LOCK_ASSERT(evdev);
617 * For certain event types, update device state bits
618 * and convert level reporting to edge reporting
625 if (bit_test(evdev->ev_key_states, code) == value)
626 return (EV_SKIP_EVENT);
627 bit_change(evdev->ev_key_states, code, value);
630 case KEY_EVENT_REPEAT:
631 if (bit_test(evdev->ev_key_states, code) == 0 ||
632 !evdev_event_supported(evdev, EV_REP))
633 return (EV_SKIP_EVENT);
637 return (EV_SKIP_EVENT);
642 if (bit_test(evdev->ev_led_states, code) == value)
643 return (EV_SKIP_EVENT);
644 bit_change(evdev->ev_led_states, code, value);
648 bit_change(evdev->ev_snd_states, code, value);
652 if (bit_test(evdev->ev_sw_states, code) == value)
653 return (EV_SKIP_EVENT);
654 bit_change(evdev->ev_sw_states, code, value);
658 if (evdev->ev_rep[code] == value)
659 return (EV_SKIP_EVENT);
660 evdev_set_repeat_params(evdev, code, value);
665 return (EV_SKIP_EVENT);
668 /* For EV_ABS, save last value in absinfo and ev_mt_states */
672 /* Postpone ABS_MT_SLOT till next event */
673 evdev_set_last_mt_slot(evdev, value);
674 return (EV_SKIP_EVENT);
676 case ABS_MT_FIRST ... ABS_MT_LAST:
677 /* Pass MT protocol type A events as is */
678 if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
680 /* Don`t repeat MT protocol type B events */
681 last_mt_slot = evdev_get_last_mt_slot(evdev);
682 if (evdev_get_mt_value(evdev, last_mt_slot, code)
684 return (EV_SKIP_EVENT);
685 evdev_set_mt_value(evdev, last_mt_slot, code, value);
686 if (last_mt_slot != CURRENT_MT_SLOT(evdev)) {
687 CURRENT_MT_SLOT(evdev) = last_mt_slot;
688 evdev->ev_report_opened = true;
689 return (EV_REPORT_MT_SLOT);
694 if (evdev->ev_absinfo[code].value == value)
695 return (EV_SKIP_EVENT);
696 evdev->ev_absinfo[code].value = value;
701 if (code == SYN_REPORT) {
702 /* Count empty reports as well as non empty */
703 evdev->ev_report_count++;
704 /* Skip empty reports */
705 if (!evdev->ev_report_opened)
706 return (EV_SKIP_EVENT);
707 evdev->ev_report_opened = false;
708 return (EV_REPORT_EVENT);
713 evdev->ev_report_opened = true;
714 return (EV_REPORT_EVENT);
718 evdev_propagate_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
721 struct evdev_client *client;
723 debugf(evdev, "%s pushed event %d/%d/%d",
724 evdev->ev_shortname, type, code, value);
726 EVDEV_LOCK_ASSERT(evdev);
728 /* Propagate event through all clients */
729 LIST_FOREACH(client, &evdev->ev_clients, ec_link) {
730 if (evdev->ev_grabber != NULL && evdev->ev_grabber != client)
733 EVDEV_CLIENT_LOCKQ(client);
734 evdev_client_push(client, type, code, value);
735 if (type == EV_SYN && code == SYN_REPORT)
736 evdev_notify_event(client);
737 EVDEV_CLIENT_UNLOCKQ(client);
740 evdev->ev_event_count++;
744 evdev_send_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
747 enum evdev_sparse_result sparse;
749 EVDEV_LOCK_ASSERT(evdev);
751 sparse = evdev_sparse_event(evdev, type, code, value);
753 case EV_REPORT_MT_SLOT:
754 /* report postponed ABS_MT_SLOT */
755 evdev_propagate_event(evdev, EV_ABS, ABS_MT_SLOT,
756 CURRENT_MT_SLOT(evdev));
758 case EV_REPORT_EVENT:
759 evdev_propagate_event(evdev, type, code, value);
767 evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
771 if (evdev_check_event(evdev, type, code, value) != 0)
776 evdev_modify_event(evdev, type, code, &value);
777 if (type == EV_SYN && code == SYN_REPORT &&
778 bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL))
779 evdev_send_mt_autorel(evdev);
780 if (type == EV_SYN && code == SYN_REPORT && evdev->ev_report_opened &&
781 bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT))
782 evdev_send_mt_compat(evdev);
783 evdev_send_event(evdev, type, code, value);
791 evdev_inject_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
798 /* evdev repeats should not be processed by hardware driver */
799 if (bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT))
806 if (evdev->ev_methods != NULL &&
807 evdev->ev_methods->ev_event != NULL)
808 evdev->ev_methods->ev_event(evdev, type, code, value);
810 * Leds and driver repeats should be reported in ev_event
811 * method body to interoperate with kbdmux states and rates
812 * propagation so both ways (ioctl and evdev) of changing it
813 * will produce only one evdev event report to client.
815 if (type == EV_LED || type == EV_REP)
824 if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
826 ret = evdev_push_event(evdev, type, code, value);
827 if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
839 evdev_register_client(struct evdev_dev *evdev, struct evdev_client *client)
843 debugf(evdev, "adding new client for device %s", evdev->ev_shortname);
845 EVDEV_LOCK_ASSERT(evdev);
847 if (LIST_EMPTY(&evdev->ev_clients) && evdev->ev_methods != NULL &&
848 evdev->ev_methods->ev_open != NULL) {
849 debugf(evdev, "calling ev_open() on device %s",
850 evdev->ev_shortname);
851 ret = evdev->ev_methods->ev_open(evdev);
854 LIST_INSERT_HEAD(&evdev->ev_clients, client, ec_link);
859 evdev_dispose_client(struct evdev_dev *evdev, struct evdev_client *client)
861 debugf(evdev, "removing client for device %s", evdev->ev_shortname);
863 EVDEV_LOCK_ASSERT(evdev);
865 LIST_REMOVE(client, ec_link);
866 if (LIST_EMPTY(&evdev->ev_clients)) {
867 if (evdev->ev_methods != NULL &&
868 evdev->ev_methods->ev_close != NULL)
869 (void)evdev->ev_methods->ev_close(evdev);
870 if (evdev_event_supported(evdev, EV_REP) &&
871 bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT))
872 evdev_stop_repeat(evdev);
874 evdev_release_client(evdev, client);
878 evdev_grab_client(struct evdev_dev *evdev, struct evdev_client *client)
881 EVDEV_LOCK_ASSERT(evdev);
883 if (evdev->ev_grabber != NULL)
886 evdev->ev_grabber = client;
892 evdev_release_client(struct evdev_dev *evdev, struct evdev_client *client)
895 EVDEV_LOCK_ASSERT(evdev);
897 if (evdev->ev_grabber != client)
900 evdev->ev_grabber = NULL;
906 evdev_repeat_callout(void *arg)
908 struct evdev_dev *evdev = (struct evdev_dev *)arg;
910 evdev_send_event(evdev, EV_KEY, evdev->ev_rep_key, KEY_EVENT_REPEAT);
911 evdev_send_event(evdev, EV_SYN, SYN_REPORT, 1);
913 if (evdev->ev_rep[REP_PERIOD])
914 callout_reset(&evdev->ev_rep_callout,
915 evdev->ev_rep[REP_PERIOD] * hz / 1000,
916 evdev_repeat_callout, evdev);
918 evdev->ev_rep_key = KEY_RESERVED;
922 evdev_start_repeat(struct evdev_dev *evdev, uint16_t key)
925 EVDEV_LOCK_ASSERT(evdev);
927 if (evdev->ev_rep[REP_DELAY]) {
928 evdev->ev_rep_key = key;
929 callout_reset(&evdev->ev_rep_callout,
930 evdev->ev_rep[REP_DELAY] * hz / 1000,
931 evdev_repeat_callout, evdev);
936 evdev_stop_repeat(struct evdev_dev *evdev)
939 EVDEV_LOCK_ASSERT(evdev);
941 if (evdev->ev_rep_key != KEY_RESERVED) {
942 callout_stop(&evdev->ev_rep_callout);
943 evdev->ev_rep_key = KEY_RESERVED;
947 MODULE_VERSION(evdev, 1);