alps.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * ALPS touchpad PS/2 mouse driver
  3. *
  4. * Copyright (c) 2003 Peter Osterlund <petero2@telia.com>
  5. * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #ifndef _ALPS_H
  12. #define _ALPS_H
  13. #include <linux/input/mt.h>
  14. #define ALPS_PROTO_V1 1
  15. #define ALPS_PROTO_V2 2
  16. #define ALPS_PROTO_V3 3
  17. #define ALPS_PROTO_V4 4
  18. #define ALPS_PROTO_V5 5
  19. #define ALPS_PROTO_V6 6
  20. #define ALPS_PROTO_V7 7 /* t3btl t4s */
  21. #define MAX_TOUCHES 2
  22. #define DOLPHIN_COUNT_PER_ELECTRODE 64
  23. #define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */
  24. #define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */
  25. /*
  26. * enum V7_PACKET_ID - defines the packet type for V7
  27. * V7_PACKET_ID_IDLE: There's no finger and no button activity.
  28. * V7_PACKET_ID_TWO: There's one or two non-resting fingers on touchpad
  29. * or there's button activities.
  30. * V7_PACKET_ID_MULTI: There are at least three non-resting fingers.
  31. * V7_PACKET_ID_NEW: The finger position in slot is not continues from
  32. * previous packet.
  33. */
  34. enum V7_PACKET_ID {
  35. V7_PACKET_ID_IDLE,
  36. V7_PACKET_ID_TWO,
  37. V7_PACKET_ID_MULTI,
  38. V7_PACKET_ID_NEW,
  39. V7_PACKET_ID_UNKNOWN,
  40. };
  41. /**
  42. * struct alps_model_info - touchpad ID table
  43. * @signature: E7 response string to match.
  44. * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
  45. * (aka command mode response) identifies the firmware minor version. This
  46. * can be used to distinguish different hardware models which are not
  47. * uniquely identifiable through their E7 responses.
  48. * @proto_version: Indicates V1/V2/V3/...
  49. * @byte0: Helps figure out whether a position report packet matches the
  50. * known format for this model. The first byte of the report, ANDed with
  51. * mask0, should match byte0.
  52. * @mask0: The mask used to check the first byte of the report.
  53. * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
  54. *
  55. * Many (but not all) ALPS touchpads can be identified by looking at the
  56. * values returned in the "E7 report" and/or the "EC report." This table
  57. * lists a number of such touchpads.
  58. */
  59. struct alps_model_info {
  60. unsigned char signature[3];
  61. unsigned char command_mode_resp;
  62. unsigned char proto_version;
  63. unsigned char byte0, mask0;
  64. int flags;
  65. };
  66. /**
  67. * struct alps_nibble_commands - encodings for register accesses
  68. * @command: PS/2 command used for the nibble
  69. * @data: Data supplied as an argument to the PS/2 command, if applicable
  70. *
  71. * The ALPS protocol uses magic sequences to transmit binary data to the
  72. * touchpad, as it is generally not OK to send arbitrary bytes out the
  73. * PS/2 port. Each of the sequences in this table sends one nibble of the
  74. * register address or (write) data. Different versions of the ALPS protocol
  75. * use slightly different encodings.
  76. */
  77. struct alps_nibble_commands {
  78. int command;
  79. unsigned char data;
  80. };
  81. struct alps_bitmap_point {
  82. int start_bit;
  83. int num_bits;
  84. };
  85. /**
  86. * struct alps_fields - decoded version of the report packet
  87. * @x_map: Bitmap of active X positions for MT.
  88. * @y_map: Bitmap of active Y positions for MT.
  89. * @fingers: Number of fingers for MT.
  90. * @pressure: Pressure.
  91. * @st: position for ST.
  92. * @mt: position for MT.
  93. * @first_mp: Packet is the first of a multi-packet report.
  94. * @is_mp: Packet is part of a multi-packet report.
  95. * @left: Left touchpad button is active.
  96. * @right: Right touchpad button is active.
  97. * @middle: Middle touchpad button is active.
  98. * @ts_left: Left trackstick button is active.
  99. * @ts_right: Right trackstick button is active.
  100. * @ts_middle: Middle trackstick button is active.
  101. */
  102. struct alps_fields {
  103. unsigned int x_map;
  104. unsigned int y_map;
  105. unsigned int fingers;
  106. int pressure;
  107. struct input_mt_pos st;
  108. struct input_mt_pos mt[MAX_TOUCHES];
  109. unsigned int first_mp:1;
  110. unsigned int is_mp:1;
  111. unsigned int left:1;
  112. unsigned int right:1;
  113. unsigned int middle:1;
  114. unsigned int ts_left:1;
  115. unsigned int ts_right:1;
  116. unsigned int ts_middle:1;
  117. };
  118. /**
  119. * struct alps_data - private data structure for the ALPS driver
  120. * @dev2: "Relative" device used to report trackstick or mouse activity.
  121. * @phys: Physical path for the relative device.
  122. * @nibble_commands: Command mapping used for touchpad register accesses.
  123. * @addr_command: Command used to tell the touchpad that a register address
  124. * follows.
  125. * @proto_version: Indicates V1/V2/V3/...
  126. * @byte0: Helps figure out whether a position report packet matches the
  127. * known format for this model. The first byte of the report, ANDed with
  128. * mask0, should match byte0.
  129. * @mask0: The mask used to check the first byte of the report.
  130. * @fw_ver: cached copy of firmware version (EC report)
  131. * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
  132. * @x_max: Largest possible X position value.
  133. * @y_max: Largest possible Y position value.
  134. * @x_bits: Number of X bits in the MT bitmap.
  135. * @y_bits: Number of Y bits in the MT bitmap.
  136. * @hw_init: Protocol-specific hardware init function.
  137. * @process_packet: Protocol-specific function to process a report packet.
  138. * @decode_fields: Protocol-specific function to read packet bitfields.
  139. * @set_abs_params: Protocol-specific function to configure the input_dev.
  140. * @prev_fin: Finger bit from previous packet.
  141. * @multi_packet: Multi-packet data in progress.
  142. * @multi_data: Saved multi-packet data.
  143. * @f: Decoded packet data fields.
  144. * @quirks: Bitmap of ALPS_QUIRK_*.
  145. * @timer: Timer for flushing out the final report packet in the stream.
  146. */
  147. struct alps_data {
  148. struct input_dev *dev2;
  149. char phys[32];
  150. /* these are autodetected when the device is identified */
  151. const struct alps_nibble_commands *nibble_commands;
  152. int addr_command;
  153. unsigned char proto_version;
  154. unsigned char byte0, mask0;
  155. unsigned char fw_ver[3];
  156. int flags;
  157. int x_max;
  158. int y_max;
  159. int x_bits;
  160. int y_bits;
  161. unsigned int x_res;
  162. unsigned int y_res;
  163. int (*hw_init)(struct psmouse *psmouse);
  164. void (*process_packet)(struct psmouse *psmouse);
  165. int (*decode_fields)(struct alps_fields *f, unsigned char *p,
  166. struct psmouse *psmouse);
  167. void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
  168. int prev_fin;
  169. int multi_packet;
  170. unsigned char multi_data[6];
  171. struct alps_fields f;
  172. u8 quirks;
  173. struct timer_list timer;
  174. };
  175. #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
  176. #ifdef CONFIG_MOUSE_PS2_ALPS
  177. int alps_detect(struct psmouse *psmouse, bool set_properties);
  178. int alps_init(struct psmouse *psmouse);
  179. #else
  180. inline int alps_detect(struct psmouse *psmouse, bool set_properties)
  181. {
  182. return -ENOSYS;
  183. }
  184. inline int alps_init(struct psmouse *psmouse)
  185. {
  186. return -ENOSYS;
  187. }
  188. #endif /* CONFIG_MOUSE_PS2_ALPS */
  189. #endif