Skip to content

Commit

Permalink
Merge branch 'fix/hfp_pcm_api_set_v5.3' into 'release/v5.3'
Browse files Browse the repository at this point in the history
fix(bt/bluedroid): Add PCM configuration about pcm frame sync signal shape (backport v5.3)

See merge request espressif/esp-idf!32483
  • Loading branch information
jack0c committed Aug 21, 2024
2 parents aad4a55 + b1c9475 commit 808950a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32
4 changes: 3 additions & 1 deletion components/bt/include/esp32/include/esp_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -202,6 +202,7 @@ the adv 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 = 0, \
.hli = BTDM_CTRL_HLI, \
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
Expand Down Expand Up @@ -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 */
Expand Down
15 changes: 14 additions & 1 deletion examples/bluetooth/bluedroid/classic_bt/hfp_ag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ 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 two configurations in menuconfig: PCM Role, PCM Polar.

- 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 Config(Role and Polar) --> 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 Config(Role and Polar) --> PCM Polar`

The default configuration of PCM frame synchronization signal is `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. As is shown in the figure ![Stereo](image/Channel_Mode.png)
The latest version of esp-idf master branch can configure three different forms(Stereo mode, Mono mode 1, Mono mode 2).

### Codec Choice

ESP32 supports two types of codec for HFP audio data: `CVSD` and `mSBC`.
Expand Down Expand Up @@ -75,7 +88,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.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 17 additions & 4 deletions examples/bluetooth/bluedroid/classic_bt/hfp_hf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ 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 two configurations in menuconfig: PCM Role, PCM Polar.

- 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 Config(Role and Polar) --> 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 Config(Role and Polar) --> PCM Polar`

The default configuration of PCM frame synchronization signal is `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. As is shown in the figure ![Stereo](../hfp_ag/image/Channel_Mode.png)
The latest version of esp-idf master branch can configure three different forms(Stereo mode, Mono mode 1, Mono mode 2).

### Codec Choice

ESP32 supports two types of codec for HFP audio data: `CVSD` and `mSBC`.
Expand All @@ -53,7 +66,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.

Expand All @@ -77,7 +90,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.
Expand Down Expand Up @@ -167,7 +180,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`.

Expand Down Expand Up @@ -268,7 +281,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
Expand Down

0 comments on commit 808950a

Please sign in to comment.