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