diff options
author | sam <sam@FreeBSD.org> | 2008-12-20 01:29:19 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2008-12-20 01:29:19 +0000 |
commit | c3f1faeb23e27c2ffda030cf892c5df698734622 (patch) | |
tree | 0b964e87f3cbd93269e72d591d2eb44bc6ace51c /sys/dev/usb | |
parent | cd99ae6c06463359389c703ff069f25d28878ad7 (diff) | |
parent | 3fcef6d9c20b6c3577c741e4a0fe24807fd08a66 (diff) | |
download | FreeBSD-src-c3f1faeb23e27c2ffda030cf892c5df698734622.zip FreeBSD-src-c3f1faeb23e27c2ffda030cf892c5df698734622.tar.gz |
MFH @ 186335
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/ucom.c | 42 | ||||
-rw-r--r-- | sys/dev/usb/ucomvar.h | 1 | ||||
-rw-r--r-- | sys/dev/usb/uftdi.c | 51 |
3 files changed, 53 insertions, 41 deletions
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 7496d40..ae263a0 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -700,6 +700,29 @@ ucomstartread(struct ucom_softc *sc) return (USBD_NORMAL_COMPLETION); } +void +ucomrxchars(struct ucom_softc *sc, u_char *cp, u_int32_t cc) +{ + struct tty *tp = sc->sc_tty; + + /* Give characters to tty layer. */ + if (ttydisc_can_bypass(tp)) { + DPRINTFN(7, ("ucomreadcb: buf = %*D\n", cc, cp, "")); + cc -= ttydisc_rint_bypass(tp, cp, cc); + } else { + while (cc > 0) { + DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp)); + if (ttydisc_rint(tp, *cp, 0) == -1) + break; + cc--; + cp++; + } + } + if (cc > 0) + device_printf(sc->sc_dev, "lost %d chars\n", cc); + ttydisc_rint_done(tp); +} + static void ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) { @@ -709,6 +732,7 @@ ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) u_int32_t cc; u_char *cp; + (void)tp; /* Used for debugging */ DPRINTF(("ucomreadcb: status = %d\n", status)); if (status != USBD_NORMAL_COMPLETION) { @@ -737,22 +761,8 @@ ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status) device_get_nameunit(sc->sc_dev), cc); goto resubmit; } - if (cc < 1) - goto resubmit; - - /* Give characters to tty layer. */ - while (cc > 0) { - DPRINTFN(7, ("ucomreadcb: char = 0x%02x\n", *cp)); - if (ttydisc_rint(tp, *cp, 0) == -1) { - /* XXX what should we do? */ - printf("%s: lost %d chars\n", - device_get_nameunit(sc->sc_dev), cc); - break; - } - cc--; - cp++; - } - ttydisc_rint_done(tp); + if (cc > 0) + ucomrxchars(sc, cp, cc); resubmit: err = ucomstartread(sc); diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h index 0fcd7f3..4433a1a 100644 --- a/sys/dev/usb/ucomvar.h +++ b/sys/dev/usb/ucomvar.h @@ -166,3 +166,4 @@ void ucom_attach_tty(struct ucom_softc *, char*, int); int ucom_attach(struct ucom_softc *); int ucom_detach(struct ucom_softc *); void ucom_status_change(struct ucom_softc *); +void ucomrxchars(struct ucom_softc *sc, u_char *cp, u_int32_t cc); diff --git a/sys/dev/usb/uftdi.c b/sys/dev/usb/uftdi.c index 5a9921b..c32bfa6 100644 --- a/sys/dev/usb/uftdi.c +++ b/sys/dev/usb/uftdi.c @@ -100,7 +100,7 @@ SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, debug, CTLFLAG_RW, * These are the maximum number of bytes transferred per frame. * The output buffer size cannot be increased due to the size encoding. */ -#define UFTDIIBUFSIZE 64 +#define UFTDIIBUFSIZE 256 #define UFTDIOBUFSIZE 64 struct uftdi_softc { @@ -458,32 +458,33 @@ uftdi_read(void *vsc, int portno, u_char **ptr, u_int32_t *count) { struct uftdi_softc *sc = vsc; u_char msr, lsr; + unsigned l; + + DPRINTFN(15,("uftdi_read: sc=%p, port=%d count=%d\n", + sc, portno, *count)); + while (*count > 0) { + l = *count; + if (l > 64) + l = 64; + + msr = FTDI_GET_MSR(*ptr); + lsr = FTDI_GET_LSR(*ptr); + + if (sc->sc_msr != msr || + (sc->sc_lsr & FTDI_LSR_MASK) != (lsr & FTDI_LSR_MASK)) { + DPRINTF(("uftdi_read: status change msr=0x%02x(0x%02x) " + "lsr=0x%02x(0x%02x)\n", msr, sc->sc_msr, + lsr, sc->sc_lsr)); + sc->sc_msr = msr; + sc->sc_lsr = lsr; + ucom_status_change(&sc->sc_ucom); + } - DPRINTFN(15,("uftdi_read: sc=%p, port=%d count=%d\n", sc, portno, - *count)); - - msr = FTDI_GET_MSR(*ptr); - lsr = FTDI_GET_LSR(*ptr); - -#ifdef USB_DEBUG - if (*count != 2) - DPRINTFN(10,("uftdi_read: sc=%p, port=%d count=%d data[0]=" - "0x%02x\n", sc, portno, *count, (*ptr)[2])); -#endif - - if (sc->sc_msr != msr || - (sc->sc_lsr & FTDI_LSR_MASK) != (lsr & FTDI_LSR_MASK)) { - DPRINTF(("uftdi_read: status change msr=0x%02x(0x%02x) " - "lsr=0x%02x(0x%02x)\n", msr, sc->sc_msr, - lsr, sc->sc_lsr)); - sc->sc_msr = msr; - sc->sc_lsr = lsr; - ucom_status_change(&sc->sc_ucom); + if (l > 2) + ucomrxchars(&sc->sc_ucom, (*ptr) + 2, l - 2); + *ptr += l; + *count -= l; } - - /* Pick up status and adjust data part. */ - *ptr += 2; - *count -= 2; } static size_t |