From: Jan Vesely <jano.vesely@gmail.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v4 2/3] usb-hid: Add high speed mouse configuration
Date: Thu, 25 Sep 2014 17:38:13 -0400 [thread overview]
Message-ID: <1411681094-8474-2-git-send-email-jano.vesely@gmail.com> (raw)
In-Reply-To: <1411681094-8474-1-git-send-email-jano.vesely@gmail.com>
v2: add usb_mouse_properties
use macros for bmAttributes
v3: rebase
v4: rebase
Signed-off-by: Jan Vesely <jano.vesely@gmail.com>
---
hw/usb/dev-hid.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 70 insertions(+), 1 deletion(-)
diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c
index 90746ed..a946528 100644
--- a/hw/usb/dev-hid.c
+++ b/hw/usb/dev-hid.c
@@ -104,6 +104,37 @@ static const USBDescIface desc_iface_mouse = {
},
};
+static const USBDescIface desc_iface_mouse2 = {
+ .bInterfaceNumber = 0,
+ .bNumEndpoints = 1,
+ .bInterfaceClass = USB_CLASS_HID,
+ .bInterfaceSubClass = 0x01, /* boot */
+ .bInterfaceProtocol = 0x02,
+ .ndesc = 1,
+ .descs = (USBDescOther[]) {
+ {
+ /* HID descriptor */
+ .data = (uint8_t[]) {
+ 0x09, /* u8 bLength */
+ USB_DT_HID, /* u8 bDescriptorType */
+ 0x01, 0x00, /* u16 HID_class */
+ 0x00, /* u8 country_code */
+ 0x01, /* u8 num_descriptors */
+ USB_DT_REPORT, /* u8 type: Report */
+ 52, 0, /* u16 len */
+ },
+ },
+ },
+ .eps = (USBDescEndpoint[]) {
+ {
+ .bEndpointAddress = USB_DIR_IN | 0x01,
+ .bmAttributes = USB_ENDPOINT_XFER_INT,
+ .wMaxPacketSize = 4,
+ .bInterval = 7, /* 2 ^ (8-1) * 125 usecs = 8 ms */
+ },
+ },
+};
+
static const USBDescIface desc_iface_tablet = {
.bInterfaceNumber = 0,
.bNumEndpoints = 1,
@@ -212,6 +243,23 @@ static const USBDescDevice desc_device_mouse = {
},
};
+static const USBDescDevice desc_device_mouse2 = {
+ .bcdUSB = 0x0200,
+ .bMaxPacketSize0 = 64,
+ .bNumConfigurations = 1,
+ .confs = (USBDescConfig[]) {
+ {
+ .bNumInterfaces = 1,
+ .bConfigurationValue = 1,
+ .iConfiguration = STR_CONFIG_MOUSE,
+ .bmAttributes = USB_CFG_ATT_ONE | USB_CFG_ATT_WAKEUP,
+ .bMaxPower = 50,
+ .nif = 1,
+ .ifs = &desc_iface_mouse2,
+ },
+ },
+};
+
static const USBDescDevice desc_device_tablet = {
.bcdUSB = 0x0100,
.bMaxPacketSize0 = 8,
@@ -281,6 +329,21 @@ static const USBDesc desc_mouse = {
.msos = &desc_msos_suspend,
};
+static const USBDesc desc_mouse2 = {
+ .id = {
+ .idVendor = 0x0627,
+ .idProduct = 0x0001,
+ .bcdDevice = 0,
+ .iManufacturer = STR_MANUFACTURER,
+ .iProduct = STR_PRODUCT_MOUSE,
+ .iSerialNumber = STR_SERIALNUMBER,
+ },
+ .full = &desc_device_mouse,
+ .high = &desc_device_mouse2,
+ .str = desc_strings,
+ .msos = &desc_msos_suspend,
+};
+
static const USBDesc desc_tablet = {
.id = {
.idVendor = 0x0627,
@@ -603,7 +666,7 @@ static void usb_tablet_realize(USBDevice *dev, Error **errp)
static void usb_mouse_realize(USBDevice *dev, Error **errp)
{
- usb_hid_initfn(dev, HID_MOUSE, &desc_mouse, &desc_mouse, errp);
+ usb_hid_initfn(dev, HID_MOUSE, &desc_mouse, &desc_mouse2, errp);
}
static void usb_keyboard_realize(USBDevice *dev, Error **errp)
@@ -682,6 +745,11 @@ static const TypeInfo usb_tablet_info = {
.class_init = usb_tablet_class_initfn,
};
+static Property usb_mouse_properties[] = {
+ DEFINE_PROP_UINT32("usb_version", USBHIDState, usb_version, 2),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void usb_mouse_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -691,6 +759,7 @@ static void usb_mouse_class_initfn(ObjectClass *klass, void *data)
uc->realize = usb_mouse_realize;
uc->product_desc = "QEMU USB Mouse";
dc->vmsd = &vmstate_usb_ptr;
+ dc->props = usb_mouse_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
--
1.9.3
next prev parent reply other threads:[~2014-09-25 21:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 21:38 [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn Jan Vesely
2014-09-25 21:38 ` Jan Vesely [this message]
2014-09-26 7:06 ` [Qemu-devel] [PATCH v4 2/3] usb-hid: Add high speed mouse configuration Gerd Hoffmann
2014-09-26 14:43 ` Jan Vesely
2014-09-29 7:32 ` Gerd Hoffmann
2014-09-25 21:38 ` [Qemu-devel] [PATCH v2 3/3] usb-hid: Add high speed keyboard configuration Jan Vesely
2014-09-26 6:21 ` [Qemu-devel] [PATCH v2 1/3] usb-hid: Move descriptor decision to usb-hid initfn Gonglei (Arei)
2014-09-26 6:53 ` Gerd Hoffmann
2014-09-26 7:11 ` Gonglei (Arei)
-- strict thread matches above, loose matches on Subject: below --
2014-09-30 2:21 [Qemu-devel] [PATCH v3 " Jan Vesely
2014-09-30 2:21 ` [Qemu-devel] [PATCH v4 2/3] usb-hid: Add high speed mouse 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=1411681094-8474-2-git-send-email-jano.vesely@gmail.com \
--to=jano.vesely@gmail.com \
--cc=kraxel@redhat.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).