DESK-MX8M-L/Peripherals/Audio

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2023/02/24

DESK-MX8M-L 2.0.0 release

2023/08/22

DESK-MX8M-L 4.0.0 release

2024/04/11

DESK-MX8M-L 4.1.0 release
2024/08/06 DESK-MX8M-L 4.2.x release


Peripheral Audio[edit | edit source]

Access to the audio interface is provided by ALSA (Advanced Linux Sound Architecture), which consists in a kernel driver and a users space library for application developers. A set of standard tools (alsa-utils) can be used for simple management of the audio codec.

Device tree configuration[edit | edit source]

MITO 8M Mini[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for MITO 8M Mini:

From imx8mm-mito8mmini.dtsi it is possible to find the Serial Audio Interface configuration:

...
&sai2 {
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_sai2>;
	assigned-clocks = <&clk IMX8MM_CLK_SAI2>;
	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
	assigned-clock-rates = <24576000>;
	status = "disabled";
};
...
&iomuxc {
...
	pinctrl_sai2: sai2grp {
		fsl,pins = <
			MX8MM_IOMUXC_SAI2_MCLK_SAI2_MCLK		0xd6
			MX8MM_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC		0xd6
			MX8MM_IOMUXC_SAI2_TXC_SAI2_TX_BCLK		0xd6
			MX8MM_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0	0xd6
			MX8MM_IOMUXC_SAI2_RXFS_SAI2_RX_SYNC		0xd6
			MX8MM_IOMUXC_SAI2_RXC_SAI2_RX_BCLK		0xd6
			MX8MM_IOMUXC_SAI2_RXD0_SAI2_RX_DATA0	0xd6
		>;
	};
...

From imx8mm-mito8mmini-sbcx.dts it is possible to find the codec SSI interface configuration:

...
...
		sound {
		compatible = "simple-audio-card";
		simple-audio-card,format = "i2s";
		simple-audio-card,name = "SBCX_TLV320";
		simple-audio-card,bitclock-master = <&cpu_dai>;
		simple-audio-card,frame-master = <&cpu_dai>;
		simple-audio-card,widgets =
			"Headphone", "Headphone Jack",
			"Line", "Line In",
			"Microphone", "Mic Jack";
		simple-audio-card,routing =
						"Speaker", "SPK",
						"Headphone Jack", "HPL",
						"Headphone Jack", "HPR",
						"MIC1LP", "Line In",
						"MIC1LM", "Line In",
						"MIC1RP", "Mic Jack",
						"Mic Jack", "MICBIAS";

		simple-audio-card,mclk-fs = <256>;

		cpu_dai: simple-audio-card,cpu {
			sound-dai = <&sai2>;
		};

		codec_dai: simple-audio-card,codec {
			sound-dai = <&codec>;
			system-clock-frequency = <12288000>;
		};
	};
...
&sai2 {
	pinctrl-names = "default";
	status = "okay";
};
...
&iomuxc {
...
	pinctrl_codec_en: codecen {
		fsl,pins = <
			MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28			 0x19
		>;
	};
...
...

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

To list the audio sound cards just use the aplay utility:

root@desk-mx8mm:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SBCXTLV320 [SBCX_TLV320], device 0: 30020000.sai-tlv320aic31xx-hifi tlv320aic31xx-hifi-0 [30020000.sai-tlv320aic31xx-hifi tlv320aic31xx-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@desk-mx8mm:~# 

Usage alsa-utils[edit | edit source]

In order to unmute the speaker the amixer utility can be used.

root@desk-mx8mm:~# amixer sset 'Speaker',0 on
Simple mixer control 'Speaker',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
root@desk-mx8mm:~# amixer sset 'Speaker Analog',0 108
Simple mixer control 'Speaker Analog',0
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 127
  Mono: Playback 108 [85%] [-9.50dB]
root@desk-mx8mm:~# amixer sset 'Speaker Driver',0 on
Simple mixer control 'Speaker Driver',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 3
  Mono: Playback 0 [0%] [6.00dB] [on]
root@desk-mx8mm:~# amixer sset 'Speaker Driver',0 2
Simple mixer control 'Speaker Driver',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 3
  Mono: Playback 2 [67%] [18.00dB] [on]
root@desk-mx8mm:~# amixer sset 'DAC',0 155
Simple mixer control 'DAC',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 175
  Mono:
  Front Left: Playback 155 [89%] [14.00dB]
  Front Right: Playback 155 [89%] [14.00dB]
root@desk-mx8mm:~# amixer sset 'Output Left From Left DAC',0 on
Simple mixer control 'Output Left From Left DAC',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
root@desk-mx8mm:~#

To perform a sound, execute the command:

root@desk-mx8mm:~# speaker-test -c 1 -t wav

speaker-test 1.2.6

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 3840 to 5760
Period size range from 1920 to 1920
Using max buffer size 5760
Periods = 4
was set period_size = 1920
was set buffer_size = 5760
 0 - Front Left
...

Additional information[edit | edit source]

Information about alsa-utils can be found on ALSA project wiki pages