wacom_wac.c 45 KB

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