elantech.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. Elantech Touchpad Driver
  2. ========================
  3. Copyright (C) 2007-2008 Arjan Opmeer <arjan@opmeer.net>
  4. Extra information for hardware version 1 found and
  5. provided by Steve Havelka
  6. Version 2 (EeePC) hardware support based on patches
  7. received from Woody at Xandros and forwarded to me
  8. by user StewieGriffin at the eeeuser.com forum
  9. Contents
  10. ~~~~~~~~
  11. 1. Introduction
  12. 2. Extra knobs
  13. 3. Hardware version 1
  14. 3.1 Registers
  15. 3.2 Native relative mode 4 byte packet format
  16. 3.3 Native absolute mode 4 byte packet format
  17. 4. Hardware version 2
  18. 4.1 Registers
  19. 4.2 Native absolute mode 6 byte packet format
  20. 4.2.1 One finger touch
  21. 4.2.2 Two finger touch
  22. 1. Introduction
  23. ~~~~~~~~~~~~
  24. Currently the Linux Elantech touchpad driver is aware of two different
  25. hardware versions unimaginatively called version 1 and version 2. Version 1
  26. is found in "older" laptops and uses 4 bytes per packet. Version 2 seems to
  27. be introduced with the EeePC and uses 6 bytes per packet, and provides
  28. additional features such as position of two fingers, and width of the touch.
  29. The driver tries to support both hardware versions and should be compatible
  30. with the Xorg Synaptics touchpad driver and its graphical configuration
  31. utilities.
  32. Additionally the operation of the touchpad can be altered by adjusting the
  33. contents of some of its internal registers. These registers are represented
  34. by the driver as sysfs entries under /sys/bus/serio/drivers/psmouse/serio?
  35. that can be read from and written to.
  36. Currently only the registers for hardware version 1 are somewhat understood.
  37. Hardware version 2 seems to use some of the same registers but it is not
  38. known whether the bits in the registers represent the same thing or might
  39. have changed their meaning.
  40. On top of that, some register settings have effect only when the touchpad is
  41. in relative mode and not in absolute mode. As the Linux Elantech touchpad
  42. driver always puts the hardware into absolute mode not all information
  43. mentioned below can be used immediately. But because there is no freely
  44. available Elantech documentation the information is provided here anyway for
  45. completeness sake.
  46. /////////////////////////////////////////////////////////////////////////////
  47. 2. Extra knobs
  48. ~~~~~~~~~~~
  49. Currently the Linux Elantech touchpad driver provides two extra knobs under
  50. /sys/bus/serio/drivers/psmouse/serio? for the user.
  51. * debug
  52. Turn different levels of debugging ON or OFF.
  53. By echoing "0" to this file all debugging will be turned OFF.
  54. Currently a value of "1" will turn on some basic debugging and a value of
  55. "2" will turn on packet debugging. For hardware version 1 the default is
  56. OFF. For version 2 the default is "1".
  57. Turning packet debugging on will make the driver dump every packet
  58. received to the syslog before processing it. Be warned that this can
  59. generate quite a lot of data!
  60. * paritycheck
  61. Turns parity checking ON or OFF.
  62. By echoing "0" to this file parity checking will be turned OFF. Any
  63. non-zero value will turn it ON. For hardware version 1 the default is ON.
  64. For version 2 the default it is OFF.
  65. Hardware version 1 provides basic data integrity verification by
  66. calculating a parity bit for the last 3 bytes of each packet. The driver
  67. can check these bits and reject any packet that appears corrupted. Using
  68. this knob you can bypass that check.
  69. Hardware version 2 does not provide the same parity bits. Only some basic
  70. data consistency checking can be done. For now checking is disabled by
  71. default. Currently even turning it on will do nothing.
  72. /////////////////////////////////////////////////////////////////////////////
  73. 3. Differentiating hardware versions
  74. =================================
  75. To detect the hardware version, read the version number as param[0].param[1].param[2]
  76. 4 bytes version: (after the arrow is the name given in the Dell-provided driver)
  77. 02.00.22 => EF013
  78. 02.06.00 => EF019
  79. In the wild, there appear to be more versions, such as 00.01.64, 01.00.21,
  80. 02.00.00, 02.00.04, 02.00.06.
  81. 6 bytes:
  82. 02.00.30 => EF113
  83. 02.08.00 => EF023
  84. 02.08.XX => EF123
  85. 02.0B.00 => EF215
  86. 04.01.XX => Scroll_EF051
  87. 04.02.XX => EF051
  88. In the wild, there appear to be more versions, such as 04.03.01, 04.04.11. There
  89. appears to be almost no difference, except for EF113, which does not report
  90. pressure/width and has different data consistency checks.
  91. Probably all the versions with param[0] <= 01 can be considered as
  92. 4 bytes/firmware 1. The versions < 02.08.00, with the exception of 02.00.30, as
  93. 4 bytes/firmware 2. Everything >= 02.08.00 can be considered as 6 bytes.
  94. /////////////////////////////////////////////////////////////////////////////
  95. 4. Hardware version 1
  96. ==================
  97. 4.1 Registers
  98. ~~~~~~~~~
  99. By echoing a hexadecimal value to a register it contents can be altered.
  100. For example:
  101. echo -n 0x16 > reg_10
  102. * reg_10
  103. bit 7 6 5 4 3 2 1 0
  104. B C T D L A S E
  105. E: 1 = enable smart edges unconditionally
  106. S: 1 = enable smart edges only when dragging
  107. A: 1 = absolute mode (needs 4 byte packets, see reg_11)
  108. L: 1 = enable drag lock (see reg_22)
  109. D: 1 = disable dynamic resolution
  110. T: 1 = disable tapping
  111. C: 1 = enable corner tap
  112. B: 1 = swap left and right button
  113. * reg_11
  114. bit 7 6 5 4 3 2 1 0
  115. 1 0 0 H V 1 F P
  116. P: 1 = enable parity checking for relative mode
  117. F: 1 = enable native 4 byte packet mode
  118. V: 1 = enable vertical scroll area
  119. H: 1 = enable horizontal scroll area
  120. * reg_20
  121. single finger width?
  122. * reg_21
  123. scroll area width (small: 0x40 ... wide: 0xff)
  124. * reg_22
  125. drag lock time out (short: 0x14 ... long: 0xfe;
  126. 0xff = tap again to release)
  127. * reg_23
  128. tap make timeout?
  129. * reg_24
  130. tap release timeout?
  131. * reg_25
  132. smart edge cursor speed (0x02 = slow, 0x03 = medium, 0x04 = fast)
  133. * reg_26
  134. smart edge activation area width?
  135. 4.2 Native relative mode 4 byte packet format
  136. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. byte 0:
  138. bit 7 6 5 4 3 2 1 0
  139. c c p2 p1 1 M R L
  140. L, R, M = 1 when Left, Right, Middle mouse button pressed
  141. some models have M as byte 3 odd parity bit
  142. when parity checking is enabled (reg_11, P = 1):
  143. p1..p2 = byte 1 and 2 odd parity bit
  144. c = 1 when corner tap detected
  145. byte 1:
  146. bit 7 6 5 4 3 2 1 0
  147. dx7 dx6 dx5 dx4 dx3 dx2 dx1 dx0
  148. dx7..dx0 = x movement; positive = right, negative = left
  149. byte 1 = 0xf0 when corner tap detected
  150. byte 2:
  151. bit 7 6 5 4 3 2 1 0
  152. dy7 dy6 dy5 dy4 dy3 dy2 dy1 dy0
  153. dy7..dy0 = y movement; positive = up, negative = down
  154. byte 3:
  155. parity checking enabled (reg_11, P = 1):
  156. bit 7 6 5 4 3 2 1 0
  157. w h n1 n0 ds3 ds2 ds1 ds0
  158. normally:
  159. ds3..ds0 = scroll wheel amount and direction
  160. positive = down or left
  161. negative = up or right
  162. when corner tap detected:
  163. ds0 = 1 when top right corner tapped
  164. ds1 = 1 when bottom right corner tapped
  165. ds2 = 1 when bottom left corner tapped
  166. ds3 = 1 when top left corner tapped
  167. n1..n0 = number of fingers on touchpad
  168. only models with firmware 2.x report this, models with
  169. firmware 1.x seem to map one, two and three finger taps
  170. directly to L, M and R mouse buttons
  171. h = 1 when horizontal scroll action
  172. w = 1 when wide finger touch?
  173. otherwise (reg_11, P = 0):
  174. bit 7 6 5 4 3 2 1 0
  175. ds7 ds6 ds5 ds4 ds3 ds2 ds1 ds0
  176. ds7..ds0 = vertical scroll amount and direction
  177. negative = up
  178. positive = down
  179. 4.3 Native absolute mode 4 byte packet format
  180. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. EF013 and EF019 have a special behaviour (due to a bug in the firmware?), and
  182. when 1 finger is touching, the first 2 position reports must be discarded.
  183. This counting is reset whenever a different number of fingers is reported.
  184. byte 0:
  185. firmware version 1.x:
  186. bit 7 6 5 4 3 2 1 0
  187. D U p1 p2 1 p3 R L
  188. L, R = 1 when Left, Right mouse button pressed
  189. p1..p3 = byte 1..3 odd parity bit
  190. D, U = 1 when rocker switch pressed Up, Down
  191. firmware version 2.x:
  192. bit 7 6 5 4 3 2 1 0
  193. n1 n0 p2 p1 1 p3 R L
  194. L, R = 1 when Left, Right mouse button pressed
  195. p1..p3 = byte 1..3 odd parity bit
  196. n1..n0 = number of fingers on touchpad
  197. byte 1:
  198. firmware version 1.x:
  199. bit 7 6 5 4 3 2 1 0
  200. f 0 th tw x9 x8 y9 y8
  201. tw = 1 when two finger touch
  202. th = 1 when three finger touch
  203. f = 1 when finger touch
  204. firmware version 2.x:
  205. bit 7 6 5 4 3 2 1 0
  206. . . . . x9 x8 y9 y8
  207. byte 2:
  208. bit 7 6 5 4 3 2 1 0
  209. x7 x6 x5 x4 x3 x2 x1 x0
  210. x9..x0 = absolute x value (horizontal)
  211. byte 3:
  212. bit 7 6 5 4 3 2 1 0
  213. y7 y6 y5 y4 y3 y2 y1 y0
  214. y9..y0 = absolute y value (vertical)
  215. /////////////////////////////////////////////////////////////////////////////
  216. 5. Hardware version 2
  217. ==================
  218. 5.1 Registers
  219. ~~~~~~~~~
  220. By echoing a hexadecimal value to a register it contents can be altered.
  221. For example:
  222. echo -n 0x56 > reg_10
  223. * reg_10
  224. bit 7 6 5 4 3 2 1 0
  225. 0 1 0 1 0 1 D 0
  226. D: 1 = enable drag and drop
  227. * reg_11
  228. bit 7 6 5 4 3 2 1 0
  229. 1 0 0 0 S 0 1 0
  230. S: 1 = enable vertical scroll
  231. * reg_21
  232. unknown (0x00)
  233. * reg_22
  234. drag and drop release time out (short: 0x70 ... long 0x7e;
  235. 0x7f = never i.e. tap again to release)
  236. 5.2 Native absolute mode 6 byte packet format
  237. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  238. 5.2.1 Parity checking and packet re-synchronization
  239. There is no parity checking, however some consistency checks can be performed.
  240. For instance for EF113:
  241. SA1= packet[0];
  242. A1 = packet[1];
  243. B1 = packet[2];
  244. SB1= packet[3];
  245. C1 = packet[4];
  246. D1 = packet[5];
  247. if( (((SA1 & 0x3C) != 0x3C) && ((SA1 & 0xC0) != 0x80)) || // check Byte 1
  248. (((SA1 & 0x0C) != 0x0C) && ((SA1 & 0xC0) == 0x80)) || // check Byte 1 (one finger pressed)
  249. (((SA1 & 0xC0) != 0x80) && (( A1 & 0xF0) != 0x00)) || // check Byte 2
  250. (((SB1 & 0x3E) != 0x38) && ((SA1 & 0xC0) != 0x80)) || // check Byte 4
  251. (((SB1 & 0x0E) != 0x08) && ((SA1 & 0xC0) == 0x80)) || // check Byte 4 (one finger pressed)
  252. (((SA1 & 0xC0) != 0x80) && (( C1 & 0xF0) != 0x00)) ) // check Byte 5
  253. // error detected
  254. For all the other ones, there are just a few constant bits:
  255. if( ((packet[0] & 0x0C) != 0x04) ||
  256. ((packet[3] & 0x0f) != 0x02) )
  257. // error detected
  258. In case an error is detected, all the packets are shifted by one (and packet[0] is discarded).
  259. 5.2.1 One/Three finger touch
  260. ~~~~~~~~~~~~~~~~
  261. byte 0:
  262. bit 7 6 5 4 3 2 1 0
  263. n1 n0 w3 w2 . . R L
  264. L, R = 1 when Left, Right mouse button pressed
  265. n1..n0 = numbers of fingers on touchpad
  266. byte 1:
  267. bit 7 6 5 4 3 2 1 0
  268. p7 p6 p5 p4 . x10 x9 x8
  269. byte 2:
  270. bit 7 6 5 4 3 2 1 0
  271. x7 x6 x5 x4 x3 x2 x1 x0
  272. x10..x0 = absolute x value (horizontal)
  273. byte 3:
  274. bit 7 6 5 4 3 2 1 0
  275. n4 vf w1 w0 . . . b2
  276. n4 = set if more than 3 fingers (only in 3 fingers mode)
  277. vf = a kind of flag ? (only on EF123, 0 when finger is over one
  278. of the buttons, 1 otherwise)
  279. w3..w0 = width of the finger touch (not EF113)
  280. b2 (on EF113 only, 0 otherwise), b2.R.L indicates one button pressed:
  281. 0 = none
  282. 1 = Left
  283. 2 = Right
  284. 3 = Middle (Left and Right)
  285. 4 = Forward
  286. 5 = Back
  287. 6 = Another one
  288. 7 = Another one
  289. byte 4:
  290. bit 7 6 5 4 3 2 1 0
  291. p3 p1 p2 p0 . . y9 y8
  292. p7..p0 = pressure (not EF113)
  293. byte 5:
  294. bit 7 6 5 4 3 2 1 0
  295. y7 y6 y5 y4 y3 y2 y1 y0
  296. y9..y0 = absolute y value (vertical)
  297. 4.2.2 Two finger touch
  298. ~~~~~~~~~~~~~~~~
  299. Note that the two pairs of coordinates are not exactly the coordinates of the
  300. two fingers, but only the pair of the lower-left and upper-right coordinates.
  301. So the actual fingers might be situated on the other diagonal of the square
  302. defined by these two points.
  303. byte 0:
  304. bit 7 6 5 4 3 2 1 0
  305. n1 n0 ay8 ax8 . . R L
  306. L, R = 1 when Left, Right mouse button pressed
  307. n1..n0 = numbers of fingers on touchpad
  308. byte 1:
  309. bit 7 6 5 4 3 2 1 0
  310. ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
  311. ax8..ax0 = lower-left finger absolute x value
  312. byte 2:
  313. bit 7 6 5 4 3 2 1 0
  314. ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
  315. ay8..ay0 = lower-left finger absolute y value
  316. byte 3:
  317. bit 7 6 5 4 3 2 1 0
  318. . . by8 bx8 . . . .
  319. byte 4:
  320. bit 7 6 5 4 3 2 1 0
  321. bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
  322. bx8..bx0 = upper-right finger absolute x value
  323. byte 5:
  324. bit 7 6 5 4 3 2 1 0
  325. by7 by8 by5 by4 by3 by2 by1 by0
  326. by8..by0 = upper-right finger absolute y value