Merge remote-tracking branch 'kraxel/seabios' into staging
[qemu.git] / hw / usb-hid.c
blobe5d57de8889f6c5a44e743d6769eea6cb0d992b1
1 /*
2 * QEMU USB HID devices
4 * Copyright (c) 2005 Fabrice Bellard
5 * Copyright (c) 2007 OpenMoko, Inc. (andrew@openedhand.com)
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
25 #include "hw.h"
26 #include "console.h"
27 #include "usb.h"
28 #include "usb-desc.h"
29 #include "qemu-timer.h"
30 #include "hid.h"
32 /* HID interface requests */
33 #define GET_REPORT 0xa101
34 #define GET_IDLE 0xa102
35 #define GET_PROTOCOL 0xa103
36 #define SET_REPORT 0x2109
37 #define SET_IDLE 0x210a
38 #define SET_PROTOCOL 0x210b
40 /* HID descriptor types */
41 #define USB_DT_HID 0x21
42 #define USB_DT_REPORT 0x22
43 #define USB_DT_PHY 0x23
45 typedef struct USBHIDState {
46 USBDevice dev;
47 HIDState hid;
48 void *datain_opaque;
49 void (*datain)(void *);
50 } USBHIDState;
52 enum {
53 STR_MANUFACTURER = 1,
54 STR_PRODUCT_MOUSE,
55 STR_PRODUCT_TABLET,
56 STR_PRODUCT_KEYBOARD,
57 STR_SERIALNUMBER,
58 STR_CONFIG_MOUSE,
59 STR_CONFIG_TABLET,
60 STR_CONFIG_KEYBOARD,
63 static const USBDescStrings desc_strings = {
64 [STR_MANUFACTURER] = "QEMU " QEMU_VERSION,
65 [STR_PRODUCT_MOUSE] = "QEMU USB Mouse",
66 [STR_PRODUCT_TABLET] = "QEMU USB Tablet",
67 [STR_PRODUCT_KEYBOARD] = "QEMU USB Keyboard",
68 [STR_SERIALNUMBER] = "42", /* == remote wakeup works */
69 [STR_CONFIG_MOUSE] = "HID Mouse",
70 [STR_CONFIG_TABLET] = "HID Tablet",
71 [STR_CONFIG_KEYBOARD] = "HID Keyboard",
74 static const USBDescIface desc_iface_mouse = {
75 .bInterfaceNumber = 0,
76 .bNumEndpoints = 1,
77 .bInterfaceClass = USB_CLASS_HID,
78 .bInterfaceSubClass = 0x01, /* boot */
79 .bInterfaceProtocol = 0x02,
80 .ndesc = 1,
81 .descs = (USBDescOther[]) {
83 /* HID descriptor */
84 .data = (uint8_t[]) {
85 0x09, /* u8 bLength */
86 USB_DT_HID, /* u8 bDescriptorType */
87 0x01, 0x00, /* u16 HID_class */
88 0x00, /* u8 country_code */
89 0x01, /* u8 num_descriptors */
90 USB_DT_REPORT, /* u8 type: Report */
91 52, 0, /* u16 len */
95 .eps = (USBDescEndpoint[]) {
97 .bEndpointAddress = USB_DIR_IN | 0x01,
98 .bmAttributes = USB_ENDPOINT_XFER_INT,
99 .wMaxPacketSize = 4,
100 .bInterval = 0x0a,
105 static const USBDescIface desc_iface_tablet = {
106 .bInterfaceNumber = 0,
107 .bNumEndpoints = 1,
108 .bInterfaceClass = USB_CLASS_HID,
109 .bInterfaceProtocol = 0x02,
110 .ndesc = 1,
111 .descs = (USBDescOther[]) {
113 /* HID descriptor */
114 .data = (uint8_t[]) {
115 0x09, /* u8 bLength */
116 USB_DT_HID, /* u8 bDescriptorType */
117 0x01, 0x00, /* u16 HID_class */
118 0x00, /* u8 country_code */
119 0x01, /* u8 num_descriptors */
120 USB_DT_REPORT, /* u8 type: Report */
121 74, 0, /* u16 len */
125 .eps = (USBDescEndpoint[]) {
127 .bEndpointAddress = USB_DIR_IN | 0x01,
128 .bmAttributes = USB_ENDPOINT_XFER_INT,
129 .wMaxPacketSize = 8,
130 .bInterval = 0x0a,
135 static const USBDescIface desc_iface_keyboard = {
136 .bInterfaceNumber = 0,
137 .bNumEndpoints = 1,
138 .bInterfaceClass = USB_CLASS_HID,
139 .bInterfaceSubClass = 0x01, /* boot */
140 .bInterfaceProtocol = 0x01, /* keyboard */
141 .ndesc = 1,
142 .descs = (USBDescOther[]) {
144 /* HID descriptor */
145 .data = (uint8_t[]) {
146 0x09, /* u8 bLength */
147 USB_DT_HID, /* u8 bDescriptorType */
148 0x11, 0x01, /* u16 HID_class */
149 0x00, /* u8 country_code */
150 0x01, /* u8 num_descriptors */
151 USB_DT_REPORT, /* u8 type: Report */
152 0x3f, 0, /* u16 len */
156 .eps = (USBDescEndpoint[]) {
158 .bEndpointAddress = USB_DIR_IN | 0x01,
159 .bmAttributes = USB_ENDPOINT_XFER_INT,
160 .wMaxPacketSize = 8,
161 .bInterval = 0x0a,
166 static const USBDescDevice desc_device_mouse = {
167 .bcdUSB = 0x0100,
168 .bMaxPacketSize0 = 8,
169 .bNumConfigurations = 1,
170 .confs = (USBDescConfig[]) {
172 .bNumInterfaces = 1,
173 .bConfigurationValue = 1,
174 .iConfiguration = STR_CONFIG_MOUSE,
175 .bmAttributes = 0xa0,
176 .bMaxPower = 50,
177 .nif = 1,
178 .ifs = &desc_iface_mouse,
183 static const USBDescDevice desc_device_tablet = {
184 .bcdUSB = 0x0100,
185 .bMaxPacketSize0 = 8,
186 .bNumConfigurations = 1,
187 .confs = (USBDescConfig[]) {
189 .bNumInterfaces = 1,
190 .bConfigurationValue = 1,
191 .iConfiguration = STR_CONFIG_TABLET,
192 .bmAttributes = 0xa0,
193 .bMaxPower = 50,
194 .nif = 1,
195 .ifs = &desc_iface_tablet,
200 static const USBDescDevice desc_device_keyboard = {
201 .bcdUSB = 0x0100,
202 .bMaxPacketSize0 = 8,
203 .bNumConfigurations = 1,
204 .confs = (USBDescConfig[]) {
206 .bNumInterfaces = 1,
207 .bConfigurationValue = 1,
208 .iConfiguration = STR_CONFIG_KEYBOARD,
209 .bmAttributes = 0xa0,
210 .bMaxPower = 50,
211 .nif = 1,
212 .ifs = &desc_iface_keyboard,
217 static const USBDesc desc_mouse = {
218 .id = {
219 .idVendor = 0x0627,
220 .idProduct = 0x0001,
221 .bcdDevice = 0,
222 .iManufacturer = STR_MANUFACTURER,
223 .iProduct = STR_PRODUCT_MOUSE,
224 .iSerialNumber = STR_SERIALNUMBER,
226 .full = &desc_device_mouse,
227 .str = desc_strings,
230 static const USBDesc desc_tablet = {
231 .id = {
232 .idVendor = 0x0627,
233 .idProduct = 0x0001,
234 .bcdDevice = 0,
235 .iManufacturer = STR_MANUFACTURER,
236 .iProduct = STR_PRODUCT_TABLET,
237 .iSerialNumber = STR_SERIALNUMBER,
239 .full = &desc_device_tablet,
240 .str = desc_strings,
243 static const USBDesc desc_keyboard = {
244 .id = {
245 .idVendor = 0x0627,
246 .idProduct = 0x0001,
247 .bcdDevice = 0,
248 .iManufacturer = STR_MANUFACTURER,
249 .iProduct = STR_PRODUCT_KEYBOARD,
250 .iSerialNumber = STR_SERIALNUMBER,
252 .full = &desc_device_keyboard,
253 .str = desc_strings,
256 static const uint8_t qemu_mouse_hid_report_descriptor[] = {
257 0x05, 0x01, /* Usage Page (Generic Desktop) */
258 0x09, 0x02, /* Usage (Mouse) */
259 0xa1, 0x01, /* Collection (Application) */
260 0x09, 0x01, /* Usage (Pointer) */
261 0xa1, 0x00, /* Collection (Physical) */
262 0x05, 0x09, /* Usage Page (Button) */
263 0x19, 0x01, /* Usage Minimum (1) */
264 0x29, 0x03, /* Usage Maximum (3) */
265 0x15, 0x00, /* Logical Minimum (0) */
266 0x25, 0x01, /* Logical Maximum (1) */
267 0x95, 0x03, /* Report Count (3) */
268 0x75, 0x01, /* Report Size (1) */
269 0x81, 0x02, /* Input (Data, Variable, Absolute) */
270 0x95, 0x01, /* Report Count (1) */
271 0x75, 0x05, /* Report Size (5) */
272 0x81, 0x01, /* Input (Constant) */
273 0x05, 0x01, /* Usage Page (Generic Desktop) */
274 0x09, 0x30, /* Usage (X) */
275 0x09, 0x31, /* Usage (Y) */
276 0x09, 0x38, /* Usage (Wheel) */
277 0x15, 0x81, /* Logical Minimum (-0x7f) */
278 0x25, 0x7f, /* Logical Maximum (0x7f) */
279 0x75, 0x08, /* Report Size (8) */
280 0x95, 0x03, /* Report Count (3) */
281 0x81, 0x06, /* Input (Data, Variable, Relative) */
282 0xc0, /* End Collection */
283 0xc0, /* End Collection */
286 static const uint8_t qemu_tablet_hid_report_descriptor[] = {
287 0x05, 0x01, /* Usage Page (Generic Desktop) */
288 0x09, 0x01, /* Usage (Pointer) */
289 0xa1, 0x01, /* Collection (Application) */
290 0x09, 0x01, /* Usage (Pointer) */
291 0xa1, 0x00, /* Collection (Physical) */
292 0x05, 0x09, /* Usage Page (Button) */
293 0x19, 0x01, /* Usage Minimum (1) */
294 0x29, 0x03, /* Usage Maximum (3) */
295 0x15, 0x00, /* Logical Minimum (0) */
296 0x25, 0x01, /* Logical Maximum (1) */
297 0x95, 0x03, /* Report Count (3) */
298 0x75, 0x01, /* Report Size (1) */
299 0x81, 0x02, /* Input (Data, Variable, Absolute) */
300 0x95, 0x01, /* Report Count (1) */
301 0x75, 0x05, /* Report Size (5) */
302 0x81, 0x01, /* Input (Constant) */
303 0x05, 0x01, /* Usage Page (Generic Desktop) */
304 0x09, 0x30, /* Usage (X) */
305 0x09, 0x31, /* Usage (Y) */
306 0x15, 0x00, /* Logical Minimum (0) */
307 0x26, 0xff, 0x7f, /* Logical Maximum (0x7fff) */
308 0x35, 0x00, /* Physical Minimum (0) */
309 0x46, 0xff, 0x7f, /* Physical Maximum (0x7fff) */
310 0x75, 0x10, /* Report Size (16) */
311 0x95, 0x02, /* Report Count (2) */
312 0x81, 0x02, /* Input (Data, Variable, Absolute) */
313 0x05, 0x01, /* Usage Page (Generic Desktop) */
314 0x09, 0x38, /* Usage (Wheel) */
315 0x15, 0x81, /* Logical Minimum (-0x7f) */
316 0x25, 0x7f, /* Logical Maximum (0x7f) */
317 0x35, 0x00, /* Physical Minimum (same as logical) */
318 0x45, 0x00, /* Physical Maximum (same as logical) */
319 0x75, 0x08, /* Report Size (8) */
320 0x95, 0x01, /* Report Count (1) */
321 0x81, 0x06, /* Input (Data, Variable, Relative) */
322 0xc0, /* End Collection */
323 0xc0, /* End Collection */
326 static const uint8_t qemu_keyboard_hid_report_descriptor[] = {
327 0x05, 0x01, /* Usage Page (Generic Desktop) */
328 0x09, 0x06, /* Usage (Keyboard) */
329 0xa1, 0x01, /* Collection (Application) */
330 0x75, 0x01, /* Report Size (1) */
331 0x95, 0x08, /* Report Count (8) */
332 0x05, 0x07, /* Usage Page (Key Codes) */
333 0x19, 0xe0, /* Usage Minimum (224) */
334 0x29, 0xe7, /* Usage Maximum (231) */
335 0x15, 0x00, /* Logical Minimum (0) */
336 0x25, 0x01, /* Logical Maximum (1) */
337 0x81, 0x02, /* Input (Data, Variable, Absolute) */
338 0x95, 0x01, /* Report Count (1) */
339 0x75, 0x08, /* Report Size (8) */
340 0x81, 0x01, /* Input (Constant) */
341 0x95, 0x05, /* Report Count (5) */
342 0x75, 0x01, /* Report Size (1) */
343 0x05, 0x08, /* Usage Page (LEDs) */
344 0x19, 0x01, /* Usage Minimum (1) */
345 0x29, 0x05, /* Usage Maximum (5) */
346 0x91, 0x02, /* Output (Data, Variable, Absolute) */
347 0x95, 0x01, /* Report Count (1) */
348 0x75, 0x03, /* Report Size (3) */
349 0x91, 0x01, /* Output (Constant) */
350 0x95, 0x06, /* Report Count (6) */
351 0x75, 0x08, /* Report Size (8) */
352 0x15, 0x00, /* Logical Minimum (0) */
353 0x25, 0xff, /* Logical Maximum (255) */
354 0x05, 0x07, /* Usage Page (Key Codes) */
355 0x19, 0x00, /* Usage Minimum (0) */
356 0x29, 0xff, /* Usage Maximum (255) */
357 0x81, 0x00, /* Input (Data, Array) */
358 0xc0, /* End Collection */
361 static void usb_hid_changed(HIDState *hs)
363 USBHIDState *us = container_of(hs, USBHIDState, hid);
365 if (us->datain) {
366 us->datain(us->datain_opaque);
369 usb_wakeup(&us->dev);
372 static void usb_hid_handle_reset(USBDevice *dev)
374 USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
376 hid_reset(&us->hid);
379 static int usb_hid_handle_control(USBDevice *dev, USBPacket *p,
380 int request, int value, int index, int length, uint8_t *data)
382 USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
383 HIDState *hs = &us->hid;
384 int ret;
386 ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
387 if (ret >= 0) {
388 return ret;
391 ret = 0;
392 switch (request) {
393 case DeviceRequest | USB_REQ_GET_INTERFACE:
394 data[0] = 0;
395 ret = 1;
396 break;
397 case DeviceOutRequest | USB_REQ_SET_INTERFACE:
398 ret = 0;
399 break;
400 /* hid specific requests */
401 case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
402 switch (value >> 8) {
403 case 0x22:
404 if (hs->kind == HID_MOUSE) {
405 memcpy(data, qemu_mouse_hid_report_descriptor,
406 sizeof(qemu_mouse_hid_report_descriptor));
407 ret = sizeof(qemu_mouse_hid_report_descriptor);
408 } else if (hs->kind == HID_TABLET) {
409 memcpy(data, qemu_tablet_hid_report_descriptor,
410 sizeof(qemu_tablet_hid_report_descriptor));
411 ret = sizeof(qemu_tablet_hid_report_descriptor);
412 } else if (hs->kind == HID_KEYBOARD) {
413 memcpy(data, qemu_keyboard_hid_report_descriptor,
414 sizeof(qemu_keyboard_hid_report_descriptor));
415 ret = sizeof(qemu_keyboard_hid_report_descriptor);
417 break;
418 default:
419 goto fail;
421 break;
422 case GET_REPORT:
423 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
424 ret = hid_pointer_poll(hs, data, length);
425 } else if (hs->kind == HID_KEYBOARD) {
426 ret = hid_keyboard_poll(hs, data, length);
428 break;
429 case SET_REPORT:
430 if (hs->kind == HID_KEYBOARD) {
431 ret = hid_keyboard_write(hs, data, length);
432 } else {
433 goto fail;
435 break;
436 case GET_PROTOCOL:
437 if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) {
438 goto fail;
440 ret = 1;
441 data[0] = hs->protocol;
442 break;
443 case SET_PROTOCOL:
444 if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) {
445 goto fail;
447 ret = 0;
448 hs->protocol = value;
449 break;
450 case GET_IDLE:
451 ret = 1;
452 data[0] = hs->idle;
453 break;
454 case SET_IDLE:
455 hs->idle = (uint8_t) (value >> 8);
456 hid_set_next_idle(hs, qemu_get_clock_ns(vm_clock));
457 ret = 0;
458 break;
459 default:
460 fail:
461 ret = USB_RET_STALL;
462 break;
464 return ret;
467 static int usb_hid_handle_data(USBDevice *dev, USBPacket *p)
469 USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
470 HIDState *hs = &us->hid;
471 uint8_t buf[p->iov.size];
472 int ret = 0;
474 switch (p->pid) {
475 case USB_TOKEN_IN:
476 if (p->devep == 1) {
477 int64_t curtime = qemu_get_clock_ns(vm_clock);
478 if (!hid_has_events(hs) &&
479 (!hs->idle || hs->next_idle_clock - curtime > 0)) {
480 return USB_RET_NAK;
482 hid_set_next_idle(hs, curtime);
483 if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
484 ret = hid_pointer_poll(hs, buf, p->iov.size);
485 } else if (hs->kind == HID_KEYBOARD) {
486 ret = hid_keyboard_poll(hs, buf, p->iov.size);
488 usb_packet_copy(p, buf, ret);
489 } else {
490 goto fail;
492 break;
493 case USB_TOKEN_OUT:
494 default:
495 fail:
496 ret = USB_RET_STALL;
497 break;
499 return ret;
502 static void usb_hid_handle_destroy(USBDevice *dev)
504 USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
506 hid_free(&us->hid);
509 static int usb_hid_initfn(USBDevice *dev, int kind)
511 USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev);
513 usb_desc_init(dev);
514 hid_init(&us->hid, kind, usb_hid_changed);
515 return 0;
518 static int usb_tablet_initfn(USBDevice *dev)
520 return usb_hid_initfn(dev, HID_TABLET);
523 static int usb_mouse_initfn(USBDevice *dev)
525 return usb_hid_initfn(dev, HID_MOUSE);
528 static int usb_keyboard_initfn(USBDevice *dev)
530 return usb_hid_initfn(dev, HID_KEYBOARD);
533 void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *))
535 USBHIDState *s = (USBHIDState *)dev;
537 s->datain_opaque = opaque;
538 s->datain = datain;
541 static int usb_hid_post_load(void *opaque, int version_id)
543 USBHIDState *s = opaque;
545 if (s->hid.idle) {
546 hid_set_next_idle(&s->hid, qemu_get_clock_ns(vm_clock));
548 return 0;
551 static const VMStateDescription vmstate_usb_ptr_queue = {
552 .name = "usb-ptr-queue",
553 .version_id = 1,
554 .minimum_version_id = 1,
555 .fields = (VMStateField []) {
556 VMSTATE_INT32(xdx, HIDPointerEvent),
557 VMSTATE_INT32(ydy, HIDPointerEvent),
558 VMSTATE_INT32(dz, HIDPointerEvent),
559 VMSTATE_INT32(buttons_state, HIDPointerEvent),
560 VMSTATE_END_OF_LIST()
563 static const VMStateDescription vmstate_usb_ptr = {
564 .name = "usb-ptr",
565 .version_id = 1,
566 .minimum_version_id = 1,
567 .post_load = usb_hid_post_load,
568 .fields = (VMStateField []) {
569 VMSTATE_USB_DEVICE(dev, USBHIDState),
570 VMSTATE_STRUCT_ARRAY(hid.ptr.queue, USBHIDState, QUEUE_LENGTH, 0,
571 vmstate_usb_ptr_queue, HIDPointerEvent),
572 VMSTATE_UINT32(hid.head, USBHIDState),
573 VMSTATE_UINT32(hid.n, USBHIDState),
574 VMSTATE_INT32(hid.protocol, USBHIDState),
575 VMSTATE_UINT8(hid.idle, USBHIDState),
576 VMSTATE_END_OF_LIST()
580 static const VMStateDescription vmstate_usb_kbd = {
581 .name = "usb-kbd",
582 .version_id = 1,
583 .minimum_version_id = 1,
584 .post_load = usb_hid_post_load,
585 .fields = (VMStateField []) {
586 VMSTATE_USB_DEVICE(dev, USBHIDState),
587 VMSTATE_UINT32_ARRAY(hid.kbd.keycodes, USBHIDState, QUEUE_LENGTH),
588 VMSTATE_UINT32(hid.head, USBHIDState),
589 VMSTATE_UINT32(hid.n, USBHIDState),
590 VMSTATE_UINT16(hid.kbd.modifiers, USBHIDState),
591 VMSTATE_UINT8(hid.kbd.leds, USBHIDState),
592 VMSTATE_UINT8_ARRAY(hid.kbd.key, USBHIDState, 16),
593 VMSTATE_INT32(hid.kbd.keys, USBHIDState),
594 VMSTATE_INT32(hid.protocol, USBHIDState),
595 VMSTATE_UINT8(hid.idle, USBHIDState),
596 VMSTATE_END_OF_LIST()
600 static struct USBDeviceInfo hid_info[] = {
602 .product_desc = "QEMU USB Tablet",
603 .qdev.name = "usb-tablet",
604 .usbdevice_name = "tablet",
605 .qdev.size = sizeof(USBHIDState),
606 .qdev.vmsd = &vmstate_usb_ptr,
607 .usb_desc = &desc_tablet,
608 .init = usb_tablet_initfn,
609 .handle_packet = usb_generic_handle_packet,
610 .handle_reset = usb_hid_handle_reset,
611 .handle_control = usb_hid_handle_control,
612 .handle_data = usb_hid_handle_data,
613 .handle_destroy = usb_hid_handle_destroy,
615 .product_desc = "QEMU USB Mouse",
616 .qdev.name = "usb-mouse",
617 .usbdevice_name = "mouse",
618 .qdev.size = sizeof(USBHIDState),
619 .qdev.vmsd = &vmstate_usb_ptr,
620 .usb_desc = &desc_mouse,
621 .init = usb_mouse_initfn,
622 .handle_packet = usb_generic_handle_packet,
623 .handle_reset = usb_hid_handle_reset,
624 .handle_control = usb_hid_handle_control,
625 .handle_data = usb_hid_handle_data,
626 .handle_destroy = usb_hid_handle_destroy,
628 .product_desc = "QEMU USB Keyboard",
629 .qdev.name = "usb-kbd",
630 .usbdevice_name = "keyboard",
631 .qdev.size = sizeof(USBHIDState),
632 .qdev.vmsd = &vmstate_usb_kbd,
633 .usb_desc = &desc_keyboard,
634 .init = usb_keyboard_initfn,
635 .handle_packet = usb_generic_handle_packet,
636 .handle_reset = usb_hid_handle_reset,
637 .handle_control = usb_hid_handle_control,
638 .handle_data = usb_hid_handle_data,
639 .handle_destroy = usb_hid_handle_destroy,
641 /* end of list */
645 static void usb_hid_register_devices(void)
647 usb_qdev_register_many(hid_info);
649 device_init(usb_hid_register_devices)