wacom_wac.c 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504
  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. /* resolution for penabled devices */
  17. #define WACOM_PL_RES 20
  18. #define WACOM_PENPRTN_RES 40
  19. #define WACOM_VOLITO_RES 50
  20. #define WACOM_GRAPHIRE_RES 80
  21. #define WACOM_INTUOS_RES 100
  22. #define WACOM_INTUOS3_RES 200
  23. /* Newer Cintiq and DTU have an offset between tablet and screen areas */
  24. #define WACOM_DTU_OFFSET 200
  25. #define WACOM_CINTIQ_OFFSET 400
  26. /*
  27. * Scale factor relating reported contact size to logical contact area.
  28. * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
  29. */
  30. #define WACOM_CONTACT_AREA_SCALE 2607
  31. /*
  32. * Percent of battery capacity for Graphire.
  33. * 8th value means AC online and show 100% capacity.
  34. */
  35. static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
  36. /*
  37. * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
  38. */
  39. static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
  40. static void wacom_notify_battery(struct wacom_wac *wacom_wac,
  41. int bat_capacity, bool bat_charging, bool bat_connected,
  42. bool ps_connected)
  43. {
  44. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  45. bool changed = wacom_wac->battery_capacity != bat_capacity ||
  46. wacom_wac->bat_charging != bat_charging ||
  47. wacom_wac->bat_connected != bat_connected ||
  48. wacom_wac->ps_connected != ps_connected;
  49. if (changed) {
  50. wacom_wac->battery_capacity = bat_capacity;
  51. wacom_wac->bat_charging = bat_charging;
  52. wacom_wac->bat_connected = bat_connected;
  53. wacom_wac->ps_connected = ps_connected;
  54. if (wacom->battery)
  55. power_supply_changed(wacom->battery);
  56. }
  57. }
  58. static int wacom_penpartner_irq(struct wacom_wac *wacom)
  59. {
  60. unsigned char *data = wacom->data;
  61. struct input_dev *input = wacom->pen_input;
  62. switch (data[0]) {
  63. case 1:
  64. if (data[5] & 0x80) {
  65. wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  66. wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
  67. input_report_key(input, wacom->tool[0], 1);
  68. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  69. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  70. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  71. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  72. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
  73. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  74. } else {
  75. input_report_key(input, wacom->tool[0], 0);
  76. input_report_abs(input, ABS_MISC, 0); /* report tool id */
  77. input_report_abs(input, ABS_PRESSURE, -1);
  78. input_report_key(input, BTN_TOUCH, 0);
  79. }
  80. break;
  81. case 2:
  82. input_report_key(input, BTN_TOOL_PEN, 1);
  83. input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
  84. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  85. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  86. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  87. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
  88. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  89. break;
  90. default:
  91. dev_dbg(input->dev.parent,
  92. "%s: received unknown report #%d\n", __func__, data[0]);
  93. return 0;
  94. }
  95. return 1;
  96. }
  97. static int wacom_pl_irq(struct wacom_wac *wacom)
  98. {
  99. struct wacom_features *features = &wacom->features;
  100. unsigned char *data = wacom->data;
  101. struct input_dev *input = wacom->pen_input;
  102. int prox, pressure;
  103. if (data[0] != WACOM_REPORT_PENABLED) {
  104. dev_dbg(input->dev.parent,
  105. "%s: received unknown report #%d\n", __func__, data[0]);
  106. return 0;
  107. }
  108. prox = data[1] & 0x40;
  109. if (!wacom->id[0]) {
  110. if ((data[0] & 0x10) || (data[4] & 0x20)) {
  111. wacom->tool[0] = BTN_TOOL_RUBBER;
  112. wacom->id[0] = ERASER_DEVICE_ID;
  113. }
  114. else {
  115. wacom->tool[0] = BTN_TOOL_PEN;
  116. wacom->id[0] = STYLUS_DEVICE_ID;
  117. }
  118. }
  119. /* If the eraser is in prox, STYLUS2 is always set. If we
  120. * mis-detected the type and notice that STYLUS2 isn't set
  121. * then force the eraser out of prox and let the pen in.
  122. */
  123. if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
  124. input_report_key(input, BTN_TOOL_RUBBER, 0);
  125. input_report_abs(input, ABS_MISC, 0);
  126. input_sync(input);
  127. wacom->tool[0] = BTN_TOOL_PEN;
  128. wacom->id[0] = STYLUS_DEVICE_ID;
  129. }
  130. pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
  131. if (features->pressure_max > 255)
  132. pressure = (pressure << 1) | ((data[4] >> 6) & 1);
  133. pressure += (features->pressure_max + 1) / 2;
  134. input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
  135. input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
  136. input_report_abs(input, ABS_PRESSURE, pressure);
  137. input_report_key(input, BTN_TOUCH, data[4] & 0x08);
  138. input_report_key(input, BTN_STYLUS, data[4] & 0x10);
  139. /* Only allow the stylus2 button to be reported for the pen tool. */
  140. input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
  141. if (!prox)
  142. wacom->id[0] = 0;
  143. input_report_key(input, wacom->tool[0], prox);
  144. input_report_abs(input, ABS_MISC, wacom->id[0]);
  145. return 1;
  146. }
  147. static int wacom_ptu_irq(struct wacom_wac *wacom)
  148. {
  149. unsigned char *data = wacom->data;
  150. struct input_dev *input = wacom->pen_input;
  151. if (data[0] != WACOM_REPORT_PENABLED) {
  152. dev_dbg(input->dev.parent,
  153. "%s: received unknown report #%d\n", __func__, data[0]);
  154. return 0;
  155. }
  156. if (data[1] & 0x04) {
  157. input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
  158. input_report_key(input, BTN_TOUCH, data[1] & 0x08);
  159. wacom->id[0] = ERASER_DEVICE_ID;
  160. } else {
  161. input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
  162. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  163. wacom->id[0] = STYLUS_DEVICE_ID;
  164. }
  165. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  166. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  167. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  168. input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  169. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  170. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  171. return 1;
  172. }
  173. static int wacom_dtu_irq(struct wacom_wac *wacom)
  174. {
  175. unsigned char *data = wacom->data;
  176. struct input_dev *input = wacom->pen_input;
  177. int prox = data[1] & 0x20;
  178. dev_dbg(input->dev.parent,
  179. "%s: received report #%d", __func__, data[0]);
  180. if (prox) {
  181. /* Going into proximity select tool */
  182. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  183. if (wacom->tool[0] == BTN_TOOL_PEN)
  184. wacom->id[0] = STYLUS_DEVICE_ID;
  185. else
  186. wacom->id[0] = ERASER_DEVICE_ID;
  187. }
  188. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  189. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  190. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  191. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  192. input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
  193. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  194. if (!prox) /* out-prox */
  195. wacom->id[0] = 0;
  196. input_report_key(input, wacom->tool[0], prox);
  197. input_report_abs(input, ABS_MISC, wacom->id[0]);
  198. return 1;
  199. }
  200. static int wacom_dtus_irq(struct wacom_wac *wacom)
  201. {
  202. char *data = wacom->data;
  203. struct input_dev *input = wacom->pen_input;
  204. unsigned short prox, pressure = 0;
  205. if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
  206. dev_dbg(input->dev.parent,
  207. "%s: received unknown report #%d", __func__, data[0]);
  208. return 0;
  209. } else if (data[0] == WACOM_REPORT_DTUSPAD) {
  210. input = wacom->pad_input;
  211. input_report_key(input, BTN_0, (data[1] & 0x01));
  212. input_report_key(input, BTN_1, (data[1] & 0x02));
  213. input_report_key(input, BTN_2, (data[1] & 0x04));
  214. input_report_key(input, BTN_3, (data[1] & 0x08));
  215. input_report_abs(input, ABS_MISC,
  216. data[1] & 0x0f ? PAD_DEVICE_ID : 0);
  217. return 1;
  218. } else {
  219. prox = data[1] & 0x80;
  220. if (prox) {
  221. switch ((data[1] >> 3) & 3) {
  222. case 1: /* Rubber */
  223. wacom->tool[0] = BTN_TOOL_RUBBER;
  224. wacom->id[0] = ERASER_DEVICE_ID;
  225. break;
  226. case 2: /* Pen */
  227. wacom->tool[0] = BTN_TOOL_PEN;
  228. wacom->id[0] = STYLUS_DEVICE_ID;
  229. break;
  230. }
  231. }
  232. input_report_key(input, BTN_STYLUS, data[1] & 0x20);
  233. input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
  234. input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
  235. input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
  236. pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
  237. input_report_abs(input, ABS_PRESSURE, pressure);
  238. input_report_key(input, BTN_TOUCH, pressure > 10);
  239. if (!prox) /* out-prox */
  240. wacom->id[0] = 0;
  241. input_report_key(input, wacom->tool[0], prox);
  242. input_report_abs(input, ABS_MISC, wacom->id[0]);
  243. return 1;
  244. }
  245. }
  246. static int wacom_graphire_irq(struct wacom_wac *wacom)
  247. {
  248. struct wacom_features *features = &wacom->features;
  249. unsigned char *data = wacom->data;
  250. struct input_dev *input = wacom->pen_input;
  251. struct input_dev *pad_input = wacom->pad_input;
  252. int battery_capacity, ps_connected;
  253. int prox;
  254. int rw = 0;
  255. int retval = 0;
  256. if (features->type == GRAPHIRE_BT) {
  257. if (data[0] != WACOM_REPORT_PENABLED_BT) {
  258. dev_dbg(input->dev.parent,
  259. "%s: received unknown report #%d\n", __func__,
  260. data[0]);
  261. goto exit;
  262. }
  263. } else if (data[0] != WACOM_REPORT_PENABLED) {
  264. dev_dbg(input->dev.parent,
  265. "%s: received unknown report #%d\n", __func__, data[0]);
  266. goto exit;
  267. }
  268. prox = data[1] & 0x80;
  269. if (prox || wacom->id[0]) {
  270. if (prox) {
  271. switch ((data[1] >> 5) & 3) {
  272. case 0: /* Pen */
  273. wacom->tool[0] = BTN_TOOL_PEN;
  274. wacom->id[0] = STYLUS_DEVICE_ID;
  275. break;
  276. case 1: /* Rubber */
  277. wacom->tool[0] = BTN_TOOL_RUBBER;
  278. wacom->id[0] = ERASER_DEVICE_ID;
  279. break;
  280. case 2: /* Mouse with wheel */
  281. input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
  282. /* fall through */
  283. case 3: /* Mouse without wheel */
  284. wacom->tool[0] = BTN_TOOL_MOUSE;
  285. wacom->id[0] = CURSOR_DEVICE_ID;
  286. break;
  287. }
  288. }
  289. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  290. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  291. if (wacom->tool[0] != BTN_TOOL_MOUSE) {
  292. if (features->type == GRAPHIRE_BT)
  293. input_report_abs(input, ABS_PRESSURE, data[6] |
  294. (((__u16) (data[1] & 0x08)) << 5));
  295. else
  296. input_report_abs(input, ABS_PRESSURE, data[6] |
  297. ((data[7] & 0x03) << 8));
  298. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  299. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  300. input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
  301. } else {
  302. input_report_key(input, BTN_LEFT, data[1] & 0x01);
  303. input_report_key(input, BTN_RIGHT, data[1] & 0x02);
  304. if (features->type == WACOM_G4 ||
  305. features->type == WACOM_MO) {
  306. input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
  307. rw = (data[7] & 0x04) - (data[7] & 0x03);
  308. } else if (features->type == GRAPHIRE_BT) {
  309. /* Compute distance between mouse and tablet */
  310. rw = 44 - (data[6] >> 2);
  311. rw = clamp_val(rw, 0, 31);
  312. input_report_abs(input, ABS_DISTANCE, rw);
  313. if (((data[1] >> 5) & 3) == 2) {
  314. /* Mouse with wheel */
  315. input_report_key(input, BTN_MIDDLE,
  316. data[1] & 0x04);
  317. rw = (data[6] & 0x01) ? -1 :
  318. (data[6] & 0x02) ? 1 : 0;
  319. } else {
  320. rw = 0;
  321. }
  322. } else {
  323. input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
  324. rw = -(signed char)data[6];
  325. }
  326. input_report_rel(input, REL_WHEEL, rw);
  327. }
  328. if (!prox)
  329. wacom->id[0] = 0;
  330. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  331. input_report_key(input, wacom->tool[0], prox);
  332. input_sync(input); /* sync last event */
  333. }
  334. /* send pad data */
  335. switch (features->type) {
  336. case WACOM_G4:
  337. prox = data[7] & 0xf8;
  338. if (prox || wacom->id[1]) {
  339. wacom->id[1] = PAD_DEVICE_ID;
  340. input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
  341. input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
  342. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  343. input_report_rel(pad_input, REL_WHEEL, rw);
  344. if (!prox)
  345. wacom->id[1] = 0;
  346. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  347. retval = 1;
  348. }
  349. break;
  350. case WACOM_MO:
  351. prox = (data[7] & 0xf8) || data[8];
  352. if (prox || wacom->id[1]) {
  353. wacom->id[1] = PAD_DEVICE_ID;
  354. input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
  355. input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
  356. input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
  357. input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
  358. input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
  359. if (!prox)
  360. wacom->id[1] = 0;
  361. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  362. retval = 1;
  363. }
  364. break;
  365. case GRAPHIRE_BT:
  366. prox = data[7] & 0x03;
  367. if (prox || wacom->id[1]) {
  368. wacom->id[1] = PAD_DEVICE_ID;
  369. input_report_key(pad_input, BTN_0, (data[7] & 0x02));
  370. input_report_key(pad_input, BTN_1, (data[7] & 0x01));
  371. if (!prox)
  372. wacom->id[1] = 0;
  373. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  374. retval = 1;
  375. }
  376. break;
  377. }
  378. /* Store current battery capacity and power supply state */
  379. if (features->type == GRAPHIRE_BT) {
  380. rw = (data[7] >> 2 & 0x07);
  381. battery_capacity = batcap_gr[rw];
  382. ps_connected = rw == 7;
  383. wacom_notify_battery(wacom, battery_capacity, ps_connected,
  384. 1, ps_connected);
  385. }
  386. exit:
  387. return retval;
  388. }
  389. static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
  390. {
  391. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  392. struct hid_report *r;
  393. struct hid_report_enum *re;
  394. re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
  395. r = re->report_id_hash[WACOM_REPORT_INTUOSREAD];
  396. if (r) {
  397. hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
  398. }
  399. }
  400. static int wacom_intuos_inout(struct wacom_wac *wacom)
  401. {
  402. struct wacom_features *features = &wacom->features;
  403. unsigned char *data = wacom->data;
  404. struct input_dev *input = wacom->pen_input;
  405. int idx = 0;
  406. /* tool number */
  407. if (features->type == INTUOS)
  408. idx = data[1] & 0x01;
  409. /* Enter report */
  410. if ((data[1] & 0xfc) == 0xc0) {
  411. /* serial number of the tool */
  412. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  413. (data[4] << 20) + (data[5] << 12) +
  414. (data[6] << 4) + (data[7] >> 4);
  415. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
  416. ((data[7] & 0x0f) << 20) | ((data[8] & 0xf0) << 12);
  417. switch (wacom->id[idx]) {
  418. case 0x812: /* Inking pen */
  419. case 0x801: /* Intuos3 Inking pen */
  420. case 0x120802: /* Intuos4/5 Inking Pen */
  421. case 0x012:
  422. wacom->tool[idx] = BTN_TOOL_PENCIL;
  423. break;
  424. case 0x822: /* Pen */
  425. case 0x842:
  426. case 0x852:
  427. case 0x823: /* Intuos3 Grip Pen */
  428. case 0x813: /* Intuos3 Classic Pen */
  429. case 0x885: /* Intuos3 Marker Pen */
  430. case 0x802: /* Intuos4/5 13HD/24HD General Pen */
  431. case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
  432. case 0x022:
  433. case 0x100804: /* Intuos4/5 13HD/24HD Art Pen */
  434. case 0x140802: /* Intuos4/5 13HD/24HD Classic Pen */
  435. case 0x160802: /* Cintiq 13HD Pro Pen */
  436. case 0x180802: /* DTH2242 Pen */
  437. case 0x100802: /* Intuos4/5 13HD/24HD General Pen */
  438. wacom->tool[idx] = BTN_TOOL_PEN;
  439. break;
  440. case 0x832: /* Stroke pen */
  441. case 0x032:
  442. wacom->tool[idx] = BTN_TOOL_BRUSH;
  443. break;
  444. case 0x007: /* Mouse 4D and 2D */
  445. case 0x09c:
  446. case 0x094:
  447. case 0x017: /* Intuos3 2D Mouse */
  448. case 0x806: /* Intuos4 Mouse */
  449. wacom->tool[idx] = BTN_TOOL_MOUSE;
  450. break;
  451. case 0x096: /* Lens cursor */
  452. case 0x097: /* Intuos3 Lens cursor */
  453. case 0x006: /* Intuos4 Lens cursor */
  454. wacom->tool[idx] = BTN_TOOL_LENS;
  455. break;
  456. case 0x82a: /* Eraser */
  457. case 0x85a:
  458. case 0x91a:
  459. case 0xd1a:
  460. case 0x0fa:
  461. case 0x82b: /* Intuos3 Grip Pen Eraser */
  462. case 0x81b: /* Intuos3 Classic Pen Eraser */
  463. case 0x91b: /* Intuos3 Airbrush Eraser */
  464. case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
  465. case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
  466. case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
  467. case 0x14080a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
  468. case 0x10090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
  469. case 0x10080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
  470. case 0x16080a: /* Cintiq 13HD Pro Pen Eraser */
  471. case 0x18080a: /* DTH2242 Eraser */
  472. case 0x10080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
  473. wacom->tool[idx] = BTN_TOOL_RUBBER;
  474. break;
  475. case 0xd12:
  476. case 0x912:
  477. case 0x112:
  478. case 0x913: /* Intuos3 Airbrush */
  479. case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
  480. case 0x100902: /* Intuos4/5 13HD/24HD Airbrush */
  481. wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
  482. break;
  483. default: /* Unknown tool */
  484. wacom->tool[idx] = BTN_TOOL_PEN;
  485. break;
  486. }
  487. return 1;
  488. }
  489. /*
  490. * don't report events for invalid data
  491. */
  492. /* older I4 styli don't work with new Cintiqs */
  493. if ((!((wacom->id[idx] >> 20) & 0x01) &&
  494. (features->type == WACOM_21UX2)) ||
  495. /* Only large Intuos support Lense Cursor */
  496. (wacom->tool[idx] == BTN_TOOL_LENS &&
  497. (features->type == INTUOS3 ||
  498. features->type == INTUOS3S ||
  499. features->type == INTUOS4 ||
  500. features->type == INTUOS4S ||
  501. features->type == INTUOS5 ||
  502. features->type == INTUOS5S ||
  503. features->type == INTUOSPM ||
  504. features->type == INTUOSPS)) ||
  505. /* Cintiq doesn't send data when RDY bit isn't set */
  506. (features->type == CINTIQ && !(data[1] & 0x40)))
  507. return 1;
  508. wacom->shared->stylus_in_proximity = true;
  509. if (wacom->shared->touch_down)
  510. return 1;
  511. /* in Range while exiting */
  512. if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
  513. input_report_key(input, BTN_TOUCH, 0);
  514. input_report_abs(input, ABS_PRESSURE, 0);
  515. input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
  516. return 2;
  517. }
  518. /* Exit report */
  519. if ((data[1] & 0xfe) == 0x80) {
  520. wacom->shared->stylus_in_proximity = false;
  521. wacom->reporting_data = false;
  522. /* don't report exit if we don't know the ID */
  523. if (!wacom->id[idx])
  524. return 1;
  525. /*
  526. * Reset all states otherwise we lose the initial states
  527. * when in-prox next time
  528. */
  529. input_report_abs(input, ABS_X, 0);
  530. input_report_abs(input, ABS_Y, 0);
  531. input_report_abs(input, ABS_DISTANCE, 0);
  532. input_report_abs(input, ABS_TILT_X, 0);
  533. input_report_abs(input, ABS_TILT_Y, 0);
  534. if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
  535. input_report_key(input, BTN_LEFT, 0);
  536. input_report_key(input, BTN_MIDDLE, 0);
  537. input_report_key(input, BTN_RIGHT, 0);
  538. input_report_key(input, BTN_SIDE, 0);
  539. input_report_key(input, BTN_EXTRA, 0);
  540. input_report_abs(input, ABS_THROTTLE, 0);
  541. input_report_abs(input, ABS_RZ, 0);
  542. } else {
  543. input_report_abs(input, ABS_PRESSURE, 0);
  544. input_report_key(input, BTN_STYLUS, 0);
  545. input_report_key(input, BTN_STYLUS2, 0);
  546. input_report_key(input, BTN_TOUCH, 0);
  547. input_report_abs(input, ABS_WHEEL, 0);
  548. if (features->type >= INTUOS3S)
  549. input_report_abs(input, ABS_Z, 0);
  550. }
  551. input_report_key(input, wacom->tool[idx], 0);
  552. input_report_abs(input, ABS_MISC, 0); /* reset tool id */
  553. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  554. wacom->id[idx] = 0;
  555. return 2;
  556. }
  557. /* don't report other events if we don't know the ID */
  558. if (!wacom->id[idx]) {
  559. /* but reschedule a read of the current tool */
  560. wacom_intuos_schedule_prox_event(wacom);
  561. return 1;
  562. }
  563. return 0;
  564. }
  565. static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
  566. {
  567. unsigned char *data = wacom_wac->data;
  568. struct input_dev *input = wacom_wac->pad_input;
  569. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  570. struct wacom_features *features = &wacom_wac->features;
  571. int bat_charging, bat_percent, touch_ring_mode;
  572. __u32 serial;
  573. int i;
  574. if (data[0] != WACOM_REPORT_REMOTE) {
  575. dev_dbg(input->dev.parent,
  576. "%s: received unknown report #%d", __func__, data[0]);
  577. return 0;
  578. }
  579. serial = data[3] + (data[4] << 8) + (data[5] << 16);
  580. wacom_wac->id[0] = PAD_DEVICE_ID;
  581. input_report_key(input, BTN_0, (data[9] & 0x01));
  582. input_report_key(input, BTN_1, (data[9] & 0x02));
  583. input_report_key(input, BTN_2, (data[9] & 0x04));
  584. input_report_key(input, BTN_3, (data[9] & 0x08));
  585. input_report_key(input, BTN_4, (data[9] & 0x10));
  586. input_report_key(input, BTN_5, (data[9] & 0x20));
  587. input_report_key(input, BTN_6, (data[9] & 0x40));
  588. input_report_key(input, BTN_7, (data[9] & 0x80));
  589. input_report_key(input, BTN_8, (data[10] & 0x01));
  590. input_report_key(input, BTN_9, (data[10] & 0x02));
  591. input_report_key(input, BTN_A, (data[10] & 0x04));
  592. input_report_key(input, BTN_B, (data[10] & 0x08));
  593. input_report_key(input, BTN_C, (data[10] & 0x10));
  594. input_report_key(input, BTN_X, (data[10] & 0x20));
  595. input_report_key(input, BTN_Y, (data[10] & 0x40));
  596. input_report_key(input, BTN_Z, (data[10] & 0x80));
  597. input_report_key(input, BTN_BASE, (data[11] & 0x01));
  598. input_report_key(input, BTN_BASE2, (data[11] & 0x02));
  599. if (data[12] & 0x80)
  600. input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
  601. else
  602. input_report_abs(input, ABS_WHEEL, 0);
  603. bat_percent = data[7] & 0x7f;
  604. bat_charging = !!(data[7] & 0x80);
  605. if (data[9] | data[10] | (data[11] & 0x03) | data[12])
  606. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  607. else
  608. input_report_abs(input, ABS_MISC, 0);
  609. input_event(input, EV_MSC, MSC_SERIAL, serial);
  610. /*Which mode select (LED light) is currently on?*/
  611. touch_ring_mode = (data[11] & 0xC0) >> 6;
  612. for (i = 0; i < WACOM_MAX_REMOTES; i++) {
  613. if (wacom_wac->serial[i] == serial)
  614. wacom->led.select[i] = touch_ring_mode;
  615. }
  616. if (!wacom->battery &&
  617. !(features->quirks & WACOM_QUIRK_BATTERY)) {
  618. features->quirks |= WACOM_QUIRK_BATTERY;
  619. INIT_WORK(&wacom->work, wacom_battery_work);
  620. wacom_schedule_work(wacom_wac);
  621. }
  622. wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
  623. bat_charging);
  624. return 1;
  625. }
  626. static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
  627. {
  628. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  629. unsigned char *data = wacom_wac->data;
  630. int i;
  631. if (data[0] != WACOM_REPORT_DEVICE_LIST)
  632. return 0;
  633. for (i = 0; i < WACOM_MAX_REMOTES; i++) {
  634. int j = i * 6;
  635. int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
  636. bool connected = data[j+2];
  637. if (connected) {
  638. int k;
  639. if (wacom_wac->serial[i] == serial)
  640. continue;
  641. if (wacom_wac->serial[i]) {
  642. wacom_remote_destroy_attr_group(wacom,
  643. wacom_wac->serial[i]);
  644. }
  645. /* A remote can pair more than once with an EKR,
  646. * check to make sure this serial isn't already paired.
  647. */
  648. for (k = 0; k < WACOM_MAX_REMOTES; k++) {
  649. if (wacom_wac->serial[k] == serial)
  650. break;
  651. }
  652. if (k < WACOM_MAX_REMOTES) {
  653. wacom_wac->serial[i] = serial;
  654. continue;
  655. }
  656. wacom_remote_create_attr_group(wacom, serial, i);
  657. } else if (wacom_wac->serial[i]) {
  658. wacom_remote_destroy_attr_group(wacom,
  659. wacom_wac->serial[i]);
  660. }
  661. }
  662. return 0;
  663. }
  664. static void wacom_intuos_general(struct wacom_wac *wacom)
  665. {
  666. struct wacom_features *features = &wacom->features;
  667. unsigned char *data = wacom->data;
  668. struct input_dev *input = wacom->pen_input;
  669. unsigned int t;
  670. /* general pen packet */
  671. if ((data[1] & 0xb8) == 0xa0) {
  672. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  673. if (features->type >= INTUOS4S && features->type <= CINTIQ_HYBRID) {
  674. t = (t << 1) | (data[1] & 1);
  675. }
  676. input_report_abs(input, ABS_PRESSURE, t);
  677. input_report_abs(input, ABS_TILT_X,
  678. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  679. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  680. input_report_key(input, BTN_STYLUS, data[1] & 2);
  681. input_report_key(input, BTN_STYLUS2, data[1] & 4);
  682. input_report_key(input, BTN_TOUCH, t > 10);
  683. }
  684. /* airbrush second packet */
  685. if ((data[1] & 0xbc) == 0xb4) {
  686. input_report_abs(input, ABS_WHEEL,
  687. (data[6] << 2) | ((data[7] >> 6) & 3));
  688. input_report_abs(input, ABS_TILT_X,
  689. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  690. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  691. }
  692. }
  693. static int wacom_intuos_irq(struct wacom_wac *wacom)
  694. {
  695. struct wacom_features *features = &wacom->features;
  696. unsigned char *data = wacom->data;
  697. struct input_dev *input = wacom->pen_input;
  698. unsigned int t;
  699. int idx = 0, result;
  700. if (data[0] != WACOM_REPORT_PENABLED &&
  701. data[0] != WACOM_REPORT_INTUOSREAD &&
  702. data[0] != WACOM_REPORT_INTUOSWRITE &&
  703. data[0] != WACOM_REPORT_INTUOSPAD &&
  704. data[0] != WACOM_REPORT_CINTIQ &&
  705. data[0] != WACOM_REPORT_CINTIQPAD &&
  706. data[0] != WACOM_REPORT_INTUOS5PAD) {
  707. dev_dbg(input->dev.parent,
  708. "%s: received unknown report #%d\n", __func__, data[0]);
  709. return 0;
  710. }
  711. /* tool number */
  712. if (features->type == INTUOS)
  713. idx = data[1] & 0x01;
  714. /* pad packets. Works as a second tool and is always in prox */
  715. if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
  716. data[0] == WACOM_REPORT_CINTIQPAD) {
  717. input = wacom->pad_input;
  718. if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
  719. input_report_key(input, BTN_0, (data[2] & 0x01));
  720. input_report_key(input, BTN_1, (data[3] & 0x01));
  721. input_report_key(input, BTN_2, (data[3] & 0x02));
  722. input_report_key(input, BTN_3, (data[3] & 0x04));
  723. input_report_key(input, BTN_4, (data[3] & 0x08));
  724. input_report_key(input, BTN_5, (data[3] & 0x10));
  725. input_report_key(input, BTN_6, (data[3] & 0x20));
  726. if (data[1] & 0x80) {
  727. input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
  728. } else {
  729. /* Out of proximity, clear wheel value. */
  730. input_report_abs(input, ABS_WHEEL, 0);
  731. }
  732. if (features->type != INTUOS4S) {
  733. input_report_key(input, BTN_7, (data[3] & 0x40));
  734. input_report_key(input, BTN_8, (data[3] & 0x80));
  735. }
  736. if (data[1] | (data[2] & 0x01) | data[3]) {
  737. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  738. } else {
  739. input_report_abs(input, ABS_MISC, 0);
  740. }
  741. } else if (features->type == DTK) {
  742. input_report_key(input, BTN_0, (data[6] & 0x01));
  743. input_report_key(input, BTN_1, (data[6] & 0x02));
  744. input_report_key(input, BTN_2, (data[6] & 0x04));
  745. input_report_key(input, BTN_3, (data[6] & 0x08));
  746. input_report_key(input, BTN_4, (data[6] & 0x10));
  747. input_report_key(input, BTN_5, (data[6] & 0x20));
  748. if (data[6] & 0x3f) {
  749. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  750. } else {
  751. input_report_abs(input, ABS_MISC, 0);
  752. }
  753. } else if (features->type == WACOM_13HD) {
  754. input_report_key(input, BTN_0, (data[3] & 0x01));
  755. input_report_key(input, BTN_1, (data[4] & 0x01));
  756. input_report_key(input, BTN_2, (data[4] & 0x02));
  757. input_report_key(input, BTN_3, (data[4] & 0x04));
  758. input_report_key(input, BTN_4, (data[4] & 0x08));
  759. input_report_key(input, BTN_5, (data[4] & 0x10));
  760. input_report_key(input, BTN_6, (data[4] & 0x20));
  761. input_report_key(input, BTN_7, (data[4] & 0x40));
  762. input_report_key(input, BTN_8, (data[4] & 0x80));
  763. if ((data[3] & 0x01) | data[4]) {
  764. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  765. } else {
  766. input_report_abs(input, ABS_MISC, 0);
  767. }
  768. } else if (features->type == WACOM_24HD) {
  769. input_report_key(input, BTN_0, (data[6] & 0x01));
  770. input_report_key(input, BTN_1, (data[6] & 0x02));
  771. input_report_key(input, BTN_2, (data[6] & 0x04));
  772. input_report_key(input, BTN_3, (data[6] & 0x08));
  773. input_report_key(input, BTN_4, (data[6] & 0x10));
  774. input_report_key(input, BTN_5, (data[6] & 0x20));
  775. input_report_key(input, BTN_6, (data[6] & 0x40));
  776. input_report_key(input, BTN_7, (data[6] & 0x80));
  777. input_report_key(input, BTN_8, (data[8] & 0x01));
  778. input_report_key(input, BTN_9, (data[8] & 0x02));
  779. input_report_key(input, BTN_A, (data[8] & 0x04));
  780. input_report_key(input, BTN_B, (data[8] & 0x08));
  781. input_report_key(input, BTN_C, (data[8] & 0x10));
  782. input_report_key(input, BTN_X, (data[8] & 0x20));
  783. input_report_key(input, BTN_Y, (data[8] & 0x40));
  784. input_report_key(input, BTN_Z, (data[8] & 0x80));
  785. /*
  786. * Three "buttons" are available on the 24HD which are
  787. * physically implemented as a touchstrip. Each button
  788. * is approximately 3 bits wide with a 2 bit spacing.
  789. * The raw touchstrip bits are stored at:
  790. * ((data[3] & 0x1f) << 8) | data[4])
  791. */
  792. input_report_key(input, KEY_PROG1, data[4] & 0x07);
  793. input_report_key(input, KEY_PROG2, data[4] & 0xE0);
  794. input_report_key(input, KEY_PROG3, data[3] & 0x1C);
  795. if (data[1] & 0x80) {
  796. input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
  797. } else {
  798. /* Out of proximity, clear wheel value. */
  799. input_report_abs(input, ABS_WHEEL, 0);
  800. }
  801. if (data[2] & 0x80) {
  802. input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
  803. } else {
  804. /* Out of proximity, clear second wheel value. */
  805. input_report_abs(input, ABS_THROTTLE, 0);
  806. }
  807. if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) {
  808. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  809. } else {
  810. input_report_abs(input, ABS_MISC, 0);
  811. }
  812. } else if (features->type == WACOM_27QHD) {
  813. input_report_key(input, KEY_PROG1, data[2] & 0x01);
  814. input_report_key(input, KEY_PROG2, data[2] & 0x02);
  815. input_report_key(input, KEY_PROG3, data[2] & 0x04);
  816. input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
  817. input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
  818. input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
  819. if ((data[2] & 0x07) | data[4] | data[5] | data[6] | data[7] | data[8] | data[9]) {
  820. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  821. } else {
  822. input_report_abs(input, ABS_MISC, 0);
  823. }
  824. } else if (features->type == CINTIQ_HYBRID) {
  825. /*
  826. * Do not send hardware buttons under Android. They
  827. * are already sent to the system through GPIO (and
  828. * have different meaning).
  829. */
  830. input_report_key(input, BTN_1, (data[4] & 0x01));
  831. input_report_key(input, BTN_2, (data[4] & 0x02));
  832. input_report_key(input, BTN_3, (data[4] & 0x04));
  833. input_report_key(input, BTN_4, (data[4] & 0x08));
  834. input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */
  835. input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */
  836. input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */
  837. input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */
  838. input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
  839. if (data[4] | (data[3] & 0x01)) {
  840. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  841. } else {
  842. input_report_abs(input, ABS_MISC, 0);
  843. }
  844. } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
  845. int i;
  846. /* Touch ring mode switch has no capacitive sensor */
  847. input_report_key(input, BTN_0, (data[3] & 0x01));
  848. /*
  849. * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
  850. * addition to the mechanical switch. Switch data is
  851. * stored in data[4], capacitive data in data[5].
  852. */
  853. for (i = 0; i < 8; i++)
  854. input_report_key(input, BTN_1 + i, data[4] & (1 << i));
  855. if (data[2] & 0x80) {
  856. input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
  857. } else {
  858. /* Out of proximity, clear wheel value. */
  859. input_report_abs(input, ABS_WHEEL, 0);
  860. }
  861. if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
  862. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  863. } else {
  864. input_report_abs(input, ABS_MISC, 0);
  865. }
  866. } else {
  867. if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
  868. input_report_key(input, BTN_0, (data[5] & 0x01));
  869. input_report_key(input, BTN_1, (data[6] & 0x01));
  870. input_report_key(input, BTN_2, (data[6] & 0x02));
  871. input_report_key(input, BTN_3, (data[6] & 0x04));
  872. input_report_key(input, BTN_4, (data[6] & 0x08));
  873. input_report_key(input, BTN_5, (data[6] & 0x10));
  874. input_report_key(input, BTN_6, (data[6] & 0x20));
  875. input_report_key(input, BTN_7, (data[6] & 0x40));
  876. input_report_key(input, BTN_8, (data[6] & 0x80));
  877. input_report_key(input, BTN_9, (data[7] & 0x01));
  878. input_report_key(input, BTN_A, (data[8] & 0x01));
  879. input_report_key(input, BTN_B, (data[8] & 0x02));
  880. input_report_key(input, BTN_C, (data[8] & 0x04));
  881. input_report_key(input, BTN_X, (data[8] & 0x08));
  882. input_report_key(input, BTN_Y, (data[8] & 0x10));
  883. input_report_key(input, BTN_Z, (data[8] & 0x20));
  884. input_report_key(input, BTN_BASE, (data[8] & 0x40));
  885. input_report_key(input, BTN_BASE2, (data[8] & 0x80));
  886. if (features->type == WACOM_22HD) {
  887. input_report_key(input, KEY_PROG1, data[9] & 0x01);
  888. input_report_key(input, KEY_PROG2, data[9] & 0x02);
  889. input_report_key(input, KEY_PROG3, data[9] & 0x04);
  890. }
  891. } else {
  892. input_report_key(input, BTN_0, (data[5] & 0x01));
  893. input_report_key(input, BTN_1, (data[5] & 0x02));
  894. input_report_key(input, BTN_2, (data[5] & 0x04));
  895. input_report_key(input, BTN_3, (data[5] & 0x08));
  896. input_report_key(input, BTN_4, (data[6] & 0x01));
  897. input_report_key(input, BTN_5, (data[6] & 0x02));
  898. input_report_key(input, BTN_6, (data[6] & 0x04));
  899. input_report_key(input, BTN_7, (data[6] & 0x08));
  900. input_report_key(input, BTN_8, (data[5] & 0x10));
  901. input_report_key(input, BTN_9, (data[6] & 0x10));
  902. }
  903. input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
  904. input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
  905. if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
  906. data[2] | (data[3] & 0x1f) | data[4] | data[8] |
  907. (data[7] & 0x01)) {
  908. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  909. } else {
  910. input_report_abs(input, ABS_MISC, 0);
  911. }
  912. }
  913. return 1;
  914. }
  915. /* process in/out prox events */
  916. result = wacom_intuos_inout(wacom);
  917. if (result)
  918. return result - 1;
  919. if (features->type >= INTUOS3S) {
  920. input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
  921. input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
  922. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
  923. } else {
  924. input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2]));
  925. input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4]));
  926. input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
  927. }
  928. /* process general packets */
  929. wacom_intuos_general(wacom);
  930. /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */
  931. if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) {
  932. if (data[1] & 0x02) {
  933. /* Rotation packet */
  934. if (features->type >= INTUOS3S) {
  935. /* I3 marker pen rotation */
  936. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  937. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  938. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  939. input_report_abs(input, ABS_Z, t);
  940. } else {
  941. /* 4D mouse rotation packet */
  942. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  943. input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
  944. ((t - 1) / 2) : -t / 2);
  945. }
  946. } else if (!(data[1] & 0x10) && features->type < INTUOS3S) {
  947. /* 4D mouse packet */
  948. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  949. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  950. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  951. input_report_key(input, BTN_SIDE, data[8] & 0x20);
  952. input_report_key(input, BTN_EXTRA, data[8] & 0x10);
  953. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  954. input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  955. } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  956. /* I4 mouse */
  957. if (features->type >= INTUOS4S && features->type <= INTUOSPL) {
  958. input_report_key(input, BTN_LEFT, data[6] & 0x01);
  959. input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
  960. input_report_key(input, BTN_RIGHT, data[6] & 0x04);
  961. input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
  962. - ((data[7] & 0x40) >> 6));
  963. input_report_key(input, BTN_SIDE, data[6] & 0x08);
  964. input_report_key(input, BTN_EXTRA, data[6] & 0x10);
  965. input_report_abs(input, ABS_TILT_X,
  966. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  967. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  968. } else {
  969. /* 2D mouse packet */
  970. input_report_key(input, BTN_LEFT, data[8] & 0x04);
  971. input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
  972. input_report_key(input, BTN_RIGHT, data[8] & 0x10);
  973. input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
  974. - ((data[8] & 0x02) >> 1));
  975. /* I3 2D mouse side buttons */
  976. if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
  977. input_report_key(input, BTN_SIDE, data[8] & 0x40);
  978. input_report_key(input, BTN_EXTRA, data[8] & 0x20);
  979. }
  980. }
  981. } else if ((features->type < INTUOS3S || features->type == INTUOS3L ||
  982. features->type == INTUOS4L || features->type == INTUOS5L ||
  983. features->type == INTUOSPL) &&
  984. wacom->tool[idx] == BTN_TOOL_LENS) {
  985. /* Lens cursor packets */
  986. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  987. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  988. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  989. input_report_key(input, BTN_SIDE, data[8] & 0x10);
  990. input_report_key(input, BTN_EXTRA, data[8] & 0x08);
  991. }
  992. }
  993. input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */
  994. input_report_key(input, wacom->tool[idx], 1);
  995. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  996. wacom->reporting_data = true;
  997. return 1;
  998. }
  999. static int int_dist(int x1, int y1, int x2, int y2)
  1000. {
  1001. int x = x2 - x1;
  1002. int y = y2 - y1;
  1003. return int_sqrt(x*x + y*y);
  1004. }
  1005. static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
  1006. unsigned char *data)
  1007. {
  1008. memcpy(wacom->data, data, 10);
  1009. wacom_intuos_irq(wacom);
  1010. input_sync(wacom->pen_input);
  1011. if (wacom->pad_input)
  1012. input_sync(wacom->pad_input);
  1013. }
  1014. static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
  1015. {
  1016. unsigned char data[WACOM_PKGLEN_MAX];
  1017. int i = 1;
  1018. unsigned power_raw, battery_capacity, bat_charging, ps_connected;
  1019. memcpy(data, wacom->data, len);
  1020. switch (data[0]) {
  1021. case 0x04:
  1022. wacom_intuos_bt_process_data(wacom, data + i);
  1023. i += 10;
  1024. /* fall through */
  1025. case 0x03:
  1026. wacom_intuos_bt_process_data(wacom, data + i);
  1027. i += 10;
  1028. wacom_intuos_bt_process_data(wacom, data + i);
  1029. i += 10;
  1030. power_raw = data[i];
  1031. bat_charging = (power_raw & 0x08) ? 1 : 0;
  1032. ps_connected = (power_raw & 0x10) ? 1 : 0;
  1033. battery_capacity = batcap_i4[power_raw & 0x07];
  1034. wacom_notify_battery(wacom, battery_capacity, bat_charging,
  1035. battery_capacity || bat_charging,
  1036. ps_connected);
  1037. break;
  1038. default:
  1039. dev_dbg(wacom->pen_input->dev.parent,
  1040. "Unknown report: %d,%d size:%zu\n",
  1041. data[0], data[1], len);
  1042. return 0;
  1043. }
  1044. return 0;
  1045. }
  1046. static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
  1047. {
  1048. struct input_dev *input = wacom->touch_input;
  1049. unsigned touch_max = wacom->features.touch_max;
  1050. int count = 0;
  1051. int i;
  1052. if (!touch_max)
  1053. return 0;
  1054. if (touch_max == 1)
  1055. return test_bit(BTN_TOUCH, input->key) &&
  1056. !wacom->shared->stylus_in_proximity;
  1057. for (i = 0; i < input->mt->num_slots; i++) {
  1058. struct input_mt_slot *ps = &input->mt->slots[i];
  1059. int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
  1060. if (id >= 0)
  1061. count++;
  1062. }
  1063. return count;
  1064. }
  1065. static int wacom_24hdt_irq(struct wacom_wac *wacom)
  1066. {
  1067. struct input_dev *input = wacom->touch_input;
  1068. unsigned char *data = wacom->data;
  1069. int i;
  1070. int current_num_contacts = data[61];
  1071. int contacts_to_send = 0;
  1072. int num_contacts_left = 4; /* maximum contacts per packet */
  1073. int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
  1074. int y_offset = 2;
  1075. if (wacom->features.type == WACOM_27QHDT) {
  1076. current_num_contacts = data[63];
  1077. num_contacts_left = 10;
  1078. byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
  1079. y_offset = 0;
  1080. }
  1081. /*
  1082. * First packet resets the counter since only the first
  1083. * packet in series will have non-zero current_num_contacts.
  1084. */
  1085. if (current_num_contacts)
  1086. wacom->num_contacts_left = current_num_contacts;
  1087. contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
  1088. for (i = 0; i < contacts_to_send; i++) {
  1089. int offset = (byte_per_packet * i) + 1;
  1090. bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
  1091. int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
  1092. if (slot < 0)
  1093. continue;
  1094. input_mt_slot(input, slot);
  1095. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1096. if (touch) {
  1097. int t_x = get_unaligned_le16(&data[offset + 2]);
  1098. int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
  1099. input_report_abs(input, ABS_MT_POSITION_X, t_x);
  1100. input_report_abs(input, ABS_MT_POSITION_Y, t_y);
  1101. if (wacom->features.type != WACOM_27QHDT) {
  1102. int c_x = get_unaligned_le16(&data[offset + 4]);
  1103. int c_y = get_unaligned_le16(&data[offset + 8]);
  1104. int w = get_unaligned_le16(&data[offset + 10]);
  1105. int h = get_unaligned_le16(&data[offset + 12]);
  1106. input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
  1107. input_report_abs(input, ABS_MT_WIDTH_MAJOR,
  1108. min(w, h) + int_dist(t_x, t_y, c_x, c_y));
  1109. input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
  1110. input_report_abs(input, ABS_MT_ORIENTATION, w > h);
  1111. }
  1112. }
  1113. }
  1114. input_mt_sync_frame(input);
  1115. wacom->num_contacts_left -= contacts_to_send;
  1116. if (wacom->num_contacts_left <= 0) {
  1117. wacom->num_contacts_left = 0;
  1118. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1119. }
  1120. return 1;
  1121. }
  1122. static int wacom_mt_touch(struct wacom_wac *wacom)
  1123. {
  1124. struct input_dev *input = wacom->touch_input;
  1125. unsigned char *data = wacom->data;
  1126. int i;
  1127. int current_num_contacts = data[2];
  1128. int contacts_to_send = 0;
  1129. int x_offset = 0;
  1130. /* MTTPC does not support Height and Width */
  1131. if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
  1132. x_offset = -4;
  1133. /*
  1134. * First packet resets the counter since only the first
  1135. * packet in series will have non-zero current_num_contacts.
  1136. */
  1137. if (current_num_contacts)
  1138. wacom->num_contacts_left = current_num_contacts;
  1139. /* There are at most 5 contacts per packet */
  1140. contacts_to_send = min(5, wacom->num_contacts_left);
  1141. for (i = 0; i < contacts_to_send; i++) {
  1142. int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
  1143. bool touch = (data[offset] & 0x1) && !wacom->shared->stylus_in_proximity;
  1144. int id = get_unaligned_le16(&data[offset + 1]);
  1145. int slot = input_mt_get_slot_by_key(input, id);
  1146. if (slot < 0)
  1147. continue;
  1148. input_mt_slot(input, slot);
  1149. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1150. if (touch) {
  1151. int x = get_unaligned_le16(&data[offset + x_offset + 7]);
  1152. int y = get_unaligned_le16(&data[offset + x_offset + 9]);
  1153. input_report_abs(input, ABS_MT_POSITION_X, x);
  1154. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1155. }
  1156. }
  1157. input_mt_sync_frame(input);
  1158. wacom->num_contacts_left -= contacts_to_send;
  1159. if (wacom->num_contacts_left <= 0) {
  1160. wacom->num_contacts_left = 0;
  1161. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1162. }
  1163. return 1;
  1164. }
  1165. static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
  1166. {
  1167. struct input_dev *input = wacom->touch_input;
  1168. unsigned char *data = wacom->data;
  1169. int i;
  1170. for (i = 0; i < 2; i++) {
  1171. int p = data[1] & (1 << i);
  1172. bool touch = p && !wacom->shared->stylus_in_proximity;
  1173. input_mt_slot(input, i);
  1174. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1175. if (touch) {
  1176. int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
  1177. int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
  1178. input_report_abs(input, ABS_MT_POSITION_X, x);
  1179. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1180. }
  1181. }
  1182. input_mt_sync_frame(input);
  1183. /* keep touch state for pen event */
  1184. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1185. return 1;
  1186. }
  1187. static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
  1188. {
  1189. unsigned char *data = wacom->data;
  1190. struct input_dev *input = wacom->touch_input;
  1191. bool prox = !wacom->shared->stylus_in_proximity;
  1192. int x = 0, y = 0;
  1193. if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
  1194. return 0;
  1195. if (len == WACOM_PKGLEN_TPC1FG) {
  1196. prox = prox && (data[0] & 0x01);
  1197. x = get_unaligned_le16(&data[1]);
  1198. y = get_unaligned_le16(&data[3]);
  1199. } else if (len == WACOM_PKGLEN_TPC1FG_B) {
  1200. prox = prox && (data[2] & 0x01);
  1201. x = get_unaligned_le16(&data[3]);
  1202. y = get_unaligned_le16(&data[5]);
  1203. } else {
  1204. prox = prox && (data[1] & 0x01);
  1205. x = le16_to_cpup((__le16 *)&data[2]);
  1206. y = le16_to_cpup((__le16 *)&data[4]);
  1207. }
  1208. if (prox) {
  1209. input_report_abs(input, ABS_X, x);
  1210. input_report_abs(input, ABS_Y, y);
  1211. }
  1212. input_report_key(input, BTN_TOUCH, prox);
  1213. /* keep touch state for pen events */
  1214. wacom->shared->touch_down = prox;
  1215. return 1;
  1216. }
  1217. static int wacom_tpc_pen(struct wacom_wac *wacom)
  1218. {
  1219. unsigned char *data = wacom->data;
  1220. struct input_dev *input = wacom->pen_input;
  1221. bool prox = data[1] & 0x20;
  1222. if (!wacom->shared->stylus_in_proximity) /* first in prox */
  1223. /* Going into proximity select tool */
  1224. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  1225. /* keep pen state for touch events */
  1226. wacom->shared->stylus_in_proximity = prox;
  1227. /* send pen events only when touch is up or forced out */
  1228. if (!wacom->shared->touch_down) {
  1229. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  1230. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  1231. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  1232. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  1233. input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
  1234. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  1235. input_report_key(input, wacom->tool[0], prox);
  1236. return 1;
  1237. }
  1238. return 0;
  1239. }
  1240. static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
  1241. {
  1242. unsigned char *data = wacom->data;
  1243. if (wacom->pen_input)
  1244. dev_dbg(wacom->pen_input->dev.parent,
  1245. "%s: received report #%d\n", __func__, data[0]);
  1246. else if (wacom->touch_input)
  1247. dev_dbg(wacom->touch_input->dev.parent,
  1248. "%s: received report #%d\n", __func__, data[0]);
  1249. switch (len) {
  1250. case WACOM_PKGLEN_TPC1FG:
  1251. return wacom_tpc_single_touch(wacom, len);
  1252. case WACOM_PKGLEN_TPC2FG:
  1253. return wacom_tpc_mt_touch(wacom);
  1254. case WACOM_PKGLEN_PENABLED:
  1255. return wacom_tpc_pen(wacom);
  1256. default:
  1257. switch (data[0]) {
  1258. case WACOM_REPORT_TPC1FG:
  1259. case WACOM_REPORT_TPCHID:
  1260. case WACOM_REPORT_TPCST:
  1261. case WACOM_REPORT_TPC1FGE:
  1262. return wacom_tpc_single_touch(wacom, len);
  1263. case WACOM_REPORT_TPCMT:
  1264. case WACOM_REPORT_TPCMT2:
  1265. return wacom_mt_touch(wacom);
  1266. case WACOM_REPORT_PENABLED:
  1267. return wacom_tpc_pen(wacom);
  1268. }
  1269. }
  1270. return 0;
  1271. }
  1272. static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
  1273. struct hid_field *field, __u8 type, __u16 code, int fuzz)
  1274. {
  1275. int fmin = field->logical_minimum;
  1276. int fmax = field->logical_maximum;
  1277. usage->type = type;
  1278. usage->code = code;
  1279. set_bit(type, input->evbit);
  1280. switch (type) {
  1281. case EV_ABS:
  1282. input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
  1283. input_abs_set_res(input, code,
  1284. hidinput_calc_abs_res(field, code));
  1285. break;
  1286. case EV_KEY:
  1287. input_set_capability(input, EV_KEY, code);
  1288. break;
  1289. case EV_MSC:
  1290. input_set_capability(input, EV_MSC, code);
  1291. break;
  1292. }
  1293. }
  1294. static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
  1295. struct hid_field *field, struct hid_usage *usage)
  1296. {
  1297. struct wacom *wacom = hid_get_drvdata(hdev);
  1298. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1299. struct input_dev *input = wacom_wac->pen_input;
  1300. switch (usage->hid) {
  1301. case HID_GD_X:
  1302. wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
  1303. break;
  1304. case HID_GD_Y:
  1305. wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
  1306. break;
  1307. case HID_DG_TIPPRESSURE:
  1308. wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
  1309. break;
  1310. case HID_DG_INRANGE:
  1311. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
  1312. break;
  1313. case HID_DG_INVERT:
  1314. wacom_map_usage(input, usage, field, EV_KEY,
  1315. BTN_TOOL_RUBBER, 0);
  1316. break;
  1317. case HID_DG_ERASER:
  1318. case HID_DG_TIPSWITCH:
  1319. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
  1320. break;
  1321. case HID_DG_BARRELSWITCH:
  1322. wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
  1323. break;
  1324. case HID_DG_BARRELSWITCH2:
  1325. wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
  1326. break;
  1327. case HID_DG_TOOLSERIALNUMBER:
  1328. wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
  1329. break;
  1330. }
  1331. }
  1332. static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
  1333. struct hid_usage *usage, __s32 value)
  1334. {
  1335. struct wacom *wacom = hid_get_drvdata(hdev);
  1336. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1337. struct input_dev *input = wacom_wac->pen_input;
  1338. /* checking which Tool / tip switch to send */
  1339. switch (usage->hid) {
  1340. case HID_DG_INRANGE:
  1341. wacom_wac->hid_data.inrange_state = value;
  1342. return 0;
  1343. case HID_DG_INVERT:
  1344. wacom_wac->hid_data.invert_state = value;
  1345. return 0;
  1346. case HID_DG_ERASER:
  1347. case HID_DG_TIPSWITCH:
  1348. wacom_wac->hid_data.tipswitch |= value;
  1349. return 0;
  1350. }
  1351. /* send pen events only when touch is up or forced out */
  1352. if (!usage->type || wacom_wac->shared->touch_down)
  1353. return 0;
  1354. input_event(input, usage->type, usage->code, value);
  1355. return 0;
  1356. }
  1357. static void wacom_wac_pen_pre_report(struct hid_device *hdev,
  1358. struct hid_report *report)
  1359. {
  1360. return;
  1361. }
  1362. static void wacom_wac_pen_report(struct hid_device *hdev,
  1363. struct hid_report *report)
  1364. {
  1365. struct wacom *wacom = hid_get_drvdata(hdev);
  1366. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1367. struct input_dev *input = wacom_wac->pen_input;
  1368. bool prox = wacom_wac->hid_data.inrange_state;
  1369. if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
  1370. /* Going into proximity select tool */
  1371. wacom_wac->tool[0] = wacom_wac->hid_data.invert_state ?
  1372. BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  1373. /* keep pen state for touch events */
  1374. wacom_wac->shared->stylus_in_proximity = prox;
  1375. /* send pen events only when touch is up or forced out */
  1376. if (!wacom_wac->shared->touch_down) {
  1377. input_report_key(input, BTN_TOUCH,
  1378. wacom_wac->hid_data.tipswitch);
  1379. input_report_key(input, wacom_wac->tool[0], prox);
  1380. wacom_wac->hid_data.tipswitch = false;
  1381. input_sync(input);
  1382. }
  1383. }
  1384. static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
  1385. struct hid_field *field, struct hid_usage *usage)
  1386. {
  1387. struct wacom *wacom = hid_get_drvdata(hdev);
  1388. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1389. struct wacom_features *features = &wacom_wac->features;
  1390. struct input_dev *input = wacom_wac->touch_input;
  1391. unsigned touch_max = wacom_wac->features.touch_max;
  1392. switch (usage->hid) {
  1393. case HID_GD_X:
  1394. features->last_slot_field = usage->hid;
  1395. if (touch_max == 1)
  1396. wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
  1397. else
  1398. wacom_map_usage(input, usage, field, EV_ABS,
  1399. ABS_MT_POSITION_X, 4);
  1400. break;
  1401. case HID_GD_Y:
  1402. features->last_slot_field = usage->hid;
  1403. if (touch_max == 1)
  1404. wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
  1405. else
  1406. wacom_map_usage(input, usage, field, EV_ABS,
  1407. ABS_MT_POSITION_Y, 4);
  1408. break;
  1409. case HID_DG_WIDTH:
  1410. case HID_DG_HEIGHT:
  1411. features->last_slot_field = usage->hid;
  1412. wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
  1413. wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
  1414. input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  1415. break;
  1416. case HID_DG_CONTACTID:
  1417. features->last_slot_field = usage->hid;
  1418. break;
  1419. case HID_DG_INRANGE:
  1420. features->last_slot_field = usage->hid;
  1421. break;
  1422. case HID_DG_INVERT:
  1423. features->last_slot_field = usage->hid;
  1424. break;
  1425. case HID_DG_TIPSWITCH:
  1426. features->last_slot_field = usage->hid;
  1427. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
  1428. break;
  1429. case HID_DG_CONTACTCOUNT:
  1430. wacom_wac->hid_data.cc_index = field->index;
  1431. wacom_wac->hid_data.cc_value_index = usage->usage_index;
  1432. break;
  1433. }
  1434. }
  1435. static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
  1436. struct input_dev *input)
  1437. {
  1438. struct hid_data *hid_data = &wacom_wac->hid_data;
  1439. bool mt = wacom_wac->features.touch_max > 1;
  1440. bool prox = hid_data->tipswitch &&
  1441. !wacom_wac->shared->stylus_in_proximity;
  1442. wacom_wac->hid_data.num_received++;
  1443. if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
  1444. return;
  1445. if (mt) {
  1446. int slot;
  1447. slot = input_mt_get_slot_by_key(input, hid_data->id);
  1448. input_mt_slot(input, slot);
  1449. input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
  1450. }
  1451. else {
  1452. input_report_key(input, BTN_TOUCH, prox);
  1453. }
  1454. if (prox) {
  1455. input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
  1456. hid_data->x);
  1457. input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
  1458. hid_data->y);
  1459. if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
  1460. input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
  1461. input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
  1462. if (hid_data->width != hid_data->height)
  1463. input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
  1464. }
  1465. }
  1466. }
  1467. static int wacom_wac_finger_event(struct hid_device *hdev,
  1468. struct hid_field *field, struct hid_usage *usage, __s32 value)
  1469. {
  1470. struct wacom *wacom = hid_get_drvdata(hdev);
  1471. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1472. switch (usage->hid) {
  1473. case HID_GD_X:
  1474. wacom_wac->hid_data.x = value;
  1475. break;
  1476. case HID_GD_Y:
  1477. wacom_wac->hid_data.y = value;
  1478. break;
  1479. case HID_DG_WIDTH:
  1480. wacom_wac->hid_data.width = value;
  1481. break;
  1482. case HID_DG_HEIGHT:
  1483. wacom_wac->hid_data.height = value;
  1484. break;
  1485. case HID_DG_CONTACTID:
  1486. wacom_wac->hid_data.id = value;
  1487. break;
  1488. case HID_DG_TIPSWITCH:
  1489. wacom_wac->hid_data.tipswitch = value;
  1490. break;
  1491. }
  1492. if (usage->usage_index + 1 == field->report_count) {
  1493. if (usage->hid == wacom_wac->features.last_slot_field)
  1494. wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
  1495. }
  1496. return 0;
  1497. }
  1498. static void wacom_wac_finger_pre_report(struct hid_device *hdev,
  1499. struct hid_report *report)
  1500. {
  1501. struct wacom *wacom = hid_get_drvdata(hdev);
  1502. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1503. struct hid_data* hid_data = &wacom_wac->hid_data;
  1504. if (hid_data->cc_index >= 0) {
  1505. struct hid_field *field = report->field[hid_data->cc_index];
  1506. int value = field->value[hid_data->cc_value_index];
  1507. if (value)
  1508. hid_data->num_expected = value;
  1509. }
  1510. else {
  1511. hid_data->num_expected = wacom_wac->features.touch_max;
  1512. }
  1513. }
  1514. static void wacom_wac_finger_report(struct hid_device *hdev,
  1515. struct hid_report *report)
  1516. {
  1517. struct wacom *wacom = hid_get_drvdata(hdev);
  1518. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1519. struct input_dev *input = wacom_wac->touch_input;
  1520. unsigned touch_max = wacom_wac->features.touch_max;
  1521. /* If more packets of data are expected, give us a chance to
  1522. * process them rather than immediately syncing a partial
  1523. * update.
  1524. */
  1525. if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
  1526. return;
  1527. if (touch_max > 1)
  1528. input_mt_sync_frame(input);
  1529. input_sync(input);
  1530. wacom_wac->hid_data.num_received = 0;
  1531. /* keep touch state for pen event */
  1532. wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
  1533. }
  1534. void wacom_wac_usage_mapping(struct hid_device *hdev,
  1535. struct hid_field *field, struct hid_usage *usage)
  1536. {
  1537. struct wacom *wacom = hid_get_drvdata(hdev);
  1538. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1539. /* currently, only direct devices have proper hid report descriptors */
  1540. __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
  1541. __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
  1542. if (WACOM_PEN_FIELD(field))
  1543. return wacom_wac_pen_usage_mapping(hdev, field, usage);
  1544. if (WACOM_FINGER_FIELD(field))
  1545. return wacom_wac_finger_usage_mapping(hdev, field, usage);
  1546. }
  1547. int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
  1548. struct hid_usage *usage, __s32 value)
  1549. {
  1550. struct wacom *wacom = hid_get_drvdata(hdev);
  1551. if (wacom->wacom_wac.features.type != HID_GENERIC)
  1552. return 0;
  1553. if (WACOM_PEN_FIELD(field))
  1554. return wacom_wac_pen_event(hdev, field, usage, value);
  1555. if (WACOM_FINGER_FIELD(field))
  1556. return wacom_wac_finger_event(hdev, field, usage, value);
  1557. return 0;
  1558. }
  1559. static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
  1560. {
  1561. int r;
  1562. for (r = 0; r < report->maxfield; r++) {
  1563. struct hid_field *field;
  1564. unsigned count, n;
  1565. field = report->field[r];
  1566. count = field->report_count;
  1567. if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
  1568. continue;
  1569. for (n = 0; n < count; n++)
  1570. wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
  1571. }
  1572. }
  1573. void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
  1574. {
  1575. struct wacom *wacom = hid_get_drvdata(hdev);
  1576. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1577. struct hid_field *field = report->field[0];
  1578. if (wacom_wac->features.type != HID_GENERIC)
  1579. return;
  1580. if (WACOM_PEN_FIELD(field))
  1581. wacom_wac_pen_pre_report(hdev, report);
  1582. if (WACOM_FINGER_FIELD(field))
  1583. wacom_wac_finger_pre_report(hdev, report);
  1584. wacom_report_events(hdev, report);
  1585. if (WACOM_PEN_FIELD(field))
  1586. return wacom_wac_pen_report(hdev, report);
  1587. if (WACOM_FINGER_FIELD(field))
  1588. return wacom_wac_finger_report(hdev, report);
  1589. }
  1590. static int wacom_bpt_touch(struct wacom_wac *wacom)
  1591. {
  1592. struct wacom_features *features = &wacom->features;
  1593. struct input_dev *input = wacom->touch_input;
  1594. struct input_dev *pad_input = wacom->pad_input;
  1595. unsigned char *data = wacom->data;
  1596. int i;
  1597. if (data[0] != 0x02)
  1598. return 0;
  1599. for (i = 0; i < 2; i++) {
  1600. int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
  1601. bool touch = data[offset + 3] & 0x80;
  1602. /*
  1603. * Touch events need to be disabled while stylus is
  1604. * in proximity because user's hand is resting on touchpad
  1605. * and sending unwanted events. User expects tablet buttons
  1606. * to continue working though.
  1607. */
  1608. touch = touch && !wacom->shared->stylus_in_proximity;
  1609. input_mt_slot(input, i);
  1610. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1611. if (touch) {
  1612. int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
  1613. int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
  1614. if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
  1615. x <<= 5;
  1616. y <<= 5;
  1617. }
  1618. input_report_abs(input, ABS_MT_POSITION_X, x);
  1619. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1620. }
  1621. }
  1622. input_mt_sync_frame(input);
  1623. input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
  1624. input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
  1625. input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
  1626. input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
  1627. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1628. return 1;
  1629. }
  1630. static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
  1631. {
  1632. struct wacom_features *features = &wacom->features;
  1633. struct input_dev *input = wacom->touch_input;
  1634. bool touch = data[1] & 0x80;
  1635. int slot = input_mt_get_slot_by_key(input, data[0]);
  1636. if (slot < 0)
  1637. return;
  1638. touch = touch && !wacom->shared->stylus_in_proximity;
  1639. input_mt_slot(input, slot);
  1640. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1641. if (touch) {
  1642. int x = (data[2] << 4) | (data[4] >> 4);
  1643. int y = (data[3] << 4) | (data[4] & 0x0f);
  1644. int width, height;
  1645. if (features->type >= INTUOSPS && features->type <= INTUOSHT) {
  1646. width = data[5] * 100;
  1647. height = data[6] * 100;
  1648. } else {
  1649. /*
  1650. * "a" is a scaled-down area which we assume is
  1651. * roughly circular and which can be described as:
  1652. * a=(pi*r^2)/C.
  1653. */
  1654. int a = data[5];
  1655. int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
  1656. int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
  1657. width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
  1658. height = width * y_res / x_res;
  1659. }
  1660. input_report_abs(input, ABS_MT_POSITION_X, x);
  1661. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1662. input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
  1663. input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
  1664. }
  1665. }
  1666. static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
  1667. {
  1668. struct input_dev *input = wacom->pad_input;
  1669. struct wacom_features *features = &wacom->features;
  1670. if (features->type == INTUOSHT) {
  1671. input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
  1672. input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
  1673. } else {
  1674. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  1675. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  1676. }
  1677. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  1678. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  1679. }
  1680. static int wacom_bpt3_touch(struct wacom_wac *wacom)
  1681. {
  1682. unsigned char *data = wacom->data;
  1683. int count = data[1] & 0x07;
  1684. int i;
  1685. if (data[0] != 0x02)
  1686. return 0;
  1687. /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
  1688. for (i = 0; i < count; i++) {
  1689. int offset = (8 * i) + 2;
  1690. int msg_id = data[offset];
  1691. if (msg_id >= 2 && msg_id <= 17)
  1692. wacom_bpt3_touch_msg(wacom, data + offset);
  1693. else if (msg_id == 128)
  1694. wacom_bpt3_button_msg(wacom, data + offset);
  1695. }
  1696. /* only update the touch if we actually have a touchpad */
  1697. if (wacom->touch_registered) {
  1698. input_mt_sync_frame(wacom->touch_input);
  1699. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1700. }
  1701. return 1;
  1702. }
  1703. static int wacom_bpt_pen(struct wacom_wac *wacom)
  1704. {
  1705. struct wacom_features *features = &wacom->features;
  1706. struct input_dev *input = wacom->pen_input;
  1707. unsigned char *data = wacom->data;
  1708. int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
  1709. if (data[0] != WACOM_REPORT_PENABLED)
  1710. return 0;
  1711. prox = (data[1] & 0x20) == 0x20;
  1712. /*
  1713. * All reports shared between PEN and RUBBER tool must be
  1714. * forced to a known starting value (zero) when transitioning to
  1715. * out-of-prox.
  1716. *
  1717. * If not reset then, to userspace, it will look like lost events
  1718. * if new tool comes in-prox with same values as previous tool sent.
  1719. *
  1720. * Hardware does report zero in most out-of-prox cases but not all.
  1721. */
  1722. if (!wacom->shared->stylus_in_proximity) {
  1723. if (data[1] & 0x08) {
  1724. wacom->tool[0] = BTN_TOOL_RUBBER;
  1725. wacom->id[0] = ERASER_DEVICE_ID;
  1726. } else {
  1727. wacom->tool[0] = BTN_TOOL_PEN;
  1728. wacom->id[0] = STYLUS_DEVICE_ID;
  1729. }
  1730. }
  1731. wacom->shared->stylus_in_proximity = prox;
  1732. if (wacom->shared->touch_down)
  1733. return 0;
  1734. if (prox) {
  1735. x = le16_to_cpup((__le16 *)&data[2]);
  1736. y = le16_to_cpup((__le16 *)&data[4]);
  1737. p = le16_to_cpup((__le16 *)&data[6]);
  1738. /*
  1739. * Convert distance from out prox to distance from tablet.
  1740. * distance will be greater than distance_max once
  1741. * touching and applying pressure; do not report negative
  1742. * distance.
  1743. */
  1744. if (data[8] <= features->distance_max)
  1745. d = features->distance_max - data[8];
  1746. pen = data[1] & 0x01;
  1747. btn1 = data[1] & 0x02;
  1748. btn2 = data[1] & 0x04;
  1749. } else {
  1750. wacom->id[0] = 0;
  1751. }
  1752. input_report_key(input, BTN_TOUCH, pen);
  1753. input_report_key(input, BTN_STYLUS, btn1);
  1754. input_report_key(input, BTN_STYLUS2, btn2);
  1755. input_report_abs(input, ABS_X, x);
  1756. input_report_abs(input, ABS_Y, y);
  1757. input_report_abs(input, ABS_PRESSURE, p);
  1758. input_report_abs(input, ABS_DISTANCE, d);
  1759. input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
  1760. input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
  1761. return 1;
  1762. }
  1763. static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  1764. {
  1765. if (len == WACOM_PKGLEN_BBTOUCH)
  1766. return wacom_bpt_touch(wacom);
  1767. else if (len == WACOM_PKGLEN_BBTOUCH3)
  1768. return wacom_bpt3_touch(wacom);
  1769. else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
  1770. return wacom_bpt_pen(wacom);
  1771. return 0;
  1772. }
  1773. static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
  1774. unsigned char *data)
  1775. {
  1776. unsigned char prefix;
  1777. /*
  1778. * We need to reroute the event from the debug interface to the
  1779. * pen interface.
  1780. * We need to add the report ID to the actual pen report, so we
  1781. * temporary overwrite the first byte to prevent having to kzalloc/kfree
  1782. * and memcpy the report.
  1783. */
  1784. prefix = data[0];
  1785. data[0] = WACOM_REPORT_BPAD_PEN;
  1786. /*
  1787. * actually reroute the event.
  1788. * No need to check if wacom->shared->pen is valid, hid_input_report()
  1789. * will check for us.
  1790. */
  1791. hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
  1792. WACOM_PKGLEN_PENABLED, 1);
  1793. data[0] = prefix;
  1794. }
  1795. static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
  1796. unsigned char *data)
  1797. {
  1798. struct input_dev *input = wacom->touch_input;
  1799. unsigned char *finger_data, prefix;
  1800. unsigned id;
  1801. int x, y;
  1802. bool valid;
  1803. prefix = data[0];
  1804. for (id = 0; id < wacom->features.touch_max; id++) {
  1805. valid = !!(prefix & BIT(id)) &&
  1806. !wacom->shared->stylus_in_proximity;
  1807. input_mt_slot(input, id);
  1808. input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
  1809. if (!valid)
  1810. continue;
  1811. finger_data = data + 1 + id * 3;
  1812. x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
  1813. y = (finger_data[2] << 4) | (finger_data[1] >> 4);
  1814. input_report_abs(input, ABS_MT_POSITION_X, x);
  1815. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1816. }
  1817. input_mt_sync_frame(input);
  1818. input_report_key(input, BTN_LEFT, prefix & 0x40);
  1819. input_report_key(input, BTN_RIGHT, prefix & 0x80);
  1820. /* keep touch state for pen event */
  1821. wacom->shared->touch_down = !!prefix &&
  1822. !wacom->shared->stylus_in_proximity;
  1823. return 1;
  1824. }
  1825. static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
  1826. {
  1827. unsigned char *data = wacom->data;
  1828. if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
  1829. (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
  1830. (data[0] != WACOM_REPORT_BPAD_TOUCH))
  1831. return 0;
  1832. if (data[1] & 0x01)
  1833. wacom_bamboo_pad_pen_event(wacom, &data[1]);
  1834. if (data[1] & 0x02)
  1835. return wacom_bamboo_pad_touch_event(wacom, &data[9]);
  1836. return 0;
  1837. }
  1838. static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
  1839. {
  1840. unsigned char *data = wacom->data;
  1841. int connected;
  1842. if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
  1843. return 0;
  1844. connected = data[1] & 0x01;
  1845. if (connected) {
  1846. int pid, battery, charging;
  1847. if ((wacom->shared->type == INTUOSHT) &&
  1848. wacom->shared->touch_input &&
  1849. wacom->shared->touch_max) {
  1850. input_report_switch(wacom->shared->touch_input,
  1851. SW_MUTE_DEVICE, data[5] & 0x40);
  1852. input_sync(wacom->shared->touch_input);
  1853. }
  1854. pid = get_unaligned_be16(&data[6]);
  1855. battery = (data[5] & 0x3f) * 100 / 31;
  1856. charging = !!(data[5] & 0x80);
  1857. if (wacom->pid != pid) {
  1858. wacom->pid = pid;
  1859. wacom_schedule_work(wacom);
  1860. }
  1861. if (wacom->shared->type)
  1862. wacom_notify_battery(wacom, battery, charging, 1, 0);
  1863. } else if (wacom->pid != 0) {
  1864. /* disconnected while previously connected */
  1865. wacom->pid = 0;
  1866. wacom_schedule_work(wacom);
  1867. wacom_notify_battery(wacom, 0, 0, 0, 0);
  1868. }
  1869. return 0;
  1870. }
  1871. static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
  1872. {
  1873. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  1874. struct wacom_features *features = &wacom_wac->features;
  1875. unsigned char *data = wacom_wac->data;
  1876. if (data[0] != WACOM_REPORT_USB)
  1877. return 0;
  1878. if (features->type == INTUOSHT &&
  1879. wacom_wac->shared->touch_input &&
  1880. features->touch_max) {
  1881. input_report_switch(wacom_wac->shared->touch_input,
  1882. SW_MUTE_DEVICE, data[8] & 0x40);
  1883. input_sync(wacom_wac->shared->touch_input);
  1884. }
  1885. if (data[9] & 0x02) { /* wireless module is attached */
  1886. int battery = (data[8] & 0x3f) * 100 / 31;
  1887. bool charging = !!(data[8] & 0x80);
  1888. wacom_notify_battery(wacom_wac, battery, charging,
  1889. battery || charging, 1);
  1890. if (!wacom->battery &&
  1891. !(features->quirks & WACOM_QUIRK_BATTERY)) {
  1892. features->quirks |= WACOM_QUIRK_BATTERY;
  1893. INIT_WORK(&wacom->work, wacom_battery_work);
  1894. wacom_schedule_work(wacom_wac);
  1895. }
  1896. }
  1897. else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
  1898. wacom->battery) {
  1899. features->quirks &= ~WACOM_QUIRK_BATTERY;
  1900. INIT_WORK(&wacom->work, wacom_battery_work);
  1901. wacom_schedule_work(wacom_wac);
  1902. wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
  1903. }
  1904. return 0;
  1905. }
  1906. void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  1907. {
  1908. bool sync;
  1909. switch (wacom_wac->features.type) {
  1910. case PENPARTNER:
  1911. sync = wacom_penpartner_irq(wacom_wac);
  1912. break;
  1913. case PL:
  1914. sync = wacom_pl_irq(wacom_wac);
  1915. break;
  1916. case WACOM_G4:
  1917. case GRAPHIRE:
  1918. case GRAPHIRE_BT:
  1919. case WACOM_MO:
  1920. sync = wacom_graphire_irq(wacom_wac);
  1921. break;
  1922. case PTU:
  1923. sync = wacom_ptu_irq(wacom_wac);
  1924. break;
  1925. case DTU:
  1926. sync = wacom_dtu_irq(wacom_wac);
  1927. break;
  1928. case DTUS:
  1929. case DTUSX:
  1930. sync = wacom_dtus_irq(wacom_wac);
  1931. break;
  1932. case INTUOS:
  1933. case INTUOS3S:
  1934. case INTUOS3:
  1935. case INTUOS3L:
  1936. case INTUOS4S:
  1937. case INTUOS4:
  1938. case INTUOS4L:
  1939. case CINTIQ:
  1940. case WACOM_BEE:
  1941. case WACOM_13HD:
  1942. case WACOM_21UX2:
  1943. case WACOM_22HD:
  1944. case WACOM_24HD:
  1945. case WACOM_27QHD:
  1946. case DTK:
  1947. case CINTIQ_HYBRID:
  1948. sync = wacom_intuos_irq(wacom_wac);
  1949. break;
  1950. case INTUOS4WL:
  1951. sync = wacom_intuos_bt_irq(wacom_wac, len);
  1952. break;
  1953. case WACOM_24HDT:
  1954. case WACOM_27QHDT:
  1955. sync = wacom_24hdt_irq(wacom_wac);
  1956. break;
  1957. case INTUOS5S:
  1958. case INTUOS5:
  1959. case INTUOS5L:
  1960. case INTUOSPS:
  1961. case INTUOSPM:
  1962. case INTUOSPL:
  1963. if (len == WACOM_PKGLEN_BBTOUCH3)
  1964. sync = wacom_bpt3_touch(wacom_wac);
  1965. else if (wacom_wac->data[0] == WACOM_REPORT_USB)
  1966. sync = wacom_status_irq(wacom_wac, len);
  1967. else
  1968. sync = wacom_intuos_irq(wacom_wac);
  1969. break;
  1970. case TABLETPC:
  1971. case TABLETPCE:
  1972. case TABLETPC2FG:
  1973. case MTSCREEN:
  1974. case MTTPC:
  1975. case MTTPC_B:
  1976. sync = wacom_tpc_irq(wacom_wac, len);
  1977. break;
  1978. case BAMBOO_PT:
  1979. case INTUOSHT:
  1980. if (wacom_wac->data[0] == WACOM_REPORT_USB)
  1981. sync = wacom_status_irq(wacom_wac, len);
  1982. else
  1983. sync = wacom_bpt_irq(wacom_wac, len);
  1984. break;
  1985. case BAMBOO_PAD:
  1986. sync = wacom_bamboo_pad_irq(wacom_wac, len);
  1987. break;
  1988. case WIRELESS:
  1989. sync = wacom_wireless_irq(wacom_wac, len);
  1990. break;
  1991. case REMOTE:
  1992. if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
  1993. sync = wacom_remote_status_irq(wacom_wac, len);
  1994. else
  1995. sync = wacom_remote_irq(wacom_wac, len);
  1996. break;
  1997. default:
  1998. sync = false;
  1999. break;
  2000. }
  2001. if (sync) {
  2002. if (wacom_wac->pen_input)
  2003. input_sync(wacom_wac->pen_input);
  2004. if (wacom_wac->touch_input)
  2005. input_sync(wacom_wac->touch_input);
  2006. if (wacom_wac->pad_input)
  2007. input_sync(wacom_wac->pad_input);
  2008. }
  2009. }
  2010. static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  2011. {
  2012. struct input_dev *input_dev = wacom_wac->pen_input;
  2013. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  2014. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2015. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2016. __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  2017. __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  2018. __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  2019. __set_bit(BTN_STYLUS, input_dev->keybit);
  2020. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2021. input_set_abs_params(input_dev, ABS_DISTANCE,
  2022. 0, wacom_wac->features.distance_max, 0, 0);
  2023. input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  2024. input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0);
  2025. input_abs_set_res(input_dev, ABS_TILT_X, 57);
  2026. input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0);
  2027. input_abs_set_res(input_dev, ABS_TILT_Y, 57);
  2028. }
  2029. static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  2030. {
  2031. struct input_dev *input_dev = wacom_wac->pen_input;
  2032. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  2033. wacom_setup_cintiq(wacom_wac);
  2034. __set_bit(BTN_LEFT, input_dev->keybit);
  2035. __set_bit(BTN_RIGHT, input_dev->keybit);
  2036. __set_bit(BTN_MIDDLE, input_dev->keybit);
  2037. __set_bit(BTN_SIDE, input_dev->keybit);
  2038. __set_bit(BTN_EXTRA, input_dev->keybit);
  2039. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  2040. __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  2041. input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  2042. input_abs_set_res(input_dev, ABS_RZ, 287);
  2043. input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  2044. }
  2045. void wacom_setup_device_quirks(struct wacom *wacom)
  2046. {
  2047. struct wacom_features *features = &wacom->wacom_wac.features;
  2048. /* The pen and pad share the same interface on most devices */
  2049. if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
  2050. features->type == DTUS || features->type == WACOM_MO ||
  2051. (features->type >= INTUOS3S && features->type <= WACOM_13HD &&
  2052. features->type != INTUOSHT)) {
  2053. if (features->device_type & WACOM_DEVICETYPE_PEN)
  2054. features->device_type |= WACOM_DEVICETYPE_PAD;
  2055. }
  2056. /* touch device found but size is not defined. use default */
  2057. if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
  2058. features->x_max = 1023;
  2059. features->y_max = 1023;
  2060. }
  2061. /*
  2062. * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
  2063. * touch interface in its HID descriptor. If this is the touch
  2064. * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
  2065. * tablet values.
  2066. */
  2067. if ((features->type >= INTUOS5S && features->type <= INTUOSHT) ||
  2068. (features->type == BAMBOO_PT)) {
  2069. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  2070. if (features->touch_max)
  2071. features->device_type |= WACOM_DEVICETYPE_TOUCH;
  2072. if (features->type == BAMBOO_PT || features->type == INTUOSHT)
  2073. features->device_type |= WACOM_DEVICETYPE_PAD;
  2074. features->x_max = 4096;
  2075. features->y_max = 4096;
  2076. }
  2077. else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  2078. features->device_type |= WACOM_DEVICETYPE_PAD;
  2079. }
  2080. }
  2081. /*
  2082. * Raw Wacom-mode pen and touch events both come from interface
  2083. * 0, whose HID descriptor has an application usage of 0xFF0D
  2084. * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
  2085. * out through the HID_GENERIC device created for interface 1,
  2086. * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
  2087. */
  2088. if (features->type == BAMBOO_PAD)
  2089. features->device_type = WACOM_DEVICETYPE_TOUCH;
  2090. if (features->type == REMOTE)
  2091. features->device_type = WACOM_DEVICETYPE_PAD;
  2092. if (wacom->hdev->bus == BUS_BLUETOOTH)
  2093. features->quirks |= WACOM_QUIRK_BATTERY;
  2094. /* quirk for bamboo touch with 2 low res touches */
  2095. if (features->type == BAMBOO_PT &&
  2096. features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  2097. features->x_max <<= 5;
  2098. features->y_max <<= 5;
  2099. features->x_fuzz <<= 5;
  2100. features->y_fuzz <<= 5;
  2101. features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
  2102. }
  2103. if (features->type == WIRELESS) {
  2104. if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
  2105. features->quirks |= WACOM_QUIRK_BATTERY;
  2106. }
  2107. }
  2108. }
  2109. int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
  2110. struct wacom_wac *wacom_wac)
  2111. {
  2112. struct wacom_features *features = &wacom_wac->features;
  2113. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  2114. if (!(features->device_type & WACOM_DEVICETYPE_PEN))
  2115. return -ENODEV;
  2116. if (features->type == HID_GENERIC)
  2117. /* setup has already been done */
  2118. return 0;
  2119. __set_bit(BTN_TOUCH, input_dev->keybit);
  2120. __set_bit(ABS_MISC, input_dev->absbit);
  2121. input_set_abs_params(input_dev, ABS_X, features->x_min,
  2122. features->x_max, features->x_fuzz, 0);
  2123. input_set_abs_params(input_dev, ABS_Y, features->y_min,
  2124. features->y_max, features->y_fuzz, 0);
  2125. input_set_abs_params(input_dev, ABS_PRESSURE, 0,
  2126. features->pressure_max, features->pressure_fuzz, 0);
  2127. /* penabled devices have fixed resolution for each model */
  2128. input_abs_set_res(input_dev, ABS_X, features->x_resolution);
  2129. input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
  2130. switch (features->type) {
  2131. case GRAPHIRE_BT:
  2132. __clear_bit(ABS_MISC, input_dev->absbit);
  2133. case WACOM_MO:
  2134. case WACOM_G4:
  2135. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  2136. features->distance_max,
  2137. 0, 0);
  2138. /* fall through */
  2139. case GRAPHIRE:
  2140. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  2141. __set_bit(BTN_LEFT, input_dev->keybit);
  2142. __set_bit(BTN_RIGHT, input_dev->keybit);
  2143. __set_bit(BTN_MIDDLE, input_dev->keybit);
  2144. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2145. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2146. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  2147. __set_bit(BTN_STYLUS, input_dev->keybit);
  2148. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2149. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2150. break;
  2151. case WACOM_27QHD:
  2152. case WACOM_24HD:
  2153. case DTK:
  2154. case WACOM_22HD:
  2155. case WACOM_21UX2:
  2156. case WACOM_BEE:
  2157. case CINTIQ:
  2158. case WACOM_13HD:
  2159. case CINTIQ_HYBRID:
  2160. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  2161. input_abs_set_res(input_dev, ABS_Z, 287);
  2162. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  2163. wacom_setup_cintiq(wacom_wac);
  2164. break;
  2165. case INTUOS3:
  2166. case INTUOS3L:
  2167. case INTUOS3S:
  2168. case INTUOS4:
  2169. case INTUOS4WL:
  2170. case INTUOS4L:
  2171. case INTUOS4S:
  2172. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  2173. input_abs_set_res(input_dev, ABS_Z, 287);
  2174. /* fall through */
  2175. case INTUOS:
  2176. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2177. wacom_setup_intuos(wacom_wac);
  2178. break;
  2179. case INTUOS5:
  2180. case INTUOS5L:
  2181. case INTUOSPM:
  2182. case INTUOSPL:
  2183. case INTUOS5S:
  2184. case INTUOSPS:
  2185. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2186. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  2187. features->distance_max,
  2188. 0, 0);
  2189. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  2190. input_abs_set_res(input_dev, ABS_Z, 287);
  2191. wacom_setup_intuos(wacom_wac);
  2192. break;
  2193. case WACOM_24HDT:
  2194. case WACOM_27QHDT:
  2195. case MTSCREEN:
  2196. case MTTPC:
  2197. case MTTPC_B:
  2198. case TABLETPC2FG:
  2199. case TABLETPC:
  2200. case TABLETPCE:
  2201. __clear_bit(ABS_MISC, input_dev->absbit);
  2202. /* fall through */
  2203. case DTUS:
  2204. case DTUSX:
  2205. case PL:
  2206. case DTU:
  2207. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2208. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2209. __set_bit(BTN_STYLUS, input_dev->keybit);
  2210. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2211. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  2212. break;
  2213. case PTU:
  2214. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2215. /* fall through */
  2216. case PENPARTNER:
  2217. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2218. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2219. __set_bit(BTN_STYLUS, input_dev->keybit);
  2220. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2221. break;
  2222. case INTUOSHT:
  2223. case BAMBOO_PT:
  2224. __clear_bit(ABS_MISC, input_dev->absbit);
  2225. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2226. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2227. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2228. __set_bit(BTN_STYLUS, input_dev->keybit);
  2229. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2230. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  2231. features->distance_max,
  2232. 0, 0);
  2233. break;
  2234. case BAMBOO_PAD:
  2235. __clear_bit(ABS_MISC, input_dev->absbit);
  2236. break;
  2237. }
  2238. return 0;
  2239. }
  2240. int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
  2241. struct wacom_wac *wacom_wac)
  2242. {
  2243. struct wacom_features *features = &wacom_wac->features;
  2244. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  2245. if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
  2246. return -ENODEV;
  2247. if (features->type == HID_GENERIC)
  2248. /* setup has already been done */
  2249. return 0;
  2250. __set_bit(BTN_TOUCH, input_dev->keybit);
  2251. if (features->touch_max == 1) {
  2252. input_set_abs_params(input_dev, ABS_X, 0,
  2253. features->x_max, features->x_fuzz, 0);
  2254. input_set_abs_params(input_dev, ABS_Y, 0,
  2255. features->y_max, features->y_fuzz, 0);
  2256. input_abs_set_res(input_dev, ABS_X,
  2257. features->x_resolution);
  2258. input_abs_set_res(input_dev, ABS_Y,
  2259. features->y_resolution);
  2260. }
  2261. else if (features->touch_max > 1) {
  2262. input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
  2263. features->x_max, features->x_fuzz, 0);
  2264. input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
  2265. features->y_max, features->y_fuzz, 0);
  2266. input_abs_set_res(input_dev, ABS_MT_POSITION_X,
  2267. features->x_resolution);
  2268. input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
  2269. features->y_resolution);
  2270. }
  2271. switch (features->type) {
  2272. case INTUOS5:
  2273. case INTUOS5L:
  2274. case INTUOSPM:
  2275. case INTUOSPL:
  2276. case INTUOS5S:
  2277. case INTUOSPS:
  2278. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  2279. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  2280. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
  2281. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  2282. break;
  2283. case WACOM_24HDT:
  2284. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  2285. input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
  2286. input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
  2287. input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  2288. /* fall through */
  2289. case WACOM_27QHDT:
  2290. case MTSCREEN:
  2291. case MTTPC:
  2292. case MTTPC_B:
  2293. case TABLETPC2FG:
  2294. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
  2295. /*fall through */
  2296. case TABLETPC:
  2297. case TABLETPCE:
  2298. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  2299. break;
  2300. case INTUOSHT:
  2301. input_dev->evbit[0] |= BIT_MASK(EV_SW);
  2302. __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
  2303. /* fall through */
  2304. case BAMBOO_PT:
  2305. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  2306. input_set_abs_params(input_dev,
  2307. ABS_MT_TOUCH_MAJOR,
  2308. 0, features->x_max, 0, 0);
  2309. input_set_abs_params(input_dev,
  2310. ABS_MT_TOUCH_MINOR,
  2311. 0, features->y_max, 0, 0);
  2312. }
  2313. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  2314. break;
  2315. case BAMBOO_PAD:
  2316. input_mt_init_slots(input_dev, features->touch_max,
  2317. INPUT_MT_POINTER);
  2318. __set_bit(BTN_LEFT, input_dev->keybit);
  2319. __set_bit(BTN_RIGHT, input_dev->keybit);
  2320. break;
  2321. }
  2322. return 0;
  2323. }
  2324. static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
  2325. int button_count)
  2326. {
  2327. int i;
  2328. for (i = 0; i < button_count && i < 10; i++)
  2329. __set_bit(BTN_0 + i, input_dev->keybit);
  2330. for (i = 10; i < button_count && i < 16; i++)
  2331. __set_bit(BTN_A + (i-10), input_dev->keybit);
  2332. for (i = 16; i < button_count && i < 18; i++)
  2333. __set_bit(BTN_BASE + (i-16), input_dev->keybit);
  2334. }
  2335. int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
  2336. struct wacom_wac *wacom_wac)
  2337. {
  2338. struct wacom_features *features = &wacom_wac->features;
  2339. if (!(features->device_type & WACOM_DEVICETYPE_PAD))
  2340. return -ENODEV;
  2341. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  2342. /* kept for making legacy xf86-input-wacom working with the wheels */
  2343. __set_bit(ABS_MISC, input_dev->absbit);
  2344. /* kept for making legacy xf86-input-wacom accepting the pad */
  2345. input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
  2346. input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
  2347. /* kept for making udev and libwacom accepting the pad */
  2348. __set_bit(BTN_STYLUS, input_dev->keybit);
  2349. wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
  2350. switch (features->type) {
  2351. case CINTIQ_HYBRID:
  2352. case DTK:
  2353. case DTUS:
  2354. case GRAPHIRE_BT:
  2355. break;
  2356. case WACOM_MO:
  2357. __set_bit(BTN_BACK, input_dev->keybit);
  2358. __set_bit(BTN_LEFT, input_dev->keybit);
  2359. __set_bit(BTN_FORWARD, input_dev->keybit);
  2360. __set_bit(BTN_RIGHT, input_dev->keybit);
  2361. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2362. break;
  2363. case WACOM_G4:
  2364. __set_bit(BTN_BACK, input_dev->keybit);
  2365. __set_bit(BTN_FORWARD, input_dev->keybit);
  2366. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  2367. break;
  2368. case WACOM_24HD:
  2369. __set_bit(KEY_PROG1, input_dev->keybit);
  2370. __set_bit(KEY_PROG2, input_dev->keybit);
  2371. __set_bit(KEY_PROG3, input_dev->keybit);
  2372. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2373. input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
  2374. break;
  2375. case WACOM_27QHD:
  2376. __set_bit(KEY_PROG1, input_dev->keybit);
  2377. __set_bit(KEY_PROG2, input_dev->keybit);
  2378. __set_bit(KEY_PROG3, input_dev->keybit);
  2379. input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
  2380. input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
  2381. input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
  2382. input_abs_set_res(input_dev, ABS_Y, 1024);
  2383. input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
  2384. input_abs_set_res(input_dev, ABS_Z, 1024);
  2385. __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
  2386. break;
  2387. case WACOM_22HD:
  2388. __set_bit(KEY_PROG1, input_dev->keybit);
  2389. __set_bit(KEY_PROG2, input_dev->keybit);
  2390. __set_bit(KEY_PROG3, input_dev->keybit);
  2391. /* fall through */
  2392. case WACOM_21UX2:
  2393. case WACOM_BEE:
  2394. case CINTIQ:
  2395. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  2396. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  2397. break;
  2398. case WACOM_13HD:
  2399. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2400. break;
  2401. case INTUOS3:
  2402. case INTUOS3L:
  2403. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  2404. /* fall through */
  2405. case INTUOS3S:
  2406. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  2407. break;
  2408. case INTUOS5:
  2409. case INTUOS5L:
  2410. case INTUOSPM:
  2411. case INTUOSPL:
  2412. case INTUOS5S:
  2413. case INTUOSPS:
  2414. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2415. break;
  2416. case INTUOS4WL:
  2417. /*
  2418. * For Bluetooth devices, the udev rule does not work correctly
  2419. * for pads unless we add a stylus capability, which forces
  2420. * ID_INPUT_TABLET to be set.
  2421. */
  2422. __set_bit(BTN_STYLUS, input_dev->keybit);
  2423. /* fall through */
  2424. case INTUOS4:
  2425. case INTUOS4L:
  2426. case INTUOS4S:
  2427. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2428. break;
  2429. case INTUOSHT:
  2430. case BAMBOO_PT:
  2431. __clear_bit(ABS_MISC, input_dev->absbit);
  2432. __set_bit(BTN_LEFT, input_dev->keybit);
  2433. __set_bit(BTN_FORWARD, input_dev->keybit);
  2434. __set_bit(BTN_BACK, input_dev->keybit);
  2435. __set_bit(BTN_RIGHT, input_dev->keybit);
  2436. break;
  2437. case REMOTE:
  2438. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  2439. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  2440. break;
  2441. default:
  2442. /* no pad supported */
  2443. return -ENODEV;
  2444. }
  2445. return 0;
  2446. }
  2447. static const struct wacom_features wacom_features_0x00 =
  2448. { "Wacom Penpartner", 5040, 3780, 255, 0,
  2449. PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  2450. static const struct wacom_features wacom_features_0x10 =
  2451. { "Wacom Graphire", 10206, 7422, 511, 63,
  2452. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2453. static const struct wacom_features wacom_features_0x81 =
  2454. { "Wacom Graphire BT", 16704, 12064, 511, 32,
  2455. GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
  2456. static const struct wacom_features wacom_features_0x11 =
  2457. { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
  2458. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2459. static const struct wacom_features wacom_features_0x12 =
  2460. { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
  2461. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2462. static const struct wacom_features wacom_features_0x13 =
  2463. { "Wacom Graphire3", 10208, 7424, 511, 63,
  2464. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2465. static const struct wacom_features wacom_features_0x14 =
  2466. { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
  2467. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2468. static const struct wacom_features wacom_features_0x15 =
  2469. { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
  2470. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2471. static const struct wacom_features wacom_features_0x16 =
  2472. { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
  2473. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2474. static const struct wacom_features wacom_features_0x17 =
  2475. { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
  2476. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2477. static const struct wacom_features wacom_features_0x18 =
  2478. { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
  2479. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2480. static const struct wacom_features wacom_features_0x19 =
  2481. { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
  2482. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  2483. static const struct wacom_features wacom_features_0x60 =
  2484. { "Wacom Volito", 5104, 3712, 511, 63,
  2485. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2486. static const struct wacom_features wacom_features_0x61 =
  2487. { "Wacom PenStation2", 3250, 2320, 255, 63,
  2488. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2489. static const struct wacom_features wacom_features_0x62 =
  2490. { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
  2491. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2492. static const struct wacom_features wacom_features_0x63 =
  2493. { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
  2494. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2495. static const struct wacom_features wacom_features_0x64 =
  2496. { "Wacom PenPartner2", 3250, 2320, 511, 63,
  2497. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  2498. static const struct wacom_features wacom_features_0x65 =
  2499. { "Wacom Bamboo", 14760, 9225, 511, 63,
  2500. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2501. static const struct wacom_features wacom_features_0x69 =
  2502. { "Wacom Bamboo1", 5104, 3712, 511, 63,
  2503. GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  2504. static const struct wacom_features wacom_features_0x6A =
  2505. { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
  2506. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2507. static const struct wacom_features wacom_features_0x6B =
  2508. { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
  2509. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2510. static const struct wacom_features wacom_features_0x20 =
  2511. { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
  2512. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2513. static const struct wacom_features wacom_features_0x21 =
  2514. { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
  2515. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2516. static const struct wacom_features wacom_features_0x22 =
  2517. { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
  2518. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2519. static const struct wacom_features wacom_features_0x23 =
  2520. { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
  2521. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2522. static const struct wacom_features wacom_features_0x24 =
  2523. { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
  2524. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2525. static const struct wacom_features wacom_features_0x30 =
  2526. { "Wacom PL400", 5408, 4056, 255, 0,
  2527. PL, WACOM_PL_RES, WACOM_PL_RES };
  2528. static const struct wacom_features wacom_features_0x31 =
  2529. { "Wacom PL500", 6144, 4608, 255, 0,
  2530. PL, WACOM_PL_RES, WACOM_PL_RES };
  2531. static const struct wacom_features wacom_features_0x32 =
  2532. { "Wacom PL600", 6126, 4604, 255, 0,
  2533. PL, WACOM_PL_RES, WACOM_PL_RES };
  2534. static const struct wacom_features wacom_features_0x33 =
  2535. { "Wacom PL600SX", 6260, 5016, 255, 0,
  2536. PL, WACOM_PL_RES, WACOM_PL_RES };
  2537. static const struct wacom_features wacom_features_0x34 =
  2538. { "Wacom PL550", 6144, 4608, 511, 0,
  2539. PL, WACOM_PL_RES, WACOM_PL_RES };
  2540. static const struct wacom_features wacom_features_0x35 =
  2541. { "Wacom PL800", 7220, 5780, 511, 0,
  2542. PL, WACOM_PL_RES, WACOM_PL_RES };
  2543. static const struct wacom_features wacom_features_0x37 =
  2544. { "Wacom PL700", 6758, 5406, 511, 0,
  2545. PL, WACOM_PL_RES, WACOM_PL_RES };
  2546. static const struct wacom_features wacom_features_0x38 =
  2547. { "Wacom PL510", 6282, 4762, 511, 0,
  2548. PL, WACOM_PL_RES, WACOM_PL_RES };
  2549. static const struct wacom_features wacom_features_0x39 =
  2550. { "Wacom DTU710", 34080, 27660, 511, 0,
  2551. PL, WACOM_PL_RES, WACOM_PL_RES };
  2552. static const struct wacom_features wacom_features_0xC4 =
  2553. { "Wacom DTF521", 6282, 4762, 511, 0,
  2554. PL, WACOM_PL_RES, WACOM_PL_RES };
  2555. static const struct wacom_features wacom_features_0xC0 =
  2556. { "Wacom DTF720", 6858, 5506, 511, 0,
  2557. PL, WACOM_PL_RES, WACOM_PL_RES };
  2558. static const struct wacom_features wacom_features_0xC2 =
  2559. { "Wacom DTF720a", 6858, 5506, 511, 0,
  2560. PL, WACOM_PL_RES, WACOM_PL_RES };
  2561. static const struct wacom_features wacom_features_0x03 =
  2562. { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
  2563. PTU, WACOM_PL_RES, WACOM_PL_RES };
  2564. static const struct wacom_features wacom_features_0x41 =
  2565. { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
  2566. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2567. static const struct wacom_features wacom_features_0x42 =
  2568. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  2569. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2570. static const struct wacom_features wacom_features_0x43 =
  2571. { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
  2572. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2573. static const struct wacom_features wacom_features_0x44 =
  2574. { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
  2575. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2576. static const struct wacom_features wacom_features_0x45 =
  2577. { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
  2578. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2579. static const struct wacom_features wacom_features_0xB0 =
  2580. { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
  2581. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
  2582. static const struct wacom_features wacom_features_0xB1 =
  2583. { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
  2584. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2585. static const struct wacom_features wacom_features_0xB2 =
  2586. { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
  2587. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2588. static const struct wacom_features wacom_features_0xB3 =
  2589. { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
  2590. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2591. static const struct wacom_features wacom_features_0xB4 =
  2592. { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
  2593. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2594. static const struct wacom_features wacom_features_0xB5 =
  2595. { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
  2596. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2597. static const struct wacom_features wacom_features_0xB7 =
  2598. { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
  2599. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
  2600. static const struct wacom_features wacom_features_0xB8 =
  2601. { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
  2602. INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
  2603. static const struct wacom_features wacom_features_0xB9 =
  2604. { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
  2605. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2606. static const struct wacom_features wacom_features_0xBA =
  2607. { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
  2608. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2609. static const struct wacom_features wacom_features_0xBB =
  2610. { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
  2611. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2612. static const struct wacom_features wacom_features_0xBC =
  2613. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  2614. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2615. static const struct wacom_features wacom_features_0xBD =
  2616. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  2617. INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2618. static const struct wacom_features wacom_features_0x26 =
  2619. { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
  2620. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
  2621. static const struct wacom_features wacom_features_0x27 =
  2622. { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
  2623. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
  2624. static const struct wacom_features wacom_features_0x28 =
  2625. { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
  2626. INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
  2627. static const struct wacom_features wacom_features_0x29 =
  2628. { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
  2629. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
  2630. static const struct wacom_features wacom_features_0x2A =
  2631. { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
  2632. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  2633. static const struct wacom_features wacom_features_0x314 =
  2634. { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
  2635. INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
  2636. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2637. static const struct wacom_features wacom_features_0x315 =
  2638. { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
  2639. INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
  2640. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2641. static const struct wacom_features wacom_features_0x317 =
  2642. { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
  2643. INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
  2644. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2645. static const struct wacom_features wacom_features_0xF4 =
  2646. { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
  2647. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
  2648. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2649. static const struct wacom_features wacom_features_0xF8 =
  2650. { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
  2651. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
  2652. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2653. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
  2654. static const struct wacom_features wacom_features_0xF6 =
  2655. { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
  2656. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
  2657. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2658. static const struct wacom_features wacom_features_0x32A =
  2659. { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 63,
  2660. WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
  2661. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2662. static const struct wacom_features wacom_features_0x32B =
  2663. { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63,
  2664. WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
  2665. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2666. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
  2667. static const struct wacom_features wacom_features_0x32C =
  2668. { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
  2669. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
  2670. static const struct wacom_features wacom_features_0x3F =
  2671. { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
  2672. CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  2673. static const struct wacom_features wacom_features_0xC5 =
  2674. { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
  2675. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
  2676. static const struct wacom_features wacom_features_0xC6 =
  2677. { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
  2678. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
  2679. static const struct wacom_features wacom_features_0x304 =
  2680. { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
  2681. WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  2682. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2683. static const struct wacom_features wacom_features_0x333 =
  2684. { "Wacom Cintiq 13HD touch", 59152, 33448, 2047, 63,
  2685. WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  2686. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2687. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
  2688. static const struct wacom_features wacom_features_0x335 =
  2689. { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
  2690. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
  2691. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2692. static const struct wacom_features wacom_features_0xC7 =
  2693. { "Wacom DTU1931", 37832, 30305, 511, 0,
  2694. PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2695. static const struct wacom_features wacom_features_0xCE =
  2696. { "Wacom DTU2231", 47864, 27011, 511, 0,
  2697. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  2698. .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
  2699. static const struct wacom_features wacom_features_0xF0 =
  2700. { "Wacom DTU1631", 34623, 19553, 511, 0,
  2701. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2702. static const struct wacom_features wacom_features_0xFB =
  2703. { "Wacom DTU1031", 21896, 13760, 511, 0,
  2704. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
  2705. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  2706. static const struct wacom_features wacom_features_0x32F =
  2707. { "Wacom DTU1031X", 22472, 12728, 511, 0,
  2708. DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
  2709. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  2710. static const struct wacom_features wacom_features_0x336 =
  2711. { "Wacom DTU1141", 23472, 13203, 1023, 0,
  2712. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
  2713. static const struct wacom_features wacom_features_0x57 =
  2714. { "Wacom DTK2241", 95640, 54060, 2047, 63,
  2715. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
  2716. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2717. static const struct wacom_features wacom_features_0x59 = /* Pen */
  2718. { "Wacom DTH2242", 95640, 54060, 2047, 63,
  2719. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
  2720. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2721. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
  2722. static const struct wacom_features wacom_features_0x5D = /* Touch */
  2723. { "Wacom DTH2242", .type = WACOM_24HDT,
  2724. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
  2725. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2726. static const struct wacom_features wacom_features_0xCC =
  2727. { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
  2728. WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  2729. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2730. static const struct wacom_features wacom_features_0xFA =
  2731. { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
  2732. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  2733. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  2734. static const struct wacom_features wacom_features_0x5B =
  2735. { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
  2736. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  2737. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2738. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
  2739. static const struct wacom_features wacom_features_0x5E =
  2740. { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
  2741. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
  2742. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2743. static const struct wacom_features wacom_features_0x90 =
  2744. { "Wacom ISDv4 90", 26202, 16325, 255, 0,
  2745. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2746. static const struct wacom_features wacom_features_0x93 =
  2747. { "Wacom ISDv4 93", 26202, 16325, 255, 0,
  2748. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2749. static const struct wacom_features wacom_features_0x97 =
  2750. { "Wacom ISDv4 97", 26202, 16325, 511, 0,
  2751. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2752. static const struct wacom_features wacom_features_0x9A =
  2753. { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
  2754. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2755. static const struct wacom_features wacom_features_0x9F =
  2756. { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
  2757. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2758. static const struct wacom_features wacom_features_0xE2 =
  2759. { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
  2760. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2761. static const struct wacom_features wacom_features_0xE3 =
  2762. { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
  2763. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2764. static const struct wacom_features wacom_features_0xE5 =
  2765. { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
  2766. MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2767. static const struct wacom_features wacom_features_0xE6 =
  2768. { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
  2769. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2770. static const struct wacom_features wacom_features_0xEC =
  2771. { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
  2772. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2773. static const struct wacom_features wacom_features_0xED =
  2774. { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
  2775. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2776. static const struct wacom_features wacom_features_0xEF =
  2777. { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
  2778. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2779. static const struct wacom_features wacom_features_0x100 =
  2780. { "Wacom ISDv4 100", 26202, 16325, 255, 0,
  2781. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2782. static const struct wacom_features wacom_features_0x101 =
  2783. { "Wacom ISDv4 101", 26202, 16325, 255, 0,
  2784. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2785. static const struct wacom_features wacom_features_0x10D =
  2786. { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
  2787. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2788. static const struct wacom_features wacom_features_0x10E =
  2789. { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
  2790. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2791. static const struct wacom_features wacom_features_0x10F =
  2792. { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
  2793. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2794. static const struct wacom_features wacom_features_0x116 =
  2795. { "Wacom ISDv4 116", 26202, 16325, 255, 0,
  2796. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2797. static const struct wacom_features wacom_features_0x12C =
  2798. { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
  2799. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2800. static const struct wacom_features wacom_features_0x4001 =
  2801. { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
  2802. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2803. static const struct wacom_features wacom_features_0x4004 =
  2804. { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
  2805. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2806. static const struct wacom_features wacom_features_0x5000 =
  2807. { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
  2808. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2809. static const struct wacom_features wacom_features_0x5002 =
  2810. { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
  2811. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2812. static const struct wacom_features wacom_features_0x47 =
  2813. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  2814. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2815. static const struct wacom_features wacom_features_0x84 =
  2816. { "Wacom Wireless Receiver", 0, 0, 0, 0,
  2817. WIRELESS, 0, 0, .touch_max = 16 };
  2818. static const struct wacom_features wacom_features_0xD0 =
  2819. { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
  2820. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2821. static const struct wacom_features wacom_features_0xD1 =
  2822. { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
  2823. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2824. static const struct wacom_features wacom_features_0xD2 =
  2825. { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
  2826. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2827. static const struct wacom_features wacom_features_0xD3 =
  2828. { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
  2829. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2830. static const struct wacom_features wacom_features_0xD4 =
  2831. { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
  2832. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2833. static const struct wacom_features wacom_features_0xD5 =
  2834. { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
  2835. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2836. static const struct wacom_features wacom_features_0xD6 =
  2837. { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
  2838. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2839. static const struct wacom_features wacom_features_0xD7 =
  2840. { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
  2841. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2842. static const struct wacom_features wacom_features_0xD8 =
  2843. { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
  2844. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2845. static const struct wacom_features wacom_features_0xDA =
  2846. { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
  2847. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2848. static const struct wacom_features wacom_features_0xDB =
  2849. { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
  2850. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  2851. static const struct wacom_features wacom_features_0xDD =
  2852. { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
  2853. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2854. static const struct wacom_features wacom_features_0xDE =
  2855. { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
  2856. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  2857. static const struct wacom_features wacom_features_0xDF =
  2858. { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
  2859. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  2860. static const struct wacom_features wacom_features_0x300 =
  2861. { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
  2862. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2863. static const struct wacom_features wacom_features_0x301 =
  2864. { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
  2865. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2866. static const struct wacom_features wacom_features_0x302 =
  2867. { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
  2868. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  2869. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2870. static const struct wacom_features wacom_features_0x303 =
  2871. { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
  2872. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  2873. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2874. static const struct wacom_features wacom_features_0x30E =
  2875. { "Wacom Intuos S", 15200, 9500, 1023, 31,
  2876. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  2877. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2878. static const struct wacom_features wacom_features_0x6004 =
  2879. { "ISD-V4", 12800, 8000, 255, 0,
  2880. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  2881. static const struct wacom_features wacom_features_0x307 =
  2882. { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
  2883. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  2884. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2885. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
  2886. static const struct wacom_features wacom_features_0x309 =
  2887. { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
  2888. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
  2889. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2890. static const struct wacom_features wacom_features_0x30A =
  2891. { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
  2892. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  2893. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  2894. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
  2895. static const struct wacom_features wacom_features_0x30C =
  2896. { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
  2897. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
  2898. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2899. static const struct wacom_features wacom_features_0x318 =
  2900. { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
  2901. .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
  2902. static const struct wacom_features wacom_features_0x319 =
  2903. { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
  2904. .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
  2905. static const struct wacom_features wacom_features_0x323 =
  2906. { "Wacom Intuos P M", 21600, 13500, 1023, 31,
  2907. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  2908. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  2909. static const struct wacom_features wacom_features_0x331 =
  2910. { "Wacom Express Key Remote", 0, 0, 0, 0,
  2911. REMOTE, 0, 0, 18, .check_for_hid_type = true,
  2912. .hid_type = HID_TYPE_USBNONE };
  2913. static const struct wacom_features wacom_features_HID_ANY_ID =
  2914. { "Wacom HID", .type = HID_GENERIC };
  2915. #define USB_DEVICE_WACOM(prod) \
  2916. HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  2917. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2918. #define BT_DEVICE_WACOM(prod) \
  2919. HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  2920. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2921. #define I2C_DEVICE_WACOM(prod) \
  2922. HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  2923. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2924. #define USB_DEVICE_LENOVO(prod) \
  2925. HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
  2926. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  2927. const struct hid_device_id wacom_ids[] = {
  2928. { USB_DEVICE_WACOM(0x00) },
  2929. { USB_DEVICE_WACOM(0x03) },
  2930. { USB_DEVICE_WACOM(0x10) },
  2931. { USB_DEVICE_WACOM(0x11) },
  2932. { USB_DEVICE_WACOM(0x12) },
  2933. { USB_DEVICE_WACOM(0x13) },
  2934. { USB_DEVICE_WACOM(0x14) },
  2935. { USB_DEVICE_WACOM(0x15) },
  2936. { USB_DEVICE_WACOM(0x16) },
  2937. { USB_DEVICE_WACOM(0x17) },
  2938. { USB_DEVICE_WACOM(0x18) },
  2939. { USB_DEVICE_WACOM(0x19) },
  2940. { USB_DEVICE_WACOM(0x20) },
  2941. { USB_DEVICE_WACOM(0x21) },
  2942. { USB_DEVICE_WACOM(0x22) },
  2943. { USB_DEVICE_WACOM(0x23) },
  2944. { USB_DEVICE_WACOM(0x24) },
  2945. { USB_DEVICE_WACOM(0x26) },
  2946. { USB_DEVICE_WACOM(0x27) },
  2947. { USB_DEVICE_WACOM(0x28) },
  2948. { USB_DEVICE_WACOM(0x29) },
  2949. { USB_DEVICE_WACOM(0x2A) },
  2950. { USB_DEVICE_WACOM(0x30) },
  2951. { USB_DEVICE_WACOM(0x31) },
  2952. { USB_DEVICE_WACOM(0x32) },
  2953. { USB_DEVICE_WACOM(0x33) },
  2954. { USB_DEVICE_WACOM(0x34) },
  2955. { USB_DEVICE_WACOM(0x35) },
  2956. { USB_DEVICE_WACOM(0x37) },
  2957. { USB_DEVICE_WACOM(0x38) },
  2958. { USB_DEVICE_WACOM(0x39) },
  2959. { USB_DEVICE_WACOM(0x3F) },
  2960. { USB_DEVICE_WACOM(0x41) },
  2961. { USB_DEVICE_WACOM(0x42) },
  2962. { USB_DEVICE_WACOM(0x43) },
  2963. { USB_DEVICE_WACOM(0x44) },
  2964. { USB_DEVICE_WACOM(0x45) },
  2965. { USB_DEVICE_WACOM(0x47) },
  2966. { USB_DEVICE_WACOM(0x57) },
  2967. { USB_DEVICE_WACOM(0x59) },
  2968. { USB_DEVICE_WACOM(0x5B) },
  2969. { USB_DEVICE_WACOM(0x5D) },
  2970. { USB_DEVICE_WACOM(0x5E) },
  2971. { USB_DEVICE_WACOM(0x60) },
  2972. { USB_DEVICE_WACOM(0x61) },
  2973. { USB_DEVICE_WACOM(0x62) },
  2974. { USB_DEVICE_WACOM(0x63) },
  2975. { USB_DEVICE_WACOM(0x64) },
  2976. { USB_DEVICE_WACOM(0x65) },
  2977. { USB_DEVICE_WACOM(0x69) },
  2978. { USB_DEVICE_WACOM(0x6A) },
  2979. { USB_DEVICE_WACOM(0x6B) },
  2980. { BT_DEVICE_WACOM(0x81) },
  2981. { USB_DEVICE_WACOM(0x84) },
  2982. { USB_DEVICE_WACOM(0x90) },
  2983. { USB_DEVICE_WACOM(0x93) },
  2984. { USB_DEVICE_WACOM(0x97) },
  2985. { USB_DEVICE_WACOM(0x9A) },
  2986. { USB_DEVICE_WACOM(0x9F) },
  2987. { USB_DEVICE_WACOM(0xB0) },
  2988. { USB_DEVICE_WACOM(0xB1) },
  2989. { USB_DEVICE_WACOM(0xB2) },
  2990. { USB_DEVICE_WACOM(0xB3) },
  2991. { USB_DEVICE_WACOM(0xB4) },
  2992. { USB_DEVICE_WACOM(0xB5) },
  2993. { USB_DEVICE_WACOM(0xB7) },
  2994. { USB_DEVICE_WACOM(0xB8) },
  2995. { USB_DEVICE_WACOM(0xB9) },
  2996. { USB_DEVICE_WACOM(0xBA) },
  2997. { USB_DEVICE_WACOM(0xBB) },
  2998. { USB_DEVICE_WACOM(0xBC) },
  2999. { BT_DEVICE_WACOM(0xBD) },
  3000. { USB_DEVICE_WACOM(0xC0) },
  3001. { USB_DEVICE_WACOM(0xC2) },
  3002. { USB_DEVICE_WACOM(0xC4) },
  3003. { USB_DEVICE_WACOM(0xC5) },
  3004. { USB_DEVICE_WACOM(0xC6) },
  3005. { USB_DEVICE_WACOM(0xC7) },
  3006. { USB_DEVICE_WACOM(0xCC) },
  3007. { USB_DEVICE_WACOM(0xCE) },
  3008. { USB_DEVICE_WACOM(0xD0) },
  3009. { USB_DEVICE_WACOM(0xD1) },
  3010. { USB_DEVICE_WACOM(0xD2) },
  3011. { USB_DEVICE_WACOM(0xD3) },
  3012. { USB_DEVICE_WACOM(0xD4) },
  3013. { USB_DEVICE_WACOM(0xD5) },
  3014. { USB_DEVICE_WACOM(0xD6) },
  3015. { USB_DEVICE_WACOM(0xD7) },
  3016. { USB_DEVICE_WACOM(0xD8) },
  3017. { USB_DEVICE_WACOM(0xDA) },
  3018. { USB_DEVICE_WACOM(0xDB) },
  3019. { USB_DEVICE_WACOM(0xDD) },
  3020. { USB_DEVICE_WACOM(0xDE) },
  3021. { USB_DEVICE_WACOM(0xDF) },
  3022. { USB_DEVICE_WACOM(0xE2) },
  3023. { USB_DEVICE_WACOM(0xE3) },
  3024. { USB_DEVICE_WACOM(0xE5) },
  3025. { USB_DEVICE_WACOM(0xE6) },
  3026. { USB_DEVICE_WACOM(0xEC) },
  3027. { USB_DEVICE_WACOM(0xED) },
  3028. { USB_DEVICE_WACOM(0xEF) },
  3029. { USB_DEVICE_WACOM(0xF0) },
  3030. { USB_DEVICE_WACOM(0xF4) },
  3031. { USB_DEVICE_WACOM(0xF6) },
  3032. { USB_DEVICE_WACOM(0xF8) },
  3033. { USB_DEVICE_WACOM(0xFA) },
  3034. { USB_DEVICE_WACOM(0xFB) },
  3035. { USB_DEVICE_WACOM(0x100) },
  3036. { USB_DEVICE_WACOM(0x101) },
  3037. { USB_DEVICE_WACOM(0x10D) },
  3038. { USB_DEVICE_WACOM(0x10E) },
  3039. { USB_DEVICE_WACOM(0x10F) },
  3040. { USB_DEVICE_WACOM(0x116) },
  3041. { USB_DEVICE_WACOM(0x12C) },
  3042. { USB_DEVICE_WACOM(0x300) },
  3043. { USB_DEVICE_WACOM(0x301) },
  3044. { USB_DEVICE_WACOM(0x302) },
  3045. { USB_DEVICE_WACOM(0x303) },
  3046. { USB_DEVICE_WACOM(0x304) },
  3047. { USB_DEVICE_WACOM(0x307) },
  3048. { USB_DEVICE_WACOM(0x309) },
  3049. { USB_DEVICE_WACOM(0x30A) },
  3050. { USB_DEVICE_WACOM(0x30C) },
  3051. { USB_DEVICE_WACOM(0x30E) },
  3052. { USB_DEVICE_WACOM(0x314) },
  3053. { USB_DEVICE_WACOM(0x315) },
  3054. { USB_DEVICE_WACOM(0x317) },
  3055. { USB_DEVICE_WACOM(0x318) },
  3056. { USB_DEVICE_WACOM(0x319) },
  3057. { USB_DEVICE_WACOM(0x323) },
  3058. { USB_DEVICE_WACOM(0x32A) },
  3059. { USB_DEVICE_WACOM(0x32B) },
  3060. { USB_DEVICE_WACOM(0x32C) },
  3061. { USB_DEVICE_WACOM(0x32F) },
  3062. { USB_DEVICE_WACOM(0x331) },
  3063. { USB_DEVICE_WACOM(0x333) },
  3064. { USB_DEVICE_WACOM(0x335) },
  3065. { USB_DEVICE_WACOM(0x336) },
  3066. { USB_DEVICE_WACOM(0x4001) },
  3067. { USB_DEVICE_WACOM(0x4004) },
  3068. { USB_DEVICE_WACOM(0x5000) },
  3069. { USB_DEVICE_WACOM(0x5002) },
  3070. { USB_DEVICE_LENOVO(0x6004) },
  3071. { USB_DEVICE_WACOM(HID_ANY_ID) },
  3072. { I2C_DEVICE_WACOM(HID_ANY_ID) },
  3073. { }
  3074. };
  3075. MODULE_DEVICE_TABLE(hid, wacom_ids);