The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 1999-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 file contains the main Bluetooth Upper Layer definitions. The Broadcom |
| 22 | * implementations of L2CAP RFCOMM, SDP and the BTIf run as one GKI task. The |
| 23 | * btu_task switches between them. |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | #ifndef BTU_H |
| 28 | #define BTU_H |
| 29 | |
| 30 | #include "bt_target.h" |
| 31 | #include "gki.h" |
| 32 | |
| 33 | /* Define the BTU mailbox usage |
| 34 | */ |
| 35 | #define BTU_HCI_RCV_MBOX TASK_MBOX_0 /* Messages from HCI */ |
| 36 | #define BTU_BTIF_MBOX TASK_MBOX_1 /* Messages to BTIF */ |
| 37 | |
| 38 | /* callbacks |
| 39 | */ |
| 40 | typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle); |
| 41 | typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr); |
| 42 | |
| 43 | |
| 44 | /* Define the timer types maintained by BTU |
| 45 | */ |
| 46 | #define BTU_TTYPE_BTM_DEV_CTL 1 |
| 47 | #define BTU_TTYPE_L2CAP_LINK 2 |
| 48 | #define BTU_TTYPE_L2CAP_CHNL 3 |
| 49 | #define BTU_TTYPE_L2CAP_HOLD 4 |
| 50 | #define BTU_TTYPE_SDP 5 |
| 51 | #define BTU_TTYPE_BTM_SCO 6 |
| 52 | #define BTU_TTYPE_BTM_ACL 9 |
| 53 | #define BTU_TTYPE_BTM_RMT_NAME 10 |
| 54 | #define BTU_TTYPE_RFCOMM_MFC 11 |
| 55 | #define BTU_TTYPE_RFCOMM_PORT 12 |
| 56 | #define BTU_TTYPE_TCS_L2CAP 13 |
| 57 | #define BTU_TTYPE_TCS_CALL 14 |
| 58 | #define BTU_TTYPE_TCS_WUG 15 |
| 59 | #define BTU_TTYPE_AUTO_SYNC 16 |
| 60 | #define BTU_TTYPE_CTP_RECON 17 |
| 61 | #define BTU_TTYPE_CTP_T100 18 |
| 62 | #define BTU_TTYPE_CTP_GUARD 19 |
| 63 | #define BTU_TTYPE_CTP_DETACH 20 |
| 64 | |
| 65 | #define BTU_TTYPE_SPP_CONN_RETRY 21 |
| 66 | #define BTU_TTYPE_USER_FUNC 22 |
| 67 | |
| 68 | #define BTU_TTYPE_FTP_DISC 25 |
| 69 | #define BTU_TTYPE_OPP_DISC 26 |
| 70 | |
| 71 | #define BTU_TTYPE_CTP_TL_DISCVY 28 |
| 72 | #define BTU_TTYPE_IPFRAG_TIMER 29 |
| 73 | #define BTU_TTYPE_HSP2_AT_CMD_TO 30 |
| 74 | #define BTU_TTYPE_HSP2_REPEAT_RING 31 |
| 75 | |
| 76 | #define BTU_TTYPE_CTP_GW_INIT 32 |
| 77 | #define BTU_TTYPE_CTP_GW_CONN 33 |
| 78 | #define BTU_TTYPE_CTP_GW_IDLE 35 |
| 79 | |
| 80 | #define BTU_TTYPE_ICP_L2CAP 36 |
| 81 | #define BTU_TTYPE_ICP_T100 37 |
| 82 | |
| 83 | #define BTU_TTYPE_HSP2_WAIT_OK 38 |
| 84 | |
| 85 | /* HCRP Timers */ |
| 86 | #define BTU_TTYPE_HCRP_NOTIF_REG 39 |
| 87 | #define BTU_TTYPE_HCRP_PROTO_RSP 40 |
| 88 | #define BTU_TTYPE_HCRP_CR_GRANT 41 |
| 89 | #define BTU_TTYPE_HCRP_CR_CHECK 42 |
| 90 | #define BTU_TTYPE_HCRP_W4_CLOSE 43 |
| 91 | |
| 92 | /* HCRPM Timers */ |
| 93 | #define BTU_TTYPE_HCRPM_NOTIF_REG 44 |
| 94 | #define BTU_TTYPE_HCRPM_NOTIF_KEEP 45 |
| 95 | #define BTU_TTYPE_HCRPM_API_RSP 46 |
| 96 | #define BTU_TTYPE_HCRPM_W4_OPEN 47 |
| 97 | #define BTU_TTYPE_HCRPM_W4_CLOSE 48 |
| 98 | |
| 99 | /* BNEP Timers */ |
| 100 | #define BTU_TTYPE_BNEP 50 |
| 101 | |
| 102 | /* OBX */ |
| 103 | #define BTU_TTYPE_OBX_CLIENT_TO 51 |
| 104 | #define BTU_TTYPE_OBX_SERVER_TO 52 |
| 105 | #define BTU_TTYPE_OBX_SVR_SESS_TO 53 |
| 106 | |
| 107 | |
| 108 | #define BTU_TTYPE_HSP2_SDP_FAIL_TO 55 |
| 109 | #define BTU_TTYPE_HSP2_SDP_RTRY_TO 56 |
| 110 | |
| 111 | /* BTU internal */ |
| 112 | /* unused 60 */ |
| 113 | |
| 114 | #define BTU_TTYPE_AVDT_CCB_RET 61 |
| 115 | #define BTU_TTYPE_AVDT_CCB_RSP 62 |
| 116 | #define BTU_TTYPE_AVDT_CCB_IDLE 63 |
| 117 | #define BTU_TTYPE_AVDT_SCB_TC 64 |
| 118 | |
| 119 | #define BTU_TTYPE_HID_DEV_REPAGE_TO 65 |
| 120 | #define BTU_TTYPE_HID_HOST_REPAGE_TO 66 |
| 121 | |
| 122 | #define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67 |
| 123 | |
| 124 | #define BTU_TTYPE_SAP_TO 68 |
| 125 | |
| 126 | /* BPP Timer */ |
| 127 | #define BTU_TTYPE_BPP_REF_CHNL 72 |
| 128 | |
| 129 | /* LP HC idle Timer */ |
| 130 | #define BTU_TTYPE_LP_HC_IDLE_TO 74 |
| 131 | |
| 132 | /* Patch RAM Timer */ |
| 133 | #define BTU_TTYPE_PATCHRAM_TO 75 |
| 134 | |
| 135 | /* eL2CAP Info Request and other proto cmds timer */ |
| 136 | #define BTU_TTYPE_L2CAP_FCR_ACK 78 |
| 137 | #define BTU_TTYPE_L2CAP_INFO 79 |
| 138 | |
| 139 | /* BTU internal for BR/EDR and AMP HCI command timeout (reserve up to 3 AMP controller) */ |
| 140 | #define BTU_TTYPE_BTU_CMD_CMPL 80 |
| 141 | #define BTU_TTYPE_BTU_AMP1_CMD_CMPL 81 |
| 142 | #define BTU_TTYPE_BTU_AMP2_CMD_CMPL 82 |
| 143 | #define BTU_TTYPE_BTU_AMP3_CMD_CMPL 83 |
| 144 | |
| 145 | #define BTU_TTYPE_MCA_CCB_RSP 98 |
| 146 | |
| 147 | /* BTU internal timer for BLE activity */ |
| 148 | #define BTU_TTYPE_BLE_INQUIRY 99 |
| 149 | #define BTU_TTYPE_BLE_GAP_LIM_DISC 100 |
| 150 | #define BTU_TTYPE_ATT_WAIT_FOR_RSP 101 |
| 151 | #define BTU_TTYPE_SMP_PAIRING_CMD 102 |
| 152 | #define BTU_TTYPE_BLE_RANDOM_ADDR 103 |
| 153 | #define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP 104 |
| 154 | #define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK 105 |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 155 | |
Ganesh Ganapathi Batta | 8fe5887 | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 156 | #define BTU_TTYPE_L2CAP_END_CONN_UPD 106 |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 157 | |
Ganesh Ganapathi Batta | 8fe5887 | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 158 | #define BTU_TTYPE_BLE_GAP_FAST_ADV 107 |
| 159 | #define BTU_TTYPE_BLE_OBSERVE 108 |
| 160 | |
| 161 | |
| 162 | #define BTU_TTYPE_UCD_TO 109 |
| 163 | |
| 164 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 165 | |
| 166 | /* Define the BTU_TASK APPL events |
| 167 | */ |
| 168 | #if (defined(NFC_SHARED_TRANSPORT_ENABLED) && (NFC_SHARED_TRANSPORT_ENABLED==TRUE)) |
| 169 | #define BTU_NFC_AVAILABLE_EVT EVENT_MASK(APPL_EVT_0) /* Notifies BTU task that NFC is available (used for shared NFC+BT transport) */ |
| 170 | #endif |
| 171 | |
| 172 | /* This is the inquiry response information held by BTU, and available |
| 173 | ** to applications. |
| 174 | */ |
| 175 | typedef struct |
| 176 | { |
| 177 | BD_ADDR remote_bd_addr; |
| 178 | UINT8 page_scan_rep_mode; |
| 179 | UINT8 page_scan_per_mode; |
| 180 | UINT8 page_scan_mode; |
| 181 | DEV_CLASS dev_class; |
| 182 | UINT16 clock_offset; |
| 183 | } tBTU_INQ_INFO; |
| 184 | |
| 185 | |
| 186 | |
| 187 | #define BTU_MAX_REG_TIMER (2) /* max # timer callbacks which may register */ |
| 188 | #define BTU_MAX_REG_EVENT (6) /* max # event callbacks which may register */ |
| 189 | #define BTU_DEFAULT_DATA_SIZE (0x2a0) |
| 190 | |
| 191 | #if (BLE_INCLUDED == TRUE) |
| 192 | #define BTU_DEFAULT_BLE_DATA_SIZE (27) |
| 193 | #endif |
| 194 | |
| 195 | /* structure to hold registered timers */ |
| 196 | typedef struct |
| 197 | { |
| 198 | TIMER_LIST_ENT *p_tle; /* timer entry */ |
| 199 | tBTU_TIMER_CALLBACK timer_cb; /* callback triggered when timer expires */ |
| 200 | } tBTU_TIMER_REG; |
| 201 | |
| 202 | /* structure to hold registered event callbacks */ |
| 203 | typedef struct |
| 204 | { |
| 205 | UINT16 event_range; /* start of event range */ |
| 206 | tBTU_EVENT_CALLBACK event_cb; /* callback triggered when event is in range */ |
| 207 | } tBTU_EVENT_REG; |
| 208 | |
| 209 | #define NFC_MAX_LOCAL_CTRLS 0 |
| 210 | |
| 211 | /* the index to BTU command queue array */ |
| 212 | #define NFC_CONTROLLER_ID (1) |
| 213 | #define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */ |
| 214 | |
| 215 | /* AMP HCI control block */ |
| 216 | typedef struct |
| 217 | { |
| 218 | BUFFER_Q cmd_xmit_q; |
| 219 | BUFFER_Q cmd_cmpl_q; |
| 220 | UINT16 cmd_window; |
| 221 | TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */ |
| 222 | #if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE) |
| 223 | BOOLEAN checked_hcisu; |
| 224 | #endif |
| 225 | } tHCI_CMD_CB; |
| 226 | |
| 227 | /* Define structure holding BTU variables |
| 228 | */ |
| 229 | typedef struct |
| 230 | { |
| 231 | tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER]; |
| 232 | tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT]; |
| 233 | |
| 234 | TIMER_LIST_Q quick_timer_queue; /* Timer queue for transport level (100/10 msec)*/ |
| 235 | TIMER_LIST_Q timer_queue; /* Timer queue for normal BTU task (1 second) */ |
Chris Manton | 0aee331 | 2014-06-12 12:52:33 -0700 | [diff] [blame^] | 236 | TIMER_LIST_Q timer_queue_oneshot; /* Timer queue for oneshot BTU tasks */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 237 | |
| 238 | TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */ |
| 239 | |
| 240 | UINT16 hcit_acl_data_size; /* Max ACL data size across HCI transport */ |
| 241 | UINT16 hcit_acl_pkt_size; /* Max ACL packet size across HCI transport */ |
| 242 | /* (this is data size plus 4 bytes overhead) */ |
| 243 | |
| 244 | #if BLE_INCLUDED == TRUE |
| 245 | UINT16 hcit_ble_acl_data_size; /* Max BLE ACL data size across HCI transport */ |
| 246 | UINT16 hcit_ble_acl_pkt_size; /* Max BLE ACL packet size across HCI transport */ |
| 247 | /* (this is data size plus 4 bytes overhead) */ |
| 248 | #endif |
| 249 | |
| 250 | BOOLEAN reset_complete; /* TRUE after first ack from device received */ |
| 251 | UINT8 trace_level; /* Trace level for HCI layer */ |
| 252 | |
| 253 | tHCI_CMD_CB hci_cmd_cb[BTU_MAX_LOCAL_CTRLS]; /* including BR/EDR */ |
| 254 | } tBTU_CB; |
| 255 | |
| 256 | #ifdef __cplusplus |
| 257 | extern "C" { |
| 258 | #endif |
| 259 | |
| 260 | /* Global BTU data */ |
| 261 | #if BTU_DYNAMIC_MEMORY == FALSE |
| 262 | BTU_API extern tBTU_CB btu_cb; |
| 263 | #else |
| 264 | BTU_API extern tBTU_CB *btu_cb_ptr; |
| 265 | #define btu_cb (*btu_cb_ptr) |
| 266 | #endif |
| 267 | |
| 268 | BTU_API extern const BD_ADDR BT_BD_ANY; |
| 269 | |
| 270 | /* Functions provided by btu_task.c |
| 271 | ************************************ |
| 272 | */ |
| 273 | BTU_API extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); |
| 274 | BTU_API extern void btu_stop_timer (TIMER_LIST_ENT *p_tle); |
Chris Manton | 0aee331 | 2014-06-12 12:52:33 -0700 | [diff] [blame^] | 275 | BTU_API extern void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); |
| 276 | BTU_API extern void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle); |
| 277 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 278 | BTU_API extern UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle); |
| 279 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 280 | BTU_API extern void btu_uipc_rx_cback(BT_HDR *p_msg); |
| 281 | |
| 282 | BTU_API extern void btu_hcif_flush_cmd_queue(void); |
| 283 | /* |
| 284 | ** Quick Timer |
| 285 | */ |
| 286 | #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) |
| 287 | #define QUICK_TIMER_TICKS (GKI_SECS_TO_TICKS (1)/QUICK_TIMER_TICKS_PER_SEC) |
| 288 | BTU_API extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout); |
| 289 | BTU_API extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle); |
| 290 | BTU_API extern void btu_process_quick_timer_evt (void); |
| 291 | BTU_API extern void process_quick_timer_evt (TIMER_LIST_Q *p_tlq); |
| 292 | #endif |
| 293 | |
| 294 | #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) |
| 295 | BTU_API extern void btu_check_bt_sleep (void); |
| 296 | #endif |
| 297 | |
| 298 | /* Functions provided by btu_hcif.c |
| 299 | ************************************ |
| 300 | */ |
| 301 | BTU_API extern void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf); |
| 302 | BTU_API extern void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg); |
| 303 | BTU_API extern void btu_hcif_send_host_rdy_for_data(void); |
| 304 | BTU_API extern void btu_hcif_cmd_timeout (UINT8 controller_id); |
| 305 | |
| 306 | /* Functions provided by btu_core.c |
| 307 | ************************************ |
| 308 | */ |
| 309 | BTU_API extern void btu_init_core(void); |
| 310 | BTU_API extern void BTE_Init(void); |
| 311 | BTU_API extern UINT16 BTU_AclPktSize(void); |
| 312 | BTU_API extern UINT16 BTU_BleAclPktSize(void); |
| 313 | |
| 314 | #ifdef __cplusplus |
| 315 | } |
| 316 | #endif |
| 317 | |
| 318 | #endif |