This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x sgtl5000 support

Dear All,

I'm facing a problem with the integration of a sgtl5000 codec on our custom AM335x hardware. We're using linux kernel 3.12.10. 

Playing a wave file or speaker-test is possible and works as expected. What goes wrong is the recording of the line in signal. Calling "arecord -f cd test.wav" produces an empty file although I have set the controls for recording via alsamixer (capture volume = max, capture source=LINE_IN). Unfortunatelly no error messages were displayed.

Any help would be appreciated.

Here are our modifications to the *.dts-file:

// Pinmuxing
mcasp0_pins: mcasp0_pins {
	pinctrl-single,pins = <
		0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_aclkx.mcasp0_aclkx */
		0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_fsx.mcasp0_fsx */
		0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr0.mcasp0_axr0 */
		0x1a8 (PIN_INPUT_PULLDOWN | MUX_MODE0) /* mcasp0_axr1.mcasp0_axr1 */
	>;
};

codec_pins: codec_pins {
	pinctrl-single,pins = <
		0x1b0 (PIN_OUTPUT | MUX_MODE3) /* xdma_event_intr0.clkout1 */
	>;
};

...

// Sound
sound {
	compatible = "ti,sgtl5000";
	ti,model = "SGTL5000";
	ti,audio-codec = <&sgtl5000>;
	ti,mcasp-controller = <&mcasp0>;
	ti,codec-clock-rate = <24000000>;
	ti,audio-routing =
		"Headphone Jack",       "HPLOUT",
		"Headphone Jack",       "HPROUT",
		"LINE1L",               "Line In",
		"LINE1R",               "Line In";
};

...

// I2C
sgtl5000: sgtl5000@0a {
	compatible = "fsl,sgtl5000";
	reg = <0x0a>;
	status = "okay";

	pinctrl-names = "default";
	pinctrl-0 = <&codec_pins>;

	clocks = <&clk_24mhz>;

	VDDA-supply = <&vaux33_reg>;
	VDDIO-supply = <&vaux33_reg>;
	VDDD-supply = <&vaux33_reg>;
};

...
//MCASP &mcasp0 { pinctrl-names = "default"; pinctrl-0 = <&mcasp0_pins>; status = "okay"; op-mode = <0>; /* MCASP_IIS_MODE */ tdm-slots = <2>; /* 4 serializer */ serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ 2 1 0 0 >; tx-num-evt = <1>; rx-num-evt = <1>; };

Furthermore we've changed the davinci-evm.c:

static struct snd_soc_dai_link evm_dai_sgtl5000 = {
	.name      = "sgtl5000",
	.stream_name = "SGTL5000",
	.codec_dai_name = "sgtl5000",
	.ops        = &evm_ops,
	.dai_fmt    = (SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_I2S |
		       SND_SOC_DAIFMT_IB_NF),
};

...

static const struct of_device_id davinci_evm_dt_ids[] = {
	{
		.compatible = "ti,da830-evm-audio",
		.data = &evm_dai_tlv320aic3x,
	},
	{
		.compatible = "ti,am33xx-beaglebone-black",
		.data = &evm_dai_tda998x_hdmi,
	},
	{
		.compatible = "ti,dra7xx-evm-audio",
		.data = (void *) &dra7xx_evm_link,
	},
	{
		.compatible = "ti,am43xx-epos-evm-audio",
		.data = &evm_dai_tlv320aic3111,
	},
	{
		.compatible = "ti,sgtl5000",
		.data = &evm_dai_sgtl5000,
	},
	{ /* sentinel */ }
};

Here is the output from dmesg:

# dmesg | grep -i sgtl

[    1.815346] sgtl5000 0-000a: sgtl5000 revision 0x11

[    1.912585] sgtl5000 0-000a: Using internal LDO instead of VDDD

[    1.928645] davinci_evm sound.3:  sgtl5000 <-> 48038000.mcasp mapping ok

This is how we connected the codec:

  • I will ask the software team to look at this.
  • Hi,

    Does this happen with all formats:
    S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE

    or just the one specified above: -f S16_LE -c2 -r44100?

    Have you tried using a different configuration for .dai_fmt in snd_soc_dai_link evm_dai_sgtl5000 stucture? I've seen reports of this being the problem with new codec integration.

    Best Regards,
    Yordan
  • Hi Biser, Hi Yordan,

    Thanks for your replies. It happened with all formats. But now I've found the problem. We'll need stereo capturing for our project, so I have always captured the line in signal on the left line in channel and measured the left output channel. Yesterday I have take a closer look at the *.wav-file and it was correct recorded. The problem is that the aplay command seems to swap the output channels so that the output sine signal is on the right channel. I guess this could be caused by the wrong frame clock. Maybe it needs to be inverted. Today I will try to change SND_SOC_DAIFMT_IB_NF to SND_SOC_DAIFMT_IB_IF or SND_SOC_DAIFMT_NB_IF.

    I will let you know, if this fixes the issue.

    Best Regards,

    Sascha

      

  • Hi,

    I've played around with the dai_fmt-flags. Unfortunatelly I was not able to fix the swapped line out channels.

    During the evaluation of the codec in a SIP client application, we've found out that there is another problem where I don't have any ideas on how to fix it. When we are playing the recorded line in signal on the line out in "real time" (arecord | aplay) there are hearable cracking sounds present. We haven't seen this issue if we are recording and playing a wav file sequentially.

    Maybe someone can help me.