[i.MX] 在Linux-3.0.35上移植TVL320AIC3106的声卡驱动

[复制链接]
 楼主| aiweixin 发表于 2016-2-29 11:38 | 显示全部楼层 |阅读模式
开发板是IMX6Q,现在想在上面移植TI的tlv320aic3106声卡驱动,看论坛上有人说是参考wm8962的方法,但是具体的应该怎么实现,有没有移植过的朋友,提供一下具体的思路,谢谢!
mini1986 发表于 2016-3-1 09:17 | 显示全部楼层
论坛里有个人实现了,搜搜,你找他问问吧......
 楼主| aiweixin 发表于 2016-3-3 08:56 | 显示全部楼层
恩,我也看到了,但这个哥们一直不在线,所以我想看看,是否还有人搞过这一块?请教一下。
apollo1 发表于 2016-3-22 14:46 | 显示全部楼层
gongyuan073 发表于 2016-4-5 15:54 | 显示全部楼层
本帖最后由 gongyuan073 于 2016-4-5 15:57 编辑
  1. #include <linux/module.h>
  2. #include <linux/moduleparam.h>
  3. #include <linux/timer.h>
  4. #include <linux/interrupt.h>
  5. #include <linux/platform_device.h>
  6. #include <linux/i2c.h>
  7. #include <sound/core.h>
  8. #include <sound/pcm.h>
  9. #include <sound/soc.h>

  10. #include <asm/dma.h>
  11. #include <asm/mach-types.h>

  12. #include <asm/hardware/asp.h>
  13. #include <mach/edma.h>

  14. #include "davinci-pcm.h"
  15. #include "davinci-i2s.h"
  16. #include "davinci-mcasp.h"

  17. #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
  18.                 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)
  19. static int com335x_hw_params(struct snd_pcm_substream *substream,
  20.                          struct snd_pcm_hw_params *params)
  21. {
  22.         struct snd_soc_pcm_runtime *rtd = substream->private_data;
  23.         struct snd_soc_dai *codec_dai = rtd->codec_dai;
  24.         struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  25.         int ret = 0;
  26.         unsigned sysclk;

  27.         sysclk = 24576000;


  28.         /* set codec DAI configuration */
  29.         ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
  30.         if (ret < 0)
  31.                 return ret;

  32.         /* set cpu DAI configuration */
  33.         ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);
  34.         if (ret < 0)
  35.                 return ret;

  36.         /* set the codec system clock */
  37.         ret = snd_soc_dai_set_sysclk(codec_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
  38.         if (ret < 0)
  39.                 return ret;

  40.         return 0;
  41. }

  42. static struct snd_soc_ops com335x_ops = {
  43.         .hw_params = com335x_hw_params,
  44. };


  45. /* davinci-evm machine dapm widgets */
  46. static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
  47.         SND_SOC_DAPM_HP("Headphone Jack", NULL),
  48.         SND_SOC_DAPM_LINE("Line Out", NULL),
  49.         SND_SOC_DAPM_MIC("Mic Jack", NULL),
  50.         SND_SOC_DAPM_LINE("Line In", NULL),
  51. };

  52. /* davinci-evm machine audio_mapnections to the codec pins */
  53. static const struct snd_soc_dapm_route audio_map[] = {
  54.         /* Headphone connected to HPLOUT, HPROUT */
  55.         {"Headphone Jack", NULL, "HPLOUT"},
  56.         {"Headphone Jack", NULL, "HPROUT"},

  57.         /* Line Out connected to LLOUT, RLOUT */
  58.         {"Line Out", NULL, "LLOUT"},
  59.         {"Line Out", NULL, "RLOUT"},

  60.         /* Mic connected to (MIC3L | MIC3R) */
  61.         {"MIC3L", NULL, "Mic Bias 2V"},
  62.         {"MIC3R", NULL, "Mic Bias 2V"},
  63.         {"Mic Bias 2V", NULL, "Mic Jack"},

  64.         /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
  65.         {"LINE1L", NULL, "Line In"},
  66.         {"LINE2L", NULL, "Line In"},
  67.         {"LINE1R", NULL, "Line In"},
  68.         {"LINE2R", NULL, "Line In"},
  69. };

  70. /* Logic for a aic3x as connected on a davinci-evm */
  71. static int com335x_aic3x_init(struct snd_soc_pcm_runtime *rtd)
  72. {
  73.         struct snd_soc_codec *codec = rtd->codec;
  74.         struct snd_soc_dapm_context *dapm = &codec->dapm;

  75.         /* Add davinci-evm specific widgets */
  76.         snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets,
  77.                                   ARRAY_SIZE(aic3x_dapm_widgets));

  78.         /* Set up davinci-evm specific audio path audio_map */
  79.         snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));

  80.         /* not connected */
  81.         snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
  82.         snd_soc_dapm_disable_pin(dapm, "HPLCOM");
  83.         snd_soc_dapm_disable_pin(dapm, "HPRCOM");

  84.         /* always connected */
  85.         snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
  86.         snd_soc_dapm_enable_pin(dapm, "Line Out");
  87.         snd_soc_dapm_enable_pin(dapm, "Mic Jack");
  88.         snd_soc_dapm_enable_pin(dapm, "Line In");

  89.         return 0;
  90. }

  91. /* davinci-evm digital audio interface glue - connects codec <--> CPU */
  92. static struct snd_soc_dai_link com335x_dai = {
  93.         .name = "TLV320AIC3X",
  94.         .stream_name = "AIC3X",
  95.         .cpu_dai_name = "davinci-mcasp.1",
  96.         .codec_dai_name = "tlv320aic3x-hifi",
  97.         .codec_name = "tlv320aic3x-codec.1-001b",
  98.         .platform_name = "davinci-pcm-audio",
  99.         .init = com335x_aic3x_init,
  100.         .ops = &com335x_ops,
  101. };

  102. static struct snd_soc_card am335x_snd_soc_card = {
  103.         .name = "COM335X EVM",
  104.         .dai_link = &com335x_dai,
  105.         .num_links = 1,
  106. };

  107. static struct platform_device *evm_snd_device;

  108. static int __init com335x_tlv320_init(void)
  109. {
  110.         int ret;

  111.         evm_snd_device = platform_device_alloc("soc-audio", 0);
  112.         if (!evm_snd_device)
  113.                 return -ENOMEM;

  114.         platform_set_drvdata(evm_snd_device, &am335x_snd_soc_card);
  115.         
  116.         ret = platform_device_add(evm_snd_device);
  117.         if (ret)
  118.                 platform_device_put(evm_snd_device);

  119.         return ret;
  120. }

  121. static void __exit com335x_tlv320_exit(void)
  122. {
  123.         platform_device_unregister(evm_snd_device);
  124. }

  125. module_init(com335x_tlv320_init);
  126. module_exit(com335x_tlv320_exit);

  127. MODULE_AUTHOR("rong gang");
  128. MODULE_DESCRIPTION("EAC COM335X ASoC driver");
  129. MODULE_LICENSE("GPL");
aimybbe 发表于 2016-4-7 13:48 | 显示全部楼层

正解,我也移植果果TLV320AIC31,基本上就是这个步骤
 楼主| aiweixin 发表于 2016-4-8 13:43 | 显示全部楼层
我声卡设备注册上了,i2c测试也正常,但是i2s上没有信号,不知道是什么问题?
aimybbe 发表于 2016-4-11 08:35 | 显示全部楼层
aiweixin 发表于 2016-4-8 13:43
我声卡设备注册上了,i2c测试也正常,但是i2s上没有信号,不知道是什么问题? ...

抱歉,我的等级太低,无回复留言的权限,TLV320AIC31IRHBR 我调的是在这个,不过应该都差不多!
mini1986 发表于 2016-5-4 10:56 | 显示全部楼层
aiweixin 发表于 2016-4-8 13:43
我声卡设备注册上了,i2c测试也正常,但是i2s上没有信号,不知道是什么问题? ...

看看是不是通道没有配置好......
明时 发表于 2016-5-26 09:48 | 显示全部楼层
版主问题解决了吗? 求驱动
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

20

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部