mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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:
parent
be10cc6251
commit
818ea3e3ce
@ -903,30 +903,6 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
(p_vendor->company_id == AVRC_CO_METADATA)) {
|
||||
av.meta_msg.p_msg = &p_data->rc_msg.msg;
|
||||
evt = BTA_AV_META_MSG_EVT;
|
||||
|
||||
tAVRC_MSG_VENDOR *vendor_msg = &av.meta_msg.p_msg->vendor;
|
||||
if (vendor_msg->hdr.ctype == AVRC_RSP_CHANGED) {
|
||||
if (vendor_msg->p_vendor_data[0] == AVRC_PDU_REGISTER_NOTIFICATION){
|
||||
uint8_t event_id = vendor_msg->p_vendor_data[4];
|
||||
if(event_id == 1){ //ESP_AVRC_RN_PLAY_STATUS_CHANGE
|
||||
uint8_t play_status = vendor_msg->p_vendor_data[5];
|
||||
switch(play_status) {
|
||||
case 0: //stopped
|
||||
case 2: //paused *
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_A2DP_PAUSED_ENTER);
|
||||
break;
|
||||
case 1: //playing *
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_A2DP_PAUSED_EXIT);
|
||||
break;
|
||||
case 3: //FWD_seek
|
||||
case 4: //REV_seek
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -693,13 +693,6 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
if (p_data->set_visibility.pair_mode != BTA_DM_IGNORE || p_data->set_visibility.conn_paired_only != BTA_DM_IGNORE) {
|
||||
BTM_SetPairableMode((BOOLEAN)(!(bta_dm_cb.disable_pair_mode)), bta_dm_cb.conn_paired_only);
|
||||
}
|
||||
|
||||
if (((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_NON_CONN) &&
|
||||
((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_NON_DISC)) {
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_SCAN_STOPPED);
|
||||
} else {
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_SCAN_STARTED);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "osi/allocator.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_coexist.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@ -455,79 +455,31 @@ BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
|
||||
|
||||
void BTA_DmCoexEventTrigger(uint32_t event)
|
||||
{
|
||||
uint8_t bt_status = 0;
|
||||
|
||||
switch(event) {
|
||||
case BTA_COEX_EVT_SCAN_STARTED:
|
||||
bta_dm_cb.coex_scan_st = true;
|
||||
break;
|
||||
case BTA_COEX_EVT_SCAN_STOPPED:
|
||||
bta_dm_cb.coex_scan_st = false;
|
||||
case BTA_COEX_EVT_SNIFF_ENTER:
|
||||
case BTA_COEX_EVT_SNIFF_EXIT:
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_ENTER:
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_EXIT:
|
||||
break;
|
||||
case BTA_COEX_EVT_ACL_CONNECTED:
|
||||
bta_dm_cb.coex_acl_st = true;
|
||||
// clear streaming state and sniff state;
|
||||
bta_dm_cb.coex_streaming_st = false;
|
||||
bta_dm_cb.coex_sniff_st = false;
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
|
||||
break;
|
||||
case BTA_COEX_EVT_ACL_DISCONNECTED:
|
||||
bta_dm_cb.coex_acl_st = false;
|
||||
// clear streaming state and sniff state;
|
||||
bta_dm_cb.coex_streaming_st = false;
|
||||
bta_dm_cb.coex_sniff_st = false;
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
|
||||
break;
|
||||
case BTA_COEX_EVT_STREAMING_STARTED:
|
||||
bta_dm_cb.coex_streaming_st = true;
|
||||
bta_dm_cb.coex_a2dp_paused_st = false;
|
||||
esp_coex_status_bit_set(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
|
||||
break;
|
||||
case BTA_COEX_EVT_STREAMING_STOPPED:
|
||||
bta_dm_cb.coex_streaming_st = false;
|
||||
bta_dm_cb.coex_a2dp_paused_st = false;
|
||||
break;
|
||||
case BTA_COEX_EVT_SNIFF_ENTER:
|
||||
bta_dm_cb.coex_sniff_st = true;
|
||||
break;
|
||||
case BTA_COEX_EVT_SNIFF_EXIT:
|
||||
bta_dm_cb.coex_sniff_st = false;
|
||||
break;
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_ENTER:
|
||||
bta_dm_cb.coex_a2dp_paused_st = true;
|
||||
break;
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_EXIT:
|
||||
bta_dm_cb.coex_a2dp_paused_st = false;
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_STREAMING);
|
||||
esp_coex_status_bit_clear(ESP_COEX_ST_TYPE_BT, ESP_COEX_BT_ST_A2DP_PAUSED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (bta_dm_cb.coex_scan_st) {
|
||||
bt_status = coex_schm_status_get(COEX_SCHM_ST_TYPE_BT) | COEX_SCHM_BT_ST_ISCAN;
|
||||
} else {
|
||||
bt_status = coex_schm_status_get(COEX_SCHM_ST_TYPE_BT) & (~COEX_SCHM_BT_ST_ISCAN);
|
||||
}
|
||||
|
||||
bt_status = bt_status & (~COEX_SCHM_BT_ST_A2DP_PAUSED);
|
||||
|
||||
// acl st may overwrite the wifi_percent set by coex_scan_st
|
||||
if (bta_dm_cb.coex_acl_st) {
|
||||
bt_status = bt_status | COEX_SCHM_BT_ST_ACL_CONNECTED;
|
||||
|
||||
if (bta_dm_cb.coex_a2dp_paused_st) {
|
||||
bt_status = bt_status | COEX_SCHM_BT_ST_A2DP_PAUSED;
|
||||
} else if (bta_dm_cb.coex_streaming_st) {
|
||||
bt_status = bt_status | COEX_SCHM_BT_ST_A2DP_STREAMING;
|
||||
} else if (bta_dm_cb.coex_sniff_st) {
|
||||
bt_status = (bt_status & (~COEX_SCHM_BT_ST_A2DP_STREAMING)) | COEX_SCHM_BT_ST_SNIFF;
|
||||
} else {
|
||||
// not streaming, not sniff, acl connected
|
||||
bt_status = bt_status & (~(COEX_SCHM_BT_ST_A2DP_STREAMING | COEX_SCHM_BT_ST_SNIFF));
|
||||
}
|
||||
} else {
|
||||
bt_status = (bt_status & ~(COEX_SCHM_BT_ST_A2DP_STREAMING | COEX_SCHM_BT_ST_ACL_CONNECTED | COEX_SCHM_BT_ST_SNIFF));
|
||||
}
|
||||
|
||||
coex_schm_status_set(COEX_SCHM_ST_TYPE_BT, bt_status);
|
||||
APPL_TRACE_EVENT("bt_status %02x", bt_status);
|
||||
printf("bt_status %02x\n", bt_status);
|
||||
}
|
||||
|
||||
}
|
@ -910,7 +910,6 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
bta_dm_pm_stop_timer_by_mode(p_data->pm_status.bd_addr, p_dev->pm_mode_attempted);
|
||||
bta_dm_pm_set_mode(p_data->pm_status.bd_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
|
||||
}
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_SNIFF_EXIT);
|
||||
} else {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
if (p_dev->prev_low) {
|
||||
@ -922,7 +921,6 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
/* link to active mode, need to restart the timer for next low power mode if needed */
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
bta_dm_pm_set_mode(p_data->pm_status.bd_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_SNIFF_EXIT);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -953,7 +951,6 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
* PM timer sole purpose is to put the link
|
||||
* in sniff mode from host side.
|
||||
*/
|
||||
BTA_DmCoexEventTrigger(BTA_COEX_EVT_SNIFF_ENTER);
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
} else {
|
||||
p_dev->info &= ~(BTA_DM_DI_SET_SNIFF | BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF);
|
||||
|
@ -1039,11 +1039,7 @@ typedef struct {
|
||||
|
||||
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
|
||||
TIMER_LIST_ENT switch_delay_timer;
|
||||
bool coex_scan_st;
|
||||
bool coex_acl_st;
|
||||
bool coex_streaming_st;
|
||||
bool coex_sniff_st;
|
||||
bool coex_a2dp_paused_st;
|
||||
|
||||
} tBTA_DM_CB;
|
||||
|
||||
#ifndef BTA_DM_SDP_DB_SIZE
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 11a8f76c5d8480ed47b33913cd1806238fc359d4
|
||||
Subproject commit 7083b45b407ea8aa50609e5d696056c8700c604f
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 28195f5fd68888ea4706731bcf728c2019e707e6
|
||||
Subproject commit 9ef89ade3bc9861d59a56c10d2189d68692e9a2f
|
@ -302,7 +302,8 @@ menu "LWIP"
|
||||
config TCP_SND_BUF_DEFAULT
|
||||
int "Default send buffer size"
|
||||
default 5744 # 4 * default MSS
|
||||
range 2440 65535
|
||||
range 2440 65535 if !LWIP_WND_SCALE
|
||||
range 2440 1024000 if LWIP_WND_SCALE
|
||||
help
|
||||
Set default send buffer size for new TCP sockets.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user