Firefly开源社区

12
发表新贴

kernel4.4.55内核的音频es8323驱动调试及dts配置

264

积分

6

威望

5

贡献

技术达人

Rank: 2

积分
264
QQ
发表于 2017-7-30 18:16:12     
本帖最后由 luwanjia 于 2017-7-31 20:14 编辑

以下是本人的调试经过,请指导!(刚接触linux驱动开发,对内核框架不熟悉,请各位指导,万分感谢!)

1. 调试环境
        内核:https://gitlab.com/TeeFirefly/linux-kernel.git firefly分支
        配置:rockchip_linux_defconfig
        dts:rk3288-firefly-lvds.dts

        $export ARCH=arm
        $export CROSS_COMPILE=arm-eabi-
        $make rockchip_linux_defconfig
        $make rk3288-firefly-lvds.img -j4

2. 问题描述
        1> 修改dts,如下git diff arch/arm/boot/dts/rk3288-firefly.dtsi:
  1. diff --git a/arch/arm/boot/dts/rk3288-firefly.dtsi b/arch/arm/boot/dts/rk3288-firefly.dtsi
  2. index 1650f98455e2..9888f0816265 100644
  3. --- a/arch/arm/boot/dts/rk3288-firefly.dtsi
  4. +++ b/arch/arm/boot/dts/rk3288-firefly.dtsi
  5. @@ -41,7 +41,6 @@
  6.   */

  7. #include "rk3288.dtsi"
  8. -
  9. / {
  10.         memory {
  11.                 device_type = "memory";
  12. @@ -171,10 +170,30 @@

  13.         sound {
  14.                 compatible = "simple-audio-card";
  15. -               simple-audio-card,name = "SPDIF";
  16. +               simple-audio-card,format = "i2s";
  17. +               simple-audio-card,name = "rockchip,rockchip-codec";
  18. +               simple-audio-card,mclk-fs = <512>;
  19. +
  20. +               simple-audio-card,dai-link@0 {
  21. +                       format = "i2s";
  22. +                       cpu {
  23. +                               sound-dai = <&i2s>;
  24. +                       };
  25. +                       codec {
  26. +                               sound-dai = <&hdmi>;
  27. +                       };
  28. +
  29. +               };
  30. +
  31.                 simple-audio-card,dai-link@1 {
  32. -                       cpu { sound-dai = <&spdif>; };
  33. -                       codec { sound-dai = <&spdif_out>; };
  34. +                       format = "i2s";
  35. +                       cpu {
  36. +                               sound-dai = <&i2s>;
  37. +                       };
  38. +
  39. +                       codec {
  40. +                               sound-dai = <&es8323>;
  41. +                       };
  42.                 };
  43.         };

  44. @@ -285,6 +304,21 @@
  45.                 WIFI,host_wake_irq = <&gpio4 30 GPIO_ACTIVE_HIGH>;
  46.                 status = "okay";
  47.         };
  48. +       rockchip-es8323 {
  49. +               compatible = "rockchip-es8323";
  50. +               dais {
  51. +                       dai0 {
  52. +                               audio-codec = <&es8323>;
  53. +                               audio-controller = <&i2s>;
  54. +                               format = "i2s";
  55. +                               //continuous-clock;
  56. +                               //bitclock-inversion;
  57. +                               //frame-inversion;
  58. +                               //bitclock-master;
  59. +                               //frame-master;
  60. +                       };
  61. +               };
  62. +       };
  63. };

  64. &cpu0 {
  65. @@ -495,6 +529,14 @@

  66. &i2c2 {
  67.         status = "okay";
  68. +       es8323: es8323@10 {
  69. +               compatible = "everest,es8323";
  70. +               reg = <0x10>;
  71. +               hp-det-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>;
  72. +               clock-names = "mclk";
  73. +               clocks = <&cru SCLK_I2S0_OUT>;
  74. +               #sound-dai-cells = <0>;
  75. +       };
  76. };

  77. &i2c4 {
复制代码

        2> 修改sound/soc/rockchip/card_info.c,这里不改编译不过
  1. diff --git a/sound/soc/rockchip/card_info.c b/sound/soc/rockchip/card_info.c
  2. index fced8016c66c..7e1d3a1e45d1 100755
  3. --- a/sound/soc/rockchip/card_info.c
  4. +++ b/sound/soc/rockchip/card_info.c
  5. @@ -62,6 +62,8 @@ int rockchip_of_get_sound_card_info_(struct snd_soc_card *card,
  6.                                      bool is_need_fmt)
  7. {
  8.         struct device_node *dai_node, *child_dai_node;
  9. +       struct device_node *bitclkmaster = NULL;
  10. +       struct device_node *framemaster = NULL;
  11.         int dai_num;

  12.         dai_node = of_get_child_by_name(card->dev->of_node, "dais");
  13. @@ -76,7 +78,8 @@ int rockchip_of_get_sound_card_info_(struct snd_soc_card *card,
  14.         for_each_child_of_node(dai_node, child_dai_node) {
  15.                 if (is_need_fmt) {
  16.                         card->dai_link[dai_num].dai_fmt =
  17. -                               snd_soc_of_parse_daifmt(child_dai_node, NULL);
  18. +                               snd_soc_of_parse_daifmt(child_dai_node, NULL,
  19. +                                                               &bitclkmaster, &framemaster);
  20.                         if ((card->dai_link[dai_num].dai_fmt &
  21.                                 SND_SOC_DAIFMT_MASTER_MASK) == 0) {
  22.                                 dev_err(card->dev,
复制代码

        3> 修改sound/soc/rockchip/rk_es8323.c,这里都是无效的修改,略过。
  1. diff --git a/sound/soc/rockchip/rk_es8323.c b/sound/soc/rockchip/rk_es8323.c
  2. index 1cbb4448bec3..31091512f971 100755
  3. --- a/sound/soc/rockchip/rk_es8323.c
  4. +++ b/sound/soc/rockchip/rk_es8323.c
  5. @@ -116,8 +116,7 @@ static const struct snd_soc_dapm_route audio_map[]= {
  6. static int rk29_es8323_init(struct snd_soc_pcm_runtime *rtd)
  7. {
  8.         struct snd_soc_dai *codec_dai = rtd->codec_dai;
  9. -       struct snd_soc_codec *codec = rtd->codec;
  10. -       struct snd_soc_dapm_context *dapm = &codec->dapm;
  11. +
  12.         int ret;
  13.          
  14.      DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
  15. @@ -128,19 +127,7 @@ static int rk29_es8323_init(struct snd_soc_pcm_runtime *rtd)
  16.                 printk(KERN_ERR "Failed to set es8323 SYSCLK: %d\n", ret);
  17.                 return ret;
  18.         }
  19. -      
  20. -    /* Add specific widgets */
  21. -#if 0
  22. -       snd_soc_dapm_new_controls(dapm, rk29_dapm_widgets,
  23. -                                 ARRAY_SIZE(rk29_dapm_widgets));
  24. -       //snd_soc_dapm_nc_pin(codec, "LOUT2");
  25. -       //snd_soc_dapm_nc_pin(codec, "ROUT2");
  26. -      
  27. -    /* Set up specific audio path audio_mapnects */
  28. -        snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
  29. -      
  30. -        snd_soc_dapm_sync(dapm);
  31. -#endif
  32. +
  33.      return 0;
  34. }

复制代码

        4> 修改sound/soc/soc-core.c,这里是调试时发现的问题,无法找到es8323的驱动,提示cpu_name = (null), cpu_dai_name = (null),不知道哪里没有修改正确。
  1. diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
  2. index 251a7e8670b7..4e14de311ec8 100644
  3. --- a/sound/soc/soc-core.c
  4. +++ b/sound/soc/soc-core.c
  5. @@ -923,6 +923,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)

  6.         dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);

  7. +       printk("!!! ASoC: dai_link->name = %s, dai_link->cpu_name = %s, dai_link->cpu_dai_name = %s\n", dai_link->name, dai_link->cpu_name, dai_link->cpu_dai_name);
  8.         cpu_dai_component.name = dai_link->cpu_name;
  9.         cpu_dai_component.of_node = dai_link->cpu_of_node;
  10.         cpu_dai_component.dai_name = dai_link->cpu_dai_name;
  11. @@ -1558,6 +1559,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
  12.         mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT);

  13.         /* bind DAIs */
  14. +       printk("!!! snd_soc_instantiate_card: card->num_links = %d\n", card->num_links);
  15.         for (i = 0; i < card->num_links; i++) {
  16.                 ret = soc_bind_dai_link(card, i);
  17.                 if (ret != 0)
复制代码

        5> 完整diff文件是 gitdiff.tar (10 KB, 下载次数: 13)
回复

使用道具 举报

61

积分

0

威望

0

贡献

技术小白

积分
61
发表于 2017-10-27 16:47:23     
你的UBUNTU声卡可以了吗?
回复

使用道具 举报

264

积分

6

威望

5

贡献

技术达人

Rank: 2

积分
264
QQ
发表于 2017-10-27 18:23:24     
shohcl 发表于 2017-10-27 16:47
你的UBUNTU声卡可以了吗?

可以了,请使用我分享的固件
http://dev.t-firefly.com/forum.p ... amp;page=1#pid62376
回复

使用道具 举报

371

积分

5

威望

0

贡献

技术达人

Rank: 2

积分
371
发表于 2017-11-15 15:51:56     
kernel-4.4 8323修复补丁

Fix_rk3288_es8323_card.rar

27.24 KB, 下载次数: 128, 下载积分: 灯泡 -1 , 经验 -1

售价: 1 灯泡  [记录]

修复补丁

回复

使用道具 举报

21

积分

0

威望

0

贡献

技术小白

积分
21
发表于 2017-11-28 18:14:12     
也遇到类似的问题
回复

使用道具 举报

10

积分

0

威望

0

贡献

游客

积分
10
发表于 2018-1-26 11:52:30     
是的,一样
回复

使用道具 举报

16

积分

0

威望

0

贡献

游客

积分
16
发表于 2018-2-4 14:33:31     
我打了你的PATCH没有用?
回复

使用道具 举报

371

积分

5

威望

0

贡献

技术达人

Rank: 2

积分
371
发表于 2018-2-7 14:32:24     
andy_y39548 发表于 2018-2-4 14:33
我打了你的PATCH没有用?

https://gitlab.com/TeeFirefly/linux-kernel   gitlab/firefly 分支
更新下代码
回复

使用道具 举报

8

积分

0

威望

0

贡献

技术小白

积分
8
发表于 2018-6-13 18:12:24     
下载不了,怎么下载呢
回复

使用道具 举报

26

积分

0

威望

0

贡献

技术小白

积分
26
发表于 2018-8-17 22:46:16     
谢谢分享!!!!!!!!!!!!!!!!!!!!!!
回复

使用道具 举报

返回列表
12
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表