wacom_wac.c 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818
  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. static bool touch_arbitration = 1;
  32. module_param(touch_arbitration, bool, 0644);
  33. MODULE_PARM_DESC(touch_arbitration, " on (Y) off (N)");
  34. static void wacom_report_numbered_buttons(struct input_dev *input_dev,
  35. int button_count, int mask);
  36. static int wacom_numbered_button_to_key(int n);
  37. static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
  38. int group);
  39. /*
  40. * Percent of battery capacity for Graphire.
  41. * 8th value means AC online and show 100% capacity.
  42. */
  43. static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
  44. /*
  45. * Percent of battery capacity for Intuos4 WL, AC has a separate bit.
  46. */
  47. static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
  48. static void __wacom_notify_battery(struct wacom_battery *battery,
  49. int bat_status, int bat_capacity,
  50. bool bat_charging, bool bat_connected,
  51. bool ps_connected)
  52. {
  53. bool changed = battery->bat_status != bat_status ||
  54. battery->battery_capacity != bat_capacity ||
  55. battery->bat_charging != bat_charging ||
  56. battery->bat_connected != bat_connected ||
  57. battery->ps_connected != ps_connected;
  58. if (changed) {
  59. battery->bat_status = bat_status;
  60. battery->battery_capacity = bat_capacity;
  61. battery->bat_charging = bat_charging;
  62. battery->bat_connected = bat_connected;
  63. battery->ps_connected = ps_connected;
  64. if (battery->battery)
  65. power_supply_changed(battery->battery);
  66. }
  67. }
  68. static void wacom_notify_battery(struct wacom_wac *wacom_wac,
  69. int bat_status, int bat_capacity, bool bat_charging,
  70. bool bat_connected, bool ps_connected)
  71. {
  72. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  73. __wacom_notify_battery(&wacom->battery, bat_status, bat_capacity,
  74. bat_charging, bat_connected, ps_connected);
  75. }
  76. static int wacom_penpartner_irq(struct wacom_wac *wacom)
  77. {
  78. unsigned char *data = wacom->data;
  79. struct input_dev *input = wacom->pen_input;
  80. switch (data[0]) {
  81. case 1:
  82. if (data[5] & 0x80) {
  83. wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  84. wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
  85. input_report_key(input, wacom->tool[0], 1);
  86. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  87. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  88. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  89. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  90. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -127));
  91. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  92. } else {
  93. input_report_key(input, wacom->tool[0], 0);
  94. input_report_abs(input, ABS_MISC, 0); /* report tool id */
  95. input_report_abs(input, ABS_PRESSURE, -1);
  96. input_report_key(input, BTN_TOUCH, 0);
  97. }
  98. break;
  99. case 2:
  100. input_report_key(input, BTN_TOOL_PEN, 1);
  101. input_report_abs(input, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
  102. input_report_abs(input, ABS_X, get_unaligned_le16(&data[1]));
  103. input_report_abs(input, ABS_Y, get_unaligned_le16(&data[3]));
  104. input_report_abs(input, ABS_PRESSURE, (signed char)data[6] + 127);
  105. input_report_key(input, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
  106. input_report_key(input, BTN_STYLUS, (data[5] & 0x40));
  107. break;
  108. default:
  109. dev_dbg(input->dev.parent,
  110. "%s: received unknown report #%d\n", __func__, data[0]);
  111. return 0;
  112. }
  113. return 1;
  114. }
  115. static int wacom_pl_irq(struct wacom_wac *wacom)
  116. {
  117. struct wacom_features *features = &wacom->features;
  118. unsigned char *data = wacom->data;
  119. struct input_dev *input = wacom->pen_input;
  120. int prox, pressure;
  121. if (data[0] != WACOM_REPORT_PENABLED) {
  122. dev_dbg(input->dev.parent,
  123. "%s: received unknown report #%d\n", __func__, data[0]);
  124. return 0;
  125. }
  126. prox = data[1] & 0x40;
  127. if (!wacom->id[0]) {
  128. if ((data[0] & 0x10) || (data[4] & 0x20)) {
  129. wacom->tool[0] = BTN_TOOL_RUBBER;
  130. wacom->id[0] = ERASER_DEVICE_ID;
  131. }
  132. else {
  133. wacom->tool[0] = BTN_TOOL_PEN;
  134. wacom->id[0] = STYLUS_DEVICE_ID;
  135. }
  136. }
  137. /* If the eraser is in prox, STYLUS2 is always set. If we
  138. * mis-detected the type and notice that STYLUS2 isn't set
  139. * then force the eraser out of prox and let the pen in.
  140. */
  141. if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
  142. input_report_key(input, BTN_TOOL_RUBBER, 0);
  143. input_report_abs(input, ABS_MISC, 0);
  144. input_sync(input);
  145. wacom->tool[0] = BTN_TOOL_PEN;
  146. wacom->id[0] = STYLUS_DEVICE_ID;
  147. }
  148. if (prox) {
  149. pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
  150. if (features->pressure_max > 255)
  151. pressure = (pressure << 1) | ((data[4] >> 6) & 1);
  152. pressure += (features->pressure_max + 1) / 2;
  153. input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
  154. input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
  155. input_report_abs(input, ABS_PRESSURE, pressure);
  156. input_report_key(input, BTN_TOUCH, data[4] & 0x08);
  157. input_report_key(input, BTN_STYLUS, data[4] & 0x10);
  158. /* Only allow the stylus2 button to be reported for the pen tool. */
  159. input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
  160. }
  161. if (!prox)
  162. wacom->id[0] = 0;
  163. input_report_key(input, wacom->tool[0], prox);
  164. input_report_abs(input, ABS_MISC, wacom->id[0]);
  165. return 1;
  166. }
  167. static int wacom_ptu_irq(struct wacom_wac *wacom)
  168. {
  169. unsigned char *data = wacom->data;
  170. struct input_dev *input = wacom->pen_input;
  171. if (data[0] != WACOM_REPORT_PENABLED) {
  172. dev_dbg(input->dev.parent,
  173. "%s: received unknown report #%d\n", __func__, data[0]);
  174. return 0;
  175. }
  176. if (data[1] & 0x04) {
  177. input_report_key(input, BTN_TOOL_RUBBER, data[1] & 0x20);
  178. input_report_key(input, BTN_TOUCH, data[1] & 0x08);
  179. wacom->id[0] = ERASER_DEVICE_ID;
  180. } else {
  181. input_report_key(input, BTN_TOOL_PEN, data[1] & 0x20);
  182. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  183. wacom->id[0] = STYLUS_DEVICE_ID;
  184. }
  185. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  186. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  187. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  188. input_report_abs(input, ABS_PRESSURE, le16_to_cpup((__le16 *)&data[6]));
  189. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  190. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  191. return 1;
  192. }
  193. static int wacom_dtu_irq(struct wacom_wac *wacom)
  194. {
  195. unsigned char *data = wacom->data;
  196. struct input_dev *input = wacom->pen_input;
  197. int prox = data[1] & 0x20;
  198. dev_dbg(input->dev.parent,
  199. "%s: received report #%d", __func__, data[0]);
  200. if (prox) {
  201. /* Going into proximity select tool */
  202. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  203. if (wacom->tool[0] == BTN_TOOL_PEN)
  204. wacom->id[0] = STYLUS_DEVICE_ID;
  205. else
  206. wacom->id[0] = ERASER_DEVICE_ID;
  207. }
  208. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  209. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  210. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  211. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  212. input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x01) << 8) | data[6]);
  213. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  214. if (!prox) /* out-prox */
  215. wacom->id[0] = 0;
  216. input_report_key(input, wacom->tool[0], prox);
  217. input_report_abs(input, ABS_MISC, wacom->id[0]);
  218. return 1;
  219. }
  220. static int wacom_dtus_irq(struct wacom_wac *wacom)
  221. {
  222. unsigned char *data = wacom->data;
  223. struct input_dev *input = wacom->pen_input;
  224. unsigned short prox, pressure = 0;
  225. if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
  226. dev_dbg(input->dev.parent,
  227. "%s: received unknown report #%d", __func__, data[0]);
  228. return 0;
  229. } else if (data[0] == WACOM_REPORT_DTUSPAD) {
  230. input = wacom->pad_input;
  231. input_report_key(input, BTN_0, (data[1] & 0x01));
  232. input_report_key(input, BTN_1, (data[1] & 0x02));
  233. input_report_key(input, BTN_2, (data[1] & 0x04));
  234. input_report_key(input, BTN_3, (data[1] & 0x08));
  235. input_report_abs(input, ABS_MISC,
  236. data[1] & 0x0f ? PAD_DEVICE_ID : 0);
  237. return 1;
  238. } else {
  239. prox = data[1] & 0x80;
  240. if (prox) {
  241. switch ((data[1] >> 3) & 3) {
  242. case 1: /* Rubber */
  243. wacom->tool[0] = BTN_TOOL_RUBBER;
  244. wacom->id[0] = ERASER_DEVICE_ID;
  245. break;
  246. case 2: /* Pen */
  247. wacom->tool[0] = BTN_TOOL_PEN;
  248. wacom->id[0] = STYLUS_DEVICE_ID;
  249. break;
  250. }
  251. }
  252. input_report_key(input, BTN_STYLUS, data[1] & 0x20);
  253. input_report_key(input, BTN_STYLUS2, data[1] & 0x40);
  254. input_report_abs(input, ABS_X, get_unaligned_be16(&data[3]));
  255. input_report_abs(input, ABS_Y, get_unaligned_be16(&data[5]));
  256. pressure = ((data[1] & 0x03) << 8) | (data[2] & 0xff);
  257. input_report_abs(input, ABS_PRESSURE, pressure);
  258. input_report_key(input, BTN_TOUCH, pressure > 10);
  259. if (!prox) /* out-prox */
  260. wacom->id[0] = 0;
  261. input_report_key(input, wacom->tool[0], prox);
  262. input_report_abs(input, ABS_MISC, wacom->id[0]);
  263. return 1;
  264. }
  265. }
  266. static int wacom_graphire_irq(struct wacom_wac *wacom)
  267. {
  268. struct wacom_features *features = &wacom->features;
  269. unsigned char *data = wacom->data;
  270. struct input_dev *input = wacom->pen_input;
  271. struct input_dev *pad_input = wacom->pad_input;
  272. int battery_capacity, ps_connected;
  273. int prox;
  274. int rw = 0;
  275. int retval = 0;
  276. if (features->type == GRAPHIRE_BT) {
  277. if (data[0] != WACOM_REPORT_PENABLED_BT) {
  278. dev_dbg(input->dev.parent,
  279. "%s: received unknown report #%d\n", __func__,
  280. data[0]);
  281. goto exit;
  282. }
  283. } else if (data[0] != WACOM_REPORT_PENABLED) {
  284. dev_dbg(input->dev.parent,
  285. "%s: received unknown report #%d\n", __func__, data[0]);
  286. goto exit;
  287. }
  288. prox = data[1] & 0x80;
  289. if (prox || wacom->id[0]) {
  290. if (prox) {
  291. switch ((data[1] >> 5) & 3) {
  292. case 0: /* Pen */
  293. wacom->tool[0] = BTN_TOOL_PEN;
  294. wacom->id[0] = STYLUS_DEVICE_ID;
  295. break;
  296. case 1: /* Rubber */
  297. wacom->tool[0] = BTN_TOOL_RUBBER;
  298. wacom->id[0] = ERASER_DEVICE_ID;
  299. break;
  300. case 2: /* Mouse with wheel */
  301. input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
  302. /* fall through */
  303. case 3: /* Mouse without wheel */
  304. wacom->tool[0] = BTN_TOOL_MOUSE;
  305. wacom->id[0] = CURSOR_DEVICE_ID;
  306. break;
  307. }
  308. }
  309. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  310. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  311. if (wacom->tool[0] != BTN_TOOL_MOUSE) {
  312. if (features->type == GRAPHIRE_BT)
  313. input_report_abs(input, ABS_PRESSURE, data[6] |
  314. (((__u16) (data[1] & 0x08)) << 5));
  315. else
  316. input_report_abs(input, ABS_PRESSURE, data[6] |
  317. ((data[7] & 0x03) << 8));
  318. input_report_key(input, BTN_TOUCH, data[1] & 0x01);
  319. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  320. input_report_key(input, BTN_STYLUS2, data[1] & 0x04);
  321. } else {
  322. input_report_key(input, BTN_LEFT, data[1] & 0x01);
  323. input_report_key(input, BTN_RIGHT, data[1] & 0x02);
  324. if (features->type == WACOM_G4 ||
  325. features->type == WACOM_MO) {
  326. input_report_abs(input, ABS_DISTANCE, data[6] & 0x3f);
  327. rw = (data[7] & 0x04) - (data[7] & 0x03);
  328. } else if (features->type == GRAPHIRE_BT) {
  329. /* Compute distance between mouse and tablet */
  330. rw = 44 - (data[6] >> 2);
  331. rw = clamp_val(rw, 0, 31);
  332. input_report_abs(input, ABS_DISTANCE, rw);
  333. if (((data[1] >> 5) & 3) == 2) {
  334. /* Mouse with wheel */
  335. input_report_key(input, BTN_MIDDLE,
  336. data[1] & 0x04);
  337. rw = (data[6] & 0x01) ? -1 :
  338. (data[6] & 0x02) ? 1 : 0;
  339. } else {
  340. rw = 0;
  341. }
  342. } else {
  343. input_report_abs(input, ABS_DISTANCE, data[7] & 0x3f);
  344. rw = -(signed char)data[6];
  345. }
  346. input_report_rel(input, REL_WHEEL, rw);
  347. }
  348. if (!prox)
  349. wacom->id[0] = 0;
  350. input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
  351. input_report_key(input, wacom->tool[0], prox);
  352. input_sync(input); /* sync last event */
  353. }
  354. /* send pad data */
  355. switch (features->type) {
  356. case WACOM_G4:
  357. prox = data[7] & 0xf8;
  358. if (prox || wacom->id[1]) {
  359. wacom->id[1] = PAD_DEVICE_ID;
  360. input_report_key(pad_input, BTN_BACK, (data[7] & 0x40));
  361. input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x80));
  362. rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
  363. input_report_rel(pad_input, REL_WHEEL, rw);
  364. if (!prox)
  365. wacom->id[1] = 0;
  366. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  367. retval = 1;
  368. }
  369. break;
  370. case WACOM_MO:
  371. prox = (data[7] & 0xf8) || data[8];
  372. if (prox || wacom->id[1]) {
  373. wacom->id[1] = PAD_DEVICE_ID;
  374. input_report_key(pad_input, BTN_BACK, (data[7] & 0x08));
  375. input_report_key(pad_input, BTN_LEFT, (data[7] & 0x20));
  376. input_report_key(pad_input, BTN_FORWARD, (data[7] & 0x10));
  377. input_report_key(pad_input, BTN_RIGHT, (data[7] & 0x40));
  378. input_report_abs(pad_input, ABS_WHEEL, (data[8] & 0x7f));
  379. if (!prox)
  380. wacom->id[1] = 0;
  381. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  382. retval = 1;
  383. }
  384. break;
  385. case GRAPHIRE_BT:
  386. prox = data[7] & 0x03;
  387. if (prox || wacom->id[1]) {
  388. wacom->id[1] = PAD_DEVICE_ID;
  389. input_report_key(pad_input, BTN_0, (data[7] & 0x02));
  390. input_report_key(pad_input, BTN_1, (data[7] & 0x01));
  391. if (!prox)
  392. wacom->id[1] = 0;
  393. input_report_abs(pad_input, ABS_MISC, wacom->id[1]);
  394. retval = 1;
  395. }
  396. break;
  397. }
  398. /* Store current battery capacity and power supply state */
  399. if (features->type == GRAPHIRE_BT) {
  400. rw = (data[7] >> 2 & 0x07);
  401. battery_capacity = batcap_gr[rw];
  402. ps_connected = rw == 7;
  403. wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
  404. battery_capacity, ps_connected, 1,
  405. ps_connected);
  406. }
  407. exit:
  408. return retval;
  409. }
  410. static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac)
  411. {
  412. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  413. struct wacom_features *features = &wacom_wac->features;
  414. struct hid_report *r;
  415. struct hid_report_enum *re;
  416. re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]);
  417. if (features->type == INTUOSHT2)
  418. r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID];
  419. else
  420. r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1];
  421. if (r) {
  422. hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT);
  423. }
  424. }
  425. static int wacom_intuos_pad(struct wacom_wac *wacom)
  426. {
  427. struct wacom_features *features = &wacom->features;
  428. unsigned char *data = wacom->data;
  429. struct input_dev *input = wacom->pad_input;
  430. int i;
  431. int buttons = 0, nbuttons = features->numbered_buttons;
  432. int keys = 0, nkeys = 0;
  433. int ring1 = 0, ring2 = 0;
  434. int strip1 = 0, strip2 = 0;
  435. bool prox = false;
  436. /* pad packets. Works as a second tool and is always in prox */
  437. if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD ||
  438. data[0] == WACOM_REPORT_CINTIQPAD))
  439. return 0;
  440. if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
  441. buttons = (data[3] << 1) | (data[2] & 0x01);
  442. ring1 = data[1];
  443. } else if (features->type == DTK) {
  444. buttons = data[6];
  445. } else if (features->type == WACOM_13HD) {
  446. buttons = (data[4] << 1) | (data[3] & 0x01);
  447. } else if (features->type == WACOM_24HD) {
  448. buttons = (data[8] << 8) | data[6];
  449. ring1 = data[1];
  450. ring2 = data[2];
  451. /*
  452. * Three "buttons" are available on the 24HD which are
  453. * physically implemented as a touchstrip. Each button
  454. * is approximately 3 bits wide with a 2 bit spacing.
  455. * The raw touchstrip bits are stored at:
  456. * ((data[3] & 0x1f) << 8) | data[4])
  457. */
  458. nkeys = 3;
  459. keys = ((data[3] & 0x1C) ? 1<<2 : 0) |
  460. ((data[4] & 0xE0) ? 1<<1 : 0) |
  461. ((data[4] & 0x07) ? 1<<0 : 0);
  462. } else if (features->type == WACOM_27QHD) {
  463. nkeys = 3;
  464. keys = data[2] & 0x07;
  465. input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
  466. input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
  467. input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
  468. } else if (features->type == CINTIQ_HYBRID) {
  469. /*
  470. * Do not send hardware buttons under Android. They
  471. * are already sent to the system through GPIO (and
  472. * have different meaning).
  473. *
  474. * d-pad right -> data[4] & 0x10
  475. * d-pad up -> data[4] & 0x20
  476. * d-pad left -> data[4] & 0x40
  477. * d-pad down -> data[4] & 0x80
  478. * d-pad center -> data[3] & 0x01
  479. */
  480. buttons = (data[4] << 1) | (data[3] & 0x01);
  481. } else if (features->type == CINTIQ_COMPANION_2) {
  482. /* d-pad right -> data[2] & 0x10
  483. * d-pad up -> data[2] & 0x20
  484. * d-pad left -> data[2] & 0x40
  485. * d-pad down -> data[2] & 0x80
  486. * d-pad center -> data[1] & 0x01
  487. */
  488. buttons = ((data[2] >> 4) << 7) |
  489. ((data[1] & 0x04) << 4) |
  490. ((data[2] & 0x0F) << 2) |
  491. (data[1] & 0x03);
  492. } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
  493. /*
  494. * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
  495. * addition to the mechanical switch. Switch data is
  496. * stored in data[4], capacitive data in data[5].
  497. *
  498. * Touch ring mode switch (data[3]) has no capacitive sensor
  499. */
  500. buttons = (data[4] << 1) | (data[3] & 0x01);
  501. ring1 = data[2];
  502. } else {
  503. if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) {
  504. buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) |
  505. (data[6] << 1) | (data[5] & 0x01);
  506. if (features->type == WACOM_22HD) {
  507. nkeys = 3;
  508. keys = data[9] & 0x07;
  509. }
  510. } else {
  511. buttons = ((data[6] & 0x10) << 5) |
  512. ((data[5] & 0x10) << 4) |
  513. ((data[6] & 0x0F) << 4) |
  514. (data[5] & 0x0F);
  515. }
  516. strip1 = ((data[1] & 0x1f) << 8) | data[2];
  517. strip2 = ((data[3] & 0x1f) << 8) | data[4];
  518. }
  519. prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) |
  520. (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2;
  521. wacom_report_numbered_buttons(input, nbuttons, buttons);
  522. for (i = 0; i < nkeys; i++)
  523. input_report_key(input, KEY_PROG1 + i, keys & (1 << i));
  524. input_report_abs(input, ABS_RX, strip1);
  525. input_report_abs(input, ABS_RY, strip2);
  526. input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0);
  527. input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0);
  528. input_report_key(input, wacom->tool[1], prox ? 1 : 0);
  529. input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
  530. input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
  531. return 1;
  532. }
  533. static int wacom_intuos_id_mangle(int tool_id)
  534. {
  535. return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
  536. }
  537. static int wacom_intuos_get_tool_type(int tool_id)
  538. {
  539. int tool_type;
  540. switch (tool_id) {
  541. case 0x812: /* Inking pen */
  542. case 0x801: /* Intuos3 Inking pen */
  543. case 0x12802: /* Intuos4/5 Inking Pen */
  544. case 0x012:
  545. tool_type = BTN_TOOL_PENCIL;
  546. break;
  547. case 0x822: /* Pen */
  548. case 0x842:
  549. case 0x852:
  550. case 0x823: /* Intuos3 Grip Pen */
  551. case 0x813: /* Intuos3 Classic Pen */
  552. case 0x885: /* Intuos3 Marker Pen */
  553. case 0x802: /* Intuos4/5 13HD/24HD General Pen */
  554. case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
  555. case 0x8e2: /* IntuosHT2 pen */
  556. case 0x022:
  557. case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
  558. case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
  559. case 0x16802: /* Cintiq 13HD Pro Pen */
  560. case 0x18802: /* DTH2242 Pen */
  561. case 0x10802: /* Intuos4/5 13HD/24HD General Pen */
  562. tool_type = BTN_TOOL_PEN;
  563. break;
  564. case 0x832: /* Stroke pen */
  565. case 0x032:
  566. tool_type = BTN_TOOL_BRUSH;
  567. break;
  568. case 0x007: /* Mouse 4D and 2D */
  569. case 0x09c:
  570. case 0x094:
  571. case 0x017: /* Intuos3 2D Mouse */
  572. case 0x806: /* Intuos4 Mouse */
  573. tool_type = BTN_TOOL_MOUSE;
  574. break;
  575. case 0x096: /* Lens cursor */
  576. case 0x097: /* Intuos3 Lens cursor */
  577. case 0x006: /* Intuos4 Lens cursor */
  578. tool_type = BTN_TOOL_LENS;
  579. break;
  580. case 0x82a: /* Eraser */
  581. case 0x84a:
  582. case 0x85a:
  583. case 0x91a:
  584. case 0xd1a:
  585. case 0x0fa:
  586. case 0x82b: /* Intuos3 Grip Pen Eraser */
  587. case 0x81b: /* Intuos3 Classic Pen Eraser */
  588. case 0x91b: /* Intuos3 Airbrush Eraser */
  589. case 0x80c: /* Intuos4/5 13HD/24HD Marker Pen Eraser */
  590. case 0x80a: /* Intuos4/5 13HD/24HD General Pen Eraser */
  591. case 0x90a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
  592. case 0x1480a: /* Intuos4/5 13HD/24HD Classic Pen Eraser */
  593. case 0x1090a: /* Intuos4/5 13HD/24HD Airbrush Eraser */
  594. case 0x1080c: /* Intuos4/5 13HD/24HD Art Pen Eraser */
  595. case 0x1680a: /* Cintiq 13HD Pro Pen Eraser */
  596. case 0x1880a: /* DTH2242 Eraser */
  597. case 0x1080a: /* Intuos4/5 13HD/24HD General Pen Eraser */
  598. tool_type = BTN_TOOL_RUBBER;
  599. break;
  600. case 0xd12:
  601. case 0x912:
  602. case 0x112:
  603. case 0x913: /* Intuos3 Airbrush */
  604. case 0x902: /* Intuos4/5 13HD/24HD Airbrush */
  605. case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
  606. tool_type = BTN_TOOL_AIRBRUSH;
  607. break;
  608. default: /* Unknown tool */
  609. tool_type = BTN_TOOL_PEN;
  610. break;
  611. }
  612. return tool_type;
  613. }
  614. static void wacom_exit_report(struct wacom_wac *wacom)
  615. {
  616. struct input_dev *input = wacom->pen_input;
  617. struct wacom_features *features = &wacom->features;
  618. unsigned char *data = wacom->data;
  619. int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
  620. /*
  621. * Reset all states otherwise we lose the initial states
  622. * when in-prox next time
  623. */
  624. input_report_abs(input, ABS_X, 0);
  625. input_report_abs(input, ABS_Y, 0);
  626. input_report_abs(input, ABS_DISTANCE, 0);
  627. input_report_abs(input, ABS_TILT_X, 0);
  628. input_report_abs(input, ABS_TILT_Y, 0);
  629. if (wacom->tool[idx] >= BTN_TOOL_MOUSE) {
  630. input_report_key(input, BTN_LEFT, 0);
  631. input_report_key(input, BTN_MIDDLE, 0);
  632. input_report_key(input, BTN_RIGHT, 0);
  633. input_report_key(input, BTN_SIDE, 0);
  634. input_report_key(input, BTN_EXTRA, 0);
  635. input_report_abs(input, ABS_THROTTLE, 0);
  636. input_report_abs(input, ABS_RZ, 0);
  637. } else {
  638. input_report_abs(input, ABS_PRESSURE, 0);
  639. input_report_key(input, BTN_STYLUS, 0);
  640. input_report_key(input, BTN_STYLUS2, 0);
  641. input_report_key(input, BTN_TOUCH, 0);
  642. input_report_abs(input, ABS_WHEEL, 0);
  643. if (features->type >= INTUOS3S)
  644. input_report_abs(input, ABS_Z, 0);
  645. }
  646. input_report_key(input, wacom->tool[idx], 0);
  647. input_report_abs(input, ABS_MISC, 0); /* reset tool id */
  648. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  649. wacom->id[idx] = 0;
  650. }
  651. static int wacom_intuos_inout(struct wacom_wac *wacom)
  652. {
  653. struct wacom_features *features = &wacom->features;
  654. unsigned char *data = wacom->data;
  655. struct input_dev *input = wacom->pen_input;
  656. int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
  657. if (!(((data[1] & 0xfc) == 0xc0) || /* in prox */
  658. ((data[1] & 0xfe) == 0x20) || /* in range */
  659. ((data[1] & 0xfe) == 0x80))) /* out prox */
  660. return 0;
  661. /* Enter report */
  662. if ((data[1] & 0xfc) == 0xc0) {
  663. /* serial number of the tool */
  664. wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
  665. (data[4] << 20) + (data[5] << 12) +
  666. (data[6] << 4) + (data[7] >> 4);
  667. wacom->id[idx] = (data[2] << 4) | (data[3] >> 4) |
  668. ((data[7] & 0x0f) << 16) | ((data[8] & 0xf0) << 8);
  669. wacom->tool[idx] = wacom_intuos_get_tool_type(wacom->id[idx]);
  670. wacom->shared->stylus_in_proximity = true;
  671. return 1;
  672. }
  673. /* in Range */
  674. if ((data[1] & 0xfe) == 0x20) {
  675. if (features->type != INTUOSHT2)
  676. wacom->shared->stylus_in_proximity = true;
  677. /* in Range while exiting */
  678. if (wacom->reporting_data) {
  679. input_report_key(input, BTN_TOUCH, 0);
  680. input_report_abs(input, ABS_PRESSURE, 0);
  681. input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
  682. return 2;
  683. }
  684. return 1;
  685. }
  686. /* Exit report */
  687. if ((data[1] & 0xfe) == 0x80) {
  688. wacom->shared->stylus_in_proximity = false;
  689. wacom->reporting_data = false;
  690. /* don't report exit if we don't know the ID */
  691. if (!wacom->id[idx])
  692. return 1;
  693. wacom_exit_report(wacom);
  694. return 2;
  695. }
  696. return 0;
  697. }
  698. static inline bool report_touch_events(struct wacom_wac *wacom)
  699. {
  700. return (touch_arbitration ? !wacom->shared->stylus_in_proximity : 1);
  701. }
  702. static inline bool delay_pen_events(struct wacom_wac *wacom)
  703. {
  704. return (wacom->shared->touch_down && touch_arbitration);
  705. }
  706. static int wacom_intuos_general(struct wacom_wac *wacom)
  707. {
  708. struct wacom_features *features = &wacom->features;
  709. unsigned char *data = wacom->data;
  710. struct input_dev *input = wacom->pen_input;
  711. int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
  712. unsigned char type = (data[1] >> 1) & 0x0F;
  713. unsigned int x, y, distance, t;
  714. if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ &&
  715. data[0] != WACOM_REPORT_INTUOS_PEN)
  716. return 0;
  717. if (delay_pen_events(wacom))
  718. return 1;
  719. /* don't report events if we don't know the tool ID */
  720. if (!wacom->id[idx]) {
  721. /* but reschedule a read of the current tool */
  722. wacom_intuos_schedule_prox_event(wacom);
  723. return 1;
  724. }
  725. /*
  726. * don't report events for invalid data
  727. */
  728. /* older I4 styli don't work with new Cintiqs */
  729. if ((!((wacom->id[idx] >> 16) & 0x01) &&
  730. (features->type == WACOM_21UX2)) ||
  731. /* Only large Intuos support Lense Cursor */
  732. (wacom->tool[idx] == BTN_TOOL_LENS &&
  733. (features->type == INTUOS3 ||
  734. features->type == INTUOS3S ||
  735. features->type == INTUOS4 ||
  736. features->type == INTUOS4S ||
  737. features->type == INTUOS5 ||
  738. features->type == INTUOS5S ||
  739. features->type == INTUOSPM ||
  740. features->type == INTUOSPS)) ||
  741. /* Cintiq doesn't send data when RDY bit isn't set */
  742. (features->type == CINTIQ && !(data[1] & 0x40)))
  743. return 1;
  744. x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1);
  745. y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1);
  746. distance = data[9] >> 2;
  747. if (features->type < INTUOS3S) {
  748. x >>= 1;
  749. y >>= 1;
  750. distance >>= 1;
  751. }
  752. if (features->type == INTUOSHT2)
  753. distance = features->distance_max - distance;
  754. input_report_abs(input, ABS_X, x);
  755. input_report_abs(input, ABS_Y, y);
  756. input_report_abs(input, ABS_DISTANCE, distance);
  757. switch (type) {
  758. case 0x00:
  759. case 0x01:
  760. case 0x02:
  761. case 0x03:
  762. /* general pen packet */
  763. t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1);
  764. if (features->pressure_max < 2047)
  765. t >>= 1;
  766. input_report_abs(input, ABS_PRESSURE, t);
  767. if (features->type != INTUOSHT2) {
  768. input_report_abs(input, ABS_TILT_X,
  769. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  770. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  771. }
  772. input_report_key(input, BTN_STYLUS, data[1] & 2);
  773. input_report_key(input, BTN_STYLUS2, data[1] & 4);
  774. input_report_key(input, BTN_TOUCH, t > 10);
  775. break;
  776. case 0x0a:
  777. /* airbrush second packet */
  778. input_report_abs(input, ABS_WHEEL,
  779. (data[6] << 2) | ((data[7] >> 6) & 3));
  780. input_report_abs(input, ABS_TILT_X,
  781. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  782. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  783. break;
  784. case 0x05:
  785. /* Rotation packet */
  786. if (features->type >= INTUOS3S) {
  787. /* I3 marker pen rotation */
  788. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  789. t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
  790. ((t-1) / 2 + 450)) : (450 - t / 2) ;
  791. input_report_abs(input, ABS_Z, t);
  792. } else {
  793. /* 4D mouse 2nd packet */
  794. t = (data[6] << 3) | ((data[7] >> 5) & 7);
  795. input_report_abs(input, ABS_RZ, (data[7] & 0x20) ?
  796. ((t - 1) / 2) : -t / 2);
  797. }
  798. break;
  799. case 0x04:
  800. /* 4D mouse 1st packet */
  801. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  802. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  803. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  804. input_report_key(input, BTN_SIDE, data[8] & 0x20);
  805. input_report_key(input, BTN_EXTRA, data[8] & 0x10);
  806. t = (data[6] << 2) | ((data[7] >> 6) & 3);
  807. input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
  808. break;
  809. case 0x06:
  810. /* I4 mouse */
  811. input_report_key(input, BTN_LEFT, data[6] & 0x01);
  812. input_report_key(input, BTN_MIDDLE, data[6] & 0x02);
  813. input_report_key(input, BTN_RIGHT, data[6] & 0x04);
  814. input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7)
  815. - ((data[7] & 0x40) >> 6));
  816. input_report_key(input, BTN_SIDE, data[6] & 0x08);
  817. input_report_key(input, BTN_EXTRA, data[6] & 0x10);
  818. input_report_abs(input, ABS_TILT_X,
  819. (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
  820. input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
  821. break;
  822. case 0x08:
  823. if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
  824. /* 2D mouse packet */
  825. input_report_key(input, BTN_LEFT, data[8] & 0x04);
  826. input_report_key(input, BTN_MIDDLE, data[8] & 0x08);
  827. input_report_key(input, BTN_RIGHT, data[8] & 0x10);
  828. input_report_rel(input, REL_WHEEL, (data[8] & 0x01)
  829. - ((data[8] & 0x02) >> 1));
  830. /* I3 2D mouse side buttons */
  831. if (features->type >= INTUOS3S && features->type <= INTUOS3L) {
  832. input_report_key(input, BTN_SIDE, data[8] & 0x40);
  833. input_report_key(input, BTN_EXTRA, data[8] & 0x20);
  834. }
  835. }
  836. else if (wacom->tool[idx] == BTN_TOOL_LENS) {
  837. /* Lens cursor packets */
  838. input_report_key(input, BTN_LEFT, data[8] & 0x01);
  839. input_report_key(input, BTN_MIDDLE, data[8] & 0x02);
  840. input_report_key(input, BTN_RIGHT, data[8] & 0x04);
  841. input_report_key(input, BTN_SIDE, data[8] & 0x10);
  842. input_report_key(input, BTN_EXTRA, data[8] & 0x08);
  843. }
  844. break;
  845. case 0x07:
  846. case 0x09:
  847. case 0x0b:
  848. case 0x0c:
  849. case 0x0d:
  850. case 0x0e:
  851. case 0x0f:
  852. /* unhandled */
  853. break;
  854. }
  855. input_report_abs(input, ABS_MISC,
  856. wacom_intuos_id_mangle(wacom->id[idx])); /* report tool id */
  857. input_report_key(input, wacom->tool[idx], 1);
  858. input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
  859. wacom->reporting_data = true;
  860. return 2;
  861. }
  862. static int wacom_intuos_irq(struct wacom_wac *wacom)
  863. {
  864. unsigned char *data = wacom->data;
  865. struct input_dev *input = wacom->pen_input;
  866. int result;
  867. if (data[0] != WACOM_REPORT_PENABLED &&
  868. data[0] != WACOM_REPORT_INTUOS_ID1 &&
  869. data[0] != WACOM_REPORT_INTUOS_ID2 &&
  870. data[0] != WACOM_REPORT_INTUOSPAD &&
  871. data[0] != WACOM_REPORT_INTUOS_PEN &&
  872. data[0] != WACOM_REPORT_CINTIQ &&
  873. data[0] != WACOM_REPORT_CINTIQPAD &&
  874. data[0] != WACOM_REPORT_INTUOS5PAD) {
  875. dev_dbg(input->dev.parent,
  876. "%s: received unknown report #%d\n", __func__, data[0]);
  877. return 0;
  878. }
  879. /* process pad events */
  880. result = wacom_intuos_pad(wacom);
  881. if (result)
  882. return result;
  883. /* process in/out prox events */
  884. result = wacom_intuos_inout(wacom);
  885. if (result)
  886. return result - 1;
  887. /* process general packets */
  888. result = wacom_intuos_general(wacom);
  889. if (result)
  890. return result - 1;
  891. return 0;
  892. }
  893. static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
  894. {
  895. unsigned char *data = wacom_wac->data;
  896. struct input_dev *input;
  897. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  898. struct wacom_remote *remote = wacom->remote;
  899. int bat_charging, bat_percent, touch_ring_mode;
  900. __u32 serial;
  901. int i, index = -1;
  902. unsigned long flags;
  903. if (data[0] != WACOM_REPORT_REMOTE) {
  904. hid_dbg(wacom->hdev, "%s: received unknown report #%d",
  905. __func__, data[0]);
  906. return 0;
  907. }
  908. serial = data[3] + (data[4] << 8) + (data[5] << 16);
  909. wacom_wac->id[0] = PAD_DEVICE_ID;
  910. spin_lock_irqsave(&remote->remote_lock, flags);
  911. for (i = 0; i < WACOM_MAX_REMOTES; i++) {
  912. if (remote->remotes[i].serial == serial) {
  913. index = i;
  914. break;
  915. }
  916. }
  917. if (index < 0 || !remote->remotes[index].registered)
  918. goto out;
  919. input = remote->remotes[index].input;
  920. input_report_key(input, BTN_0, (data[9] & 0x01));
  921. input_report_key(input, BTN_1, (data[9] & 0x02));
  922. input_report_key(input, BTN_2, (data[9] & 0x04));
  923. input_report_key(input, BTN_3, (data[9] & 0x08));
  924. input_report_key(input, BTN_4, (data[9] & 0x10));
  925. input_report_key(input, BTN_5, (data[9] & 0x20));
  926. input_report_key(input, BTN_6, (data[9] & 0x40));
  927. input_report_key(input, BTN_7, (data[9] & 0x80));
  928. input_report_key(input, BTN_8, (data[10] & 0x01));
  929. input_report_key(input, BTN_9, (data[10] & 0x02));
  930. input_report_key(input, BTN_A, (data[10] & 0x04));
  931. input_report_key(input, BTN_B, (data[10] & 0x08));
  932. input_report_key(input, BTN_C, (data[10] & 0x10));
  933. input_report_key(input, BTN_X, (data[10] & 0x20));
  934. input_report_key(input, BTN_Y, (data[10] & 0x40));
  935. input_report_key(input, BTN_Z, (data[10] & 0x80));
  936. input_report_key(input, BTN_BASE, (data[11] & 0x01));
  937. input_report_key(input, BTN_BASE2, (data[11] & 0x02));
  938. if (data[12] & 0x80)
  939. input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f) - 1);
  940. else
  941. input_report_abs(input, ABS_WHEEL, 0);
  942. bat_percent = data[7] & 0x7f;
  943. bat_charging = !!(data[7] & 0x80);
  944. if (data[9] | data[10] | (data[11] & 0x03) | data[12])
  945. input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
  946. else
  947. input_report_abs(input, ABS_MISC, 0);
  948. input_event(input, EV_MSC, MSC_SERIAL, serial);
  949. input_sync(input);
  950. /*Which mode select (LED light) is currently on?*/
  951. touch_ring_mode = (data[11] & 0xC0) >> 6;
  952. for (i = 0; i < WACOM_MAX_REMOTES; i++) {
  953. if (remote->remotes[i].serial == serial)
  954. wacom->led.groups[i].select = touch_ring_mode;
  955. }
  956. __wacom_notify_battery(&remote->remotes[index].battery,
  957. WACOM_POWER_SUPPLY_STATUS_AUTO, bat_percent,
  958. bat_charging, 1, bat_charging);
  959. out:
  960. spin_unlock_irqrestore(&remote->remote_lock, flags);
  961. return 0;
  962. }
  963. static void wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
  964. {
  965. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  966. unsigned char *data = wacom_wac->data;
  967. struct wacom_remote *remote = wacom->remote;
  968. struct wacom_remote_data remote_data;
  969. unsigned long flags;
  970. int i, ret;
  971. if (data[0] != WACOM_REPORT_DEVICE_LIST)
  972. return;
  973. memset(&remote_data, 0, sizeof(struct wacom_remote_data));
  974. for (i = 0; i < WACOM_MAX_REMOTES; i++) {
  975. int j = i * 6;
  976. int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
  977. bool connected = data[j+2];
  978. remote_data.remote[i].serial = serial;
  979. remote_data.remote[i].connected = connected;
  980. }
  981. spin_lock_irqsave(&remote->remote_lock, flags);
  982. ret = kfifo_in(&remote->remote_fifo, &remote_data, sizeof(remote_data));
  983. if (ret != sizeof(remote_data)) {
  984. spin_unlock_irqrestore(&remote->remote_lock, flags);
  985. hid_err(wacom->hdev, "Can't queue Remote status event.\n");
  986. return;
  987. }
  988. spin_unlock_irqrestore(&remote->remote_lock, flags);
  989. wacom_schedule_work(wacom_wac, WACOM_WORKER_REMOTE);
  990. }
  991. static int int_dist(int x1, int y1, int x2, int y2)
  992. {
  993. int x = x2 - x1;
  994. int y = y2 - y1;
  995. return int_sqrt(x*x + y*y);
  996. }
  997. static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
  998. unsigned char *data)
  999. {
  1000. memcpy(wacom->data, data, 10);
  1001. wacom_intuos_irq(wacom);
  1002. input_sync(wacom->pen_input);
  1003. if (wacom->pad_input)
  1004. input_sync(wacom->pad_input);
  1005. }
  1006. static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
  1007. {
  1008. unsigned char data[WACOM_PKGLEN_MAX];
  1009. int i = 1;
  1010. unsigned power_raw, battery_capacity, bat_charging, ps_connected;
  1011. memcpy(data, wacom->data, len);
  1012. switch (data[0]) {
  1013. case 0x04:
  1014. wacom_intuos_bt_process_data(wacom, data + i);
  1015. i += 10;
  1016. /* fall through */
  1017. case 0x03:
  1018. wacom_intuos_bt_process_data(wacom, data + i);
  1019. i += 10;
  1020. wacom_intuos_bt_process_data(wacom, data + i);
  1021. i += 10;
  1022. power_raw = data[i];
  1023. bat_charging = (power_raw & 0x08) ? 1 : 0;
  1024. ps_connected = (power_raw & 0x10) ? 1 : 0;
  1025. battery_capacity = batcap_i4[power_raw & 0x07];
  1026. wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
  1027. battery_capacity, bat_charging,
  1028. battery_capacity || bat_charging,
  1029. ps_connected);
  1030. break;
  1031. default:
  1032. dev_dbg(wacom->pen_input->dev.parent,
  1033. "Unknown report: %d,%d size:%zu\n",
  1034. data[0], data[1], len);
  1035. return 0;
  1036. }
  1037. return 0;
  1038. }
  1039. static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
  1040. {
  1041. struct input_dev *input = wacom->touch_input;
  1042. unsigned touch_max = wacom->features.touch_max;
  1043. int count = 0;
  1044. int i;
  1045. if (!touch_max)
  1046. return 0;
  1047. if (touch_max == 1)
  1048. return test_bit(BTN_TOUCH, input->key) &&
  1049. report_touch_events(wacom);
  1050. for (i = 0; i < input->mt->num_slots; i++) {
  1051. struct input_mt_slot *ps = &input->mt->slots[i];
  1052. int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID);
  1053. if (id >= 0)
  1054. count++;
  1055. }
  1056. return count;
  1057. }
  1058. static void wacom_intuos_pro2_bt_pen(struct wacom_wac *wacom)
  1059. {
  1060. int pen_frame_len, pen_frames;
  1061. struct input_dev *pen_input = wacom->pen_input;
  1062. unsigned char *data = wacom->data;
  1063. int i;
  1064. if (wacom->features.type == INTUOSP2_BT) {
  1065. wacom->serial[0] = get_unaligned_le64(&data[99]);
  1066. wacom->id[0] = get_unaligned_le16(&data[107]);
  1067. pen_frame_len = 14;
  1068. pen_frames = 7;
  1069. } else {
  1070. wacom->serial[0] = get_unaligned_le64(&data[33]);
  1071. wacom->id[0] = get_unaligned_le16(&data[41]);
  1072. pen_frame_len = 8;
  1073. pen_frames = 4;
  1074. }
  1075. if (wacom->serial[0] >> 52 == 1) {
  1076. /* Add back in missing bits of ID for non-USI pens */
  1077. wacom->id[0] |= (wacom->serial[0] >> 32) & 0xFFFFF;
  1078. }
  1079. for (i = 0; i < pen_frames; i++) {
  1080. unsigned char *frame = &data[i*pen_frame_len + 1];
  1081. bool valid = frame[0] & 0x80;
  1082. bool prox = frame[0] & 0x40;
  1083. bool range = frame[0] & 0x20;
  1084. bool invert = frame[0] & 0x10;
  1085. if (!valid)
  1086. continue;
  1087. if (!prox) {
  1088. wacom->shared->stylus_in_proximity = false;
  1089. wacom_exit_report(wacom);
  1090. input_sync(pen_input);
  1091. wacom->tool[0] = 0;
  1092. wacom->id[0] = 0;
  1093. wacom->serial[0] = 0;
  1094. return;
  1095. }
  1096. if (range) {
  1097. if (!wacom->tool[0]) { /* first in range */
  1098. /* Going into range select tool */
  1099. if (invert)
  1100. wacom->tool[0] = BTN_TOOL_RUBBER;
  1101. else if (wacom->id[0])
  1102. wacom->tool[0] = wacom_intuos_get_tool_type(wacom->id[0]);
  1103. else
  1104. wacom->tool[0] = BTN_TOOL_PEN;
  1105. }
  1106. input_report_abs(pen_input, ABS_X, get_unaligned_le16(&frame[1]));
  1107. input_report_abs(pen_input, ABS_Y, get_unaligned_le16(&frame[3]));
  1108. if (wacom->features.type == INTUOSP2_BT) {
  1109. /* Fix rotation alignment: userspace expects zero at left */
  1110. int16_t rotation =
  1111. (int16_t)get_unaligned_le16(&frame[9]);
  1112. rotation += 1800/4;
  1113. if (rotation > 899)
  1114. rotation -= 1800;
  1115. input_report_abs(pen_input, ABS_TILT_X,
  1116. (char)frame[7]);
  1117. input_report_abs(pen_input, ABS_TILT_Y,
  1118. (char)frame[8]);
  1119. input_report_abs(pen_input, ABS_Z, rotation);
  1120. input_report_abs(pen_input, ABS_WHEEL,
  1121. get_unaligned_le16(&frame[11]));
  1122. }
  1123. }
  1124. if (wacom->tool[0]) {
  1125. input_report_abs(pen_input, ABS_PRESSURE, get_unaligned_le16(&frame[5]));
  1126. if (wacom->features.type == INTUOSP2_BT) {
  1127. input_report_abs(pen_input, ABS_DISTANCE,
  1128. range ? frame[13] : wacom->features.distance_max);
  1129. } else {
  1130. input_report_abs(pen_input, ABS_DISTANCE,
  1131. range ? frame[7] : wacom->features.distance_max);
  1132. }
  1133. input_report_key(pen_input, BTN_TOUCH, frame[0] & 0x09);
  1134. input_report_key(pen_input, BTN_STYLUS, frame[0] & 0x02);
  1135. input_report_key(pen_input, BTN_STYLUS2, frame[0] & 0x04);
  1136. input_report_key(pen_input, wacom->tool[0], prox);
  1137. input_event(pen_input, EV_MSC, MSC_SERIAL, wacom->serial[0]);
  1138. input_report_abs(pen_input, ABS_MISC,
  1139. wacom_intuos_id_mangle(wacom->id[0])); /* report tool id */
  1140. }
  1141. wacom->shared->stylus_in_proximity = prox;
  1142. input_sync(pen_input);
  1143. }
  1144. }
  1145. static void wacom_intuos_pro2_bt_touch(struct wacom_wac *wacom)
  1146. {
  1147. const int finger_touch_len = 8;
  1148. const int finger_frames = 4;
  1149. const int finger_frame_len = 43;
  1150. struct input_dev *touch_input = wacom->touch_input;
  1151. unsigned char *data = wacom->data;
  1152. int num_contacts_left = 5;
  1153. int i, j;
  1154. for (i = 0; i < finger_frames; i++) {
  1155. unsigned char *frame = &data[i*finger_frame_len + 109];
  1156. int current_num_contacts = frame[0] & 0x7F;
  1157. int contacts_to_send;
  1158. if (!(frame[0] & 0x80))
  1159. continue;
  1160. /*
  1161. * First packet resets the counter since only the first
  1162. * packet in series will have non-zero current_num_contacts.
  1163. */
  1164. if (current_num_contacts)
  1165. wacom->num_contacts_left = current_num_contacts;
  1166. contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
  1167. for (j = 0; j < contacts_to_send; j++) {
  1168. unsigned char *touch = &frame[j*finger_touch_len + 1];
  1169. int slot = input_mt_get_slot_by_key(touch_input, touch[0]);
  1170. int x = get_unaligned_le16(&touch[2]);
  1171. int y = get_unaligned_le16(&touch[4]);
  1172. int w = touch[6] * input_abs_get_res(touch_input, ABS_MT_POSITION_X);
  1173. int h = touch[7] * input_abs_get_res(touch_input, ABS_MT_POSITION_Y);
  1174. if (slot < 0)
  1175. continue;
  1176. input_mt_slot(touch_input, slot);
  1177. input_mt_report_slot_state(touch_input, MT_TOOL_FINGER, touch[1] & 0x01);
  1178. input_report_abs(touch_input, ABS_MT_POSITION_X, x);
  1179. input_report_abs(touch_input, ABS_MT_POSITION_Y, y);
  1180. input_report_abs(touch_input, ABS_MT_TOUCH_MAJOR, max(w, h));
  1181. input_report_abs(touch_input, ABS_MT_TOUCH_MINOR, min(w, h));
  1182. input_report_abs(touch_input, ABS_MT_ORIENTATION, w > h);
  1183. }
  1184. input_mt_sync_frame(touch_input);
  1185. wacom->num_contacts_left -= contacts_to_send;
  1186. if (wacom->num_contacts_left <= 0) {
  1187. wacom->num_contacts_left = 0;
  1188. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1189. input_sync(touch_input);
  1190. }
  1191. }
  1192. if (wacom->num_contacts_left == 0) {
  1193. // Be careful that we don't accidentally call input_sync with
  1194. // only a partial set of fingers of processed
  1195. input_report_switch(touch_input, SW_MUTE_DEVICE, !(data[281] >> 7));
  1196. input_sync(touch_input);
  1197. }
  1198. }
  1199. static void wacom_intuos_pro2_bt_pad(struct wacom_wac *wacom)
  1200. {
  1201. struct input_dev *pad_input = wacom->pad_input;
  1202. unsigned char *data = wacom->data;
  1203. int buttons = data[282] | ((data[281] & 0x40) << 2);
  1204. int ring = data[285] & 0x7F;
  1205. bool ringstatus = data[285] & 0x80;
  1206. bool prox = buttons || ringstatus;
  1207. /* Fix touchring data: userspace expects 0 at left and increasing clockwise */
  1208. ring = 71 - ring;
  1209. ring += 3*72/16;
  1210. if (ring > 71)
  1211. ring -= 72;
  1212. wacom_report_numbered_buttons(pad_input, 9, buttons);
  1213. input_report_abs(pad_input, ABS_WHEEL, ringstatus ? ring : 0);
  1214. input_report_key(pad_input, wacom->tool[1], prox ? 1 : 0);
  1215. input_report_abs(pad_input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
  1216. input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
  1217. input_sync(pad_input);
  1218. }
  1219. static void wacom_intuos_pro2_bt_battery(struct wacom_wac *wacom)
  1220. {
  1221. unsigned char *data = wacom->data;
  1222. bool chg = data[284] & 0x80;
  1223. int battery_status = data[284] & 0x7F;
  1224. wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
  1225. battery_status, chg, 1, chg);
  1226. }
  1227. static void wacom_intuos_gen3_bt_pad(struct wacom_wac *wacom)
  1228. {
  1229. struct input_dev *pad_input = wacom->pad_input;
  1230. unsigned char *data = wacom->data;
  1231. int buttons = data[44];
  1232. wacom_report_numbered_buttons(pad_input, 4, buttons);
  1233. input_report_key(pad_input, wacom->tool[1], buttons ? 1 : 0);
  1234. input_report_abs(pad_input, ABS_MISC, buttons ? PAD_DEVICE_ID : 0);
  1235. input_event(pad_input, EV_MSC, MSC_SERIAL, 0xffffffff);
  1236. input_sync(pad_input);
  1237. }
  1238. static void wacom_intuos_gen3_bt_battery(struct wacom_wac *wacom)
  1239. {
  1240. unsigned char *data = wacom->data;
  1241. bool chg = data[45] & 0x80;
  1242. int battery_status = data[45] & 0x7F;
  1243. wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
  1244. battery_status, chg, 1, chg);
  1245. }
  1246. static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
  1247. {
  1248. unsigned char *data = wacom->data;
  1249. if (data[0] != 0x80 && data[0] != 0x81) {
  1250. dev_dbg(wacom->pen_input->dev.parent,
  1251. "%s: received unknown report #%d\n", __func__, data[0]);
  1252. return 0;
  1253. }
  1254. wacom_intuos_pro2_bt_pen(wacom);
  1255. if (wacom->features.type == INTUOSP2_BT) {
  1256. wacom_intuos_pro2_bt_touch(wacom);
  1257. wacom_intuos_pro2_bt_pad(wacom);
  1258. wacom_intuos_pro2_bt_battery(wacom);
  1259. } else {
  1260. wacom_intuos_gen3_bt_pad(wacom);
  1261. wacom_intuos_gen3_bt_battery(wacom);
  1262. }
  1263. return 0;
  1264. }
  1265. static int wacom_24hdt_irq(struct wacom_wac *wacom)
  1266. {
  1267. struct input_dev *input = wacom->touch_input;
  1268. unsigned char *data = wacom->data;
  1269. int i;
  1270. int current_num_contacts = data[61];
  1271. int contacts_to_send = 0;
  1272. int num_contacts_left = 4; /* maximum contacts per packet */
  1273. int byte_per_packet = WACOM_BYTES_PER_24HDT_PACKET;
  1274. int y_offset = 2;
  1275. if (wacom->features.type == WACOM_27QHDT) {
  1276. current_num_contacts = data[63];
  1277. num_contacts_left = 10;
  1278. byte_per_packet = WACOM_BYTES_PER_QHDTHID_PACKET;
  1279. y_offset = 0;
  1280. }
  1281. /*
  1282. * First packet resets the counter since only the first
  1283. * packet in series will have non-zero current_num_contacts.
  1284. */
  1285. if (current_num_contacts)
  1286. wacom->num_contacts_left = current_num_contacts;
  1287. contacts_to_send = min(num_contacts_left, wacom->num_contacts_left);
  1288. for (i = 0; i < contacts_to_send; i++) {
  1289. int offset = (byte_per_packet * i) + 1;
  1290. bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
  1291. int slot = input_mt_get_slot_by_key(input, data[offset + 1]);
  1292. if (slot < 0)
  1293. continue;
  1294. input_mt_slot(input, slot);
  1295. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1296. if (touch) {
  1297. int t_x = get_unaligned_le16(&data[offset + 2]);
  1298. int t_y = get_unaligned_le16(&data[offset + 4 + y_offset]);
  1299. input_report_abs(input, ABS_MT_POSITION_X, t_x);
  1300. input_report_abs(input, ABS_MT_POSITION_Y, t_y);
  1301. if (wacom->features.type != WACOM_27QHDT) {
  1302. int c_x = get_unaligned_le16(&data[offset + 4]);
  1303. int c_y = get_unaligned_le16(&data[offset + 8]);
  1304. int w = get_unaligned_le16(&data[offset + 10]);
  1305. int h = get_unaligned_le16(&data[offset + 12]);
  1306. input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
  1307. input_report_abs(input, ABS_MT_WIDTH_MAJOR,
  1308. min(w, h) + int_dist(t_x, t_y, c_x, c_y));
  1309. input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
  1310. input_report_abs(input, ABS_MT_ORIENTATION, w > h);
  1311. }
  1312. }
  1313. }
  1314. input_mt_sync_frame(input);
  1315. wacom->num_contacts_left -= contacts_to_send;
  1316. if (wacom->num_contacts_left <= 0) {
  1317. wacom->num_contacts_left = 0;
  1318. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1319. }
  1320. return 1;
  1321. }
  1322. static int wacom_mt_touch(struct wacom_wac *wacom)
  1323. {
  1324. struct input_dev *input = wacom->touch_input;
  1325. unsigned char *data = wacom->data;
  1326. int i;
  1327. int current_num_contacts = data[2];
  1328. int contacts_to_send = 0;
  1329. int x_offset = 0;
  1330. /* MTTPC does not support Height and Width */
  1331. if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
  1332. x_offset = -4;
  1333. /*
  1334. * First packet resets the counter since only the first
  1335. * packet in series will have non-zero current_num_contacts.
  1336. */
  1337. if (current_num_contacts)
  1338. wacom->num_contacts_left = current_num_contacts;
  1339. /* There are at most 5 contacts per packet */
  1340. contacts_to_send = min(5, wacom->num_contacts_left);
  1341. for (i = 0; i < contacts_to_send; i++) {
  1342. int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
  1343. bool touch = (data[offset] & 0x1) && report_touch_events(wacom);
  1344. int id = get_unaligned_le16(&data[offset + 1]);
  1345. int slot = input_mt_get_slot_by_key(input, id);
  1346. if (slot < 0)
  1347. continue;
  1348. input_mt_slot(input, slot);
  1349. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1350. if (touch) {
  1351. int x = get_unaligned_le16(&data[offset + x_offset + 7]);
  1352. int y = get_unaligned_le16(&data[offset + x_offset + 9]);
  1353. input_report_abs(input, ABS_MT_POSITION_X, x);
  1354. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1355. }
  1356. }
  1357. input_mt_sync_frame(input);
  1358. wacom->num_contacts_left -= contacts_to_send;
  1359. if (wacom->num_contacts_left <= 0) {
  1360. wacom->num_contacts_left = 0;
  1361. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1362. }
  1363. return 1;
  1364. }
  1365. static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
  1366. {
  1367. struct input_dev *input = wacom->touch_input;
  1368. unsigned char *data = wacom->data;
  1369. int i;
  1370. for (i = 0; i < 2; i++) {
  1371. int p = data[1] & (1 << i);
  1372. bool touch = p && report_touch_events(wacom);
  1373. input_mt_slot(input, i);
  1374. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  1375. if (touch) {
  1376. int x = le16_to_cpup((__le16 *)&data[i * 2 + 2]) & 0x7fff;
  1377. int y = le16_to_cpup((__le16 *)&data[i * 2 + 6]) & 0x7fff;
  1378. input_report_abs(input, ABS_MT_POSITION_X, x);
  1379. input_report_abs(input, ABS_MT_POSITION_Y, y);
  1380. }
  1381. }
  1382. input_mt_sync_frame(input);
  1383. /* keep touch state for pen event */
  1384. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  1385. return 1;
  1386. }
  1387. static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
  1388. {
  1389. unsigned char *data = wacom->data;
  1390. struct input_dev *input = wacom->touch_input;
  1391. bool prox = report_touch_events(wacom);
  1392. int x = 0, y = 0;
  1393. if (wacom->features.touch_max > 1 || len > WACOM_PKGLEN_TPC2FG)
  1394. return 0;
  1395. if (len == WACOM_PKGLEN_TPC1FG) {
  1396. prox = prox && (data[0] & 0x01);
  1397. x = get_unaligned_le16(&data[1]);
  1398. y = get_unaligned_le16(&data[3]);
  1399. } else if (len == WACOM_PKGLEN_TPC1FG_B) {
  1400. prox = prox && (data[2] & 0x01);
  1401. x = get_unaligned_le16(&data[3]);
  1402. y = get_unaligned_le16(&data[5]);
  1403. } else {
  1404. prox = prox && (data[1] & 0x01);
  1405. x = le16_to_cpup((__le16 *)&data[2]);
  1406. y = le16_to_cpup((__le16 *)&data[4]);
  1407. }
  1408. if (prox) {
  1409. input_report_abs(input, ABS_X, x);
  1410. input_report_abs(input, ABS_Y, y);
  1411. }
  1412. input_report_key(input, BTN_TOUCH, prox);
  1413. /* keep touch state for pen events */
  1414. wacom->shared->touch_down = prox;
  1415. return 1;
  1416. }
  1417. static int wacom_tpc_pen(struct wacom_wac *wacom)
  1418. {
  1419. unsigned char *data = wacom->data;
  1420. struct input_dev *input = wacom->pen_input;
  1421. bool prox = data[1] & 0x20;
  1422. if (!wacom->shared->stylus_in_proximity) /* first in prox */
  1423. /* Going into proximity select tool */
  1424. wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
  1425. /* keep pen state for touch events */
  1426. wacom->shared->stylus_in_proximity = prox;
  1427. /* send pen events only when touch is up or forced out
  1428. * or touch arbitration is off
  1429. */
  1430. if (!delay_pen_events(wacom)) {
  1431. input_report_key(input, BTN_STYLUS, data[1] & 0x02);
  1432. input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
  1433. input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
  1434. input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
  1435. input_report_abs(input, ABS_PRESSURE, ((data[7] & 0x07) << 8) | data[6]);
  1436. input_report_key(input, BTN_TOUCH, data[1] & 0x05);
  1437. input_report_key(input, wacom->tool[0], prox);
  1438. return 1;
  1439. }
  1440. return 0;
  1441. }
  1442. static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
  1443. {
  1444. unsigned char *data = wacom->data;
  1445. if (wacom->pen_input) {
  1446. dev_dbg(wacom->pen_input->dev.parent,
  1447. "%s: received report #%d\n", __func__, data[0]);
  1448. if (len == WACOM_PKGLEN_PENABLED ||
  1449. data[0] == WACOM_REPORT_PENABLED)
  1450. return wacom_tpc_pen(wacom);
  1451. }
  1452. else if (wacom->touch_input) {
  1453. dev_dbg(wacom->touch_input->dev.parent,
  1454. "%s: received report #%d\n", __func__, data[0]);
  1455. switch (len) {
  1456. case WACOM_PKGLEN_TPC1FG:
  1457. return wacom_tpc_single_touch(wacom, len);
  1458. case WACOM_PKGLEN_TPC2FG:
  1459. return wacom_tpc_mt_touch(wacom);
  1460. default:
  1461. switch (data[0]) {
  1462. case WACOM_REPORT_TPC1FG:
  1463. case WACOM_REPORT_TPCHID:
  1464. case WACOM_REPORT_TPCST:
  1465. case WACOM_REPORT_TPC1FGE:
  1466. return wacom_tpc_single_touch(wacom, len);
  1467. case WACOM_REPORT_TPCMT:
  1468. case WACOM_REPORT_TPCMT2:
  1469. return wacom_mt_touch(wacom);
  1470. }
  1471. }
  1472. }
  1473. return 0;
  1474. }
  1475. static int wacom_offset_rotation(struct input_dev *input, struct hid_usage *usage,
  1476. int value, int num, int denom)
  1477. {
  1478. struct input_absinfo *abs = &input->absinfo[usage->code];
  1479. int range = (abs->maximum - abs->minimum + 1);
  1480. value += num*range/denom;
  1481. if (value > abs->maximum)
  1482. value -= range;
  1483. else if (value < abs->minimum)
  1484. value += range;
  1485. return value;
  1486. }
  1487. int wacom_equivalent_usage(int usage)
  1488. {
  1489. if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMDIGITIZER) {
  1490. int subpage = (usage & 0xFF00) << 8;
  1491. int subusage = (usage & 0xFF);
  1492. if (subpage == WACOM_HID_SP_PAD ||
  1493. subpage == WACOM_HID_SP_BUTTON ||
  1494. subpage == WACOM_HID_SP_DIGITIZER ||
  1495. subpage == WACOM_HID_SP_DIGITIZERINFO ||
  1496. usage == WACOM_HID_WD_SENSE ||
  1497. usage == WACOM_HID_WD_SERIALHI ||
  1498. usage == WACOM_HID_WD_TOOLTYPE ||
  1499. usage == WACOM_HID_WD_DISTANCE ||
  1500. usage == WACOM_HID_WD_TOUCHSTRIP ||
  1501. usage == WACOM_HID_WD_TOUCHSTRIP2 ||
  1502. usage == WACOM_HID_WD_TOUCHRING ||
  1503. usage == WACOM_HID_WD_TOUCHRINGSTATUS ||
  1504. usage == WACOM_HID_WD_REPORT_VALID) {
  1505. return usage;
  1506. }
  1507. if (subpage == HID_UP_UNDEFINED)
  1508. subpage = HID_UP_DIGITIZER;
  1509. return subpage | subusage;
  1510. }
  1511. if ((usage & HID_USAGE_PAGE) == WACOM_HID_UP_WACOMTOUCH) {
  1512. int subpage = (usage & 0xFF00) << 8;
  1513. int subusage = (usage & 0xFF);
  1514. if (subpage == HID_UP_UNDEFINED)
  1515. subpage = WACOM_HID_SP_DIGITIZER;
  1516. return subpage | subusage;
  1517. }
  1518. return usage;
  1519. }
  1520. static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
  1521. struct hid_field *field, __u8 type, __u16 code, int fuzz)
  1522. {
  1523. struct wacom *wacom = input_get_drvdata(input);
  1524. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1525. struct wacom_features *features = &wacom_wac->features;
  1526. int fmin = field->logical_minimum;
  1527. int fmax = field->logical_maximum;
  1528. unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
  1529. int resolution_code = code;
  1530. if (equivalent_usage == HID_DG_TWIST) {
  1531. resolution_code = ABS_RZ;
  1532. }
  1533. if (equivalent_usage == HID_GD_X) {
  1534. fmin += features->offset_left;
  1535. fmax -= features->offset_right;
  1536. }
  1537. if (equivalent_usage == HID_GD_Y) {
  1538. fmin += features->offset_top;
  1539. fmax -= features->offset_bottom;
  1540. }
  1541. usage->type = type;
  1542. usage->code = code;
  1543. set_bit(type, input->evbit);
  1544. switch (type) {
  1545. case EV_ABS:
  1546. input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
  1547. input_abs_set_res(input, code,
  1548. hidinput_calc_abs_res(field, resolution_code));
  1549. break;
  1550. case EV_KEY:
  1551. input_set_capability(input, EV_KEY, code);
  1552. break;
  1553. case EV_MSC:
  1554. input_set_capability(input, EV_MSC, code);
  1555. break;
  1556. case EV_SW:
  1557. input_set_capability(input, EV_SW, code);
  1558. break;
  1559. }
  1560. }
  1561. static void wacom_wac_battery_usage_mapping(struct hid_device *hdev,
  1562. struct hid_field *field, struct hid_usage *usage)
  1563. {
  1564. struct wacom *wacom = hid_get_drvdata(hdev);
  1565. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1566. struct wacom_features *features = &wacom_wac->features;
  1567. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1568. switch (equivalent_usage) {
  1569. case HID_DG_BATTERYSTRENGTH:
  1570. case WACOM_HID_WD_BATTERY_LEVEL:
  1571. case WACOM_HID_WD_BATTERY_CHARGING:
  1572. features->quirks |= WACOM_QUIRK_BATTERY;
  1573. break;
  1574. }
  1575. }
  1576. static void wacom_wac_battery_event(struct hid_device *hdev, struct hid_field *field,
  1577. struct hid_usage *usage, __s32 value)
  1578. {
  1579. struct wacom *wacom = hid_get_drvdata(hdev);
  1580. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1581. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1582. switch (equivalent_usage) {
  1583. case HID_DG_BATTERYSTRENGTH:
  1584. if (value == 0) {
  1585. wacom_wac->hid_data.bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
  1586. }
  1587. else {
  1588. value = value * 100 / (field->logical_maximum - field->logical_minimum);
  1589. wacom_wac->hid_data.battery_capacity = value;
  1590. wacom_wac->hid_data.bat_connected = 1;
  1591. wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
  1592. }
  1593. break;
  1594. case WACOM_HID_WD_BATTERY_LEVEL:
  1595. value = value * 100 / (field->logical_maximum - field->logical_minimum);
  1596. wacom_wac->hid_data.battery_capacity = value;
  1597. wacom_wac->hid_data.bat_connected = 1;
  1598. wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
  1599. break;
  1600. case WACOM_HID_WD_BATTERY_CHARGING:
  1601. wacom_wac->hid_data.bat_charging = value;
  1602. wacom_wac->hid_data.ps_connected = value;
  1603. wacom_wac->hid_data.bat_connected = 1;
  1604. wacom_wac->hid_data.bat_status = WACOM_POWER_SUPPLY_STATUS_AUTO;
  1605. break;
  1606. }
  1607. }
  1608. static void wacom_wac_battery_pre_report(struct hid_device *hdev,
  1609. struct hid_report *report)
  1610. {
  1611. return;
  1612. }
  1613. static void wacom_wac_battery_report(struct hid_device *hdev,
  1614. struct hid_report *report)
  1615. {
  1616. struct wacom *wacom = hid_get_drvdata(hdev);
  1617. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1618. struct wacom_features *features = &wacom_wac->features;
  1619. if (features->quirks & WACOM_QUIRK_BATTERY) {
  1620. int status = wacom_wac->hid_data.bat_status;
  1621. int capacity = wacom_wac->hid_data.battery_capacity;
  1622. bool charging = wacom_wac->hid_data.bat_charging;
  1623. bool connected = wacom_wac->hid_data.bat_connected;
  1624. bool powered = wacom_wac->hid_data.ps_connected;
  1625. wacom_notify_battery(wacom_wac, status, capacity, charging,
  1626. connected, powered);
  1627. }
  1628. }
  1629. static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
  1630. struct hid_field *field, struct hid_usage *usage)
  1631. {
  1632. struct wacom *wacom = hid_get_drvdata(hdev);
  1633. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1634. struct wacom_features *features = &wacom_wac->features;
  1635. struct input_dev *input = wacom_wac->pad_input;
  1636. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1637. switch (equivalent_usage) {
  1638. case WACOM_HID_WD_ACCELEROMETER_X:
  1639. __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
  1640. wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 0);
  1641. features->device_type |= WACOM_DEVICETYPE_PAD;
  1642. break;
  1643. case WACOM_HID_WD_ACCELEROMETER_Y:
  1644. __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
  1645. wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 0);
  1646. features->device_type |= WACOM_DEVICETYPE_PAD;
  1647. break;
  1648. case WACOM_HID_WD_ACCELEROMETER_Z:
  1649. __set_bit(INPUT_PROP_ACCELEROMETER, input->propbit);
  1650. wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
  1651. features->device_type |= WACOM_DEVICETYPE_PAD;
  1652. break;
  1653. case WACOM_HID_WD_BUTTONCENTER:
  1654. case WACOM_HID_WD_BUTTONHOME:
  1655. case WACOM_HID_WD_BUTTONUP:
  1656. case WACOM_HID_WD_BUTTONDOWN:
  1657. case WACOM_HID_WD_BUTTONLEFT:
  1658. case WACOM_HID_WD_BUTTONRIGHT:
  1659. wacom_map_usage(input, usage, field, EV_KEY,
  1660. wacom_numbered_button_to_key(features->numbered_buttons),
  1661. 0);
  1662. features->numbered_buttons++;
  1663. features->device_type |= WACOM_DEVICETYPE_PAD;
  1664. break;
  1665. case WACOM_HID_WD_TOUCHONOFF:
  1666. case WACOM_HID_WD_MUTE_DEVICE:
  1667. /*
  1668. * This usage, which is used to mute touch events, comes
  1669. * from the pad packet, but is reported on the touch
  1670. * interface. Because the touch interface may not have
  1671. * been created yet, we cannot call wacom_map_usage(). In
  1672. * order to process this usage when we receive it, we set
  1673. * the usage type and code directly.
  1674. */
  1675. wacom_wac->has_mute_touch_switch = true;
  1676. usage->type = EV_SW;
  1677. usage->code = SW_MUTE_DEVICE;
  1678. features->device_type |= WACOM_DEVICETYPE_PAD;
  1679. break;
  1680. case WACOM_HID_WD_TOUCHSTRIP:
  1681. wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
  1682. features->device_type |= WACOM_DEVICETYPE_PAD;
  1683. break;
  1684. case WACOM_HID_WD_TOUCHSTRIP2:
  1685. wacom_map_usage(input, usage, field, EV_ABS, ABS_RY, 0);
  1686. features->device_type |= WACOM_DEVICETYPE_PAD;
  1687. break;
  1688. case WACOM_HID_WD_TOUCHRING:
  1689. wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
  1690. features->device_type |= WACOM_DEVICETYPE_PAD;
  1691. break;
  1692. case WACOM_HID_WD_TOUCHRINGSTATUS:
  1693. /*
  1694. * Only set up type/code association. Completely mapping
  1695. * this usage may overwrite the axis resolution and range.
  1696. */
  1697. usage->type = EV_ABS;
  1698. usage->code = ABS_WHEEL;
  1699. set_bit(EV_ABS, input->evbit);
  1700. features->device_type |= WACOM_DEVICETYPE_PAD;
  1701. break;
  1702. case WACOM_HID_WD_BUTTONCONFIG:
  1703. wacom_map_usage(input, usage, field, EV_KEY, KEY_BUTTONCONFIG, 0);
  1704. features->device_type |= WACOM_DEVICETYPE_PAD;
  1705. break;
  1706. case WACOM_HID_WD_ONSCREEN_KEYBOARD:
  1707. wacom_map_usage(input, usage, field, EV_KEY, KEY_ONSCREEN_KEYBOARD, 0);
  1708. features->device_type |= WACOM_DEVICETYPE_PAD;
  1709. break;
  1710. case WACOM_HID_WD_CONTROLPANEL:
  1711. wacom_map_usage(input, usage, field, EV_KEY, KEY_CONTROLPANEL, 0);
  1712. features->device_type |= WACOM_DEVICETYPE_PAD;
  1713. break;
  1714. case WACOM_HID_WD_MODE_CHANGE:
  1715. /* do not overwrite previous data */
  1716. if (!wacom_wac->has_mode_change) {
  1717. wacom_wac->has_mode_change = true;
  1718. wacom_wac->is_direct_mode = true;
  1719. }
  1720. features->device_type |= WACOM_DEVICETYPE_PAD;
  1721. break;
  1722. }
  1723. switch (equivalent_usage & 0xfffffff0) {
  1724. case WACOM_HID_WD_EXPRESSKEY00:
  1725. wacom_map_usage(input, usage, field, EV_KEY,
  1726. wacom_numbered_button_to_key(features->numbered_buttons),
  1727. 0);
  1728. features->numbered_buttons++;
  1729. features->device_type |= WACOM_DEVICETYPE_PAD;
  1730. break;
  1731. }
  1732. }
  1733. static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field,
  1734. struct hid_usage *usage, __s32 value)
  1735. {
  1736. struct wacom *wacom = hid_get_drvdata(hdev);
  1737. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1738. struct input_dev *input = wacom_wac->pad_input;
  1739. struct wacom_features *features = &wacom_wac->features;
  1740. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1741. int i;
  1742. bool do_report = false;
  1743. /*
  1744. * Avoid reporting this event and setting inrange_state if this usage
  1745. * hasn't been mapped.
  1746. */
  1747. if (!usage->type && equivalent_usage != WACOM_HID_WD_MODE_CHANGE)
  1748. return;
  1749. if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY) {
  1750. if (usage->hid != WACOM_HID_WD_TOUCHRING)
  1751. wacom_wac->hid_data.inrange_state |= value;
  1752. }
  1753. switch (equivalent_usage) {
  1754. case WACOM_HID_WD_TOUCHRING:
  1755. /*
  1756. * Userspace expects touchrings to increase in value with
  1757. * clockwise gestures and have their zero point at the
  1758. * tablet's left. HID events "should" be clockwise-
  1759. * increasing and zero at top, though the MobileStudio
  1760. * Pro and 2nd-gen Intuos Pro don't do this...
  1761. */
  1762. if (hdev->vendor == 0x56a &&
  1763. (hdev->product == 0x34d || hdev->product == 0x34e || /* MobileStudio Pro */
  1764. hdev->product == 0x357 || hdev->product == 0x358)) { /* Intuos Pro 2 */
  1765. value = (field->logical_maximum - value);
  1766. if (hdev->product == 0x357 || hdev->product == 0x358)
  1767. value = wacom_offset_rotation(input, usage, value, 3, 16);
  1768. else if (hdev->product == 0x34d || hdev->product == 0x34e)
  1769. value = wacom_offset_rotation(input, usage, value, 1, 2);
  1770. }
  1771. else {
  1772. value = wacom_offset_rotation(input, usage, value, 1, 4);
  1773. }
  1774. do_report = true;
  1775. break;
  1776. case WACOM_HID_WD_TOUCHRINGSTATUS:
  1777. if (!value)
  1778. input_event(input, usage->type, usage->code, 0);
  1779. break;
  1780. case WACOM_HID_WD_MUTE_DEVICE:
  1781. case WACOM_HID_WD_TOUCHONOFF:
  1782. if (wacom_wac->shared->touch_input) {
  1783. bool *is_touch_on = &wacom_wac->shared->is_touch_on;
  1784. if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
  1785. *is_touch_on = !(*is_touch_on);
  1786. else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
  1787. *is_touch_on = value;
  1788. input_report_switch(wacom_wac->shared->touch_input,
  1789. SW_MUTE_DEVICE, !(*is_touch_on));
  1790. input_sync(wacom_wac->shared->touch_input);
  1791. }
  1792. break;
  1793. case WACOM_HID_WD_MODE_CHANGE:
  1794. if (wacom_wac->is_direct_mode != value) {
  1795. wacom_wac->is_direct_mode = value;
  1796. wacom_schedule_work(&wacom->wacom_wac, WACOM_WORKER_MODE_CHANGE);
  1797. }
  1798. break;
  1799. case WACOM_HID_WD_BUTTONCENTER:
  1800. for (i = 0; i < wacom->led.count; i++)
  1801. wacom_update_led(wacom, features->numbered_buttons,
  1802. value, i);
  1803. /* fall through*/
  1804. default:
  1805. do_report = true;
  1806. break;
  1807. }
  1808. if (do_report) {
  1809. input_event(input, usage->type, usage->code, value);
  1810. if (value)
  1811. wacom_wac->hid_data.pad_input_event_flag = true;
  1812. }
  1813. }
  1814. static void wacom_wac_pad_pre_report(struct hid_device *hdev,
  1815. struct hid_report *report)
  1816. {
  1817. struct wacom *wacom = hid_get_drvdata(hdev);
  1818. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1819. wacom_wac->hid_data.inrange_state = 0;
  1820. }
  1821. static void wacom_wac_pad_report(struct hid_device *hdev,
  1822. struct hid_report *report, struct hid_field *field)
  1823. {
  1824. struct wacom *wacom = hid_get_drvdata(hdev);
  1825. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1826. struct input_dev *input = wacom_wac->pad_input;
  1827. bool active = wacom_wac->hid_data.inrange_state != 0;
  1828. /* report prox for expresskey events */
  1829. if (wacom_wac->hid_data.pad_input_event_flag) {
  1830. input_event(input, EV_ABS, ABS_MISC, active ? PAD_DEVICE_ID : 0);
  1831. input_sync(input);
  1832. if (!active)
  1833. wacom_wac->hid_data.pad_input_event_flag = false;
  1834. }
  1835. }
  1836. static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
  1837. struct hid_field *field, struct hid_usage *usage)
  1838. {
  1839. struct wacom *wacom = hid_get_drvdata(hdev);
  1840. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1841. struct wacom_features *features = &wacom_wac->features;
  1842. struct input_dev *input = wacom_wac->pen_input;
  1843. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1844. switch (equivalent_usage) {
  1845. case HID_GD_X:
  1846. wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
  1847. break;
  1848. case HID_GD_Y:
  1849. wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
  1850. break;
  1851. case WACOM_HID_WD_DISTANCE:
  1852. case HID_GD_Z:
  1853. wacom_map_usage(input, usage, field, EV_ABS, ABS_DISTANCE, 0);
  1854. break;
  1855. case HID_DG_TIPPRESSURE:
  1856. wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
  1857. break;
  1858. case HID_DG_INRANGE:
  1859. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
  1860. break;
  1861. case HID_DG_INVERT:
  1862. wacom_map_usage(input, usage, field, EV_KEY,
  1863. BTN_TOOL_RUBBER, 0);
  1864. break;
  1865. case HID_DG_TILT_X:
  1866. wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_X, 0);
  1867. break;
  1868. case HID_DG_TILT_Y:
  1869. wacom_map_usage(input, usage, field, EV_ABS, ABS_TILT_Y, 0);
  1870. break;
  1871. case HID_DG_TWIST:
  1872. wacom_map_usage(input, usage, field, EV_ABS, ABS_Z, 0);
  1873. break;
  1874. case HID_DG_ERASER:
  1875. case HID_DG_TIPSWITCH:
  1876. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
  1877. break;
  1878. case HID_DG_BARRELSWITCH:
  1879. wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
  1880. break;
  1881. case HID_DG_BARRELSWITCH2:
  1882. wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
  1883. break;
  1884. case HID_DG_TOOLSERIALNUMBER:
  1885. features->quirks |= WACOM_QUIRK_TOOLSERIAL;
  1886. wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
  1887. /* Adjust AES usages to match modern convention */
  1888. if (usage->hid == WACOM_HID_WT_SERIALNUMBER && field->report_size == 16) {
  1889. if (field->index + 2 < field->report->maxfield) {
  1890. struct hid_field *a = field->report->field[field->index + 1];
  1891. struct hid_field *b = field->report->field[field->index + 2];
  1892. if (a->maxusage > 0 && a->usage[0].hid == HID_DG_TOOLSERIALNUMBER && a->report_size == 32 &&
  1893. b->maxusage > 0 && b->usage[0].hid == 0xFF000000 && b->report_size == 8) {
  1894. features->quirks |= WACOM_QUIRK_AESPEN;
  1895. usage->hid = WACOM_HID_WD_TOOLTYPE;
  1896. field->logical_minimum = S16_MIN;
  1897. field->logical_maximum = S16_MAX;
  1898. a->logical_minimum = S32_MIN;
  1899. a->logical_maximum = S32_MAX;
  1900. b->usage[0].hid = WACOM_HID_WD_SERIALHI;
  1901. b->logical_minimum = 0;
  1902. b->logical_maximum = U8_MAX;
  1903. }
  1904. }
  1905. }
  1906. break;
  1907. case WACOM_HID_WD_SENSE:
  1908. features->quirks |= WACOM_QUIRK_SENSE;
  1909. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
  1910. break;
  1911. case WACOM_HID_WD_SERIALHI:
  1912. wacom_map_usage(input, usage, field, EV_ABS, ABS_MISC, 0);
  1913. if (!(features->quirks & WACOM_QUIRK_AESPEN)) {
  1914. set_bit(EV_KEY, input->evbit);
  1915. input_set_capability(input, EV_KEY, BTN_TOOL_PEN);
  1916. input_set_capability(input, EV_KEY, BTN_TOOL_RUBBER);
  1917. input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
  1918. input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
  1919. input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
  1920. if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
  1921. input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
  1922. input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
  1923. }
  1924. }
  1925. break;
  1926. case WACOM_HID_WD_FINGERWHEEL:
  1927. wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
  1928. break;
  1929. }
  1930. }
  1931. static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
  1932. struct hid_usage *usage, __s32 value)
  1933. {
  1934. struct wacom *wacom = hid_get_drvdata(hdev);
  1935. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  1936. struct wacom_features *features = &wacom_wac->features;
  1937. struct input_dev *input = wacom_wac->pen_input;
  1938. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  1939. if (wacom_wac->is_invalid_bt_frame)
  1940. return;
  1941. switch (equivalent_usage) {
  1942. case HID_GD_Z:
  1943. /*
  1944. * HID_GD_Z "should increase as the control's position is
  1945. * moved from high to low", while ABS_DISTANCE instead
  1946. * increases in value as the tool moves from low to high.
  1947. */
  1948. value = field->logical_maximum - value;
  1949. break;
  1950. case HID_DG_INRANGE:
  1951. wacom_wac->hid_data.inrange_state = value;
  1952. if (!(features->quirks & WACOM_QUIRK_SENSE))
  1953. wacom_wac->hid_data.sense_state = value;
  1954. return;
  1955. case HID_DG_INVERT:
  1956. wacom_wac->hid_data.invert_state = value;
  1957. return;
  1958. case HID_DG_ERASER:
  1959. case HID_DG_TIPSWITCH:
  1960. wacom_wac->hid_data.tipswitch |= value;
  1961. return;
  1962. case HID_DG_BARRELSWITCH:
  1963. wacom_wac->hid_data.barrelswitch = value;
  1964. return;
  1965. case HID_DG_BARRELSWITCH2:
  1966. wacom_wac->hid_data.barrelswitch2 = value;
  1967. return;
  1968. case HID_DG_TOOLSERIALNUMBER:
  1969. if (value) {
  1970. wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
  1971. wacom_wac->serial[0] |= wacom_s32tou(value, field->report_size);
  1972. }
  1973. return;
  1974. case HID_DG_TWIST:
  1975. /*
  1976. * Userspace expects pen twist to have its zero point when
  1977. * the buttons/finger is on the tablet's left. HID values
  1978. * are zero when buttons are toward the top.
  1979. */
  1980. value = wacom_offset_rotation(input, usage, value, 1, 4);
  1981. break;
  1982. case WACOM_HID_WD_SENSE:
  1983. wacom_wac->hid_data.sense_state = value;
  1984. return;
  1985. case WACOM_HID_WD_SERIALHI:
  1986. if (value) {
  1987. __u32 raw_value = wacom_s32tou(value, field->report_size);
  1988. wacom_wac->serial[0] = (wacom_wac->serial[0] & 0xFFFFFFFF);
  1989. wacom_wac->serial[0] |= ((__u64)raw_value) << 32;
  1990. /*
  1991. * Non-USI EMR devices may contain additional tool type
  1992. * information here. See WACOM_HID_WD_TOOLTYPE case for
  1993. * more details.
  1994. */
  1995. if (value >> 20 == 1) {
  1996. wacom_wac->id[0] |= raw_value & 0xFFFFF;
  1997. }
  1998. }
  1999. return;
  2000. case WACOM_HID_WD_TOOLTYPE:
  2001. /*
  2002. * Some devices (MobileStudio Pro, and possibly later
  2003. * devices as well) do not return the complete tool
  2004. * type in their WACOM_HID_WD_TOOLTYPE usage. Use a
  2005. * bitwise OR so the complete value can be built
  2006. * up over time :(
  2007. */
  2008. wacom_wac->id[0] |= wacom_s32tou(value, field->report_size);
  2009. return;
  2010. case WACOM_HID_WD_OFFSETLEFT:
  2011. if (features->offset_left && value != features->offset_left)
  2012. hid_warn(hdev, "%s: overriding existing left offset "
  2013. "%d -> %d\n", __func__, value,
  2014. features->offset_left);
  2015. features->offset_left = value;
  2016. return;
  2017. case WACOM_HID_WD_OFFSETRIGHT:
  2018. if (features->offset_right && value != features->offset_right)
  2019. hid_warn(hdev, "%s: overriding existing right offset "
  2020. "%d -> %d\n", __func__, value,
  2021. features->offset_right);
  2022. features->offset_right = value;
  2023. return;
  2024. case WACOM_HID_WD_OFFSETTOP:
  2025. if (features->offset_top && value != features->offset_top)
  2026. hid_warn(hdev, "%s: overriding existing top offset "
  2027. "%d -> %d\n", __func__, value,
  2028. features->offset_top);
  2029. features->offset_top = value;
  2030. return;
  2031. case WACOM_HID_WD_OFFSETBOTTOM:
  2032. if (features->offset_bottom && value != features->offset_bottom)
  2033. hid_warn(hdev, "%s: overriding existing bottom offset "
  2034. "%d -> %d\n", __func__, value,
  2035. features->offset_bottom);
  2036. features->offset_bottom = value;
  2037. return;
  2038. case WACOM_HID_WD_REPORT_VALID:
  2039. wacom_wac->is_invalid_bt_frame = !value;
  2040. return;
  2041. }
  2042. /* send pen events only when touch is up or forced out
  2043. * or touch arbitration is off
  2044. */
  2045. if (!usage->type || delay_pen_events(wacom_wac))
  2046. return;
  2047. /* send pen events only when the pen is in range */
  2048. if (wacom_wac->hid_data.inrange_state)
  2049. input_event(input, usage->type, usage->code, value);
  2050. else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state)
  2051. input_event(input, usage->type, usage->code, 0);
  2052. }
  2053. static void wacom_wac_pen_pre_report(struct hid_device *hdev,
  2054. struct hid_report *report)
  2055. {
  2056. struct wacom *wacom = hid_get_drvdata(hdev);
  2057. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2058. wacom_wac->is_invalid_bt_frame = false;
  2059. return;
  2060. }
  2061. static void wacom_wac_pen_report(struct hid_device *hdev,
  2062. struct hid_report *report)
  2063. {
  2064. struct wacom *wacom = hid_get_drvdata(hdev);
  2065. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2066. struct input_dev *input = wacom_wac->pen_input;
  2067. bool range = wacom_wac->hid_data.inrange_state;
  2068. bool sense = wacom_wac->hid_data.sense_state;
  2069. if (wacom_wac->is_invalid_bt_frame)
  2070. return;
  2071. if (!wacom_wac->tool[0] && range) { /* first in range */
  2072. /* Going into range select tool */
  2073. if (wacom_wac->hid_data.invert_state)
  2074. wacom_wac->tool[0] = BTN_TOOL_RUBBER;
  2075. else if (wacom_wac->id[0])
  2076. wacom_wac->tool[0] = wacom_intuos_get_tool_type(wacom_wac->id[0]);
  2077. else
  2078. wacom_wac->tool[0] = BTN_TOOL_PEN;
  2079. }
  2080. /* keep pen state for touch events */
  2081. wacom_wac->shared->stylus_in_proximity = sense;
  2082. if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) {
  2083. int id = wacom_wac->id[0];
  2084. int sw_state = wacom_wac->hid_data.barrelswitch |
  2085. (wacom_wac->hid_data.barrelswitch2 << 1);
  2086. input_report_key(input, BTN_STYLUS, sw_state == 1);
  2087. input_report_key(input, BTN_STYLUS2, sw_state == 2);
  2088. input_report_key(input, BTN_STYLUS3, sw_state == 3);
  2089. /*
  2090. * Non-USI EMR tools should have their IDs mangled to
  2091. * match the legacy behavior of wacom_intuos_general
  2092. */
  2093. if (wacom_wac->serial[0] >> 52 == 1)
  2094. id = wacom_intuos_id_mangle(id);
  2095. /*
  2096. * To ensure compatibility with xf86-input-wacom, we should
  2097. * report the BTN_TOOL_* event prior to the ABS_MISC or
  2098. * MSC_SERIAL events.
  2099. */
  2100. input_report_key(input, BTN_TOUCH,
  2101. wacom_wac->hid_data.tipswitch);
  2102. input_report_key(input, wacom_wac->tool[0], sense);
  2103. if (wacom_wac->serial[0]) {
  2104. input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]);
  2105. input_report_abs(input, ABS_MISC, sense ? id : 0);
  2106. }
  2107. wacom_wac->hid_data.tipswitch = false;
  2108. input_sync(input);
  2109. }
  2110. if (!sense) {
  2111. wacom_wac->tool[0] = 0;
  2112. wacom_wac->id[0] = 0;
  2113. wacom_wac->serial[0] = 0;
  2114. }
  2115. }
  2116. static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
  2117. struct hid_field *field, struct hid_usage *usage)
  2118. {
  2119. struct wacom *wacom = hid_get_drvdata(hdev);
  2120. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2121. struct input_dev *input = wacom_wac->touch_input;
  2122. unsigned touch_max = wacom_wac->features.touch_max;
  2123. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  2124. switch (equivalent_usage) {
  2125. case HID_GD_X:
  2126. if (touch_max == 1)
  2127. wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
  2128. else
  2129. wacom_map_usage(input, usage, field, EV_ABS,
  2130. ABS_MT_POSITION_X, 4);
  2131. break;
  2132. case HID_GD_Y:
  2133. if (touch_max == 1)
  2134. wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
  2135. else
  2136. wacom_map_usage(input, usage, field, EV_ABS,
  2137. ABS_MT_POSITION_Y, 4);
  2138. break;
  2139. case HID_DG_WIDTH:
  2140. case HID_DG_HEIGHT:
  2141. wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
  2142. wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
  2143. input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  2144. break;
  2145. case HID_DG_TIPSWITCH:
  2146. wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
  2147. break;
  2148. case HID_DG_CONTACTCOUNT:
  2149. wacom_wac->hid_data.cc_report = field->report->id;
  2150. wacom_wac->hid_data.cc_index = field->index;
  2151. wacom_wac->hid_data.cc_value_index = usage->usage_index;
  2152. break;
  2153. case HID_DG_CONTACTID:
  2154. if ((field->logical_maximum - field->logical_minimum) < touch_max) {
  2155. /*
  2156. * The HID descriptor for G11 sensors leaves logical
  2157. * maximum set to '1' despite it being a multitouch
  2158. * device. Override to a sensible number.
  2159. */
  2160. field->logical_maximum = 255;
  2161. }
  2162. break;
  2163. }
  2164. }
  2165. static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
  2166. struct input_dev *input)
  2167. {
  2168. struct hid_data *hid_data = &wacom_wac->hid_data;
  2169. bool mt = wacom_wac->features.touch_max > 1;
  2170. bool prox = hid_data->tipswitch &&
  2171. report_touch_events(wacom_wac);
  2172. if (wacom_wac->shared->has_mute_touch_switch &&
  2173. !wacom_wac->shared->is_touch_on) {
  2174. if (!wacom_wac->shared->touch_down)
  2175. return;
  2176. prox = false;
  2177. }
  2178. wacom_wac->hid_data.num_received++;
  2179. if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
  2180. return;
  2181. if (mt) {
  2182. int slot;
  2183. slot = input_mt_get_slot_by_key(input, hid_data->id);
  2184. input_mt_slot(input, slot);
  2185. input_mt_report_slot_state(input, MT_TOOL_FINGER, prox);
  2186. }
  2187. else {
  2188. input_report_key(input, BTN_TOUCH, prox);
  2189. }
  2190. if (prox) {
  2191. input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X,
  2192. hid_data->x);
  2193. input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
  2194. hid_data->y);
  2195. if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
  2196. input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
  2197. input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
  2198. if (hid_data->width != hid_data->height)
  2199. input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
  2200. }
  2201. }
  2202. }
  2203. static void wacom_wac_finger_event(struct hid_device *hdev,
  2204. struct hid_field *field, struct hid_usage *usage, __s32 value)
  2205. {
  2206. struct wacom *wacom = hid_get_drvdata(hdev);
  2207. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2208. unsigned equivalent_usage = wacom_equivalent_usage(usage->hid);
  2209. struct wacom_features *features = &wacom->wacom_wac.features;
  2210. switch (equivalent_usage) {
  2211. case HID_GD_X:
  2212. wacom_wac->hid_data.x = value;
  2213. break;
  2214. case HID_GD_Y:
  2215. wacom_wac->hid_data.y = value;
  2216. break;
  2217. case HID_DG_WIDTH:
  2218. wacom_wac->hid_data.width = value;
  2219. break;
  2220. case HID_DG_HEIGHT:
  2221. wacom_wac->hid_data.height = value;
  2222. break;
  2223. case HID_DG_CONTACTID:
  2224. wacom_wac->hid_data.id = value;
  2225. break;
  2226. case HID_DG_TIPSWITCH:
  2227. wacom_wac->hid_data.tipswitch = value;
  2228. break;
  2229. case HID_DG_CONTACTMAX:
  2230. if (!features->touch_max) {
  2231. features->touch_max = value;
  2232. } else {
  2233. hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
  2234. "%d -> %d\n", __func__, features->touch_max, value);
  2235. }
  2236. return;
  2237. }
  2238. if (usage->usage_index + 1 == field->report_count) {
  2239. if (equivalent_usage == wacom_wac->hid_data.last_slot_field)
  2240. wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
  2241. }
  2242. }
  2243. static void wacom_wac_finger_pre_report(struct hid_device *hdev,
  2244. struct hid_report *report)
  2245. {
  2246. struct wacom *wacom = hid_get_drvdata(hdev);
  2247. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2248. struct hid_data* hid_data = &wacom_wac->hid_data;
  2249. int i;
  2250. for (i = 0; i < report->maxfield; i++) {
  2251. struct hid_field *field = report->field[i];
  2252. int j;
  2253. for (j = 0; j < field->maxusage; j++) {
  2254. struct hid_usage *usage = &field->usage[j];
  2255. unsigned int equivalent_usage =
  2256. wacom_equivalent_usage(usage->hid);
  2257. switch (equivalent_usage) {
  2258. case HID_GD_X:
  2259. case HID_GD_Y:
  2260. case HID_DG_WIDTH:
  2261. case HID_DG_HEIGHT:
  2262. case HID_DG_CONTACTID:
  2263. case HID_DG_INRANGE:
  2264. case HID_DG_INVERT:
  2265. case HID_DG_TIPSWITCH:
  2266. hid_data->last_slot_field = equivalent_usage;
  2267. break;
  2268. case HID_DG_CONTACTCOUNT:
  2269. hid_data->cc_report = report->id;
  2270. hid_data->cc_index = i;
  2271. hid_data->cc_value_index = j;
  2272. break;
  2273. }
  2274. }
  2275. }
  2276. if (hid_data->cc_report != 0 &&
  2277. hid_data->cc_index >= 0) {
  2278. struct hid_field *field = report->field[hid_data->cc_index];
  2279. int value = field->value[hid_data->cc_value_index];
  2280. if (value)
  2281. hid_data->num_expected = value;
  2282. }
  2283. else {
  2284. hid_data->num_expected = wacom_wac->features.touch_max;
  2285. }
  2286. }
  2287. static void wacom_wac_finger_report(struct hid_device *hdev,
  2288. struct hid_report *report)
  2289. {
  2290. struct wacom *wacom = hid_get_drvdata(hdev);
  2291. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2292. struct input_dev *input = wacom_wac->touch_input;
  2293. unsigned touch_max = wacom_wac->features.touch_max;
  2294. /* If more packets of data are expected, give us a chance to
  2295. * process them rather than immediately syncing a partial
  2296. * update.
  2297. */
  2298. if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
  2299. return;
  2300. if (touch_max > 1)
  2301. input_mt_sync_frame(input);
  2302. input_sync(input);
  2303. wacom_wac->hid_data.num_received = 0;
  2304. /* keep touch state for pen event */
  2305. wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
  2306. }
  2307. void wacom_wac_usage_mapping(struct hid_device *hdev,
  2308. struct hid_field *field, struct hid_usage *usage)
  2309. {
  2310. struct wacom *wacom = hid_get_drvdata(hdev);
  2311. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2312. struct wacom_features *features = &wacom_wac->features;
  2313. if (WACOM_DIRECT_DEVICE(field))
  2314. features->device_type |= WACOM_DEVICETYPE_DIRECT;
  2315. /* usage tests must precede field tests */
  2316. if (WACOM_BATTERY_USAGE(usage))
  2317. wacom_wac_battery_usage_mapping(hdev, field, usage);
  2318. else if (WACOM_PAD_FIELD(field))
  2319. wacom_wac_pad_usage_mapping(hdev, field, usage);
  2320. else if (WACOM_PEN_FIELD(field))
  2321. wacom_wac_pen_usage_mapping(hdev, field, usage);
  2322. else if (WACOM_FINGER_FIELD(field))
  2323. wacom_wac_finger_usage_mapping(hdev, field, usage);
  2324. }
  2325. void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
  2326. struct hid_usage *usage, __s32 value)
  2327. {
  2328. struct wacom *wacom = hid_get_drvdata(hdev);
  2329. if (wacom->wacom_wac.features.type != HID_GENERIC)
  2330. return;
  2331. if (value > field->logical_maximum || value < field->logical_minimum)
  2332. return;
  2333. /* usage tests must precede field tests */
  2334. if (WACOM_BATTERY_USAGE(usage))
  2335. wacom_wac_battery_event(hdev, field, usage, value);
  2336. else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
  2337. wacom_wac_pad_event(hdev, field, usage, value);
  2338. else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
  2339. wacom_wac_pen_event(hdev, field, usage, value);
  2340. else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
  2341. wacom_wac_finger_event(hdev, field, usage, value);
  2342. }
  2343. static void wacom_report_events(struct hid_device *hdev,
  2344. struct hid_report *report, int collection_index,
  2345. int field_index)
  2346. {
  2347. int r;
  2348. for (r = field_index; r < report->maxfield; r++) {
  2349. struct hid_field *field;
  2350. unsigned count, n;
  2351. field = report->field[r];
  2352. count = field->report_count;
  2353. if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
  2354. continue;
  2355. for (n = 0 ; n < count; n++) {
  2356. if (field->usage[n].collection_index == collection_index)
  2357. wacom_wac_event(hdev, field, &field->usage[n],
  2358. field->value[n]);
  2359. else
  2360. return;
  2361. }
  2362. }
  2363. }
  2364. static int wacom_wac_collection(struct hid_device *hdev, struct hid_report *report,
  2365. int collection_index, struct hid_field *field,
  2366. int field_index)
  2367. {
  2368. struct wacom *wacom = hid_get_drvdata(hdev);
  2369. wacom_report_events(hdev, report, collection_index, field_index);
  2370. /*
  2371. * Non-input reports may be sent prior to the device being
  2372. * completely initialized. Since only their events need
  2373. * to be processed, exit after 'wacom_report_events' has
  2374. * been called to prevent potential crashes in the report-
  2375. * processing functions.
  2376. */
  2377. if (report->type != HID_INPUT_REPORT)
  2378. return -1;
  2379. if (WACOM_PAD_FIELD(field))
  2380. return 0;
  2381. else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
  2382. wacom_wac_pen_report(hdev, report);
  2383. else if (WACOM_FINGER_FIELD(field) && wacom->wacom_wac.touch_input)
  2384. wacom_wac_finger_report(hdev, report);
  2385. return 0;
  2386. }
  2387. void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
  2388. {
  2389. struct wacom *wacom = hid_get_drvdata(hdev);
  2390. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2391. struct hid_field *field;
  2392. bool pad_in_hid_field = false, pen_in_hid_field = false,
  2393. finger_in_hid_field = false, true_pad = false;
  2394. int r;
  2395. int prev_collection = -1;
  2396. if (wacom_wac->features.type != HID_GENERIC)
  2397. return;
  2398. for (r = 0; r < report->maxfield; r++) {
  2399. field = report->field[r];
  2400. if (WACOM_PAD_FIELD(field))
  2401. pad_in_hid_field = true;
  2402. if (WACOM_PEN_FIELD(field))
  2403. pen_in_hid_field = true;
  2404. if (WACOM_FINGER_FIELD(field))
  2405. finger_in_hid_field = true;
  2406. if (wacom_equivalent_usage(field->physical) == HID_DG_TABLETFUNCTIONKEY)
  2407. true_pad = true;
  2408. }
  2409. wacom_wac_battery_pre_report(hdev, report);
  2410. if (pad_in_hid_field && wacom->wacom_wac.pad_input)
  2411. wacom_wac_pad_pre_report(hdev, report);
  2412. if (pen_in_hid_field && wacom->wacom_wac.pen_input)
  2413. wacom_wac_pen_pre_report(hdev, report);
  2414. if (finger_in_hid_field && wacom->wacom_wac.touch_input)
  2415. wacom_wac_finger_pre_report(hdev, report);
  2416. for (r = 0; r < report->maxfield; r++) {
  2417. field = report->field[r];
  2418. if (field->usage[0].collection_index != prev_collection) {
  2419. if (wacom_wac_collection(hdev, report,
  2420. field->usage[0].collection_index, field, r) < 0)
  2421. return;
  2422. prev_collection = field->usage[0].collection_index;
  2423. }
  2424. }
  2425. wacom_wac_battery_report(hdev, report);
  2426. if (true_pad && wacom->wacom_wac.pad_input)
  2427. wacom_wac_pad_report(hdev, report, field);
  2428. }
  2429. static int wacom_bpt_touch(struct wacom_wac *wacom)
  2430. {
  2431. struct wacom_features *features = &wacom->features;
  2432. struct input_dev *input = wacom->touch_input;
  2433. struct input_dev *pad_input = wacom->pad_input;
  2434. unsigned char *data = wacom->data;
  2435. int i;
  2436. if (data[0] != 0x02)
  2437. return 0;
  2438. for (i = 0; i < 2; i++) {
  2439. int offset = (data[1] & 0x80) ? (8 * i) : (9 * i);
  2440. bool touch = report_touch_events(wacom)
  2441. && (data[offset + 3] & 0x80);
  2442. input_mt_slot(input, i);
  2443. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  2444. if (touch) {
  2445. int x = get_unaligned_be16(&data[offset + 3]) & 0x7ff;
  2446. int y = get_unaligned_be16(&data[offset + 5]) & 0x7ff;
  2447. if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
  2448. x <<= 5;
  2449. y <<= 5;
  2450. }
  2451. input_report_abs(input, ABS_MT_POSITION_X, x);
  2452. input_report_abs(input, ABS_MT_POSITION_Y, y);
  2453. }
  2454. }
  2455. input_mt_sync_frame(input);
  2456. input_report_key(pad_input, BTN_LEFT, (data[1] & 0x08) != 0);
  2457. input_report_key(pad_input, BTN_FORWARD, (data[1] & 0x04) != 0);
  2458. input_report_key(pad_input, BTN_BACK, (data[1] & 0x02) != 0);
  2459. input_report_key(pad_input, BTN_RIGHT, (data[1] & 0x01) != 0);
  2460. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  2461. return 1;
  2462. }
  2463. static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
  2464. {
  2465. struct wacom_features *features = &wacom->features;
  2466. struct input_dev *input = wacom->touch_input;
  2467. bool touch = data[1] & 0x80;
  2468. int slot = input_mt_get_slot_by_key(input, data[0]);
  2469. if (slot < 0)
  2470. return;
  2471. touch = touch && report_touch_events(wacom);
  2472. input_mt_slot(input, slot);
  2473. input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
  2474. if (touch) {
  2475. int x = (data[2] << 4) | (data[4] >> 4);
  2476. int y = (data[3] << 4) | (data[4] & 0x0f);
  2477. int width, height;
  2478. if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
  2479. width = data[5] * 100;
  2480. height = data[6] * 100;
  2481. } else {
  2482. /*
  2483. * "a" is a scaled-down area which we assume is
  2484. * roughly circular and which can be described as:
  2485. * a=(pi*r^2)/C.
  2486. */
  2487. int a = data[5];
  2488. int x_res = input_abs_get_res(input, ABS_MT_POSITION_X);
  2489. int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y);
  2490. width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
  2491. height = width * y_res / x_res;
  2492. }
  2493. input_report_abs(input, ABS_MT_POSITION_X, x);
  2494. input_report_abs(input, ABS_MT_POSITION_Y, y);
  2495. input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
  2496. input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
  2497. }
  2498. }
  2499. static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
  2500. {
  2501. struct input_dev *input = wacom->pad_input;
  2502. struct wacom_features *features = &wacom->features;
  2503. if (features->type == INTUOSHT || features->type == INTUOSHT2) {
  2504. input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
  2505. input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
  2506. } else {
  2507. input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
  2508. input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
  2509. }
  2510. input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
  2511. input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
  2512. }
  2513. static int wacom_bpt3_touch(struct wacom_wac *wacom)
  2514. {
  2515. unsigned char *data = wacom->data;
  2516. int count = data[1] & 0x07;
  2517. int touch_changed = 0, i;
  2518. if (data[0] != 0x02)
  2519. return 0;
  2520. /* data has up to 7 fixed sized 8-byte messages starting at data[2] */
  2521. for (i = 0; i < count; i++) {
  2522. int offset = (8 * i) + 2;
  2523. int msg_id = data[offset];
  2524. if (msg_id >= 2 && msg_id <= 17) {
  2525. wacom_bpt3_touch_msg(wacom, data + offset);
  2526. touch_changed++;
  2527. } else if (msg_id == 128)
  2528. wacom_bpt3_button_msg(wacom, data + offset);
  2529. }
  2530. /* only update touch if we actually have a touchpad and touch data changed */
  2531. if (wacom->touch_input && touch_changed) {
  2532. input_mt_sync_frame(wacom->touch_input);
  2533. wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
  2534. }
  2535. return 1;
  2536. }
  2537. static int wacom_bpt_pen(struct wacom_wac *wacom)
  2538. {
  2539. struct wacom_features *features = &wacom->features;
  2540. struct input_dev *input = wacom->pen_input;
  2541. unsigned char *data = wacom->data;
  2542. int x = 0, y = 0, p = 0, d = 0;
  2543. bool pen = false, btn1 = false, btn2 = false;
  2544. bool range, prox, rdy;
  2545. if (data[0] != WACOM_REPORT_PENABLED)
  2546. return 0;
  2547. range = (data[1] & 0x80) == 0x80;
  2548. prox = (data[1] & 0x40) == 0x40;
  2549. rdy = (data[1] & 0x20) == 0x20;
  2550. wacom->shared->stylus_in_proximity = range;
  2551. if (delay_pen_events(wacom))
  2552. return 0;
  2553. if (rdy) {
  2554. p = le16_to_cpup((__le16 *)&data[6]);
  2555. pen = data[1] & 0x01;
  2556. btn1 = data[1] & 0x02;
  2557. btn2 = data[1] & 0x04;
  2558. }
  2559. if (prox) {
  2560. x = le16_to_cpup((__le16 *)&data[2]);
  2561. y = le16_to_cpup((__le16 *)&data[4]);
  2562. if (data[1] & 0x08) {
  2563. wacom->tool[0] = BTN_TOOL_RUBBER;
  2564. wacom->id[0] = ERASER_DEVICE_ID;
  2565. } else {
  2566. wacom->tool[0] = BTN_TOOL_PEN;
  2567. wacom->id[0] = STYLUS_DEVICE_ID;
  2568. }
  2569. wacom->reporting_data = true;
  2570. }
  2571. if (range) {
  2572. /*
  2573. * Convert distance from out prox to distance from tablet.
  2574. * distance will be greater than distance_max once
  2575. * touching and applying pressure; do not report negative
  2576. * distance.
  2577. */
  2578. if (data[8] <= features->distance_max)
  2579. d = features->distance_max - data[8];
  2580. } else {
  2581. wacom->id[0] = 0;
  2582. }
  2583. if (wacom->reporting_data) {
  2584. input_report_key(input, BTN_TOUCH, pen);
  2585. input_report_key(input, BTN_STYLUS, btn1);
  2586. input_report_key(input, BTN_STYLUS2, btn2);
  2587. if (prox || !range) {
  2588. input_report_abs(input, ABS_X, x);
  2589. input_report_abs(input, ABS_Y, y);
  2590. }
  2591. input_report_abs(input, ABS_PRESSURE, p);
  2592. input_report_abs(input, ABS_DISTANCE, d);
  2593. input_report_key(input, wacom->tool[0], range); /* PEN or RUBBER */
  2594. input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
  2595. }
  2596. if (!range) {
  2597. wacom->reporting_data = false;
  2598. }
  2599. return 1;
  2600. }
  2601. static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
  2602. {
  2603. struct wacom_features *features = &wacom->features;
  2604. if ((features->type == INTUOSHT2) &&
  2605. (features->device_type & WACOM_DEVICETYPE_PEN))
  2606. return wacom_intuos_irq(wacom);
  2607. else if (len == WACOM_PKGLEN_BBTOUCH)
  2608. return wacom_bpt_touch(wacom);
  2609. else if (len == WACOM_PKGLEN_BBTOUCH3)
  2610. return wacom_bpt3_touch(wacom);
  2611. else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN)
  2612. return wacom_bpt_pen(wacom);
  2613. return 0;
  2614. }
  2615. static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
  2616. unsigned char *data)
  2617. {
  2618. unsigned char prefix;
  2619. /*
  2620. * We need to reroute the event from the debug interface to the
  2621. * pen interface.
  2622. * We need to add the report ID to the actual pen report, so we
  2623. * temporary overwrite the first byte to prevent having to kzalloc/kfree
  2624. * and memcpy the report.
  2625. */
  2626. prefix = data[0];
  2627. data[0] = WACOM_REPORT_BPAD_PEN;
  2628. /*
  2629. * actually reroute the event.
  2630. * No need to check if wacom->shared->pen is valid, hid_input_report()
  2631. * will check for us.
  2632. */
  2633. hid_input_report(wacom->shared->pen, HID_INPUT_REPORT, data,
  2634. WACOM_PKGLEN_PENABLED, 1);
  2635. data[0] = prefix;
  2636. }
  2637. static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
  2638. unsigned char *data)
  2639. {
  2640. struct input_dev *input = wacom->touch_input;
  2641. unsigned char *finger_data, prefix;
  2642. unsigned id;
  2643. int x, y;
  2644. bool valid;
  2645. prefix = data[0];
  2646. for (id = 0; id < wacom->features.touch_max; id++) {
  2647. valid = !!(prefix & BIT(id)) &&
  2648. report_touch_events(wacom);
  2649. input_mt_slot(input, id);
  2650. input_mt_report_slot_state(input, MT_TOOL_FINGER, valid);
  2651. if (!valid)
  2652. continue;
  2653. finger_data = data + 1 + id * 3;
  2654. x = finger_data[0] | ((finger_data[1] & 0x0f) << 8);
  2655. y = (finger_data[2] << 4) | (finger_data[1] >> 4);
  2656. input_report_abs(input, ABS_MT_POSITION_X, x);
  2657. input_report_abs(input, ABS_MT_POSITION_Y, y);
  2658. }
  2659. input_mt_sync_frame(input);
  2660. input_report_key(input, BTN_LEFT, prefix & 0x40);
  2661. input_report_key(input, BTN_RIGHT, prefix & 0x80);
  2662. /* keep touch state for pen event */
  2663. wacom->shared->touch_down = !!prefix && report_touch_events(wacom);
  2664. return 1;
  2665. }
  2666. static int wacom_bamboo_pad_irq(struct wacom_wac *wacom, size_t len)
  2667. {
  2668. unsigned char *data = wacom->data;
  2669. if (!((len == WACOM_PKGLEN_BPAD_TOUCH) ||
  2670. (len == WACOM_PKGLEN_BPAD_TOUCH_USB)) ||
  2671. (data[0] != WACOM_REPORT_BPAD_TOUCH))
  2672. return 0;
  2673. if (data[1] & 0x01)
  2674. wacom_bamboo_pad_pen_event(wacom, &data[1]);
  2675. if (data[1] & 0x02)
  2676. return wacom_bamboo_pad_touch_event(wacom, &data[9]);
  2677. return 0;
  2678. }
  2679. static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
  2680. {
  2681. unsigned char *data = wacom->data;
  2682. int connected;
  2683. if (len != WACOM_PKGLEN_WIRELESS || data[0] != WACOM_REPORT_WL)
  2684. return 0;
  2685. connected = data[1] & 0x01;
  2686. if (connected) {
  2687. int pid, battery, charging;
  2688. if ((wacom->shared->type == INTUOSHT ||
  2689. wacom->shared->type == INTUOSHT2) &&
  2690. wacom->shared->touch_input &&
  2691. wacom->shared->touch_max) {
  2692. input_report_switch(wacom->shared->touch_input,
  2693. SW_MUTE_DEVICE, data[5] & 0x40);
  2694. input_sync(wacom->shared->touch_input);
  2695. }
  2696. pid = get_unaligned_be16(&data[6]);
  2697. battery = (data[5] & 0x3f) * 100 / 31;
  2698. charging = !!(data[5] & 0x80);
  2699. if (wacom->pid != pid) {
  2700. wacom->pid = pid;
  2701. wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
  2702. }
  2703. wacom_notify_battery(wacom, WACOM_POWER_SUPPLY_STATUS_AUTO,
  2704. battery, charging, 1, 0);
  2705. } else if (wacom->pid != 0) {
  2706. /* disconnected while previously connected */
  2707. wacom->pid = 0;
  2708. wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
  2709. wacom_notify_battery(wacom, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
  2710. }
  2711. return 0;
  2712. }
  2713. static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
  2714. {
  2715. struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
  2716. struct wacom_features *features = &wacom_wac->features;
  2717. unsigned char *data = wacom_wac->data;
  2718. if (data[0] != WACOM_REPORT_USB)
  2719. return 0;
  2720. if ((features->type == INTUOSHT ||
  2721. features->type == INTUOSHT2) &&
  2722. wacom_wac->shared->touch_input &&
  2723. features->touch_max) {
  2724. input_report_switch(wacom_wac->shared->touch_input,
  2725. SW_MUTE_DEVICE, data[8] & 0x40);
  2726. input_sync(wacom_wac->shared->touch_input);
  2727. }
  2728. if (data[9] & 0x02) { /* wireless module is attached */
  2729. int battery = (data[8] & 0x3f) * 100 / 31;
  2730. bool charging = !!(data[8] & 0x80);
  2731. wacom_notify_battery(wacom_wac, WACOM_POWER_SUPPLY_STATUS_AUTO,
  2732. battery, charging, battery || charging, 1);
  2733. if (!wacom->battery.battery &&
  2734. !(features->quirks & WACOM_QUIRK_BATTERY)) {
  2735. features->quirks |= WACOM_QUIRK_BATTERY;
  2736. wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
  2737. }
  2738. }
  2739. else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
  2740. wacom->battery.battery) {
  2741. features->quirks &= ~WACOM_QUIRK_BATTERY;
  2742. wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
  2743. wacom_notify_battery(wacom_wac, POWER_SUPPLY_STATUS_UNKNOWN, 0, 0, 0, 0);
  2744. }
  2745. return 0;
  2746. }
  2747. void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  2748. {
  2749. bool sync;
  2750. switch (wacom_wac->features.type) {
  2751. case PENPARTNER:
  2752. sync = wacom_penpartner_irq(wacom_wac);
  2753. break;
  2754. case PL:
  2755. sync = wacom_pl_irq(wacom_wac);
  2756. break;
  2757. case WACOM_G4:
  2758. case GRAPHIRE:
  2759. case GRAPHIRE_BT:
  2760. case WACOM_MO:
  2761. sync = wacom_graphire_irq(wacom_wac);
  2762. break;
  2763. case PTU:
  2764. sync = wacom_ptu_irq(wacom_wac);
  2765. break;
  2766. case DTU:
  2767. sync = wacom_dtu_irq(wacom_wac);
  2768. break;
  2769. case DTUS:
  2770. case DTUSX:
  2771. sync = wacom_dtus_irq(wacom_wac);
  2772. break;
  2773. case INTUOS:
  2774. case INTUOS3S:
  2775. case INTUOS3:
  2776. case INTUOS3L:
  2777. case INTUOS4S:
  2778. case INTUOS4:
  2779. case INTUOS4L:
  2780. case CINTIQ:
  2781. case WACOM_BEE:
  2782. case WACOM_13HD:
  2783. case WACOM_21UX2:
  2784. case WACOM_22HD:
  2785. case WACOM_24HD:
  2786. case WACOM_27QHD:
  2787. case DTK:
  2788. case CINTIQ_HYBRID:
  2789. case CINTIQ_COMPANION_2:
  2790. sync = wacom_intuos_irq(wacom_wac);
  2791. break;
  2792. case INTUOS4WL:
  2793. sync = wacom_intuos_bt_irq(wacom_wac, len);
  2794. break;
  2795. case WACOM_24HDT:
  2796. case WACOM_27QHDT:
  2797. sync = wacom_24hdt_irq(wacom_wac);
  2798. break;
  2799. case INTUOS5S:
  2800. case INTUOS5:
  2801. case INTUOS5L:
  2802. case INTUOSPS:
  2803. case INTUOSPM:
  2804. case INTUOSPL:
  2805. if (len == WACOM_PKGLEN_BBTOUCH3)
  2806. sync = wacom_bpt3_touch(wacom_wac);
  2807. else if (wacom_wac->data[0] == WACOM_REPORT_USB)
  2808. sync = wacom_status_irq(wacom_wac, len);
  2809. else
  2810. sync = wacom_intuos_irq(wacom_wac);
  2811. break;
  2812. case INTUOSP2_BT:
  2813. case INTUOSHT3_BT:
  2814. sync = wacom_intuos_pro2_bt_irq(wacom_wac, len);
  2815. break;
  2816. case TABLETPC:
  2817. case TABLETPCE:
  2818. case TABLETPC2FG:
  2819. case MTSCREEN:
  2820. case MTTPC:
  2821. case MTTPC_B:
  2822. sync = wacom_tpc_irq(wacom_wac, len);
  2823. break;
  2824. case BAMBOO_PT:
  2825. case BAMBOO_PEN:
  2826. case BAMBOO_TOUCH:
  2827. case INTUOSHT:
  2828. case INTUOSHT2:
  2829. if (wacom_wac->data[0] == WACOM_REPORT_USB)
  2830. sync = wacom_status_irq(wacom_wac, len);
  2831. else
  2832. sync = wacom_bpt_irq(wacom_wac, len);
  2833. break;
  2834. case BAMBOO_PAD:
  2835. sync = wacom_bamboo_pad_irq(wacom_wac, len);
  2836. break;
  2837. case WIRELESS:
  2838. sync = wacom_wireless_irq(wacom_wac, len);
  2839. break;
  2840. case REMOTE:
  2841. sync = false;
  2842. if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
  2843. wacom_remote_status_irq(wacom_wac, len);
  2844. else
  2845. sync = wacom_remote_irq(wacom_wac, len);
  2846. break;
  2847. default:
  2848. sync = false;
  2849. break;
  2850. }
  2851. if (sync) {
  2852. if (wacom_wac->pen_input)
  2853. input_sync(wacom_wac->pen_input);
  2854. if (wacom_wac->touch_input)
  2855. input_sync(wacom_wac->touch_input);
  2856. if (wacom_wac->pad_input)
  2857. input_sync(wacom_wac->pad_input);
  2858. }
  2859. }
  2860. static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
  2861. {
  2862. struct input_dev *input_dev = wacom_wac->pen_input;
  2863. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  2864. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  2865. __set_bit(BTN_STYLUS, input_dev->keybit);
  2866. __set_bit(BTN_STYLUS2, input_dev->keybit);
  2867. input_set_abs_params(input_dev, ABS_DISTANCE,
  2868. 0, wacom_wac->features.distance_max, wacom_wac->features.distance_fuzz, 0);
  2869. }
  2870. static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
  2871. {
  2872. struct input_dev *input_dev = wacom_wac->pen_input;
  2873. struct wacom_features *features = &wacom_wac->features;
  2874. wacom_setup_basic_pro_pen(wacom_wac);
  2875. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  2876. __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
  2877. __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
  2878. __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
  2879. input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
  2880. input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, features->tilt_fuzz, 0);
  2881. input_abs_set_res(input_dev, ABS_TILT_X, 57);
  2882. input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, features->tilt_fuzz, 0);
  2883. input_abs_set_res(input_dev, ABS_TILT_Y, 57);
  2884. }
  2885. static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
  2886. {
  2887. struct input_dev *input_dev = wacom_wac->pen_input;
  2888. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  2889. wacom_setup_cintiq(wacom_wac);
  2890. __set_bit(BTN_LEFT, input_dev->keybit);
  2891. __set_bit(BTN_RIGHT, input_dev->keybit);
  2892. __set_bit(BTN_MIDDLE, input_dev->keybit);
  2893. __set_bit(BTN_SIDE, input_dev->keybit);
  2894. __set_bit(BTN_EXTRA, input_dev->keybit);
  2895. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  2896. __set_bit(BTN_TOOL_LENS, input_dev->keybit);
  2897. input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
  2898. input_abs_set_res(input_dev, ABS_RZ, 287);
  2899. input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
  2900. }
  2901. void wacom_setup_device_quirks(struct wacom *wacom)
  2902. {
  2903. struct wacom_wac *wacom_wac = &wacom->wacom_wac;
  2904. struct wacom_features *features = &wacom->wacom_wac.features;
  2905. /* The pen and pad share the same interface on most devices */
  2906. if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
  2907. features->type == DTUS ||
  2908. (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
  2909. if (features->device_type & WACOM_DEVICETYPE_PEN)
  2910. features->device_type |= WACOM_DEVICETYPE_PAD;
  2911. }
  2912. /* touch device found but size is not defined. use default */
  2913. if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
  2914. features->x_max = 1023;
  2915. features->y_max = 1023;
  2916. }
  2917. /*
  2918. * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
  2919. * touch interface in its HID descriptor. If this is the touch
  2920. * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
  2921. * tablet values.
  2922. */
  2923. if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
  2924. (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
  2925. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  2926. if (features->touch_max)
  2927. features->device_type |= WACOM_DEVICETYPE_TOUCH;
  2928. if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
  2929. features->device_type |= WACOM_DEVICETYPE_PAD;
  2930. if (features->type == INTUOSHT2) {
  2931. features->x_max = features->x_max / 10;
  2932. features->y_max = features->y_max / 10;
  2933. }
  2934. else {
  2935. features->x_max = 4096;
  2936. features->y_max = 4096;
  2937. }
  2938. }
  2939. else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  2940. features->device_type |= WACOM_DEVICETYPE_PAD;
  2941. }
  2942. }
  2943. /*
  2944. * Hack for the Bamboo One:
  2945. * the device presents a PAD/Touch interface as most Bamboos and even
  2946. * sends ghosts PAD data on it. However, later, we must disable this
  2947. * ghost interface, and we can not detect it unless we set it here
  2948. * to WACOM_DEVICETYPE_PAD or WACOM_DEVICETYPE_TOUCH.
  2949. */
  2950. if (features->type == BAMBOO_PEN &&
  2951. features->pktlen == WACOM_PKGLEN_BBTOUCH3)
  2952. features->device_type |= WACOM_DEVICETYPE_PAD;
  2953. /*
  2954. * Raw Wacom-mode pen and touch events both come from interface
  2955. * 0, whose HID descriptor has an application usage of 0xFF0D
  2956. * (i.e., WACOM_HID_WD_DIGITIZER). We route pen packets back
  2957. * out through the HID_GENERIC device created for interface 1,
  2958. * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
  2959. */
  2960. if (features->type == BAMBOO_PAD)
  2961. features->device_type = WACOM_DEVICETYPE_TOUCH;
  2962. if (features->type == REMOTE)
  2963. features->device_type = WACOM_DEVICETYPE_PAD;
  2964. if (features->type == INTUOSP2_BT) {
  2965. features->device_type |= WACOM_DEVICETYPE_PEN |
  2966. WACOM_DEVICETYPE_PAD |
  2967. WACOM_DEVICETYPE_TOUCH;
  2968. features->quirks |= WACOM_QUIRK_BATTERY;
  2969. }
  2970. if (features->type == INTUOSHT3_BT) {
  2971. features->device_type |= WACOM_DEVICETYPE_PEN |
  2972. WACOM_DEVICETYPE_PAD;
  2973. features->quirks |= WACOM_QUIRK_BATTERY;
  2974. }
  2975. switch (features->type) {
  2976. case PL:
  2977. case DTU:
  2978. case DTUS:
  2979. case DTUSX:
  2980. case WACOM_21UX2:
  2981. case WACOM_22HD:
  2982. case DTK:
  2983. case WACOM_24HD:
  2984. case WACOM_27QHD:
  2985. case CINTIQ_HYBRID:
  2986. case CINTIQ_COMPANION_2:
  2987. case CINTIQ:
  2988. case WACOM_BEE:
  2989. case WACOM_13HD:
  2990. case WACOM_24HDT:
  2991. case WACOM_27QHDT:
  2992. case TABLETPC:
  2993. case TABLETPCE:
  2994. case TABLETPC2FG:
  2995. case MTSCREEN:
  2996. case MTTPC:
  2997. case MTTPC_B:
  2998. features->device_type |= WACOM_DEVICETYPE_DIRECT;
  2999. break;
  3000. }
  3001. if (wacom->hdev->bus == BUS_BLUETOOTH)
  3002. features->quirks |= WACOM_QUIRK_BATTERY;
  3003. /* quirk for bamboo touch with 2 low res touches */
  3004. if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) &&
  3005. features->pktlen == WACOM_PKGLEN_BBTOUCH) {
  3006. features->x_max <<= 5;
  3007. features->y_max <<= 5;
  3008. features->x_fuzz <<= 5;
  3009. features->y_fuzz <<= 5;
  3010. features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
  3011. }
  3012. if (features->type == WIRELESS) {
  3013. if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
  3014. features->quirks |= WACOM_QUIRK_BATTERY;
  3015. }
  3016. }
  3017. if (features->type == REMOTE)
  3018. features->device_type |= WACOM_DEVICETYPE_WL_MONITOR;
  3019. /* HID descriptor for DTK-2451 / DTH-2452 claims to report lots
  3020. * of things it shouldn't. Lets fix up the damage...
  3021. */
  3022. if (wacom->hdev->product == 0x382 || wacom->hdev->product == 0x37d) {
  3023. features->quirks &= ~WACOM_QUIRK_TOOLSERIAL;
  3024. __clear_bit(BTN_TOOL_BRUSH, wacom_wac->pen_input->keybit);
  3025. __clear_bit(BTN_TOOL_PENCIL, wacom_wac->pen_input->keybit);
  3026. __clear_bit(BTN_TOOL_AIRBRUSH, wacom_wac->pen_input->keybit);
  3027. __clear_bit(ABS_Z, wacom_wac->pen_input->absbit);
  3028. __clear_bit(ABS_DISTANCE, wacom_wac->pen_input->absbit);
  3029. __clear_bit(ABS_TILT_X, wacom_wac->pen_input->absbit);
  3030. __clear_bit(ABS_TILT_Y, wacom_wac->pen_input->absbit);
  3031. __clear_bit(ABS_WHEEL, wacom_wac->pen_input->absbit);
  3032. __clear_bit(ABS_MISC, wacom_wac->pen_input->absbit);
  3033. __clear_bit(MSC_SERIAL, wacom_wac->pen_input->mscbit);
  3034. __clear_bit(EV_MSC, wacom_wac->pen_input->evbit);
  3035. }
  3036. }
  3037. int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
  3038. struct wacom_wac *wacom_wac)
  3039. {
  3040. struct wacom_features *features = &wacom_wac->features;
  3041. if (!(features->device_type & WACOM_DEVICETYPE_PEN))
  3042. return -ENODEV;
  3043. if (features->device_type & WACOM_DEVICETYPE_DIRECT)
  3044. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  3045. else
  3046. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  3047. if (features->type == HID_GENERIC) {
  3048. /* setup has already been done; apply otherwise-undetectible quirks */
  3049. input_set_capability(input_dev, EV_KEY, BTN_STYLUS3);
  3050. return 0;
  3051. }
  3052. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  3053. __set_bit(BTN_TOUCH, input_dev->keybit);
  3054. __set_bit(ABS_MISC, input_dev->absbit);
  3055. input_set_abs_params(input_dev, ABS_X, 0 + features->offset_left,
  3056. features->x_max - features->offset_right,
  3057. features->x_fuzz, 0);
  3058. input_set_abs_params(input_dev, ABS_Y, 0 + features->offset_top,
  3059. features->y_max - features->offset_bottom,
  3060. features->y_fuzz, 0);
  3061. input_set_abs_params(input_dev, ABS_PRESSURE, 0,
  3062. features->pressure_max, features->pressure_fuzz, 0);
  3063. /* penabled devices have fixed resolution for each model */
  3064. input_abs_set_res(input_dev, ABS_X, features->x_resolution);
  3065. input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
  3066. switch (features->type) {
  3067. case GRAPHIRE_BT:
  3068. __clear_bit(ABS_MISC, input_dev->absbit);
  3069. case WACOM_MO:
  3070. case WACOM_G4:
  3071. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  3072. features->distance_max,
  3073. features->distance_fuzz, 0);
  3074. /* fall through */
  3075. case GRAPHIRE:
  3076. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  3077. __set_bit(BTN_LEFT, input_dev->keybit);
  3078. __set_bit(BTN_RIGHT, input_dev->keybit);
  3079. __set_bit(BTN_MIDDLE, input_dev->keybit);
  3080. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  3081. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  3082. __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  3083. __set_bit(BTN_STYLUS, input_dev->keybit);
  3084. __set_bit(BTN_STYLUS2, input_dev->keybit);
  3085. break;
  3086. case WACOM_27QHD:
  3087. case WACOM_24HD:
  3088. case DTK:
  3089. case WACOM_22HD:
  3090. case WACOM_21UX2:
  3091. case WACOM_BEE:
  3092. case CINTIQ:
  3093. case WACOM_13HD:
  3094. case CINTIQ_HYBRID:
  3095. case CINTIQ_COMPANION_2:
  3096. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  3097. input_abs_set_res(input_dev, ABS_Z, 287);
  3098. wacom_setup_cintiq(wacom_wac);
  3099. break;
  3100. case INTUOS3:
  3101. case INTUOS3L:
  3102. case INTUOS3S:
  3103. case INTUOS4:
  3104. case INTUOS4WL:
  3105. case INTUOS4L:
  3106. case INTUOS4S:
  3107. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  3108. input_abs_set_res(input_dev, ABS_Z, 287);
  3109. /* fall through */
  3110. case INTUOS:
  3111. wacom_setup_intuos(wacom_wac);
  3112. break;
  3113. case INTUOS5:
  3114. case INTUOS5L:
  3115. case INTUOSPM:
  3116. case INTUOSPL:
  3117. case INTUOS5S:
  3118. case INTUOSPS:
  3119. case INTUOSP2_BT:
  3120. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  3121. features->distance_max,
  3122. features->distance_fuzz, 0);
  3123. input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
  3124. input_abs_set_res(input_dev, ABS_Z, 287);
  3125. wacom_setup_intuos(wacom_wac);
  3126. break;
  3127. case WACOM_24HDT:
  3128. case WACOM_27QHDT:
  3129. case MTSCREEN:
  3130. case MTTPC:
  3131. case MTTPC_B:
  3132. case TABLETPC2FG:
  3133. case TABLETPC:
  3134. case TABLETPCE:
  3135. __clear_bit(ABS_MISC, input_dev->absbit);
  3136. /* fall through */
  3137. case DTUS:
  3138. case DTUSX:
  3139. case PL:
  3140. case DTU:
  3141. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  3142. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  3143. __set_bit(BTN_STYLUS, input_dev->keybit);
  3144. __set_bit(BTN_STYLUS2, input_dev->keybit);
  3145. break;
  3146. case PTU:
  3147. __set_bit(BTN_STYLUS2, input_dev->keybit);
  3148. /* fall through */
  3149. case PENPARTNER:
  3150. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  3151. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  3152. __set_bit(BTN_STYLUS, input_dev->keybit);
  3153. break;
  3154. case INTUOSHT:
  3155. case BAMBOO_PT:
  3156. case BAMBOO_PEN:
  3157. case INTUOSHT2:
  3158. case INTUOSHT3_BT:
  3159. if (features->type == INTUOSHT2 ||
  3160. features->type == INTUOSHT3_BT) {
  3161. wacom_setup_basic_pro_pen(wacom_wac);
  3162. } else {
  3163. __clear_bit(ABS_MISC, input_dev->absbit);
  3164. __set_bit(BTN_TOOL_PEN, input_dev->keybit);
  3165. __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  3166. __set_bit(BTN_STYLUS, input_dev->keybit);
  3167. __set_bit(BTN_STYLUS2, input_dev->keybit);
  3168. input_set_abs_params(input_dev, ABS_DISTANCE, 0,
  3169. features->distance_max,
  3170. features->distance_fuzz, 0);
  3171. }
  3172. break;
  3173. case BAMBOO_PAD:
  3174. __clear_bit(ABS_MISC, input_dev->absbit);
  3175. break;
  3176. }
  3177. return 0;
  3178. }
  3179. int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
  3180. struct wacom_wac *wacom_wac)
  3181. {
  3182. struct wacom_features *features = &wacom_wac->features;
  3183. if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
  3184. return -ENODEV;
  3185. if (features->device_type & WACOM_DEVICETYPE_DIRECT)
  3186. __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  3187. else
  3188. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  3189. if (features->type == HID_GENERIC)
  3190. /* setup has already been done */
  3191. return 0;
  3192. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  3193. __set_bit(BTN_TOUCH, input_dev->keybit);
  3194. if (features->touch_max == 1) {
  3195. input_set_abs_params(input_dev, ABS_X, 0,
  3196. features->x_max, features->x_fuzz, 0);
  3197. input_set_abs_params(input_dev, ABS_Y, 0,
  3198. features->y_max, features->y_fuzz, 0);
  3199. input_abs_set_res(input_dev, ABS_X,
  3200. features->x_resolution);
  3201. input_abs_set_res(input_dev, ABS_Y,
  3202. features->y_resolution);
  3203. }
  3204. else if (features->touch_max > 1) {
  3205. input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
  3206. features->x_max, features->x_fuzz, 0);
  3207. input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
  3208. features->y_max, features->y_fuzz, 0);
  3209. input_abs_set_res(input_dev, ABS_MT_POSITION_X,
  3210. features->x_resolution);
  3211. input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
  3212. features->y_resolution);
  3213. }
  3214. switch (features->type) {
  3215. case INTUOSP2_BT:
  3216. input_dev->evbit[0] |= BIT_MASK(EV_SW);
  3217. __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
  3218. if (wacom_wac->shared->touch->product == 0x361) {
  3219. input_set_abs_params(input_dev, ABS_MT_POSITION_X,
  3220. 0, 12440, 4, 0);
  3221. input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
  3222. 0, 8640, 4, 0);
  3223. }
  3224. else if (wacom_wac->shared->touch->product == 0x360) {
  3225. input_set_abs_params(input_dev, ABS_MT_POSITION_X,
  3226. 0, 8960, 4, 0);
  3227. input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
  3228. 0, 5920, 4, 0);
  3229. }
  3230. input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
  3231. input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
  3232. /* fall through */
  3233. case INTUOS5:
  3234. case INTUOS5L:
  3235. case INTUOSPM:
  3236. case INTUOSPL:
  3237. case INTUOS5S:
  3238. case INTUOSPS:
  3239. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  3240. input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
  3241. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  3242. break;
  3243. case WACOM_24HDT:
  3244. input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
  3245. input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
  3246. input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
  3247. input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
  3248. /* fall through */
  3249. case WACOM_27QHDT:
  3250. case MTSCREEN:
  3251. case MTTPC:
  3252. case MTTPC_B:
  3253. case TABLETPC2FG:
  3254. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
  3255. /*fall through */
  3256. case TABLETPC:
  3257. case TABLETPCE:
  3258. break;
  3259. case INTUOSHT:
  3260. case INTUOSHT2:
  3261. input_dev->evbit[0] |= BIT_MASK(EV_SW);
  3262. __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
  3263. /* fall through */
  3264. case BAMBOO_PT:
  3265. case BAMBOO_TOUCH:
  3266. if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
  3267. input_set_abs_params(input_dev,
  3268. ABS_MT_TOUCH_MAJOR,
  3269. 0, features->x_max, 0, 0);
  3270. input_set_abs_params(input_dev,
  3271. ABS_MT_TOUCH_MINOR,
  3272. 0, features->y_max, 0, 0);
  3273. }
  3274. input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
  3275. break;
  3276. case BAMBOO_PAD:
  3277. input_mt_init_slots(input_dev, features->touch_max,
  3278. INPUT_MT_POINTER);
  3279. __set_bit(BTN_LEFT, input_dev->keybit);
  3280. __set_bit(BTN_RIGHT, input_dev->keybit);
  3281. break;
  3282. }
  3283. return 0;
  3284. }
  3285. static int wacom_numbered_button_to_key(int n)
  3286. {
  3287. if (n < 10)
  3288. return BTN_0 + n;
  3289. else if (n < 16)
  3290. return BTN_A + (n-10);
  3291. else if (n < 18)
  3292. return BTN_BASE + (n-16);
  3293. else
  3294. return 0;
  3295. }
  3296. static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
  3297. int button_count)
  3298. {
  3299. int i;
  3300. for (i = 0; i < button_count; i++) {
  3301. int key = wacom_numbered_button_to_key(i);
  3302. if (key)
  3303. __set_bit(key, input_dev->keybit);
  3304. }
  3305. }
  3306. static void wacom_24hd_update_leds(struct wacom *wacom, int mask, int group)
  3307. {
  3308. struct wacom_led *led;
  3309. int i;
  3310. bool updated = false;
  3311. /*
  3312. * 24HD has LED group 1 to the left and LED group 0 to the right.
  3313. * So group 0 matches the second half of the buttons and thus the mask
  3314. * needs to be shifted.
  3315. */
  3316. if (group == 0)
  3317. mask >>= 8;
  3318. for (i = 0; i < 3; i++) {
  3319. led = wacom_led_find(wacom, group, i);
  3320. if (!led) {
  3321. hid_err(wacom->hdev, "can't find LED %d in group %d\n",
  3322. i, group);
  3323. continue;
  3324. }
  3325. if (!updated && mask & BIT(i)) {
  3326. led->held = true;
  3327. led_trigger_event(&led->trigger, LED_FULL);
  3328. } else {
  3329. led->held = false;
  3330. }
  3331. }
  3332. }
  3333. static bool wacom_is_led_toggled(struct wacom *wacom, int button_count,
  3334. int mask, int group)
  3335. {
  3336. int group_button;
  3337. /*
  3338. * 21UX2 has LED group 1 to the left and LED group 0
  3339. * to the right. We need to reverse the group to match this
  3340. * historical behavior.
  3341. */
  3342. if (wacom->wacom_wac.features.type == WACOM_21UX2)
  3343. group = 1 - group;
  3344. group_button = group * (button_count/wacom->led.count);
  3345. if (wacom->wacom_wac.features.type == INTUOSP2_BT)
  3346. group_button = 8;
  3347. return mask & (1 << group_button);
  3348. }
  3349. static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
  3350. int group)
  3351. {
  3352. struct wacom_led *led, *next_led;
  3353. int cur;
  3354. bool pressed;
  3355. if (wacom->wacom_wac.features.type == WACOM_24HD)
  3356. return wacom_24hd_update_leds(wacom, mask, group);
  3357. pressed = wacom_is_led_toggled(wacom, button_count, mask, group);
  3358. cur = wacom->led.groups[group].select;
  3359. led = wacom_led_find(wacom, group, cur);
  3360. if (!led) {
  3361. hid_err(wacom->hdev, "can't find current LED %d in group %d\n",
  3362. cur, group);
  3363. return;
  3364. }
  3365. if (!pressed) {
  3366. led->held = false;
  3367. return;
  3368. }
  3369. if (led->held && pressed)
  3370. return;
  3371. next_led = wacom_led_next(wacom, led);
  3372. if (!next_led) {
  3373. hid_err(wacom->hdev, "can't find next LED in group %d\n",
  3374. group);
  3375. return;
  3376. }
  3377. if (next_led == led)
  3378. return;
  3379. next_led->held = true;
  3380. led_trigger_event(&next_led->trigger,
  3381. wacom_leds_brightness_get(next_led));
  3382. }
  3383. static void wacom_report_numbered_buttons(struct input_dev *input_dev,
  3384. int button_count, int mask)
  3385. {
  3386. struct wacom *wacom = input_get_drvdata(input_dev);
  3387. int i;
  3388. for (i = 0; i < wacom->led.count; i++)
  3389. wacom_update_led(wacom, button_count, mask, i);
  3390. for (i = 0; i < button_count; i++) {
  3391. int key = wacom_numbered_button_to_key(i);
  3392. if (key)
  3393. input_report_key(input_dev, key, mask & (1 << i));
  3394. }
  3395. }
  3396. int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
  3397. struct wacom_wac *wacom_wac)
  3398. {
  3399. struct wacom_features *features = &wacom_wac->features;
  3400. if ((features->type == HID_GENERIC) && features->numbered_buttons > 0)
  3401. features->device_type |= WACOM_DEVICETYPE_PAD;
  3402. if (!(features->device_type & WACOM_DEVICETYPE_PAD))
  3403. return -ENODEV;
  3404. if (features->type == REMOTE && input_dev == wacom_wac->pad_input)
  3405. return -ENODEV;
  3406. input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
  3407. /* kept for making legacy xf86-input-wacom working with the wheels */
  3408. __set_bit(ABS_MISC, input_dev->absbit);
  3409. /* kept for making legacy xf86-input-wacom accepting the pad */
  3410. if (!(input_dev->absinfo && (input_dev->absinfo[ABS_X].minimum ||
  3411. input_dev->absinfo[ABS_X].maximum)))
  3412. input_set_abs_params(input_dev, ABS_X, 0, 1, 0, 0);
  3413. if (!(input_dev->absinfo && (input_dev->absinfo[ABS_Y].minimum ||
  3414. input_dev->absinfo[ABS_Y].maximum)))
  3415. input_set_abs_params(input_dev, ABS_Y, 0, 1, 0, 0);
  3416. /* kept for making udev and libwacom accepting the pad */
  3417. __set_bit(BTN_STYLUS, input_dev->keybit);
  3418. wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
  3419. switch (features->type) {
  3420. case CINTIQ_HYBRID:
  3421. case CINTIQ_COMPANION_2:
  3422. case DTK:
  3423. case DTUS:
  3424. case GRAPHIRE_BT:
  3425. break;
  3426. case WACOM_MO:
  3427. __set_bit(BTN_BACK, input_dev->keybit);
  3428. __set_bit(BTN_LEFT, input_dev->keybit);
  3429. __set_bit(BTN_FORWARD, input_dev->keybit);
  3430. __set_bit(BTN_RIGHT, input_dev->keybit);
  3431. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3432. break;
  3433. case WACOM_G4:
  3434. __set_bit(BTN_BACK, input_dev->keybit);
  3435. __set_bit(BTN_FORWARD, input_dev->keybit);
  3436. input_set_capability(input_dev, EV_REL, REL_WHEEL);
  3437. break;
  3438. case WACOM_24HD:
  3439. __set_bit(KEY_PROG1, input_dev->keybit);
  3440. __set_bit(KEY_PROG2, input_dev->keybit);
  3441. __set_bit(KEY_PROG3, input_dev->keybit);
  3442. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3443. input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
  3444. break;
  3445. case WACOM_27QHD:
  3446. __set_bit(KEY_PROG1, input_dev->keybit);
  3447. __set_bit(KEY_PROG2, input_dev->keybit);
  3448. __set_bit(KEY_PROG3, input_dev->keybit);
  3449. input_set_abs_params(input_dev, ABS_X, -2048, 2048, 0, 0);
  3450. input_abs_set_res(input_dev, ABS_X, 1024); /* points/g */
  3451. input_set_abs_params(input_dev, ABS_Y, -2048, 2048, 0, 0);
  3452. input_abs_set_res(input_dev, ABS_Y, 1024);
  3453. input_set_abs_params(input_dev, ABS_Z, -2048, 2048, 0, 0);
  3454. input_abs_set_res(input_dev, ABS_Z, 1024);
  3455. __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
  3456. break;
  3457. case WACOM_22HD:
  3458. __set_bit(KEY_PROG1, input_dev->keybit);
  3459. __set_bit(KEY_PROG2, input_dev->keybit);
  3460. __set_bit(KEY_PROG3, input_dev->keybit);
  3461. /* fall through */
  3462. case WACOM_21UX2:
  3463. case WACOM_BEE:
  3464. case CINTIQ:
  3465. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  3466. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  3467. break;
  3468. case WACOM_13HD:
  3469. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3470. break;
  3471. case INTUOS3:
  3472. case INTUOS3L:
  3473. input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
  3474. /* fall through */
  3475. case INTUOS3S:
  3476. input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
  3477. break;
  3478. case INTUOS5:
  3479. case INTUOS5L:
  3480. case INTUOSPM:
  3481. case INTUOSPL:
  3482. case INTUOS5S:
  3483. case INTUOSPS:
  3484. case INTUOSP2_BT:
  3485. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3486. break;
  3487. case INTUOS4WL:
  3488. /*
  3489. * For Bluetooth devices, the udev rule does not work correctly
  3490. * for pads unless we add a stylus capability, which forces
  3491. * ID_INPUT_TABLET to be set.
  3492. */
  3493. __set_bit(BTN_STYLUS, input_dev->keybit);
  3494. /* fall through */
  3495. case INTUOS4:
  3496. case INTUOS4L:
  3497. case INTUOS4S:
  3498. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3499. break;
  3500. case INTUOSHT:
  3501. case BAMBOO_PT:
  3502. case BAMBOO_TOUCH:
  3503. case INTUOSHT2:
  3504. __clear_bit(ABS_MISC, input_dev->absbit);
  3505. __set_bit(BTN_LEFT, input_dev->keybit);
  3506. __set_bit(BTN_FORWARD, input_dev->keybit);
  3507. __set_bit(BTN_BACK, input_dev->keybit);
  3508. __set_bit(BTN_RIGHT, input_dev->keybit);
  3509. break;
  3510. case REMOTE:
  3511. input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
  3512. input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
  3513. break;
  3514. case INTUOSHT3_BT:
  3515. case HID_GENERIC:
  3516. break;
  3517. default:
  3518. /* no pad supported */
  3519. return -ENODEV;
  3520. }
  3521. return 0;
  3522. }
  3523. static const struct wacom_features wacom_features_0x00 =
  3524. { "Wacom Penpartner", 5040, 3780, 255, 0,
  3525. PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  3526. static const struct wacom_features wacom_features_0x10 =
  3527. { "Wacom Graphire", 10206, 7422, 511, 63,
  3528. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3529. static const struct wacom_features wacom_features_0x81 =
  3530. { "Wacom Graphire BT", 16704, 12064, 511, 32,
  3531. GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
  3532. static const struct wacom_features wacom_features_0x11 =
  3533. { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
  3534. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3535. static const struct wacom_features wacom_features_0x12 =
  3536. { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
  3537. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3538. static const struct wacom_features wacom_features_0x13 =
  3539. { "Wacom Graphire3", 10208, 7424, 511, 63,
  3540. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3541. static const struct wacom_features wacom_features_0x14 =
  3542. { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
  3543. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3544. static const struct wacom_features wacom_features_0x15 =
  3545. { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
  3546. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3547. static const struct wacom_features wacom_features_0x16 =
  3548. { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
  3549. WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3550. static const struct wacom_features wacom_features_0x17 =
  3551. { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
  3552. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3553. static const struct wacom_features wacom_features_0x18 =
  3554. { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
  3555. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3556. static const struct wacom_features wacom_features_0x19 =
  3557. { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
  3558. GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
  3559. static const struct wacom_features wacom_features_0x60 =
  3560. { "Wacom Volito", 5104, 3712, 511, 63,
  3561. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  3562. static const struct wacom_features wacom_features_0x61 =
  3563. { "Wacom PenStation2", 3250, 2320, 255, 63,
  3564. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  3565. static const struct wacom_features wacom_features_0x62 =
  3566. { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
  3567. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  3568. static const struct wacom_features wacom_features_0x63 =
  3569. { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
  3570. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  3571. static const struct wacom_features wacom_features_0x64 =
  3572. { "Wacom PenPartner2", 3250, 2320, 511, 63,
  3573. GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
  3574. static const struct wacom_features wacom_features_0x65 =
  3575. { "Wacom Bamboo", 14760, 9225, 511, 63,
  3576. WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3577. static const struct wacom_features wacom_features_0x69 =
  3578. { "Wacom Bamboo1", 5104, 3712, 511, 63,
  3579. GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
  3580. static const struct wacom_features wacom_features_0x6A =
  3581. { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
  3582. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3583. static const struct wacom_features wacom_features_0x6B =
  3584. { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
  3585. GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3586. static const struct wacom_features wacom_features_0x20 =
  3587. { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
  3588. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3589. static const struct wacom_features wacom_features_0x21 =
  3590. { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
  3591. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3592. static const struct wacom_features wacom_features_0x22 =
  3593. { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
  3594. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3595. static const struct wacom_features wacom_features_0x23 =
  3596. { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
  3597. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3598. static const struct wacom_features wacom_features_0x24 =
  3599. { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
  3600. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3601. static const struct wacom_features wacom_features_0x30 =
  3602. { "Wacom PL400", 5408, 4056, 255, 0,
  3603. PL, WACOM_PL_RES, WACOM_PL_RES };
  3604. static const struct wacom_features wacom_features_0x31 =
  3605. { "Wacom PL500", 6144, 4608, 255, 0,
  3606. PL, WACOM_PL_RES, WACOM_PL_RES };
  3607. static const struct wacom_features wacom_features_0x32 =
  3608. { "Wacom PL600", 6126, 4604, 255, 0,
  3609. PL, WACOM_PL_RES, WACOM_PL_RES };
  3610. static const struct wacom_features wacom_features_0x33 =
  3611. { "Wacom PL600SX", 6260, 5016, 255, 0,
  3612. PL, WACOM_PL_RES, WACOM_PL_RES };
  3613. static const struct wacom_features wacom_features_0x34 =
  3614. { "Wacom PL550", 6144, 4608, 511, 0,
  3615. PL, WACOM_PL_RES, WACOM_PL_RES };
  3616. static const struct wacom_features wacom_features_0x35 =
  3617. { "Wacom PL800", 7220, 5780, 511, 0,
  3618. PL, WACOM_PL_RES, WACOM_PL_RES };
  3619. static const struct wacom_features wacom_features_0x37 =
  3620. { "Wacom PL700", 6758, 5406, 511, 0,
  3621. PL, WACOM_PL_RES, WACOM_PL_RES };
  3622. static const struct wacom_features wacom_features_0x38 =
  3623. { "Wacom PL510", 6282, 4762, 511, 0,
  3624. PL, WACOM_PL_RES, WACOM_PL_RES };
  3625. static const struct wacom_features wacom_features_0x39 =
  3626. { "Wacom DTU710", 34080, 27660, 511, 0,
  3627. PL, WACOM_PL_RES, WACOM_PL_RES };
  3628. static const struct wacom_features wacom_features_0xC4 =
  3629. { "Wacom DTF521", 6282, 4762, 511, 0,
  3630. PL, WACOM_PL_RES, WACOM_PL_RES };
  3631. static const struct wacom_features wacom_features_0xC0 =
  3632. { "Wacom DTF720", 6858, 5506, 511, 0,
  3633. PL, WACOM_PL_RES, WACOM_PL_RES };
  3634. static const struct wacom_features wacom_features_0xC2 =
  3635. { "Wacom DTF720a", 6858, 5506, 511, 0,
  3636. PL, WACOM_PL_RES, WACOM_PL_RES };
  3637. static const struct wacom_features wacom_features_0x03 =
  3638. { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
  3639. PTU, WACOM_PL_RES, WACOM_PL_RES };
  3640. static const struct wacom_features wacom_features_0x41 =
  3641. { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
  3642. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3643. static const struct wacom_features wacom_features_0x42 =
  3644. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  3645. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3646. static const struct wacom_features wacom_features_0x43 =
  3647. { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
  3648. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3649. static const struct wacom_features wacom_features_0x44 =
  3650. { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
  3651. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3652. static const struct wacom_features wacom_features_0x45 =
  3653. { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
  3654. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3655. static const struct wacom_features wacom_features_0xB0 =
  3656. { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
  3657. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
  3658. static const struct wacom_features wacom_features_0xB1 =
  3659. { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
  3660. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3661. static const struct wacom_features wacom_features_0xB2 =
  3662. { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
  3663. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3664. static const struct wacom_features wacom_features_0xB3 =
  3665. { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
  3666. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3667. static const struct wacom_features wacom_features_0xB4 =
  3668. { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
  3669. INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3670. static const struct wacom_features wacom_features_0xB5 =
  3671. { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
  3672. INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3673. static const struct wacom_features wacom_features_0xB7 =
  3674. { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
  3675. INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
  3676. static const struct wacom_features wacom_features_0xB8 =
  3677. { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
  3678. INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
  3679. static const struct wacom_features wacom_features_0xB9 =
  3680. { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
  3681. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3682. static const struct wacom_features wacom_features_0xBA =
  3683. { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
  3684. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3685. static const struct wacom_features wacom_features_0xBB =
  3686. { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
  3687. INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3688. static const struct wacom_features wacom_features_0xBC =
  3689. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  3690. INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3691. static const struct wacom_features wacom_features_0xBD =
  3692. { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
  3693. INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3694. static const struct wacom_features wacom_features_0x26 =
  3695. { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
  3696. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
  3697. static const struct wacom_features wacom_features_0x27 =
  3698. { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
  3699. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
  3700. static const struct wacom_features wacom_features_0x28 =
  3701. { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
  3702. INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
  3703. static const struct wacom_features wacom_features_0x29 =
  3704. { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
  3705. INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
  3706. static const struct wacom_features wacom_features_0x2A =
  3707. { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
  3708. INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
  3709. static const struct wacom_features wacom_features_0x314 =
  3710. { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
  3711. INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
  3712. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3713. static const struct wacom_features wacom_features_0x315 =
  3714. { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
  3715. INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
  3716. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3717. static const struct wacom_features wacom_features_0x317 =
  3718. { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
  3719. INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
  3720. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3721. static const struct wacom_features wacom_features_0xF4 =
  3722. { "Wacom Cintiq 24HD", 104480, 65600, 2047, 63,
  3723. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
  3724. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3725. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3726. static const struct wacom_features wacom_features_0xF8 =
  3727. { "Wacom Cintiq 24HD touch", 104480, 65600, 2047, 63, /* Pen */
  3728. WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
  3729. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3730. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3731. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
  3732. static const struct wacom_features wacom_features_0xF6 =
  3733. { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
  3734. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
  3735. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3736. static const struct wacom_features wacom_features_0x32A =
  3737. { "Wacom Cintiq 27QHD", 120140, 67920, 2047, 63,
  3738. WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
  3739. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3740. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3741. static const struct wacom_features wacom_features_0x32B =
  3742. { "Wacom Cintiq 27QHD touch", 120140, 67920, 2047, 63,
  3743. WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
  3744. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3745. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3746. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
  3747. static const struct wacom_features wacom_features_0x32C =
  3748. { "Wacom Cintiq 27QHD touch", .type = WACOM_27QHDT,
  3749. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
  3750. static const struct wacom_features wacom_features_0x3F =
  3751. { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
  3752. CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
  3753. static const struct wacom_features wacom_features_0xC5 =
  3754. { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
  3755. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
  3756. static const struct wacom_features wacom_features_0xC6 =
  3757. { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
  3758. WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
  3759. static const struct wacom_features wacom_features_0x304 =
  3760. { "Wacom Cintiq 13HD", 59552, 33848, 1023, 63,
  3761. WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  3762. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3763. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3764. static const struct wacom_features wacom_features_0x333 =
  3765. { "Wacom Cintiq 13HD touch", 59552, 33848, 2047, 63,
  3766. WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  3767. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3768. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3769. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
  3770. static const struct wacom_features wacom_features_0x335 =
  3771. { "Wacom Cintiq 13HD touch", .type = WACOM_24HDT, /* Touch */
  3772. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x333, .touch_max = 10,
  3773. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3774. static const struct wacom_features wacom_features_0xC7 =
  3775. { "Wacom DTU1931", 37832, 30305, 511, 0,
  3776. PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3777. static const struct wacom_features wacom_features_0xCE =
  3778. { "Wacom DTU2231", 47864, 27011, 511, 0,
  3779. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  3780. .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
  3781. static const struct wacom_features wacom_features_0xF0 =
  3782. { "Wacom DTU1631", 34623, 19553, 511, 0,
  3783. DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3784. static const struct wacom_features wacom_features_0xFB =
  3785. { "Wacom DTU1031", 22096, 13960, 511, 0,
  3786. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
  3787. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
  3788. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  3789. static const struct wacom_features wacom_features_0x32F =
  3790. { "Wacom DTU1031X", 22672, 12928, 511, 0,
  3791. DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
  3792. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
  3793. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  3794. static const struct wacom_features wacom_features_0x336 =
  3795. { "Wacom DTU1141", 23672, 13403, 1023, 0,
  3796. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
  3797. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
  3798. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  3799. static const struct wacom_features wacom_features_0x57 =
  3800. { "Wacom DTK2241", 95840, 54260, 2047, 63,
  3801. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
  3802. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3803. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3804. static const struct wacom_features wacom_features_0x59 = /* Pen */
  3805. { "Wacom DTH2242", 95840, 54260, 2047, 63,
  3806. DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
  3807. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3808. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3809. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
  3810. static const struct wacom_features wacom_features_0x5D = /* Touch */
  3811. { "Wacom DTH2242", .type = WACOM_24HDT,
  3812. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
  3813. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3814. static const struct wacom_features wacom_features_0xCC =
  3815. { "Wacom Cintiq 21UX2", 87200, 65600, 2047, 63,
  3816. WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  3817. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3818. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3819. static const struct wacom_features wacom_features_0xFA =
  3820. { "Wacom Cintiq 22HD", 95840, 54260, 2047, 63,
  3821. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  3822. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3823. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
  3824. static const struct wacom_features wacom_features_0x5B =
  3825. { "Wacom Cintiq 22HDT", 95840, 54260, 2047, 63,
  3826. WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
  3827. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3828. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3829. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
  3830. static const struct wacom_features wacom_features_0x5E =
  3831. { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
  3832. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
  3833. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3834. static const struct wacom_features wacom_features_0x90 =
  3835. { "Wacom ISDv4 90", 26202, 16325, 255, 0,
  3836. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
  3837. static const struct wacom_features wacom_features_0x93 =
  3838. { "Wacom ISDv4 93", 26202, 16325, 255, 0,
  3839. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
  3840. static const struct wacom_features wacom_features_0x97 =
  3841. { "Wacom ISDv4 97", 26202, 16325, 511, 0,
  3842. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
  3843. static const struct wacom_features wacom_features_0x9A =
  3844. { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
  3845. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
  3846. static const struct wacom_features wacom_features_0x9F =
  3847. { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
  3848. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
  3849. static const struct wacom_features wacom_features_0xE2 =
  3850. { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
  3851. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3852. static const struct wacom_features wacom_features_0xE3 =
  3853. { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
  3854. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3855. static const struct wacom_features wacom_features_0xE5 =
  3856. { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
  3857. MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3858. static const struct wacom_features wacom_features_0xE6 =
  3859. { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
  3860. TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3861. static const struct wacom_features wacom_features_0xEC =
  3862. { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
  3863. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
  3864. static const struct wacom_features wacom_features_0xED =
  3865. { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
  3866. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
  3867. static const struct wacom_features wacom_features_0xEF =
  3868. { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
  3869. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
  3870. static const struct wacom_features wacom_features_0x100 =
  3871. { "Wacom ISDv4 100", 26202, 16325, 255, 0,
  3872. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3873. static const struct wacom_features wacom_features_0x101 =
  3874. { "Wacom ISDv4 101", 26202, 16325, 255, 0,
  3875. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3876. static const struct wacom_features wacom_features_0x10D =
  3877. { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
  3878. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3879. static const struct wacom_features wacom_features_0x10E =
  3880. { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
  3881. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3882. static const struct wacom_features wacom_features_0x10F =
  3883. { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
  3884. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3885. static const struct wacom_features wacom_features_0x116 =
  3886. { "Wacom ISDv4 116", 26202, 16325, 255, 0,
  3887. TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 1 };
  3888. static const struct wacom_features wacom_features_0x12C =
  3889. { "Wacom ISDv4 12C", 27848, 15752, 2047, 0,
  3890. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; /* Pen-only */
  3891. static const struct wacom_features wacom_features_0x4001 =
  3892. { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
  3893. MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3894. static const struct wacom_features wacom_features_0x4004 =
  3895. { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
  3896. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3897. static const struct wacom_features wacom_features_0x5000 =
  3898. { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
  3899. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3900. static const struct wacom_features wacom_features_0x5002 =
  3901. { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
  3902. MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3903. static const struct wacom_features wacom_features_0x47 =
  3904. { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
  3905. INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3906. static const struct wacom_features wacom_features_0x84 =
  3907. { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
  3908. static const struct wacom_features wacom_features_0xD0 =
  3909. { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
  3910. BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3911. static const struct wacom_features wacom_features_0xD1 =
  3912. { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
  3913. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3914. static const struct wacom_features wacom_features_0xD2 =
  3915. { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
  3916. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3917. static const struct wacom_features wacom_features_0xD3 =
  3918. { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
  3919. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3920. static const struct wacom_features wacom_features_0xD4 =
  3921. { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
  3922. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3923. static const struct wacom_features wacom_features_0xD5 =
  3924. { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
  3925. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3926. static const struct wacom_features wacom_features_0xD6 =
  3927. { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
  3928. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3929. static const struct wacom_features wacom_features_0xD7 =
  3930. { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
  3931. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3932. static const struct wacom_features wacom_features_0xD8 =
  3933. { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
  3934. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3935. static const struct wacom_features wacom_features_0xDA =
  3936. { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
  3937. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3938. static const struct wacom_features wacom_features_0xDB =
  3939. { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
  3940. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
  3941. static const struct wacom_features wacom_features_0xDD =
  3942. { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
  3943. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3944. static const struct wacom_features wacom_features_0xDE =
  3945. { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
  3946. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  3947. static const struct wacom_features wacom_features_0xDF =
  3948. { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
  3949. BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
  3950. static const struct wacom_features wacom_features_0x300 =
  3951. { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
  3952. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3953. static const struct wacom_features wacom_features_0x301 =
  3954. { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
  3955. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3956. static const struct wacom_features wacom_features_0x302 =
  3957. { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
  3958. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  3959. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3960. static const struct wacom_features wacom_features_0x303 =
  3961. { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
  3962. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  3963. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3964. static const struct wacom_features wacom_features_0x30E =
  3965. { "Wacom Intuos S", 15200, 9500, 1023, 31,
  3966. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  3967. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3968. static const struct wacom_features wacom_features_0x6004 =
  3969. { "ISD-V4", 12800, 8000, 255, 0,
  3970. TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  3971. static const struct wacom_features wacom_features_0x307 =
  3972. { "Wacom ISDv5 307", 59552, 33848, 2047, 63,
  3973. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  3974. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3975. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3976. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
  3977. static const struct wacom_features wacom_features_0x309 =
  3978. { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
  3979. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
  3980. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3981. static const struct wacom_features wacom_features_0x30A =
  3982. { "Wacom ISDv5 30A", 59552, 33848, 2047, 63,
  3983. CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
  3984. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3985. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  3986. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
  3987. static const struct wacom_features wacom_features_0x30C =
  3988. { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */
  3989. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10,
  3990. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  3991. static const struct wacom_features wacom_features_0x318 =
  3992. { "Wacom USB Bamboo PAD", 4095, 4095, /* Touch */
  3993. .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
  3994. static const struct wacom_features wacom_features_0x319 =
  3995. { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
  3996. .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
  3997. static const struct wacom_features wacom_features_0x325 =
  3998. { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
  3999. CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
  4000. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  4001. WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
  4002. .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
  4003. static const struct wacom_features wacom_features_0x326 = /* Touch */
  4004. { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
  4005. .oPid = 0x325 };
  4006. static const struct wacom_features wacom_features_0x323 =
  4007. { "Wacom Intuos P M", 21600, 13500, 1023, 31,
  4008. INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  4009. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  4010. static const struct wacom_features wacom_features_0x331 =
  4011. { "Wacom Express Key Remote", .type = REMOTE,
  4012. .numbered_buttons = 18, .check_for_hid_type = true,
  4013. .hid_type = HID_TYPE_USBNONE };
  4014. static const struct wacom_features wacom_features_0x33B =
  4015. { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
  4016. INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  4017. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  4018. static const struct wacom_features wacom_features_0x33C =
  4019. { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
  4020. INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  4021. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  4022. static const struct wacom_features wacom_features_0x33D =
  4023. { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
  4024. INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
  4025. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  4026. static const struct wacom_features wacom_features_0x33E =
  4027. { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
  4028. INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
  4029. .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
  4030. static const struct wacom_features wacom_features_0x343 =
  4031. { "Wacom DTK1651", 34816, 19759, 1023, 0,
  4032. DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
  4033. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET,
  4034. WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
  4035. static const struct wacom_features wacom_features_0x360 =
  4036. { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
  4037. INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
  4038. static const struct wacom_features wacom_features_0x361 =
  4039. { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
  4040. INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
  4041. static const struct wacom_features wacom_features_0x377 =
  4042. { "Wacom Intuos BT S", 15200, 9500, 4095, 63,
  4043. INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
  4044. static const struct wacom_features wacom_features_0x379 =
  4045. { "Wacom Intuos BT M", 21600, 13500, 4095, 63,
  4046. INTUOSHT3_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4 };
  4047. static const struct wacom_features wacom_features_0x37A =
  4048. { "Wacom One by Wacom S", 15200, 9500, 2047, 63,
  4049. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  4050. static const struct wacom_features wacom_features_0x37B =
  4051. { "Wacom One by Wacom M", 21600, 13500, 2047, 63,
  4052. BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
  4053. static const struct wacom_features wacom_features_HID_ANY_ID =
  4054. { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
  4055. #define USB_DEVICE_WACOM(prod) \
  4056. HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  4057. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  4058. #define BT_DEVICE_WACOM(prod) \
  4059. HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  4060. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  4061. #define I2C_DEVICE_WACOM(prod) \
  4062. HID_DEVICE(BUS_I2C, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
  4063. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  4064. #define USB_DEVICE_LENOVO(prod) \
  4065. HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
  4066. .driver_data = (kernel_ulong_t)&wacom_features_##prod
  4067. const struct hid_device_id wacom_ids[] = {
  4068. { USB_DEVICE_WACOM(0x00) },
  4069. { USB_DEVICE_WACOM(0x03) },
  4070. { USB_DEVICE_WACOM(0x10) },
  4071. { USB_DEVICE_WACOM(0x11) },
  4072. { USB_DEVICE_WACOM(0x12) },
  4073. { USB_DEVICE_WACOM(0x13) },
  4074. { USB_DEVICE_WACOM(0x14) },
  4075. { USB_DEVICE_WACOM(0x15) },
  4076. { USB_DEVICE_WACOM(0x16) },
  4077. { USB_DEVICE_WACOM(0x17) },
  4078. { USB_DEVICE_WACOM(0x18) },
  4079. { USB_DEVICE_WACOM(0x19) },
  4080. { USB_DEVICE_WACOM(0x20) },
  4081. { USB_DEVICE_WACOM(0x21) },
  4082. { USB_DEVICE_WACOM(0x22) },
  4083. { USB_DEVICE_WACOM(0x23) },
  4084. { USB_DEVICE_WACOM(0x24) },
  4085. { USB_DEVICE_WACOM(0x26) },
  4086. { USB_DEVICE_WACOM(0x27) },
  4087. { USB_DEVICE_WACOM(0x28) },
  4088. { USB_DEVICE_WACOM(0x29) },
  4089. { USB_DEVICE_WACOM(0x2A) },
  4090. { USB_DEVICE_WACOM(0x30) },
  4091. { USB_DEVICE_WACOM(0x31) },
  4092. { USB_DEVICE_WACOM(0x32) },
  4093. { USB_DEVICE_WACOM(0x33) },
  4094. { USB_DEVICE_WACOM(0x34) },
  4095. { USB_DEVICE_WACOM(0x35) },
  4096. { USB_DEVICE_WACOM(0x37) },
  4097. { USB_DEVICE_WACOM(0x38) },
  4098. { USB_DEVICE_WACOM(0x39) },
  4099. { USB_DEVICE_WACOM(0x3F) },
  4100. { USB_DEVICE_WACOM(0x41) },
  4101. { USB_DEVICE_WACOM(0x42) },
  4102. { USB_DEVICE_WACOM(0x43) },
  4103. { USB_DEVICE_WACOM(0x44) },
  4104. { USB_DEVICE_WACOM(0x45) },
  4105. { USB_DEVICE_WACOM(0x47) },
  4106. { USB_DEVICE_WACOM(0x57) },
  4107. { USB_DEVICE_WACOM(0x59) },
  4108. { USB_DEVICE_WACOM(0x5B) },
  4109. { USB_DEVICE_WACOM(0x5D) },
  4110. { USB_DEVICE_WACOM(0x5E) },
  4111. { USB_DEVICE_WACOM(0x60) },
  4112. { USB_DEVICE_WACOM(0x61) },
  4113. { USB_DEVICE_WACOM(0x62) },
  4114. { USB_DEVICE_WACOM(0x63) },
  4115. { USB_DEVICE_WACOM(0x64) },
  4116. { USB_DEVICE_WACOM(0x65) },
  4117. { USB_DEVICE_WACOM(0x69) },
  4118. { USB_DEVICE_WACOM(0x6A) },
  4119. { USB_DEVICE_WACOM(0x6B) },
  4120. { BT_DEVICE_WACOM(0x81) },
  4121. { USB_DEVICE_WACOM(0x84) },
  4122. { USB_DEVICE_WACOM(0x90) },
  4123. { USB_DEVICE_WACOM(0x93) },
  4124. { USB_DEVICE_WACOM(0x97) },
  4125. { USB_DEVICE_WACOM(0x9A) },
  4126. { USB_DEVICE_WACOM(0x9F) },
  4127. { USB_DEVICE_WACOM(0xB0) },
  4128. { USB_DEVICE_WACOM(0xB1) },
  4129. { USB_DEVICE_WACOM(0xB2) },
  4130. { USB_DEVICE_WACOM(0xB3) },
  4131. { USB_DEVICE_WACOM(0xB4) },
  4132. { USB_DEVICE_WACOM(0xB5) },
  4133. { USB_DEVICE_WACOM(0xB7) },
  4134. { USB_DEVICE_WACOM(0xB8) },
  4135. { USB_DEVICE_WACOM(0xB9) },
  4136. { USB_DEVICE_WACOM(0xBA) },
  4137. { USB_DEVICE_WACOM(0xBB) },
  4138. { USB_DEVICE_WACOM(0xBC) },
  4139. { BT_DEVICE_WACOM(0xBD) },
  4140. { USB_DEVICE_WACOM(0xC0) },
  4141. { USB_DEVICE_WACOM(0xC2) },
  4142. { USB_DEVICE_WACOM(0xC4) },
  4143. { USB_DEVICE_WACOM(0xC5) },
  4144. { USB_DEVICE_WACOM(0xC6) },
  4145. { USB_DEVICE_WACOM(0xC7) },
  4146. { USB_DEVICE_WACOM(0xCC) },
  4147. { USB_DEVICE_WACOM(0xCE) },
  4148. { USB_DEVICE_WACOM(0xD0) },
  4149. { USB_DEVICE_WACOM(0xD1) },
  4150. { USB_DEVICE_WACOM(0xD2) },
  4151. { USB_DEVICE_WACOM(0xD3) },
  4152. { USB_DEVICE_WACOM(0xD4) },
  4153. { USB_DEVICE_WACOM(0xD5) },
  4154. { USB_DEVICE_WACOM(0xD6) },
  4155. { USB_DEVICE_WACOM(0xD7) },
  4156. { USB_DEVICE_WACOM(0xD8) },
  4157. { USB_DEVICE_WACOM(0xDA) },
  4158. { USB_DEVICE_WACOM(0xDB) },
  4159. { USB_DEVICE_WACOM(0xDD) },
  4160. { USB_DEVICE_WACOM(0xDE) },
  4161. { USB_DEVICE_WACOM(0xDF) },
  4162. { USB_DEVICE_WACOM(0xE2) },
  4163. { USB_DEVICE_WACOM(0xE3) },
  4164. { USB_DEVICE_WACOM(0xE5) },
  4165. { USB_DEVICE_WACOM(0xE6) },
  4166. { USB_DEVICE_WACOM(0xEC) },
  4167. { USB_DEVICE_WACOM(0xED) },
  4168. { USB_DEVICE_WACOM(0xEF) },
  4169. { USB_DEVICE_WACOM(0xF0) },
  4170. { USB_DEVICE_WACOM(0xF4) },
  4171. { USB_DEVICE_WACOM(0xF6) },
  4172. { USB_DEVICE_WACOM(0xF8) },
  4173. { USB_DEVICE_WACOM(0xFA) },
  4174. { USB_DEVICE_WACOM(0xFB) },
  4175. { USB_DEVICE_WACOM(0x100) },
  4176. { USB_DEVICE_WACOM(0x101) },
  4177. { USB_DEVICE_WACOM(0x10D) },
  4178. { USB_DEVICE_WACOM(0x10E) },
  4179. { USB_DEVICE_WACOM(0x10F) },
  4180. { USB_DEVICE_WACOM(0x116) },
  4181. { USB_DEVICE_WACOM(0x12C) },
  4182. { USB_DEVICE_WACOM(0x300) },
  4183. { USB_DEVICE_WACOM(0x301) },
  4184. { USB_DEVICE_WACOM(0x302) },
  4185. { USB_DEVICE_WACOM(0x303) },
  4186. { USB_DEVICE_WACOM(0x304) },
  4187. { USB_DEVICE_WACOM(0x307) },
  4188. { USB_DEVICE_WACOM(0x309) },
  4189. { USB_DEVICE_WACOM(0x30A) },
  4190. { USB_DEVICE_WACOM(0x30C) },
  4191. { USB_DEVICE_WACOM(0x30E) },
  4192. { USB_DEVICE_WACOM(0x314) },
  4193. { USB_DEVICE_WACOM(0x315) },
  4194. { USB_DEVICE_WACOM(0x317) },
  4195. { USB_DEVICE_WACOM(0x318) },
  4196. { USB_DEVICE_WACOM(0x319) },
  4197. { USB_DEVICE_WACOM(0x323) },
  4198. { USB_DEVICE_WACOM(0x325) },
  4199. { USB_DEVICE_WACOM(0x326) },
  4200. { USB_DEVICE_WACOM(0x32A) },
  4201. { USB_DEVICE_WACOM(0x32B) },
  4202. { USB_DEVICE_WACOM(0x32C) },
  4203. { USB_DEVICE_WACOM(0x32F) },
  4204. { USB_DEVICE_WACOM(0x331) },
  4205. { USB_DEVICE_WACOM(0x333) },
  4206. { USB_DEVICE_WACOM(0x335) },
  4207. { USB_DEVICE_WACOM(0x336) },
  4208. { USB_DEVICE_WACOM(0x33B) },
  4209. { USB_DEVICE_WACOM(0x33C) },
  4210. { USB_DEVICE_WACOM(0x33D) },
  4211. { USB_DEVICE_WACOM(0x33E) },
  4212. { USB_DEVICE_WACOM(0x343) },
  4213. { BT_DEVICE_WACOM(0x360) },
  4214. { BT_DEVICE_WACOM(0x361) },
  4215. { BT_DEVICE_WACOM(0x377) },
  4216. { BT_DEVICE_WACOM(0x379) },
  4217. { USB_DEVICE_WACOM(0x37A) },
  4218. { USB_DEVICE_WACOM(0x37B) },
  4219. { USB_DEVICE_WACOM(0x4001) },
  4220. { USB_DEVICE_WACOM(0x4004) },
  4221. { USB_DEVICE_WACOM(0x5000) },
  4222. { USB_DEVICE_WACOM(0x5002) },
  4223. { USB_DEVICE_LENOVO(0x6004) },
  4224. { USB_DEVICE_WACOM(HID_ANY_ID) },
  4225. { I2C_DEVICE_WACOM(HID_ANY_ID) },
  4226. { BT_DEVICE_WACOM(HID_ANY_ID) },
  4227. { }
  4228. };
  4229. MODULE_DEVICE_TABLE(hid, wacom_ids);