wacom_wac.c 52 KB

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