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