Skip to content

Commit 63e5cbb

Browse files
component/bt: Added the bluedroid environment variable dynomic malloc support & support to malloc the memory to the psram.
component/bt: Added the Macro for the classic BT support. component/bt: added the bluedroid deinit method. component/bt: allow more classic BT global variables to use dynamic allocation scheme 1. allocate memory for AVDT, AVCT control blocks when dynamic memory is used 2. allow SBC decoder buffer to use dynamic allocation scheme component/bt: Remove the wrong changes in bt/Kconfig & Added the GATTS_INCLUDED in the gatt_free function when gatt service close. component/bt: Shorten the abbreviation BT_ALLOCATION_FROM_SPIRAM_FIRST and BT_BLE_DYNAMIC_ENV_MEMORY two macros.
1 parent 2a10ffc commit 63e5cbb

38 files changed

+379
-51
lines changed

components/bt/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ config BT_ACL_CONNECTIONS
173173
help
174174
Maximum BT/BLE connection count
175175

176+
config BT_ALLOCATION_FROM_SPIRAM_FIRST
177+
bool "BT/BLE will first malloc the memory from the PSRAM"
178+
depends on BLUEDROID_ENABLED
179+
default n
180+
help
181+
This select can save the internal RAM if there have the PSRAM
182+
183+
config BT_BLE_DYNAMIC_ENV_MEMORY
184+
bool "Use dynamic memory allocation in BT/BLE stack"
185+
depends on BLUEDROID_ENABLED
186+
default n
187+
help
188+
This select can make the allocation of memory will become more flexible
189+
176190
config SMP_ENABLE
177191
bool
178192
depends on BLUEDROID_ENABLED

components/bt/bluedroid/bta/ar/bta_ar.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
/* AV control block */
3333
#if BTA_DYNAMIC_MEMORY == FALSE
3434
tBTA_AR_CB bta_ar_cb;
35+
#else
36+
tBTA_AR_CB *bta_ar_cb_ptr;
3537
#endif
3638

3739
/*******************************************************************************

components/bt/bluedroid/bta/av/bta_av_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ const tBTA_AV_NSM_ACT bta_av_nsm_act[] = {
194194
/* AV control block */
195195
#if BTA_DYNAMIC_MEMORY == FALSE
196196
tBTA_AV_CB bta_av_cb;
197+
#else
198+
tBTA_AV_CB *bta_av_cb_ptr;
197199
#endif
198200

199201
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)

components/bt/bluedroid/bta/dm/bta_dm_main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "bta_api.h"
2626
#include "bta_sys.h"
2727
#include "bta_dm_int.h"
28+
#include "allocator.h"
29+
#include <string.h>
2830

2931

3032
/*****************************************************************************
@@ -35,6 +37,10 @@
3537
tBTA_DM_CB bta_dm_cb;
3638
tBTA_DM_SEARCH_CB bta_dm_search_cb;
3739
tBTA_DM_DI_CB bta_dm_di_cb;
40+
#else
41+
tBTA_DM_CB *bta_dm_cb_ptr;
42+
tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
43+
tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
3844
#endif
3945

4046

@@ -346,6 +352,18 @@ void bta_dm_sm_disable( )
346352
bta_sys_deregister( BTA_ID_DM );
347353
}
348354

355+
void bta_dm_sm_deinit(void)
356+
{
357+
memset(&bta_dm_cb, 0, sizeof(tBTA_DM_CB));
358+
memset(&bta_dm_search_cb, 0, sizeof(tBTA_DM_SEARCH_CB));
359+
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
360+
#if BTA_DYNAMIC_MEMORY
361+
FREE_AND_RESET(bta_dm_cb_ptr);
362+
FREE_AND_RESET(bta_dm_search_cb_ptr);
363+
FREE_AND_RESET(bta_dm_di_cb_ptr);
364+
#endif /* #if BTA_DYNAMIC_MEMORY */
365+
}
366+
349367

350368
/*******************************************************************************
351369
**

components/bt/bluedroid/bta/gatt/bta_gattc_main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <string.h>
3030

3131
#include "bta_gattc_int.h"
32+
#include "allocator.h"
3233

3334

3435
/*****************************************************************************
@@ -237,6 +238,8 @@ const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] = {
237238
/* GATTC control block */
238239
#if BTA_DYNAMIC_MEMORY == FALSE
239240
tBTA_GATTC_CB bta_gattc_cb;
241+
#else
242+
tBTA_GATTC_CB *bta_gattc_cb_ptr;
240243
#endif
241244

242245
#if BTA_GATT_DEBUG == TRUE
@@ -493,4 +496,12 @@ static char *gattc_state_code(tBTA_GATTC_STATE state_code)
493496
}
494497

495498
#endif /* Debug Functions */
499+
500+
void bta_gattc_deinit(void)
501+
{
502+
#if BTA_DYNAMIC_MEMORY
503+
memset(bta_gattc_cb_ptr, 0, sizeof(tBTA_GATTC_CB));
504+
FREE_AND_RESET(bta_gattc_cb_ptr);
505+
#endif /* #if BTA_DYNAMIC_MEMORY */
506+
}
496507
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */

components/bt/bluedroid/bta/gatt/bta_gatts_main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <string.h>
3030

3131
#include "bta_gatts_int.h"
32+
#include "allocator.h"
3233

3334
/* type for service building action functions */
3435
typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);
@@ -46,6 +47,8 @@ const tBTA_GATTS_SRVC_ACT bta_gatts_srvc_build_act[] = {
4647
/* GATTS control block */
4748
#if BTA_DYNAMIC_MEMORY == FALSE
4849
tBTA_GATTS_CB bta_gatts_cb;
50+
#else
51+
tBTA_GATTS_CB *bta_gatts_cb_ptr;
4952
#endif
5053

5154
/*******************************************************************************
@@ -135,4 +138,12 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
135138
return (TRUE);
136139
}
137140

141+
void bta_gatts_deinit(void)
142+
{
143+
memset(&bta_gatts_cb, 0, sizeof(tBTA_GATTS_CB));
144+
#if BTA_DYNAMIC_MEMORY
145+
FREE_AND_RESET(bta_gatts_cb_ptr);
146+
#endif /* #if BTA_DYNAMIC_MEMORY */
147+
}
148+
138149
#endif /* GATTS_INCLUDED */

components/bt/bluedroid/bta/hh/bta_hh_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ const tBTA_HH_ST_TBL bta_hh_st_tbl[] = {
245245
*****************************************************************************/
246246
#if BTA_DYNAMIC_MEMORY == FALSE
247247
tBTA_HH_CB bta_hh_cb;
248+
#else
249+
tBTA_HH_CB *bta_hh_cb_ptr;
248250
#endif
249251
/*****************************************************************************
250252
** Static functions

components/bt/bluedroid/bta/dm/bta_dm_int.h renamed to components/bt/bluedroid/bta/include/bta_dm_int.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
11301130

11311131
extern BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg);
11321132
extern void bta_dm_sm_disable( void );
1133+
extern void bta_dm_sm_deinit(void);
11331134
extern BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg);
11341135
extern void bta_dm_search_sm_disable( void );
11351136

0 commit comments

Comments
 (0)