baseband.c 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095
  1. /*
  2. * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
  3. * All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. *
  20. * File: baseband.c
  21. *
  22. * Purpose: Implement functions to access baseband
  23. *
  24. * Author: Jerry Chen
  25. *
  26. * Date: Jun. 5, 2002
  27. *
  28. * Functions:
  29. * BBuGetFrameTime - Calculate data frame transmitting time
  30. * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
  31. * BBbVT3184Init - VIA VT3184 baseband chip init code
  32. * BBvLoopbackOn - Turn on BaseBand Loopback mode
  33. * BBvLoopbackOff - Turn off BaseBand Loopback mode
  34. *
  35. * Revision History:
  36. *
  37. *
  38. */
  39. #include "tmacro.h"
  40. #include "tether.h"
  41. #include "mac.h"
  42. #include "baseband.h"
  43. #include "rf.h"
  44. #include "srom.h"
  45. #include "control.h"
  46. #include "datarate.h"
  47. #include "rndis.h"
  48. /*--------------------- Static Definitions -------------------------*/
  49. static int msglevel =MSG_LEVEL_INFO;
  50. //static int msglevel =MSG_LEVEL_DEBUG;
  51. /*--------------------- Static Classes ----------------------------*/
  52. /*--------------------- Static Variables --------------------------*/
  53. /*--------------------- Static Functions --------------------------*/
  54. /*--------------------- Export Variables --------------------------*/
  55. /*--------------------- Static Definitions -------------------------*/
  56. /*--------------------- Static Classes ----------------------------*/
  57. /*--------------------- Static Variables --------------------------*/
  58. BYTE abyVT3184_AGC[] = {
  59. 0x00, //0
  60. 0x00, //1
  61. 0x02, //2
  62. 0x02, //3 //RobertYu:20060505, 0x04, //3
  63. 0x04, //4
  64. 0x04, //5 //RobertYu:20060505, 0x06, //5
  65. 0x06, //6
  66. 0x06, //7
  67. 0x08, //8
  68. 0x08, //9
  69. 0x0A, //A
  70. 0x0A, //B
  71. 0x0C, //C
  72. 0x0C, //D
  73. 0x0E, //E
  74. 0x0E, //F
  75. 0x10, //10
  76. 0x10, //11
  77. 0x12, //12
  78. 0x12, //13
  79. 0x14, //14
  80. 0x14, //15
  81. 0x16, //16
  82. 0x16, //17
  83. 0x18, //18
  84. 0x18, //19
  85. 0x1A, //1A
  86. 0x1A, //1B
  87. 0x1C, //1C
  88. 0x1C, //1D
  89. 0x1E, //1E
  90. 0x1E, //1F
  91. 0x20, //20
  92. 0x20, //21
  93. 0x22, //22
  94. 0x22, //23
  95. 0x24, //24
  96. 0x24, //25
  97. 0x26, //26
  98. 0x26, //27
  99. 0x28, //28
  100. 0x28, //29
  101. 0x2A, //2A
  102. 0x2A, //2B
  103. 0x2C, //2C
  104. 0x2C, //2D
  105. 0x2E, //2E
  106. 0x2E, //2F
  107. 0x30, //30
  108. 0x30, //31
  109. 0x32, //32
  110. 0x32, //33
  111. 0x34, //34
  112. 0x34, //35
  113. 0x36, //36
  114. 0x36, //37
  115. 0x38, //38
  116. 0x38, //39
  117. 0x3A, //3A
  118. 0x3A, //3B
  119. 0x3C, //3C
  120. 0x3C, //3D
  121. 0x3E, //3E
  122. 0x3E //3F
  123. };
  124. BYTE abyVT3184_AL2230[] = {
  125. 0x31,//00
  126. 0x00,
  127. 0x00,
  128. 0x00,
  129. 0x00,
  130. 0x80,
  131. 0x00,
  132. 0x00,
  133. 0x70,
  134. 0x45,//tx //0x64 for FPGA
  135. 0x2A,
  136. 0x76,
  137. 0x00,
  138. 0x00,
  139. 0x80,
  140. 0x00,
  141. 0x00,//10
  142. 0x00,
  143. 0x00,
  144. 0x00,
  145. 0x00,
  146. 0x00,
  147. 0x00,
  148. 0x00,
  149. 0x00,
  150. 0x00,
  151. 0x00,
  152. 0x8e, //RobertYu:20060522, //0x8d,
  153. 0x0a, //RobertYu:20060515, //0x09,
  154. 0x00,
  155. 0x00,
  156. 0x00,
  157. 0x00,//20
  158. 0x00,
  159. 0x00,
  160. 0x00,
  161. 0x00,
  162. 0x4a,
  163. 0x00,
  164. 0x00,
  165. 0x00,
  166. 0x00,
  167. 0x00,
  168. 0x00,
  169. 0x00,
  170. 0x4a,
  171. 0x00,
  172. 0x0c, //RobertYu:20060522, //0x10,
  173. 0x26,//30
  174. 0x5b,
  175. 0x00,
  176. 0x00,
  177. 0x00,
  178. 0x00,
  179. 0xaa,
  180. 0xaa,
  181. 0xff,
  182. 0xff,
  183. 0x79,
  184. 0x00,
  185. 0x00,
  186. 0x0b,
  187. 0x48,
  188. 0x04,
  189. 0x00,//40
  190. 0x08,
  191. 0x00,
  192. 0x08,
  193. 0x08,
  194. 0x14,
  195. 0x05,
  196. 0x09,
  197. 0x00,
  198. 0x00,
  199. 0x00,
  200. 0x00,
  201. 0x09,
  202. 0x73,
  203. 0x00,
  204. 0xc5,
  205. 0x00,//50 //RobertYu:20060505, //0x15,//50
  206. 0x19,
  207. 0x00,
  208. 0x00,
  209. 0x00,
  210. 0x00,
  211. 0x00,
  212. 0x00,
  213. 0x00,
  214. 0xd0, //RobertYu:20060505, //0xb0,
  215. 0x00,
  216. 0x00,
  217. 0x00,
  218. 0x00,
  219. 0x00,
  220. 0x00,
  221. 0xe4,//60
  222. 0x80,
  223. 0x00,
  224. 0x00,
  225. 0x00,
  226. 0x00,
  227. 0x98,
  228. 0x0a,
  229. 0x00,
  230. 0x00,
  231. 0x00,
  232. 0x00,
  233. 0x00, //0x80 for FPGA
  234. 0x03,
  235. 0x01,
  236. 0x00,
  237. 0x00,//70
  238. 0x00,
  239. 0x00,
  240. 0x00,
  241. 0x00,
  242. 0x00,
  243. 0x00,
  244. 0x00,
  245. 0x00,
  246. 0x00,
  247. 0x00,
  248. 0x00,
  249. 0x00,
  250. 0x00,
  251. 0x00,
  252. 0x00,
  253. 0x8c,//80
  254. 0x01,
  255. 0x09,
  256. 0x00,
  257. 0x00,
  258. 0x00,
  259. 0x00,
  260. 0x00,
  261. 0x08,
  262. 0x00,
  263. 0x1f, //RobertYu:20060516, //0x0f,
  264. 0xb7,
  265. 0x88,
  266. 0x47,
  267. 0xaa,
  268. 0x00, //RobertYu:20060505, //0x02,
  269. 0x20,//90 //RobertYu:20060505, //0x22,//90
  270. 0x00,
  271. 0x00,
  272. 0x00,
  273. 0x00,
  274. 0x00,
  275. 0x00,
  276. 0xeb,
  277. 0x00,
  278. 0x00,
  279. 0x00,
  280. 0x00,
  281. 0x00,
  282. 0x00,
  283. 0x00,
  284. 0x01,
  285. 0x00,//a0
  286. 0x00,
  287. 0x00,
  288. 0x00,
  289. 0x00,
  290. 0x00,
  291. 0x10,
  292. 0x00,
  293. 0x18,
  294. 0x00,
  295. 0x00,
  296. 0x00,
  297. 0x00,
  298. 0x15, //RobertYu:20060516, //0x00,
  299. 0x00,
  300. 0x18,
  301. 0x38,//b0
  302. 0x30,
  303. 0x00,
  304. 0x00,
  305. 0xff,
  306. 0x0f,
  307. 0xe4,
  308. 0xe2,
  309. 0x00,
  310. 0x00,
  311. 0x00,
  312. 0x03,
  313. 0x01,
  314. 0x00,
  315. 0x00,
  316. 0x00,
  317. 0x18,//c0
  318. 0x20,
  319. 0x07,
  320. 0x18,
  321. 0xff,
  322. 0xff, //RobertYu:20060509, //0x2c,
  323. 0x0e, //RobertYu:20060530, //0x0c,
  324. 0x0a,
  325. 0x0e,
  326. 0x00, //RobertYu:20060505, //0x01,
  327. 0x82, //RobertYu:20060516, //0x8f,
  328. 0xa7,
  329. 0x3c,
  330. 0x10,
  331. 0x30, //RobertYu:20060627, //0x0b,
  332. 0x05, //RobertYu:20060516, //0x25,
  333. 0x40,//d0
  334. 0x12,
  335. 0x00,
  336. 0x00,
  337. 0x10,
  338. 0x28,
  339. 0x80,
  340. 0x2A,
  341. 0x00,
  342. 0x00,
  343. 0x00,
  344. 0x00,
  345. 0x00,
  346. 0x00,
  347. 0x00,
  348. 0x00,
  349. 0x00,//e0
  350. 0xf3, //RobertYu:20060516, //0xd3,
  351. 0x00,
  352. 0x00,
  353. 0x00,
  354. 0x10,
  355. 0x00,
  356. 0x12, //RobertYu:20060627, //0x10,
  357. 0x00,
  358. 0xf4,
  359. 0x00,
  360. 0xff,
  361. 0x79,
  362. 0x20,
  363. 0x30,
  364. 0x05, //RobertYu:20060516, //0x0c,
  365. 0x00,//f0
  366. 0x3e,
  367. 0x00,
  368. 0x00,
  369. 0x00,
  370. 0x00,
  371. 0x00,
  372. 0x00,
  373. 0x00,
  374. 0x00,
  375. 0x00,
  376. 0x00,
  377. 0x00,
  378. 0x00,
  379. 0x00,
  380. 0x00
  381. };
  382. //{{RobertYu:20060515, new BB setting for VT3226D0
  383. BYTE abyVT3184_VT3226D0[] = {
  384. 0x31,//00
  385. 0x00,
  386. 0x00,
  387. 0x00,
  388. 0x00,
  389. 0x80,
  390. 0x00,
  391. 0x00,
  392. 0x70,
  393. 0x45,//tx //0x64 for FPGA
  394. 0x2A,
  395. 0x76,
  396. 0x00,
  397. 0x00,
  398. 0x80,
  399. 0x00,
  400. 0x00,//10
  401. 0x00,
  402. 0x00,
  403. 0x00,
  404. 0x00,
  405. 0x00,
  406. 0x00,
  407. 0x00,
  408. 0x00,
  409. 0x00,
  410. 0x00,
  411. 0x8e, //RobertYu:20060525, //0x8d,
  412. 0x0a, //RobertYu:20060515, //0x09,
  413. 0x00,
  414. 0x00,
  415. 0x00,
  416. 0x00,//20
  417. 0x00,
  418. 0x00,
  419. 0x00,
  420. 0x00,
  421. 0x4a,
  422. 0x00,
  423. 0x00,
  424. 0x00,
  425. 0x00,
  426. 0x00,
  427. 0x00,
  428. 0x00,
  429. 0x4a,
  430. 0x00,
  431. 0x0c, //RobertYu:20060525, //0x10,
  432. 0x26,//30
  433. 0x5b,
  434. 0x00,
  435. 0x00,
  436. 0x00,
  437. 0x00,
  438. 0xaa,
  439. 0xaa,
  440. 0xff,
  441. 0xff,
  442. 0x79,
  443. 0x00,
  444. 0x00,
  445. 0x0b,
  446. 0x48,
  447. 0x04,
  448. 0x00,//40
  449. 0x08,
  450. 0x00,
  451. 0x08,
  452. 0x08,
  453. 0x14,
  454. 0x05,
  455. 0x09,
  456. 0x00,
  457. 0x00,
  458. 0x00,
  459. 0x00,
  460. 0x09,
  461. 0x73,
  462. 0x00,
  463. 0xc5,
  464. 0x00,//50 //RobertYu:20060505, //0x15,//50
  465. 0x19,
  466. 0x00,
  467. 0x00,
  468. 0x00,
  469. 0x00,
  470. 0x00,
  471. 0x00,
  472. 0x00,
  473. 0xd0, //RobertYu:20060505, //0xb0,
  474. 0x00,
  475. 0x00,
  476. 0x00,
  477. 0x00,
  478. 0x00,
  479. 0x00,
  480. 0xe4,//60
  481. 0x80,
  482. 0x00,
  483. 0x00,
  484. 0x00,
  485. 0x00,
  486. 0x98,
  487. 0x0a,
  488. 0x00,
  489. 0x00,
  490. 0x00,
  491. 0x00,
  492. 0x00, //0x80 for FPGA
  493. 0x03,
  494. 0x01,
  495. 0x00,
  496. 0x00,//70
  497. 0x00,
  498. 0x00,
  499. 0x00,
  500. 0x00,
  501. 0x00,
  502. 0x00,
  503. 0x00,
  504. 0x00,
  505. 0x00,
  506. 0x00,
  507. 0x00,
  508. 0x00,
  509. 0x00,
  510. 0x00,
  511. 0x00,
  512. 0x8c,//80
  513. 0x01,
  514. 0x09,
  515. 0x00,
  516. 0x00,
  517. 0x00,
  518. 0x00,
  519. 0x00,
  520. 0x08,
  521. 0x00,
  522. 0x1f, //RobertYu:20060515, //0x0f,
  523. 0xb7,
  524. 0x88,
  525. 0x47,
  526. 0xaa,
  527. 0x00, //RobertYu:20060505, //0x02,
  528. 0x20,//90 //RobertYu:20060505, //0x22,//90
  529. 0x00,
  530. 0x00,
  531. 0x00,
  532. 0x00,
  533. 0x00,
  534. 0x00,
  535. 0xeb,
  536. 0x00,
  537. 0x00,
  538. 0x00,
  539. 0x00,
  540. 0x00,
  541. 0x00,
  542. 0x00,
  543. 0x01,
  544. 0x00,//a0
  545. 0x00,
  546. 0x00,
  547. 0x00,
  548. 0x00,
  549. 0x00,
  550. 0x10,
  551. 0x00,
  552. 0x18,
  553. 0x00,
  554. 0x00,
  555. 0x00,
  556. 0x00,
  557. 0x00,
  558. 0x00,
  559. 0x18,
  560. 0x38,//b0
  561. 0x30,
  562. 0x00,
  563. 0x00,
  564. 0xff,
  565. 0x0f,
  566. 0xe4,
  567. 0xe2,
  568. 0x00,
  569. 0x00,
  570. 0x00,
  571. 0x03,
  572. 0x01,
  573. 0x00,
  574. 0x00,
  575. 0x00,
  576. 0x18,//c0
  577. 0x20,
  578. 0x07,
  579. 0x18,
  580. 0xff,
  581. 0xff, //RobertYu:20060509, //0x2c,
  582. 0x10, //RobertYu:20060525, //0x0c,
  583. 0x0a,
  584. 0x0e,
  585. 0x00, //RobertYu:20060505, //0x01,
  586. 0x84, //RobertYu:20060525, //0x8f,
  587. 0xa7,
  588. 0x3c,
  589. 0x10,
  590. 0x24, //RobertYu:20060627, //0x18,
  591. 0x05, //RobertYu:20060515, //0x25,
  592. 0x40,//d0
  593. 0x12,
  594. 0x00,
  595. 0x00,
  596. 0x10,
  597. 0x28,
  598. 0x80,
  599. 0x2A,
  600. 0x00,
  601. 0x00,
  602. 0x00,
  603. 0x00,
  604. 0x00,
  605. 0x00,
  606. 0x00,
  607. 0x00,
  608. 0x00,//e0
  609. 0xf3, //RobertYu:20060515, //0xd3,
  610. 0x00,
  611. 0x00,
  612. 0x00,
  613. 0x10,
  614. 0x00,
  615. 0x10, //RobertYu:20060627, //0x0e,
  616. 0x00,
  617. 0xf4,
  618. 0x00,
  619. 0xff,
  620. 0x79,
  621. 0x20,
  622. 0x30,
  623. 0x08, //RobertYu:20060515, //0x0c,
  624. 0x00,//f0
  625. 0x3e,
  626. 0x00,
  627. 0x00,
  628. 0x00,
  629. 0x00,
  630. 0x00,
  631. 0x00,
  632. 0x00,
  633. 0x00,
  634. 0x00,
  635. 0x00,
  636. 0x00,
  637. 0x00,
  638. 0x00,
  639. 0x00,
  640. };
  641. const WORD awcFrameTime[MAX_RATE] =
  642. {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
  643. /*--------------------- Static Functions --------------------------*/
  644. /*
  645. static
  646. unsigned long
  647. s_ulGetLowSQ3(PSDevice pDevice);
  648. static
  649. unsigned long
  650. s_ulGetRatio(PSDevice pDevice);
  651. static
  652. void
  653. s_vClearSQ3Value(PSDevice pDevice);
  654. */
  655. /*--------------------- Export Variables --------------------------*/
  656. /*
  657. * Description: Calculate data frame transmitting time
  658. *
  659. * Parameters:
  660. * In:
  661. * byPreambleType - Preamble Type
  662. * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
  663. * cbFrameLength - Baseband Type
  664. * wRate - Tx Rate
  665. * Out:
  666. *
  667. * Return Value: FrameTime
  668. *
  669. */
  670. unsigned int
  671. BBuGetFrameTime (
  672. BYTE byPreambleType,
  673. BYTE byPktType,
  674. unsigned int cbFrameLength,
  675. WORD wRate
  676. )
  677. {
  678. unsigned int uFrameTime;
  679. unsigned int uPreamble;
  680. unsigned int uTmp;
  681. unsigned int uRateIdx = (unsigned int)wRate;
  682. unsigned int uRate = 0;
  683. if (uRateIdx > RATE_54M) {
  684. ASSERT(0);
  685. return 0;
  686. }
  687. uRate = (unsigned int)awcFrameTime[uRateIdx];
  688. if (uRateIdx <= 3) { //CCK mode
  689. if (byPreambleType == 1) {//Short
  690. uPreamble = 96;
  691. } else {
  692. uPreamble = 192;
  693. }
  694. uFrameTime = (cbFrameLength * 80) / uRate; //?????
  695. uTmp = (uFrameTime * uRate) / 80;
  696. if (cbFrameLength != uTmp) {
  697. uFrameTime ++;
  698. }
  699. return (uPreamble + uFrameTime);
  700. }
  701. else {
  702. uFrameTime = (cbFrameLength * 8 + 22) / uRate; //????????
  703. uTmp = ((uFrameTime * uRate) - 22) / 8;
  704. if(cbFrameLength != uTmp) {
  705. uFrameTime ++;
  706. }
  707. uFrameTime = uFrameTime * 4; //???????
  708. if(byPktType != PK_TYPE_11A) {
  709. uFrameTime += 6;
  710. }
  711. return (20 + uFrameTime); //??????
  712. }
  713. }
  714. /*
  715. * Description: Caculate Length, Service, and Signal fields of Phy for Tx
  716. *
  717. * Parameters:
  718. * In:
  719. * pDevice - Device Structure
  720. * cbFrameLength - Tx Frame Length
  721. * wRate - Tx Rate
  722. * Out:
  723. * pwPhyLen - pointer to Phy Length field
  724. * pbyPhySrv - pointer to Phy Service field
  725. * pbyPhySgn - pointer to Phy Signal field
  726. *
  727. * Return Value: none
  728. *
  729. */
  730. void
  731. BBvCaculateParameter (
  732. PSDevice pDevice,
  733. unsigned int cbFrameLength,
  734. WORD wRate,
  735. BYTE byPacketType,
  736. PWORD pwPhyLen,
  737. PBYTE pbyPhySrv,
  738. PBYTE pbyPhySgn
  739. )
  740. {
  741. unsigned int cbBitCount;
  742. unsigned int cbUsCount = 0;
  743. unsigned int cbTmp;
  744. BOOL bExtBit;
  745. BYTE byPreambleType = pDevice->byPreambleType;
  746. BOOL bCCK = pDevice->bCCK;
  747. cbBitCount = cbFrameLength * 8;
  748. bExtBit = FALSE;
  749. switch (wRate) {
  750. case RATE_1M :
  751. cbUsCount = cbBitCount;
  752. *pbyPhySgn = 0x00;
  753. break;
  754. case RATE_2M :
  755. cbUsCount = cbBitCount / 2;
  756. if (byPreambleType == 1)
  757. *pbyPhySgn = 0x09;
  758. else // long preamble
  759. *pbyPhySgn = 0x01;
  760. break;
  761. case RATE_5M :
  762. if (bCCK == FALSE)
  763. cbBitCount ++;
  764. cbUsCount = (cbBitCount * 10) / 55;
  765. cbTmp = (cbUsCount * 55) / 10;
  766. if (cbTmp != cbBitCount)
  767. cbUsCount ++;
  768. if (byPreambleType == 1)
  769. *pbyPhySgn = 0x0a;
  770. else // long preamble
  771. *pbyPhySgn = 0x02;
  772. break;
  773. case RATE_11M :
  774. if (bCCK == FALSE)
  775. cbBitCount ++;
  776. cbUsCount = cbBitCount / 11;
  777. cbTmp = cbUsCount * 11;
  778. if (cbTmp != cbBitCount) {
  779. cbUsCount ++;
  780. if ((cbBitCount - cbTmp) <= 3)
  781. bExtBit = TRUE;
  782. }
  783. if (byPreambleType == 1)
  784. *pbyPhySgn = 0x0b;
  785. else // long preamble
  786. *pbyPhySgn = 0x03;
  787. break;
  788. case RATE_6M :
  789. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  790. *pbyPhySgn = 0x9B; //1001 1011
  791. }
  792. else {//11g, 2.4GHZ
  793. *pbyPhySgn = 0x8B; //1000 1011
  794. }
  795. break;
  796. case RATE_9M :
  797. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  798. *pbyPhySgn = 0x9F; //1001 1111
  799. }
  800. else {//11g, 2.4GHZ
  801. *pbyPhySgn = 0x8F; //1000 1111
  802. }
  803. break;
  804. case RATE_12M :
  805. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  806. *pbyPhySgn = 0x9A; //1001 1010
  807. }
  808. else {//11g, 2.4GHZ
  809. *pbyPhySgn = 0x8A; //1000 1010
  810. }
  811. break;
  812. case RATE_18M :
  813. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  814. *pbyPhySgn = 0x9E; //1001 1110
  815. }
  816. else {//11g, 2.4GHZ
  817. *pbyPhySgn = 0x8E; //1000 1110
  818. }
  819. break;
  820. case RATE_24M :
  821. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  822. *pbyPhySgn = 0x99; //1001 1001
  823. }
  824. else {//11g, 2.4GHZ
  825. *pbyPhySgn = 0x89; //1000 1001
  826. }
  827. break;
  828. case RATE_36M :
  829. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  830. *pbyPhySgn = 0x9D; //1001 1101
  831. }
  832. else {//11g, 2.4GHZ
  833. *pbyPhySgn = 0x8D; //1000 1101
  834. }
  835. break;
  836. case RATE_48M :
  837. if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  838. *pbyPhySgn = 0x98; //1001 1000
  839. }
  840. else {//11g, 2.4GHZ
  841. *pbyPhySgn = 0x88; //1000 1000
  842. }
  843. break;
  844. case RATE_54M :
  845. if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  846. *pbyPhySgn = 0x9C; //1001 1100
  847. }
  848. else {//11g, 2.4GHZ
  849. *pbyPhySgn = 0x8C; //1000 1100
  850. }
  851. break;
  852. default :
  853. if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
  854. *pbyPhySgn = 0x9C; //1001 1100
  855. }
  856. else {//11g, 2.4GHZ
  857. *pbyPhySgn = 0x8C; //1000 1100
  858. }
  859. break;
  860. }
  861. if (byPacketType == PK_TYPE_11B) {
  862. *pbyPhySrv = 0x00;
  863. if (bExtBit)
  864. *pbyPhySrv = *pbyPhySrv | 0x80;
  865. *pwPhyLen = (WORD) cbUsCount;
  866. }
  867. else {
  868. *pbyPhySrv = 0x00;
  869. *pwPhyLen = (WORD)cbFrameLength;
  870. }
  871. }
  872. /*
  873. * Description: Set Antenna mode
  874. *
  875. * Parameters:
  876. * In:
  877. * pDevice - Device Structure
  878. * byAntennaMode - Antenna Mode
  879. * Out:
  880. * none
  881. *
  882. * Return Value: none
  883. *
  884. */
  885. void
  886. BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)
  887. {
  888. //{{ RobertYu: 20041124, ABG Mode, VC1/VC2 define, make the ANT_A, ANT_B inverted
  889. /*if ( (pDevice->byRFType == RF_MAXIM2829) ||
  890. (pDevice->byRFType == RF_UW2452) ||
  891. (pDevice->byRFType == RF_AIROHA7230) ) { // RobertYu: 20041210, 20050104
  892. switch (byAntennaMode) {
  893. case ANT_TXA:
  894. byAntennaMode = ANT_TXB;
  895. break;
  896. case ANT_TXB:
  897. byAntennaMode = ANT_TXA;
  898. break;
  899. case ANT_RXA:
  900. byAntennaMode = ANT_RXB;
  901. break;
  902. case ANT_RXB:
  903. byAntennaMode = ANT_RXA;
  904. break;
  905. }
  906. }*/
  907. switch (byAntennaMode) {
  908. case ANT_TXA:
  909. break;
  910. case ANT_TXB:
  911. break;
  912. case ANT_RXA:
  913. pDevice->byBBRxConf &= 0xFC;
  914. break;
  915. case ANT_RXB:
  916. pDevice->byBBRxConf &= 0xFE;
  917. pDevice->byBBRxConf |= 0x02;
  918. break;
  919. }
  920. CONTROLnsRequestOut(pDevice,
  921. MESSAGE_TYPE_SET_ANTMD,
  922. (WORD) byAntennaMode,
  923. 0,
  924. 0,
  925. NULL);
  926. }
  927. /*
  928. * Description: Set Antenna mode
  929. *
  930. * Parameters:
  931. * In:
  932. * pDevice - Device Structure
  933. * byAntennaMode - Antenna Mode
  934. * Out:
  935. * none
  936. *
  937. * Return Value: none
  938. *
  939. */
  940. BOOL BBbVT3184Init(PSDevice pDevice)
  941. {
  942. int ntStatus;
  943. WORD wLength;
  944. PBYTE pbyAddr;
  945. PBYTE pbyAgc;
  946. WORD wLengthAgc;
  947. BYTE abyArray[256];
  948. ntStatus = CONTROLnsRequestIn(pDevice,
  949. MESSAGE_TYPE_READ,
  950. 0,
  951. MESSAGE_REQUEST_EEPROM,
  952. EEP_MAX_CONTEXT_SIZE,
  953. pDevice->abyEEPROM);
  954. if (ntStatus != STATUS_SUCCESS) {
  955. return FALSE;
  956. }
  957. // if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
  958. // return FALSE;
  959. //zonetype initial
  960. pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
  961. if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
  962. if ((pDevice->config_file.ZoneType == 0)&&
  963. (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
  964. pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
  965. pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
  966. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
  967. }
  968. else if((pDevice->config_file.ZoneType == 1)&&
  969. (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
  970. pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
  971. pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
  972. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n");
  973. }
  974. else if((pDevice->config_file.ZoneType == 2)&&
  975. (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
  976. pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
  977. pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
  978. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
  979. }
  980. else {
  981. if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
  982. printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
  983. else
  984. printk("Read Zonetype file success,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType);
  985. }
  986. }
  987. if ( !pDevice->bZoneRegExist ) {
  988. pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
  989. }
  990. pDevice->byRFType = pDevice->abyEEPROM[EEP_OFS_RFTYPE];
  991. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", pDevice->byZoneType);
  992. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", pDevice->byRFType);
  993. if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) {
  994. pDevice->byBBRxConf = abyVT3184_AL2230[10];
  995. wLength = sizeof(abyVT3184_AL2230);
  996. pbyAddr = abyVT3184_AL2230;
  997. pbyAgc = abyVT3184_AGC;
  998. wLengthAgc = sizeof(abyVT3184_AGC);
  999. pDevice->abyBBVGA[0] = 0x1C;
  1000. pDevice->abyBBVGA[1] = 0x10;
  1001. pDevice->abyBBVGA[2] = 0x0;
  1002. pDevice->abyBBVGA[3] = 0x0;
  1003. pDevice->ldBmThreshold[0] = -70;
  1004. pDevice->ldBmThreshold[1] = -48;
  1005. pDevice->ldBmThreshold[2] = 0;
  1006. pDevice->ldBmThreshold[3] = 0;
  1007. }
  1008. else if (pDevice->byRFType == RF_AIROHA7230) {
  1009. pDevice->byBBRxConf = abyVT3184_AL2230[10];
  1010. wLength = sizeof(abyVT3184_AL2230);
  1011. pbyAddr = abyVT3184_AL2230;
  1012. pbyAgc = abyVT3184_AGC;
  1013. wLengthAgc = sizeof(abyVT3184_AGC);
  1014. // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
  1015. //pbyAddr[0x09] = 0x41;
  1016. // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
  1017. //pbyAddr[0x0a] = 0x28;
  1018. // Select VC1/VC2, CR215 = 0x02->0x06
  1019. pbyAddr[0xd7] = 0x06;
  1020. pDevice->abyBBVGA[0] = 0x1C;
  1021. pDevice->abyBBVGA[1] = 0x10;
  1022. pDevice->abyBBVGA[2] = 0x0;
  1023. pDevice->abyBBVGA[3] = 0x0;
  1024. pDevice->ldBmThreshold[0] = -70;
  1025. pDevice->ldBmThreshold[1] = -48;
  1026. pDevice->ldBmThreshold[2] = 0;
  1027. pDevice->ldBmThreshold[3] = 0;
  1028. }
  1029. else if ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) {
  1030. pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; //RobertYu:20060515
  1031. wLength = sizeof(abyVT3184_VT3226D0); //RobertYu:20060515
  1032. pbyAddr = abyVT3184_VT3226D0; //RobertYu:20060515
  1033. pbyAgc = abyVT3184_AGC;
  1034. wLengthAgc = sizeof(abyVT3184_AGC);
  1035. pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack
  1036. pDevice->abyBBVGA[1] = 0x10;
  1037. pDevice->abyBBVGA[2] = 0x0;
  1038. pDevice->abyBBVGA[3] = 0x0;
  1039. pDevice->ldBmThreshold[0] = -70;
  1040. pDevice->ldBmThreshold[1] = -48;
  1041. pDevice->ldBmThreshold[2] = 0;
  1042. pDevice->ldBmThreshold[3] = 0;
  1043. // Fix VT3226 DFC system timing issue
  1044. MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
  1045. //}}
  1046. //{{RobertYu:20060609
  1047. } else if ( (pDevice->byRFType == RF_VT3342A0) ) {
  1048. pDevice->byBBRxConf = abyVT3184_VT3226D0[10];
  1049. wLength = sizeof(abyVT3184_VT3226D0);
  1050. pbyAddr = abyVT3184_VT3226D0;
  1051. pbyAgc = abyVT3184_AGC;
  1052. wLengthAgc = sizeof(abyVT3184_AGC);
  1053. pDevice->abyBBVGA[0] = 0x20;
  1054. pDevice->abyBBVGA[1] = 0x10;
  1055. pDevice->abyBBVGA[2] = 0x0;
  1056. pDevice->abyBBVGA[3] = 0x0;
  1057. pDevice->ldBmThreshold[0] = -70;
  1058. pDevice->ldBmThreshold[1] = -48;
  1059. pDevice->ldBmThreshold[2] = 0;
  1060. pDevice->ldBmThreshold[3] = 0;
  1061. // Fix VT3226 DFC system timing issue
  1062. MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
  1063. //}}
  1064. } else {
  1065. return TRUE;
  1066. }
  1067. memcpy(abyArray, pbyAddr, wLength);
  1068. CONTROLnsRequestOut(pDevice,
  1069. MESSAGE_TYPE_WRITE,
  1070. 0,
  1071. MESSAGE_REQUEST_BBREG,
  1072. wLength,
  1073. abyArray
  1074. );
  1075. memcpy(abyArray, pbyAgc, wLengthAgc);
  1076. CONTROLnsRequestOut(pDevice,
  1077. MESSAGE_TYPE_WRITE,
  1078. 0,
  1079. MESSAGE_REQUEST_BBAGC,
  1080. wLengthAgc,
  1081. abyArray
  1082. );
  1083. if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0
  1084. (pDevice->byRFType == RF_VT3342A0) //RobertYu:20060609
  1085. ) {
  1086. ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23);
  1087. MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
  1088. }
  1089. else if (pDevice->byRFType == RF_VT3226D0)
  1090. {
  1091. ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11);
  1092. MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
  1093. }
  1094. ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F);
  1095. ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
  1096. RFbRFTableDownload(pDevice);
  1097. return TRUE;//ntStatus;
  1098. }
  1099. /*
  1100. * Description: Turn on BaseBand Loopback mode
  1101. *
  1102. * Parameters:
  1103. * In:
  1104. * pDevice - Device Structure
  1105. *
  1106. * Out:
  1107. * none
  1108. *
  1109. * Return Value: none
  1110. *
  1111. */
  1112. void BBvLoopbackOn (PSDevice pDevice)
  1113. {
  1114. BYTE byData;
  1115. //CR C9 = 0x00
  1116. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xC9, &pDevice->byBBCRc9);//CR201
  1117. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0);
  1118. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x4D, &pDevice->byBBCR4d);//CR77
  1119. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, 0x90);
  1120. //CR 88 = 0x02(CCK), 0x03(OFDM)
  1121. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x88, &pDevice->byBBCR88);//CR136
  1122. if (pDevice->wCurrentRate <= RATE_11M) { //CCK
  1123. // Enable internal digital loopback: CR33 |= 0000 0001
  1124. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
  1125. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData | 0x01));//CR33
  1126. // CR154 = 0x00
  1127. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, 0); //CR154
  1128. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);//CR239
  1129. }
  1130. else { //OFDM
  1131. // Enable internal digital loopback:CR154 |= 0000 0001
  1132. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
  1133. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData | 0x01));//CR154
  1134. // CR33 = 0x00
  1135. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, 0); //CR33
  1136. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);//CR239
  1137. }
  1138. //CR14 = 0x00
  1139. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, 0);//CR14
  1140. // Disable TX_IQUN
  1141. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x09, &pDevice->byBBCR09);
  1142. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x09, (BYTE)(pDevice->byBBCR09 & 0xDE));
  1143. }
  1144. /*
  1145. * Description: Turn off BaseBand Loopback mode
  1146. *
  1147. * Parameters:
  1148. * In:
  1149. * pDevice - Device Structure
  1150. *
  1151. * Out:
  1152. * none
  1153. *
  1154. * Return Value: none
  1155. *
  1156. */
  1157. void BBvLoopbackOff (PSDevice pDevice)
  1158. {
  1159. BYTE byData;
  1160. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, pDevice->byBBCRc9);//CR201
  1161. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, pDevice->byBBCR88);//CR136
  1162. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x09, pDevice->byBBCR09);//CR136
  1163. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, pDevice->byBBCR4d);//CR77
  1164. if (pDevice->wCurrentRate <= RATE_11M) { // CCK
  1165. // Set the CR33 Bit2 to disable internal Loopback.
  1166. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
  1167. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData & 0xFE));//CR33
  1168. }
  1169. else { // OFDM
  1170. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
  1171. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData & 0xFE));//CR154
  1172. }
  1173. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x0E, &byData);//CR14
  1174. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, (BYTE)(byData | 0x80));//CR14
  1175. }
  1176. /*
  1177. * Description: Set ShortSlotTime mode
  1178. *
  1179. * Parameters:
  1180. * In:
  1181. * pDevice - Device Structure
  1182. * Out:
  1183. * none
  1184. *
  1185. * Return Value: none
  1186. *
  1187. */
  1188. void
  1189. BBvSetShortSlotTime (PSDevice pDevice)
  1190. {
  1191. BYTE byBBVGA=0;
  1192. if (pDevice->bShortSlotTime) {
  1193. pDevice->byBBRxConf &= 0xDF;//1101 1111
  1194. } else {
  1195. pDevice->byBBRxConf |= 0x20;//0010 0000
  1196. }
  1197. ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
  1198. if (byBBVGA == pDevice->abyBBVGA[0]) {
  1199. pDevice->byBBRxConf |= 0x20;//0010 0000
  1200. }
  1201. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
  1202. }
  1203. void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
  1204. {
  1205. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
  1206. // patch for 3253B0 Baseband with Cardbus module
  1207. if (byData == pDevice->abyBBVGA[0]) {
  1208. pDevice->byBBRxConf |= 0x20;//0010 0000
  1209. } else if (pDevice->bShortSlotTime) {
  1210. pDevice->byBBRxConf &= 0xDF;//1101 1111
  1211. } else {
  1212. pDevice->byBBRxConf |= 0x20;//0010 0000
  1213. }
  1214. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
  1215. }
  1216. /*
  1217. * Description: Baseband SoftwareReset
  1218. *
  1219. * Parameters:
  1220. * In:
  1221. * dwIoBase - I/O base address
  1222. * Out:
  1223. * none
  1224. *
  1225. * Return Value: none
  1226. *
  1227. */
  1228. void
  1229. BBvSoftwareReset (PSDevice pDevice)
  1230. {
  1231. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0x40);
  1232. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0);
  1233. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0x01);
  1234. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0);
  1235. }
  1236. /*
  1237. * Description: BBvSetDeepSleep
  1238. *
  1239. * Parameters:
  1240. * In:
  1241. * pDevice - Device Structure
  1242. * Out:
  1243. * none
  1244. *
  1245. * Return Value: none
  1246. *
  1247. */
  1248. void
  1249. BBvSetDeepSleep (PSDevice pDevice)
  1250. {
  1251. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
  1252. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
  1253. }
  1254. void
  1255. BBvExitDeepSleep (PSDevice pDevice)
  1256. {
  1257. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
  1258. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
  1259. }
  1260. static unsigned long s_ulGetLowSQ3(PSDevice pDevice)
  1261. {
  1262. int ii;
  1263. unsigned long ulSQ3 = 0;
  1264. unsigned long ulMaxPacket;
  1265. ulMaxPacket = pDevice->aulPktNum[RATE_54M];
  1266. if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
  1267. ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
  1268. }
  1269. for ( ii=RATE_48M;ii>=RATE_6M;ii-- ) {
  1270. if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
  1271. ulMaxPacket = pDevice->aulPktNum[ii];
  1272. ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
  1273. }
  1274. }
  1275. return ulSQ3;
  1276. }
  1277. static unsigned long s_ulGetRatio(PSDevice pDevice)
  1278. {
  1279. int ii, jj;
  1280. unsigned long ulRatio = 0;
  1281. unsigned long ulMaxPacket;
  1282. unsigned long ulPacketNum;
  1283. //This is a thousand-ratio
  1284. ulMaxPacket = pDevice->aulPktNum[RATE_54M];
  1285. if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
  1286. ulPacketNum = pDevice->aulPktNum[RATE_54M];
  1287. ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
  1288. ulRatio += TOP_RATE_54M;
  1289. }
  1290. for ( ii=RATE_48M;ii>=RATE_1M;ii-- ) {
  1291. if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
  1292. ulPacketNum = 0;
  1293. for ( jj=RATE_54M;jj>=ii;jj--)
  1294. ulPacketNum += pDevice->aulPktNum[jj];
  1295. ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
  1296. ulRatio += TOP_RATE_48M;
  1297. ulMaxPacket = pDevice->aulPktNum[ii];
  1298. }
  1299. }
  1300. return ulRatio;
  1301. }
  1302. static
  1303. void
  1304. s_vClearSQ3Value (PSDevice pDevice)
  1305. {
  1306. int ii;
  1307. pDevice->uDiversityCnt = 0;
  1308. for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
  1309. pDevice->aulPktNum[ii] = 0;
  1310. pDevice->aulSQ3Val[ii] = 0;
  1311. }
  1312. }
  1313. /*
  1314. * Description: Antenna Diversity
  1315. *
  1316. * Parameters:
  1317. * In:
  1318. * pDevice - Device Structure
  1319. * byRSR - RSR from received packet
  1320. * bySQ3 - SQ3 value from received packet
  1321. * Out:
  1322. * none
  1323. *
  1324. * Return Value: none
  1325. *
  1326. */
  1327. void
  1328. BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3)
  1329. {
  1330. pDevice->uDiversityCnt++;
  1331. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
  1332. if (byRxRate == 2) {
  1333. pDevice->aulPktNum[RATE_1M]++;
  1334. }
  1335. else if (byRxRate==4) {
  1336. pDevice->aulPktNum[RATE_2M]++;
  1337. }
  1338. else if (byRxRate==11) {
  1339. pDevice->aulPktNum[RATE_5M]++;
  1340. }
  1341. else if (byRxRate==22) {
  1342. pDevice->aulPktNum[RATE_11M]++;
  1343. }
  1344. else if(byRxRate==12){
  1345. pDevice->aulPktNum[RATE_6M]++;
  1346. pDevice->aulSQ3Val[RATE_6M] += bySQ3;
  1347. }
  1348. else if(byRxRate==18){
  1349. pDevice->aulPktNum[RATE_9M]++;
  1350. pDevice->aulSQ3Val[RATE_9M] += bySQ3;
  1351. }
  1352. else if(byRxRate==24){
  1353. pDevice->aulPktNum[RATE_12M]++;
  1354. pDevice->aulSQ3Val[RATE_12M] += bySQ3;
  1355. }
  1356. else if(byRxRate==36){
  1357. pDevice->aulPktNum[RATE_18M]++;
  1358. pDevice->aulSQ3Val[RATE_18M] += bySQ3;
  1359. }
  1360. else if(byRxRate==48){
  1361. pDevice->aulPktNum[RATE_24M]++;
  1362. pDevice->aulSQ3Val[RATE_24M] += bySQ3;
  1363. }
  1364. else if(byRxRate==72){
  1365. pDevice->aulPktNum[RATE_36M]++;
  1366. pDevice->aulSQ3Val[RATE_36M] += bySQ3;
  1367. }
  1368. else if(byRxRate==96){
  1369. pDevice->aulPktNum[RATE_48M]++;
  1370. pDevice->aulSQ3Val[RATE_48M] += bySQ3;
  1371. }
  1372. else if(byRxRate==108){
  1373. pDevice->aulPktNum[RATE_54M]++;
  1374. pDevice->aulSQ3Val[RATE_54M] += bySQ3;
  1375. }
  1376. if (pDevice->byAntennaState == 0) {
  1377. if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
  1378. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
  1379. pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
  1380. pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
  1381. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
  1382. if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
  1383. (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
  1384. (pDevice->ulSQ3_State0 == 0 ) ) {
  1385. if ( pDevice->byTMax == 0 )
  1386. return;
  1387. bScheduleCommand((void *) pDevice,
  1388. WLAN_CMD_CHANGE_ANTENNA,
  1389. NULL);
  1390. pDevice->byAntennaState = 1;
  1391. del_timer(&pDevice->TimerSQ3Tmax3);
  1392. del_timer(&pDevice->TimerSQ3Tmax2);
  1393. pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
  1394. add_timer(&pDevice->TimerSQ3Tmax1);
  1395. } else {
  1396. pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
  1397. add_timer(&pDevice->TimerSQ3Tmax3);
  1398. }
  1399. s_vClearSQ3Value(pDevice);
  1400. }
  1401. } else { //byAntennaState == 1
  1402. if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
  1403. del_timer(&pDevice->TimerSQ3Tmax1);
  1404. pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
  1405. pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
  1406. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
  1407. if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
  1408. ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
  1409. ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
  1410. ) {
  1411. bScheduleCommand((void *) pDevice,
  1412. WLAN_CMD_CHANGE_ANTENNA,
  1413. NULL);
  1414. pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
  1415. pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
  1416. add_timer(&pDevice->TimerSQ3Tmax3);
  1417. add_timer(&pDevice->TimerSQ3Tmax2);
  1418. }
  1419. pDevice->byAntennaState = 0;
  1420. s_vClearSQ3Value(pDevice);
  1421. }
  1422. } //byAntennaState
  1423. }
  1424. /*+
  1425. *
  1426. * Description:
  1427. * Timer for SQ3 antenna diversity
  1428. *
  1429. * Parameters:
  1430. * In:
  1431. * pvSysSpec1
  1432. * hDeviceContext - Pointer to the adapter
  1433. * pvSysSpec2
  1434. * pvSysSpec3
  1435. * Out:
  1436. * none
  1437. *
  1438. * Return Value: none
  1439. *
  1440. -*/
  1441. void TimerSQ3CallBack(void *hDeviceContext)
  1442. {
  1443. PSDevice pDevice = (PSDevice)hDeviceContext;
  1444. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
  1445. spin_lock_irq(&pDevice->lock);
  1446. bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
  1447. pDevice->byAntennaState = 0;
  1448. s_vClearSQ3Value(pDevice);
  1449. pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
  1450. pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
  1451. add_timer(&pDevice->TimerSQ3Tmax3);
  1452. add_timer(&pDevice->TimerSQ3Tmax2);
  1453. spin_unlock_irq(&pDevice->lock);
  1454. return;
  1455. }
  1456. /*+
  1457. *
  1458. * Description:
  1459. * Timer for SQ3 antenna diversity
  1460. *
  1461. * Parameters:
  1462. * In:
  1463. * pvSysSpec1
  1464. * hDeviceContext - Pointer to the adapter
  1465. * pvSysSpec2
  1466. * pvSysSpec3
  1467. * Out:
  1468. * none
  1469. *
  1470. * Return Value: none
  1471. *
  1472. -*/
  1473. void TimerSQ3Tmax3CallBack(void *hDeviceContext)
  1474. {
  1475. PSDevice pDevice = (PSDevice)hDeviceContext;
  1476. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
  1477. spin_lock_irq(&pDevice->lock);
  1478. pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
  1479. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
  1480. s_vClearSQ3Value(pDevice);
  1481. if ( pDevice->byTMax == 0 ) {
  1482. pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
  1483. add_timer(&pDevice->TimerSQ3Tmax3);
  1484. spin_unlock_irq(&pDevice->lock);
  1485. return;
  1486. }
  1487. bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
  1488. pDevice->byAntennaState = 1;
  1489. del_timer(&pDevice->TimerSQ3Tmax3);
  1490. del_timer(&pDevice->TimerSQ3Tmax2);
  1491. pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
  1492. add_timer(&pDevice->TimerSQ3Tmax1);
  1493. spin_unlock_irq(&pDevice->lock);
  1494. return;
  1495. }
  1496. void
  1497. BBvUpdatePreEDThreshold(
  1498. PSDevice pDevice,
  1499. BOOL bScanning)
  1500. {
  1501. switch(pDevice->byRFType)
  1502. {
  1503. case RF_AL2230:
  1504. case RF_AL2230S:
  1505. case RF_AIROHA7230:
  1506. //RobertYu:20060627, update new table
  1507. if( bScanning )
  1508. { // need Max sensitivity //RSSI -69, -70,....
  1509. if(pDevice->byBBPreEDIndex == 0) break;
  1510. pDevice->byBBPreEDIndex = 0;
  1511. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1512. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1513. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
  1514. break;
  1515. }
  1516. if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
  1517. if(pDevice->byBBPreEDIndex == 20) break;
  1518. pDevice->byBBPreEDIndex = 20;
  1519. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
  1520. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1521. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
  1522. } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
  1523. if(pDevice->byBBPreEDIndex == 19) break;
  1524. pDevice->byBBPreEDIndex = 19;
  1525. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
  1526. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1527. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
  1528. } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
  1529. if(pDevice->byBBPreEDIndex == 18) break;
  1530. pDevice->byBBPreEDIndex = 18;
  1531. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
  1532. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1533. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
  1534. } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
  1535. if(pDevice->byBBPreEDIndex == 17) break;
  1536. pDevice->byBBPreEDIndex = 17;
  1537. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
  1538. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1539. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
  1540. } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
  1541. if(pDevice->byBBPreEDIndex == 16) break;
  1542. pDevice->byBBPreEDIndex = 16;
  1543. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
  1544. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1545. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
  1546. } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
  1547. if(pDevice->byBBPreEDIndex == 15) break;
  1548. pDevice->byBBPreEDIndex = 15;
  1549. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
  1550. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1551. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
  1552. } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
  1553. if(pDevice->byBBPreEDIndex == 14) break;
  1554. pDevice->byBBPreEDIndex = 14;
  1555. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
  1556. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1557. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
  1558. } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
  1559. if(pDevice->byBBPreEDIndex == 13) break;
  1560. pDevice->byBBPreEDIndex = 13;
  1561. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1562. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
  1563. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
  1564. } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
  1565. if(pDevice->byBBPreEDIndex == 12) break;
  1566. pDevice->byBBPreEDIndex = 12;
  1567. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1568. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
  1569. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
  1570. } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
  1571. if(pDevice->byBBPreEDIndex == 11) break;
  1572. pDevice->byBBPreEDIndex = 11;
  1573. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1574. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
  1575. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
  1576. } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
  1577. if(pDevice->byBBPreEDIndex == 10) break;
  1578. pDevice->byBBPreEDIndex = 10;
  1579. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1580. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
  1581. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
  1582. } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
  1583. if(pDevice->byBBPreEDIndex == 9) break;
  1584. pDevice->byBBPreEDIndex = 9;
  1585. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1586. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
  1587. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
  1588. } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
  1589. if(pDevice->byBBPreEDIndex == 8) break;
  1590. pDevice->byBBPreEDIndex = 8;
  1591. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1592. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
  1593. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
  1594. } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
  1595. if(pDevice->byBBPreEDIndex == 7) break;
  1596. pDevice->byBBPreEDIndex = 7;
  1597. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1598. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
  1599. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
  1600. } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
  1601. if(pDevice->byBBPreEDIndex == 6) break;
  1602. pDevice->byBBPreEDIndex = 6;
  1603. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1604. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
  1605. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
  1606. } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
  1607. if(pDevice->byBBPreEDIndex == 5) break;
  1608. pDevice->byBBPreEDIndex = 5;
  1609. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1610. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
  1611. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
  1612. } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
  1613. if(pDevice->byBBPreEDIndex == 4) break;
  1614. pDevice->byBBPreEDIndex = 4;
  1615. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1616. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
  1617. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
  1618. } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
  1619. if(pDevice->byBBPreEDIndex == 3) break;
  1620. pDevice->byBBPreEDIndex = 3;
  1621. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1622. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
  1623. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
  1624. } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
  1625. if(pDevice->byBBPreEDIndex == 2) break;
  1626. pDevice->byBBPreEDIndex = 2;
  1627. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1628. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
  1629. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
  1630. } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
  1631. if(pDevice->byBBPreEDIndex == 1) break;
  1632. pDevice->byBBPreEDIndex = 1;
  1633. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1634. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
  1635. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
  1636. } else { //RSSI -69, -70,....
  1637. if(pDevice->byBBPreEDIndex == 0) break;
  1638. pDevice->byBBPreEDIndex = 0;
  1639. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1640. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1641. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
  1642. }
  1643. break;
  1644. case RF_VT3226:
  1645. case RF_VT3226D0:
  1646. //RobertYu:20060627, update new table
  1647. if( bScanning )
  1648. { // need Max sensitivity //RSSI -69, -70, ...
  1649. if(pDevice->byBBPreEDIndex == 0) break;
  1650. pDevice->byBBPreEDIndex = 0;
  1651. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1652. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
  1653. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
  1654. break;
  1655. }
  1656. if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
  1657. if(pDevice->byBBPreEDIndex == 22) break;
  1658. pDevice->byBBPreEDIndex = 22;
  1659. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
  1660. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1661. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
  1662. } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
  1663. if(pDevice->byBBPreEDIndex == 21) break;
  1664. pDevice->byBBPreEDIndex = 21;
  1665. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
  1666. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1667. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
  1668. } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
  1669. if(pDevice->byBBPreEDIndex == 20) break;
  1670. pDevice->byBBPreEDIndex = 20;
  1671. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
  1672. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1673. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
  1674. } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
  1675. if(pDevice->byBBPreEDIndex == 19) break;
  1676. pDevice->byBBPreEDIndex = 19;
  1677. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
  1678. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1679. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
  1680. } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
  1681. if(pDevice->byBBPreEDIndex == 18) break;
  1682. pDevice->byBBPreEDIndex = 18;
  1683. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
  1684. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1685. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
  1686. } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
  1687. if(pDevice->byBBPreEDIndex == 17) break;
  1688. pDevice->byBBPreEDIndex = 17;
  1689. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
  1690. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1691. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
  1692. } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
  1693. if(pDevice->byBBPreEDIndex == 16) break;
  1694. pDevice->byBBPreEDIndex = 16;
  1695. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
  1696. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1697. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
  1698. } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
  1699. if(pDevice->byBBPreEDIndex == 15) break;
  1700. pDevice->byBBPreEDIndex = 15;
  1701. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
  1702. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1703. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
  1704. } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
  1705. if(pDevice->byBBPreEDIndex == 14) break;
  1706. pDevice->byBBPreEDIndex = 14;
  1707. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1708. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
  1709. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
  1710. } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
  1711. if(pDevice->byBBPreEDIndex == 13) break;
  1712. pDevice->byBBPreEDIndex = 13;
  1713. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1714. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1715. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
  1716. } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
  1717. if(pDevice->byBBPreEDIndex == 12) break;
  1718. pDevice->byBBPreEDIndex = 12;
  1719. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1720. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
  1721. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
  1722. } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
  1723. if(pDevice->byBBPreEDIndex == 11) break;
  1724. pDevice->byBBPreEDIndex = 11;
  1725. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1726. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
  1727. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
  1728. } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
  1729. if(pDevice->byBBPreEDIndex == 10) break;
  1730. pDevice->byBBPreEDIndex = 10;
  1731. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1732. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1733. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
  1734. } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
  1735. if(pDevice->byBBPreEDIndex == 9) break;
  1736. pDevice->byBBPreEDIndex = 9;
  1737. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1738. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
  1739. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
  1740. } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
  1741. if(pDevice->byBBPreEDIndex == 8) break;
  1742. pDevice->byBBPreEDIndex = 8;
  1743. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1744. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
  1745. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
  1746. } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
  1747. if(pDevice->byBBPreEDIndex == 7) break;
  1748. pDevice->byBBPreEDIndex = 7;
  1749. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1750. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
  1751. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
  1752. } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
  1753. if(pDevice->byBBPreEDIndex == 6) break;
  1754. pDevice->byBBPreEDIndex = 6;
  1755. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1756. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
  1757. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
  1758. } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
  1759. if(pDevice->byBBPreEDIndex == 5) break;
  1760. pDevice->byBBPreEDIndex = 5;
  1761. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1762. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
  1763. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
  1764. } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
  1765. if(pDevice->byBBPreEDIndex == 4) break;
  1766. pDevice->byBBPreEDIndex = 4;
  1767. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1768. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
  1769. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
  1770. } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
  1771. if(pDevice->byBBPreEDIndex == 3) break;
  1772. pDevice->byBBPreEDIndex = 3;
  1773. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1774. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
  1775. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
  1776. } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
  1777. if(pDevice->byBBPreEDIndex == 2) break;
  1778. pDevice->byBBPreEDIndex = 2;
  1779. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1780. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
  1781. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
  1782. } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
  1783. if(pDevice->byBBPreEDIndex == 1) break;
  1784. pDevice->byBBPreEDIndex = 1;
  1785. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1786. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
  1787. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
  1788. } else { //RSSI -69, -70, ...
  1789. if(pDevice->byBBPreEDIndex == 0) break;
  1790. pDevice->byBBPreEDIndex = 0;
  1791. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1792. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
  1793. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
  1794. }
  1795. break;
  1796. case RF_VT3342A0: //RobertYu:20060627, testing table
  1797. if( bScanning )
  1798. { // need Max sensitivity //RSSI -67, -68, ...
  1799. if(pDevice->byBBPreEDIndex == 0) break;
  1800. pDevice->byBBPreEDIndex = 0;
  1801. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1802. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
  1803. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
  1804. break;
  1805. }
  1806. if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
  1807. if(pDevice->byBBPreEDIndex == 20) break;
  1808. pDevice->byBBPreEDIndex = 20;
  1809. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
  1810. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1811. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
  1812. } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
  1813. if(pDevice->byBBPreEDIndex == 19) break;
  1814. pDevice->byBBPreEDIndex = 19;
  1815. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
  1816. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1817. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
  1818. } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
  1819. if(pDevice->byBBPreEDIndex == 18) break;
  1820. pDevice->byBBPreEDIndex = 18;
  1821. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
  1822. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1823. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
  1824. } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
  1825. if(pDevice->byBBPreEDIndex == 17) break;
  1826. pDevice->byBBPreEDIndex = 17;
  1827. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
  1828. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1829. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
  1830. } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
  1831. if(pDevice->byBBPreEDIndex == 16) break;
  1832. pDevice->byBBPreEDIndex = 16;
  1833. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
  1834. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1835. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
  1836. } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
  1837. if(pDevice->byBBPreEDIndex == 15) break;
  1838. pDevice->byBBPreEDIndex = 15;
  1839. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
  1840. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1841. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
  1842. } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
  1843. if(pDevice->byBBPreEDIndex == 14) break;
  1844. pDevice->byBBPreEDIndex = 14;
  1845. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
  1846. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1847. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
  1848. } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
  1849. if(pDevice->byBBPreEDIndex == 13) break;
  1850. pDevice->byBBPreEDIndex = 13;
  1851. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
  1852. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
  1853. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
  1854. } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
  1855. if(pDevice->byBBPreEDIndex == 12) break;
  1856. pDevice->byBBPreEDIndex = 12;
  1857. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1858. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
  1859. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
  1860. } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
  1861. if(pDevice->byBBPreEDIndex == 11) break;
  1862. pDevice->byBBPreEDIndex = 11;
  1863. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
  1864. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1865. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
  1866. } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
  1867. if(pDevice->byBBPreEDIndex == 10) break;
  1868. pDevice->byBBPreEDIndex = 10;
  1869. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1870. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
  1871. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
  1872. } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
  1873. if(pDevice->byBBPreEDIndex == 9) break;
  1874. pDevice->byBBPreEDIndex = 9;
  1875. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1876. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
  1877. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
  1878. } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
  1879. if(pDevice->byBBPreEDIndex == 8) break;
  1880. pDevice->byBBPreEDIndex = 8;
  1881. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
  1882. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
  1883. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
  1884. } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
  1885. if(pDevice->byBBPreEDIndex == 7) break;
  1886. pDevice->byBBPreEDIndex = 7;
  1887. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1888. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
  1889. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
  1890. } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
  1891. if(pDevice->byBBPreEDIndex == 6) break;
  1892. pDevice->byBBPreEDIndex = 6;
  1893. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1894. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
  1895. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
  1896. } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
  1897. if(pDevice->byBBPreEDIndex == 5) break;
  1898. pDevice->byBBPreEDIndex = 5;
  1899. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1900. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
  1901. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
  1902. } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
  1903. if(pDevice->byBBPreEDIndex == 4) break;
  1904. pDevice->byBBPreEDIndex = 4;
  1905. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1906. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
  1907. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
  1908. } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
  1909. if(pDevice->byBBPreEDIndex == 3) break;
  1910. pDevice->byBBPreEDIndex = 3;
  1911. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1912. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
  1913. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
  1914. } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
  1915. if(pDevice->byBBPreEDIndex == 2) break;
  1916. pDevice->byBBPreEDIndex = 2;
  1917. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1918. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
  1919. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
  1920. } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
  1921. if(pDevice->byBBPreEDIndex == 1) break;
  1922. pDevice->byBBPreEDIndex = 1;
  1923. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1924. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
  1925. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
  1926. } else { //RSSI -67, -68, ...
  1927. if(pDevice->byBBPreEDIndex == 0) break;
  1928. pDevice->byBBPreEDIndex = 0;
  1929. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
  1930. ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
  1931. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
  1932. }
  1933. break;
  1934. }
  1935. }