wacom_wac.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. /*
  2. * drivers/input/tablet/wacom_wac.h
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #ifndef WACOM_WAC_H
  10. #define WACOM_WAC_H
  11. #include <linux/types.h>
  12. #include <linux/hid.h>
  13. #include <linux/kfifo.h>
  14. /* maximum packet length for USB/BT devices */
  15. #define WACOM_PKGLEN_MAX 361
  16. #define WACOM_NAME_MAX 64
  17. #define WACOM_MAX_REMOTES 5
  18. #define WACOM_STATUS_UNKNOWN 255
  19. /* packet length for individual models */
  20. #define WACOM_PKGLEN_BBFUN 9
  21. #define WACOM_PKGLEN_TPC1FG 5
  22. #define WACOM_PKGLEN_TPC1FG_B 10
  23. #define WACOM_PKGLEN_TPC2FG 14
  24. #define WACOM_PKGLEN_BBTOUCH 20
  25. #define WACOM_PKGLEN_BBTOUCH3 64
  26. #define WACOM_PKGLEN_BBPEN 10
  27. #define WACOM_PKGLEN_WIRELESS 32
  28. #define WACOM_PKGLEN_PENABLED 8
  29. #define WACOM_PKGLEN_BPAD_TOUCH 32
  30. #define WACOM_PKGLEN_BPAD_TOUCH_USB 64
  31. /* wacom data size per MT contact */
  32. #define WACOM_BYTES_PER_MT_PACKET 11
  33. #define WACOM_BYTES_PER_24HDT_PACKET 14
  34. #define WACOM_BYTES_PER_QHDTHID_PACKET 6
  35. /* device IDs */
  36. #define STYLUS_DEVICE_ID 0x02
  37. #define TOUCH_DEVICE_ID 0x03
  38. #define CURSOR_DEVICE_ID 0x06
  39. #define ERASER_DEVICE_ID 0x0A
  40. #define PAD_DEVICE_ID 0x0F
  41. /* wacom data packet report IDs */
  42. #define WACOM_REPORT_PENABLED 2
  43. #define WACOM_REPORT_PENABLED_BT 3
  44. #define WACOM_REPORT_INTUOS_ID1 5
  45. #define WACOM_REPORT_INTUOS_ID2 6
  46. #define WACOM_REPORT_INTUOSPAD 12
  47. #define WACOM_REPORT_INTUOS5PAD 3
  48. #define WACOM_REPORT_DTUSPAD 21
  49. #define WACOM_REPORT_TPC1FG 6
  50. #define WACOM_REPORT_TPC2FG 13
  51. #define WACOM_REPORT_TPCMT 13
  52. #define WACOM_REPORT_TPCMT2 3
  53. #define WACOM_REPORT_TPCHID 15
  54. #define WACOM_REPORT_CINTIQ 16
  55. #define WACOM_REPORT_CINTIQPAD 17
  56. #define WACOM_REPORT_TPCST 16
  57. #define WACOM_REPORT_DTUS 17
  58. #define WACOM_REPORT_TPC1FGE 18
  59. #define WACOM_REPORT_24HDT 1
  60. #define WACOM_REPORT_WL 128
  61. #define WACOM_REPORT_USB 192
  62. #define WACOM_REPORT_BPAD_PEN 3
  63. #define WACOM_REPORT_BPAD_TOUCH 16
  64. #define WACOM_REPORT_DEVICE_LIST 16
  65. #define WACOM_REPORT_INTUOS_PEN 16
  66. #define WACOM_REPORT_REMOTE 17
  67. #define WACOM_REPORT_INTUOSHT2_ID 8
  68. /* wacom command report ids */
  69. #define WAC_CMD_WL_LED_CONTROL 0x03
  70. #define WAC_CMD_LED_CONTROL 0x20
  71. #define WAC_CMD_ICON_START 0x21
  72. #define WAC_CMD_ICON_XFER 0x23
  73. #define WAC_CMD_ICON_BT_XFER 0x26
  74. #define WAC_CMD_DELETE_PAIRING 0x20
  75. #define WAC_CMD_LED_CONTROL_GENERIC 0x32
  76. #define WAC_CMD_UNPAIR_ALL 0xFF
  77. #define WAC_CMD_WL_INTUOSP2 0x82
  78. /* device quirks */
  79. #define WACOM_QUIRK_BBTOUCH_LOWRES 0x0001
  80. #define WACOM_QUIRK_SENSE 0x0002
  81. #define WACOM_QUIRK_AESPEN 0x0004
  82. #define WACOM_QUIRK_BATTERY 0x0008
  83. #define WACOM_QUIRK_TOOLSERIAL 0x0010
  84. /* device types */
  85. #define WACOM_DEVICETYPE_NONE 0x0000
  86. #define WACOM_DEVICETYPE_PEN 0x0001
  87. #define WACOM_DEVICETYPE_TOUCH 0x0002
  88. #define WACOM_DEVICETYPE_PAD 0x0004
  89. #define WACOM_DEVICETYPE_WL_MONITOR 0x0008
  90. #define WACOM_DEVICETYPE_DIRECT 0x0010
  91. #define WACOM_POWER_SUPPLY_STATUS_AUTO -1
  92. #define WACOM_HID_UP_WACOMDIGITIZER 0xff0d0000
  93. #define WACOM_HID_SP_PAD 0x00040000
  94. #define WACOM_HID_SP_BUTTON 0x00090000
  95. #define WACOM_HID_SP_DIGITIZER 0x000d0000
  96. #define WACOM_HID_SP_DIGITIZERINFO 0x00100000
  97. #define WACOM_HID_WD_DIGITIZER (WACOM_HID_UP_WACOMDIGITIZER | 0x01)
  98. #define WACOM_HID_WD_PEN (WACOM_HID_UP_WACOMDIGITIZER | 0x02)
  99. #define WACOM_HID_WD_SENSE (WACOM_HID_UP_WACOMDIGITIZER | 0x36)
  100. #define WACOM_HID_WD_DIGITIZERFNKEYS (WACOM_HID_UP_WACOMDIGITIZER | 0x39)
  101. #define WACOM_HID_WD_SERIALNUMBER (WACOM_HID_UP_WACOMDIGITIZER | 0x5b)
  102. #define WACOM_HID_WD_SERIALHI (WACOM_HID_UP_WACOMDIGITIZER | 0x5c)
  103. #define WACOM_HID_WD_TOOLTYPE (WACOM_HID_UP_WACOMDIGITIZER | 0x77)
  104. #define WACOM_HID_WD_DISTANCE (WACOM_HID_UP_WACOMDIGITIZER | 0x0132)
  105. #define WACOM_HID_WD_TOUCHSTRIP (WACOM_HID_UP_WACOMDIGITIZER | 0x0136)
  106. #define WACOM_HID_WD_TOUCHSTRIP2 (WACOM_HID_UP_WACOMDIGITIZER | 0x0137)
  107. #define WACOM_HID_WD_TOUCHRING (WACOM_HID_UP_WACOMDIGITIZER | 0x0138)
  108. #define WACOM_HID_WD_TOUCHRINGSTATUS (WACOM_HID_UP_WACOMDIGITIZER | 0x0139)
  109. #define WACOM_HID_WD_REPORT_VALID (WACOM_HID_UP_WACOMDIGITIZER | 0x01d0)
  110. #define WACOM_HID_WD_ACCELEROMETER_X (WACOM_HID_UP_WACOMDIGITIZER | 0x0401)
  111. #define WACOM_HID_WD_ACCELEROMETER_Y (WACOM_HID_UP_WACOMDIGITIZER | 0x0402)
  112. #define WACOM_HID_WD_ACCELEROMETER_Z (WACOM_HID_UP_WACOMDIGITIZER | 0x0403)
  113. #define WACOM_HID_WD_BATTERY_CHARGING (WACOM_HID_UP_WACOMDIGITIZER | 0x0404)
  114. #define WACOM_HID_WD_TOUCHONOFF (WACOM_HID_UP_WACOMDIGITIZER | 0x0454)
  115. #define WACOM_HID_WD_BATTERY_LEVEL (WACOM_HID_UP_WACOMDIGITIZER | 0x043b)
  116. #define WACOM_HID_WD_EXPRESSKEY00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0910)
  117. #define WACOM_HID_WD_EXPRESSKEYCAP00 (WACOM_HID_UP_WACOMDIGITIZER | 0x0950)
  118. #define WACOM_HID_WD_MODE_CHANGE (WACOM_HID_UP_WACOMDIGITIZER | 0x0980)
  119. #define WACOM_HID_WD_MUTE_DEVICE (WACOM_HID_UP_WACOMDIGITIZER | 0x0981)
  120. #define WACOM_HID_WD_CONTROLPANEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0982)
  121. #define WACOM_HID_WD_ONSCREEN_KEYBOARD (WACOM_HID_UP_WACOMDIGITIZER | 0x0983)
  122. #define WACOM_HID_WD_BUTTONCONFIG (WACOM_HID_UP_WACOMDIGITIZER | 0x0986)
  123. #define WACOM_HID_WD_BUTTONHOME (WACOM_HID_UP_WACOMDIGITIZER | 0x0990)
  124. #define WACOM_HID_WD_BUTTONUP (WACOM_HID_UP_WACOMDIGITIZER | 0x0991)
  125. #define WACOM_HID_WD_BUTTONDOWN (WACOM_HID_UP_WACOMDIGITIZER | 0x0992)
  126. #define WACOM_HID_WD_BUTTONLEFT (WACOM_HID_UP_WACOMDIGITIZER | 0x0993)
  127. #define WACOM_HID_WD_BUTTONRIGHT (WACOM_HID_UP_WACOMDIGITIZER | 0x0994)
  128. #define WACOM_HID_WD_BUTTONCENTER (WACOM_HID_UP_WACOMDIGITIZER | 0x0995)
  129. #define WACOM_HID_WD_FINGERWHEEL (WACOM_HID_UP_WACOMDIGITIZER | 0x0d03)
  130. #define WACOM_HID_WD_OFFSETLEFT (WACOM_HID_UP_WACOMDIGITIZER | 0x0d30)
  131. #define WACOM_HID_WD_OFFSETTOP (WACOM_HID_UP_WACOMDIGITIZER | 0x0d31)
  132. #define WACOM_HID_WD_OFFSETRIGHT (WACOM_HID_UP_WACOMDIGITIZER | 0x0d32)
  133. #define WACOM_HID_WD_OFFSETBOTTOM (WACOM_HID_UP_WACOMDIGITIZER | 0x0d33)
  134. #define WACOM_HID_WD_DATAMODE (WACOM_HID_UP_WACOMDIGITIZER | 0x1002)
  135. #define WACOM_HID_WD_DIGITIZERINFO (WACOM_HID_UP_WACOMDIGITIZER | 0x1013)
  136. #define WACOM_HID_WD_TOUCH_RING_SETTING (WACOM_HID_UP_WACOMDIGITIZER | 0x1032)
  137. #define WACOM_HID_UP_G9 0xff090000
  138. #define WACOM_HID_G9_PEN (WACOM_HID_UP_G9 | 0x02)
  139. #define WACOM_HID_G9_TOUCHSCREEN (WACOM_HID_UP_G9 | 0x11)
  140. #define WACOM_HID_UP_G11 0xff110000
  141. #define WACOM_HID_G11_PEN (WACOM_HID_UP_G11 | 0x02)
  142. #define WACOM_HID_G11_TOUCHSCREEN (WACOM_HID_UP_G11 | 0x11)
  143. #define WACOM_HID_UP_WACOMTOUCH 0xff000000
  144. #define WACOM_HID_WT_TOUCHSCREEN (WACOM_HID_UP_WACOMTOUCH | 0x04)
  145. #define WACOM_HID_WT_TOUCHPAD (WACOM_HID_UP_WACOMTOUCH | 0x05)
  146. #define WACOM_HID_WT_CONTACTMAX (WACOM_HID_UP_WACOMTOUCH | 0x55)
  147. #define WACOM_HID_WT_SERIALNUMBER (WACOM_HID_UP_WACOMTOUCH | 0x5b)
  148. #define WACOM_HID_WT_X (WACOM_HID_UP_WACOMTOUCH | 0x130)
  149. #define WACOM_HID_WT_Y (WACOM_HID_UP_WACOMTOUCH | 0x131)
  150. #define WACOM_BATTERY_USAGE(f) (((f)->hid == HID_DG_BATTERYSTRENGTH) || \
  151. ((f)->hid == WACOM_HID_WD_BATTERY_CHARGING) || \
  152. ((f)->hid == WACOM_HID_WD_BATTERY_LEVEL))
  153. #define WACOM_PAD_FIELD(f) (((f)->physical == HID_DG_TABLETFUNCTIONKEY) || \
  154. ((f)->physical == WACOM_HID_WD_DIGITIZERFNKEYS) || \
  155. ((f)->physical == WACOM_HID_WD_DIGITIZERINFO))
  156. #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
  157. ((f)->physical == HID_DG_STYLUS) || \
  158. ((f)->physical == HID_DG_PEN) || \
  159. ((f)->application == HID_DG_PEN) || \
  160. ((f)->application == HID_DG_DIGITIZER) || \
  161. ((f)->application == WACOM_HID_WD_PEN) || \
  162. ((f)->application == WACOM_HID_WD_DIGITIZER) || \
  163. ((f)->application == WACOM_HID_G9_PEN) || \
  164. ((f)->application == WACOM_HID_G11_PEN))
  165. #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
  166. ((f)->physical == HID_DG_FINGER) || \
  167. ((f)->application == HID_DG_TOUCHSCREEN) || \
  168. ((f)->application == WACOM_HID_G9_TOUCHSCREEN) || \
  169. ((f)->application == WACOM_HID_G11_TOUCHSCREEN) || \
  170. ((f)->application == WACOM_HID_WT_TOUCHPAD) || \
  171. ((f)->application == HID_DG_TOUCHPAD))
  172. #define WACOM_DIRECT_DEVICE(f) (((f)->application == HID_DG_TOUCHSCREEN) || \
  173. ((f)->application == WACOM_HID_WT_TOUCHSCREEN) || \
  174. ((f)->application == HID_DG_PEN) || \
  175. ((f)->application == WACOM_HID_WD_PEN))
  176. enum {
  177. PENPARTNER = 0,
  178. GRAPHIRE,
  179. GRAPHIRE_BT,
  180. WACOM_G4,
  181. PTU,
  182. PL,
  183. DTU,
  184. DTUS,
  185. DTUSX,
  186. INTUOS,
  187. INTUOS3S,
  188. INTUOS3,
  189. INTUOS3L,
  190. INTUOS4S,
  191. INTUOS4,
  192. INTUOS4WL,
  193. INTUOS4L,
  194. INTUOS5S,
  195. INTUOS5,
  196. INTUOS5L,
  197. INTUOSPS,
  198. INTUOSPM,
  199. INTUOSPL,
  200. INTUOSP2_BT,
  201. INTUOSHT3_BT,
  202. WACOM_21UX2,
  203. WACOM_22HD,
  204. DTK,
  205. WACOM_24HD,
  206. WACOM_27QHD,
  207. CINTIQ_HYBRID,
  208. CINTIQ_COMPANION_2,
  209. CINTIQ,
  210. WACOM_BEE,
  211. WACOM_13HD,
  212. WACOM_MO,
  213. BAMBOO_PEN,
  214. INTUOSHT,
  215. INTUOSHT2,
  216. BAMBOO_TOUCH,
  217. BAMBOO_PT,
  218. WACOM_24HDT,
  219. WACOM_27QHDT,
  220. BAMBOO_PAD,
  221. WIRELESS,
  222. REMOTE,
  223. TABLETPC, /* add new TPC below */
  224. TABLETPCE,
  225. TABLETPC2FG,
  226. MTSCREEN,
  227. MTTPC,
  228. MTTPC_B,
  229. HID_GENERIC,
  230. MAX_TYPE
  231. };
  232. struct wacom_features {
  233. const char *name;
  234. int x_max;
  235. int y_max;
  236. int pressure_max;
  237. int distance_max;
  238. int type;
  239. int x_resolution;
  240. int y_resolution;
  241. int numbered_buttons;
  242. int offset_left;
  243. int offset_right;
  244. int offset_top;
  245. int offset_bottom;
  246. int device_type;
  247. int x_phy;
  248. int y_phy;
  249. unsigned unit;
  250. int unitExpo;
  251. int x_fuzz;
  252. int y_fuzz;
  253. int pressure_fuzz;
  254. int distance_fuzz;
  255. int tilt_fuzz;
  256. unsigned quirks;
  257. unsigned touch_max;
  258. int oVid;
  259. int oPid;
  260. int pktlen;
  261. bool check_for_hid_type;
  262. int hid_type;
  263. };
  264. struct wacom_shared {
  265. bool stylus_in_proximity;
  266. bool touch_down;
  267. /* for wireless device to access USB interfaces */
  268. unsigned touch_max;
  269. int type;
  270. struct input_dev *touch_input;
  271. struct hid_device *pen;
  272. struct hid_device *touch;
  273. bool has_mute_touch_switch;
  274. bool is_touch_on;
  275. };
  276. struct hid_data {
  277. __s16 inputmode; /* InputMode HID feature, -1 if non-existent */
  278. __s16 inputmode_index; /* InputMode HID feature index in the report */
  279. bool sense_state;
  280. bool inrange_state;
  281. bool invert_state;
  282. bool tipswitch;
  283. bool barrelswitch;
  284. bool barrelswitch2;
  285. int x;
  286. int y;
  287. int pressure;
  288. int width;
  289. int height;
  290. int id;
  291. int cc_report;
  292. int cc_index;
  293. int cc_value_index;
  294. int last_slot_field;
  295. int num_expected;
  296. int num_received;
  297. int bat_status;
  298. int battery_capacity;
  299. int bat_charging;
  300. int bat_connected;
  301. int ps_connected;
  302. bool pad_input_event_flag;
  303. };
  304. struct wacom_remote_data {
  305. struct {
  306. u32 serial;
  307. bool connected;
  308. } remote[WACOM_MAX_REMOTES];
  309. };
  310. struct wacom_wac {
  311. char name[WACOM_NAME_MAX];
  312. char pen_name[WACOM_NAME_MAX];
  313. char touch_name[WACOM_NAME_MAX];
  314. char pad_name[WACOM_NAME_MAX];
  315. unsigned char data[WACOM_PKGLEN_MAX];
  316. int tool[2];
  317. int id[2];
  318. __u64 serial[2];
  319. bool reporting_data;
  320. struct wacom_features features;
  321. struct wacom_shared *shared;
  322. struct input_dev *pen_input;
  323. struct input_dev *touch_input;
  324. struct input_dev *pad_input;
  325. struct kfifo_rec_ptr_2 pen_fifo;
  326. int pid;
  327. int num_contacts_left;
  328. u8 bt_features;
  329. u8 bt_high_speed;
  330. int mode_report;
  331. int mode_value;
  332. struct hid_data hid_data;
  333. bool has_mute_touch_switch;
  334. bool has_mode_change;
  335. bool is_direct_mode;
  336. bool is_invalid_bt_frame;
  337. };
  338. #endif