Page 1 of 1

Audio 2.0: how to do >1 transfer per microframe?

Posted: Tue Jan 03, 2017 8:20 pm
by redfart
Hi, I'm running xCore-200 MC AUDIO 2V0 kit, and the Thesycon driver 3.34 eval version. I'm basing my project around the app_usb_aud_xk_216_mc project.

USB 2.0 High Speed (USB AUDIO 2.0) permits a transfer of 1024 bytes max every microframe (125 uSec). Since USB 2.0 can handle 480Mb/sec, I should be able to double or triple the data rate. I see references to "multi-packet mode" in some white papers. My attempts to simply increase audio data over the limit (by upping channel counts and sample rates) isn't working. ASIO-compliant DAW programs (like Reaper) shout that they don't see an ASIO device connected if I'm running code at too high a data rate.

Thesycon tech support claims their driver already supports data rates above 1024Bytes/microframe

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Wed Jan 04, 2017 10:53 pm
by larry
As far as I know the Thesycon driver supports high bandwidth/multi packet endpoints, but this hasn't been extensively tested with XMOS devices

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Wed Jan 04, 2017 11:33 pm
by redfart
Thanks, Larry. Any suggestions how I would go about implementing it? Merely upping my channel count and sample rate doesn't work. I presume the code handling each microframe would need to be modified. Not sure where the 1024-byte-per-uframe limit is written in.

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Wed Jan 04, 2017 11:56 pm
by redfart
Wait, I may have found it. The descriptors.h file limits the maxpacketsize here:

#define HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE (MAX_PACKET_SIZE_MULT_INPUT_1_HS * HS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES)
#define HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE (MAX_PACKET_SIZE_MULT_INPUT_1_HS * HS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES)
#define HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE (MAX_PACKET_SIZE_MULT_INPUT_1_HS * HS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES)

#if (HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE > 1024)
#warning HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE > 1024
#undef HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE
#define HS_STREAM_FORMAT_INPUT_1_MAXPACKETSIZE 1024
#endif

#if (HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE > 1024)
#warning HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE > 1024
#undef HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE
#define HS_STREAM_FORMAT_INPUT_2_MAXPACKETSIZE 1024
#endif

#if (HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE > 1024)
#warning HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE > 1024
#undef HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE
#define HS_STREAM_FORMAT_INPUT_3_MAXPACKETSIZE 1024
#endif

Removing the limit and rebuilding, I can at least run my 3rd-party apps and have them see the device, though they complain that I have made a "sample rate or device change request" when they connect. I'll have to get some HW together and confirm they are running audio.

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Thu Jan 05, 2017 12:42 am
by larry
Main problem is that the low level USB code doesn't support multiple packets. So even if you up limits, correct descriptors and make all high level code work, the USB core won't expect a different DATA PID of the second and third packet and probably just drop them.

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Thu Jan 05, 2017 1:20 am
by redfart
Is that low-level code visible in the sample project?

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Thu Jan 05, 2017 1:37 am
by larry
Unfortunately, this is the XUD module, where most core functions are in a binary library (libxud_x200.a)

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Thu Jan 05, 2017 1:46 am
by redfart
Is the lib_usb library not helpful? Or, the xud.h file?

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Thu Jan 05, 2017 1:46 am
by larry
Is the lib_usb library not helpful? Or, the xud.h file?
My apologies, I didn't realise this has been made available. I also found a related thread:

http://www.xcore.com/forum/viewtopic.php?f=37&t=4512

If you look in Pid_Out where OUT transactions are handled, after the OUT token it goes straight into doRXData where it consumes exactly one data packet. Then we go back to main loop, expecting a new transaction. This logic needs to change so multiple packets work.

Similarly for IN, where we need to be able to send multiple packets after an IN token.

Re: Audio 2.0: how to do >1 transfer per microframe?

Posted: Fri Jan 06, 2017 2:26 am
by redfart
>> "Pid_Out where OUT transactions are handled, after the OUT token it goes straight into doRXData..."

Is that found in XUD_Token_Out.S in the library?
Is the asm instruction set printed anywhere? (It's not in the chip datasheet.) I'm having trouble understanding this code.
That said, am I able to modify a library, or would XMOS need to supply a new one to me?

Thanks, I am VERY new at this! I was hoping to get by simply modifying the makefile build configurations, but now I realize I'm in the deep end.