Commit | Line | Data |
---|---|---|
e22f4eda LF |
1 | /* Description: */ |
2 | /* This file is for RTL8821A Co-exist mechanism */ | |
3 | /* History */ | |
4 | /* 2012/08/22 Cosa first check in. */ | |
5 | /* 2012/11/14 Cosa Revise for 8821A 2Ant out sourcing. */ | |
6 | ||
7 | /* include files */ | |
8 | #include "halbt_precomp.h" | |
9 | /* Global variables, these are static variables */ | |
10 | static struct coex_dm_8821a_2ant glcoex_dm_8821a_2ant; | |
11 | static struct coex_dm_8821a_2ant *coex_dm = &glcoex_dm_8821a_2ant; | |
12 | static struct coex_sta_8821a_2ant glcoex_sta_8821a_2ant; | |
13 | static struct coex_sta_8821a_2ant *coex_sta = &glcoex_sta_8821a_2ant; | |
14 | ||
15 | static const char *const glbt_info_src_8821a_2ant[] = { | |
16 | "BT Info[wifi fw]", | |
17 | "BT Info[bt rsp]", | |
18 | "BT Info[bt auto report]", | |
19 | }; | |
20 | ||
21 | static u32 glcoex_ver_date_8821a_2ant = 20130618; | |
22 | static u32 glcoex_ver_8821a_2ant = 0x5050; | |
23 | ||
24 | /* local function proto type if needed */ | |
25 | /* local function start with halbtc8821a2ant_ */ | |
26 | static u8 halbtc8821a2ant_bt_rssi_state(u8 level_num, u8 rssi_thresh, | |
27 | u8 rssi_thresh1) | |
28 | { | |
29 | long bt_rssi = 0; | |
30 | u8 bt_rssi_state = coex_sta->pre_bt_rssi_state; | |
31 | ||
32 | bt_rssi = coex_sta->bt_rssi; | |
33 | ||
34 | if (level_num == 2) { | |
35 | if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || | |
36 | (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { | |
37 | if (bt_rssi >= (rssi_thresh + | |
38 | BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
39 | bt_rssi_state = BTC_RSSI_STATE_HIGH; | |
40 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
41 | "[BTCoex], BT Rssi state switch to High\n"); | |
42 | } else { | |
43 | bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
44 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
45 | "[BTCoex], BT Rssi state stay at Low\n"); | |
46 | } | |
47 | } else { | |
48 | if (bt_rssi < rssi_thresh) { | |
49 | bt_rssi_state = BTC_RSSI_STATE_LOW; | |
50 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
51 | "[BTCoex], BT Rssi state switch to Low\n"); | |
52 | } else { | |
53 | bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
54 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
55 | "[BTCoex], BT Rssi state stay at High\n"); | |
56 | } | |
57 | } | |
58 | } else if (level_num == 3) { | |
59 | if (rssi_thresh > rssi_thresh1) { | |
60 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
61 | "[BTCoex], BT Rssi thresh error!!\n"); | |
62 | return coex_sta->pre_bt_rssi_state; | |
63 | } | |
64 | ||
65 | if ((coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_LOW) || | |
66 | (coex_sta->pre_bt_rssi_state == BTC_RSSI_STATE_STAY_LOW)) { | |
67 | if (bt_rssi >= (rssi_thresh + | |
68 | BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
69 | bt_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
70 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
71 | "[BTCoex], BT Rssi state switch to Medium\n"); | |
72 | } else { | |
73 | bt_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
74 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, | |
75 | "[BTCoex], BT Rssi state stay at Low\n"); | |
76 | } | |
77 | } else if ((coex_sta->pre_bt_rssi_state == | |
78 | BTC_RSSI_STATE_MEDIUM) || | |
79 | (coex_sta->pre_bt_rssi_state == | |
80 | BTC_RSSI_STATE_STAY_MEDIUM)) { | |
81 | if (bt_rssi >= (rssi_thresh1 + | |
82 | BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
83 | bt_rssi_state = BTC_RSSI_STATE_HIGH; | |
84 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
85 | ALGO_BT_RSSI_STATE, | |
86 | "[BTCoex], BT Rssi state switch to High\n"); | |
87 | } else if (bt_rssi < rssi_thresh) { | |
88 | bt_rssi_state = BTC_RSSI_STATE_LOW; | |
89 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
90 | ALGO_BT_RSSI_STATE, | |
91 | "[BTCoex], BT Rssi state switch to Low\n"); | |
92 | } else { | |
93 | bt_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; | |
94 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
95 | ALGO_BT_RSSI_STATE, | |
96 | "[BTCoex], BT Rssi state stay at Medium\n"); | |
97 | } | |
98 | } else { | |
99 | if (bt_rssi < rssi_thresh1) { | |
100 | bt_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
101 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
102 | ALGO_BT_RSSI_STATE, | |
103 | "[BTCoex], BT Rssi state switch to Medium\n"); | |
104 | } else { | |
105 | bt_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
106 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
107 | ALGO_BT_RSSI_STATE, | |
108 | "[BTCoex], BT Rssi state stay at High\n"); | |
109 | } | |
110 | } | |
111 | } | |
112 | ||
113 | coex_sta->pre_bt_rssi_state = bt_rssi_state; | |
114 | ||
115 | return bt_rssi_state; | |
116 | } | |
117 | ||
118 | static u8 wifi21a_rssi_state(struct btc_coexist *btcoexist, | |
119 | u8 index, u8 level_num, | |
120 | u8 rssi_thresh, u8 rssi_thresh1) | |
121 | { | |
122 | long wifi_rssi = 0; | |
123 | u8 wifi_rssi_state = coex_sta->pre_wifi_rssi_state[index]; | |
124 | ||
125 | btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); | |
126 | ||
127 | if (level_num == 2) { | |
128 | if ((coex_sta->pre_wifi_rssi_state[index] == | |
129 | BTC_RSSI_STATE_LOW) || | |
130 | (coex_sta->pre_wifi_rssi_state[index] == | |
131 | BTC_RSSI_STATE_STAY_LOW)) { | |
132 | if (wifi_rssi >= (rssi_thresh + | |
133 | BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
134 | wifi_rssi_state = BTC_RSSI_STATE_HIGH; | |
135 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
136 | ALGO_WIFI_RSSI_STATE, | |
137 | "[BTCoex], wifi RSSI state switch to High\n"); | |
138 | } else { | |
139 | wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
140 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
141 | ALGO_WIFI_RSSI_STATE, | |
142 | "[BTCoex], wifi RSSI state stay at Low\n"); | |
143 | } | |
144 | } else { | |
145 | if (wifi_rssi < rssi_thresh) { | |
146 | wifi_rssi_state = BTC_RSSI_STATE_LOW; | |
147 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
148 | ALGO_WIFI_RSSI_STATE, | |
149 | "[BTCoex], wifi RSSI state switch to Low\n"); | |
150 | } else { | |
151 | wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
152 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
153 | ALGO_WIFI_RSSI_STATE, | |
154 | "[BTCoex], wifi RSSI state stay at High\n"); | |
155 | } | |
156 | } | |
157 | } else if (level_num == 3) { | |
158 | if (rssi_thresh > rssi_thresh1) { | |
159 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
160 | "[BTCoex], wifi RSSI thresh error!!\n"); | |
161 | return coex_sta->pre_wifi_rssi_state[index]; | |
162 | } | |
163 | ||
164 | if ((coex_sta->pre_wifi_rssi_state[index] == | |
165 | BTC_RSSI_STATE_LOW) || | |
166 | (coex_sta->pre_wifi_rssi_state[index] == | |
167 | BTC_RSSI_STATE_STAY_LOW)) { | |
168 | if (wifi_rssi >= (rssi_thresh + | |
169 | BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
170 | wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
171 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
172 | ALGO_WIFI_RSSI_STATE, | |
173 | "[BTCoex], wifi RSSI state switch to Medium\n"); | |
174 | } else { | |
175 | wifi_rssi_state = BTC_RSSI_STATE_STAY_LOW; | |
176 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
177 | ALGO_WIFI_RSSI_STATE, | |
178 | "[BTCoex], wifi RSSI state stay at Low\n"); | |
179 | } | |
180 | } else if ((coex_sta->pre_wifi_rssi_state[index] == | |
181 | BTC_RSSI_STATE_MEDIUM) || | |
182 | (coex_sta->pre_wifi_rssi_state[index] == | |
183 | BTC_RSSI_STATE_STAY_MEDIUM)) { | |
184 | if (wifi_rssi >= (rssi_thresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) { | |
185 | wifi_rssi_state = BTC_RSSI_STATE_HIGH; | |
186 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
187 | "[BTCoex], wifi RSSI state switch to High\n"); | |
188 | } else if (wifi_rssi < rssi_thresh) { | |
189 | wifi_rssi_state = BTC_RSSI_STATE_LOW; | |
190 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
191 | "[BTCoex], wifi RSSI state switch to Low\n"); | |
192 | } else { | |
193 | wifi_rssi_state = BTC_RSSI_STATE_STAY_MEDIUM; | |
194 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
195 | "[BTCoex], wifi RSSI state stay at Medium\n"); | |
196 | } | |
197 | } else { | |
198 | if (wifi_rssi < rssi_thresh1) { | |
199 | wifi_rssi_state = BTC_RSSI_STATE_MEDIUM; | |
200 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
201 | "[BTCoex], wifi RSSI state switch to Medium\n"); | |
202 | } else { | |
203 | wifi_rssi_state = BTC_RSSI_STATE_STAY_HIGH; | |
204 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, | |
205 | "[BTCoex], wifi RSSI state stay at High\n"); | |
206 | } | |
207 | } | |
208 | } | |
209 | ||
210 | coex_sta->pre_wifi_rssi_state[index] = wifi_rssi_state; | |
211 | ||
212 | return wifi_rssi_state; | |
213 | } | |
214 | ||
215 | static void monitor_bt_enable_disable(struct btc_coexist *btcoexist) | |
216 | { | |
217 | static bool pre_bt_disabled; | |
218 | static u32 bt_disable_cnt; | |
219 | bool bt_active = true, bt_disabled = false; | |
220 | ||
221 | /* This function check if bt is disabled */ | |
222 | ||
223 | if (coex_sta->high_priority_tx == 0 && | |
224 | coex_sta->high_priority_rx == 0 && | |
225 | coex_sta->low_priority_tx == 0 && | |
226 | coex_sta->low_priority_rx == 0) | |
227 | bt_active = false; | |
228 | if (coex_sta->high_priority_tx == 0xffff && | |
229 | coex_sta->high_priority_rx == 0xffff && | |
230 | coex_sta->low_priority_tx == 0xffff && | |
231 | coex_sta->low_priority_rx == 0xffff) | |
232 | bt_active = false; | |
233 | if (bt_active) { | |
234 | bt_disable_cnt = 0; | |
235 | bt_disabled = false; | |
236 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, | |
237 | &bt_disabled); | |
238 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
239 | "[BTCoex], BT is enabled !!\n"); | |
240 | } else { | |
241 | bt_disable_cnt++; | |
242 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
243 | "[BTCoex], bt all counters = 0, %d times!!\n", | |
244 | bt_disable_cnt); | |
245 | if (bt_disable_cnt >= 2) { | |
246 | bt_disabled = true; | |
247 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_DISABLE, | |
248 | &bt_disabled); | |
249 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
250 | "[BTCoex], BT is disabled !!\n"); | |
251 | } | |
252 | } | |
253 | if (pre_bt_disabled != bt_disabled) { | |
254 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
255 | "[BTCoex], BT is from %s to %s!!\n", | |
256 | (pre_bt_disabled ? "disabled" : "enabled"), | |
257 | (bt_disabled ? "disabled" : "enabled")); | |
258 | pre_bt_disabled = bt_disabled; | |
259 | } | |
260 | } | |
261 | ||
262 | static void halbtc8821a2ant_monitor_bt_ctr(struct btc_coexist *btcoexist) | |
263 | { | |
264 | u32 reg_hp_txrx, reg_lp_txrx, u4tmp; | |
265 | u32 reg_hp_tx = 0, reg_hp_rx = 0, reg_lp_tx = 0, reg_lp_rx = 0; | |
266 | ||
267 | reg_hp_txrx = 0x770; | |
268 | reg_lp_txrx = 0x774; | |
269 | ||
270 | u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_hp_txrx); | |
271 | reg_hp_tx = u4tmp & MASKLWORD; | |
272 | reg_hp_rx = (u4tmp & MASKHWORD)>>16; | |
273 | ||
274 | u4tmp = btcoexist->btc_read_4byte(btcoexist, reg_lp_txrx); | |
275 | reg_lp_tx = u4tmp & MASKLWORD; | |
276 | reg_lp_rx = (u4tmp & MASKHWORD)>>16; | |
277 | ||
278 | coex_sta->high_priority_tx = reg_hp_tx; | |
279 | coex_sta->high_priority_rx = reg_hp_rx; | |
280 | coex_sta->low_priority_tx = reg_lp_tx; | |
281 | coex_sta->low_priority_rx = reg_lp_rx; | |
282 | ||
283 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
284 | "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", | |
285 | reg_hp_txrx, reg_hp_tx, reg_hp_tx, reg_hp_rx, reg_hp_rx); | |
286 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, | |
287 | "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", | |
288 | reg_lp_txrx, reg_lp_tx, reg_lp_tx, reg_lp_rx, reg_lp_rx); | |
289 | ||
290 | /* reset counter */ | |
291 | btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); | |
292 | } | |
293 | ||
294 | static void halbtc8821a2ant_query_bt_info(struct btc_coexist *btcoexist) | |
295 | { | |
296 | u8 h2c_parameter[1] = {0}; | |
297 | ||
298 | coex_sta->c2h_bt_info_req_sent = true; | |
299 | ||
300 | h2c_parameter[0] |= BIT(0); /* trigger */ | |
301 | ||
302 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
303 | "[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", | |
304 | h2c_parameter[0]); | |
305 | ||
306 | btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter); | |
307 | } | |
308 | ||
309 | static u8 halbtc8821a2ant_action_algorithm(struct btc_coexist *btcoexist) | |
310 | { | |
311 | struct btc_stack_info *stack_info = &btcoexist->stack_info; | |
312 | bool bt_hs_on = false; | |
313 | u8 algorithm = BT_8821A_2ANT_COEX_ALGO_UNDEFINED; | |
314 | u8 num_of_diff_profile = 0; | |
315 | ||
316 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
317 | ||
318 | /* for win-8 stack HID report error */ | |
319 | if (!stack_info->hid_exist) { | |
320 | /* sync BTInfo with BT firmware and stack */ | |
321 | stack_info->hid_exist = coex_sta->hid_exist; | |
322 | } | |
323 | /* when stack HID report error, here we use the info from bt fw. */ | |
324 | if (!stack_info->bt_link_exist) | |
325 | stack_info->bt_link_exist = coex_sta->bt_link_exist; | |
326 | ||
327 | if (!coex_sta->bt_link_exist) { | |
328 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
329 | "[BTCoex], No profile exists!!!\n"); | |
330 | return algorithm; | |
331 | } | |
332 | ||
333 | if (coex_sta->sco_exist) | |
334 | num_of_diff_profile++; | |
335 | if (coex_sta->hid_exist) | |
336 | num_of_diff_profile++; | |
337 | if (coex_sta->pan_exist) | |
338 | num_of_diff_profile++; | |
339 | if (coex_sta->a2dp_exist) | |
340 | num_of_diff_profile++; | |
341 | ||
342 | if (num_of_diff_profile == 1) { | |
343 | if (coex_sta->sco_exist) { | |
344 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
345 | "[BTCoex], SCO only\n"); | |
346 | algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; | |
347 | } else { | |
348 | if (coex_sta->hid_exist) { | |
349 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
350 | "[BTCoex], HID only\n"); | |
351 | algorithm = BT_8821A_2ANT_COEX_ALGO_HID; | |
352 | } else if (coex_sta->a2dp_exist) { | |
353 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
354 | "[BTCoex], A2DP only\n"); | |
355 | algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP; | |
356 | } else if (coex_sta->pan_exist) { | |
357 | if (bt_hs_on) { | |
358 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
359 | "[BTCoex], PAN(HS) only\n"); | |
360 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS; | |
361 | } else { | |
362 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
363 | "[BTCoex], PAN(EDR) only\n"); | |
364 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR; | |
365 | } | |
366 | } | |
367 | } | |
368 | } else if (num_of_diff_profile == 2) { | |
369 | if (coex_sta->sco_exist) { | |
370 | if (coex_sta->hid_exist) { | |
371 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, "[BTCoex], SCO + HID\n"); | |
372 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
373 | } else if (coex_sta->a2dp_exist) { | |
374 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
375 | "[BTCoex], SCO + A2DP ==> SCO\n"); | |
376 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
377 | } else if (coex_sta->pan_exist) { | |
378 | if (bt_hs_on) { | |
379 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
380 | "[BTCoex], SCO + PAN(HS)\n"); | |
381 | algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; | |
382 | } else { | |
383 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
384 | "[BTCoex], SCO + PAN(EDR)\n"); | |
385 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
386 | } | |
387 | } | |
388 | } else { | |
389 | if (coex_sta->hid_exist && | |
390 | coex_sta->a2dp_exist) { | |
391 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
392 | "[BTCoex], HID + A2DP\n"); | |
393 | algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; | |
394 | } else if (coex_sta->hid_exist && | |
395 | coex_sta->pan_exist) { | |
396 | if (bt_hs_on) { | |
397 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
398 | "[BTCoex], HID + PAN(HS)\n"); | |
399 | algorithm = BT_8821A_2ANT_COEX_ALGO_HID; | |
400 | } else { | |
401 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
402 | "[BTCoex], HID + PAN(EDR)\n"); | |
403 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
404 | } | |
405 | } else if (coex_sta->pan_exist && | |
406 | coex_sta->a2dp_exist) { | |
407 | if (bt_hs_on) { | |
408 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
409 | "[BTCoex], A2DP + PAN(HS)\n"); | |
410 | algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS; | |
411 | } else { | |
412 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
413 | "[BTCoex], A2DP + PAN(EDR)\n"); | |
414 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP; | |
415 | } | |
416 | } | |
417 | } | |
418 | } else if (num_of_diff_profile == 3) { | |
419 | if (coex_sta->sco_exist) { | |
420 | if (coex_sta->hid_exist && | |
421 | coex_sta->a2dp_exist) { | |
422 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
423 | "[BTCoex], SCO + HID + A2DP ==> HID\n"); | |
424 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
425 | } else if (coex_sta->hid_exist && | |
426 | coex_sta->pan_exist) { | |
427 | if (bt_hs_on) { | |
428 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
429 | "[BTCoex], SCO + HID + PAN(HS)\n"); | |
430 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
431 | } else { | |
432 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
433 | "[BTCoex], SCO + HID + PAN(EDR)\n"); | |
434 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
435 | } | |
436 | } else if (coex_sta->pan_exist && | |
437 | coex_sta->a2dp_exist) { | |
438 | if (bt_hs_on) { | |
439 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
440 | "[BTCoex], SCO + A2DP + PAN(HS)\n"); | |
441 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
442 | } else { | |
443 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
444 | "[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n"); | |
445 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
446 | } | |
447 | } | |
448 | } else { | |
449 | if (coex_sta->hid_exist && | |
450 | coex_sta->pan_exist && | |
451 | coex_sta->a2dp_exist) { | |
452 | if (bt_hs_on) { | |
453 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
454 | "[BTCoex], HID + A2DP + PAN(HS)\n"); | |
455 | algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; | |
456 | } else { | |
457 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
458 | "[BTCoex], HID + A2DP + PAN(EDR)\n"); | |
459 | algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; | |
460 | } | |
461 | } | |
462 | } | |
463 | } else if (num_of_diff_profile >= 3) { | |
464 | if (coex_sta->sco_exist) { | |
465 | if (coex_sta->hid_exist && | |
466 | coex_sta->pan_exist && | |
467 | coex_sta->a2dp_exist) { | |
468 | if (bt_hs_on) { | |
469 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
470 | "[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"); | |
471 | ||
472 | } else { | |
473 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
474 | "[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n"); | |
475 | algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; | |
476 | } | |
477 | } | |
478 | } | |
479 | } | |
480 | return algorithm; | |
481 | } | |
482 | ||
483 | static bool halbtc8821a2ant_need_to_dec_bt_pwr(struct btc_coexist *btcoexist) | |
484 | { | |
485 | bool ret = false; | |
486 | bool bt_hs_on = false, wifi_connected = false; | |
487 | long bt_hs_rssi = 0; | |
488 | u8 bt_rssi_state; | |
489 | ||
490 | if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on)) | |
491 | return false; | |
492 | if (!btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
493 | &wifi_connected)) | |
494 | return false; | |
495 | if (!btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi)) | |
496 | return false; | |
497 | ||
498 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
499 | ||
500 | if (wifi_connected) { | |
501 | if (bt_hs_on) { | |
502 | if (bt_hs_rssi > 37) { | |
503 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
504 | "[BTCoex], Need to decrease bt power for HS mode!!\n"); | |
505 | ret = true; | |
506 | } | |
507 | } else { | |
508 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
509 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
510 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
511 | "[BTCoex], Need to decrease bt power for Wifi is connected!!\n"); | |
512 | ret = true; | |
513 | } | |
514 | } | |
515 | } | |
516 | return ret; | |
517 | } | |
518 | ||
519 | static void set_fw_dac_swing_level(struct btc_coexist *btcoexist, | |
520 | u8 dac_swing_lvl) | |
521 | { | |
522 | u8 h2c_parameter[1] = {0}; | |
523 | ||
524 | /* There are several type of dacswing */ | |
525 | /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ | |
526 | h2c_parameter[0] = dac_swing_lvl; | |
527 | ||
528 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
529 | "[BTCoex], Set Dac Swing Level = 0x%x\n", dac_swing_lvl); | |
530 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
531 | "[BTCoex], FW write 0x64 = 0x%x\n", h2c_parameter[0]); | |
532 | ||
533 | btcoexist->btc_fill_h2c(btcoexist, 0x64, 1, h2c_parameter); | |
534 | } | |
535 | ||
536 | static void halbtc8821a2ant_set_fw_dec_bt_pwr(struct btc_coexist *btcoexist, | |
537 | bool dec_bt_pwr) | |
538 | { | |
539 | u8 h2c_parameter[1] = {0}; | |
540 | ||
541 | h2c_parameter[0] = 0; | |
542 | ||
543 | if (dec_bt_pwr) | |
544 | h2c_parameter[0] |= BIT(1); | |
545 | ||
546 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
547 | "[BTCoex], decrease Bt Power : %s, FW write 0x62 = 0x%x\n", | |
548 | (dec_bt_pwr ? "Yes!!" : "No!!"), h2c_parameter[0]); | |
549 | ||
550 | btcoexist->btc_fill_h2c(btcoexist, 0x62, 1, h2c_parameter); | |
551 | } | |
552 | ||
553 | static void halbtc8821a2ant_dec_bt_pwr(struct btc_coexist *btcoexist, | |
554 | bool force_exec, bool dec_bt_pwr) | |
555 | { | |
556 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
557 | "[BTCoex], %s Dec BT power = %s\n", | |
558 | (force_exec ? "force to" : ""), | |
559 | ((dec_bt_pwr) ? "ON" : "OFF")); | |
560 | coex_dm->cur_dec_bt_pwr = dec_bt_pwr; | |
561 | ||
562 | if (!force_exec) { | |
563 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
564 | "[BTCoex], pre_dec_bt_pwr =%d, cur_dec_bt_pwr =%d\n", | |
565 | coex_dm->pre_dec_bt_pwr, coex_dm->cur_dec_bt_pwr); | |
566 | ||
567 | if (coex_dm->pre_dec_bt_pwr == coex_dm->cur_dec_bt_pwr) | |
568 | return; | |
569 | } | |
570 | halbtc8821a2ant_set_fw_dec_bt_pwr(btcoexist, coex_dm->cur_dec_bt_pwr); | |
571 | ||
572 | coex_dm->pre_dec_bt_pwr = coex_dm->cur_dec_bt_pwr; | |
573 | } | |
574 | ||
575 | static void set_fw_bt_lna_constrain(struct btc_coexist *btcoexist, | |
576 | bool bt_lna_cons_on) | |
577 | { | |
578 | u8 h2c_parameter[2] = {0}; | |
579 | ||
580 | h2c_parameter[0] = 0x3; /* opCode, 0x3 = BT_SET_LNA_CONSTRAIN */ | |
581 | ||
582 | if (bt_lna_cons_on) | |
583 | h2c_parameter[1] |= BIT(0); | |
584 | ||
585 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
586 | "[BTCoex], set BT LNA Constrain: %s, FW write 0x69 = 0x%x\n", | |
587 | (bt_lna_cons_on ? "ON!!" : "OFF!!"), | |
588 | h2c_parameter[0]<<8|h2c_parameter[1]); | |
589 | ||
590 | btcoexist->btc_fill_h2c(btcoexist, 0x69, 2, h2c_parameter); | |
591 | } | |
592 | ||
593 | static void set_bt_lna_constrain(struct btc_coexist *btcoexist, bool force_exec, | |
594 | bool bt_lna_cons_on) | |
595 | { | |
596 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
597 | "[BTCoex], %s BT Constrain = %s\n", | |
598 | (force_exec ? "force" : ""), | |
599 | ((bt_lna_cons_on) ? "ON" : "OFF")); | |
600 | coex_dm->cur_bt_lna_constrain = bt_lna_cons_on; | |
601 | ||
602 | if (!force_exec) { | |
603 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
604 | "[BTCoex], pre_bt_lna_constrain =%d, cur_bt_lna_constrain =%d\n", | |
605 | coex_dm->pre_bt_lna_constrain, | |
606 | coex_dm->cur_bt_lna_constrain); | |
607 | ||
608 | if (coex_dm->pre_bt_lna_constrain == | |
609 | coex_dm->cur_bt_lna_constrain) | |
610 | return; | |
611 | } | |
612 | set_fw_bt_lna_constrain(btcoexist, coex_dm->cur_bt_lna_constrain); | |
613 | ||
614 | coex_dm->pre_bt_lna_constrain = coex_dm->cur_bt_lna_constrain; | |
615 | } | |
616 | ||
617 | static void halbtc8821a2ant_set_fw_bt_psd_mode(struct btc_coexist *btcoexist, | |
618 | u8 bt_psd_mode) | |
619 | { | |
620 | u8 h2c_parameter[2] = {0}; | |
621 | ||
622 | h2c_parameter[0] = 0x2; /* opCode, 0x2 = BT_SET_PSD_MODE */ | |
623 | ||
624 | h2c_parameter[1] = bt_psd_mode; | |
625 | ||
626 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
627 | "[BTCoex], set BT PSD mode = 0x%x, FW write 0x69 = 0x%x\n", | |
628 | h2c_parameter[1], | |
629 | h2c_parameter[0] << 8 | h2c_parameter[1]); | |
630 | ||
631 | btcoexist->btc_fill_h2c(btcoexist, 0x69, 2, h2c_parameter); | |
632 | } | |
633 | ||
634 | static void halbtc8821a2ant_set_bt_psd_mode(struct btc_coexist *btcoexist, | |
635 | bool force_exec, u8 bt_psd_mode) | |
636 | { | |
637 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
638 | "[BTCoex], %s BT PSD mode = 0x%x\n", | |
639 | (force_exec ? "force" : ""), bt_psd_mode); | |
640 | coex_dm->cur_bt_psd_mode = bt_psd_mode; | |
641 | ||
642 | if (!force_exec) { | |
643 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
644 | "[BTCoex], pre_bt_psd_mode = 0x%x, cur_bt_psd_mode = 0x%x\n", | |
645 | coex_dm->pre_bt_psd_mode, coex_dm->cur_bt_psd_mode); | |
646 | ||
647 | if (coex_dm->pre_bt_psd_mode == coex_dm->cur_bt_psd_mode) | |
648 | return; | |
649 | } | |
650 | halbtc8821a2ant_set_fw_bt_psd_mode(btcoexist, coex_dm->cur_bt_psd_mode); | |
651 | ||
652 | coex_dm->pre_bt_psd_mode = coex_dm->cur_bt_psd_mode; | |
653 | } | |
654 | ||
655 | static void halbtc8821a2ant_set_bt_auto_report(struct btc_coexist *btcoexist, | |
656 | bool enable_auto_report) | |
657 | { | |
658 | u8 h2c_parameter[1] = {0}; | |
659 | ||
660 | h2c_parameter[0] = 0; | |
661 | ||
662 | if (enable_auto_report) | |
663 | h2c_parameter[0] |= BIT(0); | |
664 | ||
665 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
666 | "[BTCoex], BT FW auto report : %s, FW write 0x68 = 0x%x\n", | |
667 | (enable_auto_report ? "Enabled!!" : "Disabled!!"), | |
668 | h2c_parameter[0]); | |
669 | ||
670 | btcoexist->btc_fill_h2c(btcoexist, 0x68, 1, h2c_parameter); | |
671 | } | |
672 | ||
673 | static void halbtc8821a2ant_bt_auto_report(struct btc_coexist *btcoexist, | |
674 | bool force_exec, | |
675 | bool enable_auto_report) | |
676 | { | |
677 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
678 | "[BTCoex], %s BT Auto report = %s\n", | |
679 | (force_exec ? "force to" : ""), | |
680 | ((enable_auto_report) ? "Enabled" : "Disabled")); | |
681 | coex_dm->cur_bt_auto_report = enable_auto_report; | |
682 | ||
683 | if (!force_exec) { | |
684 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
685 | "[BTCoex], pre_bt_auto_report =%d, cur_bt_auto_report =%d\n", | |
686 | coex_dm->pre_bt_auto_report, | |
687 | coex_dm->cur_bt_auto_report); | |
688 | ||
689 | if (coex_dm->pre_bt_auto_report == coex_dm->cur_bt_auto_report) | |
690 | return; | |
691 | } | |
692 | halbtc8821a2ant_set_bt_auto_report(btcoexist, | |
693 | coex_dm->cur_bt_auto_report); | |
694 | ||
695 | coex_dm->pre_bt_auto_report = coex_dm->cur_bt_auto_report; | |
696 | } | |
697 | ||
698 | static void halbtc8821a2ant_fw_dac_swing_lvl(struct btc_coexist *btcoexist, | |
699 | bool force_exec, | |
700 | u8 fw_dac_swing_lvl) | |
701 | { | |
702 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
703 | "[BTCoex], %s set FW Dac Swing level = %d\n", | |
704 | (force_exec ? "force to" : ""), fw_dac_swing_lvl); | |
705 | coex_dm->cur_fw_dac_swing_lvl = fw_dac_swing_lvl; | |
706 | ||
707 | if (!force_exec) { | |
708 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
709 | "[BTCoex], pre_fw_dac_swing_lvl =%d, cur_fw_dac_swing_lvl =%d\n", | |
710 | coex_dm->pre_fw_dac_swing_lvl, | |
711 | coex_dm->cur_fw_dac_swing_lvl); | |
712 | ||
713 | if (coex_dm->pre_fw_dac_swing_lvl == | |
714 | coex_dm->cur_fw_dac_swing_lvl) | |
715 | return; | |
716 | } | |
717 | ||
718 | set_fw_dac_swing_level(btcoexist, coex_dm->cur_fw_dac_swing_lvl); | |
719 | ||
720 | coex_dm->pre_fw_dac_swing_lvl = coex_dm->cur_fw_dac_swing_lvl; | |
721 | } | |
722 | ||
723 | static void set_sw_rf_rx_lpf_corner(struct btc_coexist *btcoexist, | |
724 | bool rx_rf_shrink_on) | |
725 | { | |
726 | if (rx_rf_shrink_on) { | |
727 | /* Shrink RF Rx LPF corner */ | |
728 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
729 | "[BTCoex], Shrink RF Rx LPF corner!!\n"); | |
730 | btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, | |
731 | 0xfffff, 0xffffc); | |
732 | } else { | |
733 | /* Resume RF Rx LPF corner */ | |
734 | /* After initialized, we can use coex_dm->bt_rf0x1e_backup */ | |
735 | if (btcoexist->initilized) { | |
736 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
737 | "[BTCoex], Resume RF Rx LPF corner!!\n"); | |
738 | btcoexist->btc_set_rf_reg(btcoexist, BTC_RF_A, 0x1e, | |
739 | 0xfffff, | |
740 | coex_dm->bt_rf0x1e_backup); | |
741 | } | |
742 | } | |
743 | } | |
744 | ||
745 | static void halbtc8821a2ant_RfShrink(struct btc_coexist *btcoexist, | |
746 | bool force_exec, bool rx_rf_shrink_on) | |
747 | { | |
748 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
749 | "[BTCoex], %s turn Rx RF Shrink = %s\n", | |
750 | (force_exec ? "force to" : ""), | |
751 | ((rx_rf_shrink_on) ? "ON" : "OFF")); | |
752 | coex_dm->cur_rf_rx_lpf_shrink = rx_rf_shrink_on; | |
753 | ||
754 | if (!force_exec) { | |
755 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
756 | "[BTCoex], pre_rf_rx_lpf_shrink =%d, cur_rf_rx_lpf_shrink =%d\n", | |
757 | coex_dm->pre_rf_rx_lpf_shrink, | |
758 | coex_dm->cur_rf_rx_lpf_shrink); | |
759 | ||
760 | if (coex_dm->pre_rf_rx_lpf_shrink == | |
761 | coex_dm->cur_rf_rx_lpf_shrink) | |
762 | return; | |
763 | } | |
764 | set_sw_rf_rx_lpf_corner(btcoexist, coex_dm->cur_rf_rx_lpf_shrink); | |
765 | ||
766 | coex_dm->pre_rf_rx_lpf_shrink = coex_dm->cur_rf_rx_lpf_shrink; | |
767 | } | |
768 | ||
769 | static void set_sw_penalty_tx_rate_adap(struct btc_coexist *btcoexist, | |
770 | bool low_penalty_ra) | |
771 | { | |
772 | u8 h2c_parameter[6] = {0}; | |
773 | ||
774 | h2c_parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ | |
775 | ||
776 | if (low_penalty_ra) { | |
777 | h2c_parameter[1] |= BIT(0); | |
778 | /* normal rate except MCS7/6/5, OFDM54/48/36 */ | |
779 | h2c_parameter[2] = 0x00; | |
780 | h2c_parameter[3] = 0xf7; /* MCS7 or OFDM54 */ | |
781 | h2c_parameter[4] = 0xf8; /* MCS6 or OFDM48 */ | |
782 | h2c_parameter[5] = 0xf9; /* MCS5 or OFDM36 */ | |
783 | } | |
784 | ||
785 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
786 | "[BTCoex], set WiFi Low-Penalty Retry: %s", | |
787 | (low_penalty_ra ? "ON!!" : "OFF!!")); | |
788 | ||
789 | btcoexist->btc_fill_h2c(btcoexist, 0x69, 6, h2c_parameter); | |
790 | } | |
791 | ||
792 | static void halbtc8821a2ant_low_penalty_ra(struct btc_coexist *btcoexist, | |
793 | bool force_exec, bool low_penalty_ra) | |
794 | { | |
795 | /* return; */ | |
796 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
797 | "[BTCoex], %s turn LowPenaltyRA = %s\n", | |
798 | (force_exec ? "force to" : ""), | |
799 | ((low_penalty_ra) ? "ON" : "OFF")); | |
800 | coex_dm->cur_low_penalty_ra = low_penalty_ra; | |
801 | ||
802 | if (!force_exec) { | |
803 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
804 | "[BTCoex], pre_low_penalty_ra =%d, cur_low_penalty_ra =%d\n", | |
805 | coex_dm->pre_low_penalty_ra, | |
806 | coex_dm->cur_low_penalty_ra); | |
807 | ||
808 | if (coex_dm->pre_low_penalty_ra == coex_dm->cur_low_penalty_ra) | |
809 | return; | |
810 | } | |
811 | set_sw_penalty_tx_rate_adap(btcoexist, coex_dm->cur_low_penalty_ra); | |
812 | ||
813 | coex_dm->pre_low_penalty_ra = coex_dm->cur_low_penalty_ra; | |
814 | } | |
815 | ||
816 | static void halbtc8821a2ant_set_dac_swing_reg(struct btc_coexist *btcoexist, | |
817 | u32 level) | |
818 | { | |
819 | u8 val = (u8)level; | |
820 | ||
821 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
822 | "[BTCoex], Write SwDacSwing = 0x%x\n", level); | |
823 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0xc5b, 0x3e, val); | |
824 | } | |
825 | ||
826 | static void set_sw_fulltime_dac_swing(struct btc_coexist *btcoexist, | |
827 | bool sw_dac_swing_on, | |
828 | u32 sw_dac_swing_lvl) | |
829 | { | |
830 | if (sw_dac_swing_on) | |
831 | halbtc8821a2ant_set_dac_swing_reg(btcoexist, sw_dac_swing_lvl); | |
832 | else | |
833 | halbtc8821a2ant_set_dac_swing_reg(btcoexist, 0x18); | |
834 | } | |
835 | ||
836 | static void halbtc8821a2ant_dac_swing(struct btc_coexist *btcoexist, | |
837 | bool force_exec, bool dac_swing_on, | |
838 | u32 dac_swing_lvl) | |
839 | { | |
840 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
841 | "[BTCoex], %s turn DacSwing =%s, dac_swing_lvl = 0x%x\n", | |
842 | (force_exec ? "force to" : ""), | |
843 | ((dac_swing_on) ? "ON" : "OFF"), dac_swing_lvl); | |
844 | coex_dm->cur_dac_swing_on = dac_swing_on; | |
845 | coex_dm->cur_dac_swing_lvl = dac_swing_lvl; | |
846 | ||
847 | if (!force_exec) { | |
848 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
849 | "[BTCoex], pre_dac_swing_on =%d, pre_dac_swing_lvl = 0x%x, cur_dac_swing_on =%d, cur_dac_swing_lvl = 0x%x\n", | |
850 | coex_dm->pre_dac_swing_on, | |
851 | coex_dm->pre_dac_swing_lvl, | |
852 | coex_dm->cur_dac_swing_on, | |
853 | coex_dm->cur_dac_swing_lvl); | |
854 | ||
855 | if ((coex_dm->pre_dac_swing_on == coex_dm->cur_dac_swing_on) && | |
856 | (coex_dm->pre_dac_swing_lvl == coex_dm->cur_dac_swing_lvl)) | |
857 | return; | |
858 | } | |
859 | mdelay(30); | |
860 | set_sw_fulltime_dac_swing(btcoexist, dac_swing_on, dac_swing_lvl); | |
861 | ||
862 | coex_dm->pre_dac_swing_on = coex_dm->cur_dac_swing_on; | |
863 | coex_dm->pre_dac_swing_lvl = coex_dm->cur_dac_swing_lvl; | |
864 | } | |
865 | ||
866 | static void halbtc8821a2ant_set_adc_back_off(struct btc_coexist *btcoexist, | |
867 | bool adc_back_off) | |
868 | { | |
869 | if (adc_back_off) { | |
870 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
871 | "[BTCoex], BB BackOff Level On!\n"); | |
872 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x3); | |
873 | } else { | |
874 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
875 | "[BTCoex], BB BackOff Level Off!\n"); | |
876 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x8db, 0x60, 0x1); | |
877 | } | |
878 | } | |
879 | ||
880 | static void halbtc8821a2ant_adc_back_off(struct btc_coexist *btcoexist, | |
881 | bool force_exec, bool adc_back_off) | |
882 | { | |
883 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
884 | "[BTCoex], %s turn AdcBackOff = %s\n", | |
885 | (force_exec ? "force to" : ""), | |
886 | ((adc_back_off) ? "ON" : "OFF")); | |
887 | coex_dm->cur_adc_back_off = adc_back_off; | |
888 | ||
889 | if (!force_exec) { | |
890 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
891 | "[BTCoex], pre_adc_back_off =%d, cur_adc_back_off =%d\n", | |
892 | coex_dm->pre_adc_back_off, coex_dm->cur_adc_back_off); | |
893 | ||
894 | if (coex_dm->pre_adc_back_off == coex_dm->cur_adc_back_off) | |
895 | return; | |
896 | } | |
897 | halbtc8821a2ant_set_adc_back_off(btcoexist, coex_dm->cur_adc_back_off); | |
898 | ||
899 | coex_dm->pre_adc_back_off = coex_dm->cur_adc_back_off; | |
900 | } | |
901 | ||
902 | static void halbtc8821a2ant_set_coex_table(struct btc_coexist *btcoexist, | |
903 | u32 val0x6c0, u32 val0x6c4, | |
904 | u32 val0x6c8, u8 val0x6cc) | |
905 | { | |
906 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
907 | "[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0); | |
908 | btcoexist->btc_write_4byte(btcoexist, 0x6c0, val0x6c0); | |
909 | ||
910 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
911 | "[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4); | |
912 | btcoexist->btc_write_4byte(btcoexist, 0x6c4, val0x6c4); | |
913 | ||
914 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
915 | "[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8); | |
916 | btcoexist->btc_write_4byte(btcoexist, 0x6c8, val0x6c8); | |
917 | ||
918 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, | |
919 | "[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc); | |
920 | btcoexist->btc_write_1byte(btcoexist, 0x6cc, val0x6cc); | |
921 | } | |
922 | ||
923 | static void halbtc8821a2ant_coex_table(struct btc_coexist *btcoexist, | |
924 | bool force_exec, u32 val0x6c0, | |
925 | u32 val0x6c4, u32 val0x6c8, u8 val0x6cc) | |
926 | { | |
927 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, | |
928 | "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", | |
929 | (force_exec ? "force to" : ""), | |
930 | val0x6c0, val0x6c4, val0x6c8, val0x6cc); | |
931 | coex_dm->cur_val0x6c0 = val0x6c0; | |
932 | coex_dm->cur_val0x6c4 = val0x6c4; | |
933 | coex_dm->cur_val0x6c8 = val0x6c8; | |
934 | coex_dm->cur_val0x6cc = val0x6cc; | |
935 | ||
936 | if (!force_exec) { | |
937 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
938 | "[BTCoex], pre_val0x6c0 = 0x%x, pre_val0x6c4 = 0x%x, pre_val0x6c8 = 0x%x, pre_val0x6cc = 0x%x !!\n", | |
939 | coex_dm->pre_val0x6c0, coex_dm->pre_val0x6c4, | |
940 | coex_dm->pre_val0x6c8, coex_dm->pre_val0x6cc); | |
941 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, | |
942 | "[BTCoex], cur_val0x6c0 = 0x%x, cur_val0x6c4 = 0x%x, cur_val0x6c8 = 0x%x, cur_val0x6cc = 0x%x !!\n", | |
943 | coex_dm->cur_val0x6c0, coex_dm->cur_val0x6c4, | |
944 | coex_dm->cur_val0x6c8, coex_dm->cur_val0x6cc); | |
945 | ||
946 | if ((coex_dm->pre_val0x6c0 == coex_dm->cur_val0x6c0) && | |
947 | (coex_dm->pre_val0x6c4 == coex_dm->cur_val0x6c4) && | |
948 | (coex_dm->pre_val0x6c8 == coex_dm->cur_val0x6c8) && | |
949 | (coex_dm->pre_val0x6cc == coex_dm->cur_val0x6cc)) | |
950 | return; | |
951 | } | |
952 | halbtc8821a2ant_set_coex_table(btcoexist, val0x6c0, val0x6c4, | |
953 | val0x6c8, val0x6cc); | |
954 | ||
955 | coex_dm->pre_val0x6c0 = coex_dm->cur_val0x6c0; | |
956 | coex_dm->pre_val0x6c4 = coex_dm->cur_val0x6c4; | |
957 | coex_dm->pre_val0x6c8 = coex_dm->cur_val0x6c8; | |
958 | coex_dm->pre_val0x6cc = coex_dm->cur_val0x6cc; | |
959 | } | |
960 | ||
961 | static void set_fw_ignore_wlan_act(struct btc_coexist *btcoexist, bool enable) | |
962 | { | |
963 | u8 h2c_parameter[1] = {0}; | |
964 | ||
965 | if (enable) | |
966 | h2c_parameter[0] |= BIT(0); /* function enable */ | |
967 | ||
968 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
969 | "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", | |
970 | h2c_parameter[0]); | |
971 | ||
972 | btcoexist->btc_fill_h2c(btcoexist, 0x63, 1, h2c_parameter); | |
973 | } | |
974 | ||
975 | static void halbtc8821a2ant_ignore_wlan_act(struct btc_coexist *btcoexist, | |
976 | bool force_exec, bool enable) | |
977 | { | |
978 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
979 | "[BTCoex], %s turn Ignore WlanAct %s\n", | |
980 | (force_exec ? "force to" : ""), (enable ? "ON" : "OFF")); | |
981 | coex_dm->cur_ignore_wlan_act = enable; | |
982 | ||
983 | if (!force_exec) { | |
984 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
985 | "[BTCoex], pre_ignore_wlan_act = %d, cur_ignore_wlan_act = %d!!\n", | |
986 | coex_dm->pre_ignore_wlan_act, | |
987 | coex_dm->cur_ignore_wlan_act); | |
988 | if (coex_dm->pre_ignore_wlan_act == | |
989 | coex_dm->cur_ignore_wlan_act) | |
990 | return; | |
991 | } | |
992 | set_fw_ignore_wlan_act(btcoexist, enable); | |
993 | ||
994 | coex_dm->pre_ignore_wlan_act = coex_dm->cur_ignore_wlan_act; | |
995 | } | |
996 | ||
997 | static void halbtc8821a2ant_set_fw_pstdma(struct btc_coexist *btcoexist, | |
998 | u8 byte1, u8 byte2, u8 byte3, | |
999 | u8 byte4, u8 byte5) | |
1000 | { | |
1001 | u8 h2c_parameter[5] = {0}; | |
1002 | ||
1003 | h2c_parameter[0] = byte1; | |
1004 | h2c_parameter[1] = byte2; | |
1005 | h2c_parameter[2] = byte3; | |
1006 | h2c_parameter[3] = byte4; | |
1007 | h2c_parameter[4] = byte5; | |
1008 | ||
1009 | coex_dm->ps_tdma_para[0] = byte1; | |
1010 | coex_dm->ps_tdma_para[1] = byte2; | |
1011 | coex_dm->ps_tdma_para[2] = byte3; | |
1012 | coex_dm->ps_tdma_para[3] = byte4; | |
1013 | coex_dm->ps_tdma_para[4] = byte5; | |
1014 | ||
1015 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
1016 | "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", | |
1017 | h2c_parameter[0], | |
1018 | h2c_parameter[1] << 24 | h2c_parameter[2] << 16 | | |
1019 | h2c_parameter[3]<<8|h2c_parameter[4]); | |
1020 | ||
1021 | btcoexist->btc_fill_h2c(btcoexist, 0x60, 5, h2c_parameter); | |
1022 | } | |
1023 | ||
1024 | static void sw_mechanism1(struct btc_coexist *btcoexist, bool shrink_rx_lpf, | |
1025 | bool low_penalty_ra, bool limited_dig, | |
1026 | bool bt_lna_constrain) | |
1027 | { | |
1028 | u32 wifi_bw; | |
1029 | ||
1030 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
1031 | ||
1032 | if (BTC_WIFI_BW_HT40 != wifi_bw) { /* only shrink RF Rx LPF for HT40 */ | |
1033 | if (shrink_rx_lpf) | |
1034 | shrink_rx_lpf = false; | |
1035 | } | |
1036 | ||
1037 | halbtc8821a2ant_RfShrink(btcoexist, NORMAL_EXEC, shrink_rx_lpf); | |
1038 | halbtc8821a2ant_low_penalty_ra(btcoexist, NORMAL_EXEC, low_penalty_ra); | |
1039 | ||
1040 | /* no limited DIG */ | |
1041 | /* set_bt_lna_constrain(btcoexist, NORMAL_EXEC, bBTLNAConstrain); */ | |
1042 | } | |
1043 | ||
1044 | static void sw_mechanism2(struct btc_coexist *btcoexist, bool agc_table_shift, | |
1045 | bool adc_back_off, bool sw_dac_swing, | |
1046 | u32 dac_swing_lvl) | |
1047 | { | |
1048 | /* halbtc8821a2ant_AgcTable(btcoexist, NORMAL_EXEC, bAGCTableShift); */ | |
1049 | halbtc8821a2ant_adc_back_off(btcoexist, NORMAL_EXEC, adc_back_off); | |
1050 | halbtc8821a2ant_dac_swing(btcoexist, NORMAL_EXEC, sw_dac_swing, | |
1051 | sw_dac_swing); | |
1052 | } | |
1053 | ||
1054 | static void halbtc8821a2ant_set_ant_path(struct btc_coexist *btcoexist, | |
1055 | u8 ant_pos_type, bool init_hw_cfg, | |
1056 | bool wifi_off) | |
1057 | { | |
1058 | struct btc_board_info *board_info = &btcoexist->board_info; | |
1059 | u32 u4tmp = 0; | |
1060 | u8 h2c_parameter[2] = {0}; | |
1061 | ||
1062 | if (init_hw_cfg) { | |
1063 | /* 0x4c[23] = 0, 0x4c[24] = 1 Antenna control by WL/BT */ | |
1064 | u4tmp = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
1065 | u4tmp &= ~BIT(23); | |
1066 | u4tmp |= BIT(24); | |
1067 | btcoexist->btc_write_4byte(btcoexist, 0x4c, u4tmp); | |
1068 | ||
1069 | btcoexist->btc_write_4byte(btcoexist, 0x974, 0x3ff); | |
1070 | btcoexist->btc_write_1byte(btcoexist, 0xcb4, 0x77); | |
1071 | ||
1072 | if (board_info->btdm_ant_pos == BTC_ANTENNA_AT_MAIN_PORT) { | |
1073 | /* tell firmware "antenna inverse" ==> WRONG firmware | |
1074 | * antenna control code.==>need fw to fix */ | |
1075 | h2c_parameter[0] = 1; | |
1076 | h2c_parameter[1] = 1; | |
1077 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, h2c_parameter); | |
1078 | } else { | |
1079 | /* tell firmware "no antenna inverse" ==> WRONG firmware | |
1080 | * antenna control code.==>need fw to fix */ | |
1081 | h2c_parameter[0] = 0; | |
1082 | h2c_parameter[1] = 1; | |
1083 | btcoexist->btc_fill_h2c(btcoexist, 0x65, 2, | |
1084 | h2c_parameter); | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | /* ext switch setting */ | |
1089 | switch (ant_pos_type) { | |
1090 | case BTC_ANT_WIFI_AT_MAIN: | |
1091 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x1); | |
1092 | break; | |
1093 | case BTC_ANT_WIFI_AT_AUX: | |
1094 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0xcb7, 0x30, 0x2); | |
1095 | break; | |
1096 | } | |
1097 | } | |
1098 | ||
1099 | static void ps21a_tdma(struct btc_coexist *btcoexist, bool force_exec, | |
1100 | bool turn_on, u8 type) | |
1101 | { | |
1102 | /* bool turn_on_by_cnt = false; */ | |
1103 | /* u8 ps_tdma_type_by_cnt = 0; */ | |
1104 | ||
1105 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
1106 | "[BTCoex], %s turn %s PS TDMA, type =%d\n", | |
1107 | (force_exec ? "force to" : ""), | |
1108 | (turn_on ? "ON" : "OFF"), type); | |
1109 | coex_dm->cur_ps_tdma_on = turn_on; | |
1110 | coex_dm->cur_ps_tdma = type; | |
1111 | ||
1112 | if (!force_exec) { | |
1113 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1114 | "[BTCoex], pre_ps_tdma_on = %d, cur_ps_tdma_on = %d!!\n", | |
1115 | coex_dm->pre_ps_tdma_on, coex_dm->cur_ps_tdma_on); | |
1116 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1117 | "[BTCoex], pre_ps_tdma = %d, cur_ps_tdma = %d!!\n", | |
1118 | coex_dm->pre_ps_tdma, coex_dm->cur_ps_tdma); | |
1119 | ||
1120 | if ((coex_dm->pre_ps_tdma_on == coex_dm->cur_ps_tdma_on) && | |
1121 | (coex_dm->pre_ps_tdma == coex_dm->cur_ps_tdma)) | |
1122 | return; | |
1123 | } | |
1124 | if (turn_on) { | |
1125 | switch (type) { | |
1126 | case 1: | |
1127 | default: | |
1128 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, | |
1129 | 0x1a, 0xe1, 0x90); | |
1130 | break; | |
1131 | case 2: | |
1132 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, | |
1133 | 0x12, 0xe1, 0x90); | |
1134 | break; | |
1135 | case 3: | |
1136 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1c, | |
1137 | 0x3, 0xf1, 0x90); | |
1138 | break; | |
1139 | case 4: | |
1140 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x10, | |
1141 | 0x03, 0xf1, 0x90); | |
1142 | break; | |
1143 | case 5: | |
1144 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, | |
1145 | 0x1a, 0x60, 0x90); | |
1146 | break; | |
1147 | case 6: | |
1148 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, | |
1149 | 0x12, 0x60, 0x90); | |
1150 | break; | |
1151 | case 7: | |
1152 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1c, | |
1153 | 0x3, 0x70, 0x90); | |
1154 | break; | |
1155 | case 8: | |
1156 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3, 0x10, | |
1157 | 0x3, 0x70, 0x90); | |
1158 | break; | |
1159 | case 9: | |
1160 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, | |
1161 | 0x1a, 0xe1, 0x90); | |
1162 | break; | |
1163 | case 10: | |
1164 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, | |
1165 | 0x12, 0xe1, 0x90); | |
1166 | break; | |
1167 | case 11: | |
1168 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, | |
1169 | 0xa, 0xe1, 0x90); | |
1170 | break; | |
1171 | case 12: | |
1172 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, | |
1173 | 0x5, 0xe1, 0x90); | |
1174 | break; | |
1175 | case 13: | |
1176 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, | |
1177 | 0x1a, 0x60, 0x90); | |
1178 | break; | |
1179 | case 14: | |
1180 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x12, | |
1181 | 0x12, 0x60, 0x90); | |
1182 | break; | |
1183 | case 15: | |
1184 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0xa, | |
1185 | 0xa, 0x60, 0x90); | |
1186 | break; | |
1187 | case 16: | |
1188 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, | |
1189 | 0x5, 0x60, 0x90); | |
1190 | break; | |
1191 | case 17: | |
1192 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xa3, 0x2f, | |
1193 | 0x2f, 0x60, 0x90); | |
1194 | break; | |
1195 | case 18: | |
1196 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x5, | |
1197 | 0x5, 0xe1, 0x90); | |
1198 | break; | |
1199 | case 19: | |
1200 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, | |
1201 | 0x25, 0xe1, 0x90); | |
1202 | break; | |
1203 | case 20: | |
1204 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x25, | |
1205 | 0x25, 0x60, 0x90); | |
1206 | break; | |
1207 | case 21: | |
1208 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x15, | |
1209 | 0x03, 0x70, 0x90); | |
1210 | break; | |
1211 | case 71: | |
1212 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0xe3, 0x1a, | |
1213 | 0x1a, 0xe1, 0x90); | |
1214 | break; | |
1215 | } | |
1216 | } else { | |
1217 | /* disable PS tdma */ | |
1218 | switch (type) { | |
1219 | case 0: | |
1220 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, | |
1221 | 0x40, 0x0); | |
1222 | break; | |
1223 | case 1: | |
1224 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, | |
1225 | 0x48, 0x0); | |
1226 | break; | |
1227 | default: | |
1228 | halbtc8821a2ant_set_fw_pstdma(btcoexist, 0x0, 0x0, 0x0, | |
1229 | 0x40, 0x0); | |
1230 | break; | |
1231 | } | |
1232 | } | |
1233 | ||
1234 | /* update pre state */ | |
1235 | coex_dm->pre_ps_tdma_on = coex_dm->cur_ps_tdma_on; | |
1236 | coex_dm->pre_ps_tdma = coex_dm->cur_ps_tdma; | |
1237 | } | |
1238 | ||
1239 | static void halbtc8821a2ant_coex_all_off(struct btc_coexist *btcoexist) | |
1240 | { | |
1241 | /* fw all off */ | |
1242 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1243 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1244 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1245 | ||
1246 | /* sw all off */ | |
1247 | sw_mechanism1(btcoexist, false, false, false, false); | |
1248 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1249 | ||
1250 | /* hw all off */ | |
1251 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55555555, | |
1252 | 0x55555555, 0xffff, 0x3); | |
1253 | } | |
1254 | ||
1255 | static void halbtc8821a2ant_coex_under_5g(struct btc_coexist *btcoexist) | |
1256 | { | |
1257 | halbtc8821a2ant_coex_all_off(btcoexist); | |
1258 | } | |
1259 | ||
1260 | static void halbtc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) | |
1261 | { | |
1262 | /* force to reset coex mechanism */ | |
1263 | halbtc8821a2ant_coex_table(btcoexist, FORCE_EXEC, 0x55555555, | |
1264 | 0x55555555, 0xffff, 0x3); | |
1265 | ||
1266 | ps21a_tdma(btcoexist, FORCE_EXEC, false, 1); | |
1267 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, FORCE_EXEC, 6); | |
1268 | halbtc8821a2ant_dec_bt_pwr(btcoexist, FORCE_EXEC, false); | |
1269 | ||
1270 | sw_mechanism1(btcoexist, false, false, false, false); | |
1271 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1272 | } | |
1273 | ||
1274 | static void halbtc8821a2ant_bt_inquiry_page(struct btc_coexist *btcoexist) | |
1275 | { | |
1276 | bool low_pwr_disable = true; | |
1277 | ||
1278 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1279 | &low_pwr_disable); | |
1280 | ||
1281 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
1282 | 0x5afa5afa, 0xffff, 0x3); | |
1283 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1284 | } | |
1285 | ||
1286 | static bool halbtc8821a2ant_is_common_action(struct btc_coexist *btcoexist) | |
1287 | { | |
1288 | bool common = false, wifi_connected = false, wifi_busy = false; | |
1289 | bool low_pwr_disable = false; | |
1290 | ||
1291 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
1292 | &wifi_connected); | |
1293 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
1294 | ||
1295 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
1296 | 0x5afa5afa, 0xffff, 0x3); | |
1297 | ||
1298 | if (!wifi_connected && | |
1299 | BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) { | |
1300 | low_pwr_disable = false; | |
1301 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1302 | &low_pwr_disable); | |
1303 | ||
1304 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1305 | "[BTCoex], Wifi IPS + BT IPS!!\n"); | |
1306 | ||
1307 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1308 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1309 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1310 | ||
1311 | sw_mechanism1(btcoexist, false, false, false, false); | |
1312 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1313 | ||
1314 | common = true; | |
1315 | } else if (wifi_connected && | |
1316 | (BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status)) { | |
1317 | low_pwr_disable = false; | |
1318 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1319 | &low_pwr_disable); | |
1320 | ||
1321 | if (wifi_busy) { | |
1322 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1323 | "[BTCoex], Wifi Busy + BT IPS!!\n"); | |
1324 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1325 | } else { | |
1326 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1327 | "[BTCoex], Wifi LPS + BT IPS!!\n"); | |
1328 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1329 | } | |
1330 | ||
1331 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1332 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1333 | ||
1334 | sw_mechanism1(btcoexist, false, false, false, false); | |
1335 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1336 | ||
1337 | common = true; | |
1338 | } else if (!wifi_connected && | |
1339 | (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == | |
1340 | coex_dm->bt_status)) { | |
1341 | low_pwr_disable = true; | |
1342 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1343 | &low_pwr_disable); | |
1344 | ||
1345 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1346 | "[BTCoex], Wifi IPS + BT LPS!!\n"); | |
1347 | ||
1348 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1349 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1350 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1351 | ||
1352 | sw_mechanism1(btcoexist, false, false, false, false); | |
1353 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1354 | ||
1355 | common = true; | |
1356 | } else if (wifi_connected && | |
1357 | (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == | |
1358 | coex_dm->bt_status)) { | |
1359 | low_pwr_disable = true; | |
1360 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1361 | &low_pwr_disable); | |
1362 | ||
1363 | if (wifi_busy) { | |
1364 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1365 | "[BTCoex], Wifi Busy + BT LPS!!\n"); | |
1366 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1367 | } else { | |
1368 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1369 | "[BTCoex], Wifi LPS + BT LPS!!\n"); | |
1370 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1371 | } | |
1372 | ||
1373 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1374 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1375 | ||
1376 | sw_mechanism1(btcoexist, true, true, true, true); | |
1377 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1378 | ||
1379 | common = true; | |
1380 | } else if (!wifi_connected && | |
1381 | (BT_8821A_2ANT_BT_STATUS_NON_IDLE == coex_dm->bt_status)) { | |
1382 | low_pwr_disable = false; | |
1383 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1384 | &low_pwr_disable); | |
1385 | ||
1386 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1387 | "[BTCoex], Wifi IPS + BT Busy!!\n"); | |
1388 | ||
1389 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
1390 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
1391 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
1392 | ||
1393 | sw_mechanism1(btcoexist, false, false, false, false); | |
1394 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
1395 | ||
1396 | common = true; | |
1397 | } else { | |
1398 | low_pwr_disable = true; | |
1399 | btcoexist->btc_set(btcoexist, BTC_SET_ACT_DISABLE_LOW_POWER, | |
1400 | &low_pwr_disable); | |
1401 | ||
1402 | if (wifi_busy) { | |
1403 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1404 | "[BTCoex], Wifi Busy + BT Busy!!\n"); | |
1405 | common = false; | |
1406 | } else { | |
1407 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
1408 | "[BTCoex], Wifi LPS + BT Busy!!\n"); | |
1409 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 21); | |
1410 | ||
1411 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
1412 | halbtc8821a2ant_dec_bt_pwr(btcoexist, | |
1413 | NORMAL_EXEC, true); | |
1414 | else | |
1415 | halbtc8821a2ant_dec_bt_pwr(btcoexist, | |
1416 | NORMAL_EXEC, false); | |
1417 | ||
1418 | common = true; | |
1419 | } | |
1420 | sw_mechanism1(btcoexist, true, true, true, true); | |
1421 | } | |
1422 | return common; | |
1423 | } | |
1424 | ||
1425 | static void tdma_duration_adjust(struct btc_coexist *btcoexist, | |
1426 | bool sco_hid, bool tx_pause, u8 max_interval) | |
1427 | { | |
1428 | static long up, dn, m, n, wait_count; | |
1429 | long result; | |
1430 | /* 0: no change, +1: incr WiFi duration, -1: decr WiFi duration */ | |
1431 | u8 retry_count = 0; | |
1432 | ||
1433 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, | |
1434 | "[BTCoex], TdmaDurationAdjust()\n"); | |
1435 | ||
1436 | if (coex_dm->reset_tdma_adjust) { | |
1437 | coex_dm->reset_tdma_adjust = false; | |
1438 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1439 | "[BTCoex], first run TdmaDurationAdjust()!!\n"); | |
1440 | if (sco_hid) { | |
1441 | if (tx_pause) { | |
1442 | if (max_interval == 1) { | |
1443 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
1444 | coex_dm->ps_tdma_du_adj_type = 13; | |
1445 | } else if (max_interval == 2) { | |
1446 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1447 | coex_dm->ps_tdma_du_adj_type = 14; | |
1448 | } else if (max_interval == 3) { | |
1449 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1450 | coex_dm->ps_tdma_du_adj_type = 15; | |
1451 | } else { | |
1452 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1453 | coex_dm->ps_tdma_du_adj_type = 15; | |
1454 | } | |
1455 | } else { | |
1456 | if (max_interval == 1) { | |
1457 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); | |
1458 | coex_dm->ps_tdma_du_adj_type = 9; | |
1459 | } else if (max_interval == 2) { | |
1460 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1461 | coex_dm->ps_tdma_du_adj_type = 10; | |
1462 | } else if (max_interval == 3) { | |
1463 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1464 | coex_dm->ps_tdma_du_adj_type = 11; | |
1465 | } else { | |
1466 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1467 | coex_dm->ps_tdma_du_adj_type = 11; | |
1468 | } | |
1469 | } | |
1470 | } else { | |
1471 | if (tx_pause) { | |
1472 | if (max_interval == 1) { | |
1473 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
1474 | coex_dm->ps_tdma_du_adj_type = 5; | |
1475 | } else if (max_interval == 2) { | |
1476 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1477 | coex_dm->ps_tdma_du_adj_type = 6; | |
1478 | } else if (max_interval == 3) { | |
1479 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1480 | coex_dm->ps_tdma_du_adj_type = 7; | |
1481 | } else { | |
1482 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1483 | coex_dm->ps_tdma_du_adj_type = 7; | |
1484 | } | |
1485 | } else { | |
1486 | if (max_interval == 1) { | |
1487 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); | |
1488 | coex_dm->ps_tdma_du_adj_type = 1; | |
1489 | } else if (max_interval == 2) { | |
1490 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1491 | coex_dm->ps_tdma_du_adj_type = 2; | |
1492 | } else if (max_interval == 3) { | |
1493 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1494 | coex_dm->ps_tdma_du_adj_type = 3; | |
1495 | } else { | |
1496 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1497 | coex_dm->ps_tdma_du_adj_type = 3; | |
1498 | } | |
1499 | } | |
1500 | } | |
1501 | up = 0; | |
1502 | dn = 0; | |
1503 | m = 1; | |
1504 | n = 3; | |
1505 | result = 0; | |
1506 | wait_count = 0; | |
1507 | } else { | |
1508 | /* accquire the BT TRx retry count from BT_Info byte2 */ | |
1509 | retry_count = coex_sta->bt_retry_cnt; | |
1510 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1511 | "[BTCoex], retry_count = %d\n", retry_count); | |
1512 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1513 | "[BTCoex], up =%d, dn =%d, m =%d, n =%d, wait_count =%d\n", | |
1514 | (int)up, (int)dn, (int)m, (int)n, (int)wait_count); | |
1515 | result = 0; | |
1516 | wait_count++; | |
1517 | ||
1518 | if (retry_count == 0) { | |
1519 | /* no retry in the last 2-second duration */ | |
1520 | up++; | |
1521 | dn--; | |
1522 | ||
1523 | if (dn <= 0) | |
1524 | dn = 0; | |
1525 | ||
1526 | if (up >= n) { | |
1527 | wait_count = 0; | |
1528 | n = 3; | |
1529 | up = 0; | |
1530 | dn = 0; | |
1531 | result = 1; | |
1532 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1533 | ALGO_TRACE_FW_DETAIL, | |
1534 | "[BTCoex], Increase wifi duration!!\n"); | |
1535 | } | |
1536 | } else if (retry_count <= 3) { | |
1537 | /* <= 3 retry in the last 2-second duration */ | |
1538 | up--; | |
1539 | dn++; | |
1540 | ||
1541 | if (up <= 0) | |
1542 | up = 0; | |
1543 | ||
1544 | if (dn == 2) { | |
1545 | if (wait_count <= 2) | |
1546 | m++; | |
1547 | else | |
1548 | m = 1; | |
1549 | ||
1550 | if (m >= 20) | |
1551 | m = 20; | |
1552 | ||
1553 | n = 3*m; | |
1554 | up = 0; | |
1555 | dn = 0; | |
1556 | wait_count = 0; | |
1557 | result = -1; | |
1558 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1559 | ALGO_TRACE_FW_DETAIL, | |
1560 | "[BTCoex], Decrease wifi duration for retryCounter<3!!\n"); | |
1561 | } | |
1562 | } else { | |
1563 | if (wait_count == 1) | |
1564 | m++; | |
1565 | else | |
1566 | m = 1; | |
1567 | ||
1568 | if (m >= 20) | |
1569 | m = 20; | |
1570 | ||
1571 | n = 3*m; | |
1572 | up = 0; | |
1573 | dn = 0; | |
1574 | wait_count = 0; | |
1575 | result = -1; | |
1576 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1577 | "[BTCoex], Decrease wifi duration for retryCounter>3!!\n"); | |
1578 | } | |
1579 | ||
1580 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1581 | "[BTCoex], max Interval = %d\n", max_interval); | |
1582 | if (max_interval == 1) { | |
1583 | if (tx_pause) { | |
1584 | /* TODO: refactor here */ | |
1585 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1586 | ALGO_TRACE_FW_DETAIL, | |
1587 | "[BTCoex], TxPause = 1\n"); | |
1588 | if (coex_dm->cur_ps_tdma == 71) { | |
1589 | ps21a_tdma(btcoexist, | |
1590 | NORMAL_EXEC, | |
1591 | true, 5); | |
1592 | coex_dm->ps_tdma_du_adj_type = 5; | |
1593 | } else if (coex_dm->cur_ps_tdma == 1) { | |
1594 | ps21a_tdma(btcoexist, | |
1595 | NORMAL_EXEC, | |
1596 | true, 5); | |
1597 | coex_dm->ps_tdma_du_adj_type = 5; | |
1598 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1599 | ps21a_tdma(btcoexist, | |
1600 | NORMAL_EXEC, | |
1601 | true, 6); | |
1602 | coex_dm->ps_tdma_du_adj_type = 6; | |
1603 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1604 | ps21a_tdma(btcoexist, | |
1605 | NORMAL_EXEC, | |
1606 | true, 7); | |
1607 | coex_dm->ps_tdma_du_adj_type = 7; | |
1608 | } else if (coex_dm->cur_ps_tdma == 4) { | |
1609 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1610 | coex_dm->ps_tdma_du_adj_type = 8; | |
1611 | } | |
1612 | if (coex_dm->cur_ps_tdma == 9) { | |
1613 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
1614 | coex_dm->ps_tdma_du_adj_type = 13; | |
1615 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1616 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1617 | coex_dm->ps_tdma_du_adj_type = 14; | |
1618 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1619 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1620 | coex_dm->ps_tdma_du_adj_type = 15; | |
1621 | } else if (coex_dm->cur_ps_tdma == 12) { | |
1622 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1623 | coex_dm->ps_tdma_du_adj_type = 16; | |
1624 | } | |
1625 | ||
1626 | if (result == -1) { | |
1627 | if (coex_dm->cur_ps_tdma == 5) { | |
1628 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1629 | coex_dm->ps_tdma_du_adj_type = 6; | |
1630 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1631 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1632 | coex_dm->ps_tdma_du_adj_type = 7; | |
1633 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1634 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1635 | coex_dm->ps_tdma_du_adj_type = 8; | |
1636 | } else if (coex_dm->cur_ps_tdma == 13) { | |
1637 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1638 | coex_dm->ps_tdma_du_adj_type = 14; | |
1639 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1640 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1641 | coex_dm->ps_tdma_du_adj_type = 15; | |
1642 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1643 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1644 | coex_dm->ps_tdma_du_adj_type = 16; | |
1645 | } | |
1646 | } else if (result == 1) { | |
1647 | if (coex_dm->cur_ps_tdma == 8) { | |
1648 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1649 | coex_dm->ps_tdma_du_adj_type = 7; | |
1650 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1651 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1652 | coex_dm->ps_tdma_du_adj_type = 6; | |
1653 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1654 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
1655 | coex_dm->ps_tdma_du_adj_type = 5; | |
1656 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1657 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1658 | coex_dm->ps_tdma_du_adj_type = 15; | |
1659 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1660 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1661 | coex_dm->ps_tdma_du_adj_type = 14; | |
1662 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1663 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
1664 | coex_dm->ps_tdma_du_adj_type = 13; | |
1665 | } | |
1666 | } | |
1667 | } else { | |
1668 | /* TODO: refactor here */ | |
1669 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], TxPause = 0\n"); | |
1670 | if (coex_dm->cur_ps_tdma == 5) { | |
1671 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 71); | |
1672 | coex_dm->ps_tdma_du_adj_type = 71; | |
1673 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1674 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1675 | coex_dm->ps_tdma_du_adj_type = 2; | |
1676 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1677 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1678 | coex_dm->ps_tdma_du_adj_type = 3; | |
1679 | } else if (coex_dm->cur_ps_tdma == 8) { | |
1680 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); | |
1681 | coex_dm->ps_tdma_du_adj_type = 4; | |
1682 | } | |
1683 | if (coex_dm->cur_ps_tdma == 13) { | |
1684 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); | |
1685 | coex_dm->ps_tdma_du_adj_type = 9; | |
1686 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1687 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1688 | coex_dm->ps_tdma_du_adj_type = 10; | |
1689 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1690 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1691 | coex_dm->ps_tdma_du_adj_type = 11; | |
1692 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1693 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); | |
1694 | coex_dm->ps_tdma_du_adj_type = 12; | |
1695 | } | |
1696 | ||
1697 | if (result == -1) { | |
1698 | if (coex_dm->cur_ps_tdma == 71) { | |
1699 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); | |
1700 | coex_dm->ps_tdma_du_adj_type = 1; | |
1701 | } else if (coex_dm->cur_ps_tdma == 1) { | |
1702 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1703 | coex_dm->ps_tdma_du_adj_type = 2; | |
1704 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1705 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1706 | coex_dm->ps_tdma_du_adj_type = 3; | |
1707 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1708 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); | |
1709 | coex_dm->ps_tdma_du_adj_type = 4; | |
1710 | } else if (coex_dm->cur_ps_tdma == 9) { | |
1711 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1712 | coex_dm->ps_tdma_du_adj_type = 10; | |
1713 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1714 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1715 | coex_dm->ps_tdma_du_adj_type = 11; | |
1716 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1717 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); | |
1718 | coex_dm->ps_tdma_du_adj_type = 12; | |
1719 | } | |
1720 | } else if (result == 1) { | |
1721 | if (coex_dm->cur_ps_tdma == 4) { | |
1722 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1723 | coex_dm->ps_tdma_du_adj_type = 3; | |
1724 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1725 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1726 | coex_dm->ps_tdma_du_adj_type = 2; | |
1727 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1728 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); | |
1729 | coex_dm->ps_tdma_du_adj_type = 1; | |
1730 | } else if (coex_dm->cur_ps_tdma == 1) { | |
1731 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 71); | |
1732 | coex_dm->ps_tdma_du_adj_type = 71; | |
1733 | } else if (coex_dm->cur_ps_tdma == 12) { | |
1734 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1735 | coex_dm->ps_tdma_du_adj_type = 11; | |
1736 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1737 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1738 | coex_dm->ps_tdma_du_adj_type = 10; | |
1739 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1740 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); | |
1741 | coex_dm->ps_tdma_du_adj_type = 9; | |
1742 | } | |
1743 | } | |
1744 | } | |
1745 | } else if (max_interval == 2) { | |
1746 | if (tx_pause) { | |
1747 | /* TODO: refactor here */ | |
1748 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, "[BTCoex], TxPause = 1\n"); | |
1749 | if (coex_dm->cur_ps_tdma == 1) { | |
1750 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1751 | coex_dm->ps_tdma_du_adj_type = 6; | |
1752 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1753 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1754 | coex_dm->ps_tdma_du_adj_type = 6; | |
1755 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1756 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1757 | coex_dm->ps_tdma_du_adj_type = 7; | |
1758 | } else if (coex_dm->cur_ps_tdma == 4) { | |
1759 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1760 | coex_dm->ps_tdma_du_adj_type = 8; | |
1761 | } | |
1762 | if (coex_dm->cur_ps_tdma == 9) { | |
1763 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1764 | coex_dm->ps_tdma_du_adj_type = 14; | |
1765 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1766 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1767 | coex_dm->ps_tdma_du_adj_type = 14; | |
1768 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1769 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1770 | coex_dm->ps_tdma_du_adj_type = 15; | |
1771 | } else if (coex_dm->cur_ps_tdma == 12) { | |
1772 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1773 | coex_dm->ps_tdma_du_adj_type = 16; | |
1774 | } | |
1775 | if (result == -1) { | |
1776 | if (coex_dm->cur_ps_tdma == 5) { | |
1777 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1778 | coex_dm->ps_tdma_du_adj_type = 6; | |
1779 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1780 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1781 | coex_dm->ps_tdma_du_adj_type = 7; | |
1782 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1783 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1784 | coex_dm->ps_tdma_du_adj_type = 8; | |
1785 | } else if (coex_dm->cur_ps_tdma == 13) { | |
1786 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1787 | coex_dm->ps_tdma_du_adj_type = 14; | |
1788 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1789 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1790 | coex_dm->ps_tdma_du_adj_type = 15; | |
1791 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1792 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1793 | coex_dm->ps_tdma_du_adj_type = 16; | |
1794 | } | |
1795 | } else if (result == 1) { | |
1796 | if (coex_dm->cur_ps_tdma == 8) { | |
1797 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1798 | coex_dm->ps_tdma_du_adj_type = 7; | |
1799 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1800 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1801 | coex_dm->ps_tdma_du_adj_type = 6; | |
1802 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1803 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 6); | |
1804 | coex_dm->ps_tdma_du_adj_type = 6; | |
1805 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1806 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1807 | coex_dm->ps_tdma_du_adj_type = 15; | |
1808 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1809 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1810 | coex_dm->ps_tdma_du_adj_type = 14; | |
1811 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1812 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
1813 | coex_dm->ps_tdma_du_adj_type = 14; | |
1814 | } | |
1815 | } | |
1816 | } else { | |
1817 | /* TODO: refactor here */ | |
1818 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1819 | "[BTCoex], TxPause = 0\n"); | |
1820 | if (coex_dm->cur_ps_tdma == 5) { | |
1821 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1822 | coex_dm->ps_tdma_du_adj_type = 2; | |
1823 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1824 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1825 | coex_dm->ps_tdma_du_adj_type = 2; | |
1826 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1827 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1828 | coex_dm->ps_tdma_du_adj_type = 3; | |
1829 | } else if (coex_dm->cur_ps_tdma == 8) { | |
1830 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); | |
1831 | coex_dm->ps_tdma_du_adj_type = 4; | |
1832 | } | |
1833 | if (coex_dm->cur_ps_tdma == 13) { | |
1834 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1835 | coex_dm->ps_tdma_du_adj_type = 10; | |
1836 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1837 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1838 | coex_dm->ps_tdma_du_adj_type = 10; | |
1839 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1840 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1841 | coex_dm->ps_tdma_du_adj_type = 11; | |
1842 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1843 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); | |
1844 | coex_dm->ps_tdma_du_adj_type = 12; | |
1845 | } | |
1846 | if (result == -1) { | |
1847 | if (coex_dm->cur_ps_tdma == 1) { | |
1848 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1849 | coex_dm->ps_tdma_du_adj_type = 2; | |
1850 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1851 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1852 | coex_dm->ps_tdma_du_adj_type = 3; | |
1853 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1854 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 4); | |
1855 | coex_dm->ps_tdma_du_adj_type = 4; | |
1856 | } else if (coex_dm->cur_ps_tdma == 9) { | |
1857 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1858 | coex_dm->ps_tdma_du_adj_type = 10; | |
1859 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1860 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1861 | coex_dm->ps_tdma_du_adj_type = 11; | |
1862 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1863 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); | |
1864 | coex_dm->ps_tdma_du_adj_type = 12; | |
1865 | } | |
1866 | } else if (result == 1) { | |
1867 | if (coex_dm->cur_ps_tdma == 4) { | |
1868 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
1869 | coex_dm->ps_tdma_du_adj_type = 3; | |
1870 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1871 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1872 | coex_dm->ps_tdma_du_adj_type = 2; | |
1873 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1874 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 2); | |
1875 | coex_dm->ps_tdma_du_adj_type = 2; | |
1876 | } else if (coex_dm->cur_ps_tdma == 12) { | |
1877 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
1878 | coex_dm->ps_tdma_du_adj_type = 11; | |
1879 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1880 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1881 | coex_dm->ps_tdma_du_adj_type = 10; | |
1882 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1883 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
1884 | coex_dm->ps_tdma_du_adj_type = 10; | |
1885 | } | |
1886 | } | |
1887 | } | |
1888 | } else if (max_interval == 3) { | |
1889 | if (tx_pause) { | |
1890 | /* TODO: refactor here */ | |
1891 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
1892 | "[BTCoex], TxPause = 1\n"); | |
1893 | if (coex_dm->cur_ps_tdma == 1) { | |
1894 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1895 | coex_dm->ps_tdma_du_adj_type = 7; | |
1896 | } else if (coex_dm->cur_ps_tdma == 2) { | |
1897 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1898 | coex_dm->ps_tdma_du_adj_type = 7; | |
1899 | } else if (coex_dm->cur_ps_tdma == 3) { | |
1900 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1901 | coex_dm->ps_tdma_du_adj_type = 7; | |
1902 | } else if (coex_dm->cur_ps_tdma == 4) { | |
1903 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1904 | coex_dm->ps_tdma_du_adj_type = 8; | |
1905 | } | |
1906 | if (coex_dm->cur_ps_tdma == 9) { | |
1907 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1908 | coex_dm->ps_tdma_du_adj_type = 15; | |
1909 | } else if (coex_dm->cur_ps_tdma == 10) { | |
1910 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1911 | coex_dm->ps_tdma_du_adj_type = 15; | |
1912 | } else if (coex_dm->cur_ps_tdma == 11) { | |
1913 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1914 | coex_dm->ps_tdma_du_adj_type = 15; | |
1915 | } else if (coex_dm->cur_ps_tdma == 12) { | |
1916 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1917 | coex_dm->ps_tdma_du_adj_type = 16; | |
1918 | } | |
1919 | if (result == -1) { | |
1920 | if (coex_dm->cur_ps_tdma == 5) { | |
1921 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1922 | coex_dm->ps_tdma_du_adj_type = 7; | |
1923 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1924 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1925 | coex_dm->ps_tdma_du_adj_type = 7; | |
1926 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1927 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 8); | |
1928 | coex_dm->ps_tdma_du_adj_type = 8; | |
1929 | } else if (coex_dm->cur_ps_tdma == 13) { | |
1930 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1931 | coex_dm->ps_tdma_du_adj_type = 15; | |
1932 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1933 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1934 | coex_dm->ps_tdma_du_adj_type = 15; | |
1935 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1936 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 16); | |
1937 | coex_dm->ps_tdma_du_adj_type = 16; | |
1938 | } | |
1939 | } else if (result == 1) { | |
1940 | if (coex_dm->cur_ps_tdma == 8) { | |
1941 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1942 | coex_dm->ps_tdma_du_adj_type = 7; | |
1943 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1944 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1945 | coex_dm->ps_tdma_du_adj_type = 7; | |
1946 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1947 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 7); | |
1948 | coex_dm->ps_tdma_du_adj_type = 7; | |
1949 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1950 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1951 | coex_dm->ps_tdma_du_adj_type = 15; | |
1952 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1953 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1954 | coex_dm->ps_tdma_du_adj_type = 15; | |
1955 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1956 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 15); | |
1957 | coex_dm->ps_tdma_du_adj_type = 15; | |
1958 | } | |
1959 | } | |
1960 | } else { | |
1961 | BTC_PRINT(BTC_MSG_ALGORITHM, | |
1962 | ALGO_TRACE_FW_DETAIL, | |
1963 | "[BTCoex], TxPause = 0\n"); | |
1964 | if (coex_dm->cur_ps_tdma == 5) { | |
1965 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1966 | true, 3); | |
1967 | coex_dm->ps_tdma_du_adj_type = 3; | |
1968 | } else if (coex_dm->cur_ps_tdma == 6) { | |
1969 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1970 | true, 3); | |
1971 | coex_dm->ps_tdma_du_adj_type = 3; | |
1972 | } else if (coex_dm->cur_ps_tdma == 7) { | |
1973 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1974 | true, 3); | |
1975 | coex_dm->ps_tdma_du_adj_type = 3; | |
1976 | } else if (coex_dm->cur_ps_tdma == 8) { | |
1977 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1978 | true, 4); | |
1979 | coex_dm->ps_tdma_du_adj_type = 4; | |
1980 | } | |
1981 | if (coex_dm->cur_ps_tdma == 13) { | |
1982 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1983 | true, 11); | |
1984 | coex_dm->ps_tdma_du_adj_type = 11; | |
1985 | } else if (coex_dm->cur_ps_tdma == 14) { | |
1986 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1987 | true, 11); | |
1988 | coex_dm->ps_tdma_du_adj_type = 11; | |
1989 | } else if (coex_dm->cur_ps_tdma == 15) { | |
1990 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1991 | true, 11); | |
1992 | coex_dm->ps_tdma_du_adj_type = 11; | |
1993 | } else if (coex_dm->cur_ps_tdma == 16) { | |
1994 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
1995 | true, 12); | |
1996 | coex_dm->ps_tdma_du_adj_type = 12; | |
1997 | } | |
1998 | if (result == -1) { | |
1999 | if (coex_dm->cur_ps_tdma == 1) { | |
2000 | ps21a_tdma(btcoexist, | |
2001 | NORMAL_EXEC, | |
2002 | true, 3); | |
2003 | coex_dm->ps_tdma_du_adj_type = 3; | |
2004 | } else if (coex_dm->cur_ps_tdma == 2) { | |
2005 | ps21a_tdma(btcoexist, | |
2006 | NORMAL_EXEC, | |
2007 | true, 3); | |
2008 | coex_dm->ps_tdma_du_adj_type = 3; | |
2009 | } else if (coex_dm->cur_ps_tdma == 3) { | |
2010 | ps21a_tdma(btcoexist, | |
2011 | NORMAL_EXEC, | |
2012 | true, 4); | |
2013 | coex_dm->ps_tdma_du_adj_type = 4; | |
2014 | } else if (coex_dm->cur_ps_tdma == 9) { | |
2015 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
2016 | coex_dm->ps_tdma_du_adj_type = 11; | |
2017 | } else if (coex_dm->cur_ps_tdma == 10) { | |
2018 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 11); | |
2019 | coex_dm->ps_tdma_du_adj_type = 11; | |
2020 | } else if (coex_dm->cur_ps_tdma == 11) { | |
2021 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 12); | |
2022 | coex_dm->ps_tdma_du_adj_type = 12; | |
2023 | } | |
2024 | } else if (result == 1) { | |
2025 | if (coex_dm->cur_ps_tdma == 4) { | |
2026 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
2027 | coex_dm->ps_tdma_du_adj_type = 3; | |
2028 | } else if (coex_dm->cur_ps_tdma == 3) { | |
2029 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 3); | |
2030 | coex_dm->ps_tdma_du_adj_type = 3; | |
2031 | } else if (coex_dm->cur_ps_tdma == 2) { | |
2032 | ps21a_tdma(btcoexist, | |
2033 | NORMAL_EXEC, true, 3); | |
2034 | coex_dm->ps_tdma_du_adj_type = 3; | |
2035 | } else if (coex_dm->cur_ps_tdma == 12) { | |
2036 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
2037 | true, 11); | |
2038 | coex_dm->ps_tdma_du_adj_type = 11; | |
2039 | } else if (coex_dm->cur_ps_tdma == 11) { | |
2040 | ps21a_tdma(btcoexist, | |
2041 | NORMAL_EXEC, true, 11); | |
2042 | coex_dm->ps_tdma_du_adj_type = 11; | |
2043 | } else if (coex_dm->cur_ps_tdma == 10) { | |
2044 | ps21a_tdma(btcoexist, | |
2045 | NORMAL_EXEC, true, 11); | |
2046 | coex_dm->ps_tdma_du_adj_type = 11; | |
2047 | } | |
2048 | } | |
2049 | } | |
2050 | } | |
2051 | } | |
2052 | ||
2053 | /* if current PsTdma not match with the recorded one | |
2054 | * (when scan, dhcp...), | |
2055 | * then we have to adjust it back to the previous record one. */ | |
2056 | if (coex_dm->cur_ps_tdma != coex_dm->ps_tdma_du_adj_type) { | |
2057 | bool scan = false, link = false, roam = false; | |
2058 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
2059 | "[BTCoex], PsTdma type dismatch!!!, cur_ps_tdma =%d, recordPsTdma =%d\n", | |
2060 | coex_dm->cur_ps_tdma, coex_dm->ps_tdma_du_adj_type); | |
2061 | ||
2062 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); | |
2063 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); | |
2064 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); | |
2065 | ||
2066 | if (!scan && !link && !roam) | |
2067 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, | |
2068 | coex_dm->ps_tdma_du_adj_type); | |
2069 | else | |
2070 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, | |
2071 | "[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"); | |
2072 | } | |
2073 | ||
2074 | /* when tdma_duration_adjust() is called, fw dac swing is | |
2075 | * included in the function. */ | |
2076 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 0x6); | |
2077 | } | |
2078 | ||
2079 | /* SCO only or SCO+PAN(HS) */ | |
2080 | static void halbtc8821a2ant_action_sco(struct btc_coexist *btcoexist) | |
2081 | { | |
2082 | u8 wifi_rssi_state, bt_rssi_state; | |
2083 | u32 wifi_bw; | |
2084 | ||
2085 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2086 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2087 | ||
2088 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 4); | |
2089 | ||
2090 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2091 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2092 | else | |
2093 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2094 | ||
2095 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2096 | ||
2097 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for SCO quality at 11b/g mode */ | |
2098 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x5a5a5a5a, | |
2099 | 0x5a5a5a5a, 0xffff, 0x3); | |
2100 | else /* for SCO quality & wifi performance balance at 11n mode */ | |
2101 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x5aea5aea, | |
2102 | 0x5aea5aea, 0xffff, 0x3); | |
2103 | ||
2104 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2105 | /* fw mechanism */ | |
2106 | /* ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); */ | |
2107 | ||
2108 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2109 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2110 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
2111 | false, 0); /* for voice qual */ | |
2112 | else | |
2113 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
2114 | false, 0); /* for voice qual */ | |
2115 | ||
2116 | /* sw mechanism */ | |
2117 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2118 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2119 | sw_mechanism1(btcoexist, true, true, false, false); | |
2120 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2121 | } else { | |
2122 | sw_mechanism1(btcoexist, true, true, false, false); | |
2123 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2124 | } | |
2125 | } else { | |
2126 | /* fw mechanism */ | |
2127 | ||
2128 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2129 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2130 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
2131 | false, 0); /* for voice qual */ | |
2132 | else | |
2133 | ps21a_tdma(btcoexist, NORMAL_EXEC, | |
2134 | false, 0); /* for voice qual */ | |
2135 | ||
2136 | /* sw mechanism */ | |
2137 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2138 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2139 | sw_mechanism1(btcoexist, false, true, false, false); | |
2140 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2141 | } else { | |
2142 | sw_mechanism1(btcoexist, false, true, false, false); | |
2143 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2144 | } | |
2145 | } | |
2146 | } | |
2147 | ||
2148 | static void halbtc8821a2ant_action_hid(struct btc_coexist *btcoexist) | |
2149 | { | |
2150 | u8 wifi_rssi_state, bt_rssi_state; | |
2151 | u32 wifi_bw; | |
2152 | ||
2153 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2154 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2155 | ||
2156 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2157 | ||
2158 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2159 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2160 | else | |
2161 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2162 | ||
2163 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2164 | ||
2165 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2166 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2167 | 0x5a5a5a5a, 0xffff, 0x3); | |
2168 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2169 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2170 | 0x5aea5aea, 0xffff, 0x3); | |
2171 | ||
2172 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2173 | /* fw mechanism */ | |
2174 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2175 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2176 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); | |
2177 | else | |
2178 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
2179 | /* sw mechanism */ | |
2180 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2181 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2182 | sw_mechanism1(btcoexist, true, true, false, false); | |
2183 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2184 | } else { | |
2185 | sw_mechanism1(btcoexist, true, true, false, false); | |
2186 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2187 | } | |
2188 | } else { | |
2189 | /* fw mechanism */ | |
2190 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2191 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2192 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 9); | |
2193 | else | |
2194 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 13); | |
2195 | ||
2196 | /* sw mechanism */ | |
2197 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2198 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2199 | sw_mechanism1(btcoexist, false, true, false, false); | |
2200 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2201 | } else { | |
2202 | sw_mechanism1(btcoexist, false, true, false, false); | |
2203 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2204 | } | |
2205 | } | |
2206 | } | |
2207 | ||
2208 | /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ | |
2209 | static void halbtc8821a2ant_action_a2dp(struct btc_coexist *btcoexist) | |
2210 | { | |
2211 | u8 wifi_rssi_state, bt_rssi_state; | |
2212 | u32 wifi_bw; | |
2213 | ||
2214 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2215 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2216 | ||
2217 | /* fw dac swing is called in tdma_duration_adjust() */ | |
2218 | /* halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); */ | |
2219 | ||
2220 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2221 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2222 | else | |
2223 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2224 | ||
2225 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2226 | ||
2227 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2228 | /* fw mechanism */ | |
2229 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2230 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2231 | tdma_duration_adjust(btcoexist, false, false, 1); | |
2232 | else | |
2233 | tdma_duration_adjust(btcoexist, false, true, 1); | |
2234 | ||
2235 | /* sw mechanism */ | |
2236 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2237 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2238 | sw_mechanism1(btcoexist, true, false, false, false); | |
2239 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2240 | } else { | |
2241 | sw_mechanism1(btcoexist, true, false, false, false); | |
2242 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2243 | } | |
2244 | } else { | |
2245 | /* fw mechanism */ | |
2246 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2247 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2248 | tdma_duration_adjust(btcoexist, false, false, 1); | |
2249 | else | |
2250 | tdma_duration_adjust(btcoexist, false, true, 1); | |
2251 | ||
2252 | /* sw mechanism */ | |
2253 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2254 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2255 | sw_mechanism1(btcoexist, false, false, false, false); | |
2256 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2257 | } else { | |
2258 | sw_mechanism1(btcoexist, false, false, false, false); | |
2259 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2260 | } | |
2261 | } | |
2262 | } | |
2263 | ||
2264 | static void halbtc8821a2ant_action_a2dp_pan_hs(struct btc_coexist *btcoexist) | |
2265 | { | |
2266 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2267 | u32 wifi_bw; | |
2268 | ||
2269 | bt_info_ext = coex_sta->bt_info_ext; | |
2270 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2271 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2272 | ||
2273 | /* fw dac swing is called in tdma_duration_adjust() */ | |
2274 | /* halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); */ | |
2275 | ||
2276 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2277 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2278 | else | |
2279 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2280 | ||
2281 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2282 | ||
2283 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2284 | /* fw mechanism */ | |
2285 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2286 | tdma_duration_adjust(btcoexist, false, true, 2); | |
2287 | else /* a2dp edr rate */ | |
2288 | tdma_duration_adjust(btcoexist, false, true, 1); | |
2289 | ||
2290 | /* sw mechanism */ | |
2291 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2292 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2293 | sw_mechanism1(btcoexist, true, false, false, false); | |
2294 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2295 | } else { | |
2296 | sw_mechanism1(btcoexist, true, false, false, false); | |
2297 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2298 | } | |
2299 | } else { | |
2300 | /* fw mechanism */ | |
2301 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2302 | tdma_duration_adjust(btcoexist, false, true, 2); | |
2303 | else /* a2dp edr rate */ | |
2304 | tdma_duration_adjust(btcoexist, false, true, 1); | |
2305 | ||
2306 | /* sw mechanism */ | |
2307 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2308 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2309 | sw_mechanism1(btcoexist, false, false, false, false); | |
2310 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2311 | } else { | |
2312 | sw_mechanism1(btcoexist, false, false, false, false); | |
2313 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2314 | } | |
2315 | } | |
2316 | } | |
2317 | ||
2318 | static void halbtc8821a2ant_action_pan_edr(struct btc_coexist *btcoexist) | |
2319 | { | |
2320 | u8 wifi_rssi_state, bt_rssi_state; | |
2321 | u32 wifi_bw; | |
2322 | ||
2323 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2324 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2325 | ||
2326 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2327 | ||
2328 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2329 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2330 | else | |
2331 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2332 | ||
2333 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2334 | ||
2335 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2336 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2337 | 0x5aff5aff, 0xffff, 0x3); | |
2338 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2339 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2340 | 0x5aff5aff, 0xffff, 0x3); | |
2341 | ||
2342 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2343 | /* fw mechanism */ | |
2344 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2345 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2346 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); | |
2347 | else | |
2348 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
2349 | ||
2350 | /* sw mechanism */ | |
2351 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2352 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2353 | sw_mechanism1(btcoexist, true, false, false, false); | |
2354 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2355 | } else { | |
2356 | sw_mechanism1(btcoexist, true, false, false, false); | |
2357 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2358 | } | |
2359 | } else { | |
2360 | /* fw mechanism */ | |
2361 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2362 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2363 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 1); | |
2364 | else | |
2365 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 5); | |
2366 | ||
2367 | /* sw mechanism */ | |
2368 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2369 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2370 | sw_mechanism1(btcoexist, false, false, false, false); | |
2371 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2372 | } else { | |
2373 | sw_mechanism1(btcoexist, false, false, false, false); | |
2374 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2375 | } | |
2376 | } | |
2377 | } | |
2378 | ||
2379 | /* PAN(HS) only */ | |
2380 | static void halbtc8821a2ant_action_pan_hs(struct btc_coexist *btcoexist) | |
2381 | { | |
2382 | u8 wifi_rssi_state, bt_rssi_state; | |
2383 | u32 wifi_bw; | |
2384 | ||
2385 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2386 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2387 | ||
2388 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2389 | ||
2390 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2391 | ||
2392 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2393 | /* fw mechanism */ | |
2394 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2395 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2396 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2397 | true); | |
2398 | else | |
2399 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2400 | false); | |
2401 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
2402 | ||
2403 | /* sw mechanism */ | |
2404 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2405 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2406 | sw_mechanism1(btcoexist, true, false, false, false); | |
2407 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2408 | } else { | |
2409 | sw_mechanism1(btcoexist, true, false, false, false); | |
2410 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2411 | } | |
2412 | } else { | |
2413 | /* fw mechanism */ | |
2414 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2415 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2416 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2417 | true); | |
2418 | else | |
2419 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, | |
2420 | false); | |
2421 | ||
2422 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2423 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2424 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
2425 | else | |
2426 | ps21a_tdma(btcoexist, NORMAL_EXEC, false, 1); | |
2427 | ||
2428 | /* sw mechanism */ | |
2429 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2430 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2431 | sw_mechanism1(btcoexist, false, false, false, false); | |
2432 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2433 | } else { | |
2434 | sw_mechanism1(btcoexist, false, false, false, false); | |
2435 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2436 | } | |
2437 | } | |
2438 | } | |
2439 | ||
2440 | /* PAN(EDR)+A2DP */ | |
2441 | static void halbtc8821a2ant_action_pan_edr_a2dp(struct btc_coexist *btcoexist) | |
2442 | { | |
2443 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2444 | u32 wifi_bw; | |
2445 | ||
2446 | bt_info_ext = coex_sta->bt_info_ext; | |
2447 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2448 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2449 | ||
2450 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2451 | ||
2452 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2453 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2454 | else | |
2455 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2456 | ||
2457 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2458 | ||
2459 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2460 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2461 | 0x5afa5afa, 0xffff, 0x3); | |
2462 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2463 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2464 | 0x5afa5afa, 0xffff, 0x3); | |
2465 | ||
2466 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2467 | /* fw mechanism */ | |
2468 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2469 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2470 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2471 | tdma_duration_adjust(btcoexist, false, | |
2472 | false, 3); | |
2473 | else /* a2dp edr rate */ | |
2474 | tdma_duration_adjust(btcoexist, false, | |
2475 | false, 3); | |
2476 | } else { | |
2477 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2478 | tdma_duration_adjust(btcoexist, false, true, 3); | |
2479 | else /* a2dp edr rate */ | |
2480 | tdma_duration_adjust(btcoexist, false, true, 3); | |
2481 | } | |
2482 | ||
2483 | /* sw mechanism */ | |
2484 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2485 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2486 | sw_mechanism1(btcoexist, true, false, false, false); | |
2487 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2488 | } else { | |
2489 | sw_mechanism1(btcoexist, true, false, false, false); | |
2490 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2491 | }; | |
2492 | } else { | |
2493 | /* fw mechanism */ | |
2494 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2495 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2496 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2497 | tdma_duration_adjust(btcoexist, false, | |
2498 | false, 3); | |
2499 | else /* a2dp edr rate */ | |
2500 | tdma_duration_adjust(btcoexist, false, | |
2501 | false, 3); | |
2502 | } else { | |
2503 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2504 | tdma_duration_adjust(btcoexist, false, true, 3); | |
2505 | else /* a2dp edr rate */ | |
2506 | tdma_duration_adjust(btcoexist, false, true, 3); | |
2507 | } | |
2508 | ||
2509 | /* sw mechanism */ | |
2510 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2511 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2512 | sw_mechanism1(btcoexist, false, false, false, false); | |
2513 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2514 | } else { | |
2515 | sw_mechanism1(btcoexist, false, false, false, false); | |
2516 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2517 | } | |
2518 | } | |
2519 | } | |
2520 | ||
2521 | static void halbtc8821a2ant_action_pan_edr_hid(struct btc_coexist *btcoexist) | |
2522 | { | |
2523 | u8 wifi_rssi_state, bt_rssi_state; | |
2524 | u32 wifi_bw; | |
2525 | ||
2526 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2527 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2528 | ||
2529 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2530 | ||
2531 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2532 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2533 | else | |
2534 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2535 | ||
2536 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2537 | ||
2538 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2539 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2540 | 0x5a5f5a5f, 0xffff, 0x3); | |
2541 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2542 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2543 | 0x5a5f5a5f, 0xffff, 0x3); | |
2544 | ||
2545 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2546 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 3); | |
2547 | /* fw mechanism */ | |
2548 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2549 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2550 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
2551 | else | |
2552 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
2553 | ||
2554 | /* sw mechanism */ | |
2555 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2556 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2557 | sw_mechanism1(btcoexist, true, true, false, false); | |
2558 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2559 | } else { | |
2560 | sw_mechanism1(btcoexist, true, true, false, false); | |
2561 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2562 | } | |
2563 | } else { | |
2564 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2565 | /* fw mechanism */ | |
2566 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2567 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) | |
2568 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 10); | |
2569 | else | |
2570 | ps21a_tdma(btcoexist, NORMAL_EXEC, true, 14); | |
2571 | ||
2572 | /* sw mechanism */ | |
2573 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2574 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2575 | sw_mechanism1(btcoexist, false, true, false, false); | |
2576 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2577 | } else { | |
2578 | sw_mechanism1(btcoexist, false, true, false, false); | |
2579 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2580 | } | |
2581 | } | |
2582 | } | |
2583 | ||
2584 | /* HID+A2DP+PAN(EDR) */ | |
2585 | static void action_hid_a2dp_pan_edr(struct btc_coexist *btcoexist) | |
2586 | { | |
2587 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2588 | u32 wifi_bw; | |
2589 | ||
2590 | bt_info_ext = coex_sta->bt_info_ext; | |
2591 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2592 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2593 | ||
2594 | halbtc8821a2ant_fw_dac_swing_lvl(btcoexist, NORMAL_EXEC, 6); | |
2595 | ||
2596 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2597 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2598 | else | |
2599 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2600 | ||
2601 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2602 | ||
2603 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2604 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2605 | 0x5a5a5a5a, 0xffff, 0x3); | |
2606 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2607 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2608 | 0x5a5a5a5a, 0xffff, 0x3); | |
2609 | ||
2610 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2611 | /* fw mechanism */ | |
2612 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2613 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2614 | if (bt_info_ext & BIT(0)) { /* a2dp basic rate */ | |
2615 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2616 | } else { | |
2617 | /* a2dp edr rate */ | |
2618 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2619 | } | |
2620 | } else { | |
2621 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2622 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2623 | else /* a2dp edr rate */ | |
2624 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2625 | } | |
2626 | ||
2627 | /* sw mechanism */ | |
2628 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2629 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2630 | sw_mechanism1(btcoexist, true, true, false, false); | |
2631 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2632 | } else { | |
2633 | sw_mechanism1(btcoexist, true, true, false, false); | |
2634 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2635 | } | |
2636 | } else { | |
2637 | /* fw mechanism */ | |
2638 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2639 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2640 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2641 | tdma_duration_adjust(btcoexist, true, false, 3); | |
2642 | else /* a2dp edr rate */ | |
2643 | tdma_duration_adjust(btcoexist, true, false, 3); | |
2644 | } else { | |
2645 | if (bt_info_ext & BIT(0)) { | |
2646 | /* a2dp basic rate */ | |
2647 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2648 | } else /* a2dp edr rate */ { | |
2649 | tdma_duration_adjust(btcoexist, true, true, 3); | |
2650 | } | |
2651 | } | |
2652 | ||
2653 | /* sw mechanism */ | |
2654 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2655 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2656 | sw_mechanism1(btcoexist, false, true, false, false); | |
2657 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2658 | } else { | |
2659 | sw_mechanism1(btcoexist, false, true, false, false); | |
2660 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2661 | } | |
2662 | } | |
2663 | } | |
2664 | ||
2665 | static void halbtc8821a2ant_action_hid_a2dp(struct btc_coexist *btcoexist) | |
2666 | { | |
2667 | u8 wifi_rssi_state, bt_rssi_state, bt_info_ext; | |
2668 | u32 wifi_bw; | |
2669 | ||
2670 | bt_info_ext = coex_sta->bt_info_ext; | |
2671 | wifi_rssi_state = wifi21a_rssi_state(btcoexist, 0, 2, 15, 0); | |
2672 | bt_rssi_state = halbtc8821a2ant_bt_rssi_state(2, 35, 0); | |
2673 | ||
2674 | if (halbtc8821a2ant_need_to_dec_bt_pwr(btcoexist)) | |
2675 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, true); | |
2676 | else | |
2677 | halbtc8821a2ant_dec_bt_pwr(btcoexist, NORMAL_EXEC, false); | |
2678 | ||
2679 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2680 | ||
2681 | if (BTC_WIFI_BW_LEGACY == wifi_bw) /* for HID at 11b/g mode */ | |
2682 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2683 | 0x5f5b5f5b, 0xffffff, 0x3); | |
2684 | else /* for HID quality & wifi performance balance at 11n mode */ | |
2685 | halbtc8821a2ant_coex_table(btcoexist, NORMAL_EXEC, 0x55ff55ff, | |
2686 | 0x5f5b5f5b, 0xffffff, 0x3); | |
2687 | ||
2688 | if (BTC_WIFI_BW_HT40 == wifi_bw) { | |
2689 | /* fw mechanism */ | |
2690 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2691 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2692 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2693 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2694 | else /* a2dp edr rate */ | |
2695 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2696 | } else { | |
2697 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2698 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2699 | else /* a2dp edr rate */ | |
2700 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2701 | } | |
2702 | ||
2703 | /* sw mechanism */ | |
2704 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2705 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2706 | sw_mechanism1(btcoexist, true, true, false, false); | |
2707 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2708 | } else { | |
2709 | sw_mechanism1(btcoexist, true, true, false, false); | |
2710 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2711 | } | |
2712 | } else { | |
2713 | /* fw mechanism */ | |
2714 | if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2715 | (bt_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2716 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2717 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2718 | else /* a2dp edr rate */ | |
2719 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2720 | } else { | |
2721 | if (bt_info_ext & BIT(0)) /* a2dp basic rate */ | |
2722 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2723 | else /* a2dp edr rate */ | |
2724 | tdma_duration_adjust(btcoexist, true, true, 2); | |
2725 | } | |
2726 | ||
2727 | /* sw mechanism */ | |
2728 | if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) || | |
2729 | (wifi_rssi_state == BTC_RSSI_STATE_STAY_HIGH)) { | |
2730 | sw_mechanism1(btcoexist, false, true, false, false); | |
2731 | sw_mechanism2(btcoexist, true, false, false, 0x18); | |
2732 | } else { | |
2733 | sw_mechanism1(btcoexist, false, true, false, false); | |
2734 | sw_mechanism2(btcoexist, false, false, false, 0x18); | |
2735 | } | |
2736 | } | |
2737 | } | |
2738 | ||
2739 | static void halbtc8821a2ant_run_coexist_mechanism(struct btc_coexist *btcoexist) | |
2740 | { | |
2741 | bool wifi_under_5g = false; | |
2742 | u8 algorithm = 0; | |
2743 | ||
2744 | if (btcoexist->manual_control) { | |
2745 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2746 | "[BTCoex], Manual control!!!\n"); | |
2747 | return; | |
2748 | } | |
2749 | ||
2750 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); | |
2751 | ||
2752 | if (wifi_under_5g) { | |
2753 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2754 | "[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n"); | |
2755 | halbtc8821a2ant_coex_under_5g(btcoexist); | |
2756 | return; | |
2757 | } | |
2758 | ||
2759 | algorithm = halbtc8821a2ant_action_algorithm(btcoexist); | |
2760 | if (coex_sta->c2h_bt_inquiry_page && | |
2761 | (BT_8821A_2ANT_COEX_ALGO_PANHS != algorithm)) { | |
2762 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2763 | "[BTCoex], BT is under inquiry/page scan !!\n"); | |
2764 | halbtc8821a2ant_bt_inquiry_page(btcoexist); | |
2765 | return; | |
2766 | } | |
2767 | ||
2768 | coex_dm->cur_algorithm = algorithm; | |
2769 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2770 | "[BTCoex], Algorithm = %d\n", coex_dm->cur_algorithm); | |
2771 | ||
2772 | if (halbtc8821a2ant_is_common_action(btcoexist)) { | |
2773 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2774 | "[BTCoex], Action 2-Ant common.\n"); | |
2775 | coex_dm->reset_tdma_adjust = true; | |
2776 | } else { | |
2777 | if (coex_dm->cur_algorithm != coex_dm->pre_algorithm) { | |
2778 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2779 | "[BTCoex], pre_algorithm =%d, cur_algorithm =%d\n", | |
2780 | coex_dm->pre_algorithm, | |
2781 | coex_dm->cur_algorithm); | |
2782 | coex_dm->reset_tdma_adjust = true; | |
2783 | } | |
2784 | switch (coex_dm->cur_algorithm) { | |
2785 | case BT_8821A_2ANT_COEX_ALGO_SCO: | |
2786 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2787 | "[BTCoex], Action 2-Ant, algorithm = SCO.\n"); | |
2788 | halbtc8821a2ant_action_sco(btcoexist); | |
2789 | break; | |
2790 | case BT_8821A_2ANT_COEX_ALGO_HID: | |
2791 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2792 | "[BTCoex], Action 2-Ant, algorithm = HID.\n"); | |
2793 | halbtc8821a2ant_action_hid(btcoexist); | |
2794 | break; | |
2795 | case BT_8821A_2ANT_COEX_ALGO_A2DP: | |
2796 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2797 | "[BTCoex], Action 2-Ant, algorithm = A2DP.\n"); | |
2798 | halbtc8821a2ant_action_a2dp(btcoexist); | |
2799 | break; | |
2800 | case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS: | |
2801 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2802 | "[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n"); | |
2803 | halbtc8821a2ant_action_a2dp_pan_hs(btcoexist); | |
2804 | break; | |
2805 | case BT_8821A_2ANT_COEX_ALGO_PANEDR: | |
2806 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2807 | "[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n"); | |
2808 | halbtc8821a2ant_action_pan_edr(btcoexist); | |
2809 | break; | |
2810 | case BT_8821A_2ANT_COEX_ALGO_PANHS: | |
2811 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2812 | "[BTCoex], Action 2-Ant, algorithm = HS mode.\n"); | |
2813 | halbtc8821a2ant_action_pan_hs(btcoexist); | |
2814 | break; | |
2815 | case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP: | |
2816 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2817 | "[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n"); | |
2818 | halbtc8821a2ant_action_pan_edr_a2dp(btcoexist); | |
2819 | break; | |
2820 | case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID: | |
2821 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2822 | "[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n"); | |
2823 | halbtc8821a2ant_action_pan_edr_hid(btcoexist); | |
2824 | break; | |
2825 | case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR: | |
2826 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2827 | "[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n"); | |
2828 | action_hid_a2dp_pan_edr(btcoexist); | |
2829 | break; | |
2830 | case BT_8821A_2ANT_COEX_ALGO_HID_A2DP: | |
2831 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2832 | "[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n"); | |
2833 | halbtc8821a2ant_action_hid_a2dp(btcoexist); | |
2834 | break; | |
2835 | default: | |
2836 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
2837 | "[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n"); | |
2838 | halbtc8821a2ant_coex_all_off(btcoexist); | |
2839 | break; | |
2840 | } | |
2841 | coex_dm->pre_algorithm = coex_dm->cur_algorithm; | |
2842 | } | |
2843 | } | |
2844 | ||
2845 | /* work around function start with wa_halbtc8821a2ant_ */ | |
2846 | /* extern function start with EXhalbtc8821a2ant_ */ | |
2847 | void ex_halbtc8821a2ant_init_hwconfig(struct btc_coexist *btcoexist) | |
2848 | { | |
2849 | u8 u1tmp = 0; | |
2850 | ||
2851 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
2852 | "[BTCoex], 2Ant Init HW Config!!\n"); | |
2853 | ||
2854 | /* backup rf 0x1e value */ | |
2855 | coex_dm->bt_rf0x1e_backup = | |
2856 | btcoexist->btc_get_rf_reg(btcoexist, BTC_RF_A, 0x1e, 0xfffff); | |
2857 | ||
2858 | /* 0x790[5:0] = 0x5 */ | |
2859 | u1tmp = btcoexist->btc_read_1byte(btcoexist, 0x790); | |
2860 | u1tmp &= 0xc0; | |
2861 | u1tmp |= 0x5; | |
2862 | btcoexist->btc_write_1byte(btcoexist, 0x790, u1tmp); | |
2863 | ||
2864 | /* Antenna config */ | |
2865 | halbtc8821a2ant_set_ant_path(btcoexist, BTC_ANT_WIFI_AT_MAIN, | |
2866 | true, false); | |
2867 | ||
2868 | /* PTA parameter */ | |
2869 | halbtc8821a2ant_coex_table(btcoexist, FORCE_EXEC, | |
2870 | 0x55555555, 0x55555555, | |
2871 | 0xffff, 0x3); | |
2872 | ||
2873 | /* Enable counter statistics */ | |
2874 | /* 0x76e[3] = 1, WLAN_Act control by PTA */ | |
2875 | btcoexist->btc_write_1byte(btcoexist, 0x76e, 0xc); | |
2876 | btcoexist->btc_write_1byte(btcoexist, 0x778, 0x3); | |
2877 | btcoexist->btc_write_1byte_bitmask(btcoexist, 0x40, 0x20, 0x1); | |
2878 | } | |
2879 | ||
2880 | void ex_halbtc8821a2ant_init_coex_dm(struct btc_coexist *btcoexist) | |
2881 | { | |
2882 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
2883 | "[BTCoex], Coex Mechanism Init!!\n"); | |
2884 | ||
2885 | halbtc8821a2ant_init_coex_dm(btcoexist); | |
2886 | } | |
2887 | ||
2888 | void ex_halbtc8821a2ant_display_coex_info(struct btc_coexist *btcoexist) | |
2889 | { | |
2890 | struct btc_board_info *board_info = &btcoexist->board_info; | |
2891 | struct btc_stack_info *stack_info = &btcoexist->stack_info; | |
2892 | u8 *cli_buf = btcoexist->cli_buf; | |
2893 | u8 u1tmp[4], i, bt_info_ext, ps_tdma_case = 0; | |
2894 | u32 u4tmp[4]; | |
2895 | bool roam = false, scan = false, link = false, wifi_under_5g = false; | |
2896 | bool bt_hs_on = false, wifi_busy = false; | |
2897 | long wifi_rssi = 0, bt_hs_rssi = 0; | |
2898 | u32 wifi_bw, wifi_traffic_dir; | |
2899 | u8 wifi_dot_11_chnl, wifi_hs_chnl; | |
2900 | u32 fw_ver = 0, bt_patch_ver = 0; | |
2901 | ||
2902 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
2903 | "\n ============[BT Coexist info] ============"); | |
2904 | CL_PRINTF(cli_buf); | |
2905 | ||
2906 | if (!board_info->bt_exist) { | |
2907 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n BT not exists !!!"); | |
2908 | CL_PRINTF(cli_buf); | |
2909 | return; | |
2910 | } | |
2911 | ||
2912 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d ", | |
2913 | "Ant PG number/ Ant mechanism: ", | |
2914 | board_info->pg_ant_num, board_info->btdm_ant_num); | |
2915 | CL_PRINTF(cli_buf); | |
2916 | ||
2917 | if (btcoexist->manual_control) { | |
2918 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", | |
2919 | "[Action Manual control]!!"); | |
2920 | CL_PRINTF(cli_buf); | |
2921 | } | |
2922 | ||
2923 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %d", | |
2924 | "BT stack/ hci ext ver", | |
2925 | ((stack_info->profile_notified) ? "Yes" : "No"), | |
2926 | stack_info->hci_version); | |
2927 | CL_PRINTF(cli_buf); | |
2928 | ||
2929 | btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver); | |
2930 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); | |
2931 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", | |
2932 | "CoexVer/ FwVer/ PatchVer", | |
2933 | glcoex_ver_date_8821a_2ant, glcoex_ver_8821a_2ant, | |
2934 | fw_ver, bt_patch_ver, bt_patch_ver); | |
2935 | CL_PRINTF(cli_buf); | |
2936 | ||
2937 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
2938 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_DOT11_CHNL, | |
2939 | &wifi_dot_11_chnl); | |
2940 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifi_hs_chnl); | |
2941 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d / %d(%d)", | |
2942 | "Dot11 channel / HsMode(HsChnl)", | |
2943 | wifi_dot_11_chnl, bt_hs_on, wifi_hs_chnl); | |
2944 | CL_PRINTF(cli_buf); | |
2945 | ||
2946 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
2947 | "\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", | |
2948 | coex_dm->wifi_chnl_info[0], coex_dm->wifi_chnl_info[1], | |
2949 | coex_dm->wifi_chnl_info[2]); | |
2950 | CL_PRINTF(cli_buf); | |
2951 | ||
2952 | btcoexist->btc_get(btcoexist, BTC_GET_S4_WIFI_RSSI, &wifi_rssi); | |
2953 | btcoexist->btc_get(btcoexist, BTC_GET_S4_HS_RSSI, &bt_hs_rssi); | |
2954 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
2955 | "\n %-35s = %ld/ %ld", "Wifi rssi/ HS rssi", | |
2956 | wifi_rssi, bt_hs_rssi); | |
2957 | CL_PRINTF(cli_buf); | |
2958 | ||
2959 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_SCAN, &scan); | |
2960 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_LINK, &link); | |
2961 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_ROAM, &roam); | |
2962 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d ", | |
2963 | "Wifi link/ roam/ scan", | |
2964 | link, roam, scan); | |
2965 | CL_PRINTF(cli_buf); | |
2966 | ||
2967 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifi_under_5g); | |
2968 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
2969 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy); | |
2970 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, | |
2971 | &wifi_traffic_dir); | |
2972 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s / %s/ %s ", | |
2973 | "Wifi status", | |
2974 | (wifi_under_5g ? "5G" : "2.4G"), | |
2975 | ((BTC_WIFI_BW_LEGACY == wifi_bw) ? "Legacy" : | |
2976 | (((BTC_WIFI_BW_HT40 == wifi_bw) ? "HT40" : "HT20"))), | |
2977 | ((!wifi_busy) ? "idle" : | |
2978 | ((BTC_WIFI_TRAFFIC_TX == wifi_traffic_dir) ? "uplink" : | |
2979 | "downlink"))); | |
2980 | CL_PRINTF(cli_buf); | |
2981 | ||
2982 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = [%s/ %d/ %d] ", | |
2983 | "BT [status/ rssi/ retryCnt]", | |
2984 | ((coex_sta->c2h_bt_inquiry_page) ? ("inquiry/page scan") : | |
2985 | ((BT_8821A_2ANT_BT_STATUS_IDLE == coex_dm->bt_status) ? | |
2986 | "idle" : ((BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == | |
2987 | coex_dm->bt_status) ? "connected-idle" : "busy"))), | |
2988 | coex_sta->bt_rssi, coex_sta->bt_retry_cnt); | |
2989 | CL_PRINTF(cli_buf); | |
2990 | ||
2991 | if (stack_info->profile_notified) { | |
2992 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
2993 | "\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", | |
2994 | stack_info->sco_exist, stack_info->hid_exist, | |
2995 | stack_info->pan_exist, stack_info->a2dp_exist); | |
2996 | CL_PRINTF(cli_buf); | |
2997 | ||
2998 | btcoexist->btc_disp_dbg_msg(btcoexist, | |
2999 | BTC_DBG_DISP_BT_LINK_INFO); | |
3000 | } | |
3001 | ||
3002 | bt_info_ext = coex_sta->bt_info_ext; | |
3003 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s", | |
3004 | "BT Info A2DP rate", | |
3005 | (bt_info_ext & BIT(0)) ? "Basic rate" : "EDR rate"); | |
3006 | CL_PRINTF(cli_buf); | |
3007 | ||
3008 | for (i = 0; i < BT_INFO_SRC_8821A_2ANT_MAX; i++) { | |
3009 | if (coex_sta->bt_info_c2h_cnt[i]) { | |
3010 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3011 | "\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", | |
3012 | glbt_info_src_8821a_2ant[i], | |
3013 | coex_sta->bt_info_c2h[i][0], | |
3014 | coex_sta->bt_info_c2h[i][1], | |
3015 | coex_sta->bt_info_c2h[i][2], | |
3016 | coex_sta->bt_info_c2h[i][3], | |
3017 | coex_sta->bt_info_c2h[i][4], | |
3018 | coex_sta->bt_info_c2h[i][5], | |
3019 | coex_sta->bt_info_c2h[i][6], | |
3020 | coex_sta->bt_info_c2h_cnt[i]); | |
3021 | CL_PRINTF(cli_buf); | |
3022 | } | |
3023 | } | |
3024 | ||
3025 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %s/%s", | |
3026 | "PS state, IPS/LPS", | |
3027 | ((coex_sta->under_ips ? "IPS ON" : "IPS OFF")), | |
3028 | ((coex_sta->under_lps ? "LPS ON" : "LPS OFF"))); | |
3029 | CL_PRINTF(cli_buf); | |
3030 | btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); | |
3031 | ||
3032 | /* Sw mechanism */ | |
3033 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", | |
3034 | "============[Sw mechanism] ============"); | |
3035 | CL_PRINTF(cli_buf); | |
3036 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d/ %d ", | |
3037 | "SM1[ShRf/ LpRA/ LimDig/ btLna]", | |
3038 | coex_dm->cur_rf_rx_lpf_shrink, coex_dm->cur_low_penalty_ra, | |
3039 | coex_dm->limited_dig, coex_dm->cur_bt_lna_constrain); | |
3040 | CL_PRINTF(cli_buf); | |
3041 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d/ %d(0x%x) ", | |
3042 | "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", | |
3043 | coex_dm->cur_agc_table_en, coex_dm->cur_adc_back_off, | |
3044 | coex_dm->cur_dac_swing_on, coex_dm->cur_dac_swing_lvl); | |
3045 | CL_PRINTF(cli_buf); | |
3046 | ||
3047 | /* Fw mechanism */ | |
3048 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s", | |
3049 | "============[Fw mechanism] ============"); | |
3050 | CL_PRINTF(cli_buf); | |
3051 | ||
3052 | if (!btcoexist->manual_control) { | |
3053 | ps_tdma_case = coex_dm->cur_ps_tdma; | |
3054 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3055 | "\n %-35s = %02x %02x %02x %02x %02x case-%d", | |
3056 | "PS TDMA", | |
3057 | coex_dm->ps_tdma_para[0], coex_dm->ps_tdma_para[1], | |
3058 | coex_dm->ps_tdma_para[2], coex_dm->ps_tdma_para[3], | |
3059 | coex_dm->ps_tdma_para[4], ps_tdma_case); | |
3060 | CL_PRINTF(cli_buf); | |
3061 | ||
3062 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d ", | |
3063 | "DecBtPwr/ IgnWlanAct", | |
3064 | coex_dm->cur_dec_bt_pwr, | |
3065 | coex_dm->cur_ignore_wlan_act); | |
3066 | CL_PRINTF(cli_buf); | |
3067 | } | |
3068 | ||
3069 | /* Hw setting */ | |
3070 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3071 | "\n %-35s", "============[Hw setting] ============"); | |
3072 | CL_PRINTF(cli_buf); | |
3073 | ||
3074 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", | |
3075 | "RF-A, 0x1e initVal", | |
3076 | coex_dm->bt_rf0x1e_backup); | |
3077 | CL_PRINTF(cli_buf); | |
3078 | ||
3079 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x778); | |
3080 | u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0x6cc); | |
3081 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x ", | |
3082 | "0x778 (W_Act)/ 0x6cc (CoTab Sel)", | |
3083 | u1tmp[0], u1tmp[1]); | |
3084 | CL_PRINTF(cli_buf); | |
3085 | ||
3086 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x8db); | |
3087 | u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xc5b); | |
3088 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", | |
3089 | "0x8db(ADC)/0xc5b[29:25](DAC)", | |
3090 | ((u1tmp[0]&0x60)>>5), ((u1tmp[1]&0x3e)>>1)); | |
3091 | CL_PRINTF(cli_buf); | |
3092 | ||
3093 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xcb4); | |
3094 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", | |
3095 | "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", | |
3096 | u4tmp[0]&0xff, ((u4tmp[0]&0x30000000)>>28)); | |
3097 | CL_PRINTF(cli_buf); | |
3098 | ||
3099 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x40); | |
3100 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x4c); | |
3101 | u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x974); | |
3102 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3103 | "0x40/ 0x4c[24:23]/ 0x974", | |
3104 | u1tmp[0], ((u4tmp[0]&0x01800000)>>23), u4tmp[1]); | |
3105 | CL_PRINTF(cli_buf); | |
3106 | ||
3107 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x550); | |
3108 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x522); | |
3109 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", | |
3110 | "0x550(bcn ctrl)/0x522", | |
3111 | u4tmp[0], u1tmp[0]); | |
3112 | CL_PRINTF(cli_buf); | |
3113 | ||
3114 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xc50); | |
3115 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa0a); | |
3116 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x", | |
3117 | "0xc50(DIG)/0xa0a(CCK-TH)", | |
3118 | u4tmp[0], u1tmp[0]); | |
3119 | CL_PRINTF(cli_buf); | |
3120 | ||
3121 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0xf48); | |
3122 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0xa5b); | |
3123 | u1tmp[1] = btcoexist->btc_read_1byte(btcoexist, 0xa5c); | |
3124 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, | |
3125 | "\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA", | |
3126 | u4tmp[0], (u1tmp[0]<<8) + u1tmp[1]); | |
3127 | CL_PRINTF(cli_buf); | |
3128 | ||
3129 | u4tmp[0] = btcoexist->btc_read_4byte(btcoexist, 0x6c0); | |
3130 | u4tmp[1] = btcoexist->btc_read_4byte(btcoexist, 0x6c4); | |
3131 | u4tmp[2] = btcoexist->btc_read_4byte(btcoexist, 0x6c8); | |
3132 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x/ 0x%x/ 0x%x", | |
3133 | "0x6c0/0x6c4/0x6c8", | |
3134 | u4tmp[0], u4tmp[1], u4tmp[2]); | |
3135 | CL_PRINTF(cli_buf); | |
3136 | ||
3137 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", | |
3138 | "0x770 (hi-pri Rx/Tx)", | |
3139 | coex_sta->high_priority_rx, coex_sta->high_priority_tx); | |
3140 | CL_PRINTF(cli_buf); | |
3141 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = %d/ %d", | |
3142 | "0x774(low-pri Rx/Tx)", | |
3143 | coex_sta->low_priority_rx, coex_sta->low_priority_tx); | |
3144 | CL_PRINTF(cli_buf); | |
3145 | ||
3146 | /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang */ | |
3147 | u1tmp[0] = btcoexist->btc_read_1byte(btcoexist, 0x41b); | |
3148 | CL_SPRINTF(cli_buf, BT_TMP_BUF_SIZE, "\n %-35s = 0x%x", | |
3149 | "0x41b (mgntQ hang chk == 0xf)", | |
3150 | u1tmp[0]); | |
3151 | CL_PRINTF(cli_buf); | |
3152 | ||
3153 | btcoexist->btc_disp_dbg_msg(btcoexist, BTC_DBG_DISP_COEX_STATISTICS); | |
3154 | } | |
3155 | ||
3156 | void ex_halbtc8821a2ant_ips_notify(struct btc_coexist *btcoexist, u8 type) | |
3157 | { | |
3158 | if (BTC_IPS_ENTER == type) { | |
3159 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3160 | "[BTCoex], IPS ENTER notify\n"); | |
3161 | coex_sta->under_ips = true; | |
3162 | halbtc8821a2ant_coex_all_off(btcoexist); | |
3163 | } else if (BTC_IPS_LEAVE == type) { | |
3164 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3165 | "[BTCoex], IPS LEAVE notify\n"); | |
3166 | coex_sta->under_ips = false; | |
3167 | } | |
3168 | } | |
3169 | ||
3170 | void ex_halbtc8821a2ant_lps_notify(struct btc_coexist *btcoexist, u8 type) | |
3171 | { | |
3172 | if (BTC_LPS_ENABLE == type) { | |
3173 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3174 | "[BTCoex], LPS ENABLE notify\n"); | |
3175 | coex_sta->under_lps = true; | |
3176 | } else if (BTC_LPS_DISABLE == type) { | |
3177 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3178 | "[BTCoex], LPS DISABLE notify\n"); | |
3179 | coex_sta->under_lps = false; | |
3180 | } | |
3181 | } | |
3182 | ||
3183 | void ex_halbtc8821a2ant_scan_notify(struct btc_coexist *btcoexist, u8 type) | |
3184 | { | |
3185 | if (BTC_SCAN_START == type) | |
3186 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3187 | "[BTCoex], SCAN START notify\n"); | |
3188 | else if (BTC_SCAN_FINISH == type) | |
3189 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3190 | "[BTCoex], SCAN FINISH notify\n"); | |
3191 | } | |
3192 | ||
3193 | void ex_halbtc8821a2ant_connect_notify(struct btc_coexist *btcoexist, u8 type) | |
3194 | { | |
3195 | if (BTC_ASSOCIATE_START == type) | |
3196 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3197 | "[BTCoex], CONNECT START notify\n"); | |
3198 | else if (BTC_ASSOCIATE_FINISH == type) | |
3199 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3200 | "[BTCoex], CONNECT FINISH notify\n"); | |
3201 | } | |
3202 | ||
3203 | void ex_halbtc8821a2ant_media_status_notify(struct btc_coexist *btcoexist, | |
3204 | u8 type) | |
3205 | { | |
3206 | u8 h2c_parameter[3] = {0}; | |
3207 | u32 wifi_bw; | |
3208 | u8 wifi_central_chnl; | |
3209 | ||
3210 | if (BTC_MEDIA_CONNECT == type) | |
3211 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3212 | "[BTCoex], MEDIA connect notify\n"); | |
3213 | else | |
3214 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3215 | "[BTCoex], MEDIA disconnect notify\n"); | |
3216 | ||
3217 | /* only 2.4G we need to inform bt the chnl mask */ | |
3218 | btcoexist->btc_get(btcoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, | |
3219 | &wifi_central_chnl); | |
3220 | if ((BTC_MEDIA_CONNECT == type) && | |
3221 | (wifi_central_chnl <= 14)) { | |
3222 | h2c_parameter[0] = 0x1; | |
3223 | h2c_parameter[1] = wifi_central_chnl; | |
3224 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_BW, &wifi_bw); | |
3225 | if (BTC_WIFI_BW_HT40 == wifi_bw) | |
3226 | h2c_parameter[2] = 0x30; | |
3227 | else | |
3228 | h2c_parameter[2] = 0x20; | |
3229 | } | |
3230 | ||
3231 | coex_dm->wifi_chnl_info[0] = h2c_parameter[0]; | |
3232 | coex_dm->wifi_chnl_info[1] = h2c_parameter[1]; | |
3233 | coex_dm->wifi_chnl_info[2] = h2c_parameter[2]; | |
3234 | ||
3235 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, | |
3236 | "[BTCoex], FW write 0x66 = 0x%x\n", | |
3237 | h2c_parameter[0] << 16 | | |
3238 | h2c_parameter[1] << 8 | h2c_parameter[2]); | |
3239 | ||
3240 | btcoexist->btc_fill_h2c(btcoexist, 0x66, 3, h2c_parameter); | |
3241 | } | |
3242 | ||
3243 | void ex_halbtc8821a2ant_special_packet_notify(struct btc_coexist *btcoexist, | |
3244 | u8 type) | |
3245 | { | |
3246 | if (type == BTC_PACKET_DHCP) | |
3247 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3248 | "[BTCoex], DHCP Packet notify\n"); | |
3249 | } | |
3250 | ||
3251 | void ex_halbtc8821a2ant_bt_info_notify(struct btc_coexist *btcoexist, | |
3252 | u8 *tmp_buf, u8 length) | |
3253 | { | |
3254 | u8 bt_info = 0; | |
3255 | u8 i, rsp_source = 0; | |
3256 | static u32 set_bt_lna_cnt, set_bt_psd_mode; | |
3257 | bool bt_busy = false, limited_dig = false; | |
3258 | bool wifi_connected = false, bt_hs_on = false; | |
3259 | ||
3260 | coex_sta->c2h_bt_info_req_sent = false; | |
3261 | rsp_source = tmp_buf[0]&0xf; | |
3262 | if (rsp_source >= BT_INFO_SRC_8821A_2ANT_MAX) | |
3263 | rsp_source = BT_INFO_SRC_8821A_2ANT_WIFI_FW; | |
3264 | coex_sta->bt_info_c2h_cnt[rsp_source]++; | |
3265 | ||
3266 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, | |
3267 | "[BTCoex], Bt info[%d], length =%d, hex data =[", | |
3268 | rsp_source, length); | |
3269 | for (i = 0; i < length; i++) { | |
3270 | coex_sta->bt_info_c2h[rsp_source][i] = tmp_buf[i]; | |
3271 | if (i == 1) | |
3272 | bt_info = tmp_buf[i]; | |
3273 | if (i == length-1) | |
3274 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "0x%02x]\n", | |
3275 | tmp_buf[i]); | |
3276 | else | |
3277 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "0x%02x, ", | |
3278 | tmp_buf[i]); | |
3279 | } | |
3280 | ||
3281 | if (BT_INFO_SRC_8821A_2ANT_WIFI_FW != rsp_source) { | |
3282 | coex_sta->bt_retry_cnt = /* [3:0] */ | |
3283 | coex_sta->bt_info_c2h[rsp_source][2]&0xf; | |
3284 | coex_sta->bt_rssi = | |
3285 | coex_sta->bt_info_c2h[rsp_source][3]*2+10; | |
3286 | coex_sta->bt_info_ext = | |
3287 | coex_sta->bt_info_c2h[rsp_source][4]; | |
3288 | ||
3289 | /* Here we need to resend some wifi info to BT */ | |
3290 | /* because bt is reset and loss of the info. */ | |
3291 | if ((coex_sta->bt_info_ext & BIT(1))) { | |
3292 | btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED, | |
3293 | &wifi_connected); | |
3294 | if (wifi_connected) | |
3295 | ex_halbtc8821a2ant_media_status_notify(btcoexist, | |
3296 | BTC_MEDIA_CONNECT); | |
3297 | else | |
3298 | ex_halbtc8821a2ant_media_status_notify(btcoexist, | |
3299 | BTC_MEDIA_DISCONNECT); | |
3300 | ||
3301 | set_bt_psd_mode = 0; | |
3302 | } | |
3303 | if (set_bt_psd_mode <= 3) { | |
3304 | /* fix CH-BW mode */ | |
3305 | halbtc8821a2ant_set_bt_psd_mode(btcoexist, | |
3306 | FORCE_EXEC, 0x0); | |
3307 | set_bt_psd_mode++; | |
3308 | } | |
3309 | ||
3310 | if (coex_dm->cur_bt_lna_constrain) { | |
3311 | if (!(coex_sta->bt_info_ext & BIT(2))) { | |
3312 | if (set_bt_lna_cnt <= 3) { | |
3313 | set_bt_lna_constrain(btcoexist, | |
3314 | FORCE_EXEC, true); | |
3315 | set_bt_lna_cnt++; | |
3316 | } | |
3317 | } | |
3318 | } else { | |
3319 | set_bt_lna_cnt = 0; | |
3320 | } | |
3321 | ||
3322 | if ((coex_sta->bt_info_ext & BIT(3))) | |
3323 | halbtc8821a2ant_ignore_wlan_act(btcoexist, | |
3324 | FORCE_EXEC, false); | |
3325 | else | |
3326 | /* BT already NOT ignore Wlan active, do nothing here */ | |
3327 | ||
3328 | if (!(coex_sta->bt_info_ext & BIT(4))) | |
3329 | halbtc8821a2ant_bt_auto_report(btcoexist, | |
3330 | FORCE_EXEC, true); | |
3331 | } | |
3332 | ||
3333 | btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on); | |
3334 | /* check BIT(2) first ==> check if bt is under inquiry or page scan */ | |
3335 | if (bt_info & BT_INFO_8821A_2ANT_B_INQ_PAGE) { | |
3336 | coex_sta->c2h_bt_inquiry_page = true; | |
3337 | coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; | |
3338 | } else { | |
3339 | coex_sta->c2h_bt_inquiry_page = false; | |
3340 | if (bt_info == 0x1) { /* connection exists but not busy */ | |
3341 | coex_sta->bt_link_exist = true; | |
3342 | coex_dm->bt_status = | |
3343 | BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE; | |
3344 | } else if (bt_info & BT_INFO_8821A_2ANT_B_CONNECTION) { | |
3345 | /* connection exists and some link is busy */ | |
3346 | coex_sta->bt_link_exist = true; | |
3347 | if (bt_info & BT_INFO_8821A_2ANT_B_FTP) | |
3348 | coex_sta->pan_exist = true; | |
3349 | else | |
3350 | coex_sta->pan_exist = false; | |
3351 | if (bt_info & BT_INFO_8821A_2ANT_B_A2DP) | |
3352 | coex_sta->a2dp_exist = true; | |
3353 | else | |
3354 | coex_sta->a2dp_exist = false; | |
3355 | if (bt_info & BT_INFO_8821A_2ANT_B_HID) | |
3356 | coex_sta->hid_exist = true; | |
3357 | else | |
3358 | coex_sta->hid_exist = false; | |
3359 | if (bt_info & BT_INFO_8821A_2ANT_B_SCO_ESCO) | |
3360 | coex_sta->sco_exist = true; | |
3361 | else | |
3362 | coex_sta->sco_exist = false; | |
3363 | coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; | |
3364 | } else { | |
3365 | coex_sta->bt_link_exist = false; | |
3366 | coex_sta->pan_exist = false; | |
3367 | coex_sta->a2dp_exist = false; | |
3368 | coex_sta->hid_exist = false; | |
3369 | coex_sta->sco_exist = false; | |
3370 | coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_IDLE; | |
3371 | } | |
3372 | ||
3373 | if (bt_hs_on) | |
3374 | coex_dm->bt_status = BT_8821A_2ANT_BT_STATUS_NON_IDLE; | |
3375 | } | |
3376 | ||
3377 | if (BT_8821A_2ANT_BT_STATUS_NON_IDLE == coex_dm->bt_status) | |
3378 | bt_busy = true; | |
3379 | else | |
3380 | bt_busy = false; | |
3381 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy); | |
3382 | ||
3383 | if (BT_8821A_2ANT_BT_STATUS_IDLE != coex_dm->bt_status) | |
3384 | limited_dig = true; | |
3385 | else | |
3386 | limited_dig = false; | |
3387 | coex_dm->limited_dig = limited_dig; | |
3388 | btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_LIMITED_DIG, &limited_dig); | |
3389 | ||
3390 | halbtc8821a2ant_run_coexist_mechanism(btcoexist); | |
3391 | } | |
3392 | ||
3393 | void ex_halbtc8821a2ant_halt_notify(struct btc_coexist *btcoexist) | |
3394 | { | |
3395 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, "[BTCoex], Halt notify\n"); | |
3396 | ||
3397 | halbtc8821a2ant_ignore_wlan_act(btcoexist, FORCE_EXEC, true); | |
3398 | ex_halbtc8821a2ant_media_status_notify(btcoexist, BTC_MEDIA_DISCONNECT); | |
3399 | } | |
3400 | ||
3401 | void ex_halbtc8821a2ant_periodical(struct btc_coexist *btcoexist) | |
3402 | { | |
3403 | static u8 dis_ver_info_cnt; | |
3404 | u32 fw_ver = 0, bt_patch_ver = 0; | |
3405 | struct btc_board_info *board_info = &btcoexist->board_info; | |
3406 | struct btc_stack_info *stack_info = &btcoexist->stack_info; | |
3407 | ||
3408 | BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, | |
3409 | "[BTCoex], ========================== Periodical ===========================\n"); | |
3410 | ||
3411 | if (dis_ver_info_cnt <= 5) { | |
3412 | dis_ver_info_cnt += 1; | |
3413 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3414 | "[BTCoex], ****************************************************************\n"); | |
3415 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3416 | "[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", | |
3417 | board_info->pg_ant_num, board_info->btdm_ant_num, | |
3418 | board_info->btdm_ant_pos); | |
3419 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3420 | "[BTCoex], BT stack/ hci ext ver = %s / %d\n", | |
3421 | ((stack_info->profile_notified) ? "Yes" : "No"), | |
3422 | stack_info->hci_version); | |
3423 | btcoexist->btc_get(btcoexist, BTC_GET_U4_BT_PATCH_VER, | |
3424 | &bt_patch_ver); | |
3425 | btcoexist->btc_get(btcoexist, BTC_GET_U4_WIFI_FW_VER, &fw_ver); | |
3426 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3427 | "[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", | |
3428 | glcoex_ver_date_8821a_2ant, | |
3429 | glcoex_ver_8821a_2ant, | |
3430 | fw_ver, bt_patch_ver, bt_patch_ver); | |
3431 | BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, | |
3432 | "[BTCoex], ****************************************************************\n"); | |
3433 | } | |
3434 | ||
3435 | halbtc8821a2ant_query_bt_info(btcoexist); | |
3436 | halbtc8821a2ant_monitor_bt_ctr(btcoexist); | |
3437 | monitor_bt_enable_disable(btcoexist); | |
3438 | } |