This feature has been raised on the Qualcomm platform and Samsung platforms, based on Android 6.0, which uses the Bluetooth feature on the phone as a Bluetooth headset. Bluetooth phone and Bluetooth music between them, the difference between the high-real-time Bluetooth phone calls, and its A2DP use of the physical path is not consistent, Bluetooth phone to take the PCM physical path, while Bluetooth music to go the UART path. Key Words
hfpclient BT SCO ATA command
When debugging this function, it is best to test first, whether the following signal indicators meet the requirements, so as to avoid stalling and disconnection and other unreliable factors.
In addition, to test the frequency offset, its crystal oscillator and peripheral capacitance and other devices will also affect, generally in plus or minus 10, otherwise it may also lead to the phenomenon of stalling or disconnection. Turn on HFP client Support
First, open the HFP client role feature.
Packages/apps/bluetooth/res/values/config.xml
<bool name= "PROFILE_SUPPORTED_HS_HFP" >false</bool >
<bool name= "Profile_supported_hfpclient" >true</bool>
First, open the HFP client role feature.
After the modification to support the phone function, but the phone will be disconnected after the connection, and the following error message:
01-12 17:51:58.850 3319 3572 E bt_rfcomm:port_dataind, p_port:0xe2ece48c, p_data_co_callback is null
01-12 17:51:58.850 3319 3572 E bt_btif:HFPClient:Failed to create SLC due to at error, disconnecting (2)
The screenshot is as follows:
Error message prompt is
hfpclient:failed to create SLC due to at error, disconnecting (2)
This is a hint at the AT command error, and the Bluetooth phone uses a subset of AT commands. This is because codec negotiate features are not supported and modified as follows:
system/bt/bta/hf_client/bta_hf_client_at.c
static void Bta_hf_client_handle_brsf (UINT32 value)
{
APPL _trace_debug ("%s 0x%x", __function__, value);
- bta_hf_client_cb.scb.peer_features = value;
+ Bta_hf_client_cb.scb.peer_features = value & ~0x200;
}
There should be a Bluetooth beep sound appearing here. That is, the Bluetooth call event can respond normally, but the call response is to go through the UART is the AT command protocol, the Beep is HFP the client comes with.
The codec negotiate is designed to support wideband voice signals, support 16KHz voice signals, and in support of this feature, hfpclient and devices are negotiated to anticipate the use of WBS mode data.
Headsetclientstatemachine.java
If you want to change the Bluetooth alert tone, modify the following file;
@@ -126,7 +126,7 @@ -126,7 class Headsetclientstatemachine extends StateMachine {
private int mindicatorcallheld;
Private Boolean mvgsfromstack = false;
Private Boolean mvgmfromstack = false;
- private Uri alert = Ringtonemanager.getdefaulturi (ringtonemanager.type_alarm);
+ Private Uri alert = Ringtonemanager.getdefaulturi (ringtonemanager.type_notification);
With + + + is the debug information, enter Audioon is to enter the voice of the Bluetooth phone, you can see the voice sampling rate is 8KHz.
the physical path of Bluetooth voice
As mentioned at the beginning, the voice data does not go to the UART, but instead goes to PCM or IIS, this information in:
Hardware/broadcom/libbt/src/hardware.c
Of course, the Qualcomm platform does not use Broadcom chip, there will be no problem, and the directory and code differences are very large, basically Qualcomm will be the bottom of the details are shielded, the high-pass ADSP access, developers do not even need to relate to the voice of the underlying physical path.
#define HCI_VSC_WRITE_PCM_DATA_FORMAT_PARAM 0xfc1e
#define Hci_vsc_write_i2spcm_interface_param 0xfc6d
#define HCI_VSC_ENABLE_WBS 0xfc7e
This is the data format defined by the Samsung platform using the Broadcom chip, which can be seen when using the Btsnoop tool to capture data. Btsnoop captured data can be parsed using the Comprobe tool.
#define HCI_VSC_WRITE_SCO_PCM_INT_PARAM 0xfc1c
/* Do we need this VSC for I2S??? *
/Uint16_to_stream (P, hci_ Vsc_write_sco_pcm_int_param);
*p++ = sco_pcm_param_size;
memcpy (P, &bt_sco_param, sco_pcm_param_size);
Alogi ("SCO PCM Configure {0x%x, 0x%x, 0x%x, 0x%x, 0x%x}",
bt_sco_param[0], bt_sco_param[1], bt_sco_param[2], bt_sco_ PARAM[3],
bt_sco_param[4]);
if (ret = BT_VENDOR_CBACKS->XMIT_CB (Hci_vsc_write_sco_pcm_int_param, P_buf,
hw_sco_i2spcm_cfg_cback) = = FALSE)
{
bt_vendor_cbacks->dealloc (p_buf);
}
else
return;
If it is based on the mobile phone program, the basic above setup is possible. The figure of the mobile phone scheme is as follows (omitted)
However, if the BT PCM is not directly connected to the codec, but as the UART and directly connected to the AP, this will involve the change of the driver.
First, the AP side needs to write the driver to the codec implementation of the function is completed by the AP, and the codec and headset devices connected to the AP and headset devices, so there is a part of the Audiopolicy, after all, the most basic is the audio Engin The choice of audio device, because it is a call scene, need to use low latency buffer, or the like, Aosp in this category. Gao Qualcomm's ADSP also has architecture support from hardware to software.
The kernel modification involves the writing of the Alsa driver, mainly including the device tree, PCM driver, machine Drive and BT virtual out of the codec driver, because BT hardware configuration etc on Android 6. 0 o'clock is placed in the Bluetooth protocol stack, so it is a good solution to use the virtual codec implementation here.
The configuration of BT is as follows:
1) hardware/broadcom/libbt/include/vnd_avl8890.txt?
Sco_i2spcm_if_role = 1
sco_pcm_if_clock_mode = 1
sco_pcm_if_sync_mode = 1
1 changed to 0 -"0 is slave,1 is master
2) The flag in the above TXT will eventually affect the bt_vendor_brcm.h, you need to check the BT settings inside with the AP-side PCM settings are the same
as:/
* Pcm_data_fmt_shift_mode 0:MSB First 1:LSB First */
#ifndef pcm_data_fmt_shift_mode
#define PCM_DATA_FMT_SHIFT_MODE 0
#endif
The relevant driver is associated with the AP, which is skipped here, APK layer Debug case see next article