odm_HWConfig.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. //============================================================
  21. // include files
  22. //============================================================
  23. #include "odm_precomp.h"
  24. #define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm))
  25. #define READ_AND_CONFIG_TC(ic, txt) (ODM_ReadAndConfig_TC_##ic##txt(pDM_Odm))
  26. #if (TEST_CHIP_SUPPORT == 1)
  27. #define READ_AND_CONFIG(ic, txt) do {\
  28. if (pDM_Odm->bIsMPChip)\
  29. READ_AND_CONFIG_MP(ic,txt);\
  30. else\
  31. READ_AND_CONFIG_TC(ic,txt);\
  32. } while(0)
  33. #else
  34. #define READ_AND_CONFIG READ_AND_CONFIG_MP
  35. #endif
  36. #define READ_FIRMWARE_MP(ic, txt) (ODM_ReadFirmware_MP_##ic##txt(pDM_Odm, pFirmware, pSize))
  37. #define READ_FIRMWARE_TC(ic, txt) (ODM_ReadFirmware_TC_##ic##txt(pDM_Odm, pFirmware, pSize))
  38. #if (TEST_CHIP_SUPPORT == 1)
  39. #define READ_FIRMWARE(ic, txt) do {\
  40. if (pDM_Odm->bIsMPChip)\
  41. READ_FIRMWARE_MP(ic,txt);\
  42. else\
  43. READ_FIRMWARE_TC(ic,txt);\
  44. } while(0)
  45. #else
  46. #define READ_FIRMWARE READ_FIRMWARE_MP
  47. #endif
  48. u1Byte
  49. odm_QueryRxPwrPercentage(
  50. IN s1Byte AntPower
  51. )
  52. {
  53. if ((AntPower <= -100) || (AntPower >= 20))
  54. {
  55. return 0;
  56. }
  57. else if (AntPower >= 0)
  58. {
  59. return 100;
  60. }
  61. else
  62. {
  63. return (100+AntPower);
  64. }
  65. }
  66. #if (DM_ODM_SUPPORT_TYPE != ODM_WIN)
  67. //
  68. // 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer.
  69. // IF other SW team do not support the feature, remove this section.??
  70. //
  71. s4Byte
  72. odm_SignalScaleMapping_92CSeries_patch_RT_CID_819x_Lenovo(
  73. IN OUT PDM_ODM_T pDM_Odm,
  74. s4Byte CurrSig
  75. )
  76. {
  77. s4Byte RetSig;
  78. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  79. //if(pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  80. {
  81. // Step 1. Scale mapping.
  82. // 20100611 Joseph: Re-tunning RSSI presentation for Lenovo.
  83. // 20100426 Joseph: Modify Signal strength mapping.
  84. // This modification makes the RSSI indication similar to Intel solution.
  85. // 20100414 Joseph: Tunning RSSI for Lenovo according to RTL8191SE.
  86. if(CurrSig >= 54 && CurrSig <= 100)
  87. {
  88. RetSig = 100;
  89. }
  90. else if(CurrSig>=42 && CurrSig <= 53 )
  91. {
  92. RetSig = 95;
  93. }
  94. else if(CurrSig>=36 && CurrSig <= 41 )
  95. {
  96. RetSig = 74 + ((CurrSig - 36) *20)/6;
  97. }
  98. else if(CurrSig>=33 && CurrSig <= 35 )
  99. {
  100. RetSig = 65 + ((CurrSig - 33) *8)/2;
  101. }
  102. else if(CurrSig>=18 && CurrSig <= 32 )
  103. {
  104. RetSig = 62 + ((CurrSig - 18) *2)/15;
  105. }
  106. else if(CurrSig>=15 && CurrSig <= 17 )
  107. {
  108. RetSig = 33 + ((CurrSig - 15) *28)/2;
  109. }
  110. else if(CurrSig>=10 && CurrSig <= 14 )
  111. {
  112. RetSig = 39;
  113. }
  114. else if(CurrSig>=8 && CurrSig <= 9 )
  115. {
  116. RetSig = 33;
  117. }
  118. else if(CurrSig <= 8 )
  119. {
  120. RetSig = 19;
  121. }
  122. }
  123. #endif //ENDIF (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  124. return RetSig;
  125. }
  126. s4Byte
  127. odm_SignalScaleMapping_92CSeries_patch_RT_CID_819x_Netcore(
  128. IN OUT PDM_ODM_T pDM_Odm,
  129. s4Byte CurrSig
  130. )
  131. {
  132. s4Byte RetSig;
  133. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  134. //if(pDM_Odm->SupportInterface == ODM_ITRF_USB)
  135. {
  136. // Netcore request this modification because 2009.04.13 SU driver use it.
  137. if(CurrSig >= 31 && CurrSig <= 100)
  138. {
  139. RetSig = 100;
  140. }
  141. else if(CurrSig >= 21 && CurrSig <= 30)
  142. {
  143. RetSig = 90 + ((CurrSig - 20) / 1);
  144. }
  145. else if(CurrSig >= 11 && CurrSig <= 20)
  146. {
  147. RetSig = 80 + ((CurrSig - 10) / 1);
  148. }
  149. else if(CurrSig >= 7 && CurrSig <= 10)
  150. {
  151. RetSig = 69 + (CurrSig - 7);
  152. }
  153. else if(CurrSig == 6)
  154. {
  155. RetSig = 54;
  156. }
  157. else if(CurrSig == 5)
  158. {
  159. RetSig = 45;
  160. }
  161. else if(CurrSig == 4)
  162. {
  163. RetSig = 36;
  164. }
  165. else if(CurrSig == 3)
  166. {
  167. RetSig = 27;
  168. }
  169. else if(CurrSig == 2)
  170. {
  171. RetSig = 18;
  172. }
  173. else if(CurrSig == 1)
  174. {
  175. RetSig = 9;
  176. }
  177. else
  178. {
  179. RetSig = CurrSig;
  180. }
  181. }
  182. #endif //ENDIF (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  183. return RetSig;
  184. }
  185. s4Byte
  186. odm_SignalScaleMapping_92CSeries(
  187. IN OUT PDM_ODM_T pDM_Odm,
  188. IN s4Byte CurrSig
  189. )
  190. {
  191. s4Byte RetSig;
  192. #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
  193. if(pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  194. {
  195. // Step 1. Scale mapping.
  196. if(CurrSig >= 61 && CurrSig <= 100)
  197. {
  198. RetSig = 90 + ((CurrSig - 60) / 4);
  199. }
  200. else if(CurrSig >= 41 && CurrSig <= 60)
  201. {
  202. RetSig = 78 + ((CurrSig - 40) / 2);
  203. }
  204. else if(CurrSig >= 31 && CurrSig <= 40)
  205. {
  206. RetSig = 66 + (CurrSig - 30);
  207. }
  208. else if(CurrSig >= 21 && CurrSig <= 30)
  209. {
  210. RetSig = 54 + (CurrSig - 20);
  211. }
  212. else if(CurrSig >= 5 && CurrSig <= 20)
  213. {
  214. RetSig = 42 + (((CurrSig - 5) * 2) / 3);
  215. }
  216. else if(CurrSig == 4)
  217. {
  218. RetSig = 36;
  219. }
  220. else if(CurrSig == 3)
  221. {
  222. RetSig = 27;
  223. }
  224. else if(CurrSig == 2)
  225. {
  226. RetSig = 18;
  227. }
  228. else if(CurrSig == 1)
  229. {
  230. RetSig = 9;
  231. }
  232. else
  233. {
  234. RetSig = CurrSig;
  235. }
  236. }
  237. #endif
  238. #if ((DEV_BUS_TYPE == RT_USB_INTERFACE) ||(DEV_BUS_TYPE == RT_SDIO_INTERFACE))
  239. if((pDM_Odm->SupportInterface == ODM_ITRF_USB) || (pDM_Odm->SupportInterface == ODM_ITRF_SDIO))
  240. {
  241. if(CurrSig >= 51 && CurrSig <= 100)
  242. {
  243. RetSig = 100;
  244. }
  245. else if(CurrSig >= 41 && CurrSig <= 50)
  246. {
  247. RetSig = 80 + ((CurrSig - 40)*2);
  248. }
  249. else if(CurrSig >= 31 && CurrSig <= 40)
  250. {
  251. RetSig = 66 + (CurrSig - 30);
  252. }
  253. else if(CurrSig >= 21 && CurrSig <= 30)
  254. {
  255. RetSig = 54 + (CurrSig - 20);
  256. }
  257. else if(CurrSig >= 10 && CurrSig <= 20)
  258. {
  259. RetSig = 42 + (((CurrSig - 10) * 2) / 3);
  260. }
  261. else if(CurrSig >= 5 && CurrSig <= 9)
  262. {
  263. RetSig = 22 + (((CurrSig - 5) * 3) / 2);
  264. }
  265. else if(CurrSig >= 1 && CurrSig <= 4)
  266. {
  267. RetSig = 6 + (((CurrSig - 1) * 3) / 2);
  268. }
  269. else
  270. {
  271. RetSig = CurrSig;
  272. }
  273. }
  274. #endif
  275. return RetSig;
  276. }
  277. s4Byte
  278. odm_SignalScaleMapping(
  279. IN OUT PDM_ODM_T pDM_Odm,
  280. IN s4Byte CurrSig
  281. )
  282. {
  283. if( (pDM_Odm->SupportPlatform == ODM_WIN) &&
  284. (pDM_Odm->SupportInterface != ODM_ITRF_PCIE) && //USB & SDIO
  285. (pDM_Odm->PatchID==10))//pMgntInfo->CustomerID == RT_CID_819x_Netcore
  286. {
  287. return odm_SignalScaleMapping_92CSeries_patch_RT_CID_819x_Netcore(pDM_Odm,CurrSig);
  288. }
  289. else if( (pDM_Odm->SupportPlatform == ODM_WIN) &&
  290. (pDM_Odm->SupportInterface == ODM_ITRF_PCIE) &&
  291. (pDM_Odm->PatchID==19))//pMgntInfo->CustomerID == RT_CID_819x_Lenovo)
  292. {
  293. return odm_SignalScaleMapping_92CSeries_patch_RT_CID_819x_Lenovo(pDM_Odm, CurrSig);
  294. }
  295. else{
  296. return odm_SignalScaleMapping_92CSeries(pDM_Odm,CurrSig);
  297. }
  298. }
  299. #endif
  300. static u1Byte odm_SQ_process_patch_RT_CID_819x_Lenovo(
  301. IN PDM_ODM_T pDM_Odm,
  302. IN u1Byte isCCKrate,
  303. IN u1Byte PWDB_ALL,
  304. IN u1Byte path,
  305. IN u1Byte RSSI
  306. )
  307. {
  308. u1Byte SQ;
  309. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  310. if(isCCKrate){
  311. if(IS_HARDWARE_TYPE_8723AE(pDM_Odm->Adapter))
  312. {
  313. //
  314. // <Roger_Notes> Expected signal strength and bars indication at Lenovo lab. 2013.04.11
  315. // 802.11n, 802.11b, 802.11g only at channel 6
  316. //
  317. // Attenuation (dB) OS Signal Bars RSSI by Xirrus (dBm)
  318. // 50 5 -52
  319. // 55 5 -54
  320. // 60 5 -55
  321. // 65 5 -59
  322. // 70 5 -63
  323. // 75 5 -66
  324. // 80 4 -72
  325. // 85 3 -75
  326. // 90 3 -80
  327. // 95 2 -85
  328. // 100 1 -89
  329. // 102 1 -90
  330. // 104 1 -91
  331. //
  332. RT_TRACE(COMP_DBG, DBG_WARNING, ("odm_SQ_process_patch_RT_CID_819x_Lenovo\n"));
  333. #if OS_WIN_FROM_WIN8(OS_VERSION)
  334. if(PWDB_ALL >= 50)
  335. SQ = 100;
  336. else if(PWDB_ALL >= 23 && PWDB_ALL < 50)
  337. SQ = 80;
  338. else if(PWDB_ALL >= 18 && PWDB_ALL < 23)
  339. SQ = 60;
  340. else if(PWDB_ALL >= 8 && PWDB_ALL < 18)
  341. SQ = 40;
  342. else
  343. SQ = 10;
  344. #else
  345. if(PWDB_ALL >= 34)
  346. SQ = 100;
  347. else if(PWDB_ALL >= 23 && PWDB_ALL < 34)
  348. SQ = 80;
  349. else if(PWDB_ALL >= 18 && PWDB_ALL < 23)
  350. SQ = 60;
  351. else if(PWDB_ALL >= 8 && PWDB_ALL < 18)
  352. SQ = 40;
  353. else
  354. SQ = 10;
  355. if(PWDB_ALL == 0)// Abnormal case, do not indicate the value above 20 on Win7
  356. SQ = 20;
  357. #endif
  358. }
  359. else if(IS_HARDWARE_TYPE_8192E(pDM_Odm->Adapter)){
  360. //
  361. // <Roger_Notes> Expected signal strength and bars indication at Lenovo lab. 2013.04.11
  362. // 802.11n, 802.11b, 802.11g only at channel 6
  363. //
  364. // Attenuation (dB) OS Signal Bars RSSI by Xirrus (dBm)
  365. // 50 5 -49
  366. // 55 5 -49
  367. // 60 5 -50
  368. // 65 5 -51
  369. // 70 5 -52
  370. // 75 5 -54
  371. // 80 5 -55
  372. // 85 4 -60
  373. // 90 3 -63
  374. // 95 3 -65
  375. // 100 2 -67
  376. // 102 2 -67
  377. // 104 1 -70
  378. //
  379. if(PWDB_ALL >= 50)
  380. SQ = 100;
  381. else if(PWDB_ALL >= 35 && PWDB_ALL < 50)
  382. SQ = 80;
  383. else if(PWDB_ALL >= 31 && PWDB_ALL < 35)
  384. SQ = 60;
  385. else if(PWDB_ALL >= 22 && PWDB_ALL < 31)
  386. SQ = 40;
  387. else if(PWDB_ALL >= 18 && PWDB_ALL < 22)
  388. SQ = 20;
  389. else
  390. SQ = 10;
  391. }
  392. else
  393. {
  394. if(PWDB_ALL >= 50)
  395. SQ = 100;
  396. else if(PWDB_ALL >= 35 && PWDB_ALL < 50)
  397. SQ = 80;
  398. else if(PWDB_ALL >= 22 && PWDB_ALL < 35)
  399. SQ = 60;
  400. else if(PWDB_ALL >= 18 && PWDB_ALL < 22)
  401. SQ = 40;
  402. else
  403. SQ = 10;
  404. }
  405. }
  406. else
  407. {//OFDM rate
  408. if(IS_HARDWARE_TYPE_8723AE(pDM_Odm->Adapter) ||
  409. IS_HARDWARE_TYPE_8192E(pDM_Odm->Adapter))
  410. {
  411. if(RSSI >= 45)
  412. SQ = 100;
  413. else if(RSSI >= 22 && RSSI < 45)
  414. SQ = 80;
  415. else if(RSSI >= 18 && RSSI < 22)
  416. SQ = 40;
  417. else
  418. SQ = 20;
  419. }
  420. else
  421. {
  422. if(RSSI >= 45)
  423. SQ = 100;
  424. else if(RSSI >= 22 && RSSI < 45)
  425. SQ = 80;
  426. else if(RSSI >= 18 && RSSI < 22)
  427. SQ = 40;
  428. else
  429. SQ = 20;
  430. }
  431. }
  432. RT_TRACE(COMP_DBG, DBG_TRACE, ("isCCKrate(%#d), PWDB_ALL(%#d), RSSI(%#d), SQ(%#d)\n", isCCKrate, PWDB_ALL, RSSI, SQ));
  433. #endif
  434. return SQ;
  435. }
  436. static u1Byte
  437. odm_EVMdbToPercentage(
  438. IN s1Byte Value
  439. )
  440. {
  441. //
  442. // -33dB~0dB to 0%~99%
  443. //
  444. s1Byte ret_val;
  445. ret_val = Value;
  446. //ret_val /= 2;
  447. //ODM_RT_DISP(FRX, RX_PHY_SQ, ("EVMdbToPercentage92C Value=%d / %x \n", ret_val, ret_val));
  448. if(ret_val >= 0)
  449. ret_val = 0;
  450. if(ret_val <= -33)
  451. ret_val = -33;
  452. ret_val = 0 - ret_val;
  453. ret_val*=3;
  454. if(ret_val == 99)
  455. ret_val = 100;
  456. return(ret_val);
  457. }
  458. static u1Byte
  459. odm_EVMdbm_JaguarSeries(
  460. IN s1Byte Value
  461. )
  462. {
  463. s1Byte ret_val = Value;
  464. // -33dB~0dB to 33dB ~ 0dB
  465. if(ret_val == -128)
  466. ret_val = 127;
  467. else if (ret_val < 0)
  468. ret_val = 0 - ret_val;
  469. ret_val = ret_val >> 1;
  470. return ret_val;
  471. }
  472. static u2Byte
  473. odm_Cfo(
  474. IN s1Byte Value
  475. )
  476. {
  477. s2Byte ret_val;
  478. if (Value < 0)
  479. {
  480. ret_val = 0 - Value;
  481. ret_val = (ret_val << 1) + (ret_val >> 1) ; // *2.5~=312.5/2^7
  482. ret_val = ret_val | BIT12; // set bit12 as 1 for negative cfo
  483. }
  484. else
  485. {
  486. ret_val = Value;
  487. ret_val = (ret_val << 1) + (ret_val>>1) ; // *2.5~=312.5/2^7
  488. }
  489. return ret_val;
  490. }
  491. VOID
  492. odm_RxPhyStatus92CSeries_Parsing(
  493. IN OUT PDM_ODM_T pDM_Odm,
  494. OUT PODM_PHY_INFO_T pPhyInfo,
  495. IN pu1Byte pPhyStatus,
  496. IN PODM_PACKET_INFO_T pPktinfo
  497. )
  498. {
  499. SWAT_T *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table;
  500. u1Byte i, Max_spatial_stream;
  501. s1Byte rx_pwr[4], rx_pwr_all=0;
  502. u1Byte EVM, PWDB_ALL = 0, PWDB_ALL_BT;
  503. u1Byte RSSI, total_rssi=0;
  504. BOOLEAN isCCKrate=FALSE;
  505. u1Byte rf_rx_num = 0;
  506. u1Byte cck_highpwr = 0;
  507. u1Byte LNA_idx, VGA_idx;
  508. PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus;
  509. isCCKrate = (pPktinfo->DataRate <= DESC92C_RATE11M)?TRUE :FALSE;
  510. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1;
  511. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1;
  512. if(isCCKrate)
  513. {
  514. u1Byte report;
  515. u1Byte cck_agc_rpt;
  516. pDM_Odm->PhyDbgInfo.NumQryPhyStatusCCK++;
  517. //
  518. // (1)Hardware does not provide RSSI for CCK
  519. // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
  520. //
  521. //if(pHalData->eRFPowerState == eRfOn)
  522. cck_highpwr = pDM_Odm->bCckHighPower;
  523. //else
  524. // cck_highpwr = FALSE;
  525. cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ;
  526. //2011.11.28 LukeLee: 88E use different LNA & VGA gain table
  527. //The RSSI formula should be modified according to the gain table
  528. //In 88E, cck_highpwr is always set to 1
  529. if(pDM_Odm->SupportICType & (ODM_RTL8188E|ODM_RTL8192E|ODM_RTL8723B))
  530. {
  531. LNA_idx = ((cck_agc_rpt & 0xE0) >>5);
  532. VGA_idx = (cck_agc_rpt & 0x1F);
  533. if(pDM_Odm->SupportICType & (ODM_RTL8188E|ODM_RTL8192E))
  534. {
  535. switch(LNA_idx)
  536. {
  537. case 7:
  538. if(VGA_idx <= 27)
  539. rx_pwr_all = -100 + 2*(27-VGA_idx); //VGA_idx = 27~2
  540. else
  541. rx_pwr_all = -100;
  542. break;
  543. case 6:
  544. rx_pwr_all = -48 + 2*(2-VGA_idx); //VGA_idx = 2~0
  545. break;
  546. case 5:
  547. rx_pwr_all = -42 + 2*(7-VGA_idx); //VGA_idx = 7~5
  548. break;
  549. case 4:
  550. rx_pwr_all = -36 + 2*(7-VGA_idx); //VGA_idx = 7~4
  551. break;
  552. case 3:
  553. //rx_pwr_all = -28 + 2*(7-VGA_idx); //VGA_idx = 7~0
  554. rx_pwr_all = -24 + 2*(7-VGA_idx); //VGA_idx = 7~0
  555. break;
  556. case 2:
  557. if(cck_highpwr)
  558. rx_pwr_all = -12 + 2*(5-VGA_idx); //VGA_idx = 5~0
  559. else
  560. rx_pwr_all = -6+ 2*(5-VGA_idx);
  561. break;
  562. case 1:
  563. rx_pwr_all = 8-2*VGA_idx;
  564. break;
  565. case 0:
  566. rx_pwr_all = 14-2*VGA_idx;
  567. break;
  568. default:
  569. //DbgPrint("CCK Exception default\n");
  570. break;
  571. }
  572. rx_pwr_all += 6;
  573. //2012.10.08 LukeLee: Modify for 92E CCK RSSI
  574. if(pDM_Odm->SupportICType == ODM_RTL8192E)
  575. rx_pwr_all += 10;
  576. PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  577. if(cck_highpwr == FALSE)
  578. {
  579. if(PWDB_ALL >= 80)
  580. PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80;
  581. else if((PWDB_ALL <= 78) && (PWDB_ALL >= 20))
  582. PWDB_ALL += 3;
  583. if(PWDB_ALL>100)
  584. PWDB_ALL = 100;
  585. }
  586. }
  587. else if(pDM_Odm->SupportICType & (ODM_RTL8723B))
  588. {
  589. #if (RTL8723B_SUPPORT == 1)
  590. rx_pwr_all = odm_CCKRSSI_8723B(LNA_idx,VGA_idx);
  591. PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  592. if(PWDB_ALL>100)
  593. PWDB_ALL = 100;
  594. #endif
  595. }
  596. }
  597. else
  598. {
  599. if(!cck_highpwr)
  600. {
  601. report =( cck_agc_rpt & 0xc0 )>>6;
  602. switch(report)
  603. {
  604. // 03312009 modified by cosa
  605. // Modify the RF RNA gain value to -40, -20, -2, 14 by Jenyu's suggestion
  606. // Note: different RF with the different RNA gain.
  607. case 0x3:
  608. rx_pwr_all = -46 - (cck_agc_rpt & 0x3e);
  609. break;
  610. case 0x2:
  611. rx_pwr_all = -26 - (cck_agc_rpt & 0x3e);
  612. break;
  613. case 0x1:
  614. rx_pwr_all = -12 - (cck_agc_rpt & 0x3e);
  615. break;
  616. case 0x0:
  617. rx_pwr_all = 16 - (cck_agc_rpt & 0x3e);
  618. break;
  619. }
  620. }
  621. else
  622. {
  623. //report = pDrvInfo->cfosho[0] & 0x60;
  624. //report = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a& 0x60;
  625. report = (cck_agc_rpt & 0x60)>>5;
  626. switch(report)
  627. {
  628. case 0x3:
  629. rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f)<<1) ;
  630. break;
  631. case 0x2:
  632. rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f)<<1);
  633. break;
  634. case 0x1:
  635. rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f)<<1) ;
  636. break;
  637. case 0x0:
  638. rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f)<<1) ;
  639. break;
  640. }
  641. }
  642. PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  643. //Modification for ext-LNA board
  644. if(pDM_Odm->BoardType & (ODM_BOARD_EXT_LNA | ODM_BOARD_EXT_PA))
  645. {
  646. if((cck_agc_rpt>>7) == 0){
  647. PWDB_ALL = (PWDB_ALL>94)?100:(PWDB_ALL +6);
  648. }
  649. else
  650. {
  651. if(PWDB_ALL > 38)
  652. PWDB_ALL -= 16;
  653. else
  654. PWDB_ALL = (PWDB_ALL<=16)?(PWDB_ALL>>2):(PWDB_ALL -12);
  655. }
  656. //CCK modification
  657. if(PWDB_ALL > 25 && PWDB_ALL <= 60)
  658. PWDB_ALL += 6;
  659. //else if (PWDB_ALL <= 25)
  660. // PWDB_ALL += 8;
  661. }
  662. else//Modification for int-LNA board
  663. {
  664. if(PWDB_ALL > 99)
  665. PWDB_ALL -= 8;
  666. else if(PWDB_ALL > 50 && PWDB_ALL <= 68)
  667. PWDB_ALL += 4;
  668. }
  669. }
  670. pPhyInfo->RxPWDBAll = PWDB_ALL;
  671. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  672. pPhyInfo->BTRxRSSIPercentage = PWDB_ALL;
  673. pPhyInfo->RecvSignalPower = rx_pwr_all;
  674. #endif
  675. //
  676. // (3) Get Signal Quality (EVM)
  677. //
  678. if(pPktinfo->bPacketMatchBSSID)
  679. {
  680. u1Byte SQ,SQ_rpt;
  681. if((pDM_Odm->SupportPlatform == ODM_WIN) &&
  682. (pDM_Odm->PatchID==RT_CID_819x_Lenovo)){
  683. SQ = odm_SQ_process_patch_RT_CID_819x_Lenovo(pDM_Odm,isCCKrate,PWDB_ALL,0,0);
  684. }
  685. else if(pPhyInfo->RxPWDBAll > 40 && !pDM_Odm->bInHctTest){
  686. SQ = 100;
  687. }
  688. else{
  689. SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all;
  690. if(SQ_rpt > 64)
  691. SQ = 0;
  692. else if (SQ_rpt < 20)
  693. SQ = 100;
  694. else
  695. SQ = ((64-SQ_rpt) * 100) / 44;
  696. }
  697. //DbgPrint("cck SQ = %d\n", SQ);
  698. pPhyInfo->SignalQuality = SQ;
  699. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = SQ;
  700. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1;
  701. }
  702. }
  703. else //is OFDM rate
  704. {
  705. pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM++;
  706. //
  707. // (1)Get RSSI for HT rate
  708. //
  709. for(i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++)
  710. {
  711. // 2008/01/30 MH we will judge RF RX path now.
  712. if (pDM_Odm->RFPathRxEnable & BIT(i))
  713. rf_rx_num++;
  714. //else
  715. //continue;
  716. rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain& 0x3F)*2) - 110;
  717. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  718. pPhyInfo->RxPwr[i] = rx_pwr[i];
  719. #endif
  720. /* Translate DBM to percentage. */
  721. RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]);
  722. total_rssi += RSSI;
  723. //RT_DISP(FRX, RX_PHY_SS, ("RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI));
  724. //Modification for ext-LNA board
  725. if(pDM_Odm->SupportICType&ODM_RTL8192C)
  726. {
  727. if(pDM_Odm->BoardType & (ODM_BOARD_EXT_LNA | ODM_BOARD_EXT_PA))
  728. {
  729. if((pPhyStaRpt->path_agc[i].trsw) == 1)
  730. RSSI = (RSSI>94)?100:(RSSI +6);
  731. else
  732. RSSI = (RSSI<=16)?(RSSI>>3):(RSSI -16);
  733. if((RSSI <= 34) && (RSSI >=4))
  734. RSSI -= 4;
  735. }
  736. }
  737. pPhyInfo->RxMIMOSignalStrength[i] =(u1Byte) RSSI;
  738. #if (DM_ODM_SUPPORT_TYPE & (/*ODM_WIN|*/ODM_CE|ODM_AP|ODM_ADSL))
  739. //Get Rx snr value in DB
  740. pPhyInfo->RxSNR[i] = pDM_Odm->PhyDbgInfo.RxSNRdB[i] = (s4Byte)(pPhyStaRpt->path_rxsnr[i]/2);
  741. #endif
  742. /* Record Signal Strength for next packet */
  743. if(pPktinfo->bPacketMatchBSSID)
  744. {
  745. if((pDM_Odm->SupportPlatform == ODM_WIN) &&
  746. (pDM_Odm->PatchID==RT_CID_819x_Lenovo))
  747. {
  748. if(i==ODM_RF_PATH_A)
  749. pPhyInfo->SignalQuality = odm_SQ_process_patch_RT_CID_819x_Lenovo(pDM_Odm,isCCKrate,PWDB_ALL,i,RSSI);
  750. }
  751. }
  752. }
  753. //
  754. // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
  755. //
  756. rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1 )& 0x7f) -110;
  757. PWDB_ALL_BT = PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  758. //RT_DISP(FRX, RX_PHY_SS, ("PWDB_ALL=%d\n",PWDB_ALL));
  759. pPhyInfo->RxPWDBAll = PWDB_ALL;
  760. //ODM_RT_TRACE(pDM_Odm,ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("ODM OFDM RSSI=%d\n",pPhyInfo->RxPWDBAll));
  761. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  762. pPhyInfo->BTRxRSSIPercentage = PWDB_ALL_BT;
  763. pPhyInfo->RxPower = rx_pwr_all;
  764. pPhyInfo->RecvSignalPower = rx_pwr_all;
  765. #endif
  766. if((pDM_Odm->SupportPlatform == ODM_WIN) &&(pDM_Odm->PatchID==19)){
  767. //do nothing
  768. }
  769. else{//pMgntInfo->CustomerID != RT_CID_819x_Lenovo
  770. //
  771. // (3)EVM of HT rate
  772. //
  773. if(pPktinfo->DataRate >=DESC92C_RATEMCS8 && pPktinfo->DataRate <=DESC92C_RATEMCS15)
  774. Max_spatial_stream = 2; //both spatial stream make sense
  775. else
  776. Max_spatial_stream = 1; //only spatial stream 1 makes sense
  777. for(i=0; i<Max_spatial_stream; i++)
  778. {
  779. // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
  780. // fill most significant bit to "zero" when doing shifting operation which may change a negative
  781. // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
  782. EVM = odm_EVMdbToPercentage( (pPhyStaRpt->stream_rxevm[i] )); //dbm
  783. //RT_DISP(FRX, RX_PHY_SQ, ("RXRATE=%x RXEVM=%x EVM=%s%d\n",
  784. //GET_RX_STATUS_DESC_RX_MCS(pDesc), pDrvInfo->rxevm[i], "%", EVM));
  785. if(pPktinfo->bPacketMatchBSSID)
  786. {
  787. if(i==ODM_RF_PATH_A) // Fill value in RFD, Get the first spatial stream only
  788. {
  789. pPhyInfo->SignalQuality = (u1Byte)(EVM & 0xff);
  790. }
  791. pPhyInfo->RxMIMOSignalQuality[i] = (u1Byte)(EVM & 0xff);
  792. }
  793. }
  794. }
  795. //2 For dynamic ATC switch
  796. if(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_ATC)
  797. {
  798. if(pPktinfo->bPacketMatchBSSID)
  799. {
  800. //3 Update CFO report for path-A & path-B
  801. for(i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++)
  802. {
  803. pDM_Odm->CFO_tail[i] = (int)pPhyStaRpt->path_cfotail[i];
  804. }
  805. //3 Update packet counter
  806. if(pDM_Odm->packetCount == 0xffffffff)
  807. pDM_Odm->packetCount = 0;
  808. else
  809. pDM_Odm->packetCount++;
  810. //ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD,
  811. //("pPhyStaRpt->path_cfotail[i] = 0x%x, pDM_Odm->CFO_tail[i] = 0x%x\n", pPhyStaRpt->path_cfotail[0], pDM_Odm->CFO_tail[1]));
  812. }
  813. }
  814. }
  815. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  816. //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
  817. //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
  818. if(isCCKrate)
  819. {
  820. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  821. // 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/
  822. pPhyInfo->SignalStrength = (u1Byte)(SignalScaleMapping(pDM_Odm->Adapter, PWDB_ALL));//PWDB_ALL;
  823. #else
  824. pPhyInfo->SignalStrength = (u1Byte)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));//PWDB_ALL;
  825. #endif
  826. }
  827. else
  828. {
  829. if (rf_rx_num != 0)
  830. {
  831. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  832. // 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/
  833. pPhyInfo->SignalStrength = (u1Byte)(SignalScaleMapping(pDM_Odm->Adapter, total_rssi/=rf_rx_num));//PWDB_ALL;
  834. #else
  835. pPhyInfo->SignalStrength = (u1Byte)(odm_SignalScaleMapping(pDM_Odm, total_rssi/=rf_rx_num));
  836. #endif
  837. }
  838. }
  839. #endif
  840. //DbgPrint("isCCKrate = %d, pPhyInfo->RxPWDBAll = %d, pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a = 0x%x\n",
  841. //isCCKrate, pPhyInfo->RxPWDBAll, pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a);
  842. //For 92C/92D HW (Hybrid) Antenna Diversity
  843. #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
  844. pDM_SWAT_Table->antsel = pPhyStaRpt->ant_sel;
  845. //For 88E HW Antenna Diversity
  846. pDM_Odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->ant_sel;
  847. pDM_Odm->DM_FatTable.antsel_rx_keep_1 = pPhyStaRpt->ant_sel_b;
  848. pDM_Odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2;
  849. #endif
  850. }
  851. VOID
  852. odm_RxPhyStatusJaguarSeries_Parsing(
  853. IN OUT PDM_ODM_T pDM_Odm,
  854. OUT PODM_PHY_INFO_T pPhyInfo,
  855. IN pu1Byte pPhyStatus,
  856. IN PODM_PACKET_INFO_T pPktinfo
  857. )
  858. {
  859. u1Byte i, Max_spatial_stream;
  860. s1Byte rx_pwr[4], rx_pwr_all=0;
  861. u1Byte EVM, EVMdbm, PWDB_ALL = 0, PWDB_ALL_BT;
  862. u1Byte RSSI, total_rssi=0;
  863. u1Byte isCCKrate=0;
  864. u1Byte rf_rx_num = 0;
  865. u1Byte cck_highpwr = 0;
  866. u1Byte LNA_idx, VGA_idx;
  867. PPHY_STATUS_RPT_8812_T pPhyStaRpt = (PPHY_STATUS_RPT_8812_T)pPhyStatus;
  868. if(pPktinfo->DataRate <= DESC_RATE54M)
  869. {
  870. switch(pPhyStaRpt->r_RFMOD){
  871. case 1:
  872. if(pPhyStaRpt->sub_chnl == 0)
  873. pPhyInfo->BandWidth = 1;
  874. else
  875. pPhyInfo->BandWidth = 0;
  876. break;
  877. case 2:
  878. if(pPhyStaRpt->sub_chnl == 0)
  879. pPhyInfo->BandWidth = 2;
  880. else if(pPhyStaRpt->sub_chnl == 9 || pPhyStaRpt->sub_chnl == 10)
  881. pPhyInfo->BandWidth = 1;
  882. else
  883. pPhyInfo->BandWidth = 0;
  884. break;
  885. default: case 0:
  886. pPhyInfo->BandWidth = 0;
  887. break;
  888. }
  889. }
  890. if(pPktinfo->DataRate <= DESC_RATE11M)
  891. isCCKrate = TRUE;
  892. else
  893. isCCKrate = FALSE;
  894. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1;
  895. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1;
  896. if(isCCKrate)
  897. {
  898. u1Byte cck_agc_rpt;
  899. pDM_Odm->PhyDbgInfo.NumQryPhyStatusCCK++;
  900. //
  901. // (1)Hardware does not provide RSSI for CCK
  902. // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
  903. //
  904. //if(pHalData->eRFPowerState == eRfOn)
  905. cck_highpwr = pDM_Odm->bCckHighPower;
  906. //else
  907. // cck_highpwr = FALSE;
  908. cck_agc_rpt = pPhyStaRpt->cfosho[0] ;
  909. LNA_idx = ((cck_agc_rpt & 0xE0) >>5);
  910. VGA_idx = (cck_agc_rpt & 0x1F);
  911. if(pDM_Odm->SupportICType == ODM_RTL8812)
  912. {
  913. switch(LNA_idx)
  914. {
  915. case 7:
  916. if(VGA_idx <= 27)
  917. rx_pwr_all = -100 + 2*(27-VGA_idx); //VGA_idx = 27~2
  918. else
  919. rx_pwr_all = -100;
  920. break;
  921. case 6:
  922. rx_pwr_all = -48 + 2*(2-VGA_idx); //VGA_idx = 2~0
  923. break;
  924. case 5:
  925. rx_pwr_all = -42 + 2*(7-VGA_idx); //VGA_idx = 7~5
  926. break;
  927. case 4:
  928. rx_pwr_all = -36 + 2*(7-VGA_idx); //VGA_idx = 7~4
  929. break;
  930. case 3:
  931. //rx_pwr_all = -28 + 2*(7-VGA_idx); //VGA_idx = 7~0
  932. rx_pwr_all = -24 + 2*(7-VGA_idx); //VGA_idx = 7~0
  933. break;
  934. case 2:
  935. if(cck_highpwr)
  936. rx_pwr_all = -12 + 2*(5-VGA_idx); //VGA_idx = 5~0
  937. else
  938. rx_pwr_all = -6+ 2*(5-VGA_idx);
  939. break;
  940. case 1:
  941. rx_pwr_all = 8-2*VGA_idx;
  942. break;
  943. case 0:
  944. rx_pwr_all = 14-2*VGA_idx;
  945. break;
  946. default:
  947. //DbgPrint("CCK Exception default\n");
  948. break;
  949. }
  950. rx_pwr_all += 6;
  951. PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  952. if(cck_highpwr == FALSE)
  953. {
  954. if(PWDB_ALL >= 80)
  955. PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80;
  956. else if((PWDB_ALL <= 78) && (PWDB_ALL >= 20))
  957. PWDB_ALL += 3;
  958. if(PWDB_ALL>100)
  959. PWDB_ALL = 100;
  960. }
  961. }
  962. else if(pDM_Odm->SupportICType == ODM_RTL8821)
  963. {
  964. s1Byte Pout = -6;
  965. switch(LNA_idx)
  966. {
  967. case 5:
  968. rx_pwr_all = Pout -32 -(2*VGA_idx);
  969. break;
  970. case 4:
  971. rx_pwr_all = Pout -24 -(2*VGA_idx);
  972. break;
  973. case 2:
  974. rx_pwr_all = Pout -11 -(2*VGA_idx);
  975. break;
  976. case 1:
  977. rx_pwr_all = Pout + 5 -(2*VGA_idx);
  978. break;
  979. case 0:
  980. rx_pwr_all = Pout + 21 -(2*VGA_idx);
  981. break;
  982. }
  983. PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  984. }
  985. pPhyInfo->RxPWDBAll = PWDB_ALL;
  986. //if(pPktinfo->StationID == 0)
  987. //{
  988. // DbgPrint("CCK: LNA_idx = %d, VGA_idx = %d, pPhyInfo->RxPWDBAll = %d\n",
  989. // LNA_idx, VGA_idx, pPhyInfo->RxPWDBAll);
  990. //}
  991. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  992. pPhyInfo->BTRxRSSIPercentage = PWDB_ALL;
  993. pPhyInfo->RecvSignalPower = rx_pwr_all;
  994. #endif
  995. //
  996. // (3) Get Signal Quality (EVM)
  997. //
  998. if(pPktinfo->bPacketMatchBSSID)
  999. {
  1000. u1Byte SQ,SQ_rpt;
  1001. if((pDM_Odm->SupportPlatform == ODM_WIN) &&
  1002. (pDM_Odm->PatchID==RT_CID_819x_Lenovo)){
  1003. SQ = odm_SQ_process_patch_RT_CID_819x_Lenovo(pDM_Odm,isCCKrate,PWDB_ALL,0,0);
  1004. }
  1005. else if(pPhyInfo->RxPWDBAll > 40 && !pDM_Odm->bInHctTest){
  1006. SQ = 100;
  1007. }
  1008. else{
  1009. SQ_rpt = pPhyStaRpt->pwdb_all;
  1010. if(SQ_rpt > 64)
  1011. SQ = 0;
  1012. else if (SQ_rpt < 20)
  1013. SQ = 100;
  1014. else
  1015. SQ = ((64-SQ_rpt) * 100) / 44;
  1016. }
  1017. //DbgPrint("cck SQ = %d\n", SQ);
  1018. pPhyInfo->SignalQuality = SQ;
  1019. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = SQ;
  1020. pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1;
  1021. }
  1022. }
  1023. else //is OFDM rate
  1024. {
  1025. pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM++;
  1026. //
  1027. // (1)Get RSSI for OFDM rate
  1028. //
  1029. for(i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++)
  1030. {
  1031. // 2008/01/30 MH we will judge RF RX path now.
  1032. //DbgPrint("pDM_Odm->RFPathRxEnable = %x\n", pDM_Odm->RFPathRxEnable);
  1033. if (pDM_Odm->RFPathRxEnable & BIT(i))
  1034. {
  1035. rf_rx_num++;
  1036. }
  1037. //else
  1038. //continue;
  1039. //2012.05.25 LukeLee: Testchip AGC report is wrong, it should be restored back to old formula in MP chip
  1040. //if((pDM_Odm->SupportICType & (ODM_RTL8812|ODM_RTL8821)) && (!pDM_Odm->bIsMPChip))
  1041. rx_pwr[i] = (pPhyStaRpt->gain_trsw[i]&0x7F) - 110;
  1042. //else
  1043. // rx_pwr[i] = ((pPhyStaRpt->gain_trsw[i]& 0x3F)*2) - 110; //OLD FORMULA
  1044. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  1045. pPhyInfo->RxPwr[i] = rx_pwr[i];
  1046. #endif
  1047. /* Translate DBM to percentage. */
  1048. RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]);
  1049. total_rssi += RSSI;
  1050. //RT_DISP(FRX, RX_PHY_SS, ("RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI));
  1051. pPhyInfo->RxMIMOSignalStrength[i] =(u1Byte) RSSI;
  1052. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE|ODM_AP|ODM_ADSL))
  1053. //Get Rx snr value in DB
  1054. pPhyInfo->RxSNR[i] = pDM_Odm->PhyDbgInfo.RxSNRdB[i] = pPhyStaRpt->rxsnr[i]/2;
  1055. #endif
  1056. //
  1057. // (2) CFO_short & CFO_tail
  1058. //
  1059. pPhyInfo->Cfo_short[i] = odm_Cfo( (pPhyStaRpt->cfosho[i]) );
  1060. pPhyInfo->Cfo_tail[i] = odm_Cfo( (pPhyStaRpt->cfotail[i]) );
  1061. /* Record Signal Strength for next packet */
  1062. if(pPktinfo->bPacketMatchBSSID)
  1063. {
  1064. if((pDM_Odm->SupportPlatform == ODM_WIN) &&
  1065. (pDM_Odm->PatchID==RT_CID_819x_Lenovo))
  1066. {
  1067. if(i==ODM_RF_PATH_A)
  1068. pPhyInfo->SignalQuality = odm_SQ_process_patch_RT_CID_819x_Lenovo(pDM_Odm,isCCKrate,PWDB_ALL,i,RSSI);
  1069. }
  1070. }
  1071. }
  1072. //
  1073. // (3)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
  1074. //
  1075. //2012.05.25 LukeLee: Testchip AGC report is wrong, it should be restored back to old formula in MP chip
  1076. if((pDM_Odm->SupportICType & (ODM_RTL8812|ODM_RTL8821)) && (!pDM_Odm->bIsMPChip))
  1077. rx_pwr_all = (pPhyStaRpt->pwdb_all& 0x7f) -110;
  1078. else
  1079. rx_pwr_all = (((pPhyStaRpt->pwdb_all) >> 1 )& 0x7f) -110; //OLD FORMULA
  1080. PWDB_ALL_BT = PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all);
  1081. pPhyInfo->RxPWDBAll = PWDB_ALL;
  1082. //ODM_RT_TRACE(pDM_Odm,ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("ODM OFDM RSSI=%d\n",pPhyInfo->RxPWDBAll));
  1083. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  1084. pPhyInfo->BTRxRSSIPercentage = PWDB_ALL_BT;
  1085. pPhyInfo->RxPower = rx_pwr_all;
  1086. pPhyInfo->RecvSignalPower = rx_pwr_all;
  1087. #endif
  1088. //DbgPrint("OFDM: pPhyInfo->RxPWDBAll = %d, pPhyInfo->RxMIMOSignalStrength[0] = %d, pPhyInfo->RxMIMOSignalStrength[1] = %d\n",
  1089. // pPhyInfo->RxPWDBAll, pPhyInfo->RxMIMOSignalStrength[0], pPhyInfo->RxMIMOSignalStrength[1]);
  1090. if((pDM_Odm->SupportPlatform == ODM_WIN) &&(pDM_Odm->PatchID==19)){
  1091. //do nothing
  1092. }
  1093. else{//pMgntInfo->CustomerID != RT_CID_819x_Lenovo
  1094. //
  1095. // (4)EVM of OFDM rate
  1096. //
  1097. if( (pPktinfo->DataRate>=DESC_RATEMCS8) &&
  1098. (pPktinfo->DataRate <=DESC_RATEMCS15))
  1099. Max_spatial_stream = 2;
  1100. else if( (pPktinfo->DataRate>=DESC_RATEVHTSS2MCS0) &&
  1101. (pPktinfo->DataRate <=DESC_RATEVHTSS2MCS9))
  1102. Max_spatial_stream = 2;
  1103. else
  1104. Max_spatial_stream = 1;
  1105. for(i=0; i<Max_spatial_stream; i++)
  1106. {
  1107. // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
  1108. // fill most significant bit to "zero" when doing shifting operation which may change a negative
  1109. // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
  1110. EVM = odm_EVMdbToPercentage( (pPhyStaRpt->rxevm[i] )); //dbm
  1111. EVMdbm = odm_EVMdbm_JaguarSeries(pPhyStaRpt->rxevm[i]);
  1112. //RT_DISP(FRX, RX_PHY_SQ, ("RXRATE=%x RXEVM=%x EVM=%s%d\n",
  1113. //pPktinfo->DataRate, pPhyStaRpt->rxevm[i], "%", EVM));
  1114. if(pPktinfo->bPacketMatchBSSID)
  1115. {
  1116. if(i==ODM_RF_PATH_A) // Fill value in RFD, Get the first spatial stream only
  1117. {
  1118. pPhyInfo->SignalQuality = EVM;
  1119. }
  1120. pPhyInfo->RxMIMOSignalQuality[i] = EVM;
  1121. pPhyInfo->RxMIMOEVMdbm[i] = EVMdbm;
  1122. }
  1123. }
  1124. }
  1125. //2 For dynamic ATC switch
  1126. if(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_ATC)
  1127. {
  1128. if(pPktinfo->bPacketMatchBSSID)
  1129. {
  1130. //3 Update CFO report for path-A & path-B
  1131. for(i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++)
  1132. {
  1133. pDM_Odm->CFO_tail[i] = (int)pPhyStaRpt->cfotail[i];
  1134. }
  1135. //3 Update packet counter
  1136. if(pDM_Odm->packetCount == 0xffffffff)
  1137. pDM_Odm->packetCount = 0;
  1138. else
  1139. pDM_Odm->packetCount++;
  1140. //ODM_RT_TRACE(pDM_Odm, ODM_COMP_DYNAMIC_ATC, ODM_DBG_LOUD,
  1141. //("pPhyStaRpt->path_cfotail[i] = 0x%x, pDM_Odm->CFO_tail[i] = 0x%x\n", pPhyStaRpt->path_cfotail[0], pDM_Odm->CFO_tail[1]));
  1142. }
  1143. }
  1144. }
  1145. //DbgPrint("isCCKrate= %d, pPhyInfo->SignalStrength=%d % PWDB_AL=%d rf_rx_num=%d\n", isCCKrate, pPhyInfo->SignalStrength, PWDB_ALL, rf_rx_num);
  1146. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))
  1147. //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
  1148. //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
  1149. if(isCCKrate)
  1150. {
  1151. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1152. // 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/
  1153. pPhyInfo->SignalStrength = (u1Byte)(SignalScaleMapping(pDM_Odm->Adapter, PWDB_ALL));//PWDB_ALL;
  1154. #else
  1155. pPhyInfo->SignalStrength = (u1Byte)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));//PWDB_ALL;
  1156. #endif
  1157. }
  1158. else
  1159. {
  1160. if (rf_rx_num != 0)
  1161. {
  1162. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1163. // 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/
  1164. pPhyInfo->SignalStrength = (u1Byte)(SignalScaleMapping(pDM_Odm->Adapter, total_rssi/=rf_rx_num));//PWDB_ALL;
  1165. #else
  1166. pPhyInfo->SignalStrength = (u1Byte)(odm_SignalScaleMapping(pDM_Odm, total_rssi/=rf_rx_num));
  1167. #endif
  1168. }
  1169. }
  1170. #endif
  1171. pDM_Odm->RxPWDBAve = pDM_Odm->RxPWDBAve + pPhyInfo->RxPWDBAll;
  1172. pDM_Odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->antidx_anta;
  1173. //DbgPrint("pPhyStaRpt->antidx_anta = %d, pPhyStaRpt->antidx_antb = %d, pPhyStaRpt->resvd_1 = %d",
  1174. // pPhyStaRpt->antidx_anta, pPhyStaRpt->antidx_antb, pPhyStaRpt->resvd_1);
  1175. //DbgPrint("----------------------------\n");
  1176. //DbgPrint("pPktinfo->StationID=%d, pPktinfo->DataRate=0x%x\n",pPktinfo->StationID, pPktinfo->DataRate);
  1177. //DbgPrint("pPhyStaRpt->gain_trsw[0]=0x%x, pPhyStaRpt->gain_trsw[1]=0x%x, pPhyStaRpt->pwdb_all=0x%x\n",
  1178. // pPhyStaRpt->gain_trsw[0],pPhyStaRpt->gain_trsw[1], pPhyStaRpt->pwdb_all);
  1179. //DbgPrint("pPhyInfo->RxMIMOSignalStrength[0]=%d, pPhyInfo->RxMIMOSignalStrength[1]=%d, RxPWDBAll=%d\n",
  1180. // pPhyInfo->RxMIMOSignalStrength[0], pPhyInfo->RxMIMOSignalStrength[1], pPhyInfo->RxPWDBAll);
  1181. }
  1182. VOID
  1183. odm_Init_RSSIForDM(
  1184. IN OUT PDM_ODM_T pDM_Odm
  1185. )
  1186. {
  1187. }
  1188. VOID
  1189. odm_Process_RSSIForDM(
  1190. IN OUT PDM_ODM_T pDM_Odm,
  1191. IN PODM_PHY_INFO_T pPhyInfo,
  1192. IN PODM_PACKET_INFO_T pPktinfo
  1193. )
  1194. {
  1195. s4Byte UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK, UndecoratedSmoothedOFDM, RSSI_Ave;
  1196. u1Byte isCCKrate=0;
  1197. u1Byte RSSI_max, RSSI_min, i;
  1198. u4Byte OFDM_pkt=0;
  1199. u4Byte Weighting=0;
  1200. PSTA_INFO_T pEntry;
  1201. if(pPktinfo->StationID == 0xFF)
  1202. return;
  1203. //
  1204. // 2012/05/30 MH/Luke.Lee Add some description
  1205. // In windows driver: AP/IBSS mode STA
  1206. //
  1207. //if (pDM_Odm->SupportPlatform == ODM_WIN)
  1208. //{
  1209. // pEntry = pDM_Odm->pODM_StaInfo[pDM_Odm->pAidMap[pPktinfo->StationID-1]];
  1210. //}
  1211. //else
  1212. pEntry = pDM_Odm->pODM_StaInfo[pPktinfo->StationID];
  1213. if(!IS_STA_VALID(pEntry) ){
  1214. return;
  1215. }
  1216. if((!pPktinfo->bPacketMatchBSSID) )
  1217. {
  1218. return;
  1219. }
  1220. if(pPktinfo->bPacketBeacon)
  1221. pDM_Odm->PhyDbgInfo.NumQryBeaconPkt++;
  1222. isCCKrate = (pPktinfo->DataRate <= DESC92C_RATE11M)?TRUE :FALSE;
  1223. pDM_Odm->RxRate = pPktinfo->DataRate;
  1224. /*
  1225. if(!isCCKrate)
  1226. {
  1227. DbgPrint("OFDM: pPktinfo->StationID=%d, isCCKrate=%d, pPhyInfo->RxPWDBAll=%d\n",
  1228. pPktinfo->StationID, isCCKrate, pPhyInfo->RxPWDBAll);
  1229. }
  1230. */
  1231. #if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
  1232. #if ((RTL8192C_SUPPORT == 1) ||(RTL8192D_SUPPORT == 1))
  1233. if(pDM_Odm->SupportICType & ODM_RTL8192C|ODM_RTL8192D)
  1234. {
  1235. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon)
  1236. {
  1237. //if(pPktinfo->bPacketBeacon)
  1238. //{
  1239. // DbgPrint("This is beacon, isCCKrate=%d\n", isCCKrate);
  1240. //}
  1241. ODM_AntselStatistics_88C(pDM_Odm, pPktinfo->StationID, pPhyInfo->RxPWDBAll, isCCKrate);
  1242. }
  1243. }
  1244. #endif
  1245. //-----------------Smart Antenna Debug Message------------------//
  1246. #if (RTL8188E_SUPPORT == 1)
  1247. if(pDM_Odm->SupportICType == ODM_RTL8188E)
  1248. {
  1249. u1Byte antsel_tr_mux;
  1250. pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
  1251. if(pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)
  1252. {
  1253. if(pDM_FatTable->FAT_State == FAT_TRAINING_STATE)
  1254. {
  1255. if(pPktinfo->bPacketToSelf) //(pPktinfo->bPacketMatchBSSID && (!pPktinfo->bPacketBeacon))
  1256. {
  1257. antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) |(pDM_FatTable->antsel_rx_keep_1 <<1) |pDM_FatTable->antsel_rx_keep_0;
  1258. pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll;
  1259. pDM_FatTable->antRSSIcnt[antsel_tr_mux]++;
  1260. //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("isCCKrate=%d, PWDB_ALL=%d\n",isCCKrate, pPhyInfo->RxPWDBAll));
  1261. //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("antsel_tr_mux=3'b%d%d%d\n",
  1262. //pDM_FatTable->antsel_rx_keep_2, pDM_FatTable->antsel_rx_keep_1, pDM_FatTable->antsel_rx_keep_0));
  1263. }
  1264. }
  1265. }
  1266. else if((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV)||(pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV))
  1267. {
  1268. //if(pPktinfo->bPacketToSelf) //Suggested by Luke, 121009
  1269. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketMatchBSSID)
  1270. {
  1271. antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) |(pDM_FatTable->antsel_rx_keep_1 <<1) |pDM_FatTable->antsel_rx_keep_0;
  1272. //ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD,("antsel_tr_mux=3'b%d%d%d\n",
  1273. // pDM_FatTable->antsel_rx_keep_2, pDM_FatTable->antsel_rx_keep_1, pDM_FatTable->antsel_rx_keep_0));
  1274. ODM_AntselStatistics_88E(pDM_Odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll);
  1275. }
  1276. }
  1277. }
  1278. #endif
  1279. #if (RTL8821A_SUPPORT == 1)
  1280. if(pDM_Odm->SupportICType == ODM_RTL8821)
  1281. {
  1282. pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
  1283. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketMatchBSSID)
  1284. {
  1285. if(pPktinfo->DataRate > DESC8812_RATE11M)
  1286. ODM_AntselStatistics_8821A(pDM_Odm, pDM_FatTable->antsel_rx_keep_0, pPktinfo->StationID, pPhyInfo->RxPWDBAll);
  1287. }
  1288. }
  1289. #endif
  1290. #endif //#if(defined(CONFIG_HW_ANTENNA_DIVERSITY))
  1291. #if (RTL8812A_SUPPORT == 1)
  1292. /*
  1293. if(pDM_Odm->SupportICType == ODM_RTL8812)
  1294. {
  1295. pPATHDIV_T pDM_PathDiv = &pDM_Odm->DM_PathDiv;
  1296. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketMatchBSSID)
  1297. {
  1298. if(pPktinfo->DataRate > DESC8812_RATE11M)
  1299. ODM_PathStatistics_8812A(pDM_Odm, pPktinfo->StationID,
  1300. pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A], pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]);
  1301. }
  1302. }
  1303. */
  1304. #endif
  1305. #if (RTL8723B_SUPPORT == 1)
  1306. #if (defined(CONFIG_HW_ANTENNA_DIVERSITY))
  1307. if(pDM_Odm->SupportICType == ODM_RTL8723B) //not CCK rate
  1308. {
  1309. pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable;
  1310. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketMatchBSSID)
  1311. {
  1312. if(pPktinfo->DataRate > DESC92C_RATE11M)
  1313. ODM_AntselStatistics_8723B(pDM_Odm, pDM_FatTable->antsel_rx_keep_0, pPktinfo->StationID, pPhyInfo->RxPWDBAll);
  1314. else //CCK rate
  1315. ODM_AntselStatistics_8723B(pDM_Odm, pDM_FatTable->antsel_rx_keep_0, pPktinfo->StationID, pPhyInfo->RxPWDBAll);
  1316. }
  1317. }
  1318. #endif
  1319. #endif
  1320. //-----------------Smart Antenna Debug Message------------------//
  1321. UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK;
  1322. UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM;
  1323. UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB;
  1324. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon)
  1325. {
  1326. if(!isCCKrate)//ofdm rate
  1327. {
  1328. if(pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B] == 0){
  1329. RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A];
  1330. pDM_Odm->RSSI_A = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A];
  1331. pDM_Odm->RSSI_B = 0;
  1332. }
  1333. else
  1334. {
  1335. //DbgPrint("pRfd->Status.RxMIMOSignalStrength[0] = %d, pRfd->Status.RxMIMOSignalStrength[1] = %d \n",
  1336. //pRfd->Status.RxMIMOSignalStrength[0], pRfd->Status.RxMIMOSignalStrength[1]);
  1337. pDM_Odm->RSSI_A = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A];
  1338. pDM_Odm->RSSI_B = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B];
  1339. if(pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B])
  1340. {
  1341. RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A];
  1342. RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B];
  1343. }
  1344. else
  1345. {
  1346. RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B];
  1347. RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A];
  1348. }
  1349. if((RSSI_max -RSSI_min) < 3)
  1350. RSSI_Ave = RSSI_max;
  1351. else if((RSSI_max -RSSI_min) < 6)
  1352. RSSI_Ave = RSSI_max - 1;
  1353. else if((RSSI_max -RSSI_min) < 10)
  1354. RSSI_Ave = RSSI_max - 2;
  1355. else
  1356. RSSI_Ave = RSSI_max - 3;
  1357. }
  1358. //1 Process OFDM RSSI
  1359. if(UndecoratedSmoothedOFDM <= 0) // initialize
  1360. {
  1361. UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll;
  1362. }
  1363. else
  1364. {
  1365. if(pPhyInfo->RxPWDBAll > (u4Byte)UndecoratedSmoothedOFDM)
  1366. {
  1367. UndecoratedSmoothedOFDM =
  1368. ( ((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) +
  1369. (RSSI_Ave)) /(Rx_Smooth_Factor);
  1370. UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1;
  1371. }
  1372. else
  1373. {
  1374. UndecoratedSmoothedOFDM =
  1375. ( ((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) +
  1376. (RSSI_Ave)) /(Rx_Smooth_Factor);
  1377. }
  1378. }
  1379. pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0;
  1380. }
  1381. else
  1382. {
  1383. RSSI_Ave = pPhyInfo->RxPWDBAll;
  1384. pDM_Odm->RSSI_A = (u1Byte) pPhyInfo->RxPWDBAll;
  1385. pDM_Odm->RSSI_B = 0xFF;
  1386. //1 Process CCK RSSI
  1387. if(UndecoratedSmoothedCCK <= 0) // initialize
  1388. {
  1389. UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll;
  1390. }
  1391. else
  1392. {
  1393. if(pPhyInfo->RxPWDBAll > (u4Byte)UndecoratedSmoothedCCK)
  1394. {
  1395. UndecoratedSmoothedCCK =
  1396. ( ((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) +
  1397. (pPhyInfo->RxPWDBAll)) /(Rx_Smooth_Factor);
  1398. UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1;
  1399. }
  1400. else
  1401. {
  1402. UndecoratedSmoothedCCK =
  1403. ( ((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) +
  1404. (pPhyInfo->RxPWDBAll)) /(Rx_Smooth_Factor);
  1405. }
  1406. }
  1407. pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1;
  1408. }
  1409. //if(pEntry)
  1410. {
  1411. //2011.07.28 LukeLee: modified to prevent unstable CCK RSSI
  1412. if(pEntry->rssi_stat.ValidBit >= 64)
  1413. pEntry->rssi_stat.ValidBit = 64;
  1414. else
  1415. pEntry->rssi_stat.ValidBit++;
  1416. for(i=0; i<pEntry->rssi_stat.ValidBit; i++)
  1417. OFDM_pkt += (u1Byte)(pEntry->rssi_stat.PacketMap>>i)&BIT0;
  1418. if(pEntry->rssi_stat.ValidBit == 64)
  1419. {
  1420. Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4);
  1421. UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6;
  1422. }
  1423. else
  1424. {
  1425. if(pEntry->rssi_stat.ValidBit != 0)
  1426. UndecoratedSmoothedPWDB = (OFDM_pkt*UndecoratedSmoothedOFDM+(pEntry->rssi_stat.ValidBit-OFDM_pkt)*UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit;
  1427. else
  1428. UndecoratedSmoothedPWDB = 0;
  1429. }
  1430. pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK;
  1431. pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM;
  1432. pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB;
  1433. //DbgPrint("OFDM_pkt=%d, Weighting=%d\n", OFDM_pkt, Weighting);
  1434. //DbgPrint("UndecoratedSmoothedOFDM=%d, UndecoratedSmoothedPWDB=%d, UndecoratedSmoothedCCK=%d\n",
  1435. // UndecoratedSmoothedOFDM, UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK);
  1436. }
  1437. }
  1438. }
  1439. //
  1440. // Endianness before calling this API
  1441. //
  1442. VOID
  1443. ODM_PhyStatusQuery_92CSeries(
  1444. IN OUT PDM_ODM_T pDM_Odm,
  1445. OUT PODM_PHY_INFO_T pPhyInfo,
  1446. IN pu1Byte pPhyStatus,
  1447. IN PODM_PACKET_INFO_T pPktinfo
  1448. )
  1449. {
  1450. odm_RxPhyStatus92CSeries_Parsing(
  1451. pDM_Odm,
  1452. pPhyInfo,
  1453. pPhyStatus,
  1454. pPktinfo);
  1455. if( pDM_Odm->RSSI_test == TRUE)
  1456. {
  1457. // Select the packets to do RSSI checking for antenna switching.
  1458. if(pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon )
  1459. {
  1460. /*
  1461. #if 0//(DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1462. dm_SWAW_RSSI_Check(
  1463. Adapter,
  1464. (tmppAdapter!=NULL)?(tmppAdapter==Adapter):TRUE,
  1465. bPacketMatchBSSID,
  1466. pEntry,
  1467. pRfd);
  1468. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
  1469. // Select the packets to do RSSI checking for antenna switching.
  1470. //odm_SwAntDivRSSICheck8192C(padapter, precvframe->u.hdr.attrib.RxPWDBAll);
  1471. #endif
  1472. */
  1473. ODM_SwAntDivChkPerPktRssi(pDM_Odm,pPktinfo->StationID,pPhyInfo);
  1474. }
  1475. }
  1476. else
  1477. {
  1478. odm_Process_RSSIForDM(pDM_Odm,pPhyInfo,pPktinfo);
  1479. }
  1480. }
  1481. //
  1482. // Endianness before calling this API
  1483. //
  1484. VOID
  1485. ODM_PhyStatusQuery_JaguarSeries(
  1486. IN OUT PDM_ODM_T pDM_Odm,
  1487. OUT PODM_PHY_INFO_T pPhyInfo,
  1488. IN pu1Byte pPhyStatus,
  1489. IN PODM_PACKET_INFO_T pPktinfo
  1490. )
  1491. {
  1492. odm_RxPhyStatusJaguarSeries_Parsing(
  1493. pDM_Odm,
  1494. pPhyInfo,
  1495. pPhyStatus,
  1496. pPktinfo);
  1497. odm_Process_RSSIForDM(pDM_Odm,pPhyInfo,pPktinfo);
  1498. }
  1499. VOID
  1500. ODM_PhyStatusQuery(
  1501. IN OUT PDM_ODM_T pDM_Odm,
  1502. OUT PODM_PHY_INFO_T pPhyInfo,
  1503. IN pu1Byte pPhyStatus,
  1504. IN PODM_PACKET_INFO_T pPktinfo
  1505. )
  1506. {
  1507. if(pDM_Odm->SupportICType & ODM_IC_11AC_SERIES )
  1508. {
  1509. ODM_PhyStatusQuery_JaguarSeries(pDM_Odm,pPhyInfo,pPhyStatus,pPktinfo);
  1510. }
  1511. else
  1512. {
  1513. ODM_PhyStatusQuery_92CSeries(pDM_Odm,pPhyInfo,pPhyStatus,pPktinfo);
  1514. }
  1515. }
  1516. // For future use.
  1517. VOID
  1518. ODM_MacStatusQuery(
  1519. IN OUT PDM_ODM_T pDM_Odm,
  1520. IN pu1Byte pMacStatus,
  1521. IN u1Byte MacID,
  1522. IN BOOLEAN bPacketMatchBSSID,
  1523. IN BOOLEAN bPacketToSelf,
  1524. IN BOOLEAN bPacketBeacon
  1525. )
  1526. {
  1527. // 2011/10/19 Driver team will handle in the future.
  1528. }
  1529. //
  1530. // If you want to add a new IC, Please follow below template and generate a new one.
  1531. //
  1532. //
  1533. HAL_STATUS
  1534. ODM_ConfigRFWithHeaderFile(
  1535. IN PDM_ODM_T pDM_Odm,
  1536. IN ODM_RF_Config_Type ConfigType,
  1537. IN ODM_RF_RADIO_PATH_E eRFPath
  1538. )
  1539. {
  1540. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1541. ("===>ODM_ConfigRFWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
  1542. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1543. ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
  1544. pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
  1545. #if (RTL8723A_SUPPORT == 1)
  1546. if (pDM_Odm->SupportICType == ODM_RTL8723A)
  1547. {
  1548. if(ConfigType == CONFIG_RF_RADIO) {
  1549. if(eRFPath == ODM_RF_PATH_A)
  1550. READ_AND_CONFIG_MP(8723A,_RadioA_1T);
  1551. }
  1552. }
  1553. #endif
  1554. #if (RTL8188E_SUPPORT == 1)
  1555. if (pDM_Odm->SupportICType == ODM_RTL8188E)
  1556. {
  1557. if(ConfigType == CONFIG_RF_RADIO) {
  1558. if(eRFPath == ODM_RF_PATH_A)
  1559. READ_AND_CONFIG(8188E,_RadioA_1T);
  1560. }
  1561. else if(ConfigType == CONFIG_RF_TXPWR_LMT) {
  1562. READ_AND_CONFIG(8188E,_TXPWR_LMT);
  1563. }
  1564. }
  1565. #endif
  1566. #if (RTL8812A_SUPPORT == 1)
  1567. if (pDM_Odm->SupportICType == ODM_RTL8812)
  1568. {
  1569. if(ConfigType == CONFIG_RF_RADIO) {
  1570. if(eRFPath == ODM_RF_PATH_A)
  1571. {
  1572. READ_AND_CONFIG(8812A,_RadioA);
  1573. }
  1574. else if(eRFPath == ODM_RF_PATH_B)
  1575. {
  1576. READ_AND_CONFIG(8812A,_RadioB);
  1577. }
  1578. }
  1579. else if(ConfigType == CONFIG_RF_TXPWR_LMT) {
  1580. READ_AND_CONFIG(8812A,_TXPWR_LMT);
  1581. }
  1582. }
  1583. #endif
  1584. #if (RTL8821A_SUPPORT == 1)
  1585. if (pDM_Odm->SupportICType == ODM_RTL8821)
  1586. {
  1587. if(ConfigType == CONFIG_RF_RADIO) {
  1588. if(eRFPath == ODM_RF_PATH_A)
  1589. {
  1590. READ_AND_CONFIG(8821A,_RadioA);
  1591. }
  1592. }
  1593. else if(ConfigType == CONFIG_RF_TXPWR_LMT) {
  1594. READ_AND_CONFIG(8821A,_TXPWR_LMT);
  1595. }
  1596. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("<===8821_ODM_ConfigRFWithHeaderFile\n"));
  1597. }
  1598. #endif
  1599. #if (RTL8723B_SUPPORT == 1)
  1600. if (pDM_Odm->SupportICType == ODM_RTL8723B)
  1601. {
  1602. if(eRFPath == ODM_RF_PATH_A)
  1603. READ_AND_CONFIG(8723B,_RadioA);
  1604. }
  1605. #endif
  1606. #if (RTL8192E_SUPPORT == 1)
  1607. if (pDM_Odm->SupportICType == ODM_RTL8192E)
  1608. {
  1609. if(eRFPath == ODM_RF_PATH_A)
  1610. READ_AND_CONFIG(8192E,_RadioA);
  1611. else if(eRFPath == ODM_RF_PATH_B)
  1612. READ_AND_CONFIG(8192E,_RadioB);
  1613. }
  1614. #endif
  1615. return HAL_STATUS_SUCCESS;
  1616. }
  1617. HAL_STATUS
  1618. ODM_ConfigRFWithTxPwrTrackHeaderFile(
  1619. IN PDM_ODM_T pDM_Odm
  1620. )
  1621. {
  1622. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1623. ("===>ODM_ConfigRFWithTxPwrTrackHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
  1624. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1625. ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
  1626. pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
  1627. #if (RTL8821A_SUPPORT == 1)
  1628. if (pDM_Odm->SupportICType == ODM_RTL8821)
  1629. {
  1630. if (pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  1631. READ_AND_CONFIG(8821A,_TxPowerTrack_PCIE);
  1632. else if (pDM_Odm->SupportInterface == ODM_ITRF_USB)
  1633. READ_AND_CONFIG(8821A,_TxPowerTrack_USB);
  1634. }
  1635. #endif
  1636. #if (RTL8812A_SUPPORT == 1)
  1637. if (pDM_Odm->SupportICType == ODM_RTL8812)
  1638. {
  1639. if (pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  1640. READ_AND_CONFIG(8812A,_TxPowerTrack_PCIE);
  1641. else if (pDM_Odm->SupportInterface == ODM_ITRF_USB) {
  1642. if (pDM_Odm->RFEType == 3 && pDM_Odm->bIsMPChip)
  1643. READ_AND_CONFIG_MP(8812A,_TxPowerTrack_USB_RFE3);
  1644. else
  1645. READ_AND_CONFIG(8812A,_TxPowerTrack_USB);
  1646. }
  1647. }
  1648. #endif
  1649. #if (RTL8192E_SUPPORT == 1)
  1650. if(pDM_Odm->SupportICType == ODM_RTL8192E)
  1651. {
  1652. if (pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  1653. READ_AND_CONFIG(8192E,_TxPowerTrack_PCIE);
  1654. else if (pDM_Odm->SupportInterface == ODM_ITRF_USB)
  1655. READ_AND_CONFIG(8192E,_TxPowerTrack_USB);
  1656. }
  1657. #endif
  1658. #if RTL8723B_SUPPORT
  1659. if(pDM_Odm->SupportICType == ODM_RTL8723B)
  1660. {
  1661. if (pDM_Odm->SupportInterface == ODM_ITRF_PCIE)
  1662. READ_AND_CONFIG(8723B,_TxPowerTrack_PCIE);
  1663. else if (pDM_Odm->SupportInterface == ODM_ITRF_USB)
  1664. READ_AND_CONFIG(8723B,_TxPowerTrack_USB);
  1665. // else if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO)
  1666. // READ_AND_CONFIG(8723B,_TxPowerTrack_SDIO_);
  1667. }
  1668. #endif
  1669. return HAL_STATUS_SUCCESS;
  1670. }
  1671. HAL_STATUS
  1672. ODM_ConfigBBWithHeaderFile(
  1673. IN PDM_ODM_T pDM_Odm,
  1674. IN ODM_BB_Config_Type ConfigType
  1675. )
  1676. {
  1677. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  1678. PADAPTER Adapter = pDM_Odm->Adapter;
  1679. PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo);
  1680. #endif
  1681. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1682. ("===>ODM_ConfigBBWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
  1683. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1684. ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
  1685. pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
  1686. #if (RTL8723A_SUPPORT == 1)
  1687. if(pDM_Odm->SupportICType == ODM_RTL8723A)
  1688. {
  1689. if(ConfigType == CONFIG_BB_PHY_REG)
  1690. {
  1691. READ_AND_CONFIG_MP(8723A,_PHY_REG_1T);
  1692. }
  1693. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1694. {
  1695. READ_AND_CONFIG_MP(8723A,_AGC_TAB_1T);
  1696. }
  1697. }
  1698. #endif
  1699. #if (RTL8188E_SUPPORT == 1)
  1700. if(pDM_Odm->SupportICType == ODM_RTL8188E)
  1701. {
  1702. if(ConfigType == CONFIG_BB_PHY_REG)
  1703. {
  1704. READ_AND_CONFIG(8188E,_PHY_REG_1T);
  1705. }
  1706. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1707. {
  1708. READ_AND_CONFIG(8188E,_AGC_TAB_1T);
  1709. }
  1710. else if(ConfigType == CONFIG_BB_PHY_REG_PG)
  1711. {
  1712. READ_AND_CONFIG(8188E,_PHY_REG_PG);
  1713. }
  1714. }
  1715. #endif
  1716. #if (RTL8812A_SUPPORT == 1)
  1717. if(pDM_Odm->SupportICType == ODM_RTL8812)
  1718. {
  1719. if(ConfigType == CONFIG_BB_PHY_REG)
  1720. {
  1721. READ_AND_CONFIG(8812A,_PHY_REG);
  1722. }
  1723. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1724. {
  1725. READ_AND_CONFIG(8812A,_AGC_TAB);
  1726. }
  1727. else if(ConfigType == CONFIG_BB_PHY_REG_PG)
  1728. {
  1729. if (pDM_Odm->RFEType == 3 && pDM_Odm->bIsMPChip)
  1730. READ_AND_CONFIG_MP(8812A,_PHY_REG_PG_ASUS);
  1731. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  1732. else if (pMgntInfo->CustomerID == RT_CID_WNC_NEC && pDM_Odm->bIsMPChip)
  1733. READ_AND_CONFIG_MP(8812A,_PHY_REG_PG_NEC);
  1734. #endif
  1735. else
  1736. READ_AND_CONFIG(8812A,_PHY_REG_PG);
  1737. }
  1738. else if(ConfigType == CONFIG_BB_PHY_REG_MP)
  1739. {
  1740. READ_AND_CONFIG_MP(8812A,_PHY_REG_MP);
  1741. }
  1742. ODM_RT_TRACE(pDM_Odm,ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() phy:Rtl8812AGCTABArray\n"));
  1743. ODM_RT_TRACE(pDM_Odm,ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8812PHY_REGArray\n"));
  1744. }
  1745. #endif
  1746. #if (RTL8821A_SUPPORT == 1)
  1747. if(pDM_Odm->SupportICType == ODM_RTL8821)
  1748. {
  1749. if(ConfigType == CONFIG_BB_PHY_REG)
  1750. {
  1751. READ_AND_CONFIG(8821A,_PHY_REG);
  1752. }
  1753. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1754. {
  1755. READ_AND_CONFIG(8821A,_AGC_TAB);
  1756. }
  1757. else if(ConfigType == CONFIG_BB_PHY_REG_PG)
  1758. {
  1759. READ_AND_CONFIG(8821A,_PHY_REG_PG);
  1760. }
  1761. ODM_RT_TRACE(pDM_Odm,ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() phy:Rtl8821AGCTABArray\n"));
  1762. ODM_RT_TRACE(pDM_Odm,ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8821PHY_REGArray\n"));
  1763. }
  1764. #endif
  1765. #if (RTL8723B_SUPPORT == 1)
  1766. if(pDM_Odm->SupportICType == ODM_RTL8723B)
  1767. {
  1768. if(ConfigType == CONFIG_BB_PHY_REG)
  1769. {
  1770. READ_AND_CONFIG(8723B,_PHY_REG);
  1771. }
  1772. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1773. {
  1774. READ_AND_CONFIG(8723B,_AGC_TAB);
  1775. }
  1776. else if(ConfigType == CONFIG_BB_PHY_REG_PG)
  1777. {
  1778. READ_AND_CONFIG(8723B,_PHY_REG_PG);
  1779. }
  1780. }
  1781. #endif
  1782. #if (RTL8192E_SUPPORT == 1)
  1783. if(pDM_Odm->SupportICType == ODM_RTL8192E)
  1784. {
  1785. if(ConfigType == CONFIG_BB_PHY_REG)
  1786. {
  1787. READ_AND_CONFIG(8192E,_PHY_REG);
  1788. }
  1789. else if(ConfigType == CONFIG_BB_AGC_TAB)
  1790. {
  1791. READ_AND_CONFIG(8192E,_AGC_TAB);
  1792. }
  1793. else if(ConfigType == CONFIG_BB_PHY_REG_PG)
  1794. {
  1795. //READ_AND_CONFIG(8192E,_PHY_REG_PG);
  1796. }
  1797. }
  1798. #endif
  1799. return HAL_STATUS_SUCCESS;
  1800. }
  1801. HAL_STATUS
  1802. ODM_ConfigMACWithHeaderFile(
  1803. IN PDM_ODM_T pDM_Odm
  1804. )
  1805. {
  1806. u1Byte result = HAL_STATUS_SUCCESS;
  1807. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1808. ("===>ODM_ConfigMACWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip"));
  1809. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1810. ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n",
  1811. pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType));
  1812. #if (RTL8723A_SUPPORT == 1)
  1813. if (pDM_Odm->SupportICType == ODM_RTL8723A)
  1814. {
  1815. READ_AND_CONFIG_MP(8723A,_MAC_REG);
  1816. }
  1817. #endif
  1818. #if (RTL8188E_SUPPORT == 1)
  1819. if (pDM_Odm->SupportICType == ODM_RTL8188E)
  1820. {
  1821. result = READ_AND_CONFIG(8188E,_MAC_REG);
  1822. }
  1823. #endif
  1824. #if (RTL8812A_SUPPORT == 1)
  1825. if (pDM_Odm->SupportICType == ODM_RTL8812)
  1826. {
  1827. READ_AND_CONFIG(8812A,_MAC_REG);
  1828. }
  1829. #endif
  1830. #if (RTL8821A_SUPPORT == 1)
  1831. if (pDM_Odm->SupportICType == ODM_RTL8821)
  1832. {
  1833. READ_AND_CONFIG(8821A,_MAC_REG);
  1834. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("<===8821_ODM_ConfigMACwithHeaderFile\n"));
  1835. }
  1836. #endif
  1837. #if (RTL8723B_SUPPORT == 1)
  1838. if (pDM_Odm->SupportICType == ODM_RTL8723B)
  1839. {
  1840. READ_AND_CONFIG(8723B,_MAC_REG);
  1841. }
  1842. #endif
  1843. #if (RTL8192E_SUPPORT == 1)
  1844. if (pDM_Odm->SupportICType == ODM_RTL8192E)
  1845. {
  1846. READ_AND_CONFIG(8192E,_MAC_REG);
  1847. }
  1848. #endif
  1849. return result;
  1850. }
  1851. HAL_STATUS
  1852. ODM_ConfigFWWithHeaderFile(
  1853. IN PDM_ODM_T pDM_Odm,
  1854. IN ODM_FW_Config_Type ConfigType,
  1855. OUT u1Byte *pFirmware,
  1856. OUT u4Byte *pSize
  1857. )
  1858. {
  1859. #if (RTL8188E_SUPPORT == 1)
  1860. if (pDM_Odm->SupportICType == ODM_RTL8188E)
  1861. {
  1862. if (ConfigType == CONFIG_FW_NIC)
  1863. {
  1864. READ_FIRMWARE(8188E,_FW_NIC);
  1865. }
  1866. else if (ConfigType == CONFIG_FW_WoWLAN)
  1867. {
  1868. READ_FIRMWARE(8188E,_FW_WoWLAN);
  1869. }
  1870. /* else if(ConfigType == CONFIG_FW_NIC_2)
  1871. {
  1872. READ_FIRMWARE_MP(8188E,_FW_NIC_S);
  1873. }
  1874. else if (ConfigType == CONFIG_FW_WoWLAN_2)
  1875. {
  1876. READ_FIRMWARE_MP(8188E,_FW_WoWLAN_S);
  1877. }*/
  1878. }
  1879. #endif
  1880. #if (RTL8723B_SUPPORT == 1)
  1881. if (pDM_Odm->SupportICType == ODM_RTL8723B)
  1882. {
  1883. if (ConfigType == CONFIG_FW_NIC)
  1884. {
  1885. READ_FIRMWARE(8723B,_FW_NIC);
  1886. }
  1887. #ifdef CONFIG_WOWLAN
  1888. else if (ConfigType == CONFIG_FW_WoWLAN)
  1889. {
  1890. READ_FIRMWARE(8723B,_FW_WOWLAN);
  1891. }
  1892. #endif
  1893. // else if (ConfigType == CONFIG_FW_BT)
  1894. // {
  1895. // READ_FIRMWARE_MP(8723B,_FW_BT);
  1896. // }
  1897. }
  1898. #endif
  1899. #if (RTL8812A_SUPPORT == 1)
  1900. if (pDM_Odm->SupportICType == ODM_RTL8812)
  1901. {
  1902. if (ConfigType == CONFIG_FW_NIC)
  1903. {
  1904. READ_FIRMWARE(8812A,_FW_NIC);
  1905. }
  1906. else if (ConfigType == CONFIG_FW_WoWLAN)
  1907. {
  1908. READ_FIRMWARE(8812A,_FW_WoWLAN);
  1909. }
  1910. else if (ConfigType == CONFIG_FW_BT)
  1911. {
  1912. READ_FIRMWARE(8812A,_FW_NIC_BT);
  1913. }
  1914. }
  1915. #endif
  1916. #if (RTL8821A_SUPPORT == 1)
  1917. if (pDM_Odm->SupportICType == ODM_RTL8821)
  1918. {
  1919. if (ConfigType == CONFIG_FW_NIC)
  1920. {
  1921. READ_FIRMWARE(8821A,_FW_NIC);
  1922. }
  1923. else if (ConfigType == CONFIG_FW_WoWLAN)
  1924. {
  1925. READ_FIRMWARE(8821A,_FW_WoWLAN);
  1926. }
  1927. else if (ConfigType == CONFIG_FW_BT)
  1928. {
  1929. READ_FIRMWARE(8821A,_FW_BT);
  1930. }
  1931. }
  1932. #endif
  1933. #if (RTL8192E_SUPPORT == 1)
  1934. if (pDM_Odm->SupportICType == ODM_RTL8192E)
  1935. {
  1936. if (ConfigType == CONFIG_FW_NIC)
  1937. {
  1938. READ_FIRMWARE(8192E,_FW_NIC);
  1939. }
  1940. else if (ConfigType == CONFIG_FW_WoWLAN)
  1941. {
  1942. READ_FIRMWARE(8192E,_FW_WoWLAN);
  1943. }
  1944. }
  1945. #endif
  1946. return HAL_STATUS_SUCCESS;
  1947. }