MAX98357A Audio Codec (Amplifier) on i.MX8M Mini

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MAX98357A Audio Codec (Amplifier) on i.MX8M Mini

ソリューションへジャンプ
159件の閲覧回数
akoch
Contributor II

I'm trying to get a MAX98357A I2S audio amplifier working on the i.MX8M Mini EVK.

I've had this codec working perfectly fine on an i.MX6 board using the 'simple-audio-card' approach before so I copied most of the device tree blocks and changed the SAI parts.

It currently looks like this:

codec: max98357a {
compatible = "maxim,max98357a";
#sound-dai-cells = <0>;
};

sound {
compatible = "simple-audio-card";
simple-audio-card,name = "max98357a";
simple-audio-card,format = "i2s";
simple-audio-card,widgets = "Speaker", "Speakers";
simple-audio-card,routing = "Speakers", "Speaker";
simple-audio-card,bitclock-master = <&cpu_dai>;
simple-audio-card,frame-master = <&cpu_dai>;

cpu_dai: simple-audio-card,cpu {
sound-dai = <&sai3>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <16>;
};

codec_dai: simple-audio-card,codec {
sound-dai = <&codec>;
clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
};
};

&sai3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL2_OUT>;
assigned-clock-rates = <24576000>;
fsl,sai-mclk-direction-output;
status = "okay";
};

pinctrl_sai3: sai3grp {
fsl,pins = <
MX8MM_IOMUXC_SAI3_TXFS_SAI3_TX_SYNC 0xd6
MX8MM_IOMUXC_SAI3_TXC_SAI3_TX_BCLK 0xd6
MX8MM_IOMUXC_SAI3_MCLK_SAI3_MCLK 0xd6
MX8MM_IOMUXC_SAI3_TXD_SAI3_TX_DATA0 0xd6
>;
};

The audio device is recognized and the driver module is loaded. However I am unable to play any files:

# aplay ImperialMarch60.wav
Playing WAVE 'ImperialMarch60.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
aplay: set_params:1456: Unable to install hw params

Kernel:

[  990.915833] fsl-sai 30030000.sai: failed to derive required Tx rate: 1411200
[  990.923163] fsl-sai 30030000.sai: ASoC: error at snd_soc_dai_hw_params on 30030000.sai: -22

Using a scope I can see the MCLK on SAI3 but no activity on the data lines.

I already found a matching issue in form of a Toradex post, that's why I changed from PLL1 to PLL2 but in contrast to that topic over there this did not fix my issue.

I also found this post in the NXP community describing the very same issue but on an i.MX8M Plus. I tried adapting the solution but it seems to me that there are multiple clocks that are just not present on the 8M Mini (e.g. IMX8MP_CLK_AUDIOMIX_SAI3_IPG).

Thanks in advance for any help on this!

ラベル(2)
タグ(2)
0 件の賞賛
1 解決策
121件の閲覧回数
akoch
Contributor II

Solved my issue. Turned out that the kernel/dts was not the culprit, it was ALSA.

I've used the same test file all the time, which was a 22 kHz mono file. When I tried with a 48 kHz stereo one it just worked.

So I added the following as '/etc/asound.conf' in order to re-sample everything to 48 kHz stereo:

 

 

pcm.speakerbonnet {
	type hw card 0
}
pcm.dmixer {
	type dmix
	ipc_key 1024
	ipc_perm 0666
	slave {
		pcm "speakerbonnet"
		rate 48000
		channels 2
	}
}
ctl.dmixer {
	type hw card 0
}
pcm.softvol {
	type softvol
	slave.pcm "dmixer"
	control.name "PCM"
	control.card 0
}
ctl.softvol {
	type hw card 0
}
pcm.!default {
	type plug
	slave.pcm "softvol"
}

 

 

 Now my original 22 kHz test file works fine as well

元の投稿で解決策を見る

3 返答(返信)
122件の閲覧回数
akoch
Contributor II

Solved my issue. Turned out that the kernel/dts was not the culprit, it was ALSA.

I've used the same test file all the time, which was a 22 kHz mono file. When I tried with a 48 kHz stereo one it just worked.

So I added the following as '/etc/asound.conf' in order to re-sample everything to 48 kHz stereo:

 

 

pcm.speakerbonnet {
	type hw card 0
}
pcm.dmixer {
	type dmix
	ipc_key 1024
	ipc_perm 0666
	slave {
		pcm "speakerbonnet"
		rate 48000
		channels 2
	}
}
ctl.dmixer {
	type hw card 0
}
pcm.softvol {
	type softvol
	slave.pcm "dmixer"
	control.name "PCM"
	control.card 0
}
ctl.softvol {
	type hw card 0
}
pcm.!default {
	type plug
	slave.pcm "softvol"
}

 

 

 Now my original 22 kHz test file works fine as well

133件の閲覧回数
JorgeCas
NXP TechSupport
NXP TechSupport

Issues related to the error:

[ 990.915833] fsl-sai 30030000.sai: failed to derive required Tx rate: 1411200
[ 990.923163] fsl-sai 30030000.sai: ASoC: error at snd_soc_dai_hw_params on 30030000.sai: -22

Are related to PLL, because pre-scalers and adjustment cannot reach that specific frequency. Our BSP works with 12288000 and 24576000.

So, I suggest try with these clock rates and verify it on Linux's clk summary:

cat /sys/kernel/debug/clk/clk_summary

If we use our EVK device tree as reference it uses the next value on assigned-clock-parents property, could you please try it?

&sai3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
assigned-clock-rates = <24576000>;
fsl,sai-mclk-direction-output;
status = "okay";
};

Best regards.

0 件の賞賛
131件の閲覧回数
akoch
Contributor II

Hi JorgeCas!

Thanks for your quick answer.

I did already have

 

assigned-clock-rates = <24576000>;

 

in the sai3 block so I just switched from PLL2 to PLL1 for the assigned-clock-parents as you suggested but this did not change anything.

I also tried with the second clock rate that you have proposed:

 

assigned-clock-rates = <12288000>;

 

Unfortunately this did not change anything either, same error message:

[ 34.068689] fsl-sai 30030000.sai: failed to derive required Tx rate: 1411200
[ 34.077415] fsl-sai 30030000.sai: ASoC: error at snd_soc_dai_hw_params on 30030000.sai: -2

Edit: I've attached the clock summary for reference.

0 件の賞賛