wacom_wac.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. * drivers/usb/input/wacom_wac.c
  3. *
  4. * USB Wacom Graphire and Wacom Intuos 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.h"
  14. #include "wacom_wac.h"
  15. static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
  16. {
  17. unsigned char *data = wacom->data;
  18. switch (data[0]) {
  19. case 1:
  20. if (data[5] & 0x80) {
  21. wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  22. wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
  23. wacom_report_key(wcombo, wacom->tool[0], 1);
  24. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
  25. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
  26. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
  27. wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
  28. wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127));
  29. wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
  30. } else {
  31. wacom_report_key(wcombo, wacom->tool[0], 0);
  32. wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */
  33. wacom_report_abs(wcombo, ABS_PRESSURE, -1);
  34. wacom_report_key(wcombo, BTN_TOUCH, 0);
  35. }
  36. break;
  37. case 2:
  38. wacom_report_key(wcombo, BTN_TOOL_PEN, 1);
  39. wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
  40. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
  41. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
  42. wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
  43. wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
  44. wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
  45. break;
  46. default:
  47. printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
  48. return 0;
  49. }
  50. return 1;
  51. }
  52. static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
  53. {
  54. unsigned char *data = wacom->data;
  55. int prox, id, pressure;
  56. if (data[0] != 2) {
  57. dbg("wacom_pl_irq: received unknown report #%d", data[0]);
  58. return 0;
  59. }
  60. prox = data[1] & 0x40;
  61. id = ERASER_DEVICE_ID;
  62. if (prox) {
  63. pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
  64. if (wacom->features->pressure_max > 255)
  65. pressure = (pressure << 1) | ((data[4] >> 6) & 1);
  66. pressure += (wacom->features->pressure_max + 1) / 2;
  67. /*
  68. * if going from out of proximity into proximity select between the eraser
  69. * and the pen based on the state of the stylus2 button, choose eraser if
  70. * pressed else choose pen. if not a proximity change from out to in, send
  71. * an out of proximity for previous tool then a in for new tool.
  72. */
  73. if (!wacom->tool[0]) {
  74. /* Eraser bit set for DTF */
  75. if (data[1] & 0x10)
  76. wacom->tool[1] = BTN_TOOL_RUBBER;
  77. else
  78. /* Going into proximity select tool */
  79. wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  80. } else {
  81. /* was entered with stylus2 pressed */
  82. if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
  83. /* report out proximity for previous tool */
  84. wacom_report_key(wcombo, wacom->tool[1], 0);
  85. wacom_input_sync(wcombo);
  86. wacom->tool[1] = BTN_TOOL_PEN;
  87. return 0;
  88. }
  89. }
  90. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  91. /* Unknown tool selected default to pen tool */
  92. wacom->tool[1] = BTN_TOOL_PEN;
  93. id = STYLUS_DEVICE_ID;
  94. }
  95. wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
  96. wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
  97. wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
  98. wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
  99. wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
  100. wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08);
  101. wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10);
  102. /* Only allow the stylus2 button to be reported for the pen tool. */
  103. wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
  104. } else {
  105. /* report proximity-out of a (valid) tool */
  106. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  107. /* Unknown tool selected default to pen tool */
  108. wacom->tool[1] = BTN_TOOL_PEN;
  109. }
  110. wacom_report_key(wcombo, wacom->tool[1], prox);
  111. }
  112. wacom->tool[0] = prox; /* Save proximity state */
  113. return 1;
  114. }
  115. static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
  116. {
  117. unsigned char *data = wacom->data;
  118. int id;
  119. if (data[0] != 2) {
  120. printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
  121. return 0;
  122. }
  123. if (data[1] & 0x04) {
  124. wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
  125. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
  126. id = ERASER_DEVICE_ID;
  127. } else {
  128. wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
  129. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
  130. id = STYLUS_DEVICE_ID;
  131. }
  132. wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
  133. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
  134. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
  135. wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
  136. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
  137. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
  138. return 1;
  139. }
  140. static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
  141. {
  142. unsigned char *data = wacom->data;
  143. int x, y, id, rw;
  144. if (data[0] != 2) {
  145. dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
  146. return 0;
  147. }
  148. id = STYLUS_DEVICE_ID;
  149. if (data[1] & 0x10) { /* in prox */
  150. switch ((data[1] >> 5) & 3) {
  151. case 0: /* Pen */
  152. wacom->tool[0] = BTN_TOOL_PEN;
  153. break;
  154. case 1: /* Rubber */
  155. wacom->tool[0] = BTN_TOOL_RUBBER;
  156. id = ERASER_DEVICE_ID;
  157. break;
  158. case 2: /* Mouse with wheel */
  159. wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
  160. if (wacom->features->type == WACOM_G4) {
  161. rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
  162. wacom_report_rel(wcombo, REL_WHEEL, -rw);
  163. } else
  164. wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
  165. /* fall through */
  166. case 3: /* Mouse without wheel */
  167. wacom->tool[0] = BTN_TOOL_MOUSE;
  168. id = CURSOR_DEVICE_ID;
  169. wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
  170. wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
  171. if (wacom->features->type == WACOM_G4)
  172. wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
  173. else
  174. wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
  175. break;
  176. }
  177. }
  178. if (data[1] & 0x90) {
  179. x = wacom_le16_to_cpu(&data[2]);
  180. y = wacom_le16_to_cpu(&data[4]);
  181. wacom_report_abs(wcombo, ABS_X, x);
  182. wacom_report_abs(wcombo, ABS_Y, y);
  183. if (wacom->tool[0] != BTN_TOOL_MOUSE) {
  184. wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
  185. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
  186. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
  187. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
  188. }
  189. }
  190. if (data[1] & 0x10)
  191. wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
  192. else
  193. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  194. wacom_report_key(wcombo, wacom->tool[0], data[1] & 0x10);
  195. wacom_input_sync(wcombo);
  196. /* send pad data */
  197. if (wacom->features->type == WACOM_G4) {
  198. if ( (wacom->serial[1] & 0xc0) != (data[7] & 0xf8) ) {
  199. wacom->id[1] = 1;
  200. wacom->serial[1] = (data[7] & 0xf8);
  201. wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
  202. wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
  203. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  204. wacom_report_rel(wcombo, REL_WHEEL, rw);
  205. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
  206. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  207. } else if (wacom->id[1]) {
  208. wacom->id[1] = 0;
  209. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
  210. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  211. }
  212. }
  213. return 1;
  214. }
  215. static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
  216. {
  217. unsigned char *data = wacom->data;
  218. int idx;
  219. /* tool number */
  220. idx = data[1] & 0x01;
  221. /* Enter report */
  222. if ((data[1] & 0xfc) == 0xc0) {
  223. /* serial number of the tool */
  224. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  225. (data[4] << 20) + (data[5] << 12) +
  226. (data[6] << 4) + (data[7] >> 4);
  227. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
  228. switch (wacom->id[idx]) {
  229. case 0x812: /* Inking pen */
  230. case 0x801: /* Intuos3 Inking pen */
  231. case 0x012:
  232. wacom->tool[idx] = BTN_TOOL_PENCIL;
  233. break;
  234. case 0x822: /* Pen */
  235. case 0x842:
  236. case 0x852:
  237. case 0x823: /* Intuos3 Grip Pen */
  238. case 0x813: /* Intuos3 Classic Pen */
  239. case 0x885: /* Intuos3 Marker Pen */
  240. case 0x022:
  241. wacom->tool[idx] = BTN_TOOL_PEN;
  242. break;
  243. case 0x832: /* Stroke pen */
  244. case 0x032:
  245. wacom->tool[idx] = BTN_TOOL_BRUSH;
  246. break;
  247. case 0x007: /* Mouse 4D and 2D */
  248. case 0x09c:
  249. case 0x094:
  250. case 0x017: /* Intuos3 2D Mouse */
  251. wacom->tool[idx] = BTN_TOOL_MOUSE;
  252. break;
  253. case 0x096: /* Lens cursor */
  254. case 0x097: /* Intuos3 Lens cursor */
  255. wacom->tool[idx] = BTN_TOOL_LENS;
  256. break;
  257. case 0x82a: /* Eraser */
  258. case 0x85a:
  259. case 0x91a:
  260. case 0xd1a:
  261. case 0x0fa:
  262. case 0x82b: /* Intuos3 Grip Pen Eraser */
  263. case 0x81b: /* Intuos3 Classic Pen Eraser */
  264. case 0x91b: /* Intuos3 Airbrush Eraser */
  265. wacom->tool[idx] = BTN_TOOL_RUBBER;
  266. break;
  267. case 0xd12:
  268. case 0x912:
  269. case 0x112:
  270. case 0x913: /* Intuos3 Airbrush */
  271. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  272. break;
  273. default: /* Unknown tool */
  274. wacom->tool[idx] = BTN_TOOL_PEN;
  275. }
  276. /* only large I3 support Lens Cursor */
  277. if(!((wacom->tool[idx] == BTN_TOOL_LENS)
  278. && ((wacom->features->type == INTUOS3)
  279. || (wacom->features->type == INTUOS3S)))) {
  280. wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
  281. wacom_report_key(wcombo, wacom->tool[idx], 1);
  282. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  283. return 2;
  284. }
  285. return 1;
  286. }
  287. /* Exit report */
  288. if ((data[1] & 0xfe) == 0x80) {
  289. if(!((wacom->tool[idx] == BTN_TOOL_LENS)
  290. && ((wacom->features->type == INTUOS3)
  291. || (wacom->features->type == INTUOS3S)))) {
  292. wacom_report_key(wcombo, wacom->tool[idx], 0);
  293. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  294. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  295. return 2;
  296. }
  297. }
  298. return 0;
  299. }
  300. static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
  301. {
  302. unsigned char *data = wacom->data;
  303. unsigned int t;
  304. /* general pen packet */
  305. if ((data[1] & 0xb8) == 0xa0) {
  306. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  307. wacom_report_abs(wcombo, ABS_PRESSURE, t);
  308. wacom_report_abs(wcombo, ABS_TILT_X,
  309. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  310. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  311. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
  312. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
  313. wacom_report_key(wcombo, BTN_TOUCH, t > 10);
  314. }
  315. /* airbrush second packet */
  316. if ((data[1] & 0xbc) == 0xb4) {
  317. wacom_report_abs(wcombo, ABS_WHEEL,
  318. (data[6] << 2) | ((data[7] >> 6) & 3));
  319. wacom_report_abs(wcombo, ABS_TILT_X,
  320. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  321. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  322. }
  323. return;
  324. }
  325. static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
  326. {
  327. unsigned char *data = wacom->data;
  328. unsigned int t;
  329. int idx, result;
  330. if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
  331. dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
  332. return 0;
  333. }
  334. /* tool number */
  335. idx = data[1] & 0x01;
  336. /* pad packets. Works as a second tool and is always in prox */
  337. if (data[0] == 12) {
  338. /* initiate the pad as a device */
  339. if (wacom->tool[1] != BTN_TOOL_FINGER)
  340. wacom->tool[1] = BTN_TOOL_FINGER;
  341. wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
  342. wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
  343. wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
  344. wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
  345. wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
  346. wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
  347. wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
  348. wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
  349. wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  350. wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  351. if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
  352. data[2] | (data[3] & 0x1f) | data[4])
  353. wacom_report_key(wcombo, wacom->tool[1], 1);
  354. else
  355. wacom_report_key(wcombo, wacom->tool[1], 0);
  356. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
  357. return 1;
  358. }
  359. /* process in/out prox events */
  360. result = wacom_intuos_inout(wacom, wcombo);
  361. if (result)
  362. return result-1;
  363. /* Cintiq doesn't send data when RDY bit isn't set */
  364. if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
  365. return 0;
  366. if (wacom->features->type >= INTUOS3) {
  367. wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  368. wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  369. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  370. } else {
  371. wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
  372. wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
  373. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  374. }
  375. /* process general packets */
  376. wacom_intuos_general(wacom, wcombo);
  377. /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
  378. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
  379. if (data[1] & 0x02) {
  380. /* Rotation packet */
  381. if (wacom->features->type >= INTUOS3) {
  382. /* I3 marker pen rotation reported as wheel
  383. * due to valuator limitation
  384. */
  385. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  386. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  387. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  388. wacom_report_abs(wcombo, ABS_WHEEL, t);
  389. } else {
  390. /* 4D mouse rotation packet */
  391. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  392. wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
  393. ((t - 1) / 2) : -t / 2);
  394. }
  395. } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
  396. /* 4D mouse packet */
  397. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  398. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  399. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  400. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
  401. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
  402. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  403. wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  404. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  405. /* 2D mouse packet */
  406. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
  407. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
  408. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
  409. wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
  410. - ((data[8] & 0x02) >> 1));
  411. /* I3 2D mouse side buttons */
  412. if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
  413. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
  414. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
  415. }
  416. } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
  417. /* Lens cursor packets */
  418. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  419. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  420. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  421. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
  422. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
  423. }
  424. }
  425. wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
  426. wacom_report_key(wcombo, wacom->tool[idx], 1);
  427. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  428. return 1;
  429. }
  430. int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
  431. {
  432. switch (wacom_wac->features->type) {
  433. case PENPARTNER:
  434. return (wacom_penpartner_irq(wacom_wac, wcombo));
  435. break;
  436. case PL:
  437. return (wacom_pl_irq(wacom_wac, wcombo));
  438. break;
  439. case WACOM_G4:
  440. case GRAPHIRE:
  441. return (wacom_graphire_irq(wacom_wac, wcombo));
  442. break;
  443. case PTU:
  444. return (wacom_ptu_irq(wacom_wac, wcombo));
  445. break;
  446. case INTUOS:
  447. case INTUOS3S:
  448. case INTUOS3:
  449. case INTUOS3L:
  450. case CINTIQ:
  451. return (wacom_intuos_irq(wacom_wac, wcombo));
  452. break;
  453. default:
  454. return 0;
  455. }
  456. return 0;
  457. }
  458. void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
  459. {
  460. switch (wacom_wac->features->type) {
  461. case WACOM_G4:
  462. input_dev_g4(input_dev, wacom_wac);
  463. /* fall through */
  464. case GRAPHIRE:
  465. input_dev_g(input_dev, wacom_wac);
  466. break;
  467. case INTUOS3:
  468. case INTUOS3L:
  469. case CINTIQ:
  470. input_dev_i3(input_dev, wacom_wac);
  471. /* fall through */
  472. case INTUOS3S:
  473. input_dev_i3s(input_dev, wacom_wac);
  474. case INTUOS:
  475. input_dev_i(input_dev, wacom_wac);
  476. break;
  477. case PL:
  478. case PTU:
  479. input_dev_pl(input_dev, wacom_wac);
  480. break;
  481. case PENPARTNER:
  482. input_dev_pt(input_dev, wacom_wac);
  483. break;
  484. }
  485. return;
  486. }
  487. static struct wacom_features wacom_features[] = {
  488. { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
  489. { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
  490. { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
  491. { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
  492. { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
  493. { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
  494. { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
  495. { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
  496. { "Wacom Volito", 8, 5104, 3712, 511, 0, GRAPHIRE },
  497. { "Wacom PenStation2", 8, 3250, 2320, 255, 0, GRAPHIRE },
  498. { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 0, GRAPHIRE },
  499. { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 0, GRAPHIRE },
  500. { "Wacom PenPartner2", 8, 3250, 2320, 255, 0, GRAPHIRE },
  501. { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
  502. { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  503. { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
  504. { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
  505. { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
  506. { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
  507. { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
  508. { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
  509. { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
  510. { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
  511. { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
  512. { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
  513. { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
  514. { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
  515. { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
  516. { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
  517. { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
  518. { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
  519. { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  520. { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
  521. { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
  522. { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
  523. { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
  524. { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
  525. { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
  526. { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
  527. { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
  528. { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
  529. { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 15, INTUOS3S },
  530. { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
  531. { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  532. { }
  533. };
  534. static struct usb_device_id wacom_ids[] = {
  535. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
  536. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
  537. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
  538. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
  539. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
  540. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
  541. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
  542. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
  543. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
  544. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
  545. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
  546. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
  547. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
  548. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
  549. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
  550. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
  551. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
  552. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
  553. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
  554. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
  555. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
  556. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
  557. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
  558. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
  559. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
  560. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
  561. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
  562. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
  563. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
  564. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
  565. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
  566. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
  567. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
  568. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
  569. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
  570. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
  571. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
  572. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
  573. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
  574. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
  575. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
  576. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
  577. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
  578. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
  579. { }
  580. };
  581. const struct usb_device_id * get_device_table(void) {
  582. const struct usb_device_id * id_table = wacom_ids;
  583. return id_table;
  584. }
  585. struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
  586. int index = id - wacom_ids;
  587. struct wacom_features *wf = &wacom_features[index];
  588. return wf;
  589. }
  590. MODULE_DEVICE_TABLE(usb, wacom_ids);