cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP135 + SGTL5000: arecord fails with `pcm_read: Input/output error` while aplay works

Midhul_Pk
Associate II

Hi,

I am working on STM32MP135 with SGTL5000 codec using ALSA/ASoC.

Playback is working correctly:

aplay -D default /home/audio/test_audio.wav

But audio capture is failing with Input/output error:

root@stm32mp135-comtrol:~# arecord -D hw:0,1 -f S16_LE -r 48000 -c 2 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
arecord: pcm_read:2272: read error: Input/output error

Current status:

  • Playback works correctly
  • Codec detected properly
  • I2C communication seems OK during playback
  • Capture stream fails immediately after start
root@stm32mp135-comtrol:~# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: STM32SGTL5000 [STM32-SGTL5000], device 1: 4400a024.audio-controller-sgtl5000 sgtl5000-1 [4400a024.audio-controller-sgtl5000 sgtl5000-1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

 

Device tree configuration is attached below.

Questions:

  1. What usually causes pcm_read: Input/output error in ALSA capture?
  2. Could this be related to SAI RX configuration?
  3. Is there any missing SGTL5000 mixer/control configuration required for recording?
  4. Does hw:0,1 indicate incorrect capture routing?

I checked:

  • LRCLK = 48kHz
  • BCLK = 1.536MHz
  • MCLK present
  • Playback path working

But capture still fails.

 

Device Tree :-  

Pins :- 

 

	
	sai1_pins_a: sai1-0 {
		pins {
		    pinmux = <STM32_PINMUX('A', 4, AF12)>, /* SAI1_SCK_A */
		             <STM32_PINMUX('A', 0, AF6)>, /* SAI1_SD_B */
		             <STM32_PINMUX('A', 5, AF6)>, /* SAI1_SD_A */
		             <STM32_PINMUX('F', 11, AF6)>, /* SAI1_FS_A */
		             <STM32_PINMUX('D', 13, AF6)>; /* SAI1_MCKA */
		    slew-rate = <0>;
		    drive-push-pull;
		    bias-disable;
		};
	    };

	    sai1_sleep_pins_a: sai1-sleep-0 {
		pins {
		    pinmux = <STM32_PINMUX('A', 4, ANALOG)>, /* SAI1_SCK_A */
		             <STM32_PINMUX('A', 0, ANALOG)>, /* SAI1_SD_B */
		             <STM32_PINMUX('A', 5, ANALOG)>, /* SAI1_SD_A */
		             <STM32_PINMUX('F', 11, ANALOG)>, /* SAI1_FS_A */
		             <STM32_PINMUX('D', 13, ANALOG)>; /* SAI1_MCKA */
		};
	    };

Sound :-

	sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "STM32-SGTL5000";

		simple-audio-card,widgets =
			"Microphone", "Mic Jack",
			"Headphone", "Headphone Jack",
			"Line", "Line In",
			"Line", "Line Out";

		simple-audio-card,routing =
			"Headphone Jack", "HP_OUT",
			"Line Out", "LINE_OUT",
			"Mic Jack", "MIC_IN",
			"LINE_IN", "Line In";

		/* Playback */
		simple-audio-card,dai-link@0 {
			format = "i2s";

			bitclock-master = <&cpu_tx>;
			frame-master = <&cpu_tx>;

			mclk-fs = <256>;

			cpu_tx: cpu {
				sound-dai = <&sai1a>;
			};

			codec_tx: codec {
				sound-dai = <&sgtl5000>;
			};
		};

		/* Capture */
		simple-audio-card,dai-link@1 {
			format = "i2s";

			bitclock-master = <&cpu_tx>;
			frame-master = <&cpu_tx>;

			mclk-fs = <256>;

			cpu {
				sound-dai = <&sai1b>;
			};

			codec {
				sound-dai = <&sgtl5000>;
			};
		};
	};

 

CODEC :-

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

	    #sound-dai-cells = <0>;

	    VDDA-supply = <&scmi_v3v3_sw>;
	    VDDIO-supply = <&scmi_v3v3_sw>;

	    clocks = <&sai1a>;
	    clock-names = "mclk";
	};

 SAI :-

&sai1 {
	status = "okay";

	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&sai1_pins_a>;
	pinctrl-1 = <&sai1_sleep_pins_a>;

	clock-names = "pclk", "x8k", "x11k";

	clocks = <&rcc SAI1>,
		 <&scmi_clk CK_SCMI_PLL3_Q>,
		 <&scmi_clk CK_SCMI_PLL3_R>;

	assigned-clocks = <&rcc SAI1_K>;
	assigned-clock-parents = <&scmi_clk CK_SCMI_PLL3_Q>;
	assigned-clock-rates = <12288000>;

	sai1a: audio-controller@4400a004 {
		compatible = "st,stm32-sai-sub-a";
		reg = <0x4 0x20>;

		#sound-dai-cells = <0>;

		clocks = <&rcc SAI1_K>;
		clock-names = "sai_ck";

		#clock-cells = <0>;
		clock-output-names = "sai1a_mclk";

		st,sai-mclk-output;

		dmas = <&dmamux1 87 0x400 0x01>;
		dma-names = "tx";

		status = "okay";
	};

	sai1b: audio-controller@4400a024 {
		compatible = "st,stm32-sai-sub-b";
		reg = <0x24 0x20>;

		#sound-dai-cells = <0>;

		clocks = <&rcc SAI1_K>;
		clock-names = "sai_ck";

		st,sync = <&sai1a 1>;

		dmas = <&dmamux1 88 0x400 0x01>;
		dma-names = "rx";

		status = "okay";
	};
};

 Any help would be appreciated. 

1 REPLY 1
Gregory PLANCHON
ST Employee

Hi @Midhul_Pk ,

 

Did you check out this page to run your tests?
Also, I can't say for sure that this is the root cause, but `simple-audio-card` is quite limited. It's better to use `audio-graph-card`. You can find examples on our forums on this page

 

Regards,

Grégory 

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.
Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.