Module Name: src Committed By: sborrill Date: Fri Nov 27 08:54:13 UTC 2009
Modified Files: src/sys/dev/usb [netbsd-5]: uhidev.c ums.c usbdevs Log Message: Pull up the following revisions(s) (requested by rafal in ticket #1162): sys/dev/usb/uhidev.c: revision 1.44 sys/dev/usb/ums.c: revision 1.75 sys/dev/usb/usbdevs: revision 1.536 Fix kern/41737. Add quirks to make MS Wireless Laser Mouse 6000 work. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.42.8.1 src/sys/dev/usb/uhidev.c cvs rdiff -u -r1.73 -r1.73.8.1 src/sys/dev/usb/ums.c cvs rdiff -u -r1.519.4.2 -r1.519.4.3 src/sys/dev/usb/usbdevs 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/uhidev.c diff -u src/sys/dev/usb/uhidev.c:1.42 src/sys/dev/usb/uhidev.c:1.42.8.1 --- src/sys/dev/usb/uhidev.c:1.42 Mon May 26 19:01:51 2008 +++ src/sys/dev/usb/uhidev.c Fri Nov 27 08:54:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: uhidev.c,v 1.42 2008/05/26 19:01:51 drochner Exp $ */ +/* $NetBSD: uhidev.c,v 1.42.8.1 2009/11/27 08:54:13 sborrill Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.42 2008/05/26 19:01:51 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.42.8.1 2009/11/27 08:54:13 sborrill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -105,7 +105,7 @@ struct uhidev_attach_arg uha; device_t dev; struct uhidev *csc; - int size, nrepid, repid, repsz; + int maxinpktsize, size, nrepid, repid, repsz; int *repsizes; int i; void *desc; @@ -137,6 +137,7 @@ (void)usbd_set_protocol(iface, 1); #endif + maxinpktsize = 0; sc->sc_iep_addr = sc->sc_oep_addr = -1; for (i = 0; i < id->bNumEndpoints; i++) { ed = usbd_interface2endpoint_descriptor(iface, i); @@ -158,6 +159,7 @@ if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) { + maxinpktsize = UGETW(ed->wMaxPacketSize); sc->sc_iep_addr = ed->bEndpointAddress; } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && (ed->bmAttributes & UE_XFERTYPE) == UE_INTERRUPT) { @@ -262,8 +264,10 @@ aprint_error_dev(self, "no memory\n"); USB_ATTACH_ERROR_RETURN; } + + /* Just request max packet size for the interrupt pipe */ + sc->sc_isize = maxinpktsize; sc->sc_nrepid = nrepid; - sc->sc_isize = 0; usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, USBDEV(sc->sc_dev)); @@ -272,12 +276,8 @@ repsz = hid_report_size(desc, size, hid_input, repid); DPRINTF(("uhidev_match: repid=%d, repsz=%d\n", repid, repsz)); repsizes[repid] = repsz; - if (repsz > 0) { - if (repsz > sc->sc_isize) - sc->sc_isize = repsz; - } } - sc->sc_isize += nrepid != 1; /* space for report ID */ + DPRINTF(("uhidev_attach: isize=%d\n", sc->sc_isize)); uha.parent = sc; @@ -475,7 +475,7 @@ rep, scd, scd ? scd->sc_state : 0)); if (!(scd->sc_state & UHIDEV_OPEN)) return; - if (scd->sc_in_rep_size != cc) { + if (scd->sc_in_rep_size > cc) { printf("%s: bad input length %d != %d\n", USBDEVNAME(sc->sc_dev), scd->sc_in_rep_size, cc); return; Index: src/sys/dev/usb/ums.c diff -u src/sys/dev/usb/ums.c:1.73 src/sys/dev/usb/ums.c:1.73.8.1 --- src/sys/dev/usb/ums.c:1.73 Sat May 24 16:40:58 2008 +++ src/sys/dev/usb/ums.c Fri Nov 27 08:54:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ums.c,v 1.73 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: ums.c,v 1.73.8.1 2009/11/27 08:54:13 sborrill Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.73 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.73.8.1 2009/11/27 08:54:13 sborrill Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -95,6 +95,7 @@ #define UMS_Z 0x01 /* z direction available */ #define UMS_SPUR_BUT_UP 0x02 /* spurious button up events */ #define UMS_REVZ 0x04 /* Z-axis is reversed */ +#define UMS_W 0x08 /* w direction/tilt available */ int nbuttons; @@ -152,7 +153,8 @@ int size; void *desc; u_int32_t flags, quirks; - int i, wheel; + int i, hl; + struct hid_location *zloc; struct hid_location loc_btn; aprint_naive("\n"); @@ -198,10 +200,16 @@ } /* Try the wheel first as the Z activator since it's tradition. */ - wheel = hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, - HUG_WHEEL), - uha->reportid, hid_input, &sc->sc_loc_z, &flags); - if (wheel) { + hl = hid_locate(desc, + size, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), + uha->reportid, + hid_input, + &sc->sc_loc_z, + &flags); + + zloc = &sc->sc_loc_z; + if (hl) { if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { aprint_verbose("\n%s: Wheel report 0x%04x not " "supported\n", USBDEVNAME(sc->sc_hdev.sc_dev), @@ -211,33 +219,59 @@ sc->flags |= UMS_Z; /* Wheels need the Z axis reversed. */ sc->flags ^= UMS_REVZ; + /* Put Z on the W coordinate */ + zloc = &sc->sc_loc_w; } - /* - * We might have both a wheel and Z direction, if so put - * put the Z on the W coordinate. - */ - if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, - HUG_Z), - uha->reportid, hid_input, &sc->sc_loc_w, &flags)) { - if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { - aprint_verbose("\n%s: Z report 0x%04x not " - "supported\n", - USBDEVNAME(sc->sc_hdev.sc_dev), flags); - sc->sc_loc_w.size = 0; /* Bad Z, ignore */ - } - } - } else if (hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, - HUG_Z), - uha->reportid, hid_input, &sc->sc_loc_z, &flags)) { + } + + hl = hid_locate(desc, + size, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Z), + uha->reportid, + hid_input, + zloc, + &flags); + + /* + * The horizontal component of the scrollball can also be given by + * Application Control Pan in the Consumer page, so if we didnt see + * any Z then check that. + */ + if (!hl) { + hl = hid_locate(desc, + size, + HID_USAGE2(HUP_CONSUMER, HUC_AC_PAN), + uha->reportid, + hid_input, + zloc, + &flags); + } + + if (hl) { if ((flags & MOUSE_FLAGS_MASK) != MOUSE_FLAGS) { aprint_verbose("\n%s: Z report 0x%04x not supported\n", USBDEVNAME(sc->sc_hdev.sc_dev), flags); - sc->sc_loc_z.size = 0; /* Bad Z coord, ignore it */ + zloc->size = 0; /* Bad Z coord, ignore it */ } else { - sc->flags |= UMS_Z; + if (sc->flags & UMS_Z) + sc->flags |= UMS_W; + else + sc->flags |= UMS_Z; } } + /* + * The Microsoft Wireless Laser Mouse 6000 v2.0 reports a bad + * position for the wheel and wheel tilt controls -- should be + * in bytes 3 & 4 of the report. Fix this if necessary. + */ + if (uha->uaa->vendor == USB_VENDOR_MICROSOFT && + uha->uaa->product == USB_PRODUCT_MICROSOFT_24GHZ_XCVR) { + if ((sc->flags & UMS_Z) && sc->sc_loc_z.pos == 0) + sc->sc_loc_z.pos = 24; + if ((sc->flags & UMS_W) && sc->sc_loc_w.pos == 0) + sc->sc_loc_w.pos = sc->sc_loc_z.pos + 8; + } /* figure out the number of buttons */ for (i = 1; i <= MAX_BUTTONS; i++) @@ -246,9 +280,11 @@ break; sc->nbuttons = i - 1; - aprint_normal(": %d button%s%s\n", + aprint_normal(": %d button%s%s%s%s\n", sc->nbuttons, sc->nbuttons == 1 ? "" : "s", - sc->flags & UMS_Z ? " and Z dir." : ""); + sc->flags & UMS_W ? ", W" : "", + sc->flags & UMS_Z ? " and Z dir" : "", + sc->flags & UMS_W ? "s" : ""); for (i = 1; i <= sc->nbuttons; i++) hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i), @@ -264,6 +300,9 @@ if (sc->flags & UMS_Z) DPRINTF(("ums_attach: Z\t%d/%d\n", sc->sc_loc_z.pos, sc->sc_loc_z.size)); + if (sc->flags & UMS_W) + DPRINTF(("ums_attach: W\t%d/%d\n", + sc->sc_loc_w.pos, sc->sc_loc_w.size)); for (i = 1; i <= sc->nbuttons; i++) { DPRINTF(("ums_attach: B%d\t%d/%d\n", i, sc->sc_loc_btn[i-1].pos,sc->sc_loc_btn[i-1].size)); Index: src/sys/dev/usb/usbdevs diff -u src/sys/dev/usb/usbdevs:1.519.4.2 src/sys/dev/usb/usbdevs:1.519.4.3 --- src/sys/dev/usb/usbdevs:1.519.4.2 Sat Oct 10 20:34:45 2009 +++ src/sys/dev/usb/usbdevs Fri Nov 27 08:54:13 2009 @@ -1,4 +1,4 @@ -$NetBSD: usbdevs,v 1.519.4.2 2009/10/10 20:34:45 sborrill Exp $ +$NetBSD: usbdevs,v 1.519.4.3 2009/11/27 08:54:13 sborrill Exp $ /* * Copyright (c) 1998-2004 The NetBSD Foundation, Inc. @@ -1543,6 +1543,7 @@ product MICROSOFT XBOX_CONTROLLER_S10 0x0285 Xbox Controller S (1.0) product MICROSOFT XBOX_CONTROLLER_HUB 0x0288 Xbox Controller Hub product MICROSOFT XBOX_CONTROLLER_S12 0x0289 Xbox Controller S (1.2) +product MICROSOFT 24GHZ_XCVR 0x071f 2.4GHz Transceiver V2.0 /* Microtech products */ product MICROTECH SCSIDB25 0x0004 USB-SCSI-DB25