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.

mcasp slave and bt headset play noise not right voice

Hi
I want to play a wav by a bluetooth headset spk,but I can't heard the voice what I play ,instead of noise.
# ./aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: IPNC [TI8148 IPNC], device 0: ap62xxbt AP62XXBT-DAI_CODEC-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0

After SCO link is established
# ./aplay -D hw:0,0 -c 2 -f S16_LE /mnt/ring_8k.wav
Playing WAVE '/mnt/ring_8k.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo

I heard noise, not the wav's sound ;And I found that ring_8k.wav is a 9 secs wav file,but it played 18 secs

Can anyone help me ? Does the mcasp set err ? Or the wav file is wrong to bt headset?
How can I do to make the bluetooth headset spk play right?

flowing is the details:
bt(master) dm8148(slave)
pcm_sync <--> mcasp4_AFSX --> 8k
pcm_clk <--> mcasp4_ACLKX -->256k
pcm_in <--> mcasp4_AXR0
pcm_out <--> mcasp4_AXR1

////////////////////
static struct snd_soc_dai_link ti81xx_ipnc_dai[] = {
#if defined(CONFIG_SND_SOC_AP62XXBT)
{
.name = "ap62xx_bt_pcm",
.stream_name = "ap62xxbt",
.cpu_dai_name = "davinci-mcasp.4",
.platform_name = "davinci-pcm-audio",
.codec_dai_name = "AP62XXBT-DAI_CODEC", /* DAI name */
.codec_name = "ap62xxbt-dummy-codec",
.ops = &ap62xxbt_pcm_ops,
},

#endif

////////////////////////////////////
/* Set cpu DAI configuration for ap62xx Bluetooth codec */
ret = snd_soc_dai_set_fmt(cpu_dai,
SND_SOC_DAIFMT_DSP_B |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0) {
printk(KERN_ERR "Can't set cpu DAI configuration for " \
"ap62xx Bluetooth codec \n");
return ret;
}

ret = snd_soc_dai_set_fmt(codec_dai,
SND_SOC_DAIFMT_DSP_B |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0) {
printk(KERN_ERR "Can't set codec DAI configuration for " \
"ap62xx Bluetooth codec \n");
return ret;
}

///////////////////////////////////////////
static void davinci_hw_param(struct davinci_audio_dev *dev, int stream)
{
int i, active_slots;
u32 mask = 0;

active_slots = (dev->tdm_slots > 31) ? 1 : dev->tdm_slots;
for (i = 0; i < active_slots; i++)
mask |= (1 << i);

mcasp_clr_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC);

if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
/* bit stream is MSB first with no delay */
/* DSP_B mode */
mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask);
mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD);

if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32))
mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG,
FSXMOD(dev->tdm_slots), FSXMOD(0x1FF));
else
printk(KERN_ERR "playback tdm slot %d not supported\n",
dev->tdm_slots);

mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
} else {
/* bit stream is MSB first with no delay */
/* DSP_B mode */
mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD);
mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG,
AHCLKRE);
mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask);

if ((dev->tdm_slots >= 2) || (dev->tdm_slots <= 32))
mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG,
FSRMOD(dev->tdm_slots), FSRMOD(0x1FF));
else
printk(KERN_ERR "capture tdm slot %d not supported\n",
dev->tdm_slots);

mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
}
}

Yellow pulse wave ---> pcm_sync 8k;  Green pulse wave -->pcm_clk 256k

  • Sphone,

    sphone pan said:
    card 0: IPNC [TI8148 IPNC],

    Are you using IPNC RDK?

    Best regards,
    Pavel

  • Hi Pavel Botev :

    thks for your answer,I use linux kernel of  IPNC RDK

  • I will notify our IPNC RDK team for help.

    Regards,
    Pavel

  • hello Pavel Botev 

      thank you for your support,I have fix it now ,My bluetooth can work. can aplay and record voice.

     ap6234-bt receiver samples data on the falling edge of the serial clock,but mcasp4 was configed falling edge, it is wrong.

    Accroding to mcasp configurations in sprugz8e.pdf (dm8148 datasheet)  , Chapter 16,

    CLKXP                  Transmit bitstream clock polarity select bit.
                               0  Rising edge. External receiver samples data on the falling edge of the serial clock, so the transmitter must shift data out on the rising edge of the serial clock.
                               1  Falling edge. External receiver samples data on the rising edge of the serial clock, so the transmitter must shift data out on the falling edge of the serial clock.

    so i change  the register CLKXP value

    ret = snd_soc_dai_set_fmt(cpu_dai,
                                                   SND_SOC_DAIFMT_DSP_B |
                                                   SND_SOC_DAIFMT_IB_IF |              <---> // SND_SOC_DAIFMT_NB_NF
                                                    SND_SOC_DAIFMT_CBM_CFM);

    //davinci-mcasp.c

    case SND_SOC_DAIFMT_IB_IF:

    mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
    mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);

    mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
    mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);