cancel
Showing results for 
Search instead for 
Did you mean: 

Help in creating a simple soundcard with I2S (or SAI if necessary)

AJank.2
Associate III

Hi,

I'm working on creating a simple soundcard with a simple codec called pcm5102a which is a part of the kernel source. My board is the STM32MP135F-DK. I2S seems to be enough for this purpose however if you think that SAI will work better, then I'll take advice on that happily as well.

The current configuration is as in the attached audio_test.zip with I2S1 enabled and SPI1 Clock Mux set to PLL3Q instead of the default PLL4P (all set in the STM32CubeMX). The configuration is inserted into the build with a new machine and it does build without any problems. It's only after the boot that aplay -l doesn't list any soundcards, moreover below message is visible in the dmesg output:

 

 

[    3.600504] st,stm32-i2s 44004000.audio-controller: Could not get x8k parent clock: -2
[    3.607136] st,stm32-i2s: probe of 44004000.audio-controller failed with error -2

 

 

I read that the x8k is one of the clocks necessary for audio handling, however can't figure out how to fix that.

Below are the most important parts regarding the soundcard configuration:

 

 

/ {    sound {
        compatible = "audio-graph-card";
        label = "STM32MP1-audio-test-card";
        routing =
            "Playback" , "MCLK"; /* Set a route between "MCLK" and "playback" DAPM widgets */
        dais = <&i2s1_port>;
        status = "okay";
    };
};

&i2s1{
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&i2s1_pins_mx>;
	pinctrl-1 = <&i2s1_sleep_pins_mx>;
	status = "okay";

	/* USER CODE BEGIN i2s1 */
    #clock-cells = <0>;
    clocks = <&rcc SPI1>, <&rcc SPI1_K>, <&rcc PLL3_Q>, <&rcc PLL3_R>;
    clock-names = "pclk", "i2sclk", "x8k", "x11k";
    #sound-dai-cells = <1>;

	i2s1_port: port {
        #address-cells = <1>;
        #size-cells = <0>;
		i2s1_endpoint: endpoint {
            system-clock-frequency = <48000>;
            system-clock-direction-out;
            frame-master;
            bitclock-master;
			format = "i2s";
			mclk-fs = <256>;
            remote-endpoint = <&codec_endpoint>;
		};
	};

    codec: pcm5102a {
        compatible = "ti,pcm5102a";
        #sound-dai-cells = <0>;
        clocks = <&i2s1>;     /* The codec is a consumer of I2S2 master clock */
        clock-names = "MCLK"; /* Feed MCLK codec clock with I2S2 master clock provider */

        codec_port: pcm5102a_port {
            codec_endpoint: endpoint{
                remote-endpoint = <&i2s1_endpoint>;
            };
        };
    };
	/* USER CODE END i2s1 */
};

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@AJank.2 ,
Well it is going forward !

I am not an audio expert, but if I remember well, I think that the additional DPAM Widget needs to be declared inside the codecs driver. In your case for example it should be something like:

static const struct snd_soc_dapm_widget aic31xx_dapm_mclk_widgets[] = {
	SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, mclk_event,
			    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
};

If you want a reference taken by ST, you can take a look at the cirrus,cs42l51 codecs driver.

I hope that it will help you.
Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

19 REPLIES 19
AJank.2
Associate III

I search the forum and found this post where it's advised to use below clock configuration instead:

clocks = <&rcc SPI1>, <&rcc SPI1_K>, <&scmi_clk CK_SCMI_PLL3_Q>, <&scmi_clk CK_SCMI_PLL3_R>;

 This operation seems to fix the x8k parent clock problem, however a list of new messages appeared in dmesg and aplay keeps returning empty list.

root@stm32mp13-audiotest:~# dmesg | grep audio
[    3.601263] st,stm32-i2s 44004000.audio-controller: No cache defaults, reading back from HW
[    3.888307] st,stm32-i2s 44004000.audio-controller: No cache defaults, reading back from HW
[   83.283559] systemd[1]: Hostname set to <stm32mp13-audiotest>.
[   94.358163] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   94.487565] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.st,stm32mp135f-audio_test_cubemx-mx.bin failed with error -2
[   94.503605] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   94.582875] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   94.589293] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   94.815024] Modules linked in: snd_soc_audio_graph_card snd_soc_simple_card_utils brcmfmac stm32_dcmipp cfg80211 hci_uart btbcm brcmutil stm32_crc32 bluetooth st_mipid02 gc2145 v4l2_fwnode v4l2_async stm32_cryp ecdh_generic videodev libdes ecc crypto_engine libaes mc stm32_adc_core ucsi_stm32g0 typec_ucsi typec sch_fq_codel ip_tables x_tables ipv6
[   96.602222] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   96.608640] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   96.729081] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   96.755746] Modules linked in: dcmipp_bytecap(+) videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common dcmipp_parallel dcmipp_byteproc stm32_adc(+) stm32_timer_trigger stm32_lptimer_trigger snd_soc_audio_graph_card snd_soc_simple_card_utils brcmfmac stm32_dcmipp cfg80211 hci_uart btbcm brcmutil stm32_crc32 bluetooth st_mipid02 gc2145 v4l2_fwnode v4l2_async stm32_cryp ecdh_generic videodev libdes ecc crypto_engine libaes mc stm32_adc_core ucsi_stm32g0 typec_ucsi typec sch_fq_codel ip_tables x_tables ipv6
[   96.826275] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   96.930105] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   96.978668] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   97.810640] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a
[   97.868132] OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a

Do you have any advice on what to do next?

Again, the message below:

 

OF: graph: no port node found in /soc/audio-controller@44004000/pcm5102a

 

made me think that maybe the problem is in the codec node of the Device Tree. Indeed after swapping below

 

        codec_port: pcm5102a_port {
            codec_endpoint: endpoint {
                remote-endpoint = <&i2s1_endpoint>;
            };
        };

 

to

 

        codec_port: port {
            codec_endpoint: endpoint {
                remote-endpoint = <&i2s1_endpoint>;
            };
        };

 

 The OF message disappeared, now the only remaining dmesg output regarding audio is below:

 

[    3.601352] st,stm32-i2s 44004000.audio-controller: No cache defaults, reading back from HW
[    3.883381] st,stm32-i2s 44004000.audio-controller: No cache defaults, reading back from HW
[   93.945497] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.st,stm32mp135f-audio_test_cubemx-mx.bin failed with error -2

 

Once again, do you have any advice on to fix that?

AJank.2
Associate III

@Erwan SZYMANSKI @PatrickF could I get some help with this? Is STMicroelectronics support closed this week?

Hi @AJank.2 thank you for following up on your question. 

Please apologize for the delay in response, we are just catching up after the migration to the new platform. 

I escalated your question to some audio expert. We will come back to you ASAP. 

Olivier 

 

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello @AJank.2 ,
Sorry for the delay, I was out of office.

Concerning the 2 remaining I2S messages in dmsg, they looks normal. We always have the same on our standard deliveries.

Do you still face troubles with your setup ?

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AJank.2
Associate III

Hi @Erwan SZYMANSKI, the main problem is that there are no sound cards discovered by ALSA - that I haven't fixed yet. With that simple kind of codec it seems that nothing more from what I set up already should be configured meaning that I don't know what else could be missing.

Hi @AJank.2 ,
Can you share me your complete device tree ? I will try to review it and see if I can highlight some problems inside.

Rgs,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
AJank.2
Associate III

Yes, the files generated by CubeMX with my modifications to the device tree is in the attached audio_test.tar.

Actually for some reason I'm having problems with attaching the tar archive. The error says that the file doesn't match it's type:

The attachment's audio_test.tar content type (application/x-tar) does not match its file extension and has been removed.

I'll try again in the next reply.

AJank.2
Associate III

Okay, decided to sent just the Device Tree, here it is with changed extension, from .dts to .txt.