[Nexus 5 Developer Discussion [Developers Only]] z3DD3r:
Hi there,

Sorry for delay. I was a bit busy today. Here is my workaround for bt issue:

1) android_hardware_broadcom_libbt

2) device tree

Honestly this workaround is terrible (explanations will be provided below) and disabled by default. You should add two parameters to vendor config in order to activate it:

1)

BTHW_FW_EXTENDED_CONFIGURATION

- Enable/disable the fix. TRUE/FALSE. Default value is FALSE.

2)

BTHW_FW_EXTENDED_SCO_CODEC

- SCO codec. Use the numeric value from the sco_codec_t enum. Default value is SCO_CODEC_CVSD.

Seems that the problem lies in firmware for our BT chip and eSCO command set. Controller have invalid audio configuration or doesn't have any audio configuration at all after firmware upload. That was not a problem before this change (Thanks [MENTION=7412373]Sashko98[/MENTION] for research). I've tried a solution proposed by [MENTION=7412373]Sashko98[/MENTION] but nothing changed. After a couple of days playing with different parameters in configs i noticed interesting line in logcat:

W/bt_hci:
filter_incoming_event command complete event with no matching command (opcode: [B]0xfc6d[/B])

0xfc6d is a

HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM

constant defined here and used inside of the hw_sco_i2spcm_config method. Seems that bt controller responds to

HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM

command. But why we still have an issue with audio? The answer is simple: SCO configuration can not be completed because bt_hci blocks events and callbacks are not called at all! If device uses

SCO_INTERFACE_PCM

bus interface then hw_sco_i2spcm_config method will send 3 commands:

HCI_VSC_WRITE_I2SPCM_INTERFACE_PARAM

,

HCI_VSC_WRITE_SCO_PCM_INT_PARAM

,

HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM

. Each next command will be sent only if previous was sent successfully and controller responded with correct status. Сontroller responds, but bt_hci blocks the very first event and SCO configuration fails.

We have 2 possible solutions here:

1) Understand why bt_hci blocks events... This is ideal solution, but not easy! bt_hci is a part of system bluetooth stack and bluetooth stack is huge!

2) Send all the necessary commands without waiting for response from bt controller. Yep, i know how it sounds but it works! At least for now...

I've implemented solution #2. Look at hw_config_continue_sco_setup method. It works just like the hw_set_SCO_codec method but doesn't wait for response from bt controller. Why the hw_set_SCO_codec? Because it sends one more command related to WBS before calling the hw_sco_i2spcm_config.

As i said before i think this solution is terrible. Here are my concerns about it:

1) Uncontrolled commands sent to bt controller. Who knows how long this will work...

2) Can be applied only for broadcom chips.

That's all I found at the moment. I will try to implement the solution #1, but I can't tell whether it will work. Feel free to contact me if you have any questions/ideas/improvements.

Many thank to devs who still support our old hammy! [MENTION=614507]razorloves[/MENTION], [MENTION=4473900]amaces[/MENTION], [MENTION=7730768]EnesSastim[/MENTION], [MENTION=6779822]voidz777[/MENTION], [MENTION=5019037]KiD3991[/MENTION], [MENTION=3052425]Hannibal226[/MENTION], [MENTION=5885031]hhrokarvi[/MENTION], [MENTION=7412373]Sashko98[/MENTION] and many other! You guys are awesome! Thanks a lot for your work!!! All this would be impossible without you!!!

PS: Sorry for my terrible english :)