Using ASRC (Asynchronous Sample Rate Converter)
Introduction
This page explains the usage of ASRC, available in SAMA7G5 SoCs.
The Asynchronous Sample Rate Converter converts the sample rate of an incoming audio frame without
affecting quality. It supports input and output sampling rates up to 192 kHz.
It is made of 4 independent digital signal processing modules (DSP). Each DSP can be configured with specific input
and output sampling frequencies and is associated to one of the DMA channels.
Characteristics:
- Up to 192 kHz Stereo Asynchronous Sample Rate Converter
- 8/10/12/14/16/18/20/24/32-bit Data Input/Output
- 24-bit Digital Signal Processing
- 115 dB Total Harmonic Distorsion+Noise
- Up to 4 Independent Stereo Channels (one for each DSP)
- Up to 8 DMA Channels
- Time-Division Multiplexing (TDM) Audio Streams Support
The ASRC receives triggers from all the other audio peripherals, such as I2SMCC, SSC, PDMC and SPDIF RX/TX. The triggers are unique (one for each audio peripheral) and represents the sampling rate at which its corresponding audio IP runs.
Linux ASRC driver considerations
Linux ASRC driver is registered as a Front-End (FE), using DPCM, while the rest of the audio peripherals available in the
SoC will be registered as Back-Ends (BE). This allows the interaction of ASRC with all the audio peripherals. More details regarding DPCM ca be found
here.
First of all, we have to make sure the ASRC driver is probed correctly. For this, at boot, look for this message:
mchp_asrc e1610000.asrc: hw version: 0x240
You should see the above message (or something similar) if the ASRC driver probe succeeds.
The next important step is the probing of the sound card Linux driver, needed to glue to ASRC and the rest of the audio peripherals. At boot, look for something like:
mchp-asrc-card sound: ASRC 4 FEs
mchp-asrc-card sound: Found DPCM FE: asrc-pcm-1
mchp-asrc-card sound: Found DPCM FE: asrc-pcm-2
mchp-asrc-card sound: Found DPCM FE: asrc-pcm-3
mchp-asrc-card sound: Found DPCM FE: asrc-pcm-4
This suggests that 4 FEs will be used for ASRC. We can also see the names of the FE audio devices. The sound card driver logs should continue with:
mchp-asrc-card sound: Found DPCM BE: BE mchp-pdmc - dmic-hifi, id 4
mchp-asrc-card sound: Found DPCM BE: BE mchp-spdiftx - dit-hifi, id 6
mchp-asrc-card sound: Found DPCM BE: BE mchp-spdifrx - dir-hifi, id 8
These are the interfaces registered as BEs, which can be used with ASRC. In our case, we can see the PDMC, SPDIFTX and SPDIFRX interfaces, all registered with generic codecs.
Details regarding how to use a different number of ASRC FE instances or how to add/remove BE interfaces are described in the sound card device-tree bindings:
microchip,asrc-card.yaml.
The ASRC registers 4 * 2 PCM devices. 4, because there are 4 DSPs, which are not identical in terms of usage, but, with some restrictions, they can run independently at the same time. Is multiplied by 2 because the DSPs can be used for both capture and playback.
root@sama7g5ek-sd:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 0: asrc-pcm-1 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 1: asrc-pcm-2 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 2: asrc-pcm-3 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 3: asrc-pcm-4 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
...
root@sama7g5ek-sd:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 0: asrc-pcm-1 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 1: asrc-pcm-2 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 2: asrc-pcm-3 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 3: asrc-pcm-4 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
...
The rest of the non-ASRC peripherals are registered twice. Once as normal PCM, to be used without ASRC, and as Back-End, to be used with ASRC. The normal PCM devices can be seen using
aplay/arecord commands:
root@sama7g5ek-sd:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
...
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 4: e161c000.i2s - wm8731-hifi wm8731-hifi-4 [e161c000.i2s - wm8731-hifi wm8731-hifi-4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 8: mchp-spdiftx - dit-hifi dit-hifi-8 [mchp-spdiftx - dit-hifi dit-hifi-8]
Subdevices: 1/1
Subdevice #0: subdevice #0
root@sama7g5ek-sd:~# arecord -l
**** List of CAPTURE Hardware Devices ****
...
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 4: e161c000.i2s - wm8731-hifi wm8731-hifi-4 [e161c000.i2s - wm8731-hifi wm8731-hifi-4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 6: mchp-pdmc - dmic-hifi dmic-hifi-6 [mchp-pdmc - dmic-hifi dmic-hifi-6]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 10: mchp-spdifrx - dir-hifi dir-hifi-10 [mchp-spdifrx - dir-hifi dir-hifi-10]
Subdevices: 1/1
Subdevice #0: subdevice #0
Here we can see the I2SMCC is registered with the wm8731 codec, SPDIF RX/TX and PDMC. These are the normal PCM devices, since the Back-End instances are not exported to Linux user-space. This is because of the current ASoC implementation, which only allows the presence of the Front-End. The PCM parameters for the BEs (sampling rate, frame format, number of channels) are fixed, set at boot via device-tree. For example, the parameters for I2SMCC with the Mikroe Audio PROTO Board can be described with a device-tree overlay:
microchip,dai-link@3 {
reg = <3>;
microchip,format = "i2s";
microchip,frame-master = <&dailink3_master>;
microchip,bitclock-master = <&dailink3_master>;
microchip,convert-channels = <2>;
microchip,convert-rate = <48000>;
microchip,convert-sample-format = <MCHP_ASRC_PCM_FORMAT_S24_LE>;
dailink3_master: cpu { /* make sure label is unique */
sound-dai = <&i2s0>;
};
codec {
sound-dai = <&wm8731>;
};
};
Here, when I2SMCC with WM8731 is used as a BE with ASRC, the interface will run 2 audio channels, at 48KHz, using an S24_LE format. These parameters must be supported
by both the controller and the codec. As previously mentioned, these parameters are used only when the interface is used as a BE with ASRC. When used standalone, these device-tree properties are ignored, since they are taken fro the Linu user-space audio applications. The complete overlay can be found
here. Also, the sound card device-tree node in the SAMA7G5 EK DTS file can be found
here, while the sound card driver bindings are described
here.
We explained the registration of DPCM devices, the FEs, which are the 4 ASRC DSPs, and the BEs, which are the audio peripherals that interact with ASRC. The connection between the FEs and the BEs is done using audio routing. Each BE instance is routed to each FE instance using audio sound card controls. The controls can be seen using
amixer controls or
alsamixer commands. The syntax for these controls is:
'< interface name >< interface_id > RX/TX'. For example, for I2SMCC0, we have both
'I2SMCC0 RX' and
'I2SMCC0 TX', since the I2SMCC and WM8731 support both capture and playback. For PDMC0, we have
'PDMC0 RX', since PDMC can only do capture.
These controls can take one of the values with the syntax:
'ASRC Playback/Capture PCM < FE_instance_id > BE < order_id >'.
FE_instance_id refers to the ASRC FE instance
asrc_pcm_< instance > and
order_id represents the order of BE's, when there are multiple BEs enabled for the same ASRC FE instance. The order of the BEs is important because it maps the TDM audio channels to the BE
itself. The first channels will be mapped to the BE with the
order_id 1 (the number of channels for this BE will be taken from device-tree, as explained above), the next channels will be mapped to the BE with the
order_id 2, and so on. Since we have 4 DSPs there can't be more than 4 BEs used at the same time, for one direction (playback or capture), the total number of values a control can take is 4 x 4:
root@sama7g5ek-sd:~# amixer sget 'I2SMCC0 TX'
Simple mixer control 'I2SMCC0 TX',0
Capabilities: enum
Items:
'Off'
'ASRC Playback PCM 1 BE 1'
'ASRC Playback PCM 1 BE 2'
'ASRC Playback PCM 1 BE 3'
'ASRC Playback PCM 1 BE 4'
'ASRC Playback PCM 2 BE 1'
'ASRC Playback PCM 2 BE 2'
'ASRC Playback PCM 2 BE 3'
'ASRC Playback PCM 2 BE 4'
'ASRC Playback PCM 3 BE 1'
'ASRC Playback PCM 3 BE 2'
'ASRC Playback PCM 3 BE 3'
'ASRC Playback PCM 3 BE 4'
'ASRC Playback PCM 4 BE 1'
'ASRC Playback PCM 4 BE 2'
'ASRC Playback PCM 4 BE 3'
'ASRC Playback PCM 4 BE 4'
Item0: 'Off'
In the above example, we can see all the values available for the
'I2SMCC0 TX' control.
ASRC types of usage
There are 2 types of usages of ASRC. We have the
normal use-cases, where there are a number of BEs attached to an ASRC FE interface and
aplay or
arecord (or other Linux user-space audio applications) can be used to send/receive data to/from ASRC, which sends/receives data to/from BEs, The other type of use-cases we have are called
cross use-cases. In these scenarios, the audio stream is taken from a set of BEs, passed through ASRC and then sent directly to another set of BEs. This is accomplished with minimal CPU usage, and no Linux user-space application is involved.
As mentioned above, these scenarios are used with
aplay and
arecord type of applications, to play or record an audio file. We will illustrate an example in which we will send a playback TDM stream of 4 channels to I2SMCC0 (with WM8731) and SPDIFTX. The first thing to do is to set the
'I2SMCC0 TX' and
'SPDIFTX0 TX' controls to the FE instance we want to use and in the order that we prefer. We will choose the first FE instance and I2SMCC0 as the first BE and SPDIFTX0 as the second BE, by setting the
'I2SMCC0 TX' control to
'ASRC Playback PCM 1 BE 1' and
'SPDIFTX0 TX' control to
'ASRC Playback PCM 1 BE 2':
root@sama7g5ek-sd:~# amixer sset 'I2SMCC0 TX' 'ASRC Playback PCM 1 BE 1'
Simple mixer control 'I2SMCC0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'ASRC Playback PCM 1 BE 1'
root@sama7g5ek-sd:~# amixer sset 'SPDIFTX0 TX' 'ASRC Playback PCM 1 BE 2'
Simple mixer control 'SPDIFTX0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'ASRC Playback PCM 1 BE 2'
The same configuration can be accomplished using
alsamixer command.
Now we can send a 4 channel audio stream to the first ASRC FE instance, which will have the first two channels split to I2SMCC0 and SPDIFTX0. We use
speaker test Linux application for simplicity:
root@sama7g5ek-sd:~# speaker-test -Dhw:0,0 -c 4 -t wave
As you can see, we are sending the audio data to
hw:0,0, which is card id
0 and device id
0. These values are taken from the output of
aplay -l:
root@sama7g5ek-sd:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: EK [mchp-asrc-card @ sama7g5 EK], device 0: asrc-pcm-1 (*) []
...
As shown above, we have
card 0 and
device 0 for
asrc-pcm-1, hence the device name will be
-Dhw:0,0. Make sure the correct
card and
device values are used for your use-case.
At this point, on the default serial (or
dmesg) you should see a message like:
mchp_asrc e1610000.sound: ASRC IN AIF(s):
mchp_asrc e1610000.sound: front-end
mchp_asrc e1610000.sound: ASRC OUT AIF(s):
mchp_asrc e1610000.sound: i2s@e161c000, 2 channels
mchp_asrc e1610000.sound: spdiftx@e1618000, 2 channels
This means that the DPLLs of the assigned ASRC DSPs locked and that an audio stream is taken from the user (
front-end) and first 2 channels sent to
i2s@e161c000, which is I2SMCC0, and the next 2 sent to
spdiftx@e1618000.
If the sound is not heard on the Mikroe AUDIO Proto board, please troubleshoout it by using it without ASRC, by following the steps
here
For capture, we need something simmilar, but we will use the
'RX' controls instead. For this, first, we set the
'Tx' controlls back to
'Off':
root@sama7g5ek-sd:~# amixer sset 'I2SMCC0 TX' 'Off'
Simple mixer control 'I2SMCC0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'Off'
root@sama7g5ek-sd:~# amixer sset 'SPDIFTX0 TX' 'Off'
Simple mixer control 'SPDIFTX0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'Off'
For recording a 6 channel capture stream from PDMC0 (4 channels) and SPDIFRX (2 channels), we set the
'PDMC0 RX' control to
'ASRC Capture PCM 1 BE 1' and
'SPDIFRX0 RX' to
'ASRC Capture PCM 1 BE 2':
root@sama7g5ek-sd:~# amixer sset 'PDMC0 RX' 'ASRC Capture PCM 1 BE 1'
Simple mixer control 'PDMC0 RX',0
Capabilities: enum
Items: 'Off' 'ASRC Capture PCM 1 BE 1' 'ASRC Capture PCM 1 BE 2' 'ASRC Capture PCM 1 BE 3' 'ASRC Capture PCM 1 BE 4' 'ASRC Capture PCM 2 BE 1' 'ASRC Capture PCM 2 BE 2' 'ASRC Capture PCM 2 BE 3' 'ASRC Capture
PCM 2 BE 4' 'ASRC Capture PCM 3 BE 1' 'ASRC Capture PCM 3 BE 2' 'ASRC Capture PCM 3 BE 3' 'ASRC Capture PCM 3 BE 4' 'ASRC Capture PCM 4 BE 1' 'ASRC Capture PCM 4 BE 2' 'ASRC Capture PCM 4 BE 3' 'ASRC Capture PCM
4 BE 4'
Item0: 'ASRC Capture PCM 1 BE 1'
root@sama7g5ek-sd:~# amixer sset 'SPDIFRX0 RX' 'ASRC Capture PCM 1 BE 2'
Simple mixer control 'SPDIFRX0 RX',0
Capabilities: enum
Items: 'Off' 'ASRC Capture PCM 1 BE 1' 'ASRC Capture PCM 1 BE 2' 'ASRC Capture PCM 1 BE 3' 'ASRC Capture PCM 1 BE 4' 'ASRC Capture PCM 2 BE 1' 'ASRC Capture PCM 2 BE 2' 'ASRC Capture PCM 2 BE 3' 'ASRC Capture
PCM 2 BE 4' 'ASRC Capture PCM 3 BE 1' 'ASRC Capture PCM 3 BE 2' 'ASRC Capture PCM 3 BE 3' 'ASRC Capture PCM 3 BE 4' 'ASRC Capture PCM 4 BE 1' 'ASRC Capture PCM 4 BE 2' 'ASRC Capture PCM 4 BE 3' 'ASRC Capture PCM
4 BE 4'
Item0: 'ASRC Capture PCM 1 BE 2'
We start the recording with the following command:
root@sama7g5ek-sd:~# arecord -Dhw:0,0 -c 6 -r 48000 -f S24_LE out.wav
Recording WAVE 'out.wav' : Signed 24 bit Little Endian, Rate 48000 Hz, Channels 6
If everything is fine, we should see the following message on the serial (or on
dmesg):
mchp_asrc e1610000.sound: ASRC IN AIF(s):
mchp_asrc e1610000.sound: sound@e1608000, 4 channels
mchp_asrc e1610000.sound: spdifrx@e1614000, 2 channels
mchp_asrc e1610000.sound: ASRC OUT AIF(s):
mchp_asrc e1610000.sound: front-end
Which mentions that a 6 channel capture stream is sent to the user (
front-end), composed of 4 channels from PDMC0 (
sound@e1608000) and 2 channels from SPDIFRX (
spdifrx@e1614000).
To enable PDMC0 on SAMA7G5 EK, make sure the
J3 jumper is closed. Also, the
#pdmc0 overlay must be applied in u-boot.
As previously mentioned, these kind of scenarios move the audio streams from a list of audio BEs, sends them to ASRC and then they are routed to other audio BEs, without user intervention. To accomplish this, we need to set both capture and playback controls (
'RX' and
'TX') to the same audio FE interface.
Make sure all previously
'RX' or
'TX' controls are set to
'Off'
For example, we can split a 4 audio channel from the PDM microphones of PDMC0 into 2 channels on I2SMCC0 and SPDIFTX. For this, we need to set
'I2SMCC0 TX' to
'ASRC Playback PCM 1 BE 1',
'SPDIFTX0 TX' to
'ASRC Playback PCM 1 BE 2' and
'PDMC0 RX' to
'ASRC Capture PCM 1 BE 1':
root@sama7g5ek-sd:~# amixer sset 'I2SMCC0 TX' 'ASRC Playback PCM 1 BE 1'
Simple mixer control 'I2SMCC0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'ASRC Playback PCM 1 BE 1'
root@sama7g5ek-sd:~# amixer sset 'SPDIFTX0 TX' 'ASRC Playback PCM 1 BE 2'
Simple mixer control 'SPDIFTX0 TX',0
Capabilities: enum
Items: 'Off' 'ASRC Playback PCM 1 BE 1' 'ASRC Playback PCM 1 BE 2' 'ASRC Playback PCM 1 BE 3' 'ASRC Playback PCM 1 BE 4' 'ASRC Playback PCM 2 BE 1' 'ASRC Playback PCM 2 BE 2' 'ASRC Playback PCM 2 BE 3' 'ASRC P
layback PCM 2 BE 4' 'ASRC Playback PCM 3 BE 1' 'ASRC Playback PCM 3 BE 2' 'ASRC Playback PCM 3 BE 3' 'ASRC Playback PCM 3 BE 4' 'ASRC Playback PCM 4 BE 1' 'ASRC Playback PCM 4 BE 2' 'ASRC Playback PCM 4 BE 3' 'A
SRC Playback PCM 4 BE 4'
Item0: 'ASRC Playback PCM 1 BE 2'
root@sama7g5ek-sd:~# amixer sset 'PDMC0 RX' 'ASRC Capture PCM 1 BE 1'
Simple mixer control 'PDMC0 RX',0
Capabilities: enum
Items: 'Off' 'ASRC Capture PCM 1 BE 1' 'ASRC Capture PCM 1 BE 2' 'ASRC Capture PCM 1 BE 3' 'ASRC Capture PCM 1 BE 4' 'ASRC Capture PCM 2 BE 1' 'ASRC Capture PCM 2 BE 2' 'ASRC Capture PCM 2 BE 3' 'ASRC Capture
PCM 2 BE 4' 'ASRC Capture PCM 3 BE 1' 'ASRC Capture PCM 3 BE 2' 'ASRC Capture PCM 3 BE 3' 'ASRC Capture PCM 3 BE 4' 'ASRC Capture PCM 4 BE 1' 'ASRC Capture PCM 4 BE 2' 'ASRC Capture PCM 4 BE 3' 'ASRC Capture PCM
4 BE 4'
Item0: 'ASRC Capture PCM 1 BE 1'
Right after this, on the default serial, or on
dmesg we should see:
mchp_asrc e1610000.sound: ASRC IN AIF(s):
mchp_asrc e1610000.sound: sound@e1608000, 4 channels
mchp_asrc e1610000.sound: ASRC OUT AIF(s):
mchp_asrc e1610000.sound: i2s@e161c000, 2 channels
mchp_asrc e1610000.sound: spdiftx@e1618000, 2 channels
This means that the DSPs' DPLLs locked and the 4 channel audio stream is running from the PDMC0 (
sound@e1608000), through ASRC, and then, first 2 channels sent to I2SMCC0 and next 2 channels sent to SPDIFTX (
spdiftx@e1618000).
This can only happen if the
'RX' and the
'TX' use the controls assigned to the same ASRC FE instance, in our case, the first instance:
'PCM 1'.
Troubleshooting
- If on the tests that involve SPDIFRX you do not see the message that confirms the start of the stream (and the lock of the DPLLs), make sure that the SPDIFRX connector receives data. The DPLLs can't lock unless there is real data sent to SPDIFRX;
- Sometimes, you could see an error like:
mchp_asrc e1610000.sound: the nr of DSPs needed for each BE is not in a descending order
mchp_asrc e1610000.sound: ASoC: error at snd_soc_dai_hw_params on asrc-pcm-1: -22
asrc-pcm-1: ASoC: soc_pcm_hw_params() failed (-22)
asrc-pcm-1: ASoC: dpcm_fe_dai_hw_params failed (-22)
This means that the order of the BEs is not support by ASRC. The ASRC must have the BEs put in a descending order relativ to their number of channels. For example, if we used PDMC0 with 4 channels and 2 channels with SPDIRX, PDMC0 must be set as the first BE and the SPDIFRX must be used as the second BE.
- A common error that could appear when starting a simple use-case is:
mchp_asrc e1610000.sound: FE uses X channels, BEs uses Y channels
mchp_asrc e1610000.sound: ASoC: error at snd_soc_dai_hw_params on asrc-pcm-1: -22
asrc-pcm-1: ASoC: soc_pcm_hw_params() failed (-22)
asrc-pcm-1: ASoC: dpcm_fe_dai_hw_params failed (-22)
This means that the number of audio channels asked by the used-space audio applications doesn't match with the number of audio channels summed up by the BEs. The number of the audio channels requested on the FE (ASRC) must be the same as the number of audio channels used on the BEs. For example, if
aplay/arecord commands are used, the number of audio channels on the FE can be easily set using
-c < channel_number > parameter. For more deiltas on the
aplay/arecord parameters please see the manual
here.
- Another error that might appear in a cross use-case is:
mchp_asrc e1610000.sound: 2 -> 1 DSPs; number needs to match
mchp_asrc e1610000.sound: ASoC: error at snd_soc_dai_hw_params on asrc-pcm-1: -22
asrc-pcm-1: ASoC: soc_pcm_hw_params() failed (-22)
asrc-pcm-1: ASoC: hw_params for FE failed -22
asrc-pcm-1: ASoC: dpcm_run_update_startup() failed (-22)
asrc-pcm-1: ASoC: failed to startup some BEs
This happens when the number of DSPs needed by the capture BEs is different than the number of DSPs needed by the playback BEs. For example, in our case, the capture BE is PDMC0 with 4 microphones, hence 4 channels, and the playback BE is SPDIFTX with 2 channels only. The DSPs are stereo, so we need 1 DSP for every 2 channels. Since we need 2 DSPs for PDMC and 1 DSP for SPDIFTX, the audrio stream can't start.
This error might also appear while the cross use-case configration is ongoing and not finished. In this case, please igonre the error messages.