mm-only debug patch...
[mmotm.git] / drivers / staging / vt6656 / baseband.c
blob820a7b8e6fb82dfcedbca8ed355383fd40ec8195
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
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.
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.
20 * File: baseband.c
22 * Purpose: Implement functions to access baseband
24 * Author: Jerry Chen
26 * Date: Jun. 5, 2002
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
35 * Revision History:
40 #include "tmacro.h"
41 #include "tether.h"
42 #include "mac.h"
43 #include "baseband.h"
44 #include "rf.h"
45 #include "srom.h"
46 #include "control.h"
47 #include "datarate.h"
48 #include "rndis.h"
49 #include "control.h"
51 /*--------------------- Static Definitions -------------------------*/
52 static int msglevel =MSG_LEVEL_INFO;
53 //static int msglevel =MSG_LEVEL_DEBUG;
55 /*--------------------- Static Classes ----------------------------*/
57 /*--------------------- Static Variables --------------------------*/
59 /*--------------------- Static Functions --------------------------*/
61 /*--------------------- Export Variables --------------------------*/
63 /*--------------------- Static Definitions -------------------------*/
65 /*--------------------- Static Classes ----------------------------*/
67 /*--------------------- Static Variables --------------------------*/
70 BYTE abyVT3184_AGC[] = {
71 0x00, //0
72 0x00, //1
73 0x02, //2
74 0x02, //3 //RobertYu:20060505, 0x04, //3
75 0x04, //4
76 0x04, //5 //RobertYu:20060505, 0x06, //5
77 0x06, //6
78 0x06, //7
79 0x08, //8
80 0x08, //9
81 0x0A, //A
82 0x0A, //B
83 0x0C, //C
84 0x0C, //D
85 0x0E, //E
86 0x0E, //F
87 0x10, //10
88 0x10, //11
89 0x12, //12
90 0x12, //13
91 0x14, //14
92 0x14, //15
93 0x16, //16
94 0x16, //17
95 0x18, //18
96 0x18, //19
97 0x1A, //1A
98 0x1A, //1B
99 0x1C, //1C
100 0x1C, //1D
101 0x1E, //1E
102 0x1E, //1F
103 0x20, //20
104 0x20, //21
105 0x22, //22
106 0x22, //23
107 0x24, //24
108 0x24, //25
109 0x26, //26
110 0x26, //27
111 0x28, //28
112 0x28, //29
113 0x2A, //2A
114 0x2A, //2B
115 0x2C, //2C
116 0x2C, //2D
117 0x2E, //2E
118 0x2E, //2F
119 0x30, //30
120 0x30, //31
121 0x32, //32
122 0x32, //33
123 0x34, //34
124 0x34, //35
125 0x36, //36
126 0x36, //37
127 0x38, //38
128 0x38, //39
129 0x3A, //3A
130 0x3A, //3B
131 0x3C, //3C
132 0x3C, //3D
133 0x3E, //3E
134 0x3E //3F
138 BYTE abyVT3184_AL2230[] = {
139 0x31,//00
140 0x00,
141 0x00,
142 0x00,
143 0x00,
144 0x80,
145 0x00,
146 0x00,
147 0x70,
148 0x45,//tx //0x64 for FPGA
149 0x2A,
150 0x76,
151 0x00,
152 0x00,
153 0x80,
154 0x00,
155 0x00,//10
156 0x00,
157 0x00,
158 0x00,
159 0x00,
160 0x00,
161 0x00,
162 0x00,
163 0x00,
164 0x00,
165 0x00,
166 0x8e, //RobertYu:20060522, //0x8d,
167 0x0a, //RobertYu:20060515, //0x09,
168 0x00,
169 0x00,
170 0x00,
171 0x00,//20
172 0x00,
173 0x00,
174 0x00,
175 0x00,
176 0x4a,
177 0x00,
178 0x00,
179 0x00,
180 0x00,
181 0x00,
182 0x00,
183 0x00,
184 0x4a,
185 0x00,
186 0x0c, //RobertYu:20060522, //0x10,
187 0x26,//30
188 0x5b,
189 0x00,
190 0x00,
191 0x00,
192 0x00,
193 0xaa,
194 0xaa,
195 0xff,
196 0xff,
197 0x79,
198 0x00,
199 0x00,
200 0x0b,
201 0x48,
202 0x04,
203 0x00,//40
204 0x08,
205 0x00,
206 0x08,
207 0x08,
208 0x14,
209 0x05,
210 0x09,
211 0x00,
212 0x00,
213 0x00,
214 0x00,
215 0x09,
216 0x73,
217 0x00,
218 0xc5,
219 0x00,//50 //RobertYu:20060505, //0x15,//50
220 0x19,
221 0x00,
222 0x00,
223 0x00,
224 0x00,
225 0x00,
226 0x00,
227 0x00,
228 0xd0, //RobertYu:20060505, //0xb0,
229 0x00,
230 0x00,
231 0x00,
232 0x00,
233 0x00,
234 0x00,
235 0xe4,//60
236 0x80,
237 0x00,
238 0x00,
239 0x00,
240 0x00,
241 0x98,
242 0x0a,
243 0x00,
244 0x00,
245 0x00,
246 0x00,
247 0x00, //0x80 for FPGA
248 0x03,
249 0x01,
250 0x00,
251 0x00,//70
252 0x00,
253 0x00,
254 0x00,
255 0x00,
256 0x00,
257 0x00,
258 0x00,
259 0x00,
260 0x00,
261 0x00,
262 0x00,
263 0x00,
264 0x00,
265 0x00,
266 0x00,
267 0x8c,//80
268 0x01,
269 0x09,
270 0x00,
271 0x00,
272 0x00,
273 0x00,
274 0x00,
275 0x08,
276 0x00,
277 0x1f, //RobertYu:20060516, //0x0f,
278 0xb7,
279 0x88,
280 0x47,
281 0xaa,
282 0x00, //RobertYu:20060505, //0x02,
283 0x20,//90 //RobertYu:20060505, //0x22,//90
284 0x00,
285 0x00,
286 0x00,
287 0x00,
288 0x00,
289 0x00,
290 0xeb,
291 0x00,
292 0x00,
293 0x00,
294 0x00,
295 0x00,
296 0x00,
297 0x00,
298 0x01,
299 0x00,//a0
300 0x00,
301 0x00,
302 0x00,
303 0x00,
304 0x00,
305 0x10,
306 0x00,
307 0x18,
308 0x00,
309 0x00,
310 0x00,
311 0x00,
312 0x15, //RobertYu:20060516, //0x00,
313 0x00,
314 0x18,
315 0x38,//b0
316 0x30,
317 0x00,
318 0x00,
319 0xff,
320 0x0f,
321 0xe4,
322 0xe2,
323 0x00,
324 0x00,
325 0x00,
326 0x03,
327 0x01,
328 0x00,
329 0x00,
330 0x00,
331 0x18,//c0
332 0x20,
333 0x07,
334 0x18,
335 0xff,
336 0xff, //RobertYu:20060509, //0x2c,
337 0x0e, //RobertYu:20060530, //0x0c,
338 0x0a,
339 0x0e,
340 0x00, //RobertYu:20060505, //0x01,
341 0x82, //RobertYu:20060516, //0x8f,
342 0xa7,
343 0x3c,
344 0x10,
345 0x30, //RobertYu:20060627, //0x0b,
346 0x05, //RobertYu:20060516, //0x25,
347 0x40,//d0
348 0x12,
349 0x00,
350 0x00,
351 0x10,
352 0x28,
353 0x80,
354 0x2A,
355 0x00,
356 0x00,
357 0x00,
358 0x00,
359 0x00,
360 0x00,
361 0x00,
362 0x00,
363 0x00,//e0
364 0xf3, //RobertYu:20060516, //0xd3,
365 0x00,
366 0x00,
367 0x00,
368 0x10,
369 0x00,
370 0x12, //RobertYu:20060627, //0x10,
371 0x00,
372 0xf4,
373 0x00,
374 0xff,
375 0x79,
376 0x20,
377 0x30,
378 0x05, //RobertYu:20060516, //0x0c,
379 0x00,//f0
380 0x3e,
381 0x00,
382 0x00,
383 0x00,
384 0x00,
385 0x00,
386 0x00,
387 0x00,
388 0x00,
389 0x00,
390 0x00,
391 0x00,
392 0x00,
393 0x00,
394 0x00
399 //{{RobertYu:20060515, new BB setting for VT3226D0
400 BYTE abyVT3184_VT3226D0[] = {
401 0x31,//00
402 0x00,
403 0x00,
404 0x00,
405 0x00,
406 0x80,
407 0x00,
408 0x00,
409 0x70,
410 0x45,//tx //0x64 for FPGA
411 0x2A,
412 0x76,
413 0x00,
414 0x00,
415 0x80,
416 0x00,
417 0x00,//10
418 0x00,
419 0x00,
420 0x00,
421 0x00,
422 0x00,
423 0x00,
424 0x00,
425 0x00,
426 0x00,
427 0x00,
428 0x8e, //RobertYu:20060525, //0x8d,
429 0x0a, //RobertYu:20060515, //0x09,
430 0x00,
431 0x00,
432 0x00,
433 0x00,//20
434 0x00,
435 0x00,
436 0x00,
437 0x00,
438 0x4a,
439 0x00,
440 0x00,
441 0x00,
442 0x00,
443 0x00,
444 0x00,
445 0x00,
446 0x4a,
447 0x00,
448 0x0c, //RobertYu:20060525, //0x10,
449 0x26,//30
450 0x5b,
451 0x00,
452 0x00,
453 0x00,
454 0x00,
455 0xaa,
456 0xaa,
457 0xff,
458 0xff,
459 0x79,
460 0x00,
461 0x00,
462 0x0b,
463 0x48,
464 0x04,
465 0x00,//40
466 0x08,
467 0x00,
468 0x08,
469 0x08,
470 0x14,
471 0x05,
472 0x09,
473 0x00,
474 0x00,
475 0x00,
476 0x00,
477 0x09,
478 0x73,
479 0x00,
480 0xc5,
481 0x00,//50 //RobertYu:20060505, //0x15,//50
482 0x19,
483 0x00,
484 0x00,
485 0x00,
486 0x00,
487 0x00,
488 0x00,
489 0x00,
490 0xd0, //RobertYu:20060505, //0xb0,
491 0x00,
492 0x00,
493 0x00,
494 0x00,
495 0x00,
496 0x00,
497 0xe4,//60
498 0x80,
499 0x00,
500 0x00,
501 0x00,
502 0x00,
503 0x98,
504 0x0a,
505 0x00,
506 0x00,
507 0x00,
508 0x00,
509 0x00, //0x80 for FPGA
510 0x03,
511 0x01,
512 0x00,
513 0x00,//70
514 0x00,
515 0x00,
516 0x00,
517 0x00,
518 0x00,
519 0x00,
520 0x00,
521 0x00,
522 0x00,
523 0x00,
524 0x00,
525 0x00,
526 0x00,
527 0x00,
528 0x00,
529 0x8c,//80
530 0x01,
531 0x09,
532 0x00,
533 0x00,
534 0x00,
535 0x00,
536 0x00,
537 0x08,
538 0x00,
539 0x1f, //RobertYu:20060515, //0x0f,
540 0xb7,
541 0x88,
542 0x47,
543 0xaa,
544 0x00, //RobertYu:20060505, //0x02,
545 0x20,//90 //RobertYu:20060505, //0x22,//90
546 0x00,
547 0x00,
548 0x00,
549 0x00,
550 0x00,
551 0x00,
552 0xeb,
553 0x00,
554 0x00,
555 0x00,
556 0x00,
557 0x00,
558 0x00,
559 0x00,
560 0x01,
561 0x00,//a0
562 0x00,
563 0x00,
564 0x00,
565 0x00,
566 0x00,
567 0x10,
568 0x00,
569 0x18,
570 0x00,
571 0x00,
572 0x00,
573 0x00,
574 0x00,
575 0x00,
576 0x18,
577 0x38,//b0
578 0x30,
579 0x00,
580 0x00,
581 0xff,
582 0x0f,
583 0xe4,
584 0xe2,
585 0x00,
586 0x00,
587 0x00,
588 0x03,
589 0x01,
590 0x00,
591 0x00,
592 0x00,
593 0x18,//c0
594 0x20,
595 0x07,
596 0x18,
597 0xff,
598 0xff, //RobertYu:20060509, //0x2c,
599 0x10, //RobertYu:20060525, //0x0c,
600 0x0a,
601 0x0e,
602 0x00, //RobertYu:20060505, //0x01,
603 0x84, //RobertYu:20060525, //0x8f,
604 0xa7,
605 0x3c,
606 0x10,
607 0x24, //RobertYu:20060627, //0x18,
608 0x05, //RobertYu:20060515, //0x25,
609 0x40,//d0
610 0x12,
611 0x00,
612 0x00,
613 0x10,
614 0x28,
615 0x80,
616 0x2A,
617 0x00,
618 0x00,
619 0x00,
620 0x00,
621 0x00,
622 0x00,
623 0x00,
624 0x00,
625 0x00,//e0
626 0xf3, //RobertYu:20060515, //0xd3,
627 0x00,
628 0x00,
629 0x00,
630 0x10,
631 0x00,
632 0x10, //RobertYu:20060627, //0x0e,
633 0x00,
634 0xf4,
635 0x00,
636 0xff,
637 0x79,
638 0x20,
639 0x30,
640 0x08, //RobertYu:20060515, //0x0c,
641 0x00,//f0
642 0x3e,
643 0x00,
644 0x00,
645 0x00,
646 0x00,
647 0x00,
648 0x00,
649 0x00,
650 0x00,
651 0x00,
652 0x00,
653 0x00,
654 0x00,
655 0x00,
656 0x00,
659 const WORD awcFrameTime[MAX_RATE] =
660 {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
662 /*--------------------- Static Functions --------------------------*/
665 static
666 ULONG
667 s_ulGetLowSQ3(PSDevice pDevice);
669 static
670 ULONG
671 s_ulGetRatio(PSDevice pDevice);
673 static
674 void
675 s_vClearSQ3Value(PSDevice pDevice);
678 /*--------------------- Export Variables --------------------------*/
680 * Description: Calculate data frame transmitting time
682 * Parameters:
683 * In:
684 * byPreambleType - Preamble Type
685 * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
686 * cbFrameLength - Baseband Type
687 * wRate - Tx Rate
688 * Out:
690 * Return Value: FrameTime
693 UINT
694 BBuGetFrameTime (
695 IN BYTE byPreambleType,
696 IN BYTE byPktType,
697 IN UINT cbFrameLength,
698 IN WORD wRate
701 UINT uFrameTime;
702 UINT uPreamble;
703 UINT uTmp;
704 UINT uRateIdx = (UINT)wRate;
705 UINT uRate = 0;
708 if (uRateIdx > RATE_54M) {
709 ASSERT(0);
710 return 0;
713 uRate = (UINT)awcFrameTime[uRateIdx];
715 if (uRateIdx <= 3) { //CCK mode
717 if (byPreambleType == 1) {//Short
718 uPreamble = 96;
719 } else {
720 uPreamble = 192;
722 uFrameTime = (cbFrameLength * 80) / uRate; //?????
723 uTmp = (uFrameTime * uRate) / 80;
724 if (cbFrameLength != uTmp) {
725 uFrameTime ++;
728 return (uPreamble + uFrameTime);
730 else {
731 uFrameTime = (cbFrameLength * 8 + 22) / uRate; //????????
732 uTmp = ((uFrameTime * uRate) - 22) / 8;
733 if(cbFrameLength != uTmp) {
734 uFrameTime ++;
736 uFrameTime = uFrameTime * 4; //???????
737 if(byPktType != PK_TYPE_11A) {
738 uFrameTime += 6;
740 return (20 + uFrameTime); //??????
745 * Description: Caculate Length, Service, and Signal fields of Phy for Tx
747 * Parameters:
748 * In:
749 * pDevice - Device Structure
750 * cbFrameLength - Tx Frame Length
751 * wRate - Tx Rate
752 * Out:
753 * pwPhyLen - pointer to Phy Length field
754 * pbyPhySrv - pointer to Phy Service field
755 * pbyPhySgn - pointer to Phy Signal field
757 * Return Value: none
760 VOID
761 BBvCaculateParameter (
762 IN PSDevice pDevice,
763 IN UINT cbFrameLength,
764 IN WORD wRate,
765 IN BYTE byPacketType,
766 OUT PWORD pwPhyLen,
767 OUT PBYTE pbyPhySrv,
768 OUT PBYTE pbyPhySgn
771 UINT cbBitCount;
772 UINT cbUsCount = 0;
773 UINT cbTmp;
774 BOOL bExtBit;
775 BYTE byPreambleType = pDevice->byPreambleType;
776 BOOL bCCK = pDevice->bCCK;
778 cbBitCount = cbFrameLength * 8;
779 bExtBit = FALSE;
781 switch (wRate) {
782 case RATE_1M :
783 cbUsCount = cbBitCount;
784 *pbyPhySgn = 0x00;
785 break;
787 case RATE_2M :
788 cbUsCount = cbBitCount / 2;
789 if (byPreambleType == 1)
790 *pbyPhySgn = 0x09;
791 else // long preamble
792 *pbyPhySgn = 0x01;
793 break;
795 case RATE_5M :
796 if (bCCK == FALSE)
797 cbBitCount ++;
798 cbUsCount = (cbBitCount * 10) / 55;
799 cbTmp = (cbUsCount * 55) / 10;
800 if (cbTmp != cbBitCount)
801 cbUsCount ++;
802 if (byPreambleType == 1)
803 *pbyPhySgn = 0x0a;
804 else // long preamble
805 *pbyPhySgn = 0x02;
806 break;
808 case RATE_11M :
810 if (bCCK == FALSE)
811 cbBitCount ++;
812 cbUsCount = cbBitCount / 11;
813 cbTmp = cbUsCount * 11;
814 if (cbTmp != cbBitCount) {
815 cbUsCount ++;
816 if ((cbBitCount - cbTmp) <= 3)
817 bExtBit = TRUE;
819 if (byPreambleType == 1)
820 *pbyPhySgn = 0x0b;
821 else // long preamble
822 *pbyPhySgn = 0x03;
823 break;
825 case RATE_6M :
826 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
827 *pbyPhySgn = 0x9B; //1001 1011
829 else {//11g, 2.4GHZ
830 *pbyPhySgn = 0x8B; //1000 1011
832 break;
834 case RATE_9M :
835 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
836 *pbyPhySgn = 0x9F; //1001 1111
838 else {//11g, 2.4GHZ
839 *pbyPhySgn = 0x8F; //1000 1111
841 break;
843 case RATE_12M :
844 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
845 *pbyPhySgn = 0x9A; //1001 1010
847 else {//11g, 2.4GHZ
848 *pbyPhySgn = 0x8A; //1000 1010
850 break;
852 case RATE_18M :
853 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
854 *pbyPhySgn = 0x9E; //1001 1110
856 else {//11g, 2.4GHZ
857 *pbyPhySgn = 0x8E; //1000 1110
859 break;
861 case RATE_24M :
862 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
863 *pbyPhySgn = 0x99; //1001 1001
865 else {//11g, 2.4GHZ
866 *pbyPhySgn = 0x89; //1000 1001
868 break;
870 case RATE_36M :
871 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
872 *pbyPhySgn = 0x9D; //1001 1101
874 else {//11g, 2.4GHZ
875 *pbyPhySgn = 0x8D; //1000 1101
877 break;
879 case RATE_48M :
880 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
881 *pbyPhySgn = 0x98; //1001 1000
883 else {//11g, 2.4GHZ
884 *pbyPhySgn = 0x88; //1000 1000
886 break;
888 case RATE_54M :
889 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
890 *pbyPhySgn = 0x9C; //1001 1100
892 else {//11g, 2.4GHZ
893 *pbyPhySgn = 0x8C; //1000 1100
895 break;
897 default :
898 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
899 *pbyPhySgn = 0x9C; //1001 1100
901 else {//11g, 2.4GHZ
902 *pbyPhySgn = 0x8C; //1000 1100
904 break;
907 if (byPacketType == PK_TYPE_11B) {
908 *pbyPhySrv = 0x00;
909 if (bExtBit)
910 *pbyPhySrv = *pbyPhySrv | 0x80;
911 *pwPhyLen = (WORD) cbUsCount;
913 else {
914 *pbyPhySrv = 0x00;
915 *pwPhyLen = (WORD)cbFrameLength;
921 * Description: Set Antenna mode
923 * Parameters:
924 * In:
925 * pDevice - Device Structure
926 * byAntennaMode - Antenna Mode
927 * Out:
928 * none
930 * Return Value: none
933 VOID
934 BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)
936 //{{ RobertYu: 20041124, ABG Mode, VC1/VC2 define, make the ANT_A, ANT_B inverted
937 /*if ( (pDevice->byRFType == RF_MAXIM2829) ||
938 (pDevice->byRFType == RF_UW2452) ||
939 (pDevice->byRFType == RF_AIROHA7230) ) { // RobertYu: 20041210, 20050104
941 switch (byAntennaMode) {
942 case ANT_TXA:
943 byAntennaMode = ANT_TXB;
944 break;
945 case ANT_TXB:
946 byAntennaMode = ANT_TXA;
947 break;
948 case ANT_RXA:
949 byAntennaMode = ANT_RXB;
950 break;
951 case ANT_RXB:
952 byAntennaMode = ANT_RXA;
953 break;
957 switch (byAntennaMode) {
958 case ANT_TXA:
959 break;
960 case ANT_TXB:
961 break;
962 case ANT_RXA:
963 pDevice->byBBRxConf &= 0xFC;
964 break;
965 case ANT_RXB:
966 pDevice->byBBRxConf &= 0xFE;
967 pDevice->byBBRxConf |= 0x02;;
968 break;
972 CONTROLnsRequestOut(pDevice,
973 MESSAGE_TYPE_SET_ANTMD,
974 (WORD) byAntennaMode,
977 NULL);
981 * Description: Set Antenna mode
983 * Parameters:
984 * In:
985 * pDevice - Device Structure
986 * byAntennaMode - Antenna Mode
987 * Out:
988 * none
990 * Return Value: none
993 BOOL
994 BBbVT3184Init (PSDevice pDevice)
996 NTSTATUS ntStatus;
997 WORD wLength;
998 PBYTE pbyAddr;
999 PBYTE pbyAgc;
1000 WORD wLengthAgc;
1001 BYTE abyArray[256];
1003 ntStatus = CONTROLnsRequestIn(pDevice,
1004 MESSAGE_TYPE_READ,
1006 MESSAGE_REQUEST_EEPROM,
1007 EEP_MAX_CONTEXT_SIZE,
1008 pDevice->abyEEPROM);
1009 if (ntStatus != STATUS_SUCCESS) {
1010 return FALSE;
1014 //20080215-01,<Add> by Mike Liu
1015 // if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
1016 // return FALSE;
1018 //20080804-01,<Add> by Mike Liu
1019 //zonetype initial
1020 pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
1021 if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
1022 if ((pDevice->config_file.ZoneType == 0)&&
1023 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
1024 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
1025 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
1026 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
1028 else if((pDevice->config_file.ZoneType == 1)&&
1029 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
1030 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
1031 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
1032 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n");
1034 else if((pDevice->config_file.ZoneType == 2)&&
1035 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
1036 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
1037 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
1038 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
1040 else {
1041 if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
1042 printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
1043 else
1044 printk("Read Zonetype file sucess,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType);
1048 if ( !pDevice->bZoneRegExist ) {
1049 pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
1051 pDevice->byRFType = pDevice->abyEEPROM[EEP_OFS_RFTYPE];
1053 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", pDevice->byZoneType);
1054 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", pDevice->byRFType);
1056 if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) {
1057 pDevice->byBBRxConf = abyVT3184_AL2230[10];
1058 wLength = sizeof(abyVT3184_AL2230);
1059 pbyAddr = abyVT3184_AL2230;
1060 pbyAgc = abyVT3184_AGC;
1061 wLengthAgc = sizeof(abyVT3184_AGC);
1063 pDevice->abyBBVGA[0] = 0x1C;
1064 pDevice->abyBBVGA[1] = 0x10;
1065 pDevice->abyBBVGA[2] = 0x0;
1066 pDevice->abyBBVGA[3] = 0x0;
1067 pDevice->ldBmThreshold[0] = -70;
1068 pDevice->ldBmThreshold[1] = -48;
1069 pDevice->ldBmThreshold[2] = 0;
1070 pDevice->ldBmThreshold[3] = 0;
1072 else if (pDevice->byRFType == RF_AIROHA7230) {
1073 pDevice->byBBRxConf = abyVT3184_AL2230[10];
1074 wLength = sizeof(abyVT3184_AL2230);
1075 pbyAddr = abyVT3184_AL2230;
1076 pbyAgc = abyVT3184_AGC;
1077 wLengthAgc = sizeof(abyVT3184_AGC);
1079 // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1080 //pbyAddr[0x09] = 0x41;
1081 // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1082 //pbyAddr[0x0a] = 0x28;
1083 // Select VC1/VC2, CR215 = 0x02->0x06
1084 pbyAddr[0xd7] = 0x06;
1086 pDevice->abyBBVGA[0] = 0x1C;
1087 pDevice->abyBBVGA[1] = 0x10;
1088 pDevice->abyBBVGA[2] = 0x0;
1089 pDevice->abyBBVGA[3] = 0x0;
1090 pDevice->ldBmThreshold[0] = -70;
1091 pDevice->ldBmThreshold[1] = -48;
1092 pDevice->ldBmThreshold[2] = 0;
1093 pDevice->ldBmThreshold[3] = 0;
1095 else if ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) {
1096 pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; //RobertYu:20060515
1097 wLength = sizeof(abyVT3184_VT3226D0); //RobertYu:20060515
1098 pbyAddr = abyVT3184_VT3226D0; //RobertYu:20060515
1099 pbyAgc = abyVT3184_AGC;
1100 wLengthAgc = sizeof(abyVT3184_AGC);
1102 pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack
1103 pDevice->abyBBVGA[1] = 0x10;
1104 pDevice->abyBBVGA[2] = 0x0;
1105 pDevice->abyBBVGA[3] = 0x0;
1106 pDevice->ldBmThreshold[0] = -70;
1107 pDevice->ldBmThreshold[1] = -48;
1108 pDevice->ldBmThreshold[2] = 0;
1109 pDevice->ldBmThreshold[3] = 0;
1110 // Fix VT3226 DFC system timing issue
1111 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1112 //}}
1113 //{{RobertYu:20060609
1114 } else if ( (pDevice->byRFType == RF_VT3342A0) ) {
1115 pDevice->byBBRxConf = abyVT3184_VT3226D0[10];
1116 wLength = sizeof(abyVT3184_VT3226D0);
1117 pbyAddr = abyVT3184_VT3226D0;
1118 pbyAgc = abyVT3184_AGC;
1119 wLengthAgc = sizeof(abyVT3184_AGC);
1121 pDevice->abyBBVGA[0] = 0x20;
1122 pDevice->abyBBVGA[1] = 0x10;
1123 pDevice->abyBBVGA[2] = 0x0;
1124 pDevice->abyBBVGA[3] = 0x0;
1125 pDevice->ldBmThreshold[0] = -70;
1126 pDevice->ldBmThreshold[1] = -48;
1127 pDevice->ldBmThreshold[2] = 0;
1128 pDevice->ldBmThreshold[3] = 0;
1129 // Fix VT3226 DFC system timing issue
1130 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1131 //}}
1132 } else {
1133 return TRUE;
1136 memcpy(abyArray, pbyAddr, wLength);
1137 CONTROLnsRequestOut(pDevice,
1138 MESSAGE_TYPE_WRITE,
1140 MESSAGE_REQUEST_BBREG,
1141 wLength,
1142 abyArray
1145 memcpy(abyArray, pbyAgc, wLengthAgc);
1146 CONTROLnsRequestOut(pDevice,
1147 MESSAGE_TYPE_WRITE,
1149 MESSAGE_REQUEST_BBAGC,
1150 wLengthAgc,
1151 abyArray
1155 if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0
1156 (pDevice->byRFType == RF_VT3342A0) //RobertYu:20060609
1158 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23);
1159 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1161 else if (pDevice->byRFType == RF_VT3226D0)
1163 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11);
1164 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1168 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F);
1169 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
1171 RFbRFTableDownload(pDevice);
1172 return TRUE;//ntStatus;
1177 * Description: Turn on BaseBand Loopback mode
1179 * Parameters:
1180 * In:
1181 * pDevice - Device Structure
1183 * Out:
1184 * none
1186 * Return Value: none
1189 void BBvLoopbackOn (PSDevice pDevice)
1191 BYTE byData;
1193 //CR C9 = 0x00
1194 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xC9, &pDevice->byBBCRc9);//CR201
1195 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0);
1196 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x4D, &pDevice->byBBCR4d);//CR77
1197 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, 0x90);
1199 //CR 88 = 0x02(CCK), 0x03(OFDM)
1200 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x88, &pDevice->byBBCR88);//CR136
1202 if (pDevice->wCurrentRate <= RATE_11M) { //CCK
1203 // Enable internal digital loopback: CR33 |= 0000 0001
1204 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
1205 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData | 0x01));//CR33
1206 // CR154 = 0x00
1207 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, 0); //CR154
1209 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x02);//CR239
1211 else { //OFDM
1212 // Enable internal digital loopback:CR154 |= 0000 0001
1213 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
1214 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData | 0x01));//CR154
1215 // CR33 = 0x00
1216 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, 0); //CR33
1218 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, 0x03);//CR239
1221 //CR14 = 0x00
1222 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, 0);//CR14
1224 // Disable TX_IQUN
1225 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x09, &pDevice->byBBCR09);
1226 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x09, (BYTE)(pDevice->byBBCR09 & 0xDE));
1230 * Description: Turn off BaseBand Loopback mode
1232 * Parameters:
1233 * In:
1234 * pDevice - Device Structure
1236 * Out:
1237 * none
1239 * Return Value: none
1242 void BBvLoopbackOff (PSDevice pDevice)
1244 BYTE byData;
1246 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, pDevice->byBBCRc9);//CR201
1247 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x88, pDevice->byBBCR88);//CR136
1248 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x09, pDevice->byBBCR09);//CR136
1249 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x4D, pDevice->byBBCR4d);//CR77
1251 if (pDevice->wCurrentRate <= RATE_11M) { // CCK
1252 // Set the CR33 Bit2 to disable internal Loopback.
1253 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x21, &byData);//CR33
1254 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x21, (BYTE)(byData & 0xFE));//CR33
1256 else { // OFDM
1257 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x9A, &byData);//CR154
1258 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9A, (BYTE)(byData & 0xFE));//CR154
1260 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0x0E, &byData);//CR14
1261 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0E, (BYTE)(byData | 0x80));//CR14
1267 * Description: Set ShortSlotTime mode
1269 * Parameters:
1270 * In:
1271 * pDevice - Device Structure
1272 * Out:
1273 * none
1275 * Return Value: none
1278 VOID
1279 BBvSetShortSlotTime (PSDevice pDevice)
1281 BYTE byBBVGA=0;
1283 if (pDevice->bShortSlotTime) {
1284 pDevice->byBBRxConf &= 0xDF;//1101 1111
1285 } else {
1286 pDevice->byBBRxConf |= 0x20;//0010 0000
1289 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
1290 if (byBBVGA == pDevice->abyBBVGA[0]) {
1291 pDevice->byBBRxConf |= 0x20;//0010 0000
1294 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
1299 VOID BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData)
1302 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
1304 // patch for 3253B0 Baseband with Cardbus module
1305 if (byData == pDevice->abyBBVGA[0]) {
1306 pDevice->byBBRxConf |= 0x20;//0010 0000
1307 } else if (pDevice->bShortSlotTime) {
1308 pDevice->byBBRxConf &= 0xDF;//1101 1111
1309 } else {
1310 pDevice->byBBRxConf |= 0x20;//0010 0000
1312 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
1317 * Description: Baseband SoftwareReset
1319 * Parameters:
1320 * In:
1321 * dwIoBase - I/O base address
1322 * Out:
1323 * none
1325 * Return Value: none
1328 VOID
1329 BBvSoftwareReset (PSDevice pDevice)
1331 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0x40);
1332 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x50, 0);
1333 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0x01);
1334 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x9C, 0);
1338 * Description: BBvSetDeepSleep
1340 * Parameters:
1341 * In:
1342 * pDevice - Device Structure
1343 * Out:
1344 * none
1346 * Return Value: none
1349 VOID
1350 BBvSetDeepSleep (PSDevice pDevice)
1352 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
1353 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
1356 VOID
1357 BBvExitDeepSleep (PSDevice pDevice)
1359 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
1360 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
1364 static
1365 ULONG
1366 s_ulGetLowSQ3(PSDevice pDevice)
1368 int ii;
1369 ULONG ulSQ3 = 0;
1370 ULONG ulMaxPacket;
1372 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1373 if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
1374 ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
1376 for ( ii=RATE_48M;ii>=RATE_6M;ii-- ) {
1377 if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
1378 ulMaxPacket = pDevice->aulPktNum[ii];
1379 ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
1383 return ulSQ3;
1388 static
1389 ULONG
1390 s_ulGetRatio (PSDevice pDevice)
1392 int ii,jj;
1393 ULONG ulRatio = 0;
1394 ULONG ulMaxPacket;
1395 ULONG ulPacketNum;
1397 //This is a thousand-ratio
1398 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1399 if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
1400 ulPacketNum = pDevice->aulPktNum[RATE_54M];
1401 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1402 ulRatio += TOP_RATE_54M;
1404 for ( ii=RATE_48M;ii>=RATE_1M;ii-- ) {
1405 if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
1406 ulPacketNum = 0;
1407 for ( jj=RATE_54M;jj>=ii;jj--)
1408 ulPacketNum += pDevice->aulPktNum[jj];
1409 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1410 ulRatio += TOP_RATE_48M;
1411 ulMaxPacket = pDevice->aulPktNum[ii];
1416 return ulRatio;
1420 static
1421 void
1422 s_vClearSQ3Value (PSDevice pDevice)
1424 int ii;
1425 pDevice->uDiversityCnt = 0;
1427 for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
1428 pDevice->aulPktNum[ii] = 0;
1429 pDevice->aulSQ3Val[ii] = 0;
1435 * Description: Antenna Diversity
1437 * Parameters:
1438 * In:
1439 * pDevice - Device Structure
1440 * byRSR - RSR from received packet
1441 * bySQ3 - SQ3 value from received packet
1442 * Out:
1443 * none
1445 * Return Value: none
1449 VOID
1450 BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3)
1453 pDevice->uDiversityCnt++;
1454 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
1456 if (byRxRate == 2) {
1457 pDevice->aulPktNum[RATE_1M]++;
1459 else if (byRxRate==4) {
1460 pDevice->aulPktNum[RATE_2M]++;
1462 else if (byRxRate==11) {
1463 pDevice->aulPktNum[RATE_5M]++;
1465 else if (byRxRate==22) {
1466 pDevice->aulPktNum[RATE_11M]++;
1468 else if(byRxRate==12){
1469 pDevice->aulPktNum[RATE_6M]++;
1470 pDevice->aulSQ3Val[RATE_6M] += bySQ3;
1472 else if(byRxRate==18){
1473 pDevice->aulPktNum[RATE_9M]++;
1474 pDevice->aulSQ3Val[RATE_9M] += bySQ3;
1476 else if(byRxRate==24){
1477 pDevice->aulPktNum[RATE_12M]++;
1478 pDevice->aulSQ3Val[RATE_12M] += bySQ3;
1480 else if(byRxRate==36){
1481 pDevice->aulPktNum[RATE_18M]++;
1482 pDevice->aulSQ3Val[RATE_18M] += bySQ3;
1484 else if(byRxRate==48){
1485 pDevice->aulPktNum[RATE_24M]++;
1486 pDevice->aulSQ3Val[RATE_24M] += bySQ3;
1488 else if(byRxRate==72){
1489 pDevice->aulPktNum[RATE_36M]++;
1490 pDevice->aulSQ3Val[RATE_36M] += bySQ3;
1492 else if(byRxRate==96){
1493 pDevice->aulPktNum[RATE_48M]++;
1494 pDevice->aulSQ3Val[RATE_48M] += bySQ3;
1496 else if(byRxRate==108){
1497 pDevice->aulPktNum[RATE_54M]++;
1498 pDevice->aulSQ3Val[RATE_54M] += bySQ3;
1501 if (pDevice->byAntennaState == 0) {
1503 if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
1504 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
1506 pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
1507 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1508 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
1510 if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
1511 (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
1512 (pDevice->ulSQ3_State0 == 0 ) ) {
1514 if ( pDevice->byTMax == 0 )
1515 return;
1517 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1519 pDevice->byAntennaState = 1;
1521 del_timer(&pDevice->TimerSQ3Tmax3);
1522 del_timer(&pDevice->TimerSQ3Tmax2);
1523 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1524 add_timer(&pDevice->TimerSQ3Tmax1);
1526 } else {
1527 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1528 add_timer(&pDevice->TimerSQ3Tmax3);
1530 s_vClearSQ3Value(pDevice);
1533 } else { //byAntennaState == 1
1535 if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
1537 del_timer(&pDevice->TimerSQ3Tmax1);
1538 pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
1539 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
1540 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
1542 if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
1543 ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
1544 ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
1547 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1549 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1550 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1551 add_timer(&pDevice->TimerSQ3Tmax3);
1552 add_timer(&pDevice->TimerSQ3Tmax2);
1555 pDevice->byAntennaState = 0;
1556 s_vClearSQ3Value(pDevice);
1558 } //byAntennaState
1564 * Description:
1565 * Timer for SQ3 antenna diversity
1567 * Parameters:
1568 * In:
1569 * pvSysSpec1
1570 * hDeviceContext - Pointer to the adapter
1571 * pvSysSpec2
1572 * pvSysSpec3
1573 * Out:
1574 * none
1576 * Return Value: none
1580 VOID
1581 TimerSQ3CallBack (
1582 IN HANDLE hDeviceContext
1585 PSDevice pDevice = (PSDevice)hDeviceContext;
1587 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
1588 spin_lock_irq(&pDevice->lock);
1590 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1591 pDevice->byAntennaState = 0;
1592 s_vClearSQ3Value(pDevice);
1593 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1594 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1595 add_timer(&pDevice->TimerSQ3Tmax3);
1596 add_timer(&pDevice->TimerSQ3Tmax2);
1599 spin_unlock_irq(&pDevice->lock);
1600 return;
1606 * Description:
1607 * Timer for SQ3 antenna diversity
1609 * Parameters:
1610 * In:
1611 * pvSysSpec1
1612 * hDeviceContext - Pointer to the adapter
1613 * pvSysSpec2
1614 * pvSysSpec3
1615 * Out:
1616 * none
1618 * Return Value: none
1622 VOID
1623 TimerSQ3Tmax3CallBack (
1624 IN HANDLE hDeviceContext
1627 PSDevice pDevice = (PSDevice)hDeviceContext;
1629 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
1630 spin_lock_irq(&pDevice->lock);
1632 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1633 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
1635 s_vClearSQ3Value(pDevice);
1636 if ( pDevice->byTMax == 0 ) {
1637 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1638 add_timer(&pDevice->TimerSQ3Tmax3);
1639 spin_unlock_irq(&pDevice->lock);
1640 return;
1643 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1644 pDevice->byAntennaState = 1;
1645 del_timer(&pDevice->TimerSQ3Tmax3);
1646 del_timer(&pDevice->TimerSQ3Tmax2);
1647 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1648 add_timer(&pDevice->TimerSQ3Tmax1);
1650 spin_unlock_irq(&pDevice->lock);
1651 return;
1654 VOID
1655 BBvUpdatePreEDThreshold(
1656 IN PSDevice pDevice,
1657 IN BOOL bScanning)
1661 switch(pDevice->byRFType)
1663 case RF_AL2230:
1664 case RF_AL2230S:
1665 case RF_AIROHA7230:
1666 //RobertYu:20060627, update new table
1668 if( bScanning )
1669 { // need Max sensitivity //RSSI -69, -70,....
1670 if(pDevice->byBBPreEDIndex == 0) break;
1671 pDevice->byBBPreEDIndex = 0;
1672 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1673 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1674 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
1675 break;
1678 if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
1679 if(pDevice->byBBPreEDIndex == 20) break;
1680 pDevice->byBBPreEDIndex = 20;
1681 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1682 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1683 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
1684 } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
1685 if(pDevice->byBBPreEDIndex == 19) break;
1686 pDevice->byBBPreEDIndex = 19;
1687 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
1688 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1689 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
1690 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
1691 if(pDevice->byBBPreEDIndex == 18) break;
1692 pDevice->byBBPreEDIndex = 18;
1693 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
1694 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1695 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
1696 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1697 if(pDevice->byBBPreEDIndex == 17) break;
1698 pDevice->byBBPreEDIndex = 17;
1699 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
1700 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1701 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1702 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1703 if(pDevice->byBBPreEDIndex == 16) break;
1704 pDevice->byBBPreEDIndex = 16;
1705 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
1706 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1707 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1708 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1709 if(pDevice->byBBPreEDIndex == 15) break;
1710 pDevice->byBBPreEDIndex = 15;
1711 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
1712 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1713 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1714 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1715 if(pDevice->byBBPreEDIndex == 14) break;
1716 pDevice->byBBPreEDIndex = 14;
1717 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
1718 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1719 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1720 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1721 if(pDevice->byBBPreEDIndex == 13) break;
1722 pDevice->byBBPreEDIndex = 13;
1723 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1724 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1725 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1726 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1727 if(pDevice->byBBPreEDIndex == 12) break;
1728 pDevice->byBBPreEDIndex = 12;
1729 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1730 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
1731 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1732 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1733 if(pDevice->byBBPreEDIndex == 11) break;
1734 pDevice->byBBPreEDIndex = 11;
1735 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1736 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1737 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1738 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1739 if(pDevice->byBBPreEDIndex == 10) break;
1740 pDevice->byBBPreEDIndex = 10;
1741 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1742 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
1743 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1744 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1745 if(pDevice->byBBPreEDIndex == 9) break;
1746 pDevice->byBBPreEDIndex = 9;
1747 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1748 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
1749 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1750 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1751 if(pDevice->byBBPreEDIndex == 8) break;
1752 pDevice->byBBPreEDIndex = 8;
1753 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1754 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
1755 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1756 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1757 if(pDevice->byBBPreEDIndex == 7) break;
1758 pDevice->byBBPreEDIndex = 7;
1759 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1760 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
1761 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1762 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1763 if(pDevice->byBBPreEDIndex == 6) break;
1764 pDevice->byBBPreEDIndex = 6;
1765 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1766 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
1767 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1768 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1769 if(pDevice->byBBPreEDIndex == 5) break;
1770 pDevice->byBBPreEDIndex = 5;
1771 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1772 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
1773 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1774 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1775 if(pDevice->byBBPreEDIndex == 4) break;
1776 pDevice->byBBPreEDIndex = 4;
1777 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1778 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
1779 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1780 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1781 if(pDevice->byBBPreEDIndex == 3) break;
1782 pDevice->byBBPreEDIndex = 3;
1783 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1784 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
1785 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1786 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1787 if(pDevice->byBBPreEDIndex == 2) break;
1788 pDevice->byBBPreEDIndex = 2;
1789 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1790 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1791 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1792 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1793 if(pDevice->byBBPreEDIndex == 1) break;
1794 pDevice->byBBPreEDIndex = 1;
1795 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1796 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1797 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1798 } else { //RSSI -69, -70,....
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, 0x30); //CR206(0xCE)
1803 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
1805 break;
1807 case RF_VT3226:
1808 case RF_VT3226D0:
1809 //RobertYu:20060627, update new table
1811 if( bScanning )
1812 { // need Max sensitivity //RSSI -69, -70, ...
1813 if(pDevice->byBBPreEDIndex == 0) break;
1814 pDevice->byBBPreEDIndex = 0;
1815 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1816 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1817 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1818 break;
1821 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1822 if(pDevice->byBBPreEDIndex == 22) break;
1823 pDevice->byBBPreEDIndex = 22;
1824 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1825 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1826 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1827 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1828 if(pDevice->byBBPreEDIndex == 21) break;
1829 pDevice->byBBPreEDIndex = 21;
1830 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1831 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1832 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1833 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1834 if(pDevice->byBBPreEDIndex == 20) break;
1835 pDevice->byBBPreEDIndex = 20;
1836 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1837 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1838 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1839 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1840 if(pDevice->byBBPreEDIndex == 19) break;
1841 pDevice->byBBPreEDIndex = 19;
1842 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1843 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1844 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1845 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1846 if(pDevice->byBBPreEDIndex == 18) break;
1847 pDevice->byBBPreEDIndex = 18;
1848 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1849 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1850 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1851 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1852 if(pDevice->byBBPreEDIndex == 17) break;
1853 pDevice->byBBPreEDIndex = 17;
1854 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1855 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1856 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1857 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1858 if(pDevice->byBBPreEDIndex == 16) break;
1859 pDevice->byBBPreEDIndex = 16;
1860 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1861 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1862 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1863 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1864 if(pDevice->byBBPreEDIndex == 15) break;
1865 pDevice->byBBPreEDIndex = 15;
1866 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1867 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1868 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1869 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1870 if(pDevice->byBBPreEDIndex == 14) break;
1871 pDevice->byBBPreEDIndex = 14;
1872 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1873 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1874 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1875 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1876 if(pDevice->byBBPreEDIndex == 13) break;
1877 pDevice->byBBPreEDIndex = 13;
1878 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1879 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1880 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1881 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1882 if(pDevice->byBBPreEDIndex == 12) break;
1883 pDevice->byBBPreEDIndex = 12;
1884 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1885 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1886 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1887 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1888 if(pDevice->byBBPreEDIndex == 11) break;
1889 pDevice->byBBPreEDIndex = 11;
1890 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1891 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1892 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1893 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1894 if(pDevice->byBBPreEDIndex == 10) break;
1895 pDevice->byBBPreEDIndex = 10;
1896 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1897 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1898 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1899 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1900 if(pDevice->byBBPreEDIndex == 9) break;
1901 pDevice->byBBPreEDIndex = 9;
1902 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1903 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1904 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1905 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1906 if(pDevice->byBBPreEDIndex == 8) break;
1907 pDevice->byBBPreEDIndex = 8;
1908 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1909 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1910 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1911 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1912 if(pDevice->byBBPreEDIndex == 7) break;
1913 pDevice->byBBPreEDIndex = 7;
1914 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1915 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1916 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1917 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1918 if(pDevice->byBBPreEDIndex == 6) break;
1919 pDevice->byBBPreEDIndex = 6;
1920 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1921 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1922 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1923 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1924 if(pDevice->byBBPreEDIndex == 5) break;
1925 pDevice->byBBPreEDIndex = 5;
1926 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1927 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1928 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1929 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1930 if(pDevice->byBBPreEDIndex == 4) break;
1931 pDevice->byBBPreEDIndex = 4;
1932 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1933 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1934 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1935 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1936 if(pDevice->byBBPreEDIndex == 3) break;
1937 pDevice->byBBPreEDIndex = 3;
1938 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1939 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1940 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1941 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1942 if(pDevice->byBBPreEDIndex == 2) break;
1943 pDevice->byBBPreEDIndex = 2;
1944 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1945 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1946 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1947 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1948 if(pDevice->byBBPreEDIndex == 1) break;
1949 pDevice->byBBPreEDIndex = 1;
1950 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1951 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
1952 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1953 } else { //RSSI -69, -70, ...
1954 if(pDevice->byBBPreEDIndex == 0) break;
1955 pDevice->byBBPreEDIndex = 0;
1956 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1957 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1958 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1960 break;
1962 case RF_VT3342A0: //RobertYu:20060627, testing table
1963 if( bScanning )
1964 { // need Max sensitivity //RSSI -67, -68, ...
1965 if(pDevice->byBBPreEDIndex == 0) break;
1966 pDevice->byBBPreEDIndex = 0;
1967 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1968 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1969 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
1970 break;
1973 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1974 if(pDevice->byBBPreEDIndex == 20) break;
1975 pDevice->byBBPreEDIndex = 20;
1976 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1977 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1978 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1979 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1980 if(pDevice->byBBPreEDIndex == 19) break;
1981 pDevice->byBBPreEDIndex = 19;
1982 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1983 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1984 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1985 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1986 if(pDevice->byBBPreEDIndex == 18) break;
1987 pDevice->byBBPreEDIndex = 18;
1988 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1989 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1990 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1991 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1992 if(pDevice->byBBPreEDIndex == 17) break;
1993 pDevice->byBBPreEDIndex = 17;
1994 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1995 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1996 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1997 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1998 if(pDevice->byBBPreEDIndex == 16) break;
1999 pDevice->byBBPreEDIndex = 16;
2000 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
2001 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
2002 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
2003 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
2004 if(pDevice->byBBPreEDIndex == 15) break;
2005 pDevice->byBBPreEDIndex = 15;
2006 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
2007 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
2008 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
2009 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
2010 if(pDevice->byBBPreEDIndex == 14) break;
2011 pDevice->byBBPreEDIndex = 14;
2012 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
2013 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
2014 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
2015 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
2016 if(pDevice->byBBPreEDIndex == 13) break;
2017 pDevice->byBBPreEDIndex = 13;
2018 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
2019 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
2020 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
2021 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
2022 if(pDevice->byBBPreEDIndex == 12) break;
2023 pDevice->byBBPreEDIndex = 12;
2024 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
2025 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
2026 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
2027 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
2028 if(pDevice->byBBPreEDIndex == 11) break;
2029 pDevice->byBBPreEDIndex = 11;
2030 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
2031 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
2032 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
2033 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
2034 if(pDevice->byBBPreEDIndex == 10) break;
2035 pDevice->byBBPreEDIndex = 10;
2036 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
2037 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
2038 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
2039 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
2040 if(pDevice->byBBPreEDIndex == 9) break;
2041 pDevice->byBBPreEDIndex = 9;
2042 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
2043 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
2044 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
2045 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
2046 if(pDevice->byBBPreEDIndex == 8) break;
2047 pDevice->byBBPreEDIndex = 8;
2048 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
2049 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
2050 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
2051 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
2052 if(pDevice->byBBPreEDIndex == 7) break;
2053 pDevice->byBBPreEDIndex = 7;
2054 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2055 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
2056 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
2057 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
2058 if(pDevice->byBBPreEDIndex == 6) break;
2059 pDevice->byBBPreEDIndex = 6;
2060 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2061 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
2062 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
2063 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
2064 if(pDevice->byBBPreEDIndex == 5) break;
2065 pDevice->byBBPreEDIndex = 5;
2066 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2067 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
2068 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
2069 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
2070 if(pDevice->byBBPreEDIndex == 4) break;
2071 pDevice->byBBPreEDIndex = 4;
2072 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2073 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
2074 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
2075 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
2076 if(pDevice->byBBPreEDIndex == 3) break;
2077 pDevice->byBBPreEDIndex = 3;
2078 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2079 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
2080 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
2081 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
2082 if(pDevice->byBBPreEDIndex == 2) break;
2083 pDevice->byBBPreEDIndex = 2;
2084 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2085 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
2086 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
2087 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
2088 if(pDevice->byBBPreEDIndex == 1) break;
2089 pDevice->byBBPreEDIndex = 1;
2090 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2091 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
2092 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
2093 } else { //RSSI -67, -68, ...
2094 if(pDevice->byBBPreEDIndex == 0) break;
2095 pDevice->byBBPreEDIndex = 0;
2096 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
2097 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
2098 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
2100 break;