All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] hw/usb/wacom: Add missing HID descriptor
Date: Thu, 27 Nov 2014 14:03:25 +0000	[thread overview]
Message-ID: <1417097005.15614.8.camel@linuxfoundation.org> (raw)

The USB wacom device is missing a HID descriptor which causes it
to fail to operate with recent kernels (e.g. 3.17).

This patch adds a HID desriptor to the device, based upon one from 
real wacom device and allows the device to work properly again.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

Index: qemu-2.1.0/hw/usb/dev-wacom.c
===================================================================
--- qemu-2.1.0.orig/hw/usb/dev-wacom.c	2014-08-01 15:12:17.000000000 +0100
+++ qemu-2.1.0/hw/usb/dev-wacom.c	2014-10-12 12:13:30.540306042 +0100
@@ -68,6 +68,89 @@
     [STR_SERIALNUMBER]     = "1",
 };
 
+static const uint8_t qemu_tablet_hid_report_descriptor[] = {
+    0x05, 0x01,		/* Usage Page (Generic Desktop) */
+    0x09, 0x02,		/* Usage (Mouse) */
+    0xa1, 0x01,		/* Collection (Application) */
+    0x85, 0x01,		/*   Report ID (1) */ 
+    0x09, 0x01,		/*   Usage (Pointer) */
+    0xa1, 0x00,		/*   Collection (Physical) */
+    0x05, 0x09,		/*     Usage Page (Button) */
+    0x19, 0x01,		/*     Usage Minimum (1) */
+    0x29, 0x05,		/*     Usage Maximum (5) */
+    0x15, 0x00,		/*     Logical Minimum (0) */
+    0x25, 0x01,		/*     Logical Maximum (1) */
+    0x95, 0x05,		/*     Report Count (5) */
+    0x75, 0x01,		/*     Report Size (1) */
+    0x81, 0x02,		/*     Input (Data, Variable, Absolute) */
+    0x95, 0x01,		/*     Report Count (1) */
+    0x75, 0x03,		/*     Report Size (3) */
+    0x81, 0x01,		/*     Input (Constant) */
+    0x05, 0x01,		/*     Usage Page (Generic Desktop) */
+    0x09, 0x30,		/*     Usage (X) */
+    0x09, 0x31,		/*     Usage (Y) */
+    0x15, 0x81,		/*     Logical Minimum (-127) */
+    0x25, 0x7f,		/*     Logical Maximum (127) */
+    0x75, 0x08,		/*     Report Size (8) */
+    0x95, 0x02,		/*     Report Count (2) */
+    0x81, 0x06,		/*     Input (Data, Variable, Relative) */
+    0xc0,		/*   End Collection */
+    0xc0,		/* End Collection */
+    0x05, 0x0d,		/* Usage Page (Digitizer) */
+    0x09, 0x01,		/* Usage (Digitizer) */
+    0xa1, 0x01,		/* Collection (Application) */
+    0x85, 0x02,		/*   Report ID (2) */ 
+    0xa1, 0x00,		/*   Collection (Physical) */
+    0x06, 0x00, 0xff,   /*   Usage Page (Vendor 0xff00) */
+    0x09, 0x01, 	/*   Usage (Digitizer) */
+    0x15, 0x00, 	/*     Logical Minimum (0) */
+    0x26, 0xff, 0x00,	/*     Logical Maximum (255) */
+    0x75, 0x08,		/*     Report Size (8) */
+    0x95, 0x08,		/*     Report Count (8) */
+    0x81, 0x02,		/*     Input (Data, Variable, Absolute) */
+    0xc0, 		/*   End Collection */
+    0x09, 0x01,		/*   Usage (Digitizer) */
+    0x85, 0x02, 	/*   Report ID (2) */ 
+    0x95, 0x01,		/*   Report Count (1) */
+    0xb1, 0x02,		/*   FEATURE (2) */
+    0xc0,		/* End Collection */
+    0x06, 0x00, 0xff,	/* Usage Page (Vendor 0xff00) */
+    0x09, 0x01,		/* Usage (Digitizer) */
+    0xa1, 0x01,		/* Collection (Application) */
+    0x85, 0x02,   	/*   Report ID (2) */ 
+    0x05, 0x0d,		/*   Usage Page (Digitizer)  */
+    0x09, 0x22, 	/*   Usage (Finger) */
+    0xa1, 0x00,  	/*   Collection (Physical) */
+    0x06, 0x00, 0xff,	/*   Usage Page (Vendor 0xff00) */
+    0x09, 0x01,		/*     Usage (Digitizer) */
+    0x15, 0x00, 	/*     Logical Minimum (0) */
+    0x26, 0xff, 0x00,  	/*     Logical Maximum */
+    0x75, 0x08,		/*     Report Size (8) */
+    0x95, 0x02,		/*     Report Count (2) */
+    0x81, 0x02, 	/*     Input (Data, Variable, Absolute) */
+    0x05, 0x01,		/*     Usage Page (Generic Desktop) */
+    0x09, 0x30,		/*     Usage (X) */
+    0x35, 0x00, 	/*     Physical Minimum */
+    0x46, 0xe0, 0x2e,	/*     Physical Maximum */
+    0x26, 0xe0, 0x01,   /*     Logical Maximum */
+    0x75, 0x10,		/*     Report Size (16) */
+    0x95, 0x01,		/*     Report Count (1) */
+    0x81, 0x02,		/*     Input (Data, Variable, Absolute) */
+    0x09, 0x31,		/*     Usage (Y) */
+    0x46, 0x40, 0x1f, 	/*     Physical Maximum */
+    0x26, 0x40, 0x01, 	/*     Logical Maximum */
+    0x81, 0x02, 	/*     Input (Data, Variable, Absolute) */
+    0x06, 0x00, 0xff,	/*     Usage Page (Vendor 0xff00) */
+    0x09, 0x01, 	/*     Usage (Digitizer) */
+    0x26, 0xff, 0x00,  	/*     Logical Maximum */
+    0x75, 0x08,		/*     Report Size (8) */
+    0x95, 0x0d,		/*     Report Count (13) */
+    0x81, 0x02,		/*     Input (Data, Variable, Absolute) */
+    0xc0,		/*   End Collection */ 
+    0xc0,		/* End Collection */
+};
+
+
 static const USBDescIface desc_iface_wacom = {
     .bInterfaceNumber              = 0,
     .bNumEndpoints                 = 1,
@@ -85,7 +168,7 @@
                 0x00,          /*  u8  country_code */
                 0x01,          /*  u8  num_descriptors */
                 0x22,          /*  u8  type: Report */
-                0x6e, 0,       /*  u16 len */
+                sizeof(qemu_tablet_hid_report_descriptor), 0, /*  u16 len */
             },
         },
     },
@@ -265,6 +350,15 @@
     }
 
     switch (request) {
+    case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
+        switch (value >> 8) {
+        case 0x22:
+                memcpy(data, qemu_tablet_hid_report_descriptor,
+                       sizeof(qemu_tablet_hid_report_descriptor));
+                p->actual_length = sizeof(qemu_tablet_hid_report_descriptor);
+            break;
+        }
+        break;
     case WACOM_SET_REPORT:
         if (s->mouse_grabbed) {
             qemu_remove_mouse_event_handler(s->eh_entry);

                 reply	other threads:[~2014-11-27 14:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1417097005.15614.8.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.