blob: 9478102ae58d5e06cfa1cb7c6fa7fa001b813d76 [file] [log] [blame]
Brad Bishopc68388fc2019-08-26 01:33:31 -04001From 4655dc18074e0be9d239f51dac32b61435da8549 Mon Sep 17 00:00:00 2001
Brad Bishopc342db32019-05-15 21:57:59 -04002From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 27 Nov 2014 14:04:29 +0000
4Subject: [PATCH] qemu: Add missing wacom HID descriptor
5
6The USB wacom device is missing a HID descriptor which causes it
7to fail to operate with recent kernels (e.g. 3.17).
8
9This patch adds a HID desriptor to the device, based upon one from
10real wcom device.
11
12Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
13
14Upstream-Status: Submitted
152014/11/27
16
17---
18 hw/usb/dev-wacom.c | 94 +++++++++++++++++++++++++++++++++++++++++++++-
19 1 file changed, 93 insertions(+), 1 deletion(-)
20
21diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c
Brad Bishopc68388fc2019-08-26 01:33:31 -040022index 8c43db93..3ff8ca28 100644
Brad Bishopc342db32019-05-15 21:57:59 -040023--- a/hw/usb/dev-wacom.c
24+++ b/hw/usb/dev-wacom.c
Brad Bishopc68388fc2019-08-26 01:33:31 -040025@@ -74,6 +74,89 @@ static const USBDescStrings desc_strings = {
Brad Bishopc342db32019-05-15 21:57:59 -040026 [STR_SERIALNUMBER] = "1",
27 };
28
29+static const uint8_t qemu_tablet_hid_report_descriptor[] = {
30+ 0x05, 0x01, /* Usage Page (Generic Desktop) */
31+ 0x09, 0x02, /* Usage (Mouse) */
32+ 0xa1, 0x01, /* Collection (Application) */
33+ 0x85, 0x01, /* Report ID (1) */
34+ 0x09, 0x01, /* Usage (Pointer) */
35+ 0xa1, 0x00, /* Collection (Physical) */
36+ 0x05, 0x09, /* Usage Page (Button) */
37+ 0x19, 0x01, /* Usage Minimum (1) */
38+ 0x29, 0x05, /* Usage Maximum (5) */
39+ 0x15, 0x00, /* Logical Minimum (0) */
40+ 0x25, 0x01, /* Logical Maximum (1) */
41+ 0x95, 0x05, /* Report Count (5) */
42+ 0x75, 0x01, /* Report Size (1) */
43+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
44+ 0x95, 0x01, /* Report Count (1) */
45+ 0x75, 0x03, /* Report Size (3) */
46+ 0x81, 0x01, /* Input (Constant) */
47+ 0x05, 0x01, /* Usage Page (Generic Desktop) */
48+ 0x09, 0x30, /* Usage (X) */
49+ 0x09, 0x31, /* Usage (Y) */
50+ 0x15, 0x81, /* Logical Minimum (-127) */
51+ 0x25, 0x7f, /* Logical Maximum (127) */
52+ 0x75, 0x08, /* Report Size (8) */
53+ 0x95, 0x02, /* Report Count (2) */
54+ 0x81, 0x06, /* Input (Data, Variable, Relative) */
55+ 0xc0, /* End Collection */
56+ 0xc0, /* End Collection */
57+ 0x05, 0x0d, /* Usage Page (Digitizer) */
58+ 0x09, 0x01, /* Usage (Digitizer) */
59+ 0xa1, 0x01, /* Collection (Application) */
60+ 0x85, 0x02, /* Report ID (2) */
61+ 0xa1, 0x00, /* Collection (Physical) */
62+ 0x06, 0x00, 0xff, /* Usage Page (Vendor 0xff00) */
63+ 0x09, 0x01, /* Usage (Digitizer) */
64+ 0x15, 0x00, /* Logical Minimum (0) */
65+ 0x26, 0xff, 0x00, /* Logical Maximum (255) */
66+ 0x75, 0x08, /* Report Size (8) */
67+ 0x95, 0x08, /* Report Count (8) */
68+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
69+ 0xc0, /* End Collection */
70+ 0x09, 0x01, /* Usage (Digitizer) */
71+ 0x85, 0x02, /* Report ID (2) */
72+ 0x95, 0x01, /* Report Count (1) */
73+ 0xb1, 0x02, /* FEATURE (2) */
74+ 0xc0, /* End Collection */
75+ 0x06, 0x00, 0xff, /* Usage Page (Vendor 0xff00) */
76+ 0x09, 0x01, /* Usage (Digitizer) */
77+ 0xa1, 0x01, /* Collection (Application) */
78+ 0x85, 0x02, /* Report ID (2) */
79+ 0x05, 0x0d, /* Usage Page (Digitizer) */
80+ 0x09, 0x22, /* Usage (Finger) */
81+ 0xa1, 0x00, /* Collection (Physical) */
82+ 0x06, 0x00, 0xff, /* Usage Page (Vendor 0xff00) */
83+ 0x09, 0x01, /* Usage (Digitizer) */
84+ 0x15, 0x00, /* Logical Minimum (0) */
85+ 0x26, 0xff, 0x00, /* Logical Maximum */
86+ 0x75, 0x08, /* Report Size (8) */
87+ 0x95, 0x02, /* Report Count (2) */
88+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
89+ 0x05, 0x01, /* Usage Page (Generic Desktop) */
90+ 0x09, 0x30, /* Usage (X) */
91+ 0x35, 0x00, /* Physical Minimum */
92+ 0x46, 0xe0, 0x2e, /* Physical Maximum */
93+ 0x26, 0xe0, 0x01, /* Logical Maximum */
94+ 0x75, 0x10, /* Report Size (16) */
95+ 0x95, 0x01, /* Report Count (1) */
96+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
97+ 0x09, 0x31, /* Usage (Y) */
98+ 0x46, 0x40, 0x1f, /* Physical Maximum */
99+ 0x26, 0x40, 0x01, /* Logical Maximum */
100+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
101+ 0x06, 0x00, 0xff, /* Usage Page (Vendor 0xff00) */
102+ 0x09, 0x01, /* Usage (Digitizer) */
103+ 0x26, 0xff, 0x00, /* Logical Maximum */
104+ 0x75, 0x08, /* Report Size (8) */
105+ 0x95, 0x0d, /* Report Count (13) */
106+ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
107+ 0xc0, /* End Collection */
108+ 0xc0, /* End Collection */
109+};
110+
111+
112 static const USBDescIface desc_iface_wacom = {
113 .bInterfaceNumber = 0,
114 .bNumEndpoints = 1,
Brad Bishopc68388fc2019-08-26 01:33:31 -0400115@@ -91,7 +174,7 @@ static const USBDescIface desc_iface_wacom = {
Brad Bishopc342db32019-05-15 21:57:59 -0400116 0x00, /* u8 country_code */
117 0x01, /* u8 num_descriptors */
118 0x22, /* u8 type: Report */
119- 0x6e, 0, /* u16 len */
120+ sizeof(qemu_tablet_hid_report_descriptor), 0, /* u16 len */
121 },
122 },
123 },
Brad Bishopc68388fc2019-08-26 01:33:31 -0400124@@ -271,6 +354,15 @@ static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,
Brad Bishopc342db32019-05-15 21:57:59 -0400125 }
126
127 switch (request) {
128+ case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
129+ switch (value >> 8) {
130+ case 0x22:
131+ memcpy(data, qemu_tablet_hid_report_descriptor,
132+ sizeof(qemu_tablet_hid_report_descriptor));
133+ p->actual_length = sizeof(qemu_tablet_hid_report_descriptor);
134+ break;
135+ }
136+ break;
137 case WACOM_SET_REPORT:
138 if (s->mouse_grabbed) {
139 qemu_remove_mouse_event_handler(s->eh_entry);