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