This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8148 McASP4 receive audio from tvp5158

Other Parts Discussed in Thread: TVP5158

Hi all,

         I have learned Davinci for a short time. I need to sample one channel analog audio signal input from tvp5158 now. I have connected the I2S ports of tvp5158 to McASP4 ports of DM8148. I choose DVRRDK_04.00.00.03 as my development environment. But I find that there is no driver of McASP4 in the Kernel. So I want to add one in it by myself. I imitated McASP2 driver and added many codes. Tvp5158 can output signal through I2S ports in I2S format. I use the driver of tvp5158 in the Kernel and change nothing. I use “arecord” tool of ALSA to record the audio which come from tvp5158. The command is: “arecord -Dplughw:0,0 -r16000 -f S16_LE test.wav”

Unfortunately, I can achieve nothing. I can hear nothing when I play the “test.wav” but noise. Can you help me about this? Whether my method of test or the driver of McASP4 is wrong? I appreciate any help of everyone.

The codes I added or changed:

In arch/arm/plat-omap/include/plat/Asp.h added:

#define TI81XX_ASP4_BASE    0x4A1A8000

#define     TI81XX_DMA_MCASP4_AXEVT        62

#define     TI81XX_DMA_MCASP4_AREVT       63

#define     TI81XX_ASP4_RX_INT      TI81XX_IRQ_MCASP4_RX

#define     TI81XX_ASP4_TX_INT      TI81XX_IRQ_MCASP4_TX

In arch/arm/plat-omap/include/plat/Irqs-ti81xx.h add:

#define     TI81XX_IRQ_MCASP4_TX         108

#define     TI81XX_IRQ_MCASP4_RX        109

In arch/arm/plat-omap2/Devices.c :

static const s16 ti814x_dma_rsv_chans[][2] = {

         /* (offset, number) */

         {0, 2},

         {14, 2},

         {26, 6},

         {48, 4},

         {56, 6}, //change {56,8} to {56,6}

         {-1, -1}

};

static const s16 ti814x_dma_rsv_slots[][2] = {

         /* (offset, number) */

         {0, 2},

         {14, 2},

         {26, 6},

         {48, 4},

         {56, 6}, //change {56,8} to {56,6}

         {64, 127},

    {248, 264},

         {-1, -1}

};

static u8 tvp5158_iis_serializer_direction[] = {

         RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,

         INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,

         INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,

         INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,   INACTIVE_MODE,

};

static struct snd_platform_data tvp5158_snd_data = {

         .tx_dma_offset         = 0x4A1AB000,//change

         .rx_dma_offset         = 0x4A1AB000,//change

         .asp_chan_q    = EVENTQ_0,

         .tdm_slots        = 2, /* number of channels.*/

         .op_mode         = DAVINCI_MCASP_IIS_MODE,

         .num_serializer = ARRAY_SIZE(tvp5158_iis_serializer_direction),

         .serial_dir         = tvp5158_iis_serializer_direction,

         .version    = MCASP_VERSION_2,

         .txnumevt         = 1,//change 32 to 0

         .rxnumevt         = 1,// change 32 to 1

};

static struct platform_device ti81xx_mcasp_tvp5158_device = {

         .name = "davinci-mcasp", /* driver name */

         .id = 4,// change 0 to 4

         .dev = {

                   .platform_data = &tvp5158_snd_data,

                   },

         .num_resources = ARRAY_SIZE(ti81xx_mcasp4_resource),//change

         .resource = ti81xx_mcasp4_resource,//change

};

Add these:

static struct resource ti81xx_mcasp4_resource[] = {

         {

                   .name = "mcasp",

                   .start = TI81XX_ASP4_BASE,

                   .end = TI81XX_ASP4_BASE + (SZ_1K * 12) - 1,

                   .flags = IORESOURCE_MEM,

         },

         /* TX event */

         {

                   .start = TI81XX_DMA_MCASP4_AXEVT,

                   .end = TI81XX_DMA_MCASP4_AXEVT,

                   .flags = IORESOURCE_DMA,

         },

         /* RX event */

         {

                   .start = TI81XX_DMA_MCASP4_AREVT,

                   .end = TI81XX_DMA_MCASP4_AREVT,

                   .flags = IORESOURCE_DMA,

         },

};

In sound/soc/davinci/Ti81xx-evm.c :

static struct snd_soc_dai_link ti81xx_mcasp_dai[] = {

         {

                   .name = "TVP5158AUDIO",

                   .stream_name = "TVP-PCM",

                   .cpu_dai_name= "davinci-mcasp.4",//change "davinci-mcasp.4" to "davinci-mcasp.0"

                   .codec_dai_name = "tvp5158-hifi",

                   .platform_name ="davinci-pcm-audio",

                   .codec_name = "tvp5158-audio",

                   .ops = &ti81xx_evm_ops,

         },

         {

                   .name = "TLV320AIC3X",

                   .stream_name = "AIC3X",

#if defined(CONFIG_MACH_TI810XEVM) || defined(CONFIG_MACH_TI810XDVR)|| defined (CONFIG_MACH_UD8107_DVR)

                   .cpu_dai_name= "davinci-mcasp.1",

#else

                 .cpu_dai_name= "davinci-mcasp.2",

#endif

                   .codec_dai_name = "tlv320aic3x-hifi",

                   .codec_name = "tlv320aic3x-codec.1-0018",

                   .platform_name = "davinci-pcm-audio",

                   .init = ti81xx_evm_aic3x_init,

                   .ops = &ti81xx_evm_ops,

         },

};

In Board-ti8148evm.c added:

TI814X_MUX(MCASP4_CLKX, OMAP_MUX_MODE0), // Set up pin as McASP4_ACLKX.

TI814X_MUX(MCASP4_FSX, OMAP_MUX_MODE0), //Set up pin as McASP4_AFSX.

TI814X_MUX(MCASP4_AXR0, OMAP_MUX_MODE0), // Set up pin as McASP4_AXR0.

In Davinci-mcasp.c :

static struct snd_soc_dai_driver davinci_mcasp_dai[] = {

         {

                   .name                = "davinci-mcasp.0",

                   .playback = {

                            .channels_min = 2,

                            .channels_max        = 2,

                            .rates                = DAVINCI_MCASP_RATES,

                            .formats           = SNDRV_PCM_FMTBIT_S8 |

                                                        SNDRV_PCM_FMTBIT_S16_LE |

                                                        SNDRV_PCM_FMTBIT_S32_LE,

                   },

                   .capture           = {

                            .channels_min         = 2,

 

#if defined(CONFIG_SND_TI81XX_SOC_UDDVR) || defined(CONFIG_SND_TI81XX_SOC_EVM)

                            .channels_max        = 16,

#else                           

                            .channels_max        = 2,

#endif

                            .rates                = DAVINCI_MCASP_RATES,

                            .formats   = SNDRV_PCM_FMTBIT_S8 |

                                                        SNDRV_PCM_FMTBIT_S16_LE |

                                                        SNDRV_PCM_FMTBIT_S32_LE,

                   },

                   .ops                   = &davinci_mcasp_dai_ops,

 

         },

         {

                   "davinci-mcasp.1",

                   .playback         = {

                            .channels_min = 1,

                            .channels_max         = 384,

                            .rates                 = DAVINCI_MCASP_RATES,

                            .formats   = SNDRV_PCM_FMTBIT_S16_LE,

                   },

                   .ops                   = &davinci_mcasp_dai_ops,

         },

         /*add*/

         {

                   .name                = "davinci-mcasp.4",

                   .capture           = {

                            .channels_min         = 2,

                            .channels_max        = 16,.

                            .rates                = DAVINCI_MCASP_RATES,

                            .formats   = SNDRV_PCM_FMTBIT_S16_LE,

                   },

                   .ops                   = &davinci_mcasp_dai_ops,

         },

         /*end*/

};

 

The configuration of tvp5158:

0xfe:0x01    choose the first channel

0xc0:0x00   audio sample rate is 16KHz

0xc4:0x01   Audio Mixer Select

0xc8:0x00   standalone operation

0xc3:0x68   SD_R output,I2S Master,64fS, 16bit PCM

0xfe:0x01    choose the first channel

0xc1:0x88  Volume 0db

0xc2:0x88  Volume 0db

0xc5:0x00  close the muter

 

  • Terry,

    I can provide you the below pointers, hope will be in help:

    http://processors.wiki.ti.com/index.php/TI81xx_PSP_Porting_Guide#Audio_driver_.28McASP.29

    http://processors.wiki.ti.com/index.php/TI81XX_PSP_AUDIO_Driver_User_Guide

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/351039.aspx

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/357296.aspx

    http://e2e.ti.com/support/data_converters/videoconverters/f/376/t/97108.aspx

    http://e2e.ti.com/support/embedded/linux/f/354/t/186390.aspx

    Regards,
    Pavel

  • Pavel,

    Thanks for your reply. But I think I have done anything accroding to the web pages that you have provided. Is there any differences between McASP2 and McASP4 ? Whether the driver of tvp5158 and McASP4 in kernel could work or not ? How to test?