WM8904 audio driver support for Jetson TX2 NX

Hi, I’m using BSP version 32.7.2 and we’ve added WM8904 to our custom Jetson TX2 NX carrier board to support audio functionality. We will source code in the WM8904 driver compiled into the kernel. These changes were also made to the device tree.
1、A dummy clock is added to device tree.

clocks {
wm8904_mclk: wm8904_mclk {
compatible = “fixed-clock”;
#clock-cells = <0>;
clock-frequency = <49152000>;
clock-output-names = “wm8904-mclk”;
status = “okay”;
};
};

2、Codec WM8904 is added under I2c node.

i2c@c250000 {
status = “okay”;
wm8904_codec: wm8904@1a {
status = “okay”;
compatible = “wlf,wm8904”;
reg = <0x1a>;
clocks = <&wm8904_mclk>;
clock-names = “mclk”;
};
};

3、Modified contents in the Sound node.

tegra_sound: sound {
status = “okay”;
nvidia,num-codec-link = <1>;
nvidia,num-clk = <6>;
nvidia,clk-rates = < 270950400 /* PLLA_x11025_RATE /
11289600 /
AUD_MCLK_x11025_RATE /
45158400 /
PLLA_OUT0_x11025_RATE /
45158400 /
AHUB_x11025_RATE /
245760000 /
PLLA_x8000_RATE /
12288000 /
AUD_MCLK_x8000_RATE /
49152000 /
PLLA_OUT0_x8000_RATE /
49152000 >;/
AHUB_x8000_RATE */
nvidia,xbar = <&tegra_axbar>;
nvidia,audio-routing =
“x Headphone”, “x Line Out”,
“x Line In”, “x Mic”;

            nvidia,dai-link-1 {
                    link-name = "wm8904-playback";
                    cpu-dai = <&tegra_i2s1>;
                    codec-dai = <&wm8904_codec>;
                    cpu-dai-name = "I2S1";
                    codec-dai-name = "wm8904-hifi";
                    format = "i2s";
                    bitclock-slave;
                    frame-slave;
                    bitclock-noninversion;
                    frame-noninversion;
                    bit-format = "s16_le";
                    bclk_ratio = <0>;
                    srate = <48000>;
                    num-channel = <2>;
                    ignore_suspend;
                    name-prefix = "x";
                    status = "okay";
            };

After I modified the above contents and started Jetson TX2 NX, I found the following error reported in dmesg. Could you tell me what I should do next?

nv@nv:~$ dmesg | grep 8904
[ 1.416410] wm8904 7-001a: Failed to get supply ‘DCVDD’: -19
[ 1.422184] wm8904 7-001a: Failed to request supplies: -19

The above problems have been solved by adding CONFIG_REGULATOR_DUMMY=y to tegra_defconfig in the source directory kernel-4.9/arch/arm64/configs .
The dmesg output now looks like this.
dmesg.txt (52.8 KB)

But now I can’t hear the sound when I play the audio. I used the oscilloscope to measure the I2S interface and found that the I2S interface did not output the signal when the audio file was played. May I ask what I can do to find the problem now?

1、I looked at the codec controls have the following

nv@nv:~$ amixer -c 1 controls | grep x
numid=987,iface=MIXER,name=‘DSPK1 Mux’
numid=988,iface=MIXER,name=‘DSPK2 Mux’
numid=920,iface=MIXER,name=‘I2S1 Mux’
numid=921,iface=MIXER,name=‘I2S2 Mux’
numid=922,iface=MIXER,name=‘I2S3 Mux’
numid=923,iface=MIXER,name=‘I2S4 Mux’
numid=924,iface=MIXER,name=‘I2S5 Mux’
numid=969,iface=MIXER,name=‘I2S6 Mux’
numid=910,iface=MIXER,name=‘ADMAIF1 Mux’
numid=919,iface=MIXER,name=‘ADMAIF10 Mux’
numid=959,iface=MIXER,name=‘ADMAIF11 Mux’
numid=960,iface=MIXER,name=‘ADMAIF12 Mux’
numid=961,iface=MIXER,name=‘ADMAIF13 Mux’
numid=962,iface=MIXER,name=‘ADMAIF14 Mux’
numid=963,iface=MIXER,name=‘ADMAIF15 Mux’
numid=964,iface=MIXER,name=‘ADMAIF16 Mux’
numid=965,iface=MIXER,name=‘ADMAIF17 Mux’
numid=966,iface=MIXER,name=‘ADMAIF18 Mux’
numid=967,iface=MIXER,name=‘ADMAIF19 Mux’
numid=911,iface=MIXER,name=‘ADMAIF2 Mux’
numid=968,iface=MIXER,name=‘ADMAIF20 Mux’
numid=912,iface=MIXER,name=‘ADMAIF3 Mux’
numid=913,iface=MIXER,name=‘ADMAIF4 Mux’
numid=914,iface=MIXER,name=‘ADMAIF5 Mux’
numid=915,iface=MIXER,name=‘ADMAIF6 Mux’
numid=916,iface=MIXER,name=‘ADMAIF7 Mux’
numid=917,iface=MIXER,name=‘ADMAIF8 Mux’
numid=918,iface=MIXER,name=‘ADMAIF9 Mux’
numid=957,iface=MIXER,name=‘ADX1 Mux’
numid=958,iface=MIXER,name=‘ADX2 Mux’
numid=978,iface=MIXER,name=‘ADX3 Mux’
numid=979,iface=MIXER,name=‘ADX4 Mux’
numid=939,iface=MIXER,name=‘AFC1 Mux’
numid=940,iface=MIXER,name=‘AFC2 Mux’
numid=941,iface=MIXER,name=‘AFC3 Mux’
numid=942,iface=MIXER,name=‘AFC4 Mux’
numid=943,iface=MIXER,name=‘AFC5 Mux’
numid=944,iface=MIXER,name=‘AFC6 Mux’
numid=949,iface=MIXER,name=‘AMX1-1 Mux’
numid=950,iface=MIXER,name=‘AMX1-2 Mux’
numid=951,iface=MIXER,name=‘AMX1-3 Mux’
numid=952,iface=MIXER,name=‘AMX1-4 Mux’
numid=953,iface=MIXER,name=‘AMX2-1 Mux’
numid=954,iface=MIXER,name=‘AMX2-2 Mux’
numid=955,iface=MIXER,name=‘AMX2-3 Mux’
numid=956,iface=MIXER,name=‘AMX2-4 Mux’
numid=970,iface=MIXER,name=‘AMX3-1 Mux’
numid=971,iface=MIXER,name=‘AMX3-2 Mux’
numid=972,iface=MIXER,name=‘AMX3-3 Mux’
numid=973,iface=MIXER,name=‘AMX3-4 Mux’
numid=974,iface=MIXER,name=‘AMX4-1 Mux’
numid=975,iface=MIXER,name=‘AMX4-2 Mux’
numid=976,iface=MIXER,name=‘AMX4-3 Mux’
numid=977,iface=MIXER,name=‘AMX4-4 Mux’
numid=980,iface=MIXER,name=‘ASRC1-1 Mux’
numid=981,iface=MIXER,name=‘ASRC1-2 Mux’
numid=982,iface=MIXER,name=‘ASRC1-3 Mux’
numid=983,iface=MIXER,name=‘ASRC1-4 Mux’
numid=984,iface=MIXER,name=‘ASRC1-5 Mux’
numid=985,iface=MIXER,name=‘ASRC1-6 Mux’
numid=986,iface=MIXER,name=‘ASRC1-7 Mux’
numid=839,iface=MIXER,name=‘Denominator1 Mux’
numid=840,iface=MIXER,name=‘Denominator2 Mux’
numid=841,iface=MIXER,name=‘Denominator3 Mux’
numid=842,iface=MIXER,name=‘Denominator4 Mux’
numid=843,iface=MIXER,name=‘Denominator5 Mux’
numid=844,iface=MIXER,name=‘Denominator6 Mux’
numid=929,iface=MIXER,name=‘MIXER1-1 Mux’
numid=938,iface=MIXER,name=‘MIXER1-10 Mux’
numid=930,iface=MIXER,name=‘MIXER1-2 Mux’
numid=931,iface=MIXER,name=‘MIXER1-3 Mux’
numid=932,iface=MIXER,name=‘MIXER1-4 Mux’
numid=933,iface=MIXER,name=‘MIXER1-5 Mux’
numid=934,iface=MIXER,name=‘MIXER1-6 Mux’
numid=935,iface=MIXER,name=‘MIXER1-7 Mux’
numid=936,iface=MIXER,name=‘MIXER1-8 Mux’
numid=937,iface=MIXER,name=‘MIXER1-9 Mux’
numid=947,iface=MIXER,name=‘MVC1 Mux’
numid=948,iface=MIXER,name=‘MVC2 Mux’
numid=649,iface=MIXER,name=‘Mixer Enable’
numid=833,iface=MIXER,name=‘Numerator1 Mux’
numid=834,iface=MIXER,name=‘Numerator2 Mux’
numid=835,iface=MIXER,name=‘Numerator3 Mux’
numid=836,iface=MIXER,name=‘Numerator4 Mux’
numid=837,iface=MIXER,name=‘Numerator5 Mux’
numid=838,iface=MIXER,name=‘Numerator6 Mux’
numid=945,iface=MIXER,name=‘OPE1 Mux’
numid=925,iface=MIXER,name=‘SFC1 Mux’
numid=926,iface=MIXER,name=‘SFC2 Mux’
numid=927,iface=MIXER,name=‘SFC3 Mux’
numid=928,iface=MIXER,name=‘SFC4 Mux’
numid=946,iface=MIXER,name=‘SPKPROT1 Mux’
numid=909,iface=MIXER,name=‘codec-x format’
numid=908,iface=MIXER,name=‘codec-x rate’
numid=893,iface=MIXER,name=‘x ADC 128x OSR Switch’
numid=1043,iface=MIXER,name=‘x AIFOUTL Mux’
numid=1044,iface=MIXER,name=‘x AIFOUTR Mux’
numid=890,iface=MIXER,name=‘x Capture Switch’
numid=889,iface=MIXER,name=‘x Capture Volume’
numid=906,iface=MIXER,name=‘x DAC Deemphasis Switch’
numid=905,iface=MIXER,name=‘x DAC OSRx2 Switch’
numid=1045,iface=MIXER,name=‘x DACL Mux’
numid=1046,iface=MIXER,name=‘x DACR Mux’
numid=904,iface=MIXER,name=‘x DRC Path’
numid=903,iface=MIXER,name=‘x DRC Switch’
numid=886,iface=MIXER,name=‘x Digital Capture Volume’
numid=894,iface=MIXER,name=‘x Digital Playback Boost Volume’
numid=895,iface=MIXER,name=‘x Digital Playback Volume’
numid=907,iface=MIXER,name=‘x Digital Sidetone Volume’
numid=902,iface=MIXER,name=‘x EQ Switch’
numid=881,iface=MIXER,name=‘x EQ1 Volume’
numid=882,iface=MIXER,name=‘x EQ2 Volume’
numid=883,iface=MIXER,name=‘x EQ3 Volume’
numid=884,iface=MIXER,name=‘x EQ4 Volume’
numid=885,iface=MIXER,name=‘x EQ5 Volume’
numid=1049,iface=MIXER,name=‘x HPL Mux’
numid=1050,iface=MIXER,name=‘x HPR Mux’
numid=897,iface=MIXER,name=‘x Headphone Switch’
numid=896,iface=MIXER,name=‘x Headphone Volume’
numid=898,iface=MIXER,name=‘x Headphone ZC Switch’
numid=892,iface=MIXER,name=‘x High Pass Filter Mode’
numid=891,iface=MIXER,name=‘x High Pass Filter Switch’
numid=1051,iface=MIXER,name=‘x LINEL Mux’
numid=1052,iface=MIXER,name=‘x LINER Mux’
numid=1040,iface=MIXER,name=‘x Left Capture Inverting Mux’
numid=1039,iface=MIXER,name=‘x Left Capture Mux’
numid=887,iface=MIXER,name=‘x Left Caputure Mode’
numid=1047,iface=MIXER,name=‘x Left Sidetone’
numid=900,iface=MIXER,name=‘x Line Output Switch’
numid=899,iface=MIXER,name=‘x Line Output Volume’
numid=901,iface=MIXER,name=‘x Line Output ZC Switch’
numid=1042,iface=MIXER,name=‘x Right Capture Inverting Mux’
numid=888,iface=MIXER,name=‘x Right Capture Mode’
numid=1041,iface=MIXER,name=‘x Right Capture Mux’
numid=1048,iface=MIXER,name=‘x Right Sidetone’

2、I then entered these commands to try and play the audio, but I didn’t hear anything.

nv@nv:~$ amixer -c 1 cset name=“I2S1 Mux” “ADMAIF1”
numid=920,iface=MIXER,name=‘I2S1 Mux’
; type=ENUMERATED,access=rw------,values=1,items=81
; Item #0 ‘None’
; Item #1 ‘ADMAIF1’
; Item #2 ‘ADMAIF2’
; Item #3 ‘ADMAIF3’
; Item #4 ‘ADMAIF4’
; Item #5 ‘ADMAIF5’
; Item #6 ‘ADMAIF6’
; Item #7 ‘ADMAIF7’
; Item #8 ‘ADMAIF8’
; Item #9 ‘ADMAIF9’
; Item #10 ‘ADMAIF10’
; Item #11 ‘ADMAIF11’
; Item #12 ‘ADMAIF12’
; Item #13 ‘ADMAIF13’
; Item #14 ‘ADMAIF14’
; Item #15 ‘ADMAIF15’
; Item #16 ‘ADMAIF16’
; Item #17 ‘I2S1’
; Item #18 ‘I2S2’
; Item #19 ‘I2S3’
; Item #20 ‘I2S4’
; Item #21 ‘I2S5’
; Item #22 ‘I2S6’
; Item #23 ‘SFC1’
; Item #24 ‘SFC2’
; Item #25 ‘SFC3’
; Item #26 ‘SFC4’
; Item #27 ‘MIXER1-1’
; Item #28 ‘MIXER1-2’
; Item #29 ‘MIXER1-3’
; Item #30 ‘MIXER1-4’
; Item #31 ‘MIXER1-5’
; Item #32 ‘AMX1’
; Item #33 ‘AMX2’
; Item #34 ‘AMX3’
; Item #35 ‘AMX4’
; Item #36 ‘ARAD1’
; Item #37 ‘AFC1’
; Item #38 ‘AFC2’
; Item #39 ‘AFC3’
; Item #40 ‘AFC4’
; Item #41 ‘AFC5’
; Item #42 ‘AFC6’
; Item #43 ‘OPE1’
; Item #44 ‘SPKPROT1’
; Item #45 ‘MVC1’
; Item #46 ‘MVC2’
; Item #47 ‘IQC1-1’
; Item #48 ‘IQC1-2’
; Item #49 ‘IQC2-1’
; Item #50 ‘IQC2-2’
; Item #51 ‘DMIC1’
; Item #52 ‘DMIC2’
; Item #53 ‘DMIC3’
; Item #54 ‘DMIC4’
; Item #55 ‘ADX1-1’
; Item #56 ‘ADX1-2’
; Item #57 ‘ADX1-3’
; Item #58 ‘ADX1-4’
; Item #59 ‘ADX2-1’
; Item #60 ‘ADX2-2’
; Item #61 ‘ADX2-3’
; Item #62 ‘ADX2-4’
; Item #63 ‘ADX3-1’
; Item #64 ‘ADX3-2’
; Item #65 ‘ADX3-3’
; Item #66 ‘ADX3-4’
; Item #67 ‘ADX4-1’
; Item #68 ‘ADX4-2’
; Item #69 ‘ADX4-3’
; Item #70 ‘ADX4-4’
; Item #71 ‘ADMAIF17’
; Item #72 ‘ADMAIF18’
; Item #73 ‘ADMAIF19’
; Item #74 ‘ADMAIF20’
; Item #75 ‘ASRC1-1’
; Item #76 ‘ASRC1-2’
; Item #77 ‘ASRC1-3’
; Item #78 ‘ASRC1-4’
; Item #79 ‘ASRC1-5’
; Item #80 ‘ASRC1-6’
: values=1
nv@nv:~$ amixer -c 1 cset name=“x DAC OSRx2 Switch” “on”
numid=905,iface=MIXER,name=‘x DAC OSRx2 Switch’
; type=BOOLEAN,access=rw------,values=1
: values=on
nv@nv:~$ amixer -c 1 cset name=“x DAC Deemphasis Switch” “on”
numid=906,iface=MIXER,name=‘x DAC Deemphasis Switch’
; type=BOOLEAN,access=rw------,values=1
: values=on
nv@nv:~$ amixer -c 1 cset name=“x Headphone Switch” “on”
numid=897,iface=MIXER,name=‘x Headphone Switch’
; type=BOOLEAN,access=rw------,values=2
: values=on,on
nv@nv:~$ amixer -c 1 cset name=“x Headphone Volume” 40
numid=896,iface=MIXER,name=‘x Headphone Volume’
; type=INTEGER,access=rw—R–,values=2,min=0,max=63,step=0
: values=40,40
| dBscale-min=-57.00dB,step=1.00dB,mute=0
nv@nv:~$ aplay -D hw:1,0 gzrobot.wav
Playing WAVE ‘gzrobot.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
nv@nv:~$

And the audio file gzrobot. wav playback time is about 1 minute, but I aplay-D HW :1,0 gzrobot. wav it immediately stopped and did not wait for about 1 minute, I was using oscilloscope detection I2S interface did not see any signal.
I hope someone can help me follow up on this issue. Thank you!!

Hi,

Did you set the pinmux setting for I2S1 using jetson-io tool? Commands listed below for reference

sudo /opt/nvidia/jetson-io/config-by-function.py -o dtb i2s1 aud_mclk
sudo reboot

Also, I see that audio routes in sound node have to be modified as below

nvidia,audio-routing =
    "x Headphone", "x HPOUTL",
    "x Headphone", "x HPOUTR";

See if this helps

Thanks

Yes, I will use the Jetson-io. py tool to set pinmux which I have set to look like this.

1、I’m now done with the device tree, but it’s still not playing sound, and these errors are reported in dmesg after startup

[ 9.725376] wm8904 7-001a: System clock not configured
[ 9.730560] wm8904 7-001a: ASoC: can’t set wm8904-hifi hw params: -22
[ 9.737019] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -22

Here is the complete log
dmesg.txt (53.6 KB)

2、I used the following command to display all the widgets

nv@nv:~$ amixer -c 1 controls
numid=902,iface=MIXER,name=‘x EQ Switch’
numid=881,iface=MIXER,name=‘x EQ1 Volume’
numid=882,iface=MIXER,name=‘x EQ2 Volume’
numid=883,iface=MIXER,name=‘x EQ3 Volume’
numid=884,iface=MIXER,name=‘x EQ4 Volume’
numid=885,iface=MIXER,name=‘x EQ5 Volume’
numid=1149,iface=MIXER,name=‘x HPL Mux’
numid=1150,iface=MIXER,name=‘x HPR Mux’
numid=897,iface=MIXER,name=‘x Headphone Switch’
numid=896,iface=MIXER,name=‘x Headphone Volume’
numid=898,iface=MIXER,name=‘x Headphone ZC Switch’
numid=892,iface=MIXER,name=‘x High Pass Filter Mode’
numid=891,iface=MIXER,name=‘x High Pass Filter Switch’
numid=1151,iface=MIXER,name=‘x LINEL Mux’
numid=1152,iface=MIXER,name=‘x LINER Mux’
numid=1140,iface=MIXER,name=‘x Left Capture Inverting Mux’
numid=1139,iface=MIXER,name=‘x Left Capture Mux’
numid=887,iface=MIXER,name=‘x Left Caputure Mode’
numid=1147,iface=MIXER,name=‘x Left Sidetone’
numid=900,iface=MIXER,name=‘x Line Output Switch’
numid=899,iface=MIXER,name=‘x Line Output Volume’
numid=901,iface=MIXER,name=‘x Line Output ZC Switch’
numid=1142,iface=MIXER,name=‘x Right Capture Inverting Mux’
numid=888,iface=MIXER,name=‘x Right Capture Mode’
numid=1141,iface=MIXER,name=‘x Right Capture Mux’
numid=1148,iface=MIXER,name=‘x Right Sidetone’

The complete command output is available here
command.txt (54 KB)

I called the following commands to play audio, but there was still no sound.

nv@nv:~$ amixer -c 1 cset name=“x Headphone Switch” “on”
numid=897,iface=MIXER,name=‘x Headphone Switch’
; type=BOOLEAN,access=rw------,values=2
: values=on,on
nv@nv:~$ amixer -c 1 cset name=“x DAC OSRx2 Switch” “on”
numid=905,iface=MIXER,name=‘x DAC OSRx2 Switch’
; type=BOOLEAN,access=rw------,values=1
: values=on
nv@nv:~$ aplay -D hw:1,0 gzrobot.wav
Playing WAVE ‘gzrobot.wav’ : Signed 16 bit Little Endian, Rate 16000 Hz, Mono

And I added these prints to dmesg when I called ‘aplay’, they were the same errors as before.

[ 1976.191084] wm8904 7-001a: System clock not configured
[ 1976.196249] wm8904 7-001a: ASoC: can’t set wm8904-hifi hw params: -22
[ 1976.202708] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -22
[ 1976.361099] wm8904 7-001a: System clock not configured
[ 1976.366391] wm8904 7-001a: ASoC: can’t set wm8904-hifi hw params: -22
[ 1976.372936] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -22
[ 1976.543196] wm8904 7-001a: System clock not configured
[ 1976.548361] wm8904 7-001a: ASoC: can’t set wm8904-hifi hw params: -22
[ 1976.554815] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -22
[ 2082.340175] wm8904 7-001a: System clock not configured
[ 2082.345509] wm8904 7-001a: ASoC: can’t set wm8904-hifi hw params: -22
[ 2082.352084] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -22

Are there any widgets I did not operate or the clock frequency in the device tree is not turned on to report these errors? What should I do now?

Hi,

Below error can be traced to be coming from codec driver

[ 9.725376] wm8904 7-001a: System clock not configured

Api exposed for setting sys clk source in codec driver should be called to avoid this error. Reference example is available at link

Thanks

Hi,

I see that the source of this error is from here in the source code

static int wm8904_configure_clocking(struct snd_soc_codec *codec)
{
struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
unsigned int clock0, clock2, rate;

/* Gate the clock while we're updating to avoid misclocking */
clock2 = snd_soc_read(codec, WM8904_CLOCK_RATES_2);
snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2,
		    WM8904_SYSCLK_SRC, 0);

/* This should be done on init() for bypass paths */
switch (wm8904->sysclk_src) {
case WM8904_CLK_MCLK:
	dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8904->mclk_rate);

	clock2 &= ~WM8904_SYSCLK_SRC;
	rate = wm8904->mclk_rate;

	/* Ensure the FLL is stopped */
	snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1,
			    WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0);
	break;

case WM8904_CLK_FLL:
	dev_dbg(codec->dev, "Using %dHz FLL clock\n",
		wm8904->fll_fout);

	clock2 |= WM8904_SYSCLK_SRC;
	rate = wm8904->fll_fout;
	break;

default:
	dev_err(codec->dev, "System clock not configured\n");
	return -EINVAL;
}

/* SYSCLK shouldn't be over 13.5MHz */
if (rate > 13500000) {
	clock0 = WM8904_MCLK_DIV;
	wm8904->sysclk_rate = rate / 2;
} else {
	clock0 = 0;
	wm8904->sysclk_rate = rate;
}

snd_soc_update_bits(codec, WM8904_CLOCK_RATES_0, WM8904_MCLK_DIV,
		    clock0);

snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2,
		    WM8904_CLK_SYS_ENA | WM8904_SYSCLK_SRC, clock2);

dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate);

return 0;

}

'wm8904->Sysclk_src 'is not set. How do I set it up?I saw in the development guide that it says to add an initialization function.


I found this in the source code tegra_machine_driver_mobile.c,I found this in the source tegra_machine_driver_mobile.c, but I don’t know what the WM8904 function snd_soc_dai_set_sysclk() is for; What should be filled in the second parameter, I did not find this content in the source code of WM8904.

I have now added these to tegra_machine_driver_mobile.c and the error has been resolved.

static int tegra_machine_wm8904_init(struct snd_soc_pcm_runtime *rtd)
{
struct device *dev = rtd->card->dev;
int err;
err = snd_soc_dai_set_sysclk(rtd->codec_dai, WM8904_CLK_MCLK, 12288000,
SND_SOC_CLOCK_IN);
if (err) {
dev_err(dev, “failed to wm8904 sysclk!\n”);
return err;
}
return 0;
}
static int codec_init(struct tegra_machine *machine)
{
struct snd_soc_dai_link *dai_links = machine->asoc->dai_links;
unsigned int num_links = machine->asoc->num_links, i;
if (!dai_links || !num_links)
return -EINVAL;
for (i = 0; i < num_links; i++) {
if (!dai_links[i].name)
continue;
if (strstr(dai_links[i].name, “rt565x-playback”) ||
strstr(dai_links[i].name, “rt565x-codec-sysclk-bclk1”))
dai_links[i].init = tegra_machine_rt565x_init;
else if (strstr(dai_links[i].name, “fe-pi-audio-z-v2”))
dai_links[i].init = tegra_machine_fepi_init;
else if (strstr(dai_links[i].name, “respeaker-4-mic-array”))
dai_links[i].init = tegra_machine_respeaker_init;
else if (strstr(dai_links[i].name, “wm8904-playback”))
dai_links[i].init = tegra_machine_wm8904_init;
}
return 0;
}
But now there is a new error in dmesg

[ 55.905952] wm8904 7-001a: DC servo timed out
[ 62.065945] wm8904 7-001a: DC servo timed out
[ 68.233955] wm8904 7-001a: DC servo timed out
[ 76.721952] wm8904 7-001a: DC servo timed out

Here is the complete log
dmesg.txt (53.2 KB)

I tried to play the sound but it said the device was busy

nv@nv-desktop:~$ amixer -c 1 cset name=‘I2S1 Mux’ ‘ADMAIF1’
numid=1020,iface=MIXER,name=‘I2S1 Mux’
; type=ENUMERATED,access=rw------,values=1,items=81
; Item #0 ‘None’
; Item #1 ‘ADMAIF1’
; Item #2 ‘ADMAIF2’
; Item #3 ‘ADMAIF3’
; Item #4 ‘ADMAIF4’
; Item #5 ‘ADMAIF5’
; Item #6 ‘ADMAIF6’
; Item #7 ‘ADMAIF7’
; Item #8 ‘ADMAIF8’
; Item #9 ‘ADMAIF9’
; Item #10 ‘ADMAIF10’
; Item #11 ‘ADMAIF11’
; Item #12 ‘ADMAIF12’
; Item #13 ‘ADMAIF13’
; Item #14 ‘ADMAIF14’
; Item #15 ‘ADMAIF15’
; Item #16 ‘ADMAIF16’
; Item #17 ‘I2S1’
; Item #18 ‘I2S2’
; Item #19 ‘I2S3’
; Item #20 ‘I2S4’
; Item #21 ‘I2S5’
; Item #22 ‘I2S6’
; Item #23 ‘SFC1’
; Item #24 ‘SFC2’
; Item #25 ‘SFC3’
; Item #26 ‘SFC4’
; Item #27 ‘MIXER1-1’
; Item #28 ‘MIXER1-2’
; Item #29 ‘MIXER1-3’
; Item #30 ‘MIXER1-4’
; Item #31 ‘MIXER1-5’
; Item #32 ‘AMX1’
; Item #33 ‘AMX2’
; Item #34 ‘AMX3’
; Item #35 ‘AMX4’
; Item #36 ‘ARAD1’
; Item #37 ‘AFC1’
; Item #38 ‘AFC2’
; Item #39 ‘AFC3’
; Item #40 ‘AFC4’
; Item #41 ‘AFC5’
; Item #42 ‘AFC6’
; Item #43 ‘OPE1’
; Item #44 ‘SPKPROT1’
; Item #45 ‘MVC1’
; Item #46 ‘MVC2’
; Item #47 ‘IQC1-1’
; Item #48 ‘IQC1-2’
; Item #49 ‘IQC2-1’
; Item #50 ‘IQC2-2’
; Item #51 ‘DMIC1’
; Item #52 ‘DMIC2’
; Item #53 ‘DMIC3’
; Item #54 ‘DMIC4’
; Item #55 ‘ADX1-1’
; Item #56 ‘ADX1-2’
; Item #57 ‘ADX1-3’
; Item #58 ‘ADX1-4’
; Item #59 ‘ADX2-1’
; Item #60 ‘ADX2-2’
; Item #61 ‘ADX2-3’
; Item #62 ‘ADX2-4’
; Item #63 ‘ADX3-1’
; Item #64 ‘ADX3-2’
; Item #65 ‘ADX3-3’
; Item #66 ‘ADX3-4’
; Item #67 ‘ADX4-1’
; Item #68 ‘ADX4-2’
; Item #69 ‘ADX4-3’
; Item #70 ‘ADX4-4’
; Item #71 ‘ADMAIF17’
; Item #72 ‘ADMAIF18’
; Item #73 ‘ADMAIF19’
; Item #74 ‘ADMAIF20’
; Item #75 ‘ASRC1-1’
; Item #76 ‘ASRC1-2’
; Item #77 ‘ASRC1-3’
; Item #78 ‘ASRC1-4’
; Item #79 ‘ASRC1-5’
; Item #80 ‘ASRC1-6’
: values=1
nv@nv-desktop:~$ amixer -c 1 cset name=‘x DAC OSRx2 Switch’ ‘on’
numid=905,iface=MIXER,name=‘x DAC OSRx2 Switch’
; type=BOOLEAN,access=rw------,values=1
: values=on
nv@nv-desktop:~$ amixer -c 1 cset name=‘x DAC Deemphasis Switch’ ‘on’
numid=906,iface=MIXER,name=‘x DAC Deemphasis Switch’
; type=BOOLEAN,access=rw------,values=1
: values=on
nv@nv-desktop:~$ amixer -c 1 cset name=‘x Headphone Switch’ ‘on’
numid=897,iface=MIXER,name=‘x Headphone Switch’
; type=BOOLEAN,access=rw------,values=2
: values=on,on
nv@nv-desktop:~$ amixer -c 1 cset name=‘x Headphone Volume’ 40
numid=896,iface=MIXER,name=‘x Headphone Volume’
; type=INTEGER,access=rw—R–,values=2,min=0,max=63,step=0
: values=40,40
| dBscale-min=-57.00dB,step=1.00dB,mute=0
nv@nv-desktop:~$ aplay -D hw:1,0 gzrobot.wav
aplay: main:788: audio open error: Device or resource busy

What should I do now?

Hi,

For the error mentioned in dmesg (DC servo timed out), I guess some power supply/clock may be missing. What are the power supply connections expected by the codec and voltage required by each power supply pin? Ensure they are being provided by measuring/probing the same.
Also, could you probe the mclk connection to see if its sending clock on that line at the rate of 12.28MHz.

Further, suggest you to contact codec vendor to understand the possible reason for this error

Try below commands instead and see if busy error goes away

amixer -c 1 cset name=‘I2S1 Mux’ ‘ADMAIF2’
aplay -D hw:1,1 gzrobot.wav /* assuming the wav file is of rate 48KHz */

Thanks

Yes, the mistakes are gone,But there’s no sound.

Hi,

I suspect that error from codec driver could be the culprit. Follow up regarding the same with codec vendor.

Meanwhile, you could try steps from link and share the DAPM path trace

Thanks

HI,

I used ‘i2Cset’ directly to configure the WM8904 register, then restored the device tree modification, I directly used ‘aplay’ command to play the sound, it played successfully.

Since there is a problem with the driver, I wonder whether the driver of WM8903 is compatible with WM8904. I found that these two chips are compatible.

Thanks

I’m not sure how I should do this, can you give me an example, or do you have relevant documentation?

Hi,

Since you are able to play audio, capturing dapm trace is no more necessary. (BTW, I have already provided the link to documentation if needed for future in previous comment)

Which WM8904 register did you configure for it to work?

Thanks

Hi,

For the moment, I don’t care who the specific register I set is, because we successfully debug WM8904 on RK3288 platform before, so I use logic analyzer to capture the data on I2C bus when using ‘aplay’ command on RK3288 platform, and then I directly set these data on WM8904.

I’m now writing this data on Jetson using these two scripts
wm8904_init.sh (390 Bytes)

wm8904_aplay.sh (2.2 KB)

I restored the device tree there is no WM8904 related things, audio signals are transmitted directly from I2S to WM8904 through the virtual sound card.

Hi,

Glad to know that sound is working. However, if you wish to use alsa utilities to play/set mixer controls, better to get appropriate codec driver from vendor that works without having to do explicit programming

Regards

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.