wacom_wac.c 54 KB

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