How to use record audio stream with PDMIC
The Pulse Density Modulation Interface Controller (PDMIC) is a mono PDM interface controller and decoder that can be connected to a silicon digital microphone. With the Linux PDMIC driver you can easily record sound from this simple connection setup.
This ALSA System on Chip (ASoC) layer driver embeds a digitallly controlled gain, a High-Pass and a SINCC filter.
The usual ALSA capture interface can be used to interface with this driver. The
arecord
application is the reference implementation for such an API.
During the boot, identify the call to the PDMIC driver probe function:
atmel-pdmic f8018000.pdmic: atmel-pdmic-hifi <-> f8018000.pdmic mapping ok
[..]
ALSA device list:
#0: classd @ SAMA5D2-Xplained
#1: PDMIC @ sama5d2_xplained
You can also list them with:
root@sama5d2-xplained:~# cat /proc/asound/cards
0 [SAMA5D2Xplained]: classd___SAMA5D - classd @ SAMA5D2-Xplained
classd @ SAMA5D2-Xplained
1 [sama5d2xplained]: PDMIC___sama5d2 - PDMIC @ sama5d2_xplained
PDMIC @ sama5d2_xplained
root@sama5d2-xplained:~# cat /proc/asound/pcm
00-00: CLASSD PCM atmel-classd-hifi-0 : : playback 1
01-00: PDMIC PCM atmel-pdmic-hifi-0 : : capture 1
root@sama5d2-xplained:~# cat /proc/asound/devices
0: [ 0] : control
16: [ 0- 0]: digital audio playback
32: [ 1] : control
33: : timer
56: [ 1- 0]: digital audio capture
arecord
can also list devices on which it can operate:
root@sama5d2-xplained:~# arecord --list-devices
**** List of CAPTURE Hardware Devices ****
card 1: sama5d2xplained [PDMIC @ sama5d2_xplained], device 0: PDMIC PCM atmel-pdmic-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
It tels explicitly that the
Card 1,
device 0 is the capture interface.
This information gives us the device name:
hw:1,0
When these are 2 ALSA cards such as on the SAMA5D2 Xplained, you need to select the proper interface for configuring it.
You can use
alsamixer
and change the card selection afterwards (F6 key). or directly use this command line:
alsamixer -c 1
Then you can move to the
Capture
screen using the TAB key and be able to adjust the capture volume.
With my setup, it seems that a capture volume above ~16 (Mic [dB gain: 43.00]) leads to a saturated result, keep the gain below this level.
Connecting a silicon digital microphone is very simple with the PDMIC interface. Only a data and a clock lines must be connected to the PDMIC entries. You can take the example schematics below or the on simple connection guidelines in the datasheet of the silicon digital microphone.
Select the proper ALSA interface according to the chapter above:
#Identify_the_driver_for_PDMIC.
So you can record a mono sound in the
p48000.wav
file during 10 seconds with the command:
arecord -D hw:1,0 -d 10 -f S16_LE -c1 -r48000 p48000.wav