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