Home | History | Annotate | Download | only in dm
      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 file contains compile-time configurable constants for the device
     22  *  manager.
     23  *
     24  ******************************************************************************/
     25 
     26 #include "bt_target.h"
     27 #include "bta_sys.h"
     28 #include "bta_api.h"
     29 #include "bta_dm_int.h"
     30 #include "bta_jv_api.h"
     31 
     32 #ifndef BTA_DM_LINK_POLICY_SETTINGS
     33 #define BTA_DM_LINK_POLICY_SETTINGS    (HCI_ENABLE_MASTER_SLAVE_SWITCH | HCI_ENABLE_HOLD_MODE | HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)
     34 #endif
     35 
     36 /* page timeout in 625uS */
     37 #ifndef BTA_DM_PAGE_TIMEOUT
     38 #define BTA_DM_PAGE_TIMEOUT    8192
     39 #endif
     40 
     41 /* link supervision timeout in 625uS (5 secs) */
     42 #ifndef BTA_DM_LINK_TIMEOUT
     43 #define BTA_DM_LINK_TIMEOUT    8000
     44 #endif
     45 
     46 /* TRUE to avoid scatternet when av is streaming (be the master) */
     47 #ifndef BTA_DM_AVOID_SCATTER_A2DP
     48 #define BTA_DM_AVOID_SCATTER_A2DP    TRUE
     49 #endif
     50 
     51 /* For Insight, PM cfg lookup tables are runtime configurable (to allow tweaking of params for power consumption measurements) */
     52 #ifndef BTE_SIM_APP
     53 #define tBTA_DM_PM_TYPE_QUALIFIER   const
     54 #else
     55 #define tBTA_DM_PM_TYPE_QUALIFIER
     56 #endif
     57 
     58 
     59 const tBTA_DM_CFG bta_dm_cfg =
     60 {
     61     /* mobile phone COD */
     62     BTA_DM_COD,
     63     /* link policy settings */
     64     BTA_DM_LINK_POLICY_SETTINGS,
     65     /* page timeout in 625uS */
     66     BTA_DM_PAGE_TIMEOUT,
     67     /* link supervision timeout in 625uS*/
     68     BTA_DM_LINK_TIMEOUT,
     69     /* TRUE to avoid scatternet when av is streaming (be the master) */
     70     BTA_DM_AVOID_SCATTER_A2DP
     71 };
     72 
     73 #ifndef BTA_DM_SCATTERNET
     74 /* By default, allow partial scatternet */
     75 #define BTA_DM_SCATTERNET BTA_DM_PARTIAL_SCATTERNET
     76 #endif
     77 
     78 #ifndef BTA_HH_ROLE
     79 /* By default, do not specify HH role (backward compatibility) */
     80 #define BTA_HH_ROLE BTA_ANY_ROLE
     81 #endif
     82 
     83 #ifndef BTA_AV_ROLE
     84 /* By default, AV role (backward BTA_MASTER_ROLE_PREF) */
     85 #define BTA_AV_ROLE BTA_MASTER_ROLE_PREF
     86 #endif
     87 
     88 #define BTA_DM_NUM_RM_ENTRY    4
     89 
     90 /* appids for PAN used by insight sample application
     91    these have to be same as defined in btui_int.h */
     92 #define BTUI_PAN_ID_PANU         0
     93 #define BTUI_PAN_ID_NAP          1
     94 #define BTUI_PAN_ID_GN           2
     95 
     96 /* First element is always for SYS:
     97    app_id = # of entries table, cfg is
     98    device scatternet support */
     99 const tBTA_DM_RM bta_dm_rm_cfg[] =
    100 {
    101     {BTA_ID_SYS, BTA_DM_NUM_RM_ENTRY, BTA_DM_SCATTERNET},
    102     {BTA_ID_PAN, BTUI_PAN_ID_NAP, BTA_MASTER_ROLE_ONLY},
    103     {BTA_ID_PAN, BTUI_PAN_ID_GN, BTA_MASTER_ROLE_ONLY},
    104     {BTA_ID_HH,  BTA_ALL_APP_ID, BTA_HH_ROLE},
    105     {BTA_ID_AV,  BTA_ALL_APP_ID, BTA_AV_ROLE}
    106 };
    107 
    108 
    109 tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *)&bta_dm_cfg;
    110 
    111 tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;
    112 
    113 #if BLE_INCLUDED == TRUE
    114 #  define BTA_DM_NUM_PM_ENTRY         22  /* number of entries in bta_dm_pm_cfg except the first */
    115 #  define BTA_DM_NUM_PM_SPEC          14  /* number of entries in bta_dm_pm_spec */
    116 #else
    117 #  define BTA_DM_NUM_PM_ENTRY         20  /* number of entries in bta_dm_pm_cfg except the first */
    118 #  define BTA_DM_NUM_PM_SPEC          12  /* number of entries in bta_dm_pm_spec */
    119 #endif
    120 
    121 tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] =
    122 {
    123   {BTA_ID_SYS, BTA_DM_NUM_PM_ENTRY, 0},  /* reserved: specifies length of this table. */
    124   {BTA_ID_AG,  BTA_ALL_APP_ID,      0},  /* ag uses first spec table for app id 0 */
    125   {BTA_ID_CT,  1,                   1},  /* ct (BTA_ID_CT,APP ID=1) spec table */
    126   {BTA_ID_CG,  BTA_ALL_APP_ID,      1},  /* cg resue ct spec table */
    127   {BTA_ID_DG,  BTA_ALL_APP_ID,      2},  /* dg spec table */
    128   {BTA_ID_AV,  BTA_ALL_APP_ID,      4},  /* av spec table */
    129   {BTA_ID_FTC, BTA_ALL_APP_ID,      6},  /* ftc spec table */
    130   {BTA_ID_FTS, BTA_ALL_APP_ID,      7},  /* fts spec table */
    131   {BTA_ID_HD,  BTA_ALL_APP_ID,      3},  /* hd spec table */
    132   {BTA_ID_HH,  BTA_ALL_APP_ID,      5},  /* hh spec table */
    133   {BTA_ID_PBC, BTA_ALL_APP_ID,      2},  /* reuse dg spec table */
    134   {BTA_ID_PBS, BTA_ALL_APP_ID,      7},  /* reuse fts spec table */
    135   {BTA_ID_OPC, BTA_ALL_APP_ID,      6},  /* reuse ftc spec table */
    136   {BTA_ID_OPS, BTA_ALL_APP_ID,      7},  /* reuse fts spec table */
    137   {BTA_ID_MSE, BTA_ALL_APP_ID,      7},  /* reuse fts spec table */
    138   {BTA_ID_JV,  BTA_JV_PM_ID_1,      6},  /* app BTA_JV_PM_ID_1, reuse ftc spec table */
    139   {BTA_ID_JV,  BTA_ALL_APP_ID,      7},  /* reuse fts spec table */
    140   {BTA_ID_HL,  BTA_ALL_APP_ID,      8},  /* reuse fts spec table */
    141   {BTA_ID_HS,  BTA_ALL_APP_ID,      9},  /* HS spec table */
    142   {BTA_ID_PAN, BTUI_PAN_ID_PANU,   10},  /* PANU spec table */
    143   {BTA_ID_PAN, BTUI_PAN_ID_NAP,    11}   /* NAP spec table */
    144 #if BLE_INCLUDED == TRUE
    145   ,{BTA_ID_GATTC,  BTA_ALL_APP_ID,  12}   /* gattc spec table */
    146   ,{BTA_ID_GATTS,  BTA_ALL_APP_ID,  13}  /* gatts spec table */
    147 #endif
    148 };
    149 
    150 tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] =
    151 {
    152   /* AG */
    153  {
    154   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
    155 #if (BTM_SSR_INCLUDED == TRUE)
    156   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    157 #endif
    158   {
    159       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff  */
    160       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},   /* conn close  */
    161       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app open */
    162       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app close */
    163       {{BTA_DM_PM_SNIFF_SCO_OPEN_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
    164       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff  */
    165       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* idle */
    166       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},   /* busy */
    167       {{BTA_DM_PM_RETRY,  5000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
    168   }
    169  },
    170 
    171   /* CT */
    172  {
    173   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
    174 #if (BTM_SSR_INCLUDED == TRUE)
    175   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    176 #endif
    177   {
    178       {{BTA_DM_PM_PARK,   5000},  {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  park */
    179       {{BTA_DM_PM_NO_PREF,   0},  {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    180       {{BTA_DM_PM_NO_ACTION, 0},  {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    181       {{BTA_DM_PM_NO_ACTION, 0},  {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    182       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
    183       {{BTA_DM_PM_PARK,   5000},  {BTA_DM_PM_NO_ACTION, 0}},    /* sco close  park */
    184       {{BTA_DM_PM_NO_ACTION, 0},  {BTA_DM_PM_NO_ACTION, 0}},    /* idle */
    185       {{BTA_DM_PM_NO_ACTION, 0},  {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    186       {{BTA_DM_PM_RETRY,  5000},  {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    187   }
    188  },
    189 
    190   /* DG */
    191  {
    192   (BTA_DM_PM_ACTIVE),                                             /* no power saving mode allowed */
    193 #if (BTM_SSR_INCLUDED == TRUE)
    194   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    195 #endif
    196   {
    197       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    198       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    199       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    200       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    201       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    202       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    203       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* idle */
    204       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    205       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    206   }
    207  },
    208 
    209    /* HD */
    210  {
    211   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                            /* allow park & sniff */
    212 #if (BTM_SSR_INCLUDED == TRUE)
    213   (BTA_DM_PM_SSR3),                                              /* the SSR entry */
    214 #endif
    215   {
    216       {{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open  sniff */
    217       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    218       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    219       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    220       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    221       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    222       {{BTA_DM_PM_SNIFF_HD_IDLE_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    223       {{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
    224       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    225   }
    226  },
    227 
    228    /* AV */
    229  {
    230   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    231 #if (BTM_SSR_INCLUDED == TRUE)
    232   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    233 #endif
    234   {
    235       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open  sniff */
    236       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    237       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    238       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    239       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    240       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    241       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    242       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    243       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    244   }
    245  },
    246 
    247   /* HH */
    248  {
    249   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                            /* allow park & sniff */
    250 #if (BTM_SSR_INCLUDED == TRUE)
    251   (BTA_DM_PM_SSR1),                                              /* the SSR entry */
    252 #endif
    253   {
    254       {{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY},{BTA_DM_PM_NO_ACTION, 0}}, /* conn open  sniff */
    255       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    256       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    257       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    258       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    259       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close, used for HH suspend   */
    260       {{BTA_DM_PM_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    261       {{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
    262       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    263   }
    264  },
    265 
    266   /* FTC, OPC */
    267  {
    268   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    269 #if (BTM_SSR_INCLUDED == TRUE)
    270   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    271 #endif
    272   {
    273       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    274       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    275       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    276       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    277       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    278       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    279       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    280       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    281       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    282   }
    283  },
    284 
    285   /* FTS, OPS */
    286  {
    287   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    288 #if (BTM_SSR_INCLUDED == TRUE)
    289   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    290 #endif
    291   {
    292       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    293       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    294       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    295       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    296       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    297       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    298       {{BTA_DM_PM_SNIFF_A2DP_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    299       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    300       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    301   }
    302  },
    303 
    304    /* HL */
    305  {
    306   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    307 #if (BTM_SSR_INCLUDED == TRUE)
    308   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    309 #endif
    310   {
    311       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff  */
    312       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},   /* conn close  */
    313       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app open */
    314       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app close */
    315       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* sco open, active */
    316       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* sco close sniff  */
    317       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* idle */
    318       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},   /* busy */
    319       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
    320   }
    321  },
    322 
    323   /* PANU */
    324  {
    325   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    326 #if (BTM_SSR_INCLUDED == TRUE)
    327   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    328 #endif
    329   {
    330       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    331       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    332       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    333       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    334       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    335       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    336       {{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    337       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    338       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    339   }
    340  },
    341 
    342   /* NAP */
    343  {
    344   (BTA_DM_PM_SNIFF),                                             /* allow sniff */
    345 #if (BTM_SSR_INCLUDED == TRUE)
    346   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    347 #endif
    348   {
    349       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    350       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    351       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    352       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    353       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    354       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    355       {{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    356       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    357       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}}     /* mode change retry */
    358   }
    359  },
    360 
    361   /* HS */
    362  {
    363   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
    364 #if (BTM_SSR_INCLUDED == TRUE)
    365   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    366 #endif
    367   {
    368       {{BTA_DM_PM_SNIFF,  7000},   {BTA_DM_PM_NO_ACTION, 0}},   /* conn open sniff  */
    369       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},   /* conn close  */
    370       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app open */
    371       {{BTA_DM_PM_NO_ACTION, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* app close */
    372       {{BTA_DM_PM_SNIFF3, 7000},   {BTA_DM_PM_NO_ACTION, 0}},   /* sco open, active */
    373       {{BTA_DM_PM_SNIFF,  7000},   {BTA_DM_PM_NO_ACTION, 0}},   /* sco close sniff  */
    374       {{BTA_DM_PM_SNIFF,  7000},   {BTA_DM_PM_NO_ACTION, 0}},   /* idle */
    375       {{BTA_DM_PM_ACTIVE,    0},   {BTA_DM_PM_NO_ACTION, 0}},   /* busy */
    376       {{BTA_DM_PM_RETRY,  7000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
    377   }
    378  }
    379 #if BLE_INCLUDED == TRUE
    380     /* GATTC */
    381  ,{
    382   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
    383 #if (BTM_SSR_INCLUDED == TRUE)
    384   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    385 #endif
    386   {
    387       {{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open  active */
    388       {{BTA_DM_PM_NO_PREF,    0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    389       {{BTA_DM_PM_ACTIVE,     0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    390       {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    391       {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    392       {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    393       {{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    394       {{BTA_DM_PM_ACTIVE,     0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    395 #if (AMP_INCLUDED == TRUE)
    396       {{BTA_DM_PM_NO_ACTION,  0},   {BTA_DM_PM_NO_ACTION, 0}},   /* amp */
    397 #endif
    398       {{BTA_DM_PM_RETRY,   5000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
    399   }
    400  }
    401     /* GATTS */
    402  ,{
    403   (BTA_DM_PM_SNIFF | BTA_DM_PM_PARK),                           /* allow park & sniff */
    404 #if (BTM_SSR_INCLUDED == TRUE)
    405   (BTA_DM_PM_SSR2),                                              /* the SSR entry */
    406 #endif
    407   {
    408       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn open  active */
    409       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* conn close  */
    410       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app open */
    411       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* app close */
    412       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco open  */
    413       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* sco close   */
    414       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* idle */
    415       {{BTA_DM_PM_NO_PREF,   0},   {BTA_DM_PM_NO_ACTION, 0}},    /* busy */
    416 #if (AMP_INCLUDED == TRUE)
    417       {{BTA_DM_PM_NO_PREF, 0},   {BTA_DM_PM_NO_ACTION, 0}},   /* amp */
    418 #endif
    419       {{BTA_DM_PM_RETRY,  5000},   {BTA_DM_PM_NO_ACTION, 0}}    /* mode change retry */
    420   }
    421  }
    422 
    423 #endif
    424 
    425 #ifdef BTE_SIM_APP      /* For Insight builds only */
    426  /* Entries at the end of the pm_spec table are user-defined (runtime configurable),
    427     for power consumption experiments.
    428     Insight finds the first user-defined entry by looking for the first BTA_DM_PM_NO_PREF.
    429     The number of user_defined specs is defined by BTA_SWRAP_UD_PM_SPEC_COUNT */
    430  ,
    431  {BTA_DM_PM_NO_PREF},               /* pm_spec USER_DEFINED_0 */
    432  {BTA_DM_PM_NO_PREF}                /* pm_spec USER_DEFINED_1 */
    433 #endif  /* BTE_SIM_APP */
    434 };
    435 
    436 /* Please refer to the SNIFF table definitions in bta_api.h.
    437  *
    438  * Adding to or Modifying the Table
    439  * Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 - BTA_DM_PM_SNIFF7.
    440  * Overrides of additional table entries can be specified in bdroid_buildcfg.h.  If additional
    441  * sniff parameter entries are added or an override of an existing entry is specified in
    442  * bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta_api.h will need to be match the new
    443  * ordering.
    444  *
    445  * Table Ordering
    446  * Sniff Table entries must be ordered from highest latency (biggest interval) to lowest latency.
    447  * If there is a conflict among the connected services the setting with the lowest latency will
    448  * be selected.
    449  */
    450 tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] =
    451 {
    452 /* sniff modes: max interval, min interval, attempt, timeout */
    453   {BTA_DM_PM_SNIFF_MAX,  BTA_DM_PM_SNIFF_MIN,  BTA_DM_PM_SNIFF_ATTEMPT,  BTA_DM_PM_SNIFF_TIMEOUT,  BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF - A2DP */
    454   {BTA_DM_PM_SNIFF1_MAX, BTA_DM_PM_SNIFF1_MIN, BTA_DM_PM_SNIFF1_ATTEMPT, BTA_DM_PM_SNIFF1_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF1 */
    455   {BTA_DM_PM_SNIFF2_MAX, BTA_DM_PM_SNIFF2_MIN, BTA_DM_PM_SNIFF2_ATTEMPT, BTA_DM_PM_SNIFF2_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF2- HD idle */
    456   {BTA_DM_PM_SNIFF3_MAX, BTA_DM_PM_SNIFF3_MIN, BTA_DM_PM_SNIFF3_ATTEMPT, BTA_DM_PM_SNIFF3_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF3- SCO open */
    457   {BTA_DM_PM_SNIFF4_MAX, BTA_DM_PM_SNIFF4_MIN, BTA_DM_PM_SNIFF4_ATTEMPT, BTA_DM_PM_SNIFF4_TIMEOUT, BTM_PM_MD_SNIFF}, /*for BTA_DM_PM_SNIFF4- HD active*/
    458   {BTA_DM_PM_PARK_MAX,   BTA_DM_PM_PARK_MIN,   BTA_DM_PM_PARK_ATTEMPT,   BTA_DM_PM_PARK_TIMEOUT,   BTM_PM_MD_PARK}
    459 
    460 #ifdef BTE_SIM_APP      /* For Insight builds only */
    461   /* Entries at the end of the bta_dm_pm_md table are user-defined (runtime configurable),
    462      for power consumption experiments.
    463      Insight finds the first user-defined entry by looking for the first 'max=0'.
    464      The number of user_defined specs is defined by BTA_SWRAP_UD_PM_DM_COUNT */
    465   ,
    466   {0},           /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_0 */
    467   {0},           /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_0 */
    468 
    469   {0},           /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_1 */
    470   {0}            /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_1 */
    471 #endif  /* BTE_SIM_APP */
    472 };
    473 
    474 /* 0=max_lat -> no SSR */
    475 /* the smaller of the SSR max latency wins.
    476  * the entries in this table must be from highest latency (biggest interval) to lowest latency */
    477 #if (BTM_SSR_INCLUDED == TRUE)
    478 tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] =
    479 {
    480     /*max_lat, min_rmt_to, min_loc_to*/
    481     {0,      0, 0},     /* BTA_DM_PM_SSR0 - do not use SSR */
    482     {0,      0, 2},     /* BTA_DM_PM_SSR1 - HH, can NOT share entry with any other profile,
    483                            seting default max latency and min remote timeout as 0,
    484                            and always read individual device preference from HH module */
    485     {1200,   2, 2},     /* BTA_DM_PM_SSR2 - others (as long as sniff is allowed)*/
    486     {360,  160, 2}      /* BTA_DM_PM_SSR3 - HD */
    487 };
    488 
    489 tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec = (tBTA_DM_SSR_SPEC *)&bta_dm_ssr_spec;
    490 #endif
    491 
    492 tBTA_DM_PM_CFG *p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *)&bta_dm_pm_cfg;
    493 tBTA_DM_PM_SPEC *p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *)&bta_dm_pm_spec;
    494 tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *)&bta_dm_pm_md;
    495 
    496 /* The performance impact of EIR packet size
    497 **
    498 ** When BTM_EIR_DEFAULT_FEC_REQUIRED is TRUE,
    499 ** 1 to 17 bytes,    DM1 is used and most robust.
    500 ** 18 to 121 bytes,  DM3 is used but impacts inquiry scan time with large number
    501 **                    of devices.(almost double with 150 users)
    502 ** 122 to 224 bytes, DM5 is used but cause quite big performance loss even with
    503 **                    small number of users. so it is not recommended.
    504 ** 225 to 240 bytes, DH5 is used without FEC but it not recommended.
    505 **                    (same reason of DM5)
    506 **
    507 ** When BTM_EIR_DEFAULT_FEC_REQUIRED is FALSE,
    508 ** 1 to 27 bytes,    DH1 is used but only robust at short range.
    509 ** 28 to 183 bytes,  DH3 is used but only robust at short range and impacts inquiry
    510 **                    scan time with large number of devices.
    511 ** 184 to 240 bytes, DH5 is used but it not recommended.
    512 */
    513 
    514 #if ( BTM_EIR_SERVER_INCLUDED == TRUE )
    515 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    516                                             /* for example */
    517 const UINT8 bta_dm_eir_uuid16_list[] = {    0x08, 0x11, /* Headset */
    518                                             0x1E, 0x11, /* Handsfree */
    519                                             0x0E, 0x11, /* AV Remote Control */
    520                                             0x0B, 0x11, /* Audio Sink */
    521 };
    522 #endif
    523 
    524 /* Extended Inquiry Response */
    525 const tBTA_DM_EIR_CONF bta_dm_eir_cfg =
    526 {
    527     50,    /* minimum length of local name when it is shortened */
    528            /* if length of local name is longer than this and EIR has not enough */
    529            /* room for all UUID list then local name is shortened to this length */
    530 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    531     8,
    532     (UINT8 *)bta_dm_eir_uuid16_list,
    533 #else
    534     {   /* mask of UUID list in EIR */
    535         0xFFFFFFFF, /* LSB is the first UUID of the first 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */
    536         0xFFFFFFFF  /* LSB is the first UUID of the next 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */
    537         /* BTM_EIR_UUID_LKUP_TBL can be overrided */
    538     },
    539 #endif
    540     NULL,   /* Inquiry TX power         */
    541     0,      /* length of flags in bytes */
    542     NULL,   /* flags for EIR */
    543     0,      /* length of manufacturer specific in bytes */
    544     NULL,   /* manufacturer specific */
    545     0,      /* length of additional data in bytes */
    546     NULL    /* additional data */
    547 };
    548 tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF*)&bta_dm_eir_cfg;
    549 #endif
    550