bta_sys.h revision 245876929944e9958d80db9f087008ce35f5f133
1/******************************************************************************
2 *
3 *  Copyright (C) 2003-2012 Broadcom Corporation
4 *
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:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 ******************************************************************************/
18
19/******************************************************************************
20 *
21 *  This is the public interface file for the BTA system manager.
22 *
23 ******************************************************************************/
24#ifndef BTA_SYS_H
25#define BTA_SYS_H
26
27#include "bt_target.h"
28#include "gki.h"
29
30/*****************************************************************************
31**  Constants and data types
32*****************************************************************************/
33
34/* vendor specific event handler function type */
35typedef BOOLEAN (tBTA_SYS_VS_EVT_HDLR)(UINT16 evt, void *p);
36
37/* event handler function type */
38typedef BOOLEAN (tBTA_SYS_EVT_HDLR)(BT_HDR *p_msg);
39
40/* disable function type */
41typedef void (tBTA_SYS_DISABLE)(void);
42
43
44/* HW modules */
45enum
46{
47    BTA_SYS_HW_BLUETOOTH,
48    BTA_SYS_HW_FMRX,
49    BTA_SYS_HW_FMTX,
50    BTA_SYS_HW_GPS,
51    BTA_SYS_HW_SENSOR,
52    BTA_SYS_HW_NFC,
53    BTA_SYS_HW_RT,
54
55    BTA_SYS_MAX_HW_MODULES
56};
57
58typedef UINT16 tBTA_SYS_HW_MODULE;
59
60#ifndef BTA_DM_NUM_JV_ID
61#define BTA_DM_NUM_JV_ID    2
62#endif
63
64/* SW sub-systems */
65#define BTA_ID_SYS          0            /* system manager */
66/* BLUETOOTH PART - from 0 to BTA_ID_BLUETOOTH_MAX */
67#define BTA_ID_DM           1            /* device manager */
68#define BTA_ID_DM_SEARCH    2            /* device manager search */
69#define BTA_ID_DM_SEC       3            /* device manager security */
70#define BTA_ID_DG           4            /* data gateway */
71#define BTA_ID_AG           5            /* audio gateway */
72#define BTA_ID_OPC          6            /* object push client */
73#define BTA_ID_OPS          7            /* object push server */
74#define BTA_ID_FTS          8            /* file transfer server */
75#define BTA_ID_CT           9            /* cordless telephony terminal */
76#define BTA_ID_FTC          10           /* file transfer client */
77#define BTA_ID_SS           11           /* synchronization server */
78#define BTA_ID_PR           12           /* Printer client */
79#define BTA_ID_BIC          13           /* Basic Imaging Client */
80#define BTA_ID_PAN          14           /* Personal Area Networking */
81#define BTA_ID_BIS          15           /* Basic Imaging Server */
82#define BTA_ID_ACC          16           /* Advanced Camera Client */
83#define BTA_ID_SC           17           /* SIM Card Access server */
84#define BTA_ID_AV           18           /* Advanced audio/video */
85#define BTA_ID_AVK          19           /* Audio/video sink */
86#define BTA_ID_HD           20           /* HID Device */
87#define BTA_ID_CG           21           /* Cordless Gateway */
88#define BTA_ID_BP           22           /* Basic Printing Client */
89#define BTA_ID_HH           23           /* Human Interface Device Host */
90#define BTA_ID_PBS          24           /* Phone Book Access Server */
91#define BTA_ID_PBC          25           /* Phone Book Access Client */
92#define BTA_ID_JV           26           /* Java */
93#define BTA_ID_HS           27           /* Headset */
94#define BTA_ID_MSE          28           /* Message Server Equipment */
95#define BTA_ID_MCE          29           /* Message Client Equipment */
96#define BTA_ID_HL           30           /* Health Device Profile*/
97#define BTA_ID_GATTC        31           /* GATT Client */
98#define BTA_ID_GATTS        32           /* GATT Client */
99#define BTA_ID_BLUETOOTH_MAX   33        /* last BT profile */
100
101/* FM */
102#define BTA_ID_FM           34           /* FM  */
103#define BTA_ID_FMTX         35           /* FM TX */
104
105/* SENSOR */
106#define BTA_ID_SSR          36           /* Sensor  */
107
108/* GPS */
109#define BTA_ID_GPS          37           /* GPS  */
110
111/* GENERIC */
112#define BTA_ID_PRM          38
113#define BTA_ID_SYSTEM       39           /* platform-specific */
114#define BTA_ID_SWRAP        40           /* Insight script wrapper */
115#define BTA_ID_MIP          41           /* Multicase Individual Polling */
116#define BTA_ID_RT           42           /* Audio Routing module: This module is always on. */
117
118
119/* JV */
120#define BTA_ID_JV1          43           /* JV1 */
121#define BTA_ID_JV2          44           /* JV2 */
122
123#define BTA_ID_MAX          (43 + BTA_DM_NUM_JV_ID)
124
125typedef UINT8 tBTA_SYS_ID;
126
127
128#define BTA_SYS_CONN_OPEN           0x00
129#define BTA_SYS_CONN_CLOSE          0x01
130#define BTA_SYS_APP_OPEN            0x02
131#define BTA_SYS_APP_CLOSE           0x03
132#define BTA_SYS_SCO_OPEN            0x04
133#define BTA_SYS_SCO_CLOSE           0x05
134#define BTA_SYS_CONN_IDLE           0x06
135#define BTA_SYS_CONN_BUSY           0x07
136
137/* for link policy */
138#define BTA_SYS_PLCY_SET            0x10 /* set the link policy to the given addr */
139#define BTA_SYS_PLCY_CLR            0x11 /* clear the link policy to the given addr */
140#define BTA_SYS_PLCY_DEF_SET        0x12 /* set the default link policy */
141#define BTA_SYS_PLCY_DEF_CLR        0x13 /* clear the default link policy */
142#define BTA_SYS_ROLE_CHANGE         0x14 /* role change */
143
144typedef UINT8 tBTA_SYS_CONN_STATUS;
145
146/* Bitmask of sys features */
147#define BTA_SYS_FEAT_PCM2           0x0001
148#define BTA_SYS_FEAT_PCM2_MASTER    0x0002
149
150/* tBTA_PREF_ROLES */
151typedef UINT8 tBTA_SYS_PREF_ROLES;
152
153/* conn callback for role / low power manager*/
154typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
155
156/* conn callback for role / low power manager*/
157typedef void (tBTA_SYS_SSR_CFG_CBACK)(UINT8 id, UINT8 app_id, UINT16 latency, UINT16 tout);
158
159#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE)
160/* eir callback for adding/removeing UUID */
161typedef void (tBTA_SYS_EIR_CBACK)(UINT16 uuid16, BOOLEAN adding);
162#endif
163
164/* registration structure */
165typedef struct
166{
167    tBTA_SYS_EVT_HDLR   *evt_hdlr;
168    tBTA_SYS_DISABLE    *disable;
169} tBTA_SYS_REG;
170
171/* data type to send events to BTA SYS HW manager */
172typedef struct
173{
174    BT_HDR                hdr;
175    tBTA_SYS_HW_MODULE   hw_module;
176} tBTA_SYS_HW_MSG;
177
178/* GKI task mailbox event for BTA. */
179#ifndef BTA_MBOX_EVT
180#define BTA_MBOX_EVT                TASK_MBOX_2_EVT_MASK
181#endif
182
183/* GKI task mailbox for BTA. */
184#ifndef BTA_MBOX
185#define BTA_MBOX                    TASK_MBOX_2
186#endif
187
188/* GKI timer id used for protocol timer for BTA. */
189#ifndef BTA_TIMER
190#define BTA_TIMER                   TIMER_1
191#endif
192
193/*****************************************************************************
194**  Global data
195*****************************************************************************/
196
197/* trace level */
198extern UINT8 appl_trace_level;
199
200/*****************************************************************************
201**  Macros
202*****************************************************************************/
203
204/* Calculate start of event enumeration; id is top 8 bits of event */
205#define BTA_SYS_EVT_START(id)       ((id) << 8)
206
207/*****************************************************************************
208**  events for BTA SYS HW manager
209*****************************************************************************/
210
211/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.c */
212enum
213{
214    /* device manager local device API events */
215    BTA_SYS_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SYS),
216    BTA_SYS_EVT_ENABLED_EVT,
217    BTA_SYS_EVT_STACK_ENABLED_EVT,
218    BTA_SYS_API_DISABLE_EVT,
219    BTA_SYS_EVT_DISABLED_EVT,
220    BTA_SYS_ERROR_EVT,
221
222    BTA_SYS_MAX_EVT
223};
224
225
226
227/* SYS HW status events - returned by SYS HW manager to other modules. */
228enum
229{
230    BTA_SYS_HW_OFF_EVT,
231    BTA_SYS_HW_ON_EVT,
232    BTA_SYS_HW_STARTING_EVT,
233    BTA_SYS_HW_STOPPING_EVT,
234    BTA_SYS_HW_ERROR_EVT
235
236};
237typedef UINT8 tBTA_SYS_HW_EVT;
238
239/* HW enable callback type */
240typedef void (tBTA_SYS_HW_CBACK)(tBTA_SYS_HW_EVT status);
241
242/*****************************************************************************
243**  Function declarations
244*****************************************************************************/
245
246#ifdef __cplusplus
247extern "C" {
248#endif
249
250BTA_API extern void bta_sys_init(void);
251BTA_API extern void bta_sys_event(BT_HDR *p_msg);
252BTA_API extern void bta_sys_timer_update(void);
253BTA_API extern void bta_sys_disable_timers(void);
254BTA_API extern void bta_sys_set_trace_level(UINT8 level);
255extern void bta_sys_register(UINT8 id, const tBTA_SYS_REG *p_reg);
256extern void bta_sys_deregister(UINT8 id);
257extern BOOLEAN bta_sys_is_register(UINT8 id);
258extern UINT16 bta_sys_get_sys_features(void);
259extern void bta_sys_sendmsg(void *p_msg);
260extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout);
261extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle);
262extern void bta_sys_disable(tBTA_SYS_HW_MODULE module);
263
264extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback);
265extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module );
266
267
268extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback);
269extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback);
270
271extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback);
272extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback);
273
274
275extern void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
276extern void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
277extern void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
278extern void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
279extern void bta_sys_sco_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
280extern void bta_sys_sco_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
281extern void bta_sys_sco_use(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
282extern void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
283extern void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
284extern void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
285
286#if (BTM_SSR_INCLUDED == TRUE)
287extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback);
288extern void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout);
289#endif
290
291extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback);
292extern void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status);
293extern void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback);
294extern void bta_sys_notify_collision (BD_ADDR_PTR p_bda);
295
296#if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&(BTA_EIR_CANNED_UUID_LIST != TRUE)
297extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback);
298extern void bta_sys_add_uuid(UINT16 uuid16);
299extern void bta_sys_remove_uuid(UINT16 uuid16);
300#else
301#define bta_sys_eir_register(ut)
302#define bta_sys_add_uuid(ut)
303#define bta_sys_remove_uuid(ut)
304#endif
305
306extern void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr);
307extern void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr);
308extern void bta_sys_set_default_policy (UINT8 id, UINT8 policy);
309extern void bta_sys_clear_default_policy (UINT8 id, UINT8 policy);
310extern BOOLEAN bta_sys_vs_hdl(UINT16 evt, void *p);
311
312#ifdef __cplusplus
313}
314#endif
315
316#endif /* BTA_SYS_H */
317