Problem with audio capture in the second SGTL5000 codec using I2S Master/Slave

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with audio capture in the second SGTL5000 codec using I2S Master/Slave

4,132 Views
caiopereira
Contributor III

Hello,

 

We're developing a base board for IMX6 Colibri System On Module  - Toradex, the application will use 2 audio codecs (SGTL5000), one codec is located on the System On Module and is connected to CCM_CLKO1 (IMX6 - Solo) the other codec is located on the base board and use a 12.288 MHz clock as reference. The second clock CCM_CLKO2 will be available for the ADV7180 and could not be used to the second audio codec.

In the begin, we have a problem to detect two audio codecs at the kernel startup, the fix to this problem was write a small work around in the sgtl5000.c driver to trick the LDO detection. (We will need to fix in a better way after solve the problem).

 

 

So for we have

 

SGTL 5000 System on Module - I2S - Slave (hw:1)

SGTL 5000 Base Board - I2S Master (hw:0) (We can use as I2S Slave?)

 

 

Linux Kernel: 3.10.17

 

SGTL 5000 Base Board Connection

             

SignalPinConflictsiMX6 FunctioniMX6 Note1iMX6 Note2iMX6 ALTiMX6 Pin SoCiMX6 Pin NoteiMX6 Compatibility
DIGITAL_AUDIO_2_I2S_MASTER_DIN159 AUD3_RXD ALT4CSI0_DATA07 Possible
DIGITAL_AUDIO_2_I2S_MASTER_DOUT155 AUD3_TXD ALT4CSI0_DATA05 Possible
DIGITAL_AUDIO_2_I2S_MASTER_LRCLK157 AUD3_TXFS ALT4CSI0_DATA06 Possible
DIGITAL_AUDIO_2_I2S_MASTER_SCLK153 AUD3_TXC ALT4CSI0_DATA04 Possible
I2C_1_SCL196 I2C3_SCL ALT2GPIO03 Standard
I2C_1_SDA194 I2C3_SDA ALT2GPIO06 Standard

 

 

 

Q1: With this configuration  I can play audio without problem but I can't capture audio from mic.

For this problem, the I2S Master it's the best option?

root@colibri-imx6:~# arecord temp1.wav -D hw:0 -f S16_LE -r 32000 -d 3 (

Recording WAVE 'temp1.wav' : Signed 16 bit Little Endian, Rate 32000 Hz, Mono

arecord: pcm_read:2031: read error: Input/output error

 

root@colibri-imx6:~# dmesg | tail

[   10.543575] libphy: 2188000.ethernet:00 - Link is Up - 100/Full

[   10.549523] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

[  426.024038] mxc_v4l_open: Mxc Camera no sensor ipu0/csi1

[  437.728972] mxc_v4l_open: Mxc Camera no sensor ipu0/csi1

[  461.730192] mxc_v4l_open: Mxc Camera no sensor ipu0/csi1

[  548.943287] ALSA sound/core/pcm_lib.c:1942 playback write error (DMA or IRQ trouble?)

[  609.233298] ALSA sound/core/pcm_lib.c:1942 capture write error (DMA or IRQ trouble?)

[  627.303295] ALSA sound/core/pcm_lib.c:1942 capture write error (DMA or IRQ trouble?)

[  647.763300] ALSA sound/core/pcm_lib.c:1942 capture write error (DMA or IRQ trouble?)

[  683.513295] ALSA sound/core/pcm_lib.c:1942 capture write error (DMA or IRQ trouble?)

root@colibri-imx6:~#

 

arecord: pcm_read:2031: read error: Input/output error

root@colibri-imx6:~# arecord -D hw:0 -f S16_LE temp.wav -d 2

Recording WAVE 'temp.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono

arecord: pcm_read:2031: read error: Input/output error

root@colibri-imx6:~# arecord -D hw:0 -f S16_LE temp.wav -d 2 -r 48000

Recording WAVE 'temp.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

arecord: pcm_read:2031: read error: Input/output error

 

 

Someone could help me to fix this?

 

What I doin'g wrong? Sometimes the definition of I2S Master/Slave confuse me (depend of the reference), so some could check if the SGTL5000 connection to the IMX6 and the device tree configuration are right?

 

 

Thank you!

 

Device Tree  Modifications

 

 

&ssi1 {

    fsl,mode = "i2s-slave";

    status = "okay";

};

 

&ssi2 {

        fsl,mode = "i2s-master";

        fsl,ssi-asynchronous;

        status = "okay";

};

 

sound1 {

        compatible = "fsl,imx6-colibri-sgtl5000",

                 "fsl,imx-audio-sgtl5000";

        model = "imx6-colibri-sgtl5000";

        ssi-controller = <&ssi2>;

        audio-codec = <&codec2>; /* SGTL 5000 on base board*/

        audio-routing =

            "MIC_IN", "Mic Jack",   

            "Mic Jack", "Mic Bias",

            "Headphone Jack", "HP_OUT";

        mux-int-port = <2>;

        mux-ext-port = <3>;            

    

    };

   

    sound2 {

        compatible = "fsl,imx6-colibri-sgtl5000",

                 "fsl,imx-audio-sgtl5000";

        model = "imx6-colibri-sgtl5000";

        ssi-controller = <&ssi1>;

        audio-codec = <&codec1>;

        audio-routing =

            "MIC_IN", "Mic Jack",

            "Mic Jack", "Mic Bias",

            "Headphone Jack", "HP_OUT";

        mux-int-port = <1>;

        mux-ext-port = <5>;   

    };

 

&audmux {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_audmux_t2 &pinctrl_audmux_t1 &pinctrl_audmux_mclk_2 &pinctrl_mic_gnd

              >;

    status = "okay";

};

 

&i2c1 {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_i2c1_1>;

    status = "okay";

   

    audioclk: ext12Mhz {

        compatible = "fixed-clock";

        #clock-cells = <0>;

        clock-frequency = <12288000>;

    };

   

    codec2: sgtl5000@0a {

        compatible = "fsl,sgtl5000";

        reg = <0x0a>;       

        clocks = <&audioclk 0>;       

        VDDA-supply = <&reg_2p5v>;

        VDDIO-supply = <&reg_3p3v>;

    };

};

 

i2c2 {

    clock-frequency = <100000>;

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_i2c2_1>;

    status = "okay";

 

    codec1: sgtl5000@0a {

        compatible = "fsl,sgtl5000";

        reg = <0x0a>;

        clocks = <&clks 201>;

        VDDA-supply = <&reg_2p5v>;

        VDDIO-supply = <&reg_3p3v>;

    };

};

 

audmux {

 

        pinctrl_audmux_t1: audmux-t1 {

            fsl,pins = <

                MX6QDL_PAD_KEY_COL0__AUD5_TXC  0x130b0

                MX6QDL_PAD_KEY_ROW0__AUD5_TXD  0x130b0

                MX6QDL_PAD_KEY_COL1__AUD5_TXFS 0x130b0

                MX6QDL_PAD_KEY_ROW1__AUD5_RXD  0x130b0

            >;

        };                 

       

   

        pinctrl_audmux_t2: audmux-t2 {

            fsl,pins = <

                MX6QDL_PAD_CSI0_DAT7__AUD3_RXD  0x130b0

                MX6QDL_PAD_CSI0_DAT5__AUD3_TXD  0x130b0

                MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0

                MX6QDL_PAD_CSI0_DAT4__AUD3_TXC  0x130b0

            >;

        };

};

 

 

Thank you very much.

 

Best Regards,

 

Caio Pereira

Original Attachment has been moved to: imx6dl-colibri-eval-v7.dts.zip

Original Attachment has been moved to: imx6qdl-colibri-v7.dtsi.zip

Labels (4)
4 Replies

1,289 Views
igorpadykov
NXP Employee
NXP Employee

Hi Caio

master definition implies that it provides sync clocks, usually codec is

used as master. For such sgtl5000 configuration one can look at

boundary devices linux releases (its boards have sgtl5000)

https://boundarydevices.com/fido-release-of-yocto/

http://boundarydevices.com/audio-output-selection-under-linux-on-i-mx6/

for configuration with i.MX6 as master one can look at

http://mailman.alsa-project.org/pipermail/alsa-devel/2014-September/081417.html

Best regards

igor

0 Kudos

1,289 Views
caiopereira
Contributor III

Hello Igor,

I made the test following the http://mailman.alsa-project.org/pipermail/alsa-devel/2014-September/081417.html

But I didn't have success after the change , the codec doesn't work any more.

root@colibri-imx6:~# dmesg | grep erro
[2.361336] fsl-hdmi-dai: probe of hdmi_audio.16 failed with error -12

[   27.913285] ALSA sound/core/pcm_lib.c:1942 playback write error (DMA or IRQ trouble?)

root@colibri-imx6:~# aplay -D hw:0 Side_Left.wav -d 4

Playing WAVE 'Side_Left.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

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

root@colibri-imx6:~# arecord -D hw:0 temp0.wav -d 4 -f S16_LE                                                                                                                           

Recording WAVE 'temp0.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono

arecord: pcm_read:2031: read error: Input/output error

diff --git a/arch/arm/boot/dts/imx6qdl-colibri-v7.dtsi b/arch/arm/boot/dts/imx6qdl-colibri-v7.dtsi

index 6131947..9cc7e7a 100644

--- a/arch/arm/boot/dts/imx6qdl-colibri-v7.dtsi

+++ b/arch/arm/boot/dts/imx6qdl-colibri-v7.dtsi

@@ -137,8 +137,8 @@

                        "MIC_IN", "Mic Jack", 

                        "Mic Jack", "Mic Bias",

                        "Headphone Jack", "HP_OUT";

-               mux-int-port = <2>;

-               mux-ext-port = <3>;            

+               mux-int-port = <3>;

+               mux-ext-port = <2>;            

                //mux-int-port = <1>;

                //mux-ext-port = <5>;

        };

@@ -797,7 +797,7 @@

};

--- a/sound/soc/fsl/imx-sgtl5000.c

+++ b/sound/soc/fsl/imx-sgtl5000.c

@@ -152,7 +152,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)

        data->dai.platform_of_node = ssi_np;

        data->dai.init = &imx_sgtl5000_dai_init;

        data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |

-                           SND_SOC_DAIFMT_CBM_CFM;

+                           SND_SOC_DAIFMT_CBM_CFS;

        data->card.dev = &pdev->dev;

        ret = snd_soc_of_parse_card_name(&data->card, "model");

0 Kudos

1,289 Views
igorpadykov
NXP Employee
NXP Employee

Hi Caio

such configuration is not supported in FSL BSPs, in general one can

contact Freescale Professional Services to develop it

http://www.freescale.com/webapp/sps/site/overview.jsp?code=CW_PROFESSIONAL

Best regards

igor

0 Kudos

1,289 Views
caiopereira
Contributor III

Ok, Thank you.

0 Kudos