We have a board which has an iMX6ULL SOM module with a CS4270 codec attached via sai1. It is set up so that the codec is the i2s master. In this setup, we have found that audio output (playing back a file) is working fine, however we are not getting any input from the codec. The result of running `arecord` is a file of all 0's as seen below:
arecord --format=S24_LE --duration=5 --rate=48000 --file-type=raw -c 2 out.raw -vvv
Recording raw data 'out.raw' : Signed 24 bit Little Endian, Rate 48000 Hz, Stereo
Plug PCM: Hardware PCM card 0 'r0-audio' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S24_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 32
buffer_size : 24000
period_size : 6000
period_time : 125000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 6000
period_event : 0
start_threshold : 1
stop_threshold : 24000
silence_threshold: 0
silence_size : 0
boundary : 1572864000
appl_ptr : 0
hw_ptr : 0
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
Max peak (12000 samples): 0x00000000 # 0%
^CAborted by signal Interrupt...
Max peak (12000 samples): 0x00000000 # 0%
root@r0:~# hexdump out.raw
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
00afc80
Here is what we have in our device tree:
#include "imx6ul.dtsi"
/{
...
codec_clk: aud_clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12288000>;
};
sound {
/* Simple-card driver definition */
status = "okay";
compatible = "simple-audio-card";
simple-audio-card,name = "r0-audio";
/* Define i2s format, see fig. 10 in cs4270 data sheet */
simple-audio-card,format = "i2s";
/* Set codec as clock master */
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;
/* Define the cpu audio block */
cpu_dai: simple-audio-card,cpu {
/* i2s from codec is connected to sai1 */
sound-dai = <&sai1>;
/* 2 data frames (stereo)
* 32-bit width (even though we only fill 24)
*/
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
};
/* Define the codec audio block */
codec_dai: simple-audio-card,codec {
/* Point to the codec definition at i2c2 */
sound-dai = <&codec>;
/* Provide the clock definition since the codec is master */
clocks = <&codec_clk 0>;
};
};
/* CS4270 codec is attached to sai1 on the CPU, this block enables it */
&sai1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai1>;
status = "okay";
};
/* Audio I2C Bus */
&i2c2 {
clock_frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c2>;
status = "okay";
/* CS4270 codec is at address 0x48 */
codec: cs4270@48 {
#sound-dai-cells = <0>;
status = "okay";
compatible = "cirrus,cs4270";
reg = <0x48>;
reset-gpios = <&gpio2 11 0>;
};
};
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog>;
imx6ul-evk {
/* Pins required for sai1 (i2s to codec) */
pinctrl_sai1: sai1grp {
fsl,pins = <
/* cs4270 codec wired to SAI1 */
/* Note that the RX_BCLK and RX_SYNC clock follow the TX clocks */
MX6UL_PAD_CSI_DATA04__SAI1_TX_SYNC 0x1b080
MX6UL_PAD_CSI_DATA05__SAI1_TX_BCLK 0x1b080
MX6UL_PAD_CSI_DATA06__SAI1_RX_DATA 0x11080
MX6UL_PAD_CSI_DATA07__SAI1_TX_DATA 0x1f0b8
>;
};
};
};
Here is what we have in `asound.conf`
pcm.device{
format S24_LE
rate 48000
type hw
card 0
device 0
}
pcm.!default{
type plug
slave.pcm "device"
}
This is all working fine for audio playback. I have checked the iMX registers using devmem2 and it appears that everything is set up correctly for the sai module, however I am not able to get any audio data. We have verified on a scope that the SCLK, LRCLK, and i2s data is coming in correctly, however it seems that the data is never being received by ALSA applications. Any help would be appreciated!
Hi Willard
one can try amixer described in sect.7.5 Audio Mixer (AUDMIX) i.MX Linux Reference Manual
https://source.codeaurora.org/external/imx/imx-test/tree/test/mxc_amix_test?h=imx_5.4.24_2.1.0
Best regards
igor