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_support_prop(struct evdev_dev *evdev, uint16_t prop)
344 KASSERT(prop < INPUT_PROP_CNT, ("invalid evdev input property"));
345 bit_set(evdev->ev_prop_flags, prop);
349 evdev_support_event(struct evdev_dev *evdev, uint16_t type)
352 KASSERT(type < EV_CNT, ("invalid evdev event property"));
353 bit_set(evdev->ev_type_flags, type);
357 evdev_support_key(struct evdev_dev *evdev, uint16_t code)
360 KASSERT(code < KEY_CNT, ("invalid evdev key property"));
361 bit_set(evdev->ev_key_flags, code);
365 evdev_support_rel(struct evdev_dev *evdev, uint16_t code)
368 KASSERT(code < REL_CNT, ("invalid evdev rel property"));
369 bit_set(evdev->ev_rel_flags, code);
373 evdev_support_abs(struct evdev_dev *evdev, uint16_t code, int32_t value,
374 int32_t minimum, int32_t maximum, int32_t fuzz, int32_t flat,
377 struct input_absinfo absinfo;
379 KASSERT(code < ABS_CNT, ("invalid evdev abs property"));
381 absinfo = (struct input_absinfo) {
387 .resolution = resolution,
389 evdev_set_abs_bit(evdev, code);
390 evdev_set_absinfo(evdev, code, &absinfo);
394 evdev_set_abs_bit(struct evdev_dev *evdev, uint16_t code)
397 KASSERT(code < ABS_CNT, ("invalid evdev abs property"));
398 if (evdev->ev_absinfo == NULL)
399 evdev->ev_absinfo = evdev_alloc_absinfo();
400 bit_set(evdev->ev_abs_flags, code);
404 evdev_support_msc(struct evdev_dev *evdev, uint16_t code)
407 KASSERT(code < MSC_CNT, ("invalid evdev msc property"));
408 bit_set(evdev->ev_msc_flags, code);
413 evdev_support_led(struct evdev_dev *evdev, uint16_t code)
416 KASSERT(code < LED_CNT, ("invalid evdev led property"));
417 bit_set(evdev->ev_led_flags, code);
421 evdev_support_snd(struct evdev_dev *evdev, uint16_t code)
424 KASSERT(code < SND_CNT, ("invalid evdev snd property"));
425 bit_set(evdev->ev_snd_flags, code);
429 evdev_support_sw(struct evdev_dev *evdev, uint16_t code)
432 KASSERT(code < SW_CNT, ("invalid evdev sw property"));
433 bit_set(evdev->ev_sw_flags, code);
437 evdev_event_supported(struct evdev_dev *evdev, uint16_t type)
440 KASSERT(type < EV_CNT, ("invalid evdev event property"));
441 return (bit_test(evdev->ev_type_flags, type));
445 evdev_set_absinfo(struct evdev_dev *evdev, uint16_t axis,
446 struct input_absinfo *absinfo)
449 KASSERT(axis < ABS_CNT, ("invalid evdev abs property"));
451 if (axis == ABS_MT_SLOT &&
452 (absinfo->maximum < 1 || absinfo->maximum >= MAX_MT_SLOTS))
455 if (evdev->ev_absinfo == NULL)
456 evdev->ev_absinfo = evdev_alloc_absinfo();
458 if (axis == ABS_MT_SLOT)
459 evdev->ev_absinfo[ABS_MT_SLOT].maximum = absinfo->maximum;
461 memcpy(&evdev->ev_absinfo[axis], absinfo,
462 sizeof(struct input_absinfo));
466 evdev_set_repeat_params(struct evdev_dev *evdev, uint16_t property, int value)
469 KASSERT(property < REP_CNT, ("invalid evdev repeat property"));
470 evdev->ev_rep[property] = value;
474 evdev_set_flag(struct evdev_dev *evdev, uint16_t flag)
477 KASSERT(flag < EVDEV_FLAG_CNT, ("invalid evdev flag property"));
478 bit_set(evdev->ev_flags, flag);
482 evdev_check_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
489 /* Allow SYN events implicitly */
490 if (type != EV_SYN && !evdev_event_supported(evdev, type))
502 if (!bit_test(evdev->ev_key_flags, code))
509 if (!bit_test(evdev->ev_rel_flags, code))
516 if (!bit_test(evdev->ev_abs_flags, code))
518 if (code == ABS_MT_SLOT &&
519 (value < 0 || value > MAXIMAL_MT_SLOT(evdev)))
521 if (ABS_IS_MT(code) && evdev->ev_mt == NULL &&
522 bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
529 if (!bit_test(evdev->ev_msc_flags, code))
536 if (!bit_test(evdev->ev_led_flags, code))
543 if (!bit_test(evdev->ev_snd_flags, code))
550 if (!bit_test(evdev->ev_sw_flags, code))
567 evdev_modify_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
571 EVDEV_LOCK_ASSERT(evdev);
575 if (!evdev_event_supported(evdev, EV_REP))
578 if (!bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) {
579 /* Detect driver key repeats. */
580 if (bit_test(evdev->ev_key_states, code) &&
581 *value == KEY_EVENT_DOWN)
582 *value = KEY_EVENT_REPEAT;
584 /* Start/stop callout for evdev repeats */
585 if (bit_test(evdev->ev_key_states, code) == !*value &&
586 !LIST_EMPTY(&evdev->ev_clients)) {
587 if (*value == KEY_EVENT_DOWN)
588 evdev_start_repeat(evdev, code);
590 evdev_stop_repeat(evdev);
596 /* TBD: implement fuzz */
601 static enum evdev_sparse_result
602 evdev_sparse_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
605 int32_t last_mt_slot;
607 EVDEV_LOCK_ASSERT(evdev);
610 * For certain event types, update device state bits
611 * and convert level reporting to edge reporting
618 if (bit_test(evdev->ev_key_states, code) == value)
619 return (EV_SKIP_EVENT);
620 bit_change(evdev->ev_key_states, code, value);
623 case KEY_EVENT_REPEAT:
624 if (bit_test(evdev->ev_key_states, code) == 0 ||
625 !evdev_event_supported(evdev, EV_REP))
626 return (EV_SKIP_EVENT);
630 return (EV_SKIP_EVENT);
635 if (bit_test(evdev->ev_led_states, code) == value)
636 return (EV_SKIP_EVENT);
637 bit_change(evdev->ev_led_states, code, value);
641 bit_change(evdev->ev_snd_states, code, value);
645 if (bit_test(evdev->ev_sw_states, code) == value)
646 return (EV_SKIP_EVENT);
647 bit_change(evdev->ev_sw_states, code, value);
651 if (evdev->ev_rep[code] == value)
652 return (EV_SKIP_EVENT);
653 evdev_set_repeat_params(evdev, code, value);
658 return (EV_SKIP_EVENT);
661 /* For EV_ABS, save last value in absinfo and ev_mt_states */
665 /* Postpone ABS_MT_SLOT till next event */
666 evdev_set_last_mt_slot(evdev, value);
667 return (EV_SKIP_EVENT);
669 case ABS_MT_FIRST ... ABS_MT_LAST:
670 /* Pass MT protocol type A events as is */
671 if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT))
673 /* Don`t repeat MT protocol type B events */
674 last_mt_slot = evdev_get_last_mt_slot(evdev);
675 if (evdev_get_mt_value(evdev, last_mt_slot, code)
677 return (EV_SKIP_EVENT);
678 evdev_set_mt_value(evdev, last_mt_slot, code, value);
679 if (last_mt_slot != CURRENT_MT_SLOT(evdev)) {
680 CURRENT_MT_SLOT(evdev) = last_mt_slot;
681 evdev->ev_report_opened = true;
682 return (EV_REPORT_MT_SLOT);
687 if (evdev->ev_absinfo[code].value == value)
688 return (EV_SKIP_EVENT);
689 evdev->ev_absinfo[code].value = value;
694 if (code == SYN_REPORT) {
695 /* Count empty reports as well as non empty */
696 evdev->ev_report_count++;
697 /* Skip empty reports */
698 if (!evdev->ev_report_opened)
699 return (EV_SKIP_EVENT);
700 evdev->ev_report_opened = false;
701 return (EV_REPORT_EVENT);
706 evdev->ev_report_opened = true;
707 return (EV_REPORT_EVENT);
711 evdev_propagate_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
714 struct evdev_client *client;
716 debugf(evdev, "%s pushed event %d/%d/%d",
717 evdev->ev_shortname, type, code, value);
719 EVDEV_LOCK_ASSERT(evdev);
721 /* Propagate event through all clients */
722 LIST_FOREACH(client, &evdev->ev_clients, ec_link) {
723 if (evdev->ev_grabber != NULL && evdev->ev_grabber != client)
726 EVDEV_CLIENT_LOCKQ(client);
727 evdev_client_push(client, type, code, value);
728 if (type == EV_SYN && code == SYN_REPORT)
729 evdev_notify_event(client);
730 EVDEV_CLIENT_UNLOCKQ(client);
733 evdev->ev_event_count++;
737 evdev_send_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
740 enum evdev_sparse_result sparse;
742 EVDEV_LOCK_ASSERT(evdev);
744 sparse = evdev_sparse_event(evdev, type, code, value);
746 case EV_REPORT_MT_SLOT:
747 /* report postponed ABS_MT_SLOT */
748 evdev_propagate_event(evdev, EV_ABS, ABS_MT_SLOT,
749 CURRENT_MT_SLOT(evdev));
751 case EV_REPORT_EVENT:
752 evdev_propagate_event(evdev, type, code, value);
760 evdev_push_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
764 if (evdev_check_event(evdev, type, code, value) != 0)
769 evdev_modify_event(evdev, type, code, &value);
770 if (type == EV_SYN && code == SYN_REPORT &&
771 bit_test(evdev->ev_flags, EVDEV_FLAG_MT_AUTOREL))
772 evdev_send_mt_autorel(evdev);
773 if (type == EV_SYN && code == SYN_REPORT && evdev->ev_report_opened &&
774 bit_test(evdev->ev_flags, EVDEV_FLAG_MT_STCOMPAT))
775 evdev_send_mt_compat(evdev);
776 evdev_send_event(evdev, type, code, value);
784 evdev_inject_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
791 /* evdev repeats should not be processed by hardware driver */
792 if (bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT))
799 if (evdev->ev_methods != NULL &&
800 evdev->ev_methods->ev_event != NULL)
801 evdev->ev_methods->ev_event(evdev, evdev->ev_softc,
804 * Leds and driver repeats should be reported in ev_event
805 * method body to interoperate with kbdmux states and rates
806 * propagation so both ways (ioctl and evdev) of changing it
807 * will produce only one evdev event report to client.
809 if (type == EV_LED || type == EV_REP)
818 if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
820 ret = evdev_push_event(evdev, type, code, value);
821 if (evdev->ev_lock_type != EV_LOCK_INTERNAL)
833 evdev_register_client(struct evdev_dev *evdev, struct evdev_client *client)
837 debugf(evdev, "adding new client for device %s", evdev->ev_shortname);
839 EVDEV_LOCK_ASSERT(evdev);
841 if (LIST_EMPTY(&evdev->ev_clients) && evdev->ev_methods != NULL &&
842 evdev->ev_methods->ev_open != NULL) {
843 debugf(evdev, "calling ev_open() on device %s",
844 evdev->ev_shortname);
845 ret = evdev->ev_methods->ev_open(evdev, evdev->ev_softc);
848 LIST_INSERT_HEAD(&evdev->ev_clients, client, ec_link);
853 evdev_dispose_client(struct evdev_dev *evdev, struct evdev_client *client)
855 debugf(evdev, "removing client for device %s", evdev->ev_shortname);
857 EVDEV_LOCK_ASSERT(evdev);
859 LIST_REMOVE(client, ec_link);
860 if (LIST_EMPTY(&evdev->ev_clients)) {
861 if (evdev->ev_methods != NULL &&
862 evdev->ev_methods->ev_close != NULL)
863 evdev->ev_methods->ev_close(evdev, evdev->ev_softc);
864 if (evdev_event_supported(evdev, EV_REP) &&
865 bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT))
866 evdev_stop_repeat(evdev);
868 evdev_release_client(evdev, client);
872 evdev_grab_client(struct evdev_dev *evdev, struct evdev_client *client)
875 EVDEV_LOCK_ASSERT(evdev);
877 if (evdev->ev_grabber != NULL)
880 evdev->ev_grabber = client;
886 evdev_release_client(struct evdev_dev *evdev, struct evdev_client *client)
889 EVDEV_LOCK_ASSERT(evdev);
891 if (evdev->ev_grabber != client)
894 evdev->ev_grabber = NULL;
900 evdev_repeat_callout(void *arg)
902 struct evdev_dev *evdev = (struct evdev_dev *)arg;
904 evdev_send_event(evdev, EV_KEY, evdev->ev_rep_key, KEY_EVENT_REPEAT);
905 evdev_send_event(evdev, EV_SYN, SYN_REPORT, 1);
907 if (evdev->ev_rep[REP_PERIOD])
908 callout_reset(&evdev->ev_rep_callout,
909 evdev->ev_rep[REP_PERIOD] * hz / 1000,
910 evdev_repeat_callout, evdev);
912 evdev->ev_rep_key = KEY_RESERVED;
916 evdev_start_repeat(struct evdev_dev *evdev, uint16_t key)
919 EVDEV_LOCK_ASSERT(evdev);
921 if (evdev->ev_rep[REP_DELAY]) {
922 evdev->ev_rep_key = key;
923 callout_reset(&evdev->ev_rep_callout,
924 evdev->ev_rep[REP_DELAY] * hz / 1000,
925 evdev_repeat_callout, evdev);
930 evdev_stop_repeat(struct evdev_dev *evdev)
933 EVDEV_LOCK_ASSERT(evdev);
935 if (evdev->ev_rep_key != KEY_RESERVED) {
936 callout_stop(&evdev->ev_rep_callout);
937 evdev->ev_rep_key = KEY_RESERVED;
941 MODULE_VERSION(evdev, 1);