wacom_wac.c 58 KB

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