====== Edge-2L and ES8316 audio usage ====== Using the ES8316 audio codec requires the [[https://www.khadas.com/product-page/edge-2l-io-module|Edge-2L IO board]] ===== Alsa audio device hardware name ===== The ES8316 codec is accessible via the ALSA hardware name ''hw:CARD=rockchipes8316c''. Use this name in audio commands, for example: ''aplay -D **hw:CARD=rockchipes8316c** ...''. You can verify the hardware name with the following commands: ```shell print ES8316 hw name $ aplay -L | grep rockchipes8316c -m1 hw:CARD=rockchipes8316c,DEV=0 $ arecord -L | grep rockchipes8316c -m1 hw:CARD=rockchipes8316c,DEV=0 ``` ===== Alsa audio device hardware index ===== You can also identify the ES8316 by its card index. List the available audio devices: ```shell print ES8316 hw index ~# arecord -l | grep es8316-codec -A2 card 3: rockchipes8316c [rockchip,es8316-codec], device 0: fe470000.i2s-ES8316 HiFi ES8316 HiFi-0 [fe470000.i2s-ES8316 HiFi ES8316 HiFi-0] Subdevices: 1/1 Subdevice #0: subdevice #0 ~# aplay -l | grep es8316-codec -A2 card 3: rockchipes8316c [rockchip,es8316-codec], device 0: fe470000.i2s-ES8316 HiFi ES8316 HiFi-0 [fe470000.i2s-ES8316 HiFi ES8316 HiFi-0] Subdevices: 1/1 Subdevice #0: subdevice #0 ``` In this example, the ES8316 is card 3, so its hardware index is ''3''. ===== Record audio using ES8316 ===== Record a 20-second WAV file using the hardware name: ``` arecord -D hw:CARD=rockchipes8316c -f cd -d 20 record.wav ``` Or, using the hardware index (e.g., 3): ```shell arecord -D hw:3 -f cd -d 20 record.wav ``` **Microphone Priority:** The headphone microphone has higher priority than the onboard analog microphone (AMIC). If a headphone with a microphone is connected, recording will use the headphone mic. Otherwise, it will use the onboard AMIC. ===== Playback audio using ES8316 ===== Play a WAV file using the hardware name: ```shell aplay -D hw:CARD=rockchipes8316c xxx.wav ``` Or, using the hardware index (e.g., 3): ```shell aplay -D hw:3 xxx.wav ``` **Output Priority:** The headphone output has higher priority than the onboard speaker. If headphones are connected, audio will play through them. Otherwise, audio will play through the speaker.