alps.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #define ALPS_PROTO_V1 1
  14. #define ALPS_PROTO_V2 2
  15. #define ALPS_PROTO_V3 3
  16. #define ALPS_PROTO_V4 4
  17. #define ALPS_PROTO_V5 5
  18. #define ALPS_PROTO_V6 6
  19. #define DOLPHIN_COUNT_PER_ELECTRODE 64
  20. #define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */
  21. #define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */
  22. /**
  23. * struct alps_model_info - touchpad ID table
  24. * @signature: E7 response string to match.
  25. * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
  26. * (aka command mode response) identifies the firmware minor version. This
  27. * can be used to distinguish different hardware models which are not
  28. * uniquely identifiable through their E7 responses.
  29. * @proto_version: Indicates V1/V2/V3/...
  30. * @byte0: Helps figure out whether a position report packet matches the
  31. * known format for this model. The first byte of the report, ANDed with
  32. * mask0, should match byte0.
  33. * @mask0: The mask used to check the first byte of the report.
  34. * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
  35. *
  36. * Many (but not all) ALPS touchpads can be identified by looking at the
  37. * values returned in the "E7 report" and/or the "EC report." This table
  38. * lists a number of such touchpads.
  39. */
  40. struct alps_model_info {
  41. unsigned char signature[3];
  42. unsigned char command_mode_resp;
  43. unsigned char proto_version;
  44. unsigned char byte0, mask0;
  45. unsigned char flags;
  46. };
  47. /**
  48. * struct alps_nibble_commands - encodings for register accesses
  49. * @command: PS/2 command used for the nibble
  50. * @data: Data supplied as an argument to the PS/2 command, if applicable
  51. *
  52. * The ALPS protocol uses magic sequences to transmit binary data to the
  53. * touchpad, as it is generally not OK to send arbitrary bytes out the
  54. * PS/2 port. Each of the sequences in this table sends one nibble of the
  55. * register address or (write) data. Different versions of the ALPS protocol
  56. * use slightly different encodings.
  57. */
  58. struct alps_nibble_commands {
  59. int command;
  60. unsigned char data;
  61. };
  62. /**
  63. * struct alps_fields - decoded version of the report packet
  64. * @x_map: Bitmap of active X positions for MT.
  65. * @y_map: Bitmap of active Y positions for MT.
  66. * @fingers: Number of fingers for MT.
  67. * @x: X position for ST.
  68. * @y: Y position for ST.
  69. * @z: Z position for ST.
  70. * @first_mp: Packet is the first of a multi-packet report.
  71. * @is_mp: Packet is part of a multi-packet report.
  72. * @left: Left touchpad button is active.
  73. * @right: Right touchpad button is active.
  74. * @middle: Middle touchpad button is active.
  75. * @ts_left: Left trackstick button is active.
  76. * @ts_right: Right trackstick button is active.
  77. * @ts_middle: Middle trackstick button is active.
  78. */
  79. struct alps_fields {
  80. unsigned int x_map;
  81. unsigned int y_map;
  82. unsigned int fingers;
  83. unsigned int x;
  84. unsigned int y;
  85. unsigned int z;
  86. unsigned int first_mp:1;
  87. unsigned int is_mp:1;
  88. unsigned int left:1;
  89. unsigned int right:1;
  90. unsigned int middle:1;
  91. unsigned int ts_left:1;
  92. unsigned int ts_right:1;
  93. unsigned int ts_middle:1;
  94. };
  95. /**
  96. * struct alps_data - private data structure for the ALPS driver
  97. * @dev2: "Relative" device used to report trackstick or mouse activity.
  98. * @phys: Physical path for the relative device.
  99. * @nibble_commands: Command mapping used for touchpad register accesses.
  100. * @addr_command: Command used to tell the touchpad that a register address
  101. * follows.
  102. * @proto_version: Indicates V1/V2/V3/...
  103. * @byte0: Helps figure out whether a position report packet matches the
  104. * known format for this model. The first byte of the report, ANDed with
  105. * mask0, should match byte0.
  106. * @mask0: The mask used to check the first byte of the report.
  107. * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
  108. * @x_max: Largest possible X position value.
  109. * @y_max: Largest possible Y position value.
  110. * @x_bits: Number of X bits in the MT bitmap.
  111. * @y_bits: Number of Y bits in the MT bitmap.
  112. * @hw_init: Protocol-specific hardware init function.
  113. * @process_packet: Protocol-specific function to process a report packet.
  114. * @decode_fields: Protocol-specific function to read packet bitfields.
  115. * @set_abs_params: Protocol-specific function to configure the input_dev.
  116. * @prev_fin: Finger bit from previous packet.
  117. * @multi_packet: Multi-packet data in progress.
  118. * @multi_data: Saved multi-packet data.
  119. * @x1: First X coordinate from last MT report.
  120. * @x2: Second X coordinate from last MT report.
  121. * @y1: First Y coordinate from last MT report.
  122. * @y2: Second Y coordinate from last MT report.
  123. * @fingers: Number of fingers from last MT report.
  124. * @quirks: Bitmap of ALPS_QUIRK_*.
  125. * @timer: Timer for flushing out the final report packet in the stream.
  126. */
  127. struct alps_data {
  128. struct input_dev *dev2;
  129. char phys[32];
  130. /* these are autodetected when the device is identified */
  131. const struct alps_nibble_commands *nibble_commands;
  132. int addr_command;
  133. unsigned char proto_version;
  134. unsigned char byte0, mask0;
  135. unsigned char flags;
  136. int x_max;
  137. int y_max;
  138. int x_bits;
  139. int y_bits;
  140. int (*hw_init)(struct psmouse *psmouse);
  141. void (*process_packet)(struct psmouse *psmouse);
  142. void (*decode_fields)(struct alps_fields *f, unsigned char *p,
  143. struct psmouse *psmouse);
  144. void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
  145. int prev_fin;
  146. int multi_packet;
  147. unsigned char multi_data[6];
  148. int x1, x2, y1, y2;
  149. int fingers;
  150. u8 quirks;
  151. struct timer_list timer;
  152. };
  153. #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
  154. #ifdef CONFIG_MOUSE_PS2_ALPS
  155. int alps_detect(struct psmouse *psmouse, bool set_properties);
  156. int alps_init(struct psmouse *psmouse);
  157. #else
  158. inline int alps_detect(struct psmouse *psmouse, bool set_properties)
  159. {
  160. return -ENOSYS;
  161. }
  162. inline int alps_init(struct psmouse *psmouse)
  163. {
  164. return -ENOSYS;
  165. }
  166. #endif /* CONFIG_MOUSE_PS2_ALPS */
  167. #endif