wacom_wac.c 43 KB

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