elantech.txt 16 KB

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