hal_btcoex.c 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2013 Realtek Corporation. All rights reserved.
  4. *
  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.
  8. *
  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
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #define __HAL_BTCOEX_C__
  21. #ifdef CONFIG_BT_COEXIST
  22. #include <hal_data.h>
  23. #include <hal_btcoex.h>
  24. #include "btc/mp_precomp.h"
  25. /* ************************************
  26. * Global variables
  27. * ************************************ */
  28. const char *const BtProfileString[] = {
  29. "NONE",
  30. "A2DP",
  31. "PAN",
  32. "HID",
  33. "SCO",
  34. };
  35. const char *const BtSpecString[] = {
  36. "1.0b",
  37. "1.1",
  38. "1.2",
  39. "2.0+EDR",
  40. "2.1+EDR",
  41. "3.0+HS",
  42. "4.0",
  43. };
  44. const char *const BtLinkRoleString[] = {
  45. "Master",
  46. "Slave",
  47. };
  48. const char *const h2cStaString[] = {
  49. "successful",
  50. "h2c busy",
  51. "rf off",
  52. "fw not read",
  53. };
  54. const char *const ioStaString[] = {
  55. "success",
  56. "can not IO",
  57. "rf off",
  58. "fw not read",
  59. "wait io timeout",
  60. "invalid len",
  61. "idle Q empty",
  62. "insert waitQ fail",
  63. "unknown fail",
  64. "wrong level",
  65. "h2c stopped",
  66. };
  67. const char *const GLBtcWifiBwString[] = {
  68. "11bg",
  69. "HT20",
  70. "HT40",
  71. "HT80",
  72. "HT160"
  73. };
  74. const char *const GLBtcWifiFreqString[] = {
  75. "2.4G",
  76. "5G"
  77. };
  78. const char *const GLBtcIotPeerString[] = {
  79. "UNKNOWN",
  80. "REALTEK",
  81. "REALTEK_92SE",
  82. "BROADCOM",
  83. "RALINK",
  84. "ATHEROS",
  85. "CISCO",
  86. "MERU",
  87. "MARVELL",
  88. "REALTEK_SOFTAP", /* peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */
  89. "SELF_SOFTAP", /* Self is SoftAP */
  90. "AIRGO",
  91. "INTEL",
  92. "RTK_APCLIENT",
  93. "REALTEK_81XX",
  94. "REALTEK_WOW",
  95. "REALTEK_JAGUAR_BCUTAP",
  96. "REALTEK_JAGUAR_CCUTAP"
  97. };
  98. const char *const coexOpcodeString[] = {
  99. "Wifi status notify",
  100. "Wifi progress",
  101. "Wifi info",
  102. "Power state",
  103. "Set Control",
  104. "Get Control"
  105. };
  106. const char *const coexIndTypeString[] = {
  107. "bt info",
  108. "pstdma",
  109. "limited tx/rx",
  110. "coex table",
  111. "request"
  112. };
  113. const char *const coexH2cResultString[] = {
  114. "ok",
  115. "unknown",
  116. "un opcode",
  117. "opVer MM",
  118. "par Err",
  119. "par OoR",
  120. "reqNum MM",
  121. "halMac Fail",
  122. "h2c TimeOut",
  123. "Invalid c2h Len",
  124. "data overflow"
  125. };
  126. #define HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS 8000
  127. struct btc_coexist GLBtCoexist;
  128. BTC_OFFLOAD gl_coex_offload;
  129. u8 GLBtcWiFiInScanState;
  130. u8 GLBtcWiFiInIQKState;
  131. u8 GLBtcWiFiInIPS;
  132. u8 GLBtcWiFiInLPS;
  133. u8 GLBtcBtCoexAliveRegistered;
  134. /*
  135. * BT control H2C/C2H
  136. */
  137. /* EXT_EID */
  138. typedef enum _bt_ext_eid {
  139. C2H_WIFI_FW_ACTIVE_RSP = 0,
  140. C2H_TRIG_BY_BT_FW
  141. } BT_EXT_EID;
  142. /* C2H_STATUS */
  143. typedef enum _bt_c2h_status {
  144. BT_STATUS_OK = 0,
  145. BT_STATUS_VERSION_MISMATCH,
  146. BT_STATUS_UNKNOWN_OPCODE,
  147. BT_STATUS_ERROR_PARAMETER
  148. } BT_C2H_STATUS;
  149. /* C2H BT OP CODES */
  150. typedef enum _bt_op_code {
  151. BT_OP_GET_BT_VERSION = 0x00,
  152. BT_OP_WRITE_REG_ADDR = 0x0c,
  153. BT_OP_WRITE_REG_VALUE = 0x0d,
  154. BT_OP_READ_REG = 0x11,
  155. BT_LO_OP_GET_AFH_MAP_L = 0x1e,
  156. BT_LO_OP_GET_AFH_MAP_M = 0x1f,
  157. BT_LO_OP_GET_AFH_MAP_H = 0x20,
  158. BT_OP_GET_BT_COEX_SUPPORTED_FEATURE = 0x2a,
  159. BT_OP_GET_BT_COEX_SUPPORTED_VERSION = 0x2b,
  160. BT_OP_GET_BT_ANT_DET_VAL = 0x2c,
  161. BT_OP_GET_BT_BLE_SCAN_PARA = 0x2d,
  162. BT_OP_GET_BT_BLE_SCAN_TYPE = 0x2e,
  163. BT_OP_MAX
  164. } BT_OP_CODE;
  165. #define BTC_MPOPER_TIMEOUT 50 /* unit: ms */
  166. #define C2H_MAX_SIZE 16
  167. u8 GLBtcBtMpOperSeq;
  168. _mutex GLBtcBtMpOperLock;
  169. _timer GLBtcBtMpOperTimer;
  170. _sema GLBtcBtMpRptSema;
  171. u8 GLBtcBtMpRptSeq;
  172. u8 GLBtcBtMpRptStatus;
  173. u8 GLBtcBtMpRptRsp[C2H_MAX_SIZE];
  174. u8 GLBtcBtMpRptRspSize;
  175. u8 GLBtcBtMpRptWait;
  176. u8 GLBtcBtMpRptWiFiOK;
  177. u8 GLBtcBtMpRptBTOK;
  178. /*
  179. * Debug
  180. */
  181. u32 GLBtcDbgType[COMP_MAX];
  182. u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE];
  183. u1Byte gl_btc_trace_buf[BT_TMP_BUF_SIZE];
  184. typedef struct _btcoexdbginfo {
  185. u8 *info;
  186. u32 size; /* buffer total size */
  187. u32 len; /* now used length */
  188. } BTCDBGINFO, *PBTCDBGINFO;
  189. BTCDBGINFO GLBtcDbgInfo;
  190. #define BT_Operation(Adapter) _FALSE
  191. static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size)
  192. {
  193. if (NULL == pinfo)
  194. return;
  195. _rtw_memset(pinfo, 0, sizeof(BTCDBGINFO));
  196. if (pbuf && size) {
  197. pinfo->info = pbuf;
  198. pinfo->size = size;
  199. }
  200. }
  201. void DBG_BT_INFO(u8 *dbgmsg)
  202. {
  203. PBTCDBGINFO pinfo;
  204. u32 msglen, buflen;
  205. u8 *pbuf;
  206. pinfo = &GLBtcDbgInfo;
  207. if (NULL == pinfo->info)
  208. return;
  209. msglen = strlen(dbgmsg);
  210. if (pinfo->len + msglen > pinfo->size)
  211. return;
  212. pbuf = pinfo->info + pinfo->len;
  213. _rtw_memcpy(pbuf, dbgmsg, msglen);
  214. pinfo->len += msglen;
  215. }
  216. /* ************************************
  217. * Debug related function
  218. * ************************************ */
  219. static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist)
  220. {
  221. if (!pBtCoexist->bBinded ||
  222. NULL == pBtCoexist->Adapter)
  223. return _FALSE;
  224. return _TRUE;
  225. }
  226. static void halbtcoutsrc_DbgInit(void)
  227. {
  228. u8 i;
  229. for (i = 0; i < COMP_MAX; i++)
  230. GLBtcDbgType[i] = 0;
  231. }
  232. static u8 halbtcoutsrc_IsCsrBtCoex(PBTC_COEXIST pBtCoexist)
  233. {
  234. if (pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC4
  235. || pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC8
  236. )
  237. return _TRUE;
  238. return _FALSE;
  239. }
  240. static void halbtcoutsrc_EnterPwrLock(PBTC_COEXIST pBtCoexist)
  241. {
  242. struct dvobj_priv *dvobj = adapter_to_dvobj((PADAPTER)pBtCoexist->Adapter);
  243. struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
  244. _enter_pwrlock(&pwrpriv->lock);
  245. }
  246. static void halbtcoutsrc_ExitPwrLock(PBTC_COEXIST pBtCoexist)
  247. {
  248. struct dvobj_priv *dvobj = adapter_to_dvobj((PADAPTER)pBtCoexist->Adapter);
  249. struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
  250. _exit_pwrlock(&pwrpriv->lock);
  251. }
  252. static u8 halbtcoutsrc_IsHwMailboxExist(PBTC_COEXIST pBtCoexist)
  253. {
  254. if (pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC4
  255. || pBtCoexist->board_info.bt_chip_type == BTC_CHIP_CSR_BC8
  256. )
  257. return _FALSE;
  258. else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter))
  259. return _FALSE;
  260. else
  261. return _TRUE;
  262. }
  263. static u8 halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist)
  264. {
  265. PADAPTER padapter;
  266. padapter = pBtCoexist->Adapter;
  267. pBtCoexist->bt_info.bt_ctrl_lps = _TRUE;
  268. pBtCoexist->bt_info.bt_lps_on = _FALSE;
  269. return rtw_btcoex_LPS_Leave(padapter);
  270. }
  271. void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist)
  272. {
  273. PADAPTER padapter;
  274. padapter = pBtCoexist->Adapter;
  275. if (pBtCoexist->bdontenterLPS == _FALSE) {
  276. pBtCoexist->bt_info.bt_ctrl_lps = _TRUE;
  277. pBtCoexist->bt_info.bt_lps_on = _TRUE;
  278. rtw_btcoex_LPS_Enter(padapter);
  279. }
  280. }
  281. void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist)
  282. {
  283. PADAPTER padapter;
  284. padapter = pBtCoexist->Adapter;
  285. if (pBtCoexist->bt_info.bt_ctrl_lps) {
  286. pBtCoexist->bt_info.bt_lps_on = _FALSE;
  287. rtw_btcoex_LPS_Leave(padapter);
  288. pBtCoexist->bt_info.bt_ctrl_lps = _FALSE;
  289. /* recover the LPS state to the original */
  290. #if 0
  291. padapter->hal_func.UpdateLPSStatusHandler(
  292. padapter,
  293. pPSC->RegLeisurePsMode,
  294. pPSC->RegPowerSaveMode);
  295. #endif
  296. }
  297. }
  298. /*
  299. * Constraint:
  300. * 1. this function will request pwrctrl->lock
  301. */
  302. void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist)
  303. {
  304. #ifdef CONFIG_LPS_LCLK
  305. PADAPTER padapter;
  306. PHAL_DATA_TYPE pHalData;
  307. struct pwrctrl_priv *pwrctrl;
  308. s32 ready;
  309. u32 stime;
  310. s32 utime;
  311. u32 timeout; /* unit: ms */
  312. padapter = pBtCoexist->Adapter;
  313. pHalData = GET_HAL_DATA(padapter);
  314. pwrctrl = adapter_to_pwrctl(padapter);
  315. ready = _FAIL;
  316. #ifdef LPS_RPWM_WAIT_MS
  317. timeout = LPS_RPWM_WAIT_MS;
  318. #else /* !LPS_RPWM_WAIT_MS */
  319. timeout = 30;
  320. #endif /* !LPS_RPWM_WAIT_MS */
  321. if (GLBtcBtCoexAliveRegistered == _TRUE)
  322. return;
  323. stime = rtw_get_current_time();
  324. do {
  325. ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE);
  326. if (_SUCCESS == ready)
  327. break;
  328. utime = rtw_get_passing_time_ms(stime);
  329. if (utime > timeout)
  330. break;
  331. rtw_msleep_os(1);
  332. } while (1);
  333. GLBtcBtCoexAliveRegistered = _TRUE;
  334. #endif /* CONFIG_LPS_LCLK */
  335. }
  336. /*
  337. * Constraint:
  338. * 1. this function will request pwrctrl->lock
  339. */
  340. void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist)
  341. {
  342. #ifdef CONFIG_LPS_LCLK
  343. PADAPTER padapter;
  344. if (GLBtcBtCoexAliveRegistered == _FALSE)
  345. return;
  346. padapter = pBtCoexist->Adapter;
  347. rtw_unregister_task_alive(padapter, BTCOEX_ALIVE);
  348. GLBtcBtCoexAliveRegistered = _FALSE;
  349. #endif /* CONFIG_LPS_LCLK */
  350. }
  351. void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable)
  352. {
  353. pBtCoexist->bt_info.bt_disable_low_pwr = bLowPwrDisable;
  354. if (bLowPwrDisable)
  355. halbtcoutsrc_LeaveLowPower(pBtCoexist); /* leave 32k low power. */
  356. else
  357. halbtcoutsrc_NormalLowPower(pBtCoexist); /* original 32k low power behavior. */
  358. }
  359. void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist)
  360. {
  361. PADAPTER padapter;
  362. BOOLEAN bNeedToAct = _FALSE;
  363. static u32 preTime = 0;
  364. u32 curTime = 0;
  365. padapter = pBtCoexist->Adapter;
  366. /* ===================================== */
  367. /* To void continuous deleteBA=>addBA=>deleteBA=>addBA */
  368. /* This function is not allowed to continuous called. */
  369. /* It can only be called after 8 seconds. */
  370. /* ===================================== */
  371. curTime = rtw_systime_to_ms(rtw_get_current_time());
  372. if ((curTime - preTime) < HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS) /* over 8 seconds you can execute this function again. */
  373. return;
  374. else
  375. preTime = curTime;
  376. if (pBtCoexist->bt_info.reject_agg_pkt) {
  377. bNeedToAct = _TRUE;
  378. pBtCoexist->bt_info.pre_reject_agg_pkt = pBtCoexist->bt_info.reject_agg_pkt;
  379. } else {
  380. if (pBtCoexist->bt_info.pre_reject_agg_pkt) {
  381. bNeedToAct = _TRUE;
  382. pBtCoexist->bt_info.pre_reject_agg_pkt = pBtCoexist->bt_info.reject_agg_pkt;
  383. }
  384. if (pBtCoexist->bt_info.pre_bt_ctrl_agg_buf_size !=
  385. pBtCoexist->bt_info.bt_ctrl_agg_buf_size) {
  386. bNeedToAct = _TRUE;
  387. pBtCoexist->bt_info.pre_bt_ctrl_agg_buf_size = pBtCoexist->bt_info.bt_ctrl_agg_buf_size;
  388. }
  389. if (pBtCoexist->bt_info.bt_ctrl_agg_buf_size) {
  390. if (pBtCoexist->bt_info.pre_agg_buf_size !=
  391. pBtCoexist->bt_info.agg_buf_size)
  392. bNeedToAct = _TRUE;
  393. pBtCoexist->bt_info.pre_agg_buf_size = pBtCoexist->bt_info.agg_buf_size;
  394. }
  395. }
  396. if (bNeedToAct)
  397. rtw_btcoex_rx_ampdu_apply(padapter);
  398. }
  399. u8 halbtcoutsrc_is_autoload_fail(PBTC_COEXIST pBtCoexist)
  400. {
  401. PADAPTER padapter;
  402. PHAL_DATA_TYPE pHalData;
  403. padapter = pBtCoexist->Adapter;
  404. pHalData = GET_HAL_DATA(padapter);
  405. return pHalData->bautoload_fail_flag;
  406. }
  407. u8 halbtcoutsrc_is_fw_ready(PBTC_COEXIST pBtCoexist)
  408. {
  409. PADAPTER padapter;
  410. padapter = pBtCoexist->Adapter;
  411. return padapter->bFWReady;
  412. }
  413. u8 halbtcoutsrc_IsWifiBusy(PADAPTER padapter)
  414. {
  415. if (rtw_mi_check_status(padapter, MI_AP_MODE))
  416. return _TRUE;
  417. if (rtw_mi_busy_traffic_check(padapter, _FALSE))
  418. return _TRUE;
  419. return _FALSE;
  420. }
  421. static u32 _halbtcoutsrc_GetWifiLinkStatus(PADAPTER padapter)
  422. {
  423. struct mlme_priv *pmlmepriv;
  424. u8 bp2p;
  425. u32 portConnectedStatus;
  426. pmlmepriv = &padapter->mlmepriv;
  427. bp2p = _FALSE;
  428. portConnectedStatus = 0;
  429. #ifdef CONFIG_P2P
  430. if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE))
  431. bp2p = _TRUE;
  432. #endif /* CONFIG_P2P */
  433. if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) {
  434. if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) {
  435. if (_TRUE == bp2p)
  436. portConnectedStatus |= WIFI_P2P_GO_CONNECTED;
  437. else
  438. portConnectedStatus |= WIFI_AP_CONNECTED;
  439. } else {
  440. if (_TRUE == bp2p)
  441. portConnectedStatus |= WIFI_P2P_GC_CONNECTED;
  442. else
  443. portConnectedStatus |= WIFI_STA_CONNECTED;
  444. }
  445. }
  446. return portConnectedStatus;
  447. }
  448. u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist)
  449. {
  450. /* ================================= */
  451. /* return value: */
  452. /* [31:16]=> connected port number */
  453. /* [15:0]=> port connected bit define */
  454. /* ================================ */
  455. PADAPTER padapter;
  456. u32 retVal;
  457. u32 portConnectedStatus, numOfConnectedPort;
  458. struct dvobj_priv *dvobj;
  459. _adapter *iface;
  460. int i;
  461. padapter = pBtCoexist->Adapter;
  462. retVal = 0;
  463. portConnectedStatus = 0;
  464. numOfConnectedPort = 0;
  465. dvobj = adapter_to_dvobj(padapter);
  466. for (i = 0; i < dvobj->iface_nums; i++) {
  467. iface = dvobj->padapters[i];
  468. if ((iface) && rtw_is_adapter_up(iface)) {
  469. retVal = _halbtcoutsrc_GetWifiLinkStatus(iface);
  470. if (retVal) {
  471. portConnectedStatus |= retVal;
  472. numOfConnectedPort++;
  473. }
  474. }
  475. }
  476. retVal = (numOfConnectedPort << 16) | portConnectedStatus;
  477. return retVal;
  478. }
  479. static void _btmpoper_timer_hdl(struct timer_list *t)
  480. {
  481. if (GLBtcBtMpRptWait) {
  482. GLBtcBtMpRptWait = 0;
  483. _rtw_up_sema(&GLBtcBtMpRptSema);
  484. }
  485. }
  486. /*
  487. * !IMPORTANT!
  488. * Before call this function, caller should acquire "GLBtcBtMpOperLock"!
  489. * Othrewise there will be racing problem and something may go wrong.
  490. */
  491. static u8 _btmpoper_cmd(PBTC_COEXIST pBtCoexist, u8 opcode, u8 opcodever, u8 *cmd, u8 size)
  492. {
  493. PADAPTER padapter;
  494. u8 buf[H2C_BTMP_OPER_LEN] = {0};
  495. u8 buflen;
  496. u8 seq;
  497. s32 ret;
  498. if (!cmd && size)
  499. size = 0;
  500. if ((size + 2) > H2C_BTMP_OPER_LEN)
  501. return BT_STATUS_H2C_LENGTH_EXCEEDED;
  502. buflen = size + 2;
  503. seq = GLBtcBtMpOperSeq & 0xF;
  504. GLBtcBtMpOperSeq++;
  505. buf[0] = (opcodever & 0xF) | (seq << 4);
  506. buf[1] = opcode;
  507. if (cmd && size)
  508. _rtw_memcpy(buf + 2, cmd, size);
  509. GLBtcBtMpRptWait = 1;
  510. GLBtcBtMpRptWiFiOK = 0;
  511. GLBtcBtMpRptBTOK = 0;
  512. GLBtcBtMpRptStatus = 0;
  513. padapter = pBtCoexist->Adapter;
  514. _set_timer(&GLBtcBtMpOperTimer, BTC_MPOPER_TIMEOUT);
  515. if (rtw_hal_fill_h2c_cmd(padapter, H2C_BT_MP_OPER, buflen, buf) == _FAIL) {
  516. _cancel_timer_ex(&GLBtcBtMpOperTimer);
  517. ret = BT_STATUS_H2C_FAIL;
  518. goto exit;
  519. }
  520. _rtw_down_sema(&GLBtcBtMpRptSema);
  521. /* GLBtcBtMpRptWait should be 0 here*/
  522. if (!GLBtcBtMpRptWiFiOK) {
  523. RTW_ERR("%s: Didn't get H2C Rsp Event!\n", __FUNCTION__);
  524. ret = BT_STATUS_H2C_TIMTOUT;
  525. goto exit;
  526. }
  527. if (!GLBtcBtMpRptBTOK) {
  528. RTW_DBG("%s: Didn't get BT response!\n", __FUNCTION__);
  529. ret = BT_STATUS_H2C_BT_NO_RSP;
  530. goto exit;
  531. }
  532. if (seq != GLBtcBtMpRptSeq) {
  533. RTW_ERR("%s: Sequence number not match!(%d!=%d)!\n",
  534. __FUNCTION__, seq, GLBtcBtMpRptSeq);
  535. ret = BT_STATUS_C2H_REQNUM_MISMATCH;
  536. goto exit;
  537. }
  538. switch (GLBtcBtMpRptStatus) {
  539. /* Examine the status reported from C2H */
  540. case BT_STATUS_OK:
  541. ret = BT_STATUS_BT_OP_SUCCESS;
  542. RTW_DBG("%s: C2H status = BT_STATUS_BT_OP_SUCCESS\n", __FUNCTION__);
  543. break;
  544. case BT_STATUS_VERSION_MISMATCH:
  545. ret = BT_STATUS_OPCODE_L_VERSION_MISMATCH;
  546. RTW_DBG("%s: C2H status = BT_STATUS_OPCODE_L_VERSION_MISMATCH\n", __FUNCTION__);
  547. break;
  548. case BT_STATUS_UNKNOWN_OPCODE:
  549. ret = BT_STATUS_UNKNOWN_OPCODE_L;
  550. RTW_DBG("%s: C2H status = MP_BT_STATUS_UNKNOWN_OPCODE_L\n", __FUNCTION__);
  551. break;
  552. case BT_STATUS_ERROR_PARAMETER:
  553. ret = BT_STATUS_PARAMETER_FORMAT_ERROR_L;
  554. RTW_DBG("%s: C2H status = MP_BT_STATUS_PARAMETER_FORMAT_ERROR_L\n", __FUNCTION__);
  555. break;
  556. default:
  557. ret = BT_STATUS_UNKNOWN_STATUS_L;
  558. RTW_DBG("%s: C2H status = MP_BT_STATUS_UNKNOWN_STATUS_L\n", __FUNCTION__);
  559. break;
  560. }
  561. exit:
  562. return ret;
  563. }
  564. u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist)
  565. {
  566. if (pBtCoexist->bt_info.get_bt_fw_ver_cnt <= 5) {
  567. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  568. _irqL irqL;
  569. u8 ret;
  570. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  571. ret = _btmpoper_cmd(pBtCoexist, BT_OP_GET_BT_VERSION, 0, NULL, 0);
  572. if (BT_STATUS_BT_OP_SUCCESS == ret) {
  573. pBtCoexist->bt_info.bt_real_fw_ver = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
  574. pBtCoexist->bt_info.bt_fw_ver = *(GLBtcBtMpRptRsp + 2);
  575. pBtCoexist->bt_info.get_bt_fw_ver_cnt++;
  576. }
  577. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  578. } else {
  579. #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
  580. u1Byte dataLen = 2;
  581. u1Byte buf[4] = {0};
  582. buf[0] = 0x0; /* OP_Code */
  583. buf[1] = 0x0; /* OP_Code_Length */
  584. BT_SendEventExtBtCoexControl(pBtCoexist->Adapter, _FALSE, dataLen, &buf[0]);
  585. #endif /* !CONFIG_BT_COEXIST_SOCKET_TRX */
  586. }
  587. }
  588. exit:
  589. return pBtCoexist->bt_info.bt_real_fw_ver;
  590. }
  591. s32 halbtcoutsrc_GetWifiRssi(PADAPTER padapter)
  592. {
  593. PHAL_DATA_TYPE pHalData;
  594. s32 undecorated_smoothed_pwdb = 0;
  595. pHalData = GET_HAL_DATA(padapter);
  596. undecorated_smoothed_pwdb = pHalData->entry_min_undecorated_smoothed_pwdb;
  597. return undecorated_smoothed_pwdb;
  598. }
  599. u32 halbtcoutsrc_GetBtCoexSupportedFeature(void *pBtcContext)
  600. {
  601. PBTC_COEXIST pBtCoexist;
  602. u32 ret = BT_STATUS_BT_OP_SUCCESS;
  603. u32 data = 0;
  604. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  605. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  606. u8 buf[3] = {0};
  607. _irqL irqL;
  608. u8 op_code;
  609. u8 status;
  610. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  611. op_code = BT_OP_GET_BT_COEX_SUPPORTED_FEATURE;
  612. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  613. if (status == BT_STATUS_BT_OP_SUCCESS)
  614. data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
  615. else
  616. ret = SET_BT_MP_OPER_RET(op_code, status);
  617. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  618. } else
  619. ret = BT_STATUS_NOT_IMPLEMENT;
  620. return data;
  621. }
  622. u32 halbtcoutsrc_GetBtCoexSupportedVersion(void *pBtcContext)
  623. {
  624. PBTC_COEXIST pBtCoexist;
  625. u32 ret = BT_STATUS_BT_OP_SUCCESS;
  626. u32 data = 0xFFFF;
  627. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  628. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  629. u8 buf[3] = {0};
  630. _irqL irqL;
  631. u8 op_code;
  632. u8 status;
  633. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  634. op_code = BT_OP_GET_BT_COEX_SUPPORTED_VERSION;
  635. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  636. if (status == BT_STATUS_BT_OP_SUCCESS)
  637. data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
  638. else
  639. ret = SET_BT_MP_OPER_RET(op_code, status);
  640. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  641. } else
  642. ret = BT_STATUS_NOT_IMPLEMENT;
  643. return data;
  644. }
  645. static u8 halbtcoutsrc_GetWifiScanAPNum(PADAPTER padapter)
  646. {
  647. struct mlme_priv *pmlmepriv;
  648. struct mlme_ext_priv *pmlmeext;
  649. static u8 scan_AP_num = 0;
  650. pmlmepriv = &padapter->mlmepriv;
  651. pmlmeext = &padapter->mlmeextpriv;
  652. if (GLBtcWiFiInScanState == _FALSE) {
  653. if (pmlmepriv->num_of_scanned > 0xFF)
  654. scan_AP_num = 0xFF;
  655. else
  656. scan_AP_num = (u8)pmlmepriv->num_of_scanned;
  657. }
  658. return scan_AP_num;
  659. }
  660. u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf)
  661. {
  662. PBTC_COEXIST pBtCoexist;
  663. PADAPTER padapter;
  664. PHAL_DATA_TYPE pHalData;
  665. struct mlme_ext_priv *mlmeext;
  666. u8 bSoftApExist, bVwifiExist;
  667. u8 *pu8;
  668. s32 *pS4Tmp;
  669. u32 *pU4Tmp;
  670. u8 *pU1Tmp;
  671. u8 ret;
  672. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  673. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  674. return _FALSE;
  675. padapter = pBtCoexist->Adapter;
  676. pHalData = GET_HAL_DATA(padapter);
  677. mlmeext = &padapter->mlmeextpriv;
  678. bSoftApExist = _FALSE;
  679. bVwifiExist = _FALSE;
  680. pu8 = (u8 *)pOutBuf;
  681. pS4Tmp = (s32 *)pOutBuf;
  682. pU4Tmp = (u32 *)pOutBuf;
  683. pU1Tmp = (u8 *)pOutBuf;
  684. ret = _TRUE;
  685. switch (getType) {
  686. case BTC_GET_BL_HS_OPERATION:
  687. *pu8 = _FALSE;
  688. ret = _FALSE;
  689. break;
  690. case BTC_GET_BL_HS_CONNECTING:
  691. *pu8 = _FALSE;
  692. ret = _FALSE;
  693. break;
  694. case BTC_GET_BL_WIFI_FW_READY:
  695. *pu8 = halbtcoutsrc_is_fw_ready(pBtCoexist);
  696. break;
  697. case BTC_GET_BL_WIFI_CONNECTED:
  698. *pu8 = (rtw_mi_check_status(padapter, MI_LINKED)) ? _TRUE : _FALSE;
  699. break;
  700. case BTC_GET_BL_WIFI_BUSY:
  701. *pu8 = halbtcoutsrc_IsWifiBusy(padapter);
  702. break;
  703. case BTC_GET_BL_WIFI_SCAN:
  704. #if 0
  705. *pu8 = (rtw_mi_check_fwstate(padapter, WIFI_SITE_MONITOR)) ? _TRUE : _FALSE;
  706. #else
  707. /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag
  708. WIFI_SITE_MONITOR in fwstate may not be cleared in time */
  709. *pu8 = GLBtcWiFiInScanState;
  710. #endif
  711. break;
  712. case BTC_GET_BL_WIFI_LINK:
  713. *pu8 = (rtw_mi_check_status(padapter, MI_STA_LINKING)) ? _TRUE : _FALSE;
  714. break;
  715. case BTC_GET_BL_WIFI_ROAM:
  716. *pu8 = (rtw_mi_check_status(padapter, MI_STA_LINKING)) ? _TRUE : _FALSE;
  717. break;
  718. case BTC_GET_BL_WIFI_4_WAY_PROGRESS:
  719. *pu8 = _FALSE;
  720. break;
  721. case BTC_GET_BL_WIFI_UNDER_5G:
  722. *pu8 = (pHalData->current_band_type == 1) ? _TRUE : _FALSE;
  723. break;
  724. case BTC_GET_BL_WIFI_AP_MODE_ENABLE:
  725. *pu8 = (rtw_mi_check_status(padapter, MI_AP_MODE)) ? _TRUE : _FALSE;
  726. break;
  727. case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION:
  728. *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0 ? _FALSE : _TRUE;
  729. break;
  730. case BTC_GET_BL_WIFI_UNDER_B_MODE:
  731. if (mlmeext->cur_wireless_mode == WIRELESS_11B)
  732. *pu8 = _TRUE;
  733. else
  734. *pu8 = _FALSE;
  735. break;
  736. case BTC_GET_BL_WIFI_IS_IN_MP_MODE:
  737. if (padapter->registrypriv.mp_mode == 0)
  738. *pu8 = _FALSE;
  739. else
  740. *pu8 = _TRUE;
  741. break;
  742. case BTC_GET_BL_EXT_SWITCH:
  743. *pu8 = _FALSE;
  744. break;
  745. case BTC_GET_BL_IS_ASUS_8723B:
  746. /* Always return FALSE in linux driver since this case is added only for windows driver */
  747. *pu8 = _FALSE;
  748. break;
  749. case BTC_GET_BL_RF4CE_CONNECTED:
  750. #ifdef CONFIG_RF4CE_COEXIST
  751. if (hal_btcoex_get_rf4ce_link_state() == 0)
  752. *pu8 = FALSE;
  753. else
  754. *pu8 = TRUE;
  755. #else
  756. *pu8 = FALSE;
  757. #endif
  758. break;
  759. case BTC_GET_S4_WIFI_RSSI:
  760. *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter);
  761. break;
  762. case BTC_GET_S4_HS_RSSI:
  763. *pS4Tmp = 0;
  764. ret = _FALSE;
  765. break;
  766. case BTC_GET_U4_WIFI_BW:
  767. if (IsLegacyOnly(mlmeext->cur_wireless_mode))
  768. *pU4Tmp = BTC_WIFI_BW_LEGACY;
  769. else {
  770. switch (pHalData->current_channel_bw) {
  771. case CHANNEL_WIDTH_20:
  772. *pU4Tmp = BTC_WIFI_BW_HT20;
  773. break;
  774. case CHANNEL_WIDTH_40:
  775. *pU4Tmp = BTC_WIFI_BW_HT40;
  776. break;
  777. case CHANNEL_WIDTH_80:
  778. *pU4Tmp = BTC_WIFI_BW_HT80;
  779. break;
  780. case CHANNEL_WIDTH_160:
  781. *pU4Tmp = BTC_WIFI_BW_HT160;
  782. break;
  783. default:
  784. RTW_INFO("[BTCOEX] unknown bandwidth(%d)\n", pHalData->current_channel_bw);
  785. *pU4Tmp = BTC_WIFI_BW_HT40;
  786. break;
  787. }
  788. }
  789. break;
  790. case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: {
  791. PRT_LINK_DETECT_T plinkinfo;
  792. plinkinfo = &padapter->mlmepriv.LinkDetectInfo;
  793. if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod)
  794. *pU4Tmp = BTC_WIFI_TRAFFIC_TX;
  795. else
  796. *pU4Tmp = BTC_WIFI_TRAFFIC_RX;
  797. }
  798. break;
  799. case BTC_GET_U4_WIFI_FW_VER:
  800. *pU4Tmp = pHalData->firmware_version << 16;
  801. *pU4Tmp |= pHalData->firmware_sub_version;
  802. break;
  803. case BTC_GET_U4_WIFI_LINK_STATUS:
  804. *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
  805. break;
  806. case BTC_GET_U4_BT_PATCH_VER:
  807. *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist);
  808. break;
  809. case BTC_GET_U4_VENDOR:
  810. *pU4Tmp = BTC_VENDOR_OTHER;
  811. break;
  812. case BTC_GET_U4_SUPPORTED_VERSION:
  813. *pU4Tmp = halbtcoutsrc_GetBtCoexSupportedVersion(pBtCoexist);
  814. break;
  815. case BTC_GET_U4_SUPPORTED_FEATURE:
  816. *pU4Tmp = halbtcoutsrc_GetBtCoexSupportedFeature(pBtCoexist);
  817. break;
  818. case BTC_GET_U4_WIFI_IQK_TOTAL:
  819. *pU4Tmp = pHalData->odmpriv.n_iqk_cnt;
  820. break;
  821. case BTC_GET_U4_WIFI_IQK_OK:
  822. *pU4Tmp = pHalData->odmpriv.n_iqk_ok_cnt;
  823. break;
  824. case BTC_GET_U4_WIFI_IQK_FAIL:
  825. *pU4Tmp = pHalData->odmpriv.n_iqk_fail_cnt;
  826. break;
  827. case BTC_GET_U1_WIFI_DOT11_CHNL:
  828. *pU1Tmp = padapter->mlmeextpriv.cur_channel;
  829. break;
  830. case BTC_GET_U1_WIFI_CENTRAL_CHNL:
  831. *pU1Tmp = pHalData->current_channel;
  832. break;
  833. case BTC_GET_U1_WIFI_HS_CHNL:
  834. *pU1Tmp = 0;
  835. ret = _FALSE;
  836. break;
  837. case BTC_GET_U1_WIFI_P2P_CHNL:
  838. #ifdef CONFIG_P2P
  839. {
  840. struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
  841. *pU1Tmp = pwdinfo->operating_channel;
  842. }
  843. #else
  844. *pU1Tmp = 0;
  845. #endif
  846. break;
  847. case BTC_GET_U1_MAC_PHY_MODE:
  848. /* *pU1Tmp = BTC_SMSP;
  849. * *pU1Tmp = BTC_DMSP;
  850. * *pU1Tmp = BTC_DMDP;
  851. * *pU1Tmp = BTC_MP_UNKNOWN; */
  852. break;
  853. case BTC_GET_U1_AP_NUM:
  854. *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter);
  855. break;
  856. case BTC_GET_U1_ANT_TYPE:
  857. switch (pHalData->bt_coexist.btAntisolation) {
  858. case 0:
  859. *pU1Tmp = (u1Byte)BTC_ANT_TYPE_0;
  860. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_0;
  861. break;
  862. case 1:
  863. *pU1Tmp = (u1Byte)BTC_ANT_TYPE_1;
  864. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_1;
  865. break;
  866. case 2:
  867. *pU1Tmp = (u1Byte)BTC_ANT_TYPE_2;
  868. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_2;
  869. break;
  870. case 3:
  871. *pU1Tmp = (u1Byte)BTC_ANT_TYPE_3;
  872. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_3;
  873. break;
  874. case 4:
  875. *pU1Tmp = (u1Byte)BTC_ANT_TYPE_4;
  876. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_4;
  877. break;
  878. }
  879. break;
  880. case BTC_GET_U1_IOT_PEER:
  881. *pU1Tmp = mlmeext->mlmext_info.assoc_AP_vendor;
  882. break;
  883. /* =======1Ant=========== */
  884. case BTC_GET_U1_LPS_MODE:
  885. *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode;
  886. break;
  887. default:
  888. ret = _FALSE;
  889. break;
  890. }
  891. return ret;
  892. }
  893. u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf)
  894. {
  895. PBTC_COEXIST pBtCoexist;
  896. PADAPTER padapter;
  897. PHAL_DATA_TYPE pHalData;
  898. u8 *pu8;
  899. u8 *pU1Tmp;
  900. u32 *pU4Tmp;
  901. u8 ret;
  902. u8 result = _TRUE;
  903. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  904. padapter = pBtCoexist->Adapter;
  905. pHalData = GET_HAL_DATA(padapter);
  906. pu8 = (u8 *)pInBuf;
  907. pU1Tmp = (u8 *)pInBuf;
  908. pU4Tmp = (u32 *)pInBuf;
  909. ret = _TRUE;
  910. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  911. return _FALSE;
  912. switch (setType) {
  913. /* set some u8 type variables. */
  914. case BTC_SET_BL_BT_DISABLE:
  915. pBtCoexist->bt_info.bt_disabled = *pu8;
  916. break;
  917. case BTC_SET_BL_BT_ENABLE_DISABLE_CHANGE:
  918. pBtCoexist->bt_info.bt_enable_disable_change = *pu8;
  919. break;
  920. case BTC_SET_BL_BT_TRAFFIC_BUSY:
  921. pBtCoexist->bt_info.bt_busy = *pu8;
  922. break;
  923. case BTC_SET_BL_BT_LIMITED_DIG:
  924. pBtCoexist->bt_info.limited_dig = *pu8;
  925. break;
  926. case BTC_SET_BL_FORCE_TO_ROAM:
  927. pBtCoexist->bt_info.force_to_roam = *pu8;
  928. break;
  929. case BTC_SET_BL_TO_REJ_AP_AGG_PKT:
  930. pBtCoexist->bt_info.reject_agg_pkt = *pu8;
  931. break;
  932. case BTC_SET_BL_BT_CTRL_AGG_SIZE:
  933. pBtCoexist->bt_info.bt_ctrl_agg_buf_size = *pu8;
  934. break;
  935. case BTC_SET_BL_INC_SCAN_DEV_NUM:
  936. pBtCoexist->bt_info.increase_scan_dev_num = *pu8;
  937. break;
  938. case BTC_SET_BL_BT_TX_RX_MASK:
  939. pBtCoexist->bt_info.bt_tx_rx_mask = *pu8;
  940. break;
  941. case BTC_SET_BL_MIRACAST_PLUS_BT:
  942. pBtCoexist->bt_info.miracast_plus_bt = *pu8;
  943. break;
  944. /* set some u8 type variables. */
  945. case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON:
  946. pBtCoexist->bt_info.rssi_adjust_for_agc_table_on = *pU1Tmp;
  947. break;
  948. case BTC_SET_U1_AGG_BUF_SIZE:
  949. pBtCoexist->bt_info.agg_buf_size = *pU1Tmp;
  950. break;
  951. /* the following are some action which will be triggered */
  952. case BTC_SET_ACT_GET_BT_RSSI:
  953. #if 0
  954. BT_SendGetBtRssiEvent(padapter);
  955. #else
  956. ret = _FALSE;
  957. #endif
  958. break;
  959. case BTC_SET_ACT_AGGREGATE_CTRL:
  960. halbtcoutsrc_AggregationCheck(pBtCoexist);
  961. break;
  962. /* =======1Ant=========== */
  963. /* set some u8 type variables. */
  964. case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE:
  965. pBtCoexist->bt_info.rssi_adjust_for_1ant_coex_type = *pU1Tmp;
  966. break;
  967. case BTC_SET_U1_LPS_VAL:
  968. pBtCoexist->bt_info.lps_val = *pU1Tmp;
  969. break;
  970. case BTC_SET_U1_RPWM_VAL:
  971. pBtCoexist->bt_info.rpwm_val = *pU1Tmp;
  972. break;
  973. /* the following are some action which will be triggered */
  974. case BTC_SET_ACT_LEAVE_LPS:
  975. result = halbtcoutsrc_LeaveLps(pBtCoexist);
  976. break;
  977. case BTC_SET_ACT_ENTER_LPS:
  978. halbtcoutsrc_EnterLps(pBtCoexist);
  979. break;
  980. case BTC_SET_ACT_NORMAL_LPS:
  981. halbtcoutsrc_NormalLps(pBtCoexist);
  982. break;
  983. case BTC_SET_ACT_DISABLE_LOW_POWER:
  984. halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8);
  985. break;
  986. case BTC_SET_ACT_UPDATE_RAMASK:
  987. pBtCoexist->bt_info.ra_mask = *pU4Tmp;
  988. if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == _TRUE) {
  989. struct sta_info *psta;
  990. PWLAN_BSSID_EX cur_network;
  991. cur_network = &padapter->mlmeextpriv.mlmext_info.network;
  992. psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress);
  993. rtw_hal_update_ra_mask(psta, psta->rssi_level, _FALSE);
  994. }
  995. break;
  996. case BTC_SET_ACT_SEND_MIMO_PS: {
  997. u8 newMimoPsMode = 3;
  998. struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
  999. struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
  1000. /* *pU1Tmp = 0 use SM_PS static type */
  1001. /* *pU1Tmp = 1 disable SM_PS */
  1002. if (*pU1Tmp == 0)
  1003. newMimoPsMode = WLAN_HT_CAP_SM_PS_STATIC;
  1004. else if (*pU1Tmp == 1)
  1005. newMimoPsMode = WLAN_HT_CAP_SM_PS_DISABLED;
  1006. if (check_fwstate(&padapter->mlmepriv , WIFI_ASOC_STATE) == _TRUE) {
  1007. /* issue_action_SM_PS(padapter, get_my_bssid(&(pmlmeinfo->network)), newMimoPsMode); */
  1008. issue_action_SM_PS_wait_ack(padapter , get_my_bssid(&(pmlmeinfo->network)) , newMimoPsMode, 3 , 1);
  1009. }
  1010. }
  1011. break;
  1012. case BTC_SET_ACT_CTRL_BT_INFO:
  1013. #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
  1014. {
  1015. u8 dataLen = *pU1Tmp;
  1016. u8 tmpBuf[BTC_TMP_BUF_SHORT];
  1017. if (dataLen)
  1018. _rtw_memcpy(tmpBuf, pU1Tmp + 1, dataLen);
  1019. BT_SendEventExtBtInfoControl(padapter, dataLen, &tmpBuf[0]);
  1020. }
  1021. #else /* !CONFIG_BT_COEXIST_SOCKET_TRX */
  1022. ret = _FALSE;
  1023. #endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
  1024. break;
  1025. case BTC_SET_ACT_CTRL_BT_COEX:
  1026. #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
  1027. {
  1028. u8 dataLen = *pU1Tmp;
  1029. u8 tmpBuf[BTC_TMP_BUF_SHORT];
  1030. if (dataLen)
  1031. _rtw_memcpy(tmpBuf, pU1Tmp + 1, dataLen);
  1032. BT_SendEventExtBtCoexControl(padapter, _FALSE, dataLen, &tmpBuf[0]);
  1033. }
  1034. #else /* !CONFIG_BT_COEXIST_SOCKET_TRX */
  1035. ret = _FALSE;
  1036. #endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
  1037. break;
  1038. case BTC_SET_ACT_CTRL_8723B_ANT:
  1039. #if 0
  1040. {
  1041. u1Byte dataLen = *pU1Tmp;
  1042. u1Byte tmpBuf[BTC_TMP_BUF_SHORT];
  1043. if (dataLen)
  1044. PlatformMoveMemory(&tmpBuf[0], pU1Tmp + 1, dataLen);
  1045. BT_Set8723bAnt(Adapter, dataLen, &tmpBuf[0]);
  1046. }
  1047. #else
  1048. ret = _FALSE;
  1049. #endif
  1050. break;
  1051. /* ===================== */
  1052. default:
  1053. ret = _FALSE;
  1054. break;
  1055. }
  1056. return result;
  1057. }
  1058. u8 halbtcoutsrc_UnderIps(PBTC_COEXIST pBtCoexist)
  1059. {
  1060. PADAPTER padapter;
  1061. struct pwrctrl_priv *pwrpriv;
  1062. u8 bMacPwrCtrlOn;
  1063. padapter = pBtCoexist->Adapter;
  1064. pwrpriv = &padapter->dvobj->pwrctl_priv;
  1065. bMacPwrCtrlOn = _FALSE;
  1066. if ((_TRUE == pwrpriv->bips_processing)
  1067. && (IPS_NONE != pwrpriv->ips_mode_req)
  1068. )
  1069. return _TRUE;
  1070. if (rf_off == pwrpriv->rf_pwrstate)
  1071. return _TRUE;
  1072. rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn);
  1073. if (_FALSE == bMacPwrCtrlOn)
  1074. return _TRUE;
  1075. return _FALSE;
  1076. }
  1077. u8 halbtcoutsrc_UnderLps(PBTC_COEXIST pBtCoexist)
  1078. {
  1079. return GLBtcWiFiInLPS;
  1080. }
  1081. u8 halbtcoutsrc_Under32K(PBTC_COEXIST pBtCoexist)
  1082. {
  1083. /* todo: the method to check whether wifi is under 32K or not */
  1084. return _FALSE;
  1085. }
  1086. void halbtcoutsrc_DisplayCoexStatistics(PBTC_COEXIST pBtCoexist)
  1087. {
  1088. #if 0
  1089. PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
  1090. PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
  1091. PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
  1092. u8 *cliBuf = pBtCoexist->cliBuf;
  1093. u1Byte i, j;
  1094. u1Byte tmpbuf[BTC_TMP_BUF_SHORT];
  1095. if (gl_coex_offload.cnt_h2c_sent) {
  1096. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex h2c notify]============");
  1097. CL_PRINTF(cliBuf);
  1098. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = H2c(%d)/Ack(%d)", "Coex h2c/c2h overall statistics",
  1099. gl_coex_offload.cnt_h2c_sent, gl_coex_offload.cnt_c2h_ack);
  1100. for (j = 0; j < COL_STATUS_MAX; j++) {
  1101. if (gl_coex_offload.status[j]) {
  1102. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.status[j]);
  1103. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
  1104. }
  1105. }
  1106. CL_PRINTF(cliBuf);
  1107. }
  1108. for (i = 0; i < COL_OP_WIFI_OPCODE_MAX; i++) {
  1109. if (gl_coex_offload.h2c_record[i].count) {
  1110. /*==========================================*/
  1111. /* H2C result statistics*/
  1112. /*==========================================*/
  1113. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = total:%d", coexOpcodeString[i], gl_coex_offload.h2c_record[i].count);
  1114. for (j = 0; j < COL_STATUS_MAX; j++) {
  1115. if (gl_coex_offload.h2c_record[i].status[j]) {
  1116. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.h2c_record[i].status[j]);
  1117. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
  1118. }
  1119. }
  1120. CL_PRINTF(cliBuf);
  1121. /*==========================================*/
  1122. /* H2C/C2H content*/
  1123. /*==========================================*/
  1124. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = ", "H2C / C2H content");
  1125. for (j = 0; j < gl_coex_offload.h2c_record[i].h2c_len; j++) {
  1126. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.h2c_record[i].h2c_buf[j]);
  1127. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
  1128. }
  1129. if (gl_coex_offload.h2c_record[i].c2h_ack_len) {
  1130. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, "/ ", 2);
  1131. for (j = 0; j < gl_coex_offload.h2c_record[i].c2h_ack_len; j++) {
  1132. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.h2c_record[i].c2h_ack_buf[j]);
  1133. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
  1134. }
  1135. }
  1136. CL_PRINTF(cliBuf);
  1137. /*==========================================*/
  1138. }
  1139. }
  1140. if (gl_coex_offload.cnt_c2h_ind) {
  1141. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex c2h indication]============");
  1142. CL_PRINTF(cliBuf);
  1143. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = Ind(%d)", "C2H indication statistics",
  1144. gl_coex_offload.cnt_c2h_ind);
  1145. for (j = 0; j < COL_STATUS_MAX; j++) {
  1146. if (gl_coex_offload.c2h_ind_status[j]) {
  1147. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.c2h_ind_status[j]);
  1148. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
  1149. }
  1150. }
  1151. CL_PRINTF(cliBuf);
  1152. }
  1153. for (i = 0; i < COL_IND_MAX; i++) {
  1154. if (gl_coex_offload.c2h_ind_record[i].count) {
  1155. /*==========================================*/
  1156. /* H2C result statistics*/
  1157. /*==========================================*/
  1158. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = total:%d", coexIndTypeString[i], gl_coex_offload.c2h_ind_record[i].count);
  1159. for (j = 0; j < COL_STATUS_MAX; j++) {
  1160. if (gl_coex_offload.c2h_ind_record[i].status[j]) {
  1161. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, ", %s:%d", coexH2cResultString[j], gl_coex_offload.c2h_ind_record[i].status[j]);
  1162. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, BTC_TMP_BUF_SHORT);
  1163. }
  1164. }
  1165. CL_PRINTF(cliBuf);
  1166. /*==========================================*/
  1167. /* content*/
  1168. /*==========================================*/
  1169. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = ", "C2H indication content");
  1170. for (j = 0; j < gl_coex_offload.c2h_ind_record[i].ind_len; j++) {
  1171. CL_SPRINTF(tmpbuf, BTC_TMP_BUF_SHORT, "%02x ", gl_coex_offload.c2h_ind_record[i].ind_buf[j]);
  1172. CL_STRNCAT(cliBuf, BT_TMP_BUF_SIZE, tmpbuf, 3);
  1173. }
  1174. CL_PRINTF(cliBuf);
  1175. /*==========================================*/
  1176. }
  1177. }
  1178. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Statistics]============");
  1179. CL_PRINTF(cliBuf);
  1180. #if (H2C_USE_IO_THREAD != 1)
  1181. for (i = 0; i < H2C_STATUS_MAX; i++) {
  1182. if (pHalData->h2cStatistics[i]) {
  1183. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
  1184. h2cStaString[i], pHalData->h2cStatistics[i]);
  1185. CL_PRINTF(cliBuf);
  1186. }
  1187. }
  1188. #else
  1189. for (i = 0; i < IO_STATUS_MAX; i++) {
  1190. if (Adapter->ioComStr.ioH2cStatistics[i]) {
  1191. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \
  1192. ioStaString[i], Adapter->ioComStr.ioH2cStatistics[i]);
  1193. CL_PRINTF(cliBuf);
  1194. }
  1195. }
  1196. #endif
  1197. #if 0
  1198. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "lastHMEBoxNum", \
  1199. pHalData->LastHMEBoxNum);
  1200. CL_PRINTF(cliBuf);
  1201. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x / 0x%x", "LastOkH2c/FirstFailH2c(fwNotRead)", \
  1202. pHalData->lastSuccessH2cEid, pHalData->firstFailedH2cEid);
  1203. CL_PRINTF(cliBuf);
  1204. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "c2hIsr/c2hIntr/clr1AF/noRdy/noBuf", \
  1205. pHalData->InterruptLog.nIMR_C2HCMD, DBG_Var.c2hInterruptCnt, DBG_Var.c2hClrReadC2hCnt,
  1206. DBG_Var.c2hNotReadyCnt, DBG_Var.c2hBufAlloFailCnt);
  1207. CL_PRINTF(cliBuf);
  1208. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "c2hPacket", \
  1209. DBG_Var.c2hPacketCnt);
  1210. CL_PRINTF(cliBuf);
  1211. #endif
  1212. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Periodical/ DbgCtrl", \
  1213. pBtCoexist->statistics.cntPeriodical, pBtCoexist->statistics.cntDbgCtrl);
  1214. CL_PRINTF(cliBuf);
  1215. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "PowerOn/InitHw/InitCoexDm/RfStatus", \
  1216. pBtCoexist->statistics.cntPowerOn, pBtCoexist->statistics.cntInitHwConfig, pBtCoexist->statistics.cntInitCoexDm,
  1217. pBtCoexist->statistics.cntRfStatusNotify);
  1218. CL_PRINTF(cliBuf);
  1219. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "Ips/Lps/Scan/Connect/Mstatus", \
  1220. pBtCoexist->statistics.cntIpsNotify, pBtCoexist->statistics.cntLpsNotify,
  1221. pBtCoexist->statistics.cntScanNotify, pBtCoexist->statistics.cntConnectNotify,
  1222. pBtCoexist->statistics.cntMediaStatusNotify);
  1223. CL_PRINTF(cliBuf);
  1224. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Special pkt/Bt info/ bind",
  1225. pBtCoexist->statistics.cntSpecialPacketNotify, pBtCoexist->statistics.cntBtInfoNotify,
  1226. pBtCoexist->statistics.cntBind);
  1227. CL_PRINTF(cliBuf);
  1228. #endif
  1229. PADAPTER padapter = pBtCoexist->Adapter;
  1230. PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
  1231. u8 *cliBuf = pBtCoexist->cli_buf;
  1232. if (pHalData->EEPROMBluetoothCoexist == 1) {
  1233. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Coex Status]============");
  1234. CL_PRINTF(cliBuf);
  1235. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IsBtDisabled", rtw_btcoex_IsBtDisabled(padapter));
  1236. CL_PRINTF(cliBuf);
  1237. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IsBtControlLps", rtw_btcoex_IsBtControlLps(padapter));
  1238. CL_PRINTF(cliBuf);
  1239. }
  1240. }
  1241. void halbtcoutsrc_DisplayBtLinkInfo(PBTC_COEXIST pBtCoexist)
  1242. {
  1243. #if 0
  1244. PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter;
  1245. PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt;
  1246. u8 *cliBuf = pBtCoexist->cliBuf;
  1247. u8 i;
  1248. if (pBtCoexist->stack_info.profile_notified) {
  1249. for (i = 0; i < pBtMgnt->ExtConfig.NumberOfACL; i++) {
  1250. if (pBtMgnt->ExtConfig.HCIExtensionVer >= 1) {
  1251. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "Bt link type/spec/role", \
  1252. BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
  1253. BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec],
  1254. BtLinkRoleString[pBtMgnt->ExtConfig.aclLink[i].linkRole]);
  1255. CL_PRINTF(cliBuf);
  1256. } else {
  1257. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "Bt link type/spec", \
  1258. BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile],
  1259. BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec]);
  1260. CL_PRINTF(cliBuf);
  1261. }
  1262. }
  1263. }
  1264. #endif
  1265. }
  1266. void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist)
  1267. {
  1268. PADAPTER padapter = pBtCoexist->Adapter;
  1269. struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
  1270. u8 *cliBuf = pBtCoexist->cli_buf;
  1271. s32 wifiRssi = 0, btHsRssi = 0;
  1272. BOOLEAN bScan = _FALSE, bLink = _FALSE, bRoam = _FALSE, bWifiBusy = _FALSE, bWifiUnderBMode = _FALSE;
  1273. u32 wifiBw = BTC_WIFI_BW_HT20, wifiTrafficDir = BTC_WIFI_TRAFFIC_TX, wifiFreq = BTC_FREQ_2_4G;
  1274. u32 wifiLinkStatus = 0x0;
  1275. BOOLEAN bBtHsOn = _FALSE, bLowPower = _FALSE;
  1276. u8 wifiChnl = 0, wifiP2PChnl = 0, nScanAPNum = 0, FwPSState;
  1277. u32 iqk_cnt_total = 0, iqk_cnt_ok = 0, iqk_cnt_fail = 0;
  1278. wifiLinkStatus = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist);
  1279. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "STA/vWifi/HS/p2pGo/p2pGc", \
  1280. ((wifiLinkStatus & WIFI_STA_CONNECTED) ? 1 : 0), ((wifiLinkStatus & WIFI_AP_CONNECTED) ? 1 : 0),
  1281. ((wifiLinkStatus & WIFI_HS_CONNECTED) ? 1 : 0), ((wifiLinkStatus & WIFI_P2P_GO_CONNECTED) ? 1 : 0),
  1282. ((wifiLinkStatus & WIFI_P2P_GC_CONNECTED) ? 1 : 0));
  1283. CL_PRINTF(cliBuf);
  1284. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan);
  1285. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink);
  1286. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam);
  1287. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Link/ Roam/ Scan", \
  1288. bLink, bRoam, bScan);
  1289. CL_PRINTF(cliBuf);
  1290. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_TOTAL, &iqk_cnt_total);
  1291. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_OK, &iqk_cnt_ok);
  1292. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_IQK_FAIL, &iqk_cnt_fail);
  1293. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d %s %s",
  1294. "IQK All/ OK/ Fail/AutoLoad/FWDL", iqk_cnt_total, iqk_cnt_ok, iqk_cnt_fail,
  1295. ((halbtcoutsrc_is_autoload_fail(pBtCoexist) == _TRUE) ? "fail":"ok"), ((halbtcoutsrc_is_fw_ready(pBtCoexist) == _TRUE) ? "ok":"fail"));
  1296. CL_PRINTF(cliBuf);
  1297. if (wifiLinkStatus & WIFI_STA_CONNECTED) {
  1298. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "IOT Peer", GLBtcIotPeerString[padapter->mlmeextpriv.mlmext_info.assoc_AP_vendor]);
  1299. CL_PRINTF(cliBuf);
  1300. }
  1301. pBtCoexist->btc_get(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi);
  1302. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiChnl);
  1303. if ((wifiLinkStatus & WIFI_P2P_GO_CONNECTED) || (wifiLinkStatus & WIFI_P2P_GC_CONNECTED))
  1304. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_WIFI_P2P_CHNL, &wifiP2PChnl);
  1305. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d dBm/ %d/ %d", "RSSI/ STA_Chnl/ P2P_Chnl", \
  1306. wifiRssi -100, wifiChnl, wifiP2PChnl);
  1307. CL_PRINTF(cliBuf);
  1308. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifiFreq);
  1309. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw);
  1310. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy);
  1311. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir);
  1312. pBtCoexist->btc_get(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode);
  1313. pBtCoexist->btc_get(pBtCoexist, BTC_GET_U1_AP_NUM, &nScanAPNum);
  1314. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s/ %d ", "Band/ BW/ Traffic/ APCnt", \
  1315. GLBtcWifiFreqString[wifiFreq], ((bWifiUnderBMode) ? "11b" : GLBtcWifiBwString[wifiBw]),
  1316. ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")),
  1317. nScanAPNum);
  1318. CL_PRINTF(cliBuf);
  1319. /* power status */
  1320. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s%s%s", "Power Status", \
  1321. ((halbtcoutsrc_UnderIps(pBtCoexist) == _TRUE) ? "IPS ON" : "IPS OFF"),
  1322. ((halbtcoutsrc_UnderLps(pBtCoexist) == _TRUE) ? ", LPS ON" : ", LPS OFF"),
  1323. ((halbtcoutsrc_Under32K(pBtCoexist) == _TRUE) ? ", 32k" : ""));
  1324. CL_PRINTF(cliBuf);
  1325. CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)", "Power mode cmd(lps/rpwm)", \
  1326. pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1],
  1327. pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3],
  1328. pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5],
  1329. pBtCoexist->bt_info.lps_val,
  1330. pBtCoexist->bt_info.rpwm_val);
  1331. CL_PRINTF(cliBuf);
  1332. }
  1333. void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType)
  1334. {
  1335. PBTC_COEXIST pBtCoexist;
  1336. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1337. switch (dispType) {
  1338. case BTC_DBG_DISP_COEX_STATISTICS:
  1339. halbtcoutsrc_DisplayCoexStatistics(pBtCoexist);
  1340. break;
  1341. case BTC_DBG_DISP_BT_LINK_INFO:
  1342. halbtcoutsrc_DisplayBtLinkInfo(pBtCoexist);
  1343. break;
  1344. case BTC_DBG_DISP_WIFI_STATUS:
  1345. halbtcoutsrc_DisplayWifiStatus(pBtCoexist);
  1346. break;
  1347. default:
  1348. break;
  1349. }
  1350. }
  1351. /* ************************************
  1352. * IO related function
  1353. * ************************************ */
  1354. u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr)
  1355. {
  1356. PBTC_COEXIST pBtCoexist;
  1357. PADAPTER padapter;
  1358. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1359. padapter = pBtCoexist->Adapter;
  1360. return rtw_read8(padapter, RegAddr);
  1361. }
  1362. u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr)
  1363. {
  1364. PBTC_COEXIST pBtCoexist;
  1365. PADAPTER padapter;
  1366. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1367. padapter = pBtCoexist->Adapter;
  1368. return rtw_read16(padapter, RegAddr);
  1369. }
  1370. u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr)
  1371. {
  1372. PBTC_COEXIST pBtCoexist;
  1373. PADAPTER padapter;
  1374. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1375. padapter = pBtCoexist->Adapter;
  1376. return rtw_read32(padapter, RegAddr);
  1377. }
  1378. void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
  1379. {
  1380. PBTC_COEXIST pBtCoexist;
  1381. PADAPTER padapter;
  1382. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1383. padapter = pBtCoexist->Adapter;
  1384. rtw_write8(padapter, RegAddr, Data);
  1385. }
  1386. void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b)
  1387. {
  1388. PBTC_COEXIST pBtCoexist;
  1389. PADAPTER padapter;
  1390. u8 originalValue, bitShift;
  1391. u8 i;
  1392. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1393. padapter = pBtCoexist->Adapter;
  1394. originalValue = 0;
  1395. bitShift = 0;
  1396. if (bitMask != 0xff) {
  1397. originalValue = rtw_read8(padapter, regAddr);
  1398. for (i = 0; i <= 7; i++) {
  1399. if ((bitMask >> i) & 0x1)
  1400. break;
  1401. }
  1402. bitShift = i;
  1403. data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask);
  1404. }
  1405. rtw_write8(padapter, regAddr, data1b);
  1406. }
  1407. void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data)
  1408. {
  1409. PBTC_COEXIST pBtCoexist;
  1410. PADAPTER padapter;
  1411. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1412. padapter = pBtCoexist->Adapter;
  1413. rtw_write16(padapter, RegAddr, Data);
  1414. }
  1415. void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data)
  1416. {
  1417. PBTC_COEXIST pBtCoexist;
  1418. PADAPTER padapter;
  1419. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1420. padapter = pBtCoexist->Adapter;
  1421. rtw_write32(padapter, RegAddr, Data);
  1422. }
  1423. void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data)
  1424. {
  1425. PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1426. PADAPTER Adapter = pBtCoexist->Adapter;
  1427. if (BTC_INTF_SDIO == pBtCoexist->chip_interface)
  1428. rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data);
  1429. else
  1430. rtw_write8(Adapter, RegAddr, Data);
  1431. }
  1432. void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data)
  1433. {
  1434. PBTC_COEXIST pBtCoexist;
  1435. PADAPTER padapter;
  1436. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1437. padapter = pBtCoexist->Adapter;
  1438. phy_set_bb_reg(padapter, RegAddr, BitMask, Data);
  1439. }
  1440. u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask)
  1441. {
  1442. PBTC_COEXIST pBtCoexist;
  1443. PADAPTER padapter;
  1444. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1445. padapter = pBtCoexist->Adapter;
  1446. return phy_query_bb_reg(padapter, RegAddr, BitMask);
  1447. }
  1448. void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data)
  1449. {
  1450. PBTC_COEXIST pBtCoexist;
  1451. PADAPTER padapter;
  1452. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1453. padapter = pBtCoexist->Adapter;
  1454. phy_set_rf_reg(padapter, eRFPath, RegAddr, BitMask, Data);
  1455. }
  1456. u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask)
  1457. {
  1458. PBTC_COEXIST pBtCoexist;
  1459. PADAPTER padapter;
  1460. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1461. padapter = pBtCoexist->Adapter;
  1462. return phy_query_rf_reg(padapter, eRFPath, RegAddr, BitMask);
  1463. }
  1464. u16 halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data)
  1465. {
  1466. PBTC_COEXIST pBtCoexist;
  1467. u16 ret = BT_STATUS_BT_OP_SUCCESS;
  1468. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1469. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  1470. u8 buf[3] = {0};
  1471. _irqL irqL;
  1472. u8 op_code;
  1473. u8 status;
  1474. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1475. Data = cpu_to_le32(Data);
  1476. op_code = BT_OP_WRITE_REG_VALUE;
  1477. status = _btmpoper_cmd(pBtCoexist, op_code, 0, (u8 *)&Data, 3);
  1478. if (status != BT_STATUS_BT_OP_SUCCESS)
  1479. ret = SET_BT_MP_OPER_RET(op_code, status);
  1480. else {
  1481. buf[0] = RegType;
  1482. *(u16 *)(buf + 1) = cpu_to_le16((u16)RegAddr);
  1483. op_code = BT_OP_WRITE_REG_ADDR;
  1484. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3);
  1485. if (status != BT_STATUS_BT_OP_SUCCESS)
  1486. ret = SET_BT_MP_OPER_RET(op_code, status);
  1487. }
  1488. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1489. } else
  1490. ret = BT_STATUS_NOT_IMPLEMENT;
  1491. return ret;
  1492. }
  1493. u8 halbtcoutsrc_SetBtAntDetection(void *pBtcContext, u8 txTime, u8 btChnl)
  1494. {
  1495. /* Always return _FALSE since we don't implement this yet */
  1496. #if 0
  1497. PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1498. PADAPTER Adapter = pBtCoexist->Adapter;
  1499. u1Byte btCanTx = 0;
  1500. BOOLEAN bStatus = FALSE;
  1501. bStatus = NDBG_SetBtAntDetection(Adapter, txTime, btChnl, &btCanTx);
  1502. if (bStatus && btCanTx)
  1503. return _TRUE;
  1504. else
  1505. return _FALSE;
  1506. #else
  1507. return _FALSE;
  1508. #endif
  1509. }
  1510. BOOLEAN
  1511. halbtcoutsrc_SetBtTRXMASK(
  1512. IN PVOID pBtcContext,
  1513. IN u1Byte bt_trx_mask
  1514. )
  1515. {
  1516. /* Always return _FALSE since we don't implement this yet */
  1517. #if 0
  1518. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1519. PADAPTER Adapter = pBtCoexist->Adapter;
  1520. BOOLEAN bStatus = FALSE;
  1521. u1Byte btCanTx = 0;
  1522. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter) || IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)
  1523. || IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  1524. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter))
  1525. bStatus = NDBG_SetBtTRXMASK(Adapter, 1, bt_trx_mask, &btCanTx);
  1526. else
  1527. bStatus = NDBG_SetBtTRXMASK(Adapter, 2, bt_trx_mask, &btCanTx);
  1528. }
  1529. if (bStatus)
  1530. return TRUE;
  1531. else
  1532. return FALSE;
  1533. #else
  1534. return _FALSE;
  1535. #endif
  1536. }
  1537. u16 halbtcoutsrc_GetBtReg_with_status(void *pBtcContext, u8 RegType, u32 RegAddr, u32 *data)
  1538. {
  1539. PBTC_COEXIST pBtCoexist;
  1540. u16 ret = BT_STATUS_BT_OP_SUCCESS;
  1541. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1542. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  1543. u8 buf[3] = {0};
  1544. _irqL irqL;
  1545. u8 op_code;
  1546. u8 status;
  1547. buf[0] = RegType;
  1548. *(u16 *)(buf + 1) = cpu_to_le16((u16)RegAddr);
  1549. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1550. op_code = BT_OP_READ_REG;
  1551. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3);
  1552. if (status == BT_STATUS_BT_OP_SUCCESS)
  1553. *data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
  1554. else
  1555. ret = SET_BT_MP_OPER_RET(op_code, status);
  1556. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1557. } else
  1558. ret = BT_STATUS_NOT_IMPLEMENT;
  1559. return ret;
  1560. }
  1561. u32 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr)
  1562. {
  1563. u32 regVal;
  1564. return (BT_STATUS_BT_OP_SUCCESS == halbtcoutsrc_GetBtReg_with_status(pBtcContext, RegType, RegAddr, &regVal)) ? regVal : 0xffffffff;
  1565. }
  1566. void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer)
  1567. {
  1568. PBTC_COEXIST pBtCoexist;
  1569. PADAPTER padapter;
  1570. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1571. padapter = pBtCoexist->Adapter;
  1572. rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer);
  1573. }
  1574. static void halbtcoutsrc_coex_offload_init(void)
  1575. {
  1576. u1Byte i;
  1577. gl_coex_offload.h2c_req_num = 0;
  1578. gl_coex_offload.cnt_h2c_sent = 0;
  1579. gl_coex_offload.cnt_c2h_ack = 0;
  1580. gl_coex_offload.cnt_c2h_ind = 0;
  1581. for (i = 0; i < COL_MAX_H2C_REQ_NUM; i++)
  1582. init_completion(&gl_coex_offload.c2h_event[i]);
  1583. }
  1584. static COL_H2C_STATUS halbtcoutsrc_send_h2c(PADAPTER Adapter, PCOL_H2C pcol_h2c, u16 h2c_cmd_len)
  1585. {
  1586. COL_H2C_STATUS h2c_status = COL_STATUS_C2H_OK;
  1587. u8 i;
  1588. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0))
  1589. reinit_completion(&gl_coex_offload.c2h_event[pcol_h2c->req_num]); /* set event to un signaled state */
  1590. #else
  1591. INIT_COMPLETION(gl_coex_offload.c2h_event[pcol_h2c->req_num]);
  1592. #endif
  1593. if (TRUE) {
  1594. #if 0 /*(USE_HAL_MAC_API == 1) */
  1595. if (RT_STATUS_SUCCESS == HAL_MAC_Send_BT_COEX(&GET_HAL_MAC_INFO(Adapter), (pu1Byte)(pcol_h2c), (u4Byte)h2c_cmd_len, 1)) {
  1596. if (!wait_for_completion_timeout(&gl_coex_offload.c2h_event[pcol_h2c->req_num], 20)) {
  1597. h2c_status = COL_STATUS_H2C_TIMTOUT;
  1598. }
  1599. } else {
  1600. h2c_status = COL_STATUS_H2C_HALMAC_FAIL;
  1601. }
  1602. #endif
  1603. }
  1604. return h2c_status;
  1605. }
  1606. static COL_H2C_STATUS halbtcoutsrc_check_c2h_ack(PADAPTER Adapter, PCOL_SINGLE_H2C_RECORD pH2cRecord)
  1607. {
  1608. COL_H2C_STATUS c2h_status = COL_STATUS_C2H_OK;
  1609. PCOL_H2C p_h2c_cmd = (PCOL_H2C)&pH2cRecord->h2c_buf[0];
  1610. u8 req_num = p_h2c_cmd->req_num;
  1611. PCOL_C2H_ACK p_c2h_ack = (PCOL_C2H_ACK)&gl_coex_offload.c2h_ack_buf[req_num];
  1612. if ((COL_C2H_ACK_HDR_LEN + p_c2h_ack->ret_len) > gl_coex_offload.c2h_ack_len[req_num]) {
  1613. c2h_status = COL_STATUS_COEX_DATA_OVERFLOW;
  1614. return c2h_status;
  1615. }
  1616. /* else */
  1617. {
  1618. _rtw_memmove(&pH2cRecord->c2h_ack_buf[0], &gl_coex_offload.c2h_ack_buf[req_num], gl_coex_offload.c2h_ack_len[req_num]);
  1619. pH2cRecord->c2h_ack_len = gl_coex_offload.c2h_ack_len[req_num];
  1620. }
  1621. if (p_c2h_ack->req_num != p_h2c_cmd->req_num) {
  1622. c2h_status = COL_STATUS_C2H_REQ_NUM_MISMATCH;
  1623. } else if (p_c2h_ack->opcode_ver != p_h2c_cmd->opcode_ver) {
  1624. c2h_status = COL_STATUS_C2H_OPCODE_VER_MISMATCH;
  1625. } else {
  1626. c2h_status = p_c2h_ack->status;
  1627. }
  1628. return c2h_status;
  1629. }
  1630. COL_H2C_STATUS halbtcoutsrc_CoexH2cProcess(void *pBtCoexist,
  1631. u8 opcode, u8 opcode_ver, u8 *ph2c_par, u8 h2c_par_len)
  1632. {
  1633. PADAPTER Adapter = ((struct btc_coexist *)pBtCoexist)->Adapter;
  1634. u8 H2C_Parameter[BTC_TMP_BUF_SHORT] = {0};
  1635. PCOL_H2C pcol_h2c = (PCOL_H2C)&H2C_Parameter[0];
  1636. u16 paraLen = 0;
  1637. COL_H2C_STATUS h2c_status = COL_STATUS_C2H_OK, c2h_status = COL_STATUS_C2H_OK;
  1638. COL_H2C_STATUS ret_status = COL_STATUS_C2H_OK;
  1639. u16 i, col_h2c_len = 0;
  1640. pcol_h2c->opcode = opcode;
  1641. pcol_h2c->opcode_ver = opcode_ver;
  1642. pcol_h2c->req_num = gl_coex_offload.h2c_req_num;
  1643. gl_coex_offload.h2c_req_num++;
  1644. gl_coex_offload.h2c_req_num %= 16;
  1645. _rtw_memmove(&pcol_h2c->buf[0], ph2c_par, h2c_par_len);
  1646. col_h2c_len = h2c_par_len + 2; /* 2=sizeof(OPCode, OPCode_version and Request number) */
  1647. BT_PrintData(Adapter, "[COL], H2C cmd: ", col_h2c_len, H2C_Parameter);
  1648. gl_coex_offload.cnt_h2c_sent++;
  1649. gl_coex_offload.h2c_record[opcode].count++;
  1650. gl_coex_offload.h2c_record[opcode].h2c_len = col_h2c_len;
  1651. _rtw_memmove((PVOID)&gl_coex_offload.h2c_record[opcode].h2c_buf[0], (PVOID)pcol_h2c, col_h2c_len);
  1652. h2c_status = halbtcoutsrc_send_h2c(Adapter, pcol_h2c, col_h2c_len);
  1653. gl_coex_offload.h2c_record[opcode].c2h_ack_len = 0;
  1654. if (COL_STATUS_C2H_OK == h2c_status) {
  1655. /* if reach here, it means H2C get the correct c2h response, */
  1656. c2h_status = halbtcoutsrc_check_c2h_ack(Adapter, &gl_coex_offload.h2c_record[opcode]);
  1657. ret_status = c2h_status;
  1658. } else {
  1659. /* check h2c status error, return error status code to upper layer. */
  1660. ret_status = h2c_status;
  1661. }
  1662. gl_coex_offload.h2c_record[opcode].status[ret_status]++;
  1663. gl_coex_offload.status[ret_status]++;
  1664. return ret_status;
  1665. }
  1666. u8 halbtcoutsrc_GetAntDetValFromBt(void *pBtcContext)
  1667. {
  1668. /* Always return 0 since we don't implement this yet */
  1669. #if 0
  1670. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1671. PADAPTER Adapter = pBtCoexist->Adapter;
  1672. u1Byte AntDetVal = 0x0;
  1673. u1Byte opcodeVer = 1;
  1674. BOOLEAN status = false;
  1675. status = NDBG_GetAntDetValFromBt(Adapter, opcodeVer, &AntDetVal);
  1676. RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$ halbtcoutsrc_GetAntDetValFromBt(): status = %d, feature = %x\n", status, AntDetVal));
  1677. return AntDetVal;
  1678. #else
  1679. return 0;
  1680. #endif
  1681. }
  1682. u8 halbtcoutsrc_GetBleScanTypeFromBt(void *pBtcContext)
  1683. {
  1684. PBTC_COEXIST pBtCoexist;
  1685. u32 ret = BT_STATUS_BT_OP_SUCCESS;
  1686. u8 data = 0;
  1687. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1688. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  1689. u8 buf[3] = {0};
  1690. _irqL irqL;
  1691. u8 op_code;
  1692. u8 status;
  1693. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1694. op_code = BT_OP_GET_BT_BLE_SCAN_TYPE;
  1695. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  1696. if (status == BT_STATUS_BT_OP_SUCCESS)
  1697. data = *(u8 *)GLBtcBtMpRptRsp;
  1698. else
  1699. ret = SET_BT_MP_OPER_RET(op_code, status);
  1700. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1701. } else
  1702. ret = BT_STATUS_NOT_IMPLEMENT;
  1703. return data;
  1704. }
  1705. u32 halbtcoutsrc_GetBleScanParaFromBt(void *pBtcContext, u8 scanType)
  1706. {
  1707. PBTC_COEXIST pBtCoexist;
  1708. u32 ret = BT_STATUS_BT_OP_SUCCESS;
  1709. u32 data = 0;
  1710. pBtCoexist = (PBTC_COEXIST)pBtcContext;
  1711. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) {
  1712. u8 buf[3] = {0};
  1713. _irqL irqL;
  1714. u8 op_code;
  1715. u8 status;
  1716. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1717. op_code = BT_OP_GET_BT_BLE_SCAN_PARA;
  1718. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  1719. if (status == BT_STATUS_BT_OP_SUCCESS)
  1720. data = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
  1721. else
  1722. ret = SET_BT_MP_OPER_RET(op_code, status);
  1723. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1724. } else
  1725. ret = BT_STATUS_NOT_IMPLEMENT;
  1726. return data;
  1727. }
  1728. u8 halbtcoutsrc_GetBtAFHMapFromBt(void *pBtcContext, u8 mapType, u8 *afhMap)
  1729. {
  1730. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1731. u8 buf[2] = {0};
  1732. _irqL irqL;
  1733. u8 op_code;
  1734. u32 *AfhMapL = (u32 *)&(afhMap[0]);
  1735. u32 *AfhMapM = (u32 *)&(afhMap[4]);
  1736. u16 *AfhMapH = (u16 *)&(afhMap[8]);
  1737. u8 status;
  1738. u32 ret = BT_STATUS_BT_OP_SUCCESS;
  1739. if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _FALSE)
  1740. return _FALSE;
  1741. buf[0] = 0;
  1742. buf[1] = mapType;
  1743. _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1744. op_code = BT_LO_OP_GET_AFH_MAP_L;
  1745. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  1746. if (status == BT_STATUS_BT_OP_SUCCESS)
  1747. *AfhMapL = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
  1748. else {
  1749. ret = SET_BT_MP_OPER_RET(op_code, status);
  1750. goto exit;
  1751. }
  1752. op_code = BT_LO_OP_GET_AFH_MAP_M;
  1753. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  1754. if (status == BT_STATUS_BT_OP_SUCCESS)
  1755. *AfhMapM = le32_to_cpu(*(u32 *)GLBtcBtMpRptRsp);
  1756. else {
  1757. ret = SET_BT_MP_OPER_RET(op_code, status);
  1758. goto exit;
  1759. }
  1760. op_code = BT_LO_OP_GET_AFH_MAP_H;
  1761. status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 0);
  1762. if (status == BT_STATUS_BT_OP_SUCCESS)
  1763. *AfhMapH = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp);
  1764. else {
  1765. ret = SET_BT_MP_OPER_RET(op_code, status);
  1766. goto exit;
  1767. }
  1768. exit:
  1769. _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL);
  1770. return (ret == BT_STATUS_BT_OP_SUCCESS) ? _TRUE : _FALSE;
  1771. }
  1772. u32 halbtcoutsrc_GetPhydmVersion(void *pBtcContext)
  1773. {
  1774. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1775. PADAPTER Adapter = pBtCoexist->Adapter;
  1776. #ifdef CONFIG_RTL8192E
  1777. return RELEASE_VERSION_8192E;
  1778. #endif
  1779. #ifdef CONFIG_RTL8821A
  1780. return RELEASE_VERSION_8821A;
  1781. #endif
  1782. #ifdef CONFIG_RTL8723B
  1783. return RELEASE_VERSION_8723B;
  1784. #endif
  1785. #ifdef CONFIG_RTL8812A
  1786. return RELEASE_VERSION_8812A;
  1787. #endif
  1788. #ifdef CONFIG_RTL8703B
  1789. return RELEASE_VERSION_8703B;
  1790. #endif
  1791. #ifdef CONFIG_RTL8822B
  1792. return RELEASE_VERSION_8822B;
  1793. #endif
  1794. #ifdef CONFIG_RTL8723D
  1795. return RELEASE_VERSION_8723D;
  1796. #endif
  1797. #ifdef CONFIG_RTL8821C
  1798. return RELEASE_VERSION_8821C;
  1799. #endif
  1800. }
  1801. void halbtcoutsrc_phydm_modify_RA_PCR_threshold(void *pBtcContext, u8 RA_offset_direction, u8 RA_threshold_offset)
  1802. {
  1803. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1804. /* switch to #if 0 in case the phydm version does not provide the function */
  1805. #if 1
  1806. phydm_modify_RA_PCR_threshold(pBtCoexist->odm_priv, RA_offset_direction, RA_threshold_offset);
  1807. #endif
  1808. }
  1809. u32 halbtcoutsrc_phydm_query_PHY_counter(void *pBtcContext, u8 info_type)
  1810. {
  1811. struct btc_coexist *pBtCoexist = (struct btc_coexist *)pBtcContext;
  1812. /* switch to #if 0 in case the phydm version does not provide the function */
  1813. #if 1
  1814. return phydm_cmn_info_query((struct PHY_DM_STRUCT *)pBtCoexist->odm_priv, (enum phydm_info_query_e)info_type);
  1815. #else
  1816. return 0;
  1817. #endif
  1818. }
  1819. #if 0
  1820. static void BT_CoexOffloadRecordErrC2hAck(PADAPTER Adapter)
  1821. {
  1822. PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
  1823. if (pDefaultAdapter != Adapter)
  1824. return;
  1825. if (!hal_btcoex_IsBtExist(Adapter))
  1826. return;
  1827. gl_coex_offload.cnt_c2h_ack++;
  1828. gl_coex_offload.status[COL_STATUS_INVALID_C2H_LEN]++;
  1829. }
  1830. static void BT_CoexOffloadC2hAckCheck(PADAPTER Adapter, u8 *tmpBuf, u8 length)
  1831. {
  1832. PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
  1833. PCOL_C2H_ACK p_c2h_ack = NULL;
  1834. u8 req_num = 0xff;
  1835. if (pDefaultAdapter != Adapter)
  1836. return;
  1837. if (!hal_btcoex_IsBtExist(Adapter))
  1838. return;
  1839. gl_coex_offload.cnt_c2h_ack++;
  1840. if (length < COL_C2H_ACK_HDR_LEN) { /* c2h ack length must >= 3 (status, opcode_ver, req_num and ret_len) */
  1841. gl_coex_offload.status[COL_STATUS_INVALID_C2H_LEN]++;
  1842. } else {
  1843. BT_PrintData(Adapter, "[COL], c2h ack:", length, tmpBuf);
  1844. p_c2h_ack = (PCOL_C2H_ACK)tmpBuf;
  1845. req_num = p_c2h_ack->req_num;
  1846. _rtw_memmove(&gl_coex_offload.c2h_ack_buf[req_num][0], tmpBuf, length);
  1847. gl_coex_offload.c2h_ack_len[req_num] = length;
  1848. complete(&gl_coex_offload.c2h_event[req_num]);
  1849. }
  1850. }
  1851. static void BT_CoexOffloadC2hIndCheck(PADAPTER Adapter, u8 *tmpBuf, u8 length)
  1852. {
  1853. PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
  1854. PCOL_C2H_IND p_c2h_ind = NULL;
  1855. u8 ind_type = 0, ind_version = 0, ind_length = 0;
  1856. if (pDefaultAdapter != Adapter)
  1857. return;
  1858. if (!hal_btcoex_IsBtExist(Adapter))
  1859. return;
  1860. gl_coex_offload.cnt_c2h_ind++;
  1861. if (length < COL_C2H_IND_HDR_LEN) { /* c2h indication length must >= 3 (type, version and length) */
  1862. gl_coex_offload.c2h_ind_status[COL_STATUS_INVALID_C2H_LEN]++;
  1863. } else {
  1864. BT_PrintData(Adapter, "[COL], c2h indication:", length, tmpBuf);
  1865. p_c2h_ind = (PCOL_C2H_IND)tmpBuf;
  1866. ind_type = p_c2h_ind->type;
  1867. ind_version = p_c2h_ind->version;
  1868. ind_length = p_c2h_ind->length;
  1869. _rtw_memmove(&gl_coex_offload.c2h_ind_buf[0], tmpBuf, length);
  1870. gl_coex_offload.c2h_ind_len = length;
  1871. /* log */
  1872. gl_coex_offload.c2h_ind_record[ind_type].count++;
  1873. gl_coex_offload.c2h_ind_record[ind_type].status[COL_STATUS_C2H_OK]++;
  1874. _rtw_memmove(&gl_coex_offload.c2h_ind_record[ind_type].ind_buf[0], tmpBuf, length);
  1875. gl_coex_offload.c2h_ind_record[ind_type].ind_len = length;
  1876. gl_coex_offload.c2h_ind_status[COL_STATUS_C2H_OK]++;
  1877. /*TODO: need to check c2h indication length*/
  1878. /* TODO: Notification */
  1879. }
  1880. }
  1881. void BT_CoexOffloadC2hCheck(PADAPTER Adapter, u8 *Buffer, u8 Length)
  1882. {
  1883. #if 0 /*(USE_HAL_MAC_API == 1)*/
  1884. u8 c2hSubCmdId = 0, c2hAckLen = 0, h2cCmdId = 0, h2cSubCmdId = 0, c2hIndLen = 0;
  1885. BT_PrintData(Adapter, "[COL], c2h packet:", Length - 2, Buffer + 2);
  1886. c2hSubCmdId = (u1Byte)C2H_HDR_GET_C2H_SUB_CMD_ID(Buffer);
  1887. if (c2hSubCmdId == C2H_SUB_CMD_ID_H2C_ACK_HDR ||
  1888. c2hSubCmdId == C2H_SUB_CMD_ID_BT_COEX_INFO) {
  1889. if (c2hSubCmdId == C2H_SUB_CMD_ID_H2C_ACK_HDR) {
  1890. /* coex c2h ack */
  1891. h2cCmdId = (u1Byte)H2C_ACK_HDR_GET_H2C_CMD_ID(Buffer);
  1892. h2cSubCmdId = (u1Byte)H2C_ACK_HDR_GET_H2C_SUB_CMD_ID(Buffer);
  1893. if (h2cCmdId == 0xff && h2cSubCmdId == 0x60) {
  1894. c2hAckLen = (u1Byte)C2H_HDR_GET_LEN(Buffer);
  1895. if (c2hAckLen >= 8)
  1896. BT_CoexOffloadC2hAckCheck(Adapter, &Buffer[12], (u1Byte)(c2hAckLen - 8));
  1897. else
  1898. BT_CoexOffloadRecordErrC2hAck(Adapter);
  1899. }
  1900. } else if (c2hSubCmdId == C2H_SUB_CMD_ID_BT_COEX_INFO) {
  1901. /* coex c2h indication */
  1902. c2hIndLen = (u1Byte)C2H_HDR_GET_LEN(Buffer);
  1903. BT_CoexOffloadC2hIndCheck(Adapter, &Buffer[4], (u1Byte)c2hIndLen);
  1904. }
  1905. }
  1906. #endif
  1907. }
  1908. #endif
  1909. /* ************************************
  1910. * Extern functions called by other module
  1911. * ************************************ */
  1912. u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter)
  1913. {
  1914. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  1915. u8 antNum = 1, chipType = 0, singleAntPath = 0;
  1916. HAL_DATA_TYPE *pHalData = GET_HAL_DATA((PADAPTER)padapter);
  1917. if (pBtCoexist->bBinded)
  1918. return _FALSE;
  1919. else
  1920. pBtCoexist->bBinded = _TRUE;
  1921. pBtCoexist->statistics.cnt_bind++;
  1922. pBtCoexist->Adapter = padapter;
  1923. pBtCoexist->odm_priv = (PVOID)&(pHalData->odmpriv);
  1924. pBtCoexist->stack_info.profile_notified = _FALSE;
  1925. pBtCoexist->bt_info.bt_ctrl_agg_buf_size = _FALSE;
  1926. pBtCoexist->bt_info.agg_buf_size = 5;
  1927. pBtCoexist->bt_info.increase_scan_dev_num = _FALSE;
  1928. pBtCoexist->bt_info.miracast_plus_bt = _FALSE;
  1929. antNum = rtw_btcoex_get_pg_ant_num((PADAPTER)padapter);
  1930. EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum);
  1931. if (antNum == 1) {
  1932. singleAntPath = rtw_btcoex_get_pg_single_ant_path((PADAPTER)padapter);
  1933. EXhalbtcoutsrc_SetSingleAntPath(singleAntPath);
  1934. }
  1935. /* set default antenna position to main port */
  1936. pBtCoexist->board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
  1937. pBtCoexist->board_info.btdm_ant_det_finish = _FALSE;
  1938. pBtCoexist->board_info.btdm_ant_num_by_ant_det = 1;
  1939. pBtCoexist->board_info.tfbga_package = rtw_btcoex_is_tfbga_package_type((PADAPTER)padapter);
  1940. pBtCoexist->board_info.rfe_type = rtw_btcoex_get_pg_rfe_type((PADAPTER)padapter);
  1941. pBtCoexist->board_info.ant_div_cfg = rtw_btcoex_get_ant_div_cfg((PADAPTER)padapter);
  1942. return _TRUE;
  1943. }
  1944. u8 EXhalbtcoutsrc_InitlizeVariables(void *padapter)
  1945. {
  1946. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  1947. /* pBtCoexist->statistics.cntBind++; */
  1948. halbtcoutsrc_DbgInit();
  1949. halbtcoutsrc_coex_offload_init();
  1950. #ifdef CONFIG_PCI_HCI
  1951. pBtCoexist->chip_interface = BTC_INTF_PCI;
  1952. #elif defined(CONFIG_USB_HCI)
  1953. pBtCoexist->chip_interface = BTC_INTF_USB;
  1954. #elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
  1955. pBtCoexist->chip_interface = BTC_INTF_SDIO;
  1956. #else
  1957. pBtCoexist->chip_interface = BTC_INTF_UNKNOWN;
  1958. #endif
  1959. EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter);
  1960. pBtCoexist->btc_read_1byte = halbtcoutsrc_Read1Byte;
  1961. pBtCoexist->btc_write_1byte = halbtcoutsrc_Write1Byte;
  1962. pBtCoexist->btc_write_1byte_bitmask = halbtcoutsrc_BitMaskWrite1Byte;
  1963. pBtCoexist->btc_read_2byte = halbtcoutsrc_Read2Byte;
  1964. pBtCoexist->btc_write_2byte = halbtcoutsrc_Write2Byte;
  1965. pBtCoexist->btc_read_4byte = halbtcoutsrc_Read4Byte;
  1966. pBtCoexist->btc_write_4byte = halbtcoutsrc_Write4Byte;
  1967. pBtCoexist->btc_write_local_reg_1byte = halbtcoutsrc_WriteLocalReg1Byte;
  1968. pBtCoexist->btc_set_bb_reg = halbtcoutsrc_SetBbReg;
  1969. pBtCoexist->btc_get_bb_reg = halbtcoutsrc_GetBbReg;
  1970. pBtCoexist->btc_set_rf_reg = halbtcoutsrc_SetRfReg;
  1971. pBtCoexist->btc_get_rf_reg = halbtcoutsrc_GetRfReg;
  1972. pBtCoexist->btc_fill_h2c = halbtcoutsrc_FillH2cCmd;
  1973. pBtCoexist->btc_disp_dbg_msg = halbtcoutsrc_DisplayDbgMsg;
  1974. pBtCoexist->btc_get = halbtcoutsrc_Get;
  1975. pBtCoexist->btc_set = halbtcoutsrc_Set;
  1976. pBtCoexist->btc_get_bt_reg = halbtcoutsrc_GetBtReg;
  1977. pBtCoexist->btc_set_bt_reg = halbtcoutsrc_SetBtReg;
  1978. pBtCoexist->btc_set_bt_ant_detection = halbtcoutsrc_SetBtAntDetection;
  1979. pBtCoexist->btc_set_bt_trx_mask = halbtcoutsrc_SetBtTRXMASK;
  1980. pBtCoexist->btc_coex_h2c_process = halbtcoutsrc_CoexH2cProcess;
  1981. pBtCoexist->btc_get_bt_coex_supported_feature = halbtcoutsrc_GetBtCoexSupportedFeature;
  1982. pBtCoexist->btc_get_bt_coex_supported_version= halbtcoutsrc_GetBtCoexSupportedVersion;
  1983. pBtCoexist->btc_get_ant_det_val_from_bt = halbtcoutsrc_GetAntDetValFromBt;
  1984. pBtCoexist->btc_get_ble_scan_type_from_bt = halbtcoutsrc_GetBleScanTypeFromBt;
  1985. pBtCoexist->btc_get_ble_scan_para_from_bt = halbtcoutsrc_GetBleScanParaFromBt;
  1986. pBtCoexist->btc_get_bt_afh_map_from_bt = halbtcoutsrc_GetBtAFHMapFromBt;
  1987. pBtCoexist->btc_get_bt_phydm_version = halbtcoutsrc_GetPhydmVersion;
  1988. pBtCoexist->btc_phydm_modify_RA_PCR_threshold = halbtcoutsrc_phydm_modify_RA_PCR_threshold;
  1989. pBtCoexist->btc_phydm_query_PHY_counter = halbtcoutsrc_phydm_query_PHY_counter;
  1990. pBtCoexist->cli_buf = &GLBtcDbgBuf[0];
  1991. GLBtcWiFiInScanState = _FALSE;
  1992. GLBtcWiFiInIQKState = _FALSE;
  1993. GLBtcWiFiInIPS = _FALSE;
  1994. GLBtcWiFiInLPS = _FALSE;
  1995. GLBtcBtCoexAliveRegistered = _FALSE;
  1996. /* BT Control H2C/C2H*/
  1997. GLBtcBtMpOperSeq = 0;
  1998. _rtw_mutex_init(&GLBtcBtMpOperLock);
  1999. rtw_init_timer(&GLBtcBtMpOperTimer, padapter, _btmpoper_timer_hdl);
  2000. _rtw_init_sema(&GLBtcBtMpRptSema, 0);
  2001. GLBtcBtMpRptSeq = 0;
  2002. GLBtcBtMpRptStatus = 0;
  2003. _rtw_memset(GLBtcBtMpRptRsp, 0, C2H_MAX_SIZE);
  2004. GLBtcBtMpRptRspSize = 0;
  2005. GLBtcBtMpRptWait = 0;
  2006. GLBtcBtMpRptWiFiOK = 0;
  2007. GLBtcBtMpRptBTOK = 0;
  2008. return _TRUE;
  2009. }
  2010. void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist)
  2011. {
  2012. HAL_DATA_TYPE *pHalData = NULL;
  2013. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2014. return;
  2015. pHalData = GET_HAL_DATA((PADAPTER)pBtCoexist->Adapter);
  2016. /* Power on setting function is only added in 8723B currently */
  2017. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2018. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2019. ex_halbtc8723b2ant_power_on_setting(pBtCoexist);
  2020. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2021. ex_halbtc8723b1ant_power_on_setting(pBtCoexist);
  2022. }
  2023. if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2024. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2025. ex_halbtc8723d2ant_power_on_setting(pBtCoexist);
  2026. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2027. ex_halbtc8723d1ant_power_on_setting(pBtCoexist);
  2028. }
  2029. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2030. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2031. ex_halbtc8821a1ant_power_on_setting(pBtCoexist);
  2032. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2033. ex_halbtc8821a2ant_power_on_setting(pBtCoexist);
  2034. }
  2035. if ((IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) && (pHalData->EEPROMBluetoothCoexist == _TRUE)) {
  2036. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2037. ex_halbtc8822b1ant_power_on_setting(pBtCoexist);
  2038. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2039. ex_halbtc8822b2ant_power_on_setting(pBtCoexist);
  2040. }
  2041. if ((IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) && (pHalData->EEPROMBluetoothCoexist == _TRUE)) {
  2042. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2043. ex_halbtc8821c2ant_power_on_setting(pBtCoexist);
  2044. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2045. ex_halbtc8821c1ant_power_on_setting(pBtCoexist);
  2046. }
  2047. }
  2048. void EXhalbtcoutsrc_PreLoadFirmware(PBTC_COEXIST pBtCoexist)
  2049. {
  2050. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2051. return;
  2052. pBtCoexist->statistics.cnt_pre_load_firmware++;
  2053. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2054. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2055. ex_halbtc8723b2ant_pre_load_firmware(pBtCoexist);
  2056. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2057. ex_halbtc8723b1ant_pre_load_firmware(pBtCoexist);
  2058. }
  2059. if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2060. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2061. ex_halbtc8723d2ant_pre_load_firmware(pBtCoexist);
  2062. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2063. ex_halbtc8723d1ant_pre_load_firmware(pBtCoexist);
  2064. }
  2065. if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2066. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2067. ex_halbtc8821c2ant_pre_load_firmware(pBtCoexist);
  2068. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2069. ex_halbtc8821c1ant_pre_load_firmware(pBtCoexist);
  2070. }
  2071. }
  2072. void EXhalbtcoutsrc_init_hw_config(PBTC_COEXIST pBtCoexist, u8 bWifiOnly)
  2073. {
  2074. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2075. return;
  2076. pBtCoexist->statistics.cnt_init_hw_config++;
  2077. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2078. #if 0
  2079. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2080. ex_halbtc8821aCsr2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2081. else
  2082. #endif
  2083. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2084. ex_halbtc8821a2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2085. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2086. ex_halbtc8821a1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2087. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2088. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2089. ex_halbtc8723b2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2090. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2091. ex_halbtc8723b1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2092. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2093. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2094. ex_halbtc8703b1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2095. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2096. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2097. ex_halbtc8723d2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2098. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2099. ex_halbtc8723d1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2100. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2101. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2102. ex_halbtc8192e2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2103. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2104. ex_halbtc8192e1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2105. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2106. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2107. ex_halbtc8812a2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2108. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2109. ex_halbtc8812a1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2110. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2111. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2112. ex_halbtc8822b1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2113. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2114. ex_halbtc8822b2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2115. #ifdef CONFIG_FW_MULTI_PORT_SUPPORT
  2116. rtw_hal_set_default_port_id_cmd(pBtCoexist->Adapter, 0);
  2117. rtw_hal_set_wifi_port_id_cmd(pBtCoexist->Adapter);
  2118. #endif
  2119. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2120. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2121. ex_halbtc8821c2ant_init_hw_config(pBtCoexist, bWifiOnly);
  2122. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2123. ex_halbtc8821c1ant_init_hw_config(pBtCoexist, bWifiOnly);
  2124. #ifdef CONFIG_FW_MULTI_PORT_SUPPORT
  2125. rtw_hal_set_default_port_id_cmd(pBtCoexist->Adapter, 0);
  2126. rtw_hal_set_wifi_port_id_cmd(pBtCoexist->Adapter);
  2127. #endif
  2128. }
  2129. }
  2130. void EXhalbtcoutsrc_init_coex_dm(PBTC_COEXIST pBtCoexist)
  2131. {
  2132. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2133. return;
  2134. pBtCoexist->statistics.cnt_init_coex_dm++;
  2135. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2136. #if 0
  2137. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2138. ex_halbtc8821aCsr2ant_init_coex_dm(pBtCoexist);
  2139. else
  2140. #endif
  2141. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2142. ex_halbtc8821a2ant_init_coex_dm(pBtCoexist);
  2143. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2144. ex_halbtc8821a1ant_init_coex_dm(pBtCoexist);
  2145. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2146. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2147. ex_halbtc8723b2ant_init_coex_dm(pBtCoexist);
  2148. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2149. ex_halbtc8723b1ant_init_coex_dm(pBtCoexist);
  2150. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2151. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2152. ex_halbtc8703b1ant_init_coex_dm(pBtCoexist);
  2153. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2154. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2155. ex_halbtc8723d2ant_init_coex_dm(pBtCoexist);
  2156. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2157. ex_halbtc8723d1ant_init_coex_dm(pBtCoexist);
  2158. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2159. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2160. ex_halbtc8192e2ant_init_coex_dm(pBtCoexist);
  2161. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2162. ex_halbtc8192e1ant_init_coex_dm(pBtCoexist);
  2163. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2164. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2165. ex_halbtc8812a2ant_init_coex_dm(pBtCoexist);
  2166. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2167. ex_halbtc8812a1ant_init_coex_dm(pBtCoexist);
  2168. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2169. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2170. ex_halbtc8822b1ant_init_coex_dm(pBtCoexist);
  2171. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2172. ex_halbtc8822b2ant_init_coex_dm(pBtCoexist);
  2173. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2174. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2175. ex_halbtc8821c2ant_init_coex_dm(pBtCoexist);
  2176. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2177. ex_halbtc8821c1ant_init_coex_dm(pBtCoexist);
  2178. }
  2179. pBtCoexist->initilized = _TRUE;
  2180. }
  2181. void EXhalbtcoutsrc_ips_notify(PBTC_COEXIST pBtCoexist, u8 type)
  2182. {
  2183. u8 ipsType;
  2184. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2185. return;
  2186. pBtCoexist->statistics.cnt_ips_notify++;
  2187. if (pBtCoexist->manual_control)
  2188. return;
  2189. if (IPS_NONE == type) {
  2190. ipsType = BTC_IPS_LEAVE;
  2191. GLBtcWiFiInIPS = _FALSE;
  2192. } else {
  2193. ipsType = BTC_IPS_ENTER;
  2194. GLBtcWiFiInIPS = _TRUE;
  2195. }
  2196. /* All notify is called in cmd thread, don't need to leave low power again
  2197. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2198. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2199. #if 0
  2200. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2201. ex_halbtc8821aCsr2ant_ips_notify(pBtCoexist, ipsType);
  2202. else
  2203. #endif
  2204. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2205. ex_halbtc8821a2ant_ips_notify(pBtCoexist, ipsType);
  2206. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2207. ex_halbtc8821a1ant_ips_notify(pBtCoexist, ipsType);
  2208. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2209. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2210. ex_halbtc8723b2ant_ips_notify(pBtCoexist, ipsType);
  2211. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2212. ex_halbtc8723b1ant_ips_notify(pBtCoexist, ipsType);
  2213. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2214. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2215. ex_halbtc8703b1ant_ips_notify(pBtCoexist, ipsType);
  2216. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2217. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2218. ex_halbtc8723d2ant_ips_notify(pBtCoexist, ipsType);
  2219. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2220. ex_halbtc8723d1ant_ips_notify(pBtCoexist, ipsType);
  2221. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2222. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2223. ex_halbtc8192e2ant_ips_notify(pBtCoexist, ipsType);
  2224. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2225. ex_halbtc8192e1ant_ips_notify(pBtCoexist, ipsType);
  2226. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2227. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2228. ex_halbtc8812a2ant_ips_notify(pBtCoexist, ipsType);
  2229. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2230. ex_halbtc8812a1ant_ips_notify(pBtCoexist, ipsType);
  2231. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2232. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2233. ex_halbtc8822b1ant_ips_notify(pBtCoexist, ipsType);
  2234. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2235. ex_halbtc8822b2ant_ips_notify(pBtCoexist, ipsType);
  2236. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2237. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2238. ex_halbtc8821c2ant_ips_notify(pBtCoexist, ipsType);
  2239. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2240. ex_halbtc8821c1ant_ips_notify(pBtCoexist, ipsType);
  2241. }
  2242. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2243. }
  2244. void EXhalbtcoutsrc_lps_notify(PBTC_COEXIST pBtCoexist, u8 type)
  2245. {
  2246. u8 lpsType;
  2247. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2248. return;
  2249. pBtCoexist->statistics.cnt_lps_notify++;
  2250. if (pBtCoexist->manual_control)
  2251. return;
  2252. if (PS_MODE_ACTIVE == type) {
  2253. lpsType = BTC_LPS_DISABLE;
  2254. GLBtcWiFiInLPS = _FALSE;
  2255. } else {
  2256. lpsType = BTC_LPS_ENABLE;
  2257. GLBtcWiFiInLPS = _TRUE;
  2258. }
  2259. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2260. #if 0
  2261. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2262. ex_halbtc8821aCsr2ant_lps_notify(pBtCoexist, lpsType);
  2263. else
  2264. #endif
  2265. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2266. ex_halbtc8821a2ant_lps_notify(pBtCoexist, lpsType);
  2267. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2268. ex_halbtc8821a1ant_lps_notify(pBtCoexist, lpsType);
  2269. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2270. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2271. ex_halbtc8723b2ant_lps_notify(pBtCoexist, lpsType);
  2272. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2273. ex_halbtc8723b1ant_lps_notify(pBtCoexist, lpsType);
  2274. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2275. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2276. ex_halbtc8703b1ant_lps_notify(pBtCoexist, lpsType);
  2277. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2278. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2279. ex_halbtc8723d2ant_lps_notify(pBtCoexist, lpsType);
  2280. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2281. ex_halbtc8723d1ant_lps_notify(pBtCoexist, lpsType);
  2282. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2283. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2284. ex_halbtc8192e2ant_lps_notify(pBtCoexist, lpsType);
  2285. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2286. ex_halbtc8192e1ant_lps_notify(pBtCoexist, lpsType);
  2287. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2288. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2289. ex_halbtc8812a2ant_lps_notify(pBtCoexist, lpsType);
  2290. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2291. ex_halbtc8812a1ant_lps_notify(pBtCoexist, lpsType);
  2292. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2293. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2294. ex_halbtc8822b1ant_lps_notify(pBtCoexist, lpsType);
  2295. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2296. ex_halbtc8822b2ant_lps_notify(pBtCoexist, lpsType);
  2297. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2298. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2299. ex_halbtc8821c2ant_lps_notify(pBtCoexist, lpsType);
  2300. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2301. ex_halbtc8821c1ant_lps_notify(pBtCoexist, lpsType);
  2302. }
  2303. }
  2304. void EXhalbtcoutsrc_scan_notify(PBTC_COEXIST pBtCoexist, u8 type)
  2305. {
  2306. u8 scanType;
  2307. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2308. return;
  2309. pBtCoexist->statistics.cnt_scan_notify++;
  2310. if (pBtCoexist->manual_control)
  2311. return;
  2312. if (type) {
  2313. scanType = BTC_SCAN_START;
  2314. GLBtcWiFiInScanState = _TRUE;
  2315. } else {
  2316. scanType = BTC_SCAN_FINISH;
  2317. GLBtcWiFiInScanState = _FALSE;
  2318. }
  2319. /* All notify is called in cmd thread, don't need to leave low power again
  2320. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2321. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2322. #if 0
  2323. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2324. ex_halbtc8821aCsr2ant_scan_notify(pBtCoexist, scanType);
  2325. else
  2326. #endif
  2327. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2328. ex_halbtc8821a2ant_scan_notify(pBtCoexist, scanType);
  2329. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2330. ex_halbtc8821a1ant_scan_notify(pBtCoexist, scanType);
  2331. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2332. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2333. ex_halbtc8723b2ant_scan_notify(pBtCoexist, scanType);
  2334. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2335. ex_halbtc8723b1ant_scan_notify(pBtCoexist, scanType);
  2336. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2337. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2338. ex_halbtc8703b1ant_scan_notify(pBtCoexist, scanType);
  2339. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2340. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2341. ex_halbtc8723d2ant_scan_notify(pBtCoexist, scanType);
  2342. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2343. ex_halbtc8723d1ant_scan_notify(pBtCoexist, scanType);
  2344. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2345. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2346. ex_halbtc8192e2ant_scan_notify(pBtCoexist, scanType);
  2347. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2348. ex_halbtc8192e1ant_scan_notify(pBtCoexist, scanType);
  2349. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2350. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2351. ex_halbtc8812a2ant_scan_notify(pBtCoexist, scanType);
  2352. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2353. ex_halbtc8812a1ant_scan_notify(pBtCoexist, scanType);
  2354. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2355. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2356. ex_halbtc8822b1ant_scan_notify(pBtCoexist, scanType);
  2357. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2358. ex_halbtc8822b2ant_scan_notify(pBtCoexist, scanType);
  2359. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2360. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2361. ex_halbtc8821c2ant_scan_notify(pBtCoexist, scanType);
  2362. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2363. ex_halbtc8821c1ant_scan_notify(pBtCoexist, scanType);
  2364. }
  2365. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2366. }
  2367. void EXhalbtcoutsrc_SetAntennaPathNotify(PBTC_COEXIST pBtCoexist, u8 type)
  2368. {
  2369. #if 0
  2370. u8 switchType;
  2371. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2372. return;
  2373. if (pBtCoexist->manual_control)
  2374. return;
  2375. halbtcoutsrc_LeaveLowPower(pBtCoexist);
  2376. switchType = type;
  2377. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2378. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2379. ex_halbtc8723b1ant_set_antenna_notify(pBtCoexist, type);
  2380. }
  2381. if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2382. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2383. ex_halbtc8723d1ant_set_antenna_notify(pBtCoexist, type);
  2384. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2385. ex_halbtc8723d2ant_set_antenna_notify(pBtCoexist, type);
  2386. }
  2387. halbtcoutsrc_NormalLowPower(pBtCoexist);
  2388. #endif
  2389. }
  2390. void EXhalbtcoutsrc_connect_notify(PBTC_COEXIST pBtCoexist, u8 action)
  2391. {
  2392. u8 assoType;
  2393. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2394. return;
  2395. pBtCoexist->statistics.cnt_connect_notify++;
  2396. if (pBtCoexist->manual_control)
  2397. return;
  2398. if (action)
  2399. assoType = BTC_ASSOCIATE_START;
  2400. else
  2401. assoType = BTC_ASSOCIATE_FINISH;
  2402. /* All notify is called in cmd thread, don't need to leave low power again
  2403. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2404. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2405. #if 0
  2406. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2407. ex_halbtc8821aCsr2ant_connect_notify(pBtCoexist, assoType);
  2408. else
  2409. #endif
  2410. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2411. ex_halbtc8821a2ant_connect_notify(pBtCoexist, assoType);
  2412. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2413. ex_halbtc8821a1ant_connect_notify(pBtCoexist, assoType);
  2414. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2415. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2416. ex_halbtc8723b2ant_connect_notify(pBtCoexist, assoType);
  2417. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2418. ex_halbtc8723b1ant_connect_notify(pBtCoexist, assoType);
  2419. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2420. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2421. ex_halbtc8703b1ant_connect_notify(pBtCoexist, assoType);
  2422. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2423. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2424. ex_halbtc8723d2ant_connect_notify(pBtCoexist, assoType);
  2425. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2426. ex_halbtc8723d1ant_connect_notify(pBtCoexist, assoType);
  2427. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2428. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2429. ex_halbtc8192e2ant_connect_notify(pBtCoexist, assoType);
  2430. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2431. ex_halbtc8192e1ant_connect_notify(pBtCoexist, assoType);
  2432. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2433. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2434. ex_halbtc8812a2ant_connect_notify(pBtCoexist, assoType);
  2435. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2436. ex_halbtc8812a1ant_connect_notify(pBtCoexist, assoType);
  2437. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2438. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2439. ex_halbtc8822b1ant_connect_notify(pBtCoexist, assoType);
  2440. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2441. ex_halbtc8822b2ant_connect_notify(pBtCoexist, assoType);
  2442. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2443. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2444. ex_halbtc8821c2ant_connect_notify(pBtCoexist, assoType);
  2445. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2446. ex_halbtc8821c1ant_connect_notify(pBtCoexist, assoType);
  2447. }
  2448. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2449. }
  2450. void EXhalbtcoutsrc_media_status_notify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus)
  2451. {
  2452. u8 mStatus;
  2453. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2454. return;
  2455. pBtCoexist->statistics.cnt_media_status_notify++;
  2456. if (pBtCoexist->manual_control)
  2457. return;
  2458. if (RT_MEDIA_CONNECT == mediaStatus)
  2459. mStatus = BTC_MEDIA_CONNECT;
  2460. else
  2461. mStatus = BTC_MEDIA_DISCONNECT;
  2462. /* All notify is called in cmd thread, don't need to leave low power again
  2463. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2464. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2465. #if 0
  2466. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2467. ex_halbtc8821aCsr2ant_media_status_notify(pBtCoexist, mStatus);
  2468. else
  2469. #endif
  2470. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2471. ex_halbtc8821a2ant_media_status_notify(pBtCoexist, mStatus);
  2472. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2473. ex_halbtc8821a1ant_media_status_notify(pBtCoexist, mStatus);
  2474. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2475. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2476. ex_halbtc8723b2ant_media_status_notify(pBtCoexist, mStatus);
  2477. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2478. ex_halbtc8723b1ant_media_status_notify(pBtCoexist, mStatus);
  2479. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2480. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2481. ex_halbtc8703b1ant_media_status_notify(pBtCoexist, mStatus);
  2482. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2483. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2484. ex_halbtc8723d2ant_media_status_notify(pBtCoexist, mStatus);
  2485. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2486. ex_halbtc8723d1ant_media_status_notify(pBtCoexist, mStatus);
  2487. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2488. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2489. ex_halbtc8192e2ant_media_status_notify(pBtCoexist, mStatus);
  2490. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2491. ex_halbtc8192e1ant_media_status_notify(pBtCoexist, mStatus);
  2492. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2493. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2494. ex_halbtc8812a2ant_media_status_notify(pBtCoexist, mStatus);
  2495. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2496. ex_halbtc8812a1ant_media_status_notify(pBtCoexist, mStatus);
  2497. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2498. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2499. ex_halbtc8822b1ant_media_status_notify(pBtCoexist, mStatus);
  2500. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2501. ex_halbtc8822b2ant_media_status_notify(pBtCoexist, mStatus);
  2502. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2503. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2504. ex_halbtc8821c2ant_media_status_notify(pBtCoexist, mStatus);
  2505. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2506. ex_halbtc8821c1ant_media_status_notify(pBtCoexist, mStatus);
  2507. }
  2508. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2509. }
  2510. void EXhalbtcoutsrc_specific_packet_notify(PBTC_COEXIST pBtCoexist, u8 pktType)
  2511. {
  2512. u8 packetType;
  2513. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2514. return;
  2515. pBtCoexist->statistics.cnt_specific_packet_notify++;
  2516. if (pBtCoexist->manual_control)
  2517. return;
  2518. if (PACKET_DHCP == pktType)
  2519. packetType = BTC_PACKET_DHCP;
  2520. else if (PACKET_EAPOL == pktType)
  2521. packetType = BTC_PACKET_EAPOL;
  2522. else if (PACKET_ARP == pktType)
  2523. packetType = BTC_PACKET_ARP;
  2524. else {
  2525. packetType = BTC_PACKET_UNKNOWN;
  2526. return;
  2527. }
  2528. /* All notify is called in cmd thread, don't need to leave low power again
  2529. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2530. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2531. #if 0
  2532. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2533. ex_halbtc8821aCsr2ant_specific_packet_notify(pBtCoexist, packetType);
  2534. else
  2535. #endif
  2536. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2537. ex_halbtc8821a2ant_specific_packet_notify(pBtCoexist, packetType);
  2538. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2539. ex_halbtc8821a1ant_specific_packet_notify(pBtCoexist, packetType);
  2540. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2541. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2542. ex_halbtc8723b2ant_specific_packet_notify(pBtCoexist, packetType);
  2543. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2544. ex_halbtc8723b1ant_specific_packet_notify(pBtCoexist, packetType);
  2545. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2546. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2547. ex_halbtc8703b1ant_specific_packet_notify(pBtCoexist, packetType);
  2548. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2549. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2550. ex_halbtc8723d2ant_specific_packet_notify(pBtCoexist, packetType);
  2551. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2552. ex_halbtc8723d1ant_specific_packet_notify(pBtCoexist, packetType);
  2553. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2554. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2555. ex_halbtc8192e2ant_specific_packet_notify(pBtCoexist, packetType);
  2556. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2557. ex_halbtc8192e1ant_specific_packet_notify(pBtCoexist, packetType);
  2558. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2559. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2560. ex_halbtc8812a2ant_specific_packet_notify(pBtCoexist, packetType);
  2561. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2562. ex_halbtc8812a1ant_specific_packet_notify(pBtCoexist, packetType);
  2563. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2564. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2565. ex_halbtc8822b1ant_specific_packet_notify(pBtCoexist, packetType);
  2566. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2567. ex_halbtc8822b2ant_specific_packet_notify(pBtCoexist, packetType);
  2568. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2569. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2570. ex_halbtc8821c2ant_specific_packet_notify(pBtCoexist, packetType);
  2571. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2572. ex_halbtc8821c1ant_specific_packet_notify(pBtCoexist, packetType);
  2573. }
  2574. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2575. }
  2576. void EXhalbtcoutsrc_bt_info_notify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length)
  2577. {
  2578. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2579. return;
  2580. pBtCoexist->statistics.cnt_bt_info_notify++;
  2581. /* All notify is called in cmd thread, don't need to leave low power again
  2582. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2583. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2584. #if 0
  2585. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2586. ex_halbtc8821aCsr2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2587. else
  2588. #endif
  2589. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2590. ex_halbtc8821a2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2591. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2592. ex_halbtc8821a1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2593. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2594. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2595. ex_halbtc8723b2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2596. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2597. ex_halbtc8723b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2598. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2599. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2600. ex_halbtc8703b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2601. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2602. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2603. ex_halbtc8723d2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2604. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2605. ex_halbtc8723d1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2606. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2607. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2608. ex_halbtc8192e2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2609. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2610. ex_halbtc8192e1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2611. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2612. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2613. ex_halbtc8812a2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2614. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2615. ex_halbtc8812a1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2616. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2617. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2618. ex_halbtc8822b1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2619. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2620. ex_halbtc8822b2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2621. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2622. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2623. ex_halbtc8821c2ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2624. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2625. ex_halbtc8821c1ant_bt_info_notify(pBtCoexist, tmpBuf, length);
  2626. }
  2627. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2628. }
  2629. VOID
  2630. EXhalbtcoutsrc_RfStatusNotify(
  2631. IN PBTC_COEXIST pBtCoexist,
  2632. IN u1Byte type
  2633. )
  2634. {
  2635. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2636. return;
  2637. pBtCoexist->statistics.cnt_rf_status_notify++;
  2638. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2639. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2640. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2641. ex_halbtc8723b1ant_rf_status_notify(pBtCoexist, type);
  2642. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2643. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2644. ex_halbtc8703b1ant_rf_status_notify(pBtCoexist, type);
  2645. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2646. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2647. ex_halbtc8723d1ant_rf_status_notify(pBtCoexist, type);
  2648. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2649. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2650. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2651. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2652. ex_halbtc8822b1ant_rf_status_notify(pBtCoexist, type);
  2653. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2654. ex_halbtc8822b2ant_rf_status_notify(pBtCoexist, type);
  2655. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2656. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2657. ex_halbtc8821c2ant_rf_status_notify(pBtCoexist, type);
  2658. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2659. ex_halbtc8821c1ant_rf_status_notify(pBtCoexist, type);
  2660. }
  2661. }
  2662. void EXhalbtcoutsrc_StackOperationNotify(PBTC_COEXIST pBtCoexist, u8 type)
  2663. {
  2664. #if 0
  2665. u8 stackOpType;
  2666. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2667. return;
  2668. pBtCoexist->statistics.cntStackOperationNotify++;
  2669. if (pBtCoexist->manual_control)
  2670. return;
  2671. if ((HCI_BT_OP_INQUIRY_START == type) ||
  2672. (HCI_BT_OP_PAGING_START == type) ||
  2673. (HCI_BT_OP_PAIRING_START == type))
  2674. stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_START;
  2675. else if ((HCI_BT_OP_INQUIRY_FINISH == type) ||
  2676. (HCI_BT_OP_PAGING_SUCCESS == type) ||
  2677. (HCI_BT_OP_PAGING_UNSUCCESS == type) ||
  2678. (HCI_BT_OP_PAIRING_FINISH == type))
  2679. stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH;
  2680. else
  2681. stackOpType = BTC_STACK_OP_NONE;
  2682. #endif
  2683. }
  2684. void EXhalbtcoutsrc_halt_notify(PBTC_COEXIST pBtCoexist)
  2685. {
  2686. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2687. return;
  2688. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2689. #if 0
  2690. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2691. ex_halbtc8821aCsr2ant_halt_notify(pBtCoexist);
  2692. else
  2693. #endif
  2694. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2695. ex_halbtc8821a2ant_halt_notify(pBtCoexist);
  2696. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2697. ex_halbtc8821a1ant_halt_notify(pBtCoexist);
  2698. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2699. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2700. ex_halbtc8723b2ant_halt_notify(pBtCoexist);
  2701. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2702. ex_halbtc8723b1ant_halt_notify(pBtCoexist);
  2703. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2704. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2705. ex_halbtc8703b1ant_halt_notify(pBtCoexist);
  2706. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2707. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2708. ex_halbtc8723d2ant_halt_notify(pBtCoexist);
  2709. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2710. ex_halbtc8723d1ant_halt_notify(pBtCoexist);
  2711. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2712. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2713. ex_halbtc8192e2ant_halt_notify(pBtCoexist);
  2714. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2715. ex_halbtc8192e1ant_halt_notify(pBtCoexist);
  2716. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2717. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2718. ex_halbtc8812a2ant_halt_notify(pBtCoexist);
  2719. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2720. ex_halbtc8812a1ant_halt_notify(pBtCoexist);
  2721. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2722. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2723. ex_halbtc8822b1ant_halt_notify(pBtCoexist);
  2724. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2725. ex_halbtc8822b2ant_halt_notify(pBtCoexist);
  2726. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2727. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2728. ex_halbtc8821c2ant_halt_notify(pBtCoexist);
  2729. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2730. ex_halbtc8821c1ant_halt_notify(pBtCoexist);
  2731. }
  2732. }
  2733. void EXhalbtcoutsrc_SwitchBtTRxMask(PBTC_COEXIST pBtCoexist)
  2734. {
  2735. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2736. if (pBtCoexist->board_info.btdm_ant_num == 2) {
  2737. halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x01); /* BT goto standby while GNT_BT 1-->0 */
  2738. } else if (pBtCoexist->board_info.btdm_ant_num == 1) {
  2739. halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x15); /* BT goto standby while GNT_BT 1-->0 */
  2740. }
  2741. }
  2742. }
  2743. void EXhalbtcoutsrc_pnp_notify(PBTC_COEXIST pBtCoexist, u8 pnpState)
  2744. {
  2745. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2746. return;
  2747. /* */
  2748. /* currently only 1ant we have to do the notification, */
  2749. /* once pnp is notified to sleep state, we have to leave LPS that we can sleep normally. */
  2750. /* */
  2751. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2752. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2753. ex_halbtc8723b1ant_pnp_notify(pBtCoexist, pnpState);
  2754. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2755. ex_halbtc8723b2ant_pnp_notify(pBtCoexist, pnpState);
  2756. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2757. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2758. ex_halbtc8703b1ant_pnp_notify(pBtCoexist, pnpState);
  2759. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2760. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2761. ex_halbtc8723d1ant_pnp_notify(pBtCoexist, pnpState);
  2762. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2763. ex_halbtc8723d2ant_pnp_notify(pBtCoexist, pnpState);
  2764. } else if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2765. #if 0
  2766. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2767. ex_halbtc8821aCsr2ant_pnp_notify(pBtCoexist, pnpState);
  2768. else
  2769. #endif
  2770. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2771. ex_halbtc8821a1ant_pnp_notify(pBtCoexist, pnpState);
  2772. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2773. ex_halbtc8821a2ant_pnp_notify(pBtCoexist, pnpState);
  2774. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2775. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2776. ex_halbtc8192e1ant_pnp_notify(pBtCoexist, pnpState);
  2777. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2778. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2779. ex_halbtc8812a1ant_pnp_notify(pBtCoexist, pnpState);
  2780. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2781. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2782. ex_halbtc8822b1ant_pnp_notify(pBtCoexist, pnpState);
  2783. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2784. ex_halbtc8822b2ant_pnp_notify(pBtCoexist, pnpState);
  2785. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2786. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2787. ex_halbtc8821c2ant_pnp_notify(pBtCoexist, pnpState);
  2788. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2789. ex_halbtc8821c1ant_pnp_notify(pBtCoexist, pnpState);
  2790. }
  2791. }
  2792. void EXhalbtcoutsrc_CoexDmSwitch(PBTC_COEXIST pBtCoexist)
  2793. {
  2794. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2795. return;
  2796. pBtCoexist->statistics.cnt_coex_dm_switch++;
  2797. halbtcoutsrc_LeaveLowPower(pBtCoexist);
  2798. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2799. if (pBtCoexist->board_info.btdm_ant_num == 1) {
  2800. pBtCoexist->stop_coex_dm = TRUE;
  2801. ex_halbtc8723b1ant_coex_dm_reset(pBtCoexist);
  2802. EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2);
  2803. ex_halbtc8723b2ant_init_hw_config(pBtCoexist, FALSE);
  2804. ex_halbtc8723b2ant_init_coex_dm(pBtCoexist);
  2805. pBtCoexist->stop_coex_dm = FALSE;
  2806. }
  2807. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2808. if (pBtCoexist->board_info.btdm_ant_num == 1) {
  2809. pBtCoexist->stop_coex_dm = TRUE;
  2810. ex_halbtc8723d1ant_coex_dm_reset(pBtCoexist);
  2811. EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2);
  2812. ex_halbtc8723d2ant_init_hw_config(pBtCoexist, FALSE);
  2813. ex_halbtc8723d2ant_init_coex_dm(pBtCoexist);
  2814. pBtCoexist->stop_coex_dm = FALSE;
  2815. }
  2816. }
  2817. halbtcoutsrc_NormalLowPower(pBtCoexist);
  2818. }
  2819. void EXhalbtcoutsrc_periodical(PBTC_COEXIST pBtCoexist)
  2820. {
  2821. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2822. return;
  2823. pBtCoexist->statistics.cnt_periodical++;
  2824. /* Periodical should be called in cmd thread, */
  2825. /* don't need to leave low power again
  2826. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2827. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  2828. #if 0
  2829. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  2830. ex_halbtc8821aCsr2ant_periodical(pBtCoexist);
  2831. else
  2832. #endif
  2833. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2834. ex_halbtc8821a2ant_periodical(pBtCoexist);
  2835. else if (pBtCoexist->board_info.btdm_ant_num == 1) {
  2836. if (!halbtcoutsrc_UnderIps(pBtCoexist))
  2837. ex_halbtc8821a1ant_periodical(pBtCoexist);
  2838. }
  2839. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2840. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2841. ex_halbtc8723b2ant_periodical(pBtCoexist);
  2842. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2843. ex_halbtc8723b1ant_periodical(pBtCoexist);
  2844. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  2845. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2846. ex_halbtc8723d2ant_periodical(pBtCoexist);
  2847. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2848. ex_halbtc8723d1ant_periodical(pBtCoexist);
  2849. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  2850. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2851. ex_halbtc8703b1ant_periodical(pBtCoexist);
  2852. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2853. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2854. ex_halbtc8192e2ant_periodical(pBtCoexist);
  2855. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2856. ex_halbtc8192e1ant_periodical(pBtCoexist);
  2857. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2858. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2859. ex_halbtc8812a2ant_periodical(pBtCoexist);
  2860. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2861. ex_halbtc8812a1ant_periodical(pBtCoexist);
  2862. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  2863. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2864. ex_halbtc8822b1ant_periodical(pBtCoexist);
  2865. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  2866. ex_halbtc8822b2ant_periodical(pBtCoexist);
  2867. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  2868. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2869. ex_halbtc8821c2ant_periodical(pBtCoexist);
  2870. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2871. ex_halbtc8821c1ant_periodical(pBtCoexist);
  2872. }
  2873. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2874. }
  2875. void EXhalbtcoutsrc_dbg_control(PBTC_COEXIST pBtCoexist, u8 opCode, u8 opLen, u8 *pData)
  2876. {
  2877. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2878. return;
  2879. pBtCoexist->statistics.cnt_dbg_ctrl++;
  2880. /* This function doesn't be called yet, */
  2881. /* default no need to leave low power to avoid deadlock
  2882. * halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  2883. if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  2884. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2885. ex_halbtc8192e1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
  2886. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  2887. if (pBtCoexist->board_info.btdm_ant_num == 2)
  2888. ex_halbtc8812a2ant_dbg_control(pBtCoexist, opCode, opLen, pData);
  2889. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  2890. ex_halbtc8812a1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
  2891. } else if(IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter))
  2892. if(pBtCoexist->board_info.btdm_ant_num == 1)
  2893. ex_halbtc8822b1ant_dbg_control(pBtCoexist, opCode, opLen, pData);
  2894. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  2895. }
  2896. #if 0
  2897. VOID
  2898. EXhalbtcoutsrc_AntennaDetection(
  2899. IN PBTC_COEXIST pBtCoexist,
  2900. IN u4Byte centFreq,
  2901. IN u4Byte offset,
  2902. IN u4Byte span,
  2903. IN u4Byte seconds
  2904. )
  2905. {
  2906. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2907. return;
  2908. /* Need to refine the following power save operations to enable this function in the future */
  2909. #if 0
  2910. IPSDisable(pBtCoexist->Adapter, FALSE, 0);
  2911. LeisurePSLeave(pBtCoexist->Adapter, LPS_DISABLE_BT_COEX);
  2912. #endif
  2913. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  2914. if (pBtCoexist->board_info.btdm_ant_num == 1)
  2915. ex_halbtc8723b1ant_AntennaDetection(pBtCoexist, centFreq, offset, span, seconds);
  2916. }
  2917. /* IPSReturn(pBtCoexist->Adapter, 0xff); */
  2918. }
  2919. #endif
  2920. void EXhalbtcoutsrc_StackUpdateProfileInfo(void)
  2921. {
  2922. #ifdef CONFIG_BT_COEXIST_SOCKET_TRX
  2923. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  2924. PADAPTER padapter = (PADAPTER)GLBtCoexist.Adapter;
  2925. PBT_MGNT pBtMgnt = &padapter->coex_info.BtMgnt;
  2926. u8 i;
  2927. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2928. return;
  2929. pBtCoexist->stack_info.profile_notified = _TRUE;
  2930. pBtCoexist->stack_info.num_of_link =
  2931. pBtMgnt->ExtConfig.NumberOfACL + pBtMgnt->ExtConfig.NumberOfSCO;
  2932. /* reset first */
  2933. pBtCoexist->stack_info.bt_link_exist = _FALSE;
  2934. pBtCoexist->stack_info.sco_exist = _FALSE;
  2935. pBtCoexist->stack_info.acl_exist = _FALSE;
  2936. pBtCoexist->stack_info.a2dp_exist = _FALSE;
  2937. pBtCoexist->stack_info.hid_exist = _FALSE;
  2938. pBtCoexist->stack_info.num_of_hid = 0;
  2939. pBtCoexist->stack_info.pan_exist = _FALSE;
  2940. if (!pBtMgnt->ExtConfig.NumberOfACL)
  2941. pBtCoexist->stack_info.min_bt_rssi = 0;
  2942. if (pBtCoexist->stack_info.num_of_link) {
  2943. pBtCoexist->stack_info.bt_link_exist = _TRUE;
  2944. if (pBtMgnt->ExtConfig.NumberOfSCO)
  2945. pBtCoexist->stack_info.sco_exist = _TRUE;
  2946. if (pBtMgnt->ExtConfig.NumberOfACL)
  2947. pBtCoexist->stack_info.acl_exist = _TRUE;
  2948. }
  2949. for (i = 0; i < pBtMgnt->ExtConfig.NumberOfACL; i++) {
  2950. if (BT_PROFILE_A2DP == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
  2951. pBtCoexist->stack_info.a2dp_exist = _TRUE;
  2952. else if (BT_PROFILE_PAN == pBtMgnt->ExtConfig.aclLink[i].BTProfile)
  2953. pBtCoexist->stack_info.pan_exist = _TRUE;
  2954. else if (BT_PROFILE_HID == pBtMgnt->ExtConfig.aclLink[i].BTProfile) {
  2955. pBtCoexist->stack_info.hid_exist = _TRUE;
  2956. pBtCoexist->stack_info.num_of_hid++;
  2957. } else
  2958. pBtCoexist->stack_info.unknown_acl_exist = _TRUE;
  2959. }
  2960. #endif /* CONFIG_BT_COEXIST_SOCKET_TRX */
  2961. }
  2962. void EXhalbtcoutsrc_UpdateMinBtRssi(s8 btRssi)
  2963. {
  2964. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  2965. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2966. return;
  2967. pBtCoexist->stack_info.min_bt_rssi = btRssi;
  2968. }
  2969. void EXhalbtcoutsrc_SetHciVersion(u16 hciVersion)
  2970. {
  2971. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  2972. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2973. return;
  2974. pBtCoexist->stack_info.hci_version = hciVersion;
  2975. }
  2976. void EXhalbtcoutsrc_SetBtPatchVersion(u16 btHciVersion, u16 btPatchVersion)
  2977. {
  2978. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  2979. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  2980. return;
  2981. pBtCoexist->bt_info.bt_real_fw_ver = btPatchVersion;
  2982. pBtCoexist->bt_info.bt_hci_ver = btHciVersion;
  2983. }
  2984. #if 0
  2985. void EXhalbtcoutsrc_SetBtExist(u8 bBtExist)
  2986. {
  2987. GLBtCoexist.boardInfo.bBtExist = bBtExist;
  2988. }
  2989. #endif
  2990. void EXhalbtcoutsrc_SetChipType(u8 chipType)
  2991. {
  2992. switch (chipType) {
  2993. default:
  2994. case BT_2WIRE:
  2995. case BT_ISSC_3WIRE:
  2996. case BT_ACCEL:
  2997. case BT_RTL8756:
  2998. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_UNDEF;
  2999. break;
  3000. case BT_CSR_BC4:
  3001. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC4;
  3002. break;
  3003. case BT_CSR_BC8:
  3004. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_CSR_BC8;
  3005. break;
  3006. case BT_RTL8723A:
  3007. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8723A;
  3008. break;
  3009. case BT_RTL8821:
  3010. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8821;
  3011. break;
  3012. case BT_RTL8723B:
  3013. GLBtCoexist.board_info.bt_chip_type = BTC_CHIP_RTL8723B;
  3014. break;
  3015. }
  3016. }
  3017. void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum)
  3018. {
  3019. if (BT_COEX_ANT_TYPE_PG == type) {
  3020. GLBtCoexist.board_info.pg_ant_num = antNum;
  3021. GLBtCoexist.board_info.btdm_ant_num = antNum;
  3022. #if 0
  3023. /* The antenna position: Main (default) or Aux for pgAntNum=2 && btdmAntNum =1 */
  3024. /* The antenna position should be determined by auto-detect mechanism */
  3025. /* The following is assumed to main, and those must be modified if y auto-detect mechanism is ready */
  3026. if ((GLBtCoexist.board_info.pg_ant_num == 2) && (GLBtCoexist.board_info.btdm_ant_num == 1))
  3027. GLBtCoexist.board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
  3028. else
  3029. GLBtCoexist.board_info.btdm_ant_pos = BTC_ANTENNA_AT_MAIN_PORT;
  3030. #endif
  3031. } else if (BT_COEX_ANT_TYPE_ANTDIV == type) {
  3032. GLBtCoexist.board_info.btdm_ant_num = antNum;
  3033. /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
  3034. } else if (BT_COEX_ANT_TYPE_DETECTED == type) {
  3035. GLBtCoexist.board_info.btdm_ant_num = antNum;
  3036. /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */
  3037. }
  3038. }
  3039. /*
  3040. * Currently used by 8723b only, S0 or S1
  3041. * */
  3042. void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath)
  3043. {
  3044. GLBtCoexist.board_info.single_ant_path = singleAntPath;
  3045. }
  3046. void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist)
  3047. {
  3048. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  3049. return;
  3050. halbtcoutsrc_LeaveLowPower(pBtCoexist);
  3051. /* To prevent the racing with IPS enter */
  3052. halbtcoutsrc_EnterPwrLock(pBtCoexist);
  3053. if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) {
  3054. #if 0
  3055. if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE)
  3056. ex_halbtc8821aCsr2ant_display_coex_info(pBtCoexist);
  3057. else
  3058. #endif
  3059. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3060. ex_halbtc8821a2ant_display_coex_info(pBtCoexist);
  3061. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3062. ex_halbtc8821a1ant_display_coex_info(pBtCoexist);
  3063. } else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  3064. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3065. ex_halbtc8723b2ant_display_coex_info(pBtCoexist);
  3066. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3067. ex_halbtc8723b1ant_display_coex_info(pBtCoexist);
  3068. } else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) {
  3069. if (pBtCoexist->board_info.btdm_ant_num == 1)
  3070. ex_halbtc8703b1ant_display_coex_info(pBtCoexist);
  3071. } else if (IS_HARDWARE_TYPE_8723D(pBtCoexist->Adapter)) {
  3072. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3073. ex_halbtc8723d2ant_display_coex_info(pBtCoexist);
  3074. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3075. ex_halbtc8723d1ant_display_coex_info(pBtCoexist);
  3076. } else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) {
  3077. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3078. ex_halbtc8192e2ant_display_coex_info(pBtCoexist);
  3079. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3080. ex_halbtc8192e1ant_display_coex_info(pBtCoexist);
  3081. } else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  3082. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3083. ex_halbtc8812a2ant_display_coex_info(pBtCoexist);
  3084. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3085. ex_halbtc8812a1ant_display_coex_info(pBtCoexist);
  3086. } else if (IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  3087. if (pBtCoexist->board_info.btdm_ant_num == 1)
  3088. ex_halbtc8822b1ant_display_coex_info(pBtCoexist);
  3089. else if (pBtCoexist->board_info.btdm_ant_num == 2)
  3090. ex_halbtc8822b2ant_display_coex_info(pBtCoexist);
  3091. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  3092. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3093. ex_halbtc8821c2ant_display_coex_info(pBtCoexist);
  3094. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3095. ex_halbtc8821c1ant_display_coex_info(pBtCoexist);
  3096. }
  3097. halbtcoutsrc_ExitPwrLock(pBtCoexist);
  3098. halbtcoutsrc_NormalLowPower(pBtCoexist);
  3099. }
  3100. void EXhalbtcoutsrc_DisplayAntDetection(PBTC_COEXIST pBtCoexist)
  3101. {
  3102. if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  3103. return;
  3104. halbtcoutsrc_LeaveLowPower(pBtCoexist);
  3105. if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) {
  3106. if (pBtCoexist->board_info.btdm_ant_num == 1)
  3107. ex_halbtc8723b1ant_display_ant_detection(pBtCoexist);
  3108. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  3109. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3110. ex_halbtc8821c2ant_display_ant_detection(pBtCoexist);
  3111. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3112. ex_halbtc8821c1ant_display_ant_detection(pBtCoexist);
  3113. }
  3114. halbtcoutsrc_NormalLowPower(pBtCoexist);
  3115. }
  3116. void ex_halbtcoutsrc_pta_off_on_notify(PBTC_COEXIST pBtCoexist, u8 bBTON)
  3117. {
  3118. if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) {
  3119. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3120. ex_halbtc8812a2ant_pta_off_on_notify(pBtCoexist, (bBTON == _TRUE) ? BTC_BT_ON : BTC_BT_OFF);
  3121. }
  3122. }
  3123. void EXhalbtcoutsrc_set_rfe_type(u8 type)
  3124. {
  3125. GLBtCoexist.board_info.rfe_type= type;
  3126. }
  3127. #ifdef CONFIG_RF4CE_COEXIST
  3128. void EXhalbtcoutsrc_set_rf4ce_link_state(u8 state)
  3129. {
  3130. GLBtCoexist.rf4ce_info.link_state = state;
  3131. }
  3132. u8 EXhalbtcoutsrc_get_rf4ce_link_state(void)
  3133. {
  3134. return GLBtCoexist.rf4ce_info.link_state;
  3135. }
  3136. #endif
  3137. void EXhalbtcoutsrc_switchband_notify(struct btc_coexist *pBtCoexist, u8 type)
  3138. {
  3139. if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist))
  3140. return;
  3141. if(pBtCoexist->manual_control)
  3142. return;
  3143. /* Driver should guarantee that the HW status isn't in low power mode */
  3144. /* halbtcoutsrc_LeaveLowPower(pBtCoexist); */
  3145. if(IS_HARDWARE_TYPE_8822B(pBtCoexist->Adapter)) {
  3146. if(pBtCoexist->board_info.btdm_ant_num == 1)
  3147. ex_halbtc8822b1ant_switchband_notify(pBtCoexist, type);
  3148. else if(pBtCoexist->board_info.btdm_ant_num == 2)
  3149. ex_halbtc8822b2ant_switchband_notify(pBtCoexist, type);
  3150. } else if (IS_HARDWARE_TYPE_8821C(pBtCoexist->Adapter)) {
  3151. if (pBtCoexist->board_info.btdm_ant_num == 2)
  3152. ex_halbtc8821c2ant_switchband_notify(pBtCoexist, type);
  3153. else if (pBtCoexist->board_info.btdm_ant_num == 1)
  3154. ex_halbtc8821c1ant_switchband_notify(pBtCoexist, type);
  3155. }
  3156. /* halbtcoutsrc_NormalLowPower(pBtCoexist); */
  3157. }
  3158. static void halbt_init_hw_config92C(PADAPTER padapter)
  3159. {
  3160. PHAL_DATA_TYPE pHalData;
  3161. u8 u1Tmp;
  3162. pHalData = GET_HAL_DATA(padapter);
  3163. if ((pHalData->bt_coexist.btChipType == BT_CSR_BC4) ||
  3164. (pHalData->bt_coexist.btChipType == BT_CSR_BC8)) {
  3165. if (pHalData->rf_type == RF_1T1R) {
  3166. /* Config to 1T1R */
  3167. u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable);
  3168. u1Tmp &= ~BIT(1);
  3169. rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp);
  3170. RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp));
  3171. u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable);
  3172. u1Tmp &= ~BIT(1);
  3173. rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp);
  3174. RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp));
  3175. }
  3176. }
  3177. }
  3178. static void halbt_init_hw_config92D(PADAPTER padapter)
  3179. {
  3180. PHAL_DATA_TYPE pHalData;
  3181. u8 u1Tmp;
  3182. pHalData = GET_HAL_DATA(padapter);
  3183. if ((pHalData->bt_coexist.btChipType == BT_CSR_BC4) ||
  3184. (pHalData->bt_coexist.btChipType == BT_CSR_BC8)) {
  3185. if (pHalData->rf_type == RF_1T1R) {
  3186. /* Config to 1T1R */
  3187. u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable);
  3188. u1Tmp &= ~BIT(1);
  3189. rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp);
  3190. RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp));
  3191. u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable);
  3192. u1Tmp &= ~BIT(1);
  3193. rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp);
  3194. RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp));
  3195. }
  3196. }
  3197. }
  3198. /*
  3199. * Description:
  3200. * Run BT-Coexist mechansim or not
  3201. *
  3202. */
  3203. void hal_btcoex_SetBTCoexist(PADAPTER padapter, u8 bBtExist)
  3204. {
  3205. PHAL_DATA_TYPE pHalData;
  3206. pHalData = GET_HAL_DATA(padapter);
  3207. pHalData->bt_coexist.bBtExist = bBtExist;
  3208. }
  3209. /*
  3210. * Dewcription:
  3211. * Check is co-exist mechanism enabled or not
  3212. *
  3213. * Return:
  3214. * _TRUE Enable BT co-exist mechanism
  3215. * _FALSE Disable BT co-exist mechanism
  3216. */
  3217. u8 hal_btcoex_IsBtExist(PADAPTER padapter)
  3218. {
  3219. PHAL_DATA_TYPE pHalData;
  3220. pHalData = GET_HAL_DATA(padapter);
  3221. return pHalData->bt_coexist.bBtExist;
  3222. }
  3223. u8 hal_btcoex_IsBtDisabled(PADAPTER padapter)
  3224. {
  3225. if (!hal_btcoex_IsBtExist(padapter))
  3226. return _TRUE;
  3227. if (GLBtCoexist.bt_info.bt_disabled)
  3228. return _TRUE;
  3229. else
  3230. return _FALSE;
  3231. }
  3232. void hal_btcoex_SetChipType(PADAPTER padapter, u8 chipType)
  3233. {
  3234. PHAL_DATA_TYPE pHalData;
  3235. pHalData = GET_HAL_DATA(padapter);
  3236. pHalData->bt_coexist.btChipType = chipType;
  3237. }
  3238. void hal_btcoex_SetPgAntNum(PADAPTER padapter, u8 antNum)
  3239. {
  3240. PHAL_DATA_TYPE pHalData;
  3241. pHalData = GET_HAL_DATA(padapter);
  3242. pHalData->bt_coexist.btTotalAntNum = antNum;
  3243. }
  3244. u8 hal_btcoex_Initialize(PADAPTER padapter)
  3245. {
  3246. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
  3247. u8 ret;
  3248. _rtw_memset(&GLBtCoexist, 0, sizeof(GLBtCoexist));
  3249. hal_btcoex_SetBTCoexist(padapter, rtw_btcoex_get_bt_coexist(padapter));
  3250. hal_btcoex_SetChipType(padapter, rtw_btcoex_get_chip_type(padapter));
  3251. hal_btcoex_SetPgAntNum(padapter, rtw_btcoex_get_pg_ant_num(padapter));
  3252. ret = EXhalbtcoutsrc_InitlizeVariables((void *)padapter);
  3253. return ret;
  3254. }
  3255. void hal_btcoex_PowerOnSetting(PADAPTER padapter)
  3256. {
  3257. EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist);
  3258. }
  3259. void hal_btcoex_PowerOffSetting(PADAPTER padapter)
  3260. {
  3261. /* Clear the WiFi on/off bit in scoreboard reg. if necessary */
  3262. if (IS_HARDWARE_TYPE_8703B(padapter) || IS_HARDWARE_TYPE_8723D(padapter)
  3263. || IS_HARDWARE_TYPE_8821C(padapter) || IS_HARDWARE_TYPE_8822B(padapter))
  3264. rtw_write16(padapter, 0xaa, 0x8000);
  3265. }
  3266. void hal_btcoex_PreLoadFirmware(PADAPTER padapter)
  3267. {
  3268. EXhalbtcoutsrc_PreLoadFirmware(&GLBtCoexist);
  3269. }
  3270. void hal_btcoex_InitHwConfig(PADAPTER padapter, u8 bWifiOnly)
  3271. {
  3272. if (!hal_btcoex_IsBtExist(padapter))
  3273. return;
  3274. EXhalbtcoutsrc_init_hw_config(&GLBtCoexist, bWifiOnly);
  3275. EXhalbtcoutsrc_init_coex_dm(&GLBtCoexist);
  3276. }
  3277. void hal_btcoex_IpsNotify(PADAPTER padapter, u8 type)
  3278. {
  3279. EXhalbtcoutsrc_ips_notify(&GLBtCoexist, type);
  3280. }
  3281. void hal_btcoex_LpsNotify(PADAPTER padapter, u8 type)
  3282. {
  3283. EXhalbtcoutsrc_lps_notify(&GLBtCoexist, type);
  3284. }
  3285. void hal_btcoex_ScanNotify(PADAPTER padapter, u8 type)
  3286. {
  3287. EXhalbtcoutsrc_scan_notify(&GLBtCoexist, type);
  3288. }
  3289. void hal_btcoex_ConnectNotify(PADAPTER padapter, u8 action)
  3290. {
  3291. EXhalbtcoutsrc_connect_notify(&GLBtCoexist, action);
  3292. }
  3293. void hal_btcoex_MediaStatusNotify(PADAPTER padapter, u8 mediaStatus)
  3294. {
  3295. EXhalbtcoutsrc_media_status_notify(&GLBtCoexist, mediaStatus);
  3296. }
  3297. void hal_btcoex_SpecialPacketNotify(PADAPTER padapter, u8 pktType)
  3298. {
  3299. EXhalbtcoutsrc_specific_packet_notify(&GLBtCoexist, pktType);
  3300. }
  3301. void hal_btcoex_IQKNotify(PADAPTER padapter, u8 state)
  3302. {
  3303. GLBtcWiFiInIQKState = state;
  3304. }
  3305. void hal_btcoex_BtInfoNotify(PADAPTER padapter, u8 length, u8 *tmpBuf)
  3306. {
  3307. if (GLBtcWiFiInIQKState == _TRUE)
  3308. return;
  3309. EXhalbtcoutsrc_bt_info_notify(&GLBtCoexist, tmpBuf, length);
  3310. }
  3311. void hal_btcoex_BtMpRptNotify(PADAPTER padapter, u8 length, u8 *tmpBuf)
  3312. {
  3313. u8 extid, status, len, seq;
  3314. if (!GLBtcBtMpRptWait)
  3315. return;
  3316. if ((length < 3) || (!tmpBuf))
  3317. return;
  3318. extid = tmpBuf[0];
  3319. /* not response from BT FW then exit*/
  3320. switch (extid) {
  3321. case C2H_WIFI_FW_ACTIVE_RSP:
  3322. GLBtcBtMpRptWiFiOK = 1;
  3323. return;
  3324. case C2H_TRIG_BY_BT_FW:
  3325. _cancel_timer_ex(&GLBtcBtMpOperTimer);
  3326. GLBtcBtMpRptWait = 0;
  3327. GLBtcBtMpRptBTOK = 1;
  3328. break;
  3329. default:
  3330. return;
  3331. }
  3332. status = tmpBuf[1] & 0xF;
  3333. len = length - 3;
  3334. seq = tmpBuf[2] >> 4;
  3335. GLBtcBtMpRptSeq = seq;
  3336. GLBtcBtMpRptStatus = status;
  3337. _rtw_memcpy(GLBtcBtMpRptRsp, tmpBuf + 3, len);
  3338. GLBtcBtMpRptRspSize = len;
  3339. _rtw_up_sema(&GLBtcBtMpRptSema);
  3340. }
  3341. void hal_btcoex_SuspendNotify(PADAPTER padapter, u8 state)
  3342. {
  3343. switch (state) {
  3344. case BTCOEX_SUSPEND_STATE_SUSPEND:
  3345. EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP);
  3346. break;
  3347. case BTCOEX_SUSPEND_STATE_SUSPEND_KEEP_ANT:
  3348. /* should switch to "#if 1" once all ICs' coex. revision are upgraded to support the KEEP_ANT case */
  3349. #if 0
  3350. EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP_KEEP_ANT);
  3351. #else
  3352. EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP);
  3353. EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_SLEEP_KEEP_ANT);
  3354. #endif
  3355. break;
  3356. case BTCOEX_SUSPEND_STATE_RESUME:
  3357. EXhalbtcoutsrc_pnp_notify(&GLBtCoexist, BTC_WIFI_PNP_WAKE_UP);
  3358. break;
  3359. }
  3360. }
  3361. void hal_btcoex_HaltNotify(PADAPTER padapter, u8 do_halt)
  3362. {
  3363. if (do_halt == 1)
  3364. EXhalbtcoutsrc_halt_notify(&GLBtCoexist);
  3365. GLBtCoexist.bBinded = _FALSE;
  3366. GLBtCoexist.Adapter = NULL;
  3367. }
  3368. void hal_btcoex_SwitchBtTRxMask(PADAPTER padapter)
  3369. {
  3370. EXhalbtcoutsrc_SwitchBtTRxMask(&GLBtCoexist);
  3371. }
  3372. void hal_btcoex_Hanlder(PADAPTER padapter)
  3373. {
  3374. u32 bt_patch_ver;
  3375. EXhalbtcoutsrc_periodical(&GLBtCoexist);
  3376. if (GLBtCoexist.bt_info.bt_get_fw_ver == 0) {
  3377. GLBtCoexist.btc_get(&GLBtCoexist, BTC_GET_U4_BT_PATCH_VER, &bt_patch_ver);
  3378. GLBtCoexist.bt_info.bt_get_fw_ver = bt_patch_ver;
  3379. }
  3380. }
  3381. s32 hal_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter)
  3382. {
  3383. return (s32)GLBtCoexist.bt_info.reject_agg_pkt;
  3384. }
  3385. s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER padapter)
  3386. {
  3387. return (s32)GLBtCoexist.bt_info.bt_ctrl_agg_buf_size;
  3388. }
  3389. u32 hal_btcoex_GetAMPDUSize(PADAPTER padapter)
  3390. {
  3391. return (u32)GLBtCoexist.bt_info.agg_buf_size;
  3392. }
  3393. void hal_btcoex_SetManualControl(PADAPTER padapter, u8 bmanual)
  3394. {
  3395. GLBtCoexist.manual_control = bmanual;
  3396. }
  3397. u8 hal_btcoex_1Ant(PADAPTER padapter)
  3398. {
  3399. if (hal_btcoex_IsBtExist(padapter) == _FALSE)
  3400. return _FALSE;
  3401. if (GLBtCoexist.board_info.btdm_ant_num == 1)
  3402. return _TRUE;
  3403. return _FALSE;
  3404. }
  3405. u8 hal_btcoex_IsBtControlLps(PADAPTER padapter)
  3406. {
  3407. if (GLBtCoexist.bdontenterLPS == _TRUE)
  3408. return _TRUE;
  3409. if (hal_btcoex_IsBtExist(padapter) == _FALSE)
  3410. return _FALSE;
  3411. if (GLBtCoexist.bt_info.bt_disabled)
  3412. return _FALSE;
  3413. if (GLBtCoexist.bt_info.bt_ctrl_lps)
  3414. return _TRUE;
  3415. return _FALSE;
  3416. }
  3417. u8 hal_btcoex_IsLpsOn(PADAPTER padapter)
  3418. {
  3419. if (GLBtCoexist.bdontenterLPS == _TRUE)
  3420. return _FALSE;
  3421. if (hal_btcoex_IsBtExist(padapter) == _FALSE)
  3422. return _FALSE;
  3423. if (GLBtCoexist.bt_info.bt_disabled)
  3424. return _FALSE;
  3425. if (GLBtCoexist.bt_info.bt_lps_on)
  3426. return _TRUE;
  3427. return _FALSE;
  3428. }
  3429. u8 hal_btcoex_RpwmVal(PADAPTER padapter)
  3430. {
  3431. return GLBtCoexist.bt_info.rpwm_val;
  3432. }
  3433. u8 hal_btcoex_LpsVal(PADAPTER padapter)
  3434. {
  3435. return GLBtCoexist.bt_info.lps_val;
  3436. }
  3437. u32 hal_btcoex_GetRaMask(PADAPTER padapter)
  3438. {
  3439. if (!hal_btcoex_IsBtExist(padapter))
  3440. return 0;
  3441. if (GLBtCoexist.bt_info.bt_disabled)
  3442. return 0;
  3443. /* Modify by YiWei , suggest by Cosa and Jenyu
  3444. * Remove the limit antenna number , because 2 antenna case (ex: 8192eu)also want to get BT coex report rate mask.
  3445. */
  3446. /*if (GLBtCoexist.board_info.btdm_ant_num != 1)
  3447. return 0;*/
  3448. return GLBtCoexist.bt_info.ra_mask;
  3449. }
  3450. void hal_btcoex_RecordPwrMode(PADAPTER padapter, u8 *pCmdBuf, u8 cmdLen)
  3451. {
  3452. _rtw_memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen);
  3453. }
  3454. void hal_btcoex_DisplayBtCoexInfo(PADAPTER padapter, u8 *pbuf, u32 bufsize)
  3455. {
  3456. PBTCDBGINFO pinfo;
  3457. pinfo = &GLBtcDbgInfo;
  3458. DBG_BT_INFO_INIT(pinfo, pbuf, bufsize);
  3459. EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist);
  3460. DBG_BT_INFO_INIT(pinfo, NULL, 0);
  3461. }
  3462. void hal_btcoex_SetDBG(PADAPTER padapter, u32 *pDbgModule)
  3463. {
  3464. u32 i;
  3465. if (NULL == pDbgModule)
  3466. return;
  3467. for (i = 0; i < COMP_MAX; i++)
  3468. GLBtcDbgType[i] = pDbgModule[i];
  3469. }
  3470. u32 hal_btcoex_GetDBG(PADAPTER padapter, u8 *pStrBuf, u32 bufSize)
  3471. {
  3472. s32 count;
  3473. u8 *pstr;
  3474. u32 leftSize;
  3475. if ((NULL == pStrBuf) || (0 == bufSize))
  3476. return 0;
  3477. count = 0;
  3478. pstr = pStrBuf;
  3479. leftSize = bufSize;
  3480. /* RTW_INFO(FUNC_ADPT_FMT ": bufsize=%d\n", FUNC_ADPT_ARG(padapter), bufSize); */
  3481. count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG);
  3482. if ((count < 0) || (count >= leftSize))
  3483. goto exit;
  3484. pstr += count;
  3485. leftSize -= count;
  3486. count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n");
  3487. if ((count < 0) || (count >= leftSize))
  3488. goto exit;
  3489. pstr += count;
  3490. leftSize -= count;
  3491. count = rtw_sprintf(pstr, leftSize,
  3492. "COMP_COEX: 0x%08X\n\n",
  3493. GLBtcDbgType[COMP_COEX]);
  3494. if ((count < 0) || (count >= leftSize))
  3495. goto exit;
  3496. pstr += count;
  3497. leftSize -= count;
  3498. #if 0
  3499. count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n");
  3500. if ((count < 0) || (count >= leftSize))
  3501. goto exit;
  3502. pstr += count;
  3503. leftSize -= count;
  3504. count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n",
  3505. GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_INIT ? 1 : 0);
  3506. if ((count < 0) || (count >= leftSize))
  3507. goto exit;
  3508. pstr += count;
  3509. leftSize -= count;
  3510. count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n",
  3511. GLBtcDbgType[BTC_MSG_INTERFACE] & INTF_NOTIFY ? 1 : 0);
  3512. if ((count < 0) || (count >= leftSize))
  3513. goto exit;
  3514. pstr += count;
  3515. leftSize -= count;
  3516. count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n");
  3517. if ((count < 0) || (count >= leftSize))
  3518. goto exit;
  3519. pstr += count;
  3520. leftSize -= count;
  3521. count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n",
  3522. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_RSSI_STATE ? 1 : 0);
  3523. if ((count < 0) || (count >= leftSize))
  3524. goto exit;
  3525. pstr += count;
  3526. leftSize -= count;
  3527. count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n",
  3528. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_WIFI_RSSI_STATE ? 1 : 0);
  3529. if ((count < 0) || (count >= leftSize))
  3530. goto exit;
  3531. pstr += count;
  3532. leftSize -= count;
  3533. count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n",
  3534. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_BT_MONITOR ? 1 : 0);
  3535. if ((count < 0) || (count >= leftSize))
  3536. goto exit;
  3537. pstr += count;
  3538. leftSize -= count;
  3539. count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n",
  3540. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE ? 1 : 0);
  3541. if ((count < 0) || (count >= leftSize))
  3542. goto exit;
  3543. pstr += count;
  3544. leftSize -= count;
  3545. count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n",
  3546. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW ? 1 : 0);
  3547. if ((count < 0) || (count >= leftSize))
  3548. goto exit;
  3549. pstr += count;
  3550. leftSize -= count;
  3551. count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n",
  3552. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_DETAIL ? 1 : 0);
  3553. if ((count < 0) || (count >= leftSize))
  3554. goto exit;
  3555. pstr += count;
  3556. leftSize -= count;
  3557. count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n",
  3558. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_FW_EXEC ? 1 : 0);
  3559. if ((count < 0) || (count >= leftSize))
  3560. goto exit;
  3561. pstr += count;
  3562. leftSize -= count;
  3563. count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n",
  3564. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW ? 1 : 0);
  3565. if ((count < 0) || (count >= leftSize))
  3566. goto exit;
  3567. pstr += count;
  3568. leftSize -= count;
  3569. count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n",
  3570. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_DETAIL ? 1 : 0);
  3571. if ((count < 0) || (count >= leftSize))
  3572. goto exit;
  3573. pstr += count;
  3574. leftSize -= count;
  3575. count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n",
  3576. GLBtcDbgType[BTC_MSG_ALGORITHM] & ALGO_TRACE_SW_EXEC ? 1 : 0);
  3577. if ((count < 0) || (count >= leftSize))
  3578. goto exit;
  3579. pstr += count;
  3580. leftSize -= count;
  3581. #endif
  3582. exit:
  3583. count = pstr - pStrBuf;
  3584. /* RTW_INFO(FUNC_ADPT_FMT ": usedsize=%d\n", FUNC_ADPT_ARG(padapter), count); */
  3585. return count;
  3586. }
  3587. u8 hal_btcoex_IncreaseScanDeviceNum(PADAPTER padapter)
  3588. {
  3589. if (!hal_btcoex_IsBtExist(padapter))
  3590. return _FALSE;
  3591. if (GLBtCoexist.bt_info.increase_scan_dev_num)
  3592. return _TRUE;
  3593. return _FALSE;
  3594. }
  3595. u8 hal_btcoex_IsBtLinkExist(PADAPTER padapter)
  3596. {
  3597. if (GLBtCoexist.bt_link_info.bt_link_exist)
  3598. return _TRUE;
  3599. return _FALSE;
  3600. }
  3601. void hal_btcoex_SetBtPatchVersion(PADAPTER padapter, u16 btHciVer, u16 btPatchVer)
  3602. {
  3603. EXhalbtcoutsrc_SetBtPatchVersion(btHciVer, btPatchVer);
  3604. }
  3605. void hal_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion)
  3606. {
  3607. EXhalbtcoutsrc_SetHciVersion(hciVersion);
  3608. }
  3609. void hal_btcoex_StackUpdateProfileInfo(void)
  3610. {
  3611. EXhalbtcoutsrc_StackUpdateProfileInfo();
  3612. }
  3613. void hal_btcoex_pta_off_on_notify(PADAPTER padapter, u8 bBTON)
  3614. {
  3615. ex_halbtcoutsrc_pta_off_on_notify(&GLBtCoexist, bBTON);
  3616. }
  3617. /*
  3618. * Description:
  3619. * Setting BT coex antenna isolation type .
  3620. * coex mechanisn/ spital stream/ best throughput
  3621. * anttype = 0 , PSTDMA / 2SS / 0.5T , bad isolation , WiFi/BT ANT Distance<15cm , (<20dB) for 2,3 antenna
  3622. * anttype = 1 , PSTDMA / 1SS / 0.5T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 2 antenna
  3623. * anttype = 2 , TDMA / 2SS / T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 3 antenna
  3624. * anttype = 3 , no TDMA / 1SS / 0.5T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 2 antenna
  3625. * anttype = 4 , no TDMA / 2SS / T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 3 antenna
  3626. * wifi only throughput ~ T
  3627. * wifi/BT share one antenna with SPDT
  3628. */
  3629. void hal_btcoex_SetAntIsolationType(PADAPTER padapter, u8 anttype)
  3630. {
  3631. PHAL_DATA_TYPE pHalData;
  3632. PBTC_COEXIST pBtCoexist = &GLBtCoexist;
  3633. /*RTW_INFO("####%s , anttype = %d , %d\n" , __func__ , anttype , __LINE__); */
  3634. pHalData = GET_HAL_DATA(padapter);
  3635. pHalData->bt_coexist.btAntisolation = anttype;
  3636. switch (pHalData->bt_coexist.btAntisolation) {
  3637. case 0:
  3638. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_0;
  3639. break;
  3640. case 1:
  3641. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_1;
  3642. break;
  3643. case 2:
  3644. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_2;
  3645. break;
  3646. case 3:
  3647. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_3;
  3648. break;
  3649. case 4:
  3650. pBtCoexist->board_info.ant_type = (u1Byte)BTC_ANT_TYPE_4;
  3651. break;
  3652. }
  3653. }
  3654. #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE
  3655. int
  3656. hal_btcoex_ParseAntIsolationConfigFile(
  3657. PADAPTER Adapter,
  3658. char *buffer
  3659. )
  3660. {
  3661. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  3662. u32 i = 0 , j = 0;
  3663. char *szLine , *ptmp;
  3664. int rtStatus = _SUCCESS;
  3665. char param_value_string[10];
  3666. u8 param_value;
  3667. u8 anttype = 4;
  3668. u8 ant_num = 3 , ant_distance = 50 , rfe_type = 1;
  3669. typedef struct ant_isolation {
  3670. char *param_name; /* antenna isolation config parameter name */
  3671. u8 *value; /* antenna isolation config parameter value */
  3672. } ANT_ISOLATION;
  3673. ANT_ISOLATION ant_isolation_param[] = {
  3674. {"ANT_NUMBER" , &ant_num},
  3675. {"ANT_DISTANCE" , &ant_distance},
  3676. {"RFE_TYPE" , &rfe_type},
  3677. {NULL , 0}
  3678. };
  3679. /* RTW_INFO("===>Hal_ParseAntIsolationConfigFile()\n" ); */
  3680. ptmp = buffer;
  3681. for (szLine = GetLineFromBuffer(ptmp) ; szLine != NULL; szLine = GetLineFromBuffer(ptmp)) {
  3682. /* skip comment */
  3683. if (IsCommentString(szLine))
  3684. continue;
  3685. /* RTW_INFO("%s : szLine = %s , strlen(szLine) = %d\n" , __func__ , szLine , strlen(szLine));*/
  3686. for (j = 0 ; ant_isolation_param[j].param_name != NULL ; j++) {
  3687. if (strstr(szLine , ant_isolation_param[j].param_name) != NULL) {
  3688. i = 0;
  3689. while (i < strlen(szLine)) {
  3690. if (szLine[i] != '"')
  3691. ++i;
  3692. else {
  3693. /* skip only has one " */
  3694. if (strpbrk(szLine , "\"") == strrchr(szLine , '"')) {
  3695. RTW_INFO("Fail to parse parameters , format error!\n");
  3696. break;
  3697. }
  3698. _rtw_memset((PVOID)param_value_string , 0 , 10);
  3699. if (!ParseQualifiedString(szLine , &i , param_value_string , '"' , '"')) {
  3700. RTW_INFO("Fail to parse parameters\n");
  3701. return _FAIL;
  3702. } else if (!GetU1ByteIntegerFromStringInDecimal(param_value_string , ant_isolation_param[j].value))
  3703. RTW_INFO("Fail to GetU1ByteIntegerFromStringInDecimal\n");
  3704. break;
  3705. }
  3706. }
  3707. }
  3708. }
  3709. }
  3710. /* YiWei 20140716 , for BT coex antenna isolation control */
  3711. /* rfe_type = 0 was SPDT , rfe_type = 1 was coupler */
  3712. if (ant_num == 3 && ant_distance >= 50)
  3713. anttype = 3;
  3714. else if (ant_num == 2 && ant_distance >= 50 && rfe_type == 1)
  3715. anttype = 2;
  3716. else if (ant_num == 3 && ant_distance >= 15 && ant_distance < 50)
  3717. anttype = 2;
  3718. else if (ant_num == 2 && ant_distance >= 15 && ant_distance < 50 && rfe_type == 1)
  3719. anttype = 2;
  3720. else if ((ant_num == 2 && ant_distance < 15 && rfe_type == 1) || (ant_num == 3 && ant_distance < 15))
  3721. anttype = 1;
  3722. else if (ant_num == 2 && rfe_type == 0)
  3723. anttype = 0;
  3724. else
  3725. anttype = 0;
  3726. hal_btcoex_SetAntIsolationType(Adapter, anttype);
  3727. RTW_INFO("%s : ant_num = %d\n" , __func__ , ant_num);
  3728. RTW_INFO("%s : ant_distance = %d\n" , __func__ , ant_distance);
  3729. RTW_INFO("%s : rfe_type = %d\n" , __func__ , rfe_type);
  3730. /* RTW_INFO("<===Hal_ParseAntIsolationConfigFile()\n"); */
  3731. return rtStatus;
  3732. }
  3733. int
  3734. hal_btcoex_AntIsolationConfig_ParaFile(
  3735. IN PADAPTER Adapter,
  3736. IN char *pFileName
  3737. )
  3738. {
  3739. HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
  3740. int rlen = 0 , rtStatus = _FAIL;
  3741. _rtw_memset(pHalData->para_file_buf , 0 , MAX_PARA_FILE_BUF_LEN);
  3742. rtw_get_phy_file_path(Adapter, pFileName);
  3743. if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) {
  3744. rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN);
  3745. if (rlen > 0)
  3746. rtStatus = _SUCCESS;
  3747. }
  3748. if (rtStatus == _SUCCESS) {
  3749. /*RTW_INFO("%s(): read %s ok\n", __func__ , pFileName);*/
  3750. rtStatus = hal_btcoex_ParseAntIsolationConfigFile(Adapter , pHalData->para_file_buf);
  3751. } else
  3752. RTW_INFO("%s(): No File %s, Load from *** Array!\n" , __func__ , pFileName);
  3753. return rtStatus;
  3754. }
  3755. #endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */
  3756. u16 hal_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data)
  3757. {
  3758. u16 ret = 0;
  3759. halbtcoutsrc_LeaveLowPower(&GLBtCoexist);
  3760. ret = halbtcoutsrc_GetBtReg_with_status(&GLBtCoexist, type, addr, data);
  3761. halbtcoutsrc_NormalLowPower(&GLBtCoexist);
  3762. return ret;
  3763. }
  3764. u16 hal_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val)
  3765. {
  3766. u16 ret = 0;
  3767. halbtcoutsrc_LeaveLowPower(&GLBtCoexist);
  3768. ret = halbtcoutsrc_SetBtReg(&GLBtCoexist, type, addr, val);
  3769. halbtcoutsrc_NormalLowPower(&GLBtCoexist);
  3770. return ret;
  3771. }
  3772. void hal_btcoex_set_rfe_type(u8 type)
  3773. {
  3774. EXhalbtcoutsrc_set_rfe_type(type);
  3775. }
  3776. #ifdef CONFIG_RF4CE_COEXIST
  3777. void hal_btcoex_set_rf4ce_link_state(u8 state)
  3778. {
  3779. EXhalbtcoutsrc_set_rf4ce_link_state(state);
  3780. }
  3781. u8 hal_btcoex_get_rf4ce_link_state(void)
  3782. {
  3783. return EXhalbtcoutsrc_get_rf4ce_link_state();
  3784. }
  3785. #endif /* CONFIG_RF4CE_COEXIST */
  3786. void hal_btcoex_switchband_notify(u8 under_scan, u8 band_type)
  3787. {
  3788. switch (band_type) {
  3789. case BAND_ON_2_4G:
  3790. if (under_scan)
  3791. EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_24G);
  3792. else
  3793. EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_24G_NOFORSCAN);
  3794. break;
  3795. case BAND_ON_5G:
  3796. EXhalbtcoutsrc_switchband_notify(&GLBtCoexist, BTC_SWITCH_TO_5G);
  3797. break;
  3798. default:
  3799. RTW_INFO("[BTCOEX] unkown switch band type\n");
  3800. break;
  3801. }
  3802. }
  3803. #endif /* CONFIG_BT_COEXIST */