wacom_wac.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525
  1. /*
  2. * drivers/input/tablet/wacom_wac.c
  3. *
  4. * USB Wacom tablet support - Wacom specific code
  5. *
  6. */
  7. /*
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include "wacom_wac.h"
  14. #include "wacom.h"
  15. #include <linux/input/mt.h>
  16. static int wacom_penpartner_irq(struct wacom_wac *wacom)
  17. {
  18. unsigned char *data = wacom->data;
  19. struct input_dev *input = wacom->input;
  20. switch (data[0]) {
  21. case 1:
  22. if (data[5] & 0x80) {
  23. wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  24. wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
  25. input_report_key(input, wacom->tool[0], 1);
  26. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  27. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  28. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  29. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  30. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
  31. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  32. } else {
  33. input_report_key(input, wacom->tool[0], 0);
  34. input_report_abs(input, ABS_MISC, 0); /* report tool id */
  35. input_report_abs(input, ABS_PRESSURE, -1);
  36. input_report_key(input, BTN_TOUCH, 0);
  37. }
  38. break;
  39. case 2:
  40. input_report_key(input, BTN_TOOL_PEN, 1);
  41. input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
  42. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  43. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  44. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  45. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
  46. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  47. break;
  48. default:
  49. printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
  50. return 0;
  51. }
  52. return 1;
  53. }
  54. static int wacom_pl_irq(struct wacom_wac *wacom)
  55. {
  56. struct wacom_features *features = &wacom->features;
  57. unsigned char *data = wacom->data;
  58. struct input_dev *input = wacom->input;
  59. int prox, pressure;
  60. if (data[0] != WACOM_REPORT_PENABLED) {
  61. dbg("wacom_pl_irq: received unknown report #%d", data[0]);
  62. return 0;
  63. }
  64. prox = data[1] & 0x40;
  65. if (prox) {
  66. wacom->id[0] = ERASER_DEVICE_ID;
  67. pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
  68. if (features->pressure_max > 255)
  69. pressure = (pressure << 1) | ((data[4] >> 6) & 1);
  70. pressure += (features->pressure_max + 1) / 2;
  71. /*
  72. * if going from out of proximity into proximity select between the eraser
  73. * and the pen based on the state of the stylus2 button, choose eraser if
  74. * pressed else choose pen. if not a proximity change from out to in, send
  75. * an out of proximity for previous tool then a in for new tool.
  76. */
  77. if (!wacom->tool[0]) {
  78. /* Eraser bit set for DTF */
  79. if (data[1] & 0x10)
  80. wacom->tool[1] = BTN_TOOL_RUBBER;
  81. else
  82. /* Going into proximity select tool */
  83. wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  84. } else {
  85. /* was entered with stylus2 pressed */
  86. if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
  87. /* report out proximity for previous tool */
  88. input_report_key(input, wacom->tool[1], 0);
  89. input_sync(input);
  90. wacom->tool[1] = BTN_TOOL_PEN;
  91. return 0;
  92. }
  93. }
  94. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  95. /* Unknown tool selected default to pen tool */
  96. wacom->tool[1] = BTN_TOOL_PEN;
  97. wacom->id[0] = STYLUS_DEVICE_ID;
  98. }
  99. input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
  100. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  101. input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
  102. input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
  103. input_report_abs(input, ABS_PRESSURE, pressure);
  104. input_report_key(input, BTN_TOUCH, data[4] & 0x08);
  105. input_report_key(input, BTN_STYLUS, data[4] & 0x10);
  106. /* Only allow the stylus2 button to be reported for the pen tool. */
  107. input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
  108. } else {
  109. /* report proximity-out of a (valid) tool */
  110. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  111. /* Unknown tool selected default to pen tool */
  112. wacom->tool[1] = BTN_TOOL_PEN;
  113. }
  114. input_report_key(input, wacom->tool[1], prox);
  115. }
  116. wacom->tool[0] = prox; /* Save proximity state */
  117. return 1;
  118. }
  119. static int wacom_ptu_irq(struct wacom_wac *wacom)
  120. {
  121. unsigned char *data = wacom->data;
  122. struct input_dev *input = wacom->input;
  123. if (data[0] != WACOM_REPORT_PENABLED) {
  124. printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
  125. return 0;
  126. }
  127. if (data[1] & 0x04) {
  128. input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
  129. input_report_key(input, BTN_TOUCH, data[1] & 0x08);
  130. wacom->id[0] = ERASER_DEVICE_ID;
  131. } else {
  132. input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
  133. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  134. wacom->id[0] = STYLUS_DEVICE_ID;
  135. }
  136. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  137. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  138. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  139. input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  140. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  141. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  142. return 1;
  143. }
  144. static int wacom_dtu_irq(struct wacom_wac *wacom)
  145. {
  146. struct wacom_features *features = &wacom->features;
  147. char *data = wacom->data;
  148. struct input_dev *input = wacom->input;
  149. int prox = data[1] & 0x20, pressure;
  150. dbg("wacom_dtu_irq: received report #%d", data[0]);
  151. if (prox) {
  152. /* Going into proximity select tool */
  153. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  154. if (wacom->tool[0] == BTN_TOOL_PEN)
  155. wacom->id[0] = STYLUS_DEVICE_ID;
  156. else
  157. wacom->id[0] = ERASER_DEVICE_ID;
  158. }
  159. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  160. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  161. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  162. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  163. pressure = ((data[7] & 0x01) << 8) | data[6];
  164. if (pressure < 0)
  165. pressure = features->pressure_max + pressure + 1;
  166. input_report_abs(input, ABS_PRESSURE, pressure);
  167. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  168. if (!prox) /* out-prox */
  169. wacom->id[0] = 0;
  170. input_report_key(input, wacom->tool[0], prox);
  171. input_report_abs(input, ABS_MISC, wacom->id[0]);
  172. return 1;
  173. }
  174. static int wacom_graphire_irq(struct wacom_wac *wacom)
  175. {
  176. struct wacom_features *features = &wacom->features;
  177. unsigned char *data = wacom->data;
  178. struct input_dev *input = wacom->input;
  179. int prox;
  180. int rw = 0;
  181. int retval = 0;
  182. if (data[0] != WACOM_REPORT_PENABLED) {
  183. dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
  184. goto exit;
  185. }
  186. prox = data[1] & 0x80;
  187. if (prox || wacom->id[0]) {
  188. if (prox) {
  189. switch ((data[1] >> 5) & 3) {
  190. case 0: /* Pen */
  191. wacom->tool[0] = BTN_TOOL_PEN;
  192. wacom->id[0] = STYLUS_DEVICE_ID;
  193. break;
  194. case 1: /* Rubber */
  195. wacom->tool[0] = BTN_TOOL_RUBBER;
  196. wacom->id[0] = ERASER_DEVICE_ID;
  197. break;
  198. case 2: /* Mouse with wheel */
  199. input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
  200. /* fall through */
  201. case 3: /* Mouse without wheel */
  202. wacom->tool[0] = BTN_TOOL_MOUSE;
  203. wacom->id[0] = CURSOR_DEVICE_ID;
  204. break;
  205. }
  206. }
  207. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  208. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  209. if (wacom->tool[0] != BTN_TOOL_MOUSE) {
  210. input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
  211. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  212. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  213. input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
  214. } else {
  215. input_report_key(input, BTN_LEFT, data[1] & 0x01);
  216. input_report_key(input, BTN_RIGHT, data[1] & 0x02);
  217. if (features->type == WACOM_G4 ||
  218. features->type == WACOM_MO) {
  219. input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
  220. rw = (data[7] & 0x04) - (data[7] & 0x03);
  221. } else {
  222. input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
  223. rw = -(signed char)data[6];
  224. }
  225. input_report_rel(input, REL_WHEEL, rw);
  226. }
  227. if (!prox)
  228. wacom->id[0] = 0;
  229. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  230. input_report_key(input, wacom->tool[0], prox);
  231. input_sync(input); /* sync last event */
  232. }
  233. /* send pad data */
  234. switch (features->type) {
  235. case WACOM_G4:
  236. prox = data[7] & 0xf8;
  237. if (prox || wacom->id[1]) {
  238. wacom->id[1] = PAD_DEVICE_ID;
  239. input_report_key(input, BTN_0, (data[7] & 0x40));
  240. input_report_key(input, BTN_4, (data[7] & 0x80));
  241. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  242. input_report_rel(input, REL_WHEEL, rw);
  243. input_report_key(input, BTN_TOOL_FINGER, 0xf0);
  244. if (!prox)
  245. wacom->id[1] = 0;
  246. input_report_abs(input, ABS_MISC, wacom->id[1]);
  247. input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
  248. retval = 1;
  249. }
  250. break;
  251. case WACOM_MO:
  252. prox = (data[7] & 0xf8) || data[8];
  253. if (prox || wacom->id[1]) {
  254. wacom->id[1] = PAD_DEVICE_ID;
  255. input_report_key(input, BTN_0, (data[7] & 0x08));
  256. input_report_key(input, BTN_1, (data[7] & 0x20));
  257. input_report_key(input, BTN_4, (data[7] & 0x10));
  258. input_report_key(input, BTN_5, (data[7] & 0x40));
  259. input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
  260. input_report_key(input, BTN_TOOL_FINGER, 0xf0);
  261. if (!prox)
  262. wacom->id[1] = 0;
  263. input_report_abs(input, ABS_MISC, wacom->id[1]);
  264. input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
  265. }
  266. retval = 1;
  267. break;
  268. }
  269. exit:
  270. return retval;
  271. }
  272. static int wacom_intuos_inout(struct wacom_wac *wacom)
  273. {
  274. struct wacom_features *features = &wacom->features;
  275. unsigned char *data = wacom->data;
  276. struct input_dev *input = wacom->input;
  277. int idx = 0;
  278. /* tool number */
  279. if (features->type == INTUOS)
  280. idx = data[1] & 0x01;
  281. /* Enter report */
  282. if ((data[1] & 0xfc) == 0xc0) {
  283. /* serial number of the tool */
  284. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  285. (data[4] << 20) + (data[5] << 12) +
  286. (data[6] << 4) + (data[7] >> 4);
  287. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
  288. ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
  289. switch (wacom->id[idx] & 0xfffff) {
  290. case 0x812: /* Inking pen */
  291. case 0x801: /* Intuos3 Inking pen */
  292. case 0x20802: /* Intuos4 Inking Pen */
  293. case 0x012:
  294. wacom->tool[idx] = BTN_TOOL_PENCIL;
  295. break;
  296. case 0x822: /* Pen */
  297. case 0x842:
  298. case 0x852:
  299. case 0x823: /* Intuos3 Grip Pen */
  300. case 0x813: /* Intuos3 Classic Pen */
  301. case 0x885: /* Intuos3 Marker Pen */
  302. case 0x802: /* Intuos4 General Pen */
  303. case 0x804: /* Intuos4 Marker Pen */
  304. case 0x40802: /* Intuos4 Classic Pen */
  305. case 0x022:
  306. wacom->tool[idx] = BTN_TOOL_PEN;
  307. break;
  308. case 0x832: /* Stroke pen */
  309. case 0x032:
  310. wacom->tool[idx] = BTN_TOOL_BRUSH;
  311. break;
  312. case 0x007: /* Mouse 4D and 2D */
  313. case 0x09c:
  314. case 0x094:
  315. case 0x017: /* Intuos3 2D Mouse */
  316. case 0x806: /* Intuos4 Mouse */
  317. wacom->tool[idx] = BTN_TOOL_MOUSE;
  318. break;
  319. case 0x096: /* Lens cursor */
  320. case 0x097: /* Intuos3 Lens cursor */
  321. case 0x006: /* Intuos4 Lens cursor */
  322. wacom->tool[idx] = BTN_TOOL_LENS;
  323. break;
  324. case 0x82a: /* Eraser */
  325. case 0x85a:
  326. case 0x91a:
  327. case 0xd1a:
  328. case 0x0fa:
  329. case 0x82b: /* Intuos3 Grip Pen Eraser */
  330. case 0x81b: /* Intuos3 Classic Pen Eraser */
  331. case 0x91b: /* Intuos3 Airbrush Eraser */
  332. case 0x80c: /* Intuos4 Marker Pen Eraser */
  333. case 0x80a: /* Intuos4 General Pen Eraser */
  334. case 0x4080a: /* Intuos4 Classic Pen Eraser */
  335. case 0x90a: /* Intuos4 Airbrush Eraser */
  336. wacom->tool[idx] = BTN_TOOL_RUBBER;
  337. break;
  338. case 0xd12:
  339. case 0x912:
  340. case 0x112:
  341. case 0x913: /* Intuos3 Airbrush */
  342. case 0x902: /* Intuos4 Airbrush */
  343. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  344. break;
  345. default: /* Unknown tool */
  346. wacom->tool[idx] = BTN_TOOL_PEN;
  347. break;
  348. }
  349. return 1;
  350. }
  351. /* older I4 styli don't work with new Cintiqs */
  352. if (!((wacom->id[idx] >> 20) & 0x01) &&
  353. (features->type == WACOM_21UX2))
  354. return 1;
  355. /* Exit report */
  356. if ((data[1] & 0xfe) == 0x80) {
  357. /*
  358. * Reset all states otherwise we lose the initial states
  359. * when in-prox next time
  360. */
  361. input_report_abs(input, ABS_X, 0);
  362. input_report_abs(input, ABS_Y, 0);
  363. input_report_abs(input, ABS_DISTANCE, 0);
  364. input_report_abs(input, ABS_TILT_X, 0);
  365. input_report_abs(input, ABS_TILT_Y, 0);
  366. if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
  367. input_report_key(input, BTN_LEFT, 0);
  368. input_report_key(input, BTN_MIDDLE, 0);
  369. input_report_key(input, BTN_RIGHT, 0);
  370. input_report_key(input, BTN_SIDE, 0);
  371. input_report_key(input, BTN_EXTRA, 0);
  372. input_report_abs(input, ABS_THROTTLE, 0);
  373. input_report_abs(input, ABS_RZ, 0);
  374. } else {
  375. input_report_abs(input, ABS_PRESSURE, 0);
  376. input_report_key(input, BTN_STYLUS, 0);
  377. input_report_key(input, BTN_STYLUS2, 0);
  378. input_report_key(input, BTN_TOUCH, 0);
  379. input_report_abs(input, ABS_WHEEL, 0);
  380. if (features->type >= INTUOS3S)
  381. input_report_abs(input, ABS_Z, 0);
  382. }
  383. input_report_key(input, wacom->tool[idx], 0);
  384. input_report_abs(input, ABS_MISC, 0); /* reset tool id */
  385. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  386. wacom->id[idx] = 0;
  387. return 2;
  388. }
  389. return 0;
  390. }
  391. static void wacom_intuos_general(struct wacom_wac *wacom)
  392. {
  393. struct wacom_features *features = &wacom->features;
  394. unsigned char *data = wacom->data;
  395. struct input_dev *input = wacom->input;
  396. unsigned int t;
  397. /* general pen packet */
  398. if ((data[1] & 0xb8) == 0xa0) {
  399. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  400. if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
  401. features->type == WACOM_21UX2) {
  402. t = (t << 1) | (data[1] & 1);
  403. }
  404. input_report_abs(input, ABS_PRESSURE, t);
  405. input_report_abs(input, ABS_TILT_X,
  406. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  407. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  408. input_report_key(input, BTN_STYLUS, data[1] & 2);
  409. input_report_key(input, BTN_STYLUS2, data[1] & 4);
  410. input_report_key(input, BTN_TOUCH, t > 10);
  411. }
  412. /* airbrush second packet */
  413. if ((data[1] & 0xbc) == 0xb4) {
  414. input_report_abs(input, ABS_WHEEL,
  415. (data[6] << 2) | ((data[7] >> 6) & 3));
  416. input_report_abs(input, ABS_TILT_X,
  417. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  418. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  419. }
  420. }
  421. static int wacom_intuos_irq(struct wacom_wac *wacom)
  422. {
  423. struct wacom_features *features = &wacom->features;
  424. unsigned char *data = wacom->data;
  425. struct input_dev *input = wacom->input;
  426. unsigned int t;
  427. int idx = 0, result;
  428. if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD
  429. && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD) {
  430. dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
  431. return 0;
  432. }
  433. /* tool number */
  434. if (features->type == INTUOS)
  435. idx = data[1] & 0x01;
  436. /* pad packets. Works as a second tool and is always in prox */
  437. if (data[0] == WACOM_REPORT_INTUOSPAD) {
  438. /* initiate the pad as a device */
  439. if (wacom->tool[1] != BTN_TOOL_FINGER)
  440. wacom->tool[1] = BTN_TOOL_FINGER;
  441. if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
  442. input_report_key(input, BTN_0, (data[2] & 0x01));
  443. input_report_key(input, BTN_1, (data[3] & 0x01));
  444. input_report_key(input, BTN_2, (data[3] & 0x02));
  445. input_report_key(input, BTN_3, (data[3] & 0x04));
  446. input_report_key(input, BTN_4, (data[3] & 0x08));
  447. input_report_key(input, BTN_5, (data[3] & 0x10));
  448. input_report_key(input, BTN_6, (data[3] & 0x20));
  449. if (data[1] & 0x80) {
  450. input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
  451. } else {
  452. /* Out of proximity, clear wheel value. */
  453. input_report_abs(input, ABS_WHEEL, 0);
  454. }
  455. if (features->type != INTUOS4S) {
  456. input_report_key(input, BTN_7, (data[3] & 0x40));
  457. input_report_key(input, BTN_8, (data[3] & 0x80));
  458. }
  459. if (data[1] | (data[2] & 0x01) | data[3]) {
  460. input_report_key(input, wacom->tool[1], 1);
  461. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  462. } else {
  463. input_report_key(input, wacom->tool[1], 0);
  464. input_report_abs(input, ABS_MISC, 0);
  465. }
  466. } else {
  467. if (features->type == WACOM_21UX2) {
  468. input_report_key(input, BTN_0, (data[5] & 0x01));
  469. input_report_key(input, BTN_1, (data[6] & 0x01));
  470. input_report_key(input, BTN_2, (data[6] & 0x02));
  471. input_report_key(input, BTN_3, (data[6] & 0x04));
  472. input_report_key(input, BTN_4, (data[6] & 0x08));
  473. input_report_key(input, BTN_5, (data[6] & 0x10));
  474. input_report_key(input, BTN_6, (data[6] & 0x20));
  475. input_report_key(input, BTN_7, (data[6] & 0x40));
  476. input_report_key(input, BTN_8, (data[6] & 0x80));
  477. input_report_key(input, BTN_9, (data[7] & 0x01));
  478. input_report_key(input, BTN_A, (data[8] & 0x01));
  479. input_report_key(input, BTN_B, (data[8] & 0x02));
  480. input_report_key(input, BTN_C, (data[8] & 0x04));
  481. input_report_key(input, BTN_X, (data[8] & 0x08));
  482. input_report_key(input, BTN_Y, (data[8] & 0x10));
  483. input_report_key(input, BTN_Z, (data[8] & 0x20));
  484. input_report_key(input, BTN_BASE, (data[8] & 0x40));
  485. input_report_key(input, BTN_BASE2, (data[8] & 0x80));
  486. } else {
  487. input_report_key(input, BTN_0, (data[5] & 0x01));
  488. input_report_key(input, BTN_1, (data[5] & 0x02));
  489. input_report_key(input, BTN_2, (data[5] & 0x04));
  490. input_report_key(input, BTN_3, (data[5] & 0x08));
  491. input_report_key(input, BTN_4, (data[6] & 0x01));
  492. input_report_key(input, BTN_5, (data[6] & 0x02));
  493. input_report_key(input, BTN_6, (data[6] & 0x04));
  494. input_report_key(input, BTN_7, (data[6] & 0x08));
  495. input_report_key(input, BTN_8, (data[5] & 0x10));
  496. input_report_key(input, BTN_9, (data[6] & 0x10));
  497. }
  498. input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  499. input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  500. if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
  501. data[2] | (data[3] & 0x1f) | data[4] | data[8] |
  502. (data[7] & 0x01)) {
  503. input_report_key(input, wacom->tool[1], 1);
  504. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  505. } else {
  506. input_report_key(input, wacom->tool[1], 0);
  507. input_report_abs(input, ABS_MISC, 0);
  508. }
  509. }
  510. input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
  511. return 1;
  512. }
  513. /* process in/out prox events */
  514. result = wacom_intuos_inout(wacom);
  515. if (result)
  516. return result - 1;
  517. /* don't proceed if we don't know the ID */
  518. if (!wacom->id[idx])
  519. return 0;
  520. /* Only large Intuos support Lense Cursor */
  521. if (wacom->tool[idx] == BTN_TOOL_LENS &&
  522. (features->type == INTUOS3 ||
  523. features->type == INTUOS3S ||
  524. features->type == INTUOS4 ||
  525. features->type == INTUOS4S)) {
  526. return 0;
  527. }
  528. /* Cintiq doesn't send data when RDY bit isn't set */
  529. if (features->type == CINTIQ && !(data[1] & 0x40))
  530. return 0;
  531. if (features->type >= INTUOS3S) {
  532. input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  533. input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  534. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  535. } else {
  536. input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
  537. input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
  538. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  539. }
  540. /* process general packets */
  541. wacom_intuos_general(wacom);
  542. /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
  543. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
  544. if (data[1] & 0x02) {
  545. /* Rotation packet */
  546. if (features->type >= INTUOS3S) {
  547. /* I3 marker pen rotation */
  548. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  549. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  550. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  551. input_report_abs(input, ABS_Z, t);
  552. } else {
  553. /* 4D mouse rotation packet */
  554. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  555. input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
  556. ((t - 1) / 2) : -t / 2);
  557. }
  558. } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
  559. /* 4D mouse packet */
  560. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  561. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  562. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  563. input_report_key(input, BTN_SIDE, data[8] & 0x20);
  564. input_report_key(input, BTN_EXTRA, data[8] & 0x10);
  565. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  566. input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  567. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  568. /* I4 mouse */
  569. if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
  570. input_report_key(input, BTN_LEFT, data[6] & 0x01);
  571. input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
  572. input_report_key(input, BTN_RIGHT, data[6] & 0x04);
  573. input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
  574. - ((data[7] & 0x40) >> 6));
  575. input_report_key(input, BTN_SIDE, data[6] & 0x08);
  576. input_report_key(input, BTN_EXTRA, data[6] & 0x10);
  577. input_report_abs(input, ABS_TILT_X,
  578. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  579. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  580. } else {
  581. /* 2D mouse packet */
  582. input_report_key(input, BTN_LEFT, data[8] & 0x04);
  583. input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
  584. input_report_key(input, BTN_RIGHT, data[8] & 0x10);
  585. input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
  586. - ((data[8] & 0x02) >> 1));
  587. /* I3 2D mouse side buttons */
  588. if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
  589. input_report_key(input, BTN_SIDE, data[8] & 0x40);
  590. input_report_key(input, BTN_EXTRA, data[8] & 0x20);
  591. }
  592. }
  593. } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
  594. features->type == INTUOS4L) &&
  595. wacom->tool[idx] == BTN_TOOL_LENS) {
  596. /* Lens cursor packets */
  597. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  598. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  599. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  600. input_report_key(input, BTN_SIDE, data[8] & 0x10);
  601. input_report_key(input, BTN_EXTRA, data[8] & 0x08);
  602. }
  603. }
  604. input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
  605. input_report_key(input, wacom->tool[idx], 1);
  606. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  607. return 1;
  608. }
  609. static void wacom_tpc_finger_in(struct wacom_wac *wacom, char *data, int idx)
  610. {
  611. struct input_dev *input = wacom->input;
  612. int finger = idx + 1;
  613. int x = le16_to_cpup((__le16 *)&data[finger * 2]) & 0x7fff;
  614. int y = le16_to_cpup((__le16 *)&data[4 + finger * 2]) & 0x7fff;
  615. /*
  616. * Work around input core suppressing "duplicate" events since
  617. * we are abusing ABS_X/ABS_Y to transmit multi-finger data.
  618. * This should go away once we switch to true multitouch
  619. * protocol.
  620. */
  621. if (wacom->last_finger != finger) {
  622. if (x == input_abs_get_val(input, ABS_X))
  623. x++;
  624. if (y == input_abs_get_val(input, ABS_Y))
  625. y++;
  626. }
  627. input_report_abs(input, ABS_X, x);
  628. input_report_abs(input, ABS_Y, y);
  629. input_report_abs(input, ABS_MISC, wacom->id[0]);
  630. input_report_key(input, wacom->tool[finger], 1);
  631. if (!idx)
  632. input_report_key(input, BTN_TOUCH, 1);
  633. input_event(input, EV_MSC, MSC_SERIAL, finger);
  634. input_sync(input);
  635. wacom->last_finger = finger;
  636. }
  637. static void wacom_tpc_touch_out(struct wacom_wac *wacom, int idx)
  638. {
  639. struct input_dev *input = wacom->input;
  640. int finger = idx + 1;
  641. input_report_abs(input, ABS_X, 0);
  642. input_report_abs(input, ABS_Y, 0);
  643. input_report_abs(input, ABS_MISC, 0);
  644. input_report_key(input, wacom->tool[finger], 0);
  645. if (!idx)
  646. input_report_key(input, BTN_TOUCH, 0);
  647. input_event(input, EV_MSC, MSC_SERIAL, finger);
  648. input_sync(input);
  649. }
  650. static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
  651. {
  652. char *data = wacom->data;
  653. struct input_dev *input = wacom->input;
  654. wacom->tool[1] = BTN_TOOL_DOUBLETAP;
  655. wacom->id[0] = TOUCH_DEVICE_ID;
  656. wacom->tool[2] = BTN_TOOL_TRIPLETAP;
  657. if (len != WACOM_PKGLEN_TPC1FG) {
  658. switch (data[0]) {
  659. case WACOM_REPORT_TPC1FG:
  660. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  661. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  662. input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  663. input_report_key(input, BTN_TOUCH, le16_to_cpup((__le16 *)&data[6]));
  664. input_report_abs(input, ABS_MISC, wacom->id[0]);
  665. input_report_key(input, wacom->tool[1], 1);
  666. input_sync(input);
  667. break;
  668. case WACOM_REPORT_TPC2FG:
  669. if (data[1] & 0x01)
  670. wacom_tpc_finger_in(wacom, data, 0);
  671. else if (wacom->id[1] & 0x01)
  672. wacom_tpc_touch_out(wacom, 0);
  673. if (data[1] & 0x02)
  674. wacom_tpc_finger_in(wacom, data, 1);
  675. else if (wacom->id[1] & 0x02)
  676. wacom_tpc_touch_out(wacom, 1);
  677. break;
  678. }
  679. } else {
  680. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  681. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  682. input_report_key(input, BTN_TOUCH, 1);
  683. input_report_abs(input, ABS_MISC, wacom->id[1]);
  684. input_report_key(input, wacom->tool[1], 1);
  685. input_sync(input);
  686. }
  687. }
  688. static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
  689. {
  690. struct wacom_features *features = &wacom->features;
  691. char *data = wacom->data;
  692. struct input_dev *input = wacom->input;
  693. int prox = 0, pressure;
  694. int retval = 0;
  695. dbg("wacom_tpc_irq: received report #%d", data[0]);
  696. if (len == WACOM_PKGLEN_TPC1FG || /* single touch */
  697. data[0] == WACOM_REPORT_TPC1FG || /* single touch */
  698. data[0] == WACOM_REPORT_TPC2FG) { /* 2FG touch */
  699. if (wacom->shared->stylus_in_proximity) {
  700. if (wacom->id[1] & 0x01)
  701. wacom_tpc_touch_out(wacom, 0);
  702. if (wacom->id[1] & 0x02)
  703. wacom_tpc_touch_out(wacom, 1);
  704. wacom->id[1] = 0;
  705. return 0;
  706. }
  707. if (len == WACOM_PKGLEN_TPC1FG) { /* with touch */
  708. prox = data[0] & 0x01;
  709. } else { /* with capacity */
  710. if (data[0] == WACOM_REPORT_TPC1FG)
  711. /* single touch */
  712. prox = data[1] & 0x01;
  713. else
  714. /* 2FG touch data */
  715. prox = data[1] & 0x03;
  716. }
  717. if (prox) {
  718. if (!wacom->id[1])
  719. wacom->last_finger = 1;
  720. wacom_tpc_touch_in(wacom, len);
  721. } else {
  722. if (data[0] == WACOM_REPORT_TPC2FG) {
  723. /* 2FGT out-prox */
  724. if (wacom->id[1] & 0x01)
  725. wacom_tpc_touch_out(wacom, 0);
  726. if (wacom->id[1] & 0x02)
  727. wacom_tpc_touch_out(wacom, 1);
  728. } else
  729. /* one finger touch */
  730. wacom_tpc_touch_out(wacom, 0);
  731. wacom->id[0] = 0;
  732. }
  733. /* keep prox bit to send proper out-prox event */
  734. wacom->id[1] = prox;
  735. } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */
  736. prox = data[1] & 0x20;
  737. if (!wacom->shared->stylus_in_proximity) { /* first in prox */
  738. /* Going into proximity select tool */
  739. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  740. if (wacom->tool[0] == BTN_TOOL_PEN)
  741. wacom->id[0] = STYLUS_DEVICE_ID;
  742. else
  743. wacom->id[0] = ERASER_DEVICE_ID;
  744. wacom->shared->stylus_in_proximity = true;
  745. }
  746. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  747. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  748. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  749. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  750. pressure = ((data[7] & 0x01) << 8) | data[6];
  751. if (pressure < 0)
  752. pressure = features->pressure_max + pressure + 1;
  753. input_report_abs(input, ABS_PRESSURE, pressure);
  754. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  755. if (!prox) { /* out-prox */
  756. wacom->id[0] = 0;
  757. wacom->shared->stylus_in_proximity = false;
  758. }
  759. input_report_key(input, wacom->tool[0], prox);
  760. input_report_abs(input, ABS_MISC, wacom->id[0]);
  761. retval = 1;
  762. }
  763. return retval;
  764. }
  765. static int wacom_bpt_touch(struct wacom_wac *wacom)
  766. {
  767. struct wacom_features *features = &wacom->features;
  768. struct input_dev *input = wacom->input;
  769. unsigned char *data = wacom->data;
  770. int i;
  771. for (i = 0; i < 2; i++) {
  772. int p = data[9 * i + 2];
  773. bool touch = p && !wacom->shared->stylus_in_proximity;
  774. input_mt_slot(input, i);
  775. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  776. /*
  777. * Touch events need to be disabled while stylus is
  778. * in proximity because user's hand is resting on touchpad
  779. * and sending unwanted events. User expects tablet buttons
  780. * to continue working though.
  781. */
  782. if (touch) {
  783. int x = get_unaligned_be16(&data[9 * i + 3]) & 0x7ff;
  784. int y = get_unaligned_be16(&data[9 * i + 5]) & 0x7ff;
  785. if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
  786. x <<= 5;
  787. y <<= 5;
  788. }
  789. input_report_abs(input, ABS_MT_PRESSURE, p);
  790. input_report_abs(input, ABS_MT_POSITION_X, x);
  791. input_report_abs(input, ABS_MT_POSITION_Y, y);
  792. }
  793. }
  794. input_mt_report_pointer_emulation(input, true);
  795. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  796. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  797. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  798. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  799. input_sync(input);
  800. return 0;
  801. }
  802. static int wacom_bpt_pen(struct wacom_wac *wacom)
  803. {
  804. struct input_dev *input = wacom->input;
  805. unsigned char *data = wacom->data;
  806. int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
  807. /*
  808. * Similar to Graphire protocol, data[1] & 0x20 is proximity and
  809. * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore
  810. * 2 unused tool ID's.
  811. */
  812. prox = (data[1] & 0x30) == 0x30;
  813. /*
  814. * All reports shared between PEN and RUBBER tool must be
  815. * forced to a known starting value (zero) when transitioning to
  816. * out-of-prox.
  817. *
  818. * If not reset then, to userspace, it will look like lost events
  819. * if new tool comes in-prox with same values as previous tool sent.
  820. *
  821. * Hardware does report zero in most out-of-prox cases but not all.
  822. */
  823. if (prox) {
  824. if (!wacom->shared->stylus_in_proximity) {
  825. if (data[1] & 0x08) {
  826. wacom->tool[0] = BTN_TOOL_RUBBER;
  827. wacom->id[0] = ERASER_DEVICE_ID;
  828. } else {
  829. wacom->tool[0] = BTN_TOOL_PEN;
  830. wacom->id[0] = STYLUS_DEVICE_ID;
  831. }
  832. wacom->shared->stylus_in_proximity = true;
  833. }
  834. x = le16_to_cpup((__le16 *)&data[2]);
  835. y = le16_to_cpup((__le16 *)&data[4]);
  836. p = le16_to_cpup((__le16 *)&data[6]);
  837. d = data[8];
  838. pen = data[1] & 0x01;
  839. btn1 = data[1] & 0x02;
  840. btn2 = data[1] & 0x04;
  841. }
  842. input_report_key(input, BTN_TOUCH, pen);
  843. input_report_key(input, BTN_STYLUS, btn1);
  844. input_report_key(input, BTN_STYLUS2, btn2);
  845. input_report_abs(input, ABS_X, x);
  846. input_report_abs(input, ABS_Y, y);
  847. input_report_abs(input, ABS_PRESSURE, p);
  848. input_report_abs(input, ABS_DISTANCE, d);
  849. if (!prox) {
  850. wacom->id[0] = 0;
  851. wacom->shared->stylus_in_proximity = false;
  852. }
  853. input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
  854. input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
  855. return 1;
  856. }
  857. static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  858. {
  859. if (len == WACOM_PKGLEN_BBTOUCH)
  860. return wacom_bpt_touch(wacom);
  861. else if (len == WACOM_PKGLEN_BBFUN)
  862. return wacom_bpt_pen(wacom);
  863. return 0;
  864. }
  865. void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  866. {
  867. bool sync;
  868. switch (wacom_wac->features.type) {
  869. case PENPARTNER:
  870. sync = wacom_penpartner_irq(wacom_wac);
  871. break;
  872. case PL:
  873. sync = wacom_pl_irq(wacom_wac);
  874. break;
  875. case WACOM_G4:
  876. case GRAPHIRE:
  877. case WACOM_MO:
  878. sync = wacom_graphire_irq(wacom_wac);
  879. break;
  880. case PTU:
  881. sync = wacom_ptu_irq(wacom_wac);
  882. break;
  883. case DTU:
  884. sync = wacom_dtu_irq(wacom_wac);
  885. break;
  886. case INTUOS:
  887. case INTUOS3S:
  888. case INTUOS3:
  889. case INTUOS3L:
  890. case INTUOS4S:
  891. case INTUOS4:
  892. case INTUOS4L:
  893. case CINTIQ:
  894. case WACOM_BEE:
  895. case WACOM_21UX2:
  896. sync = wacom_intuos_irq(wacom_wac);
  897. break;
  898. case TABLETPC:
  899. case TABLETPC2FG:
  900. sync = wacom_tpc_irq(wacom_wac, len);
  901. break;
  902. case BAMBOO_PT:
  903. sync = wacom_bpt_irq(wacom_wac, len);
  904. break;
  905. default:
  906. sync = false;
  907. break;
  908. }
  909. if (sync)
  910. input_sync(wacom_wac->input);
  911. }
  912. static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  913. {
  914. struct input_dev *input_dev = wacom_wac->input;
  915. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  916. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  917. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  918. __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  919. __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  920. __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  921. __set_bit(BTN_STYLUS, input_dev->keybit);
  922. __set_bit(BTN_STYLUS2, input_dev->keybit);
  923. input_set_abs_params(input_dev, ABS_DISTANCE,
  924. 0, wacom_wac->features.distance_max, 0, 0);
  925. input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  926. input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
  927. input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
  928. }
  929. static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  930. {
  931. struct input_dev *input_dev = wacom_wac->input;
  932. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  933. wacom_setup_cintiq(wacom_wac);
  934. __set_bit(BTN_LEFT, input_dev->keybit);
  935. __set_bit(BTN_RIGHT, input_dev->keybit);
  936. __set_bit(BTN_MIDDLE, input_dev->keybit);
  937. __set_bit(BTN_SIDE, input_dev->keybit);
  938. __set_bit(BTN_EXTRA, input_dev->keybit);
  939. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  940. __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  941. input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  942. input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  943. }
  944. void wacom_setup_device_quirks(struct wacom_features *features)
  945. {
  946. /* touch device found but size is not defined. use default */
  947. if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {
  948. features->x_max = 1023;
  949. features->y_max = 1023;
  950. }
  951. /* these device have multiple inputs */
  952. if (features->type == TABLETPC || features->type == TABLETPC2FG ||
  953. features->type == BAMBOO_PT)
  954. features->quirks |= WACOM_QUIRK_MULTI_INPUT;
  955. /* quirks for bamboo touch */
  956. if (features->type == BAMBOO_PT &&
  957. features->device_type == BTN_TOOL_TRIPLETAP) {
  958. features->x_max <<= 5;
  959. features->y_max <<= 5;
  960. features->x_fuzz <<= 5;
  961. features->y_fuzz <<= 5;
  962. features->pressure_max = 256;
  963. features->pressure_fuzz = 16;
  964. features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
  965. }
  966. }
  967. void wacom_setup_input_capabilities(struct input_dev *input_dev,
  968. struct wacom_wac *wacom_wac)
  969. {
  970. struct wacom_features *features = &wacom_wac->features;
  971. int i;
  972. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  973. __set_bit(BTN_TOUCH, input_dev->keybit);
  974. input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
  975. features->x_fuzz, 0);
  976. input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
  977. features->y_fuzz, 0);
  978. input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
  979. features->pressure_fuzz, 0);
  980. __set_bit(ABS_MISC, input_dev->absbit);
  981. switch (wacom_wac->features.type) {
  982. case WACOM_MO:
  983. __set_bit(BTN_1, input_dev->keybit);
  984. __set_bit(BTN_5, input_dev->keybit);
  985. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  986. /* fall through */
  987. case WACOM_G4:
  988. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  989. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  990. __set_bit(BTN_0, input_dev->keybit);
  991. __set_bit(BTN_4, input_dev->keybit);
  992. /* fall through */
  993. case GRAPHIRE:
  994. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  995. __set_bit(BTN_LEFT, input_dev->keybit);
  996. __set_bit(BTN_RIGHT, input_dev->keybit);
  997. __set_bit(BTN_MIDDLE, input_dev->keybit);
  998. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  999. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1000. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1001. __set_bit(BTN_STYLUS, input_dev->keybit);
  1002. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1003. break;
  1004. case WACOM_21UX2:
  1005. __set_bit(BTN_A, input_dev->keybit);
  1006. __set_bit(BTN_B, input_dev->keybit);
  1007. __set_bit(BTN_C, input_dev->keybit);
  1008. __set_bit(BTN_X, input_dev->keybit);
  1009. __set_bit(BTN_Y, input_dev->keybit);
  1010. __set_bit(BTN_Z, input_dev->keybit);
  1011. __set_bit(BTN_BASE, input_dev->keybit);
  1012. __set_bit(BTN_BASE2, input_dev->keybit);
  1013. /* fall through */
  1014. case WACOM_BEE:
  1015. __set_bit(BTN_8, input_dev->keybit);
  1016. __set_bit(BTN_9, input_dev->keybit);
  1017. /* fall through */
  1018. case CINTIQ:
  1019. for (i = 0; i < 8; i++)
  1020. __set_bit(BTN_0 + i, input_dev->keybit);
  1021. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  1022. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  1023. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  1024. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1025. wacom_setup_cintiq(wacom_wac);
  1026. break;
  1027. case INTUOS3:
  1028. case INTUOS3L:
  1029. __set_bit(BTN_4, input_dev->keybit);
  1030. __set_bit(BTN_5, input_dev->keybit);
  1031. __set_bit(BTN_6, input_dev->keybit);
  1032. __set_bit(BTN_7, input_dev->keybit);
  1033. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  1034. /* fall through */
  1035. case INTUOS3S:
  1036. __set_bit(BTN_0, input_dev->keybit);
  1037. __set_bit(BTN_1, input_dev->keybit);
  1038. __set_bit(BTN_2, input_dev->keybit);
  1039. __set_bit(BTN_3, input_dev->keybit);
  1040. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  1041. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  1042. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1043. /* fall through */
  1044. case INTUOS:
  1045. wacom_setup_intuos(wacom_wac);
  1046. break;
  1047. case INTUOS4:
  1048. case INTUOS4L:
  1049. __set_bit(BTN_7, input_dev->keybit);
  1050. __set_bit(BTN_8, input_dev->keybit);
  1051. /* fall through */
  1052. case INTUOS4S:
  1053. for (i = 0; i < 7; i++)
  1054. __set_bit(BTN_0 + i, input_dev->keybit);
  1055. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  1056. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1057. wacom_setup_intuos(wacom_wac);
  1058. break;
  1059. case TABLETPC2FG:
  1060. if (features->device_type == BTN_TOOL_TRIPLETAP) {
  1061. __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
  1062. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  1063. }
  1064. /* fall through */
  1065. case TABLETPC:
  1066. if (features->device_type == BTN_TOOL_DOUBLETAP ||
  1067. features->device_type == BTN_TOOL_TRIPLETAP) {
  1068. input_set_abs_params(input_dev, ABS_RX, 0, features->x_phy, 0, 0);
  1069. input_set_abs_params(input_dev, ABS_RY, 0, features->y_phy, 0, 0);
  1070. __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
  1071. }
  1072. if (features->device_type != BTN_TOOL_PEN)
  1073. break; /* no need to process stylus stuff */
  1074. /* fall through */
  1075. case PL:
  1076. case PTU:
  1077. case DTU:
  1078. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1079. __set_bit(BTN_STYLUS, input_dev->keybit);
  1080. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1081. /* fall through */
  1082. case PENPARTNER:
  1083. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1084. break;
  1085. case BAMBOO_PT:
  1086. __clear_bit(ABS_MISC, input_dev->absbit);
  1087. if (features->device_type == BTN_TOOL_TRIPLETAP) {
  1088. __set_bit(BTN_LEFT, input_dev->keybit);
  1089. __set_bit(BTN_FORWARD, input_dev->keybit);
  1090. __set_bit(BTN_BACK, input_dev->keybit);
  1091. __set_bit(BTN_RIGHT, input_dev->keybit);
  1092. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  1093. __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
  1094. input_mt_init_slots(input_dev, 2);
  1095. input_set_abs_params(input_dev, ABS_MT_POSITION_X,
  1096. 0, features->x_max,
  1097. features->x_fuzz, 0);
  1098. input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
  1099. 0, features->y_max,
  1100. features->y_fuzz, 0);
  1101. input_set_abs_params(input_dev, ABS_MT_PRESSURE,
  1102. 0, features->pressure_max,
  1103. features->pressure_fuzz, 0);
  1104. } else if (features->device_type == BTN_TOOL_PEN) {
  1105. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1106. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1107. __set_bit(BTN_STYLUS, input_dev->keybit);
  1108. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1109. }
  1110. break;
  1111. }
  1112. }
  1113. static const struct wacom_features wacom_features_0x00 =
  1114. { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER };
  1115. static const struct wacom_features wacom_features_0x10 =
  1116. { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
  1117. static const struct wacom_features wacom_features_0x11 =
  1118. { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE };
  1119. static const struct wacom_features wacom_features_0x12 =
  1120. { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE };
  1121. static const struct wacom_features wacom_features_0x13 =
  1122. { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE };
  1123. static const struct wacom_features wacom_features_0x14 =
  1124. { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
  1125. static const struct wacom_features wacom_features_0x15 =
  1126. { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 };
  1127. static const struct wacom_features wacom_features_0x16 =
  1128. { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 };
  1129. static const struct wacom_features wacom_features_0x17 =
  1130. { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
  1131. static const struct wacom_features wacom_features_0x18 =
  1132. { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO };
  1133. static const struct wacom_features wacom_features_0x19 =
  1134. { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE };
  1135. static const struct wacom_features wacom_features_0x60 =
  1136. { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
  1137. static const struct wacom_features wacom_features_0x61 =
  1138. { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE };
  1139. static const struct wacom_features wacom_features_0x62 =
  1140. { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
  1141. static const struct wacom_features wacom_features_0x63 =
  1142. { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE };
  1143. static const struct wacom_features wacom_features_0x64 =
  1144. { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE };
  1145. static const struct wacom_features wacom_features_0x65 =
  1146. { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO };
  1147. static const struct wacom_features wacom_features_0x69 =
  1148. { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE };
  1149. static const struct wacom_features wacom_features_0x20 =
  1150. { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
  1151. static const struct wacom_features wacom_features_0x21 =
  1152. { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
  1153. static const struct wacom_features wacom_features_0x22 =
  1154. { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
  1155. static const struct wacom_features wacom_features_0x23 =
  1156. { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
  1157. static const struct wacom_features wacom_features_0x24 =
  1158. { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
  1159. static const struct wacom_features wacom_features_0x30 =
  1160. { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL };
  1161. static const struct wacom_features wacom_features_0x31 =
  1162. { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL };
  1163. static const struct wacom_features wacom_features_0x32 =
  1164. { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL };
  1165. static const struct wacom_features wacom_features_0x33 =
  1166. { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL };
  1167. static const struct wacom_features wacom_features_0x34 =
  1168. { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL };
  1169. static const struct wacom_features wacom_features_0x35 =
  1170. { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL };
  1171. static const struct wacom_features wacom_features_0x37 =
  1172. { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL };
  1173. static const struct wacom_features wacom_features_0x38 =
  1174. { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
  1175. static const struct wacom_features wacom_features_0x39 =
  1176. { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL };
  1177. static const struct wacom_features wacom_features_0xC4 =
  1178. { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL };
  1179. static const struct wacom_features wacom_features_0xC0 =
  1180. { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
  1181. static const struct wacom_features wacom_features_0xC2 =
  1182. { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL };
  1183. static const struct wacom_features wacom_features_0x03 =
  1184. { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU };
  1185. static const struct wacom_features wacom_features_0x41 =
  1186. { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS };
  1187. static const struct wacom_features wacom_features_0x42 =
  1188. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
  1189. static const struct wacom_features wacom_features_0x43 =
  1190. { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS };
  1191. static const struct wacom_features wacom_features_0x44 =
  1192. { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS };
  1193. static const struct wacom_features wacom_features_0x45 =
  1194. { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS };
  1195. static const struct wacom_features wacom_features_0xB0 =
  1196. { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S };
  1197. static const struct wacom_features wacom_features_0xB1 =
  1198. { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 };
  1199. static const struct wacom_features wacom_features_0xB2 =
  1200. { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 };
  1201. static const struct wacom_features wacom_features_0xB3 =
  1202. { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L };
  1203. static const struct wacom_features wacom_features_0xB4 =
  1204. { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L };
  1205. static const struct wacom_features wacom_features_0xB5 =
  1206. { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 };
  1207. static const struct wacom_features wacom_features_0xB7 =
  1208. { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S };
  1209. static const struct wacom_features wacom_features_0xB8 =
  1210. { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S };
  1211. static const struct wacom_features wacom_features_0xB9 =
  1212. { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 };
  1213. static const struct wacom_features wacom_features_0xBA =
  1214. { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L };
  1215. static const struct wacom_features wacom_features_0xBB =
  1216. { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L };
  1217. static const struct wacom_features wacom_features_0xBC =
  1218. { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047, 63, INTUOS4 };
  1219. static const struct wacom_features wacom_features_0x3F =
  1220. { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ };
  1221. static const struct wacom_features wacom_features_0xC5 =
  1222. { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE };
  1223. static const struct wacom_features wacom_features_0xC6 =
  1224. { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE };
  1225. static const struct wacom_features wacom_features_0xC7 =
  1226. { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL };
  1227. static const struct wacom_features wacom_features_0xCE =
  1228. { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511, 0, DTU };
  1229. static const struct wacom_features wacom_features_0xF0 =
  1230. { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511, 0, DTU };
  1231. static const struct wacom_features wacom_features_0xCC =
  1232. { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047, 63, WACOM_21UX2 };
  1233. static const struct wacom_features wacom_features_0x90 =
  1234. { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
  1235. static const struct wacom_features wacom_features_0x93 =
  1236. { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
  1237. static const struct wacom_features wacom_features_0x9A =
  1238. { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
  1239. static const struct wacom_features wacom_features_0x9F =
  1240. { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC };
  1241. static const struct wacom_features wacom_features_0xE2 =
  1242. { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
  1243. static const struct wacom_features wacom_features_0xE3 =
  1244. { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
  1245. static const struct wacom_features wacom_features_0x47 =
  1246. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
  1247. static struct wacom_features wacom_features_0xD0 =
  1248. { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
  1249. static struct wacom_features wacom_features_0xD1 =
  1250. { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
  1251. static struct wacom_features wacom_features_0xD2 =
  1252. { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
  1253. static struct wacom_features wacom_features_0xD3 =
  1254. { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
  1255. static const struct wacom_features wacom_features_0xD4 =
  1256. { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 255, 63, BAMBOO_PT };
  1257. static struct wacom_features wacom_features_0xD8 =
  1258. { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
  1259. static struct wacom_features wacom_features_0xDA =
  1260. { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
  1261. static struct wacom_features wacom_features_0xDB =
  1262. { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
  1263. static const struct wacom_features wacom_features_0x6004 =
  1264. { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 0, TABLETPC };
  1265. #define USB_DEVICE_WACOM(prod) \
  1266. USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
  1267. .driver_info = (kernel_ulong_t)&wacom_features_##prod
  1268. #define USB_DEVICE_LENOVO(prod) \
  1269. USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
  1270. .driver_info = (kernel_ulong_t)&wacom_features_##prod
  1271. const struct usb_device_id wacom_ids[] = {
  1272. { USB_DEVICE_WACOM(0x00) },
  1273. { USB_DEVICE_WACOM(0x10) },
  1274. { USB_DEVICE_WACOM(0x11) },
  1275. { USB_DEVICE_WACOM(0x12) },
  1276. { USB_DEVICE_WACOM(0x13) },
  1277. { USB_DEVICE_WACOM(0x14) },
  1278. { USB_DEVICE_WACOM(0x15) },
  1279. { USB_DEVICE_WACOM(0x16) },
  1280. { USB_DEVICE_WACOM(0x17) },
  1281. { USB_DEVICE_WACOM(0x18) },
  1282. { USB_DEVICE_WACOM(0x19) },
  1283. { USB_DEVICE_WACOM(0x60) },
  1284. { USB_DEVICE_WACOM(0x61) },
  1285. { USB_DEVICE_WACOM(0x62) },
  1286. { USB_DEVICE_WACOM(0x63) },
  1287. { USB_DEVICE_WACOM(0x64) },
  1288. { USB_DEVICE_WACOM(0x65) },
  1289. { USB_DEVICE_WACOM(0x69) },
  1290. { USB_DEVICE_WACOM(0x20) },
  1291. { USB_DEVICE_WACOM(0x21) },
  1292. { USB_DEVICE_WACOM(0x22) },
  1293. { USB_DEVICE_WACOM(0x23) },
  1294. { USB_DEVICE_WACOM(0x24) },
  1295. { USB_DEVICE_WACOM(0x30) },
  1296. { USB_DEVICE_WACOM(0x31) },
  1297. { USB_DEVICE_WACOM(0x32) },
  1298. { USB_DEVICE_WACOM(0x33) },
  1299. { USB_DEVICE_WACOM(0x34) },
  1300. { USB_DEVICE_WACOM(0x35) },
  1301. { USB_DEVICE_WACOM(0x37) },
  1302. { USB_DEVICE_WACOM(0x38) },
  1303. { USB_DEVICE_WACOM(0x39) },
  1304. { USB_DEVICE_WACOM(0xC4) },
  1305. { USB_DEVICE_WACOM(0xC0) },
  1306. { USB_DEVICE_WACOM(0xC2) },
  1307. { USB_DEVICE_WACOM(0x03) },
  1308. { USB_DEVICE_WACOM(0x41) },
  1309. { USB_DEVICE_WACOM(0x42) },
  1310. { USB_DEVICE_WACOM(0x43) },
  1311. { USB_DEVICE_WACOM(0x44) },
  1312. { USB_DEVICE_WACOM(0x45) },
  1313. { USB_DEVICE_WACOM(0xB0) },
  1314. { USB_DEVICE_WACOM(0xB1) },
  1315. { USB_DEVICE_WACOM(0xB2) },
  1316. { USB_DEVICE_WACOM(0xB3) },
  1317. { USB_DEVICE_WACOM(0xB4) },
  1318. { USB_DEVICE_WACOM(0xB5) },
  1319. { USB_DEVICE_WACOM(0xB7) },
  1320. { USB_DEVICE_WACOM(0xB8) },
  1321. { USB_DEVICE_WACOM(0xB9) },
  1322. { USB_DEVICE_WACOM(0xBA) },
  1323. { USB_DEVICE_WACOM(0xBB) },
  1324. { USB_DEVICE_WACOM(0xBC) },
  1325. { USB_DEVICE_WACOM(0x3F) },
  1326. { USB_DEVICE_WACOM(0xC5) },
  1327. { USB_DEVICE_WACOM(0xC6) },
  1328. { USB_DEVICE_WACOM(0xC7) },
  1329. { USB_DEVICE_WACOM(0xCE) },
  1330. { USB_DEVICE_WACOM(0xD0) },
  1331. { USB_DEVICE_WACOM(0xD1) },
  1332. { USB_DEVICE_WACOM(0xD2) },
  1333. { USB_DEVICE_WACOM(0xD3) },
  1334. { USB_DEVICE_WACOM(0xD4) },
  1335. { USB_DEVICE_WACOM(0xD8) },
  1336. { USB_DEVICE_WACOM(0xDA) },
  1337. { USB_DEVICE_WACOM(0xDB) },
  1338. { USB_DEVICE_WACOM(0xF0) },
  1339. { USB_DEVICE_WACOM(0xCC) },
  1340. { USB_DEVICE_WACOM(0x90) },
  1341. { USB_DEVICE_WACOM(0x93) },
  1342. { USB_DEVICE_WACOM(0x9A) },
  1343. { USB_DEVICE_WACOM(0x9F) },
  1344. { USB_DEVICE_WACOM(0xE2) },
  1345. { USB_DEVICE_WACOM(0xE3) },
  1346. { USB_DEVICE_WACOM(0x47) },
  1347. { USB_DEVICE_LENOVO(0x6004) },
  1348. { }
  1349. };
  1350. MODULE_DEVICE_TABLE(usb, wacom_ids);