We have the tlv320aic3007 audio codec on our custom carrier board connected to i2c0 and i2s0 lines on the nano. I’ve tried to update the device tree according to ASoC Driver guide but it doesn’t seem to find the device.
Here are they updates I’ve tried in tegra210-porg-p3448-common.dtsi:
Using i2cdetect we can see that the codec is detected on the i2c0 bus at the correct address, 0x18. I haven’t been able to find any errors pointing me in the right direction in dmesg though.
The first thing that you need to check is if the codec driver has been probed on boot. Is the codec has been probed and registered successfully, then you should see it listed under …
$ sudo cat /sys/kernel/debug/asoc/codecs
If it is not there, then check that the codec is enabled in the kernel config …
The reason I ask is that getting the codec to probe and register is usually fairly straight forward to get working, but knowing how to configure the codec is the tricky part. Once the codec is registered and you have configured device-tree, then the next thing is knowing now to configure and enable the audio route in the codec. If you refer to the codec driver [0], you will see that it provides a lot of mixer controls for configuring and enabling the audio route. This is far the most complex part of integrating an I2S codec and unless this is a codec we have used (which this is not), it is difficult to assist with this. So it can be a good idea to ask the codec vendor how to configure the Linux driver for the codec.
Yes, I’ve used this codec once before on a different SoM, it was included in their dev board and already defined in their device tree. I had to modify its routing via the driver and Alsa which worked, but this is my first time really getting into the Jetson device tree and adding a device.
It is listing as added in the kernel config, but I don’t believe I see it listed when I cat /sys/kernel/debug/asoc/codecs.
OK great. You mentioned that you are using I2C0, can you confirm that is the I2C on pins 185 and 187 of the module? If so, then that should be the gen1_i2c controller, but this is the I2C controller at address 0x7000c000.
You’re correct, I think I put the codec-dai under the wrong address. We are using pins 185 and 187 so I moved it into the i2c@7000c000 section, but it still does not seem to be detected:
I made the changes in tegra210-porg-p3448-common.dtsi and then ran the following command to rebuild:
make -C kernel/kernel-4.9/ ARCH=arm64 O=$TEGRA_KERNEL_OUT LOCALVERSION=-tegra CROSS_COMPILE=${TOOLCHAIN_PREFIX} -j8 --output-sync=target dtbs
But I did not use the “sudo ./flash.sh -r -k DTB jetson-nano-emmc mmcblk0p1” command to update the Nano. I just copied the new .dtb straight to the /boot folder.
Yes that is the problem. Please try flashing the DTB. If you look at the /boot/extlinux/extlinux.conf it does not have an FDT entry for loading the DTB from the rootfs and so the one in the DTB partition is used. That said it is possible to update the extlinux.conf to load one from /boot.
That’ll teach me to take shortcuts! It is now seeing my device tree changes and trying to setup the codec, but it is failing with the following in dmesg:
tegra-asoc: sound: ASoC: CODEC DAI tlv320-hifi not registered
tegra-asoc: sound: snd_soc_register_card failed (-517)
That error can be normal. The error code -517 means that the probing of the codec is being deferred because some dependency (clocks, resets, etc) are not available yet and will continue to retry probing it. So check the debugfs node again for the codec and see if it is there …
So I had some naming mismatches between the device tree and driver .c file. Changed tlv320-hifi to tlv320aic3x-hifi and that error disappeared. Then next I had to fix my cpu-dai-name from “I2S0” to “I2S4”, and fix the audio-routing prefixes to all "x ".
Now it is loading with no errors in dmesg and it looks like I just need to setup the routing with amixer?
Then I setup the other I2S4 field values according to the codec data sheet, as well as the ‘x ’ routing, but I’m still not getting any sound when I try to playback.
The above mixer settings should be set by default for Nano (in /usr/share/alsa/init/postinit/00-tegra.conf). It is not necessary to set the other I2S mixer controls (for channels, sample-rate, etc) as these should be configured when capture/playback start depending on the PCM format being used. These are only to override the PCM format for some more complex use-cases.
To check if the audio path is good try …
$ echo 0 | sudo tee /sys/kernel/debug/tracing/trace
$ echo 0 | sudo tee /sys/kernel/debug/tracing/events/enable
$ echo 1 | sudo tee /sys/kernel/debug/tracing/tracing_on
$ echo 1 | sudo tee /sys/kernel/debug/tracing/events/asoc/snd_soc_dapm_widget_power/enable
$ speaker-test -D hw:tegrasndt210ref,0 -c 2 -r 48000 -F S16_LE -t sine -f 500 -l 1
$ sudo cat /sys/kernel/debug/tracing/trace
Can you run the following script and send me the output?
#!/bin/bash
set -e
set -u
outfile="${HOME}/tegra-audio-debug.txt"
if [ -f "${outfile}" ]; then
rm "${outfile}"
fi
alsactl store -f "${outfile}"
dapm_dirs=$(sudo find /sys/kernel/debug/asoc -type d -name dapm)
for dir in ${dapm_dirs}; do
sudo find ${dir} -type f -exec echo {} \; -exec cat {} \; >> "${outfile}"
done
echo "Tegra audio debug info written to ${outfile}"
Please can you attach the output file because it is quite long.