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.

DM8168 audio with mcasp

I'm trying to use an I2S audio source from an ADV7604 with the mcasp 1 interface on a DM8168 Z3 board.  We've developed our own board which has the ADV7604 on it.  The ADV7604 is working with video, I can see I2S audio signals being generated by the ADV7604, I've added driver code to the linux kernel to handle the audio information, but I keep getting the message

arecord: pcm_read:1617: read error: Input/output error

when I try to do a capture with arecord.  I also get a dmesg of

capture write error (DMA or IRQ trouble?)

The arecord command I'm using is

arecord -Dhw:0,1 -t wav -f S32_LE -r 48000 -c 2 -d 5 tmp.wav

The I2S being sent by the digital HDMI source is 24 bit so I changed the driver to add support for 24 bit and tried

arecord -Dhw:0,1 -t wav -f S24_LE -r 48000 -c 2 -d 5 tmp.wav

but I get the same result.

The system is reporting the presence of the audio device correctly:

asoc: HDMI-DAI-CODEC <-> hdmi-dai mapping ok
asoc: adv7604-hifi <-> davinci-mcasp.1 mapping ok
ALSA device list:
  #0: TI81XX EVM

When I do "arecord -l" I get:

**** List of CAPTURE Hardware Devices ****
card 0: EVM [TI81XX EVM], device 1: ADV7604 adv7604-hifi-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The changes I made to the linux kernel are:

board-ti8168evm.c:

added:

static struct platform_device ti8168_adv7604_snd_driver = {
    .name    = "adv7604-sound",
    .id    = -1,
};

changed:

static u8 ti8168_mcasp1_serializer_direction[] = {
    RX_MODE,    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,
};


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

in ti8168_evm_init:

        platform_device_register( &ti8168_adv7604_snd_driver );

I didn't make any changes in devices.c since it looked right for mcasp 1.

I added an adv7604.c sound driver file to sound/soc/codecs which has the "adv7604-sound" sound driver and the "adv7604-hifi"

I also added:

#if (defined(CONFIG_VIDEO_ADV7604) || defined(CONFIG_VIDEO_ADV7604_MODULE))
        {
                .name = "ADV7604_SOC_LINK",
                .stream_name = "ADV7604",
                .cpu_dai_name= "davinci-mcasp.1",
                .codec_dai_name = "adv7604-hifi",
                .codec_name = "adv7604-sound",
                .platform_name = "davinci-pcm-audio",
                .init = evm_adv7604_init,
                .ops = &evm_ext_master_ops,
        },
#endif

to the ti81xx_evm_init array in sound/soc/davinci/davinci-evm.c

It looks like everything is recognized and connected, but I keep getting the capture write error (DMA or IRQ trouble?) message.  I can see data being sent on the mcasp signals so I would expect to end up with a wav file filled with at least noise, but I didn't expect to keep getting this timeout.  I believe the message is being generated by the routine wait_for_avail in sound/core/pcm_lib.c.  It looks like it's waiting for data to become available, but none appears.

The kernel is linux 2.6.37 with PSP 04.04.00.01.

Anybody have any suggestions?

Carl

  • Hello,

    Please check here:

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

    http://processors.wiki.ti.com/index.php/TI81XX_Audio_Driver_User_Guide#A_minimal_record_application

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

    e2e.ti.com/support/dsp/omap_applications_processors/f/42/p/73618/304267.aspx

    Regards,

    Pavel

  • Thank you for the info.  I've read through all these documents, but I had already implemented the recommendations.  Do you know what typically causes the message "capture write error (DMA or IRQ trouble?)"?  For example, is it possible that there is no LRCLK (AFSR) on the mcasp1 interface so therefore no DMA transfers occur?  I've been scouring the code and carefully examining our board, but can find nothing that seems to be the cause of the problem.  All the signals from the ADV7604 look correct and the changes in the linux code I've made to use the mcasp 1 interface look right.  What dma offset should be used for the mcasp 1 interface and are there possible issues with using the edma interface and the mcasp 1 interface together?

    Carl

  • Hi Carl,

    We have some more info here:

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/716/p/155480/573291.aspx

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

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

    I hope these would help.

    Regards,

    Pavel

  • Thank you for the info.  I've read through most of these documents and tried to follow the instructions carefully.

    A difference that we've discovered is that if we make our changes in PSP4.00.01.13.patch2 we can get the audio to work, but when we use PSP4.04.00.01 it won't work (we keep getting the capture write error (DMA or IRQ trouble?)).  Is there a difference in how a custom audio device should be setup between PSP4.00.01.13.patch2 and PSP4.04.00.01 that would explain this?

    Carl

  • Hi Carl,

    You can check the differences between these two versions of the PSP, to see which patch (or patches) are causing that error.

    The PSP 04.04.00.01 tag is here:

    http://arago-project.org/git/projects/?p=linux-omap3.git;a=shortlog;h=52752d53adda8c345650c5c7000856cffc638208

    The PSP 04.00.01.13.patch2 tag is here:

    http://arago-project.org/git/projects/?p=linux-omap3.git;a=shortlog;h=745a06cb913ad7a9ab44855aa36d8c012cd5793b

    And the newest patches for the PSP are here:

    http://arago-project.org/git/projects/?p=linux-omap3.git;a=shortlog;h=refs/heads/ti81xx-master

    Regards,

    Pavel

  • I got it working.  I realized that I had too many serializers enabled.  When I changed the board-ti8168evm.c file to only have the number of receive serializers that actually had data on them then it started working and I no longer got the capture write error.  I didn't realize this could be the problem until I read the information in the technical reference manual about McASP DMA errors in section 14.2.8.4.5.  Thank you for your help.

    Carl

  • Hi Carl,

    We are also getting same issue with McASP1 in DM8148 when we configure multiple serializer in RX_MODE.

    Could you please explain us how to resolve this DMA  issue with multiple use of  serializer?

    Thanks,
    Devang.

  • Devang,

    It's been a while since I looked at this so please bear with me while I try and remember what happened and what I did to fix it.

    I believe the issue was that I had the following array set up for mcasp1 in board-ti8168evm.c:

    static u8 ti8168_mcasp1_serializer_direction[] = {
    RX_MODE, 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,
    };

    This didn't work because I was specifying an RX_MODE serializer on mcasp1 AXR0 and an RX_MODE serializer on mcasp1 AXR1, but I wasn't using mcasp1 AXR1 at all. When I changed the array to the following:

    static u8 ti8168_mcasp1_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,
    };

    then I no longer got the DMA errors because the system was no longer expecting sound data on mcasp1 AXR1.
  • Hi Carl,

    Thanks for your response, We are able to resolve our issue. Actually as per our requirement we are using AXR0 & AXR1 to capture 4 channel audio form two I2S pins of the codec chip.

    Thanks,
    Devang.

  • Dear Devang,

    I also required to use AXR0 and AXR1 for 4 channel audio. As per current mcasp driver implementation multiple serializer is not supported. Could you please tell me how did you achieve this.

    BR/-
    Nihad
  • Hi Abdul,

    You have to add multiple serializer support to Mcasp driver.

    Thanks,
    Devang

  • Dear Devang,

    It will be really helpful if you could point which files and which functions i need to modify to add multiple serializer support.

    BR/-
    Nihad
  • Hi,

    Carl,Can you provide me the adv7604 audio driver? I now work on adv7611.

    Thank you!

    vefone

  • Here's  a dropbox link to a gzipped tar file which has the code I have.

    https://dl.dropboxusercontent.com/u/4803265/adv7604_sound.tar.gz