I am trying to test the TLV320DAC3100EVM-U kit with IMX93QS93 Linux board. I am able to detect it know as you can see here:
root@qs93-5210:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: tlv320aic31xxco [tlv320aic31xx-codec], device 0: 443b0000.sai-tlv320dac31xx-hifi tlv320dac31xx-hifi-0 [443b0000.sai-tlv320dac31xx-hifi tlv320dac31xx-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
and,
root@qs93-5210:~# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
sysdefault:CARD=tlv320aic31xxco
tlv320aic31xx-codec, 443b0000.sai-tlv320dac31xx-hifi tlv320dac31xx-hifi-0
Default Audio Device
- But when I tried to aplay sine wave I got the following errors:
root@qs93-5210:~# speaker-test -D plughw:0,0 -c 2 -r 48000 -F S16_LE -t sine -f 500
speaker-test 1.2.8
Playback device is plughw:0,0
Stream parameters are 48000[ 247.600154] tlv320aic31xx-codec 1-0018: aic31xx_setup_pll: Sample rate (48000) and format not supported
Hz, S16_LE, 2 ch[ 247.610738] tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_dai_hw_params on tlv320dac31xx-hifi: -22
annels
Sine wave[ 247.621511] 443b0000.sai-tlv320dac31xx-hifi: ASoC: error at __soc_pcm_hw_params on 443b0000.sai-tlv320dac31xx-hifi: -22
rate is 500.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 131072
Period size range from 16 to 8184
Using max buffer size 131072
Periods = 4
Unable to set hw params for playback: Invalid argument
Setting of hwparams failed: Invalid argument
- I've seen this related kernel messages as well:
alsa-lib /usr/src/debug/alsa-lib/1.2.8-r0/src/ucm/main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
No state is present for card tlv320aic31xxco
alsa-lib /usr/src/debug/alsa-lib/1.2.8-r0/src/ucm/main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
Found hardware: "simple-card" "" "" "" ""
Hardware is initialized using a generic method
- Here it is my device tree :
audio_clk: audio-clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12288000>;
};
codec_audio: sound {
compatible = "simple-audio-card";
simple-audio-card,name = "tlv320aic31xx-codec";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
"Line", "Line Out",
"Headphone", "Headphone Jack",
"Speaker", "Speaker Out";
simple-audio-card,routing =
"Line In", "AIN1", // Line input route
"Line Out", "HPL", // Line out to left headphone
"Line Out", "HPR", // Line out to right headphone
"Headphone Jack", "HPL",
"Headphone Jack", "HPR";
status = "okay";
cpu_dai: simple-audio-card,cpu {
sound-dai = <&sai1>;
};
codec_dai: simple-audio-card,codec {
sound-dai = <&audio_codec>;
clocks = <&audio_clk>;
};
};
};
&sai1 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai1>;
status = "okay";
assigned-clocks = <&clk IMX93_CLK_SAI1>;
assigned-clock-parents = <&clk IMX93_CLK_AUDIO_PLL>;
assigned-clock-rates = <12288000>;
clocks = <&clk IMX93_CLK_SAI1_IPG>,
<&clk IMX93_CLK_AUDIO_PLL>,
<&clk IMX93_CLK_DUMMY>, <&clk IMX93_CLK_DUMMY>,
<&clk IMX93_CLK_AUDIO_PLL>;
clock-names = "bus", "mclk1", "mclk2", "mclk3", "pll";
};
&lpi2c2 {
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpi2c2>;
status = "okay";
// Add TLV320AIC3100 audio codec node
audio_codec: codec@18 {
compatible = "ti,tlv320dac3100";
pinctrl-names = "default";
reg = <0x18>;
#sound-dai-cells = <0>;
reset-gpio = <&gpio4 9 GPIO_ACTIVE_LOW>;
HPVDD-supply = <®_vdd_3v3>;
AVDD-supply = <®_vdd_3v3>;
DVDD-supply = <®_vref_1v8>;
IOVDD-supply = <®_vdd_3v3>;
SPRVDD-supply = <®_vdd_3v3>;
SPLVDD-supply = <®_vdd_3v3>;
status = "okay";
};
};
I am struggling to make this work, could anyone help me out with this?
Update:
- I just updated the device tree like you can see:
reg_audio_pwr_5v: regulator-audio-pwr_5v {
compatible = "regulator-fixed";
regulator-name = "audio-pwr";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
enable-active-high;
regulator-always-on;
};
reg_audio_pwr_3v3: regulator-audio-pwr_3v3 {
compatible = "regulator-fixed";
regulator-name = "audio-pwr";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
regulator-always-on;
};
reg_audio_pwr_1v8: regulator-audio-pwr_1v8 {
compatible = "regulator-fixed";
regulator-name = "audio-pwr";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
enable-active-high;
regulator-always-on;
};
audio_clk: audio-clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <12288000>;
};
codec_audio: sound {
compatible = "simple-audio-card";
simple-audio-card,name = "tlv320dac3100-codec";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&cpu_dai>;
simple-audio-card,frame-master = <&cpu_dai>;
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Line", "Line In",
"Line", "Line Out",
"Headphone", "Headphone Jack",
"Speaker", "Speaker Out";
simple-audio-card,routing =
"Mic Jack", "MICBIAS",
"Line In", "AIN1",
"Line Out", "HPL",
"Line Out", "HPR",
"Headphone Jack", "HPL",
"Headphone Jack", "HPR";
status = "okay";
cpu_dai: simple-audio-card,cpu {
sound-dai = <&sai1>;
};
codec_dai: simple-audio-card,codec {
sound-dai = <&audio_codec>;
};
};
};
&sai1 {
#sound-dai-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai1>;
assigned-clocks = <&clk IMX93_CLK_SAI1>;
assigned-clock-parents = <&clk IMX93_CLK_AUDIO_PLL>;
assigned-clock-rates = <12288000>;
fsl,sai-mclk-direction-output;
status = "okay";
};
&lpi2c2 {
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpi2c2>;
scl-gpios = <&gpio1 2 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
sda-gpios = <&gpio1 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
status = "okay";
// Add TLV320AIC3100 audio codec node
audio_codec: codec@18 {
compatible = "ti,tlv320dac3100";
pinctrl-names = "default";
reg = <0x18>;
#sound-dai-cells = <0>;
ai31xx-micbias-vg = <MICBIAS_2_5V>;
reset-gpio = <&gpio4 9 GPIO_ACTIVE_LOW>;
HPVDD-supply = <®_audio_pwr_3v3>;
AVDD-supply = <®_audio_pwr_3v3>;
DVDD-supply = <®_audio_pwr_1v8>;
IOVDD-supply = <®_audio_pwr_3v3>;
SPRVDD-supply = <®_audio_pwr_5v>;
SPLVDD-supply = <®_audio_pwr_5v>;
SPKVDD-supply = <®_audio_pwr_5v>;
clocks = <&audio_clk>;
};
};
And playing sine wave seems to be working with (480kHz, 441KHz), as there are no error in output, But not the case for (48kHz).
speaker-test -D plughw:0,0 -r 480000 -F S16_LE -t sine -f 500
speaker-test 1.2.8
Playback device is plughw:0,0
Stream parameters are 480000Hz, S16_LE, 1 channels
Sine wave rate is 500.0000Hz
Rate set to 480000Hz (requested 480000Hz)
Buffer size range from 80 to 327680
Period size range from 39 to 20460
Using max buffer size 327680
Periods = 4
was set period_size = 10240
was set buffer_size = 327680
0 - Front Left
Time per period = 2.344742
0 - Front Left
Time per period = 2.986622
0 - Front Left
Time per period = 2.986579
0 - Front Left
Time per period = 2.986168
0 - Front Left
Time per period = 2.987078
0 - Front Left
Time per period = 2.986581
0 - Front Left
root@qs93-5210:~# speaker-test -D plughw:0,0 -r 48000 -F S16_LE -t sine -f 500
speaker-test 1.2.8
Playback device is plughw:0,0
Stream para[ 614.702723] tlv320aic31xx-codec 1-0018: aic31xx_setup_pll: Sample rate (48000) and format not supported
meters are 48000H[ 614.712523] tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_dai_hw_params on tlv320dac31xx-hifi: -22
z, S16_LE, 1 chan[ 614.723375] 443b0000.sai-tlv320dac31xx-hifi: ASoC: error at __soc_pcm_hw_params on 443b0000.sai-tlv320dac31xx-hifi: -22
nels
Sine wave rate is 500.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 131072
Period size range from 16 to 8184
Using max buffer size 131072
Periods = 4
Unable to set hw params for playback: Invalid argument
Setting of hwparams failed: Invalid argument
And I still have this kernel messages when Linux starts :
alsa-lib /usr/src/debug/alsa-lib/1.2.8-r0/src/ucm/main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
No state is present for card tlv320dac3100co
alsa-lib /usr/src/debug/alsa-lib/1.2.8-r0/src/ucm/main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -2
Found hardware: "simple-card" "" "" "" ""
Hardware is initialized using a generic method
No state is present for card tlv320dac3100co
What could be the problem here and the clock frequency is set to 12,288MHz (multiple of 48kHz) ?
Thank you for your support.
I am currently using the official Linux kernel driver for the TLV320AIC31xx audio codec, as provided by the kernel maintainers. It supposed to work fine for my codec, but I will try to use the third party Linux driver and see.
- I double checked the CODEC voltage and seem to be correct.
- The clocks should be configured as expected but I might be wrong in something.
- No, I am not seeing any thing related to audio mapping --> ok.
Hello,
Hope you are doing well; I will be working in your support case.
The TLV320DAC3100 audio CODEC is not supported by default on our BSP. To use this CODEC to your system, you need to add a third-party driver provided by Texas Instruments and configure your device tree.
Unfortunately, there is not a guide to port this specific CODEC to the BSP. The references we have are the i.MX porting guide and EVK device tree (WM8962).
I see that you are using the simple audio card provided by Linux as the Machine driver. I don't recommend customers to do this and try with TI driver.
Here some debugging recommendations:
Best regards.