Skip to main content

Audio

1. Overview

The audio part of the Omni3576 development board uses the ES8388 driver chip, which is a high-performance, low-power and low-cost audio codec. It includes a 2-channel ADC, a 2-channel DAC, a microphone amplifier, a headphone amplifier, digital sound effects, and analog mixing and gain functions.

2. Sound configuration

  1. Check the sound card device

    luckfox@luckfox:~$ arecord -l
    **** List of CAPTURE Hardware Devices ****
    card 0: rockchipes8388 [rockchip-es8388], device 0: dailink-multicodecs ES8323 HiFi-0 [dailink-multicodecs ES8323 HiFi-0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0

    luckfox@luckfox:~$ aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: rockchipes8388 [rockchip-es8388], device 0: dailink-multicodecs ES8323 HiFi-0 [dailink-multicodecs ES8323 HiFi-0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
    card 1: rockchipdp0 [rockchip-dp0], device 0: rockchip-dp0 spdif-hifi-0 [rockchip-dp0 spdif-hifi-0]
    Subdevices: 1/1
    Subdevice #0: subdevice #0
  2. Sound card driver directory

    luckfox@luckfox:~$ ls /dev/snd/
    by-path controlC0 controlC1 pcmC0D0c pcmC0D0p pcmC1D0p seq timer
    • controlC0 and controlC1: used for sound card control, C0 means sound card 0, C1 means sound card 1, corresponding to the sound output of SOC above
    • pcmC0D0c: pcm device for recording, the last "c" is the abbreviation of capture, indicating the recording device
    • pcmC0D0p and pcmC1D0p: pcm device for playback, the last "p" is the abbreviation of playback, indicating the playback device
    luckfox@luckfox:~$  ls -l /dev/snd/by-path/
    total 0
    lrwxrwxrwx 1 root root 12 Oct 18 10:03 platform-dp0-sound -> ../controlC1
    lrwxrwxrwx 1 root root 12 Oct 18 10:03 platform-es8388-sound -> ../controlC0

3. Test

  1. Recording Test

    arecord -Dhw:0,0  -f cd -r 44100 -c 2 -t wav test.wav 
  2. Headphone test (plugging in headphones will automatically switch input and output channels)

    设置录音增益:
    tinymix -D 0 set "Left Channel Capture Volume" 8
    tinymix -D 0 set "Right Channel Capture Volume" 8
    设置播放音量:
    tinymix -D 0 set "Output 1 Playback Volume" 33 33
    tinymix -D 0 set "Output 2 Playback Volume" 33 33
    播放:
    aplay -Dhw:0,0 -t wav /userdata/test.wav
    录音:
    arecord -Dhw:0,0 -f cd -r 44100 -c 2 -t wav /userdata/test.wav
  3. Playback test

    aplay -Dhw:0,0 -t wav /userdata/test.wav

4. Device tree Overview

  1. The Audio DTS source file has been defined in kernel-6.10/arch/arm64/boot/dts/rockchip/luckfox-omni3576-codec.dtsi, and we can call it directly.

    / {
    es8388_sound: es8388-sound {
    status = "okay";
    compatible = "rockchip,multicodecs-card";
    rockchip,card-name = "rockchip-es8388";
    rockchip,format = "i2s";
    rockchip,mclk-fs = <256>;
    rockchip,cpu = <&sai1>;
    rockchip,codec = <&es8388>;
    rockchip,audio-routing =
    "Headphone", "LOUT1",
    "Headphone", "ROUT1",
    "Speaker", "LOUT1",
    "Speaker", "ROUT1",
    "LINPUT2", "Main Mic",
    "RINPUT2", "Main Mic",
    "LINPUT2", "Headset Mic",
    "RINPUT2", "Headset Mic";
    };
    };

    &i2c2 {
    status = "okay";

    es8388: es8388@10 {
    status = "okay";
    #sound-dai-cells = <0>;
    compatible = "everest,es8388", "everest,es8323";
    reg = <0x10>;
    clocks = <&mclkout_sai1>;
    clock-names = "mclk";
    assigned-clocks = <&mclkout_sai1>;
    assigned-clock-rates = <12288000>;
    pinctrl-names = "default";
    pinctrl-0 = <&sai1m0_mclk>;
    };
    };


    &sai1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&sai1m0_lrck
    &sai1m0_sclk
    &sai1m0_sdi0
    &sai1m0_sdo0>;
    };