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