wacom_wac.c 98 KB

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