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          {{BTA_DM_PM_RETRY, 5000},
    438           {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
    439      }}
    440     /* GATTS : 14 */
    441     ,
    442     {(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
    443 #if (BTM_SSR_INCLUDED == TRUE)
    444      (BTA_DM_PM_SSR2), /* the SSR entry */
    445 #endif
    446      {
    447          {{BTA_DM_PM_NO_PREF, 0},
    448           {BTA_DM_PM_NO_ACTION, 0}}, /* conn open  active */
    449          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close  */
    450          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
    451          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
    452          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open  */
    453          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
    454          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
    455          {{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
    456          {{BTA_DM_PM_RETRY, 5000},
    457           {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
    458      }}
    459 
    460 #ifdef BTE_SIM_APP /* For Insight builds only */
    461     /* Entries at the end of the pm_spec table are user-defined (runtime
    462        configurable),
    463        for power consumption experiments.
    464        Insight finds the first user-defined entry by looking for the first
    465        BTA_DM_PM_NO_PREF.
    466        The number of user_defined specs is defined by
    467        BTA_SWRAP_UD_PM_SPEC_COUNT */
    468     ,
    469     {BTA_DM_PM_NO_PREF}, /* pm_spec USER_DEFINED_0 */
    470     {BTA_DM_PM_NO_PREF}  /* pm_spec USER_DEFINED_1 */
    471 #endif                   /* BTE_SIM_APP */
    472 };
    473 
    474 /* Please refer to the SNIFF table definitions in bta_api.h.
    475  *
    476  * Adding to or Modifying the Table
    477  * Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 -
    478  * BTA_DM_PM_SNIFF7.
    479  * Overrides of additional table entries can be specified in bdroid_buildcfg.h.
    480  * If additional
    481  * sniff parameter entries are added or an override of an existing entry is
    482  * specified in
    483  * bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta_api.h will need to
    484  * be match the new
    485  * ordering.
    486  *
    487  * Table Ordering
    488  * Sniff Table entries must be ordered from highest latency (biggest interval)
    489  * to lowest latency.
    490  * If there is a conflict among the connected services the setting with the
    491  * lowest latency will
    492  * be selected.
    493  */
    494 tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] = {
    495     /*
    496      * More sniff parameter entries can be added for
    497      * BTA_DM_PM_SNIFF3 - BTA_DM_PM_SNIFF7, if needed. When entries are added or
    498      * removed, BTA_DM_PM_PARK_IDX needs to be updated to reflect the actual
    499      * index
    500      * BTA_DM_PM_PARK_IDX is defined in bta_api.h and can be override by the
    501      * bdroid_buildcfg.h settings.
    502      * The SNIFF table entries must be in the order from highest latency
    503      * (biggest
    504      * interval) to lowest latency. If there's a conflict among the connected
    505      * services, the setting with lowest latency wins.
    506      */
    507     /* sniff modes: max interval, min interval, attempt, timeout */
    508     {BTA_DM_PM_SNIFF_MAX, BTA_DM_PM_SNIFF_MIN, BTA_DM_PM_SNIFF_ATTEMPT,
    509      BTA_DM_PM_SNIFF_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF - A2DP */
    510     {BTA_DM_PM_SNIFF1_MAX, BTA_DM_PM_SNIFF1_MIN, BTA_DM_PM_SNIFF1_ATTEMPT,
    511      BTA_DM_PM_SNIFF1_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF1 */
    512     {BTA_DM_PM_SNIFF2_MAX, BTA_DM_PM_SNIFF2_MIN, BTA_DM_PM_SNIFF2_ATTEMPT,
    513      BTA_DM_PM_SNIFF2_TIMEOUT,
    514      BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF2- HD idle */
    515     {BTA_DM_PM_SNIFF3_MAX, BTA_DM_PM_SNIFF3_MIN, BTA_DM_PM_SNIFF3_ATTEMPT,
    516      BTA_DM_PM_SNIFF3_TIMEOUT,
    517      BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF3- SCO open */
    518     {BTA_DM_PM_SNIFF4_MAX, BTA_DM_PM_SNIFF4_MIN, BTA_DM_PM_SNIFF4_ATTEMPT,
    519      BTA_DM_PM_SNIFF4_TIMEOUT,
    520      BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF4- HD active */
    521     {BTA_DM_PM_SNIFF5_MAX, BTA_DM_PM_SNIFF5_MIN, BTA_DM_PM_SNIFF5_ATTEMPT,
    522      BTA_DM_PM_SNIFF5_TIMEOUT,
    523      BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF5- HD active */
    524     {BTA_DM_PM_PARK_MAX, BTA_DM_PM_PARK_MIN, BTA_DM_PM_PARK_ATTEMPT,
    525      BTA_DM_PM_PARK_TIMEOUT, BTM_PM_MD_PARK}
    526 
    527 #ifdef BTE_SIM_APP /* For Insight builds only */
    528     /* Entries at the end of the bta_dm_pm_md table are user-defined (runtime
    529        configurable),
    530        for power consumption experiments.
    531        Insight finds the first user-defined entry by looking for the first
    532        'max=0'.
    533        The number of user_defined specs is defined by BTA_SWRAP_UD_PM_DM_COUNT
    534        */
    535     ,
    536     {0}, /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_0
    537             */
    538     {0}, /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_0 */
    539 
    540     {0}, /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_1
    541             */
    542     {0}  /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_1 */
    543 #endif   /* BTE_SIM_APP */
    544 };
    545 
    546 /* 0=max_lat -> no SSR */
    547 /* the smaller of the SSR max latency wins.
    548  * the entries in this table must be from highest latency (biggest interval) to
    549  * lowest latency */
    550 #if (BTM_SSR_INCLUDED == TRUE)
    551 tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] = {
    552     /*max_lat, min_rmt_to, min_loc_to*/
    553     {0, 0, 0}, /* BTA_DM_PM_SSR0 - do not use SSR */
    554     /* BTA_DM_PM_SSR1 - HH, can NOT share entry with any other profile, seting
    555        default max latency and min remote timeout as 0, and always read
    556        individual device preference from HH module */
    557     {0, 0, 2},
    558     {1200, 2, 2},    /* BTA_DM_PM_SSR2 - others (as long as sniff is allowed)*/
    559     {360, 160, 1600} /* BTA_DM_PM_SSR3 - HD */
    560 };
    561 
    562 tBTA_DM_SSR_SPEC* p_bta_dm_ssr_spec = (tBTA_DM_SSR_SPEC*)&bta_dm_ssr_spec;
    563 #endif
    564 
    565 tBTA_DM_PM_CFG* p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG*)&bta_dm_pm_cfg;
    566 tBTA_DM_PM_SPEC* p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC*)&bta_dm_pm_spec;
    567 tBTM_PM_PWR_MD* p_bta_dm_pm_md = (tBTM_PM_PWR_MD*)&bta_dm_pm_md;
    568 
    569 /* The performance impact of EIR packet size
    570  *
    571  * When BTM_EIR_DEFAULT_FEC_REQUIRED is true,
    572  * 1 to 17 bytes,    DM1 is used and most robust.
    573  * 18 to 121 bytes,  DM3 is used but impacts inquiry scan time with large number
    574  *                    of devices.(almost double with 150 users)
    575  * 122 to 224 bytes, DM5 is used but cause quite big performance loss even with
    576  *                    small number of users. so it is not recommended.
    577  * 225 to 240 bytes, DH5 is used without FEC but it not recommended.
    578  *                    (same reason of DM5)
    579  *
    580  * When BTM_EIR_DEFAULT_FEC_REQUIRED is false,
    581  * 1 to 27 bytes,    DH1 is used but only robust at short range.
    582  * 28 to 183 bytes,  DH3 is used but only robust at short range and impacts
    583  * inquiry
    584  *                    scan time with large number of devices.
    585  * 184 to 240 bytes, DH5 is used but it not recommended.
    586 */
    587 
    588 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    589 /* for example */
    590 const uint8_t bta_dm_eir_uuid16_list[] = {
    591     0x08, 0x11, /* Headset */
    592     0x1E, 0x11, /* Handsfree */
    593     0x0E, 0x11, /* AV Remote Control */
    594     0x0B, 0x11, /* Audio Sink */
    595 };
    596 #endif  // BTA_EIR_CANNED_UUID_LIST
    597 
    598 /* Extended Inquiry Response */
    599 const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
    600     50, /* minimum length of local name when it is shortened */
    601         /* if length of local name is longer than this and EIR has not enough */
    602         /* room for all UUID list then local name is shortened to this length */
    603 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
    604     8,    (uint8_t*)bta_dm_eir_uuid16_list,
    605 #else     // BTA_EIR_CANNED_UUID_LIST
    606     {
    607         /* mask of UUID list in EIR */
    608         0xFFFFFFFF, /* LSB is the first UUID of the first 32 UUIDs in
    609                        BTM_EIR_UUID_LKUP_TBL */
    610         0xFFFFFFFF  /* LSB is the first UUID of the next 32 UUIDs in
    611                        BTM_EIR_UUID_LKUP_TBL */
    612         /* BTM_EIR_UUID_LKUP_TBL can be overrided */
    613     },
    614 #endif    // BTA_EIR_CANNED_UUID_LIST
    615     NULL, /* Inquiry TX power         */
    616     0,    /* length of flags in bytes */
    617     NULL, /* flags for EIR */
    618     0,    /* length of manufacturer specific in bytes */
    619     NULL, /* manufacturer specific */
    620     0,    /* length of additional data in bytes */
    621     NULL  /* additional data */
    622 };
    623 tBTA_DM_EIR_CONF* p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF*)&bta_dm_eir_cfg;
    624