qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Vesely <jano.vesely@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] usb-hid: Add high speed keyboard configuration
Date: Sun, 16 Feb 2014 00:41:26 -0500	[thread overview]
Message-ID: <1392529286-24938-2-git-send-email-jano.vesely@gmail.com> (raw)
In-Reply-To: <1392529286-24938-1-git-send-email-jano.vesely@gmail.com>

Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
---
Tested on Ubuntu, Fedora, and HelenOS.

 hw/usb/dev-hid.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 59 insertions(+), 8 deletions(-)

diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 954cde1..53e7bd3 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_FULL,
+            .bmAttributes          = 0xa0,
+            .bMaxPower             = 50,
+            .nif = 1,
+            .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,
+            .iConfiguration        = STR_CONFIG_KEYBOARD_HIGH,
             .bmAttributes          = 0xa0,
             .bMaxPower             = 50,
             .nif = 1,
-            .ifs = &desc_iface_keyboard,
+            .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,
 };
-- 
1.8.3.2

  reply	other threads:[~2014-02-16  5:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-16  5:41 [Qemu-devel] [PATCH 1/2] usb-hid: Add high speed mouse configuration Jan Vesely
2014-02-16  5:41 ` Jan Vesely [this message]
2014-02-17 12:10 ` Gerd Hoffmann
2014-02-23  7:37   ` [Qemu-devel] [PATCH v2 " Jan Vesely
2014-02-23  7:37     ` [Qemu-devel] [PATCH v2 2/2] usb-hid: Add high speed keyboard configuration Jan Vesely
2014-03-17 17:53     ` [Qemu-devel] [PATCH v2 1/2] usb-hid: Add high speed mouse configuration Ján Veselý
2014-04-03  5:27       ` Ján Veselý
2014-04-07  8:02         ` Gerd Hoffmann
     [not found]           ` <CA+K+NcQZf-__sqSBTewBooUTUWMDP_m34iDVQX7YsHtUzAwb6g@mail.gmail.com>
     [not found]             ` <1397629640.23535.7.camel@nilsson.home.kraxel.org>
2014-09-11  4:57               ` Jan Vesely
2014-09-11  4:58                 ` [Qemu-devel] [PATCH 1/3] usb-hid: Move descriptor decision to usb-hid initfn Jan Vesely
2014-09-11  4:58                   ` [Qemu-devel] [PATCH v3 2/3] usb-hid: Add high speed mouse configuration Jan Vesely
2014-09-11  4:58                   ` [Qemu-devel] [PATCH 3/3] usb-hid: Add high speed keyboard configuration Jan Vesely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392529286-24938-2-git-send-email-jano.vesely@gmail.com \
    --to=jano.vesely@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).