wacom_wac.c 55 KB

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