rk3399 android8.1 配置声卡

项目场景:

fm1288声卡配置,麦克风喇叭接在了fm1288上,没有接在rk3399平台

文章目录

前言

一、声卡配置项

二、配置步骤

1.i2s配置

2.声卡配置

2.麦克风,喇叭配置



前言

rk3399声卡调试可以通过查看 cat /proc/asound/cards 找到已经在dts中配置好的声卡

一、声卡配置项

正常情况下,如果声卡是通过 i2c 配置参数的,需要在设备树里配置 i2c 例如:

&i2c1 {
        status = "okay";
        i2c-scl-rising-time-ns = <140>;
        i2c-scl-falling-time-ns = <30>;

        es8316: es8316@11 {                                      //声卡
                #sound-dai-cells = <0>;
                compatible = "everest,es8316";
                reg = <0x11>;
                clocks = <&cru SCLK_I2S_8CH_OUT>;
                clock-names = "mclk";
                pinctrl-names = "default";
                pinctrl-0 = <&i2s_8ch_mclk>;
                spk-con-gpio = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>;
        };
};

但是fm1288我们是通过串口配置参数的,所以这步可以不要,通过apk读写串口直接配置参数就可以。

除此之外,主要是配置设备树,以及驱动代码修改。 

二、配置步骤

1.i2s配置

因为声卡要接 i2s ,所以先要打开 i2s

&i2s0 {
        status = "okay";
        rockchip,i2s-broken-burst-len;
        rockchip,playback-channels = <8>;
        rockchip,capture-channels = <8>;
        #sound-dai-cells = <0>;
};

2.声卡配置

因为是用串口配置参数,所以使用虚拟声卡

        dummy_codec: dummy-codec {
                status = "okay";
                compatible = "rockchip,dummy-codec";
                #sound-dai-cells = <0>;
                clocks = <&cru SCLK_I2S_8CH_OUT>;
                clock-names = "mclk";
                pinctrl-names = "default";
                pinctrl-0 = <&i2s_8ch_mclk>;
        };

        fm1288_sound: fm1288-sound {
                status = "okay";
                compatible = "simple-audio-card";                 //声卡通用驱动匹配
                simple-audio-card,name = "rockchip,fm1288-sound"; //注册的声卡名
                simple-audio-card,format = "i2s";                 
                simple-audio-card,mclk-fs = <256>;

//这两段是麦克风喇叭配置,因为麦克风喇叭直接接在了fm1288上所以不需要配置,若是接在rk3399上,则需要
            /*   simple-audio-card,widgets =
                        "Microphone", "Mic Jack",
                        "Headphone", "Headphone Jack";
                simple-audio-card,routing =
                        "Mic Jack", "MICBIAS1",
                        "IN1P", "Mic Jack",
                        "Headphone Jack", "HPOL",
                        "Headphone Jack", "HPOR"; */           

                simple-audio-card,cpu {                          //cpu段audio主控
                        sound-dai = <&i2s0>;
                };
                simple-audio-card,codec {                        //codec段,用于跟cpu绑定
                        sound-dai = <&dummy_codec>;
                };
        };

注册后的声卡可以看到 

 

2.麦克风,喇叭配置

上述讲过麦克风喇叭因为没有接在rk3399平台上,所以此时在android层放录音是没有声音的,需要配置 fm1288声卡数据直接输出到 rk3399平台。

hardware/rockchip/audio/tinyalsa_hal/audio_hw.c 修改在麦克风,喇叭处添加fm1288声卡:

static bool is_speaker_out_sound_card(char* buf)
{
    /*add sound card name of speaker here*/
    const char* NAME [] =
    {
       "rockchiprk",
       "realtekrt5651co",
       "rockchipes8316c",
       "rockchiprk809co",
+      "rockchipfm1288s",
    };


static bool is_mic_in_sound_card(char* buf)
{
    /*add sound card name of mic here*/
    static char* NAME [] =
    {
        "rockchiprk",
        "realtekrt5651co",
        "rockchipes8316c",
        "rockchiprk809co",
+       "rockchipfm1288s",
    };


你可能感兴趣的:(rk3399)