wacom_wac.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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. wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
  190. }
  191. else
  192. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  193. if (data[1] & 0x10) /* only report prox-in when in area */
  194. wacom_report_key(wcombo, wacom->tool[0], 1);
  195. if (!(data[1] & 0x90)) /* report prox-out when physically out */
  196. wacom_report_key(wcombo, wacom->tool[0], 0);
  197. wacom_input_sync(wcombo);
  198. /* send pad data */
  199. if (wacom->features->type == WACOM_G4) {
  200. if ( (wacom->serial[1] & 0xc0) != (data[7] & 0xf8) ) {
  201. wacom->id[1] = 1;
  202. wacom->serial[1] = (data[7] & 0xf8);
  203. wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
  204. wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
  205. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  206. wacom_report_rel(wcombo, REL_WHEEL, rw);
  207. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
  208. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  209. } else if (wacom->id[1]) {
  210. wacom->id[1] = 0;
  211. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
  212. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  213. }
  214. }
  215. return 1;
  216. }
  217. static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
  218. {
  219. unsigned char *data = wacom->data;
  220. int idx;
  221. /* tool number */
  222. idx = data[1] & 0x01;
  223. /* Enter report */
  224. if ((data[1] & 0xfc) == 0xc0) {
  225. /* serial number of the tool */
  226. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  227. (data[4] << 20) + (data[5] << 12) +
  228. (data[6] << 4) + (data[7] >> 4);
  229. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
  230. switch (wacom->id[idx]) {
  231. case 0x812: /* Inking pen */
  232. case 0x801: /* Intuos3 Inking pen */
  233. case 0x012:
  234. wacom->tool[idx] = BTN_TOOL_PENCIL;
  235. break;
  236. case 0x822: /* Pen */
  237. case 0x842:
  238. case 0x852:
  239. case 0x823: /* Intuos3 Grip Pen */
  240. case 0x813: /* Intuos3 Classic Pen */
  241. case 0x885: /* Intuos3 Marker Pen */
  242. case 0x022:
  243. wacom->tool[idx] = BTN_TOOL_PEN;
  244. break;
  245. case 0x832: /* Stroke pen */
  246. case 0x032:
  247. wacom->tool[idx] = BTN_TOOL_BRUSH;
  248. break;
  249. case 0x007: /* Mouse 4D and 2D */
  250. case 0x09c:
  251. case 0x094:
  252. case 0x017: /* Intuos3 2D Mouse */
  253. wacom->tool[idx] = BTN_TOOL_MOUSE;
  254. break;
  255. case 0x096: /* Lens cursor */
  256. case 0x097: /* Intuos3 Lens cursor */
  257. wacom->tool[idx] = BTN_TOOL_LENS;
  258. break;
  259. case 0x82a: /* Eraser */
  260. case 0x85a:
  261. case 0x91a:
  262. case 0xd1a:
  263. case 0x0fa:
  264. case 0x82b: /* Intuos3 Grip Pen Eraser */
  265. case 0x81b: /* Intuos3 Classic Pen Eraser */
  266. case 0x91b: /* Intuos3 Airbrush Eraser */
  267. wacom->tool[idx] = BTN_TOOL_RUBBER;
  268. break;
  269. case 0xd12:
  270. case 0x912:
  271. case 0x112:
  272. case 0x913: /* Intuos3 Airbrush */
  273. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  274. break;
  275. default: /* Unknown tool */
  276. wacom->tool[idx] = BTN_TOOL_PEN;
  277. }
  278. /* only large I3 support Lens Cursor */
  279. if(!((wacom->tool[idx] == BTN_TOOL_LENS)
  280. && ((wacom->features->type == INTUOS3)
  281. || (wacom->features->type == INTUOS3S)))) {
  282. wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
  283. wacom_report_key(wcombo, wacom->tool[idx], 1);
  284. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  285. return 2;
  286. }
  287. return 1;
  288. }
  289. /* Exit report */
  290. if ((data[1] & 0xfe) == 0x80) {
  291. if(!((wacom->tool[idx] == BTN_TOOL_LENS)
  292. && ((wacom->features->type == INTUOS3)
  293. || (wacom->features->type == INTUOS3S)))) {
  294. wacom_report_key(wcombo, wacom->tool[idx], 0);
  295. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  296. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  297. return 2;
  298. }
  299. }
  300. return 0;
  301. }
  302. static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
  303. {
  304. unsigned char *data = wacom->data;
  305. unsigned int t;
  306. /* general pen packet */
  307. if ((data[1] & 0xb8) == 0xa0) {
  308. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  309. wacom_report_abs(wcombo, ABS_PRESSURE, t);
  310. wacom_report_abs(wcombo, ABS_TILT_X,
  311. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  312. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  313. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
  314. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
  315. wacom_report_key(wcombo, BTN_TOUCH, t > 10);
  316. }
  317. /* airbrush second packet */
  318. if ((data[1] & 0xbc) == 0xb4) {
  319. wacom_report_abs(wcombo, ABS_WHEEL,
  320. (data[6] << 2) | ((data[7] >> 6) & 3));
  321. wacom_report_abs(wcombo, ABS_TILT_X,
  322. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  323. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  324. }
  325. return;
  326. }
  327. static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
  328. {
  329. unsigned char *data = wacom->data;
  330. unsigned int t;
  331. int idx, result;
  332. if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
  333. dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
  334. return 0;
  335. }
  336. /* tool number */
  337. idx = data[1] & 0x01;
  338. /* pad packets. Works as a second tool and is always in prox */
  339. if (data[0] == 12) {
  340. /* initiate the pad as a device */
  341. if (wacom->tool[1] != BTN_TOOL_FINGER)
  342. wacom->tool[1] = BTN_TOOL_FINGER;
  343. wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
  344. wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
  345. wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
  346. wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
  347. wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
  348. wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
  349. wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
  350. wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
  351. wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  352. wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  353. if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
  354. data[2] | (data[3] & 0x1f) | data[4])
  355. wacom_report_key(wcombo, wacom->tool[1], 1);
  356. else
  357. wacom_report_key(wcombo, wacom->tool[1], 0);
  358. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
  359. return 1;
  360. }
  361. /* process in/out prox events */
  362. result = wacom_intuos_inout(wacom, wcombo);
  363. if (result)
  364. return result-1;
  365. /* Cintiq doesn't send data when RDY bit isn't set */
  366. if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
  367. return 0;
  368. if (wacom->features->type >= INTUOS3S) {
  369. wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  370. wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  371. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  372. } else {
  373. wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
  374. wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
  375. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  376. }
  377. /* process general packets */
  378. wacom_intuos_general(wacom, wcombo);
  379. /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
  380. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
  381. if (data[1] & 0x02) {
  382. /* Rotation packet */
  383. if (wacom->features->type >= INTUOS3S) {
  384. /* I3 marker pen rotation reported as wheel
  385. * due to valuator limitation
  386. */
  387. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  388. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  389. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  390. wacom_report_abs(wcombo, ABS_WHEEL, t);
  391. } else {
  392. /* 4D mouse rotation packet */
  393. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  394. wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
  395. ((t - 1) / 2) : -t / 2);
  396. }
  397. } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
  398. /* 4D mouse packet */
  399. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  400. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  401. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  402. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
  403. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
  404. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  405. wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  406. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  407. /* 2D mouse packet */
  408. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
  409. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
  410. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
  411. wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
  412. - ((data[8] & 0x02) >> 1));
  413. /* I3 2D mouse side buttons */
  414. if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
  415. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
  416. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
  417. }
  418. } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
  419. /* Lens cursor packets */
  420. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  421. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  422. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  423. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
  424. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
  425. }
  426. }
  427. wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
  428. wacom_report_key(wcombo, wacom->tool[idx], 1);
  429. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  430. return 1;
  431. }
  432. int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
  433. {
  434. switch (wacom_wac->features->type) {
  435. case PENPARTNER:
  436. return (wacom_penpartner_irq(wacom_wac, wcombo));
  437. break;
  438. case PL:
  439. return (wacom_pl_irq(wacom_wac, wcombo));
  440. break;
  441. case WACOM_G4:
  442. case GRAPHIRE:
  443. return (wacom_graphire_irq(wacom_wac, wcombo));
  444. break;
  445. case PTU:
  446. return (wacom_ptu_irq(wacom_wac, wcombo));
  447. break;
  448. case INTUOS:
  449. case INTUOS3S:
  450. case INTUOS3:
  451. case INTUOS3L:
  452. case CINTIQ:
  453. return (wacom_intuos_irq(wacom_wac, wcombo));
  454. break;
  455. default:
  456. return 0;
  457. }
  458. return 0;
  459. }
  460. void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
  461. {
  462. switch (wacom_wac->features->type) {
  463. case WACOM_G4:
  464. input_dev_g4(input_dev, wacom_wac);
  465. /* fall through */
  466. case GRAPHIRE:
  467. input_dev_g(input_dev, wacom_wac);
  468. break;
  469. case INTUOS3:
  470. case INTUOS3L:
  471. case CINTIQ:
  472. input_dev_i3(input_dev, wacom_wac);
  473. /* fall through */
  474. case INTUOS3S:
  475. input_dev_i3s(input_dev, wacom_wac);
  476. case INTUOS:
  477. input_dev_i(input_dev, wacom_wac);
  478. break;
  479. case PL:
  480. case PTU:
  481. input_dev_pl(input_dev, wacom_wac);
  482. break;
  483. case PENPARTNER:
  484. input_dev_pt(input_dev, wacom_wac);
  485. break;
  486. }
  487. return;
  488. }
  489. static struct wacom_features wacom_features[] = {
  490. { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
  491. { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
  492. { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
  493. { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
  494. { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
  495. { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
  496. { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
  497. { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
  498. { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
  499. { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
  500. { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
  501. { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE },
  502. { "Wacom PenPartner2", 8, 3250, 2320, 255, 63, GRAPHIRE },
  503. { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
  504. { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  505. { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
  506. { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
  507. { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
  508. { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
  509. { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
  510. { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
  511. { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
  512. { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
  513. { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
  514. { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
  515. { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
  516. { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
  517. { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
  518. { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
  519. { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
  520. { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
  521. { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  522. { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
  523. { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
  524. { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
  525. { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
  526. { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
  527. { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
  528. { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
  529. { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
  530. { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
  531. { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
  532. { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
  533. { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
  534. { }
  535. };
  536. static struct usb_device_id wacom_ids[] = {
  537. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
  538. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
  539. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
  540. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
  541. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
  542. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
  543. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
  544. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
  545. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
  546. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
  547. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
  548. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
  549. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
  550. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
  551. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
  552. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
  553. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
  554. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
  555. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
  556. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
  557. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
  558. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
  559. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
  560. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
  561. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
  562. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
  563. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
  564. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
  565. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
  566. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
  567. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
  568. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
  569. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
  570. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
  571. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
  572. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
  573. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
  574. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
  575. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
  576. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
  577. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
  578. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
  579. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
  580. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
  581. { }
  582. };
  583. const struct usb_device_id * get_device_table(void) {
  584. const struct usb_device_id * id_table = wacom_ids;
  585. return id_table;
  586. }
  587. struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
  588. int index = id - wacom_ids;
  589. struct wacom_features *wf = &wacom_features[index];
  590. return wf;
  591. }
  592. MODULE_DEVICE_TABLE(usb, wacom_ids);