Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / usb / usb_quirks.c
blobe68a6421f17336604be29c1139237906fc79144a
1 /* $NetBSD: usb_quirks.c,v 1.64 2009/04/24 14:16:50 jakllsch Exp $ */
2 /* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */
4 /*
5 * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
6 * All rights reserved.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Lennart Augustsson (lennart@augustsson.net) at
10 * Carlstedt Research & Technology.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.64 2009/04/24 14:16:50 jakllsch Exp $");
37 #include <sys/param.h>
38 #include <sys/systm.h>
40 #include <dev/usb/usb.h>
42 #include <dev/usb/usbdevs.h>
43 #include <dev/usb/usb_quirks.h>
45 #ifdef USB_DEBUG
46 extern int usbdebug;
47 #endif
49 #define ANY 0xffff
51 Static const struct usbd_quirk_entry {
52 u_int16_t idVendor;
53 u_int16_t idProduct;
54 u_int16_t bcdDevice;
55 struct usbd_quirks quirks;
56 } usb_quirks[] = {
57 /* Devices which should be ignored by uhid */
58 { USB_VENDOR_APC, USB_PRODUCT_APC_UPS, ANY, { UQ_HID_IGNORE }},
59 { USB_VENDOR_CYBERPOWER, USB_PRODUCT_CYBERPOWER_UPS, ANY, { UQ_HID_IGNORE }},
60 { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1, ANY, { UQ_HID_IGNORE }},
61 { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2, ANY, { UQ_HID_IGNORE }},
62 { USB_VENDOR_MICROCHIP, USB_PRODUCT_MICROCHIP_PICKIT1,
63 ANY, { UQ_HID_IGNORE }},
64 { USB_VENDOR_TRIPPLITE2, USB_PRODUCT_TRIPPLITE2_UPS,
65 ANY, { UQ_HID_IGNORE }},
67 { USB_VENDOR_METAGEEK, USB_PRODUCT_METAGEEK_WISPY_24X, ANY, { UQ_HID_IGNORE }},
69 { USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE, 0x100, { UQ_NO_SET_PROTO}},
70 { USB_VENDOR_INSIDEOUT, USB_PRODUCT_INSIDEOUT_EDGEPORT4,
71 0x094, { UQ_SWAP_UNICODE}},
72 { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_BAD_ADC }},
73 { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_AU_NO_XU }},
74 { USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ADA70, 0x103, { UQ_BAD_ADC }},
75 { USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ASC495, 0x000, { UQ_BAD_AUDIO }},
76 { USB_VENDOR_SONY, USB_PRODUCT_SONY_PS2EYETOY4, 0x000, { UQ_BAD_AUDIO }},
77 { USB_VENDOR_SONY, USB_PRODUCT_SONY_PS2EYETOY5, 0x000, { UQ_BAD_AUDIO }},
78 { USB_VENDOR_PHILIPS, USB_PRODUCT_PHILIPS_PCVC740K, ANY, { UQ_BAD_AUDIO }},
79 { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMPRONB,
80 0x000, { UQ_BAD_AUDIO }},
81 { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMPRO4K,
82 0x000, { UQ_BAD_AUDIO }},
83 { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_QUICKCAMMESS,
84 0x100, { UQ_BAD_ADC }},
85 { USB_VENDOR_QTRONIX, USB_PRODUCT_QTRONIX_980N, 0x110, { UQ_SPUR_BUT_UP }},
86 { USB_VENDOR_ALCOR2, USB_PRODUCT_ALCOR2_KBD_HUB, 0x001, { UQ_SPUR_BUT_UP }},
87 { USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS,
88 0x100, { UQ_ASSUME_CM_OVER_DATA }},
89 { USB_VENDOR_SANYO, USB_PRODUCT_SANYO_SCP4900,
90 0x000, { UQ_ASSUME_CM_OVER_DATA }},
91 { USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_T720C,
92 0x001, { UQ_ASSUME_CM_OVER_DATA }},
93 { USB_VENDOR_EICON, USB_PRODUCT_EICON_DIVA852,
94 0x100, { UQ_ASSUME_CM_OVER_DATA }},
95 { USB_VENDOR_SIEMENS2, USB_PRODUCT_SIEMENS2_MC75,
96 0x000, { UQ_ASSUME_CM_OVER_DATA }},
97 { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, { UQ_AU_NO_FRAC }},
98 { USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE,
99 0x100, { UQ_AU_INP_ASYNC }},
100 { USB_VENDOR_AVANCELOGIC, USB_PRODUCT_AVANCELOGIC_USBAUDIO,
101 0x101, { UQ_AU_INP_ASYNC }},
102 { USB_VENDOR_PLANTRONICS, USB_PRODUCT_PLANTRONICS_HEADSET,
103 0x004, { UQ_AU_INP_ASYNC }},
104 /* XXX These should have a revision number, but I don't know what they are. */
105 { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY, { UQ_BROKEN_BIDIR }},
106 { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY, { UQ_BROKEN_BIDIR }},
107 { USB_VENDOR_HP, USB_PRODUCT_HP_815C, ANY, { UQ_BROKEN_BIDIR }},
108 { USB_VENDOR_HP, USB_PRODUCT_HP_810C, ANY, { UQ_BROKEN_BIDIR }},
109 { USB_VENDOR_HP, USB_PRODUCT_HP_830C, ANY, { UQ_BROKEN_BIDIR }},
110 { USB_VENDOR_HP, USB_PRODUCT_HP_885C, ANY, { UQ_BROKEN_BIDIR }},
111 { USB_VENDOR_HP, USB_PRODUCT_HP_840C, ANY, { UQ_BROKEN_BIDIR }},
112 { USB_VENDOR_HP, USB_PRODUCT_HP_816C, ANY, { UQ_BROKEN_BIDIR }},
113 { USB_VENDOR_HP, USB_PRODUCT_HP_959C, ANY, { UQ_BROKEN_BIDIR }},
114 { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY900, ANY, { UQ_BROKEN_BIDIR }},
115 { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY760, ANY, { UQ_BROKEN_BIDIR }},
116 { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY920, ANY, { UQ_BROKEN_BIDIR }},
117 { USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY800, ANY, { UQ_BROKEN_BIDIR }},
119 { USB_VENDOR_HP, USB_PRODUCT_HP_1220C, ANY, { UQ_BROKEN_BIDIR }},
121 /* HID and audio are both invalid on iPhone/iPod Touch */
122 { USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE,
123 ANY, { UQ_HID_IGNORE | UQ_BAD_AUDIO }},
124 { USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPOD_TOUCH,
125 ANY, { UQ_HID_IGNORE | UQ_BAD_AUDIO }},
126 { USB_VENDOR_APPLE, USB_PRODUCT_APPLE_IPHONE_3G,
127 ANY, { UQ_HID_IGNORE | UQ_BAD_AUDIO }},
129 { USB_VENDOR_QUALCOMM, USB_PRODUCT_QUALCOMM_CDMA_MSM,
130 ANY, { UQ_ASSUME_CM_OVER_DATA }},
131 { USB_VENDOR_QUALCOMM2, USB_PRODUCT_QUALCOMM2_CDMA_MSM,
132 ANY, { UQ_ASSUME_CM_OVER_DATA }},
133 { USB_VENDOR_HYUNDAI, USB_PRODUCT_HYUNDAI_UM175,
134 ANY, { UQ_ASSUME_CM_OVER_DATA }},
135 { 0, 0, 0, { 0 } }
138 const struct usbd_quirks usbd_no_quirk = { 0 };
140 const struct usbd_quirks *
141 usbd_find_quirk(usb_device_descriptor_t *d)
143 const struct usbd_quirk_entry *t;
144 u_int16_t vendor = UGETW(d->idVendor);
145 u_int16_t product = UGETW(d->idProduct);
146 u_int16_t revision = UGETW(d->bcdDevice);
148 for (t = usb_quirks; t->idVendor != 0; t++) {
149 if (t->idVendor == vendor &&
150 t->idProduct == product &&
151 (t->bcdDevice == ANY || t->bcdDevice == revision))
152 break;
154 #ifdef USB_DEBUG
155 if (usbdebug && t->quirks.uq_flags)
156 logprintf("usbd_find_quirk 0x%04x/0x%04x/%x: %d\n",
157 UGETW(d->idVendor), UGETW(d->idProduct),
158 UGETW(d->bcdDevice), t->quirks.uq_flags);
159 #endif
160 return (&t->quirks);