Forráskód Böngészése

f7: Do not wait for write buffer to completely fill at Full Speed.
Now the buffer is 128kB, it takes ~150ms to fill it at FS.

Keir Fraser 5 éve
szülő
commit
12028bdffe
6 módosított fájl, 12 hozzáadás és 5 törlés
  1. 3 0
      inc/usb.h
  2. 6 1
      src/floppy.c
  3. 1 1
      src/usb/core.c
  4. 0 1
      src/usb/defs.h
  5. 1 1
      src/usb/hw_dwc_otg.c
  6. 1 1
      src/usb/hw_f1.c

+ 3 - 0
inc/usb.h

@@ -44,6 +44,9 @@ bool_t ep_tx_ready(uint8_t ep);
  * REQUIRES: ep_tx_ready(@ep) == TRUE */
 void usb_write(uint8_t ep, const void *buf, uint32_t len);
 
+/* Is the USB enumerated at High Speed? */
+bool_t usb_is_highspeed(void);
+
 /*
  * Local variables:
  * mode: C

+ 6 - 1
src/floppy.c

@@ -615,10 +615,15 @@ static uint8_t floppy_write_prep(const struct gw_write_flux *wf)
 static void floppy_write_wait_data(void)
 {
     bool_t write_finished;
+    unsigned int u_buf_threshold;
 
     floppy_process_write_packet();
     wdata_decode_flux();
 
+    /* We don't wait for the massive F7 u_buf[] to fill at Full Speed. */
+    u_buf_threshold = ((U_BUF_SZ > 16384) && !usb_is_highspeed())
+        ? 16384 - 512 : U_BUF_SZ - 512;
+
     /* Wait for DMA and input buffers to fill, or write stream to end. We must
      * take care because, since we are not yet draining the DMA buffer, the
      * write stream may end without us noticing and setting rw.write_finished. 
@@ -627,7 +632,7 @@ static void floppy_write_wait_data(void)
                       ? rw.write_finished
                       : (u_buf[U_MASK(u_prod-1)] == 0));
     if (((dma.prod != (ARRAY_SIZE(dma.buf)-1)) 
-         || ((uint32_t)(u_prod - u_cons) < (U_BUF_SZ - 512)))
+         || ((uint32_t)(u_prod - u_cons) < u_buf_threshold))
         && !write_finished)
         return;
 

+ 1 - 1
src/usb/core.c

@@ -49,7 +49,7 @@ static bool_t handle_control_request(void)
                 memcpy(ep0.data, device_qualifier, ep0.data_len);
             }
         } else if ((type == DESC_CONFIGURATION) && (idx == 0)) {
-            if (hw_is_highspeed()) {
+            if (usb_is_highspeed()) {
                 ep0.data_len = config_hs_descriptor[2]; /* wTotalLength */
                 memcpy(ep0.data, config_hs_descriptor, ep0.data_len);
             } else {

+ 0 - 1
src/usb/defs.h

@@ -83,7 +83,6 @@ void usb_setaddr(uint8_t addr);
 void hw_usb_init(void);
 void hw_usb_deinit(void);
 bool_t hw_has_highspeed(void);
-bool_t hw_is_highspeed(void);
 
 #define WARN printk
 

+ 1 - 1
src/usb/hw_dwc_otg.c

@@ -31,7 +31,7 @@ bool_t hw_has_highspeed(void)
     return conf_iface == IFACE_HS_EMBEDDED;
 }
 
-bool_t hw_is_highspeed(void)
+bool_t usb_is_highspeed(void)
 {
     return is_hs;
 }

+ 1 - 1
src/usb/hw_f1.c

@@ -27,7 +27,7 @@ bool_t hw_has_highspeed(void)
     return FALSE;
 }
 
-bool_t hw_is_highspeed(void)
+bool_t usb_is_highspeed(void)
 {
     return FALSE;
 }