But there are errors during boot (see attached dmesg.log, timestamp 5.075526)
It seems I have a problem with the MCLK of the codec. In the kernel source tlv320aic31xx.c, only 12 and 12,5 MHz are supported (see struct aic31xx_divs). But with the default device tree for the Verdin iMX8MM these values are not achievable. I only got 12684288 Hz or 11915637 Hz.
Since the clock IMX8MM_AUDIO_PLL1_OUT is the parent clock of the sai2 (Line 696 of file imx8mm-verdin.dtsi) I tried to change this PLL-clock to a multiple of 12 MHz. But this didn’t work either.
Is it even possible to use the TLV320DAC3100 on a Verdin IMX8MM or do I have to use another codec?
See the attached dmesg.log. The solution was, to assign a clock-parent to &sai2 with 24 MHz.
Now when I try to test the codec I get the error -19, that there is no device:
$ speaker-test
speaker-test 1.2.1
Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib ../../../alsa-lib-1.2.1.2/src/pcm/pcm_direct.c:1824:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
Playback open error: -19,No such device
There is no data transfer on the I2C or I2S lines.
Any ideas?
Could you please check alsamixer to see which sound card is being used by default? Also, using the alsamixer are you able to enable the speaker? Please share the dmesg log after performing configuration using alsamixer.
Please, also check the commands from this Audio (Linux) | Toradex Developer Center article. You can see that there is an example for speaker-test as well: please try to point to your specific sound card as well.
I understand that you are trying to use IMX8MM_AUDIO_PLL1_REF_SEL instead of the default IMX8MM_AUDIO_PLL1_OUT for &sai2. But could you please test with the default clock (IMX8MM_AUDIO_PLL1_OUT) again?
Also could you please share how are you connecting your codec to the module?
When I try this then I get the errors during boot, that the MCLK has an unsupported frequency (12684288 Hz) and I have no soundcard at all. Please see the dmesg.log in my first post.
When I call alsamixer, I got the error cannot open mixer: No such device.
Alsamixer only opens, when I use alsamixer -Dsysdefault. There I can unmute the speaker and set the volume. The dmesg log is attached.
Pressing F6 to select the sound card, I see two entries: - (default) and 0 tlv320aic3100. When I try to select the default one I get the error Cannot open mixer device 'default'. No such device.
With speaker-test -Dsysdefault the test starts and I see traffic on all I2S-lines (BCLK, SYNC, DOUT, MCLK). But still no sound. We connected the module as follows:
The fact that tlv320aic3100 is showing up in alsamixer is good, at least
What happens when you try to select tlv320aic3100 and unmute it?
That is intriguing… does unmuting and increasing tlv320aic3100’s volume in alsamixer helps?
Could you please also share the output of:
cat /proc/asound/cards
and
cat /etc/asound.conf
If you want to use your tlv320aic3100 as the default sound card, please refer to Setting the default device - AlsaProject to learn how to set the default sound card to it.
Maybe your default sound card is by default pointing to nowhere?
I finally got it to output a sound.
All this time I didn’t realize that I had to unmute not only the speaker, but also the output of the DAC.
Additionally there was a bug in my wire setup.
Another source of error was the /etc/asound.conf. I use the reference multimedia image with the built in asound.conf. In this the default sound card is set to the NAU8822. So I made the following entries:
pcm.default_card{
type hw
card "tlv320aic3100"
}
ctl.!default{
type hw
card "tlv320aic3100"
}
ctl.mixer0{
type hw
card "tlv320aic3100"
}
The sound quality is not necessarily good and also quite quiet. But that should be fixable.
I understand that you are trying to use IMX8MM_AUDIO_PLL1_REF_SEL instead of the default IMX8MM_AUDIO_PLL1_OUT for &sai2. But could you please test with the default clock (IMX8MM_AUDIO_PLL1_OUT) again?
Since I get an error message when booting up that a reparenting is not possible, I took another look at this issue and found a better solution:
When I change the AUDIO_PLL1-clock to a multiply of 12 or 12.5 MHz (e.g. 650 MHz) then I can use the default IMX8MM_AUDIO_PLL1_OUT and I get a supported frequency for the TLV320DAC3100: