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