Subject: touchpanel bug: better patch
To: None <port-hpcarm@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: port-hpcarm
Date: 09/09/2002 07:44:52
Here is a better patch for the touchpanel bug. It gives me a much better
compromise between stylus move accuracy and interrupt overhead.
Index: j720ssp.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hpcarm/dev/j720ssp.c,v
retrieving revision 1.8
diff -U4 -r1.8 j720ssp.c
--- j720ssp.c 2002/07/22 20:55:48 1.8
+++ j720ssp.c 2002/09/09 05:42:06
@@ -114,8 +114,9 @@
struct tpcalib_softc sc_tpcalib;
void *sc_kbdsi;
void *sc_tpsi;
+ u_int64_t sc_tpdelay;
struct callout sc_tptimeout;
int sc_enabled;
};
@@ -281,8 +282,9 @@
callout_init(&sc->sc_tptimeout);
/* Setup touchpad interrupt */
sc->sc_tpsi = softintr_establish(IPL_SOFTCLOCK, j720tpsoft, sc);
+ sc->sc_tpdelay = 0;
sa11x0_intr_establish(0, 9, 1, IPL_BIO, j720tp_intr, sc);
/* LCD control is on the same bus */
config_hook(CONFIG_HOOK_SET, CONFIG_HOOK_BRIGHTNESS,
@@ -378,12 +380,21 @@
int
j720tp_intr(void *arg)
{
struct j720ssp_softc *sc = arg;
+ int s;
+ u_int64_t now;
bus_space_write_4(sc->sc_iot, sc->sc_gpioh, SAGPIO_EDR, 1 << 9);
- softintr_schedule(sc->sc_tpsi);
+ s = splclock();
+ now = softclock_ticks;
+ splx(s);
+
+ if (now >= sc->sc_tpdelay) {
+ sc->sc_tpdelay = now + (hz / 12);
+ softintr_schedule(sc->sc_tpsi);
+ }
return (1);
}
--
Emmanuel Dreyfus
manu@netbsd.org