From a0864e3a2a2d1705f7612e6dfb13e19d5869cd81 Mon Sep 17 00:00:00 2001 From: Josef Karthauser Date: Sun, 7 Apr 2002 17:04:01 +0000 Subject: [PATCH] MFNetBSD: uhid.c (1.42 & 1.43), ugraphire_rdesc.h (1.1) date: 2000/12/29 01:47:49; author: augustss; Supply our own report descriptor (from Nick Hibma) for the Wacom Graphire. The descriptor it reports is broken. XXX Not tested, because I don't have the device. date: 2001/08/15 00:06:49; author: augustss; state: Exp; lines: +3 -1 If there was a vendor+product locator match return a higher match value. Rationale, if you have a device (e.g., a mouse) with a more specific driver but want to recognize it with the more generic driver you can do that by supplying vendor and product locators for the generic one. --- sys/dev/usb/ugraphire_rdesc.h | 92 +++++++++++++++++++++++++++++++++++ sys/dev/usb/uhid.c | 27 ++++++++-- 2 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 sys/dev/usb/ugraphire_rdesc.h diff --git a/sys/dev/usb/ugraphire_rdesc.h b/sys/dev/usb/ugraphire_rdesc.h new file mode 100644 index 000000000000..9dd6988ab907 --- /dev/null +++ b/sys/dev/usb/ugraphire_rdesc.h @@ -0,0 +1,92 @@ +/* $NetBSD: usb/ugraphire_rdesc.h,v 1.1 2000/12/29 01:47:49 augustss Exp $ */ +/* $FreeBSD$ */ +/* + * Copyright (c) 2000 Nick Hibma + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +static uByte uhid_graphire_report_descr[] = { + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Digitizer) */ + 0xa1, 0x01, /* COLLECTION (Application) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x01, /* USAGE (Digitizer) */ + 0xa1, 0x00, /* COLLECTION (Physical) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ + 0x09, 0x33, /* USAGE (Touch) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x44, /* USAGE (Barrel Switch) */ + 0x95, 0x02, /* REPORT_COUNT (2) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x95, 0x02, /* REPORT_COUNT (2) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x03, /* INPUT (Cnst,Var,Abs) */ + 0x09, 0x3c, /* USAGE (Invert) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x38, /* USAGE (Transducer Index) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x32, /* USAGE (In Range) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x01, /* REPORT_SIZE (1) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x30, /* USAGE (X) */ + 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ + 0x26, 0xde, 0x27, /* LOGICAL_MAXIMUM (10206) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x09, 0x31, /* USAGE (Y) */ + 0x26, 0xfe, 0x1c, /* LOGICAL_MAXIMUM (7422) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x30, /* USAGE (Tip Pressure) */ + 0x26, 0xff, 0x01, /* LOGICAL_MAXIMUM (511) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x75, 0x10, /* REPORT_SIZE (16) */ + 0x81, 0x02, /* INPUT (Data,Var,Abs) */ + 0xc0, /* END_COLLECTION */ + 0x05, 0x0d, /* USAGE_PAGE (Digitizers) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x02, /* REPORT_ID (2) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0x09, 0x00, /* USAGE (Undefined) */ + 0x85, 0x03, /* REPORT_ID (3) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0xb1, 0x02, /* FEATURE (Data,Var,Abs) */ + 0xc0, /* END_COLLECTION */ +}; diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 381d81bfa47f..70dae3af1fa7 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: uhid.c,v 1.40 2000/10/10 12:37:01 augustss Exp $ */ +/* $NetBSD: uhid.c,v 1.43 2001/08/15 00:06:49 augustss Exp $ */ /* $FreeBSD$ */ /* @@ -74,10 +74,14 @@ #include #include +#include #include #include #include +/* Report descriptor for broken Wacom Graphire */ +#include + #ifdef UHID_DEBUG #define DPRINTF(x) if (uhiddebug) logprintf x #define DPRINTFN(n,x) if (uhiddebug>(n)) logprintf x @@ -180,6 +184,8 @@ USB_MATCH(uhid) id = usbd_get_interface_descriptor(uaa->iface); if (id == NULL || id->bInterfaceClass != UICLASS_HID) return (UMATCH_NONE); + if (uaa->matchlvl) + return (uaa->matchlvl); return (UMATCH_IFACECLASS_GENERIC); } @@ -228,8 +234,23 @@ USB_ATTACH(uhid) sc->sc_ep_addr = ed->bEndpointAddress; - desc = NULL; - err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_USBDEV); + if (uaa->vendor == USB_VENDOR_WACOM && + uaa->product == USB_PRODUCT_WACOM_GRAPHIRE /* && + uaa->revision == 0x???? */) { /* XXX should use revision */ + /* The report descriptor for the Wacom Graphire is broken. */ + size = sizeof uhid_graphire_report_descr; + desc = malloc(size, M_USBDEV, M_NOWAIT); + if (desc == NULL) + err = USBD_NOMEM; + else { + err = USBD_NORMAL_COMPLETION; + memcpy(desc, uhid_graphire_report_descr, size); + } + } else { + desc = NULL; + err = usbd_alloc_report_desc(uaa->iface, &desc, &size,M_USBDEV); + } + if (err) { printf("%s: no report descriptor\n", USBDEVNAME(sc->sc_dev)); sc->sc_dying = 1;