Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2 | /* |
Dmitry Torokhov | 4104d13 | 2007-05-07 16:16:29 -0400 | [diff] [blame] | 3 | * drivers/input/tablet/wacom_wac.c |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 4 | * |
Ping Cheng | ee54500 | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 5 | * USB Wacom tablet support - Wacom specific code |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 9 | */ |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 10 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 11 | #include "wacom_wac.h" |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 12 | #include "wacom.h" |
Henrik Rydberg | 47c78e8 | 2010-11-27 09:16:48 +0100 | [diff] [blame] | 13 | #include <linux/input/mt.h> |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 14 | |
Ping Cheng | e35fb8c | 2011-03-26 21:16:05 -0700 | [diff] [blame] | 15 | /* resolution for penabled devices */ |
| 16 | #define WACOM_PL_RES 20 |
| 17 | #define WACOM_PENPRTN_RES 40 |
| 18 | #define WACOM_VOLITO_RES 50 |
| 19 | #define WACOM_GRAPHIRE_RES 80 |
| 20 | #define WACOM_INTUOS_RES 100 |
| 21 | #define WACOM_INTUOS3_RES 200 |
| 22 | |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 23 | /* Newer Cintiq and DTU have an offset between tablet and screen areas */ |
| 24 | #define WACOM_DTU_OFFSET 200 |
| 25 | #define WACOM_CINTIQ_OFFSET 400 |
| 26 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 27 | /* |
| 28 | * Scale factor relating reported contact size to logical contact area. |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 29 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo |
| 30 | */ |
| 31 | #define WACOM_CONTACT_AREA_SCALE 2607 |
| 32 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 33 | static bool touch_arbitration = 1; |
| 34 | module_param(touch_arbitration, bool, 0644); |
| 35 | MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)"); |
| 36 | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 37 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 38 | int button_count, int mask); |
| 39 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 40 | static int wacom_numbered_button_to_key(int n); |
| 41 | |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 42 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 43 | int group); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 44 | /* |
| 45 | * Percent of battery capacity for Graphire. |
| 46 | * 8th value means AC online and show 100% capacity. |
| 47 | */ |
| 48 | static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; |
| 49 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 50 | /* |
| 51 | * Percent of battery capacity for Intuos4 WL, AC has a separate bit. |
| 52 | */ |
| 53 | static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; |
| 54 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 55 | static void __wacom_notify_battery(struct wacom_battery *battery, |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 56 | int bat_status, int bat_capacity, |
| 57 | bool bat_charging, bool bat_connected, |
| 58 | bool ps_connected) |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 59 | { |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 60 | bool changed = battery->bat_status != bat_status || |
| 61 | battery->battery_capacity != bat_capacity || |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 62 | battery->bat_charging != bat_charging || |
| 63 | battery->bat_connected != bat_connected || |
| 64 | battery->ps_connected != ps_connected; |
| 65 | |
| 66 | if (changed) { |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 67 | battery->bat_status = bat_status; |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 68 | battery->battery_capacity = bat_capacity; |
| 69 | battery->bat_charging = bat_charging; |
| 70 | battery->bat_connected = bat_connected; |
| 71 | battery->ps_connected = ps_connected; |
| 72 | |
| 73 | if (battery->battery) |
| 74 | power_supply_changed(battery->battery); |
| 75 | } |
| 76 | } |
| 77 | |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 78 | static void wacom_notify_battery(struct wacom_wac *wacom_wac, |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 79 | int bat_status, int bat_capacity, bool bat_charging, |
| 80 | bool bat_connected, bool ps_connected) |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 81 | { |
| 82 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 83 | |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 84 | __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity, |
| 85 | bat_charging, bat_connected, ps_connected); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 88 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 89 | { |
| 90 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 91 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 92 | |
| 93 | switch (data[0]) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 94 | case 1: |
| 95 | if (data[5] & 0x80) { |
| 96 | wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 97 | wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 98 | input_report_key(input, wacom->tool[0], 1); |
| 99 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 100 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
| 101 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 102 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
| 103 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); |
| 104 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 105 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 106 | input_report_key(input, wacom->tool[0], 0); |
| 107 | input_report_abs(input, ABS_MISC, 0); /* report tool id */ |
| 108 | input_report_abs(input, ABS_PRESSURE, -1); |
| 109 | input_report_key(input, BTN_TOUCH, 0); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 110 | } |
| 111 | break; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 112 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 113 | case 2: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 114 | input_report_key(input, BTN_TOOL_PEN, 1); |
| 115 | input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 116 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
| 117 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 118 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
| 119 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); |
| 120 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 121 | break; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 122 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 123 | default: |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 124 | dev_dbg(input->dev.parent, |
| 125 | "%s: received unknown report #%d\n", __func__, data[0]); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 126 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 127 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 128 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 129 | return 1; |
| 130 | } |
| 131 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 132 | static int wacom_pl_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 133 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 134 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 135 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 136 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 137 | int prox, pressure; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 138 | |
Ping Cheng | cad7470 | 2009-12-15 00:35:25 -0800 | [diff] [blame] | 139 | if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 140 | dev_dbg(input->dev.parent, |
| 141 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | prox = data[1] & 0x40; |
| 146 | |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 147 | if (!wacom->id[0]) { |
| 148 | if ((data[0] & 0x10) || (data[4] & 0x20)) { |
| 149 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 150 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 151 | } |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 152 | else { |
| 153 | wacom->tool[0] = BTN_TOOL_PEN; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 154 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 155 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 158 | /* If the eraser is in prox, STYLUS2 is always set. If we |
| 159 | * mis-detected the type and notice that STYLUS2 isn't set |
| 160 | * then force the eraser out of prox and let the pen in. |
| 161 | */ |
| 162 | if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { |
| 163 | input_report_key(input, BTN_TOOL_RUBBER, 0); |
| 164 | input_report_abs(input, ABS_MISC, 0); |
| 165 | input_sync(input); |
| 166 | wacom->tool[0] = BTN_TOOL_PEN; |
| 167 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 168 | } |
| 169 | |
Jason Gerecke | 282e463 | 2017-01-26 09:06:22 -0800 | [diff] [blame] | 170 | if (prox) { |
| 171 | pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); |
| 172 | if (features->pressure_max > 255) |
| 173 | pressure = (pressure << 1) | ((data[4] >> 6) & 1); |
| 174 | pressure += (features->pressure_max + 1) / 2; |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 175 | |
Jason Gerecke | 282e463 | 2017-01-26 09:06:22 -0800 | [diff] [blame] | 176 | input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); |
| 177 | input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); |
| 178 | input_report_abs(input, ABS_PRESSURE, pressure); |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 179 | |
Jason Gerecke | 282e463 | 2017-01-26 09:06:22 -0800 | [diff] [blame] | 180 | input_report_key(input, BTN_TOUCH, data[4] & 0x08); |
| 181 | input_report_key(input, BTN_STYLUS, data[4] & 0x10); |
| 182 | /* Only allow the stylus2 button to be reported for the pen tool. */ |
| 183 | input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20)); |
| 184 | } |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 185 | |
| 186 | if (!prox) |
| 187 | wacom->id[0] = 0; |
| 188 | input_report_key(input, wacom->tool[0], prox); |
| 189 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 190 | return 1; |
| 191 | } |
| 192 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 193 | static int wacom_ptu_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 194 | { |
| 195 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 196 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 197 | |
Ping Cheng | cad7470 | 2009-12-15 00:35:25 -0800 | [diff] [blame] | 198 | if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 199 | dev_dbg(input->dev.parent, |
| 200 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 201 | return 0; |
| 202 | } |
| 203 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 204 | if (data[1] & 0x04) { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 205 | input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20); |
| 206 | input_report_key(input, BTN_TOUCH, data[1] & 0x08); |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 207 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 208 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 209 | input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20); |
| 210 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 211 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 212 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 213 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 214 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 215 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
| 216 | input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 217 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 218 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 219 | return 1; |
| 220 | } |
| 221 | |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 222 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
| 223 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 224 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 225 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 226 | int prox = data[1] & 0x20; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 227 | |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 228 | dev_dbg(input->dev.parent, |
| 229 | "%s: received report #%d", __func__, data[0]); |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 230 | |
| 231 | if (prox) { |
| 232 | /* Going into proximity select tool */ |
| 233 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 234 | if (wacom->tool[0] == BTN_TOOL_PEN) |
| 235 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 236 | else |
| 237 | wacom->id[0] = ERASER_DEVICE_ID; |
| 238 | } |
| 239 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 240 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
| 241 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 242 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 243 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 244 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
| 245 | if (!prox) /* out-prox */ |
| 246 | wacom->id[0] = 0; |
| 247 | input_report_key(input, wacom->tool[0], prox); |
| 248 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
| 249 | return 1; |
| 250 | } |
| 251 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 252 | static int wacom_dtus_irq(struct wacom_wac *wacom) |
| 253 | { |
Jason Gerecke | 073b50b | 2019-08-16 11:54:26 -0700 | [diff] [blame] | 254 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 255 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 256 | unsigned short prox, pressure = 0; |
| 257 | |
| 258 | if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { |
| 259 | dev_dbg(input->dev.parent, |
| 260 | "%s: received unknown report #%d", __func__, data[0]); |
| 261 | return 0; |
| 262 | } else if (data[0] == WACOM_REPORT_DTUSPAD) { |
Benjamin Tissoires | 422b031 | 2014-07-24 12:50:39 -0700 | [diff] [blame] | 263 | input = wacom->pad_input; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 264 | input_report_key(input, BTN_0, (data[1] & 0x01)); |
| 265 | input_report_key(input, BTN_1, (data[1] & 0x02)); |
| 266 | input_report_key(input, BTN_2, (data[1] & 0x04)); |
| 267 | input_report_key(input, BTN_3, (data[1] & 0x08)); |
| 268 | input_report_abs(input, ABS_MISC, |
| 269 | data[1] & 0x0f ? PAD_DEVICE_ID : 0); |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 270 | return 1; |
| 271 | } else { |
| 272 | prox = data[1] & 0x80; |
| 273 | if (prox) { |
| 274 | switch ((data[1] >> 3) & 3) { |
| 275 | case 1: /* Rubber */ |
| 276 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 277 | wacom->id[0] = ERASER_DEVICE_ID; |
| 278 | break; |
| 279 | |
| 280 | case 2: /* Pen */ |
| 281 | wacom->tool[0] = BTN_TOOL_PEN; |
| 282 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 283 | break; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | input_report_key(input, BTN_STYLUS, data[1] & 0x20); |
| 288 | input_report_key(input, BTN_STYLUS2, data[1] & 0x40); |
| 289 | input_report_abs(input, ABS_X, get_unaligned_be16(&data[3])); |
| 290 | input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5])); |
| 291 | pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff); |
| 292 | input_report_abs(input, ABS_PRESSURE, pressure); |
| 293 | input_report_key(input, BTN_TOUCH, pressure > 10); |
| 294 | |
| 295 | if (!prox) /* out-prox */ |
| 296 | wacom->id[0] = 0; |
| 297 | input_report_key(input, wacom->tool[0], prox); |
| 298 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 299 | return 1; |
| 300 | } |
| 301 | } |
| 302 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 303 | static int wacom_graphire_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 304 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 305 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 306 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 307 | struct input_dev *input = wacom->pen_input; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 308 | struct input_dev *pad_input = wacom->pad_input; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 309 | int battery_capacity, ps_connected; |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 310 | int prox; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 311 | int rw = 0; |
| 312 | int retval = 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 313 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 314 | if (features->type == GRAPHIRE_BT) { |
| 315 | if (data[0] != WACOM_REPORT_PENABLED_BT) { |
| 316 | dev_dbg(input->dev.parent, |
| 317 | "%s: received unknown report #%d\n", __func__, |
| 318 | data[0]); |
| 319 | goto exit; |
| 320 | } |
| 321 | } else if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 322 | dev_dbg(input->dev.parent, |
| 323 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 324 | goto exit; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 327 | prox = data[1] & 0x80; |
| 328 | if (prox || wacom->id[0]) { |
| 329 | if (prox) { |
| 330 | switch ((data[1] >> 5) & 3) { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 331 | |
| 332 | case 0: /* Pen */ |
| 333 | wacom->tool[0] = BTN_TOOL_PEN; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 334 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 335 | break; |
| 336 | |
| 337 | case 1: /* Rubber */ |
| 338 | wacom->tool[0] = BTN_TOOL_RUBBER; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 339 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 340 | break; |
| 341 | |
| 342 | case 2: /* Mouse with wheel */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 343 | input_report_key(input, BTN_MIDDLE, data[1] & 0x04); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 344 | fallthrough; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 345 | |
| 346 | case 3: /* Mouse without wheel */ |
| 347 | wacom->tool[0] = BTN_TOOL_MOUSE; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 348 | wacom->id[0] = CURSOR_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 349 | break; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 350 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 351 | } |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 352 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 353 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 354 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 355 | if (features->type == GRAPHIRE_BT) |
| 356 | input_report_abs(input, ABS_PRESSURE, data[6] | |
| 357 | (((__u16) (data[1] & 0x08)) << 5)); |
| 358 | else |
| 359 | input_report_abs(input, ABS_PRESSURE, data[6] | |
| 360 | ((data[7] & 0x03) << 8)); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 361 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
| 362 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 363 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); |
Dmitry Torokhov | afb567e | 2010-04-13 23:08:58 -0700 | [diff] [blame] | 364 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 365 | input_report_key(input, BTN_LEFT, data[1] & 0x01); |
| 366 | input_report_key(input, BTN_RIGHT, data[1] & 0x02); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 367 | if (features->type == WACOM_G4 || |
| 368 | features->type == WACOM_MO) { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 369 | input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); |
Mike Auty | d9f66c1 | 2010-08-28 20:35:17 -0700 | [diff] [blame] | 370 | rw = (data[7] & 0x04) - (data[7] & 0x03); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 371 | } else if (features->type == GRAPHIRE_BT) { |
| 372 | /* Compute distance between mouse and tablet */ |
| 373 | rw = 44 - (data[6] >> 2); |
| 374 | rw = clamp_val(rw, 0, 31); |
| 375 | input_report_abs(input, ABS_DISTANCE, rw); |
| 376 | if (((data[1] >> 5) & 3) == 2) { |
| 377 | /* Mouse with wheel */ |
| 378 | input_report_key(input, BTN_MIDDLE, |
| 379 | data[1] & 0x04); |
| 380 | rw = (data[6] & 0x01) ? -1 : |
| 381 | (data[6] & 0x02) ? 1 : 0; |
| 382 | } else { |
| 383 | rw = 0; |
| 384 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 385 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 386 | input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); |
Mike Auty | d9f66c1 | 2010-08-28 20:35:17 -0700 | [diff] [blame] | 387 | rw = -(signed char)data[6]; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 388 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 389 | input_report_rel(input, REL_WHEEL, rw); |
Dmitry Torokhov | afb567e | 2010-04-13 23:08:58 -0700 | [diff] [blame] | 390 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 391 | |
| 392 | if (!prox) |
| 393 | wacom->id[0] = 0; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 394 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
| 395 | input_report_key(input, wacom->tool[0], prox); |
| 396 | input_sync(input); /* sync last event */ |
Ping Cheng | 80d4e8e | 2007-02-23 12:22:48 -0800 | [diff] [blame] | 397 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 398 | |
| 399 | /* send pad data */ |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 400 | switch (features->type) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 401 | case WACOM_G4: |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 402 | prox = data[7] & 0xf8; |
| 403 | if (prox || wacom->id[1]) { |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 404 | wacom->id[1] = PAD_DEVICE_ID; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 405 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x40)); |
| 406 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80)); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 407 | rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 408 | input_report_rel(pad_input, REL_WHEEL, rw); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 409 | if (!prox) |
| 410 | wacom->id[1] = 0; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 411 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
Ping Cheng | ab687b1 | 2010-04-05 23:07:41 -0700 | [diff] [blame] | 412 | retval = 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 413 | } |
Ping Cheng | 7ecfbfd | 2007-06-14 23:32:48 -0400 | [diff] [blame] | 414 | break; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 415 | |
| 416 | case WACOM_MO: |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 417 | prox = (data[7] & 0xf8) || data[8]; |
| 418 | if (prox || wacom->id[1]) { |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 419 | wacom->id[1] = PAD_DEVICE_ID; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 420 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x08)); |
| 421 | input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20)); |
| 422 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10)); |
| 423 | input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40)); |
| 424 | input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f)); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 425 | if (!prox) |
| 426 | wacom->id[1] = 0; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 427 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
Ping Cheng | 8446001 | 2011-07-06 18:05:43 -0700 | [diff] [blame] | 428 | retval = 1; |
Ping Cheng | 7ecfbfd | 2007-06-14 23:32:48 -0400 | [diff] [blame] | 429 | } |
| 430 | break; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 431 | case GRAPHIRE_BT: |
| 432 | prox = data[7] & 0x03; |
| 433 | if (prox || wacom->id[1]) { |
| 434 | wacom->id[1] = PAD_DEVICE_ID; |
| 435 | input_report_key(pad_input, BTN_0, (data[7] & 0x02)); |
| 436 | input_report_key(pad_input, BTN_1, (data[7] & 0x01)); |
| 437 | if (!prox) |
| 438 | wacom->id[1] = 0; |
| 439 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
| 440 | retval = 1; |
| 441 | } |
| 442 | break; |
| 443 | } |
| 444 | |
| 445 | /* Store current battery capacity and power supply state */ |
| 446 | if (features->type == GRAPHIRE_BT) { |
| 447 | rw = (data[7] >> 2 & 0x07); |
| 448 | battery_capacity = batcap_gr[rw]; |
| 449 | ps_connected = rw == 7; |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 450 | wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 451 | battery_capacity, ps_connected, 1, |
| 452 | ps_connected); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 453 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 454 | exit: |
| 455 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 458 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) |
| 459 | { |
| 460 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 0bbfe28 | 2016-01-06 13:25:53 -0800 | [diff] [blame] | 461 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 462 | struct hid_report *r; |
| 463 | struct hid_report_enum *re; |
| 464 | |
| 465 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); |
Jason Gerecke | 0bbfe28 | 2016-01-06 13:25:53 -0800 | [diff] [blame] | 466 | if (features->type == INTUOSHT2) |
| 467 | r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; |
| 468 | else |
| 469 | r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 470 | if (r) { |
| 471 | hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); |
| 472 | } |
| 473 | } |
| 474 | |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 475 | static int wacom_intuos_pad(struct wacom_wac *wacom) |
| 476 | { |
| 477 | struct wacom_features *features = &wacom->features; |
| 478 | unsigned char *data = wacom->data; |
| 479 | struct input_dev *input = wacom->pad_input; |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 480 | int i; |
| 481 | int buttons = 0, nbuttons = features->numbered_buttons; |
| 482 | int keys = 0, nkeys = 0; |
| 483 | int ring1 = 0, ring2 = 0; |
| 484 | int strip1 = 0, strip2 = 0; |
| 485 | bool prox = false; |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 486 | bool wrench = false, keyboard = false, mute_touch = false, menu = false, |
| 487 | info = false; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 488 | |
| 489 | /* pad packets. Works as a second tool and is always in prox */ |
| 490 | if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || |
| 491 | data[0] == WACOM_REPORT_CINTIQPAD)) |
| 492 | return 0; |
| 493 | |
| 494 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 495 | buttons = (data[3] << 1) | (data[2] & 0x01); |
| 496 | ring1 = data[1]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 497 | } else if (features->type == DTK) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 498 | buttons = data[6]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 499 | } else if (features->type == WACOM_13HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 500 | buttons = (data[4] << 1) | (data[3] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 501 | } else if (features->type == WACOM_24HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 502 | buttons = (data[8] << 8) | data[6]; |
| 503 | ring1 = data[1]; |
| 504 | ring2 = data[2]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 505 | |
| 506 | /* |
| 507 | * Three "buttons" are available on the 24HD which are |
| 508 | * physically implemented as a touchstrip. Each button |
| 509 | * is approximately 3 bits wide with a 2 bit spacing. |
| 510 | * The raw touchstrip bits are stored at: |
| 511 | * ((data[3] & 0x1f) << 8) | data[4]) |
| 512 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 513 | nkeys = 3; |
| 514 | keys = ((data[3] & 0x1C) ? 1<<2 : 0) | |
| 515 | ((data[4] & 0xE0) ? 1<<1 : 0) | |
| 516 | ((data[4] & 0x07) ? 1<<0 : 0); |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 517 | keyboard = !!(data[4] & 0xE0); |
| 518 | info = !!(data[3] & 0x1C); |
| 519 | |
| 520 | if (features->oPid) { |
| 521 | mute_touch = !!(data[4] & 0x07); |
| 522 | if (mute_touch) |
| 523 | wacom->shared->is_touch_on = |
| 524 | !wacom->shared->is_touch_on; |
| 525 | } else { |
| 526 | wrench = !!(data[4] & 0x07); |
| 527 | } |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 528 | } else if (features->type == WACOM_27QHD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 529 | nkeys = 3; |
| 530 | keys = data[2] & 0x07; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 531 | |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 532 | wrench = !!(data[2] & 0x01); |
| 533 | keyboard = !!(data[2] & 0x02); |
| 534 | |
| 535 | if (features->oPid) { |
| 536 | mute_touch = !!(data[2] & 0x04); |
| 537 | if (mute_touch) |
| 538 | wacom->shared->is_touch_on = |
| 539 | !wacom->shared->is_touch_on; |
| 540 | } else { |
| 541 | menu = !!(data[2] & 0x04); |
| 542 | } |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 543 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); |
| 544 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); |
| 545 | input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 546 | } else if (features->type == CINTIQ_HYBRID) { |
| 547 | /* |
| 548 | * Do not send hardware buttons under Android. They |
| 549 | * are already sent to the system through GPIO (and |
| 550 | * have different meaning). |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 551 | * |
| 552 | * d-pad right -> data[4] & 0x10 |
| 553 | * d-pad up -> data[4] & 0x20 |
| 554 | * d-pad left -> data[4] & 0x40 |
| 555 | * d-pad down -> data[4] & 0x80 |
| 556 | * d-pad center -> data[3] & 0x01 |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 557 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 558 | buttons = (data[4] << 1) | (data[3] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 559 | } else if (features->type == CINTIQ_COMPANION_2) { |
Aaron Armstrong Skomra | 693c3da | 2019-07-23 11:09:15 -0700 | [diff] [blame] | 560 | /* d-pad right -> data[2] & 0x10 |
| 561 | * d-pad up -> data[2] & 0x20 |
| 562 | * d-pad left -> data[2] & 0x40 |
| 563 | * d-pad down -> data[2] & 0x80 |
| 564 | * d-pad center -> data[1] & 0x01 |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 565 | */ |
Jason Gerecke | 0402b6b | 2015-12-16 13:37:36 -0800 | [diff] [blame] | 566 | buttons = ((data[2] >> 4) << 7) | |
Aaron Armstrong Skomra | 693c3da | 2019-07-23 11:09:15 -0700 | [diff] [blame] | 567 | ((data[1] & 0x04) << 4) | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 568 | ((data[2] & 0x0F) << 2) | |
| 569 | (data[1] & 0x03); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 570 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 571 | /* |
| 572 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in |
| 573 | * addition to the mechanical switch. Switch data is |
| 574 | * stored in data[4], capacitive data in data[5]. |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 575 | * |
| 576 | * Touch ring mode switch (data[3]) has no capacitive sensor |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 577 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 578 | buttons = (data[4] << 1) | (data[3] & 0x01); |
| 579 | ring1 = data[2]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 580 | } else { |
| 581 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 582 | buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) | |
| 583 | (data[6] << 1) | (data[5] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 584 | |
| 585 | if (features->type == WACOM_22HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 586 | nkeys = 3; |
| 587 | keys = data[9] & 0x07; |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 588 | |
| 589 | info = !!(data[9] & 0x01); |
| 590 | wrench = !!(data[9] & 0x02); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 591 | } |
| 592 | } else { |
Ping Cheng | ce06760 | 2017-08-31 15:50:03 -0700 | [diff] [blame] | 593 | buttons = ((data[6] & 0x10) << 5) | |
| 594 | ((data[5] & 0x10) << 4) | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 595 | ((data[6] & 0x0F) << 4) | |
| 596 | (data[5] & 0x0F); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 597 | } |
Jason Gerecke | f73d08d | 2015-12-16 13:37:33 -0800 | [diff] [blame] | 598 | strip1 = ((data[1] & 0x1f) << 8) | data[2]; |
| 599 | strip2 = ((data[3] & 0x1f) << 8) | data[4]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 600 | } |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 601 | |
Jason Gerecke | 073b50b | 2019-08-16 11:54:26 -0700 | [diff] [blame] | 602 | prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) | |
Dan Carpenter | 8f9cfdd | 2015-12-09 13:22:05 +0300 | [diff] [blame] | 603 | (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2; |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 604 | |
| 605 | wacom_report_numbered_buttons(input, nbuttons, buttons); |
| 606 | |
| 607 | for (i = 0; i < nkeys; i++) |
| 608 | input_report_key(input, KEY_PROG1 + i, keys & (1 << i)); |
| 609 | |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 610 | input_report_key(input, KEY_BUTTONCONFIG, wrench); |
| 611 | input_report_key(input, KEY_ONSCREEN_KEYBOARD, keyboard); |
| 612 | input_report_key(input, KEY_CONTROLPANEL, menu); |
| 613 | input_report_key(input, KEY_INFO, info); |
| 614 | |
| 615 | if (wacom->shared && wacom->shared->touch_input) { |
| 616 | input_report_switch(wacom->shared->touch_input, |
| 617 | SW_MUTE_DEVICE, |
| 618 | !wacom->shared->is_touch_on); |
| 619 | input_sync(wacom->shared->touch_input); |
| 620 | } |
| 621 | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 622 | input_report_abs(input, ABS_RX, strip1); |
Jason Gerecke | 03a0dc5 | 2015-12-16 13:37:34 -0800 | [diff] [blame] | 623 | input_report_abs(input, ABS_RY, strip2); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 624 | |
Jason Gerecke | aaae03e | 2015-12-16 13:37:35 -0800 | [diff] [blame] | 625 | input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0); |
| 626 | input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 627 | |
| 628 | input_report_key(input, wacom->tool[1], prox ? 1 : 0); |
| 629 | input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); |
| 630 | |
| 631 | input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); |
| 632 | |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 633 | return 1; |
| 634 | } |
| 635 | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 636 | static int wacom_intuos_id_mangle(int tool_id) |
| 637 | { |
| 638 | return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); |
| 639 | } |
| 640 | |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 641 | static int wacom_intuos_get_tool_type(int tool_id) |
| 642 | { |
| 643 | int tool_type; |
| 644 | |
| 645 | switch (tool_id) { |
| 646 | case 0x812: /* Inking pen */ |
| 647 | case 0x801: /* Intuos3 Inking pen */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 648 | case 0x12802: /* Intuos4/5 Inking Pen */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 649 | case 0x012: |
| 650 | tool_type = BTN_TOOL_PENCIL; |
| 651 | break; |
| 652 | |
| 653 | case 0x822: /* Pen */ |
| 654 | case 0x842: |
| 655 | case 0x852: |
| 656 | case 0x823: /* Intuos3 Grip Pen */ |
| 657 | case 0x813: /* Intuos3 Classic Pen */ |
| 658 | case 0x885: /* Intuos3 Marker Pen */ |
| 659 | case 0x802: /* Intuos4/5 13HD/24HD General Pen */ |
| 660 | case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ |
| 661 | case 0x8e2: /* IntuosHT2 pen */ |
| 662 | case 0x022: |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 663 | case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ |
Jason Gerecke | 4e6e7d7 | 2019-02-19 17:58:56 +0000 | [diff] [blame] | 664 | case 0x10842: /* MobileStudio Pro Pro Pen slim */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 665 | case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ |
| 666 | case 0x16802: /* Cintiq 13HD Pro Pen */ |
| 667 | case 0x18802: /* DTH2242 Pen */ |
| 668 | case 0x10802: /* Intuos4/5 13HD/24HD General Pen */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 669 | tool_type = BTN_TOOL_PEN; |
| 670 | break; |
| 671 | |
| 672 | case 0x832: /* Stroke pen */ |
| 673 | case 0x032: |
| 674 | tool_type = BTN_TOOL_BRUSH; |
| 675 | break; |
| 676 | |
| 677 | case 0x007: /* Mouse 4D and 2D */ |
| 678 | case 0x09c: |
| 679 | case 0x094: |
| 680 | case 0x017: /* Intuos3 2D Mouse */ |
| 681 | case 0x806: /* Intuos4 Mouse */ |
| 682 | tool_type = BTN_TOOL_MOUSE; |
| 683 | break; |
| 684 | |
| 685 | case 0x096: /* Lens cursor */ |
| 686 | case 0x097: /* Intuos3 Lens cursor */ |
| 687 | case 0x006: /* Intuos4 Lens cursor */ |
| 688 | tool_type = BTN_TOOL_LENS; |
| 689 | break; |
| 690 | |
| 691 | case 0x82a: /* Eraser */ |
Jason Gerecke | 9ce9a12 | 2016-11-11 15:05:52 -0800 | [diff] [blame] | 692 | case 0x84a: |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 693 | case 0x85a: |
| 694 | case 0x91a: |
| 695 | case 0xd1a: |
| 696 | case 0x0fa: |
| 697 | case 0x82b: /* Intuos3 Grip Pen Eraser */ |
| 698 | case 0x81b: /* Intuos3 Classic Pen Eraser */ |
| 699 | case 0x91b: /* Intuos3 Airbrush Eraser */ |
| 700 | case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */ |
| 701 | case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */ |
| 702 | case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 703 | case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */ |
| 704 | case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ |
| 705 | case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */ |
Jason Gerecke | 4e6e7d7 | 2019-02-19 17:58:56 +0000 | [diff] [blame] | 706 | case 0x1084a: /* MobileStudio Pro Pro Pen slim Eraser */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 707 | case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */ |
| 708 | case 0x1880a: /* DTH2242 Eraser */ |
| 709 | case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 710 | tool_type = BTN_TOOL_RUBBER; |
| 711 | break; |
| 712 | |
| 713 | case 0xd12: |
| 714 | case 0x912: |
| 715 | case 0x112: |
| 716 | case 0x913: /* Intuos3 Airbrush */ |
| 717 | case 0x902: /* Intuos4/5 13HD/24HD Airbrush */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 718 | case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 719 | tool_type = BTN_TOOL_AIRBRUSH; |
| 720 | break; |
| 721 | |
| 722 | default: /* Unknown tool */ |
| 723 | tool_type = BTN_TOOL_PEN; |
| 724 | break; |
| 725 | } |
| 726 | return tool_type; |
| 727 | } |
| 728 | |
Aaron Armstrong Skomra | 619d3a2 | 2018-04-04 14:24:11 -0700 | [diff] [blame] | 729 | static void wacom_exit_report(struct wacom_wac *wacom) |
| 730 | { |
| 731 | struct input_dev *input = wacom->pen_input; |
| 732 | struct wacom_features *features = &wacom->features; |
| 733 | unsigned char *data = wacom->data; |
| 734 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
| 735 | |
| 736 | /* |
| 737 | * Reset all states otherwise we lose the initial states |
| 738 | * when in-prox next time |
| 739 | */ |
| 740 | input_report_abs(input, ABS_X, 0); |
| 741 | input_report_abs(input, ABS_Y, 0); |
| 742 | input_report_abs(input, ABS_DISTANCE, 0); |
| 743 | input_report_abs(input, ABS_TILT_X, 0); |
| 744 | input_report_abs(input, ABS_TILT_Y, 0); |
| 745 | if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { |
| 746 | input_report_key(input, BTN_LEFT, 0); |
| 747 | input_report_key(input, BTN_MIDDLE, 0); |
| 748 | input_report_key(input, BTN_RIGHT, 0); |
| 749 | input_report_key(input, BTN_SIDE, 0); |
| 750 | input_report_key(input, BTN_EXTRA, 0); |
| 751 | input_report_abs(input, ABS_THROTTLE, 0); |
| 752 | input_report_abs(input, ABS_RZ, 0); |
| 753 | } else { |
| 754 | input_report_abs(input, ABS_PRESSURE, 0); |
| 755 | input_report_key(input, BTN_STYLUS, 0); |
| 756 | input_report_key(input, BTN_STYLUS2, 0); |
| 757 | input_report_key(input, BTN_TOUCH, 0); |
| 758 | input_report_abs(input, ABS_WHEEL, 0); |
| 759 | if (features->type >= INTUOS3S) |
| 760 | input_report_abs(input, ABS_Z, 0); |
| 761 | } |
| 762 | input_report_key(input, wacom->tool[idx], 0); |
| 763 | input_report_abs(input, ABS_MISC, 0); /* reset tool id */ |
| 764 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
| 765 | wacom->id[idx] = 0; |
| 766 | } |
| 767 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 768 | static int wacom_intuos_inout(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 769 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 770 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 771 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 772 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 773 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 774 | |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 775 | if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */ |
| 776 | ((data[1] & 0xfe) == 0x20) || /* in range */ |
| 777 | ((data[1] & 0xfe) == 0x80))) /* out prox */ |
| 778 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 779 | |
| 780 | /* Enter report */ |
| 781 | if ((data[1] & 0xfc) == 0xc0) { |
| 782 | /* serial number of the tool */ |
| 783 | wacom->serial[idx] = ((data[3] & 0x0f) << 28) + |
| 784 | (data[4] << 20) + (data[5] << 12) + |
| 785 | (data[6] << 4) + (data[7] >> 4); |
| 786 | |
Ping Cheng | 493630b | 2010-06-22 11:21:34 -0700 | [diff] [blame] | 787 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 788 | ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 789 | |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 790 | wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 791 | |
Ping Cheng | eff6ca9 | 2016-05-02 21:17:34 -0700 | [diff] [blame] | 792 | wacom->shared->stylus_in_proximity = true; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 793 | return 1; |
| 794 | } |
| 795 | |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 796 | /* in Range */ |
| 797 | if ((data[1] & 0xfe) == 0x20) { |
Ping Cheng | 526d6e7 | 2016-01-08 17:16:25 -0800 | [diff] [blame] | 798 | if (features->type != INTUOSHT2) |
| 799 | wacom->shared->stylus_in_proximity = true; |
Ping Cheng | 486b908 | 2015-02-20 14:25:58 -0800 | [diff] [blame] | 800 | |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 801 | /* in Range while exiting */ |
| 802 | if (wacom->reporting_data) { |
| 803 | input_report_key(input, BTN_TOUCH, 0); |
| 804 | input_report_abs(input, ABS_PRESSURE, 0); |
| 805 | input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); |
| 806 | return 2; |
| 807 | } |
| 808 | return 1; |
Jason Gerecke | 4eb1830 | 2013-09-20 09:48:46 -0700 | [diff] [blame] | 809 | } |
| 810 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 811 | /* Exit report */ |
| 812 | if ((data[1] & 0xfe) == 0x80) { |
Ping Cheng | f3586d2 | 2015-03-20 14:57:00 -0700 | [diff] [blame] | 813 | wacom->shared->stylus_in_proximity = false; |
Ping Cheng | b3bd7ef | 2015-01-09 11:05:13 -0800 | [diff] [blame] | 814 | wacom->reporting_data = false; |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 815 | |
Ping Cheng | 373a535 | 2015-01-09 11:04:50 -0800 | [diff] [blame] | 816 | /* don't report exit if we don't know the ID */ |
| 817 | if (!wacom->id[idx]) |
| 818 | return 1; |
| 819 | |
Aaron Armstrong Skomra | 619d3a2 | 2018-04-04 14:24:11 -0700 | [diff] [blame] | 820 | wacom_exit_report(wacom); |
Ping Cheng | 80d4e8e | 2007-02-23 12:22:48 -0800 | [diff] [blame] | 821 | return 2; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 822 | } |
Ping Cheng | 373a535 | 2015-01-09 11:04:50 -0800 | [diff] [blame] | 823 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 824 | return 0; |
| 825 | } |
| 826 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 827 | static inline bool report_touch_events(struct wacom_wac *wacom) |
| 828 | { |
| 829 | return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); |
| 830 | } |
| 831 | |
| 832 | static inline bool delay_pen_events(struct wacom_wac *wacom) |
| 833 | { |
| 834 | return (wacom->shared->touch_down && touch_arbitration); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 837 | static int wacom_intuos_general(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 838 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 839 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 840 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 841 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 842 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 843 | unsigned char type = (data[1] >> 1) & 0x0F; |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 844 | unsigned int x, y, distance, t; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 845 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 846 | if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && |
| 847 | data[0] != WACOM_REPORT_INTUOS_PEN) |
| 848 | return 0; |
| 849 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 850 | if (delay_pen_events(wacom)) |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 851 | return 1; |
| 852 | |
Ping Cheng | 599b082 | 2016-01-08 17:14:54 -0800 | [diff] [blame] | 853 | /* don't report events if we don't know the tool ID */ |
| 854 | if (!wacom->id[idx]) { |
| 855 | /* but reschedule a read of the current tool */ |
| 856 | wacom_intuos_schedule_prox_event(wacom); |
| 857 | return 1; |
| 858 | } |
| 859 | |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 860 | /* |
| 861 | * don't report events for invalid data |
| 862 | */ |
| 863 | /* older I4 styli don't work with new Cintiqs */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 864 | if ((!((wacom->id[idx] >> 16) & 0x01) && |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 865 | (features->type == WACOM_21UX2)) || |
| 866 | /* Only large Intuos support Lense Cursor */ |
| 867 | (wacom->tool[idx] == BTN_TOOL_LENS && |
| 868 | (features->type == INTUOS3 || |
| 869 | features->type == INTUOS3S || |
| 870 | features->type == INTUOS4 || |
| 871 | features->type == INTUOS4S || |
| 872 | features->type == INTUOS5 || |
| 873 | features->type == INTUOS5S || |
| 874 | features->type == INTUOSPM || |
| 875 | features->type == INTUOSPS)) || |
| 876 | /* Cintiq doesn't send data when RDY bit isn't set */ |
| 877 | (features->type == CINTIQ && !(data[1] & 0x40))) |
| 878 | return 1; |
| 879 | |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 880 | x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); |
| 881 | y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1); |
| 882 | distance = data[9] >> 2; |
| 883 | if (features->type < INTUOS3S) { |
| 884 | x >>= 1; |
| 885 | y >>= 1; |
| 886 | distance >>= 1; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 887 | } |
Jason Gerecke | b72fb1d | 2019-08-07 14:11:55 -0700 | [diff] [blame] | 888 | if (features->type == INTUOSHT2) |
| 889 | distance = features->distance_max - distance; |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 890 | input_report_abs(input, ABS_X, x); |
| 891 | input_report_abs(input, ABS_Y, y); |
| 892 | input_report_abs(input, ABS_DISTANCE, distance); |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 893 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 894 | switch (type) { |
| 895 | case 0x00: |
| 896 | case 0x01: |
| 897 | case 0x02: |
| 898 | case 0x03: |
| 899 | /* general pen packet */ |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 900 | t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1); |
| 901 | if (features->pressure_max < 2047) |
| 902 | t >>= 1; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 903 | input_report_abs(input, ABS_PRESSURE, t); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 904 | if (features->type != INTUOSHT2) { |
| 905 | input_report_abs(input, ABS_TILT_X, |
Jason Gerecke | ec5fc1c | 2014-11-18 16:50:08 -0800 | [diff] [blame] | 906 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 907 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
| 908 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 909 | input_report_key(input, BTN_STYLUS, data[1] & 2); |
| 910 | input_report_key(input, BTN_STYLUS2, data[1] & 4); |
| 911 | input_report_key(input, BTN_TOUCH, t > 10); |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 912 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 913 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 914 | case 0x0a: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 915 | /* airbrush second packet */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 916 | input_report_abs(input, ABS_WHEEL, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 917 | (data[6] << 2) | ((data[7] >> 6) & 3)); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 918 | input_report_abs(input, ABS_TILT_X, |
Jason Gerecke | ec5fc1c | 2014-11-18 16:50:08 -0800 | [diff] [blame] | 919 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 920 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 921 | break; |
| 922 | |
| 923 | case 0x05: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 924 | /* Rotation packet */ |
| 925 | if (features->type >= INTUOS3S) { |
| 926 | /* I3 marker pen rotation */ |
| 927 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 928 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : |
| 929 | ((t-1) / 2 + 450)) : (450 - t / 2) ; |
| 930 | input_report_abs(input, ABS_Z, t); |
| 931 | } else { |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 932 | /* 4D mouse 2nd packet */ |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 933 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 934 | input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? |
| 935 | ((t - 1) / 2) : -t / 2); |
| 936 | } |
| 937 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 938 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 939 | case 0x04: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 940 | /* 4D mouse 1st packet */ |
| 941 | input_report_key(input, BTN_LEFT, data[8] & 0x01); |
| 942 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); |
| 943 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); |
| 944 | |
| 945 | input_report_key(input, BTN_SIDE, data[8] & 0x20); |
| 946 | input_report_key(input, BTN_EXTRA, data[8] & 0x10); |
| 947 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
| 948 | input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); |
| 949 | break; |
| 950 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 951 | case 0x06: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 952 | /* I4 mouse */ |
| 953 | input_report_key(input, BTN_LEFT, data[6] & 0x01); |
| 954 | input_report_key(input, BTN_MIDDLE, data[6] & 0x02); |
| 955 | input_report_key(input, BTN_RIGHT, data[6] & 0x04); |
| 956 | input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) |
| 957 | - ((data[7] & 0x40) >> 6)); |
| 958 | input_report_key(input, BTN_SIDE, data[6] & 0x08); |
| 959 | input_report_key(input, BTN_EXTRA, data[6] & 0x10); |
| 960 | |
| 961 | input_report_abs(input, ABS_TILT_X, |
| 962 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 963 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
| 964 | break; |
| 965 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 966 | case 0x08: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 967 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { |
| 968 | /* 2D mouse packet */ |
| 969 | input_report_key(input, BTN_LEFT, data[8] & 0x04); |
| 970 | input_report_key(input, BTN_MIDDLE, data[8] & 0x08); |
| 971 | input_report_key(input, BTN_RIGHT, data[8] & 0x10); |
| 972 | input_report_rel(input, REL_WHEEL, (data[8] & 0x01) |
| 973 | - ((data[8] & 0x02) >> 1)); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 974 | |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 975 | /* I3 2D mouse side buttons */ |
| 976 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { |
| 977 | input_report_key(input, BTN_SIDE, data[8] & 0x40); |
| 978 | input_report_key(input, BTN_EXTRA, data[8] & 0x20); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 979 | } |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 980 | } |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 981 | else if (wacom->tool[idx] == BTN_TOOL_LENS) { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 982 | /* Lens cursor packets */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 983 | input_report_key(input, BTN_LEFT, data[8] & 0x01); |
| 984 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); |
| 985 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); |
| 986 | input_report_key(input, BTN_SIDE, data[8] & 0x10); |
| 987 | input_report_key(input, BTN_EXTRA, data[8] & 0x08); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 988 | } |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 989 | break; |
| 990 | |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 991 | case 0x07: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 992 | case 0x09: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 993 | case 0x0b: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 994 | case 0x0c: |
| 995 | case 0x0d: |
| 996 | case 0x0e: |
| 997 | case 0x0f: |
| 998 | /* unhandled */ |
| 999 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1000 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1001 | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 1002 | input_report_abs(input, ABS_MISC, |
| 1003 | wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1004 | input_report_key(input, wacom->tool[idx], 1); |
| 1005 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
Ping Cheng | b3bd7ef | 2015-01-09 11:05:13 -0800 | [diff] [blame] | 1006 | wacom->reporting_data = true; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1007 | return 2; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | static int wacom_intuos_irq(struct wacom_wac *wacom) |
| 1011 | { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1012 | unsigned char *data = wacom->data; |
| 1013 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1014 | int result; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1015 | |
| 1016 | if (data[0] != WACOM_REPORT_PENABLED && |
Jason Gerecke | 0610999 | 2015-11-30 17:13:52 -0800 | [diff] [blame] | 1017 | data[0] != WACOM_REPORT_INTUOS_ID1 && |
| 1018 | data[0] != WACOM_REPORT_INTUOS_ID2 && |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1019 | data[0] != WACOM_REPORT_INTUOSPAD && |
| 1020 | data[0] != WACOM_REPORT_INTUOS_PEN && |
| 1021 | data[0] != WACOM_REPORT_CINTIQ && |
| 1022 | data[0] != WACOM_REPORT_CINTIQPAD && |
| 1023 | data[0] != WACOM_REPORT_INTUOS5PAD) { |
| 1024 | dev_dbg(input->dev.parent, |
| 1025 | "%s: received unknown report #%d\n", __func__, data[0]); |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1029 | /* process pad events */ |
| 1030 | result = wacom_intuos_pad(wacom); |
| 1031 | if (result) |
| 1032 | return result; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1033 | |
| 1034 | /* process in/out prox events */ |
| 1035 | result = wacom_intuos_inout(wacom); |
| 1036 | if (result) |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1037 | return result - 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1038 | |
| 1039 | /* process general packets */ |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1040 | result = wacom_intuos_general(wacom); |
| 1041 | if (result) |
| 1042 | return result - 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1043 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1044 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1045 | } |
| 1046 | |
Jason Gerecke | 149f6f6 | 2017-03-31 10:02:05 -0700 | [diff] [blame] | 1047 | static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) |
| 1048 | { |
| 1049 | unsigned char *data = wacom_wac->data; |
| 1050 | struct input_dev *input; |
| 1051 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 1052 | struct wacom_remote *remote = wacom->remote; |
| 1053 | int bat_charging, bat_percent, touch_ring_mode; |
| 1054 | __u32 serial; |
| 1055 | int i, index = -1; |
| 1056 | unsigned long flags; |
| 1057 | |
| 1058 | if (data[0] != WACOM_REPORT_REMOTE) { |
| 1059 | hid_dbg(wacom->hdev, "%s: received unknown report #%d", |
| 1060 | __func__, data[0]); |
| 1061 | return 0; |
| 1062 | } |
| 1063 | |
| 1064 | serial = data[3] + (data[4] << 8) + (data[5] << 16); |
| 1065 | wacom_wac->id[0] = PAD_DEVICE_ID; |
| 1066 | |
| 1067 | spin_lock_irqsave(&remote->remote_lock, flags); |
| 1068 | |
| 1069 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1070 | if (remote->remotes[i].serial == serial) { |
| 1071 | index = i; |
| 1072 | break; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | if (index < 0 || !remote->remotes[index].registered) |
| 1077 | goto out; |
| 1078 | |
| 1079 | input = remote->remotes[index].input; |
| 1080 | |
| 1081 | input_report_key(input, BTN_0, (data[9] & 0x01)); |
| 1082 | input_report_key(input, BTN_1, (data[9] & 0x02)); |
| 1083 | input_report_key(input, BTN_2, (data[9] & 0x04)); |
| 1084 | input_report_key(input, BTN_3, (data[9] & 0x08)); |
| 1085 | input_report_key(input, BTN_4, (data[9] & 0x10)); |
| 1086 | input_report_key(input, BTN_5, (data[9] & 0x20)); |
| 1087 | input_report_key(input, BTN_6, (data[9] & 0x40)); |
| 1088 | input_report_key(input, BTN_7, (data[9] & 0x80)); |
| 1089 | |
| 1090 | input_report_key(input, BTN_8, (data[10] & 0x01)); |
| 1091 | input_report_key(input, BTN_9, (data[10] & 0x02)); |
| 1092 | input_report_key(input, BTN_A, (data[10] & 0x04)); |
| 1093 | input_report_key(input, BTN_B, (data[10] & 0x08)); |
| 1094 | input_report_key(input, BTN_C, (data[10] & 0x10)); |
| 1095 | input_report_key(input, BTN_X, (data[10] & 0x20)); |
| 1096 | input_report_key(input, BTN_Y, (data[10] & 0x40)); |
| 1097 | input_report_key(input, BTN_Z, (data[10] & 0x80)); |
| 1098 | |
| 1099 | input_report_key(input, BTN_BASE, (data[11] & 0x01)); |
| 1100 | input_report_key(input, BTN_BASE2, (data[11] & 0x02)); |
| 1101 | |
| 1102 | if (data[12] & 0x80) |
Aaron Armstrong Skomra | fcf887e | 2019-08-16 12:00:54 -0700 | [diff] [blame] | 1103 | input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1); |
Jason Gerecke | 149f6f6 | 2017-03-31 10:02:05 -0700 | [diff] [blame] | 1104 | else |
| 1105 | input_report_abs(input, ABS_WHEEL, 0); |
| 1106 | |
| 1107 | bat_percent = data[7] & 0x7f; |
| 1108 | bat_charging = !!(data[7] & 0x80); |
| 1109 | |
| 1110 | if (data[9] | data[10] | (data[11] & 0x03) | data[12]) |
| 1111 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); |
| 1112 | else |
| 1113 | input_report_abs(input, ABS_MISC, 0); |
| 1114 | |
| 1115 | input_event(input, EV_MSC, MSC_SERIAL, serial); |
| 1116 | |
| 1117 | input_sync(input); |
| 1118 | |
| 1119 | /*Which mode select (LED light) is currently on?*/ |
| 1120 | touch_ring_mode = (data[11] & 0xC0) >> 6; |
| 1121 | |
| 1122 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1123 | if (remote->remotes[i].serial == serial) |
| 1124 | wacom->led.groups[i].select = touch_ring_mode; |
| 1125 | } |
| 1126 | |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 1127 | __wacom_notify_battery(&remote->remotes[index].battery, |
| 1128 | WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent, |
Jason Gerecke | 149f6f6 | 2017-03-31 10:02:05 -0700 | [diff] [blame] | 1129 | bat_charging, 1, bat_charging); |
| 1130 | |
| 1131 | out: |
| 1132 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
| 1133 | return 0; |
| 1134 | } |
| 1135 | |
| 1136 | static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) |
| 1137 | { |
| 1138 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 1139 | unsigned char *data = wacom_wac->data; |
| 1140 | struct wacom_remote *remote = wacom->remote; |
| 1141 | struct wacom_remote_data remote_data; |
| 1142 | unsigned long flags; |
| 1143 | int i, ret; |
| 1144 | |
| 1145 | if (data[0] != WACOM_REPORT_DEVICE_LIST) |
| 1146 | return; |
| 1147 | |
| 1148 | memset(&remote_data, 0, sizeof(struct wacom_remote_data)); |
| 1149 | |
| 1150 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 1151 | int j = i * 6; |
| 1152 | int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4]; |
| 1153 | bool connected = data[j+2]; |
| 1154 | |
| 1155 | remote_data.remote[i].serial = serial; |
| 1156 | remote_data.remote[i].connected = connected; |
| 1157 | } |
| 1158 | |
| 1159 | spin_lock_irqsave(&remote->remote_lock, flags); |
| 1160 | |
| 1161 | ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data)); |
| 1162 | if (ret != sizeof(remote_data)) { |
| 1163 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
| 1164 | hid_err(wacom->hdev, "Can't queue Remote status event.\n"); |
| 1165 | return; |
| 1166 | } |
| 1167 | |
| 1168 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
| 1169 | |
| 1170 | wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE); |
| 1171 | } |
| 1172 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1173 | static int int_dist(int x1, int y1, int x2, int y2) |
| 1174 | { |
| 1175 | int x = x2 - x1; |
| 1176 | int y = y2 - y1; |
| 1177 | |
| 1178 | return int_sqrt(x*x + y*y); |
| 1179 | } |
| 1180 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1181 | static void wacom_intuos_bt_process_data(struct wacom_wac *wacom, |
| 1182 | unsigned char *data) |
| 1183 | { |
| 1184 | memcpy(wacom->data, data, 10); |
| 1185 | wacom_intuos_irq(wacom); |
| 1186 | |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1187 | input_sync(wacom->pen_input); |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1188 | if (wacom->pad_input) |
| 1189 | input_sync(wacom->pad_input); |
| 1190 | } |
| 1191 | |
| 1192 | static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1193 | { |
| 1194 | unsigned char data[WACOM_PKGLEN_MAX]; |
| 1195 | int i = 1; |
| 1196 | unsigned power_raw, battery_capacity, bat_charging, ps_connected; |
| 1197 | |
| 1198 | memcpy(data, wacom->data, len); |
| 1199 | |
| 1200 | switch (data[0]) { |
| 1201 | case 0x04: |
| 1202 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1203 | i += 10; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 1204 | fallthrough; |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1205 | case 0x03: |
| 1206 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1207 | i += 10; |
| 1208 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1209 | i += 10; |
| 1210 | power_raw = data[i]; |
| 1211 | bat_charging = (power_raw & 0x08) ? 1 : 0; |
| 1212 | ps_connected = (power_raw & 0x10) ? 1 : 0; |
| 1213 | battery_capacity = batcap_i4[power_raw & 0x07]; |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 1214 | wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1215 | battery_capacity, bat_charging, |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 1216 | battery_capacity || bat_charging, |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 1217 | ps_connected); |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1218 | break; |
| 1219 | default: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1220 | dev_dbg(wacom->pen_input->dev.parent, |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1221 | "Unknown report: %d,%d size:%zu\n", |
| 1222 | data[0], data[1], len); |
| 1223 | return 0; |
| 1224 | } |
| 1225 | return 0; |
| 1226 | } |
| 1227 | |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1228 | static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) |
| 1229 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1230 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1231 | unsigned touch_max = wacom->features.touch_max; |
| 1232 | int count = 0; |
| 1233 | int i; |
| 1234 | |
Ping Cheng | 26ba61f | 2015-05-19 17:42:02 -0700 | [diff] [blame] | 1235 | if (!touch_max) |
| 1236 | return 0; |
| 1237 | |
Jason Gerecke | 71b5c47 | 2015-04-15 17:22:32 -0700 | [diff] [blame] | 1238 | if (touch_max == 1) |
| 1239 | return test_bit(BTN_TOUCH, input->key) && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1240 | report_touch_events(wacom); |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1241 | |
| 1242 | for (i = 0; i < input->mt->num_slots; i++) { |
| 1243 | struct input_mt_slot *ps = &input->mt->slots[i]; |
| 1244 | int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); |
| 1245 | if (id >= 0) |
| 1246 | count++; |
| 1247 | } |
| 1248 | |
| 1249 | return count; |
| 1250 | } |
| 1251 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1252 | static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) |
| 1253 | { |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1254 | int pen_frame_len, pen_frames; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1255 | |
| 1256 | struct input_dev *pen_input = wacom->pen_input; |
| 1257 | unsigned char *data = wacom->data; |
| 1258 | int i; |
| 1259 | |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 1260 | if (wacom->features.type == INTUOSP2_BT || |
| 1261 | wacom->features.type == INTUOSP2S_BT) { |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1262 | wacom->serial[0] = get_unaligned_le64(&data[99]); |
| 1263 | wacom->id[0] = get_unaligned_le16(&data[107]); |
| 1264 | pen_frame_len = 14; |
| 1265 | pen_frames = 7; |
| 1266 | } else { |
| 1267 | wacom->serial[0] = get_unaligned_le64(&data[33]); |
| 1268 | wacom->id[0] = get_unaligned_le16(&data[41]); |
| 1269 | pen_frame_len = 8; |
| 1270 | pen_frames = 4; |
| 1271 | } |
| 1272 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1273 | if (wacom->serial[0] >> 52 == 1) { |
| 1274 | /* Add back in missing bits of ID for non-USI pens */ |
| 1275 | wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; |
| 1276 | } |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1277 | |
| 1278 | for (i = 0; i < pen_frames; i++) { |
| 1279 | unsigned char *frame = &data[i*pen_frame_len + 1]; |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1280 | bool valid = frame[0] & 0x80; |
| 1281 | bool prox = frame[0] & 0x40; |
| 1282 | bool range = frame[0] & 0x20; |
Jason Gerecke | 2cc0880 | 2019-04-24 15:12:57 -0700 | [diff] [blame] | 1283 | bool invert = frame[0] & 0x10; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1284 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1285 | if (!valid) |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1286 | continue; |
| 1287 | |
Aaron Armstrong Skomra | 619d3a2 | 2018-04-04 14:24:11 -0700 | [diff] [blame] | 1288 | if (!prox) { |
| 1289 | wacom->shared->stylus_in_proximity = false; |
| 1290 | wacom_exit_report(wacom); |
| 1291 | input_sync(pen_input); |
Jason Gerecke | 2cc0880 | 2019-04-24 15:12:57 -0700 | [diff] [blame] | 1292 | |
| 1293 | wacom->tool[0] = 0; |
| 1294 | wacom->id[0] = 0; |
| 1295 | wacom->serial[0] = 0; |
Aaron Armstrong Skomra | 619d3a2 | 2018-04-04 14:24:11 -0700 | [diff] [blame] | 1296 | return; |
| 1297 | } |
Jason Gerecke | 2cc0880 | 2019-04-24 15:12:57 -0700 | [diff] [blame] | 1298 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1299 | if (range) { |
Jason Gerecke | 2cc0880 | 2019-04-24 15:12:57 -0700 | [diff] [blame] | 1300 | if (!wacom->tool[0]) { /* first in range */ |
| 1301 | /* Going into range select tool */ |
| 1302 | if (invert) |
| 1303 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 1304 | else if (wacom->id[0]) |
| 1305 | wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]); |
| 1306 | else |
| 1307 | wacom->tool[0] = BTN_TOOL_PEN; |
| 1308 | } |
| 1309 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1310 | input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); |
| 1311 | input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1312 | |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 1313 | if (wacom->features.type == INTUOSP2_BT || |
| 1314 | wacom->features.type == INTUOSP2S_BT) { |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1315 | /* Fix rotation alignment: userspace expects zero at left */ |
| 1316 | int16_t rotation = |
| 1317 | (int16_t)get_unaligned_le16(&frame[9]); |
| 1318 | rotation += 1800/4; |
| 1319 | |
| 1320 | if (rotation > 899) |
| 1321 | rotation -= 1800; |
| 1322 | |
| 1323 | input_report_abs(pen_input, ABS_TILT_X, |
| 1324 | (char)frame[7]); |
| 1325 | input_report_abs(pen_input, ABS_TILT_Y, |
| 1326 | (char)frame[8]); |
| 1327 | input_report_abs(pen_input, ABS_Z, rotation); |
| 1328 | input_report_abs(pen_input, ABS_WHEEL, |
| 1329 | get_unaligned_le16(&frame[11])); |
| 1330 | } |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1331 | } |
Jason Gerecke | e92a7be | 2019-04-24 15:12:58 -0700 | [diff] [blame] | 1332 | if (wacom->tool[0]) { |
| 1333 | input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); |
Aaron Armstrong Skomra | 7cdf6e4 | 2019-08-12 11:55:52 -0700 | [diff] [blame] | 1334 | if (wacom->features.type == INTUOSP2_BT || |
| 1335 | wacom->features.type == INTUOSP2S_BT) { |
Jason Gerecke | e92a7be | 2019-04-24 15:12:58 -0700 | [diff] [blame] | 1336 | input_report_abs(pen_input, ABS_DISTANCE, |
| 1337 | range ? frame[13] : wacom->features.distance_max); |
| 1338 | } else { |
| 1339 | input_report_abs(pen_input, ABS_DISTANCE, |
| 1340 | range ? frame[7] : wacom->features.distance_max); |
| 1341 | } |
| 1342 | |
Jason Gerecke | fe7f8d7 | 2019-05-07 11:53:20 -0700 | [diff] [blame] | 1343 | input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09); |
Jason Gerecke | e92a7be | 2019-04-24 15:12:58 -0700 | [diff] [blame] | 1344 | input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); |
| 1345 | input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); |
| 1346 | |
| 1347 | input_report_key(pen_input, wacom->tool[0], prox); |
| 1348 | input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); |
| 1349 | input_report_abs(pen_input, ABS_MISC, |
| 1350 | wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1351 | } |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1352 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame] | 1353 | wacom->shared->stylus_in_proximity = prox; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1354 | |
| 1355 | input_sync(pen_input); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom) |
| 1360 | { |
| 1361 | const int finger_touch_len = 8; |
| 1362 | const int finger_frames = 4; |
| 1363 | const int finger_frame_len = 43; |
| 1364 | |
| 1365 | struct input_dev *touch_input = wacom->touch_input; |
| 1366 | unsigned char *data = wacom->data; |
| 1367 | int num_contacts_left = 5; |
| 1368 | int i, j; |
| 1369 | |
| 1370 | for (i = 0; i < finger_frames; i++) { |
| 1371 | unsigned char *frame = &data[i*finger_frame_len + 109]; |
| 1372 | int current_num_contacts = frame[0] & 0x7F; |
| 1373 | int contacts_to_send; |
| 1374 | |
| 1375 | if (!(frame[0] & 0x80)) |
| 1376 | continue; |
| 1377 | |
| 1378 | /* |
| 1379 | * First packet resets the counter since only the first |
| 1380 | * packet in series will have non-zero current_num_contacts. |
| 1381 | */ |
| 1382 | if (current_num_contacts) |
| 1383 | wacom->num_contacts_left = current_num_contacts; |
| 1384 | |
| 1385 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
| 1386 | |
| 1387 | for (j = 0; j < contacts_to_send; j++) { |
| 1388 | unsigned char *touch = &frame[j*finger_touch_len + 1]; |
| 1389 | int slot = input_mt_get_slot_by_key(touch_input, touch[0]); |
| 1390 | int x = get_unaligned_le16(&touch[2]); |
| 1391 | int y = get_unaligned_le16(&touch[4]); |
| 1392 | int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X); |
| 1393 | int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y); |
| 1394 | |
| 1395 | if (slot < 0) |
| 1396 | continue; |
| 1397 | |
| 1398 | input_mt_slot(touch_input, slot); |
| 1399 | input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01); |
| 1400 | input_report_abs(touch_input, ABS_MT_POSITION_X, x); |
| 1401 | input_report_abs(touch_input, ABS_MT_POSITION_Y, y); |
| 1402 | input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h)); |
| 1403 | input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h)); |
| 1404 | input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h); |
| 1405 | } |
| 1406 | |
| 1407 | input_mt_sync_frame(touch_input); |
| 1408 | |
| 1409 | wacom->num_contacts_left -= contacts_to_send; |
| 1410 | if (wacom->num_contacts_left <= 0) { |
| 1411 | wacom->num_contacts_left = 0; |
| 1412 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Jason Gerecke | 69dbdff | 2019-05-07 11:53:22 -0700 | [diff] [blame] | 1413 | input_sync(touch_input); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1414 | } |
| 1415 | } |
| 1416 | |
Jason Gerecke | 69dbdff | 2019-05-07 11:53:22 -0700 | [diff] [blame] | 1417 | if (wacom->num_contacts_left == 0) { |
| 1418 | // Be careful that we don't accidentally call input_sync with |
| 1419 | // only a partial set of fingers of processed |
| 1420 | input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7)); |
| 1421 | input_sync(touch_input); |
| 1422 | } |
| 1423 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1424 | } |
| 1425 | |
| 1426 | static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom) |
| 1427 | { |
| 1428 | struct input_dev *pad_input = wacom->pad_input; |
| 1429 | unsigned char *data = wacom->data; |
Jason Gerecke | dcce8ef | 2020-04-24 14:04:00 -0700 | [diff] [blame] | 1430 | int nbuttons = wacom->features.numbered_buttons; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1431 | |
Jason Gerecke | dcce8ef | 2020-04-24 14:04:00 -0700 | [diff] [blame] | 1432 | int expresskeys = data[282]; |
| 1433 | int center = (data[281] & 0x40) >> 6; |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 1434 | int ring = data[285] & 0x7F; |
| 1435 | bool ringstatus = data[285] & 0x80; |
Jason Gerecke | dcce8ef | 2020-04-24 14:04:00 -0700 | [diff] [blame] | 1436 | bool prox = expresskeys || center || ringstatus; |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 1437 | |
| 1438 | /* Fix touchring data: userspace expects 0 at left and increasing clockwise */ |
| 1439 | ring = 71 - ring; |
| 1440 | ring += 3*72/16; |
| 1441 | if (ring > 71) |
| 1442 | ring -= 72; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1443 | |
Jason Gerecke | dcce8ef | 2020-04-24 14:04:00 -0700 | [diff] [blame] | 1444 | wacom_report_numbered_buttons(pad_input, nbuttons, |
| 1445 | expresskeys | (center << (nbuttons - 1))); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1446 | |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 1447 | input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1448 | |
| 1449 | input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0); |
| 1450 | input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); |
| 1451 | input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff); |
| 1452 | |
| 1453 | input_sync(pad_input); |
| 1454 | } |
| 1455 | |
| 1456 | static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom) |
| 1457 | { |
| 1458 | unsigned char *data = wacom->data; |
| 1459 | |
| 1460 | bool chg = data[284] & 0x80; |
| 1461 | int battery_status = data[284] & 0x7F; |
| 1462 | |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 1463 | wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1464 | battery_status, chg, 1, chg); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1465 | } |
| 1466 | |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1467 | static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom) |
| 1468 | { |
| 1469 | struct input_dev *pad_input = wacom->pad_input; |
| 1470 | unsigned char *data = wacom->data; |
| 1471 | |
| 1472 | int buttons = data[44]; |
| 1473 | |
| 1474 | wacom_report_numbered_buttons(pad_input, 4, buttons); |
| 1475 | |
| 1476 | input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0); |
| 1477 | input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0); |
| 1478 | input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff); |
| 1479 | |
| 1480 | input_sync(pad_input); |
| 1481 | } |
| 1482 | |
| 1483 | static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom) |
| 1484 | { |
| 1485 | unsigned char *data = wacom->data; |
| 1486 | |
| 1487 | bool chg = data[45] & 0x80; |
| 1488 | int battery_status = data[45] & 0x7F; |
| 1489 | |
| 1490 | wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 1491 | battery_status, chg, 1, chg); |
| 1492 | } |
| 1493 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1494 | static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1495 | { |
| 1496 | unsigned char *data = wacom->data; |
| 1497 | |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1498 | if (data[0] != 0x80 && data[0] != 0x81) { |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1499 | dev_dbg(wacom->pen_input->dev.parent, |
| 1500 | "%s: received unknown report #%d\n", __func__, data[0]); |
| 1501 | return 0; |
| 1502 | } |
| 1503 | |
| 1504 | wacom_intuos_pro2_bt_pen(wacom); |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 1505 | if (wacom->features.type == INTUOSP2_BT || |
| 1506 | wacom->features.type == INTUOSP2S_BT) { |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 1507 | wacom_intuos_pro2_bt_touch(wacom); |
| 1508 | wacom_intuos_pro2_bt_pad(wacom); |
| 1509 | wacom_intuos_pro2_bt_battery(wacom); |
| 1510 | } else { |
| 1511 | wacom_intuos_gen3_bt_pad(wacom); |
| 1512 | wacom_intuos_gen3_bt_battery(wacom); |
| 1513 | } |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1514 | return 0; |
| 1515 | } |
| 1516 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1517 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
| 1518 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1519 | struct input_dev *input = wacom->touch_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1520 | unsigned char *data = wacom->data; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1521 | int i; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1522 | int current_num_contacts = data[61]; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1523 | int contacts_to_send = 0; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1524 | int num_contacts_left = 4; /* maximum contacts per packet */ |
| 1525 | int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; |
| 1526 | int y_offset = 2; |
| 1527 | |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 1528 | if (wacom->shared->has_mute_touch_switch && |
| 1529 | !wacom->shared->is_touch_on) { |
| 1530 | if (!wacom->shared->touch_down) |
| 1531 | return 0; |
| 1532 | } |
| 1533 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1534 | if (wacom->features.type == WACOM_27QHDT) { |
| 1535 | current_num_contacts = data[63]; |
| 1536 | num_contacts_left = 10; |
| 1537 | byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET; |
| 1538 | y_offset = 0; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1539 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1540 | |
| 1541 | /* |
| 1542 | * First packet resets the counter since only the first |
| 1543 | * packet in series will have non-zero current_num_contacts. |
| 1544 | */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1545 | if (current_num_contacts) |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1546 | wacom->num_contacts_left = current_num_contacts; |
| 1547 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1548 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1549 | |
| 1550 | for (i = 0; i < contacts_to_send; i++) { |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1551 | int offset = (byte_per_packet * i) + 1; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1552 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 1553 | int slot = input_mt_get_slot_by_key(input, data[offset + 1]); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1554 | |
| 1555 | if (slot < 0) |
| 1556 | continue; |
| 1557 | input_mt_slot(input, slot); |
| 1558 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1559 | |
| 1560 | if (touch) { |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1561 | int t_x = get_unaligned_le16(&data[offset + 2]); |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1562 | int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1563 | |
| 1564 | input_report_abs(input, ABS_MT_POSITION_X, t_x); |
| 1565 | input_report_abs(input, ABS_MT_POSITION_Y, t_y); |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1566 | |
| 1567 | if (wacom->features.type != WACOM_27QHDT) { |
| 1568 | int c_x = get_unaligned_le16(&data[offset + 4]); |
| 1569 | int c_y = get_unaligned_le16(&data[offset + 8]); |
| 1570 | int w = get_unaligned_le16(&data[offset + 10]); |
| 1571 | int h = get_unaligned_le16(&data[offset + 12]); |
| 1572 | |
| 1573 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h)); |
| 1574 | input_report_abs(input, ABS_MT_WIDTH_MAJOR, |
| 1575 | min(w, h) + int_dist(t_x, t_y, c_x, c_y)); |
| 1576 | input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); |
| 1577 | input_report_abs(input, ABS_MT_ORIENTATION, w > h); |
| 1578 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1579 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1580 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1581 | input_mt_sync_frame(input); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1582 | |
| 1583 | wacom->num_contacts_left -= contacts_to_send; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1584 | if (wacom->num_contacts_left <= 0) { |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1585 | wacom->num_contacts_left = 0; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1586 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1587 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1588 | return 1; |
| 1589 | } |
| 1590 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1591 | static int wacom_mt_touch(struct wacom_wac *wacom) |
| 1592 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1593 | struct input_dev *input = wacom->touch_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1594 | unsigned char *data = wacom->data; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1595 | int i; |
| 1596 | int current_num_contacts = data[2]; |
| 1597 | int contacts_to_send = 0; |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1598 | int x_offset = 0; |
| 1599 | |
| 1600 | /* MTTPC does not support Height and Width */ |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 1601 | if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B) |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1602 | x_offset = -4; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1603 | |
| 1604 | /* |
| 1605 | * First packet resets the counter since only the first |
| 1606 | * packet in series will have non-zero current_num_contacts. |
| 1607 | */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1608 | if (current_num_contacts) |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1609 | wacom->num_contacts_left = current_num_contacts; |
| 1610 | |
| 1611 | /* There are at most 5 contacts per packet */ |
| 1612 | contacts_to_send = min(5, wacom->num_contacts_left); |
| 1613 | |
| 1614 | for (i = 0; i < contacts_to_send; i++) { |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1615 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1616 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1617 | int id = get_unaligned_le16(&data[offset + 1]); |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 1618 | int slot = input_mt_get_slot_by_key(input, id); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1619 | |
| 1620 | if (slot < 0) |
| 1621 | continue; |
| 1622 | |
| 1623 | input_mt_slot(input, slot); |
| 1624 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1625 | if (touch) { |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1626 | int x = get_unaligned_le16(&data[offset + x_offset + 7]); |
| 1627 | int y = get_unaligned_le16(&data[offset + x_offset + 9]); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1628 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 1629 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
| 1630 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1631 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1632 | input_mt_sync_frame(input); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1633 | |
| 1634 | wacom->num_contacts_left -= contacts_to_send; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1635 | if (wacom->num_contacts_left <= 0) { |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1636 | wacom->num_contacts_left = 0; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1637 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1638 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1639 | return 1; |
| 1640 | } |
| 1641 | |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1642 | static int wacom_tpc_mt_touch(struct wacom_wac *wacom) |
| 1643 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1644 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1645 | unsigned char *data = wacom->data; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1646 | int i; |
| 1647 | |
| 1648 | for (i = 0; i < 2; i++) { |
| 1649 | int p = data[1] & (1 << i); |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1650 | bool touch = p && report_touch_events(wacom); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1651 | |
| 1652 | input_mt_slot(input, i); |
| 1653 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1654 | if (touch) { |
| 1655 | int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff; |
| 1656 | int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff; |
| 1657 | |
| 1658 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 1659 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1660 | } |
| 1661 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1662 | input_mt_sync_frame(input); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1663 | |
| 1664 | /* keep touch state for pen event */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1665 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1666 | |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1667 | return 1; |
| 1668 | } |
| 1669 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1670 | static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1671 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1672 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1673 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1674 | bool prox = report_touch_events(wacom); |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1675 | int x = 0, y = 0; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1676 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1677 | if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG) |
| 1678 | return 0; |
| 1679 | |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1680 | if (len == WACOM_PKGLEN_TPC1FG) { |
| 1681 | prox = prox && (data[0] & 0x01); |
| 1682 | x = get_unaligned_le16(&data[1]); |
| 1683 | y = get_unaligned_le16(&data[3]); |
| 1684 | } else if (len == WACOM_PKGLEN_TPC1FG_B) { |
| 1685 | prox = prox && (data[2] & 0x01); |
| 1686 | x = get_unaligned_le16(&data[3]); |
| 1687 | y = get_unaligned_le16(&data[5]); |
| 1688 | } else { |
| 1689 | prox = prox && (data[1] & 0x01); |
| 1690 | x = le16_to_cpup((__le16 *)&data[2]); |
| 1691 | y = le16_to_cpup((__le16 *)&data[4]); |
| 1692 | } |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1693 | |
| 1694 | if (prox) { |
| 1695 | input_report_abs(input, ABS_X, x); |
| 1696 | input_report_abs(input, ABS_Y, y); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1697 | } |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1698 | input_report_key(input, BTN_TOUCH, prox); |
| 1699 | |
| 1700 | /* keep touch state for pen events */ |
| 1701 | wacom->shared->touch_down = prox; |
| 1702 | |
| 1703 | return 1; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1704 | } |
| 1705 | |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1706 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1707 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1708 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1709 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1710 | bool prox = data[1] & 0x20; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1711 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1712 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1713 | /* Going into proximity select tool */ |
| 1714 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1715 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1716 | /* keep pen state for touch events */ |
| 1717 | wacom->shared->stylus_in_proximity = prox; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1718 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1719 | /* send pen events only when touch is up or forced out |
| 1720 | * or touch arbitration is off |
| 1721 | */ |
| 1722 | if (!delay_pen_events(wacom)) { |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1723 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 1724 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
| 1725 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 1726 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Jason Gerecke | 0b335ca | 2014-07-24 13:15:31 -0700 | [diff] [blame] | 1727 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]); |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1728 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
| 1729 | input_report_key(input, wacom->tool[0], prox); |
| 1730 | return 1; |
| 1731 | } |
| 1732 | |
| 1733 | return 0; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1734 | } |
| 1735 | |
| 1736 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) |
| 1737 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1738 | unsigned char *data = wacom->data; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1739 | |
Jason Gerecke | 2ac97f0 | 2017-04-25 11:29:56 -0700 | [diff] [blame] | 1740 | if (wacom->pen_input) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1741 | dev_dbg(wacom->pen_input->dev.parent, |
| 1742 | "%s: received report #%d\n", __func__, data[0]); |
Jason Gerecke | 2ac97f0 | 2017-04-25 11:29:56 -0700 | [diff] [blame] | 1743 | |
| 1744 | if (len == WACOM_PKGLEN_PENABLED || |
| 1745 | data[0] == WACOM_REPORT_PENABLED) |
| 1746 | return wacom_tpc_pen(wacom); |
| 1747 | } |
| 1748 | else if (wacom->touch_input) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1749 | dev_dbg(wacom->touch_input->dev.parent, |
| 1750 | "%s: received report #%d\n", __func__, data[0]); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1751 | |
Jason Gerecke | 2ac97f0 | 2017-04-25 11:29:56 -0700 | [diff] [blame] | 1752 | switch (len) { |
| 1753 | case WACOM_PKGLEN_TPC1FG: |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1754 | return wacom_tpc_single_touch(wacom, len); |
| 1755 | |
Jason Gerecke | 2ac97f0 | 2017-04-25 11:29:56 -0700 | [diff] [blame] | 1756 | case WACOM_PKGLEN_TPC2FG: |
| 1757 | return wacom_tpc_mt_touch(wacom); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1758 | |
Jason Gerecke | 2ac97f0 | 2017-04-25 11:29:56 -0700 | [diff] [blame] | 1759 | default: |
| 1760 | switch (data[0]) { |
| 1761 | case WACOM_REPORT_TPC1FG: |
| 1762 | case WACOM_REPORT_TPCHID: |
| 1763 | case WACOM_REPORT_TPCST: |
| 1764 | case WACOM_REPORT_TPC1FGE: |
| 1765 | return wacom_tpc_single_touch(wacom, len); |
| 1766 | |
| 1767 | case WACOM_REPORT_TPCMT: |
| 1768 | case WACOM_REPORT_TPCMT2: |
| 1769 | return wacom_mt_touch(wacom); |
| 1770 | |
| 1771 | } |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1772 | } |
| 1773 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1774 | |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1775 | return 0; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1776 | } |
| 1777 | |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 1778 | static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage, |
| 1779 | int value, int num, int denom) |
| 1780 | { |
| 1781 | struct input_absinfo *abs = &input->absinfo[usage->code]; |
| 1782 | int range = (abs->maximum - abs->minimum + 1); |
| 1783 | |
| 1784 | value += num*range/denom; |
| 1785 | if (value > abs->maximum) |
| 1786 | value -= range; |
| 1787 | else if (value < abs->minimum) |
| 1788 | value += range; |
| 1789 | return value; |
| 1790 | } |
| 1791 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 1792 | int wacom_equivalent_usage(int usage) |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1793 | { |
| 1794 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) { |
| 1795 | int subpage = (usage & 0xFF00) << 8; |
| 1796 | int subusage = (usage & 0xFF); |
| 1797 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1798 | if (subpage == WACOM_HID_SP_PAD || |
| 1799 | subpage == WACOM_HID_SP_BUTTON || |
| 1800 | subpage == WACOM_HID_SP_DIGITIZER || |
Jason Gerecke | b5c921e | 2016-10-19 18:03:44 -0700 | [diff] [blame] | 1801 | subpage == WACOM_HID_SP_DIGITIZERINFO || |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1802 | usage == WACOM_HID_WD_SENSE || |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 1803 | usage == WACOM_HID_WD_SERIALHI || |
| 1804 | usage == WACOM_HID_WD_TOOLTYPE || |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1805 | usage == WACOM_HID_WD_DISTANCE || |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1806 | usage == WACOM_HID_WD_TOUCHSTRIP || |
| 1807 | usage == WACOM_HID_WD_TOUCHSTRIP2 || |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1808 | usage == WACOM_HID_WD_TOUCHRING || |
Aaron Armstrong Skomra | b1f466a | 2018-03-06 10:48:35 -0800 | [diff] [blame] | 1809 | usage == WACOM_HID_WD_TOUCHRINGSTATUS || |
| 1810 | usage == WACOM_HID_WD_REPORT_VALID) { |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1811 | return usage; |
| 1812 | } |
| 1813 | |
| 1814 | if (subpage == HID_UP_UNDEFINED) |
| 1815 | subpage = HID_UP_DIGITIZER; |
| 1816 | |
| 1817 | return subpage | subusage; |
| 1818 | } |
| 1819 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 1820 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) { |
| 1821 | int subpage = (usage & 0xFF00) << 8; |
| 1822 | int subusage = (usage & 0xFF); |
| 1823 | |
Aaron Armstrong Skomra | f4e11d5 | 2019-06-12 14:19:30 -0700 | [diff] [blame] | 1824 | if (usage == WACOM_HID_WT_REPORT_VALID) |
| 1825 | return usage; |
| 1826 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 1827 | if (subpage == HID_UP_UNDEFINED) |
| 1828 | subpage = WACOM_HID_SP_DIGITIZER; |
| 1829 | |
| 1830 | return subpage | subusage; |
| 1831 | } |
| 1832 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1833 | return usage; |
| 1834 | } |
| 1835 | |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1836 | static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1837 | struct hid_field *field, __u8 type, __u16 code, int fuzz) |
| 1838 | { |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 1839 | struct wacom *wacom = input_get_drvdata(input); |
| 1840 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1841 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1842 | int fmin = field->logical_minimum; |
| 1843 | int fmax = field->logical_maximum; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1844 | unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1845 | int resolution_code = code; |
| 1846 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1847 | if (equivalent_usage == HID_DG_TWIST) { |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1848 | resolution_code = ABS_RZ; |
| 1849 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1850 | |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 1851 | if (equivalent_usage == HID_GD_X) { |
| 1852 | fmin += features->offset_left; |
| 1853 | fmax -= features->offset_right; |
| 1854 | } |
| 1855 | if (equivalent_usage == HID_GD_Y) { |
| 1856 | fmin += features->offset_top; |
| 1857 | fmax -= features->offset_bottom; |
| 1858 | } |
| 1859 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1860 | usage->type = type; |
| 1861 | usage->code = code; |
| 1862 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1863 | switch (type) { |
| 1864 | case EV_ABS: |
| 1865 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); |
| 1866 | input_abs_set_res(input, code, |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1867 | hidinput_calc_abs_res(field, resolution_code)); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1868 | break; |
| 1869 | case EV_KEY: |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1870 | case EV_MSC: |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1871 | case EV_SW: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 1872 | input_set_capability(input, type, code); |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1873 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1874 | } |
| 1875 | } |
| 1876 | |
Jason Gerecke | 5ac3d4a | 2017-04-28 09:25:34 -0700 | [diff] [blame] | 1877 | static void wacom_wac_battery_usage_mapping(struct hid_device *hdev, |
| 1878 | struct hid_field *field, struct hid_usage *usage) |
| 1879 | { |
| 1880 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1881 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1882 | struct wacom_features *features = &wacom_wac->features; |
| 1883 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1884 | |
| 1885 | switch (equivalent_usage) { |
| 1886 | case HID_DG_BATTERYSTRENGTH: |
| 1887 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1888 | case WACOM_HID_WD_BATTERY_CHARGING: |
| 1889 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 1890 | break; |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field, |
| 1895 | struct hid_usage *usage, __s32 value) |
| 1896 | { |
| 1897 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1898 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1899 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1900 | |
| 1901 | switch (equivalent_usage) { |
| 1902 | case HID_DG_BATTERYSTRENGTH: |
| 1903 | if (value == 0) { |
| 1904 | wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN; |
| 1905 | } |
| 1906 | else { |
| 1907 | value = value * 100 / (field->logical_maximum - field->logical_minimum); |
| 1908 | wacom_wac->hid_data.battery_capacity = value; |
| 1909 | wacom_wac->hid_data.bat_connected = 1; |
| 1910 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1911 | } |
| 1912 | break; |
| 1913 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1914 | value = value * 100 / (field->logical_maximum - field->logical_minimum); |
| 1915 | wacom_wac->hid_data.battery_capacity = value; |
| 1916 | wacom_wac->hid_data.bat_connected = 1; |
| 1917 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1918 | break; |
| 1919 | case WACOM_HID_WD_BATTERY_CHARGING: |
| 1920 | wacom_wac->hid_data.bat_charging = value; |
| 1921 | wacom_wac->hid_data.ps_connected = value; |
| 1922 | wacom_wac->hid_data.bat_connected = 1; |
| 1923 | wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO; |
| 1924 | break; |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | static void wacom_wac_battery_pre_report(struct hid_device *hdev, |
| 1929 | struct hid_report *report) |
| 1930 | { |
| 1931 | return; |
| 1932 | } |
| 1933 | |
| 1934 | static void wacom_wac_battery_report(struct hid_device *hdev, |
| 1935 | struct hid_report *report) |
| 1936 | { |
| 1937 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1938 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1939 | struct wacom_features *features = &wacom_wac->features; |
| 1940 | |
| 1941 | if (features->quirks & WACOM_QUIRK_BATTERY) { |
| 1942 | int status = wacom_wac->hid_data.bat_status; |
| 1943 | int capacity = wacom_wac->hid_data.battery_capacity; |
| 1944 | bool charging = wacom_wac->hid_data.bat_charging; |
| 1945 | bool connected = wacom_wac->hid_data.bat_connected; |
| 1946 | bool powered = wacom_wac->hid_data.ps_connected; |
| 1947 | |
| 1948 | wacom_notify_battery(wacom_wac, status, capacity, charging, |
| 1949 | connected, powered); |
| 1950 | } |
| 1951 | } |
| 1952 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1953 | static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, |
| 1954 | struct hid_field *field, struct hid_usage *usage) |
| 1955 | { |
| 1956 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1957 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1958 | struct wacom_features *features = &wacom_wac->features; |
| 1959 | struct input_dev *input = wacom_wac->pad_input; |
| 1960 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1961 | |
| 1962 | switch (equivalent_usage) { |
| 1963 | case WACOM_HID_WD_ACCELEROMETER_X: |
| 1964 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1965 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1966 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1967 | break; |
| 1968 | case WACOM_HID_WD_ACCELEROMETER_Y: |
| 1969 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1970 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1971 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1972 | break; |
| 1973 | case WACOM_HID_WD_ACCELEROMETER_Z: |
| 1974 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1975 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1976 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1977 | break; |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 1978 | case WACOM_HID_WD_BUTTONCENTER: |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1979 | case WACOM_HID_WD_BUTTONHOME: |
| 1980 | case WACOM_HID_WD_BUTTONUP: |
| 1981 | case WACOM_HID_WD_BUTTONDOWN: |
| 1982 | case WACOM_HID_WD_BUTTONLEFT: |
| 1983 | case WACOM_HID_WD_BUTTONRIGHT: |
| 1984 | wacom_map_usage(input, usage, field, EV_KEY, |
| 1985 | wacom_numbered_button_to_key(features->numbered_buttons), |
| 1986 | 0); |
| 1987 | features->numbered_buttons++; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1988 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1989 | break; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1990 | case WACOM_HID_WD_TOUCHONOFF: |
Ping Cheng | d793ff8 | 2017-02-14 21:27:45 -0800 | [diff] [blame] | 1991 | case WACOM_HID_WD_MUTE_DEVICE: |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 1992 | /* |
| 1993 | * This usage, which is used to mute touch events, comes |
| 1994 | * from the pad packet, but is reported on the touch |
| 1995 | * interface. Because the touch interface may not have |
| 1996 | * been created yet, we cannot call wacom_map_usage(). In |
| 1997 | * order to process this usage when we receive it, we set |
| 1998 | * the usage type and code directly. |
| 1999 | */ |
| 2000 | wacom_wac->has_mute_touch_switch = true; |
| 2001 | usage->type = EV_SW; |
| 2002 | usage->code = SW_MUTE_DEVICE; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 2003 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 2004 | break; |
| 2005 | case WACOM_HID_WD_TOUCHSTRIP: |
| 2006 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 2007 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 2008 | break; |
| 2009 | case WACOM_HID_WD_TOUCHSTRIP2: |
| 2010 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 2011 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 2012 | break; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2013 | case WACOM_HID_WD_TOUCHRING: |
| 2014 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 2015 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2016 | break; |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2017 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
Jason Gerecke | 8d411cb | 2017-08-04 15:35:14 -0700 | [diff] [blame] | 2018 | /* |
| 2019 | * Only set up type/code association. Completely mapping |
| 2020 | * this usage may overwrite the axis resolution and range. |
| 2021 | */ |
| 2022 | usage->type = EV_ABS; |
| 2023 | usage->code = ABS_WHEEL; |
| 2024 | set_bit(EV_ABS, input->evbit); |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2025 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2026 | break; |
Ping Cheng | 4eb220c | 2017-02-14 21:26:21 -0800 | [diff] [blame] | 2027 | case WACOM_HID_WD_BUTTONCONFIG: |
| 2028 | wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0); |
| 2029 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2030 | break; |
| 2031 | case WACOM_HID_WD_ONSCREEN_KEYBOARD: |
| 2032 | wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0); |
| 2033 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2034 | break; |
| 2035 | case WACOM_HID_WD_CONTROLPANEL: |
| 2036 | wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0); |
| 2037 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2038 | break; |
Benjamin Tissoires | 4082da8 | 2017-02-14 21:27:18 -0800 | [diff] [blame] | 2039 | case WACOM_HID_WD_MODE_CHANGE: |
| 2040 | /* do not overwrite previous data */ |
| 2041 | if (!wacom_wac->has_mode_change) { |
| 2042 | wacom_wac->has_mode_change = true; |
| 2043 | wacom_wac->is_direct_mode = true; |
| 2044 | } |
| 2045 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 2046 | break; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2047 | } |
| 2048 | |
| 2049 | switch (equivalent_usage & 0xfffffff0) { |
| 2050 | case WACOM_HID_WD_EXPRESSKEY00: |
| 2051 | wacom_map_usage(input, usage, field, EV_KEY, |
| 2052 | wacom_numbered_button_to_key(features->numbered_buttons), |
| 2053 | 0); |
| 2054 | features->numbered_buttons++; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 2055 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2056 | break; |
| 2057 | } |
| 2058 | } |
| 2059 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2060 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, |
| 2061 | struct hid_usage *usage, __s32 value) |
| 2062 | { |
| 2063 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2064 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2065 | struct input_dev *input = wacom_wac->pad_input; |
| 2066 | struct wacom_features *features = &wacom_wac->features; |
| 2067 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 2068 | int i; |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2069 | bool do_report = false; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2070 | |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2071 | /* |
| 2072 | * Avoid reporting this event and setting inrange_state if this usage |
| 2073 | * hasn't been mapped. |
| 2074 | */ |
Benjamin Tissoires | 4082da8 | 2017-02-14 21:27:18 -0800 | [diff] [blame] | 2075 | if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE) |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2076 | return; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2077 | |
| 2078 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2079 | if (usage->hid != WACOM_HID_WD_TOUCHRING) |
| 2080 | wacom_wac->hid_data.inrange_state |= value; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2081 | } |
| 2082 | |
| 2083 | switch (equivalent_usage) { |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2084 | case WACOM_HID_WD_TOUCHRING: |
| 2085 | /* |
| 2086 | * Userspace expects touchrings to increase in value with |
| 2087 | * clockwise gestures and have their zero point at the |
| 2088 | * tablet's left. HID events "should" be clockwise- |
| 2089 | * increasing and zero at top, though the MobileStudio |
| 2090 | * Pro and 2nd-gen Intuos Pro don't do this... |
| 2091 | */ |
| 2092 | if (hdev->vendor == 0x56a && |
| 2093 | (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */ |
Ping Cheng | 384225c | 2019-06-23 16:52:43 -0700 | [diff] [blame] | 2094 | hdev->product == 0x357 || hdev->product == 0x358 || /* Intuos Pro 2 */ |
Aaron Armstrong Skomra | 6e2abc6 | 2019-06-26 15:48:48 -0700 | [diff] [blame] | 2095 | hdev->product == 0x392 || /* Intuos Pro 2 */ |
Jason Gerecke | fe4e940 | 2019-12-16 10:18:57 -0800 | [diff] [blame] | 2096 | hdev->product == 0x398 || hdev->product == 0x399 || /* MobileStudio Pro */ |
| 2097 | hdev->product == 0x3AA)) { /* MobileStudio Pro */ |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2098 | value = (field->logical_maximum - value); |
| 2099 | |
Aaron Armstrong Skomra | 6e2abc6 | 2019-06-26 15:48:48 -0700 | [diff] [blame] | 2100 | if (hdev->product == 0x357 || hdev->product == 0x358 || |
| 2101 | hdev->product == 0x392) |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2102 | value = wacom_offset_rotation(input, usage, value, 3, 16); |
Ping Cheng | 384225c | 2019-06-23 16:52:43 -0700 | [diff] [blame] | 2103 | else if (hdev->product == 0x34d || hdev->product == 0x34e || |
Jason Gerecke | fe4e940 | 2019-12-16 10:18:57 -0800 | [diff] [blame] | 2104 | hdev->product == 0x398 || hdev->product == 0x399 || |
| 2105 | hdev->product == 0x3AA) |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2106 | value = wacom_offset_rotation(input, usage, value, 1, 2); |
| 2107 | } |
| 2108 | else { |
| 2109 | value = wacom_offset_rotation(input, usage, value, 1, 4); |
| 2110 | } |
| 2111 | do_report = true; |
| 2112 | break; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 2113 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2114 | if (!value) |
| 2115 | input_event(input, usage->type, usage->code, 0); |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2116 | break; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 2117 | |
Ping Cheng | d793ff8 | 2017-02-14 21:27:45 -0800 | [diff] [blame] | 2118 | case WACOM_HID_WD_MUTE_DEVICE: |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 2119 | case WACOM_HID_WD_TOUCHONOFF: |
| 2120 | if (wacom_wac->shared->touch_input) { |
Jason Gerecke | 403c0f6 | 2017-12-26 14:53:55 -0800 | [diff] [blame] | 2121 | bool *is_touch_on = &wacom_wac->shared->is_touch_on; |
| 2122 | |
| 2123 | if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) |
| 2124 | *is_touch_on = !(*is_touch_on); |
| 2125 | else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) |
| 2126 | *is_touch_on = value; |
| 2127 | |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 2128 | input_report_switch(wacom_wac->shared->touch_input, |
Jason Gerecke | 403c0f6 | 2017-12-26 14:53:55 -0800 | [diff] [blame] | 2129 | SW_MUTE_DEVICE, !(*is_touch_on)); |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 2130 | input_sync(wacom_wac->shared->touch_input); |
| 2131 | } |
| 2132 | break; |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 2133 | |
Benjamin Tissoires | 4082da8 | 2017-02-14 21:27:18 -0800 | [diff] [blame] | 2134 | case WACOM_HID_WD_MODE_CHANGE: |
| 2135 | if (wacom_wac->is_direct_mode != value) { |
| 2136 | wacom_wac->is_direct_mode = value; |
| 2137 | wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE); |
| 2138 | } |
| 2139 | break; |
| 2140 | |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 2141 | case WACOM_HID_WD_BUTTONCENTER: |
| 2142 | for (i = 0; i < wacom->led.count; i++) |
| 2143 | wacom_update_led(wacom, features->numbered_buttons, |
| 2144 | value, i); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 2145 | fallthrough; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 2146 | default: |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2147 | do_report = true; |
| 2148 | break; |
| 2149 | } |
| 2150 | |
| 2151 | if (do_report) { |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2152 | input_event(input, usage->type, usage->code, value); |
Ping Cheng | ed1fa73 | 2017-04-04 12:31:07 -0700 | [diff] [blame] | 2153 | if (value) |
| 2154 | wacom_wac->hid_data.pad_input_event_flag = true; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 2155 | } |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2156 | } |
| 2157 | |
| 2158 | static void wacom_wac_pad_pre_report(struct hid_device *hdev, |
| 2159 | struct hid_report *report) |
| 2160 | { |
| 2161 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2162 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2163 | |
| 2164 | wacom_wac->hid_data.inrange_state = 0; |
| 2165 | } |
| 2166 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2167 | static void wacom_wac_pad_report(struct hid_device *hdev, |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2168 | struct hid_report *report, struct hid_field *field) |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2169 | { |
| 2170 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2171 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2172 | struct input_dev *input = wacom_wac->pad_input; |
| 2173 | bool active = wacom_wac->hid_data.inrange_state != 0; |
| 2174 | |
| 2175 | /* report prox for expresskey events */ |
Aaron Armstrong Skomra | d4b8efe | 2019-05-10 15:34:17 -0700 | [diff] [blame] | 2176 | if (wacom_wac->hid_data.pad_input_event_flag) { |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2177 | input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2178 | input_sync(input); |
Ping Cheng | ed1fa73 | 2017-04-04 12:31:07 -0700 | [diff] [blame] | 2179 | if (!active) |
| 2180 | wacom_wac->hid_data.pad_input_event_flag = false; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2181 | } |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2182 | } |
| 2183 | |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2184 | static void wacom_set_barrel_switch3_usage(struct wacom_wac *wacom_wac) |
| 2185 | { |
| 2186 | struct input_dev *input = wacom_wac->pen_input; |
| 2187 | struct wacom_features *features = &wacom_wac->features; |
| 2188 | |
| 2189 | if (!(features->quirks & WACOM_QUIRK_AESPEN) && |
| 2190 | wacom_wac->hid_data.barrelswitch && |
| 2191 | wacom_wac->hid_data.barrelswitch2 && |
| 2192 | wacom_wac->hid_data.serialhi) |
| 2193 | input_set_capability(input, EV_KEY, BTN_STYLUS3); |
| 2194 | } |
| 2195 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2196 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, |
| 2197 | struct hid_field *field, struct hid_usage *usage) |
| 2198 | { |
| 2199 | struct wacom *wacom = hid_get_drvdata(hdev); |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2200 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2201 | struct wacom_features *features = &wacom_wac->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2202 | struct input_dev *input = wacom_wac->pen_input; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2203 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2204 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2205 | switch (equivalent_usage) { |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2206 | case HID_GD_X: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2207 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2208 | break; |
| 2209 | case HID_GD_Y: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2210 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2211 | break; |
Jason Gerecke | b5c921e | 2016-10-19 18:03:44 -0700 | [diff] [blame] | 2212 | case WACOM_HID_WD_DISTANCE: |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 2213 | case HID_GD_Z: |
| 2214 | wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0); |
| 2215 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2216 | case HID_DG_TIPPRESSURE: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2217 | wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2218 | break; |
| 2219 | case HID_DG_INRANGE: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2220 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2221 | break; |
| 2222 | case HID_DG_INVERT: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2223 | wacom_map_usage(input, usage, field, EV_KEY, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2224 | BTN_TOOL_RUBBER, 0); |
| 2225 | break; |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 2226 | case HID_DG_TILT_X: |
| 2227 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0); |
| 2228 | break; |
| 2229 | case HID_DG_TILT_Y: |
| 2230 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0); |
| 2231 | break; |
| 2232 | case HID_DG_TWIST: |
| 2233 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); |
| 2234 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2235 | case HID_DG_ERASER: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2236 | input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER); |
| 2237 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
| 2238 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2239 | case HID_DG_TIPSWITCH: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2240 | input_set_capability(input, EV_KEY, BTN_TOOL_PEN); |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2241 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2242 | break; |
| 2243 | case HID_DG_BARRELSWITCH: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2244 | wacom_wac->hid_data.barrelswitch = true; |
| 2245 | wacom_set_barrel_switch3_usage(wacom_wac); |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2246 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2247 | break; |
| 2248 | case HID_DG_BARRELSWITCH2: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2249 | wacom_wac->hid_data.barrelswitch2 = true; |
| 2250 | wacom_set_barrel_switch3_usage(wacom_wac); |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2251 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2252 | break; |
| 2253 | case HID_DG_TOOLSERIALNUMBER: |
Jason Gerecke | 8341720 | 2017-11-10 11:50:01 -0800 | [diff] [blame] | 2254 | features->quirks |= WACOM_QUIRK_TOOLSERIAL; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2255 | wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2256 | break; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2257 | case WACOM_HID_WD_SENSE: |
| 2258 | features->quirks |= WACOM_QUIRK_SENSE; |
| 2259 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); |
| 2260 | break; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2261 | case WACOM_HID_WD_SERIALHI: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2262 | wacom_wac->hid_data.serialhi = true; |
| 2263 | wacom_set_barrel_switch3_usage(wacom_wac); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2264 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2265 | break; |
Jason Gerecke | 929d6d5 | 2016-10-19 18:03:45 -0700 | [diff] [blame] | 2266 | case WACOM_HID_WD_FINGERWHEEL: |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 2267 | input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH); |
Jason Gerecke | 929d6d5 | 2016-10-19 18:03:45 -0700 | [diff] [blame] | 2268 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); |
| 2269 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2270 | } |
| 2271 | } |
| 2272 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2273 | static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2274 | struct hid_usage *usage, __s32 value) |
| 2275 | { |
| 2276 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2277 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2278 | struct wacom_features *features = &wacom_wac->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2279 | struct input_dev *input = wacom_wac->pen_input; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2280 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2281 | |
Aaron Armstrong Skomra | b1f466a | 2018-03-06 10:48:35 -0800 | [diff] [blame] | 2282 | if (wacom_wac->is_invalid_bt_frame) |
| 2283 | return; |
| 2284 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2285 | switch (equivalent_usage) { |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 2286 | case HID_GD_Z: |
| 2287 | /* |
| 2288 | * HID_GD_Z "should increase as the control's position is |
| 2289 | * moved from high to low", while ABS_DISTANCE instead |
| 2290 | * increases in value as the tool moves from low to high. |
| 2291 | */ |
| 2292 | value = field->logical_maximum - value; |
| 2293 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2294 | case HID_DG_INRANGE: |
| 2295 | wacom_wac->hid_data.inrange_state = value; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2296 | if (!(features->quirks & WACOM_QUIRK_SENSE)) |
| 2297 | wacom_wac->hid_data.sense_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2298 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2299 | case HID_DG_INVERT: |
| 2300 | wacom_wac->hid_data.invert_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2301 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2302 | case HID_DG_ERASER: |
| 2303 | case HID_DG_TIPSWITCH: |
| 2304 | wacom_wac->hid_data.tipswitch |= value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2305 | return; |
Jason Gerecke | 9e429d5 | 2017-11-07 08:25:17 -0800 | [diff] [blame] | 2306 | case HID_DG_BARRELSWITCH: |
| 2307 | wacom_wac->hid_data.barrelswitch = value; |
| 2308 | return; |
| 2309 | case HID_DG_BARRELSWITCH2: |
| 2310 | wacom_wac->hid_data.barrelswitch2 = value; |
| 2311 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2312 | case HID_DG_TOOLSERIALNUMBER: |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2313 | if (value) { |
| 2314 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
Jason Gerecke | ff479731 | 2019-11-06 11:59:46 -0800 | [diff] [blame] | 2315 | wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size); |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2316 | } |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2317 | return; |
Jason Gerecke | d252f4a | 2017-08-30 15:13:26 -0700 | [diff] [blame] | 2318 | case HID_DG_TWIST: |
| 2319 | /* |
| 2320 | * Userspace expects pen twist to have its zero point when |
| 2321 | * the buttons/finger is on the tablet's left. HID values |
| 2322 | * are zero when buttons are toward the top. |
| 2323 | */ |
| 2324 | value = wacom_offset_rotation(input, usage, value, 1, 4); |
| 2325 | break; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2326 | case WACOM_HID_WD_SENSE: |
| 2327 | wacom_wac->hid_data.sense_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2328 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2329 | case WACOM_HID_WD_SERIALHI: |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2330 | if (value) { |
Jason Gerecke | ff479731 | 2019-11-06 11:59:46 -0800 | [diff] [blame] | 2331 | __u32 raw_value = wacom_s32tou(value, field->report_size); |
| 2332 | |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2333 | wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); |
Jason Gerecke | ff479731 | 2019-11-06 11:59:46 -0800 | [diff] [blame] | 2334 | wacom_wac->serial[0] |= ((__u64)raw_value) << 32; |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2335 | /* |
| 2336 | * Non-USI EMR devices may contain additional tool type |
| 2337 | * information here. See WACOM_HID_WD_TOOLTYPE case for |
| 2338 | * more details. |
| 2339 | */ |
| 2340 | if (value >> 20 == 1) { |
Jason Gerecke | ff479731 | 2019-11-06 11:59:46 -0800 | [diff] [blame] | 2341 | wacom_wac->id[0] |= raw_value & 0xFFFFF; |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2342 | } |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2343 | } |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2344 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2345 | case WACOM_HID_WD_TOOLTYPE: |
| 2346 | /* |
| 2347 | * Some devices (MobileStudio Pro, and possibly later |
| 2348 | * devices as well) do not return the complete tool |
| 2349 | * type in their WACOM_HID_WD_TOOLTYPE usage. Use a |
| 2350 | * bitwise OR so the complete value can be built |
| 2351 | * up over time :( |
| 2352 | */ |
Jason Gerecke | ff479731 | 2019-11-06 11:59:46 -0800 | [diff] [blame] | 2353 | wacom_wac->id[0] |= wacom_s32tou(value, field->report_size); |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2354 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2355 | case WACOM_HID_WD_OFFSETLEFT: |
| 2356 | if (features->offset_left && value != features->offset_left) |
Colin Ian King | 75a5f3a | 2017-06-26 20:35:38 +0100 | [diff] [blame] | 2357 | hid_warn(hdev, "%s: overriding existing left offset " |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2358 | "%d -> %d\n", __func__, value, |
| 2359 | features->offset_left); |
| 2360 | features->offset_left = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2361 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2362 | case WACOM_HID_WD_OFFSETRIGHT: |
| 2363 | if (features->offset_right && value != features->offset_right) |
Colin Ian King | 75a5f3a | 2017-06-26 20:35:38 +0100 | [diff] [blame] | 2364 | hid_warn(hdev, "%s: overriding existing right offset " |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2365 | "%d -> %d\n", __func__, value, |
| 2366 | features->offset_right); |
| 2367 | features->offset_right = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2368 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2369 | case WACOM_HID_WD_OFFSETTOP: |
| 2370 | if (features->offset_top && value != features->offset_top) |
Colin Ian King | 75a5f3a | 2017-06-26 20:35:38 +0100 | [diff] [blame] | 2371 | hid_warn(hdev, "%s: overriding existing top offset " |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2372 | "%d -> %d\n", __func__, value, |
| 2373 | features->offset_top); |
| 2374 | features->offset_top = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2375 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2376 | case WACOM_HID_WD_OFFSETBOTTOM: |
| 2377 | if (features->offset_bottom && value != features->offset_bottom) |
Colin Ian King | 75a5f3a | 2017-06-26 20:35:38 +0100 | [diff] [blame] | 2378 | hid_warn(hdev, "%s: overriding existing bottom offset " |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2379 | "%d -> %d\n", __func__, value, |
| 2380 | features->offset_bottom); |
| 2381 | features->offset_bottom = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2382 | return; |
Aaron Armstrong Skomra | b1f466a | 2018-03-06 10:48:35 -0800 | [diff] [blame] | 2383 | case WACOM_HID_WD_REPORT_VALID: |
| 2384 | wacom_wac->is_invalid_bt_frame = !value; |
| 2385 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2386 | } |
| 2387 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2388 | /* send pen events only when touch is up or forced out |
| 2389 | * or touch arbitration is off |
| 2390 | */ |
| 2391 | if (!usage->type || delay_pen_events(wacom_wac)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2392 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2393 | |
Jason Gerecke | 4affc23 | 2017-09-07 17:49:50 -0700 | [diff] [blame] | 2394 | /* send pen events only when the pen is in range */ |
Jason Gerecke | 5b40104 | 2017-09-07 17:52:15 -0700 | [diff] [blame] | 2395 | if (wacom_wac->hid_data.inrange_state) |
| 2396 | input_event(input, usage->type, usage->code, value); |
| 2397 | else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state) |
| 2398 | input_event(input, usage->type, usage->code, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2399 | } |
| 2400 | |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2401 | static void wacom_wac_pen_pre_report(struct hid_device *hdev, |
| 2402 | struct hid_report *report) |
| 2403 | { |
Aaron Armstrong Skomra | b1f466a | 2018-03-06 10:48:35 -0800 | [diff] [blame] | 2404 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2405 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2406 | |
| 2407 | wacom_wac->is_invalid_bt_frame = false; |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2408 | return; |
| 2409 | } |
| 2410 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2411 | static void wacom_wac_pen_report(struct hid_device *hdev, |
| 2412 | struct hid_report *report) |
| 2413 | { |
| 2414 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2415 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2416 | struct input_dev *input = wacom_wac->pen_input; |
Jason Gerecke | 7690dd1 | 2017-09-07 17:48:55 -0700 | [diff] [blame] | 2417 | bool range = wacom_wac->hid_data.inrange_state; |
| 2418 | bool sense = wacom_wac->hid_data.sense_state; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2419 | |
Aaron Armstrong Skomra | b1f466a | 2018-03-06 10:48:35 -0800 | [diff] [blame] | 2420 | if (wacom_wac->is_invalid_bt_frame) |
| 2421 | return; |
| 2422 | |
Jason Gerecke | 7690dd1 | 2017-09-07 17:48:55 -0700 | [diff] [blame] | 2423 | if (!wacom_wac->tool[0] && range) { /* first in range */ |
| 2424 | /* Going into range select tool */ |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2425 | if (wacom_wac->hid_data.invert_state) |
| 2426 | wacom_wac->tool[0] = BTN_TOOL_RUBBER; |
| 2427 | else if (wacom_wac->id[0]) |
| 2428 | wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); |
| 2429 | else |
| 2430 | wacom_wac->tool[0] = BTN_TOOL_PEN; |
| 2431 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2432 | |
| 2433 | /* keep pen state for touch events */ |
Jason Gerecke | 7690dd1 | 2017-09-07 17:48:55 -0700 | [diff] [blame] | 2434 | wacom_wac->shared->stylus_in_proximity = sense; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2435 | |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2436 | if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2437 | int id = wacom_wac->id[0]; |
Jason Gerecke | 9e429d5 | 2017-11-07 08:25:17 -0800 | [diff] [blame] | 2438 | int sw_state = wacom_wac->hid_data.barrelswitch | |
| 2439 | (wacom_wac->hid_data.barrelswitch2 << 1); |
| 2440 | |
| 2441 | input_report_key(input, BTN_STYLUS, sw_state == 1); |
| 2442 | input_report_key(input, BTN_STYLUS2, sw_state == 2); |
| 2443 | input_report_key(input, BTN_STYLUS3, sw_state == 3); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2444 | |
| 2445 | /* |
| 2446 | * Non-USI EMR tools should have their IDs mangled to |
| 2447 | * match the legacy behavior of wacom_intuos_general |
| 2448 | */ |
| 2449 | if (wacom_wac->serial[0] >> 52 == 1) |
| 2450 | id = wacom_intuos_id_mangle(id); |
| 2451 | |
| 2452 | /* |
| 2453 | * To ensure compatibility with xf86-input-wacom, we should |
| 2454 | * report the BTN_TOOL_* event prior to the ABS_MISC or |
| 2455 | * MSC_SERIAL events. |
| 2456 | */ |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2457 | input_report_key(input, BTN_TOUCH, |
| 2458 | wacom_wac->hid_data.tipswitch); |
Jason Gerecke | 4affc23 | 2017-09-07 17:49:50 -0700 | [diff] [blame] | 2459 | input_report_key(input, wacom_wac->tool[0], sense); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2460 | if (wacom_wac->serial[0]) { |
| 2461 | input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]); |
Jason Gerecke | 4affc23 | 2017-09-07 17:49:50 -0700 | [diff] [blame] | 2462 | input_report_abs(input, ABS_MISC, sense ? id : 0); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2463 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2464 | |
| 2465 | wacom_wac->hid_data.tipswitch = false; |
| 2466 | |
| 2467 | input_sync(input); |
| 2468 | } |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2469 | |
Jason Gerecke | 4affc23 | 2017-09-07 17:49:50 -0700 | [diff] [blame] | 2470 | if (!sense) { |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2471 | wacom_wac->tool[0] = 0; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2472 | wacom_wac->id[0] = 0; |
Jason Gerecke | 993f0d9 | 2017-09-07 17:44:12 -0700 | [diff] [blame] | 2473 | wacom_wac->serial[0] = 0; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2474 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2475 | } |
| 2476 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2477 | static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, |
| 2478 | struct hid_field *field, struct hid_usage *usage) |
| 2479 | { |
| 2480 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2481 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2482 | struct input_dev *input = wacom_wac->touch_input; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2483 | unsigned touch_max = wacom_wac->features.touch_max; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2484 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2485 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2486 | switch (equivalent_usage) { |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2487 | case HID_GD_X: |
| 2488 | if (touch_max == 1) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2489 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2490 | else |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2491 | wacom_map_usage(input, usage, field, EV_ABS, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2492 | ABS_MT_POSITION_X, 4); |
| 2493 | break; |
| 2494 | case HID_GD_Y: |
| 2495 | if (touch_max == 1) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2496 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2497 | else |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2498 | wacom_map_usage(input, usage, field, EV_ABS, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2499 | ABS_MT_POSITION_Y, 4); |
| 2500 | break; |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2501 | case HID_DG_WIDTH: |
| 2502 | case HID_DG_HEIGHT: |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2503 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0); |
| 2504 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0); |
| 2505 | input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0); |
| 2506 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2507 | case HID_DG_TIPSWITCH: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2508 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2509 | break; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2510 | case HID_DG_CONTACTCOUNT: |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2511 | wacom_wac->hid_data.cc_report = field->report->id; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2512 | wacom_wac->hid_data.cc_index = field->index; |
| 2513 | wacom_wac->hid_data.cc_value_index = usage->usage_index; |
| 2514 | break; |
Jason Gerecke | 6f107fa | 2017-04-19 14:47:24 -0700 | [diff] [blame] | 2515 | case HID_DG_CONTACTID: |
| 2516 | if ((field->logical_maximum - field->logical_minimum) < touch_max) { |
| 2517 | /* |
| 2518 | * The HID descriptor for G11 sensors leaves logical |
| 2519 | * maximum set to '1' despite it being a multitouch |
| 2520 | * device. Override to a sensible number. |
| 2521 | */ |
| 2522 | field->logical_maximum = 255; |
| 2523 | } |
| 2524 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2525 | } |
| 2526 | } |
| 2527 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2528 | static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, |
| 2529 | struct input_dev *input) |
| 2530 | { |
| 2531 | struct hid_data *hid_data = &wacom_wac->hid_data; |
| 2532 | bool mt = wacom_wac->features.touch_max > 1; |
| 2533 | bool prox = hid_data->tipswitch && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2534 | report_touch_events(wacom_wac); |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2535 | |
Ping Cheng | d793ff8 | 2017-02-14 21:27:45 -0800 | [diff] [blame] | 2536 | if (wacom_wac->shared->has_mute_touch_switch && |
| 2537 | !wacom_wac->shared->is_touch_on) { |
| 2538 | if (!wacom_wac->shared->touch_down) |
| 2539 | return; |
Jiapeng Zhong | e29c62f | 2021-01-20 15:34:30 +0800 | [diff] [blame] | 2540 | prox = false; |
Ping Cheng | d793ff8 | 2017-02-14 21:27:45 -0800 | [diff] [blame] | 2541 | } |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2542 | |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2543 | wacom_wac->hid_data.num_received++; |
| 2544 | if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) |
| 2545 | return; |
| 2546 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2547 | if (mt) { |
| 2548 | int slot; |
| 2549 | |
| 2550 | slot = input_mt_get_slot_by_key(input, hid_data->id); |
| 2551 | input_mt_slot(input, slot); |
| 2552 | input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); |
| 2553 | } |
| 2554 | else { |
| 2555 | input_report_key(input, BTN_TOUCH, prox); |
| 2556 | } |
| 2557 | |
| 2558 | if (prox) { |
| 2559 | input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X, |
| 2560 | hid_data->x); |
| 2561 | input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y, |
| 2562 | hid_data->y); |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2563 | |
| 2564 | if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { |
| 2565 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); |
| 2566 | input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); |
| 2567 | if (hid_data->width != hid_data->height) |
| 2568 | input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1); |
| 2569 | } |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2570 | } |
| 2571 | } |
| 2572 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2573 | static void wacom_wac_finger_event(struct hid_device *hdev, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2574 | struct hid_field *field, struct hid_usage *usage, __s32 value) |
| 2575 | { |
| 2576 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2577 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2578 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Aaron Armstrong Skomra | 184eccd | 2019-06-12 14:19:29 -0700 | [diff] [blame] | 2579 | struct wacom_features *features = &wacom->wacom_wac.features; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2580 | |
Aaron Armstrong Skomra | f4e11d5 | 2019-06-12 14:19:30 -0700 | [diff] [blame] | 2581 | if (wacom_wac->is_invalid_bt_frame) |
| 2582 | return; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2583 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2584 | switch (equivalent_usage) { |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2585 | case HID_GD_X: |
| 2586 | wacom_wac->hid_data.x = value; |
| 2587 | break; |
| 2588 | case HID_GD_Y: |
| 2589 | wacom_wac->hid_data.y = value; |
| 2590 | break; |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2591 | case HID_DG_WIDTH: |
| 2592 | wacom_wac->hid_data.width = value; |
| 2593 | break; |
| 2594 | case HID_DG_HEIGHT: |
| 2595 | wacom_wac->hid_data.height = value; |
| 2596 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2597 | case HID_DG_CONTACTID: |
| 2598 | wacom_wac->hid_data.id = value; |
| 2599 | break; |
| 2600 | case HID_DG_TIPSWITCH: |
| 2601 | wacom_wac->hid_data.tipswitch = value; |
| 2602 | break; |
Aaron Armstrong Skomra | f4e11d5 | 2019-06-12 14:19:30 -0700 | [diff] [blame] | 2603 | case WACOM_HID_WT_REPORT_VALID: |
| 2604 | wacom_wac->is_invalid_bt_frame = !value; |
| 2605 | return; |
Aaron Armstrong Skomra | 184eccd | 2019-06-12 14:19:29 -0700 | [diff] [blame] | 2606 | case HID_DG_CONTACTMAX: |
Jason Gerecke | 88f3884 | 2021-02-16 11:41:54 -0800 | [diff] [blame] | 2607 | if (!features->touch_max) { |
| 2608 | features->touch_max = value; |
| 2609 | } else { |
| 2610 | hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " |
| 2611 | "%d -> %d\n", __func__, features->touch_max, value); |
| 2612 | } |
Aaron Armstrong Skomra | 184eccd | 2019-06-12 14:19:29 -0700 | [diff] [blame] | 2613 | return; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2614 | } |
| 2615 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2616 | if (usage->usage_index + 1 == field->report_count) { |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2617 | if (equivalent_usage == wacom_wac->hid_data.last_slot_field) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2618 | wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2619 | } |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2620 | } |
| 2621 | |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2622 | static void wacom_wac_finger_pre_report(struct hid_device *hdev, |
| 2623 | struct hid_report *report) |
| 2624 | { |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2625 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2626 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2627 | struct hid_data* hid_data = &wacom_wac->hid_data; |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2628 | int i; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2629 | |
Aaron Armstrong Skomra | f4e11d5 | 2019-06-12 14:19:30 -0700 | [diff] [blame] | 2630 | wacom_wac->is_invalid_bt_frame = false; |
| 2631 | |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2632 | for (i = 0; i < report->maxfield; i++) { |
| 2633 | struct hid_field *field = report->field[i]; |
| 2634 | int j; |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2635 | |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2636 | for (j = 0; j < field->maxusage; j++) { |
| 2637 | struct hid_usage *usage = &field->usage[j]; |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2638 | unsigned int equivalent_usage = |
| 2639 | wacom_equivalent_usage(usage->hid); |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2640 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2641 | switch (equivalent_usage) { |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2642 | case HID_GD_X: |
| 2643 | case HID_GD_Y: |
| 2644 | case HID_DG_WIDTH: |
| 2645 | case HID_DG_HEIGHT: |
| 2646 | case HID_DG_CONTACTID: |
| 2647 | case HID_DG_INRANGE: |
| 2648 | case HID_DG_INVERT: |
| 2649 | case HID_DG_TIPSWITCH: |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2650 | hid_data->last_slot_field = equivalent_usage; |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2651 | break; |
Jason Gerecke | b43f977 | 2020-04-08 07:58:37 -0700 | [diff] [blame] | 2652 | case HID_DG_CONTACTCOUNT: |
| 2653 | hid_data->cc_report = report->id; |
| 2654 | hid_data->cc_index = i; |
| 2655 | hid_data->cc_value_index = j; |
| 2656 | break; |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2657 | } |
| 2658 | } |
| 2659 | } |
Jason Gerecke | b43f977 | 2020-04-08 07:58:37 -0700 | [diff] [blame] | 2660 | |
| 2661 | if (hid_data->cc_report != 0 && |
| 2662 | hid_data->cc_index >= 0) { |
| 2663 | struct hid_field *field = report->field[hid_data->cc_index]; |
| 2664 | int value = field->value[hid_data->cc_value_index]; |
| 2665 | if (value) |
| 2666 | hid_data->num_expected = value; |
| 2667 | } |
| 2668 | else { |
| 2669 | hid_data->num_expected = wacom_wac->features.touch_max; |
| 2670 | } |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2671 | } |
| 2672 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2673 | static void wacom_wac_finger_report(struct hid_device *hdev, |
| 2674 | struct hid_report *report) |
| 2675 | { |
| 2676 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2677 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2678 | struct input_dev *input = wacom_wac->touch_input; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2679 | unsigned touch_max = wacom_wac->features.touch_max; |
| 2680 | |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2681 | /* If more packets of data are expected, give us a chance to |
| 2682 | * process them rather than immediately syncing a partial |
| 2683 | * update. |
| 2684 | */ |
| 2685 | if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected) |
| 2686 | return; |
| 2687 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2688 | if (touch_max > 1) |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2689 | input_mt_sync_frame(input); |
| 2690 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2691 | input_sync(input); |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2692 | wacom_wac->hid_data.num_received = 0; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2693 | |
| 2694 | /* keep touch state for pen event */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2695 | wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2696 | } |
| 2697 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2698 | void wacom_wac_usage_mapping(struct hid_device *hdev, |
| 2699 | struct hid_field *field, struct hid_usage *usage) |
| 2700 | { |
| 2701 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2702 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 2703 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2704 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2705 | if (WACOM_DIRECT_DEVICE(field)) |
| 2706 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2707 | |
Jason Gerecke | 5ac3d4a | 2017-04-28 09:25:34 -0700 | [diff] [blame] | 2708 | /* usage tests must precede field tests */ |
| 2709 | if (WACOM_BATTERY_USAGE(usage)) |
| 2710 | wacom_wac_battery_usage_mapping(hdev, field, usage); |
| 2711 | else if (WACOM_PAD_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2712 | wacom_wac_pad_usage_mapping(hdev, field, usage); |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2713 | else if (WACOM_PEN_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2714 | wacom_wac_pen_usage_mapping(hdev, field, usage); |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2715 | else if (WACOM_FINGER_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2716 | wacom_wac_finger_usage_mapping(hdev, field, usage); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2717 | } |
| 2718 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2719 | void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2720 | struct hid_usage *usage, __s32 value) |
| 2721 | { |
| 2722 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2723 | |
| 2724 | if (wacom->wacom_wac.features.type != HID_GENERIC) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2725 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2726 | |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2727 | if (value > field->logical_maximum || value < field->logical_minimum) |
| 2728 | return; |
| 2729 | |
Jason Gerecke | 5ac3d4a | 2017-04-28 09:25:34 -0700 | [diff] [blame] | 2730 | /* usage tests must precede field tests */ |
| 2731 | if (WACOM_BATTERY_USAGE(usage)) |
| 2732 | wacom_wac_battery_event(hdev, field, usage, value); |
| 2733 | else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) |
| 2734 | wacom_wac_pad_event(hdev, field, usage, value); |
| 2735 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2736 | wacom_wac_pen_event(hdev, field, usage, value); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2737 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2738 | wacom_wac_finger_event(hdev, field, usage, value); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2739 | } |
| 2740 | |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2741 | static void wacom_report_events(struct hid_device *hdev, |
| 2742 | struct hid_report *report, int collection_index, |
| 2743 | int field_index) |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2744 | { |
| 2745 | int r; |
| 2746 | |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2747 | for (r = field_index; r < report->maxfield; r++) { |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2748 | struct hid_field *field; |
| 2749 | unsigned count, n; |
| 2750 | |
| 2751 | field = report->field[r]; |
| 2752 | count = field->report_count; |
| 2753 | |
| 2754 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 2755 | continue; |
| 2756 | |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2757 | for (n = 0 ; n < count; n++) { |
| 2758 | if (field->usage[n].collection_index == collection_index) |
| 2759 | wacom_wac_event(hdev, field, &field->usage[n], |
| 2760 | field->value[n]); |
| 2761 | else |
| 2762 | return; |
| 2763 | } |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2764 | } |
| 2765 | } |
| 2766 | |
Jiri Kosina | 7ba8fc0 | 2018-03-07 15:34:51 +0100 | [diff] [blame] | 2767 | static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report, |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2768 | int collection_index, struct hid_field *field, |
| 2769 | int field_index) |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2770 | { |
| 2771 | struct wacom *wacom = hid_get_drvdata(hdev); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2772 | |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2773 | wacom_report_events(hdev, report, collection_index, field_index); |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2774 | |
Jason Gerecke | a9ce785 | 2017-01-17 15:38:58 -0800 | [diff] [blame] | 2775 | /* |
| 2776 | * Non-input reports may be sent prior to the device being |
| 2777 | * completely initialized. Since only their events need |
| 2778 | * to be processed, exit after 'wacom_report_events' has |
| 2779 | * been called to prevent potential crashes in the report- |
| 2780 | * processing functions. |
| 2781 | */ |
| 2782 | if (report->type != HID_INPUT_REPORT) |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2783 | return -1; |
Jason Gerecke | 5ac3d4a | 2017-04-28 09:25:34 -0700 | [diff] [blame] | 2784 | |
Jason Gerecke | d9216d7 | 2020-09-23 13:14:56 -0700 | [diff] [blame] | 2785 | if (WACOM_PAD_FIELD(field)) |
| 2786 | return 0; |
| 2787 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2788 | wacom_wac_pen_report(hdev, report); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2789 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2790 | wacom_wac_finger_report(hdev, report); |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2791 | |
| 2792 | return 0; |
| 2793 | } |
| 2794 | |
| 2795 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) |
| 2796 | { |
| 2797 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2798 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2799 | struct hid_field *field; |
| 2800 | bool pad_in_hid_field = false, pen_in_hid_field = false, |
Aaron Armstrong Skomra | d4b8efe | 2019-05-10 15:34:17 -0700 | [diff] [blame] | 2801 | finger_in_hid_field = false, true_pad = false; |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2802 | int r; |
| 2803 | int prev_collection = -1; |
| 2804 | |
| 2805 | if (wacom_wac->features.type != HID_GENERIC) |
| 2806 | return; |
| 2807 | |
| 2808 | for (r = 0; r < report->maxfield; r++) { |
| 2809 | field = report->field[r]; |
| 2810 | |
| 2811 | if (WACOM_PAD_FIELD(field)) |
| 2812 | pad_in_hid_field = true; |
| 2813 | if (WACOM_PEN_FIELD(field)) |
| 2814 | pen_in_hid_field = true; |
| 2815 | if (WACOM_FINGER_FIELD(field)) |
| 2816 | finger_in_hid_field = true; |
Aaron Armstrong Skomra | d4b8efe | 2019-05-10 15:34:17 -0700 | [diff] [blame] | 2817 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) |
| 2818 | true_pad = true; |
Aaron Armstrong Skomra | f8b6a74 | 2018-03-06 10:48:34 -0800 | [diff] [blame] | 2819 | } |
| 2820 | |
| 2821 | wacom_wac_battery_pre_report(hdev, report); |
| 2822 | |
| 2823 | if (pad_in_hid_field && wacom->wacom_wac.pad_input) |
| 2824 | wacom_wac_pad_pre_report(hdev, report); |
| 2825 | if (pen_in_hid_field && wacom->wacom_wac.pen_input) |
| 2826 | wacom_wac_pen_pre_report(hdev, report); |
| 2827 | if (finger_in_hid_field && wacom->wacom_wac.touch_input) |
| 2828 | wacom_wac_finger_pre_report(hdev, report); |
| 2829 | |
| 2830 | for (r = 0; r < report->maxfield; r++) { |
| 2831 | field = report->field[r]; |
| 2832 | |
| 2833 | if (field->usage[0].collection_index != prev_collection) { |
| 2834 | if (wacom_wac_collection(hdev, report, |
| 2835 | field->usage[0].collection_index, field, r) < 0) |
| 2836 | return; |
| 2837 | prev_collection = field->usage[0].collection_index; |
| 2838 | } |
| 2839 | } |
| 2840 | |
| 2841 | wacom_wac_battery_report(hdev, report); |
Aaron Armstrong Skomra | d4b8efe | 2019-05-10 15:34:17 -0700 | [diff] [blame] | 2842 | |
| 2843 | if (true_pad && wacom->wacom_wac.pad_input) |
| 2844 | wacom_wac_pad_report(hdev, report, field); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2845 | } |
| 2846 | |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 2847 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2848 | { |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 2849 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2850 | struct input_dev *input = wacom->touch_input; |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2851 | struct input_dev *pad_input = wacom->pad_input; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2852 | unsigned char *data = wacom->data; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2853 | int i; |
| 2854 | |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2855 | if (data[0] != 0x02) |
| 2856 | return 0; |
| 2857 | |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2858 | for (i = 0; i < 2; i++) { |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2859 | int offset = (data[1] & 0x80) ? (8 * i) : (9 * i); |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2860 | bool touch = report_touch_events(wacom) |
| 2861 | && (data[offset + 3] & 0x80); |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2862 | |
| 2863 | input_mt_slot(input, i); |
| 2864 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
Henrik Rydberg | c5f4dec | 2010-12-15 13:50:34 +0100 | [diff] [blame] | 2865 | if (touch) { |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2866 | int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff; |
| 2867 | int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff; |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 2868 | if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { |
| 2869 | x <<= 5; |
| 2870 | y <<= 5; |
| 2871 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2872 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 2873 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2874 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2875 | } |
| 2876 | |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 2877 | input_mt_sync_frame(input); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2878 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2879 | input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0); |
| 2880 | input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0); |
| 2881 | input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0); |
| 2882 | input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0); |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2883 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2884 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2885 | return 1; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2886 | } |
| 2887 | |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2888 | static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2889 | { |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2890 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2891 | struct input_dev *input = wacom->touch_input; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2892 | bool touch = data[1] & 0x80; |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 2893 | int slot = input_mt_get_slot_by_key(input, data[0]); |
| 2894 | |
| 2895 | if (slot < 0) |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2896 | return; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2897 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2898 | touch = touch && report_touch_events(wacom); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2899 | |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 2900 | input_mt_slot(input, slot); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2901 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 2902 | |
| 2903 | if (touch) { |
| 2904 | int x = (data[2] << 4) | (data[4] >> 4); |
| 2905 | int y = (data[3] << 4) | (data[4] & 0x0f); |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2906 | int width, height; |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 2907 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2908 | if (features->type >= INTUOSPS && features->type <= INTUOSHT2) { |
Jason Gerecke | 0b279da | 2013-11-25 18:43:16 -0800 | [diff] [blame] | 2909 | width = data[5] * 100; |
| 2910 | height = data[6] * 100; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2911 | } else { |
| 2912 | /* |
| 2913 | * "a" is a scaled-down area which we assume is |
| 2914 | * roughly circular and which can be described as: |
| 2915 | * a=(pi*r^2)/C. |
| 2916 | */ |
| 2917 | int a = data[5]; |
Ping Cheng | d7da3a3 | 2014-06-13 13:37:33 -0700 | [diff] [blame] | 2918 | int x_res = input_abs_get_res(input, ABS_MT_POSITION_X); |
| 2919 | int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y); |
| 2920 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2921 | height = width * y_res / x_res; |
| 2922 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2923 | |
| 2924 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 2925 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 2926 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, width); |
| 2927 | input_report_abs(input, ABS_MT_TOUCH_MINOR, height); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2928 | } |
| 2929 | } |
| 2930 | |
| 2931 | static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) |
| 2932 | { |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2933 | struct input_dev *input = wacom->pad_input; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2934 | struct wacom_features *features = &wacom->features; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2935 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2936 | if (features->type == INTUOSHT || features->type == INTUOSHT2) { |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2937 | input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0); |
| 2938 | input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0); |
| 2939 | } else { |
| 2940 | input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); |
| 2941 | input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); |
| 2942 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2943 | input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2944 | input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); |
| 2945 | } |
| 2946 | |
| 2947 | static int wacom_bpt3_touch(struct wacom_wac *wacom) |
| 2948 | { |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2949 | unsigned char *data = wacom->data; |
Jason Gerecke | 19d57d3 | 2012-03-06 10:19:19 -0800 | [diff] [blame] | 2950 | int count = data[1] & 0x07; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2951 | int touch_changed = 0, i; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2952 | |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2953 | if (data[0] != 0x02) |
| 2954 | return 0; |
| 2955 | |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2956 | /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ |
| 2957 | for (i = 0; i < count; i++) { |
| 2958 | int offset = (8 * i) + 2; |
| 2959 | int msg_id = data[offset]; |
| 2960 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2961 | if (msg_id >= 2 && msg_id <= 17) { |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2962 | wacom_bpt3_touch_msg(wacom, data + offset); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2963 | touch_changed++; |
| 2964 | } else if (msg_id == 128) |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2965 | wacom_bpt3_button_msg(wacom, data + offset); |
| 2966 | |
| 2967 | } |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2968 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2969 | /* only update touch if we actually have a touchpad and touch data changed */ |
Benjamin Tissoires | 84dfbd7 | 2016-07-13 18:05:55 +0200 | [diff] [blame] | 2970 | if (wacom->touch_input && touch_changed) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2971 | input_mt_sync_frame(wacom->touch_input); |
| 2972 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 2973 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2974 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2975 | return 1; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2976 | } |
| 2977 | |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2978 | static int wacom_bpt_pen(struct wacom_wac *wacom) |
| 2979 | { |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 2980 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2981 | struct input_dev *input = wacom->pen_input; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2982 | unsigned char *data = wacom->data; |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 2983 | int x = 0, y = 0, p = 0, d = 0; |
| 2984 | bool pen = false, btn1 = false, btn2 = false; |
| 2985 | bool range, prox, rdy; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2986 | |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2987 | if (data[0] != WACOM_REPORT_PENABLED) |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2988 | return 0; |
| 2989 | |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 2990 | range = (data[1] & 0x80) == 0x80; |
| 2991 | prox = (data[1] & 0x40) == 0x40; |
| 2992 | rdy = (data[1] & 0x20) == 0x20; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2993 | |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 2994 | wacom->shared->stylus_in_proximity = range; |
| 2995 | if (delay_pen_events(wacom)) |
| 2996 | return 0; |
| 2997 | |
| 2998 | if (rdy) { |
| 2999 | p = le16_to_cpup((__le16 *)&data[6]); |
| 3000 | pen = data[1] & 0x01; |
| 3001 | btn1 = data[1] & 0x02; |
| 3002 | btn2 = data[1] & 0x04; |
| 3003 | } |
| 3004 | if (prox) { |
| 3005 | x = le16_to_cpup((__le16 *)&data[2]); |
| 3006 | y = le16_to_cpup((__le16 *)&data[4]); |
| 3007 | |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 3008 | if (data[1] & 0x08) { |
| 3009 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 3010 | wacom->id[0] = ERASER_DEVICE_ID; |
| 3011 | } else { |
| 3012 | wacom->tool[0] = BTN_TOOL_PEN; |
| 3013 | wacom->id[0] = STYLUS_DEVICE_ID; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3014 | } |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 3015 | wacom->reporting_data = true; |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 3016 | } |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 3017 | if (range) { |
Chris Bagwell | c18c2ce | 2011-10-10 08:52:13 -0700 | [diff] [blame] | 3018 | /* |
| 3019 | * Convert distance from out prox to distance from tablet. |
| 3020 | * distance will be greater than distance_max once |
| 3021 | * touching and applying pressure; do not report negative |
| 3022 | * distance. |
| 3023 | */ |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 3024 | if (data[8] <= features->distance_max) |
| 3025 | d = features->distance_max - data[8]; |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 3026 | } else { |
| 3027 | wacom->id[0] = 0; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3028 | } |
| 3029 | |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 3030 | if (wacom->reporting_data) { |
| 3031 | input_report_key(input, BTN_TOUCH, pen); |
| 3032 | input_report_key(input, BTN_STYLUS, btn1); |
| 3033 | input_report_key(input, BTN_STYLUS2, btn2); |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3034 | |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 3035 | if (prox || !range) { |
| 3036 | input_report_abs(input, ABS_X, x); |
| 3037 | input_report_abs(input, ABS_Y, y); |
| 3038 | } |
| 3039 | input_report_abs(input, ABS_PRESSURE, p); |
| 3040 | input_report_abs(input, ABS_DISTANCE, d); |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3041 | |
Jason Gerecke | 8947b0c | 2018-05-18 07:17:18 -0700 | [diff] [blame] | 3042 | input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */ |
| 3043 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */ |
| 3044 | } |
| 3045 | |
| 3046 | if (!range) { |
| 3047 | wacom->reporting_data = false; |
| 3048 | } |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3049 | |
| 3050 | return 1; |
| 3051 | } |
| 3052 | |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 3053 | static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) |
| 3054 | { |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3055 | struct wacom_features *features = &wacom->features; |
| 3056 | |
| 3057 | if ((features->type == INTUOSHT2) && |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3058 | (features->device_type & WACOM_DEVICETYPE_PEN)) |
| 3059 | return wacom_intuos_irq(wacom); |
| 3060 | else if (len == WACOM_PKGLEN_BBTOUCH) |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 3061 | return wacom_bpt_touch(wacom); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 3062 | else if (len == WACOM_PKGLEN_BBTOUCH3) |
| 3063 | return wacom_bpt3_touch(wacom); |
| 3064 | else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN) |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 3065 | return wacom_bpt_pen(wacom); |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 3066 | |
| 3067 | return 0; |
| 3068 | } |
| 3069 | |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3070 | static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom, |
| 3071 | unsigned char *data) |
| 3072 | { |
| 3073 | unsigned char prefix; |
| 3074 | |
| 3075 | /* |
| 3076 | * We need to reroute the event from the debug interface to the |
| 3077 | * pen interface. |
| 3078 | * We need to add the report ID to the actual pen report, so we |
| 3079 | * temporary overwrite the first byte to prevent having to kzalloc/kfree |
| 3080 | * and memcpy the report. |
| 3081 | */ |
| 3082 | prefix = data[0]; |
| 3083 | data[0] = WACOM_REPORT_BPAD_PEN; |
| 3084 | |
| 3085 | /* |
| 3086 | * actually reroute the event. |
| 3087 | * No need to check if wacom->shared->pen is valid, hid_input_report() |
| 3088 | * will check for us. |
| 3089 | */ |
| 3090 | hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data, |
| 3091 | WACOM_PKGLEN_PENABLED, 1); |
| 3092 | |
| 3093 | data[0] = prefix; |
| 3094 | } |
| 3095 | |
| 3096 | static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, |
| 3097 | unsigned char *data) |
| 3098 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 3099 | struct input_dev *input = wacom->touch_input; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3100 | unsigned char *finger_data, prefix; |
| 3101 | unsigned id; |
| 3102 | int x, y; |
| 3103 | bool valid; |
| 3104 | |
| 3105 | prefix = data[0]; |
| 3106 | |
| 3107 | for (id = 0; id < wacom->features.touch_max; id++) { |
| 3108 | valid = !!(prefix & BIT(id)) && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 3109 | report_touch_events(wacom); |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3110 | |
| 3111 | input_mt_slot(input, id); |
| 3112 | input_mt_report_slot_state(input, MT_TOOL_FINGER, valid); |
| 3113 | |
| 3114 | if (!valid) |
| 3115 | continue; |
| 3116 | |
| 3117 | finger_data = data + 1 + id * 3; |
| 3118 | x = finger_data[0] | ((finger_data[1] & 0x0f) << 8); |
| 3119 | y = (finger_data[2] << 4) | (finger_data[1] >> 4); |
| 3120 | |
| 3121 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 3122 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
| 3123 | } |
| 3124 | |
| 3125 | input_mt_sync_frame(input); |
| 3126 | |
| 3127 | input_report_key(input, BTN_LEFT, prefix & 0x40); |
| 3128 | input_report_key(input, BTN_RIGHT, prefix & 0x80); |
| 3129 | |
| 3130 | /* keep touch state for pen event */ |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 3131 | wacom->shared->touch_down = !!prefix && report_touch_events(wacom); |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3132 | |
| 3133 | return 1; |
| 3134 | } |
| 3135 | |
| 3136 | static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len) |
| 3137 | { |
| 3138 | unsigned char *data = wacom->data; |
| 3139 | |
| 3140 | if (!((len == WACOM_PKGLEN_BPAD_TOUCH) || |
| 3141 | (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) || |
| 3142 | (data[0] != WACOM_REPORT_BPAD_TOUCH)) |
| 3143 | return 0; |
| 3144 | |
| 3145 | if (data[1] & 0x01) |
| 3146 | wacom_bamboo_pad_pen_event(wacom, &data[1]); |
| 3147 | |
| 3148 | if (data[1] & 0x02) |
| 3149 | return wacom_bamboo_pad_touch_event(wacom, &data[9]); |
| 3150 | |
| 3151 | return 0; |
| 3152 | } |
| 3153 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3154 | static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) |
| 3155 | { |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3156 | unsigned char *data = wacom->data; |
| 3157 | int connected; |
| 3158 | |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 3159 | if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL) |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3160 | return 0; |
| 3161 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3162 | connected = data[1] & 0x01; |
| 3163 | if (connected) { |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 3164 | int pid, battery, charging; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3165 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3166 | if ((wacom->shared->type == INTUOSHT || |
| 3167 | wacom->shared->type == INTUOSHT2) && |
Ping Cheng | 44b9683 | 2014-11-06 17:30:51 -0800 | [diff] [blame] | 3168 | wacom->shared->touch_input && |
| 3169 | wacom->shared->touch_max) { |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 3170 | input_report_switch(wacom->shared->touch_input, |
| 3171 | SW_MUTE_DEVICE, data[5] & 0x40); |
| 3172 | input_sync(wacom->shared->touch_input); |
| 3173 | } |
| 3174 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3175 | pid = get_unaligned_be16(&data[6]); |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 3176 | battery = (data[5] & 0x3f) * 100 / 31; |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 3177 | charging = !!(data[5] & 0x80); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3178 | if (wacom->pid != pid) { |
| 3179 | wacom->pid = pid; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 3180 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3181 | } |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 3182 | |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 3183 | wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 3184 | battery, charging, 1, 0); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 3185 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3186 | } else if (wacom->pid != 0) { |
| 3187 | /* disconnected while previously connected */ |
| 3188 | wacom->pid = 0; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 3189 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 3190 | wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 3191 | } |
| 3192 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3193 | return 0; |
| 3194 | } |
| 3195 | |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 3196 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) |
| 3197 | { |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3198 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 3199 | struct wacom_features *features = &wacom_wac->features; |
| 3200 | unsigned char *data = wacom_wac->data; |
| 3201 | |
| 3202 | if (data[0] != WACOM_REPORT_USB) |
| 3203 | return 0; |
| 3204 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3205 | if ((features->type == INTUOSHT || |
| 3206 | features->type == INTUOSHT2) && |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 3207 | wacom_wac->shared->touch_input && |
| 3208 | features->touch_max) { |
| 3209 | input_report_switch(wacom_wac->shared->touch_input, |
| 3210 | SW_MUTE_DEVICE, data[8] & 0x40); |
| 3211 | input_sync(wacom_wac->shared->touch_input); |
| 3212 | } |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3213 | |
| 3214 | if (data[9] & 0x02) { /* wireless module is attached */ |
| 3215 | int battery = (data[8] & 0x3f) * 100 / 31; |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 3216 | bool charging = !!(data[8] & 0x80); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3217 | |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 3218 | wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO, |
| 3219 | battery, charging, battery || charging, 1); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3220 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 3221 | if (!wacom->battery.battery && |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3222 | !(features->quirks & WACOM_QUIRK_BATTERY)) { |
| 3223 | features->quirks |= WACOM_QUIRK_BATTERY; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 3224 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3225 | } |
| 3226 | } |
| 3227 | else if ((features->quirks & WACOM_QUIRK_BATTERY) && |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 3228 | wacom->battery.battery) { |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3229 | features->quirks &= ~WACOM_QUIRK_BATTERY; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 3230 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
Jason Gerecke | 16e4598 | 2017-04-28 09:25:33 -0700 | [diff] [blame] | 3231 | wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 3232 | } |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 3233 | return 0; |
| 3234 | } |
| 3235 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3236 | void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3237 | { |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3238 | bool sync; |
| 3239 | |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 3240 | switch (wacom_wac->features.type) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3241 | case PENPARTNER: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3242 | sync = wacom_penpartner_irq(wacom_wac); |
| 3243 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3244 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3245 | case PL: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3246 | sync = wacom_pl_irq(wacom_wac); |
| 3247 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3248 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3249 | case WACOM_G4: |
| 3250 | case GRAPHIRE: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 3251 | case GRAPHIRE_BT: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3252 | case WACOM_MO: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3253 | sync = wacom_graphire_irq(wacom_wac); |
| 3254 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3255 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3256 | case PTU: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3257 | sync = wacom_ptu_irq(wacom_wac); |
| 3258 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3259 | |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 3260 | case DTU: |
| 3261 | sync = wacom_dtu_irq(wacom_wac); |
| 3262 | break; |
| 3263 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3264 | case DTUS: |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 3265 | case DTUSX: |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3266 | sync = wacom_dtus_irq(wacom_wac); |
| 3267 | break; |
| 3268 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3269 | case INTUOS: |
| 3270 | case INTUOS3S: |
| 3271 | case INTUOS3: |
| 3272 | case INTUOS3L: |
| 3273 | case INTUOS4S: |
| 3274 | case INTUOS4: |
| 3275 | case INTUOS4L: |
| 3276 | case CINTIQ: |
| 3277 | case WACOM_BEE: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3278 | case WACOM_13HD: |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 3279 | case WACOM_21UX2: |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 3280 | case WACOM_22HD: |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 3281 | case WACOM_24HD: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3282 | case WACOM_27QHD: |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 3283 | case DTK: |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 3284 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 3285 | case CINTIQ_COMPANION_2: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3286 | sync = wacom_intuos_irq(wacom_wac); |
| 3287 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3288 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 3289 | case INTUOS4WL: |
| 3290 | sync = wacom_intuos_bt_irq(wacom_wac, len); |
| 3291 | break; |
| 3292 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 3293 | case WACOM_24HDT: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3294 | case WACOM_27QHDT: |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 3295 | sync = wacom_24hdt_irq(wacom_wac); |
| 3296 | break; |
| 3297 | |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3298 | case INTUOS5S: |
| 3299 | case INTUOS5: |
| 3300 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3301 | case INTUOSPS: |
| 3302 | case INTUOSPM: |
| 3303 | case INTUOSPL: |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3304 | if (len == WACOM_PKGLEN_BBTOUCH3) |
| 3305 | sync = wacom_bpt3_touch(wacom_wac); |
Jason Gerecke | 2d13a43 | 2015-03-06 11:47:42 -0800 | [diff] [blame] | 3306 | else if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 3307 | sync = wacom_status_irq(wacom_wac, len); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3308 | else |
| 3309 | sync = wacom_intuos_irq(wacom_wac); |
| 3310 | break; |
| 3311 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3312 | case INTUOSP2_BT: |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 3313 | case INTUOSP2S_BT: |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 3314 | case INTUOSHT3_BT: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3315 | sync = wacom_intuos_pro2_bt_irq(wacom_wac, len); |
| 3316 | break; |
| 3317 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3318 | case TABLETPC: |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 3319 | case TABLETPCE: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3320 | case TABLETPC2FG: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3321 | case MTSCREEN: |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 3322 | case MTTPC: |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 3323 | case MTTPC_B: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3324 | sync = wacom_tpc_irq(wacom_wac, len); |
| 3325 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 3326 | |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3327 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3328 | case BAMBOO_PEN: |
| 3329 | case BAMBOO_TOUCH: |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 3330 | case INTUOSHT: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3331 | case INTUOSHT2: |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 3332 | if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 3333 | sync = wacom_status_irq(wacom_wac, len); |
| 3334 | else |
| 3335 | sync = wacom_bpt_irq(wacom_wac, len); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3336 | break; |
| 3337 | |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3338 | case BAMBOO_PAD: |
| 3339 | sync = wacom_bamboo_pad_irq(wacom_wac, len); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3340 | break; |
| 3341 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3342 | case WIRELESS: |
| 3343 | sync = wacom_wireless_irq(wacom_wac, len); |
| 3344 | break; |
| 3345 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3346 | case REMOTE: |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 3347 | sync = false; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3348 | if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST) |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 3349 | wacom_remote_status_irq(wacom_wac, len); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3350 | else |
| 3351 | sync = wacom_remote_irq(wacom_wac, len); |
| 3352 | break; |
| 3353 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3354 | default: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3355 | sync = false; |
| 3356 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3357 | } |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3358 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3359 | if (sync) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 3360 | if (wacom_wac->pen_input) |
| 3361 | input_sync(wacom_wac->pen_input); |
| 3362 | if (wacom_wac->touch_input) |
| 3363 | input_sync(wacom_wac->touch_input); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3364 | if (wacom_wac->pad_input) |
| 3365 | input_sync(wacom_wac->pad_input); |
| 3366 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3367 | } |
| 3368 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3369 | static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3370 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 3371 | struct input_dev *input_dev = wacom_wac->pen_input; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3372 | |
| 3373 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3374 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3375 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3376 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3377 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3378 | |
| 3379 | input_set_abs_params(input_dev, ABS_DISTANCE, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3380 | 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3381 | } |
| 3382 | |
| 3383 | static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) |
| 3384 | { |
| 3385 | struct input_dev *input_dev = wacom_wac->pen_input; |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3386 | struct wacom_features *features = &wacom_wac->features; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3387 | |
| 3388 | wacom_setup_basic_pro_pen(wacom_wac); |
| 3389 | |
| 3390 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3391 | __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); |
| 3392 | __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); |
| 3393 | __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); |
| 3394 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3395 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3396 | input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3397 | input_abs_set_res(input_dev, ABS_TILT_X, 57); |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3398 | input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3399 | input_abs_set_res(input_dev, ABS_TILT_Y, 57); |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 3400 | } |
| 3401 | |
| 3402 | static void wacom_setup_intuos(struct wacom_wac *wacom_wac) |
| 3403 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 3404 | struct input_dev *input_dev = wacom_wac->pen_input; |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 3405 | |
| 3406 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 3407 | |
| 3408 | wacom_setup_cintiq(wacom_wac); |
| 3409 | |
| 3410 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3411 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3412 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 3413 | __set_bit(BTN_SIDE, input_dev->keybit); |
| 3414 | __set_bit(BTN_EXTRA, input_dev->keybit); |
| 3415 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 3416 | __set_bit(BTN_TOOL_LENS, input_dev->keybit); |
| 3417 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3418 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3419 | input_abs_set_res(input_dev, ABS_RZ, 287); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3420 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); |
| 3421 | } |
| 3422 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3423 | void wacom_setup_device_quirks(struct wacom *wacom) |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3424 | { |
Jason Gerecke | 11db817 | 2018-10-10 13:40:26 -0700 | [diff] [blame] | 3425 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3426 | struct wacom_features *features = &wacom->wacom_wac.features; |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3427 | |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3428 | /* The pen and pad share the same interface on most devices */ |
| 3429 | if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3430 | features->type == DTUS || |
| 3431 | (features->type >= INTUOS3S && features->type <= WACOM_MO)) { |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3432 | if (features->device_type & WACOM_DEVICETYPE_PEN) |
| 3433 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3434 | } |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3435 | |
| 3436 | /* touch device found but size is not defined. use default */ |
Jason Gerecke | aa86b18 | 2015-06-15 18:01:42 -0700 | [diff] [blame] | 3437 | if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3438 | features->x_max = 1023; |
| 3439 | features->y_max = 1023; |
| 3440 | } |
| 3441 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3442 | /* |
| 3443 | * Intuos5/Pro and Bamboo 3rd gen have no useful data about its |
| 3444 | * touch interface in its HID descriptor. If this is the touch |
| 3445 | * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the |
| 3446 | * tablet values. |
| 3447 | */ |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3448 | if ((features->type >= INTUOS5S && features->type <= INTUOSPL) || |
| 3449 | (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) { |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3450 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3451 | if (features->touch_max) |
| 3452 | features->device_type |= WACOM_DEVICETYPE_TOUCH; |
Jiri Kosina | a3088ab | 2015-11-17 00:24:14 +0100 | [diff] [blame] | 3453 | if (features->type >= INTUOSHT && features->type <= BAMBOO_PT) |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3454 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3455 | |
Jason Gerecke | 3b8d573 | 2018-06-26 09:58:02 -0700 | [diff] [blame] | 3456 | if (features->type == INTUOSHT2) { |
| 3457 | features->x_max = features->x_max / 10; |
| 3458 | features->y_max = features->y_max / 10; |
| 3459 | } |
| 3460 | else { |
| 3461 | features->x_max = 4096; |
| 3462 | features->y_max = 4096; |
| 3463 | } |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3464 | } |
Jason Gerecke | 9633920 | 2015-07-01 13:01:00 -0700 | [diff] [blame] | 3465 | else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
| 3466 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3467 | } |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3468 | } |
| 3469 | |
| 3470 | /* |
Benjamin Tissoires | 580549e | 2016-03-25 15:26:55 +0100 | [diff] [blame] | 3471 | * Hack for the Bamboo One: |
| 3472 | * the device presents a PAD/Touch interface as most Bamboos and even |
| 3473 | * sends ghosts PAD data on it. However, later, we must disable this |
| 3474 | * ghost interface, and we can not detect it unless we set it here |
| 3475 | * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH. |
| 3476 | */ |
| 3477 | if (features->type == BAMBOO_PEN && |
| 3478 | features->pktlen == WACOM_PKGLEN_BBTOUCH3) |
| 3479 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3480 | |
| 3481 | /* |
Jason Gerecke | 042628a | 2015-04-30 17:51:54 -0700 | [diff] [blame] | 3482 | * Raw Wacom-mode pen and touch events both come from interface |
| 3483 | * 0, whose HID descriptor has an application usage of 0xFF0D |
Jason Gerecke | 8de8228 | 2016-10-19 18:03:37 -0700 | [diff] [blame] | 3484 | * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back |
Jason Gerecke | 042628a | 2015-04-30 17:51:54 -0700 | [diff] [blame] | 3485 | * out through the HID_GENERIC device created for interface 1, |
Benjamin Tissoires | 70caee0a | 2015-07-09 14:11:51 -0400 | [diff] [blame] | 3486 | * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH. |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3487 | */ |
| 3488 | if (features->type == BAMBOO_PAD) |
Benjamin Tissoires | 70caee0a | 2015-07-09 14:11:51 -0400 | [diff] [blame] | 3489 | features->device_type = WACOM_DEVICETYPE_TOUCH; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3490 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3491 | if (features->type == REMOTE) |
| 3492 | features->device_type = WACOM_DEVICETYPE_PAD; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3493 | |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 3494 | if (features->type == INTUOSP2_BT || |
| 3495 | features->type == INTUOSP2S_BT) { |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3496 | features->device_type |= WACOM_DEVICETYPE_PEN | |
| 3497 | WACOM_DEVICETYPE_PAD | |
| 3498 | WACOM_DEVICETYPE_TOUCH; |
| 3499 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3500 | } |
| 3501 | |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 3502 | if (features->type == INTUOSHT3_BT) { |
| 3503 | features->device_type |= WACOM_DEVICETYPE_PEN | |
| 3504 | WACOM_DEVICETYPE_PAD; |
| 3505 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3506 | } |
| 3507 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3508 | switch (features->type) { |
| 3509 | case PL: |
| 3510 | case DTU: |
| 3511 | case DTUS: |
| 3512 | case DTUSX: |
| 3513 | case WACOM_21UX2: |
| 3514 | case WACOM_22HD: |
| 3515 | case DTK: |
| 3516 | case WACOM_24HD: |
| 3517 | case WACOM_27QHD: |
| 3518 | case CINTIQ_HYBRID: |
| 3519 | case CINTIQ_COMPANION_2: |
| 3520 | case CINTIQ: |
| 3521 | case WACOM_BEE: |
| 3522 | case WACOM_13HD: |
| 3523 | case WACOM_24HDT: |
| 3524 | case WACOM_27QHDT: |
| 3525 | case TABLETPC: |
| 3526 | case TABLETPCE: |
| 3527 | case TABLETPC2FG: |
| 3528 | case MTSCREEN: |
| 3529 | case MTTPC: |
| 3530 | case MTTPC_B: |
| 3531 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
| 3532 | break; |
| 3533 | } |
| 3534 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3535 | if (wacom->hdev->bus == BUS_BLUETOOTH) |
| 3536 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3537 | |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 3538 | /* quirk for bamboo touch with 2 low res touches */ |
Jason Gerecke | be853fd | 2015-12-04 14:45:27 -0800 | [diff] [blame] | 3539 | if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 3540 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 3541 | features->x_max <<= 5; |
| 3542 | features->y_max <<= 5; |
| 3543 | features->x_fuzz <<= 5; |
| 3544 | features->y_fuzz <<= 5; |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 3545 | features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3546 | } |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3547 | |
| 3548 | if (features->type == WIRELESS) { |
Jason Gerecke | ccad85c | 2015-08-03 10:17:04 -0700 | [diff] [blame] | 3549 | if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) { |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 3550 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3551 | } |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3552 | } |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 3553 | |
| 3554 | if (features->type == REMOTE) |
| 3555 | features->device_type |= WACOM_DEVICETYPE_WL_MONITOR; |
Jason Gerecke | 11db817 | 2018-10-10 13:40:26 -0700 | [diff] [blame] | 3556 | |
| 3557 | /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots |
| 3558 | * of things it shouldn't. Lets fix up the damage... |
| 3559 | */ |
| 3560 | if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) { |
| 3561 | features->quirks &= ~WACOM_QUIRK_TOOLSERIAL; |
| 3562 | __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit); |
| 3563 | __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit); |
| 3564 | __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit); |
| 3565 | __clear_bit(ABS_Z, wacom_wac->pen_input->absbit); |
| 3566 | __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit); |
| 3567 | __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit); |
| 3568 | __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit); |
| 3569 | __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit); |
| 3570 | __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit); |
| 3571 | __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit); |
| 3572 | __clear_bit(EV_MSC, wacom_wac->pen_input->evbit); |
| 3573 | } |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3574 | } |
| 3575 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3576 | int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3577 | struct wacom_wac *wacom_wac) |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3578 | { |
| 3579 | struct wacom_features *features = &wacom_wac->features; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3580 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3581 | if (!(features->device_type & WACOM_DEVICETYPE_PEN)) |
| 3582 | return -ENODEV; |
| 3583 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3584 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3585 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3586 | else |
| 3587 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3588 | |
Ping Cheng | 46fc466 | 2021-04-05 20:46:34 -0700 | [diff] [blame] | 3589 | if (features->type == HID_GENERIC) |
| 3590 | /* setup has already been done */ |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 3591 | return 0; |
| 3592 | |
Ping Cheng | 276559d | 2021-03-11 11:30:09 -0800 | [diff] [blame] | 3593 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3594 | __set_bit(BTN_TOUCH, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3595 | __set_bit(ABS_MISC, input_dev->absbit); |
| 3596 | |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3597 | input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left, |
| 3598 | features->x_max - features->offset_right, |
| 3599 | features->x_fuzz, 0); |
| 3600 | input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top, |
| 3601 | features->y_max - features->offset_bottom, |
| 3602 | features->y_fuzz, 0); |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3603 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, |
| 3604 | features->pressure_max, features->pressure_fuzz, 0); |
| 3605 | |
| 3606 | /* penabled devices have fixed resolution for each model */ |
| 3607 | input_abs_set_res(input_dev, ABS_X, features->x_resolution); |
| 3608 | input_abs_set_res(input_dev, ABS_Y, features->y_resolution); |
| 3609 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3610 | switch (features->type) { |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3611 | case GRAPHIRE_BT: |
| 3612 | __clear_bit(ABS_MISC, input_dev->absbit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3613 | fallthrough; |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3614 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3615 | case WACOM_MO: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3616 | case WACOM_G4: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3617 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
| 3618 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3619 | features->distance_fuzz, 0); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3620 | fallthrough; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3621 | |
| 3622 | case GRAPHIRE: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3623 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 3624 | |
| 3625 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3626 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3627 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 3628 | |
| 3629 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3630 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3631 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 3632 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3633 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3634 | break; |
| 3635 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3636 | case WACOM_27QHD: |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 3637 | case WACOM_24HD: |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 3638 | case DTK: |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 3639 | case WACOM_22HD: |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 3640 | case WACOM_21UX2: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3641 | case WACOM_BEE: |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 3642 | case CINTIQ: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3643 | case WACOM_13HD: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3644 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 3645 | case CINTIQ_COMPANION_2: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3646 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3647 | input_abs_set_res(input_dev, ABS_Z, 287); |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3648 | wacom_setup_cintiq(wacom_wac); |
| 3649 | break; |
| 3650 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3651 | case INTUOS3: |
| 3652 | case INTUOS3L: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3653 | case INTUOS3S: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3654 | case INTUOS4: |
| 3655 | case INTUOS4WL: |
| 3656 | case INTUOS4L: |
| 3657 | case INTUOS4S: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3658 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3659 | input_abs_set_res(input_dev, ABS_Z, 287); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3660 | fallthrough; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3661 | |
| 3662 | case INTUOS: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3663 | wacom_setup_intuos(wacom_wac); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3664 | break; |
| 3665 | |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3666 | case INTUOS5: |
| 3667 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3668 | case INTUOSPM: |
| 3669 | case INTUOSPL: |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3670 | case INTUOS5S: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3671 | case INTUOSPS: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3672 | case INTUOSP2_BT: |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 3673 | case INTUOSP2S_BT: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3674 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
| 3675 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3676 | features->distance_fuzz, 0); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3677 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3678 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
| 3679 | input_abs_set_res(input_dev, ABS_Z, 287); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3680 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3681 | wacom_setup_intuos(wacom_wac); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3682 | break; |
| 3683 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 3684 | case WACOM_24HDT: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3685 | case WACOM_27QHDT: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3686 | case MTSCREEN: |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 3687 | case MTTPC: |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 3688 | case MTTPC_B: |
Ping Cheng | 6795a52 | 2012-06-28 16:49:00 -0700 | [diff] [blame] | 3689 | case TABLETPC2FG: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3690 | case TABLETPC: |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 3691 | case TABLETPCE: |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 3692 | __clear_bit(ABS_MISC, input_dev->absbit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3693 | fallthrough; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3694 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3695 | case DTUS: |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 3696 | case DTUSX: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3697 | case PL: |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 3698 | case DTU: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3699 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Jason Gerecke | 3512069 | 2011-09-08 09:38:14 -0700 | [diff] [blame] | 3700 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3701 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3702 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
Jason Gerecke | 3512069 | 2011-09-08 09:38:14 -0700 | [diff] [blame] | 3703 | break; |
| 3704 | |
| 3705 | case PTU: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3706 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3707 | fallthrough; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3708 | |
| 3709 | case PENPARTNER: |
Jason Gerecke | 1fab84a | 2011-08-26 23:18:22 -0700 | [diff] [blame] | 3710 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3711 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
Jason Gerecke | 1fab84a | 2011-08-26 23:18:22 -0700 | [diff] [blame] | 3712 | __set_bit(BTN_STYLUS, input_dev->keybit); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3713 | break; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3714 | |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 3715 | case INTUOSHT: |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3716 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3717 | case BAMBOO_PEN: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3718 | case INTUOSHT2: |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 3719 | case INTUOSHT3_BT: |
| 3720 | if (features->type == INTUOSHT2 || |
| 3721 | features->type == INTUOSHT3_BT) { |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3722 | wacom_setup_basic_pro_pen(wacom_wac); |
| 3723 | } else { |
| 3724 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3725 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3726 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3727 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3728 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3729 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3730 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3731 | features->distance_fuzz, 0); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3732 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3733 | break; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3734 | case BAMBOO_PAD: |
| 3735 | __clear_bit(ABS_MISC, input_dev->absbit); |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3736 | break; |
| 3737 | } |
| 3738 | return 0; |
| 3739 | } |
| 3740 | |
| 3741 | int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, |
| 3742 | struct wacom_wac *wacom_wac) |
| 3743 | { |
| 3744 | struct wacom_features *features = &wacom_wac->features; |
| 3745 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3746 | if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) |
| 3747 | return -ENODEV; |
| 3748 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3749 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3750 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3751 | else |
| 3752 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3753 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3754 | if (features->type == HID_GENERIC) |
| 3755 | /* setup has already been done */ |
| 3756 | return 0; |
| 3757 | |
Ping Cheng | 276559d | 2021-03-11 11:30:09 -0800 | [diff] [blame] | 3758 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3759 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 3760 | |
| 3761 | if (features->touch_max == 1) { |
| 3762 | input_set_abs_params(input_dev, ABS_X, 0, |
| 3763 | features->x_max, features->x_fuzz, 0); |
| 3764 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 3765 | features->y_max, features->y_fuzz, 0); |
| 3766 | input_abs_set_res(input_dev, ABS_X, |
| 3767 | features->x_resolution); |
| 3768 | input_abs_set_res(input_dev, ABS_Y, |
| 3769 | features->y_resolution); |
| 3770 | } |
| 3771 | else if (features->touch_max > 1) { |
| 3772 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, |
| 3773 | features->x_max, features->x_fuzz, 0); |
| 3774 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, |
| 3775 | features->y_max, features->y_fuzz, 0); |
| 3776 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, |
| 3777 | features->x_resolution); |
| 3778 | input_abs_set_res(input_dev, ABS_MT_POSITION_Y, |
| 3779 | features->y_resolution); |
| 3780 | } |
| 3781 | |
| 3782 | switch (features->type) { |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3783 | case INTUOSP2_BT: |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 3784 | case INTUOSP2S_BT: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3785 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3786 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 3787 | |
| 3788 | if (wacom_wac->shared->touch->product == 0x361) { |
| 3789 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
| 3790 | 0, 12440, 4, 0); |
| 3791 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
| 3792 | 0, 8640, 4, 0); |
| 3793 | } |
| 3794 | else if (wacom_wac->shared->touch->product == 0x360) { |
| 3795 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
| 3796 | 0, 8960, 4, 0); |
| 3797 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
| 3798 | 0, 5920, 4, 0); |
| 3799 | } |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 3800 | else if (wacom_wac->shared->touch->product == 0x393) { |
| 3801 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
| 3802 | 0, 6400, 4, 0); |
| 3803 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
| 3804 | 0, 4000, 4, 0); |
| 3805 | } |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3806 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); |
Aaron Armstrong Skomra | 68c20cc | 2019-05-10 15:34:18 -0700 | [diff] [blame] | 3807 | input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3808 | |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3809 | fallthrough; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3810 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3811 | case INTUOS5: |
| 3812 | case INTUOS5L: |
| 3813 | case INTUOSPM: |
| 3814 | case INTUOSPL: |
| 3815 | case INTUOS5S: |
| 3816 | case INTUOSPS: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3817 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); |
| 3818 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); |
| 3819 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
| 3820 | break; |
| 3821 | |
| 3822 | case WACOM_24HDT: |
| 3823 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); |
| 3824 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); |
| 3825 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); |
| 3826 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3827 | fallthrough; |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3828 | |
| 3829 | case WACOM_27QHDT: |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 3830 | if (wacom_wac->shared->touch->product == 0x32C || |
| 3831 | wacom_wac->shared->touch->product == 0xF6) { |
| 3832 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3833 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 3834 | wacom_wac->shared->has_mute_touch_switch = true; |
| 3835 | } |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3836 | fallthrough; |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 3837 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3838 | case MTSCREEN: |
| 3839 | case MTTPC: |
| 3840 | case MTTPC_B: |
| 3841 | case TABLETPC2FG: |
| 3842 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3843 | fallthrough; |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3844 | |
| 3845 | case TABLETPC: |
| 3846 | case TABLETPCE: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3847 | break; |
| 3848 | |
| 3849 | case INTUOSHT: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3850 | case INTUOSHT2: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3851 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3852 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 3853 | fallthrough; |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3854 | |
| 3855 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3856 | case BAMBOO_TOUCH: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3857 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 3858 | input_set_abs_params(input_dev, |
| 3859 | ABS_MT_TOUCH_MAJOR, |
| 3860 | 0, features->x_max, 0, 0); |
| 3861 | input_set_abs_params(input_dev, |
| 3862 | ABS_MT_TOUCH_MINOR, |
| 3863 | 0, features->y_max, 0, 0); |
| 3864 | } |
| 3865 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
| 3866 | break; |
| 3867 | |
| 3868 | case BAMBOO_PAD: |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3869 | input_mt_init_slots(input_dev, features->touch_max, |
| 3870 | INPUT_MT_POINTER); |
| 3871 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3872 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3873 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3874 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3875 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3876 | } |
| 3877 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 3878 | static int wacom_numbered_button_to_key(int n) |
| 3879 | { |
| 3880 | if (n < 10) |
| 3881 | return BTN_0 + n; |
| 3882 | else if (n < 16) |
| 3883 | return BTN_A + (n-10); |
| 3884 | else if (n < 18) |
| 3885 | return BTN_BASE + (n-16); |
| 3886 | else |
| 3887 | return 0; |
| 3888 | } |
| 3889 | |
Jiri Kosina | 5397df1 | 2015-08-28 20:46:42 +0200 | [diff] [blame] | 3890 | static void wacom_setup_numbered_buttons(struct input_dev *input_dev, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3891 | int button_count) |
| 3892 | { |
| 3893 | int i; |
| 3894 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 3895 | for (i = 0; i < button_count; i++) { |
| 3896 | int key = wacom_numbered_button_to_key(i); |
| 3897 | |
| 3898 | if (key) |
| 3899 | __set_bit(key, input_dev->keybit); |
| 3900 | } |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3901 | } |
| 3902 | |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3903 | static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group) |
| 3904 | { |
| 3905 | struct wacom_led *led; |
| 3906 | int i; |
| 3907 | bool updated = false; |
| 3908 | |
| 3909 | /* |
| 3910 | * 24HD has LED group 1 to the left and LED group 0 to the right. |
| 3911 | * So group 0 matches the second half of the buttons and thus the mask |
| 3912 | * needs to be shifted. |
| 3913 | */ |
| 3914 | if (group == 0) |
| 3915 | mask >>= 8; |
| 3916 | |
| 3917 | for (i = 0; i < 3; i++) { |
| 3918 | led = wacom_led_find(wacom, group, i); |
| 3919 | if (!led) { |
| 3920 | hid_err(wacom->hdev, "can't find LED %d in group %d\n", |
| 3921 | i, group); |
| 3922 | continue; |
| 3923 | } |
| 3924 | if (!updated && mask & BIT(i)) { |
| 3925 | led->held = true; |
| 3926 | led_trigger_event(&led->trigger, LED_FULL); |
| 3927 | } else { |
| 3928 | led->held = false; |
| 3929 | } |
| 3930 | } |
| 3931 | } |
| 3932 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3933 | static bool wacom_is_led_toggled(struct wacom *wacom, int button_count, |
| 3934 | int mask, int group) |
| 3935 | { |
Jason Gerecke | 6441fc7 | 2019-05-07 11:53:21 -0700 | [diff] [blame] | 3936 | int group_button; |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3937 | |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3938 | /* |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3939 | * 21UX2 has LED group 1 to the left and LED group 0 |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3940 | * to the right. We need to reverse the group to match this |
| 3941 | * historical behavior. |
| 3942 | */ |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3943 | if (wacom->wacom_wac.features.type == WACOM_21UX2) |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3944 | group = 1 - group; |
| 3945 | |
Jason Gerecke | 6441fc7 | 2019-05-07 11:53:21 -0700 | [diff] [blame] | 3946 | group_button = group * (button_count/wacom->led.count); |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3947 | |
Jason Gerecke | 6441fc7 | 2019-05-07 11:53:21 -0700 | [diff] [blame] | 3948 | if (wacom->wacom_wac.features.type == INTUOSP2_BT) |
| 3949 | group_button = 8; |
| 3950 | |
| 3951 | return mask & (1 << group_button); |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3952 | } |
| 3953 | |
| 3954 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 3955 | int group) |
| 3956 | { |
| 3957 | struct wacom_led *led, *next_led; |
| 3958 | int cur; |
| 3959 | bool pressed; |
| 3960 | |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3961 | if (wacom->wacom_wac.features.type == WACOM_24HD) |
| 3962 | return wacom_24hd_update_leds(wacom, mask, group); |
| 3963 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3964 | pressed = wacom_is_led_toggled(wacom, button_count, mask, group); |
| 3965 | cur = wacom->led.groups[group].select; |
| 3966 | |
| 3967 | led = wacom_led_find(wacom, group, cur); |
| 3968 | if (!led) { |
| 3969 | hid_err(wacom->hdev, "can't find current LED %d in group %d\n", |
| 3970 | cur, group); |
| 3971 | return; |
| 3972 | } |
| 3973 | |
| 3974 | if (!pressed) { |
| 3975 | led->held = false; |
| 3976 | return; |
| 3977 | } |
| 3978 | |
| 3979 | if (led->held && pressed) |
| 3980 | return; |
| 3981 | |
| 3982 | next_led = wacom_led_next(wacom, led); |
| 3983 | if (!next_led) { |
| 3984 | hid_err(wacom->hdev, "can't find next LED in group %d\n", |
| 3985 | group); |
| 3986 | return; |
| 3987 | } |
| 3988 | if (next_led == led) |
| 3989 | return; |
| 3990 | |
| 3991 | next_led->held = true; |
| 3992 | led_trigger_event(&next_led->trigger, |
| 3993 | wacom_leds_brightness_get(next_led)); |
| 3994 | } |
| 3995 | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 3996 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 3997 | int button_count, int mask) |
| 3998 | { |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3999 | struct wacom *wacom = input_get_drvdata(input_dev); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 4000 | int i; |
| 4001 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 4002 | for (i = 0; i < wacom->led.count; i++) |
| 4003 | wacom_update_led(wacom, button_count, mask, i); |
| 4004 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 4005 | for (i = 0; i < button_count; i++) { |
| 4006 | int key = wacom_numbered_button_to_key(i); |
| 4007 | |
| 4008 | if (key) |
| 4009 | input_report_key(input_dev, key, mask & (1 << i)); |
| 4010 | } |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 4011 | } |
| 4012 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4013 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, |
| 4014 | struct wacom_wac *wacom_wac) |
| 4015 | { |
| 4016 | struct wacom_features *features = &wacom_wac->features; |
| 4017 | |
Ping Cheng | e7deb15 | 2017-01-30 15:40:49 -0800 | [diff] [blame] | 4018 | if ((features->type == HID_GENERIC) && features->numbered_buttons > 0) |
| 4019 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 4020 | |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 4021 | if (!(features->device_type & WACOM_DEVICETYPE_PAD)) |
| 4022 | return -ENODEV; |
| 4023 | |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 4024 | if (features->type == REMOTE && input_dev == wacom_wac->pad_input) |
| 4025 | return -ENODEV; |
| 4026 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4027 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 4028 | |
| 4029 | /* kept for making legacy xf86-input-wacom working with the wheels */ |
| 4030 | __set_bit(ABS_MISC, input_dev->absbit); |
| 4031 | |
| 4032 | /* kept for making legacy xf86-input-wacom accepting the pad */ |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 4033 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum || |
| 4034 | input_dev->absinfo[ABS_X].maximum))) |
| 4035 | input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0); |
| 4036 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum || |
| 4037 | input_dev->absinfo[ABS_Y].maximum))) |
| 4038 | input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4039 | |
Benjamin Tissoires | 12969e3 | 2014-09-11 13:14:04 -0400 | [diff] [blame] | 4040 | /* kept for making udev and libwacom accepting the pad */ |
| 4041 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 4042 | |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4043 | wacom_setup_numbered_buttons(input_dev, features->numbered_buttons); |
| 4044 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4045 | switch (features->type) { |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4046 | |
| 4047 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4048 | case CINTIQ_COMPANION_2: |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4049 | case DTK: |
| 4050 | case DTUS: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4051 | case GRAPHIRE_BT: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4052 | break; |
| 4053 | |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 4054 | case WACOM_MO: |
| 4055 | __set_bit(BTN_BACK, input_dev->keybit); |
| 4056 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 4057 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 4058 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 4059 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4060 | break; |
| 4061 | |
| 4062 | case WACOM_G4: |
| 4063 | __set_bit(BTN_BACK, input_dev->keybit); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 4064 | __set_bit(BTN_FORWARD, input_dev->keybit); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 4065 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 4066 | break; |
| 4067 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4068 | case WACOM_24HD: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4069 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4070 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4071 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 4072 | |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 4073 | __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); |
| 4074 | __set_bit(KEY_INFO, input_dev->keybit); |
| 4075 | |
| 4076 | if (!features->oPid) |
| 4077 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4078 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4079 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4080 | input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); |
| 4081 | break; |
| 4082 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4083 | case WACOM_27QHD: |
| 4084 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4085 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4086 | __set_bit(KEY_PROG3, input_dev->keybit); |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 4087 | |
| 4088 | __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit); |
| 4089 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4090 | |
| 4091 | if (!features->oPid) |
| 4092 | __set_bit(KEY_CONTROLPANEL, input_dev->keybit); |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4093 | input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0); |
| 4094 | input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */ |
| 4095 | input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0); |
| 4096 | input_abs_set_res(input_dev, ABS_Y, 1024); |
| 4097 | input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0); |
| 4098 | input_abs_set_res(input_dev, ABS_Z, 1024); |
| 4099 | __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); |
| 4100 | break; |
| 4101 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4102 | case WACOM_22HD: |
| 4103 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 4104 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 4105 | __set_bit(KEY_PROG3, input_dev->keybit); |
Aaron Armstrong Skomra | 670e909 | 2019-08-16 12:02:50 -0700 | [diff] [blame] | 4106 | |
| 4107 | __set_bit(KEY_BUTTONCONFIG, input_dev->keybit); |
| 4108 | __set_bit(KEY_INFO, input_dev->keybit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 4109 | fallthrough; |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4110 | |
| 4111 | case WACOM_21UX2: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4112 | case WACOM_BEE: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4113 | case CINTIQ: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4114 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
| 4115 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
| 4116 | break; |
| 4117 | |
| 4118 | case WACOM_13HD: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4119 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4120 | break; |
| 4121 | |
| 4122 | case INTUOS3: |
| 4123 | case INTUOS3L: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4124 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 4125 | fallthrough; |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4126 | |
| 4127 | case INTUOS3S: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4128 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
| 4129 | break; |
| 4130 | |
| 4131 | case INTUOS5: |
| 4132 | case INTUOS5L: |
| 4133 | case INTUOSPM: |
| 4134 | case INTUOSPL: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4135 | case INTUOS5S: |
| 4136 | case INTUOSPS: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4137 | case INTUOSP2_BT: |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 4138 | case INTUOSP2S_BT: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4139 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4140 | break; |
| 4141 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 4142 | case INTUOS4WL: |
| 4143 | /* |
| 4144 | * For Bluetooth devices, the udev rule does not work correctly |
| 4145 | * for pads unless we add a stylus capability, which forces |
| 4146 | * ID_INPUT_TABLET to be set. |
| 4147 | */ |
| 4148 | __set_bit(BTN_STYLUS, input_dev->keybit); |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 4149 | fallthrough; |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 4150 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4151 | case INTUOS4: |
| 4152 | case INTUOS4L: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4153 | case INTUOS4S: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 4154 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4155 | break; |
| 4156 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 4157 | case INTUOSHT: |
| 4158 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4159 | case BAMBOO_TOUCH: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 4160 | case INTUOSHT2: |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 4161 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 4162 | |
| 4163 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 4164 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 4165 | __set_bit(BTN_BACK, input_dev->keybit); |
| 4166 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 4167 | |
| 4168 | break; |
| 4169 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4170 | case REMOTE: |
| 4171 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); |
| 4172 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 4173 | break; |
| 4174 | |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 4175 | case INTUOSHT3_BT: |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 4176 | case HID_GENERIC: |
| 4177 | break; |
| 4178 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4179 | default: |
| 4180 | /* no pad supported */ |
Ping Cheng | b3c8e93 | 2014-11-18 13:27:48 -0800 | [diff] [blame] | 4181 | return -ENODEV; |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 4182 | } |
| 4183 | return 0; |
| 4184 | } |
| 4185 | |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4186 | static const struct wacom_features wacom_features_0x00 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4187 | { "Wacom Penpartner", 5040, 3780, 255, 0, |
| 4188 | PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4189 | static const struct wacom_features wacom_features_0x10 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4190 | { "Wacom Graphire", 10206, 7422, 511, 63, |
| 4191 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4192 | static const struct wacom_features wacom_features_0x81 = |
| 4193 | { "Wacom Graphire BT", 16704, 12064, 511, 32, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4194 | GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4195 | static const struct wacom_features wacom_features_0x11 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4196 | { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, |
| 4197 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4198 | static const struct wacom_features wacom_features_0x12 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4199 | { "Wacom Graphire2 5x7", 13918, 10206, 511, 63, |
| 4200 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4201 | static const struct wacom_features wacom_features_0x13 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4202 | { "Wacom Graphire3", 10208, 7424, 511, 63, |
| 4203 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4204 | static const struct wacom_features wacom_features_0x14 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4205 | { "Wacom Graphire3 6x8", 16704, 12064, 511, 63, |
| 4206 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4207 | static const struct wacom_features wacom_features_0x15 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4208 | { "Wacom Graphire4 4x5", 10208, 7424, 511, 63, |
| 4209 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4210 | static const struct wacom_features wacom_features_0x16 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4211 | { "Wacom Graphire4 6x8", 16704, 12064, 511, 63, |
| 4212 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4213 | static const struct wacom_features wacom_features_0x17 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4214 | { "Wacom BambooFun 4x5", 14760, 9225, 511, 63, |
| 4215 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4216 | static const struct wacom_features wacom_features_0x18 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4217 | { "Wacom BambooFun 6x8", 21648, 13530, 511, 63, |
| 4218 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4219 | static const struct wacom_features wacom_features_0x19 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4220 | { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63, |
| 4221 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4222 | static const struct wacom_features wacom_features_0x60 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4223 | { "Wacom Volito", 5104, 3712, 511, 63, |
| 4224 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4225 | static const struct wacom_features wacom_features_0x61 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4226 | { "Wacom PenStation2", 3250, 2320, 255, 63, |
| 4227 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4228 | static const struct wacom_features wacom_features_0x62 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4229 | { "Wacom Volito2 4x5", 5104, 3712, 511, 63, |
| 4230 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4231 | static const struct wacom_features wacom_features_0x63 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4232 | { "Wacom Volito2 2x3", 3248, 2320, 511, 63, |
| 4233 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4234 | static const struct wacom_features wacom_features_0x64 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4235 | { "Wacom PenPartner2", 3250, 2320, 511, 63, |
| 4236 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4237 | static const struct wacom_features wacom_features_0x65 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4238 | { "Wacom Bamboo", 14760, 9225, 511, 63, |
| 4239 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4240 | static const struct wacom_features wacom_features_0x69 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4241 | { "Wacom Bamboo1", 5104, 3712, 511, 63, |
| 4242 | GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 4243 | static const struct wacom_features wacom_features_0x6A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4244 | { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63, |
| 4245 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 4246 | static const struct wacom_features wacom_features_0x6B = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4247 | { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63, |
| 4248 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4249 | static const struct wacom_features wacom_features_0x20 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4250 | { "Wacom Intuos 4x5", 12700, 10600, 1023, 31, |
| 4251 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4252 | static const struct wacom_features wacom_features_0x21 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4253 | { "Wacom Intuos 6x8", 20320, 16240, 1023, 31, |
| 4254 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4255 | static const struct wacom_features wacom_features_0x22 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4256 | { "Wacom Intuos 9x12", 30480, 24060, 1023, 31, |
| 4257 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4258 | static const struct wacom_features wacom_features_0x23 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4259 | { "Wacom Intuos 12x12", 30480, 31680, 1023, 31, |
| 4260 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4261 | static const struct wacom_features wacom_features_0x24 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4262 | { "Wacom Intuos 12x18", 45720, 31680, 1023, 31, |
| 4263 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4264 | static const struct wacom_features wacom_features_0x30 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4265 | { "Wacom PL400", 5408, 4056, 255, 0, |
| 4266 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4267 | static const struct wacom_features wacom_features_0x31 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4268 | { "Wacom PL500", 6144, 4608, 255, 0, |
| 4269 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4270 | static const struct wacom_features wacom_features_0x32 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4271 | { "Wacom PL600", 6126, 4604, 255, 0, |
| 4272 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4273 | static const struct wacom_features wacom_features_0x33 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4274 | { "Wacom PL600SX", 6260, 5016, 255, 0, |
| 4275 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4276 | static const struct wacom_features wacom_features_0x34 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4277 | { "Wacom PL550", 6144, 4608, 511, 0, |
| 4278 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4279 | static const struct wacom_features wacom_features_0x35 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4280 | { "Wacom PL800", 7220, 5780, 511, 0, |
| 4281 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4282 | static const struct wacom_features wacom_features_0x37 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4283 | { "Wacom PL700", 6758, 5406, 511, 0, |
| 4284 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4285 | static const struct wacom_features wacom_features_0x38 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4286 | { "Wacom PL510", 6282, 4762, 511, 0, |
| 4287 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4288 | static const struct wacom_features wacom_features_0x39 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4289 | { "Wacom DTU710", 34080, 27660, 511, 0, |
| 4290 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4291 | static const struct wacom_features wacom_features_0xC4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4292 | { "Wacom DTF521", 6282, 4762, 511, 0, |
| 4293 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4294 | static const struct wacom_features wacom_features_0xC0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4295 | { "Wacom DTF720", 6858, 5506, 511, 0, |
| 4296 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4297 | static const struct wacom_features wacom_features_0xC2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4298 | { "Wacom DTF720a", 6858, 5506, 511, 0, |
| 4299 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4300 | static const struct wacom_features wacom_features_0x03 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4301 | { "Wacom Cintiq Partner", 20480, 15360, 511, 0, |
| 4302 | PTU, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4303 | static const struct wacom_features wacom_features_0x41 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4304 | { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31, |
| 4305 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4306 | static const struct wacom_features wacom_features_0x42 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4307 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
| 4308 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4309 | static const struct wacom_features wacom_features_0x43 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4310 | { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31, |
| 4311 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4312 | static const struct wacom_features wacom_features_0x44 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4313 | { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31, |
| 4314 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4315 | static const struct wacom_features wacom_features_0x45 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4316 | { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31, |
| 4317 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4318 | static const struct wacom_features wacom_features_0xB0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4319 | { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4320 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4321 | static const struct wacom_features wacom_features_0xB1 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4322 | { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4323 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4324 | static const struct wacom_features wacom_features_0xB2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4325 | { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4326 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4327 | static const struct wacom_features wacom_features_0xB3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4328 | { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4329 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4330 | static const struct wacom_features wacom_features_0xB4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4331 | { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4332 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4333 | static const struct wacom_features wacom_features_0xB5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4334 | { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4335 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4336 | static const struct wacom_features wacom_features_0xB7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4337 | { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4338 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4339 | static const struct wacom_features wacom_features_0xB8 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4340 | { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4341 | INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4342 | static const struct wacom_features wacom_features_0xB9 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4343 | { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4344 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4345 | static const struct wacom_features wacom_features_0xBA = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4346 | { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4347 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4348 | static const struct wacom_features wacom_features_0xBB = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4349 | { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4350 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 4351 | static const struct wacom_features wacom_features_0xBC = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4352 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4353 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 4354 | static const struct wacom_features wacom_features_0xBD = |
| 4355 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4356 | INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 4357 | static const struct wacom_features wacom_features_0x26 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4358 | { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4359 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 4360 | static const struct wacom_features wacom_features_0x27 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4361 | { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4362 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 4363 | static const struct wacom_features wacom_features_0x28 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4364 | { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4365 | INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 4366 | static const struct wacom_features wacom_features_0x29 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4367 | { "Wacom Intuos5 S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4368 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 4369 | static const struct wacom_features wacom_features_0x2A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4370 | { "Wacom Intuos5 M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4371 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 4372 | static const struct wacom_features wacom_features_0x314 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4373 | { "Wacom Intuos Pro S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4374 | INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4375 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 4376 | static const struct wacom_features wacom_features_0x315 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4377 | { "Wacom Intuos Pro M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4378 | INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4379 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 4380 | static const struct wacom_features wacom_features_0x317 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4381 | { "Wacom Intuos Pro L", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4382 | INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4383 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 4384 | static const struct wacom_features wacom_features_0xF4 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4385 | { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4386 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4387 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4388 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Jason Gerecke | 6f4d038 | 2012-08-21 22:11:59 -0700 | [diff] [blame] | 4389 | static const struct wacom_features wacom_features_0xF8 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4390 | { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */ |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4391 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4392 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4393 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 3bd1f7e | 2013-05-23 10:22:33 -0700 | [diff] [blame] | 4394 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 4395 | static const struct wacom_features wacom_features_0xF6 = |
| 4396 | { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4397 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, |
| 4398 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4399 | static const struct wacom_features wacom_features_0x32A = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4400 | { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4401 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4402 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | a7e6645 | 2015-02-04 16:01:54 -0800 | [diff] [blame] | 4403 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4404 | static const struct wacom_features wacom_features_0x32B = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4405 | { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4406 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4407 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4408 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4409 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C }; |
| 4410 | static const struct wacom_features wacom_features_0x32C = |
| 4411 | { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT, |
| 4412 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4413 | static const struct wacom_features wacom_features_0x3F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4414 | { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4415 | CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4416 | static const struct wacom_features wacom_features_0xC5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4417 | { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4418 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4419 | static const struct wacom_features wacom_features_0xC6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4420 | { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4421 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4422 | static const struct wacom_features wacom_features_0x304 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4423 | { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4424 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4425 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4426 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 4427 | static const struct wacom_features wacom_features_0x333 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4428 | { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4429 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 4430 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4431 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 4432 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 }; |
| 4433 | static const struct wacom_features wacom_features_0x335 = |
| 4434 | { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */ |
| 4435 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10, |
| 4436 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4437 | static const struct wacom_features wacom_features_0xC7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4438 | { "Wacom DTU1931", 37832, 30305, 511, 0, |
| 4439 | PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 4440 | static const struct wacom_features wacom_features_0xCE = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4441 | { "Wacom DTU2231", 47864, 27011, 511, 0, |
| 4442 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4443 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE }; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 4444 | static const struct wacom_features wacom_features_0xF0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4445 | { "Wacom DTU1631", 34623, 19553, 511, 0, |
| 4446 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 4447 | static const struct wacom_features wacom_features_0xFB = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4448 | { "Wacom DTU1031", 22096, 13960, 511, 0, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4449 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4450 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4451 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 4452 | static const struct wacom_features wacom_features_0x32F = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4453 | { "Wacom DTU1031X", 22672, 12928, 511, 0, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4454 | DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4455 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 4456 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Aaron Skomra | 007760c | 2015-04-16 15:01:14 -0700 | [diff] [blame] | 4457 | static const struct wacom_features wacom_features_0x336 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4458 | { "Wacom DTU1141", 23672, 13403, 1023, 0, |
Ping Cheng | ff38e82 | 2015-11-12 17:21:14 -0800 | [diff] [blame] | 4459 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4460 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | ff38e82 | 2015-11-12 17:21:14 -0800 | [diff] [blame] | 4461 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4462 | static const struct wacom_features wacom_features_0x57 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4463 | { "Wacom DTK2241", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4464 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4465 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4466 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 4467 | static const struct wacom_features wacom_features_0x59 = /* Pen */ |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4468 | { "Wacom DTH2242", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4469 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4470 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4471 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 4472 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; |
| 4473 | static const struct wacom_features wacom_features_0x5D = /* Touch */ |
| 4474 | { "Wacom DTH2242", .type = WACOM_24HDT, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4475 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, |
| 4476 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 4477 | static const struct wacom_features wacom_features_0xCC = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4478 | { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4479 | WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4480 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4481 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 4482 | static const struct wacom_features wacom_features_0xFA = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4483 | { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4484 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4485 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4486 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4487 | static const struct wacom_features wacom_features_0x5B = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4488 | { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4489 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4490 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4491 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 3bd1f7e | 2013-05-23 10:22:33 -0700 | [diff] [blame] | 4492 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4493 | static const struct wacom_features wacom_features_0x5E = |
| 4494 | { "Wacom Cintiq 22HDT", .type = WACOM_24HDT, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4495 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10, |
| 4496 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4497 | static const struct wacom_features wacom_features_0x90 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4498 | { "Wacom ISDv4 90", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4499 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4500 | static const struct wacom_features wacom_features_0x93 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4501 | { "Wacom ISDv4 93", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4502 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 4503 | static const struct wacom_features wacom_features_0x97 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4504 | { "Wacom ISDv4 97", 26202, 16325, 511, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4505 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4506 | static const struct wacom_features wacom_features_0x9A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4507 | { "Wacom ISDv4 9A", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4508 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4509 | static const struct wacom_features wacom_features_0x9F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4510 | { "Wacom ISDv4 9F", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4511 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4512 | static const struct wacom_features wacom_features_0xE2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4513 | { "Wacom ISDv4 E2", 26202, 16325, 255, 0, |
| 4514 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4515 | static const struct wacom_features wacom_features_0xE3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4516 | { "Wacom ISDv4 E3", 26202, 16325, 255, 0, |
| 4517 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 4518 | static const struct wacom_features wacom_features_0xE5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4519 | { "Wacom ISDv4 E5", 26202, 16325, 255, 0, |
| 4520 | MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Manoj Iyer | 26fcd2a | 2011-03-31 22:39:43 -0700 | [diff] [blame] | 4521 | static const struct wacom_features wacom_features_0xE6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4522 | { "Wacom ISDv4 E6", 27760, 15694, 255, 0, |
| 4523 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Chris Bagwell | 0d0e306 | 2011-12-11 23:50:59 -0800 | [diff] [blame] | 4524 | static const struct wacom_features wacom_features_0xEC = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4525 | { "Wacom ISDv4 EC", 25710, 14500, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4526 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4527 | static const struct wacom_features wacom_features_0xED = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4528 | { "Wacom ISDv4 ED", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4529 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4530 | static const struct wacom_features wacom_features_0xEF = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4531 | { "Wacom ISDv4 EF", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4532 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4533 | static const struct wacom_features wacom_features_0x100 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4534 | { "Wacom ISDv4 100", 26202, 16325, 255, 0, |
| 4535 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4536 | static const struct wacom_features wacom_features_0x101 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4537 | { "Wacom ISDv4 101", 26202, 16325, 255, 0, |
| 4538 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Stephan Frank | 5869483 | 2013-03-07 14:08:50 -0800 | [diff] [blame] | 4539 | static const struct wacom_features wacom_features_0x10D = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4540 | { "Wacom ISDv4 10D", 26202, 16325, 255, 0, |
| 4541 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 2d3163f | 2013-10-22 15:35:30 -0700 | [diff] [blame] | 4542 | static const struct wacom_features wacom_features_0x10E = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4543 | { "Wacom ISDv4 10E", 27760, 15694, 255, 0, |
| 4544 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 9b4f60e | 2013-10-15 23:46:34 -0700 | [diff] [blame] | 4545 | static const struct wacom_features wacom_features_0x10F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4546 | { "Wacom ISDv4 10F", 27760, 15694, 255, 0, |
| 4547 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 61616ed | 2014-05-14 11:42:22 -0700 | [diff] [blame] | 4548 | static const struct wacom_features wacom_features_0x116 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4549 | { "Wacom ISDv4 116", 26202, 16325, 255, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4550 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 }; |
Jason Gerecke | aeaf50d | 2014-07-28 10:53:16 -0700 | [diff] [blame] | 4551 | static const struct wacom_features wacom_features_0x12C = |
| 4552 | { "Wacom ISDv4 12C", 27848, 15752, 2047, 0, |
Jason Gerecke | 29b9e14 | 2018-06-25 13:24:34 -0700 | [diff] [blame] | 4553 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */ |
Ping Cheng | edbe265 | 2012-11-21 13:12:50 -0800 | [diff] [blame] | 4554 | static const struct wacom_features wacom_features_0x4001 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4555 | { "Wacom ISDv4 4001", 26202, 16325, 255, 0, |
| 4556 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4557 | static const struct wacom_features wacom_features_0x4004 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4558 | { "Wacom ISDv4 4004", 11060, 6220, 255, 0, |
| 4559 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4560 | static const struct wacom_features wacom_features_0x5000 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4561 | { "Wacom ISDv4 5000", 27848, 15752, 1023, 0, |
| 4562 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4563 | static const struct wacom_features wacom_features_0x5002 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4564 | { "Wacom ISDv4 5002", 29576, 16724, 1023, 0, |
| 4565 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4566 | static const struct wacom_features wacom_features_0x47 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4567 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
| 4568 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 4569 | static const struct wacom_features wacom_features_0x84 = |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4570 | { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4571 | static const struct wacom_features wacom_features_0xD0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4572 | { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4573 | BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4574 | static const struct wacom_features wacom_features_0xD1 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4575 | { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31, |
| 4576 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4577 | static const struct wacom_features wacom_features_0xD2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4578 | { "Wacom Bamboo Craft", 14720, 9200, 1023, 31, |
| 4579 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4580 | static const struct wacom_features wacom_features_0xD3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4581 | { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31, |
| 4582 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Kevin Granade | 57a7872 | 2010-12-10 23:04:02 -0800 | [diff] [blame] | 4583 | static const struct wacom_features wacom_features_0xD4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4584 | { "Wacom Bamboo Pen", 14720, 9200, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4585 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Gerard Braad | 18adad1 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 4586 | static const struct wacom_features wacom_features_0xD5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4587 | { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4588 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4589 | static const struct wacom_features wacom_features_0xD6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4590 | { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31, |
| 4591 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4592 | static const struct wacom_features wacom_features_0xD7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4593 | { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31, |
| 4594 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4595 | static const struct wacom_features wacom_features_0xD8 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4596 | { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31, |
| 4597 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4598 | static const struct wacom_features wacom_features_0xDA = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4599 | { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31, |
| 4600 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4601 | static const struct wacom_features wacom_features_0xDB = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4602 | { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31, |
| 4603 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4604 | static const struct wacom_features wacom_features_0xDD = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4605 | { "Wacom Bamboo Connect", 14720, 9200, 1023, 31, |
| 4606 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4607 | static const struct wacom_features wacom_features_0xDE = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4608 | { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31, |
| 4609 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4610 | static const struct wacom_features wacom_features_0xDF = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4611 | { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31, |
| 4612 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4613 | static const struct wacom_features wacom_features_0x300 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4614 | { "Wacom Bamboo One S", 14720, 9225, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4615 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4616 | static const struct wacom_features wacom_features_0x301 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4617 | { "Wacom Bamboo One M", 21648, 13530, 1023, 31, |
Aaron Armstrong Skomra | b79cbc5 | 2017-03-29 13:07:36 -0700 | [diff] [blame] | 4618 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4619 | static const struct wacom_features wacom_features_0x302 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4620 | { "Wacom Intuos PT S", 15200, 9500, 1023, 31, |
| 4621 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4622 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4623 | static const struct wacom_features wacom_features_0x303 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4624 | { "Wacom Intuos PT M", 21600, 13500, 1023, 31, |
| 4625 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4626 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4627 | static const struct wacom_features wacom_features_0x30E = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4628 | { "Wacom Intuos S", 15200, 9500, 1023, 31, |
| 4629 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4630 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4631 | static const struct wacom_features wacom_features_0x6004 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4632 | { "ISD-V4", 12800, 8000, 255, 0, |
| 4633 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4634 | static const struct wacom_features wacom_features_0x307 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4635 | { "Wacom ISDv5 307", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4636 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4637 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4638 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 4639 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4640 | static const struct wacom_features wacom_features_0x309 = |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 4641 | { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4642 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, |
| 4643 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4644 | static const struct wacom_features wacom_features_0x30A = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4645 | { "Wacom ISDv5 30A", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4646 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4647 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4648 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4649 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C }; |
| 4650 | static const struct wacom_features wacom_features_0x30C = |
| 4651 | { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */ |
| 4652 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10, |
| 4653 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 4654 | static const struct wacom_features wacom_features_0x318 = |
| 4655 | { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */ |
| 4656 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
| 4657 | static const struct wacom_features wacom_features_0x319 = |
| 4658 | { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */ |
| 4659 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4660 | static const struct wacom_features wacom_features_0x325 = |
| 4661 | { "Wacom ISDv5 325", 59552, 33848, 2047, 63, |
| 4662 | CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11, |
| 4663 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4664 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4665 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 }; |
| 4666 | static const struct wacom_features wacom_features_0x326 = /* Touch */ |
| 4667 | { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM, |
| 4668 | .oPid = 0x325 }; |
Ping Cheng | fefb391 | 2014-11-11 12:52:08 -0800 | [diff] [blame] | 4669 | static const struct wacom_features wacom_features_0x323 = |
| 4670 | { "Wacom Intuos P M", 21600, 13500, 1023, 31, |
| 4671 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4672 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4673 | static const struct wacom_features wacom_features_0x331 = |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4674 | { "Wacom Express Key Remote", .type = REMOTE, |
| 4675 | .numbered_buttons = 18, .check_for_hid_type = true, |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4676 | .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 4677 | static const struct wacom_features wacom_features_0x33B = |
| 4678 | { "Wacom Intuos S 2", 15200, 9500, 2047, 63, |
| 4679 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4680 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4681 | static const struct wacom_features wacom_features_0x33C = |
| 4682 | { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63, |
| 4683 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4684 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4685 | static const struct wacom_features wacom_features_0x33D = |
| 4686 | { "Wacom Intuos P M 2", 21600, 13500, 2047, 63, |
| 4687 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4688 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4689 | static const struct wacom_features wacom_features_0x33E = |
| 4690 | { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63, |
| 4691 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4692 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4693 | static const struct wacom_features wacom_features_0x343 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4694 | { "Wacom DTK1651", 34816, 19759, 1023, 0, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4695 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4696 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4697 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4698 | static const struct wacom_features wacom_features_0x360 = |
| 4699 | { "Wacom Intuos Pro M", 44800, 29600, 8191, 63, |
Aaron Armstrong Skomra | 49cc4c2 | 2017-03-06 10:54:57 -0800 | [diff] [blame] | 4700 | INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 }; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4701 | static const struct wacom_features wacom_features_0x361 = |
| 4702 | { "Wacom Intuos Pro L", 62200, 43200, 8191, 63, |
Aaron Armstrong Skomra | 49cc4c2 | 2017-03-06 10:54:57 -0800 | [diff] [blame] | 4703 | INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 }; |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 4704 | static const struct wacom_features wacom_features_0x377 = |
| 4705 | { "Wacom Intuos BT S", 15200, 9500, 4095, 63, |
| 4706 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
| 4707 | static const struct wacom_features wacom_features_0x379 = |
| 4708 | { "Wacom Intuos BT M", 21600, 13500, 4095, 63, |
| 4709 | INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 }; |
Jason Gerecke | c947218 | 2017-12-26 15:50:18 -0800 | [diff] [blame] | 4710 | static const struct wacom_features wacom_features_0x37A = |
| 4711 | { "Wacom One by Wacom S", 15200, 9500, 2047, 63, |
| 4712 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
| 4713 | static const struct wacom_features wacom_features_0x37B = |
| 4714 | { "Wacom One by Wacom M", 21600, 13500, 2047, 63, |
| 4715 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 4716 | static const struct wacom_features wacom_features_0x393 = |
| 4717 | { "Wacom Intuos Pro S", 31920, 19950, 8191, 63, |
| 4718 | INTUOSP2S_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, |
| 4719 | .touch_max = 10 }; |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4720 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 4721 | static const struct wacom_features wacom_features_HID_ANY_ID = |
Jason Gerecke | 41372d5 | 2016-08-08 12:06:30 -0700 | [diff] [blame] | 4722 | { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID }; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 4723 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4724 | #define USB_DEVICE_WACOM(prod) \ |
| 4725 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4726 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4727 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4728 | #define BT_DEVICE_WACOM(prod) \ |
| 4729 | HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4730 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Aristeu Rozanski | 1483f55 | 2011-06-22 01:17:17 -0700 | [diff] [blame] | 4731 | |
Mika Westerberg | eef23a8 | 2015-02-23 15:52:43 +0200 | [diff] [blame] | 4732 | #define I2C_DEVICE_WACOM(prod) \ |
| 4733 | HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4734 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4735 | |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4736 | #define USB_DEVICE_LENOVO(prod) \ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4737 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ |
| 4738 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4739 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4740 | const struct hid_device_id wacom_ids[] = { |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4741 | { USB_DEVICE_WACOM(0x00) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4742 | { USB_DEVICE_WACOM(0x03) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4743 | { USB_DEVICE_WACOM(0x10) }, |
| 4744 | { USB_DEVICE_WACOM(0x11) }, |
| 4745 | { USB_DEVICE_WACOM(0x12) }, |
| 4746 | { USB_DEVICE_WACOM(0x13) }, |
| 4747 | { USB_DEVICE_WACOM(0x14) }, |
| 4748 | { USB_DEVICE_WACOM(0x15) }, |
| 4749 | { USB_DEVICE_WACOM(0x16) }, |
| 4750 | { USB_DEVICE_WACOM(0x17) }, |
| 4751 | { USB_DEVICE_WACOM(0x18) }, |
| 4752 | { USB_DEVICE_WACOM(0x19) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4753 | { USB_DEVICE_WACOM(0x20) }, |
| 4754 | { USB_DEVICE_WACOM(0x21) }, |
| 4755 | { USB_DEVICE_WACOM(0x22) }, |
| 4756 | { USB_DEVICE_WACOM(0x23) }, |
| 4757 | { USB_DEVICE_WACOM(0x24) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4758 | { USB_DEVICE_WACOM(0x26) }, |
| 4759 | { USB_DEVICE_WACOM(0x27) }, |
| 4760 | { USB_DEVICE_WACOM(0x28) }, |
| 4761 | { USB_DEVICE_WACOM(0x29) }, |
| 4762 | { USB_DEVICE_WACOM(0x2A) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4763 | { USB_DEVICE_WACOM(0x30) }, |
| 4764 | { USB_DEVICE_WACOM(0x31) }, |
| 4765 | { USB_DEVICE_WACOM(0x32) }, |
| 4766 | { USB_DEVICE_WACOM(0x33) }, |
| 4767 | { USB_DEVICE_WACOM(0x34) }, |
| 4768 | { USB_DEVICE_WACOM(0x35) }, |
| 4769 | { USB_DEVICE_WACOM(0x37) }, |
| 4770 | { USB_DEVICE_WACOM(0x38) }, |
| 4771 | { USB_DEVICE_WACOM(0x39) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4772 | { USB_DEVICE_WACOM(0x3F) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4773 | { USB_DEVICE_WACOM(0x41) }, |
| 4774 | { USB_DEVICE_WACOM(0x42) }, |
| 4775 | { USB_DEVICE_WACOM(0x43) }, |
| 4776 | { USB_DEVICE_WACOM(0x44) }, |
| 4777 | { USB_DEVICE_WACOM(0x45) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4778 | { USB_DEVICE_WACOM(0x47) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4779 | { USB_DEVICE_WACOM(0x57) }, |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 4780 | { USB_DEVICE_WACOM(0x59) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4781 | { USB_DEVICE_WACOM(0x5B) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4782 | { USB_DEVICE_WACOM(0x5D) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4783 | { USB_DEVICE_WACOM(0x5E) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4784 | { USB_DEVICE_WACOM(0x60) }, |
| 4785 | { USB_DEVICE_WACOM(0x61) }, |
| 4786 | { USB_DEVICE_WACOM(0x62) }, |
| 4787 | { USB_DEVICE_WACOM(0x63) }, |
| 4788 | { USB_DEVICE_WACOM(0x64) }, |
| 4789 | { USB_DEVICE_WACOM(0x65) }, |
| 4790 | { USB_DEVICE_WACOM(0x69) }, |
| 4791 | { USB_DEVICE_WACOM(0x6A) }, |
| 4792 | { USB_DEVICE_WACOM(0x6B) }, |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4793 | { BT_DEVICE_WACOM(0x81) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4794 | { USB_DEVICE_WACOM(0x84) }, |
| 4795 | { USB_DEVICE_WACOM(0x90) }, |
| 4796 | { USB_DEVICE_WACOM(0x93) }, |
| 4797 | { USB_DEVICE_WACOM(0x97) }, |
| 4798 | { USB_DEVICE_WACOM(0x9A) }, |
| 4799 | { USB_DEVICE_WACOM(0x9F) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4800 | { USB_DEVICE_WACOM(0xB0) }, |
| 4801 | { USB_DEVICE_WACOM(0xB1) }, |
| 4802 | { USB_DEVICE_WACOM(0xB2) }, |
| 4803 | { USB_DEVICE_WACOM(0xB3) }, |
| 4804 | { USB_DEVICE_WACOM(0xB4) }, |
| 4805 | { USB_DEVICE_WACOM(0xB5) }, |
| 4806 | { USB_DEVICE_WACOM(0xB7) }, |
| 4807 | { USB_DEVICE_WACOM(0xB8) }, |
| 4808 | { USB_DEVICE_WACOM(0xB9) }, |
| 4809 | { USB_DEVICE_WACOM(0xBA) }, |
| 4810 | { USB_DEVICE_WACOM(0xBB) }, |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 4811 | { USB_DEVICE_WACOM(0xBC) }, |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 4812 | { BT_DEVICE_WACOM(0xBD) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4813 | { USB_DEVICE_WACOM(0xC0) }, |
| 4814 | { USB_DEVICE_WACOM(0xC2) }, |
| 4815 | { USB_DEVICE_WACOM(0xC4) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4816 | { USB_DEVICE_WACOM(0xC5) }, |
| 4817 | { USB_DEVICE_WACOM(0xC6) }, |
| 4818 | { USB_DEVICE_WACOM(0xC7) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4819 | { USB_DEVICE_WACOM(0xCC) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4820 | { USB_DEVICE_WACOM(0xCE) }, |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 4821 | { USB_DEVICE_WACOM(0xD0) }, |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 4822 | { USB_DEVICE_WACOM(0xD1) }, |
| 4823 | { USB_DEVICE_WACOM(0xD2) }, |
| 4824 | { USB_DEVICE_WACOM(0xD3) }, |
Kevin Granade | 57a7872 | 2010-12-10 23:04:02 -0800 | [diff] [blame] | 4825 | { USB_DEVICE_WACOM(0xD4) }, |
Gerard Braad | 18adad1 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 4826 | { USB_DEVICE_WACOM(0xD5) }, |
Ping Cheng | d38acb4 | 2011-01-24 09:32:50 -0800 | [diff] [blame] | 4827 | { USB_DEVICE_WACOM(0xD6) }, |
| 4828 | { USB_DEVICE_WACOM(0xD7) }, |
David Foley | a318e6b | 2010-11-30 23:45:46 -0800 | [diff] [blame] | 4829 | { USB_DEVICE_WACOM(0xD8) }, |
| 4830 | { USB_DEVICE_WACOM(0xDA) }, |
David Foley | 47d0923 | 2010-12-07 21:05:59 -0800 | [diff] [blame] | 4831 | { USB_DEVICE_WACOM(0xDB) }, |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4832 | { USB_DEVICE_WACOM(0xDD) }, |
| 4833 | { USB_DEVICE_WACOM(0xDE) }, |
| 4834 | { USB_DEVICE_WACOM(0xDF) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4835 | { USB_DEVICE_WACOM(0xE2) }, |
| 4836 | { USB_DEVICE_WACOM(0xE3) }, |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 4837 | { USB_DEVICE_WACOM(0xE5) }, |
Manoj Iyer | 26fcd2a | 2011-03-31 22:39:43 -0700 | [diff] [blame] | 4838 | { USB_DEVICE_WACOM(0xE6) }, |
Chris Bagwell | 0d0e306 | 2011-12-11 23:50:59 -0800 | [diff] [blame] | 4839 | { USB_DEVICE_WACOM(0xEC) }, |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4840 | { USB_DEVICE_WACOM(0xED) }, |
| 4841 | { USB_DEVICE_WACOM(0xEF) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4842 | { USB_DEVICE_WACOM(0xF0) }, |
| 4843 | { USB_DEVICE_WACOM(0xF4) }, |
| 4844 | { USB_DEVICE_WACOM(0xF6) }, |
| 4845 | { USB_DEVICE_WACOM(0xF8) }, |
| 4846 | { USB_DEVICE_WACOM(0xFA) }, |
| 4847 | { USB_DEVICE_WACOM(0xFB) }, |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4848 | { USB_DEVICE_WACOM(0x100) }, |
| 4849 | { USB_DEVICE_WACOM(0x101) }, |
Stephan Frank | 5869483 | 2013-03-07 14:08:50 -0800 | [diff] [blame] | 4850 | { USB_DEVICE_WACOM(0x10D) }, |
Jason Gerecke | 2d3163f | 2013-10-22 15:35:30 -0700 | [diff] [blame] | 4851 | { USB_DEVICE_WACOM(0x10E) }, |
Jason Gerecke | 9b4f60e | 2013-10-15 23:46:34 -0700 | [diff] [blame] | 4852 | { USB_DEVICE_WACOM(0x10F) }, |
Jason Gerecke | 61616ed | 2014-05-14 11:42:22 -0700 | [diff] [blame] | 4853 | { USB_DEVICE_WACOM(0x116) }, |
Jason Gerecke | aeaf50d | 2014-07-28 10:53:16 -0700 | [diff] [blame] | 4854 | { USB_DEVICE_WACOM(0x12C) }, |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4855 | { USB_DEVICE_WACOM(0x300) }, |
| 4856 | { USB_DEVICE_WACOM(0x301) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4857 | { USB_DEVICE_WACOM(0x302) }, |
| 4858 | { USB_DEVICE_WACOM(0x303) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4859 | { USB_DEVICE_WACOM(0x304) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4860 | { USB_DEVICE_WACOM(0x307) }, |
| 4861 | { USB_DEVICE_WACOM(0x309) }, |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4862 | { USB_DEVICE_WACOM(0x30A) }, |
| 4863 | { USB_DEVICE_WACOM(0x30C) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4864 | { USB_DEVICE_WACOM(0x30E) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4865 | { USB_DEVICE_WACOM(0x314) }, |
| 4866 | { USB_DEVICE_WACOM(0x315) }, |
| 4867 | { USB_DEVICE_WACOM(0x317) }, |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 4868 | { USB_DEVICE_WACOM(0x318) }, |
| 4869 | { USB_DEVICE_WACOM(0x319) }, |
Ping Cheng | fefb391 | 2014-11-11 12:52:08 -0800 | [diff] [blame] | 4870 | { USB_DEVICE_WACOM(0x323) }, |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4871 | { USB_DEVICE_WACOM(0x325) }, |
| 4872 | { USB_DEVICE_WACOM(0x326) }, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4873 | { USB_DEVICE_WACOM(0x32A) }, |
| 4874 | { USB_DEVICE_WACOM(0x32B) }, |
| 4875 | { USB_DEVICE_WACOM(0x32C) }, |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 4876 | { USB_DEVICE_WACOM(0x32F) }, |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4877 | { USB_DEVICE_WACOM(0x331) }, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 4878 | { USB_DEVICE_WACOM(0x333) }, |
| 4879 | { USB_DEVICE_WACOM(0x335) }, |
Aaron Skomra | 007760c | 2015-04-16 15:01:14 -0700 | [diff] [blame] | 4880 | { USB_DEVICE_WACOM(0x336) }, |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 4881 | { USB_DEVICE_WACOM(0x33B) }, |
| 4882 | { USB_DEVICE_WACOM(0x33C) }, |
| 4883 | { USB_DEVICE_WACOM(0x33D) }, |
| 4884 | { USB_DEVICE_WACOM(0x33E) }, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4885 | { USB_DEVICE_WACOM(0x343) }, |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4886 | { BT_DEVICE_WACOM(0x360) }, |
| 4887 | { BT_DEVICE_WACOM(0x361) }, |
Aaron Armstrong Skomra | 87046b6 | 2018-03-06 10:48:33 -0800 | [diff] [blame] | 4888 | { BT_DEVICE_WACOM(0x377) }, |
| 4889 | { BT_DEVICE_WACOM(0x379) }, |
Jason Gerecke | c947218 | 2017-12-26 15:50:18 -0800 | [diff] [blame] | 4890 | { USB_DEVICE_WACOM(0x37A) }, |
| 4891 | { USB_DEVICE_WACOM(0x37B) }, |
Aaron Armstrong Skomra | 912c6aa | 2019-06-12 14:19:28 -0700 | [diff] [blame] | 4892 | { BT_DEVICE_WACOM(0x393) }, |
Ping Cheng | edbe265 | 2012-11-21 13:12:50 -0800 | [diff] [blame] | 4893 | { USB_DEVICE_WACOM(0x4001) }, |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4894 | { USB_DEVICE_WACOM(0x4004) }, |
| 4895 | { USB_DEVICE_WACOM(0x5000) }, |
| 4896 | { USB_DEVICE_WACOM(0x5002) }, |
Benjamin Tissoires | 00d6f227 | 2014-12-01 11:52:39 -0500 | [diff] [blame] | 4897 | { USB_DEVICE_LENOVO(0x6004) }, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 4898 | |
| 4899 | { USB_DEVICE_WACOM(HID_ANY_ID) }, |
Mika Westerberg | eef23a8 | 2015-02-23 15:52:43 +0200 | [diff] [blame] | 4900 | { I2C_DEVICE_WACOM(HID_ANY_ID) }, |
Jason Gerecke | b9e0625 | 2017-01-25 12:08:35 -0800 | [diff] [blame] | 4901 | { BT_DEVICE_WACOM(HID_ANY_ID) }, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 4902 | { } |
| 4903 | }; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4904 | MODULE_DEVICE_TABLE(hid, wacom_ids); |