wacom_wac.c 100 KB

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