1 /******************************************************************************
3 * Copyright (C) 2003-2012 Broadcom Corporation
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 ******************************************************************************/
19 /******************************************************************************
21 * This is the main implementation file for the BTA system manager.
23 ******************************************************************************/
24 #define LOG_TAG "bt_bta_sys_main"
26 // #include <assert.h>
34 #include "bta_sys_int.h"
36 #include "fixed_queue.h"
39 #include "hash_functions.h"
40 #if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
41 #include "bta_ar_api.h"
44 #include "allocator.h"
48 /* system manager control block definition */
49 #if BTA_DYNAMIC_MEMORY == FALSE
50 tBTA_SYS_CB bta_sys_cb;
52 tBTA_SYS_CB *bta_sys_cb_ptr;
55 static hash_map_t *bta_alarm_hash_map;
56 static const size_t BTA_ALARM_HASH_MAP_SIZE = 17;
57 static osi_mutex_t bta_alarm_lock;
58 // extern thread_t *bt_workqueue_thread;
61 /* TODO Bluedroid - Hard-coded trace levels - Needs to be configurable */
62 UINT8 appl_trace_level = BT_TRACE_LEVEL_WARNING; //APPL_INITIAL_TRACE_LEVEL;
63 UINT8 btif_trace_level = BT_TRACE_LEVEL_WARNING;
65 void btu_bta_alarm_ready(fixed_queue_t *queue);
67 static const tBTA_SYS_REG bta_sys_hw_reg = {
73 /* type for action functions */
74 typedef void (*tBTA_SYS_ACTION)(tBTA_SYS_HW_MSG *p_data);
76 /* action function list */
77 const tBTA_SYS_ACTION bta_sys_action[] = {
78 /* device manager local device API events - cf bta_sys.h for events */
79 bta_sys_hw_api_enable, /* 0 BTA_SYS_HW_API_ENABLE_EVT */
80 bta_sys_hw_evt_enabled, /* 1 BTA_SYS_HW_EVT_ENABLED_EVT */
81 bta_sys_hw_evt_stack_enabled, /* 2 BTA_SYS_HW_EVT_STACK_ENABLED_EVT */
82 bta_sys_hw_api_disable, /* 3 BTA_SYS_HW_API_DISABLE_EVT */
83 bta_sys_hw_evt_disabled, /* 4 BTA_SYS_HW_EVT_DISABLED_EVT */
84 bta_sys_hw_error /* 5 BTA_SYS_HW_ERROR_EVT */
87 /* state machine action enumeration list */
89 /* device manager local device API events */
90 BTA_SYS_HW_API_ENABLE,
91 BTA_SYS_HW_EVT_ENABLED,
92 BTA_SYS_HW_EVT_STACK_ENABLED,
93 BTA_SYS_HW_API_DISABLE,
94 BTA_SYS_HW_EVT_DISABLED,
98 #define BTA_SYS_NUM_ACTIONS (BTA_SYS_MAX_EVT & 0x00ff)
99 #define BTA_SYS_IGNORE BTA_SYS_NUM_ACTIONS
101 /* state table information */
102 #define BTA_SYS_ACTIONS 2 /* number of actions */
103 #define BTA_SYS_NEXT_STATE 2 /* position of next state */
104 #define BTA_SYS_NUM_COLS 3 /* number of columns in state tables */
107 /* state table for OFF state */
108 const UINT8 bta_sys_hw_off[][BTA_SYS_NUM_COLS] = {
109 /* Event Action 1 Action 2 Next State */
110 /* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
111 /* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
112 /* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
113 /* API_DISABLE */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
114 /* EVT_DISABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
115 /* EVT_ERROR */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF}
118 const UINT8 bta_sys_hw_starting[][BTA_SYS_NUM_COLS] = {
119 /* Event Action 1 Action 2 Next State */
120 /* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* wait for completion event */
121 /* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
122 /* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
123 /* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive disable/enable: change state wait for completion to disable */
124 /* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_HW_API_ENABLE, BTA_SYS_HW_STARTING}, /* successive enable/disable: notify, then restart HW */
125 /* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
128 const UINT8 bta_sys_hw_on[][BTA_SYS_NUM_COLS] = {
129 /* Event Action 1 Action 2 Next State */
130 /* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
131 /* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
132 /* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
133 /* API_DISABLE */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON}, /* don't change the state here, as some other modules might be active */
134 /* EVT_DISABLED */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
135 /* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
138 const UINT8 bta_sys_hw_stopping[][BTA_SYS_NUM_COLS] = {
139 /* Event Action 1 Action 2 Next State */
140 /* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* change state, and wait for completion event to enable */
141 /* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: finish the enable before disabling */
142 /* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_HW_API_DISABLE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: notify, then stop */
143 /* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* wait for completion event */
144 /* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
145 /* EVT_ERROR */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}
148 typedef const UINT8 (*tBTA_SYS_ST_TBL)[BTA_SYS_NUM_COLS];
151 const tBTA_SYS_ST_TBL bta_sys_st_tbl[] = {
158 /*******************************************************************************
160 ** Function bta_sys_init
162 ** Description BTA initialization; called from task initialization.
167 *******************************************************************************/
168 void bta_sys_init(void)
170 memset(&bta_sys_cb, 0, sizeof(tBTA_SYS_CB));
172 osi_mutex_new(&bta_alarm_lock);
174 bta_alarm_hash_map = hash_map_new(BTA_ALARM_HASH_MAP_SIZE,
175 hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL);
177 appl_trace_level = APPL_INITIAL_TRACE_LEVEL;
179 /* register BTA SYS message handler */
180 bta_sys_register( BTA_ID_SYS, &bta_sys_hw_reg);
182 /* register for BTM notifications */
183 BTM_RegisterForDeviceStatusNotif ((tBTM_DEV_STATUS_CB *)&bta_sys_hw_btm_cback );
185 #if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
191 void bta_sys_free(void)
193 hash_map_free(bta_alarm_hash_map);
194 osi_mutex_free(&bta_alarm_lock);
195 #if BTA_DYNAMIC_MEMORY
196 FREE_AND_RESET(bta_sys_cb_ptr);
200 /*******************************************************************************
202 ** Function bta_dm_sm_execute
204 ** Description State machine event handling function for DM
209 *******************************************************************************/
210 BOOLEAN bta_sys_sm_execute(BT_HDR *p_msg)
212 BOOLEAN freebuf = TRUE;
213 tBTA_SYS_ST_TBL state_table;
217 APPL_TRACE_EVENT("bta_sys_sm_execute state:%d, event:0x%x\n", bta_sys_cb.state, p_msg->event);
219 /* look up the state table for the current state */
220 state_table = bta_sys_st_tbl[bta_sys_cb.state];
222 bta_sys_cb.state = state_table[p_msg->event & 0x00ff][BTA_SYS_NEXT_STATE];
224 /* execute action functions */
225 for (i = 0; i < BTA_SYS_ACTIONS; i++) {
226 if ((action = state_table[p_msg->event & 0x00ff][i]) != BTA_SYS_IGNORE) {
227 (*bta_sys_action[action])( (tBTA_SYS_HW_MSG *) p_msg);
237 void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback)
239 bta_sys_cb.sys_hw_cback[module] = cback;
243 void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module )
245 bta_sys_cb.sys_hw_cback[module] = NULL;
248 /*******************************************************************************
250 ** Function bta_sys_hw_btm_cback
252 ** Description This function is registered by BTA SYS to BTM in order to get status notifications
257 *******************************************************************************/
258 void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status )
261 tBTA_SYS_HW_MSG *sys_event;
263 APPL_TRACE_DEBUG(" bta_sys_hw_btm_cback was called with parameter: %i" , status );
265 /* send a message to BTA SYS */
266 if ((sys_event = (tBTA_SYS_HW_MSG *) osi_malloc(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
267 if (status == BTM_DEV_STATUS_UP) {
268 sys_event->hdr.event = BTA_SYS_EVT_STACK_ENABLED_EVT;
269 } else if (status == BTM_DEV_STATUS_DOWN) {
270 sys_event->hdr.event = BTA_SYS_ERROR_EVT;
272 /* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
273 osi_free (sys_event);
278 bta_sys_sendmsg(sys_event);
281 APPL_TRACE_DEBUG("ERROR bta_sys_hw_btm_cback couldn't send msg" );
287 /*******************************************************************************
289 ** Function bta_sys_hw_error
291 ** Description In case the HW device stops answering... Try to turn it off, then re-enable all
292 ** previously active SW modules.
294 ** Returns success or failure
296 *******************************************************************************/
297 void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg)
300 UNUSED(p_sys_hw_msg);
302 APPL_TRACE_DEBUG("%s\n", __FUNCTION__);
304 for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++) {
305 if ( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index )) {
306 switch ( module_index) {
307 case BTA_SYS_HW_BLUETOOTH:
308 /* Send BTA_SYS_HW_ERROR_EVT to DM */
309 if (bta_sys_cb.sys_hw_cback[module_index] != NULL) {
310 bta_sys_cb.sys_hw_cback[module_index] (BTA_SYS_HW_ERROR_EVT);
314 /* not yet supported */
323 /*******************************************************************************
325 ** Function bta_sys_hw_enable
327 ** Description this function is called after API enable and HW has been turned on
330 ** Returns success or failure
332 *******************************************************************************/
334 void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg )
336 if ((!bta_sys_cb.sys_hw_module_active) && (bta_sys_cb.state != BTA_SYS_HW_ON)) {
337 /* register which HW module was turned on */
338 bta_sys_cb.sys_hw_module_active |= ((UINT32)1 << p_sys_hw_msg->hw_module );
340 tBTA_SYS_HW_MSG *p_msg;
341 if ((p_msg = (tBTA_SYS_HW_MSG *) osi_malloc(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
342 p_msg->hdr.event = BTA_SYS_EVT_ENABLED_EVT;
343 p_msg->hw_module = p_sys_hw_msg->hw_module;
345 bta_sys_sendmsg(p_msg);
348 /* register which HW module was turned on */
349 bta_sys_cb.sys_hw_module_active |= ((UINT32)1 << p_sys_hw_msg->hw_module );
351 /* HW already in use, so directly notify the caller */
352 if (bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ] != NULL ) {
353 bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]( BTA_SYS_HW_ON_EVT );
357 APPL_TRACE_EVENT ("bta_sys_hw_api_enable for %d, active modules 0x%04X\n",
358 p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active);
362 /*******************************************************************************
364 ** Function bta_sys_hw_disable
366 ** Description if no other module is using the HW, this function will call ( if defined ) a user-macro to turn off the HW
369 ** Returns success or failure
371 *******************************************************************************/
372 void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg)
374 APPL_TRACE_DEBUG("bta_sys_hw_api_disable for %d, active modules: 0x%04X\n",
375 p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active );
377 /* make sure the related SW blocks were stopped */
378 bta_sys_disable( p_sys_hw_msg->hw_module );
381 /* register which module we turn off */
382 bta_sys_cb.sys_hw_module_active &= ~((UINT32)1 << p_sys_hw_msg->hw_module );
385 /* if there are still some SW modules using the HW, just provide an answer to the calling */
386 if ( bta_sys_cb.sys_hw_module_active != 0 ) {
387 /* if there are still some SW modules using the HW, directly notify the caller */
388 if ( bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ] != NULL ) {
389 bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]( BTA_SYS_HW_OFF_EVT );
392 /* manually update the state of our system */
393 bta_sys_cb.state = BTA_SYS_HW_STOPPING;
395 tBTA_SYS_HW_MSG *p_msg;
396 if ((p_msg = (tBTA_SYS_HW_MSG *) osi_malloc(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
397 p_msg->hdr.event = BTA_SYS_EVT_DISABLED_EVT;
398 p_msg->hw_module = p_sys_hw_msg->hw_module;
400 bta_sys_sendmsg(p_msg);
407 /*******************************************************************************
409 ** Function bta_sys_hw_event_enabled
414 ** Returns success or failure
416 *******************************************************************************/
417 void bta_sys_hw_evt_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg)
419 APPL_TRACE_EVENT("bta_sys_hw_evt_enabled for %i\n", p_sys_hw_msg->hw_module);
420 BTM_DeviceReset( NULL );
424 /*******************************************************************************
426 ** Function bta_sys_hw_event_disabled
431 ** Returns success or failure
433 *******************************************************************************/
434 void bta_sys_hw_evt_disabled(tBTA_SYS_HW_MSG *p_sys_hw_msg)
436 UINT8 hw_module_index;
438 APPL_TRACE_DEBUG("bta_sys_hw_evt_disabled - module 0x%X\n", p_sys_hw_msg->hw_module);
440 for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++) {
441 if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL) {
442 bta_sys_cb.sys_hw_cback[hw_module_index] (BTA_SYS_HW_OFF_EVT);
447 /*******************************************************************************
449 ** Function bta_sys_hw_event_stack_enabled
451 ** Description we receive this event once the SW side is ready ( stack, FW download,... ),
452 ** i.e. we can really start using the device. So notify the app.
454 ** Returns success or failure
456 *******************************************************************************/
457 void bta_sys_hw_evt_stack_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg)
459 UINT8 hw_module_index;
460 UNUSED(p_sys_hw_msg);
462 APPL_TRACE_DEBUG(" bta_sys_hw_evt_stack_enabled!notify the callers\n");
464 for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++ ) {
465 if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL) {
466 bta_sys_cb.sys_hw_cback[hw_module_index] (BTA_SYS_HW_ON_EVT);
474 /*******************************************************************************
476 ** Function bta_sys_event
478 ** Description BTA event handler; called from task event handler.
483 *******************************************************************************/
484 void bta_sys_event(BT_HDR *p_msg)
487 BOOLEAN freebuf = TRUE;
489 APPL_TRACE_EVENT("BTA got event 0x%x\n", p_msg->event);
491 /* get subsystem id from event */
492 id = (UINT8) (p_msg->event >> 8);
494 /* verify id and call subsystem event handler */
495 if ((id < BTA_ID_MAX) && (bta_sys_cb.reg[id] != NULL)) {
496 freebuf = (*bta_sys_cb.reg[id]->evt_hdlr)(p_msg);
498 APPL_TRACE_WARNING("BTA got unregistered event id %d\n", id);
507 /*******************************************************************************
509 ** Function bta_sys_register
511 ** Description Called by other BTA subsystems to register their event
517 *******************************************************************************/
518 void bta_sys_register(UINT8 id, const tBTA_SYS_REG *p_reg)
520 bta_sys_cb.reg[id] = (tBTA_SYS_REG *) p_reg;
521 bta_sys_cb.is_reg[id] = TRUE;
524 /*******************************************************************************
526 ** Function bta_sys_deregister
528 ** Description Called by other BTA subsystems to de-register
534 *******************************************************************************/
535 void bta_sys_deregister(UINT8 id)
537 bta_sys_cb.is_reg[id] = FALSE;
540 /*******************************************************************************
542 ** Function bta_sys_is_register
544 ** Description Called by other BTA subsystems to get registeration
550 *******************************************************************************/
551 BOOLEAN bta_sys_is_register(UINT8 id)
553 return bta_sys_cb.is_reg[id];
556 /*******************************************************************************
558 ** Function bta_sys_sendmsg
560 ** Description Send a message to BTA. This function is designed to
561 ** optimize sending of messages to BTA. It is called by BTA
562 ** API functions and call-in functions.
567 *******************************************************************************/
568 void bta_sys_sendmsg(void *p_msg)
570 // There is a race condition that occurs if the stack is shut down while
571 // there is a procedure in progress that can schedule a task via this
572 // message queue. This causes |btu_bta_msg_queue| to get cleaned up before
573 // it gets used here; hence we check for NULL before using it.
574 if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, TASK_POST_BLOCKING) != TASK_POST_SUCCESS) {
579 /*******************************************************************************
581 ** Function bta_sys_start_timer
583 ** Description Start a protocol timer for the specified amount
584 ** of time in milliseconds.
588 *******************************************************************************/
589 void bta_alarm_cb(void *data)
591 assert(data != NULL);
592 TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
594 btu_task_post(SIG_BTU_BTA_ALARM, p_tle, TASK_POST_BLOCKING);
597 void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)
599 assert(p_tle != NULL);
601 // Get the alarm for this p_tle.
602 osi_mutex_lock(&bta_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
603 if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
604 hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0));
606 osi_mutex_unlock(&bta_alarm_lock);
608 osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
610 LOG_ERROR("%s unable to create alarm.", __func__);
615 p_tle->ticks = timeout_ms;
616 //osi_alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
617 osi_alarm_set(alarm, (period_ms_t)timeout_ms);
620 bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
622 osi_alarm_t *alarm = (osi_alarm_t *)hash_map_entry->data;
623 period_ms_t *p_remaining_ms = (period_ms_t *)context;
624 *p_remaining_ms += osi_alarm_get_remaining_ms(alarm);
628 UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
630 period_ms_t remaining_ms = 0;
631 osi_mutex_lock(&bta_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
632 // Get the alarm for this p_tle
633 hash_map_foreach(bta_alarm_hash_map, hash_iter_ro_cb, &remaining_ms);
634 osi_mutex_unlock(&bta_alarm_lock);
639 /*******************************************************************************
641 ** Function bta_sys_stop_timer
643 ** Description Stop a BTA timer.
647 *******************************************************************************/
648 void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle)
650 assert(p_tle != NULL);
652 osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
654 LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
657 osi_alarm_cancel(alarm);
660 /*******************************************************************************
662 ** Function bta_sys_free_timer
664 ** Description Stop and free a BTA timer.
668 *******************************************************************************/
669 void bta_sys_free_timer(TIMER_LIST_ENT *p_tle)
671 assert(p_tle != NULL);
673 osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
675 LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
678 osi_alarm_cancel(alarm);
679 hash_map_erase(bta_alarm_hash_map, p_tle);
682 /*******************************************************************************
684 ** Function bta_sys_disable
686 ** Description For each registered subsystem execute its disable function.
690 *******************************************************************************/
691 void bta_sys_disable(tBTA_SYS_HW_MODULE module)
696 APPL_TRACE_DEBUG("bta_sys_disable: module %i", module);
699 case BTA_SYS_HW_BLUETOOTH:
701 bta_id_max = BTA_ID_BLUETOOTH_MAX;
704 APPL_TRACE_WARNING("bta_sys_disable: unkown module");
708 for ( ; bta_id <= bta_id_max; bta_id++) {
709 if (bta_sys_cb.reg[bta_id] != NULL) {
710 if (bta_sys_cb.is_reg[bta_id] == TRUE && bta_sys_cb.reg[bta_id]->disable != NULL) {
711 (*bta_sys_cb.reg[bta_id]->disable)();
717 /*******************************************************************************
719 ** Function bta_sys_set_trace_level
721 ** Description Set trace level for BTA
725 *******************************************************************************/
726 void bta_sys_set_trace_level(UINT8 level)
728 appl_trace_level = level;
731 /*******************************************************************************
733 ** Function bta_sys_get_sys_features
735 ** Description Returns sys_features to other BTA modules.
737 ** Returns sys_features
739 *******************************************************************************/
740 UINT16 bta_sys_get_sys_features (void)
742 return bta_sys_cb.sys_features;