summaryrefslogtreecommitdiff
path: root/sys/dev/usb/ugen.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2004-07-21 00:01:09 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2004-07-21 00:01:09 +0000
commit1939583a95bbe7a8022a6bee1010821fde2ff1bb (patch)
tree7f8ebb392c8e96c623d578a3cd85077af6d5be37 /sys/dev/usb/ugen.c
parenteb833e87668c2e29e560a558673f37ed802ef6d9 (diff)
from freebsd, ugen.c 1.68 usbdi_util.c 1.27 usbdi_util.h 1.15
log message: Implement outgoing interrupt pipes. It is part of the USB 1.1 spec. The Lego Infrared Tower use it. ok deraadt@
Diffstat (limited to 'sys/dev/usb/ugen.c')
-rw-r--r--sys/dev/usb/ugen.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index feee3004c41..b7f955fd601 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ugen.c,v 1.29 2004/07/08 22:18:44 deraadt Exp $ */
+/* $OpenBSD: ugen.c,v 1.30 2004/07/21 00:01:07 dlg Exp $ */
/* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */
/* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -359,6 +359,13 @@ ugenopen(dev_t dev, int flag, int mode, usb_proc_ptr p)
edesc = sce->edesc;
switch (edesc->bmAttributes & UE_XFERTYPE) {
case UE_INTERRUPT:
+ if (dir == OUT) {
+ err = usbd_open_pipe(sce->iface,
+ edesc->bEndpointAddress, 0, &sce->pipeh);
+ if (err)
+ return (EIO);
+ break;
+ }
isize = UGETW(edesc->wMaxPacketSize);
if (isize == 0) /* shouldn't happen */
return (EINVAL);
@@ -715,6 +722,30 @@ ugen_do_write(struct ugen_softc *sc, int endpt, struct uio *uio, int flag)
}
usbd_free_xfer(xfer);
break;
+ case UE_INTERRUPT:
+ xfer = usbd_alloc_xfer(sc->sc_udev);
+ if (xfer == 0)
+ return (EIO);
+ while ((n = min(UGETW(sce->edesc->wMaxPacketSize),
+ uio->uio_resid)) != 0) {
+ error = uiomove(buf, n, uio);
+ if (error)
+ break;
+ DPRINTFN(1, ("ugenwrite: transfer %d bytes\n", n));
+ err = usbd_intr_transfer(xfer, sce->pipeh, 0,
+ sce->timeout, buf, &n, "ugenwi");
+ if (err) {
+ if (err == USBD_INTERRUPTED)
+ error = EINTR;
+ else if (err == USBD_TIMEOUT)
+ error = ETIMEDOUT;
+ else
+ error = EIO;
+ break;
+ }
+ }
+ usbd_free_xfer(xfer);
+ break;
default:
return (ENXIO);
}