wacom_wac.c 41 KB

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