Elantech Touchpad Driver
========================
        Copyright (C) 2007 Arjan Opmeer <arjan@opmeer.net>

        Extra information found and provided by Steve Havelka

Configuration of the touchpad is performed by writing values to registers
found under sysfs entries /sys/bus/serio/drivers/psmouse/serio?/reg_*.

E.g. to disable tapping while leaving the other settings to the default
Windows driver value one would:

   echo -n 0x32 > reg_10


Registers
~~~~~~~~~

* reg_10        (Windows driver default value 0x12)

   bit   7   6   5   4   3   2   1   0
         B   C   T   D   L   A   S   E

         E: 1 = enable smart edges in other cases
         S: 1 = enable smart edges only when dragging
         A: 1 = absolute mode (needs 4 byte packets, see reg_11)
         L: 1 = enable drag lock (see reg_22)
         D: 1 = disable dynamic resolution
         T: 1 = disable tapping
         C: 1 = enable corner tap
         B: 1 = swap left and right button

* reg_11        (Windows driver default value 0x8f)

   bit   7   6   5   4   3   2   1   0
         1   0   0   H   V   1   F   P

         P: 1 = enable parity checking for relative mode
         F: 1 = enable native 4 byte packet mode
         V: 1 = enable vertical scroll area
         H: 1 = enable horizonal scroll area


* reg_20        (Windows driver default value 0x0a)

         single finger width?

* reg_21        (Windows driver default value 0x60)

         scroll area width (small: 0x40 ... wide: 0xff)

* reg_22        (Windows driver default value 0xff)

         drag lock time out (short: 0x14 ... long: 0xfe; 0xff =never)

* reg_23        (Windows driver default value 0x10)

         tap make timeout?

         Note: the Windows driver does not write this register

* reg_24        (Windows driver default value 0x10)

         tap release timeout?

         Note: the Windows driver does not write this register

* reg_25        (Windows driver default value 0x03)

         smart edge cursor speed (0x02 = slow, 0x03 = medium, 0x04 = fast)

* reg_26        (Windows driver default value 0x00 ?? )

         smart edge activation area width?

         Note: the Windows driver does not write this register
         Note: the Windows driver default value of 0x00 disables smart edges
               when it would get written
         Note: the Windows driver sets bit 0 of the registry value to disable
               tapping when typing, but never actually writes the register.
               Only used as an internal driver flag?



Initially the Elantouch Touchpad is in emulation mode and reports 3 byte
standard PS/2 packets and hence works with a standard mouse driver.
However, it can be configured to talk its native 4 byte relative mode and 4
byte absolute mode both for which a dedicated driver is needed.


Native 4 byte relative mode packet format
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

byte 0:
   bit   7   6   5   4   3   2   1   0
         c   c  p2  p1   1   M   R   L

         L, R, M = 1 when Left, Right, Middle mouse button pressed
            some models have M as byte 3 odd parity
         when parity checking is enabled (P = 1):
            p1 = byte 1 odd parity
            p2 = byte 2 odd parity
         c = 1 when corner tap detected

byte 1:
   bit   7   6   5   4   3   2   1   0
        dx7 dx6 dx5 dx4 dx3 dx2 dx1 dx0

         dx7..dx0 = x movement;   positive = right, negative = left
         byte 1 = 0xf0 when corner tap detected

byte 2:
   bit   7   6   5   4   3   2   1   0
        dy7 dy6 dy5 dy4 dy3 dy2 dy1 dy0

         dy7..dy0 = y movement;   positive = up,    negative = down

byte 3:
   bit   7   6   5   4   3   2   1   0
         w   h  n1  n0  d3  d2  d1  d0

         when parity checking is enabled (P = 1):
            normally:
               d3..d0 = scroll wheel amount and direction
                        positive = down or left
                        negative = up or right
            when corner tap detected:
               d0 = 1 when top right corner tapped
               d1 = 1 when bottom right corner tapped
               d2 = 1 when bottom left corner tapped
               d3 = 1 when top left corner tapped
            n1..n0 = number of fingers on touchpad
               not all models report this but map one, two and three
               finger taps directly to L, M and R mouse buttons
            w = 1 when wide finger touch?
            h = 1 when horizontal scroll action
         otherwise (P = 0):
            all of byte 3 is vertical scroll amount and direction
            negative = up
            positive = down


Native 4 byte absolute mode packet format
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

byte 0:
   bit   7   6   5   4   3   2   1   0
         D   U  p1  p2   1  p3   R   L

         L, R = 1 when Left, Right mouse button pressed
         p1..p3 = parity bit of bytes 1..3
         D, U = 1 when rocker switch pressed Up, Down

byte 1:
   bit   7   6   5   4   3   2   1   0
         f   0  th  tw  x9  x8  y9  y8

         tw = 1 when two finger touch
         th = 1 when three finger touch
         f  = 1 when finger touch

byte 2:
   bit   7   6   5   4   3   2   1   0
        x7  x6  x5  x4  x3  x2  x1  x0

         x9..x0 = absolute x value (horizontal)

byte 3:
   bit   7   6   5   4   3   2   1   0
        y7  y6  y5  y4  y3  y2  y1  y0

         y9..y0 = absolute y value (vertical)
