Two audio codecs on an i.MX6Q

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Two audio codecs on an i.MX6Q

跳至解决方案
2,608 次查看
christian_s
Contributor II

Hello community,

we are currently trying to bring up a custom i.MX6Q board with two TI TLV320AIC3106 codecs based on Linux 3.10.17.

Both codecs are I2S slaves and attached via SSI1<->AUDMUX3 and SSI2<->AUDMUX4.

I have written a machine driver and audio playback works on each of the codecs - but only when one of the two is enabled in the DT.

If I enable both codecs still only one works:

aplay -D "plughw:0,0" /some.wav

Playing WAVE '/some.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono

ALSA sound/core/pcm_lib.c:1944 playback write error (DMA or IRQ trouble?)

aplay: pcm_write:1603: write error: Input/output error

The reason for this is that I do not have any activity on any of the I2S lines of the first codec when both codecs are enabled, and I don't understand why.

Here is (the relevant part of) my DT:

/ {

        sound1 {

                compatible = "fsl,imx-audio-tlv320aic3x";

                model = "CODEC1";

                ssi-controller = <&ssi1>;

                audio-codec = <&codec1>;

                audio-routing =

                        "Microphone 1",      "LINE1L",

                        "Microphone 1",      "LINE1R",

                        "Microphone 2",      "LINE2L",

                        "Microphone 2",      "LINE2R",

                        "Piezo Loudspeaker", "LLOUT";

                mux-int-port = <1>;

                mux-ext-port = <3>;

        };

        sound2 {

                compatible = "fsl,imx-audio-tlv320aic3x";

                model = "CODEC2";

                ssi-controller = <&ssi2>;

                audio-codec = <&codec2>;

                audio-routing =

                        "Microphone 1", "LINE1L",

                        "Microphone 1", "LINE1R",

                        "Microphone 2", "LINE2L",

                        "Microphone 2", "LINE2R",

                        "Loudspeaker",  "LLOUT",

                        "Loudspeaker",  "RLOUT";

                mux-int-port = <2>;

                mux-ext-port = <4>;

        };

};

&audmux {

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_audmux_4>;

        status = "okay";

};

&i2c1 {

        clock-frequency = <100000>;

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_i2c1_2>;

        status = "okay";

        codec1: tlv320aic3x@01b {

                compatible = "ti,tlv320aic3x";

                reg = <0x01b>;

                gpio-reset = <&gpio5 18 GPIO_ACTIVE_LOW>;

        status = "okay";

        clocks = <&clks 201>;

        clock-names = "cko";

        clock-frequency = <25000000>;

       

        AVDD-supply = <&reg_audio>;

        IOVDD-supply = <&reg_audio>;

        DRVDD-supply = <&reg_audio>;

        DVDD-supply = <&reg_audio>;

        HPVDD-supply = <&reg_audio>;

        SPRVDD-supply = <&reg_audio>;

        SPLVDD-supply = <&reg_audio>;

        };

        codec2: tlv320aic3x@018 {

                compatible = "ti,tlv320aic3x";

                reg = <0x018>;

                gpio-reset = <&gpio5 18 GPIO_ACTIVE_LOW>;

        status = "okay";

        clocks = <&clks 201>;

        clock-names = "cko";

        clock-frequency = <25000000>;

       

        AVDD-supply = <&reg_audio>;

        IOVDD-supply = <&reg_audio>;

        DRVDD-supply = <&reg_audio>;

        DVDD-supply = <&reg_audio>;

        HPVDD-supply = <&reg_audio>;

        SPRVDD-supply = <&reg_audio>;

        SPLVDD-supply = <&reg_audio>;

        };

};

&iomuxc {

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_audmux_4>;

    audmux {

        pinctrl_audmux_4: audmux-4 {

            fsl,pins = <

                                MX6QDL_PAD_SD2_DAT0__AUD4_RXD  0x130b0

                                MX6QDL_PAD_SD2_DAT3__AUD4_TXC  0x130b0

                                MX6QDL_PAD_SD2_DAT2__AUD4_TXD  0x110b0

                                MX6QDL_PAD_SD2_DAT1__AUD4_TXFS 0x130b0

                                MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0

                                MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0

                                MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x110b0

                                MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0

            >;

        };

    };

};

&ssi1 {

        fsl,mode = "i2s-master";

        status = "okay";

};

&ssi2 {

        fsl,mode = "i2s-master";

        status = "okay";

};

As said: If i disable sound1, sound2 will work and vice versa. Both active, only sound2 will work.

Does anybody have an idea what I might be missing?

Thanks in advance!

Chris

标签 (3)
0 项奖励
1 解答
1,459 次查看
christian_s
Contributor II

I was able to solve it.

It was a two part problem:

a) The machine driver I used as template for my own didn't handle being loaded multiple times very well. I rewrote it, which resolved the blocking issue.

However after that, I still couldn't play back audio from both codecs. As soon as I started interacting with the second codec, playback from the first one would stop. This was caused by

b) By hardware design both codecs on our board share the same reset GPIO. The codec driver performed a hardware reset on every playback/capture start event resetting the other codec

在原帖中查看解决方案

0 项奖励
6 回复数
1,459 次查看
nguyenanhduc
Contributor I

Dear Chris,

Currently I am trying to develop a similar system with 2 audios connected to the i.mx6 through 2 SSI (AUD3, AUD5) which must comply with ALSA architecture. I have used wandboard and some extra hardware for my tests.

If possible, could you please help me to tackle the problem, i would appreciate it much.

With best regards,

0 项奖励
1,460 次查看
christian_s
Contributor II

I was able to solve it.

It was a two part problem:

a) The machine driver I used as template for my own didn't handle being loaded multiple times very well. I rewrote it, which resolved the blocking issue.

However after that, I still couldn't play back audio from both codecs. As soon as I started interacting with the second codec, playback from the first one would stop. This was caused by

b) By hardware design both codecs on our board share the same reset GPIO. The codec driver performed a hardware reset on every playback/capture start event resetting the other codec

0 项奖励
1,018 次查看
divyeshmarne0
Contributor III

Hi chrish,

did u solve this issue?

0 项奖励
1,459 次查看
sinanakman
Senior Contributor III

Hi Chris

Can you run a i2cdetect -l to see if both devices get

listed ?

Regards

Sinan Akman

0 项奖励
1,459 次查看
christian_s
Contributor II

Yes, I can detect, read from/write to both devices.

Also I just noticed, that the same thing happens when I activate my S/PDIF interface. Only when both TI codecs are disabled, I can work with S/PDIF.

I think I'm blocking something somewhere as soon as I have activated one audio device.

0 项奖励
1,459 次查看
christian_s
Contributor II

Sorry. Please ignore my S/PDIF comment. S/PDIF does work fine. Only the audio codecs are blocking each other

0 项奖励