components/coex: backports for coex schm

1. support 40M Wi-Fi when calculate AFH

2. Calculate channel classification according to Host and coex

3. Set BR/EDR/LE coex schm status in controller

4. Only set AFH for BT when WiFi is connected

5. Fix a potential dead lock issue when set AFH

6. Fix WiFi connecting coex schm issue due to periodic timer

7. Complete BT a2dp pause coex schm

8. Increase BT slice when BT a2dp pause in order to receive AVRC event

9. Add more coex schm for BT/BLE
This commit is contained in:
baohongde
2020-01-14 16:30:33 +08:00
parent be10cc6251
commit 818ea3e3ce
13 changed files with 51 additions and 197 deletions

View File

@@ -1065,37 +1065,6 @@ menu Wi-Fi
If only Bluetooth is used, it is recommended to disable this option to reduce binary file
size.
choice SW_COEXIST_PREFERENCE
prompt "WiFi/Bluetooth coexistence performance preference"
depends on SW_COEXIST_ENABLE
default SW_COEXIST_PREFERENCE_BALANCE
help
Choose Bluetooth/WiFi/Balance for different preference.
If choose WiFi, it will make WiFi performance better. Such, keep WiFi Audio more fluent.
If choose Bluetooth, it will make Bluetooth performance better. Such, keep Bluetooth(A2DP) Audio more
fluent.
If choose Balance, the performance of WiFi and bluetooth will be balance. It's default. Normally, just
choose balance, the A2DP audio can play fluently, too.
Except config preference in menuconfig, you can also call esp_coex_preference_set() dynamically.
config SW_COEXIST_PREFERENCE_WIFI
bool "WiFi"
config SW_COEXIST_PREFERENCE_BT
bool "Bluetooth(include BR/EDR and BLE)"
config SW_COEXIST_PREFERENCE_BALANCE
bool "Balance"
endchoice
config SW_COEXIST_PREFERENCE_VALUE
int
depends on SW_COEXIST_ENABLE
default 0 if SW_COEXIST_PREFERENCE_WIFI
default 1 if SW_COEXIST_PREFERENCE_BT
default 2 if SW_COEXIST_PREFERENCE_BALANCE
config ESP32_WIFI_STATIC_RX_BUFFER_NUM
int "Max number of WiFi static RX buffers"
range 2 25 if !WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST

View File

@@ -24,8 +24,3 @@ esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
{
return coex_preference_set((coex_prefer_t)prefer);
}
esp_err_t esp_coex_wifi_percent_set(int wifi_percent)
{
return coex_wifi_percent_set(wifi_percent);
}

View File

@@ -422,10 +422,6 @@ void start_cpu0_default(void)
#if CONFIG_SW_COEXIST_ENABLE
esp_coex_adapter_register(&g_coex_adapter_funcs);
coex_pre_init();
coex_preference_set(CONFIG_SW_COEXIST_PREFERENCE_VALUE);
extern esp_err_t coex_schm_init(void);
coex_schm_init();
#endif
bootloader_flash_update_id();

View File

@@ -32,6 +32,22 @@ typedef enum {
ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
} esp_coex_prefer_t;
/**
* @brief coex status type
*/
typedef enum {
ESP_COEX_ST_TYPE_WIFI = 0,
ESP_COEX_ST_TYPE_BLE,
ESP_COEX_ST_TYPE_BT,
} esp_coex_status_type_t;
#define ESP_COEX_BLE_ST_MESH_CONFIG 0x08
#define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10
#define ESP_COEX_BLE_ST_MESH_STANDBY 0x20
#define ESP_COEX_BT_ST_A2DP_STREAMING 0x10
#define ESP_COEX_BT_ST_A2DP_PAUSED 0x20
/**
* @brief Get software coexist version string
*
@@ -40,7 +56,8 @@ typedef enum {
const char *esp_coex_version_get(void);
/**
* @brief Set coexist preference of performance
* @deprecated Use esp_coex_status_bit_set() and esp_coex_status_bit_clear() instead.
* Set coexist preference of performance
* For example, if prefer to bluetooth, then it will make A2DP(play audio via classic bt)
* more smooth while wifi is runnning something.
* If prefer to wifi, it will do similar things as prefer to bluetooth.
@@ -52,13 +69,21 @@ const char *esp_coex_version_get(void);
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer);
/**
* @brief Set coexist wifi_percent
* Default is 50%. The range is 10% <= wifi_percent <= 90%.
*
* @param prefer : percent without %. Eg: 70 means 70%
* @return : ESP_OK - success, other - failed
* @brief Set coex schm status
* @param type : WIFI/BLE/BT
* @param status : WIFI/BLE/BT STATUS
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_coex_wifi_percent_set(int wifi_percent);
esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status);
/**
* @brief Clear coex schm status
* @param type : WIFI/BLE/BT
* @param status : WIFI/BLE/BT STATUS
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status);
#ifdef __cplusplus
}

View File

@@ -31,28 +31,6 @@ typedef enum {
typedef void (* coex_func_cb_t)(uint32_t event, int sched_cnt);
typedef enum {
COEX_SCHM_ST_TYPE_WIFI = 0,
COEX_SCHM_ST_TYPE_BLE,
COEX_SCHM_ST_TYPE_BT,
} coex_schm_st_type_t;
#define COEX_SCHM_BLE_ST_IDLE 0x0
#define COEX_SCHM_BLE_ST_ADV 0x01
#define COEX_SCHM_BLE_ST_SCAN 0x02
#define COEX_SCHM_BLE_ST_CONNECTED 0x04
#define COEX_SCHM_BLE_ST_MESH_CONFIG 0x08
#define COEX_SCHM_BLE_ST_MESH_TRAFFIC 0x10
#define COEX_SCHM_BLE_ST_MESH_STANDBY 0x20
#define COEX_SCHM_BT_ST_IDLE 0x0
#define COEX_SCHM_BT_ST_ISCAN 0x01
#define COEX_SCHM_BT_ST_INQ 0x02
#define COEX_SCHM_BT_ST_ACL_CONNECTED 0x04
#define COEX_SCHM_BT_ST_SNIFF 0x08
#define COEX_SCHM_BT_ST_A2DP_STREAMING 0x10
#define COEX_SCHM_BT_ST_A2DP_PAUSED 0x20
/**
* @brief Pre-Init software coexist
* extern function for internal use.
@@ -102,36 +80,12 @@ const char *coex_version_get(void);
*/
esp_err_t coex_preference_set(coex_prefer_t prefer);
/**
* @brief Set coexist wifi_percent for internal
* Default is 50%. The range is 10% <= wifi_percent <= 90%.
*
* @param prefer : percent without %. Eg: 70 means 70%
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_wifi_percent_set(int wifi_percent);
/**
* @brief Get software coexist status.
* @return : software coexist status
*/
uint32_t coex_status_get(void);
/**
* @brief Set coex schm status
* @param type : WIFI/BLE/BT
* @param status : WIFI/BLE/BT STATUS
* @return : ESP_OK - success, other - failed
*/
esp_err_t coex_schm_status_set(coex_schm_st_type_t type, uint32_t status);
/**
* @brief Get coex schm status
* @param type : WIFI/BLE/BT
* @return : status
*/
uint32_t coex_schm_status_get(coex_schm_st_type_t type);
/**
* @brief Set software coexist condition.
* @return : software coexist condition