Audio
The NXP i.MX95 Technical Guide documentation from RidgeRun is presently being developed. |
Introduction
The Verdin i.MX95 platform uses the standard Linux audio subsystem ALSA (Advanced Linux Sound Architecture) for audio playback and capture. ALSA exposes audio hardware as sound cards and provides tools to configure mixers, control audio paths, and handle raw audio streams.
On Verdin i.MX95, audio is implemented using a NAU8822 audio codec connected to the SoC through a Synchronous Audio Interface (SAI). This configuration is exposed as a single ALSA sound card and device (typically hw:0,0), simplifying audio configuration compared to platforms with multiple audio interfaces.
Common ALSA tools include:
amixerandalsamixerfor mixer and routing configurationaplayfor audio playbackarecordfor audio capture
For higher-level audio handling, frameworks such as GStreamer can be used to play encoded formats (e.g., MP3), convert audio streams, and build more complex pipelines.
This page demonstrates how to test and validate audio functionality on Verdin i.MX95 using ALSA and GStreamer.
Testing audio on Verdin i.MX95
Before playing or recording audio, identify the available sound cards on the system:
cat /proc/asound/cards
Example output:
0 [verdinnau8822 ]: simple-card - verdin-nau8822
verdin-nau8822
In this example, the onboard audio codec (NAU8822) is exposed as ALSA card 0.
Playback Test
Unmute the output and set a playback volume:
amixer -c 0 sset Headphone unmute amixer -c 0 set Headphone 75%
The output should show playback enabled and volume at 75 percent:
Simple mixer control 'Headphone',0 Front Left: 47 [75%] Playback [on] Front Right: 47 [75%] Playback [on]
Test playback with a generated signal:
speaker-test --device hw:0,0 --rate 48000 --channels 2 --format S16_LE --test wav
Connect your headphones to port X20 (Check the end of this page to learn about each port). You should hear a voice saying "Front left" and "Front Right". You should also see this output:
speaker-test 1.2.11 Playback device is hw:0,0 Stream parameters are 48000Hz, S16_LE, 2 channels WAV file(s) Rate set to 48000Hz (requested 48000Hz) Buffer size range from 32 to 131072 Period size range from 16 to 8184 Periods = 4 was set period_size = 8184 was set buffer_size = 32736 0 - Front Left 1 - Front Right Time per period = 2.390311 0 - Front Left 1 - Front Right Time per period = 3.068254 0 - Front Left 1 - Front Right
Playback with Audio Files
You can also test playback using a WAV file:
aplay -D hw:0,0 /usr/share/sounds/alsa/Front_Center.wav
Alternatively, use the default ALSA device:
aplay -D sysdefault:CARD=verdinnau8822 /usr/share/sounds/alsa/Front_Center.wav
Audio Capture Test
To record audio from the default capture device:
arecord -D hw:0,0 -f S16_LE -r 48000 -c 2 test.wav
Stop recording with Ctrl+C, then play it back:
aplay -D hw:0,0 test.wav
GStreamer Playback
Play a WAV file using GStreamer:
gst-launch-1.0 filesrc location=/usr/share/sounds/alsa/Front_Center.wav ! wavparse ! audioconvert ! alsasink device=hw:0,0
Play an MP3 file:
gst-launch-1.0 playbin uri=file:///path/to/file.mp3 audio-sink="alsasink device=hw:0,0"
GStreamer Test Signal
Generate a test tone without requiring a file:
gst-launch-1.0 audiotestsrc ! audioconvert ! alsasink device=hw:0,0
Inspect Mixer Controls
Available mixer controls may vary depending on the platform. To list them:
amixer -c 0 scontrols
You should see the following controls
Simple mixer control 'Headphone',0 Simple mixer control 'Headphone ZC',0 Simple mixer control 'Speaker',0 Simple mixer control 'Speaker ZC',0 Simple mixer control 'PCM',0 Simple mixer control 'Aux Boost',0 Simple mixer control 'ADC',0 Simple mixer control 'ADC 128x Oversampling',0 Simple mixer control 'ADC Companding',0 Simple mixer control 'ADC Inversion',0 Simple mixer control 'ALC Attack',0 Simple mixer control 'ALC Decay',0 Simple mixer control 'ALC Enable',0 Simple mixer control 'ALC Hold',0 Simple mixer control 'ALC Max Gain',0 Simple mixer control 'ALC Min Gain',0 Simple mixer control 'ALC Mode',0 Simple mixer control 'ALC Noise Gate',0 Simple mixer control 'ALC Noise Gate Threshold',0 Simple mixer control 'ALC Target',0 Simple mixer control 'AUX1 Output Mixer LDAC',0 Simple mixer control 'AUX1 Output Mixer LMIX',0 Simple mixer control 'AUX1 Output Mixer RDAC',0 Simple mixer control 'AUX1 Output Mixer RINMIX',0 Simple mixer control 'AUX1 Output Mixer RMIX',0 Simple mixer control 'AUX2 Output Mixer AUX1MIX Output',0 Simple mixer control 'AUX2 Output Mixer LDAC',0 Simple mixer control 'AUX2 Output Mixer LINMIX',0 Simple mixer control 'AUX2 Output Mixer LMIX',0 Simple mixer control 'AUXOUT',0 Simple mixer control 'DAC 128x Oversampling',0 Simple mixer control 'DAC Companding',0 Simple mixer control 'DAC Inversion',0 Simple mixer control 'DAC Limiter',0 Simple mixer control 'DAC Limiter Attack',0 Simple mixer control 'DAC Limiter Decay',0 Simple mixer control 'DAC Limiter Threshold',0 Simple mixer control 'Digital Loopback',0 Simple mixer control 'EQ Function',0 Simple mixer control 'High Pass Cut Off',0 Simple mixer control 'High Pass Filter',0 Simple mixer control 'L2/R2 Boost',0 Simple mixer control 'Left Input Mixer L2',0 Simple mixer control 'Left Input Mixer MicN',0 Simple mixer control 'Left Input Mixer MicP',0 Simple mixer control 'Left Output Mixer LAUX',0 Simple mixer control 'Left Output Mixer LDAC',0 Simple mixer control 'Left Output Mixer LINMIX',0 Simple mixer control 'Left Output Mixer RDAC',0 Simple mixer control 'PGA',0 Simple mixer control 'PGA Boost',0 Simple mixer control 'PGA ZC',0 Simple mixer control 'Right Input Mixer MicN',0 Simple mixer control 'Right Input Mixer MicP',0 Simple mixer control 'Right Input Mixer R2',0 Simple mixer control 'Right Output Mixer LDAC',0 Simple mixer control 'Right Output Mixer RAUX',0 Simple mixer control 'Right Output Mixer RDAC',0 Simple mixer control 'Right Output Mixer RINMIX',0
To inspect a specific control:
amixer -c 0 sget Headphone
Simple mixer control 'Headphone',0 Capabilities: volume pswitch Playback channels: Front Left - Front Right Capture channels: Front Left - Front Right Limits: 0 - 63 Front Left: 47 [75%] [-10.00dB] Playback [on] Front Right: 47 [75%] [-10.00dB] Playback [on]
BTL (Bridge-Tied Load) Mode
The NAU8822 codec supports a Bridge-Tied Load (BTL) output mode for driving speakers.
In BTL mode, the speaker is driven by two opposite-phase signals instead of a signal and ground. This effectively doubles the voltage across the speaker, resulting in higher output power.
An overlay is available to enable this mode:
verdin-imx95_nau8822-btl_overlay.dtbo
To apply the overlay:
fw_setenv overlays verdin-imx95_nau8822-btl_overlay.dtbo reboot
After reboot, test audio playback:
speaker-test -D hw:0,0 -c 2
BTL mode is intended for speaker outputs. Ensure the correct pins are used and avoid connecting one side of the speaker to ground.