Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pckbport add support for elantech (v2) touchpads tha...



details:   https://anonhg.NetBSD.org/src/rev/b5a14cf068a9
branches:  trunk
changeset: 772525:b5a14cf068a9
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jan 07 10:27:58 2012 +0000

description:
add support for elantech (v2) touchpads that report input pressure

diffstat:

 sys/dev/pckbport/elantech.c    |  33 +++++++++++++++++++++------------
 sys/dev/pckbport/elantechvar.h |   4 ++--
 2 files changed, 23 insertions(+), 14 deletions(-)

diffs (86 lines):

diff -r 3cb037b32c1e -r b5a14cf068a9 sys/dev/pckbport/elantech.c
--- a/sys/dev/pckbport/elantech.c       Sat Jan 07 02:07:58 2012 +0000
+++ b/sys/dev/pckbport/elantech.c       Sat Jan 07 10:27:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: elantech.c,v 1.4 2011/09/09 14:29:47 jakllsch Exp $ */
+/* $NetBSD: elantech.c,v 1.5 2012/01/07 10:27:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "opt_pms.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elantech.c,v 1.4 2011/09/09 14:29:47 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elantech.c,v 1.5 2012/01/07 10:27:58 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -220,11 +220,20 @@
        if (!psc->sc_enabled)
                return;
 
-       if ((psc->inputstate == 0 && (data & 0x0c) != 0x0c) ||
-           (psc->inputstate == 3 && (data & 0x0f) != 0x08)) {
-               aprint_debug_dev(psc->sc_dev, "waiting for sync..\n");
-               psc->inputstate = 0;
-               return;
+       if (sc->version >= 0x020800) {
+               if ((psc->inputstate == 0 && (data & 0x0c) != 0x04) ||
+                   (psc->inputstate == 3 && (data & 0x0f) != 0x02)) {
+                       aprint_debug_dev(psc->sc_dev, "waiting for sync..\n");
+                       psc->inputstate = 0;
+                       return;
+               }
+       } else {
+               if ((psc->inputstate == 0 && (data & 0x0c) != 0x0c) ||
+                   (psc->inputstate == 3 && (data & 0x0e) != 0x08)) {
+                       aprint_debug_dev(psc->sc_dev, "waiting for sync..\n");
+                       psc->inputstate = 0;
+                       return;
+               }
        }
 
        psc->packet[psc->inputstate++] = data & 0xff;
@@ -245,8 +254,8 @@
        case 0:
                /* FALLTHROUGH */
        case 1:
-               ep.ep_x = ((int16_t)psc->packet[1] << 8) | psc->packet[2];
-               ep.ep_y = ((int16_t)psc->packet[4] << 8) | psc->packet[5];
+               ep.ep_x = ((int16_t)(psc->packet[1] & 0xf) << 8) | psc->packet[2];
+               ep.ep_y = ((int16_t)(psc->packet[4] & 0xf) << 8) | psc->packet[5];
 
                aprint_debug_dev(psc->sc_dev,
                    "%d finger detected in elantech mode:\n", ep.ep_nfingers);
@@ -365,9 +374,9 @@
                    resp[0], resp[2], resp[0], resp[1], resp[2]);
                goto doreset;
        }
-       sc->version = fwversion;
-       aprint_normal_dev(psc->sc_dev, "Elantech touchpad version %d.%d\n",
-           resp[0], resp[2]);
+       sc->version = (resp[0] << 16) | (resp[1] << 8) | resp[2];
+       aprint_normal_dev(psc->sc_dev, "Elantech touchpad version %d.%d (%06x)\n",
+           resp[0], resp[2], sc->version);
 
        res = pms_elantech_init(psc);
        if (res) {
diff -r 3cb037b32c1e -r b5a14cf068a9 sys/dev/pckbport/elantechvar.h
--- a/sys/dev/pckbport/elantechvar.h    Sat Jan 07 02:07:58 2012 +0000
+++ b/sys/dev/pckbport/elantechvar.h    Sat Jan 07 10:27:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: elantechvar.h,v 1.1 2008/12/14 00:42:33 jmcneill Exp $ */
+/* $NetBSD: elantechvar.h,v 1.2 2012/01/07 10:27:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #define _DEV_PCKBCPORT_ELANTECHVAR_H
 
 struct elantech_softc {
-       uint16_t        version;
+       uint32_t        version;
 
        bool            initializing;
        int16_t         last_x, last_y, last_z;



Home | Main Index | Thread Index | Old Index