/* * Logitech Unifying recever emulation. * * Copyright (c) 2014 Peter Wu * * Based on: hw/usb/dev-wacom.c: * Copyright (c) 2006 Openedhand Ltd. * Author: Andrzej Zaborowski * * Based on hw/usb-hid.c: * Copyright (c) 2005 Fabrice Bellard * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "hw/hw.h" #include "ui/console.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "dump.h" #include "hw/input/hid.h" #include "hw/usb/hid-logitech-dj.h" /* descriptors are retrieved with usbhid-dump (need to unbind interfaces from * usbhid) and prettified with hidrd 0.2 */ /* keyboard */ static const uint8_t iface0_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x06, /* Usage (Keyboard), */ 0xA1, 0x01, /* Collection (Application), */ 0x05, 0x07, /* Usage Page (Keyboard), */ 0x19, 0xE0, /* Usage Minimum (KB Leftcontrol), */ 0x29, 0xE7, /* Usage Maximum (KB Right GUI), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x25, 0x01, /* Logical Maximum (1), */ 0x75, 0x01, /* Report Size (1), */ 0x95, 0x08, /* Report Count (8), */ 0x81, 0x02, /* Input (Variable), */ 0x81, 0x03, /* Input (Constant, Variable), */ 0x95, 0x05, /* Report Count (5), */ 0x05, 0x08, /* Usage Page (LED), */ 0x19, 0x01, /* Usage Minimum (01h), */ 0x29, 0x05, /* Usage Maximum (05h), */ 0x91, 0x02, /* Output (Variable), */ 0x95, 0x01, /* Report Count (1), */ 0x75, 0x03, /* Report Size (3), */ 0x91, 0x01, /* Output (Constant), */ 0x95, 0x06, /* Report Count (6), */ 0x75, 0x08, /* Report Size (8), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x26, 0xA4, 0x00, /* Logical Maximum (164), */ 0x05, 0x07, /* Usage Page (Keyboard), */ 0x19, 0x00, /* Usage Minimum (None), */ 0x2A, 0xA4, 0x00, /* Usage Maximum (KB ExSel), */ 0x81, 0x00, /* Input, */ 0xC0 /* End Collection */ }; /* mouse, multimedia, power, media center */ static const uint8_t iface1_hid_report_descriptor[] = { 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x02, /* Usage (Mouse), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x02, /* Report ID (2), */ 0x09, 0x01, /* Usage (Pointer), */ 0xA1, 0x00, /* Collection (Physical), */ 0x05, 0x09, /* Usage Page (Button), */ 0x19, 0x01, /* Usage Minimum (01h), */ 0x29, 0x10, /* Usage Maximum (10h), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x25, 0x01, /* Logical Maximum (1), */ 0x95, 0x10, /* Report Count (16), */ 0x75, 0x01, /* Report Size (1), */ 0x81, 0x02, /* Input (Variable), */ 0x05, 0x01, /* Usage Page (Desktop), */ 0x16, 0x01, 0xF8, /* Logical Minimum (-2047), */ 0x26, 0xFF, 0x07, /* Logical Maximum (2047), */ 0x75, 0x0C, /* Report Size (12), */ 0x95, 0x02, /* Report Count (2), */ 0x09, 0x30, /* Usage (X), */ 0x09, 0x31, /* Usage (Y), */ 0x81, 0x06, /* Input (Variable, Relative), */ 0x15, 0x81, /* Logical Minimum (-127), */ 0x25, 0x7F, /* Logical Maximum (127), */ 0x75, 0x08, /* Report Size (8), */ 0x95, 0x01, /* Report Count (1), */ 0x09, 0x38, /* Usage (Wheel), */ 0x81, 0x06, /* Input (Variable, Relative), */ 0x05, 0x0C, /* Usage Page (Consumer), */ 0x0A, 0x38, 0x02, /* Usage (AC Pan), */ 0x95, 0x01, /* Report Count (1), */ 0x81, 0x06, /* Input (Variable, Relative), */ 0xC0, /* End Collection, */ 0xC0, /* End Collection, */ 0x05, 0x0C, /* Usage Page (Consumer), */ 0x09, 0x01, /* Usage (Consumer Control), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x03, /* Report ID (3), */ 0x75, 0x10, /* Report Size (16), */ 0x95, 0x02, /* Report Count (2), */ 0x15, 0x01, /* Logical Minimum (1), */ 0x26, 0x8C, 0x02, /* Logical Maximum (652), */ 0x19, 0x01, /* Usage Minimum (Consumer Control), */ 0x2A, 0x8C, 0x02, /* Usage Maximum (AC Send), */ 0x81, 0x00, /* Input, */ 0xC0, /* End Collection, */ 0x05, 0x01, /* Usage Page (Desktop), */ 0x09, 0x80, /* Usage (Sys Control), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x04, /* Report ID (4), */ 0x75, 0x02, /* Report Size (2), */ 0x95, 0x01, /* Report Count (1), */ 0x15, 0x01, /* Logical Minimum (1), */ 0x25, 0x03, /* Logical Maximum (3), */ 0x09, 0x82, /* Usage (Sys Sleep), */ 0x09, 0x81, /* Usage (Sys Power Down), */ 0x09, 0x83, /* Usage (Sys Wake Up), */ 0x81, 0x60, /* Input (No Preferred, Null State), */ 0x75, 0x06, /* Report Size (6), */ 0x81, 0x03, /* Input (Constant, Variable), */ 0xC0, /* End Collection, */ 0x06, 0xBC, 0xFF, /* Usage Page (FFBCh), */ 0x09, 0x88, /* Usage (88h), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x08, /* Report ID (8), */ 0x19, 0x01, /* Usage Minimum (01h), */ 0x29, 0xFF, /* Usage Maximum (FFh), */ 0x15, 0x01, /* Logical Minimum (1), */ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 0x75, 0x08, /* Report Size (8), */ 0x95, 0x01, /* Report Count (1), */ 0x81, 0x00, /* Input, */ 0xC0 /* End Collection */ }; /* vendor specific: short HID++, long HID++, DJ */ static const uint8_t iface2_hid_report_descriptor[] = { 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 0x09, 0x01, /* Usage (01h), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x10, /* Report ID (16), */ 0x75, 0x08, /* Report Size (8), */ 0x95, 0x06, /* Report Count (6), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 0x09, 0x01, /* Usage (01h), */ 0x81, 0x00, /* Input, */ 0x09, 0x01, /* Usage (01h), */ 0x91, 0x00, /* Output, */ 0xC0, /* End Collection, */ 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 0x09, 0x02, /* Usage (02h), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x11, /* Report ID (17), */ 0x75, 0x08, /* Report Size (8), */ 0x95, 0x13, /* Report Count (19), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 0x09, 0x02, /* Usage (02h), */ 0x81, 0x00, /* Input, */ 0x09, 0x02, /* Usage (02h), */ 0x91, 0x00, /* Output, */ 0xC0, /* End Collection, */ 0x06, 0x00, 0xFF, /* Usage Page (FF00h), */ 0x09, 0x04, /* Usage (04h), */ 0xA1, 0x01, /* Collection (Application), */ 0x85, 0x20, /* Report ID (32), */ 0x75, 0x08, /* Report Size (8), */ 0x95, 0x0E, /* Report Count (14), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 0x09, 0x41, /* Usage (41h), */ 0x81, 0x00, /* Input, */ 0x09, 0x41, /* Usage (41h), */ 0x91, 0x00, /* Output, */ 0x85, 0x21, /* Report ID (33), */ 0x95, 0x1F, /* Report Count (31), */ 0x15, 0x00, /* Logical Minimum (0), */ 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ 0x09, 0x42, /* Usage (42h), */ 0x81, 0x00, /* Input, */ 0x09, 0x42, /* Usage (42h), */ 0x91, 0x00, /* Output, */ 0xC0 /* End Collection */ }; enum { STR_MANUFACTURER = 1, STR_PRODUCT = 2, /* string descriptor 3 is not defined */ STR_CONFIG_FULL = 4, }; static const USBDescStrings desc_strings = { [STR_MANUFACTURER] = "Logitech", [STR_PRODUCT] = "USB Receiver", // Other string: RQR24.00_B0018, bcdDevice = 24.00, bMaxPacketSize0 = 32 [STR_CONFIG_FULL] = "RQR12.01_B0019", }; static const USBDescIface desc_iface_ltunify[] = { { /* DJ disabled: keyboard, DJ enabled: unused */ .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, .bInterfaceSubClass = 0x01, /* boot */ .bInterfaceProtocol = 0x01, /* Keyboard */ .ndesc = 1, .descs = (USBDescOther[]) { { /* HID descriptor */ .data = (uint8_t[]) { 0x09, /* u8 bLength */ 0x21, /* u8 bDescriptorType */ 0x11, 0x01, /* u16 HID_class */ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type: Report */ 59, 0, /* u16 len */ }, }, }, .eps = (USBDescEndpoint[]) { { .bEndpointAddress = USB_DIR_IN | 0x01, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 8, .bInterval = 8, }, }, },{ /* DJ disabled: mouse, multimedia, power, media center. DJ enabled: * unused */ .bInterfaceNumber = 1, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, .bInterfaceSubClass = 0x01, /* boot */ .bInterfaceProtocol = 0x02, /* Mouse */ .ndesc = 1, .descs = (USBDescOther[]) { { /* HID descriptor */ .data = (uint8_t[]) { 0x09, /* u8 bLength */ 0x21, /* u8 bDescriptorType */ 0x11, 0x01, /* u16 HID_class */ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type: Report */ 148, 0, /* u16 len */ }, }, }, .eps = (USBDescEndpoint[]) { { .bEndpointAddress = USB_DIR_IN | 0x02, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 8, .bInterval = 2, }, }, },{ /* Short HID++, Long HID++, DJ (if enabled) */ .bInterfaceNumber = 2, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, .bInterfaceSubClass = 0x00, /* No Subclass */ .bInterfaceProtocol = 0x00, /* None */ .ndesc = 1, .descs = (USBDescOther[]) { { /* HID descriptor */ .data = (uint8_t[]) { 0x09, /* u8 bLength */ 0x21, /* u8 bDescriptorType */ 0x11, 0x01, /* u16 HID_class */ 0x00, /* u8 country_code */ 0x01, /* u8 num_descriptors */ 0x22, /* u8 type: Report */ 98, 0, /* u16 len */ }, }, }, .eps = (USBDescEndpoint[]) { { .bEndpointAddress = USB_DIR_IN | 0x03, .bmAttributes = USB_ENDPOINT_XFER_INT, .wMaxPacketSize = 0x20, .bInterval = 2, }, }, }, }; static const USBDescDevice desc_device_ltunify = { .bcdUSB = 0x0200, .bMaxPacketSize0 = 8, .bNumConfigurations = 1, .confs = (USBDescConfig[]) { { .bNumInterfaces = 3, .bConfigurationValue = 1, .iConfiguration = STR_CONFIG_FULL, .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 49, /* 98 mA */ .nif = ARRAY_SIZE(desc_iface_ltunify), .ifs = desc_iface_ltunify, }, }, }; static const USBDesc desc_ltunify = { .id = { .idVendor = 0x046d, .idProduct = 0xc52b, .bcdDevice = 0x1201, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, .iSerialNumber = 0, /* device does not have such a serial number */ }, .full = &desc_device_ltunify, .str = desc_strings, }; /* temporary helper to find a paired device matching this HID device */ static LHidDevice *find_lhid_device(USBLtunifyState *s, HIDState *hs) { int i; LHidDevice *hd; for (i = 0; i < MAX_DEVICES; i++) { hd = &s->devices[i]; if (hd->hid == hs) { return hd; } } return NULL; } /* Called when the host mouse or keyboard generates an event */ static void usb_ltunify_hid_event(HIDState *hs) { USBLtunifyState *s; LHidDevice *hd; uint8_t ifnum; if (hs->kind == HID_KEYBOARD) { ifnum = IFACE_KBD; } else if (hs->kind == HID_MOUSE) { ifnum = IFACE_MSE; } else { return; } s = container_of(hs, USBLtunifyState, hid[ifnum]); hd = find_lhid_device(s, hs); if (hd == NULL || hd->mode == LTUNIFY_MODE_HID) { usb_wakeup(s->intr[ifnum], 0); } else { assert(hd->mode == LTUNIFY_MODE_DJ); usb_wakeup(s->intr[IFACE_HIDPP], 0); } } static void usb_ltunify_handle_reset(USBDevice *dev) { USBLtunifyState *s = (USBLtunifyState *) dev; if (s->enable_kbd) { hid_reset(&s->hid[IFACE_KBD]); } hid_reset(&s->hid[IFACE_MSE]); hidpp_reset(s); } static void usb_ltunify_handle_control_hid(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBLtunifyState *s = (USBLtunifyState *) dev; HIDState *hs = NULL; if (index == IFACE_KBD && !s->enable_kbd) { goto fail; } hs = &s->hid[index]; switch (request) { case HID_GET_REPORT: p->actual_length = usb_ltunify_poll_hid(hs, data, length); break; case HID_SET_REPORT: if (hs->kind == HID_KEYBOARD) { /* for toggling LEDs */ p->actual_length = hid_keyboard_write(hs, data, length); } else { /* not applicable for mice */ goto fail; } break; case HID_GET_IDLE: /* Idle rates for specific Report IDs should be implemented by checking * (uint8_t) value (Report ID) */ data[0] = hs->idle; p->actual_length = 1; break; case HID_SET_IDLE: /* report_id = (uint8_t) value; // 0 is a wildcard for all reports */ hs->idle = (uint8_t) (value >> 8); hid_set_next_idle(hs); if (hs->kind == HID_MOUSE) { /* start accepting pointer events if not already */ hid_pointer_activate(hs); } break; case HID_GET_PROTOCOL: data[0] = hs->protocol; p->actual_length = 1; break; case HID_SET_PROTOCOL: hs->protocol = data[0]; break; default: fail: p->status = USB_RET_STALL; break; } } static void usb_ltunify_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBLtunifyState *s = (USBLtunifyState *) dev; int ret; int desc_len = 0; const uint8_t *desc = NULL; usb_dump_submit(s->usb_dump_state, p); /* handle basic requests such as DeviceRequest | USB_REQ_GET_DESCRIPTOR */ ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { goto data_ready; } switch (request) { case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: // look for class descriptor type Report (0x22), descriptor index is // always 0 for class descriptor type other than Physical descriptor. if (value == 0x2200) { // index: interface number switch (index) { case 0: desc = iface0_hid_report_descriptor; desc_len = sizeof(iface0_hid_report_descriptor); break; case 1: desc = iface1_hid_report_descriptor; desc_len = sizeof(iface1_hid_report_descriptor); break; case 2: desc = iface2_hid_report_descriptor; desc_len = sizeof(iface2_hid_report_descriptor); break; } if (desc_len > 0) { if (desc_len > length) { desc_len = length; } memcpy(data, desc, desc_len); p->actual_length = desc_len; } } goto data_ready; } if (index == IFACE_KBD || index == IFACE_KBD) { /* HID interface for mouse and keyboard */ usb_ltunify_handle_control_hid(dev, p, request, value, index, length, data); } else if (index == IFACE_HIDPP) { /* Logitech Proprietary HID++ interface */ usb_ltunify_handle_control_hidpp(dev, p, request, value, index, length, data); } else { p->status = USB_RET_STALL; } data_ready: usb_dump_complete(s->usb_dump_state, p); } int usb_ltunify_poll_hid(HIDState *hs, uint8_t *buf, size_t bufsz) { int len = 0; assert(hs != NULL); if (hs->kind == HID_MOUSE) { /* start accepting pointer events if not already */ hid_pointer_activate(hs); } if (!hid_has_events(hs)) { return 0; } hid_set_next_idle(hs); assert(hs->kind == HID_MOUSE || hs->kind == HID_KEYBOARD); if (hs->kind == HID_MOUSE) { uint8_t pbuf[4]; /* buttons, x, y, wheel */ uint8_t lbuf[7]; hid_pointer_poll(hs, pbuf, sizeof(pbuf)); /* buttons (16 bits) */ lbuf[0] = pbuf[0]; lbuf[1] = 0; /* X, Y (12 bits each) */ lbuf[2] = pbuf[1]; lbuf[3] = ((int8_t) pbuf[1] & 0xf00) >> 8; /* (ff)fe -> 0f */ lbuf[3] |= (pbuf[2] & 0xf) << 4; /* de -> e0 */ lbuf[4] = ((int8_t) pbuf[2] & 0xff0) >> 4; /* (ff)de -> fd */ /* wheel, consumer (8 bit each) */ lbuf[5] = pbuf[3]; lbuf[6] = 0; len = MIN(sizeof(lbuf), bufsz); memcpy(buf, lbuf, len); } else if (hs->kind == HID_KEYBOARD) { len = hid_keyboard_poll(hs, buf, bufsz); } return len; } static void usb_ltunify_handle_datain_hid(USBDevice *dev, USBPacket *p) { USBLtunifyState *s = (USBLtunifyState *) dev; uint8_t ifnum = p->ep->nr == 1 ? IFACE_KBD : IFACE_MSE; HIDState *hs = &s->hid[ifnum]; uint8_t buf[p->iov.size]; LHidDevice *hd = find_lhid_device(s, hs); int len; if (hd != NULL && hd->mode == LTUNIFY_MODE_DJ) { /* do not speak HID when in HID++ mode */ p->status = USB_RET_NAK; return; } len = usb_ltunify_poll_hid(hs, buf, sizeof(buf)); if (len <= 0) { p->status = USB_RET_NAK; return; } if (hs->kind == HID_MOUSE) { memmove(buf + 1, buf, MIN(len, sizeof(buf) - 1)); buf[0] = 2; /* Report ID for Mouse collection */ len = MIN(len + 1, sizeof(buf)); } usb_dump_complete_data(s->usb_dump_state, p, buf, len); usb_packet_copy(p, buf, len); usb_dump_submit(s->usb_dump_state, p); } /* handle interrupt transfers (this device does not have a bulk/iso endpoint */ static void usb_ltunify_handle_data(USBDevice *dev, USBPacket *p) { switch (p->pid) { case USB_TOKEN_IN: /* keyboard or mouse */ if (p->ep->nr == 1 || p->ep->nr == 2) { usb_ltunify_handle_datain_hid(dev, p); return; } else if (p->ep->nr == 3) { usb_ltunify_handle_datain_hidpp(dev, p); return; } else { abort(); } /* Fall through. */ case USB_TOKEN_OUT: default: p->status = USB_RET_STALL; } } static void usb_ltunify_handle_destroy(USBDevice *dev) { USBLtunifyState *s = (USBLtunifyState *) dev; hid_free(&s->hid[IFACE_MSE]); if (s->enable_kbd) { hid_free(&s->hid[IFACE_KBD]); } if (s->usb_dump_state) { usb_dump_cleanup(s->usb_dump_state); g_free(s->usb_dump_state); s->usb_dump_state = NULL; } } static int usb_ltunify_initfn(USBDevice *dev) { USBLtunifyState *s = DO_UPCAST(USBLtunifyState, dev, dev); // init device descriptors, etc. usb_desc_init(dev); /* retrieve interrupt endpoints for each interface */ s->intr[IFACE_KBD] = usb_ep_get(dev, USB_TOKEN_IN, 1); s->intr[IFACE_MSE] = usb_ep_get(dev, USB_TOKEN_IN, 2); s->intr[IFACE_HIDPP] = usb_ep_get(dev, USB_TOKEN_IN, 3); /* the receiver supports multiple HID devices. Let's load some even if not * all of them are paired. */ if (s->enable_kbd) { hid_init(&s->hid[IFACE_KBD], HID_KEYBOARD, usb_ltunify_hid_event); } hid_init(&s->hid[IFACE_MSE], HID_MOUSE, usb_ltunify_hid_event); hidpp_init(s); if (s->usbdump_filename != NULL) { s->usb_dump_state = usb_dump_init_alloc(s->usbdump_filename); } return 0; } static const VMStateDescription vmstate_usb_ltunify = { .name = "usb-ltunify", .unmigratable = 1, }; static Property usb_ltunify_properties[] = { DEFINE_PROP_BOOL("kbd", USBLtunifyState, enable_kbd, true), DEFINE_PROP_STRING("usbdump", USBLtunifyState, usbdump_filename), DEFINE_PROP_END_OF_LIST(), }; static void usb_ltunify_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); USBDeviceClass *uc = USB_DEVICE_CLASS(klass); uc->product_desc = "QEMU Logitech Unifying Receiver"; uc->usb_desc = &desc_ltunify; uc->init = usb_ltunify_initfn; uc->handle_reset = usb_ltunify_handle_reset; uc->handle_control = usb_ltunify_handle_control; uc->handle_data = usb_ltunify_handle_data; uc->handle_destroy = usb_ltunify_handle_destroy; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); dc->desc = "QEMU Logitech Unifying Receiver"; dc->vmsd = &vmstate_usb_ltunify; dc->props = usb_ltunify_properties; } static const TypeInfo ltunify_info = { .name = "usb-ltunify-receiver", .parent = TYPE_USB_DEVICE, .instance_size = sizeof(USBLtunifyState), .class_init = usb_ltunify_class_init, }; static void usb_ltunify_register_types(void) { type_register_static(<unify_info); usb_legacy_register("usb-ltunify-receiver", "ltunify-receiver", NULL); } type_init(usb_ltunify_register_types)