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