xCore200 UAC2 Demo record only silence under Linux Topic is solved

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

Hi,
here the action on board and resulting print on console with the debug code added just before my patch force dsdMode to OFF:

Code: Select all

    printstr("dsdMode : ");
    printintln(dsdMode);

    #if(DSD_CHANS_DAC == 0)
        dsdMode = DSD_MODE_OFF;
    #endif

1) Run board with USB detached
dsdMode : 0

2) Attach USB to host
dsdMode : 0
dsdMode : 0
dsdMode : 0
dsdMode : 2

3) Run arecord -D hw:0 -r 48000 ...
dsdMode : 2
(so this without patch will record empty audio)

4) Run spekaker-tests -D hw:0 -r 48000 ...
dsdMode : 0
(AudioHwConfig will be executed also if the sample rate is not changed and correctly init ADC and DAC also without patch)

5) Run arecord -D hw:0 -r 48000 ...
(AudioHwConfig was not executed because sample rate is not changed but ADC is just correctly initialized and audio will becorrectly recorded)

6) Run arecord -D hw:0 -r 96000 ...
dsdMode : 0
(Changing samplerate force execution of AudioHwConfig)

7) Detaching and attaching again USB cable result in retarting exactly from point (2)

Hope this help to understand!

Lorenzo


View Solution
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

That's a helpful report but it displays some some bizarre behaviour. Following the control path from EP0 through to audio, the stream format is set in the descriptors. Each USB interface gets a stream format from the descriptors and will be native DSD if it is initialised to UAC_FORMAT_TYPEI_RAW_DATA. Later on, as this format value is passed through, it reaches decouple.xc where it is translated into a dsd setting and passed to audio.xc, which is where you have been debugging.

Code: Select all

#ifdef NATIVE_DSD
                if(dataFormat == UAC_FORMAT_TYPEI_RAW_DATA)
                {
                    dsdMode = DSD_MODE_NATIVE;
                }
#endif
and

Code: Select all

#define DSD_MODE_OFF          0
#define DSD_MODE_DOP          1
#define DSD_MODE_NATIVE       2
So if you are seeing the value 2, then the only way this can be is if NATIVE_DSD is set at compile time.

This gets set in devicedefines.h:

Code: Select all

/**
 * @brief Number of DSD output channels. Default: 0 (disabled)
 */
#if defined(DSD_CHANS_DAC)
    #if defined(NATIVE_DSD) && (NATIVE_DSD == 0)
        #undef NATIVE_DSD
    #else
        #define NATIVE_DSD       1  /* Always enable Native DSD when DSD mode is enabled */
    #endif
#else
    #define DSD_CHANS_DAC        0
#endif
The only way I could explain the behaviour you are seeing is if DSD_CHANS_DAC is defined, and the linux driver tries to select the DSD interface present in the device and it's descriptors. That would indicate 2 issues - DSD is enabled and Linux incorrectly selects that interface. What may be an issue here is that setting DSD_CHANS_DAC to 0 and NATIVE_DSD is undefined, then NATIVE_DSD will be defined as 1, which will enable it in the ref design...

Does this match your setup?
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

yes, you are right this is exactly wath happen to me:

this is my makefile config, you can see that i define DSD_CHANS_DAC=0, exactly as in other configuration from the reference design:

Code: Select all

XCC_FLAGS_MyConfig  = $(BUILD_FLAGS) -DI2S_CHANS_DAC=4 -DI2S_CHANS_ADC=12 -DNUM_USB_CHAN_OUT=4 -DNUM_USB_CHAN_IN=12 \
								-DMIDI=0 -DSPDIF_TX=0 -DSPDIF_RX=0 -DADAT_TX=0 -DADAT_RX=0 -DDSD_CHANS_DAC=0 \
								-DMAX_FREQ=96000 -DOUTPUT_VOLUME_CONTROL=0 -DINPUT_VOLUME_CONTROL=0 -DMIXER=0 -DHID_CONTROLS=0
INCLUDE_ONLY_IN_MyConfig =
If I simply avoid to define it in configuration all work perfectly without any patch!!

so probably a better fix of the problem can be editing devicedefines.h in this way:

Code: Select all

#if defined(DSD_CHANS_DAC) && (DSD_CHANS_DAC != 0)
    #if defined(NATIVE_DSD) && (NATIVE_DSD == 0)
        #undef NATIVE_DSD
    #else
        #define NATIVE_DSD       1  /* Always enable Native DSD when DSD mode is enabled */
    #endif
#else
    #define DSD_CHANS_DAC        0
#endif
In this way DSD_CHANS_DAC can be undefined or defined as 0 giving the same result!

Lorenzo
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

In this way DSD_CHANS_DAC can be undefined or defined as 0 giving the same result!
Yes, this is a more intuitive behaviour. Thanks very much for raising it - I have submitted an internal bugzilla #17588.

Still unsolved is why the linux USB audio driver tries to select the native DSD interface for playback...
Post Reply