TLV320AIC3106: m_read:2221: read error: Input/output error
Closed this issue · 6 comments
I'd like to share my problem when I moved device tree and kernel from linux 4.14 to 5.15.
I'm using am335xx as base and have TLV320AIC3106 codec. Previously I was using yocto dunfell with kernel 4.14 I didn't have any problem with these device tree configurations.
/{
...
regulators {
compatible = "simple-bus";
vcc3v3: fixedregulator@1 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
};
sound {
compatible = "ti,da830-evm-audio";
ti,model = "AM335x-EVM";
ti,audio-codec = <&audio_codec>;
ti,mcasp-controller = <&mcasp0>;
ti,codec-clock-rate = <12000000>;
ti,audio-routing =
"LINE1L", "Line In",
"LINE2L", "Line In",
"LINE1R", "Line In",
"LINE2R", "Line In";
clocks = <&mcasp0_fck>;
clock-names = "mclk";
};
};
&i2c0 {
audio_codec: tlv320aic3106@18 {
compatible = "ti,tlv320aic3106";
reg = <0x18>;
ai3x-micbias-vg = <0x0>;
status = "okay";
};
};
&am33xx_pinmux {
audio_pins: pinmux_audio {
pinctrl-single,pins = <
AM33XX_IOPAD(0x9AC, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_ahclkx.mcasp0_ahclkx */
AM33XX_IOPAD(0x990, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx */
AM33XX_IOPAD(0x994, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx */
AM33XX_IOPAD(0x998, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 */
AM33XX_IOPAD(0x9A8, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1.mcasp0_axr1 */
>;
};
};
&mcasp0 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
op-mode = <0>; /* MCASP_ISS_MODE */
tdm-slots = <2>;
serial-dir = <
2 1 0 0
>;
tx-num-evt = <2>;
rx-num-evt = <2>;
};
...
and I can use aplay in order to capture sounds
# aplay -vvv -C -D hw:0,0 -r 16000 -f S16_LE -c 2 /tmp/a.wav
Recording WAVE '/tmp/a.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
Hardware PCM card 0 'AM335x-EVM' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 16000
exact rate : 16000 (16000/1)
msbits : 16
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
appl_ptr : 0
hw_ptr : 0
Max peak (4000 samples): 0x000000d0 # 0%
Max peak (4000 samples): 0x000000f1 # 0%
Max peak (4000 samples): 0x000000d4 # 0%
Max peak (4000 samples): 0x000000d6 # 0%
Max peak (4000 samples): 0x000000db # 0%
Max peak (4000 samples): 0x000000d2 # 0%
Max peak (4000 samples): 0x0000017d # 1%
Max peak (4000 samples): 0x0000013e # 0%
Max peak (4000 samples): 0x00000154 # 1%
Max peak (4000 samples): 0x00000149 # 1%
Max peak (4000 samples): 0x00000160 # 1%
lsmod:
~# lsmod
Module Size Used by
cn 16384 1
snd_soc_evm 16384 1
snd_soc_davinci_mcasp 24576 2
snd_soc_tlv320aic3x 49152 1
snd_soc_edma 16384 1 snd_soc_davinci_mcasp
snd_soc_omap 16384 1 snd_soc_davinci_mcasp
snd_soc_core 118784 5 snd_soc_davinci_mcasp,snd_soc_edma,snd_soc_evm,snd_soc_omap,snd_soc_tlv320aic3x
snd_pcm_dmaengine 16384 2 snd_soc_omap,snd_soc_core
snd_pcm 81920 6 snd_soc_davinci_mcasp,snd_pcm_dmaengine,snd_soc_omap,snd_soc_core,snd_soc_tlv320aic3x
snd_timer 28672 1 snd_pcm
snd 49152 4 snd_timer,snd_soc_core,snd_pcm
soundcore 16384 1 snd
cpufreq_dt 16384 0
cryptodev 45056 0
- The things are changed when we tried to use latest simple-audio-card driver.
\ {
regulators {
compatible = "simple-bus";
vcc3v3: fixedregulator@1 {
compatible = "regulator-fixed";
regulator-name = "vcc3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
};
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "snd-ddi";
simple-audio-card,widgets =
"Line", "Line In";
simple-audio-card,routing =
"LINE1L", "Line In",
"LINE2L", "Line In",
"LINE1R", "Line In",
"LINE2R", "Line In";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound_codec>;
simple-audio-card,frame-master = <&sound_codec>;
simple-audio-card,mclk-fs = <32>;
sound_cpu: simple-audio-card,cpu {
sound-dai = <&mcasp0>;
};
sound_codec: simple-audio-card,codec {
sound-dai = <&tlv320aic3106>;
clocks = <&mcasp0_fck>;
};
};
};
&i2c0 {
tlv320aic3106: tlv320aic3106@18 {
#sound-dai-cells = <0>;
compatible = "ti,tlv320aic3106";
reg = <0x18>;
status = "okay";
/* Regulators */
AVDD-supply = <&vcc3v3>;
IOVDD-supply = <&vcc3v3>;
DRVDD-supply = <&vcc3v3>;
DVDD-supply = <&vdig1_reg>;
};
};
&vdig1_reg {
regulator-boot-on;
regulator-always-on;
};
&mcasp0 {
#sound-dai-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&mcasp0_pins>;
op-mode = <0>; /* MCASP_ISS_MODE */
tdm-slots = <2>;
serial-dir = <
2 1 0 0
>;
tx-num-evt = <2>;
rx-num-evt = <2>;
};
for this dts, I always get pcm_read error
~# lsmod
Module Size Used by
snd_soc_simple_card 16384 1
snd_soc_simple_card_utils 20480 1 snd_soc_simple_card
snd_soc_davinci_mcasp 28672 2
snd_soc_ti_udma 16384 1 snd_soc_davinci_mcasp
snd_soc_ti_edma 16384 1 snd_soc_davinci_mcasp
snd_soc_ti_sdma 16384 1 snd_soc_davinci_mcasp
snd_soc_tlv320aic3x_i2c 16384 1
snd_soc_tlv320aic3x 53248 1 snd_soc_tlv320aic3x_i2c
snd_soc_core 147456 7 snd_soc_davinci_mcasp,snd_soc_simple_card_utils,snd_soc_ti_sdma,snd_soc_ti_edma,snd_soc_tlv320aic3x,snd_soc_ti_udma,snd_soc_simple_card
snd_pcm_dmaengine 16384 1 snd_soc_core
snd_pcm 94208 5 snd_soc_davinci_mcasp,snd_pcm_dmaengine,snd_soc_core,snd_soc_tlv320aic3x
snd_timer 28672 1 snd_pcm
snd 57344 4 snd_timer,snd_soc_core,snd_pcm
soundcore 16384 1 snd
cfg80211 307200 0
cpufreq_dt 16384 0
~# aplay -vvv -C -D hw:0,0 -r 16000 -f S16_LE -c 2 /tmp/a.wav
Recording WAVE '/tmp/a.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Stereo
Hardware PCM card 0 'snd-ddi' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 16000
exact rate : 16000 (16000/1)
msbits : 16
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
appl_ptr : 0
hw_ptr : 0
arecord: pcm_read:2221: read error: Input/output error
What do you suggest in order to investigate problem and solve it? I used here as reference: https://git.phytec.de/linux-mainline/tree/arch/arm/boot/dts/am335x-wega.dtsi?h=v5.15.82-phy
Hello Hasan,
there have been some changes in the regulator framework and regulators should be put in the root node without the "regulators" subnode ("/"). But I don't think that has any impact on your issue.
What is providing the clocks on your hardware, the codec or the mcasp?
Hi @dominiknh90 , I did some measurements on HW and it seems clock is not driven.
mcasp is providing clock
If the codec is providing both bitclock and wordclock you'll need a simple-card configured like this with the mcasp as clock provider:
(I configured our Wega board like this and it needs simple-audio-card,mclk-fs = <512>;)
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "snd-ddi";
simple-audio-card,widgets =
"Line", "Line In";
simple-audio-card,routing =
"LINE1L", "Line In",
"LINE2L", "Line In",
"LINE1R", "Line In",
"LINE2R", "Line In";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&sound_cpu>;
simple-audio-card,frame-master = <&sound_cpu>;
simple-audio-card,mclk-fs = <512>;
sound_cpu: simple-audio-card,cpu {
sound-dai = <&mcasp0>;
};
sound_codec: simple-audio-card,codec {
sound-dai = <&tlv320aic3106>;
};
};
I'm able to record some data with your change but I see recoded data is not similar with previous dts source.
May I ask why you choose simple-audio-card,mclk-fs = <512>;
and removed clocks = <&mcasp0_fck>;
since it's part of old device tree.
I'm also attaching audio-codec schema to have more information about codec&clock
I'm able to record some data with your change but I see recoded data is not similar with previous dts source.
May I ask why you choose
simple-audio-card,mclk-fs = <512>;
and removedclocks = <&mcasp0_fck>;
since it's part of old device tree.
So in our setup the mcasp provides the bitclock and the wordclock. I2S_MCLK is not used.So there is no need to add the mcasp clock to the codec node because the codec doesn't do anything with the mcasp clock.
simple-audio-card,mclk-fs = <512>; was just the value I needed in order to get the right clock for the sample rate.
Your setup looks similar to our Wega board but you still might have to adjust some values in the devicetree.
Thanks again @dominiknh90 , I'm closing this issue after your valuable responses. We'll try to adjust mclk-fs value in order to get right sample rate.