wacom_wac.c 70 KB

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