Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/usb Pull up following revision(s) (requested by j...



details:   https://anonhg.NetBSD.org/src/rev/221863a00623
branches:  netbsd-9
changeset: 940717:221863a00623
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Oct 15 12:03:23 2020 +0000

description:
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.

diffstat:

 sys/dev/usb/ums.c |  46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diffs (84 lines):

diff -r 284e59d9e7a7 -r 221863a00623 sys/dev/usb/ums.c
--- a/sys/dev/usb/ums.c Mon Oct 12 10:27:57 2020 +0000
+++ b/sys/dev/usb/ums.c Thu Oct 15 12:03:23 2020 +0000
@@ -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 @@
 {
        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 @@
                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 @@
 
 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:



Home | Main Index | Thread Index | Old Index