DESK-MX9-L/Peripherals/Microphone

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2025/03/18 DESK-MX9-L 5.2.0 release


Peripheral Micorphone[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]

Here below an example of device tree configuration used on standard DAVE's kit for AURA:

From imx93-aura-sbcx.dtsi it is possible to find the codec 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 = <&sai3>;
		};

		codec_dai: simple-audio-card,codec {
			sound-dai = <&codec>;
			system-clock-frequency = <12288000>;
		};

	};
...
};
...
&sai3 {
	#sound-dai-cells = <0>;
	assigned-clock-rates = <24576000>;
	status = "okay";
};
...
&lpi2c1 {
	status = "okay";

	codec: tlv320aic31xx@18 {
		#sound-dai-cells = <0>;
		compatible = "ti,tlv320aic3100";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_codec_en>;
		reg = <0x18>;
		clocks = <&clk IMX93_CLK_SAI3_GATE>;
		clock-names = "mclk1";
		reset-gpios = <&gpio2 21 GPIO_ACTIVE_LOW>;
		HPVDD-supply = <&carrier_reg_3v3>;
		SPRVDD-supply = <&carrier_reg_5v0>;
		SPLVDD-supply = <&carrier_reg_5v0>;
		AVDD-supply = <&carrier_reg_3v3>;
		IOVDD-supply = <&carrier_reg_3v3>;
		DVDD-supply = <&carrier_reg_1v8>;
		status = "okay";
	};
};
...
...
&iomuxc {
...
	pinctrl_codec_en: codecen {
		fsl,pins = <
			MX93_PAD_GPIO_IO21__GPIO2_IO21			 0x31e
		>;
	};
...
};

Accessing the peripheral[edit | edit source]

Linux messages at boot time[edit | edit source]

...
[    2.155123] ALSA device list:
[    2.162823]   #0: SBCX_TLV320
...

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

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

Setup Speaker[edit | edit source]

To unmute the speaker the amixer utility can be used.

root@desk-mx93-rev1:~# amixer sset "Speaker" "on"
Simple mixer control 'Speaker',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
root@desk-mx93-rev1:~# amixer sset "Speaker Analog" "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-mx93-rev1:~# amixer sset "Speaker Driver" "on 2"
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-mx93-rev1:~# amixer sset "DAC" "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-mx93-rev1:~# amixer sset "Output Left From Left DAC" "on"
Simple mixer control 'Output Left From Left DAC',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]

Setup Micorphone[edit | edit source]

To initialize the microphone the amixer utility can be used.

root@desk-mx93-rev1:~# amixer cset name="ADC Capture Switch" on
numid=2,iface=MIXER,name='ADC Capture Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
root@desk-mx93-rev1:~# amixer sset "ADC" "64"
Simple mixer control 'ADC',0
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined
  Capture channels: Mono
  Limits: Capture 0 - 64
  Mono: Capture 64 [100%] [12.00dB] [on]
root@desk-mx93-rev1:~# amixer sset "Mic PGA" "5"
Simple mixer control 'Mic PGA',0
  Capabilities: cvolume cvolume-joined
  Capture channels: Mono
  Limits: Capture 0 - 119
  Mono: Capture 5 [4%] [2.50dB]
root@desk-mx93-rev1:~# amixer sset "ADC Fine" "0"
Simple mixer control 'ADC Fine',0
  Capabilities: cvolume cvolume-joined
  Capture channels: Mono
  Limits: Capture 0 - 4
  Mono: Capture 0 [0%] [0.00dB]
root@desk-mx93-rev1:~# amixer sset "MIC1LM M-Terminal" "Off"
Simple mixer control 'MIC1LM M-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'Off'
root@desk-mx93-rev1:~# amixer sset "MIC1LM P-Terminal" "Off"
Simple mixer control 'MIC1LM P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'Off'
root@desk-mx93-rev1:~# amixer sset "MIC1LP P-Terminal" "Off"
Simple mixer control 'MIC1LP P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'Off'
root@desk-mx93-rev1:~# amixer sset "MIC1RP P-Terminal" "FFR 40 Ohm"
Simple mixer control 'MIC1RP P-Terminal',0
  Capabilities: enum
  Items: 'Off' 'FFR 10 Ohm' 'FFR 20 Ohm' 'FFR 40 Ohm'
  Item0: 'FFR 40 Ohm'
root@desk-mx93-rev1:~#

Register a sound for 5 seconds[edit | edit source]

To register a sound for 5 seconds, perform the command below

root@desk-mx93-rev1:~# arecord -V mono -r 48000 -d 5 -c1 -f dat rec.wav
Recording WAVE 'rec.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
# +                                                | 02%root@desk-mx93-rev1:~#

To perform recorded sound, execute the command:

root@desk-mx93-rev1:~# aplay rec.wav
Playing WAVE 'rec.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
root@desk-mx93-rev1:~#

Additional information[edit | edit source]

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