Hi,
        Based on what we found in
http://lists.freebsd.org/pipermail/freebsd-current/2008-December/001052.html

I hacked up the following patch to uftdi which allows the recv/xmit buffer size to be tuned at bootup time. This allows our app which is low speed (1200bps), but very timing sensitive to work using a usb serial adaptor based on the uftdi chipset. For us, adding hint.uftdi.0.buffersize="9" to /boot/device.hints does the trick.

Is there a better way to do this ? Are there any other side effects anyone can think of ?



--- sys/dev/usb/uftdi.c.orig    2008-12-09 11:47:02.000000000 -0500
+++ sys/dev/usb/uftdi.c 2008-12-09 11:47:05.000000000 -0500
@@ -198,6 +198,7 @@
        usb_interface_descriptor_t *id;
        usb_endpoint_descriptor_t *ed;
        int i;
+       unsigned int ivar;
        usbd_status err;
        struct ucom_softc *ucom = &sc->sc_ucom;
        DPRINTFN(10,("\nuftdi_attach: sc=%p\n", sc));
@@ -353,11 +354,27 @@
                ucom->sc_portno = FTDI_PIT_SIOA;
        else
                ucom->sc_portno = FTDI_PIT_SIOA + id->bInterfaceNumber;
-       /* bulkin, bulkout set above */

-       ucom->sc_ibufsize = UFTDIIBUFSIZE;
-       ucom->sc_obufsize = UFTDIOBUFSIZE - sc->sc_hdrlen;
-       ucom->sc_ibufsizepad = UFTDIIBUFSIZE;
+ /* For certain low speed / timing sensitive applications having the buffers too large causes + data to be stuck in the queue too long. By adding a tuneable, users can lower the buffer
+          size to what works for their application
+        */
+
+       if (!resource_int_value(
+ "uftdi", device_get_unit(ucom->sc_dev), "buffersize", &ivar) && (ivar > sc->sc_hdrlen && ivar <= UFTDIIBUFSIZE) ) {
+                       ucom->sc_ibufsize = ivar;
+                       ucom->sc_obufsize = ivar - sc->sc_hdrlen;
+                       ucom->sc_ibufsizepad = ivar;;
+ device_printf(ucom->sc_dev, "Setting buffers to %d\n",ivar);
+               }
+               else
+               {
+                       ucom->sc_ibufsize = UFTDIIBUFSIZE;
+                       ucom->sc_obufsize = UFTDIOBUFSIZE - sc->sc_hdrlen;
+                       ucom->sc_ibufsizepad = UFTDIIBUFSIZE;
+ device_printf(ucom->sc_dev, "Setting buffers to default of %d\n",UFTDIIBUFSIZE);
+
+               }
        ucom->sc_opkthdrlen = sc->sc_hdrlen;

        ---Mike



--------------------------------------------------------------------
Mike Tancsa,                                      tel +1 519 651 3400
Sentex Communications,                            [EMAIL PROTECTED]
Providing Internet since 1994                    www.sentex.net
Cambridge, Ontario Canada                         www.sentex.net/mike

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to