Lines Matching +full:abs +full:- +full:flat
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
97 uint32_t flat; member
116 struct vtinput_absinfo abs; member
140 * Per-device softc
174 vi_reset_dev(&sc->vsc_vs); in pci_vtinput_reset()
204 * - host send EV_MSC to guest in pci_vtinput_notify_statusq()
205 * - guest sends EV_MSC back to host in pci_vtinput_notify_statusq()
206 * - host writes EV_MSC to evdev in pci_vtinput_notify_statusq()
207 * - evdev saves EV_MSC in it's event buffer in pci_vtinput_notify_statusq()
208 * - host receives an extra EV_MSC by reading the evdev event in pci_vtinput_notify_statusq()
210 * - frames become larger and larger in pci_vtinput_notify_statusq()
226 if (write(sc->vsc_fd, &host_event, sizeof(host_event)) == -1) { in pci_vtinput_notify_statusq()
239 return (-1); in pci_vtinput_get_bitmap()
243 memset(sc->vsc_config.u.bitmap, 0, sizeof(sc->vsc_config.u.bitmap)); in pci_vtinput_get_bitmap()
244 if (ioctl(sc->vsc_fd, cmd, sc->vsc_config.u.bitmap) < 0) { in pci_vtinput_get_bitmap()
245 return (-1); in pci_vtinput_get_bitmap()
249 for (int i = count - 1; i >= 0; i--) { in pci_vtinput_get_bitmap()
250 if (sc->vsc_config.u.bitmap[i]) { in pci_vtinput_get_bitmap()
255 return (-1); in pci_vtinput_get_bitmap()
262 if (ioctl(sc->vsc_fd, EVIOCGNAME(sizeof(name) - 1), name) < 0) { in pci_vtinput_read_config_id_name()
266 memcpy(sc->vsc_config.u.string, name, sizeof(name)); in pci_vtinput_read_config_id_name()
267 sc->vsc_config.size = strnlen(name, sizeof(name)); in pci_vtinput_read_config_id_name()
276 sc->vsc_config.size = 0; in pci_vtinput_read_config_id_serial()
285 if (ioctl(sc->vsc_fd, EVIOCGID, &devids)) { in pci_vtinput_read_config_id_devids()
289 sc->vsc_config.u.ids.bustype = devids.bustype; in pci_vtinput_read_config_id_devids()
290 sc->vsc_config.u.ids.vendor = devids.vendor; in pci_vtinput_read_config_id_devids()
291 sc->vsc_config.u.ids.product = devids.product; in pci_vtinput_read_config_id_devids()
292 sc->vsc_config.u.ids.version = devids.version; in pci_vtinput_read_config_id_devids()
293 sc->vsc_config.size = sizeof(struct vtinput_devids); in pci_vtinput_read_config_id_devids()
315 sc->vsc_config.size = size; in pci_vtinput_read_config_prop_bits()
355 const unsigned int cmd = EVIOCGBIT(sc->vsc_config.subsel, count); in pci_vtinput_read_config_ev_bits()
361 sc->vsc_config.size = size; in pci_vtinput_read_config_ev_bits()
374 /* get abs information */ in pci_vtinput_read_config_abs_info()
375 struct input_absinfo abs; in pci_vtinput_read_config_abs_info() local
376 if (ioctl(sc->vsc_fd, EVIOCGABS(sc->vsc_config.subsel), &abs) < 0) { in pci_vtinput_read_config_abs_info()
380 /* save abs information */ in pci_vtinput_read_config_abs_info()
381 sc->vsc_config.u.abs.min = abs.minimum; in pci_vtinput_read_config_abs_info()
382 sc->vsc_config.u.abs.max = abs.maximum; in pci_vtinput_read_config_abs_info()
383 sc->vsc_config.u.abs.fuzz = abs.fuzz; in pci_vtinput_read_config_abs_info()
384 sc->vsc_config.u.abs.flat = abs.flat; in pci_vtinput_read_config_abs_info()
385 sc->vsc_config.u.abs.res = abs.resolution; in pci_vtinput_read_config_abs_info()
386 sc->vsc_config.size = sizeof(struct vtinput_absinfo); in pci_vtinput_read_config_abs_info()
394 switch (sc->vsc_config.select) { in pci_vtinput_read_config()
407 sc, sc->vsc_config.subsel); in pci_vtinput_read_config()
429 if (!sc->vsc_config_valid) { in pci_vtinput_cfgread()
432 sc->vsc_config.select, sc->vsc_config.subsel)); in pci_vtinput_cfgread()
436 sc->vsc_config_valid = 1; in pci_vtinput_cfgread()
439 uint8_t *ptr = (uint8_t *)&sc->vsc_config; in pci_vtinput_cfgread()
457 uint8_t *ptr = (uint8_t *)&sc->vsc_config; in pci_vtinput_cfgwrite()
461 sc->vsc_config_valid = 0; in pci_vtinput_cfgwrite()
471 if (queue->idx >= queue->size) { in vtinput_eventqueue_add_event()
473 const uint32_t newSize = queue->idx; in vtinput_eventqueue_add_event()
474 void *newPtr = realloc(queue->events, in vtinput_eventqueue_add_event()
475 queue->size * sizeof(struct vtinput_event_elem)); in vtinput_eventqueue_add_event()
481 queue->events = newPtr; in vtinput_eventqueue_add_event()
482 queue->size = newSize; in vtinput_eventqueue_add_event()
486 struct vtinput_event *event = &queue->events[queue->idx].event; in vtinput_eventqueue_add_event()
487 event->type = e->type; in vtinput_eventqueue_add_event()
488 event->code = e->code; in vtinput_eventqueue_add_event()
489 event->value = e->value; in vtinput_eventqueue_add_event()
490 queue->idx++; in vtinput_eventqueue_add_event()
499 queue->idx = 0; in vtinput_eventqueue_clear()
510 for (uint32_t i = 0; i < queue->idx; ++i) { in vtinput_eventqueue_send_events()
520 __func__, queue->idx)); in vtinput_eventqueue_send_events()
549 queue->events[i].iov = iov; in vtinput_eventqueue_send_events()
550 queue->events[i].idx = req.idx; in vtinput_eventqueue_send_events()
557 for (uint32_t i = 0; i < queue->idx; ++i) { in vtinput_eventqueue_send_events()
558 struct vtinput_event_elem event = queue->events[i]; in vtinput_eventqueue_send_events()
574 if (len == -1 && errno != EAGAIN) { in vtinput_read_event_from_host()
593 if (!(sc->vsc_vs.vs_status & VIRTIO_CONFIG_STATUS_DRIVER_OK)) in vtinput_read_event()
598 while (vtinput_read_event_from_host(sc->vsc_fd, &event) == 0) { in vtinput_read_event()
600 vtinput_eventqueue_add_event(&sc->vsc_eventqueue, &event); in vtinput_read_event()
609 &sc->vsc_eventqueue, &sc->vsc_queues[VTINPUT_EVENTQ]); in vtinput_read_event()
617 return (-1); in pci_vtinput_legacy_config()
621 * virtio-input,/dev/input/eventX in pci_vtinput_legacy_config()
628 char *path = strndup(opts, cp - opts); in pci_vtinput_legacy_config()
648 sc->vsc_evdev = get_config_value_node(nvl, "path"); in pci_vtinput_init()
649 if (sc->vsc_evdev == NULL) { in pci_vtinput_init()
658 sc->vsc_fd = open(sc->vsc_evdev, O_RDWR | O_NONBLOCK); in pci_vtinput_init()
659 if (sc->vsc_fd < 0) { in pci_vtinput_init()
660 WPRINTF(("%s: failed to open %s", __func__, sc->vsc_evdev)); in pci_vtinput_init()
666 int error = ioctl(sc->vsc_fd, EVIOCGVERSION, &evversion); in pci_vtinput_init()
668 WPRINTF(("%s: %s is no evdev", __func__, sc->vsc_evdev)); in pci_vtinput_init()
673 error = ioctl(sc->vsc_fd, EVIOCGRAB, 1); in pci_vtinput_init()
675 WPRINTF(("%s: failed to grab %s", __func__, sc->vsc_evdev)); in pci_vtinput_init()
687 if (pthread_mutex_init(&sc->vsc_mtx, &mtx_attr)) { in pci_vtinput_init()
693 sc->vsc_eventqueue.idx = 0; in pci_vtinput_init()
694 sc->vsc_eventqueue.size = VTINPUT_MAX_PKT_LEN; in pci_vtinput_init()
695 sc->vsc_eventqueue.events = calloc( in pci_vtinput_init()
696 sc->vsc_eventqueue.size, sizeof(struct vtinput_event_elem)); in pci_vtinput_init()
697 sc->vsc_config_valid = 0; in pci_vtinput_init()
698 if (sc->vsc_eventqueue.events == NULL) { in pci_vtinput_init()
704 sc->vsc_evp = mevent_add(sc->vsc_fd, EVF_READ, vtinput_read_event, sc); in pci_vtinput_init()
705 if (sc->vsc_evp == NULL) { in pci_vtinput_init()
713 if (caph_rights_limit(sc->vsc_fd, &rights) == -1) { in pci_vtinput_init()
720 &sc->vsc_vs, &vtinput_vi_consts, sc, pi, sc->vsc_queues); in pci_vtinput_init()
721 sc->vsc_vs.vs_mtx = &sc->vsc_mtx; in pci_vtinput_init()
724 sc->vsc_queues[VTINPUT_EVENTQ].vq_qsize = VTINPUT_RINGSZ; in pci_vtinput_init()
725 sc->vsc_queues[VTINPUT_EVENTQ].vq_notify = pci_vtinput_notify_eventq; in pci_vtinput_init()
726 sc->vsc_queues[VTINPUT_STATUSQ].vq_qsize = VTINPUT_RINGSZ; in pci_vtinput_init()
727 sc->vsc_queues[VTINPUT_STATUSQ].vq_notify = pci_vtinput_notify_statusq; in pci_vtinput_init()
738 /* add MSI-X table BAR */ in pci_vtinput_init()
739 if (vi_intr_init(&sc->vsc_vs, 1, fbsdrun_virtio_msix())) in pci_vtinput_init()
742 vi_set_io_bar(&sc->vsc_vs, 0); in pci_vtinput_init()
748 return (-1); in pci_vtinput_init()
751 if (sc->vsc_evp) in pci_vtinput_init()
752 mevent_delete(sc->vsc_evp); in pci_vtinput_init()
753 if (sc->vsc_eventqueue.events) in pci_vtinput_init()
754 free(sc->vsc_eventqueue.events); in pci_vtinput_init()
755 if (sc->vsc_mtx) in pci_vtinput_init()
756 pthread_mutex_destroy(&sc->vsc_mtx); in pci_vtinput_init()
759 if (sc->vsc_fd) in pci_vtinput_init()
760 close(sc->vsc_fd); in pci_vtinput_init()
764 return (-1); in pci_vtinput_init()
768 .pe_emu = "virtio-input",