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.

Connecting a codec to McASP in Linux 2.6.37

Other Parts Discussed in Thread: TEST2

(Since the original post mysteriously disappeared, I'm retrying this question.)

We are using the (Arago) linux kernel 2.6.37 (also labelled v2.6.37_DAVINCIPSP_03.21.00.04). There are several TLV320AIC3256 codec connected to an OMAP-L138 SoM board via I2C and McASP. The board is based on the DA850 EVM.

To support the codec, I've backported the tlv320aic32x4 driver from the 2.6.39 linux kernel.

The I2C part is configured correctly, and I can get and set mixer components and other settings via I2C to the codec.

However, setting up the McASP data path is a complete riddle, and I need help to get this to work.

In the board files, the following structs "glue" the codec to the audio data transfer unit:

static struct snd_soc_dai_link da8xx_evm_dai[] = {
        {
                .name = "TLV320AIC3X-1",
                .stream_name = "AIC3X-1",
                .cpu_dai_name= "davinci-mcasp.0",
                .codec_dai_name = "tlv320aic32x4-hifi",
                .codec_name = "tlv320aic32x4.11-0018",
                .platform_name = "davinci-pcm-audio",
                .init = evm_aic3x_init_analog,
                .ops = &evm_ops,
        },
        {
                .name = "TLV320AIC3X-2",
                .stream_name = "AIC3X-2",
                .cpu_dai_name= "davinci-mcasp.0",
                .codec_dai_name = "tlv320aic32x4-hifi",
                .codec_name = "tlv320aic32x4.12-0018",
                .platform_name = "davinci-pcm-audio",
                .init = evm_aic3x_init_analog,
                .ops = &evm_ops,
        },

The string "davinci-mcasp.0" refers to the struct in sound/soc/davinci/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,
                        .channels_max   = 2,
                        .rates          = DAVINCI_MCASP_RATES,
                        .formats        = SNDRV_PCM_FMTBIT_S8 |
                                                SNDRV_PCM_FMTBIT_S16_LE |
                                                SNDRV_PCM_FMTBIT_S32_LE,
                },
                .ops            = &davinci_mcasp_dai_ops,

        },

And in the board config files, there is also a struct that configures the McASP ports:

static u8 da850_iis_serializer_direction[] = {
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  RX_MODE,        TX_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
};

static struct snd_platform_data da850_evm_snd_data = {
        .tx_dma_offset  = 0x2000,
        .rx_dma_offset  = 0x2000,
        .op_mode        = DAVINCI_MCASP_IIS_MODE,
        .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
        .tdm_slots      = 2,
        .serial_dir     = da850_iis_serializer_direction,
        .asp_chan_q     = EVENTQ_1,
        .version        = MCASP_VERSION_2,
        .txnumevt       = 1,
        .rxnumevt       = 1,
};

...
da8xx_register_mcasp(0, &da850_evm_snd_data);

Now this part is a complete mystery. To have multiple CODECs, do i need to register multiple instances of the McASP driver and fill in the serializer structs for each? And if not, how does it know which input is for which codec? And what are all the fields? There's no documentation whatsoever, so the above was my best guess to get at least one codec functioning. It sort of seems to do something, but all samples are zero and I get lots of overrun errors when using arecord to capture data from it.

  • No anwers because

    - The problem isn't clear?

    - There's no-one who knows the answer?

    - It's the holiday season?

    In any case, I'd also welcome any suggestions as to where I could possibly find some more information or help!

  • Try asking on the alsa-devel list.

  • Hi Mike,

    You can interface multiple codecs to single McASP. If you register two codec to McASP you will get two playback nodes PCMC0D0p and PCMC0D1p using each node you can play song(aplay hw:0,0 test1.mp3, aplay hw:0,1 test2.mp3). In this case you will be able to play one song at a time either using PCMC0D0p or PCMC0D1p. If you try to do simultaneously you will get the resource error as there are no DAI available at the platform side(only one McASP). If you have two McASP you can interface one codec each to two McASP. In this case you will be able to play two song simultaneously as you have two platform DAI.

    Hope this helps.

    Regards,

    Vishwas HC  

  • "If you have two McASP"

    By that, do you mean actually having special hardware? If so, what's the point of having 16 McASP pins if can only use one?

    Or do you mean creating multiple instances of the mcasp driver? If so, how does one do that?

    For now, I would be delighted to get just ONE working, which so far has proved impossible. Any ideas on that?

  • Yes it is  two McASP engine. If you want to play two song simultaneously you need to have two McASP engine in the present ASoC framework, according to my knowledge.

    If you want to achive this by creating multiple instance of the McASP driver you need to modify DMA part of the platform driver. 

     

  • So in short, the hardware can do it but there's no support in software yet?

    "you need to modify DMA part of the platform driver"

    By that statement, do you mean "spend a few weeks writing a bunch of code" or "add some configuration data"?

    Well, I feel stupid, but I still don't understand it.

  • Yes you are right.

    It is not just configuration addition. To my knowledge, ASoC framework does not support using single platform DAI interface to multiple codec . You need to modify the driver completely which fits to ASoC framework, which I feel complex.  

  • Okay, so for multiple DACs i'll have to do more work.

    But what about getting just ONE codec to work with the McASP layer? I haven't succeeded in getting any audio data in or out, whatever I tried. Using arecord will generate a file filled with all zeroes.