Device-side USB Audio 2 #318
Replies: 1 comment
-
This is an interesting (but far from easy) project. As you already pointed out, the Circle driver for the DWC OTG USB controller was developed for the host mode only. I'm not sure, if it is really possible and sensible to extend it for device (aka gadget, peripheral) operation. The Circle driver has been implemented after analyzing the Linux driver heavily. The Peripheral Controller Driver (PCD) was ignored in this process. It is implemented in the file dwc_otg_pcd* files in the Linux driver and works on a separated register block of the controller, which are not touched by the Circle host controller driver. The USB controller has its own slave DMA engine, so the I would suggest to put the USB device support into a separate library (e.g. in include/circle/usbdev/ and lib/usbdev/). This would be especially helpful for an easy integration into Circle, in case you want to contribute your source code for Circle. Of course you can copy the source code, which you need from the Circle host controller driver, but you shouldn't modify or subclass it in the lib/usb/ directory, because it is already rather complex and there are also dependencies with the xHCI driver for the RPi 4. So a clean implementation of a Circle driver for the device mode seems to be better to me. |
Beta Was this translation helpful? Give feedback.
-
I'm looking to connect a PCM/I2S ADC with an external clock using an RPI Zero2W to USB using USBAudio2.0 to support 192K 32bit. I've already got circle up and running, cross compiling from x86_64 linux into aarch64 bare metal on the RPI Zero2W. I've done cypress firmware and drivers before for embedded systems years ago, so this seems relatively straight forward (but does require work). I've read through the USB2.0 and USB Audio Class 2.0 specifications and barring vendor specifics it looks possible to add this to circle. On the i2s/PCM I've got the ADC in master mode with a 24.576MHz MCLK then clocking the PCM/i2S nicely according to the scope.
I can see the current circle code is coded heavily as a usb host driver/host controller/root hub implementation however many of the classes could also be used to support a device side implementation.
It looks like it should be possible to use the same DMA channel classes, interrupt handler, transactions, end points etc but sub-class the dwchidevice class to create a USB Bus Interface version that allows incoming requests. This would then appear as a device in the USB bus that can be made to publicise it has a USB Audio 2.0 interface. The RPI can sit in OTG mode, headless and dedicated to bridging using a DMA on the PCM into a ring buffer with a DMA on the USB side.
I will let you know how I get on.
Beta Was this translation helpful? Give feedback.
All reactions