wacom_wac.c 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213
  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. #include <linux/hid.h>
  17. /* resolution for penabled devices */
  18. #define WACOM_PL_RES 20
  19. #define WACOM_PENPRTN_RES 40
  20. #define WACOM_VOLITO_RES 50
  21. #define WACOM_GRAPHIRE_RES 80
  22. #define WACOM_INTUOS_RES 100
  23. #define WACOM_INTUOS3_RES 200
  24. /* Scale factor relating reported contact size to logical contact area.
  25. * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
  26. */
  27. #define WACOM_CONTACT_AREA_SCALE 2607
  28. static int wacom_penpartner_irq(struct wacom_wac *wacom)
  29. {
  30. unsigned char *data = wacom->data;
  31. struct input_dev *input = wacom->input;
  32. switch (data[0]) {
  33. case 1:
  34. if (data[5] & 0x80) {
  35. wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  36. wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
  37. input_report_key(input, wacom->tool[0], 1);
  38. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  39. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  40. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  41. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  42. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
  43. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  44. } else {
  45. input_report_key(input, wacom->tool[0], 0);
  46. input_report_abs(input, ABS_MISC, 0); /* report tool id */
  47. input_report_abs(input, ABS_PRESSURE, -1);
  48. input_report_key(input, BTN_TOUCH, 0);
  49. }
  50. break;
  51. case 2:
  52. input_report_key(input, BTN_TOOL_PEN, 1);
  53. input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
  54. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  55. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  56. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  57. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
  58. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  59. break;
  60. default:
  61. dev_dbg(input->dev.parent,
  62. "%s: received unknown report #%d\n", __func__, data[0]);
  63. return 0;
  64. }
  65. return 1;
  66. }
  67. static int wacom_pl_irq(struct wacom_wac *wacom)
  68. {
  69. struct wacom_features *features = &wacom->features;
  70. unsigned char *data = wacom->data;
  71. struct input_dev *input = wacom->input;
  72. int prox, pressure;
  73. if (data[0] != WACOM_REPORT_PENABLED) {
  74. dev_dbg(input->dev.parent,
  75. "%s: received unknown report #%d\n", __func__, data[0]);
  76. return 0;
  77. }
  78. prox = data[1] & 0x40;
  79. if (prox) {
  80. wacom->id[0] = ERASER_DEVICE_ID;
  81. pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
  82. if (features->pressure_max > 255)
  83. pressure = (pressure << 1) | ((data[4] >> 6) & 1);
  84. pressure += (features->pressure_max + 1) / 2;
  85. /*
  86. * if going from out of proximity into proximity select between the eraser
  87. * and the pen based on the state of the stylus2 button, choose eraser if
  88. * pressed else choose pen. if not a proximity change from out to in, send
  89. * an out of proximity for previous tool then a in for new tool.
  90. */
  91. if (!wacom->tool[0]) {
  92. /* Eraser bit set for DTF */
  93. if (data[1] & 0x10)
  94. wacom->tool[1] = BTN_TOOL_RUBBER;
  95. else
  96. /* Going into proximity select tool */
  97. wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  98. } else {
  99. /* was entered with stylus2 pressed */
  100. if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
  101. /* report out proximity for previous tool */
  102. input_report_key(input, wacom->tool[1], 0);
  103. input_sync(input);
  104. wacom->tool[1] = BTN_TOOL_PEN;
  105. return 0;
  106. }
  107. }
  108. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  109. /* Unknown tool selected default to pen tool */
  110. wacom->tool[1] = BTN_TOOL_PEN;
  111. wacom->id[0] = STYLUS_DEVICE_ID;
  112. }
  113. input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
  114. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  115. input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
  116. input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
  117. input_report_abs(input, ABS_PRESSURE, pressure);
  118. input_report_key(input, BTN_TOUCH, data[4] & 0x08);
  119. input_report_key(input, BTN_STYLUS, data[4] & 0x10);
  120. /* Only allow the stylus2 button to be reported for the pen tool. */
  121. input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
  122. } else {
  123. /* report proximity-out of a (valid) tool */
  124. if (wacom->tool[1] != BTN_TOOL_RUBBER) {
  125. /* Unknown tool selected default to pen tool */
  126. wacom->tool[1] = BTN_TOOL_PEN;
  127. }
  128. input_report_key(input, wacom->tool[1], prox);
  129. }
  130. wacom->tool[0] = prox; /* Save proximity state */
  131. return 1;
  132. }
  133. static int wacom_ptu_irq(struct wacom_wac *wacom)
  134. {
  135. unsigned char *data = wacom->data;
  136. struct input_dev *input = wacom->input;
  137. if (data[0] != WACOM_REPORT_PENABLED) {
  138. dev_dbg(input->dev.parent,
  139. "%s: received unknown report #%d\n", __func__, data[0]);
  140. return 0;
  141. }
  142. if (data[1] & 0x04) {
  143. input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
  144. input_report_key(input, BTN_TOUCH, data[1] & 0x08);
  145. wacom->id[0] = ERASER_DEVICE_ID;
  146. } else {
  147. input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
  148. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  149. wacom->id[0] = STYLUS_DEVICE_ID;
  150. }
  151. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  152. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  153. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  154. input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  155. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  156. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  157. return 1;
  158. }
  159. static int wacom_dtu_irq(struct wacom_wac *wacom)
  160. {
  161. struct wacom_features *features = &wacom->features;
  162. char *data = wacom->data;
  163. struct input_dev *input = wacom->input;
  164. int prox = data[1] & 0x20, pressure;
  165. dev_dbg(input->dev.parent,
  166. "%s: received report #%d", __func__, data[0]);
  167. if (prox) {
  168. /* Going into proximity select tool */
  169. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  170. if (wacom->tool[0] == BTN_TOOL_PEN)
  171. wacom->id[0] = STYLUS_DEVICE_ID;
  172. else
  173. wacom->id[0] = ERASER_DEVICE_ID;
  174. }
  175. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  176. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  177. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  178. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  179. pressure = ((data[7] & 0x01) << 8) | data[6];
  180. if (pressure < 0)
  181. pressure = features->pressure_max + pressure + 1;
  182. input_report_abs(input, ABS_PRESSURE, pressure);
  183. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  184. if (!prox) /* out-prox */
  185. wacom->id[0] = 0;
  186. input_report_key(input, wacom->tool[0], prox);
  187. input_report_abs(input, ABS_MISC, wacom->id[0]);
  188. return 1;
  189. }
  190. static int wacom_graphire_irq(struct wacom_wac *wacom)
  191. {
  192. struct wacom_features *features = &wacom->features;
  193. unsigned char *data = wacom->data;
  194. struct input_dev *input = wacom->input;
  195. int prox;
  196. int rw = 0;
  197. int retval = 0;
  198. if (data[0] != WACOM_REPORT_PENABLED) {
  199. dev_dbg(input->dev.parent,
  200. "%s: received unknown report #%d\n", __func__, data[0]);
  201. goto exit;
  202. }
  203. prox = data[1] & 0x80;
  204. if (prox || wacom->id[0]) {
  205. if (prox) {
  206. switch ((data[1] >> 5) & 3) {
  207. case 0: /* Pen */
  208. wacom->tool[0] = BTN_TOOL_PEN;
  209. wacom->id[0] = STYLUS_DEVICE_ID;
  210. break;
  211. case 1: /* Rubber */
  212. wacom->tool[0] = BTN_TOOL_RUBBER;
  213. wacom->id[0] = ERASER_DEVICE_ID;
  214. break;
  215. case 2: /* Mouse with wheel */
  216. input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
  217. /* fall through */
  218. case 3: /* Mouse without wheel */
  219. wacom->tool[0] = BTN_TOOL_MOUSE;
  220. wacom->id[0] = CURSOR_DEVICE_ID;
  221. break;
  222. }
  223. }
  224. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  225. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  226. if (wacom->tool[0] != BTN_TOOL_MOUSE) {
  227. input_report_abs(input, ABS_PRESSURE, data[6] | ((data[7] & 0x03) << 8));
  228. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  229. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  230. input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
  231. } else {
  232. input_report_key(input, BTN_LEFT, data[1] & 0x01);
  233. input_report_key(input, BTN_RIGHT, data[1] & 0x02);
  234. if (features->type == WACOM_G4 ||
  235. features->type == WACOM_MO) {
  236. input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
  237. rw = (data[7] & 0x04) - (data[7] & 0x03);
  238. } else {
  239. input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
  240. rw = -(signed char)data[6];
  241. }
  242. input_report_rel(input, REL_WHEEL, rw);
  243. }
  244. if (!prox)
  245. wacom->id[0] = 0;
  246. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  247. input_report_key(input, wacom->tool[0], prox);
  248. input_event(input, EV_MSC, MSC_SERIAL, 1);
  249. input_sync(input); /* sync last event */
  250. }
  251. /* send pad data */
  252. switch (features->type) {
  253. case WACOM_G4:
  254. prox = data[7] & 0xf8;
  255. if (prox || wacom->id[1]) {
  256. wacom->id[1] = PAD_DEVICE_ID;
  257. input_report_key(input, BTN_BACK, (data[7] & 0x40));
  258. input_report_key(input, BTN_FORWARD, (data[7] & 0x80));
  259. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  260. input_report_rel(input, REL_WHEEL, rw);
  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. retval = 1;
  266. }
  267. break;
  268. case WACOM_MO:
  269. prox = (data[7] & 0xf8) || data[8];
  270. if (prox || wacom->id[1]) {
  271. wacom->id[1] = PAD_DEVICE_ID;
  272. input_report_key(input, BTN_BACK, (data[7] & 0x08));
  273. input_report_key(input, BTN_LEFT, (data[7] & 0x20));
  274. input_report_key(input, BTN_FORWARD, (data[7] & 0x10));
  275. input_report_key(input, BTN_RIGHT, (data[7] & 0x40));
  276. input_report_abs(input, ABS_WHEEL, (data[8] & 0x7f));
  277. if (!prox)
  278. wacom->id[1] = 0;
  279. input_report_abs(input, ABS_MISC, wacom->id[1]);
  280. input_event(input, EV_MSC, MSC_SERIAL, 0xf0);
  281. retval = 1;
  282. }
  283. break;
  284. }
  285. exit:
  286. return retval;
  287. }
  288. static int wacom_intuos_inout(struct wacom_wac *wacom)
  289. {
  290. struct wacom_features *features = &wacom->features;
  291. unsigned char *data = wacom->data;
  292. struct input_dev *input = wacom->input;
  293. int idx = 0;
  294. /* tool number */
  295. if (features->type == INTUOS)
  296. idx = data[1] & 0x01;
  297. /* Enter report */
  298. if ((data[1] & 0xfc) == 0xc0) {
  299. if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
  300. wacom->shared->stylus_in_proximity = true;
  301. /* serial number of the tool */
  302. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  303. (data[4] << 20) + (data[5] << 12) +
  304. (data[6] << 4) + (data[7] >> 4);
  305. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
  306. ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
  307. switch (wacom->id[idx] & 0xfffff) {
  308. case 0x812: /* Inking pen */
  309. case 0x801: /* Intuos3 Inking pen */
  310. case 0x20802: /* Intuos4 Inking Pen */
  311. case 0x012:
  312. wacom->tool[idx] = BTN_TOOL_PENCIL;
  313. break;
  314. case 0x822: /* Pen */
  315. case 0x842:
  316. case 0x852:
  317. case 0x823: /* Intuos3 Grip Pen */
  318. case 0x813: /* Intuos3 Classic Pen */
  319. case 0x885: /* Intuos3 Marker Pen */
  320. case 0x802: /* Intuos4 General Pen */
  321. case 0x804: /* Intuos4 Marker Pen */
  322. case 0x40802: /* Intuos4 Classic Pen */
  323. case 0x18803: /* DTH2242 Grip Pen */
  324. case 0x022:
  325. wacom->tool[idx] = BTN_TOOL_PEN;
  326. break;
  327. case 0x832: /* Stroke pen */
  328. case 0x032:
  329. wacom->tool[idx] = BTN_TOOL_BRUSH;
  330. break;
  331. case 0x007: /* Mouse 4D and 2D */
  332. case 0x09c:
  333. case 0x094:
  334. case 0x017: /* Intuos3 2D Mouse */
  335. case 0x806: /* Intuos4 Mouse */
  336. wacom->tool[idx] = BTN_TOOL_MOUSE;
  337. break;
  338. case 0x096: /* Lens cursor */
  339. case 0x097: /* Intuos3 Lens cursor */
  340. case 0x006: /* Intuos4 Lens cursor */
  341. wacom->tool[idx] = BTN_TOOL_LENS;
  342. break;
  343. case 0x82a: /* Eraser */
  344. case 0x85a:
  345. case 0x91a:
  346. case 0xd1a:
  347. case 0x0fa:
  348. case 0x82b: /* Intuos3 Grip Pen Eraser */
  349. case 0x81b: /* Intuos3 Classic Pen Eraser */
  350. case 0x91b: /* Intuos3 Airbrush Eraser */
  351. case 0x80c: /* Intuos4 Marker Pen Eraser */
  352. case 0x80a: /* Intuos4 General Pen Eraser */
  353. case 0x4080a: /* Intuos4 Classic Pen Eraser */
  354. case 0x90a: /* Intuos4 Airbrush Eraser */
  355. wacom->tool[idx] = BTN_TOOL_RUBBER;
  356. break;
  357. case 0xd12:
  358. case 0x912:
  359. case 0x112:
  360. case 0x913: /* Intuos3 Airbrush */
  361. case 0x902: /* Intuos4 Airbrush */
  362. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  363. break;
  364. default: /* Unknown tool */
  365. wacom->tool[idx] = BTN_TOOL_PEN;
  366. break;
  367. }
  368. return 1;
  369. }
  370. /* older I4 styli don't work with new Cintiqs */
  371. if (!((wacom->id[idx] >> 20) & 0x01) &&
  372. (features->type == WACOM_21UX2))
  373. return 1;
  374. /* Exit report */
  375. if ((data[1] & 0xfe) == 0x80) {
  376. if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
  377. wacom->shared->stylus_in_proximity = false;
  378. /*
  379. * Reset all states otherwise we lose the initial states
  380. * when in-prox next time
  381. */
  382. input_report_abs(input, ABS_X, 0);
  383. input_report_abs(input, ABS_Y, 0);
  384. input_report_abs(input, ABS_DISTANCE, 0);
  385. input_report_abs(input, ABS_TILT_X, 0);
  386. input_report_abs(input, ABS_TILT_Y, 0);
  387. if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
  388. input_report_key(input, BTN_LEFT, 0);
  389. input_report_key(input, BTN_MIDDLE, 0);
  390. input_report_key(input, BTN_RIGHT, 0);
  391. input_report_key(input, BTN_SIDE, 0);
  392. input_report_key(input, BTN_EXTRA, 0);
  393. input_report_abs(input, ABS_THROTTLE, 0);
  394. input_report_abs(input, ABS_RZ, 0);
  395. } else {
  396. input_report_abs(input, ABS_PRESSURE, 0);
  397. input_report_key(input, BTN_STYLUS, 0);
  398. input_report_key(input, BTN_STYLUS2, 0);
  399. input_report_key(input, BTN_TOUCH, 0);
  400. input_report_abs(input, ABS_WHEEL, 0);
  401. if (features->type >= INTUOS3S)
  402. input_report_abs(input, ABS_Z, 0);
  403. }
  404. input_report_key(input, wacom->tool[idx], 0);
  405. input_report_abs(input, ABS_MISC, 0); /* reset tool id */
  406. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  407. wacom->id[idx] = 0;
  408. return 2;
  409. }
  410. return 0;
  411. }
  412. static void wacom_intuos_general(struct wacom_wac *wacom)
  413. {
  414. struct wacom_features *features = &wacom->features;
  415. unsigned char *data = wacom->data;
  416. struct input_dev *input = wacom->input;
  417. unsigned int t;
  418. /* general pen packet */
  419. if ((data[1] & 0xb8) == 0xa0) {
  420. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  421. if (features->type >= INTUOS4S && features->type <= WACOM_24HD) {
  422. t = (t << 1) | (data[1] & 1);
  423. }
  424. input_report_abs(input, ABS_PRESSURE, t);
  425. input_report_abs(input, ABS_TILT_X,
  426. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  427. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  428. input_report_key(input, BTN_STYLUS, data[1] & 2);
  429. input_report_key(input, BTN_STYLUS2, data[1] & 4);
  430. input_report_key(input, BTN_TOUCH, t > 10);
  431. }
  432. /* airbrush second packet */
  433. if ((data[1] & 0xbc) == 0xb4) {
  434. input_report_abs(input, ABS_WHEEL,
  435. (data[6] << 2) | ((data[7] >> 6) & 3));
  436. input_report_abs(input, ABS_TILT_X,
  437. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  438. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  439. }
  440. }
  441. static int wacom_intuos_irq(struct wacom_wac *wacom)
  442. {
  443. struct wacom_features *features = &wacom->features;
  444. unsigned char *data = wacom->data;
  445. struct input_dev *input = wacom->input;
  446. unsigned int t;
  447. int idx = 0, result;
  448. if (data[0] != WACOM_REPORT_PENABLED &&
  449. data[0] != WACOM_REPORT_INTUOSREAD &&
  450. data[0] != WACOM_REPORT_INTUOSWRITE &&
  451. data[0] != WACOM_REPORT_INTUOSPAD &&
  452. data[0] != WACOM_REPORT_INTUOS5PAD) {
  453. dev_dbg(input->dev.parent,
  454. "%s: received unknown report #%d\n", __func__, data[0]);
  455. return 0;
  456. }
  457. /* tool number */
  458. if (features->type == INTUOS)
  459. idx = data[1] & 0x01;
  460. /* pad packets. Works as a second tool and is always in prox */
  461. if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD) {
  462. if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
  463. input_report_key(input, BTN_0, (data[2] & 0x01));
  464. input_report_key(input, BTN_1, (data[3] & 0x01));
  465. input_report_key(input, BTN_2, (data[3] & 0x02));
  466. input_report_key(input, BTN_3, (data[3] & 0x04));
  467. input_report_key(input, BTN_4, (data[3] & 0x08));
  468. input_report_key(input, BTN_5, (data[3] & 0x10));
  469. input_report_key(input, BTN_6, (data[3] & 0x20));
  470. if (data[1] & 0x80) {
  471. input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
  472. } else {
  473. /* Out of proximity, clear wheel value. */
  474. input_report_abs(input, ABS_WHEEL, 0);
  475. }
  476. if (features->type != INTUOS4S) {
  477. input_report_key(input, BTN_7, (data[3] & 0x40));
  478. input_report_key(input, BTN_8, (data[3] & 0x80));
  479. }
  480. if (data[1] | (data[2] & 0x01) | data[3]) {
  481. input_report_key(input, wacom->tool[1], 1);
  482. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  483. } else {
  484. input_report_key(input, wacom->tool[1], 0);
  485. input_report_abs(input, ABS_MISC, 0);
  486. }
  487. } else if (features->type == DTK) {
  488. input_report_key(input, BTN_0, (data[6] & 0x01));
  489. input_report_key(input, BTN_1, (data[6] & 0x02));
  490. input_report_key(input, BTN_2, (data[6] & 0x04));
  491. input_report_key(input, BTN_3, (data[6] & 0x08));
  492. input_report_key(input, BTN_4, (data[6] & 0x10));
  493. input_report_key(input, BTN_5, (data[6] & 0x20));
  494. } else if (features->type == WACOM_24HD) {
  495. input_report_key(input, BTN_0, (data[6] & 0x01));
  496. input_report_key(input, BTN_1, (data[6] & 0x02));
  497. input_report_key(input, BTN_2, (data[6] & 0x04));
  498. input_report_key(input, BTN_3, (data[6] & 0x08));
  499. input_report_key(input, BTN_4, (data[6] & 0x10));
  500. input_report_key(input, BTN_5, (data[6] & 0x20));
  501. input_report_key(input, BTN_6, (data[6] & 0x40));
  502. input_report_key(input, BTN_7, (data[6] & 0x80));
  503. input_report_key(input, BTN_8, (data[8] & 0x01));
  504. input_report_key(input, BTN_9, (data[8] & 0x02));
  505. input_report_key(input, BTN_A, (data[8] & 0x04));
  506. input_report_key(input, BTN_B, (data[8] & 0x08));
  507. input_report_key(input, BTN_C, (data[8] & 0x10));
  508. input_report_key(input, BTN_X, (data[8] & 0x20));
  509. input_report_key(input, BTN_Y, (data[8] & 0x40));
  510. input_report_key(input, BTN_Z, (data[8] & 0x80));
  511. /*
  512. * Three "buttons" are available on the 24HD which are
  513. * physically implemented as a touchstrip. Each button
  514. * is approximately 3 bits wide with a 2 bit spacing.
  515. * The raw touchstrip bits are stored at:
  516. * ((data[3] & 0x1f) << 8) | data[4])
  517. */
  518. input_report_key(input, KEY_PROG1, data[4] & 0x07);
  519. input_report_key(input, KEY_PROG2, data[4] & 0xE0);
  520. input_report_key(input, KEY_PROG3, data[3] & 0x1C);
  521. if (data[1] & 0x80) {
  522. input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
  523. } else {
  524. /* Out of proximity, clear wheel value. */
  525. input_report_abs(input, ABS_WHEEL, 0);
  526. }
  527. if (data[2] & 0x80) {
  528. input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
  529. } else {
  530. /* Out of proximity, clear second wheel value. */
  531. input_report_abs(input, ABS_THROTTLE, 0);
  532. }
  533. if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
  534. input_report_key(input, wacom->tool[1], 1);
  535. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  536. } else {
  537. input_report_key(input, wacom->tool[1], 0);
  538. input_report_abs(input, ABS_MISC, 0);
  539. }
  540. } else if (features->type >= INTUOS5S && features->type <= INTUOS5L) {
  541. int i;
  542. /* Touch ring mode switch has no capacitive sensor */
  543. input_report_key(input, BTN_0, (data[3] & 0x01));
  544. /*
  545. * ExpressKeys on Intuos5 have a capacitive sensor in
  546. * addition to the mechanical switch. Switch data is
  547. * stored in data[4], capacitive data in data[5].
  548. */
  549. for (i = 0; i < 8; i++)
  550. input_report_key(input, BTN_1 + i, data[4] & (1 << i));
  551. if (data[2] & 0x80) {
  552. input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
  553. } else {
  554. /* Out of proximity, clear wheel value. */
  555. input_report_abs(input, ABS_WHEEL, 0);
  556. }
  557. if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
  558. input_report_key(input, wacom->tool[1], 1);
  559. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  560. } else {
  561. input_report_key(input, wacom->tool[1], 0);
  562. input_report_abs(input, ABS_MISC, 0);
  563. }
  564. } else {
  565. if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
  566. input_report_key(input, BTN_0, (data[5] & 0x01));
  567. input_report_key(input, BTN_1, (data[6] & 0x01));
  568. input_report_key(input, BTN_2, (data[6] & 0x02));
  569. input_report_key(input, BTN_3, (data[6] & 0x04));
  570. input_report_key(input, BTN_4, (data[6] & 0x08));
  571. input_report_key(input, BTN_5, (data[6] & 0x10));
  572. input_report_key(input, BTN_6, (data[6] & 0x20));
  573. input_report_key(input, BTN_7, (data[6] & 0x40));
  574. input_report_key(input, BTN_8, (data[6] & 0x80));
  575. input_report_key(input, BTN_9, (data[7] & 0x01));
  576. input_report_key(input, BTN_A, (data[8] & 0x01));
  577. input_report_key(input, BTN_B, (data[8] & 0x02));
  578. input_report_key(input, BTN_C, (data[8] & 0x04));
  579. input_report_key(input, BTN_X, (data[8] & 0x08));
  580. input_report_key(input, BTN_Y, (data[8] & 0x10));
  581. input_report_key(input, BTN_Z, (data[8] & 0x20));
  582. input_report_key(input, BTN_BASE, (data[8] & 0x40));
  583. input_report_key(input, BTN_BASE2, (data[8] & 0x80));
  584. if (features->type == WACOM_22HD) {
  585. input_report_key(input, KEY_PROG1, data[9] & 0x01);
  586. input_report_key(input, KEY_PROG2, data[9] & 0x02);
  587. input_report_key(input, KEY_PROG3, data[9] & 0x04);
  588. }
  589. } else {
  590. input_report_key(input, BTN_0, (data[5] & 0x01));
  591. input_report_key(input, BTN_1, (data[5] & 0x02));
  592. input_report_key(input, BTN_2, (data[5] & 0x04));
  593. input_report_key(input, BTN_3, (data[5] & 0x08));
  594. input_report_key(input, BTN_4, (data[6] & 0x01));
  595. input_report_key(input, BTN_5, (data[6] & 0x02));
  596. input_report_key(input, BTN_6, (data[6] & 0x04));
  597. input_report_key(input, BTN_7, (data[6] & 0x08));
  598. input_report_key(input, BTN_8, (data[5] & 0x10));
  599. input_report_key(input, BTN_9, (data[6] & 0x10));
  600. }
  601. input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  602. input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  603. if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
  604. data[2] | (data[3] & 0x1f) | data[4] | data[8] |
  605. (data[7] & 0x01)) {
  606. input_report_key(input, wacom->tool[1], 1);
  607. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  608. } else {
  609. input_report_key(input, wacom->tool[1], 0);
  610. input_report_abs(input, ABS_MISC, 0);
  611. }
  612. }
  613. input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
  614. return 1;
  615. }
  616. /* process in/out prox events */
  617. result = wacom_intuos_inout(wacom);
  618. if (result)
  619. return result - 1;
  620. /* don't proceed if we don't know the ID */
  621. if (!wacom->id[idx])
  622. return 0;
  623. /* Only large Intuos support Lense Cursor */
  624. if (wacom->tool[idx] == BTN_TOOL_LENS &&
  625. (features->type == INTUOS3 ||
  626. features->type == INTUOS3S ||
  627. features->type == INTUOS4 ||
  628. features->type == INTUOS4S ||
  629. features->type == INTUOS5 ||
  630. features->type == INTUOS5S)) {
  631. return 0;
  632. }
  633. /* Cintiq doesn't send data when RDY bit isn't set */
  634. if (features->type == CINTIQ && !(data[1] & 0x40))
  635. return 0;
  636. if (features->type >= INTUOS3S) {
  637. input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  638. input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  639. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  640. } else {
  641. input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
  642. input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
  643. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  644. }
  645. /* process general packets */
  646. wacom_intuos_general(wacom);
  647. /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
  648. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
  649. if (data[1] & 0x02) {
  650. /* Rotation packet */
  651. if (features->type >= INTUOS3S) {
  652. /* I3 marker pen rotation */
  653. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  654. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  655. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  656. input_report_abs(input, ABS_Z, t);
  657. } else {
  658. /* 4D mouse rotation packet */
  659. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  660. input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
  661. ((t - 1) / 2) : -t / 2);
  662. }
  663. } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
  664. /* 4D mouse packet */
  665. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  666. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  667. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  668. input_report_key(input, BTN_SIDE, data[8] & 0x20);
  669. input_report_key(input, BTN_EXTRA, data[8] & 0x10);
  670. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  671. input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  672. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  673. /* I4 mouse */
  674. if ((features->type >= INTUOS4S && features->type <= INTUOS4L) ||
  675. (features->type >= INTUOS5S && features->type <= INTUOS5L)) {
  676. input_report_key(input, BTN_LEFT, data[6] & 0x01);
  677. input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
  678. input_report_key(input, BTN_RIGHT, data[6] & 0x04);
  679. input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
  680. - ((data[7] & 0x40) >> 6));
  681. input_report_key(input, BTN_SIDE, data[6] & 0x08);
  682. input_report_key(input, BTN_EXTRA, data[6] & 0x10);
  683. input_report_abs(input, ABS_TILT_X,
  684. ((data[7] << 1) & 0x7e) | (data[8] >> 7));
  685. input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f);
  686. } else {
  687. /* 2D mouse packet */
  688. input_report_key(input, BTN_LEFT, data[8] & 0x04);
  689. input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
  690. input_report_key(input, BTN_RIGHT, data[8] & 0x10);
  691. input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
  692. - ((data[8] & 0x02) >> 1));
  693. /* I3 2D mouse side buttons */
  694. if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
  695. input_report_key(input, BTN_SIDE, data[8] & 0x40);
  696. input_report_key(input, BTN_EXTRA, data[8] & 0x20);
  697. }
  698. }
  699. } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
  700. features->type == INTUOS4L || features->type == INTUOS5L) &&
  701. wacom->tool[idx] == BTN_TOOL_LENS) {
  702. /* Lens cursor packets */
  703. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  704. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  705. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  706. input_report_key(input, BTN_SIDE, data[8] & 0x10);
  707. input_report_key(input, BTN_EXTRA, data[8] & 0x08);
  708. }
  709. }
  710. input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
  711. input_report_key(input, wacom->tool[idx], 1);
  712. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  713. return 1;
  714. }
  715. static int int_dist(int x1, int y1, int x2, int y2)
  716. {
  717. int x = x2 - x1;
  718. int y = y2 - y1;
  719. return int_sqrt(x*x + y*y);
  720. }
  721. static int wacom_24hdt_irq(struct wacom_wac *wacom)
  722. {
  723. struct input_dev *input = wacom->input;
  724. char *data = wacom->data;
  725. int i;
  726. int current_num_contacts = data[61];
  727. int contacts_to_send = 0;
  728. /*
  729. * First packet resets the counter since only the first
  730. * packet in series will have non-zero current_num_contacts.
  731. */
  732. if (current_num_contacts)
  733. wacom->num_contacts_left = current_num_contacts;
  734. /* There are at most 4 contacts per packet */
  735. contacts_to_send = min(4, wacom->num_contacts_left);
  736. for (i = 0; i < contacts_to_send; i++) {
  737. int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1;
  738. bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity;
  739. int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
  740. if (slot < 0)
  741. continue;
  742. input_mt_slot(input, slot);
  743. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  744. if (touch) {
  745. int t_x = le16_to_cpup((__le16 *)&data[offset + 2]);
  746. int c_x = le16_to_cpup((__le16 *)&data[offset + 4]);
  747. int t_y = le16_to_cpup((__le16 *)&data[offset + 6]);
  748. int c_y = le16_to_cpup((__le16 *)&data[offset + 8]);
  749. int w = le16_to_cpup((__le16 *)&data[offset + 10]);
  750. int h = le16_to_cpup((__le16 *)&data[offset + 12]);
  751. input_report_abs(input, ABS_MT_POSITION_X, t_x);
  752. input_report_abs(input, ABS_MT_POSITION_Y, t_y);
  753. input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
  754. input_report_abs(input, ABS_MT_WIDTH_MAJOR, min(w, h) + int_dist(t_x, t_y, c_x, c_y));
  755. input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
  756. input_report_abs(input, ABS_MT_ORIENTATION, w > h);
  757. }
  758. }
  759. input_mt_report_pointer_emulation(input, true);
  760. wacom->num_contacts_left -= contacts_to_send;
  761. if (wacom->num_contacts_left <= 0)
  762. wacom->num_contacts_left = 0;
  763. return 1;
  764. }
  765. static int wacom_mt_touch(struct wacom_wac *wacom)
  766. {
  767. struct input_dev *input = wacom->input;
  768. char *data = wacom->data;
  769. int i;
  770. int current_num_contacts = data[2];
  771. int contacts_to_send = 0;
  772. int x_offset = 0;
  773. /* MTTPC does not support Height and Width */
  774. if (wacom->features.type == MTTPC)
  775. x_offset = -4;
  776. /*
  777. * First packet resets the counter since only the first
  778. * packet in series will have non-zero current_num_contacts.
  779. */
  780. if (current_num_contacts)
  781. wacom->num_contacts_left = current_num_contacts;
  782. /* There are at most 5 contacts per packet */
  783. contacts_to_send = min(5, wacom->num_contacts_left);
  784. for (i = 0; i < contacts_to_send; i++) {
  785. int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
  786. bool touch = data[offset] & 0x1;
  787. int id = le16_to_cpup((__le16 *)&data[offset + 1]);
  788. int slot = input_mt_get_slot_by_key(input, id);
  789. if (slot < 0)
  790. continue;
  791. input_mt_slot(input, slot);
  792. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  793. if (touch) {
  794. int x = le16_to_cpup((__le16 *)&data[offset + x_offset + 7]);
  795. int y = le16_to_cpup((__le16 *)&data[offset + x_offset + 9]);
  796. input_report_abs(input, ABS_MT_POSITION_X, x);
  797. input_report_abs(input, ABS_MT_POSITION_Y, y);
  798. }
  799. }
  800. input_mt_report_pointer_emulation(input, true);
  801. wacom->num_contacts_left -= contacts_to_send;
  802. if (wacom->num_contacts_left < 0)
  803. wacom->num_contacts_left = 0;
  804. return 1;
  805. }
  806. static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
  807. {
  808. struct input_dev *input = wacom->input;
  809. unsigned char *data = wacom->data;
  810. int contact_with_no_pen_down_count = 0;
  811. int i;
  812. for (i = 0; i < 2; i++) {
  813. int p = data[1] & (1 << i);
  814. bool touch = p && !wacom->shared->stylus_in_proximity;
  815. input_mt_slot(input, i);
  816. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  817. if (touch) {
  818. int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
  819. int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
  820. input_report_abs(input, ABS_MT_POSITION_X, x);
  821. input_report_abs(input, ABS_MT_POSITION_Y, y);
  822. contact_with_no_pen_down_count++;
  823. }
  824. }
  825. input_mt_report_pointer_emulation(input, true);
  826. /* keep touch state for pen event */
  827. wacom->shared->touch_down = (contact_with_no_pen_down_count > 0);
  828. return 1;
  829. }
  830. static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
  831. {
  832. char *data = wacom->data;
  833. struct input_dev *input = wacom->input;
  834. bool prox;
  835. int x = 0, y = 0;
  836. if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
  837. return 0;
  838. if (!wacom->shared->stylus_in_proximity) {
  839. if (len == WACOM_PKGLEN_TPC1FG) {
  840. prox = data[0] & 0x01;
  841. x = get_unaligned_le16(&data[1]);
  842. y = get_unaligned_le16(&data[3]);
  843. } else {
  844. prox = data[1] & 0x01;
  845. x = le16_to_cpup((__le16 *)&data[2]);
  846. y = le16_to_cpup((__le16 *)&data[4]);
  847. }
  848. } else
  849. /* force touch out when pen is in prox */
  850. prox = 0;
  851. if (prox) {
  852. input_report_abs(input, ABS_X, x);
  853. input_report_abs(input, ABS_Y, y);
  854. }
  855. input_report_key(input, BTN_TOUCH, prox);
  856. /* keep touch state for pen events */
  857. wacom->shared->touch_down = prox;
  858. return 1;
  859. }
  860. static int wacom_tpc_pen(struct wacom_wac *wacom)
  861. {
  862. struct wacom_features *features = &wacom->features;
  863. char *data = wacom->data;
  864. struct input_dev *input = wacom->input;
  865. int pressure;
  866. bool prox = data[1] & 0x20;
  867. if (!wacom->shared->stylus_in_proximity) /* first in prox */
  868. /* Going into proximity select tool */
  869. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  870. /* keep pen state for touch events */
  871. wacom->shared->stylus_in_proximity = prox;
  872. /* send pen events only when touch is up or forced out */
  873. if (!wacom->shared->touch_down) {
  874. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  875. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  876. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  877. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  878. pressure = ((data[7] & 0x01) << 8) | data[6];
  879. if (pressure < 0)
  880. pressure = features->pressure_max + pressure + 1;
  881. input_report_abs(input, ABS_PRESSURE, pressure);
  882. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  883. input_report_key(input, wacom->tool[0], prox);
  884. return 1;
  885. }
  886. return 0;
  887. }
  888. static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
  889. {
  890. char *data = wacom->data;
  891. dev_dbg(wacom->input->dev.parent,
  892. "%s: received report #%d\n", __func__, data[0]);
  893. switch (len) {
  894. case WACOM_PKGLEN_TPC1FG:
  895. return wacom_tpc_single_touch(wacom, len);
  896. case WACOM_PKGLEN_TPC2FG:
  897. return wacom_tpc_mt_touch(wacom);
  898. default:
  899. switch (data[0]) {
  900. case WACOM_REPORT_TPC1FG:
  901. case WACOM_REPORT_TPCHID:
  902. case WACOM_REPORT_TPCST:
  903. case WACOM_REPORT_TPC1FGE:
  904. return wacom_tpc_single_touch(wacom, len);
  905. case WACOM_REPORT_TPCMT:
  906. return wacom_mt_touch(wacom);
  907. case WACOM_REPORT_PENABLED:
  908. return wacom_tpc_pen(wacom);
  909. }
  910. }
  911. return 0;
  912. }
  913. static int wacom_bpt_touch(struct wacom_wac *wacom)
  914. {
  915. struct wacom_features *features = &wacom->features;
  916. struct input_dev *input = wacom->input;
  917. unsigned char *data = wacom->data;
  918. int i;
  919. if (data[0] != 0x02)
  920. return 0;
  921. for (i = 0; i < 2; i++) {
  922. int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
  923. bool touch = data[offset + 3] & 0x80;
  924. /*
  925. * Touch events need to be disabled while stylus is
  926. * in proximity because user's hand is resting on touchpad
  927. * and sending unwanted events. User expects tablet buttons
  928. * to continue working though.
  929. */
  930. touch = touch && !wacom->shared->stylus_in_proximity;
  931. input_mt_slot(input, i);
  932. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  933. if (touch) {
  934. int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
  935. int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
  936. if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
  937. x <<= 5;
  938. y <<= 5;
  939. }
  940. input_report_abs(input, ABS_MT_POSITION_X, x);
  941. input_report_abs(input, ABS_MT_POSITION_Y, y);
  942. }
  943. }
  944. input_mt_report_pointer_emulation(input, true);
  945. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  946. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  947. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  948. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  949. input_sync(input);
  950. return 0;
  951. }
  952. static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
  953. {
  954. struct input_dev *input = wacom->input;
  955. bool touch = data[1] & 0x80;
  956. int slot = input_mt_get_slot_by_key(input, data[0]);
  957. if (slot < 0)
  958. return;
  959. touch = touch && !wacom->shared->stylus_in_proximity;
  960. input_mt_slot(input, slot);
  961. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  962. if (touch) {
  963. int x = (data[2] << 4) | (data[4] >> 4);
  964. int y = (data[3] << 4) | (data[4] & 0x0f);
  965. int a = data[5];
  966. // "a" is a scaled-down area which we assume is roughly
  967. // circular and which can be described as: a=(pi*r^2)/C.
  968. int x_res = input_abs_get_res(input, ABS_X);
  969. int y_res = input_abs_get_res(input, ABS_Y);
  970. int width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
  971. int height = width * y_res / x_res;
  972. input_report_abs(input, ABS_MT_POSITION_X, x);
  973. input_report_abs(input, ABS_MT_POSITION_Y, y);
  974. input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
  975. input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
  976. }
  977. }
  978. static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
  979. {
  980. struct input_dev *input = wacom->input;
  981. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  982. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  983. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  984. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  985. }
  986. static int wacom_bpt3_touch(struct wacom_wac *wacom)
  987. {
  988. struct input_dev *input = wacom->input;
  989. unsigned char *data = wacom->data;
  990. int count = data[1] & 0x07;
  991. int i;
  992. if (data[0] != 0x02)
  993. return 0;
  994. /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
  995. for (i = 0; i < count; i++) {
  996. int offset = (8 * i) + 2;
  997. int msg_id = data[offset];
  998. if (msg_id >= 2 && msg_id <= 17)
  999. wacom_bpt3_touch_msg(wacom, data + offset);
  1000. else if (msg_id == 128)
  1001. wacom_bpt3_button_msg(wacom, data + offset);
  1002. }
  1003. input_mt_report_pointer_emulation(input, true);
  1004. input_sync(input);
  1005. return 0;
  1006. }
  1007. static int wacom_bpt_pen(struct wacom_wac *wacom)
  1008. {
  1009. struct input_dev *input = wacom->input;
  1010. unsigned char *data = wacom->data;
  1011. int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
  1012. if (data[0] != 0x02)
  1013. return 0;
  1014. prox = (data[1] & 0x20) == 0x20;
  1015. /*
  1016. * All reports shared between PEN and RUBBER tool must be
  1017. * forced to a known starting value (zero) when transitioning to
  1018. * out-of-prox.
  1019. *
  1020. * If not reset then, to userspace, it will look like lost events
  1021. * if new tool comes in-prox with same values as previous tool sent.
  1022. *
  1023. * Hardware does report zero in most out-of-prox cases but not all.
  1024. */
  1025. if (prox) {
  1026. if (!wacom->shared->stylus_in_proximity) {
  1027. if (data[1] & 0x08) {
  1028. wacom->tool[0] = BTN_TOOL_RUBBER;
  1029. wacom->id[0] = ERASER_DEVICE_ID;
  1030. } else {
  1031. wacom->tool[0] = BTN_TOOL_PEN;
  1032. wacom->id[0] = STYLUS_DEVICE_ID;
  1033. }
  1034. wacom->shared->stylus_in_proximity = true;
  1035. }
  1036. x = le16_to_cpup((__le16 *)&data[2]);
  1037. y = le16_to_cpup((__le16 *)&data[4]);
  1038. p = le16_to_cpup((__le16 *)&data[6]);
  1039. /*
  1040. * Convert distance from out prox to distance from tablet.
  1041. * distance will be greater than distance_max once
  1042. * touching and applying pressure; do not report negative
  1043. * distance.
  1044. */
  1045. if (data[8] <= wacom->features.distance_max)
  1046. d = wacom->features.distance_max - data[8];
  1047. pen = data[1] & 0x01;
  1048. btn1 = data[1] & 0x02;
  1049. btn2 = data[1] & 0x04;
  1050. }
  1051. input_report_key(input, BTN_TOUCH, pen);
  1052. input_report_key(input, BTN_STYLUS, btn1);
  1053. input_report_key(input, BTN_STYLUS2, btn2);
  1054. input_report_abs(input, ABS_X, x);
  1055. input_report_abs(input, ABS_Y, y);
  1056. input_report_abs(input, ABS_PRESSURE, p);
  1057. input_report_abs(input, ABS_DISTANCE, d);
  1058. if (!prox) {
  1059. wacom->id[0] = 0;
  1060. wacom->shared->stylus_in_proximity = false;
  1061. }
  1062. input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
  1063. input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
  1064. return 1;
  1065. }
  1066. static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  1067. {
  1068. if (len == WACOM_PKGLEN_BBTOUCH)
  1069. return wacom_bpt_touch(wacom);
  1070. else if (len == WACOM_PKGLEN_BBTOUCH3)
  1071. return wacom_bpt3_touch(wacom);
  1072. else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
  1073. return wacom_bpt_pen(wacom);
  1074. return 0;
  1075. }
  1076. static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
  1077. {
  1078. unsigned char *data = wacom->data;
  1079. int connected;
  1080. if (len != WACOM_PKGLEN_WIRELESS || data[0] != 0x80)
  1081. return 0;
  1082. connected = data[1] & 0x01;
  1083. if (connected) {
  1084. int pid, battery;
  1085. pid = get_unaligned_be16(&data[6]);
  1086. battery = data[5] & 0x3f;
  1087. if (wacom->pid != pid) {
  1088. wacom->pid = pid;
  1089. wacom_schedule_work(wacom);
  1090. }
  1091. wacom->battery_capacity = battery;
  1092. } else if (wacom->pid != 0) {
  1093. /* disconnected while previously connected */
  1094. wacom->pid = 0;
  1095. wacom_schedule_work(wacom);
  1096. wacom->battery_capacity = 0;
  1097. }
  1098. return 0;
  1099. }
  1100. void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  1101. {
  1102. bool sync;
  1103. switch (wacom_wac->features.type) {
  1104. case PENPARTNER:
  1105. sync = wacom_penpartner_irq(wacom_wac);
  1106. break;
  1107. case PL:
  1108. sync = wacom_pl_irq(wacom_wac);
  1109. break;
  1110. case WACOM_G4:
  1111. case GRAPHIRE:
  1112. case WACOM_MO:
  1113. sync = wacom_graphire_irq(wacom_wac);
  1114. break;
  1115. case PTU:
  1116. sync = wacom_ptu_irq(wacom_wac);
  1117. break;
  1118. case DTU:
  1119. sync = wacom_dtu_irq(wacom_wac);
  1120. break;
  1121. case INTUOS:
  1122. case INTUOS3S:
  1123. case INTUOS3:
  1124. case INTUOS3L:
  1125. case INTUOS4S:
  1126. case INTUOS4:
  1127. case INTUOS4L:
  1128. case CINTIQ:
  1129. case WACOM_BEE:
  1130. case WACOM_21UX2:
  1131. case WACOM_22HD:
  1132. case WACOM_24HD:
  1133. case DTK:
  1134. sync = wacom_intuos_irq(wacom_wac);
  1135. break;
  1136. case WACOM_24HDT:
  1137. sync = wacom_24hdt_irq(wacom_wac);
  1138. break;
  1139. case INTUOS5S:
  1140. case INTUOS5:
  1141. case INTUOS5L:
  1142. if (len == WACOM_PKGLEN_BBTOUCH3)
  1143. sync = wacom_bpt3_touch(wacom_wac);
  1144. else
  1145. sync = wacom_intuos_irq(wacom_wac);
  1146. break;
  1147. case TABLETPC:
  1148. case TABLETPCE:
  1149. case TABLETPC2FG:
  1150. case MTSCREEN:
  1151. case MTTPC:
  1152. sync = wacom_tpc_irq(wacom_wac, len);
  1153. break;
  1154. case BAMBOO_PT:
  1155. sync = wacom_bpt_irq(wacom_wac, len);
  1156. break;
  1157. case WIRELESS:
  1158. sync = wacom_wireless_irq(wacom_wac, len);
  1159. break;
  1160. default:
  1161. sync = false;
  1162. break;
  1163. }
  1164. if (sync)
  1165. input_sync(wacom_wac->input);
  1166. }
  1167. static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  1168. {
  1169. struct input_dev *input_dev = wacom_wac->input;
  1170. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  1171. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1172. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1173. __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  1174. __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  1175. __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  1176. __set_bit(BTN_STYLUS, input_dev->keybit);
  1177. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1178. input_set_abs_params(input_dev, ABS_DISTANCE,
  1179. 0, wacom_wac->features.distance_max, 0, 0);
  1180. input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  1181. input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
  1182. input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
  1183. }
  1184. static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  1185. {
  1186. struct input_dev *input_dev = wacom_wac->input;
  1187. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1188. wacom_setup_cintiq(wacom_wac);
  1189. __set_bit(BTN_LEFT, input_dev->keybit);
  1190. __set_bit(BTN_RIGHT, input_dev->keybit);
  1191. __set_bit(BTN_MIDDLE, input_dev->keybit);
  1192. __set_bit(BTN_SIDE, input_dev->keybit);
  1193. __set_bit(BTN_EXTRA, input_dev->keybit);
  1194. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1195. __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  1196. input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  1197. input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  1198. }
  1199. void wacom_setup_device_quirks(struct wacom_features *features)
  1200. {
  1201. /* touch device found but size is not defined. use default */
  1202. if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
  1203. features->x_max = 1023;
  1204. features->y_max = 1023;
  1205. }
  1206. /* these device have multiple inputs */
  1207. if (features->type >= WIRELESS ||
  1208. (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
  1209. (features->oVid && features->oPid))
  1210. features->quirks |= WACOM_QUIRK_MULTI_INPUT;
  1211. /* quirk for bamboo touch with 2 low res touches */
  1212. if (features->type == BAMBOO_PT &&
  1213. features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  1214. features->x_max <<= 5;
  1215. features->y_max <<= 5;
  1216. features->x_fuzz <<= 5;
  1217. features->y_fuzz <<= 5;
  1218. features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
  1219. }
  1220. if (features->type == WIRELESS) {
  1221. /* monitor never has input and pen/touch have delayed create */
  1222. features->quirks |= WACOM_QUIRK_NO_INPUT;
  1223. /* must be monitor interface if no device_type set */
  1224. if (!features->device_type)
  1225. features->quirks |= WACOM_QUIRK_MONITOR;
  1226. }
  1227. }
  1228. static unsigned int wacom_calculate_touch_res(unsigned int logical_max,
  1229. unsigned int physical_max)
  1230. {
  1231. /* Touch physical dimensions are in 100th of mm */
  1232. return (logical_max * 100) / physical_max;
  1233. }
  1234. static void wacom_abs_set_axis(struct input_dev *input_dev,
  1235. struct wacom_wac *wacom_wac)
  1236. {
  1237. struct wacom_features *features = &wacom_wac->features;
  1238. if (features->device_type == BTN_TOOL_PEN) {
  1239. input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
  1240. features->x_fuzz, 0);
  1241. input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
  1242. features->y_fuzz, 0);
  1243. input_set_abs_params(input_dev, ABS_PRESSURE, 0,
  1244. features->pressure_max, features->pressure_fuzz, 0);
  1245. /* penabled devices have fixed resolution for each model */
  1246. input_abs_set_res(input_dev, ABS_X, features->x_resolution);
  1247. input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
  1248. } else {
  1249. if (features->touch_max <= 2) {
  1250. input_set_abs_params(input_dev, ABS_X, 0,
  1251. features->x_max, features->x_fuzz, 0);
  1252. input_set_abs_params(input_dev, ABS_Y, 0,
  1253. features->y_max, features->y_fuzz, 0);
  1254. input_abs_set_res(input_dev, ABS_X,
  1255. wacom_calculate_touch_res(features->x_max,
  1256. features->x_phy));
  1257. input_abs_set_res(input_dev, ABS_Y,
  1258. wacom_calculate_touch_res(features->y_max,
  1259. features->y_phy));
  1260. }
  1261. if (features->touch_max > 1) {
  1262. input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
  1263. features->x_max, features->x_fuzz, 0);
  1264. input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
  1265. features->y_max, features->y_fuzz, 0);
  1266. input_abs_set_res(input_dev, ABS_MT_POSITION_X,
  1267. wacom_calculate_touch_res(features->x_max,
  1268. features->x_phy));
  1269. input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
  1270. wacom_calculate_touch_res(features->y_max,
  1271. features->y_phy));
  1272. }
  1273. }
  1274. }
  1275. int wacom_setup_input_capabilities(struct input_dev *input_dev,
  1276. struct wacom_wac *wacom_wac)
  1277. {
  1278. struct wacom_features *features = &wacom_wac->features;
  1279. int i;
  1280. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  1281. __set_bit(BTN_TOUCH, input_dev->keybit);
  1282. __set_bit(ABS_MISC, input_dev->absbit);
  1283. wacom_abs_set_axis(input_dev, wacom_wac);
  1284. switch (wacom_wac->features.type) {
  1285. case WACOM_MO:
  1286. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  1287. /* fall through */
  1288. case WACOM_G4:
  1289. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  1290. __set_bit(BTN_BACK, input_dev->keybit);
  1291. __set_bit(BTN_FORWARD, input_dev->keybit);
  1292. /* fall through */
  1293. case GRAPHIRE:
  1294. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1295. __set_bit(BTN_LEFT, input_dev->keybit);
  1296. __set_bit(BTN_RIGHT, input_dev->keybit);
  1297. __set_bit(BTN_MIDDLE, input_dev->keybit);
  1298. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1299. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1300. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1301. __set_bit(BTN_STYLUS, input_dev->keybit);
  1302. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1303. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1304. break;
  1305. case WACOM_24HD:
  1306. __set_bit(BTN_A, input_dev->keybit);
  1307. __set_bit(BTN_B, input_dev->keybit);
  1308. __set_bit(BTN_C, input_dev->keybit);
  1309. __set_bit(BTN_X, input_dev->keybit);
  1310. __set_bit(BTN_Y, input_dev->keybit);
  1311. __set_bit(BTN_Z, input_dev->keybit);
  1312. for (i = 6; i < 10; i++)
  1313. __set_bit(BTN_0 + i, input_dev->keybit);
  1314. __set_bit(KEY_PROG1, input_dev->keybit);
  1315. __set_bit(KEY_PROG2, input_dev->keybit);
  1316. __set_bit(KEY_PROG3, input_dev->keybit);
  1317. /* fall through */
  1318. case DTK:
  1319. for (i = 0; i < 6; i++)
  1320. __set_bit(BTN_0 + i, input_dev->keybit);
  1321. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1322. input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
  1323. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1324. wacom_setup_cintiq(wacom_wac);
  1325. break;
  1326. case WACOM_22HD:
  1327. __set_bit(KEY_PROG1, input_dev->keybit);
  1328. __set_bit(KEY_PROG2, input_dev->keybit);
  1329. __set_bit(KEY_PROG3, input_dev->keybit);
  1330. /* fall through */
  1331. case WACOM_21UX2:
  1332. __set_bit(BTN_A, input_dev->keybit);
  1333. __set_bit(BTN_B, input_dev->keybit);
  1334. __set_bit(BTN_C, input_dev->keybit);
  1335. __set_bit(BTN_X, input_dev->keybit);
  1336. __set_bit(BTN_Y, input_dev->keybit);
  1337. __set_bit(BTN_Z, input_dev->keybit);
  1338. __set_bit(BTN_BASE, input_dev->keybit);
  1339. __set_bit(BTN_BASE2, input_dev->keybit);
  1340. /* fall through */
  1341. case WACOM_BEE:
  1342. __set_bit(BTN_8, input_dev->keybit);
  1343. __set_bit(BTN_9, input_dev->keybit);
  1344. /* fall through */
  1345. case CINTIQ:
  1346. for (i = 0; i < 8; i++)
  1347. __set_bit(BTN_0 + i, input_dev->keybit);
  1348. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  1349. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  1350. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1351. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1352. wacom_setup_cintiq(wacom_wac);
  1353. break;
  1354. case INTUOS3:
  1355. case INTUOS3L:
  1356. __set_bit(BTN_4, input_dev->keybit);
  1357. __set_bit(BTN_5, input_dev->keybit);
  1358. __set_bit(BTN_6, input_dev->keybit);
  1359. __set_bit(BTN_7, input_dev->keybit);
  1360. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  1361. /* fall through */
  1362. case INTUOS3S:
  1363. __set_bit(BTN_0, input_dev->keybit);
  1364. __set_bit(BTN_1, input_dev->keybit);
  1365. __set_bit(BTN_2, input_dev->keybit);
  1366. __set_bit(BTN_3, input_dev->keybit);
  1367. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  1368. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1369. /* fall through */
  1370. case INTUOS:
  1371. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1372. wacom_setup_intuos(wacom_wac);
  1373. break;
  1374. case INTUOS5:
  1375. case INTUOS5L:
  1376. if (features->device_type == BTN_TOOL_PEN) {
  1377. __set_bit(BTN_7, input_dev->keybit);
  1378. __set_bit(BTN_8, input_dev->keybit);
  1379. }
  1380. /* fall through */
  1381. case INTUOS5S:
  1382. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1383. if (features->device_type == BTN_TOOL_PEN) {
  1384. for (i = 0; i < 7; i++)
  1385. __set_bit(BTN_0 + i, input_dev->keybit);
  1386. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  1387. features->distance_max,
  1388. 0, 0);
  1389. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1390. wacom_setup_intuos(wacom_wac);
  1391. } else if (features->device_type == BTN_TOOL_FINGER) {
  1392. __clear_bit(ABS_MISC, input_dev->absbit);
  1393. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
  1394. 0, features->x_max, 0, 0);
  1395. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
  1396. 0, features->y_max, 0, 0);
  1397. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  1398. }
  1399. break;
  1400. case INTUOS4:
  1401. case INTUOS4L:
  1402. __set_bit(BTN_7, input_dev->keybit);
  1403. __set_bit(BTN_8, input_dev->keybit);
  1404. /* fall through */
  1405. case INTUOS4S:
  1406. for (i = 0; i < 7; i++)
  1407. __set_bit(BTN_0 + i, input_dev->keybit);
  1408. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1409. wacom_setup_intuos(wacom_wac);
  1410. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1411. break;
  1412. case WACOM_24HDT:
  1413. if (features->device_type == BTN_TOOL_FINGER) {
  1414. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  1415. input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
  1416. input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
  1417. input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  1418. }
  1419. /* fall through */
  1420. case MTSCREEN:
  1421. case MTTPC:
  1422. case TABLETPC2FG:
  1423. if (features->device_type == BTN_TOOL_FINGER) {
  1424. unsigned int flags = INPUT_MT_DIRECT;
  1425. if (wacom_wac->features.type == TABLETPC2FG)
  1426. flags = 0;
  1427. input_mt_init_slots(input_dev, features->touch_max, flags);
  1428. }
  1429. /* fall through */
  1430. case TABLETPC:
  1431. case TABLETPCE:
  1432. __clear_bit(ABS_MISC, input_dev->absbit);
  1433. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1434. if (features->device_type != BTN_TOOL_PEN)
  1435. break; /* no need to process stylus stuff */
  1436. /* fall through */
  1437. case PL:
  1438. case DTU:
  1439. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1440. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1441. __set_bit(BTN_STYLUS, input_dev->keybit);
  1442. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1443. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1444. break;
  1445. case PTU:
  1446. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1447. /* fall through */
  1448. case PENPARTNER:
  1449. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1450. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1451. __set_bit(BTN_STYLUS, input_dev->keybit);
  1452. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1453. break;
  1454. case BAMBOO_PT:
  1455. __clear_bit(ABS_MISC, input_dev->absbit);
  1456. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1457. if (features->device_type == BTN_TOOL_FINGER) {
  1458. unsigned int flags = INPUT_MT_POINTER;
  1459. __set_bit(BTN_LEFT, input_dev->keybit);
  1460. __set_bit(BTN_FORWARD, input_dev->keybit);
  1461. __set_bit(BTN_BACK, input_dev->keybit);
  1462. __set_bit(BTN_RIGHT, input_dev->keybit);
  1463. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  1464. input_set_abs_params(input_dev,
  1465. ABS_MT_TOUCH_MAJOR,
  1466. 0, features->x_max, 0, 0);
  1467. input_set_abs_params(input_dev,
  1468. ABS_MT_TOUCH_MINOR,
  1469. 0, features->y_max, 0, 0);
  1470. } else {
  1471. __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
  1472. __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
  1473. flags = 0;
  1474. }
  1475. input_mt_init_slots(input_dev, features->touch_max, flags);
  1476. } else if (features->device_type == BTN_TOOL_PEN) {
  1477. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1478. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1479. __set_bit(BTN_STYLUS, input_dev->keybit);
  1480. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1481. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  1482. features->distance_max,
  1483. 0, 0);
  1484. }
  1485. break;
  1486. }
  1487. return 0;
  1488. }
  1489. static const struct wacom_features wacom_features_0x00 =
  1490. { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
  1491. 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  1492. static const struct wacom_features wacom_features_0x10 =
  1493. { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
  1494. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1495. static const struct wacom_features wacom_features_0x11 =
  1496. { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
  1497. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1498. static const struct wacom_features wacom_features_0x12 =
  1499. { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
  1500. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1501. static const struct wacom_features wacom_features_0x13 =
  1502. { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
  1503. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1504. static const struct wacom_features wacom_features_0x14 =
  1505. { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
  1506. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1507. static const struct wacom_features wacom_features_0x15 =
  1508. { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
  1509. 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1510. static const struct wacom_features wacom_features_0x16 =
  1511. { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
  1512. 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1513. static const struct wacom_features wacom_features_0x17 =
  1514. { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
  1515. 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1516. static const struct wacom_features wacom_features_0x18 =
  1517. { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
  1518. 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1519. static const struct wacom_features wacom_features_0x19 =
  1520. { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
  1521. 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  1522. static const struct wacom_features wacom_features_0x60 =
  1523. { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
  1524. 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  1525. static const struct wacom_features wacom_features_0x61 =
  1526. { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
  1527. 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  1528. static const struct wacom_features wacom_features_0x62 =
  1529. { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
  1530. 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  1531. static const struct wacom_features wacom_features_0x63 =
  1532. { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
  1533. 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  1534. static const struct wacom_features wacom_features_0x64 =
  1535. { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
  1536. 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  1537. static const struct wacom_features wacom_features_0x65 =
  1538. { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
  1539. 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1540. static const struct wacom_features wacom_features_0x69 =
  1541. { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
  1542. 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  1543. static const struct wacom_features wacom_features_0x6A =
  1544. { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
  1545. 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1546. static const struct wacom_features wacom_features_0x6B =
  1547. { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
  1548. 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1549. static const struct wacom_features wacom_features_0x20 =
  1550. { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
  1551. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1552. static const struct wacom_features wacom_features_0x21 =
  1553. { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
  1554. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1555. static const struct wacom_features wacom_features_0x22 =
  1556. { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
  1557. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1558. static const struct wacom_features wacom_features_0x23 =
  1559. { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
  1560. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1561. static const struct wacom_features wacom_features_0x24 =
  1562. { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
  1563. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1564. static const struct wacom_features wacom_features_0x30 =
  1565. { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
  1566. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1567. static const struct wacom_features wacom_features_0x31 =
  1568. { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
  1569. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1570. static const struct wacom_features wacom_features_0x32 =
  1571. { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
  1572. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1573. static const struct wacom_features wacom_features_0x33 =
  1574. { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
  1575. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1576. static const struct wacom_features wacom_features_0x34 =
  1577. { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
  1578. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1579. static const struct wacom_features wacom_features_0x35 =
  1580. { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
  1581. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1582. static const struct wacom_features wacom_features_0x37 =
  1583. { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
  1584. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1585. static const struct wacom_features wacom_features_0x38 =
  1586. { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
  1587. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1588. static const struct wacom_features wacom_features_0x39 =
  1589. { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
  1590. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1591. static const struct wacom_features wacom_features_0xC4 =
  1592. { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
  1593. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1594. static const struct wacom_features wacom_features_0xC0 =
  1595. { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
  1596. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1597. static const struct wacom_features wacom_features_0xC2 =
  1598. { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
  1599. 0, PL, WACOM_PL_RES, WACOM_PL_RES };
  1600. static const struct wacom_features wacom_features_0x03 =
  1601. { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
  1602. 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
  1603. static const struct wacom_features wacom_features_0x41 =
  1604. { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
  1605. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1606. static const struct wacom_features wacom_features_0x42 =
  1607. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
  1608. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1609. static const struct wacom_features wacom_features_0x43 =
  1610. { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
  1611. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1612. static const struct wacom_features wacom_features_0x44 =
  1613. { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
  1614. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1615. static const struct wacom_features wacom_features_0x45 =
  1616. { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
  1617. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1618. static const struct wacom_features wacom_features_0xB0 =
  1619. { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
  1620. 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1621. static const struct wacom_features wacom_features_0xB1 =
  1622. { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
  1623. 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1624. static const struct wacom_features wacom_features_0xB2 =
  1625. { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
  1626. 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1627. static const struct wacom_features wacom_features_0xB3 =
  1628. { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
  1629. 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1630. static const struct wacom_features wacom_features_0xB4 =
  1631. { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
  1632. 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1633. static const struct wacom_features wacom_features_0xB5 =
  1634. { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
  1635. 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1636. static const struct wacom_features wacom_features_0xB7 =
  1637. { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
  1638. 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1639. static const struct wacom_features wacom_features_0xB8 =
  1640. { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
  1641. 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1642. static const struct wacom_features wacom_features_0xB9 =
  1643. { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
  1644. 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1645. static const struct wacom_features wacom_features_0xBA =
  1646. { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
  1647. 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1648. static const struct wacom_features wacom_features_0xBB =
  1649. { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
  1650. 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1651. static const struct wacom_features wacom_features_0xBC =
  1652. { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047,
  1653. 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1654. static const struct wacom_features wacom_features_0x26 =
  1655. { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
  1656. 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
  1657. .touch_max = 16 };
  1658. static const struct wacom_features wacom_features_0x27 =
  1659. { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
  1660. 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
  1661. .touch_max = 16 };
  1662. static const struct wacom_features wacom_features_0x28 =
  1663. { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
  1664. 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
  1665. .touch_max = 16 };
  1666. static const struct wacom_features wacom_features_0x29 =
  1667. { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
  1668. 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1669. static const struct wacom_features wacom_features_0x2A =
  1670. { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
  1671. 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1672. static const struct wacom_features wacom_features_0xF4 =
  1673. { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
  1674. 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1675. static const struct wacom_features wacom_features_0xF8 =
  1676. { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, /* Pen */
  1677. 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
  1678. static const struct wacom_features wacom_features_0xF6 =
  1679. { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
  1680. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10 };
  1681. static const struct wacom_features wacom_features_0x3F =
  1682. { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
  1683. 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1684. static const struct wacom_features wacom_features_0xC5 =
  1685. { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
  1686. 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1687. static const struct wacom_features wacom_features_0xC6 =
  1688. { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
  1689. 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1690. static const struct wacom_features wacom_features_0xC7 =
  1691. { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
  1692. 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1693. static const struct wacom_features wacom_features_0xCE =
  1694. { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
  1695. 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1696. static const struct wacom_features wacom_features_0xF0 =
  1697. { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
  1698. 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1699. static const struct wacom_features wacom_features_0x59 = /* Pen */
  1700. { "Wacom DTH2242", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
  1701. 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
  1702. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
  1703. static const struct wacom_features wacom_features_0x5D = /* Touch */
  1704. { "Wacom DTH2242", .type = WACOM_24HDT,
  1705. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10 };
  1706. static const struct wacom_features wacom_features_0xCC =
  1707. { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87200, 65600, 2047,
  1708. 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1709. static const struct wacom_features wacom_features_0xFA =
  1710. { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95840, 54260, 2047,
  1711. 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  1712. static const struct wacom_features wacom_features_0x90 =
  1713. { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1714. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1715. static const struct wacom_features wacom_features_0x93 =
  1716. { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1717. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1718. static const struct wacom_features wacom_features_0x97 =
  1719. { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
  1720. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1721. static const struct wacom_features wacom_features_0x9A =
  1722. { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1723. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1724. static const struct wacom_features wacom_features_0x9F =
  1725. { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1726. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1727. static const struct wacom_features wacom_features_0xE2 =
  1728. { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
  1729. 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1730. .touch_max = 2 };
  1731. static const struct wacom_features wacom_features_0xE3 =
  1732. { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
  1733. 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1734. .touch_max = 2 };
  1735. static const struct wacom_features wacom_features_0xE5 =
  1736. { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
  1737. 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1738. static const struct wacom_features wacom_features_0xE6 =
  1739. { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
  1740. 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1741. .touch_max = 2 };
  1742. static const struct wacom_features wacom_features_0xEC =
  1743. { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
  1744. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1745. static const struct wacom_features wacom_features_0xED =
  1746. { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1747. 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1748. static const struct wacom_features wacom_features_0xEF =
  1749. { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
  1750. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1751. static const struct wacom_features wacom_features_0x100 =
  1752. { "Wacom ISDv4 100", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
  1753. 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1754. static const struct wacom_features wacom_features_0x101 =
  1755. { "Wacom ISDv4 101", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
  1756. 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1757. static const struct wacom_features wacom_features_0x4001 =
  1758. { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
  1759. 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1760. static const struct wacom_features wacom_features_0x47 =
  1761. { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
  1762. 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1763. static const struct wacom_features wacom_features_0x84 =
  1764. { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
  1765. 0, WIRELESS, 0, 0, .touch_max = 16 };
  1766. static const struct wacom_features wacom_features_0xD0 =
  1767. { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1768. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1769. .touch_max = 2 };
  1770. static const struct wacom_features wacom_features_0xD1 =
  1771. { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1772. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1773. .touch_max = 2 };
  1774. static const struct wacom_features wacom_features_0xD2 =
  1775. { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1776. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1777. .touch_max = 2 };
  1778. static const struct wacom_features wacom_features_0xD3 =
  1779. { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
  1780. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1781. .touch_max = 2 };
  1782. static const struct wacom_features wacom_features_0xD4 =
  1783. { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1784. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1785. static const struct wacom_features wacom_features_0xD5 =
  1786. { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
  1787. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1788. static const struct wacom_features wacom_features_0xD6 =
  1789. { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1790. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1791. .touch_max = 2 };
  1792. static const struct wacom_features wacom_features_0xD7 =
  1793. { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1794. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1795. .touch_max = 2 };
  1796. static const struct wacom_features wacom_features_0xD8 =
  1797. { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
  1798. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1799. .touch_max = 2 };
  1800. static const struct wacom_features wacom_features_0xDA =
  1801. { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
  1802. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1803. .touch_max = 2 };
  1804. static struct wacom_features wacom_features_0xDB =
  1805. { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
  1806. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1807. .touch_max = 2 };
  1808. static const struct wacom_features wacom_features_0xDD =
  1809. { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
  1810. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1811. static const struct wacom_features wacom_features_0xDE =
  1812. { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
  1813. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1814. .touch_max = 16 };
  1815. static const struct wacom_features wacom_features_0xDF =
  1816. { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
  1817. 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  1818. .touch_max = 16 };
  1819. static const struct wacom_features wacom_features_0x6004 =
  1820. { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
  1821. 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  1822. #define USB_DEVICE_WACOM(prod) \
  1823. USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
  1824. .driver_info = (kernel_ulong_t)&wacom_features_##prod
  1825. #define USB_DEVICE_DETAILED(prod, class, sub, proto) \
  1826. USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
  1827. sub, proto), \
  1828. .driver_info = (kernel_ulong_t)&wacom_features_##prod
  1829. #define USB_DEVICE_LENOVO(prod) \
  1830. USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
  1831. .driver_info = (kernel_ulong_t)&wacom_features_##prod
  1832. const struct usb_device_id wacom_ids[] = {
  1833. { USB_DEVICE_WACOM(0x00) },
  1834. { USB_DEVICE_WACOM(0x10) },
  1835. { USB_DEVICE_WACOM(0x11) },
  1836. { USB_DEVICE_WACOM(0x12) },
  1837. { USB_DEVICE_WACOM(0x13) },
  1838. { USB_DEVICE_WACOM(0x14) },
  1839. { USB_DEVICE_WACOM(0x15) },
  1840. { USB_DEVICE_WACOM(0x16) },
  1841. { USB_DEVICE_WACOM(0x17) },
  1842. { USB_DEVICE_WACOM(0x18) },
  1843. { USB_DEVICE_WACOM(0x19) },
  1844. { USB_DEVICE_WACOM(0x60) },
  1845. { USB_DEVICE_WACOM(0x61) },
  1846. { USB_DEVICE_WACOM(0x62) },
  1847. { USB_DEVICE_WACOM(0x63) },
  1848. { USB_DEVICE_WACOM(0x64) },
  1849. { USB_DEVICE_WACOM(0x65) },
  1850. { USB_DEVICE_WACOM(0x69) },
  1851. { USB_DEVICE_WACOM(0x6A) },
  1852. { USB_DEVICE_WACOM(0x6B) },
  1853. { USB_DEVICE_WACOM(0x20) },
  1854. { USB_DEVICE_WACOM(0x21) },
  1855. { USB_DEVICE_WACOM(0x22) },
  1856. { USB_DEVICE_WACOM(0x23) },
  1857. { USB_DEVICE_WACOM(0x24) },
  1858. { USB_DEVICE_WACOM(0x30) },
  1859. { USB_DEVICE_WACOM(0x31) },
  1860. { USB_DEVICE_WACOM(0x32) },
  1861. { USB_DEVICE_WACOM(0x33) },
  1862. { USB_DEVICE_WACOM(0x34) },
  1863. { USB_DEVICE_WACOM(0x35) },
  1864. { USB_DEVICE_WACOM(0x37) },
  1865. { USB_DEVICE_WACOM(0x38) },
  1866. { USB_DEVICE_WACOM(0x39) },
  1867. { USB_DEVICE_WACOM(0xC4) },
  1868. { USB_DEVICE_WACOM(0xC0) },
  1869. { USB_DEVICE_WACOM(0xC2) },
  1870. { USB_DEVICE_WACOM(0x03) },
  1871. { USB_DEVICE_WACOM(0x41) },
  1872. { USB_DEVICE_WACOM(0x42) },
  1873. { USB_DEVICE_WACOM(0x43) },
  1874. { USB_DEVICE_WACOM(0x44) },
  1875. { USB_DEVICE_WACOM(0x45) },
  1876. { USB_DEVICE_WACOM(0x59) },
  1877. { USB_DEVICE_WACOM(0x5D) },
  1878. { USB_DEVICE_WACOM(0xB0) },
  1879. { USB_DEVICE_WACOM(0xB1) },
  1880. { USB_DEVICE_WACOM(0xB2) },
  1881. { USB_DEVICE_WACOM(0xB3) },
  1882. { USB_DEVICE_WACOM(0xB4) },
  1883. { USB_DEVICE_WACOM(0xB5) },
  1884. { USB_DEVICE_WACOM(0xB7) },
  1885. { USB_DEVICE_WACOM(0xB8) },
  1886. { USB_DEVICE_WACOM(0xB9) },
  1887. { USB_DEVICE_WACOM(0xBA) },
  1888. { USB_DEVICE_WACOM(0xBB) },
  1889. { USB_DEVICE_WACOM(0xBC) },
  1890. { USB_DEVICE_WACOM(0x26) },
  1891. { USB_DEVICE_WACOM(0x27) },
  1892. { USB_DEVICE_WACOM(0x28) },
  1893. { USB_DEVICE_WACOM(0x29) },
  1894. { USB_DEVICE_WACOM(0x2A) },
  1895. { USB_DEVICE_WACOM(0x3F) },
  1896. { USB_DEVICE_WACOM(0xC5) },
  1897. { USB_DEVICE_WACOM(0xC6) },
  1898. { USB_DEVICE_WACOM(0xC7) },
  1899. /*
  1900. * DTU-2231 has two interfaces on the same configuration,
  1901. * only one is used.
  1902. */
  1903. { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
  1904. USB_INTERFACE_SUBCLASS_BOOT,
  1905. USB_INTERFACE_PROTOCOL_MOUSE) },
  1906. { USB_DEVICE_WACOM(0x84) },
  1907. { USB_DEVICE_WACOM(0xD0) },
  1908. { USB_DEVICE_WACOM(0xD1) },
  1909. { USB_DEVICE_WACOM(0xD2) },
  1910. { USB_DEVICE_WACOM(0xD3) },
  1911. { USB_DEVICE_WACOM(0xD4) },
  1912. { USB_DEVICE_WACOM(0xD5) },
  1913. { USB_DEVICE_WACOM(0xD6) },
  1914. { USB_DEVICE_WACOM(0xD7) },
  1915. { USB_DEVICE_WACOM(0xD8) },
  1916. { USB_DEVICE_WACOM(0xDA) },
  1917. { USB_DEVICE_WACOM(0xDB) },
  1918. { USB_DEVICE_WACOM(0xDD) },
  1919. { USB_DEVICE_WACOM(0xDE) },
  1920. { USB_DEVICE_WACOM(0xDF) },
  1921. { USB_DEVICE_WACOM(0xF0) },
  1922. { USB_DEVICE_WACOM(0xCC) },
  1923. { USB_DEVICE_WACOM(0x90) },
  1924. { USB_DEVICE_WACOM(0x93) },
  1925. { USB_DEVICE_WACOM(0x97) },
  1926. { USB_DEVICE_WACOM(0x9A) },
  1927. { USB_DEVICE_WACOM(0x9F) },
  1928. { USB_DEVICE_WACOM(0xE2) },
  1929. { USB_DEVICE_WACOM(0xE3) },
  1930. { USB_DEVICE_WACOM(0xE5) },
  1931. { USB_DEVICE_WACOM(0xE6) },
  1932. { USB_DEVICE_WACOM(0xEC) },
  1933. { USB_DEVICE_WACOM(0xED) },
  1934. { USB_DEVICE_WACOM(0xEF) },
  1935. { USB_DEVICE_WACOM(0x100) },
  1936. { USB_DEVICE_WACOM(0x101) },
  1937. { USB_DEVICE_WACOM(0x4001) },
  1938. { USB_DEVICE_WACOM(0x47) },
  1939. { USB_DEVICE_WACOM(0xF4) },
  1940. { USB_DEVICE_WACOM(0xF8) },
  1941. { USB_DEVICE_WACOM(0xF6) },
  1942. { USB_DEVICE_WACOM(0xFA) },
  1943. { USB_DEVICE_LENOVO(0x6004) },
  1944. { }
  1945. };
  1946. MODULE_DEVICE_TABLE(usb, wacom_ids);