alps.txt 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. ALPS Touchpad Protocol
  2. ----------------------
  3. Introduction
  4. ------------
  5. Currently the ALPS touchpad driver supports five protocol versions in use by
  6. ALPS touchpads, called versions 1, 2, 3, 4 and 5.
  7. Since roughly mid-2010 several new ALPS touchpads have been released and
  8. integrated into a variety of laptops and netbooks. These new touchpads
  9. have enough behavior differences that the alps_model_data definition
  10. table, describing the properties of the different versions, is no longer
  11. adequate. The design choices were to re-define the alps_model_data
  12. table, with the risk of regression testing existing devices, or isolate
  13. the new devices outside of the alps_model_data table. The latter design
  14. choice was made. The new touchpad signatures are named: "Rushmore",
  15. "Pinnacle", and "Dolphin", which you will see in the alps.c code.
  16. For the purposes of this document, this group of ALPS touchpads will
  17. generically be called "new ALPS touchpads".
  18. We experimented with probing the ACPI interface _HID (Hardware ID)/_CID
  19. (Compatibility ID) definition as a way to uniquely identify the
  20. different ALPS variants but there did not appear to be a 1:1 mapping.
  21. In fact, it appeared to be an m:n mapping between the _HID and actual
  22. hardware type.
  23. Detection
  24. ---------
  25. All ALPS touchpads should respond to the "E6 report" command sequence:
  26. E8-E6-E6-E6-E9. An ALPS touchpad should respond with either 00-00-0A or
  27. 00-00-64 if no buttons are pressed. The bits 0-2 of the first byte will be 1s
  28. if some buttons are pressed.
  29. If the E6 report is successful, the touchpad model is identified using the "E7
  30. report" sequence: E8-E7-E7-E7-E9. The response is the model signature and is
  31. matched against known models in the alps_model_data_array.
  32. For older touchpads supporting protocol versions 3 and 4, the E7 report
  33. model signature is always 73-02-64. To differentiate between these
  34. versions, the response from the "Enter Command Mode" sequence must be
  35. inspected as described below.
  36. The new ALPS touchpads have an E7 signature of 73-03-50 or 73-03-0A but
  37. seem to be better differentiated by the EC Command Mode response.
  38. Command Mode
  39. ------------
  40. Protocol versions 3 and 4 have a command mode that is used to read and write
  41. one-byte device registers in a 16-bit address space. The command sequence
  42. EC-EC-EC-E9 places the device in command mode, and the device will respond
  43. with 88-07 followed by a third byte. This third byte can be used to determine
  44. whether the devices uses the version 3 or 4 protocol.
  45. To exit command mode, PSMOUSE_CMD_SETSTREAM (EA) is sent to the touchpad.
  46. While in command mode, register addresses can be set by first sending a
  47. specific command, either EC for v3 devices or F5 for v4 devices. Then the
  48. address is sent one nibble at a time, where each nibble is encoded as a
  49. command with optional data. This enoding differs slightly between the v3 and
  50. v4 protocols.
  51. Once an address has been set, the addressed register can be read by sending
  52. PSMOUSE_CMD_GETINFO (E9). The first two bytes of the response contains the
  53. address of the register being read, and the third contains the value of the
  54. register. Registers are written by writing the value one nibble at a time
  55. using the same encoding used for addresses.
  56. For the new ALPS touchpads, the EC command is used to enter command
  57. mode. The response in the new ALPS touchpads is significantly different,
  58. and more important in determining the behavior. This code has been
  59. separated from the original alps_model_data table and put in the
  60. alps_identify function. For example, there seem to be two hardware init
  61. sequences for the "Dolphin" touchpads as determined by the second byte
  62. of the EC response.
  63. Packet Format
  64. -------------
  65. In the following tables, the following notation is used.
  66. CAPITALS = stick, miniscules = touchpad
  67. ?'s can have different meanings on different models, such as wheel rotation,
  68. extra buttons, stick buttons on a dualpoint, etc.
  69. PS/2 packet format
  70. ------------------
  71. byte 0: 0 0 YSGN XSGN 1 M R L
  72. byte 1: X7 X6 X5 X4 X3 X2 X1 X0
  73. byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
  74. Note that the device never signals overflow condition.
  75. ALPS Absolute Mode - Protocol Verion 1
  76. --------------------------------------
  77. byte 0: 1 0 0 0 1 x9 x8 x7
  78. byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  79. byte 2: 0 ? ? l r ? fin ges
  80. byte 3: 0 ? ? ? ? y9 y8 y7
  81. byte 4: 0 y6 y5 y4 y3 y2 y1 y0
  82. byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  83. ALPS Absolute Mode - Protocol Version 2
  84. ---------------------------------------
  85. byte 0: 1 ? ? ? 1 ? ? ?
  86. byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  87. byte 2: 0 x10 x9 x8 x7 ? fin ges
  88. byte 3: 0 y9 y8 y7 1 M R L
  89. byte 4: 0 y6 y5 y4 y3 y2 y1 y0
  90. byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  91. Dualpoint device -- interleaved packet format
  92. ---------------------------------------------
  93. byte 0: 1 1 0 0 1 1 1 1
  94. byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  95. byte 2: 0 x10 x9 x8 x7 0 fin ges
  96. byte 3: 0 0 YSGN XSGN 1 1 1 1
  97. byte 4: X7 X6 X5 X4 X3 X2 X1 X0
  98. byte 5: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
  99. byte 6: 0 y9 y8 y7 1 m r l
  100. byte 7: 0 y6 y5 y4 y3 y2 y1 y0
  101. byte 8: 0 z6 z5 z4 z3 z2 z1 z0
  102. ALPS Absolute Mode - Protocol Version 3
  103. ---------------------------------------
  104. ALPS protocol version 3 has three different packet formats. The first two are
  105. associated with touchpad events, and the third is associatd with trackstick
  106. events.
  107. The first type is the touchpad position packet.
  108. byte 0: 1 ? x1 x0 1 1 1 1
  109. byte 1: 0 x10 x9 x8 x7 x6 x5 x4
  110. byte 2: 0 y10 y9 y8 y7 y6 y5 y4
  111. byte 3: 0 M R L 1 m r l
  112. byte 4: 0 mt x3 x2 y3 y2 y1 y0
  113. byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  114. Note that for some devices the trackstick buttons are reported in this packet,
  115. and on others it is reported in the trackstick packets.
  116. The second packet type contains bitmaps representing the x and y axes. In the
  117. bitmaps a given bit is set if there is a finger covering that position on the
  118. given axis. Thus the bitmap packet can be used for low-resolution multi-touch
  119. data, although finger tracking is not possible. This packet also encodes the
  120. number of contacts (f1 and f0 in the table below).
  121. byte 0: 1 1 x1 x0 1 1 1 1
  122. byte 1: 0 x8 x7 x6 x5 x4 x3 x2
  123. byte 2: 0 y7 y6 y5 y4 y3 y2 y1
  124. byte 3: 0 y10 y9 y8 1 1 1 1
  125. byte 4: 0 x14 x13 x12 x11 x10 x9 y0
  126. byte 5: 0 1 ? ? ? ? f1 f0
  127. This packet only appears after a position packet with the mt bit set, and
  128. usually only appears when there are two or more contacts (although
  129. occasionally it's seen with only a single contact).
  130. The final v3 packet type is the trackstick packet.
  131. byte 0: 1 1 x7 y7 1 1 1 1
  132. byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  133. byte 2: 0 y6 y5 y4 y3 y2 y1 y0
  134. byte 3: 0 1 0 0 1 0 0 0
  135. byte 4: 0 z4 z3 z2 z1 z0 ? ?
  136. byte 5: 0 0 1 1 1 1 1 1
  137. ALPS Absolute Mode - Protocol Version 4
  138. ---------------------------------------
  139. Protocol version 4 has an 8-byte packet format.
  140. byte 0: 1 ? x1 x0 1 1 1 1
  141. byte 1: 0 x10 x9 x8 x7 x6 x5 x4
  142. byte 2: 0 y10 y9 y8 y7 y6 y5 y4
  143. byte 3: 0 1 x3 x2 y3 y2 y1 y0
  144. byte 4: 0 ? ? ? 1 ? r l
  145. byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  146. byte 6: bitmap data (described below)
  147. byte 7: bitmap data (described below)
  148. The last two bytes represent a partial bitmap packet, with 3 full packets
  149. required to construct a complete bitmap packet. Once assembled, the 6-byte
  150. bitmap packet has the following format:
  151. byte 0: 0 1 x7 x6 x5 x4 x3 x2
  152. byte 1: 0 x1 x0 y4 y3 y2 y1 y0
  153. byte 2: 0 0 ? x14 x13 x12 x11 x10
  154. byte 3: 0 x9 x8 y9 y8 y7 y6 y5
  155. byte 4: 0 0 0 0 0 0 0 0
  156. byte 5: 0 0 0 0 0 0 0 y10
  157. There are several things worth noting here.
  158. 1) In the bitmap data, bit 6 of byte 0 serves as a sync byte to
  159. identify the first fragment of a bitmap packet.
  160. 2) The bitmaps represent the same data as in the v3 bitmap packets, although
  161. the packet layout is different.
  162. 3) There doesn't seem to be a count of the contact points anywhere in the v4
  163. protocol packets. Deriving a count of contact points must be done by
  164. analyzing the bitmaps.
  165. 4) There is a 3 to 1 ratio of position packets to bitmap packets. Therefore
  166. MT position can only be updated for every third ST position update, and
  167. the count of contact points can only be updated every third packet as
  168. well.
  169. So far no v4 devices with tracksticks have been encountered.
  170. ALPS Absolute Mode - Protocol Version 5
  171. ---------------------------------------
  172. This is basically Protocol Version 3 but with different logic for packet
  173. decode. It uses the same alps_process_touchpad_packet_v3 call with a
  174. specialized decode_fields function pointer to correctly interpret the
  175. packets. This appears to only be used by the Dolphin devices.
  176. For single-touch, the 6-byte packet format is:
  177. byte 0: 1 1 0 0 1 0 0 0
  178. byte 1: 0 x6 x5 x4 x3 x2 x1 x0
  179. byte 2: 0 y6 y5 y4 y3 y2 y1 y0
  180. byte 3: 0 M R L 1 m r l
  181. byte 4: y10 y9 y8 y7 x10 x9 x8 x7
  182. byte 5: 0 z6 z5 z4 z3 z2 z1 z0
  183. For mt, the format is:
  184. byte 0: 1 1 1 n3 1 n2 n1 x24
  185. byte 1: 1 y7 y6 y5 y4 y3 y2 y1
  186. byte 2: ? x2 x1 y12 y11 y10 y9 y8
  187. byte 3: 0 x23 x22 x21 x20 x19 x18 x17
  188. byte 4: 0 x9 x8 x7 x6 x5 x4 x3
  189. byte 5: 0 x16 x15 x14 x13 x12 x11 x10