wacom_wac.c 67 KB

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