From d7e7c660b4259f77f73d3c5be6815c00cf38233d Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 29 Nov 2009 20:48:19 +0000 Subject: [PATCH] Early-generation touchpads do not send periodic calibration frames for baseline subtraction, and are very temperature sensitive, so would slowly drift out of a calibrated state when under load. Escape this by taking the last frame before we decide that the pad is idle as a finger-free baseline. Tested on: iBook G4 --- sys/dev/usb/input/atp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys/dev/usb/input/atp.c b/sys/dev/usb/input/atp.c index c3aae4190c9..1489f9cefeb 100644 --- a/sys/dev/usb/input/atp.c +++ b/sys/dev/usb/input/atp.c @@ -1850,6 +1850,21 @@ atp_intr(struct usb_xfer *xfer, usb_error_t error) sc->sc_idlecount++; if (sc->sc_idlecount >= ATP_IDLENESS_THRESHOLD) { DPRINTFN(ATP_LLEVEL_INFO, "idle\n"); + + /* + * Use the last frame before we go idle for + * calibration on pads which do not send + * calibration frames. + */ + if (sc->sc_params->prot < ATP_PROT_GEYSER3) { + memcpy(sc->base_x, sc->cur_x, + sc->sc_params->n_xsensors * + sizeof(*(sc->base_x))); + memcpy(sc->base_y, sc->cur_y, + sc->sc_params->n_ysensors * + sizeof(*(sc->base_y))); + } + sc->sc_idlecount = 0; usbd_transfer_start(sc->sc_xfer[ATP_RESET]); }