USB Audio framework spdif to i2s issue

If you have a simple question and just want an answer.
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

USB Audio framework spdif to i2s issue

Post by __BriKs__ »

Hello,

I'm working on a custom HW with a XUF208 256 TQ64 chipset.
I work with the usb audio software framework.
The device is an audio power stereo amplifier with USB and SPDIF IN and a DAC.
The USB streaming works and now I work on the SPDIF IN part.

I don't know how to use usb audio framework to get the spdif working.
My custom HW is designed on xCORE-200 multichannel audio platform with a clock generator CS2100 and PLL PL611 (just like audio plateform hardware).
I use a scope to probe SPDIF signal which looks good, I probe also the signal PLL_SYNC (like in audio plateform hardware) which looks good (300Hz).
I proble DAC signals all looks good (master clock, DAC_BCLK, DAC_LRCLK) except DAC_DATA which is always low level despite there is data on SPDIF line.

My dac and clock sheme works because when using USB the device works correctly.

I suspect a bad configuration in my project files (makefile and customdefine.h).

How can I get SPDIF IN working (only SPDIF, USB disable) ?
Here my project files.

I didn't really well understand how to configure spdif IN ;
Do I need the mixer core ?
How to set this line ? :
/* Channel index of SPDIF Rx channels */
#define SPDIF_RX_INDEX (0)
Do I need NUM_USB_CHAN_IN to specific value ?

My objective is just to stream from spdif to I2s instead of USB to i2s.

Many thanks for help :)

Best Regards,

Florian
You do not have the required permissions to view the files attached to this post.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Hello mon2 hope your are doing well.

This is my plan B in case I can't get initial hw design working which is designed upon Xmos audio plateforme and using a dedicaced chip to regen audio clock from spdif with low jitter.
The AN00231 purpose is to do clock regeneration with cpu without using Xmos audio plateform design.

I think it is just a file configuration error to get working audio usb framework streaming spdif. Then I will focus first on trying to get usb framework working.

Attached my whole project (called BriXamp) and schematic.
You do not have the required permissions to view the files attached to this post.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

See if section 3.8 helps:

Code: Select all

https://www.xmos.com/download/sw_usb_audio:-sw_usb_audio-[design-guide](6.16.1alpha1).pdf
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Yes I understand I don't need mixer to play sound from SPDIF.

Then I use in makefile the following parameters:
-DI2S_CHAN_DAC=2 -DI2S_CHAN_ADC=0 -DNUM_USB_CHAN_OUT=0 -DNUM_USB_CHAN_IN=0 -DSPDIF_RX=1 -DMIDI=0 -DDSD_CHAN_DAC=0 -DMAX_FREQ=192000
And I get a build error:
C:/Users/Florian Briquel/Desktop/BriXampspdif/module_usb_audio/audio.xc:682:73: error: index of array exceeds its upper bound
asm("ldw %0, dp[g_digData]":"=r"(samplesIn_0[SPDIF_RX_INDEX + 0]));
~~~~~~~~~~~~~~~~^~~~
C:/Users/Florian Briquel/Desktop/BriXampspdif/module_usb_audio/audio.xc:683:75: error: index of array exceeds its upper bound
asm("ldw %0, dp[g_digData+4]":"=r"(samplesIn_0[SPDIF_RX_INDEX + 1]));

I don't understand how to set following line in customdefine.h:
/* Channel index of SPDIF Rx channels */
#define SPDIF_RX_INDEX (???)

I made mistake thinking that spdif rx index set to 0 will put spdif data into audio driver instead of usb data but I realize I don't understand the relationship between spdif_rx_index and samplesIn.
Can anybody help to understand how to play spdif with xmos usb multiplateforme framework ?
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Fun facts, project build when I set -DNUM_USB_CHAN_IN to 2 (-DNUM_USB_CHAN_IN=2) and then hw relative to clock seems working:
the cs2100 ic is feeded by a 300hz signal from xmos and xmos set the right pin to select masterclock from cs2100 instead of pl611. In other word the hw designed from xmos audio multichanel plateforme works just as expected. The dac is feeded with bclk, lrclk and masterclock but still nothing on data line. There is data on spdif line which is connected to xmos pin 42 xod35 (single bit port P1L0 juts like defined in my xn file).

I think my hw is good this is the firmware which is not well configured.

I suspect I'm not far away to get it working but it seems no sense to get the project build with the line -DNUM_USB_CHAN_IN=2 because I don't want to push data from xmos to host I just want to push data from spdif to i2s :)
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Hello,

Finally I'm using the AN00231 SPDIF TO I2S ASRC project to see if my hw is working regards to spdif IN.
I'm in trouble with this project; It almost works but hang.
I modify the project to remove all relative to I2C (my PCM1792 dac don't need any config to work), button and led.
My HW is based upon multichannel audio plateforme (specially in regards of DAC reset and MCLK selection pin).
I get the following output from console when runing the project with toslink connected and my pc streaming music on it:
Starting I2S
SR change in lib_audio_codec - 48000
Initializing I2S to 48000Hz and MCLK to 24576000Hz
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1

a lots of 'New rate in SRC in=3, out=1' lines and:
spdif rate ave=0, valid=0, i2s rate=0, valid=0, i2s_buff=-15, fs_ratio=0x1FFEAC0B, nom_fs=0x20000000
and finally:
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=3, out=1
New rate in SRC in=57005, out=1
ASRC_proc Error code 11
After the line ASRC proc Error the I2S lines come inactive (high level state).

I scope I2S signal, I see looking good signals interrrupted by blank level (high level) on I2S data, bclk and wclk.
I think something is not very well initialized reseting the process all the time (all the 'New rate in SRC in=3, out=1' line)
I share my project, anybody can help me debug ?

Regards,

Florian
You do not have the required permissions to view the files attached to this post.
User avatar
Yanava
Member
Posts: 8
Joined: Mon Sep 10, 2018 4:23 pm

Post by Yanava »

Did you manage to get this working? It is very unclear on the XMOS documentation how to get SPDIF and USB Audio working on the same part.
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Sorry but no :/ I try to make working other framework than USB audio to get working spdif (last try with no success with spdif asrc project exemple).
Relative to USB audio framework I don't understand how to map the signals from spdif in the framework, and then when I try severals config I never see spdif working :/

If you have some success on make working spdif on USB audio framework I'm very interested in.

regards,

Florian
__BriKs__
Active Member
Posts: 48
Joined: Tue Nov 27, 2018 9:45 pm

Post by __BriKs__ »

Hello,
Still working on spdif to usb with Xmos usb audio framework on a custom HW.

I start to doubt there is a way to make spdif input working with this framework and the XUF208 chip :/

My custom hw is based upon harware usb audio plateform, using a dediced CS2100 ic for the spdif part.
My custom hw works great with USB, so my dac and Xmos ic work, but for spdif I can get it working.
I'm on a stereo config with a stereo dac, when I use framework with spdif config :
XCC_FLAGS = $(BUILD_FLAGS) -DSPDIF_RX=1 line on makefile
and my custom file look like that:
/* Default to board version version 2.0 */
#ifndef XCORE_200_MC_AUDIO_HW_VERSION
#define XCORE_200_MC_AUDIO_HW_VERSION 2
#endif

/* Tile defines */
#define AUDIO_IO_TILE 0
#define XUD_TILE 0

/* SPDIF Tx i/o moved tile between board versions 1.0 -> 2.0 */
#if XCORE_200_MC_AUDIO_HW_VERSION < 2
#define SPDIF_TX_TILE 0
#endif

#define MIDI_TILE 0

/* Mixer core enabled by default */
#ifndef MIXER
#define MIXER 0
#endif

/* Mixing disabled by default */
#ifndef MAX_MIX_COUNT
#define MAX_MIX_COUNT 0
#endif

/* Board is self-powered i.e. not USB bus-powered */
#define SELF_POWERED 1

/* Enable/Disable MIDI - Default is MIDI off */
#ifndef MIDI
#define MIDI 0
#endif

/* Enable/Disable SPDIF output - Default is S/PDIF on */
#ifndef SPDIF_TX
#define SPDIF_TX 0
#endif

/* Defines relating to channel count and channel arrangement (Set to 0 for disable) */
//:audio_defs
/* Number of USB streaming channels - Default is 4 in 4 out */
#ifndef NUM_USB_CHAN_IN
#define NUM_USB_CHAN_IN (2) /* Device to Host */
#endif
#ifndef NUM_USB_CHAN_OUT
#define NUM_USB_CHAN_OUT (0) /* Host to Device */
#endif

/* Number of IS2 chans to DAC..*/
#ifndef I2S_CHANS_DAC
#define I2S_CHANS_DAC (2)
#endif

/* Number of I2S chans from ADC */
#ifndef I2S_CHANS_ADC
#define I2S_CHANS_ADC (0)
#endif

/* Channel index of SPDIF Rx channels (duplicated DAC channels 1/2 when index is 0) */
#define SPDIF_TX_INDEX (0)

/* Channel index of SPDIF Rx channels */
#define SPDIF_RX_INDEX (0)

/* Channel index of ADAT Tx channels */
#if defined(SPDIF_TX) && (SPDIF_TX==1)
#define ADAT_TX_INDEX (SPDIF_TX_INDEX + 2)
#else
#define ADAT_TX_INDEX (I2S_CHANS_DAC)
#endif

/* Channel index of ADAT Rx channels */
#if defined(SPDIF_RX) && (SPDIF_RX==1)
#define ADAT_RX_INDEX (SPDIF_RX_INDEX + 2)
#else
#define ADAT_RX_INDEX (I2S_CHANS_ADC)
#endif

/* Master clock defines (in Hz) */
#define MCLK_441 (512*44100) /* 44.1, 88.2 etc */
#define MCLK_48 (512*48000) /* 48, 96 etc */

The CS2100 give a clock, the dac signals bclk, lrclk and masterclock are good but the data signal is always low despite a right spdif signal on the Xmos pin I choose (pin XOD35 and following line in my xn file: <Port Location="XS1_PORT_1L" Name="PORT_SPDIF_IN"/>).

Note: i must disable mixer in customdefines (look my customdefine just above) because my XUF208 is a 8 cores only and if I enable mixer this require 9 cores which is not possible. So maybe without mixer spdif just don't work and then it's not possible to use usb audio framework for spdif to i2s with XUF208?

Please someone help :)