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