Module Name: src Committed By: martin Date: Thu Oct 15 12:03:23 UTC 2020
Modified Files: src/sys/dev/usb [netbsd-9]: ums.c Log Message: Pull up following revision(s) (requested by jmcneill in ticket #1112): sys/dev/usb/ums.c: revision 1.94 sys/dev/usb/ums.c: revision 1.99 Initialize tcpalib for ums devices. In r1.3 of src/sys/dev/hid/hidms.c, tpcalib is used for any hidms device reporting absolute coordinates. So ums devices reporting absolute coordinates also need to initialize tcpalib - do it for all ums devices. An uninitialized tcpalib stops a mouse with absolute coordinates from "moving". For absolute pointers, report min/max X and Y values using WSMOUSEIO_[SG]CALIBCOORDS ioctl. To generate a diff of this commit: cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/dev/usb/ums.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/ums.c diff -u src/sys/dev/usb/ums.c:1.93.2.3 src/sys/dev/usb/ums.c:1.93.2.4 --- src/sys/dev/usb/ums.c:1.93.2.3 Tue Jan 21 19:54:55 2020 +++ src/sys/dev/usb/ums.c Thu Oct 15 12:03:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ums.c,v 1.93.2.3 2020/01/21 19:54:55 martin Exp $ */ +/* $NetBSD: ums.c,v 1.93.2.4 2020/10/15 12:03:23 martin Exp $ */ /* * Copyright (c) 1998, 2017 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.93.2.3 2020/01/21 19:54:55 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.93.2.4 2020/10/15 12:03:23 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -137,6 +137,8 @@ ums_attach(device_t parent, device_t sel { struct ums_softc *sc = device_private(self); struct uhidev_attach_arg *uha = aux; + struct hid_data *d; + struct hid_item item; int size, error; void *desc; uint32_t quirks; @@ -203,6 +205,36 @@ ums_attach(device_t parent, device_t sel sc->sc_alwayson = true; } + tpcalib_init(&sc->sc_ms.sc_tpcalib); + + /* calibrate the pointer if it reports absolute events */ + if (sc->sc_ms.flags & HIDMS_ABS) { + memset(&sc->sc_ms.sc_calibcoords, 0, sizeof(sc->sc_ms.sc_calibcoords)); + sc->sc_ms.sc_calibcoords.maxx = 0; + sc->sc_ms.sc_calibcoords.maxy = 0; + sc->sc_ms.sc_calibcoords.samplelen = WSMOUSE_CALIBCOORDS_RESET; + d = hid_start_parse(desc, size, hid_input); + if (d != NULL) { + while (hid_get_item(d, &item)) { + if (item.kind != hid_input + || HID_GET_USAGE_PAGE(item.usage) != HUP_GENERIC_DESKTOP + || item.report_ID != sc->sc_hdev.sc_report_id) + continue; + if (HID_GET_USAGE(item.usage) == HUG_X) { + sc->sc_ms.sc_calibcoords.minx = item.logical_minimum; + sc->sc_ms.sc_calibcoords.maxx = item.logical_maximum; + } + if (HID_GET_USAGE(item.usage) == HUG_Y) { + sc->sc_ms.sc_calibcoords.miny = item.logical_minimum; + sc->sc_ms.sc_calibcoords.maxy = item.logical_maximum; + } + } + hid_end_parse(d); + } + tpcalib_ioctl(&sc->sc_ms.sc_tpcalib, WSMOUSEIO_SCALIBCOORDS, + (void *)&sc->sc_ms.sc_calibcoords, 0, 0); + } + hidms_attach(self, &sc->sc_ms, &ums_accessops); if (sc->sc_alwayson) { @@ -315,10 +347,18 @@ ums_disable(void *v) Static int ums_ioctl(void *v, u_long cmd, void *data, int flag, - struct lwp * p) + struct lwp *l) { struct ums_softc *sc = v; + int error; + + if (sc->sc_ms.flags & HIDMS_ABS) { + error = tpcalib_ioctl(&sc->sc_ms.sc_tpcalib, cmd, data, + flag, l); + if (error != EPASSTHROUGH) + return error; + } switch (cmd) { case WSMOUSEIO_GTYPE: