TI中文支持网
TI专业的中文技术问题搜集分享网站

AM335X 如何配置 spdif 输出?

我接的引脚是 MCASP0_AXR0, 现在输出的声音全是沙沙响,但是解码器那边可以识别歌曲的采样频率.

pinmux_config 我总觉得是 punmux_config 那里出了问题,刚接触学习这些,希望指点。

[    2.034003] line:472 file:drivers/base/platform.c======drv->driver.name: snd-soc-dummy
[    2.042536] line:472 file:drivers/base/platform.c======drv->driver.name: soc-audio
[    2.050722] line:472 file:drivers/base/platform.c======drv->driver.name: spdif-dit
[    2.059062] line:472 file:drivers/base/platform.c======drv->driver.name: davinci-pcm-audio
[    2.067943] line:472 file:drivers/base/platform.c======drv->driver.name: davinci-mcasp
[    2.086728] ===========card->name: AM335X EVM SPDIF[    2.086734] card->dai_link->name: McASP0
[    2.086738] card->dai_link->stream_name: spdif
[    2.086742] card->dai_link->codec_dai_name: dit-hifi
[    2.086746] card->dai_link->codec_name: spdif-dit
[    2.086750] card->dai_link->platform_name: davinci-pcm-audio

root@am335x-evm:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SPDIF [AM335X EVM SPDIF], device 0: spdif dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

========================================================

还有一点,对于 pinmux_config 的原理我不是很懂,有没有什么说明文档吗?

我从 arch/arm/mach-omap2/board-am335xevm.c ——-> setup_pin_mux(struct pinmux_config *pin_mux) ———–>

———>omap_mux_init_signal(const char *muxname, int val)——->omap_mux_get_by_name—-> _omap_mux_get_by_name—-> …..

看的一头雾水,产生了一些疑问,比如:

/* Module pin mux for mcasp0 */
 static struct pinmux_config mcasp0_pin_mux[] = {
         {"mcasp0_aclkx.mcasp0_aclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
         {"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
         {"mcasp0_axr0.mcasp0_axr0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
         {"mcasp0_ahclkr.mcasp0_axr2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
         {NULL, 0},
  };
像 mcasp0_aclkx.mcasp0_aclkx 是 mode0.muxname 模式?

这两个部分是什么mcasp0_aclkx.mcasp0_aclkx?

比如 {"mcasp0_ahclkr.mcasp0_axr2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN}, 这一行的意思?

读了一下代码,先说说我自己的理解,mcasp0_ahclkr 是模式0 下这个名字对应的 io,  mcasp0_axr2 是后面 “OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN” 这个新

模式对应的名字,整句的意思是将模式0 下这个名字对应的 io,配置为模式 "OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN"。猜的,望指正^_^

Steven Liu1:

对于pinmux,有一个工具,下载地址和使用方法:http://processors.wiki.ti.com/index.php/Pin_Mux_Utility_for_ARM_MPU_Processors

由于在AM335x上,为了灵活配置,是有引脚复用功能的,比如你上面提到的mcasp0_aclkx,这个管脚,他除了可以配置成mcasp0_aclkx,还可以配成spi1_sclk,mmc0_sdcd, gpio3_14等多种模式,最多有8种,“mcasp0_aclkx.mcasp0_aclkx”,这种表达,点前面的mcasp0_aclkx代表着管脚,每个管脚以模式0的含义来命名,点后面的表示他现在的功能配置,这个定义就是把这个管脚配成mcasp0_aclkx,即配成模式0,所以后面就有 OMAP_MUX_MODE0的参数,其他的一些参数上下拉,input等也是在这个表达式中表示出来。

jing zhu:

回复 Steven Liu1:

请问我直接将 mcasp0_axr0 接到 spdif 的同轴输出, 是不是配置为 模式0 就可以了,还要上下拉什么吗?

jing zhu:

回复 Steven Liu1:

现在的输出是放一首歌,有部分可以一直沙沙响,久不久有点正常的音乐,.接收端识别的采样率一直为44.1k.

Steven Liu1:

回复 jing zhu:

为啥你觉得是pinmux的问题呢?配置上面的都确认是没问题的?

如果你担心pinmux的问题,在linux console里面通过devmem2 0x44e0990来查看control module里面对mcasp0_aclkx的pingmux的配置,其他的管家都能通过这样的方式来确认。

jing zhu:

回复 Steven Liu1:

sound/soc/davinci/davinci-evm.c 下面是我对这个文件的修改,贴上来看看是不是哪里做的不够?.

==================================================

 35 #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ 36                 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)

93 static int evm_spdif_hw_params(struct snd_pcm_substream *substream, 94                                 struct snd_pcm_hw_params *params) 95 { 96         struct snd_soc_pcm_runtime *rtd = substream->private_data; 97         struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 98  99         /* set cpu DAI configuration */100         return snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);101 }

111 static struct snd_soc_ops evm_spdif_ops = {112         .hw_params = evm_spdif_hw_params,113 };

==================================================

304 static struct snd_soc_dai_link my_am335x_evm_sk_dai1 = {305         .name = "McASP0",306         .stream_name = "spdif",307         .cpu_dai_name= "davinci-mcasp.0",308         .codec_dai_name = "dit-hifi",309         .codec_name = "spdif-dit",310         .platform_name = "davinci-pcm-audio",311         .ops = &evm_spdif_ops,312 };====================================================

453 static struct snd_soc_card my_am335x_evm_sk_snd_soc_card1 = {454         .name = "AM335X EVM SPDIF",455         .dai_link = &my_am335x_evm_sk_dai1,456         .num_links = 1,457 };====================================================

static struct platform_device *evm_snd_spdif_dit_device;

static struct platform_device *evm_snd_device_1;

 static int __init evm_init(void) {

          int ret;          evm_snd_spdif_dit_device = platform_device_alloc("spdif-dit",-1);         if(!evm_snd_spdif_dit_device)                 return -ENOMEM;         ret = platform_device_add(evm_snd_spdif_dit_device);         if(ret)                 goto err1;         evm_snd_device_1 = platform_device_alloc("soc-audio", 0);         if (!evm_snd_device_1)         {                 ret = -ENOMEM;                 goto err4;         }         platform_set_drvdata(evm_snd_device_1, &my_am335x_evm_sk_snd_soc_card1);         ret = platform_device_add(evm_snd_device_1);         if (ret) {                 pr_info("line======== %d,platform device add error\n",__LINE__);                 platform_device_put(evm_snd_device_1);                 goto err4;         }return 0;

……

err1:….

}

jing zhu:

回复 Steven Liu1:

arch/arm/mach-omap2/board-am335xevm.c

=====================

233 static u8 my_am335x_dit_serializer_direction0[] = { 234         TX_MODE,  INACTIVE_MODE,  INACTIVE_MODE,        INACTIVE_MODE, 235         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE, 236         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE, 237         INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE, 238 };

255 static struct snd_platform_data my_am335x_evm_snd_data0 = { 256          .tx_dma_offset  = 0x46000000,   /* McASP0 */ 257          //.rx_dma_offset        = 0x46000000, 258          .op_mode        = DAVINCI_MCASP_DIT_MODE, 259          .num_serializer = ARRAY_SIZE(my_am335x_dit_serializer_direction0), 260          .tdm_slots      = 2, 261          .serial_dir     = my_am335x_dit_serializer_direction0, 262          .asp_chan_q     = EVENTQ_2, 263          .version        = MCASP_VERSION_3, 264          .txnumevt       = 1, 265          .rxnumevt       = 1, 266  }; 693 /* Module pin mux for mcasp0  (我最迷糊的是这里)*/ 694 static struct pinmux_config my_mcasp0_pin_mux[] = { 695         {"mcasp0_aclkr.mcasp0_axr2", OMAP_MUX_MODE2 | AM33XX_PULL_DISA}, 696         {"mcasp0_ahclkx.mcasp0_ahclkx", OMAP_MUX_MODE0 | AM33XX_PULL_DISA}, 697         {"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PULL_DISA}, 698         //{"mcasp0_axr0.mcasp0_axr0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN}, 699         {"mcasp0_axr0.mcasp0_axr0", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT}, 700         {NULL, 0}, 701 };

1857 /* Setup McASP 0 */1858 static void my_mcasp0_init(int evm_id, int profile)1859 {1860         /* Configure McASP */1861         pr_info("line: %d file: %s setup_pin_mux\n",__LINE__,__FILE__);1862         setup_pin_mux(my_mcasp0_pin_mux);1863 1864         pr_info("line: %d file: %s am335x_register_mcasp(&my_am335x_evm_snd_data0, 0)\n",__LINE__,__FILE_     _);1865         am335x_register_mcasp(&my_am335x_evm_snd_data0, 0);1866 1867         return;1868 }

2516 static struct evm_dev_cfg evm_chipsee_bbbexp_dev_cfg[] = {2517         {mii1_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2518         {usb0_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2519         {usb1_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2520         {mmc0_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2521         {lcdc_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2522         {i2c1_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2523         {cap_tsc_init,     DEV_ON_BASEBOARD, PROFILE_ALL},2524         {mfd_tscadc_init,       DEV_ON_BASEBOARD, PROFILE_ALL},2525         //{mcasp0_init,   DEV_ON_BASEBOARD, PROFILE_ALL},2526         {my_mcasp0_init,   DEV_ON_BASEBOARD, PROFILE_ALL},2527         {chipsee_gpio_led_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2528         {chipsee_buzz_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2529         {chipsee_backlight_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2530         {chipsee_hmi_audio_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2531         {d_can_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2532         {uart1_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2533         {uart2_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2534         {uart4_init,  DEV_ON_BASEBOARD, PROFILE_ALL},2535         {NULL, 0, 0},2536 };2636 /* Setup Chipsee Beaglebone Black Expansion */2637 static void setup_chipsee_bbbexp(void)2638 {2639         pr_info("The board is a Chipsee Beaglebone Black Expansion.\n");2640 2641         am335x_mmc[0].gpio_wp = -EINVAL;2642 2643         _configure_device(CHIPSEE_BBBEXP, evm_chipsee_bbbexp_dev_cfg, PROFILE_NONE);2644 2645         am33xx_cpsw_init(AM33XX_CPSW_MODE_MII, NULL, NULL);2646         /* Atheros Tx Clk delay Phy fixup */2647         phy_register_fixup_for_uid(AM335X_EVM_PHY_ID, AM335X_EVM_PHY_MASK,2648                                    am33xx_evm_tx_clk_dly_phy_fixup);2649 }2677 static void am335x_evm_setup(struct memory_accessor *mem_acc, void *context)2678 {2679         /* Chipsee Beaglebone Black Expansion */2680         setup_chipsee_bbbexp();2681         return;2682 }2692 static struct at24_platform_data am335x_baseboard_eeprom_info = {2693         .byte_len       = (256*1024) / 8,2694         .page_size      = 64,2695         .flags          = AT24_FLAG_ADDR16,2696         .setup          = am335x_evm_setup,2697         .context        = (void *)NULL,2698 };

Jian Zhou:

回复 jing zhu:

请问你用的是哪家的audio codec?我们demo板上的用的是AIC3106,如果codec不一样需要在ALSA的架构下增加驱动程序

jing zhu:

回复 Jian Zhou:

我直接将引脚接到外面功放的 spdif 输入端口了.

Jian Zhou:

回复 jing zhu:

我们MCASP的引脚出来要接个音频codec(或者简单的DA),然后在接到功放才对啊。

SPDIF是个纯粹的功放么?

jing zhu:

回复 Jian Zhou:

那边有DA的,播放音乐时,可以间隔听到点音乐声,但多数都是沙沙响,而且在 alsa 库里设置别的采样率,那边DA依然显示 44.1k, 不知道是不是驱动有问题

赞(0)
未经允许不得转载:TI中文支持网 » AM335X 如何配置 spdif 输出?
分享到: 更多 (0)