wacom_wac.c 52 KB

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