Audio
1. Audio Interface Introduction
Taking M5-R1 as an example, it has a headphone interface through which a wired headphone can be connected externally.
2. Audio Testing
# When HDMI display is plugged in and headphones are plugged in, you can see two output options to choose from. Here, 0 corresponds to headphones, and 1 corresponds to HDMI.
root@rk3588-buildroot:/# pactl list short sinks
0 alsa_output.0.HiFi__hw_rockchipes8388__sink module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_output.1.HDMI__hw_rockchiphdmi1__sink module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
# Check if the current default output is HDMI or headphones
root@rk3588-buildroot:/# pactl get-default-sink
alsa_output.0.HiFi__hw_rockchipes8388__sink
# Setting to 1 means set sound to output from HDMI display
root@rk3588-buildroot:/# pactl set-default-sink 1
# Verify
root@rk3588-buildroot:/# pactl get-default-sink
alsa_output.1.HDMI__hw_rockchiphdmi1__sink
root@rk3588-buildroot:/# aplay 1KHz.wav
Playing WAVE '1KHz.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
aplay: pcm_write:2178: write error: Interrupted system call
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: ALSA woke us up to write new data to the device, but there was actually nothing to write.
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: Most likely this is a bug in the ALSA driver '(null)'. Please report this issue to the ALSA developers.
E: [alsa-sink-rockchip-hdmi1 i2s-hifi-0] alsa-sink.c: We were woken up with POLLOUT set -- however a subsequent snd_pcm_avail() returned 0 or another value < min_avail.# Use headphone microphone for recording
amixer -c 0 cset name='Differential Mux' 'Line 1'
# Use arecord command, -d specifies how many seconds to record
arecord -D hw:0,0 --period-size=1024 --buffer-size=4096 -r 16000 -c 2 -f S16_LE r.wav -d 7
aplay r.wav
# Use external microphone for recording
amixer -c 0 cset name='Differential Mux' 'Line 2'
# Use arecord command, -d specifies how many seconds to record
arecord -D hw:0,0 --period-size=1024 --buffer-size=4096 -r 16000 -c 2 -f S16_LE r.wav -d 7
aplay r.wav