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.

Using McASP0 instead of McASP2 for audio out

Hi,

 

Our custom HW has a different codec instead of tlv320aic3x in dm814x evm

Connection to codec is through Mcasp 0 instead of  Mcasp 2(used in dm814x evm)

Codec is controlled through a used space i2c driver instead of  i2c slave driver in kernel.

Currenlty we need a playback path

 

The following changes are made for this 

file: . \arch\arm\mach-omap2\board-ti8148evm.c 

Pin muxing are made for macasp0

       omap_mux_init_signal("mcasp0_aclkr", OMAP_PIN_OUTPUT);

       omap_mux_init_signal("mcasp0_fsr", OMAP_PIN_OUTPUT);

       omap_mux_init_signal("mcasp0_axr0", OMAP_PIN_OUTPUT);

       omap_mux_init_signal("mcasp0_axr1", OMAP_PIN_OUTPUT);

       omap_mux_init_signal("mcasp0_axr2", OMAP_PIN_OUTPUT);

       omap_mux_init_signal("mcasp0_axr3", OMAP_PIN_INPUT);

       omap_mux_init_signal("mcasp0_axr4", OMAP_PIN_INPUT);

       omap_mux_init_signal("mcasp0_axr5", OMAP_PIN_INPUT);

 

/* Only Playback path for now */

static u8 ti8148_iis_serializer_direction[] = {

TX_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 ti8148_evm_snd_data = {

  .tx_dma_offset = 0x46000000,

   .rx_dma_offset = 0x46000000,

   .op_mode = DAVINCI_MCASP_IIS_MODE,

   .num_serializer = ARRAY_SIZE(ti8148_iis_serializer_direction),

   .tdm_slots = 2, 

    .serial_dir = ti8148_iis_serializer_direction,

    .asp_chan_q = EVENTQ_2,

     .version = MCASP_VERSION_2,

     .txnumevt = 1,

     .rxnumevt = 0,

};

 

Not sure about the setting 

.asp_chan_q = EVENTQ_2,

In \sound\soc\davinci\davinci-evm.c

 

a dummy platform device ad73311-codec was added so that the codec will not control the audio path. In our there is a user space driver control the codec 

 

static struct snd_soc_dai_link ti81xx_evm_dai = {

.name = "ad73311",

.stream_name = "AD73311",

.cpu_dai_name = "davinci-mcasp.0",

.codec_dai_name = "ad73311-hifi",

.codec_name = "ad73311-codec",

.platform_name = "davinci-pcm-audio",

.ops = &evm_ops,

};

 

 

and evm_hw_params modified as follows

 

static int evm_hw_params(struct snd_pcm_substream *substream,

struct snd_pcm_hw_params *params)

{

struct snd_soc_pcm_runtime *rtd = substream->private_data;

struct snd_soc_dai *codec_dai = rtd->codec_dai;

struct snd_soc_dai *cpu_dai = rtd->cpu_dai;

int ret = 0;

unsigned sysclk;

 

/* ASP1 on DM355 EVM is clocked by an external oscillator */

if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||

   machine_is_davinci_dm365_evm())

sysclk = 27000000;

 

/* ASP0 in DM6446 EVM is clocked by U55, as configured by

* board-dm644x-evm.c using GPIOs from U18.  There are six

* options; here we "know" we use a 48 KHz sample rate.

*/

else if (machine_is_davinci_evm())

sysclk = 12288000;

 

else if (machine_is_davinci_da830_evm() ||

machine_is_davinci_da850_evm() ||

machine_is_ti8168evm() ||

machine_is_ti8148evm())

sysclk = 24576000;

 

else

return -EINVAL;

 

 

/* set cpu DAI configuration */

ret = snd_soc_dai_set_fmt(cpu_dai, AUDIO_FORMAT);

if (ret < 0)

return ret;

return 0;

}

 

and the AUDIO_FORMAT is changed as follows to e  use J4 as clock master instead of codec

 

#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \

SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_NB_NF)

 

with these changes  Alsa link is detected

<-----capture---->

asoc: ad73311-hifi <-> davinci-mcasp.0 mapping ok

 platform_device_add

ALSA device list:

  #0: TI81XX EVM

TCP cubic registered

<---end capture--->

 

Are these changes ok? Is the EVENTQ_2  correct?  Where can we find these EventQ IDs documented?

 

When I ran aplay <xxx.wav>

It is  hanging. 

 

Thanks and regards,

Ishaqe

 

  • Hi Ishaqe,

        Please change the DMA event mapping for McASP & test.

    file: ./arch/arm/mach-omap2/devices.c

    static struct resource ti81xx_mcasp_resource[] = {

            {

                    .name = "mcasp",

                    .start = TI81XX_ASP0_BASE,

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

                    .flags = IORESOURCE_MEM,

            },

            /* TX event */

            {

                    .start = TI81XX_DMA_MCASP0_AXEVT,

                    .end = TI81XX_DMA_MCASP0_AXEVT,

                    .flags = IORESOURCE_DMA,

            },

            /* RX event */

            {

                    .start = TI81XX_DMA_MCASP0_AREVT,

                    .end = TI81XX_DMA_MCASP0_AREVT,

                    .flags = IORESOURCE_DMA,

            },

    };

     

    static struct platform_device ti81xx_mcasp_device = {

            .name = "davinci-mcasp",

            .id = 0,

            .num_resources = ARRAY_SIZE(ti81xx_mcasp_resource),

            .resource = ti81xx_mcasp_resource,

    };

     

    Regards,

    Amit

  • Hi Ishaqe,

    TI814x has specific mux bit definitions than generic omap2, for the following lines, I think you should use TI814X_INPUT_EN instead of OMAP_PIN_INPUT

    omap_mux_init_signal("mcasp0_axr3", OMAP_PIN_INPUT);

    omap_mux_init_signal("mcasp0_axr4", OMAP_PIN_INPUT);

    omap_mux_init_signal("mcasp0_axr5", OMAP_PIN_INPUT);

    I digest below source code from /arch/arm/mach-omap2/mux.h (PSP 4.1.0.6) for your reference.

    /* 34xx specific mux bit defines */
    #define OMAP_INPUT_EN   (1 << 8)
    #define OMAP_OFF_EN   (1 << 9)
    #define OMAP_OFFOUT_EN   (1 << 10)
    #define OMAP_OFFOUT_VAL   (1 << 11)
    #define OMAP_OFF_PULL_EN  (1 << 12)
    #define OMAP_OFF_PULL_UP  (1 << 13)
    #define OMAP_WAKEUP_EN   (1 << 14)

    /* 44xx specific mux bit defines */
    #define OMAP_WAKEUP_EVENT  (1 << 15)

    /* TI814x specific mux bit definitions */
    #define TI814X_PULL_DIS   (1 << 16)
    #define TI814X_PULL_UP   (1 << 17)
    #define TI814X_INPUT_EN   (1 << 18)
    #define TI814X_SLEW_SLOW  (1 << 19)

    /* Active pin states */
    #define OMAP_PIN_OUTPUT   0
    #define OMAP_PIN_INPUT   OMAP_INPUT_EN
    #define OMAP_PIN_INPUT_PULLUP  (OMAP_PULL_ENA | OMAP_INPUT_EN \
          | OMAP_PULL_UP)
    #define OMAP_PIN_INPUT_PULLDOWN  (OMAP_PULL_ENA | OMAP_INPUT_EN)

    Best Regards,

    Luke Lin

  • Hi,

    Whether this problem is resolved?

    I am also getting similar kind of a behaviour in DM8168 based board.

    All the settings given in this mail chain is tried.

    Any extra setting required.

    Regards,

    Nitish James

  • I'm using the AIC3106 codec and aplay <music.wav> works perfectly fine with that.  I defined a new codec driver named adv7604.  I used the steps mentioned in:

    http://processors.wiki.ti.com/index.php/TI81xx_PSP_Porting_Guide and guidelines from here:

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

    I seem to have issues while I use the new device/codec for playback:

    root@arago:~# aplay -l
    **** List of PLAYBACK Hardware Devices ****
    card 0: EVM [TI81XX EVM], device 0: AIC3X tlv320aic3x-hifi-0 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 0: EVM [TI81XX EVM], device 1: hdmi HDMI-DAI-CODEC-1 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0
    card 0: EVM [TI81XX EVM], device 2: ADV7604 adv7604-hifi-2 []
      Subdevices: 1/1
      Subdevice #0: subdevice #0

    This is the message during bootup:

    notify_init : notify drivercreated  for  remote proc id 2 at physical Address 0xbf900000
    asoc: tlv320aic3x-hifi <-> davinci-mcasp.2 mapping ok
    asoc: HDMI-DAI-CODEC <-> hdmi-dai mapping ok
    asoc: adv7604-hifi <-> davinci-mcasp.2 mapping ok
    ALSA device list:
      #0: TI81XX EVM

    Now trying playback:

    root@arago:~# aplay -vv -Dhw:0,2 dt_32bars_89rap.wav
    Playing WAVE 'dtasoc: machine hw_params failed
    _32bars_89rap.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
    aplay: set_params:1041: Unable to install hw params:
    ACCESS:  RW_INTERLEAVED
    FORMAT:  S16_LE
    SUBFORMAT:  STD
    SAMPLE_BITS: 16
    FRAME_BITS: 32
    CHANNELS: 2
    RATE: 44100
    PERIOD_TIME: (46439 46440)
    PERIOD_SIZE: 2048
    PERIOD_BYTES: 8192
    PERIODS: 16
    BUFFER_TIME: (743038 743039)
    BUFFER_SIZE: 32768
    BUFFER_BYTES: 131072
    TICK_TIME: 0

    If I use the default device, it plays back without any problems:

    root@arago:~# aplay -vv -Dhw:0,1 dt_32bars_89rap.wav
    Playing WAVE 'dtWrapper Enabled...
    _32bars_89rap.wav' : Signed 16 bit Little EndianStart audio transfer...
    , Rate 44100 Hz, Stereo
    Hardware PCM card 0 'TI81XX EVM' device 1 subdevice 0
    Its setup is:
      stream       : PLAYBACK
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 44100
      exact rate   : 44100 (44100/1)
      msbits       : 16
      buffer_size  : 32768
      period_size  : 2048
      period_time  : 46439
      tstamp_mode  : NONE
      period_step  : 1
      avail_min    : 2048
      period_event : 0
      start_threshold  : 32768
      stop_threshold   : 32768
      silence_threshold: 0
      silence_size : 0
      boundary     : 1073741824
      appl_ptr     : 0
      hw_ptr       : 0
    ##################################################+| 98%
    Wrapper disabled...
    Aborted by signal Interrupt...

    But if I try to capture a sound from HDMI input (coming out from my PC), it seems to capture some audio but nothing is heard on playback.  I can hear only noise:

    root@arago:~# amixer cset name='PGA Capture Volume' 100%,100%
    numid=37,iface=MIXER,name='PGA Capture Volume'
      ; type=INTEGER,access=rw---R--,values=2,min=0,max=119,step=0
      : values=119,119
      | dBscale-min=0.00dB,step=0.50dB,mute=0
    root@arago:~# arecord -d 60 -f cd -t wav -c 2 -vv -Dhw:0 sample_capture.wav
    Recording WAVE 'sample_capture.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
    Hardware PCM card 0 'TI81XX EVM' device 0 subdevice 0
    Its setup is:
      stream       : CAPTURE
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 44100
      exact rate   : 44100 (44100/1)
      msbits       : 16
      buffer_size  : 32768
      period_size  : 2048
      period_time  : 46439
      tstamp_mode  : NONE
      period_step  : 1
      avail_min    : 2048
      period_event : 0
      start_threshold  : 1
      stop_threshold   : 32768
      silence_threshold: 0
      silence_size : 0
      boundary     : 1073741824
      appl_ptr     : 0
      hw_ptr       : 0
    ###################+                               | 37%overrun!!! (at least 3157.450 ms long)
    Status:
      state       : XRUN
      trigger_time: 1259786280.185592701
      tstamp      : 1259786283.342990894
      delay       : 0
      avail       : 32768
      avail_max   : 32768
    ###################+                               | 37%
    root@arago:~# aplay -vv -Dhw:0,1 sample_capture.wav
    Playing WAVE 'saWrapper Enabled...
    mple_capture.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
    Hardware PCM card 0 'TI81XX EVM' device 1 subdevice 0
    Its setup is:
      stream       : PStart audio transfer...
    LAYBACK
      access       : RW_INTERLEAVED
      format       : S16_LE
      subformat    : STD
      channels     : 2
      rate         : 44100
      exact rate   : 44100 (44100/1)
      msbits       : 16
      buffer_size  : 32768
      period_size  : 2048
      period_time  : 46439
      tstamp_mode  : NONE
      period_step  : 1
      avail_min    : 2048
      period_event : 0
      start_threshold  : 32768
      stop_threshold   : 32768
      silence_threshold: 0
      silence_size : 0
      boundary     : 1073741824
      appl_ptr     : 0
      hw_ptr       : 0
    ###################+                               | 37%
    Wrapper disabled...
    root@arago:~#

    Any ideas or help would be greatly appreciated.  Thanks,

    Bharadwaj

  • Bharadwaj,

    From you logs i found that you have added a new codec and using the same mcasp2 instance for interfacing with the new codec.

    asoc: tlv320aic3x-hifi <-> davinci-mcasp.2 mapping ok
    asoc: HDMI-DAI-CODEC <-> hdmi-dai mapping ok
    asoc: adv7604-hifi <-> davinci-mcasp.2 mapping ok

    The error you are getting while trying to use the new added codec is" aplay -vv -Dhw:0,2 dt_32bars_89rap.wav" is due to the mismatch in the hardware params supported by the McASP and the newly added codec is not matching with the test file used for the playback. The file you are trying to play is a signed 16 bit Little Endian, Rate 44100 Hz, Stereo file which need a support from the codec

    Please check these capabilities are supported by the codec.

    Regards,

    Deepu Raj



  • Hi Deepu Raj,

    Thanks for your reply. I fixed the issue & found that all 3 devices can be on the same McASP because one is analog audio & the other one is digital audio.  The way we got it to work was the McASP needed to match with the particular HDMI input we were using (HDMI 1 or 2 or 3) & in our case, I was testing only with HDMI 1 while HDMI 3 was supposed to be used as per the schematics. Both the aplay & arecord work fine with this change.  Thanks,

    Bharadwaj

  • Hello Bharadwaj!!!

    can you tell more detail??? I'm newbie and I need to capture audio from HDMI Input in DM8168, but it have only noise!!!

    Thanks a lot!!!!

  • Here's how I got it to work:

    1. Connect the HDMI input to correct HDMI in your board. It might be HDMI 1 or 2 or 3.

    2. Check MCLK freq 24.5MHz, LRCLK 48KHz, SCLK 3MHz

    3. Default HDMI audio output to just HDMI (DVD quality)

    4. root@arago:~# arecord -Dhw:<HDMI_device>,0 -f dat | aplay -Dhw:<HDMI_device>,0 -f dat

    Let me know if that works.


  • Thaks Bharadwaj!!!

    but how can I check freq of MCLK, LRCLK, SCLK?. I have looked for in davinci-hdmi.c and board-dm8168z3.c, but I can not find it to modify?

  • You've to look at it physically on the board using a scope.

  • Thanks!!!

    I have got it!!!