wacom_wac.c 38 KB

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