Lines Matching +full:abs +full:- +full:flat

1 /*-
3 * Copyright (c) 2015-2016 Vladimir Kondratyev <wulf@FreeBSD.org>
82 "Who is receiving events: bit0 - sysmouse, bit1 - kbdmux, "
83 "bit2 - mouse hardware, bit3 - keyboard hardware");
85 &evdev_sysmouse_t_axis, 0, "Extract T-axis from 0-none, 1-ums, 2-psm");
105 if (evdev != NULL && evdev->ev_cdev != NULL && in evdev_free()
106 evdev->ev_cdev->si_drv1 != NULL) in evdev_free()
134 evdev->ev_report_size = report_size; in evdev_set_report_size()
148 bit_ffs_at(evdev->ev_key_flags, KEY_OK, KEY_CNT - KEY_OK, &res); in evdev_estimate_report_size()
149 if (res == -1) in evdev_estimate_report_size()
150 bit_ffs(evdev->ev_key_flags, BTN_MISC, &res); in evdev_estimate_report_size()
151 size += (res != -1); in evdev_estimate_report_size()
152 bit_count(evdev->ev_key_flags, BTN_MISC, KEY_OK - BTN_MISC, &res); in evdev_estimate_report_size()
156 bit_count(evdev->ev_rel_flags, 0, REL_CNT, &res); in evdev_estimate_report_size()
163 if (evdev->ev_absinfo != NULL) { in evdev_estimate_report_size()
164 bit_count(evdev->ev_abs_flags, 0, ABS_CNT, &res); in evdev_estimate_report_size()
166 bit_count(evdev->ev_abs_flags, ABS_MT_FIRST, MT_CNT, &res); in evdev_estimate_report_size()
169 if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) in evdev_estimate_report_size()
174 size += res * (MAX_MT_REPORTS - 1); in evdev_estimate_report_size()
179 bit_count(evdev->ev_msc_flags, 0, MSC_CNT, &res); in evdev_estimate_report_size()
183 bit_count(evdev->ev_led_flags, 0, LED_CNT, &res); in evdev_estimate_report_size()
187 bit_ffs(evdev->ev_snd_flags, SND_CNT, &res); in evdev_estimate_report_size()
188 size += (res != -1); in evdev_estimate_report_size()
190 bit_ffs(evdev->ev_sw_flags, SW_CNT, &res); in evdev_estimate_report_size()
191 size += (res != -1); in evdev_estimate_report_size()
205 snprintf(ev_unit_str, sizeof(ev_unit_str), "%d", evdev->ev_unit); in evdev_sysctl_create()
206 sysctl_ctx_init(&evdev->ev_sysctl_ctx); in evdev_sysctl_create()
208 ev_sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
213 SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
215 evdev->ev_name, 0, in evdev_sysctl_create()
218 SYSCTL_ADD_STRUCT(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
220 &evdev->ev_id, input_id, in evdev_sysctl_create()
224 SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
226 evdev->ev_shortname, 0, in evdev_sysctl_create()
230 SYSCTL_ADD_STRING(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
232 evdev->ev_serial, 0, in evdev_sysctl_create()
235 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
237 evdev->ev_prop_flags, sizeof(evdev->ev_prop_flags), "", in evdev_sysctl_create()
240 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
242 evdev->ev_type_flags, sizeof(evdev->ev_type_flags), "", in evdev_sysctl_create()
245 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
247 evdev->ev_key_flags, sizeof(evdev->ev_key_flags), in evdev_sysctl_create()
250 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
252 evdev->ev_rel_flags, sizeof(evdev->ev_rel_flags), "", in evdev_sysctl_create()
255 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
257 evdev->ev_abs_flags, sizeof(evdev->ev_abs_flags), "", in evdev_sysctl_create()
260 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
262 evdev->ev_msc_flags, sizeof(evdev->ev_msc_flags), "", in evdev_sysctl_create()
265 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
267 evdev->ev_led_flags, sizeof(evdev->ev_led_flags), "", in evdev_sysctl_create()
270 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
272 evdev->ev_snd_flags, sizeof(evdev->ev_snd_flags), "", in evdev_sysctl_create()
275 SYSCTL_ADD_OPAQUE(&evdev->ev_sysctl_ctx, in evdev_sysctl_create()
277 evdev->ev_sw_flags, sizeof(evdev->ev_sw_flags), "", in evdev_sysctl_create()
287 evdev->ev_shortname, evdev->ev_name, evdev->ev_serial); in evdev_register_common()
290 CK_SLIST_INIT(&evdev->ev_clients); in evdev_register_common()
291 sx_init(&evdev->ev_list_lock, "evsx"); in evdev_register_common()
294 bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) { in evdev_register_common()
296 callout_init_mtx(&evdev->ev_rep_callout, in evdev_register_common()
297 evdev->ev_state_lock, 0); in evdev_register_common()
299 if (evdev->ev_rep[REP_DELAY] == 0 && in evdev_register_common()
300 evdev->ev_rep[REP_PERIOD] == 0) { in evdev_register_common()
302 evdev->ev_rep[REP_DELAY] = 250; in evdev_register_common()
303 evdev->ev_rep[REP_PERIOD] = 33; in evdev_register_common()
308 if (bit_test(evdev->ev_abs_flags, ABS_MT_SLOT) || in evdev_register_common()
309 bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK)) in evdev_register_common()
313 if (evdev->ev_report_size == 0) { in evdev_register_common()
330 sx_destroy(&evdev->ev_list_lock); in evdev_register_common()
339 if (bit_test(evdev->ev_flags, EVDEV_FLAG_EXT_EPOCH)) in evdev_register()
340 evdev->ev_lock_type = EV_LOCK_EXT_EPOCH; in evdev_register()
342 evdev->ev_lock_type = EV_LOCK_INTERNAL; in evdev_register()
343 evdev->ev_state_lock = &evdev->ev_mtx; in evdev_register()
344 mtx_init(&evdev->ev_mtx, "evmtx", NULL, MTX_DEF); in evdev_register()
348 mtx_destroy(&evdev->ev_mtx); in evdev_register()
357 evdev->ev_lock_type = EV_LOCK_MTX; in evdev_register_mtx()
358 evdev->ev_state_lock = mtx; in evdev_register_mtx()
368 evdev->ev_shortname, evdev->ev_name); in evdev_unregister()
370 sysctl_ctx_free(&evdev->ev_sysctl_ctx); in evdev_unregister()
373 evdev->ev_cdev->si_drv1 = NULL; in evdev_unregister()
375 CK_SLIST_FOREACH_SAFE(client, &evdev->ev_clients, ec_link, tmp) { in evdev_unregister()
386 evdev->ev_cdev = NULL; in evdev_unregister()
387 sx_destroy(&evdev->ev_list_lock); in evdev_unregister()
388 if (ret == 0 && evdev->ev_lock_type != EV_LOCK_MTX) in evdev_unregister()
389 mtx_destroy(&evdev->ev_mtx); in evdev_unregister()
391 evdev_free_absinfo(evdev->ev_absinfo); in evdev_unregister()
401 snprintf(evdev->ev_name, NAMELEN, "%s", name); in evdev_set_name()
409 evdev->ev_id = (struct input_id) { in evdev_set_id()
421 snprintf(evdev->ev_shortname, NAMELEN, "%s", name); in evdev_set_phys()
428 snprintf(evdev->ev_serial, NAMELEN, "%s", serial); in evdev_set_serial()
436 evdev->ev_methods = methods; in evdev_set_methods()
437 evdev->ev_softc = softc; in evdev_set_methods()
444 return (evdev->ev_softc); in evdev_get_softc()
452 bit_set(evdev->ev_prop_flags, prop); in evdev_support_prop()
460 bit_set(evdev->ev_type_flags, type); in evdev_support_event()
468 bit_set(evdev->ev_key_flags, code); in evdev_support_key()
476 bit_set(evdev->ev_rel_flags, code); in evdev_support_rel()
481 int32_t maximum, int32_t fuzz, int32_t flat, int32_t resolution) in evdev_support_abs() argument
485 KASSERT(code < ABS_CNT, ("invalid evdev abs property")); in evdev_support_abs()
492 .flat = flat, in evdev_support_abs()
503 KASSERT(code < ABS_CNT, ("invalid evdev abs property")); in evdev_set_abs_bit()
504 if (evdev->ev_absinfo == NULL) in evdev_set_abs_bit()
505 evdev->ev_absinfo = evdev_alloc_absinfo(); in evdev_set_abs_bit()
506 bit_set(evdev->ev_abs_flags, code); in evdev_set_abs_bit()
514 bit_set(evdev->ev_msc_flags, code); in evdev_support_msc()
523 bit_set(evdev->ev_led_flags, code); in evdev_support_led()
531 bit_set(evdev->ev_snd_flags, code); in evdev_support_snd()
539 bit_set(evdev->ev_sw_flags, code); in evdev_support_sw()
547 return (bit_test(evdev->ev_type_flags, type)); in evdev_event_supported()
555 KASSERT(axis < ABS_CNT, ("invalid evdev abs property")); in evdev_set_absinfo()
558 (absinfo->maximum < 1 || absinfo->maximum >= MAX_MT_SLOTS)) in evdev_set_absinfo()
561 if (evdev->ev_absinfo == NULL) in evdev_set_absinfo()
562 evdev->ev_absinfo = evdev_alloc_absinfo(); in evdev_set_absinfo()
565 evdev->ev_absinfo[ABS_MT_SLOT].maximum = absinfo->maximum; in evdev_set_absinfo()
567 memcpy(&evdev->ev_absinfo[axis], absinfo, in evdev_set_absinfo()
576 evdev->ev_rep[property] = value; in evdev_set_repeat_params()
584 bit_set(evdev->ev_flags, flag); in evdev_set_flag()
608 if (!bit_test(evdev->ev_key_flags, code)) in evdev_check_event()
615 if (!bit_test(evdev->ev_rel_flags, code)) in evdev_check_event()
622 if (!bit_test(evdev->ev_abs_flags, code)) in evdev_check_event()
627 if (ABS_IS_MT(code) && evdev->ev_mt == NULL && in evdev_check_event()
628 bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) in evdev_check_event()
635 if (!bit_test(evdev->ev_msc_flags, code)) in evdev_check_event()
642 if (!bit_test(evdev->ev_led_flags, code)) in evdev_check_event()
649 if (!bit_test(evdev->ev_snd_flags, code)) in evdev_check_event()
656 if (!bit_test(evdev->ev_sw_flags, code)) in evdev_check_event()
685 if (!bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) { in evdev_modify_event()
687 if (bit_test(evdev->ev_key_states, code) && in evdev_modify_event()
692 if (bit_test(evdev->ev_key_states, code) == !*value && in evdev_modify_event()
693 !CK_SLIST_EMPTY(&evdev->ev_clients)) { in evdev_modify_event()
706 old_value = evdev->ev_absinfo[code].value; in evdev_modify_event()
707 else if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) in evdev_modify_event()
718 fuzz = evdev->ev_absinfo[code].fuzz; in evdev_modify_event()
722 abs_change = abs(*value - old_value); in evdev_modify_event()
750 if (bit_test(evdev->ev_key_states, code) == value) in evdev_sparse_event()
752 bit_change(evdev->ev_key_states, code, value); in evdev_sparse_event()
756 if (bit_test(evdev->ev_key_states, code) == 0 || in evdev_sparse_event()
767 if (bit_test(evdev->ev_led_states, code) == value) in evdev_sparse_event()
769 bit_change(evdev->ev_led_states, code, value); in evdev_sparse_event()
773 bit_change(evdev->ev_snd_states, code, value); in evdev_sparse_event()
777 if (bit_test(evdev->ev_sw_states, code) == value) in evdev_sparse_event()
779 bit_change(evdev->ev_sw_states, code, value); in evdev_sparse_event()
783 if (evdev->ev_rep[code] == value) in evdev_sparse_event()
803 if (!bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) in evdev_sparse_event()
813 evdev->ev_report_opened = true; in evdev_sparse_event()
819 if (evdev->ev_absinfo[code].value == value) in evdev_sparse_event()
821 evdev->ev_absinfo[code].value = value; in evdev_sparse_event()
828 evdev->ev_report_count++; in evdev_sparse_event()
830 if (!evdev->ev_report_opened) in evdev_sparse_event()
832 evdev->ev_report_opened = false; in evdev_sparse_event()
838 evdev->ev_report_opened = true; in evdev_sparse_event()
850 evdev->ev_shortname, type, code, value); in evdev_propagate_event()
855 if (evdev->ev_lock_type == EV_LOCK_INTERNAL) in evdev_propagate_event()
859 evdev->ev_lock_type == EV_LOCK_MTX || in_epoch(INPUT_EPOCH) != 0, in evdev_propagate_event()
862 CK_SLIST_FOREACH(client, &evdev->ev_clients, ec_link) { in evdev_propagate_event()
863 if (evdev->ev_grabber != NULL && evdev->ev_grabber != client) in evdev_propagate_event()
872 if (evdev->ev_lock_type == EV_LOCK_INTERNAL) in evdev_propagate_event()
875 evdev->ev_event_count++; in evdev_propagate_event()
910 bit_foreach(evdev->ev_kdb_led_states, LED_CNT, code) in evdev_restore_after_kdb()
912 !bit_test(evdev->ev_led_states, code)); in evdev_restore_after_kdb()
913 bit_nclear(evdev->ev_kdb_led_states, 0, LED_MAX); in evdev_restore_after_kdb()
917 bit_foreach(evdev->ev_key_states, KEY_CNT, code) in evdev_restore_after_kdb()
935 evdev->ev_kdb_active = true; in evdev_push_event()
937 bit_set(evdev->ev_kdb_led_states, in evdev_push_event()
938 bit_test(evdev->ev_led_states, code) != value); in evdev_push_event()
945 if (evdev->ev_kdb_active) { in evdev_push_event()
946 evdev->ev_kdb_active = false; in evdev_push_event()
951 bit_test(evdev->ev_abs_flags, ABS_MT_SLOT)) in evdev_push_event()
954 if (bit_test(evdev->ev_flags, EVDEV_FLAG_MT_TRACK) && in evdev_push_event()
975 if (bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) in evdev_inject_event()
982 if (evdev->ev_methods != NULL && in evdev_inject_event()
983 evdev->ev_methods->ev_event != NULL) in evdev_inject_event()
984 evdev->ev_methods->ev_event(evdev, type, code, value); in evdev_inject_event()
1000 if (evdev->ev_lock_type == EV_LOCK_MTX) in evdev_inject_event()
1002 else if (evdev->ev_lock_type == EV_LOCK_EXT_EPOCH) in evdev_inject_event()
1005 if (evdev->ev_lock_type == EV_LOCK_MTX) in evdev_inject_event()
1007 else if (evdev->ev_lock_type == EV_LOCK_EXT_EPOCH) in evdev_inject_event()
1024 debugf(evdev, "adding new client for device %s", evdev->ev_shortname); in evdev_register_client()
1028 if (CK_SLIST_EMPTY(&evdev->ev_clients) && evdev->ev_methods != NULL && in evdev_register_client()
1029 evdev->ev_methods->ev_open != NULL) { in evdev_register_client()
1031 evdev->ev_shortname); in evdev_register_client()
1032 ret = evdev->ev_methods->ev_open(evdev); in evdev_register_client()
1035 CK_SLIST_INSERT_HEAD(&evdev->ev_clients, client, ec_link); in evdev_register_client()
1042 debugf(evdev, "removing client for device %s", evdev->ev_shortname); in evdev_dispose_client()
1046 CK_SLIST_REMOVE(&evdev->ev_clients, client, evdev_client, ec_link); in evdev_dispose_client()
1047 if (CK_SLIST_EMPTY(&evdev->ev_clients)) { in evdev_dispose_client()
1048 if (evdev->ev_methods != NULL && in evdev_dispose_client()
1049 evdev->ev_methods->ev_close != NULL) in evdev_dispose_client()
1050 (void)evdev->ev_methods->ev_close(evdev); in evdev_dispose_client()
1052 bit_test(evdev->ev_flags, EVDEV_FLAG_SOFTREPEAT)) { in evdev_dispose_client()
1053 if (evdev->ev_lock_type != EV_LOCK_MTX) in evdev_dispose_client()
1056 if (evdev->ev_lock_type != EV_LOCK_MTX) in evdev_dispose_client()
1060 if (evdev->ev_lock_type != EV_LOCK_MTX) in evdev_dispose_client()
1063 if (evdev->ev_lock_type != EV_LOCK_MTX) in evdev_dispose_client()
1073 if (evdev->ev_grabber != NULL) in evdev_grab_client()
1076 evdev->ev_grabber = client; in evdev_grab_client()
1087 if (evdev->ev_grabber != client) in evdev_release_client()
1090 evdev->ev_grabber = NULL; in evdev_release_client()
1101 * The function is intended to be called from evdev-unrelated parts of in evdev_is_grabbed()
1102 * code like syscons-compatible parts of mouse and keyboard drivers. in evdev_is_grabbed()
1103 * That makes unlocked read-only access acceptable. in evdev_is_grabbed()
1105 return (evdev->ev_grabber != NULL); in evdev_is_grabbed()
1114 if (evdev->ev_lock_type == EV_LOCK_EXT_EPOCH) in evdev_repeat_callout()
1116 evdev_send_event(evdev, EV_KEY, evdev->ev_rep_key, KEY_EVENT_REPEAT); in evdev_repeat_callout()
1118 if (evdev->ev_lock_type == EV_LOCK_EXT_EPOCH) in evdev_repeat_callout()
1121 if (evdev->ev_rep[REP_PERIOD]) in evdev_repeat_callout()
1122 callout_reset(&evdev->ev_rep_callout, in evdev_repeat_callout()
1123 evdev->ev_rep[REP_PERIOD] * hz / 1000, in evdev_repeat_callout()
1126 evdev->ev_rep_key = KEY_RESERVED; in evdev_repeat_callout()
1135 if (evdev->ev_rep[REP_DELAY]) { in evdev_start_repeat()
1136 evdev->ev_rep_key = key; in evdev_start_repeat()
1137 callout_reset(&evdev->ev_rep_callout, in evdev_start_repeat()
1138 evdev->ev_rep[REP_DELAY] * hz / 1000, in evdev_start_repeat()
1149 if (evdev->ev_rep_key != KEY_RESERVED) { in evdev_stop_repeat()
1150 callout_stop(&evdev->ev_rep_callout); in evdev_stop_repeat()
1151 evdev->ev_rep_key = KEY_RESERVED; in evdev_stop_repeat()