diff options
author | n_hibma <n_hibma@FreeBSD.org> | 1999-11-17 22:33:51 +0000 |
---|---|---|
committer | n_hibma <n_hibma@FreeBSD.org> | 1999-11-17 22:33:51 +0000 |
commit | aeb2d2626b24c89dbb68adb9caebd10bbe02dd43 (patch) | |
tree | 4ffabed555c86f3e004db50f4d745f46d25b77c9 /sys/dev/usb/ums.c | |
parent | a586d3a066b64caa068a9a83440201f39e4d6677 (diff) | |
download | FreeBSD-src-aeb2d2626b24c89dbb68adb9caebd10bbe02dd43.zip FreeBSD-src-aeb2d2626b24c89dbb68adb9caebd10bbe02dd43.tar.gz |
Synchronisation with NetBSD as of 1999/11/16:
Cleaning up the code:
- Declare many functions static
- Change variable names to make them more self explanatory
- Change usbd_request_handle -> usbd_xfer_handle
- Syntactical changes
- Remove some unused code
- Other KNF changes
Interrupt context handling
- Change delay to usbd_delay_ms were possible (takes polling mode into
account)
- Change detection mechanism for interrupt context
Add support for pre-allocation DMA-able memory by device driver
Add preliminary support for isochronous to the UHCI driver (not for OHCI
yet).
usb.c, uhci.c, ohci.c
- Initial attempt at detachable USB host controllers
- Handle the use_polling flag with a lttle more care and only set it if
we are cold booting.
usb.c, uhci.c ohci.c, usbdi.c usbdi_util.c usb_subr.c
- Make sure an aborted pipe is marked as not running.
- Start queued request in the right order.
- Insert some more DIAGNOSTIC sanity checks.
- Remove (almost) unused definitions USBD_XFER_OUT and USBD_XFER_IN.
usb.c, usb_subr.c
- Add an event mechanism so that a userland process can watch devices
come and go.
ohci.c
- Handle the case when a USB transfer is so long that it crosses two
page (4K) boundaries. OHCI cannot do that with a single TD so we make
a chain.
ulpt.c
- Use a bigger buffer when transferring data.
- Pre-allocate the DMA buffer. This makes the driver slightly more
efficient.
- Comment out the GET_DEVICE_ID code, because for some unknown reason it
causes printing to fail sometimes.
usb.h
- Add a macro to extract the isoc type.
- Add a macro to check whether the routine has been entered after splusb
and if not, complain.
usbdi.c
- Fix a glitch in dequeueing and aborting requests on interrupt pipes.
- Add a flag in the request to determine if the data copying is done by
the driver or the usbdi layer.
Diffstat (limited to 'sys/dev/usb/ums.c')
-rw-r--r-- | sys/dev/usb/ums.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 20e6fcf..3a997e0 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -123,7 +123,7 @@ struct ums_softc { #define MOUSE_FLAGS_MASK (HIO_CONST|HIO_RELATIVE) #define MOUSE_FLAGS (HIO_RELATIVE) -static void ums_intr __P((usbd_request_handle reqh, +static void ums_intr __P((usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)); static void ums_add_to_queue __P((struct ums_softc *sc, @@ -166,7 +166,7 @@ USB_MATCH(ums) usb_interface_descriptor_t *id; int size, ret; void *desc; - usbd_status r; + usbd_status err; if (!uaa->iface) return (UMATCH_NONE); @@ -174,8 +174,8 @@ USB_MATCH(ums) if (!id || id->bInterfaceClass != UCLASS_HID) return (UMATCH_NONE); - r = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP); - if (r != USBD_NORMAL_COMPLETION) + err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP); + if (err) return (UMATCH_NONE); if (hid_is_collection(desc, size, @@ -196,7 +196,7 @@ USB_ATTACH(ums) usb_endpoint_descriptor_t *ed; int size; void *desc; - usbd_status r; + usbd_status err; char devinfo[1024]; u_int32_t flags; int i; @@ -232,8 +232,8 @@ USB_ATTACH(ums) USB_ATTACH_ERROR_RETURN; } - r = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP); - if (r != USBD_NORMAL_COMPLETION) + err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_TEMP); + if (err) USB_ATTACH_ERROR_RETURN; if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), @@ -395,8 +395,8 @@ ums_detach(device_t self) } void -ums_intr(reqh, addr, status) - usbd_request_handle reqh; +ums_intr(xfer, addr, status) + usbd_xfer_handle xfer; usbd_private_handle addr; usbd_status status; { @@ -444,6 +444,12 @@ ums_intr(reqh, addr, status) sc->status.dy += dy; sc->status.dz += dz; + /* Discard data in case of full buffer */ + if (sc->qcount == sizeof(sc->qbuf)) { + DPRINTF(("Buffer full, discarded packet")); + return; + } + /* * The Qtronix keyboard has a built in PS/2 port for a mouse. * The firmware once in a while posts a spurious button up @@ -528,7 +534,7 @@ ums_enable(v) { struct ums_softc *sc = v; - usbd_status r; + usbd_status err; if (sc->sc_enabled) return EBUSY; @@ -543,12 +549,12 @@ ums_enable(v) callout_handle_init(&sc->timeout_handle); /* Set up interrupt pipe. */ - r = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr, + err = usbd_open_pipe_intr(sc->sc_iface, sc->sc_ep_addr, USBD_SHORT_XFER_OK, &sc->sc_intrpipe, sc, sc->sc_ibuf, sc->sc_isize, ums_intr); - if (r != USBD_NORMAL_COMPLETION) { + if (err) { DPRINTF(("ums_enable: usbd_open_pipe_intr failed, error=%d\n", - r)); + err)); sc->sc_enabled = 0; return (EIO); } @@ -576,6 +582,8 @@ ums_disable(priv) static int ums_open(dev_t dev, int flag, int fmt, struct proc *p) { + struct ums_softc *sc; + USB_GET_SC_OPEN(ums, UMSUNIT(dev), sc); return ums_enable(sc); @@ -584,6 +592,8 @@ ums_open(dev_t dev, int flag, int fmt, struct proc *p) static int ums_close(dev_t dev, int flag, int fmt, struct proc *p) { + struct ums_softc *sc; + USB_GET_SC(ums, UMSUNIT(dev), sc); if (!sc) @@ -598,12 +608,14 @@ ums_close(dev_t dev, int flag, int fmt, struct proc *p) static int ums_read(dev_t dev, struct uio *uio, int flag) { - USB_GET_SC(ums, UMSUNIT(dev), sc); + struct ums_softc *sc; int s; char buf[sizeof(sc->qbuf)]; int l = 0; int error; + USB_GET_SC(ums, UMSUNIT(dev), sc); + s = splusb(); if (!sc) { splx(s); @@ -666,10 +678,12 @@ ums_read(dev_t dev, struct uio *uio, int flag) static int ums_poll(dev_t dev, int events, struct proc *p) { - USB_GET_SC(ums, UMSUNIT(dev), sc); + struct ums_softc *sc; int revents = 0; int s; + USB_GET_SC(ums, UMSUNIT(dev), sc); + if (!sc) return 0; @@ -690,11 +704,13 @@ ums_poll(dev_t dev, int events, struct proc *p) int ums_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { - USB_GET_SC(ums, UMSUNIT(dev), sc); + struct ums_softc *sc; int error = 0; int s; mousemode_t mode; + USB_GET_SC(ums, UMSUNIT(dev), sc); + if (!sc) return EIO; |