wacom_wac.c 89 KB

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