基于RK3288 平台 Simple card声卡添加及调试

「爱情、让人受尽委屈。」 2021-11-14 14:44 1834阅读 0赞

基于RK3288 平台 Simple card声卡添加及调试
Simple card即简单通用的machine driver, 如果simple-card框架足够满足需求,建议优先使用simple card框架,简单,方便,且易用.

一、 添加声卡

  1. 添加codec driver,比如添加:sound/soc/codec/es8323.c
  2. 修改sound/soc/codec/Kconfig以及Makefile加入驱动编译。
    sound/soc/codec/Kconfig: 添加
    select SND_SOC_ES8323 if I2C
    config SND_SOC_ES8323

    1. tristate "Everest Semi ES8323 CODEC"
    2. depends on I2C

    sound/soc/codec/Makefile: 添加
    snd-soc-es8323-objs := es8323.o
    obj-$(CONFIG_SND_SOC_ES8323) += snd-soc-es8323.o

  3. menuconfig中enable simple card以及codec
    make menuconfig Device Drivers —-> Sound card support —-> Advanced Linux Sound Architecture —-> ALSA for SoC audio support —-> ASoC support for Rockchip
    CODEC drivers —->
    <*> Everest Semi ES8323 CODEC

  4. 产品的DTS中添加Simple Card Node

二、修改DTS文件
1 添加sound card 和 spdif(可选添加,用不到不用添加)
2 添加:&i2c2(es8323 mclk)和&i2s(es8323 I2S通信)
3 添加&sound
注意,需要增加内容如下:
{\
sound: sound {
status = “okay”;
compatible = “simple-audio-card”;
simple-audio-card,format = “i2s”;
simple-audio-card,name = “rockchip,firefly-codec”;
simple-audio-card,mclk-fs = <512>;
simple-audio-card,widgets =
“Microphone”, “Microphone Jack”,
“Headphone”, “Headphone Jack”;
simple-audio-card,routing =
“MIC1”, “Microphone Jack”,
“MIC2”, “Microphone Jack”,
“Microphone Jack”, “micbias1”,
“Headphone Jack”, “HPOL”,
“Headphone Jack”, “HPOR”;

  1. simple-audio-card,dai-link@0 \{
  2. format = "i2s";
  3. cpu \{
  4. sound-dai = <&i2s>;
  5. \};
  6. codec \{
  7. sound-dai = <&es8323>;
  8. \};
  9. \};
  10. simple-audio-card,dai-link@1 \{
  11. format = "i2s";
  12. cpu \{
  13. sound-dai = <&i2s>;
  14. \};
  15. codec \{
  16. sound-dai = <&hdmi>;
  17. \};
  18. \};
  19. \};
  20. spdif\_out: spdif-out \{
  21. status = "okay";
  22. compatible = "linux,spdif-dit";
  23. \#sound-dai-cells = <0>;
  24. \};
  25. spdif-sound \{
  26. status = "okay";
  27. compatible = "simple-audio-card";
  28. simple-audio-card,name = "ROCKCHIP,SPDIF";
  29. simple-audio-card,cpu \{
  30. sound-dai = <&spdif>;
  31. \};
  32. simple-audio-card,codec \{
  33. sound-dai = <&spdif\_out>;
  34. \};

}

&i2c2 {
status = “okay”;

  1. es8323: es8323@10 \{
  2. status = "okay";
  3. compatible = "everest,es8323";
  4. reg = <0x10>;
  5. spk-con-gpio = <&gpio5 12 GPIO\_ACTIVE\_LOW>;

// hp-det-gpio = <&gpio7 15 GPIO_ACTIVE_LOW>;
clock-names = “mclk”;
clocks = <&cru SCLK_I2S0_OUT>;
pinctrl-names = “default”;
pinctrl-0 = <&i2s0_mclk>;
#sound-dai-cells = <0>;
};
};
需要注意的是,如上es8323的clocks即mclk, upstream代码遵循谁使用clk谁申请的原则,所以后续自己添加的codec driver,如果有使用

外部clk作为mclk,需要做同样的适配。

&i2s {
#sound-dai-cells = <0>;
status = “okay”;
};
&sound {
status = “okay”;
};

注意要去掉以下内容,否则声卡驱动无法挂载
&es8323 {
// aux-det-gpio = <&gpio2 15 GPIO_ACTIVE_HIGH>;
spk-ctl-gpio = <&gpio7 2 GPIO_ACTIVE_HIGH>;
};
三、总结
1 屏幕不亮的问题
调试中发现屏幕 背光是亮的,但是屏幕不亮,把vcc_sys_5v: vcc-sys-5v,gpio GPIO0_B5 修改为GPIO7_A3屏幕就亮了。
如下所示:
vcc_sys_5v: vcc-sys-5v{
compatible = “regulator-fixed”;
enable-active-high;
gpio = <&gpio7 3 GPIO_ACTIVE_HIGH>;
pinctrl-names = “default”;
pinctrl-0 = <&pwr5v_en>;
regulator-name = “vcc_sys_5v”;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-always-on;
regulator-boot-on;
};

  1. vcc-sys \{
  2. pwr5v\_en: pwr5v-en \{
  3. rockchip,pins = <7 3 RK\_FUNC\_GPIO &pcfg\_output\_high>;
  4. \};
  5. \};

2 调试中声卡总是挂载不上去:在dts中去掉以下内容后就可以了。因为在I2C2中已经设置过
&es8323 {
// aux-det-gpio = <&gpio2 15 GPIO_ACTIVE_HIGH>;
spk-ctl-gpio = <&gpio7 2 GPIO_ACTIVE_HIGH>;
};

发表评论

表情:
评论列表 (有 0 条评论,1834人围观)

还没有评论,来说两句吧...

相关阅读