From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHTe4-00038s-0I for qemu-devel@nongnu.org; Sun, 23 Feb 2014 02:38:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHTdv-0007y4-Is for qemu-devel@nongnu.org; Sun, 23 Feb 2014 02:38:39 -0500 Received: from mail-qa0-x22e.google.com ([2607:f8b0:400d:c00::22e]:33391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHTdv-0007xJ-DO for qemu-devel@nongnu.org; Sun, 23 Feb 2014 02:38:31 -0500 Received: by mail-qa0-f46.google.com with SMTP id k15so5121082qaq.33 for ; Sat, 22 Feb 2014 23:38:31 -0800 (PST) From: Jan Vesely Date: Sun, 23 Feb 2014 02:37:51 -0500 Message-Id: <1393141071-14204-2-git-send-email-jano.vesely@gmail.com> In-Reply-To: <1393141071-14204-1-git-send-email-jano.vesely@gmail.com> References: <1392639007.26953.28.camel@nilsson.home.kraxel.org> <1393141071-14204-1-git-send-email-jano.vesely@gmail.com> Subject: [Qemu-devel] [PATCH v2 2/2] usb-hid: Add high speed keyboard configuration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kraxel@redhat.com v2: add usb_keyboard_properties use macros for bmAttributes Signed-off-by: Jan Vesely --- hw/usb/dev-hid.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 70c2c5f..6ead61c 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -56,7 +56,8 @@ enum { STR_PRODUCT_KEYBOARD, STR_SERIALNUMBER, STR_CONFIG_TABLET, - STR_CONFIG_KEYBOARD, + STR_CONFIG_KEYBOARD_FULL, + STR_CONFIG_KEYBOARD_HIGH, STR_CONFIG_MOUSE_FULL, STR_CONFIG_MOUSE_HIGH, }; @@ -68,7 +69,8 @@ static const USBDescStrings desc_strings = { [STR_PRODUCT_KEYBOARD] = "QEMU USB Keyboard", [STR_SERIALNUMBER] = "42", /* == remote wakeup works */ [STR_CONFIG_TABLET] = "HID Tablet", - [STR_CONFIG_KEYBOARD] = "HID Keyboard", + [STR_CONFIG_KEYBOARD_FULL] = "HID Keyboard Full speed configuration (usb 1.1)", + [STR_CONFIG_KEYBOARD_HIGH] = "HID Keyboard High speed configuration (usb 2.0)", [STR_CONFIG_MOUSE_FULL]= "HID Mouse Full speed configuration (usb 1.1)", [STR_CONFIG_MOUSE_HIGH]= "HID Mouse High speed configuration (usb 2.0)", }; @@ -195,7 +197,7 @@ static const USBDescIface desc_iface_tablet2 = { }, }; -static const USBDescIface desc_iface_keyboard = { +static const USBDescIface desc_iface_keyboard_full = { .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, @@ -226,6 +228,37 @@ static const USBDescIface desc_iface_keyboard = { }, }; +static const USBDescIface desc_iface_keyboard_high = { + .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 */ + USB_DT_HID, /* u8 bDescriptorType */ + 0x11, 0x01, /* u16 HID_class */ + 0x00, /* u8 country_code */ + 0x01, /* u8 num_descriptors */ + USB_DT_REPORT, /* u8 type: Report */ + 0x3f, 0, /* u16 len */ + }, + }, + }, + .eps = (USBDescEndpoint[]) { + { + .bEndpointAddress = USB_DIR_IN | 0x01, + .bmAttributes = USB_ENDPOINT_XFER_INT, + .wMaxPacketSize = 8, + .bInterval = 0x06, + }, + }, +}; + static const USBDescDevice desc_device_mouse_full = { .bcdUSB = 0x0200, .bMaxPacketSize0 = 8, @@ -294,19 +327,36 @@ static const USBDescDevice desc_device_tablet2 = { }, }; -static const USBDescDevice desc_device_keyboard = { - .bcdUSB = 0x0100, +static const USBDescDevice desc_device_keyboard_full = { + .bcdUSB = 0x0200, .bMaxPacketSize0 = 8, .bNumConfigurations = 1, .confs = (USBDescConfig[]) { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .iConfiguration = STR_CONFIG_KEYBOARD, + .iConfiguration = STR_CONFIG_KEYBOARD_FULL, .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, .bMaxPower = 50, .nif = 1, - .ifs = &desc_iface_keyboard, + .ifs = &desc_iface_keyboard_full, + }, + }, +}; + +static const USBDescDevice desc_device_keyboard_high = { + .bcdUSB = 0x0200, + .bMaxPacketSize0 = 8, + .bNumConfigurations = 1, + .confs = (USBDescConfig[]) { + { + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = STR_CONFIG_KEYBOARD_HIGH, + .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP, + .bMaxPower = 50, + .nif = 1, + .ifs = &desc_iface_keyboard_high, }, }, }; @@ -368,7 +418,8 @@ static const USBDesc desc_keyboard = { .iProduct = STR_PRODUCT_KEYBOARD, .iSerialNumber = STR_SERIALNUMBER, }, - .full = &desc_device_keyboard, + .full = &desc_device_keyboard_full, + .high = &desc_device_keyboard_high, .str = desc_strings, .msos = &desc_msos_suspend, }; @@ -753,6 +804,11 @@ static const TypeInfo usb_mouse_info = { .class_init = usb_mouse_class_initfn, }; +static Property usb_keyboard_properties[] = { + DEFINE_PROP_UINT32("usb_version", USBHIDState, usb_version, 2), + DEFINE_PROP_END_OF_LIST(), +}; + static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -763,6 +819,7 @@ static void usb_keyboard_class_initfn(ObjectClass *klass, void *data) uc->product_desc = "QEMU USB Keyboard"; uc->usb_desc = &desc_keyboard; dc->vmsd = &vmstate_usb_kbd; + dc->props = usb_keyboard_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } -- 1.9.0