summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/devlist2h.awk6
-rw-r--r--sys/dev/usb/if_aue.c5
-rw-r--r--sys/dev/usb/if_kue.c14
-rw-r--r--sys/dev/usb/kue_fw.h8
-rw-r--r--sys/dev/usb/ohci.c57
-rw-r--r--sys/dev/usb/uaudio.c371
-rw-r--r--sys/dev/usb/uaudioreg.h67
-rw-r--r--sys/dev/usb/ucom.c8
-rw-r--r--sys/dev/usb/ugen.c4
-rw-r--r--sys/dev/usb/ugraphire_rdesc.h92
-rw-r--r--sys/dev/usb/uhci.c52
-rw-r--r--sys/dev/usb/uhid.c26
-rw-r--r--sys/dev/usb/uhub.c4
-rw-r--r--sys/dev/usb/ukbd.c121
-rw-r--r--sys/dev/usb/ulpt.c41
-rw-r--r--sys/dev/usb/umodem.c12
-rw-r--r--sys/dev/usb/ums.c4
-rw-r--r--sys/dev/usb/urio.c40
-rw-r--r--sys/dev/usb/usb.c6
-rw-r--r--sys/dev/usb/usb.h3
-rw-r--r--sys/dev/usb/usb_port.h3
-rw-r--r--sys/dev/usb/usb_quirks.c17
-rw-r--r--sys/dev/usb/usb_quirks.h14
-rw-r--r--sys/dev/usb/usb_subr.c43
-rw-r--r--sys/dev/usb/usbdi.c4
-rw-r--r--sys/dev/usb/usbdi.h6
-rw-r--r--sys/dev/usb/usbdivar.h8
-rw-r--r--sys/dev/usb/uscanner.c14
28 files changed, 747 insertions, 303 deletions
diff --git a/sys/dev/usb/devlist2h.awk b/sys/dev/usb/devlist2h.awk
index ff4dbc1b863..da3d472985a 100644
--- a/sys/dev/usb/devlist2h.awk
+++ b/sys/dev/usb/devlist2h.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $OpenBSD: devlist2h.awk,v 1.5 2001/01/27 04:02:10 deraadt Exp $
+# $OpenBSD: devlist2h.awk,v 1.6 2001/01/28 09:43:41 aaron Exp $
# $NetBSD: devlist2h.awk,v 1.8 1999/11/18 23:32:25 augustss Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -175,7 +175,7 @@ END {
printf("\n") > dfile
- printf("struct usb_known_product usb_known_products[] = {\n") > dfile
+ printf("const struct usb_known_product usb_known_products[] = {\n") > dfile
for (i = 1; i <= nproducts; i++) {
printf("\t{\n") > dfile
printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
@@ -198,7 +198,7 @@ END {
printf("\t{ 0, 0, NULL }\n") > dfile
printf("};\n\n") > dfile
- printf("struct usb_known_vendor usb_known_vendors[] = {\n") > dfile
+ printf("const struct usb_known_vendor usb_known_vendors[] = {\n") > dfile
for (i = 1; i <= nvendors; i++) {
printf("\t{\n") > dfile
printf("\t USB_VENDOR_%s,\n", vendors[i, 1]) \
diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c
index 82c3847421e..8977c600c5e 100644
--- a/sys/dev/usb/if_aue.c
+++ b/sys/dev/usb/if_aue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aue.c,v 1.10 2000/11/07 21:03:01 aaron Exp $ */
+/* $OpenBSD: if_aue.c,v 1.11 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: if_aue.c,v 1.38 2000/04/04 20:16:19 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -187,7 +187,8 @@ struct aue_type {
Static struct aue_type aue_devs[] = {
{ USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100, 0 },
- { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX, 0 },
+ { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1, 0 },
+ { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5, 0 },
{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX, 1 },
{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1, 1 },
{ USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA, 1 },
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 515cc460d98..be395645447 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_kue.c,v 1.6 2000/12/05 21:37:39 deraadt Exp $ */
+/* $OpenBSD: if_kue.c,v 1.7 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: if_kue.c,v 1.28 2000/04/02 21:25:41 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -173,7 +173,7 @@ int kuedebug = 0;
/*
* Various supported device vendors/products.
*/
-Static struct kue_type kue_devs[] = {
+Static const struct kue_type kue_devs[] = {
{ USB_VENDOR_AOX, USB_PRODUCT_AOX_USB101 },
{ USB_VENDOR_ADS, USB_PRODUCT_ADS_UBS10BT },
{ USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC10T },
@@ -307,7 +307,7 @@ kue_ctl(sc, rw, breq, val, data, len)
USETW(req.wLength, len);
s = splusb();
- err = KUE_DO_REQUEST(sc->kue_udev, &req, data);
+ err = KUE_DO_REQUEST(sc->kue_udev, &req, (void *)data);
splx(s);
return (err);
@@ -365,7 +365,7 @@ kue_load_fw(sc)
DPRINTFN(1,("%s: kue_load_fw: download code_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, kue_code_seg, sizeof(kue_code_seg));
+ 0, (void *)kue_code_seg, sizeof(kue_code_seg));
if (err) {
printf("%s: failed to load code segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
@@ -376,7 +376,7 @@ kue_load_fw(sc)
DPRINTFN(1,("%s: kue_load_fw: download fix_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, kue_fix_seg, sizeof(kue_fix_seg));
+ 0, (void *)kue_fix_seg, sizeof(kue_fix_seg));
if (err) {
printf("%s: failed to load fixup segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
@@ -387,7 +387,7 @@ kue_load_fw(sc)
DPRINTFN(1,("%s: kue_load_fw: download trig_seg\n",
USBDEVNAME(sc->kue_dev)));
err = kue_ctl(sc, KUE_CTL_WRITE, KUE_CMD_SEND_SCAN,
- 0, kue_trig_seg, sizeof(kue_trig_seg));
+ 0, (void *)kue_trig_seg, sizeof(kue_trig_seg));
if (err) {
printf("%s: failed to load trigger segment: %s\n",
USBDEVNAME(sc->kue_dev), usbd_errstr(err));
@@ -515,7 +515,7 @@ kue_reset(sc)
USB_MATCH(kue)
{
USB_MATCH_START(kue, uaa);
- struct kue_type *t;
+ const struct kue_type *t;
DPRINTFN(25,("kue_match: enter\n"));
diff --git a/sys/dev/usb/kue_fw.h b/sys/dev/usb/kue_fw.h
index 08b914b0931..78e6bbfccb8 100644
--- a/sys/dev/usb/kue_fw.h
+++ b/sys/dev/usb/kue_fw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kue_fw.h,v 1.3 2000/03/30 16:19:32 aaron Exp $ */
+/* $OpenBSD: kue_fw.h,v 1.4 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: kue_fw.h,v 1.2 2000/03/27 12:33:54 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -87,7 +87,7 @@
#define KUE_QTINTR_LOAD_CODE_HIGH 0x9C
/* Firmware code segment */
-Static unsigned char kue_code_seg[] =
+Static const unsigned char kue_code_seg[] =
{
/******************************************/
/* NOTE: B6/C3 is data header signature */
@@ -579,7 +579,7 @@ Static unsigned char kue_code_seg[] =
};
/* Firmware fixup (data?) segment */
-Static unsigned char kue_fix_seg[] =
+Static const unsigned char kue_fix_seg[] =
{
/******************************************/
/* NOTE: B6/C3 is data header signature */
@@ -682,6 +682,6 @@ Static unsigned char kue_fix_seg[] =
/* Fixup command. */
#define KUE_TRIGCMD_OFFSET 5
-Static unsigned char kue_trig_seg[] = {
+Static const unsigned char kue_trig_seg[] = {
0xb6, 0xc3, 0x01, 0x00, 0x06, 0x64, 0x00, 0x00
};
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index 8a3f5a514d9..695934bff81 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ohci.c,v 1.17 2001/01/22 23:24:32 deraadt Exp $ */
+/* $OpenBSD: ohci.c,v 1.18 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: ohci.c,v 1.93 2000/08/17 23:18:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
@@ -42,8 +42,8 @@
/*
* USB Open Host Controller driver.
*
- * OHCI spec: ftp://ftp.compaq.com/pub/supportinformation/papers/hcir1_0a.exe
- * USB spec: http://www.usb.org/developers/data/usb11.pdf
+ * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html
+ * USB spec: http://www.usb.org/developers/data/usbspec.zip
*/
#include <sys/param.h>
@@ -101,6 +101,20 @@ int ohcidebug = 0;
#define DPRINTFN(n,x)
#endif
+/*
+ * The OHCI controller is little endian, so on big endian machines
+ * the data strored in memory needs to be swapped.
+ */
+#if defined(__FreeBSD__)
+#if BYTE_ORDER == BIG_ENDIAN
+#define htole32(x) (bswap32(x))
+#define le32toh(x) (bswap32(x))
+#else
+#define htole32(x) (x)
+#define le32toh(x) (x)
+#endif
+#endif
+
struct ohci_pipe;
Static ohci_soft_ed_t *ohci_alloc_sed(ohci_softc_t *);
@@ -929,13 +943,45 @@ ohci_shutdown(void *v)
void
ohci_power(int why, void *v)
{
-#ifdef OHCI_DEBUG
ohci_softc_t *sc = v;
+ u_int32_t ctl;
+ int s;
+#ifdef OHCI_DEBUG
DPRINTF(("ohci_power: sc=%p, why=%d\n", sc, why));
- /* XXX should suspend/resume */
ohci_dumpregs(sc);
#endif
+
+ s = splusb();
+ switch (why) {
+ case PWR_SUSPEND:
+ case PWR_STANDBY:
+ sc->sc_bus.use_polling++;
+ ctl = OREAD4(sc, OHCI_CONTROL);
+ ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_SUSPEND;
+ OWRITE4(sc, OHCI_CONTROL, ctl);
+ usb_delay_ms(&sc->sc_bus, USB_RESUME_WAIT);
+ sc->sc_bus.use_polling--;
+ break;
+ case PWR_RESUME:
+ sc->sc_bus.use_polling++;
+ ctl = OREAD4(sc, OHCI_CONTROL);
+ ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_RESUME;
+ OWRITE4(sc, OHCI_CONTROL, ctl);
+ usb_delay_ms(&sc->sc_bus, USB_RESUME_DELAY);
+ ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL;
+ OWRITE4(sc, OHCI_CONTROL, ctl);
+ usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY);
+ sc->sc_bus.use_polling--;
+ break;
+#if defined(__NetBSD__)
+ case PWR_SOFTSUSPEND:
+ case PWR_SOFTSTANDBY:
+ case PWR_SOFTRESUME:
+ break;
+#endif
+ }
+ splx(s);
}
#ifdef OHCI_DEBUG
@@ -1275,6 +1321,7 @@ ohci_softintr(struct usbd_bus *bus)
(struct ohci_pipe *)xfer->pipe;
if (sitd->flags & OHCI_CALL_DONE) {
opipe->u.iso.inuse -= xfer->nframes;
+ /* XXX update frlengths with actual length */
/* XXX xfer->actlen = actlen; */
xfer->status = USBD_NORMAL_COMPLETION;
usb_transfer_complete(xfer);
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index c93d757cf87..a7ab58c6940 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudio.c,v 1.7 2000/11/08 18:10:37 aaron Exp $ */
+/* $OpenBSD: uaudio.c,v 1.8 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: uaudio.c,v 1.29 2000/10/05 01:35:07 augustss Exp $ */
/*
@@ -39,9 +39,9 @@
*/
/*
- * USB audio specs: http://www.teleport.com/~usb/data/Audio10.pdf
- * http://www.teleport.com/~usb/data/Frmts10.pdf
- * http://www.teleport.com/~usb/data/Termt10.pdf
+ * USB audio specs: http://www.usb.org/developers/data/devclass/audio10.pdf
+ * http://www.usb.org/developers/data/devclass/frmts10.pdf
+ * http://www.usb.org/developers/data/devclass/termt10.pdf
*/
#include <sys/param.h>
@@ -96,6 +96,8 @@ struct mixerctl {
#define MIX_SIZE(n) ((n) == MIX_SIGNED_16 || (n) == MIX_UNSIGNED_16 ? 2 : 1)
#define MIX_UNSIGNED(n) ((n) == MIX_UNSIGNED_16)
int minval, maxval;
+ u_int delta;
+ u_int mul;
u_int8_t class;
char ctlname[MAX_AUDIO_DEV_LEN];
char *ctlunit;
@@ -105,6 +107,7 @@ struct mixerctl {
struct as_info {
u_int8_t alt;
u_int8_t encoding;
+ usbd_interface_handle ifaceh;
usb_interface_descriptor_t *idesc;
usb_endpoint_descriptor_audio_t *edesc;
struct usb_audio_streaming_type1_descriptor *asf1desc;
@@ -115,7 +118,7 @@ struct chan {
void (*intr)(void *); /* dma completion intr handler */
void *arg; /* arg for intr() */
usbd_pipe_handle pipe;
- int dir; /* direction, UE_DIR_XXX */
+ int dir; /* direction */
u_int sample_size;
u_int sample_rate;
@@ -129,6 +132,8 @@ struct chan {
int blksize; /* chunk size to report up */
int transferred; /* transferred bytes not reported up */
+ char nofrac; /* don't do sample rate adjustment */
+
int curchanbuf;
struct chanbuf {
struct chan *chan;
@@ -146,9 +151,7 @@ struct uaudio_softc {
usbd_device_handle sc_udev; /* USB device */
int sc_ac_iface; /* Audio Control interface */
- int sc_as_iface; /* Audio Streaming interface */
usbd_interface_handle sc_ac_ifaceh;
- usbd_interface_handle sc_as_ifaceh;
struct chan sc_chan;
@@ -336,7 +339,7 @@ USB_ATTACH(uaudio)
usb_config_descriptor_t *cdesc;
char devinfo[1024];
usbd_status err;
- int i;
+ int i, j, found;
usbd_devinfo(uaa->device, 0, devinfo);
printf(": %s\n", devinfo);
@@ -360,28 +363,39 @@ USB_ATTACH(uaudio)
sc->sc_ac_ifaceh = uaa->iface;
/* Pick up the AS interface. */
for (i = 0; i < uaa->nifaces; i++) {
- if (uaa->ifaces[i] != NULL) {
- id = usbd_get_interface_descriptor(uaa->ifaces[i]);
- if (id != NULL &&
- id->bInterfaceNumber == sc->sc_as_iface) {
- sc->sc_as_ifaceh = uaa->ifaces[i];
- uaa->ifaces[i] = NULL;
- break;
+ if (uaa->ifaces[i] == NULL)
+ continue;
+ id = usbd_get_interface_descriptor(uaa->ifaces[i]);
+ if (id == NULL)
+ continue;
+ found = 0;
+ for (j = 0; j < sc->sc_nalts; j++) {
+ if (id->bInterfaceNumber ==
+ sc->sc_alts[j].idesc->bInterfaceNumber) {
+ sc->sc_alts[j].ifaceh = uaa->ifaces[i];
+ found = 1;
}
}
+ if (found)
+ uaa->ifaces[i] = NULL;
}
- if (sc->sc_as_ifaceh == NULL) {
- printf("%s: missing AS interface(s)\n",USBDEVNAME(sc->sc_dev));
- USB_ATTACH_ERROR_RETURN;
+ for (j = 0; j < sc->sc_nalts; j++) {
+ if (sc->sc_alts[j].ifaceh == NULL) {
+ printf("%s: alt %d missing AS interface(s)\n", USBDEVNAME(sc->sc_dev), j);
+ USB_ATTACH_ERROR_RETURN;
+ }
}
- printf("%s: streaming interface %d, audio rev %d.%02x\n",
- USBDEVNAME(sc->sc_dev), sc->sc_as_iface,
+ printf("%s: audio rev %d.%02x\n",
+ USBDEVNAME(sc->sc_dev),
sc->sc_audio_rev >> 8, sc->sc_audio_rev & 0xff);
sc->sc_chan.sc = sc;
+ if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_AU_NO_FRAC)
+ sc->sc_chan.nofrac = 1;
+
DPRINTF(("uaudio_attach: doing audio_attach_mi\n"));
#if defined(__OpenBSD__)
audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev);
@@ -520,6 +534,8 @@ uaudio_find_iface(char *buf, int size, int *offsp, int subtype)
void
uaudio_mixer_add_ctl(struct uaudio_softc *sc, struct mixerctl *mc)
{
+ int res;
+
if (sc->sc_nctls == 0)
sc->sc_ctls = malloc(sizeof *mc, M_USBDEV, M_NOWAIT);
else
@@ -531,6 +547,7 @@ uaudio_mixer_add_ctl(struct uaudio_softc *sc, struct mixerctl *mc)
return;
}
+ mc->delta = 0;
if (mc->type != MIX_ON_OFF) {
/* Determine min and max values. */
mc->minval = uaudio_signext(mc->type,
@@ -541,6 +558,14 @@ uaudio_mixer_add_ctl(struct uaudio_softc *sc, struct mixerctl *mc)
uaudio_get(sc, GET_MAX, UT_READ_CLASS_INTERFACE,
mc->wValue[0], mc->wIndex,
MIX_SIZE(mc->type)));
+ mc->mul = mc->maxval - mc->minval;
+ if (mc->mul == 0)
+ mc->mul = 1;
+ res = uaudio_get(sc, GET_RES, UT_READ_CLASS_INTERFACE,
+ mc->wValue[0], mc->wIndex,
+ MIX_SIZE(mc->type));
+ if (res > 0)
+ mc->delta = (res * 256 + mc->mul/2) / mc->mul;
} else {
mc->minval = 0;
mc->maxval = 1;
@@ -962,7 +987,7 @@ uaudio_add_extension(struct uaudio_softc *sc, usb_descriptor_t *v,
DPRINTFN(2,("uaudio_add_extension: bUnitId=%d bNrInPins=%d\n",
d->bUnitId, d->bNrInPins));
- if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_NO_XU)
+ if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_AU_NO_XU)
return;
if (d1->bmControls[0] & UA_EXT_ENABLE_MASK) {
@@ -1057,12 +1082,16 @@ uaudio_process_as(struct uaudio_softc *sc, char *buf, int *offsp,
dir = UE_GET_DIR(ed->bEndpointAddress);
type = UE_GET_ISO_TYPE(ed->bmAttributes);
+ if ((usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_AU_INP_ASYNC) &&
+ dir == UE_DIR_IN && type == UE_ISO_ADAPT)
+ type = UE_ISO_ASYNC;
+
/* We can't handle endpoints that need a sync pipe. */
if (dir == UE_DIR_IN ? type == UE_ISO_ADAPT : type == UE_ISO_ASYNC) {
- printf("%s: ignored %sput endpoint of type 0x%x\n",
+ printf("%s: ignored %sput endpoint of type %s\n",
USBDEVNAME(sc->sc_dev),
dir == UE_DIR_IN ? "in" : "out",
- ed->bmAttributes & UE_ISO_TYPE);
+ dir == UE_DIR_IN ? "adaptive" : "async");
return (USBD_NORMAL_COMPLETION);
}
@@ -1078,7 +1107,7 @@ uaudio_process_as(struct uaudio_softc *sc, char *buf, int *offsp,
chan = asf1d->bNrChannels;
prec = asf1d->bBitResolution;
if (prec != 8 && prec != 16) {
-#ifdef AUDIO_DEBUG
+#ifdef UAUDIO_DEBUG
printf("%s: ignored setting with precision %d\n",
USBDEVNAME(sc->sc_dev), prec);
#endif
@@ -1115,7 +1144,7 @@ uaudio_process_as(struct uaudio_softc *sc, char *buf, int *offsp,
ai.asf1desc = asf1d;
uaudio_add_alt(sc, &ai);
sc->sc_chan.terminal = asid->bTerminalLink; /* XXX */
- sc->sc_chan.dir = dir;
+ sc->sc_chan.dir |= dir == UE_DIR_OUT ? AUMODE_PLAY : AUMODE_RECORD;
return (USBD_NORMAL_COMPLETION);
}
#undef offs
@@ -1136,13 +1165,14 @@ uaudio_identify_as(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
id = uaudio_find_iface(buf, size, &offs, UISUBCLASS_AUDIOSTREAM);
if (id == NULL)
return (USBD_INVAL);
- sc->sc_as_iface = id->bInterfaceNumber;
- DPRINTF(("uaudio_identify_as: AS interface is %d\n", sc->sc_as_iface));
sc->sc_chan.terminal = -1;
+ sc->sc_chan.dir = 0;
/* Loop through all the alternate settings. */
while (offs <= size) {
+ DPRINTFN(2, ("uaudio_identify: interface %d\n",
+ id->bInterfaceNumber));
switch (id->bNumEndpoints) {
case 0:
DPRINTFN(2, ("uaudio_identify: AS null alt=%d\n",
@@ -1153,7 +1183,7 @@ uaudio_identify_as(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
err = uaudio_process_as(sc, buf, &offs, size, id);
break;
default:
-#ifdef AUDIO_DEBUG
+#ifdef UAUDIO_DEBUG
printf("%s: ignored audio interface with %d "
"endpoints\n",
USBDEVNAME(sc->sc_dev), id->bNumEndpoints);
@@ -1172,6 +1202,10 @@ uaudio_identify_as(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
USBDEVNAME(sc->sc_dev));
return (USBD_INVAL);
}
+#if 0
+ if (sc->sc_chan.dir == (AUMODE_PLAY | AUMODE_RECORD))
+ sc->sc_props |= AUDIO_PROP_FULLDUPLEX;
+#endif
return (USBD_NORMAL_COMPLETION);
}
@@ -1336,6 +1370,7 @@ uaudio_query_devinfo(void *addr, mixer_devinfo_t *mi)
mi->type = AUDIO_MIXER_VALUE;
strncpy(mi->un.v.units.name, mc->ctlunit, MAX_AUDIO_DEV_LEN);
mi->un.v.num_channels = mc->nchan;
+ mi->un.v.delta = mc->delta;
break;
}
return (0);
@@ -1353,9 +1388,9 @@ uaudio_open(void *addr, int flags)
if (sc->sc_chan.terminal < 0)
return (ENXIO);
- if ((flags & FREAD) && sc->sc_chan.dir != UE_DIR_IN)
+ if ((flags & FREAD) && !(sc->sc_chan.dir & AUMODE_RECORD))
return (EACCES);
- if ((flags & FWRITE) && sc->sc_chan.dir != UE_DIR_OUT)
+ if ((flags & FWRITE) && !(sc->sc_chan.dir & AUMODE_PLAY))
return (EACCES);
sc->sc_chan.intr = 0;
@@ -1563,8 +1598,8 @@ uaudio_value2bsd(struct mixerctl *mc, int val)
if (mc->type == MIX_ON_OFF)
val = val != 0;
else
- val = (uaudio_signext(mc->type, val) - mc->minval) * 256
- / (mc->maxval - mc->minval);
+ val = ((uaudio_signext(mc->type, val) - mc->minval) * 256
+ + mc->mul/2) / mc->mul;
DPRINTFN(5, ("val'=%d\n", val));
return (val);
}
@@ -1577,7 +1612,7 @@ uaudio_bsd2value(struct mixerctl *mc, int val)
if (mc->type == MIX_ON_OFF)
val = val != 0;
else
- val = val * (mc->maxval - mc->minval) / 256 + mc->minval;
+ val = (val + mc->delta/2) * mc->mul / 256 + mc->minval;
DPRINTFN(5, ("val'=%d\n", val));
return (val);
}
@@ -1777,7 +1812,7 @@ uaudio_chan_open(struct uaudio_softc *sc, struct chan *ch)
endpt, ch->sample_rate, as->alt));
/* Set alternate interface corresponding to the mode. */
- err = usbd_set_interface(sc->sc_as_ifaceh, as->alt);
+ err = usbd_set_interface(as->ifaceh, as->alt);
if (err)
return (err);
@@ -1792,17 +1827,19 @@ uaudio_chan_open(struct uaudio_softc *sc, struct chan *ch)
#endif
DPRINTF(("uaudio_open_chan: create pipe to 0x%02x\n", endpt));
- err = usbd_open_pipe(sc->sc_as_ifaceh, endpt, 0, &ch->pipe);
+ err = usbd_open_pipe(as->ifaceh, endpt, 0, &ch->pipe);
return (err);
}
void
uaudio_chan_close(struct uaudio_softc *sc, struct chan *ch)
{
+ struct as_info *as = &sc->sc_alts[sc->sc_curaltidx];
+
if (sc->sc_nullalt >= 0) {
DPRINTF(("uaudio_close_chan: set null alt=%d\n",
sc->sc_nullalt));
- usbd_set_interface(sc->sc_as_ifaceh, sc->sc_nullalt);
+ usbd_set_interface(as->ifaceh, sc->sc_nullalt);
}
usbd_abort_pipe(ch->pipe);
usbd_close_pipe(ch->pipe);
@@ -1870,7 +1907,8 @@ uaudio_chan_ptransfer(struct chan *ch)
size = ch->bytes_per_frame;
residue += ch->fraction;
if (residue >= USB_FRAMES_PER_SECOND) {
- size += ch->sample_size;
+ if (!ch->nofrac)
+ size += ch->sample_size;
residue -= USB_FRAMES_PER_SECOND;
}
cb->sizes[i] = size;
@@ -1973,7 +2011,8 @@ uaudio_chan_rtransfer(struct chan *ch)
size = ch->bytes_per_frame;
residue += ch->fraction;
if (residue >= USB_FRAMES_PER_SECOND) {
- size += ch->sample_size;
+ if (!ch->nofrac)
+ size += ch->sample_size;
residue -= USB_FRAMES_PER_SECOND;
}
cb->sizes[i] = size;
@@ -2017,9 +2056,17 @@ uaudio_chan_rintr(usbd_xfer_handle xfer, usbd_private_handle priv,
usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
DPRINTFN(5,("uaudio_chan_rintr: count=%d, transferred=%d\n",
count, ch->transferred));
+
+ if (count < cb->size) {
+ /* if the device fails to keep up, copy last byte */
+ u_char b = count ? cb->buffer[count-1] : 0;
+ while (count < cb->size)
+ cb->buffer[count++] = b;
+ }
+
#ifdef DIAGNOSTIC
if (count != cb->size) {
- printf("uaudio_chan_pintr: count(%d) != size(%d)\n",
+ printf("uaudio_chan_rintr: count(%d) != size(%d)\n",
count, cb->size);
}
#endif
@@ -2043,7 +2090,7 @@ uaudio_chan_rintr(usbd_xfer_handle xfer, usbd_private_handle priv,
s = splaudio();
while (ch->transferred >= ch->blksize) {
ch->transferred -= ch->blksize;
- DPRINTFN(5,("uaudio_chan_pintr: call %p(%p)\n",
+ DPRINTFN(5,("uaudio_chan_rintr: call %p(%p)\n",
ch->intr, ch->arg));
ch->intr(ch->arg);
}
@@ -2078,14 +2125,15 @@ uaudio_chan_set_param(struct chan *ch, struct audio_params *param,
int
uaudio_set_params(void *addr, int setmode, int usemode,
- struct audio_params *p, struct audio_params *r)
+ struct audio_params *play, struct audio_params *rec)
{
struct uaudio_softc *sc = addr;
int flags = sc->sc_altflags;
- int pfactor, rfactor;
+ int factor;
int enc, i, j;
- void (*pswcode)(void *, u_char *buf, int cnt);
- void (*rswcode)(void *, u_char *buf, int cnt);
+ void (*swcode)(void *, u_char *buf, int cnt);
+ struct audio_params *p;
+ int mode;
if (sc->sc_dying)
return (EIO);
@@ -2093,132 +2141,149 @@ uaudio_set_params(void *addr, int setmode, int usemode,
if (sc->sc_chan.pipe != NULL)
return (EBUSY);
- pswcode = rswcode = 0;
- pfactor = rfactor = 1;
- enc = p->encoding;
- switch (p->encoding) {
- case AUDIO_ENCODING_SLINEAR_BE:
- if (p->precision == 16) {
- rswcode = pswcode = swap_bytes;
- enc = AUDIO_ENCODING_SLINEAR_LE;
- } else if (p->precision == 8 && !(flags & HAS_8)) {
- pswcode = rswcode = change_sign8;
- enc = AUDIO_ENCODING_ULINEAR_LE;
- }
- break;
- case AUDIO_ENCODING_SLINEAR_LE:
- if (p->precision == 8 && !(flags & HAS_8)) {
- pswcode = rswcode = change_sign8;
- enc = AUDIO_ENCODING_ULINEAR_LE;
- }
- break;
- case AUDIO_ENCODING_ULINEAR_BE:
- if (p->precision == 16) {
- pswcode = swap_bytes_change_sign16_le;
- rswcode = change_sign16_swap_bytes_le;
- enc = AUDIO_ENCODING_SLINEAR_LE;
- } else if (p->precision == 8 && !(flags & HAS_8U)) {
- pswcode = rswcode = change_sign8;
- enc = AUDIO_ENCODING_SLINEAR_LE;
- }
- break;
- case AUDIO_ENCODING_ULINEAR_LE:
- if (p->precision == 16) {
- pswcode = rswcode = change_sign16_le;
- enc = AUDIO_ENCODING_SLINEAR_LE;
- } else if (p->precision == 8 && !(flags & HAS_8U)) {
- pswcode = rswcode = change_sign8;
- enc = AUDIO_ENCODING_SLINEAR_LE;
- }
- break;
- case AUDIO_ENCODING_ULAW:
- if (!(flags & HAS_MULAW)) {
- if (flags & HAS_8U) {
- pswcode = mulaw_to_ulinear8;
- rswcode = ulinear8_to_mulaw;
+ for (mode = AUMODE_RECORD; mode != -1;
+ mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
+ if ((setmode & mode) == 0)
+ continue;
+ if ((sc->sc_chan.dir & mode) == 0)
+ continue;
+
+ p = mode == AUMODE_PLAY ? play : rec;
+
+ factor = 1;
+ swcode = 0;
+ enc = p->encoding;
+ switch (enc) {
+ case AUDIO_ENCODING_SLINEAR_BE:
+ if (p->precision == 16) {
+ swcode = swap_bytes;
+ enc = AUDIO_ENCODING_SLINEAR_LE;
+ } else if (p->precision == 8 && !(flags & HAS_8)) {
+ swcode = change_sign8;
enc = AUDIO_ENCODING_ULINEAR_LE;
- } else if (flags & HAS_8) {
- pswcode = mulaw_to_slinear8;
- rswcode = slinear8_to_mulaw;
+ }
+ break;
+ case AUDIO_ENCODING_SLINEAR_LE:
+ if (p->precision == 8 && !(flags & HAS_8)) {
+ swcode = change_sign8;
+ enc = AUDIO_ENCODING_ULINEAR_LE;
+ }
+ break;
+ case AUDIO_ENCODING_ULINEAR_BE:
+ if (p->precision == 16) {
+ if (mode == AUMODE_PLAY)
+ swcode = swap_bytes_change_sign16_le;
+ else
+ swcode = change_sign16_swap_bytes_le;
enc = AUDIO_ENCODING_SLINEAR_LE;
- } else if (flags & HAS_16) {
- pswcode = mulaw_to_slinear16_le;
- pfactor = 2;
+ } else if (p->precision == 8 && !(flags & HAS_8U)) {
+ swcode = change_sign8;
enc = AUDIO_ENCODING_SLINEAR_LE;
- /* XXX recording not handled */
- if (setmode & AUMODE_RECORD)
- return (EINVAL);
- } else
- return (EINVAL);
- }
- break;
- case AUDIO_ENCODING_ALAW:
- if (!(flags & HAS_ALAW)) {
- if (flags & HAS_8U) {
- pswcode = alaw_to_ulinear8;
- rswcode = ulinear8_to_alaw;
- enc = AUDIO_ENCODING_ULINEAR_LE;
- } else if (flags & HAS_8) {
- pswcode = alaw_to_slinear8;
- rswcode = slinear8_to_alaw;
+ }
+ break;
+ case AUDIO_ENCODING_ULINEAR_LE:
+ if (p->precision == 16) {
+ swcode = change_sign16_le;
enc = AUDIO_ENCODING_SLINEAR_LE;
- } else if (flags & HAS_16) {
- pswcode = alaw_to_slinear16_le;
- pfactor = 2;
+ } else if (p->precision == 8 && !(flags & HAS_8U)) {
+ swcode = change_sign8;
enc = AUDIO_ENCODING_SLINEAR_LE;
- /* XXX recording not handled */
- if (setmode & AUMODE_RECORD)
+ }
+ break;
+ case AUDIO_ENCODING_ULAW:
+ if (!(flags & HAS_MULAW)) {
+ if (mode == AUMODE_PLAY &&
+ (flags & HAS_16)) {
+ swcode = mulaw_to_slinear16_le;
+ factor = 2;
+ enc = AUDIO_ENCODING_SLINEAR_LE;
+ } else if (flags & HAS_8U) {
+ if (mode == AUMODE_PLAY)
+ swcode = mulaw_to_ulinear8;
+ else
+ swcode = ulinear8_to_mulaw;
+ enc = AUDIO_ENCODING_ULINEAR_LE;
+ } else if (flags & HAS_8) {
+ if (mode == AUMODE_PLAY)
+ swcode = mulaw_to_slinear8;
+ else
+ swcode = slinear8_to_mulaw;
+ enc = AUDIO_ENCODING_SLINEAR_LE;
+ } else
return (EINVAL);
- } else
- return (EINVAL);
+ }
+ break;
+ case AUDIO_ENCODING_ALAW:
+ if (!(flags & HAS_ALAW)) {
+ if (mode == AUMODE_PLAY &&
+ (flags & HAS_16)) {
+ swcode = alaw_to_slinear16_le;
+ factor = 2;
+ enc = AUDIO_ENCODING_SLINEAR_LE;
+ } else if (flags & HAS_8U) {
+ if (mode == AUMODE_PLAY)
+ swcode = alaw_to_ulinear8;
+ else
+ swcode = ulinear8_to_alaw;
+ enc = AUDIO_ENCODING_ULINEAR_LE;
+ } else if (flags & HAS_8) {
+ if (mode == AUMODE_PLAY)
+ swcode = alaw_to_slinear8;
+ else
+ swcode = slinear8_to_alaw;
+ enc = AUDIO_ENCODING_SLINEAR_LE;
+ } else
+ return (EINVAL);
+ }
+ break;
+ default:
+ return (EINVAL);
}
- break;
- default:
- return (EINVAL);
- }
- /* XXX do some other conversions... */
-
- DPRINTF(("uaudio_set_params: chan=%d prec=%d enc=%d rate=%ld\n",
- p->channels, p->precision, enc, p->sample_rate));
-
- for (i = 0; i < sc->sc_nalts; i++) {
- struct usb_audio_streaming_type1_descriptor *a1d =
- sc->sc_alts[i].asf1desc;
- if (p->channels == a1d->bNrChannels &&
- p->precision ==a1d->bBitResolution &&
- enc == sc->sc_alts[i].encoding) {
- if (a1d->bSamFreqType == UA_SAMP_CONTNUOUS) {
- DPRINTFN(2,("uaudio_set_params: cont %d-%d\n",
- UA_SAMP_LO(a1d), UA_SAMP_HI(a1d)));
- if (UA_SAMP_LO(a1d) < p->sample_rate &&
- p->sample_rate < UA_SAMP_HI(a1d))
- goto found;
- } else {
- for (j = 0; j < a1d->bSamFreqType; j++) {
- DPRINTFN(2,("uaudio_set_params: disc #"
- "%d: %d\n", j, UA_GETSAMP(a1d, j)));
- /* XXX allow for some slack */
- if (UA_GETSAMP(a1d, j) ==
- p->sample_rate)
+ /* XXX do some other conversions... */
+
+ DPRINTF(("uaudio_set_params: chan=%d prec=%d enc=%d rate=%ld\n",
+ p->channels, p->precision, enc, p->sample_rate));
+
+ for (i = 0; i < sc->sc_nalts; i++) {
+ struct usb_audio_streaming_type1_descriptor *a1d =
+ sc->sc_alts[i].asf1desc;
+ if (p->channels == a1d->bNrChannels &&
+ p->precision == a1d->bBitResolution &&
+ enc == sc->sc_alts[i].encoding &&
+ (mode == AUMODE_PLAY ? UE_DIR_OUT : UE_DIR_IN) ==
+ UE_GET_DIR(sc->sc_alts[i].edesc->bEndpointAddress)) {
+ if (a1d->bSamFreqType == UA_SAMP_CONTNUOUS) {
+ DPRINTFN(2,("uaudio_set_params: cont %d-%d\n",
+ UA_SAMP_LO(a1d), UA_SAMP_HI(a1d)));
+ if (UA_SAMP_LO(a1d) < p->sample_rate &&
+ p->sample_rate < UA_SAMP_HI(a1d))
goto found;
+ } else {
+ for (j = 0; j < a1d->bSamFreqType; j++) {
+ DPRINTFN(2,("uaudio_set_params: disc #"
+ "%d: %d\n", j, UA_GETSAMP(a1d, j)));
+ /* XXX allow for some slack */
+ if (UA_GETSAMP(a1d, j) ==
+ p->sample_rate)
+ goto found;
+ }
}
}
}
- }
- return (EINVAL);
+ return (EINVAL);
- found:
- p->sw_code = pswcode;
- r->sw_code = rswcode;
- p->factor = pfactor;
- r->factor = rfactor;
- sc->sc_curaltidx = i;
+ found:
+ p->sw_code = swcode;
+ p->factor = factor;
+ if (usemode == mode)
+ sc->sc_curaltidx = i;
+ }
DPRINTF(("uaudio_set_params: use altidx=%d, altno=%d\n",
sc->sc_curaltidx,
sc->sc_alts[sc->sc_curaltidx].idesc->bAlternateSetting));
- return (0);
+ return (0);
}
usbd_status
diff --git a/sys/dev/usb/uaudioreg.h b/sys/dev/usb/uaudioreg.h
index 49fd49c07e6..d843bca6fdd 100644
--- a/sys/dev/usb/uaudioreg.h
+++ b/sys/dev/usb/uaudioreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uaudioreg.h,v 1.5 2000/11/08 18:10:37 aaron Exp $ */
+/* $OpenBSD: uaudioreg.h,v 1.6 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: uaudioreg.h,v 1.6 2000/05/30 10:10:17 augustss Exp $ */
/*
@@ -239,7 +239,70 @@ struct usb_audio_extension_unit_1 {
/*uByte iExtension;*/
} UPACKED;
-#define UAT_STREAM 0x0101
+/* USB terminal types */
+#define UAT_UNDEFINED 0x0100
+#define UAT_STREAM 0x0101
+#define UAT_VENDOR 0x01ff
+/* input terminal types */
+#define UATI_UNDEFINED 0x0200
+#define UATI_MICROPHONE 0x0201
+#define UATI_DESKMICROPHONE 0x0202
+#define UATI_PERSONALMICROPHONE 0x0203
+#define UATI_OMNIMICROPHONE 0x0204
+#define UATI_MICROPHONEARRAY 0x0205
+#define UATI_PROCMICROPHONEARR 0x0206
+/* output terminal types */
+#define UATO_UNDEFINED 0x0300
+#define UATO_SPEAKER 0x0301
+#define UATO_HEADPHONES 0x0302
+#define UATO_DISPLAYAUDIO 0x0303
+#define UATO_DESKTOPSPEAKER 0x0304
+#define UATO_ROOMSPEAKER 0x0305
+#define UATO_COMMSPEAKER 0x0306
+#define UATO_SUBWOOFER 0x0307
+/* bidir terminal types */
+#define UATB_UNDEFINED 0x0400
+#define UATB_HANDSET 0x0401
+#define UATB_HEADSET 0x0402
+#define UATB_SPEAKERPHONE 0x0403
+#define UATB_SPEAKERPHONEESUP 0x0404
+#define UATB_SPEAKERPHONEECANC 0x0405
+/* telephony terminal types */
+#define UATT_UNDEFINED 0x0500
+#define UATT_PHONELINE 0x0501
+#define UATT_TELEPHONE 0x0502
+#define UATT_DOWNLINEPHONE 0x0503
+/* external terminal types */
+#define UATE_UNDEFINED 0x0600
+#define UATE_ANALOGCONN 0x0601
+#define UATE_DIGITALAUIFC 0x0602
+#define UATE_LINECONN 0x0603
+#define UATE_LEGACYCONN 0x0604
+#define UATE_SPDIF 0x0605
+#define UATE_1394DA 0x0606
+#define UATE_1394DV 0x0607
+/* embedded function terminal types */
+#define UATF_UNDEFINED 0x0700
+#define UATF_CALIBNOISE 0x0701
+#define UATF_EQUNOISE 0x0702
+#define UATF_CDPLAYER 0x0703
+#define UATF_DAT 0x0704
+#define UATF_DCC 0x0705
+#define UATF_MINIDISK 0x0706
+#define UATF_ANALOGTAPE 0x0707
+#define UATF_PHONOGRAPH 0x0708
+#define UATF_VCRAUDIO 0x0709
+#define UATF_VIDEODISCAUDIO 0x070a
+#define UATF_DVDAUDIO 0x070b
+#define UATF_TVTUNERAUDIO 0x070c
+#define UATF_SATELLITE 0x070d
+#define UATF_CABLETUNER 0x070e
+#define UATF_DSS 0x070f
+#define UATF_RADIORECV 0x0710
+#define UATF_RADIOXMIT 0x0711
+#define UATF_MULTITRACK 0x0712
+#define UATF_SYNTHESIZER 0x0713
+
#define SET_CUR 0x01
#define GET_CUR 0x81
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index 1fdf8aa071f..00107ea2bca 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ucom.c,v 1.6 2000/11/08 18:10:37 aaron Exp $ */
+/* $OpenBSD: ucom.c,v 1.7 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: ucom.c,v 1.30 2000/09/23 04:33:04 augustss Exp $ */
/*
@@ -966,6 +966,9 @@ ucomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
}
usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
+#if defined(__NetBSD__) && NRND > 0
+ rnd_add_uint32(&sc->sc_rndsource, cc);
+#endif
DPRINTFN(5,("ucomwritecb: cc=%d\n", cc));
/* convert from USB bytes to tty bytes */
cc -= sc->sc_opkthdrlen;
@@ -1021,6 +1024,9 @@ ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
}
usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
+#if defined(__NetBSD__) && NRND > 0
+ rnd_add_uint32(&sc->sc_rndsource, cc);
+#endif
DPRINTFN(5,("ucomreadcb: got %d chars, tp=%p\n", cc, tp));
if (sc->sc_methods->ucom_read != NULL)
sc->sc_methods->ucom_read(sc->sc_parent, sc->sc_portno,
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 6fa37f3f683..56b28da7eb3 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ugen.c,v 1.13 2000/11/21 18:45:53 mickey Exp $ */
+/* $OpenBSD: ugen.c,v 1.14 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: ugen.c,v 1.43 2000/10/24 14:53:59 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -1224,7 +1224,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd,
}
case USB_GET_DEVICEINFO:
usbd_fill_deviceinfo(sc->sc_udev,
- (struct usb_device_info *)addr);
+ (struct usb_device_info *)addr, 1);
break;
default:
return (EINVAL);
diff --git a/sys/dev/usb/ugraphire_rdesc.h b/sys/dev/usb/ugraphire_rdesc.h
new file mode 100644
index 00000000000..5942419415b
--- /dev/null
+++ b/sys/dev/usb/ugraphire_rdesc.h
@@ -0,0 +1,92 @@
+/* $OpenBSD: ugraphire_rdesc.h,v 1.1 2001/01/28 09:43:41 aaron Exp $ */
+/* $NetBSD: $ */
+/*
+ * Copyright (c) 2000 Nick Hibma <n_hibma@freebsd.org>
+ * 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/uhci.c b/sys/dev/usb/uhci.c
index faa0dfec7fd..e626229beeb 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhci.c,v 1.17 2000/12/11 04:23:20 ho Exp $ */
+/* $OpenBSD: uhci.c,v 1.18 2001/01/28 09:43:41 aaron Exp $ */
/* $NetBSD: uhci.c,v 1.125 2000/09/23 21:00:10 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -43,8 +43,8 @@
* USB Universal Host Controller driver.
* Handles e.g. PIIX3 and PIIX4.
*
- * UHCI spec: http://www.intel.com/design/usb/uhci11d.pdf
- * USB spec: http://www.usb.org/developers/data/usb11.pdf
+ * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm
+ * USB spec: http://www.usb.org/developers/data/usbspec.zip
* PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf
* ftp://download.intel.com/design/intarch/datashts/29056201.pdf
*/
@@ -110,6 +110,20 @@ int uhcinoloop = 0;
#define DPRINTFN(n,x)
#endif
+/*
+ * The UHCI controller is little endian, so on big endian machines
+ * the data strored in memory needs to be swapped.
+ */
+#if defined(__FreeBSD__)
+#if BYTE_ORDER == BIG_ENDIAN
+#define htole32(x) (bswap32(x))
+#define le32toh(x) (bswap32(x))
+#else
+#define htole32(x) (x)
+#define le32toh(x) (x)
+#endif
+#endif
+
struct uhci_pipe {
struct usbd_pipe pipe;
int nexttoggle;
@@ -681,7 +695,9 @@ uhci_power(int why, void *v)
DPRINTF(("uhci_power: sc=%p, why=%d (was %d), cmd=0x%x\n",
sc, why, sc->sc_suspend, cmd));
- if (why != PWR_RESUME) {
+ switch (why) {
+ case PWR_SUSPEND:
+ case PWR_STANDBY:
#ifdef UHCI_DEBUG
if (uhcidebug > 2)
uhci_dumpregs(sc);
@@ -701,7 +717,8 @@ uhci_power(int why, void *v)
sc->sc_suspend = why;
sc->sc_bus.use_polling--;
DPRINTF(("uhci_power: cmd=0x%x\n", UREAD2(sc, UHCI_CMD)));
- } else {
+ break;
+ case PWR_RESUME:
#ifdef DIAGNOSTIC
if (sc->sc_suspend == PWR_RESUME)
printf("uhci_power: weird, resume without suspend.\n");
@@ -731,6 +748,13 @@ uhci_power(int why, void *v)
if (uhcidebug > 2)
uhci_dumpregs(sc);
#endif
+ break;
+#if defined(__NetBSD__)
+ case PWR_SOFTSUSPEND:
+ case PWR_SOFTSTANDBY:
+ case PWR_SOFTRESUME:
+ break;
+#endif
}
splx(s);
}
@@ -1139,16 +1163,16 @@ uhci_intr(void *arg)
}
#endif
+ status = UREAD2(sc, UHCI_STS);
+ if (status == 0) /* The interrupt was not for us. */
+ return (0);
+
if (sc->sc_suspend != PWR_RESUME) {
printf("%s: interrupt while not operating ignored\n",
USBDEVNAME(sc->sc_bus.bdev));
return (0);
}
- status = UREAD2(sc, UHCI_STS);
- if (status == 0) /* The interrupt was not for us. */
- return (0);
-
#if defined(DIAGNOSTIC) && defined(__NetBSD__)
if (sc->sc_suspend != PWR_RESUME)
printf("uhci_intr: suspended sts=0x%x\n", status);
@@ -1178,7 +1202,7 @@ uhci_intr(void *arg)
/* no acknowledge needed */
if (!sc->sc_dying)
printf("%s: host controller halted\n",
- USBDEVNAME(sc->sc_bus.bdev));
+ USBDEVNAME(sc->sc_bus.bdev));
sc->sc_dying = 1;
#ifdef UHCI_DEBUG
uhci_dump_all(sc);
@@ -1317,7 +1341,7 @@ uhci_idone(uhci_intr_info_t *ii)
if (xfer->nframes != 0) {
/* Isoc transfer, do things differently. */
uhci_soft_td_t **stds = upipe->u.iso.stds;
- int i, n, nframes;
+ int i, n, nframes, len;
DPRINTFN(5,("uhci_idone: ii=%p isoc ready\n", ii));
@@ -1335,7 +1359,9 @@ uhci_idone(uhci_intr_info_t *ii)
if (++n >= UHCI_VFRAMELIST_COUNT)
n = 0;
status = le32toh(std->td.td_status);
- actlen += UHCI_TD_GET_ACTLEN(status);
+ len = UHCI_TD_GET_ACTLEN(status);
+ xfer->frlengths[i] = len;
+ actlen += len;
}
upipe->u.iso.inuse -= nframes;
xfer->actlen = actlen;
@@ -2348,7 +2374,7 @@ uhci_device_isoc_abort(usbd_xfer_handle xfer)
for (i = 0; i < nframes; i++) {
std = stds[n];
std->td.td_status &= htole32(~(UHCI_TD_ACTIVE | UHCI_TD_IOC));
- len = UHCI_TD_GET_MAXLEN(std->td.td_token);
+ len = UHCI_TD_GET_MAXLEN(le32toh(std->td.td_token));
if (len > maxlen)
maxlen = len;
if (++n >= UHCI_VFRAMELIST_COUNT)
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index e47a2454e3d..2730e06efd8 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhid.c,v 1.12 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: uhid.c,v 1.13 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: uhid.c,v 1.40 2000/10/10 12:37:01 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $ */
@@ -40,7 +40,7 @@
*/
/*
- * HID spec: http://www.usb.org/developers/data/usbhid10.pdf
+ * HID spec: http://www.usb.org/developers/data/devclass/hid1_1.pdf
*/
#include <sys/param.h>
@@ -69,11 +69,15 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
+#include <dev/usb/usbdevs.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/hid.h>
#include <dev/usb/usb_quirks.h>
+/* Report descriptor for broken Wacom Graphire */
+#include <dev/usb/ugraphire_rdesc.h>
+
#ifdef UHID_DEBUG
#define DPRINTF(x) if (uhiddebug) logprintf x
#define DPRINTFN(n,x) if (uhiddebug>(n)) logprintf x
@@ -216,8 +220,22 @@ 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;
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index b3298635eca..5a60a06232b 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhub.c,v 1.11 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: uhub.c,v 1.12 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: uhub.c,v 1.47 2000/09/24 02:08:38 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
@@ -40,7 +40,7 @@
*/
/*
- * USB spec: http://www.usb.org/developers/docs.htm
+ * USB spec: http://www.usb.org/developers/data/usbspec.zip
*/
#include <sys/param.h>
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index aff3ecf2b93..c37773136f3 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -38,7 +38,7 @@
*/
/*
- * HID spec: http://www.usb.org/developers/data/usbhid10.pdf
+ * HID spec: http://www.usb.org/developers/data/devclass/hid1_1.pdf
*/
#include <sys/param.h>
@@ -77,7 +77,7 @@
#include "opt_wsdisplay_compat.h"
#endif
-#ifdef USB_DEBUG
+#ifdef UKBD_DEBUG
#define DPRINTF(x) if (ukbddebug) logprintf x
#define DPRINTFN(n,x) if (ukbddebug>(n)) logprintf x
int ukbddebug = 0;
@@ -138,13 +138,13 @@ Static u_int8_t ukbd_trtab[256] = {
22, 47, 17, 45, 21, 44, 2, 3, /* 18 - 1F */
4, 5, 6, 7, 8, 9, 10, 11, /* 20 - 27 */
28, 1, 14, 15, 57, 12, 13, 26, /* 28 - 2F */
- 27, 43, NN, 39, 40, 41, 51, 52, /* 30 - 37 */
+ 27, 43, 43, 39, 40, 41, 51, 52, /* 30 - 37 */
53, 58, 59, 60, 61, 62, 63, 64, /* 38 - 3F */
65, 66, 67, 68, 87, 88, 170, 70, /* 40 - 47 */
127, 210, 199, 201, 211, 207, 209, 205, /* 48 - 4F */
203, 208, 200, 69, 181, 55, 74, 78, /* 50 - 57 */
156, 79, 80, 81, 75, 76, 77, 71, /* 58 - 5F */
- 72, 73, 82, 83, NN, 221, NN, NN, /* 60 - 67 */
+ 72, 73, 82, 83, 86, 221, NN, NN, /* 60 - 67 */
NN, NN, NN, NN, NN, NN, NN, NN, /* 68 - 6F */
NN, NN, NN, NN, NN, NN, NN, NN, /* 70 - 77 */
NN, NN, NN, NN, NN, NN, NN, NN, /* 78 - 7F */
@@ -185,6 +185,10 @@ struct ukbd_softc {
int sc_console_keyboard; /* we are the console keyboard */
+ char sc_debounce; /* for quirk handling */
+ struct callout sc_delay; /* for quirk handling */
+ struct ukbd_data sc_data; /* for quirk handling */
+
int sc_leds;
#if defined(__OpenBSD__)
@@ -211,12 +215,38 @@ struct ukbd_softc {
u_char sc_dying;
};
+#ifdef UKBD_DEBUG
+#define UKBDTRACESIZE 64
+struct ukbdtraceinfo {
+ int unit;
+ struct timeval tv;
+ struct ukbd_data ud;
+};
+struct ukbdtraceinfo ukbdtracedata[UKBDTRACESIZE];
+int ukbdtraceindex = 0;
+int ukbdtrace = 0;
+void ukbdtracedump(void);
+void
+ukbdtracedump(void)
+{
+ int i;
+ for (i = 0; i < UKBDTRACESIZE; i++) {
+ struct ukbdtraceinfo *p =
+ &ukbdtracedata[(i+ukbdtraceindex)%UKBDTRACESIZE];
+ printf("%lu.%06lu: mod=0x%02x key0=0x%02x key1=0x%02x "
+ "key2=0x%02x key3=0x%02x\n",
+ p->tv.tv_sec, p->tv.tv_usec,
+ p->ud.modifiers, p->ud.keycode[0], p->ud.keycode[1],
+ p->ud.keycode[2], p->ud.keycode[3]);
+ }
+}
+#endif
+
#define UKBDUNIT(dev) (minor(dev))
#define UKBD_CHUNK 128 /* chunk size for read */
#define UKBD_BSIZE 1020 /* buffer size */
-Static int ukbd_is_console = 0;
-
+Static int ukbd_is_console;
Static void ukbd_cngetc(void *, u_int *, int *);
Static void ukbd_cnpollc(void *, int);
@@ -229,6 +259,8 @@ const struct wskbd_consops ukbd_consops = {
#endif
Static void ukbd_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
+Static void ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud);
+Static void ukbd_delayed_decode(void *addr);
Static int ukbd_enable(void *, int);
Static void ukbd_set_leds(void *, int);
@@ -279,6 +311,7 @@ USB_ATTACH(ukbd)
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
usbd_status err;
+ u_int32_t qflags;
char devinfo[1024];
#if defined(__NetBSD__) || defined(__OpenBSD__)
struct wskbddev_attach_args a;
@@ -317,7 +350,8 @@ USB_ATTACH(ukbd)
USB_ATTACH_ERROR_RETURN;
}
- if ((usbd_get_quirks(uaa->device)->uq_flags & UQ_NO_SET_PROTO) == 0) {
+ qflags = usbd_get_quirks(uaa->device)->uq_flags;
+ if ((qflags & UQ_NO_SET_PROTO) == 0) {
err = usbd_set_protocol(iface, 0);
DPRINTFN(5, ("ukbd_attach: protocol set\n"));
if (err) {
@@ -326,9 +360,10 @@ USB_ATTACH(ukbd)
USB_ATTACH_ERROR_RETURN;
}
}
+ sc->sc_debounce = (qflags & UQ_SPUR_BUT_UP) != 0;
/* Ignore if SETIDLE fails since it is not crucial. */
- usbd_set_idle(iface, 0, 0);
+ (void)usbd_set_idle(iface, 0, 0);
sc->sc_ep_addr = ed->bEndpointAddress;
@@ -358,10 +393,12 @@ USB_ATTACH(ukbd)
#if defined(__OpenBSD__) && defined(WSDISPLAY_COMPAT_RAWKBD)
timeout_set(&sc->sc_rawrepeat_ch, ukbd_rawrepeat, sc);
+ timeout_set(&sc->sc_delay, ukbd_delayed_decode, sc);
#endif
#if defined(__NetBSD__)
callout_init(&sc->sc_rawrepeat_ch);
+ callout_init(&sc->sc_delay);
#endif
/* Flash the leds; no real purpose, just shows we're alive. */
@@ -483,12 +520,6 @@ ukbd_intr(xfer, addr, status)
{
struct ukbd_softc *sc = addr;
struct ukbd_data *ud = &sc->sc_ndata;
- int mod, omod;
- u_int16_t ibuf[MAXKEYS]; /* chars events */
- int s;
- int nkeys, i, j;
- int key;
-#define ADDKEY(c) ibuf[nkeys++] = (c)
DPRINTFN(5, ("ukbd_intr: status=%d\n", status));
if (status == USBD_CANCELLED)
@@ -500,8 +531,65 @@ ukbd_intr(xfer, addr, status)
return;
}
- DPRINTFN(5, (" mod=0x%02x key0=0x%02x key1=0x%02x\n",
- ud->modifiers, ud->keycode[0], ud->keycode[1]));
+ if (sc->sc_debounce) {
+ /*
+ * Some keyboards have a peculiar quirk. They sometimes
+ * generate a key up followed by a key down for the same
+ * key after about 10 ms.
+ * We avoid this bug by holding off decoding for 20 ms.
+ */
+ sc->sc_data = *ud;
+#if defined(__OpenBSD__)
+ timeout_add(&sc->sc_delay, hz / 50);
+#else
+ callout_reset(&sc->sc_delay, hz / 50, ukbd_delayed_decode, sc);
+#endif
+ } else {
+ ukbd_decode(sc, ud);
+ }
+}
+
+void
+ukbd_delayed_decode(void *addr)
+{
+ struct ukbd_softc *sc = addr;
+
+ ukbd_decode(sc, &sc->sc_data);
+}
+
+void
+ukbd_decode(struct ukbd_softc *sc, struct ukbd_data *ud)
+{
+ int mod, omod;
+ u_int16_t ibuf[MAXKEYS]; /* chars events */
+ int s;
+ int nkeys, i, j;
+ int key;
+#define ADDKEY(c) ibuf[nkeys++] = (c)
+
+#ifdef UKBD_DEBUG
+ /*
+ * Keep a trace of the last events. Using printf changes the
+ * timing, so this can be useful sometimes.
+ */
+ if (ukbdtrace) {
+ struct ukbdtraceinfo *p = &ukbdtracedata[ukbdtraceindex];
+ p->unit = sc->sc_dev.dv_unit;
+ microtime(&p->tv);
+ p->ud = *ud;
+ if (++ukbdtraceindex >= UKBDTRACESIZE)
+ ukbdtraceindex = 0;
+ }
+ if (ukbddebug > 5) {
+ struct timeval tv;
+ microtime(&tv);
+ DPRINTF((" at %lu.%06lu mod=0x%02x key0=0x%02x key1=0x%02x "
+ "key2=0x%02x key3=0x%02x\n",
+ tv.tv_sec, tv.tv_usec,
+ ud->modifiers, ud->keycode[0], ud->keycode[1],
+ ud->keycode[2], ud->keycode[3]));
+ }
+#endif
if (ud->keycode[0] == KEY_ERROR) {
DPRINTF(("ukbd_intr: KEY_ERROR\n"));
@@ -526,6 +614,7 @@ ukbd_intr(xfer, addr, status)
for (j = 0; j < NKEYCODE; j++)
if (key == ud->keycode[j])
goto rfound;
+ DPRINTFN(3,("ukbd_intr: relse key=0x%02x\n", key));
ADDKEY(key | RELEASE);
rfound:
;
diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c
index d17b46e035b..ede62f3d4d9 100644
--- a/sys/dev/usb/ulpt.c
+++ b/sys/dev/usb/ulpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ulpt.c,v 1.5 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: ulpt.c,v 1.6 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: ulpt.c,v 1.38 2000/06/01 14:29:00 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $ */
@@ -40,7 +40,7 @@
*/
/*
- * Printer Class spec: http://www.usb.org/developers/data/usbprn10.pdf
+ * Printer Class spec: http://www.usb.org/developers/data/devclass/usbprint109.PDF
*/
#include <sys/param.h>
@@ -369,7 +369,17 @@ ulpt_reset(struct ulpt_softc *sc)
USETW(req.wValue, 0);
USETW(req.wIndex, sc->sc_ifaceno);
USETW(req.wLength, 0);
- (void)usbd_do_request(sc->sc_udev, &req, 0);
+
+ /*
+ * There was a mistake in the USB printer 1.0 spec that gave the
+ * request type as UT_WRITE_CLASS_OTHER, it should have been
+ * UT_WRITE_CLASS_INTERFACE. Many printers use the old one,
+ * so we try both.
+ */
+ if (usbd_do_request(sc->sc_udev, &req, 0)) {
+ req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+ (void)usbd_do_request(sc->sc_udev, &req, 0);
+ }
}
/*
@@ -403,33 +413,48 @@ ulptopen(dev_t dev, int flag, int mode, struct proc *p)
#endif
+ error = 0;
+ sc->sc_refcnt++;
+
if ((flags & ULPT_NOPRIME) == 0)
ulpt_reset(sc);
for (spin = 0; (ulpt_status(sc) & LPS_SELECT) == 0; spin += STEP) {
if (spin >= TIMEOUT) {
+ error = EBUSY;
sc->sc_state = 0;
- return (EBUSY);
+ goto done;
}
/* wait 1/4 second, give up if we get a signal */
error = tsleep((caddr_t)sc, LPTPRI | PCATCH, "ulptop", STEP);
if (error != EWOULDBLOCK) {
sc->sc_state = 0;
- return (error);
+ goto done;
+ }
+
+ if (sc->sc_dying) {
+ error = ENXIO;
+ sc->sc_state = 0;
+ goto done;
}
}
err = usbd_open_pipe(sc->sc_iface, sc->sc_bulk, 0, &sc->sc_bulkpipe);
if (err) {
sc->sc_state = 0;
- return (EIO);
+ error = EIO;
+ goto done;
}
sc->sc_state = ULPT_OPEN;
- DPRINTF(("ulptopen: done\n"));
- return (0);
+ done:
+ if (--sc->sc_refcnt < 0)
+ usb_detach_wakeup(USBDEV(sc->sc_dev));
+
+ DPRINTF(("ulptopen: done, error=%d\n", error));
+ return (error);
}
int
diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c
index 458c8ac4e11..3340bf3765a 100644
--- a/sys/dev/usb/umodem.c
+++ b/sys/dev/usb/umodem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: umodem.c,v 1.5 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: umodem.c,v 1.6 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: umodem.c,v 1.31 2000/10/22 08:20:09 explorer Exp $ */
/*
@@ -39,7 +39,8 @@
*/
/*
- * Comm Class spec: http://www.usb.org/developers/data/usbcdc11.pdf
+ * Comm Class spec: http://www.usb.org/developers/data/devclass/usbcdc10.pdf
+ * http://www.usb.org/developers/data/devclass/usbcdc11.pdf
*/
/*
@@ -263,8 +264,11 @@ USB_ATTACH(umodem)
sc->sc_cm_over_data = 1;
} else {
if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) {
- err = umodem_set_comm_feature(sc, UCDC_ABSTRACT_STATE,
- UCDC_DATA_MULTIPLEXED);
+ if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE)
+ err = umodem_set_comm_feature(sc,
+ UCDC_ABSTRACT_STATE, UCDC_DATA_MULTIPLEXED);
+ else
+ err = 0;
if (err) {
printf("%s: could not set data multiplex mode\n",
USBDEVNAME(sc->sc_dev));
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index bf013a2d675..634bc82ba7b 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ums.c,v 1.3 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: ums.c,v 1.4 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: ums.c,v 1.45 2000/10/08 20:52:18 augustss Exp $ */
/*
@@ -39,7 +39,7 @@
*/
/*
- * HID spec: http://www.usb.org/developers/data/usbhid10.pdf
+ * HID spec: http://www.usb.org/developers/data/devclass/hid1_1.pdf
*/
/* XXX complete SPUR_UP change */
diff --git a/sys/dev/usb/urio.c b/sys/dev/usb/urio.c
index ca8e549f0e2..35cd619bda6 100644
--- a/sys/dev/usb/urio.c
+++ b/sys/dev/usb/urio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: urio.c,v 1.4 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: urio.c,v 1.5 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: urio.c,v 1.5 2000/10/24 14:53:59 augustss Exp $ */
/*
@@ -274,9 +274,7 @@ USB_DETACH(urio)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-urio_activate(self, act)
- device_ptr_t self;
- enum devact act;
+urio_activate(device_ptr_t self, enum devact act)
{
struct urio_softc *sc = (struct urio_softc *)self;
@@ -294,11 +292,7 @@ urio_activate(self, act)
#endif
int
-urioopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+urioopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct urio_softc *sc;
usbd_status err;
@@ -331,11 +325,7 @@ urioopen(dev, flag, mode, p)
}
int
-urioclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+urioclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct urio_softc *sc;
USB_GET_SC(urio, URIOUNIT(dev), sc);
@@ -358,10 +348,7 @@ urioclose(dev, flag, mode, p)
}
int
-urioread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+urioread(dev_t dev, struct uio *uio, int flag)
{
struct urio_softc *sc;
usbd_xfer_handle xfer;
@@ -418,10 +405,7 @@ urioread(dev, uio, flag)
}
int
-uriowrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+uriowrite(dev_t dev, struct uio *uio, int flag)
{
struct urio_softc *sc;
usbd_xfer_handle xfer;
@@ -483,12 +467,7 @@ uriowrite(dev, uio, flag)
int
-urioioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+urioioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
{
struct urio_softc * sc;
int unit = URIOUNIT(dev);
@@ -583,10 +562,7 @@ ret:
}
int
-uriopoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+uriopoll(dev_t dev, int events, struct proc *p)
{
return (0);
}
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index b1a0cb22b41..0683597dfab 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.13 2000/11/08 18:10:38 aaron Exp $ */
+/* $OpenBSD: usb.c,v 1.14 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb.c,v 1.47 2000/08/24 14:12:34 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.c,v 1.20 1999/11/17 22:33:46 n_hibma Exp $ */
@@ -499,7 +499,7 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
dev = sc->sc_bus->devices[addr];
if (dev == NULL)
return (ENXIO);
- usbd_fill_deviceinfo(dev, di);
+ usbd_fill_deviceinfo(dev, di, 1);
break;
}
@@ -621,7 +621,7 @@ usbd_add_dev_event(int type, usbd_device_handle udev)
{
struct usb_event ue;
- usbd_fill_deviceinfo(udev, &ue.u.ue_device);
+ usbd_fill_deviceinfo(udev, &ue.u.ue_device, USB_EVENT_IS_ATTACH(type));
usb_add_event(type, &ue);
}
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 956ba2fca84..a02573c4d9a 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.11 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usb.h,v 1.12 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb.h,v 1.50 2000/06/01 15:43:32 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
@@ -561,6 +561,7 @@ struct usb_event {
#define USB_EVENT_DEVICE_DETACH 4
#define USB_EVENT_DRIVER_ATTACH 5
#define USB_EVENT_DRIVER_DETACH 6
+#define USB_EVENT_IS_ATTACH(n) ((n) == USB_EVENT_CTRLR_ATTACH || (n) == USB_EVENT_DEVICE_ATTACH || (n) == USB_EVENT_DRIVER_ATTACH)
struct timespec ue_time;
union {
struct {
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index 484638df9ed..4b090d8057f 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_port.h,v 1.20 2000/11/11 16:23:30 drahn Exp $ */
+/* $OpenBSD: usb_port.h,v 1.21 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb_port.h,v 1.35 2000/09/23 04:32:23 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -258,6 +258,7 @@ typedef int usb_malloc_type;
#define uhidpoll uhidselect
#define ugenpoll ugenselect
#define uriopoll urioselect
+#define uscannerpoll uscannerselect
#define powerhook_establish(fn, sc) (fn)
#define powerhook_disestablish(hdl)
diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c
index 09e198590bd..2c7be8676f6 100644
--- a/sys/dev/usb/usb_quirks.c
+++ b/sys/dev/usb/usb_quirks.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_quirks.c,v 1.7 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usb_quirks.c,v 1.8 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb_quirks.c,v 1.31 2000/10/24 14:57:35 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.13 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -51,7 +51,7 @@
extern int usbdebug;
#endif
-Static struct usbd_quirk_entry {
+Static const struct usbd_quirk_entry {
u_int16_t idVendor;
u_int16_t idProduct;
u_int16_t bcdDevice;
@@ -65,7 +65,7 @@ Static struct usbd_quirk_entry {
{ USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_WACOM, USB_PRODUCT_WACOM_CT0405U, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_BAD_ADC }},
- { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_NO_XU }},
+ { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_AU_NO_XU }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ADA70, 0x103, { UQ_BAD_ADC }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ASC495, 0x000, { UQ_BAD_AUDIO }},
{ USB_VENDOR_QTRONIX, USB_PRODUCT_QTRONIX_980N, 0x110, { UQ_SPUR_BUT_UP }},
@@ -75,15 +75,20 @@ Static struct usbd_quirk_entry {
{ USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS,
0x100, { UQ_ASSUME_CM_OVER_DATA | UQ_NO_STRINGS }},
{ USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41, 0x110, { UQ_POWER_CLAIM }},
+ { USB_VENDOR_ACERP, USB_PRODUCT_ACERP_ACERSCAN_320U,
+ 0x000, { UQ_NO_STRINGS }},
+ { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, { UQ_AU_NO_FRAC }},
+ { USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE,
+ 0x100, { UQ_AU_INP_ASYNC }},
{ 0, 0, 0, { 0 } }
};
-struct usbd_quirks usbd_no_quirk = { 0 };
+const struct usbd_quirks usbd_no_quirk = { 0 };
-struct usbd_quirks *
+const struct usbd_quirks *
usbd_find_quirk(usb_device_descriptor_t *d)
{
- struct usbd_quirk_entry *t;
+ const struct usbd_quirk_entry *t;
for (t = usb_quirks; t->idVendor != 0; t++) {
if (t->idVendor == UGETW(d->idVendor) &&
diff --git a/sys/dev/usb/usb_quirks.h b/sys/dev/usb/usb_quirks.h
index 94212334792..7b757073082 100644
--- a/sys/dev/usb/usb_quirks.h
+++ b/sys/dev/usb/usb_quirks.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_quirks.h,v 1.6 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usb_quirks.h,v 1.7 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb_quirks.h,v 1.15 2000/10/24 14:56:09 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_quirks.h,v 1.9 1999/11/12 23:31:03 n_hibma Exp $ */
@@ -49,11 +49,13 @@ struct usbd_quirks {
#define UQ_BUS_POWERED 0x0020 /* device is bus powered, despite claim */
#define UQ_BAD_AUDIO 0x0040 /* device claims audio class, but isn't */
#define UQ_SPUR_BUT_UP 0x0080 /* spurious mouse button up events */
-#define UQ_NO_XU 0x0100 /* audio device has broken extension unit */
-#define UQ_ASSUME_CM_OVER_DATA 0x0200 /* modem device breaks on cm over data */
-#define UQ_POWER_CLAIM 0x0400 /* hub lies about power status */
+#define UQ_AU_NO_XU 0x0100 /* audio device has broken extension unit */
+#define UQ_POWER_CLAIM 0x0200 /* hub lies about power status */
+#define UQ_AU_NO_FRAC 0x0400 /* don't adjust for fractional samples */
+#define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */
+#define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
};
-extern struct usbd_quirks usbd_no_quirk;
+extern const struct usbd_quirks usbd_no_quirk;
-struct usbd_quirks *usbd_find_quirk(usb_device_descriptor_t *);
+const struct usbd_quirks *usbd_find_quirk(usb_device_descriptor_t *);
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index f0eaa01ccdc..2f4c7b5db4f 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.15 2001/01/27 04:02:10 deraadt Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.16 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usb_subr.c,v 1.72 2000/04/14 14:13:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -76,7 +76,8 @@ extern int usbdebug;
#define DPRINTFN(n,x)
#endif
-Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static void usbd_devinfo_vp(usbd_device_handle, char *, char *, int);
Static char *usbd_get_string(usbd_device_handle, int, char *);
Static int usbd_getnewaddr(usbd_bus_handle bus);
#if defined(__NetBSD__)
@@ -114,7 +115,7 @@ struct usb_known_product {
#include <dev/usb/usbdevs_data.h>
#endif /* USBVERBOSE */
-Static const char *usbd_error_strs[] = {
+Static const char * const usbd_error_strs[] = {
"NORMAL_COMPLETION",
"IN_PROGRESS",
"PENDING_REQUESTS",
@@ -212,14 +213,26 @@ usbd_get_string(usbd_device_handle dev, int si, char *buf)
return (buf);
}
+static void
+usbd_trim_trailings_spaces(char *p)
+{
+ char *q;
+
+ if (p == NULL)
+ return;
+ q = p + strlen(p);
+ while (--q >= p && *q == ' ')
+ *q = 0;
+}
+
void
-usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p)
+usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p, int usedev)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
#ifdef USBVERBOSE
- struct usb_known_vendor *ukv;
- struct usb_known_product *ukp;
+ const struct usb_known_vendor *ukv;
+ const struct usb_known_product *ukp;
#endif
if (dev == NULL) {
@@ -227,8 +240,15 @@ usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p)
return;
}
- vendor = usbd_get_string(dev, udd->iManufacturer, v);
- product = usbd_get_string(dev, udd->iProduct, p);
+ if (usedev) {
+ vendor = usbd_get_string(dev, udd->iManufacturer, v);
+ usbd_trim_trailings_spaces(vendor);
+ product = usbd_get_string(dev, udd->iProduct, p);
+ usbd_trim_trailings_spaces(product);
+ } else {
+ vendor = NULL;
+ product = NULL;
+ }
#ifdef USBVERBOSE
if (vendor == NULL || product == NULL) {
for(ukv = usb_known_vendors;
@@ -276,7 +296,7 @@ usbd_devinfo(usbd_device_handle dev, int showclass, char *cp)
char product[USB_MAX_STRING_LEN];
int bcdDevice, bcdUSB;
- usbd_devinfo_vp(dev, vendor, product);
+ usbd_devinfo_vp(dev, vendor, product, 1);
cp += sprintf(cp, "%s%s%s", vendor, *vendor ? " " : "", product);
if (showclass)
cp += sprintf(cp, ", class %d/%d",
@@ -1157,7 +1177,8 @@ usbd_submatch(struct device *parent, void *match, void *aux)
#endif
void
-usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di)
+usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di,
+ int usedev)
{
struct usbd_port *p;
int i, err, s;
@@ -1165,7 +1186,7 @@ usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di)
di->bus = USBDEVUNIT(dev->bus->bdev);
di->addr = dev->address;
di->cookie = dev->cookie;
- usbd_devinfo_vp(dev, di->vendor, di->product);
+ usbd_devinfo_vp(dev, di->vendor, di->product, usedev);
usbd_printBCD(di->release, UGETW(dev->ddesc.bcdDevice));
di->vendorNo = UGETW(dev->ddesc.idVendor);
di->productNo = UGETW(dev->ddesc.idProduct);
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index 212888b4860..d1392fa8bc8 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.c,v 1.12 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usbdi.c,v 1.13 2001/01/28 09:43:42 aaron Exp $ */
/* $NetBSD: usbdi.c,v 1.77 2000/09/23 21:02:04 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -1012,7 +1012,7 @@ usbd_do_request_async(usbd_device_handle dev, usb_device_request_t *req,
return (USBD_NORMAL_COMPLETION);
}
-struct usbd_quirks *
+const struct usbd_quirks *
usbd_get_quirks(usbd_device_handle dev)
{
return (dev->quirks);
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index 603324a3d64..56767898592 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdi.h,v 1.10 2000/11/08 18:10:39 aaron Exp $ */
+/* $OpenBSD: usbdi.h,v 1.11 2001/01/28 09:43:43 aaron Exp $ */
/* $NetBSD: usbdi.h,v 1.44 2000/09/23 21:02:04 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
@@ -153,7 +153,7 @@ usb_device_descriptor_t *usbd_get_device_descriptor(usbd_device_handle dev);
usbd_status usbd_set_interface(usbd_interface_handle, int);
int usbd_get_no_alts(usb_config_descriptor_t *, int);
usbd_status usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface);
-void usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di);
+void usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di, int);
int usbd_get_interface_altindex(usbd_interface_handle iface);
usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd,
@@ -171,7 +171,7 @@ void usbd_add_dev_event(int, usbd_device_handle);
void usbd_add_drv_event(int, usbd_device_handle, device_ptr_t);
void usbd_devinfo(usbd_device_handle, int, char *);
-struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
+const struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
(usbd_interface_handle iface, u_int8_t address);
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 1c23d14a27c..524ba05ab1c 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdivar.h,v 1.11 2000/11/08 18:10:39 aaron Exp $ */
-/* $NetBSD: usbdivar.h,v 1.56 2000/06/01 14:29:03 augustss Exp $ */
+/* $OpenBSD: usbdivar.h,v 1.12 2001/01/28 09:43:43 aaron Exp $ */
+/* $NetBSD: usbdivar.h,v 1.60 2000/12/28 10:40:36 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -114,6 +114,7 @@ struct usbd_bus {
#define USBREV_PRE_1_0 1
#define USBREV_1_0 2
#define USBREV_1_1 3
+#define USBREV_2_0 4
#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1" }
#if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -139,7 +140,7 @@ struct usbd_device {
struct usbd_interface *ifaces; /* array of all interfaces */
usb_device_descriptor_t ddesc; /* device descriptor */
usb_config_descriptor_t *cdesc; /* full config descr */
- struct usbd_quirks *quirks; /* device quirks, always set */
+ const struct usbd_quirks *quirks; /* device quirks, always set */
struct usbd_hub *hub; /* only if this is a hub */
device_ptr_t *subdevs; /* sub-devices, 0 terminated */
};
@@ -220,7 +221,6 @@ void usbd_finish(void);
/* Routines from usb_subr.c */
int usbctlprint(void *, const char *);
void usb_delay_ms(usbd_bus_handle, u_int);
-void usbd_devinfo_vp(usbd_device_handle, char *, char *);
usbd_status usbd_reset_port(usbd_device_handle dev,
int port, usb_port_status_t *ps);
usbd_status usbd_setup_pipe(usbd_device_handle dev,
diff --git a/sys/dev/usb/uscanner.c b/sys/dev/usb/uscanner.c
index 5d5b9c6f702..fb5de01ddd4 100644
--- a/sys/dev/usb/uscanner.c
+++ b/sys/dev/usb/uscanner.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uscanner.c,v 1.1 2000/11/16 19:40:17 aaron Exp $ */
-/* $NetBSD: uscanner.c,v 1.9 2000/11/14 13:57:16 augustss Exp $ */
+/* $OpenBSD: uscanner.c,v 1.2 2001/01/28 09:43:43 aaron Exp $ */
+/* $NetBSD: uscanner.c,v 1.11 2001/01/07 14:46:32 augustss Exp $ */
/* $FreeBSD$ */
/*
@@ -102,14 +102,18 @@ static const struct scanner_id {
{ USB_VENDOR_HP, USB_PRODUCT_HP_4200C },
{ USB_VENDOR_HP, USB_PRODUCT_HP_S20 },
{ USB_VENDOR_HP, USB_PRODUCT_HP_5200C },
+#if 0
{ USB_VENDOR_HP, USB_PRODUCT_HP_5300C },
+#endif
{ USB_VENDOR_HP, USB_PRODUCT_HP_6200C },
{ USB_VENDOR_HP, USB_PRODUCT_HP_6300C },
/* Avision */
{ USB_VENDOR_AVISION, USB_PRODUCT_AVISION_1200U },
+#if 0
/* Microtek */
+ { USB_VENDOR_SCANLOGIC, USB_PRODUCT_SCANLOGIC_336CX },
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_X6U },
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_336CX },
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_336CX2 },
@@ -117,6 +121,7 @@ static const struct scanner_id {
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_V6USL },
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_V6USL2 },
{ USB_VENDOR_MICROTEK, USB_PRODUCT_MICROTEK_V6UL },
+#endif
/* Mustek */
{ USB_VENDOR_MUSTEK, USB_PRODUCT_MUSTEK_1200CU },
@@ -144,6 +149,7 @@ static const struct scanner_id {
{ USB_VENDOR_EPSON, USB_PRODUCT_EPSON_610 },
{ USB_VENDOR_EPSON, USB_PRODUCT_EPSON_1200 },
{ USB_VENDOR_EPSON, USB_PRODUCT_EPSON_1600 },
+ { USB_VENDOR_EPSON, USB_PRODUCT_EPSON_1640 },
/* UMAX */
{ USB_VENDOR_UMAX, USB_PRODUCT_UMAX_ASTRA1220U },
@@ -632,11 +638,7 @@ USB_DETACH(uscanner)
}
int
-#if defined(__OpenBSD__)
-uscannerselect(dev, events, p)
-#else
uscannerpoll(dev, events, p)
-#endif
dev_t dev;
int events;
struct proc *p;