Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pckbport PR/28774: Kentaro A. Kurahone: Add synaptic...
details: https://anonhg.NetBSD.org/src/rev/5db7123b71b8
branches: trunk
changeset: 572211:5db7123b71b8
user: christos <christos%NetBSD.org@localhost>
date: Fri Dec 24 18:33:06 2004 +0000
description:
PR/28774: Kentaro A. Kurahone: Add synaptics touchpad driver
diffstat:
sys/dev/pckbport/files.pckbport | 3 +-
sys/dev/pckbport/pms.c | 84 ++--
sys/dev/pckbport/pmsvar.h | 70 ++++
sys/dev/pckbport/synaptics.c | 636 ++++++++++++++++++++++++++++++++++++++++
sys/dev/pckbport/synapticsreg.h | 78 ++++
sys/dev/pckbport/synapticsvar.h | 57 +++
6 files changed, 883 insertions(+), 45 deletions(-)
diffs (truncated from 1055 to 300 lines):
diff -r 98a93c8f1eb5 -r 5db7123b71b8 sys/dev/pckbport/files.pckbport
--- a/sys/dev/pckbport/files.pckbport Fri Dec 24 17:37:43 2004 +0000
+++ b/sys/dev/pckbport/files.pckbport Fri Dec 24 18:33:06 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pckbport,v 1.1 2004/03/13 17:31:33 bjh21 Exp $
+# $NetBSD: files.pckbport,v 1.2 2004/12/24 18:33:06 christos Exp $
# devices attached at pckbport, for use with wscons
file dev/pckbport/pckbport.c pckbport | pckbport_machdep_cnattach
@@ -13,3 +13,4 @@
device pms: wsmousedev
attach pms at pckbport
file dev/pckbport/pms.c pms
+file dev/pckbport/synaptics.c pms
diff -r 98a93c8f1eb5 -r 5db7123b71b8 sys/dev/pckbport/pms.c
--- a/sys/dev/pckbport/pms.c Fri Dec 24 17:37:43 2004 +0000
+++ b/sys/dev/pckbport/pms.c Fri Dec 24 18:33:06 2004 +0000
@@ -1,6 +1,8 @@
-/* $NetBSD: pms.c,v 1.2 2004/03/18 21:05:19 bjh21 Exp $ */
+/* $NetBSD: pms.c,v 1.3 2004/12/24 18:33:06 christos Exp $ */
/*-
+ * Copyright (c) 2004 Kentaro Kurahone.
+ * Copyright (c) 2004 Ales Krenek.
* Copyright (c) 1994 Charles M. Hannum.
* Copyright (c) 1992, 1993 Erik Forsberg.
* All rights reserved.
@@ -24,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.2 2004/03/18 21:05:19 bjh21 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pms.c,v 1.3 2004/12/24 18:33:06 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -36,8 +38,11 @@
#include <machine/bus.h>
#include <dev/pckbport/pckbportvar.h>
+#include <dev/pckbport/synapticsvar.h>
#include <dev/pckbport/pmsreg.h>
+#include <dev/pckbport/pmsvar.h>
+
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsmousevar.h>
@@ -49,43 +54,17 @@
#define DPRINTF(x)
#endif
-enum pms_type { PMS_UNKNOWN, PMS_STANDARD, PMS_SCROLL3, PMS_SCROLL5 };
+enum pms_type tries[] = {
+ PMS_SCROLL5, PMS_SCROLL3, PMS_STANDARD, PMS_UNKNOWN
+};
-struct pms_protocol {
- int rates[3];
- int response;
- const char *name;
-} pms_protocols[] = {
+struct pms_protocol pms_protocols[] = {
{ { 0, 0, 0 }, 0, "unknown protocol" },
{ { 0, 0, 0 }, 0, "no scroll wheel (3 buttons)" },
{ { 200, 100, 80 }, 3, "scroll wheel (3 buttons)" },
{ { 200, 200, 80 }, 4, "scroll wheel (5 buttons)" }
};
-enum pms_type tries[] = {
- PMS_SCROLL5, PMS_SCROLL3, PMS_STANDARD, PMS_UNKNOWN
-};
-
-struct pms_softc { /* driver status information */
- struct device sc_dev;
-
- pckbport_tag_t sc_kbctag;
- int sc_kbcslot;
-
- int sc_enabled; /* input enabled? */
-#ifndef PMS_DISABLE_POWERHOOK
- void *sc_powerhook; /* cookie from power hook */
- int sc_suspended; /* suspended? */
-#endif /* !PMS_DISABLE_POWERHOOK */
- int inputstate; /* number of bytes received for this packet */
- u_int buttons; /* mouse button status */
- enum pms_type protocol;
- unsigned char packet[4];
- struct timeval last, current;
-
- struct device *sc_wsmousedev;
- struct proc *sc_event_thread;
-};
int pmsprobe(struct device *, struct cfdata *, void *);
void pmsattach(struct device *, struct device *, void *);
@@ -189,7 +168,7 @@
struct pms_softc *sc = (void *)self;
struct pckbport_attach_args *pa = aux;
struct wsmousedev_attach_args a;
- u_char cmd[1], resp[2];
+ u_char cmd[2], resp[2];
int res;
sc->sc_kbctag = pa->pa_tag;
@@ -213,9 +192,14 @@
sc->buttons = 0;
sc->protocol = PMS_UNKNOWN;
- pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
- pmsinput, sc, sc->sc_dev.dv_xname);
-
+ /* Probe for synaptics touchpad. */
+ if (pms_synaptics_probe_init(sc) == 0) {
+ sc->protocol = PMS_SYNAPTICS;
+ } else {
+ /* Install generic handler. */
+ pckbport_set_inputhandler(sc->sc_kbctag, sc->sc_kbcslot,
+ pmsinput, sc, sc->sc_dev.dv_xname);
+ }
a.accessops = &pms_accessops;
a.accesscookie = sc;
@@ -245,7 +229,7 @@
static void
do_enable(struct pms_softc *sc)
{
- u_char cmd[1];
+ u_char cmd[2];
int res;
sc->inputstate = 0;
@@ -253,8 +237,12 @@
pckbport_slot_enable(sc->sc_kbctag, sc->sc_kbcslot, 1);
+ if (sc->protocol == PMS_SYNAPTICS)
+ pms_synaptics_enable(sc);
+
cmd[0] = PMS_DEV_ENABLE;
- res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0);
+ res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd,
+ 1, 0, 1, 0);
if (res)
printf("pms_enable: command error %d\n", res);
@@ -296,7 +284,8 @@
int res;
cmd[0] = PMS_DEV_DISABLE;
- res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1, 0, 1, 0);
+ res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd,
+ 1, 0, 1, 0);
if (res)
printf("pms_disable: command error\n");
@@ -350,8 +339,11 @@
}
break;
case PWR_RESUME:
+ if (sc->protocol == PMS_SYNAPTICS)
+ pms_synaptics_resume(sc);
if (sc->sc_enabled && sc->sc_suspended) {
- sc->protocol = PMS_UNKNOWN; /* recheck protocol & init mouse */
+ /* recheck protocol & init mouse */
+ sc->protocol = PMS_UNKNOWN;
sc->sc_suspended = 0;
do_enable(sc); /* only if we were suspended */
}
@@ -392,7 +384,7 @@
if (i)
printf("pms_ioctl: SET_RES command error\n");
break;
-
+
default:
return EPASSTHROUGH;
}
@@ -428,12 +420,16 @@
save_protocol = sc->protocol;
pms_disable(sc);
cmd[0] = PMS_RESET;
- res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd, 1,
- 2, 1, resp);
+ res = pckbport_enqueue_cmd(sc->sc_kbctag, sc->sc_kbcslot, cmd,
+ 1, 2, 1, resp);
if (res)
DPRINTF(("%s: reset error %d\n", sc->sc_dev.dv_xname,
res));
- sc->protocol = PMS_UNKNOWN;
+
+ /* For the synaptics case, leave the protocol alone. */
+ if (sc->protocol != PMS_SYNAPTICS) {
+ sc->protocol = PMS_UNKNOWN;
+ }
pms_enable(sc);
if (sc->protocol != save_protocol) {
#if defined(PMSDEBUG) || defined(DIAGNOSTIC)
diff -r 98a93c8f1eb5 -r 5db7123b71b8 sys/dev/pckbport/pmsvar.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pckbport/pmsvar.h Fri Dec 24 18:33:06 2004 +0000
@@ -0,0 +1,70 @@
+/* $NetBSD: pmsvar.h,v 1.1 2004/12/24 18:33:06 christos Exp $ */
+
+/*-
+ * Copyright (c) 2004 Kentaro Kurahone.
+ * Copyright (c) 2004 Ales Krenek.
+ * Copyright (c) 1994 Charles M. Hannum.
+ * Copyright (c) 1992, 1993 Erik Forsberg.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_PCKBCPORT_PMSVAR_H_
+#define _DEV_PCKBCPORT_PMSVAR_H_
+
+enum pms_type {
+ PMS_UNKNOWN,
+ PMS_STANDARD,
+ PMS_SCROLL3,
+ PMS_SCROLL5,
+ PMS_SYNAPTICS
+};
+
+struct pms_protocol {
+ int rates[3];
+ int response;
+ const char *name;
+};
+
+struct pms_softc { /* driver status information */
+ struct device sc_dev;
+
+ pckbport_tag_t sc_kbctag;
+ int sc_kbcslot;
+
+ int sc_enabled; /* input enabled? */
+#ifndef PMS_DISABLE_POWERHOOK
+ void *sc_powerhook; /* cookie from power hook */
+ int sc_suspended; /* suspended? */
+#endif /* !PMS_DISABLE_POWERHOOK */
+ int inputstate; /* number of bytes received for this packet */
+ u_int buttons; /* mouse button status */
+ enum pms_type protocol;
+ unsigned char packet[6];
+ struct timeval last, current;
+
+ struct device *sc_wsmousedev;
+ struct proc *sc_event_thread;
+
+ union {
+ struct synaptics_softc synaptics;
+ } u;
+};
+
+#endif
diff -r 98a93c8f1eb5 -r 5db7123b71b8 sys/dev/pckbport/synaptics.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pckbport/synaptics.c Fri Dec 24 18:33:06 2004 +0000
@@ -0,0 +1,636 @@
+/* $NetBSD: synaptics.c,v 1.1 2004/12/24 18:33:06 christos Exp $ */
+
+/*
+ * Copyright (c) 2004, Ales Krenek
+ * Copyright (c) 2004, Kentaro A. Kurahone
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of the authors nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Home |
Main Index |
Thread Index |
Old Index