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.

Adding 4 channel capture support into McASP0

Hi,

We are working on DM8148 based customized board in our project. We are able to capture single stereo channel perfectly. We have to add support to capture 4 stereo channels on our system.

We are using EZSDK 5.05.01.04 and linux kernel "linux-2.6.37-psp04.04.00.01".

Could you please suggest how we can implement this functionality on our system?

Thanks,
Devang.

  • And the below e2e thread is for 16 channels:

    e2e.ti.com/.../1366410
  • Hi Pavel,


    Thanks for your reply,

    We refer links you suggested:

    And we did changes in kernel accordingly.

    But we are facing issue when we trying to capture 4 channel audio with below Aplication exapmle.

    We are getting below errors:

    cannot set channel count (Invalid argument)
    root@dm814x-evm:/home/cvic#

    Please suggest.

    Thanks,
    Devang

  • Devang,

    Is it working fine with snd_pcm_hw_params_set_channels (playback_handle, hw_params, 2)?

    And does it fail when snd_pcm_hw_params_set_channels (playback_handle, hw_params, 4)?

    BR
    Pavel

  • Hi Pavel,

    Yes, It's working fine with 2 channel audio capture. but we are getting invalid argument error with 4 channel audio capture.

    Thanks,
    Devang.
  • Devang,

    Note that the audio codec that comes with EVM supports 2 channels max:

    linux-kernel/sound/soc/codecs/tlv320aic3x.c - codec driver for TI EVM, set by default with 2 channels for both capture/playback

    .playback .channels_max = 2

    .capture .channels_max = 2

    You should check the datasheet of your audio codec that it supports 4 channels and set the channels_max to 4

    Set also:

    linux-kernel/sound/soc/davinci/davinci-pcm.c - set by default with 2 channels for both capture/playback

    pcm_hardware_playback .channels_max = 2,

    pcm_hardware_capture .channels_max = 2 //set to 4

    linux-kernel/sound/soc/davinci/davinci-mcasp.c - platform driver, set by default with 2 channels for both capture/playback

    .playback .channels_max = 2

    .capture .channels_max = 2 //set to 4
  • Try also with modifying board-evm8148.c

    static struct snd_platform_data ti8148_evm_snd_data = {

    .tdm_slots = 2, // set to 4
  • Hi Pavel,


    Thanks for the support,  We have made above changes as you suggested.

    Now we are able to capture audio raw file by giving number of channels 4.Now could you please suggest  how can we identify this is 4 channel audio?

    Thanks,
    Devang.

  • Devang,

    You can try with aplay, playback application or audio analyzer tool

    BR
    Pavel

  • Hi Pavel,


    We are able to capture 4 channel audio now in our system,

    But we are facing issue with sampling rate of audio. Can you please suggest settings required to capture 4 channel audio at 48khz sample rate?


    Thanks,
    Devang.

  • Devang,

    Devang panchal said:
    But we are facing issue with sampling rate of audio.

    Could you be more specific, what issue you are facing?

    Devang panchal said:
    Can you please suggest settings required to capture 4 channel audio at 48khz sample rate?

    Are you able to capture 2 channels (stereo) at 48KHz sample rate successfully? Are you able to capture 4 channels (multichannel) for other sample rates (8KHz, 11.025KHz, 16KHz, 22.05KHz, 32KHz, 44.1KHz, 64KHz, 88.2KHz, 96KHz) successfully? I mean is this issue only for 48MHz sample rate?


    Please also have a try with the latest linux kernel (which has some audio fixes):

    BR
    Pavel

  • Hi Pavel,


    Yes, We are able to capture 2 channel audio at 48 khz.

    But when we are going to capture 4 channel at 48 khz the audio is not captured properly at 48khz. means the audio raw file play correctly at 24khz sample rate.

    Thanks,
    Devang.

  • Devang,

    Devang panchal said:
    audio is not captured properly at 48khz

    Could you be more specific, can you provide console log output?

    Are you able to capture 4 channels (multichannel) for other sample rates (8KHz, 11.025KHz, 16KHz, 22.05KHz, 32KHz, 44.1KHz, 64KHz, 88.2KHz, 96KHz) successfully?

    Have you tried with the latest linux kernel?

    BR
    Pavel

  • Hi Pavel,

    Yes. We are able to capture 4 channel audio with different sample rates. But the audio file only play correctly at 24 khz sample rates with 4 channel with audio analyzer tool.

    Thanks,
    Devang.

  • Devang,

    Devang panchal said:
    But the audio file only play correctly at 24 khz sample rates with 4 channel

    Can you provide more info for the 48KHz non-working case, do you have errors in the console output?

    Have you tried with the latest linux kernel?

    BR
    Pavel

  • Hi Pavel,

    We are not getting any errors while capture the 4 channel audio but the issue is we are not getting actual audio at 48 khz.
    We are working on DM8148 customize board so it will take time to test with latest kernel on our board.

    Thanks,
    Devang.
  • Devang,

    Devang panchal said:
    We are not getting any errors while capture the 4 channel audio but the issue is we are not getting actual audio at 48 khz.

    Do you have any errors reported in console during playing 4 channel audio at 48KHz or you just do not hear any sound?

    BR
    Pavel

  • Hi Pavel,
    Yes, We are not getting any errors while capturing audio. Also we can here audio at 48 khz but it is faster than original audio. We can hear audio perfectly if we play that audio at 24 khz.
  • Devang,

    Devang panchal said:
    Yes, We are not getting any errors while capturing audio.

    I have asked for errors when playing audio, do you have console errors when playing the audio?

    Devang panchal said:
    Also we can here audio at 48 khz but it is faster than original audio.

    Note that sampling frequencies for playback and capture streams should be same. What is your period size? Can you try with period size of 64.

    Regards,
    Pavel

  • Hi Pavel,

    We are not getting any errors while also playing audio.

    We captured 4channel audio by arecord by below command at 48 khz:
    arecord -f dat -t wav -c 4 audio.wav -D hw:0,0

    But we are not getting actual audio at 48 khz while playing in audio analyzer tool at 48 khz. instead of 48khz if we set 24khz then it's play perfectly. That is our problem.

    Do we have to change mcasp capture clock?

    Thanks,
    Devang.
  • Hi Pavel,

    Our period-size is 256. Should we change it to 64?

    Thanks,
    Devang.
  • Hi Pavel,

    Please find attached 2 channel audio captured file and 4 channel captured audio file at 48khz for your reference.

    Please change the extension of the above files to .raw.

    Thanks,
    Devang.

  • Hi Devang,

    Thank you for providing me these files, but I do not think I can use the 4 channel audio file on my side as I have DM814x EVM which comes with stereo (2 channel) audio codec AIC3x.

    Best regards,
    Pavel
  • The ALSA SoC Audio Driver by default supports AIC3106 audio codec and audio in stereo mode. You should modify it to support your new audio codec.

    Try with the below settings:

    1. Access type - RW_INTERLEAVED
    2. Channels - 4
    3. Format - S16_LE
    4. Period size - 64




    BR
    Pavel

  • Hi,

    I am also having issue that the recorded file , when played is faster then the original.
    Did you reolve this issue ? What can be the reason for this transformation ?

    Thanks,
    Ran
  • Hi,

    Yes, We were able to resolve this issue.
    Are you capturing 4 channel audio or 2 channel? Have you made any changes in alsa driver?

    Thanks,
    Devang.