wacom_wac.c 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  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.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, 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. if (prox) {
  62. wacom->id[0] = ERASER_DEVICE_ID;
  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. wacom->id[0] = 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, wacom->id[0]); /* 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. if (data[0] != 2) {
  119. printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
  120. return 0;
  121. }
  122. if (data[1] & 0x04) {
  123. wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
  124. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
  125. wacom->id[0] = ERASER_DEVICE_ID;
  126. } else {
  127. wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
  128. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
  129. wacom->id[0] = STYLUS_DEVICE_ID;
  130. }
  131. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
  132. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
  133. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
  134. wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
  135. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
  136. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
  137. return 1;
  138. }
  139. static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
  140. {
  141. unsigned char *data = wacom->data;
  142. int x, y, rw;
  143. if (data[0] != 2) {
  144. dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
  145. return 0;
  146. }
  147. if (data[1] & 0x80) {
  148. /* in prox and not a pad data */
  149. switch ((data[1] >> 5) & 3) {
  150. case 0: /* Pen */
  151. wacom->tool[0] = BTN_TOOL_PEN;
  152. wacom->id[0] = STYLUS_DEVICE_ID;
  153. break;
  154. case 1: /* Rubber */
  155. wacom->tool[0] = BTN_TOOL_RUBBER;
  156. wacom->id[0] = 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. wacom->features->type == WACOM_MO) {
  162. rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
  163. wacom_report_rel(wcombo, REL_WHEEL, -rw);
  164. } else
  165. wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
  166. /* fall through */
  167. case 3: /* Mouse without wheel */
  168. wacom->tool[0] = BTN_TOOL_MOUSE;
  169. wacom->id[0] = CURSOR_DEVICE_ID;
  170. wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
  171. wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
  172. if (wacom->features->type == WACOM_G4 ||
  173. wacom->features->type == WACOM_MO)
  174. wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
  175. else
  176. wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
  177. break;
  178. }
  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, wacom->id[0]); /* report tool id */
  190. wacom_report_key(wcombo, wacom->tool[0], 1);
  191. } else if (wacom->id[0]) {
  192. wacom_report_abs(wcombo, ABS_X, 0);
  193. wacom_report_abs(wcombo, ABS_Y, 0);
  194. if (wacom->tool[0] == BTN_TOOL_MOUSE) {
  195. wacom_report_key(wcombo, BTN_LEFT, 0);
  196. wacom_report_key(wcombo, BTN_RIGHT, 0);
  197. wacom_report_abs(wcombo, ABS_DISTANCE, 0);
  198. } else {
  199. wacom_report_abs(wcombo, ABS_PRESSURE, 0);
  200. wacom_report_key(wcombo, BTN_TOUCH, 0);
  201. wacom_report_key(wcombo, BTN_STYLUS, 0);
  202. wacom_report_key(wcombo, BTN_STYLUS2, 0);
  203. }
  204. wacom->id[0] = 0;
  205. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  206. wacom_report_key(wcombo, wacom->tool[0], 0);
  207. }
  208. /* send pad data */
  209. switch (wacom->features->type) {
  210. case WACOM_G4:
  211. if (data[7] & 0xf8) {
  212. wacom_input_sync(wcombo); /* sync last event */
  213. wacom->id[1] = PAD_DEVICE_ID;
  214. wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
  215. wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
  216. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  217. wacom_report_rel(wcombo, REL_WHEEL, rw);
  218. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
  219. wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
  220. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  221. } else if (wacom->id[1]) {
  222. wacom_input_sync(wcombo); /* sync last event */
  223. wacom->id[1] = 0;
  224. wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
  225. wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
  226. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
  227. wacom_report_abs(wcombo, ABS_MISC, 0);
  228. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  229. }
  230. break;
  231. case WACOM_MO:
  232. if ((data[7] & 0xf8) || (data[8] & 0xff)) {
  233. wacom_input_sync(wcombo); /* sync last event */
  234. wacom->id[1] = PAD_DEVICE_ID;
  235. wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
  236. wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
  237. wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
  238. wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
  239. wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
  240. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
  241. wacom_report_abs(wcombo, ABS_MISC, wacom->id[1]);
  242. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  243. } else if (wacom->id[1]) {
  244. wacom_input_sync(wcombo); /* sync last event */
  245. wacom->id[1] = 0;
  246. wacom_report_key(wcombo, BTN_0, (data[7] & 0x08));
  247. wacom_report_key(wcombo, BTN_1, (data[7] & 0x20));
  248. wacom_report_key(wcombo, BTN_4, (data[7] & 0x10));
  249. wacom_report_key(wcombo, BTN_5, (data[7] & 0x40));
  250. wacom_report_abs(wcombo, ABS_WHEEL, (data[8] & 0x7f));
  251. wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
  252. wacom_report_abs(wcombo, ABS_MISC, 0);
  253. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  254. }
  255. break;
  256. }
  257. return 1;
  258. }
  259. static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
  260. {
  261. unsigned char *data = wacom->data;
  262. int idx = 0;
  263. /* tool number */
  264. if (wacom->features->type == INTUOS)
  265. idx = data[1] & 0x01;
  266. /* Enter report */
  267. if ((data[1] & 0xfc) == 0xc0) {
  268. /* serial number of the tool */
  269. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  270. (data[4] << 20) + (data[5] << 12) +
  271. (data[6] << 4) + (data[7] >> 4);
  272. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
  273. switch (wacom->id[idx]) {
  274. case 0x812: /* Inking pen */
  275. case 0x801: /* Intuos3 Inking pen */
  276. case 0x20802: /* Intuos4 Classic Pen */
  277. case 0x012:
  278. wacom->tool[idx] = BTN_TOOL_PENCIL;
  279. break;
  280. case 0x822: /* Pen */
  281. case 0x842:
  282. case 0x852:
  283. case 0x823: /* Intuos3 Grip Pen */
  284. case 0x813: /* Intuos3 Classic Pen */
  285. case 0x885: /* Intuos3 Marker Pen */
  286. case 0x802: /* Intuos4 Grip Pen Eraser */
  287. case 0x804: /* Intuos4 Marker Pen */
  288. case 0x40802: /* Intuos4 Classic Pen */
  289. case 0x022:
  290. wacom->tool[idx] = BTN_TOOL_PEN;
  291. break;
  292. case 0x832: /* Stroke pen */
  293. case 0x032:
  294. wacom->tool[idx] = BTN_TOOL_BRUSH;
  295. break;
  296. case 0x007: /* Mouse 4D and 2D */
  297. case 0x09c:
  298. case 0x094:
  299. case 0x017: /* Intuos3 2D Mouse */
  300. case 0x806: /* Intuos4 Mouse */
  301. wacom->tool[idx] = BTN_TOOL_MOUSE;
  302. break;
  303. case 0x096: /* Lens cursor */
  304. case 0x097: /* Intuos3 Lens cursor */
  305. case 0x006: /* Intuos4 Lens cursor */
  306. wacom->tool[idx] = BTN_TOOL_LENS;
  307. break;
  308. case 0x82a: /* Eraser */
  309. case 0x85a:
  310. case 0x91a:
  311. case 0xd1a:
  312. case 0x0fa:
  313. case 0x82b: /* Intuos3 Grip Pen Eraser */
  314. case 0x81b: /* Intuos3 Classic Pen Eraser */
  315. case 0x91b: /* Intuos3 Airbrush Eraser */
  316. case 0x80c: /* Intuos4 Marker Pen Eraser */
  317. case 0x80a: /* Intuos4 Grip Pen Eraser */
  318. case 0x4080a: /* Intuos4 Classic Pen Eraser */
  319. case 0x90a: /* Intuos4 Airbrush Eraser */
  320. wacom->tool[idx] = BTN_TOOL_RUBBER;
  321. break;
  322. case 0xd12:
  323. case 0x912:
  324. case 0x112:
  325. case 0x913: /* Intuos3 Airbrush */
  326. case 0x902: /* Intuos4 Airbrush */
  327. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  328. break;
  329. default: /* Unknown tool */
  330. wacom->tool[idx] = BTN_TOOL_PEN;
  331. }
  332. return 1;
  333. }
  334. /* Exit report */
  335. if ((data[1] & 0xfe) == 0x80) {
  336. /*
  337. * Reset all states otherwise we lose the initial states
  338. * when in-prox next time
  339. */
  340. wacom_report_abs(wcombo, ABS_X, 0);
  341. wacom_report_abs(wcombo, ABS_Y, 0);
  342. wacom_report_abs(wcombo, ABS_DISTANCE, 0);
  343. wacom_report_abs(wcombo, ABS_TILT_X, 0);
  344. wacom_report_abs(wcombo, ABS_TILT_Y, 0);
  345. if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
  346. wacom_report_key(wcombo, BTN_LEFT, 0);
  347. wacom_report_key(wcombo, BTN_MIDDLE, 0);
  348. wacom_report_key(wcombo, BTN_RIGHT, 0);
  349. wacom_report_key(wcombo, BTN_SIDE, 0);
  350. wacom_report_key(wcombo, BTN_EXTRA, 0);
  351. wacom_report_abs(wcombo, ABS_THROTTLE, 0);
  352. wacom_report_abs(wcombo, ABS_RZ, 0);
  353. } else {
  354. wacom_report_abs(wcombo, ABS_PRESSURE, 0);
  355. wacom_report_key(wcombo, BTN_STYLUS, 0);
  356. wacom_report_key(wcombo, BTN_STYLUS2, 0);
  357. wacom_report_key(wcombo, BTN_TOUCH, 0);
  358. wacom_report_abs(wcombo, ABS_WHEEL, 0);
  359. if (wacom->features->type >= INTUOS3S)
  360. wacom_report_abs(wcombo, ABS_Z, 0);
  361. }
  362. wacom_report_key(wcombo, wacom->tool[idx], 0);
  363. wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
  364. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  365. wacom->id[idx] = 0;
  366. return 2;
  367. }
  368. return 0;
  369. }
  370. static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
  371. {
  372. unsigned char *data = wacom->data;
  373. unsigned int t;
  374. /* general pen packet */
  375. if ((data[1] & 0xb8) == 0xa0) {
  376. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  377. if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L)
  378. t = (t << 1) | (data[1] & 1);
  379. wacom_report_abs(wcombo, ABS_PRESSURE, t);
  380. wacom_report_abs(wcombo, ABS_TILT_X,
  381. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  382. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  383. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
  384. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
  385. wacom_report_key(wcombo, BTN_TOUCH, t > 10);
  386. }
  387. /* airbrush second packet */
  388. if ((data[1] & 0xbc) == 0xb4) {
  389. wacom_report_abs(wcombo, ABS_WHEEL,
  390. (data[6] << 2) | ((data[7] >> 6) & 3));
  391. wacom_report_abs(wcombo, ABS_TILT_X,
  392. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  393. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  394. }
  395. return;
  396. }
  397. static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
  398. {
  399. unsigned char *data = wacom->data;
  400. unsigned int t;
  401. int idx = 0, result;
  402. if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
  403. dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
  404. return 0;
  405. }
  406. /* tool number */
  407. if (wacom->features->type == INTUOS)
  408. idx = data[1] & 0x01;
  409. /* pad packets. Works as a second tool and is always in prox */
  410. if (data[0] == 12) {
  411. /* initiate the pad as a device */
  412. if (wacom->tool[1] != BTN_TOOL_FINGER)
  413. wacom->tool[1] = BTN_TOOL_FINGER;
  414. if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
  415. wacom_report_key(wcombo, BTN_0, (data[2] & 0x01));
  416. wacom_report_key(wcombo, BTN_1, (data[3] & 0x01));
  417. wacom_report_key(wcombo, BTN_2, (data[3] & 0x02));
  418. wacom_report_key(wcombo, BTN_3, (data[3] & 0x04));
  419. wacom_report_key(wcombo, BTN_4, (data[3] & 0x08));
  420. wacom_report_key(wcombo, BTN_5, (data[3] & 0x10));
  421. wacom_report_key(wcombo, BTN_6, (data[3] & 0x20));
  422. if (data[1] & 0x80) {
  423. wacom_report_abs(wcombo, ABS_WHEEL, (data[1] & 0x7f));
  424. } else {
  425. /* Out of proximity, clear wheel value. */
  426. wacom_report_abs(wcombo, ABS_WHEEL, 0);
  427. }
  428. if (wacom->features->type != INTUOS4S) {
  429. wacom_report_key(wcombo, BTN_7, (data[3] & 0x40));
  430. wacom_report_key(wcombo, BTN_8, (data[3] & 0x80));
  431. }
  432. if (data[1] | (data[2] & 0x01) | data[3]) {
  433. wacom_report_key(wcombo, wacom->tool[1], 1);
  434. wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
  435. } else {
  436. wacom_report_key(wcombo, wacom->tool[1], 0);
  437. wacom_report_abs(wcombo, ABS_MISC, 0);
  438. }
  439. } else {
  440. wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
  441. wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
  442. wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
  443. wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
  444. wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
  445. wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
  446. wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
  447. wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
  448. wacom_report_key(wcombo, BTN_8, (data[5] & 0x10));
  449. wacom_report_key(wcombo, BTN_9, (data[6] & 0x10));
  450. wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  451. wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  452. if ((data[5] & 0x1f) | (data[6] & 0x1f) | (data[1] & 0x1f) |
  453. data[2] | (data[3] & 0x1f) | data[4]) {
  454. wacom_report_key(wcombo, wacom->tool[1], 1);
  455. wacom_report_abs(wcombo, ABS_MISC, PAD_DEVICE_ID);
  456. } else {
  457. wacom_report_key(wcombo, wacom->tool[1], 0);
  458. wacom_report_abs(wcombo, ABS_MISC, 0);
  459. }
  460. }
  461. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
  462. return 1;
  463. }
  464. /* process in/out prox events */
  465. result = wacom_intuos_inout(wacom, wcombo);
  466. if (result)
  467. return result-1;
  468. /* don't proceed if we don't know the ID */
  469. if (!wacom->id[idx])
  470. return 0;
  471. /* Only large Intuos support Lense Cursor */
  472. if ((wacom->tool[idx] == BTN_TOOL_LENS)
  473. && ((wacom->features->type == INTUOS3)
  474. || (wacom->features->type == INTUOS3S)
  475. || (wacom->features->type == INTUOS4)
  476. || (wacom->features->type == INTUOS4S)))
  477. return 0;
  478. /* Cintiq doesn't send data when RDY bit isn't set */
  479. if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
  480. return 0;
  481. if (wacom->features->type >= INTUOS3S) {
  482. wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  483. wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  484. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  485. } else {
  486. wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
  487. wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
  488. wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  489. }
  490. /* process general packets */
  491. wacom_intuos_general(wacom, wcombo);
  492. /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
  493. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
  494. if (data[1] & 0x02) {
  495. /* Rotation packet */
  496. if (wacom->features->type >= INTUOS3S) {
  497. /* I3 marker pen rotation */
  498. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  499. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  500. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  501. wacom_report_abs(wcombo, ABS_Z, t);
  502. } else {
  503. /* 4D mouse rotation packet */
  504. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  505. wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
  506. ((t - 1) / 2) : -t / 2);
  507. }
  508. } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
  509. /* 4D mouse packet */
  510. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  511. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  512. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  513. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
  514. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
  515. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  516. wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  517. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  518. /* I4 mouse */
  519. if (wacom->features->type >= INTUOS4S && wacom->features->type <= INTUOS4L) {
  520. wacom_report_key(wcombo, BTN_LEFT, data[6] & 0x01);
  521. wacom_report_key(wcombo, BTN_MIDDLE, data[6] & 0x02);
  522. wacom_report_key(wcombo, BTN_RIGHT, data[6] & 0x04);
  523. wacom_report_rel(wcombo, REL_WHEEL, ((data[7] & 0x80) >> 7)
  524. - ((data[7] & 0x40) >> 6));
  525. wacom_report_key(wcombo, BTN_SIDE, data[6] & 0x08);
  526. wacom_report_key(wcombo, BTN_EXTRA, data[6] & 0x10);
  527. wacom_report_abs(wcombo, ABS_TILT_X,
  528. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  529. wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
  530. } else {
  531. /* 2D mouse packet */
  532. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
  533. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
  534. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
  535. wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
  536. - ((data[8] & 0x02) >> 1));
  537. /* I3 2D mouse side buttons */
  538. if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
  539. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
  540. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
  541. }
  542. }
  543. } else if ((wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L ||
  544. wacom->features->type == INTUOS4L) &&
  545. wacom->tool[idx] == BTN_TOOL_LENS) {
  546. /* Lens cursor packets */
  547. wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
  548. wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
  549. wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
  550. wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
  551. wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
  552. }
  553. }
  554. wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
  555. wacom_report_key(wcombo, wacom->tool[idx], 1);
  556. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  557. return 1;
  558. }
  559. static void wacom_tpc_finger_in(struct wacom_wac *wacom, void *wcombo, char *data, int idx)
  560. {
  561. wacom_report_abs(wcombo, ABS_X,
  562. (data[2 + idx * 2] & 0xff) | ((data[3 + idx * 2] & 0x7f) << 8));
  563. wacom_report_abs(wcombo, ABS_Y,
  564. (data[6 + idx * 2] & 0xff) | ((data[7 + idx * 2] & 0x7f) << 8));
  565. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
  566. wacom_report_key(wcombo, wacom->tool[idx], 1);
  567. if (idx)
  568. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  569. else
  570. wacom_report_key(wcombo, BTN_TOUCH, 1);
  571. }
  572. static void wacom_tpc_touch_out(struct wacom_wac *wacom, void *wcombo, int idx)
  573. {
  574. wacom_report_abs(wcombo, ABS_X, 0);
  575. wacom_report_abs(wcombo, ABS_Y, 0);
  576. wacom_report_abs(wcombo, ABS_MISC, 0);
  577. wacom_report_key(wcombo, wacom->tool[idx], 0);
  578. if (idx)
  579. wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
  580. else
  581. wacom_report_key(wcombo, BTN_TOUCH, 0);
  582. return;
  583. }
  584. static void wacom_tpc_touch_in(struct wacom_wac *wacom, void *wcombo)
  585. {
  586. char *data = wacom->data;
  587. struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
  588. static int firstFinger = 0;
  589. static int secondFinger = 0;
  590. wacom->tool[0] = BTN_TOOL_DOUBLETAP;
  591. wacom->id[0] = TOUCH_DEVICE_ID;
  592. wacom->tool[1] = BTN_TOOL_TRIPLETAP;
  593. if (urb->actual_length != WACOM_PKGLEN_TPC1FG) {
  594. switch (data[0]) {
  595. case 6:
  596. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
  597. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
  598. wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
  599. wacom_report_key(wcombo, BTN_TOUCH, wacom_le16_to_cpu(&data[6]));
  600. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
  601. wacom_report_key(wcombo, wacom->tool[0], 1);
  602. break;
  603. case 13:
  604. /* keep this byte to send proper out-prox event */
  605. wacom->id[1] = data[1] & 0x03;
  606. if (data[1] & 0x01) {
  607. wacom_tpc_finger_in(wacom, wcombo, data, 0);
  608. firstFinger = 1;
  609. } else if (firstFinger) {
  610. wacom_tpc_touch_out(wacom, wcombo, 0);
  611. }
  612. if (data[1] & 0x02) {
  613. /* sync first finger data */
  614. if (firstFinger)
  615. wacom_input_sync(wcombo);
  616. wacom_tpc_finger_in(wacom, wcombo, data, 1);
  617. secondFinger = 1;
  618. } else if (secondFinger) {
  619. /* sync first finger data */
  620. if (firstFinger)
  621. wacom_input_sync(wcombo);
  622. wacom_tpc_touch_out(wacom, wcombo, 1);
  623. secondFinger = 0;
  624. }
  625. if (!(data[1] & 0x01))
  626. firstFinger = 0;
  627. break;
  628. }
  629. } else {
  630. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
  631. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
  632. wacom_report_key(wcombo, BTN_TOUCH, 1);
  633. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
  634. wacom_report_key(wcombo, wacom->tool[0], 1);
  635. }
  636. return;
  637. }
  638. static int wacom_tpc_irq(struct wacom_wac *wacom, void *wcombo)
  639. {
  640. char *data = wacom->data;
  641. int prox = 0, pressure, idx = -1;
  642. static int stylusInProx, touchInProx = 1, touchOut;
  643. struct urb *urb = ((struct wacom_combo *)wcombo)->urb;
  644. dbg("wacom_tpc_irq: received report #%d", data[0]);
  645. if (urb->actual_length == WACOM_PKGLEN_TPC1FG ||
  646. data[0] == 6 || /* single touch */
  647. data[0] == 13) { /* 2FG touch */
  648. if (urb->actual_length == WACOM_PKGLEN_TPC1FG) { /* with touch */
  649. prox = data[0] & 0x01;
  650. } else { /* with capacity */
  651. if (data[0] == 6)
  652. /* single touch */
  653. prox = data[1] & 0x01;
  654. else
  655. /* 2FG touch data */
  656. prox = data[1] & 0x03;
  657. }
  658. if (!stylusInProx) { /* stylus not in prox */
  659. if (prox) {
  660. if (touchInProx) {
  661. wacom_tpc_touch_in(wacom, wcombo);
  662. touchOut = 1;
  663. return 1;
  664. }
  665. } else {
  666. /* 2FGT out-prox */
  667. if ((data[0] & 0xff) == 13) {
  668. idx = (wacom->id[1] & 0x01) - 1;
  669. if (idx == 0) {
  670. wacom_tpc_touch_out(wacom, wcombo, idx);
  671. /* sync first finger event */
  672. if (wacom->id[1] & 0x02)
  673. wacom_input_sync(wcombo);
  674. }
  675. idx = (wacom->id[1] & 0x02) - 1;
  676. if (idx == 1)
  677. wacom_tpc_touch_out(wacom, wcombo, idx);
  678. } else /* one finger touch */
  679. wacom_tpc_touch_out(wacom, wcombo, 0);
  680. touchOut = 0;
  681. touchInProx = 1;
  682. return 1;
  683. }
  684. } else if (touchOut || !prox) { /* force touch out-prox */
  685. wacom_tpc_touch_out(wacom, wcombo, 0);
  686. touchOut = 0;
  687. touchInProx = 1;
  688. return 1;
  689. }
  690. } else if (data[0] == 2) { /* Penabled */
  691. prox = data[1] & 0x20;
  692. touchInProx = 0;
  693. if (prox) { /* in prox */
  694. if (!wacom->id[0]) {
  695. /* Going into proximity select tool */
  696. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  697. if (wacom->tool[0] == BTN_TOOL_PEN)
  698. wacom->id[0] = STYLUS_DEVICE_ID;
  699. else
  700. wacom->id[0] = ERASER_DEVICE_ID;
  701. }
  702. wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
  703. wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
  704. wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
  705. wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
  706. pressure = ((data[7] & 0x01) << 8) | data[6];
  707. if (pressure < 0)
  708. pressure = wacom->features->pressure_max + pressure + 1;
  709. wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
  710. wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x05);
  711. } else {
  712. wacom_report_abs(wcombo, ABS_X, 0);
  713. wacom_report_abs(wcombo, ABS_Y, 0);
  714. wacom_report_abs(wcombo, ABS_PRESSURE, 0);
  715. wacom_report_key(wcombo, BTN_STYLUS, 0);
  716. wacom_report_key(wcombo, BTN_STYLUS2, 0);
  717. wacom_report_key(wcombo, BTN_TOUCH, 0);
  718. wacom->id[0] = 0;
  719. /* pen is out so touch can be enabled now */
  720. touchInProx = 1;
  721. }
  722. wacom_report_key(wcombo, wacom->tool[0], prox);
  723. wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]);
  724. stylusInProx = prox;
  725. return 1;
  726. }
  727. return 0;
  728. }
  729. int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
  730. {
  731. switch (wacom_wac->features->type) {
  732. case PENPARTNER:
  733. return wacom_penpartner_irq(wacom_wac, wcombo);
  734. case PL:
  735. return wacom_pl_irq(wacom_wac, wcombo);
  736. case WACOM_G4:
  737. case GRAPHIRE:
  738. case WACOM_MO:
  739. return wacom_graphire_irq(wacom_wac, wcombo);
  740. case PTU:
  741. return wacom_ptu_irq(wacom_wac, wcombo);
  742. case INTUOS:
  743. case INTUOS3S:
  744. case INTUOS3:
  745. case INTUOS3L:
  746. case INTUOS4S:
  747. case INTUOS4:
  748. case INTUOS4L:
  749. case CINTIQ:
  750. case WACOM_BEE:
  751. return wacom_intuos_irq(wacom_wac, wcombo);
  752. case TABLETPC:
  753. case TABLETPC2FG:
  754. return wacom_tpc_irq(wacom_wac, wcombo);
  755. default:
  756. return 0;
  757. }
  758. return 0;
  759. }
  760. void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
  761. {
  762. switch (wacom_wac->features->type) {
  763. case WACOM_MO:
  764. input_dev_mo(input_dev, wacom_wac);
  765. case WACOM_G4:
  766. input_dev_g4(input_dev, wacom_wac);
  767. /* fall through */
  768. case GRAPHIRE:
  769. input_dev_g(input_dev, wacom_wac);
  770. break;
  771. case WACOM_BEE:
  772. input_dev_bee(input_dev, wacom_wac);
  773. case INTUOS3:
  774. case INTUOS3L:
  775. case CINTIQ:
  776. input_dev_i3(input_dev, wacom_wac);
  777. /* fall through */
  778. case INTUOS3S:
  779. input_dev_i3s(input_dev, wacom_wac);
  780. /* fall through */
  781. case INTUOS:
  782. input_dev_i(input_dev, wacom_wac);
  783. break;
  784. case INTUOS4:
  785. case INTUOS4L:
  786. input_dev_i4(input_dev, wacom_wac);
  787. /* fall through */
  788. case INTUOS4S:
  789. input_dev_i4s(input_dev, wacom_wac);
  790. input_dev_i(input_dev, wacom_wac);
  791. break;
  792. case TABLETPC2FG:
  793. input_dev_tpc2fg(input_dev, wacom_wac);
  794. /* fall through */
  795. case TABLETPC:
  796. input_dev_tpc(input_dev, wacom_wac);
  797. if (wacom_wac->features->device_type != BTN_TOOL_PEN)
  798. break; /* no need to process stylus stuff */
  799. /* fall through */
  800. case PL:
  801. case PTU:
  802. input_dev_pl(input_dev, wacom_wac);
  803. /* fall through */
  804. case PENPARTNER:
  805. input_dev_pt(input_dev, wacom_wac);
  806. break;
  807. }
  808. return;
  809. }
  810. static struct wacom_features wacom_features[] = {
  811. { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255, 0, PENPARTNER },
  812. { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
  813. { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511, 63, GRAPHIRE },
  814. { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511, 63, GRAPHIRE },
  815. { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, GRAPHIRE },
  816. { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
  817. { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511, 63, WACOM_G4 },
  818. { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, WACOM_G4 },
  819. { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
  820. { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511, 63, WACOM_MO },
  821. { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511, 63, GRAPHIRE },
  822. { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
  823. { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255, 63, GRAPHIRE },
  824. { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
  825. { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511, 63, GRAPHIRE },
  826. { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511, 63, GRAPHIRE },
  827. { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511, 63, WACOM_MO },
  828. { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511, 63, GRAPHIRE },
  829. { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
  830. { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
  831. { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
  832. { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
  833. { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
  834. { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255, 0, PL },
  835. { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255, 0, PL },
  836. { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255, 0, PL },
  837. { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255, 0, PL },
  838. { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511, 0, PL },
  839. { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511, 0, PL },
  840. { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511, 0, PL },
  841. { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
  842. { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511, 0, PL },
  843. { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511, 0, PL },
  844. { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
  845. { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511, 0, PL },
  846. { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511, 0, PTU },
  847. { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023, 31, INTUOS },
  848. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
  849. { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023, 31, INTUOS },
  850. { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023, 31, INTUOS },
  851. { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023, 31, INTUOS },
  852. { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023, 63, INTUOS3S },
  853. { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023, 63, INTUOS3 },
  854. { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023, 63, INTUOS3 },
  855. { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023, 63, INTUOS3L },
  856. { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023, 63, INTUOS3L },
  857. { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023, 63, INTUOS3 },
  858. { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023, 63, INTUOS3S },
  859. { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047, 63, INTUOS4S },
  860. { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047, 63, INTUOS4 },
  861. { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 63, INTUOS4L },
  862. { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047, 63, INTUOS4L },
  863. { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 63, CINTIQ },
  864. { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023, 63, WACOM_BEE },
  865. { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023, 63, WACOM_BEE },
  866. { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511, 0, PL },
  867. { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
  868. { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
  869. { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255, 0, TABLETPC },
  870. { "Wacom ISDv4 9F", WACOM_PKGLEN_PENABLED, 26202, 16325, 255, 0, TABLETPC },
  871. { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
  872. { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG },
  873. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS },
  874. { }
  875. };
  876. static struct usb_device_id wacom_ids[] = {
  877. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
  878. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
  879. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
  880. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
  881. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
  882. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
  883. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
  884. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
  885. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x17) },
  886. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x18) },
  887. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x19) },
  888. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
  889. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
  890. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
  891. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
  892. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
  893. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x65) },
  894. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x69) },
  895. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
  896. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
  897. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
  898. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
  899. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
  900. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
  901. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
  902. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
  903. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
  904. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
  905. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
  906. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
  907. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
  908. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
  909. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
  910. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
  911. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC2) },
  912. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
  913. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
  914. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
  915. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
  916. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
  917. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
  918. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
  919. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
  920. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
  921. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
  922. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
  923. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
  924. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
  925. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB8) },
  926. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB9) },
  927. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBA) },
  928. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xBB) },
  929. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
  930. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC5) },
  931. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC6) },
  932. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC7) },
  933. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x90) },
  934. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x93) },
  935. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9A) },
  936. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x9F) },
  937. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE2) },
  938. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xE3) },
  939. { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
  940. { }
  941. };
  942. const struct usb_device_id *get_device_table(void)
  943. {
  944. const struct usb_device_id *id_table = wacom_ids;
  945. return id_table;
  946. }
  947. struct wacom_features * get_wacom_feature(const struct usb_device_id *id)
  948. {
  949. int index = id - wacom_ids;
  950. struct wacom_features *wf = &wacom_features[index];
  951. return wf;
  952. }
  953. MODULE_DEVICE_TABLE(usb, wacom_ids);