bta_sys.h 11 KB

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