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.

Why is sound distorted when using Wl18xx HFP/HSP over HCI?

Other Parts Discussed in Thread: WL1831

I am using WL1831 bluetooth module on a custom board, whose main processor has to send audio to mono heasets through bluetooth HFP/HSP profiles. The board I am working on has just UART connection, since the main processor lacks PCM controller. So, I want audio to go through HCI.


My setup is the following:

- bluez 5.34

- pulseaudio 6.0 with bluez5 module support

- ti wl18xx driver and firmware 8.5R, TIInit_11.8.32.bts file

I am able to pair and connect to headsets, so I think driver + Bluez stack is fine. After connection, pulseaudio creates bluetooth source and sink devices (through module-bluez5-device). I also send these HCI commands to wl1831, in order to enable SCO over HCI:

# Route SCO connection over HCI instead of PCM
hcitool -i hci0 cmd 0x3f 0x210 0x01 0x00 0x00 0x00 0xFF > /dev/null

When I play any audio file to headsets, the sound is distorted, as if sampling frequency were wrong. Anyway, the sample specifications reported by PulseAudio are correct:

sample spec: s16le 1ch 8000Hz

So, why is sound distorted and how can I fix it?

  • Hi,

    Can you try the below commands and see if it helps?

    hcitool cmd 0x3f 0x0210 0x01 0x78 0xff 0x01 0xff
    hcitool cmd 0x03 0x002f 0x01

    Regards,
    Gigi Joseph.
  • Hi Gigi.

    No, it does not help. Nothing changes in audio, distortion is still there. The audio I play is a short voice message, but through headset voice sounds metallic and slower than normal.

    Please find below the output of your commands:

    root@freescale ~$ hcitool cmd 0x3f 0x0210 0x01 0x78 0xff 0x01 0xff
    < HCI Command: ogf 0x3f, ocf 0x0210, plen 5
    01 78 FF 01 FF
    > HCI Event: 0x0e plen 6
    01 10 FE 00 78 04

    root@freescale ~$ hcitool cmd 0x03 0x002f 0x01
    < HCI Command: ogf 0x03, ocf 0x002f, plen 1
    01
    > HCI Event: 0x0e plen 4
    01 2F 0C 0C

    I am not able to understand if they ran with success or not. What do you think? I think second command failed.

    I tried to send same commands before starting Bluez, output is different and seems correct:

    HCI Command: ogf 0x3f, ocf 0x0210, plen 5
      01 78 FF 01 FF
    > HCI Event: 0x0e plen 6
      01 10 FE 00 78 04

    HCI Command: ogf 0x03, ocf 0x002f, plen 1
      01
    > HCI Event: 0x0e plen 4
      01 2F 0C 00

    But again sound is distorted. Moreover, kernel prints these messages during audio playback:

    Bluetooth: Unknown type 2 conn 9a81c400
    Bluetooth: Unknown type 2 conn 9a81c400
    Bluetooth: Unknown type 2 conn 9a81c400
    Bluetooth: Unknown type 2 conn 9a81c400
    ...

    Regards,

    Federico

  • Hi Federico,

    Looking at the error prints, it seems the host stack does not handle the num_completed_pkts correctly. The "type= 2" corresponds to eSCO link. It seems the stack is not correctly handling it. And this could lead to breaks in the audio.

    You might want to try to force a SCO connection, or try to handle the eSCO data correctly.

    Regards,
    Gigi Joseph.
  • Hi Gigi.


    Can you please explain how to force a SCO connection?

    Also, can you please explain the meaning of these commands you gave me and that I tried:

    hcitool cmd 0x3f 0x0210 0x01 0x78 0xff 0x01 0xff
    hcitool cmd 0x03 0x002f 0x01

    Regards,

    Federico

  • Hi Federico,

    You tried:
    Send_HCI_VS_Write_SCO_Configuration (configures "HCI" connection type, host tx buffer size, etc ) & HCI_Write_SCO_Flow_Control_Enable commands.

    Forcing SCO connection will depend on your stack implementation. For example, BlueZ stack has a module param ("disable_esco") on bluetooth.ko. You can use that.

    Another option would be to use: processors.wiki.ti.com/.../CC256x_VS_HCI_Commands (Byte: 3/Bit:7) and clear eSCO support from LMP supported features.

    Regards,
    Gigi Joseph.
  • Hi Gigi.


    I tried to force SCO connection by settings disable_esco=1 kernel parameter for bluez. I am still sending the two commands you gave me (Send_HCI_VS_Write_SCO_Configuration & HCI_Write_SCO_Flow_Control_Enable).  Unfortunately, no success.


    When I connect to headset with such parameter, kernel keeps printing these messages very fast:

    Bluetooth: hci0 SCO packet for unknown connection handle 257
    Bluetooth: hci0 SCO packet for unknown connection handle 257
    Bluetooth: hci0 SCO packet for unknown connection handle 257
    Bluetooth: hci0 SCO packet for unknown connection handle 257
    Bluetooth: hci0 SCO packet for unknown connection handle 257


    What does it mean?

    Moreover, I am not able to play anything, I do not hear any sound. Please help me.

    I made second test, using the SetFeature command you suggested (and removing the disable_esco parameter). In this case, kernel does not print any error, but when I play the audio file I do not hear anything. Moreover, during playback, btmon does not dump any HCI data/event.

    How can i solve this problem?

  • Hi,

    It looks to me that the SCO data is being dropped by the stack, as it does not recognize the sco connection. This is not a wl18xx issue, but looks to be related to the stack. Please post this on some BlueZ forums, and you will get better response there.

    Regards,
    Gigi Joseph.