Lines Matching full:vi
39 static void vi_input_send(VuInput *vi, struct virtio_input_event *event) in vi_input_send() argument
41 VuDev *dev = &vi->dev.parent; in vi_input_send()
47 if (vi->qindex == vi->qsize) { in vi_input_send()
48 vi->qsize++; in vi_input_send()
49 vi->queue = g_realloc_n(vi->queue, vi->qsize, sizeof(vi->queue[0])); in vi_input_send()
51 vi->queue[vi->qindex++].event = *event; in vi_input_send()
60 for (i = 0; i < vi->qindex; i++) { in vi_input_send()
64 vu_queue_unpop(dev, vq, vi->queue[i].elem, 0); in vi_input_send()
66 vi->qindex = 0; in vi_input_send()
70 vi->queue[i].elem = elem; in vi_input_send()
74 for (i = 0; i < vi->qindex; i++) { in vi_input_send()
75 elem = vi->queue[i].elem; in vi_input_send()
77 0, &vi->queue[i].event, sizeof(virtio_input_event)); in vi_input_send()
82 vu_queue_notify(&vi->dev.parent, vq); in vi_input_send()
83 vi->qindex = 0; in vi_input_send()
89 VuInput *vi = data; in vi_evdev_watch() local
90 int fd = vi->evdevfd; in vi_evdev_watch()
109 vi_input_send(vi, &virtio); in vi_evdev_watch()
114 static void vi_handle_status(VuInput *vi, virtio_input_event *event) in vi_handle_status() argument
131 rc = write(vi->evdevfd, &evdev, sizeof(evdev)); in vi_handle_status()
139 VuInput *vi = container_of(dev, VuInput, dev.parent); in vi_handle_sts() local
156 vi_handle_status(vi, &event); in vi_handle_sts()
161 vu_queue_notify(&vi->dev.parent, vq); in vi_handle_sts()
174 VuInput *vi = container_of(dev, VuInput, dev.parent); in vi_queue_set_started() local
186 if (started && !vi->evsrc) { in vi_queue_set_started()
187 vi->evsrc = vug_source_new(&vi->dev, vi->evdevfd, in vi_queue_set_started()
188 G_IO_IN, vi_evdev_watch, vi); in vi_queue_set_started()
191 if (!started && vi->evsrc) { in vi_queue_set_started()
192 vug_source_destroy(vi->evsrc); in vi_queue_set_started()
193 vi->evsrc = NULL; in vi_queue_set_started()
198 vi_find_config(VuInput *vi, uint8_t select, uint8_t subsel) in vi_find_config() argument
203 for (i = 0; i < vi->config->len; i++) { in vi_find_config()
204 cfg = &g_array_index(vi->config, virtio_input_config, i); in vi_find_config()
215 VuInput *vi = container_of(dev, VuInput, dev.parent); in vi_get_config() local
217 if (len > sizeof(*vi->sel_config)) { in vi_get_config()
221 if (vi->sel_config) { in vi_get_config()
222 memcpy(config, vi->sel_config, len); in vi_get_config()
234 VuInput *vi = container_of(dev, VuInput, dev.parent); in vi_set_config() local
237 vi->sel_config = vi_find_config(vi, config->select, config->subsel); in vi_set_config()
249 vi_bits_config(VuInput *vi, int type, int count) in vi_bits_config() argument
255 rc = ioctl(vi->evdevfd, EVIOCGBIT(type, count / 8), bits.u.bitmap); in vi_bits_config()
272 g_array_append_val(vi->config, bits); in vi_bits_config()
299 VuInput vi = { 0, }; in main() local
331 vi.evdevfd = open(opt_evdev, O_RDWR); in main()
332 if (vi.evdevfd < 0) { in main()
337 rc = ioctl(vi.evdevfd, EVIOCGVERSION, &ver); in main()
344 rc = ioctl(vi.evdevfd, EVIOCGRAB, 1); in main()
351 vi.config = g_array_new(false, false, sizeof(virtio_input_config)); in main()
353 if (ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1), in main()
360 g_array_append_val(vi.config, id); in main()
362 if (ioctl(vi.evdevfd, EVIOCGID, &ids) == 0) { in main()
370 g_array_append_val(vi.config, id); in main()
373 vi_bits_config(&vi, EV_KEY, KEY_CNT); in main()
374 vi_bits_config(&vi, EV_REL, REL_CNT); in main()
375 vi_bits_config(&vi, EV_ABS, ABS_CNT); in main()
376 vi_bits_config(&vi, EV_MSC, MSC_CNT); in main()
377 vi_bits_config(&vi, EV_SW, SW_CNT); in main()
378 g_debug("config length: %u", vi.config->len); in main()
396 if (!vug_init(&vi.dev, VHOST_USER_INPUT_MAX_QUEUES, fd, vi_panic, in main()
406 vug_deinit(&vi.dev); in main()
408 vug_source_destroy(vi.evsrc); in main()
409 g_array_free(vi.config, TRUE); in main()
410 g_free(vi.queue); in main()