2018-01-20 08:35:28

by Attila Tőkés

[permalink] [raw]
Subject: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Everyone,

I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
with PulseAudio.

Based on the information I found on the web (blogs / forums / mailing
list archives), apparently, HSP does not really works with the
Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
yet. Some people suggest it may be a problem with the BCM43438
firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
dongles are reported to be working fine. (The most complete
description I found about the problem is:
http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp)

I think it would be useful to get clear picture about the problem. And
maybe we could try to fix it.

Does anyone managed to figure out what exactly the problem is?

I started investigating the issue, but didn't got any result yet. I
didn't had too much experience with the Linux's Bluetooth stack, so
some help with the further investigation would be useful.

----

Bellow are some details of my investigation.

Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker

Kernel: raspberrypi 4.14.14-v7
BlueZ: 5.43
PulseAudio: 11.1

Summary:
- BCM43438's driver is sucessfuly loaded, it's firmware is uploaded successfully
- the Bluetooth speaker gets detected and the pairing / connection works fine
- PulseAudio detects the speaker as a card
- both the headset_head_unit and a2dp_sink profiles are shown by
`pacmd list-cards` and can be set with `pacmd set-card-profile`
- with the a2dp_sink profile, the audio playback works fine (tested
with `paplay`)
- with the headset_head_unit profile, `paplay` gets stuck at start a
no audio is played (`parecord` does the same)

I started booth BlueZ and PulseAudio in debug mode, but found nothing
obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.

Linking the following logs (uploaded to PasteBin; they are too long
inline them):
- the Blootoothd's log - https://pastebin.com/WC17Ze0r
- the PlulseAudio's log - https://pastebin.com/jUjqjuhC
- the output of the PA commands - https://pastebin.com/wvRzdTEx
- the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
https://pastebin.com/Ax7XYr94
- the HCI dump -https://pastebin.com/zqhqKu57

SCO dump did not managed to get.

I executed the following steps:
(the steps are marked in the log files too):
- start Blootoothd
- start PulseAudio
- powered on the Bloothooth speaker
- tried to play some audio
$ pacmd list cards
$ pacmd set-card-profile 1 headset_head_unit
$ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
/tmp/h2g2.ogg (gets stuck)
$ pacmd set-card-profile 1 a2dp_sink
$ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (works)

Thanks,
Attila


2018-01-21 19:22:55

by Attila Tőkés

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Marcel,


On Sun, Jan 21, 2018 at 2:21 PM, Marcel Holtmann <[email protected]> wrote:
> Hi Tokes,
>
>>>>>> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
>>>>>> with PulseAudio.
>>>>>>
>>>>>> Based on the information I found on the web (blogs / forums / mailing
>>>>>> list archives), apparently, HSP does not really works with the
>>>>>> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
>>>>>> yet. Some people suggest it may be a problem with the BCM43438
>>>>>> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
>>>>>> dongles are reported to be working fine. (The most complete
>>>>>> description I found about the problem is:
>>>>>> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp)
>>>>>>
>>>>>> I think it would be useful to get clear picture about the problem. And
>>>>>> maybe we could try to fix it.
>>>>>>
>>>>>> Does anyone managed to figure out what exactly the problem is?
>>>>>>
>>>>>> I started investigating the issue, but didn't got any result yet. I
>>>>>> didn't had too much experience with the Linux's Bluetooth stack, so
>>>>>> some help with the further investigation would be useful.
>>>>>>
>>>>>> ----
>>>>>>
>>>>>> Bellow are some details of my investigation.
>>>>>>
>>>>>> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>>>>>>
>>>>>> Kernel: raspberrypi 4.14.14-v7
>>>>>> BlueZ: 5.43
>>>>>> PulseAudio: 11.1
>>>>>>
>>>>>> Summary:
>>>>>> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded successfully
>>>>>> - the Bluetooth speaker gets detected and the pairing / connection works fine
>>>>>> - PulseAudio detects the speaker as a card
>>>>>> - both the headset_head_unit and a2dp_sink profiles are shown by
>>>>>> `pacmd list-cards` and can be set with `pacmd set-card-profile`
>>>>>> - with the a2dp_sink profile, the audio playback works fine (tested
>>>>>> with `paplay`)
>>>>>> - with the headset_head_unit profile, `paplay` gets stuck at start a
>>>>>> no audio is played (`parecord` does the same)
>>>>>>
>>>>>> I started booth BlueZ and PulseAudio in debug mode, but found nothing
>>>>>> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>>>>>>
>>>>>> Linking the following logs (uploaded to PasteBin; they are too long
>>>>>> inline them):
>>>>>> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
>>>>>> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
>>>>>> - the output of the PA commands - https://pastebin.com/wvRzdTEx
>>>>>> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
>>>>>> https://pastebin.com/Ax7XYr94
>>>>>> - the HCI dump -https://pastebin.com/zqhqKu57
>>>>>>
>>>>>> SCO dump did not managed to get.
>>>>>>
>>>>>> I executed the following steps:
>>>>>> (the steps are marked in the log files too):
>>>>>> - start Blootoothd
>>>>>> - start PulseAudio
>>>>>> - powered on the Bloothooth speaker
>>>>>> - tried to play some audio
>>>>>> $ pacmd list cards
>>>>>> $ pacmd set-card-profile 1 headset_head_unit
>>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
>>>>>> /tmp/h2g2.ogg (gets stuck)
>>>>>> $ pacmd set-card-profile 1 a2dp_sink
>>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (works)
>>>>>
>>>>> HSP playback getting stuck is a fairly common problem (affecting
>>>>> multiple bluetooth adapters from different vendors). Solutions for the
>>>>> problem are known for a few adapters, but not this one. The issue is
>>>>> documented here (the "HSP problem: the bluetooth sink and source are
>>>>> created, but no audio is being transmitted" section):
>>>>>
>>>>> https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index8h3
>>>>>
>>>>> As you can read there, the underlying problem in the known cases is
>>>>> either that firmware is missing or the SCO audio routing is wrong in
>>>>> the adapter. Changing the routing requires (at least in the known
>>>>> cases) a vendor-specific magic command. I don't know how to figure out
>>>>> the correct command. On one Broadcom chip this does the trick: "hcitool
>>>>> cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
>>>>> that is to work on a different chip.
>>>>
>>>> I just sent that HCI command right now and guess what, it worked :).
>>>> Both paplay an parecord are working fine with the HSP profile now.
>>>
>>> Awesome! I'll update the wiki page.
>>
>> Ok, Thanks! I posted the solution to the two related GitHub issues +
>> some forums / blog posts, so hope it will reach anyone interested in
>> this.
>
> I would be more interested in someone adding this kind of PCM routing configuration to DT and also adopting the hci_bcm.c driver to use it and send the appropriate commands.

I could take a look on adding the new functionality to hci_bcm.c. I'm
not really familiar with the Linux kernel development, so be aware
that this will take some time.

>
> Sending hcitool cmd is like injecting commands. That is a hack. It is not a solution. So commenting that you need some hcitool to hack the hardware setup, that is just wrong. Get this merged into the driver and have it configurable via DT.

Yes, I know its not the best solution, but it fixes the problem and
this is more important for most of the people, than having the "right"
solution. That's why I posted it to GitHub, etc.

>
> Also if you have a recent enough btmon installed, then it might actually decode the Broadcom commands for you. Can you give it a try and see what it says.
>

Actually, I found a document today with the vendor specific HCI
commands for the Cypress CYW4329/CYW4330 chip
(http://www.cypress.com/file/298311/download). Its not the same chip,
by I guess the commands will be similar for all the Cypress / Broadcom
chips.

According to this document the HCI command
hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01

translates to:

command = 0x01C (Write_SCO_PCM_Int_Param)
SCO_Routing = 0x01 (Transport)
PCM_Interface_Rate = 0x02 (512 KBps)
Frame_Type = 0x00 (Short)
Sync_Mode = 0x01 (Master)
Clock_Mode = 0x01 (Master)

btmon (5.43) does not seems to know to decode the command. It outputs this:

$ sudo btmon -s /org/bluez/hci0
...
@ RAW Open: hcitool (privileged) version 2.22 {0x0003} 16.534966
@ RAW Close: hcitool
{0x0003} 16.534997
@ RAW Open: hcitool (privileged) version 2.22 {0x0003}
[hci0] 16.535043
< HCI Command: Vendor (0x3f|0x001c) plen 5 [hci0] 16.535162
01 02 00 01 01 .....
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 16.535566
Vendor (0x3f|0x001c) ncmd 1
Status: Success (0x00)
@ RAW Close: hcitool

> Regards
>
> Marcel
>

Thanks,
Attila

2018-01-21 12:21:13

by Marcel Holtmann

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Tokes,

>>>>> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
>>>>> with PulseAudio.
>>>>>
>>>>> Based on the information I found on the web (blogs / forums / mailing
>>>>> list archives), apparently, HSP does not really works with the
>>>>> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
>>>>> yet. Some people suggest it may be a problem with the BCM43438
>>>>> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
>>>>> dongles are reported to be working fine. (The most complete
>>>>> description I found about the problem is:
>>>>> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp)
>>>>>
>>>>> I think it would be useful to get clear picture about the problem. And
>>>>> maybe we could try to fix it.
>>>>>
>>>>> Does anyone managed to figure out what exactly the problem is?
>>>>>
>>>>> I started investigating the issue, but didn't got any result yet. I
>>>>> didn't had too much experience with the Linux's Bluetooth stack, so
>>>>> some help with the further investigation would be useful.
>>>>>
>>>>> ----
>>>>>
>>>>> Bellow are some details of my investigation.
>>>>>
>>>>> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>>>>>
>>>>> Kernel: raspberrypi 4.14.14-v7
>>>>> BlueZ: 5.43
>>>>> PulseAudio: 11.1
>>>>>
>>>>> Summary:
>>>>> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded successfully
>>>>> - the Bluetooth speaker gets detected and the pairing / connection works fine
>>>>> - PulseAudio detects the speaker as a card
>>>>> - both the headset_head_unit and a2dp_sink profiles are shown by
>>>>> `pacmd list-cards` and can be set with `pacmd set-card-profile`
>>>>> - with the a2dp_sink profile, the audio playback works fine (tested
>>>>> with `paplay`)
>>>>> - with the headset_head_unit profile, `paplay` gets stuck at start a
>>>>> no audio is played (`parecord` does the same)
>>>>>
>>>>> I started booth BlueZ and PulseAudio in debug mode, but found nothing
>>>>> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>>>>>
>>>>> Linking the following logs (uploaded to PasteBin; they are too long
>>>>> inline them):
>>>>> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
>>>>> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
>>>>> - the output of the PA commands - https://pastebin.com/wvRzdTEx
>>>>> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
>>>>> https://pastebin.com/Ax7XYr94
>>>>> - the HCI dump -https://pastebin.com/zqhqKu57
>>>>>
>>>>> SCO dump did not managed to get.
>>>>>
>>>>> I executed the following steps:
>>>>> (the steps are marked in the log files too):
>>>>> - start Blootoothd
>>>>> - start PulseAudio
>>>>> - powered on the Bloothooth speaker
>>>>> - tried to play some audio
>>>>> $ pacmd list cards
>>>>> $ pacmd set-card-profile 1 headset_head_unit
>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
>>>>> /tmp/h2g2.ogg (gets stuck)
>>>>> $ pacmd set-card-profile 1 a2dp_sink
>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (works)
>>>>
>>>> HSP playback getting stuck is a fairly common problem (affecting
>>>> multiple bluetooth adapters from different vendors). Solutions for the
>>>> problem are known for a few adapters, but not this one. The issue is
>>>> documented here (the "HSP problem: the bluetooth sink and source are
>>>> created, but no audio is being transmitted" section):
>>>>
>>>> https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index8h3
>>>>
>>>> As you can read there, the underlying problem in the known cases is
>>>> either that firmware is missing or the SCO audio routing is wrong in
>>>> the adapter. Changing the routing requires (at least in the known
>>>> cases) a vendor-specific magic command. I don't know how to figure out
>>>> the correct command. On one Broadcom chip this does the trick: "hcitool
>>>> cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
>>>> that is to work on a different chip.
>>>
>>> I just sent that HCI command right now and guess what, it worked :).
>>> Both paplay an parecord are working fine with the HSP profile now.
>>
>> Awesome! I'll update the wiki page.
>
> Ok, Thanks! I posted the solution to the two related GitHub issues +
> some forums / blog posts, so hope it will reach anyone interested in
> this.

I would be more interested in someone adding this kind of PCM routing configuration to DT and also adopting the hci_bcm.c driver to use it and send the appropriate commands.

Sending hcitool cmd is like injecting commands. That is a hack. It is not a solution. So commenting that you need some hcitool to hack the hardware setup, that is just wrong. Get this merged into the driver and have it configurable via DT.

Also if you have a recent enough btmon installed, then it might actually decode the Broadcom commands for you. Can you give it a try and see what it says.

Regards

Marcel


2018-01-21 09:54:06

by Attila Tőkés

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

On Sun, Jan 21, 2018 at 12:06 AM, Tanu Kaskinen <[email protected]> wrote:
> On Sat, 2018-01-20 at 22:39 +0200, T=C5=91k=C3=A9s Attila wrote:
>> Hi Tanu,
>>
>> On Sat, Jan 20, 2018 at 10:06 PM, Tanu Kaskinen <[email protected]> wrote:
>> > On Sat, 2018-01-20 at 10:35 +0200, T=C5=91k=C3=A9s Attila wrote:
>> > > Hi Everyone,
>> > >
>> > > I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mod=
e
>> > > with PulseAudio.
>> > >
>> > > Based on the information I found on the web (blogs / forums / mailin=
g
>> > > list archives), apparently, HSP does not really works with the
>> > > Rasberry Pi's built in BCM43438 chip. I didn't found the exact reaso=
n
>> > > yet. Some people suggest it may be a problem with the BCM43438
>> > > firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
>> > > dongles are reported to be working fine. (The most complete
>> > > description I found about the problem is:
>> > > http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2=
p-hsp)
>> > >
>> > > I think it would be useful to get clear picture about the problem. A=
nd
>> > > maybe we could try to fix it.
>> > >
>> > > Does anyone managed to figure out what exactly the problem is?
>> > >
>> > > I started investigating the issue, but didn't got any result yet. I
>> > > didn't had too much experience with the Linux's Bluetooth stack, so
>> > > some help with the further investigation would be useful.
>> > >
>> > > ----
>> > >
>> > > Bellow are some details of my investigation.
>> > >
>> > > Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>> > >
>> > > Kernel: raspberrypi 4.14.14-v7
>> > > BlueZ: 5.43
>> > > PulseAudio: 11.1
>> > >
>> > > Summary:
>> > > - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded =
successfully
>> > > - the Bluetooth speaker gets detected and the pairing / connection w=
orks fine
>> > > - PulseAudio detects the speaker as a card
>> > > - both the headset_head_unit and a2dp_sink profiles are shown by
>> > > `pacmd list-cards` and can be set with `pacmd set-card-profile`
>> > > - with the a2dp_sink profile, the audio playback works fine (tested
>> > > with `paplay`)
>> > > - with the headset_head_unit profile, `paplay` gets stuck at start a
>> > > no audio is played (`parecord` does the same)
>> > >
>> > > I started booth BlueZ and PulseAudio in debug mode, but found nothin=
g
>> > > obviuosly wrong (at least for me :P) in the logs. Also did a HCI dum=
p.
>> > >
>> > > Linking the following logs (uploaded to PasteBin; they are too long
>> > > inline them):
>> > > - the Blootoothd's log - https://pastebin.com/WC17Ze0r
>> > > - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
>> > > - the output of the PA commands - https://pastebin.com/wvRzdTEx
>> > > - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
>> > > https://pastebin.com/Ax7XYr94
>> > > - the HCI dump -https://pastebin.com/zqhqKu57
>> > >
>> > > SCO dump did not managed to get.
>> > >
>> > > I executed the following steps:
>> > > (the steps are marked in the log files too):
>> > > - start Blootoothd
>> > > - start PulseAudio
>> > > - powered on the Bloothooth speaker
>> > > - tried to play some audio
>> > > $ pacmd list cards
>> > > $ pacmd set-card-profile 1 headset_head_unit
>> > > $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
>> > > /tmp/h2g2.ogg (gets stuck)
>> > > $ pacmd set-card-profile 1 a2dp_sink
>> > > $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg =
(works)
>> >
>> > HSP playback getting stuck is a fairly common problem (affecting
>> > multiple bluetooth adapters from different vendors). Solutions for the
>> > problem are known for a few adapters, but not this one. The issue is
>> > documented here (the "HSP problem: the bluetooth sink and source are
>> > created, but no audio is being transmitted" section):
>> >
>> > https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Use=
r/Bluetooth/#index8h3
>> >
>> > As you can read there, the underlying problem in the known cases is
>> > either that firmware is missing or the SCO audio routing is wrong in
>> > the adapter. Changing the routing requires (at least in the known
>> > cases) a vendor-specific magic command. I don't know how to figure out
>> > the correct command. On one Broadcom chip this does the trick: "hcitoo=
l
>> > cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
>> > that is to work on a different chip.
>>
>> I just sent that HCI command right now and guess what, it worked :).
>> Both paplay an parecord are working fine with the HSP profile now.
>
> Awesome! I'll update the wiki page.

Ok, Thanks! I posted the solution to the two related GitHub issues +
some forums / blog posts, so hope it will reach anyone interested in
this.

>
> --
> Tanu
>
> https://liberapay.com/tanuk
> https://www.patreon.com/tanuk

2018-01-20 22:06:40

by Tanu Kaskinen

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

On Sat, 2018-01-20 at 22:39 +0200, Tőkés Attila wrote:
> Hi Tanu,
>
> On Sat, Jan 20, 2018 at 10:06 PM, Tanu Kaskinen <[email protected]> wrote:
> > On Sat, 2018-01-20 at 10:35 +0200, Tőkés Attila wrote:
> > > Hi Everyone,
> > >
> > > I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
> > > with PulseAudio.
> > >
> > > Based on the information I found on the web (blogs / forums / mailing
> > > list archives), apparently, HSP does not really works with the
> > > Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
> > > yet. Some people suggest it may be a problem with the BCM43438
> > > firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
> > > dongles are reported to be working fine. (The most complete
> > > description I found about the problem is:
> > > http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp)
> > >
> > > I think it would be useful to get clear picture about the problem. And
> > > maybe we could try to fix it.
> > >
> > > Does anyone managed to figure out what exactly the problem is?
> > >
> > > I started investigating the issue, but didn't got any result yet. I
> > > didn't had too much experience with the Linux's Bluetooth stack, so
> > > some help with the further investigation would be useful.
> > >
> > > ----
> > >
> > > Bellow are some details of my investigation.
> > >
> > > Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
> > >
> > > Kernel: raspberrypi 4.14.14-v7
> > > BlueZ: 5.43
> > > PulseAudio: 11.1
> > >
> > > Summary:
> > > - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded successfully
> > > - the Bluetooth speaker gets detected and the pairing / connection works fine
> > > - PulseAudio detects the speaker as a card
> > > - both the headset_head_unit and a2dp_sink profiles are shown by
> > > `pacmd list-cards` and can be set with `pacmd set-card-profile`
> > > - with the a2dp_sink profile, the audio playback works fine (tested
> > > with `paplay`)
> > > - with the headset_head_unit profile, `paplay` gets stuck at start a
> > > no audio is played (`parecord` does the same)
> > >
> > > I started booth BlueZ and PulseAudio in debug mode, but found nothing
> > > obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
> > >
> > > Linking the following logs (uploaded to PasteBin; they are too long
> > > inline them):
> > > - the Blootoothd's log - https://pastebin.com/WC17Ze0r
> > > - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
> > > - the output of the PA commands - https://pastebin.com/wvRzdTEx
> > > - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
> > > https://pastebin.com/Ax7XYr94
> > > - the HCI dump -https://pastebin.com/zqhqKu57
> > >
> > > SCO dump did not managed to get.
> > >
> > > I executed the following steps:
> > > (the steps are marked in the log files too):
> > > - start Blootoothd
> > > - start PulseAudio
> > > - powered on the Bloothooth speaker
> > > - tried to play some audio
> > > $ pacmd list cards
> > > $ pacmd set-card-profile 1 headset_head_unit
> > > $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
> > > /tmp/h2g2.ogg (gets stuck)
> > > $ pacmd set-card-profile 1 a2dp_sink
> > > $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (works)
> >
> > HSP playback getting stuck is a fairly common problem (affecting
> > multiple bluetooth adapters from different vendors). Solutions for the
> > problem are known for a few adapters, but not this one. The issue is
> > documented here (the "HSP problem: the bluetooth sink and source are
> > created, but no audio is being transmitted" section):
> >
> > https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index8h3
> >
> > As you can read there, the underlying problem in the known cases is
> > either that firmware is missing or the SCO audio routing is wrong in
> > the adapter. Changing the routing requires (at least in the known
> > cases) a vendor-specific magic command. I don't know how to figure out
> > the correct command. On one Broadcom chip this does the trick: "hcitool
> > cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
> > that is to work on a different chip.
>
> I just sent that HCI command right now and guess what, it worked :).
> Both paplay an parecord are working fine with the HSP profile now.

Awesome! I'll update the wiki page.

--
Tanu

https://liberapay.com/tanuk
https://www.patreon.com/tanuk

2018-01-20 20:39:05

by Attila Tőkés

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Tanu,

On Sat, Jan 20, 2018 at 10:06 PM, Tanu Kaskinen <[email protected]> wrote:
> On Sat, 2018-01-20 at 10:35 +0200, T=C5=91k=C3=A9s Attila wrote:
>> Hi Everyone,
>>
>> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
>> with PulseAudio.
>>
>> Based on the information I found on the web (blogs / forums / mailing
>> list archives), apparently, HSP does not really works with the
>> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
>> yet. Some people suggest it may be a problem with the BCM43438
>> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
>> dongles are reported to be working fine. (The most complete
>> description I found about the problem is:
>> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hs=
p)
>>
>> I think it would be useful to get clear picture about the problem. And
>> maybe we could try to fix it.
>>
>> Does anyone managed to figure out what exactly the problem is?
>>
>> I started investigating the issue, but didn't got any result yet. I
>> didn't had too much experience with the Linux's Bluetooth stack, so
>> some help with the further investigation would be useful.
>>
>> ----
>>
>> Bellow are some details of my investigation.
>>
>> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>>
>> Kernel: raspberrypi 4.14.14-v7
>> BlueZ: 5.43
>> PulseAudio: 11.1
>>
>> Summary:
>> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded succ=
essfully
>> - the Bluetooth speaker gets detected and the pairing / connection works=
fine
>> - PulseAudio detects the speaker as a card
>> - both the headset_head_unit and a2dp_sink profiles are shown by
>> `pacmd list-cards` and can be set with `pacmd set-card-profile`
>> - with the a2dp_sink profile, the audio playback works fine (tested
>> with `paplay`)
>> - with the headset_head_unit profile, `paplay` gets stuck at start a
>> no audio is played (`parecord` does the same)
>>
>> I started booth BlueZ and PulseAudio in debug mode, but found nothing
>> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>>
>> Linking the following logs (uploaded to PasteBin; they are too long
>> inline them):
>> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
>> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
>> - the output of the PA commands - https://pastebin.com/wvRzdTEx
>> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
>> https://pastebin.com/Ax7XYr94
>> - the HCI dump -https://pastebin.com/zqhqKu57
>>
>> SCO dump did not managed to get.
>>
>> I executed the following steps:
>> (the steps are marked in the log files too):
>> - start Blootoothd
>> - start PulseAudio
>> - powered on the Bloothooth speaker
>> - tried to play some audio
>> $ pacmd list cards
>> $ pacmd set-card-profile 1 headset_head_unit
>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
>> /tmp/h2g2.ogg (gets stuck)
>> $ pacmd set-card-profile 1 a2dp_sink
>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (wor=
ks)
>
> HSP playback getting stuck is a fairly common problem (affecting
> multiple bluetooth adapters from different vendors). Solutions for the
> problem are known for a few adapters, but not this one. The issue is
> documented here (the "HSP problem: the bluetooth sink and source are
> created, but no audio is being transmitted" section):
>
> https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/B=
luetooth/#index8h3
>
> As you can read there, the underlying problem in the known cases is
> either that firmware is missing or the SCO audio routing is wrong in
> the adapter. Changing the routing requires (at least in the known
> cases) a vendor-specific magic command. I don't know how to figure out
> the correct command. On one Broadcom chip this does the trick: "hcitool
> cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
> that is to work on a different chip.

I just sent that HCI command right now and guess what, it worked :).
Both paplay an parecord are working fine with the HSP profile now.

>
> --
> Tanu
>
> https://liberapay.com/tanuk
> https://www.patreon.com/tanuk

Thanks,
Attila

2018-01-20 20:06:35

by Tanu Kaskinen

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

On Sat, 2018-01-20 at 10:35 +0200, Tőkés Attila wrote:
> Hi Everyone,
>
> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
> with PulseAudio.
>
> Based on the information I found on the web (blogs / forums / mailing
> list archives), apparently, HSP does not really works with the
> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
> yet. Some people suggest it may be a problem with the BCM43438
> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
> dongles are reported to be working fine. (The most complete
> description I found about the problem is:
> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp)
>
> I think it would be useful to get clear picture about the problem. And
> maybe we could try to fix it.
>
> Does anyone managed to figure out what exactly the problem is?
>
> I started investigating the issue, but didn't got any result yet. I
> didn't had too much experience with the Linux's Bluetooth stack, so
> some help with the further investigation would be useful.
>
> ----
>
> Bellow are some details of my investigation.
>
> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>
> Kernel: raspberrypi 4.14.14-v7
> BlueZ: 5.43
> PulseAudio: 11.1
>
> Summary:
> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded successfully
> - the Bluetooth speaker gets detected and the pairing / connection works fine
> - PulseAudio detects the speaker as a card
> - both the headset_head_unit and a2dp_sink profiles are shown by
> `pacmd list-cards` and can be set with `pacmd set-card-profile`
> - with the a2dp_sink profile, the audio playback works fine (tested
> with `paplay`)
> - with the headset_head_unit profile, `paplay` gets stuck at start a
> no audio is played (`parecord` does the same)
>
> I started booth BlueZ and PulseAudio in debug mode, but found nothing
> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>
> Linking the following logs (uploaded to PasteBin; they are too long
> inline them):
> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
> - the output of the PA commands - https://pastebin.com/wvRzdTEx
> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
> https://pastebin.com/Ax7XYr94
> - the HCI dump -https://pastebin.com/zqhqKu57
>
> SCO dump did not managed to get.
>
> I executed the following steps:
> (the steps are marked in the log files too):
> - start Blootoothd
> - start PulseAudio
> - powered on the Bloothooth speaker
> - tried to play some audio
> $ pacmd list cards
> $ pacmd set-card-profile 1 headset_head_unit
> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
> /tmp/h2g2.ogg (gets stuck)
> $ pacmd set-card-profile 1 a2dp_sink
> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (works)

HSP playback getting stuck is a fairly common problem (affecting
multiple bluetooth adapters from different vendors). Solutions for the
problem are known for a few adapters, but not this one. The issue is
documented here (the "HSP problem: the bluetooth sink and source are
created, but no audio is being transmitted" section):

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index8h3

As you can read there, the underlying problem in the known cases is
either that firmware is missing or the SCO audio routing is wrong in
the adapter. Changing the routing requires (at least in the known
cases) a vendor-specific magic command. I don't know how to figure out
the correct command. On one Broadcom chip this does the trick: "hcitool
cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
that is to work on a different chip.

--
Tanu

https://liberapay.com/tanuk
https://www.patreon.com/tanuk

2018-01-20 11:44:10

by Attila Tőkés

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Barry,

On Sat, Jan 20, 2018 at 12:24 PM, Barry Byford <[email protected]> wrote:
> Hello Attila,
>
>
> On 20 January 2018 at 08:35, T=C5=91k=C3=A9s Attila <[email protected]>=
wrote:
>> Hi Everyone,
>>
>> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
>> with PulseAudio.
>>
>> Based on the information I found on the web (blogs / forums / mailing
>> list archives), apparently, HSP does not really works with the
>> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
>> yet. Some people suggest it may be a problem with the BCM43438
>> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
>> dongles are reported to be working fine. (The most complete
>> description I found about the problem is:
>> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hs=
p)
>>
>> I think it would be useful to get clear picture about the problem. And
>> maybe we could try to fix it.
>
> There is an issue on the Raspberry Pi Foundation/Trading GitHub for
> their Linux kernel source tree:
> https://github.com/raspberrypi/linux/issues/1552
>
>
>> Does anyone managed to figure out what exactly the problem is?
>
> The trail on issue 1552 goes all the way back to Cypress/Broadcom via
> people at Raspberry Pi Trading and has the status of "waiting for
> internal comment" so I suspect they will be the people to ping about
> this.
>
The Wifi and Blootooth are provided by the same BCM43438 chip, but I
have no problem using them together (issue #1552). The issue I
described seems to affect only the HSP audio Bluetooth profile.

While tested the Bluetooth audio (A2DP / HSP) the Wifi was on all the
time (mostly idle). Also, using the A2DP profile I'm able to play
audio even while having 10+Mbps (up or down) traffic on the Wifi.

There are 2 HSP related GitHub issues on the raspberrypi/linux project:
https://github.com/raspberrypi/linux/issues/2229
https://github.com/raspberrypi/linux/issues/1401

, but they does not seem to have clear cause of the problem.

Given that the A2DP profile works fine with BCM43438 and USB dongles
are reported to work with both A2DP and HSP, my guess is that
something gets wrong on the Bluetooth protocol level, either in the
BCM43438 (firmware problem) or in it's driver.

Now, I not sure what would be the steps to investigate a such an
issue. I guess we should get some dumps (HCI + SCO) and try to figure
out were it gets wrong. Also we could try to get some dump while using
a USB dongle and compare with the BCM43438 dumps.

Any ideas?

By the way, can somebody help me getting the SCO dump? Probably, I
should use the scotest tool, but tried a lot of options without
success.

>>
>> I started investigating the issue, but didn't got any result yet. I
>> didn't had too much experience with the Linux's Bluetooth stack, so
>> some help with the further investigation would be useful.
>>
>> ----
>>
>> Bellow are some details of my investigation.
>>
>> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>>
>> Kernel: raspberrypi 4.14.14-v7
>> BlueZ: 5.43
>> PulseAudio: 11.1
>>
>> Summary:
>> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded succ=
essfully
>> - the Bluetooth speaker gets detected and the pairing / connection works=
fine
>> - PulseAudio detects the speaker as a card
>> - both the headset_head_unit and a2dp_sink profiles are shown by
>> `pacmd list-cards` and can be set with `pacmd set-card-profile`
>> - with the a2dp_sink profile, the audio playback works fine (tested
>> with `paplay`)
>> - with the headset_head_unit profile, `paplay` gets stuck at start a
>> no audio is played (`parecord` does the same)
>>
>> I started booth BlueZ and PulseAudio in debug mode, but found nothing
>> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>>
>> Linking the following logs (uploaded to PasteBin; they are too long
>> inline them):
>> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
>> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
>> - the output of the PA commands - https://pastebin.com/wvRzdTEx
>> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
>> https://pastebin.com/Ax7XYr94
>> - the HCI dump -https://pastebin.com/zqhqKu57
>>
>> SCO dump did not managed to get.
>>
>> I executed the following steps:
>> (the steps are marked in the log files too):
>> - start Blootoothd
>> - start PulseAudio
>> - powered on the Bloothooth speaker
>> - tried to play some audio
>> $ pacmd list cards
>> $ pacmd set-card-profile 1 headset_head_unit
>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
>> /tmp/h2g2.ogg (gets stuck)
>> $ pacmd set-card-profile 1 a2dp_sink
>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (wor=
ks)
>>
>> Thanks,
>> Attila
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks,
Attila

2018-01-20 10:24:33

by Barry Byford

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hello Attila,


On 20 January 2018 at 08:35, T=C5=91k=C3=A9s Attila <[email protected]> w=
rote:
> Hi Everyone,
>
> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP mode
> with PulseAudio.
>
> Based on the information I found on the web (blogs / forums / mailing
> list archives), apparently, HSP does not really works with the
> Rasberry Pi's built in BCM43438 chip. I didn't found the exact reason
> yet. Some people suggest it may be a problem with the BCM43438
> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
> dongles are reported to be working fine. (The most complete
> description I found about the problem is:
> http://youness.net/raspberry-pi/bluetooth-headset-raspberry-pi-3-ad2p-hsp=
)
>
> I think it would be useful to get clear picture about the problem. And
> maybe we could try to fix it.

There is an issue on the Raspberry Pi Foundation/Trading GitHub for
their Linux kernel source tree:
https://github.com/raspberrypi/linux/issues/1552


> Does anyone managed to figure out what exactly the problem is?

The trail on issue 1552 goes all the way back to Cypress/Broadcom via
people at Raspberry Pi Trading and has the status of "waiting for
internal comment" so I suspect they will be the people to ping about
this.

>
> I started investigating the issue, but didn't got any result yet. I
> didn't had too much experience with the Linux's Bluetooth stack, so
> some help with the further investigation would be useful.
>
> ----
>
> Bellow are some details of my investigation.
>
> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
>
> Kernel: raspberrypi 4.14.14-v7
> BlueZ: 5.43
> PulseAudio: 11.1
>
> Summary:
> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded succe=
ssfully
> - the Bluetooth speaker gets detected and the pairing / connection works =
fine
> - PulseAudio detects the speaker as a card
> - both the headset_head_unit and a2dp_sink profiles are shown by
> `pacmd list-cards` and can be set with `pacmd set-card-profile`
> - with the a2dp_sink profile, the audio playback works fine (tested
> with `paplay`)
> - with the headset_head_unit profile, `paplay` gets stuck at start a
> no audio is played (`parecord` does the same)
>
> I started booth BlueZ and PulseAudio in debug mode, but found nothing
> obviuosly wrong (at least for me :P) in the logs. Also did a HCI dump.
>
> Linking the following logs (uploaded to PasteBin; they are too long
> inline them):
> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
> - the output of the PA commands - https://pastebin.com/wvRzdTEx
> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
> https://pastebin.com/Ax7XYr94
> - the HCI dump -https://pastebin.com/zqhqKu57
>
> SCO dump did not managed to get.
>
> I executed the following steps:
> (the steps are marked in the log files too):
> - start Blootoothd
> - start PulseAudio
> - powered on the Bloothooth speaker
> - tried to play some audio
> $ pacmd list cards
> $ pacmd set-card-profile 1 headset_head_unit
> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
> /tmp/h2g2.ogg (gets stuck)
> $ pacmd set-card-profile 1 a2dp_sink
> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink /tmp/h2g2.ogg (work=
s)
>
> Thanks,
> Attila
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2018-06-05 19:28:50

by Attila Tőkés

[permalink] [raw]
Subject: Re: Raspberry Pi 3 / BCM43438 + HSP profile + PulseAudio

Hi Marcel,

I just sent a patch with the changes for the SCO routing:
[PATCH] Bluetooth: hci_bcm: Configure SCO routing automatically

The patch applies to the bluetooth-next branch. I tested it with a 4.15.18
kernel (rpi build).

Thanks,
Attila

On Sun, Jan 21, 2018 at 9:22 PM, Attila Tőkés <[email protected]> wrote:

> Hi Marcel,
>
>
> On Sun, Jan 21, 2018 at 2:21 PM, Marcel Holtmann <[email protected]>
> wrote:
> > Hi Tokes,
> >
> >>>>>> I'm trying to use a Bluetooth speaker with Raspberry Pi 3 in HSP
> mode
> >>>>>> with PulseAudio.
> >>>>>>
> >>>>>> Based on the information I found on the web (blogs / forums /
> mailing
> >>>>>> list archives), apparently, HSP does not really works with the
> >>>>>> Rasberry Pi's built in BCM43438 chip. I didn't found the exact
> reason
> >>>>>> yet. Some people suggest it may be a problem with the BCM43438
> >>>>>> firmware or with the kernel driver. A2DP, and HSP with USB Bluetooth
> >>>>>> dongles are reported to be working fine. (The most complete
> >>>>>> description I found about the problem is:
> >>>>>> http://youness.net/raspberry-pi/bluetooth-headset-
> raspberry-pi-3-ad2p-hsp)
> >>>>>>
> >>>>>> I think it would be useful to get clear picture about the problem.
> And
> >>>>>> maybe we could try to fix it.
> >>>>>>
> >>>>>> Does anyone managed to figure out what exactly the problem is?
> >>>>>>
> >>>>>> I started investigating the issue, but didn't got any result yet. I
> >>>>>> didn't had too much experience with the Linux's Bluetooth stack, so
> >>>>>> some help with the further investigation would be useful.
> >>>>>>
> >>>>>> ----
> >>>>>>
> >>>>>> Bellow are some details of my investigation.
> >>>>>>
> >>>>>> Hardware: Raspberry Pi 3 + JBL GO! Bluetooth speaker
> >>>>>>
> >>>>>> Kernel: raspberrypi 4.14.14-v7
> >>>>>> BlueZ: 5.43
> >>>>>> PulseAudio: 11.1
> >>>>>>
> >>>>>> Summary:
> >>>>>> - BCM43438's driver is sucessfuly loaded, it's firmware is uploaded
> successfully
> >>>>>> - the Bluetooth speaker gets detected and the pairing / connection
> works fine
> >>>>>> - PulseAudio detects the speaker as a card
> >>>>>> - both the headset_head_unit and a2dp_sink profiles are shown by
> >>>>>> `pacmd list-cards` and can be set with `pacmd set-card-profile`
> >>>>>> - with the a2dp_sink profile, the audio playback works fine (tested
> >>>>>> with `paplay`)
> >>>>>> - with the headset_head_unit profile, `paplay` gets stuck at start a
> >>>>>> no audio is played (`parecord` does the same)
> >>>>>>
> >>>>>> I started booth BlueZ and PulseAudio in debug mode, but found
> nothing
> >>>>>> obviuosly wrong (at least for me :P) in the logs. Also did a HCI
> dump.
> >>>>>>
> >>>>>> Linking the following logs (uploaded to PasteBin; they are too long
> >>>>>> inline them):
> >>>>>> - the Blootoothd's log - https://pastebin.com/WC17Ze0r
> >>>>>> - the PlulseAudio's log - https://pastebin.com/jUjqjuhC
> >>>>>> - the output of the PA commands - https://pastebin.com/wvRzdTEx
> >>>>>> - the output of some BL Tools (sdptool / bluetoothctl / hciconfig) -
> >>>>>> https://pastebin.com/Ax7XYr94
> >>>>>> - the HCI dump -https://pastebin.com/zqhqKu57
> >>>>>>
> >>>>>> SCO dump did not managed to get.
> >>>>>>
> >>>>>> I executed the following steps:
> >>>>>> (the steps are marked in the log files too):
> >>>>>> - start Blootoothd
> >>>>>> - start PulseAudio
> >>>>>> - powered on the Bloothooth speaker
> >>>>>> - tried to play some audio
> >>>>>> $ pacmd list cards
> >>>>>> $ pacmd set-card-profile 1 headset_head_unit
> >>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.headset_head_unit
> >>>>>> /tmp/h2g2.ogg (gets stuck)
> >>>>>> $ pacmd set-card-profile 1 a2dp_sink
> >>>>>> $ paplay -v -d bluez_sink.78_44_05_4B_4F_FF.a2dp_sink
> /tmp/h2g2.ogg (works)
> >>>>>
> >>>>> HSP playback getting stuck is a fairly common problem (affecting
> >>>>> multiple bluetooth adapters from different vendors). Solutions for
> the
> >>>>> problem are known for a few adapters, but not this one. The issue is
> >>>>> documented here (the "HSP problem: the bluetooth sink and source are
> >>>>> created, but no audio is being transmitted" section):
> >>>>>
> >>>>> https://www.freedesktop.org/wiki/Software/PulseAudio/
> Documentation/User/Bluetooth/#index8h3
> >>>>>
> >>>>> As you can read there, the underlying problem in the known cases is
> >>>>> either that firmware is missing or the SCO audio routing is wrong in
> >>>>> the adapter. Changing the routing requires (at least in the known
> >>>>> cases) a vendor-specific magic command. I don't know how to figure
> out
> >>>>> the correct command. On one Broadcom chip this does the trick:
> "hcitool
> >>>>> cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01", but I don't know how likely
> >>>>> that is to work on a different chip.
> >>>>
> >>>> I just sent that HCI command right now and guess what, it worked :).
> >>>> Both paplay an parecord are working fine with the HSP profile now.
> >>>
> >>> Awesome! I'll update the wiki page.
> >>
> >> Ok, Thanks! I posted the solution to the two related GitHub issues +
> >> some forums / blog posts, so hope it will reach anyone interested in
> >> this.
> >
> > I would be more interested in someone adding this kind of PCM routing
> configuration to DT and also adopting the hci_bcm.c driver to use it and
> send the appropriate commands.
>
> I could take a look on adding the new functionality to hci_bcm.c. I'm
> not really familiar with the Linux kernel development, so be aware
> that this will take some time.
>
> >
> > Sending hcitool cmd is like injecting commands. That is a hack. It is
> not a solution. So commenting that you need some hcitool to hack the
> hardware setup, that is just wrong. Get this merged into the driver and
> have it configurable via DT.
>
> Yes, I know its not the best solution, but it fixes the problem and
> this is more important for most of the people, than having the "right"
> solution. That's why I posted it to GitHub, etc.
>
> >
> > Also if you have a recent enough btmon installed, then it might actually
> decode the Broadcom commands for you. Can you give it a try and see what it
> says.
> >
>
> Actually, I found a document today with the vendor specific HCI
> commands for the Cypress CYW4329/CYW4330 chip
> (http://www.cypress.com/file/298311/download). Its not the same chip,
> by I guess the commands will be similar for all the Cypress / Broadcom
> chips.
>
> According to this document the HCI command
> hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01
>
> translates to:
>
> command = 0x01C (Write_SCO_PCM_Int_Param)
> SCO_Routing = 0x01 (Transport)
> PCM_Interface_Rate = 0x02 (512 KBps)
> Frame_Type = 0x00 (Short)
> Sync_Mode = 0x01 (Master)
> Clock_Mode = 0x01 (Master)
>
> btmon (5.43) does not seems to know to decode the command. It outputs this:
>
> $ sudo btmon -s /org/bluez/hci0
> ...
> @ RAW Open: hcitool (privileged) version 2.22 {0x0003} 16.534966
> @ RAW Close: hcitool
> {0x0003} 16.534997
> @ RAW Open: hcitool (privileged) version 2.22 {0x0003}
> [hci0] 16.535043
> < HCI Command: Vendor (0x3f|0x001c) plen 5 [hci0] 16.535162
> 01 02 00 01 01 .....
> > HCI Event: Command Complete (0x0e) plen 4 [hci0] 16.535566
> Vendor (0x3f|0x001c) ncmd 1
> Status: Success (0x00)
> @ RAW Close: hcitool
>
> > Regards
> >
> > Marcel
> >
>
> Thanks,
> Attila
>