Lines Matching +full:usb +full:- +full:hs

2  * QEMU USB HID devices
28 #include "hw/usb.h"
35 #include "hw/usb/hid.h"
36 #include "hw/qdev-properties.h"
48 #define TYPE_USB_HID "usb-hid"
67 [STR_PRODUCT_MOUSE] = "QEMU USB Mouse",
68 [STR_PRODUCT_TABLET] = "QEMU USB Tablet",
69 [STR_PRODUCT_KEYBOARD] = "QEMU USB Keyboard",
136 .bInterval = 7, /* 2 ^ (8-1) * 125 usecs = 8 ms */
196 .bInterval = 4, /* 2 ^ (4-1) * 125 usecs = 1 ms */
258 .bInterval = 7, /* 2 ^ (8-1) * 125 usecs = 8 ms */
477 0x15, 0x81, /* Logical Minimum (-0x7f) */
515 0x15, 0x81, /* Logical Minimum (-0x7f) */
561 static void usb_hid_changed(HIDState *hs) in usb_hid_changed() argument
563 USBHIDState *us = container_of(hs, USBHIDState, hid); in usb_hid_changed()
565 usb_wakeup(us->intr, 0); in usb_hid_changed()
572 hid_reset(&us->hid); in usb_hid_handle_reset()
579 HIDState *hs = &us->hid; in usb_hid_handle_control() local
592 if (hs->kind == HID_MOUSE) { in usb_hid_handle_control()
595 p->actual_length = sizeof(qemu_mouse_hid_report_descriptor); in usb_hid_handle_control()
596 } else if (hs->kind == HID_TABLET) { in usb_hid_handle_control()
599 p->actual_length = sizeof(qemu_tablet_hid_report_descriptor); in usb_hid_handle_control()
600 } else if (hs->kind == HID_KEYBOARD) { in usb_hid_handle_control()
603 p->actual_length = sizeof(qemu_keyboard_hid_report_descriptor); in usb_hid_handle_control()
611 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { in usb_hid_handle_control()
612 p->actual_length = hid_pointer_poll(hs, data, length); in usb_hid_handle_control()
613 } else if (hs->kind == HID_KEYBOARD) { in usb_hid_handle_control()
614 p->actual_length = hid_keyboard_poll(hs, data, length); in usb_hid_handle_control()
618 if (hs->kind == HID_KEYBOARD) { in usb_hid_handle_control()
619 p->actual_length = hid_keyboard_write(hs, data, length); in usb_hid_handle_control()
625 if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) { in usb_hid_handle_control()
628 data[0] = hs->protocol; in usb_hid_handle_control()
629 p->actual_length = 1; in usb_hid_handle_control()
632 if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) { in usb_hid_handle_control()
635 hs->protocol = value; in usb_hid_handle_control()
638 data[0] = hs->idle; in usb_hid_handle_control()
639 p->actual_length = 1; in usb_hid_handle_control()
642 hs->idle = (uint8_t) (value >> 8); in usb_hid_handle_control()
643 hid_set_next_idle(hs); in usb_hid_handle_control()
644 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { in usb_hid_handle_control()
645 hid_pointer_activate(hs); in usb_hid_handle_control()
650 p->status = USB_RET_STALL; in usb_hid_handle_control()
658 HIDState *hs = &us->hid; in usb_hid_handle_data() local
659 g_autofree uint8_t *buf = g_malloc(p->iov.size); in usb_hid_handle_data()
662 switch (p->pid) { in usb_hid_handle_data()
664 if (p->ep->nr == 1) { in usb_hid_handle_data()
665 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { in usb_hid_handle_data()
666 hid_pointer_activate(hs); in usb_hid_handle_data()
668 if (!hid_has_events(hs)) { in usb_hid_handle_data()
669 p->status = USB_RET_NAK; in usb_hid_handle_data()
672 hid_set_next_idle(hs); in usb_hid_handle_data()
673 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { in usb_hid_handle_data()
674 len = hid_pointer_poll(hs, buf, p->iov.size); in usb_hid_handle_data()
675 } else if (hs->kind == HID_KEYBOARD) { in usb_hid_handle_data()
676 len = hid_keyboard_poll(hs, buf, p->iov.size); in usb_hid_handle_data()
686 p->status = USB_RET_STALL; in usb_hid_handle_data()
695 hid_free(&us->hid); in usb_hid_unrealize()
703 switch (us->usb_version) { in usb_hid_initfn()
705 dev->usb_desc = usb1; in usb_hid_initfn()
708 dev->usb_desc = usb2; in usb_hid_initfn()
711 dev->usb_desc = NULL; in usb_hid_initfn()
713 if (!dev->usb_desc) { in usb_hid_initfn()
714 error_setg(errp, "Invalid usb version %d for usb hid device", in usb_hid_initfn()
715 us->usb_version); in usb_hid_initfn()
721 us->intr = usb_ep_get(dev, USB_TOKEN_IN, 1); in usb_hid_initfn()
722 hid_init(&us->hid, kind, usb_hid_changed); in usb_hid_initfn()
723 if (us->display && us->hid.s) { in usb_hid_initfn()
724 qemu_input_handler_bind(us->hid.s, us->display, us->head, NULL); in usb_hid_initfn()
748 if (s->dev.remote_wakeup) { in usb_ptr_post_load()
749 hid_pointer_activate(&s->hid); in usb_ptr_post_load()
755 .name = "usb-ptr",
767 .name = "usb-kbd",
781 uc->handle_reset = usb_hid_handle_reset; in usb_hid_class_initfn()
782 uc->handle_control = usb_hid_handle_control; in usb_hid_class_initfn()
783 uc->handle_data = usb_hid_handle_data; in usb_hid_class_initfn()
784 uc->unrealize = usb_hid_unrealize; in usb_hid_class_initfn()
785 uc->handle_attach = usb_desc_attach; in usb_hid_class_initfn()
808 uc->realize = usb_tablet_realize; in usb_tablet_class_initfn()
809 uc->product_desc = "QEMU USB Tablet"; in usb_tablet_class_initfn()
810 dc->vmsd = &vmstate_usb_ptr; in usb_tablet_class_initfn()
812 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); in usb_tablet_class_initfn()
816 .name = "usb-tablet",
831 uc->realize = usb_mouse_realize; in usb_mouse_class_initfn()
832 uc->product_desc = "QEMU USB Mouse"; in usb_mouse_class_initfn()
833 dc->vmsd = &vmstate_usb_ptr; in usb_mouse_class_initfn()
835 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); in usb_mouse_class_initfn()
839 .name = "usb-mouse",
855 uc->realize = usb_keyboard_realize; in usb_keyboard_class_initfn()
856 uc->product_desc = "QEMU USB Keyboard"; in usb_keyboard_class_initfn()
857 dc->vmsd = &vmstate_usb_kbd; in usb_keyboard_class_initfn()
859 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); in usb_keyboard_class_initfn()
863 .name = "usb-kbd",
872 usb_legacy_register("usb-tablet", "tablet", NULL); in usb_hid_register_types()
874 usb_legacy_register("usb-mouse", "mouse", NULL); in usb_hid_register_types()
876 usb_legacy_register("usb-kbd", "keyboard", NULL); in usb_hid_register_types()