Error connecting audio codec MAX98357A to iMX6

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

Error connecting audio codec MAX98357A to iMX6

Jump to solution
392 Views
marcelomjr
Contributor I

Hello, I'm using the iMX6 processor (VAR SOM SOLO from Variscite) and I'm trying to use the codec MAX98357A to play audios.

In the project, my custom board is using the AUD4 port to connect to the codec, so I'm using the device tree bellow for that.

After building the linux with Yocto and running the Linux I can see the card board that I created, but when I try to set the volume or use the audio controls they aren't available.

root@var-som-mx6:~#  cat /proc/asound/cards
0 [max98357a      ]: simple-card - max98357a
                      max98357a

Someone could me help to check if I am doing something wrong in the device tree, please?

 

 

/ {
	model = "Variscite i.MX6 DL/Solo SOM-SOLO SOM-DUAL SoloCustomBoard";
	dts-version = "2.0.19";

	extcodec: max98357a@0 {
        compatible = "maxim,max98357a";
		status = "okay";
        #sound-dai-cells = <0>;
    };

	 sound {
        compatible = "simple-audio-card";
        simple-audio-card,name = "max98357a";
        simple-audio-card,format = "i2s";
        simple-audio-card,widgets = "Speaker", "Speakers";
        simple-audio-card,routing = "Speakers", "Speaker";
        simple-audio-card,bitclock-master = <&cpu_dai>;
        simple-audio-card,frame-master = <&cpu_dai>;
        cpu_dai: simple-audio-card,cpu {
            sound-dai = <&ssi1>;
			system-clock-frequency = <883200>;
            dai-tdm-slot-num = <2>;
            dai-tdm-slot-width = <16>;
        };
        codec_dai: simple-audio-card,codec {
            sound-dai = <&extcodec>;
        };
    };

	soc {
		hdmi_audio@120000 {
			status = "disabled";
		};
	};
};


&audmux {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_audmux4>;

	ssi1 {
		fsl,audmux-port = <MX31_AUDMUX_PORT1_SSI0>;
		fsl,port-config = <
			0x00000000
			IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT4_SSI_PINS_4)
		>;
	};
	
	aud4 {
		fsl,audmux-port = <MX31_AUDMUX_PORT4_SSI_PINS_4>;
		fsl,port-config = <
			(IMX_AUDMUX_V2_PTCR_TFSDIR |
			IMX_AUDMUX_V2_PTCR_TFSEL(MX31_AUDMUX_PORT1_SSI0) |
			IMX_AUDMUX_V2_PTCR_TCLKDIR |
			IMX_AUDMUX_V2_PTCR_TCSEL(MX31_AUDMUX_PORT1_SSI0))
			IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0)
		>;
	};
};

&ssi1 {
      fsl,mode = "i2s-master";
      assigned-clocks = <&clks IMX6QDL_CLK_SSI1_SEL>, <&clks IMX6QDL_CLK_SSI1>;
      assigned-clock-parents = <&clks IMX6QDL_CLK_PLL4_AUDIO_DIV>;
      assigned-clock-rates = <0>, <49152000>; // 48kHz on SSI1 clock
      status = "okay";    
};

&iomuxc {
	imx6qdl-var-som-mx6 {
		pinctrl_audmux4: audmux4grp {
			fsl,pins = <
				MX6QDL_PAD_DISP0_DAT20__AUD4_TXC  0x130b0
				MX6QDL_PAD_DISP0_DAT21__AUD4_TXD  0x110b0
				MX6QDL_PAD_DISP0_DAT22__AUD4_TXFS 0x130b0
				MX6QDL_PAD_DISP0_DAT23__AUD4_RXD  0x130b0
			>;
		};
	};
};

 

 

 I can't set the volume or use another amixer commands:

 

 

root@var-som-mx6:~# amixer set PCM 127
amixer: Unable to find simple control 'PCM',0

 

 

The command "amixer scontrols" returns nothing and the alsamixer shows " This sound device does not have any controls".

 

 

root@var-som-mx6:~# amixer scontrols                                                                                                                                                                        
root@var-som-mx6:~#

 

 

 

Labels (1)
0 Kudos
Reply
1 Solution
304 Views
Manuel_Salas
NXP TechSupport
NXP TechSupport

Hello @marcelomjr 

I hope you are doing very well.

 

I appears the MAX98357A is a digital amplifier, not a typical audio codec. It does not support hardware mixers or volume controls. It just takes I2S in and blasts it out to the speaker.

So:

amixer: Unable to find simple control 'PCM',0
alsamixer: This sound device does not have any controls

It is expected behavior.

 

You can try to use alsamixer with a virtual control for example softvol plugin.

# /etc/asound.conf or ~/.asoundrc

pcm.softvol {
    type softvol
    slave.pcm "plughw:0"
    control {
        name "SoftVolume"
        card 0
    }
}

Then try to adjust volume:

$ amixer -D softvol set SoftVolume 50%

 

I hope this can helps to you.

 

Best regards,

Salas.

 

View solution in original post

2 Replies
305 Views
Manuel_Salas
NXP TechSupport
NXP TechSupport

Hello @marcelomjr 

I hope you are doing very well.

 

I appears the MAX98357A is a digital amplifier, not a typical audio codec. It does not support hardware mixers or volume controls. It just takes I2S in and blasts it out to the speaker.

So:

amixer: Unable to find simple control 'PCM',0
alsamixer: This sound device does not have any controls

It is expected behavior.

 

You can try to use alsamixer with a virtual control for example softvol plugin.

# /etc/asound.conf or ~/.asoundrc

pcm.softvol {
    type softvol
    slave.pcm "plughw:0"
    control {
        name "SoftVolume"
        card 0
    }
}

Then try to adjust volume:

$ amixer -D softvol set SoftVolume 50%

 

I hope this can helps to you.

 

Best regards,

Salas.

 

180 Views
marcelomjr
Contributor I

Hello @Manuel_Salas, this configuration worked, thank you very much!

The only thing I did different to work was use this command to change the volume:

amixer -c 0 sset 'SoftVolume' 50%

 

Best regards,

Marcelo Martimiano