tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

dwc2: add endpoint allocation support.

Open HiFiPhile opened this issue 2 years ago • 2 comments

Describe the PR Add endpoint buffer allocation support.

Also flush FIFO on bus reset, as incomplete iso transfers can cause some strange issues, seems flushing FIFO is a work around.

HiFiPhile avatar Nov 21 '23 17:11 HiFiPhile

For dcd_edpt_close_all(), shouldn't it stop pending transfer and flush FIFO, just like dcd_edpt_close() does ? https://github.com/hathach/tinyusb/blob/f1898fef8c605843e1a783bf758949247caae90e/src/portable/synopsys/dwc2/dcd_dwc2.c#L632

HiFiPhile avatar Nov 24 '23 09:11 HiFiPhile

Refactor done, maybe you want to apply the new coding style.

HiFiPhile avatar Jan 15 '24 16:01 HiFiPhile

@kkitayam When you have time could you add ISO endpoint allocation support to UVC class ?

The idea is to avoid USB buffer alloc/free at runtime as it's hard to manage buffer on some devices.

It's pretty simple:

  • Add usbd_edpt_iso_alloc in dirver opening to alloc maximum size needed: https://github.com/hathach/tinyusb/blob/67cd8349d614f7a981117ad85d6707e106cd6145/src/class/audio/audio_device.c#L1544
  • In set interface, instead of usbd_edpt_close and usbd_edpt_open use usbd_edpt_iso_activate https://github.com/hathach/tinyusb/blob/67cd8349d614f7a981117ad85d6707e106cd6145/src/class/audio/audio_device.c#L1742

Currently the main problem is in dwc2 driver, something is wrong with runtime buffer size adjustment, after ISO endpoint closing there is a chance that the device stop transferring packets.

Packets have been acked but no interrupt fired:

image image

dwc2.zip

HiFiPhile avatar Mar 23 '24 16:03 HiFiPhile

@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.

HiFiPhile avatar Mar 25 '24 16:03 HiFiPhile

@hathach Could you take a look of my pending PRs when you have some time ? Especially this one is necessary to make audio class running reliably.

sorry, will review this asap.

hathach avatar Mar 25 '24 17:03 hathach