Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1 | /* |
Dmitry Torokhov | 4104d13 | 2007-05-07 16:16:29 -0400 | [diff] [blame] | 2 | * drivers/input/tablet/wacom_wac.c |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3 | * |
Ping Cheng | ee54500 | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 4 | * USB Wacom tablet support - Wacom specific code |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 5 | * |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | */ |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 14 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 15 | #include "wacom_wac.h" |
Dmitry Torokhov | 51269fe | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 16 | #include "wacom.h" |
Henrik Rydberg | 47c78e8 | 2010-11-27 09:16:48 +0100 | [diff] [blame] | 17 | #include <linux/input/mt.h> |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 18 | |
Ping Cheng | e35fb8c | 2011-03-26 21:16:05 -0700 | [diff] [blame] | 19 | /* resolution for penabled devices */ |
| 20 | #define WACOM_PL_RES 20 |
| 21 | #define WACOM_PENPRTN_RES 40 |
| 22 | #define WACOM_VOLITO_RES 50 |
| 23 | #define WACOM_GRAPHIRE_RES 80 |
| 24 | #define WACOM_INTUOS_RES 100 |
| 25 | #define WACOM_INTUOS3_RES 200 |
| 26 | |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 27 | /* Newer Cintiq and DTU have an offset between tablet and screen areas */ |
| 28 | #define WACOM_DTU_OFFSET 200 |
| 29 | #define WACOM_CINTIQ_OFFSET 400 |
| 30 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 31 | /* |
| 32 | * Scale factor relating reported contact size to logical contact area. |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 33 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo |
| 34 | */ |
| 35 | #define WACOM_CONTACT_AREA_SCALE 2607 |
| 36 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 37 | static bool touch_arbitration = 1; |
| 38 | module_param(touch_arbitration, bool, 0644); |
| 39 | MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)"); |
| 40 | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 41 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 42 | int button_count, int mask); |
| 43 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 44 | static int wacom_numbered_button_to_key(int n); |
| 45 | |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 46 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 47 | int group); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 48 | /* |
| 49 | * Percent of battery capacity for Graphire. |
| 50 | * 8th value means AC online and show 100% capacity. |
| 51 | */ |
| 52 | static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 }; |
| 53 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 54 | /* |
| 55 | * Percent of battery capacity for Intuos4 WL, AC has a separate bit. |
| 56 | */ |
| 57 | static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; |
| 58 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 59 | static void __wacom_notify_battery(struct wacom_battery *battery, |
| 60 | int bat_capacity, bool bat_charging, |
| 61 | bool bat_connected, bool ps_connected) |
| 62 | { |
| 63 | bool changed = battery->battery_capacity != bat_capacity || |
| 64 | battery->bat_charging != bat_charging || |
| 65 | battery->bat_connected != bat_connected || |
| 66 | battery->ps_connected != ps_connected; |
| 67 | |
| 68 | if (changed) { |
| 69 | battery->battery_capacity = bat_capacity; |
| 70 | battery->bat_charging = bat_charging; |
| 71 | battery->bat_connected = bat_connected; |
| 72 | battery->ps_connected = ps_connected; |
| 73 | |
| 74 | if (battery->battery) |
| 75 | power_supply_changed(battery->battery); |
| 76 | } |
| 77 | } |
| 78 | |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 79 | static void wacom_notify_battery(struct wacom_wac *wacom_wac, |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 80 | int bat_capacity, bool bat_charging, bool bat_connected, |
| 81 | bool ps_connected) |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 82 | { |
| 83 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 84 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 85 | __wacom_notify_battery(&wacom->battery, bat_capacity, bat_charging, |
| 86 | bat_connected, ps_connected); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 89 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 90 | { |
| 91 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 92 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 93 | |
| 94 | switch (data[0]) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 95 | case 1: |
| 96 | if (data[5] & 0x80) { |
| 97 | wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 98 | wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 99 | input_report_key(input, wacom->tool[0], 1); |
| 100 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 101 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
| 102 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 103 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
| 104 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127)); |
| 105 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 106 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 107 | input_report_key(input, wacom->tool[0], 0); |
| 108 | input_report_abs(input, ABS_MISC, 0); /* report tool id */ |
| 109 | input_report_abs(input, ABS_PRESSURE, -1); |
| 110 | input_report_key(input, BTN_TOUCH, 0); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 111 | } |
| 112 | break; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 113 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 114 | case 2: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 115 | input_report_key(input, BTN_TOOL_PEN, 1); |
| 116 | input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 117 | input_report_abs(input, ABS_X, get_unaligned_le16(&data[1])); |
| 118 | input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 119 | input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127); |
| 120 | input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20)); |
| 121 | input_report_key(input, BTN_STYLUS, (data[5] & 0x40)); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 122 | break; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 123 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 124 | default: |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 125 | dev_dbg(input->dev.parent, |
| 126 | "%s: received unknown report #%d\n", __func__, data[0]); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 127 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 128 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 129 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 130 | return 1; |
| 131 | } |
| 132 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 133 | static int wacom_pl_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 134 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 135 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 136 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 137 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 138 | int prox, pressure; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 139 | |
Ping Cheng | cad7470 | 2009-12-15 00:35:25 -0800 | [diff] [blame] | 140 | if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 141 | dev_dbg(input->dev.parent, |
| 142 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | prox = data[1] & 0x40; |
| 147 | |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 148 | if (!wacom->id[0]) { |
| 149 | if ((data[0] & 0x10) || (data[4] & 0x20)) { |
| 150 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 151 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 152 | } |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 153 | else { |
| 154 | wacom->tool[0] = BTN_TOOL_PEN; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 155 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 156 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Jason Gerecke | 025bcc1 | 2015-08-03 10:18:10 -0700 | [diff] [blame] | 159 | /* If the eraser is in prox, STYLUS2 is always set. If we |
| 160 | * mis-detected the type and notice that STYLUS2 isn't set |
| 161 | * then force the eraser out of prox and let the pen in. |
| 162 | */ |
| 163 | if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) { |
| 164 | input_report_key(input, BTN_TOOL_RUBBER, 0); |
| 165 | input_report_abs(input, ABS_MISC, 0); |
| 166 | input_sync(input); |
| 167 | wacom->tool[0] = BTN_TOOL_PEN; |
| 168 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 169 | } |
| 170 | |
| 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; |
| 175 | |
| 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); |
| 179 | |
| 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 | |
| 185 | if (!prox) |
| 186 | wacom->id[0] = 0; |
| 187 | input_report_key(input, wacom->tool[0], prox); |
| 188 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 189 | return 1; |
| 190 | } |
| 191 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 192 | static int wacom_ptu_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 193 | { |
| 194 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 195 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 196 | |
Ping Cheng | cad7470 | 2009-12-15 00:35:25 -0800 | [diff] [blame] | 197 | if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 198 | dev_dbg(input->dev.parent, |
| 199 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 203 | if (data[1] & 0x04) { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 204 | input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20); |
| 205 | input_report_key(input, BTN_TOUCH, data[1] & 0x08); |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 206 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 207 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 208 | input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20); |
| 209 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 210 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 211 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 212 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 213 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 214 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
| 215 | input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6])); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 216 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 217 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 218 | return 1; |
| 219 | } |
| 220 | |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 221 | static int wacom_dtu_irq(struct wacom_wac *wacom) |
| 222 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 223 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 224 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 225 | int prox = data[1] & 0x20; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 226 | |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 227 | dev_dbg(input->dev.parent, |
| 228 | "%s: received report #%d", __func__, data[0]); |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 229 | |
| 230 | if (prox) { |
| 231 | /* Going into proximity select tool */ |
| 232 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
| 233 | if (wacom->tool[0] == BTN_TOOL_PEN) |
| 234 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 235 | else |
| 236 | wacom->id[0] = ERASER_DEVICE_ID; |
| 237 | } |
| 238 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 239 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
| 240 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 241 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 242 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]); |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 243 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
| 244 | if (!prox) /* out-prox */ |
| 245 | wacom->id[0] = 0; |
| 246 | input_report_key(input, wacom->tool[0], prox); |
| 247 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
| 248 | return 1; |
| 249 | } |
| 250 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 251 | static int wacom_dtus_irq(struct wacom_wac *wacom) |
| 252 | { |
| 253 | char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 254 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 255 | unsigned short prox, pressure = 0; |
| 256 | |
| 257 | if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { |
| 258 | dev_dbg(input->dev.parent, |
| 259 | "%s: received unknown report #%d", __func__, data[0]); |
| 260 | return 0; |
| 261 | } else if (data[0] == WACOM_REPORT_DTUSPAD) { |
Benjamin Tissoires | 422b031 | 2014-07-24 12:50:39 -0700 | [diff] [blame] | 262 | input = wacom->pad_input; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 263 | input_report_key(input, BTN_0, (data[1] & 0x01)); |
| 264 | input_report_key(input, BTN_1, (data[1] & 0x02)); |
| 265 | input_report_key(input, BTN_2, (data[1] & 0x04)); |
| 266 | input_report_key(input, BTN_3, (data[1] & 0x08)); |
| 267 | input_report_abs(input, ABS_MISC, |
| 268 | data[1] & 0x0f ? PAD_DEVICE_ID : 0); |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 269 | return 1; |
| 270 | } else { |
| 271 | prox = data[1] & 0x80; |
| 272 | if (prox) { |
| 273 | switch ((data[1] >> 3) & 3) { |
| 274 | case 1: /* Rubber */ |
| 275 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 276 | wacom->id[0] = ERASER_DEVICE_ID; |
| 277 | break; |
| 278 | |
| 279 | case 2: /* Pen */ |
| 280 | wacom->tool[0] = BTN_TOOL_PEN; |
| 281 | wacom->id[0] = STYLUS_DEVICE_ID; |
| 282 | break; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | input_report_key(input, BTN_STYLUS, data[1] & 0x20); |
| 287 | input_report_key(input, BTN_STYLUS2, data[1] & 0x40); |
| 288 | input_report_abs(input, ABS_X, get_unaligned_be16(&data[3])); |
| 289 | input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5])); |
| 290 | pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff); |
| 291 | input_report_abs(input, ABS_PRESSURE, pressure); |
| 292 | input_report_key(input, BTN_TOUCH, pressure > 10); |
| 293 | |
| 294 | if (!prox) /* out-prox */ |
| 295 | wacom->id[0] = 0; |
| 296 | input_report_key(input, wacom->tool[0], prox); |
| 297 | input_report_abs(input, ABS_MISC, wacom->id[0]); |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 298 | return 1; |
| 299 | } |
| 300 | } |
| 301 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 302 | static int wacom_graphire_irq(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 303 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 304 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 305 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 306 | struct input_dev *input = wacom->pen_input; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 307 | struct input_dev *pad_input = wacom->pad_input; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 308 | int battery_capacity, ps_connected; |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 309 | int prox; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 310 | int rw = 0; |
| 311 | int retval = 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 312 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 313 | if (features->type == GRAPHIRE_BT) { |
| 314 | if (data[0] != WACOM_REPORT_PENABLED_BT) { |
| 315 | dev_dbg(input->dev.parent, |
| 316 | "%s: received unknown report #%d\n", __func__, |
| 317 | data[0]); |
| 318 | goto exit; |
| 319 | } |
| 320 | } else if (data[0] != WACOM_REPORT_PENABLED) { |
Dmitry Torokhov | eb71d1b | 2012-05-02 00:13:38 -0700 | [diff] [blame] | 321 | dev_dbg(input->dev.parent, |
| 322 | "%s: received unknown report #%d\n", __func__, data[0]); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 323 | goto exit; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 326 | prox = data[1] & 0x80; |
| 327 | if (prox || wacom->id[0]) { |
| 328 | if (prox) { |
| 329 | switch ((data[1] >> 5) & 3) { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 330 | |
| 331 | case 0: /* Pen */ |
| 332 | wacom->tool[0] = BTN_TOOL_PEN; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 333 | wacom->id[0] = STYLUS_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 334 | break; |
| 335 | |
| 336 | case 1: /* Rubber */ |
| 337 | wacom->tool[0] = BTN_TOOL_RUBBER; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 338 | wacom->id[0] = ERASER_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 339 | break; |
| 340 | |
| 341 | case 2: /* Mouse with wheel */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 342 | input_report_key(input, BTN_MIDDLE, data[1] & 0x04); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 343 | /* fall through */ |
| 344 | |
| 345 | case 3: /* Mouse without wheel */ |
| 346 | wacom->tool[0] = BTN_TOOL_MOUSE; |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 347 | wacom->id[0] = CURSOR_DEVICE_ID; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 348 | break; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 349 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 350 | } |
Dmitry Torokhov | 252f776 | 2010-03-19 22:33:38 -0700 | [diff] [blame] | 351 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 352 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 353 | if (wacom->tool[0] != BTN_TOOL_MOUSE) { |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 354 | if (features->type == GRAPHIRE_BT) |
| 355 | input_report_abs(input, ABS_PRESSURE, data[6] | |
| 356 | (((__u16) (data[1] & 0x08)) << 5)); |
| 357 | else |
| 358 | input_report_abs(input, ABS_PRESSURE, data[6] | |
| 359 | ((data[7] & 0x03) << 8)); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 360 | input_report_key(input, BTN_TOUCH, data[1] & 0x01); |
| 361 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 362 | input_report_key(input, BTN_STYLUS2, data[1] & 0x04); |
Dmitry Torokhov | afb567e | 2010-04-13 23:08:58 -0700 | [diff] [blame] | 363 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 364 | input_report_key(input, BTN_LEFT, data[1] & 0x01); |
| 365 | input_report_key(input, BTN_RIGHT, data[1] & 0x02); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 366 | if (features->type == WACOM_G4 || |
| 367 | features->type == WACOM_MO) { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 368 | input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f); |
Mike Auty | d9f66c1 | 2010-08-28 20:35:17 -0700 | [diff] [blame] | 369 | rw = (data[7] & 0x04) - (data[7] & 0x03); |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 370 | } else if (features->type == GRAPHIRE_BT) { |
| 371 | /* Compute distance between mouse and tablet */ |
| 372 | rw = 44 - (data[6] >> 2); |
| 373 | rw = clamp_val(rw, 0, 31); |
| 374 | input_report_abs(input, ABS_DISTANCE, rw); |
| 375 | if (((data[1] >> 5) & 3) == 2) { |
| 376 | /* Mouse with wheel */ |
| 377 | input_report_key(input, BTN_MIDDLE, |
| 378 | data[1] & 0x04); |
| 379 | rw = (data[6] & 0x01) ? -1 : |
| 380 | (data[6] & 0x02) ? 1 : 0; |
| 381 | } else { |
| 382 | rw = 0; |
| 383 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 384 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 385 | input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f); |
Mike Auty | d9f66c1 | 2010-08-28 20:35:17 -0700 | [diff] [blame] | 386 | rw = -(signed char)data[6]; |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 387 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 388 | input_report_rel(input, REL_WHEEL, rw); |
Dmitry Torokhov | afb567e | 2010-04-13 23:08:58 -0700 | [diff] [blame] | 389 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 390 | |
| 391 | if (!prox) |
| 392 | wacom->id[0] = 0; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 393 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */ |
| 394 | input_report_key(input, wacom->tool[0], prox); |
| 395 | input_sync(input); /* sync last event */ |
Ping Cheng | 80d4e8e | 2007-02-23 12:22:48 -0800 | [diff] [blame] | 396 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 397 | |
| 398 | /* send pad data */ |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 399 | switch (features->type) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 400 | case WACOM_G4: |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 401 | prox = data[7] & 0xf8; |
| 402 | if (prox || wacom->id[1]) { |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 403 | wacom->id[1] = PAD_DEVICE_ID; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 404 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x40)); |
| 405 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80)); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 406 | rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 407 | input_report_rel(pad_input, REL_WHEEL, rw); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 408 | if (!prox) |
| 409 | wacom->id[1] = 0; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 410 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
Ping Cheng | ab687b1 | 2010-04-05 23:07:41 -0700 | [diff] [blame] | 411 | retval = 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 412 | } |
Ping Cheng | 7ecfbfd | 2007-06-14 23:32:48 -0400 | [diff] [blame] | 413 | break; |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 414 | |
| 415 | case WACOM_MO: |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 416 | prox = (data[7] & 0xf8) || data[8]; |
| 417 | if (prox || wacom->id[1]) { |
Ping Cheng | e34b9d2 | 2008-05-05 11:36:41 -0400 | [diff] [blame] | 418 | wacom->id[1] = PAD_DEVICE_ID; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 419 | input_report_key(pad_input, BTN_BACK, (data[7] & 0x08)); |
| 420 | input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20)); |
| 421 | input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10)); |
| 422 | input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40)); |
| 423 | input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f)); |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 424 | if (!prox) |
| 425 | wacom->id[1] = 0; |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 426 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
Ping Cheng | 8446001 | 2011-07-06 18:05:43 -0700 | [diff] [blame] | 427 | retval = 1; |
Ping Cheng | 7ecfbfd | 2007-06-14 23:32:48 -0400 | [diff] [blame] | 428 | } |
| 429 | break; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 430 | case GRAPHIRE_BT: |
| 431 | prox = data[7] & 0x03; |
| 432 | if (prox || wacom->id[1]) { |
| 433 | wacom->id[1] = PAD_DEVICE_ID; |
| 434 | input_report_key(pad_input, BTN_0, (data[7] & 0x02)); |
| 435 | input_report_key(pad_input, BTN_1, (data[7] & 0x01)); |
| 436 | if (!prox) |
| 437 | wacom->id[1] = 0; |
| 438 | input_report_abs(pad_input, ABS_MISC, wacom->id[1]); |
| 439 | retval = 1; |
| 440 | } |
| 441 | break; |
| 442 | } |
| 443 | |
| 444 | /* Store current battery capacity and power supply state */ |
| 445 | if (features->type == GRAPHIRE_BT) { |
| 446 | rw = (data[7] >> 2 & 0x07); |
| 447 | battery_capacity = batcap_gr[rw]; |
| 448 | ps_connected = rw == 7; |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 449 | wacom_notify_battery(wacom, battery_capacity, ps_connected, |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 450 | 1, ps_connected); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 451 | } |
Ping Cheng | 3b57ca0 | 2010-03-04 21:50:59 -0800 | [diff] [blame] | 452 | exit: |
| 453 | return retval; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 454 | } |
| 455 | |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 456 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) |
| 457 | { |
| 458 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 0bbfe28 | 2016-01-06 13:25:53 -0800 | [diff] [blame] | 459 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 460 | struct hid_report *r; |
| 461 | struct hid_report_enum *re; |
| 462 | |
| 463 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); |
Jason Gerecke | 0bbfe28 | 2016-01-06 13:25:53 -0800 | [diff] [blame] | 464 | if (features->type == INTUOSHT2) |
| 465 | r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; |
| 466 | else |
| 467 | r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; |
Benjamin Tissoires | 5fcad16 | 2015-03-05 17:36:54 -0500 | [diff] [blame] | 468 | if (r) { |
| 469 | hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); |
| 470 | } |
| 471 | } |
| 472 | |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 473 | static int wacom_intuos_pad(struct wacom_wac *wacom) |
| 474 | { |
| 475 | struct wacom_features *features = &wacom->features; |
| 476 | unsigned char *data = wacom->data; |
| 477 | struct input_dev *input = wacom->pad_input; |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 478 | int i; |
| 479 | int buttons = 0, nbuttons = features->numbered_buttons; |
| 480 | int keys = 0, nkeys = 0; |
| 481 | int ring1 = 0, ring2 = 0; |
| 482 | int strip1 = 0, strip2 = 0; |
| 483 | bool prox = false; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 484 | |
| 485 | /* pad packets. Works as a second tool and is always in prox */ |
| 486 | if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || |
| 487 | data[0] == WACOM_REPORT_CINTIQPAD)) |
| 488 | return 0; |
| 489 | |
| 490 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 491 | buttons = (data[3] << 1) | (data[2] & 0x01); |
| 492 | ring1 = data[1]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 493 | } else if (features->type == DTK) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 494 | buttons = data[6]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 495 | } else if (features->type == WACOM_13HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 496 | buttons = (data[4] << 1) | (data[3] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 497 | } else if (features->type == WACOM_24HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 498 | buttons = (data[8] << 8) | data[6]; |
| 499 | ring1 = data[1]; |
| 500 | ring2 = data[2]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 501 | |
| 502 | /* |
| 503 | * Three "buttons" are available on the 24HD which are |
| 504 | * physically implemented as a touchstrip. Each button |
| 505 | * is approximately 3 bits wide with a 2 bit spacing. |
| 506 | * The raw touchstrip bits are stored at: |
| 507 | * ((data[3] & 0x1f) << 8) | data[4]) |
| 508 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 509 | nkeys = 3; |
| 510 | keys = ((data[3] & 0x1C) ? 1<<2 : 0) | |
| 511 | ((data[4] & 0xE0) ? 1<<1 : 0) | |
| 512 | ((data[4] & 0x07) ? 1<<0 : 0); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 513 | } else if (features->type == WACOM_27QHD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 514 | nkeys = 3; |
| 515 | keys = data[2] & 0x07; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 516 | |
| 517 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); |
| 518 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); |
| 519 | input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 520 | } else if (features->type == CINTIQ_HYBRID) { |
| 521 | /* |
| 522 | * Do not send hardware buttons under Android. They |
| 523 | * are already sent to the system through GPIO (and |
| 524 | * have different meaning). |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 525 | * |
| 526 | * d-pad right -> data[4] & 0x10 |
| 527 | * d-pad up -> data[4] & 0x20 |
| 528 | * d-pad left -> data[4] & 0x40 |
| 529 | * d-pad down -> data[4] & 0x80 |
| 530 | * d-pad center -> data[3] & 0x01 |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 531 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 532 | buttons = (data[4] << 1) | (data[3] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 533 | } else if (features->type == CINTIQ_COMPANION_2) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 534 | /* d-pad right -> data[4] & 0x10 |
| 535 | * d-pad up -> data[4] & 0x20 |
| 536 | * d-pad left -> data[4] & 0x40 |
| 537 | * d-pad down -> data[4] & 0x80 |
| 538 | * d-pad center -> data[3] & 0x01 |
| 539 | */ |
Jason Gerecke | 0402b6b | 2015-12-16 13:37:36 -0800 | [diff] [blame] | 540 | buttons = ((data[2] >> 4) << 7) | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 541 | ((data[1] & 0x04) << 6) | |
| 542 | ((data[2] & 0x0F) << 2) | |
| 543 | (data[1] & 0x03); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 544 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 545 | /* |
| 546 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in |
| 547 | * addition to the mechanical switch. Switch data is |
| 548 | * stored in data[4], capacitive data in data[5]. |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 549 | * |
| 550 | * Touch ring mode switch (data[3]) has no capacitive sensor |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 551 | */ |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 552 | buttons = (data[4] << 1) | (data[3] & 0x01); |
| 553 | ring1 = data[2]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 554 | } else { |
| 555 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 556 | buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) | |
| 557 | (data[6] << 1) | (data[5] & 0x01); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 558 | |
| 559 | if (features->type == WACOM_22HD) { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 560 | nkeys = 3; |
| 561 | keys = data[9] & 0x07; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 562 | } |
| 563 | } else { |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 564 | buttons = ((data[6] & 0x10) << 10) | |
| 565 | ((data[5] & 0x10) << 9) | |
| 566 | ((data[6] & 0x0F) << 4) | |
| 567 | (data[5] & 0x0F); |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 568 | } |
Jason Gerecke | f73d08d | 2015-12-16 13:37:33 -0800 | [diff] [blame] | 569 | strip1 = ((data[1] & 0x1f) << 8) | data[2]; |
| 570 | strip2 = ((data[3] & 0x1f) << 8) | data[4]; |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 571 | } |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 572 | |
Dan Carpenter | 8f9cfdd | 2015-12-09 13:22:05 +0300 | [diff] [blame] | 573 | prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) | |
| 574 | (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2; |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 575 | |
| 576 | wacom_report_numbered_buttons(input, nbuttons, buttons); |
| 577 | |
| 578 | for (i = 0; i < nkeys; i++) |
| 579 | input_report_key(input, KEY_PROG1 + i, keys & (1 << i)); |
| 580 | |
| 581 | input_report_abs(input, ABS_RX, strip1); |
Jason Gerecke | 03a0dc5 | 2015-12-16 13:37:34 -0800 | [diff] [blame] | 582 | input_report_abs(input, ABS_RY, strip2); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 583 | |
Jason Gerecke | aaae03e | 2015-12-16 13:37:35 -0800 | [diff] [blame] | 584 | input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0); |
| 585 | input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 586 | |
| 587 | input_report_key(input, wacom->tool[1], prox ? 1 : 0); |
| 588 | input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); |
| 589 | |
| 590 | input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); |
| 591 | |
Jason Gerecke | fb013a0 | 2015-11-30 17:13:46 -0800 | [diff] [blame] | 592 | return 1; |
| 593 | } |
| 594 | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 595 | static int wacom_intuos_id_mangle(int tool_id) |
| 596 | { |
| 597 | return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); |
| 598 | } |
| 599 | |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 600 | static int wacom_intuos_get_tool_type(int tool_id) |
| 601 | { |
| 602 | int tool_type; |
| 603 | |
| 604 | switch (tool_id) { |
| 605 | case 0x812: /* Inking pen */ |
| 606 | case 0x801: /* Intuos3 Inking pen */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 607 | case 0x12802: /* Intuos4/5 Inking Pen */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 608 | case 0x012: |
| 609 | tool_type = BTN_TOOL_PENCIL; |
| 610 | break; |
| 611 | |
| 612 | case 0x822: /* Pen */ |
| 613 | case 0x842: |
| 614 | case 0x852: |
| 615 | case 0x823: /* Intuos3 Grip Pen */ |
| 616 | case 0x813: /* Intuos3 Classic Pen */ |
| 617 | case 0x885: /* Intuos3 Marker Pen */ |
| 618 | case 0x802: /* Intuos4/5 13HD/24HD General Pen */ |
| 619 | case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ |
| 620 | case 0x8e2: /* IntuosHT2 pen */ |
| 621 | case 0x022: |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 622 | case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ |
| 623 | case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ |
| 624 | case 0x16802: /* Cintiq 13HD Pro Pen */ |
| 625 | case 0x18802: /* DTH2242 Pen */ |
| 626 | case 0x10802: /* Intuos4/5 13HD/24HD General Pen */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 627 | tool_type = BTN_TOOL_PEN; |
| 628 | break; |
| 629 | |
| 630 | case 0x832: /* Stroke pen */ |
| 631 | case 0x032: |
| 632 | tool_type = BTN_TOOL_BRUSH; |
| 633 | break; |
| 634 | |
| 635 | case 0x007: /* Mouse 4D and 2D */ |
| 636 | case 0x09c: |
| 637 | case 0x094: |
| 638 | case 0x017: /* Intuos3 2D Mouse */ |
| 639 | case 0x806: /* Intuos4 Mouse */ |
| 640 | tool_type = BTN_TOOL_MOUSE; |
| 641 | break; |
| 642 | |
| 643 | case 0x096: /* Lens cursor */ |
| 644 | case 0x097: /* Intuos3 Lens cursor */ |
| 645 | case 0x006: /* Intuos4 Lens cursor */ |
| 646 | tool_type = BTN_TOOL_LENS; |
| 647 | break; |
| 648 | |
| 649 | case 0x82a: /* Eraser */ |
Jason Gerecke | 9ce9a12 | 2016-11-11 15:05:52 -0800 | [diff] [blame] | 650 | case 0x84a: |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 651 | case 0x85a: |
| 652 | case 0x91a: |
| 653 | case 0xd1a: |
| 654 | case 0x0fa: |
| 655 | case 0x82b: /* Intuos3 Grip Pen Eraser */ |
| 656 | case 0x81b: /* Intuos3 Classic Pen Eraser */ |
| 657 | case 0x91b: /* Intuos3 Airbrush Eraser */ |
| 658 | case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */ |
| 659 | case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */ |
| 660 | case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 661 | case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */ |
| 662 | case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */ |
| 663 | case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */ |
| 664 | case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */ |
| 665 | case 0x1880a: /* DTH2242 Eraser */ |
| 666 | case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 667 | tool_type = BTN_TOOL_RUBBER; |
| 668 | break; |
| 669 | |
| 670 | case 0xd12: |
| 671 | case 0x912: |
| 672 | case 0x112: |
| 673 | case 0x913: /* Intuos3 Airbrush */ |
| 674 | case 0x902: /* Intuos4/5 13HD/24HD Airbrush */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 675 | case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 676 | tool_type = BTN_TOOL_AIRBRUSH; |
| 677 | break; |
| 678 | |
| 679 | default: /* Unknown tool */ |
| 680 | tool_type = BTN_TOOL_PEN; |
| 681 | break; |
| 682 | } |
| 683 | return tool_type; |
| 684 | } |
| 685 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 686 | static int wacom_intuos_inout(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 687 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 688 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 689 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 690 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 691 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 692 | |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 693 | if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */ |
| 694 | ((data[1] & 0xfe) == 0x20) || /* in range */ |
| 695 | ((data[1] & 0xfe) == 0x80))) /* out prox */ |
| 696 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 697 | |
| 698 | /* Enter report */ |
| 699 | if ((data[1] & 0xfc) == 0xc0) { |
| 700 | /* serial number of the tool */ |
| 701 | wacom->serial[idx] = ((data[3] & 0x0f) << 28) + |
| 702 | (data[4] << 20) + (data[5] << 12) + |
| 703 | (data[6] << 4) + (data[7] >> 4); |
| 704 | |
Ping Cheng | 493630b | 2010-06-22 11:21:34 -0700 | [diff] [blame] | 705 | wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 706 | ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 707 | |
Benjamin Tissoires | 7e12978 | 2016-02-12 17:27:40 +0100 | [diff] [blame] | 708 | wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 709 | |
Ping Cheng | eff6ca9 | 2016-05-02 21:17:34 -0700 | [diff] [blame] | 710 | wacom->shared->stylus_in_proximity = true; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 711 | return 1; |
| 712 | } |
| 713 | |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 714 | /* in Range */ |
| 715 | if ((data[1] & 0xfe) == 0x20) { |
Ping Cheng | 526d6e7 | 2016-01-08 17:16:25 -0800 | [diff] [blame] | 716 | if (features->type != INTUOSHT2) |
| 717 | wacom->shared->stylus_in_proximity = true; |
Ping Cheng | 486b908 | 2015-02-20 14:25:58 -0800 | [diff] [blame] | 718 | |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 719 | /* in Range while exiting */ |
| 720 | if (wacom->reporting_data) { |
| 721 | input_report_key(input, BTN_TOUCH, 0); |
| 722 | input_report_abs(input, ABS_PRESSURE, 0); |
| 723 | input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max); |
| 724 | return 2; |
| 725 | } |
| 726 | return 1; |
Jason Gerecke | 4eb1830 | 2013-09-20 09:48:46 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 729 | /* Exit report */ |
| 730 | if ((data[1] & 0xfe) == 0x80) { |
Ping Cheng | f3586d2 | 2015-03-20 14:57:00 -0700 | [diff] [blame] | 731 | wacom->shared->stylus_in_proximity = false; |
Ping Cheng | b3bd7ef | 2015-01-09 11:05:13 -0800 | [diff] [blame] | 732 | wacom->reporting_data = false; |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 733 | |
Ping Cheng | 373a535 | 2015-01-09 11:04:50 -0800 | [diff] [blame] | 734 | /* don't report exit if we don't know the ID */ |
| 735 | if (!wacom->id[idx]) |
| 736 | return 1; |
| 737 | |
Ping Cheng | 6f660f1 | 2009-05-08 18:30:33 -0700 | [diff] [blame] | 738 | /* |
| 739 | * Reset all states otherwise we lose the initial states |
| 740 | * when in-prox next time |
| 741 | */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 742 | input_report_abs(input, ABS_X, 0); |
| 743 | input_report_abs(input, ABS_Y, 0); |
| 744 | input_report_abs(input, ABS_DISTANCE, 0); |
| 745 | input_report_abs(input, ABS_TILT_X, 0); |
| 746 | input_report_abs(input, ABS_TILT_Y, 0); |
Ping Cheng | 80d4e8e | 2007-02-23 12:22:48 -0800 | [diff] [blame] | 747 | if (wacom->tool[idx] >= BTN_TOOL_MOUSE) { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 748 | input_report_key(input, BTN_LEFT, 0); |
| 749 | input_report_key(input, BTN_MIDDLE, 0); |
| 750 | input_report_key(input, BTN_RIGHT, 0); |
| 751 | input_report_key(input, BTN_SIDE, 0); |
| 752 | input_report_key(input, BTN_EXTRA, 0); |
| 753 | input_report_abs(input, ABS_THROTTLE, 0); |
| 754 | input_report_abs(input, ABS_RZ, 0); |
Ping Cheng | 7ecfbfd | 2007-06-14 23:32:48 -0400 | [diff] [blame] | 755 | } else { |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 756 | input_report_abs(input, ABS_PRESSURE, 0); |
| 757 | input_report_key(input, BTN_STYLUS, 0); |
| 758 | input_report_key(input, BTN_STYLUS2, 0); |
| 759 | input_report_key(input, BTN_TOUCH, 0); |
| 760 | input_report_abs(input, ABS_WHEEL, 0); |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 761 | if (features->type >= INTUOS3S) |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 762 | input_report_abs(input, ABS_Z, 0); |
Ping Cheng | 8d32e3a | 2006-09-26 13:34:47 -0700 | [diff] [blame] | 763 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 764 | input_report_key(input, wacom->tool[idx], 0); |
| 765 | input_report_abs(input, ABS_MISC, 0); /* reset tool id */ |
| 766 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
Ping Cheng | 6f660f1 | 2009-05-08 18:30:33 -0700 | [diff] [blame] | 767 | wacom->id[idx] = 0; |
Ping Cheng | 80d4e8e | 2007-02-23 12:22:48 -0800 | [diff] [blame] | 768 | return 2; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 769 | } |
Ping Cheng | 373a535 | 2015-01-09 11:04:50 -0800 | [diff] [blame] | 770 | |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 771 | return 0; |
| 772 | } |
| 773 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 774 | static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len) |
| 775 | { |
| 776 | unsigned char *data = wacom_wac->data; |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 777 | struct input_dev *input; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 778 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 779 | struct wacom_remote *remote = wacom->remote; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 780 | int bat_charging, bat_percent, touch_ring_mode; |
| 781 | __u32 serial; |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 782 | int i, index = -1; |
| 783 | unsigned long flags; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 784 | |
| 785 | if (data[0] != WACOM_REPORT_REMOTE) { |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 786 | hid_dbg(wacom->hdev, "%s: received unknown report #%d", |
| 787 | __func__, data[0]); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | serial = data[3] + (data[4] << 8) + (data[5] << 16); |
| 792 | wacom_wac->id[0] = PAD_DEVICE_ID; |
| 793 | |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 794 | spin_lock_irqsave(&remote->remote_lock, flags); |
| 795 | |
| 796 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 797 | if (remote->remotes[i].serial == serial) { |
| 798 | index = i; |
| 799 | break; |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | if (index < 0 || !remote->remotes[index].registered) |
| 804 | goto out; |
| 805 | |
| 806 | input = remote->remotes[index].input; |
| 807 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 808 | input_report_key(input, BTN_0, (data[9] & 0x01)); |
| 809 | input_report_key(input, BTN_1, (data[9] & 0x02)); |
| 810 | input_report_key(input, BTN_2, (data[9] & 0x04)); |
| 811 | input_report_key(input, BTN_3, (data[9] & 0x08)); |
| 812 | input_report_key(input, BTN_4, (data[9] & 0x10)); |
| 813 | input_report_key(input, BTN_5, (data[9] & 0x20)); |
| 814 | input_report_key(input, BTN_6, (data[9] & 0x40)); |
| 815 | input_report_key(input, BTN_7, (data[9] & 0x80)); |
| 816 | |
| 817 | input_report_key(input, BTN_8, (data[10] & 0x01)); |
| 818 | input_report_key(input, BTN_9, (data[10] & 0x02)); |
| 819 | input_report_key(input, BTN_A, (data[10] & 0x04)); |
| 820 | input_report_key(input, BTN_B, (data[10] & 0x08)); |
| 821 | input_report_key(input, BTN_C, (data[10] & 0x10)); |
| 822 | input_report_key(input, BTN_X, (data[10] & 0x20)); |
| 823 | input_report_key(input, BTN_Y, (data[10] & 0x40)); |
| 824 | input_report_key(input, BTN_Z, (data[10] & 0x80)); |
| 825 | |
| 826 | input_report_key(input, BTN_BASE, (data[11] & 0x01)); |
| 827 | input_report_key(input, BTN_BASE2, (data[11] & 0x02)); |
| 828 | |
| 829 | if (data[12] & 0x80) |
| 830 | input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f)); |
| 831 | else |
| 832 | input_report_abs(input, ABS_WHEEL, 0); |
| 833 | |
| 834 | bat_percent = data[7] & 0x7f; |
| 835 | bat_charging = !!(data[7] & 0x80); |
| 836 | |
| 837 | if (data[9] | data[10] | (data[11] & 0x03) | data[12]) |
| 838 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); |
| 839 | else |
| 840 | input_report_abs(input, ABS_MISC, 0); |
| 841 | |
| 842 | input_event(input, EV_MSC, MSC_SERIAL, serial); |
| 843 | |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 844 | input_sync(input); |
| 845 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 846 | /*Which mode select (LED light) is currently on?*/ |
| 847 | touch_ring_mode = (data[11] & 0xC0) >> 6; |
| 848 | |
| 849 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
Benjamin Tissoires | e7749f6 | 2016-07-13 18:06:06 +0200 | [diff] [blame] | 850 | if (remote->remotes[i].serial == serial) |
Benjamin Tissoires | a50aac7 | 2016-07-13 18:06:00 +0200 | [diff] [blame] | 851 | wacom->led.groups[i].select = touch_ring_mode; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 852 | } |
| 853 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 854 | __wacom_notify_battery(&remote->remotes[index].battery, bat_percent, |
| 855 | bat_charging, 1, bat_charging); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 856 | |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 857 | out: |
| 858 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
| 859 | return 0; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 860 | } |
| 861 | |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 862 | static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 863 | { |
| 864 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 865 | unsigned char *data = wacom_wac->data; |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 866 | struct wacom_remote *remote = wacom->remote; |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 867 | struct wacom_remote_data remote_data; |
| 868 | unsigned long flags; |
| 869 | int i, ret; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 870 | |
| 871 | if (data[0] != WACOM_REPORT_DEVICE_LIST) |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 872 | return; |
| 873 | |
| 874 | memset(&remote_data, 0, sizeof(struct wacom_remote_data)); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 875 | |
| 876 | for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
| 877 | int j = i * 6; |
| 878 | int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4]; |
| 879 | bool connected = data[j+2]; |
| 880 | |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 881 | remote_data.remote[i].serial = serial; |
| 882 | remote_data.remote[i].connected = connected; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 883 | } |
| 884 | |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 885 | spin_lock_irqsave(&remote->remote_lock, flags); |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 886 | |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 887 | ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data)); |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 888 | if (ret != sizeof(remote_data)) { |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 889 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 890 | hid_err(wacom->hdev, "Can't queue Remote status event.\n"); |
| 891 | return; |
| 892 | } |
| 893 | |
Benjamin Tissoires | 83e6b40 | 2016-07-13 18:06:02 +0200 | [diff] [blame] | 894 | spin_unlock_irqrestore(&remote->remote_lock, flags); |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 895 | |
| 896 | wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 897 | } |
| 898 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 899 | static inline bool report_touch_events(struct wacom_wac *wacom) |
| 900 | { |
| 901 | return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1); |
| 902 | } |
| 903 | |
| 904 | static inline bool delay_pen_events(struct wacom_wac *wacom) |
| 905 | { |
| 906 | return (wacom->shared->touch_down && touch_arbitration); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 907 | } |
| 908 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 909 | static int wacom_intuos_general(struct wacom_wac *wacom) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 910 | { |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 911 | struct wacom_features *features = &wacom->features; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 912 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 913 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 914 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 915 | unsigned char type = (data[1] >> 1) & 0x0F; |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 916 | unsigned int x, y, distance, t; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 917 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 918 | if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && |
| 919 | data[0] != WACOM_REPORT_INTUOS_PEN) |
| 920 | return 0; |
| 921 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 922 | if (delay_pen_events(wacom)) |
Ping Cheng | c1b03f5 | 2016-01-08 17:16:06 -0800 | [diff] [blame] | 923 | return 1; |
| 924 | |
Ping Cheng | 599b082 | 2016-01-08 17:14:54 -0800 | [diff] [blame] | 925 | /* don't report events if we don't know the tool ID */ |
| 926 | if (!wacom->id[idx]) { |
| 927 | /* but reschedule a read of the current tool */ |
| 928 | wacom_intuos_schedule_prox_event(wacom); |
| 929 | return 1; |
| 930 | } |
| 931 | |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 932 | /* |
| 933 | * don't report events for invalid data |
| 934 | */ |
| 935 | /* older I4 styli don't work with new Cintiqs */ |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 936 | if ((!((wacom->id[idx] >> 16) & 0x01) && |
Ping Cheng | 4750f5f | 2016-01-08 17:15:48 -0800 | [diff] [blame] | 937 | (features->type == WACOM_21UX2)) || |
| 938 | /* Only large Intuos support Lense Cursor */ |
| 939 | (wacom->tool[idx] == BTN_TOOL_LENS && |
| 940 | (features->type == INTUOS3 || |
| 941 | features->type == INTUOS3S || |
| 942 | features->type == INTUOS4 || |
| 943 | features->type == INTUOS4S || |
| 944 | features->type == INTUOS5 || |
| 945 | features->type == INTUOS5S || |
| 946 | features->type == INTUOSPM || |
| 947 | features->type == INTUOSPS)) || |
| 948 | /* Cintiq doesn't send data when RDY bit isn't set */ |
| 949 | (features->type == CINTIQ && !(data[1] & 0x40))) |
| 950 | return 1; |
| 951 | |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 952 | x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); |
| 953 | y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1); |
| 954 | distance = data[9] >> 2; |
| 955 | if (features->type < INTUOS3S) { |
| 956 | x >>= 1; |
| 957 | y >>= 1; |
| 958 | distance >>= 1; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 959 | } |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 960 | input_report_abs(input, ABS_X, x); |
| 961 | input_report_abs(input, ABS_Y, y); |
| 962 | input_report_abs(input, ABS_DISTANCE, distance); |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 963 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 964 | switch (type) { |
| 965 | case 0x00: |
| 966 | case 0x01: |
| 967 | case 0x02: |
| 968 | case 0x03: |
| 969 | /* general pen packet */ |
Jason Gerecke | 5f33f43 | 2015-11-30 17:13:51 -0800 | [diff] [blame] | 970 | t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1); |
| 971 | if (features->pressure_max < 2047) |
| 972 | t >>= 1; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 973 | input_report_abs(input, ABS_PRESSURE, t); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 974 | if (features->type != INTUOSHT2) { |
| 975 | input_report_abs(input, ABS_TILT_X, |
Jason Gerecke | ec5fc1c | 2014-11-18 16:50:08 -0800 | [diff] [blame] | 976 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 977 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
| 978 | } |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 979 | input_report_key(input, BTN_STYLUS, data[1] & 2); |
| 980 | input_report_key(input, BTN_STYLUS2, data[1] & 4); |
| 981 | input_report_key(input, BTN_TOUCH, t > 10); |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 982 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 983 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 984 | case 0x0a: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 985 | /* airbrush second packet */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 986 | input_report_abs(input, ABS_WHEEL, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 987 | (data[6] << 2) | ((data[7] >> 6) & 3)); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 988 | input_report_abs(input, ABS_TILT_X, |
Jason Gerecke | ec5fc1c | 2014-11-18 16:50:08 -0800 | [diff] [blame] | 989 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 990 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 991 | break; |
| 992 | |
| 993 | case 0x05: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 994 | /* Rotation packet */ |
| 995 | if (features->type >= INTUOS3S) { |
| 996 | /* I3 marker pen rotation */ |
| 997 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 998 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : |
| 999 | ((t-1) / 2 + 450)) : (450 - t / 2) ; |
| 1000 | input_report_abs(input, ABS_Z, t); |
| 1001 | } else { |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1002 | /* 4D mouse 2nd packet */ |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1003 | t = (data[6] << 3) | ((data[7] >> 5) & 7); |
| 1004 | input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? |
| 1005 | ((t - 1) / 2) : -t / 2); |
| 1006 | } |
| 1007 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1008 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1009 | case 0x04: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1010 | /* 4D mouse 1st packet */ |
| 1011 | input_report_key(input, BTN_LEFT, data[8] & 0x01); |
| 1012 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); |
| 1013 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); |
| 1014 | |
| 1015 | input_report_key(input, BTN_SIDE, data[8] & 0x20); |
| 1016 | input_report_key(input, BTN_EXTRA, data[8] & 0x10); |
| 1017 | t = (data[6] << 2) | ((data[7] >> 6) & 3); |
| 1018 | input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); |
| 1019 | break; |
| 1020 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1021 | case 0x06: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1022 | /* I4 mouse */ |
| 1023 | input_report_key(input, BTN_LEFT, data[6] & 0x01); |
| 1024 | input_report_key(input, BTN_MIDDLE, data[6] & 0x02); |
| 1025 | input_report_key(input, BTN_RIGHT, data[6] & 0x04); |
| 1026 | input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) |
| 1027 | - ((data[7] & 0x40) >> 6)); |
| 1028 | input_report_key(input, BTN_SIDE, data[6] & 0x08); |
| 1029 | input_report_key(input, BTN_EXTRA, data[6] & 0x10); |
| 1030 | |
| 1031 | input_report_abs(input, ABS_TILT_X, |
| 1032 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 1033 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
| 1034 | break; |
| 1035 | |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1036 | case 0x08: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1037 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { |
| 1038 | /* 2D mouse packet */ |
| 1039 | input_report_key(input, BTN_LEFT, data[8] & 0x04); |
| 1040 | input_report_key(input, BTN_MIDDLE, data[8] & 0x08); |
| 1041 | input_report_key(input, BTN_RIGHT, data[8] & 0x10); |
| 1042 | input_report_rel(input, REL_WHEEL, (data[8] & 0x01) |
| 1043 | - ((data[8] & 0x02) >> 1)); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1044 | |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1045 | /* I3 2D mouse side buttons */ |
| 1046 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { |
| 1047 | input_report_key(input, BTN_SIDE, data[8] & 0x40); |
| 1048 | input_report_key(input, BTN_EXTRA, data[8] & 0x20); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1049 | } |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1050 | } |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1051 | else if (wacom->tool[idx] == BTN_TOOL_LENS) { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1052 | /* Lens cursor packets */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1053 | input_report_key(input, BTN_LEFT, data[8] & 0x01); |
| 1054 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); |
| 1055 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); |
| 1056 | input_report_key(input, BTN_SIDE, data[8] & 0x10); |
| 1057 | input_report_key(input, BTN_EXTRA, data[8] & 0x08); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1058 | } |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1059 | break; |
| 1060 | |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1061 | case 0x07: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1062 | case 0x09: |
Jason Gerecke | 571f572 | 2015-11-30 17:13:50 -0800 | [diff] [blame] | 1063 | case 0x0b: |
Jason Gerecke | a8a09c8 | 2015-11-30 17:13:49 -0800 | [diff] [blame] | 1064 | case 0x0c: |
| 1065 | case 0x0d: |
| 1066 | case 0x0e: |
| 1067 | case 0x0f: |
| 1068 | /* unhandled */ |
| 1069 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1070 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1071 | |
Jason Gerecke | 82527da | 2016-10-19 18:03:47 -0700 | [diff] [blame] | 1072 | input_report_abs(input, ABS_MISC, |
| 1073 | wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */ |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 1074 | input_report_key(input, wacom->tool[idx], 1); |
| 1075 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); |
Ping Cheng | b3bd7ef | 2015-01-09 11:05:13 -0800 | [diff] [blame] | 1076 | wacom->reporting_data = true; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1077 | return 2; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
| 1080 | static int wacom_intuos_irq(struct wacom_wac *wacom) |
| 1081 | { |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1082 | unsigned char *data = wacom->data; |
| 1083 | struct input_dev *input = wacom->pen_input; |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1084 | int result; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1085 | |
| 1086 | if (data[0] != WACOM_REPORT_PENABLED && |
Jason Gerecke | 0610999 | 2015-11-30 17:13:52 -0800 | [diff] [blame] | 1087 | data[0] != WACOM_REPORT_INTUOS_ID1 && |
| 1088 | data[0] != WACOM_REPORT_INTUOS_ID2 && |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1089 | data[0] != WACOM_REPORT_INTUOSPAD && |
| 1090 | data[0] != WACOM_REPORT_INTUOS_PEN && |
| 1091 | data[0] != WACOM_REPORT_CINTIQ && |
| 1092 | data[0] != WACOM_REPORT_CINTIQPAD && |
| 1093 | data[0] != WACOM_REPORT_INTUOS5PAD) { |
| 1094 | dev_dbg(input->dev.parent, |
| 1095 | "%s: received unknown report #%d\n", __func__, data[0]); |
| 1096 | return 0; |
| 1097 | } |
| 1098 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1099 | /* process pad events */ |
| 1100 | result = wacom_intuos_pad(wacom); |
| 1101 | if (result) |
| 1102 | return result; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1103 | |
| 1104 | /* process in/out prox events */ |
| 1105 | result = wacom_intuos_inout(wacom); |
| 1106 | if (result) |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1107 | return result - 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1108 | |
| 1109 | /* process general packets */ |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1110 | result = wacom_intuos_general(wacom); |
| 1111 | if (result) |
| 1112 | return result - 1; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1113 | |
Jason Gerecke | 16e0a6a | 2015-11-30 17:13:48 -0800 | [diff] [blame] | 1114 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 1115 | } |
| 1116 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1117 | static int int_dist(int x1, int y1, int x2, int y2) |
| 1118 | { |
| 1119 | int x = x2 - x1; |
| 1120 | int y = y2 - y1; |
| 1121 | |
| 1122 | return int_sqrt(x*x + y*y); |
| 1123 | } |
| 1124 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1125 | static void wacom_intuos_bt_process_data(struct wacom_wac *wacom, |
| 1126 | unsigned char *data) |
| 1127 | { |
| 1128 | memcpy(wacom->data, data, 10); |
| 1129 | wacom_intuos_irq(wacom); |
| 1130 | |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1131 | input_sync(wacom->pen_input); |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1132 | if (wacom->pad_input) |
| 1133 | input_sync(wacom->pad_input); |
| 1134 | } |
| 1135 | |
| 1136 | static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1137 | { |
| 1138 | unsigned char data[WACOM_PKGLEN_MAX]; |
| 1139 | int i = 1; |
| 1140 | unsigned power_raw, battery_capacity, bat_charging, ps_connected; |
| 1141 | |
| 1142 | memcpy(data, wacom->data, len); |
| 1143 | |
| 1144 | switch (data[0]) { |
| 1145 | case 0x04: |
| 1146 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1147 | i += 10; |
| 1148 | /* fall through */ |
| 1149 | case 0x03: |
| 1150 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1151 | i += 10; |
| 1152 | wacom_intuos_bt_process_data(wacom, data + i); |
| 1153 | i += 10; |
| 1154 | power_raw = data[i]; |
| 1155 | bat_charging = (power_raw & 0x08) ? 1 : 0; |
| 1156 | ps_connected = (power_raw & 0x10) ? 1 : 0; |
| 1157 | battery_capacity = batcap_i4[power_raw & 0x07]; |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 1158 | wacom_notify_battery(wacom, battery_capacity, bat_charging, |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 1159 | battery_capacity || bat_charging, |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 1160 | ps_connected); |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1161 | break; |
| 1162 | default: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1163 | dev_dbg(wacom->pen_input->dev.parent, |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 1164 | "Unknown report: %d,%d size:%zu\n", |
| 1165 | data[0], data[1], len); |
| 1166 | return 0; |
| 1167 | } |
| 1168 | return 0; |
| 1169 | } |
| 1170 | |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1171 | static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) |
| 1172 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1173 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1174 | unsigned touch_max = wacom->features.touch_max; |
| 1175 | int count = 0; |
| 1176 | int i; |
| 1177 | |
Ping Cheng | 26ba61f | 2015-05-19 17:42:02 -0700 | [diff] [blame] | 1178 | if (!touch_max) |
| 1179 | return 0; |
| 1180 | |
Jason Gerecke | 71b5c47 | 2015-04-15 17:22:32 -0700 | [diff] [blame] | 1181 | if (touch_max == 1) |
| 1182 | return test_bit(BTN_TOUCH, input->key) && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1183 | report_touch_events(wacom); |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1184 | |
| 1185 | for (i = 0; i < input->mt->num_slots; i++) { |
| 1186 | struct input_mt_slot *ps = &input->mt->slots[i]; |
| 1187 | int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); |
| 1188 | if (id >= 0) |
| 1189 | count++; |
| 1190 | } |
| 1191 | |
| 1192 | return count; |
| 1193 | } |
| 1194 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1195 | static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom) |
| 1196 | { |
| 1197 | const int pen_frame_len = 14; |
| 1198 | const int pen_frames = 7; |
| 1199 | |
| 1200 | struct input_dev *pen_input = wacom->pen_input; |
| 1201 | unsigned char *data = wacom->data; |
| 1202 | int i; |
| 1203 | |
| 1204 | wacom->serial[0] = get_unaligned_le64(&data[99]); |
| 1205 | wacom->id[0] = get_unaligned_le16(&data[107]); |
| 1206 | if (wacom->serial[0] >> 52 == 1) { |
| 1207 | /* Add back in missing bits of ID for non-USI pens */ |
| 1208 | wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF; |
| 1209 | } |
| 1210 | wacom->tool[0] = wacom_intuos_get_tool_type(wacom_intuos_id_mangle(wacom->id[0])); |
| 1211 | |
| 1212 | for (i = 0; i < pen_frames; i++) { |
| 1213 | unsigned char *frame = &data[i*pen_frame_len + 1]; |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1214 | bool valid = frame[0] & 0x80; |
| 1215 | bool prox = frame[0] & 0x40; |
| 1216 | bool range = frame[0] & 0x20; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1217 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1218 | if (!valid) |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1219 | continue; |
| 1220 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1221 | if (range) { |
| 1222 | input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1])); |
| 1223 | input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3])); |
| 1224 | input_report_abs(pen_input, ABS_TILT_X, frame[7]); |
| 1225 | input_report_abs(pen_input, ABS_TILT_Y, frame[8]); |
| 1226 | input_report_abs(pen_input, ABS_Z, get_unaligned_le16(&frame[9])); |
| 1227 | input_report_abs(pen_input, ABS_WHEEL, get_unaligned_le16(&frame[11])); |
| 1228 | } |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1229 | input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5])); |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1230 | input_report_abs(pen_input, ABS_DISTANCE, range ? frame[13] : wacom->features.distance_max); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1231 | |
| 1232 | input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x01); |
| 1233 | input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02); |
| 1234 | input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04); |
| 1235 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1236 | input_report_key(pen_input, wacom->tool[0], prox); |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1237 | input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]); |
| 1238 | input_report_abs(pen_input, ABS_MISC, |
| 1239 | wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */ |
| 1240 | |
Jason Gerecke | a48324d | 2017-02-10 16:14:07 -0800 | [diff] [blame^] | 1241 | wacom->shared->stylus_in_proximity = prox; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 1242 | |
| 1243 | input_sync(pen_input); |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom) |
| 1248 | { |
| 1249 | const int finger_touch_len = 8; |
| 1250 | const int finger_frames = 4; |
| 1251 | const int finger_frame_len = 43; |
| 1252 | |
| 1253 | struct input_dev *touch_input = wacom->touch_input; |
| 1254 | unsigned char *data = wacom->data; |
| 1255 | int num_contacts_left = 5; |
| 1256 | int i, j; |
| 1257 | |
| 1258 | for (i = 0; i < finger_frames; i++) { |
| 1259 | unsigned char *frame = &data[i*finger_frame_len + 109]; |
| 1260 | int current_num_contacts = frame[0] & 0x7F; |
| 1261 | int contacts_to_send; |
| 1262 | |
| 1263 | if (!(frame[0] & 0x80)) |
| 1264 | continue; |
| 1265 | |
| 1266 | /* |
| 1267 | * First packet resets the counter since only the first |
| 1268 | * packet in series will have non-zero current_num_contacts. |
| 1269 | */ |
| 1270 | if (current_num_contacts) |
| 1271 | wacom->num_contacts_left = current_num_contacts; |
| 1272 | |
| 1273 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
| 1274 | |
| 1275 | for (j = 0; j < contacts_to_send; j++) { |
| 1276 | unsigned char *touch = &frame[j*finger_touch_len + 1]; |
| 1277 | int slot = input_mt_get_slot_by_key(touch_input, touch[0]); |
| 1278 | int x = get_unaligned_le16(&touch[2]); |
| 1279 | int y = get_unaligned_le16(&touch[4]); |
| 1280 | int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X); |
| 1281 | int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y); |
| 1282 | |
| 1283 | if (slot < 0) |
| 1284 | continue; |
| 1285 | |
| 1286 | input_mt_slot(touch_input, slot); |
| 1287 | input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01); |
| 1288 | input_report_abs(touch_input, ABS_MT_POSITION_X, x); |
| 1289 | input_report_abs(touch_input, ABS_MT_POSITION_Y, y); |
| 1290 | input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h)); |
| 1291 | input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h)); |
| 1292 | input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h); |
| 1293 | } |
| 1294 | |
| 1295 | input_mt_sync_frame(touch_input); |
| 1296 | |
| 1297 | wacom->num_contacts_left -= contacts_to_send; |
| 1298 | if (wacom->num_contacts_left <= 0) { |
| 1299 | wacom->num_contacts_left = 0; |
| 1300 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7)); |
| 1305 | input_sync(touch_input); |
| 1306 | } |
| 1307 | |
| 1308 | static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom) |
| 1309 | { |
| 1310 | struct input_dev *pad_input = wacom->pad_input; |
| 1311 | unsigned char *data = wacom->data; |
| 1312 | |
| 1313 | int buttons = (data[282] << 1) | ((data[281] >> 6) & 0x01); |
| 1314 | int ring = data[285]; |
| 1315 | int prox = buttons | (ring & 0x80); |
| 1316 | |
| 1317 | wacom_report_numbered_buttons(pad_input, 9, buttons); |
| 1318 | |
| 1319 | input_report_abs(pad_input, ABS_WHEEL, (ring & 0x80) ? (ring & 0x7f) : 0); |
| 1320 | |
| 1321 | input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0); |
| 1322 | input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); |
| 1323 | input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff); |
| 1324 | |
| 1325 | input_sync(pad_input); |
| 1326 | } |
| 1327 | |
| 1328 | static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom) |
| 1329 | { |
| 1330 | unsigned char *data = wacom->data; |
| 1331 | |
| 1332 | bool chg = data[284] & 0x80; |
| 1333 | int battery_status = data[284] & 0x7F; |
| 1334 | |
| 1335 | wacom_notify_battery(wacom, battery_status, chg, 1, chg); |
| 1336 | } |
| 1337 | |
| 1338 | static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len) |
| 1339 | { |
| 1340 | unsigned char *data = wacom->data; |
| 1341 | |
| 1342 | if (data[0] != 0x80) { |
| 1343 | dev_dbg(wacom->pen_input->dev.parent, |
| 1344 | "%s: received unknown report #%d\n", __func__, data[0]); |
| 1345 | return 0; |
| 1346 | } |
| 1347 | |
| 1348 | wacom_intuos_pro2_bt_pen(wacom); |
| 1349 | wacom_intuos_pro2_bt_touch(wacom); |
| 1350 | wacom_intuos_pro2_bt_pad(wacom); |
| 1351 | wacom_intuos_pro2_bt_battery(wacom); |
| 1352 | return 0; |
| 1353 | } |
| 1354 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1355 | static int wacom_24hdt_irq(struct wacom_wac *wacom) |
| 1356 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1357 | struct input_dev *input = wacom->touch_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1358 | unsigned char *data = wacom->data; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1359 | int i; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1360 | int current_num_contacts = data[61]; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1361 | int contacts_to_send = 0; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1362 | int num_contacts_left = 4; /* maximum contacts per packet */ |
| 1363 | int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET; |
| 1364 | int y_offset = 2; |
| 1365 | |
| 1366 | if (wacom->features.type == WACOM_27QHDT) { |
| 1367 | current_num_contacts = data[63]; |
| 1368 | num_contacts_left = 10; |
| 1369 | byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET; |
| 1370 | y_offset = 0; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1371 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1372 | |
| 1373 | /* |
| 1374 | * First packet resets the counter since only the first |
| 1375 | * packet in series will have non-zero current_num_contacts. |
| 1376 | */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1377 | if (current_num_contacts) |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1378 | wacom->num_contacts_left = current_num_contacts; |
| 1379 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1380 | contacts_to_send = min(num_contacts_left, wacom->num_contacts_left); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1381 | |
| 1382 | for (i = 0; i < contacts_to_send; i++) { |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1383 | int offset = (byte_per_packet * i) + 1; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1384 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 1385 | int slot = input_mt_get_slot_by_key(input, data[offset + 1]); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1386 | |
| 1387 | if (slot < 0) |
| 1388 | continue; |
| 1389 | input_mt_slot(input, slot); |
| 1390 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1391 | |
| 1392 | if (touch) { |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1393 | int t_x = get_unaligned_le16(&data[offset + 2]); |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1394 | int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1395 | |
| 1396 | input_report_abs(input, ABS_MT_POSITION_X, t_x); |
| 1397 | input_report_abs(input, ABS_MT_POSITION_Y, t_y); |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 1398 | |
| 1399 | if (wacom->features.type != WACOM_27QHDT) { |
| 1400 | int c_x = get_unaligned_le16(&data[offset + 4]); |
| 1401 | int c_y = get_unaligned_le16(&data[offset + 8]); |
| 1402 | int w = get_unaligned_le16(&data[offset + 10]); |
| 1403 | int h = get_unaligned_le16(&data[offset + 12]); |
| 1404 | |
| 1405 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h)); |
| 1406 | input_report_abs(input, ABS_MT_WIDTH_MAJOR, |
| 1407 | min(w, h) + int_dist(t_x, t_y, c_x, c_y)); |
| 1408 | input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h)); |
| 1409 | input_report_abs(input, ABS_MT_ORIENTATION, w > h); |
| 1410 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1411 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1412 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1413 | input_mt_sync_frame(input); |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1414 | |
| 1415 | wacom->num_contacts_left -= contacts_to_send; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1416 | if (wacom->num_contacts_left <= 0) { |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1417 | wacom->num_contacts_left = 0; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1418 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1419 | } |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 1420 | return 1; |
| 1421 | } |
| 1422 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1423 | static int wacom_mt_touch(struct wacom_wac *wacom) |
| 1424 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1425 | struct input_dev *input = wacom->touch_input; |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1426 | unsigned char *data = wacom->data; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1427 | int i; |
| 1428 | int current_num_contacts = data[2]; |
| 1429 | int contacts_to_send = 0; |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1430 | int x_offset = 0; |
| 1431 | |
| 1432 | /* MTTPC does not support Height and Width */ |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 1433 | if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B) |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1434 | x_offset = -4; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1435 | |
| 1436 | /* |
| 1437 | * First packet resets the counter since only the first |
| 1438 | * packet in series will have non-zero current_num_contacts. |
| 1439 | */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1440 | if (current_num_contacts) |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1441 | wacom->num_contacts_left = current_num_contacts; |
| 1442 | |
| 1443 | /* There are at most 5 contacts per packet */ |
| 1444 | contacts_to_send = min(5, wacom->num_contacts_left); |
| 1445 | |
| 1446 | for (i = 0; i < contacts_to_send; i++) { |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 1447 | int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1448 | bool touch = (data[offset] & 0x1) && report_touch_events(wacom); |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1449 | int id = get_unaligned_le16(&data[offset + 1]); |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 1450 | int slot = input_mt_get_slot_by_key(input, id); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1451 | |
| 1452 | if (slot < 0) |
| 1453 | continue; |
| 1454 | |
| 1455 | input_mt_slot(input, slot); |
| 1456 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1457 | if (touch) { |
Jason Gerecke | edc8e20a | 2014-05-14 16:53:30 -0700 | [diff] [blame] | 1458 | int x = get_unaligned_le16(&data[offset + x_offset + 7]); |
| 1459 | int y = get_unaligned_le16(&data[offset + x_offset + 9]); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1460 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 1461 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
| 1462 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1463 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1464 | input_mt_sync_frame(input); |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1465 | |
| 1466 | wacom->num_contacts_left -= contacts_to_send; |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1467 | if (wacom->num_contacts_left <= 0) { |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1468 | wacom->num_contacts_left = 0; |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1469 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1470 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1471 | return 1; |
| 1472 | } |
| 1473 | |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1474 | static int wacom_tpc_mt_touch(struct wacom_wac *wacom) |
| 1475 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1476 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1477 | unsigned char *data = wacom->data; |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1478 | int i; |
| 1479 | |
| 1480 | for (i = 0; i < 2; i++) { |
| 1481 | int p = data[1] & (1 << i); |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1482 | bool touch = p && report_touch_events(wacom); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1483 | |
| 1484 | input_mt_slot(input, i); |
| 1485 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 1486 | if (touch) { |
| 1487 | int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff; |
| 1488 | int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff; |
| 1489 | |
| 1490 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 1491 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1492 | } |
| 1493 | } |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 1494 | input_mt_sync_frame(input); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1495 | |
| 1496 | /* keep touch state for pen event */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 1497 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1498 | |
Ping Cheng | 84eb5aa | 2011-03-12 20:35:18 -0800 | [diff] [blame] | 1499 | return 1; |
| 1500 | } |
| 1501 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1502 | 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] | 1503 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1504 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1505 | struct input_dev *input = wacom->touch_input; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1506 | bool prox = report_touch_events(wacom); |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1507 | int x = 0, y = 0; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1508 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1509 | if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG) |
| 1510 | return 0; |
| 1511 | |
Ping Cheng | e0d41fd | 2015-02-20 14:27:30 -0800 | [diff] [blame] | 1512 | if (len == WACOM_PKGLEN_TPC1FG) { |
| 1513 | prox = prox && (data[0] & 0x01); |
| 1514 | x = get_unaligned_le16(&data[1]); |
| 1515 | y = get_unaligned_le16(&data[3]); |
| 1516 | } else if (len == WACOM_PKGLEN_TPC1FG_B) { |
| 1517 | prox = prox && (data[2] & 0x01); |
| 1518 | x = get_unaligned_le16(&data[3]); |
| 1519 | y = get_unaligned_le16(&data[5]); |
| 1520 | } else { |
| 1521 | prox = prox && (data[1] & 0x01); |
| 1522 | x = le16_to_cpup((__le16 *)&data[2]); |
| 1523 | y = le16_to_cpup((__le16 *)&data[4]); |
| 1524 | } |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1525 | |
| 1526 | if (prox) { |
| 1527 | input_report_abs(input, ABS_X, x); |
| 1528 | input_report_abs(input, ABS_Y, y); |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1529 | } |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1530 | input_report_key(input, BTN_TOUCH, prox); |
| 1531 | |
| 1532 | /* keep touch state for pen events */ |
| 1533 | wacom->shared->touch_down = prox; |
| 1534 | |
| 1535 | return 1; |
Ping Cheng | ec67bbe | 2009-12-15 00:35:24 -0800 | [diff] [blame] | 1536 | } |
| 1537 | |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1538 | static int wacom_tpc_pen(struct wacom_wac *wacom) |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1539 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1540 | unsigned char *data = wacom->data; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1541 | struct input_dev *input = wacom->pen_input; |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1542 | bool prox = data[1] & 0x20; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1543 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1544 | if (!wacom->shared->stylus_in_proximity) /* first in prox */ |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1545 | /* Going into proximity select tool */ |
| 1546 | wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1547 | |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1548 | /* keep pen state for touch events */ |
| 1549 | wacom->shared->stylus_in_proximity = prox; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1550 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 1551 | /* send pen events only when touch is up or forced out |
| 1552 | * or touch arbitration is off |
| 1553 | */ |
| 1554 | if (!delay_pen_events(wacom)) { |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1555 | input_report_key(input, BTN_STYLUS, data[1] & 0x02); |
| 1556 | input_report_key(input, BTN_STYLUS2, data[1] & 0x10); |
| 1557 | input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2])); |
| 1558 | input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4])); |
Jason Gerecke | 0b335ca | 2014-07-24 13:15:31 -0700 | [diff] [blame] | 1559 | input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]); |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 1560 | input_report_key(input, BTN_TOUCH, data[1] & 0x05); |
| 1561 | input_report_key(input, wacom->tool[0], prox); |
| 1562 | return 1; |
| 1563 | } |
| 1564 | |
| 1565 | return 0; |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) |
| 1569 | { |
Jason Gerecke | 74b6341 | 2014-04-19 13:50:22 -0700 | [diff] [blame] | 1570 | unsigned char *data = wacom->data; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1571 | |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1572 | if (wacom->pen_input) |
| 1573 | dev_dbg(wacom->pen_input->dev.parent, |
| 1574 | "%s: received report #%d\n", __func__, data[0]); |
| 1575 | else if (wacom->touch_input) |
| 1576 | dev_dbg(wacom->touch_input->dev.parent, |
| 1577 | "%s: received report #%d\n", __func__, data[0]); |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1578 | |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1579 | switch (len) { |
| 1580 | case WACOM_PKGLEN_TPC1FG: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1581 | return wacom_tpc_single_touch(wacom, len); |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1582 | |
| 1583 | case WACOM_PKGLEN_TPC2FG: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1584 | return wacom_tpc_mt_touch(wacom); |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1585 | |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 1586 | case WACOM_PKGLEN_PENABLED: |
| 1587 | return wacom_tpc_pen(wacom); |
| 1588 | |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1589 | default: |
| 1590 | switch (data[0]) { |
| 1591 | case WACOM_REPORT_TPC1FG: |
| 1592 | case WACOM_REPORT_TPCHID: |
| 1593 | case WACOM_REPORT_TPCST: |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 1594 | case WACOM_REPORT_TPC1FGE: |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1595 | return wacom_tpc_single_touch(wacom, len); |
| 1596 | |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1597 | case WACOM_REPORT_TPCMT: |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 1598 | case WACOM_REPORT_TPCMT2: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 1599 | return wacom_mt_touch(wacom); |
| 1600 | |
Ping Cheng | 31175a8 | 2012-01-31 00:07:33 -0800 | [diff] [blame] | 1601 | case WACOM_REPORT_PENABLED: |
| 1602 | return wacom_tpc_pen(wacom); |
| 1603 | } |
| 1604 | } |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1605 | |
Ping Cheng | 8aa9a9a | 2011-03-12 20:34:11 -0800 | [diff] [blame] | 1606 | return 0; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 1607 | } |
| 1608 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 1609 | int wacom_equivalent_usage(int usage) |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1610 | { |
| 1611 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) { |
| 1612 | int subpage = (usage & 0xFF00) << 8; |
| 1613 | int subusage = (usage & 0xFF); |
| 1614 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1615 | if (subpage == WACOM_HID_SP_PAD || |
| 1616 | subpage == WACOM_HID_SP_BUTTON || |
| 1617 | subpage == WACOM_HID_SP_DIGITIZER || |
Jason Gerecke | b5c921e | 2016-10-19 18:03:44 -0700 | [diff] [blame] | 1618 | subpage == WACOM_HID_SP_DIGITIZERINFO || |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1619 | usage == WACOM_HID_WD_SENSE || |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 1620 | usage == WACOM_HID_WD_SERIALHI || |
| 1621 | usage == WACOM_HID_WD_TOOLTYPE || |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1622 | usage == WACOM_HID_WD_DISTANCE || |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1623 | usage == WACOM_HID_WD_TOUCHSTRIP || |
| 1624 | usage == WACOM_HID_WD_TOUCHSTRIP2 || |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1625 | usage == WACOM_HID_WD_TOUCHRING || |
| 1626 | usage == WACOM_HID_WD_TOUCHRINGSTATUS) { |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1627 | return usage; |
| 1628 | } |
| 1629 | |
| 1630 | if (subpage == HID_UP_UNDEFINED) |
| 1631 | subpage = HID_UP_DIGITIZER; |
| 1632 | |
| 1633 | return subpage | subusage; |
| 1634 | } |
| 1635 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 1636 | if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) { |
| 1637 | int subpage = (usage & 0xFF00) << 8; |
| 1638 | int subusage = (usage & 0xFF); |
| 1639 | |
| 1640 | if (subpage == HID_UP_UNDEFINED) |
| 1641 | subpage = WACOM_HID_SP_DIGITIZER; |
| 1642 | |
| 1643 | return subpage | subusage; |
| 1644 | } |
| 1645 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1646 | return usage; |
| 1647 | } |
| 1648 | |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1649 | 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] | 1650 | struct hid_field *field, __u8 type, __u16 code, int fuzz) |
| 1651 | { |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 1652 | struct wacom *wacom = input_get_drvdata(input); |
| 1653 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1654 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1655 | int fmin = field->logical_minimum; |
| 1656 | int fmax = field->logical_maximum; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1657 | unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1658 | int resolution_code = code; |
| 1659 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1660 | if (equivalent_usage == HID_DG_TWIST) { |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1661 | resolution_code = ABS_RZ; |
| 1662 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1663 | |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 1664 | if (equivalent_usage == HID_GD_X) { |
| 1665 | fmin += features->offset_left; |
| 1666 | fmax -= features->offset_right; |
| 1667 | } |
| 1668 | if (equivalent_usage == HID_GD_Y) { |
| 1669 | fmin += features->offset_top; |
| 1670 | fmax -= features->offset_bottom; |
| 1671 | } |
| 1672 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1673 | usage->type = type; |
| 1674 | usage->code = code; |
| 1675 | |
| 1676 | set_bit(type, input->evbit); |
| 1677 | |
| 1678 | switch (type) { |
| 1679 | case EV_ABS: |
| 1680 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); |
| 1681 | input_abs_set_res(input, code, |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1682 | hidinput_calc_abs_res(field, resolution_code)); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1683 | break; |
| 1684 | case EV_KEY: |
| 1685 | input_set_capability(input, EV_KEY, code); |
| 1686 | break; |
| 1687 | case EV_MSC: |
| 1688 | input_set_capability(input, EV_MSC, code); |
| 1689 | break; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1690 | case EV_SW: |
| 1691 | input_set_capability(input, EV_SW, code); |
| 1692 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1693 | } |
| 1694 | } |
| 1695 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1696 | static void wacom_wac_pad_usage_mapping(struct hid_device *hdev, |
| 1697 | struct hid_field *field, struct hid_usage *usage) |
| 1698 | { |
| 1699 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1700 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1701 | struct wacom_features *features = &wacom_wac->features; |
| 1702 | struct input_dev *input = wacom_wac->pad_input; |
| 1703 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1704 | |
| 1705 | switch (equivalent_usage) { |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1706 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1707 | case WACOM_HID_WD_BATTERY_CHARGING: |
| 1708 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 1709 | break; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1710 | case WACOM_HID_WD_ACCELEROMETER_X: |
| 1711 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1712 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1713 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1714 | break; |
| 1715 | case WACOM_HID_WD_ACCELEROMETER_Y: |
| 1716 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1717 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1718 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1719 | break; |
| 1720 | case WACOM_HID_WD_ACCELEROMETER_Z: |
| 1721 | __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit); |
| 1722 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1723 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1724 | break; |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 1725 | case WACOM_HID_WD_BUTTONCENTER: |
| 1726 | wacom->generic_has_leds = true; |
| 1727 | /* fall through */ |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1728 | case WACOM_HID_WD_BUTTONHOME: |
| 1729 | case WACOM_HID_WD_BUTTONUP: |
| 1730 | case WACOM_HID_WD_BUTTONDOWN: |
| 1731 | case WACOM_HID_WD_BUTTONLEFT: |
| 1732 | case WACOM_HID_WD_BUTTONRIGHT: |
| 1733 | wacom_map_usage(input, usage, field, EV_KEY, |
| 1734 | wacom_numbered_button_to_key(features->numbered_buttons), |
| 1735 | 0); |
| 1736 | features->numbered_buttons++; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1737 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1738 | break; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1739 | case WACOM_HID_WD_TOUCHONOFF: |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 1740 | /* |
| 1741 | * This usage, which is used to mute touch events, comes |
| 1742 | * from the pad packet, but is reported on the touch |
| 1743 | * interface. Because the touch interface may not have |
| 1744 | * been created yet, we cannot call wacom_map_usage(). In |
| 1745 | * order to process this usage when we receive it, we set |
| 1746 | * the usage type and code directly. |
| 1747 | */ |
| 1748 | wacom_wac->has_mute_touch_switch = true; |
| 1749 | usage->type = EV_SW; |
| 1750 | usage->code = SW_MUTE_DEVICE; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1751 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1752 | break; |
| 1753 | case WACOM_HID_WD_TOUCHSTRIP: |
| 1754 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1755 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1756 | break; |
| 1757 | case WACOM_HID_WD_TOUCHSTRIP2: |
| 1758 | wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1759 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | bf78adc | 2016-10-19 18:03:53 -0700 | [diff] [blame] | 1760 | break; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1761 | case WACOM_HID_WD_TOUCHRING: |
| 1762 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1763 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1764 | break; |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 1765 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
| 1766 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); |
| 1767 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 1768 | break; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
| 1771 | switch (equivalent_usage & 0xfffffff0) { |
| 1772 | case WACOM_HID_WD_EXPRESSKEY00: |
| 1773 | wacom_map_usage(input, usage, field, EV_KEY, |
| 1774 | wacom_numbered_button_to_key(features->numbered_buttons), |
| 1775 | 0); |
| 1776 | features->numbered_buttons++; |
Ping Cheng | f3f24e7 | 2016-12-08 22:05:44 -0800 | [diff] [blame] | 1777 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1778 | break; |
| 1779 | } |
| 1780 | } |
| 1781 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1782 | static void wacom_wac_pad_battery_event(struct hid_device *hdev, struct hid_field *field, |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1783 | struct hid_usage *usage, __s32 value) |
| 1784 | { |
| 1785 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1786 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1787 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
| 1788 | |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1789 | switch (equivalent_usage) { |
| 1790 | case WACOM_HID_WD_BATTERY_LEVEL: |
| 1791 | wacom_wac->hid_data.battery_capacity = value; |
| 1792 | wacom_wac->hid_data.bat_connected = 1; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1793 | break; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1794 | |
| 1795 | case WACOM_HID_WD_BATTERY_CHARGING: |
| 1796 | wacom_wac->hid_data.bat_charging = value; |
| 1797 | wacom_wac->hid_data.ps_connected = value; |
| 1798 | wacom_wac->hid_data.bat_connected = 1; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1799 | break; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1800 | } |
| 1801 | } |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1802 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1803 | static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field, |
| 1804 | struct hid_usage *usage, __s32 value) |
| 1805 | { |
| 1806 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1807 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1808 | struct input_dev *input = wacom_wac->pad_input; |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 1809 | struct wacom_features *features = &wacom_wac->features; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1810 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 1811 | int i; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1812 | |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 1813 | /* |
| 1814 | * Avoid reporting this event and setting inrange_state if this usage |
| 1815 | * hasn't been mapped. |
| 1816 | */ |
| 1817 | if (!usage->type) |
| 1818 | return; |
| 1819 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1820 | if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) { |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 1821 | if (usage->hid != WACOM_HID_WD_TOUCHRING) |
| 1822 | wacom_wac->hid_data.inrange_state |= value; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1823 | } |
| 1824 | |
| 1825 | switch (equivalent_usage) { |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1826 | case WACOM_HID_WD_TOUCHRINGSTATUS: |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 1827 | if (!value) |
| 1828 | input_event(input, usage->type, usage->code, 0); |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1829 | break; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1830 | |
Aaron Armstrong Skomra | d2ec58a | 2017-01-25 12:08:41 -0800 | [diff] [blame] | 1831 | case WACOM_HID_WD_TOUCHONOFF: |
| 1832 | if (wacom_wac->shared->touch_input) { |
| 1833 | input_report_switch(wacom_wac->shared->touch_input, |
| 1834 | SW_MUTE_DEVICE, !value); |
| 1835 | input_sync(wacom_wac->shared->touch_input); |
| 1836 | } |
| 1837 | break; |
Aaron Armstrong Skomra | 10c55ca | 2017-01-25 12:08:42 -0800 | [diff] [blame] | 1838 | |
| 1839 | case WACOM_HID_WD_BUTTONCENTER: |
| 1840 | for (i = 0; i < wacom->led.count; i++) |
| 1841 | wacom_update_led(wacom, features->numbered_buttons, |
| 1842 | value, i); |
| 1843 | /* fall through*/ |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1844 | default: |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1845 | input_event(input, usage->type, usage->code, value); |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1846 | break; |
| 1847 | } |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1848 | } |
| 1849 | |
| 1850 | static void wacom_wac_pad_pre_report(struct hid_device *hdev, |
| 1851 | struct hid_report *report) |
| 1852 | { |
| 1853 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1854 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1855 | |
| 1856 | wacom_wac->hid_data.inrange_state = 0; |
| 1857 | } |
| 1858 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1859 | static void wacom_wac_pad_battery_report(struct hid_device *hdev, |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1860 | struct hid_report *report) |
| 1861 | { |
| 1862 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1863 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1864 | struct wacom_features *features = &wacom_wac->features; |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1865 | |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1866 | if (features->quirks & WACOM_QUIRK_BATTERY) { |
| 1867 | int capacity = wacom_wac->hid_data.battery_capacity; |
| 1868 | bool charging = wacom_wac->hid_data.bat_charging; |
| 1869 | bool connected = wacom_wac->hid_data.bat_connected; |
| 1870 | bool powered = wacom_wac->hid_data.ps_connected; |
| 1871 | |
| 1872 | wacom_notify_battery(wacom_wac, capacity, charging, |
| 1873 | connected, powered); |
| 1874 | } |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1875 | } |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1876 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1877 | static void wacom_wac_pad_report(struct hid_device *hdev, |
| 1878 | struct hid_report *report) |
| 1879 | { |
| 1880 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1881 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1882 | struct input_dev *input = wacom_wac->pad_input; |
| 1883 | bool active = wacom_wac->hid_data.inrange_state != 0; |
| 1884 | |
| 1885 | /* report prox for expresskey events */ |
| 1886 | if (wacom_equivalent_usage(report->field[0]->physical) == HID_DG_TABLETFUNCTIONKEY) { |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1887 | input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0); |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 1888 | input_sync(input); |
| 1889 | } |
Aaron Armstrong Skomra | 65ef4c1 | 2017-01-25 12:08:38 -0800 | [diff] [blame] | 1890 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 1891 | } |
| 1892 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1893 | static void wacom_wac_pen_usage_mapping(struct hid_device *hdev, |
| 1894 | struct hid_field *field, struct hid_usage *usage) |
| 1895 | { |
| 1896 | struct wacom *wacom = hid_get_drvdata(hdev); |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1897 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1898 | struct wacom_features *features = &wacom_wac->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1899 | struct input_dev *input = wacom_wac->pen_input; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1900 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1901 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1902 | switch (equivalent_usage) { |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1903 | case HID_GD_X: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1904 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1905 | break; |
| 1906 | case HID_GD_Y: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1907 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1908 | break; |
Jason Gerecke | b5c921e | 2016-10-19 18:03:44 -0700 | [diff] [blame] | 1909 | case WACOM_HID_WD_DISTANCE: |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1910 | case HID_GD_Z: |
| 1911 | wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0); |
| 1912 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1913 | case HID_DG_TIPPRESSURE: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1914 | wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1915 | break; |
| 1916 | case HID_DG_INRANGE: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1917 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1918 | break; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1919 | case HID_DG_BATTERYSTRENGTH: |
| 1920 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 1921 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1922 | case HID_DG_INVERT: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1923 | wacom_map_usage(input, usage, field, EV_KEY, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1924 | BTN_TOOL_RUBBER, 0); |
| 1925 | break; |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1926 | case HID_DG_TILT_X: |
| 1927 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0); |
| 1928 | break; |
| 1929 | case HID_DG_TILT_Y: |
| 1930 | wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0); |
| 1931 | break; |
| 1932 | case HID_DG_TWIST: |
| 1933 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0); |
| 1934 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1935 | case HID_DG_ERASER: |
| 1936 | case HID_DG_TIPSWITCH: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1937 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1938 | break; |
| 1939 | case HID_DG_BARRELSWITCH: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1940 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1941 | break; |
| 1942 | case HID_DG_BARRELSWITCH2: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1943 | wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1944 | break; |
| 1945 | case HID_DG_TOOLSERIALNUMBER: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1946 | wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1947 | break; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1948 | case WACOM_HID_WD_SENSE: |
| 1949 | features->quirks |= WACOM_QUIRK_SENSE; |
| 1950 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0); |
| 1951 | break; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 1952 | case WACOM_HID_WD_SERIALHI: |
| 1953 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0); |
| 1954 | set_bit(EV_KEY, input->evbit); |
| 1955 | input_set_capability(input, EV_KEY, BTN_TOOL_PEN); |
| 1956 | input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER); |
| 1957 | input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH); |
| 1958 | input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL); |
| 1959 | input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH); |
| 1960 | input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE); |
| 1961 | input_set_capability(input, EV_KEY, BTN_TOOL_LENS); |
| 1962 | break; |
Jason Gerecke | 929d6d5 | 2016-10-19 18:03:45 -0700 | [diff] [blame] | 1963 | case WACOM_HID_WD_FINGERWHEEL: |
| 1964 | wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0); |
| 1965 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1966 | } |
| 1967 | } |
| 1968 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1969 | 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] | 1970 | struct hid_usage *usage, __s32 value) |
| 1971 | { |
| 1972 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1973 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1974 | struct wacom_features *features = &wacom_wac->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 1975 | struct input_dev *input = wacom_wac->pen_input; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1976 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1977 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 1978 | switch (equivalent_usage) { |
Jason Gerecke | 50066a0 | 2016-10-19 18:03:42 -0700 | [diff] [blame] | 1979 | case HID_GD_Z: |
| 1980 | /* |
| 1981 | * HID_GD_Z "should increase as the control's position is |
| 1982 | * moved from high to low", while ABS_DISTANCE instead |
| 1983 | * increases in value as the tool moves from low to high. |
| 1984 | */ |
| 1985 | value = field->logical_maximum - value; |
| 1986 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1987 | case HID_DG_INRANGE: |
| 1988 | wacom_wac->hid_data.inrange_state = value; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 1989 | if (!(features->quirks & WACOM_QUIRK_SENSE)) |
| 1990 | wacom_wac->hid_data.sense_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1991 | return; |
Jason Gerecke | 93aab7f | 2016-10-19 18:03:52 -0700 | [diff] [blame] | 1992 | case HID_DG_BATTERYSTRENGTH: |
| 1993 | wacom_wac->hid_data.battery_capacity = value; |
| 1994 | wacom_wac->hid_data.bat_connected = 1; |
| 1995 | break; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1996 | case HID_DG_INVERT: |
| 1997 | wacom_wac->hid_data.invert_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 1998 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 1999 | case HID_DG_ERASER: |
| 2000 | case HID_DG_TIPSWITCH: |
| 2001 | wacom_wac->hid_data.tipswitch |= value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2002 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2003 | case HID_DG_TOOLSERIALNUMBER: |
Dan Carpenter | a35f09b | 2016-11-10 22:25:39 +0300 | [diff] [blame] | 2004 | wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2005 | wacom_wac->serial[0] |= value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2006 | return; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2007 | case WACOM_HID_WD_SENSE: |
| 2008 | wacom_wac->hid_data.sense_state = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2009 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2010 | case WACOM_HID_WD_SERIALHI: |
| 2011 | wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF); |
| 2012 | wacom_wac->serial[0] |= ((__u64)value) << 32; |
| 2013 | /* |
| 2014 | * Non-USI EMR devices may contain additional tool type |
| 2015 | * information here. See WACOM_HID_WD_TOOLTYPE case for |
| 2016 | * more details. |
| 2017 | */ |
| 2018 | if (value >> 20 == 1) { |
| 2019 | wacom_wac->id[0] |= value & 0xFFFFF; |
| 2020 | } |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2021 | return; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2022 | case WACOM_HID_WD_TOOLTYPE: |
| 2023 | /* |
| 2024 | * Some devices (MobileStudio Pro, and possibly later |
| 2025 | * devices as well) do not return the complete tool |
| 2026 | * type in their WACOM_HID_WD_TOOLTYPE usage. Use a |
| 2027 | * bitwise OR so the complete value can be built |
| 2028 | * up over time :( |
| 2029 | */ |
| 2030 | wacom_wac->id[0] |= value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2031 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2032 | case WACOM_HID_WD_OFFSETLEFT: |
| 2033 | if (features->offset_left && value != features->offset_left) |
| 2034 | hid_warn(hdev, "%s: overriding exising left offset " |
| 2035 | "%d -> %d\n", __func__, value, |
| 2036 | features->offset_left); |
| 2037 | features->offset_left = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2038 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2039 | case WACOM_HID_WD_OFFSETRIGHT: |
| 2040 | if (features->offset_right && value != features->offset_right) |
| 2041 | hid_warn(hdev, "%s: overriding exising right offset " |
| 2042 | "%d -> %d\n", __func__, value, |
| 2043 | features->offset_right); |
| 2044 | features->offset_right = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2045 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2046 | case WACOM_HID_WD_OFFSETTOP: |
| 2047 | if (features->offset_top && value != features->offset_top) |
| 2048 | hid_warn(hdev, "%s: overriding exising top offset " |
| 2049 | "%d -> %d\n", __func__, value, |
| 2050 | features->offset_top); |
| 2051 | features->offset_top = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2052 | return; |
Jason Gerecke | 345857b | 2016-10-19 18:03:50 -0700 | [diff] [blame] | 2053 | case WACOM_HID_WD_OFFSETBOTTOM: |
| 2054 | if (features->offset_bottom && value != features->offset_bottom) |
| 2055 | hid_warn(hdev, "%s: overriding exising bottom offset " |
| 2056 | "%d -> %d\n", __func__, value, |
| 2057 | features->offset_bottom); |
| 2058 | features->offset_bottom = value; |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2059 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2060 | } |
| 2061 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2062 | /* send pen events only when touch is up or forced out |
| 2063 | * or touch arbitration is off |
| 2064 | */ |
| 2065 | if (!usage->type || delay_pen_events(wacom_wac)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2066 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2067 | |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2068 | /* send pen events only when the pen is in/entering/leaving proximity */ |
| 2069 | if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0]) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2070 | return; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2071 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2072 | input_event(input, usage->type, usage->code, value); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2073 | } |
| 2074 | |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2075 | static void wacom_wac_pen_pre_report(struct hid_device *hdev, |
| 2076 | struct hid_report *report) |
| 2077 | { |
| 2078 | return; |
| 2079 | } |
| 2080 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2081 | static void wacom_wac_pen_report(struct hid_device *hdev, |
| 2082 | struct hid_report *report) |
| 2083 | { |
| 2084 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2085 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2086 | struct input_dev *input = wacom_wac->pen_input; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2087 | bool prox = wacom_wac->hid_data.inrange_state; |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2088 | bool range = wacom_wac->hid_data.sense_state; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2089 | |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2090 | if (!wacom_wac->tool[0] && prox) { /* first in prox */ |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2091 | /* Going into proximity select tool */ |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2092 | if (wacom_wac->hid_data.invert_state) |
| 2093 | wacom_wac->tool[0] = BTN_TOOL_RUBBER; |
| 2094 | else if (wacom_wac->id[0]) |
| 2095 | wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]); |
| 2096 | else |
| 2097 | wacom_wac->tool[0] = BTN_TOOL_PEN; |
| 2098 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2099 | |
| 2100 | /* keep pen state for touch events */ |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2101 | wacom_wac->shared->stylus_in_proximity = range; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2102 | |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2103 | if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2104 | int id = wacom_wac->id[0]; |
| 2105 | |
| 2106 | /* |
| 2107 | * Non-USI EMR tools should have their IDs mangled to |
| 2108 | * match the legacy behavior of wacom_intuos_general |
| 2109 | */ |
| 2110 | if (wacom_wac->serial[0] >> 52 == 1) |
| 2111 | id = wacom_intuos_id_mangle(id); |
| 2112 | |
| 2113 | /* |
| 2114 | * To ensure compatibility with xf86-input-wacom, we should |
| 2115 | * report the BTN_TOOL_* event prior to the ABS_MISC or |
| 2116 | * MSC_SERIAL events. |
| 2117 | */ |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2118 | input_report_key(input, BTN_TOUCH, |
| 2119 | wacom_wac->hid_data.tipswitch); |
| 2120 | input_report_key(input, wacom_wac->tool[0], prox); |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2121 | if (wacom_wac->serial[0]) { |
| 2122 | input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]); |
| 2123 | input_report_abs(input, ABS_MISC, id); |
| 2124 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2125 | |
| 2126 | wacom_wac->hid_data.tipswitch = false; |
| 2127 | |
| 2128 | input_sync(input); |
| 2129 | } |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2130 | |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2131 | if (!prox) { |
Jason Gerecke | 61ce346 | 2016-10-19 18:03:46 -0700 | [diff] [blame] | 2132 | wacom_wac->tool[0] = 0; |
Jason Gerecke | f85c9dc | 2016-10-19 18:03:48 -0700 | [diff] [blame] | 2133 | wacom_wac->id[0] = 0; |
| 2134 | } |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2135 | } |
| 2136 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2137 | static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, |
| 2138 | struct hid_field *field, struct hid_usage *usage) |
| 2139 | { |
| 2140 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2141 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2142 | struct input_dev *input = wacom_wac->touch_input; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2143 | unsigned touch_max = wacom_wac->features.touch_max; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2144 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2145 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2146 | switch (equivalent_usage) { |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2147 | case HID_GD_X: |
| 2148 | if (touch_max == 1) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2149 | wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2150 | else |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2151 | wacom_map_usage(input, usage, field, EV_ABS, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2152 | ABS_MT_POSITION_X, 4); |
| 2153 | break; |
| 2154 | case HID_GD_Y: |
| 2155 | if (touch_max == 1) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2156 | wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2157 | else |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2158 | wacom_map_usage(input, usage, field, EV_ABS, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2159 | ABS_MT_POSITION_Y, 4); |
| 2160 | break; |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2161 | case HID_DG_WIDTH: |
| 2162 | case HID_DG_HEIGHT: |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2163 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0); |
| 2164 | wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0); |
| 2165 | input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0); |
| 2166 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2167 | case HID_DG_TIPSWITCH: |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2168 | wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2169 | break; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2170 | case HID_DG_CONTACTCOUNT: |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2171 | wacom_wac->hid_data.cc_report = field->report->id; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2172 | wacom_wac->hid_data.cc_index = field->index; |
| 2173 | wacom_wac->hid_data.cc_value_index = usage->usage_index; |
| 2174 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2175 | } |
| 2176 | } |
| 2177 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2178 | static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, |
| 2179 | struct input_dev *input) |
| 2180 | { |
| 2181 | struct hid_data *hid_data = &wacom_wac->hid_data; |
| 2182 | bool mt = wacom_wac->features.touch_max > 1; |
| 2183 | bool prox = hid_data->tipswitch && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2184 | report_touch_events(wacom_wac); |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2185 | |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2186 | wacom_wac->hid_data.num_received++; |
| 2187 | if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected) |
| 2188 | return; |
| 2189 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2190 | if (mt) { |
| 2191 | int slot; |
| 2192 | |
| 2193 | slot = input_mt_get_slot_by_key(input, hid_data->id); |
| 2194 | input_mt_slot(input, slot); |
| 2195 | input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); |
| 2196 | } |
| 2197 | else { |
| 2198 | input_report_key(input, BTN_TOUCH, prox); |
| 2199 | } |
| 2200 | |
| 2201 | if (prox) { |
| 2202 | input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X, |
| 2203 | hid_data->x); |
| 2204 | input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y, |
| 2205 | hid_data->y); |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2206 | |
| 2207 | if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { |
| 2208 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); |
| 2209 | input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); |
| 2210 | if (hid_data->width != hid_data->height) |
| 2211 | input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1); |
| 2212 | } |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2213 | } |
| 2214 | } |
| 2215 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2216 | static void wacom_wac_finger_event(struct hid_device *hdev, |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2217 | struct hid_field *field, struct hid_usage *usage, __s32 value) |
| 2218 | { |
| 2219 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2220 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2221 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2222 | |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2223 | switch (equivalent_usage) { |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2224 | case HID_GD_X: |
| 2225 | wacom_wac->hid_data.x = value; |
| 2226 | break; |
| 2227 | case HID_GD_Y: |
| 2228 | wacom_wac->hid_data.y = value; |
| 2229 | break; |
Jason Gerecke | 488abb5 | 2015-07-21 11:07:25 -0700 | [diff] [blame] | 2230 | case HID_DG_WIDTH: |
| 2231 | wacom_wac->hid_data.width = value; |
| 2232 | break; |
| 2233 | case HID_DG_HEIGHT: |
| 2234 | wacom_wac->hid_data.height = value; |
| 2235 | break; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2236 | case HID_DG_CONTACTID: |
| 2237 | wacom_wac->hid_data.id = value; |
| 2238 | break; |
| 2239 | case HID_DG_TIPSWITCH: |
| 2240 | wacom_wac->hid_data.tipswitch = value; |
| 2241 | break; |
| 2242 | } |
| 2243 | |
| 2244 | |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2245 | if (usage->usage_index + 1 == field->report_count) { |
Jason Gerecke | c9c0958 | 2016-10-19 18:03:43 -0700 | [diff] [blame] | 2246 | if (equivalent_usage == wacom_wac->hid_data.last_slot_field) |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2247 | wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2248 | } |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2249 | } |
| 2250 | |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2251 | static void wacom_wac_finger_pre_report(struct hid_device *hdev, |
| 2252 | struct hid_report *report) |
| 2253 | { |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2254 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2255 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2256 | struct hid_data* hid_data = &wacom_wac->hid_data; |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2257 | int i; |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2258 | |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2259 | for (i = 0; i < report->maxfield; i++) { |
| 2260 | struct hid_field *field = report->field[i]; |
| 2261 | int j; |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2262 | |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2263 | for (j = 0; j < field->maxusage; j++) { |
| 2264 | struct hid_usage *usage = &field->usage[j]; |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2265 | unsigned int equivalent_usage = |
| 2266 | wacom_equivalent_usage(usage->hid); |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2267 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2268 | switch (equivalent_usage) { |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2269 | case HID_GD_X: |
| 2270 | case HID_GD_Y: |
| 2271 | case HID_DG_WIDTH: |
| 2272 | case HID_DG_HEIGHT: |
| 2273 | case HID_DG_CONTACTID: |
| 2274 | case HID_DG_INRANGE: |
| 2275 | case HID_DG_INVERT: |
| 2276 | case HID_DG_TIPSWITCH: |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2277 | hid_data->last_slot_field = equivalent_usage; |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2278 | break; |
| 2279 | case HID_DG_CONTACTCOUNT: |
| 2280 | hid_data->cc_report = report->id; |
| 2281 | hid_data->cc_index = i; |
| 2282 | hid_data->cc_value_index = j; |
| 2283 | break; |
Jason Gerecke | 499522c | 2015-10-07 16:54:21 -0700 | [diff] [blame] | 2284 | } |
| 2285 | } |
| 2286 | } |
Jason Gerecke | 003f50a | 2016-07-21 09:10:46 -0700 | [diff] [blame] | 2287 | |
Jason Gerecke | df70793 | 2015-10-07 16:54:22 -0700 | [diff] [blame] | 2288 | if (hid_data->cc_report != 0 && |
| 2289 | hid_data->cc_index >= 0) { |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2290 | struct hid_field *field = report->field[hid_data->cc_index]; |
| 2291 | int value = field->value[hid_data->cc_value_index]; |
| 2292 | if (value) |
| 2293 | hid_data->num_expected = value; |
| 2294 | } |
| 2295 | else { |
| 2296 | hid_data->num_expected = wacom_wac->features.touch_max; |
| 2297 | } |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2300 | static void wacom_wac_finger_report(struct hid_device *hdev, |
| 2301 | struct hid_report *report) |
| 2302 | { |
| 2303 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2304 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2305 | struct input_dev *input = wacom_wac->touch_input; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2306 | unsigned touch_max = wacom_wac->features.touch_max; |
| 2307 | |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2308 | /* If more packets of data are expected, give us a chance to |
| 2309 | * process them rather than immediately syncing a partial |
| 2310 | * update. |
| 2311 | */ |
| 2312 | if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected) |
| 2313 | return; |
| 2314 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2315 | if (touch_max > 1) |
Jason Gerecke | 601a22f | 2014-12-10 16:26:04 -0800 | [diff] [blame] | 2316 | input_mt_sync_frame(input); |
| 2317 | |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2318 | input_sync(input); |
Jason Gerecke | 1b5d514a | 2015-07-21 11:07:24 -0700 | [diff] [blame] | 2319 | wacom_wac->hid_data.num_received = 0; |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2320 | |
| 2321 | /* keep touch state for pen event */ |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2322 | wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac); |
Benjamin Tissoires | 5ae6e89 | 2014-09-23 12:08:09 -0400 | [diff] [blame] | 2323 | } |
| 2324 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2325 | void wacom_wac_usage_mapping(struct hid_device *hdev, |
| 2326 | struct hid_field *field, struct hid_usage *usage) |
| 2327 | { |
| 2328 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2329 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 2330 | struct wacom_features *features = &wacom_wac->features; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2331 | |
Aaron Armstrong Skomra | ac2423c | 2017-01-25 12:08:40 -0800 | [diff] [blame] | 2332 | if (WACOM_DIRECT_DEVICE(field)) |
| 2333 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2334 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2335 | if (WACOM_PAD_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2336 | wacom_wac_pad_usage_mapping(hdev, field, usage); |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2337 | else if (WACOM_PEN_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2338 | wacom_wac_pen_usage_mapping(hdev, field, usage); |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2339 | else if (WACOM_FINGER_FIELD(field)) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2340 | wacom_wac_finger_usage_mapping(hdev, field, usage); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2341 | } |
| 2342 | |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2343 | void wacom_wac_event(struct hid_device *hdev, struct hid_field *field, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2344 | struct hid_usage *usage, __s32 value) |
| 2345 | { |
| 2346 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2347 | |
| 2348 | if (wacom->wacom_wac.features.type != HID_GENERIC) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2349 | return; |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2350 | |
Aaron Armstrong Skomra | 60a2218 | 2017-01-25 12:08:39 -0800 | [diff] [blame] | 2351 | if (value > field->logical_maximum || value < field->logical_minimum) |
| 2352 | return; |
| 2353 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2354 | if (WACOM_PAD_FIELD(field)) { |
| 2355 | wacom_wac_pad_battery_event(hdev, field, usage, value); |
| 2356 | if (wacom->wacom_wac.pad_input) |
| 2357 | wacom_wac_pad_event(hdev, field, usage, value); |
| 2358 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2359 | wacom_wac_pen_event(hdev, field, usage, value); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2360 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
Ping Cheng | 354a329 | 2016-12-08 22:03:27 -0800 | [diff] [blame] | 2361 | wacom_wac_finger_event(hdev, field, usage, value); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2362 | } |
| 2363 | |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2364 | static void wacom_report_events(struct hid_device *hdev, struct hid_report *report) |
| 2365 | { |
| 2366 | int r; |
| 2367 | |
| 2368 | for (r = 0; r < report->maxfield; r++) { |
| 2369 | struct hid_field *field; |
| 2370 | unsigned count, n; |
| 2371 | |
| 2372 | field = report->field[r]; |
| 2373 | count = field->report_count; |
| 2374 | |
| 2375 | if (!(HID_MAIN_ITEM_VARIABLE & field->flags)) |
| 2376 | continue; |
| 2377 | |
| 2378 | for (n = 0; n < count; n++) |
| 2379 | wacom_wac_event(hdev, field, &field->usage[n], field->value[n]); |
| 2380 | } |
| 2381 | } |
| 2382 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2383 | void wacom_wac_report(struct hid_device *hdev, struct hid_report *report) |
| 2384 | { |
| 2385 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 2386 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 2387 | struct hid_field *field = report->field[0]; |
| 2388 | |
| 2389 | if (wacom_wac->features.type != HID_GENERIC) |
| 2390 | return; |
| 2391 | |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2392 | if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 2393 | wacom_wac_pad_pre_report(hdev, report); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2394 | else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2395 | wacom_wac_pen_pre_report(hdev, report); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2396 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
Jason Gerecke | 06324e0 | 2015-07-21 11:07:23 -0700 | [diff] [blame] | 2397 | wacom_wac_finger_pre_report(hdev, report); |
| 2398 | |
| 2399 | wacom_report_events(hdev, report); |
| 2400 | |
Jason Gerecke | a9ce785 | 2017-01-17 15:38:58 -0800 | [diff] [blame] | 2401 | /* |
| 2402 | * Non-input reports may be sent prior to the device being |
| 2403 | * completely initialized. Since only their events need |
| 2404 | * to be processed, exit after 'wacom_report_events' has |
| 2405 | * been called to prevent potential crashes in the report- |
| 2406 | * processing functions. |
| 2407 | */ |
| 2408 | if (report->type != HID_INPUT_REPORT) |
| 2409 | return; |
| 2410 | |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2411 | if (WACOM_PAD_FIELD(field)) { |
| 2412 | wacom_wac_pad_battery_report(hdev, report); |
| 2413 | if (wacom->wacom_wac.pad_input) |
| 2414 | wacom_wac_pad_report(hdev, report); |
| 2415 | } else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) |
| 2416 | wacom_wac_pen_report(hdev, report); |
Ping Cheng | 6f46cf9 | 2016-12-08 22:04:52 -0800 | [diff] [blame] | 2417 | else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input) |
Ping Cheng | c9cfb2a | 2016-12-08 22:06:15 -0800 | [diff] [blame] | 2418 | wacom_wac_finger_report(hdev, report); |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 2419 | } |
| 2420 | |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 2421 | static int wacom_bpt_touch(struct wacom_wac *wacom) |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2422 | { |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 2423 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2424 | struct input_dev *input = wacom->touch_input; |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2425 | struct input_dev *pad_input = wacom->pad_input; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2426 | unsigned char *data = wacom->data; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2427 | int i; |
| 2428 | |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2429 | if (data[0] != 0x02) |
| 2430 | return 0; |
| 2431 | |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2432 | for (i = 0; i < 2; i++) { |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2433 | int offset = (data[1] & 0x80) ? (8 * i) : (9 * i); |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2434 | bool touch = report_touch_events(wacom) |
| 2435 | && (data[offset + 3] & 0x80); |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2436 | |
| 2437 | input_mt_slot(input, i); |
| 2438 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
Henrik Rydberg | c5f4dec | 2010-12-15 13:50:34 +0100 | [diff] [blame] | 2439 | if (touch) { |
Chris Bagwell | 8f90686 | 2011-09-09 13:38:10 -0700 | [diff] [blame] | 2440 | int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff; |
| 2441 | int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff; |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 2442 | if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) { |
| 2443 | x <<= 5; |
| 2444 | y <<= 5; |
| 2445 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2446 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 2447 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2448 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2449 | } |
| 2450 | |
Benjamin Tissoires | 9a1c001 | 2015-02-17 14:19:46 -0500 | [diff] [blame] | 2451 | input_mt_sync_frame(input); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2452 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2453 | input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0); |
| 2454 | input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0); |
| 2455 | input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0); |
| 2456 | input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0); |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2457 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2458 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2459 | return 1; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2460 | } |
| 2461 | |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2462 | 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] | 2463 | { |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2464 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2465 | struct input_dev *input = wacom->touch_input; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2466 | bool touch = data[1] & 0x80; |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 2467 | int slot = input_mt_get_slot_by_key(input, data[0]); |
| 2468 | |
| 2469 | if (slot < 0) |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2470 | return; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2471 | |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2472 | touch = touch && report_touch_events(wacom); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2473 | |
Ping Cheng | 02295e6 | 2013-01-04 23:56:00 -0800 | [diff] [blame] | 2474 | input_mt_slot(input, slot); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2475 | input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); |
| 2476 | |
| 2477 | if (touch) { |
| 2478 | int x = (data[2] << 4) | (data[4] >> 4); |
| 2479 | int y = (data[3] << 4) | (data[4] & 0x0f); |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2480 | int width, height; |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 2481 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2482 | if (features->type >= INTUOSPS && features->type <= INTUOSHT2) { |
Jason Gerecke | 0b279da | 2013-11-25 18:43:16 -0800 | [diff] [blame] | 2483 | width = data[5] * 100; |
| 2484 | height = data[6] * 100; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2485 | } else { |
| 2486 | /* |
| 2487 | * "a" is a scaled-down area which we assume is |
| 2488 | * roughly circular and which can be described as: |
| 2489 | * a=(pi*r^2)/C. |
| 2490 | */ |
| 2491 | int a = data[5]; |
Ping Cheng | d7da3a3 | 2014-06-13 13:37:33 -0700 | [diff] [blame] | 2492 | int x_res = input_abs_get_res(input, ABS_MT_POSITION_X); |
| 2493 | int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y); |
| 2494 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2495 | height = width * y_res / x_res; |
| 2496 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2497 | |
| 2498 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 2499 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
Jason Gerecke | 4e90495 | 2012-10-03 17:19:11 -0700 | [diff] [blame] | 2500 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, width); |
| 2501 | input_report_abs(input, ABS_MT_TOUCH_MINOR, height); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2502 | } |
| 2503 | } |
| 2504 | |
| 2505 | static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) |
| 2506 | { |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2507 | struct input_dev *input = wacom->pad_input; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2508 | struct wacom_features *features = &wacom->features; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2509 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2510 | if (features->type == INTUOSHT || features->type == INTUOSHT2) { |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2511 | input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0); |
| 2512 | input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0); |
| 2513 | } else { |
| 2514 | input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); |
| 2515 | input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); |
| 2516 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2517 | input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2518 | input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); |
| 2519 | } |
| 2520 | |
| 2521 | static int wacom_bpt3_touch(struct wacom_wac *wacom) |
| 2522 | { |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2523 | unsigned char *data = wacom->data; |
Jason Gerecke | 19d57d3 | 2012-03-06 10:19:19 -0800 | [diff] [blame] | 2524 | int count = data[1] & 0x07; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2525 | int touch_changed = 0, i; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2526 | |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2527 | if (data[0] != 0x02) |
| 2528 | return 0; |
| 2529 | |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2530 | /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ |
| 2531 | for (i = 0; i < count; i++) { |
| 2532 | int offset = (8 * i) + 2; |
| 2533 | int msg_id = data[offset]; |
| 2534 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2535 | if (msg_id >= 2 && msg_id <= 17) { |
Ping Cheng | 7d059ed | 2015-03-20 14:57:21 -0700 | [diff] [blame] | 2536 | wacom_bpt3_touch_msg(wacom, data + offset); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2537 | touch_changed++; |
| 2538 | } else if (msg_id == 128) |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2539 | wacom_bpt3_button_msg(wacom, data + offset); |
| 2540 | |
| 2541 | } |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2542 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2543 | /* 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] | 2544 | if (wacom->touch_input && touch_changed) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2545 | input_mt_sync_frame(wacom->touch_input); |
| 2546 | wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); |
| 2547 | } |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2548 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 2549 | return 1; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2550 | } |
| 2551 | |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2552 | static int wacom_bpt_pen(struct wacom_wac *wacom) |
| 2553 | { |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 2554 | struct wacom_features *features = &wacom->features; |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2555 | struct input_dev *input = wacom->pen_input; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2556 | unsigned char *data = wacom->data; |
| 2557 | int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; |
| 2558 | |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2559 | if (data[0] != WACOM_REPORT_PENABLED) |
Chris Bagwell | 5a6c865 | 2011-11-07 19:52:42 -0800 | [diff] [blame] | 2560 | return 0; |
| 2561 | |
Chris Bagwell | c598141 | 2011-10-26 22:28:34 -0700 | [diff] [blame] | 2562 | prox = (data[1] & 0x20) == 0x20; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2563 | |
| 2564 | /* |
| 2565 | * All reports shared between PEN and RUBBER tool must be |
| 2566 | * forced to a known starting value (zero) when transitioning to |
| 2567 | * out-of-prox. |
| 2568 | * |
| 2569 | * If not reset then, to userspace, it will look like lost events |
| 2570 | * if new tool comes in-prox with same values as previous tool sent. |
| 2571 | * |
| 2572 | * Hardware does report zero in most out-of-prox cases but not all. |
| 2573 | */ |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 2574 | if (!wacom->shared->stylus_in_proximity) { |
| 2575 | if (data[1] & 0x08) { |
| 2576 | wacom->tool[0] = BTN_TOOL_RUBBER; |
| 2577 | wacom->id[0] = ERASER_DEVICE_ID; |
| 2578 | } else { |
| 2579 | wacom->tool[0] = BTN_TOOL_PEN; |
| 2580 | wacom->id[0] = STYLUS_DEVICE_ID; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2581 | } |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 2582 | } |
| 2583 | |
| 2584 | wacom->shared->stylus_in_proximity = prox; |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2585 | if (delay_pen_events(wacom)) |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 2586 | return 0; |
| 2587 | |
| 2588 | if (prox) { |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2589 | x = le16_to_cpup((__le16 *)&data[2]); |
| 2590 | y = le16_to_cpup((__le16 *)&data[4]); |
| 2591 | p = le16_to_cpup((__le16 *)&data[6]); |
Chris Bagwell | c18c2ce | 2011-10-10 08:52:13 -0700 | [diff] [blame] | 2592 | /* |
| 2593 | * Convert distance from out prox to distance from tablet. |
| 2594 | * distance will be greater than distance_max once |
| 2595 | * touching and applying pressure; do not report negative |
| 2596 | * distance. |
| 2597 | */ |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 2598 | if (data[8] <= features->distance_max) |
| 2599 | d = features->distance_max - data[8]; |
Chris Bagwell | c18c2ce | 2011-10-10 08:52:13 -0700 | [diff] [blame] | 2600 | |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2601 | pen = data[1] & 0x01; |
| 2602 | btn1 = data[1] & 0x02; |
| 2603 | btn2 = data[1] & 0x04; |
Ping Cheng | 0149931 | 2015-03-20 14:58:01 -0700 | [diff] [blame] | 2604 | } else { |
| 2605 | wacom->id[0] = 0; |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2606 | } |
| 2607 | |
| 2608 | input_report_key(input, BTN_TOUCH, pen); |
| 2609 | input_report_key(input, BTN_STYLUS, btn1); |
| 2610 | input_report_key(input, BTN_STYLUS2, btn2); |
| 2611 | |
| 2612 | input_report_abs(input, ABS_X, x); |
| 2613 | input_report_abs(input, ABS_Y, y); |
| 2614 | input_report_abs(input, ABS_PRESSURE, p); |
| 2615 | input_report_abs(input, ABS_DISTANCE, d); |
| 2616 | |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2617 | input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */ |
| 2618 | input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */ |
| 2619 | |
| 2620 | return 1; |
| 2621 | } |
| 2622 | |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 2623 | static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) |
| 2624 | { |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2625 | struct wacom_features *features = &wacom->features; |
| 2626 | |
| 2627 | if ((features->type == INTUOSHT2) && |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2628 | (features->device_type & WACOM_DEVICETYPE_PEN)) |
| 2629 | return wacom_intuos_irq(wacom); |
| 2630 | else if (len == WACOM_PKGLEN_BBTOUCH) |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 2631 | return wacom_bpt_touch(wacom); |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 2632 | else if (len == WACOM_PKGLEN_BBTOUCH3) |
| 2633 | return wacom_bpt3_touch(wacom); |
| 2634 | else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN) |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 2635 | return wacom_bpt_pen(wacom); |
Chris Bagwell | e1d38e4 | 2010-09-12 00:09:27 -0700 | [diff] [blame] | 2636 | |
| 2637 | return 0; |
| 2638 | } |
| 2639 | |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 2640 | static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom, |
| 2641 | unsigned char *data) |
| 2642 | { |
| 2643 | unsigned char prefix; |
| 2644 | |
| 2645 | /* |
| 2646 | * We need to reroute the event from the debug interface to the |
| 2647 | * pen interface. |
| 2648 | * We need to add the report ID to the actual pen report, so we |
| 2649 | * temporary overwrite the first byte to prevent having to kzalloc/kfree |
| 2650 | * and memcpy the report. |
| 2651 | */ |
| 2652 | prefix = data[0]; |
| 2653 | data[0] = WACOM_REPORT_BPAD_PEN; |
| 2654 | |
| 2655 | /* |
| 2656 | * actually reroute the event. |
| 2657 | * No need to check if wacom->shared->pen is valid, hid_input_report() |
| 2658 | * will check for us. |
| 2659 | */ |
| 2660 | hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data, |
| 2661 | WACOM_PKGLEN_PENABLED, 1); |
| 2662 | |
| 2663 | data[0] = prefix; |
| 2664 | } |
| 2665 | |
| 2666 | static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, |
| 2667 | unsigned char *data) |
| 2668 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2669 | struct input_dev *input = wacom->touch_input; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 2670 | unsigned char *finger_data, prefix; |
| 2671 | unsigned id; |
| 2672 | int x, y; |
| 2673 | bool valid; |
| 2674 | |
| 2675 | prefix = data[0]; |
| 2676 | |
| 2677 | for (id = 0; id < wacom->features.touch_max; id++) { |
| 2678 | valid = !!(prefix & BIT(id)) && |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2679 | report_touch_events(wacom); |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 2680 | |
| 2681 | input_mt_slot(input, id); |
| 2682 | input_mt_report_slot_state(input, MT_TOOL_FINGER, valid); |
| 2683 | |
| 2684 | if (!valid) |
| 2685 | continue; |
| 2686 | |
| 2687 | finger_data = data + 1 + id * 3; |
| 2688 | x = finger_data[0] | ((finger_data[1] & 0x0f) << 8); |
| 2689 | y = (finger_data[2] << 4) | (finger_data[1] >> 4); |
| 2690 | |
| 2691 | input_report_abs(input, ABS_MT_POSITION_X, x); |
| 2692 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
| 2693 | } |
| 2694 | |
| 2695 | input_mt_sync_frame(input); |
| 2696 | |
| 2697 | input_report_key(input, BTN_LEFT, prefix & 0x40); |
| 2698 | input_report_key(input, BTN_RIGHT, prefix & 0x80); |
| 2699 | |
| 2700 | /* keep touch state for pen event */ |
Ping Cheng | 1924e05 | 2016-08-09 14:38:56 -0700 | [diff] [blame] | 2701 | wacom->shared->touch_down = !!prefix && report_touch_events(wacom); |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 2702 | |
| 2703 | return 1; |
| 2704 | } |
| 2705 | |
| 2706 | static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len) |
| 2707 | { |
| 2708 | unsigned char *data = wacom->data; |
| 2709 | |
| 2710 | if (!((len == WACOM_PKGLEN_BPAD_TOUCH) || |
| 2711 | (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) || |
| 2712 | (data[0] != WACOM_REPORT_BPAD_TOUCH)) |
| 2713 | return 0; |
| 2714 | |
| 2715 | if (data[1] & 0x01) |
| 2716 | wacom_bamboo_pad_pen_event(wacom, &data[1]); |
| 2717 | |
| 2718 | if (data[1] & 0x02) |
| 2719 | return wacom_bamboo_pad_touch_event(wacom, &data[9]); |
| 2720 | |
| 2721 | return 0; |
| 2722 | } |
| 2723 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 2724 | static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len) |
| 2725 | { |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2726 | unsigned char *data = wacom->data; |
| 2727 | int connected; |
| 2728 | |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2729 | if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL) |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 2730 | return 0; |
| 2731 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2732 | connected = data[1] & 0x01; |
| 2733 | if (connected) { |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 2734 | int pid, battery, charging; |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2735 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2736 | if ((wacom->shared->type == INTUOSHT || |
| 2737 | wacom->shared->type == INTUOSHT2) && |
Ping Cheng | 44b9683 | 2014-11-06 17:30:51 -0800 | [diff] [blame] | 2738 | wacom->shared->touch_input && |
| 2739 | wacom->shared->touch_max) { |
Ping Cheng | 961794a | 2013-12-05 12:54:53 -0800 | [diff] [blame] | 2740 | input_report_switch(wacom->shared->touch_input, |
| 2741 | SW_MUTE_DEVICE, data[5] & 0x40); |
| 2742 | input_sync(wacom->shared->touch_input); |
| 2743 | } |
| 2744 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2745 | pid = get_unaligned_be16(&data[6]); |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 2746 | battery = (data[5] & 0x3f) * 100 / 31; |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 2747 | charging = !!(data[5] & 0x80); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2748 | if (wacom->pid != pid) { |
| 2749 | wacom->pid = pid; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 2750 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2751 | } |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 2752 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 2753 | wacom_notify_battery(wacom, battery, charging, 1, 0); |
Jason Gerecke | 953f2c5 | 2015-03-06 11:47:39 -0800 | [diff] [blame] | 2754 | |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2755 | } else if (wacom->pid != 0) { |
| 2756 | /* disconnected while previously connected */ |
| 2757 | wacom->pid = 0; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 2758 | wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS); |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 2759 | wacom_notify_battery(wacom, 0, 0, 0, 0); |
Chris Bagwell | 16bf288 | 2012-03-25 23:26:20 -0700 | [diff] [blame] | 2760 | } |
| 2761 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 2762 | return 0; |
| 2763 | } |
| 2764 | |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2765 | static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len) |
| 2766 | { |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2767 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2768 | struct wacom_features *features = &wacom_wac->features; |
| 2769 | unsigned char *data = wacom_wac->data; |
| 2770 | |
| 2771 | if (data[0] != WACOM_REPORT_USB) |
| 2772 | return 0; |
| 2773 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2774 | if ((features->type == INTUOSHT || |
| 2775 | features->type == INTUOSHT2) && |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2776 | wacom_wac->shared->touch_input && |
| 2777 | features->touch_max) { |
| 2778 | input_report_switch(wacom_wac->shared->touch_input, |
| 2779 | SW_MUTE_DEVICE, data[8] & 0x40); |
| 2780 | input_sync(wacom_wac->shared->touch_input); |
| 2781 | } |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2782 | |
| 2783 | if (data[9] & 0x02) { /* wireless module is attached */ |
| 2784 | int battery = (data[8] & 0x3f) * 100 / 31; |
Jason Gerecke | b0882cb | 2015-03-06 11:47:43 -0800 | [diff] [blame] | 2785 | bool charging = !!(data[8] & 0x80); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2786 | |
| 2787 | wacom_notify_battery(wacom_wac, battery, charging, |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 2788 | battery || charging, 1); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2789 | |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 2790 | if (!wacom->battery.battery && |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2791 | !(features->quirks & WACOM_QUIRK_BATTERY)) { |
| 2792 | features->quirks |= WACOM_QUIRK_BATTERY; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 2793 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2794 | } |
| 2795 | } |
| 2796 | else if ((features->quirks & WACOM_QUIRK_BATTERY) && |
Benjamin Tissoires | 59d69bc | 2016-07-13 18:06:08 +0200 | [diff] [blame] | 2797 | wacom->battery.battery) { |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2798 | features->quirks &= ~WACOM_QUIRK_BATTERY; |
Benjamin Tissoires | d17d1f1 | 2016-07-13 18:05:52 +0200 | [diff] [blame] | 2799 | wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY); |
Jason Gerecke | 71fa641 | 2015-03-11 10:25:41 -0700 | [diff] [blame] | 2800 | wacom_notify_battery(wacom_wac, 0, 0, 0, 0); |
Jason Gerecke | 8f93b0b | 2015-03-06 11:47:41 -0800 | [diff] [blame] | 2801 | } |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2802 | return 0; |
| 2803 | } |
| 2804 | |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2805 | void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2806 | { |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2807 | bool sync; |
| 2808 | |
Jason Childs | e33da8a | 2010-02-17 22:38:31 -0800 | [diff] [blame] | 2809 | switch (wacom_wac->features.type) { |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2810 | case PENPARTNER: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2811 | sync = wacom_penpartner_irq(wacom_wac); |
| 2812 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2813 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2814 | case PL: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2815 | sync = wacom_pl_irq(wacom_wac); |
| 2816 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2817 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2818 | case WACOM_G4: |
| 2819 | case GRAPHIRE: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 2820 | case GRAPHIRE_BT: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2821 | case WACOM_MO: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2822 | sync = wacom_graphire_irq(wacom_wac); |
| 2823 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2824 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2825 | case PTU: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2826 | sync = wacom_ptu_irq(wacom_wac); |
| 2827 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2828 | |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 2829 | case DTU: |
| 2830 | sync = wacom_dtu_irq(wacom_wac); |
| 2831 | break; |
| 2832 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 2833 | case DTUS: |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 2834 | case DTUSX: |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 2835 | sync = wacom_dtus_irq(wacom_wac); |
| 2836 | break; |
| 2837 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2838 | case INTUOS: |
| 2839 | case INTUOS3S: |
| 2840 | case INTUOS3: |
| 2841 | case INTUOS3L: |
| 2842 | case INTUOS4S: |
| 2843 | case INTUOS4: |
| 2844 | case INTUOS4L: |
| 2845 | case CINTIQ: |
| 2846 | case WACOM_BEE: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 2847 | case WACOM_13HD: |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 2848 | case WACOM_21UX2: |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 2849 | case WACOM_22HD: |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 2850 | case WACOM_24HD: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 2851 | case WACOM_27QHD: |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 2852 | case DTK: |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 2853 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 2854 | case CINTIQ_COMPANION_2: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2855 | sync = wacom_intuos_irq(wacom_wac); |
| 2856 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2857 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 2858 | case INTUOS4WL: |
| 2859 | sync = wacom_intuos_bt_irq(wacom_wac, len); |
| 2860 | break; |
| 2861 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 2862 | case WACOM_24HDT: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 2863 | case WACOM_27QHDT: |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 2864 | sync = wacom_24hdt_irq(wacom_wac); |
| 2865 | break; |
| 2866 | |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 2867 | case INTUOS5S: |
| 2868 | case INTUOS5: |
| 2869 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 2870 | case INTUOSPS: |
| 2871 | case INTUOSPM: |
| 2872 | case INTUOSPL: |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 2873 | if (len == WACOM_PKGLEN_BBTOUCH3) |
| 2874 | sync = wacom_bpt3_touch(wacom_wac); |
Jason Gerecke | 2d13a43 | 2015-03-06 11:47:42 -0800 | [diff] [blame] | 2875 | else if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 2876 | sync = wacom_status_irq(wacom_wac, len); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 2877 | else |
| 2878 | sync = wacom_intuos_irq(wacom_wac); |
| 2879 | break; |
| 2880 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 2881 | case INTUOSP2_BT: |
| 2882 | sync = wacom_intuos_pro2_bt_irq(wacom_wac, len); |
| 2883 | break; |
| 2884 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2885 | case TABLETPC: |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 2886 | case TABLETPCE: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2887 | case TABLETPC2FG: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 2888 | case MTSCREEN: |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 2889 | case MTTPC: |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 2890 | case MTTPC_B: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2891 | sync = wacom_tpc_irq(wacom_wac, len); |
| 2892 | break; |
Ping Cheng | 545f4e9 | 2008-11-24 11:44:27 -0500 | [diff] [blame] | 2893 | |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2894 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 2895 | case BAMBOO_PEN: |
| 2896 | case BAMBOO_TOUCH: |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 2897 | case INTUOSHT: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2898 | case INTUOSHT2: |
Jason Gerecke | 4ca4ec7 | 2015-03-06 11:47:38 -0800 | [diff] [blame] | 2899 | if (wacom_wac->data[0] == WACOM_REPORT_USB) |
| 2900 | sync = wacom_status_irq(wacom_wac, len); |
| 2901 | else |
| 2902 | sync = wacom_bpt_irq(wacom_wac, len); |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 2903 | break; |
| 2904 | |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 2905 | case BAMBOO_PAD: |
| 2906 | sync = wacom_bamboo_pad_irq(wacom_wac, len); |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2907 | break; |
| 2908 | |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 2909 | case WIRELESS: |
| 2910 | sync = wacom_wireless_irq(wacom_wac, len); |
| 2911 | break; |
| 2912 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 2913 | case REMOTE: |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 2914 | sync = false; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 2915 | if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST) |
Benjamin Tissoires | e6f2813 | 2016-07-13 18:06:01 +0200 | [diff] [blame] | 2916 | wacom_remote_status_irq(wacom_wac, len); |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 2917 | else |
| 2918 | sync = wacom_remote_irq(wacom_wac, len); |
| 2919 | break; |
| 2920 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2921 | default: |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2922 | sync = false; |
| 2923 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2924 | } |
Dmitry Torokhov | 95dd3b3 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2925 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 2926 | if (sync) { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2927 | if (wacom_wac->pen_input) |
| 2928 | input_sync(wacom_wac->pen_input); |
| 2929 | if (wacom_wac->touch_input) |
| 2930 | input_sync(wacom_wac->touch_input); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 2931 | if (wacom_wac->pad_input) |
| 2932 | input_sync(wacom_wac->pad_input); |
| 2933 | } |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2934 | } |
| 2935 | |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2936 | static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac) |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 2937 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2938 | struct input_dev *input_dev = wacom_wac->pen_input; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2939 | |
| 2940 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2941 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2942 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2943 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 2944 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 2945 | |
| 2946 | input_set_abs_params(input_dev, ABS_DISTANCE, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 2947 | 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2948 | } |
| 2949 | |
| 2950 | static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) |
| 2951 | { |
| 2952 | struct input_dev *input_dev = wacom_wac->pen_input; |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 2953 | struct wacom_features *features = &wacom_wac->features; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 2954 | |
| 2955 | wacom_setup_basic_pro_pen(wacom_wac); |
| 2956 | |
| 2957 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 2958 | __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); |
| 2959 | __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); |
| 2960 | __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); |
| 2961 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2962 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 2963 | 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] | 2964 | input_abs_set_res(input_dev, ABS_TILT_X, 57); |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 2965 | 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] | 2966 | input_abs_set_res(input_dev, ABS_TILT_Y, 57); |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 2967 | } |
| 2968 | |
| 2969 | static void wacom_setup_intuos(struct wacom_wac *wacom_wac) |
| 2970 | { |
Jason Gerecke | 2a6cdbd | 2015-06-15 18:01:45 -0700 | [diff] [blame] | 2971 | struct input_dev *input_dev = wacom_wac->pen_input; |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 2972 | |
| 2973 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 2974 | |
| 2975 | wacom_setup_cintiq(wacom_wac); |
| 2976 | |
| 2977 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 2978 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 2979 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 2980 | __set_bit(BTN_SIDE, input_dev->keybit); |
| 2981 | __set_bit(BTN_EXTRA, input_dev->keybit); |
| 2982 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 2983 | __set_bit(BTN_TOOL_LENS, input_dev->keybit); |
| 2984 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2985 | input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 2986 | input_abs_set_res(input_dev, ABS_RZ, 287); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 2987 | input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); |
| 2988 | } |
| 2989 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 2990 | void wacom_setup_device_quirks(struct wacom *wacom) |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 2991 | { |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 2992 | struct wacom_features *features = &wacom->wacom_wac.features; |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 2993 | |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 2994 | /* The pen and pad share the same interface on most devices */ |
| 2995 | if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 || |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 2996 | features->type == DTUS || |
| 2997 | (features->type >= INTUOS3S && features->type <= WACOM_MO)) { |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 2998 | if (features->device_type & WACOM_DEVICETYPE_PEN) |
| 2999 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3000 | } |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3001 | |
| 3002 | /* touch device found but size is not defined. use default */ |
Jason Gerecke | aa86b18 | 2015-06-15 18:01:42 -0700 | [diff] [blame] | 3003 | if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) { |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3004 | features->x_max = 1023; |
| 3005 | features->y_max = 1023; |
| 3006 | } |
| 3007 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3008 | /* |
| 3009 | * Intuos5/Pro and Bamboo 3rd gen have no useful data about its |
| 3010 | * touch interface in its HID descriptor. If this is the touch |
| 3011 | * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the |
| 3012 | * tablet values. |
| 3013 | */ |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3014 | if ((features->type >= INTUOS5S && features->type <= INTUOSPL) || |
| 3015 | (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) { |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3016 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3017 | if (features->touch_max) |
| 3018 | features->device_type |= WACOM_DEVICETYPE_TOUCH; |
Jiri Kosina | a3088ab | 2015-11-17 00:24:14 +0100 | [diff] [blame] | 3019 | if (features->type >= INTUOSHT && features->type <= BAMBOO_PT) |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3020 | features->device_type |= WACOM_DEVICETYPE_PAD; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3021 | |
| 3022 | features->x_max = 4096; |
| 3023 | features->y_max = 4096; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3024 | } |
Jason Gerecke | 9633920 | 2015-07-01 13:01:00 -0700 | [diff] [blame] | 3025 | else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
| 3026 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3027 | } |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3028 | } |
| 3029 | |
| 3030 | /* |
Benjamin Tissoires | 580549e | 2016-03-25 15:26:55 +0100 | [diff] [blame] | 3031 | * Hack for the Bamboo One: |
| 3032 | * the device presents a PAD/Touch interface as most Bamboos and even |
| 3033 | * sends ghosts PAD data on it. However, later, we must disable this |
| 3034 | * ghost interface, and we can not detect it unless we set it here |
| 3035 | * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH. |
| 3036 | */ |
| 3037 | if (features->type == BAMBOO_PEN && |
| 3038 | features->pktlen == WACOM_PKGLEN_BBTOUCH3) |
| 3039 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3040 | |
| 3041 | /* |
Jason Gerecke | 042628a | 2015-04-30 17:51:54 -0700 | [diff] [blame] | 3042 | * Raw Wacom-mode pen and touch events both come from interface |
| 3043 | * 0, whose HID descriptor has an application usage of 0xFF0D |
Jason Gerecke | 8de8228 | 2016-10-19 18:03:37 -0700 | [diff] [blame] | 3044 | * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back |
Jason Gerecke | 042628a | 2015-04-30 17:51:54 -0700 | [diff] [blame] | 3045 | * out through the HID_GENERIC device created for interface 1, |
Benjamin Tissoires | 70caee0 | 2015-07-09 14:11:51 -0400 | [diff] [blame] | 3046 | * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH. |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3047 | */ |
| 3048 | if (features->type == BAMBOO_PAD) |
Benjamin Tissoires | 70caee0 | 2015-07-09 14:11:51 -0400 | [diff] [blame] | 3049 | features->device_type = WACOM_DEVICETYPE_TOUCH; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3050 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3051 | if (features->type == REMOTE) |
| 3052 | features->device_type = WACOM_DEVICETYPE_PAD; |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3053 | |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3054 | if (features->type == INTUOSP2_BT) { |
| 3055 | features->device_type |= WACOM_DEVICETYPE_PEN | |
| 3056 | WACOM_DEVICETYPE_PAD | |
| 3057 | WACOM_DEVICETYPE_TOUCH; |
| 3058 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3059 | } |
| 3060 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3061 | switch (features->type) { |
| 3062 | case PL: |
| 3063 | case DTU: |
| 3064 | case DTUS: |
| 3065 | case DTUSX: |
| 3066 | case WACOM_21UX2: |
| 3067 | case WACOM_22HD: |
| 3068 | case DTK: |
| 3069 | case WACOM_24HD: |
| 3070 | case WACOM_27QHD: |
| 3071 | case CINTIQ_HYBRID: |
| 3072 | case CINTIQ_COMPANION_2: |
| 3073 | case CINTIQ: |
| 3074 | case WACOM_BEE: |
| 3075 | case WACOM_13HD: |
| 3076 | case WACOM_24HDT: |
| 3077 | case WACOM_27QHDT: |
| 3078 | case TABLETPC: |
| 3079 | case TABLETPCE: |
| 3080 | case TABLETPC2FG: |
| 3081 | case MTSCREEN: |
| 3082 | case MTTPC: |
| 3083 | case MTTPC_B: |
| 3084 | features->device_type |= WACOM_DEVICETYPE_DIRECT; |
| 3085 | break; |
| 3086 | } |
| 3087 | |
Ping Cheng | 42f4f27 | 2015-04-15 16:53:54 -0700 | [diff] [blame] | 3088 | if (wacom->hdev->bus == BUS_BLUETOOTH) |
| 3089 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3090 | |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 3091 | /* quirk for bamboo touch with 2 low res touches */ |
Jason Gerecke | be853fd | 2015-12-04 14:45:27 -0800 | [diff] [blame] | 3092 | if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 3093 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 3094 | features->x_max <<= 5; |
| 3095 | features->y_max <<= 5; |
| 3096 | features->x_fuzz <<= 5; |
| 3097 | features->y_fuzz <<= 5; |
Henrik Rydberg | f4ccbef | 2010-09-05 12:57:13 -0700 | [diff] [blame] | 3098 | features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3099 | } |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3100 | |
| 3101 | if (features->type == WIRELESS) { |
Jason Gerecke | ccad85c | 2015-08-03 10:17:04 -0700 | [diff] [blame] | 3102 | if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) { |
Benjamin Tissoires | ac8d101 | 2014-07-25 17:29:48 -0700 | [diff] [blame] | 3103 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 3104 | } |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 3105 | } |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 3106 | |
| 3107 | if (features->type == REMOTE) |
| 3108 | features->device_type |= WACOM_DEVICETYPE_WL_MONITOR; |
Henrik Rydberg | bc73dd3 | 2010-09-05 12:26:16 -0700 | [diff] [blame] | 3109 | } |
| 3110 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3111 | int wacom_setup_pen_input_capabilities(struct input_dev *input_dev, |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3112 | struct wacom_wac *wacom_wac) |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3113 | { |
| 3114 | struct wacom_features *features = &wacom_wac->features; |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3115 | |
| 3116 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 3117 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3118 | if (!(features->device_type & WACOM_DEVICETYPE_PEN)) |
| 3119 | return -ENODEV; |
| 3120 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3121 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3122 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3123 | else |
| 3124 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3125 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 3126 | if (features->type == HID_GENERIC) |
| 3127 | /* setup has already been done */ |
| 3128 | return 0; |
| 3129 | |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3130 | __set_bit(BTN_TOUCH, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3131 | __set_bit(ABS_MISC, input_dev->absbit); |
| 3132 | |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3133 | input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left, |
| 3134 | features->x_max - features->offset_right, |
| 3135 | features->x_fuzz, 0); |
| 3136 | input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top, |
| 3137 | features->y_max - features->offset_bottom, |
| 3138 | features->y_fuzz, 0); |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3139 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, |
| 3140 | features->pressure_max, features->pressure_fuzz, 0); |
| 3141 | |
| 3142 | /* penabled devices have fixed resolution for each model */ |
| 3143 | input_abs_set_res(input_dev, ABS_X, features->x_resolution); |
| 3144 | input_abs_set_res(input_dev, ABS_Y, features->y_resolution); |
| 3145 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3146 | switch (features->type) { |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3147 | case GRAPHIRE_BT: |
| 3148 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3149 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3150 | case WACOM_MO: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3151 | case WACOM_G4: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3152 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
| 3153 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3154 | features->distance_fuzz, 0); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3155 | /* fall through */ |
| 3156 | |
| 3157 | case GRAPHIRE: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3158 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 3159 | |
| 3160 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3161 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3162 | __set_bit(BTN_MIDDLE, input_dev->keybit); |
| 3163 | |
| 3164 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3165 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3166 | __set_bit(BTN_TOOL_MOUSE, input_dev->keybit); |
| 3167 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3168 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3169 | break; |
| 3170 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3171 | case WACOM_27QHD: |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 3172 | case WACOM_24HD: |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 3173 | case DTK: |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 3174 | case WACOM_22HD: |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 3175 | case WACOM_21UX2: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3176 | case WACOM_BEE: |
Ping Cheng | 6521d0b | 2010-10-24 21:53:40 -0700 | [diff] [blame] | 3177 | case CINTIQ: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3178 | case WACOM_13HD: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3179 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 3180 | case CINTIQ_COMPANION_2: |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3181 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3182 | input_abs_set_res(input_dev, ABS_Z, 287); |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3183 | wacom_setup_cintiq(wacom_wac); |
| 3184 | break; |
| 3185 | |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3186 | case INTUOS3: |
| 3187 | case INTUOS3L: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3188 | case INTUOS3S: |
Ping Cheng | a2f71c6 | 2015-01-27 13:29:36 -0800 | [diff] [blame] | 3189 | case INTUOS4: |
| 3190 | case INTUOS4WL: |
| 3191 | case INTUOS4L: |
| 3192 | case INTUOS4S: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3193 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
Jason Gerecke | 26fe412 | 2014-11-18 16:50:09 -0800 | [diff] [blame] | 3194 | input_abs_set_res(input_dev, ABS_Z, 287); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3195 | /* fall through */ |
| 3196 | |
| 3197 | case INTUOS: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3198 | wacom_setup_intuos(wacom_wac); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3199 | break; |
| 3200 | |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3201 | case INTUOS5: |
| 3202 | case INTUOS5L: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3203 | case INTUOSPM: |
| 3204 | case INTUOSPL: |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3205 | case INTUOS5S: |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3206 | case INTUOSPS: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3207 | case INTUOSP2_BT: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3208 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
| 3209 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3210 | features->distance_fuzz, 0); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3211 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3212 | input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); |
| 3213 | input_abs_set_res(input_dev, ABS_Z, 287); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3214 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3215 | wacom_setup_intuos(wacom_wac); |
Jason Gerecke | ae584ca | 2012-04-03 15:50:40 -0700 | [diff] [blame] | 3216 | break; |
| 3217 | |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 3218 | case WACOM_24HDT: |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3219 | case WACOM_27QHDT: |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3220 | case MTSCREEN: |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 3221 | case MTTPC: |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 3222 | case MTTPC_B: |
Ping Cheng | 6795a52 | 2012-06-28 16:49:00 -0700 | [diff] [blame] | 3223 | case TABLETPC2FG: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3224 | case TABLETPC: |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 3225 | case TABLETPCE: |
Ping Cheng | a43c7c5 | 2011-03-12 20:34:42 -0800 | [diff] [blame] | 3226 | __clear_bit(ABS_MISC, input_dev->absbit); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3227 | /* fall through */ |
| 3228 | |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3229 | case DTUS: |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 3230 | case DTUSX: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3231 | case PL: |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 3232 | case DTU: |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3233 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Jason Gerecke | 3512069 | 2011-09-08 09:38:14 -0700 | [diff] [blame] | 3234 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3235 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3236 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
Jason Gerecke | 3512069 | 2011-09-08 09:38:14 -0700 | [diff] [blame] | 3237 | break; |
| 3238 | |
| 3239 | case PTU: |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3240 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3241 | /* fall through */ |
| 3242 | |
| 3243 | case PENPARTNER: |
Jason Gerecke | 1fab84a | 2011-08-26 23:18:22 -0700 | [diff] [blame] | 3244 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
Dmitry Torokhov | 8da23fc | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3245 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
Jason Gerecke | 1fab84a | 2011-08-26 23:18:22 -0700 | [diff] [blame] | 3246 | __set_bit(BTN_STYLUS, input_dev->keybit); |
Dmitry Torokhov | 73a97f4 | 2010-03-19 22:18:15 -0700 | [diff] [blame] | 3247 | break; |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3248 | |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 3249 | case INTUOSHT: |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3250 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3251 | case BAMBOO_PEN: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3252 | case INTUOSHT2: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3253 | if (features->type == INTUOSHT2) { |
| 3254 | wacom_setup_basic_pro_pen(wacom_wac); |
| 3255 | } else { |
| 3256 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3257 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); |
| 3258 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); |
| 3259 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3260 | __set_bit(BTN_STYLUS2, input_dev->keybit); |
| 3261 | input_set_abs_params(input_dev, ABS_DISTANCE, 0, |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3262 | features->distance_max, |
Jason Gerecke | bef7e20 | 2016-04-22 14:30:53 -0700 | [diff] [blame] | 3263 | features->distance_fuzz, 0); |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3264 | } |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 3265 | break; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3266 | case BAMBOO_PAD: |
| 3267 | __clear_bit(ABS_MISC, input_dev->absbit); |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3268 | break; |
| 3269 | } |
| 3270 | return 0; |
| 3271 | } |
| 3272 | |
| 3273 | int wacom_setup_touch_input_capabilities(struct input_dev *input_dev, |
| 3274 | struct wacom_wac *wacom_wac) |
| 3275 | { |
| 3276 | struct wacom_features *features = &wacom_wac->features; |
| 3277 | |
| 3278 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 3279 | |
| 3280 | if (!(features->device_type & WACOM_DEVICETYPE_TOUCH)) |
| 3281 | return -ENODEV; |
| 3282 | |
Jason Gerecke | e5bc8eb | 2016-08-08 12:06:29 -0700 | [diff] [blame] | 3283 | if (features->device_type & WACOM_DEVICETYPE_DIRECT) |
| 3284 | __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); |
| 3285 | else |
| 3286 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); |
| 3287 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3288 | if (features->type == HID_GENERIC) |
| 3289 | /* setup has already been done */ |
| 3290 | return 0; |
| 3291 | |
| 3292 | __set_bit(BTN_TOUCH, input_dev->keybit); |
| 3293 | |
| 3294 | if (features->touch_max == 1) { |
| 3295 | input_set_abs_params(input_dev, ABS_X, 0, |
| 3296 | features->x_max, features->x_fuzz, 0); |
| 3297 | input_set_abs_params(input_dev, ABS_Y, 0, |
| 3298 | features->y_max, features->y_fuzz, 0); |
| 3299 | input_abs_set_res(input_dev, ABS_X, |
| 3300 | features->x_resolution); |
| 3301 | input_abs_set_res(input_dev, ABS_Y, |
| 3302 | features->y_resolution); |
| 3303 | } |
| 3304 | else if (features->touch_max > 1) { |
| 3305 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, |
| 3306 | features->x_max, features->x_fuzz, 0); |
| 3307 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, |
| 3308 | features->y_max, features->y_fuzz, 0); |
| 3309 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, |
| 3310 | features->x_resolution); |
| 3311 | input_abs_set_res(input_dev, ABS_MT_POSITION_Y, |
| 3312 | features->y_resolution); |
| 3313 | } |
| 3314 | |
| 3315 | switch (features->type) { |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3316 | case INTUOSP2_BT: |
| 3317 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3318 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 3319 | |
| 3320 | if (wacom_wac->shared->touch->product == 0x361) { |
| 3321 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
| 3322 | 0, 12440, 4, 0); |
| 3323 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
| 3324 | 0, 8640, 4, 0); |
| 3325 | } |
| 3326 | else if (wacom_wac->shared->touch->product == 0x360) { |
| 3327 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
| 3328 | 0, 8960, 4, 0); |
| 3329 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, |
| 3330 | 0, 5920, 4, 0); |
| 3331 | } |
| 3332 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); |
| 3333 | input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40); |
| 3334 | |
| 3335 | /* fall through */ |
| 3336 | |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3337 | case INTUOS5: |
| 3338 | case INTUOS5L: |
| 3339 | case INTUOSPM: |
| 3340 | case INTUOSPL: |
| 3341 | case INTUOS5S: |
| 3342 | case INTUOSPS: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3343 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); |
| 3344 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0); |
| 3345 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
| 3346 | break; |
| 3347 | |
| 3348 | case WACOM_24HDT: |
| 3349 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0); |
| 3350 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0); |
| 3351 | input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0); |
| 3352 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); |
| 3353 | /* fall through */ |
| 3354 | |
| 3355 | case WACOM_27QHDT: |
| 3356 | case MTSCREEN: |
| 3357 | case MTTPC: |
| 3358 | case MTTPC_B: |
| 3359 | case TABLETPC2FG: |
| 3360 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); |
| 3361 | /*fall through */ |
| 3362 | |
| 3363 | case TABLETPC: |
| 3364 | case TABLETPCE: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3365 | break; |
| 3366 | |
| 3367 | case INTUOSHT: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3368 | case INTUOSHT2: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3369 | input_dev->evbit[0] |= BIT_MASK(EV_SW); |
| 3370 | __set_bit(SW_MUTE_DEVICE, input_dev->swbit); |
| 3371 | /* fall through */ |
| 3372 | |
| 3373 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3374 | case BAMBOO_TOUCH: |
Jason Gerecke | 2636a3f | 2015-06-15 18:01:44 -0700 | [diff] [blame] | 3375 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 3376 | input_set_abs_params(input_dev, |
| 3377 | ABS_MT_TOUCH_MAJOR, |
| 3378 | 0, features->x_max, 0, 0); |
| 3379 | input_set_abs_params(input_dev, |
| 3380 | ABS_MT_TOUCH_MINOR, |
| 3381 | 0, features->y_max, 0, 0); |
| 3382 | } |
| 3383 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
| 3384 | break; |
| 3385 | |
| 3386 | case BAMBOO_PAD: |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 3387 | input_mt_init_slots(input_dev, features->touch_max, |
| 3388 | INPUT_MT_POINTER); |
| 3389 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3390 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3391 | break; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3392 | } |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 3393 | return 0; |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 3394 | } |
| 3395 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 3396 | static int wacom_numbered_button_to_key(int n) |
| 3397 | { |
| 3398 | if (n < 10) |
| 3399 | return BTN_0 + n; |
| 3400 | else if (n < 16) |
| 3401 | return BTN_A + (n-10); |
| 3402 | else if (n < 18) |
| 3403 | return BTN_BASE + (n-16); |
| 3404 | else |
| 3405 | return 0; |
| 3406 | } |
| 3407 | |
Jiri Kosina | 5397df1 | 2015-08-28 20:46:42 +0200 | [diff] [blame] | 3408 | static void wacom_setup_numbered_buttons(struct input_dev *input_dev, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3409 | int button_count) |
| 3410 | { |
| 3411 | int i; |
| 3412 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 3413 | for (i = 0; i < button_count; i++) { |
| 3414 | int key = wacom_numbered_button_to_key(i); |
| 3415 | |
| 3416 | if (key) |
| 3417 | __set_bit(key, input_dev->keybit); |
| 3418 | } |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3419 | } |
| 3420 | |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3421 | static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group) |
| 3422 | { |
| 3423 | struct wacom_led *led; |
| 3424 | int i; |
| 3425 | bool updated = false; |
| 3426 | |
| 3427 | /* |
| 3428 | * 24HD has LED group 1 to the left and LED group 0 to the right. |
| 3429 | * So group 0 matches the second half of the buttons and thus the mask |
| 3430 | * needs to be shifted. |
| 3431 | */ |
| 3432 | if (group == 0) |
| 3433 | mask >>= 8; |
| 3434 | |
| 3435 | for (i = 0; i < 3; i++) { |
| 3436 | led = wacom_led_find(wacom, group, i); |
| 3437 | if (!led) { |
| 3438 | hid_err(wacom->hdev, "can't find LED %d in group %d\n", |
| 3439 | i, group); |
| 3440 | continue; |
| 3441 | } |
| 3442 | if (!updated && mask & BIT(i)) { |
| 3443 | led->held = true; |
| 3444 | led_trigger_event(&led->trigger, LED_FULL); |
| 3445 | } else { |
| 3446 | led->held = false; |
| 3447 | } |
| 3448 | } |
| 3449 | } |
| 3450 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3451 | static bool wacom_is_led_toggled(struct wacom *wacom, int button_count, |
| 3452 | int mask, int group) |
| 3453 | { |
| 3454 | int button_per_group; |
| 3455 | |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3456 | /* |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3457 | * 21UX2 has LED group 1 to the left and LED group 0 |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3458 | * to the right. We need to reverse the group to match this |
| 3459 | * historical behavior. |
| 3460 | */ |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3461 | if (wacom->wacom_wac.features.type == WACOM_21UX2) |
Benjamin Tissoires | 5a0fe8ab | 2016-07-13 18:06:13 +0200 | [diff] [blame] | 3462 | group = 1 - group; |
| 3463 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3464 | button_per_group = button_count/wacom->led.count; |
| 3465 | |
| 3466 | return mask & (1 << (group * button_per_group)); |
| 3467 | } |
| 3468 | |
| 3469 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask, |
| 3470 | int group) |
| 3471 | { |
| 3472 | struct wacom_led *led, *next_led; |
| 3473 | int cur; |
| 3474 | bool pressed; |
| 3475 | |
Benjamin Tissoires | 6a06281 | 2016-07-13 18:06:14 +0200 | [diff] [blame] | 3476 | if (wacom->wacom_wac.features.type == WACOM_24HD) |
| 3477 | return wacom_24hd_update_leds(wacom, mask, group); |
| 3478 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3479 | pressed = wacom_is_led_toggled(wacom, button_count, mask, group); |
| 3480 | cur = wacom->led.groups[group].select; |
| 3481 | |
| 3482 | led = wacom_led_find(wacom, group, cur); |
| 3483 | if (!led) { |
| 3484 | hid_err(wacom->hdev, "can't find current LED %d in group %d\n", |
| 3485 | cur, group); |
| 3486 | return; |
| 3487 | } |
| 3488 | |
| 3489 | if (!pressed) { |
| 3490 | led->held = false; |
| 3491 | return; |
| 3492 | } |
| 3493 | |
| 3494 | if (led->held && pressed) |
| 3495 | return; |
| 3496 | |
| 3497 | next_led = wacom_led_next(wacom, led); |
| 3498 | if (!next_led) { |
| 3499 | hid_err(wacom->hdev, "can't find next LED in group %d\n", |
| 3500 | group); |
| 3501 | return; |
| 3502 | } |
| 3503 | if (next_led == led) |
| 3504 | return; |
| 3505 | |
| 3506 | next_led->held = true; |
| 3507 | led_trigger_event(&next_led->trigger, |
| 3508 | wacom_leds_brightness_get(next_led)); |
| 3509 | } |
| 3510 | |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 3511 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, |
| 3512 | int button_count, int mask) |
| 3513 | { |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3514 | struct wacom *wacom = input_get_drvdata(input_dev); |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 3515 | int i; |
| 3516 | |
Benjamin Tissoires | 34736aa | 2016-07-13 18:06:12 +0200 | [diff] [blame] | 3517 | for (i = 0; i < wacom->led.count; i++) |
| 3518 | wacom_update_led(wacom, button_count, mask, i); |
| 3519 | |
Jason Gerecke | 49005b9 | 2016-10-19 18:03:39 -0700 | [diff] [blame] | 3520 | for (i = 0; i < button_count; i++) { |
| 3521 | int key = wacom_numbered_button_to_key(i); |
| 3522 | |
| 3523 | if (key) |
| 3524 | input_report_key(input_dev, key, mask & (1 << i)); |
| 3525 | } |
Jason Gerecke | c7f0522 | 2015-11-30 17:13:47 -0800 | [diff] [blame] | 3526 | } |
| 3527 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3528 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, |
| 3529 | struct wacom_wac *wacom_wac) |
| 3530 | { |
| 3531 | struct wacom_features *features = &wacom_wac->features; |
| 3532 | |
Ping Cheng | e7deb15 | 2017-01-30 15:40:49 -0800 | [diff] [blame] | 3533 | if ((features->type == HID_GENERIC) && features->numbered_buttons > 0) |
| 3534 | features->device_type |= WACOM_DEVICETYPE_PAD; |
| 3535 | |
Jason Gerecke | 862cf55 | 2015-06-15 18:01:43 -0700 | [diff] [blame] | 3536 | if (!(features->device_type & WACOM_DEVICETYPE_PAD)) |
| 3537 | return -ENODEV; |
| 3538 | |
Benjamin Tissoires | 7c35dc3 | 2016-07-13 18:06:07 +0200 | [diff] [blame] | 3539 | if (features->type == REMOTE && input_dev == wacom_wac->pad_input) |
| 3540 | return -ENODEV; |
| 3541 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3542 | input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 3543 | |
| 3544 | /* kept for making legacy xf86-input-wacom working with the wheels */ |
| 3545 | __set_bit(ABS_MISC, input_dev->absbit); |
| 3546 | |
| 3547 | /* kept for making legacy xf86-input-wacom accepting the pad */ |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 3548 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum || |
| 3549 | input_dev->absinfo[ABS_X].maximum))) |
| 3550 | input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0); |
| 3551 | if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum || |
| 3552 | input_dev->absinfo[ABS_Y].maximum))) |
| 3553 | input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0); |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3554 | |
Benjamin Tissoires | 12969e3 | 2014-09-11 13:14:04 -0400 | [diff] [blame] | 3555 | /* kept for making udev and libwacom accepting the pad */ |
| 3556 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3557 | |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3558 | wacom_setup_numbered_buttons(input_dev, features->numbered_buttons); |
| 3559 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3560 | switch (features->type) { |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3561 | |
| 3562 | case CINTIQ_HYBRID: |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 3563 | case CINTIQ_COMPANION_2: |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3564 | case DTK: |
| 3565 | case DTUS: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 3566 | case GRAPHIRE_BT: |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 3567 | break; |
| 3568 | |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 3569 | case WACOM_MO: |
| 3570 | __set_bit(BTN_BACK, input_dev->keybit); |
| 3571 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3572 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 3573 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3574 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3575 | break; |
| 3576 | |
| 3577 | case WACOM_G4: |
| 3578 | __set_bit(BTN_BACK, input_dev->keybit); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 3579 | __set_bit(BTN_FORWARD, input_dev->keybit); |
Benjamin Tissoires | 3813810 | 2014-07-24 12:51:03 -0700 | [diff] [blame] | 3580 | input_set_capability(input_dev, EV_REL, REL_WHEEL); |
| 3581 | break; |
| 3582 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3583 | case WACOM_24HD: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3584 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 3585 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 3586 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 3587 | |
| 3588 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3589 | input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); |
| 3590 | break; |
| 3591 | |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3592 | case WACOM_27QHD: |
| 3593 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 3594 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 3595 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 3596 | input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0); |
| 3597 | input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */ |
| 3598 | input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0); |
| 3599 | input_abs_set_res(input_dev, ABS_Y, 1024); |
| 3600 | input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0); |
| 3601 | input_abs_set_res(input_dev, ABS_Z, 1024); |
| 3602 | __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); |
| 3603 | break; |
| 3604 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3605 | case WACOM_22HD: |
| 3606 | __set_bit(KEY_PROG1, input_dev->keybit); |
| 3607 | __set_bit(KEY_PROG2, input_dev->keybit); |
| 3608 | __set_bit(KEY_PROG3, input_dev->keybit); |
| 3609 | /* fall through */ |
| 3610 | |
| 3611 | case WACOM_21UX2: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3612 | case WACOM_BEE: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3613 | case CINTIQ: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3614 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
| 3615 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
| 3616 | break; |
| 3617 | |
| 3618 | case WACOM_13HD: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3619 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3620 | break; |
| 3621 | |
| 3622 | case INTUOS3: |
| 3623 | case INTUOS3L: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3624 | input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0); |
| 3625 | /* fall through */ |
| 3626 | |
| 3627 | case INTUOS3S: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3628 | input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0); |
| 3629 | break; |
| 3630 | |
| 3631 | case INTUOS5: |
| 3632 | case INTUOS5L: |
| 3633 | case INTUOSPM: |
| 3634 | case INTUOSPL: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3635 | case INTUOS5S: |
| 3636 | case INTUOSPS: |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 3637 | case INTUOSP2_BT: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3638 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3639 | break; |
| 3640 | |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 3641 | case INTUOS4WL: |
| 3642 | /* |
| 3643 | * For Bluetooth devices, the udev rule does not work correctly |
| 3644 | * for pads unless we add a stylus capability, which forces |
| 3645 | * ID_INPUT_TABLET to be set. |
| 3646 | */ |
| 3647 | __set_bit(BTN_STYLUS, input_dev->keybit); |
| 3648 | /* fall through */ |
| 3649 | |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3650 | case INTUOS4: |
| 3651 | case INTUOS4L: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3652 | case INTUOS4S: |
Benjamin Tissoires | 10059cdc | 2014-07-24 12:49:08 -0700 | [diff] [blame] | 3653 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3654 | break; |
| 3655 | |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 3656 | case INTUOSHT: |
| 3657 | case BAMBOO_PT: |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 3658 | case BAMBOO_TOUCH: |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 3659 | case INTUOSHT2: |
Benjamin Tissoires | 3116871 | 2014-07-24 12:50:10 -0700 | [diff] [blame] | 3660 | __clear_bit(ABS_MISC, input_dev->absbit); |
| 3661 | |
| 3662 | __set_bit(BTN_LEFT, input_dev->keybit); |
| 3663 | __set_bit(BTN_FORWARD, input_dev->keybit); |
| 3664 | __set_bit(BTN_BACK, input_dev->keybit); |
| 3665 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 3666 | |
| 3667 | break; |
| 3668 | |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 3669 | case REMOTE: |
| 3670 | input_set_capability(input_dev, EV_MSC, MSC_SERIAL); |
| 3671 | input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); |
| 3672 | break; |
| 3673 | |
Jason Gerecke | 5922e61 | 2016-10-19 18:03:51 -0700 | [diff] [blame] | 3674 | case HID_GENERIC: |
| 3675 | break; |
| 3676 | |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3677 | default: |
| 3678 | /* no pad supported */ |
Ping Cheng | b3c8e93 | 2014-11-18 13:27:48 -0800 | [diff] [blame] | 3679 | return -ENODEV; |
Benjamin Tissoires | d2d13f1 | 2014-07-24 12:48:28 -0700 | [diff] [blame] | 3680 | } |
| 3681 | return 0; |
| 3682 | } |
| 3683 | |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3684 | static const struct wacom_features wacom_features_0x00 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3685 | { "Wacom Penpartner", 5040, 3780, 255, 0, |
| 3686 | PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3687 | static const struct wacom_features wacom_features_0x10 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3688 | { "Wacom Graphire", 10206, 7422, 511, 63, |
| 3689 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 3690 | static const struct wacom_features wacom_features_0x81 = |
| 3691 | { "Wacom Graphire BT", 16704, 12064, 511, 32, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3692 | GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3693 | static const struct wacom_features wacom_features_0x11 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3694 | { "Wacom Graphire2 4x5", 10206, 7422, 511, 63, |
| 3695 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3696 | static const struct wacom_features wacom_features_0x12 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3697 | { "Wacom Graphire2 5x7", 13918, 10206, 511, 63, |
| 3698 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3699 | static const struct wacom_features wacom_features_0x13 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3700 | { "Wacom Graphire3", 10208, 7424, 511, 63, |
| 3701 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3702 | static const struct wacom_features wacom_features_0x14 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3703 | { "Wacom Graphire3 6x8", 16704, 12064, 511, 63, |
| 3704 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3705 | static const struct wacom_features wacom_features_0x15 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3706 | { "Wacom Graphire4 4x5", 10208, 7424, 511, 63, |
| 3707 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3708 | static const struct wacom_features wacom_features_0x16 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3709 | { "Wacom Graphire4 6x8", 16704, 12064, 511, 63, |
| 3710 | WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3711 | static const struct wacom_features wacom_features_0x17 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3712 | { "Wacom BambooFun 4x5", 14760, 9225, 511, 63, |
| 3713 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3714 | static const struct wacom_features wacom_features_0x18 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3715 | { "Wacom BambooFun 6x8", 21648, 13530, 511, 63, |
| 3716 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3717 | static const struct wacom_features wacom_features_0x19 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3718 | { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63, |
| 3719 | GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3720 | static const struct wacom_features wacom_features_0x60 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3721 | { "Wacom Volito", 5104, 3712, 511, 63, |
| 3722 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3723 | static const struct wacom_features wacom_features_0x61 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3724 | { "Wacom PenStation2", 3250, 2320, 255, 63, |
| 3725 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3726 | static const struct wacom_features wacom_features_0x62 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3727 | { "Wacom Volito2 4x5", 5104, 3712, 511, 63, |
| 3728 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3729 | static const struct wacom_features wacom_features_0x63 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3730 | { "Wacom Volito2 2x3", 3248, 2320, 511, 63, |
| 3731 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3732 | static const struct wacom_features wacom_features_0x64 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3733 | { "Wacom PenPartner2", 3250, 2320, 511, 63, |
| 3734 | GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3735 | static const struct wacom_features wacom_features_0x65 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3736 | { "Wacom Bamboo", 14760, 9225, 511, 63, |
| 3737 | WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3738 | static const struct wacom_features wacom_features_0x69 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3739 | { "Wacom Bamboo1", 5104, 3712, 511, 63, |
| 3740 | GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 3741 | static const struct wacom_features wacom_features_0x6A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3742 | { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63, |
| 3743 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 3744 | static const struct wacom_features wacom_features_0x6B = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3745 | { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63, |
| 3746 | GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3747 | static const struct wacom_features wacom_features_0x20 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3748 | { "Wacom Intuos 4x5", 12700, 10600, 1023, 31, |
| 3749 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3750 | static const struct wacom_features wacom_features_0x21 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3751 | { "Wacom Intuos 6x8", 20320, 16240, 1023, 31, |
| 3752 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3753 | static const struct wacom_features wacom_features_0x22 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3754 | { "Wacom Intuos 9x12", 30480, 24060, 1023, 31, |
| 3755 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3756 | static const struct wacom_features wacom_features_0x23 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3757 | { "Wacom Intuos 12x12", 30480, 31680, 1023, 31, |
| 3758 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3759 | static const struct wacom_features wacom_features_0x24 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3760 | { "Wacom Intuos 12x18", 45720, 31680, 1023, 31, |
| 3761 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3762 | static const struct wacom_features wacom_features_0x30 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3763 | { "Wacom PL400", 5408, 4056, 255, 0, |
| 3764 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3765 | static const struct wacom_features wacom_features_0x31 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3766 | { "Wacom PL500", 6144, 4608, 255, 0, |
| 3767 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3768 | static const struct wacom_features wacom_features_0x32 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3769 | { "Wacom PL600", 6126, 4604, 255, 0, |
| 3770 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3771 | static const struct wacom_features wacom_features_0x33 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3772 | { "Wacom PL600SX", 6260, 5016, 255, 0, |
| 3773 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3774 | static const struct wacom_features wacom_features_0x34 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3775 | { "Wacom PL550", 6144, 4608, 511, 0, |
| 3776 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3777 | static const struct wacom_features wacom_features_0x35 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3778 | { "Wacom PL800", 7220, 5780, 511, 0, |
| 3779 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3780 | static const struct wacom_features wacom_features_0x37 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3781 | { "Wacom PL700", 6758, 5406, 511, 0, |
| 3782 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3783 | static const struct wacom_features wacom_features_0x38 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3784 | { "Wacom PL510", 6282, 4762, 511, 0, |
| 3785 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3786 | static const struct wacom_features wacom_features_0x39 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3787 | { "Wacom DTU710", 34080, 27660, 511, 0, |
| 3788 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3789 | static const struct wacom_features wacom_features_0xC4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3790 | { "Wacom DTF521", 6282, 4762, 511, 0, |
| 3791 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3792 | static const struct wacom_features wacom_features_0xC0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3793 | { "Wacom DTF720", 6858, 5506, 511, 0, |
| 3794 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3795 | static const struct wacom_features wacom_features_0xC2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3796 | { "Wacom DTF720a", 6858, 5506, 511, 0, |
| 3797 | PL, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3798 | static const struct wacom_features wacom_features_0x03 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3799 | { "Wacom Cintiq Partner", 20480, 15360, 511, 0, |
| 3800 | PTU, WACOM_PL_RES, WACOM_PL_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3801 | static const struct wacom_features wacom_features_0x41 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3802 | { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31, |
| 3803 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3804 | static const struct wacom_features wacom_features_0x42 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3805 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
| 3806 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3807 | static const struct wacom_features wacom_features_0x43 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3808 | { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31, |
| 3809 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3810 | static const struct wacom_features wacom_features_0x44 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3811 | { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31, |
| 3812 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3813 | static const struct wacom_features wacom_features_0x45 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3814 | { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31, |
| 3815 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3816 | static const struct wacom_features wacom_features_0xB0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3817 | { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3818 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3819 | static const struct wacom_features wacom_features_0xB1 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3820 | { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3821 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3822 | static const struct wacom_features wacom_features_0xB2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3823 | { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3824 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3825 | static const struct wacom_features wacom_features_0xB3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3826 | { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3827 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3828 | static const struct wacom_features wacom_features_0xB4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3829 | { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3830 | INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3831 | static const struct wacom_features wacom_features_0xB5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3832 | { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3833 | INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3834 | static const struct wacom_features wacom_features_0xB7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3835 | { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3836 | INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3837 | static const struct wacom_features wacom_features_0xB8 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3838 | { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3839 | INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3840 | static const struct wacom_features wacom_features_0xB9 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3841 | { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3842 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3843 | static const struct wacom_features wacom_features_0xBA = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3844 | { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3845 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3846 | static const struct wacom_features wacom_features_0xBB = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3847 | { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3848 | INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 3849 | static const struct wacom_features wacom_features_0xBC = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3850 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3851 | INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 3852 | static const struct wacom_features wacom_features_0xBD = |
| 3853 | { "Wacom Intuos4 WL", 40640, 25400, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3854 | INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3855 | static const struct wacom_features wacom_features_0x26 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3856 | { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3857 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3858 | static const struct wacom_features wacom_features_0x27 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3859 | { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3860 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3861 | static const struct wacom_features wacom_features_0x28 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3862 | { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3863 | INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3864 | static const struct wacom_features wacom_features_0x29 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3865 | { "Wacom Intuos5 S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3866 | INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 }; |
Jason Gerecke | 9fee619 | 2012-04-03 15:47:22 -0700 | [diff] [blame] | 3867 | static const struct wacom_features wacom_features_0x2A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3868 | { "Wacom Intuos5 M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3869 | INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3870 | static const struct wacom_features wacom_features_0x314 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3871 | { "Wacom Intuos Pro S", 31496, 19685, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3872 | INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3873 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3874 | static const struct wacom_features wacom_features_0x315 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3875 | { "Wacom Intuos Pro M", 44704, 27940, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3876 | INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3877 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 9a35c41 | 2013-09-20 09:51:56 -0700 | [diff] [blame] | 3878 | static const struct wacom_features wacom_features_0x317 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3879 | { "Wacom Intuos Pro L", 65024, 40640, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3880 | INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3881 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Jason Gerecke | 803296b | 2011-12-12 00:11:45 -0800 | [diff] [blame] | 3882 | static const struct wacom_features wacom_features_0xF4 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3883 | { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3884 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3885 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3886 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Jason Gerecke | 6f4d038 | 2012-08-21 22:11:59 -0700 | [diff] [blame] | 3887 | static const struct wacom_features wacom_features_0xF8 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3888 | { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */ |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3889 | WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3890 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3891 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 3bd1f7e | 2013-05-23 10:22:33 -0700 | [diff] [blame] | 3892 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; |
Jason Gerecke | b1e4279 | 2012-10-21 00:38:04 -0700 | [diff] [blame] | 3893 | static const struct wacom_features wacom_features_0xF6 = |
| 3894 | { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3895 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, |
| 3896 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3897 | static const struct wacom_features wacom_features_0x32A = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3898 | { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3899 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3900 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | a7e6645 | 2015-02-04 16:01:54 -0800 | [diff] [blame] | 3901 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3902 | static const struct wacom_features wacom_features_0x32B = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3903 | { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3904 | WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3905 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3906 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 3907 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C }; |
| 3908 | static const struct wacom_features wacom_features_0x32C = |
| 3909 | { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT, |
| 3910 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3911 | static const struct wacom_features wacom_features_0x3F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3912 | { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3913 | CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3914 | static const struct wacom_features wacom_features_0xC5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3915 | { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3916 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3917 | static const struct wacom_features wacom_features_0xC6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3918 | { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3919 | WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3920 | static const struct wacom_features wacom_features_0x304 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3921 | { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3922 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3923 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3924 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 3925 | static const struct wacom_features wacom_features_0x333 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3926 | { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3927 | WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 3928 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3929 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 3930 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 }; |
| 3931 | static const struct wacom_features wacom_features_0x335 = |
| 3932 | { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */ |
| 3933 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10, |
| 3934 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3935 | static const struct wacom_features wacom_features_0xC7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3936 | { "Wacom DTU1931", 37832, 30305, 511, 0, |
| 3937 | PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 3938 | static const struct wacom_features wacom_features_0xCE = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3939 | { "Wacom DTU2231", 47864, 27011, 511, 0, |
| 3940 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3941 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE }; |
Ping Cheng | c8f2edc | 2010-06-28 01:10:51 -0700 | [diff] [blame] | 3942 | static const struct wacom_features wacom_features_0xF0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3943 | { "Wacom DTU1631", 34623, 19553, 511, 0, |
| 3944 | DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 497ab1f | 2014-01-20 20:18:04 -0800 | [diff] [blame] | 3945 | static const struct wacom_features wacom_features_0xFB = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3946 | { "Wacom DTU1031", 22096, 13960, 511, 0, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3947 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3948 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3949 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 3950 | static const struct wacom_features wacom_features_0x32F = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3951 | { "Wacom DTU1031X", 22672, 12928, 511, 0, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3952 | DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3953 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 3954 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Aaron Skomra | 007760c | 2015-04-16 15:01:14 -0700 | [diff] [blame] | 3955 | static const struct wacom_features wacom_features_0x336 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3956 | { "Wacom DTU1141", 23672, 13403, 1023, 0, |
Ping Cheng | ff38e82 | 2015-11-12 17:21:14 -0800 | [diff] [blame] | 3957 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3958 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | ff38e82 | 2015-11-12 17:21:14 -0800 | [diff] [blame] | 3959 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3960 | static const struct wacom_features wacom_features_0x57 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3961 | { "Wacom DTK2241", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3962 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3963 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3964 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 3965 | static const struct wacom_features wacom_features_0x59 = /* Pen */ |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3966 | { "Wacom DTH2242", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3967 | DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3968 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3969 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 3970 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; |
| 3971 | static const struct wacom_features wacom_features_0x5D = /* Touch */ |
| 3972 | { "Wacom DTH2242", .type = WACOM_24HDT, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3973 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, |
| 3974 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 3975 | static const struct wacom_features wacom_features_0xCC = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3976 | { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3977 | WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3978 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3979 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | d838c64 | 2012-07-24 23:54:11 -0700 | [diff] [blame] | 3980 | static const struct wacom_features wacom_features_0xFA = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3981 | { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3982 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3983 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3984 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3985 | static const struct wacom_features wacom_features_0x5B = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3986 | { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 3987 | WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 3988 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 3989 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Ping Cheng | 3bd1f7e | 2013-05-23 10:22:33 -0700 | [diff] [blame] | 3990 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 3991 | static const struct wacom_features wacom_features_0x5E = |
| 3992 | { "Wacom Cintiq 22HDT", .type = WACOM_24HDT, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 3993 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10, |
| 3994 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3995 | static const struct wacom_features wacom_features_0x90 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3996 | { "Wacom ISDv4 90", 26202, 16325, 255, 0, |
| 3997 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 3998 | static const struct wacom_features wacom_features_0x93 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 3999 | { "Wacom ISDv4 93", 26202, 16325, 255, 0, |
| 4000 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 11d0cf8 | 2011-06-27 12:57:58 -0700 | [diff] [blame] | 4001 | static const struct wacom_features wacom_features_0x97 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4002 | { "Wacom ISDv4 97", 26202, 16325, 511, 0, |
| 4003 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4004 | static const struct wacom_features wacom_features_0x9A = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4005 | { "Wacom ISDv4 9A", 26202, 16325, 255, 0, |
| 4006 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4007 | static const struct wacom_features wacom_features_0x9F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4008 | { "Wacom ISDv4 9F", 26202, 16325, 255, 0, |
| 4009 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4010 | static const struct wacom_features wacom_features_0xE2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4011 | { "Wacom ISDv4 E2", 26202, 16325, 255, 0, |
| 4012 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4013 | static const struct wacom_features wacom_features_0xE3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4014 | { "Wacom ISDv4 E3", 26202, 16325, 255, 0, |
| 4015 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 4016 | static const struct wacom_features wacom_features_0xE5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4017 | { "Wacom ISDv4 E5", 26202, 16325, 255, 0, |
| 4018 | MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Manoj Iyer | 26fcd2a | 2011-03-31 22:39:43 -0700 | [diff] [blame] | 4019 | static const struct wacom_features wacom_features_0xE6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4020 | { "Wacom ISDv4 E6", 27760, 15694, 255, 0, |
| 4021 | TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Chris Bagwell | 0d0e306 | 2011-12-11 23:50:59 -0800 | [diff] [blame] | 4022 | static const struct wacom_features wacom_features_0xEC = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4023 | { "Wacom ISDv4 EC", 25710, 14500, 255, 0, |
| 4024 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4025 | static const struct wacom_features wacom_features_0xED = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4026 | { "Wacom ISDv4 ED", 26202, 16325, 255, 0, |
| 4027 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4028 | static const struct wacom_features wacom_features_0xEF = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4029 | { "Wacom ISDv4 EF", 26202, 16325, 255, 0, |
| 4030 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4031 | static const struct wacom_features wacom_features_0x100 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4032 | { "Wacom ISDv4 100", 26202, 16325, 255, 0, |
| 4033 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4034 | static const struct wacom_features wacom_features_0x101 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4035 | { "Wacom ISDv4 101", 26202, 16325, 255, 0, |
| 4036 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Stephan Frank | 5869483 | 2013-03-07 14:08:50 -0800 | [diff] [blame] | 4037 | static const struct wacom_features wacom_features_0x10D = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4038 | { "Wacom ISDv4 10D", 26202, 16325, 255, 0, |
| 4039 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 2d3163f | 2013-10-22 15:35:30 -0700 | [diff] [blame] | 4040 | static const struct wacom_features wacom_features_0x10E = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4041 | { "Wacom ISDv4 10E", 27760, 15694, 255, 0, |
| 4042 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 9b4f60e | 2013-10-15 23:46:34 -0700 | [diff] [blame] | 4043 | static const struct wacom_features wacom_features_0x10F = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4044 | { "Wacom ISDv4 10F", 27760, 15694, 255, 0, |
| 4045 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | 61616ed | 2014-05-14 11:42:22 -0700 | [diff] [blame] | 4046 | static const struct wacom_features wacom_features_0x116 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4047 | { "Wacom ISDv4 116", 26202, 16325, 255, 0, |
| 4048 | TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | aeaf50d | 2014-07-28 10:53:16 -0700 | [diff] [blame] | 4049 | static const struct wacom_features wacom_features_0x12C = |
| 4050 | { "Wacom ISDv4 12C", 27848, 15752, 2047, 0, |
| 4051 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | edbe265 | 2012-11-21 13:12:50 -0800 | [diff] [blame] | 4052 | static const struct wacom_features wacom_features_0x4001 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4053 | { "Wacom ISDv4 4001", 26202, 16325, 255, 0, |
| 4054 | MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4055 | static const struct wacom_features wacom_features_0x4004 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4056 | { "Wacom ISDv4 4004", 11060, 6220, 255, 0, |
| 4057 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4058 | static const struct wacom_features wacom_features_0x5000 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4059 | { "Wacom ISDv4 5000", 27848, 15752, 1023, 0, |
| 4060 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4061 | static const struct wacom_features wacom_features_0x5002 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4062 | { "Wacom ISDv4 5002", 29576, 16724, 1023, 0, |
| 4063 | MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Dmitry Torokhov | e87a344 | 2010-02-18 01:51:47 -0800 | [diff] [blame] | 4064 | static const struct wacom_features wacom_features_0x47 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4065 | { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31, |
| 4066 | INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Chris Bagwell | d3825d5 | 2012-03-25 23:26:11 -0700 | [diff] [blame] | 4067 | static const struct wacom_features wacom_features_0x84 = |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4068 | { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4069 | static const struct wacom_features wacom_features_0xD0 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4070 | { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4071 | BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4072 | static const struct wacom_features wacom_features_0xD1 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4073 | { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31, |
| 4074 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4075 | static const struct wacom_features wacom_features_0xD2 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4076 | { "Wacom Bamboo Craft", 14720, 9200, 1023, 31, |
| 4077 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4078 | static const struct wacom_features wacom_features_0xD3 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4079 | { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31, |
| 4080 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Kevin Granade | 57a7872 | 2010-12-10 23:04:02 -0800 | [diff] [blame] | 4081 | static const struct wacom_features wacom_features_0xD4 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4082 | { "Wacom Bamboo Pen", 14720, 9200, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4083 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Gerard Braad | 18adad1 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 4084 | static const struct wacom_features wacom_features_0xD5 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4085 | { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4086 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4087 | static const struct wacom_features wacom_features_0xD6 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4088 | { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31, |
| 4089 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4090 | static const struct wacom_features wacom_features_0xD7 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4091 | { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31, |
| 4092 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4093 | static const struct wacom_features wacom_features_0xD8 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4094 | { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31, |
| 4095 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | 7b824bb | 2011-03-26 21:16:04 -0700 | [diff] [blame] | 4096 | static const struct wacom_features wacom_features_0xDA = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4097 | { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31, |
| 4098 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4099 | static const struct wacom_features wacom_features_0xDB = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4100 | { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31, |
| 4101 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4102 | static const struct wacom_features wacom_features_0xDD = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4103 | { "Wacom Bamboo Connect", 14720, 9200, 1023, 31, |
| 4104 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4105 | static const struct wacom_features wacom_features_0xDE = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4106 | { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31, |
| 4107 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4108 | static const struct wacom_features wacom_features_0xDF = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4109 | { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31, |
| 4110 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4111 | static const struct wacom_features wacom_features_0x300 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4112 | { "Wacom Bamboo One S", 14720, 9225, 1023, 31, |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4113 | BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4114 | static const struct wacom_features wacom_features_0x301 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4115 | { "Wacom Bamboo One M", 21648, 13530, 1023, 31, |
| 4116 | BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4117 | static const struct wacom_features wacom_features_0x302 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4118 | { "Wacom Intuos PT S", 15200, 9500, 1023, 31, |
| 4119 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4120 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4121 | static const struct wacom_features wacom_features_0x303 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4122 | { "Wacom Intuos PT M", 21600, 13500, 1023, 31, |
| 4123 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4124 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | b5fd2a3 | 2013-11-25 18:44:55 -0800 | [diff] [blame] | 4125 | static const struct wacom_features wacom_features_0x30E = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4126 | { "Wacom Intuos S", 15200, 9500, 1023, 31, |
| 4127 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4128 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4129 | static const struct wacom_features wacom_features_0x6004 = |
Benjamin Tissoires | 80befa9 | 2014-07-24 13:05:19 -0700 | [diff] [blame] | 4130 | { "ISD-V4", 12800, 8000, 255, 0, |
| 4131 | TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4132 | static const struct wacom_features wacom_features_0x307 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4133 | { "Wacom ISDv5 307", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4134 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4135 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4136 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 4137 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4138 | static const struct wacom_features wacom_features_0x309 = |
Jason Gerecke | 36d3c51 | 2013-09-20 09:47:35 -0700 | [diff] [blame] | 4139 | { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4140 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, |
| 4141 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4142 | static const struct wacom_features wacom_features_0x30A = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4143 | { "Wacom ISDv5 30A", 59552, 33848, 2047, 63, |
Aaron Skomra | 70ee06c | 2015-08-20 16:05:16 -0700 | [diff] [blame] | 4144 | CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, |
Ping Cheng | fa77034 | 2014-12-01 13:44:28 -0800 | [diff] [blame] | 4145 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4146 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4147 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C }; |
| 4148 | static const struct wacom_features wacom_features_0x30C = |
| 4149 | { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */ |
| 4150 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10, |
| 4151 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 4152 | static const struct wacom_features wacom_features_0x318 = |
| 4153 | { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */ |
| 4154 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
| 4155 | static const struct wacom_features wacom_features_0x319 = |
| 4156 | { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */ |
| 4157 | .type = BAMBOO_PAD, 35, 48, .touch_max = 4 }; |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4158 | static const struct wacom_features wacom_features_0x325 = |
| 4159 | { "Wacom ISDv5 325", 59552, 33848, 2047, 63, |
| 4160 | CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11, |
| 4161 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4162 | WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4163 | .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 }; |
| 4164 | static const struct wacom_features wacom_features_0x326 = /* Touch */ |
| 4165 | { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM, |
| 4166 | .oPid = 0x325 }; |
Ping Cheng | fefb391 | 2014-11-11 12:52:08 -0800 | [diff] [blame] | 4167 | static const struct wacom_features wacom_features_0x323 = |
| 4168 | { "Wacom Intuos P M", 21600, 13500, 1023, 31, |
| 4169 | INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4170 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4171 | static const struct wacom_features wacom_features_0x331 = |
Ping Cheng | 3b164a0 | 2015-09-23 09:59:10 -0700 | [diff] [blame] | 4172 | { "Wacom Express Key Remote", .type = REMOTE, |
| 4173 | .numbered_buttons = 18, .check_for_hid_type = true, |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4174 | .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 4175 | static const struct wacom_features wacom_features_0x33B = |
| 4176 | { "Wacom Intuos S 2", 15200, 9500, 2047, 63, |
| 4177 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4178 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4179 | static const struct wacom_features wacom_features_0x33C = |
| 4180 | { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63, |
| 4181 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4182 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4183 | static const struct wacom_features wacom_features_0x33D = |
| 4184 | { "Wacom Intuos P M 2", 21600, 13500, 2047, 63, |
| 4185 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, |
| 4186 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
| 4187 | static const struct wacom_features wacom_features_0x33E = |
| 4188 | { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63, |
| 4189 | INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16, |
| 4190 | .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4191 | static const struct wacom_features wacom_features_0x343 = |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4192 | { "Wacom DTK1651", 34816, 19759, 1023, 0, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4193 | DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4, |
Jason Gerecke | e779ef2 | 2016-10-19 18:03:49 -0700 | [diff] [blame] | 4194 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4195 | WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4196 | static const struct wacom_features wacom_features_0x360 = |
| 4197 | { "Wacom Intuos Pro M", 44800, 29600, 8191, 63, |
| 4198 | INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 }; |
| 4199 | static const struct wacom_features wacom_features_0x361 = |
| 4200 | { "Wacom Intuos Pro L", 62200, 43200, 8191, 63, |
| 4201 | INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 }; |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4202 | |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 4203 | static const struct wacom_features wacom_features_HID_ANY_ID = |
Jason Gerecke | 41372d5 | 2016-08-08 12:06:30 -0700 | [diff] [blame] | 4204 | { "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] | 4205 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4206 | #define USB_DEVICE_WACOM(prod) \ |
| 4207 | HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4208 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4209 | |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4210 | #define BT_DEVICE_WACOM(prod) \ |
| 4211 | HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4212 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Aristeu Rozanski | 1483f55 | 2011-06-22 01:17:17 -0700 | [diff] [blame] | 4213 | |
Mika Westerberg | eef23a8 | 2015-02-23 15:52:43 +0200 | [diff] [blame] | 4214 | #define I2C_DEVICE_WACOM(prod) \ |
| 4215 | HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\ |
| 4216 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
| 4217 | |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4218 | #define USB_DEVICE_LENOVO(prod) \ |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4219 | HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \ |
| 4220 | .driver_data = (kernel_ulong_t)&wacom_features_##prod |
Ajay Ramaswamy | 7b4b306 | 2010-12-23 01:19:39 -0800 | [diff] [blame] | 4221 | |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4222 | const struct hid_device_id wacom_ids[] = { |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4223 | { USB_DEVICE_WACOM(0x00) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4224 | { USB_DEVICE_WACOM(0x03) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4225 | { USB_DEVICE_WACOM(0x10) }, |
| 4226 | { USB_DEVICE_WACOM(0x11) }, |
| 4227 | { USB_DEVICE_WACOM(0x12) }, |
| 4228 | { USB_DEVICE_WACOM(0x13) }, |
| 4229 | { USB_DEVICE_WACOM(0x14) }, |
| 4230 | { USB_DEVICE_WACOM(0x15) }, |
| 4231 | { USB_DEVICE_WACOM(0x16) }, |
| 4232 | { USB_DEVICE_WACOM(0x17) }, |
| 4233 | { USB_DEVICE_WACOM(0x18) }, |
| 4234 | { USB_DEVICE_WACOM(0x19) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4235 | { USB_DEVICE_WACOM(0x20) }, |
| 4236 | { USB_DEVICE_WACOM(0x21) }, |
| 4237 | { USB_DEVICE_WACOM(0x22) }, |
| 4238 | { USB_DEVICE_WACOM(0x23) }, |
| 4239 | { USB_DEVICE_WACOM(0x24) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4240 | { USB_DEVICE_WACOM(0x26) }, |
| 4241 | { USB_DEVICE_WACOM(0x27) }, |
| 4242 | { USB_DEVICE_WACOM(0x28) }, |
| 4243 | { USB_DEVICE_WACOM(0x29) }, |
| 4244 | { USB_DEVICE_WACOM(0x2A) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4245 | { USB_DEVICE_WACOM(0x30) }, |
| 4246 | { USB_DEVICE_WACOM(0x31) }, |
| 4247 | { USB_DEVICE_WACOM(0x32) }, |
| 4248 | { USB_DEVICE_WACOM(0x33) }, |
| 4249 | { USB_DEVICE_WACOM(0x34) }, |
| 4250 | { USB_DEVICE_WACOM(0x35) }, |
| 4251 | { USB_DEVICE_WACOM(0x37) }, |
| 4252 | { USB_DEVICE_WACOM(0x38) }, |
| 4253 | { USB_DEVICE_WACOM(0x39) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4254 | { USB_DEVICE_WACOM(0x3F) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4255 | { USB_DEVICE_WACOM(0x41) }, |
| 4256 | { USB_DEVICE_WACOM(0x42) }, |
| 4257 | { USB_DEVICE_WACOM(0x43) }, |
| 4258 | { USB_DEVICE_WACOM(0x44) }, |
| 4259 | { USB_DEVICE_WACOM(0x45) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4260 | { USB_DEVICE_WACOM(0x47) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4261 | { USB_DEVICE_WACOM(0x57) }, |
Ping Cheng | a112e9f | 2013-02-13 20:20:01 -0800 | [diff] [blame] | 4262 | { USB_DEVICE_WACOM(0x59) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4263 | { USB_DEVICE_WACOM(0x5B) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4264 | { USB_DEVICE_WACOM(0x5D) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4265 | { USB_DEVICE_WACOM(0x5E) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4266 | { USB_DEVICE_WACOM(0x60) }, |
| 4267 | { USB_DEVICE_WACOM(0x61) }, |
| 4268 | { USB_DEVICE_WACOM(0x62) }, |
| 4269 | { USB_DEVICE_WACOM(0x63) }, |
| 4270 | { USB_DEVICE_WACOM(0x64) }, |
| 4271 | { USB_DEVICE_WACOM(0x65) }, |
| 4272 | { USB_DEVICE_WACOM(0x69) }, |
| 4273 | { USB_DEVICE_WACOM(0x6A) }, |
| 4274 | { USB_DEVICE_WACOM(0x6B) }, |
Benjamin Tissoires | 387142b | 2014-08-06 13:52:56 -0700 | [diff] [blame] | 4275 | { BT_DEVICE_WACOM(0x81) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4276 | { USB_DEVICE_WACOM(0x84) }, |
| 4277 | { USB_DEVICE_WACOM(0x90) }, |
| 4278 | { USB_DEVICE_WACOM(0x93) }, |
| 4279 | { USB_DEVICE_WACOM(0x97) }, |
| 4280 | { USB_DEVICE_WACOM(0x9A) }, |
| 4281 | { USB_DEVICE_WACOM(0x9F) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4282 | { USB_DEVICE_WACOM(0xB0) }, |
| 4283 | { USB_DEVICE_WACOM(0xB1) }, |
| 4284 | { USB_DEVICE_WACOM(0xB2) }, |
| 4285 | { USB_DEVICE_WACOM(0xB3) }, |
| 4286 | { USB_DEVICE_WACOM(0xB4) }, |
| 4287 | { USB_DEVICE_WACOM(0xB5) }, |
| 4288 | { USB_DEVICE_WACOM(0xB7) }, |
| 4289 | { USB_DEVICE_WACOM(0xB8) }, |
| 4290 | { USB_DEVICE_WACOM(0xB9) }, |
| 4291 | { USB_DEVICE_WACOM(0xBA) }, |
| 4292 | { USB_DEVICE_WACOM(0xBB) }, |
Ping Cheng | 3a4b4aa | 2010-06-03 22:10:21 -0700 | [diff] [blame] | 4293 | { USB_DEVICE_WACOM(0xBC) }, |
Benjamin Tissoires | 81af7e6 | 2014-08-06 13:55:56 -0700 | [diff] [blame] | 4294 | { BT_DEVICE_WACOM(0xBD) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4295 | { USB_DEVICE_WACOM(0xC0) }, |
| 4296 | { USB_DEVICE_WACOM(0xC2) }, |
| 4297 | { USB_DEVICE_WACOM(0xC4) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4298 | { USB_DEVICE_WACOM(0xC5) }, |
| 4299 | { USB_DEVICE_WACOM(0xC6) }, |
| 4300 | { USB_DEVICE_WACOM(0xC7) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4301 | { USB_DEVICE_WACOM(0xCC) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4302 | { USB_DEVICE_WACOM(0xCE) }, |
Henrik Rydberg | cb734c0 | 2010-09-05 12:53:16 -0700 | [diff] [blame] | 4303 | { USB_DEVICE_WACOM(0xD0) }, |
Chris Bagwell | 2aaacb1 | 2010-09-12 00:11:35 -0700 | [diff] [blame] | 4304 | { USB_DEVICE_WACOM(0xD1) }, |
| 4305 | { USB_DEVICE_WACOM(0xD2) }, |
| 4306 | { USB_DEVICE_WACOM(0xD3) }, |
Kevin Granade | 57a7872 | 2010-12-10 23:04:02 -0800 | [diff] [blame] | 4307 | { USB_DEVICE_WACOM(0xD4) }, |
Gerard Braad | 18adad1 | 2011-08-16 00:17:56 -0700 | [diff] [blame] | 4308 | { USB_DEVICE_WACOM(0xD5) }, |
Ping Cheng | d38acb4 | 2011-01-24 09:32:50 -0800 | [diff] [blame] | 4309 | { USB_DEVICE_WACOM(0xD6) }, |
| 4310 | { USB_DEVICE_WACOM(0xD7) }, |
David Foley | a318e6b | 2010-11-30 23:45:46 -0800 | [diff] [blame] | 4311 | { USB_DEVICE_WACOM(0xD8) }, |
| 4312 | { USB_DEVICE_WACOM(0xDA) }, |
David Foley | 47d0923 | 2010-12-07 21:05:59 -0800 | [diff] [blame] | 4313 | { USB_DEVICE_WACOM(0xDB) }, |
Chris Bagwell | 73149ab | 2011-10-26 22:34:21 -0700 | [diff] [blame] | 4314 | { USB_DEVICE_WACOM(0xDD) }, |
| 4315 | { USB_DEVICE_WACOM(0xDE) }, |
| 4316 | { USB_DEVICE_WACOM(0xDF) }, |
Bastian Blank | b036f6f | 2010-02-10 23:06:23 -0800 | [diff] [blame] | 4317 | { USB_DEVICE_WACOM(0xE2) }, |
| 4318 | { USB_DEVICE_WACOM(0xE3) }, |
Ping Cheng | 1963518 | 2012-04-29 21:09:18 -0700 | [diff] [blame] | 4319 | { USB_DEVICE_WACOM(0xE5) }, |
Manoj Iyer | 26fcd2a | 2011-03-31 22:39:43 -0700 | [diff] [blame] | 4320 | { USB_DEVICE_WACOM(0xE6) }, |
Chris Bagwell | 0d0e306 | 2011-12-11 23:50:59 -0800 | [diff] [blame] | 4321 | { USB_DEVICE_WACOM(0xEC) }, |
Ping Cheng | ac17383 | 2012-06-12 00:15:06 -0700 | [diff] [blame] | 4322 | { USB_DEVICE_WACOM(0xED) }, |
| 4323 | { USB_DEVICE_WACOM(0xEF) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4324 | { USB_DEVICE_WACOM(0xF0) }, |
| 4325 | { USB_DEVICE_WACOM(0xF4) }, |
| 4326 | { USB_DEVICE_WACOM(0xF6) }, |
| 4327 | { USB_DEVICE_WACOM(0xF8) }, |
| 4328 | { USB_DEVICE_WACOM(0xFA) }, |
| 4329 | { USB_DEVICE_WACOM(0xFB) }, |
Ping Cheng | 6afdc28 | 2012-11-03 12:16:15 -0700 | [diff] [blame] | 4330 | { USB_DEVICE_WACOM(0x100) }, |
| 4331 | { USB_DEVICE_WACOM(0x101) }, |
Stephan Frank | 5869483 | 2013-03-07 14:08:50 -0800 | [diff] [blame] | 4332 | { USB_DEVICE_WACOM(0x10D) }, |
Jason Gerecke | 2d3163f | 2013-10-22 15:35:30 -0700 | [diff] [blame] | 4333 | { USB_DEVICE_WACOM(0x10E) }, |
Jason Gerecke | 9b4f60e | 2013-10-15 23:46:34 -0700 | [diff] [blame] | 4334 | { USB_DEVICE_WACOM(0x10F) }, |
Jason Gerecke | 61616ed | 2014-05-14 11:42:22 -0700 | [diff] [blame] | 4335 | { USB_DEVICE_WACOM(0x116) }, |
Jason Gerecke | aeaf50d | 2014-07-28 10:53:16 -0700 | [diff] [blame] | 4336 | { USB_DEVICE_WACOM(0x12C) }, |
Ping Cheng | f41a64e | 2013-08-21 09:14:49 -0700 | [diff] [blame] | 4337 | { USB_DEVICE_WACOM(0x300) }, |
| 4338 | { USB_DEVICE_WACOM(0x301) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4339 | { USB_DEVICE_WACOM(0x302) }, |
| 4340 | { USB_DEVICE_WACOM(0x303) }, |
Ping Cheng | 5621856 | 2013-05-05 19:56:18 -0700 | [diff] [blame] | 4341 | { USB_DEVICE_WACOM(0x304) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4342 | { USB_DEVICE_WACOM(0x307) }, |
| 4343 | { USB_DEVICE_WACOM(0x309) }, |
Benjamin Tissoires | 89f2ab5 | 2014-09-03 15:43:25 -0400 | [diff] [blame] | 4344 | { USB_DEVICE_WACOM(0x30A) }, |
| 4345 | { USB_DEVICE_WACOM(0x30C) }, |
Benjamin Tissoires | a3e6f65 | 2014-07-24 13:05:49 -0700 | [diff] [blame] | 4346 | { USB_DEVICE_WACOM(0x30E) }, |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4347 | { USB_DEVICE_WACOM(0x314) }, |
| 4348 | { USB_DEVICE_WACOM(0x315) }, |
| 4349 | { USB_DEVICE_WACOM(0x317) }, |
Benjamin Tissoires | 8c97a76 | 2015-02-26 11:28:50 -0500 | [diff] [blame] | 4350 | { USB_DEVICE_WACOM(0x318) }, |
| 4351 | { USB_DEVICE_WACOM(0x319) }, |
Ping Cheng | fefb391 | 2014-11-11 12:52:08 -0800 | [diff] [blame] | 4352 | { USB_DEVICE_WACOM(0x323) }, |
Jason Gerecke | f7acb55 | 2015-10-13 10:03:49 -0700 | [diff] [blame] | 4353 | { USB_DEVICE_WACOM(0x325) }, |
| 4354 | { USB_DEVICE_WACOM(0x326) }, |
Ping Cheng | 500d416 | 2015-01-27 13:30:03 -0800 | [diff] [blame] | 4355 | { USB_DEVICE_WACOM(0x32A) }, |
| 4356 | { USB_DEVICE_WACOM(0x32B) }, |
| 4357 | { USB_DEVICE_WACOM(0x32C) }, |
Ping Cheng | fff00bf | 2014-12-04 18:23:04 -0800 | [diff] [blame] | 4358 | { USB_DEVICE_WACOM(0x32F) }, |
Aaron Skomra | 72b236d | 2015-08-20 16:05:17 -0700 | [diff] [blame] | 4359 | { USB_DEVICE_WACOM(0x331) }, |
Ping Cheng | b4bf212 | 2015-03-25 17:08:13 -0700 | [diff] [blame] | 4360 | { USB_DEVICE_WACOM(0x333) }, |
| 4361 | { USB_DEVICE_WACOM(0x335) }, |
Aaron Skomra | 007760c | 2015-04-16 15:01:14 -0700 | [diff] [blame] | 4362 | { USB_DEVICE_WACOM(0x336) }, |
Ping Cheng | eda01da | 2015-09-23 13:51:15 -0700 | [diff] [blame] | 4363 | { USB_DEVICE_WACOM(0x33B) }, |
| 4364 | { USB_DEVICE_WACOM(0x33C) }, |
| 4365 | { USB_DEVICE_WACOM(0x33D) }, |
| 4366 | { USB_DEVICE_WACOM(0x33E) }, |
Ping Cheng | e1123fe | 2016-04-12 13:37:45 -0700 | [diff] [blame] | 4367 | { USB_DEVICE_WACOM(0x343) }, |
Jason Gerecke | 4922cd2 | 2017-01-25 12:08:37 -0800 | [diff] [blame] | 4368 | { BT_DEVICE_WACOM(0x360) }, |
| 4369 | { BT_DEVICE_WACOM(0x361) }, |
Ping Cheng | edbe265 | 2012-11-21 13:12:50 -0800 | [diff] [blame] | 4370 | { USB_DEVICE_WACOM(0x4001) }, |
Jason Gerecke | d51ddb2 | 2014-05-14 17:14:29 -0700 | [diff] [blame] | 4371 | { USB_DEVICE_WACOM(0x4004) }, |
| 4372 | { USB_DEVICE_WACOM(0x5000) }, |
| 4373 | { USB_DEVICE_WACOM(0x5002) }, |
Benjamin Tissoires | 00d6f227 | 2014-12-01 11:52:39 -0500 | [diff] [blame] | 4374 | { USB_DEVICE_LENOVO(0x6004) }, |
Benjamin Tissoires | 7704ac9 | 2014-09-23 12:08:08 -0400 | [diff] [blame] | 4375 | |
| 4376 | { USB_DEVICE_WACOM(HID_ANY_ID) }, |
Mika Westerberg | eef23a8 | 2015-02-23 15:52:43 +0200 | [diff] [blame] | 4377 | { I2C_DEVICE_WACOM(HID_ANY_ID) }, |
Jason Gerecke | b9e0625 | 2017-01-25 12:08:35 -0800 | [diff] [blame] | 4378 | { BT_DEVICE_WACOM(HID_ANY_ID) }, |
Ping Cheng | 3bea733 | 2006-07-13 18:01:36 -0700 | [diff] [blame] | 4379 | { } |
| 4380 | }; |
Benjamin Tissoires | 29b4739 | 2014-07-24 12:52:23 -0700 | [diff] [blame] | 4381 | MODULE_DEVICE_TABLE(hid, wacom_ids); |