1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 *published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
15 #include <drv_types.h>
16 #include <rtl8723a_hal.h>
17 #include <usb_ops_linux.h>
21 u32 BTCoexDbgLevel
= _bt_dbg_off_
;
23 #define RTPRINT(_Comp, _Level, Fmt)\
25 if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
30 #define RTPRINT_ADDR(dbgtype, dbgflag, printstr, _Ptr)\
31 if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
33 u8 *ptr = (u8 *)_Ptr; \
36 for (__i = 0; __i < 6; __i++) \
37 printk("%02X%s", ptr[__i], (__i == 5)?"":"-"); \
40 #define RTPRINT_DATA(dbgtype, dbgflag, _TitleString, _HexData, _HexDataLen)\
41 if ((BTCoexDbgLevel == _bt_dbg_on_)) {\
43 u8 *ptr = (u8 *)_HexData; \
44 printk(_TitleString); \
45 for (__i = 0; __i < (u32)_HexDataLen; __i++) { \
46 printk("%02X%s", ptr[__i], (((__i + 1) % 4) == 0)?" ":" ");\
47 if (((__i + 1) % 16) == 0) \
52 /* Added by Annie, 2005-11-22. */
53 #define MAX_STR_LEN 64
54 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
55 #define PRINTABLE(_ch) (_ch >= ' ' && _ch <= '~')
56 #define RT_PRINT_STR(_Comp, _Level, _TitleString, _Ptr, _Len) \
59 u8 buffer[MAX_STR_LEN]; \
60 u32 length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1);\
61 memset(buffer, 0, MAX_STR_LEN); \
62 memcpy(buffer, (u8 *)_Ptr, length); \
63 for (__i = 0; __i < length; __i++) { \
64 if (!PRINTABLE(buffer[__i])) \
67 buffer[length] = '\0'; \
68 printk(_TitleString); \
69 printk(": %d, <%s>\n", _Len, buffer); \
72 #define DCMD_Printf(...)
73 #define RT_ASSERT(...)
75 #define rsprintf snprintf
77 #define GetDefaultAdapter(padapter) padapter
79 #define PlatformZeroMemory(ptr, sz) memset(ptr, 0, sz)
81 #define PlatformProcessHCICommands(...)
82 #define PlatformTxBTQueuedPackets(...)
83 #define PlatformIndicateBTACLData(...) (RT_STATUS_SUCCESS)
84 #define PlatformAcquireSpinLock(padapter, type)
85 #define PlatformReleaseSpinLock(padapter, type)
87 #define GET_UNDECORATED_AVERAGE_RSSI(padapter) \
88 (GET_HAL_DATA(padapter)->dmpriv.EntryMinUndecoratedSmoothedPWDB)
89 #define RT_RF_CHANGE_SOURCE u32
100 /* ===== Below this line is sync from SD7 driver COMMOM/BT.c ===== */
102 static u8
BT_Operation(struct rtw_adapter
*padapter
)
104 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
105 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
107 if (pBtMgnt
->BtOperationOn
)
113 static u8
BT_IsLegalChannel(struct rtw_adapter
*padapter
, u8 channel
)
115 struct rt_channel_info
*pChanneList
= NULL
;
118 pChanneList
= padapter
->mlmeextpriv
.channel_set
;
119 channelLen
= padapter
->mlmeextpriv
.max_chan_nums
;
121 for (i
= 0; i
< channelLen
; i
++) {
122 RTPRINT(FIOCTL
, IOCTL_STATE
,
123 ("Check if chnl(%d) in channel plan contains bt target chnl(%d) for BT connection\n",
124 pChanneList
[i
].ChannelNum
, channel
));
125 if ((channel
== pChanneList
[i
].ChannelNum
) ||
126 (channel
== pChanneList
[i
].ChannelNum
+ 2))
132 void BT_SignalCompensation(struct rtw_adapter
*padapter
, u8
*rssi_wifi
, u8
*rssi_bt
)
134 BTDM_SignalCompensation(padapter
, rssi_wifi
, rssi_bt
);
137 void rtl8723a_BT_wifiscan_notify(struct rtw_adapter
*padapter
, u8 scanType
)
139 BTHCI_WifiScanNotify(padapter
, scanType
);
140 BTDM_CheckAntSelMode(padapter
);
141 BTDM_WifiScanNotify(padapter
, scanType
);
144 void rtl8723a_BT_wifiassociate_notify(struct rtw_adapter
*padapter
, u8 action
)
147 /* true = associate start */
148 /* false = associate finished */
150 BTDM_CheckAntSelMode(padapter
);
152 BTDM_WifiAssociateNotify(padapter
, action
);
155 void BT_HaltProcess(struct rtw_adapter
*padapter
)
157 BTDM_ForHalt(padapter
);
160 /* ===== End of sync from SD7 driver COMMOM/BT.c ===== */
163 #define UINT64_C(v) (v)
165 #define FillOctetString(_os, _octet, _len) \
166 (_os).Octet = (u8 *)(_octet); \
167 (_os).Length = (_len);
169 static enum rt_status
PlatformIndicateBTEvent(
170 struct rtw_adapter
*padapter
,
175 enum rt_status rt_status
= RT_STATUS_FAILURE
;
177 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_DETAIL
, ("BT event start, %d bytes data to Transferred!!\n", dataLen
));
178 RTPRINT_DATA(FIOCTL
, IOCTL_BT_EVENT_DETAIL
, "To transfer Hex Data :\n",
181 BT_EventParse(padapter
, pEvntData
, dataLen
);
183 printk(KERN_WARNING
"%s: Linux has no way to report BT event!!\n", __func__
);
185 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_DETAIL
, ("BT event end, %s\n",
186 (rt_status
== RT_STATUS_SUCCESS
) ? "SUCCESS" : "FAIL"));
191 /* ===== Below this line is sync from SD7 driver COMMOM/bt_hci.c ===== */
193 static u8
bthci_GetLocalChannel(struct rtw_adapter
*padapter
)
195 return padapter
->mlmeextpriv
.cur_channel
;
198 static u8
bthci_GetCurrentEntryNum(struct rtw_adapter
*padapter
, u8 PhyHandle
)
200 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
203 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
204 if ((pBTInfo
->BtAsocEntry
[i
].bUsed
) &&
205 (pBTInfo
->BtAsocEntry
[i
].PhyLinkCmdData
.BtPhyLinkhandle
== PhyHandle
))
212 static void bthci_DecideBTChannel(struct rtw_adapter
*padapter
, u8 EntryNum
)
214 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
215 struct mlme_priv
*pmlmepriv
;
216 struct bt_30info
*pBTInfo
;
217 struct bt_mgnt
*pBtMgnt
;
218 struct bt_hci_info
*pBtHciInfo
;
219 struct chnl_txpower_triple
*pTriple_subband
= NULL
;
220 struct common_triple
*pTriple
;
221 u8 i
, j
, localchnl
, firstRemoteLegalChnlInTriplet
= 0;
222 u8 regulatory_skipLen
= 0;
223 u8 subbandTripletCnt
= 0;
225 pmlmepriv
= &padapter
->mlmepriv
;
226 pBTInfo
= GET_BT_INFO(padapter
);
227 pBtMgnt
= &pBTInfo
->BtMgnt
;
228 pBtHciInfo
= &pBTInfo
->BtHciInfo
;
230 pBtMgnt
->CheckChnlIsSuit
= true;
231 localchnl
= bthci_GetLocalChannel(padapter
);
233 pTriple
= (struct common_triple
*)
234 &pBtHciInfo
->BTPreChnllist
[COUNTRY_STR_LEN
];
236 /* contains country string, len is 3 */
237 for (i
= 0; i
< (pBtHciInfo
->BtPreChnlListLen
-COUNTRY_STR_LEN
); i
+= 3, pTriple
++) {
239 /* check every triplet, an triplet may be */
240 /* regulatory extension identifier or sub-band triplet */
242 if (pTriple
->byte_1st
== 0xc9) {
243 /* Regulatory Extension Identifier, skip it */
244 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
),
245 ("Find Regulatory ID, regulatory class = %d\n", pTriple
->byte_2nd
));
246 regulatory_skipLen
+= 3;
247 pTriple_subband
= NULL
;
249 } else { /* Sub-band triplet */
250 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Find Sub-band triplet \n"));
252 pTriple_subband
= (struct chnl_txpower_triple
*)pTriple
;
253 /* if remote first legal channel not found, then find first remote channel */
254 /* and it's legal for our channel plan. */
256 /* search the sub-band triplet and find if remote channel is legal to our channel plan. */
257 for (j
= pTriple_subband
->FirstChnl
; j
< (pTriple_subband
->FirstChnl
+pTriple_subband
->NumChnls
); j
++) {
258 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), (" Check if chnl(%d) is legal\n", j
));
259 if (BT_IsLegalChannel(padapter
, j
)) {
260 /* remote channel is legal for our channel plan. */
261 firstRemoteLegalChnlInTriplet
= j
;
262 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
),
263 ("Find first remote legal channel : %d\n",
264 firstRemoteLegalChnlInTriplet
));
266 /* If we find a remote legal channel in the sub-band triplet */
267 /* and only BT connection is established(local not connect to any AP or IBSS), */
268 /* then we just switch channel to remote channel. */
269 if (!(check_fwstate(pmlmepriv
, WIFI_ASOC_STATE
|WIFI_ADHOC_STATE
|WIFI_AP_STATE
) ||
270 BTHCI_HsConnectionEstablished(padapter
))) {
271 pBtMgnt
->BTChannel
= firstRemoteLegalChnlInTriplet
;
272 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Remote legal channel (%d) is selected, Local not connect to any!!\n", pBtMgnt
->BTChannel
));
275 if ((localchnl
>= firstRemoteLegalChnlInTriplet
) &&
276 (localchnl
< (pTriple_subband
->FirstChnl
+pTriple_subband
->NumChnls
))) {
277 pBtMgnt
->BTChannel
= localchnl
;
278 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Local channel (%d) is selected, wifi or BT connection exists\n", pBtMgnt
->BTChannel
));
288 if (subbandTripletCnt
) {
289 /* if any preferred channel triplet exists */
290 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("There are %d sub band triplet exists, ", subbandTripletCnt
));
291 if (firstRemoteLegalChnlInTriplet
== 0) {
292 /* no legal channel is found, reject the connection. */
293 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("no legal channel is found!!\n"));
295 /* Remote Legal channel is found but not match to local */
296 /* wifi connection exists), so reject the connection. */
297 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
),
298 ("Remote Legal channel is found but not match to local(wifi connection exists)!!\n"));
300 pBtMgnt
->CheckChnlIsSuit
= false;
302 /* There are not any preferred channel triplet exists */
303 /* Use current legal channel as the bt channel. */
304 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("No sub band triplet exists!!\n"));
306 pBtMgnt
->BTChannel
= localchnl
;
307 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Local channel (%d) is selected!!\n", pBtMgnt
->BTChannel
));
310 /* Success:return true */
311 /* Fail:return false */
312 static u8
bthci_GetAssocInfo(struct rtw_adapter
*padapter
, u8 EntryNum
)
314 struct bt_30info
*pBTInfo
;
315 struct bt_hci_info
*pBtHciInfo
;
318 u8 BaseMemoryShift
= 0;
320 struct amp_assoc_structure
*pAmpAsoc
;
322 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("GetAssocInfo start\n"));
323 pBTInfo
= GET_BT_INFO(padapter
);
324 pBtHciInfo
= &pBTInfo
->BtHciInfo
;
326 if (pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
== 0) {
327 if (pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocRemLen
< (MAX_AMP_ASSOC_FRAG_LEN
))
328 TotalLen
= pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocRemLen
;
329 else if (pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocRemLen
== (MAX_AMP_ASSOC_FRAG_LEN
))
330 TotalLen
= MAX_AMP_ASSOC_FRAG_LEN
;
331 } else if (pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
> 0)
332 TotalLen
= pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
;
334 while ((pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
>= BaseMemoryShift
) || TotalLen
> BaseMemoryShift
) {
335 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("GetAssocInfo, TotalLen =%d, BaseMemoryShift =%d\n", TotalLen
, BaseMemoryShift
));
337 (u8
*)pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocfragment
+BaseMemoryShift
,
338 TotalLen
-BaseMemoryShift
);
339 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, "GetAssocInfo :\n",
340 tempBuf
, TotalLen
-BaseMemoryShift
);
342 pAmpAsoc
= (struct amp_assoc_structure
*)tempBuf
;
343 le16_to_cpus(&pAmpAsoc
->Length
);
344 BaseMemoryShift
+= 3 + pAmpAsoc
->Length
;
346 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("TypeID = 0x%x, ", pAmpAsoc
->TypeID
));
347 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD
, "Hex Data: \n", pAmpAsoc
->Data
, pAmpAsoc
->Length
);
348 switch (pAmpAsoc
->TypeID
) {
350 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("==> AMP_MAC_ADDR\n"));
351 if (pAmpAsoc
->Length
> 6)
353 memcpy(pBTInfo
->BtAsocEntry
[EntryNum
].BTRemoteMACAddr
, pAmpAsoc
->Data
, 6);
354 RTPRINT_ADDR(FIOCTL
, IOCTL_BT_HCICMD
, ("Remote Mac address \n"), pBTInfo
->BtAsocEntry
[EntryNum
].BTRemoteMACAddr
);
356 case AMP_PREFERRED_CHANNEL_LIST
:
357 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("==> AMP_PREFERRED_CHANNEL_LIST\n"));
358 pBtHciInfo
->BtPreChnlListLen
= pAmpAsoc
->Length
;
359 memcpy(pBtHciInfo
->BTPreChnllist
,
361 pBtHciInfo
->BtPreChnlListLen
);
362 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD
, "Preferred channel list : \n", pBtHciInfo
->BTPreChnllist
, pBtHciInfo
->BtPreChnlListLen
);
363 bthci_DecideBTChannel(padapter
, EntryNum
);
365 case AMP_CONNECTED_CHANNEL
:
366 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("==> AMP_CONNECTED_CHANNEL\n"));
367 pBtHciInfo
->BTConnectChnlListLen
= pAmpAsoc
->Length
;
368 memcpy(pBtHciInfo
->BTConnectChnllist
,
370 pBtHciInfo
->BTConnectChnlListLen
);
372 case AMP_80211_PAL_CAP_LIST
:
373 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("==> AMP_80211_PAL_CAP_LIST\n"));
374 pBTInfo
->BtAsocEntry
[EntryNum
].BTCapability
= *(u32
*)(pAmpAsoc
->Data
);
375 if (pBTInfo
->BtAsocEntry
[EntryNum
].BTCapability
& 0x00000001) {
378 /* Signifies PAL capable of utilizing received activity reports. */
380 if (pBTInfo
->BtAsocEntry
[EntryNum
].BTCapability
& 0x00000002) {
382 /* Signifies PAL is capable of utilizing scheduling information received in an activity reports. */
385 case AMP_80211_PAL_VISION
:
386 pBtHciInfo
->BTPalVersion
= *(u8
*)(pAmpAsoc
->Data
);
387 pBtHciInfo
->BTPalCompanyID
= *(u16
*)(((u8
*)(pAmpAsoc
->Data
))+1);
388 pBtHciInfo
->BTPalsubversion
= *(u16
*)(((u8
*)(pAmpAsoc
->Data
))+3);
389 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("==> AMP_80211_PAL_VISION PalVersion 0x%x, PalCompanyID 0x%x, Palsubversion 0x%x\n",
390 pBtHciInfo
->BTPalVersion
,
391 pBtHciInfo
->BTPalCompanyID
,
392 pBtHciInfo
->BTPalsubversion
));
395 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("==> Unsupport TypeID !!\n"));
400 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("GetAssocInfo end\n"));
405 static u8
bthci_AddEntry(struct rtw_adapter
*padapter
)
407 struct bt_30info
*pBTInfo
;
408 struct bt_mgnt
*pBtMgnt
;
411 pBTInfo
= GET_BT_INFO(padapter
);
412 pBtMgnt
= &pBTInfo
->BtMgnt
;
414 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
415 if (pBTInfo
->BtAsocEntry
[i
].bUsed
== false) {
416 pBTInfo
->BtAsocEntry
[i
].bUsed
= true;
417 pBtMgnt
->CurrentConnectEntryNum
= i
;
422 if (i
== MAX_BT_ASOC_ENTRY_NUM
) {
423 RTPRINT(FIOCTL
, IOCTL_STATE
, ("bthci_AddEntry(), Add entry fail!!\n"));
429 static u8
bthci_DiscardTxPackets(struct rtw_adapter
*padapter
, u16 LLH
)
435 bthci_CheckLogLinkBehavior(
436 struct rtw_adapter
*padapter
,
437 struct hci_flow_spec TxFlowSpec
440 u8 ID
= TxFlowSpec
.Identifier
;
441 u8 ServiceType
= TxFlowSpec
.ServiceType
;
442 u16 MaxSDUSize
= TxFlowSpec
.MaximumSDUSize
;
443 u32 SDUInterArrivatime
= TxFlowSpec
.SDUInterArrivalTime
;
448 if (ServiceType
== BT_LL_BE
) {
450 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = TX best effort flowspec\n"));
451 } else if ((ServiceType
== BT_LL_GU
) && (MaxSDUSize
== 0xffff)) {
453 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = RX guaranteed latency flowspec\n"));
454 } else if ((ServiceType
== BT_LL_GU
) && (MaxSDUSize
== 2500)) {
455 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = RX guaranteed Large latency flowspec\n"));
459 if (ServiceType
== BT_LL_BE
) {
461 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = RX best effort flowspec\n"));
466 if ((ServiceType
== BT_LL_GU
) && (MaxSDUSize
== 1492)) {
468 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = TX guaranteed latency flowspec\n"));
469 } else if ((ServiceType
== BT_LL_GU
) && (MaxSDUSize
== 2500)) {
470 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = TX guaranteed Large latency flowspec\n"));
474 if (ServiceType
== BT_LL_BE
) {
475 if ((SDUInterArrivatime
== 0xffffffff) && (ServiceType
== BT_LL_BE
) && (MaxSDUSize
== 1492)) {
477 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = TX/RX aggregated best effort flowspec\n"));
479 } else if (ServiceType
== BT_LL_GU
) {
480 if (SDUInterArrivatime
== 100) {
482 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = TX/RX guaranteed bandwidth flowspec\n"));
487 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Logical Link Type = Unknow Type !!!!!!!!\n"));
491 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
),
492 ("ID = 0x%x, ServiceType = 0x%x, MaximumSDUSize = 0x%x, SDUInterArrivalTime = 0x%x, AccessLatency = 0x%x, FlushTimeout = 0x%x\n",
493 TxFlowSpec
.Identifier
, TxFlowSpec
.ServiceType
, MaxSDUSize
,
494 SDUInterArrivatime
, TxFlowSpec
.AccessLatency
, TxFlowSpec
.FlushTimeout
));
498 static u16
bthci_AssocMACAddr(struct rtw_adapter
*padapter
, void *pbuf
)
500 struct amp_assoc_structure
*pAssoStrc
= (struct amp_assoc_structure
*)pbuf
;
501 pAssoStrc
->TypeID
= AMP_MAC_ADDR
;
502 pAssoStrc
->Length
= 0x06;
503 memcpy(&pAssoStrc
->Data
[0], padapter
->eeprompriv
.mac_addr
, 6);
504 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
),
505 ("AssocMACAddr : \n"), pAssoStrc
, pAssoStrc
->Length
+3);
507 return pAssoStrc
->Length
+ 3;
511 bthci_PALCapabilities(
512 struct rtw_adapter
*padapter
,
516 struct amp_assoc_structure
*pAssoStrc
= (struct amp_assoc_structure
*)pbuf
;
518 pAssoStrc
->TypeID
= AMP_80211_PAL_CAP_LIST
;
519 pAssoStrc
->Length
= 0x04;
521 pAssoStrc
->Data
[0] = 0x00;
522 pAssoStrc
->Data
[1] = 0x00;
524 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("PALCapabilities:\n"), pAssoStrc
, pAssoStrc
->Length
+3);
525 RTPRINT(FIOCTL
, IOCTL_BT_LOGO
, ("PALCapabilities \n"));
527 RTPRINT(FIOCTL
, IOCTL_BT_LOGO
, (" TypeID = 0x%x,\n Length = 0x%x,\n Content = 0x0000\n",
531 return pAssoStrc
->Length
+ 3;
534 static u16
bthci_AssocPreferredChannelList(struct rtw_adapter
*padapter
,
535 void *pbuf
, u8 EntryNum
)
537 struct bt_30info
*pBTInfo
;
538 struct amp_assoc_structure
*pAssoStrc
;
539 struct amp_pref_chnl_regulatory
*pReg
;
540 struct chnl_txpower_triple
*pTriple
;
541 char ctrString
[3] = {'X', 'X', 'X'};
545 pBTInfo
= GET_BT_INFO(padapter
);
546 pAssoStrc
= (struct amp_assoc_structure
*)pbuf
;
547 pReg
= (struct amp_pref_chnl_regulatory
*)&pAssoStrc
->Data
[3];
549 preferredChnl
= bthci_GetLocalChannel(padapter
);
550 pAssoStrc
->TypeID
= AMP_PREFERRED_CHANNEL_LIST
;
553 memcpy(&pAssoStrc
->Data
[0], &ctrString
[0], 3);
555 pReg
->regulatoryClass
= 254;
556 pReg
->coverageClass
= 0;
558 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
| IOCTL_BT_LOGO
), ("PREFERRED_CHNL_LIST\n"));
559 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
| IOCTL_BT_LOGO
), ("XXX, 201, 254, 0\n"));
560 /* at the following, chnl 1~11 should be contained */
561 pTriple
= (struct chnl_txpower_triple
*)&pAssoStrc
->Data
[len
];
563 /* (1) if any wifi or bt HS connection exists */
564 if ((pBTInfo
->BtAsocEntry
[EntryNum
].AMPRole
== AMP_BTAP_CREATOR
) ||
565 (check_fwstate(&padapter
->mlmepriv
, WIFI_ASOC_STATE
|
566 WIFI_ADHOC_STATE
| WIFI_ADHOC_MASTER_STATE
|
568 BTHCI_HsConnectionEstablished(padapter
)) {
569 pTriple
->FirstChnl
= preferredChnl
;
570 pTriple
->NumChnls
= 1;
571 pTriple
->MaxTxPowerInDbm
= 20;
573 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
| IOCTL_BT_LOGO
), ("First Channel = %d, Channel Num = %d, MaxDbm = %d\n",
576 pTriple
->MaxTxPowerInDbm
));
579 pAssoStrc
->Length
= (u16
)len
;
580 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD
, ("AssocPreferredChannelList : \n"), pAssoStrc
, pAssoStrc
->Length
+3);
582 return pAssoStrc
->Length
+ 3;
585 static u16
bthci_AssocPALVer(struct rtw_adapter
*padapter
, void *pbuf
)
587 struct amp_assoc_structure
*pAssoStrc
= (struct amp_assoc_structure
*)pbuf
;
591 pAssoStrc
->TypeID
= AMP_80211_PAL_VISION
;
592 pAssoStrc
->Length
= 0x5;
593 pu1Tmp
= &pAssoStrc
->Data
[0];
594 *pu1Tmp
= 0x1; /* PAL Version */
595 pu2Tmp
= (u16
*)&pAssoStrc
->Data
[1];
596 *pu2Tmp
= 0x5D; /* SIG Company identifier of 802.11 PAL vendor */
597 pu2Tmp
= (u16
*)&pAssoStrc
->Data
[3];
598 *pu2Tmp
= 0x1; /* PAL Sub-version specifier */
600 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("AssocPALVer : \n"), pAssoStrc
, pAssoStrc
->Length
+3);
601 RTPRINT(FIOCTL
, IOCTL_BT_LOGO
, ("AssocPALVer \n"));
603 RTPRINT(FIOCTL
, IOCTL_BT_LOGO
, (" TypeID = 0x%x,\n Length = 0x%x,\n PAL Version = 0x01,\n PAL vendor = 0x01,\n PAL Sub-version specifier = 0x01\n",
606 return pAssoStrc
->Length
+ 3;
609 static u8
bthci_CheckRfStateBeforeConnect(struct rtw_adapter
*padapter
)
611 struct bt_30info
*pBTInfo
;
612 enum rt_rf_power_state RfState
;
614 pBTInfo
= GET_BT_INFO(padapter
);
616 RfState
= padapter
->pwrctrlpriv
.rf_pwrstate
;
618 if (RfState
!= rf_on
) {
619 mod_timer(&pBTInfo
->BTPsDisableTimer
,
620 jiffies
+ msecs_to_jiffies(50));
626 static void bthci_ResponderStartToScan(struct rtw_adapter
*padapter
)
630 static u8
bthci_PhyLinkConnectionInProgress(struct rtw_adapter
*padapter
, u8 PhyLinkHandle
)
632 struct bt_30info
*pBTInfo
;
633 struct bt_mgnt
*pBtMgnt
;
635 pBTInfo
= GET_BT_INFO(padapter
);
636 pBtMgnt
= &pBTInfo
->BtMgnt
;
638 if (pBtMgnt
->bPhyLinkInProgress
&&
639 (pBtMgnt
->BtCurrentPhyLinkhandle
== PhyLinkHandle
))
644 static void bthci_ResetFlowSpec(struct rtw_adapter
*padapter
, u8 EntryNum
, u8 index
)
646 struct bt_30info
*pBTinfo
;
648 pBTinfo
= GET_BT_INFO(padapter
);
650 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].BtLogLinkhandle
= 0;
651 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].BtPhyLinkhandle
= 0;
652 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].bLLCompleteEventIsSet
= false;
653 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].bLLCancelCMDIsSetandComplete
= false;
654 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].BtTxFlowSpecID
= 0;
655 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].TxPacketCount
= 0;
657 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.Identifier
= 0x01;
658 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.ServiceType
= SERVICE_BEST_EFFORT
;
659 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.MaximumSDUSize
= 0xffff;
660 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.SDUInterArrivalTime
= 0xffffffff;
661 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.AccessLatency
= 0xffffffff;
662 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Tx_Flow_Spec
.FlushTimeout
= 0xffffffff;
664 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.Identifier
= 0x01;
665 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.ServiceType
= SERVICE_BEST_EFFORT
;
666 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.MaximumSDUSize
= 0xffff;
667 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.SDUInterArrivalTime
= 0xffffffff;
668 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.AccessLatency
= 0xffffffff;
669 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[index
].Rx_Flow_Spec
.FlushTimeout
= 0xffffffff;
672 static void bthci_ResetEntry(struct rtw_adapter
*padapter
, u8 EntryNum
)
674 struct bt_30info
*pBTinfo
;
675 struct bt_mgnt
*pBtMgnt
;
678 pBTinfo
= GET_BT_INFO(padapter
);
679 pBtMgnt
= &pBTinfo
->BtMgnt
;
681 pBTinfo
->BtAsocEntry
[EntryNum
].bUsed
= false;
682 pBTinfo
->BtAsocEntry
[EntryNum
].BtCurrentState
= HCI_STATE_DISCONNECTED
;
683 pBTinfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_DISCONNECTED
;
685 pBTinfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocRemLen
= 0;
686 pBTinfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.BtPhyLinkhandle
= 0;
687 if (pBTinfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocfragment
!= NULL
)
688 memset(pBTinfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocfragment
, 0, TOTAL_ALLOCIATE_ASSOC_LEN
);
689 pBTinfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
= 0;
691 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyType
= 0;
692 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
= 0;
693 memset(pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKey
, 0,
694 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
);
695 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
= 0;
697 /* 0x640; 0.625ms*1600 = 1000ms, 0.625ms*16000 = 10000ms */
698 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.LinkSuperversionTimeout
= 0x3e80;
700 pBTinfo
->BtAsocEntry
[EntryNum
].AMPRole
= AMP_BTAP_NONE
;
702 pBTinfo
->BtAsocEntry
[EntryNum
].mAssoc
= false;
703 pBTinfo
->BtAsocEntry
[EntryNum
].b4waySuccess
= false;
706 pBTinfo
->BtAsocEntry
[EntryNum
].KeyReplayCounter
= 0;
707 pBTinfo
->BtAsocEntry
[EntryNum
].BTWPAAuthState
= STATE_WPA_AUTH_UNINITIALIZED
;
709 pBTinfo
->BtAsocEntry
[EntryNum
].bSendSupervisionPacket
= false;
710 pBTinfo
->BtAsocEntry
[EntryNum
].NoRxPktCnt
= 0;
711 pBTinfo
->BtAsocEntry
[EntryNum
].ShortRangeMode
= 0;
712 pBTinfo
->BtAsocEntry
[EntryNum
].rxSuvpPktCnt
= 0;
714 for (j
= 0; j
< MAX_LOGICAL_LINK_NUM
; j
++)
715 bthci_ResetFlowSpec(padapter
, EntryNum
, j
);
717 pBtMgnt
->BTAuthCount
= 0;
718 pBtMgnt
->BTAsocCount
= 0;
719 pBtMgnt
->BTCurrentConnectType
= BT_DISCONNECT
;
720 pBtMgnt
->BTReceiveConnectPkt
= BT_DISCONNECT
;
722 HALBT_RemoveKey(padapter
, EntryNum
);
725 static void bthci_RemoveEntryByEntryNum(struct rtw_adapter
*padapter
, u8 EntryNum
)
727 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
728 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
730 bthci_ResetEntry(padapter
, EntryNum
);
732 if (pBtMgnt
->CurrentBTConnectionCnt
> 0)
733 pBtMgnt
->CurrentBTConnectionCnt
--;
735 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], CurrentBTConnectionCnt = %d!!\n",
736 pBtMgnt
->CurrentBTConnectionCnt
));
738 if (pBtMgnt
->CurrentBTConnectionCnt
> 0) {
739 pBtMgnt
->BtOperationOn
= true;
741 pBtMgnt
->BtOperationOn
= false;
742 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], Bt Operation OFF!!\n"));
745 if (!pBtMgnt
->BtOperationOn
) {
746 del_timer_sync(&pBTInfo
->BTHCIDiscardAclDataTimer
);
747 del_timer_sync(&pBTInfo
->BTBeaconTimer
);
748 pBtMgnt
->bStartSendSupervisionPkt
= false;
753 bthci_CommandCompleteHeader(
757 enum hci_status status
760 struct packet_irp_hcievent_data
*PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)pbuf
;
761 u8 NumHCI_Comm
= 0x1;
763 PPacketIrpEvent
->EventCode
= HCI_EVENT_COMMAND_COMPLETE
;
764 PPacketIrpEvent
->Data
[0] = NumHCI_Comm
; /* packet # */
765 PPacketIrpEvent
->Data
[1] = HCIOPCODELOW(OCF
, OGF
);
766 PPacketIrpEvent
->Data
[2] = HCIOPCODEHIGHT(OCF
, OGF
);
768 if (OGF
== OGF_EXTENSION
) {
769 if (OCF
== HCI_SET_RSSI_VALUE
) {
770 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT_PERIODICAL
),
771 ("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
772 NumHCI_Comm
, (HCIOPCODEHIGHT(OCF
, OGF
)), (HCIOPCODELOW(OCF
, OGF
)), status
, OGF
, OCF
));
774 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_EXT
),
775 ("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
776 NumHCI_Comm
, (HCIOPCODEHIGHT(OCF
, OGF
)), (HCIOPCODELOW(OCF
, OGF
)), status
, OGF
, OCF
));
779 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
),
780 ("[BT event], CommandComplete, Num_HCI_Comm = 0x%x, Opcode = 0x%02x%02x, status = 0x%x, OGF = 0x%x, OCF = 0x%x\n",
781 NumHCI_Comm
, (HCIOPCODEHIGHT(OCF
, OGF
)), (HCIOPCODELOW(OCF
, OGF
)), status
, OGF
, OCF
));
786 static u8
bthci_ExtensionEventHeaderRtk(u8
*pbuf
, u8 extensionEvent
)
788 struct packet_irp_hcievent_data
*PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)pbuf
;
789 PPacketIrpEvent
->EventCode
= HCI_EVENT_EXTENSION_RTK
;
790 PPacketIrpEvent
->Data
[0] = extensionEvent
; /* extension event code */
795 static enum rt_status
797 struct rtw_adapter
*padapter
,
802 enum rt_status rt_status
;
804 rt_status
= PlatformIndicateBTEvent(padapter
, pEvntData
, dataLen
);
810 bthci_EventWriteRemoteAmpAssoc(
811 struct rtw_adapter
*padapter
,
812 enum hci_status status
,
816 u8 localBuf
[TmpLocalBufSize
] = "";
819 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
821 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
822 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
824 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
825 OGF_STATUS_PARAMETERS
,
826 HCI_WRITE_REMOTE_AMP_ASSOC
,
828 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("PhyLinkHandle = 0x%x, status = %d\n", PLHandle
, status
));
829 /* Return parameters starts from here */
830 pRetPar
= &PPacketIrpEvent
->Data
[len
];
831 pRetPar
[0] = status
; /* status */
832 pRetPar
[1] = PLHandle
;
834 PPacketIrpEvent
->Length
= len
;
836 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
840 bthci_EventEnhancedFlushComplete(
841 struct rtw_adapter
*padapter
,
846 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
848 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("EventEnhancedFlushComplete, LLH = 0x%x\n", LLH
));
850 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
851 PPacketIrpEvent
->EventCode
= HCI_EVENT_ENHANCED_FLUSH_COMPLETE
;
852 PPacketIrpEvent
->Length
= 2;
853 /* Logical link handle */
854 PPacketIrpEvent
->Data
[0] = TWOBYTE_LOWBYTE(LLH
);
855 PPacketIrpEvent
->Data
[1] = TWOBYTE_HIGHTBYTE(LLH
);
857 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
861 bthci_EventShortRangeModeChangeComplete(
862 struct rtw_adapter
*padapter
,
863 enum hci_status HciStatus
,
868 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
869 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
871 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
873 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE
)) {
874 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
875 ("[BT event], Short Range Mode Change Complete, Ignore to send this event due to event mask page 2\n"));
878 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Short Range Mode Change Complete, Status = %d\n , PLH = 0x%x\n, Short_Range_Mode_State = 0x%x\n",
879 HciStatus
, pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
, ShortRangeState
));
881 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
882 PPacketIrpEvent
->EventCode
= HCI_EVENT_SHORT_RANGE_MODE_CHANGE_COMPLETE
;
883 PPacketIrpEvent
->Length
= 3;
884 PPacketIrpEvent
->Data
[0] = HciStatus
;
885 PPacketIrpEvent
->Data
[1] = pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
886 PPacketIrpEvent
->Data
[2] = ShortRangeState
;
887 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 5);
890 static void bthci_EventSendFlowSpecModifyComplete(struct rtw_adapter
*padapter
,
891 enum hci_status HciStatus
,
895 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
896 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
897 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
899 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE
)) {
900 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
),
901 ("[BT event], Flow Spec Modify Complete, Ignore to send this event due to event mask page 2\n"));
904 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
),
905 ("[BT event], Flow Spec Modify Complete, status = 0x%x, LLH = 0x%x\n", HciStatus
, logicHandle
));
906 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
907 PPacketIrpEvent
->EventCode
= HCI_EVENT_FLOW_SPEC_MODIFY_COMPLETE
;
908 PPacketIrpEvent
->Length
= 3;
910 PPacketIrpEvent
->Data
[0] = HciStatus
;
911 /* Logical link handle */
912 PPacketIrpEvent
->Data
[1] = TWOBYTE_LOWBYTE(logicHandle
);
913 PPacketIrpEvent
->Data
[2] = TWOBYTE_HIGHTBYTE(logicHandle
);
915 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 5);
919 bthci_EventExtWifiScanNotify(
920 struct rtw_adapter
*padapter
,
924 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
925 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
930 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
932 if (!pBtMgnt
->BtOperationOn
)
935 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
937 len
+= bthci_ExtensionEventHeaderRtk(&localBuf
[0], HCI_EVENT_EXT_WIFI_SCAN_NOTIFY
);
939 /* Return parameters starts from here */
940 pRetPar
= &PPacketIrpEvent
->Data
[len
];
941 pu1Temp
= (u8
*)&pRetPar
[0];
945 PPacketIrpEvent
->Length
= len
;
947 if (bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2) == RT_STATUS_SUCCESS
) {
948 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Wifi scan notify, scan type = %d\n",
954 bthci_EventAMPReceiverReport(
955 struct rtw_adapter
*padapter
,
959 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
960 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
962 if (pBtHciInfo
->bTestNeedReport
) {
963 u8 localBuf
[20] = "";
966 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
968 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), (" HCI_EVENT_AMP_RECEIVER_REPORT\n"));
969 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
970 PPacketIrpEvent
->EventCode
= HCI_EVENT_AMP_RECEIVER_REPORT
;
971 PPacketIrpEvent
->Length
= 2;
973 PPacketIrpEvent
->Data
[0] = pBtHciInfo
->TestCtrType
;
975 PPacketIrpEvent
->Data
[1] = Reason
;
977 pu4Temp
= (u32
*)&PPacketIrpEvent
->Data
[2];
978 *pu4Temp
= pBtHciInfo
->TestEventType
;
980 pu2Temp
= (u16
*)&PPacketIrpEvent
->Data
[6];
981 *pu2Temp
= pBtHciInfo
->TestNumOfFrame
;
983 pu2Temp
= (u16
*)&PPacketIrpEvent
->Data
[8];
984 *pu2Temp
= pBtHciInfo
->TestNumOfErrFrame
;
986 pu4Temp
= (u32
*)&PPacketIrpEvent
->Data
[10];
987 *pu4Temp
= pBtHciInfo
->TestNumOfBits
;
989 pu4Temp
= (u32
*)&PPacketIrpEvent
->Data
[14];
990 *pu4Temp
= pBtHciInfo
->TestNumOfErrBits
;
992 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 20);
994 /* Return to Idel state with RX and TX off. */
998 pBtHciInfo
->TestNumOfFrame
= 0x00;
1002 bthci_EventChannelSelected(
1003 struct rtw_adapter
*padapter
,
1007 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1008 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1009 u8 localBuf
[3] = "";
1010 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1012 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_CHANNEL_SELECT
)) {
1013 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1014 ("[BT event], Channel Selected, Ignore to send this event due to event mask page 2\n"));
1018 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
|IOCTL_STATE
,
1019 ("[BT event], Channel Selected, PhyLinkHandle %d\n",
1020 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
));
1022 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1023 PPacketIrpEvent
->EventCode
= HCI_EVENT_CHANNEL_SELECT
;
1024 PPacketIrpEvent
->Length
= 1;
1025 PPacketIrpEvent
->Data
[0] = pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
1026 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 3);
1030 bthci_EventDisconnectPhyLinkComplete(
1031 struct rtw_adapter
*padapter
,
1032 enum hci_status HciStatus
,
1033 enum hci_status Reason
,
1037 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1038 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1039 u8 localBuf
[5] = "";
1040 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1042 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE
)) {
1043 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1044 ("[BT event], Disconnect Physical Link Complete, Ignore to send this event due to event mask page 2\n"));
1047 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1048 ("[BT event], Disconnect Physical Link Complete, Status = 0x%x, PLH = 0x%x Reason = 0x%x\n",
1049 HciStatus
, pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
, Reason
));
1050 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1051 PPacketIrpEvent
->EventCode
= HCI_EVENT_DISCONNECT_PHY_LINK_COMPLETE
;
1052 PPacketIrpEvent
->Length
= 3;
1053 PPacketIrpEvent
->Data
[0] = HciStatus
;
1054 PPacketIrpEvent
->Data
[1] = pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
1055 PPacketIrpEvent
->Data
[2] = Reason
;
1056 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 5);
1060 bthci_EventPhysicalLinkComplete(
1061 struct rtw_adapter
*padapter
,
1062 enum hci_status HciStatus
,
1067 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1068 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
1069 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1070 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
1071 u8 localBuf
[4] = "";
1072 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1075 pBtMgnt
->bPhyLinkInProgress
= false;
1076 pBtDbg
->dbgHciInfo
.hciCmdPhyLinkStatus
= HciStatus
;
1077 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_PHY_LINK_COMPLETE
)) {
1078 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1079 ("[BT event], Physical Link Complete, Ignore to send this event due to event mask page 2\n"));
1083 if (EntryNum
== 0xff) {
1084 /* connection not started yet, just use the input physical link handle to response. */
1085 PL_handle
= PLHandle
;
1087 /* connection is under progress, use the phy link handle we recorded. */
1088 PL_handle
= pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
1089 pBTInfo
->BtAsocEntry
[EntryNum
].bNeedPhysLinkCompleteEvent
= false;
1092 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Physical Link Complete, Status = 0x%x PhyLinkHandle = 0x%x\n", HciStatus
,
1095 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1096 PPacketIrpEvent
->EventCode
= HCI_EVENT_PHY_LINK_COMPLETE
;
1097 PPacketIrpEvent
->Length
= 2;
1099 PPacketIrpEvent
->Data
[0] = HciStatus
;
1100 PPacketIrpEvent
->Data
[1] = PL_handle
;
1101 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
1106 bthci_EventCommandStatus(
1107 struct rtw_adapter
*padapter
,
1110 enum hci_status HciStatus
1114 u8 localBuf
[6] = "";
1115 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1116 u8 Num_Hci_Comm
= 0x1;
1117 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1118 ("[BT event], CommandStatus, Opcode = 0x%02x%02x, OGF = 0x%x, OCF = 0x%x, Status = 0x%x, Num_HCI_COMM = 0x%x\n",
1119 (HCIOPCODEHIGHT(OCF
, OGF
)), (HCIOPCODELOW(OCF
, OGF
)), OGF
, OCF
, HciStatus
, Num_Hci_Comm
));
1121 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1122 PPacketIrpEvent
->EventCode
= HCI_EVENT_COMMAND_STATUS
;
1123 PPacketIrpEvent
->Length
= 4;
1124 PPacketIrpEvent
->Data
[0] = HciStatus
; /* current pending */
1125 PPacketIrpEvent
->Data
[1] = Num_Hci_Comm
; /* packet # */
1126 PPacketIrpEvent
->Data
[2] = HCIOPCODELOW(OCF
, OGF
);
1127 PPacketIrpEvent
->Data
[3] = HCIOPCODEHIGHT(OCF
, OGF
);
1129 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 6);
1134 bthci_EventLogicalLinkComplete(
1135 struct rtw_adapter
*padapter
,
1136 enum hci_status HciStatus
,
1143 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
1144 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1145 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1146 u8 localBuf
[7] = "";
1147 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1149 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_LOGICAL_LINK_COMPLETE
)) {
1150 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
,
1151 ("[BT event], Logical Link Complete, Ignore to send this event due to event mask page 2\n"));
1154 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Logical Link Complete, PhyLinkHandle = 0x%x, LogLinkHandle = 0x%x, Status = 0x%x\n",
1155 PhyLinkHandle
, LogLinkHandle
, HciStatus
));
1157 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1158 PPacketIrpEvent
->EventCode
= HCI_EVENT_LOGICAL_LINK_COMPLETE
;
1159 PPacketIrpEvent
->Length
= 5;
1161 PPacketIrpEvent
->Data
[0] = HciStatus
;/* status code */
1162 /* Logical link handle */
1163 PPacketIrpEvent
->Data
[1] = TWOBYTE_LOWBYTE(LogLinkHandle
);
1164 PPacketIrpEvent
->Data
[2] = TWOBYTE_HIGHTBYTE(LogLinkHandle
);
1165 /* Physical link handle */
1166 PPacketIrpEvent
->Data
[3] = TWOBYTE_LOWBYTE(PhyLinkHandle
);
1167 /* corresponding Tx flow spec ID */
1168 if (HciStatus
== HCI_STATUS_SUCCESS
) {
1169 PPacketIrpEvent
->Data
[4] =
1170 pBTInfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[LogLinkIndex
].Tx_Flow_Spec
.Identifier
;
1172 PPacketIrpEvent
->Data
[4] = 0x0;
1175 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 7);
1179 bthci_EventDisconnectLogicalLinkComplete(
1180 struct rtw_adapter
*padapter
,
1181 enum hci_status HciStatus
,
1183 enum hci_status Reason
1186 u8 localBuf
[6] = "";
1187 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1188 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1189 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1191 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE
)) {
1192 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Disconnect Logical Link Complete, Ignore to send this event due to event mask page 2\n"));
1195 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Disconnect Logical Link Complete, Status = 0x%x, LLH = 0x%x Reason = 0x%x\n", HciStatus
, LogLinkHandle
, Reason
));
1197 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1198 PPacketIrpEvent
->EventCode
= HCI_EVENT_DISCONNECT_LOGICAL_LINK_COMPLETE
;
1199 PPacketIrpEvent
->Length
= 4;
1201 PPacketIrpEvent
->Data
[0] = HciStatus
;
1202 /* Logical link handle */
1203 PPacketIrpEvent
->Data
[1] = TWOBYTE_LOWBYTE(LogLinkHandle
);
1204 PPacketIrpEvent
->Data
[2] = TWOBYTE_HIGHTBYTE(LogLinkHandle
);
1205 /* Disconnect reason */
1206 PPacketIrpEvent
->Data
[3] = Reason
;
1208 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 6);
1212 bthci_EventFlushOccurred(
1213 struct rtw_adapter
*padapter
,
1217 u8 localBuf
[4] = "";
1218 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1219 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("bthci_EventFlushOccurred(), LLH = 0x%x\n", LogLinkHandle
));
1221 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1222 PPacketIrpEvent
->EventCode
= HCI_EVENT_FLUSH_OCCRUED
;
1223 PPacketIrpEvent
->Length
= 2;
1224 /* Logical link handle */
1225 PPacketIrpEvent
->Data
[0] = TWOBYTE_LOWBYTE(LogLinkHandle
);
1226 PPacketIrpEvent
->Data
[1] = TWOBYTE_HIGHTBYTE(LogLinkHandle
);
1228 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
1231 static enum hci_status
1232 bthci_BuildPhysicalLink(
1233 struct rtw_adapter
*padapter
,
1234 struct packet_irp_hcicmd_data
*pHciCmd
,
1238 enum hci_status status
= HCI_STATUS_SUCCESS
;
1239 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1240 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
1243 /* Send HCI Command status event to AMP. */
1244 bthci_EventCommandStatus(padapter
,
1245 LINK_CONTROL_COMMANDS
,
1247 HCI_STATUS_SUCCESS
);
1249 PLH
= *((u8
*)pHciCmd
->Data
);
1251 /* Check if resource or bt connection is under progress, if yes, reject the link creation. */
1252 if (!bthci_AddEntry(padapter
)) {
1253 status
= HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE
;
1254 bthci_EventPhysicalLinkComplete(padapter
, status
, INVALID_ENTRY_NUM
, PLH
);
1258 EntryNum
= pBtMgnt
->CurrentConnectEntryNum
;
1259 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
= PLH
;
1260 pBtMgnt
->BtCurrentPhyLinkhandle
= PLH
;
1262 if (pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.AMPAssocfragment
== NULL
) {
1263 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Create/Accept PhysicalLink, AMP controller is busy\n"));
1264 status
= HCI_STATUS_CONTROLLER_BUSY
;
1265 bthci_EventPhysicalLinkComplete(padapter
, status
, INVALID_ENTRY_NUM
, PLH
);
1269 /* Record Key and the info */
1270 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
= (*((u8
*)pHciCmd
->Data
+1));
1271 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyType
= (*((u8
*)pHciCmd
->Data
+2));
1272 memcpy(pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKey
,
1273 (((u8
*)pHciCmd
->Data
+3)), pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
);
1274 memcpy(pBTInfo
->BtAsocEntry
[EntryNum
].PMK
, pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKey
, PMK_LEN
);
1275 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("BuildPhysicalLink, EntryNum = %d, PLH = 0x%x KeyLen = 0x%x, KeyType = 0x%x\n",
1276 EntryNum
, pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
,
1277 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
,
1278 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyType
));
1279 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_LOGO
|IOCTL_BT_HCICMD
), ("BtAMPKey\n"), pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKey
,
1280 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtAMPKeyLen
);
1281 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_LOGO
|IOCTL_BT_HCICMD
), ("PMK\n"), pBTInfo
->BtAsocEntry
[EntryNum
].PMK
,
1284 if (OCF
== HCI_CREATE_PHYSICAL_LINK
) {
1285 /* These macros require braces */
1286 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTED
, STATE_CMD_CREATE_PHY_LINK
, EntryNum
);
1287 } else if (OCF
== HCI_ACCEPT_PHYSICAL_LINK
) {
1288 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTED
, STATE_CMD_ACCEPT_PHY_LINK
, EntryNum
);
1295 bthci_BuildLogicalLink(
1296 struct rtw_adapter
*padapter
,
1297 struct packet_irp_hcicmd_data
*pHciCmd
,
1301 enum hci_status status
= HCI_STATUS_SUCCESS
;
1302 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
1303 struct bt_mgnt
*pBtMgnt
= &pBTinfo
->BtMgnt
;
1304 u8 PhyLinkHandle
, EntryNum
;
1305 static u16 AssignLogHandle
= 1;
1307 struct hci_flow_spec TxFlowSpec
;
1308 struct hci_flow_spec RxFlowSpec
;
1309 u32 MaxSDUSize
, ArriveTime
, Bandwidth
;
1311 PhyLinkHandle
= *((u8
*)pHciCmd
->Data
);
1313 EntryNum
= bthci_GetCurrentEntryNum(padapter
, PhyLinkHandle
);
1316 &pHciCmd
->Data
[1], sizeof(struct hci_flow_spec
));
1318 &pHciCmd
->Data
[17], sizeof(struct hci_flow_spec
));
1320 MaxSDUSize
= TxFlowSpec
.MaximumSDUSize
;
1321 ArriveTime
= TxFlowSpec
.SDUInterArrivalTime
;
1323 if (bthci_CheckLogLinkBehavior(padapter
, TxFlowSpec
) && bthci_CheckLogLinkBehavior(padapter
, RxFlowSpec
))
1324 Bandwidth
= BTTOTALBANDWIDTH
;
1325 else if (MaxSDUSize
== 0xffff && ArriveTime
== 0xffffffff)
1326 Bandwidth
= BTTOTALBANDWIDTH
;
1328 Bandwidth
= MaxSDUSize
*8*1000/(ArriveTime
+244);
1330 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
,
1331 ("BuildLogicalLink, PhyLinkHandle = 0x%x, MaximumSDUSize = 0x%x, SDUInterArrivalTime = 0x%x, Bandwidth = 0x%x\n",
1332 PhyLinkHandle
, MaxSDUSize
, ArriveTime
, Bandwidth
));
1334 if (EntryNum
== 0xff) {
1335 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Invalid Physical Link handle = 0x%x, status = HCI_STATUS_UNKNOW_CONNECT_ID, return\n", PhyLinkHandle
));
1336 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1338 /* When we receive Create/Accept logical link command, we should send command status event first. */
1339 bthci_EventCommandStatus(padapter
,
1340 LINK_CONTROL_COMMANDS
,
1346 if (!pBtMgnt
->bLogLinkInProgress
) {
1347 if (bthci_PhyLinkConnectionInProgress(padapter
, PhyLinkHandle
)) {
1348 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Physical link connection in progress, status = HCI_STATUS_CMD_DISALLOW, return\n"));
1349 status
= HCI_STATUS_CMD_DISALLOW
;
1351 pBtMgnt
->bPhyLinkInProgressStartLL
= true;
1352 /* When we receive Create/Accept logical link command, we should send command status event first. */
1353 bthci_EventCommandStatus(padapter
,
1354 LINK_CONTROL_COMMANDS
,
1361 if (Bandwidth
> BTTOTALBANDWIDTH
) {
1362 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("status = HCI_STATUS_QOS_REJECT, Bandwidth = 0x%x, return\n", Bandwidth
));
1363 status
= HCI_STATUS_QOS_REJECT
;
1365 /* When we receive Create/Accept logical link command, we should send command status event first. */
1366 bthci_EventCommandStatus(padapter
,
1367 LINK_CONTROL_COMMANDS
,
1371 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("status = HCI_STATUS_SUCCESS\n"));
1372 status
= HCI_STATUS_SUCCESS
;
1374 /* When we receive Create/Accept logical link command, we should send command status event first. */
1375 bthci_EventCommandStatus(padapter
,
1376 LINK_CONTROL_COMMANDS
,
1382 if (pBTinfo
->BtAsocEntry
[EntryNum
].BtCurrentState
!= HCI_STATE_CONNECTED
) {
1383 bthci_EventLogicalLinkComplete(padapter
,
1384 HCI_STATUS_CMD_DISALLOW
, 0, 0, 0, EntryNum
);
1388 pBtMgnt
->bLogLinkInProgress
= true;
1390 /* find an unused logical link index and copy the data */
1391 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
1392 if (pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
== 0) {
1393 enum hci_status LogCompEventstatus
= HCI_STATUS_SUCCESS
;
1395 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtPhyLinkhandle
= *((u8
*)pHciCmd
->Data
);
1396 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
= AssignLogHandle
;
1397 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("BuildLogicalLink, EntryNum = %d, physical link handle = 0x%x, logical link handle = 0x%x\n",
1398 EntryNum
, pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
,
1399 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
));
1400 memcpy(&pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].Tx_Flow_Spec
,
1401 &TxFlowSpec
, sizeof(struct hci_flow_spec
));
1402 memcpy(&pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].Rx_Flow_Spec
,
1403 &RxFlowSpec
, sizeof(struct hci_flow_spec
));
1405 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].bLLCompleteEventIsSet
= false;
1407 if (pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].bLLCancelCMDIsSetandComplete
)
1408 LogCompEventstatus
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1409 bthci_EventLogicalLinkComplete(padapter
,
1411 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtPhyLinkhandle
,
1412 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
, i
, EntryNum
);
1414 pBTinfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
[i
].bLLCompleteEventIsSet
= true;
1417 pBtMgnt
->BtCurrentLogLinkhandle
= AssignLogHandle
;
1424 bthci_EventLogicalLinkComplete(padapter
,
1425 HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE
, 0, 0, 0, EntryNum
);
1427 pBtMgnt
->bLogLinkInProgress
= false;
1430 bthci_EventLogicalLinkComplete(padapter
,
1431 HCI_STATUS_CONTROLLER_BUSY
, 0, 0, 0, EntryNum
);
1437 bthci_StartBeaconAndConnect(
1438 struct rtw_adapter
*padapter
,
1439 struct packet_irp_hcicmd_data
*pHciCmd
,
1443 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
1444 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1445 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
1447 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("StartBeaconAndConnect, CurrentAssocNum =%d, AMPRole =%d\n",
1449 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AMPRole
));
1451 if (!pBtMgnt
->CheckChnlIsSuit
) {
1452 bthci_EventPhysicalLinkComplete(padapter
, HCI_STATUS_CONNECT_REJ_NOT_SUIT_CHNL_FOUND
, CurrentAssocNum
, INVALID_PL_HANDLE
);
1453 bthci_RemoveEntryByEntryNum(padapter
, CurrentAssocNum
);
1457 if (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AMPRole
== AMP_BTAP_CREATOR
) {
1458 rsprintf((char *)pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTSsidBuf
, 32, "AMP-%02x-%02x-%02x-%02x-%02x-%02x",
1459 padapter
->eeprompriv
.mac_addr
[0],
1460 padapter
->eeprompriv
.mac_addr
[1],
1461 padapter
->eeprompriv
.mac_addr
[2],
1462 padapter
->eeprompriv
.mac_addr
[3],
1463 padapter
->eeprompriv
.mac_addr
[4],
1464 padapter
->eeprompriv
.mac_addr
[5]);
1465 } else if (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AMPRole
== AMP_BTAP_JOINER
) {
1466 rsprintf((char *)pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTSsidBuf
, 32, "AMP-%02x-%02x-%02x-%02x-%02x-%02x",
1467 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[0],
1468 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[1],
1469 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[2],
1470 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[3],
1471 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[4],
1472 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTRemoteMACAddr
[5]);
1475 FillOctetString(pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTSsid
, pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTSsidBuf
, 21);
1476 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].BTSsid
.Length
= 21;
1478 /* To avoid set the start ap or connect twice, or the original connection will be disconnected. */
1479 if (!pBtMgnt
->bBTConnectInProgress
) {
1480 pBtMgnt
->bBTConnectInProgress
= true;
1481 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], BT Connect in progress ON!!\n"));
1482 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_STARTING
, STATE_CMD_MAC_START_COMPLETE
, CurrentAssocNum
);
1484 /* 20100325 Joseph: Check RF ON/OFF. */
1485 /* If RF OFF, it reschedule connecting operation after 50ms. */
1486 if (!bthci_CheckRfStateBeforeConnect(padapter
))
1489 if (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AMPRole
== AMP_BTAP_CREATOR
) {
1490 /* These macros need braces */
1491 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_CONNECTING
, STATE_CMD_MAC_CONNECT_COMPLETE
, CurrentAssocNum
);
1492 } else if (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AMPRole
== AMP_BTAP_JOINER
) {
1493 bthci_ResponderStartToScan(padapter
);
1496 RT_PRINT_STR(_module_rtl871x_mlme_c_
, _drv_notice_
,
1497 "StartBeaconAndConnect, SSID:\n",
1498 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].BTSsid
.Octet
,
1499 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].BTSsid
.Length
);
1502 static void bthci_ResetBtMgnt(struct bt_mgnt
*pBtMgnt
)
1504 pBtMgnt
->BtOperationOn
= false;
1505 pBtMgnt
->bBTConnectInProgress
= false;
1506 pBtMgnt
->bLogLinkInProgress
= false;
1507 pBtMgnt
->bPhyLinkInProgress
= false;
1508 pBtMgnt
->bPhyLinkInProgressStartLL
= false;
1509 pBtMgnt
->DisconnectEntryNum
= 0xff;
1510 pBtMgnt
->bStartSendSupervisionPkt
= false;
1511 pBtMgnt
->JoinerNeedSendAuth
= false;
1512 pBtMgnt
->CurrentBTConnectionCnt
= 0;
1513 pBtMgnt
->BTCurrentConnectType
= BT_DISCONNECT
;
1514 pBtMgnt
->BTReceiveConnectPkt
= BT_DISCONNECT
;
1515 pBtMgnt
->BTAuthCount
= 0;
1516 pBtMgnt
->btLogoTest
= 0;
1519 static void bthci_ResetBtHciInfo(struct bt_hci_info
*pBtHciInfo
)
1521 pBtHciInfo
->BTEventMask
= 0;
1522 pBtHciInfo
->BTEventMaskPage2
= 0;
1523 pBtHciInfo
->ConnAcceptTimeout
= 10000;
1524 pBtHciInfo
->PageTimeout
= 0x30;
1525 pBtHciInfo
->LocationDomainAware
= 0x0;
1526 pBtHciInfo
->LocationDomain
= 0x5858;
1527 pBtHciInfo
->LocationDomainOptions
= 0x58;
1528 pBtHciInfo
->LocationOptions
= 0x0;
1529 pBtHciInfo
->FlowControlMode
= 0x1; /* 0:Packet based data flow control mode(BR/EDR), 1: Data block based data flow control mode(AMP). */
1531 pBtHciInfo
->enFlush_LLH
= 0;
1532 pBtHciInfo
->FLTO_LLH
= 0;
1534 /* Test command only */
1535 pBtHciInfo
->bTestIsEnd
= true;
1536 pBtHciInfo
->bInTestMode
= false;
1537 pBtHciInfo
->bTestNeedReport
= false;
1538 pBtHciInfo
->TestScenario
= 0xff;
1539 pBtHciInfo
->TestReportInterval
= 0x01;
1540 pBtHciInfo
->TestCtrType
= 0x5d;
1541 pBtHciInfo
->TestEventType
= 0x00;
1542 pBtHciInfo
->TestNumOfFrame
= 0;
1543 pBtHciInfo
->TestNumOfErrFrame
= 0;
1544 pBtHciInfo
->TestNumOfBits
= 0;
1545 pBtHciInfo
->TestNumOfErrBits
= 0;
1548 static void bthci_ResetBtSec(struct rtw_adapter
*padapter
, struct bt_security
*pBtSec
)
1550 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
1552 /* Set BT used HW or SW encrypt !! */
1553 if (GET_HAL_DATA(padapter
)->bBTMode
)
1554 pBtSec
->bUsedHwEncrypt
= true;
1556 pBtSec
->bUsedHwEncrypt
= false;
1557 RT_TRACE(_module_rtl871x_security_c_
, _drv_info_
,
1558 "%s: bUsedHwEncrypt =%d\n", __func__
, pBtSec
->bUsedHwEncrypt
);
1560 pBtSec
->RSNIE
.Octet
= pBtSec
->RSNIEBuf
;
1563 static void bthci_ResetBtExtInfo(struct bt_mgnt
*pBtMgnt
)
1567 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
1568 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
= 0;
1569 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
= 0;
1570 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
= 0;
1571 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
= BT_PROFILE_NONE
;
1572 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
= BT_SPEC_2_1_EDR
;
1573 pBtMgnt
->ExtConfig
.linkInfo
[i
].BT_RSSI
= 0;
1574 pBtMgnt
->ExtConfig
.linkInfo
[i
].TrafficProfile
= BT_PROFILE_NONE
;
1575 pBtMgnt
->ExtConfig
.linkInfo
[i
].linkRole
= BT_LINK_MASTER
;
1578 pBtMgnt
->ExtConfig
.CurrentConnectHandle
= 0;
1579 pBtMgnt
->ExtConfig
.CurrentIncomingTrafficMode
= 0;
1580 pBtMgnt
->ExtConfig
.CurrentOutgoingTrafficMode
= 0;
1581 pBtMgnt
->ExtConfig
.MIN_BT_RSSI
= 0;
1582 pBtMgnt
->ExtConfig
.NumberOfHandle
= 0;
1583 pBtMgnt
->ExtConfig
.NumberOfSCO
= 0;
1584 pBtMgnt
->ExtConfig
.CurrentBTStatus
= 0;
1585 pBtMgnt
->ExtConfig
.HCIExtensionVer
= 0;
1587 pBtMgnt
->ExtConfig
.bManualControl
= false;
1588 pBtMgnt
->ExtConfig
.bBTBusy
= false;
1589 pBtMgnt
->ExtConfig
.bBTA2DPBusy
= false;
1592 static enum hci_status
bthci_CmdReset(struct rtw_adapter
*_padapter
, u8 bNeedSendEvent
)
1594 enum hci_status status
= HCI_STATUS_SUCCESS
;
1595 struct rtw_adapter
*padapter
;
1596 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
1597 struct bt_30info
*pBTInfo
;
1598 struct bt_mgnt
*pBtMgnt
;
1599 struct bt_hci_info
*pBtHciInfo
;
1600 struct bt_security
*pBtSec
;
1601 struct bt_dgb
*pBtDbg
;
1604 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("bthci_CmdReset()\n"));
1606 padapter
= GetDefaultAdapter(_padapter
);
1607 pBTInfo
= GET_BT_INFO(padapter
);
1608 pBtMgnt
= &pBTInfo
->BtMgnt
;
1609 pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1610 pBtSec
= &pBTInfo
->BtSec
;
1611 pBtDbg
= &pBTInfo
->BtDbg
;
1613 pBTInfo
->padapter
= padapter
;
1615 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++)
1616 bthci_ResetEntry(padapter
, i
);
1618 bthci_ResetBtMgnt(pBtMgnt
);
1619 bthci_ResetBtHciInfo(pBtHciInfo
);
1620 bthci_ResetBtSec(padapter
, pBtSec
);
1622 pBtMgnt
->BTChannel
= BT_Default_Chnl
;
1623 pBtMgnt
->CheckChnlIsSuit
= true;
1625 pBTInfo
->BTBeaconTmrOn
= false;
1627 pBtMgnt
->bCreateSpportQos
= true;
1629 del_timer_sync(&pBTInfo
->BTHCIDiscardAclDataTimer
);
1630 del_timer_sync(&pBTInfo
->BTBeaconTimer
);
1632 HALBT_SetRtsCtsNoLenLimit(padapter
);
1634 /* Maybe we need to take care Group != AES case !! */
1635 /* now we Pairwise and Group all used AES !! */
1637 bthci_ResetBtExtInfo(pBtMgnt
);
1639 /* send command complete event here when all data are received. */
1640 if (bNeedSendEvent
) {
1641 u8 localBuf
[6] = "";
1644 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1646 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1648 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1649 OGF_SET_EVENT_MASK_COMMAND
,
1653 /* Return parameters starts from here */
1654 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1655 pRetPar
[0] = status
; /* status */
1657 PPacketIrpEvent
->Length
= len
;
1659 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1665 static enum hci_status
1666 bthci_CmdWriteRemoteAMPAssoc(
1667 struct rtw_adapter
*padapter
,
1668 struct packet_irp_hcicmd_data
*pHciCmd
1671 enum hci_status status
= HCI_STATUS_SUCCESS
;
1672 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1673 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
1677 pBtDbg
->dbgHciInfo
.hciCmdCntWriteRemoteAmpAssoc
++;
1678 PhyLinkHandle
= *((u8
*)pHciCmd
->Data
);
1679 CurrentAssocNum
= bthci_GetCurrentEntryNum(padapter
, PhyLinkHandle
);
1681 if (CurrentAssocNum
== 0xff) {
1682 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("WriteRemoteAMPAssoc, No such Handle in the Entry\n"));
1683 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1684 bthci_EventWriteRemoteAmpAssoc(padapter
, status
, PhyLinkHandle
);
1688 if (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocfragment
== NULL
) {
1689 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("WriteRemoteAMPAssoc, AMP controller is busy\n"));
1690 status
= HCI_STATUS_CONTROLLER_BUSY
;
1691 bthci_EventWriteRemoteAmpAssoc(padapter
, status
, PhyLinkHandle
);
1695 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.BtPhyLinkhandle
= PhyLinkHandle
;/* u8 *)pHciCmd->Data); */
1696 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.LenSoFar
= *((u16
*)((u8
*)pHciCmd
->Data
+1));
1697 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
= *((u16
*)((u8
*)pHciCmd
->Data
+3));
1699 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("WriteRemoteAMPAssoc, LenSoFar = 0x%x, AssocRemLen = 0x%x\n",
1700 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.LenSoFar
,
1701 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
));
1703 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
),
1704 ("WriteRemoteAMPAssoc fragment \n"),
1706 pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
+5);
1707 if ((pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
) > MAX_AMP_ASSOC_FRAG_LEN
) {
1708 memcpy(((u8
*)pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocfragment
+(pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.LenSoFar
*(sizeof(u8
)))),
1709 (u8
*)pHciCmd
->Data
+5,
1710 MAX_AMP_ASSOC_FRAG_LEN
);
1712 memcpy((u8
*)(pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocfragment
)+(pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.LenSoFar
*(sizeof(u8
))),
1713 ((u8
*)pHciCmd
->Data
+5),
1714 (pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
));
1716 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), "WriteRemoteAMPAssoc :\n",
1717 pHciCmd
->Data
+5, pBTInfo
->BtAsocEntry
[CurrentAssocNum
].AmpAsocCmdData
.AMPAssocRemLen
);
1719 if (!bthci_GetAssocInfo(padapter
, CurrentAssocNum
))
1720 status
= HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE
;
1722 bthci_EventWriteRemoteAmpAssoc(padapter
, status
, PhyLinkHandle
);
1724 bthci_StartBeaconAndConnect(padapter
, pHciCmd
, CurrentAssocNum
);
1731 static enum hci_status
bthci_CmdReadConnectionAcceptTimeout(struct rtw_adapter
*padapter
)
1733 enum hci_status status
= HCI_STATUS_SUCCESS
;
1734 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
1735 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1736 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1737 u8 localBuf
[8] = "";
1740 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1743 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1745 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1746 OGF_SET_EVENT_MASK_COMMAND
,
1747 HCI_READ_CONNECTION_ACCEPT_TIMEOUT
,
1750 /* Return parameters starts from here */
1751 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1752 pRetPar
[0] = status
; /* status */
1753 pu2Temp
= (u16
*)&pRetPar
[1]; /* Conn_Accept_Timeout */
1754 *pu2Temp
= pBtHciInfo
->ConnAcceptTimeout
;
1756 PPacketIrpEvent
->Length
= len
;
1758 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1764 static enum hci_status
1765 bthci_CmdWriteConnectionAcceptTimeout(
1766 struct rtw_adapter
*padapter
,
1767 struct packet_irp_hcicmd_data
*pHciCmd
1770 enum hci_status status
= HCI_STATUS_SUCCESS
;
1771 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1772 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1774 u8 localBuf
[6] = "";
1777 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1779 pu2Temp
= (u16
*)&pHciCmd
->Data
[0];
1780 pBtHciInfo
->ConnAcceptTimeout
= *pu2Temp
;
1781 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("ConnAcceptTimeout = 0x%x",
1782 pBtHciInfo
->ConnAcceptTimeout
));
1784 /* send command complete event here when all data are received. */
1785 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1787 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1788 OGF_SET_EVENT_MASK_COMMAND
,
1789 HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT
,
1792 /* Return parameters starts from here */
1793 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1794 pRetPar
[0] = status
; /* status */
1796 PPacketIrpEvent
->Length
= len
;
1798 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1803 static enum hci_status
1804 bthci_CmdReadPageTimeout(
1805 struct rtw_adapter
*padapter
,
1806 struct packet_irp_hcicmd_data
*pHciCmd
1809 enum hci_status status
= HCI_STATUS_SUCCESS
;
1810 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1811 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1812 u8 localBuf
[8] = "";
1815 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1818 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1820 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1821 OGF_SET_EVENT_MASK_COMMAND
,
1822 HCI_READ_PAGE_TIMEOUT
,
1825 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Read PageTimeout = 0x%x\n", pBtHciInfo
->PageTimeout
));
1826 /* Return parameters starts from here */
1827 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1828 pRetPar
[0] = status
; /* status */
1829 pu2Temp
= (u16
*)&pRetPar
[1]; /* Page_Timeout */
1830 *pu2Temp
= pBtHciInfo
->PageTimeout
;
1832 PPacketIrpEvent
->Length
= len
;
1834 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1839 static enum hci_status
1840 bthci_CmdWritePageTimeout(
1841 struct rtw_adapter
*padapter
,
1842 struct packet_irp_hcicmd_data
*pHciCmd
1845 enum hci_status status
= HCI_STATUS_SUCCESS
;
1846 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
1847 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
1850 pu2Temp
= (u16
*)&pHciCmd
->Data
[0];
1851 pBtHciInfo
->PageTimeout
= *pu2Temp
;
1852 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Write PageTimeout = 0x%x\n",
1853 pBtHciInfo
->PageTimeout
));
1855 /* send command complete event here when all data are received. */
1857 u8 localBuf
[6] = "";
1860 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1862 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1864 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1865 OGF_SET_EVENT_MASK_COMMAND
,
1866 HCI_WRITE_PAGE_TIMEOUT
,
1869 /* Return parameters starts from here */
1870 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1871 pRetPar
[0] = status
; /* status */
1873 PPacketIrpEvent
->Length
= len
;
1875 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1881 static enum hci_status
1882 bthci_CmdReadLinkSupervisionTimeout(
1883 struct rtw_adapter
*padapter
,
1884 struct packet_irp_hcicmd_data
*pHciCmd
1887 enum hci_status status
= HCI_STATUS_SUCCESS
;
1888 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
1889 u8 physicalLinkHandle
, EntryNum
;
1891 physicalLinkHandle
= *((u8
*)pHciCmd
->Data
);
1893 EntryNum
= bthci_GetCurrentEntryNum(padapter
, physicalLinkHandle
);
1895 if (EntryNum
== 0xff) {
1896 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("ReadLinkSupervisionTimeout, No such Handle in the Entry\n"));
1897 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1901 if (pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
!= physicalLinkHandle
)
1902 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1905 u8 localBuf
[10] = "";
1908 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1911 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1913 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1914 OGF_SET_EVENT_MASK_COMMAND
,
1915 HCI_READ_LINK_SUPERVISION_TIMEOUT
,
1918 /* Return parameters starts from here */
1919 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1920 pRetPar
[0] = status
;
1921 pRetPar
[1] = pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
1923 pu2Temp
= (u16
*)&pRetPar
[3]; /* Conn_Accept_Timeout */
1924 *pu2Temp
= pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.LinkSuperversionTimeout
;
1926 PPacketIrpEvent
->Length
= len
;
1928 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1934 static enum hci_status
1935 bthci_CmdWriteLinkSupervisionTimeout(
1936 struct rtw_adapter
*padapter
,
1937 struct packet_irp_hcicmd_data
*pHciCmd
1940 enum hci_status status
= HCI_STATUS_SUCCESS
;
1941 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
1942 u8 physicalLinkHandle
, EntryNum
;
1944 physicalLinkHandle
= *((u8
*)pHciCmd
->Data
);
1946 EntryNum
= bthci_GetCurrentEntryNum(padapter
, physicalLinkHandle
);
1948 if (EntryNum
== 0xff) {
1949 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("WriteLinkSupervisionTimeout, No such Handle in the Entry\n"));
1950 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1952 if (pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
!= physicalLinkHandle
) {
1953 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
1955 pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.LinkSuperversionTimeout
= *((u16
*)(((u8
*)pHciCmd
->Data
)+2));
1956 RTPRINT(FIOCTL
, IOCTL_STATE
, ("BT Write LinkSuperversionTimeout[%d] = 0x%x\n",
1957 EntryNum
, pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.LinkSuperversionTimeout
));
1962 u8 localBuf
[8] = "";
1965 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
1967 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
1969 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
1970 OGF_SET_EVENT_MASK_COMMAND
,
1971 HCI_WRITE_LINK_SUPERVISION_TIMEOUT
,
1974 /* Return parameters starts from here */
1975 pRetPar
= &PPacketIrpEvent
->Data
[len
];
1976 pRetPar
[0] = status
;
1977 pRetPar
[1] = pBTinfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
;
1980 PPacketIrpEvent
->Length
= len
;
1982 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
1988 static enum hci_status
1989 bthci_CmdEnhancedFlush(
1990 struct rtw_adapter
*padapter
,
1991 struct packet_irp_hcicmd_data
*pHciCmd
1994 enum hci_status status
= HCI_STATUS_SUCCESS
;
1995 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
1996 struct bt_hci_info
*pBtHciInfo
= &pBTinfo
->BtHciInfo
;
2000 logicHandle
= *((u16
*)&pHciCmd
->Data
[0]);
2001 Packet_Type
= pHciCmd
->Data
[2];
2003 if (Packet_Type
!= 0)
2004 status
= HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE
;
2006 pBtHciInfo
->enFlush_LLH
= logicHandle
;
2008 if (bthci_DiscardTxPackets(padapter
, pBtHciInfo
->enFlush_LLH
))
2009 bthci_EventFlushOccurred(padapter
, pBtHciInfo
->enFlush_LLH
);
2011 /* should send command status event */
2012 bthci_EventCommandStatus(padapter
,
2013 OGF_SET_EVENT_MASK_COMMAND
,
2017 if (pBtHciInfo
->enFlush_LLH
) {
2018 bthci_EventEnhancedFlushComplete(padapter
, pBtHciInfo
->enFlush_LLH
);
2019 pBtHciInfo
->enFlush_LLH
= 0;
2025 static enum hci_status
2026 bthci_CmdReadLogicalLinkAcceptTimeout(
2027 struct rtw_adapter
*padapter
,
2028 struct packet_irp_hcicmd_data
*pHciCmd
2031 enum hci_status status
= HCI_STATUS_SUCCESS
;
2032 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
2033 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2034 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2035 u8 localBuf
[8] = "";
2038 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2041 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2043 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2044 OGF_SET_EVENT_MASK_COMMAND
,
2045 HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT
,
2048 /* Return parameters starts from here */
2049 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2050 pRetPar
[0] = status
;
2052 pu2Temp
= (u16
*)&pRetPar
[1]; /* Conn_Accept_Timeout */
2053 *pu2Temp
= pBtHciInfo
->LogicalAcceptTimeout
;
2055 PPacketIrpEvent
->Length
= len
;
2057 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2062 static enum hci_status
2063 bthci_CmdWriteLogicalLinkAcceptTimeout(
2064 struct rtw_adapter
*padapter
,
2065 struct packet_irp_hcicmd_data
*pHciCmd
2068 enum hci_status status
= HCI_STATUS_SUCCESS
;
2069 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
2070 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2071 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2072 u8 localBuf
[6] = "";
2075 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2077 pBtHciInfo
->LogicalAcceptTimeout
= *((u16
*)pHciCmd
->Data
);
2079 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2081 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2082 OGF_SET_EVENT_MASK_COMMAND
,
2083 HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT
,
2086 /* Return parameters starts from here */
2087 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2088 pRetPar
[0] = status
;
2091 PPacketIrpEvent
->Length
= len
;
2093 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2097 static enum hci_status
2098 bthci_CmdSetEventMask(
2099 struct rtw_adapter
*padapter
,
2100 struct packet_irp_hcicmd_data
*pHciCmd
2103 enum hci_status status
= HCI_STATUS_SUCCESS
;
2104 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
2105 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2106 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2108 u8 localBuf
[6] = "";
2111 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2113 pu8Temp
= (u8
*)&pHciCmd
->Data
[0];
2114 pBtHciInfo
->BTEventMask
= *pu8Temp
;
2115 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("BTEventMask = 0x%"i64fmt
"x\n",
2116 pBtHciInfo
->BTEventMask
));
2118 /* send command complete event here when all data are received. */
2119 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2121 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2122 OGF_SET_EVENT_MASK_COMMAND
,
2126 /* Return parameters starts from here */
2127 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2128 pRetPar
[0] = status
; /* status */
2130 PPacketIrpEvent
->Length
= len
;
2132 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2138 static enum hci_status
2139 bthci_CmdSetEventMaskPage2(
2140 struct rtw_adapter
*padapter
,
2141 struct packet_irp_hcicmd_data
*pHciCmd
2144 enum hci_status status
= HCI_STATUS_SUCCESS
;
2145 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2146 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2148 u8 localBuf
[6] = "";
2151 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2153 pu8Temp
= (u8
*)&pHciCmd
->Data
[0];
2154 pBtHciInfo
->BTEventMaskPage2
= *pu8Temp
;
2155 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("BTEventMaskPage2 = 0x%"i64fmt
"x\n",
2156 pBtHciInfo
->BTEventMaskPage2
));
2158 /* send command complete event here when all data are received. */
2159 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2161 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2162 OGF_SET_EVENT_MASK_COMMAND
,
2163 HCI_SET_EVENT_MASK_PAGE_2
,
2166 /* Return parameters starts from here */
2167 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2168 pRetPar
[0] = status
; /* status */
2170 PPacketIrpEvent
->Length
= len
;
2172 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2177 static enum hci_status
2178 bthci_CmdReadLocationData(
2179 struct rtw_adapter
*padapter
,
2180 struct packet_irp_hcicmd_data
*pHciCmd
2183 enum hci_status status
= HCI_STATUS_SUCCESS
;
2184 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2185 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2186 u8 localBuf
[12] = "";
2189 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2192 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2194 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2195 OGF_SET_EVENT_MASK_COMMAND
,
2196 HCI_READ_LOCATION_DATA
,
2198 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DomainAware = 0x%x\n", pBtHciInfo
->LocationDomainAware
));
2199 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Domain = 0x%x\n", pBtHciInfo
->LocationDomain
));
2200 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DomainOptions = 0x%x\n", pBtHciInfo
->LocationDomainOptions
));
2201 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Options = 0x%x\n", pBtHciInfo
->LocationOptions
));
2203 /* Return parameters starts from here */
2204 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2205 pRetPar
[0] = status
;
2207 pRetPar
[1] = pBtHciInfo
->LocationDomainAware
; /* 0x0; Location_Domain_Aware */
2208 pu2Temp
= (u16
*)&pRetPar
[2]; /* Location_Domain */
2209 *pu2Temp
= pBtHciInfo
->LocationDomain
; /* 0x5858; */
2210 pRetPar
[4] = pBtHciInfo
->LocationDomainOptions
; /* 0x58; Location_Domain_Options */
2211 pRetPar
[5] = pBtHciInfo
->LocationOptions
; /* 0x0; Location_Options */
2213 PPacketIrpEvent
->Length
= len
;
2215 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2219 static enum hci_status
2220 bthci_CmdWriteLocationData(
2221 struct rtw_adapter
*padapter
,
2222 struct packet_irp_hcicmd_data
*pHciCmd
2225 enum hci_status status
= HCI_STATUS_SUCCESS
;
2226 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2227 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2229 u8 localBuf
[6] = "";
2232 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2234 pBtHciInfo
->LocationDomainAware
= pHciCmd
->Data
[0];
2235 pu2Temp
= (u16
*)&pHciCmd
->Data
[1];
2236 pBtHciInfo
->LocationDomain
= *pu2Temp
;
2237 pBtHciInfo
->LocationDomainOptions
= pHciCmd
->Data
[3];
2238 pBtHciInfo
->LocationOptions
= pHciCmd
->Data
[4];
2239 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DomainAware = 0x%x\n", pBtHciInfo
->LocationDomainAware
));
2240 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Domain = 0x%x\n", pBtHciInfo
->LocationDomain
));
2241 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DomainOptions = 0x%x\n", pBtHciInfo
->LocationDomainOptions
));
2242 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Options = 0x%x\n", pBtHciInfo
->LocationOptions
));
2244 /* send command complete event here when all data are received. */
2245 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2247 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2248 OGF_SET_EVENT_MASK_COMMAND
,
2249 HCI_WRITE_LOCATION_DATA
,
2252 /* Return parameters starts from here */
2253 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2254 pRetPar
[0] = status
; /* status */
2256 PPacketIrpEvent
->Length
= len
;
2258 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2263 static enum hci_status
2264 bthci_CmdReadFlowControlMode(
2265 struct rtw_adapter
*padapter
,
2266 struct packet_irp_hcicmd_data
*pHciCmd
2269 enum hci_status status
= HCI_STATUS_SUCCESS
;
2270 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2271 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2272 u8 localBuf
[7] = "";
2275 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2277 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2279 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2280 OGF_SET_EVENT_MASK_COMMAND
,
2281 HCI_READ_FLOW_CONTROL_MODE
,
2284 /* Return parameters starts from here */
2285 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2286 pRetPar
[0] = status
;
2287 pRetPar
[1] = pBtHciInfo
->FlowControlMode
; /* Flow Control Mode */
2289 PPacketIrpEvent
->Length
= len
;
2291 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2295 static enum hci_status
2296 bthci_CmdWriteFlowControlMode(
2297 struct rtw_adapter
*padapter
,
2298 struct packet_irp_hcicmd_data
*pHciCmd
2301 enum hci_status status
= HCI_STATUS_SUCCESS
;
2302 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2303 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2304 u8 localBuf
[6] = "";
2307 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2309 pBtHciInfo
->FlowControlMode
= pHciCmd
->Data
[0];
2311 /* send command complete event here when all data are received. */
2312 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2314 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2315 OGF_SET_EVENT_MASK_COMMAND
,
2316 HCI_WRITE_FLOW_CONTROL_MODE
,
2319 /* Return parameters starts from here */
2320 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2321 pRetPar
[0] = status
; /* status */
2323 PPacketIrpEvent
->Length
= len
;
2325 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2330 static enum hci_status
2331 bthci_CmdReadBestEffortFlushTimeout(
2332 struct rtw_adapter
*padapter
,
2333 struct packet_irp_hcicmd_data
*pHciCmd
2336 enum hci_status status
= HCI_STATUS_SUCCESS
;
2337 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
2338 u16 i
, j
, logicHandle
;
2339 u32 BestEffortFlushTimeout
= 0xffffffff;
2342 logicHandle
= *((u16
*)pHciCmd
->Data
);
2343 /* find an matched logical link index and copy the data */
2344 for (j
= 0; j
< MAX_BT_ASOC_ENTRY_NUM
; j
++) {
2345 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
2346 if (pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
== logicHandle
) {
2347 BestEffortFlushTimeout
= pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BestEffortFlushTimeout
;
2355 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2358 u8 localBuf
[10] = "";
2361 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2364 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2366 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2367 OGF_SET_EVENT_MASK_COMMAND
,
2368 HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT
,
2371 /* Return parameters starts from here */
2372 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2373 pRetPar
[0] = status
;
2374 pu4Temp
= (u32
*)&pRetPar
[1]; /* Best_Effort_Flush_Timeout */
2375 *pu4Temp
= BestEffortFlushTimeout
;
2377 PPacketIrpEvent
->Length
= len
;
2379 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2384 static enum hci_status
2385 bthci_CmdWriteBestEffortFlushTimeout(
2386 struct rtw_adapter
*padapter
,
2387 struct packet_irp_hcicmd_data
*pHciCmd
2390 enum hci_status status
= HCI_STATUS_SUCCESS
;
2391 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
2392 u16 i
, j
, logicHandle
;
2393 u32 BestEffortFlushTimeout
= 0xffffffff;
2396 logicHandle
= *((u16
*)pHciCmd
->Data
);
2397 BestEffortFlushTimeout
= *((u32
*)(pHciCmd
->Data
+1));
2399 /* find an matched logical link index and copy the data */
2400 for (j
= 0; j
< MAX_BT_ASOC_ENTRY_NUM
; j
++) {
2401 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
2402 if (pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
== logicHandle
) {
2403 pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BestEffortFlushTimeout
= BestEffortFlushTimeout
;
2411 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2414 u8 localBuf
[6] = "";
2417 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2419 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2421 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2422 OGF_SET_EVENT_MASK_COMMAND
,
2423 HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT
,
2426 /* Return parameters starts from here */
2427 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2428 pRetPar
[0] = status
;
2430 PPacketIrpEvent
->Length
= len
;
2432 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2437 static enum hci_status
2438 bthci_CmdShortRangeMode(
2439 struct rtw_adapter
*padapter
,
2440 struct packet_irp_hcicmd_data
*pHciCmd
2443 enum hci_status status
= HCI_STATUS_SUCCESS
;
2444 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2445 u8 PhyLinkHandle
, EntryNum
, ShortRangeMode
;
2447 PhyLinkHandle
= pHciCmd
->Data
[0];
2448 ShortRangeMode
= pHciCmd
->Data
[1];
2449 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("PLH = 0x%x, Short_Range_Mode = 0x%x\n", PhyLinkHandle
, ShortRangeMode
));
2451 EntryNum
= bthci_GetCurrentEntryNum(padapter
, PhyLinkHandle
);
2452 if (EntryNum
!= 0xff) {
2453 pBTInfo
->BtAsocEntry
[EntryNum
].ShortRangeMode
= ShortRangeMode
;
2455 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("No such PLH(0x%x)\n", PhyLinkHandle
));
2456 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2459 bthci_EventCommandStatus(padapter
,
2460 OGF_SET_EVENT_MASK_COMMAND
,
2461 HCI_SHORT_RANGE_MODE
,
2464 bthci_EventShortRangeModeChangeComplete(padapter
, status
, ShortRangeMode
, EntryNum
);
2469 static enum hci_status
bthci_CmdReadLocalSupportedCommands(struct rtw_adapter
*padapter
)
2471 enum hci_status status
= HCI_STATUS_SUCCESS
;
2472 u8 localBuf
[TmpLocalBufSize
] = "";
2473 u8
*pRetPar
, *pSupportedCmds
;
2475 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2477 /* send command complete event here when all data are received. */
2478 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2479 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2481 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2482 OGF_INFORMATIONAL_PARAMETERS
,
2483 HCI_READ_LOCAL_SUPPORTED_COMMANDS
,
2486 /* Return parameters starts from here */
2487 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2488 pRetPar
[0] = status
; /* status */
2490 pSupportedCmds
= &pRetPar
[1];
2491 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[5]= 0xc0\nBit [6]= Set Event Mask, [7]= Reset\n"));
2492 pSupportedCmds
[5] = 0xc0;
2493 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[6]= 0x01\nBit [0]= Set Event Filter\n"));
2494 pSupportedCmds
[6] = 0x01;
2495 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[7]= 0x0c\nBit [2]= Read Connection Accept Timeout, [3]= Write Connection Accept Timeout\n"));
2496 pSupportedCmds
[7] = 0x0c;
2497 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[10]= 0x80\nBit [7]= Host Number Of Completed Packets\n"));
2498 pSupportedCmds
[10] = 0x80;
2499 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[11]= 0x03\nBit [0]= Read Link Supervision Timeout, [1]= Write Link Supervision Timeout\n"));
2500 pSupportedCmds
[11] = 0x03;
2501 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[14]= 0xa8\nBit [3]= Read Local Version Information, [5]= Read Local Supported Features, [7]= Read Buffer Size\n"));
2502 pSupportedCmds
[14] = 0xa8;
2503 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[15]= 0x1c\nBit [2]= Read Failed Contact Count, [3]= Reset Failed Contact Count, [4]= Get Link Quality\n"));
2504 pSupportedCmds
[15] = 0x1c;
2505 /* pSupportedCmds[16] = 0x04; */
2506 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[19]= 0x40\nBit [6]= Enhanced Flush\n"));
2507 pSupportedCmds
[19] = 0x40;
2508 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[21]= 0xff\nBit [0]= Create Physical Link, [1]= Accept Physical Link, [2]= Disconnect Physical Link, [3]= Create Logical Link\n"));
2509 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), (" [4]= Accept Logical Link, [5]= Disconnect Logical Link, [6]= Logical Link Cancel, [7]= Flow Spec Modify\n"));
2510 pSupportedCmds
[21] = 0xff;
2511 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[22]= 0xff\nBit [0]= Read Logical Link Accept Timeout, [1]= Write Logical Link Accept Timeout, [2]= Set Event Mask Page 2, [3]= Read Location Data\n"));
2512 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), (" [4]= Write Location Data, [5]= Read Local AMP Info, [6]= Read Local AMP_ASSOC, [7]= Write Remote AMP_ASSOC\n"));
2513 pSupportedCmds
[22] = 0xff;
2514 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[23]= 0x07\nBit [0]= Read Flow Control Mode, [1]= Write Flow Control Mode, [2]= Read Data Block Size\n"));
2515 pSupportedCmds
[23] = 0x07;
2516 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD
|IOCTL_BT_LOGO
), ("Octet[24]= 0x1c\nBit [2]= Read Best Effort Flush Timeout, [3]= Write Best Effort Flush Timeout, [4]= Short Range Mode\n"));
2517 pSupportedCmds
[24] = 0x1c;
2519 PPacketIrpEvent
->Length
= len
;
2521 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2526 static enum hci_status
bthci_CmdReadLocalSupportedFeatures(struct rtw_adapter
*padapter
)
2528 enum hci_status status
= HCI_STATUS_SUCCESS
;
2529 u8 localBuf
[TmpLocalBufSize
] = "";
2532 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2534 /* send command complete event here when all data are received. */
2535 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2536 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2538 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2539 OGF_INFORMATIONAL_PARAMETERS
,
2540 HCI_READ_LOCAL_SUPPORTED_FEATURES
,
2543 /* Return parameters starts from here */
2544 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2545 pRetPar
[0] = status
; /* status */
2547 PPacketIrpEvent
->Length
= len
;
2549 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2553 static enum hci_status
bthci_CmdReadLocalAMPAssoc(struct rtw_adapter
*padapter
,
2554 struct packet_irp_hcicmd_data
*pHciCmd
)
2556 enum hci_status status
= HCI_STATUS_SUCCESS
;
2557 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2558 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
2559 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
2560 u8 PhyLinkHandle
, EntryNum
;
2562 pBtDbg
->dbgHciInfo
.hciCmdCntReadLocalAmpAssoc
++;
2563 PhyLinkHandle
= *((u8
*)pHciCmd
->Data
);
2564 EntryNum
= bthci_GetCurrentEntryNum(padapter
, PhyLinkHandle
);
2566 if ((EntryNum
== 0xff) && PhyLinkHandle
!= 0) {
2567 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("ReadLocalAMPAssoc, EntryNum = %d !!!!!, physical link handle = 0x%x\n",
2568 EntryNum
, PhyLinkHandle
));
2569 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2570 } else if (pBtMgnt
->bPhyLinkInProgressStartLL
) {
2571 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2572 pBtMgnt
->bPhyLinkInProgressStartLL
= false;
2574 pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.BtPhyLinkhandle
= *((u8
*)pHciCmd
->Data
);
2575 pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
= *((u16
*)((u8
*)pHciCmd
->Data
+1));
2576 pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.MaxRemoteASSOCLen
= *((u16
*)((u8
*)pHciCmd
->Data
+3));
2577 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("ReadLocalAMPAssoc, LenSoFar =%d, MaxRemoteASSOCLen =%d\n",
2578 pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
,
2579 pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.MaxRemoteASSOCLen
));
2582 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("ReadLocalAMPAssoc, EntryNum = %d !!!!!, physical link handle = 0x%x, LengthSoFar = %x \n",
2583 EntryNum
, PhyLinkHandle
, pBTInfo
->BtAsocEntry
[EntryNum
].AmpAsocCmdData
.LenSoFar
));
2585 /* send command complete event here when all data are received. */
2587 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2589 /* PVOID buffer = padapter->IrpHCILocalbuf.Ptr; */
2590 u8 localBuf
[TmpLocalBufSize
] = "";
2593 u16 typeLen
= 0, remainLen
= 0, ret_index
= 0;
2596 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2597 /* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
2598 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2600 totalLen
+= bthci_CommandCompleteHeader(&localBuf
[0],
2601 OGF_STATUS_PARAMETERS
,
2602 HCI_READ_LOCAL_AMP_ASSOC
,
2604 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("ReadLocalAMPAssoc, Remaining_Len =%d \n", remainLen
));
2605 /* Return parameters starts from here */
2606 pRetPar
= &PPacketIrpEvent
->Data
[totalLen
];
2607 pRetPar
[0] = status
; /* status */
2608 pRetPar
[1] = *((u8
*)pHciCmd
->Data
);
2609 pRemainLen
= (u16
*)&pRetPar
[2]; /* AMP_ASSOC_Remaining_Length */
2610 totalLen
+= 4; /* 0]~[3] */
2613 typeLen
= bthci_AssocMACAddr(padapter
, &pRetPar
[ret_index
]);
2614 totalLen
+= typeLen
;
2615 remainLen
+= typeLen
;
2616 ret_index
+= typeLen
;
2617 typeLen
= bthci_AssocPreferredChannelList(padapter
, &pRetPar
[ret_index
], EntryNum
);
2618 totalLen
+= typeLen
;
2619 remainLen
+= typeLen
;
2620 ret_index
+= typeLen
;
2621 typeLen
= bthci_PALCapabilities(padapter
, &pRetPar
[ret_index
]);
2622 totalLen
+= typeLen
;
2623 remainLen
+= typeLen
;
2624 ret_index
+= typeLen
;
2625 typeLen
= bthci_AssocPALVer(padapter
, &pRetPar
[ret_index
]);
2626 totalLen
+= typeLen
;
2627 remainLen
+= typeLen
;
2628 PPacketIrpEvent
->Length
= (u8
)totalLen
;
2629 *pRemainLen
= remainLen
; /* AMP_ASSOC_Remaining_Length */
2630 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("ReadLocalAMPAssoc, Remaining_Len =%d \n", remainLen
));
2631 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("AMP_ASSOC_fragment : \n"), PPacketIrpEvent
->Data
, totalLen
);
2633 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, totalLen
+2);
2639 static enum hci_status
bthci_CmdReadFailedContactCounter(struct rtw_adapter
*padapter
,
2640 struct packet_irp_hcicmd_data
*pHciCmd
)
2643 enum hci_status status
= HCI_STATUS_SUCCESS
;
2644 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2645 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2646 u8 localBuf
[TmpLocalBufSize
] = "";
2649 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2652 handle
= *((u16
*)pHciCmd
->Data
);
2653 /* send command complete event here when all data are received. */
2654 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2655 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2657 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2658 OGF_STATUS_PARAMETERS
,
2659 HCI_READ_FAILED_CONTACT_COUNTER
,
2662 /* Return parameters starts from here */
2663 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2664 pRetPar
[0] = status
; /* status */
2665 pRetPar
[1] = TWOBYTE_LOWBYTE(handle
);
2666 pRetPar
[2] = TWOBYTE_HIGHTBYTE(handle
);
2667 pRetPar
[3] = TWOBYTE_LOWBYTE(pBtHciInfo
->FailContactCount
);
2668 pRetPar
[4] = TWOBYTE_HIGHTBYTE(pBtHciInfo
->FailContactCount
);
2670 PPacketIrpEvent
->Length
= len
;
2672 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2677 static enum hci_status
2678 bthci_CmdResetFailedContactCounter(
2679 struct rtw_adapter
*padapter
,
2680 struct packet_irp_hcicmd_data
*pHciCmd
2683 enum hci_status status
= HCI_STATUS_SUCCESS
;
2684 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
2685 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2686 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
2688 u8 localBuf
[TmpLocalBufSize
] = "";
2691 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2693 handle
= *((u16
*)pHciCmd
->Data
);
2694 pBtHciInfo
->FailContactCount
= 0;
2696 /* send command complete event here when all data are received. */
2697 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2698 /* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
2699 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2701 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2702 OGF_STATUS_PARAMETERS
,
2703 HCI_RESET_FAILED_CONTACT_COUNTER
,
2706 /* Return parameters starts from here */
2707 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2708 pRetPar
[0] = status
; /* status */
2709 pRetPar
[1] = TWOBYTE_LOWBYTE(handle
);
2710 pRetPar
[2] = TWOBYTE_HIGHTBYTE(handle
);
2712 PPacketIrpEvent
->Length
= len
;
2714 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2719 /* BT 3.0+HS [Vol 2] 7.4.1 */
2721 static enum hci_status
2722 bthci_CmdReadLocalVersionInformation(
2723 struct rtw_adapter
*padapter
2726 enum hci_status status
= HCI_STATUS_SUCCESS
;
2727 /* send command complete event here when all data are received. */
2728 u8 localBuf
[TmpLocalBufSize
] = "";
2731 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2734 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2735 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2737 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2738 OGF_INFORMATIONAL_PARAMETERS
,
2739 HCI_READ_LOCAL_VERSION_INFORMATION
,
2742 /* Return parameters starts from here */
2743 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2744 pRetPar
[0] = status
; /* status */
2745 pRetPar
[1] = 0x05; /* HCI_Version */
2746 pu2Temp
= (u16
*)&pRetPar
[2]; /* HCI_Revision */
2748 pRetPar
[4] = 0x05; /* LMP/PAL_Version */
2749 pu2Temp
= (u16
*)&pRetPar
[5]; /* Manufacturer_Name */
2751 pu2Temp
= (u16
*)&pRetPar
[7]; /* LMP/PAL_Subversion */
2754 PPacketIrpEvent
->Length
= len
;
2756 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("LOCAL_VERSION_INFORMATION\n"));
2757 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("Status %x\n", status
));
2758 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("HCI_Version = 0x05\n"));
2759 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("HCI_Revision = 0x0001\n"));
2760 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("LMP/PAL_Version = 0x05\n"));
2761 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("Manufacturer_Name = 0x0001\n"));
2762 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("LMP/PAL_Subversion = 0x0001\n"));
2764 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2770 static enum hci_status
bthci_CmdReadDataBlockSize(struct rtw_adapter
*padapter
)
2772 enum hci_status status
= HCI_STATUS_SUCCESS
;
2773 u8 localBuf
[TmpLocalBufSize
] = "";
2776 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2779 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2780 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2782 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2783 OGF_INFORMATIONAL_PARAMETERS
,
2784 HCI_READ_DATA_BLOCK_SIZE
,
2787 /* Return parameters starts from here */
2788 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2789 pRetPar
[0] = HCI_STATUS_SUCCESS
; /* status */
2790 pu2Temp
= (u16
*)&pRetPar
[1]; /* Max_ACL_Data_Packet_Length */
2791 *pu2Temp
= Max80211PALPDUSize
;
2793 pu2Temp
= (u16
*)&pRetPar
[3]; /* Data_Block_Length */
2794 *pu2Temp
= Max80211PALPDUSize
;
2795 pu2Temp
= (u16
*)&pRetPar
[5]; /* Total_Num_Data_Blocks */
2796 *pu2Temp
= BTTotalDataBlockNum
;
2798 PPacketIrpEvent
->Length
= len
;
2800 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2806 static enum hci_status
bthci_CmdReadBufferSize(struct rtw_adapter
*padapter
)
2808 enum hci_status status
= HCI_STATUS_SUCCESS
;
2809 u8 localBuf
[TmpLocalBufSize
] = "";
2812 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2815 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2816 /* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
2817 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2819 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2820 OGF_INFORMATIONAL_PARAMETERS
,
2821 HCI_READ_BUFFER_SIZE
,
2823 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Synchronous_Data_Packet_Length = 0x%x\n", BTSynDataPacketLength
));
2824 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Total_Num_ACL_Data_Packets = 0x%x\n", BTTotalDataBlockNum
));
2825 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("Total_Num_Synchronous_Data_Packets = 0x%x\n", BTTotalDataBlockNum
));
2826 /* Return parameters starts from here */
2827 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2828 pRetPar
[0] = status
; /* status */
2829 pu2Temp
= (u16
*)&pRetPar
[1]; /* HC_ACL_Data_Packet_Length */
2830 *pu2Temp
= Max80211PALPDUSize
;
2832 pRetPar
[3] = BTSynDataPacketLength
; /* HC_Synchronous_Data_Packet_Length */
2833 pu2Temp
= (u16
*)&pRetPar
[4]; /* HC_Total_Num_ACL_Data_Packets */
2834 *pu2Temp
= BTTotalDataBlockNum
;
2835 pu2Temp
= (u16
*)&pRetPar
[6]; /* HC_Total_Num_Synchronous_Data_Packets */
2836 *pu2Temp
= BTTotalDataBlockNum
;
2838 PPacketIrpEvent
->Length
= len
;
2840 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2845 static enum hci_status
bthci_CmdReadLocalAMPInfo(struct rtw_adapter
*padapter
)
2847 enum hci_status status
= HCI_STATUS_SUCCESS
;
2848 struct pwrctrl_priv
*ppwrctrl
= &padapter
->pwrctrlpriv
;
2849 u8 localBuf
[TmpLocalBufSize
] = "";
2852 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2855 u32 TotalBandwidth
= BTTOTALBANDWIDTH
, MaxBandGUBandwidth
= BTMAXBANDGUBANDWIDTH
;
2856 u8 ControlType
= 0x01, AmpStatus
= 0x01;
2857 u32 MaxFlushTimeout
= 10000, BestEffortFlushTimeout
= 5000;
2858 u16 MaxPDUSize
= Max80211PALPDUSize
, PalCap
= 0x1, AmpAssocLen
= Max80211AMPASSOCLen
, MinLatency
= 20;
2860 if ((ppwrctrl
->rfoff_reason
& RF_CHANGE_BY_HW
) ||
2861 (ppwrctrl
->rfoff_reason
& RF_CHANGE_BY_SW
)) {
2862 AmpStatus
= AMP_STATUS_NO_CAPACITY_FOR_BT
;
2865 PlatformZeroMemory(&localBuf
[0], TmpLocalBufSize
);
2866 /* PPacketIrpEvent = (struct packet_irp_hcievent_data *)(buffer); */
2867 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2869 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2870 OGF_STATUS_PARAMETERS
,
2871 HCI_READ_LOCAL_AMP_INFO
,
2874 /* Return parameters starts from here */
2875 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2876 pRetPar
[0] = status
; /* status */
2877 pRetPar
[1] = AmpStatus
; /* AMP_Status */
2878 pu4Temp
= (u32
*)&pRetPar
[2]; /* Total_Bandwidth */
2879 *pu4Temp
= TotalBandwidth
; /* 0x19bfcc00;0x7530; */
2880 pu4Temp
= (u32
*)&pRetPar
[6]; /* Max_Guaranteed_Bandwidth */
2881 *pu4Temp
= MaxBandGUBandwidth
; /* 0x19bfcc00;0x4e20; */
2882 pu4Temp
= (u32
*)&pRetPar
[10]; /* Min_Latency */
2883 *pu4Temp
= MinLatency
; /* 150; */
2884 pu4Temp
= (u32
*)&pRetPar
[14]; /* Max_PDU_Size */
2885 *pu4Temp
= MaxPDUSize
;
2886 pRetPar
[18] = ControlType
; /* Controller_Type */
2887 pu2Temp
= (u16
*)&pRetPar
[19]; /* PAL_Capabilities */
2889 pu2Temp
= (u16
*)&pRetPar
[21]; /* AMP_ASSOC_Length */
2890 *pu2Temp
= AmpAssocLen
;
2891 pu4Temp
= (u32
*)&pRetPar
[23]; /* Max_Flush_Timeout */
2892 *pu4Temp
= MaxFlushTimeout
;
2893 pu4Temp
= (u32
*)&pRetPar
[27]; /* Best_Effort_Flush_Timeout */
2894 *pu4Temp
= BestEffortFlushTimeout
;
2896 PPacketIrpEvent
->Length
= len
;
2897 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("AmpStatus = 0x%x\n",
2899 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("TotalBandwidth = 0x%x, MaxBandGUBandwidth = 0x%x, MinLatency = 0x%x, \n MaxPDUSize = 0x%x, ControlType = 0x%x\n",
2900 TotalBandwidth
, MaxBandGUBandwidth
, MinLatency
, MaxPDUSize
, ControlType
));
2901 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("PalCap = 0x%x, AmpAssocLen = 0x%x, MaxFlushTimeout = 0x%x, BestEffortFlushTimeout = 0x%x\n",
2902 PalCap
, AmpAssocLen
, MaxFlushTimeout
, BestEffortFlushTimeout
));
2903 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2907 static enum hci_status
2908 bthci_CmdCreatePhysicalLink(
2909 struct rtw_adapter
*padapter
,
2910 struct packet_irp_hcicmd_data
*pHciCmd
2913 enum hci_status status
;
2914 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2915 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
2917 pBtDbg
->dbgHciInfo
.hciCmdCntCreatePhyLink
++;
2919 status
= bthci_BuildPhysicalLink(padapter
,
2920 pHciCmd
, HCI_CREATE_PHYSICAL_LINK
);
2925 static enum hci_status
2926 bthci_CmdReadLinkQuality(
2927 struct rtw_adapter
*padapter
,
2928 struct packet_irp_hcicmd_data
*pHciCmd
2931 enum hci_status status
= HCI_STATUS_SUCCESS
;
2932 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2934 u8 EntryNum
, LinkQuality
= 0x55;
2936 PLH
= *((u16
*)&pHciCmd
->Data
[0]);
2937 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("PLH = 0x%x\n", PLH
));
2939 EntryNum
= bthci_GetCurrentEntryNum(padapter
, (u8
)PLH
);
2940 if (EntryNum
== 0xff) {
2941 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("No such PLH(0x%x)\n", PLH
));
2942 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
2946 u8 localBuf
[11] = "";
2949 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
2951 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
2953 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
2954 OGF_STATUS_PARAMETERS
,
2955 HCI_READ_LINK_QUALITY
,
2958 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, (" PLH = 0x%x\n Link Quality = 0x%x\n", PLH
, LinkQuality
));
2960 /* Return parameters starts from here */
2961 pRetPar
= &PPacketIrpEvent
->Data
[len
];
2962 pRetPar
[0] = status
; /* status */
2963 *((u16
*)&pRetPar
[1]) = pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkCmdData
.BtPhyLinkhandle
; /* Handle */
2964 pRetPar
[3] = 0x55; /* Link Quailty */
2966 PPacketIrpEvent
->Length
= len
;
2968 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
2974 static enum hci_status
2975 bthci_CmdCreateLogicalLink(
2976 struct rtw_adapter
*padapter
,
2977 struct packet_irp_hcicmd_data
*pHciCmd
2980 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2981 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
2983 pBtDbg
->dbgHciInfo
.hciCmdCntCreateLogLink
++;
2985 bthci_BuildLogicalLink(padapter
, pHciCmd
,
2986 HCI_CREATE_LOGICAL_LINK
);
2988 return HCI_STATUS_SUCCESS
;
2991 static enum hci_status
2992 bthci_CmdAcceptLogicalLink(
2993 struct rtw_adapter
*padapter
,
2994 struct packet_irp_hcicmd_data
*pHciCmd
2997 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
2998 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3000 pBtDbg
->dbgHciInfo
.hciCmdCntAcceptLogLink
++;
3002 bthci_BuildLogicalLink(padapter
, pHciCmd
,
3003 HCI_ACCEPT_LOGICAL_LINK
);
3005 return HCI_STATUS_SUCCESS
;
3008 static enum hci_status
3009 bthci_CmdDisconnectLogicalLink(
3010 struct rtw_adapter
*padapter
,
3011 struct packet_irp_hcicmd_data
*pHciCmd
3014 enum hci_status status
= HCI_STATUS_SUCCESS
;
3015 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
3016 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
3017 struct bt_mgnt
*pBtMgnt
= &pBTinfo
->BtMgnt
;
3018 struct bt_dgb
*pBtDbg
= &pBTinfo
->BtDbg
;
3020 u8 i
, j
, find
= 0, LogLinkCount
= 0;
3022 pBtDbg
->dbgHciInfo
.hciCmdCntDisconnectLogLink
++;
3024 logicHandle
= *((u16
*)pHciCmd
->Data
);
3025 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DisconnectLogicalLink, logicHandle = 0x%x\n", logicHandle
));
3027 /* find an created logical link index and clear the data */
3028 for (j
= 0; j
< MAX_BT_ASOC_ENTRY_NUM
; j
++) {
3029 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
3030 if (pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
== logicHandle
) {
3031 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("DisconnectLogicalLink, logicHandle is matched 0x%x\n", logicHandle
));
3032 bthci_ResetFlowSpec(padapter
, j
, i
);
3034 pBtMgnt
->DisconnectEntryNum
= j
;
3041 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
3044 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
3045 if (pBTinfo
->BtAsocEntry
[pBtMgnt
->DisconnectEntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
!= 0)
3049 /* When we receive Create logical link command, we should send command status event first. */
3050 bthci_EventCommandStatus(padapter
,
3051 LINK_CONTROL_COMMANDS
,
3052 HCI_DISCONNECT_LOGICAL_LINK
,
3055 /* When we determines the logical link is established, we should send command complete event. */
3057 if (status
== HCI_STATUS_SUCCESS
) {
3058 bthci_EventDisconnectLogicalLinkComplete(padapter
, status
,
3059 logicHandle
, HCI_STATUS_CONNECT_TERMINATE_LOCAL_HOST
);
3062 if (LogLinkCount
== 0)
3063 mod_timer(&pBTinfo
->BTDisconnectPhyLinkTimer
,
3064 jiffies
+ msecs_to_jiffies(100));
3069 static enum hci_status
3070 bthci_CmdLogicalLinkCancel(struct rtw_adapter
*padapter
,
3071 struct packet_irp_hcicmd_data
*pHciCmd
)
3073 enum hci_status status
= HCI_STATUS_SUCCESS
;
3074 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
3075 struct bt_mgnt
*pBtMgnt
= &pBTinfo
->BtMgnt
;
3076 u8 CurrentEntryNum
, CurrentLogEntryNum
;
3078 u8 physicalLinkHandle
, TxFlowSpecID
, i
;
3079 u16 CurrentLogicalHandle
;
3081 physicalLinkHandle
= *((u8
*)pHciCmd
->Data
);
3082 TxFlowSpecID
= *(((u8
*)pHciCmd
->Data
)+1);
3084 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("LogicalLinkCancel, physicalLinkHandle = 0x%x, TxFlowSpecID = 0x%x\n",
3085 physicalLinkHandle
, TxFlowSpecID
));
3087 CurrentEntryNum
= pBtMgnt
->CurrentConnectEntryNum
;
3088 CurrentLogicalHandle
= pBtMgnt
->BtCurrentLogLinkhandle
;
3090 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("CurrentEntryNum = 0x%x, CurrentLogicalHandle = 0x%x\n",
3091 CurrentEntryNum
, CurrentLogicalHandle
));
3093 CurrentLogEntryNum
= 0xff;
3094 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
3095 if ((CurrentLogicalHandle
== pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[i
].BtLogLinkhandle
) &&
3096 (physicalLinkHandle
== pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[i
].BtPhyLinkhandle
)) {
3097 CurrentLogEntryNum
= i
;
3102 if (CurrentLogEntryNum
== 0xff) {
3103 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("LogicalLinkCancel, CurrentLogEntryNum == 0xff !!!!\n"));
3104 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
3107 if (pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[CurrentLogEntryNum
].bLLCompleteEventIsSet
) {
3108 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("LogicalLinkCancel, LLCompleteEventIsSet!!!!\n"));
3109 status
= HCI_STATUS_ACL_CONNECT_EXISTS
;
3114 u8 localBuf
[8] = "";
3117 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3119 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3121 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3122 LINK_CONTROL_COMMANDS
,
3123 HCI_LOGICAL_LINK_CANCEL
,
3126 /* Return parameters starts from here */
3127 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3128 pRetPar
[0] = status
; /* status */
3129 pRetPar
[1] = pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[CurrentLogEntryNum
].BtPhyLinkhandle
;
3130 pRetPar
[2] = pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[CurrentLogEntryNum
].BtTxFlowSpecID
;
3132 PPacketIrpEvent
->Length
= len
;
3134 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3137 pBTinfo
->BtAsocEntry
[CurrentEntryNum
].LogLinkCmdData
[CurrentLogEntryNum
].bLLCancelCMDIsSetandComplete
= true;
3142 static enum hci_status
3143 bthci_CmdFlowSpecModify(struct rtw_adapter
*padapter
,
3144 struct packet_irp_hcicmd_data
*pHciCmd
)
3146 enum hci_status status
= HCI_STATUS_SUCCESS
;
3147 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
3148 struct bt_30info
*pBTinfo
= GET_BT_INFO(padapter
);
3152 logicHandle
= *((u16
*)pHciCmd
->Data
);
3153 /* find an matched logical link index and copy the data */
3154 for (j
= 0; j
< MAX_BT_ASOC_ENTRY_NUM
; j
++) {
3155 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
3156 if (pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
== logicHandle
) {
3157 memcpy(&pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].Tx_Flow_Spec
,
3158 &pHciCmd
->Data
[2], sizeof(struct hci_flow_spec
));
3159 memcpy(&pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].Rx_Flow_Spec
,
3160 &pHciCmd
->Data
[18], sizeof(struct hci_flow_spec
));
3162 bthci_CheckLogLinkBehavior(padapter
, pBTinfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].Tx_Flow_Spec
);
3168 RTPRINT(FIOCTL
, IOCTL_BT_LOGO
, ("FlowSpecModify, LLH = 0x%x, \n", logicHandle
));
3170 /* When we receive Flow Spec Modify command, we should send command status event first. */
3171 bthci_EventCommandStatus(padapter
,
3172 LINK_CONTROL_COMMANDS
,
3173 HCI_FLOW_SPEC_MODIFY
,
3174 HCI_STATUS_SUCCESS
);
3177 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
3179 bthci_EventSendFlowSpecModifyComplete(padapter
, status
, logicHandle
);
3184 static enum hci_status
3185 bthci_CmdAcceptPhysicalLink(struct rtw_adapter
*padapter
,
3186 struct packet_irp_hcicmd_data
*pHciCmd
)
3188 enum hci_status status
;
3189 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3190 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3192 pBtDbg
->dbgHciInfo
.hciCmdCntAcceptPhyLink
++;
3194 status
= bthci_BuildPhysicalLink(padapter
,
3195 pHciCmd
, HCI_ACCEPT_PHYSICAL_LINK
);
3200 static enum hci_status
3201 bthci_CmdDisconnectPhysicalLink(struct rtw_adapter
*padapter
,
3202 struct packet_irp_hcicmd_data
*pHciCmd
)
3204 enum hci_status status
= HCI_STATUS_SUCCESS
;
3205 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3206 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3207 u8 PLH
, CurrentEntryNum
, PhysLinkDisconnectReason
;
3209 pBtDbg
->dbgHciInfo
.hciCmdCntDisconnectPhyLink
++;
3211 PLH
= *((u8
*)pHciCmd
->Data
);
3212 PhysLinkDisconnectReason
= *((u8
*)pHciCmd
->Data
+1);
3213 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_DISCONNECT_PHYSICAL_LINK PhyHandle = 0x%x, Reason = 0x%x\n",
3214 PLH
, PhysLinkDisconnectReason
));
3216 CurrentEntryNum
= bthci_GetCurrentEntryNum(padapter
, PLH
);
3218 if (CurrentEntryNum
== 0xff) {
3219 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
,
3220 ("DisconnectPhysicalLink, No such Handle in the Entry\n"));
3221 status
= HCI_STATUS_UNKNOW_CONNECT_ID
;
3223 pBTInfo
->BtAsocEntry
[CurrentEntryNum
].PhyLinkDisconnectReason
=
3224 (enum hci_status
)PhysLinkDisconnectReason
;
3226 /* Send HCI Command status event to AMP. */
3227 bthci_EventCommandStatus(padapter
, LINK_CONTROL_COMMANDS
,
3228 HCI_DISCONNECT_PHYSICAL_LINK
, status
);
3230 if (status
!= HCI_STATUS_SUCCESS
)
3233 /* The macros below require { and } in the if statement */
3234 if (pBTInfo
->BtAsocEntry
[CurrentEntryNum
].BtCurrentState
== HCI_STATE_DISCONNECTED
) {
3235 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTED
, STATE_CMD_DISCONNECT_PHY_LINK
, CurrentEntryNum
);
3237 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTING
, STATE_CMD_DISCONNECT_PHY_LINK
, CurrentEntryNum
);
3242 static enum hci_status
3243 bthci_CmdSetACLLinkDataFlowMode(struct rtw_adapter
*padapter
,
3244 struct packet_irp_hcicmd_data
*pHciCmd
)
3246 enum hci_status status
= HCI_STATUS_SUCCESS
;
3247 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3248 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3249 u8 localBuf
[8] = "";
3252 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3255 pBtMgnt
->ExtConfig
.CurrentConnectHandle
= *((u16
*)pHciCmd
->Data
);
3256 pBtMgnt
->ExtConfig
.CurrentIncomingTrafficMode
= *((u8
*)pHciCmd
->Data
)+2;
3257 pBtMgnt
->ExtConfig
.CurrentOutgoingTrafficMode
= *((u8
*)pHciCmd
->Data
)+3;
3258 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("Connection Handle = 0x%x, Incoming Traffic mode = 0x%x, Outgoing Traffic mode = 0x%x",
3259 pBtMgnt
->ExtConfig
.CurrentConnectHandle
,
3260 pBtMgnt
->ExtConfig
.CurrentIncomingTrafficMode
,
3261 pBtMgnt
->ExtConfig
.CurrentOutgoingTrafficMode
));
3264 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3266 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3268 HCI_SET_ACL_LINK_DATA_FLOW_MODE
,
3271 /* Return parameters starts from here */
3272 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3273 pRetPar
[0] = status
; /* status */
3275 pu2Temp
= (u16
*)&pRetPar
[1];
3276 *pu2Temp
= pBtMgnt
->ExtConfig
.CurrentConnectHandle
;
3278 PPacketIrpEvent
->Length
= len
;
3280 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3284 static enum hci_status
3285 bthci_CmdSetACLLinkStatus(struct rtw_adapter
*padapter
,
3286 struct packet_irp_hcicmd_data
*pHciCmd
)
3288 enum hci_status status
= HCI_STATUS_SUCCESS
;
3289 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3290 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3291 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3295 pBtDbg
->dbgHciInfo
.hciCmdCntSetAclLinkStatus
++;
3296 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_EXT
, "SetACLLinkStatus, Hex Data :\n",
3297 &pHciCmd
->Data
[0], pHciCmd
->Length
);
3299 /* Only Core Stack v251 and later version support this command. */
3300 pBtMgnt
->bSupportProfile
= true;
3302 pBtMgnt
->ExtConfig
.NumberOfHandle
= *((u8
*)pHciCmd
->Data
);
3303 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("NumberOfHandle = 0x%x\n", pBtMgnt
->ExtConfig
.NumberOfHandle
));
3305 pTriple
= &pHciCmd
->Data
[1];
3306 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
3307 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
= *((u16
*)&pTriple
[0]);
3308 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
= pTriple
[2];
3309 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
= pTriple
[3];
3310 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
,
3311 ("Connection_Handle = 0x%x, Incoming Traffic mode = 0x%x, Outgoing Traffic Mode = 0x%x\n",
3312 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
,
3313 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
,
3314 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
));
3319 u8 localBuf
[6] = "";
3322 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3324 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3326 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3328 HCI_SET_ACL_LINK_STATUS
,
3331 /* Return parameters starts from here */
3332 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3333 pRetPar
[0] = status
; /* status */
3336 PPacketIrpEvent
->Length
= len
;
3338 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3344 static enum hci_status
3345 bthci_CmdSetSCOLinkStatus(
3346 struct rtw_adapter
*padapter
,
3347 struct packet_irp_hcicmd_data
*pHciCmd
3350 enum hci_status status
= HCI_STATUS_SUCCESS
;
3351 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3352 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3353 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3355 pBtDbg
->dbgHciInfo
.hciCmdCntSetScoLinkStatus
++;
3356 pBtMgnt
->ExtConfig
.NumberOfSCO
= *((u8
*)pHciCmd
->Data
);
3357 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("NumberOfSCO = 0x%x\n",
3358 pBtMgnt
->ExtConfig
.NumberOfSCO
));
3361 u8 localBuf
[6] = "";
3364 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3366 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3368 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3370 HCI_SET_SCO_LINK_STATUS
,
3373 /* Return parameters starts from here */
3374 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3375 pRetPar
[0] = status
; /* status */
3378 PPacketIrpEvent
->Length
= len
;
3380 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3386 static enum hci_status
3387 bthci_CmdSetRSSIValue(
3388 struct rtw_adapter
*padapter
,
3389 struct packet_irp_hcicmd_data
*pHciCmd
3392 enum hci_status status
= HCI_STATUS_SUCCESS
;
3393 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3394 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3397 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
3398 if (pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
== *((u16
*)&pHciCmd
->Data
[0])) {
3399 pBtMgnt
->ExtConfig
.linkInfo
[i
].BT_RSSI
= (s8
)(pHciCmd
->Data
[2]);
3400 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_PERIODICAL
,
3401 ("Connection_Handle = 0x%x, RSSI = %d \n",
3402 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
,
3403 pBtMgnt
->ExtConfig
.linkInfo
[i
].BT_RSSI
));
3405 /* get the minimum bt rssi value */
3406 if (pBtMgnt
->ExtConfig
.linkInfo
[i
].BT_RSSI
<= min_bt_rssi
)
3407 min_bt_rssi
= pBtMgnt
->ExtConfig
.linkInfo
[i
].BT_RSSI
;
3410 pBtMgnt
->ExtConfig
.MIN_BT_RSSI
= min_bt_rssi
;
3411 RTPRINT(FBT
, BT_TRACE
, ("[bt rssi], the min rssi is %d\n", min_bt_rssi
));
3414 u8 localBuf
[6] = "";
3417 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3419 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3421 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3426 /* Return parameters starts from here */
3427 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3428 pRetPar
[0] = status
; /* status */
3431 PPacketIrpEvent
->Length
= len
;
3433 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3439 static enum hci_status
3440 bthci_CmdSetCurrentBluetoothStatus(
3441 struct rtw_adapter
*padapter
,
3442 struct packet_irp_hcicmd_data
*pHciCmd
3445 enum hci_status status
= HCI_STATUS_SUCCESS
;
3446 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
3447 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3448 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3450 pBtMgnt
->ExtConfig
.CurrentBTStatus
= *((u8
*)&pHciCmd
->Data
[0]);
3451 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("SetCurrentBluetoothStatus, CurrentBTStatus = 0x%x\n",
3452 pBtMgnt
->ExtConfig
.CurrentBTStatus
));
3455 u8 localBuf
[6] = "";
3458 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3460 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3462 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3464 HCI_SET_CURRENT_BLUETOOTH_STATUS
,
3467 /* Return parameters starts from here */
3468 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3469 pRetPar
[0] = status
; /* status */
3472 PPacketIrpEvent
->Length
= len
;
3474 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3480 static enum hci_status
3481 bthci_CmdExtensionVersionNotify(
3482 struct rtw_adapter
*padapter
,
3483 struct packet_irp_hcicmd_data
*pHciCmd
3486 enum hci_status status
= HCI_STATUS_SUCCESS
;
3487 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3488 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3489 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3491 pBtDbg
->dbgHciInfo
.hciCmdCntExtensionVersionNotify
++;
3492 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_EXT
, "ExtensionVersionNotify, Hex Data :\n",
3493 &pHciCmd
->Data
[0], pHciCmd
->Length
);
3495 pBtMgnt
->ExtConfig
.HCIExtensionVer
= *((u16
*)&pHciCmd
->Data
[0]);
3496 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCIExtensionVer = 0x%x\n", pBtMgnt
->ExtConfig
.HCIExtensionVer
));
3499 u8 localBuf
[6] = "";
3502 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3504 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3506 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3508 HCI_EXTENSION_VERSION_NOTIFY
,
3511 /* Return parameters starts from here */
3512 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3513 pRetPar
[0] = status
; /* status */
3516 PPacketIrpEvent
->Length
= len
;
3518 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3524 static enum hci_status
3525 bthci_CmdLinkStatusNotify(
3526 struct rtw_adapter
*padapter
,
3527 struct packet_irp_hcicmd_data
*pHciCmd
3530 enum hci_status status
= HCI_STATUS_SUCCESS
;
3531 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3532 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3533 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
3537 pBtDbg
->dbgHciInfo
.hciCmdCntLinkStatusNotify
++;
3538 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_EXT
, "LinkStatusNotify, Hex Data :\n",
3539 &pHciCmd
->Data
[0], pHciCmd
->Length
);
3541 /* Current only RTL8723 support this command. */
3542 pBtMgnt
->bSupportProfile
= true;
3544 pBtMgnt
->ExtConfig
.NumberOfHandle
= *((u8
*)pHciCmd
->Data
);
3545 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("NumberOfHandle = 0x%x\n", pBtMgnt
->ExtConfig
.NumberOfHandle
));
3546 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCIExtensionVer = %d\n", pBtMgnt
->ExtConfig
.HCIExtensionVer
));
3548 pTriple
= &pHciCmd
->Data
[1];
3549 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
3550 if (pBtMgnt
->ExtConfig
.HCIExtensionVer
< 1) {
3551 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
= *((u16
*)&pTriple
[0]);
3552 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
= pTriple
[2];
3553 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
= pTriple
[3];
3554 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
,
3555 ("Connection_Handle = 0x%x, BTProfile =%d, BTSpec =%d\n",
3556 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
,
3557 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
,
3558 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
));
3560 } else if (pBtMgnt
->ExtConfig
.HCIExtensionVer
>= 1) {
3561 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
= *((u16
*)&pTriple
[0]);
3562 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
= pTriple
[2];
3563 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
= pTriple
[3];
3564 pBtMgnt
->ExtConfig
.linkInfo
[i
].linkRole
= pTriple
[4];
3565 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
,
3566 ("Connection_Handle = 0x%x, BTProfile =%d, BTSpec =%d, LinkRole =%d\n",
3567 pBtMgnt
->ExtConfig
.linkInfo
[i
].ConnectHandle
,
3568 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
,
3569 pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
,
3570 pBtMgnt
->ExtConfig
.linkInfo
[i
].linkRole
));
3575 BTHCI_UpdateBTProfileRTKToMoto(padapter
);
3577 u8 localBuf
[6] = "";
3580 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3582 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3584 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3586 HCI_LINK_STATUS_NOTIFY
,
3589 /* Return parameters starts from here */
3590 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3591 pRetPar
[0] = status
; /* status */
3594 PPacketIrpEvent
->Length
= len
;
3596 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3602 static enum hci_status
3603 bthci_CmdBtOperationNotify(
3604 struct rtw_adapter
*padapter
,
3605 struct packet_irp_hcicmd_data
*pHciCmd
3608 enum hci_status status
= HCI_STATUS_SUCCESS
;
3609 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3610 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3612 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_EXT
, "Bt Operation notify, Hex Data :\n",
3613 &pHciCmd
->Data
[0], pHciCmd
->Length
);
3615 pBtMgnt
->ExtConfig
.btOperationCode
= *((u8
*)pHciCmd
->Data
);
3616 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("btOperationCode = 0x%x\n", pBtMgnt
->ExtConfig
.btOperationCode
));
3617 switch (pBtMgnt
->ExtConfig
.btOperationCode
) {
3618 case HCI_BT_OP_NONE
:
3619 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Operation None!!\n"));
3621 case HCI_BT_OP_INQUIRY_START
:
3622 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Inquire start!!\n"));
3624 case HCI_BT_OP_INQUIRY_FINISH
:
3625 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Inquire finished!!\n"));
3627 case HCI_BT_OP_PAGING_START
:
3628 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Paging is started!!\n"));
3630 case HCI_BT_OP_PAGING_SUCCESS
:
3631 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Paging complete successfully!!\n"));
3633 case HCI_BT_OP_PAGING_UNSUCCESS
:
3634 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Paging complete unsuccessfully!!\n"));
3636 case HCI_BT_OP_PAIRING_START
:
3637 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Pairing start!!\n"));
3639 case HCI_BT_OP_PAIRING_FINISH
:
3640 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Pairing finished!!\n"));
3642 case HCI_BT_OP_BT_DEV_ENABLE
:
3643 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : BT Device is enabled!!\n"));
3645 case HCI_BT_OP_BT_DEV_DISABLE
:
3646 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : BT Device is disabled!!\n"));
3649 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[bt operation] : Unknown, error!!\n"));
3652 BTDM_AdjustForBtOperation(padapter
);
3654 u8 localBuf
[6] = "";
3657 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3659 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3661 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3663 HCI_BT_OPERATION_NOTIFY
,
3666 /* Return parameters starts from here */
3667 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3668 pRetPar
[0] = status
; /* status */
3671 PPacketIrpEvent
->Length
= len
;
3673 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3679 static enum hci_status
3680 bthci_CmdEnableWifiScanNotify(struct rtw_adapter
*padapter
,
3681 struct packet_irp_hcicmd_data
*pHciCmd
)
3683 enum hci_status status
= HCI_STATUS_SUCCESS
;
3684 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3685 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
3687 RTPRINT_DATA(FIOCTL
, IOCTL_BT_HCICMD_EXT
, "Enable Wifi scan notify, Hex Data :\n",
3688 &pHciCmd
->Data
[0], pHciCmd
->Length
);
3690 pBtMgnt
->ExtConfig
.bEnableWifiScanNotify
= *((u8
*)pHciCmd
->Data
);
3691 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("bEnableWifiScanNotify = %d\n", pBtMgnt
->ExtConfig
.bEnableWifiScanNotify
));
3694 u8 localBuf
[6] = "";
3697 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3699 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3701 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3703 HCI_ENABLE_WIFI_SCAN_NOTIFY
,
3706 /* Return parameters starts from here */
3707 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3708 pRetPar
[0] = status
; /* status */
3711 PPacketIrpEvent
->Length
= len
;
3713 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3719 static enum hci_status
3720 bthci_CmdWIFICurrentChannel(struct rtw_adapter
*padapter
,
3721 struct packet_irp_hcicmd_data
*pHciCmd
)
3723 enum hci_status status
= HCI_STATUS_SUCCESS
;
3724 struct mlme_ext_priv
*pmlmeext
= &padapter
->mlmeextpriv
;
3725 u8 chnl
= pmlmeext
->cur_channel
;
3727 if (pmlmeext
->cur_bwmode
== HT_CHANNEL_WIDTH_40
) {
3728 if (pmlmeext
->cur_ch_offset
== HAL_PRIME_CHNL_OFFSET_UPPER
)
3730 else if (pmlmeext
->cur_ch_offset
== HAL_PRIME_CHNL_OFFSET_LOWER
)
3734 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("Current Channel = 0x%x\n", chnl
));
3737 u8 localBuf
[8] = "";
3740 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3742 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3744 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3746 HCI_WIFI_CURRENT_CHANNEL
,
3749 /* Return parameters starts from here */
3750 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3751 pRetPar
[0] = status
; /* status */
3752 pRetPar
[1] = chnl
; /* current channel */
3754 PPacketIrpEvent
->Length
= len
;
3756 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3762 static enum hci_status
3763 bthci_CmdWIFICurrentBandwidth(struct rtw_adapter
*padapter
,
3764 struct packet_irp_hcicmd_data
*pHciCmd
)
3766 enum hci_status status
= HCI_STATUS_SUCCESS
;
3767 enum ht_channel_width bw
;
3770 bw
= padapter
->mlmeextpriv
.cur_bwmode
;
3772 if (bw
== HT_CHANNEL_WIDTH_20
)
3774 else if (bw
== HT_CHANNEL_WIDTH_40
)
3777 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("Current BW = 0x%x\n",
3781 u8 localBuf
[8] = "";
3784 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3786 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3788 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3790 HCI_WIFI_CURRENT_BANDWIDTH
,
3793 /* Return parameters starts from here */
3794 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3795 pRetPar
[0] = status
; /* status */
3796 pRetPar
[1] = CurrentBW
; /* current BW */
3798 PPacketIrpEvent
->Length
= len
;
3800 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3806 static enum hci_status
3807 bthci_CmdWIFIConnectionStatus(
3808 struct rtw_adapter
*padapter
,
3809 struct packet_irp_hcicmd_data
*pHciCmd
3812 enum hci_status status
= HCI_STATUS_SUCCESS
;
3813 u8 connectStatus
= HCI_WIFI_NOT_CONNECTED
;
3815 if (check_fwstate(&padapter
->mlmepriv
, WIFI_AP_STATE
)) {
3816 if (padapter
->stapriv
.asoc_sta_count
>= 3)
3817 connectStatus
= HCI_WIFI_CONNECTED
;
3819 connectStatus
= HCI_WIFI_NOT_CONNECTED
;
3820 } else if (check_fwstate(&padapter
->mlmepriv
, WIFI_ADHOC_STATE
|WIFI_ADHOC_MASTER_STATE
|WIFI_ASOC_STATE
)) {
3821 connectStatus
= HCI_WIFI_CONNECTED
;
3822 } else if (check_fwstate(&padapter
->mlmepriv
, WIFI_UNDER_LINKING
)) {
3823 connectStatus
= HCI_WIFI_CONNECT_IN_PROGRESS
;
3825 connectStatus
= HCI_WIFI_NOT_CONNECTED
;
3829 u8 localBuf
[8] = "";
3832 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3834 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3836 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3838 HCI_WIFI_CONNECTION_STATUS
,
3841 /* Return parameters starts from here */
3842 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3843 pRetPar
[0] = status
; /* status */
3844 pRetPar
[1] = connectStatus
; /* connect status */
3846 PPacketIrpEvent
->Length
= len
;
3848 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3854 static enum hci_status
3855 bthci_CmdEnableDeviceUnderTestMode(
3856 struct rtw_adapter
*padapter
,
3857 struct packet_irp_hcicmd_data
*pHciCmd
3860 enum hci_status status
= HCI_STATUS_SUCCESS
;
3861 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3862 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
3864 pBtHciInfo
->bInTestMode
= true;
3865 pBtHciInfo
->bTestIsEnd
= false;
3867 /* send command complete event here when all data are received. */
3869 u8 localBuf
[6] = "";
3872 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3874 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3876 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
3877 OGF_TESTING_COMMANDS
,
3878 HCI_ENABLE_DEVICE_UNDER_TEST_MODE
,
3881 /* Return parameters starts from here */
3882 pRetPar
= &PPacketIrpEvent
->Data
[len
];
3883 pRetPar
[0] = status
; /* status */
3885 PPacketIrpEvent
->Length
= len
;
3887 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
3893 static enum hci_status
3894 bthci_CmdAMPTestEnd(struct rtw_adapter
*padapter
,
3895 struct packet_irp_hcicmd_data
*pHciCmd
)
3897 enum hci_status status
= HCI_STATUS_SUCCESS
;
3898 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3899 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
3901 if (!pBtHciInfo
->bInTestMode
) {
3902 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Not in Test mode, return status = HCI_STATUS_CMD_DISALLOW\n"));
3903 status
= HCI_STATUS_CMD_DISALLOW
;
3907 pBtHciInfo
->bTestIsEnd
= true;
3909 del_timer_sync(&pBTInfo
->BTTestSendPacketTimer
);
3911 rtl8723a_check_bssid(padapter
, true);
3913 /* send command complete event here when all data are received. */
3915 u8 localBuf
[4] = "";
3916 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3918 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("AMP Test End Event \n"));
3919 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3920 PPacketIrpEvent
->EventCode
= HCI_EVENT_AMP_TEST_END
;
3921 PPacketIrpEvent
->Length
= 2;
3923 PPacketIrpEvent
->Data
[0] = status
;
3924 PPacketIrpEvent
->Data
[1] = pBtHciInfo
->TestScenario
;
3926 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
3929 bthci_EventAMPReceiverReport(padapter
, 0x01);
3934 static enum hci_status
3935 bthci_CmdAMPTestCommand(struct rtw_adapter
*padapter
,
3936 struct packet_irp_hcicmd_data
*pHciCmd
)
3938 enum hci_status status
= HCI_STATUS_SUCCESS
;
3939 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
3940 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
3942 if (!pBtHciInfo
->bInTestMode
) {
3943 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Not in Test mode, return status = HCI_STATUS_CMD_DISALLOW\n"));
3944 status
= HCI_STATUS_CMD_DISALLOW
;
3948 pBtHciInfo
->TestScenario
= *((u8
*)pHciCmd
->Data
);
3950 if (pBtHciInfo
->TestScenario
== 0x01)
3951 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("TX Single Test \n"));
3952 else if (pBtHciInfo
->TestScenario
== 0x02)
3953 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Receive Frame Test \n"));
3955 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("No Such Test !!!!!!!!!!!!!!!!!! \n"));
3957 if (pBtHciInfo
->bTestIsEnd
) {
3958 u8 localBuf
[5] = "";
3959 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3961 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("AMP Test End Event \n"));
3962 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3963 PPacketIrpEvent
->EventCode
= HCI_EVENT_AMP_TEST_END
;
3964 PPacketIrpEvent
->Length
= 2;
3966 PPacketIrpEvent
->Data
[0] = status
;
3967 PPacketIrpEvent
->Data
[1] = pBtHciInfo
->TestScenario
;
3969 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
3971 /* Return to Idel state with RX and TX off. */
3976 /* should send command status event */
3977 bthci_EventCommandStatus(padapter
,
3978 OGF_TESTING_COMMANDS
,
3979 HCI_AMP_TEST_COMMAND
,
3982 /* The HCI_AMP_Start Test Event shall be generated when the */
3983 /* HCI_AMP_Test_Command has completed and the first data is ready to be sent */
3987 u8 localBuf
[5] = "";
3988 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
3990 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), (" HCI_AMP_Start Test Event \n"));
3991 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
3992 PPacketIrpEvent
->EventCode
= HCI_EVENT_AMP_START_TEST
;
3993 PPacketIrpEvent
->Length
= 2;
3995 PPacketIrpEvent
->Data
[0] = status
;
3996 PPacketIrpEvent
->Data
[1] = pBtHciInfo
->TestScenario
;
3998 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, 4);
4000 /* Return to Idel state with RX and TX off. */
4003 if (pBtHciInfo
->TestScenario
== 0x01) {
4005 When in a transmitter test scenario and the frames/bursts count have been
4006 transmitted the HCI_AMP_Test_End event shall be sent.
4008 mod_timer(&pBTInfo
->BTTestSendPacketTimer
,
4009 jiffies
+ msecs_to_jiffies(50));
4010 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("TX Single Test \n"));
4011 } else if (pBtHciInfo
->TestScenario
== 0x02) {
4012 rtl8723a_check_bssid(padapter
, false);
4013 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_BT_LOGO
), ("Receive Frame Test \n"));
4019 static enum hci_status
4020 bthci_CmdEnableAMPReceiverReports(struct rtw_adapter
*padapter
,
4021 struct packet_irp_hcicmd_data
*pHciCmd
)
4023 enum hci_status status
= HCI_STATUS_SUCCESS
;
4024 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4025 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
4027 if (!pBtHciInfo
->bInTestMode
) {
4028 status
= HCI_STATUS_CMD_DISALLOW
;
4029 /* send command complete event here when all data are received. */
4031 u8 localBuf
[6] = "";
4034 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
4036 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
4038 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
4039 OGF_TESTING_COMMANDS
,
4040 HCI_ENABLE_AMP_RECEIVER_REPORTS
,
4043 /* Return parameters starts from here */
4044 pRetPar
= &PPacketIrpEvent
->Data
[len
];
4045 pRetPar
[0] = status
; /* status */
4047 PPacketIrpEvent
->Length
= len
;
4049 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
4054 pBtHciInfo
->bTestNeedReport
= *((u8
*)pHciCmd
->Data
);
4055 pBtHciInfo
->TestReportInterval
= (*((u8
*)pHciCmd
->Data
+2));
4057 bthci_EventAMPReceiverReport(padapter
, 0x00);
4059 /* send command complete event here when all data are received. */
4061 u8 localBuf
[6] = "";
4064 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
4066 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
4068 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
4069 OGF_TESTING_COMMANDS
,
4070 HCI_ENABLE_AMP_RECEIVER_REPORTS
,
4073 /* Return parameters starts from here */
4074 pRetPar
= &PPacketIrpEvent
->Data
[len
];
4075 pRetPar
[0] = status
; /* status */
4077 PPacketIrpEvent
->Length
= len
;
4079 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
4085 static enum hci_status
4086 bthci_CmdHostBufferSize(struct rtw_adapter
*padapter
,
4087 struct packet_irp_hcicmd_data
*pHciCmd
)
4089 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4090 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4091 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
4092 enum hci_status status
= HCI_STATUS_SUCCESS
;
4093 u8 localBuf
[6] = "";
4097 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].ACLPacketsData
.ACLDataPacketLen
= *((u16
*)pHciCmd
->Data
);
4098 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].SyncDataPacketLen
= *((u8
*)(pHciCmd
->Data
+2));
4099 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].TotalNumACLDataPackets
= *((u16
*)(pHciCmd
->Data
+3));
4100 pBTInfo
->BtAsocEntry
[pBtMgnt
->CurrentConnectEntryNum
].TotalSyncNumDataPackets
= *((u16
*)(pHciCmd
->Data
+5));
4102 /* send command complete event here when all data are received. */
4103 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
4105 len
+= bthci_CommandCompleteHeader(&localBuf
[0],
4106 OGF_SET_EVENT_MASK_COMMAND
,
4107 HCI_HOST_BUFFER_SIZE
,
4110 /* Return parameters starts from here */
4111 pRetPar
= &PPacketIrpEvent
->Data
[len
];
4112 pRetPar
[0] = status
; /* status */
4114 PPacketIrpEvent
->Length
= len
;
4116 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
4121 static enum hci_status
4122 bthci_UnknownCMD(struct rtw_adapter
*padapter
, struct packet_irp_hcicmd_data
*pHciCmd
)
4124 enum hci_status status
= HCI_STATUS_UNKNOW_HCI_CMD
;
4125 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4126 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
4128 pBtDbg
->dbgHciInfo
.hciCmdCntUnknown
++;
4129 bthci_EventCommandStatus(padapter
,
4137 static enum hci_status
4138 bthci_HandleOGFInformationalParameters(struct rtw_adapter
*padapter
,
4139 struct packet_irp_hcicmd_data
*pHciCmd
)
4141 enum hci_status status
= HCI_STATUS_SUCCESS
;
4143 switch (pHciCmd
->OCF
) {
4144 case HCI_READ_LOCAL_VERSION_INFORMATION
:
4145 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCAL_VERSION_INFORMATION\n"));
4146 status
= bthci_CmdReadLocalVersionInformation(padapter
);
4148 case HCI_READ_LOCAL_SUPPORTED_COMMANDS
:
4149 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCAL_SUPPORTED_COMMANDS\n"));
4150 status
= bthci_CmdReadLocalSupportedCommands(padapter
);
4152 case HCI_READ_LOCAL_SUPPORTED_FEATURES
:
4153 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCAL_SUPPORTED_FEATURES\n"));
4154 status
= bthci_CmdReadLocalSupportedFeatures(padapter
);
4156 case HCI_READ_BUFFER_SIZE
:
4157 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_BUFFER_SIZE\n"));
4158 status
= bthci_CmdReadBufferSize(padapter
);
4160 case HCI_READ_DATA_BLOCK_SIZE
:
4161 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_DATA_BLOCK_SIZE\n"));
4162 status
= bthci_CmdReadDataBlockSize(padapter
);
4165 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("bthci_HandleOGFInformationalParameters(), Unknown case = 0x%x\n", pHciCmd
->OCF
));
4166 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
4167 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4173 static enum hci_status
4174 bthci_HandleOGFSetEventMaskCMD(struct rtw_adapter
*padapter
,
4175 struct packet_irp_hcicmd_data
*pHciCmd
)
4177 enum hci_status status
= HCI_STATUS_SUCCESS
;
4179 switch (pHciCmd
->OCF
) {
4180 case HCI_SET_EVENT_MASK
:
4181 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_SET_EVENT_MASK\n"));
4182 status
= bthci_CmdSetEventMask(padapter
, pHciCmd
);
4185 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_RESET\n"));
4186 status
= bthci_CmdReset(padapter
, true);
4188 case HCI_READ_CONNECTION_ACCEPT_TIMEOUT
:
4189 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_CONNECTION_ACCEPT_TIMEOUT\n"));
4190 status
= bthci_CmdReadConnectionAcceptTimeout(padapter
);
4192 case HCI_SET_EVENT_FILTER
:
4193 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_SET_EVENT_FILTER\n"));
4195 case HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT
:
4196 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_CONNECTION_ACCEPT_TIMEOUT\n"));
4197 status
= bthci_CmdWriteConnectionAcceptTimeout(padapter
, pHciCmd
);
4199 case HCI_READ_PAGE_TIMEOUT
:
4200 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_PAGE_TIMEOUT\n"));
4201 status
= bthci_CmdReadPageTimeout(padapter
, pHciCmd
);
4203 case HCI_WRITE_PAGE_TIMEOUT
:
4204 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_PAGE_TIMEOUT\n"));
4205 status
= bthci_CmdWritePageTimeout(padapter
, pHciCmd
);
4207 case HCI_HOST_NUMBER_OF_COMPLETED_PACKETS
:
4208 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_HOST_NUMBER_OF_COMPLETED_PACKETS\n"));
4210 case HCI_READ_LINK_SUPERVISION_TIMEOUT
:
4211 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LINK_SUPERVISION_TIMEOUT\n"));
4212 status
= bthci_CmdReadLinkSupervisionTimeout(padapter
, pHciCmd
);
4214 case HCI_WRITE_LINK_SUPERVISION_TIMEOUT
:
4215 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_LINK_SUPERVISION_TIMEOUT\n"));
4216 status
= bthci_CmdWriteLinkSupervisionTimeout(padapter
, pHciCmd
);
4218 case HCI_ENHANCED_FLUSH
:
4219 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_ENHANCED_FLUSH\n"));
4220 status
= bthci_CmdEnhancedFlush(padapter
, pHciCmd
);
4222 case HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT
:
4223 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT\n"));
4224 status
= bthci_CmdReadLogicalLinkAcceptTimeout(padapter
, pHciCmd
);
4226 case HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT
:
4227 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT\n"));
4228 status
= bthci_CmdWriteLogicalLinkAcceptTimeout(padapter
, pHciCmd
);
4230 case HCI_SET_EVENT_MASK_PAGE_2
:
4231 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_SET_EVENT_MASK_PAGE_2\n"));
4232 status
= bthci_CmdSetEventMaskPage2(padapter
, pHciCmd
);
4234 case HCI_READ_LOCATION_DATA
:
4235 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCATION_DATA\n"));
4236 status
= bthci_CmdReadLocationData(padapter
, pHciCmd
);
4238 case HCI_WRITE_LOCATION_DATA
:
4239 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_LOCATION_DATA\n"));
4240 status
= bthci_CmdWriteLocationData(padapter
, pHciCmd
);
4242 case HCI_READ_FLOW_CONTROL_MODE
:
4243 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_FLOW_CONTROL_MODE\n"));
4244 status
= bthci_CmdReadFlowControlMode(padapter
, pHciCmd
);
4246 case HCI_WRITE_FLOW_CONTROL_MODE
:
4247 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_FLOW_CONTROL_MODE\n"));
4248 status
= bthci_CmdWriteFlowControlMode(padapter
, pHciCmd
);
4250 case HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT
:
4251 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_BEST_EFFORT_FLUSH_TIMEOUT\n"));
4252 status
= bthci_CmdReadBestEffortFlushTimeout(padapter
, pHciCmd
);
4254 case HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT
:
4255 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_BEST_EFFORT_FLUSH_TIMEOUT\n"));
4256 status
= bthci_CmdWriteBestEffortFlushTimeout(padapter
, pHciCmd
);
4258 case HCI_SHORT_RANGE_MODE
:
4259 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_SHORT_RANGE_MODE\n"));
4260 status
= bthci_CmdShortRangeMode(padapter
, pHciCmd
);
4262 case HCI_HOST_BUFFER_SIZE
:
4263 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_HOST_BUFFER_SIZE\n"));
4264 status
= bthci_CmdHostBufferSize(padapter
, pHciCmd
);
4267 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("bthci_HandleOGFSetEventMaskCMD(), Unknown case = 0x%x\n", pHciCmd
->OCF
));
4268 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
4269 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4275 static enum hci_status
4276 bthci_HandleOGFStatusParameters(struct rtw_adapter
*padapter
,
4277 struct packet_irp_hcicmd_data
*pHciCmd
)
4279 enum hci_status status
= HCI_STATUS_SUCCESS
;
4281 switch (pHciCmd
->OCF
) {
4282 case HCI_READ_FAILED_CONTACT_COUNTER
:
4283 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_FAILED_CONTACT_COUNTER\n"));
4284 status
= bthci_CmdReadFailedContactCounter(padapter
, pHciCmd
);
4286 case HCI_RESET_FAILED_CONTACT_COUNTER
:
4287 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_RESET_FAILED_CONTACT_COUNTER\n"));
4288 status
= bthci_CmdResetFailedContactCounter(padapter
, pHciCmd
);
4290 case HCI_READ_LINK_QUALITY
:
4291 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LINK_QUALITY\n"));
4292 status
= bthci_CmdReadLinkQuality(padapter
, pHciCmd
);
4295 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_RSSI\n"));
4297 case HCI_READ_LOCAL_AMP_INFO
:
4298 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCAL_AMP_INFO\n"));
4299 status
= bthci_CmdReadLocalAMPInfo(padapter
);
4301 case HCI_READ_LOCAL_AMP_ASSOC
:
4302 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_READ_LOCAL_AMP_ASSOC\n"));
4303 status
= bthci_CmdReadLocalAMPAssoc(padapter
, pHciCmd
);
4305 case HCI_WRITE_REMOTE_AMP_ASSOC
:
4306 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_WRITE_REMOTE_AMP_ASSOC\n"));
4307 status
= bthci_CmdWriteRemoteAMPAssoc(padapter
, pHciCmd
);
4310 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("bthci_HandleOGFStatusParameters(), Unknown case = 0x%x\n", pHciCmd
->OCF
));
4311 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
4312 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4318 static enum hci_status
4319 bthci_HandleOGFLinkControlCMD(struct rtw_adapter
*padapter
,
4320 struct packet_irp_hcicmd_data
*pHciCmd
)
4322 enum hci_status status
= HCI_STATUS_SUCCESS
;
4324 switch (pHciCmd
->OCF
) {
4325 case HCI_CREATE_PHYSICAL_LINK
:
4326 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_CREATE_PHYSICAL_LINK\n"));
4327 status
= bthci_CmdCreatePhysicalLink(padapter
, pHciCmd
);
4329 case HCI_ACCEPT_PHYSICAL_LINK
:
4330 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_ACCEPT_PHYSICAL_LINK\n"));
4331 status
= bthci_CmdAcceptPhysicalLink(padapter
, pHciCmd
);
4333 case HCI_DISCONNECT_PHYSICAL_LINK
:
4334 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_DISCONNECT_PHYSICAL_LINK\n"));
4335 status
= bthci_CmdDisconnectPhysicalLink(padapter
, pHciCmd
);
4337 case HCI_CREATE_LOGICAL_LINK
:
4338 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_CREATE_LOGICAL_LINK\n"));
4339 status
= bthci_CmdCreateLogicalLink(padapter
, pHciCmd
);
4341 case HCI_ACCEPT_LOGICAL_LINK
:
4342 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_ACCEPT_LOGICAL_LINK\n"));
4343 status
= bthci_CmdAcceptLogicalLink(padapter
, pHciCmd
);
4345 case HCI_DISCONNECT_LOGICAL_LINK
:
4346 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_DISCONNECT_LOGICAL_LINK\n"));
4347 status
= bthci_CmdDisconnectLogicalLink(padapter
, pHciCmd
);
4349 case HCI_LOGICAL_LINK_CANCEL
:
4350 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_LOGICAL_LINK_CANCEL\n"));
4351 status
= bthci_CmdLogicalLinkCancel(padapter
, pHciCmd
);
4353 case HCI_FLOW_SPEC_MODIFY
:
4354 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_FLOW_SPEC_MODIFY\n"));
4355 status
= bthci_CmdFlowSpecModify(padapter
, pHciCmd
);
4358 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("bthci_HandleOGFLinkControlCMD(), Unknown case = 0x%x\n", pHciCmd
->OCF
));
4359 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
4360 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4366 static enum hci_status
4367 bthci_HandleOGFTestingCMD(struct rtw_adapter
*padapter
,
4368 struct packet_irp_hcicmd_data
*pHciCmd
)
4370 enum hci_status status
= HCI_STATUS_SUCCESS
;
4371 switch (pHciCmd
->OCF
) {
4372 case HCI_ENABLE_DEVICE_UNDER_TEST_MODE
:
4373 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_ENABLE_DEVICE_UNDER_TEST_MODE\n"));
4374 bthci_CmdEnableDeviceUnderTestMode(padapter
, pHciCmd
);
4376 case HCI_AMP_TEST_END
:
4377 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_AMP_TEST_END\n"));
4378 bthci_CmdAMPTestEnd(padapter
, pHciCmd
);
4380 case HCI_AMP_TEST_COMMAND
:
4381 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_AMP_TEST_COMMAND\n"));
4382 bthci_CmdAMPTestCommand(padapter
, pHciCmd
);
4384 case HCI_ENABLE_AMP_RECEIVER_REPORTS
:
4385 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_ENABLE_AMP_RECEIVER_REPORTS\n"));
4386 bthci_CmdEnableAMPReceiverReports(padapter
, pHciCmd
);
4389 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
4390 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4396 static enum hci_status
4397 bthci_HandleOGFExtension(struct rtw_adapter
*padapter
,
4398 struct packet_irp_hcicmd_data
*pHciCmd
)
4400 enum hci_status status
= HCI_STATUS_SUCCESS
;
4401 switch (pHciCmd
->OCF
) {
4402 case HCI_SET_ACL_LINK_DATA_FLOW_MODE
:
4403 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_SET_ACL_LINK_DATA_FLOW_MODE\n"));
4404 status
= bthci_CmdSetACLLinkDataFlowMode(padapter
, pHciCmd
);
4406 case HCI_SET_ACL_LINK_STATUS
:
4407 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_SET_ACL_LINK_STATUS\n"));
4408 status
= bthci_CmdSetACLLinkStatus(padapter
, pHciCmd
);
4410 case HCI_SET_SCO_LINK_STATUS
:
4411 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_SET_SCO_LINK_STATUS\n"));
4412 status
= bthci_CmdSetSCOLinkStatus(padapter
, pHciCmd
);
4414 case HCI_SET_RSSI_VALUE
:
4415 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_PERIODICAL
, ("HCI_SET_RSSI_VALUE\n"));
4416 status
= bthci_CmdSetRSSIValue(padapter
, pHciCmd
);
4418 case HCI_SET_CURRENT_BLUETOOTH_STATUS
:
4419 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_SET_CURRENT_BLUETOOTH_STATUS\n"));
4420 status
= bthci_CmdSetCurrentBluetoothStatus(padapter
, pHciCmd
);
4422 /* The following is for RTK8723 */
4424 case HCI_EXTENSION_VERSION_NOTIFY
:
4425 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_EXTENSION_VERSION_NOTIFY\n"));
4426 status
= bthci_CmdExtensionVersionNotify(padapter
, pHciCmd
);
4428 case HCI_LINK_STATUS_NOTIFY
:
4429 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_LINK_STATUS_NOTIFY\n"));
4430 status
= bthci_CmdLinkStatusNotify(padapter
, pHciCmd
);
4432 case HCI_BT_OPERATION_NOTIFY
:
4433 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_BT_OPERATION_NOTIFY\n"));
4434 status
= bthci_CmdBtOperationNotify(padapter
, pHciCmd
);
4436 case HCI_ENABLE_WIFI_SCAN_NOTIFY
:
4437 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_ENABLE_WIFI_SCAN_NOTIFY\n"));
4438 status
= bthci_CmdEnableWifiScanNotify(padapter
, pHciCmd
);
4441 /* The following is for IVT */
4442 case HCI_WIFI_CURRENT_CHANNEL
:
4443 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_WIFI_CURRENT_CHANNEL\n"));
4444 status
= bthci_CmdWIFICurrentChannel(padapter
, pHciCmd
);
4446 case HCI_WIFI_CURRENT_BANDWIDTH
:
4447 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_WIFI_CURRENT_BANDWIDTH\n"));
4448 status
= bthci_CmdWIFICurrentBandwidth(padapter
, pHciCmd
);
4450 case HCI_WIFI_CONNECTION_STATUS
:
4451 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_WIFI_CONNECTION_STATUS\n"));
4452 status
= bthci_CmdWIFIConnectionStatus(padapter
, pHciCmd
);
4456 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("HCI_UNKNOWN_COMMAND\n"));
4457 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
4464 bthci_StateStarting(struct rtw_adapter
*padapter
,
4465 enum hci_state_with_cmd StateCmd
, u8 EntryNum
)
4467 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4468 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4470 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Starting], "));
4472 case STATE_CMD_CONNECT_ACCEPT_TIMEOUT
:
4473 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_CONNECT_ACCEPT_TIMEOUT\n"));
4474 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_CONNECT_ACCEPT_TIMEOUT
;
4475 pBtMgnt
->bNeedNotifyAMPNoCap
= true;
4476 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4478 case STATE_CMD_DISCONNECT_PHY_LINK
:
4479 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4481 bthci_EventDisconnectPhyLinkComplete(padapter
,
4483 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4486 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4488 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_UNKNOW_CONNECT_ID
;
4490 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4492 case STATE_CMD_MAC_START_COMPLETE
:
4493 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_MAC_START_COMPLETE\n"));
4494 if (pBTInfo
->BtAsocEntry
[EntryNum
].AMPRole
== AMP_BTAP_CREATOR
)
4495 bthci_EventChannelSelected(padapter
, EntryNum
);
4498 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4504 bthci_StateConnecting(struct rtw_adapter
*padapter
,
4505 enum hci_state_with_cmd StateCmd
, u8 EntryNum
)
4507 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4508 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4510 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Connecting], "));
4512 case STATE_CMD_CONNECT_ACCEPT_TIMEOUT
:
4513 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_CONNECT_ACCEPT_TIMEOUT\n"));
4514 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_CONNECT_ACCEPT_TIMEOUT
;
4515 pBtMgnt
->bNeedNotifyAMPNoCap
= true;
4516 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4518 case STATE_CMD_MAC_CONNECT_COMPLETE
:
4519 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_MAC_CONNECT_COMPLETE\n"));
4521 if (pBTInfo
->BtAsocEntry
[EntryNum
].AMPRole
== AMP_BTAP_JOINER
) {
4522 RT_TRACE(_module_rtl871x_security_c_
, _drv_info_
,
4523 "StateConnecting\n");
4526 case STATE_CMD_DISCONNECT_PHY_LINK
:
4527 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4529 bthci_EventDisconnectPhyLinkComplete(padapter
,
4531 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4534 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_UNKNOW_CONNECT_ID
;
4536 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4538 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4541 case STATE_CMD_MAC_CONNECT_CANCEL_INDICATE
:
4542 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_MAC_CONNECT_CANCEL_INDICATE\n"));
4543 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_CONTROLLER_BUSY
;
4544 /* Because this state cmd is caused by the BTHCI_EventAMPStatusChange(), */
4545 /* we don't need to send event in the following BTHCI_DisconnectPeer() again. */
4546 pBtMgnt
->bNeedNotifyAMPNoCap
= false;
4547 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4550 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4556 bthci_StateConnected(struct rtw_adapter
*padapter
,
4557 enum hci_state_with_cmd StateCmd
, u8 EntryNum
)
4559 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
4560 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4561 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4563 u16 logicHandle
= 0;
4565 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Connected], "));
4567 case STATE_CMD_DISCONNECT_PHY_LINK
:
4568 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4570 /* When we are trying to disconnect the phy link, we should disconnect log link first, */
4571 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
4572 if (pBTInfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
->BtLogLinkhandle
!= 0) {
4573 logicHandle
= pBTInfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
->BtLogLinkhandle
;
4575 bthci_EventDisconnectLogicalLinkComplete(padapter
, HCI_STATUS_SUCCESS
,
4576 logicHandle
, pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
);
4578 pBTInfo
->BtAsocEntry
[EntryNum
].LogLinkCmdData
->BtLogLinkhandle
= 0;
4582 bthci_EventDisconnectPhyLinkComplete(padapter
,
4584 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4587 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4589 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4592 case STATE_CMD_MAC_DISCONNECT_INDICATE
:
4593 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_MAC_DISCONNECT_INDICATE\n"));
4595 bthci_EventDisconnectPhyLinkComplete(padapter
,
4597 /* TODO: Remote Host not local host */
4598 HCI_STATUS_CONNECT_TERMINATE_LOCAL_HOST
,
4600 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4603 case STATE_CMD_ENTER_STATE
:
4604 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_ENTER_STATE\n"));
4606 if (pBtMgnt
->bBTConnectInProgress
) {
4607 pBtMgnt
->bBTConnectInProgress
= false;
4608 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], BT Connect in progress OFF!!\n"));
4610 pBTInfo
->BtAsocEntry
[EntryNum
].BtCurrentState
= HCI_STATE_CONNECTED
;
4611 pBTInfo
->BtAsocEntry
[EntryNum
].b4waySuccess
= true;
4612 pBtMgnt
->bStartSendSupervisionPkt
= true;
4614 /* for rate adaptive */
4616 rtl8723a_update_ramask(padapter
,
4617 MAX_FW_SUPPORT_MACID_NUM
-1-EntryNum
, 0);
4619 HalSetBrateCfg23a(padapter
, padapter
->mlmepriv
.cur_network
.network
.SupportedRates
);
4620 BTDM_SetFwChnlInfo(padapter
, RT_MEDIA_CONNECT
);
4623 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4629 bthci_StateAuth(struct rtw_adapter
*padapter
, enum hci_state_with_cmd StateCmd
,
4632 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4633 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4635 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Authenticating], "));
4637 case STATE_CMD_CONNECT_ACCEPT_TIMEOUT
:
4638 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_CONNECT_ACCEPT_TIMEOUT\n"));
4639 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_CONNECT_ACCEPT_TIMEOUT
;
4640 pBtMgnt
->bNeedNotifyAMPNoCap
= true;
4641 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4643 case STATE_CMD_DISCONNECT_PHY_LINK
:
4644 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4645 bthci_EventDisconnectPhyLinkComplete(padapter
,
4647 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4650 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_UNKNOW_CONNECT_ID
;
4652 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4654 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4656 case STATE_CMD_4WAY_FAILED
:
4657 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_4WAY_FAILED\n"));
4659 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
= HCI_STATUS_AUTH_FAIL
;
4660 pBtMgnt
->bNeedNotifyAMPNoCap
= true;
4662 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4664 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4666 case STATE_CMD_4WAY_SUCCESSED
:
4667 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_4WAY_SUCCESSED\n"));
4669 bthci_EventPhysicalLinkComplete(padapter
, HCI_STATUS_SUCCESS
, EntryNum
, INVALID_PL_HANDLE
);
4671 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4673 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_CONNECTED
, STATE_CMD_ENTER_STATE
, EntryNum
);
4676 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4682 bthci_StateDisconnecting(struct rtw_adapter
*padapter
,
4683 enum hci_state_with_cmd StateCmd
, u8 EntryNum
)
4685 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4686 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4688 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Disconnecting], "));
4690 case STATE_CMD_MAC_CONNECT_CANCEL_INDICATE
:
4691 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_MAC_CONNECT_CANCEL_INDICATE\n"));
4692 if (pBTInfo
->BtAsocEntry
[EntryNum
].bNeedPhysLinkCompleteEvent
) {
4693 bthci_EventPhysicalLinkComplete(padapter
,
4694 pBTInfo
->BtAsocEntry
[EntryNum
].PhysLinkCompleteStatus
,
4695 EntryNum
, INVALID_PL_HANDLE
);
4698 if (pBtMgnt
->bBTConnectInProgress
) {
4699 pBtMgnt
->bBTConnectInProgress
= false;
4700 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], BT Connect in progress OFF!!\n"));
4703 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTED
, STATE_CMD_ENTER_STATE
, EntryNum
);
4705 case STATE_CMD_DISCONNECT_PHY_LINK
:
4706 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4708 bthci_EventDisconnectPhyLinkComplete(padapter
,
4710 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4713 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4715 BTHCI_DisconnectPeer(padapter
, EntryNum
);
4718 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4724 bthci_StateDisconnected(struct rtw_adapter
*padapter
,
4725 enum hci_state_with_cmd StateCmd
, u8 EntryNum
)
4727 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
4728 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4729 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
4730 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4732 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT state], [Disconnected], "));
4734 case STATE_CMD_CREATE_PHY_LINK
:
4735 case STATE_CMD_ACCEPT_PHY_LINK
:
4736 if (StateCmd
== STATE_CMD_CREATE_PHY_LINK
)
4737 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_CREATE_PHY_LINK\n"));
4739 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_ACCEPT_PHY_LINK\n"));
4741 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT PS], Disable IPS and LPS\n"));
4742 ips_leave23a(padapter
);
4743 LPS_Leave23a(padapter
);
4745 pBtMgnt
->bPhyLinkInProgress
= true;
4746 pBtMgnt
->BTCurrentConnectType
= BT_DISCONNECT
;
4747 pBtMgnt
->CurrentBTConnectionCnt
++;
4748 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], CurrentBTConnectionCnt = %d\n",
4749 pBtMgnt
->CurrentBTConnectionCnt
));
4750 pBtMgnt
->BtOperationOn
= true;
4751 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], Bt Operation ON!! CurrentConnectEntryNum = %d\n",
4752 pBtMgnt
->CurrentConnectEntryNum
));
4754 if (pBtMgnt
->bBTConnectInProgress
) {
4755 bthci_EventPhysicalLinkComplete(padapter
, HCI_STATUS_CONTROLLER_BUSY
, INVALID_ENTRY_NUM
, pBtMgnt
->BtCurrentPhyLinkhandle
);
4756 bthci_RemoveEntryByEntryNum(padapter
, EntryNum
);
4760 if (StateCmd
== STATE_CMD_CREATE_PHY_LINK
)
4761 pBTInfo
->BtAsocEntry
[EntryNum
].AMPRole
= AMP_BTAP_CREATOR
;
4763 pBTInfo
->BtAsocEntry
[EntryNum
].AMPRole
= AMP_BTAP_JOINER
;
4765 /* 1. MAC not yet in selected channel */
4766 while (check_fwstate(&padapter
->mlmepriv
, WIFI_ASOC_STATE
|WIFI_SITE_MONITOR
)) {
4767 RTPRINT(FIOCTL
, IOCTL_STATE
, ("Scan/Roaming/Wifi Link is in Progress, wait 200 ms\n"));
4770 /* 2. MAC already in selected channel */
4771 RTPRINT(FIOCTL
, IOCTL_STATE
, ("Channel is Ready\n"));
4772 mod_timer(&pBTInfo
->BTHCIJoinTimeoutTimer
,
4773 jiffies
+ msecs_to_jiffies(pBtHciInfo
->ConnAcceptTimeout
));
4775 pBTInfo
->BtAsocEntry
[EntryNum
].bNeedPhysLinkCompleteEvent
= true;
4777 case STATE_CMD_DISCONNECT_PHY_LINK
:
4778 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_DISCONNECT_PHY_LINK\n"));
4780 del_timer_sync(&pBTInfo
->BTHCIJoinTimeoutTimer
);
4782 bthci_EventDisconnectPhyLinkComplete(padapter
,
4784 pBTInfo
->BtAsocEntry
[EntryNum
].PhyLinkDisconnectReason
,
4787 if (pBTInfo
->BtAsocEntry
[EntryNum
].bNeedPhysLinkCompleteEvent
) {
4788 bthci_EventPhysicalLinkComplete(padapter
,
4789 HCI_STATUS_UNKNOW_CONNECT_ID
,
4790 EntryNum
, INVALID_PL_HANDLE
);
4793 if (pBtMgnt
->bBTConnectInProgress
) {
4794 pBtMgnt
->bBTConnectInProgress
= false;
4795 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], BT Connect in progress OFF!!\n"));
4797 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTED
, STATE_CMD_ENTER_STATE
, EntryNum
);
4798 bthci_RemoveEntryByEntryNum(padapter
, EntryNum
);
4800 case STATE_CMD_ENTER_STATE
:
4801 RTPRINT(FIOCTL
, IOCTL_STATE
, ("STATE_CMD_ENTER_STATE\n"));
4804 RTPRINT(FIOCTL
, IOCTL_STATE
, ("State command(%d) is Wrong !!!\n", StateCmd
));
4809 void BTHCI_EventParse(struct rtw_adapter
*padapter
, void *pEvntData
, u32 dataLen
)
4813 u8
BTHCI_HsConnectionEstablished(struct rtw_adapter
*padapter
)
4815 u8 bBtConnectionExist
= false;
4816 struct bt_30info
*pBtinfo
= GET_BT_INFO(padapter
);
4819 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
4820 if (pBtinfo
->BtAsocEntry
[i
].b4waySuccess
) {
4821 bBtConnectionExist
= true;
4826 /*RTPRINT(FIOCTL, IOCTL_STATE, (" BTHCI_HsConnectionEstablished(), connection exist = %d\n", bBtConnectionExist)); */
4828 return bBtConnectionExist
;
4832 BTHCI_CheckProfileExist(struct rtw_adapter
*padapter
,
4833 enum bt_traffic_mode_profile Profile
)
4835 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4836 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4837 u8 IsPRofile
= false;
4840 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
4841 if (pBtMgnt
->ExtConfig
.linkInfo
[i
].TrafficProfile
== Profile
) {
4850 void BTHCI_UpdateBTProfileRTKToMoto(struct rtw_adapter
*padapter
)
4852 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4853 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4856 pBtMgnt
->ExtConfig
.NumberOfSCO
= 0;
4858 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
4859 pBtMgnt
->ExtConfig
.linkInfo
[i
].TrafficProfile
= BT_PROFILE_NONE
;
4861 if (pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
== BT_PROFILE_SCO
)
4862 pBtMgnt
->ExtConfig
.NumberOfSCO
++;
4864 pBtMgnt
->ExtConfig
.linkInfo
[i
].TrafficProfile
= pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
;
4865 switch (pBtMgnt
->ExtConfig
.linkInfo
[i
].TrafficProfile
) {
4866 case BT_PROFILE_SCO
:
4868 case BT_PROFILE_PAN
:
4869 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
= BT_MOTOR_EXT_BE
;
4870 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
= BT_MOTOR_EXT_BE
;
4872 case BT_PROFILE_A2DP
:
4873 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
= BT_MOTOR_EXT_GULB
;
4874 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
= BT_MOTOR_EXT_GULB
;
4876 case BT_PROFILE_HID
:
4877 pBtMgnt
->ExtConfig
.linkInfo
[i
].IncomingTrafficMode
= BT_MOTOR_EXT_GUL
;
4878 pBtMgnt
->ExtConfig
.linkInfo
[i
].OutgoingTrafficMode
= BT_MOTOR_EXT_BE
;
4885 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RTK, NumberOfHandle = %d, NumberOfSCO = %d\n",
4886 pBtMgnt
->ExtConfig
.NumberOfHandle
, pBtMgnt
->ExtConfig
.NumberOfSCO
));
4889 void BTHCI_WifiScanNotify(struct rtw_adapter
*padapter
, u8 scanType
)
4891 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4892 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4894 if (pBtMgnt
->ExtConfig
.bEnableWifiScanNotify
)
4895 bthci_EventExtWifiScanNotify(padapter
, scanType
);
4900 struct rtw_adapter
*padapter
,
4902 enum hci_state_with_cmd StateCmd
,
4906 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4907 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4909 if (EntryNum
== 0xff) {
4910 RTPRINT(FIOCTL
, IOCTL_STATE
, (" StateMachine, error EntryNum = 0x%x \n", EntryNum
));
4913 RTPRINT(FIOCTL
, IOCTL_STATE
, (" StateMachine, EntryNum = 0x%x, CurrentState = 0x%x, BtNextState = 0x%x, StateCmd = 0x%x , StateToEnter = 0x%x\n",
4914 EntryNum
, pBTInfo
->BtAsocEntry
[EntryNum
].BtCurrentState
, pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
, StateCmd
, StateToEnter
));
4916 if (pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
& StateToEnter
) {
4917 pBTInfo
->BtAsocEntry
[EntryNum
].BtCurrentState
= StateToEnter
;
4919 switch (StateToEnter
) {
4920 case HCI_STATE_STARTING
:
4921 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_DISCONNECTING
| HCI_STATE_CONNECTING
;
4922 bthci_StateStarting(padapter
, StateCmd
, EntryNum
);
4924 case HCI_STATE_CONNECTING
:
4925 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_CONNECTING
| HCI_STATE_DISCONNECTING
| HCI_STATE_AUTHENTICATING
;
4926 bthci_StateConnecting(padapter
, StateCmd
, EntryNum
);
4928 case HCI_STATE_AUTHENTICATING
:
4929 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_DISCONNECTING
| HCI_STATE_CONNECTED
;
4930 bthci_StateAuth(padapter
, StateCmd
, EntryNum
);
4932 case HCI_STATE_CONNECTED
:
4933 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_CONNECTED
| HCI_STATE_DISCONNECTING
;
4934 bthci_StateConnected(padapter
, StateCmd
, EntryNum
);
4936 case HCI_STATE_DISCONNECTING
:
4937 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_DISCONNECTED
| HCI_STATE_DISCONNECTING
;
4938 bthci_StateDisconnecting(padapter
, StateCmd
, EntryNum
);
4940 case HCI_STATE_DISCONNECTED
:
4941 pBTInfo
->BtAsocEntry
[EntryNum
].BtNextState
= HCI_STATE_DISCONNECTED
| HCI_STATE_STARTING
| HCI_STATE_CONNECTING
;
4942 bthci_StateDisconnected(padapter
, StateCmd
, EntryNum
);
4945 RTPRINT(FIOCTL
, IOCTL_STATE
, (" StateMachine, Unknown state to enter!!!\n"));
4949 RTPRINT(FIOCTL
, IOCTL_STATE
, (" StateMachine, Wrong state to enter\n"));
4952 /* 20100325 Joseph: Disable/Enable IPS/LPS according to BT status. */
4953 if (!pBtMgnt
->bBTConnectInProgress
&& !pBtMgnt
->BtOperationOn
) {
4954 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT PS], ips_enter23a()\n"));
4955 ips_enter23a(padapter
);
4959 void BTHCI_DisconnectPeer(struct rtw_adapter
*padapter
, u8 EntryNum
)
4961 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4962 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
4964 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, (" BTHCI_DisconnectPeer()\n"));
4966 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTING
, STATE_CMD_MAC_CONNECT_CANCEL_INDICATE
, EntryNum
);
4968 if (pBTInfo
->BtAsocEntry
[EntryNum
].bUsed
) {
4969 /*BTPKT_SendDeauthentication(padapter, pBTInfo->BtAsocEntry[EntryNum].BTRemoteMACAddr, unspec_reason); not porting yet */
4972 if (pBtMgnt
->bBTConnectInProgress
) {
4973 pBtMgnt
->bBTConnectInProgress
= false;
4974 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT Flag], BT Connect in progress OFF!!\n"));
4977 bthci_RemoveEntryByEntryNum(padapter
, EntryNum
);
4979 if (pBtMgnt
->bNeedNotifyAMPNoCap
) {
4980 RTPRINT(FIOCTL
, IOCTL_STATE
, ("[BT AMPStatus], set to invalid in BTHCI_DisconnectPeer()\n"));
4981 BTHCI_EventAMPStatusChange(padapter
, AMP_STATUS_NO_CAPACITY_FOR_BT
);
4985 void BTHCI_EventNumOfCompletedDataBlocks(struct rtw_adapter
*padapter
)
4987 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
4988 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
4989 struct bt_hci_info
*pBtHciInfo
= &pBTInfo
->BtHciInfo
;
4990 u8 localBuf
[TmpLocalBufSize
] = "";
4991 u8
*pRetPar
, *pTriple
;
4992 u8 len
= 0, i
, j
, handleNum
= 0;
4993 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
4994 u16
*pu2Temp
, *pPackets
, *pHandle
, *pDblocks
;
4997 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
4999 if (!(pBtHciInfo
->BTEventMaskPage2
& EMP2_HCI_EVENT_NUM_OF_COMPLETE_DATA_BLOCKS
)) {
5000 RTPRINT(FIOCTL
, IOCTL_BT_EVENT
, ("[BT event], Num Of Completed DataBlocks, Ignore to send NumOfCompletedDataBlocksEvent due to event mask page 2\n"));
5004 /* Return parameters starts from here */
5005 pRetPar
= &PPacketIrpEvent
->Data
[0];
5006 pTriple
= &pRetPar
[3];
5007 for (j
= 0; j
< MAX_BT_ASOC_ENTRY_NUM
; j
++) {
5009 for (i
= 0; i
< MAX_LOGICAL_LINK_NUM
; i
++) {
5010 if (pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
) {
5012 pHandle
= (u16
*)&pTriple
[0]; /* Handle[i] */
5013 pPackets
= (u16
*)&pTriple
[2]; /* Num_Of_Completed_Packets[i] */
5014 pDblocks
= (u16
*)&pTriple
[4]; /* Num_Of_Completed_Blocks[i] */
5015 *pHandle
= pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].BtLogLinkhandle
;
5016 *pPackets
= (u16
)pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].TxPacketCount
;
5017 *pDblocks
= (u16
)pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].TxPacketCount
;
5018 if (pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].TxPacketCount
) {
5020 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_DETAIL
,
5021 ("[BT event], Num Of Completed DataBlocks, Handle = 0x%x, Num_Of_Completed_Packets = 0x%x, Num_Of_Completed_Blocks = 0x%x\n",
5022 *pHandle
, *pPackets
, *pDblocks
));
5024 pBTInfo
->BtAsocEntry
[j
].LogLinkCmdData
[i
].TxPacketCount
= 0;
5031 pRetPar
[2] = handleNum
; /* Number_of_Handles */
5033 pu2Temp
= (u16
*)&pRetPar
[0];
5034 *pu2Temp
= BTTotalDataBlockNum
;
5037 PPacketIrpEvent
->EventCode
= HCI_EVENT_NUM_OF_COMPLETE_DATA_BLOCKS
;
5038 PPacketIrpEvent
->Length
= len
;
5039 if (handleNum
&& sent
)
5040 bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2);
5043 void BTHCI_EventAMPStatusChange(struct rtw_adapter
*padapter
, u8 AMP_Status
)
5045 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
5046 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
5047 struct packet_irp_hcievent_data
*PPacketIrpEvent
;
5049 u8 localBuf
[7] = "";
5052 if (AMP_Status
== AMP_STATUS_NO_CAPACITY_FOR_BT
) {
5053 pBtMgnt
->BTNeedAMPStatusChg
= true;
5054 pBtMgnt
->bNeedNotifyAMPNoCap
= false;
5056 BTHCI_DisconnectAll(padapter
);
5057 } else if (AMP_Status
== AMP_STATUS_FULL_CAPACITY_FOR_BT
) {
5058 pBtMgnt
->BTNeedAMPStatusChg
= false;
5061 PPacketIrpEvent
= (struct packet_irp_hcievent_data
*)(&localBuf
[0]);
5062 /* Return parameters starts from here */
5063 pRetPar
= &PPacketIrpEvent
->Data
[0];
5065 pRetPar
[0] = 0; /* Status */
5067 pRetPar
[1] = AMP_Status
; /* AMP_Status */
5070 PPacketIrpEvent
->EventCode
= HCI_EVENT_AMP_STATUS_CHANGE
;
5071 PPacketIrpEvent
->Length
= len
;
5072 if (bthci_IndicateEvent(padapter
, PPacketIrpEvent
, len
+2) == RT_STATUS_SUCCESS
)
5073 RTPRINT(FIOCTL
, (IOCTL_BT_EVENT
|IOCTL_STATE
), ("[BT event], AMP Status Change, AMP_Status = %d\n", AMP_Status
));
5076 void BTHCI_DisconnectAll(struct rtw_adapter
*padapter
)
5078 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
5081 RTPRINT(FIOCTL
, IOCTL_STATE
, (" DisconnectALL()\n"));
5083 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
5084 if (pBTInfo
->BtAsocEntry
[i
].b4waySuccess
) {
5085 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_CONNECTED
, STATE_CMD_DISCONNECT_PHY_LINK
, i
);
5086 } else if (pBTInfo
->BtAsocEntry
[i
].bUsed
) {
5087 if (pBTInfo
->BtAsocEntry
[i
].BtCurrentState
== HCI_STATE_CONNECTING
) {
5088 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_CONNECTING
, STATE_CMD_MAC_CONNECT_CANCEL_INDICATE
, i
);
5089 } else if (pBTInfo
->BtAsocEntry
[i
].BtCurrentState
== HCI_STATE_DISCONNECTING
) {
5090 BTHCI_SM_WITH_INFO(padapter
, HCI_STATE_DISCONNECTING
, STATE_CMD_MAC_CONNECT_CANCEL_INDICATE
, i
);
5098 struct rtw_adapter
*padapter
,
5099 struct packet_irp_hcicmd_data
*pHciCmd
5102 enum hci_status status
= HCI_STATUS_SUCCESS
;
5103 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
5104 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
5106 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("\n"));
5107 RTPRINT(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), ("HCI Command start, OGF = 0x%x, OCF = 0x%x, Length = 0x%x\n",
5108 pHciCmd
->OGF
, pHciCmd
->OCF
, pHciCmd
->Length
));
5109 if (pHciCmd
->Length
) {
5110 RTPRINT_DATA(FIOCTL
, (IOCTL_BT_HCICMD_DETAIL
|IOCTL_BT_LOGO
), "HCI Command, Hex Data :\n",
5111 &pHciCmd
->Data
[0], pHciCmd
->Length
);
5113 if (pHciCmd
->OGF
== OGF_EXTENSION
) {
5114 if (pHciCmd
->OCF
== HCI_SET_RSSI_VALUE
)
5115 RTPRINT(FIOCTL
, IOCTL_BT_EVENT_PERIODICAL
, ("[BT cmd], "));
5117 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_EXT
, ("[BT cmd], "));
5119 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("[BT cmd], "));
5122 pBtDbg
->dbgHciInfo
.hciCmdCnt
++;
5124 switch (pHciCmd
->OGF
) {
5125 case LINK_CONTROL_COMMANDS
:
5126 status
= bthci_HandleOGFLinkControlCMD(padapter
, pHciCmd
);
5128 case HOLD_MODE_COMMAND
:
5130 case OGF_SET_EVENT_MASK_COMMAND
:
5131 status
= bthci_HandleOGFSetEventMaskCMD(padapter
, pHciCmd
);
5133 case OGF_INFORMATIONAL_PARAMETERS
:
5134 status
= bthci_HandleOGFInformationalParameters(padapter
, pHciCmd
);
5136 case OGF_STATUS_PARAMETERS
:
5137 status
= bthci_HandleOGFStatusParameters(padapter
, pHciCmd
);
5139 case OGF_TESTING_COMMANDS
:
5140 status
= bthci_HandleOGFTestingCMD(padapter
, pHciCmd
);
5143 status
= bthci_HandleOGFExtension(padapter
, pHciCmd
);
5146 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI Command(), Unknown OGF = 0x%x\n", pHciCmd
->OGF
));
5147 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD
, ("HCI_UNKNOWN_COMMAND\n"));
5148 status
= bthci_UnknownCMD(padapter
, pHciCmd
);
5151 RTPRINT(FIOCTL
, IOCTL_BT_HCICMD_DETAIL
, ("HCI Command execution end!!\n"));
5156 /* ===== End of sync from SD7 driver COMMOM/bt_hci.c ===== */
5158 static const char *const BtStateString
[] = {
5166 "BT_ACL_INQ_OR_PAG",
5167 "BT_STATE_NOT_DEFINED"
5170 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.c ===== */
5172 static void btdm_SetFwIgnoreWlanAct(struct rtw_adapter
*padapter
, u8 bEnable
)
5174 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
5175 u8 H2C_Parameter
[1] = {0};
5178 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT Ignore Wlan_Act !!\n"));
5179 H2C_Parameter
[0] |= BIT(0); /* function enable */
5180 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
5182 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT don't ignore Wlan_Act !!\n"));
5185 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], set FW for BT Ignore Wlan_Act, write 0x25 = 0x%02x\n",
5188 FillH2CCmd(padapter
, BT_IGNORE_WLAN_ACT_EID
, 1, H2C_Parameter
);
5191 static void btdm_NotifyFwScan(struct rtw_adapter
*padapter
, u8 scanType
)
5193 u8 H2C_Parameter
[1] = {0};
5195 if (scanType
== true)
5196 H2C_Parameter
[0] = 0x1;
5198 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Notify FW for wifi scan, write 0x3b = 0x%02x\n",
5201 FillH2CCmd(padapter
, 0x3b, 1, H2C_Parameter
);
5204 static void btdm_1AntSetPSMode(struct rtw_adapter
*padapter
,
5205 u8 enable
, u8 smartps
, u8 mode
)
5207 struct pwrctrl_priv
*pwrctrl
;
5209 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Current LPS(%s, %d), smartps =%d\n", enable
== true?"ON":"OFF", mode
, smartps
));
5211 pwrctrl
= &padapter
->pwrctrlpriv
;
5213 if (enable
== true) {
5214 rtw_set_ps_mode23a(padapter
, PS_MODE_MIN
, smartps
, mode
);
5216 rtw_set_ps_mode23a(padapter
, PS_MODE_ACTIVE
, 0, 0);
5217 LPS_RF_ON_check23a(padapter
, 100);
5221 static void btdm_1AntTSFSwitch(struct rtw_adapter
*padapter
, u8 enable
)
5225 oldVal
= rtl8723au_read8(padapter
, 0x550);
5228 newVal
= oldVal
| EN_BCN_FUNCTION
;
5230 newVal
= oldVal
& ~EN_BCN_FUNCTION
;
5232 if (oldVal
!= newVal
)
5233 rtl8723au_write8(padapter
, 0x550, newVal
);
5236 static u8
btdm_Is1AntPsTdmaStateChange(struct rtw_adapter
*padapter
)
5238 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
5239 struct btdm_8723a_1ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5241 if ((pBtdm8723
->bPrePsTdmaOn
!= pBtdm8723
->bCurPsTdmaOn
) ||
5242 (pBtdm8723
->prePsTdma
!= pBtdm8723
->curPsTdma
))
5248 /* Before enter TDMA, make sure Power Saving is enable! */
5251 struct rtw_adapter
*padapter
,
5256 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
5257 struct btdm_8723a_1ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5259 pBtdm8723
->bCurPsTdmaOn
= bTurnOn
;
5260 pBtdm8723
->curPsTdma
= type
;
5263 case 1: /* A2DP Level-1 or FTP/OPP */
5265 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5266 /* wide duration for WiFi */
5267 BTDM_SetFw3a(padapter
, 0xd3, 0x1a, 0x1a, 0x0, 0x58);
5270 case 2: /* A2DP Level-2 */
5271 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5272 /* normal duration for WiFi */
5273 BTDM_SetFw3a(padapter
, 0xd3, 0x12, 0x12, 0x0, 0x58);
5276 case 3: /* BT FTP/OPP */
5277 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5278 /* normal duration for WiFi */
5279 BTDM_SetFw3a(padapter
, 0xd3, 0x30, 0x03, 0x10, 0x58);
5283 case 4: /* for wifi scan & BT is connected */
5284 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5285 /* protect 3 beacons in 3-beacon period & no Tx pause at BT slot */
5286 BTDM_SetFw3a(padapter
, 0x93, 0x15, 0x03, 0x14, 0x0);
5289 case 5: /* for WiFi connected-busy & BT is Non-Connected-Idle */
5290 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5291 /* SCO mode, Ant fixed at WiFi, WLAN_Act toggle */
5292 BTDM_SetFw3a(padapter
, 0x61, 0x15, 0x03, 0x31, 0x00);
5295 case 9: /* ACL high-retry type - 2 */
5296 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5297 /* narrow duration for WiFi */
5298 BTDM_SetFw3a(padapter
, 0xd3, 0xa, 0xa, 0x0, 0x58); /* narrow duration for WiFi */
5301 case 10: /* for WiFi connect idle & BT ACL busy or WiFi Connected-Busy & BT is Inquiry */
5302 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5303 BTDM_SetFw3a(padapter
, 0x13, 0xa, 0xa, 0x0, 0x40);
5305 case 11: /* ACL high-retry type - 3 */
5306 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5307 /* narrow duration for WiFi */
5308 BTDM_SetFw3a(padapter
, 0xd3, 0x05, 0x05, 0x00, 0x58);
5311 case 12: /* for WiFi Connected-Busy & BT is Connected-Idle */
5312 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5313 /* Allow High-Pri BT */
5314 BTDM_SetFw3a(padapter
, 0xeb, 0x0a, 0x03, 0x31, 0x18);
5317 case 20: /* WiFi only busy , TDMA mode for power saving */
5318 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5319 BTDM_SetFw3a(padapter
, 0x13, 0x25, 0x25, 0x00, 0x00);
5321 case 27: /* WiFi DHCP/Site Survey & BT SCO busy */
5322 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5323 BTDM_SetFw3a(padapter
, 0xa3, 0x25, 0x03, 0x31, 0x98);
5325 case 28: /* WiFi DHCP/Site Survey & BT idle */
5326 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5327 BTDM_SetFw3a(padapter
, 0x69, 0x25, 0x03, 0x31, 0x00);
5329 case 29: /* WiFi DHCP/Site Survey & BT ACL busy */
5330 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5331 BTDM_SetFw3a(padapter
, 0xeb, 0x1a, 0x1a, 0x01, 0x18);
5332 rtl8723au_write32(padapter
, 0x6c0, 0x5afa5afa);
5333 rtl8723au_write32(padapter
, 0x6c4, 0x5afa5afa);
5336 case 30: /* WiFi idle & BT Inquiry */
5337 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5338 BTDM_SetFw3a(padapter
, 0x93, 0x15, 0x03, 0x14, 0x00);
5340 case 31: /* BT HID */
5341 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5342 BTDM_SetFw3a(padapter
, 0xd3, 0x1a, 0x1a, 0x00, 0x58);
5344 case 32: /* BT SCO & Inquiry */
5345 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5346 BTDM_SetFw3a(padapter
, 0xab, 0x0a, 0x03, 0x11, 0x98);
5348 case 33: /* BT SCO & WiFi site survey */
5349 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5350 BTDM_SetFw3a(padapter
, 0xa3, 0x25, 0x03, 0x30, 0x98);
5352 case 34: /* BT HID & WiFi site survey */
5353 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5354 BTDM_SetFw3a(padapter
, 0xd3, 0x1a, 0x1a, 0x00, 0x18);
5356 case 35: /* BT HID & WiFi Connecting */
5357 if (btdm_Is1AntPsTdmaStateChange(padapter
))
5358 BTDM_SetFw3a(padapter
, 0xe3, 0x1a, 0x1a, 0x00, 0x18);
5362 /* disable PS-TDMA */
5365 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5366 /* Antenna control by PTA, 0x870 = 0x310 */
5367 BTDM_SetFw3a(padapter
, 0x8, 0x0, 0x0, 0x0, 0x0);
5372 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5373 /* Antenna control by PTA, 0x870 = 0x310 */
5374 BTDM_SetFw3a(padapter
, 0x0, 0x0, 0x0, 0x8, 0x0);
5376 /* Switch Antenna to BT */
5377 rtl8723au_write16(padapter
, 0x860, 0x210);
5378 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 0x860 = 0x210, Switch Antenna to BT\n"));
5381 if (btdm_Is1AntPsTdmaStateChange(padapter
)) {
5382 /* Antenna control by PTA, 0x870 = 0x310 */
5383 BTDM_SetFw3a(padapter
, 0x0, 0x0, 0x0, 0x8, 0x0);
5385 /* Switch Antenna to WiFi */
5386 rtl8723au_write16(padapter
, 0x860, 0x110);
5387 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 0x860 = 0x110, Switch Antenna to WiFi\n"));
5392 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Current TDMA(%s, %d)\n",
5393 pBtdm8723
->bCurPsTdmaOn
?"ON":"OFF", pBtdm8723
->curPsTdma
));
5395 /* update pre state */
5396 pBtdm8723
->bPrePsTdmaOn
= pBtdm8723
->bCurPsTdmaOn
;
5397 pBtdm8723
->prePsTdma
= pBtdm8723
->curPsTdma
;
5401 _btdm_1AntSetPSTDMA(struct rtw_adapter
*padapter
, u8 bPSEn
, u8 smartps
,
5402 u8 psOption
, u8 bTDMAOn
, u8 tdmaType
)
5404 struct pwrctrl_priv
*pwrctrl
;
5405 struct hal_data_8723a
*pHalData
;
5406 struct btdm_8723a_1ant
*pBtdm8723
;
5410 if (!check_fwstate(&padapter
->mlmepriv
, WIFI_STATION_STATE
) &&
5411 (get_fwstate(&padapter
->mlmepriv
) != WIFI_NULL_STATE
)) {
5412 btdm_1AntPsTdma(padapter
, bTDMAOn
, tdmaType
);
5415 psOption
&= ~BIT(0);
5417 RTPRINT(FBT
, BT_TRACE
,
5418 ("[BTCoex], Set LPS(%s, %d) TDMA(%s, %d)\n",
5419 bPSEn
== true?"ON":"OFF", psOption
,
5420 bTDMAOn
== true?"ON":"OFF", tdmaType
));
5422 pwrctrl
= &padapter
->pwrctrlpriv
;
5423 pHalData
= GET_HAL_DATA(padapter
);
5424 pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5427 if (pBtdm8723
->bWiFiHalt
) {
5428 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Enable PS Fail, WiFi in Halt!!\n"));
5432 if (pwrctrl
->bInSuspend
) {
5433 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Enable PS Fail, WiFi in Suspend!!\n"));
5437 if (padapter
->bDriverStopped
) {
5438 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Enable PS Fail, WiFi driver stopped!!\n"));
5442 if (padapter
->bSurpriseRemoved
) {
5443 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Enable PS Fail, WiFi Surprise Removed!!\n"));
5447 psMode
= PS_MODE_MIN
;
5449 psMode
= PS_MODE_ACTIVE
;
5453 if (psMode
!= pwrctrl
->pwr_mode
) {
5455 } else if (psMode
!= PS_MODE_ACTIVE
) {
5456 if (psOption
!= pwrctrl
->bcn_ant_mode
)
5458 else if (smartps
!= pwrctrl
->smart_ps
)
5468 if (pBtdm8723
->bCurPsTdmaOn
) {
5470 btdm_1AntPsTdma(padapter
, false, tdmaType
);
5472 if (!rtl8723a_BT_enabled(padapter
) ||
5473 (pHalData
->bt_coexist
.halCoex8723
.c2hBtInfo
== BT_INFO_STATE_NO_CONNECTION
) ||
5474 (pHalData
->bt_coexist
.halCoex8723
.c2hBtInfo
== BT_INFO_STATE_CONNECT_IDLE
) ||
5476 btdm_1AntPsTdma(padapter
, false, 9);
5478 btdm_1AntPsTdma(padapter
, false, 0);
5482 /* change Power Save State */
5483 btdm_1AntSetPSMode(padapter
, bPSEn
, smartps
, psOption
);
5486 btdm_1AntPsTdma(padapter
, bTDMAOn
, tdmaType
);
5490 btdm_1AntSetPSTDMA(struct rtw_adapter
*padapter
, u8 bPSEn
,
5491 u8 psOption
, u8 bTDMAOn
, u8 tdmaType
)
5493 _btdm_1AntSetPSTDMA(padapter
, bPSEn
, 0, psOption
, bTDMAOn
, tdmaType
);
5496 static void btdm_1AntWifiParaAdjust(struct rtw_adapter
*padapter
, u8 bEnable
)
5498 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
5499 struct btdm_8723a_1ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5502 pBtdm8723
->curWifiPara
= 1;
5503 if (pBtdm8723
->preWifiPara
!= pBtdm8723
->curWifiPara
)
5504 BTDM_SetSwPenaltyTxRateAdaptive(padapter
, BT_TX_RATE_ADAPTIVE_LOW_PENALTY
);
5506 pBtdm8723
->curWifiPara
= 2;
5507 if (pBtdm8723
->preWifiPara
!= pBtdm8723
->curWifiPara
)
5508 BTDM_SetSwPenaltyTxRateAdaptive(padapter
, BT_TX_RATE_ADAPTIVE_NORMAL
);
5513 static void btdm_1AntPtaParaReload(struct rtw_adapter
*padapter
)
5516 rtl8723au_write8(padapter
, 0x6cc, 0x0); /* 1-Ant coex */
5517 rtl8723au_write32(padapter
, 0x6c8, 0xffff); /* wifi break table */
5518 rtl8723au_write32(padapter
, 0x6c4, 0x55555555); /* coex table */
5520 /* Antenna switch control parameter */
5521 rtl8723au_write32(padapter
, 0x858, 0xaaaaaaaa);
5522 if (IS_8723A_A_CUT(GET_HAL_DATA(padapter
)->VersionID
)) {
5523 /* SPDT(connected with TRSW) control by hardware PTA */
5524 rtl8723au_write32(padapter
, 0x870, 0x0);
5525 rtl8723au_write8(padapter
, 0x40, 0x24);
5527 rtl8723au_write8(padapter
, 0x40, 0x20);
5528 /* set antenna at bt side if ANTSW is software control */
5529 rtl8723au_write16(padapter
, 0x860, 0x210);
5530 /* SPDT(connected with TRSW) control by hardware PTA */
5531 rtl8723au_write32(padapter
, 0x870, 0x300);
5532 /* ANTSW keep by GNT_BT */
5533 rtl8723au_write32(padapter
, 0x874, 0x22804000);
5536 /* coexistence parameters */
5537 rtl8723au_write8(padapter
, 0x778, 0x1); /* enable RTK mode PTA */
5539 /* BT don't ignore WLAN_Act */
5540 btdm_SetFwIgnoreWlanAct(padapter
, false);
5545 *1: upgrade (add WiFi duration time)
5547 *-1: downgrade (add BT duration time)
5549 static s8
btdm_1AntTdmaJudgement(struct rtw_adapter
*padapter
, u8 retry
)
5551 struct hal_data_8723a
*pHalData
;
5552 struct btdm_8723a_1ant
*pBtdm8723
;
5553 static s8 up
, dn
, m
= 1, n
= 3, WaitCount
;
5556 pHalData
= GET_HAL_DATA(padapter
);
5557 pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5560 if (pBtdm8723
->psTdmaMonitorCnt
== 0) {
5571 /* no retry in the last 2-second duration */
5577 /* retry = 0 in consecutive 3m*(2s), add WiFi duration */
5585 } else if (retry
<= 3) {
5586 /* retry<= 3 in the last 2-second duration */
5593 /* retry<= 3 in consecutive 2*(2s), minus WiFi duration (add BT duration) */
5596 /* record how many time downgrad WiFi duration */
5601 /* the max number of m is 20 */
5602 /* the longest time of upgrade WiFi duration is 20*3*2s = 120s */
5610 /* retry count > 3 */
5611 /* retry>3, minus WiFi duration (add BT duration) */
5614 /* record how many time downgrad WiFi duration */
5629 static void btdm_1AntTdmaDurationAdjustForACL(struct rtw_adapter
*padapter
)
5631 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
5632 struct btdm_8723a_1ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
5634 if (pBtdm8723
->psTdmaGlobalCnt
!= pBtdm8723
->psTdmaMonitorCnt
) {
5635 pBtdm8723
->psTdmaMonitorCnt
= 0;
5636 pBtdm8723
->psTdmaGlobalCnt
= 0;
5638 if (pBtdm8723
->psTdmaMonitorCnt
== 0) {
5639 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 2);
5640 pBtdm8723
->psTdmaDuAdjType
= 2;
5642 /* Now we only have 4 level Ps Tdma, */
5643 /* if that's not the following 4 level(will changed by wifi scan, dhcp...), */
5644 /* then we have to adjust it back to the previous record one. */
5645 if ((pBtdm8723
->curPsTdma
!= 1) &&
5646 (pBtdm8723
->curPsTdma
!= 2) &&
5647 (pBtdm8723
->curPsTdma
!= 9) &&
5648 (pBtdm8723
->curPsTdma
!= 11)) {
5649 btdm_1AntSetPSTDMA(padapter
, true, 0, true, pBtdm8723
->psTdmaDuAdjType
);
5653 judge
= btdm_1AntTdmaJudgement(padapter
, pHalData
->bt_coexist
.halCoex8723
.btRetryCnt
);
5655 if (pBtdm8723
->curPsTdma
== 1) {
5656 /* Decrease WiFi duration for high BT retry */
5657 if (pHalData
->bt_coexist
.halCoex8723
.btInfoExt
)
5658 pBtdm8723
->psTdmaDuAdjType
= 9;
5660 pBtdm8723
->psTdmaDuAdjType
= 2;
5661 btdm_1AntSetPSTDMA(padapter
, true, 0, true, pBtdm8723
->psTdmaDuAdjType
);
5662 } else if (pBtdm8723
->curPsTdma
== 2) {
5663 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 9);
5664 pBtdm8723
->psTdmaDuAdjType
= 9;
5665 } else if (pBtdm8723
->curPsTdma
== 9) {
5666 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 11);
5667 pBtdm8723
->psTdmaDuAdjType
= 11;
5669 } else if (judge
== 1) {
5670 if (pBtdm8723
->curPsTdma
== 11) {
5671 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 9);
5672 pBtdm8723
->psTdmaDuAdjType
= 9;
5673 } else if (pBtdm8723
->curPsTdma
== 9) {
5674 if (pHalData
->bt_coexist
.halCoex8723
.btInfoExt
)
5675 pBtdm8723
->psTdmaDuAdjType
= 9;
5677 pBtdm8723
->psTdmaDuAdjType
= 2;
5678 btdm_1AntSetPSTDMA(padapter
, true, 0, true, pBtdm8723
->psTdmaDuAdjType
);
5679 } else if (pBtdm8723
->curPsTdma
== 2) {
5680 if (pHalData
->bt_coexist
.halCoex8723
.btInfoExt
)
5681 pBtdm8723
->psTdmaDuAdjType
= 9;
5683 pBtdm8723
->psTdmaDuAdjType
= 1;
5684 btdm_1AntSetPSTDMA(padapter
, true, 0, true, pBtdm8723
->psTdmaDuAdjType
);
5688 RTPRINT(FBT
, BT_TRACE
,
5689 ("[BTCoex], ACL current TDMA(%s, %d)\n",
5690 (pBtdm8723
->bCurPsTdmaOn
? "ON" : "OFF"), pBtdm8723
->curPsTdma
));
5692 pBtdm8723
->psTdmaMonitorCnt
++;
5695 static void btdm_1AntCoexProcessForWifiConnect(struct rtw_adapter
*padapter
)
5697 struct mlme_priv
*pmlmepriv
;
5698 struct hal_data_8723a
*pHalData
;
5699 struct bt_coexist_8723a
*pBtCoex
;
5700 struct btdm_8723a_1ant
*pBtdm8723
;
5703 pmlmepriv
= &padapter
->mlmepriv
;
5704 pHalData
= GET_HAL_DATA(padapter
);
5705 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
5706 pBtdm8723
= &pBtCoex
->btdm1Ant
;
5707 BtState
= pBtCoex
->c2hBtInfo
;
5709 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], WiFi is %s\n",
5710 BTDM_IsWifiBusy(padapter
)?"Busy":"IDLE"));
5711 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT is %s\n",
5712 BtStateString
[BtState
]));
5714 padapter
->pwrctrlpriv
.btcoex_rfon
= false;
5716 if (!BTDM_IsWifiBusy(padapter
) &&
5717 !check_fwstate(&padapter
->mlmepriv
, WIFI_AP_STATE
) &&
5718 (BtState
== BT_INFO_STATE_NO_CONNECTION
||
5719 BtState
== BT_INFO_STATE_CONNECT_IDLE
)) {
5721 case BT_INFO_STATE_NO_CONNECTION
:
5722 _btdm_1AntSetPSTDMA(padapter
, true, 2, 0x26, false, 9);
5724 case BT_INFO_STATE_CONNECT_IDLE
:
5725 _btdm_1AntSetPSTDMA(padapter
, true, 2, 0x26, false, 0);
5730 case BT_INFO_STATE_NO_CONNECTION
:
5731 case BT_INFO_STATE_CONNECT_IDLE
:
5733 btdm_1AntSetPSTDMA(padapter
, false, 0, true, 5);
5734 rtl8723au_write32(padapter
, 0x6c0, 0x5a5a5a5a);
5735 rtl8723au_write32(padapter
, 0x6c4, 0x5a5a5a5a);
5737 case BT_INFO_STATE_ACL_INQ_OR_PAG
:
5738 RTPRINT(FBT
, BT_TRACE
,
5739 ("[BTCoex], BT PROFILE is "
5740 "BT_INFO_STATE_ACL_INQ_OR_PAG\n"));
5741 case BT_INFO_STATE_INQ_OR_PAG
:
5742 padapter
->pwrctrlpriv
.btcoex_rfon
= true;
5743 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 30);
5745 case BT_INFO_STATE_SCO_ONLY_BUSY
:
5746 case BT_INFO_STATE_ACL_SCO_BUSY
:
5747 if (true == pBtCoex
->bC2hBtInquiryPage
)
5748 btdm_1AntSetPSTDMA(padapter
, false, 0,
5751 #ifdef BTCOEX_CMCC_TEST
5752 btdm_1AntSetPSTDMA(padapter
, false, 0,
5754 #else /* !BTCOEX_CMCC_TEST */
5755 btdm_1AntSetPSTDMA(padapter
, false, 0,
5757 rtl8723au_write32(padapter
, 0x6c0, 0x5a5a5a5a);
5758 rtl8723au_write32(padapter
, 0x6c4, 0x5a5a5a5a);
5759 #endif /* !BTCOEX_CMCC_TEST */
5762 case BT_INFO_STATE_ACL_ONLY_BUSY
:
5763 padapter
->pwrctrlpriv
.btcoex_rfon
= true;
5764 if (pBtCoex
->c2hBtProfile
== BT_INFO_HID
) {
5765 RTPRINT(FBT
, BT_TRACE
,
5766 ("[BTCoex], BT PROFILE is HID\n"));
5767 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 31);
5768 } else if (pBtCoex
->c2hBtProfile
== BT_INFO_FTP
) {
5769 RTPRINT(FBT
, BT_TRACE
,
5770 ("[BTCoex], BT PROFILE is FTP/OPP\n"));
5771 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 3);
5772 } else if (pBtCoex
->c2hBtProfile
== (BT_INFO_A2DP
|BT_INFO_FTP
)) {
5773 RTPRINT(FBT
, BT_TRACE
,
5774 ("[BTCoex], BT PROFILE is A2DP_FTP\n"));
5775 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 11);
5777 if (pBtCoex
->c2hBtProfile
== BT_INFO_A2DP
)
5778 RTPRINT(FBT
, BT_TRACE
,
5779 ("[BTCoex], BT PROFILE is "
5782 RTPRINT(FBT
, BT_TRACE
,
5783 ("[BTCoex], BT PROFILE is "
5784 "UNKNOWN(0x%02X)! Use A2DP "
5786 pBtCoex
->c2hBtProfile
));
5787 btdm_1AntTdmaDurationAdjustForACL(padapter
);
5793 pBtdm8723
->psTdmaGlobalCnt
++;
5797 btdm_1AntUpdateHalRAMask(struct rtw_adapter
*padapter
, u32 mac_id
, u32 filter
)
5802 u8 shortGIrate
= false;
5803 int supportRateNum
= 0;
5804 struct sta_info
*psta
;
5805 struct hal_data_8723a
*pHalData
;
5806 struct dm_priv
*pdmpriv
;
5807 struct mlme_ext_priv
*pmlmeext
;
5808 struct mlme_ext_info
*pmlmeinfo
;
5809 struct wlan_bssid_ex
*cur_network
;
5811 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], %s, MACID =%d, filter = 0x%08x!!\n",
5812 __func__
, mac_id
, filter
));
5814 pHalData
= GET_HAL_DATA(padapter
);
5815 pdmpriv
= &pHalData
->dmpriv
;
5816 pmlmeext
= &padapter
->mlmeextpriv
;
5817 pmlmeinfo
= &pmlmeext
->mlmext_info
;
5818 cur_network
= &pmlmeinfo
->network
;
5820 if (mac_id
>= NUM_STA
) { /* CAM_SIZE */
5821 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], %s, MACID =%d illegal!!\n",
5826 psta
= pmlmeinfo
->FW_sta_info
[mac_id
].psta
;
5828 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], %s, Can't find station!!\n",
5836 case 0:/* for infra mode */
5838 rtw_get_rateset_len23a(cur_network
->SupportedRates
);
5839 mask
= update_supported_rate23a(cur_network
->SupportedRates
,
5841 mask
|= (pmlmeinfo
->HT_enable
) ?
5842 update_MSC_rate23a(&pmlmeinfo
->ht_cap
):0;
5843 if (support_short_GI23a(padapter
, &pmlmeinfo
->ht_cap
))
5846 case 1:/* for broadcast/multicast */
5847 supportRateNum
= rtw_get_rateset_len23a(
5848 pmlmeinfo
->FW_sta_info
[mac_id
].SupportedRates
);
5849 mask
= update_basic_rate23a(cur_network
->SupportedRates
,
5852 default: /* for each sta in IBSS */
5853 supportRateNum
= rtw_get_rateset_len23a(
5854 pmlmeinfo
->FW_sta_info
[mac_id
].SupportedRates
);
5855 mask
= update_supported_rate23a(cur_network
->SupportedRates
,
5859 mask
|= ((raid
<<28)&0xf0000000);
5862 init_rate
= get_highest_rate_idx23a(mask
)&0x3f;
5864 arg
= mac_id
&0x1f;/* MACID */
5866 if (true == shortGIrate
)
5869 RTPRINT(FBT
, BT_TRACE
,
5870 ("[BTCoex], Update FW RAID entry, MASK = 0x%08x, "
5871 "arg = 0x%02x\n", mask
, arg
));
5873 rtl8723a_set_raid_cmd(padapter
, mask
, arg
);
5875 psta
->init_rate
= init_rate
;
5876 pdmpriv
->INIDATA_RATE
[mac_id
] = init_rate
;
5880 btdm_1AntUpdateHalRAMaskForSCO(struct rtw_adapter
*padapter
, u8 forceUpdate
)
5882 struct btdm_8723a_1ant
*pBtdm8723
;
5883 struct sta_priv
*pstapriv
;
5884 struct wlan_bssid_ex
*cur_network
;
5885 struct sta_info
*psta
;
5889 pBtdm8723
= &GET_HAL_DATA(padapter
)->bt_coexist
.halCoex8723
.btdm1Ant
;
5891 if (pBtdm8723
->bRAChanged
== true && forceUpdate
== false)
5894 pstapriv
= &padapter
->stapriv
;
5895 cur_network
= &padapter
->mlmeextpriv
.mlmext_info
.network
;
5896 psta
= rtw_get_stainfo23a(pstapriv
, cur_network
->MacAddress
);
5897 macid
= psta
->mac_id
;
5899 filter
|= BIT(_1M_RATE_
);
5900 filter
|= BIT(_2M_RATE_
);
5901 filter
|= BIT(_5M_RATE_
);
5902 filter
|= BIT(_11M_RATE_
);
5903 filter
|= BIT(_6M_RATE_
);
5904 filter
|= BIT(_9M_RATE_
);
5906 btdm_1AntUpdateHalRAMask(padapter
, macid
, filter
);
5908 pBtdm8723
->bRAChanged
= true;
5911 static void btdm_1AntRecoverHalRAMask(struct rtw_adapter
*padapter
)
5913 struct btdm_8723a_1ant
*pBtdm8723
;
5914 struct sta_priv
*pstapriv
;
5915 struct wlan_bssid_ex
*cur_network
;
5916 struct sta_info
*psta
;
5918 pBtdm8723
= &GET_HAL_DATA(padapter
)->bt_coexist
.halCoex8723
.btdm1Ant
;
5920 if (pBtdm8723
->bRAChanged
== false)
5923 pstapriv
= &padapter
->stapriv
;
5924 cur_network
= &padapter
->mlmeextpriv
.mlmext_info
.network
;
5925 psta
= rtw_get_stainfo23a(pstapriv
, cur_network
->MacAddress
);
5927 Update_RA_Entry23a(padapter
, psta
);
5929 pBtdm8723
->bRAChanged
= false;
5933 btdm_1AntBTStateChangeHandler(struct rtw_adapter
*padapter
,
5934 enum bt_state_1ant oldState
,
5935 enum bt_state_1ant newState
)
5937 struct hal_data_8723a
*phaldata
;
5938 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT state change, %s => %s\n",
5939 BtStateString
[oldState
],
5940 BtStateString
[newState
]));
5942 /* BT default ignore wlan active, */
5943 /* WiFi MUST disable this when BT is enable */
5944 if (newState
> BT_INFO_STATE_DISABLED
)
5945 btdm_SetFwIgnoreWlanAct(padapter
, false);
5947 if ((check_fwstate(&padapter
->mlmepriv
, WIFI_STATION_STATE
)) &&
5948 (BTDM_IsWifiConnectionExist(padapter
))) {
5949 if ((newState
== BT_INFO_STATE_SCO_ONLY_BUSY
) ||
5950 (newState
== BT_INFO_STATE_ACL_SCO_BUSY
)) {
5951 btdm_1AntUpdateHalRAMaskForSCO(padapter
, false);
5953 /* Recover original RA setting */
5954 btdm_1AntRecoverHalRAMask(padapter
);
5957 phaldata
= GET_HAL_DATA(padapter
);
5958 phaldata
->bt_coexist
.halCoex8723
.btdm1Ant
.bRAChanged
= false;
5961 if (oldState
== newState
)
5964 if (oldState
== BT_INFO_STATE_ACL_ONLY_BUSY
) {
5965 struct hal_data_8723a
*Hal
= GET_HAL_DATA(padapter
);
5966 Hal
->bt_coexist
.halCoex8723
.btdm1Ant
.psTdmaMonitorCnt
= 0;
5967 Hal
->bt_coexist
.halCoex8723
.btdm1Ant
.psTdmaMonitorCntForSCO
= 0;
5970 if ((oldState
== BT_INFO_STATE_SCO_ONLY_BUSY
) ||
5971 (oldState
== BT_INFO_STATE_ACL_SCO_BUSY
)) {
5972 struct hal_data_8723a
*Hal
= GET_HAL_DATA(padapter
);
5973 Hal
->bt_coexist
.halCoex8723
.btdm1Ant
.psTdmaMonitorCntForSCO
= 0;
5976 /* Active 2Ant mechanism when BT Connected */
5977 if ((oldState
== BT_INFO_STATE_DISABLED
) ||
5978 (oldState
== BT_INFO_STATE_NO_CONNECTION
)) {
5979 if ((newState
!= BT_INFO_STATE_DISABLED
) &&
5980 (newState
!= BT_INFO_STATE_NO_CONNECTION
)) {
5981 BTDM_SetSwRfRxLpfCorner(padapter
,
5982 BT_RF_RX_LPF_CORNER_SHRINK
);
5983 BTDM_AGCTable(padapter
, BT_AGCTABLE_ON
);
5984 BTDM_BBBackOffLevel(padapter
, BT_BB_BACKOFF_ON
);
5987 if ((newState
== BT_INFO_STATE_DISABLED
) ||
5988 (newState
== BT_INFO_STATE_NO_CONNECTION
)) {
5989 BTDM_SetSwRfRxLpfCorner(padapter
,
5990 BT_RF_RX_LPF_CORNER_RESUME
);
5991 BTDM_AGCTable(padapter
, BT_AGCTABLE_OFF
);
5992 BTDM_BBBackOffLevel(padapter
, BT_BB_BACKOFF_OFF
);
5997 static void btdm_1AntBtCoexistHandler(struct rtw_adapter
*padapter
)
5999 struct hal_data_8723a
*pHalData
;
6000 struct bt_coexist_8723a
*pBtCoex8723
;
6001 struct btdm_8723a_1ant
*pBtdm8723
;
6003 pHalData
= GET_HAL_DATA(padapter
);
6004 pBtCoex8723
= &pHalData
->bt_coexist
.halCoex8723
;
6005 pBtdm8723
= &pBtCoex8723
->btdm1Ant
;
6006 padapter
->pwrctrlpriv
.btcoex_rfon
= false;
6007 if (!rtl8723a_BT_enabled(padapter
)) {
6008 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT is disabled\n"));
6010 if (BTDM_IsWifiConnectionExist(padapter
)) {
6011 RTPRINT(FBT
, BT_TRACE
,
6012 ("[BTCoex], wifi is connected\n"));
6014 if (BTDM_IsWifiBusy(padapter
)) {
6015 RTPRINT(FBT
, BT_TRACE
,
6016 ("[BTCoex], Wifi is busy\n"));
6017 btdm_1AntSetPSTDMA(padapter
, false, 0,
6020 RTPRINT(FBT
, BT_TRACE
,
6021 ("[BTCoex], Wifi is idle\n"));
6022 _btdm_1AntSetPSTDMA(padapter
, true, 2, 1,
6026 RTPRINT(FBT
, BT_TRACE
,
6027 ("[BTCoex], wifi is disconnected\n"));
6029 btdm_1AntSetPSTDMA(padapter
, false, 0, false, 9);
6032 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT is enabled\n"));
6034 if (BTDM_IsWifiConnectionExist(padapter
)) {
6035 RTPRINT(FBT
, BT_TRACE
,
6036 ("[BTCoex], wifi is connected\n"));
6038 btdm_1AntWifiParaAdjust(padapter
, true);
6039 btdm_1AntCoexProcessForWifiConnect(padapter
);
6041 RTPRINT(FBT
, BT_TRACE
,
6042 ("[BTCoex], wifi is disconnected\n"));
6044 /* Antenna switch at BT side(0x870 = 0x300,
6045 0x860 = 0x210) after PSTDMA off */
6046 btdm_1AntWifiParaAdjust(padapter
, false);
6047 btdm_1AntSetPSTDMA(padapter
, false, 0, false, 0);
6051 btdm_1AntBTStateChangeHandler(padapter
, pBtCoex8723
->prec2hBtInfo
,
6052 pBtCoex8723
->c2hBtInfo
);
6053 pBtCoex8723
->prec2hBtInfo
= pBtCoex8723
->c2hBtInfo
;
6056 void BTDM_1AntSignalCompensation(struct rtw_adapter
*padapter
,
6057 u8
*rssi_wifi
, u8
*rssi_bt
)
6059 struct hal_data_8723a
*pHalData
;
6060 struct btdm_8723a_1ant
*pBtdm8723
;
6061 u8 RSSI_WiFi_Cmpnstn
, RSSI_BT_Cmpnstn
;
6063 pHalData
= GET_HAL_DATA(padapter
);
6064 pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
;
6065 RSSI_WiFi_Cmpnstn
= 0;
6066 RSSI_BT_Cmpnstn
= 0;
6068 switch (pBtdm8723
->curPsTdma
) {
6069 case 1: /* WiFi 52ms */
6070 RSSI_WiFi_Cmpnstn
= 11; /* 22*0.48 */
6072 case 2: /* WiFi 36ms */
6073 RSSI_WiFi_Cmpnstn
= 14; /* 22*0.64 */
6075 case 9: /* WiFi 20ms */
6076 RSSI_WiFi_Cmpnstn
= 18; /* 22*0.80 */
6078 case 11: /* WiFi 10ms */
6079 RSSI_WiFi_Cmpnstn
= 20; /* 22*0.90 */
6081 case 4: /* WiFi 21ms */
6082 RSSI_WiFi_Cmpnstn
= 17; /* 22*0.79 */
6084 case 16: /* WiFi 24ms */
6085 RSSI_WiFi_Cmpnstn
= 18; /* 22*0.76 */
6087 case 18: /* WiFi 37ms */
6088 RSSI_WiFi_Cmpnstn
= 14; /* 22*0.64 */
6090 case 23: /* Level-1, Antenna switch to BT at all time */
6091 case 24: /* Level-2, Antenna switch to BT at all time */
6092 case 25: /* Level-3a, Antenna switch to BT at all time */
6093 case 26: /* Level-3b, Antenna switch to BT at all time */
6094 case 27: /* Level-3b, Antenna switch to BT at all time */
6095 case 33: /* BT SCO & WiFi site survey */
6096 RSSI_WiFi_Cmpnstn
= 22;
6102 if (rssi_wifi
&& RSSI_WiFi_Cmpnstn
) {
6103 RTPRINT(FBT
, BT_TRACE
,
6104 ("[BTCoex], 1AntSgnlCmpnstn, case %d, WiFiCmpnstn "
6105 "=%d(%d => %d)\n", pBtdm8723
->curPsTdma
,
6106 RSSI_WiFi_Cmpnstn
, *rssi_wifi
,
6107 *rssi_wifi
+RSSI_WiFi_Cmpnstn
));
6108 *rssi_wifi
+= RSSI_WiFi_Cmpnstn
;
6111 if (rssi_bt
&& RSSI_BT_Cmpnstn
) {
6112 RTPRINT(FBT
, BT_TRACE
,
6113 ("[BTCoex], 1AntSgnlCmpnstn, case %d, BTCmpnstn "
6114 "=%d(%d => %d)\n", pBtdm8723
->curPsTdma
,
6115 RSSI_BT_Cmpnstn
, *rssi_bt
, *rssi_bt
+RSSI_BT_Cmpnstn
));
6116 *rssi_bt
+= RSSI_BT_Cmpnstn
;
6120 static void BTDM_1AntParaInit(struct rtw_adapter
*padapter
)
6122 struct hal_data_8723a
*pHalData
;
6123 struct bt_coexist_8723a
*pBtCoex
;
6124 struct btdm_8723a_1ant
*pBtdm8723
;
6126 pHalData
= GET_HAL_DATA(padapter
);
6127 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
6128 pBtdm8723
= &pBtCoex
->btdm1Ant
;
6130 /* Enable counter statistics */
6131 rtl8723au_write8(padapter
, 0x76e, 0x4);
6132 btdm_1AntPtaParaReload(padapter
);
6134 pBtdm8723
->wifiRssiThresh
= 48;
6136 pBtdm8723
->bWiFiHalt
= false;
6137 pBtdm8723
->bRAChanged
= false;
6139 if ((pBtCoex
->c2hBtInfo
!= BT_INFO_STATE_DISABLED
) &&
6140 (pBtCoex
->c2hBtInfo
!= BT_INFO_STATE_NO_CONNECTION
)) {
6141 BTDM_SetSwRfRxLpfCorner(padapter
, BT_RF_RX_LPF_CORNER_SHRINK
);
6142 BTDM_AGCTable(padapter
, BT_AGCTABLE_ON
);
6143 BTDM_BBBackOffLevel(padapter
, BT_BB_BACKOFF_ON
);
6147 static void BTDM_1AntForHalt(struct rtw_adapter
*padapter
)
6149 RTPRINT(FBT
, BT_TRACE
, ("\n[BTCoex], 1Ant for halt\n"));
6151 GET_HAL_DATA(padapter
)->bt_coexist
.halCoex8723
.btdm1Ant
.bWiFiHalt
=
6154 btdm_1AntWifiParaAdjust(padapter
, false);
6156 /* don't use btdm_1AntSetPSTDMA() here */
6157 /* it will call rtw_set_ps_mode23a() and request pwrpriv->lock. */
6158 /* This will lead to deadlock, if this function is called in IPS */
6159 /* Lucas@20130205 */
6160 btdm_1AntPsTdma(padapter
, false, 0);
6162 btdm_SetFwIgnoreWlanAct(padapter
, true);
6165 static void BTDM_1AntLpsLeave(struct rtw_adapter
*padapter
)
6167 RTPRINT(FBT
, BT_TRACE
, ("\n[BTCoex], 1Ant for LPS Leave\n"));
6169 /* Prevent from entering LPS again */
6170 GET_HAL_DATA(padapter
)->bt_coexist
.halCoex8723
.btdm1Ant
.bWiFiHalt
=
6173 btdm_1AntSetPSTDMA(padapter
, false, 0, false, 8);
6174 /*btdm_1AntPsTdma(padapter, false, 8); */
6177 static void BTDM_1AntWifiAssociateNotify(struct rtw_adapter
*padapter
, u8 type
)
6179 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6181 RTPRINT(FBT
, BT_TRACE
,
6182 ("\n[BTCoex], 1Ant for associate, type =%d\n", type
));
6185 rtl8723a_CheckAntenna_Selection(padapter
);
6186 if (!rtl8723a_BT_enabled(padapter
))
6187 btdm_1AntSetPSTDMA(padapter
, false, 0, false, 9);
6189 struct bt_coexist_8723a
*pBtCoex
;
6192 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
6193 BtState
= pBtCoex
->c2hBtInfo
;
6195 btdm_1AntTSFSwitch(padapter
, true);
6197 if (BtState
== BT_INFO_STATE_NO_CONNECTION
||
6198 BtState
== BT_INFO_STATE_CONNECT_IDLE
) {
6199 btdm_1AntSetPSTDMA(padapter
, false, 0,
6201 } else if (BtState
== BT_INFO_STATE_SCO_ONLY_BUSY
||
6202 BtState
== BT_INFO_STATE_ACL_SCO_BUSY
) {
6203 btdm_1AntSetPSTDMA(padapter
, false, 0,
6205 rtl8723au_write32(padapter
, 0x6c0, 0x5a5a5a5a);
6206 rtl8723au_write32(padapter
, 0x6c4, 0x5a5a5a5a);
6207 } else if (BtState
== BT_INFO_STATE_ACL_ONLY_BUSY
||
6208 BtState
== BT_INFO_STATE_ACL_INQ_OR_PAG
) {
6209 if (pBtCoex
->c2hBtProfile
== BT_INFO_HID
)
6210 btdm_1AntSetPSTDMA(padapter
, false, 0,
6213 btdm_1AntSetPSTDMA(padapter
, false, 0,
6218 if (!rtl8723a_BT_enabled(padapter
)) {
6219 if (!BTDM_IsWifiConnectionExist(padapter
)) {
6220 btdm_1AntPsTdma(padapter
, false, 0);
6221 btdm_1AntTSFSwitch(padapter
, false);
6225 btdm_1AntBtCoexistHandler(padapter
);
6230 BTDM_1AntMediaStatusNotify(struct rtw_adapter
*padapter
,
6231 enum rt_media_status mstatus
)
6233 struct bt_coexist_8723a
*pBtCoex
;
6235 pBtCoex
= &GET_HAL_DATA(padapter
)->bt_coexist
.halCoex8723
;
6237 RTPRINT(FBT
, BT_TRACE
,
6238 ("\n\n[BTCoex]******************************\n"));
6239 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], MediaStatus, WiFi %s !!\n",
6240 mstatus
== RT_MEDIA_CONNECT
?"CONNECT":"DISCONNECT"));
6241 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex]******************************\n"));
6243 if (RT_MEDIA_CONNECT
== mstatus
) {
6244 if (check_fwstate(&padapter
->mlmepriv
, WIFI_STATION_STATE
)) {
6245 if (pBtCoex
->c2hBtInfo
== BT_INFO_STATE_SCO_ONLY_BUSY
||
6246 pBtCoex
->c2hBtInfo
== BT_INFO_STATE_ACL_SCO_BUSY
)
6247 btdm_1AntUpdateHalRAMaskForSCO(padapter
, true);
6250 padapter
->pwrctrlpriv
.DelayLPSLastTimeStamp
= jiffies
;
6251 BTDM_1AntForDhcp(padapter
);
6253 /* DBG_8723A("%s rtl8723a_DeinitAntenna_Selection\n",
6255 rtl8723a_DeinitAntenna_Selection(padapter
);
6256 btdm_1AntBtCoexistHandler(padapter
);
6257 pBtCoex
->btdm1Ant
.bRAChanged
= false;
6261 void BTDM_1AntForDhcp(struct rtw_adapter
*padapter
)
6263 struct hal_data_8723a
*pHalData
;
6265 struct bt_coexist_8723a
*pBtCoex
;
6266 struct btdm_8723a_1ant
*pBtdm8723
;
6268 pHalData
= GET_HAL_DATA(padapter
);
6269 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
6270 BtState
= pBtCoex
->c2hBtInfo
;
6271 pBtdm8723
= &pBtCoex
->btdm1Ant
;
6273 RTPRINT(FBT
, BT_TRACE
, ("\n[BTCoex], 1Ant for DHCP\n"));
6274 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 1Ant for DHCP, WiFi is %s\n",
6275 BTDM_IsWifiBusy(padapter
)?"Busy":"IDLE"));
6276 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 1Ant for DHCP, %s\n",
6277 BtStateString
[BtState
]));
6279 BTDM_1AntWifiAssociateNotify(padapter
, true);
6282 static void BTDM_1AntWifiScanNotify(struct rtw_adapter
*padapter
, u8 scanType
)
6284 struct hal_data_8723a
*pHalData
;
6286 struct bt_coexist_8723a
*pBtCoex
;
6287 struct btdm_8723a_1ant
*pBtdm8723
;
6289 pHalData
= GET_HAL_DATA(padapter
);
6290 BtState
= pHalData
->bt_coexist
.halCoex8723
.c2hBtInfo
;
6291 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
6292 pBtdm8723
= &pBtCoex
->btdm1Ant
;
6294 RTPRINT(FBT
, BT_TRACE
, ("\n[BTCoex], 1Ant for wifi scan =%d!!\n",
6296 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 1Ant for wifi scan, WiFi is %s\n",
6297 BTDM_IsWifiBusy(padapter
)?"Busy":"IDLE"));
6298 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 1Ant for wifi scan, %s\n",
6299 BtStateString
[BtState
]));
6302 rtl8723a_CheckAntenna_Selection(padapter
);
6303 if (!rtl8723a_BT_enabled(padapter
)) {
6304 btdm_1AntSetPSTDMA(padapter
, false, 0, false, 9);
6305 } else if (BTDM_IsWifiConnectionExist(padapter
) == false) {
6306 BTDM_1AntWifiAssociateNotify(padapter
, true);
6308 if ((BtState
== BT_INFO_STATE_SCO_ONLY_BUSY
) ||
6309 (BtState
== BT_INFO_STATE_ACL_SCO_BUSY
)) {
6310 if (pBtCoex
->bC2hBtInquiryPage
) {
6311 btdm_1AntSetPSTDMA(padapter
, false, 0,
6314 padapter
->pwrctrlpriv
.btcoex_rfon
=
6316 btdm_1AntSetPSTDMA(padapter
, true, 0,
6319 } else if (true == pBtCoex
->bC2hBtInquiryPage
) {
6320 padapter
->pwrctrlpriv
.btcoex_rfon
= true;
6321 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 30);
6322 } else if (BtState
== BT_INFO_STATE_ACL_ONLY_BUSY
) {
6323 padapter
->pwrctrlpriv
.btcoex_rfon
= true;
6324 if (pBtCoex
->c2hBtProfile
== BT_INFO_HID
)
6325 btdm_1AntSetPSTDMA(padapter
, true, 0,
6328 btdm_1AntSetPSTDMA(padapter
, true, 0,
6331 padapter
->pwrctrlpriv
.btcoex_rfon
= true;
6332 btdm_1AntSetPSTDMA(padapter
, true, 0, true, 5);
6336 btdm_NotifyFwScan(padapter
, 1);
6338 /* WiFi_Finish_Scan */
6339 btdm_NotifyFwScan(padapter
, 0);
6340 btdm_1AntBtCoexistHandler(padapter
);
6344 static void BTDM_1AntFwC2hBtInfo8723A(struct rtw_adapter
*padapter
)
6346 struct hal_data_8723a
*pHalData
;
6347 struct bt_30info
*pBTInfo
;
6348 struct bt_mgnt
*pBtMgnt
;
6349 struct bt_coexist_8723a
*pBtCoex
;
6352 pHalData
= GET_HAL_DATA(padapter
);
6353 pBTInfo
= GET_BT_INFO(padapter
);
6354 pBtMgnt
= &pBTInfo
->BtMgnt
;
6355 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
6357 u1tmp
= pBtCoex
->c2hBtInfoOriginal
;
6358 /* sco BUSY bit is not used on voice over PCM platform */
6359 btState
= u1tmp
& 0xF;
6360 pBtCoex
->c2hBtProfile
= u1tmp
& 0xE0;
6362 /* default set bt to idle state. */
6363 pBtMgnt
->ExtConfig
.bBTBusy
= false;
6364 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_IDLE
;
6366 /* check BIT2 first ==> check if bt is under inquiry or page scan */
6367 if (btState
& BIT(2))
6368 pBtCoex
->bC2hBtInquiryPage
= true;
6370 pBtCoex
->bC2hBtInquiryPage
= false;
6373 if (!(btState
& BIT(0)))
6374 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_NO_CONNECTION
;
6377 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_CONNECT_IDLE
;
6378 else if (btState
== 0x9) {
6379 if (pBtCoex
->bC2hBtInquiryPage
== true)
6380 pBtCoex
->c2hBtInfo
=
6381 BT_INFO_STATE_ACL_INQ_OR_PAG
;
6383 pBtCoex
->c2hBtInfo
=
6384 BT_INFO_STATE_ACL_ONLY_BUSY
;
6385 pBtMgnt
->ExtConfig
.bBTBusy
= true;
6386 } else if (btState
== 0x3) {
6387 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_SCO_ONLY_BUSY
;
6388 pBtMgnt
->ExtConfig
.bBTBusy
= true;
6389 } else if (btState
== 0xb) {
6390 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_ACL_SCO_BUSY
;
6391 pBtMgnt
->ExtConfig
.bBTBusy
= true;
6393 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_MAX
;
6394 if (pBtMgnt
->ExtConfig
.bBTBusy
)
6395 pHalData
->bt_coexist
.CurrentState
&=
6396 ~BT_COEX_STATE_BT_IDLE
;
6399 if (BT_INFO_STATE_NO_CONNECTION
== pBtCoex
->c2hBtInfo
||
6400 BT_INFO_STATE_CONNECT_IDLE
== pBtCoex
->c2hBtInfo
) {
6401 if (pBtCoex
->bC2hBtInquiryPage
)
6402 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_INQ_OR_PAG
;
6405 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], %s(%d)\n",
6406 BtStateString
[pBtCoex
->c2hBtInfo
], pBtCoex
->c2hBtInfo
));
6408 if (pBtCoex
->c2hBtProfile
!= BT_INFO_HID
)
6409 pBtCoex
->c2hBtProfile
&= ~BT_INFO_HID
;
6412 void BTDM_1AntBtCoexist8723A(struct rtw_adapter
*padapter
)
6414 struct mlme_priv
*pmlmepriv
;
6415 struct hal_data_8723a
*pHalData
;
6416 unsigned long delta_time
;
6418 pmlmepriv
= &padapter
->mlmepriv
;
6419 pHalData
= GET_HAL_DATA(padapter
);
6421 if (check_fwstate(pmlmepriv
, WIFI_SITE_MONITOR
)) {
6422 /* already done in BTDM_1AntForScan() */
6423 RTPRINT(FBT
, BT_TRACE
,
6424 ("[BTCoex], wifi is under scan progress!!\n"));
6428 if (check_fwstate(pmlmepriv
, WIFI_UNDER_LINKING
)) {
6429 RTPRINT(FBT
, BT_TRACE
,
6430 ("[BTCoex], wifi is under link progress!!\n"));
6434 /* under DHCP(Special packet) */
6435 delta_time
= jiffies
- padapter
->pwrctrlpriv
.DelayLPSLastTimeStamp
;
6436 delta_time
= jiffies_to_msecs(delta_time
);
6437 if (delta_time
< 500) {
6438 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], wifi is under DHCP "
6439 "progress(%li ms)!!\n", delta_time
));
6443 BTDM_CheckWiFiState(padapter
);
6445 btdm_1AntBtCoexistHandler(padapter
);
6448 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87231Ant.c ===== */
6450 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.c ===== */
6452 /* local function start with btdm_ */
6453 static u8
btdm_ActionAlgorithm(struct rtw_adapter
*padapter
)
6455 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
6456 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
6457 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6458 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6459 u8 bScoExist
= false, bBtLinkExist
= false, bBtHsModeExist
= false;
6460 u8 algorithm
= BT_2ANT_COEX_ALGO_UNDEFINED
;
6462 if (pBtMgnt
->ExtConfig
.NumberOfHandle
)
6463 bBtLinkExist
= true;
6464 if (pBtMgnt
->ExtConfig
.NumberOfSCO
)
6466 if (BT_HsConnectionEstablished(padapter
))
6467 bBtHsModeExist
= true;
6469 /* here we get BT status first */
6471 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_IDLE
;
6473 if ((bScoExist
) || (bBtHsModeExist
) ||
6474 (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
))) {
6475 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO or HID or HS exists, set BT non-idle !!!\n"));
6476 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_NON_IDLE
;
6479 if ((pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) &&
6480 (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
))) {
6481 if (BTDM_BtTxRxCounterL(padapter
) < 100) {
6482 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP, low priority tx+rx < 100, set BT connected-idle!!!\n"));
6483 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
6485 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP, low priority tx+rx >= 100, set BT non-idle!!!\n"));
6486 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_NON_IDLE
;
6490 if ((pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) &&
6491 (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
))) {
6492 if (BTDM_BtTxRxCounterL(padapter
) < 600) {
6493 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN, low priority tx+rx < 600, set BT connected-idle!!!\n"));
6494 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
6496 if (pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
) {
6497 if ((pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
/
6498 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
) > 9) {
6499 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN, low priority rx/tx > 9, set BT connected-idle!!!\n"));
6500 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
6504 if (BT_2ANT_BT_STATUS_CONNECTED_IDLE
!= pBtdm8723
->btStatus
) {
6505 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN, set BT non-idle!!!\n"));
6506 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_NON_IDLE
;
6509 /* Pan+A2dp profile */
6510 if ((pBtMgnt
->ExtConfig
.NumberOfHandle
== 2) &&
6511 (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) &&
6512 (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
))) {
6513 if (BTDM_BtTxRxCounterL(padapter
) < 600) {
6514 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN+A2DP, low priority tx+rx < 600, set BT connected-idle!!!\n"));
6515 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
6517 if (pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
) {
6518 if ((pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
/
6519 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
) > 9) {
6520 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN+A2DP, low priority rx/tx > 9, set BT connected-idle!!!\n"));
6521 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
6525 if (BT_2ANT_BT_STATUS_CONNECTED_IDLE
!= pBtdm8723
->btStatus
) {
6526 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN+A2DP, set BT non-idle!!!\n"));
6527 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_NON_IDLE
;
6531 if (BT_2ANT_BT_STATUS_IDLE
!= pBtdm8723
->btStatus
)
6532 pBtMgnt
->ExtConfig
.bBTBusy
= true;
6534 pBtMgnt
->ExtConfig
.bBTBusy
= false;
6536 if (!bBtLinkExist
) {
6537 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], No profile exists!!!\n"));
6541 if (pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) {
6543 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO only\n"));
6544 algorithm
= BT_2ANT_COEX_ALGO_SCO
;
6546 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
)) {
6547 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID only\n"));
6548 algorithm
= BT_2ANT_COEX_ALGO_HID
;
6549 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6550 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP only\n"));
6551 algorithm
= BT_2ANT_COEX_ALGO_A2DP
;
6552 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) {
6553 if (bBtHsModeExist
) {
6554 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN(HS) only\n"));
6555 algorithm
= BT_2ANT_COEX_ALGO_PANHS
;
6557 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN(EDR) only\n"));
6558 algorithm
= BT_2ANT_COEX_ALGO_PANEDR
;
6561 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! NO matched profile for NumberOfHandle =%d \n",
6562 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6565 } else if (pBtMgnt
->ExtConfig
.NumberOfHandle
== 2) {
6567 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
)) {
6568 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + HID\n"));
6569 algorithm
= BT_2ANT_COEX_ALGO_HID
;
6570 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6571 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + A2DP\n"));
6572 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) {
6573 if (bBtHsModeExist
) {
6574 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + PAN(HS)\n"));
6575 algorithm
= BT_2ANT_COEX_ALGO_SCO
;
6577 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + PAN(EDR)\n"));
6578 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
6581 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO exists but why NO matched ACL profile for NumberOfHandle =%d\n",
6582 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6585 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6586 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6587 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP\n"));
6588 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
6589 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6590 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) {
6591 if (bBtHsModeExist
) {
6592 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(HS)\n"));
6593 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
6595 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(EDR)\n"));
6596 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
6598 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) &&
6599 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6600 if (bBtHsModeExist
) {
6601 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(HS)\n"));
6602 algorithm
= BT_2ANT_COEX_ALGO_A2DP
;
6604 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(EDR)\n"));
6605 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_A2DP
;
6608 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! NO matched profile for NumberOfHandle =%d\n",
6609 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6612 } else if (pBtMgnt
->ExtConfig
.NumberOfHandle
== 3) {
6614 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6615 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6616 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + HID + A2DP\n"));
6617 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6618 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) {
6619 if (bBtHsModeExist
) {
6620 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + HID + PAN(HS)\n"));
6621 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
6623 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + HID + PAN(EDR)\n"));
6624 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
6626 } else if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) &&
6627 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6628 if (bBtHsModeExist
) {
6629 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + A2DP + PAN(HS)\n"));
6630 algorithm
= BT_2ANT_COEX_ALGO_SCO
;
6632 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + A2DP + PAN(EDR)\n"));
6635 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO exists but why NO matched profile for NumberOfHandle =%d\n",
6636 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6639 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6640 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) &&
6641 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6642 if (bBtHsModeExist
) {
6643 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
6644 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP_PANHS
;
6646 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
6647 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
6650 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! NO matched profile for NumberOfHandle =%d\n",
6651 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6654 } else if (pBtMgnt
->ExtConfig
.NumberOfHandle
>= 3) {
6656 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
6657 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) &&
6658 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
6660 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n"));
6662 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(EDR)\n"));
6664 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO exists but why NO matched profile for NumberOfHandle =%d\n",
6665 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6668 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! NO matched profile for NumberOfHandle =%d\n",
6669 pBtMgnt
->ExtConfig
.NumberOfHandle
));
6675 static u8
btdm_NeedToDecBtPwr(struct rtw_adapter
*padapter
)
6677 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6680 if (BT_Operation(padapter
)) {
6681 if (pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
> 47) {
6682 RTPRINT(FBT
, BT_TRACE
, ("Need to decrease bt power for HS mode!!\n"));
6685 RTPRINT(FBT
, BT_TRACE
, ("NO Need to decrease bt power for HS mode!!\n"));
6688 if (BTDM_IsWifiConnectionExist(padapter
)) {
6689 RTPRINT(FBT
, BT_TRACE
, ("Need to decrease bt power for Wifi is connected!!\n"));
6697 btdm_SetCoexTable(struct rtw_adapter
*padapter
, u32 val0x6c0
,
6698 u32 val0x6c8
, u8 val0x6cc
)
6700 RTPRINT(FBT
, BT_TRACE
, ("set coex table, set 0x6c0 = 0x%x\n", val0x6c0
));
6701 rtl8723au_write32(padapter
, 0x6c0, val0x6c0
);
6703 RTPRINT(FBT
, BT_TRACE
, ("set coex table, set 0x6c8 = 0x%x\n", val0x6c8
));
6704 rtl8723au_write32(padapter
, 0x6c8, val0x6c8
);
6706 RTPRINT(FBT
, BT_TRACE
, ("set coex table, set 0x6cc = 0x%x\n", val0x6cc
));
6707 rtl8723au_write8(padapter
, 0x6cc, val0x6cc
);
6711 btdm_SetSwFullTimeDacSwing(struct rtw_adapter
*padapter
, u8 bSwDacSwingOn
,
6714 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6716 if (bSwDacSwingOn
) {
6717 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SwDacSwing = 0x%x\n", swDacSwingLvl
));
6718 PHY_SetBBReg(padapter
, 0x880, 0xff000000, swDacSwingLvl
);
6719 pHalData
->bt_coexist
.bSWCoexistAllOff
= false;
6721 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SwDacSwing Off!\n"));
6722 PHY_SetBBReg(padapter
, 0x880, 0xff000000, 0xc0);
6727 btdm_SetFwDacSwingLevel(struct rtw_adapter
*padapter
, u8 dacSwingLvl
)
6729 u8 H2C_Parameter
[1] = {0};
6731 H2C_Parameter
[0] = dacSwingLvl
;
6733 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl
));
6734 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], write 0x29 = 0x%x\n", H2C_Parameter
[0]));
6736 FillH2CCmd(padapter
, 0x29, 1, H2C_Parameter
);
6739 static void btdm_2AntDecBtPwr(struct rtw_adapter
*padapter
, u8 bDecBtPwr
)
6741 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6742 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6744 RTPRINT(FBT
, BT_TRACE
,
6745 ("[BTCoex], Dec BT power = %s\n",
6746 ((bDecBtPwr
) ? "ON" : "OFF")));
6747 pBtdm8723
->bCurDecBtPwr
= bDecBtPwr
;
6749 if (pBtdm8723
->bPreDecBtPwr
== pBtdm8723
->bCurDecBtPwr
)
6752 BTDM_SetFwDecBtPwr(padapter
, pBtdm8723
->bCurDecBtPwr
);
6754 pBtdm8723
->bPreDecBtPwr
= pBtdm8723
->bCurDecBtPwr
;
6758 btdm_2AntFwDacSwingLvl(struct rtw_adapter
*padapter
, u8 fwDacSwingLvl
)
6760 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6761 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6763 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], set FW Dac Swing level = %d\n", fwDacSwingLvl
));
6764 pBtdm8723
->curFwDacSwingLvl
= fwDacSwingLvl
;
6766 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n", */
6767 /*pBtdm8723->preFwDacSwingLvl, pBtdm8723->curFwDacSwingLvl)); */
6769 if (pBtdm8723
->preFwDacSwingLvl
== pBtdm8723
->curFwDacSwingLvl
)
6772 btdm_SetFwDacSwingLevel(padapter
, pBtdm8723
->curFwDacSwingLvl
);
6774 pBtdm8723
->preFwDacSwingLvl
= pBtdm8723
->curFwDacSwingLvl
;
6778 btdm_2AntRfShrink(struct rtw_adapter
*padapter
, u8 bRxRfShrinkOn
)
6780 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6781 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6783 RTPRINT(FBT
, BT_TRACE
,
6784 ("[BTCoex], turn Rx RF Shrink = %s\n",
6785 ((bRxRfShrinkOn
) ? "ON" : "OFF")));
6786 pBtdm8723
->bCurRfRxLpfShrink
= bRxRfShrinkOn
;
6788 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n", */
6789 /*pBtdm8723->bPreRfRxLpfShrink, pBtdm8723->bCurRfRxLpfShrink)); */
6791 if (pBtdm8723
->bPreRfRxLpfShrink
== pBtdm8723
->bCurRfRxLpfShrink
)
6794 BTDM_SetSwRfRxLpfCorner(padapter
, (u8
)pBtdm8723
->bCurRfRxLpfShrink
);
6796 pBtdm8723
->bPreRfRxLpfShrink
= pBtdm8723
->bCurRfRxLpfShrink
;
6800 btdm_2AntLowPenaltyRa(struct rtw_adapter
*padapter
, u8 bLowPenaltyRa
)
6802 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6803 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6805 RTPRINT(FBT
, BT_TRACE
,
6806 ("[BTCoex], turn LowPenaltyRA = %s\n",
6807 ((bLowPenaltyRa
) ? "ON" : "OFF")));
6808 pBtdm8723
->bCurLowPenaltyRa
= bLowPenaltyRa
;
6810 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n", */
6811 /*pBtdm8723->bPreLowPenaltyRa, pBtdm8723->bCurLowPenaltyRa)); */
6813 if (pBtdm8723
->bPreLowPenaltyRa
== pBtdm8723
->bCurLowPenaltyRa
)
6816 BTDM_SetSwPenaltyTxRateAdaptive(padapter
, (u8
)pBtdm8723
->bCurLowPenaltyRa
);
6818 pBtdm8723
->bPreLowPenaltyRa
= pBtdm8723
->bCurLowPenaltyRa
;
6822 btdm_2AntDacSwing(struct rtw_adapter
*padapter
,
6823 u8 bDacSwingOn
, u32 dacSwingLvl
)
6825 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6826 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6828 RTPRINT(FBT
, BT_TRACE
,
6829 ("[BTCoex], turn DacSwing =%s, dacSwingLvl = 0x%x\n",
6830 (bDacSwingOn
? "ON" : "OFF"), dacSwingLvl
));
6831 pBtdm8723
->bCurDacSwingOn
= bDacSwingOn
;
6832 pBtdm8723
->curDacSwingLvl
= dacSwingLvl
;
6834 if ((pBtdm8723
->bPreDacSwingOn
== pBtdm8723
->bCurDacSwingOn
) &&
6835 (pBtdm8723
->preDacSwingLvl
== pBtdm8723
->curDacSwingLvl
))
6839 btdm_SetSwFullTimeDacSwing(padapter
, bDacSwingOn
, dacSwingLvl
);
6841 pBtdm8723
->bPreDacSwingOn
= pBtdm8723
->bCurDacSwingOn
;
6842 pBtdm8723
->preDacSwingLvl
= pBtdm8723
->curDacSwingLvl
;
6845 static void btdm_2AntAdcBackOff(struct rtw_adapter
*padapter
, u8 bAdcBackOff
)
6847 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6848 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6850 RTPRINT(FBT
, BT_TRACE
,
6851 ("[BTCoex], turn AdcBackOff = %s\n",
6852 ((bAdcBackOff
) ? "ON" : "OFF")));
6853 pBtdm8723
->bCurAdcBackOff
= bAdcBackOff
;
6855 if (pBtdm8723
->bPreAdcBackOff
== pBtdm8723
->bCurAdcBackOff
)
6858 BTDM_BBBackOffLevel(padapter
, (u8
)pBtdm8723
->bCurAdcBackOff
);
6860 pBtdm8723
->bPreAdcBackOff
= pBtdm8723
->bCurAdcBackOff
;
6863 static void btdm_2AntAgcTable(struct rtw_adapter
*padapter
, u8 bAgcTableEn
)
6865 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6866 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6868 RTPRINT(FBT
, BT_TRACE
,
6869 ("[BTCoex], %s Agc Table\n", ((bAgcTableEn
) ? "Enable" : "Disable")));
6870 pBtdm8723
->bCurAgcTableEn
= bAgcTableEn
;
6872 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n", */
6873 /*pBtdm8723->bPreAgcTableEn, pBtdm8723->bCurAgcTableEn)); */
6875 if (pBtdm8723
->bPreAgcTableEn
== pBtdm8723
->bCurAgcTableEn
)
6878 BTDM_AGCTable(padapter
, (u8
)bAgcTableEn
);
6880 pBtdm8723
->bPreAgcTableEn
= pBtdm8723
->bCurAgcTableEn
;
6884 btdm_2AntCoexTable(struct rtw_adapter
*padapter
,
6885 u32 val0x6c0
, u32 val0x6c8
, u8 val0x6cc
)
6887 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6888 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6890 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], write Coex Table 0x6c0 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n",
6891 val0x6c0
, val0x6c8
, val0x6cc
));
6892 pBtdm8723
->curVal0x6c0
= val0x6c0
;
6893 pBtdm8723
->curVal0x6c8
= val0x6c8
;
6894 pBtdm8723
->curVal0x6cc
= val0x6cc
;
6896 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n", */
6897 /*pBtdm8723->preVal0x6c0, pBtdm8723->preVal0x6c8, pBtdm8723->preVal0x6cc)); */
6898 /* RTPRINT(FBT, BT_TRACE, ("[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n", */
6899 /*pBtdm8723->curVal0x6c0, pBtdm8723->curVal0x6c8, pBtdm8723->curVal0x6cc)); */
6901 if ((pBtdm8723
->preVal0x6c0
== pBtdm8723
->curVal0x6c0
) &&
6902 (pBtdm8723
->preVal0x6c8
== pBtdm8723
->curVal0x6c8
) &&
6903 (pBtdm8723
->preVal0x6cc
== pBtdm8723
->curVal0x6cc
))
6906 btdm_SetCoexTable(padapter
, val0x6c0
, val0x6c8
, val0x6cc
);
6908 pBtdm8723
->preVal0x6c0
= pBtdm8723
->curVal0x6c0
;
6909 pBtdm8723
->preVal0x6c8
= pBtdm8723
->curVal0x6c8
;
6910 pBtdm8723
->preVal0x6cc
= pBtdm8723
->curVal0x6cc
;
6913 static void btdm_2AntIgnoreWlanAct(struct rtw_adapter
*padapter
, u8 bEnable
)
6915 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6916 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6918 RTPRINT(FBT
, BT_TRACE
,
6919 ("[BTCoex], turn Ignore WlanAct %s\n", (bEnable
? "ON" : "OFF")));
6920 pBtdm8723
->bCurIgnoreWlanAct
= bEnable
;
6923 if (pBtdm8723
->bPreIgnoreWlanAct
== pBtdm8723
->bCurIgnoreWlanAct
)
6926 btdm_SetFwIgnoreWlanAct(padapter
, bEnable
);
6927 pBtdm8723
->bPreIgnoreWlanAct
= pBtdm8723
->bCurIgnoreWlanAct
;
6931 btdm_2AntSetFw3a(struct rtw_adapter
*padapter
, u8 byte1
, u8 byte2
,
6932 u8 byte3
, u8 byte4
, u8 byte5
)
6934 u8 H2C_Parameter
[5] = {0};
6936 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6938 /* byte1[1:0] != 0 means enable pstdma */
6939 /* for 2Ant bt coexist, if byte1 != 0 means enable pstdma */
6941 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
6942 H2C_Parameter
[0] = byte1
;
6943 H2C_Parameter
[1] = byte2
;
6944 H2C_Parameter
[2] = byte3
;
6945 H2C_Parameter
[3] = byte4
;
6946 H2C_Parameter
[4] = byte5
;
6948 pHalData
->bt_coexist
.fw3aVal
[0] = byte1
;
6949 pHalData
->bt_coexist
.fw3aVal
[1] = byte2
;
6950 pHalData
->bt_coexist
.fw3aVal
[2] = byte3
;
6951 pHalData
->bt_coexist
.fw3aVal
[3] = byte4
;
6952 pHalData
->bt_coexist
.fw3aVal
[4] = byte5
;
6954 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], FW write 0x3a(5bytes) = 0x%x%08x\n",
6956 H2C_Parameter
[1]<<24|H2C_Parameter
[2]<<16|H2C_Parameter
[3]<<8|H2C_Parameter
[4]));
6958 FillH2CCmd(padapter
, 0x3a, 5, H2C_Parameter
);
6961 static void btdm_2AntPsTdma(struct rtw_adapter
*padapter
, u8 bTurnOn
, u8 type
)
6963 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
6964 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
6966 u8 bTurnOnByCnt
= false;
6967 u8 psTdmaTypeByCnt
= 0;
6969 btTxRxCnt
= BTDM_BtTxRxCounterH(padapter
)+BTDM_BtTxRxCounterL(padapter
);
6970 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT TxRx Counters = %d\n", btTxRxCnt
));
6971 if (btTxRxCnt
> 3000) {
6972 bTurnOnByCnt
= true;
6973 psTdmaTypeByCnt
= 8;
6975 RTPRINT(FBT
, BT_TRACE
,
6976 ("[BTCoex], For BTTxRxCounters, turn %s PS TDMA, type =%d\n",
6977 (bTurnOnByCnt
? "ON" : "OFF"), psTdmaTypeByCnt
));
6978 pBtdm8723
->bCurPsTdmaOn
= bTurnOnByCnt
;
6979 pBtdm8723
->curPsTdma
= psTdmaTypeByCnt
;
6981 RTPRINT(FBT
, BT_TRACE
,
6982 ("[BTCoex], turn %s PS TDMA, type =%d\n",
6983 (bTurnOn
? "ON" : "OFF"), type
));
6984 pBtdm8723
->bCurPsTdmaOn
= bTurnOn
;
6985 pBtdm8723
->curPsTdma
= type
;
6988 if ((pBtdm8723
->bPrePsTdmaOn
== pBtdm8723
->bCurPsTdmaOn
) &&
6989 (pBtdm8723
->prePsTdma
== pBtdm8723
->curPsTdma
))
6996 btdm_2AntSetFw3a(padapter
, 0xe3, 0x1a, 0x1a, 0xa1, 0x98);
6999 btdm_2AntSetFw3a(padapter
, 0xe3, 0x12, 0x12, 0xa1, 0x98);
7002 btdm_2AntSetFw3a(padapter
, 0xe3, 0xa, 0xa, 0xa1, 0x98);
7005 btdm_2AntSetFw3a(padapter
, 0xa3, 0x5, 0x5, 0xa1, 0x80);
7008 btdm_2AntSetFw3a(padapter
, 0xe3, 0x1a, 0x1a, 0x20, 0x98);
7011 btdm_2AntSetFw3a(padapter
, 0xe3, 0x12, 0x12, 0x20, 0x98);
7014 btdm_2AntSetFw3a(padapter
, 0xe3, 0xa, 0xa, 0x20, 0x98);
7017 btdm_2AntSetFw3a(padapter
, 0xa3, 0x5, 0x5, 0x20, 0x80);
7020 btdm_2AntSetFw3a(padapter
, 0xe3, 0x1a, 0x1a, 0xa1, 0x98);
7023 btdm_2AntSetFw3a(padapter
, 0xe3, 0x12, 0x12, 0xa1, 0x98);
7026 btdm_2AntSetFw3a(padapter
, 0xe3, 0xa, 0xa, 0xa1, 0x98);
7029 btdm_2AntSetFw3a(padapter
, 0xe3, 0x5, 0x5, 0xa1, 0x98);
7032 btdm_2AntSetFw3a(padapter
, 0xe3, 0x1a, 0x1a, 0x20, 0x98);
7035 btdm_2AntSetFw3a(padapter
, 0xe3, 0x12, 0x12, 0x20, 0x98);
7038 btdm_2AntSetFw3a(padapter
, 0xe3, 0xa, 0xa, 0x20, 0x98);
7041 btdm_2AntSetFw3a(padapter
, 0xe3, 0x5, 0x5, 0x20, 0x98);
7044 btdm_2AntSetFw3a(padapter
, 0xa3, 0x2f, 0x2f, 0x20, 0x80);
7047 btdm_2AntSetFw3a(padapter
, 0xe3, 0x5, 0x5, 0xa1, 0x98);
7050 btdm_2AntSetFw3a(padapter
, 0xe3, 0x25, 0x25, 0xa1, 0x98);
7053 btdm_2AntSetFw3a(padapter
, 0xe3, 0x25, 0x25, 0x20, 0x98);
7057 /* disable PS tdma */
7060 btdm_2AntSetFw3a(padapter
, 0x0, 0x0, 0x0, 0x8, 0x0);
7063 btdm_2AntSetFw3a(padapter
, 0x0, 0x0, 0x0, 0x0, 0x0);
7066 btdm_2AntSetFw3a(padapter
, 0x0, 0x0, 0x0, 0x8, 0x0);
7071 /* update pre state */
7072 pBtdm8723
->bPrePsTdmaOn
= pBtdm8723
->bCurPsTdmaOn
;
7073 pBtdm8723
->prePsTdma
= pBtdm8723
->curPsTdma
;
7076 static void btdm_2AntBtInquiryPage(struct rtw_adapter
*padapter
)
7078 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7079 btdm_2AntIgnoreWlanAct(padapter
, false);
7080 btdm_2AntPsTdma(padapter
, true, 8);
7083 static u8
btdm_HoldForBtInqPage(struct rtw_adapter
*padapter
)
7085 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
7086 u32 curTime
= jiffies
;
7088 if (pHalData
->bt_coexist
.halCoex8723
.bC2hBtInquiryPage
) {
7089 /* bt inquiry or page is started. */
7090 if (pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
== 0) {
7091 pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
= curTime
;
7092 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT Inquiry/page is started at time : 0x%lx \n",
7093 pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
));
7096 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT Inquiry/page started time : 0x%lx, curTime : 0x%x \n",
7097 pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
, curTime
));
7099 if (pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
) {
7100 if (((curTime
- pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
)/1000000) >= 10) {
7101 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], BT Inquiry/page >= 10sec!!!"));
7102 pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
= 0;
7106 if (pHalData
->bt_coexist
.halCoex8723
.btInqPageStartTime
) {
7107 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7108 btdm_2AntIgnoreWlanAct(padapter
, false);
7109 btdm_2AntPsTdma(padapter
, true, 8);
7116 static u8
btdm_Is2Ant8723ACommonAction(struct rtw_adapter
*padapter
)
7118 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
7119 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
7122 RTPRINT(FBT
, BT_TRACE
, ("%s :BTDM_IsWifiConnectionExist =%x check_fwstate =%x pmlmepriv->fw_state = 0x%x\n", __func__
, BTDM_IsWifiConnectionExist(padapter
), check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
)), padapter
->mlmepriv
.fw_state
));
7124 if ((!BTDM_IsWifiConnectionExist(padapter
)) &&
7125 (!check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
))) &&
7126 (BT_2ANT_BT_STATUS_IDLE
== pBtdm8723
->btStatus
)) {
7127 RTPRINT(FBT
, BT_TRACE
, ("Wifi idle + Bt idle!!\n"));
7129 btdm_2AntLowPenaltyRa(padapter
, false);
7130 btdm_2AntRfShrink(padapter
, false);
7131 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7133 btdm_2AntIgnoreWlanAct(padapter
, false);
7134 btdm_2AntPsTdma(padapter
, false, 0);
7135 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7136 btdm_2AntDecBtPwr(padapter
, false);
7138 btdm_2AntAgcTable(padapter
, false);
7139 btdm_2AntAdcBackOff(padapter
, false);
7140 btdm_2AntDacSwing(padapter
, false, 0xc0);
7143 } else if (((BTDM_IsWifiConnectionExist(padapter
)) ||
7144 (check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
)))) &&
7145 (BT_2ANT_BT_STATUS_IDLE
== pBtdm8723
->btStatus
)) {
7146 RTPRINT(FBT
, BT_TRACE
, ("Wifi non-idle + BT idle!!\n"));
7148 btdm_2AntLowPenaltyRa(padapter
, true);
7149 btdm_2AntRfShrink(padapter
, false);
7150 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7152 btdm_2AntIgnoreWlanAct(padapter
, false);
7153 btdm_2AntPsTdma(padapter
, false, 0);
7154 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7155 btdm_2AntDecBtPwr(padapter
, true);
7157 btdm_2AntAgcTable(padapter
, false);
7158 btdm_2AntAdcBackOff(padapter
, false);
7159 btdm_2AntDacSwing(padapter
, false, 0xc0);
7162 } else if ((!BTDM_IsWifiConnectionExist(padapter
)) &&
7163 (!check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
))) &&
7164 (BT_2ANT_BT_STATUS_CONNECTED_IDLE
== pBtdm8723
->btStatus
)) {
7165 RTPRINT(FBT
, BT_TRACE
, ("Wifi idle + Bt connected idle!!\n"));
7167 btdm_2AntLowPenaltyRa(padapter
, true);
7168 btdm_2AntRfShrink(padapter
, true);
7169 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7171 btdm_2AntIgnoreWlanAct(padapter
, false);
7172 btdm_2AntPsTdma(padapter
, false, 0);
7173 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7174 btdm_2AntDecBtPwr(padapter
, false);
7176 btdm_2AntAgcTable(padapter
, false);
7177 btdm_2AntAdcBackOff(padapter
, false);
7178 btdm_2AntDacSwing(padapter
, false, 0xc0);
7181 } else if (((BTDM_IsWifiConnectionExist(padapter
)) ||
7182 (check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
)))) &&
7183 (BT_2ANT_BT_STATUS_CONNECTED_IDLE
== pBtdm8723
->btStatus
)) {
7184 RTPRINT(FBT
, BT_TRACE
, ("Wifi non-idle + Bt connected idle!!\n"));
7186 btdm_2AntLowPenaltyRa(padapter
, true);
7187 btdm_2AntRfShrink(padapter
, true);
7188 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7190 btdm_2AntIgnoreWlanAct(padapter
, false);
7191 btdm_2AntPsTdma(padapter
, false, 0);
7192 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7193 btdm_2AntDecBtPwr(padapter
, true);
7195 btdm_2AntAgcTable(padapter
, false);
7196 btdm_2AntAdcBackOff(padapter
, false);
7197 btdm_2AntDacSwing(padapter
, false, 0xc0);
7200 } else if ((!BTDM_IsWifiConnectionExist(padapter
)) &&
7201 (!check_fwstate(&padapter
->mlmepriv
, (_FW_UNDER_SURVEY
|_FW_UNDER_LINKING
))) &&
7202 (BT_2ANT_BT_STATUS_NON_IDLE
== pBtdm8723
->btStatus
)) {
7203 RTPRINT(FBT
, BT_TRACE
, ("Wifi idle + BT non-idle!!\n"));
7205 btdm_2AntLowPenaltyRa(padapter
, true);
7206 btdm_2AntRfShrink(padapter
, true);
7207 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7209 btdm_2AntIgnoreWlanAct(padapter
, false);
7210 btdm_2AntPsTdma(padapter
, false, 0);
7211 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7212 btdm_2AntDecBtPwr(padapter
, false);
7214 btdm_2AntAgcTable(padapter
, false);
7215 btdm_2AntAdcBackOff(padapter
, false);
7216 btdm_2AntDacSwing(padapter
, false, 0xc0);
7220 RTPRINT(FBT
, BT_TRACE
, ("Wifi non-idle + BT non-idle!!\n"));
7221 btdm_2AntLowPenaltyRa(padapter
, true);
7222 btdm_2AntRfShrink(padapter
, true);
7223 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
7224 btdm_2AntIgnoreWlanAct(padapter
, false);
7225 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
7233 btdm_2AntTdmaDurationAdjust(struct rtw_adapter
*padapter
, u8 bScoHid
,
7234 u8 bTxPause
, u8 maxInterval
)
7236 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
7237 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
7238 static s32 up
, dn
, m
, n
, WaitCount
;
7239 s32 result
; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */
7242 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TdmaDurationAdjust()\n"));
7244 if (pBtdm8723
->bResetTdmaAdjust
) {
7245 pBtdm8723
->bResetTdmaAdjust
= false;
7246 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], first run TdmaDurationAdjust()!!\n"));
7249 btdm_2AntPsTdma(padapter
, true, 15);
7250 pBtdm8723
->psTdmaDuAdjType
= 15;
7252 btdm_2AntPsTdma(padapter
, true, 11);
7253 pBtdm8723
->psTdmaDuAdjType
= 11;
7257 btdm_2AntPsTdma(padapter
, true, 7);
7258 pBtdm8723
->psTdmaDuAdjType
= 7;
7260 btdm_2AntPsTdma(padapter
, true, 3);
7261 pBtdm8723
->psTdmaDuAdjType
= 3;
7271 /* accquire the BT TRx retry count from BT_Info byte2 */
7272 retryCount
= pHalData
->bt_coexist
.halCoex8723
.btRetryCnt
;
7273 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], retryCount = %d\n", retryCount
));
7277 if (retryCount
== 0) { /* no retry in the last 2-second duration */
7284 if (up
>= n
) { /* if ³sÄò n Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration */
7290 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Increase wifi duration!!\n"));
7292 } else if (retryCount
<= 3) { /* <= 3 retry in the last 2-second duration */
7299 if (dn
== 2) { /* if ³sÄò 2 Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration */
7301 m
++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
7305 if (m
>= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
7313 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n"));
7315 } else { /* retry count > 3, ¥un1¦¸ retry count > 3, «h½Õ¯¶WiFi duration */
7317 m
++; /* ÁקK¤@ª½¦b¨âÓlevel¤¤¨Ó¦^ */
7321 if (m
>= 20) /* m ³Ì¤jÈ = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. */
7328 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n"));
7331 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], max Interval = %d\n", maxInterval
));
7332 if (maxInterval
== 1) {
7334 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 1\n"));
7335 if (pBtdm8723
->curPsTdma
== 1) {
7336 btdm_2AntPsTdma(padapter
, true, 5);
7337 pBtdm8723
->psTdmaDuAdjType
= 5;
7338 } else if (pBtdm8723
->curPsTdma
== 2) {
7339 btdm_2AntPsTdma(padapter
, true, 6);
7340 pBtdm8723
->psTdmaDuAdjType
= 6;
7341 } else if (pBtdm8723
->curPsTdma
== 3) {
7342 btdm_2AntPsTdma(padapter
, true, 7);
7343 pBtdm8723
->psTdmaDuAdjType
= 7;
7344 } else if (pBtdm8723
->curPsTdma
== 4) {
7345 btdm_2AntPsTdma(padapter
, true, 8);
7346 pBtdm8723
->psTdmaDuAdjType
= 8;
7348 if (pBtdm8723
->curPsTdma
== 9) {
7349 btdm_2AntPsTdma(padapter
, true, 13);
7350 pBtdm8723
->psTdmaDuAdjType
= 13;
7351 } else if (pBtdm8723
->curPsTdma
== 10) {
7352 btdm_2AntPsTdma(padapter
, true, 14);
7353 pBtdm8723
->psTdmaDuAdjType
= 14;
7354 } else if (pBtdm8723
->curPsTdma
== 11) {
7355 btdm_2AntPsTdma(padapter
, true, 15);
7356 pBtdm8723
->psTdmaDuAdjType
= 15;
7357 } else if (pBtdm8723
->curPsTdma
== 12) {
7358 btdm_2AntPsTdma(padapter
, true, 16);
7359 pBtdm8723
->psTdmaDuAdjType
= 16;
7363 if (pBtdm8723
->curPsTdma
== 5) {
7364 btdm_2AntPsTdma(padapter
, true, 6);
7365 pBtdm8723
->psTdmaDuAdjType
= 6;
7366 } else if (pBtdm8723
->curPsTdma
== 6) {
7367 btdm_2AntPsTdma(padapter
, true, 7);
7368 pBtdm8723
->psTdmaDuAdjType
= 7;
7369 } else if (pBtdm8723
->curPsTdma
== 7) {
7370 btdm_2AntPsTdma(padapter
, true, 8);
7371 pBtdm8723
->psTdmaDuAdjType
= 8;
7372 } else if (pBtdm8723
->curPsTdma
== 13) {
7373 btdm_2AntPsTdma(padapter
, true, 14);
7374 pBtdm8723
->psTdmaDuAdjType
= 14;
7375 } else if (pBtdm8723
->curPsTdma
== 14) {
7376 btdm_2AntPsTdma(padapter
, true, 15);
7377 pBtdm8723
->psTdmaDuAdjType
= 15;
7378 } else if (pBtdm8723
->curPsTdma
== 15) {
7379 btdm_2AntPsTdma(padapter
, true, 16);
7380 pBtdm8723
->psTdmaDuAdjType
= 16;
7382 } else if (result
== 1) {
7383 if (pBtdm8723
->curPsTdma
== 8) {
7384 btdm_2AntPsTdma(padapter
, true, 7);
7385 pBtdm8723
->psTdmaDuAdjType
= 7;
7386 } else if (pBtdm8723
->curPsTdma
== 7) {
7387 btdm_2AntPsTdma(padapter
, true, 6);
7388 pBtdm8723
->psTdmaDuAdjType
= 6;
7389 } else if (pBtdm8723
->curPsTdma
== 6) {
7390 btdm_2AntPsTdma(padapter
, true, 5);
7391 pBtdm8723
->psTdmaDuAdjType
= 5;
7392 } else if (pBtdm8723
->curPsTdma
== 16) {
7393 btdm_2AntPsTdma(padapter
, true, 15);
7394 pBtdm8723
->psTdmaDuAdjType
= 15;
7395 } else if (pBtdm8723
->curPsTdma
== 15) {
7396 btdm_2AntPsTdma(padapter
, true, 14);
7397 pBtdm8723
->psTdmaDuAdjType
= 14;
7398 } else if (pBtdm8723
->curPsTdma
== 14) {
7399 btdm_2AntPsTdma(padapter
, true, 13);
7400 pBtdm8723
->psTdmaDuAdjType
= 13;
7404 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 0\n"));
7405 if (pBtdm8723
->curPsTdma
== 5) {
7406 btdm_2AntPsTdma(padapter
, true, 1);
7407 pBtdm8723
->psTdmaDuAdjType
= 1;
7408 } else if (pBtdm8723
->curPsTdma
== 6) {
7409 btdm_2AntPsTdma(padapter
, true, 2);
7410 pBtdm8723
->psTdmaDuAdjType
= 2;
7411 } else if (pBtdm8723
->curPsTdma
== 7) {
7412 btdm_2AntPsTdma(padapter
, true, 3);
7413 pBtdm8723
->psTdmaDuAdjType
= 3;
7414 } else if (pBtdm8723
->curPsTdma
== 8) {
7415 btdm_2AntPsTdma(padapter
, true, 4);
7416 pBtdm8723
->psTdmaDuAdjType
= 4;
7418 if (pBtdm8723
->curPsTdma
== 13) {
7419 btdm_2AntPsTdma(padapter
, true, 9);
7420 pBtdm8723
->psTdmaDuAdjType
= 9;
7421 } else if (pBtdm8723
->curPsTdma
== 14) {
7422 btdm_2AntPsTdma(padapter
, true, 10);
7423 pBtdm8723
->psTdmaDuAdjType
= 10;
7424 } else if (pBtdm8723
->curPsTdma
== 15) {
7425 btdm_2AntPsTdma(padapter
, true, 11);
7426 pBtdm8723
->psTdmaDuAdjType
= 11;
7427 } else if (pBtdm8723
->curPsTdma
== 16) {
7428 btdm_2AntPsTdma(padapter
, true, 12);
7429 pBtdm8723
->psTdmaDuAdjType
= 12;
7433 if (pBtdm8723
->curPsTdma
== 1) {
7434 btdm_2AntPsTdma(padapter
, true, 2);
7435 pBtdm8723
->psTdmaDuAdjType
= 2;
7436 } else if (pBtdm8723
->curPsTdma
== 2) {
7437 btdm_2AntPsTdma(padapter
, true, 3);
7438 pBtdm8723
->psTdmaDuAdjType
= 3;
7439 } else if (pBtdm8723
->curPsTdma
== 3) {
7440 btdm_2AntPsTdma(padapter
, true, 4);
7441 pBtdm8723
->psTdmaDuAdjType
= 4;
7442 } else if (pBtdm8723
->curPsTdma
== 9) {
7443 btdm_2AntPsTdma(padapter
, true, 10);
7444 pBtdm8723
->psTdmaDuAdjType
= 10;
7445 } else if (pBtdm8723
->curPsTdma
== 10) {
7446 btdm_2AntPsTdma(padapter
, true, 11);
7447 pBtdm8723
->psTdmaDuAdjType
= 11;
7448 } else if (pBtdm8723
->curPsTdma
== 11) {
7449 btdm_2AntPsTdma(padapter
, true, 12);
7450 pBtdm8723
->psTdmaDuAdjType
= 12;
7452 } else if (result
== 1) {
7453 if (pBtdm8723
->curPsTdma
== 4) {
7454 btdm_2AntPsTdma(padapter
, true, 3);
7455 pBtdm8723
->psTdmaDuAdjType
= 3;
7456 } else if (pBtdm8723
->curPsTdma
== 3) {
7457 btdm_2AntPsTdma(padapter
, true, 2);
7458 pBtdm8723
->psTdmaDuAdjType
= 2;
7459 } else if (pBtdm8723
->curPsTdma
== 2) {
7460 btdm_2AntPsTdma(padapter
, true, 1);
7461 pBtdm8723
->psTdmaDuAdjType
= 1;
7462 } else if (pBtdm8723
->curPsTdma
== 12) {
7463 btdm_2AntPsTdma(padapter
, true, 11);
7464 pBtdm8723
->psTdmaDuAdjType
= 11;
7465 } else if (pBtdm8723
->curPsTdma
== 11) {
7466 btdm_2AntPsTdma(padapter
, true, 10);
7467 pBtdm8723
->psTdmaDuAdjType
= 10;
7468 } else if (pBtdm8723
->curPsTdma
== 10) {
7469 btdm_2AntPsTdma(padapter
, true, 9);
7470 pBtdm8723
->psTdmaDuAdjType
= 9;
7474 } else if (maxInterval
== 2) {
7476 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 1\n"));
7477 if (pBtdm8723
->curPsTdma
== 1) {
7478 btdm_2AntPsTdma(padapter
, true, 6);
7479 pBtdm8723
->psTdmaDuAdjType
= 6;
7480 } else if (pBtdm8723
->curPsTdma
== 2) {
7481 btdm_2AntPsTdma(padapter
, true, 6);
7482 pBtdm8723
->psTdmaDuAdjType
= 6;
7483 } else if (pBtdm8723
->curPsTdma
== 3) {
7484 btdm_2AntPsTdma(padapter
, true, 7);
7485 pBtdm8723
->psTdmaDuAdjType
= 7;
7486 } else if (pBtdm8723
->curPsTdma
== 4) {
7487 btdm_2AntPsTdma(padapter
, true, 8);
7488 pBtdm8723
->psTdmaDuAdjType
= 8;
7490 if (pBtdm8723
->curPsTdma
== 9) {
7491 btdm_2AntPsTdma(padapter
, true, 14);
7492 pBtdm8723
->psTdmaDuAdjType
= 14;
7493 } else if (pBtdm8723
->curPsTdma
== 10) {
7494 btdm_2AntPsTdma(padapter
, true, 14);
7495 pBtdm8723
->psTdmaDuAdjType
= 14;
7496 } else if (pBtdm8723
->curPsTdma
== 11) {
7497 btdm_2AntPsTdma(padapter
, true, 15);
7498 pBtdm8723
->psTdmaDuAdjType
= 15;
7499 } else if (pBtdm8723
->curPsTdma
== 12) {
7500 btdm_2AntPsTdma(padapter
, true, 16);
7501 pBtdm8723
->psTdmaDuAdjType
= 16;
7504 if (pBtdm8723
->curPsTdma
== 5) {
7505 btdm_2AntPsTdma(padapter
, true, 6);
7506 pBtdm8723
->psTdmaDuAdjType
= 6;
7507 } else if (pBtdm8723
->curPsTdma
== 6) {
7508 btdm_2AntPsTdma(padapter
, true, 7);
7509 pBtdm8723
->psTdmaDuAdjType
= 7;
7510 } else if (pBtdm8723
->curPsTdma
== 7) {
7511 btdm_2AntPsTdma(padapter
, true, 8);
7512 pBtdm8723
->psTdmaDuAdjType
= 8;
7513 } else if (pBtdm8723
->curPsTdma
== 13) {
7514 btdm_2AntPsTdma(padapter
, true, 14);
7515 pBtdm8723
->psTdmaDuAdjType
= 14;
7516 } else if (pBtdm8723
->curPsTdma
== 14) {
7517 btdm_2AntPsTdma(padapter
, true, 15);
7518 pBtdm8723
->psTdmaDuAdjType
= 15;
7519 } else if (pBtdm8723
->curPsTdma
== 15) {
7520 btdm_2AntPsTdma(padapter
, true, 16);
7521 pBtdm8723
->psTdmaDuAdjType
= 16;
7523 } else if (result
== 1) {
7524 if (pBtdm8723
->curPsTdma
== 8) {
7525 btdm_2AntPsTdma(padapter
, true, 7);
7526 pBtdm8723
->psTdmaDuAdjType
= 7;
7527 } else if (pBtdm8723
->curPsTdma
== 7) {
7528 btdm_2AntPsTdma(padapter
, true, 6);
7529 pBtdm8723
->psTdmaDuAdjType
= 6;
7530 } else if (pBtdm8723
->curPsTdma
== 6) {
7531 btdm_2AntPsTdma(padapter
, true, 6);
7532 pBtdm8723
->psTdmaDuAdjType
= 6;
7533 } else if (pBtdm8723
->curPsTdma
== 16) {
7534 btdm_2AntPsTdma(padapter
, true, 15);
7535 pBtdm8723
->psTdmaDuAdjType
= 15;
7536 } else if (pBtdm8723
->curPsTdma
== 15) {
7537 btdm_2AntPsTdma(padapter
, true, 14);
7538 pBtdm8723
->psTdmaDuAdjType
= 14;
7539 } else if (pBtdm8723
->curPsTdma
== 14) {
7540 btdm_2AntPsTdma(padapter
, true, 14);
7541 pBtdm8723
->psTdmaDuAdjType
= 14;
7545 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 0\n"));
7546 if (pBtdm8723
->curPsTdma
== 5) {
7547 btdm_2AntPsTdma(padapter
, true, 2);
7548 pBtdm8723
->psTdmaDuAdjType
= 2;
7549 } else if (pBtdm8723
->curPsTdma
== 6) {
7550 btdm_2AntPsTdma(padapter
, true, 2);
7551 pBtdm8723
->psTdmaDuAdjType
= 2;
7552 } else if (pBtdm8723
->curPsTdma
== 7) {
7553 btdm_2AntPsTdma(padapter
, true, 3);
7554 pBtdm8723
->psTdmaDuAdjType
= 3;
7555 } else if (pBtdm8723
->curPsTdma
== 8) {
7556 btdm_2AntPsTdma(padapter
, true, 4);
7557 pBtdm8723
->psTdmaDuAdjType
= 4;
7559 if (pBtdm8723
->curPsTdma
== 13) {
7560 btdm_2AntPsTdma(padapter
, true, 10);
7561 pBtdm8723
->psTdmaDuAdjType
= 10;
7562 } else if (pBtdm8723
->curPsTdma
== 14) {
7563 btdm_2AntPsTdma(padapter
, true, 10);
7564 pBtdm8723
->psTdmaDuAdjType
= 10;
7565 } else if (pBtdm8723
->curPsTdma
== 15) {
7566 btdm_2AntPsTdma(padapter
, true, 11);
7567 pBtdm8723
->psTdmaDuAdjType
= 11;
7568 } else if (pBtdm8723
->curPsTdma
== 16) {
7569 btdm_2AntPsTdma(padapter
, true, 12);
7570 pBtdm8723
->psTdmaDuAdjType
= 12;
7573 if (pBtdm8723
->curPsTdma
== 1) {
7574 btdm_2AntPsTdma(padapter
, true, 2);
7575 pBtdm8723
->psTdmaDuAdjType
= 2;
7576 } else if (pBtdm8723
->curPsTdma
== 2) {
7577 btdm_2AntPsTdma(padapter
, true, 3);
7578 pBtdm8723
->psTdmaDuAdjType
= 3;
7579 } else if (pBtdm8723
->curPsTdma
== 3) {
7580 btdm_2AntPsTdma(padapter
, true, 4);
7581 pBtdm8723
->psTdmaDuAdjType
= 4;
7582 } else if (pBtdm8723
->curPsTdma
== 9) {
7583 btdm_2AntPsTdma(padapter
, true, 10);
7584 pBtdm8723
->psTdmaDuAdjType
= 10;
7585 } else if (pBtdm8723
->curPsTdma
== 10) {
7586 btdm_2AntPsTdma(padapter
, true, 11);
7587 pBtdm8723
->psTdmaDuAdjType
= 11;
7588 } else if (pBtdm8723
->curPsTdma
== 11) {
7589 btdm_2AntPsTdma(padapter
, true, 12);
7590 pBtdm8723
->psTdmaDuAdjType
= 12;
7592 } else if (result
== 1) {
7593 if (pBtdm8723
->curPsTdma
== 4) {
7594 btdm_2AntPsTdma(padapter
, true, 3);
7595 pBtdm8723
->psTdmaDuAdjType
= 3;
7596 } else if (pBtdm8723
->curPsTdma
== 3) {
7597 btdm_2AntPsTdma(padapter
, true, 2);
7598 pBtdm8723
->psTdmaDuAdjType
= 2;
7599 } else if (pBtdm8723
->curPsTdma
== 2) {
7600 btdm_2AntPsTdma(padapter
, true, 2);
7601 pBtdm8723
->psTdmaDuAdjType
= 2;
7602 } else if (pBtdm8723
->curPsTdma
== 12) {
7603 btdm_2AntPsTdma(padapter
, true, 11);
7604 pBtdm8723
->psTdmaDuAdjType
= 11;
7605 } else if (pBtdm8723
->curPsTdma
== 11) {
7606 btdm_2AntPsTdma(padapter
, true, 10);
7607 pBtdm8723
->psTdmaDuAdjType
= 10;
7608 } else if (pBtdm8723
->curPsTdma
== 10) {
7609 btdm_2AntPsTdma(padapter
, true, 10);
7610 pBtdm8723
->psTdmaDuAdjType
= 10;
7614 } else if (maxInterval
== 3) {
7616 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 1\n"));
7617 if (pBtdm8723
->curPsTdma
== 1) {
7618 btdm_2AntPsTdma(padapter
, true, 7);
7619 pBtdm8723
->psTdmaDuAdjType
= 7;
7620 } else if (pBtdm8723
->curPsTdma
== 2) {
7621 btdm_2AntPsTdma(padapter
, true, 7);
7622 pBtdm8723
->psTdmaDuAdjType
= 7;
7623 } else if (pBtdm8723
->curPsTdma
== 3) {
7624 btdm_2AntPsTdma(padapter
, true, 7);
7625 pBtdm8723
->psTdmaDuAdjType
= 7;
7626 } else if (pBtdm8723
->curPsTdma
== 4) {
7627 btdm_2AntPsTdma(padapter
, true, 8);
7628 pBtdm8723
->psTdmaDuAdjType
= 8;
7630 if (pBtdm8723
->curPsTdma
== 9) {
7631 btdm_2AntPsTdma(padapter
, true, 15);
7632 pBtdm8723
->psTdmaDuAdjType
= 15;
7633 } else if (pBtdm8723
->curPsTdma
== 10) {
7634 btdm_2AntPsTdma(padapter
, true, 15);
7635 pBtdm8723
->psTdmaDuAdjType
= 15;
7636 } else if (pBtdm8723
->curPsTdma
== 11) {
7637 btdm_2AntPsTdma(padapter
, true, 15);
7638 pBtdm8723
->psTdmaDuAdjType
= 15;
7639 } else if (pBtdm8723
->curPsTdma
== 12) {
7640 btdm_2AntPsTdma(padapter
, true, 16);
7641 pBtdm8723
->psTdmaDuAdjType
= 16;
7644 if (pBtdm8723
->curPsTdma
== 5) {
7645 btdm_2AntPsTdma(padapter
, true, 7);
7646 pBtdm8723
->psTdmaDuAdjType
= 7;
7647 } else if (pBtdm8723
->curPsTdma
== 6) {
7648 btdm_2AntPsTdma(padapter
, true, 7);
7649 pBtdm8723
->psTdmaDuAdjType
= 7;
7650 } else if (pBtdm8723
->curPsTdma
== 7) {
7651 btdm_2AntPsTdma(padapter
, true, 8);
7652 pBtdm8723
->psTdmaDuAdjType
= 8;
7653 } else if (pBtdm8723
->curPsTdma
== 13) {
7654 btdm_2AntPsTdma(padapter
, true, 15);
7655 pBtdm8723
->psTdmaDuAdjType
= 15;
7656 } else if (pBtdm8723
->curPsTdma
== 14) {
7657 btdm_2AntPsTdma(padapter
, true, 15);
7658 pBtdm8723
->psTdmaDuAdjType
= 15;
7659 } else if (pBtdm8723
->curPsTdma
== 15) {
7660 btdm_2AntPsTdma(padapter
, true, 16);
7661 pBtdm8723
->psTdmaDuAdjType
= 16;
7663 } else if (result
== 1) {
7664 if (pBtdm8723
->curPsTdma
== 8) {
7665 btdm_2AntPsTdma(padapter
, true, 7);
7666 pBtdm8723
->psTdmaDuAdjType
= 7;
7667 } else if (pBtdm8723
->curPsTdma
== 7) {
7668 btdm_2AntPsTdma(padapter
, true, 7);
7669 pBtdm8723
->psTdmaDuAdjType
= 7;
7670 } else if (pBtdm8723
->curPsTdma
== 6) {
7671 btdm_2AntPsTdma(padapter
, true, 7);
7672 pBtdm8723
->psTdmaDuAdjType
= 7;
7673 } else if (pBtdm8723
->curPsTdma
== 16) {
7674 btdm_2AntPsTdma(padapter
, true, 15);
7675 pBtdm8723
->psTdmaDuAdjType
= 15;
7676 } else if (pBtdm8723
->curPsTdma
== 15) {
7677 btdm_2AntPsTdma(padapter
, true, 15);
7678 pBtdm8723
->psTdmaDuAdjType
= 15;
7679 } else if (pBtdm8723
->curPsTdma
== 14) {
7680 btdm_2AntPsTdma(padapter
, true, 15);
7681 pBtdm8723
->psTdmaDuAdjType
= 15;
7685 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], TxPause = 0\n"));
7686 if (pBtdm8723
->curPsTdma
== 5) {
7687 btdm_2AntPsTdma(padapter
, true, 3);
7688 pBtdm8723
->psTdmaDuAdjType
= 3;
7689 } else if (pBtdm8723
->curPsTdma
== 6) {
7690 btdm_2AntPsTdma(padapter
, true, 3);
7691 pBtdm8723
->psTdmaDuAdjType
= 3;
7692 } else if (pBtdm8723
->curPsTdma
== 7) {
7693 btdm_2AntPsTdma(padapter
, true, 3);
7694 pBtdm8723
->psTdmaDuAdjType
= 3;
7695 } else if (pBtdm8723
->curPsTdma
== 8) {
7696 btdm_2AntPsTdma(padapter
, true, 4);
7697 pBtdm8723
->psTdmaDuAdjType
= 4;
7699 if (pBtdm8723
->curPsTdma
== 13) {
7700 btdm_2AntPsTdma(padapter
, true, 11);
7701 pBtdm8723
->psTdmaDuAdjType
= 11;
7702 } else if (pBtdm8723
->curPsTdma
== 14) {
7703 btdm_2AntPsTdma(padapter
, true, 11);
7704 pBtdm8723
->psTdmaDuAdjType
= 11;
7705 } else if (pBtdm8723
->curPsTdma
== 15) {
7706 btdm_2AntPsTdma(padapter
, true, 11);
7707 pBtdm8723
->psTdmaDuAdjType
= 11;
7708 } else if (pBtdm8723
->curPsTdma
== 16) {
7709 btdm_2AntPsTdma(padapter
, true, 12);
7710 pBtdm8723
->psTdmaDuAdjType
= 12;
7713 if (pBtdm8723
->curPsTdma
== 1) {
7714 btdm_2AntPsTdma(padapter
, true, 3);
7715 pBtdm8723
->psTdmaDuAdjType
= 3;
7716 } else if (pBtdm8723
->curPsTdma
== 2) {
7717 btdm_2AntPsTdma(padapter
, true, 3);
7718 pBtdm8723
->psTdmaDuAdjType
= 3;
7719 } else if (pBtdm8723
->curPsTdma
== 3) {
7720 btdm_2AntPsTdma(padapter
, true, 4);
7721 pBtdm8723
->psTdmaDuAdjType
= 4;
7722 } else if (pBtdm8723
->curPsTdma
== 9) {
7723 btdm_2AntPsTdma(padapter
, true, 11);
7724 pBtdm8723
->psTdmaDuAdjType
= 11;
7725 } else if (pBtdm8723
->curPsTdma
== 10) {
7726 btdm_2AntPsTdma(padapter
, true, 11);
7727 pBtdm8723
->psTdmaDuAdjType
= 11;
7728 } else if (pBtdm8723
->curPsTdma
== 11) {
7729 btdm_2AntPsTdma(padapter
, true, 12);
7730 pBtdm8723
->psTdmaDuAdjType
= 12;
7732 } else if (result
== 1) {
7733 if (pBtdm8723
->curPsTdma
== 4) {
7734 btdm_2AntPsTdma(padapter
, true, 3);
7735 pBtdm8723
->psTdmaDuAdjType
= 3;
7736 } else if (pBtdm8723
->curPsTdma
== 3) {
7737 btdm_2AntPsTdma(padapter
, true, 3);
7738 pBtdm8723
->psTdmaDuAdjType
= 3;
7739 } else if (pBtdm8723
->curPsTdma
== 2) {
7740 btdm_2AntPsTdma(padapter
, true, 3);
7741 pBtdm8723
->psTdmaDuAdjType
= 3;
7742 } else if (pBtdm8723
->curPsTdma
== 12) {
7743 btdm_2AntPsTdma(padapter
, true, 11);
7744 pBtdm8723
->psTdmaDuAdjType
= 11;
7745 } else if (pBtdm8723
->curPsTdma
== 11) {
7746 btdm_2AntPsTdma(padapter
, true, 11);
7747 pBtdm8723
->psTdmaDuAdjType
= 11;
7748 } else if (pBtdm8723
->curPsTdma
== 10) {
7749 btdm_2AntPsTdma(padapter
, true, 11);
7750 pBtdm8723
->psTdmaDuAdjType
= 11;
7756 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PsTdma type : recordPsTdma =%d\n", pBtdm8723
->psTdmaDuAdjType
));
7757 /* if current PsTdma not match with the recorded one (when scan, dhcp...), */
7758 /* then we have to adjust it back to the previous record one. */
7759 if (pBtdm8723
->curPsTdma
!= pBtdm8723
->psTdmaDuAdjType
) {
7760 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n",
7761 pBtdm8723
->curPsTdma
, pBtdm8723
->psTdmaDuAdjType
));
7763 if (!check_fwstate(&padapter
->mlmepriv
, _FW_UNDER_SURVEY
|_FW_UNDER_LINKING
))
7764 btdm_2AntPsTdma(padapter
, true, pBtdm8723
->psTdmaDuAdjType
);
7766 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n"));
7770 /* default Action */
7771 /* SCO only or SCO+PAN(HS) */
7772 static void btdm_2Ant8723ASCOAction(struct rtw_adapter
*padapter
)
7774 u8 btRssiState
, btRssiState1
;
7776 if (btdm_NeedToDecBtPwr(padapter
))
7777 btdm_2AntDecBtPwr(padapter
, true);
7779 btdm_2AntDecBtPwr(padapter
, false);
7781 if (BTDM_IsHT40(padapter
)) {
7782 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
7783 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7785 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7786 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7787 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
7788 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7789 btdm_2AntPsTdma(padapter
, true, 11);
7791 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
7792 btdm_2AntPsTdma(padapter
, true, 15);
7796 btdm_2AntAgcTable(padapter
, false);
7797 btdm_2AntAdcBackOff(padapter
, true);
7798 btdm_2AntDacSwing(padapter
, false, 0xc0);
7800 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
7801 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7802 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
7805 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
7806 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
7807 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
7808 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7809 btdm_2AntPsTdma(padapter
, true, 11);
7811 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
7812 btdm_2AntPsTdma(padapter
, true, 15);
7816 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7817 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7818 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
7819 btdm_2AntAgcTable(padapter
, true);
7820 btdm_2AntAdcBackOff(padapter
, true);
7821 btdm_2AntDacSwing(padapter
, false, 0xc0);
7823 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
7824 btdm_2AntAgcTable(padapter
, false);
7825 btdm_2AntAdcBackOff(padapter
, false);
7826 btdm_2AntDacSwing(padapter
, false, 0xc0);
7831 static void btdm_2Ant8723AHIDAction(struct rtw_adapter
*padapter
)
7833 u8 btRssiState
, btRssiState1
;
7835 if (btdm_NeedToDecBtPwr(padapter
))
7836 btdm_2AntDecBtPwr(padapter
, true);
7838 btdm_2AntDecBtPwr(padapter
, false);
7840 if (BTDM_IsHT40(padapter
)) {
7841 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
7842 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7844 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7845 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7846 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
7847 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7848 btdm_2AntPsTdma(padapter
, true, 9);
7850 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
7851 btdm_2AntPsTdma(padapter
, true, 13);
7855 btdm_2AntAgcTable(padapter
, false);
7856 btdm_2AntAdcBackOff(padapter
, false);
7857 btdm_2AntDacSwing(padapter
, false, 0xc0);
7859 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
7860 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7861 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
7864 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
7865 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
7866 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
7867 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7868 btdm_2AntPsTdma(padapter
, true, 9);
7870 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
7871 btdm_2AntPsTdma(padapter
, true, 13);
7875 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7876 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7877 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
7878 btdm_2AntAgcTable(padapter
, true);
7879 btdm_2AntAdcBackOff(padapter
, true);
7880 btdm_2AntDacSwing(padapter
, false, 0xc0);
7882 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
7883 btdm_2AntAgcTable(padapter
, false);
7884 btdm_2AntAdcBackOff(padapter
, false);
7885 btdm_2AntDacSwing(padapter
, false, 0xc0);
7890 /* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */
7891 static void btdm_2Ant8723AA2DPAction(struct rtw_adapter
*padapter
)
7893 u8 btRssiState
, btRssiState1
;
7894 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
7895 u8 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
7897 if (btdm_NeedToDecBtPwr(padapter
))
7898 btdm_2AntDecBtPwr(padapter
, true);
7900 btdm_2AntDecBtPwr(padapter
, false);
7902 if (BTDM_IsHT40(padapter
)) {
7903 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
7904 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7907 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7908 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7909 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
7910 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7912 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
7913 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
7914 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 3);
7916 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
7917 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 1);
7920 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
7921 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
7922 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
7923 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 3);
7925 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
7926 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 1);
7931 btdm_2AntAgcTable(padapter
, false);
7932 btdm_2AntAdcBackOff(padapter
, true);
7933 btdm_2AntDacSwing(padapter
, false, 0xc0);
7935 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
7936 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7937 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
7940 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
7941 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
7942 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
7943 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7944 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
7945 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
7946 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 3);
7948 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
7949 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 1);
7952 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
7953 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
7954 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
7955 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 3);
7957 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
7958 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 1);
7963 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7964 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7965 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
7966 btdm_2AntAgcTable(padapter
, true);
7967 btdm_2AntAdcBackOff(padapter
, true);
7968 btdm_2AntDacSwing(padapter
, false, 0xc0);
7970 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
7971 btdm_2AntAgcTable(padapter
, false);
7972 btdm_2AntAdcBackOff(padapter
, false);
7973 btdm_2AntDacSwing(padapter
, false, 0xc0);
7978 static void btdm_2Ant8723APANEDRAction(struct rtw_adapter
*padapter
)
7980 u8 btRssiState
, btRssiState1
;
7982 if (btdm_NeedToDecBtPwr(padapter
))
7983 btdm_2AntDecBtPwr(padapter
, true);
7985 btdm_2AntDecBtPwr(padapter
, false);
7987 if (BTDM_IsHT40(padapter
)) {
7988 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
7989 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
7992 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
7993 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
7994 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
7995 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
7996 btdm_2AntPsTdma(padapter
, true, 2);
7998 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
7999 btdm_2AntPsTdma(padapter
, true, 6);
8003 btdm_2AntAgcTable(padapter
, false);
8004 btdm_2AntAdcBackOff(padapter
, true);
8005 btdm_2AntDacSwing(padapter
, false, 0xc0);
8007 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8008 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8009 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
8012 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8013 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8014 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8015 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8016 btdm_2AntPsTdma(padapter
, true, 2);
8018 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8019 btdm_2AntPsTdma(padapter
, true, 6);
8023 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8024 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8025 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8026 btdm_2AntAgcTable(padapter
, true);
8027 btdm_2AntAdcBackOff(padapter
, true);
8028 btdm_2AntDacSwing(padapter
, false, 0xc0);
8030 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8031 btdm_2AntAgcTable(padapter
, false);
8032 btdm_2AntAdcBackOff(padapter
, false);
8033 btdm_2AntDacSwing(padapter
, false, 0xc0);
8039 static void btdm_2Ant8723APANHSAction(struct rtw_adapter
*padapter
)
8043 if (BTDM_IsHT40(padapter
)) {
8044 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8045 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 47, 0);
8047 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8048 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8049 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8050 btdm_2AntDecBtPwr(padapter
, true);
8052 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8053 btdm_2AntDecBtPwr(padapter
, false);
8055 btdm_2AntPsTdma(padapter
, false, 0);
8058 btdm_2AntAgcTable(padapter
, false);
8059 btdm_2AntAdcBackOff(padapter
, true);
8060 btdm_2AntDacSwing(padapter
, false, 0xc0);
8062 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8063 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 47, 0);
8065 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8066 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8067 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high\n"));
8069 btdm_2AntDecBtPwr(padapter
, true);
8070 btdm_2AntPsTdma(padapter
, false, 0);
8073 btdm_2AntAgcTable(padapter
, true);
8074 btdm_2AntAdcBackOff(padapter
, true);
8075 btdm_2AntDacSwing(padapter
, false, 0xc0);
8077 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low\n"));
8079 btdm_2AntDecBtPwr(padapter
, false);
8080 btdm_2AntPsTdma(padapter
, false, 0);
8083 btdm_2AntAgcTable(padapter
, false);
8084 btdm_2AntAdcBackOff(padapter
, false);
8085 btdm_2AntDacSwing(padapter
, false, 0xc0);
8091 static void btdm_2Ant8723APANEDRA2DPAction(struct rtw_adapter
*padapter
)
8093 u8 btRssiState
, btRssiState1
, btInfoExt
;
8094 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8096 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
8098 if (btdm_NeedToDecBtPwr(padapter
))
8099 btdm_2AntDecBtPwr(padapter
, true);
8101 btdm_2AntDecBtPwr(padapter
, false);
8103 if (BTDM_IsHT40(padapter
)) {
8104 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8105 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8107 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8108 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8109 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8111 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8113 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8114 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8115 btdm_2AntPsTdma(padapter
, true, 4);
8117 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8118 btdm_2AntPsTdma(padapter
, true, 2);
8121 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8123 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8124 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8125 btdm_2AntPsTdma(padapter
, true, 8);
8127 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8128 btdm_2AntPsTdma(padapter
, true, 6);
8133 btdm_2AntAgcTable(padapter
, false);
8134 btdm_2AntAdcBackOff(padapter
, true);
8135 btdm_2AntDacSwing(padapter
, false, 0xc0);
8137 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8138 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8139 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
8141 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8142 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8143 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8144 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8146 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8147 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8148 btdm_2AntPsTdma(padapter
, true, 4);
8150 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8151 btdm_2AntPsTdma(padapter
, true, 2);
8154 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8156 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8157 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8158 btdm_2AntPsTdma(padapter
, true, 8);
8160 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8161 btdm_2AntPsTdma(padapter
, true, 6);
8166 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8167 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8168 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8169 btdm_2AntAgcTable(padapter
, true);
8170 btdm_2AntAdcBackOff(padapter
, true);
8171 btdm_2AntDacSwing(padapter
, false, 0xc0);
8173 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8174 btdm_2AntAgcTable(padapter
, false);
8175 btdm_2AntAdcBackOff(padapter
, false);
8176 btdm_2AntDacSwing(padapter
, false, 0xc0);
8181 static void btdm_2Ant8723APANEDRHIDAction(struct rtw_adapter
*padapter
)
8183 u8 btRssiState
, btRssiState1
;
8185 if (btdm_NeedToDecBtPwr(padapter
))
8186 btdm_2AntDecBtPwr(padapter
, true);
8188 btdm_2AntDecBtPwr(padapter
, false);
8190 if (BTDM_IsHT40(padapter
)) {
8191 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8192 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8194 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8195 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8196 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8197 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8198 btdm_2AntPsTdma(padapter
, true, 10);
8200 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8201 btdm_2AntPsTdma(padapter
, true, 14);
8205 btdm_2AntAgcTable(padapter
, false);
8206 btdm_2AntAdcBackOff(padapter
, true);
8207 btdm_2AntDacSwing(padapter
, false, 0xc0);
8209 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8210 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8211 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
8214 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8215 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8216 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8217 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8218 btdm_2AntPsTdma(padapter
, true, 10);
8220 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8221 btdm_2AntPsTdma(padapter
, true, 14);
8225 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8226 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8227 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8228 btdm_2AntAgcTable(padapter
, true);
8229 btdm_2AntAdcBackOff(padapter
, true);
8230 btdm_2AntDacSwing(padapter
, false, 0xc0);
8232 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8233 btdm_2AntAgcTable(padapter
, false);
8234 btdm_2AntAdcBackOff(padapter
, false);
8235 btdm_2AntDacSwing(padapter
, false, 0xc0);
8240 /* HID+A2DP+PAN(EDR) */
8241 static void btdm_2Ant8723AHIDA2DPPANEDRAction(struct rtw_adapter
*padapter
)
8243 u8 btRssiState
, btRssiState1
, btInfoExt
;
8244 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8246 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
8248 if (btdm_NeedToDecBtPwr(padapter
))
8249 btdm_2AntDecBtPwr(padapter
, true);
8251 btdm_2AntDecBtPwr(padapter
, false);
8253 if (BTDM_IsHT40(padapter
)) {
8254 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8255 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8256 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8257 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8258 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8259 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8261 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8262 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8263 btdm_2AntPsTdma(padapter
, true, 12);
8265 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8266 btdm_2AntPsTdma(padapter
, true, 10);
8269 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8270 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8271 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8272 btdm_2AntPsTdma(padapter
, true, 16);
8274 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8275 btdm_2AntPsTdma(padapter
, true, 14);
8280 btdm_2AntAgcTable(padapter
, false);
8281 btdm_2AntAdcBackOff(padapter
, true);
8282 btdm_2AntDacSwing(padapter
, false, 0xc0);
8284 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8285 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 37, 0);
8286 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 27, 0);
8287 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8288 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8289 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8290 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8292 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8293 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8294 btdm_2AntPsTdma(padapter
, true, 12);
8296 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8297 btdm_2AntPsTdma(padapter
, true, 10);
8300 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8301 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8302 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8303 btdm_2AntPsTdma(padapter
, true, 16);
8305 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8306 btdm_2AntPsTdma(padapter
, true, 14);
8311 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8312 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8313 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8314 btdm_2AntAgcTable(padapter
, true);
8315 btdm_2AntAdcBackOff(padapter
, true);
8316 btdm_2AntDacSwing(padapter
, false, 0xc0);
8318 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8319 btdm_2AntAgcTable(padapter
, false);
8320 btdm_2AntAdcBackOff(padapter
, false);
8321 btdm_2AntDacSwing(padapter
, false, 0xc0);
8326 static void btdm_2Ant8723AHIDA2DPAction(struct rtw_adapter
*padapter
)
8328 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8329 u8 btRssiState
, btRssiState1
, btInfoExt
;
8331 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
8333 if (btdm_NeedToDecBtPwr(padapter
))
8334 btdm_2AntDecBtPwr(padapter
, true);
8336 btdm_2AntDecBtPwr(padapter
, false);
8338 if (BTDM_IsHT40(padapter
)) {
8339 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8340 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8341 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8342 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8343 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8344 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8346 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8347 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8348 btdm_2AntTdmaDurationAdjust(padapter
, true, false, 3);
8350 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8351 btdm_2AntTdmaDurationAdjust(padapter
, true, false, 1);
8354 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8355 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8356 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8357 btdm_2AntTdmaDurationAdjust(padapter
, true, true, 3);
8359 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8360 btdm_2AntTdmaDurationAdjust(padapter
, true, true, 1);
8364 btdm_2AntAgcTable(padapter
, false);
8365 btdm_2AntAdcBackOff(padapter
, true);
8366 btdm_2AntDacSwing(padapter
, false, 0xc0);
8368 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8369 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8370 btRssiState1
= BTDM_CheckCoexRSSIState(padapter
, 2, 27, 0);
8372 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8373 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8374 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8375 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8377 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8378 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8379 btdm_2AntTdmaDurationAdjust(padapter
, true, false, 3);
8381 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8382 btdm_2AntTdmaDurationAdjust(padapter
, true, false, 1);
8385 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8386 if (btInfoExt
&BIT(0)) { /* a2dp rate, 1:basic /0:edr */
8387 RTPRINT(FBT
, BT_TRACE
, ("a2dp basic rate \n"));
8388 btdm_2AntTdmaDurationAdjust(padapter
, true, true, 3);
8390 RTPRINT(FBT
, BT_TRACE
, ("a2dp edr rate \n"));
8391 btdm_2AntTdmaDurationAdjust(padapter
, true, true, 1);
8394 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8395 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8396 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8398 btdm_2AntAgcTable(padapter
, true);
8399 btdm_2AntAdcBackOff(padapter
, true);
8400 btdm_2AntDacSwing(padapter
, false, 0xc0);
8402 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8404 btdm_2AntAgcTable(padapter
, false);
8405 btdm_2AntAdcBackOff(padapter
, false);
8406 btdm_2AntDacSwing(padapter
, false, 0xc0);
8411 static void btdm_2Ant8723AA2dp(struct rtw_adapter
*padapter
)
8413 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8414 u8 btRssiState
, btRssiState1
, btInfoExt
;
8416 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
8418 if (btdm_NeedToDecBtPwr(padapter
))
8419 btdm_2AntDecBtPwr(padapter
, true);
8421 btdm_2AntDecBtPwr(padapter
, false);
8423 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
8424 btdm_2AntIgnoreWlanAct(padapter
, false);
8426 if (BTDM_IsHT40(padapter
)) {
8427 RTPRINT(FBT
, BT_TRACE
, ("HT40\n"));
8428 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 37, 0);
8430 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8431 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8432 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8433 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8434 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 1);
8436 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8437 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 1);
8441 btdm_2AntAgcTable(padapter
, false);
8442 btdm_2AntAdcBackOff(padapter
, true);
8443 btdm_2AntDacSwing(padapter
, false, 0xc0);
8445 RTPRINT(FBT
, BT_TRACE
, ("HT20 or Legacy\n"));
8446 btRssiState
= BTDM_CheckCoexRSSIState(padapter
, 2, 47, 0);
8447 btRssiState1
= BTDM_CheckCoexRSSIState1(padapter
, 2, 27, 0);
8450 if ((btRssiState1
== BT_RSSI_STATE_HIGH
) ||
8451 (btRssiState1
== BT_RSSI_STATE_STAY_HIGH
)) {
8452 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 high \n"));
8453 PlatformEFIOWrite1Byte(padapter
, 0x883, 0x40);
8454 btdm_2AntTdmaDurationAdjust(padapter
, false, false, 1);
8456 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi-1 low \n"));
8457 btdm_2AntTdmaDurationAdjust(padapter
, false, true, 1);
8461 if ((btRssiState
== BT_RSSI_STATE_HIGH
) ||
8462 (btRssiState
== BT_RSSI_STATE_STAY_HIGH
)) {
8463 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi high \n"));
8464 btdm_2AntAgcTable(padapter
, true);
8465 btdm_2AntAdcBackOff(padapter
, true);
8466 btdm_2AntDacSwing(padapter
, false, 0xc0);
8468 RTPRINT(FBT
, BT_TRACE
, ("Wifi rssi low \n"));
8469 btdm_2AntAgcTable(padapter
, false);
8470 btdm_2AntAdcBackOff(padapter
, false);
8471 btdm_2AntDacSwing(padapter
, false, 0xc0);
8476 /* extern function start with BTDM_ */
8477 static void BTDM_2AntParaInit(struct rtw_adapter
*padapter
)
8480 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8481 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
8483 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 2Ant Parameter Init!!\n"));
8485 /* Enable counter statistics */
8486 rtl8723au_write8(padapter
, 0x76e, 0x4);
8487 rtl8723au_write8(padapter
, 0x778, 0x3);
8488 rtl8723au_write8(padapter
, 0x40, 0x20);
8490 /* force to reset coex mechanism */
8491 pBtdm8723
->preVal0x6c0
= 0x0;
8492 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
8494 pBtdm8723
->bPrePsTdmaOn
= true;
8495 btdm_2AntPsTdma(padapter
, false, 0);
8497 pBtdm8723
->preFwDacSwingLvl
= 0x10;
8498 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
8500 pBtdm8723
->bPreDecBtPwr
= true;
8501 btdm_2AntDecBtPwr(padapter
, false);
8503 pBtdm8723
->bPreAgcTableEn
= true;
8504 btdm_2AntAgcTable(padapter
, false);
8506 pBtdm8723
->bPreAdcBackOff
= true;
8507 btdm_2AntAdcBackOff(padapter
, false);
8509 pBtdm8723
->bPreLowPenaltyRa
= true;
8510 btdm_2AntLowPenaltyRa(padapter
, false);
8512 pBtdm8723
->bPreRfRxLpfShrink
= true;
8513 btdm_2AntRfShrink(padapter
, false);
8515 pBtdm8723
->bPreDacSwingOn
= true;
8516 btdm_2AntDacSwing(padapter
, false, 0xc0);
8518 pBtdm8723
->bPreIgnoreWlanAct
= true;
8519 btdm_2AntIgnoreWlanAct(padapter
, false);
8522 static void BTDM_2AntHwCoexAllOff8723A(struct rtw_adapter
*padapter
)
8524 btdm_2AntCoexTable(padapter
, 0x55555555, 0xffff, 0x3);
8527 static void BTDM_2AntFwCoexAllOff8723A(struct rtw_adapter
*padapter
)
8529 btdm_2AntIgnoreWlanAct(padapter
, false);
8530 btdm_2AntPsTdma(padapter
, false, 0);
8531 btdm_2AntFwDacSwingLvl(padapter
, 0x20);
8532 btdm_2AntDecBtPwr(padapter
, false);
8535 static void BTDM_2AntSwCoexAllOff8723A(struct rtw_adapter
*padapter
)
8537 btdm_2AntAgcTable(padapter
, false);
8538 btdm_2AntAdcBackOff(padapter
, false);
8539 btdm_2AntLowPenaltyRa(padapter
, false);
8540 btdm_2AntRfShrink(padapter
, false);
8541 btdm_2AntDacSwing(padapter
, false, 0xc0);
8544 static void BTDM_2AntFwC2hBtInfo8723A(struct rtw_adapter
*padapter
)
8546 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
8547 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
8548 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8549 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
8551 u8 algorithm
= BT_2ANT_COEX_ALGO_UNDEFINED
;
8552 u8 bBtLinkExist
= false, bBtHsModeExist
= false;
8554 btInfo
= pHalData
->bt_coexist
.halCoex8723
.c2hBtInfoOriginal
;
8555 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_IDLE
;
8557 /* check BIT2 first ==> check if bt is under inquiry or page scan */
8558 if (btInfo
& BIT(2)) {
8559 if (!pHalData
->bt_coexist
.halCoex8723
.bC2hBtInquiryPage
) {
8560 pBtMgnt
->ExtConfig
.bHoldForBtOperation
= true;
8561 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
= 1;
8562 btdm_2AntBtInquiryPage(padapter
);
8564 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
++;
8565 btdm_HoldForBtInqPage(padapter
);
8567 pHalData
->bt_coexist
.halCoex8723
.bC2hBtInquiryPage
= true;
8570 pHalData
->bt_coexist
.halCoex8723
.bC2hBtInquiryPage
= false;
8571 pBtMgnt
->ExtConfig
.bHoldForBtOperation
= false;
8572 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
= 0;
8575 RTPRINT(FBT
, BT_TRACE
,
8576 ("[BTC2H], pHalData->bt_coexist.halCoex8723.bC2hBtInquiryPage =%x pBtMgnt->ExtConfig.bHoldPeriodCnt =%x pBtMgnt->ExtConfig.bHoldForBtOperation =%x\n",
8577 pHalData
->bt_coexist
.halCoex8723
.bC2hBtInquiryPage
,
8578 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
,
8579 pBtMgnt
->ExtConfig
.bHoldForBtOperation
));
8581 RTPRINT(FBT
, BT_TRACE
,
8582 ("[BTC2H], btInfo =%x pHalData->bt_coexist.halCoex8723.c2hBtInfoOriginal =%x\n",
8583 btInfo
, pHalData
->bt_coexist
.halCoex8723
.c2hBtInfoOriginal
));
8584 if (btInfo
&BT_INFO_ACL
) {
8585 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], BTInfo: bConnect = true btInfo =%x\n", btInfo
));
8586 bBtLinkExist
= true;
8587 if (((btInfo
&(BT_INFO_FTP
|BT_INFO_A2DP
|BT_INFO_HID
|BT_INFO_SCO_BUSY
)) != 0) ||
8588 pHalData
->bt_coexist
.halCoex8723
.btRetryCnt
> 0) {
8589 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_NON_IDLE
;
8591 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_CONNECTED_IDLE
;
8594 if (btInfo
&BT_INFO_SCO
|| btInfo
&BT_INFO_SCO_BUSY
) {
8595 if (btInfo
&BT_INFO_FTP
|| btInfo
&BT_INFO_A2DP
|| btInfo
&BT_INFO_HID
) {
8596 switch (btInfo
&0xe0) {
8598 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + HID\n"));
8599 algorithm
= BT_2ANT_COEX_ALGO_HID
;
8602 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Error!!! SCO + A2DP\n"));
8605 if (bBtHsModeExist
) {
8606 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + PAN(HS)\n"));
8607 algorithm
= BT_2ANT_COEX_ALGO_SCO
;
8609 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO + PAN(EDR)\n"));
8610 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
8613 case (BT_INFO_HID
| BT_INFO_A2DP
):
8614 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP\n"));
8615 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8617 case (BT_INFO_HID
| BT_INFO_FTP
):
8618 if (bBtHsModeExist
) {
8619 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(HS)\n"));
8620 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8622 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(EDR)\n"));
8623 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
8626 case (BT_INFO_A2DP
| BT_INFO_FTP
):
8627 if (bBtHsModeExist
) {
8628 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(HS)\n"));
8629 algorithm
= BT_2ANT_COEX_ALGO_A2DP
;
8631 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(EDR)\n"));
8632 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_A2DP
;
8635 case (BT_INFO_HID
| BT_INFO_A2DP
| BT_INFO_FTP
):
8636 if (bBtHsModeExist
) {
8637 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
8638 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8640 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
8641 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
8646 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], SCO only\n"));
8647 algorithm
= BT_2ANT_COEX_ALGO_SCO
;
8650 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], non SCO\n"));
8651 switch (btInfo
&0xe0) {
8653 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID\n"));
8654 algorithm
= BT_2ANT_COEX_ALGO_HID
;
8657 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP\n"));
8658 algorithm
= BT_2ANT_COEX_ALGO_A2DP
;
8661 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], PAN(EDR)\n"));
8662 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
8664 case (BT_INFO_HID
| BT_INFO_A2DP
):
8665 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP\n"));
8666 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8668 case (BT_INFO_HID
|BT_INFO_FTP
):
8669 if (bBtHsModeExist
) {
8670 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(HS)\n"));
8671 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8673 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + PAN(EDR)\n"));
8674 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_HID
;
8677 case (BT_INFO_A2DP
|BT_INFO_FTP
):
8678 if (bBtHsModeExist
) {
8679 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(HS)\n"));
8680 algorithm
= BT_2ANT_COEX_ALGO_A2DP
;
8682 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], A2DP + PAN(EDR)\n"));
8683 algorithm
= BT_2ANT_COEX_ALGO_PANEDR_A2DP
;
8686 case (BT_INFO_HID
|BT_INFO_A2DP
|BT_INFO_FTP
):
8687 if (bBtHsModeExist
) {
8688 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(HS)\n"));
8689 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP
;
8691 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], HID + A2DP + PAN(EDR)\n"));
8692 algorithm
= BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR
;
8699 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], BTInfo: bConnect = false\n"));
8700 pBtdm8723
->btStatus
= BT_2ANT_BT_STATUS_IDLE
;
8703 pBtdm8723
->curAlgorithm
= algorithm
;
8704 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Algorithm = %d \n", pBtdm8723
->curAlgorithm
));
8707 BTDM_CheckWiFiState(padapter
);
8708 if (pBtMgnt
->ExtConfig
.bManualControl
) {
8709 RTPRINT(FBT
, BT_TRACE
, ("Action Manual control, won't execute bt coexist mechanism!!\n"));
8714 void BTDM_2AntBtCoexist8723A(struct rtw_adapter
*padapter
)
8716 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
8717 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
8718 struct bt_dgb
*pBtDbg
= &pBTInfo
->BtDbg
;
8719 u8 btInfoOriginal
= 0;
8720 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8721 struct btdm_8723a_2ant
*pBtdm8723
= &pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
;
8723 if (BTDM_BtProfileSupport(padapter
)) {
8724 if (pBtMgnt
->ExtConfig
.bHoldForBtOperation
) {
8725 RTPRINT(FBT
, BT_TRACE
, ("Action for BT Operation adjust!!\n"));
8728 if (pBtMgnt
->ExtConfig
.bHoldPeriodCnt
) {
8729 RTPRINT(FBT
, BT_TRACE
, ("Hold BT inquiry/page scan setting (cnt = %d)!!\n",
8730 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
));
8731 if (pBtMgnt
->ExtConfig
.bHoldPeriodCnt
>= 11) {
8732 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
= 0;
8733 /* next time the coexist parameters should be reset again. */
8735 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
++;
8740 if (pBtDbg
->dbgCtrl
)
8741 RTPRINT(FBT
, BT_TRACE
, ("[Dbg control], "));
8743 pBtdm8723
->curAlgorithm
= btdm_ActionAlgorithm(padapter
);
8744 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Algorithm = %d \n", pBtdm8723
->curAlgorithm
));
8746 if (btdm_Is2Ant8723ACommonAction(padapter
)) {
8747 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant common.\n"));
8748 pBtdm8723
->bResetTdmaAdjust
= true;
8750 if (pBtdm8723
->curAlgorithm
!= pBtdm8723
->preAlgorithm
) {
8751 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n",
8752 pBtdm8723
->preAlgorithm
, pBtdm8723
->curAlgorithm
));
8753 pBtdm8723
->bResetTdmaAdjust
= true;
8755 switch (pBtdm8723
->curAlgorithm
) {
8756 case BT_2ANT_COEX_ALGO_SCO
:
8757 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = SCO.\n"));
8758 btdm_2Ant8723ASCOAction(padapter
);
8760 case BT_2ANT_COEX_ALGO_HID
:
8761 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID.\n"));
8762 btdm_2Ant8723AHIDAction(padapter
);
8764 case BT_2ANT_COEX_ALGO_A2DP
:
8765 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = A2DP.\n"));
8766 btdm_2Ant8723AA2DPAction(padapter
);
8768 case BT_2ANT_COEX_ALGO_PANEDR
:
8769 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN(EDR).\n"));
8770 btdm_2Ant8723APANEDRAction(padapter
);
8772 case BT_2ANT_COEX_ALGO_PANHS
:
8773 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HS mode.\n"));
8774 btdm_2Ant8723APANHSAction(padapter
);
8776 case BT_2ANT_COEX_ALGO_PANEDR_A2DP
:
8777 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN+A2DP.\n"));
8778 btdm_2Ant8723APANEDRA2DPAction(padapter
);
8780 case BT_2ANT_COEX_ALGO_PANEDR_HID
:
8781 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
8782 btdm_2Ant8723APANEDRHIDAction(padapter
);
8784 case BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR
:
8785 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
8786 btdm_2Ant8723AHIDA2DPPANEDRAction(padapter
);
8788 case BT_2ANT_COEX_ALGO_HID_A2DP
:
8789 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID+A2DP.\n"));
8790 btdm_2Ant8723AHIDA2DPAction(padapter
);
8793 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = 0.\n"));
8794 btdm_2Ant8723AA2DPAction(padapter
);
8797 pBtdm8723
->preAlgorithm
= pBtdm8723
->curAlgorithm
;
8800 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex] Get bt info by fw!!\n"));
8801 /* msg shows c2h rsp for bt_info is received or not. */
8802 if (pHalData
->bt_coexist
.halCoex8723
.bC2hBtInfoReqSent
)
8803 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex] c2h for btInfo not rcvd yet!!\n"));
8805 btInfoOriginal
= pHalData
->bt_coexist
.halCoex8723
.c2hBtInfoOriginal
;
8807 if (pBtMgnt
->ExtConfig
.bHoldForBtOperation
) {
8808 RTPRINT(FBT
, BT_TRACE
, ("Action for BT Operation adjust!!\n"));
8811 if (pBtMgnt
->ExtConfig
.bHoldPeriodCnt
) {
8812 RTPRINT(FBT
, BT_TRACE
,
8813 ("Hold BT inquiry/page scan setting (cnt = %d)!!\n",
8814 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
));
8815 if (pBtMgnt
->ExtConfig
.bHoldPeriodCnt
>= 11) {
8816 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
= 0;
8817 /* next time the coexist parameters should be reset again. */
8819 pBtMgnt
->ExtConfig
.bHoldPeriodCnt
++;
8824 if (pBtDbg
->dbgCtrl
)
8825 RTPRINT(FBT
, BT_TRACE
, ("[Dbg control], "));
8826 if (btdm_Is2Ant8723ACommonAction(padapter
)) {
8827 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant common.\n"));
8828 pBtdm8723
->bResetTdmaAdjust
= true;
8830 if (pBtdm8723
->curAlgorithm
!= pBtdm8723
->preAlgorithm
) {
8831 RTPRINT(FBT
, BT_TRACE
,
8832 ("[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n",
8833 pBtdm8723
->preAlgorithm
,
8834 pBtdm8723
->curAlgorithm
));
8835 pBtdm8723
->bResetTdmaAdjust
= true;
8837 switch (pBtdm8723
->curAlgorithm
) {
8838 case BT_2ANT_COEX_ALGO_SCO
:
8839 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = SCO.\n"));
8840 btdm_2Ant8723ASCOAction(padapter
);
8842 case BT_2ANT_COEX_ALGO_HID
:
8843 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID.\n"));
8844 btdm_2Ant8723AHIDAction(padapter
);
8846 case BT_2ANT_COEX_ALGO_A2DP
:
8847 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = A2DP.\n"));
8848 btdm_2Ant8723AA2dp(padapter
);
8850 case BT_2ANT_COEX_ALGO_PANEDR
:
8851 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN(EDR).\n"));
8852 btdm_2Ant8723APANEDRAction(padapter
);
8854 case BT_2ANT_COEX_ALGO_PANHS
:
8855 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HS mode.\n"));
8856 btdm_2Ant8723APANHSAction(padapter
);
8858 case BT_2ANT_COEX_ALGO_PANEDR_A2DP
:
8859 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN+A2DP.\n"));
8860 btdm_2Ant8723APANEDRA2DPAction(padapter
);
8862 case BT_2ANT_COEX_ALGO_PANEDR_HID
:
8863 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = PAN(EDR)+HID.\n"));
8864 btdm_2Ant8723APANEDRHIDAction(padapter
);
8866 case BT_2ANT_COEX_ALGO_HID_A2DP_PANEDR
:
8867 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID+A2DP+PAN.\n"));
8868 btdm_2Ant8723AHIDA2DPPANEDRAction(padapter
);
8870 case BT_2ANT_COEX_ALGO_HID_A2DP
:
8871 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = HID+A2DP.\n"));
8872 btdm_2Ant8723AHIDA2DPAction(padapter
);
8875 RTPRINT(FBT
, BT_TRACE
, ("Action 2-Ant, algorithm = 0.\n"));
8876 btdm_2Ant8723AA2DPAction(padapter
);
8879 pBtdm8723
->preAlgorithm
= pBtdm8723
->curAlgorithm
;
8884 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc87232Ant.c ===== */
8886 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtc8723.c ===== */
8888 static u8 btCoexDbgBuf
[BT_TMP_BUF_SIZE
];
8890 static const char *const BtProfileString
[] = {
8898 static const char *const BtSpecString
[] = {
8908 static const char *const BtLinkRoleString
[] = {
8913 static u8
btdm_BtWifiAntNum(struct rtw_adapter
*padapter
)
8915 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8916 struct bt_coexist_8723a
*pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
8918 if (Ant_x2
== pHalData
->bt_coexist
.BT_Ant_Num
) {
8919 if (Ant_x2
== pBtCoex
->TotalAntNum
)
8929 static void btdm_BtHwCountersMonitor(struct rtw_adapter
*padapter
)
8931 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8932 u32 regHPTxRx
, regLPTxRx
, u4Tmp
;
8933 u32 regHPTx
= 0, regHPRx
= 0, regLPTx
= 0, regLPRx
= 0;
8935 regHPTxRx
= REG_HIGH_PRIORITY_TXRX
;
8936 regLPTxRx
= REG_LOW_PRIORITY_TXRX
;
8938 u4Tmp
= rtl8723au_read32(padapter
, regHPTxRx
);
8939 regHPTx
= u4Tmp
& bMaskLWord
;
8940 regHPRx
= (u4Tmp
& bMaskHWord
)>>16;
8942 u4Tmp
= rtl8723au_read32(padapter
, regLPTxRx
);
8943 regLPTx
= u4Tmp
& bMaskLWord
;
8944 regLPRx
= (u4Tmp
& bMaskHWord
)>>16;
8946 pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
= regHPTx
;
8947 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
= regHPRx
;
8948 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
= regLPTx
;
8949 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
= regLPRx
;
8951 RTPRINT(FBT
, BT_TRACE
, ("High Priority Tx/Rx = %d / %d\n", regHPTx
, regHPRx
));
8952 RTPRINT(FBT
, BT_TRACE
, ("Low Priority Tx/Rx = %d / %d\n", regLPTx
, regLPRx
));
8955 rtl8723au_write8(padapter
, 0x76e, 0xc);
8958 /* This function check if 8723 bt is disabled */
8959 static void btdm_BtEnableDisableCheck8723A(struct rtw_adapter
*padapter
)
8962 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
8964 #ifdef CHECK_BT_EXIST_FROM_REG
8967 /* ox68[28]= 1 => BT enable; otherwise disable */
8968 val8
= rtl8723au_read8(padapter
, 0x6B);
8969 if (!(val8
& BIT(4)))
8973 pHalData
->bt_coexist
.bCurBtDisabled
= false;
8975 pHalData
->bt_coexist
.bCurBtDisabled
= true;
8977 if (pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
== 0 &&
8978 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
== 0 &&
8979 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
== 0 &&
8980 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
== 0)
8982 if (pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
== 0xeaea &&
8983 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
== 0xeaea &&
8984 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
== 0xeaea &&
8985 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
== 0xeaea)
8987 if (pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
== 0xffff &&
8988 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
== 0xffff &&
8989 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
== 0xffff &&
8990 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
== 0xffff)
8993 pHalData
->bt_coexist
.btActiveZeroCnt
= 0;
8994 pHalData
->bt_coexist
.bCurBtDisabled
= false;
8995 RTPRINT(FBT
, BT_TRACE
, ("8723A BT is enabled !!\n"));
8997 pHalData
->bt_coexist
.btActiveZeroCnt
++;
8998 RTPRINT(FBT
, BT_TRACE
, ("8723A bt all counters = 0, %d times!!\n",
8999 pHalData
->bt_coexist
.btActiveZeroCnt
));
9000 if (pHalData
->bt_coexist
.btActiveZeroCnt
>= 2) {
9001 pHalData
->bt_coexist
.bCurBtDisabled
= true;
9002 RTPRINT(FBT
, BT_TRACE
, ("8723A BT is disabled !!\n"));
9007 if (!pHalData
->bt_coexist
.bCurBtDisabled
) {
9008 if (BTDM_IsWifiConnectionExist(padapter
))
9009 BTDM_SetFwChnlInfo(padapter
, RT_MEDIA_CONNECT
);
9011 BTDM_SetFwChnlInfo(padapter
, RT_MEDIA_DISCONNECT
);
9014 if (pHalData
->bt_coexist
.bPreBtDisabled
!=
9015 pHalData
->bt_coexist
.bCurBtDisabled
) {
9016 RTPRINT(FBT
, BT_TRACE
, ("8723A BT is from %s to %s!!\n",
9017 (pHalData
->bt_coexist
.bPreBtDisabled
? "disabled":"enabled"),
9018 (pHalData
->bt_coexist
.bCurBtDisabled
? "disabled":"enabled")));
9019 pHalData
->bt_coexist
.bPreBtDisabled
= pHalData
->bt_coexist
.bCurBtDisabled
;
9023 static void btdm_BTCoexist8723AHandler(struct rtw_adapter
*padapter
)
9025 struct hal_data_8723a
*pHalData
;
9027 pHalData
= GET_HAL_DATA(padapter
);
9029 if (btdm_BtWifiAntNum(padapter
) == Ant_x2
) {
9030 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 2 Ant mechanism\n"));
9031 BTDM_2AntBtCoexist8723A(padapter
);
9033 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], 1 Ant mechanism\n"));
9034 BTDM_1AntBtCoexist8723A(padapter
);
9037 if (!BTDM_IsSameCoexistState(padapter
)) {
9038 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Coexist State[bitMap] change from 0x%"i64fmt
"x to 0x%"i64fmt
"x\n",
9039 pHalData
->bt_coexist
.PreviousState
,
9040 pHalData
->bt_coexist
.CurrentState
));
9041 pHalData
->bt_coexist
.PreviousState
= pHalData
->bt_coexist
.CurrentState
;
9043 RTPRINT(FBT
, BT_TRACE
, ("["));
9044 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_BT30
)
9045 RTPRINT(FBT
, BT_TRACE
, ("BT 3.0, "));
9046 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_HT20
)
9047 RTPRINT(FBT
, BT_TRACE
, ("HT20, "));
9048 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_HT40
)
9049 RTPRINT(FBT
, BT_TRACE
, ("HT40, "));
9050 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_LEGACY
)
9051 RTPRINT(FBT
, BT_TRACE
, ("Legacy, "));
9052 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_RSSI_LOW
)
9053 RTPRINT(FBT
, BT_TRACE
, ("Rssi_Low, "));
9054 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_RSSI_MEDIUM
)
9055 RTPRINT(FBT
, BT_TRACE
, ("Rssi_Mid, "));
9056 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_RSSI_HIGH
)
9057 RTPRINT(FBT
, BT_TRACE
, ("Rssi_High, "));
9058 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_IDLE
)
9059 RTPRINT(FBT
, BT_TRACE
, ("Wifi_Idle, "));
9060 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_UPLINK
)
9061 RTPRINT(FBT
, BT_TRACE
, ("Wifi_Uplink, "));
9062 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_WIFI_DOWNLINK
)
9063 RTPRINT(FBT
, BT_TRACE
, ("Wifi_Downlink, "));
9064 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_BT_IDLE
)
9065 RTPRINT(FBT
, BT_TRACE
, ("BT_idle, "));
9066 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_PROFILE_HID
)
9067 RTPRINT(FBT
, BT_TRACE
, ("PRO_HID, "));
9068 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_PROFILE_A2DP
)
9069 RTPRINT(FBT
, BT_TRACE
, ("PRO_A2DP, "));
9070 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_PROFILE_PAN
)
9071 RTPRINT(FBT
, BT_TRACE
, ("PRO_PAN, "));
9072 if (pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_PROFILE_SCO
)
9073 RTPRINT(FBT
, BT_TRACE
, ("PRO_SCO, "));
9074 RTPRINT(FBT
, BT_TRACE
, ("]\n"));
9078 /* extern function start with BTDM_ */
9079 u32
BTDM_BtTxRxCounterH(struct rtw_adapter
*padapter
)
9081 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9084 counters
= pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
+
9085 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
;
9089 u32
BTDM_BtTxRxCounterL(struct rtw_adapter
*padapter
)
9091 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9094 counters
= pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
+
9095 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
;
9099 void BTDM_SetFwChnlInfo(struct rtw_adapter
*padapter
, enum rt_media_status mstatus
)
9101 struct mlme_ext_priv
*pmlmeext
= &padapter
->mlmeextpriv
;
9102 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9103 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9104 u8 H2C_Parameter
[3] = {0};
9108 if (RT_MEDIA_CONNECT
== mstatus
)
9109 H2C_Parameter
[0] = 0x1; /* 0: disconnected, 1:connected */
9111 if (check_fwstate(&padapter
->mlmepriv
, WIFI_ASOC_STATE
)) {
9113 chnl
= pmlmeext
->cur_channel
;
9114 if (BTDM_IsHT40(padapter
)) {
9115 if (pmlmeext
->cur_ch_offset
== HAL_PRIME_CHNL_OFFSET_UPPER
)
9117 else if (pmlmeext
->cur_ch_offset
== HAL_PRIME_CHNL_OFFSET_LOWER
)
9120 H2C_Parameter
[1] = chnl
;
9121 } else { /* check if HS link is exists */
9123 if (BT_Operation(padapter
))
9124 H2C_Parameter
[1] = pBtMgnt
->BTChannel
;
9126 H2C_Parameter
[1] = pmlmeext
->cur_channel
;
9129 if (BTDM_IsHT40(padapter
))
9130 H2C_Parameter
[2] = 0x30;
9132 H2C_Parameter
[2] = 0x20;
9134 FillH2CCmd(padapter
, 0x19, 3, H2C_Parameter
);
9137 u8
BTDM_IsWifiConnectionExist(struct rtw_adapter
*padapter
)
9141 if (BTHCI_HsConnectionEstablished(padapter
))
9144 if (check_fwstate(&padapter
->mlmepriv
, WIFI_ASOC_STATE
) == true)
9151 struct rtw_adapter
*padapter
,
9159 u8 H2C_Parameter
[5] = {0};
9161 if (rtl8723a_BT_using_antenna_1(padapter
)) {
9162 if ((!check_fwstate(&padapter
->mlmepriv
, WIFI_STATION_STATE
)) &&
9163 (get_fwstate(&padapter
->mlmepriv
) != WIFI_NULL_STATE
)) {
9164 /* for softap mode */
9165 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9166 struct bt_coexist_8723a
*pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9167 u8 BtState
= pBtCoex
->c2hBtInfo
;
9169 if ((BtState
!= BT_INFO_STATE_NO_CONNECTION
) &&
9170 (BtState
!= BT_INFO_STATE_CONNECT_IDLE
)) {
9171 if (byte1
& BIT(4)) {
9183 H2C_Parameter
[0] = byte1
;
9184 H2C_Parameter
[1] = byte2
;
9185 H2C_Parameter
[2] = byte3
;
9186 H2C_Parameter
[3] = byte4
;
9187 H2C_Parameter
[4] = byte5
;
9189 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], FW write 0x3a(5bytes) = 0x%02x%08x\n",
9191 H2C_Parameter
[1]<<24|H2C_Parameter
[2]<<16|H2C_Parameter
[3]<<8|H2C_Parameter
[4]));
9193 FillH2CCmd(padapter
, 0x3a, 5, H2C_Parameter
);
9196 void BTDM_QueryBtInformation(struct rtw_adapter
*padapter
)
9198 u8 H2C_Parameter
[1] = {0};
9199 struct hal_data_8723a
*pHalData
;
9200 struct bt_coexist_8723a
*pBtCoex
;
9202 pHalData
= GET_HAL_DATA(padapter
);
9203 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9205 if (!rtl8723a_BT_enabled(padapter
)) {
9206 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_DISABLED
;
9207 pBtCoex
->bC2hBtInfoReqSent
= false;
9211 if (pBtCoex
->c2hBtInfo
== BT_INFO_STATE_DISABLED
)
9212 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_NO_CONNECTION
;
9214 if (pBtCoex
->bC2hBtInfoReqSent
== true)
9215 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], didn't recv previous BtInfo report!\n"));
9217 pBtCoex
->bC2hBtInfoReqSent
= true;
9219 H2C_Parameter
[0] |= BIT(0); /* trigger */
9221 /*RTPRINT(FBT, BT_TRACE, ("[BTCoex], Query Bt information, write 0x38 = 0x%x\n", */
9222 /*H2C_Parameter[0])); */
9224 FillH2CCmd(padapter
, 0x38, 1, H2C_Parameter
);
9227 void BTDM_SetSwRfRxLpfCorner(struct rtw_adapter
*padapter
, u8 type
)
9229 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9231 if (BT_RF_RX_LPF_CORNER_SHRINK
== type
) {
9232 /* Shrink RF Rx LPF corner */
9233 RTPRINT(FBT
, BT_TRACE
, ("Shrink RF Rx LPF corner!!\n"));
9234 PHY_SetRFReg(padapter
, PathA
, 0x1e, bRFRegOffsetMask
, 0xf0ff7);
9235 pHalData
->bt_coexist
.bSWCoexistAllOff
= false;
9236 } else if (BT_RF_RX_LPF_CORNER_RESUME
== type
) {
9237 /* Resume RF Rx LPF corner */
9238 RTPRINT(FBT
, BT_TRACE
, ("Resume RF Rx LPF corner!!\n"));
9239 PHY_SetRFReg(padapter
, PathA
, 0x1e, bRFRegOffsetMask
, pHalData
->bt_coexist
.BtRfRegOrigin1E
);
9244 BTDM_SetSwPenaltyTxRateAdaptive(
9245 struct rtw_adapter
*padapter
,
9249 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9252 tmpU1
= rtl8723au_read8(padapter
, 0x4fd);
9254 if (BT_TX_RATE_ADAPTIVE_LOW_PENALTY
== raType
) {
9256 pHalData
->bt_coexist
.bSWCoexistAllOff
= false;
9257 } else if (BT_TX_RATE_ADAPTIVE_NORMAL
== raType
) {
9261 rtl8723au_write8(padapter
, 0x4fd, tmpU1
);
9264 void BTDM_SetFwDecBtPwr(struct rtw_adapter
*padapter
, u8 bDecBtPwr
)
9266 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9267 u8 H2C_Parameter
[1] = {0};
9269 H2C_Parameter
[0] = 0;
9272 H2C_Parameter
[0] |= BIT(1);
9273 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
9276 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], decrease Bt Power : %s, write 0x21 = 0x%x\n",
9277 (bDecBtPwr
? "Yes!!" : "No!!"), H2C_Parameter
[0]));
9279 FillH2CCmd(padapter
, 0x21, 1, H2C_Parameter
);
9282 u8
BTDM_BtProfileSupport(struct rtw_adapter
*padapter
)
9285 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9286 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9287 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9289 if (pBtMgnt
->bSupportProfile
&&
9290 !pHalData
->bt_coexist
.halCoex8723
.bForceFwBtInfo
)
9296 static void BTDM_AdjustForBtOperation8723A(struct rtw_adapter
*padapter
)
9298 /* BTDM_2AntAdjustForBtOperation8723(padapter); */
9301 static void BTDM_FwC2hBtRssi8723A(struct rtw_adapter
*padapter
, u8
*tmpBuf
)
9303 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9304 u8 percent
= 0, u1tmp
= 0;
9307 percent
= u1tmp
*2+10;
9309 pHalData
->bt_coexist
.halCoex8723
.btRssi
= percent
;
9310 /*RTPRINT(FBT, BT_TRACE, ("[BTC2H], BT RSSI =%d\n", percent)); */
9314 rtl8723a_fw_c2h_BT_info(struct rtw_adapter
*padapter
, u8
*tmpBuf
, u8 length
)
9316 struct hal_data_8723a
*pHalData
;
9317 struct bt_30info
*pBTInfo
;
9318 struct bt_mgnt
*pBtMgnt
;
9319 struct bt_coexist_8723a
*pBtCoex
;
9322 pHalData
= GET_HAL_DATA(padapter
);
9323 pBTInfo
= GET_BT_INFO(padapter
);
9324 pBtMgnt
= &pBTInfo
->BtMgnt
;
9325 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9327 pBtCoex
->bC2hBtInfoReqSent
= false;
9329 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], BT info[%d]=[", length
));
9331 pBtCoex
->btRetryCnt
= 0;
9332 for (i
= 0; i
< length
; i
++) {
9335 pBtCoex
->c2hBtInfoOriginal
= tmpBuf
[i
];
9338 pBtCoex
->btRetryCnt
= tmpBuf
[i
];
9341 BTDM_FwC2hBtRssi8723A(padapter
, &tmpBuf
[i
]);
9344 pBtCoex
->btInfoExt
= tmpBuf
[i
]&BIT(0);
9349 RTPRINT(FBT
, BT_TRACE
, ("0x%02x]\n", tmpBuf
[i
]));
9351 RTPRINT(FBT
, BT_TRACE
, ("0x%02x, ", tmpBuf
[i
]));
9353 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], BT RSSI =%d\n", pBtCoex
->btRssi
));
9354 if (pBtCoex
->btInfoExt
)
9355 RTPRINT(FBT
, BT_TRACE
, ("[BTC2H], pBtCoex->btInfoExt =%x\n", pBtCoex
->btInfoExt
));
9357 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9358 BTDM_1AntFwC2hBtInfo8723A(padapter
);
9360 BTDM_2AntFwC2hBtInfo8723A(padapter
);
9362 if (pBtMgnt
->ExtConfig
.bManualControl
) {
9363 RTPRINT(FBT
, BT_TRACE
, ("%s: Action Manual control!!\n", __func__
));
9367 btdm_BTCoexist8723AHandler(padapter
);
9370 static void BTDM_Display8723ABtCoexInfo(struct rtw_adapter
*padapter
)
9372 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9373 struct bt_coexist_8723a
*pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9374 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9375 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9376 u8 u1Tmp
, u1Tmp1
, u1Tmp2
, i
, btInfoExt
, psTdmaCase
= 0;
9380 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n ============[BT Coexist info]============");
9381 DCMD_Printf(btCoexDbgBuf
);
9383 if (!rtl8723a_BT_coexist(padapter
)) {
9384 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n BT not exists !!!");
9385 DCMD_Printf(btCoexDbgBuf
);
9389 antNum
= btdm_BtWifiAntNum(padapter
);
9390 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d/%d ", "Ant mechanism PG/Now run :", \
9391 ((pHalData
->bt_coexist
.BT_Ant_Num
== Ant_x2
) ? 2 : 1), ((antNum
== Ant_x2
) ? 2 : 1));
9392 DCMD_Printf(btCoexDbgBuf
);
9394 if (pBtMgnt
->ExtConfig
.bManualControl
) {
9395 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s", "[Action Manual control]!!");
9396 DCMD_Printf(btCoexDbgBuf
);
9398 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \
9399 ((pBtMgnt
->bSupportProfile
) ? "Yes" : "No"), pBtMgnt
->ExtConfig
.HCIExtensionVer
);
9400 DCMD_Printf(btCoexDbgBuf
);
9403 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\n %-35s = / %d", "Dot11 channel / BT channel", \
9404 pBtMgnt
->BTChannel
);
9405 DCMD_Printf(btCoexDbgBuf
);
9407 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\n %-35s = %d / %d / %d", "Wifi/BT/HS rssi", \
9408 BTDM_GetRxSS(padapter
),
9409 pHalData
->bt_coexist
.halCoex8723
.btRssi
,
9410 pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
);
9411 DCMD_Printf(btCoexDbgBuf
);
9413 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9414 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\n %-35s = %s / %s ", "WIfi status",
9415 ((BTDM_Legacy(padapter
)) ? "Legacy" : (((BTDM_IsHT40(padapter
)) ? "HT40" : "HT20"))),
9416 ((!BTDM_IsWifiBusy(padapter
)) ? "idle" : ((BTDM_IsWifiUplink(padapter
)) ? "uplink" : "downlink")));
9417 DCMD_Printf(btCoexDbgBuf
);
9419 if (pBtMgnt
->bSupportProfile
) {
9420 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP",
9421 ((BTHCI_CheckProfileExist(padapter
, BT_PROFILE_SCO
)) ? 1 : 0),
9422 ((BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
)) ? 1 : 0),
9423 ((BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) ? 1 : 0),
9424 ((BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) ? 1 : 0));
9425 DCMD_Printf(btCoexDbgBuf
);
9427 for (i
= 0; i
< pBtMgnt
->ExtConfig
.NumberOfHandle
; i
++) {
9428 if (pBtMgnt
->ExtConfig
.HCIExtensionVer
>= 1) {
9429 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %s/ %s/ %s", "Bt link type/spec/role",
9430 BtProfileString
[pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
],
9431 BtSpecString
[pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
],
9432 BtLinkRoleString
[pBtMgnt
->ExtConfig
.linkInfo
[i
].linkRole
]);
9433 DCMD_Printf(btCoexDbgBuf
);
9435 btInfoExt
= pHalData
->bt_coexist
.halCoex8723
.btInfoExt
;
9436 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %s", "A2DP rate", \
9437 (btInfoExt
& BIT(0)) ?
9438 "Basic rate" : "EDR rate");
9439 DCMD_Printf(btCoexDbgBuf
);
9441 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %s/ %s", "Bt link type/spec", \
9442 BtProfileString
[pBtMgnt
->ExtConfig
.linkInfo
[i
].BTProfile
],
9443 BtSpecString
[pBtMgnt
->ExtConfig
.linkInfo
[i
].BTCoreSpec
]);
9444 DCMD_Printf(btCoexDbgBuf
);
9451 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9452 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s", "============[Sw BT Coex mechanism]============");
9453 DCMD_Printf(btCoexDbgBuf
);
9454 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d ", "AGC Table", \
9455 pBtCoex
->btdm2Ant
.bCurAgcTableEn
);
9456 DCMD_Printf(btCoexDbgBuf
);
9457 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d ", "ADC Backoff", \
9458 pBtCoex
->btdm2Ant
.bCurAdcBackOff
);
9459 DCMD_Printf(btCoexDbgBuf
);
9460 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d ", "Low penalty RA", \
9461 pBtCoex
->btdm2Ant
.bCurLowPenaltyRa
);
9462 DCMD_Printf(btCoexDbgBuf
);
9463 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d ", "RF Rx LPF Shrink", \
9464 pBtCoex
->btdm2Ant
.bCurRfRxLpfShrink
);
9465 DCMD_Printf(btCoexDbgBuf
);
9467 u4Tmp
[0] = PHY_QueryRFReg(padapter
, PathA
, 0x1e, 0xff0);
9468 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x/ 0x%x", "RF-A, 0x1e[11:4]/original val", \
9469 u4Tmp
[0], pHalData
->bt_coexist
.BtRfRegOrigin1E
);
9470 DCMD_Printf(btCoexDbgBuf
);
9473 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9474 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s", "============[Fw BT Coex mechanism]============");
9475 DCMD_Printf(btCoexDbgBuf
);
9477 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9478 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9479 psTdmaCase
= pHalData
->bt_coexist
.halCoex8723
.btdm1Ant
.curPsTdma
;
9481 psTdmaCase
= pHalData
->bt_coexist
.halCoex8723
.btdm2Ant
.curPsTdma
;
9482 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA(0x3a)", \
9483 pHalData
->bt_coexist
.fw3aVal
[0], pHalData
->bt_coexist
.fw3aVal
[1],
9484 pHalData
->bt_coexist
.fw3aVal
[2], pHalData
->bt_coexist
.fw3aVal
[3],
9485 pHalData
->bt_coexist
.fw3aVal
[4], psTdmaCase
);
9486 DCMD_Printf(btCoexDbgBuf
);
9488 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d ", "Decrease Bt Power", \
9489 pBtCoex
->btdm2Ant
.bCurDecBtPwr
);
9490 DCMD_Printf(btCoexDbgBuf
);
9492 u1Tmp
= rtl8723au_read8(padapter
, 0x778);
9493 u1Tmp1
= rtl8723au_read8(padapter
, 0x783);
9494 u1Tmp2
= rtl8723au_read8(padapter
, 0x796);
9495 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \
9496 u1Tmp
, u1Tmp1
, u1Tmp2
);
9497 DCMD_Printf(btCoexDbgBuf
);
9499 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9500 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x / 0x%x", "Sw DacSwing Ctrl/Val", \
9501 pBtCoex
->btdm2Ant
.bCurDacSwingOn
, pBtCoex
->btdm2Ant
.curDacSwingLvl
);
9502 DCMD_Printf(btCoexDbgBuf
);
9504 u4Tmp
[0] = rtl8723au_read32(padapter
, 0x880);
9505 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "0x880", \
9507 DCMD_Printf(btCoexDbgBuf
);
9510 if (!pBtMgnt
->ExtConfig
.bManualControl
) {
9511 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s", "============[Hw BT Coex mechanism]============");
9512 DCMD_Printf(btCoexDbgBuf
);
9515 u1Tmp
= rtl8723au_read8(padapter
, 0x40);
9516 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "0x40", \
9518 DCMD_Printf(btCoexDbgBuf
);
9520 u4Tmp
[0] = rtl8723au_read32(padapter
, 0x550);
9521 u1Tmp
= rtl8723au_read8(padapter
, 0x522);
9522 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x/0x%x", "0x550(bcn contrl)/0x522", \
9524 DCMD_Printf(btCoexDbgBuf
);
9526 u4Tmp
[0] = rtl8723au_read32(padapter
, 0x484);
9527 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \
9529 DCMD_Printf(btCoexDbgBuf
);
9531 u4Tmp
[0] = rtl8723au_read32(padapter
, 0x50);
9532 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "0xc50(dig)", \
9534 DCMD_Printf(btCoexDbgBuf
);
9536 u4Tmp
[0] = rtl8723au_read32(padapter
, 0xda0);
9537 u4Tmp
[1] = rtl8723au_read32(padapter
, 0xda4);
9538 u4Tmp
[2] = rtl8723au_read32(padapter
, 0xda8);
9539 u4Tmp
[3] = rtl8723au_read32(padapter
, 0xdac);
9540 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \
9541 u4Tmp
[0], u4Tmp
[1], u4Tmp
[2], u4Tmp
[3]);
9542 DCMD_Printf(btCoexDbgBuf
);
9544 u4Tmp
[0] = rtl8723au_read32(padapter
, 0x6c0);
9545 u4Tmp
[1] = rtl8723au_read32(padapter
, 0x6c4);
9546 u4Tmp
[2] = rtl8723au_read32(padapter
, 0x6c8);
9547 u1Tmp
= rtl8723au_read8(padapter
, 0x6cc);
9548 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \
9549 u4Tmp
[0], u4Tmp
[1], u4Tmp
[2], u1Tmp
);
9550 DCMD_Printf(btCoexDbgBuf
);
9552 /* u4Tmp = rtl8723au_read32(padapter, 0x770); */
9553 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d / %d", "0x770(Hi pri Rx[31:16]/Tx[15:0])", \
9554 pHalData
->bt_coexist
.halCoex8723
.highPriorityRx
,
9555 pHalData
->bt_coexist
.halCoex8723
.highPriorityTx
);
9556 DCMD_Printf(btCoexDbgBuf
);
9557 /* u4Tmp = rtl8723au_read32(padapter, 0x774); */
9558 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = %d / %d", "0x774(Lo pri Rx[31:16]/Tx[15:0])", \
9559 pHalData
->bt_coexist
.halCoex8723
.lowPriorityRx
,
9560 pHalData
->bt_coexist
.halCoex8723
.lowPriorityTx
);
9561 DCMD_Printf(btCoexDbgBuf
);
9563 /* Tx mgnt queue hang or not, 0x41b should = 0xf, ex: 0xd ==>hang */
9564 u1Tmp
= rtl8723au_read8(padapter
, 0x41b);
9565 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "0x41b (hang chk == 0xf)", \
9567 DCMD_Printf(btCoexDbgBuf
);
9568 rsprintf(btCoexDbgBuf
, BT_TMP_BUF_SIZE
, "\r\n %-35s = 0x%x", "lastHMEBoxNum", \
9569 pHalData
->LastHMEBoxNum
);
9570 DCMD_Printf(btCoexDbgBuf
);
9574 BTDM_8723ASignalCompensation(struct rtw_adapter
*padapter
,
9575 u8
*rssi_wifi
, u8
*rssi_bt
)
9577 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9578 BTDM_1AntSignalCompensation(padapter
, rssi_wifi
, rssi_bt
);
9581 static void BTDM_8723AInit(struct rtw_adapter
*padapter
)
9583 if (btdm_BtWifiAntNum(padapter
) == Ant_x2
)
9584 BTDM_2AntParaInit(padapter
);
9586 BTDM_1AntParaInit(padapter
);
9589 static void BTDM_HWCoexAllOff8723A(struct rtw_adapter
*padapter
)
9591 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9592 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9594 if (pBtMgnt
->ExtConfig
.bManualControl
)
9597 if (btdm_BtWifiAntNum(padapter
) == Ant_x2
)
9598 BTDM_2AntHwCoexAllOff8723A(padapter
);
9601 static void BTDM_FWCoexAllOff8723A(struct rtw_adapter
*padapter
)
9603 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9604 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9606 if (pBtMgnt
->ExtConfig
.bManualControl
)
9609 if (btdm_BtWifiAntNum(padapter
) == Ant_x2
)
9610 BTDM_2AntFwCoexAllOff8723A(padapter
);
9613 static void BTDM_SWCoexAllOff8723A(struct rtw_adapter
*padapter
)
9615 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9616 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9618 if (pBtMgnt
->ExtConfig
.bManualControl
)
9621 if (btdm_BtWifiAntNum(padapter
) == Ant_x2
)
9622 BTDM_2AntSwCoexAllOff8723A(padapter
);
9626 BTDM_Set8723ABtCoexCurrAntNum(struct rtw_adapter
*padapter
, u8 antNum
)
9628 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9629 struct bt_coexist_8723a
*pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9632 pBtCoex
->TotalAntNum
= Ant_x1
;
9633 else if (antNum
== 2)
9634 pBtCoex
->TotalAntNum
= Ant_x2
;
9637 void rtl8723a_BT_lps_leave(struct rtw_adapter
*padapter
)
9639 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9640 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9642 if (pBtMgnt
->ExtConfig
.bManualControl
)
9645 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9646 BTDM_1AntLpsLeave(padapter
);
9649 static void BTDM_ForHalt8723A(struct rtw_adapter
*padapter
)
9651 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9652 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9654 if (pBtMgnt
->ExtConfig
.bManualControl
)
9657 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9658 BTDM_1AntForHalt(padapter
);
9661 static void BTDM_WifiScanNotify8723A(struct rtw_adapter
*padapter
, u8 scanType
)
9663 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9664 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9666 if (pBtMgnt
->ExtConfig
.bManualControl
)
9669 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9670 BTDM_1AntWifiScanNotify(padapter
, scanType
);
9674 BTDM_WifiAssociateNotify8723A(struct rtw_adapter
*padapter
, u8 action
)
9676 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9677 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9679 if (pBtMgnt
->ExtConfig
.bManualControl
)
9682 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9683 BTDM_1AntWifiAssociateNotify(padapter
, action
);
9687 BTDM_MediaStatusNotify8723A(struct rtw_adapter
*padapter
,
9688 enum rt_media_status mstatus
)
9690 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9691 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9693 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], MediaStatusNotify, %s\n",
9694 mstatus
?"connect":"disconnect"));
9696 BTDM_SetFwChnlInfo(padapter
, mstatus
);
9698 if (pBtMgnt
->ExtConfig
.bManualControl
)
9701 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9702 BTDM_1AntMediaStatusNotify(padapter
, mstatus
);
9705 static void BTDM_ForDhcp8723A(struct rtw_adapter
*padapter
)
9707 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9708 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9710 if (pBtMgnt
->ExtConfig
.bManualControl
)
9713 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9714 BTDM_1AntForDhcp(padapter
);
9717 bool rtl8723a_BT_using_antenna_1(struct rtw_adapter
*padapter
)
9719 if (btdm_BtWifiAntNum(padapter
) == Ant_x1
)
9725 static void BTDM_BTCoexist8723A(struct rtw_adapter
*padapter
)
9727 struct hal_data_8723a
*pHalData
;
9728 struct bt_30info
*pBTInfo
;
9729 struct bt_mgnt
*pBtMgnt
;
9730 struct bt_coexist_8723a
*pBtCoex
;
9732 pHalData
= GET_HAL_DATA(padapter
);
9733 pBTInfo
= GET_BT_INFO(padapter
);
9734 pBtMgnt
= &pBTInfo
->BtMgnt
;
9735 pBtCoex
= &pHalData
->bt_coexist
.halCoex8723
;
9737 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], beacon RSSI = 0x%x(%d)\n",
9738 pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
,
9739 pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
));
9741 btdm_BtHwCountersMonitor(padapter
);
9742 btdm_BtEnableDisableCheck8723A(padapter
);
9744 if (pBtMgnt
->ExtConfig
.bManualControl
) {
9745 RTPRINT(FBT
, BT_TRACE
, ("%s: Action Manual control!!\n", __func__
));
9749 if (pBtCoex
->bC2hBtInfoReqSent
) {
9750 if (!rtl8723a_BT_enabled(padapter
)) {
9751 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_DISABLED
;
9753 if (pBtCoex
->c2hBtInfo
== BT_INFO_STATE_DISABLED
)
9754 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_NO_CONNECTION
;
9757 btdm_BTCoexist8723AHandler(padapter
);
9758 } else if (!rtl8723a_BT_enabled(padapter
)) {
9759 pBtCoex
->c2hBtInfo
= BT_INFO_STATE_DISABLED
;
9760 btdm_BTCoexist8723AHandler(padapter
);
9763 BTDM_QueryBtInformation(padapter
);
9766 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtc8723.c ===== */
9768 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.c ===== */
9770 /* local function start with btdm_ */
9771 /* extern function start with BTDM_ */
9773 static void BTDM_SetAntenna(struct rtw_adapter
*padapter
, u8 who
)
9779 struct rtw_adapter
*padapter
,
9785 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9786 u8 H2C_Parameter
[3] = {0};
9788 if (pHalData
->bt_coexist
.BT_Ant_Num
!= Ant_x1
)
9791 H2C_Parameter
[2] = 0;
9792 H2C_Parameter
[1] = 0;
9793 H2C_Parameter
[0] = 0;
9796 H2C_Parameter
[2] |= 0x02; /* BIT1 */
9797 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
9799 pHalData
->bt_coexist
.bInterruptOn
= bInterruptOn
;
9802 H2C_Parameter
[2] |= 0x10; /* BIT4 */
9803 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
9805 pHalData
->bt_coexist
.bSingleAntOn
= bSingleAntOn
;
9808 H2C_Parameter
[2] |= 0x20; /* BIT5 */
9809 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
9811 pHalData
->bt_coexist
.bMultiNAVOn
= bMultiNAVOn
;
9813 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], SingleAntenna =[%s:%s:%s], write 0xe = 0x%x\n",
9814 bSingleAntOn
?"ON":"OFF", bInterruptOn
?"ON":"OFF", bMultiNAVOn
?"ON":"OFF",
9815 H2C_Parameter
[0]<<16|H2C_Parameter
[1]<<8|H2C_Parameter
[2]));
9818 void BTDM_CheckBTIdleChange1Ant(struct rtw_adapter
*padapter
)
9820 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
9821 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
9822 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9823 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
9824 u8 stateChange
= false;
9825 u32 BT_Polling
, Ratio_Act
, Ratio_STA
;
9826 u32 BT_Active
, BT_State
;
9827 u32 regBTActive
= 0, regBTState
= 0, regBTPolling
= 0;
9829 if (!rtl8723a_BT_coexist(padapter
))
9831 if (pBtMgnt
->ExtConfig
.bManualControl
)
9833 if (pHalData
->bt_coexist
.BT_CoexistType
!= BT_CSR_BC8
)
9835 if (pHalData
->bt_coexist
.BT_Ant_Num
!= Ant_x1
)
9838 /* The following we only consider CSR BC8 and fw version should be >= 62 */
9839 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], FirmwareVersion = 0x%x(%d)\n",
9840 pHalData
->FirmwareVersion
, pHalData
->FirmwareVersion
));
9841 regBTActive
= REG_BT_ACTIVE
;
9842 regBTState
= REG_BT_STATE
;
9843 if (pHalData
->FirmwareVersion
>= FW_VER_BT_REG1
)
9844 regBTPolling
= REG_BT_POLLING1
;
9846 regBTPolling
= REG_BT_POLLING
;
9848 BT_Active
= rtl8723au_read32(padapter
, regBTActive
);
9849 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT_Active(0x%x) =%x\n", regBTActive
, BT_Active
));
9850 BT_Active
= BT_Active
& 0x00ffffff;
9852 BT_State
= rtl8723au_read32(padapter
, regBTState
);
9853 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT_State(0x%x) =%x\n", regBTState
, BT_State
));
9854 BT_State
= BT_State
& 0x00ffffff;
9856 BT_Polling
= rtl8723au_read32(padapter
, regBTPolling
);
9857 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT_Polling(0x%x) =%x\n", regBTPolling
, BT_Polling
));
9859 if (BT_Active
== 0xffffffff && BT_State
== 0xffffffff && BT_Polling
== 0xffffffff)
9861 if (BT_Polling
== 0)
9864 Ratio_Act
= BT_Active
*1000/BT_Polling
;
9865 Ratio_STA
= BT_State
*1000/BT_Polling
;
9867 pHalData
->bt_coexist
.Ratio_Tx
= Ratio_Act
;
9868 pHalData
->bt_coexist
.Ratio_PRI
= Ratio_STA
;
9870 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], Ratio_Act =%d\n", Ratio_Act
));
9871 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], Ratio_STA =%d\n", Ratio_STA
));
9873 if (Ratio_STA
< 60 && Ratio_Act
< 500) { /* BT PAN idle */
9874 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_PAN_IDLE
;
9875 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_DOWNLINK
;
9876 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_UPLINK
;
9878 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_IDLE
;
9881 /* Check if BT PAN (under BT 2.1) is uplink or downlink */
9882 if ((Ratio_Act
/Ratio_STA
) < 2) {
9884 pHalData
->bt_coexist
.BT21TrafficStatistics
.bTxBusyTraffic
= true;
9885 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_PAN_UPLINK
;
9886 pHalData
->bt_coexist
.BT21TrafficStatistics
.bRxBusyTraffic
= false;
9887 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_DOWNLINK
;
9889 /* BT PAN downlink */
9890 pHalData
->bt_coexist
.BT21TrafficStatistics
.bTxBusyTraffic
= false;
9891 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_UPLINK
;
9892 pHalData
->bt_coexist
.BT21TrafficStatistics
.bRxBusyTraffic
= true;
9893 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_PAN_DOWNLINK
;
9896 /* BT PAN downlink */
9897 pHalData
->bt_coexist
.BT21TrafficStatistics
.bTxBusyTraffic
= false;
9898 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_PAN_UPLINK
;
9899 pHalData
->bt_coexist
.BT21TrafficStatistics
.bRxBusyTraffic
= true;
9900 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_PAN_DOWNLINK
;
9904 /* Check BT is idle or not */
9905 if (pBtMgnt
->ExtConfig
.NumberOfHandle
== 0 &&
9906 pBtMgnt
->ExtConfig
.NumberOfSCO
== 0) {
9907 pBtMgnt
->ExtConfig
.bBTBusy
= false;
9908 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_IDLE
;
9910 if (Ratio_STA
< 60) {
9911 pBtMgnt
->ExtConfig
.bBTBusy
= false;
9912 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_IDLE
;
9914 pBtMgnt
->ExtConfig
.bBTBusy
= true;
9915 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_IDLE
;
9919 if (pBtMgnt
->ExtConfig
.NumberOfHandle
== 0 &&
9920 pBtMgnt
->ExtConfig
.NumberOfSCO
== 0) {
9921 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_RSSI_LOW
;
9922 pBtMgnt
->ExtConfig
.MIN_BT_RSSI
= 0;
9923 BTDM_SetAntenna(padapter
, BTDM_ANT_BT_IDLE
);
9925 if (pBtMgnt
->ExtConfig
.MIN_BT_RSSI
<= -5) {
9926 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT_RSSI_LOW
;
9927 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], core stack notify bt rssi Low\n"));
9929 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT_RSSI_LOW
;
9930 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], core stack notify bt rssi Normal\n"));
9934 if (pHalData
->bt_coexist
.bBTBusyTraffic
!= pBtMgnt
->ExtConfig
.bBTBusy
) {
9935 /* BT idle or BT non-idle */
9936 pHalData
->bt_coexist
.bBTBusyTraffic
= pBtMgnt
->ExtConfig
.bBTBusy
;
9941 if (!pBtMgnt
->ExtConfig
.bBTBusy
)
9942 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT is idle or disable\n"));
9944 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT is non-idle\n"));
9946 if (!pBtMgnt
->ExtConfig
.bBTBusy
) {
9947 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT is idle or disable\n"));
9948 if (check_fwstate(&padapter
->mlmepriv
, WIFI_UNDER_LINKING
|WIFI_SITE_MONITOR
) == true)
9949 BTDM_SetAntenna(padapter
, BTDM_ANT_WIFI
);
9953 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr1Ant.c ===== */
9955 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.c ===== */
9957 /* local function start with btdm_ */
9960 /* In the following, FW should be done before SW mechanism. */
9961 /* BTDM_Balance(), BTDM_DiminishWiFi(), BT_NAV() should be done */
9962 /* before BTDM_AGCTable(), BTDM_BBBackOffLevel(), btdm_DacSwing(). */
9964 /* extern function start with BTDM_ */
9968 struct rtw_adapter
*padapter
,
9975 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
9976 u8 H2C_Parameter
[3] = {0};
9978 if (pHalData
->bt_coexist
.BT_Ant_Num
!= Ant_x2
)
9981 if ((pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_BT_RSSI_LOW
) &&
9982 (DACSwingLevel
== 0x20)) {
9983 RTPRINT(FBT
, BT_TRACE
, ("[BT]DiminishWiFi 0x20 original, but set 0x18 for Low RSSI!\n"));
9984 DACSwingLevel
= 0x18;
9987 H2C_Parameter
[2] = 0;
9988 H2C_Parameter
[1] = DACSwingLevel
;
9989 H2C_Parameter
[0] = 0;
9991 H2C_Parameter
[2] |= 0x01; /* BIT0 */
9993 H2C_Parameter
[2] |= 0x02; /* BIT1 */
9994 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
9997 H2C_Parameter
[2] |= 0x08; /* BIT3 */
9998 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
10001 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], bDACOn = %s, bInterruptOn = %s, write 0xe = 0x%x\n",
10002 bDACOn
?"ON":"OFF", bInterruptOn
?"ON":"OFF",
10003 H2C_Parameter
[0]<<16|H2C_Parameter
[1]<<8|H2C_Parameter
[2]));
10004 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], bNAVOn = %s\n",
10005 bNAVOn
?"ON":"OFF"));
10008 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtcCsr2Ant.c ===== */
10010 /* ===== Below this line is sync from SD7 driver HAL/BTCoexist/HalBtCoexist.c ===== */
10012 /* local function */
10013 static void btdm_ResetFWCoexState(struct rtw_adapter
*padapter
)
10015 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10017 pHalData
->bt_coexist
.CurrentState
= 0;
10018 pHalData
->bt_coexist
.PreviousState
= 0;
10021 static void btdm_InitBtCoexistDM(struct rtw_adapter
*padapter
)
10023 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10025 /* 20100415 Joseph: Restore RF register 0x1E and 0x1F value for further usage. */
10026 pHalData
->bt_coexist
.BtRfRegOrigin1E
= PHY_QueryRFReg(padapter
, PathA
, RF_RCK1
, bRFRegOffsetMask
);
10027 pHalData
->bt_coexist
.BtRfRegOrigin1F
= PHY_QueryRFReg(padapter
, PathA
, RF_RCK2
, 0xf0);
10029 pHalData
->bt_coexist
.CurrentState
= 0;
10030 pHalData
->bt_coexist
.PreviousState
= 0;
10032 BTDM_8723AInit(padapter
);
10033 pHalData
->bt_coexist
.bInitlized
= true;
10037 /* extern function */
10039 void BTDM_CheckAntSelMode(struct rtw_adapter
*padapter
)
10043 void BTDM_FwC2hBtRssi(struct rtw_adapter
*padapter
, u8
*tmpBuf
)
10045 BTDM_FwC2hBtRssi8723A(padapter
, tmpBuf
);
10048 void BTDM_DisplayBtCoexInfo(struct rtw_adapter
*padapter
)
10050 BTDM_Display8723ABtCoexInfo(padapter
);
10053 void BTDM_RejectAPAggregatedPacket(struct rtw_adapter
*padapter
, u8 bReject
)
10057 u8
BTDM_IsHT40(struct rtw_adapter
*padapter
)
10060 enum ht_channel_width bw
;
10062 bw
= padapter
->mlmeextpriv
.cur_bwmode
;
10064 if (bw
== HT_CHANNEL_WIDTH_20
)
10066 else if (bw
== HT_CHANNEL_WIDTH_40
)
10072 u8
BTDM_Legacy(struct rtw_adapter
*padapter
)
10074 struct mlme_ext_priv
*pmlmeext
;
10075 u8 isLegacy
= false;
10077 pmlmeext
= &padapter
->mlmeextpriv
;
10078 if ((pmlmeext
->cur_wireless_mode
== WIRELESS_11B
) ||
10079 (pmlmeext
->cur_wireless_mode
== WIRELESS_11G
) ||
10080 (pmlmeext
->cur_wireless_mode
== WIRELESS_11BG
))
10086 void BTDM_CheckWiFiState(struct rtw_adapter
*padapter
)
10088 struct hal_data_8723a
*pHalData
;
10089 struct mlme_priv
*pmlmepriv
;
10090 struct bt_30info
*pBTInfo
;
10091 struct bt_mgnt
*pBtMgnt
;
10093 pHalData
= GET_HAL_DATA(padapter
);
10094 pmlmepriv
= &padapter
->mlmepriv
;
10095 pBTInfo
= GET_BT_INFO(padapter
);
10096 pBtMgnt
= &pBTInfo
->BtMgnt
;
10098 if (pmlmepriv
->LinkDetectInfo
.bBusyTraffic
) {
10099 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_IDLE
;
10101 if (pmlmepriv
->LinkDetectInfo
.bTxBusyTraffic
)
10102 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_UPLINK
;
10104 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_UPLINK
;
10106 if (pmlmepriv
->LinkDetectInfo
.bRxBusyTraffic
)
10107 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_DOWNLINK
;
10109 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_DOWNLINK
;
10111 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_IDLE
;
10112 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_UPLINK
;
10113 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_DOWNLINK
;
10116 if (BTDM_Legacy(padapter
)) {
10117 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_LEGACY
;
10118 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_HT20
;
10119 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_HT40
;
10121 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_LEGACY
;
10122 if (BTDM_IsHT40(padapter
)) {
10123 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_HT40
;
10124 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_HT20
;
10126 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_HT20
;
10127 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_HT40
;
10131 if (pBtMgnt
->BtOperationOn
)
10132 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_BT30
;
10134 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_BT30
;
10137 s32
BTDM_GetRxSS(struct rtw_adapter
*padapter
)
10139 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
10140 struct mlme_priv
*pmlmepriv
;
10141 struct hal_data_8723a
*pHalData
;
10142 s32 UndecoratedSmoothedPWDB
= 0;
10144 pmlmepriv
= &padapter
->mlmepriv
;
10145 pHalData
= GET_HAL_DATA(padapter
);
10147 if (check_fwstate(pmlmepriv
, _FW_LINKED
)) {
10148 UndecoratedSmoothedPWDB
= GET_UNDECORATED_AVERAGE_RSSI(padapter
);
10149 } else { /* associated entry pwdb */
10150 UndecoratedSmoothedPWDB
= pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
;
10151 /* pHalData->BT_EntryMinUndecoratedSmoothedPWDB */
10153 RTPRINT(FBT
, BT_TRACE
, ("BTDM_GetRxSS() = %d\n", UndecoratedSmoothedPWDB
));
10154 return UndecoratedSmoothedPWDB
;
10157 static s32
BTDM_GetRxBeaconSS(struct rtw_adapter
*padapter
)
10159 /*PMGNT_INFO pMgntInfo = &padapter->MgntInfo; */
10160 struct mlme_priv
*pmlmepriv
;
10161 struct hal_data_8723a
*pHalData
;
10162 s32 pwdbBeacon
= 0;
10164 pmlmepriv
= &padapter
->mlmepriv
;
10165 pHalData
= GET_HAL_DATA(padapter
);
10167 if (check_fwstate(pmlmepriv
, _FW_LINKED
)) {
10168 /* pwdbBeacon = pHalData->dmpriv.UndecoratedSmoothedBeacon; */
10169 pwdbBeacon
= pHalData
->dmpriv
.EntryMinUndecoratedSmoothedPWDB
;
10171 RTPRINT(FBT
, BT_TRACE
, ("BTDM_GetRxBeaconSS() = %d\n", pwdbBeacon
));
10175 /* Get beacon rssi state */
10176 u8
BTDM_CheckCoexBcnRssiState(struct rtw_adapter
*padapter
, u8 levelNum
,
10177 u8 RssiThresh
, u8 RssiThresh1
)
10179 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10180 s32 pwdbBeacon
= 0;
10181 u8 bcnRssiState
= 0;
10183 pwdbBeacon
= BTDM_GetRxBeaconSS(padapter
);
10185 if (levelNum
== 2) {
10186 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM
;
10188 if ((pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_LOW
) ||
10189 (pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_STAY_LOW
)) {
10190 if (pwdbBeacon
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10191 bcnRssiState
= BT_RSSI_STATE_HIGH
;
10192 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10193 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10194 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to High\n"));
10196 bcnRssiState
= BT_RSSI_STATE_STAY_LOW
;
10197 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state stay at Low\n"));
10200 if (pwdbBeacon
< RssiThresh
) {
10201 bcnRssiState
= BT_RSSI_STATE_LOW
;
10202 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10203 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10204 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to Low\n"));
10206 bcnRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10207 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state stay at High\n"));
10210 } else if (levelNum
== 3) {
10211 if (RssiThresh
> RssiThresh1
) {
10212 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON thresh error!!\n"));
10213 return pHalData
->bt_coexist
.preRssiStateBeacon
;
10216 if ((pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_LOW
) ||
10217 (pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_STAY_LOW
)) {
10218 if (pwdbBeacon
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10219 bcnRssiState
= BT_RSSI_STATE_MEDIUM
;
10220 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM
;
10221 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10222 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10223 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to Medium\n"));
10225 bcnRssiState
= BT_RSSI_STATE_STAY_LOW
;
10226 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state stay at Low\n"));
10228 } else if ((pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_MEDIUM
) ||
10229 (pHalData
->bt_coexist
.preRssiStateBeacon
== BT_RSSI_STATE_STAY_MEDIUM
)) {
10230 if (pwdbBeacon
>= (RssiThresh1
+BT_FW_COEX_THRESH_TOL
)) {
10231 bcnRssiState
= BT_RSSI_STATE_HIGH
;
10232 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10233 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10234 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM
;
10235 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to High\n"));
10236 } else if (pwdbBeacon
< RssiThresh
) {
10237 bcnRssiState
= BT_RSSI_STATE_LOW
;
10238 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10239 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10240 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM
;
10241 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to Low\n"));
10243 bcnRssiState
= BT_RSSI_STATE_STAY_MEDIUM
;
10244 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state stay at Medium\n"));
10247 if (pwdbBeacon
< RssiThresh1
) {
10248 bcnRssiState
= BT_RSSI_STATE_MEDIUM
;
10249 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_BEACON_MEDIUM
;
10250 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_HIGH
;
10251 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_BEACON_LOW
;
10252 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state switch to Medium\n"));
10254 bcnRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10255 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_BEACON state stay at High\n"));
10260 pHalData
->bt_coexist
.preRssiStateBeacon
= bcnRssiState
;
10262 return bcnRssiState
;
10265 u8
BTDM_CheckCoexRSSIState1(struct rtw_adapter
*padapter
, u8 levelNum
,
10266 u8 RssiThresh
, u8 RssiThresh1
)
10268 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10269 s32 UndecoratedSmoothedPWDB
= 0;
10270 u8 btRssiState
= 0;
10272 UndecoratedSmoothedPWDB
= BTDM_GetRxSS(padapter
);
10274 if (levelNum
== 2) {
10275 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM
;
10277 if ((pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_LOW
) ||
10278 (pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_STAY_LOW
)) {
10279 if (UndecoratedSmoothedPWDB
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10280 btRssiState
= BT_RSSI_STATE_HIGH
;
10281 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10282 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10283 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to High\n"));
10285 btRssiState
= BT_RSSI_STATE_STAY_LOW
;
10286 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state stay at Low\n"));
10289 if (UndecoratedSmoothedPWDB
< RssiThresh
) {
10290 btRssiState
= BT_RSSI_STATE_LOW
;
10291 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10292 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10293 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to Low\n"));
10295 btRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10296 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state stay at High\n"));
10299 } else if (levelNum
== 3) {
10300 if (RssiThresh
> RssiThresh1
) {
10301 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 thresh error!!\n"));
10302 return pHalData
->bt_coexist
.preRssiState1
;
10305 if ((pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_LOW
) ||
10306 (pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_STAY_LOW
)) {
10307 if (UndecoratedSmoothedPWDB
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10308 btRssiState
= BT_RSSI_STATE_MEDIUM
;
10309 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_MEDIUM
;
10310 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10311 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10312 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to Medium\n"));
10314 btRssiState
= BT_RSSI_STATE_STAY_LOW
;
10315 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state stay at Low\n"));
10317 } else if ((pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_MEDIUM
) ||
10318 (pHalData
->bt_coexist
.preRssiState1
== BT_RSSI_STATE_STAY_MEDIUM
)) {
10319 if (UndecoratedSmoothedPWDB
>= (RssiThresh1
+BT_FW_COEX_THRESH_TOL
)) {
10320 btRssiState
= BT_RSSI_STATE_HIGH
;
10321 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10322 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10323 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM
;
10324 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to High\n"));
10325 } else if (UndecoratedSmoothedPWDB
< RssiThresh
) {
10326 btRssiState
= BT_RSSI_STATE_LOW
;
10327 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10328 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10329 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM
;
10330 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to Low\n"));
10332 btRssiState
= BT_RSSI_STATE_STAY_MEDIUM
;
10333 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state stay at Medium\n"));
10336 if (UndecoratedSmoothedPWDB
< RssiThresh1
) {
10337 btRssiState
= BT_RSSI_STATE_MEDIUM
;
10338 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_1_MEDIUM
;
10339 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_HIGH
;
10340 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_1_LOW
;
10341 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state switch to Medium\n"));
10343 btRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10344 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI_1 state stay at High\n"));
10349 pHalData
->bt_coexist
.preRssiState1
= btRssiState
;
10351 return btRssiState
;
10354 u8
BTDM_CheckCoexRSSIState(struct rtw_adapter
*padapter
, u8 levelNum
,
10355 u8 RssiThresh
, u8 RssiThresh1
)
10357 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10358 s32 UndecoratedSmoothedPWDB
= 0;
10359 u8 btRssiState
= 0;
10361 UndecoratedSmoothedPWDB
= BTDM_GetRxSS(padapter
);
10363 if (levelNum
== 2) {
10364 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM
;
10366 if ((pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_LOW
) ||
10367 (pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_STAY_LOW
)) {
10368 if (UndecoratedSmoothedPWDB
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10369 btRssiState
= BT_RSSI_STATE_HIGH
;
10370 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_HIGH
;
10371 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_LOW
;
10372 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to High\n"));
10374 btRssiState
= BT_RSSI_STATE_STAY_LOW
;
10375 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state stay at Low\n"));
10378 if (UndecoratedSmoothedPWDB
< RssiThresh
) {
10379 btRssiState
= BT_RSSI_STATE_LOW
;
10380 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_LOW
;
10381 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_HIGH
;
10382 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to Low\n"));
10384 btRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10385 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state stay at High\n"));
10388 } else if (levelNum
== 3) {
10389 if (RssiThresh
> RssiThresh1
) {
10390 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI thresh error!!\n"));
10391 return pHalData
->bt_coexist
.preRssiState
;
10394 if ((pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_LOW
) ||
10395 (pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_STAY_LOW
)) {
10396 if (UndecoratedSmoothedPWDB
>= (RssiThresh
+BT_FW_COEX_THRESH_TOL
)) {
10397 btRssiState
= BT_RSSI_STATE_MEDIUM
;
10398 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_MEDIUM
;
10399 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_LOW
;
10400 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_HIGH
;
10401 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to Medium\n"));
10403 btRssiState
= BT_RSSI_STATE_STAY_LOW
;
10404 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state stay at Low\n"));
10406 } else if ((pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_MEDIUM
) ||
10407 (pHalData
->bt_coexist
.preRssiState
== BT_RSSI_STATE_STAY_MEDIUM
)) {
10408 if (UndecoratedSmoothedPWDB
>= (RssiThresh1
+BT_FW_COEX_THRESH_TOL
)) {
10409 btRssiState
= BT_RSSI_STATE_HIGH
;
10410 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_HIGH
;
10411 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_LOW
;
10412 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM
;
10413 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to High\n"));
10414 } else if (UndecoratedSmoothedPWDB
< RssiThresh
) {
10415 btRssiState
= BT_RSSI_STATE_LOW
;
10416 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_LOW
;
10417 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_HIGH
;
10418 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM
;
10419 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to Low\n"));
10421 btRssiState
= BT_RSSI_STATE_STAY_MEDIUM
;
10422 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state stay at Medium\n"));
10425 if (UndecoratedSmoothedPWDB
< RssiThresh1
) {
10426 btRssiState
= BT_RSSI_STATE_MEDIUM
;
10427 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_WIFI_RSSI_MEDIUM
;
10428 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_HIGH
;
10429 pHalData
->bt_coexist
.CurrentState
&= ~BT_COEX_STATE_WIFI_RSSI_LOW
;
10430 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state switch to Medium\n"));
10432 btRssiState
= BT_RSSI_STATE_STAY_HIGH
;
10433 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], RSSI state stay at High\n"));
10438 pHalData
->bt_coexist
.preRssiState
= btRssiState
;
10440 return btRssiState
;
10443 bool rtl8723a_BT_disable_EDCA_turbo(struct rtw_adapter
*padapter
)
10445 struct bt_mgnt
*pBtMgnt
;
10446 struct hal_data_8723a
*pHalData
;
10447 u8 bBtChangeEDCA
= false;
10448 u32 EDCA_BT_BE
= 0x5ea42b, cur_EDCA_reg
;
10451 pHalData
= GET_HAL_DATA(padapter
);
10452 pBtMgnt
= &pHalData
->BtInfo
.BtMgnt
;
10454 if (!rtl8723a_BT_coexist(padapter
)) {
10456 pHalData
->bt_coexist
.lastBtEdca
= 0;
10459 if (!((pBtMgnt
->bSupportProfile
) ||
10460 (pHalData
->bt_coexist
.BT_CoexistType
== BT_CSR_BC8
))) {
10462 pHalData
->bt_coexist
.lastBtEdca
= 0;
10466 if (rtl8723a_BT_using_antenna_1(padapter
)) {
10468 pHalData
->bt_coexist
.lastBtEdca
= 0;
10472 if (pHalData
->bt_coexist
.exec_cnt
< 3)
10473 pHalData
->bt_coexist
.exec_cnt
++;
10475 pHalData
->bt_coexist
.bEDCAInitialized
= true;
10477 /* When BT is non idle */
10478 if (!(pHalData
->bt_coexist
.CurrentState
& BT_COEX_STATE_BT_IDLE
)) {
10479 RTPRINT(FBT
, BT_TRACE
, ("BT state non idle, set bt EDCA\n"));
10481 /* aggr_num = 0x0909; */
10482 if (pHalData
->odmpriv
.DM_EDCA_Table
.bCurrentTurboEDCA
) {
10483 bBtChangeEDCA
= true;
10484 pHalData
->odmpriv
.DM_EDCA_Table
.bCurrentTurboEDCA
= false;
10485 pHalData
->dmpriv
.prv_traffic_idx
= 3;
10487 cur_EDCA_reg
= rtl8723au_read32(padapter
, REG_EDCA_BE_PARAM
);
10489 if (cur_EDCA_reg
!= EDCA_BT_BE
)
10490 bBtChangeEDCA
= true;
10491 if (bBtChangeEDCA
|| !pHalData
->bt_coexist
.bEDCAInitialized
) {
10492 rtl8723au_write32(padapter
, REG_EDCA_BE_PARAM
,
10494 pHalData
->bt_coexist
.lastBtEdca
= EDCA_BT_BE
;
10498 RTPRINT(FBT
, BT_TRACE
, ("BT state idle, set original EDCA\n"));
10499 pHalData
->bt_coexist
.lastBtEdca
= 0;
10507 struct rtw_adapter
*padapter
,
10513 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10514 u8 H2C_Parameter
[3] = {0};
10517 H2C_Parameter
[2] = 1;
10518 H2C_Parameter
[1] = ms1
;
10519 H2C_Parameter
[0] = ms0
;
10520 pHalData
->bt_coexist
.bFWCoexistAllOff
= false;
10522 H2C_Parameter
[2] = 0;
10523 H2C_Parameter
[1] = 0;
10524 H2C_Parameter
[0] = 0;
10526 pHalData
->bt_coexist
.bBalanceOn
= bBalanceOn
;
10528 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], Balance =[%s:%dms:%dms], write 0xc = 0x%x\n",
10529 bBalanceOn
?"ON":"OFF", ms0
, ms1
,
10530 H2C_Parameter
[0]<<16|H2C_Parameter
[1]<<8|H2C_Parameter
[2]));
10532 FillH2CCmd(padapter
, 0xc, 3, H2C_Parameter
);
10535 void BTDM_AGCTable(struct rtw_adapter
*padapter
, u8 type
)
10537 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10538 if (type
== BT_AGCTABLE_OFF
) {
10539 RTPRINT(FBT
, BT_TRACE
, ("[BT]AGCTable Off!\n"));
10540 rtl8723au_write32(padapter
, 0xc78, 0x641c0001);
10541 rtl8723au_write32(padapter
, 0xc78, 0x631d0001);
10542 rtl8723au_write32(padapter
, 0xc78, 0x621e0001);
10543 rtl8723au_write32(padapter
, 0xc78, 0x611f0001);
10544 rtl8723au_write32(padapter
, 0xc78, 0x60200001);
10546 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0x32000);
10547 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0x71000);
10548 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0xb0000);
10549 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0xfc000);
10550 PHY_SetRFReg(padapter
, PathA
, RF_RX_G1
, bRFRegOffsetMask
, 0x30355);
10552 pHalData
->bt_coexist
.b8723aAgcTableOn
= false;
10553 } else if (type
== BT_AGCTABLE_ON
) {
10554 RTPRINT(FBT
, BT_TRACE
, ("[BT]AGCTable On!\n"));
10555 rtl8723au_write32(padapter
, 0xc78, 0x4e1c0001);
10556 rtl8723au_write32(padapter
, 0xc78, 0x4d1d0001);
10557 rtl8723au_write32(padapter
, 0xc78, 0x4c1e0001);
10558 rtl8723au_write32(padapter
, 0xc78, 0x4b1f0001);
10559 rtl8723au_write32(padapter
, 0xc78, 0x4a200001);
10561 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0xdc000);
10562 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0x90000);
10563 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0x51000);
10564 PHY_SetRFReg(padapter
, PathA
, RF_RX_AGC_HP
, bRFRegOffsetMask
, 0x12000);
10565 PHY_SetRFReg(padapter
, PathA
, RF_RX_G1
, bRFRegOffsetMask
, 0x00355);
10567 pHalData
->bt_coexist
.b8723aAgcTableOn
= true;
10569 pHalData
->bt_coexist
.bSWCoexistAllOff
= false;
10573 void BTDM_BBBackOffLevel(struct rtw_adapter
*padapter
, u8 type
)
10575 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10577 if (type
== BT_BB_BACKOFF_OFF
) {
10578 RTPRINT(FBT
, BT_TRACE
, ("[BT]BBBackOffLevel Off!\n"));
10579 rtl8723au_write32(padapter
, 0xc04, 0x3a05611);
10580 } else if (type
== BT_BB_BACKOFF_ON
) {
10581 RTPRINT(FBT
, BT_TRACE
, ("[BT]BBBackOffLevel On!\n"));
10582 rtl8723au_write32(padapter
, 0xc04, 0x3a07611);
10583 pHalData
->bt_coexist
.bSWCoexistAllOff
= false;
10587 void BTDM_FWCoexAllOff(struct rtw_adapter
*padapter
)
10589 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10591 RTPRINT(FBT
, BT_TRACE
, ("BTDM_FWCoexAllOff()\n"));
10592 if (pHalData
->bt_coexist
.bFWCoexistAllOff
)
10594 RTPRINT(FBT
, BT_TRACE
, ("BTDM_FWCoexAllOff(), real Do\n"));
10596 BTDM_FWCoexAllOff8723A(padapter
);
10598 pHalData
->bt_coexist
.bFWCoexistAllOff
= true;
10601 void BTDM_SWCoexAllOff(struct rtw_adapter
*padapter
)
10603 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10605 RTPRINT(FBT
, BT_TRACE
, ("BTDM_SWCoexAllOff()\n"));
10606 if (pHalData
->bt_coexist
.bSWCoexistAllOff
)
10608 RTPRINT(FBT
, BT_TRACE
, ("BTDM_SWCoexAllOff(), real Do\n"));
10609 BTDM_SWCoexAllOff8723A(padapter
);
10611 pHalData
->bt_coexist
.bSWCoexistAllOff
= true;
10614 void BTDM_HWCoexAllOff(struct rtw_adapter
*padapter
)
10616 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10618 RTPRINT(FBT
, BT_TRACE
, ("BTDM_HWCoexAllOff()\n"));
10619 if (pHalData
->bt_coexist
.bHWCoexistAllOff
)
10621 RTPRINT(FBT
, BT_TRACE
, ("BTDM_HWCoexAllOff(), real Do\n"));
10623 BTDM_HWCoexAllOff8723A(padapter
);
10625 pHalData
->bt_coexist
.bHWCoexistAllOff
= true;
10628 void BTDM_CoexAllOff(struct rtw_adapter
*padapter
)
10630 BTDM_FWCoexAllOff(padapter
);
10631 BTDM_SWCoexAllOff(padapter
);
10632 BTDM_HWCoexAllOff(padapter
);
10635 void rtl8723a_BT_disable_coexist(struct rtw_adapter
*padapter
)
10637 struct pwrctrl_priv
*ppwrctrl
= &padapter
->pwrctrlpriv
;
10639 if (!rtl8723a_BT_coexist(padapter
))
10642 /* 8723 1Ant doesn't need to turn off bt coexist mechanism. */
10643 if (rtl8723a_BT_using_antenna_1(padapter
))
10646 /* Before enter IPS, turn off FW BT Co-exist mechanism */
10647 if (ppwrctrl
->reg_rfoff
== rf_on
) {
10648 RTPRINT(FBT
, BT_TRACE
, ("[BT][DM], Before enter IPS, turn off all Coexist DM\n"));
10649 btdm_ResetFWCoexState(padapter
);
10650 BTDM_CoexAllOff(padapter
);
10651 BTDM_SetAntenna(padapter
, BTDM_ANT_BT
);
10655 void BTDM_SignalCompensation(struct rtw_adapter
*padapter
, u8
*rssi_wifi
, u8
*rssi_bt
)
10657 BTDM_8723ASignalCompensation(padapter
, rssi_wifi
, rssi_bt
);
10660 void rtl8723a_BT_do_coexist(struct rtw_adapter
*padapter
)
10662 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10664 if (!rtl8723a_BT_coexist(padapter
)) {
10665 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BT not exists!!\n"));
10669 if (!pHalData
->bt_coexist
.bInitlized
) {
10670 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], btdm_InitBtCoexistDM()\n"));
10671 btdm_InitBtCoexistDM(padapter
);
10674 RTPRINT(FBT
, BT_TRACE
, ("\n\n[DM][BT], BTDM start!!\n"));
10676 BTDM_PWDBMonitor(padapter
);
10678 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], HW type is 8723\n"));
10679 BTDM_BTCoexist8723A(padapter
);
10680 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], BTDM end!!\n\n"));
10683 void BTDM_UpdateCoexState(struct rtw_adapter
*padapter
)
10685 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10687 if (!BTDM_IsSameCoexistState(padapter
)) {
10688 RTPRINT(FBT
, BT_TRACE
, ("[BTCoex], Coexist State[bitMap] change from 0x%"i64fmt
"x to 0x%"i64fmt
"x, changeBits = 0x%"i64fmt
"x\n",
10689 pHalData
->bt_coexist
.PreviousState
,
10690 pHalData
->bt_coexist
.CurrentState
,
10691 (pHalData
->bt_coexist
.PreviousState
^pHalData
->bt_coexist
.CurrentState
)));
10692 pHalData
->bt_coexist
.PreviousState
= pHalData
->bt_coexist
.CurrentState
;
10696 u8
BTDM_IsSameCoexistState(struct rtw_adapter
*padapter
)
10698 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10700 if (pHalData
->bt_coexist
.PreviousState
== pHalData
->bt_coexist
.CurrentState
) {
10703 RTPRINT(FBT
, BT_TRACE
, ("[DM][BT], Coexist state changed!!\n"));
10708 void BTDM_PWDBMonitor(struct rtw_adapter
*padapter
)
10710 struct bt_30info
*pBTInfo
= GET_BT_INFO(GetDefaultAdapter(padapter
));
10711 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
10712 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10713 u8 H2C_Parameter
[3] = {0};
10714 s32 tmpBTEntryMaxPWDB
= 0, tmpBTEntryMinPWDB
= 0xff;
10717 if (pBtMgnt
->BtOperationOn
) {
10718 for (i
= 0; i
< MAX_BT_ASOC_ENTRY_NUM
; i
++) {
10719 if (pBTInfo
->BtAsocEntry
[i
].bUsed
) {
10720 if (pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
< tmpBTEntryMinPWDB
)
10721 tmpBTEntryMinPWDB
= pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
;
10722 if (pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
> tmpBTEntryMaxPWDB
)
10723 tmpBTEntryMaxPWDB
= pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
;
10724 /* Report every BT connection (HS mode) RSSI to FW */
10725 H2C_Parameter
[2] = (u8
)(pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
& 0xFF);
10726 H2C_Parameter
[0] = (MAX_FW_SUPPORT_MACID_NUM
-1-i
);
10727 RTPRINT(FDM
, DM_BT30
, ("RSSI report for BT[%d], H2C_Par = 0x%x\n", i
, H2C_Parameter
[0]));
10728 FillH2CCmd(padapter
, RSSI_SETTING_EID
, 3, H2C_Parameter
);
10729 RTPRINT_ADDR(FDM
, (DM_PWDB
|DM_BT30
), ("BT_Entry Mac :"),
10730 pBTInfo
->BtAsocEntry
[i
].BTRemoteMACAddr
)
10731 RTPRINT(FDM
, (DM_PWDB
|DM_BT30
),
10732 ("BT rx pwdb[%d] = 0x%x(%d)\n", i
,
10733 pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
,
10734 pBTInfo
->BtAsocEntry
[i
].UndecoratedSmoothedPWDB
));
10737 if (tmpBTEntryMaxPWDB
!= 0) { /* If associated entry is found */
10738 pHalData
->dmpriv
.BT_EntryMaxUndecoratedSmoothedPWDB
= tmpBTEntryMaxPWDB
;
10739 RTPRINT(FDM
, (DM_PWDB
|DM_BT30
), ("BT_EntryMaxPWDB = 0x%x(%d)\n",
10740 tmpBTEntryMaxPWDB
, tmpBTEntryMaxPWDB
));
10742 pHalData
->dmpriv
.BT_EntryMaxUndecoratedSmoothedPWDB
= 0;
10744 if (tmpBTEntryMinPWDB
!= 0xff) { /* If associated entry is found */
10745 pHalData
->dmpriv
.BT_EntryMinUndecoratedSmoothedPWDB
= tmpBTEntryMinPWDB
;
10746 RTPRINT(FDM
, (DM_PWDB
|DM_BT30
), ("BT_EntryMinPWDB = 0x%x(%d)\n",
10747 tmpBTEntryMinPWDB
, tmpBTEntryMinPWDB
));
10749 pHalData
->dmpriv
.BT_EntryMinUndecoratedSmoothedPWDB
= 0;
10754 u8
BTDM_IsBTBusy(struct rtw_adapter
*padapter
)
10756 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
10757 struct bt_mgnt
*pBtMgnt
= &pBTInfo
->BtMgnt
;
10759 if (pBtMgnt
->ExtConfig
.bBTBusy
)
10765 u8
BTDM_IsWifiBusy(struct rtw_adapter
*padapter
)
10767 /*PMGNT_INFO pMgntInfo = &GetDefaultAdapter(padapter)->MgntInfo; */
10768 struct mlme_priv
*pmlmepriv
= &GetDefaultAdapter(padapter
)->mlmepriv
;
10769 struct bt_30info
*pBTInfo
= GET_BT_INFO(padapter
);
10770 struct bt_traffic
*pBtTraffic
= &pBTInfo
->BtTraffic
;
10772 if (pmlmepriv
->LinkDetectInfo
.bBusyTraffic
||
10773 pBtTraffic
->Bt30TrafficStatistics
.bTxBusyTraffic
||
10774 pBtTraffic
->Bt30TrafficStatistics
.bRxBusyTraffic
)
10780 u8
BTDM_IsCoexistStateChanged(struct rtw_adapter
*padapter
)
10782 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10784 if (pHalData
->bt_coexist
.PreviousState
== pHalData
->bt_coexist
.CurrentState
)
10790 u8
BTDM_IsWifiUplink(struct rtw_adapter
*padapter
)
10792 /*PMGNT_INFO pMgntInfo = &GetDefaultAdapter(padapter)->MgntInfo; */
10793 struct mlme_priv
*pmlmepriv
;
10794 struct bt_30info
*pBTInfo
;
10795 struct bt_traffic
*pBtTraffic
;
10797 pmlmepriv
= &padapter
->mlmepriv
;
10798 pBTInfo
= GET_BT_INFO(padapter
);
10799 pBtTraffic
= &pBTInfo
->BtTraffic
;
10801 if ((pmlmepriv
->LinkDetectInfo
.bTxBusyTraffic
) ||
10802 (pBtTraffic
->Bt30TrafficStatistics
.bTxBusyTraffic
))
10808 u8
BTDM_IsWifiDownlink(struct rtw_adapter
*padapter
)
10810 /*PMGNT_INFO pMgntInfo = &GetDefaultAdapter(padapter)->MgntInfo; */
10811 struct mlme_priv
*pmlmepriv
;
10812 struct bt_30info
*pBTInfo
;
10813 struct bt_traffic
*pBtTraffic
;
10815 pmlmepriv
= &padapter
->mlmepriv
;
10816 pBTInfo
= GET_BT_INFO(padapter
);
10817 pBtTraffic
= &pBTInfo
->BtTraffic
;
10819 if ((pmlmepriv
->LinkDetectInfo
.bRxBusyTraffic
) ||
10820 (pBtTraffic
->Bt30TrafficStatistics
.bRxBusyTraffic
))
10826 u8
BTDM_IsBTHSMode(struct rtw_adapter
*padapter
)
10828 /*PMGNT_INFO pMgntInfo = &GetDefaultAdapter(padapter)->MgntInfo; */
10829 struct hal_data_8723a
*pHalData
;
10830 struct bt_mgnt
*pBtMgnt
;
10832 pHalData
= GET_HAL_DATA(padapter
);
10833 pBtMgnt
= &pHalData
->BtInfo
.BtMgnt
;
10835 if (pBtMgnt
->BtOperationOn
)
10841 u8
BTDM_IsBTUplink(struct rtw_adapter
*padapter
)
10843 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10845 if (pHalData
->bt_coexist
.BT21TrafficStatistics
.bTxBusyTraffic
)
10851 u8
BTDM_IsBTDownlink(struct rtw_adapter
*padapter
)
10853 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10855 if (pHalData
->bt_coexist
.BT21TrafficStatistics
.bRxBusyTraffic
)
10861 void BTDM_AdjustForBtOperation(struct rtw_adapter
*padapter
)
10863 RTPRINT(FBT
, BT_TRACE
, ("[BT][DM], BTDM_AdjustForBtOperation()\n"));
10864 BTDM_AdjustForBtOperation8723A(padapter
);
10867 void BTDM_SetBtCoexCurrAntNum(struct rtw_adapter
*padapter
, u8 antNum
)
10869 BTDM_Set8723ABtCoexCurrAntNum(padapter
, antNum
);
10872 void BTDM_ForHalt(struct rtw_adapter
*padapter
)
10874 if (!rtl8723a_BT_coexist(padapter
))
10877 BTDM_ForHalt8723A(padapter
);
10878 GET_HAL_DATA(padapter
)->bt_coexist
.bInitlized
= false;
10881 void BTDM_WifiScanNotify(struct rtw_adapter
*padapter
, u8 scanType
)
10883 if (!rtl8723a_BT_coexist(padapter
))
10886 BTDM_WifiScanNotify8723A(padapter
, scanType
);
10889 void BTDM_WifiAssociateNotify(struct rtw_adapter
*padapter
, u8 action
)
10891 if (!rtl8723a_BT_coexist(padapter
))
10894 BTDM_WifiAssociateNotify8723A(padapter
, action
);
10897 void rtl8723a_BT_mediastatus_notify(struct rtw_adapter
*padapter
,
10898 enum rt_media_status mstatus
)
10900 if (!rtl8723a_BT_coexist(padapter
))
10903 BTDM_MediaStatusNotify8723A(padapter
, mstatus
);
10906 void rtl8723a_BT_specialpacket_notify(struct rtw_adapter
*padapter
)
10908 if (!rtl8723a_BT_coexist(padapter
))
10911 BTDM_ForDhcp8723A(padapter
);
10914 void BTDM_ResetActionProfileState(struct rtw_adapter
*padapter
)
10916 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
10918 pHalData
->bt_coexist
.CurrentState
&= ~\
10919 (BT_COEX_STATE_PROFILE_HID
|BT_COEX_STATE_PROFILE_A2DP
|
10920 BT_COEX_STATE_PROFILE_PAN
|BT_COEX_STATE_PROFILE_SCO
);
10923 u8
BTDM_IsActionSCO(struct rtw_adapter
*padapter
)
10925 struct hal_data_8723a
*pHalData
;
10926 struct bt_30info
*pBTInfo
;
10927 struct bt_mgnt
*pBtMgnt
;
10928 struct bt_dgb
*pBtDbg
;
10931 pHalData
= GET_HAL_DATA(padapter
);
10932 pBTInfo
= GET_BT_INFO(padapter
);
10933 pBtMgnt
= &pBTInfo
->BtMgnt
;
10934 pBtDbg
= &pBTInfo
->BtDbg
;
10937 if (pBtDbg
->dbgCtrl
) {
10938 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_SCO
) {
10939 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_SCO
;
10943 if (pBtMgnt
->ExtConfig
.NumberOfSCO
> 0) {
10944 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_SCO
;
10951 u8
BTDM_IsActionHID(struct rtw_adapter
*padapter
)
10953 struct bt_30info
*pBTInfo
;
10954 struct hal_data_8723a
*pHalData
;
10955 struct bt_mgnt
*pBtMgnt
;
10956 struct bt_dgb
*pBtDbg
;
10959 pHalData
= GET_HAL_DATA(padapter
);
10960 pBTInfo
= GET_BT_INFO(padapter
);
10961 pBtMgnt
= &pBTInfo
->BtMgnt
;
10962 pBtDbg
= &pBTInfo
->BtDbg
;
10965 if (pBtDbg
->dbgCtrl
) {
10966 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_HID
) {
10967 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_HID
;
10971 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
10972 pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) {
10973 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_HID
;
10980 u8
BTDM_IsActionA2DP(struct rtw_adapter
*padapter
)
10982 struct hal_data_8723a
*pHalData
;
10983 struct bt_30info
*pBTInfo
;
10984 struct bt_mgnt
*pBtMgnt
;
10985 struct bt_dgb
*pBtDbg
;
10988 pHalData
= GET_HAL_DATA(padapter
);
10989 pBTInfo
= GET_BT_INFO(padapter
);
10990 pBtMgnt
= &pBTInfo
->BtMgnt
;
10991 pBtDbg
= &pBTInfo
->BtDbg
;
10994 if (pBtDbg
->dbgCtrl
) {
10995 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_A2DP
) {
10996 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_A2DP
;
11000 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
) &&
11001 pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) {
11002 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_A2DP
;
11009 u8
BTDM_IsActionPAN(struct rtw_adapter
*padapter
)
11011 struct hal_data_8723a
*pHalData
;
11012 struct bt_30info
*pBTInfo
;
11013 struct bt_mgnt
*pBtMgnt
;
11014 struct bt_dgb
*pBtDbg
;
11017 pHalData
= GET_HAL_DATA(padapter
);
11018 pBTInfo
= GET_BT_INFO(padapter
);
11019 pBtMgnt
= &pBTInfo
->BtMgnt
;
11020 pBtDbg
= &pBTInfo
->BtDbg
;
11023 if (pBtDbg
->dbgCtrl
) {
11024 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_PAN
) {
11025 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_PAN
;
11029 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) &&
11030 pBtMgnt
->ExtConfig
.NumberOfHandle
== 1) {
11031 pHalData
->bt_coexist
.CurrentState
|= BT_COEX_STATE_PROFILE_PAN
;
11038 u8
BTDM_IsActionHIDA2DP(struct rtw_adapter
*padapter
)
11040 struct hal_data_8723a
*pHalData
;
11041 struct bt_30info
*pBTInfo
;
11042 struct bt_mgnt
*pBtMgnt
;
11043 struct bt_dgb
*pBtDbg
;
11046 pHalData
= GET_HAL_DATA(padapter
);
11047 pBTInfo
= GET_BT_INFO(padapter
);
11048 pBtMgnt
= &pBTInfo
->BtMgnt
;
11049 pBtDbg
= &pBTInfo
->BtDbg
;
11052 if (pBtDbg
->dbgCtrl
) {
11053 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_HID_A2DP
) {
11054 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_HID
|BT_COEX_STATE_PROFILE_A2DP
);
11058 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
11059 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
11060 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_HID
|BT_COEX_STATE_PROFILE_A2DP
);
11067 u8
BTDM_IsActionHIDPAN(struct rtw_adapter
*padapter
)
11069 struct hal_data_8723a
*pHalData
;
11070 struct bt_30info
*pBTInfo
;
11071 struct bt_dgb
*pBtDbg
;
11074 pHalData
= GET_HAL_DATA(padapter
);
11075 pBTInfo
= GET_BT_INFO(padapter
);
11076 pBtDbg
= &pBTInfo
->BtDbg
;
11079 if (pBtDbg
->dbgCtrl
) {
11080 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_HID_PAN
) {
11081 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_HID
|BT_COEX_STATE_PROFILE_PAN
);
11085 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_HID
) &&
11086 BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
)) {
11087 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_HID
|BT_COEX_STATE_PROFILE_PAN
);
11094 u8
BTDM_IsActionPANA2DP(struct rtw_adapter
*padapter
)
11096 struct hal_data_8723a
*pHalData
;
11097 struct bt_30info
*pBTInfo
;
11098 struct bt_dgb
*pBtDbg
;
11101 pHalData
= GET_HAL_DATA(padapter
);
11102 pBTInfo
= GET_BT_INFO(padapter
);
11103 pBtDbg
= &pBTInfo
->BtDbg
;
11106 if (pBtDbg
->dbgCtrl
) {
11107 if (pBtDbg
->dbgProfile
== BT_DBG_PROFILE_PAN_A2DP
) {
11108 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_PAN
|BT_COEX_STATE_PROFILE_A2DP
);
11112 if (BTHCI_CheckProfileExist(padapter
, BT_PROFILE_PAN
) && BTHCI_CheckProfileExist(padapter
, BT_PROFILE_A2DP
)) {
11113 pHalData
->bt_coexist
.CurrentState
|= (BT_COEX_STATE_PROFILE_PAN
|BT_COEX_STATE_PROFILE_A2DP
);
11120 bool rtl8723a_BT_enabled(struct rtw_adapter
*padapter
)
11122 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
11124 if (pHalData
->bt_coexist
.bCurBtDisabled
)
11130 /* ===== End of sync from SD7 driver HAL/BTCoexist/HalBtCoexist.c ===== */
11132 /* ===== Below this line is sync from SD7 driver HAL/HalBT.c ===== */
11135 /*local function */
11138 static void halbt_InitHwConfig8723A(struct rtw_adapter
*padapter
)
11143 /*extern function */
11145 u8
HALBT_GetPGAntNum(struct rtw_adapter
*padapter
)
11147 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
11149 return pHalData
->bt_coexist
.BT_Ant_Num
;
11152 void HALBT_SetKey(struct rtw_adapter
*padapter
, u8 EntryNum
)
11154 struct bt_30info
*pBTinfo
;
11155 struct bt_asoc_entry
*pBtAssocEntry
;
11158 pBTinfo
= GET_BT_INFO(padapter
);
11159 pBtAssocEntry
= &pBTinfo
->BtAsocEntry
[EntryNum
];
11161 pBtAssocEntry
->HwCAMIndex
= BT_HWCAM_STAR
+ EntryNum
;
11163 usConfig
= CAM_VALID
| (CAM_AES
<< 2);
11164 rtl8723a_cam_write(padapter
, pBtAssocEntry
->HwCAMIndex
, usConfig
,
11165 pBtAssocEntry
->BTRemoteMACAddr
,
11166 pBtAssocEntry
->PTK
+ TKIP_ENC_KEY_POS
);
11169 void HALBT_RemoveKey(struct rtw_adapter
*padapter
, u8 EntryNum
)
11171 struct bt_30info
*pBTinfo
;
11172 struct bt_asoc_entry
*pBtAssocEntry
;
11174 pBTinfo
= GET_BT_INFO(padapter
);
11175 pBtAssocEntry
= &pBTinfo
->BtAsocEntry
[EntryNum
];
11177 if (pBTinfo
->BtAsocEntry
[EntryNum
].HwCAMIndex
!= 0) {
11178 /* ToDo : add New HALBT_RemoveKey function !! */
11179 if (pBtAssocEntry
->HwCAMIndex
>= BT_HWCAM_STAR
&&
11180 pBtAssocEntry
->HwCAMIndex
< HALF_CAM_ENTRY
)
11181 rtl8723a_cam_empty_entry(padapter
,
11182 pBtAssocEntry
->HwCAMIndex
);
11183 pBTinfo
->BtAsocEntry
[EntryNum
].HwCAMIndex
= 0;
11187 void rtl8723a_BT_init_hal_vars(struct rtw_adapter
*padapter
)
11189 struct hal_data_8723a
*pHalData
;
11191 pHalData
= GET_HAL_DATA(padapter
);
11193 pHalData
->bt_coexist
.BluetoothCoexist
= pHalData
->EEPROMBluetoothCoexist
;
11194 pHalData
->bt_coexist
.BT_Ant_Num
= pHalData
->EEPROMBluetoothAntNum
;
11195 pHalData
->bt_coexist
.BT_CoexistType
= pHalData
->EEPROMBluetoothType
;
11196 pHalData
->bt_coexist
.BT_Ant_isolation
= pHalData
->EEPROMBluetoothAntIsolation
;
11197 pHalData
->bt_coexist
.bt_radiosharedtype
= pHalData
->EEPROMBluetoothRadioShared
;
11199 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
11200 "BT Coexistance = 0x%x\n", rtl8723a_BT_coexist(padapter
));
11202 if (rtl8723a_BT_coexist(padapter
)) {
11203 if (pHalData
->bt_coexist
.BT_Ant_Num
== Ant_x2
) {
11204 BTDM_SetBtCoexCurrAntNum(padapter
, 2);
11205 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
11206 "BlueTooth BT_Ant_Num = Antx2\n");
11207 } else if (pHalData
->bt_coexist
.BT_Ant_Num
== Ant_x1
) {
11208 BTDM_SetBtCoexCurrAntNum(padapter
, 1);
11209 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
11210 "BlueTooth BT_Ant_Num = Antx1\n");
11212 pHalData
->bt_coexist
.bBTBusyTraffic
= false;
11213 pHalData
->bt_coexist
.bBTTrafficModeSet
= false;
11214 pHalData
->bt_coexist
.bBTNonTrafficModeSet
= false;
11215 pHalData
->bt_coexist
.CurrentState
= 0;
11216 pHalData
->bt_coexist
.PreviousState
= 0;
11218 RT_TRACE(_module_hal_init_c_
, _drv_info_
,
11219 "bt_radiosharedType = 0x%x\n",
11220 pHalData
->bt_coexist
.bt_radiosharedtype
);
11224 bool rtl8723a_BT_coexist(struct rtw_adapter
*padapter
)
11226 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
11228 if (pHalData
->bt_coexist
.BluetoothCoexist
)
11234 u8
HALBT_BTChipType(struct rtw_adapter
*padapter
)
11236 struct hal_data_8723a
*pHalData
= GET_HAL_DATA(padapter
);
11238 return pHalData
->bt_coexist
.BT_CoexistType
;
11241 void rtl8723a_BT_init_hwconfig(struct rtw_adapter
*padapter
)
11243 halbt_InitHwConfig8723A(padapter
);
11244 rtl8723a_BT_do_coexist(padapter
);
11247 void HALBT_SetRtsCtsNoLenLimit(struct rtw_adapter
*padapter
)
11251 /* ===== End of sync from SD7 driver HAL/HalBT.c ===== */
11253 void rtl8723a_dual_antenna_detection(struct rtw_adapter
*padapter
)
11255 struct hal_data_8723a
*pHalData
;
11256 struct dm_odm_t
*pDM_Odm
;
11257 struct sw_ant_sw
*pDM_SWAT_Table
;
11260 pHalData
= GET_HAL_DATA(padapter
);
11261 pDM_Odm
= &pHalData
->odmpriv
;
11262 pDM_SWAT_Table
= &pDM_Odm
->DM_SWAT_Table
;
11265 /* <Roger_Notes> RTL8723A Single and Dual antenna dynamic detection
11266 mechanism when RF power state is on. */
11267 /* We should take power tracking, IQK, LCK, RCK RF read/write
11268 operation into consideration. */
11271 if (!pHalData
->bAntennaDetected
) {
11272 u8 btAntNum
= BT_GetPGAntNum(padapter
);
11274 /* Set default antenna B status */
11275 if (btAntNum
== Ant_x2
)
11276 pDM_SWAT_Table
->ANTB_ON
= true;
11277 else if (btAntNum
== Ant_x1
)
11278 pDM_SWAT_Table
->ANTB_ON
= false;
11280 pDM_SWAT_Table
->ANTB_ON
= true;
11282 if (pHalData
->CustomerID
!= RT_CID_TOSHIBA
) {
11283 for (i
= 0; i
< MAX_ANTENNA_DETECTION_CNT
; i
++) {
11284 if (ODM_SingleDualAntennaDetection
11285 (&pHalData
->odmpriv
, ANTTESTALL
) == true)
11289 /* Set default antenna number for BT coexistence */
11290 if (btAntNum
== Ant_x2
)
11291 BT_SetBtCoexCurrAntNum(padapter
,
11295 pHalData
->bAntennaDetected
= true;