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