Merge branch 'fix/hfp_pcm_api_set' into 'master'

fix(bt/bluedroid): Add PCM configuration about pcm frame sync signal shape

Closes BT-3809

See merge request espressif/esp-idf!32265
This commit is contained in:
Wang Meng Yang 2024-07-30 21:11:26 +08:00
commit f3f8618eee
6 changed files with 86 additions and 8 deletions

View File

@ -67,7 +67,7 @@ config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF
default 0
menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
bool "PCM Signal Config (Role and Polar)"
bool "PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono)"
depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default y
@ -95,6 +95,37 @@ choice BTDM_CTRL_PCM_POLAR
bool "Rising Edge"
endchoice
choice BTDM_CTRL_PCM_FSYNCSHP
prompt "Channel Mode(Stereo/Mono)"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
default BTDM_CTRL_PCM_FSYNCSHP_STEREO_MODE
help
PCM frame synchronization signal shape can be configured as Stereo Mode or Mono Mode.
(There are detailed instructions under the path examples/bluetooth/bluedroid/classic_bt/hfp_ag/README.md)
config BTDM_CTRL_PCM_FSYNCSHP_STEREO_MODE
bool "Stereo Mode"
help
Stereo Mode(Dual channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK.
The FSYNC signal continues until the end of the current channel-data transmission.
(There is a waveform graph under the path examples/bluetooth/bluedroid/classic_bt/hfp_ag/image)
config BTDM_CTRL_PCM_FSYNCSHP_MONO_MODE_LF
bool "Mono Mode 1"
help
Mono Mode 1(Single channel): FSYNC signal starts to change a CLK clock cycle earlier than the DOUT signal.
The FSYNC signal continues for one extra CLK clock cycle.
(There is a waveform graph under the path examples/bluetooth/bluedroid/classic_bt/hfp_ag/image)
config BTDM_CTRL_PCM_FSYNCSHP_MONO_MODE_FF
bool "Mono Mode 2"
help
Mono Mode 2(Single channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK.
The FSYNC signal continues for one extra CLK clock cycle.
(There is a waveform graph under the path examples/bluetooth/bluedroid/classic_bt/hfp_ag/image)
endchoice
config BTDM_CTRL_PCM_ROLE_EFF
int
default 0 if BTDM_CTRL_PCM_ROLE_MASTER
@ -107,6 +138,13 @@ config BTDM_CTRL_PCM_POLAR_EFF
default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
default 0
config BTDM_CTRL_PCM_FSYNCSHP_EFF
int
default 0 if BTDM_CTRL_PCM_FSYNCSHP_STEREO_MODE
default 1 if BTDM_CTRL_PCM_FSYNCSHP_MONO_MODE_LF
default 2 if BTDM_CTRL_PCM_FSYNCSHP_MONO_MODE_FF
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM

@ -1 +1 @@
Subproject commit b814f26bbb3d726418c0f80f9f91153dfd978f85
Subproject commit ad0d5df0b9890c783c02da126df8a979e5ca1cf9

View File

@ -55,7 +55,7 @@ extern "C" {
*
* @note Please do not modify this value
*/
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240315
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240722
/**
* @brief Bluetooth Controller mode
@ -202,6 +202,7 @@ the advertising packet will be discarded until the memory is restored. */
.ble_sca = CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF, \
.pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
.pcm_fsyncshp = CONFIG_BTDM_CTRL_PCM_FSYNCSHP_EFF, \
.hli = BTDM_CTRL_HLI, \
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
@ -253,6 +254,7 @@ typedef struct {
uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig */
uint8_t pcm_role; /*!< PCM role (master & slave). Configurable in menuconfig */
uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge). Configurable in menuconfig */
uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal (stereo mode & mono mode). Configurable in menuconfig */
bool hli; /*!< True if using high level interrupt; false otherwise. Configurable in menuconfig */
uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig */
bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig */

View File

@ -43,6 +43,25 @@ The default configuration is `PCM`, if you want to use `vHCI` you should configu
`Component config --> Bluetooth --> Bluedroid Options --> Hands Free/Handset Profile --> audio(SCO) data path --> HCI`.
#### PCM Signal Configurations
PCM Signal supports three configurations in menuconfig: PCM Role, PCM Polar and Channel Mode(Stereo/Mono).
- PCM Role: PCM role can be configured as PCM master or PCM slave. The default configuration is `Master`, you can change the PCM role in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> PCM Role`
- PCM Polar: PCM polarity can be configured as Falling Edge or Rising Edge. The default configuration is `Falling Edge`, you can change the PCM polar in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> PCM Polar`
- Channel Mode(Stereo/Mono): PCM frame synchronization signal can be configured as Stereo mode or Mono mode, where the Mono mode can be configured in two different forms(Mono mode 1 and Mono mode 2). As is shown in the figure ![Stereo/Mono](image/Channel_Mode_Stereo_Mono.png)
- Stereo Mode(Dual channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK. The FSYNC signal continues until the end of the current channel-data transmission.
- Mono Mode 1(Single channel): FSYNC signal starts to change a CLK clock cycle earlier than the DOUT signal, which means that the FSYNC signal takes effect a clock cycle earlier than the first bit of the current channel-data transmission. The FSYNC signal continues for one extra CLK clock cycle.
- Mono Mode 2(Single channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK. The FSYNC signal continues for one extra CLK clock cycle.
- The default configuration is `Stereo Mode`, you can change the PCM Channel mode in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> Channel Mode(Stereo/Mono)`
### Codec Choice
ESP32 supports two types of codec for HFP audio data: `CVSD` and `mSBC`.
@ -75,7 +94,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
## Example Output
When you flash and monitor this example, the commands help table prints the following log at the very begining:
When you flash and monitor this example, the commands help table prints the following log at the very beginning:
```
Type 'help' to get the list of commands.

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -45,6 +45,25 @@ The default configuration is `PCM`, if you want to use `vHCI` you should configu
`Component config --> Bluetooth --> Bluedroid Options --> Hands Free/Handset Profile --> audio(SCO) data path --> HCI`.
#### PCM Signal Configurations
PCM Signal supports three configurations in menuconfig: PCM Role, PCM Polar and Channel Mode(Stereo/Mono).
- PCM Role: PCM role can be configured as PCM master or PCM slave. The default configuration is `Master`, you can change the PCM role in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> PCM Role`
- PCM Polar: PCM polarity can be configured as Falling Edge or Rising Edge. The default configuration is `Falling Edge`, you can change the PCM polar in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> PCM Polar`
- Channel Mode(Stereo/Mono): PCM frame synchronization signal can be configured as Stereo mode or Mono mode, where the Mono mode can be configured in two different forms(Mono mode 1 and Mono mode 2). As is shown in the figure ![Stereo/Mono](../hfp_ag/image/Channel_Mode_Stereo_Mono.png)
- Stereo Mode(Dual channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK. The FSYNC signal continues until the end of the current channel-data transmission.
- Mono Mode 1(Single channel): FSYNC signal starts to change a CLK clock cycle earlier than the DOUT signal, which means that the FSYNC signal takes effect a clock cycle earlier than the first bit of the current channel-data transmission. The FSYNC signal continues for one extra CLK clock cycle.
- Mono Mode 2(Single channel): FSYNC and DOUT signals both change simultaneously on the edge of CLK. The FSYNC signal continues for one extra CLK clock cycle.
- The default configuration is `Stereo Mode`, you can change the PCM Channel mode in `menuconfig` path:
`Component config --> Bluetooth --> Controller Options --> PCM Signal Configurations --> PCM Signal Configurations: Role, Polar and Channel Mode(Stereo/Mono) --> Channel Mode(Stereo/Mono)`
### Codec Choice
ESP32 supports two types of codec for HFP audio data: `CVSD` and `mSBC`.
@ -53,7 +72,7 @@ ESP32 supports two types of codec for HFP audio data: `CVSD` and `mSBC`.
`Component config --> Bluetooth --> Bluedroid Options --> Wide Band Speech`.
Switching on the `Wide Band Speech` means that the prefered codec is `mSBC`, but which one is actually being used also depends on the `Data Path` configuration.
Switching on the `Wide Band Speech` means that the preferred codec is `mSBC`, but which one is actually being used also depends on the `Data Path` configuration.
- If you choose `PCM` for datapath, you can only use `CVSD` and hardware is responsible for the codec job. In the meanwhile, you cannot use `mSBC` by switching `Wide Band Speech` on, because the `mSBC` is implemented in the Bluedroid (Bluetooth Host Stack) by software.
@ -77,7 +96,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
## Example Output
When you run this example, the explain prints the following at the very begining:
When you run this example, the explain prints the following at the very beginning:
```
Type 'help' to get the list of commands.
@ -167,7 +186,7 @@ I (133262) BT_HF: --audio state disconnected
- Reject an incoming call
- Disable the voice recognition
#### Choise of Codec
#### Choice of Codec
ESP32 supports both CVSD and mSBC codec. HF Unit and AG device determine which codec to use by exchanging features during service level connection. The choice of codec also depends on the your configuration in `menuconfig`.
@ -268,7 +287,7 @@ I (293172) BT_HF: APP HFP event: AT_RESPONSE
I (293172) BT_HF: --AT response event, code 0, cme 0
E (293702) BT_BTM: btm_sco_connected, handle 181
I (293702) BT_HF: APP HFP event: AUDIO_STATE_EVT
I (293702) BT_HF: --audio state connecte
I (293702) BT_HF: --audio state connected
```
#### Query Current Operator Name