wacom_wac.c 51 KB

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