12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405 |
- /******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
- *
- *
- ******************************************************************************/
- //============================================================
- // include files
- //============================================================
- #include "odm_precomp.h"
- const u2Byte dB_Invert_Table[8][12] = {
- { 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4},
- { 4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16},
- { 18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63},
- { 71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251},
- { 282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000},
- { 1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981},
- { 4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849},
- { 17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535}};
- // 20100515 Joseph: Add global variable to keep temporary scan list for antenna switching test.
- //u1Byte tmpNumBssDesc;
- //RT_WLAN_BSS tmpbssDesc[MAX_BSS_DESC];
- #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- static u4Byte edca_setting_UL[HT_IOT_PEER_MAX] =
- // UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MERU MARVELL 92U_AP SELF_AP(DownLink/Tx)
- { 0x5e4322, 0xa44f, 0x5e4322, 0x5ea32b, 0x5ea422, 0x5ea322, 0x3ea430, 0x5ea42b, 0x5ea44f, 0x5e4322, 0x5e4322};
- static u4Byte edca_setting_DL[HT_IOT_PEER_MAX] =
- // UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MERU, MARVELL 92U_AP SELF_AP(UpLink/Rx)
- { 0xa44f, 0x5ea44f, 0x5e4322, 0x5ea42b, 0xa44f, 0xa630, 0x5ea630, 0x5ea42b, 0xa44f, 0xa42b, 0xa42b};
- static u4Byte edca_setting_DL_GMode[HT_IOT_PEER_MAX] =
- // UNKNOWN REALTEK_90 REALTEK_92SE BROADCOM RALINK ATHEROS CISCO MERU, MARVELL 92U_AP SELF_AP
- { 0x4322, 0xa44f, 0x5e4322, 0xa42b, 0x5e4322, 0x4322, 0xa42b, 0x5ea42b, 0xa44f, 0x5e4322, 0x5ea42b};
- //============================================================
- // EDCA Paramter for AP/ADSL by Mingzhi 2011-11-22
- //============================================================
- #elif (DM_ODM_SUPPORT_TYPE &ODM_ADSL)
- enum qos_prio { BK, BE, VI, VO, VI_AG, VO_AG };
- static const struct ParaRecord rtl_ap_EDCA[] =
- {
- //ACM,AIFSN, ECWmin, ECWmax, TXOplimit
- {0, 7, 4, 10, 0}, //BK
- {0, 3, 4, 6, 0}, //BE
- {0, 1, 3, 4, 188}, //VI
- {0, 1, 2, 3, 102}, //VO
- {0, 1, 3, 4, 94}, //VI_AG
- {0, 1, 2, 3, 47}, //VO_AG
- };
- static const struct ParaRecord rtl_sta_EDCA[] =
- {
- //ACM,AIFSN, ECWmin, ECWmax, TXOplimit
- {0, 7, 4, 10, 0},
- {0, 3, 4, 10, 0},
- {0, 2, 3, 4, 188},
- {0, 2, 2, 3, 102},
- {0, 2, 3, 4, 94},
- {0, 2, 2, 3, 47},
- };
- #endif
- //============================================================
- // Global var
- //============================================================
- u4Byte OFDMSwingTable[OFDM_TABLE_SIZE_92D] = {
- 0x7f8001fe, // 0, +6.0dB
- 0x788001e2, // 1, +5.5dB
- 0x71c001c7, // 2, +5.0dB
- 0x6b8001ae, // 3, +4.5dB
- 0x65400195, // 4, +4.0dB
- 0x5fc0017f, // 5, +3.5dB
- 0x5a400169, // 6, +3.0dB
- 0x55400155, // 7, +2.5dB
- 0x50800142, // 8, +2.0dB
- 0x4c000130, // 9, +1.5dB
- 0x47c0011f, // 10, +1.0dB
- 0x43c0010f, // 11, +0.5dB
- 0x40000100, // 12, +0dB
- 0x3c8000f2, // 13, -0.5dB
- 0x390000e4, // 14, -1.0dB
- 0x35c000d7, // 15, -1.5dB
- 0x32c000cb, // 16, -2.0dB
- 0x300000c0, // 17, -2.5dB
- 0x2d4000b5, // 18, -3.0dB
- 0x2ac000ab, // 19, -3.5dB
- 0x288000a2, // 20, -4.0dB
- 0x26000098, // 21, -4.5dB
- 0x24000090, // 22, -5.0dB
- 0x22000088, // 23, -5.5dB
- 0x20000080, // 24, -6.0dB
- 0x1e400079, // 25, -6.5dB
- 0x1c800072, // 26, -7.0dB
- 0x1b00006c, // 27. -7.5dB
- 0x19800066, // 28, -8.0dB
- 0x18000060, // 29, -8.5dB
- 0x16c0005b, // 30, -9.0dB
- 0x15800056, // 31, -9.5dB
- 0x14400051, // 32, -10.0dB
- 0x1300004c, // 33, -10.5dB
- 0x12000048, // 34, -11.0dB
- 0x11000044, // 35, -11.5dB
- 0x10000040, // 36, -12.0dB
- };
- u1Byte CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = {
- {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, // 0, +0dB
- {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, // 1, -0.5dB
- {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 2, -1.0dB
- {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, // 3, -1.5dB
- {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 4, -2.0dB
- {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, // 5, -2.5dB
- {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 6, -3.0dB
- {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, // 7, -3.5dB
- {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 8, -4.0dB
- {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, // 9, -4.5dB
- {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 10, -5.0dB
- {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, // 11, -5.5dB
- {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 12, -6.0dB <== default
- {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, // 13, -6.5dB
- {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 14, -7.0dB
- {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, // 15, -7.5dB
- {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 16, -8.0dB
- {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, // 17, -8.5dB
- {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 18, -9.0dB
- {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 19, -9.5dB
- {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 20, -10.0dB
- {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 21, -10.5dB
- {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 22, -11.0dB
- {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, // 23, -11.5dB
- {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, // 24, -12.0dB
- {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, // 25, -12.5dB
- {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, // 26, -13.0dB
- {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, // 27, -13.5dB
- {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, // 28, -14.0dB
- {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, // 29, -14.5dB
- {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, // 30, -15.0dB
- {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, // 31, -15.5dB
- {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} // 32, -16.0dB
- };
- u1Byte CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = {
- {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, // 0, +0dB
- {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, // 1, -0.5dB
- {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 2, -1.0dB
- {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, // 3, -1.5dB
- {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 4, -2.0dB
- {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, // 5, -2.5dB
- {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 6, -3.0dB
- {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, // 7, -3.5dB
- {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 8, -4.0dB
- {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, // 9, -4.5dB
- {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 10, -5.0dB
- {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 11, -5.5dB
- {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 12, -6.0dB <== default
- {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, // 13, -6.5dB
- {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 14, -7.0dB
- {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 15, -7.5dB
- {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 16, -8.0dB
- {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 17, -8.5dB
- {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 18, -9.0dB
- {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 19, -9.5dB
- {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 20, -10.0dB
- {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, // 21, -10.5dB
- {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, // 22, -11.0dB
- {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 23, -11.5dB
- {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 24, -12.0dB
- {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, // 25, -12.5dB
- {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 26, -13.0dB
- {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 27, -13.5dB
- {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 28, -14.0dB
- {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 29, -14.5dB
- {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 30, -15.0dB
- {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 31, -15.5dB
- {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} // 32, -16.0dB
- };
- u4Byte OFDMSwingTable_New[OFDM_TABLE_SIZE_92D] = {
- 0x0b40002d, // 0, -15.0dB
- 0x0c000030, // 1, -14.5dB
- 0x0cc00033, // 2, -14.0dB
- 0x0d800036, // 3, -13.5dB
- 0x0e400039, // 4, -13.0dB
- 0x0f00003c, // 5, -12.5dB
- 0x10000040, // 6, -12.0dB
- 0x11000044, // 7, -11.5dB
- 0x12000048, // 8, -11.0dB
- 0x1300004c, // 9, -10.5dB
- 0x14400051, // 10, -10.0dB
- 0x15800056, // 11, -9.5dB
- 0x16c0005b, // 12, -9.0dB
- 0x18000060, // 13, -8.5dB
- 0x19800066, // 14, -8.0dB
- 0x1b00006c, // 15, -7.5dB
- 0x1c800072, // 16, -7.0dB
- 0x1e400079, // 17, -6.5dB
- 0x20000080, // 18, -6.0dB
- 0x22000088, // 19, -5.5dB
- 0x24000090, // 20, -5.0dB
- 0x26000098, // 21, -4.5dB
- 0x288000a2, // 22, -4.0dB
- 0x2ac000ab, // 23, -3.5dB
- 0x2d4000b5, // 24, -3.0dB
- 0x300000c0, // 25, -2.5dB
- 0x32c000cb, // 26, -2.0dB
- 0x35c000d7, // 27, -1.5dB
- 0x390000e4, // 28, -1.0dB
- 0x3c8000f2, // 29, -0.5dB
- 0x40000100, // 30, +0dB
- 0x43c0010f, // 31, +0.5dB
- 0x47c0011f, // 32, +1.0dB
- 0x4c000130, // 33, +1.5dB
- 0x50800142, // 34, +2.0dB
- 0x55400155, // 35, +2.5dB
- 0x5a400169, // 36, +3.0dB
- 0x5fc0017f, // 37, +3.5dB
- 0x65400195, // 38, +4.0dB
- 0x6b8001ae, // 39, +4.5dB
- 0x71c001c7, // 40, +5.0dB
- 0x788001e2, // 41, +5.5dB
- 0x7f8001fe // 42, +6.0dB
- };
- u1Byte CCKSwingTable_Ch1_Ch13_New[CCK_TABLE_SIZE][8] = {
- {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}, // 0, -16.0dB
- {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, // 1, -15.5dB
- {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, // 2, -15.0dB
- {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, // 3, -14.5dB
- {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, // 4, -14.0dB
- {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, // 5, -13.5dB
- {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, // 6, -13.0dB
- {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, // 7, -12.5dB
- {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, // 8, -12.0dB
- {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, // 9, -11.5dB
- {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 10, -11.0dB
- {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, // 11, -10.5dB
- {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 12, -10.0dB
- {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, // 13, -9.5dB
- {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, // 14, -9.0dB
- {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, // 15, -8.5dB
- {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, // 16, -8.0dB
- {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, // 17, -7.5dB
- {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, // 18, -7.0dB
- {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, // 19, -6.5dB
- {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, // 20, -6.0dB
- {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, // 21, -5.5dB
- {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, // 22, -5.0dB
- {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, // 23, -4.5dB
- {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, // 24, -4.0dB
- {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, // 25, -3.5dB
- {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, // 26, -3.0dB
- {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, // 27, -2.5dB
- {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, // 28, -2.0dB
- {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, // 29, -1.5dB
- {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, // 30, -1.0dB
- {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, // 31, -0.5dB
- {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04} // 32, +0dB
- };
- u1Byte CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8]= {
- {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, // 0, -16.0dB
- {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 1, -15.5dB
- {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, // 2, -15.0dB
- {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 3, -14.5dB
- {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, // 4, -14.0dB
- {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 5, -13.5dB
- {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, // 6, -13.0dB
- {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, // 7, -12.5dB
- {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 8, -12.0dB
- {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, // 9, -11.5dB
- {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, // 10, -11.0dB
- {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, // 11, -10.5dB
- {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 12, -10.0dB
- {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, // 13, -9.5dB
- {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 14, -9.0dB
- {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, // 15, -8.5dB
- {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 16, -8.0dB
- {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, // 17, -7.5dB
- {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, // 18, -7.0dB
- {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, // 19, -6.5dB
- {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 20, -6.0dB
- {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, // 21, -5.5dB
- {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, // 22, -5.0dB
- {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, // 23, -4.5dB
- {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, // 24, -4.0dB
- {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, // 25, -3.5dB
- {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, // 26, -3.0dB
- {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, // 27, -2.5dB
- {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, // 28, -2.0dB
- {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, // 29, -1.5dB
- {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, // 30, -1.0dB
- {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, // 31, -0.5dB
- {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00} // 32, +0dB
- };
- u4Byte TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] =
- {
- 0x081, // 0, -12.0dB
- 0x088, // 1, -11.5dB
- 0x090, // 2, -11.0dB
- 0x099, // 3, -10.5dB
- 0x0A2, // 4, -10.0dB
- 0x0AC, // 5, -9.5dB
- 0x0B6, // 6, -9.0dB
- 0x0C0, // 7, -8.5dB
- 0x0CC, // 8, -8.0dB
- 0x0D8, // 9, -7.5dB
- 0x0E5, // 10, -7.0dB
- 0x0F2, // 11, -6.5dB
- 0x101, // 12, -6.0dB
- 0x110, // 13, -5.5dB
- 0x120, // 14, -5.0dB
- 0x131, // 15, -4.5dB
- 0x143, // 16, -4.0dB
- 0x156, // 17, -3.5dB
- 0x16A, // 18, -3.0dB
- 0x180, // 19, -2.5dB
- 0x197, // 20, -2.0dB
- 0x1AF, // 21, -1.5dB
- 0x1C8, // 22, -1.0dB
- 0x1E3, // 23, -0.5dB
- 0x200, // 24, +0 dB
- 0x21E, // 25, +0.5dB
- 0x23E, // 26, +1.0dB
- 0x261, // 27, +1.5dB
- 0x285, // 28, +2.0dB
- 0x2AB, // 29, +2.5dB
- 0x2D3, // 30, +3.0dB
- 0x2FE, // 31, +3.5dB
- 0x32B, // 32, +4.0dB
- 0x35C, // 33, +4.5dB
- 0x38E, // 34, +5.0dB
- 0x3C4, // 35, +5.5dB
- 0x3FE // 36, +6.0dB
- };
- #ifdef AP_BUILD_WORKAROUND
- unsigned int TxPwrTrk_OFDM_SwingTbl[TxPwrTrk_OFDM_SwingTbl_Len] = {
- /* +6.0dB */ 0x7f8001fe,
- /* +5.5dB */ 0x788001e2,
- /* +5.0dB */ 0x71c001c7,
- /* +4.5dB */ 0x6b8001ae,
- /* +4.0dB */ 0x65400195,
- /* +3.5dB */ 0x5fc0017f,
- /* +3.0dB */ 0x5a400169,
- /* +2.5dB */ 0x55400155,
- /* +2.0dB */ 0x50800142,
- /* +1.5dB */ 0x4c000130,
- /* +1.0dB */ 0x47c0011f,
- /* +0.5dB */ 0x43c0010f,
- /* 0.0dB */ 0x40000100,
- /* -0.5dB */ 0x3c8000f2,
- /* -1.0dB */ 0x390000e4,
- /* -1.5dB */ 0x35c000d7,
- /* -2.0dB */ 0x32c000cb,
- /* -2.5dB */ 0x300000c0,
- /* -3.0dB */ 0x2d4000b5,
- /* -3.5dB */ 0x2ac000ab,
- /* -4.0dB */ 0x288000a2,
- /* -4.5dB */ 0x26000098,
- /* -5.0dB */ 0x24000090,
- /* -5.5dB */ 0x22000088,
- /* -6.0dB */ 0x20000080,
- /* -6.5dB */ 0x1a00006c,
- /* -7.0dB */ 0x1c800072,
- /* -7.5dB */ 0x18000060,
- /* -8.0dB */ 0x19800066,
- /* -8.5dB */ 0x15800056,
- /* -9.0dB */ 0x26c0005b,
- /* -9.5dB */ 0x14400051,
- /* -10.0dB */ 0x24400051,
- /* -10.5dB */ 0x1300004c,
- /* -11.0dB */ 0x12000048,
- /* -11.5dB */ 0x11000044,
- /* -12.0dB */ 0x10000040
- };
- #endif
- //============================================================
- // Local Function predefine.
- //============================================================
- //START------------COMMON INFO RELATED---------------//
- VOID
- odm_CommonInfoSelfInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_CommonInfoSelfUpdate(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_CmnInfoInit_Debug(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_CmnInfoHook_Debug(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_CmnInfoUpdate_Debug(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_BasicDbgMessage
- (
- IN PDM_ODM_T pDM_Odm
- );
- /*
- VOID
- odm_FindMinimumRSSI(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_IsLinked(
- IN PDM_ODM_T pDM_Odm
- );
- */
- //END------------COMMON INFO RELATED---------------//
- //START---------------DIG---------------------------//
- VOID
- odm_FalseAlarmCounterStatistics(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DIGInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DIG(
- IN PDM_ODM_T pDM_Odm
- );
- BOOLEAN
- odm_DigAbort(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_CCKPacketDetectionThresh(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_AdaptivityInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_Adaptivity(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte IGI
- );
- //END---------------DIG---------------------------//
- //START-------BB POWER SAVE-----------------------//
- VOID
- odm_DynamicBBPowerSavingInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicBBPowerSaving(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_1R_CCA(
- IN PDM_ODM_T pDM_Odm
- );
- //END---------BB POWER SAVE-----------------------//
- //START-----------------PSD-----------------------//
- #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN))
- //============================================================
- // Function predefine.
- //============================================================
- VOID odm_PathDiversityInit_92C( IN PADAPTER Adapter);
- VOID odm_2TPathDiversityInit_92C( IN PADAPTER Adapter);
- VOID odm_1TPathDiversityInit_92C( IN PADAPTER Adapter);
- BOOLEAN odm_IsConnected_92C(IN PADAPTER Adapter);
- VOID odm_PathDiversityAfterLink_92C( IN PADAPTER Adapter);
- VOID
- odm_CCKTXPathDiversityCallback(
- PRT_TIMER pTimer
- );
- VOID
- odm_CCKTXPathDiversityWorkItemCallback(
- IN PVOID pContext
- );
- VOID
- odm_PathDivChkAntSwitchCallback(
- PRT_TIMER pTimer
- );
- VOID
- odm_PathDivChkAntSwitchWorkitemCallback(
- IN PVOID pContext
- );
- VOID odm_SetRespPath_92C( IN PADAPTER Adapter, IN u1Byte DefaultRespPath);
- VOID odm_OFDMTXPathDiversity_92C( IN PADAPTER Adapter);
- VOID odm_CCKTXPathDiversity_92C( IN PADAPTER Adapter);
- VOID odm_ResetPathDiversity_92C( IN PADAPTER Adapter);
- //Start-------------------- RX High Power------------------------//
- VOID odm_RXHPInit( IN PDM_ODM_T pDM_Odm);
- VOID odm_RXHP( IN PDM_ODM_T pDM_Odm);
- VOID odm_Write_RXHP( IN PDM_ODM_T pDM_Odm);
- VOID odm_PSD_RXHP( IN PDM_ODM_T pDM_Odm);
- VOID odm_PSD_RXHPCallback( PRT_TIMER pTimer);
- VOID odm_PSD_RXHPWorkitemCallback( IN PVOID pContext);
- //End--------------------- RX High Power -----------------------//
- VOID odm_PathDivInit_92D( IN PDM_ODM_T pDM_Odm);
- VOID
- odm_SetRespPath_92C(
- IN PADAPTER Adapter,
- IN u1Byte DefaultRespPath
- );
- #endif
- //END-------------------PSD-----------------------//
- VOID
- odm_RefreshRateAdaptiveMaskMP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RefreshRateAdaptiveMaskCE(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RefreshRateAdaptiveMaskAPADSL(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicATCSwitch_init(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicATCSwitch(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_Write_CrystalCap(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte CrystalCap
- );
- VOID
- odm_DynamicTxPowerInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPowerRestorePowerIndex(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPowerNIC(
- IN PDM_ODM_T pDM_Odm
- );
- #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- VOID
- odm_DynamicTxPowerSavePowerIndex(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPowerWritePowerIndex(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Value);
- VOID
- odm_DynamicTxPower_92C(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPower_92D(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_MPT_DIGCallback(
- PRT_TIMER pTimer
- );
- VOID
- odm_MPT_DIGWorkItemCallback(
- IN PVOID pContext
- );
- #endif
- VOID
- odm_RSSIMonitorInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RSSIMonitorCheckMP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RSSIMonitorCheckCE(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RSSIMonitorCheckAP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RSSIMonitorCheck(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPower(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_DynamicTxPowerAP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_SwAntDivInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_SwAntDivInit_NIC(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_SwAntDivChkAntSwitch(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Step
- );
- VOID
- odm_SwAntDivChkAntSwitchNIC(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Step
- );
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_SwAntDivChkAntSwitchCallback(
- PRT_TIMER pTimer
- );
- VOID
- odm_SwAntDivChkAntSwitchWorkitemCallback(
- IN PVOID pContext
- );
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
- #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext);
- #endif
- VOID
- odm_GlobalAdapterCheck(
- IN VOID
- );
- VOID
- odm_RefreshBasicRateMask(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RefreshRateAdaptiveMask(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- ODM_TXPowerTrackingCheck(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_TXPowerTrackingCheckAP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_RateAdaptiveMaskInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_TXPowerTrackingThermalMeterInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_TXPowerTrackingInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_TXPowerTrackingCheckMP(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_TXPowerTrackingCheckCE(
- IN PDM_ODM_T pDM_Odm
- );
- #if(DM_ODM_SUPPORT_TYPE & (ODM_WIN))
- VOID
- ODM_RateAdaptiveStateApInit(
- IN PADAPTER Adapter ,
- IN PRT_WLAN_STA pEntry
- );
- VOID
- odm_TXPowerTrackingCallbackThermalMeter92C(
- IN PADAPTER Adapter
- );
- VOID
- odm_TXPowerTrackingCallbackRXGainThermalMeter92D(
- IN PADAPTER Adapter
- );
- VOID
- odm_TXPowerTrackingCallbackThermalMeter92D(
- IN PADAPTER Adapter
- );
- VOID
- odm_TXPowerTrackingDirectCall92C(
- IN PADAPTER Adapter
- );
- VOID
- odm_TXPowerTrackingThermalMeterCheck(
- IN PADAPTER Adapter
- );
- #endif
- VOID
- odm_EdcaTurboCheck(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- ODM_EdcaTurboInit(
- IN PDM_ODM_T pDM_Odm
- );
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- VOID
- odm_EdcaTurboCheckMP(
- IN PDM_ODM_T pDM_Odm
- );
- //check if edca turbo is disabled
- BOOLEAN
- odm_IsEdcaTurboDisable(
- IN PDM_ODM_T pDM_Odm
- );
- //choose edca paramter for special IOT case
- VOID
- ODM_EdcaParaSelByIot(
- IN PDM_ODM_T pDM_Odm,
- OUT u4Byte *EDCA_BE_UL,
- OUT u4Byte *EDCA_BE_DL
- );
- //check if it is UL or DL
- VOID
- odm_EdcaChooseTrafficIdx(
- IN PDM_ODM_T pDM_Odm,
- IN u8Byte cur_tx_bytes,
- IN u8Byte cur_rx_bytes,
- IN BOOLEAN bBiasOnRx,
- OUT BOOLEAN *pbIsCurRDLState
- );
- #elif (DM_ODM_SUPPORT_TYPE==ODM_CE)
- VOID
- odm_EdcaTurboCheckCE(
- IN PDM_ODM_T pDM_Odm
- );
- #else
- VOID
- odm_IotEngine(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_EdcaParaInit(
- IN PDM_ODM_T pDM_Odm
- );
- #endif
- #define RxDefaultAnt1 0x65a9
- #define RxDefaultAnt2 0x569a
- VOID
- odm_InitHybridAntDiv(
- IN PDM_ODM_T pDM_Odm
- );
- BOOLEAN
- odm_StaDefAntSel(
- IN PDM_ODM_T pDM_Odm,
- IN u4Byte OFDM_Ant1_Cnt,
- IN u4Byte OFDM_Ant2_Cnt,
- IN u4Byte CCK_Ant1_Cnt,
- IN u4Byte CCK_Ant2_Cnt,
- OUT u1Byte *pDefAnt
- );
- VOID
- odm_SetRxIdleAnt(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Ant,
- IN BOOLEAN bDualPath
- );
- VOID
- odm_HwAntDiv(
- IN PDM_ODM_T pDM_Odm
- );
- VOID odm_PathDiversityInit(IN PDM_ODM_T pDM_Odm);
- VOID odm_PathDiversity( IN PDM_ODM_T pDM_Odm);
- #if 0
- //#if ((DM_ODM_SUPPORT_TYPE==ODM_AP)&&defined(HW_ANT_SWITCH))
- VOID
- odm_HW_AntennaSwitchInit(
- IN PDM_ODM_T pDM_Odm
- );
- VOID
- odm_SetRxIdleAnt(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Ant
- );
- VOID
- odm_StaAntSelect(
- IN PDM_ODM_T pDM_Odm,
- IN struct stat_info *pstat
- );
- VOID
- odm_HW_IdleAntennaSelect(
- IN PDM_ODM_T pDM_Odm
- );
- u1Byte
- ODM_Diversity_AntennaSelect(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte *data
- );
- #endif
- //============================================================
- //3 Export Interface
- //============================================================
- //
- // 2011/09/21 MH Add to describe different team necessary resource allocate??
- //
- VOID
- ODM_DMInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //2012.05.03 Luke: For all IC series
- odm_CommonInfoSelfInit(pDM_Odm);
- odm_CmnInfoInit_Debug(pDM_Odm);
- odm_DIGInit(pDM_Odm);
- odm_AdaptivityInit(pDM_Odm);
- odm_RateAdaptiveMaskInit(pDM_Odm);
-
- #if (RTL8192E_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8192E)
- {
- odm_PrimaryCCA_Check_Init(pDM_Odm);
- }
- #endif
- //#if (MP_DRIVER != 1)
- if ( *(pDM_Odm->mp_mode) != 1)
- odm_PathDiversityInit(pDM_Odm);
- //#endif
- ODM_EdcaTurboInit(pDM_Odm);
- if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- {
- odm_TXPowerTrackingInit(pDM_Odm);
- //#if (MP_DRIVER != 1)
- if ( *(pDM_Odm->mp_mode) != 1)
- odm_InitHybridAntDiv(pDM_Odm);
- //#endif
- }
- else if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- {
- odm_DynamicBBPowerSavingInit(pDM_Odm);
- odm_DynamicTxPowerInit(pDM_Odm);
- odm_TXPowerTrackingInit(pDM_Odm);
- //ODM_EdcaTurboInit(pDM_Odm);
- //#if (MP_DRIVER != 1)
- if ( *(pDM_Odm->mp_mode) != 1) {
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- odm_SwAntDivInit(pDM_Odm);
- else if(pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D))
- {
- if(pDM_Odm->AntDivType == HW_ANTDIV)
- odm_InitHybridAntDiv(pDM_Odm);
- else
- odm_SwAntDivInit(pDM_Odm);
- }
- else
- odm_InitHybridAntDiv(pDM_Odm);
- }
- //#endif
- //2010.05.30 LukeLee: For CE platform, files in IC subfolders may not be included to be compiled,
- // so compile flags must be left here to prevent from compile errors
- #if (RTL8188E_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8188E)
- {
- odm_PrimaryCCA_Init(pDM_Odm); // Gary
- ODM_RAInfo_Init_all(pDM_Odm);
- }
- #endif
- //2010.05.30 LukeLee: Following are not incorporated into ODM structure yet.
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- if(pDM_Odm->SupportICType&ODM_RTL8723A)
- odm_PSDMonitorInit(pDM_Odm);
-
- if(!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8188E)))
- {
- odm_RXHPInit(pDM_Odm);
- }
- if(pDM_Odm->SupportICType==ODM_RTL8192D)
- {
- odm_PathDivInit_92D(pDM_Odm); //92D Path Div Init //Neil Chen
- }
- #endif
- }
- odm_DynamicATCSwitch_init(pDM_Odm);
- }
- //
- // 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM.
- // You can not add any dummy function here, be care, you can only use DM structure
- // to perform any new ODM_DM.
- //
- VOID
- ODM_DMWatchdog(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //odm_CmnInfoHook_Debug(pDM_Odm);
- //odm_CmnInfoUpdate_Debug(pDM_Odm);
- odm_CommonInfoSelfUpdate(pDM_Odm);
- odm_BasicDbgMessage(pDM_Odm);
- odm_FalseAlarmCounterStatistics(pDM_Odm);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): RSSI=0x%x\n",pDM_Odm->RSSI_Min));
- odm_RSSIMonitorCheck(pDM_Odm);
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- //#ifdef CONFIG_PLATFORM_SPRD
- //For CE Platform(SPRD or Tablet)
- //8723A or 8189ES platform
- //NeilChen--2012--08--24--
- //Fix Leave LPS issue
- if( (pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&// in LPS mode
- (
- (pDM_Odm->SupportICType & (ODM_RTL8723A ) )||
- (pDM_Odm->SupportICType & (ODM_RTL8188E) &&((pDM_Odm->SupportInterface == ODM_ITRF_SDIO)) )
- )
- )
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
- odm_DIGbyRSSI_LPS(pDM_Odm);
- }
- else
- //#endif
- #endif
- {
- odm_DIG(pDM_Odm);
- }
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue);
- }
- odm_CCKPacketDetectionThresh(pDM_Odm);
- if(*(pDM_Odm->pbPowerSaving)==TRUE)
- return;
-
- odm_RefreshRateAdaptiveMask(pDM_Odm);
- odm_RefreshBasicRateMask(pDM_Odm);
- odm_DynamicBBPowerSaving(pDM_Odm);
- odm_EdcaTurboCheck(pDM_Odm);
- odm_PathDiversity(pDM_Odm);
- odm_DynamicATCSwitch(pDM_Odm);
-
- #if 0
- #if (RTL8723B_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8723B)
- odm_DynamicPrimaryCCA_Check(pDM_Odm);
- #endif
- #endif
- #if (RTL8192E_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8192E)
- odm_DynamicPrimaryCCA_Check(pDM_Odm);
- #endif
- if(pDM_Odm->SupportICType == ODM_RTL8192E)
- return;
- //#if (MP_DRIVER != 1)
- if ( *(pDM_Odm->mp_mode) != 1) {
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK);
- }
- else if(pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D))
- {
- if(pDM_Odm->AntDivType == HW_ANTDIV)
- odm_HwAntDiv(pDM_Odm);
- else
- odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK);
- }
- else
- odm_HwAntDiv(pDM_Odm);
- }
- //#endif
- if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- {
- if (pDM_Odm->SupportICType & (ODM_RTL8812|ODM_RTL8821))
- //if (pDM_Odm->SupportICType & ODM_RTL8812)
- {
- ODM_TXPowerTrackingCheck(pDM_Odm);
- }
- #if (RTL8821A_SUPPORT == 1)
- if(pDM_Odm->SupportICType & ODM_RTL8821)
- {
- if(pDM_Odm->bLinked)
- {
- if((*pDM_Odm->pChannel != pDM_Odm->preChannel) && (!*pDM_Odm->pbScanInProcess))
- {
- pDM_Odm->preChannel = *pDM_Odm->pChannel;
- pDM_Odm->LinkedInterval = 0;
- }
- if(pDM_Odm->LinkedInterval < 3)
- pDM_Odm->LinkedInterval++;
-
- if(pDM_Odm->LinkedInterval == 2)
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
- //mark out IQK flow to prevent tx stuck. by Maddest 20130306
- //PHY_IQCalibrate_8821A(pAdapter, FALSE);
- }
- }
- else
- pDM_Odm->LinkedInterval = 0;
- }
- #endif
- }
- else if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- {
- if (!(pDM_Odm->SupportICType & (ODM_RTL8723B)))
- ODM_TXPowerTrackingCheck(pDM_Odm);
- //odm_EdcaTurboCheck(pDM_Odm);
- odm_DynamicTxPower(pDM_Odm);
- #if( DM_ODM_SUPPORT_TYPE & (ODM_WIN))
- if(!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8188E)))
- odm_RXHP(pDM_Odm);
- #endif
- //2010.05.30 LukeLee: For CE platform, files in IC subfolders may not be included to be compiled,
- // so compile flags must be left here to prevent from compile errors
- #if (RTL8192D_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8192D)
- ODM_DynamicEarlyMode(pDM_Odm);
- #endif
- odm_DynamicBBPowerSaving(pDM_Odm);
- #if (RTL8188E_SUPPORT == 1)
- if(pDM_Odm->SupportICType==ODM_RTL8188E)
- odm_DynamicPrimaryCCA(pDM_Odm);
- #endif
-
- }
- pDM_Odm->PhyDbgInfo.NumQryBeaconPkt = 0;
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- odm_dtc(pDM_Odm);
- #endif
- }
- //
- // Init /.. Fixed HW value. Only init time.
- //
- VOID
- ODM_CmnInfoInit(
- IN PDM_ODM_T pDM_Odm,
- IN ODM_CMNINFO_E CmnInfo,
- IN u4Byte Value
- )
- {
- //ODM_RT_TRACE(pDM_Odm,);
- //
- // This section is used for init value
- //
- switch (CmnInfo)
- {
- //
- // Fixed ODM value.
- //
- case ODM_CMNINFO_ABILITY:
- pDM_Odm->SupportAbility = (u4Byte)Value;
- break;
- case ODM_CMNINFO_RF_TYPE:
- pDM_Odm->RFType = (u1Byte)Value;
- break;
- case ODM_CMNINFO_PLATFORM:
- pDM_Odm->SupportPlatform = (u1Byte)Value;
- break;
- case ODM_CMNINFO_INTERFACE:
- pDM_Odm->SupportInterface = (u1Byte)Value;
- break;
- case ODM_CMNINFO_MP_TEST_CHIP:
- pDM_Odm->bIsMPChip= (u1Byte)Value;
- break;
-
- case ODM_CMNINFO_IC_TYPE:
- pDM_Odm->SupportICType = Value;
- break;
- case ODM_CMNINFO_CUT_VER:
- pDM_Odm->CutVersion = (u1Byte)Value;
- break;
- case ODM_CMNINFO_FAB_VER:
- pDM_Odm->FabVersion = (u1Byte)Value;
- break;
- case ODM_CMNINFO_RFE_TYPE:
- pDM_Odm->RFEType = (u1Byte)Value;
- break;
- case ODM_CMNINFO_RF_ANTENNA_TYPE:
- pDM_Odm->AntDivType= (u1Byte)Value;
- break;
- case ODM_CMNINFO_BOARD_TYPE:
- pDM_Odm->BoardType = (u1Byte)Value;
- break;
- case ODM_CMNINFO_EXT_LNA:
- pDM_Odm->ExtLNA = (u1Byte)Value;
- break;
- case ODM_CMNINFO_5G_EXT_LNA:
- pDM_Odm->ExtLNA5G = (u1Byte)Value;
- break;
- case ODM_CMNINFO_EXT_PA:
- pDM_Odm->ExtPA = (u1Byte)Value;
- break;
- case ODM_CMNINFO_5G_EXT_PA:
- pDM_Odm->ExtPA5G = (u1Byte)Value;
- break;
- case ODM_CMNINFO_EXT_TRSW:
- pDM_Odm->ExtTRSW = (u1Byte)Value;
- break;
- case ODM_CMNINFO_PATCH_ID:
- pDM_Odm->PatchID = (u1Byte)Value;
- break;
- case ODM_CMNINFO_BINHCT_TEST:
- pDM_Odm->bInHctTest = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_BWIFI_TEST:
- pDM_Odm->bWIFITest = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_SMART_CONCURRENT:
- pDM_Odm->bDualMacSmartConcurrent = (BOOLEAN )Value;
- break;
-
- //To remove the compiler warning, must add an empty default statement to handle the other values.
- default:
- //do nothing
- break;
-
- }
- }
- VOID
- ODM_CmnInfoHook(
- IN PDM_ODM_T pDM_Odm,
- IN ODM_CMNINFO_E CmnInfo,
- IN PVOID pValue
- )
- {
- //
- // Hook call by reference pointer.
- //
- switch (CmnInfo)
- {
- //
- // Dynamic call by reference pointer.
- //
- case ODM_CMNINFO_MAC_PHY_MODE:
- pDM_Odm->pMacPhyMode = (u1Byte *)pValue;
- break;
-
- case ODM_CMNINFO_TX_UNI:
- pDM_Odm->pNumTxBytesUnicast = (u8Byte *)pValue;
- break;
- case ODM_CMNINFO_RX_UNI:
- pDM_Odm->pNumRxBytesUnicast = (u8Byte *)pValue;
- break;
- case ODM_CMNINFO_WM_MODE:
- pDM_Odm->pWirelessMode = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_BAND:
- pDM_Odm->pBandType = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_SEC_CHNL_OFFSET:
- pDM_Odm->pSecChOffset = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_SEC_MODE:
- pDM_Odm->pSecurity = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_BW:
- pDM_Odm->pBandWidth = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_CHNL:
- pDM_Odm->pChannel = (u1Byte *)pValue;
- break;
-
- case ODM_CMNINFO_DMSP_GET_VALUE:
- pDM_Odm->pbGetValueFromOtherMac = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_BUDDY_ADAPTOR:
- pDM_Odm->pBuddyAdapter = (PADAPTER *)pValue;
- break;
- case ODM_CMNINFO_DMSP_IS_MASTER:
- pDM_Odm->pbMasterOfDMSP = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_SCAN:
- pDM_Odm->pbScanInProcess = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_POWER_SAVING:
- pDM_Odm->pbPowerSaving = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_ONE_PATH_CCA:
- pDM_Odm->pOnePathCCA = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_DRV_STOP:
- pDM_Odm->pbDriverStopped = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_PNP_IN:
- pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_INIT_ON:
- pDM_Odm->pinit_adpt_in_progress = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_ANT_TEST:
- pDM_Odm->pAntennaTest = (u1Byte *)pValue;
- break;
- case ODM_CMNINFO_NET_CLOSED:
- pDM_Odm->pbNet_closed = (BOOLEAN *)pValue;
- break;
- case ODM_CMNINFO_FORCED_RATE:
- pDM_Odm->pForcedDataRate = (pu2Byte)pValue;
- break;
- case ODM_CMNINFO_MP_MODE:
- pDM_Odm->mp_mode = (u1Byte *)pValue;
- break;
- //case ODM_CMNINFO_RTSTA_AID:
- // pDM_Odm->pAidMap = (u1Byte *)pValue;
- // break;
- //case ODM_CMNINFO_BT_COEXIST:
- // pDM_Odm->BTCoexist = (BOOLEAN *)pValue;
- //case ODM_CMNINFO_STA_STATUS:
- //pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue;
- //break;
- //case ODM_CMNINFO_PHY_STATUS:
- // pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue;
- // break;
- //case ODM_CMNINFO_MAC_STATUS:
- // pDM_Odm->pMacInfo = (ODM_MAC_INFO *)pValue;
- // break;
- //To remove the compiler warning, must add an empty default statement to handle the other values.
- default:
- //do nothing
- break;
- }
- }
- VOID
- ODM_CmnInfoPtrArrayHook(
- IN PDM_ODM_T pDM_Odm,
- IN ODM_CMNINFO_E CmnInfo,
- IN u2Byte Index,
- IN PVOID pValue
- )
- {
- //
- // Hook call by reference pointer.
- //
- switch (CmnInfo)
- {
- //
- // Dynamic call by reference pointer.
- //
- case ODM_CMNINFO_STA_STATUS:
- pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue;
- break;
- //To remove the compiler warning, must add an empty default statement to handle the other values.
- default:
- //do nothing
- break;
- }
-
- }
- //
- // Update Band/CHannel/.. The values are dynamic but non-per-packet.
- //
- VOID
- ODM_CmnInfoUpdate(
- IN PDM_ODM_T pDM_Odm,
- IN u4Byte CmnInfo,
- IN u8Byte Value
- )
- {
- //
- // This init variable may be changed in run time.
- //
- switch (CmnInfo)
- {
- case ODM_CMNINFO_LINK_IN_PROGRESS:
- pDM_Odm->bLinkInProcess = (BOOLEAN)Value;
- break;
-
- case ODM_CMNINFO_ABILITY:
- pDM_Odm->SupportAbility = (u4Byte)Value;
- break;
- case ODM_CMNINFO_RF_TYPE:
- pDM_Odm->RFType = (u1Byte)Value;
- break;
- case ODM_CMNINFO_WIFI_DIRECT:
- pDM_Odm->bWIFI_Direct = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_WIFI_DISPLAY:
- pDM_Odm->bWIFI_Display = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_LINK:
- pDM_Odm->bLinked = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_RSSI_MIN:
- pDM_Odm->RSSI_Min= (u1Byte)Value;
- break;
- case ODM_CMNINFO_DBG_COMP:
- pDM_Odm->DebugComponents = Value;
- break;
- case ODM_CMNINFO_DBG_LEVEL:
- pDM_Odm->DebugLevel = (u4Byte)Value;
- break;
- case ODM_CMNINFO_RA_THRESHOLD_HIGH:
- pDM_Odm->RateAdaptive.HighRSSIThresh = (u1Byte)Value;
- break;
- case ODM_CMNINFO_RA_THRESHOLD_LOW:
- pDM_Odm->RateAdaptive.LowRSSIThresh = (u1Byte)Value;
- break;
- // The following is for BT HS mode and BT coexist mechanism.
- case ODM_CMNINFO_BT_DISABLED:
- pDM_Odm->bBtDisabled = (BOOLEAN)Value;
- break;
-
- case ODM_CMNINFO_BT_HS_CONNECT_PROCESS:
- pDM_Odm->bBtConnectProcess = (BOOLEAN)Value;
- break;
-
- case ODM_CMNINFO_BT_HS_RSSI:
- pDM_Odm->btHsRssi = (u1Byte)Value;
- break;
-
- case ODM_CMNINFO_BT_OPERATION:
- pDM_Odm->bBtHsOperation = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_BT_LIMITED_DIG:
- pDM_Odm->bBtLimitedDig = (BOOLEAN)Value;
- break;
- case ODM_CMNINFO_BT_DISABLE_EDCA:
- pDM_Odm->bBtDisableEdcaTurbo = (BOOLEAN)Value;
- break;
-
- /*
- case ODM_CMNINFO_OP_MODE:
- pDM_Odm->OPMode = (u1Byte)Value;
- break;
- case ODM_CMNINFO_WM_MODE:
- pDM_Odm->WirelessMode = (u1Byte)Value;
- break;
- case ODM_CMNINFO_BAND:
- pDM_Odm->BandType = (u1Byte)Value;
- break;
- case ODM_CMNINFO_SEC_CHNL_OFFSET:
- pDM_Odm->SecChOffset = (u1Byte)Value;
- break;
- case ODM_CMNINFO_SEC_MODE:
- pDM_Odm->Security = (u1Byte)Value;
- break;
- case ODM_CMNINFO_BW:
- pDM_Odm->BandWidth = (u1Byte)Value;
- break;
- case ODM_CMNINFO_CHNL:
- pDM_Odm->Channel = (u1Byte)Value;
- break;
- */
- default:
- //do nothing
- break;
- }
-
- }
- VOID
- odm_CommonInfoSelfInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pDM_Odm->bCckHighPower = (BOOLEAN) ODM_GetBBReg(pDM_Odm, ODM_REG(CCK_RPT_FORMAT,pDM_Odm), ODM_BIT(CCK_RPT_FORMAT,pDM_Odm));
- pDM_Odm->RFPathRxEnable = (u1Byte) ODM_GetBBReg(pDM_Odm, ODM_REG(BB_RX_PATH,pDM_Odm), ODM_BIT(BB_RX_PATH,pDM_Odm));
- #if (DM_ODM_SUPPORT_TYPE != ODM_CE)
- pDM_Odm->pbNet_closed = &pDM_Odm->BOOLEAN_temp;
- #endif
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- pDM_Odm->AntDivType = SW_ANTDIV;
- }
- else if(pDM_Odm->SupportICType==ODM_RTL8723B)
- {
- //pDM_Odm->AntDivType = S0S1_HW_ANTDIV;
- pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV;
- }
-
- else if(pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D))
- {
- #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- pDM_Odm->AntDivType = HW_ANTDIV;
- #elif (defined(CONFIG_SW_ANTENNA_DIVERSITY))
- pDM_Odm->AntDivType = SW_ANTDIV;
- #endif
- }
- pDM_Odm->TxRate = 0xFF;
- ODM_InitDebugSetting(pDM_Odm);
- }
- VOID
- odm_CommonInfoSelfUpdate(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u1Byte EntryCnt=0;
- u1Byte i;
- PSTA_INFO_T pEntry;
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- pEntry = pDM_Odm->pODM_StaInfo[0];
- if(pMgntInfo->mAssoc)
- {
- pEntry->bUsed=TRUE;
- for (i=0; i<6; i++)
- pEntry->MacAddr[i] = pMgntInfo->Bssid[i];
- }
- else
- {
- pEntry->bUsed=FALSE;
- for (i=0; i<6; i++)
- pEntry->MacAddr[i] = 0;
- }
- #endif
- if(*(pDM_Odm->pBandWidth) == ODM_BW40M)
- {
- if(*(pDM_Odm->pSecChOffset) == 1)
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) -2;
- else if(*(pDM_Odm->pSecChOffset) == 2)
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) +2;
- }
- else
- pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
- for (i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- pEntry = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pEntry))
- EntryCnt++;
- }
- if(EntryCnt == 1)
- pDM_Odm->bOneEntryOnly = TRUE;
- else
- pDM_Odm->bOneEntryOnly = FALSE;
- }
- VOID
- odm_CmnInfoInit_Debug(
- IN PDM_ODM_T pDM_Odm
- )
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug==>\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform=%d\n",pDM_Odm->SupportPlatform) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility=0x%x\n",pDM_Odm->SupportAbility) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface=%d\n",pDM_Odm->SupportInterface) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType=0x%x\n",pDM_Odm->SupportICType) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion=%d\n",pDM_Odm->CutVersion) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion=%d\n",pDM_Odm->FabVersion) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType=%d\n",pDM_Odm->RFType) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType=%d\n",pDM_Odm->BoardType) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA=%d\n",pDM_Odm->ExtLNA) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA=%d\n",pDM_Odm->ExtPA) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW=%d\n",pDM_Odm->ExtTRSW) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID=%d\n",pDM_Odm->PatchID) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest=%d\n",pDM_Odm->bInHctTest) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest=%d\n",pDM_Odm->bWIFITest) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent=%d\n",pDM_Odm->bDualMacSmartConcurrent) );
- }
- VOID
- odm_CmnInfoHook_Debug(
- IN PDM_ODM_T pDM_Odm
- )
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoHook_Debug==>\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumTxBytesUnicast=%llu\n",*(pDM_Odm->pNumTxBytesUnicast)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumRxBytesUnicast=%llu\n",*(pDM_Odm->pNumRxBytesUnicast)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pWirelessMode=0x%x\n",*(pDM_Odm->pWirelessMode)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecChOffset=%d\n",*(pDM_Odm->pSecChOffset)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecurity=%d\n",*(pDM_Odm->pSecurity)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandWidth=%d\n",*(pDM_Odm->pBandWidth)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pChannel=%d\n",*(pDM_Odm->pChannel)) );
- if(pDM_Odm->SupportICType==ODM_RTL8192D)
- {
- if(pDM_Odm->pBandType)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandType=%d\n",*(pDM_Odm->pBandType)) );
- if(pDM_Odm->pMacPhyMode)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pMacPhyMode=%d\n",*(pDM_Odm->pMacPhyMode)) );
- if(pDM_Odm->pBuddyAdapter)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbGetValueFromOtherMac=%d\n",*(pDM_Odm->pbGetValueFromOtherMac)) );
- if(pDM_Odm->pBuddyAdapter)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBuddyAdapter=%p\n",*(pDM_Odm->pBuddyAdapter)) );
- if(pDM_Odm->pbMasterOfDMSP)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbMasterOfDMSP=%d\n",*(pDM_Odm->pbMasterOfDMSP)) );
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess=%d\n",*(pDM_Odm->pbScanInProcess)) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving=%d\n",*(pDM_Odm->pbPowerSaving)) );
- if(pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL))
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("pOnePathCCA=%d\n",*(pDM_Odm->pOnePathCCA)) );
- }
- VOID
- odm_CmnInfoUpdate_Debug(
- IN PDM_ODM_T pDM_Odm
- )
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug==>\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Direct=%d\n",pDM_Odm->bWIFI_Direct) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Display=%d\n",pDM_Odm->bWIFI_Display) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked=%d\n",pDM_Odm->bLinked) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min=%d\n",pDM_Odm->RSSI_Min) );
- }
- VOID
- odm_BasicDbgMessage
- (
- IN PDM_ODM_T pDM_Odm
- )
- {
- PFALSE_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg==>\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d, CurrentIGI = 0x%x \n",
- pDM_Odm->bLinked, pDM_Odm->RSSI_Min, pDM_DigTable->CurIGValue) );
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("Cnt_Cck_fail = %d, Cnt_Ofdm_fail = %d, Total False Alarm = %d\n",
- FalseAlmCnt->Cnt_Cck_fail, FalseAlmCnt->Cnt_Ofdm_fail, FalseAlmCnt->Cnt_all));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_COMMON, ODM_DBG_LOUD, ("RxRate = 0x%x, RSSI_A = %d, RSSI_B = %d\n",
- pDM_Odm->RxRate, pDM_Odm->RSSI_A, pDM_Odm->RSSI_B));
- }
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- ODM_InitAllWorkItems(IN PDM_ODM_T pDM_Odm )
- {
- #if USE_WORKITEM
- PADAPTER pAdapter = pDM_Odm->Adapter;
- ODM_InitializeWorkItem( pDM_Odm,
- &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchWorkitem,
- (RT_WORKITEM_CALL_BACK)odm_SwAntDivChkAntSwitchWorkitemCallback,
- (PVOID)pAdapter,
- "AntennaSwitchWorkitem"
- );
- ODM_InitializeWorkItem(
- pDM_Odm,
- &(pDM_Odm->PathDivSwitchWorkitem),
- (RT_WORKITEM_CALL_BACK)odm_PathDivChkAntSwitchWorkitemCallback,
- (PVOID)pAdapter,
- "SWAS_WorkItem");
- ODM_InitializeWorkItem(
- pDM_Odm,
- &(pDM_Odm->CCKPathDiversityWorkitem),
- (RT_WORKITEM_CALL_BACK)odm_CCKTXPathDiversityWorkItemCallback,
- (PVOID)pAdapter,
- "CCKTXPathDiversityWorkItem");
- ODM_InitializeWorkItem(
- pDM_Odm,
- &(pDM_Odm->MPT_DIGWorkitem),
- (RT_WORKITEM_CALL_BACK)odm_MPT_DIGWorkItemCallback,
- (PVOID)pAdapter,
- "MPT_DIGWorkitem");
-
- #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- #if (RTL8188E_SUPPORT == 1)
- ODM_InitializeWorkItem(
- pDM_Odm,
- &(pDM_Odm->FastAntTrainingWorkitem),
- (RT_WORKITEM_CALL_BACK)odm_FastAntTrainingWorkItemCallback,
- (PVOID)pAdapter,
- "FastAntTrainingWorkitem");
- #endif
- #endif
- ODM_InitializeWorkItem(
- pDM_Odm,
- &(pDM_Odm->DM_RXHP_Table.PSDTimeWorkitem),
- (RT_WORKITEM_CALL_BACK)odm_PSD_RXHPWorkitemCallback,
- (PVOID)pAdapter,
- "PSDRXHP_WorkItem");
- #endif
- }
- VOID
- ODM_FreeAllWorkItems(IN PDM_ODM_T pDM_Odm )
- {
- #if USE_WORKITEM
- ODM_FreeWorkItem( &(pDM_Odm->DM_SWAT_Table.SwAntennaSwitchWorkitem));
- ODM_FreeWorkItem(&(pDM_Odm->PathDivSwitchWorkitem));
- ODM_FreeWorkItem(&(pDM_Odm->CCKPathDiversityWorkitem));
-
- ODM_FreeWorkItem(&(pDM_Odm->FastAntTrainingWorkitem));
- ODM_FreeWorkItem(&(pDM_Odm->MPT_DIGWorkitem));
- ODM_FreeWorkItem((&pDM_Odm->DM_RXHP_Table.PSDTimeWorkitem));
- #endif
- }
- #endif
- /*
- VOID
- odm_FindMinimumRSSI(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u4Byte i;
- u1Byte RSSI_Min = 0xFF;
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- // if(pDM_Odm->pODM_StaInfo[i] != NULL)
- if(IS_STA_VALID(pDM_Odm->pODM_StaInfo[i]) )
- {
- if(pDM_Odm->pODM_StaInfo[i]->RSSI_Ave < RSSI_Min)
- {
- RSSI_Min = pDM_Odm->pODM_StaInfo[i]->RSSI_Ave;
- }
- }
- }
- pDM_Odm->RSSI_Min = RSSI_Min;
- }
- VOID
- odm_IsLinked(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u4Byte i;
- BOOLEAN Linked = FALSE;
-
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IS_STA_VALID(pDM_Odm->pODM_StaInfo[i]) )
- {
- Linked = TRUE;
- break;
- }
-
- }
- pDM_Odm->bLinked = Linked;
- }
- */
- //3============================================================
- //3 DIG
- //3============================================================
- /*-----------------------------------------------------------------------------
- * Function: odm_DIGInit()
- *
- * Overview: Set DIG scheme init value.
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- *
- *---------------------------------------------------------------------------*/
- VOID
- ODM_ChangeDynamicInitGainThresh(
- IN PDM_ODM_T pDM_Odm,
- IN u4Byte DM_Type,
- IN u4Byte DM_Value
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- if (DM_Type == DIG_TYPE_THRESH_HIGH)
- {
- pDM_DigTable->RssiHighThresh = DM_Value;
- }
- else if (DM_Type == DIG_TYPE_THRESH_LOW)
- {
- pDM_DigTable->RssiLowThresh = DM_Value;
- }
- else if (DM_Type == DIG_TYPE_ENABLE)
- {
- pDM_DigTable->Dig_Enable_Flag = TRUE;
- }
- else if (DM_Type == DIG_TYPE_DISABLE)
- {
- pDM_DigTable->Dig_Enable_Flag = FALSE;
- }
- else if (DM_Type == DIG_TYPE_BACKOFF)
- {
- if(DM_Value > 30)
- DM_Value = 30;
- pDM_DigTable->BackoffVal = (u1Byte)DM_Value;
- }
- else if(DM_Type == DIG_TYPE_RX_GAIN_MIN)
- {
- if(DM_Value == 0)
- DM_Value = 0x1;
- pDM_DigTable->rx_gain_range_min = (u1Byte)DM_Value;
- }
- else if(DM_Type == DIG_TYPE_RX_GAIN_MAX)
- {
- if(DM_Value > 0x50)
- DM_Value = 0x50;
- pDM_DigTable->rx_gain_range_max = (u1Byte)DM_Value;
- }
- } /* DM_ChangeDynamicInitGainThresh */
- int getIGIForDiff(int value_IGI)
- {
- #define ONERCCA_LOW_TH 0x30
- #define ONERCCA_LOW_DIFF 8
- if (value_IGI < ONERCCA_LOW_TH) {
- if ((ONERCCA_LOW_TH - value_IGI) < ONERCCA_LOW_DIFF)
- return ONERCCA_LOW_TH;
- else
- return value_IGI + ONERCCA_LOW_DIFF;
- } else {
- return value_IGI;
- }
- }
- VOID
- odm_AdaptivityInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
- if(IS_HARDWARE_TYPE_8723B(pAdapter))
- {
- pDM_Odm->TH_H = 0xf8; //-8dB
- pDM_Odm->TH_L = 0xfb; //-5dB
- }
- else if(IS_HARDWARE_TYPE_8192EE(pAdapter))
- {
- pDM_Odm->TH_H = 0xf0; //-16dB
- pDM_Odm->TH_L = 0xf3; //-13dB
- }
- else
- {
- pDM_Odm->TH_H = 0xfa; //-6dB
- pDM_Odm->TH_L = 0xfd; //-3dB
- }
-
- pDM_Odm->IGI_Base = 0x32;
- pDM_Odm->IGI_target = 0x1c;
- pDM_Odm->ForceEDCCA = 0;
- pDM_Odm->AdapEn_RSSI = 32;//45;
- }
- // Add by Neil Chen to enable edcca to MP Platform
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_EnableEDCCA(
- IN PDM_ODM_T pDM_Odm
- )
- {
- // This should be moved out of OUTSRC
- PADAPTER pAdapter = pDM_Odm->Adapter;
- // Enable EDCCA. The value is suggested by SD3 Wilson.
- //
- // Revised for ASUS 11b/g performance issues, suggested by BB Neil, 2012.04.13.
- //
- if((pDM_Odm->SupportICType == ODM_RTL8723A)&&(IS_WIRELESS_MODE_G(pAdapter)))
- {
- //PlatformEFIOWrite1Byte(Adapter, rOFDM0_ECCAThreshold, 0x00);
- ODM_Write1Byte(pDM_Odm,rOFDM0_ECCAThreshold,0x00);
- ODM_Write1Byte(pDM_Odm,rOFDM0_ECCAThreshold+2,0xFD);
-
- }
- else
- {
- //PlatformEFIOWrite1Byte(Adapter, rOFDM0_ECCAThreshold, 0x03);
- ODM_Write1Byte(pDM_Odm,rOFDM0_ECCAThreshold,0x03);
- ODM_Write1Byte(pDM_Odm,rOFDM0_ECCAThreshold+2,0x00);
- }
-
- //PlatformEFIOWrite1Byte(Adapter, rOFDM0_ECCAThreshold+2, 0x00);
- }
- VOID
- odm_DisableEDCCA(
- IN PDM_ODM_T pDM_Odm
- )
- {
- // Disable EDCCA..
- ODM_Write1Byte(pDM_Odm, rOFDM0_ECCAThreshold, 0x7f);
- ODM_Write1Byte(pDM_Odm, rOFDM0_ECCAThreshold+2, 0x7f);
- }
- //
- // Description: According to initial gain value to determine to enable or disable EDCCA.
- //
- // Suggested by SD3 Wilson. Added by tynli. 2011.11.25.
- //
- VOID
- odm_DynamicEDCCA(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- u1Byte RegC50, RegC58;
- BOOLEAN bFwCurrentInPSMode=FALSE;
- pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_FW_PSMODE_STATUS, (pu1Byte)(&bFwCurrentInPSMode));
- // Disable EDCCA mode while under LPS mode, added by Roger, 2012.09.14.
- if(bFwCurrentInPSMode)
- return;
-
- RegC50 = (u1Byte)ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskByte0);
- RegC58 = (u1Byte)ODM_GetBBReg(pDM_Odm, rOFDM0_XBAGCCore1, bMaskByte0);
- if((RegC50 > 0x28 && RegC58 > 0x28) ||
- ((pDM_Odm->SupportICType == ODM_RTL8723A && IS_WIRELESS_MODE_G(pAdapter) && RegC50>0x26)) ||
- (pDM_Odm->SupportICType == ODM_RTL8188E && RegC50 > 0x28))
- {
- if(!pHalData->bPreEdccaEnable)
- {
- odm_EnableEDCCA(pDM_Odm);
- pHalData->bPreEdccaEnable = TRUE;
- }
-
- }
- else if((RegC50 < 0x25 && RegC58 < 0x25) || (pDM_Odm->SupportICType == ODM_RTL8188E && RegC50 < 0x25))
- {
- if(pHalData->bPreEdccaEnable)
- {
- odm_DisableEDCCA(pDM_Odm);
- pHalData->bPreEdccaEnable = FALSE;
- }
- }
- }
- #endif // end MP platform support
- VOID
- odm_DynamicATCSwitch_init(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
-
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN )
- pDM_Odm->CrystalCap = pHalData->CrystalCap;
- pDM_Odm->bATCStatus = (u1Byte)ODM_GetBBReg(pDM_Odm, rOFDM1_CFOTracking, BIT11);
- pDM_Odm->CFOThreshold = CFO_Threshold_Xtal;
- #endif
- }
- VOID
- odm_DynamicATCSwitch(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u1Byte CrystalCap,ATC_status_temp = 0;
- u4Byte packet_count;
- int CFO_kHz_A,CFO_kHz_B,CFO_ave = 0, Adjust_Xtal = 0;
- int CFO_ave_diff;
-
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN )
- if(!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_ATC))
- return;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("=========> odm_DynamicATCSwitch()\n"));
- //2 No link!
- //
- if(!pDM_Odm->bLinked)
- {
- //3
- //3 1.Enable ATC
- if(pDM_Odm->bATCStatus == ATC_Status_Off)
- {
- if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- ODM_SetBBReg(pDM_Odm, rOFDM1_CFOTracking, BIT11, ATC_Status_On);
-
- if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- ODM_SetBBReg(pDM_Odm, rFc_area_Jaguar, BIT14, ATC_Status_On);
-
- pDM_Odm->bATCStatus = ATC_Status_On;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): No link!!\n"));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): ATCStatus = %d\n", pDM_Odm->bATCStatus));
- //3 2.Disable CFO tracking for BT
- if(!pDM_Odm->bBtDisabled)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Disable CFO tracking for BT!!\n"));
- return;
- }
- //3 3.Reset Crystal Cap.
- if(pDM_Odm->CrystalCap != pHalData->CrystalCap)
- {
- pDM_Odm->CrystalCap = pHalData->CrystalCap;
- CrystalCap = pDM_Odm->CrystalCap & 0x3f;
- odm_Write_CrystalCap(pDM_Odm,CrystalCap);
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): CrystalCap = 0x%x\n", pDM_Odm->CrystalCap));
-
- }
- else
- {
- //2 Initialization
- //
- //3 1. Calculate CFO for path-A & path-B
- CFO_kHz_A = (int)(pDM_Odm->CFO_tail[0] * 3125) / 1280;
- CFO_kHz_B = (int)(pDM_Odm->CFO_tail[1] * 3125) / 1280;
- packet_count = pDM_Odm->packetCount;
-
- //3 2.No new packet
- if(packet_count == pDM_Odm->packetCount_pre)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): packet counter doesn't change\n"));
- return;
- }
- pDM_Odm->packetCount_pre = packet_count;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): packet counter = %d\n", pDM_Odm->packetCount));
-
- //3 3.Average CFO
- if(pDM_Odm->RFType == ODM_1T1R)
- CFO_ave = CFO_kHz_A;
- else
- CFO_ave = (int)(CFO_kHz_A + CFO_kHz_B) >> 1;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): CFO_kHz_A = %dkHz, CFO_kHz_B = %dkHz, CFO_ave = %dkHz\n",
- CFO_kHz_A, CFO_kHz_B, CFO_ave));
- //3 4.Avoid abnormal large CFO
- CFO_ave_diff = (pDM_Odm->CFO_ave_pre >= CFO_ave)?(pDM_Odm->CFO_ave_pre - CFO_ave):(CFO_ave - pDM_Odm->CFO_ave_pre);
- if(CFO_ave_diff > 20 && pDM_Odm->largeCFOHit == 0)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): first large CFO hit\n"));
- pDM_Odm->largeCFOHit = 1;
- return;
- }
- else
- pDM_Odm->largeCFOHit = 0;
- pDM_Odm->CFO_ave_pre = CFO_ave;
- //2 CFO tracking by adjusting Xtal cap.
- //
- if (pDM_Odm->bBtDisabled)
- {
- //3 1.Dynamic Xtal threshold
- if(CFO_ave >= -pDM_Odm->CFOThreshold && CFO_ave <= pDM_Odm->CFOThreshold && pDM_Odm->bIsfreeze == 0)
- {
- if (pDM_Odm->CFOThreshold == CFO_Threshold_Xtal)
- {
- pDM_Odm->CFOThreshold = CFO_Threshold_Xtal + 10;
- pDM_Odm->bIsfreeze = 1;
- }
- else
- pDM_Odm->CFOThreshold = CFO_Threshold_Xtal;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Dynamic threshold = %d\n", pDM_Odm->CFOThreshold));
-
- //3 2.Calculate Xtal offset
- if(CFO_ave > pDM_Odm->CFOThreshold && pDM_Odm->CrystalCap < 0x3f)
- Adjust_Xtal = ((CFO_ave - CFO_Threshold_Xtal) >> 2) + 1;
- else if(CFO_ave < (-pDM_Odm->CFOThreshold) && pDM_Odm->CrystalCap > 0)
- Adjust_Xtal = ((CFO_ave + CFO_Threshold_Xtal) >> 2) - 1;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Crystal cap = 0x%x, Crystal cap offset = %d\n", pDM_Odm->CrystalCap, Adjust_Xtal));
- //3 3.Adjudt Crystal Cap.
- if(Adjust_Xtal != 0)
- {
- pDM_Odm->bIsfreeze = 0;
- pDM_Odm->CrystalCap = pDM_Odm->CrystalCap + Adjust_Xtal;
- if(pDM_Odm->CrystalCap > 0x3f)
- pDM_Odm->CrystalCap = 0x3f;
- else if (pDM_Odm->CrystalCap < 0)
- pDM_Odm->CrystalCap = 0;
- CrystalCap = pDM_Odm->CrystalCap & 0x3f;
- odm_Write_CrystalCap(pDM_Odm,CrystalCap);
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): New crystal cap = 0x%x \n", pDM_Odm->CrystalCap));
- }
- }
- else if(pDM_Odm->CrystalCap != pHalData->CrystalCap)
- {
- //3 Reset Xtal Cap when BT is enable
- pDM_Odm->CrystalCap = pHalData->CrystalCap;
- CrystalCap = pDM_Odm->CrystalCap & 0x3f;
- odm_Write_CrystalCap(pDM_Odm,CrystalCap);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Disable CFO tracking for BT!!\n"));
- }
- else
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Disable CFO tracking for BT!!\n"));
- if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES){
- //2 Dynamic ATC switch
- //
- //3 1.Enable ATC when CFO is larger then 80kHz
- if(CFO_ave < CFO_Threshold_ATC && CFO_ave > -CFO_Threshold_ATC)
- {
- if(pDM_Odm->bATCStatus == ATC_Status_On)
- {
- ODM_SetBBReg(pDM_Odm, rOFDM1_CFOTracking, BIT11, ATC_Status_Off);
- pDM_Odm->bATCStatus = ATC_Status_Off;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Disable ATC!!\n"));
- }
- else
- {
- if(pDM_Odm->bATCStatus == ATC_Status_Off)
- {
- ODM_SetBBReg(pDM_Odm, rOFDM1_CFOTracking, BIT11, ATC_Status_On);
- pDM_Odm->bATCStatus = ATC_Status_On;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD, ("odm_DynamicATCSwitch(): Enable ATC!!\n"));
- }
- }
- }
- #endif
- }
- VOID
- odm_Write_CrystalCap(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte CrystalCap
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- if(IS_HARDWARE_TYPE_8192D(Adapter))
- {
- PHY_SetBBReg(Adapter, 0x24, 0xF0, CrystalCap & 0x0F);
- PHY_SetBBReg(Adapter, 0x28, 0xF0000000, ((CrystalCap & 0xF0) >> 4));
- }
- if(IS_HARDWARE_TYPE_8188E(Adapter))
- {
- // write 0x24[16:11] = 0x24[22:17] = CrystalCap
- PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6)));
- }
-
- if(IS_HARDWARE_TYPE_8812(Adapter))
- {
- // write 0x2C[30:25] = 0x2C[24:19] = CrystalCap
- CrystalCap = CrystalCap & 0x3F;
- PHY_SetBBReg(Adapter, REG_MAC_PHY_CTRL, 0x7FF80000, (CrystalCap | (CrystalCap << 6)));
- }
-
- //only for B-cut
- if ((IS_HARDWARE_TYPE_8723A(Adapter) && pHalData->EEPROMVersion >= 0x01) ||
- IS_HARDWARE_TYPE_8723B(Adapter) ||IS_HARDWARE_TYPE_8192E(Adapter) || IS_HARDWARE_TYPE_8821(Adapter))
- {
- // 0x2C[23:18] = 0x2C[17:12] = CrystalCap
- CrystalCap = CrystalCap & 0x3F;
- PHY_SetBBReg(Adapter, REG_MAC_PHY_CTRL, 0xFFF000, (CrystalCap | (CrystalCap << 6)));
- }
-
- if(IS_HARDWARE_TYPE_8723AE(Adapter))
- PHY_SetBBReg(Adapter, REG_LDOA15_CTRL, bMaskDWord, 0x01572505);
- }
- VOID
- odm_Adaptivity(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte IGI
- )
- {
- s4Byte TH_H_dmc, TH_L_dmc;
- s4Byte TH_H, TH_L, Diff, IGI_target;
- u4Byte value32;
- BOOLEAN EDCCA_State;
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER pAdapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- BOOLEAN bFwCurrentInPSMode=FALSE;
- PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo);
-
- pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_FW_PSMODE_STATUS, (pu1Byte)(&bFwCurrentInPSMode));
- // Disable EDCCA mode while under LPS mode, added by Roger, 2012.09.14.
- if(bFwCurrentInPSMode)
- return;
- #endif
- if(!(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY))
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("Go to odm_DynamicEDCCA() \n"));
- // Add by Neil Chen to enable edcca to MP Platform
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- // Adjust EDCCA.
- if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- odm_DynamicEDCCA(pDM_Odm);
- #endif
- return;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_Adaptivity() =====> \n"));
- if(pDM_Odm->bForceThresh)
- {
- pDM_Odm->TH_H = pDM_Odm->Force_TH_H;
- pDM_Odm->TH_L = pDM_Odm->Force_TH_L;
- }
- else
- {
- if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- {
- if(*pDM_Odm->pBandType == BAND_ON_5G)
- {
- pDM_Odm->TH_H = 0xf4;//0xf8;
- pDM_Odm->TH_L = 0xf7;//0xfb;
- }
- else
- {
- pDM_Odm->TH_H = 0xf4;//0xfa;
- pDM_Odm->TH_L = 0xf7;//0xfd;
- }
- }
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("pDM_Odm->ForceEDCCA=%d, IGI_Base=0x%x, TH_H=0x%x, TH_L=0x%x, AdapEn_RSSI = %d\n",
- pDM_Odm->ForceEDCCA, pDM_Odm->IGI_Base, pDM_Odm->TH_H, pDM_Odm->TH_L, pDM_Odm->AdapEn_RSSI));
- if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- ODM_SetBBReg(pDM_Odm, 0x800, BIT10, 0); //ADC_mask enable
-
- if(!pDM_Odm->bLinked)
- {
- return;
- }
- if(!pDM_Odm->ForceEDCCA)
- {
- if(pDM_Odm->RSSI_Min > pDM_Odm->AdapEn_RSSI)
- EDCCA_State = 1;
- else if(pDM_Odm->RSSI_Min < (pDM_Odm->AdapEn_RSSI - 5))
- EDCCA_State = 0;
- }
- else
- EDCCA_State = 1;
- //if((pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) && (*pDM_Odm->pBandType == BAND_ON_5G))
- //IGI_target = pDM_Odm->IGI_Base;
- //else
- {
- if(*pDM_Odm->pBandWidth == ODM_BW20M) //CHANNEL_WIDTH_20
- IGI_target = pDM_Odm->IGI_Base;
- else if(*pDM_Odm->pBandWidth == ODM_BW40M)
- IGI_target = pDM_Odm->IGI_Base + 2;
- else if(*pDM_Odm->pBandWidth == ODM_BW80M)
- IGI_target = pDM_Odm->IGI_Base + 6;
- else
- IGI_target = pDM_Odm->IGI_Base;
- }
- pDM_Odm->IGI_target = IGI_target;
- if(pDM_Odm->TH_H & BIT7)
- TH_H = pDM_Odm->TH_H | 0xFFFFFF00;
- else
- TH_H = pDM_Odm->TH_H;
- if(pDM_Odm->TH_L & BIT7)
- TH_L = pDM_Odm->TH_L | 0xFFFFFF00;
- else
- TH_L = pDM_Odm->TH_L;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("BandWidth=%s, IGI_target=0x%x, EDCCA_State=%d\n",
- (*pDM_Odm->pBandWidth==ODM_BW80M)?"80M":((*pDM_Odm->pBandWidth==ODM_BW40M)?"40M":"20M"), IGI_target, EDCCA_State));
- if(EDCCA_State == 1)
- {
- if(IGI < IGI_target)
- {
- Diff = IGI_target -(s4Byte)IGI;
- TH_H_dmc = TH_H + Diff;
- if(TH_H_dmc > 10)
- TH_H_dmc = 10;
- TH_L_dmc = TH_L + Diff;
- if(TH_L_dmc > 10)
- TH_L_dmc = 10;
- }
- else
- {
- Diff = (s4Byte)IGI - IGI_target;
- TH_H_dmc = TH_H - Diff;
- TH_L_dmc = TH_L - Diff;
- }
- TH_H_dmc = (TH_H_dmc & 0xFF);
- TH_L_dmc = (TH_L_dmc & 0xFF);
- }
- else
- {
- TH_H_dmc = 0x7f;
- TH_L_dmc = 0x7f;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("IGI=0x%x, TH_H_dmc=0x%x, TH_L_dmc=0x%x\n",
- IGI, TH_H_dmc, TH_L_dmc));
- if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- {
- ODM_SetBBReg(pDM_Odm,rOFDM0_ECCAThreshold, bMaskByte0, TH_L_dmc);
- ODM_SetBBReg(pDM_Odm,rOFDM0_ECCAThreshold, bMaskByte2, TH_H_dmc);
- }
- else
- ODM_SetBBReg(pDM_Odm, rFPGA0_XB_LSSIReadBack, 0xFFFF, (TH_H_dmc<<8) | TH_L_dmc);
- }
- VOID
- ODM_Write_DIG(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte CurrentIGI
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- if(pDM_Odm->StopDIG)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("Stop Writing IGI\n"));
- return;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x \n",
- ODM_REG(IGI_A,pDM_Odm),ODM_BIT(IGI,pDM_Odm)));
- if(pDM_DigTable->CurIGValue != CurrentIGI)//if(pDM_DigTable->PreIGValue != CurrentIGI)
- {
- if(pDM_Odm->SupportPlatform & (ODM_CE|ODM_WIN))
- {
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- if(pDM_Odm->RFType != ODM_1T1R)
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- }
- else if(pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL))
- {
- switch(*(pDM_Odm->pOnePathCCA))
- {
- case ODM_CCA_2R:
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- if(pDM_Odm->RFType != ODM_1T1R)
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- break;
- case ODM_CCA_1R_A:
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- if(pDM_Odm->RFType != ODM_1T1R)
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B,pDM_Odm), ODM_BIT(IGI,pDM_Odm), getIGIForDiff(CurrentIGI));
- break;
- case ODM_CCA_1R_B:
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A,pDM_Odm), ODM_BIT(IGI,pDM_Odm), getIGIForDiff(CurrentIGI));
- if(pDM_Odm->RFType != ODM_1T1R)
- ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B,pDM_Odm), ODM_BIT(IGI,pDM_Odm), CurrentIGI);
- break;
- }
- }
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x). \n",CurrentIGI));
- //pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue;
- pDM_DigTable->CurIGValue = CurrentIGI;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x \n",CurrentIGI));
- }
- VOID
- odm_DIGbyRSSI_LPS(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //PADAPTER pAdapter =pDM_Odm->Adapter;
- //pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- PFALSE_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
- #if 0 //and 2.3.5 coding rule
- struct mlme_priv *pmlmepriv = &(pAdapter->mlmepriv);
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- #endif
- u1Byte RSSI_Lower=DM_DIG_MIN_NIC; //0x1E or 0x1C
- u1Byte CurrentIGI=pDM_Odm->RSSI_Min;
-
- CurrentIGI=CurrentIGI+RSSI_OFFSET_DIG;
-
- //ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG_LPS, ODM_DBG_LOUD, ("odm_DIG()==>\n"));
- // Using FW PS mode to make IGI
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n"));
- //Adjust by FA in LPS MODE
- if(pFalseAlmCnt->Cnt_all> DM_DIG_FA_TH2_LPS)
- CurrentIGI = CurrentIGI+2;
- else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS)
- CurrentIGI = CurrentIGI+1;
- else if(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS)
- CurrentIGI = CurrentIGI-1;
- //Lower bound checking
- //RSSI Lower bound check
- if((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC)
- RSSI_Lower =(pDM_Odm->RSSI_Min-10);
- else
- RSSI_Lower =DM_DIG_MIN_NIC;
- //Upper and Lower Bound checking
- if(CurrentIGI > DM_DIG_MAX_NIC)
- CurrentIGI=DM_DIG_MAX_NIC;
- else if(CurrentIGI < RSSI_Lower)
- CurrentIGI =RSSI_Lower;
- ODM_Write_DIG(pDM_Odm, CurrentIGI);//ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue);
- }
- VOID
- odm_DIGInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- //pDM_DigTable->Dig_Enable_Flag = TRUE;
- //pDM_DigTable->Dig_Ext_Port_Stage = DIG_EXT_PORT_STAGE_MAX;
- pDM_DigTable->CurIGValue = (u1Byte) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A,pDM_Odm), ODM_BIT(IGI,pDM_Odm));
- //pDM_DigTable->PreIGValue = 0x0;
- //pDM_DigTable->CurSTAConnectState = pDM_DigTable->PreSTAConnectState = DIG_STA_DISCONNECT;
- //pDM_DigTable->CurMultiSTAConnectState = DIG_MultiSTA_DISCONNECT;
- pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW;
- pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH;
- pDM_DigTable->FALowThresh = DM_FALSEALARM_THRESH_LOW;
- pDM_DigTable->FAHighThresh = DM_FALSEALARM_THRESH_HIGH;
- if(pDM_Odm->BoardType & (ODM_BOARD_EXT_PA|ODM_BOARD_EXT_LNA))
- {
- pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC;
- pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC;
- }
- else
- {
- pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC;
- pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC;
- }
- pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT;
- pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX;
- pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN;
- pDM_DigTable->PreCCK_CCAThres = 0xFF;
- pDM_DigTable->CurCCK_CCAThres = 0x83;
- pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC;
- pDM_DigTable->LargeFAHit = 0;
- pDM_DigTable->Recover_cnt = 0;
- pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC;
- pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC;
- pDM_DigTable->bMediaConnect_0 = FALSE;
- pDM_DigTable->bMediaConnect_1 = FALSE;
-
- //To Initialize pDM_Odm->bDMInitialGainEnable == FALSE to avoid DIG error
- pDM_Odm->bDMInitialGainEnable = TRUE;
- //To Initi BT30 IGI
- pDM_DigTable->BT30_CurIGI=0x32;
- }
- VOID
- odm_DigForBtHsMode(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- pDIG_T pDM_DigTable=&pDM_Odm->DM_DigTable;
- u1Byte digForBtHs=0;
- u1Byte digUpBound=0x5a;
-
- if(pDM_Odm->bBtConnectProcess)
- {
- if(pDM_Odm->SupportICType&(ODM_RTL8723A))
- digForBtHs = 0x28;
- else
- digForBtHs = 0x22;
- }
- else
- {
- //
- // Decide DIG value by BT HS RSSI.
- //
- digForBtHs = pDM_Odm->btHsRssi+4;
- //DIG Bound
- if(pDM_Odm->SupportICType&(ODM_RTL8723A))
- digUpBound = 0x3e;
-
- if(digForBtHs > digUpBound)
- digForBtHs = digUpBound;
- if(digForBtHs < 0x1c)
- digForBtHs = 0x1c;
- // update Current IGI
- pDM_DigTable->BT30_CurIGI = digForBtHs;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DigForBtHsMode() : set DigValue=0x%x\n", digForBtHs));
- #endif
- }
- VOID
- odm_DIG(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- PFALSE_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- u1Byte DIG_Dynamic_MIN;
- u1Byte DIG_MaxOfMin;
- BOOLEAN FirstConnect, FirstDisConnect;
- u1Byte dm_dig_max, dm_dig_min, offset;
- u1Byte CurrentIGI = pDM_DigTable->CurIGValue;
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- // This should be moved out of OUTSRC
- PADAPTER pAdapter = pDM_Odm->Adapter;
- #if OS_WIN_FROM_WIN7(OS_VERSION)
- if(IsAPModeExist( pAdapter) && pAdapter->bInHctTest)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: Is AP mode or In HCT Test \n"));
- return;
- }
- #endif
- /*
- if (pDM_Odm->SupportICType==ODM_RTL8723B)
- return;
- */
- if(pDM_Odm->bBtHsOperation)
- {
- odm_DigForBtHsMode(pDM_Odm);
- }
-
- if(!(pDM_Odm->SupportICType &(ODM_RTL8723A|ODM_RTL8188E)))
- {
- if(pRX_HP_Table->RXHP_flag == 1)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In RXHP Operation \n"));
- return;
- }
- }
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- #ifdef CONFIG_SPECIAL_SETTING_FOR_FUNAI_TV
- if((pDM_Odm->bLinked) && (pDM_Odm->Adapter->registrypriv.force_igi !=0))
- {
- printk("pDM_Odm->RSSI_Min=%d \n",pDM_Odm->RSSI_Min);
- ODM_Write_DIG(pDM_Odm,pDM_Odm->Adapter->registrypriv.force_igi);
- return;
- }
- #endif
- #endif
- #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- prtl8192cd_priv priv = pDM_Odm->priv;
- if (!((priv->up_time > 5) && (priv->up_time % 2)) )
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: Not In DIG Operation Period \n"));
- return;
- }
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n"));
- //if(!(pDM_Odm->SupportAbility & (ODM_BB_DIG|ODM_BB_FA_CNT)))
- if((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) ||(!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT)))
- {
- #if 0
- if(pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL))
- {
- if ((pDM_Odm->SupportICType == ODM_RTL8192C) && (pDM_Odm->ExtLNA == 1))
- CurrentIGI = 0x30; //pDM_DigTable->CurIGValue = 0x30;
- else
- CurrentIGI = 0x20; //pDM_DigTable->CurIGValue = 0x20;
- ODM_Write_DIG(pDM_Odm, CurrentIGI);//ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue);
- }
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n"));
- return;
- }
-
- if(*(pDM_Odm->pbScanInProcess))
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In Scan Progress \n"));
- return;
- }
- //add by Neil Chen to avoid PSD is processing
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- if(pDM_Odm->bDMInitialGainEnable == FALSE)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing \n"));
- return;
- }
- }
-
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- if(*(pDM_Odm->pMacPhyMode) == ODM_DMSP)
- {
- if(*(pDM_Odm->pbMasterOfDMSP))
- {
- DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
- FirstConnect = (pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == FALSE);
- FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == TRUE);
- }
- else
- {
- DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1;
- FirstConnect = (pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1 == FALSE);
- FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1 == TRUE);
- }
- }
- else
- {
- if(*(pDM_Odm->pBandType) == ODM_BAND_5G)
- {
- DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
- FirstConnect = (pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == FALSE);
- FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == TRUE);
- }
- else
- {
- DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1;
- FirstConnect = (pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1 == FALSE);
- FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1 == TRUE);
- }
- }
- }
- else
- {
- DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
- FirstConnect = (pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == FALSE);
- FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0 == TRUE);
- }
-
- //1 Boundary Decision
- if(pDM_Odm->SupportICType & (ODM_RTL8192C) &&(pDM_Odm->BoardType & (ODM_BOARD_EXT_LNA | ODM_BOARD_EXT_PA)))
- {
- if(pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL))
- {
- dm_dig_max = DM_DIG_MAX_AP_HP;
- dm_dig_min = DM_DIG_MIN_AP_HP;
- }
- else
- {
- dm_dig_max = DM_DIG_MAX_NIC_HP;
- dm_dig_min = DM_DIG_MIN_NIC_HP;
- }
- DIG_MaxOfMin = DM_DIG_MAX_AP_HP;
- }
- else
- {
- if(pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL))
- {
- #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- #ifdef DFS
- if (!priv->pmib->dot11DFSEntry.disable_DFS &&
- (OPMODE & WIFI_AP_STATE) &&
- (((pDM_Odm->ControlChannel >= 52) &&
- (pDM_Odm->ControlChannel <= 64)) ||
- ((pDM_Odm->ControlChannel >= 100) &&
- (pDM_Odm->ControlChannel <= 140))))
- dm_dig_max = 0x24;
- else
- #endif
- if (priv->pmib->dot11RFEntry.tx2path) {
- if (*(pDM_Odm->pWirelessMode) == ODM_WM_B)//(priv->pmib->dot11BssType.net_work_type == WIRELESS_11B)
- dm_dig_max = 0x2A;
- else
- dm_dig_max = 0x32;
- }
- else
- #endif
- dm_dig_max = DM_DIG_MAX_AP;
- dm_dig_min = DM_DIG_MIN_AP;
- DIG_MaxOfMin = dm_dig_max;
- }
- else
- {
- if((pDM_Odm->SupportICType >= ODM_RTL8188E) && (pDM_Odm->SupportPlatform & (ODM_WIN|ODM_CE)))
- dm_dig_max = 0x5A;
- else
- dm_dig_max = DM_DIG_MAX_NIC;
-
- if(pDM_Odm->SupportICType != ODM_RTL8821)
- dm_dig_min = DM_DIG_MIN_NIC;
- else
- dm_dig_min = 0x1C;
- DIG_MaxOfMin = DM_DIG_MAX_AP;
- }
- }
-
- if(pDM_Odm->bLinked)
- {
- if(pDM_Odm->SupportICType&(ODM_RTL8723A/*|ODM_RTL8821*/))
- {
- //2 Upper Bound
- if(( pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC )
- pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC;
- else if(( pDM_Odm->RSSI_Min + 10) < DM_DIG_MIN_NIC )
- pDM_DigTable->rx_gain_range_max = DM_DIG_MIN_NIC;
- else
- pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10;
- //BT is Concurrent
- if(pDM_Odm->bBtLimitedDig)
- {
- if(pDM_Odm->RSSI_Min>10)
- {
- if((pDM_Odm->RSSI_Min - 10) > DM_DIG_MAX_NIC)
- DIG_Dynamic_MIN = DM_DIG_MAX_NIC;
- else if((pDM_Odm->RSSI_Min - 10) < DM_DIG_MIN_NIC)
- DIG_Dynamic_MIN = DM_DIG_MIN_NIC;
- else
- DIG_Dynamic_MIN = pDM_Odm->RSSI_Min - 10;
- }
- else
- DIG_Dynamic_MIN=DM_DIG_MIN_NIC;
- }
- else
- {
- if((pDM_Odm->RSSI_Min + 20) > dm_dig_max )
- pDM_DigTable->rx_gain_range_max = dm_dig_max;
- else if((pDM_Odm->RSSI_Min + 20) < dm_dig_min )
- pDM_DigTable->rx_gain_range_max = dm_dig_min;
- else
- pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20;
-
- }
- }
- else
- {
- if((pDM_Odm->SupportICType & (ODM_RTL8192E|ODM_RTL8723B|ODM_RTL8812|ODM_RTL8821)) && (pDM_Odm->bBtLimitedDig==1)){
- //2 Modify DIG upper bound for 92E, 8723B, 8821 & 8812 BT
- if((pDM_Odm->RSSI_Min + 10) > dm_dig_max )
- pDM_DigTable->rx_gain_range_max = dm_dig_max;
- else if((pDM_Odm->RSSI_Min + 10) < dm_dig_min )
- pDM_DigTable->rx_gain_range_max = dm_dig_min;
- else
- pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10;
- }
- else{
-
- //2 Modify DIG upper bound
- //2013.03.19 Luke: Modified upper bound for Netgear rental house test
- if(pDM_Odm->SupportICType != ODM_RTL8821)
- offset = 20;
- else
- offset = 10;
-
- if((pDM_Odm->RSSI_Min + offset) > dm_dig_max )
- pDM_DigTable->rx_gain_range_max = dm_dig_max;
- else if((pDM_Odm->RSSI_Min + offset) < dm_dig_min )
- pDM_DigTable->rx_gain_range_max = dm_dig_min;
- else
- pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + offset;
-
- }
-
- //2 Modify DIG lower bound
- /*
- if((pFalseAlmCnt->Cnt_all > 500)&&(DIG_Dynamic_MIN < 0x25))
- DIG_Dynamic_MIN++;
- else if(((pFalseAlmCnt->Cnt_all < 500)||(pDM_Odm->RSSI_Min < 8))&&(DIG_Dynamic_MIN > dm_dig_min))
- DIG_Dynamic_MIN--;
- */
- if(pDM_Odm->bOneEntryOnly)
- {
- if(pDM_Odm->RSSI_Min < dm_dig_min)
- DIG_Dynamic_MIN = dm_dig_min;
- else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin)
- DIG_Dynamic_MIN = DIG_MaxOfMin;
- else
- DIG_Dynamic_MIN = pDM_Odm->RSSI_Min;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : bOneEntryOnly=TRUE, DIG_Dynamic_MIN=0x%x\n",DIG_Dynamic_MIN));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n",pDM_Odm->RSSI_Min));
- }
- //1 Lower Bound for 88E AntDiv
- #if (RTL8188E_SUPPORT == 1)
- else if((pDM_Odm->SupportICType == ODM_RTL8188E)&&(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
- {
- if((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) ||(pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV))
- {
- DIG_Dynamic_MIN = (u1Byte) pDM_DigTable->AntDiv_RSSI_max;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d \n",pDM_DigTable->AntDiv_RSSI_max));
- }
- }
- #endif
- else
- {
- DIG_Dynamic_MIN=dm_dig_min;
- }
- }
- }
- else
- {
- pDM_DigTable->rx_gain_range_max = dm_dig_max;
- DIG_Dynamic_MIN = dm_dig_min;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : No Link\n"));
- }
-
- //1 Modify DIG lower bound, deal with abnorally large false alarm
- if(pFalseAlmCnt->Cnt_all > 10000)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("dm_DIG(): Abnornally false alarm case. \n"));
- if(pDM_DigTable->LargeFAHit != 3)
- pDM_DigTable->LargeFAHit++;
- if(pDM_DigTable->ForbiddenIGI < CurrentIGI)//if(pDM_DigTable->ForbiddenIGI < pDM_DigTable->CurIGValue)
- {
- pDM_DigTable->ForbiddenIGI = (u1Byte)CurrentIGI;//pDM_DigTable->ForbiddenIGI = pDM_DigTable->CurIGValue;
- pDM_DigTable->LargeFAHit = 1;
- }
- if(pDM_DigTable->LargeFAHit >= 3)
- {
- if((pDM_DigTable->ForbiddenIGI+1) >pDM_DigTable->rx_gain_range_max)
- pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max;
- else
- pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1);
- pDM_DigTable->Recover_cnt = 3600; //3600=2hr
- }
- }
- else
- {
- //Recovery mechanism for IGI lower bound
- if(pDM_DigTable->Recover_cnt != 0)
- pDM_DigTable->Recover_cnt --;
- else
- {
- if(pDM_DigTable->LargeFAHit < 3)
- {
- if((pDM_DigTable->ForbiddenIGI -1) < DIG_Dynamic_MIN) //DM_DIG_MIN)
- {
- pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; //DM_DIG_MIN;
- pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; //DM_DIG_MIN;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n"));
- }
- else
- {
- pDM_DigTable->ForbiddenIGI --;
- pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Approach Lower Bound\n"));
- }
- }
- else
- {
- pDM_DigTable->LargeFAHit = 0;
- }
- }
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): pDM_DigTable->LargeFAHit=%d\n",pDM_DigTable->LargeFAHit));
- if((pDM_Odm->SupportPlatform&(ODM_WIN|ODM_CE))&&(pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 10))
- pDM_DigTable->rx_gain_range_min = dm_dig_min;
-
- if(pDM_DigTable->rx_gain_range_min > pDM_DigTable->rx_gain_range_max)
- pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max;
- //1 Adjust initial gain by false alarm
- if(pDM_Odm->bLinked)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG AfterLink\n"));
- if(FirstConnect)
- {
- if(pDM_Odm->RSSI_Min <= DIG_MaxOfMin)
- CurrentIGI = pDM_Odm->RSSI_Min;
- else
- CurrentIGI = DIG_MaxOfMin;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n"));
- }
- else
- {
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- if(pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_92D)
- CurrentIGI = CurrentIGI + 4;//pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2;
- else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_92D)
- CurrentIGI = CurrentIGI + 2; //pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1;
- else if(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_92D)
- CurrentIGI = CurrentIGI - 2;//pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1;
- }
- else
- {
- //FA for Combo IC--NeilChen--2012--09--28
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- //WLAN and BT ConCurrent
- if(pDM_Odm->bBtLimitedDig)
- {
- if(pFalseAlmCnt->Cnt_all > 0x300)
- CurrentIGI = CurrentIGI + 4;
- else if (pFalseAlmCnt->Cnt_all > 0x250)
- CurrentIGI = CurrentIGI + 2;
- else if(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0)
- CurrentIGI = CurrentIGI -2;
- }
- else //Not Concurrent
- {
- if(pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2)
- CurrentIGI = CurrentIGI + 4;//pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2;
- else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1)
- CurrentIGI = CurrentIGI + 2;//pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1;
- else if(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0)
- CurrentIGI = CurrentIGI - 2;//pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1;
- }
- }
- else
- {
- if(pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2)
- CurrentIGI = CurrentIGI + 4;//pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2;
- else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1)
- CurrentIGI = CurrentIGI + 2;//pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1;
- else if(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0)
- CurrentIGI = CurrentIGI - 2;//pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1;
- if((pDM_Odm->SupportPlatform&(ODM_WIN|ODM_CE))&&(pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 10)
- &&(pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH1))
- CurrentIGI = pDM_DigTable->rx_gain_range_min;
- }
- }
- }
- }
- else
- {
- //CurrentIGI = pDM_DigTable->rx_gain_range_min;//pDM_DigTable->CurIGValue = pDM_DigTable->rx_gain_range_min
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG BeforeLink\n"));
- if(FirstDisConnect)
- {
- CurrentIGI = pDM_DigTable->rx_gain_range_min;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First DisConnect \n"));
- }
- else
- {
- //2012.03.30 LukeLee: enable DIG before link but with very high thresholds
- if(pFalseAlmCnt->Cnt_all > 10000)
- CurrentIGI = CurrentIGI + 4;
- else if (pFalseAlmCnt->Cnt_all > 8000)
- CurrentIGI = CurrentIGI + 2;
- else if(pFalseAlmCnt->Cnt_all < 500)
- CurrentIGI = CurrentIGI - 2;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): England DIG \n"));
- }
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG End Adjust IGI\n"));
- //1 Check initial gain by upper/lower bound
- if(CurrentIGI > pDM_DigTable->rx_gain_range_max)
- CurrentIGI = pDM_DigTable->rx_gain_range_max;
- if(CurrentIGI < pDM_DigTable->rx_gain_range_min)
- CurrentIGI = pDM_DigTable->rx_gain_range_min;
-
- if(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY)
- {
- if(CurrentIGI > (pDM_Odm->IGI_target + 4))
- CurrentIGI = (u1Byte)pDM_Odm->IGI_target + 4;
- }
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): rx_gain_range_max=0x%x, rx_gain_range_min=0x%x\n",
- pDM_DigTable->rx_gain_range_max, pDM_DigTable->rx_gain_range_min));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): TotalFA=%d\n", pFalseAlmCnt->Cnt_all));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue=0x%x\n", CurrentIGI));
- //2 High power RSSI threshold
- #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pDM_Odm->Adapter);
- //PMGNT_INFO pMgntInfo = &(pAdapter->MgntInfo);
- // for LC issue to dymanic modify DIG lower bound----------LC Mocca Issue
- u8Byte curTxOkCnt=0, curRxOkCnt=0;
- static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
- //u8Byte OKCntAll=0;
- //static u8Byte TXByteCnt_A=0, TXByteCnt_B=0, RXByteCnt_A=0, RXByteCnt_B=0;
- //u8Byte CurByteCnt=0, PreByteCnt=0;
-
- curTxOkCnt = pAdapter->TxStats.NumTxBytesUnicast - lastTxOkCnt;
- curRxOkCnt =pAdapter->RxStats.NumRxBytesUnicast - lastRxOkCnt;
- lastTxOkCnt = pAdapter->TxStats.NumTxBytesUnicast;
- lastRxOkCnt = pAdapter->RxStats.NumRxBytesUnicast;
- //----------------------------------------------------------end for LC Mocca issue
- if((pDM_Odm->SupportICType == ODM_RTL8723A)&& (pHalData->UndecoratedSmoothedPWDB > DM_DIG_HIGH_PWR_THRESHOLD))
- {
- // High power IGI lower bound
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): UndecoratedSmoothedPWDB(%#x)\n", pHalData->UndecoratedSmoothedPWDB));
- if(CurrentIGI < DM_DIG_HIGH_PWR_IGI_LOWER_BOUND)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue(%#x)\n", pDM_DigTable->CurIGValue));
- //pDM_DigTable->CurIGValue = DM_DIG_HIGH_PWR_IGI_LOWER_BOUND;
- CurrentIGI=DM_DIG_HIGH_PWR_IGI_LOWER_BOUND;
- }
- }
- if((pDM_Odm->SupportICType & ODM_RTL8723A) &&
- IS_WIRELESS_MODE_G(pAdapter))
- {
- if(pHalData->UndecoratedSmoothedPWDB > 0x28)
- {
- if(CurrentIGI < DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND)
- {
- //pDM_DigTable->CurIGValue = DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND;
- CurrentIGI = DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND;
- }
- }
- }
- #if 0
- if((pDM_Odm->SupportICType & ODM_RTL8723A)&&(pMgntInfo->CustomerID = RT_CID_LENOVO_CHINA))
- {
- OKCntAll = (curTxOkCnt+curRxOkCnt);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue(%#x)\n", CurrentIGI));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): UndecoratedSmoothedPWDB(%#x)\n", pHalData->UndecoratedSmoothedPWDB));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): OKCntAll(%#x)\n", OKCntAll));
- //8723AS_VAU
- if(pDM_Odm->SupportInterface==ODM_ITRF_USB)
- {
- if(pHalData->UndecoratedSmoothedPWDB < 12)
- {
- if(CurrentIGI > DM_DIG_MIN_NIC)
- {
- if(OKCntAll >= 1500000) // >=6Mbps
- CurrentIGI=0x1B;
- else if(OKCntAll >= 1000000) //4Mbps
- CurrentIGI=0x1A;
- else if(OKCntAll >= 500000) //2Mbps
- CurrentIGI=0x19;
- else if(OKCntAll >= 250000) //1Mbps
- CurrentIGI=0x18;
- else
- {
- CurrentIGI=0x17; //SCAN mode
- }
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("Modify---->CurIGValue(%#x)\n", CurrentIGI));
- }
- }
- }
- #endif
- }
- #endif
-
- #if (RTL8192D_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- //sherry delete DualMacSmartConncurrent 20110517
- if(*(pDM_Odm->pMacPhyMode) == ODM_DMSP)
- {
- ODM_Write_DIG_DMSP(pDM_Odm, (u1Byte)CurrentIGI);//ODM_Write_DIG_DMSP(pDM_Odm, pDM_DigTable->CurIGValue);
- if(*(pDM_Odm->pbMasterOfDMSP))
- {
- pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN;
- }
- else
- {
- pDM_DigTable->bMediaConnect_1 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_1 = DIG_Dynamic_MIN;
- }
- }
- else
- {
- ODM_Write_DIG(pDM_Odm, CurrentIGI);//ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue);
- if(*(pDM_Odm->pBandType) == ODM_BAND_5G)
- {
- pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN;
- }
- else
- {
- pDM_DigTable->bMediaConnect_1 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_1 = DIG_Dynamic_MIN;
- }
- }
- }
- else
- #endif
- {
- if(pDM_Odm->bBtHsOperation)
- {
- if(pDM_Odm->bLinked)
- {
- if(pDM_DigTable->BT30_CurIGI > (CurrentIGI))
- {
- ODM_Write_DIG(pDM_Odm, CurrentIGI);
-
- }
- else
- {
- ODM_Write_DIG(pDM_Odm, pDM_DigTable->BT30_CurIGI);
- }
- pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN;
- }
- else
- {
- if(pDM_Odm->bLinkInProcess)
- {
- ODM_Write_DIG(pDM_Odm, 0x1c);
- }
- else if(pDM_Odm->bBtConnectProcess)
- {
- ODM_Write_DIG(pDM_Odm, 0x28);
- }
- else
- {
- ODM_Write_DIG(pDM_Odm, pDM_DigTable->BT30_CurIGI);//ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue);
- }
- }
- }
- else // BT is not using
- {
- ODM_Write_DIG(pDM_Odm, CurrentIGI);//ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue);
- pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked;
- pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN;
- }
- }
- }
- BOOLEAN
- odm_DigAbort(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- // This should be moved out of OUTSRC
- PADAPTER pAdapter = pDM_Odm->Adapter;
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
-
- #if OS_WIN_FROM_WIN7(OS_VERSION)
- if(IsAPModeExist( pAdapter) && pAdapter->bInHctTest)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: Is AP mode or In HCT Test \n"));
- return TRUE;
- }
- #endif
- if(pRX_HP_Table->RXHP_flag == 1)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In RXHP Operation \n"));
- return TRUE;
- }
- return FALSE;
- #else // For Other team any special case for DIG?
- return FALSE;
- #endif
-
- }
- //3============================================================
- //3 FASLE ALARM CHECK
- //3============================================================
- VOID
- odm_FalseAlarmCounterStatistics(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u4Byte ret_value;
- PFALSE_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
- #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
- prtl8192cd_priv priv = pDM_Odm->priv;
- if( (priv->auto_channel != 0) && (priv->auto_channel != 2) )
- return;
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- if((pDM_Odm->SupportICType == ODM_RTL8192D) &&
- (*(pDM_Odm->pMacPhyMode)==ODM_DMSP)&& ////modify by Guo.Mingzhi 2011-12-29
- (!(*(pDM_Odm->pbMasterOfDMSP))))
- {
- odm_FalseAlarmCounterStatistics_ForSlaveOfDMSP(pDM_Odm);
- return;
- }
- #endif
- if(!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))
- return;
- if(pDM_Odm->SupportICType & ODM_IC_11N_SERIES)
- {
- //hold ofdm counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); //hold page C counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); //hold page D counter
-
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
- FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff);
- FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16);
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
- FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff);
- FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16);
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
- FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff);
- FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16);
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
- FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff);
- FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal +
- FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail +
- FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail;
- #if (RTL8188E_SUPPORT==1)
- if((pDM_Odm->SupportICType == ODM_RTL8188E)||(pDM_Odm->SupportICType == ODM_RTL8192E))
- {
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_SC_CNT_11N, bMaskDWord);
- FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff);
- FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16);
- }
- #endif
- #if (RTL8192D_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- odm_GetCCKFalseAlarm_92D(pDM_Odm);
- }
- else
- #endif
- {
- //hold cck counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1);
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1);
-
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0);
- FalseAlmCnt->Cnt_Cck_fail = ret_value;
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3);
- FalseAlmCnt->Cnt_Cck_fail += (ret_value& 0xff)<<8;
- ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord);
- FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) |((ret_value&0xFF00)>>8);
- }
-
- FalseAlmCnt->Cnt_all = ( FalseAlmCnt->Cnt_Fast_Fsync +
- FalseAlmCnt->Cnt_SB_Search_fail +
- FalseAlmCnt->Cnt_Parity_Fail +
- FalseAlmCnt->Cnt_Rate_Illegal +
- FalseAlmCnt->Cnt_Crc8_fail +
- FalseAlmCnt->Cnt_Mcs_fail +
- FalseAlmCnt->Cnt_Cck_fail);
- FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA;
- #if (RTL8192C_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192C)
- odm_ResetFACounter_92C(pDM_Odm);
- #endif
- #if (RTL8192D_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- odm_ResetFACounter_92D(pDM_Odm);
- #endif
- if(pDM_Odm->SupportICType >=ODM_RTL8723A)
- {
- //reset false alarm counter registers
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1);
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0);
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1);
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0);
- //update ofdm counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); //update page C counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); //update page D counter
- //reset CCK CCA counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0);
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2);
- //reset CCK FA counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0);
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2);
- }
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n",
- FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n",
- FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n",
- FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail));
- }
- else if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES)
- {
- u4Byte CCKenable;
- //read OFDM FA counter
- FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord);
- FalseAlmCnt->Cnt_Cck_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_11AC, bMaskLWord);
-
- CCKenable = ODM_GetBBReg(pDM_Odm, ODM_REG_BB_RX_PATH_11AC, BIT28);
- if(CCKenable)//if(*pDM_Odm->pBandType == ODM_BAND_2_4G)
- FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail;
- else
- FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail;
- // reset OFDM FA coutner
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1);
- ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0);
- // reset CCK FA counter
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0);
- ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1);
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail=%d\n", FalseAlmCnt->Cnt_Cck_fail));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail=%d\n", FalseAlmCnt->Cnt_Ofdm_fail));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm=%d\n", FalseAlmCnt->Cnt_all));
- }
- //3============================================================
- //3 CCK Packet Detect Threshold
- //3============================================================
- VOID
- odm_CCKPacketDetectionThresh(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u1Byte CurCCK_CCAThres;
- PFALSE_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- //modify by Guo.Mingzhi 2011-12-29
- if (pDM_Odm->bDualMacSmartConcurrent == TRUE)
- // if (pDM_Odm->bDualMacSmartConcurrent == FALSE)
- return;
- if(pDM_Odm->bBtHsOperation)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_CCKPacketDetectionThresh() write 0xcd for BT HS mode!!\n"));
- ODM_Write_CCK_CCA_Thres(pDM_Odm, 0xcd);
- return;
- }
- #endif
- if(!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT)))
- return;
- if(pDM_Odm->ExtLNA)
- return;
- if(pDM_Odm->bLinked)
- {
- if(pDM_Odm->RSSI_Min > 25)
- CurCCK_CCAThres = 0xcd;
- else if((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10))
- CurCCK_CCAThres = 0x83;
- else
- {
- if(FalseAlmCnt->Cnt_Cck_fail > 1000)
- CurCCK_CCAThres = 0x83;
- else
- CurCCK_CCAThres = 0x40;
- }
- }
- else
- {
- if(FalseAlmCnt->Cnt_Cck_fail > 1000)
- CurCCK_CCAThres = 0x83;
- else
- CurCCK_CCAThres = 0x40;
- }
-
- #if (RTL8192D_SUPPORT==1)
- if((pDM_Odm->SupportICType == ODM_RTL8192D)&&(*pDM_Odm->pBandType == ODM_BAND_2_4G))
- ODM_Write_CCK_CCA_Thres_92D(pDM_Odm, CurCCK_CCAThres);
- else
- #endif
- ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres);
- }
- VOID
- ODM_Write_CCK_CCA_Thres(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte CurCCK_CCAThres
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- if(pDM_DigTable->CurCCK_CCAThres!=CurCCK_CCAThres) //modify by Guo.Mingzhi 2012-01-03
- {
- ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA,pDM_Odm), CurCCK_CCAThres);
- }
- pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres;
- pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres;
-
- }
- //3============================================================
- //3 BB Power Save
- //3============================================================
- VOID
- odm_DynamicBBPowerSavingInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
- pDM_PSTable->PreCCAState = CCA_MAX;
- pDM_PSTable->CurCCAState = CCA_MAX;
- pDM_PSTable->PreRFState = RF_MAX;
- pDM_PSTable->CurRFState = RF_MAX;
- pDM_PSTable->Rssi_val_min = 0;
- pDM_PSTable->initialize = 0;
- }
- VOID
- odm_DynamicBBPowerSaving(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- if (pDM_Odm->SupportICType != ODM_RTL8723A)
- return;
- if(!(pDM_Odm->SupportAbility & ODM_BB_PWR_SAVE))
- return;
- if(!(pDM_Odm->SupportPlatform & (ODM_WIN|ODM_CE)))
- return;
-
- //1 2.Power Saving for 92C
- if((pDM_Odm->SupportICType == ODM_RTL8192C) &&(pDM_Odm->RFType == ODM_2T2R))
- {
- odm_1R_CCA(pDM_Odm);
- }
-
- // 20100628 Joseph: Turn off BB power save for 88CE because it makesthroughput unstable.
- // 20100831 Joseph: Turn ON BB power save again after modifying AGC delay from 900ns ot 600ns.
- //1 3.Power Saving for 88C
- else
- {
- ODM_RF_Saving(pDM_Odm, FALSE);
- }
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
-
- }
- VOID
- odm_1R_CCA(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
- if(pDM_Odm->RSSI_Min!= 0xFF)
- {
-
- if(pDM_PSTable->PreCCAState == CCA_2R)
- {
- if(pDM_Odm->RSSI_Min >= 35)
- pDM_PSTable->CurCCAState = CCA_1R;
- else
- pDM_PSTable->CurCCAState = CCA_2R;
-
- }
- else{
- if(pDM_Odm->RSSI_Min <= 30)
- pDM_PSTable->CurCCAState = CCA_2R;
- else
- pDM_PSTable->CurCCAState = CCA_1R;
- }
- }
- else{
- pDM_PSTable->CurCCAState=CCA_MAX;
- }
-
- if(pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState)
- {
- if(pDM_PSTable->CurCCAState == CCA_1R)
- {
- if( pDM_Odm->RFType ==ODM_2T2R )
- {
- ODM_SetBBReg(pDM_Odm, 0xc04 , bMaskByte0, 0x13);
- //PHY_SetBBReg(pAdapter, 0xe70, bMaskByte3, 0x20);
- }
- else
- {
- ODM_SetBBReg(pDM_Odm, 0xc04 , bMaskByte0, 0x23);
- //PHY_SetBBReg(pAdapter, 0xe70, 0x7fc00000, 0x10c); // Set RegE70[30:22] = 9b'100001100
- }
- }
- else
- {
- ODM_SetBBReg(pDM_Odm, 0xc04 , bMaskByte0, 0x33);
- //PHY_SetBBReg(pAdapter,0xe70, bMaskByte3, 0x63);
- }
- pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState;
- }
- //ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("CCAStage = %s\n",(pDM_PSTable->CurCCAState==0)?"1RCCA":"2RCCA"));
- }
- void
- ODM_RF_Saving(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte bForceInNormal
- )
- {
- #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
- pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable;
- u1Byte Rssi_Up_bound = 30 ;
- u1Byte Rssi_Low_bound = 25;
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- if(pDM_Odm->PatchID == 40 ) //RT_CID_819x_FUNAI_TV
- {
- Rssi_Up_bound = 50 ;
- Rssi_Low_bound = 45;
- }
- #endif
- if(pDM_PSTable->initialize == 0){
-
- pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14;
- pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3;
- pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24;
- pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12;
- //Reg818 = PHY_QueryBBReg(pAdapter, 0x818, bMaskDWord);
- pDM_PSTable->initialize = 1;
- }
- if(!bForceInNormal)
- {
- if(pDM_Odm->RSSI_Min != 0xFF)
- {
- if(pDM_PSTable->PreRFState == RF_Normal)
- {
- if(pDM_Odm->RSSI_Min >= Rssi_Up_bound)
- pDM_PSTable->CurRFState = RF_Save;
- else
- pDM_PSTable->CurRFState = RF_Normal;
- }
- else{
- if(pDM_Odm->RSSI_Min <= Rssi_Low_bound)
- pDM_PSTable->CurRFState = RF_Normal;
- else
- pDM_PSTable->CurRFState = RF_Save;
- }
- }
- else
- pDM_PSTable->CurRFState=RF_MAX;
- }
- else
- {
- pDM_PSTable->CurRFState = RF_Normal;
- }
-
- if(pDM_PSTable->PreRFState != pDM_PSTable->CurRFState)
- {
- if(pDM_PSTable->CurRFState == RF_Save)
- {
- // <tynli_note> 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode.
- // Suggested by SD3 Yu-Nan. 2011.01.20.
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- ODM_SetBBReg(pDM_Odm, 0x874 , BIT5, 0x1); //Reg874[5]=1b'1
- }
- ODM_SetBBReg(pDM_Odm, 0x874 , 0x1C0000, 0x2); //Reg874[20:18]=3'b010
- ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); //RegC70[3]=1'b0
- ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); //Reg85C[31:24]=0x63
- ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); //Reg874[15:14]=2'b10
- ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); //RegA75[7:4]=0x3
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); //Reg818[28]=1'b0
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); //Reg818[28]=1'b1
- //ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, (" RF_Save"));
- }
- else
- {
- ODM_SetBBReg(pDM_Odm, 0x874 , 0x1CC000, pDM_PSTable->Reg874);
- ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70);
- ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C);
- ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74);
- ODM_SetBBReg(pDM_Odm,0x818, BIT28, 0x0);
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- ODM_SetBBReg(pDM_Odm,0x874 , BIT5, 0x0); //Reg874[5]=1b'0
- }
- //ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, (" RF_Normal"));
- }
- pDM_PSTable->PreRFState =pDM_PSTable->CurRFState;
- }
- #endif
- }
- //3============================================================
- //3 RATR MASK
- //3============================================================
- //3============================================================
- //3 Rate Adaptive
- //3============================================================
- VOID
- odm_RateAdaptiveMaskInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive;
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PMGNT_INFO pMgntInfo = &pDM_Odm->Adapter->MgntInfo;
- pMgntInfo->Ratr_State = DM_RATR_STA_INIT;
- if (pMgntInfo->DM_Type == DM_Type_ByDriver)
- pMgntInfo->bUseRAMask = TRUE;
- else
- pMgntInfo->bUseRAMask = FALSE;
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- pOdmRA->Type = DM_Type_ByDriver;
- if (pOdmRA->Type == DM_Type_ByDriver)
- pDM_Odm->bUseRAMask = _TRUE;
- else
- pDM_Odm->bUseRAMask = _FALSE;
- #endif
- pOdmRA->RATRState = DM_RATR_STA_INIT;
- pOdmRA->LdpcThres = 35;
- pOdmRA->bUseLdpc = FALSE;
- pOdmRA->HighRSSIThresh = 50;
- pOdmRA->LowRSSIThresh = 20;
- }
- #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
- VOID
- ODM_RateAdaptiveStateApInit(
- IN PADAPTER Adapter ,
- IN PRT_WLAN_STA pEntry
- )
- {
- pEntry->Ratr_State = DM_RATR_STA_INIT;
- }
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- u4Byte ODM_Get_Rate_Bitmap(
- IN PDM_ODM_T pDM_Odm,
- IN u4Byte macid,
- IN u4Byte ra_mask,
- IN u1Byte rssi_level)
- {
- PSTA_INFO_T pEntry;
- u4Byte rate_bitmap = 0;
- u1Byte WirelessMode;
- //u1Byte WirelessMode =*(pDM_Odm->pWirelessMode);
-
-
- pEntry = pDM_Odm->pODM_StaInfo[macid];
- if(!IS_STA_VALID(pEntry))
- return ra_mask;
- WirelessMode = pEntry->wireless_mode;
-
- switch(WirelessMode)
- {
- case ODM_WM_B:
- if(ra_mask & 0x0000000c) //11M or 5.5M enable
- rate_bitmap = 0x0000000d;
- else
- rate_bitmap = 0x0000000f;
- break;
-
- case (ODM_WM_G):
- case (ODM_WM_A):
- if(rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x00000f00;
- else
- rate_bitmap = 0x00000ff0;
- break;
-
- case (ODM_WM_B|ODM_WM_G):
- if(rssi_level == DM_RATR_STA_HIGH)
- rate_bitmap = 0x00000f00;
- else if(rssi_level == DM_RATR_STA_MIDDLE)
- rate_bitmap = 0x00000ff0;
- else
- rate_bitmap = 0x00000ff5;
- break;
- case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G) :
- case (ODM_WM_B|ODM_WM_N24G) :
- case (ODM_WM_A|ODM_WM_N5G) :
- {
- if ( pDM_Odm->RFType == ODM_1T2R ||pDM_Odm->RFType == ODM_1T1R)
- {
- if(rssi_level == DM_RATR_STA_HIGH)
- {
- rate_bitmap = 0x000f0000;
- }
- else if(rssi_level == DM_RATR_STA_MIDDLE)
- {
- rate_bitmap = 0x000ff000;
- }
- else{
- if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
- rate_bitmap = 0x000ff015;
- else
- rate_bitmap = 0x000ff005;
- }
- }
- else
- {
- if(rssi_level == DM_RATR_STA_HIGH)
- {
- rate_bitmap = 0x0f8f0000;
- }
- else if(rssi_level == DM_RATR_STA_MIDDLE)
- {
- rate_bitmap = 0x0f8ff000;
- }
- else
- {
- if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
- rate_bitmap = 0x0f8ff015;
- else
- rate_bitmap = 0x0f8ff005;
- }
- }
- }
- break;
- case (ODM_WM_AC|ODM_WM_A):
- case (ODM_WM_AC|ODM_WM_G):
- if (pDM_Odm->RFType == RF_1T1R)
- {
- if( (pDM_Odm->SupportICType == ODM_RTL8821)||
- (pDM_Odm->SupportICType == ODM_RTL8812 && pDM_Odm->bIsMPChip))
- {
- if( (pDM_Odm->SupportICType == ODM_RTL8821)
- && (pDM_Odm->SupportInterface == ODM_ITRF_USB)
- && (*(pDM_Odm->pChannel) >= 149))
- {
- if(rssi_level == 1) // add by Gary for ac-series
- rate_bitmap = 0x001f8000;
- else if (rssi_level == 2)
- rate_bitmap = 0x001ff000;
- else
- rate_bitmap = 0x001ff010;
- }
- else
- {
- if(rssi_level == 1) // add by Gary for ac-series
- rate_bitmap = 0x003f8000;
- else if (rssi_level == 2)
- rate_bitmap = 0x003ff000;
- else
- rate_bitmap = 0x003ff010;
- }
- }
- else{
- rate_bitmap = 0x000ff010;
- }
- }
- else
- {
- if(pDM_Odm->bIsMPChip)
- {
- if(rssi_level == 1) // add by Gary for ac-series
- rate_bitmap = 0xfe3f8000; // VHT 2SS MCS3~9
- else if (rssi_level == 2)
- rate_bitmap = 0xfffff000; // VHT 2SS MCS0~9
- else
- rate_bitmap = 0xfffff010; // All
- }
- else
- rate_bitmap = 0x3fcff010;
- }
- break;
-
- default:
- if(pDM_Odm->RFType == RF_1T2R)
- rate_bitmap = 0x000fffff;
- else
- rate_bitmap = 0x0fffffff;
- break;
- }
- //printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n",__FUNCTION__,rssi_level,WirelessMode,rate_bitmap);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x \n",rssi_level,WirelessMode,rate_bitmap));
- return (ra_mask&rate_bitmap);
-
- }
- #endif
- VOID
- odm_RefreshBasicRateMask(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- static u1Byte Stage = 0;
- u1Byte CurStage = 0;
- OCTET_STRING osRateSet;
- PMGNT_INFO pMgntInfo = GetDefaultMgntInfo(Adapter);
- u1Byte RateSet[5] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M, MGN_6M};
- if(pDM_Odm->SupportICType != ODM_RTL8812 && pDM_Odm->SupportICType != ODM_RTL8821 )
- return;
- if(pDM_Odm->bLinked == FALSE) // unlink Default port information
- CurStage = 0;
- else if(pDM_Odm->RSSI_Min < 25) // link RSSI < 25%
- CurStage = 1;
- else if(pDM_Odm->RSSI_Min > 30) // link RSSI > 30%
- CurStage = 3;
- else
- CurStage = 2; // link 25% <= RSSI <= 30%
- if(CurStage != Stage)
- {
- if(CurStage == 1)
- {
- FillOctetString(osRateSet, RateSet, 5);
- FilterSupportRate(pMgntInfo->mBrates, &osRateSet, FALSE);
- Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_BASIC_RATE, (pu1Byte)&osRateSet);
- }
- else if(CurStage == 3 && (Stage == 1 || Stage == 2))
- {
- Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_BASIC_RATE, (pu1Byte)(&pMgntInfo->mBrates) );
- }
- }
-
- Stage = CurStage;
- #endif
- }
- /*-----------------------------------------------------------------------------
- * Function: odm_RefreshRateAdaptiveMask()
- *
- * Overview: Update rate table mask according to rssi
- *
- * Input: NONE
- *
- * Output: NONE
- *
- * Return: NONE
- *
- * Revised History:
- * When Who Remark
- * 05/27/2009 hpfan Create Version 0.
- *
- *---------------------------------------------------------------------------*/
- VOID
- odm_RefreshRateAdaptiveMask(
- IN PDM_ODM_T pDM_Odm
- )
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n"));
- if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n"));
- return;
- }
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- odm_RefreshRateAdaptiveMaskMP(pDM_Odm);
- break;
- case ODM_CE:
- odm_RefreshRateAdaptiveMaskCE(pDM_Odm);
- break;
- case ODM_AP:
- case ODM_ADSL:
- odm_RefreshRateAdaptiveMaskAPADSL(pDM_Odm);
- break;
- }
-
- }
- VOID
- odm_RefreshRateAdaptiveMaskMP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER pAdapter = pDM_Odm->Adapter;
- PADAPTER pTargetAdapter = NULL;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- PMGNT_INFO pMgntInfo = GetDefaultMgntInfo(pAdapter);
- PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
- if(pAdapter->bDriverStopped)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
- return;
- }
- if(!pMgntInfo->bUseRAMask)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
- return;
- }
- // if default port is connected, update RA table for default port (infrastructure mode only)
- if(pMgntInfo->mAssoc && (!ACTING_AS_AP(pAdapter)))
- {
-
- if(pHalData->UndecoratedSmoothedPWDB < pRA->LdpcThres)
- {
- pRA->bUseLdpc = TRUE;
- pRA->bLowerRtsRate = TRUE;
- Set_RA_LDPC_8812(pAdapter,0,TRUE);
- //DbgPrint("RSSI=%d, bUseLdpc = TRUE\n", pHalData->UndecoratedSmoothedPWDB);
- }
- else if(pHalData->UndecoratedSmoothedPWDB > (pRA->LdpcThres-5))
- {
- pRA->bUseLdpc = FALSE;
- pRA->bLowerRtsRate = FALSE;
- Set_RA_LDPC_8812(pAdapter,0,FALSE);
- //DbgPrint("RSSI=%d, bUseLdpc = FALSE\n", pHalData->UndecoratedSmoothedPWDB);
- }
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("odm_RefreshRateAdaptiveMask(): Infrasture Mode\n"));
- if( ODM_RAStateCheck(pDM_Odm, pHalData->UndecoratedSmoothedPWDB, pMgntInfo->bSetTXPowerTrainingByOid, &pMgntInfo->Ratr_State) )
- {
- ODM_PRINT_ADDR(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("Target AP addr : "), pMgntInfo->Bssid);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pHalData->UndecoratedSmoothedPWDB, pMgntInfo->Ratr_State));
- pAdapter->HalFunc.UpdateHalRAMaskHandler(
- pAdapter,
- FALSE,
- pMgntInfo->mMacId,
- NULL,
- NULL,
- pMgntInfo->Ratr_State,
- RAMask_Normal);
- }
- }
- //
- // The following part configure AP/VWifi/IBSS rate adaptive mask.
- //
- if(pMgntInfo->mIbss) // Target: AP/IBSS peer.
- pTargetAdapter = GetDefaultAdapter(pAdapter);
- else
- pTargetAdapter = GetFirstAPAdapter(pAdapter);
- // if extension port (softap) is started, updaet RA table for more than one clients associate
- if(pTargetAdapter != NULL)
- {
- int i;
- PRT_WLAN_STA pEntry;
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- pEntry = AsocEntry_EnumStation(pTargetAdapter, i);
- if(NULL != pEntry)
- {
- if(pEntry->bAssociated)
- {
- if(ODM_RAStateCheck(pDM_Odm, pEntry->rssi_stat.UndecoratedSmoothedPWDB, pMgntInfo->bSetTXPowerTrainingByOid, &pEntry->Ratr_State) )
- {
- ODM_PRINT_ADDR(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("Target STA addr : "), pEntry->MacAddr);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pEntry->rssi_stat.UndecoratedSmoothedPWDB, pEntry->Ratr_State));
- pAdapter->HalFunc.UpdateHalRAMaskHandler(
- pTargetAdapter,
- FALSE,
- pEntry->AssociatedMacId,
- pEntry->MacAddr,
- pEntry,
- pEntry->Ratr_State,
- RAMask_Normal);
- }
- }
- }
- }
- }
- if(pMgntInfo->bSetTXPowerTrainingByOid)
- pMgntInfo->bSetTXPowerTrainingByOid = FALSE;
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- }
- VOID
- odm_RefreshRateAdaptiveMaskCE(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- u1Byte i;
- PADAPTER pAdapter = pDM_Odm->Adapter;
- PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
- if(pAdapter->bDriverStopped)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n"));
- return;
- }
- if(!pDM_Odm->bUseRAMask)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n"));
- return;
- }
- //printk("==> %s \n",__FUNCTION__);
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++){
- PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pstat) ) {
- #if((RTL8812A_SUPPORT==1)||(RTL8821A_SUPPORT==1))
- if((pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8821))
- {
- if(pstat->rssi_stat.UndecoratedSmoothedPWDB < pRA->LdpcThres)
- {
- pRA->bUseLdpc = TRUE;
- pRA->bLowerRtsRate = TRUE;
- Set_RA_LDPC_8812(pstat, TRUE);
- //DbgPrint("RSSI=%d, bUseLdpc = TRUE\n", pHalData->UndecoratedSmoothedPWDB);
- }
- else if(pstat->rssi_stat.UndecoratedSmoothedPWDB > (pRA->LdpcThres-5))
- {
- pRA->bUseLdpc = FALSE;
- pRA->bLowerRtsRate = FALSE;
- Set_RA_LDPC_8812(pstat, FALSE);
- //DbgPrint("RSSI=%d, bUseLdpc = FALSE\n", pHalData->UndecoratedSmoothedPWDB);
- }
- }
- #endif
- if( TRUE == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, FALSE , &pstat->rssi_level) )
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level));
- //printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level);
- rtw_hal_update_ra_mask(pstat, pstat->rssi_level);
- }
-
- }
- }
-
- #endif
- }
- VOID
- odm_RefreshRateAdaptiveMaskAPADSL(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- struct rtl8192cd_priv *priv = pDM_Odm->priv;
- struct stat_info *pstat;
- if (!priv->pmib->dot11StationConfigEntry.autoRate)
- return;
- if (list_empty(&priv->asoc_list))
- return;
- list_for_each_entry(pstat, &priv->asoc_list, asoc_list) {
- if(ODM_RAStateCheck(pDM_Odm, (s4Byte)pstat->rssi, FALSE, &pstat->rssi_level) ) {
- ODM_PRINT_ADDR(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("Target STA addr : "), pstat->hwaddr);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi, pstat->rssi_level));
- #ifdef CONFIG_RTL_88E_SUPPORT
- if (GET_CHIP_VER(priv)==VERSION_8188E) {
- #ifdef TXREPORT
- add_RATid(priv, pstat);
- #endif
- } else
- #endif
- {
- #if defined(CONFIG_RTL_92D_SUPPORT) || defined(CONFIG_RTL_92C_SUPPORT)
- add_update_RATid(priv, pstat);
- #endif
- }
- }
- }
- #endif
- }
- // Return Value: BOOLEAN
- // - TRUE: RATRState is changed.
- BOOLEAN
- ODM_RAStateCheck(
- IN PDM_ODM_T pDM_Odm,
- IN s4Byte RSSI,
- IN BOOLEAN bForceUpdate,
- OUT pu1Byte pRATRState
- )
- {
- PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive;
- const u1Byte GoUpGap = 5;
- u1Byte HighRSSIThreshForRA = pRA->HighRSSIThresh;
- u1Byte LowRSSIThreshForRA = pRA->LowRSSIThresh;
- u1Byte RATRState;
- // Threshold Adjustment:
- // when RSSI state trends to go up one or two levels, make sure RSSI is high enough.
- // Here GoUpGap is added to solve the boundary's level alternation issue.
- switch (*pRATRState)
- {
- case DM_RATR_STA_INIT:
- case DM_RATR_STA_HIGH:
- break;
- case DM_RATR_STA_MIDDLE:
- HighRSSIThreshForRA += GoUpGap;
- break;
- case DM_RATR_STA_LOW:
- HighRSSIThreshForRA += GoUpGap;
- LowRSSIThreshForRA += GoUpGap;
- break;
- default:
- ODM_RT_ASSERT(pDM_Odm, FALSE, ("wrong rssi level setting %d !", *pRATRState) );
- break;
- }
- // Decide RATRState by RSSI.
- if(RSSI > HighRSSIThreshForRA)
- RATRState = DM_RATR_STA_HIGH;
- else if(RSSI > LowRSSIThreshForRA)
- RATRState = DM_RATR_STA_MIDDLE;
- else
- RATRState = DM_RATR_STA_LOW;
- //printk("==>%s,RATRState:0x%02x ,RSSI:%d \n",__FUNCTION__,RATRState,RSSI);
- if( *pRATRState!=RATRState || bForceUpdate)
- {
- ODM_RT_TRACE( pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState) );
- *pRATRState = RATRState;
- return TRUE;
- }
- return FALSE;
- }
- //============================================================
- //3============================================================
- //3 Dynamic Tx Power
- //3============================================================
- VOID
- odm_DynamicTxPowerInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- #if DEV_BUS_TYPE==RT_USB_INTERFACE
- if(RT_GetInterfaceSelection(Adapter) == INTF_SEL1_USB_High_Power)
- {
- odm_DynamicTxPowerSavePowerIndex(pDM_Odm);
- pMgntInfo->bDynamicTxPowerEnable = TRUE;
- }
- else
- #else
- //so 92c pci do not need dynamic tx power? vivi check it later
- if(IS_HARDWARE_TYPE_8192D(Adapter))
- pMgntInfo->bDynamicTxPowerEnable = TRUE;
- else
- pMgntInfo->bDynamicTxPowerEnable = FALSE;
- #endif
-
- pHalData->LastDTPLvl = TxHighPwrLevel_Normal;
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- pdmpriv->bDynamicTxPowerEnable = _FALSE;
- #if (RTL8192C_SUPPORT==1)
- #ifdef CONFIG_USB_HCI
- #ifdef CONFIG_INTEL_PROXIM
- if((pHalData->BoardType == BOARD_USB_High_PA)||(Adapter->proximity.proxim_support==_TRUE))
- #else
- if(pHalData->BoardType == BOARD_USB_High_PA)
- #endif
- {
- //odm_SavePowerIndex(Adapter);
- odm_DynamicTxPowerSavePowerIndex(pDM_Odm);
- pdmpriv->bDynamicTxPowerEnable = _TRUE;
- }
- else
- #else
- pdmpriv->bDynamicTxPowerEnable = _FALSE;
- #endif
- #endif
-
- pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal;
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
-
- #endif
-
- }
- VOID
- odm_DynamicTxPowerSavePowerIndex(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u1Byte index;
- u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
-
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- for(index = 0; index< 6; index++)
- pHalData->PowerIndex_backup[index] = PlatformEFIORead1Byte(Adapter, Power_Index_REG[index]);
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- for(index = 0; index< 6; index++)
- pdmpriv->PowerIndex_backup[index] = rtw_read8(Adapter, Power_Index_REG[index]);
- #endif
- }
- VOID
- odm_DynamicTxPowerRestorePowerIndex(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u1Byte index;
- PADAPTER Adapter = pDM_Odm->Adapter;
- #if (DM_ODM_SUPPORT_TYPE & (ODM_CE|ODM_WIN))
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- for(index = 0; index< 6; index++)
- PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], pHalData->PowerIndex_backup[index]);
- #elif(DM_ODM_SUPPORT_TYPE == ODM_CE)
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- for(index = 0; index< 6; index++)
- rtw_write8(Adapter, Power_Index_REG[index], pdmpriv->PowerIndex_backup[index]);
- #endif
- #endif
- }
- VOID
- odm_DynamicTxPowerWritePowerIndex(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Value)
- {
- u1Byte index;
- u4Byte Power_Index_REG[6] = {0xc90, 0xc91, 0xc92, 0xc98, 0xc99, 0xc9a};
-
- for(index = 0; index< 6; index++)
- //PlatformEFIOWrite1Byte(Adapter, Power_Index_REG[index], Value);
- ODM_Write1Byte(pDM_Odm, Power_Index_REG[index], Value);
- }
- VOID
- odm_DynamicTxPower(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //
- // For AP/ADSL use prtl8192cd_priv
- // For CE/NIC use PADAPTER
- //
- //PADAPTER pAdapter = pDM_Odm->Adapter;
- // prtl8192cd_priv priv = pDM_Odm->priv;
- if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR))
- return;
- // 2012/01/12 MH According to Luke's suggestion, only high power will support the feature.
- if (pDM_Odm->ExtPA == FALSE)
- return;
-
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- case ODM_CE:
- odm_DynamicTxPowerNIC(pDM_Odm);
- break;
- case ODM_AP:
- odm_DynamicTxPowerAP(pDM_Odm);
- break;
- case ODM_ADSL:
- //odm_DIGAP(pDM_Odm);
- break;
- }
-
- }
- VOID
- odm_DynamicTxPowerNIC(
- IN PDM_ODM_T pDM_Odm
- )
- {
- if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR))
- return;
-
- #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- if(pDM_Odm->SupportICType == ODM_RTL8192C)
- {
- odm_DynamicTxPower_92C(pDM_Odm);
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- odm_DynamicTxPower_92D(pDM_Odm);
- }
- else if (pDM_Odm->SupportICType & ODM_RTL8188E)
- {
- // Add Later.
- }
- else if (pDM_Odm->SupportICType == ODM_RTL8188E)
- {
- // ???
- // This part need to be redefined.
- }
- #endif
- }
- VOID
- odm_DynamicTxPowerAP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
- prtl8192cd_priv priv = pDM_Odm->priv;
- s4Byte i;
- if(!priv->pshare->rf_ft_var.tx_pwr_ctrl)
- return;
-
- #ifdef HIGH_POWER_EXT_PA
- if(pDM_Odm->ExtPA)
- tx_power_control(priv);
- #endif
- /*
- * Check if station is near by to use lower tx power
- */
- if ((priv->up_time % 3) == 0 ) {
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++){
- PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pstat) ) {
- if ((pstat->hp_level == 0) && (pstat->rssi > TX_POWER_NEAR_FIELD_THRESH_AP+4))
- pstat->hp_level = 1;
- else if ((pstat->hp_level == 1) && (pstat->rssi < TX_POWER_NEAR_FIELD_THRESH_AP))
- pstat->hp_level = 0;
- }
- }
- }
- #endif
- }
- VOID
- odm_DynamicTxPower_92C(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- s4Byte UndecoratedSmoothedPWDB;
- // STA not connected and AP not connected
- if((!pMgntInfo->bMediaConnect) &&
- (pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
- {
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n"));
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //the LastDTPlvl should reset when disconnect,
- //otherwise the tx power level wouldn't change when disconnect and connect again.
- // Maddest 20091220.
- pHalData->LastDTPLvl=TxHighPwrLevel_Normal;
- return;
- }
- #if (INTEL_PROXIMITY_SUPPORT == 1)
- // Intel set fixed tx power
- if(pMgntInfo->IntelProximityModeInfo.PowerOutput > 0)
- {
- switch(pMgntInfo->IntelProximityModeInfo.PowerOutput){
- case 1:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
- break;
- case 2:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_70;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_70\n"));
- break;
- case 3:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_50;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_50\n"));
- break;
- case 4:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_35;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_35\n"));
- break;
- case 5:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_15;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_15\n"));
- break;
- default:
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_100\n"));
- break;
- }
- }
- else
- #endif
- {
- if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) ||
- (pHalData->DMFlag & HAL_DM_HIPWR_DISABLE) ||
- pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- }
- else
- {
- if(pMgntInfo->bMediaConnect) // Default port
- {
- if(ACTING_AS_AP(Adapter) || ACTING_AS_IBSS(Adapter))
- {
- UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- else
- {
- UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- }
- else // associated entry pwdb
- {
- UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
-
- if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
- (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
- }
- }
- }
- if( pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl )
- {
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192C() Channel = %d \n" , pHalData->CurrentChannel));
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- if( (pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) &&
- (pHalData->LastDTPLvl == TxHighPwrLevel_Level1 || pHalData->LastDTPLvl == TxHighPwrLevel_Level2)) //TxHighPwrLevel_Normal
- odm_DynamicTxPowerRestorePowerIndex(pDM_Odm);
- else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
- odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x14);
- else if(pHalData->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
- odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x10);
- }
- pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl;
-
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- #if (RTL8192C_SUPPORT==1)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
- struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
- int UndecoratedSmoothedPWDB;
- if(!pdmpriv->bDynamicTxPowerEnable)
- return;
- #ifdef CONFIG_INTEL_PROXIM
- if(Adapter->proximity.proxim_on== _TRUE){
- struct proximity_priv *prox_priv=Adapter->proximity.proximity_priv;
- // Intel set fixed tx power
- printk("\n %s Adapter->proximity.proxim_on=%d prox_priv->proxim_modeinfo->power_output=%d \n",__FUNCTION__,Adapter->proximity.proxim_on,prox_priv->proxim_modeinfo->power_output);
- if(prox_priv!=NULL){
- if(prox_priv->proxim_modeinfo->power_output> 0)
- {
- switch(prox_priv->proxim_modeinfo->power_output)
- {
- case 1:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
- printk("TxHighPwrLevel_100\n");
- break;
- case 2:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_70;
- printk("TxHighPwrLevel_70\n");
- break;
- case 3:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_50;
- printk("TxHighPwrLevel_50\n");
- break;
- case 4:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_35;
- printk("TxHighPwrLevel_35\n");
- break;
- case 5:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_15;
- printk("TxHighPwrLevel_15\n");
- break;
- default:
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_100;
- printk("TxHighPwrLevel_100\n");
- break;
- }
- }
- }
- }
- else
- #endif
- {
- // STA not connected and AP not connected
- if((check_fwstate(pmlmepriv, _FW_LINKED) != _TRUE) &&
- (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0))
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n"));
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //the LastDTPlvl should reset when disconnect,
- //otherwise the tx power level wouldn't change when disconnect and connect again.
- // Maddest 20091220.
- pdmpriv->LastDTPLvl=TxHighPwrLevel_Normal;
- return;
- }
-
- if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) // Default port
- {
- #if 0
- //todo: AP Mode
- if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) ||
- (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE))
- {
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- else
- {
- UndecoratedSmoothedPWDB = pdmpriv->UndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- #else
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- #endif
- }
- else // associated entry pwdb
- {
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
-
- if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
- (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
- }
- }
- if( (pdmpriv->DynamicTxHighPowerLvl != pdmpriv->LastDTPLvl) )
- {
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Normal) // HP1 -> Normal or HP2 -> Normal
- odm_DynamicTxPowerRestorePowerIndex(pDM_Odm);
- else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
- odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x14);
- else if(pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2)
- odm_DynamicTxPowerWritePowerIndex(pDM_Odm, 0x10);
- }
- pdmpriv->LastDTPLvl = pdmpriv->DynamicTxHighPowerLvl;
- #endif
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- }
- VOID
- odm_DynamicTxPower_92D(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- s4Byte UndecoratedSmoothedPWDB;
- PADAPTER BuddyAdapter = Adapter->BuddyAdapter;
- BOOLEAN bGetValueFromBuddyAdapter = dm_DualMacGetParameterFromBuddyAdapter(Adapter);
- u1Byte HighPowerLvlBackForMac0 = TxHighPwrLevel_Level1;
- // If dynamic high power is disabled.
- if( (pMgntInfo->bDynamicTxPowerEnable != TRUE) ||
- (pHalData->DMFlag & HAL_DM_HIPWR_DISABLE) ||
- pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_HIGH_POWER)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- return;
- }
- // STA not connected and AP not connected
- if((!pMgntInfo->bMediaConnect) &&
- (pHalData->EntryMinUndecoratedSmoothedPWDB == 0))
- {
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n"));
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //the LastDTPlvl should reset when disconnect,
- //otherwise the tx power level wouldn't change when disconnect and connect again.
- // Maddest 20091220.
- pHalData->LastDTPLvl=TxHighPwrLevel_Normal;
- return;
- }
-
- if(pMgntInfo->bMediaConnect) // Default port
- {
- if(ACTING_AS_AP(Adapter) || pMgntInfo->mIbss)
- {
- UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- else
- {
- UndecoratedSmoothedPWDB = pHalData->UndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- }
- else // associated entry pwdb
- {
- UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
-
- if(IS_HARDWARE_TYPE_8192D(Adapter) && GET_HAL_DATA(Adapter)->CurrentBandType == 1){
- if(UndecoratedSmoothedPWDB >= 0x33)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB <0x33) &&
- (UndecoratedSmoothedPWDB >= 0x2b) )
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < 0x2b)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Normal\n"));
- }
- }
- else
-
- {
- if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
- (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
- {
- pHalData->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
- }
- }
- //sherry delete flag 20110517
- if(bGetValueFromBuddyAdapter)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 1 \n"));
- if(Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() change value \n"));
- HighPowerLvlBackForMac0 = pHalData->DynamicTxHighPowerLvl;
- pHalData->DynamicTxHighPowerLvl = Adapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP;
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- pHalData->DynamicTxHighPowerLvl = HighPowerLvlBackForMac0;
- Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = FALSE;
- }
- }
- if( (pHalData->DynamicTxHighPowerLvl != pHalData->LastDTPLvl) )
- {
- ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192S() Channel = %d \n" , pHalData->CurrentChannel));
- if(Adapter->DualMacSmartConcurrent == TRUE)
- {
- if(BuddyAdapter == NULL)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter == NULL case \n"));
- if(!Adapter->bSlaveOfDMSP)
- {
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- }
- }
- else
- {
- if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMSP \n"));
- if(Adapter->bSlaveOfDMSP)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() bslave case \n"));
- BuddyAdapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = TRUE;
- BuddyAdapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP = pHalData->DynamicTxHighPowerLvl;
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() master case \n"));
- if(!bGetValueFromBuddyAdapter)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 0 \n"));
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- }
- }
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMDP\n"));
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- }
- }
- }
- else
- {
- PHY_SetTxPowerLevel8192C(Adapter, pHalData->CurrentChannel);
- }
- }
- pHalData->LastDTPLvl = pHalData->DynamicTxHighPowerLvl;
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- #if (RTL8192D_SUPPORT==1)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- DM_ODM_T *podmpriv = &pHalData->odmpriv;
- int UndecoratedSmoothedPWDB;
- #if (RTL8192D_EASY_SMART_CONCURRENT == 1)
- PADAPTER BuddyAdapter = Adapter->BuddyAdapter;
- BOOLEAN bGetValueFromBuddyAdapter = DualMacGetParameterFromBuddyAdapter(Adapter);
- u8 HighPowerLvlBackForMac0 = TxHighPwrLevel_Level1;
- #endif
- // If dynamic high power is disabled.
- if( (pdmpriv->bDynamicTxPowerEnable != _TRUE) ||
- (!(podmpriv->SupportAbility& ODM_BB_DYNAMIC_TXPWR)) )
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- return;
- }
- // STA not connected and AP not connected
- if((check_fwstate(pmlmepriv, _FW_LINKED) != _TRUE) &&
- (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0))
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("Not connected to any \n"));
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //the LastDTPlvl should reset when disconnect,
- //otherwise the tx power level wouldn't change when disconnect and connect again.
- // Maddest 20091220.
- pdmpriv->LastDTPLvl=TxHighPwrLevel_Normal;
- return;
- }
-
- if(check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) // Default port
- {
- #if 0
- //todo: AP Mode
- if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == _TRUE) ||
- (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == _TRUE))
- {
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Client PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- else
- {
- UndecoratedSmoothedPWDB = pdmpriv->UndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("STA Default Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- #else
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- #endif
- }
- else // associated entry pwdb
- {
- UndecoratedSmoothedPWDB = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("AP Ext Port PWDB = 0x%x \n", UndecoratedSmoothedPWDB));
- }
- #if TX_POWER_FOR_5G_BAND == 1
- if(pHalData->CurrentBandType92D == BAND_ON_5G){
- if(UndecoratedSmoothedPWDB >= 0x33)
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level2 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB <0x33) &&
- (UndecoratedSmoothedPWDB >= 0x2b) )
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < 0x2b)
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("5G:TxHighPwrLevel_Normal\n"));
- }
- }
- else
- #endif
- {
- if(UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL2)
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level2;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x0)\n"));
- }
- else if((UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL2-3)) &&
- (UndecoratedSmoothedPWDB >= TX_POWER_NEAR_FIELD_THRESH_LVL1) )
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Level1;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Level1 (TxPwr=0x10)\n"));
- }
- else if(UndecoratedSmoothedPWDB < (TX_POWER_NEAR_FIELD_THRESH_LVL1-5))
- {
- pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal;
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("TxHighPwrLevel_Normal\n"));
- }
- }
- #if (RTL8192D_EASY_SMART_CONCURRENT == 1)
- if(bGetValueFromBuddyAdapter)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 1 \n"));
- if(Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() change value \n"));
- HighPowerLvlBackForMac0 = pHalData->DynamicTxHighPowerLvl;
- pHalData->DynamicTxHighPowerLvl = Adapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP;
- PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel);
- pHalData->DynamicTxHighPowerLvl = HighPowerLvlBackForMac0;
- Adapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = _FALSE;
- }
- }
- #endif
- if( (pdmpriv->DynamicTxHighPowerLvl != pdmpriv->LastDTPLvl) )
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_HIPWR, DBG_LOUD, ("PHY_SetTxPowerLevel8192S() Channel = %d \n" , pHalData->CurrentChannel));
- #if (RTL8192D_EASY_SMART_CONCURRENT == 1)
- if(BuddyAdapter == NULL)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter == NULL case \n"));
- if(!Adapter->bSlaveOfDMSP)
- {
- PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel);
- }
- }
- else
- {
- if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMSP \n"));
- if(Adapter->bSlaveOfDMSP)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() bslave case \n"));
- BuddyAdapter->DualMacDMSPControl.bChangeTxHighPowerLvlForAnotherMacOfDMSP = _TRUE;
- BuddyAdapter->DualMacDMSPControl.CurTxHighLvlForAnotherMacOfDMSP = pHalData->DynamicTxHighPowerLvl;
- }
- else
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() master case \n"));
- if(!bGetValueFromBuddyAdapter)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() mac 0 for mac 0 \n"));
- PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel);
- }
- }
- }
- else
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_MLME,DBG_LOUD,("dm_DynamicTxPower() BuddyAdapter DMDP\n"));
- PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel);
- }
- }
- #else
- PHY_SetTxPowerLevel8192D(Adapter, pHalData->CurrentChannel);
- #endif
- }
- pdmpriv->LastDTPLvl = pdmpriv->DynamicTxHighPowerLvl;
- #endif
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- }
- //3============================================================
- //3 RSSI Monitor
- //3============================================================
- VOID
- odm_RSSIDumpToRegister(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- if(pDM_Odm->SupportICType == ODM_RTL8812)
- {
- PlatformEFIOWrite1Byte(Adapter, rA_RSSIDump_Jaguar, Adapter->RxStats.RxRSSIPercentage[0]);
- PlatformEFIOWrite1Byte(Adapter, rB_RSSIDump_Jaguar, Adapter->RxStats.RxRSSIPercentage[1]);
- // Rx EVM
- PlatformEFIOWrite1Byte(Adapter, rS1_RXevmDump_Jaguar, Adapter->RxStats.RxEVMdbm[0]);
- PlatformEFIOWrite1Byte(Adapter, rS2_RXevmDump_Jaguar, Adapter->RxStats.RxEVMdbm[1]);
- // Rx SNR
- PlatformEFIOWrite1Byte(Adapter, rA_RXsnrDump_Jaguar, (u1Byte)(Adapter->RxStats.RxSNRdB[0]));
- PlatformEFIOWrite1Byte(Adapter, rB_RXsnrDump_Jaguar, (u1Byte)(Adapter->RxStats.RxSNRdB[1]));
- // Rx Cfo_Short
- PlatformEFIOWrite2Byte(Adapter, rA_CfoShortDump_Jaguar, Adapter->RxStats.RxCfoShort[0]);
- PlatformEFIOWrite2Byte(Adapter, rB_CfoShortDump_Jaguar, Adapter->RxStats.RxCfoShort[1]);
- // Rx Cfo_Tail
- PlatformEFIOWrite2Byte(Adapter, rA_CfoLongDump_Jaguar, Adapter->RxStats.RxCfoTail[0]);
- PlatformEFIOWrite2Byte(Adapter, rB_CfoLongDump_Jaguar, Adapter->RxStats.RxCfoTail[1]);
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8192E)
- {
- PlatformEFIOWrite1Byte(Adapter, rA_RSSIDump_92E, Adapter->RxStats.RxRSSIPercentage[0]);
- PlatformEFIOWrite1Byte(Adapter, rB_RSSIDump_92E, Adapter->RxStats.RxRSSIPercentage[1]);
- // Rx EVM
- PlatformEFIOWrite1Byte(Adapter, rS1_RXevmDump_92E, Adapter->RxStats.RxEVMdbm[0]);
- PlatformEFIOWrite1Byte(Adapter, rS2_RXevmDump_92E, Adapter->RxStats.RxEVMdbm[1]);
- // Rx SNR
- PlatformEFIOWrite1Byte(Adapter, rA_RXsnrDump_92E, (u1Byte)(Adapter->RxStats.RxSNRdB[0]));
- PlatformEFIOWrite1Byte(Adapter, rB_RXsnrDump_92E, (u1Byte)(Adapter->RxStats.RxSNRdB[1]));
- // Rx Cfo_Short
- PlatformEFIOWrite2Byte(Adapter, rA_CfoShortDump_92E, Adapter->RxStats.RxCfoShort[0]);
- PlatformEFIOWrite2Byte(Adapter, rB_CfoShortDump_92E, Adapter->RxStats.RxCfoShort[1]);
- // Rx Cfo_Tail
- PlatformEFIOWrite2Byte(Adapter, rA_CfoLongDump_92E, Adapter->RxStats.RxCfoTail[0]);
- PlatformEFIOWrite2Byte(Adapter, rB_CfoLongDump_92E, Adapter->RxStats.RxCfoTail[1]);
- }
- #endif
- }
- VOID
- odm_RSSIMonitorInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- }
- VOID
- odm_RSSIMonitorCheck(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //
- // For AP/ADSL use prtl8192cd_priv
- // For CE/NIC use PADAPTER
- //
- if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR))
- return;
-
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- odm_RSSIMonitorCheckMP(pDM_Odm);
- break;
- case ODM_CE:
- odm_RSSIMonitorCheckCE(pDM_Odm);
- break;
- case ODM_AP:
- odm_RSSIMonitorCheckAP(pDM_Odm);
- break;
- case ODM_ADSL:
- //odm_DIGAP(pDM_Odm);
- break;
- }
-
- } // odm_RSSIMonitorCheck
- VOID
- odm_RSSIMonitorCheckMP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PRT_WLAN_STA pEntry;
- u1Byte i;
- s4Byte tmpEntryMaxPWDB=0, tmpEntryMinPWDB=0xff;
- u1Byte H2C_Parameter[4] ={0};
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- u8Byte curTxOkCnt = 0;
- u8Byte curRxOkCnt = 0;
- BEAMFORMING_CAP Beamform_cap = BEAMFORMING_CAP_NONE;
- u1Byte TxBF_EN = 0;
-
- RT_DISP(FDM, DM_PWDB, ("pHalData->UndecoratedSmoothedPWDB = 0x%x( %d)\n",
- pHalData->UndecoratedSmoothedPWDB,
- pHalData->UndecoratedSmoothedPWDB));
- curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - pMgntInfo->lastTxOkCnt;
- curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - pMgntInfo->lastRxOkCnt;
- pMgntInfo->lastTxOkCnt = curTxOkCnt;
- pMgntInfo->lastRxOkCnt = curRxOkCnt;
-
- RT_DISP(FDM, DM_PWDB, ("Tx = %d Rx = %d\n", curTxOkCnt, curRxOkCnt));
-
- if(pDM_Odm->SupportICType == ODM_RTL8188E && (pMgntInfo->CustomerID==RT_CID_819x_HP))
- {
- if(curRxOkCnt >(curTxOkCnt*6))
- {
- PlatformEFIOWrite4Byte(Adapter, REG_ARFR0, 0x8f015);
- }
- else
- {
- PlatformEFIOWrite4Byte(Adapter, REG_ARFR0, 0xff015);
- }
- }
- if((pDM_Odm->SupportICType == ODM_RTL8812) || pDM_Odm->SupportICType == ODM_RTL8821)
- {
- if(curRxOkCnt >(curTxOkCnt*6))
- H2C_Parameter[3]=0x01;
- else
- H2C_Parameter[3]=0x00;
- }
- if(pDM_Odm->SupportICType == ODM_RTL8192E || pDM_Odm->SupportICType == ODM_RTL8812)
- {
- u1Byte STBC_TX = 0;
- PRT_HIGH_THROUGHPUT pHTInfo = GET_HT_INFO(pMgntInfo);
- PRT_VERY_HIGH_THROUGHPUT pVHTInfo = GET_VHT_INFO(pMgntInfo);
- if(IS_WIRELESS_MODE_AC_5G(Adapter))
- STBC_TX = TEST_FLAG(pVHTInfo->VhtCurStbc, STBC_VHT_ENABLE_TX);
- else
- STBC_TX = TEST_FLAG(pHTInfo->HtCurStbc, STBC_HT_ENABLE_TX);
-
- H2C_Parameter[3] |= STBC_TX<<1;
- }
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- {
- pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
- }
- else
- {
- pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
- }
- if(pEntry!=NULL)
- {
- if(pEntry->bAssociated)
- {
- RT_DISP_ADDR(FDM, DM_PWDB, ("pEntry->MacAddr ="), pEntry->MacAddr);
- RT_DISP(FDM, DM_PWDB, ("pEntry->rssi = 0x%x(%d)\n",
- pEntry->rssi_stat.UndecoratedSmoothedPWDB,
- pEntry->rssi_stat.UndecoratedSmoothedPWDB));
- if(pDM_Odm->SupportICType == ODM_RTL8192E)
- {
- Beamform_cap = Beamforming_GetEntryBeamCapByMacId(pMgntInfo, pEntry->AssociatedMacId);
- if(Beamform_cap == BEAMFORMER_CAP_HT_EXPLICIT || Beamform_cap == BEAMFORMER_CAP_VHT_SU ||
- Beamform_cap == (BEAMFORMER_CAP_HT_EXPLICIT|BEAMFORMEE_CAP_HT_EXPLICIT) ||
- Beamform_cap == (BEAMFORMER_CAP_VHT_SU|BEAMFORMEE_CAP_VHT_SU))
- TxBF_EN = 1;
- H2C_Parameter[3] |= TxBF_EN << 6;
- }
-
- if(pEntry->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
- tmpEntryMinPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
- if(pEntry->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
- tmpEntryMaxPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
- H2C_Parameter[2] = (u1Byte)(pEntry->rssi_stat.UndecoratedSmoothedPWDB & 0xFF);
- H2C_Parameter[1] = 0x20; // fw v12 cmdid 5:use max macid ,for nic ,default macid is 0 ,max macid is 1
- H2C_Parameter[0] = (pEntry->AssociatedMacId);
- if(pDM_Odm->SupportICType == ODM_RTL8812)
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 4, H2C_Parameter);
- else if(pDM_Odm->SupportICType == ODM_RTL8192E)
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 4, H2C_Parameter);
- else
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 3, H2C_Parameter);
- }
- }
- else
- {
- break;
- }
- }
- if(tmpEntryMaxPWDB != 0) // If associated entry is found
- {
- pHalData->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
- RT_DISP(FDM, DM_PWDB, ("EntryMaxPWDB = 0x%x(%d)\n", tmpEntryMaxPWDB, tmpEntryMaxPWDB));
- }
- else
- {
- pHalData->EntryMaxUndecoratedSmoothedPWDB = 0;
- }
-
- if(tmpEntryMinPWDB != 0xff) // If associated entry is found
- {
- pHalData->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
- RT_DISP(FDM, DM_PWDB, ("EntryMinPWDB = 0x%x(%d)\n", tmpEntryMinPWDB, tmpEntryMinPWDB));
- }
- else
- {
- pHalData->EntryMinUndecoratedSmoothedPWDB = 0;
- }
- // Indicate Rx signal strength to FW.
- if(pMgntInfo->bUseRAMask)
- {
- if(pDM_Odm->SupportICType == ODM_RTL8192E)
- {
- Beamform_cap = Beamforming_GetEntryBeamCapByMacId(pMgntInfo, pMgntInfo->mMacId);
- if(Beamform_cap == BEAMFORMER_CAP_HT_EXPLICIT || Beamform_cap == BEAMFORMER_CAP_VHT_SU ||
- Beamform_cap == (BEAMFORMER_CAP_HT_EXPLICIT|BEAMFORMEE_CAP_HT_EXPLICIT) ||
- Beamform_cap == (BEAMFORMER_CAP_VHT_SU|BEAMFORMEE_CAP_VHT_SU))
- TxBF_EN = 1;
-
- H2C_Parameter[3] |= TxBF_EN << 6;
- }
-
- H2C_Parameter[2] = (u1Byte)(pHalData->UndecoratedSmoothedPWDB & 0xFF);
- H2C_Parameter[1] = 0x20; // fw v12 cmdid 5:use max macid ,for nic ,default macid is 0 ,max macid is 1
- H2C_Parameter[0] = 0; // fw v12 cmdid 5:use max macid ,for nic ,default macid is 0 ,max macid is 1
- if(pDM_Odm->SupportICType == ODM_RTL8812)
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 4, H2C_Parameter);
- else if(pDM_Odm->SupportICType == ODM_RTL8192E)
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 4, H2C_Parameter);
- else
- ODM_FillH2CCmd(Adapter, ODM_H2C_RSSI_REPORT, 3, H2C_Parameter);
- }
- else
- {
- PlatformEFIOWrite1Byte(Adapter, 0x4fe, (u1Byte)pHalData->UndecoratedSmoothedPWDB);
- //DbgPrint("0x4fe write %x %d\n", pHalData->UndecoratedSmoothedPWDB, pHalData->UndecoratedSmoothedPWDB);
- }
- if((pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8192E))
- odm_RSSIDumpToRegister(pDM_Odm);
- odm_FindMinimumRSSI(Adapter);
- ODM_CmnInfoUpdate(&pHalData->DM_OutSrc ,ODM_CMNINFO_LINK, (u8Byte)pHalData->bLinked);
- ODM_CmnInfoUpdate(&pHalData->DM_OutSrc ,ODM_CMNINFO_RSSI_MIN, (u8Byte)pHalData->MinUndecoratedPWDBForDM);
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- }
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- //
- //sherry move from DUSC to here 20110517
- //
- static VOID
- FindMinimumRSSI_Dmsp(
- IN PADAPTER pAdapter
- )
- {
- #if 0
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- s32 Rssi_val_min_back_for_mac0;
- BOOLEAN bGetValueFromBuddyAdapter = dm_DualMacGetParameterFromBuddyAdapter(pAdapter);
- BOOLEAN bRestoreRssi = _FALSE;
- PADAPTER BuddyAdapter = pAdapter->BuddyAdapter;
- if(pHalData->MacPhyMode92D == DUALMAC_SINGLEPHY)
- {
- if(BuddyAdapter!= NULL)
- {
- if(pHalData->bSlaveOfDMSP)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_EASY_CONCURRENT,DBG_LOUD,("bSlavecase of dmsp\n"));
- BuddyAdapter->DualMacDMSPControl.RssiValMinForAnotherMacOfDMSP = pdmpriv->MinUndecoratedPWDBForDM;
- }
- else
- {
- if(bGetValueFromBuddyAdapter)
- {
- //ODM_RT_TRACE(pDM_Odm,COMP_EASY_CONCURRENT,DBG_LOUD,("get new RSSI\n"));
- bRestoreRssi = _TRUE;
- Rssi_val_min_back_for_mac0 = pdmpriv->MinUndecoratedPWDBForDM;
- pdmpriv->MinUndecoratedPWDBForDM = pAdapter->DualMacDMSPControl.RssiValMinForAnotherMacOfDMSP;
- }
- }
- }
-
- }
- if(bRestoreRssi)
- {
- bRestoreRssi = _FALSE;
- pdmpriv->MinUndecoratedPWDBForDM = Rssi_val_min_back_for_mac0;
- }
- #endif
- }
- static void
- FindMinimumRSSI(
- IN PADAPTER pAdapter
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- PDM_ODM_T pDM_Odm = &(pHalData->odmpriv);
- //1 1.Determine the minimum RSSI
- if((pDM_Odm->bLinked != _TRUE) &&
- (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0))
- {
- pdmpriv->MinUndecoratedPWDBForDM = 0;
- //ODM_RT_TRACE(pDM_Odm,COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any \n"));
- }
- else
- {
- pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB;
- }
- //DBG_8192C("%s=>MinUndecoratedPWDBForDM(%d)\n",__FUNCTION__,pdmpriv->MinUndecoratedPWDBForDM);
- //ODM_RT_TRACE(pDM_Odm,COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n",pHalData->MinUndecoratedPWDBForDM));
- }
- #endif
- VOID
- odm_RSSIMonitorCheckCE(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- int i;
- int tmpEntryMaxPWDB=0, tmpEntryMinPWDB=0xff;
- u8 sta_cnt=0;
- u8 UL_DL_STATE = 0;// for 8812 use
- u32 PWDB_rssi[NUM_STA]={0};//[0~15]:MACID, [16~31]:PWDB_rssi
- if(pDM_Odm->bLinked != _TRUE)
- return;
- #if((RTL8812A_SUPPORT==1)||(RTL8821A_SUPPORT==1))
- if((pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8821))
- {
- u64 curTxOkCnt = Adapter->xmitpriv.tx_bytes - Adapter->xmitpriv.last_tx_bytes;
- u64 curRxOkCnt = Adapter->recvpriv.rx_bytes - Adapter->recvpriv.last_rx_bytes;
- if(curRxOkCnt >(curTxOkCnt*6))
- UL_DL_STATE = 1;
- else
- UL_DL_STATE = 0;
- }
- #endif
- #if(RTL8192E_SUPPORT==1)
- /*
- if(pDM_Odm->SupportICType == ODM_RTL8192E)
- {
- STBC_TX = ((pMgntInfo->pHTInfo->HtCurStbc)&0x02)>>1;
- H2C_Parameter[4] = STBC_TX;
- }
- */
- #endif
-
- //if(check_fwstate(&Adapter->mlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == _TRUE)
- {
- #if 1
- struct sta_info *psta;
-
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) {
- if (IS_STA_VALID(psta = pDM_Odm->pODM_StaInfo[i]))
- {
- if(psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
- tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
- if(psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
- tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
- #if 0
- DBG_871X("%s mac_id:%u, mac:"MAC_FMT", rssi:%d\n", __func__,
- psta->mac_id, MAC_ARG(psta->hwaddr), psta->rssi_stat.UndecoratedSmoothedPWDB);
- #endif
- if(psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) {
-
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) | ((Adapter->stapriv.asoc_sta_count+1) << 8));
- else if ((pDM_Odm->SupportICType == ODM_RTL8192E)||(pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8821))
- PWDB_rssi[sta_cnt++] = (((u8)(psta->mac_id&0xFF)) | ((psta->rssi_stat.UndecoratedSmoothedPWDB&0x7F)<<16) );
- else
- PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) );
-
- }
- }
- }
- #else
- _irqL irqL;
- _list *plist, *phead;
- struct sta_info *psta;
- struct sta_priv *pstapriv = &Adapter->stapriv;
- u8 bcast_addr[ETH_ALEN]= {0xff,0xff,0xff,0xff,0xff,0xff};
- _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL);
- for(i=0; i< NUM_STA; i++)
- {
- phead = &(pstapriv->sta_hash[i]);
- plist = get_next(phead);
-
- while ((rtw_end_of_queue_search(phead, plist)) == _FALSE)
- {
- psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
- plist = get_next(plist);
- if(_rtw_memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) ||
- _rtw_memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN))
- continue;
- if(psta->state & WIFI_ASOC_STATE)
- {
-
- if(psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
- tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
- if(psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB)
- tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
- if(psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)){
- //printk("%s==> mac_id(%d),rssi(%d)\n",__FUNCTION__,psta->mac_id,psta->rssi_stat.UndecoratedSmoothedPWDB);
- #if(RTL8192D_SUPPORT==1)
- PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) | ((Adapter->stapriv.asoc_sta_count+1) << 8));
- #else
- PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16) );
- #endif
- }
- }
-
- }
- }
-
- _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL);
- #endif
- //printk("%s==> sta_cnt(%d)\n",__FUNCTION__,sta_cnt);
- for(i=0; i< sta_cnt; i++)
- {
- if(PWDB_rssi[i] != (0)){
- if(pHalData->fw_ractrl == _TRUE)// Report every sta's RSSI to FW
- {
- #if(RTL8192D_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192D){
- FillH2CCmd92D(Adapter, H2C_RSSI_REPORT, 3, (u8 *)(&PWDB_rssi[i]));
- }
- #endif
-
-
- #if((RTL8192C_SUPPORT==1)||(RTL8723A_SUPPORT==1))
- if((pDM_Odm->SupportICType == ODM_RTL8192C)||(pDM_Odm->SupportICType == ODM_RTL8723A)){
- rtl8192c_set_rssi_cmd(Adapter, (u8*)&PWDB_rssi[i]);
- }
- #endif
-
- #if((RTL8812A_SUPPORT==1)||(RTL8821A_SUPPORT==1))
- if((pDM_Odm->SupportICType == ODM_RTL8812)||(pDM_Odm->SupportICType == ODM_RTL8821)){
- PWDB_rssi[i] |= (UL_DL_STATE << 24);
- rtl8812_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
- }
- #endif
- #if(RTL8192E_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8192E){
- PWDB_rssi[i] |= (UL_DL_STATE << 24);
- rtl8192e_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i]));
- }
- #endif
- }
- else{
- #if((RTL8188E_SUPPORT==1)&&(RATE_ADAPTIVE_SUPPORT == 1))
- if(pDM_Odm->SupportICType == ODM_RTL8188E){
- ODM_RA_SetRSSI_8188E(
- &(pHalData->odmpriv), (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF));
- }
- #endif
- }
- }
- }
- }
- if(tmpEntryMaxPWDB != 0) // If associated entry is found
- {
- pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB;
- }
- else
- {
- pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0;
- }
- if(tmpEntryMinPWDB != 0xff) // If associated entry is found
- {
- pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB;
- }
- else
- {
- pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0;
- }
- FindMinimumRSSI(Adapter);//get pdmpriv->MinUndecoratedPWDBForDM
- #if(RTL8192D_SUPPORT==1)
- FindMinimumRSSI_Dmsp(Adapter);
- #endif
- ODM_CmnInfoUpdate(&pHalData->odmpriv ,ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM);
- #endif//if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- }
- VOID
- odm_RSSIMonitorCheckAP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
- #ifdef CONFIG_RTL_92C_SUPPORT || defined(CONFIG_RTL_92D_SUPPORT)
- u4Byte i;
- PSTA_INFO_T pstat;
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- pstat = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pstat) )
- {
- #ifdef STA_EXT
- if (REMAP_AID(pstat) < (FW_NUM_STAT - 1))
- #endif
- add_update_rssi(pDM_Odm->priv, pstat);
- }
- }
- #endif
- #endif
- }
- VOID
- ODM_InitAllTimers(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if(defined(CONFIG_SW_ANTENNA_DIVERSITY))
- ODM_InitializeTimer(pDM_Odm,&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer,
- (RT_TIMER_CALL_BACK)odm_SwAntDivChkAntSwitchCallback, NULL, "SwAntennaSwitchTimer");
- #endif
- #if (!(DM_ODM_SUPPORT_TYPE == ODM_CE))
- #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- #if (RTL8188E_SUPPORT == 1)
- ODM_InitializeTimer(pDM_Odm,&pDM_Odm->FastAntTrainingTimer,
- (RT_TIMER_CALL_BACK)odm_FastAntTrainingCallback, NULL, "FastAntTrainingTimer");
- #endif
- #endif
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- ODM_InitializeTimer(pDM_Odm, &pDM_Odm->PSDTimer,
- (RT_TIMER_CALL_BACK)dm_PSDMonitorCallback, NULL, "PSDTimer");
- //
- //Path Diversity
- //Neil Chen--2011--06--16-- / 2012/02/23 MH Revise Arch.
- //
- ODM_InitializeTimer(pDM_Odm, &pDM_Odm->PathDivSwitchTimer,
- (RT_TIMER_CALL_BACK)odm_PathDivChkAntSwitchCallback, NULL, "PathDivTimer");
- ODM_InitializeTimer(pDM_Odm, &pDM_Odm->CCKPathDiversityTimer,
- (RT_TIMER_CALL_BACK)odm_CCKTXPathDiversityCallback, NULL, "CCKPathDiversityTimer");
- ODM_InitializeTimer(pDM_Odm, &pDM_Odm->MPT_DIGTimer,
- (RT_TIMER_CALL_BACK)odm_MPT_DIGCallback, NULL, "MPT_DIGTimer");
- ODM_InitializeTimer(pDM_Odm, &pDM_Odm->DM_RXHP_Table.PSDTimer,
- (RT_TIMER_CALL_BACK)odm_PSD_RXHPCallback, NULL, "PSDRXHPTimer");
- #endif
- }
- VOID
- ODM_CancelAllTimers(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- //
- // 2012/01/12 MH Temp BSOD fix. We need to find NIC allocate mem fail reason in
- // win7 platform.
- //
- HAL_ADAPTER_STS_CHK(pDM_Odm)
- #endif
- #if(defined(CONFIG_SW_ANTENNA_DIVERSITY))
- ODM_CancelTimer(pDM_Odm,&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer);
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- #if (RTL8188E_SUPPORT == 1)
- ODM_CancelTimer(pDM_Odm,&pDM_Odm->FastAntTrainingTimer);
- #endif
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->PSDTimer);
- //
- //Path Diversity
- //Neil Chen--2011--06--16-- / 2012/02/23 MH Revise Arch.
- //
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->PathDivSwitchTimer);
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->CCKPathDiversityTimer);
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->MPT_DIGTimer);
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->DM_RXHP_Table.PSDTimer);
- #endif
- }
- VOID
- ODM_ReleaseAllTimers(
- IN PDM_ODM_T pDM_Odm
- )
- {
- ODM_ReleaseTimer(pDM_Odm,&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer);
- #if (RTL8188E_SUPPORT == 1)
- ODM_ReleaseTimer(pDM_Odm,&pDM_Odm->FastAntTrainingTimer);
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->PSDTimer);
- //
- //Path Diversity
- //Neil Chen--2011--06--16-- / 2012/02/23 MH Revise Arch.
- //
- ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->PathDivSwitchTimer);
- ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->CCKPathDiversityTimer);
- ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->MPT_DIGTimer);
- ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->DM_RXHP_Table.PSDTimer);
- #endif
- }
- //#endif
- //3============================================================
- //3 Tx Power Tracking
- //3============================================================
- VOID
- odm_TXPowerTrackingInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- odm_TXPowerTrackingThermalMeterInit(pDM_Odm);
- }
- u1Byte
- getSwingIndex(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u1Byte i = 0;
- u4Byte bbSwing;
- #if ((RTL8812A_SUPPORT==1)||(RTL8821A_SUPPORT==1))
- bbSwing = PHY_GetTxBBSwing_8812A(Adapter, pHalData->CurrentBandType, ODM_RF_PATH_A);
- #endif
- for (i = 0; i < TXSCALE_TABLE_SIZE; ++i)
- if ( bbSwing == TxScalingTable_Jaguar[i])
- break;
-
- return i;
- }
- VOID
- odm_TXPowerTrackingThermalMeterInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- u1Byte p = 0;
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- #if MP_DRIVER != 1 //for mp driver, turn off txpwrtracking as default
- pHalData->TxPowerTrackControl = TRUE;
- #endif//#if (MP_DRIVER != 1)
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
-
- #if( (RTL8188E_SUPPORT==1) || (RTL8812A_SUPPORT==1) || (RTL8821A_SUPPORT==1) ||(RTL8192E_SUPPORT==1) )
- {
- pDM_Odm->RFCalibrateInfo.bTXPowerTracking = _TRUE;
- pDM_Odm->RFCalibrateInfo.TXPowercount = 0;
- pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = _FALSE;
- //#if (MP_DRIVER != 1) //for mp driver, turn off txpwrtracking as default
- if ( *(pDM_Odm->mp_mode) != 1)
- pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = _TRUE;
- //#endif//#if (MP_DRIVER != 1)
- MSG_8192C("pDM_Odm TxPowerTrackControl = %d\n", pDM_Odm->RFCalibrateInfo.TxPowerTrackControl);
- }
- #else
- {
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- //if(IS_HARDWARE_TYPE_8192C(pHalData))
- {
- pdmpriv->bTXPowerTracking = _TRUE;
- pdmpriv->TXPowercount = 0;
- pdmpriv->bTXPowerTrackingInit = _FALSE;
- //#if (MP_DRIVER != 1) //for mp driver, turn off txpwrtracking as default
- if (*(pDM_Odm->mp_mode) != 1)
- pdmpriv->TxPowerTrackControl = _TRUE;
- //#endif//#if (MP_DRIVER != 1)
- }
- MSG_8192C("pdmpriv->TxPowerTrackControl = %d\n", pdmpriv->TxPowerTrackControl);
-
- }
- #endif//endif (CONFIG_RTL8188E==1)
- #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- #ifdef RTL8188E_SUPPORT
- {
- pDM_Odm->RFCalibrateInfo.bTXPowerTracking = _TRUE;
- pDM_Odm->RFCalibrateInfo.TXPowercount = 0;
- pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = _FALSE;
- pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = _TRUE;
- }
- #endif
- #endif
- pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = TRUE;
- pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter;
- pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter;
- pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter;
- // The index of "0 dB" in SwingTable.
- if (pDM_Odm->SupportICType == ODM_RTL8188E || pDM_Odm->SupportICType == ODM_RTL8723B ||
- pDM_Odm->SupportICType == ODM_RTL8192E)
- {
- pDM_Odm->DefaultOfdmIndex = 30;
- pDM_Odm->DefaultCckIndex = 20;
- } else {
- u1Byte defaultSwingIndex = getSwingIndex(pDM_Odm);
- pDM_Odm->DefaultOfdmIndex = (defaultSwingIndex == TXSCALE_TABLE_SIZE) ? 24 : defaultSwingIndex;
- pDM_Odm->DefaultCckIndex = 24;
- }
- pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex;
- pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex;
-
- for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p)
- {
- pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex;
- pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex;
- pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0;
- pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0;
- pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0;
- }
- }
- VOID
- ODM_TXPowerTrackingCheck(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //
- // For AP/ADSL use prtl8192cd_priv
- // For CE/NIC use PADAPTER
- //
- //if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
- //return;
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- odm_TXPowerTrackingCheckMP(pDM_Odm);
- break;
- case ODM_CE:
- odm_TXPowerTrackingCheckCE(pDM_Odm);
- break;
- case ODM_AP:
- odm_TXPowerTrackingCheckAP(pDM_Odm);
- break;
- case ODM_ADSL:
- //odm_DIGAP(pDM_Odm);
- break;
- }
- }
- VOID
- odm_TXPowerTrackingCheckCE(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- #if( (RTL8192C_SUPPORT==1) || (RTL8723A_SUPPORT==1) )
- if(IS_HARDWARE_TYPE_8192C(Adapter)){
- rtl8192c_odm_CheckTXPowerTracking(Adapter);
- return;
- }
- #endif
- #if (RTL8192D_SUPPORT==1)
- if(IS_HARDWARE_TYPE_8192D(Adapter)){
- #if (RTL8192D_EASY_SMART_CONCURRENT == 1)
- if(!Adapter->bSlaveOfDMSP)
- #endif
- rtl8192d_odm_CheckTXPowerTracking(Adapter);
- return;
- }
- #endif
- #if(((RTL8188E_SUPPORT==1) || (RTL8812A_SUPPORT==1) || (RTL8821A_SUPPORT==1) || (RTL8192E_SUPPORT==1) || (RTL8723B_SUPPORT==1) ))
- if(!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK))
- {
- return;
- }
- if(!pDM_Odm->RFCalibrateInfo.TM_Trigger) //at least delay 1 sec
- {
- //pHalData->TxPowerCheckCnt++; //cosa add for debug
- if(IS_HARDWARE_TYPE_8188E(Adapter) || IS_HARDWARE_TYPE_JAGUAR(Adapter) || IS_HARDWARE_TYPE_8192E(Adapter) )//||IS_HARDWARE_TYPE_8723B(Adapter))
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03);
- else
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_T_METER_OLD, bRFRegOffsetMask, 0x60);
-
- //DBG_871X("Trigger Thermal Meter!!\n");
-
- pDM_Odm->RFCalibrateInfo.TM_Trigger = 1;
- return;
- }
- else
- {
- //DBG_871X("Schedule TxPowerTracking direct call!!\n");
- ODM_TXPowerTrackingCallback_ThermalMeter(Adapter);
- pDM_Odm->RFCalibrateInfo.TM_Trigger = 0;
- }
- #endif
- #endif
- }
- VOID
- odm_TXPowerTrackingCheckMP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- PADAPTER Adapter = pDM_Odm->Adapter;
- if (ODM_CheckPowerStatus(Adapter) == FALSE)
- {
- RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("===>ODM_CheckPowerStatus() return FALSE\n"));
- return;
- }
- if(IS_HARDWARE_TYPE_8723A(Adapter))
- return;
- if(!Adapter->bSlaveOfDMSP || Adapter->DualMacSmartConcurrent == FALSE)
- odm_TXPowerTrackingThermalMeterCheck(Adapter);
- else {
- RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("!Adapter->bSlaveOfDMSP || Adapter->DualMacSmartConcurrent == FALSE\n"));
- }
- #endif
-
- }
- VOID
- odm_TXPowerTrackingCheckAP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE == ODM_AP)
- prtl8192cd_priv priv = pDM_Odm->priv;
- if ( (priv->pmib->dot11RFEntry.ther) && ((priv->up_time % priv->pshare->rf_ft_var.tpt_period) == 0)){
- #ifdef CONFIG_RTL_92D_SUPPORT
- if (GET_CHIP_VER(priv)==VERSION_8192D){
- tx_power_tracking_92D(priv);
- } else
- #endif
- {
- #ifdef CONFIG_RTL_92C_SUPPORT
- tx_power_tracking(priv);
- #endif
- }
- }
- #endif
- }
- //antenna mapping info
- // 1: right-side antenna
- // 2/0: left-side antenna
- //PDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt: for right-side antenna: Ant:1 RxDefaultAnt1
- //PDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt: for left-side antenna: Ant:0 RxDefaultAnt2
- // We select left antenna as default antenna in initial process, modify it as needed
- //
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_TXPowerTrackingThermalMeterCheck(
- IN PADAPTER Adapter
- )
- {
- #ifndef AP_BUILD_WORKAROUND
- static u1Byte TM_Trigger = 0;
- if(!(GET_HAL_DATA(Adapter)->DM_OutSrc.SupportAbility & ODM_RF_TX_PWR_TRACK))
- {
- RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,
- ("===>odm_TXPowerTrackingThermalMeterCheck(),pMgntInfo->bTXPowerTracking is FALSE, return!!\n"));
- return;
- }
- if(!TM_Trigger) //at least delay 1 sec
- {
- if(IS_HARDWARE_TYPE_8192D(Adapter))
- PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_T_METER_92D, BIT17 | BIT16, 0x03);
- else if(IS_HARDWARE_TYPE_8188E(Adapter) || IS_HARDWARE_TYPE_JAGUAR(Adapter) || IS_HARDWARE_TYPE_8192E(Adapter) ||
- IS_HARDWARE_TYPE_8723B(Adapter))
- PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03);
- else
- PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60);
-
- RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,("Trigger Thermal Meter!!\n"));
-
- TM_Trigger = 1;
- return;
- }
- else
- {
- RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,("Schedule TxPowerTracking direct call!!\n"));
- odm_TXPowerTrackingDirectCall(Adapter); //Using direct call is instead, added by Roger, 2009.06.18.
- TM_Trigger = 0;
- }
- #endif
- }
- // Only for 8723A SW ANT DIV INIT--2012--07--17
- VOID
- odm_SwAntDivInit_NIC_8723A(
- IN PDM_ODM_T pDM_Odm)
- {
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- PADAPTER Adapter = pDM_Odm->Adapter;
-
- u1Byte btAntNum=BT_GetPgAntNum(Adapter);
- if(IS_HARDWARE_TYPE_8723A(Adapter))
- {
- pDM_SWAT_Table->ANTA_ON =TRUE;
-
- // Set default antenna B status by PG
- if(btAntNum == 2)
- pDM_SWAT_Table->ANTB_ON = TRUE;
- else if(btAntNum == 1)
- pDM_SWAT_Table->ANTB_ON = FALSE;
- else
- pDM_SWAT_Table->ANTB_ON = TRUE;
- }
- }
- #endif //end #ifMP
- //3============================================================
- //3 SW Antenna Diversity
- //3============================================================
- #if(defined(CONFIG_SW_ANTENNA_DIVERSITY))
- VOID
- odm_SwAntDivInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- odm_SwAntDivInit_NIC(pDM_Odm);
- #elif(DM_ODM_SUPPORT_TYPE == ODM_AP)
- dm_SW_AntennaSwitchInit(pDM_Odm->priv);
- #endif
- }
- VOID
- odm_SwAntDivInit_NIC(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- // Init SW ANT DIV mechanism for 8723AE/AU/AS
- // CE/AP/ADSL no using SW ANT DIV for 8723A Series IC
- //#if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- #if (RTL8723A_SUPPORT==1)
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- odm_SwAntDivInit_NIC_8723A(pDM_Odm);
- }
- #endif
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS:Init SW Antenna Switch\n"));
- pDM_SWAT_Table->RSSI_sum_A = 0;
- pDM_SWAT_Table->RSSI_cnt_A = 0;
- pDM_SWAT_Table->RSSI_sum_B = 0;
- pDM_SWAT_Table->RSSI_cnt_B = 0;
- pDM_SWAT_Table->CurAntenna = MAIN_ANT;
- pDM_SWAT_Table->PreAntenna = MAIN_ANT;
- pDM_SWAT_Table->try_flag = 0xff;
- pDM_SWAT_Table->PreRSSI = 0;
- pDM_SWAT_Table->SWAS_NoLink_State = 0;
- pDM_SWAT_Table->bTriggerAntennaSwitch = 0;
- pDM_SWAT_Table->SelectAntennaMap=0xAA;
- pDM_SWAT_Table->lastTxOkCnt = 0;
- pDM_SWAT_Table->lastRxOkCnt = 0;
- pDM_SWAT_Table->TXByteCnt_A = 0;
- pDM_SWAT_Table->TXByteCnt_B = 0;
- pDM_SWAT_Table->RXByteCnt_A = 0;
- pDM_SWAT_Table->RXByteCnt_B = 0;
- pDM_SWAT_Table->TrafficLoad = TRAFFIC_LOW;
- pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ODM_Read4Byte(pDM_Odm, 0x860);
-
- }
- //
- // 20100514 Joseph:
- // Add new function to reset the state of antenna diversity before link.
- //
- VOID
- ODM_SwAntDivResetBeforeLink(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- pDM_SWAT_Table->SWAS_NoLink_State = 0;
- }
- //
- // 20100514 Luke/Joseph:
- // Add new function to reset antenna diversity state after link.
- //
- VOID
- ODM_SwAntDivRestAfterLink(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- pDM_SWAT_Table->RSSI_cnt_A = 0;
- pDM_SWAT_Table->RSSI_cnt_B = 0;
- pDM_Odm->RSSI_test = FALSE;
- pDM_SWAT_Table->try_flag = 0xff;
- pDM_SWAT_Table->RSSI_Trying = 0;
- pDM_SWAT_Table->SelectAntennaMap=0xAA;
- }
- VOID
- ODM_SwAntDivChkPerPktRssi(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte StationID,
- IN PODM_PHY_INFO_T pPhyInfo
- )
- {
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
-
- if(!(pDM_Odm->SupportAbility & (ODM_BB_ANT_DIV)))
- return;
- // temporary Fix 8723A MP SW ANT DIV Bug --NeilChen--2012--07--11
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- //if(StationID == pDM_SWAT_Table->RSSI_target)
- //{
- //1 RSSI for SW Antenna Switch
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- pDM_SWAT_Table->RSSI_sum_A += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_A++;
- }
- else
- {
- pDM_SWAT_Table->RSSI_sum_B += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_B++;
- }
- //}
- }
- else
- {
- if(StationID == pDM_SWAT_Table->RSSI_target)
- {
- //1 RSSI for SW Antenna Switch
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- pDM_SWAT_Table->RSSI_sum_A += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_A++;
- }
- else
- {
- pDM_SWAT_Table->RSSI_sum_B += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_B++;
- }
- }
- }
- #else
- if(StationID == pDM_SWAT_Table->RSSI_target)
- {
- //1 RSSI for SW Antenna Switch
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- pDM_SWAT_Table->RSSI_sum_A += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_A++;
- }
- else
- {
- pDM_SWAT_Table->RSSI_sum_B += pPhyInfo->RxPWDBAll;
- pDM_SWAT_Table->RSSI_cnt_B++;
- }
- }
- #endif
- }
- //
- VOID
- odm_SwAntDivChkAntSwitch(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Step
- )
- {
- //
- // For AP/ADSL use prtl8192cd_priv
- // For CE/NIC use PADAPTER
- //
- prtl8192cd_priv priv = pDM_Odm->priv;
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- odm_SwAntDivChkAntSwitchNIC(pDM_Odm, Step);
- break;
- case ODM_CE:
- odm_SwAntDivChkAntSwitchNIC(pDM_Odm, Step);
- break;
- case ODM_AP:
- case ODM_ADSL:
- #if (DM_ODM_SUPPORT_TYPE & (ODM_AP |ODM_ADSL))
- if (priv->pshare->rf_ft_var.antSw_enable && (priv->up_time % 4==1))
- dm_SW_AntennaSwitch(priv, SWAW_STEP_PEAK);
- #endif
- break;
- }
- }
- //
- // 20100514 Luke/Joseph:
- // Add new function for antenna diversity after link.
- // This is the main function of antenna diversity after link.
- // This function is called in HalDmWatchDog() and ODM_SwAntDivChkAntSwitchCallback().
- // HalDmWatchDog() calls this function with SWAW_STEP_PEAK to initialize the antenna test.
- // In SWAW_STEP_PEAK, another antenna and a 500ms timer will be set for testing.
- // After 500ms, ODM_SwAntDivChkAntSwitchCallback() calls this function to compare the signal just
- // listened on the air with the RSSI of original antenna.
- // It chooses the antenna with better RSSI.
- // There is also a aged policy for error trying. Each error trying will cost more 5 seconds waiting
- // penalty to get next try.
- VOID
- ODM_SetAntenna(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Antenna)
- {
- ODM_SetBBReg(pDM_Odm, 0x860, BIT8|BIT9, Antenna);
- }
- VOID
- odm_SwAntDivChkAntSwitchNIC(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Step
- )
- {
- #if ((RTL8192C_SUPPORT==1)||(RTL8723A_SUPPORT==1))
- //PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- PADAPTER Adapter=pDM_Odm->Adapter;
- #endif
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- s4Byte curRSSI=100, RSSI_A, RSSI_B;
- u1Byte nextAntenna=AUX_ANT;
- //static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
- u8Byte curTxOkCnt=0, curRxOkCnt=0;
- //static u8Byte TXByteCnt_A=0, TXByteCnt_B=0, RXByteCnt_A=0, RXByteCnt_B=0;
- u8Byte CurByteCnt=0, PreByteCnt=0;
- //static u1Byte TrafficLoad = TRAFFIC_LOW;
- u1Byte Score_A=0, Score_B=0; //A: Main; B: AUX
- u1Byte i;
- if(!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
- return;
- if (pDM_Odm->SupportICType & (ODM_RTL8192D|ODM_RTL8188E))
- return;
- if((pDM_Odm->SupportICType == ODM_RTL8192C) &&(pDM_Odm->RFType == ODM_2T2R))
- return;
- if(pDM_Odm->SupportPlatform & ODM_WIN)
- {
- if(*(pDM_Odm->pAntennaTest))
- return;
- }
- if((pDM_SWAT_Table->ANTA_ON == FALSE) ||(pDM_SWAT_Table->ANTB_ON == FALSE))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("odm_SwAntDivChkAntSwitch(): No AntDiv Mechanism, Antenna A or B is off\n"));
- return;
- }
- // Radio off: Status reset to default and return.
- if(*(pDM_Odm->pbPowerSaving)==TRUE) //pHalData->eRFPowerState==eRfOff
- {
- ODM_SwAntDivRestAfterLink(pDM_Odm);
- return;
- }
- // Handling step mismatch condition.
- // Peak step is not finished at last time. Recover the variable and check again.
- if( Step != pDM_SWAT_Table->try_flag )
- {
- ODM_SwAntDivRestAfterLink(pDM_Odm);
- }
- #if (DM_ODM_SUPPORT_TYPE &( ODM_WIN| ODM_CE ))
- if(pDM_SWAT_Table->try_flag == 0xff)
- {
- pDM_SWAT_Table->RSSI_target = 0xff;
-
- #if(DM_ODM_SUPPORT_TYPE & ODM_CE)
- {
- u1Byte index = 0;
- PSTA_INFO_T pEntry = NULL;
-
-
- for(index=0; index<ODM_ASSOCIATE_ENTRY_NUM; index++)
- {
- pEntry = pDM_Odm->pODM_StaInfo[index];
- if(IS_STA_VALID(pEntry) ) {
- break;
- }
- }
- if(pEntry == NULL)
- {
- ODM_SwAntDivRestAfterLink(pDM_Odm);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): No Link.\n"));
- return;
- }
- else
- {
- pDM_SWAT_Table->RSSI_target = index;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): RSSI_target is PEER STA\n"));
- }
- }
- #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo=&pAdapter->MgntInfo;
-
- // Select RSSI checking target
- if(pMgntInfo->mAssoc && !ACTING_AS_AP(pAdapter))
- {
- // Target: Infrastructure mode AP.
- //pDM_SWAT_Table->RSSI_target = NULL;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("odm_SwAntDivChkAntSwitch(): RSSI_target is DEF AP!\n"));
- }
- else
- {
- u1Byte index = 0;
- PSTA_INFO_T pEntry = NULL;
- PADAPTER pTargetAdapter = NULL;
-
- if(pMgntInfo->mIbss )
- {
- // Target: AP/IBSS peer.
- pTargetAdapter = pAdapter;
- }
- else
- {
- pTargetAdapter = GetFirstAPAdapter(pAdapter);
- }
- if(pTargetAdapter != NULL)
- {
- for(index=0; index<ODM_ASSOCIATE_ENTRY_NUM; index++)
- {
-
- pEntry = AsocEntry_EnumStation(pTargetAdapter, index);
- if(pEntry != NULL)
- {
- if(pEntry->bAssociated)
- break;
- }
-
- }
-
- }
- if(pEntry == NULL)
- {
- ODM_SwAntDivRestAfterLink(pDM_Odm);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): No Link.\n"));
- return;
- }
- else
- {
- //pDM_SWAT_Table->RSSI_target = pEntry;
- pDM_SWAT_Table->RSSI_target = index;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): RSSI_target is PEER STA\n"));
- }
- }//end if(pMgntInfo->mAssoc && !ACTING_AS_AP(Adapter))
- }
- #endif
- pDM_SWAT_Table->RSSI_cnt_A = 0;
- pDM_SWAT_Table->RSSI_cnt_B = 0;
- pDM_SWAT_Table->try_flag = 0;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("odm_SwAntDivChkAntSwitch(): Set try_flag to 0 prepare for peak!\n"));
- return;
- }
- else
- {
- // To Fix 8723A SW ANT DIV Bug issue
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- if (pDM_Odm->SupportICType & ODM_RTL8723A)
- {
- curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - pDM_SWAT_Table->lastTxOkCnt;
- curRxOkCnt =Adapter->RxStats.NumRxBytesUnicast - pDM_SWAT_Table->lastRxOkCnt;
- pDM_SWAT_Table->lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
- pDM_SWAT_Table->lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
- }
- #else
- curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast) - pDM_SWAT_Table->lastTxOkCnt;
- curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast) - pDM_SWAT_Table->lastRxOkCnt;
- pDM_SWAT_Table->lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast);
- pDM_SWAT_Table->lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast);
- #endif
- if(pDM_SWAT_Table->try_flag == 1)
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- pDM_SWAT_Table->TXByteCnt_A += curTxOkCnt;
- pDM_SWAT_Table->RXByteCnt_A += curRxOkCnt;
- }
- else
- {
- pDM_SWAT_Table->TXByteCnt_B += curTxOkCnt;
- pDM_SWAT_Table->RXByteCnt_B += curRxOkCnt;
- }
-
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? AUX_ANT : MAIN_ANT;
- pDM_SWAT_Table->RSSI_Trying--;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("RSSI_Trying = %d\n",pDM_SWAT_Table->RSSI_Trying));
- if(pDM_SWAT_Table->RSSI_Trying == 0)
- {
- CurByteCnt = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? (pDM_SWAT_Table->TXByteCnt_A+pDM_SWAT_Table->RXByteCnt_A) : (pDM_SWAT_Table->TXByteCnt_B+pDM_SWAT_Table->RXByteCnt_B);
- PreByteCnt = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? (pDM_SWAT_Table->TXByteCnt_B+pDM_SWAT_Table->RXByteCnt_B) : (pDM_SWAT_Table->TXByteCnt_A+pDM_SWAT_Table->RXByteCnt_A);
-
- if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_HIGH)
- //CurByteCnt = PlatformDivision64(CurByteCnt, 9);
- PreByteCnt = PreByteCnt*9;
- else if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_LOW)
- //CurByteCnt = PlatformDivision64(CurByteCnt, 2);
- PreByteCnt = PreByteCnt*2;
- if(pDM_SWAT_Table->RSSI_cnt_A > 0)
- RSSI_A = pDM_SWAT_Table->RSSI_sum_A/pDM_SWAT_Table->RSSI_cnt_A;
- else
- RSSI_A = 0;
- if(pDM_SWAT_Table->RSSI_cnt_B > 0)
- RSSI_B = pDM_SWAT_Table->RSSI_sum_B/pDM_SWAT_Table->RSSI_cnt_B;
- else
- RSSI_B = 0;
- curRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_B : RSSI_A;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Luke:PreRSSI = %d, CurRSSI = %d\n",pDM_SWAT_Table->PreRSSI, curRSSI));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: preAntenna= %s, curAntenna= %s \n",
- (pDM_SWAT_Table->PreAntenna == MAIN_ANT?"MAIN":"AUX"), (pDM_SWAT_Table->CurAntenna == MAIN_ANT?"MAIN":"AUX")));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Luke:RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
- RSSI_A, pDM_SWAT_Table->RSSI_cnt_A, RSSI_B, pDM_SWAT_Table->RSSI_cnt_B));
- }
- }
- else
- {
-
- if(pDM_SWAT_Table->RSSI_cnt_A > 0)
- RSSI_A = pDM_SWAT_Table->RSSI_sum_A/pDM_SWAT_Table->RSSI_cnt_A;
- else
- RSSI_A = 0;
- if(pDM_SWAT_Table->RSSI_cnt_B > 0)
- RSSI_B = pDM_SWAT_Table->RSSI_sum_B/pDM_SWAT_Table->RSSI_cnt_B;
- else
- RSSI_B = 0;
- curRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->PreAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ekul:PreRSSI = %d, CurRSSI = %d\n", pDM_SWAT_Table->PreRSSI, curRSSI));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: preAntenna= %s, curAntenna= %s \n",
- (pDM_SWAT_Table->PreAntenna == MAIN_ANT?"MAIN":"AUX"), (pDM_SWAT_Table->CurAntenna == MAIN_ANT?"MAIN":"AUX")));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ekul:RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
- RSSI_A, pDM_SWAT_Table->RSSI_cnt_A, RSSI_B, pDM_SWAT_Table->RSSI_cnt_B));
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curTxOkCnt = %d\n", curTxOkCnt));
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curRxOkCnt = %d\n", curRxOkCnt));
- }
- //1 Trying State
- if((pDM_SWAT_Table->try_flag == 1)&&(pDM_SWAT_Table->RSSI_Trying == 0))
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: TestMode = TP_MODE"));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("TRY:CurByteCnt = %lld,", CurByteCnt));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("TRY:PreByteCnt = %lld\n",PreByteCnt));
- if(CurByteCnt < PreByteCnt)
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
- else
- pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
- }
- else
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
- else
- pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
- }
- for (i= 0; i<8; i++)
- {
- if(((pDM_SWAT_Table->SelectAntennaMap>>i)&BIT0) == 1)
- Score_A++;
- else
- Score_B++;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SelectAntennaMap=%x\n ",pDM_SWAT_Table->SelectAntennaMap));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Score_A=%d, Score_B=%d\n", Score_A, Score_B));
-
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- nextAntenna = (Score_A > Score_B)?MAIN_ANT:AUX_ANT;
- }
- else
- {
- nextAntenna = (Score_B > Score_A)?AUX_ANT:MAIN_ANT;
- }
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("nextAntenna=%s\n",(nextAntenna==Antenna_A)?"A":"B"));
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("preAntenna= %s, curAntenna= %s \n",
- //(DM_SWAT_Table.PreAntenna == Antenna_A?"A":"B"), (DM_SWAT_Table.CurAntenna == Antenna_A?"A":"B")));
- if(nextAntenna != pDM_SWAT_Table->CurAntenna)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: Switch back to another antenna"));
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: current anntena is good\n"));
- }
- }
- if(pDM_SWAT_Table->TestMode == RSSI_MODE)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: TestMode = RSSI_MODE"));
- pDM_SWAT_Table->SelectAntennaMap=0xAA;
- if(curRSSI < pDM_SWAT_Table->PreRSSI) //Current antenna is worse than previous antenna
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: Switch back to another antenna"));
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? AUX_ANT : MAIN_ANT;
- }
- else // current anntena is good
- {
- nextAntenna =pDM_SWAT_Table->CurAntenna;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: current anntena is good\n"));
- }
- }
- pDM_SWAT_Table->try_flag = 0;
- pDM_Odm->RSSI_test = FALSE;
- pDM_SWAT_Table->RSSI_sum_A = 0;
- pDM_SWAT_Table->RSSI_cnt_A = 0;
- pDM_SWAT_Table->RSSI_sum_B = 0;
- pDM_SWAT_Table->RSSI_cnt_B = 0;
- pDM_SWAT_Table->TXByteCnt_A = 0;
- pDM_SWAT_Table->TXByteCnt_B = 0;
- pDM_SWAT_Table->RXByteCnt_A = 0;
- pDM_SWAT_Table->RXByteCnt_B = 0;
-
- }
- //1 Normal State
- else if(pDM_SWAT_Table->try_flag == 0)
- {
- if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_HIGH)
- {
- if ((curTxOkCnt+curRxOkCnt) > 3750000)//if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
- pDM_SWAT_Table->TrafficLoad = TRAFFIC_HIGH;
- else
- pDM_SWAT_Table->TrafficLoad = TRAFFIC_LOW;
- }
- else if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_LOW)
- {
- if ((curTxOkCnt+curRxOkCnt) > 3750000) //if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
- pDM_SWAT_Table->TrafficLoad = TRAFFIC_HIGH;
- else
- pDM_SWAT_Table->TrafficLoad = TRAFFIC_LOW;
- }
- if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_HIGH)
- pDM_SWAT_Table->bTriggerAntennaSwitch = 0;
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Normal:TrafficLoad = %llu\n", curTxOkCnt+curRxOkCnt));
- //Prepare To Try Antenna
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? AUX_ANT : MAIN_ANT;
- pDM_SWAT_Table->try_flag = 1;
- pDM_Odm->RSSI_test = TRUE;
- if((curRxOkCnt+curTxOkCnt) > 1000)
- {
- pDM_SWAT_Table->RSSI_Trying = 4;
- pDM_SWAT_Table->TestMode = TP_MODE;
- }
- else
- {
- pDM_SWAT_Table->RSSI_Trying = 2;
- pDM_SWAT_Table->TestMode = RSSI_MODE;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: Normal State -> Begin Trying!\n"));
-
-
- pDM_SWAT_Table->RSSI_sum_A = 0;
- pDM_SWAT_Table->RSSI_cnt_A = 0;
- pDM_SWAT_Table->RSSI_sum_B = 0;
- pDM_SWAT_Table->RSSI_cnt_B = 0;
- }
- }
- //1 4.Change TRX antenna
- if(nextAntenna != pDM_SWAT_Table->CurAntenna)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("SWAS: Change TX Antenna!\n "));
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, nextAntenna);
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- ODM_SetAntenna(pDM_Odm,nextAntenna);
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- {
- BOOLEAN bEnqueue;
- bEnqueue = (pDM_Odm->SupportInterface == ODM_ITRF_PCIE)?FALSE :TRUE;
- rtw_antenna_select_cmd(pDM_Odm->Adapter, nextAntenna, bEnqueue);
- }
- #endif
-
- }
- //1 5.Reset Statistics
- pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- pDM_SWAT_Table->CurAntenna = nextAntenna;
- pDM_SWAT_Table->PreRSSI = curRSSI;
- //1 6.Set next timer
- {
- //PADAPTER pAdapter = pDM_Odm->Adapter;
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
-
- if(pDM_SWAT_Table->RSSI_Trying == 0)
- return;
- if(pDM_SWAT_Table->RSSI_Trying%2 == 0)
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_HIGH)
- {
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 10 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 10 ); //ms
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 10 ms\n"));
- }
- else if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_LOW)
- {
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 50 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 50 ); //ms
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 50 ms\n"));
- }
- }
- else
- {
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 500 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 500 ); //ms
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_SW_AntennaSwitch(): Test another antenna for 500 ms\n"));
- }
- }
- else
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_HIGH)
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 90 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 90 ); //ms
- else if(pDM_SWAT_Table->TrafficLoad == TRAFFIC_LOW)
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 100 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 100 ); //ms
- }
- else
- //PlatformSetTimer( pAdapter, &pHalData->SwAntennaSwitchTimer, 500 ); //ms
- ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 500 ); //ms
- }
- }
- #endif // #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
- #endif // #if (RTL8192C_SUPPORT==1)
- }
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- u1Byte
- odm_SwAntDivSelectChkChnl(
- IN PADAPTER Adapter
- )
- {
- #if (RT_MEM_SIZE_LEVEL != RT_MEM_SIZE_MINIMUM)
- u1Byte index, target_chnl=0;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- u1Byte chnl_peer_cnt[14] = {0};
- if(Adapter->MgntInfo.tmpNumBssDesc==0)
- {
- return 0;
- }
- else
- {
- // 20100519 Joseph: Select checking channel from current scan list.
- // We just choose the channel with most APs to be the test scan channel.
- for(index=0; index<Adapter->MgntInfo.tmpNumBssDesc; index++)
- {
- // Add by hpfan: prevent access invalid channel number
- // TODO: Verify channel number by channel plan
- if(Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber == 0 ||
- Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber > 13)
- continue;
-
- chnl_peer_cnt[Adapter->MgntInfo.tmpbssDesc[index].ChannelNumber-1]++;
- }
- for(index=0; index<14; index++)
- {
- if(chnl_peer_cnt[index]>chnl_peer_cnt[target_chnl])
- target_chnl = index;
- }
- target_chnl+=1;
- ODM_RT_TRACE(pDM_Odm,COMP_SWAS, DBG_LOUD,
- ("odm_SwAntDivSelectChkChnl(): Channel %d is select as test channel.\n", target_chnl));
- return target_chnl;
- }
- #else
- return 0;
- #endif
- }
- VOID
- odm_SwAntDivConsructChkScanChnl(
- IN PADAPTER Adapter,
- IN u1Byte ChkChnl
- )
- {
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- PRT_CHANNEL_LIST pChannelList = GET_RT_CHANNEL_LIST(pMgntInfo);
- u1Byte index;
- if(ChkChnl==0)
- {
- // 20100519 Joseph: Original antenna scanned nothing.
- // Test antenna shall scan all channel with half period in this condition.
- RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_CONSTRUCT_SCAN_LIST, NULL, NULL);
- for(index=0; index<pChannelList->ChannelLen; index++)
- pChannelList->ChnlListEntry[index].ScanPeriod /= 2;
- }
- else
- {
- // The using of this CustomizedScanRequest is a trick to rescan the two channels
- // under the NORMAL scanning process. It will not affect MGNT_INFO.CustomizedScanRequest.
- CUSTOMIZED_SCAN_REQUEST CustomScanReq;
- CustomScanReq.bEnabled = TRUE;
- CustomScanReq.Channels[0] = ChkChnl;
- CustomScanReq.Channels[1] = pMgntInfo->dot11CurrentChannelNumber;
- CustomScanReq.nChannels = 2;
- CustomScanReq.ScanType = SCAN_ACTIVE;
- CustomScanReq.Duration = DEFAULT_ACTIVE_SCAN_PERIOD;
- RtActChannelList(Adapter, RT_CHNL_LIST_ACTION_CONSTRUCT_SCAN_LIST, &CustomScanReq, NULL);
- }
- }
- #endif //#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- //
- // 20100514 Luke/Joseph:
- // Callback function for 500ms antenna test trying.
- //
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_SwAntDivChkAntSwitchCallback(
- PRT_TIMER pTimer
- )
- {
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- pSWAT_T pDM_SWAT_Table = &pHalData->DM_OutSrc.DM_SWAT_Table;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- ODM_ScheduleWorkItem(&pDM_SWAT_Table->SwAntennaSwitchWorkitem);
- #else
- odm_SwAntDivChkAntSwitch(&pHalData->DM_OutSrc, SWAW_STEP_DETERMINE);
- #endif
- #else
- ODM_ScheduleWorkItem(&pDM_SWAT_Table->SwAntennaSwitchWorkitem);
- #endif
-
- }
- VOID
- odm_SwAntDivChkAntSwitchWorkitemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER pAdapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- odm_SwAntDivChkAntSwitch(&pHalData->DM_OutSrc, SWAW_STEP_DETERMINE);
- }
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext)
- {
- PDM_ODM_T pDM_Odm= (PDM_ODM_T)FunctionContext;
- PADAPTER padapter = pDM_Odm->Adapter;
- if(padapter->net_closed == _TRUE)
- return;
- odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_DETERMINE);
- }
- #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext)
- {
- PDM_ODM_T pDM_Odm= (PDM_ODM_T)FunctionContext;
- odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_DETERMINE);
- }
- #endif
- #else //#if(defined(CONFIG_SW_ANTENNA_DIVERSITY))
- VOID odm_SwAntDivInit( IN PDM_ODM_T pDM_Odm ) {}
- VOID ODM_SwAntDivChkPerPktRssi(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte StationID,
- IN PODM_PHY_INFO_T pPhyInfo
- ) {}
- VOID odm_SwAntDivChkAntSwitch(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Step
- ) {}
- VOID ODM_SwAntDivResetBeforeLink( IN PDM_ODM_T pDM_Odm ){}
- VOID ODM_SwAntDivRestAfterLink( IN PDM_ODM_T pDM_Odm ){}
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- u1Byte odm_SwAntDivSelectChkChnl( IN PADAPTER Adapter ){ return 0;}
- VOID
- odm_SwAntDivConsructChkScanChnl(
- IN PADAPTER Adapter,
- IN u1Byte ChkChnl
- ){}
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID odm_SwAntDivChkAntSwitchCallback( PRT_TIMER pTimer){}
- VOID odm_SwAntDivChkAntSwitchWorkitemCallback( IN PVOID pContext ){}
- #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext){}
- #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP|ODM_ADSL))
- VOID odm_SwAntDivChkAntSwitchCallback(void *FunctionContext){}
- #endif
- #endif //#if(defined(CONFIG_SW_ANTENNA_DIVERSITY))
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- #if((defined(CONFIG_SW_ANTENNA_DIVERSITY))||(defined(CONFIG_HW_ANTENNA_DIVERSITY)))
- BOOLEAN
- ODM_SwAntDivCheckBeforeLink8192C(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (RT_MEM_SIZE_LEVEL != RT_MEM_SIZE_MINIMUM)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE* pHalData = NULL;
- PMGNT_INFO pMgntInfo = NULL;
- //pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
- s1Byte Score = 0;
- PRT_WLAN_BSS pTmpBssDesc;
- PRT_WLAN_BSS pTestBssDesc;
- u1Byte target_chnl = 0;
- u1Byte index;
- return FALSE;
- if (pDM_Odm->Adapter == NULL) //For BSOD when plug/unplug fast. //By YJ,120413
- { // The ODM structure is not initialized.
- return FALSE;
- }
- // 2012/04/26 MH Prevent no-checked IC to execute antenna diversity.
- if(pDM_Odm->SupportICType == ODM_RTL8188E && pDM_Odm->SupportInterface != ODM_ITRF_PCIE)
- return FALSE;
- pHalData = GET_HAL_DATA(Adapter);
- pMgntInfo = &Adapter->MgntInfo;
-
- // Condition that does not need to use antenna diversity.
- if(IS_8723A_SERIES(pHalData->VersionID) ||
- IS_92C_SERIAL(pHalData->VersionID) ||
- (pHalData->AntDivCfg==0) ||
- pMgntInfo->AntennaTest ||
- Adapter->bInHctTest)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): No AntDiv Mechanism.\n"));
- return FALSE;
- }
- if(IS_8723A_SERIES(pHalData->VersionID) || IS_92C_SERIAL(pHalData->VersionID) )
- {
- if((pDM_SWAT_Table->ANTA_ON == FALSE) ||(pDM_SWAT_Table->ANTB_ON == FALSE))
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): No AntDiv Mechanism, Antenna A or B is off\n"));
- return FALSE;
- }
- }
- // Since driver is going to set BB register, it shall check if there is another thread controlling BB/RF.
- PlatformAcquireSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
- if(pHalData->eRFPowerState!=eRfOn || pMgntInfo->RFChangeInProgress || pMgntInfo->bMediaConnect)
- {
- PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): RFChangeInProgress(%x), eRFPowerState(%x)\n",
- pMgntInfo->RFChangeInProgress,
- pHalData->eRFPowerState));
-
- pDM_SWAT_Table->SWAS_NoLink_State = 0;
-
- return FALSE;
- }
- else
- {
- PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
- }
- //1 Run AntDiv mechanism "Before Link" part.
- if(pDM_SWAT_Table->SWAS_NoLink_State == 0)
- {
- //1 Prepare to do Scan again to check current antenna state.
- // Set check state to next step.
- pDM_SWAT_Table->SWAS_NoLink_State = 1;
-
- // Copy Current Scan list.
- Adapter->MgntInfo.tmpNumBssDesc = pMgntInfo->NumBssDesc;
- PlatformMoveMemory((PVOID)Adapter->MgntInfo.tmpbssDesc, (PVOID)pMgntInfo->bssDesc, sizeof(RT_WLAN_BSS)*MAX_BSS_DESC);
-
- if(pDM_Odm->SupportICType == ODM_RTL8188E)
- {
- if(pDM_FatTable->RxIdleAnt == MAIN_ANT)
- ODM_UpdateRxIdleAnt_88E(pDM_Odm, AUX_ANT);
- else
- ODM_UpdateRxIdleAnt_88E(pDM_Odm, MAIN_ANT);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C: Change to %s for testing.\n", ((pDM_FatTable->RxIdleAnt == MAIN_ANT)?"MAIN_ANT":"AUX_ANT")));
- }
- if(pDM_Odm->SupportICType != ODM_RTL8188E)
- {
- // Switch Antenna to another one.
- pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- pDM_SWAT_Table->CurAntenna = (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?AUX_ANT:MAIN_ANT;
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C: Change to Ant(%s) for testing.\n", (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?"MAIN":"AUX"));
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
- pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
- }
- // Go back to scan function again.
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink8192C: Scan one more time\n"));
- pMgntInfo->ScanStep=0;
- target_chnl = odm_SwAntDivSelectChkChnl(Adapter);
- odm_SwAntDivConsructChkScanChnl(Adapter, target_chnl);
- CHNL_ReleaseOpLock(Adapter);
- PlatformSetTimer(Adapter, &pMgntInfo->ScanTimer, 5);
- return TRUE;
- }
- else
- {
- //1 ScanComple() is called after antenna swiched.
- //1 Check scan result and determine which antenna is going
- //1 to be used.
- for(index=0; index<Adapter->MgntInfo.tmpNumBssDesc; index++)
- {
- pTmpBssDesc = &(Adapter->MgntInfo.tmpbssDesc[index]);
- pTestBssDesc = &(pMgntInfo->bssDesc[index]);
- if(PlatformCompareMemory(pTestBssDesc->bdBssIdBuf, pTmpBssDesc->bdBssIdBuf, 6)!=0)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink8192C(): ERROR!! This shall not happen.\n"));
- continue;
- }
- if(pTmpBssDesc->RecvSignalPower > pTestBssDesc->RecvSignalPower)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink8192C: Compare scan entry: Score++\n"));
- RT_PRINT_STR(ODM_COMP_ANT_DIV, ODM_DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
-
- Score++;
- PlatformMoveMemory(pTestBssDesc, pTmpBssDesc, sizeof(RT_WLAN_BSS));
- }
- else if(pTmpBssDesc->RecvSignalPower < pTestBssDesc->RecvSignalPower)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SwAntDivCheckBeforeLink8192C: Compare scan entry: Score--\n"));
- RT_PRINT_STR(ODM_COMP_ANT_DIV, ODM_DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
- Score--;
- }
- }
- if(pDM_Odm->SupportICType == ODM_RTL8188E)
- {
- if(pMgntInfo->NumBssDesc!=0 && Score<=0)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): Using Ant(%s)\n", (pDM_FatTable->RxIdleAnt==MAIN_ANT)?"MAIN_ANT":"AUX_ANT"));
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): Remain Ant(%s)\n", (pDM_FatTable->RxIdleAnt==MAIN_ANT)?"AUX_ANT":"MAIN_ANT"));
- if(pDM_FatTable->RxIdleAnt == MAIN_ANT)
- ODM_UpdateRxIdleAnt_88E(pDM_Odm, AUX_ANT);
- else
- ODM_UpdateRxIdleAnt_88E(pDM_Odm, MAIN_ANT);
- }
- }
- if(pDM_Odm->SupportICType != ODM_RTL8188E)
- {
- if(pMgntInfo->NumBssDesc!=0 && Score<=0)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): Using Ant(%s)\n", (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?"MAIN":"AUX"));
- pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C(): Remain Ant(%s)\n", (pDM_SWAT_Table->CurAntenna==MAIN_ANT)?"AUX":"MAIN"));
- pDM_SWAT_Table->CurAntenna = pDM_SWAT_Table->PreAntenna;
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
- pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
- PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
- }
- }
- // Check state reset to default and wait for next time.
- pDM_SWAT_Table->SWAS_NoLink_State = 0;
- return FALSE;
- }
- #else
- return FALSE;
- #endif
- return FALSE;
- }
- #else
- BOOLEAN
- ODM_SwAntDivCheckBeforeLink8192C(
- IN PDM_ODM_T pDM_Odm
- )
- {
- return FALSE;
- }
- #endif //#if((defined(CONFIG_SW_ANTENNA_DIVERSITY))||(defined(CONFIG_HW_ANTENNA_DIVERSITY)))
- #endif //#if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- //3============================================================
- //3 SW Antenna Diversity
- //3============================================================
- #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- VOID
- odm_InitHybridAntDiv_88C_92D(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)||(DM_ODM_SUPPORT_TYPE==ODM_ADSL))
- struct rtl8192cd_priv *priv=pDM_Odm->priv;
- #endif
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- u1Byte bTxPathSel=0; //0:Path-A 1:Path-B
- u1Byte i;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_InitHybridAntDiv==============>\n"));
- //whether to do antenna diversity or not
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if(priv==NULL) return;
- if(!priv->pshare->rf_ft_var.antHw_enable)
- return;
-
- #ifdef SW_ANT_SWITCH
- priv->pshare->rf_ft_var.antSw_enable =0;
- #endif
- #endif
- if((pDM_Odm->SupportICType != ODM_RTL8192C) && (pDM_Odm->SupportICType != ODM_RTL8192D))
- return;
- bTxPathSel=(pDM_Odm->RFType==ODM_1T1R)?FALSE:TRUE;
- ODM_SetBBReg(pDM_Odm,ODM_REG_BB_PWR_SAV1_11N, BIT23, 0); //No update ANTSEL during GNT_BT=1
- ODM_SetBBReg(pDM_Odm,ODM_REG_TX_ANT_CTRL_11N, BIT21, 1); //TX atenna selection from tx_info
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTSEL_PIN_11N, BIT23, 1); //enable LED[1:0] pin as ANTSEL
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTSEL_CTRL_11N, BIT8|BIT9, 0x01); // 0x01: left antenna, 0x02: right antenna
- // check HW setting: ANTSEL pin connection
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- ODM_Write2Byte(pDM_Odm,ODM_REG_RF_PIN_11N, (ODM_Read2Byte(pDM_Odm,0x804)&0xf0ff )| BIT(8) ); // b11-b8=0001,update RFPin setting
- #endif
-
- // only AP support different path selection temperarly
- if(!bTxPathSel){ //PATH-A
- ODM_SetBBReg(pDM_Odm,ODM_REG_PIN_CTRL_11N, BIT8|BIT9, 0 ); // ANTSEL as HW control
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTSEL_PATH_11N, BIT13, 1); //select TX ANTESEL from path A
- }
- else {
- ODM_SetBBReg(pDM_Odm,ODM_REG_PIN_CTRL_11N, BIT24|BIT25, 0 ); // ANTSEL as HW control
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTSEL_PATH_11N, BIT13, 0); //select ANTESEL from path B
- }
- //Set OFDM HW RX Antenna Diversity
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTDIV_PARA1_11N, 0x7FF, 0x0c0); //Pwdb threshold=8dB
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTDIV_PARA1_11N, BIT11, 0); //Switch to another antenna by checking pwdb threshold
- ODM_SetBBReg(pDM_Odm,ODM_REG_ANTDIV_PARA3_11N, BIT23, 1); // Decide final antenna by comparing 2 antennas' pwdb
-
- //Set CCK HW RX Antenna Diversity
- ODM_SetBBReg(pDM_Odm,ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 0); //Antenna diversity decision period = 32 sample
- ODM_SetBBReg(pDM_Odm,ODM_REG_CCK_ANTDIV_PARA2_11N, 0xf, 0xf); //Threshold for antenna diversity. Check another antenna power if input power < ANT_lim*4
- ODM_SetBBReg(pDM_Odm,ODM_REG_CCK_ANTDIV_PARA3_11N, BIT13, 1); //polarity ana_A=1 and ana_B=0
- ODM_SetBBReg(pDM_Odm,ODM_REG_CCK_ANTDIV_PARA4_11N, 0x1f, 0x8); //default antenna power = inpwr*(0.5 + r_ant_step/16)
- //Enable HW Antenna Diversity
- if(!bTxPathSel) //PATH-A
- ODM_SetBBReg(pDM_Odm,ODM_REG_IGI_A_11N, BIT7,1); // Enable Hardware antenna switch
- else
- ODM_SetBBReg(pDM_Odm,ODM_REG_IGI_B_11N, BIT7,1); // Enable Hardware antenna switch
- ODM_SetBBReg(pDM_Odm,ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1);//Enable antenna diversity
- pDM_SWAT_Table->CurAntenna=0; //choose left antenna as default antenna
- pDM_SWAT_Table->PreAntenna=0;
- for(i=0; i<ASSOCIATE_ENTRY_NUM ; i++)
- {
- pDM_SWAT_Table->CCK_Ant1_Cnt[i] = 0;
- pDM_SWAT_Table->CCK_Ant2_Cnt[i] = 0;
- pDM_SWAT_Table->OFDM_Ant1_Cnt[i] = 0;
- pDM_SWAT_Table->OFDM_Ant2_Cnt[i] = 0;
- pDM_SWAT_Table->RSSI_Ant1_Sum[i] = 0;
- pDM_SWAT_Table->RSSI_Ant2_Sum[i] = 0;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("<==============odm_InitHybridAntDiv\n"));
- }
- VOID
- odm_InitHybridAntDiv(
- IN PDM_ODM_T pDM_Odm
- )
- {
- if(!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("Return: Not Support HW AntDiv\n"));
- return;
- }
-
- if(pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D))
- {
- #if ((RTL8192C_SUPPORT == 1)||(RTL8192D_SUPPORT == 1))
- odm_InitHybridAntDiv_88C_92D(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8188E)
- {
- #if (RTL8188E_SUPPORT == 1)
- ODM_AntennaDiversityInit_88E(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8821)
- {
- #if (RTL8821A_SUPPORT == 1)
- // ODM_AntennaDiversityInit_8821A(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8723B)
- {
- #if (RTL8723B_SUPPORT == 1)
- ODM_AntennaDiversityInit_8723B(pDM_Odm);
- #endif
- }
-
- }
- BOOLEAN
- odm_StaDefAntSel(
- IN PDM_ODM_T pDM_Odm,
- IN u4Byte OFDM_Ant1_Cnt,
- IN u4Byte OFDM_Ant2_Cnt,
- IN u4Byte CCK_Ant1_Cnt,
- IN u4Byte CCK_Ant2_Cnt,
- OUT u1Byte *pDefAnt
- )
- {
- #if 1
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_StaDefAntSelect==============>\n"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("OFDM_Ant1_Cnt:%d, OFDM_Ant2_Cnt:%d\n",OFDM_Ant1_Cnt,OFDM_Ant2_Cnt));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("CCK_Ant1_Cnt:%d, CCK_Ant2_Cnt:%d\n",CCK_Ant1_Cnt,CCK_Ant2_Cnt));
-
- if(((OFDM_Ant1_Cnt+OFDM_Ant2_Cnt)==0)&&((CCK_Ant1_Cnt + CCK_Ant2_Cnt) <10)){
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_StaDefAntSelect Fail: No enough packet info!\n"));
- return FALSE;
- }
- if(OFDM_Ant1_Cnt || OFDM_Ant2_Cnt ) {
- //if RX OFDM packet number larger than 0
- if(OFDM_Ant1_Cnt > OFDM_Ant2_Cnt)
- (*pDefAnt)=1;
- else
- (*pDefAnt)=0;
- }
- // else if RX CCK packet number larger than 10
- else if((CCK_Ant1_Cnt + CCK_Ant2_Cnt) >=10 )
- {
- if(CCK_Ant1_Cnt > (5*CCK_Ant2_Cnt))
- (*pDefAnt)=1;
- else if(CCK_Ant2_Cnt > (5*CCK_Ant1_Cnt))
- (*pDefAnt)=0;
- else if(CCK_Ant1_Cnt > CCK_Ant2_Cnt)
- (*pDefAnt)=0;
- else
- (*pDefAnt)=1;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("TxAnt = %s\n",((*pDefAnt)==1)?"Ant1":"Ant2"));
-
- #endif
- //u4Byte antsel = ODM_GetBBReg(pDM_Odm, 0xc88, bMaskByte0);
- //(*pDefAnt)= (u1Byte) antsel;
-
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("<==============odm_StaDefAntSelect\n"));
- return TRUE;
-
- }
- VOID
- odm_SetRxIdleAnt(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Ant,
- IN BOOLEAN bDualPath
- )
- {
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- //ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_SetRxIdleAnt==============>\n"));
- if(Ant != pDM_SWAT_Table->RxIdleAnt)
- {
- //for path-A
- if(Ant==1)
- ODM_SetBBReg(pDM_Odm,ODM_REG_RX_DEFUALT_A_11N, 0xFFFF, 0x65a9); //right-side antenna
- else
- ODM_SetBBReg(pDM_Odm,ODM_REG_RX_DEFUALT_A_11N, 0xFFFF, 0x569a); //left-side antenna
- //for path-B
- if(bDualPath){
- if(Ant==0)
- ODM_SetBBReg(pDM_Odm,ODM_REG_RX_DEFUALT_A_11N, 0xFFFF0000, 0x65a9); //right-side antenna
- else
- ODM_SetBBReg(pDM_Odm,ODM_REG_RX_DEFUALT_A_11N, 0xFFFF0000, 0x569a); //left-side antenna
- }
- }
- pDM_SWAT_Table->RxIdleAnt = Ant;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("RxIdleAnt: %s Reg858=0x%x\n",(Ant==1)?"Ant1":"Ant2",(Ant==1)?0x65a9:0x569a));
- //ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("<==============odm_SetRxIdleAnt\n"));
- }
-
- VOID
- ODM_AntselStatistics_88C(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte MacId,
- IN u4Byte PWDBAll,
- IN BOOLEAN isCCKrate
- )
- {
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- if(pDM_SWAT_Table->antsel == 1)
- {
- if(isCCKrate)
- pDM_SWAT_Table->CCK_Ant1_Cnt[MacId]++;
- else
- {
- pDM_SWAT_Table->OFDM_Ant1_Cnt[MacId]++;
- pDM_SWAT_Table->RSSI_Ant1_Sum[MacId] += PWDBAll;
- }
- }
- else
- {
- if(isCCKrate)
- pDM_SWAT_Table->CCK_Ant2_Cnt[MacId]++;
- else
- {
- pDM_SWAT_Table->OFDM_Ant2_Cnt[MacId]++;
- pDM_SWAT_Table->RSSI_Ant2_Sum[MacId] += PWDBAll;
- }
- }
- }
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- VOID
- ODM_SetTxAntByTxInfo_88C_92D(
- IN PDM_ODM_T pDM_Odm,
- IN pu1Byte pDesc,
- IN u1Byte macId
- )
- {
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- u1Byte antsel;
- if(!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV))
- return;
- if(pDM_SWAT_Table->RxIdleAnt == 1)
- antsel=(pDM_SWAT_Table->TxAnt[macId] == 1)?0:1;
- else
- antsel=(pDM_SWAT_Table->TxAnt[macId] == 1)?1:0;
-
- SET_TX_DESC_ANTSEL_A_92C(pDesc, antsel);
- //SET_TX_DESC_ANTSEL_B_92C(pDesc, antsel);
- //ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("SET_TX_DESC_ANTSEL_A_92C=%d\n", pDM_SWAT_Table->TxAnt[macId]));
- }
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- VOID
- ODM_SetTxAntByTxInfo_88C_92D(
- IN PDM_ODM_T pDM_Odm
- )
- {
- }
- #elif(DM_ODM_SUPPORT_TYPE==ODM_AP)
- VOID
- ODM_SetTxAntByTxInfo_88C_92D(
- IN PDM_ODM_T pDM_Odm
- )
- {
- }
- #endif
- VOID
- odm_HwAntDiv_92C_92D(
- IN PDM_ODM_T pDM_Odm
- )
- {
- SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- u4Byte RSSI_Min=0xFF, RSSI, RSSI_Ant1, RSSI_Ant2;
- u1Byte RxIdleAnt, i;
- BOOLEAN bRet=FALSE;
- PSTA_INFO_T pEntry;
-
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- struct rtl8192cd_priv *priv=pDM_Odm->priv;
- //if test, return
- if(priv->pshare->rf_ft_var.CurAntenna & 0x80)
- return;
- #endif
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_HwAntDiv==============>\n"));
-
- if(!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) //if don't support antenna diveristy
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_HwAntDiv: Not supported!\n"));
- return;
- }
- if((pDM_Odm->SupportICType != ODM_RTL8192C) && (pDM_Odm->SupportICType != ODM_RTL8192D))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("Return: IC Type is not 92C or 92D\n"));
- return;
- }
-
- #if (DM_ODM_SUPPORT_TYPE&(ODM_WIN|ODM_CE))
- if(!pDM_Odm->bLinked)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("Return: bLinked is FALSE\n"));
- return;
- }
- #endif
- for (i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- pEntry = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pEntry))
- {
- RSSI_Ant1 = (pDM_SWAT_Table->OFDM_Ant1_Cnt[i] == 0)?0:(pDM_SWAT_Table->RSSI_Ant1_Sum[i]/pDM_SWAT_Table->OFDM_Ant1_Cnt[i]);
- RSSI_Ant2 = (pDM_SWAT_Table->OFDM_Ant2_Cnt[i] == 0)?0:(pDM_SWAT_Table->RSSI_Ant2_Sum[i]/pDM_SWAT_Table->OFDM_Ant2_Cnt[i]);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("RSSI_Ant1=%d, RSSI_Ant2=%d\n", RSSI_Ant1, RSSI_Ant2));
-
- if(RSSI_Ant1 ||RSSI_Ant2)
- {
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- if(pDM_Odm->pODM_StaInfo[i]->expire_to)
- #endif
- {
- RSSI = (RSSI_Ant1 < RSSI_Ant2) ? RSSI_Ant1 : RSSI_Ant2;
- if((!RSSI) || ( RSSI < RSSI_Min) ) {
- pDM_SWAT_Table->TargetSTA = i;
- RSSI_Min = RSSI;
- }
- }
- }
- ///STA: found out default antenna
- bRet=odm_StaDefAntSel(pDM_Odm,
- pDM_SWAT_Table->OFDM_Ant1_Cnt[i],
- pDM_SWAT_Table->OFDM_Ant2_Cnt[i],
- pDM_SWAT_Table->CCK_Ant1_Cnt[i],
- pDM_SWAT_Table->CCK_Ant2_Cnt[i],
- &pDM_SWAT_Table->TxAnt[i]);
- //if Tx antenna selection: successful
- if(bRet){
- pDM_SWAT_Table->RSSI_Ant1_Sum[i] = 0;
- pDM_SWAT_Table->RSSI_Ant2_Sum[i] = 0;
- pDM_SWAT_Table->OFDM_Ant1_Cnt[i] = 0;
- pDM_SWAT_Table->OFDM_Ant2_Cnt[i] = 0;
- pDM_SWAT_Table->CCK_Ant1_Cnt[i] = 0;
- pDM_SWAT_Table->CCK_Ant2_Cnt[i] = 0;
- }
- }
- }
-
- //set RX Idle Ant
- RxIdleAnt = pDM_SWAT_Table->TxAnt[pDM_SWAT_Table->TargetSTA];
- odm_SetRxIdleAnt(pDM_Odm, RxIdleAnt, FALSE);
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- #ifdef TX_SHORTCUT
- if (!priv->pmib->dot11OperationEntry.disable_txsc) {
- plist = phead->next;
- while(plist != phead) {
- pstat = list_entry(plist, struct stat_info, asoc_list);
- if(pstat->expire_to) {
- for (i=0; i<TX_SC_ENTRY_NUM; i++) {
- struct tx_desc *pdesc= &(pstat->tx_sc_ent[i].hwdesc1);
- pdesc->Dword2 &= set_desc(~ (BIT(24)|BIT(25)));
- if((pstat->CurAntenna^priv->pshare->rf_ft_var.CurAntenna)&1)
- pdesc->Dword2 |= set_desc(BIT(24)|BIT(25));
- pdesc= &(pstat->tx_sc_ent[i].hwdesc2);
- pdesc->Dword2 &= set_desc(~ (BIT(24)|BIT(25)));
- if((pstat->CurAntenna^priv->pshare->rf_ft_var.CurAntenna)&1)
- pdesc->Dword2 |= set_desc(BIT(24)|BIT(25));
- }
- }
- if (plist == plist->next)
- break;
- plist = plist->next;
- };
- }
- #endif
- #endif
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("<==============odm_HwAntDiv\n"));
-
- }
- VOID
- odm_HwAntDiv(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
-
- //if(pAdapter->MgntInfo.AntennaTest)
- // return;
-
- if(!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("Return: Not Support HW AntDiv\n"));
- return;
- }
-
- if(pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D))
- {
- #if ((RTL8192C_SUPPORT == 1)||(RTL8192D_SUPPORT == 1))
- odm_HwAntDiv_92C_92D(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8188E)
- {
- #if (RTL8188E_SUPPORT == 1)
- ODM_AntennaDiversity_88E(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8821)
- {
- #if (RTL8821A_SUPPORT == 1)
- ODM_AntennaDiversity_8821A(pDM_Odm);
- #endif
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8723B)
- {
- #if (RTL8723B_SUPPORT == 1)
- ODM_AntennaDiversity_8723B(pDM_Odm);
- #endif
- }
- }
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- #if 0
- VOID
- odm_HwAntDiv(
- IN PDM_ODM_T pDM_Odm
- )
- {
- struct rtl8192cd_priv *priv=pDM_Odm->priv;
- struct stat_info *pstat, *pstat_min=NULL;
- struct list_head *phead, *plist;
- int rssi_min= 0xff, i;
- u1Byte idleAnt=priv->pshare->rf_ft_var.CurAntenna;
- u1Byte nextAnt;
- BOOLEAN bRet=FALSE;
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("odm_HwAntDiv==============>\n"));
- if((!priv->pshare->rf_ft_var.antHw_enable) ||(!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)))
- return;
-
- //if test, return
- if(priv->pshare->rf_ft_var.CurAntenna & 0x80)
- return;
-
- phead = &priv->asoc_list;
- plist = phead->next;
- ////=========================
- //find mimum rssi sta
- ////=========================
- while(plist != phead) {
- pstat = list_entry(plist, struct stat_info, asoc_list);
- if((pstat->expire_to) && (pstat->AntRSSI[0] || pstat->AntRSSI[1])) {
- int rssi = (pstat->AntRSSI[0] < pstat->AntRSSI[1]) ? pstat->AntRSSI[0] : pstat->AntRSSI[1];
- if((!pstat_min) || ( rssi < rssi_min) ) {
- pstat_min = pstat;
- rssi_min = rssi;
- }
- }
- ///STA: found out default antenna
- bRet=odm_StaDefAntSel(pDM_Odm,
- pstat->hwRxAntSel[1],
- pstat->hwRxAntSel[0],
- pstat->cckPktCount[1],
- pstat->cckPktCount[0],
- &nextAnt
- );
-
- //if default antenna selection: successful
- if(bRet){
- pstat->CurAntenna = nextAnt;
- //update rssi
- for(i=0; i<2; i++) {
- if(pstat->cckPktCount[i]==0 && pstat->hwRxAntSel[i]==0)
- pstat->AntRSSI[i] = 0;
- }
- if(pstat->AntRSSI[idleAnt]==0)
- pstat->AntRSSI[idleAnt] = pstat->AntRSSI[idleAnt^1];
- // reset variables
- pstat->hwRxAntSel[1] = pstat->hwRxAntSel[0] =0;
- pstat->cckPktCount[1]= pstat->cckPktCount[0] =0;
- }
- if (plist == plist->next)
- break;
- plist = plist->next;
-
- };
- ////=========================
- //Choose RX Idle antenna according to minmum rssi
- ////=========================
- if(pstat_min) {
- if(priv->pshare->rf_ft_var.CurAntenna!=pstat_min->CurAntenna)
- odm_SetRxIdleAnt(pDM_Odm,pstat_min->CurAntenna,TRUE);
- priv->pshare->rf_ft_var.CurAntenna = pstat_min->CurAntenna;
- }
- #ifdef TX_SHORTCUT
- if (!priv->pmib->dot11OperationEntry.disable_txsc) {
- plist = phead->next;
- while(plist != phead) {
- pstat = list_entry(plist, struct stat_info, asoc_list);
- if(pstat->expire_to) {
- for (i=0; i<TX_SC_ENTRY_NUM; i++) {
- struct tx_desc *pdesc= &(pstat->tx_sc_ent[i].hwdesc1);
- pdesc->Dword2 &= set_desc(~ (BIT(24)|BIT(25)));
- if((pstat->CurAntenna^priv->pshare->rf_ft_var.CurAntenna)&1)
- pdesc->Dword2 |= set_desc(BIT(24)|BIT(25));
- pdesc= &(pstat->tx_sc_ent[i].hwdesc2);
- pdesc->Dword2 &= set_desc(~ (BIT(24)|BIT(25)));
- if((pstat->CurAntenna^priv->pshare->rf_ft_var.CurAntenna)&1)
- pdesc->Dword2 |= set_desc(BIT(24)|BIT(25));
- }
- }
- if (plist == plist->next)
- break;
- plist = plist->next;
- };
- }
- #endif
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD,"<==============odm_HwAntDiv\n");
- }
- #endif
- u1Byte
- ODM_Diversity_AntennaSelect(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte *data
- )
- {
- struct rtl8192cd_priv *priv=pDM_Odm->priv;
- int ant = _atoi(data, 16);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("ODM_Diversity_AntennaSelect==============>\n"));
- #ifdef PCIE_POWER_SAVING
- PCIeWakeUp(priv, POWER_DOWN_T0);
- #endif
- if (ant==AUX_ANT || ant==MAIN_ANT)
- {
- if ( !priv->pshare->rf_ft_var.antSw_select) {
- ODM_Write4Byte(pDM_Odm,0x870, ODM_Read4Byte(pDM_Odm,0x870) | BIT(8)| BIT(9) ); // ANTSEL A as SW control
- ODM_Write1Byte(pDM_Odm,0xc50, ODM_Read1Byte(pDM_Odm,0xc50) & (~ BIT(7))); // rx OFDM SW control
- PHY_SetBBReg(priv, 0x860, 0x300, ant);
- } else {
- ODM_Write4Byte(pDM_Odm,0x870, ODM_Read4Byte(pDM_Odm,0x870) | BIT(24)| BIT(25) ); // ANTSEL B as HW control
- PHY_SetBBReg(priv, 0x864, 0x300, ant);
- ODM_Write1Byte(pDM_Odm,0xc58, ODM_Read1Byte(pDM_Odm,0xc58) & (~ BIT(7))); // rx OFDM SW control
- }
- ODM_Write1Byte(pDM_Odm,0xa01, ODM_Read1Byte(pDM_Odm,0xa01) & (~ BIT(7))); // rx CCK SW control
- ODM_Write4Byte(pDM_Odm,0x80c, ODM_Read4Byte(pDM_Odm,0x80c) & (~ BIT(21))); // select ant by tx desc
- ODM_Write4Byte(pDM_Odm,0x858, 0x569a569a);
- priv->pshare->rf_ft_var.antHw_enable = 0;
- priv->pshare->rf_ft_var.CurAntenna = (ant%2);
- #ifdef SW_ANT_SWITCH
- priv->pshare->rf_ft_var.antSw_enable = 0;
- priv->pshare->DM_SWAT_Table.CurAntenna = ant;
- priv->pshare->RSSI_test =0;
- #endif
- }
- else if(ant==0){
- if ( !priv->pshare->rf_ft_var.antSw_select) {
- ODM_Write4Byte(pDM_Odm,0x870, ODM_Read4Byte(pDM_Odm,0x870) & ~(BIT(8)| BIT(9)) );
- ODM_Write1Byte(pDM_Odm,0xc50, ODM_Read1Byte(pDM_Odm,0xc50) | BIT(7)); // OFDM HW control
- } else {
- ODM_Write4Byte(pDM_Odm,0x870, ODM_Read4Byte(pDM_Odm,0x870) & ~(BIT(24)| BIT(25)) );
- ODM_Write1Byte(pDM_Odm,0xc58, ODM_Read1Byte(pDM_Odm,0xc58) | BIT(7)); // OFDM HW control
- }
- ODM_Write1Byte(pDM_Odm,0xa01, ODM_Read1Byte(pDM_Odm,0xa01) | BIT(7)); // CCK HW control
- ODM_Write4Byte(pDM_Odm,0x80c, ODM_Read4Byte(pDM_Odm,0x80c) | BIT(21) ); // by tx desc
- priv->pshare->rf_ft_var.CurAntenna = 0;
- ODM_Write4Byte(pDM_Odm,0x858, 0x569a569a);
- priv->pshare->rf_ft_var.antHw_enable = 1;
- #ifdef SW_ANT_SWITCH
- priv->pshare->rf_ft_var.antSw_enable = 0;
- priv->pshare->RSSI_test =0;
- #endif
- }
- #ifdef SW_ANT_SWITCH
- else if(ant==3) {
- if(!priv->pshare->rf_ft_var.antSw_enable) {
-
- dm_SW_AntennaSwitchInit(priv);
- ODM_Write4Byte(pDM_Odm,0x858, 0x569a569a);
- priv->pshare->lastTxOkCnt = priv->net_stats.tx_bytes;
- priv->pshare->lastRxOkCnt = priv->net_stats.rx_bytes;
- }
- if ( !priv->pshare->rf_ft_var.antSw_select)
- ODM_Write1Byte(pDM_Odm,0xc50, ODM_Read1Byte(pDM_Odm,0xc50) & (~ BIT(7))); // rx OFDM SW control
- else
- ODM_Write1Byte(pDM_Odm,0xc58, ODM_Read1Byte(pDM_Odm,0xc58) & (~ BIT(7))); // rx OFDM SW control
- ODM_Write1Byte(pDM_Odm,0xa01, ODM_Read1Byte(pDM_Odm,0xa01) & (~ BIT(7))); // rx CCK SW control
- ODM_Write4Byte(pDM_Odm,0x80c, ODM_Read4Byte(pDM_Odm,0x80c) & (~ BIT(21))); // select ant by tx desc
- priv->pshare->rf_ft_var.antHw_enable = 0;
- priv->pshare->rf_ft_var.antSw_enable = 1;
- }
- #endif
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV,ODM_DBG_LOUD,("<==============ODM_Diversity_AntennaSelect\n"));
- return 1;
- }
- #endif
- #else //#if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- VOID odm_InitHybridAntDiv( IN PDM_ODM_T pDM_Odm ){}
- VOID odm_HwAntDiv( IN PDM_ODM_T pDM_Odm){}
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- VOID ODM_SetTxAntByTxInfo_88C_92D(
- IN PDM_ODM_T pDM_Odm,
- IN pu1Byte pDesc,
- IN u1Byte macId
- ){}
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- VOID ODM_SetTxAntByTxInfo_88C_92D( IN PDM_ODM_T pDM_Odm){ }
- #elif(DM_ODM_SUPPORT_TYPE==ODM_AP)
- VOID ODM_SetTxAntByTxInfo_88C_92D( IN PDM_ODM_T pDM_Odm){ }
- #endif
- #endif //#if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
- //============================================================
- //EDCA Turbo
- //============================================================
- VOID
- ODM_EdcaTurboInit(
- IN PDM_ODM_T pDM_Odm)
- {
- #if ((DM_ODM_SUPPORT_TYPE == ODM_AP)||(DM_ODM_SUPPORT_TYPE==ODM_ADSL))
- odm_EdcaParaInit(pDM_Odm);
- #elif (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- PADAPTER Adapter = NULL;
- HAL_DATA_TYPE *pHalData = NULL;
- if(pDM_Odm->Adapter==NULL) {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("EdcaTurboInit fail!!!\n"));
- return;
- }
- Adapter=pDM_Odm->Adapter;
- pHalData=GET_HAL_DATA(Adapter);
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = FALSE;
- pDM_Odm->DM_EDCA_Table.bIsCurRDLState = FALSE;
- pHalData->bIsAnyNonBEPkts = FALSE;
-
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = FALSE;
- pDM_Odm->DM_EDCA_Table.bIsCurRDLState = FALSE;
- Adapter->recvpriv.bIsAnyNonBEPkts =FALSE;
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Orginial VO PARAM: 0x%x\n",ODM_Read4Byte(pDM_Odm,ODM_EDCA_VO_PARAM)));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Orginial VI PARAM: 0x%x\n",ODM_Read4Byte(pDM_Odm,ODM_EDCA_VI_PARAM)));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Orginial BE PARAM: 0x%x\n",ODM_Read4Byte(pDM_Odm,ODM_EDCA_BE_PARAM)));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Orginial BK PARAM: 0x%x\n",ODM_Read4Byte(pDM_Odm,ODM_EDCA_BK_PARAM)));
-
- } // ODM_InitEdcaTurbo
- VOID
- odm_EdcaTurboCheck(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //
- // For AP/ADSL use prtl8192cd_priv
- // For CE/NIC use PADAPTER
- //
- //
- // 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate
- // at the same time. In the stage2/3, we need to prive universal interface and merge all
- // HW dynamic mechanism.
- //
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("odm_EdcaTurboCheck========================>\n"));
- if(!(pDM_Odm->SupportAbility& ODM_MAC_EDCA_TURBO ))
- return;
- switch (pDM_Odm->SupportPlatform)
- {
- case ODM_WIN:
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- odm_EdcaTurboCheckMP(pDM_Odm);
- #endif
- break;
- case ODM_CE:
- #if(DM_ODM_SUPPORT_TYPE==ODM_CE)
- odm_EdcaTurboCheckCE(pDM_Odm);
- #endif
- break;
- case ODM_AP:
- case ODM_ADSL:
- #if ((DM_ODM_SUPPORT_TYPE == ODM_AP)||(DM_ODM_SUPPORT_TYPE==ODM_ADSL))
- odm_IotEngine(pDM_Odm);
- #endif
- break;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("<========================odm_EdcaTurboCheck\n"));
- } // odm_CheckEdcaTurbo
- #if(DM_ODM_SUPPORT_TYPE==ODM_CE)
- VOID
- odm_EdcaTurboCheckCE(
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if(DM_ODM_SUPPORT_TYPE==ODM_CE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- u32 EDCA_BE_UL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_UL[pMgntInfo->IOTPeer];
- u32 EDCA_BE_DL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_DL[pMgntInfo->IOTPeer];
- u32 ICType=pDM_Odm->SupportICType;
- u32 IOTPeer=0;
- u8 WirelessMode=0xFF; //invalid value
- u32 trafficIndex;
- u32 edca_param;
- u64 cur_tx_bytes = 0;
- u64 cur_rx_bytes = 0;
- u8 bbtchange = _FALSE;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv);
- struct recv_priv *precvpriv = &(Adapter->recvpriv);
- struct registry_priv *pregpriv = &Adapter->registrypriv;
- struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- if ((pregpriv->wifi_spec == 1) )//|| (pmlmeinfo->HT_enable == 0))
- {
- goto dm_CheckEdcaTurbo_EXIT;
- }
- if(pDM_Odm->pWirelessMode!=NULL)
- WirelessMode=*(pDM_Odm->pWirelessMode);
- IOTPeer = pmlmeinfo->assoc_AP_vendor;
- if (IOTPeer >= HT_IOT_PEER_MAX)
- {
- goto dm_CheckEdcaTurbo_EXIT;
- }
- // Check if the status needs to be changed.
- if((bbtchange) || (!precvpriv->bIsAnyNonBEPkts) )
- {
- cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes;
- cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes;
- //traffic, TX or RX
- if((IOTPeer == HT_IOT_PEER_RALINK)||(IOTPeer == HT_IOT_PEER_ATHEROS))
- {
- if (cur_tx_bytes > (cur_rx_bytes << 2))
- { // Uplink TP is present.
- trafficIndex = UP_LINK;
- }
- else
- { // Balance TP is present.
- trafficIndex = DOWN_LINK;
- }
- }
- else
- {
- if (cur_rx_bytes > (cur_tx_bytes << 2))
- { // Downlink TP is present.
- trafficIndex = DOWN_LINK;
- }
- else
- { // Balance TP is present.
- trafficIndex = UP_LINK;
- }
- }
- if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA))
- {
- if(ICType==ODM_RTL8192D)
- {
- // Single PHY
- if(pDM_Odm->RFType==ODM_2T2R)
- {
- EDCA_BE_UL = 0x60a42b; //0x5ea42b;
- EDCA_BE_DL = 0x60a42b; //0x5ea42b;
- }
- else
- {
- EDCA_BE_UL = 0x6ea42b;
- EDCA_BE_DL = 0x6ea42b;
- }
- }
- else
- {
- if(pDM_Odm->SupportInterface==ODM_ITRF_PCIE) {
- if((ICType==ODM_RTL8192C)&&(pDM_Odm->RFType==ODM_2T2R)) {
- EDCA_BE_UL = 0x60a42b;
- EDCA_BE_DL = 0x60a42b;
- }
- else
- {
- EDCA_BE_UL = 0x6ea42b;
- EDCA_BE_DL = 0x6ea42b;
- }
- }
- }
-
- //92D txop can't be set to 0x3e for cisco1250
- if((ICType!=ODM_RTL8192D) && (IOTPeer== HT_IOT_PEER_CISCO) &&(WirelessMode==ODM_WM_N24G))
- {
- EDCA_BE_DL = edca_setting_DL[IOTPeer];
- EDCA_BE_UL = edca_setting_UL[IOTPeer];
- }
- //merge from 92s_92c_merge temp brunch v2445 20120215
- else if((IOTPeer == HT_IOT_PEER_CISCO) &&((WirelessMode==ODM_WM_G)||(WirelessMode==(ODM_WM_B|ODM_WM_G))||(WirelessMode==ODM_WM_A)||(WirelessMode==ODM_WM_B)))
- {
- EDCA_BE_DL = edca_setting_DL_GMode[IOTPeer];
- }
- else if((IOTPeer== HT_IOT_PEER_AIRGO )&& ((WirelessMode==ODM_WM_G)||(WirelessMode==ODM_WM_A)))
- {
- EDCA_BE_DL = 0xa630;
- }
- else if(IOTPeer == HT_IOT_PEER_MARVELL)
- {
- EDCA_BE_DL = edca_setting_DL[IOTPeer];
- EDCA_BE_UL = edca_setting_UL[IOTPeer];
- }
- else if(IOTPeer == HT_IOT_PEER_ATHEROS)
- {
- // Set DL EDCA for Atheros peer to 0x3ea42b. Suggested by SD3 Wilson for ASUS TP issue.
- EDCA_BE_DL = edca_setting_DL[IOTPeer];
- }
- if((ICType==ODM_RTL8812)||(ICType==ODM_RTL8192E)) //add 8812AU/8812AE
- {
- EDCA_BE_UL = 0x5ea42b;
- EDCA_BE_DL = 0x5ea42b;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("8812A: EDCA_BE_UL=0x%x EDCA_BE_DL =0x%x",EDCA_BE_UL,EDCA_BE_DL));
- }
- if (trafficIndex == DOWN_LINK)
- edca_param = EDCA_BE_DL;
- else
- edca_param = EDCA_BE_UL;
- rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param);
- pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex;
- }
-
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = _TRUE;
- }
- else
- {
- //
- // Turn Off EDCA turbo here.
- // Restore original EDCA according to the declaration of AP.
- //
- if(pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)
- {
- rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE);
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = _FALSE;
- }
- }
- dm_CheckEdcaTurbo_EXIT:
- // Set variables for next time.
- precvpriv->bIsAnyNonBEPkts = _FALSE;
- pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes;
- precvpriv->last_rx_bytes = precvpriv->rx_bytes;
- #endif
- }
- #elif(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- VOID
- odm_EdcaTurboCheckMP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- PADAPTER pDefaultAdapter = GetDefaultAdapter(Adapter);
- PADAPTER pExtAdapter = GetFirstExtAdapter(Adapter);//NULL;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- PSTA_QOS pStaQos = Adapter->MgntInfo.pStaQos;
- //[Win7 Count Tx/Rx statistic for Extension Port] odm_CheckEdcaTurbo's Adapter is always Default. 2009.08.20, by Bohn
- u8Byte Ext_curTxOkCnt = 0;
- u8Byte Ext_curRxOkCnt = 0;
- //For future Win7 Enable Default Port to modify AMPDU size dynamically, 2009.08.20, Bohn.
- u1Byte TwoPortStatus = (u1Byte)TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE;
-
- #elif (DM_ODM_SUPPORT_TYPE==ODM_CE)
- struct dm_priv *pdmpriv = &pHalData->dmpriv;
- struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv);
- struct recv_priv *precvpriv = &(Adapter->recvpriv);
- struct registry_priv *pregpriv = &Adapter->registrypriv;
- struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- #ifdef CONFIG_BT_COEXIST
- struct btcoexist_priv *pbtpriv = &(pHalData->bt_coexist);
- #endif
- u1Byte bbtchange =FALSE;
- #endif
- // Keep past Tx/Rx packet count for RT-to-RT EDCA turbo.
- u8Byte curTxOkCnt = 0;
- u8Byte curRxOkCnt = 0;
- u4Byte EDCA_BE_UL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_UL[pMgntInfo->IOTPeer];
- u4Byte EDCA_BE_DL = 0x5ea42b;//Parameter suggested by Scott //edca_setting_DL[pMgntInfo->IOTPeer];
- u4Byte EDCA_BE = 0x5ea42b;
- u4Byte IOTPeer=0;
- BOOLEAN *pbIsCurRDLState=NULL;
- BOOLEAN bLastIsCurRDLState=FALSE;
- BOOLEAN bBiasOnRx=FALSE;
- BOOLEAN bEdcaTurboOn=FALSE;
- u1Byte TxRate = 0xFF;
- u8Byte value64;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("odm_EdcaTurboCheckMP========================>"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Orginial BE PARAM: 0x%x\n",ODM_Read4Byte(pDM_Odm,ODM_EDCA_BE_PARAM)));
- ////===============================
- ////list paramter for different platform
- ////===============================
- bLastIsCurRDLState=pDM_Odm->DM_EDCA_Table.bIsCurRDLState;
- pbIsCurRDLState=&(pDM_Odm->DM_EDCA_Table.bIsCurRDLState);
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- //2012/09/14 MH Add
- if (pMgntInfo->NumNonBePkt > pMgntInfo->RegEdcaThresh &&
- !Adapter->MgntInfo.bWiFiConfg)
- {
- pHalData->bIsAnyNonBEPkts = TRUE;
- }
- pMgntInfo->NumNonBePkt = 0;
- // Caculate TX/RX TP:
- //curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - pMgntInfo->lastTxOkCnt;
- //curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - pMgntInfo->lastRxOkCnt;
- curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - pDM_Odm->lastTxOkCnt;
- curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - pDM_Odm->lastRxOkCnt;
- pDM_Odm->lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
- pDM_Odm->lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
- if(pExtAdapter == NULL)
- pExtAdapter = pDefaultAdapter;
- Ext_curTxOkCnt = pExtAdapter->TxStats.NumTxBytesUnicast - pMgntInfo->Ext_lastTxOkCnt;
- Ext_curRxOkCnt = pExtAdapter->RxStats.NumRxBytesUnicast - pMgntInfo->Ext_lastRxOkCnt;
- GetTwoPortSharedResource(Adapter,TWO_PORT_SHARED_OBJECT__STATUS,NULL,&TwoPortStatus);
- //For future Win7 Enable Default Port to modify AMPDU size dynamically, 2009.08.20, Bohn.
- if(TwoPortStatus == TWO_PORT_STATUS__EXTENSION_ONLY)
- {
- curTxOkCnt = Ext_curTxOkCnt ;
- curRxOkCnt = Ext_curRxOkCnt ;
- }
- //
- IOTPeer=pMgntInfo->IOTPeer;
- bBiasOnRx=(pMgntInfo->IOTAction & HT_IOT_ACT_EDCA_BIAS_ON_RX)?TRUE:FALSE;
- bEdcaTurboOn=((!pHalData->bIsAnyNonBEPkts) && (!pMgntInfo->bDisableFrameBursting))?TRUE:FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("bIsAnyNonBEPkts : 0x%lx bDisableFrameBursting : 0x%lx \n",pHalData->bIsAnyNonBEPkts,pMgntInfo->bDisableFrameBursting));
-
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- // Caculate TX/RX TP:
- curTxOkCnt = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes;
- curRxOkCnt = precvpriv->rx_bytes - precvpriv->last_rx_bytes;
- #ifdef CONFIG_BT_COEXIST
- if(pbtpriv->BT_Coexist)
- {
- if( (pbtpriv->BT_EDCA[UP_LINK]!=0) || (pbtpriv->BT_EDCA[DOWN_LINK]!=0))
- bbtchange = TRUE;
- }
- #endif
- IOTPeer=pmlmeinfo->assoc_AP_vendor;
- bBiasOnRx=((IOTPeer == HT_IOT_PEER_RALINK)||(IOTPeer == HT_IOT_PEER_ATHEROS))?TRUE:FALSE;
- bEdcaTurboOn=(bbtchange || (!precvpriv->bIsAnyNonBEPkts))?TRUE:FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("bbtchange : 0x%lx bIsAnyNonBEPkts : 0x%lx \n",bbtchange,precvpriv->bIsAnyNonBEPkts));
- #endif
- ////===============================
- ////check if edca turbo is disabled
- ////===============================
- if(odm_IsEdcaTurboDisable(pDM_Odm))
- goto dm_CheckEdcaTurbo_EXIT;
- ////===============================
- ////remove iot case out
- ////===============================
- ODM_EdcaParaSelByIot(pDM_Odm, &EDCA_BE_UL, &EDCA_BE_DL);
- ////===============================
- ////Check if the status needs to be changed.
- ////===============================
- if(bEdcaTurboOn)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("bEdcaTurboOn : 0x%x bBiasOnRx : 0x%x\n",bEdcaTurboOn,bBiasOnRx));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("curTxOkCnt : 0x%lx \n",curTxOkCnt));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("curRxOkCnt : 0x%lx \n",curRxOkCnt));
- if(bBiasOnRx)
- odm_EdcaChooseTrafficIdx(pDM_Odm,curTxOkCnt, curRxOkCnt, TRUE, pbIsCurRDLState);
- else
- odm_EdcaChooseTrafficIdx(pDM_Odm,curTxOkCnt, curRxOkCnt, FALSE, pbIsCurRDLState);
- //modify by Guo.Mingzhi 2011-12-29
- EDCA_BE=((*pbIsCurRDLState)==TRUE)?EDCA_BE_DL:EDCA_BE_UL;
- if(IS_HARDWARE_TYPE_8811AU(Adapter))
- {
- if(pMgntInfo->RegTxDutyEnable)
- {
- //2013.01.23 LukeLee: debug for 8811AU thermal issue (reduce Tx duty cycle)
- if(!pMgntInfo->ForcedDataRate) //auto rate
- {
- if(pDM_Odm->TxRate != 0xFF)
- TxRate = HwRateToMRate8812(pDM_Odm->TxRate);
- }
- else //force rate
- {
- TxRate = (u1Byte) pMgntInfo->ForcedDataRate;
- }
- value64 = (curRxOkCnt<<2);
- if(curTxOkCnt < value64) //Downlink
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- else //Uplink
- {
- //DbgPrint("pDM_Odm->RFCalibrateInfo.ThermalValue = 0x%X\n", pDM_Odm->RFCalibrateInfo.ThermalValue);
- //if(pDM_Odm->RFCalibrateInfo.ThermalValue < pHalData->EEPROMThermalMeter)
- if(pDM_Odm->RFCalibrateInfo.ThermalValue < 0x2c)
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- else
- {
- switch (TxRate)
- {
- case MGN_VHT1SS_MCS6:
- case MGN_VHT1SS_MCS5:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0x1ea42b);
- break;
- case MGN_VHT1SS_MCS4:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0xa42b);
- break;
- case MGN_VHT1SS_MCS3:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0xa47f);
- break;
- case MGN_VHT1SS_MCS2:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0xa57f);
- break;
- case MGN_VHT1SS_MCS1:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0xa77f);
- break;
- case MGN_VHT1SS_MCS0:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,0xa87f);
- break;
- default:
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- break;
- }
- }
- }
- }
- else
- {
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- }
- }
- else
- ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("EDCA Turbo on: EDCA_BE:0x%lx\n",EDCA_BE));
- // if(((*pbIsCurRDLState)!=bLastIsCurRDLState)||(!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA))
- // {
- // EDCA_BE=((*pbIsCurRDLState)==TRUE)?EDCA_BE_DL:EDCA_BE_UL;
- // ODM_Write4Byte(pDM_Odm,ODM_EDCA_BE_PARAM,EDCA_BE);
- // }
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = TRUE;
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("EDCA_BE_DL : 0x%lx EDCA_BE_UL : 0x%lx EDCA_BE : 0x%lx \n",EDCA_BE_DL,EDCA_BE_UL,EDCA_BE));
- }
- else
- {
- // Turn Off EDCA turbo here.
- // Restore original EDCA according to the declaration of AP.
- if(pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)
- {
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_AC_PARAM, GET_WMM_PARAM_ELE_SINGLE_AC_PARAM(pStaQos->WMMParamEle, AC0_BE) );
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, pHalData->AcParam_BE);
- #endif
- pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Restore EDCA BE: 0x%lx \n",pDM_Odm->WMMEDCA_BE));
- }
- }
- ////===============================
- ////Set variables for next time.
- ////===============================
- dm_CheckEdcaTurbo_EXIT:
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- pHalData->bIsAnyNonBEPkts = FALSE;
- pMgntInfo->lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
- pMgntInfo->lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
- pMgntInfo->Ext_lastTxOkCnt = pExtAdapter->TxStats.NumTxBytesUnicast;
- pMgntInfo->Ext_lastRxOkCnt = pExtAdapter->RxStats.NumRxBytesUnicast;
- #elif (DM_ODM_SUPPORT_TYPE==ODM_CE)
- precvpriv->bIsAnyNonBEPkts = FALSE;
- pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes;
- precvpriv->last_rx_bytes = precvpriv->rx_bytes;
- #endif
- }
- //check if edca turbo is disabled
- BOOLEAN
- odm_IsEdcaTurboDisable(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- u4Byte IOTPeer=pMgntInfo->IOTPeer;
- #elif (DM_ODM_SUPPORT_TYPE==ODM_CE)
- struct registry_priv *pregpriv = &Adapter->registrypriv;
- struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv);
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- u4Byte IOTPeer=pmlmeinfo->assoc_AP_vendor;
- u1Byte WirelessMode=0xFF; //invalid value
- if(pDM_Odm->pWirelessMode!=NULL)
- WirelessMode=*(pDM_Odm->pWirelessMode);
- #endif
- if(pDM_Odm->bBtDisableEdcaTurbo)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD, ("EdcaTurboDisable for BT!!\n"));
- return TRUE;
- }
- if((!(pDM_Odm->SupportAbility& ODM_MAC_EDCA_TURBO ))||
- (pDM_Odm->bWIFITest)||
- (IOTPeer>= HT_IOT_PEER_MAX))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD, ("EdcaTurboDisable\n"));
- return TRUE;
- }
- #if (DM_ODM_SUPPORT_TYPE ==ODM_WIN)
- // 1. We do not turn on EDCA turbo mode for some AP that has IOT issue
- // 2. User may disable EDCA Turbo mode with OID settings.
- if(pMgntInfo->IOTAction & HT_IOT_ACT_DISABLE_EDCA_TURBO){
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD, ("IOTAction:EdcaTurboDisable\n"));
- return TRUE;
- }
-
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- //suggested by Jr.Luke: open TXOP for B/G/BG/A mode 2012-0215
- if((WirelessMode==ODM_WM_B)||(WirelessMode==(ODM_WM_B|ODM_WM_G)||(WirelessMode==ODM_WM_G)||(WirelessMode=ODM_WM_A))
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM)|0x5E0000);
-
- if(pDM_Odm->SupportICType==ODM_RTL8192D) {
- if ((pregpriv->wifi_spec == 1) || (pmlmeext->cur_wireless_mode == WIRELESS_11B)) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD, ("92D:EdcaTurboDisable\n"));
- return TRUE;
- }
- }
- else
- {
- if((pregpriv->wifi_spec == 1) || (pmlmeinfo->HT_enable == 0)){
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD, ("Others:EdcaTurboDisable\n"));
- return TRUE;
- }
- }
- #endif
- return FALSE;
-
- }
- //add iot case here: for MP/CE
- VOID
- ODM_EdcaParaSelByIot(
- IN PDM_ODM_T pDM_Odm,
- OUT u4Byte *EDCA_BE_UL,
- OUT u4Byte *EDCA_BE_DL
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u4Byte IOTPeer=0;
- u4Byte ICType=pDM_Odm->SupportICType;
- u1Byte WirelessMode=0xFF; //invalid value
- u4Byte RFType=pDM_Odm->RFType;
- u4Byte IOTPeerSubType=0;
- #if(DM_ODM_SUPPORT_TYPE==ODM_WIN)
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- u1Byte TwoPortStatus = (u1Byte)TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE;
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
- #ifdef CONFIG_BT_COEXIST
- struct btcoexist_priv *pbtpriv = &(pHalData->bt_coexist);
- #endif
- u1Byte bbtchange =FALSE;
- #endif
- if(pDM_Odm->pWirelessMode!=NULL)
- WirelessMode=*(pDM_Odm->pWirelessMode);
-
- ///////////////////////////////////////////////////////////
- ////list paramter for different platform
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- IOTPeer=pMgntInfo->IOTPeer;
- IOTPeerSubType=pMgntInfo->IOTPeerSubtype;
- GetTwoPortSharedResource(Adapter,TWO_PORT_SHARED_OBJECT__STATUS,NULL,&TwoPortStatus);
- #elif(DM_ODM_SUPPORT_TYPE==ODM_CE)
- IOTPeer=pmlmeinfo->assoc_AP_vendor;
- #ifdef CONFIG_BT_COEXIST
- if(pbtpriv->BT_Coexist)
- {
- if( (pbtpriv->BT_EDCA[UP_LINK]!=0) || (pbtpriv->BT_EDCA[DOWN_LINK]!=0))
- bbtchange = TRUE;
- }
- #endif
- #endif
- if(ICType==ODM_RTL8192D)
- {
- // Single PHY
- if(pDM_Odm->RFType==ODM_2T2R)
- {
- (*EDCA_BE_UL) = 0x60a42b; //0x5ea42b;
- (*EDCA_BE_DL) = 0x60a42b; //0x5ea42b;
- }
- else
- {
- (*EDCA_BE_UL) = 0x6ea42b;
- (*EDCA_BE_DL) = 0x6ea42b;
- }
- }
- ////============================
- /// IOT case for MP
- ////============================
- #if (DM_ODM_SUPPORT_TYPE==ODM_WIN)
- else
- {
- if(pDM_Odm->SupportInterface==ODM_ITRF_PCIE){
- if((ICType==ODM_RTL8192C)&&(pDM_Odm->RFType==ODM_2T2R)) {
- (*EDCA_BE_UL) = 0x60a42b;
- (*EDCA_BE_DL) = 0x60a42b;
- }
- else
- {
- (*EDCA_BE_UL) = 0x6ea42b;
- (*EDCA_BE_DL) = 0x6ea42b;
- }
- }
- }
-
- if(TwoPortStatus == TWO_PORT_STATUS__EXTENSION_ONLY)
- {
- (*EDCA_BE_UL) = 0x5ea42b;//Parameter suggested by Scott //edca_setting_UL[ExtAdapter->MgntInfo.IOTPeer];
- (*EDCA_BE_DL) = 0x5ea42b;//Parameter suggested by Scott //edca_setting_DL[ExtAdapter->MgntInfo.IOTPeer];
- }
-
- #if (INTEL_PROXIMITY_SUPPORT == 1)
- if(pMgntInfo->IntelClassModeInfo.bEnableCA == TRUE)
- {
- (*EDCA_BE_UL) = (*EDCA_BE_DL) = 0xa44f;
- }
- else
- #endif
- {
- if((!pMgntInfo->bDisableFrameBursting) &&
- (pMgntInfo->IOTAction & (HT_IOT_ACT_FORCED_ENABLE_BE_TXOP|HT_IOT_ACT_AMSDU_ENABLE)))
- {// To check whether we shall force turn on TXOP configuration.
- if(!((*EDCA_BE_UL) & 0xffff0000))
- (*EDCA_BE_UL) |= 0x005e0000; // Force TxOP limit to 0x005e for UL.
- if(!((*EDCA_BE_DL) & 0xffff0000))
- (*EDCA_BE_DL) |= 0x005e0000; // Force TxOP limit to 0x005e for DL.
- }
-
- //92D txop can't be set to 0x3e for cisco1250
- if((ICType!=ODM_RTL8192D) && (IOTPeer== HT_IOT_PEER_CISCO) &&(WirelessMode==ODM_WM_N24G))
- {
- (*EDCA_BE_DL) = edca_setting_DL[IOTPeer];
- (*EDCA_BE_UL) = edca_setting_UL[IOTPeer];
- }
- //merge from 92s_92c_merge temp brunch v2445 20120215
- else if((IOTPeer == HT_IOT_PEER_CISCO) &&((WirelessMode==ODM_WM_G)||(WirelessMode==(ODM_WM_B|ODM_WM_G))||(WirelessMode==ODM_WM_A)||(WirelessMode==ODM_WM_B)))
- {
- (*EDCA_BE_DL) = edca_setting_DL_GMode[IOTPeer];
- }
- else if((IOTPeer== HT_IOT_PEER_AIRGO )&& ((WirelessMode==ODM_WM_G)||(WirelessMode==ODM_WM_A)))
- {
- (*EDCA_BE_DL) = 0xa630;
- }
- else if(IOTPeer == HT_IOT_PEER_MARVELL)
- {
- (*EDCA_BE_DL) = edca_setting_DL[IOTPeer];
- (*EDCA_BE_UL) = edca_setting_UL[IOTPeer];
- }
- else if(IOTPeer == HT_IOT_PEER_ATHEROS)
- {
- // Set DL EDCA for Atheros peer to 0x3ea42b. Suggested by SD3 Wilson for ASUS TP issue.
- (*EDCA_BE_DL) = edca_setting_DL[IOTPeer];
-
- if(ICType == ODM_RTL8821)
- (*EDCA_BE_DL) = 0x5ea630;
-
- }
- }
- if((ICType == ODM_RTL8192D)&&(IOTPeerSubType == HT_IOT_PEER_LINKSYS_E4200_V1)&&((WirelessMode==ODM_WM_N5G)))
- {
- (*EDCA_BE_DL) = 0x432b;
- (*EDCA_BE_UL) = 0x432b;
- }
- if((ICType==ODM_RTL8812)||(ICType==ODM_RTL8192E)) //add 8812AU/8812AE
- {
- (*EDCA_BE_UL) = 0x5ea42b;
- (*EDCA_BE_DL) = 0x5ea42b;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("8812A: EDCA_BE_UL=0x%lx EDCA_BE_DL =0x%lx",(*EDCA_BE_UL),(*EDCA_BE_DL)));
- }
- // Revised for Atheros DIR-655 IOT issue to improve down link TP, added by Roger, 2013.03.22.
- if((ICType == ODM_RTL8723A) && (IOTPeerSubType== HT_IOT_PEER_ATHEROS_DIR655) &&
- (pMgntInfo->dot11CurrentChannelNumber == 6))
- {
- (*EDCA_BE_DL) = 0xa92b;
- }
- ////============================
- /// IOT case for CE
- ////============================
- #elif (DM_ODM_SUPPORT_TYPE==ODM_CE)
- if(RFType==ODM_RTL8192D)
- {
- if((IOTPeer == HT_IOT_PEER_CISCO) &&(WirelessMode==ODM_WM_N24G))
- {
- (*EDCA_BE_UL) = EDCAParam[IOTPeer][UP_LINK];
- (*EDCA_BE_DL)=EDCAParam[IOTPeer][DOWN_LINK];
- }
- else if((IOTPeer == HT_IOT_PEER_AIRGO) &&
- ((WirelessMode==ODM_WM_B)||(WirelessMode==(ODM_WM_B|ODM_WM_G))))
- (*EDCA_BE_DL)=0x00a630;
-
- else if((IOTPeer== HT_IOT_PEER_ATHEROS) &&
- (WirelessMode&ODM_WM_N5G) &&
- (Adapter->securitypriv.dot11PrivacyAlgrthm == _AES_ ))
- (*EDCA_BE_DL)=0xa42b;
-
- }
- //92C IOT case:
- else
- {
- #ifdef CONFIG_BT_COEXIST
- if(bbtchange)
- {
- (*EDCA_BE_UL) = pbtpriv->BT_EDCA[UP_LINK];
- (*EDCA_BE_DL) = pbtpriv->BT_EDCA[DOWN_LINK];
- }
- else
- #endif
- {
- if((IOTPeer == HT_IOT_PEER_CISCO) &&(WirelessMode==ODM_WM_N24G))
- {
- (*EDCA_BE_UL) = EDCAParam[IOTPeer][UP_LINK];
- (*EDCA_BE_DL)=EDCAParam[IOTPeer][DOWN_LINK];
- }
- else
- {
- (*EDCA_BE_UL)=EDCAParam[HT_IOT_PEER_UNKNOWN][UP_LINK];
- (*EDCA_BE_DL)=EDCAParam[HT_IOT_PEER_UNKNOWN][DOWN_LINK];
- }
- }
- if(pDM_Odm->SupportInterface==ODM_ITRF_PCIE){
- if((ICType==ODM_RTL8192C)&&(pDM_Odm->RFType==ODM_2T2R))
- {
- (*EDCA_BE_UL) = 0x60a42b;
- (*EDCA_BE_DL) = 0x60a42b;
- }
- else
- {
- (*EDCA_BE_UL) = 0x6ea42b;
- (*EDCA_BE_DL) = 0x6ea42b;
- }
- }
- }
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Special: EDCA_BE_UL=0x%lx EDCA_BE_DL =0x%lx",(*EDCA_BE_UL),(*EDCA_BE_DL)));
- }
- VOID
- odm_EdcaChooseTrafficIdx(
- IN PDM_ODM_T pDM_Odm,
- IN u8Byte cur_tx_bytes,
- IN u8Byte cur_rx_bytes,
- IN BOOLEAN bBiasOnRx,
- OUT BOOLEAN *pbIsCurRDLState
- )
- {
-
-
- if(bBiasOnRx)
- {
-
- if(cur_tx_bytes>(cur_rx_bytes*4))
- {
- *pbIsCurRDLState=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Uplink Traffic\n "));
- }
- else
- {
- *pbIsCurRDLState=TRUE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Balance Traffic\n"));
- }
- }
- else
- {
- if(cur_rx_bytes>(cur_tx_bytes*4))
- {
- *pbIsCurRDLState=TRUE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Downlink Traffic\n"));
- }
- else
- {
- *pbIsCurRDLState=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_EDCA_TURBO,ODM_DBG_LOUD,("Balance Traffic\n"));
- }
- }
- return ;
- }
- #endif
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)||(DM_ODM_SUPPORT_TYPE==ODM_ADSL))
- void odm_EdcaParaInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- prtl8192cd_priv priv = pDM_Odm->priv;
- int mode=priv->pmib->dot11BssType.net_work_type;
-
- static unsigned int slot_time, VO_TXOP, VI_TXOP, sifs_time;
- struct ParaRecord EDCA[4];
- memset(EDCA, 0, 4*sizeof(struct ParaRecord));
- sifs_time = 10;
- slot_time = 20;
- if (mode & (ODM_WM_N24G|ODM_WM_N5G))
- sifs_time = 16;
- if (mode & (ODM_WM_N24G|ODM_WM_N5G| ODM_WM_G|ODM_WM_A))
- slot_time = 9;
- #if((defined(RTL_MANUAL_EDCA))&&(DM_ODM_SUPPORT_TYPE==ODM_AP))
- if( priv->pmib->dot11QosEntry.ManualEDCA ) {
- if( OPMODE & WIFI_AP_STATE )
- memcpy(EDCA, priv->pmib->dot11QosEntry.AP_manualEDCA, 4*sizeof(struct ParaRecord));
- else
- memcpy(EDCA, priv->pmib->dot11QosEntry.STA_manualEDCA, 4*sizeof(struct ParaRecord));
- #ifdef WIFI_WMM
- if (QOS_ENABLE)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, (EDCA[VI].TXOPlimit<< 16) | (EDCA[VI].ECWmax<< 12) | (EDCA[VI].ECWmin<< 8) | (sifs_time + EDCA[VI].AIFSN* slot_time));
- else
- #endif
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, (EDCA[BE].TXOPlimit<< 16) | (EDCA[BE].ECWmax<< 12) | (EDCA[BE].ECWmin<< 8) | (sifs_time + EDCA[VI].AIFSN* slot_time));
- }else
- #endif //RTL_MANUAL_EDCA
- {
- if(OPMODE & WIFI_AP_STATE)
- {
- memcpy(EDCA, rtl_ap_EDCA, 2*sizeof(struct ParaRecord));
- if(mode & (ODM_WM_A|ODM_WM_G|ODM_WM_N24G|ODM_WM_N5G))
- memcpy(&EDCA[VI], &rtl_ap_EDCA[VI_AG], 2*sizeof(struct ParaRecord));
- else
- memcpy(&EDCA[VI], &rtl_ap_EDCA[VI], 2*sizeof(struct ParaRecord));
- }
- else
- {
- memcpy(EDCA, rtl_sta_EDCA, 2*sizeof(struct ParaRecord));
- if(mode & (ODM_WM_A|ODM_WM_G|ODM_WM_N24G|ODM_WM_N5G))
- memcpy(&EDCA[VI], &rtl_sta_EDCA[VI_AG], 2*sizeof(struct ParaRecord));
- else
- memcpy(&EDCA[VI], &rtl_sta_EDCA[VI], 2*sizeof(struct ParaRecord));
- }
-
- #ifdef WIFI_WMM
- if (QOS_ENABLE)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, (EDCA[VI].TXOPlimit<< 16) | (EDCA[VI].ECWmax<< 12) | (EDCA[VI].ECWmin<< 8) | (sifs_time + EDCA[VI].AIFSN* slot_time));
- else
- #endif
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, (EDCA[BK].ECWmax<< 12) | (EDCA[BK].ECWmin<< 8) | (sifs_time + EDCA[VI].AIFSN* slot_time));
- #elif(DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, (EDCA[BK].ECWmax<< 12) | (EDCA[BK].ECWmin<< 8) | (sifs_time + 2* slot_time));
- #endif
-
- }
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VO_PARAM, (EDCA[VO].TXOPlimit<< 16) | (EDCA[VO].ECWmax<< 12) | (EDCA[VO].ECWmin<< 8) | (sifs_time + EDCA[VO].AIFSN* slot_time));
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (EDCA[BE].TXOPlimit<< 16) | (EDCA[BE].ECWmax<< 12) | (EDCA[BE].ECWmin<< 8) | (sifs_time + EDCA[BE].AIFSN* slot_time));
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BK_PARAM, (EDCA[BK].TXOPlimit<< 16) | (EDCA[BK].ECWmax<< 12) | (EDCA[BK].ECWmin<< 8) | (sifs_time + EDCA[BK].AIFSN* slot_time));
- // ODM_Write1Byte(pDM_Odm,ACMHWCTRL, 0x00);
- priv->pshare->iot_mode_enable = 0;
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (priv->pshare->rf_ft_var.wifi_beq_iot)
- priv->pshare->iot_mode_VI_exist = 0;
-
- #ifdef WMM_VIBE_PRI
- priv->pshare->iot_mode_BE_exist = 0;
- #endif
-
- #ifdef LOW_TP_TXOP
- priv->pshare->BE_cwmax_enhance = 0;
- #endif
- #elif (DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- priv->pshare->iot_mode_BE_exist = 0;
- #endif
- priv->pshare->iot_mode_VO_exist = 0;
- }
- BOOLEAN
- ODM_ChooseIotMainSTA(
- IN PDM_ODM_T pDM_Odm,
- IN PSTA_INFO_T pstat
- )
- {
- prtl8192cd_priv priv = pDM_Odm->priv;
- BOOLEAN bhighTP_found_pstat=FALSE;
-
- if ((GET_ROOT(priv)->up_time % 2) == 0) {
- unsigned int tx_2s_avg = 0;
- unsigned int rx_2s_avg = 0;
- int i=0, aggReady=0;
- unsigned long total_sum = (priv->pshare->current_tx_bytes+priv->pshare->current_rx_bytes);
- pstat->current_tx_bytes += pstat->tx_byte_cnt;
- pstat->current_rx_bytes += pstat->rx_byte_cnt;
- if (total_sum != 0) {
- if (total_sum <= 100) {
- tx_2s_avg = (unsigned int)((pstat->current_tx_bytes*100) / total_sum);
- rx_2s_avg = (unsigned int)((pstat->current_rx_bytes*100) / total_sum);
- } else {
- tx_2s_avg = (unsigned int)(pstat->current_tx_bytes / (total_sum / 100));
- rx_2s_avg = (unsigned int)(pstat->current_rx_bytes / (total_sum / 100));
- }
- }
- #if(DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- if (pstat->ht_cap_len) {
- if ((tx_2s_avg + rx_2s_avg) >=25 /*50*/) {
- priv->pshare->highTP_found_pstat = pstat;
- bhighTP_found_pstat=TRUE;
- }
- }
- #elif(DM_ODM_SUPPORT_TYPE==ODM_AP)
- for(i=0; i<8; i++)
- aggReady += (pstat->ADDBA_ready[i]);
- if (pstat->ht_cap_len && aggReady)
- {
- if ((tx_2s_avg + rx_2s_avg >= 25)) {
- priv->pshare->highTP_found_pstat = pstat;
- }
-
- #ifdef CLIENT_MODE
- if (OPMODE & WIFI_STATION_STATE) {
- #if (DM_ODM_SUPPORT_TYPE &ODM_AP) && defined(USE_OUT_SRC)
- if ((pstat->IOTPeer==HT_IOT_PEER_RALINK) && ((tx_2s_avg + rx_2s_avg) >= 45))
- #else
- if(pstat->is_ralink_sta && ((tx_2s_avg + rx_2s_avg) >= 45))
- #endif
- priv->pshare->highTP_found_pstat = pstat;
- }
- #endif
- }
- #endif
- } else {
- pstat->current_tx_bytes = pstat->tx_byte_cnt;
- pstat->current_rx_bytes = pstat->rx_byte_cnt;
- }
- return bhighTP_found_pstat;
- }
- #ifdef WIFI_WMM
- VOID
- ODM_IotEdcaSwitch(
- IN PDM_ODM_T pDM_Odm,
- IN unsigned char enable
- )
- {
- prtl8192cd_priv priv = pDM_Odm->priv;
- int mode=priv->pmib->dot11BssType.net_work_type;
- unsigned int slot_time = 20, sifs_time = 10, BE_TXOP = 47, VI_TXOP = 94;
- unsigned int vi_cw_max = 4, vi_cw_min = 3, vi_aifs;
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (!(!priv->pmib->dot11OperationEntry.wifi_specific ||
- ((OPMODE & WIFI_AP_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- #ifdef CLIENT_MODE
- || ((OPMODE & WIFI_STATION_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- #endif
- ))
- return;
- #endif
- if ((mode & (ODM_WM_N24G|ODM_WM_N5G)) && (priv->pshare->ht_sta_num
- #ifdef WDS
- || ((OPMODE & WIFI_AP_STATE) && priv->pmib->dot11WdsInfo.wdsEnabled && priv->pmib->dot11WdsInfo.wdsNum)
- #endif
- ))
- sifs_time = 16;
- if (mode & (ODM_WM_N24G|ODM_WM_N5G|ODM_WM_G|ODM_WM_A)) {
- slot_time = 9;
- }
- else
- {
- BE_TXOP = 94;
- VI_TXOP = 188;
- }
- #if (DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- if (priv->pshare->iot_mode_VO_exist) {
- // to separate AC_VI and AC_BE to avoid using the same EDCA settings
- if (priv->pshare->iot_mode_BE_exist) {
- vi_cw_max = 5;
- vi_cw_min = 3;
- } else {
- vi_cw_max = 6;
- vi_cw_min = 4;
- }
- }
- vi_aifs = (sifs_time + ((OPMODE & WIFI_AP_STATE)?1:2) * slot_time);
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, ((VI_TXOP*(1-priv->pshare->iot_mode_VO_exist)) << 16)| (vi_cw_max << 12) | (vi_cw_min << 8) | vi_aifs);
-
- #elif (DM_ODM_SUPPORT_TYPE==ODM_AP)
- if ((OPMODE & WIFI_AP_STATE) && priv->pmib->dot11OperationEntry.wifi_specific) {
- if (priv->pshare->iot_mode_VO_exist) {
- #ifdef WMM_VIBE_PRI
- if (priv->pshare->iot_mode_BE_exist)
- {
- vi_cw_max = 5;
- vi_cw_min = 3;
- vi_aifs = (sifs_time + ((OPMODE & WIFI_AP_STATE)?1:2) * slot_time);
- }
- else
- #endif
- {
- vi_cw_max = 6;
- vi_cw_min = 4;
- vi_aifs = 0x2b;
- }
- }
- else {
- vi_aifs = (sifs_time + ((OPMODE & WIFI_AP_STATE)?1:2) * slot_time);
- }
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_VI_PARAM, ((VI_TXOP*(1-priv->pshare->iot_mode_VO_exist)) << 16)
- | (vi_cw_max << 12) | (vi_cw_min << 8) | vi_aifs);
- }
- #endif
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (priv->pshare->rf_ft_var.wifi_beq_iot && priv->pshare->iot_mode_VI_exist)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (10 << 12) | (4 << 8) | 0x4f);
- else if(!enable)
- #elif(DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- if(!enable) //if iot is disable ,maintain original BEQ PARAM
- #endif
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (((OPMODE & WIFI_AP_STATE)?6:10) << 12) | (4 << 8)
- | (sifs_time + 3 * slot_time));
- else
- {
- int txop_enlarge;
- int txop;
- unsigned int cw_max;
- unsigned int txop_close;
-
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined LOW_TP_TXOP))
- cw_max = ((priv->pshare->BE_cwmax_enhance) ? 10 : 6);
- txop_close = ((priv->pshare->rf_ft_var.low_tp_txop && priv->pshare->rf_ft_var.low_tp_txop_close) ? 1 : 0);
- if(priv->pshare->txop_enlarge == 0xe) //if intel case
- txop = (txop_close ? 0 : (BE_TXOP*2));
- else //if other case
- txop = (txop_close ? 0: (BE_TXOP*priv->pshare->txop_enlarge));
- #else
- cw_max=6;
- if((priv->pshare->txop_enlarge==0xe)||(priv->pshare->txop_enlarge==0xd))
- txop=BE_TXOP*2;
- else
- txop=BE_TXOP*priv->pshare->txop_enlarge;
- #endif
-
- if (priv->pshare->ht_sta_num
- #ifdef WDS
- || ((OPMODE & WIFI_AP_STATE) && (mode & (ODM_WM_N24G|ODM_WM_N5G)) &&
- priv->pmib->dot11WdsInfo.wdsEnabled && priv->pmib->dot11WdsInfo.wdsNum)
- #endif
- )
- {
- if (priv->pshare->txop_enlarge == 0xe) {
- // is intel client, use a different edca value
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (txop<< 16) | (cw_max<< 12) | (4 << 8) | 0x1f);
- priv->pshare->txop_enlarge = 2;
- }
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- #ifndef LOW_TP_TXOP
- else if (priv->pshare->txop_enlarge == 0xd) {
- // is intel ralink, use a different edca value
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (txop << 16) | (4 << 12) | (3 << 8) | 0x19);
- priv->pshare->txop_enlarge = 2;
- }
- #endif
- #endif
- else
- {
- if (pDM_Odm->RFType==ODM_2T2R)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (txop << 16) |
- (cw_max << 12) | (4 << 8) | (sifs_time + 3 * slot_time));
- else
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined LOW_TP_TXOP)
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (txop << 16) |
- (((priv->pshare->BE_cwmax_enhance) ? 10 : 5) << 12) | (3 << 8) | (sifs_time + 2 * slot_time));
- #else
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (txop << 16) |
- (5 << 12) | (3 << 8) | (sifs_time + 2 * slot_time));
- #endif
- }
- }
- else
- {
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined LOW_TP_TXOP))
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (BE_TXOP << 16) | (cw_max << 12) | (4 << 8) | (sifs_time + 3 * slot_time));
- #else
- #if defined(CONFIG_RTL_8196D) || defined(CONFIG_RTL_8196E) || (defined(CONFIG_RTL_8197D) && !defined(CONFIG_PORT0_EXT_GIGA))
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (BE_TXOP*2 << 16) | (cw_max << 12) | (5 << 8) | (sifs_time + 3 * slot_time));
- #else
- ODM_Write4Byte(pDM_Odm, ODM_EDCA_BE_PARAM, (BE_TXOP*2 << 16) | (cw_max << 12) | (4 << 8) | (sifs_time + 3 * slot_time));
- #endif
-
- #endif
- }
- }
- }
- #endif
- VOID
- odm_IotEngine(
- IN PDM_ODM_T pDM_Odm
- )
- {
- struct rtl8192cd_priv *priv=pDM_Odm->priv;
- PSTA_INFO_T pstat = NULL;
- u4Byte i;
-
- #ifdef WIFI_WMM
- unsigned int switch_turbo = 0;
- #endif
- ////////////////////////////////////////////////////////
- // if EDCA Turbo function is not supported or Manual EDCA Setting
- // then return
- ////////////////////////////////////////////////////////
- if(!(pDM_Odm->SupportAbility&ODM_MAC_EDCA_TURBO)){
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("ODM_MAC_EDCA_TURBO NOT SUPPORTED\n"));
- return;
- }
-
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)&& defined(RTL_MANUAL_EDCA) && defined(WIFI_WMM))
- if(priv->pmib->dot11QosEntry.ManualEDCA){
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("ODM_MAC_EDCA_TURBO OFF: MANUAL SETTING\n"));
- return ;
- }
- #endif
- #if !(DM_ODM_SUPPORT_TYPE &ODM_AP)
- //////////////////////////////////////////////////////
- //find high TP STA every 2s
- //////////////////////////////////////////////////////
- if ((GET_ROOT(priv)->up_time % 2) == 0)
- priv->pshare->highTP_found_pstat==NULL;
- #if 0
- phead = &priv->asoc_list;
- plist = phead->next;
- while(plist != phead) {
- pstat = list_entry(plist, struct stat_info, asoc_list);
- if(ODM_ChooseIotMainSTA(pDM_Odm, pstat)); //find the correct station
- break;
- if (plist == plist->next) //the last plist
- break;
- plist = plist->next;
- };
- #endif
- //find highTP STA
- for(i=0; i<ODM_ASSOCIATE_ENTRY_NUM; i++) {
- pstat = pDM_Odm->pODM_StaInfo[i];
- if(IS_STA_VALID(pstat) && (ODM_ChooseIotMainSTA(pDM_Odm, pstat))) //find the correct station
- break;
- }
- //////////////////////////////////////////////////////
- //if highTP STA is not found, then return
- //////////////////////////////////////////////////////
- if(priv->pshare->highTP_found_pstat==NULL) {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("ODM_MAC_EDCA_TURBO OFF: NO HT STA FOUND\n"));
- return;
- }
- #endif
- pstat=priv->pshare->highTP_found_pstat;
- #ifdef WIFI_WMM
- if (QOS_ENABLE) {
- if (!priv->pmib->dot11OperationEntry.wifi_specific
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- ||((OPMODE & WIFI_AP_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- #elif(DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- || (priv->pmib->dot11OperationEntry.wifi_specific == 2)
- #endif
- ) {
- if (priv->pshare->iot_mode_enable &&
- ((priv->pshare->phw->VO_pkt_count > 50) ||
- (priv->pshare->phw->VI_pkt_count > 50) ||
- (priv->pshare->phw->BK_pkt_count > 50))) {
- priv->pshare->iot_mode_enable = 0;
- switch_turbo++;
- } else if ((!priv->pshare->iot_mode_enable) &&
- ((priv->pshare->phw->VO_pkt_count < 50) &&
- (priv->pshare->phw->VI_pkt_count < 50) &&
- (priv->pshare->phw->BK_pkt_count < 50))) {
- priv->pshare->iot_mode_enable++;
- switch_turbo++;
- }
- }
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if ((OPMODE & WIFI_AP_STATE) && priv->pmib->dot11OperationEntry.wifi_specific)
- #elif (DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- if (priv->pmib->dot11OperationEntry.wifi_specific)
- #endif
- {
- if (!priv->pshare->iot_mode_VO_exist && (priv->pshare->phw->VO_pkt_count > 50)) {
- priv->pshare->iot_mode_VO_exist++;
- switch_turbo++;
- } else if (priv->pshare->iot_mode_VO_exist && (priv->pshare->phw->VO_pkt_count < 50)) {
- priv->pshare->iot_mode_VO_exist = 0;
- switch_turbo++;
- }
- #if((DM_ODM_SUPPORT_TYPE==ODM_ADSL)||((DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined WMM_VIBE_PRI)))
- if (priv->pshare->iot_mode_VO_exist) {
- //printk("[%s %d] BE_pkt_count=%d\n", __FUNCTION__, __LINE__, priv->pshare->phw->BE_pkt_count);
- if (!priv->pshare->iot_mode_BE_exist && (priv->pshare->phw->BE_pkt_count > 250)) {
- priv->pshare->iot_mode_BE_exist++;
- switch_turbo++;
- } else if (priv->pshare->iot_mode_BE_exist && (priv->pshare->phw->BE_pkt_count < 250)) {
- priv->pshare->iot_mode_BE_exist = 0;
- switch_turbo++;
- }
- }
- #endif
- #if (DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (priv->pshare->rf_ft_var.wifi_beq_iot)
- {
- if (!priv->pshare->iot_mode_VI_exist && (priv->pshare->phw->VI_rx_pkt_count > 50)) {
- priv->pshare->iot_mode_VI_exist++;
- switch_turbo++;
- } else if (priv->pshare->iot_mode_VI_exist && (priv->pshare->phw->VI_rx_pkt_count < 50)) {
- priv->pshare->iot_mode_VI_exist = 0;
- switch_turbo++;
- }
- }
- #endif
- }
- else if (!pstat || pstat->rssi < priv->pshare->rf_ft_var.txop_enlarge_lower) {
- if (priv->pshare->txop_enlarge) {
- priv->pshare->txop_enlarge = 0;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- }
- #if(defined(CLIENT_MODE) && (DM_ODM_SUPPORT_TYPE==ODM_AP))
- if ((OPMODE & WIFI_STATION_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- {
- if (priv->pshare->iot_mode_enable &&
- (((priv->pshare->phw->VO_pkt_count > 50) ||
- (priv->pshare->phw->VI_pkt_count > 50) ||
- (priv->pshare->phw->BK_pkt_count > 50)) ||
- (pstat && (!pstat->ADDBA_ready[0]) & (!pstat->ADDBA_ready[3]))))
- {
- priv->pshare->iot_mode_enable = 0;
- switch_turbo++;
- }
- else if ((!priv->pshare->iot_mode_enable) &&
- (((priv->pshare->phw->VO_pkt_count < 50) &&
- (priv->pshare->phw->VI_pkt_count < 50) &&
- (priv->pshare->phw->BK_pkt_count < 50)) &&
- (pstat && (pstat->ADDBA_ready[0] | pstat->ADDBA_ready[3]))))
- {
- priv->pshare->iot_mode_enable++;
- switch_turbo++;
- }
- }
- #endif
- priv->pshare->phw->VO_pkt_count = 0;
- priv->pshare->phw->VI_pkt_count = 0;
- priv->pshare->phw->BK_pkt_count = 0;
- #if((DM_ODM_SUPPORT_TYPE==ODM_ADSL)||((DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined WMM_VIBE_PRI)))
- priv->pshare->phw->BE_pkt_count = 0;
- #endif
-
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (priv->pshare->rf_ft_var.wifi_beq_iot)
- priv->pshare->phw->VI_rx_pkt_count = 0;
- #endif
- }
- #endif
- if ((priv->up_time % 2) == 0) {
- /*
- * decide EDCA content for different chip vendor
- */
- #ifdef WIFI_WMM
- #if(DM_ODM_SUPPORT_TYPE==ODM_ADSL)
- if (QOS_ENABLE && (!priv->pmib->dot11OperationEntry.wifi_specific || (priv->pmib->dot11OperationEntry.wifi_specific == 2)
-
- #elif(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (QOS_ENABLE && (!priv->pmib->dot11OperationEntry.wifi_specific ||
- ((OPMODE & WIFI_AP_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- #ifdef CLIENT_MODE
- || ((OPMODE & WIFI_STATION_STATE) && (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- #endif
- #endif
- ))
-
- {
- if (pstat && pstat->rssi >= priv->pshare->rf_ft_var.txop_enlarge_upper) {
- #ifdef LOW_TP_TXOP
- #if (DM_ODM_SUPPORT_TYPE &ODM_AP) && defined(USE_OUT_SRC)
- if (pstat->IOTPeer==HT_IOT_PEER_INTEL)
- #else
- if (pstat->is_intel_sta)
- #endif
- {
- if (priv->pshare->txop_enlarge != 0xe)
- {
- priv->pshare->txop_enlarge = 0xe;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- }
- else if (priv->pshare->txop_enlarge != 2)
- {
- priv->pshare->txop_enlarge = 2;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- #else
- if (priv->pshare->txop_enlarge != 2)
- {
- #if (DM_ODM_SUPPORT_TYPE &ODM_AP) && defined(USE_OUT_SRC)
- if (pstat->IOTPeer==HT_IOT_PEER_INTEL)
- #else
- if (pstat->is_intel_sta)
- #endif
- priv->pshare->txop_enlarge = 0xe;
- #if (DM_ODM_SUPPORT_TYPE &ODM_AP) && defined(USE_OUT_SRC)
- else if (pstat->IOTPeer==HT_IOT_PEER_RALINK)
- #else
- else if (pstat->is_ralink_sta)
- #endif
- priv->pshare->txop_enlarge = 0xd;
- else
- priv->pshare->txop_enlarge = 2;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- #endif
- #if 0
- if (priv->pshare->txop_enlarge != 2)
- {
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- if (pstat->IOTPeer==HT_IOT_PEER_INTEL)
- #else
- if (pstat->is_intel_sta)
- #endif
- priv->pshare->txop_enlarge = 0xe;
- #if(DM_ODM_SUPPORT_TYPE==ODM_AP)
- else if (pstat->IOTPeer==HT_IOT_PEER_RALINK)
- priv->pshare->txop_enlarge = 0xd;
- #endif
- else
- priv->pshare->txop_enlarge = 2;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- #endif
- }
- else if (!pstat || pstat->rssi < priv->pshare->rf_ft_var.txop_enlarge_lower)
- {
- if (priv->pshare->txop_enlarge) {
- priv->pshare->txop_enlarge = 0;
- if (priv->pshare->iot_mode_enable)
- switch_turbo++;
- }
- }
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)&&( defined LOW_TP_TXOP))
- // for Intel IOT, need to enlarge CW MAX from 6 to 10
- if (pstat && pstat->is_intel_sta && (((pstat->tx_avarage+pstat->rx_avarage)>>10) <
- priv->pshare->rf_ft_var.cwmax_enhance_thd))
- {
- if (!priv->pshare->BE_cwmax_enhance && priv->pshare->iot_mode_enable)
- {
- priv->pshare->BE_cwmax_enhance = 1;
- switch_turbo++;
- }
- } else {
- if (priv->pshare->BE_cwmax_enhance) {
- priv->pshare->BE_cwmax_enhance = 0;
- switch_turbo++;
- }
- }
- #endif
- }
- #endif
- priv->pshare->current_tx_bytes = 0;
- priv->pshare->current_rx_bytes = 0;
- }
-
- #if((DM_ODM_SUPPORT_TYPE==ODM_AP)&& defined( SW_TX_QUEUE))
- if ((priv->assoc_num > 1) && (AMPDU_ENABLE))
- {
- if (priv->swq_txmac_chg >= priv->pshare->rf_ft_var.swq_en_highthd){
- if ((priv->swq_en == 0)){
- switch_turbo++;
- if (priv->pshare->txop_enlarge == 0)
- priv->pshare->txop_enlarge = 2;
- priv->swq_en = 1;
- }
- else
- {
- if ((switch_turbo > 0) && (priv->pshare->txop_enlarge == 0) && (priv->pshare->iot_mode_enable != 0))
- {
- priv->pshare->txop_enlarge = 2;
- switch_turbo--;
- }
- }
- }
- else if(priv->swq_txmac_chg <= priv->pshare->rf_ft_var.swq_dis_lowthd){
- priv->swq_en = 0;
- }
- else if ((priv->swq_en == 1) && (switch_turbo > 0) && (priv->pshare->txop_enlarge == 0) && (priv->pshare->iot_mode_enable != 0)) {
- priv->pshare->txop_enlarge = 2;
- switch_turbo--;
- }
- }
- #if ((DM_ODM_SUPPORT_TYPE==ODM_AP)&&(defined CONFIG_RTL_819XD))
- else if( (priv->assoc_num == 1) && (AMPDU_ENABLE)) {
- if (pstat) {
- int en_thd = 14417920>>(priv->up_time % 2);
- if ((priv->swq_en == 0) && (pstat->current_tx_bytes > en_thd) && (pstat->current_rx_bytes > en_thd) ) { //50Mbps
- priv->swq_en = 1;
- priv->swqen_keeptime = priv->up_time;
- }
- else if ((priv->swq_en == 1) && ((pstat->tx_avarage < 4587520) || (pstat->rx_avarage < 4587520))) { //35Mbps
- priv->swq_en = 0;
- priv->swqen_keeptime = 0;
- }
- }
- else {
- priv->swq_en = 0;
- priv->swqen_keeptime = 0;
- }
- }
- #endif
- #endif
- #ifdef WIFI_WMM
- #ifdef LOW_TP_TXOP
- if ((!priv->pmib->dot11OperationEntry.wifi_specific || (priv->pmib->dot11OperationEntry.wifi_specific == 2))
- && QOS_ENABLE) {
- if (switch_turbo || priv->pshare->rf_ft_var.low_tp_txop) {
- unsigned int thd_tp;
- unsigned char under_thd;
- unsigned int curr_tp;
- if (priv->pmib->dot11BssType.net_work_type & (ODM_WM_N24G|ODM_WM_N5G| ODM_WM_G))
- {
- // Determine the upper bound throughput threshold.
- if (priv->pmib->dot11BssType.net_work_type & (ODM_WM_N24G|ODM_WM_N5G)) {
- if (priv->assoc_num && priv->assoc_num != priv->pshare->ht_sta_num)
- thd_tp = priv->pshare->rf_ft_var.low_tp_txop_thd_g;
- else
- thd_tp = priv->pshare->rf_ft_var.low_tp_txop_thd_n;
- }
- else
- thd_tp = priv->pshare->rf_ft_var.low_tp_txop_thd_g;
- // Determine to close txop.
- curr_tp = (unsigned int)(priv->ext_stats.tx_avarage>>17) + (unsigned int)(priv->ext_stats.rx_avarage>>17);
- if (curr_tp <= thd_tp && curr_tp >= priv->pshare->rf_ft_var.low_tp_txop_thd_low)
- under_thd = 1;
- else
- under_thd = 0;
- }
- else
- {
- under_thd = 0;
- }
- if (switch_turbo)
- {
- priv->pshare->rf_ft_var.low_tp_txop_close = under_thd;
- priv->pshare->rf_ft_var.low_tp_txop_count = 0;
- }
- else if (priv->pshare->iot_mode_enable && (priv->pshare->rf_ft_var.low_tp_txop_close != under_thd)) {
- priv->pshare->rf_ft_var.low_tp_txop_count++;
- if (priv->pshare->rf_ft_var.low_tp_txop_close) {
- priv->pshare->rf_ft_var.low_tp_txop_count = priv->pshare->rf_ft_var.low_tp_txop_delay;
- }
- if (priv->pshare->rf_ft_var.low_tp_txop_count ==priv->pshare->rf_ft_var.low_tp_txop_delay)
- {
- priv->pshare->rf_ft_var.low_tp_txop_count = 0;
- priv->pshare->rf_ft_var.low_tp_txop_close = under_thd;
- switch_turbo++;
- }
- }
- else
- {
- priv->pshare->rf_ft_var.low_tp_txop_count = 0;
- }
- }
- }
- #endif
- if (switch_turbo)
- ODM_IotEdcaSwitch( pDM_Odm, priv->pshare->iot_mode_enable );
- #endif
- }
- #endif
- #if( DM_ODM_SUPPORT_TYPE == ODM_WIN)
- //
- // 2011/07/26 MH Add an API for testing IQK fail case.
- //
- BOOLEAN
- ODM_CheckPowerStatus(
- IN PADAPTER Adapter)
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- RT_RF_POWER_STATE rtState;
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- // 2011/07/27 MH We are not testing ready~~!! We may fail to get correct value when init sequence.
- if (pMgntInfo->init_adpt_in_progress == TRUE)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("ODM_CheckPowerStatus Return TRUE, due to initadapter"));
- return TRUE;
- }
-
- //
- // 2011/07/19 MH We can not execute tx pwoer tracking/ LLC calibrate or IQK.
- //
- Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState));
- if(Adapter->bDriverStopped || Adapter->bDriverIsGoingToPnpSetPowerSleep || rtState == eRfOff)
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("ODM_CheckPowerStatus Return FALSE, due to %d/%d/%d\n",
- Adapter->bDriverStopped, Adapter->bDriverIsGoingToPnpSetPowerSleep, rtState));
- return FALSE;
- }
- return TRUE;
- }
- #endif
- // need to ODM CE Platform
- //move to here for ANT detection mechanism using
- #if ((DM_ODM_SUPPORT_TYPE == ODM_WIN)||(DM_ODM_SUPPORT_TYPE == ODM_CE))
- u4Byte
- GetPSDData(
- IN PDM_ODM_T pDM_Odm,
- unsigned int point,
- u1Byte initial_gain_psd)
- {
- //unsigned int val, rfval;
- //int psd_report;
- u4Byte psd_report;
-
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- //Debug Message
- //val = PHY_QueryBBReg(Adapter,0x908, bMaskDWord);
- //DbgPrint("Reg908 = 0x%x\n",val);
- //val = PHY_QueryBBReg(Adapter,0xDF4, bMaskDWord);
- //rfval = PHY_QueryRFReg(Adapter, ODM_RF_PATH_A, 0x00, bRFRegOffsetMask);
- //DbgPrint("RegDF4 = 0x%x, RFReg00 = 0x%x\n",val, rfval);
- //DbgPrint("PHYTXON = %x, OFDMCCA_PP = %x, CCKCCA_PP = %x, RFReg00 = %x\n",
- //(val&BIT25)>>25, (val&BIT14)>>14, (val&BIT15)>>15, rfval);
- //Set DCO frequency index, offset=(40MHz/SamplePts)*point
- ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point);
- //Start PSD calculation, Reg808[22]=0->1
- ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1);
- //Need to wait for HW PSD report
- ODM_StallExecution(1000);
- ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0);
- //Read PSD report, Reg8B4[15:0]
- psd_report = ODM_GetBBReg(pDM_Odm,0x8B4, bMaskDWord) & 0x0000FFFF;
-
- #if 1//(DEV_BUS_TYPE == RT_PCI_INTERFACE) && ( (RT_PLATFORM == PLATFORM_LINUX) || (RT_PLATFORM == PLATFORM_MACOSX))
- psd_report = (u4Byte) (ConvertTo_dB(psd_report))+(u4Byte)(initial_gain_psd-0x1c);
- #else
- psd_report = (int) (20*log10((double)psd_report))+(int)(initial_gain_psd-0x1c);
- #endif
- return psd_report;
-
- }
- u4Byte
- ConvertTo_dB(
- u4Byte Value)
- {
- u1Byte i;
- u1Byte j;
- u4Byte dB;
- Value = Value & 0xFFFF;
-
- for (i=0;i<8;i++)
- {
- if (Value <= dB_Invert_Table[i][11])
- {
- break;
- }
- }
- if (i >= 8)
- {
- return (96); // maximum 96 dB
- }
- for (j=0;j<12;j++)
- {
- if (Value <= dB_Invert_Table[i][j])
- {
- break;
- }
- }
- dB = i*12 + j + 1;
- return (dB);
- }
- #endif
- //
- // LukeLee:
- // PSD function will be moved to FW in future IC, but now is only implemented in MP platform
- // So PSD function will not be incorporated to common ODM
- //
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- #define AFH_PSD 1 //0:normal PSD scan, 1: only do 20 pts PSD
- #define MODE_40M 0 //0:20M, 1:40M
- #define PSD_TH2 3
- #define PSD_CHMIN 20 // Minimum channel number for BT AFH
- #define SIR_STEP_SIZE 3
- #define Smooth_Size_1 5
- #define Smooth_TH_1 3
- #define Smooth_Size_2 10
- #define Smooth_TH_2 4
- #define Smooth_Size_3 20
- #define Smooth_TH_3 4
- #define Smooth_Step_Size 5
- #define Adaptive_SIR 1
- //#if(RTL8723_FPGA_VERIFICATION == 1)
- //#define PSD_RESCAN 1
- //#else
- //#define PSD_RESCAN 4
- //#endif
- #define SCAN_INTERVAL 1500 //ms
- #define SYN_Length 5 // for 92D
-
- #define LNA_Low_Gain_1 0x64
- #define LNA_Low_Gain_2 0x5A
- #define LNA_Low_Gain_3 0x58
- #define pw_th_10dB 0x0
- #define pw_th_16dB 0x3
- #define FA_RXHP_TH1 5000
- #define FA_RXHP_TH2 1500
- #define FA_RXHP_TH3 800
- #define FA_RXHP_TH4 600
- #define FA_RXHP_TH5 500
- #define Idle_Mode 0
- #define High_TP_Mode 1
- #define Low_TP_Mode 2
- VOID
- odm_PSDMonitorInit(
- IN PDM_ODM_T pDM_Odm)
- {
- #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)|(DEV_BUS_TYPE == RT_USB_INTERFACE)
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- //PSD Monitor Setting
- //Which path in ADC/DAC is turnned on for PSD: both I/Q
- ODM_SetBBReg(pDM_Odm, ODM_PSDREG, BIT10|BIT11, 0x3);
- //Ageraged number: 8
- ODM_SetBBReg(pDM_Odm, ODM_PSDREG, BIT12|BIT13, 0x1);
- pDM_Odm->bPSDinProcess = FALSE;
- pDM_Odm->bUserAssignLevel = FALSE;
- pDM_Odm->bPSDactive = FALSE;
- //pDM_Odm->bDMInitialGainEnable=TRUE; //change the initialization to DIGinit
- //Set Debug Port
- //PHY_SetBBReg(Adapter, 0x908, bMaskDWord, 0x803);
- //PHY_SetBBReg(Adapter, 0xB34, bMaskByte0, 0x00); // pause PSD
- //PHY_SetBBReg(Adapter, 0xB38, bMaskByte0, 10); //rescan
- //PHY_SetBBReg(Adapter, 0xB38, bMaskByte2|bMaskByte3, 100); //interval
- //PlatformSetTimer( Adapter, &pHalData->PSDTriggerTimer, 0); //ms
- #endif
- }
- VOID
- PatchDCTone(
- IN PDM_ODM_T pDM_Odm,
- pu4Byte PSD_report,
- u1Byte initial_gain_psd
- )
- {
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- //PADAPTER pAdapter;
-
- u4Byte psd_report;
- //2 Switch to CH11 to patch CH9 and CH13 DC tone
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, 11);
-
- if(pDM_Odm->SupportICType== ODM_RTL8192D)
- {
- if((*(pDM_Odm->pMacPhyMode) == ODM_SMSP)||(*(pDM_Odm->pMacPhyMode) == ODM_DMSP))
- {
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, 11);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x25, 0xfffff, 0x643BC);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x26, 0xfffff, 0xFC038);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x27, 0xfffff, 0x77C1A);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2B, 0xfffff, 0x41289);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2C, 0xfffff, 0x01840);
- }
- else
- {
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x25, 0xfffff, 0x643BC);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x26, 0xfffff, 0xFC038);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x27, 0xfffff, 0x77C1A);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2B, 0xfffff, 0x41289);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2C, 0xfffff, 0x01840);
- }
- }
-
- //Ch9 DC tone patch
- psd_report = GetPSDData(pDM_Odm, 96, initial_gain_psd);
- PSD_report[50] = psd_report;
- //Ch13 DC tone patch
- psd_report = GetPSDData(pDM_Odm, 32, initial_gain_psd);
- PSD_report[70] = psd_report;
-
- //2 Switch to CH3 to patch CH1 and CH5 DC tone
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, 3);
-
- if(pDM_Odm->SupportICType==ODM_RTL8192D)
- {
- if((*(pDM_Odm->pMacPhyMode) == ODM_SMSP)||(*(pDM_Odm->pMacPhyMode) == ODM_DMSP))
- {
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, 3);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_B, 0x25, 0xfffff, 0x643BC);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_B, 0x26, 0xfffff, 0xFC038);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x27, 0xfffff, 0x07C1A);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_B, 0x2B, 0xfffff, 0x61289);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_B, 0x2C, 0xfffff, 0x01C41);
- }
- else
- {
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_A, 0x25, 0xfffff, 0x643BC);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_A, 0x26, 0xfffff, 0xFC038);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x27, 0xfffff, 0x07C1A);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_A, 0x2B, 0xfffff, 0x61289);
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_A, 0x2C, 0xfffff, 0x01C41);
- }
- }
-
- //Ch1 DC tone patch
- psd_report = GetPSDData(pDM_Odm, 96, initial_gain_psd);
- PSD_report[10] = psd_report;
- //Ch5 DC tone patch
- psd_report = GetPSDData(pDM_Odm, 32, initial_gain_psd);
- PSD_report[30] = psd_report;
- }
- VOID
- GoodChannelDecision(
- PDM_ODM_T pDM_Odm,
- pu4Byte PSD_report,
- pu1Byte PSD_bitmap,
- u1Byte RSSI_BT,
- pu1Byte PSD_bitmap_memory)
- {
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- //s4Byte TH1 = SSBT-0x15; // modify TH by Neil Chen
- s4Byte TH1= RSSI_BT+0x14;
- s4Byte TH2 = RSSI_BT+85;
- //u2Byte TH3;
- // s4Byte RegB34;
- u1Byte bitmap, Smooth_size[3], Smooth_TH[3];
- //u1Byte psd_bit;
- u4Byte i,n,j, byte_idx, bit_idx, good_cnt, good_cnt_smoothing, Smooth_Interval[3];
- int start_byte_idx,start_bit_idx,cur_byte_idx, cur_bit_idx,NOW_byte_idx ;
-
- // RegB34 = PHY_QueryBBReg(Adapter,0xB34, bMaskDWord)&0xFF;
- if((pDM_Odm->SupportICType == ODM_RTL8192C)||(pDM_Odm->SupportICType == ODM_RTL8192D))
- {
- TH1 = RSSI_BT + 0x14;
- }
- Smooth_size[0]=Smooth_Size_1;
- Smooth_size[1]=Smooth_Size_2;
- Smooth_size[2]=Smooth_Size_3;
- Smooth_TH[0]=Smooth_TH_1;
- Smooth_TH[1]=Smooth_TH_2;
- Smooth_TH[2]=Smooth_TH_3;
- Smooth_Interval[0]=16;
- Smooth_Interval[1]=15;
- Smooth_Interval[2]=13;
- good_cnt = 0;
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- //2 Threshold
- if(RSSI_BT >=41)
- TH1 = 113;
- else if(RSSI_BT >=38) // >= -15dBm
- TH1 = 105; //0x69
- else if((RSSI_BT >=33)&(RSSI_BT <38))
- TH1 = 99+(RSSI_BT-33); //0x63
- else if((RSSI_BT >=26)&(RSSI_BT<33))
- TH1 = 99-(33-RSSI_BT)+2; //0x5e
- else if((RSSI_BT >=24)&(RSSI_BT<26))
- TH1 = 88-((RSSI_BT-24)*3); //0x58
- else if((RSSI_BT >=18)&(RSSI_BT<24))
- TH1 = 77+((RSSI_BT-18)*2);
- else if((RSSI_BT >=14)&(RSSI_BT<18))
- TH1 = 63+((RSSI_BT-14)*2);
- else if((RSSI_BT >=8)&(RSSI_BT<14))
- TH1 = 58+((RSSI_BT-8)*2);
- else if((RSSI_BT >=3)&(RSSI_BT<8))
- TH1 = 52+(RSSI_BT-3);
- else
- TH1 = 51;
- }
- for (i = 0; i< 10; i++)
- PSD_bitmap[i] = 0;
-
- // Add By Gary
- for (i=0; i<80; i++)
- pRX_HP_Table->PSD_bitmap_RXHP[i] = 0;
- // End
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- TH1 =TH1-SIR_STEP_SIZE;
- }
- while (good_cnt < PSD_CHMIN)
- {
- good_cnt = 0;
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- if(TH1 ==TH2)
- break;
- if((TH1+SIR_STEP_SIZE) < TH2)
- TH1 += SIR_STEP_SIZE;
- else
- TH1 = TH2;
- }
- else
- {
- if(TH1==(RSSI_BT+0x1E))
- break;
- if((TH1+2) < (RSSI_BT+0x1E))
- TH1+=3;
- else
- TH1 = RSSI_BT+0x1E;
-
- }
- ODM_RT_TRACE(pDM_Odm,COMP_PSD,DBG_LOUD,("PSD: decision threshold is: %d", TH1));
-
- for (i = 0; i< 80; i++)
- {
- if((s4Byte)(PSD_report[i]) < TH1)
- {
- byte_idx = i / 8;
- bit_idx = i -8*byte_idx;
- bitmap = PSD_bitmap[byte_idx];
- PSD_bitmap[byte_idx] = bitmap | (u1Byte) (1 << bit_idx);
- }
- }
- #if DBG
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD: before smoothing\n"));
- for(n=0;n<10;n++)
- {
- //DbgPrint("PSD_bitmap[%u]=%x\n", n, PSD_bitmap[n]);
- for (i = 0; i<8; i++)
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD_bitmap[%u] = %d\n", 2402+n*8+i, (PSD_bitmap[n]&BIT(i))>>i));
- }
- #endif
-
- //1 Start of smoothing function
- for (j=0;j<3;j++)
- {
- start_byte_idx=0;
- start_bit_idx=0;
- for(n=0; n<Smooth_Interval[j]; n++)
- {
- good_cnt_smoothing = 0;
- cur_bit_idx = start_bit_idx;
- cur_byte_idx = start_byte_idx;
- for ( i=0; i < Smooth_size[j]; i++)
- {
- NOW_byte_idx = cur_byte_idx + (i+cur_bit_idx)/8;
- if ( (PSD_bitmap[NOW_byte_idx]& BIT( (cur_bit_idx + i)%8)) != 0)
- good_cnt_smoothing++;
- }
- if( good_cnt_smoothing < Smooth_TH[j] )
- {
- cur_bit_idx = start_bit_idx;
- cur_byte_idx = start_byte_idx;
- for ( i=0; i< Smooth_size[j] ; i++)
- {
- NOW_byte_idx = cur_byte_idx + (i+cur_bit_idx)/8;
- PSD_bitmap[NOW_byte_idx] = PSD_bitmap[NOW_byte_idx] & (~BIT( (cur_bit_idx + i)%8));
- }
- }
- start_bit_idx = start_bit_idx + Smooth_Step_Size;
- while ( (start_bit_idx) > 7 )
- {
- start_byte_idx= start_byte_idx+start_bit_idx/8;
- start_bit_idx = start_bit_idx%8;
- }
- }
- ODM_RT_TRACE( pDM_Odm,COMP_PSD, DBG_LOUD,("PSD: after %u smoothing", j+1));
- for(n=0;n<10;n++)
- {
- for (i = 0; i<8; i++)
- {
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD_bitmap[%u] = %d\n", 2402+n*8+i, (PSD_bitmap[n]&BIT(i))>>i));
-
- if ( ((PSD_bitmap[n]&BIT(i))>>i) ==1) //----- Add By Gary
- {
- pRX_HP_Table->PSD_bitmap_RXHP[8*n+i] = 1;
- } // ------end by Gary
- }
- }
- }
-
- good_cnt = 0;
- for ( i = 0; i < 10; i++)
- {
- for (n = 0; n < 8; n++)
- if((PSD_bitmap[i]& BIT(n)) != 0)
- good_cnt++;
- }
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD: good channel cnt = %u",good_cnt));
- }
- //RT_TRACE(COMP_PSD, DBG_LOUD,("PSD: SSBT=%d, TH2=%d, TH1=%d",SSBT,TH2,TH1));
- for (i = 0; i <10; i++)
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD: PSD_bitmap[%u]=%x",i,PSD_bitmap[i]));
- /*
- //Update bitmap memory
- for(i = 0; i < 80; i++)
- {
- byte_idx = i / 8;
- bit_idx = i -8*byte_idx;
- psd_bit = (PSD_bitmap[byte_idx] & BIT(bit_idx)) >> bit_idx;
- bitmap = PSD_bitmap_memory[i];
- PSD_bitmap_memory[i] = (bitmap << 1) |psd_bit;
- }
- */
- }
- VOID
- odm_PSD_Monitor(
- PDM_ODM_T pDM_Odm
- )
- {
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- //PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- unsigned int pts, start_point, stop_point;
- u1Byte initial_gain ;
- static u1Byte PSD_bitmap_memory[80], init_memory = 0;
- static u1Byte psd_cnt=0;
- static u4Byte PSD_report[80], PSD_report_tmp;
- static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
- u1Byte H2C_PSD_DATA[5]={0,0,0,0,0};
- static u1Byte H2C_PSD_DATA_last[5] ={0,0,0,0,0};
- u1Byte idx[20]={96,99,102,106,109,112,115,118,122,125,
- 0,3,6,10,13,16,19,22,26,29};
- u1Byte n, i, channel, BBReset,tone_idx;
- u1Byte PSD_bitmap[10], SSBT=0,initial_gain_psd=0, RSSI_BT=0, initialGainUpper;
- s4Byte PSD_skip_start, PSD_skip_stop;
- u4Byte CurrentChannel, RXIQI, RxIdleLowPwr, wlan_channel;
- u4Byte ReScan, Interval, Is40MHz;
- u8Byte curTxOkCnt, curRxOkCnt;
- int cur_byte_idx, cur_bit_idx;
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
-
- if( (*(pDM_Odm->pbScanInProcess)) ||
- pDM_Odm->bLinkInProcess)
- {
- if((pDM_Odm->SupportICType==ODM_RTL8723A)&(pDM_Odm->SupportInterface==ODM_ITRF_PCIE))
- {
- //pHalData->bPSDactive=FALSE;
- //ODM_SetTimer(pDM_Odm,&pDM_SWAT_Table->SwAntennaSwitchTimer, 100 )
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PSDTimer, 1500); //ms
- //psd_cnt=0;
- }
- return;
- }
- if(pDM_Odm->bBtHsOperation)
- {
- ReScan = 1;
- Interval = SCAN_INTERVAL;
- }
- else
- {
- ReScan = PSD_RESCAN;
- Interval = SCAN_INTERVAL;
- }
- //1 Initialization
- if(init_memory == 0)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("Init memory\n"));
- for(i = 0; i < 80; i++)
- PSD_bitmap_memory[i] = 0xFF; // channel is always good
- init_memory = 1;
- }
- if(psd_cnt == 0)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("Enter dm_PSD_Monitor\n"));
- for(i = 0; i < 80; i++)
- PSD_report[i] = 0;
- }
- #if 0 //for test only
- DbgPrint("cosa odm_PSD_Monitor call()\n");
- DbgPrint("cosa pHalData->RSSI_BT = %d\n", pHalData->RSSI_BT);
- DbgPrint("cosa pHalData->bUserAssignLevel = %d\n", pHalData->bUserAssignLevel);
- #if 0
- psd_cnt++;
- if (psd_cnt < ReScan)
- PlatformSetTimer( Adapter, &pHalData->PSDTimer, Interval); //ms
- else
- psd_cnt = 0;
- return;
- #endif
- #endif
- //1 Backup Current Settings
- CurrentChannel = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask);
- /*
- if(pDM_Odm->SupportICType==ODM_RTL8192D)
- {
- //2 Record Current synthesizer parameters based on current channel
- if((*pDM_Odm->MacPhyMode92D == SINGLEMAC_SINGLEPHY)||(*pDM_Odm->MacPhyMode92D == DUALMAC_SINGLEPHY))
- {
- SYN_RF25 = ODM_GetRFReg(Adapter, ODM_RF_PATH_B, 0x25, bMaskDWord);
- SYN_RF26 = ODM_GetRFReg(Adapter, ODM_RF_PATH_B, 0x26, bMaskDWord);
- SYN_RF27 = ODM_GetRFReg(Adapter, ODM_RF_PATH_B, 0x27, bMaskDWord);
- SYN_RF2B = ODM_GetRFReg(Adapter, ODM_RF_PATH_B, 0x2B, bMaskDWord);
- SYN_RF2C = ODM_GetRFReg(Adapter, ODM_RF_PATH_B, 0x2C, bMaskDWord);
- }
- else // DualMAC_DualPHY 2G
- {
- SYN_RF25 = ODM_GetRFReg(Adapter, ODM_RF_PATH_A, 0x25, bMaskDWord);
- SYN_RF26 = ODM_GetRFReg(Adapter, ODM_RF_PATH_A, 0x26, bMaskDWord);
- SYN_RF27 = ODM_GetRFReg(Adapter, ODM_RF_PATH_A, 0x27, bMaskDWord);
- SYN_RF2B = ODM_GetRFReg(Adapter, ODM_RF_PATH_A, 0x2B, bMaskDWord);
- SYN_RF2C = ODM_GetRFReg(Adapter, ODM_RF_PATH_A, 0x2C, bMaskDWord);
- }
- }
- */
- //RXIQI = PHY_QueryBBReg(Adapter, 0xC14, bMaskDWord);
- RXIQI = ODM_GetBBReg(pDM_Odm, 0xC14, bMaskDWord);
- //RxIdleLowPwr = (PHY_QueryBBReg(Adapter, 0x818, bMaskDWord)&BIT28)>>28;
- RxIdleLowPwr = (ODM_GetBBReg(pDM_Odm, 0x818, bMaskDWord)&BIT28)>>28;
- //2???
- if(CHNL_RUN_ABOVE_40MHZ(pMgntInfo))
- Is40MHz = TRUE;
- else
- Is40MHz = FALSE;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_PSD, DBG_LOUD,("PSD Scan Start\n"));
- //1 Turn off CCK
- //PHY_SetBBReg(Adapter, rFPGA0_RFMOD, BIT24, 0);
- ODM_SetBBReg(pDM_Odm, rFPGA0_RFMOD, BIT24, 0);
- //1 Turn off TX
- //Pause TX Queue
- //PlatformEFIOWrite1Byte(Adapter, REG_TXPAUSE, 0xFF);
- ODM_Write1Byte(pDM_Odm,REG_TXPAUSE, 0xFF);
-
- //Force RX to stop TX immediately
- //PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_AC, bRFRegOffsetMask, 0x32E13);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_AC, bRFRegOffsetMask, 0x32E13);
- //1 Turn off RX
- //Rx AGC off RegC70[0]=0, RegC7C[20]=0
- //PHY_SetBBReg(Adapter, 0xC70, BIT0, 0);
- //PHY_SetBBReg(Adapter, 0xC7C, BIT20, 0);
- ODM_SetBBReg(pDM_Odm, 0xC70, BIT0, 0);
- ODM_SetBBReg(pDM_Odm, 0xC7C, BIT20, 0);
-
- //Turn off CCA
- //PHY_SetBBReg(Adapter, 0xC14, bMaskDWord, 0x0);
- ODM_SetBBReg(pDM_Odm, 0xC14, bMaskDWord, 0x0);
-
- //BB Reset
- //BBReset = PlatformEFIORead1Byte(Adapter, 0x02);
- BBReset = ODM_Read1Byte(pDM_Odm, 0x02);
-
- //PlatformEFIOWrite1Byte(Adapter, 0x02, BBReset&(~BIT0));
- //PlatformEFIOWrite1Byte(Adapter, 0x02, BBReset|BIT0);
- ODM_SetBBReg(pDM_Odm, 0x87C, BIT31, 1); //clock gated to prevent from AGC table mess
- ODM_Write1Byte(pDM_Odm, 0x02, BBReset&(~BIT0));
- ODM_Write1Byte(pDM_Odm, 0x02, BBReset|BIT0);
- ODM_SetBBReg(pDM_Odm, 0x87C, BIT31, 0);
-
- //1 Leave RX idle low power
- //PHY_SetBBReg(Adapter, 0x818, BIT28, 0x0);
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0);
- //1 Fix initial gain
- //if (IS_HARDWARE_TYPE_8723AE(Adapter))
- //RSSI_BT = pHalData->RSSI_BT;
- //else if((IS_HARDWARE_TYPE_8192C(Adapter))||(IS_HARDWARE_TYPE_8192D(Adapter))) // Add by Gary
- // RSSI_BT = RSSI_BT_new;
- if((pDM_Odm->SupportICType==ODM_RTL8723A)&(pDM_Odm->SupportInterface==ODM_ITRF_PCIE))
- RSSI_BT=pDM_Odm->RSSI_BT; //need to check C2H to pDM_Odm RSSI BT
- if(RSSI_BT>=47)
- RSSI_BT=47;
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("PSD: RSSI_BT= %d\n", RSSI_BT));
-
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- //Neil add--2011--10--12
- //2 Initial Gain index
- if(RSSI_BT >=35) // >= -15dBm
- initial_gain_psd = RSSI_BT*2;
- else if((RSSI_BT >=33)&(RSSI_BT<35))
- initial_gain_psd = RSSI_BT*2+6;
- else if((RSSI_BT >=24)&(RSSI_BT<33))
- initial_gain_psd = 70-(33-RSSI_BT);
- else if((RSSI_BT >=19)&(RSSI_BT<24))
- initial_gain_psd = 64-((24-RSSI_BT)*4);
- else if((RSSI_BT >=14)&(RSSI_BT<19))
- initial_gain_psd = 44-((18-RSSI_BT)*2);
- else if((RSSI_BT >=8)&(RSSI_BT<14))
- initial_gain_psd = 35-(14-RSSI_BT);
- else
- initial_gain_psd = 0x1B;
- }
- else
- {
-
- //need to do
- initial_gain_psd = pDM_Odm->RSSI_Min; // PSD report based on RSSI
- //}
- }
- //if(RSSI_BT<0x17)
- // RSSI_BT +=3;
- //DbgPrint("PSD: RSSI_BT= %d\n", RSSI_BT);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("PSD: RSSI_BT= %d\n", RSSI_BT));
- //initialGainUpper = 0x5E; //Modify by neil chen
-
- if(pDM_Odm->bUserAssignLevel)
- {
- pDM_Odm->bUserAssignLevel = FALSE;
- initialGainUpper = 0x7f;
- }
- else
- {
- initialGainUpper = 0x5E;
- }
-
- /*
- if (initial_gain_psd < 0x1a)
- initial_gain_psd = 0x1a;
- if (initial_gain_psd > initialGainUpper)
- initial_gain_psd = initialGainUpper;
- */
- //if(pDM_Odm->SupportICType==ODM_RTL8723A)
- SSBT = RSSI_BT * 2 +0x3E;
-
-
- //if(IS_HARDWARE_TYPE_8723AE(Adapter))
- // SSBT = RSSI_BT * 2 +0x3E;
- //else if((IS_HARDWARE_TYPE_8192C(Adapter))||(IS_HARDWARE_TYPE_8192D(Adapter))) // Add by Gary
- //{
- // RSSI_BT = initial_gain_psd;
- // SSBT = RSSI_BT;
- //}
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("PSD: SSBT= %d\n", SSBT));
- ODM_RT_TRACE( pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("PSD: initial gain= 0x%x\n", initial_gain_psd));
- //DbgPrint("PSD: SSBT= %d", SSBT);
- //need to do
- //pMgntInfo->bDMInitialGainEnable = FALSE;
- pDM_Odm->bDMInitialGainEnable = FALSE;
- initial_gain =(u1Byte) (ODM_GetBBReg(pDM_Odm, 0xc50, bMaskDWord) & 0x7F);
-
- // make sure the initial gain is under the correct range.
- //initial_gain_psd &= 0x7f;
- ODM_Write_DIG(pDM_Odm, initial_gain_psd);
- //1 Turn off 3-wire
- ODM_SetBBReg(pDM_Odm, 0x88c, BIT20|BIT21|BIT22|BIT23, 0xF);
- //pts value = 128, 256, 512, 1024
- pts = 128;
- if(pts == 128)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0);
- start_point = 64;
- stop_point = 192;
- }
- else if(pts == 256)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x1);
- start_point = 128;
- stop_point = 384;
- }
- else if(pts == 512)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x2);
- start_point = 256;
- stop_point = 768;
- }
- else
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x3);
- start_point = 512;
- stop_point = 1536;
- }
-
- //3 Skip WLAN channels if WLAN busy
- curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast) - lastTxOkCnt;
- curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast) - lastRxOkCnt;
- lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast);
- lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast);
- PSD_skip_start=80;
- PSD_skip_stop = 0;
- wlan_channel = CurrentChannel & 0x0f;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD,DBG_LOUD,("PSD: current channel: %x, BW:%d \n", wlan_channel, Is40MHz));
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- if(pDM_Odm->bBtHsOperation)
- {
- if(pDM_Odm->bLinked)
- {
- if(Is40MHz)
- {
- PSD_skip_start = ((wlan_channel-1)*5 -Is40MHz*10)-2; // Modify by Neil to add 10 chs to mask
- PSD_skip_stop = (PSD_skip_start + (1+Is40MHz)*20)+4;
- }
- else
- {
- PSD_skip_start = ((wlan_channel-1)*5 -Is40MHz*10)-10; // Modify by Neil to add 10 chs to mask
- PSD_skip_stop = (PSD_skip_start + (1+Is40MHz)*20)+18;
- }
- }
- else
- {
- // mask for 40MHz
- PSD_skip_start = ((wlan_channel-1)*5 -Is40MHz*10)-2; // Modify by Neil to add 10 chs to mask
- PSD_skip_stop = (PSD_skip_start + (1+Is40MHz)*20)+4;
- }
- if(PSD_skip_start < 0)
- PSD_skip_start = 0;
- if(PSD_skip_stop >80)
- PSD_skip_stop = 80;
- }
- else
- {
- if((curRxOkCnt+curTxOkCnt) > 5)
- {
- if(Is40MHz)
- {
- PSD_skip_start = ((wlan_channel-1)*5 -Is40MHz*10)-2; // Modify by Neil to add 10 chs to mask
- PSD_skip_stop = (PSD_skip_start + (1+Is40MHz)*20)+4;
- }
- else
- {
- PSD_skip_start = ((wlan_channel-1)*5 -Is40MHz*10)-10; // Modify by Neil to add 10 chs to mask
- PSD_skip_stop = (PSD_skip_start + (1+Is40MHz)*20)+18;
- }
-
- if(PSD_skip_start < 0)
- PSD_skip_start = 0;
- if(PSD_skip_stop >80)
- PSD_skip_stop = 80;
- }
- }
- }
- #if 0
- else
- {
- if((curRxOkCnt+curTxOkCnt) > 1000)
- {
- PSD_skip_start = (wlan_channel-1)*5 -Is40MHz*10;
- PSD_skip_stop = PSD_skip_start + (1+Is40MHz)*20;
- }
- }
- #endif //Reove RXHP Issue
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD,DBG_LOUD,("PSD: Skip tone from %d to %d \n", PSD_skip_start, PSD_skip_stop));
- for (n=0;n<80;n++)
- {
- if((n%20)==0)
- {
- channel = (n/20)*4 + 1;
-
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, channel);
- }
- tone_idx = n%20;
- if ((n>=PSD_skip_start) && (n<PSD_skip_stop))
- {
- PSD_report[n] = SSBT;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD,DBG_LOUD,("PSD:Tone %d skipped \n", n));
- }
- else
- {
- PSD_report_tmp = GetPSDData(pDM_Odm, idx[tone_idx], initial_gain_psd);
- if ( PSD_report_tmp > PSD_report[n])
- PSD_report[n] = PSD_report_tmp;
-
- }
- }
- PatchDCTone(pDM_Odm, PSD_report, initial_gain_psd);
-
- //----end
- //1 Turn on RX
- //Rx AGC on
- ODM_SetBBReg(pDM_Odm, 0xC70, BIT0, 1);
- ODM_SetBBReg(pDM_Odm, 0xC7C, BIT20, 1);
- //CCK on
- ODM_SetBBReg(pDM_Odm, rFPGA0_RFMOD, BIT24, 1);
- //1 Turn on TX
- //Resume TX Queue
-
- ODM_Write1Byte(pDM_Odm,REG_TXPAUSE, 0x00);
- //Turn on 3-wire
- ODM_SetBBReg(pDM_Odm, 0x88c, BIT20|BIT21|BIT22|BIT23, 0x0);
- //1 Restore Current Settings
- //Resume DIG
- pDM_Odm->bDMInitialGainEnable = TRUE;
-
- ODM_Write_DIG(pDM_Odm, initial_gain);
- // restore originl center frequency
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel);
- //Turn on CCA
- ODM_SetBBReg(pDM_Odm, 0xC14, bMaskDWord, RXIQI);
- //Restore RX idle low power
- if(RxIdleLowPwr == TRUE)
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 1);
-
- psd_cnt++;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("PSD:psd_cnt = %d \n",psd_cnt));
- if (psd_cnt < ReScan)
- ODM_SetTimer(pDM_Odm, &pDM_Odm->PSDTimer, Interval);
- else
- {
- psd_cnt = 0;
- for(i=0;i<80;i++)
- //DbgPrint("psd_report[%d]= %d \n", 2402+i, PSD_report[i]);
- RT_TRACE( COMP_PSD, DBG_LOUD,("psd_report[%d]= %d \n", 2402+i, PSD_report[i]));
- GoodChannelDecision(pDM_Odm, PSD_report, PSD_bitmap,RSSI_BT, PSD_bitmap_memory);
- if(pDM_Odm->SupportICType==ODM_RTL8723A)
- {
- cur_byte_idx=0;
- cur_bit_idx=0;
- //2 Restore H2C PSD Data to Last Data
- H2C_PSD_DATA_last[0] = H2C_PSD_DATA[0];
- H2C_PSD_DATA_last[1] = H2C_PSD_DATA[1];
- H2C_PSD_DATA_last[2] = H2C_PSD_DATA[2];
- H2C_PSD_DATA_last[3] = H2C_PSD_DATA[3];
- H2C_PSD_DATA_last[4] = H2C_PSD_DATA[4];
-
- //2 Translate 80bit channel map to 40bit channel
- for ( i=0;i<5;i++)
- {
- for(n=0;n<8;n++)
- {
- cur_byte_idx = i*2 + n/4;
- cur_bit_idx = (n%4)*2;
- if ( ((PSD_bitmap[cur_byte_idx]& BIT(cur_bit_idx)) != 0) && ((PSD_bitmap[cur_byte_idx]& BIT(cur_bit_idx+1)) != 0))
- H2C_PSD_DATA[i] = H2C_PSD_DATA[i] | (u1Byte) (1 << n);
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("H2C_PSD_DATA[%d]=0x%x\n" ,i, H2C_PSD_DATA[i]));
- }
-
- //3 To Compare the difference
- for ( i=0;i<5;i++)
- {
- if(H2C_PSD_DATA[i] !=H2C_PSD_DATA_last[i])
- {
- FillH2CCmd(Adapter, H2C_92C_PSD_RESULT, 5, H2C_PSD_DATA);
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_PSD, DBG_LOUD,("Need to Update the AFH Map \n"));
- break;
- }
- else
- {
- if(i==5)
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("Not need to Update\n"));
- }
- }
- //pHalData->bPSDactive=FALSE;
- if(pDM_Odm->bBtHsOperation)
- {
- ODM_SetTimer(pDM_Odm, &pDM_Odm->PSDTimer, 10000);
- ODM_RT_TRACE( pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("Leave dm_PSD_Monitor\n"));
- }
- else
- {
- ODM_SetTimer(pDM_Odm, &pDM_Odm->PSDTimer, 1500);
- ODM_RT_TRACE( pDM_Odm,ODM_COMP_PSD, DBG_LOUD,("Leave dm_PSD_Monitor\n"));
- }
- }
- }
- }
- /*
- //Neil for Get BT RSSI
- // Be Triggered by BT C2H CMD
- VOID
- ODM_PSDGetRSSI(
- IN u1Byte RSSI_BT)
- {
- }
- */
- VOID
- ODM_PSDMonitor(
- IN PDM_ODM_T pDM_Odm
- )
- {
- //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
-
- //if(IS_HARDWARE_TYPE_8723AE(Adapter))
-
- if(pDM_Odm->SupportICType == ODM_RTL8723A) //may need to add other IC type
- {
- if(pDM_Odm->SupportInterface==ODM_ITRF_PCIE)
- {
- if(pDM_Odm->bBtDisabled) //need to check upper layer connection
- {
- pDM_Odm->bPSDactive=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD, ("odm_PSDMonitor, return for BT is disabled!!!\n"));
- return;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PSD, DBG_LOUD, ("odm_PSDMonitor\n"));
- //if(pHalData->bPSDactive ==FALSE)
- //{
- pDM_Odm->bPSDinProcess = TRUE;
- //pHalData->bPSDactive=TRUE;
- pDM_Odm->bPSDactive=TRUE;
- odm_PSD_Monitor(pDM_Odm);
- pDM_Odm->bPSDinProcess = FALSE;
- }
- }
- }
- VOID
- odm_PSDMonitorCallback(
- PRT_TIMER pTimer
- )
- {
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PlatformScheduleWorkItem(&pHalData->PSDMonitorWorkitem);
- }
- VOID
- odm_PSDMonitorWorkItemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER Adapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- ODM_PSDMonitor(pDM_Odm);
- }
- // <20130108, Kordan> E.g., With LNA used, we make the Rx power smaller to have a better EVM. (Asked by Willis)
- VOID
- odm_RFEControl(
- IN PDM_ODM_T pDM_Odm,
- IN u8Byte RSSIVal
- )
- {
- PADAPTER Adapter = (PADAPTER)pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- static u1Byte TRSW_HighPwr = 0;
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, DBG_LOUD, ("===> odm_RFEControl, RSSI = %d, TRSW_HighPwr = 0x%X, pHalData->RFEType = %d\n",
- RSSIVal, TRSW_HighPwr, pHalData->RFEType ));
- if (pHalData->RFEType == 3) {
-
- pDM_Odm->RSSI_TRSW = RSSIVal;
- if (pDM_Odm->RSSI_TRSW >= pDM_Odm->RSSI_TRSW_H)
- {
- TRSW_HighPwr = 1; // Switch to
- PHY_SetBBReg(Adapter, r_ANTSEL_SW_Jaguar, BIT1|BIT0, 0x1); // Set ANTSW=1/ANTSWB=0 for SW control
- PHY_SetBBReg(Adapter, r_ANTSEL_SW_Jaguar, BIT9|BIT8, 0x3); // Set ANTSW=1/ANTSWB=0 for SW control
-
- }
- else if (pDM_Odm->RSSI_TRSW <= pDM_Odm->RSSI_TRSW_L)
- {
- TRSW_HighPwr = 0; // Switched back
- PHY_SetBBReg(Adapter, r_ANTSEL_SW_Jaguar, BIT1|BIT0, 0x1); // Set ANTSW=1/ANTSWB=0 for SW control
- PHY_SetBBReg(Adapter, r_ANTSEL_SW_Jaguar, BIT9|BIT8, 0x0); // Set ANTSW=1/ANTSWB=0 for SW control
- }
- }
-
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, DBG_LOUD, ("(pDM_Odm->RSSI_TRSW_H, pDM_Odm->RSSI_TRSW_L) = (%d, %d)\n", pDM_Odm->RSSI_TRSW_H, pDM_Odm->RSSI_TRSW_L));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, DBG_LOUD, ("(RSSIVal, RSSIVal, pDM_Odm->RSSI_TRSW_iso) = (%d, %d, %d)\n",
- RSSIVal, pDM_Odm->RSSI_TRSW_iso, pDM_Odm->RSSI_TRSW));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, DBG_LOUD, ("<=== odm_RFEControl, RSSI = %d, TRSW_HighPwr = 0x%X\n", RSSIVal, TRSW_HighPwr));
- }
- VOID
- ODM_MPT_DIG(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- PFALSE_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
- u1Byte CurrentIGI = (u1Byte)pDM_DigTable->CurIGValue;
- u1Byte DIG_Upper = 0x40, DIG_Lower = 0x20, C50, E50;
- u8Byte RXOK_cal;
- u1Byte IGI_A = 0x20, IGI_B = 0x20;
- #if ODM_FIX_2G_DIG
- IGI_A = 0x22;
- IGI_B = 0x24;
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_MP, DBG_LOUD, ("===> ODM_MPT_DIG, pBandType = %d\n", *pDM_Odm->pBandType));
- odm_FalseAlarmCounterStatistics( pDM_Odm);
- pDM_Odm->LastNumQryPhyStatusAll = pDM_Odm->NumQryPhyStatusAll;
- pDM_Odm->NumQryPhyStatusAll = pDM_Odm->PhyDbgInfo.NumQryPhyStatusCCK + pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM;
- RXOK_cal = pDM_Odm->NumQryPhyStatusAll - pDM_Odm->LastNumQryPhyStatusAll;
-
- if (RXOK_cal == 0)
- pDM_Odm->RxPWDBAve_final= 0;
- else
- pDM_Odm->RxPWDBAve_final= pDM_Odm->RxPWDBAve/RXOK_cal;
- pDM_Odm->RxPWDBAve = 0;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, DBG_LOUD, ("RX OK = %d\n", RXOK_cal));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, DBG_LOUD, ("pDM_Odm->RxPWDBAve_final = %d\n", pDM_Odm->RxPWDBAve_final));
- // <20130315, Kordan> Except Cameo, we should always trun on 2.4G/5G DIG.
- // (Cameo fixes the IGI of 2.4G, so only DIG on 5G. Asked by James.)
- #if ODM_FIX_2G_DIG
- if (*pDM_Odm->pBandType == BAND_ON_5G){ // for 5G
- #else
- if (1){ // for both 2G/5G
- #endif
- pDM_Odm->MPDIG_2G = FALSE;
- pDM_Odm->Times_2G = 0;
-
- if (RXOK_cal >= 70 && pDM_Odm->RxPWDBAve_final<= 30)
- {
- if (CurrentIGI > 0x24){
- ODM_Write1Byte( pDM_Odm, rA_IGI_Jaguar, 0x24);
- ODM_Write1Byte( pDM_Odm, rB_IGI_Jaguar, 0x24);
- }
- }
- else
- {
- if(pFalseAlmCnt->Cnt_all > 1000){
- CurrentIGI = CurrentIGI + 8;
- }
- else if(pFalseAlmCnt->Cnt_all > 200){
- CurrentIGI = CurrentIGI + 4;
- }
- else if (pFalseAlmCnt->Cnt_all > 50){
- CurrentIGI = CurrentIGI + 2;
- }
- else if (pFalseAlmCnt->Cnt_all < 2){
- CurrentIGI = CurrentIGI - 2;
- }
-
- if (CurrentIGI < DIG_Lower ){
- CurrentIGI = DIG_Lower;
- }
- else if(CurrentIGI > DIG_Upper){
- CurrentIGI = DIG_Upper;
- }
-
- pDM_DigTable->CurIGValue = CurrentIGI;
-
- ODM_Write1Byte( pDM_Odm, rA_IGI_Jaguar, (u1Byte)CurrentIGI);
- ODM_Write1Byte( pDM_Odm, rB_IGI_Jaguar, (u1Byte)CurrentIGI);
- C50 = ODM_Read1Byte( pDM_Odm, 0xc50);
- E50 = ODM_Read1Byte( pDM_Odm, 0xe50);
- //pDM_Odm->MPDIG_2G = FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_MP, DBG_LOUD, ("DIG = (%x, %x), Cnt_all = %d, Cnt_Ofdm_fail = %d, Cnt_Cck_fail = %d\n", C50, E50, pFalseAlmCnt->Cnt_all, pFalseAlmCnt->Cnt_Ofdm_fail, pFalseAlmCnt->Cnt_Cck_fail));
- }
-
- }
- else
- { //2G
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_MP, DBG_LOUD, ("MPDIG_2G = %d,\n", pDM_Odm->MPDIG_2G));
-
- if(pDM_Odm->MPDIG_2G == FALSE){
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_MP, DBG_LOUD, ("===> Fix IGI\n"));
- ODM_Write1Byte( pDM_Odm, rA_IGI_Jaguar, (u1Byte)IGI_A);
- ODM_Write1Byte( pDM_Odm, rB_IGI_Jaguar, (u1Byte)IGI_B);
- }
- if (pDM_Odm->Times_2G == 2)
- pDM_Odm->MPDIG_2G = TRUE;
- pDM_Odm->Times_2G++;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_DIG, DBG_LOUD, ("pDM_Odm->RxPWDBAve_final = %d\n", pDM_Odm->RxPWDBAve_final));
- if (pDM_Odm->SupportICType == ODM_RTL8812)
- odm_RFEControl(pDM_Odm, pDM_Odm->RxPWDBAve_final);
-
- ODM_SetTimer(pDM_Odm, &pDM_Odm->MPT_DIGTimer, 700);
-
- }
- VOID
- odm_MPT_DIGCallback(
- PRT_TIMER pTimer
- )
- {
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- PlatformScheduleWorkItem(&pDM_Odm->MPT_DIGWorkitem);
- #else
- ODM_MPT_DIG(pDM_Odm);
- #endif
- #else
- PlatformScheduleWorkItem(&pDM_Odm->MPT_DIGWorkitem);
- #endif
- }
- VOID
- odm_MPT_DIGWorkItemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER Adapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- ODM_MPT_DIG(pDM_Odm);
- }
- //cosa debug tool need to modify
- VOID
- ODM_PSDDbgControl(
- IN PADAPTER Adapter,
- IN u4Byte mode,
- IN u4Byte btRssi
- )
- {
- #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD, (" Monitor mode=%d, btRssi=%d\n", mode, btRssi));
- if(mode)
- {
- pDM_Odm->RSSI_BT = (u1Byte)btRssi;
- pDM_Odm->bUserAssignLevel = TRUE;
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PSDTimer, 0); //ms
- }
- else
- {
- ODM_CancelTimer(pDM_Odm, &pDM_Odm->PSDTimer);
- }
- #endif
- }
- //#if(DEV_BUS_TYPE == RT_PCI_INTERFACE)|(DEV_BUS_TYPE == RT_USB_INTERFACE)
- void odm_RXHPInit(
- IN PDM_ODM_T pDM_Odm)
- {
- #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)|(DEV_BUS_TYPE == RT_USB_INTERFACE)
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- u1Byte index;
- pRX_HP_Table->RXHP_enable = TRUE;
- pRX_HP_Table->RXHP_flag = 0;
- pRX_HP_Table->PSD_func_trigger = 0;
- pRX_HP_Table->Pre_IGI = 0x20;
- pRX_HP_Table->Cur_IGI = 0x20;
- pRX_HP_Table->Cur_pw_th = pw_th_10dB;
- pRX_HP_Table->Pre_pw_th = pw_th_10dB;
- for(index=0; index<80; index++)
- pRX_HP_Table->PSD_bitmap_RXHP[index] = 1;
- #if(DEV_BUS_TYPE == RT_USB_INTERFACE)
- pRX_HP_Table->TP_Mode = Idle_Mode;
- #endif
- #endif
- }
- void odm_RXHP(
- IN PDM_ODM_T pDM_Odm)
- {
- #if( DM_ODM_SUPPORT_TYPE & (ODM_WIN))
- #if (DEV_BUS_TYPE == RT_PCI_INTERFACE) | (DEV_BUS_TYPE == RT_USB_INTERFACE)
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable;
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- PFALSE_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt);
-
- u1Byte i, j, sum;
- u1Byte Is40MHz;
- s1Byte Intf_diff_idx, MIN_Intf_diff_idx = 16;
- s4Byte cur_channel;
- u1Byte ch_map_intf_5M[17] = {0};
- static u4Byte FA_TH = 0;
- static u1Byte psd_intf_flag = 0;
- static s4Byte curRssi = 0;
- static s4Byte preRssi = 0;
- static u1Byte PSDTriggerCnt = 1;
-
- u1Byte RX_HP_enable = (u1Byte)(ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore2, bMaskDWord)>>31); // for debug!!
- #if(DEV_BUS_TYPE == RT_USB_INTERFACE)
- static s8Byte lastTxOkCnt = 0, lastRxOkCnt = 0;
- s8Byte curTxOkCnt, curRxOkCnt;
- s8Byte curTPOkCnt;
- s8Byte TP_Acc3, TP_Acc5;
- static s8Byte TP_Buff[5] = {0};
- static u1Byte pre_state = 0, pre_state_flag = 0;
- static u1Byte Intf_HighTP_flag = 0, De_counter = 16;
- static u1Byte TP_Degrade_flag = 0;
- #endif
- static u1Byte LatchCnt = 0;
-
- if(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8188E))
- return;
- //AGC RX High Power Mode is only applied on 2G band in 92D!!!
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- if(*(pDM_Odm->pBandType) != ODM_BAND_2_4G)
- return;
- }
- if(!(pDM_Odm->SupportAbility==ODM_BB_RXHP))
- return;
- //RX HP ON/OFF
- if(RX_HP_enable == 1)
- pRX_HP_Table->RXHP_enable = FALSE;
- else
- pRX_HP_Table->RXHP_enable = TRUE;
- if(pRX_HP_Table->RXHP_enable == FALSE)
- {
- if(pRX_HP_Table->RXHP_flag == 1)
- {
- pRX_HP_Table->RXHP_flag = 0;
- psd_intf_flag = 0;
- }
- return;
- }
- #if(DEV_BUS_TYPE == RT_USB_INTERFACE)
- //2 Record current TP for USB interface
- curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast)-lastTxOkCnt;
- curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast)-lastRxOkCnt;
- lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast);
- lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast);
- curTPOkCnt = curTxOkCnt+curRxOkCnt;
- TP_Buff[0] = curTPOkCnt; // current TP
- TP_Acc3 = PlatformDivision64((TP_Buff[1]+TP_Buff[2]+TP_Buff[3]), 3);
- TP_Acc5 = PlatformDivision64((TP_Buff[0]+TP_Buff[1]+TP_Buff[2]+TP_Buff[3]+TP_Buff[4]), 5);
-
- if(TP_Acc5 < 1000)
- pRX_HP_Table->TP_Mode = Idle_Mode;
- else if((1000 < TP_Acc5)&&(TP_Acc5 < 3750000))
- pRX_HP_Table->TP_Mode = Low_TP_Mode;
- else
- pRX_HP_Table->TP_Mode = High_TP_Mode;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RX HP TP Mode = %d\n", pRX_HP_Table->TP_Mode));
- // Since TP result would be sampled every 2 sec, it needs to delay 4sec to wait PSD processing.
- // When LatchCnt = 0, we would Get PSD result.
- if(TP_Degrade_flag == 1)
- {
- LatchCnt--;
- if(LatchCnt == 0)
- {
- TP_Degrade_flag = 0;
- }
- }
- // When PSD function triggered by TP degrade 20%, and Interference Flag = 1
- // Set a De_counter to wait IGI = upper bound. If time is UP, the Interference flag will be pull down.
- if(Intf_HighTP_flag == 1)
- {
- De_counter--;
- if(De_counter == 0)
- {
- Intf_HighTP_flag = 0;
- psd_intf_flag = 0;
- }
- }
- #endif
- //2 AGC RX High Power Mode by PSD only applied to STA Mode
- //3 NOT applied 1. Ad Hoc Mode.
- //3 NOT applied 2. AP Mode
- if ((pMgntInfo->mAssoc) && (!pMgntInfo->mIbss) && (!ACTING_AS_AP(Adapter)))
- {
- Is40MHz = *(pDM_Odm->pBandWidth);
- curRssi = pDM_Odm->RSSI_Min;
- cur_channel = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x0fff) & 0x0f;
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RXHP RX HP flag = %d\n", pRX_HP_Table->RXHP_flag));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RXHP FA = %d\n", FalseAlmCnt->Cnt_all));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RXHP cur RSSI = %d, pre RSSI=%d\n", curRssi, preRssi));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RXHP current CH = %d\n", cur_channel));
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RXHP Is 40MHz = %d\n", Is40MHz));
- //2 PSD function would be triggered
- //3 1. Every 4 sec for PCIE
- //3 2. Before TP Mode (Idle TP<4kbps) for USB
- //3 3. After TP Mode (High TP) for USB
- if((curRssi > 68) && (pRX_HP_Table->RXHP_flag == 0)) // Only RSSI>TH and RX_HP_flag=0 will Do PSD process
- {
- #if (DEV_BUS_TYPE == RT_USB_INTERFACE)
- //2 Before TP Mode ==> PSD would be trigger every 4 sec
- if(pRX_HP_Table->TP_Mode == Idle_Mode) //2.1 less wlan traffic <4kbps
- {
- #endif
- if(PSDTriggerCnt == 1)
- {
- odm_PSD_RXHP(pDM_Odm);
- pRX_HP_Table->PSD_func_trigger = 1;
- PSDTriggerCnt = 0;
- }
- else
- {
- PSDTriggerCnt++;
- }
- #if(DEV_BUS_TYPE == RT_USB_INTERFACE)
- }
- //2 After TP Mode ==> Check if TP degrade larger than 20% would trigger PSD function
- if(pRX_HP_Table->TP_Mode == High_TP_Mode)
- {
- if((pre_state_flag == 0)&&(LatchCnt == 0))
- {
- // TP var < 5%
- if((((curTPOkCnt-TP_Acc3)*20)<(TP_Acc3))&&(((curTPOkCnt-TP_Acc3)*20)>(-TP_Acc3)))
- {
- pre_state++;
- if(pre_state == 3) // hit pre_state condition => consecutive 3 times
- {
- pre_state_flag = 1;
- pre_state = 0;
- }
- }
- else
- {
- pre_state = 0;
- }
- }
- //3 If pre_state_flag=1 ==> start to monitor TP degrade 20%
- if(pre_state_flag == 1)
- {
- if(((TP_Acc3-curTPOkCnt)*5)>(TP_Acc3)) // degrade 20%
- {
- odm_PSD_RXHP(pDM_Odm);
- pRX_HP_Table->PSD_func_trigger = 1;
- TP_Degrade_flag = 1;
- LatchCnt = 2;
- pre_state_flag = 0;
- }
- else if(((TP_Buff[2]-curTPOkCnt)*5)>TP_Buff[2])
- {
- odm_PSD_RXHP(pDM_Odm);
- pRX_HP_Table->PSD_func_trigger = 1;
- TP_Degrade_flag = 1;
- LatchCnt = 2;
- pre_state_flag = 0;
- }
- else if(((TP_Buff[3]-curTPOkCnt)*5)>TP_Buff[3])
- {
- odm_PSD_RXHP(pDM_Odm);
- pRX_HP_Table->PSD_func_trigger = 1;
- TP_Degrade_flag = 1;
- LatchCnt = 2;
- pre_state_flag = 0;
- }
- }
- }
- #endif
- }
- #if (DEV_BUS_TYPE == RT_USB_INTERFACE)
- for (i=0;i<4;i++)
- {
- TP_Buff[4-i] = TP_Buff[3-i];
- }
- #endif
- //2 Update PSD bitmap according to PSD report
- if((pRX_HP_Table->PSD_func_trigger == 1)&&(LatchCnt == 0))
- {
- //2 Separate 80M bandwidth into 16 group with smaller 5M BW.
- for (i = 0 ; i < 16 ; i++)
- {
- sum = 0;
- for(j = 0; j < 5 ; j++)
- sum += pRX_HP_Table->PSD_bitmap_RXHP[5*i + j];
-
- if(sum < 5)
- {
- ch_map_intf_5M[i] = 1; // interference flag
- }
- }
- //=============just for debug=========================
- //for(i=0;i<16;i++)
- //DbgPrint("RX HP: ch_map_intf_5M[%d] = %d\n", i, ch_map_intf_5M[i]);
- //===============================================
- //2 Mask target channel 5M index
- for(i = 0; i < (4+4*Is40MHz) ; i++)
- {
- ch_map_intf_5M[cur_channel - (1+2*Is40MHz) + i] = 0;
- }
-
- psd_intf_flag = 0;
- for(i = 0; i < 16; i++)
- {
- if(ch_map_intf_5M[i] == 1)
- {
- psd_intf_flag = 1; // interference is detected!!!
- break;
- }
- }
-
- #if (DEV_BUS_TYPE == RT_USB_INTERFACE)
- if(pRX_HP_Table->TP_Mode!=Idle_Mode)
- {
- if(psd_intf_flag == 1) // to avoid psd_intf_flag always 1
- {
- Intf_HighTP_flag = 1;
- De_counter = 32; // 0x1E -> 0x3E needs 32 times by each IGI step =1
- }
- }
- #endif
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RX HP psd_intf_flag = %d\n", psd_intf_flag));
- //2 Distance between target channel and interference
- for(i = 0; i < 16; i++)
- {
- if(ch_map_intf_5M[i] == 1)
- {
- Intf_diff_idx = ((cur_channel+Is40MHz-(i+1))>0) ? (s1Byte)(cur_channel-2*Is40MHz-(i-2)) : (s1Byte)((i+1)-(cur_channel+2*Is40MHz));
- if(Intf_diff_idx < MIN_Intf_diff_idx)
- MIN_Intf_diff_idx = Intf_diff_idx; // the min difference index between interference and target
- }
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RX HP MIN_Intf_diff_idx = %d\n", MIN_Intf_diff_idx));
- //2 Choose False Alarm Threshold
- switch (MIN_Intf_diff_idx){
- case 0:
- case 1:
- case 2:
- case 3:
- FA_TH = FA_RXHP_TH1;
- break;
- case 4: // CH5
- case 5: // CH6
- FA_TH = FA_RXHP_TH2;
- break;
- case 6: // CH7
- case 7: // CH8
- FA_TH = FA_RXHP_TH3;
- break;
- case 8: // CH9
- case 9: //CH10
- FA_TH = FA_RXHP_TH4;
- break;
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- FA_TH = FA_RXHP_TH5;
- break;
- }
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_RXHP, ODM_DBG_LOUD, ("RX HP FA_TH = %d\n", FA_TH));
- pRX_HP_Table->PSD_func_trigger = 0;
- }
- //1 Monitor RSSI variation to choose the suitable IGI or Exit AGC RX High Power Mode
- if(pRX_HP_Table->RXHP_flag == 1)
- {
- if ((curRssi > 80)&&(preRssi < 80))
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_1;
- }
- else if ((curRssi < 80)&&(preRssi > 80))
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_2;
- }
- else if ((curRssi > 72)&&(preRssi < 72))
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_2;
- }
- else if ((curRssi < 72)&&( preRssi > 72))
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_3;
- }
- else if (curRssi < 68) //RSSI is NOT large enough!!==> Exit AGC RX High Power Mode
- {
- pRX_HP_Table->Cur_pw_th = pw_th_10dB;
- pRX_HP_Table->RXHP_flag = 0; // Back to Normal DIG Mode
- psd_intf_flag = 0;
- }
- }
- else // pRX_HP_Table->RXHP_flag == 0
- {
- //1 Decide whether to enter AGC RX High Power Mode
- if ((curRssi > 70) && (psd_intf_flag == 1) && (FalseAlmCnt->Cnt_all > FA_TH) &&
- (pDM_DigTable->CurIGValue == pDM_DigTable->rx_gain_range_max))
- {
- if (curRssi > 80)
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_1;
- }
- else if (curRssi > 72)
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_2;
- }
- else
- {
- pRX_HP_Table->Cur_IGI = LNA_Low_Gain_3;
- }
- pRX_HP_Table->Cur_pw_th = pw_th_16dB; //RegC54[9:8]=2'b11: to enter AGC Flow 3
- pRX_HP_Table->First_time_enter = TRUE;
- pRX_HP_Table->RXHP_flag = 1; // RXHP_flag=1: AGC RX High Power Mode, RXHP_flag=0: Normal DIG Mode
- }
- }
- preRssi = curRssi;
- odm_Write_RXHP(pDM_Odm);
- }
- #endif //#if( DM_ODM_SUPPORT_TYPE & (ODM_WIN))
- #endif //#if (DEV_BUS_TYPE == RT_PCI_INTERFACE) | (DEV_BUS_TYPE == RT_USB_INTERFACE)
- }
- void odm_Write_RXHP(
- IN PDM_ODM_T pDM_Odm)
- {
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- u4Byte currentIGI;
- if(pRX_HP_Table->Cur_IGI != pRX_HP_Table->Pre_IGI)
- {
- ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskByte0, pRX_HP_Table->Cur_IGI);
- ODM_SetBBReg(pDM_Odm, rOFDM0_XBAGCCore1, bMaskByte0, pRX_HP_Table->Cur_IGI);
- }
-
- if(pRX_HP_Table->Cur_pw_th != pRX_HP_Table->Pre_pw_th)
- {
- ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore2, BIT8|BIT9, pRX_HP_Table->Cur_pw_th); // RegC54[9:8]=2'b11: AGC Flow 3
- }
- if(pRX_HP_Table->RXHP_flag == 0)
- {
- pRX_HP_Table->Cur_IGI = 0x20;
- }
- else
- {
- currentIGI = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskByte0);
- if(currentIGI<0x50)
- {
- ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskByte0, pRX_HP_Table->Cur_IGI);
- ODM_SetBBReg(pDM_Odm, rOFDM0_XBAGCCore1, bMaskByte0, pRX_HP_Table->Cur_IGI);
- }
- }
- pRX_HP_Table->Pre_IGI = pRX_HP_Table->Cur_IGI;
- pRX_HP_Table->Pre_pw_th = pRX_HP_Table->Cur_pw_th;
- }
- VOID
- odm_PSD_RXHP(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
- PADAPTER Adapter = pDM_Odm->Adapter;
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- unsigned int pts, start_point, stop_point, initial_gain ;
- static u1Byte PSD_bitmap_memory[80], init_memory = 0;
- static u1Byte psd_cnt=0;
- static u4Byte PSD_report[80], PSD_report_tmp;
- static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
- u1Byte idx[20]={96,99,102,106,109,112,115,118,122,125,
- 0,3,6,10,13,16,19,22,26,29};
- u1Byte n, i, channel, BBReset,tone_idx;
- u1Byte PSD_bitmap[10]/*, SSBT=0*/,initial_gain_psd=0, RSSI_BT=0, initialGainUpper;
- s4Byte PSD_skip_start, PSD_skip_stop;
- u4Byte CurrentChannel, RXIQI, RxIdleLowPwr, wlan_channel;
- u4Byte ReScan, Interval, Is40MHz;
- u8Byte curTxOkCnt, curRxOkCnt;
- //--------------2G band synthesizer for 92D switch RF channel using-----------------
- u1Byte group_idx=0;
- u4Byte SYN_RF25=0, SYN_RF26=0, SYN_RF27=0, SYN_RF2B=0, SYN_RF2C=0;
- u4Byte SYN[5] = {0x25, 0x26, 0x27, 0x2B, 0x2C}; // synthesizer RF register for 2G channel
- u4Byte SYN_group[3][5] = {{0x643BC, 0xFC038, 0x77C1A, 0x41289, 0x01840}, // For CH1,2,4,9,10.11.12 {0x643BC, 0xFC038, 0x77C1A, 0x41289, 0x01840}
- {0x643BC, 0xFC038, 0x07C1A, 0x41289, 0x01840}, // For CH3,13,14
- {0x243BC, 0xFC438, 0x07C1A, 0x4128B, 0x0FC41}}; // For Ch5,6,7,8
- //--------------------- Add by Gary for Debug setting ----------------------
- u1Byte RSSI_BT_new = (u1Byte) ODM_GetBBReg(pDM_Odm, 0xB9C, 0xFF);
- u1Byte rssi_ctrl = (u1Byte) ODM_GetBBReg(pDM_Odm, 0xB38, 0xFF);
- //---------------------------------------------------------------------
-
- if(pMgntInfo->bScanInProgress)
- {
- return;
- }
- ReScan = PSD_RESCAN;
- Interval = SCAN_INTERVAL;
- //1 Initialization
- if(init_memory == 0)
- {
- RT_TRACE( COMP_PSD, DBG_LOUD,("Init memory\n"));
- for(i = 0; i < 80; i++)
- PSD_bitmap_memory[i] = 0xFF; // channel is always good
- init_memory = 1;
- }
- if(psd_cnt == 0)
- {
- RT_TRACE(COMP_PSD, DBG_LOUD,("Enter dm_PSD_Monitor\n"));
- for(i = 0; i < 80; i++)
- PSD_report[i] = 0;
- }
- //1 Backup Current Settings
- CurrentChannel = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask);
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- //2 Record Current synthesizer parameters based on current channel
- if((*(pDM_Odm->pMacPhyMode)==ODM_SMSP)||(*(pDM_Odm->pMacPhyMode)==ODM_DMSP))
- {
- SYN_RF25 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x25, bMaskDWord);
- SYN_RF26 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x26, bMaskDWord);
- SYN_RF27 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x27, bMaskDWord);
- SYN_RF2B = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2B, bMaskDWord);
- SYN_RF2C = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2C, bMaskDWord);
- }
- else // DualMAC_DualPHY 2G
- {
- SYN_RF25 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x25, bMaskDWord);
- SYN_RF26 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x26, bMaskDWord);
- SYN_RF27 = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x27, bMaskDWord);
- SYN_RF2B = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2B, bMaskDWord);
- SYN_RF2C = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2C, bMaskDWord);
- }
- }
- RXIQI = ODM_GetBBReg(pDM_Odm, 0xC14, bMaskDWord);
- RxIdleLowPwr = (ODM_GetBBReg(pDM_Odm, 0x818, bMaskDWord)&BIT28)>>28;
- Is40MHz = *(pDM_Odm->pBandWidth);
- ODM_RT_TRACE(pDM_Odm, COMP_PSD, DBG_LOUD,("PSD Scan Start\n"));
- //1 Turn off CCK
- ODM_SetBBReg(pDM_Odm, rFPGA0_RFMOD, BIT24, 0);
- //1 Turn off TX
- //Pause TX Queue
- ODM_Write1Byte(pDM_Odm, REG_TXPAUSE, 0xFF);
- //Force RX to stop TX immediately
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_AC, bRFRegOffsetMask, 0x32E13);
- //1 Turn off RX
- //Rx AGC off RegC70[0]=0, RegC7C[20]=0
- ODM_SetBBReg(pDM_Odm, 0xC70, BIT0, 0);
- ODM_SetBBReg(pDM_Odm, 0xC7C, BIT20, 0);
- //Turn off CCA
- ODM_SetBBReg(pDM_Odm, 0xC14, bMaskDWord, 0x0);
- //BB Reset
- ODM_SetBBReg(pDM_Odm, 0x87C, BIT31, 1); //clock gated to prevent from AGC table mess
- BBReset = ODM_Read1Byte(pDM_Odm, 0x02);
- ODM_Write1Byte(pDM_Odm, 0x02, BBReset&(~BIT0));
- ODM_Write1Byte(pDM_Odm, 0x02, BBReset|BIT0);
- ODM_SetBBReg(pDM_Odm, 0x87C, BIT31, 0);
- //1 Leave RX idle low power
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0);
- //1 Fix initial gain
- RSSI_BT = RSSI_BT_new;
- RT_TRACE(COMP_PSD, DBG_LOUD,("PSD: RSSI_BT= %d\n", RSSI_BT));
-
- if(rssi_ctrl == 1) // just for debug!!
- initial_gain_psd = RSSI_BT_new;
- else
- initial_gain_psd = pDM_Odm->RSSI_Min; // PSD report based on RSSI
-
- RT_TRACE(COMP_PSD, DBG_LOUD,("PSD: RSSI_BT= %d\n", RSSI_BT));
-
- initialGainUpper = 0x54;
-
- RSSI_BT = initial_gain_psd;
- //SSBT = RSSI_BT;
-
- //RT_TRACE( COMP_PSD, DBG_LOUD,("PSD: SSBT= %d\n", SSBT));
- RT_TRACE( COMP_PSD, DBG_LOUD,("PSD: initial gain= 0x%x\n", initial_gain_psd));
-
- pDM_Odm->bDMInitialGainEnable = FALSE;
- initial_gain = ODM_GetBBReg(pDM_Odm, 0xc50, bMaskDWord) & 0x7F;
- //ODM_SetBBReg(pDM_Odm, 0xc50, 0x7F, initial_gain_psd);
- ODM_Write_DIG(pDM_Odm, initial_gain_psd);
- //1 Turn off 3-wire
- ODM_SetBBReg(pDM_Odm, 0x88c, BIT20|BIT21|BIT22|BIT23, 0xF);
- //pts value = 128, 256, 512, 1024
- pts = 128;
- if(pts == 128)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0);
- start_point = 64;
- stop_point = 192;
- }
- else if(pts == 256)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x1);
- start_point = 128;
- stop_point = 384;
- }
- else if(pts == 512)
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x2);
- start_point = 256;
- stop_point = 768;
- }
- else
- {
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x3);
- start_point = 512;
- stop_point = 1536;
- }
-
- //3 Skip WLAN channels if WLAN busy
- curTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast) - lastTxOkCnt;
- curRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast) - lastRxOkCnt;
- lastTxOkCnt = *(pDM_Odm->pNumTxBytesUnicast);
- lastRxOkCnt = *(pDM_Odm->pNumRxBytesUnicast);
-
- PSD_skip_start=80;
- PSD_skip_stop = 0;
- wlan_channel = CurrentChannel & 0x0f;
- RT_TRACE(COMP_PSD,DBG_LOUD,("PSD: current channel: %x, BW:%d \n", wlan_channel, Is40MHz));
-
- if((curRxOkCnt+curTxOkCnt) > 1000)
- {
- PSD_skip_start = (wlan_channel-1)*5 -Is40MHz*10;
- PSD_skip_stop = PSD_skip_start + (1+Is40MHz)*20;
- }
- RT_TRACE(COMP_PSD,DBG_LOUD,("PSD: Skip tone from %d to %d \n", PSD_skip_start, PSD_skip_stop));
- for (n=0;n<80;n++)
- {
- if((n%20)==0)
- {
- channel = (n/20)*4 + 1;
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- switch(channel)
- {
- case 1:
- case 9:
- group_idx = 0;
- break;
- case 5:
- group_idx = 2;
- break;
- case 13:
- group_idx = 1;
- break;
- }
- if((*(pDM_Odm->pMacPhyMode)==ODM_SMSP)||(*(pDM_Odm->pMacPhyMode)==ODM_DMSP))
- {
- for(i = 0; i < SYN_Length; i++)
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, SYN[i], bMaskDWord, SYN_group[group_idx][i]);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, channel);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, channel);
- }
- else // DualMAC_DualPHY 2G
- {
- for(i = 0; i < SYN_Length; i++)
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, SYN[i], bMaskDWord, SYN_group[group_idx][i]);
-
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, channel);
- }
- }
- else
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, channel);
- }
- tone_idx = n%20;
- if ((n>=PSD_skip_start) && (n<PSD_skip_stop))
- {
- PSD_report[n] = initial_gain_psd;//SSBT;
- ODM_RT_TRACE(pDM_Odm,COMP_PSD,DBG_LOUD,("PSD:Tone %d skipped \n", n));
- }
- else
- {
- PSD_report_tmp = GetPSDData(pDM_Odm, idx[tone_idx], initial_gain_psd);
- if ( PSD_report_tmp > PSD_report[n])
- PSD_report[n] = PSD_report_tmp;
-
- }
- }
- PatchDCTone(pDM_Odm, PSD_report, initial_gain_psd);
-
- //----end
- //1 Turn on RX
- //Rx AGC on
- ODM_SetBBReg(pDM_Odm, 0xC70, BIT0, 1);
- ODM_SetBBReg(pDM_Odm, 0xC7C, BIT20, 1);
- //CCK on
- ODM_SetBBReg(pDM_Odm, rFPGA0_RFMOD, BIT24, 1);
- //1 Turn on TX
- //Resume TX Queue
- ODM_Write1Byte(pDM_Odm, REG_TXPAUSE, 0x00);
- //Turn on 3-wire
- ODM_SetBBReg(pDM_Odm, 0x88c, BIT20|BIT21|BIT22|BIT23, 0x0);
- //1 Restore Current Settings
- //Resume DIG
- pDM_Odm->bDMInitialGainEnable= TRUE;
- //ODM_SetBBReg(pDM_Odm, 0xc50, 0x7F, initial_gain);
- ODM_Write_DIG(pDM_Odm,(u1Byte) initial_gain);
- // restore originl center frequency
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel);
- if(pDM_Odm->SupportICType == ODM_RTL8192D)
- {
- if((*(pDM_Odm->pMacPhyMode)==ODM_SMSP)||(*(pDM_Odm->pMacPhyMode)==ODM_DMSP))
- {
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, RF_CHNLBW, bMaskDWord, CurrentChannel);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x25, bMaskDWord, SYN_RF25);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x26, bMaskDWord, SYN_RF26);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x27, bMaskDWord, SYN_RF27);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2B, bMaskDWord, SYN_RF2B);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_B, 0x2C, bMaskDWord, SYN_RF2C);
- }
- else // DualMAC_DualPHY
- {
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x25, bMaskDWord, SYN_RF25);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x26, bMaskDWord, SYN_RF26);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x27, bMaskDWord, SYN_RF27);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2B, bMaskDWord, SYN_RF2B);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x2C, bMaskDWord, SYN_RF2C);
- }
- }
- //Turn on CCA
- ODM_SetBBReg(pDM_Odm, 0xC14, bMaskDWord, RXIQI);
- //Restore RX idle low power
- if(RxIdleLowPwr == TRUE)
- ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 1);
-
- psd_cnt++;
- //gPrint("psd cnt=%d\n", psd_cnt);
- ODM_RT_TRACE(pDM_Odm,COMP_PSD, DBG_LOUD,("PSD:psd_cnt = %d \n",psd_cnt));
- if (psd_cnt < ReScan)
- {
- ODM_SetTimer(pDM_Odm, &pRX_HP_Table->PSDTimer, Interval); //ms
- }
- else
- {
- psd_cnt = 0;
- for(i=0;i<80;i++)
- RT_TRACE( COMP_PSD, DBG_LOUD,("psd_report[%d]= %d \n", 2402+i, PSD_report[i]));
- //DbgPrint("psd_report[%d]= %d \n", 2402+i, PSD_report[i]);
- GoodChannelDecision(pDM_Odm, PSD_report, PSD_bitmap,RSSI_BT, PSD_bitmap_memory);
- }
- }
- VOID
- odm_PSD_RXHPCallback(
- PRT_TIMER pTimer
- )
- {
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- pRXHP_T pRX_HP_Table = &pDM_Odm->DM_RXHP_Table;
-
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- ODM_ScheduleWorkItem(&pRX_HP_Table->PSDTimeWorkitem);
- #else
- odm_PSD_RXHP(pDM_Odm);
- #endif
- #else
- ODM_ScheduleWorkItem(&pRX_HP_Table->PSDTimeWorkitem);
- #endif
-
- }
- VOID
- odm_PSD_RXHPWorkitemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER pAdapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
-
- odm_PSD_RXHP(pDM_Odm);
- }
- #endif //#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_PathDiversityInit(
- IN PDM_ODM_T pDM_Odm
- )
- {
- if(!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_PATH_DIV,ODM_DBG_LOUD,("Return: Not Support PathDiv\n"));
- return;
- }
- #if (RTL8812A_SUPPORT == 1)
- // if(pDM_Odm->SupportICType & ODM_RTL8812)
- // ODM_PathDiversityInit_8812A(pDM_Odm);
- #endif
- }
- VOID
- odm_PathDiversity(
- IN PDM_ODM_T pDM_Odm
- )
- {
- if(!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV))
- {
- ODM_RT_TRACE(pDM_Odm, ODM_COMP_PATH_DIV,ODM_DBG_LOUD,("Return: Not Support PathDiv\n"));
- return;
- }
- #if (RTL8812A_SUPPORT == 1)
- // if(pDM_Odm->SupportICType & ODM_RTL8812)
- // ODM_PathDiversity_8812A(pDM_Odm);
- #endif
- }
- //
- // 2011/12/02 MH Copy from MP oursrc for temporarily test.
- //
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- odm_OFDMTXPathDiversity_92C(
- IN PADAPTER Adapter)
- {
- // HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- PRT_WLAN_STA pEntry;
- u1Byte i, DefaultRespPath = 0;
- s4Byte MinRSSI = 0xFF;
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- pDM_PDTable->OFDMTXPath = 0;
-
- //1 Default Port
- if(pMgntInfo->mAssoc)
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: Default port RSSI[0]=%d, RSSI[1]=%d\n",
- Adapter->RxStats.RxRSSIPercentage[0], Adapter->RxStats.RxRSSIPercentage[1]));
- if(Adapter->RxStats.RxRSSIPercentage[0] > Adapter->RxStats.RxRSSIPercentage[1])
- {
- pDM_PDTable->OFDMTXPath = pDM_PDTable->OFDMTXPath & (~BIT0);
- MinRSSI = Adapter->RxStats.RxRSSIPercentage[1];
- DefaultRespPath = 0;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: Default port Select Path-0\n"));
- }
- else
- {
- pDM_PDTable->OFDMTXPath = pDM_PDTable->OFDMTXPath | BIT0;
- MinRSSI = Adapter->RxStats.RxRSSIPercentage[0];
- DefaultRespPath = 1;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: Default port Select Path-1\n"));
- }
- //RT_TRACE( COMP_SWAS, DBG_LOUD, ("pDM_PDTable->OFDMTXPath =0x%x\n",pDM_PDTable->OFDMTXPath));
- }
- //1 Extension Port
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
- else
- pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
- if(pEntry!=NULL)
- {
- if(pEntry->bAssociated)
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: MACID=%d, RSSI_0=%d, RSSI_1=%d\n",
- pEntry->AssociatedMacId, pEntry->rssi_stat.RxRSSIPercentage[0], pEntry->rssi_stat.RxRSSIPercentage[1]));
-
- if(pEntry->rssi_stat.RxRSSIPercentage[0] > pEntry->rssi_stat.RxRSSIPercentage[1])
- {
- pDM_PDTable->OFDMTXPath = pDM_PDTable->OFDMTXPath & ~(BIT(pEntry->AssociatedMacId));
- //pHalData->TXPath = pHalData->TXPath & ~(1<<(pEntry->AssociatedMacId));
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: MACID=%d Select Path-0\n", pEntry->AssociatedMacId));
- if(pEntry->rssi_stat.RxRSSIPercentage[1] < MinRSSI)
- {
- MinRSSI = pEntry->rssi_stat.RxRSSIPercentage[1];
- DefaultRespPath = 0;
- }
- }
- else
- {
- pDM_PDTable->OFDMTXPath = pDM_PDTable->OFDMTXPath | BIT(pEntry->AssociatedMacId);
- //pHalData->TXPath = pHalData->TXPath | (1 << (pEntry->AssociatedMacId));
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_OFDMTXPathDiversity_92C: MACID=%d Select Path-1\n", pEntry->AssociatedMacId));
- if(pEntry->rssi_stat.RxRSSIPercentage[0] < MinRSSI)
- {
- MinRSSI = pEntry->rssi_stat.RxRSSIPercentage[0];
- DefaultRespPath = 1;
- }
- }
- }
- }
- else
- {
- break;
- }
- }
- pDM_PDTable->OFDMDefaultRespPath = DefaultRespPath;
- }
- BOOLEAN
- odm_IsConnected_92C(
- IN PADAPTER Adapter
- )
- {
- PRT_WLAN_STA pEntry;
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- u4Byte i;
- BOOLEAN bConnected=FALSE;
-
- if(pMgntInfo->mAssoc)
- {
- bConnected = TRUE;
- }
- else
- {
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
- else
- pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
- if(pEntry!=NULL)
- {
- if(pEntry->bAssociated)
- {
- bConnected = TRUE;
- break;
- }
- }
- else
- {
- break;
- }
- }
- }
- return bConnected;
- }
- VOID
- odm_ResetPathDiversity_92C(
- IN PADAPTER Adapter
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- PRT_WLAN_STA pEntry;
- u4Byte i,j;
- pHalData->RSSI_test = FALSE;
- pDM_PDTable->CCK_Pkt_Cnt = 0;
- pDM_PDTable->OFDM_Pkt_Cnt = 0;
- pHalData->CCK_Pkt_Cnt =0;
- pHalData->OFDM_Pkt_Cnt =0;
-
- if(pDM_PDTable->CCKPathDivEnable == TRUE)
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x01); //RX path = PathAB
- for(i=0; i<2; i++)
- {
- pDM_PDTable->RSSI_CCK_Path_cnt[i]=0;
- pDM_PDTable->RSSI_CCK_Path[i] = 0;
- }
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
- else
- pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
- if(pEntry!=NULL)
- {
- pEntry->rssi_stat.CCK_Pkt_Cnt = 0;
- pEntry->rssi_stat.OFDM_Pkt_Cnt = 0;
- for(j=0; j<2; j++)
- {
- pEntry->rssi_stat.RSSI_CCK_Path_cnt[j] = 0;
- pEntry->rssi_stat.RSSI_CCK_Path[j] = 0;
- }
- }
- else
- break;
- }
- }
- VOID
- odm_CCKTXPathDiversity_92C(
- IN PADAPTER Adapter
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
- PRT_WLAN_STA pEntry;
- s4Byte MinRSSI = 0xFF;
- u1Byte i, DefaultRespPath = 0;
- // BOOLEAN bBModePathDiv = FALSE;
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- //1 Default Port
- if(pMgntInfo->mAssoc)
- {
- if(pHalData->OFDM_Pkt_Cnt == 0)
- {
- for(i=0; i<2; i++)
- {
- if(pDM_PDTable->RSSI_CCK_Path_cnt[i] > 1) //Because the first packet is discarded
- pDM_PDTable->RSSI_CCK_Path[i] = pDM_PDTable->RSSI_CCK_Path[i] / (pDM_PDTable->RSSI_CCK_Path_cnt[i]-1);
- else
- pDM_PDTable->RSSI_CCK_Path[i] = 0;
- }
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: pDM_PDTable->RSSI_CCK_Path[0]=%d, pDM_PDTable->RSSI_CCK_Path[1]=%d\n",
- pDM_PDTable->RSSI_CCK_Path[0], pDM_PDTable->RSSI_CCK_Path[1]));
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: pDM_PDTable->RSSI_CCK_Path_cnt[0]=%d, pDM_PDTable->RSSI_CCK_Path_cnt[1]=%d\n",
- pDM_PDTable->RSSI_CCK_Path_cnt[0], pDM_PDTable->RSSI_CCK_Path_cnt[1]));
-
- if(pDM_PDTable->RSSI_CCK_Path[0] > pDM_PDTable->RSSI_CCK_Path[1])
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath & (~BIT0);
- MinRSSI = pDM_PDTable->RSSI_CCK_Path[1];
- DefaultRespPath = 0;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Default port Select CCK Path-0\n"));
- }
- else if(pDM_PDTable->RSSI_CCK_Path[0] < pDM_PDTable->RSSI_CCK_Path[1])
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath | BIT0;
- MinRSSI = pDM_PDTable->RSSI_CCK_Path[0];
- DefaultRespPath = 1;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Default port Select CCK Path-1\n"));
- }
- else
- {
- if((pDM_PDTable->RSSI_CCK_Path[0] != 0) && (pDM_PDTable->RSSI_CCK_Path[0] < MinRSSI))
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath & (~BIT0);
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Default port Select CCK Path-0\n"));
- MinRSSI = pDM_PDTable->RSSI_CCK_Path[1];
- DefaultRespPath = 0;
- }
- else
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Default port unchange CCK Path\n"));
- }
- }
- }
- else //Follow OFDM decision
- {
- pDM_PDTable->CCKTXPath = (pDM_PDTable->CCKTXPath & (~BIT0)) | (pDM_PDTable->OFDMTXPath &BIT0);
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Follow OFDM decision, Default port Select CCK Path-%d\n",
- pDM_PDTable->CCKTXPath &BIT0));
- }
- }
- //1 Extension Port
- for(i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++)
- {
- if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- pEntry = AsocEntry_EnumStation(GetFirstExtAdapter(Adapter), i);
- else
- pEntry = AsocEntry_EnumStation(GetDefaultAdapter(Adapter), i);
- if(pEntry!=NULL)
- {
- if(pEntry->bAssociated)
- {
- if(pEntry->rssi_stat.OFDM_Pkt_Cnt == 0)
- {
- u1Byte j=0;
- for(j=0; j<2; j++)
- {
- if(pEntry->rssi_stat.RSSI_CCK_Path_cnt[j] > 1)
- pEntry->rssi_stat.RSSI_CCK_Path[j] = pEntry->rssi_stat.RSSI_CCK_Path[j] / (pEntry->rssi_stat.RSSI_CCK_Path_cnt[j]-1);
- else
- pEntry->rssi_stat.RSSI_CCK_Path[j] = 0;
- }
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: MACID=%d, RSSI_CCK0=%d, RSSI_CCK1=%d\n",
- pEntry->AssociatedMacId, pEntry->rssi_stat.RSSI_CCK_Path[0], pEntry->rssi_stat.RSSI_CCK_Path[1]));
-
- if(pEntry->rssi_stat.RSSI_CCK_Path[0] >pEntry->rssi_stat.RSSI_CCK_Path[1])
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath & ~(BIT(pEntry->AssociatedMacId));
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: MACID=%d Select CCK Path-0\n", pEntry->AssociatedMacId));
- if(pEntry->rssi_stat.RSSI_CCK_Path[1] < MinRSSI)
- {
- MinRSSI = pEntry->rssi_stat.RSSI_CCK_Path[1];
- DefaultRespPath = 0;
- }
- }
- else if(pEntry->rssi_stat.RSSI_CCK_Path[0] <pEntry->rssi_stat.RSSI_CCK_Path[1])
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath | BIT(pEntry->AssociatedMacId);
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: MACID=%d Select CCK Path-1\n", pEntry->AssociatedMacId));
- if(pEntry->rssi_stat.RSSI_CCK_Path[0] < MinRSSI)
- {
- MinRSSI = pEntry->rssi_stat.RSSI_CCK_Path[0];
- DefaultRespPath = 1;
- }
- }
- else
- {
- if((pEntry->rssi_stat.RSSI_CCK_Path[0] != 0) && (pEntry->rssi_stat.RSSI_CCK_Path[0] < MinRSSI))
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->CCKTXPath & ~(BIT(pEntry->AssociatedMacId));
- MinRSSI = pEntry->rssi_stat.RSSI_CCK_Path[1];
- DefaultRespPath = 0;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: MACID=%d Select CCK Path-0\n", pEntry->AssociatedMacId));
- }
- else
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: MACID=%d unchange CCK Path\n", pEntry->AssociatedMacId));
- }
- }
- }
- else //Follow OFDM decision
- {
- pDM_PDTable->CCKTXPath = (pDM_PDTable->CCKTXPath & (~(BIT(pEntry->AssociatedMacId)))) | (pDM_PDTable->OFDMTXPath & BIT(pEntry->AssociatedMacId));
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: Follow OFDM decision, MACID=%d Select CCK Path-%d\n",
- pEntry->AssociatedMacId, (pDM_PDTable->CCKTXPath & BIT(pEntry->AssociatedMacId))>>(pEntry->AssociatedMacId)));
- }
- }
- }
- else
- {
- break;
- }
- }
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C:MinRSSI=%d\n",MinRSSI));
- if(MinRSSI == 0xFF)
- DefaultRespPath = pDM_PDTable->CCKDefaultRespPath;
- pDM_PDTable->CCKDefaultRespPath = DefaultRespPath;
- }
- VOID
- odm_PathDiversityAfterLink_92C(
- IN PADAPTER Adapter
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- u1Byte DefaultRespPath=0;
- if((!IS_92C_SERIAL(pHalData->VersionID)) || (pHalData->PathDivCfg != 1) || (pHalData->eRFPowerState == eRfOff))
- {
- if(pHalData->PathDivCfg == 0)
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("No ODM_TXPathDiversity()\n"));
- }
- else
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("2T ODM_TXPathDiversity()\n"));
- }
- return;
- }
- if(!odm_IsConnected_92C(Adapter))
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("ODM_TXPathDiversity(): No Connections\n"));
- return;
- }
-
-
- if(pDM_PDTable->TrainingState == 0)
- {
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("ODM_TXPathDiversity() ==>\n"));
- odm_OFDMTXPathDiversity_92C(Adapter);
- if((pDM_PDTable->CCKPathDivEnable == TRUE) && (pDM_PDTable->OFDM_Pkt_Cnt < 100))
- {
- //RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: TrainingState=0\n"));
-
- if(pDM_PDTable->CCK_Pkt_Cnt > 300)
- pDM_PDTable->Timer = 20;
- else if(pDM_PDTable->CCK_Pkt_Cnt > 100)
- pDM_PDTable->Timer = 60;
- else
- pDM_PDTable->Timer = 250;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: timer=%d\n",pDM_PDTable->Timer));
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x00); // RX path = PathA
- pDM_PDTable->TrainingState = 1;
- pHalData->RSSI_test = TRUE;
- ODM_SetTimer( pDM_Odm, &pDM_Odm->CCKPathDiversityTimer, pDM_PDTable->Timer); //ms
- }
- else
- {
- pDM_PDTable->CCKTXPath = pDM_PDTable->OFDMTXPath;
- DefaultRespPath = pDM_PDTable->OFDMDefaultRespPath;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_SetRespPath_92C: Skip odm_CCKTXPathDiversity_92C, DefaultRespPath is OFDM\n"));
- odm_SetRespPath_92C(Adapter, DefaultRespPath);
- odm_ResetPathDiversity_92C(Adapter);
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("ODM_TXPathDiversity() <==\n"));
- }
- }
- else if(pDM_PDTable->TrainingState == 1)
- {
- //RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: TrainingState=1\n"));
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x05); // RX path = PathB
- pDM_PDTable->TrainingState = 2;
- ODM_SetTimer( pDM_Odm, &pDM_Odm->CCKPathDiversityTimer, pDM_PDTable->Timer); //ms
- }
- else
- {
- //RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_CCKTXPathDiversity_92C: TrainingState=2\n"));
- pDM_PDTable->TrainingState = 0;
- odm_CCKTXPathDiversity_92C(Adapter);
- if(pDM_PDTable->OFDM_Pkt_Cnt != 0)
- {
- DefaultRespPath = pDM_PDTable->OFDMDefaultRespPath;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_SetRespPath_92C: DefaultRespPath is OFDM\n"));
- }
- else
- {
- DefaultRespPath = pDM_PDTable->CCKDefaultRespPath;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_SetRespPath_92C: DefaultRespPath is CCK\n"));
- }
- odm_SetRespPath_92C(Adapter, DefaultRespPath);
- odm_ResetPathDiversity_92C(Adapter);
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("ODM_TXPathDiversity() <==\n"));
- }
- }
- VOID
- odm_CCKTXPathDiversityCallback(
- PRT_TIMER pTimer
- )
- {
- #if USE_WORKITEM
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- #else
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- #endif
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- PlatformScheduleWorkItem(&pDM_Odm->CCKPathDiversityWorkitem);
- #else
- odm_PathDiversityAfterLink_92C(Adapter);
- #endif
- #else
- PlatformScheduleWorkItem(&pDM_Odm->CCKPathDiversityWorkitem);
- #endif
- }
- VOID
- odm_CCKTXPathDiversityWorkItemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER Adapter = (PADAPTER)pContext;
- odm_CCKTXPathDiversity_92C(Adapter);
- }
- VOID
- ODM_CCKPathDiversityChkPerPktRssi(
- PADAPTER Adapter,
- BOOLEAN bIsDefPort,
- BOOLEAN bMatchBSSID,
- PRT_WLAN_STA pEntry,
- PRT_RFD pRfd,
- pu1Byte pDesc
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- BOOLEAN bCount = FALSE;
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- //BOOLEAN isCCKrate = RX_HAL_IS_CCK_RATE_92C(pDesc);
- #if DEV_BUS_TYPE != RT_SDIO_INTERFACE
- BOOLEAN isCCKrate = RX_HAL_IS_CCK_RATE(Adapter, pDesc);
- #else //below code would be removed if we have verified SDIO
- BOOLEAN isCCKrate = IS_HARDWARE_TYPE_8188E(Adapter) ? RX_HAL_IS_CCK_RATE_88E(pDesc) : RX_HAL_IS_CCK_RATE_92C(pDesc);
- #endif
- if((pHalData->PathDivCfg != 1) || (pHalData->RSSI_test == FALSE))
- return;
-
- if(pHalData->RSSI_target==NULL && bIsDefPort && bMatchBSSID)
- bCount = TRUE;
- else if(pHalData->RSSI_target!=NULL && pEntry!=NULL && pHalData->RSSI_target==pEntry)
- bCount = TRUE;
- if(bCount && isCCKrate)
- {
- if(pDM_PDTable->TrainingState == 1 )
- {
- if(pEntry)
- {
- if(pEntry->rssi_stat.RSSI_CCK_Path_cnt[0] != 0)
- pEntry->rssi_stat.RSSI_CCK_Path[0] += pRfd->Status.RxPWDBAll;
- pEntry->rssi_stat.RSSI_CCK_Path_cnt[0]++;
- }
- else
- {
- if(pDM_PDTable->RSSI_CCK_Path_cnt[0] != 0)
- pDM_PDTable->RSSI_CCK_Path[0] += pRfd->Status.RxPWDBAll;
- pDM_PDTable->RSSI_CCK_Path_cnt[0]++;
- }
- }
- else if(pDM_PDTable->TrainingState == 2 )
- {
- if(pEntry)
- {
- if(pEntry->rssi_stat.RSSI_CCK_Path_cnt[1] != 0)
- pEntry->rssi_stat.RSSI_CCK_Path[1] += pRfd->Status.RxPWDBAll;
- pEntry->rssi_stat.RSSI_CCK_Path_cnt[1]++;
- }
- else
- {
- if(pDM_PDTable->RSSI_CCK_Path_cnt[1] != 0)
- pDM_PDTable->RSSI_CCK_Path[1] += pRfd->Status.RxPWDBAll;
- pDM_PDTable->RSSI_CCK_Path_cnt[1]++;
- }
- }
- }
- }
- BOOLEAN
- ODM_PathDiversityBeforeLink92C(
- //IN PADAPTER Adapter
- IN PDM_ODM_T pDM_Odm
- )
- {
- #if (RT_MEM_SIZE_LEVEL != RT_MEM_SIZE_MINIMUM)
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE* pHalData = NULL;
- PMGNT_INFO pMgntInfo = NULL;
- //pSWAT_T pDM_SWAT_Table = &Adapter->DM_SWAT_Table;
- pPD_T pDM_PDTable = NULL;
- s1Byte Score = 0;
- PRT_WLAN_BSS pTmpBssDesc;
- PRT_WLAN_BSS pTestBssDesc;
- u1Byte target_chnl = 0;
- u1Byte index;
- if (pDM_Odm->Adapter == NULL) //For BSOD when plug/unplug fast. //By YJ,120413
- { // The ODM structure is not initialized.
- return FALSE;
- }
- pHalData = GET_HAL_DATA(Adapter);
- pMgntInfo = &Adapter->MgntInfo;
- pDM_PDTable = &Adapter->DM_PDTable;
-
- // Condition that does not need to use path diversity.
- if((!IS_92C_SERIAL(pHalData->VersionID)) || (pHalData->PathDivCfg!=1) || pMgntInfo->AntennaTest )
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD,
- ("ODM_PathDiversityBeforeLink92C(): No PathDiv Mechanism before link.\n"));
- return FALSE;
- }
- // Since driver is going to set BB register, it shall check if there is another thread controlling BB/RF.
- PlatformAcquireSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
- if(pHalData->eRFPowerState!=eRfOn || pMgntInfo->RFChangeInProgress || pMgntInfo->bMediaConnect)
- {
- PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
-
- RT_TRACE(COMP_SWAS, DBG_LOUD,
- ("ODM_PathDiversityBeforeLink92C(): RFChangeInProgress(%x), eRFPowerState(%x)\n",
- pMgntInfo->RFChangeInProgress,
- pHalData->eRFPowerState));
-
- //pDM_SWAT_Table->SWAS_NoLink_State = 0;
- pDM_PDTable->PathDiv_NoLink_State = 0;
-
- return FALSE;
- }
- else
- {
- PlatformReleaseSpinLock(Adapter, RT_RF_STATE_SPINLOCK);
- }
- //1 Run AntDiv mechanism "Before Link" part.
- //if(pDM_SWAT_Table->SWAS_NoLink_State == 0)
- if(pDM_PDTable->PathDiv_NoLink_State == 0)
- {
- //1 Prepare to do Scan again to check current antenna state.
- // Set check state to next step.
- //pDM_SWAT_Table->SWAS_NoLink_State = 1;
- pDM_PDTable->PathDiv_NoLink_State = 1;
-
- // Copy Current Scan list.
- Adapter->MgntInfo.tmpNumBssDesc = pMgntInfo->NumBssDesc;
- PlatformMoveMemory((PVOID)Adapter->MgntInfo.tmpbssDesc, (PVOID)pMgntInfo->bssDesc, sizeof(RT_WLAN_BSS)*MAX_BSS_DESC);
- // Switch Antenna to another one.
- if(pDM_PDTable->DefaultRespPath == 0)
- {
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x05); // TRX path = PathB
- odm_SetRespPath_92C(Adapter, 1);
- pDM_PDTable->OFDMTXPath = 0xFFFFFFFF;
- pDM_PDTable->CCKTXPath = 0xFFFFFFFF;
- }
- else
- {
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x00); // TRX path = PathA
- odm_SetRespPath_92C(Adapter, 0);
- pDM_PDTable->OFDMTXPath = 0x0;
- pDM_PDTable->CCKTXPath = 0x0;
- }
- #if 0
- pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- pDM_SWAT_Table->CurAntenna = (pDM_SWAT_Table->CurAntenna==Antenna_A)?Antenna_B:Antenna_A;
-
- RT_TRACE(COMP_SWAS, DBG_LOUD,
- ("ODM_SwAntDivCheckBeforeLink8192C: Change to Ant(%s) for testing.\n", (pDM_SWAT_Table->CurAntenna==Antenna_A)?"A":"B"));
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
- pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
- PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
- #endif
- // Go back to scan function again.
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_PathDiversityBeforeLink92C: Scan one more time\n"));
- pMgntInfo->ScanStep=0;
- target_chnl = odm_SwAntDivSelectChkChnl(Adapter);
- odm_SwAntDivConsructChkScanChnl(Adapter, target_chnl);
- CHNL_ReleaseOpLock(Adapter);
- PlatformSetTimer(Adapter, &pMgntInfo->ScanTimer, 5);
- return TRUE;
- }
- else
- {
- //1 ScanComple() is called after antenna swiched.
- //1 Check scan result and determine which antenna is going
- //1 to be used.
- for(index=0; index<Adapter->MgntInfo.tmpNumBssDesc; index++)
- {
- pTmpBssDesc = &(Adapter->MgntInfo.tmpbssDesc[index]);
- pTestBssDesc = &(pMgntInfo->bssDesc[index]);
- if(PlatformCompareMemory(pTestBssDesc->bdBssIdBuf, pTmpBssDesc->bdBssIdBuf, 6)!=0)
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_PathDiversityBeforeLink92C(): ERROR!! This shall not happen.\n"));
- continue;
- }
- if(pTmpBssDesc->RecvSignalPower > pTestBssDesc->RecvSignalPower)
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_PathDiversityBeforeLink92C: Compare scan entry: Score++\n"));
- RT_PRINT_STR(COMP_SWAS, DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
-
- Score++;
- PlatformMoveMemory(pTestBssDesc, pTmpBssDesc, sizeof(RT_WLAN_BSS));
- }
- else if(pTmpBssDesc->RecvSignalPower < pTestBssDesc->RecvSignalPower)
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("ODM_PathDiversityBeforeLink92C: Compare scan entry: Score--\n"));
- RT_PRINT_STR(COMP_SWAS, DBG_LOUD, "SSID: ", pTestBssDesc->bdSsIdBuf, pTestBssDesc->bdSsIdLen);
- RT_TRACE(COMP_SWAS, DBG_LOUD, ("Original: %d, Test: %d\n", pTmpBssDesc->RecvSignalPower, pTestBssDesc->RecvSignalPower));
- Score--;
- }
- }
- if(pMgntInfo->NumBssDesc!=0 && Score<=0)
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD,
- ("ODM_PathDiversityBeforeLink92C(): DefaultRespPath=%d\n", pDM_PDTable->DefaultRespPath));
- //pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- }
- else
- {
- RT_TRACE(COMP_SWAS, DBG_LOUD,
- ("ODM_PathDiversityBeforeLink92C(): DefaultRespPath=%d\n", pDM_PDTable->DefaultRespPath));
- if(pDM_PDTable->DefaultRespPath == 0)
- {
- pDM_PDTable->OFDMTXPath = 0xFFFFFFFF;
- pDM_PDTable->CCKTXPath = 0xFFFFFFFF;
- odm_SetRespPath_92C(Adapter, 1);
- }
- else
- {
- pDM_PDTable->OFDMTXPath = 0x0;
- pDM_PDTable->CCKTXPath = 0x0;
- odm_SetRespPath_92C(Adapter, 0);
- }
- PHY_SetBBReg(Adapter, rCCK0_AFESetting , 0x0F000000, 0x01); // RX path = PathAB
- //pDM_SWAT_Table->CurAntenna = pDM_SWAT_Table->PreAntenna;
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, DM_SWAT_Table.CurAntenna);
- //pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 = ((pDM_SWAT_Table->SWAS_NoLink_BK_Reg860 & 0xfffffcff) | (pDM_SWAT_Table->CurAntenna<<8));
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, bMaskDWord, pDM_SWAT_Table->SWAS_NoLink_BK_Reg860);
- }
- // Check state reset to default and wait for next time.
- //pDM_SWAT_Table->SWAS_NoLink_State = 0;
- pDM_PDTable->PathDiv_NoLink_State = 0;
- return FALSE;
- }
- #else
- return FALSE;
- #endif
-
- }
- //Neil Chen---2011--06--22
- //----92D Path Diversity----//
- //#ifdef PathDiv92D
- //==================================
- //3 Path Diversity
- //==================================
- //
- // 20100514 Luke/Joseph:
- // Add new function for antenna diversity after link.
- // This is the main function of antenna diversity after link.
- // This function is called in HalDmWatchDog() and ODM_SwAntDivChkAntSwitchCallback().
- // HalDmWatchDog() calls this function with SWAW_STEP_PEAK to initialize the antenna test.
- // In SWAW_STEP_PEAK, another antenna and a 500ms timer will be set for testing.
- // After 500ms, ODM_SwAntDivChkAntSwitchCallback() calls this function to compare the signal just
- // listened on the air with the RSSI of original antenna.
- // It chooses the antenna with better RSSI.
- // There is also a aged policy for error trying. Each error trying will cost more 5 seconds waiting
- // penalty to get next try.
- //
- //
- // 20100503 Joseph:
- // Add new function SwAntDivCheck8192C().
- // This is the main function of Antenna diversity function before link.
- // Mainly, it just retains last scan result and scan again.
- // After that, it compares the scan result to see which one gets better RSSI.
- // It selects antenna with better receiving power and returns better scan result.
- //
- //
- // 20100514 Luke/Joseph:
- // This function is used to gather the RSSI information for antenna testing.
- // It selects the RSSI of the peer STA that we want to know.
- //
- VOID
- ODM_PathDivChkPerPktRssi(
- PADAPTER Adapter,
- BOOLEAN bIsDefPort,
- BOOLEAN bMatchBSSID,
- PRT_WLAN_STA pEntry,
- PRT_RFD pRfd
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- BOOLEAN bCount = FALSE;
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- if(pHalData->RSSI_target==NULL && bIsDefPort && bMatchBSSID)
- bCount = TRUE;
- else if(pHalData->RSSI_target!=NULL && pEntry!=NULL && pHalData->RSSI_target==pEntry)
- bCount = TRUE;
- if(bCount)
- {
- //1 RSSI for SW Antenna Switch
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- pHalData->RSSI_sum_A += pRfd->Status.RxPWDBAll;
- pHalData->RSSI_cnt_A++;
- }
- else
- {
- pHalData->RSSI_sum_B += pRfd->Status.RxPWDBAll;
- pHalData->RSSI_cnt_B++;
- }
- }
- }
- //
- // 20100514 Luke/Joseph:
- // Add new function to reset antenna diversity state after link.
- //
- VOID
- ODM_PathDivRestAfterLink(
- IN PDM_ODM_T pDM_Odm
- )
- {
- PADAPTER Adapter=pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- pHalData->RSSI_cnt_A = 0;
- pHalData->RSSI_cnt_B = 0;
- pHalData->RSSI_test = FALSE;
- pDM_SWAT_Table->try_flag = 0x0; // NOT 0xff
- pDM_SWAT_Table->RSSI_Trying = 0;
- pDM_SWAT_Table->SelectAntennaMap=0xAA;
- pDM_SWAT_Table->CurAntenna = MAIN_ANT;
- }
- //
- // 20100514 Luke/Joseph:
- // Callback function for 500ms antenna test trying.
- //
- VOID
- odm_PathDivChkAntSwitchCallback(
- PRT_TIMER pTimer
- )
- {
- PADAPTER Adapter = (PADAPTER)pTimer->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- PlatformScheduleWorkItem(&pDM_Odm->PathDivSwitchWorkitem);
- #else
- odm_PathDivChkAntSwitch(pDM_Odm);
- #endif
- #else
- PlatformScheduleWorkItem(&pDM_Odm->PathDivSwitchWorkitem);
- #endif
- //odm_SwAntDivChkAntSwitch(Adapter, SWAW_STEP_DETERMINE);
- }
- VOID
- odm_PathDivChkAntSwitchWorkitemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER pAdapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- odm_PathDivChkAntSwitch(pDM_Odm);
- }
- //MAC0_ACCESS_PHY1
- // 2011-06-22 Neil Chen & Gary Hsin
- // Refer to Jr.Luke's SW ANT DIV
- // 92D Path Diversity Main function
- // refer to 88C software antenna diversity
- //
- VOID
- odm_PathDivChkAntSwitch(
- PDM_ODM_T pDM_Odm
- //PADAPTER Adapter,
- //u1Byte Step
- )
- {
- PADAPTER Adapter = pDM_Odm->Adapter;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PMGNT_INFO pMgntInfo = &Adapter->MgntInfo;
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- s4Byte curRSSI=100, RSSI_A, RSSI_B;
- u1Byte nextAntenna=AUX_ANT;
- static u8Byte lastTxOkCnt=0, lastRxOkCnt=0;
- u8Byte curTxOkCnt, curRxOkCnt;
- static u8Byte TXByteCnt_A=0, TXByteCnt_B=0, RXByteCnt_A=0, RXByteCnt_B=0;
- u8Byte CurByteCnt=0, PreByteCnt=0;
- static u1Byte TrafficLoad = TRAFFIC_LOW;
- u1Byte Score_A=0, Score_B=0;
- u1Byte i=0x0;
- // Neil Chen
- static u1Byte pathdiv_para=0x0;
- static u1Byte switchfirsttime=0x00;
- // u1Byte regB33 = (u1Byte) PHY_QueryBBReg(Adapter, 0xB30,BIT27);
- u1Byte regB33 = (u1Byte)ODM_GetBBReg(pDM_Odm, PATHDIV_REG, BIT27);
- //u1Byte reg637 =0x0;
- static u1Byte fw_value=0x0;
- //u8Byte curTxOkCnt_tmp, curRxOkCnt_tmp;
- PADAPTER BuddyAdapter = Adapter->BuddyAdapter; // another adapter MAC
- // Path Diversity //Neil Chen--2011--06--22
- //u1Byte PathDiv_Trigger = (u1Byte) PHY_QueryBBReg(Adapter, 0xBA0,BIT31);
- u1Byte PathDiv_Trigger = (u1Byte) ODM_GetBBReg(pDM_Odm, PATHDIV_TRI,BIT31);
- u1Byte PathDiv_Enable = pHalData->bPathDiv_Enable;
- //DbgPrint("Path Div PG Value:%x \n",PathDiv_Enable);
- if((BuddyAdapter==NULL)||(!PathDiv_Enable)||(PathDiv_Trigger)||(pHalData->CurrentBandType == BAND_ON_2_4G))
- {
- return;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD,("===================>odm_PathDivChkAntSwitch()\n"));
- // The first time to switch path excluding 2nd, 3rd, ....etc....
- if(switchfirsttime==0)
- {
- if(regB33==0)
- {
- pDM_SWAT_Table->CurAntenna = MAIN_ANT; // Default MAC0_5G-->Path A (current antenna)
- }
- }
- // Condition that does not need to use antenna diversity.
- if(pDM_Odm->SupportICType != ODM_RTL8192D)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("odm_PathDiversityMechanims(): No PathDiv Mechanism.\n"));
- return;
- }
- // Radio off: Status reset to default and return.
- if(pHalData->eRFPowerState==eRfOff)
- {
- //ODM_SwAntDivRestAfterLink(Adapter);
- return;
- }
- /*
- // Handling step mismatch condition.
- // Peak step is not finished at last time. Recover the variable and check again.
- if( Step != pDM_SWAT_Table->try_flag )
- {
- ODM_SwAntDivRestAfterLink(Adapter);
- } */
-
- if(pDM_SWAT_Table->try_flag == 0xff)
- {
- // Select RSSI checking target
- if(pMgntInfo->mAssoc && !ACTING_AS_AP(Adapter))
- {
- // Target: Infrastructure mode AP.
- pHalData->RSSI_target = NULL;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("odm_PathDivMechanism(): RSSI_target is DEF AP!\n"));
- }
- else
- {
- u1Byte index = 0;
- PRT_WLAN_STA pEntry = NULL;
- PADAPTER pTargetAdapter = NULL;
-
- if( pMgntInfo->mIbss || ACTING_AS_AP(Adapter) )
- {
- // Target: AP/IBSS peer.
- pTargetAdapter = Adapter;
- }
- else if(IsAPModeExist(Adapter) && GetFirstExtAdapter(Adapter) != NULL)
- {
- // Target: VWIFI peer.
- pTargetAdapter = GetFirstExtAdapter(Adapter);
- }
- if(pTargetAdapter != NULL)
- {
- for(index=0; index<ODM_ASSOCIATE_ENTRY_NUM; index++)
- {
- pEntry = AsocEntry_EnumStation(pTargetAdapter, index);
- if(pEntry != NULL)
- {
- if(pEntry->bAssociated)
- break;
- }
- }
- }
- if(pEntry == NULL)
- {
- ODM_PathDivRestAfterLink(pDM_Odm);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): No Link.\n"));
- return;
- }
- else
- {
- pHalData->RSSI_target = pEntry;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): RSSI_target is PEER STA\n"));
- }
- }
-
- pHalData->RSSI_cnt_A = 0;
- pHalData->RSSI_cnt_B = 0;
- pDM_SWAT_Table->try_flag = 0;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("odm_SwAntDivChkAntSwitch(): Set try_flag to 0 prepare for peak!\n"));
- return;
- }
- else
- {
- // 1st step
- curTxOkCnt = Adapter->TxStats.NumTxBytesUnicast - lastTxOkCnt;
- curRxOkCnt = Adapter->RxStats.NumRxBytesUnicast - lastRxOkCnt;
- lastTxOkCnt = Adapter->TxStats.NumTxBytesUnicast;
- lastRxOkCnt = Adapter->RxStats.NumRxBytesUnicast;
-
- if(pDM_SWAT_Table->try_flag == 1) // Training State
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- TXByteCnt_A += curTxOkCnt;
- RXByteCnt_A += curRxOkCnt;
- }
- else
- {
- TXByteCnt_B += curTxOkCnt;
- RXByteCnt_B += curRxOkCnt;
- }
-
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? AUX_ANT : MAIN_ANT;
- pDM_SWAT_Table->RSSI_Trying--;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: RSSI_Trying = %d\n",pDM_SWAT_Table->RSSI_Trying));
- if(pDM_SWAT_Table->RSSI_Trying == 0)
- {
- CurByteCnt = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? (TXByteCnt_A+RXByteCnt_A) : (TXByteCnt_B+RXByteCnt_B);
- PreByteCnt = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? (TXByteCnt_B+RXByteCnt_B) : (TXByteCnt_A+RXByteCnt_A);
-
- if(TrafficLoad == TRAFFIC_HIGH)
- {
- //CurByteCnt = PlatformDivision64(CurByteCnt, 9);
- PreByteCnt =PreByteCnt*9;
- }
- else if(TrafficLoad == TRAFFIC_LOW)
- {
- //CurByteCnt = PlatformDivision64(CurByteCnt, 2);
- PreByteCnt =PreByteCnt*2;
- }
- if(pHalData->RSSI_cnt_A > 0)
- RSSI_A = pHalData->RSSI_sum_A/pHalData->RSSI_cnt_A;
- else
- RSSI_A = 0;
- if(pHalData->RSSI_cnt_B > 0)
- RSSI_B = pHalData->RSSI_sum_B/pHalData->RSSI_cnt_B;
- else
- RSSI_B = 0;
- curRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_B : RSSI_A;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: PreRSSI = %d, CurRSSI = %d\n",pDM_SWAT_Table->PreRSSI, curRSSI));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: preAntenna= %s, curAntenna= %s \n",
- (pDM_SWAT_Table->PreAntenna == MAIN_ANT?"MAIN":"AUX"), (pDM_SWAT_Table->CurAntenna == MAIN_ANT?"MAIN":"AUX")));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
- RSSI_A, pHalData->RSSI_cnt_A, RSSI_B, pHalData->RSSI_cnt_B));
- }
- }
- else // try_flag=0
- {
-
- if(pHalData->RSSI_cnt_A > 0)
- RSSI_A = pHalData->RSSI_sum_A/pHalData->RSSI_cnt_A;
- else
- RSSI_A = 0;
- if(pHalData->RSSI_cnt_B > 0)
- RSSI_B = pHalData->RSSI_sum_B/pHalData->RSSI_cnt_B;
- else
- RSSI_B = 0;
- curRSSI = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- pDM_SWAT_Table->PreRSSI = (pDM_SWAT_Table->PreAntenna == MAIN_ANT)? RSSI_A : RSSI_B;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: PreRSSI = %d, CurRSSI = %d\n", pDM_SWAT_Table->PreRSSI, curRSSI));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: preAntenna= %s, curAntenna= %s \n",
- (pDM_SWAT_Table->PreAntenna == MAIN_ANT?"MAIN":"AUX"), (pDM_SWAT_Table->CurAntenna == MAIN_ANT?"MAIN":"AUX")));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH DIV=: RSSI_A= %d, RSSI_cnt_A = %d, RSSI_B= %d, RSSI_cnt_B = %d\n",
- RSSI_A, pHalData->RSSI_cnt_A, RSSI_B, pHalData->RSSI_cnt_B));
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curTxOkCnt = %d\n", curTxOkCnt));
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Ekul:curRxOkCnt = %d\n", curRxOkCnt));
- }
- //1 Trying State
- if((pDM_SWAT_Table->try_flag == 1)&&(pDM_SWAT_Table->RSSI_Trying == 0))
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: TestMode = TP_MODE"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH= TRY:CurByteCnt = %"i64fmt"d,", CurByteCnt));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH= TRY:PreByteCnt = %"i64fmt"d\n",PreByteCnt));
- if(CurByteCnt < PreByteCnt)
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
- else
- pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
- }
- else
- {
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- pDM_SWAT_Table->SelectAntennaMap=(pDM_SWAT_Table->SelectAntennaMap<<1)+1;
- else
- pDM_SWAT_Table->SelectAntennaMap=pDM_SWAT_Table->SelectAntennaMap<<1;
- }
- for (i= 0; i<8; i++)
- {
- if(((pDM_SWAT_Table->SelectAntennaMap>>i)&BIT0) == 1)
- Score_A++;
- else
- Score_B++;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("SelectAntennaMap=%x\n ",pDM_SWAT_Table->SelectAntennaMap));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Score_A=%d, Score_B=%d\n", Score_A, Score_B));
-
- if(pDM_SWAT_Table->CurAntenna == MAIN_ANT)
- {
- nextAntenna = (Score_A >= Score_B)?MAIN_ANT:AUX_ANT;
- }
- else
- {
- nextAntenna = (Score_B >= Score_A)?AUX_ANT:MAIN_ANT;
- }
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: nextAntenna=%s\n",(nextAntenna==MAIN_ANT)?"MAIN":"AUX"));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: preAntenna= %s, curAntenna= %s \n",
- (pDM_SWAT_Table->PreAntenna == MAIN_ANT?"MAIN":"AUX"), (pDM_SWAT_Table->CurAntenna == MAIN_ANT?"MAIN":"AUX")));
- if(nextAntenna != pDM_SWAT_Table->CurAntenna)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Switch back to another antenna"));
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: current anntena is good\n"));
- }
- }
-
- if(pDM_SWAT_Table->TestMode == RSSI_MODE)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: TestMode = RSSI_MODE"));
- pDM_SWAT_Table->SelectAntennaMap=0xAA;
- if(curRSSI < pDM_SWAT_Table->PreRSSI) //Current antenna is worse than previous antenna
- {
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Switch back to another antenna"));
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)?AUX_ANT : MAIN_ANT;
- }
- else // current anntena is good
- {
- nextAntenna =pDM_SWAT_Table->CurAntenna;
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: current anntena is good\n"));
- }
- }
-
- pDM_SWAT_Table->try_flag = 0;
- pHalData->RSSI_test = FALSE;
- pHalData->RSSI_sum_A = 0;
- pHalData->RSSI_cnt_A = 0;
- pHalData->RSSI_sum_B = 0;
- pHalData->RSSI_cnt_B = 0;
- TXByteCnt_A = 0;
- TXByteCnt_B = 0;
- RXByteCnt_A = 0;
- RXByteCnt_B = 0;
-
- }
- //1 Normal State
- else if(pDM_SWAT_Table->try_flag == 0)
- {
- if(TrafficLoad == TRAFFIC_HIGH)
- {
- if ((curTxOkCnt+curRxOkCnt) > 3750000)//if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
- TrafficLoad = TRAFFIC_HIGH;
- else
- TrafficLoad = TRAFFIC_LOW;
- }
- else if(TrafficLoad == TRAFFIC_LOW)
- {
- if ((curTxOkCnt+curRxOkCnt) > 3750000)//if(PlatformDivision64(curTxOkCnt+curRxOkCnt, 2) > 1875000)
- TrafficLoad = TRAFFIC_HIGH;
- else
- TrafficLoad = TRAFFIC_LOW;
- }
- if(TrafficLoad == TRAFFIC_HIGH)
- pDM_SWAT_Table->bTriggerAntennaSwitch = 0;
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("Normal:TrafficLoad = %llu\n", curTxOkCnt+curRxOkCnt));
- //Prepare To Try Antenna
- nextAntenna = (pDM_SWAT_Table->CurAntenna == MAIN_ANT)? AUX_ANT : MAIN_ANT;
- pDM_SWAT_Table->try_flag = 1;
- pHalData->RSSI_test = TRUE;
- if((curRxOkCnt+curTxOkCnt) > 1000)
- {
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- pDM_SWAT_Table->RSSI_Trying = 4;
- #else
- pDM_SWAT_Table->RSSI_Trying = 2;
- #endif
- pDM_SWAT_Table->TestMode = TP_MODE;
- }
- else
- {
- pDM_SWAT_Table->RSSI_Trying = 2;
- pDM_SWAT_Table->TestMode = RSSI_MODE;
- }
-
- //RT_TRACE(COMP_SWAS, DBG_LOUD, ("SWAS: Normal State -> Begin Trying!\n"));
- pHalData->RSSI_sum_A = 0;
- pHalData->RSSI_cnt_A = 0;
- pHalData->RSSI_sum_B = 0;
- pHalData->RSSI_cnt_B = 0;
- } // end of try_flag=0
- }
-
- //1 4.Change TRX antenna
- if(nextAntenna != pDM_SWAT_Table->CurAntenna)
- {
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Change TX Antenna!\n "));
- //PHY_SetBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300, nextAntenna); for 88C
- if(nextAntenna==MAIN_ANT)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Next Antenna is RF PATH A\n "));
- pathdiv_para = 0x02; //02 to switchback to RF path A
- fw_value = 0x03;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- odm_PathDiversity_8192D(pDM_Odm, pathdiv_para);
- #else
- ODM_FillH2CCmd(Adapter, ODM_H2C_PathDiv,1,(pu1Byte)(&fw_value));
- #endif
- }
- else if(nextAntenna==AUX_ANT)
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Next Antenna is RF PATH B\n "));
- if(switchfirsttime==0) // First Time To Enter Path Diversity
- {
- switchfirsttime=0x01;
- pathdiv_para = 0x00;
- fw_value=0x00; // to backup RF Path A Releated Registers
-
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- odm_PathDiversity_8192D(pDM_Odm, pathdiv_para);
- #else
- ODM_FillH2CCmd(Adapter, ODM_H2C_PathDiv,1,(pu1Byte)(&fw_value));
- //for(u1Byte n=0; n<80,n++)
- //{
- //delay_us(500);
- ODM_delay_ms(500);
- odm_PathDiversity_8192D(pDM_Odm, pathdiv_para);
-
- fw_value=0x01; // to backup RF Path A Releated Registers
- ODM_FillH2CCmd(Adapter, ODM_H2C_PathDiv,1,(pu1Byte)(&fw_value));
- #endif
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: FIRST TIME To DO PATH SWITCH!\n "));
- }
- else
- {
- pathdiv_para = 0x01;
- fw_value = 0x02;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- odm_PathDiversity_8192D(pDM_Odm, pathdiv_para);
- #else
- ODM_FillH2CCmd(Adapter, ODM_H2C_PathDiv,1,(pu1Byte)(&fw_value));
- #endif
- }
- }
- // odm_PathDiversity_8192D(Adapter, pathdiv_para);
- }
- //1 5.Reset Statistics
- pDM_SWAT_Table->PreAntenna = pDM_SWAT_Table->CurAntenna;
- pDM_SWAT_Table->CurAntenna = nextAntenna;
- pDM_SWAT_Table->PreRSSI = curRSSI;
-
- //1 6.Set next timer
- if(pDM_SWAT_Table->RSSI_Trying == 0)
- return;
- if(pDM_SWAT_Table->RSSI_Trying%2 == 0)
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- if(TrafficLoad == TRAFFIC_HIGH)
- {
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 10 ); //ms
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Test another antenna for 10 ms\n"));
- #else
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 20 ); //ms
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Test another antenna for 20 ms\n"));
- #endif
- }
- else if(TrafficLoad == TRAFFIC_LOW)
- {
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 50 ); //ms
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Test another antenna for 50 ms\n"));
- }
- }
- else // TestMode == RSSI_MODE
- {
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 500 ); //ms
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Test another antenna for 500 ms\n"));
- }
- }
- else
- {
- if(pDM_SWAT_Table->TestMode == TP_MODE)
- {
- if(TrafficLoad == TRAFFIC_HIGH)
-
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 90 ); //ms
- //ODM_RT_TRACE(pDM_Odm,ODM_COMP_PATH_DIV, ODM_DBG_LOUD, ("=PATH=: Test another antenna for 90 ms\n"));
- #else
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 180); //ms
- #endif
- else if(TrafficLoad == TRAFFIC_LOW)
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 100 ); //ms
- }
- else
- ODM_SetTimer( pDM_Odm, &pDM_Odm->PathDivSwitchTimer, 500 ); //ms
- }
- }
- //==================================================
- //3 PathDiv End
- //==================================================
- VOID
- odm_SetRespPath_92C(
- IN PADAPTER Adapter,
- IN u1Byte DefaultRespPath
- )
- {
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- RT_TRACE( COMP_SWAS, DBG_LOUD, ("odm_SetRespPath_92C: Select Response Path=%d\n",DefaultRespPath));
- if(DefaultRespPath != pDM_PDTable->DefaultRespPath)
- {
- if(DefaultRespPath == 0)
- {
- PlatformEFIOWrite1Byte(Adapter, 0x6D8, (PlatformEFIORead1Byte(Adapter, 0x6D8)&0xc0)|0x15);
- }
- else
- {
- PlatformEFIOWrite1Byte(Adapter, 0x6D8, (PlatformEFIORead1Byte(Adapter, 0x6D8)&0xc0)|0x2A);
- }
- }
- pDM_PDTable->DefaultRespPath = DefaultRespPath;
- }
- VOID
- ODM_FillTXPathInTXDESC(
- IN PADAPTER Adapter,
- IN PRT_TCB pTcb,
- IN pu1Byte pDesc
- )
- {
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- u4Byte TXPath;
- pPD_T pDM_PDTable = &Adapter->DM_PDTable;
- //2011.09.05 Add by Luke Lee for path diversity
- if(pHalData->PathDivCfg == 1)
- {
- TXPath = (pDM_PDTable->OFDMTXPath >> pTcb->macId) & BIT0;
- //RT_TRACE( COMP_SWAS, DBG_LOUD, ("Fill TXDESC: macID=%d, TXPath=%d\n", pTcb->macId, TXPath));
- //SET_TX_DESC_TX_ANT_CCK(pDesc,TXPath);
- if(TXPath == 0)
- {
- SET_TX_DESC_TX_ANTL_92C(pDesc,1);
- SET_TX_DESC_TX_ANT_HT_92C(pDesc,1);
- }
- else
- {
- SET_TX_DESC_TX_ANTL_92C(pDesc,2);
- SET_TX_DESC_TX_ANT_HT_92C(pDesc,2);
- }
- TXPath = (pDM_PDTable->CCKTXPath >> pTcb->macId) & BIT0;
- if(TXPath == 0)
- {
- SET_TX_DESC_TX_ANT_CCK_92C(pDesc,1);
- }
- else
- {
- SET_TX_DESC_TX_ANT_CCK_92C(pDesc,2);
- }
- }
- }
- //Only for MP //Neil Chen--2012--0502--
- VOID
- odm_PathDivInit_92D(
- IN PDM_ODM_T pDM_Odm)
- {
- pPATHDIV_PARA pathIQK = &pDM_Odm->pathIQK;
- pathIQK->org_2g_RegC14=0x0;
- pathIQK->org_2g_RegC4C=0x0;
- pathIQK->org_2g_RegC80=0x0;
- pathIQK->org_2g_RegC94=0x0;
- pathIQK->org_2g_RegCA0=0x0;
- pathIQK->org_5g_RegC14=0x0;
- pathIQK->org_5g_RegCA0=0x0;
- pathIQK->org_5g_RegE30=0x0;
- pathIQK->swt_2g_RegC14=0x0;
- pathIQK->swt_2g_RegC4C=0x0;
- pathIQK->swt_2g_RegC80=0x0;
- pathIQK->swt_2g_RegC94=0x0;
- pathIQK->swt_2g_RegCA0=0x0;
- pathIQK->swt_5g_RegC14=0x0;
- pathIQK->swt_5g_RegCA0=0x0;
- pathIQK->swt_5g_RegE30=0x0;
- }
- #endif // #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN| ODM_CE))
- VOID
- odm_PHY_SaveAFERegisters(
- IN PDM_ODM_T pDM_Odm,
- IN pu4Byte AFEReg,
- IN pu4Byte AFEBackup,
- IN u4Byte RegisterNum
- )
- {
- u4Byte i;
-
- //RT_DISP(FINIT, INIT_IQK, ("Save ADDA parameters.\n"));
- for( i = 0 ; i < RegisterNum ; i++){
- AFEBackup[i] = ODM_GetBBReg(pDM_Odm, AFEReg[i], bMaskDWord);
- }
- }
- VOID
- odm_PHY_ReloadAFERegisters(
- IN PDM_ODM_T pDM_Odm,
- IN pu4Byte AFEReg,
- IN pu4Byte AFEBackup,
- IN u4Byte RegiesterNum
- )
- {
- u4Byte i;
- //RT_DISP(FINIT, INIT_IQK, ("Reload ADDA power saving parameters !\n"));
- for(i = 0 ; i < RegiesterNum; i++)
- {
-
- ODM_SetBBReg(pDM_Odm, AFEReg[i], bMaskDWord, AFEBackup[i]);
- }
- }
- //
- // Description:
- // Set Single/Dual Antenna default setting for products that do not do detection in advance.
- //
- // Added by Joseph, 2012.03.22
- //
- VOID
- ODM_SingleDualAntennaDefaultSetting(
- IN PDM_ODM_T pDM_Odm
- )
- {
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- pDM_SWAT_Table->ANTA_ON=TRUE;
- pDM_SWAT_Table->ANTB_ON=TRUE;
- }
- //2 8723A ANT DETECT
- //
- // Description:
- // Implement IQK single tone for RF DPK loopback and BB PSD scanning.
- // This function is cooperated with BB team Neil.
- //
- // Added by Roger, 2011.12.15
- //
- BOOLEAN
- ODM_SingleDualAntennaDetection(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte mode
- )
- {
- PADAPTER pAdapter = pDM_Odm->Adapter;
- pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
- u4Byte CurrentChannel,RfLoopReg;
- u1Byte n;
- u4Byte Reg88c, Regc08, Reg874, Regc50;
- u1Byte initial_gain = 0x5a;
- u4Byte PSD_report_tmp;
- u4Byte AntA_report = 0x0, AntB_report = 0x0,AntO_report=0x0;
- BOOLEAN bResult = TRUE;
- BOOLEAN bAntDetection = FALSE;
- u4Byte AFE_Backup[16];
- u4Byte AFE_REG_8723A[16] = {
- rRx_Wait_CCA, rTx_CCK_RFON,
- rTx_CCK_BBON, rTx_OFDM_RFON,
- rTx_OFDM_BBON, rTx_To_Rx,
- rTx_To_Tx, rRx_CCK,
- rRx_OFDM, rRx_Wait_RIFS,
- rRx_TO_Rx, rStandby,
- rSleep, rPMPD_ANAEN,
- rFPGA0_XCD_SwitchControl, rBlue_Tooth};
- // Retrieve antenna detection registry info, added by Roger, 2012.11.27.
- pAdapter->HalFunc.GetHalDefVarHandler(pAdapter, HAL_DEF_ANT_DETECT, &bAntDetection);
-
- if(!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8192C)))
- return bResult;
- if(!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV) && !bAntDetection)
- return bResult;
- if(pDM_Odm->SupportICType == ODM_RTL8192C)
- {
- //Which path in ADC/DAC is turnned on for PSD: both I/Q
- ODM_SetBBReg(pDM_Odm, 0x808, BIT10|BIT11, 0x3);
- //Ageraged number: 8
- ODM_SetBBReg(pDM_Odm, 0x808, BIT12|BIT13, 0x1);
- //pts = 128;
- ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0);
- }
- //1 Backup Current RF/BB Settings
-
- CurrentChannel = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask);
- RfLoopReg = ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x00, bRFRegOffsetMask);
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, ODM_DPDT, Antenna_A); // change to Antenna A
- // Step 1: USE IQK to transmitter single tone
- ODM_StallExecution(10);
-
- //Store A Path Register 88c, c08, 874, c50
- Reg88c = ODM_GetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord);
- Regc08 = ODM_GetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord);
- Reg874 = ODM_GetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord);
- Regc50 = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord);
-
- // Store AFE Registers
- odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16);
-
- //Set PSD 128 pts
- ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); //128 pts
-
- // To SET CH1 to do
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x7401); //Channel 1
-
- // AFE all on step
- ODM_SetBBReg(pDM_Odm, rRx_Wait_CCA, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_CCK_RFON, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_CCK_BBON, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_OFDM_RFON, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_OFDM_BBON, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_To_Rx, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rTx_To_Tx, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rRx_CCK, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rRx_OFDM, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rRx_Wait_RIFS, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rRx_TO_Rx, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rStandby, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rSleep, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rPMPD_ANAEN, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_SwitchControl, bMaskDWord, 0x6FDB25A4);
- ODM_SetBBReg(pDM_Odm, rBlue_Tooth, bMaskDWord, 0x6FDB25A4);
- // 3 wire Disable
- ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, 0xCCF000C0);
-
- //BB IQK Setting
- ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800E4);
- ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22208000);
- //IQK setting tone@ 4.34Mhz
- ODM_SetBBReg(pDM_Odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008C1C);
- ODM_SetBBReg(pDM_Odm, rTx_IQK, bMaskDWord, 0x01007c00);
- //Page B init
- ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x00080000);
- ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x0f600000);
- ODM_SetBBReg(pDM_Odm, rRx_IQK, bMaskDWord, 0x01004800);
- ODM_SetBBReg(pDM_Odm, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f);
- ODM_SetBBReg(pDM_Odm, rTx_IQK_PI_A, bMaskDWord, 0x82150008);
- ODM_SetBBReg(pDM_Odm, rRx_IQK_PI_A, bMaskDWord, 0x28150008);
- ODM_SetBBReg(pDM_Odm, rIQK_AGC_Rsp, bMaskDWord, 0x001028d0);
- //RF loop Setting
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x0, 0xFFFFF, 0x50008);
-
- //IQK Single tone start
- ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x80800000);
- ODM_SetBBReg(pDM_Odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000);
- ODM_StallExecution(10000);
- PSD_report_tmp=0x0;
- for (n=0;n<2;n++)
- {
- PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain);
- if(PSD_report_tmp >AntA_report)
- AntA_report=PSD_report_tmp;
- }
- PSD_report_tmp=0x0;
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); // change to Antenna B
- ODM_StallExecution(10);
-
- for (n=0;n<2;n++)
- {
- PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain);
- if(PSD_report_tmp > AntB_report)
- AntB_report=PSD_report_tmp;
- }
- // change to open case
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, 0); // change to Ant A and B all open case
- ODM_StallExecution(10);
-
- for (n=0;n<2;n++)
- {
- PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain);
- if(PSD_report_tmp > AntO_report)
- AntO_report=PSD_report_tmp;
- }
- //Close IQK Single Tone function
- ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x00000000);
- PSD_report_tmp = 0x0;
- //1 Return to antanna A
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A);
- ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, Reg88c);
- ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, Regc08);
- ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, Reg874);
- ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, 0x7F, 0x40);
- ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord, Regc50);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask,CurrentChannel);
- ODM_SetRFReg(pDM_Odm, ODM_RF_PATH_A, 0x00, bRFRegOffsetMask,RfLoopReg);
- //Reload AFE Registers
- odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16);
- //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d \n", 2416, AntA_report));
- //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d \n", 2416, AntB_report));
- //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d \n", 2416, AntO_report));
- if(pDM_Odm->SupportICType == ODM_RTL8723A)
- {
- //2 Test Ant B based on Ant A is ON
- if(mode==ANTTESTB)
- {
- if(AntA_report >= 100)
- {
- if(AntB_report > (AntA_report+1))
- {
- pDM_SWAT_Table->ANTB_ON=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n"));
- }
- else
- {
- pDM_SWAT_Table->ANTB_ON=TRUE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n"));
- }
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n"));
- pDM_SWAT_Table->ANTB_ON=FALSE; // Set Antenna B off as default
- bResult = FALSE;
- }
- }
- //2 Test Ant A and B based on DPDT Open
- else if(mode==ANTTESTALL)
- {
- if((AntO_report >=100) && (AntO_report <=118))
- {
- if(AntA_report > (AntO_report+1))
- {
- pDM_SWAT_Table->ANTA_ON=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("Ant A is OFF\n"));
- }
- else
- {
- pDM_SWAT_Table->ANTA_ON=TRUE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("Ant A is ON\n"));
- }
- if(AntB_report > (AntO_report+2))
- {
- pDM_SWAT_Table->ANTB_ON=FALSE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("Ant B is OFF\n"));
- }
- else
- {
- pDM_SWAT_Table->ANTB_ON=TRUE;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("Ant B is ON\n"));
- }
-
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d \n", 2416, AntA_report));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d \n", 2416, AntB_report));
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d \n", 2416, AntO_report));
-
- pDM_Odm->AntDetectedInfo.bAntDetected= TRUE;
- pDM_Odm->AntDetectedInfo.dBForAntA = AntA_report;
- pDM_Odm->AntDetectedInfo.dBForAntB = AntB_report;
- pDM_Odm->AntDetectedInfo.dBForAntO = AntO_report;
-
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("return FALSE!!\n"));
- bResult = FALSE;
- }
- }
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8192C)
- {
- if(AntA_report >= 100)
- {
- if(AntB_report > (AntA_report+2))
- {
- pDM_SWAT_Table->ANTA_ON=FALSE;
- pDM_SWAT_Table->ANTB_ON=TRUE;
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna B\n"));
- }
- else if(AntA_report > (AntB_report+2))
- {
- pDM_SWAT_Table->ANTA_ON=TRUE;
- pDM_SWAT_Table->ANTB_ON=FALSE;
- ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A);
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n"));
- }
- else
- {
- pDM_SWAT_Table->ANTA_ON=TRUE;
- pDM_SWAT_Table->ANTB_ON=TRUE;
- RT_TRACE(COMP_ANTENNA, DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna \n"));
- }
- }
- else
- {
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n"));
- pDM_SWAT_Table->ANTA_ON=TRUE; // Set Antenna A on as default
- pDM_SWAT_Table->ANTB_ON=FALSE; // Set Antenna B off as default
- bResult = FALSE;
- }
- }
- return bResult;
- }
- #endif // end odm_CE
- #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
- VOID
- ODM_UpdateInitRate(
- IN PDM_ODM_T pDM_Odm,
- IN u1Byte Rate
- )
- {
- u1Byte p = 0;
- ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Get C2H Command! Rate=0x%x\n", Rate));
-
- if(pDM_Odm->SupportICType == ODM_RTL8821 || pDM_Odm->SupportICType == ODM_RTL8812)
- {
- pDM_Odm->TxRate = Rate;
- #if DEV_BUS_TYPE==RT_PCI_INTERFACE
- #if USE_WORKITEM
- PlatformScheduleWorkItem(&pDM_Odm->RaRptWorkitem);
- #else
- if(pDM_Odm->SupportICType == ODM_RTL8821)
- {
- ODM_TxPwrTrackSetPwr8821A(pDM_Odm, MIX_MODE, ODM_RF_PATH_A, 0);
- }
- else
- {
- for (p = ODM_RF_PATH_A; p < 2; p++)
- {
- ODM_TxPwrTrackSetPwr8812A(pDM_Odm, BBSWING, p, 0);
- }
- }
- #endif
- #else
- PlatformScheduleWorkItem(&pDM_Odm->RaRptWorkitem);
- #endif
- }
- else
- return;
- }
- VOID
- ODM_UpdateInitRateWorkItemCallback(
- IN PVOID pContext
- )
- {
- PADAPTER Adapter = (PADAPTER)pContext;
- HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
- PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc;
- u1Byte p = 0;
- if(pDM_Odm->SupportICType == ODM_RTL8821)
- {
- ODM_TxPwrTrackSetPwr8821A(pDM_Odm, MIX_MODE, ODM_RF_PATH_A, 0);
- }
- else if(pDM_Odm->SupportICType == ODM_RTL8812)
- {
- for (p = ODM_RF_PATH_A; p < 2; p++) //DOn't know how to include &c
- {
- ODM_TxPwrTrackSetPwr8812A(pDM_Odm, BBSWING, p, 0);
- }
- }
-
- }
- #endif
- #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
- /* Justin: According to the current RRSI to adjust Response Frame TX power, 2012/11/05 */
- void odm_dtc(PDM_ODM_T pDM_Odm)
- {
- #ifdef CONFIG_DM_RESP_TXAGC
- #define DTC_BASE 35 /* RSSI higher than this value, start to decade TX power */
- #define DTC_DWN_BASE (DTC_BASE-5) /* RSSI lower than this value, start to increase TX power */
- /* RSSI vs TX power step mapping: decade TX power */
- static const u8 dtc_table_down[]={
- DTC_BASE,
- (DTC_BASE+5),
- (DTC_BASE+10),
- (DTC_BASE+15),
- (DTC_BASE+20),
- (DTC_BASE+25)
- };
- /* RSSI vs TX power step mapping: increase TX power */
- static const u8 dtc_table_up[]={
- DTC_DWN_BASE,
- (DTC_DWN_BASE-5),
- (DTC_DWN_BASE-10),
- (DTC_DWN_BASE-15),
- (DTC_DWN_BASE-15),
- (DTC_DWN_BASE-20),
- (DTC_DWN_BASE-20),
- (DTC_DWN_BASE-25),
- (DTC_DWN_BASE-25),
- (DTC_DWN_BASE-30),
- (DTC_DWN_BASE-35)
- };
- u8 i;
- u8 dtc_steps=0;
- u8 sign;
- u8 resp_txagc=0;
- #if 0
- /* As DIG is disabled, DTC is also disable */
- if(!(pDM_Odm->SupportAbility & ODM_XXXXXX))
- return;
- #endif
- if (DTC_BASE < pDM_Odm->RSSI_Min) {
- /* need to decade the CTS TX power */
- sign = 1;
- for (i=0;i<ARRAY_SIZE(dtc_table_down);i++)
- {
- if ((dtc_table_down[i] >= pDM_Odm->RSSI_Min) || (dtc_steps >= 6))
- break;
- else
- dtc_steps++;
- }
- }
- #if 0
- else if (DTC_DWN_BASE > pDM_Odm->RSSI_Min)
- {
- /* needs to increase the CTS TX power */
- sign = 0;
- dtc_steps = 1;
- for (i=0;i<ARRAY_SIZE(dtc_table_up);i++)
- {
- if ((dtc_table_up[i] <= pDM_Odm->RSSI_Min) || (dtc_steps>=10))
- break;
- else
- dtc_steps++;
- }
- }
- #endif
- else
- {
- sign = 0;
- dtc_steps = 0;
- }
- resp_txagc = dtc_steps | (sign << 4);
- resp_txagc = resp_txagc | (resp_txagc << 5);
- ODM_Write1Byte(pDM_Odm, 0x06d9, resp_txagc);
- DBG_871X("%s RSSI_Min:%u, set RESP_TXAGC to %s %u\n",
- __func__, pDM_Odm->RSSI_Min, sign?"minus":"plus", dtc_steps);
- #endif /* CONFIG_RESP_TXAGC_ADJUST */
- }
- #endif /* #if (DM_ODM_SUPPORT_TYPE == ODM_CE) */
|