1 /******************************************************************************
3 * Copyright (C) 2002-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 interface file for the bte application task
23 ******************************************************************************/
33 /* Maximum length for serial port device name */
34 #ifndef BTE_APPL_MAX_USERIAL_DEV_NAME
35 #define BTE_APPL_MAX_USERIAL_DEV_NAME (256)
37 #ifndef BTAPP_AHF_API_SUPPORT
38 #define BTAPP_AHF_API_SUPPORT FALSE
44 /* this defines the enabled BTA modules. client may not be defined as those are enabled at run time.
45 * they are defined for completeness. please check with bta_sys.h for new modules.
46 * BTA_ID_DM serves as flag for BTA_EnableBluetooth()
47 * BTA_ID_RES can be used to fs ID in bte_appl.
50 #define BTAPP_NUM_ID_BLOCKS ((BTA_ID_MAX/32)+1) /* number of 32 bit required to store one bit per
53 #define BTAPP_APPL_MAIL_EVENT(x) (x<<8) /* define bte_appl task mail box event. LSB contains
54 BTA_ID_xxx (see bta_sys.h) */
55 #define BTAPP_APPL_MAIL_EVT 0xff00 /* high byte contains bitmap of application module event */
57 /* helper macro to copy BTA callack data y into message buffer x, for event data structure z */
58 #define MEMCPY_APPL_MSG(x, y, z) memcpy( (void *)(((UINT8 *)x)+sizeof(BT_HDR)), (void *)y, sizeof(z) )
60 /* Event masks for BTE_APPL_TASK */
61 #define BTE_APPL_STARTUP_EVT EVENT_MASK(APPL_EVT_0) /* Bluetooth has started */
62 #define BTE_APPL_SHUTDOWN_EVT EVENT_MASK(APPL_EVT_1) /* Bluetooth is shutting down */
63 #define BTE_APPL_SOCKET_RX_EVT EVENT_MASK(APPL_EVT_2) /* Socket data ready to be read */
64 #define BTE_APPL_DBUS_RX_EVT EVENT_MASK(APPL_EVT_3) /* DBUS message ready to be read */
65 #define BTE_APPL_BTA_ENABLE_EVT EVENT_MASK(APPL_EVT_4) /* BTA Enabled event */
68 /* Application configuration */
69 #define BTE_APPL_PATCHRAM_PATH_MAXLEN 128
70 #define BTE_APPL_CONTACTS_DB_PATH 256
73 #if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
78 UINT8 ble_max_key_size;
82 extern tBTE_APPL_CFG bte_appl_cfg;
85 pthread_mutex_t mutex; /* mutex to protect below signal condition */
86 pthread_cond_t cond; /* signal event */
89 /* helper functions to handle pthread conditions event from outside GKI */
90 extern void bte_create_semaphore( tBTAPP_SEMAPHORE * p_sema );
91 extern void bte_wait_semaphore( tBTAPP_SEMAPHORE * p_sema, unsigned msecs_to );
92 extern void bte_signal_semaphore( tBTAPP_SEMAPHORE * p_sema );
93 extern void bte_destroy_semaphore( tBTAPP_SEMAPHORE * p_sema );
95 /* global application control block storing global application states and variables */
96 typedef struct tBTE_APPL_CB_tag {
97 sigset_t signal_handler_set; /* signal handler set used by signal handler thread */
98 #if ( TRUE == BTE_RESET_BAUD_ON_BT_DISABLE )
99 tBTAPP_SEMAPHORE shutdown_semaphore; /* used to sync with terminate handler initated ops */
101 BOOLEAN amp_enabled; /* TRUE if AMP is in use */
104 extern tBTE_APPL_CB bte_appl_cb;
106 /* Exports the application task */
107 extern void BTE_appl_task(UINT32 params);
108 extern int BTAPP_enable_bta( const UINT32 bta_module_state[BTAPP_NUM_ID_BLOCKS], int includingFM );
109 extern int BTAPP_disable_bta( const UINT32 bta_module_state[BTAPP_NUM_ID_BLOCKS], int includingFM );
111 extern UINT8 appl_trace_level;
112 #define BT_PCM_CLK_IDX 1
113 #ifndef BT_PCM_DEF_CLK
114 #define BT_PCM_DEF_CLK 4 /* defaults to 2048khz PCM clk */
116 #define BT_PCM_SYNC_MS_ROLE_IDX 3
117 #define BT_PCM_CLK_MS_ROLE_IDX 4
118 #ifndef BT_PCM_DEF_ROLE
119 #define BT_PCM_DEF_ROLE 0x00 /* assume slave as default */
122 /* helper macros to set, clear and get current BTA module id in a 32bit ARRAY!! */
123 /* set bit id to 1 in UINT32 a[] NO RANGE CHECK!*/
124 #define BTAPP_SET_BTA_MOD(id, a) { a[id/32] |= (UINT32)(1<<(id % 32)); }
126 /* set bit id to 0 (cleared) in UINT32 a[] NO RANGE CHECK */
127 #define BTAPP_CLEAR_BTA_MOD(id, a) { a[id/32] &= (UINT32)!(1<<(id % 32)); }
129 /* tests if bit id is 1 in UINT32 a[] NO RANGE CHECK */
130 #define BTAPP_BTA_MOD_IS_SET(id, a) (a[id/32] & (UINT32)(1<<(id % 32)))
132 /* update this list either via btld.txt or directly here by adding the new profiles as per bta_sys.h.
133 * each xxx_LISTx may only contain 32 bits */
134 #ifndef BTAPP_BTA_MODULES_LIST0
135 #define BTAPP_BTA_MODULES_LIST0 (\
154 #define BTAPP_LIST1_BLOCK 32 /* next 32 bit block */
155 #ifndef BTAPP_BTA_MODULES_LIST1
156 #define BTAPP_BTA_MODULES_LIST1 (\
157 ( 1<<(BTA_ID_MAX-BTAPP_LIST1_BLOCK) ) | \
158 ( 1<<(BTA_ID_MSE-BTAPP_LIST1_BLOCK) ) | \
162 /* for future GPS etc support. goes int LIST1 above */
164 ( 1<<(BTA_ID_SSR-BTAPP_LIST1_BLOCK) ) \
165 ( 1<<(BTA_ID_MSE-BTAPP_LIST1_BLOCK) ) \
166 ( 1<<(BTA_ID_MCE-BTAPP_LIST1_BLOCK) )
169 /* used application init default in bte_main.c, bte_appl_cfg */
170 #ifndef BTAPP_DEFAULT_MODULES
171 #if (1==BTAPP_NUM_ID_BLOCKS)
172 #define BTAPP_DEFAULT_MODULES {BTAPP_BTA_MODULES_LIST0} /* max 32 modules IDs */
173 #elif (2==BTAPP_NUM_ID_BLOCKS)
174 #define BTAPP_DEFAULT_MODULES {BTAPP_BTA_MODULES_LIST0, BTAPP_BTA_MODULES_LIST1} /* 64 module IDs max */
176 #error "Define more BTAPP_BTA_MODULES_LISTx"
180 #endif /* BTE_APPL_H */