VOID EXhalbtc8723a1ant_ConnectNotify( IN PBTC_COEXIST pBtCoexist, IN u1Byte type ) { BOOLEAN bWifiConnected=FALSE; if(pBtCoexist->btInfo.bBtDisabled) { halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); } else { if(BTC_ASSOCIATE_START == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n")); //set 0x550[3]=1 before PsTdma halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE); halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); // extend wifi slot } else if(BTC_ASSOCIATE_FINISH == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n")); pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); if(!bWifiConnected) { // non-connected scan halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); } else { halbtc8723a1ant_CoexForWifiConnect(pBtCoexist); } } } }
VOID halbtc8723a1ant_CoexTable( IN PBTC_COEXIST pBtCoexist, IN BOOLEAN bForceExec, IN u4Byte val0x6c0, IN u4Byte val0x6c8, IN u1Byte val0x6cc ) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc)); pCoexDm->curVal0x6c0 = val0x6c0; pCoexDm->curVal0x6c8 = val0x6c8; pCoexDm->curVal0x6cc = val0x6cc; if(!bForceExec) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n", pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc)); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n", pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc)); if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) return; } halbtc8723a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc); pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; }
VOID halbtc8723a1ant_MonitorBtCtr( IN PBTC_COEXIST pBtCoexist ) { u4Byte regHPTxRx, regLPTxRx, u4Tmp; u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; //u1Byte u1Tmp; regHPTxRx = 0x770; regLPTxRx = 0x774; u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); regHPTx = u4Tmp & bMaskLWord; regHPRx = (u4Tmp & bMaskHWord)>>16; u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); regLPTx = u4Tmp & bMaskLWord; regLPRx = (u4Tmp & bMaskHWord)>>16; pCoexSta->highPriorityTx = regHPTx; pCoexSta->highPriorityRx = regHPRx; pCoexSta->lowPriorityTx = regLPTx; pCoexSta->lowPriorityRx = regLPRx; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); // reset counter pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); }
void btinfo_evt_dump(struct btinfo_8761au *info) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"cid:0x%02x, len:%u\n", info->cid, info->len); if (info->len > 2) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL, "byte2:%s%s%s%s%s%s%s%s\n" , info->connection?"connection ":"" , info->scoe_sco?"scoe_sco ":"" , info->inq_page?"inq_page ":"" , info->acl_busy?"acl_busy ":"" , info->sco_busy?"sco_busy ":"" , info->hid?"hid ":"" , info->a2dp?"a2dp ":"" , info->ftp?"ftp":"" ); if (info->len > 3) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"retry_cnt:%u\n", info->retry_cnt); if (info->len > 4) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"rssi:%u\n", info->rssi); if (info->len > 5) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"byte5:%s%s\n" , info->esco_sco?"eSCO_SCO ":"" , info->master_slave?"Master_Slave ":""); }
VOID EXhalbtc8723a1ant_ScanNotify( IN PBTC_COEXIST pBtCoexist, IN u1Byte type ) { BOOLEAN bWifiConnected=FALSE; halbtc8723a1ant_NotifyFwScan(pBtCoexist, type); if(pBtCoexist->btInfo.bBtDisabled) { halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); } else { pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); if(BTC_SCAN_START == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")); if(!bWifiConnected) { // non-connected scan //set 0x550[3]=1 before PsTdma halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE); } halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); } else if(BTC_SCAN_FINISH == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")); if(!bWifiConnected) { // non-connected scan halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); } else { halbtc8723a1ant_CoexForWifiConnect(pBtCoexist); } } } }
VOID halbtc8723a1ant_MonitorBtCtr( IN PBTC_COEXIST pBtCoexist ) { u4Byte regHPTxRx, regLPTxRx, u4Tmp; u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; u1Byte u1Tmp; regHPTxRx = 0x770; regLPTxRx = 0x774; u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regHPTxRx); regHPTx = u4Tmp & MASKLWORD; regHPRx = (u4Tmp & MASKHWORD)>>16; u4Tmp = pBtCoexist->btc_read_4byte(pBtCoexist, regLPTxRx); regLPTx = u4Tmp & MASKLWORD; regLPRx = (u4Tmp & MASKHWORD)>>16; pCoexSta->highPriorityTx = regHPTx; pCoexSta->highPriorityRx = regHPRx; pCoexSta->lowPriorityTx = regLPTx; pCoexSta->lowPriorityRx = regLPRx; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); // reset counter pBtCoexist->btc_write_1byte(pBtCoexist, 0x76e, 0xc); }
VOID halbtc8723a1ant_MonitorBtEnableDisable( IN PBTC_COEXIST pBtCoexist ) { static BOOLEAN bPreBtDisabled=FALSE; static u4Byte btDisableCnt=0; BOOLEAN bBtActive=true, bBtDisabled=FALSE; // This function check if bt is disabled if( pCoexSta->highPriorityTx == 0 && pCoexSta->highPriorityRx == 0 && pCoexSta->lowPriorityTx == 0 && pCoexSta->lowPriorityRx == 0) { bBtActive = FALSE; } if( pCoexSta->highPriorityTx == 0xffff && pCoexSta->highPriorityRx == 0xffff && pCoexSta->lowPriorityTx == 0xffff && pCoexSta->lowPriorityRx == 0xffff) { bBtActive = FALSE; } if(bBtActive) { btDisableCnt = 0; bBtDisabled = FALSE; pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is enabled !!\n")); } else { btDisableCnt++; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], bt all counters=0, %d times!!\n", btDisableCnt)); if(btDisableCnt >= 2) { bBtDisabled = true; pBtCoexist->btc_set(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is disabled !!\n")); } } if(bPreBtDisabled != bBtDisabled) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], BT is from %s to %s!!\n", (bPreBtDisabled ? "disabled":"enabled"), (bBtDisabled ? "disabled":"enabled"))); bPreBtDisabled = bBtDisabled; if(!bBtDisabled) { halbtc8723a1ant_BtEnableAction(pBtCoexist); } else { pBtCoexist->btc_set(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); } } }
u8 rtl_btcoex_sendmsgbysocket(struct rtl_priv *rtlpriv, u8 *msg, u8 msg_size, bool force) { //u8 i; u8 error; struct msghdr udpmsg; mm_segment_t oldfs; struct iovec iov; struct bt_coex_info *pcoex_info = &rtlpriv->coex_info; if(false == force) { if(false == pcoex_info->BT_attend) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"TX Blocked: WiFi-BT disconnected\n"); return _FAIL; } } BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"<<<<<<<<<<<<<<<<<<<<<<<<WIFI_TO_BT,msg:%s\n",msg); /********test code*********** for(i =0;i<msg_size;i++) printk("%02x",msg[i]); printk("\n"); *******************/ iov.iov_base = (void *)msg; iov.iov_len = msg_size; udpmsg.msg_name = &pcoex_info->bt_addr; udpmsg.msg_namelen = sizeof(struct sockaddr_in); #if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 18, 0)) udpmsg.msg_iov = &iov; udpmsg.msg_iovlen = 1; #endif udpmsg.msg_control = NULL; udpmsg.msg_controllen = 0; udpmsg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; udpmsg.msg_flags = 0; oldfs = get_fs(); set_fs(KERNEL_DS); #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) error = sock_sendmsg(pcoex_info->udpsock, &udpmsg, msg_size); #else error = sock_sendmsg(pcoex_info->udpsock, &udpmsg); #endif set_fs(oldfs); if(error < 0) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"Error when sendimg msg, error:%d\n",error); return _FAIL; } return _SUCCESS; }
VOID EXhalbtc8723a1ant_MediaStatusNotify( IN PBTC_COEXIST pBtCoexist, IN u1Byte type ) { if(BTC_MEDIA_CONNECT == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n")); } else { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n")); } }
VOID halbtc8723a1ant_SetFwPstdma( IN PBTC_COEXIST pBtCoexist, IN u1Byte type, IN u1Byte byte1, IN u1Byte byte2, IN u1Byte byte3, IN u1Byte byte4, IN u1Byte byte5 ) { u1Byte H2C_Parameter[5] ={0}; u1Byte realByte1=byte1, realByte5=byte5; BOOLEAN bApEnable=FALSE; pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); // byte1[1:0] != 0 means enable pstdma // for 2Ant bt coexist, if byte1 != 0 means enable pstdma if(byte1) { if(bApEnable) { if(type != 5 && type != 12) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n")); realByte1 &= ~BIT4; realByte1 |= BIT5; realByte5 |= BIT5; realByte5 &= ~BIT6; } } } H2C_Parameter[0] = realByte1; H2C_Parameter[1] = byte2; H2C_Parameter[2] = byte3; H2C_Parameter[3] = byte4; H2C_Parameter[4] = realByte5; pCoexDm->psTdmaPara[0] = realByte1; pCoexDm->psTdmaPara[1] = byte2; pCoexDm->psTdmaPara[2] = byte3; pCoexDm->psTdmaPara[3] = byte4; pCoexDm->psTdmaPara[4] = realByte5; BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n", H2C_Parameter[0], H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); pBtCoexist->btc_fill_h2c(pBtCoexist, 0x3a, 5, H2C_Parameter); }
VOID EXhalbtc8723a1ant_LpsNotify( IN PBTC_COEXIST pBtCoexist, IN u1Byte type ) { if(BTC_LPS_ENABLE == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n")); } else if(BTC_LPS_DISABLE == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n")); halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); } }
VOID EXhalbtc8723a1ant_IpsNotify( IN PBTC_COEXIST pBtCoexist, IN u1Byte type ) { if(BTC_IPS_ENTER == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n")); halbtc8723a1ant_CoexAllOff(pBtCoexist); } else if(BTC_IPS_LEAVE == type) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n")); //halbtc8723a1ant_InitCoexDm(pBtCoexist); } }
void rtl_btcoex_dump_tx_msg(u8 *tx_msg, u8 len, u8 *msg_name) { u8 i = 0; return; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"_%s\n",msg_name); for(i=0;i<len;i++) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"%02x ",tx_msg[i]); BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"\n"); }
//============================================================ // extern function start with EXhalbtc8723a1ant_ //============================================================ VOID EXhalbtc8723a1ant_InitHwConfig( IN PBTC_COEXIST pBtCoexist ) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n")); // backup rf 0x1e value pCoexDm->btRf0x1eBackup = pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); // enable counter statistics pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); // coex table pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); // 1-Ant coex pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); // wifi break table pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); //coex table // antenna switch control parameter pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0xaaaaaaaa); pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210); //set antenna at wifi side if ANTSW is software control pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x870, 0x300); //SPDT(connected with TRSW) control by hardware PTA pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x874, 0x22804000); //ANTSW keep by GNT_BT // coexistence parameters pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); // enable RTK mode PTA }
void rtl_btcoex_close_kernel_socket(struct rtl_priv *rtlpriv) { struct bt_coex_info *pcoex_info = &rtlpriv->coex_info; if(pcoex_info->sock_open & KERNEL_SOCKET_OK) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"release kernel socket\n"); cancel_delayed_work(&rtlpriv->works.socket_wq); sock_release(pcoex_info->udpsock); pcoex_info->sock_open &= ~(KERNEL_SOCKET_OK); if(true == pcoex_info->BT_attend) pcoex_info->BT_attend = false; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"sock_open:%d, BT_attend:%d\n",pcoex_info ->sock_open,pcoex_info ->BT_attend); } }
u8 rtl_send_complete_event_to_BT(struct rtl_priv *rtlpriv,RTW_HCI_EXT_CMD BT_RELATED_CMD,RTL_HCI_STATUS status) { rtl_hci_event *hci_event; u8 local_buf[6] = ""; u8 len=0,tx_event_length = 0; u8 *ret_par; u8 *event_data = NULL; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"#LEVEL_END,rtl_send_complete_event_to_BT\n"); hci_event = (rtl_hci_event*)(&local_buf[0]); event_data = hci_event->data; hci_event->event_code = HCI_EVENT_COMMAND_COMPLETE; *event_data = 0x1; *(event_data + 1) = HCIOPCODELOW(BT_RELATED_CMD, OGF_EXTENSION); *(event_data + 2) = HCIOPCODEHIGHT(BT_RELATED_CMD, OGF_EXTENSION); len = len + 3; ret_par = &hci_event->data[len]; ret_par[0] = status; len++; hci_event->length = len; //total tx event length + event_code length + sizeof(length) tx_event_length = hci_event->length + 2; rtl_btcoex_dump_tx_msg((u8 *)hci_event, tx_event_length,"rtl_send_complete_event_to_BT"); status = rtl_btcoex_sendmsgbysocket(rtlpriv,(u8 *)hci_event, tx_event_length,false); return status; }
void rtl_btcoex_SendEventExtBtCoexControl(struct rtl_priv *rtlpriv, u8 bNeedDbgRsp, u8 dataLen, void *pData) { u8 len=0, tx_event_length = 0; u8 local_buf[32] = ""; u8 *ret_par; u8 opCode=0; u8 *pInBuf=(u8 *)pData; rtl_hci_event *hci_event; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"#LEVEL_WIFI_ACTIVE,SendEventExtBtCoexControl\n"); opCode = pInBuf[0]; hci_event = (rtl_hci_event*)(&local_buf[0]); hci_event->event_code = HCI_EVENT_EXTENSION_RTK; hci_event->data[0] = HCI_EVENT_EXT_BT_COEX_CONTROL; //extension event code len ++; ret_par = hci_event->data + len; memcpy(&ret_par[0], pData, dataLen); /*maybe not safe here*/ len += dataLen; hci_event->length = len; //total tx event length + event_code length + sizeof(length) tx_event_length = hci_event->length + 2; rtl_btcoex_dump_tx_msg((u8 *)hci_event, tx_event_length, "BT COEX CONTROL"); rtl_btcoex_sendmsgbysocket(rtlpriv,(u8 *)hci_event, tx_event_length,false); }
VOID halbtc8723a1ant_SetCoexTable( IN PBTC_COEXIST pBtCoexist, IN u4Byte val0x6c0, IN u4Byte val0x6c8, IN u1Byte val0x6cc ) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); }
VOID EXhalbtc8723a1ant_InitCoexDm( IN PBTC_COEXIST pBtCoexist ) { BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n")); halbtc8723a1ant_InitCoexDm(pBtCoexist); }
void rtl_btcoex_init_socket(struct rtl_priv *rtlpriv) { u8 is_invite = false; struct bt_coex_info *pcoex_info = &rtlpriv->coex_info; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"8812AE:init socket with 8761AU\n"); INIT_DELAYED_WORK(&rtlpriv->works.socket_wq, (void *)rtl_btcoex_recvmsgbysocket); if(false == pcoex_info->is_exist) { memset(pcoex_info,0,sizeof(struct bt_coex_info)); pbtcoexadapter = rtlpriv; //rtl_btcoex_create_nl_socket(padapter); rtl_btcoex_create_kernel_socket(rtlpriv,is_invite); pcoex_info->is_exist = true; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"set coex_info->is_exist: %d\n",pcoex_info->is_exist); } }
VOID halbtc8723a1ant_SetSwRfRxLpfCorner( IN PBTC_COEXIST pBtCoexist, IN BOOLEAN bRxRfShrinkOn ) { if(bRxRfShrinkOn) { //Shrink RF Rx LPF corner BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7); } else { //Resume RF Rx LPF corner // After initialized, we can use pCoexDm->btRf0x1eBackup if(pBtCoexist->bInitilized) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n")); pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); } } }
void * safe_memcpy (void * dest, const void *src, u32 n , u32 max_len) { if(n > max_len) { memcpy(dest, src, max_len); BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"critical error in memcpy!\n"); } else { /*ok case*/ memcpy(dest,src, n); } return NULL; }
VOID halbtc8723a1ant_SetSwPenaltyTxRateAdaptive( IN PBTC_COEXIST pBtCoexist, IN BOOLEAN bLowPenaltyRa ) { u1Byte tmpU1; tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); tmpU1 |= BIT0; if(bLowPenaltyRa) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); tmpU1 &= ~BIT2; } else { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Tx rate adaptive, set normal!!\n")); tmpU1 |= BIT2; } pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); }
u8 rtl_btcoex_parse_BT_patch_ver_info_cmd(struct rtl_priv *rtlpriv, u8 *pcmd, u16 cmdlen) { RTL_HCI_STATUS status=HCI_STATUS_SUCCESS; u16 btPatchVer=0x0, btHciVer=0x0; btHciVer = pcmd[0] | pcmd[1]<<8; btPatchVer = pcmd[2] | pcmd[3]<<8; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"%s, cmd:%02x %02x %02x %02x\n", __func__,pcmd[0] ,pcmd[1] ,pcmd[2] ,pcmd[3]); BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"%s, HCI Ver:%d, Patch Ver:%d\n", __func__, btHciVer,btPatchVer); rtlpriv->btcoexist.btc_ops->btc_set_bt_patch_version(btHciVer, btPatchVer); return rtl_send_complete_event_to_BT(rtlpriv,HCI_BT_PATCH_VERSION_NOTIFY,status); }
u8 rtl_btcoex_create_kernel_socket(struct rtl_priv *rtlpriv, u8 is_invite) { s8 kernel_socket_err; struct bt_coex_info *pcoex_info = &rtlpriv->coex_info; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"%s CONNECT_PORT %d\n",__func__,CONNECT_PORT); if(NULL == pcoex_info) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"coex_info: NULL\n"); return _FAIL; } kernel_socket_err = sock_create(PF_INET, SOCK_DGRAM, 0, &pcoex_info->udpsock); BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"binding socket,err= %d\n",kernel_socket_err); if (kernel_socket_err<0) { BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"Error during creation of socket error:%d\n",kernel_socket_err); return _FAIL; } else { memset(&(pcoex_info->sin), 0, sizeof(pcoex_info->sin)); pcoex_info->sin.sin_family = AF_INET; pcoex_info->sin.sin_port = htons(CONNECT_PORT); pcoex_info->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); memset(&(pcoex_info->bt_addr), 0, sizeof(pcoex_info->bt_addr)); pcoex_info->bt_addr.sin_family = AF_INET; pcoex_info->bt_addr.sin_port = htons(CONNECT_PORT_BT); pcoex_info->bt_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); pcoex_info->sk_store = NULL; kernel_socket_err = pcoex_info->udpsock->ops->bind(pcoex_info->udpsock,(struct sockaddr *)&pcoex_info->sin,sizeof(pcoex_info->sin)); if(kernel_socket_err == 0){ BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"binding socket success\n"); pcoex_info->udpsock->sk->sk_data_ready = rtl_btcoex_recvmsg_int; pcoex_info->sock_open |= KERNEL_SOCKET_OK; pcoex_info->BT_attend = false; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"WIFI sending attend_req\n"); rtl_btcoex_sendmsgbysocket(rtlpriv,attend_req,sizeof(attend_req),true); return _SUCCESS; } else { pcoex_info->BT_attend = false; sock_release(pcoex_info->udpsock); BTC_PRINT(BTC_MSG_SOCKET, SOCKET_CRITICAL,"Error binding socket: %d\n",kernel_socket_err); return _FAIL; } } }
u8 rtl_btcoex_parse_HCI_Ver_notify_cmd(struct rtl_priv *rtlpriv, u8 *pcmd, u16 cmdlen) { RTL_HCI_STATUS status=HCI_STATUS_SUCCESS; u16 hciver = pcmd[0] | pcmd[1] <<8; struct bt_coex_info *pcoex_info = &rtlpriv->coex_info; PBT_MGNT bt_mgnt=&pcoex_info->BtMgnt; bt_mgnt->ext_config.hci_extension_ver = hciver; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"%s, HCI Version: %d\n",__func__,bt_mgnt->ext_config.hci_extension_ver); if(bt_mgnt->ext_config.hci_extension_ver < 4) { status = HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"%s, Version = %d, HCI Version < 4\n", __func__,bt_mgnt->ext_config.hci_extension_ver); } else { rtlpriv->btcoexist.btc_ops->btc_set_hci_version(hciver); } return rtl_send_complete_event_to_BT(rtlpriv,HCI_EXTENSION_VERSION_NOTIFY,status); }
void rtl_btcoex_parse_hci_cmd(struct rtl_priv *rtlpriv, u8 *pcmd, u16 len) { u16 opcode = pcmd[0] | pcmd[1]<<8; u16 hci_OGF = HCI_OGF(opcode); u16 hci_OCF = HCI_OCF(opcode); u8 cmdlen = len -3; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"#LEVEL1,OGF: %x,OCF: %x\n",hci_OGF,hci_OCF); switch(hci_OGF) { case OGF_EXTENSION: BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"#LEVEL1,HCI_EXTENSION_CMD_OGF\n"); rtl_btcoex_parse_hci_extend_cmd(rtlpriv, &pcmd[3], cmdlen, hci_OCF); break; default: BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"#LEVEL1,Other OGF: %x\n",hci_OGF); break; } }
u16 rtl_btcoex_parse_recv_data(u8 *msg, u8 msg_size) { u8 *cmp_msg1 = attend_ack; u8 *cmp_msg2 = leave_ack; u8 *cmp_msg3 = bt_leave; u8 *cmp_msg4 = invite_req; u8 *cmp_msg5 = attend_req; u8 *cmp_msg6 = invite_rsp; u8 res = OTHER; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,"\n>>>>>>>>>>>>>>>>>>>>>>>BT_TO_WIFI"); if(memcmp(cmp_msg1,msg,msg_size) == 0) { res = RX_ATTEND_ACK; } else if(memcmp(cmp_msg2,msg,msg_size) == 0) { res = RX_LEAVE_ACK; } else if(memcmp(cmp_msg3,msg,msg_size) == 0) { res = RX_BT_LEAVE; } else if(memcmp(cmp_msg4,msg,msg_size) == 0) { res = RX_INVITE_REQ; } else if(memcmp(cmp_msg5,msg,msg_size) == 0) { res = RX_ATTEND_REQ; } else if(memcmp(cmp_msg6,msg,msg_size) == 0) { res = RX_INVITE_RSP; } else { /*DBG_871X("%s, OGF|OCF:%02x%02x\n",__func__,msg[1],msg[0]);*/ res = OTHER; BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,",other_cmd!\n"); } if(OTHER != res) BTC_PRINT(BTC_MSG_SOCKET, SOCKET_NORMAL,",base_cmd:%s\n",msg); return res; }
VOID halbtc8723a1ant_IgnoreWlanAct( IN PBTC_COEXIST pBtCoexist, IN BOOLEAN bForceExec, IN BOOLEAN bEnable ) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n", (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); pCoexDm->bCurIgnoreWlanAct = bEnable; if(!bForceExec) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct)); if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) return; } halbtc8723a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; }
VOID halbtc8723a1ant_RfShrink( IN PBTC_COEXIST pBtCoexist, IN BOOLEAN bForceExec, IN BOOLEAN bRxRfShrinkOn ) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n", (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; if(!bForceExec) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n", pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink)); if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) return; } halbtc8723a1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; }