wacom_wac.c 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033
  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 void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage,
  1109. struct hid_field *field, __u8 type, __u16 code, int fuzz)
  1110. {
  1111. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1112. struct input_dev *input = wacom_wac->input;
  1113. int fmin = field->logical_minimum;
  1114. int fmax = field->logical_maximum;
  1115. usage->type = type;
  1116. usage->code = code;
  1117. set_bit(type, input->evbit);
  1118. switch (type) {
  1119. case EV_ABS:
  1120. input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
  1121. input_abs_set_res(input, code,
  1122. hidinput_calc_abs_res(field, code));
  1123. break;
  1124. case EV_KEY:
  1125. input_set_capability(input, EV_KEY, code);
  1126. break;
  1127. case EV_MSC:
  1128. input_set_capability(input, EV_MSC, code);
  1129. break;
  1130. }
  1131. }
  1132. static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
  1133. struct hid_field *field, struct hid_usage *usage)
  1134. {
  1135. struct wacom *wacom = hid_get_drvdata(hdev);
  1136. switch (usage->hid) {
  1137. case HID_GD_X:
  1138. wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
  1139. break;
  1140. case HID_GD_Y:
  1141. wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
  1142. break;
  1143. case HID_DG_TIPPRESSURE:
  1144. wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0);
  1145. break;
  1146. case HID_DG_INRANGE:
  1147. wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
  1148. break;
  1149. case HID_DG_INVERT:
  1150. wacom_map_usage(wacom, usage, field, EV_KEY,
  1151. BTN_TOOL_RUBBER, 0);
  1152. break;
  1153. case HID_DG_ERASER:
  1154. case HID_DG_TIPSWITCH:
  1155. wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
  1156. break;
  1157. case HID_DG_BARRELSWITCH:
  1158. wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0);
  1159. break;
  1160. case HID_DG_BARRELSWITCH2:
  1161. wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0);
  1162. break;
  1163. case HID_DG_TOOLSERIALNUMBER:
  1164. wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0);
  1165. break;
  1166. }
  1167. }
  1168. static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
  1169. struct hid_usage *usage, __s32 value)
  1170. {
  1171. struct wacom *wacom = hid_get_drvdata(hdev);
  1172. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1173. struct input_dev *input = wacom_wac->input;
  1174. /* checking which Tool / tip switch to send */
  1175. switch (usage->hid) {
  1176. case HID_DG_INRANGE:
  1177. wacom_wac->hid_data.inrange_state = value;
  1178. return 0;
  1179. case HID_DG_INVERT:
  1180. wacom_wac->hid_data.invert_state = value;
  1181. return 0;
  1182. case HID_DG_ERASER:
  1183. case HID_DG_TIPSWITCH:
  1184. wacom_wac->hid_data.tipswitch |= value;
  1185. return 0;
  1186. }
  1187. /* send pen events only when touch is up or forced out */
  1188. if (!usage->type || wacom_wac->shared->touch_down)
  1189. return 0;
  1190. input_event(input, usage->type, usage->code, value);
  1191. return 0;
  1192. }
  1193. static void wacom_wac_pen_report(struct hid_device *hdev,
  1194. struct hid_report *report)
  1195. {
  1196. struct wacom *wacom = hid_get_drvdata(hdev);
  1197. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1198. struct input_dev *input = wacom_wac->input;
  1199. bool prox = wacom_wac->hid_data.inrange_state;
  1200. if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
  1201. /* Going into proximity select tool */
  1202. wacom_wac->tool[0] = wacom_wac->hid_data.invert_state ?
  1203. BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  1204. /* keep pen state for touch events */
  1205. wacom_wac->shared->stylus_in_proximity = prox;
  1206. /* send pen events only when touch is up or forced out */
  1207. if (!wacom_wac->shared->touch_down) {
  1208. input_report_key(input, BTN_TOUCH,
  1209. wacom_wac->hid_data.tipswitch);
  1210. input_report_key(input, wacom_wac->tool[0], prox);
  1211. wacom_wac->hid_data.tipswitch = false;
  1212. input_sync(input);
  1213. }
  1214. }
  1215. static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
  1216. struct hid_field *field, struct hid_usage *usage)
  1217. {
  1218. struct wacom *wacom = hid_get_drvdata(hdev);
  1219. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1220. struct input_dev *input = wacom_wac->input;
  1221. unsigned touch_max = wacom_wac->features.touch_max;
  1222. switch (usage->hid) {
  1223. case HID_GD_X:
  1224. if (touch_max == 1)
  1225. wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
  1226. else
  1227. wacom_map_usage(wacom, usage, field, EV_ABS,
  1228. ABS_MT_POSITION_X, 4);
  1229. break;
  1230. case HID_GD_Y:
  1231. if (touch_max == 1)
  1232. wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
  1233. else
  1234. wacom_map_usage(wacom, usage, field, EV_ABS,
  1235. ABS_MT_POSITION_Y, 4);
  1236. break;
  1237. case HID_DG_CONTACTID:
  1238. input_mt_init_slots(input, wacom_wac->features.touch_max,
  1239. INPUT_MT_DIRECT);
  1240. break;
  1241. case HID_DG_INRANGE:
  1242. break;
  1243. case HID_DG_INVERT:
  1244. break;
  1245. case HID_DG_TIPSWITCH:
  1246. wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
  1247. break;
  1248. }
  1249. }
  1250. static int wacom_wac_finger_event(struct hid_device *hdev,
  1251. struct hid_field *field, struct hid_usage *usage, __s32 value)
  1252. {
  1253. struct wacom *wacom = hid_get_drvdata(hdev);
  1254. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1255. switch (usage->hid) {
  1256. case HID_GD_X:
  1257. wacom_wac->hid_data.x = value;
  1258. break;
  1259. case HID_GD_Y:
  1260. wacom_wac->hid_data.y = value;
  1261. break;
  1262. case HID_DG_CONTACTID:
  1263. wacom_wac->hid_data.id = value;
  1264. break;
  1265. case HID_DG_TIPSWITCH:
  1266. wacom_wac->hid_data.tipswitch = value;
  1267. break;
  1268. }
  1269. return 0;
  1270. }
  1271. static void wacom_wac_finger_mt_report(struct wacom_wac *wacom_wac,
  1272. struct input_dev *input, bool touch)
  1273. {
  1274. int slot;
  1275. struct hid_data *hid_data = &wacom_wac->hid_data;
  1276. slot = input_mt_get_slot_by_key(input, hid_data->id);
  1277. input_mt_slot(input, slot);
  1278. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1279. if (touch) {
  1280. input_report_abs(input, ABS_MT_POSITION_X, hid_data->x);
  1281. input_report_abs(input, ABS_MT_POSITION_Y, hid_data->y);
  1282. }
  1283. input_mt_sync_frame(input);
  1284. }
  1285. static void wacom_wac_finger_single_touch_report(struct wacom_wac *wacom_wac,
  1286. struct input_dev *input, bool touch)
  1287. {
  1288. struct hid_data *hid_data = &wacom_wac->hid_data;
  1289. if (touch) {
  1290. input_report_abs(input, ABS_X, hid_data->x);
  1291. input_report_abs(input, ABS_Y, hid_data->y);
  1292. }
  1293. input_report_key(input, BTN_TOUCH, touch);
  1294. }
  1295. static void wacom_wac_finger_report(struct hid_device *hdev,
  1296. struct hid_report *report)
  1297. {
  1298. struct wacom *wacom = hid_get_drvdata(hdev);
  1299. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1300. struct input_dev *input = wacom_wac->input;
  1301. bool touch = wacom_wac->hid_data.tipswitch &&
  1302. !wacom_wac->shared->stylus_in_proximity;
  1303. unsigned touch_max = wacom_wac->features.touch_max;
  1304. if (touch_max > 1)
  1305. wacom_wac_finger_mt_report(wacom_wac, input, touch);
  1306. else
  1307. wacom_wac_finger_single_touch_report(wacom_wac, input, touch);
  1308. input_sync(input);
  1309. /* keep touch state for pen event */
  1310. wacom_wac->shared->touch_down = touch;
  1311. }
  1312. #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
  1313. ((f)->physical == HID_DG_STYLUS))
  1314. #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
  1315. ((f)->physical == HID_DG_FINGER))
  1316. void wacom_wac_usage_mapping(struct hid_device *hdev,
  1317. struct hid_field *field, struct hid_usage *usage)
  1318. {
  1319. struct wacom *wacom = hid_get_drvdata(hdev);
  1320. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1321. struct input_dev *input = wacom_wac->input;
  1322. /* currently, only direct devices have proper hid report descriptors */
  1323. __set_bit(INPUT_PROP_DIRECT, input->propbit);
  1324. if (WACOM_PEN_FIELD(field))
  1325. return wacom_wac_pen_usage_mapping(hdev, field, usage);
  1326. if (WACOM_FINGER_FIELD(field))
  1327. return wacom_wac_finger_usage_mapping(hdev, field, usage);
  1328. }
  1329. int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
  1330. struct hid_usage *usage, __s32 value)
  1331. {
  1332. struct wacom *wacom = hid_get_drvdata(hdev);
  1333. if (wacom->wacom_wac.features.type != HID_GENERIC)
  1334. return 0;
  1335. if (WACOM_PEN_FIELD(field))
  1336. return wacom_wac_pen_event(hdev, field, usage, value);
  1337. if (WACOM_FINGER_FIELD(field))
  1338. return wacom_wac_finger_event(hdev, field, usage, value);
  1339. return 0;
  1340. }
  1341. void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
  1342. {
  1343. struct wacom *wacom = hid_get_drvdata(hdev);
  1344. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1345. struct hid_field *field = report->field[0];
  1346. if (wacom_wac->features.type != HID_GENERIC)
  1347. return;
  1348. if (WACOM_PEN_FIELD(field))
  1349. return wacom_wac_pen_report(hdev, report);
  1350. if (WACOM_FINGER_FIELD(field))
  1351. return wacom_wac_finger_report(hdev, report);
  1352. }
  1353. static int wacom_bpt_touch(struct wacom_wac *wacom)
  1354. {
  1355. struct wacom_features *features = &wacom->features;
  1356. struct input_dev *input = wacom->input;
  1357. struct input_dev *pad_input = wacom->pad_input;
  1358. unsigned char *data = wacom->data;
  1359. int i;
  1360. if (data[0] != 0x02)
  1361. return 0;
  1362. for (i = 0; i < 2; i++) {
  1363. int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
  1364. bool touch = data[offset + 3] & 0x80;
  1365. /*
  1366. * Touch events need to be disabled while stylus is
  1367. * in proximity because user's hand is resting on touchpad
  1368. * and sending unwanted events. User expects tablet buttons
  1369. * to continue working though.
  1370. */
  1371. touch = touch && !wacom->shared->stylus_in_proximity;
  1372. input_mt_slot(input, i);
  1373. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1374. if (touch) {
  1375. int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
  1376. int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
  1377. if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
  1378. x <<= 5;
  1379. y <<= 5;
  1380. }
  1381. input_report_abs(input, ABS_MT_POSITION_X, x);
  1382. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1383. }
  1384. }
  1385. input_mt_report_pointer_emulation(input, true);
  1386. input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
  1387. input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
  1388. input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
  1389. input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
  1390. return 1;
  1391. }
  1392. static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
  1393. {
  1394. struct wacom_features *features = &wacom->features;
  1395. struct input_dev *input = wacom->input;
  1396. bool touch = data[1] & 0x80;
  1397. int slot = input_mt_get_slot_by_key(input, data[0]);
  1398. if (slot < 0)
  1399. return;
  1400. touch = touch && !wacom->shared->stylus_in_proximity;
  1401. input_mt_slot(input, slot);
  1402. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1403. if (touch) {
  1404. int x = (data[2] << 4) | (data[4] >> 4);
  1405. int y = (data[3] << 4) | (data[4] & 0x0f);
  1406. int width, height;
  1407. if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
  1408. width = data[5] * 100;
  1409. height = data[6] * 100;
  1410. } else {
  1411. /*
  1412. * "a" is a scaled-down area which we assume is
  1413. * roughly circular and which can be described as:
  1414. * a=(pi*r^2)/C.
  1415. */
  1416. int a = data[5];
  1417. int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
  1418. int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
  1419. width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
  1420. height = width * y_res / x_res;
  1421. }
  1422. input_report_abs(input, ABS_MT_POSITION_X, x);
  1423. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1424. input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
  1425. input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
  1426. }
  1427. }
  1428. static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
  1429. {
  1430. struct input_dev *input = wacom->pad_input;
  1431. struct wacom_features *features = &wacom->features;
  1432. if (features->type == INTUOSHT) {
  1433. input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
  1434. input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
  1435. } else {
  1436. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  1437. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  1438. }
  1439. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  1440. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  1441. }
  1442. static int wacom_bpt3_touch(struct wacom_wac *wacom)
  1443. {
  1444. struct input_dev *input = wacom->input;
  1445. unsigned char *data = wacom->data;
  1446. int count = data[1] & 0x07;
  1447. int i;
  1448. if (data[0] != 0x02)
  1449. return 0;
  1450. /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
  1451. for (i = 0; i < count; i++) {
  1452. int offset = (8 * i) + 2;
  1453. int msg_id = data[offset];
  1454. if (msg_id >= 2 && msg_id <= 17)
  1455. wacom_bpt3_touch_msg(wacom, data + offset);
  1456. else if (msg_id == 128)
  1457. wacom_bpt3_button_msg(wacom, data + offset);
  1458. }
  1459. input_mt_report_pointer_emulation(input, true);
  1460. return 1;
  1461. }
  1462. static int wacom_bpt_pen(struct wacom_wac *wacom)
  1463. {
  1464. struct wacom_features *features = &wacom->features;
  1465. struct input_dev *input = wacom->input;
  1466. unsigned char *data = wacom->data;
  1467. int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
  1468. if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
  1469. return 0;
  1470. if (data[0] == WACOM_REPORT_USB) {
  1471. if (features->type == INTUOSHT && features->touch_max) {
  1472. input_report_switch(wacom->shared->touch_input,
  1473. SW_MUTE_DEVICE, data[8] & 0x40);
  1474. input_sync(wacom->shared->touch_input);
  1475. }
  1476. return 0;
  1477. }
  1478. prox = (data[1] & 0x20) == 0x20;
  1479. /*
  1480. * All reports shared between PEN and RUBBER tool must be
  1481. * forced to a known starting value (zero) when transitioning to
  1482. * out-of-prox.
  1483. *
  1484. * If not reset then, to userspace, it will look like lost events
  1485. * if new tool comes in-prox with same values as previous tool sent.
  1486. *
  1487. * Hardware does report zero in most out-of-prox cases but not all.
  1488. */
  1489. if (prox) {
  1490. if (!wacom->shared->stylus_in_proximity) {
  1491. if (data[1] & 0x08) {
  1492. wacom->tool[0] = BTN_TOOL_RUBBER;
  1493. wacom->id[0] = ERASER_DEVICE_ID;
  1494. } else {
  1495. wacom->tool[0] = BTN_TOOL_PEN;
  1496. wacom->id[0] = STYLUS_DEVICE_ID;
  1497. }
  1498. wacom->shared->stylus_in_proximity = true;
  1499. }
  1500. x = le16_to_cpup((__le16 *)&data[2]);
  1501. y = le16_to_cpup((__le16 *)&data[4]);
  1502. p = le16_to_cpup((__le16 *)&data[6]);
  1503. /*
  1504. * Convert distance from out prox to distance from tablet.
  1505. * distance will be greater than distance_max once
  1506. * touching and applying pressure; do not report negative
  1507. * distance.
  1508. */
  1509. if (data[8] <= features->distance_max)
  1510. d = features->distance_max - data[8];
  1511. pen = data[1] & 0x01;
  1512. btn1 = data[1] & 0x02;
  1513. btn2 = data[1] & 0x04;
  1514. }
  1515. input_report_key(input, BTN_TOUCH, pen);
  1516. input_report_key(input, BTN_STYLUS, btn1);
  1517. input_report_key(input, BTN_STYLUS2, btn2);
  1518. input_report_abs(input, ABS_X, x);
  1519. input_report_abs(input, ABS_Y, y);
  1520. input_report_abs(input, ABS_PRESSURE, p);
  1521. input_report_abs(input, ABS_DISTANCE, d);
  1522. if (!prox) {
  1523. wacom->id[0] = 0;
  1524. wacom->shared->stylus_in_proximity = false;
  1525. }
  1526. input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
  1527. input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
  1528. return 1;
  1529. }
  1530. static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  1531. {
  1532. if (len == WACOM_PKGLEN_BBTOUCH)
  1533. return wacom_bpt_touch(wacom);
  1534. else if (len == WACOM_PKGLEN_BBTOUCH3)
  1535. return wacom_bpt3_touch(wacom);
  1536. else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
  1537. return wacom_bpt_pen(wacom);
  1538. return 0;
  1539. }
  1540. static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
  1541. {
  1542. unsigned char *data = wacom->data;
  1543. int connected;
  1544. if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
  1545. return 0;
  1546. connected = data[1] & 0x01;
  1547. if (connected) {
  1548. int pid, battery, ps_connected;
  1549. if ((wacom->shared->type == INTUOSHT) &&
  1550. wacom->shared->touch_max) {
  1551. input_report_switch(wacom->shared->touch_input,
  1552. SW_MUTE_DEVICE, data[5] & 0x40);
  1553. input_sync(wacom->shared->touch_input);
  1554. }
  1555. pid = get_unaligned_be16(&data[6]);
  1556. battery = (data[5] & 0x3f) * 100 / 31;
  1557. ps_connected = !!(data[5] & 0x80);
  1558. if (wacom->pid != pid) {
  1559. wacom->pid = pid;
  1560. wacom_schedule_work(wacom);
  1561. }
  1562. if (wacom->shared->type &&
  1563. (battery != wacom->battery_capacity ||
  1564. ps_connected != wacom->ps_connected)) {
  1565. wacom->battery_capacity = battery;
  1566. wacom->ps_connected = ps_connected;
  1567. wacom->bat_charging = ps_connected &&
  1568. wacom->battery_capacity < 100;
  1569. wacom_notify_battery(wacom);
  1570. }
  1571. } else if (wacom->pid != 0) {
  1572. /* disconnected while previously connected */
  1573. wacom->pid = 0;
  1574. wacom_schedule_work(wacom);
  1575. wacom->battery_capacity = 0;
  1576. wacom->bat_charging = 0;
  1577. wacom->ps_connected = 0;
  1578. }
  1579. return 0;
  1580. }
  1581. void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  1582. {
  1583. bool sync;
  1584. switch (wacom_wac->features.type) {
  1585. case PENPARTNER:
  1586. sync = wacom_penpartner_irq(wacom_wac);
  1587. break;
  1588. case PL:
  1589. sync = wacom_pl_irq(wacom_wac);
  1590. break;
  1591. case WACOM_G4:
  1592. case GRAPHIRE:
  1593. case GRAPHIRE_BT:
  1594. case WACOM_MO:
  1595. sync = wacom_graphire_irq(wacom_wac);
  1596. break;
  1597. case PTU:
  1598. sync = wacom_ptu_irq(wacom_wac);
  1599. break;
  1600. case DTU:
  1601. sync = wacom_dtu_irq(wacom_wac);
  1602. break;
  1603. case DTUS:
  1604. sync = wacom_dtus_irq(wacom_wac);
  1605. break;
  1606. case INTUOS:
  1607. case INTUOS3S:
  1608. case INTUOS3:
  1609. case INTUOS3L:
  1610. case INTUOS4S:
  1611. case INTUOS4:
  1612. case INTUOS4L:
  1613. case CINTIQ:
  1614. case WACOM_BEE:
  1615. case WACOM_13HD:
  1616. case WACOM_21UX2:
  1617. case WACOM_22HD:
  1618. case WACOM_24HD:
  1619. case DTK:
  1620. case CINTIQ_HYBRID:
  1621. sync = wacom_intuos_irq(wacom_wac);
  1622. break;
  1623. case INTUOS4WL:
  1624. sync = wacom_intuos_bt_irq(wacom_wac, len);
  1625. break;
  1626. case WACOM_24HDT:
  1627. sync = wacom_24hdt_irq(wacom_wac);
  1628. break;
  1629. case INTUOS5S:
  1630. case INTUOS5:
  1631. case INTUOS5L:
  1632. case INTUOSPS:
  1633. case INTUOSPM:
  1634. case INTUOSPL:
  1635. if (len == WACOM_PKGLEN_BBTOUCH3)
  1636. sync = wacom_bpt3_touch(wacom_wac);
  1637. else
  1638. sync = wacom_intuos_irq(wacom_wac);
  1639. break;
  1640. case TABLETPC:
  1641. case TABLETPCE:
  1642. case TABLETPC2FG:
  1643. case MTSCREEN:
  1644. case MTTPC:
  1645. case MTTPC_B:
  1646. sync = wacom_tpc_irq(wacom_wac, len);
  1647. break;
  1648. case BAMBOO_PT:
  1649. case INTUOSHT:
  1650. sync = wacom_bpt_irq(wacom_wac, len);
  1651. break;
  1652. case WIRELESS:
  1653. sync = wacom_wireless_irq(wacom_wac, len);
  1654. break;
  1655. default:
  1656. sync = false;
  1657. break;
  1658. }
  1659. if (sync) {
  1660. input_sync(wacom_wac->input);
  1661. if (wacom_wac->pad_input)
  1662. input_sync(wacom_wac->pad_input);
  1663. }
  1664. }
  1665. static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  1666. {
  1667. struct input_dev *input_dev = wacom_wac->input;
  1668. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  1669. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1670. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1671. __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  1672. __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  1673. __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  1674. __set_bit(BTN_STYLUS, input_dev->keybit);
  1675. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1676. input_set_abs_params(input_dev, ABS_DISTANCE,
  1677. 0, wacom_wac->features.distance_max, 0, 0);
  1678. input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  1679. input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
  1680. input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
  1681. }
  1682. static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  1683. {
  1684. struct input_dev *input_dev = wacom_wac->input;
  1685. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1686. wacom_setup_cintiq(wacom_wac);
  1687. __set_bit(BTN_LEFT, input_dev->keybit);
  1688. __set_bit(BTN_RIGHT, input_dev->keybit);
  1689. __set_bit(BTN_MIDDLE, input_dev->keybit);
  1690. __set_bit(BTN_SIDE, input_dev->keybit);
  1691. __set_bit(BTN_EXTRA, input_dev->keybit);
  1692. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1693. __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  1694. input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  1695. input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  1696. }
  1697. void wacom_setup_device_quirks(struct wacom_features *features)
  1698. {
  1699. /* touch device found but size is not defined. use default */
  1700. if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
  1701. features->x_max = 1023;
  1702. features->y_max = 1023;
  1703. }
  1704. /* these device have multiple inputs */
  1705. if (features->type >= WIRELESS ||
  1706. (features->type >= INTUOS5S && features->type <= INTUOSHT) ||
  1707. (features->oVid && features->oPid))
  1708. features->quirks |= WACOM_QUIRK_MULTI_INPUT;
  1709. /* quirk for bamboo touch with 2 low res touches */
  1710. if (features->type == BAMBOO_PT &&
  1711. features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  1712. features->x_max <<= 5;
  1713. features->y_max <<= 5;
  1714. features->x_fuzz <<= 5;
  1715. features->y_fuzz <<= 5;
  1716. features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
  1717. }
  1718. if (features->type == WIRELESS) {
  1719. /* monitor never has input and pen/touch have delayed create */
  1720. features->quirks |= WACOM_QUIRK_NO_INPUT;
  1721. /* must be monitor interface if no device_type set */
  1722. if (!features->device_type) {
  1723. features->quirks |= WACOM_QUIRK_MONITOR;
  1724. features->quirks |= WACOM_QUIRK_BATTERY;
  1725. }
  1726. }
  1727. }
  1728. static void wacom_abs_set_axis(struct input_dev *input_dev,
  1729. struct wacom_wac *wacom_wac)
  1730. {
  1731. struct wacom_features *features = &wacom_wac->features;
  1732. if (features->device_type == BTN_TOOL_PEN) {
  1733. input_set_abs_params(input_dev, ABS_X, features->x_min,
  1734. features->x_max, features->x_fuzz, 0);
  1735. input_set_abs_params(input_dev, ABS_Y, features->y_min,
  1736. features->y_max, features->y_fuzz, 0);
  1737. input_set_abs_params(input_dev, ABS_PRESSURE, 0,
  1738. features->pressure_max, features->pressure_fuzz, 0);
  1739. /* penabled devices have fixed resolution for each model */
  1740. input_abs_set_res(input_dev, ABS_X, features->x_resolution);
  1741. input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
  1742. } else {
  1743. if (features->touch_max == 1) {
  1744. input_set_abs_params(input_dev, ABS_X, 0,
  1745. features->x_max, features->x_fuzz, 0);
  1746. input_set_abs_params(input_dev, ABS_Y, 0,
  1747. features->y_max, features->y_fuzz, 0);
  1748. input_abs_set_res(input_dev, ABS_X,
  1749. features->x_resolution);
  1750. input_abs_set_res(input_dev, ABS_Y,
  1751. features->y_resolution);
  1752. }
  1753. if (features->touch_max > 1) {
  1754. input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
  1755. features->x_max, features->x_fuzz, 0);
  1756. input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
  1757. features->y_max, features->y_fuzz, 0);
  1758. input_abs_set_res(input_dev, ABS_MT_POSITION_X,
  1759. features->x_resolution);
  1760. input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
  1761. features->y_resolution);
  1762. }
  1763. }
  1764. }
  1765. int wacom_setup_input_capabilities(struct input_dev *input_dev,
  1766. struct wacom_wac *wacom_wac)
  1767. {
  1768. struct wacom_features *features = &wacom_wac->features;
  1769. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  1770. if (features->type == HID_GENERIC)
  1771. /* setup has already been done */
  1772. return 0;
  1773. __set_bit(BTN_TOUCH, input_dev->keybit);
  1774. __set_bit(ABS_MISC, input_dev->absbit);
  1775. wacom_abs_set_axis(input_dev, wacom_wac);
  1776. switch (features->type) {
  1777. case WACOM_MO:
  1778. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  1779. /* fall through */
  1780. case WACOM_G4:
  1781. /* fall through */
  1782. case GRAPHIRE:
  1783. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1784. __set_bit(BTN_LEFT, input_dev->keybit);
  1785. __set_bit(BTN_RIGHT, input_dev->keybit);
  1786. __set_bit(BTN_MIDDLE, input_dev->keybit);
  1787. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1788. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1789. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1790. __set_bit(BTN_STYLUS, input_dev->keybit);
  1791. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1792. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1793. break;
  1794. case GRAPHIRE_BT:
  1795. __clear_bit(ABS_MISC, input_dev->absbit);
  1796. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  1797. features->distance_max,
  1798. 0, 0);
  1799. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1800. __set_bit(BTN_LEFT, input_dev->keybit);
  1801. __set_bit(BTN_RIGHT, input_dev->keybit);
  1802. __set_bit(BTN_MIDDLE, input_dev->keybit);
  1803. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1804. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1805. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  1806. __set_bit(BTN_STYLUS, input_dev->keybit);
  1807. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1808. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1809. break;
  1810. case WACOM_24HD:
  1811. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1812. input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
  1813. /* fall through */
  1814. case DTK:
  1815. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1816. wacom_setup_cintiq(wacom_wac);
  1817. break;
  1818. case WACOM_22HD:
  1819. case WACOM_21UX2:
  1820. case WACOM_BEE:
  1821. case CINTIQ:
  1822. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1823. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1824. wacom_setup_cintiq(wacom_wac);
  1825. break;
  1826. case WACOM_13HD:
  1827. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1828. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1829. wacom_setup_cintiq(wacom_wac);
  1830. break;
  1831. case INTUOS3:
  1832. case INTUOS3L:
  1833. case INTUOS3S:
  1834. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1835. /* fall through */
  1836. case INTUOS:
  1837. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1838. wacom_setup_intuos(wacom_wac);
  1839. break;
  1840. case INTUOS5:
  1841. case INTUOS5L:
  1842. case INTUOSPM:
  1843. case INTUOSPL:
  1844. case INTUOS5S:
  1845. case INTUOSPS:
  1846. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1847. if (features->device_type == BTN_TOOL_PEN) {
  1848. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  1849. features->distance_max,
  1850. 0, 0);
  1851. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1852. wacom_setup_intuos(wacom_wac);
  1853. } else if (features->device_type == BTN_TOOL_FINGER) {
  1854. __clear_bit(ABS_MISC, input_dev->absbit);
  1855. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
  1856. 0, features->x_max, 0, 0);
  1857. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
  1858. 0, features->y_max, 0, 0);
  1859. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  1860. }
  1861. break;
  1862. case INTUOS4:
  1863. case INTUOS4WL:
  1864. case INTUOS4L:
  1865. case INTUOS4S:
  1866. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1867. wacom_setup_intuos(wacom_wac);
  1868. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1869. break;
  1870. case WACOM_24HDT:
  1871. if (features->device_type == BTN_TOOL_FINGER) {
  1872. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  1873. input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
  1874. input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
  1875. input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  1876. }
  1877. /* fall through */
  1878. case MTSCREEN:
  1879. case MTTPC:
  1880. case MTTPC_B:
  1881. case TABLETPC2FG:
  1882. if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1)
  1883. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
  1884. /* fall through */
  1885. case TABLETPC:
  1886. case TABLETPCE:
  1887. __clear_bit(ABS_MISC, input_dev->absbit);
  1888. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1889. if (features->device_type != BTN_TOOL_PEN)
  1890. break; /* no need to process stylus stuff */
  1891. /* fall through */
  1892. case DTUS:
  1893. case PL:
  1894. case DTU:
  1895. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1896. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1897. __set_bit(BTN_STYLUS, input_dev->keybit);
  1898. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1899. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1900. break;
  1901. case PTU:
  1902. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1903. /* fall through */
  1904. case PENPARTNER:
  1905. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1906. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1907. __set_bit(BTN_STYLUS, input_dev->keybit);
  1908. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1909. break;
  1910. case INTUOSHT:
  1911. if (features->touch_max &&
  1912. features->device_type == BTN_TOOL_FINGER) {
  1913. input_dev->evbit[0] |= BIT_MASK(EV_SW);
  1914. __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
  1915. }
  1916. /* fall through */
  1917. case BAMBOO_PT:
  1918. __clear_bit(ABS_MISC, input_dev->absbit);
  1919. if (features->device_type == BTN_TOOL_FINGER) {
  1920. if (features->touch_max) {
  1921. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  1922. input_set_abs_params(input_dev,
  1923. ABS_MT_TOUCH_MAJOR,
  1924. 0, features->x_max, 0, 0);
  1925. input_set_abs_params(input_dev,
  1926. ABS_MT_TOUCH_MINOR,
  1927. 0, features->y_max, 0, 0);
  1928. }
  1929. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  1930. } else {
  1931. /* buttons/keys only interface */
  1932. __clear_bit(ABS_X, input_dev->absbit);
  1933. __clear_bit(ABS_Y, input_dev->absbit);
  1934. __clear_bit(BTN_TOUCH, input_dev->keybit);
  1935. }
  1936. } else if (features->device_type == BTN_TOOL_PEN) {
  1937. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  1938. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  1939. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  1940. __set_bit(BTN_STYLUS, input_dev->keybit);
  1941. __set_bit(BTN_STYLUS2, input_dev->keybit);
  1942. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  1943. features->distance_max,
  1944. 0, 0);
  1945. }
  1946. break;
  1947. case CINTIQ_HYBRID:
  1948. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  1949. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  1950. wacom_setup_cintiq(wacom_wac);
  1951. break;
  1952. }
  1953. return 0;
  1954. }
  1955. int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
  1956. struct wacom_wac *wacom_wac)
  1957. {
  1958. struct wacom_features *features = &wacom_wac->features;
  1959. int i;
  1960. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  1961. /* kept for making legacy xf86-input-wacom working with the wheels */
  1962. __set_bit(ABS_MISC, input_dev->absbit);
  1963. /* kept for making legacy xf86-input-wacom accepting the pad */
  1964. input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
  1965. input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
  1966. /* kept for making udev and libwacom accepting the pad */
  1967. __set_bit(BTN_STYLUS, input_dev->keybit);
  1968. switch (features->type) {
  1969. case GRAPHIRE_BT:
  1970. __set_bit(BTN_0, input_dev->keybit);
  1971. __set_bit(BTN_1, input_dev->keybit);
  1972. break;
  1973. case WACOM_MO:
  1974. __set_bit(BTN_BACK, input_dev->keybit);
  1975. __set_bit(BTN_LEFT, input_dev->keybit);
  1976. __set_bit(BTN_FORWARD, input_dev->keybit);
  1977. __set_bit(BTN_RIGHT, input_dev->keybit);
  1978. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  1979. break;
  1980. case WACOM_G4:
  1981. __set_bit(BTN_BACK, input_dev->keybit);
  1982. __set_bit(BTN_LEFT, input_dev->keybit);
  1983. __set_bit(BTN_FORWARD, input_dev->keybit);
  1984. __set_bit(BTN_RIGHT, input_dev->keybit);
  1985. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  1986. break;
  1987. case WACOM_24HD:
  1988. __set_bit(BTN_A, input_dev->keybit);
  1989. __set_bit(BTN_B, input_dev->keybit);
  1990. __set_bit(BTN_C, input_dev->keybit);
  1991. __set_bit(BTN_X, input_dev->keybit);
  1992. __set_bit(BTN_Y, input_dev->keybit);
  1993. __set_bit(BTN_Z, input_dev->keybit);
  1994. for (i = 0; i < 10; i++)
  1995. __set_bit(BTN_0 + i, input_dev->keybit);
  1996. __set_bit(KEY_PROG1, input_dev->keybit);
  1997. __set_bit(KEY_PROG2, input_dev->keybit);
  1998. __set_bit(KEY_PROG3, input_dev->keybit);
  1999. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2000. input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
  2001. break;
  2002. case DTK:
  2003. for (i = 0; i < 6; i++)
  2004. __set_bit(BTN_0 + i, input_dev->keybit);
  2005. break;
  2006. case WACOM_22HD:
  2007. __set_bit(KEY_PROG1, input_dev->keybit);
  2008. __set_bit(KEY_PROG2, input_dev->keybit);
  2009. __set_bit(KEY_PROG3, input_dev->keybit);
  2010. /* fall through */
  2011. case WACOM_21UX2:
  2012. __set_bit(BTN_A, input_dev->keybit);
  2013. __set_bit(BTN_B, input_dev->keybit);
  2014. __set_bit(BTN_C, input_dev->keybit);
  2015. __set_bit(BTN_X, input_dev->keybit);
  2016. __set_bit(BTN_Y, input_dev->keybit);
  2017. __set_bit(BTN_Z, input_dev->keybit);
  2018. __set_bit(BTN_BASE, input_dev->keybit);
  2019. __set_bit(BTN_BASE2, input_dev->keybit);
  2020. /* fall through */
  2021. case WACOM_BEE:
  2022. __set_bit(BTN_8, input_dev->keybit);
  2023. __set_bit(BTN_9, input_dev->keybit);
  2024. /* fall through */
  2025. case CINTIQ:
  2026. for (i = 0; i < 8; i++)
  2027. __set_bit(BTN_0 + i, input_dev->keybit);
  2028. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  2029. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  2030. break;
  2031. case WACOM_13HD:
  2032. for (i = 0; i < 9; i++)
  2033. __set_bit(BTN_0 + i, input_dev->keybit);
  2034. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2035. break;
  2036. case INTUOS3:
  2037. case INTUOS3L:
  2038. __set_bit(BTN_4, input_dev->keybit);
  2039. __set_bit(BTN_5, input_dev->keybit);
  2040. __set_bit(BTN_6, input_dev->keybit);
  2041. __set_bit(BTN_7, input_dev->keybit);
  2042. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  2043. /* fall through */
  2044. case INTUOS3S:
  2045. __set_bit(BTN_0, input_dev->keybit);
  2046. __set_bit(BTN_1, input_dev->keybit);
  2047. __set_bit(BTN_2, input_dev->keybit);
  2048. __set_bit(BTN_3, input_dev->keybit);
  2049. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  2050. break;
  2051. case INTUOS5:
  2052. case INTUOS5L:
  2053. case INTUOSPM:
  2054. case INTUOSPL:
  2055. __set_bit(BTN_7, input_dev->keybit);
  2056. __set_bit(BTN_8, input_dev->keybit);
  2057. /* fall through */
  2058. case INTUOS5S:
  2059. case INTUOSPS:
  2060. /* touch interface does not have the pad device */
  2061. if (features->device_type != BTN_TOOL_PEN)
  2062. return 1;
  2063. for (i = 0; i < 7; i++)
  2064. __set_bit(BTN_0 + i, input_dev->keybit);
  2065. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2066. break;
  2067. case INTUOS4WL:
  2068. /*
  2069. * For Bluetooth devices, the udev rule does not work correctly
  2070. * for pads unless we add a stylus capability, which forces
  2071. * ID_INPUT_TABLET to be set.
  2072. */
  2073. __set_bit(BTN_STYLUS, input_dev->keybit);
  2074. /* fall through */
  2075. case INTUOS4:
  2076. case INTUOS4L:
  2077. __set_bit(BTN_7, input_dev->keybit);
  2078. __set_bit(BTN_8, input_dev->keybit);
  2079. /* fall through */
  2080. case INTUOS4S:
  2081. for (i = 0; i < 7; i++)
  2082. __set_bit(BTN_0 + i, input_dev->keybit);
  2083. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2084. break;
  2085. case CINTIQ_HYBRID:
  2086. for (i = 0; i < 9; i++)
  2087. __set_bit(BTN_0 + i, input_dev->keybit);
  2088. break;
  2089. case DTUS:
  2090. for (i = 0; i < 4; i++)
  2091. __set_bit(BTN_0 + i, input_dev->keybit);
  2092. break;
  2093. case INTUOSHT:
  2094. case BAMBOO_PT:
  2095. /* pad device is on the touch interface */
  2096. if (features->device_type != BTN_TOOL_FINGER)
  2097. return 1;
  2098. __clear_bit(ABS_MISC, input_dev->absbit);
  2099. __set_bit(BTN_LEFT, input_dev->keybit);
  2100. __set_bit(BTN_FORWARD, input_dev->keybit);
  2101. __set_bit(BTN_BACK, input_dev->keybit);
  2102. __set_bit(BTN_RIGHT, input_dev->keybit);
  2103. break;
  2104. default:
  2105. /* no pad supported */
  2106. return 1;
  2107. }
  2108. return 0;
  2109. }
  2110. static const struct wacom_features wacom_features_0x00 =
  2111. { "Wacom Penpartner", 5040, 3780, 255, 0,
  2112. PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  2113. static const struct wacom_features wacom_features_0x10 =
  2114. { "Wacom Graphire", 10206, 7422, 511, 63,
  2115. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2116. static const struct wacom_features wacom_features_0x81 =
  2117. { "Wacom Graphire BT", 16704, 12064, 511, 32,
  2118. GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2119. static const struct wacom_features wacom_features_0x11 =
  2120. { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
  2121. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2122. static const struct wacom_features wacom_features_0x12 =
  2123. { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
  2124. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2125. static const struct wacom_features wacom_features_0x13 =
  2126. { "Wacom Graphire3", 10208, 7424, 511, 63,
  2127. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2128. static const struct wacom_features wacom_features_0x14 =
  2129. { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
  2130. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2131. static const struct wacom_features wacom_features_0x15 =
  2132. { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
  2133. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2134. static const struct wacom_features wacom_features_0x16 =
  2135. { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
  2136. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2137. static const struct wacom_features wacom_features_0x17 =
  2138. { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
  2139. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2140. static const struct wacom_features wacom_features_0x18 =
  2141. { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
  2142. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2143. static const struct wacom_features wacom_features_0x19 =
  2144. { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
  2145. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2146. static const struct wacom_features wacom_features_0x60 =
  2147. { "Wacom Volito", 5104, 3712, 511, 63,
  2148. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2149. static const struct wacom_features wacom_features_0x61 =
  2150. { "Wacom PenStation2", 3250, 2320, 255, 63,
  2151. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2152. static const struct wacom_features wacom_features_0x62 =
  2153. { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
  2154. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2155. static const struct wacom_features wacom_features_0x63 =
  2156. { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
  2157. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2158. static const struct wacom_features wacom_features_0x64 =
  2159. { "Wacom PenPartner2", 3250, 2320, 511, 63,
  2160. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2161. static const struct wacom_features wacom_features_0x65 =
  2162. { "Wacom Bamboo", 14760, 9225, 511, 63,
  2163. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2164. static const struct wacom_features wacom_features_0x69 =
  2165. { "Wacom Bamboo1", 5104, 3712, 511, 63,
  2166. GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  2167. static const struct wacom_features wacom_features_0x6A =
  2168. { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
  2169. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2170. static const struct wacom_features wacom_features_0x6B =
  2171. { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
  2172. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2173. static const struct wacom_features wacom_features_0x20 =
  2174. { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
  2175. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2176. static const struct wacom_features wacom_features_0x21 =
  2177. { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
  2178. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2179. static const struct wacom_features wacom_features_0x22 =
  2180. { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
  2181. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2182. static const struct wacom_features wacom_features_0x23 =
  2183. { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
  2184. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2185. static const struct wacom_features wacom_features_0x24 =
  2186. { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
  2187. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2188. static const struct wacom_features wacom_features_0x30 =
  2189. { "Wacom PL400", 5408, 4056, 255, 0,
  2190. PL, WACOM_PL_RES, WACOM_PL_RES };
  2191. static const struct wacom_features wacom_features_0x31 =
  2192. { "Wacom PL500", 6144, 4608, 255, 0,
  2193. PL, WACOM_PL_RES, WACOM_PL_RES };
  2194. static const struct wacom_features wacom_features_0x32 =
  2195. { "Wacom PL600", 6126, 4604, 255, 0,
  2196. PL, WACOM_PL_RES, WACOM_PL_RES };
  2197. static const struct wacom_features wacom_features_0x33 =
  2198. { "Wacom PL600SX", 6260, 5016, 255, 0,
  2199. PL, WACOM_PL_RES, WACOM_PL_RES };
  2200. static const struct wacom_features wacom_features_0x34 =
  2201. { "Wacom PL550", 6144, 4608, 511, 0,
  2202. PL, WACOM_PL_RES, WACOM_PL_RES };
  2203. static const struct wacom_features wacom_features_0x35 =
  2204. { "Wacom PL800", 7220, 5780, 511, 0,
  2205. PL, WACOM_PL_RES, WACOM_PL_RES };
  2206. static const struct wacom_features wacom_features_0x37 =
  2207. { "Wacom PL700", 6758, 5406, 511, 0,
  2208. PL, WACOM_PL_RES, WACOM_PL_RES };
  2209. static const struct wacom_features wacom_features_0x38 =
  2210. { "Wacom PL510", 6282, 4762, 511, 0,
  2211. PL, WACOM_PL_RES, WACOM_PL_RES };
  2212. static const struct wacom_features wacom_features_0x39 =
  2213. { "Wacom DTU710", 34080, 27660, 511, 0,
  2214. PL, WACOM_PL_RES, WACOM_PL_RES };
  2215. static const struct wacom_features wacom_features_0xC4 =
  2216. { "Wacom DTF521", 6282, 4762, 511, 0,
  2217. PL, WACOM_PL_RES, WACOM_PL_RES };
  2218. static const struct wacom_features wacom_features_0xC0 =
  2219. { "Wacom DTF720", 6858, 5506, 511, 0,
  2220. PL, WACOM_PL_RES, WACOM_PL_RES };
  2221. static const struct wacom_features wacom_features_0xC2 =
  2222. { "Wacom DTF720a", 6858, 5506, 511, 0,
  2223. PL, WACOM_PL_RES, WACOM_PL_RES };
  2224. static const struct wacom_features wacom_features_0x03 =
  2225. { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
  2226. PTU, WACOM_PL_RES, WACOM_PL_RES };
  2227. static const struct wacom_features wacom_features_0x41 =
  2228. { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
  2229. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2230. static const struct wacom_features wacom_features_0x42 =
  2231. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  2232. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2233. static const struct wacom_features wacom_features_0x43 =
  2234. { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
  2235. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2236. static const struct wacom_features wacom_features_0x44 =
  2237. { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
  2238. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2239. static const struct wacom_features wacom_features_0x45 =
  2240. { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
  2241. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2242. static const struct wacom_features wacom_features_0xB0 =
  2243. { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
  2244. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2245. static const struct wacom_features wacom_features_0xB1 =
  2246. { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
  2247. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2248. static const struct wacom_features wacom_features_0xB2 =
  2249. { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
  2250. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2251. static const struct wacom_features wacom_features_0xB3 =
  2252. { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
  2253. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2254. static const struct wacom_features wacom_features_0xB4 =
  2255. { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
  2256. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2257. static const struct wacom_features wacom_features_0xB5 =
  2258. { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
  2259. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2260. static const struct wacom_features wacom_features_0xB7 =
  2261. { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
  2262. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2263. static const struct wacom_features wacom_features_0xB8 =
  2264. { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
  2265. INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2266. static const struct wacom_features wacom_features_0xB9 =
  2267. { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
  2268. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2269. static const struct wacom_features wacom_features_0xBA =
  2270. { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
  2271. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2272. static const struct wacom_features wacom_features_0xBB =
  2273. { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
  2274. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2275. static const struct wacom_features wacom_features_0xBC =
  2276. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  2277. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2278. static const struct wacom_features wacom_features_0xBD =
  2279. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  2280. INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2281. static const struct wacom_features wacom_features_0x26 =
  2282. { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
  2283. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
  2284. static const struct wacom_features wacom_features_0x27 =
  2285. { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
  2286. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
  2287. static const struct wacom_features wacom_features_0x28 =
  2288. { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
  2289. INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
  2290. static const struct wacom_features wacom_features_0x29 =
  2291. { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
  2292. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2293. static const struct wacom_features wacom_features_0x2A =
  2294. { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
  2295. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2296. static const struct wacom_features wacom_features_0x314 =
  2297. { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
  2298. INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
  2299. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2300. static const struct wacom_features wacom_features_0x315 =
  2301. { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
  2302. INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
  2303. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2304. static const struct wacom_features wacom_features_0x317 =
  2305. { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
  2306. INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
  2307. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2308. static const struct wacom_features wacom_features_0xF4 =
  2309. { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63,
  2310. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
  2311. static const struct wacom_features wacom_features_0xF8 =
  2312. { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */
  2313. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
  2314. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
  2315. static const struct wacom_features wacom_features_0xF6 =
  2316. { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
  2317. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
  2318. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2319. static const struct wacom_features wacom_features_0x3F =
  2320. { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
  2321. CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2322. static const struct wacom_features wacom_features_0xC5 =
  2323. { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
  2324. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2325. static const struct wacom_features wacom_features_0xC6 =
  2326. { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
  2327. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
  2328. static const struct wacom_features wacom_features_0x304 =
  2329. { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63,
  2330. WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
  2331. static const struct wacom_features wacom_features_0xC7 =
  2332. { "Wacom DTU1931", 37832, 30305, 511, 0,
  2333. PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2334. static const struct wacom_features wacom_features_0xCE =
  2335. { "Wacom DTU2231", 47864, 27011, 511, 0,
  2336. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  2337. .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
  2338. static const struct wacom_features wacom_features_0xF0 =
  2339. { "Wacom DTU1631", 34623, 19553, 511, 0,
  2340. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2341. static const struct wacom_features wacom_features_0xFB =
  2342. { "Wacom DTU1031", 22096, 13960, 511, 0,
  2343. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2344. static const struct wacom_features wacom_features_0x57 =
  2345. { "Wacom DTK2241", 95640, 54060, 2047, 63,
  2346. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
  2347. static const struct wacom_features wacom_features_0x59 = /* Pen */
  2348. { "Wacom DTH2242", 95640, 54060, 2047, 63,
  2349. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
  2350. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
  2351. static const struct wacom_features wacom_features_0x5D = /* Touch */
  2352. { "Wacom DTH2242", .type = WACOM_24HDT,
  2353. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
  2354. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2355. static const struct wacom_features wacom_features_0xCC =
  2356. { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63,
  2357. WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
  2358. static const struct wacom_features wacom_features_0xFA =
  2359. { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63,
  2360. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
  2361. static const struct wacom_features wacom_features_0x5B =
  2362. { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63,
  2363. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
  2364. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
  2365. static const struct wacom_features wacom_features_0x5E =
  2366. { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
  2367. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
  2368. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2369. static const struct wacom_features wacom_features_0x90 =
  2370. { "Wacom ISDv4 90", 26202, 16325, 255, 0,
  2371. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2372. static const struct wacom_features wacom_features_0x93 =
  2373. { "Wacom ISDv4 93", 26202, 16325, 255, 0,
  2374. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2375. static const struct wacom_features wacom_features_0x97 =
  2376. { "Wacom ISDv4 97", 26202, 16325, 511, 0,
  2377. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2378. static const struct wacom_features wacom_features_0x9A =
  2379. { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
  2380. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2381. static const struct wacom_features wacom_features_0x9F =
  2382. { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
  2383. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2384. static const struct wacom_features wacom_features_0xE2 =
  2385. { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
  2386. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2387. static const struct wacom_features wacom_features_0xE3 =
  2388. { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
  2389. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2390. static const struct wacom_features wacom_features_0xE5 =
  2391. { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
  2392. MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2393. static const struct wacom_features wacom_features_0xE6 =
  2394. { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
  2395. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2396. static const struct wacom_features wacom_features_0xEC =
  2397. { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
  2398. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2399. static const struct wacom_features wacom_features_0xED =
  2400. { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
  2401. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2402. static const struct wacom_features wacom_features_0xEF =
  2403. { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
  2404. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2405. static const struct wacom_features wacom_features_0x100 =
  2406. { "Wacom ISDv4 100", 26202, 16325, 255, 0,
  2407. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2408. static const struct wacom_features wacom_features_0x101 =
  2409. { "Wacom ISDv4 101", 26202, 16325, 255, 0,
  2410. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2411. static const struct wacom_features wacom_features_0x10D =
  2412. { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
  2413. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2414. static const struct wacom_features wacom_features_0x10E =
  2415. { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
  2416. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2417. static const struct wacom_features wacom_features_0x10F =
  2418. { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
  2419. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2420. static const struct wacom_features wacom_features_0x116 =
  2421. { "Wacom ISDv4 116", 26202, 16325, 255, 0,
  2422. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2423. static const struct wacom_features wacom_features_0x12C =
  2424. { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
  2425. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2426. static const struct wacom_features wacom_features_0x4001 =
  2427. { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
  2428. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2429. static const struct wacom_features wacom_features_0x4004 =
  2430. { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
  2431. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2432. static const struct wacom_features wacom_features_0x5000 =
  2433. { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
  2434. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2435. static const struct wacom_features wacom_features_0x5002 =
  2436. { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
  2437. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2438. static const struct wacom_features wacom_features_0x47 =
  2439. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  2440. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2441. static const struct wacom_features wacom_features_0x84 =
  2442. { "Wacom Wireless Receiver", 0, 0, 0, 0,
  2443. WIRELESS, 0, 0, .touch_max = 16 };
  2444. static const struct wacom_features wacom_features_0xD0 =
  2445. { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
  2446. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2447. static const struct wacom_features wacom_features_0xD1 =
  2448. { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
  2449. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2450. static const struct wacom_features wacom_features_0xD2 =
  2451. { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
  2452. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2453. static const struct wacom_features wacom_features_0xD3 =
  2454. { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
  2455. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2456. static const struct wacom_features wacom_features_0xD4 =
  2457. { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
  2458. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2459. static const struct wacom_features wacom_features_0xD5 =
  2460. { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
  2461. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2462. static const struct wacom_features wacom_features_0xD6 =
  2463. { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
  2464. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2465. static const struct wacom_features wacom_features_0xD7 =
  2466. { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
  2467. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2468. static const struct wacom_features wacom_features_0xD8 =
  2469. { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
  2470. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2471. static const struct wacom_features wacom_features_0xDA =
  2472. { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
  2473. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2474. static const struct wacom_features wacom_features_0xDB =
  2475. { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
  2476. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2477. static const struct wacom_features wacom_features_0xDD =
  2478. { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
  2479. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2480. static const struct wacom_features wacom_features_0xDE =
  2481. { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
  2482. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  2483. static const struct wacom_features wacom_features_0xDF =
  2484. { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
  2485. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  2486. static const struct wacom_features wacom_features_0x300 =
  2487. { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
  2488. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2489. static const struct wacom_features wacom_features_0x301 =
  2490. { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
  2491. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2492. static const struct wacom_features wacom_features_0x302 =
  2493. { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
  2494. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  2495. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2496. static const struct wacom_features wacom_features_0x303 =
  2497. { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
  2498. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  2499. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2500. static const struct wacom_features wacom_features_0x30E =
  2501. { "Wacom Intuos S", 15200, 9500, 1023, 31,
  2502. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  2503. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2504. static const struct wacom_features wacom_features_0x6004 =
  2505. { "ISD-V4", 12800, 8000, 255, 0,
  2506. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2507. static const struct wacom_features wacom_features_0x307 =
  2508. { "Wacom ISDv5 307", 59352, 33648, 2047, 63,
  2509. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
  2510. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
  2511. static const struct wacom_features wacom_features_0x309 =
  2512. { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
  2513. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
  2514. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2515. static const struct wacom_features wacom_features_0x30A =
  2516. { "Wacom ISDv5 30A", 59352, 33648, 2047, 63,
  2517. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
  2518. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
  2519. static const struct wacom_features wacom_features_0x30C =
  2520. { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
  2521. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
  2522. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2523. static const struct wacom_features wacom_features_HID_ANY_ID =
  2524. { "Wacom HID", .type = HID_GENERIC };
  2525. #define USB_DEVICE_WACOM(prod) \
  2526. HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  2527. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2528. #define BT_DEVICE_WACOM(prod) \
  2529. HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  2530. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2531. #define USB_DEVICE_LENOVO(prod) \
  2532. HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
  2533. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2534. const struct hid_device_id wacom_ids[] = {
  2535. { USB_DEVICE_WACOM(0x00) },
  2536. { USB_DEVICE_WACOM(0x03) },
  2537. { USB_DEVICE_WACOM(0x10) },
  2538. { USB_DEVICE_WACOM(0x11) },
  2539. { USB_DEVICE_WACOM(0x12) },
  2540. { USB_DEVICE_WACOM(0x13) },
  2541. { USB_DEVICE_WACOM(0x14) },
  2542. { USB_DEVICE_WACOM(0x15) },
  2543. { USB_DEVICE_WACOM(0x16) },
  2544. { USB_DEVICE_WACOM(0x17) },
  2545. { USB_DEVICE_WACOM(0x18) },
  2546. { USB_DEVICE_WACOM(0x19) },
  2547. { USB_DEVICE_WACOM(0x20) },
  2548. { USB_DEVICE_WACOM(0x21) },
  2549. { USB_DEVICE_WACOM(0x22) },
  2550. { USB_DEVICE_WACOM(0x23) },
  2551. { USB_DEVICE_WACOM(0x24) },
  2552. { USB_DEVICE_WACOM(0x26) },
  2553. { USB_DEVICE_WACOM(0x27) },
  2554. { USB_DEVICE_WACOM(0x28) },
  2555. { USB_DEVICE_WACOM(0x29) },
  2556. { USB_DEVICE_WACOM(0x2A) },
  2557. { USB_DEVICE_WACOM(0x30) },
  2558. { USB_DEVICE_WACOM(0x31) },
  2559. { USB_DEVICE_WACOM(0x32) },
  2560. { USB_DEVICE_WACOM(0x33) },
  2561. { USB_DEVICE_WACOM(0x34) },
  2562. { USB_DEVICE_WACOM(0x35) },
  2563. { USB_DEVICE_WACOM(0x37) },
  2564. { USB_DEVICE_WACOM(0x38) },
  2565. { USB_DEVICE_WACOM(0x39) },
  2566. { USB_DEVICE_WACOM(0x3F) },
  2567. { USB_DEVICE_WACOM(0x41) },
  2568. { USB_DEVICE_WACOM(0x42) },
  2569. { USB_DEVICE_WACOM(0x43) },
  2570. { USB_DEVICE_WACOM(0x44) },
  2571. { USB_DEVICE_WACOM(0x45) },
  2572. { USB_DEVICE_WACOM(0x47) },
  2573. { USB_DEVICE_WACOM(0x57) },
  2574. { USB_DEVICE_WACOM(0x59) },
  2575. { USB_DEVICE_WACOM(0x5B) },
  2576. { USB_DEVICE_WACOM(0x5D) },
  2577. { USB_DEVICE_WACOM(0x5E) },
  2578. { USB_DEVICE_WACOM(0x60) },
  2579. { USB_DEVICE_WACOM(0x61) },
  2580. { USB_DEVICE_WACOM(0x62) },
  2581. { USB_DEVICE_WACOM(0x63) },
  2582. { USB_DEVICE_WACOM(0x64) },
  2583. { USB_DEVICE_WACOM(0x65) },
  2584. { USB_DEVICE_WACOM(0x69) },
  2585. { USB_DEVICE_WACOM(0x6A) },
  2586. { USB_DEVICE_WACOM(0x6B) },
  2587. { BT_DEVICE_WACOM(0x81) },
  2588. { USB_DEVICE_WACOM(0x84) },
  2589. { USB_DEVICE_WACOM(0x90) },
  2590. { USB_DEVICE_WACOM(0x93) },
  2591. { USB_DEVICE_WACOM(0x97) },
  2592. { USB_DEVICE_WACOM(0x9A) },
  2593. { USB_DEVICE_WACOM(0x9F) },
  2594. { USB_DEVICE_WACOM(0xB0) },
  2595. { USB_DEVICE_WACOM(0xB1) },
  2596. { USB_DEVICE_WACOM(0xB2) },
  2597. { USB_DEVICE_WACOM(0xB3) },
  2598. { USB_DEVICE_WACOM(0xB4) },
  2599. { USB_DEVICE_WACOM(0xB5) },
  2600. { USB_DEVICE_WACOM(0xB7) },
  2601. { USB_DEVICE_WACOM(0xB8) },
  2602. { USB_DEVICE_WACOM(0xB9) },
  2603. { USB_DEVICE_WACOM(0xBA) },
  2604. { USB_DEVICE_WACOM(0xBB) },
  2605. { USB_DEVICE_WACOM(0xBC) },
  2606. { BT_DEVICE_WACOM(0xBD) },
  2607. { USB_DEVICE_WACOM(0xC0) },
  2608. { USB_DEVICE_WACOM(0xC2) },
  2609. { USB_DEVICE_WACOM(0xC4) },
  2610. { USB_DEVICE_WACOM(0xC5) },
  2611. { USB_DEVICE_WACOM(0xC6) },
  2612. { USB_DEVICE_WACOM(0xC7) },
  2613. { USB_DEVICE_WACOM(0xCC) },
  2614. { USB_DEVICE_WACOM(0xCE) },
  2615. { USB_DEVICE_WACOM(0xD0) },
  2616. { USB_DEVICE_WACOM(0xD1) },
  2617. { USB_DEVICE_WACOM(0xD2) },
  2618. { USB_DEVICE_WACOM(0xD3) },
  2619. { USB_DEVICE_WACOM(0xD4) },
  2620. { USB_DEVICE_WACOM(0xD5) },
  2621. { USB_DEVICE_WACOM(0xD6) },
  2622. { USB_DEVICE_WACOM(0xD7) },
  2623. { USB_DEVICE_WACOM(0xD8) },
  2624. { USB_DEVICE_WACOM(0xDA) },
  2625. { USB_DEVICE_WACOM(0xDB) },
  2626. { USB_DEVICE_WACOM(0xDD) },
  2627. { USB_DEVICE_WACOM(0xDE) },
  2628. { USB_DEVICE_WACOM(0xDF) },
  2629. { USB_DEVICE_WACOM(0xE2) },
  2630. { USB_DEVICE_WACOM(0xE3) },
  2631. { USB_DEVICE_WACOM(0xE5) },
  2632. { USB_DEVICE_WACOM(0xE6) },
  2633. { USB_DEVICE_WACOM(0xEC) },
  2634. { USB_DEVICE_WACOM(0xED) },
  2635. { USB_DEVICE_WACOM(0xEF) },
  2636. { USB_DEVICE_WACOM(0xF0) },
  2637. { USB_DEVICE_WACOM(0xF4) },
  2638. { USB_DEVICE_WACOM(0xF6) },
  2639. { USB_DEVICE_WACOM(0xF8) },
  2640. { USB_DEVICE_WACOM(0xFA) },
  2641. { USB_DEVICE_WACOM(0xFB) },
  2642. { USB_DEVICE_WACOM(0x100) },
  2643. { USB_DEVICE_WACOM(0x101) },
  2644. { USB_DEVICE_WACOM(0x10D) },
  2645. { USB_DEVICE_WACOM(0x10E) },
  2646. { USB_DEVICE_WACOM(0x10F) },
  2647. { USB_DEVICE_WACOM(0x116) },
  2648. { USB_DEVICE_WACOM(0x12C) },
  2649. { USB_DEVICE_WACOM(0x300) },
  2650. { USB_DEVICE_WACOM(0x301) },
  2651. { USB_DEVICE_WACOM(0x302) },
  2652. { USB_DEVICE_WACOM(0x303) },
  2653. { USB_DEVICE_WACOM(0x304) },
  2654. { USB_DEVICE_WACOM(0x307) },
  2655. { USB_DEVICE_WACOM(0x309) },
  2656. { USB_DEVICE_WACOM(0x30A) },
  2657. { USB_DEVICE_WACOM(0x30C) },
  2658. { USB_DEVICE_WACOM(0x30E) },
  2659. { USB_DEVICE_WACOM(0x314) },
  2660. { USB_DEVICE_WACOM(0x315) },
  2661. { USB_DEVICE_WACOM(0x317) },
  2662. { USB_DEVICE_WACOM(0x4001) },
  2663. { USB_DEVICE_WACOM(0x4004) },
  2664. { USB_DEVICE_WACOM(0x5000) },
  2665. { USB_DEVICE_WACOM(0x5002) },
  2666. { USB_DEVICE_WACOM(HID_ANY_ID) },
  2667. { }
  2668. };
  2669. MODULE_DEVICE_TABLE(hid, wacom_ids);