Commit | Line | Data |
---|---|---|
3c05bedb GKH |
1 | /*************************************************************** |
2 | * Description: | |
3 | * | |
4 | * This file is for RTL8723B Co-exist mechanism | |
5 | * | |
6 | * History | |
7 | * 2012/11/15 Cosa first check in. | |
8 | * | |
9 | ***************************************************************/ | |
10 | ||
11 | ||
12 | /*************************************************************** | |
13 | * include files | |
14 | ***************************************************************/ | |
15 | #include "halbt_precomp.h" | |
16 | #if 1 | |
17 | /*************************************************************** | |
18 | * Global variables, these are static variables | |
19 | ***************************************************************/ | |
20 | static struct coex_dm_8723b_1ant glcoex_dm_8723b_1ant; | |
21 | static struct coex_dm_8723b_1ant *coex_dm = &glcoex_dm_8723b_1ant; | |
22 | static struct coex_sta_8723b_1ant glcoex_sta_8723b_1ant; | |
23 | static struct coex_sta_8723b_1ant *coex_sta = &glcoex_sta_8723b_1ant; | |
24 | ||
e9329bd3 | 25 | static const char *const GLBtInfoSrc8723b1Ant[] = { |
3c05bedb GKH |
26 | "BT Info[wifi fw]", |
27 | "BT Info[bt rsp]", | |
28 | "BT Info[bt auto report]", | |
29 | }; | |
30 | ||
e9329bd3 KZ |
31 | static u32 glcoex_ver_date_8723b_1ant = 20130906; |
32 | static u32 glcoex_ver_8723b_1ant = 0x45; | |
3c05bedb GKH |
33 | |
34 | /*************************************************************** | |
35 | * local function proto type if needed | |
36 | ***************************************************************/ | |
37 | /*************************************************************** | |
38 | * local function start with halbtc8723b1ant_ | |
39 | ***************************************************************/ | |
e9329bd3 KZ |
40 | static u8 halbtc8723b1ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, |
41 | u8 rssi_thresh1) | |
3c05bedb GKH |
42 | { |
43 | s32 bt_rssi=0; | |
44 | u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; | |
45 | ||
46 | bt_rssi = coex_sta->bt_rssi; | |
47 | ||
48 | if (level_num == 2){ | |
49 | if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || | |
50 | (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { | |
51 | if (bt_rssi >= rssi_thresh + | |
52 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
53 | bt_rssi_state = BTC_RSSI_STATE_HIGH; | |
54 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
55 | "[BTCoex], BT Rssi state " | |
56 | "switch to High\n"); | |
57 | } else { | |
58 | bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
59 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
60 | "[BTCoex], BT Rssi state " | |
61 | "stay at Low\n"); | |
62 | } | |
63 | } else { | |
64 | if (bt_rssi < rssi_thresh) { | |
65 | bt_rssi_state = BTC_RSSI_STATE_LOW; | |
66 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
67 | "[BTCoex], BT Rssi state " | |
68 | "switch to Low\n"); | |
69 | } else { | |
70 | bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
71 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
72 | "[BTCoex], BT Rssi state " | |
73 | "stay at High\n"); | |
74 | } | |
75 | } | |
76 | } else if (level_num == 3) { | |
77 | if (rssi_thresh > rssi_thresh1) { | |
78 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
79 | "[BTCoex], BT Rssi thresh error!!\n"); | |
80 | return coex_sta->pre_bt_rssi_state; | |
81 | } | |
82 | ||
83 | if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || | |
84 | (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { | |
85 | if (bt_rssi >= rssi_thresh + | |
86 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
87 | bt_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
88 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
89 | "[BTCoex], BT Rssi state " | |
90 | "switch to Medium\n"); | |
91 | } else { | |
92 | bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
93 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
94 | "[BTCoex], BT Rssi state " | |
95 | "stay at Low\n"); | |
96 | } | |
97 | } else if ((coex_sta->pre_bt_rssi_state == | |
98 | BTC_RSSI_STATE_MEDIUM) || | |
99 | (coex_sta->pre_bt_rssi_state == | |
100 | BTC_RSSI_STATE_STAY_MEDIUM)) { | |
101 | if (bt_rssi >= rssi_thresh1 + | |
102 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
103 | bt_rssi_state = BTC_RSSI_STATE_HIGH; | |
104 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
105 | "[BTCoex], BT Rssi state " | |
106 | "switch to High\n"); | |
107 | } else if (bt_rssi < rssi_thresh) { | |
108 | bt_rssi_state = BTC_RSSI_STATE_LOW; | |
109 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
110 | "[BTCoex], BT Rssi state " | |
111 | "switch to Low\n"); | |
112 | } else { | |
113 | bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; | |
114 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
115 | "[BTCoex], BT Rssi state " | |
116 | "stay at Medium\n"); | |
117 | } | |
118 | } else { | |
119 | if (bt_rssi < rssi_thresh1) { | |
120 | bt_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
121 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
122 | "[BTCoex], BT Rssi state " | |
123 | "switch to Medium\n"); | |
124 | } else { | |
125 | bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
126 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
127 | "[BTCoex], BT Rssi state " | |
128 | "stay at High\n"); | |
129 | } | |
130 | } | |
131 | } | |
132 | ||
133 | coex_sta->pre_bt_rssi_state = bt_rssi_state; | |
134 | ||
135 | return bt_rssi_state; | |
136 | } | |
137 | ||
e9329bd3 KZ |
138 | static u8 halbtc8723b1ant_wifi_rssi_state(struct btc_coexist *btcoexist, |
139 | u8 index, u8 level_num, | |
140 | u8 rssi_thresh, u8 rssi_thresh1) | |
3c05bedb GKH |
141 | { |
142 | s32 wifi_rssi=0; | |
143 | u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; | |
144 | ||
145 | btcoexist->btc_get(btcoexist, | |
146 | BTC_GET_S4_WIFI_RSSI, &wifi_rssi); | |
147 | ||
148 | if (level_num == 2) { | |
149 | if ((coex_sta->pre_wifi_rssi_state[index] == | |
150 | BTC_RSSI_STATE_LOW) || | |
151 | (coex_sta->pre_wifi_rssi_state[index] == | |
152 | BTC_RSSI_STATE_STAY_LOW)) { | |
153 | if (wifi_rssi >= rssi_thresh + | |
154 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
155 | wifi_rssi_state = BTC_RSSI_STATE_HIGH; | |
156 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
157 | ALGO_WIFI_RSSI_STATE, | |
158 | "[BTCoex], wifi RSSI state " | |
159 | "switch to High\n"); | |
160 | } else { | |
161 | wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
162 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
163 | ALGO_WIFI_RSSI_STATE, | |
164 | "[BTCoex], wifi RSSI state " | |
165 | "stay at Low\n"); | |
166 | } | |
167 | } else { | |
168 | if (wifi_rssi < rssi_thresh) { | |
169 | wifi_rssi_state = BTC_RSSI_STATE_LOW; | |
170 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
171 | ALGO_WIFI_RSSI_STATE, | |
172 | "[BTCoex], wifi RSSI state " | |
173 | "switch to Low\n"); | |
174 | } else { | |
175 | wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
176 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
177 | ALGO_WIFI_RSSI_STATE, | |
178 | "[BTCoex], wifi RSSI state " | |
179 | "stay at High\n"); | |
180 | } | |
181 | } | |
182 | } else if (level_num == 3) { | |
183 | if (rssi_thresh > rssi_thresh1) { | |
184 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
185 | "[BTCoex], wifi RSSI thresh error!!\n"); | |
186 | return coex_sta->pre_wifi_rssi_state[index]; | |
187 | } | |
188 | ||
189 | if ((coex_sta->pre_wifi_rssi_state[index] == | |
190 | BTC_RSSI_STATE_LOW) || | |
191 | (coex_sta->pre_wifi_rssi_state[index] == | |
192 | BTC_RSSI_STATE_STAY_LOW)) { | |
193 | if (wifi_rssi >= rssi_thresh + | |
194 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
195 | wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
196 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
197 | ALGO_WIFI_RSSI_STATE, | |
198 | "[BTCoex], wifi RSSI state " | |
199 | "switch to Medium\n"); | |
200 | } else { | |
201 | wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
202 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
203 | ALGO_WIFI_RSSI_STATE, | |
204 | "[BTCoex], wifi RSSI state " | |
205 | "stay at Low\n"); | |
206 | } | |
207 | } else if ((coex_sta->pre_wifi_rssi_state[index] == | |
208 | BTC_RSSI_STATE_MEDIUM) || | |
209 | (coex_sta->pre_wifi_rssi_state[index] == | |
210 | BTC_RSSI_STATE_STAY_MEDIUM)) { | |
211 | if (wifi_rssi >= rssi_thresh1 + | |
212 | BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT) { | |
213 | wifi_rssi_state = BTC_RSSI_STATE_HIGH; | |
214 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
215 | ALGO_WIFI_RSSI_STATE, | |
216 | "[BTCoex], wifi RSSI state " | |
217 | "switch to High\n"); | |
218 | } else if (wifi_rssi < rssi_thresh) { | |
219 | wifi_rssi_state = BTC_RSSI_STATE_LOW; | |
220 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
221 | ALGO_WIFI_RSSI_STATE, | |
222 | "[BTCoex], wifi RSSI state " | |
223 | "switch to Low\n"); | |
224 | } else { | |
225 | wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; | |
226 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
227 | ALGO_WIFI_RSSI_STATE, | |
228 | "[BTCoex], wifi RSSI state " | |
229 | "stay at Medium\n"); | |
230 | } | |
231 | } else { | |
232 | if (wifi_rssi < rssi_thresh1) { | |
233 | wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
234 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
235 | ALGO_WIFI_RSSI_STATE, | |
236 | "[BTCoex], wifi RSSI state " | |
237 | "switch to Medium\n"); | |
238 | } else { | |
239 | wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
240 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
241 | ALGO_WIFI_RSSI_STATE, | |
242 | "[BTCoex], wifi RSSI state " | |
243 | "stay at High\n"); | |
244 | } | |
245 | } | |
246 | } | |
247 | ||
248 | coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; | |
249 | ||
250 | return wifi_rssi_state; | |
251 | } | |
252 | ||
e9329bd3 KZ |
253 | static void halbtc8723b1ant_updatera_mask(struct btc_coexist *btcoexist, |
254 | bool force_exec, u32 dis_rate_mask) | |
3c05bedb GKH |
255 | { |
256 | coex_dm->curra_mask = dis_rate_mask; | |
257 | ||
258 | if (force_exec || (coex_dm->prera_mask != coex_dm->curra_mask)) | |
259 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_UPDATE_ra_mask, | |
260 | &coex_dm->curra_mask); | |
261 | ||
262 | coex_dm->prera_mask = coex_dm->curra_mask; | |
263 | } | |
264 | ||
e9329bd3 KZ |
265 | static void halbtc8723b1ant_auto_rate_fallback_retry( |
266 | struct btc_coexist *btcoexist, | |
267 | bool force_exec, u8 type) | |
3c05bedb GKH |
268 | { |
269 | bool wifi_under_bmode = false; | |
270 | ||
271 | coex_dm->cur_arfr_type = type; | |
272 | ||
273 | if (force_exec || (coex_dm->pre_arfr_type != coex_dm->cur_arfr_type)) { | |
274 | switch (coex_dm->cur_arfr_type) { | |
275 | case 0: /* normal mode */ | |
276 | btcoexist->btc_write_4byte(btcoexist, 0x430, | |
277 | coex_dm->backup_arfr_cnt1); | |
278 | btcoexist->btc_write_4byte(btcoexist, 0x434, | |
279 | coex_dm->backup_arfr_cnt2); | |
280 | break; | |
281 | case 1: | |
282 | btcoexist->btc_get(btcoexist, | |
283 | BTC_GET_BL_WIFI_UNDER_B_MODE, | |
284 | &wifi_under_bmode); | |
285 | if (wifi_under_bmode) { | |
286 | btcoexist->btc_write_4byte(btcoexist, | |
287 | 0x430, 0x0); | |
288 | btcoexist->btc_write_4byte(btcoexist, | |
289 | 0x434, 0x01010101); | |
290 | } else { | |
291 | btcoexist->btc_write_4byte(btcoexist, | |
292 | 0x430, 0x0); | |
293 | btcoexist->btc_write_4byte(btcoexist, | |
294 | 0x434, 0x04030201); | |
295 | } | |
296 | break; | |
297 | default: | |
298 | break; | |
299 | } | |
300 | } | |
301 | ||
302 | coex_dm->pre_arfr_type = coex_dm->cur_arfr_type; | |
303 | } | |
304 | ||
e9329bd3 KZ |
305 | static void halbtc8723b1ant_retry_limit(struct btc_coexist *btcoexist, |
306 | bool force_exec, u8 type) | |
3c05bedb GKH |
307 | { |
308 | coex_dm->cur_retry_limit_type = type; | |
309 | ||
310 | if (force_exec || (coex_dm->pre_retry_limit_type != | |
311 | coex_dm->cur_retry_limit_type)) { | |
312 | ||
313 | switch (coex_dm->cur_retry_limit_type) { | |
314 | case 0: /* normal mode */ | |
315 | btcoexist->btc_write_2byte(btcoexist, 0x42a, | |
316 | coex_dm->backup_retry_limit); | |
317 | break; | |
318 | case 1: /* retry limit=8 */ | |
319 | btcoexist->btc_write_2byte(btcoexist, 0x42a, 0x0808); | |
320 | break; | |
321 | default: | |
322 | break; | |
323 | } | |
324 | } | |
325 | ||
326 | coex_dm->pre_retry_limit_type = coex_dm->cur_retry_limit_type; | |
327 | } | |
328 | ||
e9329bd3 KZ |
329 | static void halbtc8723b1ant_ampdu_maxtime(struct btc_coexist *btcoexist, |
330 | bool force_exec, u8 type) | |
3c05bedb GKH |
331 | { |
332 | coex_dm->cur_ampdu_time_type = type; | |
333 | ||
334 | if (force_exec || (coex_dm->pre_ampdu_time_type != | |
335 | coex_dm->cur_ampdu_time_type)) { | |
336 | switch (coex_dm->cur_ampdu_time_type) { | |
337 | case 0: /* normal mode */ | |
338 | btcoexist->btc_write_1byte(btcoexist, 0x456, | |
339 | coex_dm->backup_ampdu_max_time); | |
340 | break; | |
341 | case 1: /* AMPDU timw = 0x38 * 32us */ | |
342 | btcoexist->btc_write_1byte(btcoexist, | |
343 | 0x456, 0x38); | |
344 | break; | |
345 | default: | |
346 | break; | |
347 | } | |
348 | } | |
349 | ||
350 | coex_dm->pre_ampdu_time_type = coex_dm->cur_ampdu_time_type; | |
351 | } | |
352 | ||
e9329bd3 | 353 | static void halbtc8723b1ant_limited_tx(struct btc_coexist *btcoexist, |
3c05bedb GKH |
354 | bool force_exec, u8 ra_maskType, u8 arfr_type, |
355 | u8 retry_limit_type, u8 ampdu_time_type) | |
356 | { | |
357 | switch (ra_maskType) { | |
358 | case 0: /* normal mode */ | |
359 | halbtc8723b1ant_updatera_mask(btcoexist, force_exec, 0x0); | |
360 | break; | |
361 | case 1: /* disable cck 1/2 */ | |
362 | halbtc8723b1ant_updatera_mask(btcoexist, force_exec, | |
363 | 0x00000003); | |
364 | break; | |
365 | /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4*/ | |
366 | case 2: | |
367 | halbtc8723b1ant_updatera_mask(btcoexist, force_exec, | |
368 | 0x0001f1f7); | |
369 | break; | |
370 | default: | |
371 | break; | |
372 | } | |
373 | ||
374 | halbtc8723b1ant_auto_rate_fallback_retry(btcoexist, force_exec, | |
375 | arfr_type); | |
376 | halbtc8723b1ant_retry_limit(btcoexist, force_exec, retry_limit_type); | |
377 | halbtc8723b1ant_ampdu_maxtime(btcoexist, force_exec, ampdu_time_type); | |
378 | } | |
379 | ||
e9329bd3 | 380 | static void halbtc8723b1ant_limited_rx(struct btc_coexist *btcoexist, |
3c05bedb GKH |
381 | bool force_exec, bool rej_ap_agg_pkt, |
382 | bool b_bt_ctrl_agg_buf_size, u8 agg_buf_size) | |
383 | { | |
384 | bool reject_rx_agg = rej_ap_agg_pkt; | |
385 | bool bt_ctrl_rx_agg_size = b_bt_ctrl_agg_buf_size; | |
386 | u8 rxAggSize = agg_buf_size; | |
387 | ||
388 | /********************************************** | |
389 | * Rx Aggregation related setting | |
390 | **********************************************/ | |
391 | btcoexist->btc_set(btcoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, | |
392 | &reject_rx_agg); | |
393 | /* decide BT control aggregation buf size or not */ | |
394 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, | |
395 | &bt_ctrl_rx_agg_size); | |
396 | /* aggregation buf size, only work | |
397 | *when BT control Rx aggregation size. */ | |
398 | btcoexist->btc_set(btcoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); | |
399 | /* real update aggregation setting */ | |
400 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); | |
401 | } | |
402 | ||
e9329bd3 | 403 | static void halbtc8723b1ant_monitor_bt_ctr(struct btc_coexist *btcoexist) |
3c05bedb GKH |
404 | { |
405 | u32 reg_hp_txrx, reg_lp_txrx, u32tmp; | |
406 | u32 reg_hp_tx = 0, reg_hp_rx = 0; | |
407 | u32 reg_lp_tx = 0, reg_lp_rx = 0; | |
408 | ||
409 | reg_hp_txrx = 0x770; | |
410 | reg_lp_txrx = 0x774; | |
411 | ||
412 | u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); | |
413 | reg_hp_tx = u32tmp & MASKLWORD; | |
414 | reg_hp_rx = (u32tmp & MASKHWORD) >> 16; | |
415 | ||
416 | u32tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); | |
417 | reg_lp_tx = u32tmp & MASKLWORD; | |
418 | reg_lp_rx = (u32tmp & MASKHWORD) >> 16; | |
419 | ||
420 | coex_sta->high_priority_tx = reg_hp_tx; | |
421 | coex_sta->high_priority_rx = reg_hp_rx; | |
422 | coex_sta->low_priority_tx = reg_lp_tx; | |
423 | coex_sta->low_priority_rx = reg_lp_rx; | |
424 | ||
425 | /* reset counter */ | |
426 | btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); | |
427 | } | |
428 | ||
e9329bd3 | 429 | static void halbtc8723b1ant_query_bt_info(struct btc_coexist *btcoexist) |
3c05bedb GKH |
430 | { |
431 | u8 h2c_parameter[1] = {0}; | |
432 | ||
433 | coex_sta->c2h_bt_info_req_sent = true; | |
434 | ||
435 | h2c_parameter[0] |= BIT0; /* trigger*/ | |
436 | ||
437 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
438 | "[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", | |
439 | h2c_parameter[0]); | |
440 | ||
441 | btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); | |
442 | } | |
443 | ||
e9329bd3 KZ |
444 | static bool halbtc8723b1ant_is_wifi_status_changed( |
445 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
446 | { |
447 | static bool pre_wifi_busy = false; | |
448 | static bool pre_under_4way = false, pre_bt_hs_on = false; | |
449 | bool wifi_busy = false, under_4way = false, bt_hs_on = false; | |
450 | bool wifi_connected = false; | |
451 | ||
452 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
453 | &wifi_connected); | |
454 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
455 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
456 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, | |
457 | &under_4way); | |
458 | ||
459 | if (wifi_connected) { | |
460 | if (wifi_busy != pre_wifi_busy) { | |
461 | pre_wifi_busy = wifi_busy; | |
462 | return true; | |
463 | } | |
464 | if (under_4way != pre_under_4way) { | |
465 | pre_under_4way = under_4way; | |
466 | return true; | |
467 | } | |
468 | if (bt_hs_on != pre_bt_hs_on) { | |
469 | pre_bt_hs_on = bt_hs_on; | |
470 | return true; | |
471 | } | |
472 | } | |
473 | ||
474 | return false; | |
475 | } | |
476 | ||
e9329bd3 | 477 | static void halbtc8723b1ant_update_bt_link_info(struct btc_coexist *btcoexist) |
3c05bedb GKH |
478 | { |
479 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
480 | bool bt_hs_on = false; | |
481 | ||
482 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
483 | ||
484 | bt_link_info->bt_link_exist = coex_sta->bt_link_exist; | |
485 | bt_link_info->sco_exist = coex_sta->sco_exist; | |
486 | bt_link_info->a2dp_exist = coex_sta->a2dp_exist; | |
487 | bt_link_info->pan_exist = coex_sta->pan_exist; | |
488 | bt_link_info->hid_exist = coex_sta->hid_exist; | |
489 | ||
490 | /* work around for HS mode. */ | |
491 | if (bt_hs_on) { | |
492 | bt_link_info->pan_exist = true; | |
493 | bt_link_info->bt_link_exist = true; | |
494 | } | |
495 | ||
496 | /* check if Sco only */ | |
497 | if (bt_link_info->sco_exist && !bt_link_info->a2dp_exist && | |
498 | !bt_link_info->pan_exist && !bt_link_info->hid_exist) | |
499 | bt_link_info->sco_only = true; | |
500 | else | |
501 | bt_link_info->sco_only = false; | |
502 | ||
503 | /* check if A2dp only */ | |
504 | if (!bt_link_info->sco_exist && bt_link_info->a2dp_exist && | |
505 | !bt_link_info->pan_exist && !bt_link_info->hid_exist) | |
506 | bt_link_info->a2dp_only = true; | |
507 | else | |
508 | bt_link_info->a2dp_only = false; | |
509 | ||
510 | /* check if Pan only */ | |
511 | if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && | |
512 | bt_link_info->pan_exist && !bt_link_info->hid_exist) | |
513 | bt_link_info->pan_only = true; | |
514 | else | |
515 | bt_link_info->pan_only = false; | |
516 | ||
517 | /* check if Hid only */ | |
518 | if (!bt_link_info->sco_exist && !bt_link_info->a2dp_exist && | |
519 | !bt_link_info->pan_exist && bt_link_info->hid_exist ) | |
520 | bt_link_info->hid_only = true; | |
521 | else | |
522 | bt_link_info->hid_only = false; | |
523 | } | |
524 | ||
e9329bd3 | 525 | static u8 halbtc8723b1ant_action_algorithm(struct btc_coexist *btcoexist) |
3c05bedb GKH |
526 | { |
527 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
528 | bool bt_hs_on = false; | |
529 | u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED; | |
530 | u8 numOfDiffProfile = 0; | |
531 | ||
532 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
533 | ||
534 | if (!bt_link_info->bt_link_exist) { | |
535 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
536 | "[BTCoex], No BT link exists!!!\n"); | |
537 | return algorithm; | |
538 | } | |
539 | ||
540 | if (bt_link_info->sco_exist) | |
541 | numOfDiffProfile++; | |
542 | if (bt_link_info->hid_exist) | |
543 | numOfDiffProfile++; | |
544 | if (bt_link_info->pan_exist) | |
545 | numOfDiffProfile++; | |
546 | if (bt_link_info->a2dp_exist) | |
547 | numOfDiffProfile++; | |
548 | ||
549 | if (numOfDiffProfile == 1) { | |
550 | if (bt_link_info->sco_exist) { | |
551 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
552 | "[BTCoex], BT Profile = SCO only\n"); | |
553 | algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; | |
554 | } else { | |
555 | if (bt_link_info->hid_exist) { | |
556 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
557 | "[BTCoex], BT Profile = HID only\n"); | |
558 | algorithm = BT_8723B_1ANT_COEX_ALGO_HID; | |
559 | } else if (bt_link_info->a2dp_exist) { | |
560 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
561 | "[BTCoex], BT Profile = A2DP only\n"); | |
562 | algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP; | |
563 | } else if (bt_link_info->pan_exist) { | |
564 | if (bt_hs_on) { | |
565 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
566 | "[BTCoex], BT Profile = " | |
567 | "PAN(HS) only\n"); | |
568 | algorithm = | |
569 | BT_8723B_1ANT_COEX_ALGO_PANHS; | |
570 | } else { | |
571 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
572 | "[BTCoex], BT Profile = " | |
573 | "PAN(EDR) only\n"); | |
574 | algorithm = | |
575 | BT_8723B_1ANT_COEX_ALGO_PANEDR; | |
576 | } | |
577 | } | |
578 | } | |
579 | } else if (numOfDiffProfile == 2) { | |
580 | if (bt_link_info->sco_exist) { | |
581 | if (bt_link_info->hid_exist) { | |
582 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
583 | "[BTCoex], BT Profile = SCO + HID\n"); | |
584 | algorithm = BT_8723B_1ANT_COEX_ALGO_HID; | |
585 | } else if (bt_link_info->a2dp_exist) { | |
586 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
587 | "[BTCoex], BT Profile = " | |
588 | "SCO + A2DP ==> SCO\n"); | |
589 | algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; | |
590 | } else if (bt_link_info->pan_exist) { | |
591 | if (bt_hs_on) { | |
592 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
593 | "[BTCoex], BT Profile " | |
594 | "= SCO + PAN(HS)\n"); | |
595 | algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; | |
596 | } else { | |
597 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
598 | "[BTCoex], BT Profile " | |
599 | "= SCO + PAN(EDR)\n"); | |
600 | algorithm = | |
601 | BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; | |
602 | } | |
603 | } | |
604 | } else { | |
605 | if (bt_link_info->hid_exist && | |
606 | bt_link_info->a2dp_exist) { | |
607 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
608 | "[BTCoex], BT Profile = " | |
609 | "HID + A2DP\n"); | |
610 | algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; | |
611 | } else if (bt_link_info->hid_exist && | |
612 | bt_link_info->pan_exist) { | |
613 | if (bt_hs_on) { | |
614 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
615 | "[BTCoex], BT Profile = " | |
616 | "HID + PAN(HS)\n"); | |
617 | algorithm = | |
618 | BT_8723B_1ANT_COEX_ALGO_HID_A2DP; | |
619 | } else { | |
620 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
621 | "[BTCoex], BT Profile = " | |
622 | "HID + PAN(EDR)\n"); | |
623 | algorithm = | |
624 | BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; | |
625 | } | |
626 | } else if (bt_link_info->pan_exist && | |
627 | bt_link_info->a2dp_exist) { | |
628 | if (bt_hs_on) { | |
629 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
630 | "[BTCoex], BT Profile = " | |
631 | "A2DP + PAN(HS)\n"); | |
632 | algorithm = | |
633 | BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS; | |
634 | } else { | |
635 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
636 | "[BTCoex], BT Profile = " | |
637 | "A2DP + PAN(EDR)\n"); | |
638 | algorithm = | |
639 | BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP; | |
640 | } | |
641 | } | |
642 | } | |
643 | } else if (numOfDiffProfile == 3) { | |
644 | if (bt_link_info->sco_exist) { | |
645 | if (bt_link_info->hid_exist && | |
646 | bt_link_info->a2dp_exist) { | |
647 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
648 | "[BTCoex], BT Profile = " | |
649 | "SCO + HID + A2DP ==> HID\n"); | |
650 | algorithm = BT_8723B_1ANT_COEX_ALGO_HID; | |
651 | } else if (bt_link_info->hid_exist && | |
652 | bt_link_info->pan_exist) { | |
653 | if (bt_hs_on) { | |
654 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
655 | "[BTCoex], BT Profile = " | |
656 | "SCO + HID + PAN(HS)\n"); | |
657 | algorithm = | |
658 | BT_8723B_1ANT_COEX_ALGO_HID_A2DP; | |
659 | } else { | |
660 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
661 | "[BTCoex], BT Profile = " | |
662 | "SCO + HID + PAN(EDR)\n"); | |
663 | algorithm = | |
664 | BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; | |
665 | } | |
666 | } else if (bt_link_info->pan_exist && | |
667 | bt_link_info->a2dp_exist) { | |
668 | if (bt_hs_on) { | |
669 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
670 | "[BTCoex], BT Profile = " | |
671 | "SCO + A2DP + PAN(HS)\n"); | |
672 | algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; | |
673 | } else { | |
674 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
675 | "[BTCoex], BT Profile = SCO + " | |
676 | "A2DP + PAN(EDR) ==> HID\n"); | |
677 | algorithm = | |
678 | BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; | |
679 | } | |
680 | } | |
681 | } else { | |
682 | if (bt_link_info->hid_exist && | |
683 | bt_link_info->pan_exist && | |
684 | bt_link_info->a2dp_exist) { | |
685 | if (bt_hs_on) { | |
686 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
687 | "[BTCoex], BT Profile = " | |
688 | "HID + A2DP + PAN(HS)\n"); | |
689 | algorithm = | |
690 | BT_8723B_1ANT_COEX_ALGO_HID_A2DP; | |
691 | } else { | |
692 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
693 | "[BTCoex], BT Profile = " | |
694 | "HID + A2DP + PAN(EDR)\n"); | |
695 | algorithm = | |
696 | BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR; | |
697 | } | |
698 | } | |
699 | } | |
700 | } else if (numOfDiffProfile >= 3) { | |
701 | if (bt_link_info->sco_exist) { | |
702 | if (bt_link_info->hid_exist && | |
703 | bt_link_info->pan_exist && | |
704 | bt_link_info->a2dp_exist) { | |
705 | if (bt_hs_on) { | |
706 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
707 | "[BTCoex], Error!!! " | |
708 | "BT Profile = SCO + " | |
709 | "HID + A2DP + PAN(HS)\n"); | |
710 | } else { | |
711 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
712 | "[BTCoex], BT Profile = " | |
713 | "SCO + HID + A2DP + PAN(EDR)" | |
714 | "==>PAN(EDR)+HID\n"); | |
715 | algorithm = | |
716 | BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; | |
717 | } | |
718 | } | |
719 | } | |
720 | } | |
721 | ||
722 | return algorithm; | |
723 | } | |
724 | ||
e9329bd3 | 725 | static bool halbtc8723b1ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) |
3c05bedb GKH |
726 | { |
727 | bool ret = false; | |
728 | bool bt_hs_on = false, wifi_connected = false; | |
729 | s32 bt_hs_rssi = 0; | |
730 | u8 bt_rssi_state; | |
731 | ||
732 | if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on)) | |
733 | return false; | |
734 | if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
735 | &wifi_connected)) | |
736 | return false; | |
737 | if (!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi)) | |
738 | return false; | |
739 | ||
740 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 35, 0); | |
741 | ||
742 | if (wifi_connected) { | |
743 | if (bt_hs_on) { | |
744 | if (bt_hs_rssi > 37) | |
745 | ret = true; | |
746 | } else { | |
747 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
748 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
749 | ret = true; | |
750 | } | |
751 | } | |
752 | ||
753 | return ret; | |
754 | } | |
755 | ||
e9329bd3 KZ |
756 | static void halbtc8723b1ant_set_fw_dac_swing_level( |
757 | struct btc_coexist *btcoexist, | |
758 | u8 dac_swing_lvl) | |
3c05bedb GKH |
759 | { |
760 | u8 h2c_parameter[1] = {0}; | |
761 | ||
762 | /* There are several type of dacswing | |
763 | * 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ | |
764 | h2c_parameter[0] = dac_swing_lvl; | |
765 | ||
766 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
767 | "[BTCoex], Set Dac Swing Level=0x%x\n", dac_swing_lvl); | |
768 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
769 | "[BTCoex], FW write 0x64=0x%x\n", h2c_parameter[0]); | |
770 | ||
771 | btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); | |
772 | } | |
773 | ||
e9329bd3 | 774 | static void halbtc8723b1ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, |
3c05bedb GKH |
775 | bool dec_bt_pwr) |
776 | { | |
777 | u8 h2c_parameter[1] = {0}; | |
778 | ||
779 | h2c_parameter[0] = 0; | |
780 | ||
781 | if (dec_bt_pwr) | |
782 | h2c_parameter[0] |= BIT1; | |
783 | ||
784 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
785 | "[BTCoex], decrease Bt Power : %s, FW write 0x62=0x%x\n", | |
786 | (dec_bt_pwr? "Yes!!":"No!!"),h2c_parameter[0]); | |
787 | ||
788 | btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); | |
789 | } | |
790 | ||
e9329bd3 | 791 | static void halbtc8723b1ant_dec_bt_pwr(struct btc_coexist *btcoexist, |
3c05bedb GKH |
792 | bool force_exec, bool dec_bt_pwr) |
793 | { | |
794 | return; | |
795 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
796 | "[BTCoex], %s Dec BT power = %s\n", | |
797 | (force_exec ? "force to" : ""), (dec_bt_pwr ? "ON" : "OFF")); | |
798 | coex_dm->cur_dec_bt_pwr = dec_bt_pwr; | |
799 | ||
800 | if (!force_exec) { | |
801 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
802 | "[BTCoex], bPreDecBtPwr=%d, bCurDecBtPwr=%d\n", | |
803 | coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr); | |
804 | ||
805 | if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr) | |
806 | return; | |
807 | } | |
808 | halbtc8723b1ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr); | |
809 | ||
810 | coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; | |
811 | } | |
812 | ||
f2591796 | 813 | #if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) |
e9329bd3 | 814 | static void halbtc8723b1ant_set_bt_auto_report(struct btc_coexist *btcoexist, |
3c05bedb GKH |
815 | bool enable_auto_report) |
816 | { | |
817 | u8 h2c_parameter[1] = {0}; | |
818 | ||
819 | h2c_parameter[0] = 0; | |
820 | ||
821 | if (enable_auto_report) | |
822 | h2c_parameter[0] |= BIT0; | |
823 | ||
824 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
825 | "[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", | |
826 | (enable_auto_report? "Enabled!!":"Disabled!!"), | |
827 | h2c_parameter[0]); | |
828 | ||
829 | btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); | |
830 | } | |
831 | ||
e9329bd3 | 832 | static void halbtc8723b1ant_bt_auto_report(struct btc_coexist *btcoexist, |
3c05bedb GKH |
833 | bool force_exec, bool enable_auto_report) |
834 | { | |
835 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
836 | "[BTCoex], %s BT Auto report = %s\n", | |
837 | (force_exec? "force to":""), | |
838 | ((enable_auto_report)? "Enabled":"Disabled")); | |
839 | coex_dm->cur_bt_auto_report = enable_auto_report; | |
840 | ||
841 | if (!force_exec) { | |
842 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
843 | "[BTCoex], bPreBtAutoReport=%d, " | |
844 | "bCurBtAutoReport=%d\n", | |
845 | coex_dm->pre_bt_auto_report, | |
846 | coex_dm->cur_bt_auto_report); | |
847 | ||
848 | if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) | |
849 | return; | |
850 | } | |
851 | halbtc8723b1ant_set_bt_auto_report(btcoexist, | |
852 | coex_dm->cur_bt_auto_report); | |
853 | ||
854 | coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; | |
855 | } | |
f2591796 | 856 | #endif |
3c05bedb | 857 | |
e9329bd3 | 858 | static void halbtc8723b1ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, |
3c05bedb GKH |
859 | bool force_exec, u8 fw_dac_swing_lvl) |
860 | { | |
861 | return; | |
862 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
863 | "[BTCoex], %s set FW Dac Swing level = %d\n", | |
864 | (force_exec? "force to":""), fw_dac_swing_lvl); | |
865 | coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl; | |
866 | ||
867 | if (!force_exec) { | |
868 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
869 | "[BTCoex], preFwDacSwingLvl=%d, " | |
870 | "curFwDacSwingLvl=%d\n", | |
871 | coex_dm->pre_fw_dac_swing_lvl, | |
872 | coex_dm->cur_fw_dac_swing_lvl); | |
873 | ||
874 | if (coex_dm->pre_fw_dac_swing_lvl == | |
875 | coex_dm->cur_fw_dac_swing_lvl) | |
876 | return; | |
877 | } | |
878 | ||
879 | halbtc8723b1ant_set_fw_dac_swing_level(btcoexist, | |
880 | coex_dm->cur_fw_dac_swing_lvl); | |
881 | ||
882 | coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; | |
883 | } | |
884 | ||
e9329bd3 | 885 | static void halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive( |
3c05bedb GKH |
886 | struct btc_coexist *btcoexist, |
887 | bool low_penalty_ra) | |
888 | { | |
889 | u8 h2c_parameter[6] = {0}; | |
890 | ||
891 | h2c_parameter[0] = 0x6; /* opCode, 0x6= Retry_Penalty */ | |
892 | ||
893 | if (low_penalty_ra) { | |
894 | h2c_parameter[1] |= BIT0; | |
895 | /*normal rate except MCS7/6/5, OFDM54/48/36 */ | |
896 | h2c_parameter[2] = 0x00; | |
897 | h2c_parameter[3] = 0xf7; /*MCS7 or OFDM54 */ | |
898 | h2c_parameter[4] = 0xf8; /*MCS6 or OFDM48 */ | |
899 | h2c_parameter[5] = 0xf9; /*MCS5 or OFDM36 */ | |
900 | } | |
901 | ||
902 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
903 | "[BTCoex], set WiFi Low-Penalty Retry: %s", | |
904 | (low_penalty_ra ? "ON!!" : "OFF!!")); | |
905 | ||
906 | btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); | |
907 | } | |
908 | ||
e9329bd3 | 909 | static void halbtc8723b1ant_low_penalty_ra(struct btc_coexist *btcoexist, |
3c05bedb GKH |
910 | bool force_exec, bool low_penalty_ra) |
911 | { | |
912 | coex_dm->cur_low_penalty_ra = low_penalty_ra; | |
913 | ||
914 | if (!force_exec) { | |
915 | if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) | |
916 | return; | |
917 | } | |
918 | halbtc8723b1ant_set_sw_penalty_tx_rate_adaptive(btcoexist, | |
919 | coex_dm->cur_low_penalty_ra); | |
920 | ||
921 | coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; | |
922 | } | |
923 | ||
e9329bd3 | 924 | static void halbtc8723b1ant_set_coex_table(struct btc_coexist *btcoexist, |
3c05bedb GKH |
925 | u32 val0x6c0, u32 val0x6c4, |
926 | u32 val0x6c8, u8 val0x6cc) | |
927 | { | |
928 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
929 | "[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0); | |
930 | btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); | |
931 | ||
932 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
933 | "[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4); | |
934 | btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); | |
935 | ||
936 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
937 | "[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8); | |
938 | btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); | |
939 | ||
940 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
941 | "[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc); | |
942 | btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); | |
943 | } | |
944 | ||
e9329bd3 | 945 | static void halbtc8723b1ant_coex_table(struct btc_coexist *btcoexist, |
3c05bedb GKH |
946 | bool force_exec, u32 val0x6c0, |
947 | u32 val0x6c4, u32 val0x6c8, | |
948 | u8 val0x6cc) | |
949 | { | |
950 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
951 | "[BTCoex], %s write Coex Table 0x6c0=0x%x," | |
952 | " 0x6c4=0x%x, 0x6cc=0x%x\n", (force_exec ? "force to" : ""), | |
953 | val0x6c0, val0x6c4, val0x6cc); | |
954 | coex_dm->cur_val0x6c0 = val0x6c0; | |
955 | coex_dm->cur_val0x6c4 = val0x6c4; | |
956 | coex_dm->cur_val0x6c8 = val0x6c8; | |
957 | coex_dm->cur_val0x6cc = val0x6cc; | |
958 | ||
959 | if (!force_exec) { | |
960 | if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && | |
961 | (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && | |
962 | (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && | |
963 | (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) | |
964 | return; | |
965 | } | |
966 | halbtc8723b1ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, | |
967 | val0x6c8, val0x6cc); | |
968 | ||
969 | coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; | |
970 | coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; | |
971 | coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; | |
972 | coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; | |
973 | } | |
974 | ||
e9329bd3 | 975 | static void halbtc8723b1ant_coex_table_with_type(struct btc_coexist *btcoexist, |
3c05bedb GKH |
976 | bool force_exec, u8 type) |
977 | { | |
978 | switch (type) { | |
979 | case 0: | |
980 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, | |
981 | 0x55555555, 0xffffff, 0x3); | |
982 | break; | |
983 | case 1: | |
984 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, | |
985 | 0x5a5a5a5a, 0xffffff, 0x3); | |
986 | break; | |
987 | case 2: | |
988 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, | |
989 | 0x5a5a5a5a, 0xffffff, 0x3); | |
990 | break; | |
991 | case 3: | |
992 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, | |
993 | 0xaaaaaaaa, 0xffffff, 0x3); | |
994 | break; | |
995 | case 4: | |
996 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, | |
997 | 0x5aaa5aaa, 0xffffff, 0x3); | |
998 | break; | |
999 | case 5: | |
1000 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5a5a5a5a, | |
1001 | 0xaaaa5a5a, 0xffffff, 0x3); | |
1002 | break; | |
1003 | case 6: | |
1004 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x55555555, | |
1005 | 0xaaaa5a5a, 0xffffff, 0x3); | |
1006 | break; | |
1007 | case 7: | |
1008 | halbtc8723b1ant_coex_table(btcoexist, force_exec, 0x5afa5afa, | |
1009 | 0x5afa5afa, 0xffffff, 0x3); | |
1010 | break; | |
1011 | default: | |
1012 | break; | |
1013 | } | |
1014 | } | |
1015 | ||
e9329bd3 | 1016 | static void halbtc8723b1ant_SetFwIgnoreWlanAct(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1017 | bool enable) |
1018 | { | |
1019 | u8 h2c_parameter[1] = {0}; | |
1020 | ||
1021 | if (enable) | |
1022 | h2c_parameter[0] |= BIT0; /* function enable */ | |
1023 | ||
1024 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
1025 | "[BTCoex], set FW for BT Ignore Wlan_Act," | |
1026 | " FW write 0x63=0x%x\n", h2c_parameter[0]); | |
1027 | ||
1028 | btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); | |
1029 | } | |
1030 | ||
e9329bd3 | 1031 | static void halbtc8723b1ant_ignore_wlan_act(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1032 | bool force_exec, bool enable) |
1033 | { | |
1034 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
1035 | "[BTCoex], %s turn Ignore WlanAct %s\n", | |
1036 | (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); | |
1037 | coex_dm->cur_ignore_wlan_act = enable; | |
1038 | ||
1039 | if (!force_exec) { | |
1040 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1041 | "[BTCoex], bPreIgnoreWlanAct = %d, " | |
1042 | "bCurIgnoreWlanAct = %d!!\n", | |
1043 | coex_dm->pre_ignore_wlan_act, | |
1044 | coex_dm->cur_ignore_wlan_act); | |
1045 | ||
1046 | if (coex_dm->pre_ignore_wlan_act == | |
1047 | coex_dm->cur_ignore_wlan_act) | |
1048 | return; | |
1049 | } | |
1050 | halbtc8723b1ant_SetFwIgnoreWlanAct(btcoexist, enable); | |
1051 | ||
1052 | coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; | |
1053 | } | |
1054 | ||
e9329bd3 | 1055 | static void halbtc8723b1ant_set_fw_ps_tdma(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1056 | u8 byte1, u8 byte2, u8 byte3, |
1057 | u8 byte4, u8 byte5) | |
1058 | { | |
1059 | u8 h2c_parameter[5] = {0}; | |
1060 | u8 real_byte1 = byte1, real_byte5 = byte5; | |
1061 | bool ap_enable = false; | |
1062 | ||
1063 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, | |
1064 | &ap_enable); | |
1065 | ||
1066 | if (ap_enable) { | |
1067 | if ((byte1 & BIT4) && !(byte1 & BIT5)) { | |
1068 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
1069 | "[BTCoex], FW for 1Ant AP mode\n"); | |
1070 | real_byte1 &= ~BIT4; | |
1071 | real_byte1 |= BIT5; | |
1072 | ||
1073 | real_byte5 |= BIT5; | |
1074 | real_byte5 &= ~BIT6; | |
1075 | } | |
1076 | } | |
1077 | ||
1078 | h2c_parameter[0] = real_byte1; | |
1079 | h2c_parameter[1] = byte2; | |
1080 | h2c_parameter[2] = byte3; | |
1081 | h2c_parameter[3] = byte4; | |
1082 | h2c_parameter[4] = real_byte5; | |
1083 | ||
1084 | coex_dm->ps_tdma_para[0] = real_byte1; | |
1085 | coex_dm->ps_tdma_para[1] = byte2; | |
1086 | coex_dm->ps_tdma_para[2] = byte3; | |
1087 | coex_dm->ps_tdma_para[3] = byte4; | |
1088 | coex_dm->ps_tdma_para[4] = real_byte5; | |
1089 | ||
1090 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
1091 | "[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", | |
1092 | h2c_parameter[0], | |
1093 | h2c_parameter[1] << 24 | | |
1094 | h2c_parameter[2] << 16 | | |
1095 | h2c_parameter[3] << 8 | | |
1096 | h2c_parameter[4]); | |
1097 | ||
1098 | btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); | |
1099 | } | |
1100 | ||
e9329bd3 | 1101 | static void halbtc8723b1ant_SetLpsRpwm(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1102 | u8 lps_val, u8 rpwm_val) |
1103 | { | |
1104 | u8 lps = lps_val; | |
1105 | u8 rpwm = rpwm_val; | |
1106 | ||
1107 | btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_LPS, &lps); | |
1108 | btcoexist->btc_set(btcoexist, BTC_SET_U1_1ANT_RPWM, &rpwm); | |
1109 | } | |
1110 | ||
e9329bd3 KZ |
1111 | static void halbtc8723b1ant_LpsRpwm(struct btc_coexist *btcoexist, |
1112 | bool force_exec, u8 lps_val, u8 rpwm_val) | |
3c05bedb GKH |
1113 | { |
1114 | ||
1115 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
1116 | "[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", | |
1117 | (force_exec ? "force to" : ""), lps_val, rpwm_val); | |
1118 | coex_dm->cur_lps = lps_val; | |
1119 | coex_dm->cur_rpwm = rpwm_val; | |
1120 | ||
1121 | if (!force_exec) { | |
1122 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1123 | "[BTCoex], LPS-RxBeaconMode=0x%x , LPS-RPWM=0x%x!!\n", | |
1124 | coex_dm->cur_lps, coex_dm->cur_rpwm); | |
1125 | ||
1126 | if ((coex_dm->pre_lps == coex_dm->cur_lps) && | |
1127 | (coex_dm->pre_rpwm == coex_dm->cur_rpwm)) { | |
1128 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1129 | "[BTCoex], LPS-RPWM_Last=0x%x" | |
1130 | " , LPS-RPWM_Now=0x%x!!\n", | |
1131 | coex_dm->pre_rpwm, coex_dm->cur_rpwm); | |
1132 | ||
1133 | return; | |
1134 | } | |
1135 | } | |
1136 | halbtc8723b1ant_SetLpsRpwm(btcoexist, lps_val, rpwm_val); | |
1137 | ||
1138 | coex_dm->pre_lps = coex_dm->cur_lps; | |
1139 | coex_dm->pre_rpwm = coex_dm->cur_rpwm; | |
1140 | } | |
1141 | ||
e9329bd3 | 1142 | static void halbtc8723b1ant_sw_mechanism1(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1143 | bool shrink_rx_lpf, bool low_penalty_ra, |
1144 | bool limited_dig, bool bt_lna_constrain) | |
1145 | { | |
1146 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1147 | "[BTCoex], SM1[ShRf/ LpRA/ LimDig/ btLna] = %d %d %d %d\n", | |
1148 | shrink_rx_lpf, low_penalty_ra, limited_dig, bt_lna_constrain); | |
1149 | ||
1150 | halbtc8723b1ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); | |
1151 | } | |
1152 | ||
e9329bd3 | 1153 | static void halbtc8723b1ant_sw_mechanism2(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1154 | bool agc_table_shift, bool adc_backoff, |
1155 | bool sw_dac_swing, u32 dac_swing_lvl) | |
1156 | { | |
1157 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1158 | "[BTCoex], SM2[AgcT/ AdcB/ SwDacSwing(lvl)] = %d %d %d\n", | |
1159 | agc_table_shift, adc_backoff, sw_dac_swing); | |
1160 | } | |
1161 | ||
e9329bd3 | 1162 | static void halbtc8723b1ant_SetAntPath(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1163 | u8 ant_pos_type, bool init_hw_cfg, |
1164 | bool wifi_off) | |
1165 | { | |
1166 | struct btc_board_info *board_info = &btcoexist->board_info; | |
1167 | u32 fw_ver = 0, u32tmp = 0; | |
1168 | bool pg_ext_switch = false; | |
1169 | bool use_ext_switch = false; | |
1170 | u8 h2c_parameter[2] = {0}; | |
1171 | ||
1172 | btcoexist->btc_get(btcoexist, BTC_GET_BL_EXT_SWITCH, &pg_ext_switch); | |
1173 | /* [31:16]=fw ver, [15:0]=fw sub ver */ | |
1174 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); | |
1175 | ||
1176 | ||
1177 | if ((fw_ver < 0xc0000) || pg_ext_switch) | |
1178 | use_ext_switch = true; | |
1179 | ||
1180 | if (init_hw_cfg){ | |
1181 | /*BT select s0/s1 is controlled by WiFi */ | |
1182 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x1); | |
1183 | ||
1184 | /*Force GNT_BT to Normal */ | |
1185 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x0); | |
1186 | } else if (wifi_off) { | |
1187 | /*Force GNT_BT to High */ | |
1188 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x765, 0x18, 0x3); | |
1189 | /*BT select s0/s1 is controlled by BT */ | |
1190 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x67, 0x20, 0x0); | |
1191 | ||
1192 | /* 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL | |
1193 | * BT Vendor 0xac=0xf002 */ | |
1194 | u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
1195 | u32tmp &= ~BIT23; | |
1196 | u32tmp &= ~BIT24; | |
1197 | btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); | |
1198 | } | |
1199 | ||
1200 | if (use_ext_switch) { | |
1201 | if (init_hw_cfg) { | |
1202 | /* 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT */ | |
1203 | u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
1204 | u32tmp &= ~BIT23; | |
1205 | u32tmp |= BIT24; | |
1206 | btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); | |
1207 | ||
1208 | if (board_info->btdm_ant_pos == | |
1209 | BTC_ANTENNA_AT_MAIN_PORT) { | |
1210 | /* Main Ant to BT for IPS case 0x4c[23]=1 */ | |
1211 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1212 | 0x64, 0x1, | |
1213 | 0x1); | |
1214 | ||
1215 | /*tell firmware "no antenna inverse"*/ | |
1216 | h2c_parameter[0] = 0; | |
1217 | h2c_parameter[1] = 1; /*ext switch type*/ | |
1218 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, | |
1219 | h2c_parameter); | |
1220 | } else { | |
1221 | /*Aux Ant to BT for IPS case 0x4c[23]=1 */ | |
1222 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1223 | 0x64, 0x1, | |
1224 | 0x0); | |
1225 | ||
1226 | /*tell firmware "antenna inverse"*/ | |
1227 | h2c_parameter[0] = 1; | |
1228 | h2c_parameter[1] = 1; /*ext switch type*/ | |
1229 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, | |
1230 | h2c_parameter); | |
1231 | } | |
1232 | } | |
1233 | ||
1234 | /* fixed internal switch first*/ | |
1235 | /* fixed internal switch S1->WiFi, S0->BT*/ | |
1236 | if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) | |
1237 | btcoexist->btc_write_2byte(btcoexist, 0x948, 0x0); | |
1238 | else/* fixed internal switch S0->WiFi, S1->BT*/ | |
1239 | btcoexist->btc_write_2byte(btcoexist, 0x948, 0x280); | |
1240 | ||
1241 | /* ext switch setting */ | |
1242 | switch (ant_pos_type) { | |
1243 | case BTC_ANT_PATH_WIFI: | |
1244 | if (board_info->btdm_ant_pos == | |
1245 | BTC_ANTENNA_AT_MAIN_PORT) | |
1246 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1247 | 0x92c, 0x3, | |
1248 | 0x1); | |
1249 | else | |
1250 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1251 | 0x92c, 0x3, | |
1252 | 0x2); | |
1253 | break; | |
1254 | case BTC_ANT_PATH_BT: | |
1255 | if (board_info->btdm_ant_pos == | |
1256 | BTC_ANTENNA_AT_MAIN_PORT) | |
1257 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1258 | 0x92c, 0x3, | |
1259 | 0x2); | |
1260 | else | |
1261 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1262 | 0x92c, 0x3, | |
1263 | 0x1); | |
1264 | break; | |
1265 | default: | |
1266 | case BTC_ANT_PATH_PTA: | |
1267 | if (board_info->btdm_ant_pos == | |
1268 | BTC_ANTENNA_AT_MAIN_PORT) | |
1269 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1270 | 0x92c, 0x3, | |
1271 | 0x1); | |
1272 | else | |
1273 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1274 | 0x92c, 0x3, | |
1275 | 0x2); | |
1276 | break; | |
1277 | } | |
1278 | ||
1279 | } else { | |
1280 | if (init_hw_cfg) { | |
1281 | /* 0x4c[23]=1, 0x4c[24]=0 Antenna control by 0x64*/ | |
1282 | u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
1283 | u32tmp |= BIT23; | |
1284 | u32tmp &= ~BIT24; | |
1285 | btcoexist->btc_write_4byte(btcoexist, 0x4c, u32tmp); | |
1286 | ||
1287 | if (board_info->btdm_ant_pos == | |
1288 | BTC_ANTENNA_AT_MAIN_PORT) { | |
1289 | /*Main Ant to WiFi for IPS case 0x4c[23]=1*/ | |
1290 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1291 | 0x64, 0x1, | |
1292 | 0x0); | |
1293 | ||
1294 | /*tell firmware "no antenna inverse"*/ | |
1295 | h2c_parameter[0] = 0; | |
1296 | h2c_parameter[1] = 0; /*internal switch type*/ | |
1297 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, | |
1298 | h2c_parameter); | |
1299 | } else { | |
1300 | /*Aux Ant to BT for IPS case 0x4c[23]=1*/ | |
1301 | btcoexist->btc_write_1byte_bitmask(btcoexist, | |
1302 | 0x64, 0x1, | |
1303 | 0x1); | |
1304 | ||
1305 | /*tell firmware "antenna inverse"*/ | |
1306 | h2c_parameter[0] = 1; | |
1307 | h2c_parameter[1] = 0; /*internal switch type*/ | |
1308 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, | |
1309 | h2c_parameter); | |
1310 | } | |
1311 | } | |
1312 | ||
1313 | /* fixed external switch first*/ | |
1314 | /*Main->WiFi, Aux->BT*/ | |
1315 | if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) | |
1316 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, | |
1317 | 0x3, 0x1); | |
1318 | else/*Main->BT, Aux->WiFi */ | |
1319 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x92c, | |
1320 | 0x3, 0x2); | |
1321 | ||
1322 | /* internal switch setting*/ | |
1323 | switch (ant_pos_type) { | |
1324 | case BTC_ANT_PATH_WIFI: | |
1325 | if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) | |
1326 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1327 | 0x0); | |
1328 | else | |
1329 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1330 | 0x280); | |
1331 | break; | |
1332 | case BTC_ANT_PATH_BT: | |
1333 | if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) | |
1334 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1335 | 0x280); | |
1336 | else | |
1337 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1338 | 0x0); | |
1339 | break; | |
1340 | default: | |
1341 | case BTC_ANT_PATH_PTA: | |
1342 | if(board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) | |
1343 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1344 | 0x200); | |
1345 | else | |
1346 | btcoexist->btc_write_2byte(btcoexist, 0x948, | |
1347 | 0x80); | |
1348 | break; | |
1349 | } | |
1350 | } | |
1351 | } | |
1352 | ||
e9329bd3 KZ |
1353 | static void halbtc8723b1ant_ps_tdma(struct btc_coexist *btcoexist, |
1354 | bool force_exec, bool turn_on, u8 type) | |
3c05bedb GKH |
1355 | { |
1356 | bool wifi_busy = false; | |
1357 | u8 rssi_adjust_val = 0; | |
1358 | ||
1359 | coex_dm->cur_ps_tdma_on = turn_on; | |
1360 | coex_dm->cur_ps_tdma = type; | |
1361 | ||
1362 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
1363 | ||
1364 | if (!force_exec) { | |
1365 | if (coex_dm->cur_ps_tdma_on) | |
1366 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1367 | "[BTCoex], ******** TDMA(on, %d) *********\n", | |
1368 | coex_dm->cur_ps_tdma); | |
1369 | else | |
1370 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1371 | "[BTCoex], ******** TDMA(off, %d) ********\n", | |
1372 | coex_dm->cur_ps_tdma); | |
1373 | ||
1374 | ||
1375 | if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && | |
1376 | (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) | |
1377 | return; | |
1378 | } | |
1379 | if (turn_on) { | |
1380 | switch (type) { | |
1381 | default: | |
1382 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1a, | |
1383 | 0x1a, 0x0, 0x50); | |
1384 | break; | |
1385 | case 1: | |
1386 | if (wifi_busy) | |
1387 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1388 | 0x3a, 0x03, | |
1389 | 0x10, 0x50); | |
1390 | else | |
1391 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist,0x51, | |
1392 | 0x3a, 0x03, | |
1393 | 0x10, 0x51); | |
1394 | ||
1395 | rssi_adjust_val = 11; | |
1396 | break; | |
1397 | case 2: | |
1398 | if (wifi_busy) | |
1399 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1400 | 0x2b, 0x03, | |
1401 | 0x10, 0x50); | |
1402 | else | |
1403 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1404 | 0x2b, 0x03, | |
1405 | 0x10, 0x51); | |
1406 | rssi_adjust_val = 14; | |
1407 | break; | |
1408 | case 3: | |
1409 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1d, | |
1410 | 0x1d, 0x0, 0x52); | |
1411 | break; | |
1412 | case 4: | |
1413 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, | |
1414 | 0x3, 0x14, 0x0); | |
1415 | rssi_adjust_val = 17; | |
1416 | break; | |
1417 | case 5: | |
1418 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15, | |
1419 | 0x3, 0x11, 0x10); | |
1420 | break; | |
1421 | case 6: | |
1422 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x20, | |
1423 | 0x3, 0x11, 0x13); | |
1424 | break; | |
1425 | case 7: | |
1426 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xc, | |
1427 | 0x5, 0x0, 0x0); | |
1428 | break; | |
1429 | case 8: | |
1430 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, | |
1431 | 0x3, 0x10, 0x0); | |
1432 | break; | |
1433 | case 9: | |
1434 | if(wifi_busy) | |
1435 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1436 | 0x21, 0x3, | |
1437 | 0x10, 0x50); | |
1438 | else | |
1439 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1440 | 0x21, 0x3, | |
1441 | 0x10, 0x50); | |
1442 | rssi_adjust_val = 18; | |
1443 | break; | |
1444 | case 10: | |
1445 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, | |
1446 | 0xa, 0x0, 0x40); | |
1447 | break; | |
1448 | case 11: | |
1449 | if (wifi_busy) | |
1450 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1451 | 0x15, 0x03, | |
1452 | 0x10, 0x50); | |
1453 | else | |
1454 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, | |
1455 | 0x15, 0x03, | |
1456 | 0x10, 0x50); | |
1457 | rssi_adjust_val = 20; | |
1458 | break; | |
1459 | case 12: | |
1460 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x0a, | |
1461 | 0x0a, 0x0, 0x50); | |
1462 | break; | |
1463 | case 13: | |
1464 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x15, | |
1465 | 0x15, 0x0, 0x50); | |
1466 | break; | |
1467 | case 14: | |
1468 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21, | |
1469 | 0x3, 0x10, 0x52); | |
1470 | break; | |
1471 | case 15: | |
1472 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa, | |
1473 | 0x3, 0x8, 0x0); | |
1474 | break; | |
1475 | case 16: | |
1476 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x15, | |
1477 | 0x3, 0x10, 0x0); | |
1478 | rssi_adjust_val = 18; | |
1479 | break; | |
1480 | case 18: | |
1481 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x93, 0x25, | |
1482 | 0x3, 0x10, 0x0); | |
1483 | rssi_adjust_val = 14; | |
1484 | break; | |
1485 | case 20: | |
1486 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x35, | |
1487 | 0x03, 0x11, 0x10); | |
1488 | break; | |
1489 | case 21: | |
1490 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x15, | |
1491 | 0x03, 0x11, 0x10); | |
1492 | break; | |
1493 | case 22: | |
1494 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0x25, | |
1495 | 0x03, 0x11, 0x10); | |
1496 | break; | |
1497 | case 23: | |
1498 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, | |
1499 | 0x3, 0x31, 0x18); | |
1500 | rssi_adjust_val = 22; | |
1501 | break; | |
1502 | case 24: | |
1503 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x15, | |
1504 | 0x3, 0x31, 0x18); | |
1505 | rssi_adjust_val = 22; | |
1506 | break; | |
1507 | case 25: | |
1508 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, | |
1509 | 0x3, 0x31, 0x18); | |
1510 | rssi_adjust_val = 22; | |
1511 | break; | |
1512 | case 26: | |
1513 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0xa, | |
1514 | 0x3, 0x31, 0x18); | |
1515 | rssi_adjust_val = 22; | |
1516 | break; | |
1517 | case 27: | |
1518 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xe3, 0x25, | |
1519 | 0x3, 0x31, 0x98); | |
1520 | rssi_adjust_val = 22; | |
1521 | break; | |
1522 | case 28: | |
1523 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x69, 0x25, | |
1524 | 0x3, 0x31, 0x0); | |
1525 | break; | |
1526 | case 29: | |
1527 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xab, 0x1a, | |
1528 | 0x1a, 0x1, 0x10); | |
1529 | break; | |
1530 | case 30: | |
1531 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x14, | |
1532 | 0x3, 0x10, 0x50); | |
1533 | break; | |
1534 | case 31: | |
1535 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x1a, | |
1536 | 0x1a, 0, 0x58); | |
1537 | break; | |
1538 | case 32: | |
1539 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x61, 0xa, | |
1540 | 0x3, 0x10, 0x0); | |
1541 | break; | |
1542 | case 33: | |
1543 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xa3, 0x25, | |
1544 | 0x3, 0x30, 0x90); | |
1545 | break; | |
1546 | case 34: | |
1547 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x53, 0x1a, | |
1548 | 0x1a, 0x0, 0x10); | |
1549 | break; | |
1550 | case 35: | |
1551 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x63, 0x1a, | |
1552 | 0x1a, 0x0, 0x10); | |
1553 | break; | |
1554 | case 36: | |
1555 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0xd3, 0x12, | |
1556 | 0x3, 0x14, 0x50); | |
1557 | break; | |
1558 | /* SoftAP only with no sta associated,BT disable , | |
1559 | * TDMA mode for power saving | |
1560 | * here softap mode screen off will cost 70-80mA for phone */ | |
1561 | case 40: | |
1562 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x23, 0x18, | |
1563 | 0x00, 0x10, 0x24); | |
1564 | break; | |
1565 | } | |
1566 | } else { | |
1567 | switch (type) { | |
1568 | case 8: /*PTA Control */ | |
1569 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x8, 0x0, | |
1570 | 0x0, 0x0, 0x0); | |
1571 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_PTA, | |
1572 | false, false); | |
1573 | break; | |
1574 | case 0: | |
1575 | default: /*Software control, Antenna at BT side */ | |
1576 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, | |
1577 | 0x0, 0x0, 0x0); | |
1578 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT, | |
1579 | false, false); | |
1580 | break; | |
1581 | case 9: /*Software control, Antenna at WiFi side */ | |
1582 | halbtc8723b1ant_set_fw_ps_tdma(btcoexist, 0x0, 0x0, | |
1583 | 0x0, 0x0, 0x0); | |
1584 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_WIFI, | |
1585 | false, false); | |
1586 | break; | |
1587 | } | |
1588 | } | |
1589 | rssi_adjust_val = 0; | |
1590 | btcoexist->btc_set(btcoexist, | |
1591 | BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, | |
1592 | &rssi_adjust_val); | |
1593 | ||
1594 | /* update pre state */ | |
1595 | coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; | |
1596 | coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; | |
1597 | } | |
1598 | ||
e9329bd3 | 1599 | static bool halbtc8723b1ant_is_common_action(struct btc_coexist *btcoexist) |
3c05bedb GKH |
1600 | { |
1601 | bool commom = false, wifi_connected = false; | |
1602 | bool wifi_busy = false; | |
1603 | ||
1604 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
1605 | &wifi_connected); | |
1606 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
1607 | ||
1608 | if (!wifi_connected && | |
1609 | BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status) { | |
1610 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1611 | "[BTCoex], Wifi non connected-idle + " | |
1612 | "BT non connected-idle!!\n"); | |
1613 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1614 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1615 | ||
1616 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
1617 | false, false); | |
1618 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
1619 | false, 0x18); | |
1620 | ||
1621 | commom = true; | |
1622 | } else if (wifi_connected && | |
1623 | (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == | |
1624 | coex_dm->bt_status)) { | |
1625 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1626 | "[BTCoex], Wifi connected + " | |
1627 | "BT non connected-idle!!\n"); | |
1628 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1629 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1630 | ||
1631 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
1632 | false, false); | |
1633 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
1634 | false, 0x18); | |
1635 | ||
1636 | commom = true; | |
1637 | } else if (!wifi_connected && | |
1638 | (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == | |
1639 | coex_dm->bt_status)) { | |
1640 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1641 | "[BTCoex], Wifi non connected-idle + " | |
1642 | "BT connected-idle!!\n"); | |
1643 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1644 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1645 | ||
1646 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
1647 | false, false); | |
1648 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
1649 | false, 0x18); | |
1650 | ||
1651 | commom = true; | |
1652 | } else if (wifi_connected && | |
1653 | (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == | |
1654 | coex_dm->bt_status)) { | |
1655 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1656 | "[BTCoex], Wifi connected + BT connected-idle!!\n"); | |
1657 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1658 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1659 | ||
1660 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
1661 | false, false); | |
1662 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
1663 | false, 0x18); | |
1664 | ||
1665 | commom = true; | |
1666 | } else if (!wifi_connected && | |
1667 | (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != | |
1668 | coex_dm->bt_status)) { | |
1669 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1670 | ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); | |
1671 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1672 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1673 | ||
1674 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
1675 | false, false); | |
1676 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
1677 | false, 0x18); | |
1678 | ||
1679 | commom = true; | |
1680 | } else { | |
1681 | if (wifi_busy) | |
1682 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1683 | "[BTCoex], Wifi Connected-Busy" | |
1684 | " + BT Busy!!\n"); | |
1685 | else | |
1686 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1687 | "[BTCoex], Wifi Connected-Idle" | |
1688 | " + BT Busy!!\n"); | |
1689 | ||
1690 | commom = false; | |
1691 | } | |
1692 | ||
1693 | return commom; | |
1694 | } | |
1695 | ||
1696 | ||
e9329bd3 KZ |
1697 | static void halbtc8723b1ant_tdma_duration_adjust_for_acl( |
1698 | struct btc_coexist *btcoexist, | |
1699 | u8 wifi_status) | |
3c05bedb GKH |
1700 | { |
1701 | static s32 up, dn, m, n, wait_count; | |
1702 | /* 0: no change, +1: increase WiFi duration, | |
1703 | * -1: decrease WiFi duration */ | |
1704 | s32 result; | |
1705 | u8 retry_count = 0, bt_info_ext; | |
1706 | static bool pre_wifi_busy = false; | |
1707 | bool wifi_busy = false; | |
1708 | ||
1709 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
1710 | "[BTCoex], TdmaDurationAdjustForAcl()\n"); | |
1711 | ||
1712 | if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifi_status) | |
1713 | wifi_busy = true; | |
1714 | else | |
1715 | wifi_busy = false; | |
1716 | ||
1717 | if ((BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == | |
1718 | wifi_status) || | |
1719 | (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifi_status) || | |
1720 | (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifi_status)) { | |
1721 | if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && | |
1722 | coex_dm->cur_ps_tdma != 3 && coex_dm->cur_ps_tdma != 9) { | |
1723 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1724 | true, 9); | |
1725 | coex_dm->ps_tdma_du_adj_type = 9; | |
1726 | ||
1727 | up = 0; | |
1728 | dn = 0; | |
1729 | m = 1; | |
1730 | n = 3; | |
1731 | result = 0; | |
1732 | wait_count = 0; | |
1733 | } | |
1734 | return; | |
1735 | } | |
1736 | ||
1737 | if (!coex_dm->auto_tdma_adjust) { | |
1738 | coex_dm->auto_tdma_adjust = true; | |
1739 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1740 | "[BTCoex], first run TdmaDurationAdjust()!!\n"); | |
1741 | ||
1742 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1743 | coex_dm->ps_tdma_du_adj_type = 2; | |
1744 | ||
1745 | up = 0; | |
1746 | dn = 0; | |
1747 | m = 1; | |
1748 | n = 3; | |
1749 | result = 0; | |
1750 | wait_count = 0; | |
1751 | } else { | |
fc4d82c0 | 1752 | /*acquire the BT TRx retry count from BT_Info byte2 */ |
3c05bedb GKH |
1753 | retry_count = coex_sta->bt_retry_cnt; |
1754 | bt_info_ext = coex_sta->bt_info_ext; | |
1755 | result = 0; | |
1756 | wait_count++; | |
1757 | /* no retry in the last 2-second duration */ | |
1758 | if (retry_count == 0) { | |
1759 | up++; | |
1760 | dn--; | |
1761 | ||
1762 | if (dn <= 0) | |
1763 | dn = 0; | |
1764 | ||
1765 | if (up >= n) { | |
1766 | wait_count = 0; | |
1767 | n = 3; | |
1768 | up = 0; | |
1769 | dn = 0; | |
1770 | result = 1; | |
1771 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1772 | ALGO_TRACE_FW_DETAIL, | |
1773 | "[BTCoex], Increase wifi " | |
1774 | "duration!!\n"); | |
1775 | } | |
1776 | } else if (retry_count <= 3) { | |
1777 | up--; | |
1778 | dn++; | |
1779 | ||
1780 | if (up <= 0) | |
1781 | up = 0; | |
1782 | ||
1783 | if (dn == 2) { | |
1784 | if (wait_count <= 2) | |
1785 | m++; | |
1786 | else | |
1787 | m = 1; | |
1788 | ||
1789 | if (m >= 20) | |
1790 | m = 20; | |
1791 | ||
1792 | n = 3 * m; | |
1793 | up = 0; | |
1794 | dn = 0; | |
1795 | wait_count = 0; | |
1796 | result = -1; | |
1797 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1798 | ALGO_TRACE_FW_DETAIL, | |
1799 | "[BTCoex], Decrease wifi duration" | |
1800 | " for retryCounter<3!!\n"); | |
1801 | } | |
1802 | } else { | |
1803 | if (wait_count == 1) | |
1804 | m++; | |
1805 | else | |
1806 | m = 1; | |
1807 | ||
1808 | if (m >= 20) | |
1809 | m = 20; | |
1810 | ||
1811 | n = 3 * m; | |
1812 | up = 0; | |
1813 | dn = 0; | |
1814 | wait_count = 0; | |
1815 | result = -1; | |
1816 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1817 | "[BTCoex], Decrease wifi duration" | |
1818 | " for retryCounter>3!!\n"); | |
1819 | } | |
1820 | ||
1821 | if (result == -1) { | |
1822 | if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && | |
1823 | ((coex_dm->cur_ps_tdma == 1) || | |
1824 | (coex_dm->cur_ps_tdma == 2))) { | |
1825 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1826 | true, 9); | |
1827 | coex_dm->ps_tdma_du_adj_type = 9; | |
1828 | } else if (coex_dm->cur_ps_tdma == 1) { | |
1829 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1830 | true, 2); | |
1831 | coex_dm->ps_tdma_du_adj_type = 2; | |
1832 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1833 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1834 | true, 9); | |
1835 | coex_dm->ps_tdma_du_adj_type = 9; | |
1836 | } else if (coex_dm->cur_ps_tdma == 9) { | |
1837 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1838 | true, 11); | |
1839 | coex_dm->ps_tdma_du_adj_type = 11; | |
1840 | } | |
1841 | } else if(result == 1) { | |
1842 | if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(bt_info_ext)) && | |
1843 | ((coex_dm->cur_ps_tdma == 1) || | |
1844 | (coex_dm->cur_ps_tdma == 2))) { | |
1845 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1846 | true, 9); | |
1847 | coex_dm->ps_tdma_du_adj_type = 9; | |
1848 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1849 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1850 | true, 9); | |
1851 | coex_dm->ps_tdma_du_adj_type = 9; | |
1852 | } else if (coex_dm->cur_ps_tdma == 9) { | |
1853 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1854 | true, 2); | |
1855 | coex_dm->ps_tdma_du_adj_type = 2; | |
1856 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1857 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1858 | true, 1); | |
1859 | coex_dm->ps_tdma_du_adj_type = 1; | |
1860 | } | |
1861 | } else { /*no change */ | |
1862 | /*if busy / idle change */ | |
1863 | if (wifi_busy != pre_wifi_busy) { | |
1864 | pre_wifi_busy = wifi_busy; | |
1865 | halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, | |
1866 | true, | |
1867 | coex_dm->cur_ps_tdma); | |
1868 | } | |
1869 | ||
1870 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1871 | "[BTCoex],********* TDMA(on, %d) ********\n", | |
1872 | coex_dm->cur_ps_tdma); | |
1873 | } | |
1874 | ||
1875 | if (coex_dm->cur_ps_tdma != 1 && coex_dm->cur_ps_tdma != 2 && | |
1876 | coex_dm->cur_ps_tdma != 9 && coex_dm->cur_ps_tdma != 11) { | |
1877 | /* recover to previous adjust type */ | |
1878 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, | |
1879 | coex_dm->ps_tdma_du_adj_type); | |
1880 | } | |
1881 | } | |
1882 | } | |
1883 | ||
e9329bd3 KZ |
1884 | static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState( |
1885 | struct btc_coexist *btcoexist, bool new_ps_state) | |
3c05bedb GKH |
1886 | { |
1887 | u8 lps_mode = 0x0; | |
1888 | ||
1889 | btcoexist->btc_get(btcoexist, BTC_GET_U1_LPS_MODE, &lps_mode); | |
1890 | ||
1891 | if (lps_mode) { /* already under LPS state */ | |
1892 | if (new_ps_state) { | |
1893 | /* keep state under LPS, do nothing. */ | |
1894 | } else { | |
1895 | /* will leave LPS state, turn off psTdma first */ | |
1896 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1897 | false, 0); | |
1898 | } | |
1899 | } else { /* NO PS state */ | |
1900 | if (new_ps_state) { | |
1901 | /* will enter LPS state, turn off psTdma first */ | |
1902 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
1903 | false, 0); | |
1904 | } else { | |
1905 | /* keep state under NO PS state, do nothing. */ | |
1906 | } | |
1907 | } | |
1908 | } | |
1909 | ||
e9329bd3 | 1910 | static void halbtc8723b1ant_power_save_state(struct btc_coexist *btcoexist, |
3c05bedb GKH |
1911 | u8 ps_type, u8 lps_val, |
1912 | u8 rpwm_val) | |
1913 | { | |
1914 | bool low_pwr_disable = false; | |
1915 | ||
1916 | switch (ps_type) { | |
1917 | case BTC_PS_WIFI_NATIVE: | |
1918 | /* recover to original 32k low power setting */ | |
1919 | low_pwr_disable = false; | |
1920 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1921 | &low_pwr_disable); | |
1922 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, NULL); | |
1923 | break; | |
1924 | case BTC_PS_LPS_ON: | |
1925 | halbtc8723b1ant_PsTdmaCheckForPowerSaveState(btcoexist, true); | |
1926 | halbtc8723b1ant_LpsRpwm(btcoexist, NORMAL_EXEC, lps_val, | |
1927 | rpwm_val); | |
1928 | /* when coex force to enter LPS, do not enter 32k low power. */ | |
1929 | low_pwr_disable = true; | |
1930 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1931 | &low_pwr_disable); | |
1932 | /* power save must executed before psTdma. */ | |
1933 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_ENTER_LPS, NULL); | |
1934 | break; | |
1935 | case BTC_PS_LPS_OFF: | |
1936 | halbtc8723b1ant_PsTdmaCheckForPowerSaveState(btcoexist, false); | |
1937 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, NULL); | |
1938 | break; | |
1939 | default: | |
1940 | break; | |
1941 | } | |
1942 | } | |
1943 | ||
f2591796 | 1944 | #if (BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) |
e9329bd3 | 1945 | static void halbtc8723b1ant_action_wifi_only(struct btc_coexist *btcoexist) |
3c05bedb GKH |
1946 | { |
1947 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); | |
1948 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9); | |
1949 | } | |
1950 | ||
e9329bd3 KZ |
1951 | static void halbtc8723b1ant_monitor_bt_enable_disable( |
1952 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
1953 | { |
1954 | static bool pre_bt_disabled = false; | |
1955 | static u32 bt_disable_cnt = 0; | |
1956 | bool bt_active = true, bt_disabled = false; | |
1957 | ||
1958 | /* This function check if bt is disabled */ | |
1959 | ||
1960 | if (coex_sta->high_priority_tx == 0 && | |
1961 | coex_sta->high_priority_rx == 0 && | |
1962 | coex_sta->low_priority_tx == 0 && | |
1963 | coex_sta->low_priority_rx == 0) | |
1964 | bt_active = false; | |
1965 | ||
1966 | if (coex_sta->high_priority_tx == 0xffff && | |
1967 | coex_sta->high_priority_rx == 0xffff && | |
1968 | coex_sta->low_priority_tx == 0xffff && | |
1969 | coex_sta->low_priority_rx == 0xffff) | |
1970 | bt_active = false; | |
1971 | ||
1972 | if (bt_active) { | |
1973 | bt_disable_cnt = 0; | |
1974 | bt_disabled = false; | |
1975 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, | |
1976 | &bt_disabled); | |
1977 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1978 | "[BTCoex], BT is enabled !!\n"); | |
1979 | } else { | |
1980 | bt_disable_cnt++; | |
1981 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1982 | "[BTCoex], bt all counters=0, %d times!!\n", | |
1983 | bt_disable_cnt); | |
1984 | if (bt_disable_cnt >= 2) { | |
1985 | bt_disabled = true; | |
1986 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, | |
1987 | &bt_disabled); | |
1988 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1989 | "[BTCoex], BT is disabled !!\n"); | |
1990 | halbtc8723b1ant_action_wifi_only(btcoexist); | |
1991 | } | |
1992 | } | |
1993 | if (pre_bt_disabled != bt_disabled) { | |
1994 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
1995 | "[BTCoex], BT is from %s to %s!!\n", | |
1996 | (pre_bt_disabled ? "disabled" : "enabled"), | |
1997 | (bt_disabled ? "disabled" : "enabled")); | |
1998 | pre_bt_disabled = bt_disabled; | |
1999 | if (!bt_disabled) { | |
2000 | } else { | |
2001 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_LEAVE_LPS, | |
2002 | NULL); | |
2003 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_NORMAL_LPS, | |
2004 | NULL); | |
2005 | } | |
2006 | } | |
2007 | } | |
f2591796 | 2008 | #endif |
3c05bedb GKH |
2009 | |
2010 | /*************************************************** | |
2011 | * | |
2012 | * Software Coex Mechanism start | |
2013 | * | |
2014 | ***************************************************/ | |
2015 | /* SCO only or SCO+PAN(HS) */ | |
e9329bd3 | 2016 | static void halbtc8723b1ant_action_sco(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2017 | { |
2018 | u8 wifi_rssi_state; | |
2019 | u32 wifi_bw; | |
2020 | ||
2021 | wifi_rssi_state = | |
2022 | halbtc8723b1ant_wifi_rssi_state(btcoexist, 0, 2, 25, 0); | |
2023 | ||
2024 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4); | |
2025 | ||
2026 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2027 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2028 | else | |
2029 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2030 | ||
2031 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2032 | ||
2033 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2034 | /* sw mechanism */ | |
2035 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2036 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2037 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2038 | false, false); | |
2039 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2040 | false, 0x18); | |
2041 | } else { | |
2042 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2043 | false, false); | |
2044 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2045 | false, 0x18); | |
2046 | } | |
2047 | } else { | |
2048 | /* sw mechanism */ | |
2049 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2050 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2051 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2052 | false, false); | |
2053 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2054 | false, 0x18); | |
2055 | } else { | |
2056 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2057 | false, false); | |
2058 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2059 | false, 0x18); | |
2060 | } | |
2061 | } | |
2062 | } | |
2063 | ||
2064 | ||
e9329bd3 | 2065 | static void halbtc8723b1ant_action_hid(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2066 | { |
2067 | u8 wifi_rssi_state, bt_rssi_state; | |
2068 | u32 wifi_bw; | |
2069 | ||
2070 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2071 | 0, 2, 25, 0); | |
2072 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2073 | ||
2074 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2075 | ||
2076 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2077 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2078 | else | |
2079 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2080 | ||
2081 | btcoexist->btc_get(btcoexist, | |
2082 | BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2083 | ||
2084 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2085 | /* sw mechanism */ | |
2086 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2087 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2088 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2089 | false, false); | |
2090 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2091 | false, 0x18); | |
2092 | } else { | |
2093 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2094 | false, false); | |
2095 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2096 | false, 0x18); | |
2097 | } | |
2098 | } else { | |
2099 | /* sw mechanism */ | |
2100 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2101 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2102 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2103 | false, false); | |
2104 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2105 | false, 0x18); | |
2106 | } else { | |
2107 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2108 | false, false); | |
2109 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2110 | false, 0x18); | |
2111 | } | |
2112 | } | |
2113 | } | |
2114 | ||
2115 | /*A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ | |
e9329bd3 | 2116 | static void halbtc8723b1ant_action_a2dp(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2117 | { |
2118 | u8 wifi_rssi_state, bt_rssi_state; | |
2119 | u32 wifi_bw; | |
2120 | ||
2121 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2122 | 0, 2, 25, 0); | |
2123 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2124 | ||
2125 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2126 | ||
2127 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2128 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2129 | else | |
2130 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2131 | ||
2132 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2133 | ||
2134 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2135 | /* sw mechanism */ | |
2136 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2137 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2138 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2139 | false, false); | |
2140 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2141 | false, 0x18); | |
2142 | } else { | |
2143 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2144 | false, false); | |
2145 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2146 | false, 0x18); | |
2147 | } | |
2148 | } else { | |
2149 | /* sw mechanism */ | |
2150 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2151 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2152 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2153 | false, false); | |
2154 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2155 | false, 0x18); | |
2156 | } else { | |
2157 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2158 | false, false); | |
2159 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2160 | false, 0x18); | |
2161 | } | |
2162 | } | |
2163 | } | |
2164 | ||
e9329bd3 | 2165 | static void halbtc8723b1ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2166 | { |
2167 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2168 | u32 wifi_bw; | |
2169 | ||
2170 | bt_info_ext = coex_sta->bt_info_ext; | |
2171 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2172 | 0, 2, 25, 0); | |
2173 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2174 | ||
2175 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2176 | ||
2177 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2178 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2179 | else | |
2180 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2181 | ||
2182 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2183 | ||
2184 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2185 | /* sw mechanism */ | |
2186 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2187 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2188 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2189 | false, false); | |
2190 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2191 | false, 0x18); | |
2192 | } else { | |
2193 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2194 | false, false); | |
2195 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2196 | false, 0x18); | |
2197 | } | |
2198 | } else { | |
2199 | /* sw mechanism */ | |
2200 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2201 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2202 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2203 | false, false); | |
2204 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2205 | false, 0x18); | |
2206 | } else { | |
2207 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2208 | false, false); | |
2209 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2210 | false, 0x18); | |
2211 | } | |
2212 | } | |
2213 | } | |
2214 | ||
e9329bd3 | 2215 | static void halbtc8723b1ant_action_pan_edr(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2216 | { |
2217 | u8 wifi_rssi_state, bt_rssi_state; | |
2218 | u32 wifi_bw; | |
2219 | ||
2220 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2221 | 0, 2, 25, 0); | |
2222 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2223 | ||
2224 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2225 | ||
2226 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2227 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2228 | else | |
2229 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2230 | ||
2231 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2232 | ||
2233 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2234 | /* sw mechanism */ | |
2235 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2236 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2237 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2238 | false, false); | |
2239 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2240 | false, 0x18); | |
2241 | } else { | |
2242 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2243 | false, false); | |
2244 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2245 | false, 0x18); | |
2246 | } | |
2247 | } else { | |
2248 | /* sw mechanism */ | |
2249 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2250 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2251 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2252 | false, false); | |
2253 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2254 | false, 0x18); | |
2255 | } else { | |
2256 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2257 | false, false); | |
2258 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2259 | false, 0x18); | |
2260 | } | |
2261 | } | |
2262 | } | |
2263 | ||
2264 | ||
2265 | /* PAN(HS) only */ | |
e9329bd3 | 2266 | static void halbtc8723b1ant_action_pan_hs(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2267 | { |
2268 | u8 wifi_rssi_state, bt_rssi_state; | |
2269 | u32 wifi_bw; | |
2270 | ||
2271 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2272 | 0, 2, 25, 0); | |
2273 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2274 | ||
2275 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2276 | ||
2277 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2278 | ||
2279 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2280 | /* fw mechanism */ | |
2281 | if((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2282 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2283 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2284 | false); | |
2285 | else | |
2286 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2287 | false); | |
2288 | ||
2289 | /* sw mechanism */ | |
2290 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2291 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2292 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2293 | false, false); | |
2294 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2295 | false, 0x18); | |
2296 | } else { | |
2297 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2298 | false, false); | |
2299 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2300 | false, 0x18); | |
2301 | } | |
2302 | } else { | |
2303 | /* fw mechanism */ | |
2304 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2305 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2306 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2307 | false); | |
2308 | else | |
2309 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2310 | false); | |
2311 | ||
2312 | /* sw mechanism */ | |
2313 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2314 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2315 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2316 | false, false); | |
2317 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2318 | false, 0x18); | |
2319 | } else { | |
2320 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2321 | false, false); | |
2322 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2323 | false, 0x18); | |
2324 | } | |
2325 | } | |
2326 | } | |
2327 | ||
2328 | /*PAN(EDR)+A2DP */ | |
e9329bd3 | 2329 | static void halbtc8723b1ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2330 | { |
2331 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2332 | u32 wifi_bw; | |
2333 | ||
2334 | bt_info_ext = coex_sta->bt_info_ext; | |
2335 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2336 | 0, 2, 25, 0); | |
2337 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2338 | ||
2339 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2340 | ||
2341 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2342 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2343 | else | |
2344 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2345 | ||
2346 | btcoexist->btc_get(btcoexist, | |
2347 | BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2348 | ||
2349 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2350 | /* sw mechanism */ | |
2351 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2352 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2353 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2354 | false, false); | |
2355 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2356 | false, 0x18); | |
2357 | } else { | |
2358 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2359 | false, false); | |
2360 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2361 | false, 0x18); | |
2362 | } | |
2363 | } else { | |
2364 | /* sw mechanism */ | |
2365 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2366 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2367 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2368 | false, false); | |
2369 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2370 | false, 0x18); | |
2371 | } else { | |
2372 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, | |
2373 | false, false); | |
2374 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2375 | false, 0x18); | |
2376 | } | |
2377 | } | |
2378 | } | |
2379 | ||
e9329bd3 | 2380 | static void halbtc8723b1ant_action_pan_edr_hid(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2381 | { |
2382 | u8 wifi_rssi_state, bt_rssi_state; | |
2383 | u32 wifi_bw; | |
2384 | ||
2385 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2386 | 0, 2, 25, 0); | |
2387 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2388 | ||
2389 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2390 | ||
2391 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2392 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2393 | else | |
2394 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2395 | ||
2396 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2397 | ||
2398 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2399 | /* sw mechanism */ | |
2400 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2401 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2402 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2403 | false, false); | |
2404 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2405 | false, 0x18); | |
2406 | } else { | |
2407 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2408 | false, false); | |
2409 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2410 | false, 0x18); | |
2411 | } | |
2412 | } else { | |
2413 | /* sw mechanism */ | |
2414 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2415 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2416 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2417 | false, false); | |
2418 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2419 | false, 0x18); | |
2420 | } else { | |
2421 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2422 | false, false); | |
2423 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2424 | false, 0x18); | |
2425 | } | |
2426 | } | |
2427 | } | |
2428 | ||
2429 | /* HID+A2DP+PAN(EDR) */ | |
e9329bd3 KZ |
2430 | static void halbtc8723b1ant_action_hid_a2dp_pan_edr( |
2431 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
2432 | { |
2433 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2434 | u32 wifi_bw; | |
2435 | ||
2436 | bt_info_ext = coex_sta->bt_info_ext; | |
2437 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2438 | 0, 2, 25, 0); | |
2439 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2440 | ||
2441 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2442 | ||
2443 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2444 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2445 | else | |
2446 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2447 | ||
2448 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2449 | ||
2450 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2451 | /* sw mechanism */ | |
2452 | if((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2453 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2454 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2455 | false, false); | |
2456 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2457 | false, 0x18); | |
2458 | } else { | |
2459 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2460 | false, false); | |
2461 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2462 | false, 0x18); | |
2463 | } | |
2464 | } else { | |
2465 | /* sw mechanism */ | |
2466 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2467 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2468 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2469 | false, false); | |
2470 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2471 | false, 0x18); | |
2472 | } else { | |
2473 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2474 | false, false); | |
2475 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2476 | false, 0x18); | |
2477 | } | |
2478 | } | |
2479 | } | |
2480 | ||
e9329bd3 | 2481 | static void halbtc8723b1ant_action_hid_a2dp(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2482 | { |
2483 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2484 | u32 wifi_bw; | |
2485 | ||
2486 | bt_info_ext = coex_sta->bt_info_ext; | |
2487 | wifi_rssi_state = halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2488 | 0, 2, 25, 0); | |
2489 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 50, 0); | |
2490 | ||
2491 | if (halbtc8723b1ant_need_to_dec_bt_pwr(btcoexist)) | |
2492 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2493 | else | |
2494 | halbtc8723b1ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2495 | ||
2496 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2497 | ||
2498 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2499 | /* sw mechanism */ | |
2500 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2501 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2502 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2503 | false, false); | |
2504 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2505 | false, 0x18); | |
2506 | } else { | |
2507 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2508 | false, false); | |
2509 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2510 | false, 0x18); | |
2511 | } | |
2512 | } else { | |
2513 | /* sw mechanism */ | |
2514 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2515 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2516 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2517 | false, false); | |
2518 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2519 | false, 0x18); | |
2520 | } else { | |
2521 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, true, | |
2522 | false, false); | |
2523 | halbtc8723b1ant_sw_mechanism2(btcoexist, false, false, | |
2524 | false, 0x18); | |
2525 | } | |
2526 | } | |
2527 | } | |
2528 | ||
2529 | /***************************************************** | |
2530 | * | |
2531 | * Non-Software Coex Mechanism start | |
2532 | * | |
2533 | *****************************************************/ | |
e9329bd3 | 2534 | static void halbtc8723b1ant_action_hs(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2535 | { |
2536 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
2537 | halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 2); | |
2538 | } | |
2539 | ||
e9329bd3 | 2540 | static void halbtc8723b1ant_action_bt_inquiry(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2541 | { |
2542 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2543 | bool wifi_connected = false, ap_enable = false; | |
2544 | ||
2545 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, | |
2546 | &ap_enable); | |
2547 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
2548 | &wifi_connected); | |
2549 | ||
2550 | if (!wifi_connected) { | |
2551 | halbtc8723b1ant_power_save_state(btcoexist, | |
2552 | BTC_PS_WIFI_NATIVE, 0x0, 0x0); | |
2553 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
2554 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2555 | } else if (bt_link_info->sco_exist || bt_link_info->hid_only) { | |
2556 | /* SCO/HID-only busy */ | |
2557 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2558 | 0x0, 0x0); | |
2559 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32); | |
2560 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2561 | } else { | |
2562 | if (ap_enable) | |
2563 | halbtc8723b1ant_power_save_state(btcoexist, | |
2564 | BTC_PS_WIFI_NATIVE, | |
2565 | 0x0, 0x0); | |
2566 | else | |
2567 | halbtc8723b1ant_power_save_state(btcoexist, | |
2568 | BTC_PS_LPS_ON, | |
2569 | 0x50, 0x4); | |
2570 | ||
2571 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30); | |
2572 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2573 | } | |
2574 | } | |
2575 | ||
e9329bd3 KZ |
2576 | static void halbtc8723b1ant_action_bt_sco_hid_only_busy( |
2577 | struct btc_coexist *btcoexist, | |
2578 | u8 wifi_status) | |
3c05bedb GKH |
2579 | { |
2580 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2581 | bool wifi_connected = false; | |
2582 | ||
2583 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
2584 | &wifi_connected); | |
2585 | ||
2586 | /* tdma and coex table */ | |
2587 | ||
2588 | if (bt_link_info->sco_exist) { | |
2589 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
2590 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2); | |
2591 | } else { /* HID */ | |
2592 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
2593 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 5); | |
2594 | } | |
2595 | } | |
2596 | ||
e9329bd3 | 2597 | static void halbtc8723b1ant_action_wifi_connected_bt_acl_busy( |
3c05bedb GKH |
2598 | struct btc_coexist *btcoexist, |
2599 | u8 wifi_status) | |
2600 | { | |
2601 | u8 bt_rssi_state; | |
2602 | ||
2603 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2604 | bt_rssi_state = halbtc8723b1ant_bt_rssi_state(2, 28, 0); | |
2605 | ||
2606 | if (bt_link_info->hid_only) { /*HID */ | |
2607 | halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist, | |
2608 | wifi_status); | |
2609 | coex_dm->auto_tdma_adjust = false; | |
2610 | return; | |
2611 | } else if (bt_link_info->a2dp_only) { /*A2DP */ | |
2612 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2613 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2614 | halbtc8723b1ant_tdma_duration_adjust_for_acl(btcoexist, | |
2615 | wifi_status); | |
2616 | } else { /*for low BT RSSI */ | |
2617 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2618 | true, 11); | |
2619 | coex_dm->auto_tdma_adjust = false; | |
2620 | } | |
2621 | ||
2622 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2623 | } else if (bt_link_info->hid_exist && | |
2624 | bt_link_info->a2dp_exist) { /*HID+A2DP */ | |
2625 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2626 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2627 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2628 | true, 14); | |
2629 | coex_dm->auto_tdma_adjust = false; | |
2630 | } else { /*for low BT RSSI*/ | |
2631 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2632 | true, 14); | |
2633 | coex_dm->auto_tdma_adjust = false; | |
2634 | } | |
2635 | ||
2636 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6); | |
2637 | /*PAN(OPP,FTP), HID+PAN(OPP,FTP) */ | |
2638 | } else if (bt_link_info->pan_only || | |
2639 | (bt_link_info->hid_exist && bt_link_info->pan_exist)) { | |
2640 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
2641 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 6); | |
2642 | coex_dm->auto_tdma_adjust = false; | |
2643 | /*A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP)*/ | |
2644 | } else if ((bt_link_info->a2dp_exist && bt_link_info->pan_exist) || | |
2645 | (bt_link_info->hid_exist && bt_link_info->a2dp_exist && | |
2646 | bt_link_info->pan_exist)) { | |
2647 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
2648 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2649 | coex_dm->auto_tdma_adjust = false; | |
2650 | } else { | |
2651 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
2652 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2653 | coex_dm->auto_tdma_adjust = false; | |
2654 | } | |
2655 | } | |
2656 | ||
e9329bd3 KZ |
2657 | static void halbtc8723b1ant_action_wifi_not_connected( |
2658 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
2659 | { |
2660 | /* power save state */ | |
2661 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2662 | 0x0, 0x0); | |
2663 | ||
2664 | /* tdma and coex table */ | |
2665 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); | |
2666 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0); | |
2667 | } | |
2668 | ||
e9329bd3 | 2669 | static void halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan( |
3c05bedb GKH |
2670 | struct btc_coexist *btcoexist) |
2671 | { | |
2672 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2673 | 0x0, 0x0); | |
2674 | ||
2675 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22); | |
2676 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2677 | } | |
2678 | ||
e9329bd3 KZ |
2679 | static void halbtc8723b1ant_ActionWifiConnectedScan( |
2680 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
2681 | { |
2682 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2683 | ||
2684 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2685 | 0x0, 0x0); | |
2686 | ||
2687 | /* tdma and coex table */ | |
2688 | if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { | |
2689 | if (bt_link_info->a2dp_exist && | |
2690 | bt_link_info->pan_exist) { | |
2691 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2692 | true, 22); | |
2693 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
2694 | NORMAL_EXEC, 1); | |
2695 | } else { | |
2696 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); | |
2697 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2698 | } | |
2699 | } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || | |
2700 | (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == | |
2701 | coex_dm->bt_status)) { | |
2702 | halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist, | |
2703 | BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); | |
2704 | } else { | |
2705 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); | |
2706 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2707 | } | |
2708 | } | |
2709 | ||
e9329bd3 | 2710 | static void halbtc8723b1ant_action_wifi_connected_special_packet( |
3c05bedb GKH |
2711 | struct btc_coexist *btcoexist) |
2712 | { | |
2713 | bool hs_connecting = false; | |
2714 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2715 | ||
2716 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_CONNECTING, &hs_connecting); | |
2717 | ||
2718 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2719 | 0x0, 0x0); | |
2720 | ||
2721 | /* tdma and coex table */ | |
2722 | if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { | |
2723 | if (bt_link_info->a2dp_exist && bt_link_info->pan_exist) { | |
2724 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2725 | true, 22); | |
2726 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
2727 | NORMAL_EXEC, 1); | |
2728 | } else { | |
2729 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2730 | true, 20); | |
2731 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
2732 | NORMAL_EXEC, 1); | |
2733 | } | |
2734 | } else { | |
2735 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20); | |
2736 | halbtc8723b1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1); | |
2737 | } | |
2738 | } | |
2739 | ||
e9329bd3 | 2740 | static void halbtc8723b1ant_action_wifi_connected(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2741 | { |
2742 | bool wifi_busy = false; | |
2743 | bool scan = false, link = false, roam = false; | |
2744 | bool under_4way = false, ap_enable = false; | |
2745 | ||
2746 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2747 | "[BTCoex], CoexForWifiConnect()===>\n"); | |
2748 | ||
2749 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, | |
2750 | &under_4way); | |
2751 | if (under_4way) { | |
2752 | halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist); | |
2753 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2754 | "[BTCoex], CoexForWifiConnect(), " | |
2755 | "return for wifi is under 4way<===\n"); | |
2756 | return; | |
2757 | } | |
2758 | ||
2759 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); | |
2760 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); | |
2761 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); | |
2762 | ||
2763 | if (scan || link || roam) { | |
2764 | halbtc8723b1ant_ActionWifiConnectedScan(btcoexist); | |
2765 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2766 | "[BTCoex], CoexForWifiConnect(), " | |
2767 | "return for wifi is under scan<===\n"); | |
2768 | return; | |
2769 | } | |
2770 | ||
2771 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, | |
2772 | &ap_enable); | |
2773 | /* power save state */ | |
2774 | if (!ap_enable && | |
2775 | BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status && | |
2776 | !btcoexist->bt_link_info.hid_only) | |
2777 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_LPS_ON, | |
2778 | 0x50, 0x4); | |
2779 | else | |
2780 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
2781 | 0x0, 0x0); | |
2782 | ||
2783 | /* tdma and coex table */ | |
2784 | btcoexist->btc_get(btcoexist, | |
2785 | BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
2786 | if (!wifi_busy) { | |
2787 | if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { | |
2788 | halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist, | |
2789 | BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); | |
2790 | } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == | |
2791 | coex_dm->bt_status) || | |
2792 | (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == | |
2793 | coex_dm->bt_status)) { | |
2794 | halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist, | |
2795 | BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); | |
2796 | } else { | |
2797 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, | |
2798 | false, 8); | |
2799 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
2800 | NORMAL_EXEC, 2); | |
2801 | } | |
2802 | } else { | |
2803 | if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) { | |
2804 | halbtc8723b1ant_action_wifi_connected_bt_acl_busy(btcoexist, | |
2805 | BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); | |
2806 | } else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == | |
2807 | coex_dm->bt_status) || | |
2808 | (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == | |
2809 | coex_dm->bt_status)) { | |
2810 | halbtc8723b1ant_action_bt_sco_hid_only_busy(btcoexist, | |
2811 | BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); | |
2812 | } else { | |
2813 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8); | |
2814 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
2815 | NORMAL_EXEC, 2); | |
2816 | } | |
2817 | } | |
2818 | } | |
2819 | ||
e9329bd3 KZ |
2820 | static void halbtc8723b1ant_run_sw_coexist_mechanism( |
2821 | struct btc_coexist *btcoexist) | |
3c05bedb GKH |
2822 | { |
2823 | u8 algorithm = 0; | |
2824 | ||
2825 | algorithm = halbtc8723b1ant_action_algorithm(btcoexist); | |
2826 | coex_dm->cur_algorithm = algorithm; | |
2827 | ||
2828 | if (halbtc8723b1ant_is_common_action(btcoexist)) { | |
2829 | } else { | |
2830 | switch (coex_dm->cur_algorithm) { | |
2831 | case BT_8723B_1ANT_COEX_ALGO_SCO: | |
2832 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2833 | "[BTCoex], Action algorithm = SCO.\n"); | |
2834 | halbtc8723b1ant_action_sco(btcoexist); | |
2835 | break; | |
2836 | case BT_8723B_1ANT_COEX_ALGO_HID: | |
2837 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2838 | "[BTCoex], Action algorithm = HID.\n"); | |
2839 | halbtc8723b1ant_action_hid(btcoexist); | |
2840 | break; | |
2841 | case BT_8723B_1ANT_COEX_ALGO_A2DP: | |
2842 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2843 | "[BTCoex], Action algorithm = A2DP.\n"); | |
2844 | halbtc8723b1ant_action_a2dp(btcoexist); | |
2845 | break; | |
2846 | case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS: | |
2847 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2848 | "[BTCoex], Action algorithm = " | |
2849 | "A2DP+PAN(HS).\n"); | |
2850 | halbtc8723b1ant_action_a2dp_pan_hs(btcoexist); | |
2851 | break; | |
2852 | case BT_8723B_1ANT_COEX_ALGO_PANEDR: | |
2853 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2854 | "[BTCoex], Action algorithm = PAN(EDR).\n"); | |
2855 | halbtc8723b1ant_action_pan_edr(btcoexist); | |
2856 | break; | |
2857 | case BT_8723B_1ANT_COEX_ALGO_PANHS: | |
2858 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2859 | "[BTCoex], Action algorithm = HS mode.\n"); | |
2860 | halbtc8723b1ant_action_pan_hs(btcoexist); | |
2861 | break; | |
2862 | case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP: | |
2863 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2864 | "[BTCoex], Action algorithm = PAN+A2DP.\n"); | |
2865 | halbtc8723b1ant_action_pan_edr_a2dp(btcoexist); | |
2866 | break; | |
2867 | case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID: | |
2868 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2869 | "[BTCoex], Action algorithm = " | |
2870 | "PAN(EDR)+HID.\n"); | |
2871 | halbtc8723b1ant_action_pan_edr_hid(btcoexist); | |
2872 | break; | |
2873 | case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: | |
2874 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2875 | "[BTCoex], Action algorithm = " | |
2876 | "HID+A2DP+PAN.\n"); | |
2877 | halbtc8723b1ant_action_hid_a2dp_pan_edr(btcoexist); | |
2878 | break; | |
2879 | case BT_8723B_1ANT_COEX_ALGO_HID_A2DP: | |
2880 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2881 | "[BTCoex], Action algorithm = HID+A2DP.\n"); | |
2882 | halbtc8723b1ant_action_hid_a2dp(btcoexist); | |
2883 | break; | |
2884 | default: | |
2885 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2886 | "[BTCoex], Action algorithm = " | |
2887 | "coexist All Off!!\n"); | |
2888 | break; | |
2889 | } | |
2890 | coex_dm->pre_algorithm = coex_dm->cur_algorithm; | |
2891 | } | |
2892 | } | |
2893 | ||
e9329bd3 | 2894 | static void halbtc8723b1ant_run_coexist_mechanism(struct btc_coexist *btcoexist) |
3c05bedb GKH |
2895 | { |
2896 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
2897 | bool wifi_connected = false, bt_hs_on = false; | |
2898 | bool limited_dig = false, bIncreaseScanDevNum = false; | |
2899 | bool b_bt_ctrl_agg_buf_size = false; | |
2900 | u8 agg_buf_size = 5; | |
2901 | u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH; | |
2902 | ||
2903 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2904 | "[BTCoex], RunCoexistMechanism()===>\n"); | |
2905 | ||
2906 | if (btcoexist->manual_control) { | |
2907 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2908 | "[BTCoex], RunCoexistMechanism(), " | |
2909 | "return for Manual CTRL <===\n"); | |
2910 | return; | |
2911 | } | |
2912 | ||
2913 | if (btcoexist->stop_coex_dm) { | |
2914 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2915 | "[BTCoex], RunCoexistMechanism(), " | |
2916 | "return for Stop Coex DM <===\n"); | |
2917 | return; | |
2918 | } | |
2919 | ||
2920 | if (coex_sta->under_ips) { | |
2921 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2922 | "[BTCoex], wifi is under IPS !!!\n"); | |
2923 | return; | |
2924 | } | |
2925 | ||
2926 | if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || | |
2927 | (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || | |
2928 | (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) { | |
2929 | limited_dig = true; | |
2930 | bIncreaseScanDevNum = true; | |
2931 | } | |
2932 | ||
2933 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig); | |
2934 | btcoexist->btc_set(btcoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, | |
2935 | &bIncreaseScanDevNum); | |
2936 | ||
2937 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
2938 | &wifi_connected); | |
2939 | ||
2940 | if (!bt_link_info->sco_exist && !bt_link_info->hid_exist) { | |
2941 | halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, 0, 0, 0, 0); | |
2942 | } else { | |
2943 | if (wifi_connected) { | |
2944 | wifi_rssi_state = | |
2945 | halbtc8723b1ant_wifi_rssi_state(btcoexist, | |
2946 | 1, 2, 30, 0); | |
2947 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2948 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2949 | halbtc8723b1ant_limited_tx(btcoexist, | |
2950 | NORMAL_EXEC, | |
2951 | 1, 1, 1, 1); | |
2952 | } else { | |
2953 | halbtc8723b1ant_limited_tx(btcoexist, | |
2954 | NORMAL_EXEC, | |
2955 | 1, 1, 1, 1); | |
2956 | } | |
2957 | } else { | |
2958 | halbtc8723b1ant_limited_tx(btcoexist, NORMAL_EXEC, | |
2959 | 0, 0, 0, 0); | |
2960 | } | |
2961 | } | |
2962 | ||
2963 | if (bt_link_info->sco_exist) { | |
2964 | b_bt_ctrl_agg_buf_size = true; | |
2965 | agg_buf_size = 0x3; | |
2966 | } else if (bt_link_info->hid_exist) { | |
2967 | b_bt_ctrl_agg_buf_size = true; | |
2968 | agg_buf_size = 0x5; | |
2969 | } else if (bt_link_info->a2dp_exist || bt_link_info->pan_exist) { | |
2970 | b_bt_ctrl_agg_buf_size = true; | |
2971 | agg_buf_size = 0x8; | |
2972 | } | |
2973 | halbtc8723b1ant_limited_rx(btcoexist, NORMAL_EXEC, false, | |
2974 | b_bt_ctrl_agg_buf_size, agg_buf_size); | |
2975 | ||
2976 | halbtc8723b1ant_run_sw_coexist_mechanism(btcoexist); | |
2977 | ||
2978 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
2979 | ||
2980 | if (coex_sta->c2h_bt_inquiry_page) { | |
2981 | halbtc8723b1ant_action_bt_inquiry(btcoexist); | |
2982 | return; | |
2983 | } else if (bt_hs_on) { | |
2984 | halbtc8723b1ant_action_hs(btcoexist); | |
2985 | return; | |
2986 | } | |
2987 | ||
2988 | ||
2989 | if (!wifi_connected) { | |
2990 | bool scan = false, link = false, roam = false; | |
2991 | ||
2992 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2993 | "[BTCoex], wifi is non connected-idle !!!\n"); | |
2994 | ||
2995 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); | |
2996 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); | |
2997 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); | |
2998 | ||
2999 | if (scan || link || roam) | |
3000 | halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist); | |
3001 | else | |
3002 | halbtc8723b1ant_action_wifi_not_connected(btcoexist); | |
3003 | } else { /* wifi LPS/Busy */ | |
3004 | halbtc8723b1ant_action_wifi_connected(btcoexist); | |
3005 | } | |
3006 | } | |
3007 | ||
e9329bd3 | 3008 | static void halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) |
3c05bedb GKH |
3009 | { |
3010 | /* force to reset coex mechanism */ | |
3011 | halbtc8723b1ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); | |
3012 | halbtc8723b1ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false); | |
3013 | ||
3014 | /* sw all off */ | |
3015 | halbtc8723b1ant_sw_mechanism1(btcoexist, false, false, false, false); | |
3016 | halbtc8723b1ant_sw_mechanism2(btcoexist,false, false, false, 0x18); | |
3017 | ||
3018 | halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 8); | |
3019 | halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); | |
3020 | } | |
3021 | ||
e9329bd3 KZ |
3022 | static void halbtc8723b1ant_init_hw_config(struct btc_coexist *btcoexist, |
3023 | bool backup) | |
3c05bedb GKH |
3024 | { |
3025 | u32 u32tmp = 0; | |
3026 | u8 u8tmp = 0; | |
3027 | u32 cnt_bt_cal_chk = 0; | |
3028 | ||
3029 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3030 | "[BTCoex], 1Ant Init HW Config!!\n"); | |
3031 | ||
3032 | if (backup) {/* backup rf 0x1e value */ | |
3033 | coex_dm->bt_rf0x1e_backup = | |
3034 | btcoexist->btc_get_rf_reg(btcoexist, | |
3035 | BTC_RF_A, 0x1e, 0xfffff); | |
3036 | ||
3037 | coex_dm->backup_arfr_cnt1 = | |
3038 | btcoexist->btc_read_4byte(btcoexist, 0x430); | |
3039 | coex_dm->backup_arfr_cnt2 = | |
3040 | btcoexist->btc_read_4byte(btcoexist, 0x434); | |
3041 | coex_dm->backup_retry_limit = | |
3042 | btcoexist->btc_read_2byte(btcoexist, 0x42a); | |
3043 | coex_dm->backup_ampdu_max_time = | |
3044 | btcoexist->btc_read_1byte(btcoexist, 0x456); | |
3045 | } | |
3046 | ||
3047 | /* WiFi goto standby while GNT_BT 0-->1 */ | |
3048 | btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); | |
3049 | /* BT goto standby while GNT_BT 1-->0 */ | |
3050 | btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x2, 0xfffff, 0x500); | |
3051 | ||
3052 | btcoexist->btc_write_1byte(btcoexist, 0x974, 0xff); | |
3053 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x944, 0x3, 0x3); | |
3054 | btcoexist->btc_write_1byte(btcoexist, 0x930, 0x77); | |
3055 | ||
3056 | ||
3057 | /* BT calibration check */ | |
3058 | while (cnt_bt_cal_chk <= 20) { | |
3059 | u32tmp = btcoexist->btc_read_4byte(btcoexist, 0x49d); | |
3060 | cnt_bt_cal_chk++; | |
3061 | if (u32tmp & BIT0) { | |
3062 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3063 | "[BTCoex], ########### BT " | |
3064 | "calibration(cnt=%d) ###########\n", | |
3065 | cnt_bt_cal_chk); | |
3066 | mdelay(50); | |
3067 | } else { | |
3068 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3069 | "[BTCoex], ********** BT NOT " | |
3070 | "calibration (cnt=%d)**********\n", | |
3071 | cnt_bt_cal_chk); | |
3072 | break; | |
3073 | } | |
3074 | } | |
3075 | ||
3076 | /* 0x790[5:0]=0x5 */ | |
3077 | u8tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); | |
3078 | u8tmp &= 0xc0; | |
3079 | u8tmp |= 0x5; | |
3080 | btcoexist->btc_write_1byte(btcoexist, 0x790, u8tmp); | |
3081 | ||
3082 | /* Enable counter statistics */ | |
3083 | /*0x76e[3] =1, WLAN_Act control by PTA */ | |
3084 | btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); | |
3085 | btcoexist->btc_write_1byte(btcoexist, 0x778, 0x1); | |
3086 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); | |
3087 | ||
3088 | /*Antenna config */ | |
3089 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_PTA, true, false); | |
3090 | /* PTA parameter */ | |
3091 | halbtc8723b1ant_coex_table_with_type(btcoexist, FORCE_EXEC, 0); | |
3092 | ||
3093 | } | |
3094 | ||
e9329bd3 | 3095 | static void halbtc8723b1ant_wifi_off_hw_cfg(struct btc_coexist *btcoexist) |
3c05bedb GKH |
3096 | { |
3097 | /* set wlan_act to low */ | |
3098 | btcoexist->btc_write_1byte(btcoexist, 0x76e, 0); | |
3099 | } | |
3100 | ||
3101 | /************************************************************** | |
3102 | * work around function start with wa_halbtc8723b1ant_ | |
3103 | **************************************************************/ | |
3104 | /************************************************************** | |
3105 | * extern function start with EXhalbtc8723b1ant_ | |
3106 | **************************************************************/ | |
3107 | ||
3108 | void ex_halbtc8723b1ant_init_hwconfig(struct btc_coexist *btcoexist) | |
3109 | { | |
3110 | halbtc8723b1ant_init_hw_config(btcoexist, true); | |
3111 | } | |
3112 | ||
3113 | void ex_halbtc8723b1ant_init_coex_dm(struct btc_coexist *btcoexist) | |
3114 | { | |
3115 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3116 | "[BTCoex], Coex Mechanism Init!!\n"); | |
3117 | ||
3118 | btcoexist->stop_coex_dm = false; | |
3119 | ||
3120 | halbtc8723b1ant_init_coex_dm(btcoexist); | |
3121 | ||
3122 | halbtc8723b1ant_query_bt_info(btcoexist); | |
3123 | } | |
3124 | ||
3125 | void ex_halbtc8723b1ant_display_coex_info(struct btc_coexist *btcoexist) | |
3126 | { | |
3127 | struct btc_board_info *board_info = &btcoexist->board_info; | |
3128 | struct btc_stack_info *stack_info = &btcoexist->stack_info; | |
3129 | struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info; | |
3130 | u8 *cli_buf = btcoexist->cli_buf; | |
3131 | u8 u8tmp[4], i, bt_info_ext, psTdmaCase=0; | |
3132 | u16 u16tmp[4]; | |
3133 | u32 u32tmp[4]; | |
3134 | bool roam = false, scan = false; | |
3135 | bool link = false, wifi_under_5g = false; | |
3136 | bool bt_hs_on = false, wifi_busy = false; | |
3137 | s32 wifi_rssi =0, bt_hs_rssi = 0; | |
3138 | u32 wifi_bw, wifi_traffic_dir, fa_ofdm, fa_cck; | |
3139 | u8 wifi_dot11_chnl, wifi_hs_chnl; | |
3140 | u32 fw_ver = 0, bt_patch_ver = 0; | |
3141 | ||
3142 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3143 | "\r\n ============[BT Coexist info]============"); | |
3144 | CL_PRINTF(cli_buf); | |
3145 | ||
3146 | if (btcoexist->manual_control) { | |
3147 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3148 | "\r\n ============[Under Manual Control]=========="); | |
3149 | CL_PRINTF(cli_buf); | |
3150 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3151 | "\r\n =========================================="); | |
3152 | CL_PRINTF(cli_buf); | |
3153 | } | |
3154 | if (btcoexist->stop_coex_dm) { | |
3155 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3156 | "\r\n ============[Coex is STOPPED]============"); | |
3157 | CL_PRINTF(cli_buf); | |
3158 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3159 | "\r\n =========================================="); | |
3160 | CL_PRINTF(cli_buf); | |
3161 | } | |
3162 | ||
3163 | if (!board_info->bt_exist) { | |
3164 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n BT not exists !!!"); | |
3165 | CL_PRINTF(cli_buf); | |
3166 | return; | |
3167 | } | |
3168 | ||
3169 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", | |
3170 | "Ant PG Num/ Ant Mech/ Ant Pos:", \ | |
3171 | board_info->pg_ant_num, board_info->btdm_ant_num, | |
3172 | board_info->btdm_ant_pos); | |
3173 | CL_PRINTF(cli_buf); | |
3174 | ||
3175 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", | |
3176 | "BT stack/ hci ext ver", \ | |
3177 | ((stack_info->profile_notified)? "Yes":"No"), | |
3178 | stack_info->hci_version); | |
3179 | CL_PRINTF(cli_buf); | |
3180 | ||
3181 | btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); | |
3182 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); | |
3183 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3184 | "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", | |
3185 | "CoexVer/ FwVer/ PatchVer", \ | |
3186 | glcoex_ver_date_8723b_1ant, glcoex_ver_8723b_1ant, | |
3187 | fw_ver, bt_patch_ver, bt_patch_ver); | |
3188 | CL_PRINTF(cli_buf); | |
3189 | ||
3190 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
3191 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, | |
3192 | &wifi_dot11_chnl); | |
3193 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); | |
3194 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", | |
3195 | "Dot11 channel / HsChnl(HsMode)", \ | |
3196 | wifi_dot11_chnl, wifi_hs_chnl, bt_hs_on); | |
3197 | CL_PRINTF(cli_buf); | |
3198 | ||
3199 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", | |
3200 | "H2C Wifi inform bt chnl Info", \ | |
3201 | coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1], | |
3202 | coex_dm->wifi_chnl_info[2]); | |
3203 | CL_PRINTF(cli_buf); | |
3204 | ||
3205 | btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); | |
3206 | btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); | |
3207 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", | |
3208 | "Wifi rssi/ HS rssi", wifi_rssi, bt_hs_rssi); | |
3209 | CL_PRINTF(cli_buf); | |
3210 | ||
3211 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); | |
3212 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); | |
3213 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); | |
3214 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", | |
3215 | "Wifi link/ roam/ scan", link, roam, scan); | |
3216 | CL_PRINTF(cli_buf); | |
3217 | ||
3218 | btcoexist->btc_get(btcoexist,BTC_GET_BL_WIFI_UNDER_5G, | |
3219 | &wifi_under_5g); | |
3220 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
3221 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
3222 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, | |
3223 | &wifi_traffic_dir); | |
3224 | ||
3225 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", | |
3226 | "Wifi status", (wifi_under_5g? "5G":"2.4G"), | |
3227 | ((BTC_WIFI_BW_LEGACY==wifi_bw)? "Legacy": | |
3228 | (((BTC_WIFI_BW_HT40==wifi_bw)? "HT40":"HT20"))), | |
3229 | ((!wifi_busy)? "idle": | |
3230 | ((BTC_WIFI_TRAFFIC_TX==wifi_traffic_dir)? | |
3231 | "uplink":"downlink"))); | |
3232 | CL_PRINTF(cli_buf); | |
3233 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", | |
3234 | "BT [status/ rssi/ retryCnt]", | |
3235 | ((btcoexist->bt_info.bt_disabled)? ("disabled"): | |
3236 | ((coex_sta->c2h_bt_inquiry_page)?("inquiry/page scan"): | |
3237 | ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == coex_dm->bt_status)? | |
3238 | "non-connected idle": | |
3239 | ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == coex_dm->bt_status)? | |
3240 | "connected-idle":"busy")))), | |
3241 | coex_sta->bt_rssi, coex_sta->bt_retry_cnt); | |
3242 | CL_PRINTF(cli_buf); | |
3243 | ||
3244 | ||
3245 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", | |
3246 | "SCO/HID/PAN/A2DP", bt_link_info->sco_exist, | |
3247 | bt_link_info->hid_exist, bt_link_info->pan_exist, | |
3248 | bt_link_info->a2dp_exist); | |
3249 | CL_PRINTF(cli_buf); | |
3250 | btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_BT_LINK_INFO); | |
3251 | ||
3252 | bt_info_ext = coex_sta->bt_info_ext; | |
3253 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", | |
3254 | "BT Info A2DP rate", | |
3255 | (bt_info_ext & BIT0) ? "Basic rate" : "EDR rate"); | |
3256 | CL_PRINTF(cli_buf); | |
3257 | ||
3258 | for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) { | |
3259 | if (coex_sta->bt_info_c2h_cnt[i]) { | |
3260 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3261 | "\r\n %-35s = %02x %02x %02x " | |
3262 | "%02x %02x %02x %02x(%d)", | |
3263 | GLBtInfoSrc8723b1Ant[i], | |
3264 | coex_sta->bt_info_c2h[i][0], | |
3265 | coex_sta->bt_info_c2h[i][1], | |
3266 | coex_sta->bt_info_c2h[i][2], | |
3267 | coex_sta->bt_info_c2h[i][3], | |
3268 | coex_sta->bt_info_c2h[i][4], | |
3269 | coex_sta->bt_info_c2h[i][5], | |
3270 | coex_sta->bt_info_c2h[i][6], | |
3271 | coex_sta->bt_info_c2h_cnt[i]); | |
3272 | CL_PRINTF(cli_buf); | |
3273 | } | |
3274 | } | |
3275 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3276 | "\r\n %-35s = %s/%s, (0x%x/0x%x)", | |
3277 | "PS state, IPS/LPS, (lps/rpwm)", \ | |
3278 | ((coex_sta->under_ips? "IPS ON":"IPS OFF")), | |
3279 | ((coex_sta->under_lps? "LPS ON":"LPS OFF")), | |
3280 | btcoexist->bt_info.lps_1ant, | |
3281 | btcoexist->bt_info.rpwm_1ant); | |
3282 | CL_PRINTF(cli_buf); | |
3283 | btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); | |
3284 | ||
3285 | if (!btcoexist->manual_control) { | |
3286 | /* Sw mechanism */ | |
3287 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", | |
3288 | "============[Sw mechanism]============"); | |
3289 | CL_PRINTF(cli_buf); | |
3290 | ||
3291 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", | |
3292 | "SM1[ShRf/ LpRA/ LimDig]", \ | |
3293 | coex_dm->cur_rf_rx_lpf_shrink, | |
3294 | coex_dm->cur_low_penalty_ra, | |
3295 | btcoexist->bt_info.limited_dig); | |
3296 | CL_PRINTF(cli_buf); | |
3297 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3298 | "\r\n %-35s = %d/ %d/ %d(0x%x) ", | |
3299 | "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ | |
3300 | coex_dm->cur_agc_table_en, | |
3301 | coex_dm->cur_adc_backoff, | |
3302 | coex_dm->cur_dac_swing_on, | |
3303 | coex_dm->cur_dac_swing_lvl); | |
3304 | CL_PRINTF(cli_buf); | |
3305 | ||
3306 | ||
3307 | CL_PRINTF(cli_buf); | |
3308 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", | |
3309 | "Rate Mask", btcoexist->bt_info.ra_mask); | |
3310 | CL_PRINTF(cli_buf); | |
3311 | ||
3312 | /* Fw mechanism */ | |
3313 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", | |
3314 | "============[Fw mechanism]============"); | |
3315 | CL_PRINTF(cli_buf); | |
3316 | ||
3317 | psTdmaCase = coex_dm->cur_ps_tdma; | |
3318 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3319 | "\r\n %-35s = %02x %02x %02x %02x %02x " | |
3320 | "case-%d (auto:%d)", | |
3321 | "PS TDMA", coex_dm->ps_tdma_para[0], | |
3322 | coex_dm->ps_tdma_para[1], coex_dm->ps_tdma_para[2], | |
3323 | coex_dm->ps_tdma_para[3], coex_dm->ps_tdma_para[4], | |
3324 | psTdmaCase, coex_dm->auto_tdma_adjust); | |
3325 | CL_PRINTF(cli_buf); | |
3326 | ||
3327 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", | |
3328 | "Latest error condition(should be 0)", \ | |
3329 | coex_dm->error_condition); | |
3330 | CL_PRINTF(cli_buf); | |
3331 | ||
3332 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", | |
3333 | "DecBtPwr/ IgnWlanAct", coex_dm->cur_dec_bt_pwr, | |
3334 | coex_dm->cur_ignore_wlan_act); | |
3335 | CL_PRINTF(cli_buf); | |
3336 | } | |
3337 | ||
3338 | /* Hw setting */ | |
3339 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s", | |
3340 | "============[Hw setting]============"); | |
3341 | CL_PRINTF(cli_buf); | |
3342 | ||
3343 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", | |
3344 | "RF-A, 0x1e initVal", coex_dm->bt_rf0x1e_backup); | |
3345 | CL_PRINTF(cli_buf); | |
3346 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", | |
3347 | "backup ARFR1/ARFR2/RL/AMaxTime", coex_dm->backup_arfr_cnt1, | |
3348 | coex_dm->backup_arfr_cnt2, coex_dm->backup_retry_limit, | |
3349 | coex_dm->backup_ampdu_max_time); | |
3350 | CL_PRINTF(cli_buf); | |
3351 | ||
3352 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x430); | |
3353 | u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x434); | |
3354 | u16tmp[0] = btcoexist->btc_read_2byte(btcoexist, 0x42a); | |
3355 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x456); | |
3356 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", | |
3357 | "0x430/0x434/0x42a/0x456", | |
3358 | u32tmp[0], u32tmp[1], u16tmp[0], u8tmp[0]); | |
3359 | CL_PRINTF(cli_buf); | |
3360 | ||
3361 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); | |
3362 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6cc); | |
3363 | u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x880); | |
3364 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3365 | "0x778/0x6cc/0x880[29:25]", u8tmp[0], u32tmp[0], | |
3366 | (u32tmp[1] & 0x3e000000) >> 25); | |
3367 | CL_PRINTF(cli_buf); | |
3368 | ||
3369 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x948); | |
3370 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x67); | |
3371 | u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x765); | |
3372 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3373 | "0x948/ 0x67[5] / 0x765", | |
3374 | u32tmp[0], ((u8tmp[0] & 0x20)>> 5), u8tmp[1]); | |
3375 | CL_PRINTF(cli_buf); | |
3376 | ||
3377 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x92c); | |
3378 | u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x930); | |
3379 | u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x944); | |
3380 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3381 | "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", | |
3382 | u32tmp[0] & 0x3, u32tmp[1] & 0xff, u32tmp[2] & 0x3); | |
3383 | CL_PRINTF(cli_buf); | |
3384 | ||
3385 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x39); | |
3386 | u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x40); | |
3387 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
3388 | u8tmp[2] = btcoexist->btc_read_1byte(btcoexist, 0x64); | |
3389 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3390 | "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", | |
3391 | "0x38[11]/0x40/0x4c[24:23]/0x64[0]", | |
3392 | ((u8tmp[0] & 0x8)>>3), u8tmp[1], | |
3393 | ((u32tmp[0] & 0x01800000) >> 23), u8tmp[2] & 0x1); | |
3394 | CL_PRINTF(cli_buf); | |
3395 | ||
3396 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); | |
3397 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); | |
3398 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", | |
3399 | "0x550(bcn ctrl)/0x522", u32tmp[0], u8tmp[0]); | |
3400 | CL_PRINTF(cli_buf); | |
3401 | ||
3402 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); | |
3403 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x49c); | |
3404 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", | |
3405 | "0xc50(dig)/0x49c(null-drop)", u32tmp[0] & 0xff, u8tmp[0]); | |
3406 | CL_PRINTF(cli_buf); | |
3407 | ||
3408 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xda0); | |
3409 | u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0xda4); | |
3410 | u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0xda8); | |
3411 | u32tmp[3] = btcoexist->btc_read_4byte(btcoexist, 0xcf0); | |
3412 | ||
3413 | u8tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); | |
3414 | u8tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); | |
3415 | ||
3416 | fa_ofdm = ((u32tmp[0] & 0xffff0000) >> 16) + | |
3417 | ((u32tmp[1] & 0xffff0000) >> 16) + | |
3418 | (u32tmp[1] & 0xffff) + | |
3419 | (u32tmp[2] & 0xffff) + \ | |
3420 | ((u32tmp[3] & 0xffff0000) >> 16) + | |
3421 | (u32tmp[3] & 0xffff) ; | |
3422 | fa_cck = (u8tmp[0] << 8) + u8tmp[1]; | |
3423 | ||
3424 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3425 | "OFDM-CCA/OFDM-FA/CCK-FA", | |
3426 | u32tmp[0] & 0xffff, fa_ofdm, fa_cck); | |
3427 | CL_PRINTF(cli_buf); | |
3428 | ||
3429 | u32tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); | |
3430 | u32tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); | |
3431 | u32tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); | |
3432 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3433 | "0x6c0/0x6c4/0x6c8(coexTable)", | |
3434 | u32tmp[0], u32tmp[1], u32tmp[2]); | |
3435 | CL_PRINTF(cli_buf); | |
3436 | ||
3437 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", | |
3438 | "0x770(high-pri rx/tx)", coex_sta->high_priority_rx, | |
3439 | coex_sta->high_priority_tx); | |
3440 | CL_PRINTF(cli_buf); | |
3441 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", | |
3442 | "0x774(low-pri rx/tx)", coex_sta->low_priority_rx, | |
3443 | coex_sta->low_priority_tx); | |
3444 | CL_PRINTF(cli_buf); | |
3445 | #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 1) | |
3446 | halbtc8723b1ant_monitor_bt_ctr(btcoexist); | |
3447 | #endif | |
3448 | btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); | |
3449 | } | |
3450 | ||
3451 | ||
3452 | void ex_halbtc8723b1ant_ips_notify(struct btc_coexist *btcoexist, u8 type) | |
3453 | { | |
3454 | ||
3455 | if (btcoexist->manual_control || btcoexist->stop_coex_dm) | |
3456 | return; | |
3457 | ||
3458 | if (BTC_IPS_ENTER == type) { | |
3459 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3460 | "[BTCoex], IPS ENTER notify\n"); | |
3461 | coex_sta->under_ips = true; | |
3462 | ||
3463 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT, | |
3464 | false, true); | |
3465 | /* set PTA control */ | |
3466 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 0); | |
3467 | halbtc8723b1ant_coex_table_with_type(btcoexist, | |
3468 | NORMAL_EXEC, 0); | |
3469 | } else if (BTC_IPS_LEAVE == type) { | |
3470 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3471 | "[BTCoex], IPS LEAVE notify\n"); | |
3472 | coex_sta->under_ips = false; | |
3473 | ||
3474 | halbtc8723b1ant_run_coexist_mechanism(btcoexist); | |
3475 | } | |
3476 | } | |
3477 | ||
3478 | void ex_halbtc8723b1ant_lps_notify(struct btc_coexist *btcoexist, u8 type) | |
3479 | { | |
3480 | if (btcoexist->manual_control || btcoexist->stop_coex_dm) | |
3481 | return; | |
3482 | ||
3483 | if (BTC_LPS_ENABLE == type) { | |
3484 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3485 | "[BTCoex], LPS ENABLE notify\n"); | |
3486 | coex_sta->under_lps = true; | |
3487 | } else if (BTC_LPS_DISABLE == type) { | |
3488 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3489 | "[BTCoex], LPS DISABLE notify\n"); | |
3490 | coex_sta->under_lps = false; | |
3491 | } | |
3492 | } | |
3493 | ||
3494 | void ex_halbtc8723b1ant_scan_notify(struct btc_coexist *btcoexist, u8 type) | |
3495 | { | |
3496 | bool wifi_connected = false, bt_hs_on = false; | |
3497 | ||
3498 | if (btcoexist->manual_control || btcoexist->stop_coex_dm || | |
3499 | btcoexist->bt_info.bt_disabled) | |
3500 | return; | |
3501 | ||
3502 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
3503 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
3504 | &wifi_connected); | |
3505 | ||
3506 | halbtc8723b1ant_query_bt_info(btcoexist); | |
3507 | ||
3508 | if (coex_sta->c2h_bt_inquiry_page) { | |
3509 | halbtc8723b1ant_action_bt_inquiry(btcoexist); | |
3510 | return; | |
3511 | } else if (bt_hs_on) { | |
3512 | halbtc8723b1ant_action_hs(btcoexist); | |
3513 | return; | |
3514 | } | |
3515 | ||
3516 | if (BTC_SCAN_START == type) { | |
3517 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3518 | "[BTCoex], SCAN START notify\n"); | |
3519 | if (!wifi_connected) /* non-connected scan */ | |
3520 | halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist); | |
3521 | else /* wifi is connected */ | |
3522 | halbtc8723b1ant_ActionWifiConnectedScan(btcoexist); | |
3523 | } else if (BTC_SCAN_FINISH == type) { | |
3524 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3525 | "[BTCoex], SCAN FINISH notify\n"); | |
3526 | if (!wifi_connected) /* non-connected scan */ | |
3527 | halbtc8723b1ant_action_wifi_not_connected(btcoexist); | |
3528 | else | |
3529 | halbtc8723b1ant_action_wifi_connected(btcoexist); | |
3530 | } | |
3531 | } | |
3532 | ||
3533 | void ex_halbtc8723b1ant_connect_notify(struct btc_coexist *btcoexist, u8 type) | |
3534 | { | |
3535 | bool wifi_connected = false, bt_hs_on = false; | |
3536 | ||
3537 | if (btcoexist->manual_control || btcoexist->stop_coex_dm || | |
3538 | btcoexist->bt_info.bt_disabled) | |
3539 | return; | |
3540 | ||
3541 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
3542 | if (coex_sta->c2h_bt_inquiry_page) { | |
3543 | halbtc8723b1ant_action_bt_inquiry(btcoexist); | |
3544 | return; | |
3545 | } else if (bt_hs_on) { | |
3546 | halbtc8723b1ant_action_hs(btcoexist); | |
3547 | return; | |
3548 | } | |
3549 | ||
3550 | if (BTC_ASSOCIATE_START == type) { | |
3551 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3552 | "[BTCoex], CONNECT START notify\n"); | |
3553 | halbtc8723b1ant_action_wifi_not_connected_asso_auth_scan(btcoexist); | |
3554 | } else if (BTC_ASSOCIATE_FINISH == type) { | |
3555 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3556 | "[BTCoex], CONNECT FINISH notify\n"); | |
3557 | ||
3558 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
3559 | &wifi_connected); | |
3560 | if (!wifi_connected) /* non-connected scan */ | |
3561 | halbtc8723b1ant_action_wifi_not_connected(btcoexist); | |
3562 | else | |
3563 | halbtc8723b1ant_action_wifi_connected(btcoexist); | |
3564 | } | |
3565 | } | |
3566 | ||
3567 | void ex_halbtc8723b1ant_media_status_notify(struct btc_coexist *btcoexist, | |
3568 | u8 type) | |
3569 | { | |
3570 | u8 h2c_parameter[3] ={0}; | |
3571 | u32 wifi_bw; | |
3572 | u8 wifiCentralChnl; | |
3573 | ||
3574 | if (btcoexist->manual_control || btcoexist->stop_coex_dm || | |
3575 | btcoexist->bt_info.bt_disabled ) | |
3576 | return; | |
3577 | ||
3578 | if (BTC_MEDIA_CONNECT == type) | |
3579 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3580 | "[BTCoex], MEDIA connect notify\n"); | |
3581 | else | |
3582 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3583 | "[BTCoex], MEDIA disconnect notify\n"); | |
3584 | ||
3585 | /* only 2.4G we need to inform bt the chnl mask */ | |
3586 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, | |
3587 | &wifiCentralChnl); | |
3588 | ||
3589 | if ((BTC_MEDIA_CONNECT == type) && | |
3590 | (wifiCentralChnl <= 14)) { | |
3591 | h2c_parameter[0] = 0x0; | |
3592 | h2c_parameter[1] = wifiCentralChnl; | |
3593 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
3594 | if (BTC_WIFI_BW_HT40 == wifi_bw) | |
3595 | h2c_parameter[2] = 0x30; | |
3596 | else | |
3597 | h2c_parameter[2] = 0x20; | |
3598 | } | |
3599 | ||
3600 | coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; | |
3601 | coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; | |
3602 | coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; | |
3603 | ||
3604 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
3605 | "[BTCoex], FW write 0x66=0x%x\n", | |
3606 | h2c_parameter[0] << 16 | h2c_parameter[1] << 8 | | |
3607 | h2c_parameter[2]); | |
3608 | ||
3609 | btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); | |
3610 | } | |
3611 | ||
3612 | void ex_halbtc8723b1ant_special_packet_notify(struct btc_coexist *btcoexist, | |
3613 | u8 type) | |
3614 | { | |
3615 | bool bt_hs_on = false; | |
3616 | ||
3617 | if (btcoexist->manual_control || btcoexist->stop_coex_dm || | |
3618 | btcoexist->bt_info.bt_disabled) | |
3619 | return; | |
3620 | ||
3621 | coex_sta->special_pkt_period_cnt = 0; | |
3622 | ||
3623 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
3624 | if (coex_sta->c2h_bt_inquiry_page) { | |
3625 | halbtc8723b1ant_action_bt_inquiry(btcoexist); | |
3626 | return; | |
3627 | } else if (bt_hs_on) { | |
3628 | halbtc8723b1ant_action_hs(btcoexist); | |
3629 | return; | |
3630 | } | |
3631 | ||
3632 | if (BTC_PACKET_DHCP == type || | |
3633 | BTC_PACKET_EAPOL == type) { | |
3634 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3635 | "[BTCoex], special Packet(%d) notify\n", type); | |
3636 | halbtc8723b1ant_action_wifi_connected_special_packet(btcoexist); | |
3637 | } | |
3638 | } | |
3639 | ||
3640 | void ex_halbtc8723b1ant_bt_info_notify(struct btc_coexist *btcoexist, | |
3641 | u8 *tmp_buf, u8 length) | |
3642 | { | |
3643 | u8 bt_info = 0; | |
3644 | u8 i, rsp_source = 0; | |
3645 | bool wifi_connected = false; | |
3646 | bool bt_busy = false; | |
3647 | ||
3648 | coex_sta->c2h_bt_info_req_sent = false; | |
3649 | ||
3650 | rsp_source = tmp_buf[0] & 0xf; | |
3651 | if (rsp_source >= BT_INFO_SRC_8723B_1ANT_MAX) | |
3652 | rsp_source = BT_INFO_SRC_8723B_1ANT_WIFI_FW; | |
3653 | coex_sta->bt_info_c2h_cnt[rsp_source]++; | |
3654 | ||
3655 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3656 | "[BTCoex], Bt info[%d], length=%d, hex data=[", | |
3657 | rsp_source, length); | |
3658 | for (i=0; i<length; i++) { | |
3659 | coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; | |
3660 | if (i == 1) | |
3661 | bt_info = tmp_buf[i]; | |
3662 | if (i == length - 1) | |
3663 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3664 | "0x%02x]\n", tmp_buf[i]); | |
3665 | else | |
3666 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3667 | "0x%02x, ", tmp_buf[i]); | |
3668 | } | |
3669 | ||
3670 | if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rsp_source) { | |
3671 | coex_sta->bt_retry_cnt = /* [3:0] */ | |
3672 | coex_sta->bt_info_c2h[rsp_source][2] & 0xf; | |
3673 | ||
3674 | coex_sta->bt_rssi = | |
3675 | coex_sta->bt_info_c2h[rsp_source][3] * 2 + 10; | |
3676 | ||
3677 | coex_sta->bt_info_ext = | |
3678 | coex_sta->bt_info_c2h[rsp_source][4]; | |
3679 | ||
3680 | /* Here we need to resend some wifi info to BT | |
3681 | * because bt is reset and loss of the info.*/ | |
3682 | if(coex_sta->bt_info_ext & BIT1) | |
3683 | { | |
3684 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3685 | "[BTCoex], BT ext info bit1 check, " | |
3686 | "send wifi BW&Chnl to BT!!\n"); | |
3687 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
3688 | &wifi_connected); | |
3689 | if(wifi_connected) | |
3690 | ex_halbtc8723b1ant_media_status_notify(btcoexist, | |
3691 | BTC_MEDIA_CONNECT); | |
3692 | else | |
3693 | ex_halbtc8723b1ant_media_status_notify(btcoexist, | |
3694 | BTC_MEDIA_DISCONNECT); | |
3695 | } | |
3696 | ||
3697 | if (coex_sta->bt_info_ext & BIT3) { | |
3698 | if (!btcoexist->manual_control && | |
3699 | !btcoexist->stop_coex_dm) { | |
3700 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3701 | "[BTCoex], BT ext info bit3 check, " | |
3702 | "set BT NOT ignore Wlan active!!\n"); | |
3703 | halbtc8723b1ant_ignore_wlan_act(btcoexist, | |
3704 | FORCE_EXEC, | |
3705 | false); | |
3706 | } | |
3707 | } else { | |
3708 | /* BT already NOT ignore Wlan active, do nothing here.*/ | |
3709 | } | |
3710 | #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) | |
3711 | if (coex_sta->bt_info_ext & BIT4) { | |
3712 | /* BT auto report already enabled, do nothing */ | |
3713 | } else { | |
3714 | halbtc8723b1ant_bt_auto_report(btcoexist, FORCE_EXEC, | |
3715 | true); | |
3716 | } | |
3717 | #endif | |
3718 | } | |
3719 | ||
3720 | /* check BIT2 first ==> check if bt is under inquiry or page scan */ | |
3721 | if (bt_info & BT_INFO_8723B_1ANT_B_INQ_PAGE) | |
3722 | coex_sta->c2h_bt_inquiry_page = true; | |
3723 | else | |
3724 | coex_sta->c2h_bt_inquiry_page = false; | |
3725 | ||
3726 | /* set link exist status */ | |
3727 | if (!(bt_info & BT_INFO_8723B_1ANT_B_CONNECTION)) { | |
3728 | coex_sta->bt_link_exist = false; | |
3729 | coex_sta->pan_exist = false; | |
3730 | coex_sta->a2dp_exist = false; | |
3731 | coex_sta->hid_exist = false; | |
3732 | coex_sta->sco_exist = false; | |
3733 | } else { /* connection exists */ | |
3734 | coex_sta->bt_link_exist = true; | |
3735 | if (bt_info & BT_INFO_8723B_1ANT_B_FTP) | |
3736 | coex_sta->pan_exist = true; | |
3737 | else | |
3738 | coex_sta->pan_exist = false; | |
3739 | if (bt_info & BT_INFO_8723B_1ANT_B_A2DP) | |
3740 | coex_sta->a2dp_exist = true; | |
3741 | else | |
3742 | coex_sta->a2dp_exist = false; | |
3743 | if (bt_info & BT_INFO_8723B_1ANT_B_HID) | |
3744 | coex_sta->hid_exist = true; | |
3745 | else | |
3746 | coex_sta->hid_exist = false; | |
3747 | if (bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) | |
3748 | coex_sta->sco_exist = true; | |
3749 | else | |
3750 | coex_sta->sco_exist = false; | |
3751 | } | |
3752 | ||
3753 | halbtc8723b1ant_update_bt_link_info(btcoexist); | |
3754 | ||
3755 | if (!(bt_info&BT_INFO_8723B_1ANT_B_CONNECTION)) { | |
3756 | coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; | |
3757 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3758 | "[BTCoex], BtInfoNotify(), " | |
3759 | "BT Non-Connected idle!!!\n"); | |
3760 | /* connection exists but no busy */ | |
3761 | } else if (bt_info == BT_INFO_8723B_1ANT_B_CONNECTION) { | |
3762 | coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE; | |
3763 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3764 | "[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n"); | |
3765 | } else if ((bt_info & BT_INFO_8723B_1ANT_B_SCO_ESCO) || | |
3766 | (bt_info & BT_INFO_8723B_1ANT_B_SCO_BUSY)) { | |
3767 | coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_SCO_BUSY; | |
3768 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3769 | "[BTCoex], BtInfoNotify(), " | |
3770 | "BT SCO busy!!!\n"); | |
3771 | } else if (bt_info & BT_INFO_8723B_1ANT_B_ACL_BUSY) { | |
3772 | if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != coex_dm->bt_status) | |
3773 | coex_dm->auto_tdma_adjust = false; | |
3774 | ||
3775 | coex_dm->bt_status = BT_8723B_1ANT_BT_STATUS_ACL_BUSY; | |
3776 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3777 | "[BTCoex], BtInfoNotify(), BT ACL busy!!!\n"); | |
3778 | } else { | |
3779 | coex_dm->bt_status = | |
3780 | BT_8723B_1ANT_BT_STATUS_MAX; | |
3781 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3782 | "[BTCoex], BtInfoNotify(), BT Non-Defined state!!\n"); | |
3783 | } | |
3784 | ||
3785 | if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == coex_dm->bt_status) || | |
3786 | (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == coex_dm->bt_status) || | |
3787 | (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == coex_dm->bt_status)) | |
3788 | bt_busy = true; | |
3789 | else | |
3790 | bt_busy = false; | |
3791 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); | |
3792 | ||
3793 | halbtc8723b1ant_run_coexist_mechanism(btcoexist); | |
3794 | } | |
3795 | ||
3796 | void ex_halbtc8723b1ant_halt_notify(struct btc_coexist *btcoexist) | |
3797 | { | |
3798 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); | |
3799 | ||
3800 | btcoexist->stop_coex_dm = true; | |
3801 | ||
3802 | halbtc8723b1ant_SetAntPath(btcoexist, BTC_ANT_PATH_BT, false, true); | |
3803 | ||
3804 | halbtc8723b1ant_wifi_off_hw_cfg(btcoexist); | |
3805 | halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); | |
3806 | ||
3807 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
3808 | 0x0, 0x0); | |
3809 | halbtc8723b1ant_ps_tdma(btcoexist, FORCE_EXEC, false, 0); | |
3810 | ||
3811 | ex_halbtc8723b1ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); | |
3812 | } | |
3813 | ||
3814 | void ex_halbtc8723b1ant_pnp_notify(struct btc_coexist *btcoexist, u8 pnp_state) | |
3815 | { | |
3816 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Pnp notify\n"); | |
3817 | ||
3818 | if (BTC_WIFI_PNP_SLEEP == pnp_state) { | |
3819 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3820 | "[BTCoex], Pnp notify to SLEEP\n"); | |
3821 | btcoexist->stop_coex_dm = true; | |
3822 | halbtc8723b1ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); | |
3823 | halbtc8723b1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, | |
3824 | 0x0, 0x0); | |
3825 | halbtc8723b1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 9); | |
3826 | } else if (BTC_WIFI_PNP_WAKE_UP == pnp_state) { | |
3827 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3828 | "[BTCoex], Pnp notify to WAKE UP\n"); | |
3829 | btcoexist->stop_coex_dm = false; | |
3830 | halbtc8723b1ant_init_hw_config(btcoexist, false); | |
3831 | halbtc8723b1ant_init_coex_dm(btcoexist); | |
3832 | halbtc8723b1ant_query_bt_info(btcoexist); | |
3833 | } | |
3834 | } | |
3835 | ||
3836 | void ex_halbtc8723b1ant_periodical(struct btc_coexist *btcoexist) | |
3837 | { | |
3838 | struct btc_board_info *board_info = &btcoexist->board_info; | |
3839 | struct btc_stack_info *stack_info = &btcoexist->stack_info; | |
3840 | static u8 dis_ver_info_cnt = 0; | |
3841 | u32 fw_ver = 0, bt_patch_ver = 0; | |
3842 | ||
3843 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3844 | "[BTCoex], ==========================" | |
3845 | "Periodical===========================\n"); | |
3846 | ||
3847 | if (dis_ver_info_cnt <= 5) { | |
3848 | dis_ver_info_cnt += 1; | |
3849 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3850 | "[BTCoex], *************************" | |
3851 | "***************************************\n"); | |
3852 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3853 | "[BTCoex], Ant PG Num/ Ant Mech/ " | |
3854 | "Ant Pos = %d/ %d/ %d\n", \ | |
3855 | board_info->pg_ant_num, board_info->btdm_ant_num, | |
3856 | board_info->btdm_ant_pos); | |
3857 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3858 | "[BTCoex], BT stack/ hci ext ver = %s / %d\n", \ | |
3859 | ((stack_info->profile_notified)? "Yes":"No"), | |
3860 | stack_info->hci_version); | |
3861 | btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, | |
3862 | &bt_patch_ver); | |
3863 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); | |
3864 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3865 | "[BTCoex], CoexVer/ FwVer/ PatchVer " | |
3866 | "= %d_%x/ 0x%x/ 0x%x(%d)\n", \ | |
3867 | glcoex_ver_date_8723b_1ant, | |
3868 | glcoex_ver_8723b_1ant, fw_ver, | |
3869 | bt_patch_ver, bt_patch_ver); | |
3870 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3871 | "[BTCoex], *****************************" | |
3872 | "***********************************\n"); | |
3873 | } | |
3874 | ||
3875 | #if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) | |
3876 | halbtc8723b1ant_query_bt_info(btcoexist); | |
3877 | halbtc8723b1ant_monitor_bt_ctr(btcoexist); | |
3878 | halbtc8723b1ant_monitor_bt_enable_disable(btcoexist); | |
3879 | #else | |
3880 | if (halbtc8723b1ant_is_wifi_status_changed(btcoexist) || | |
3881 | coex_dm->auto_tdma_adjust) { | |
3882 | if (coex_sta->special_pkt_period_cnt > 2) | |
3883 | halbtc8723b1ant_run_coexist_mechanism(btcoexist); | |
3884 | } | |
3885 | ||
3886 | coex_sta->special_pkt_period_cnt++; | |
3887 | #endif | |
3888 | } | |
3889 | ||
3890 | ||
3891 | #endif | |
3892 |