2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
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.
22 * Purpose: Implement functions to access baseband
29 * BBuGetFrameTime - Calculate data frame transmitting time
30 * BBvCalculateParameter - Calculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
31 * BBbVT3184Init - VIA VT3184 baseband chip init code
48 static int msglevel =MSG_LEVEL_INFO;
49 //static int msglevel =MSG_LEVEL_DEBUG;
51 u8 abyVT3184_AGC[] = {
55 0x02, //3 //RobertYu:20060505, 0x04, //3
57 0x04, //5 //RobertYu:20060505, 0x06, //5
118 u8 abyVT3184_AL2230[] = {
128 0x45,//tx //0x64 for FPGA
146 0x8e, //RobertYu:20060522, //0x8d,
147 0x0a, //RobertYu:20060515, //0x09,
166 0x0c, //RobertYu:20060522, //0x10,
199 0x00,//50 //RobertYu:20060505, //0x15,//50
208 0xd0, //RobertYu:20060505, //0xb0,
227 0x00, //0x80 for FPGA
257 0x1f, //RobertYu:20060516, //0x0f,
262 0x00, //RobertYu:20060505, //0x02,
263 0x20,//90 //RobertYu:20060505, //0x22,//90
292 0x15, //RobertYu:20060516, //0x00,
316 0xff, //RobertYu:20060509, //0x2c,
317 0x0e, //RobertYu:20060530, //0x0c,
320 0x00, //RobertYu:20060505, //0x01,
321 0x82, //RobertYu:20060516, //0x8f,
325 0x30, //RobertYu:20060627, //0x0b,
326 0x05, //RobertYu:20060516, //0x25,
344 0xf3, //RobertYu:20060516, //0xd3,
350 0x12, //RobertYu:20060627, //0x10,
358 0x05, //RobertYu:20060516, //0x0c,
377 //{{RobertYu:20060515, new BB setting for VT3226D0
378 u8 abyVT3184_VT3226D0[] = {
388 0x45,//tx //0x64 for FPGA
406 0x8e, //RobertYu:20060525, //0x8d,
407 0x0a, //RobertYu:20060515, //0x09,
426 0x0c, //RobertYu:20060525, //0x10,
459 0x00,//50 //RobertYu:20060505, //0x15,//50
468 0xd0, //RobertYu:20060505, //0xb0,
487 0x00, //0x80 for FPGA
517 0x1f, //RobertYu:20060515, //0x0f,
522 0x00, //RobertYu:20060505, //0x02,
523 0x20,//90 //RobertYu:20060505, //0x22,//90
576 0xff, //RobertYu:20060509, //0x2c,
577 0x10, //RobertYu:20060525, //0x0c,
580 0x00, //RobertYu:20060505, //0x01,
581 0x84, //RobertYu:20060525, //0x8f,
585 0x24, //RobertYu:20060627, //0x18,
586 0x05, //RobertYu:20060515, //0x25,
604 0xf3, //RobertYu:20060515, //0xd3,
610 0x10, //RobertYu:20060627, //0x0e,
618 0x08, //RobertYu:20060515, //0x0c,
637 const u16 awcFrameTime[MAX_RATE] =
638 {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
643 s_ulGetLowSQ3(PSDevice pDevice);
647 s_ulGetRatio(PSDevice pDevice);
651 s_vClearSQ3Value(PSDevice pDevice);
655 * Description: Calculate data frame transmitting time
659 * byPreambleType - Preamble Type
660 * byPktType - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA
661 * cbFrameLength - Baseband Type
665 * Return Value: FrameTime
672 unsigned int cbFrameLength,
676 unsigned int uFrameTime;
677 unsigned int uPreamble;
679 unsigned int uRateIdx = (unsigned int)wRate;
680 unsigned int uRate = 0;
682 if (uRateIdx > RATE_54M) {
686 uRate = (unsigned int)awcFrameTime[uRateIdx];
688 if (uRateIdx <= 3) { //CCK mode
690 if (byPreambleType == 1) {//Short
695 uFrameTime = (cbFrameLength * 80) / uRate; //?????
696 uTmp = (uFrameTime * uRate) / 80;
697 if (cbFrameLength != uTmp) {
701 return (uPreamble + uFrameTime);
704 uFrameTime = (cbFrameLength * 8 + 22) / uRate; //????????
705 uTmp = ((uFrameTime * uRate) - 22) / 8;
706 if(cbFrameLength != uTmp) {
709 uFrameTime = uFrameTime * 4; //???????
710 if(byPktType != PK_TYPE_11A) {
713 return (20 + uFrameTime); //??????
718 * Description: Calculate Length, Service, and Signal fields of Phy for Tx
722 * pDevice - Device Structure
723 * cbFrameLength - Tx Frame Length
726 * struct vnt_phy_field *phy
727 * - pointer to Phy Length field
728 * - pointer to Phy Service field
729 * - pointer to Phy Signal field
734 void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength,
735 u16 wRate, u8 byPacketType, struct vnt_phy_field *phy)
741 u8 byPreambleType = pDevice->byPreambleType;
742 int bCCK = pDevice->bCCK;
744 cbBitCount = cbFrameLength * 8;
749 cbUsCount = cbBitCount;
754 cbUsCount = cbBitCount / 2;
755 if (byPreambleType == 1)
757 else // long preamble
764 cbUsCount = (cbBitCount * 10) / 55;
765 cbTmp = (cbUsCount * 55) / 10;
766 if (cbTmp != cbBitCount)
768 if (byPreambleType == 1)
770 else // long preamble
778 cbUsCount = cbBitCount / 11;
779 cbTmp = cbUsCount * 11;
780 if (cbTmp != cbBitCount) {
782 if ((cbBitCount - cbTmp) <= 3)
785 if (byPreambleType == 1)
787 else // long preamble
792 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
801 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
810 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
819 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
828 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
837 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
846 if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ
855 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
864 if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ
873 if (byPacketType == PK_TYPE_11B) {
876 phy->service |= 0x80;
877 phy->len = cpu_to_le16((u16)cbUsCount);
880 phy->len = cpu_to_le16((u16)cbFrameLength);
885 * Description: Set Antenna mode
889 * pDevice - Device Structure
890 * byAntennaMode - Antenna Mode
897 void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode)
899 switch (byAntennaMode) {
904 pDevice->byBBRxConf &= 0xFC;
907 pDevice->byBBRxConf &= 0xFE;
908 pDevice->byBBRxConf |= 0x02;
912 CONTROLnsRequestOut(pDevice,
913 MESSAGE_TYPE_SET_ANTMD,
921 * Description: Set Antenna mode
925 * pDevice - Device Structure
926 * byAntennaMode - Antenna Mode
934 int BBbVT3184Init(struct vnt_private *pDevice)
944 ntStatus = CONTROLnsRequestIn(pDevice,
947 MESSAGE_REQUEST_EEPROM,
948 EEP_MAX_CONTEXT_SIZE,
950 if (ntStatus != STATUS_SUCCESS) {
954 // if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
958 pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
959 if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
960 if ((pDevice->config_file.ZoneType == 0)&&
961 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
962 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
963 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
964 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
966 else if((pDevice->config_file.ZoneType == 1)&&
967 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
968 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
969 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
970 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n");
972 else if((pDevice->config_file.ZoneType == 2)&&
973 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
974 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
975 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
976 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
979 if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
980 printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
982 printk("Read Zonetype file success,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType);
986 if ( !pDevice->bZoneRegExist ) {
987 pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
989 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);
994 if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) {
995 pDevice->byBBRxConf = abyVT3184_AL2230[10];
996 wLength = sizeof(abyVT3184_AL2230);
997 pbyAddr = abyVT3184_AL2230;
998 pbyAgc = abyVT3184_AGC;
999 wLengthAgc = sizeof(abyVT3184_AGC);
1001 pDevice->abyBBVGA[0] = 0x1C;
1002 pDevice->abyBBVGA[1] = 0x10;
1003 pDevice->abyBBVGA[2] = 0x0;
1004 pDevice->abyBBVGA[3] = 0x0;
1005 pDevice->ldBmThreshold[0] = -70;
1006 pDevice->ldBmThreshold[1] = -48;
1007 pDevice->ldBmThreshold[2] = 0;
1008 pDevice->ldBmThreshold[3] = 0;
1010 else if (pDevice->byRFType == RF_AIROHA7230) {
1011 pDevice->byBBRxConf = abyVT3184_AL2230[10];
1012 wLength = sizeof(abyVT3184_AL2230);
1013 pbyAddr = abyVT3184_AL2230;
1014 pbyAgc = abyVT3184_AGC;
1015 wLengthAgc = sizeof(abyVT3184_AGC);
1017 // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1018 //pbyAddr[0x09] = 0x41;
1019 // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1020 //pbyAddr[0x0a] = 0x28;
1021 // Select VC1/VC2, CR215 = 0x02->0x06
1022 pbyAddr[0xd7] = 0x06;
1024 pDevice->abyBBVGA[0] = 0x1C;
1025 pDevice->abyBBVGA[1] = 0x10;
1026 pDevice->abyBBVGA[2] = 0x0;
1027 pDevice->abyBBVGA[3] = 0x0;
1028 pDevice->ldBmThreshold[0] = -70;
1029 pDevice->ldBmThreshold[1] = -48;
1030 pDevice->ldBmThreshold[2] = 0;
1031 pDevice->ldBmThreshold[3] = 0;
1033 else if ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) {
1034 pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; //RobertYu:20060515
1035 wLength = sizeof(abyVT3184_VT3226D0); //RobertYu:20060515
1036 pbyAddr = abyVT3184_VT3226D0; //RobertYu:20060515
1037 pbyAgc = abyVT3184_AGC;
1038 wLengthAgc = sizeof(abyVT3184_AGC);
1040 pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack
1041 pDevice->abyBBVGA[1] = 0x10;
1042 pDevice->abyBBVGA[2] = 0x0;
1043 pDevice->abyBBVGA[3] = 0x0;
1044 pDevice->ldBmThreshold[0] = -70;
1045 pDevice->ldBmThreshold[1] = -48;
1046 pDevice->ldBmThreshold[2] = 0;
1047 pDevice->ldBmThreshold[3] = 0;
1048 // Fix VT3226 DFC system timing issue
1049 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1051 //{{RobertYu:20060609
1052 } else if ( (pDevice->byRFType == RF_VT3342A0) ) {
1053 pDevice->byBBRxConf = abyVT3184_VT3226D0[10];
1054 wLength = sizeof(abyVT3184_VT3226D0);
1055 pbyAddr = abyVT3184_VT3226D0;
1056 pbyAgc = abyVT3184_AGC;
1057 wLengthAgc = sizeof(abyVT3184_AGC);
1059 pDevice->abyBBVGA[0] = 0x20;
1060 pDevice->abyBBVGA[1] = 0x10;
1061 pDevice->abyBBVGA[2] = 0x0;
1062 pDevice->abyBBVGA[3] = 0x0;
1063 pDevice->ldBmThreshold[0] = -70;
1064 pDevice->ldBmThreshold[1] = -48;
1065 pDevice->ldBmThreshold[2] = 0;
1066 pDevice->ldBmThreshold[3] = 0;
1067 // Fix VT3226 DFC system timing issue
1068 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1074 memcpy(abyArray, pbyAddr, wLength);
1075 CONTROLnsRequestOut(pDevice,
1078 MESSAGE_REQUEST_BBREG,
1083 memcpy(abyArray, pbyAgc, wLengthAgc);
1084 CONTROLnsRequestOut(pDevice,
1087 MESSAGE_REQUEST_BBAGC,
1092 if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0
1093 (pDevice->byRFType == RF_VT3342A0) //RobertYu:20060609
1095 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23);
1096 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1098 else if (pDevice->byRFType == RF_VT3226D0)
1100 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11);
1101 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1104 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F);
1105 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
1107 RFbRFTableDownload(pDevice);
1109 /* Fix for TX USB resets from vendors driver */
1110 CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ, USB_REG4,
1111 MESSAGE_REQUEST_MEM, sizeof(data), &data);
1115 CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, USB_REG4,
1116 MESSAGE_REQUEST_MEM, sizeof(data), &data);
1118 return true;//ntStatus;
1122 * Description: Set ShortSlotTime mode
1126 * pDevice - Device Structure
1130 * Return Value: none
1133 void BBvSetShortSlotTime(struct vnt_private *pDevice)
1137 if (pDevice->bShortSlotTime)
1138 pDevice->byBBRxConf &= 0xDF;//1101 1111
1140 pDevice->byBBRxConf |= 0x20;//0010 0000
1142 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
1143 if (byBBVGA == pDevice->abyBBVGA[0])
1144 pDevice->byBBRxConf |= 0x20;//0010 0000
1146 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
1149 void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData)
1152 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
1154 // patch for 3253B0 Baseband with Cardbus module
1155 if (pDevice->bShortSlotTime)
1156 pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */
1158 pDevice->byBBRxConf |= 0x20; /* 0010 0000 */
1160 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
1164 * Description: BBvSetDeepSleep
1168 * pDevice - Device Structure
1172 * Return Value: none
1175 void BBvSetDeepSleep(struct vnt_private *pDevice)
1177 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
1178 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
1181 void BBvExitDeepSleep(struct vnt_private *pDevice)
1183 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
1184 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
1187 static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice)
1190 unsigned long ulSQ3 = 0;
1191 unsigned long ulMaxPacket;
1193 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1194 if (pDevice->aulPktNum[RATE_54M] != 0)
1195 ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
1197 for (ii = RATE_48M; ii >= RATE_6M; ii--)
1198 if (pDevice->aulPktNum[ii] > ulMaxPacket) {
1199 ulMaxPacket = pDevice->aulPktNum[ii];
1200 ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
1206 static unsigned long s_ulGetRatio(struct vnt_private *pDevice)
1209 unsigned long ulRatio = 0;
1210 unsigned long ulMaxPacket;
1211 unsigned long ulPacketNum;
1213 //This is a thousand-ratio
1214 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1215 if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
1216 ulPacketNum = pDevice->aulPktNum[RATE_54M];
1217 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1218 ulRatio += TOP_RATE_54M;
1220 for (ii = RATE_48M; ii >= RATE_1M; ii--)
1221 if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
1223 for ( jj=RATE_54M;jj>=ii;jj--)
1224 ulPacketNum += pDevice->aulPktNum[jj];
1225 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1226 ulRatio += TOP_RATE_48M;
1227 ulMaxPacket = pDevice->aulPktNum[ii];
1233 static void s_vClearSQ3Value(struct vnt_private *pDevice)
1236 pDevice->uDiversityCnt = 0;
1238 for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
1239 pDevice->aulPktNum[ii] = 0;
1240 pDevice->aulSQ3Val[ii] = 0;
1245 * Description: Antenna Diversity
1249 * pDevice - Device Structure
1250 * byRSR - RSR from received packet
1251 * bySQ3 - SQ3 value from received packet
1255 * Return Value: none
1259 void BBvAntennaDiversity(struct vnt_private *pDevice,
1260 u8 byRxRate, u8 bySQ3)
1263 pDevice->uDiversityCnt++;
1264 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
1266 if (byRxRate == 2) {
1267 pDevice->aulPktNum[RATE_1M]++;
1269 else if (byRxRate==4) {
1270 pDevice->aulPktNum[RATE_2M]++;
1272 else if (byRxRate==11) {
1273 pDevice->aulPktNum[RATE_5M]++;
1275 else if (byRxRate==22) {
1276 pDevice->aulPktNum[RATE_11M]++;
1278 else if(byRxRate==12){
1279 pDevice->aulPktNum[RATE_6M]++;
1280 pDevice->aulSQ3Val[RATE_6M] += bySQ3;
1282 else if(byRxRate==18){
1283 pDevice->aulPktNum[RATE_9M]++;
1284 pDevice->aulSQ3Val[RATE_9M] += bySQ3;
1286 else if(byRxRate==24){
1287 pDevice->aulPktNum[RATE_12M]++;
1288 pDevice->aulSQ3Val[RATE_12M] += bySQ3;
1290 else if(byRxRate==36){
1291 pDevice->aulPktNum[RATE_18M]++;
1292 pDevice->aulSQ3Val[RATE_18M] += bySQ3;
1294 else if(byRxRate==48){
1295 pDevice->aulPktNum[RATE_24M]++;
1296 pDevice->aulSQ3Val[RATE_24M] += bySQ3;
1298 else if(byRxRate==72){
1299 pDevice->aulPktNum[RATE_36M]++;
1300 pDevice->aulSQ3Val[RATE_36M] += bySQ3;
1302 else if(byRxRate==96){
1303 pDevice->aulPktNum[RATE_48M]++;
1304 pDevice->aulSQ3Val[RATE_48M] += bySQ3;
1306 else if(byRxRate==108){
1307 pDevice->aulPktNum[RATE_54M]++;
1308 pDevice->aulSQ3Val[RATE_54M] += bySQ3;
1311 if (pDevice->byAntennaState == 0) {
1313 if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
1314 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
1316 pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
1317 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1318 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
1320 if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
1321 (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
1322 (pDevice->ulSQ3_State0 == 0 ) ) {
1324 if ( pDevice->byTMax == 0 )
1327 bScheduleCommand((void *) pDevice,
1328 WLAN_CMD_CHANGE_ANTENNA,
1331 pDevice->byAntennaState = 1;
1333 del_timer(&pDevice->TimerSQ3Tmax3);
1334 del_timer(&pDevice->TimerSQ3Tmax2);
1335 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1336 add_timer(&pDevice->TimerSQ3Tmax1);
1339 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1340 add_timer(&pDevice->TimerSQ3Tmax3);
1342 s_vClearSQ3Value(pDevice);
1345 } else { //byAntennaState == 1
1347 if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
1349 del_timer(&pDevice->TimerSQ3Tmax1);
1350 pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
1351 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
1352 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
1354 if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
1355 ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
1356 ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
1359 bScheduleCommand((void *) pDevice,
1360 WLAN_CMD_CHANGE_ANTENNA,
1363 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1364 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1365 add_timer(&pDevice->TimerSQ3Tmax3);
1366 add_timer(&pDevice->TimerSQ3Tmax2);
1369 pDevice->byAntennaState = 0;
1370 s_vClearSQ3Value(pDevice);
1378 * Timer for SQ3 antenna diversity
1383 * hDeviceContext - Pointer to the adapter
1389 * Return Value: none
1393 void TimerSQ3CallBack(struct vnt_private *pDevice)
1396 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
1397 spin_lock_irq(&pDevice->lock);
1399 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1400 pDevice->byAntennaState = 0;
1401 s_vClearSQ3Value(pDevice);
1402 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1403 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1404 add_timer(&pDevice->TimerSQ3Tmax3);
1405 add_timer(&pDevice->TimerSQ3Tmax2);
1407 spin_unlock_irq(&pDevice->lock);
1413 * Timer for SQ3 antenna diversity
1418 * hDeviceContext - Pointer to the adapter
1424 * Return Value: none
1428 void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice)
1431 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
1432 spin_lock_irq(&pDevice->lock);
1434 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1435 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
1437 s_vClearSQ3Value(pDevice);
1438 if ( pDevice->byTMax == 0 ) {
1439 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1440 add_timer(&pDevice->TimerSQ3Tmax3);
1441 spin_unlock_irq(&pDevice->lock);
1445 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1446 pDevice->byAntennaState = 1;
1447 del_timer(&pDevice->TimerSQ3Tmax3);
1448 del_timer(&pDevice->TimerSQ3Tmax2);
1449 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1450 add_timer(&pDevice->TimerSQ3Tmax1);
1452 spin_unlock_irq(&pDevice->lock);
1455 void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
1458 switch(pDevice->byRFType)
1463 //RobertYu:20060627, update new table
1466 { // need Max sensitivity //RSSI -69, -70,....
1467 if(pDevice->byBBPreEDIndex == 0) break;
1468 pDevice->byBBPreEDIndex = 0;
1469 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1470 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1471 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
1475 if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
1476 if(pDevice->byBBPreEDIndex == 20) break;
1477 pDevice->byBBPreEDIndex = 20;
1478 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1479 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1480 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
1481 } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
1482 if(pDevice->byBBPreEDIndex == 19) break;
1483 pDevice->byBBPreEDIndex = 19;
1484 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
1485 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1486 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
1487 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
1488 if(pDevice->byBBPreEDIndex == 18) break;
1489 pDevice->byBBPreEDIndex = 18;
1490 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
1491 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1492 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
1493 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1494 if(pDevice->byBBPreEDIndex == 17) break;
1495 pDevice->byBBPreEDIndex = 17;
1496 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
1497 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1498 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1499 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1500 if(pDevice->byBBPreEDIndex == 16) break;
1501 pDevice->byBBPreEDIndex = 16;
1502 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
1503 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1504 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1505 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1506 if(pDevice->byBBPreEDIndex == 15) break;
1507 pDevice->byBBPreEDIndex = 15;
1508 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
1509 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1510 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1511 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1512 if(pDevice->byBBPreEDIndex == 14) break;
1513 pDevice->byBBPreEDIndex = 14;
1514 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
1515 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1516 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1517 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1518 if(pDevice->byBBPreEDIndex == 13) break;
1519 pDevice->byBBPreEDIndex = 13;
1520 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1521 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1522 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1523 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1524 if(pDevice->byBBPreEDIndex == 12) break;
1525 pDevice->byBBPreEDIndex = 12;
1526 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1527 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
1528 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1529 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1530 if(pDevice->byBBPreEDIndex == 11) break;
1531 pDevice->byBBPreEDIndex = 11;
1532 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1533 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1534 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1535 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1536 if(pDevice->byBBPreEDIndex == 10) break;
1537 pDevice->byBBPreEDIndex = 10;
1538 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1539 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
1540 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1541 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1542 if(pDevice->byBBPreEDIndex == 9) break;
1543 pDevice->byBBPreEDIndex = 9;
1544 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1545 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
1546 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1547 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1548 if(pDevice->byBBPreEDIndex == 8) break;
1549 pDevice->byBBPreEDIndex = 8;
1550 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1551 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
1552 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1553 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1554 if(pDevice->byBBPreEDIndex == 7) break;
1555 pDevice->byBBPreEDIndex = 7;
1556 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1557 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
1558 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1559 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1560 if(pDevice->byBBPreEDIndex == 6) break;
1561 pDevice->byBBPreEDIndex = 6;
1562 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1563 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
1564 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1565 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1566 if(pDevice->byBBPreEDIndex == 5) break;
1567 pDevice->byBBPreEDIndex = 5;
1568 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1569 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
1570 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1571 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1572 if(pDevice->byBBPreEDIndex == 4) break;
1573 pDevice->byBBPreEDIndex = 4;
1574 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1575 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
1576 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1577 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1578 if(pDevice->byBBPreEDIndex == 3) break;
1579 pDevice->byBBPreEDIndex = 3;
1580 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1581 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
1582 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1583 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1584 if(pDevice->byBBPreEDIndex == 2) break;
1585 pDevice->byBBPreEDIndex = 2;
1586 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1587 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1588 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1589 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1590 if(pDevice->byBBPreEDIndex == 1) break;
1591 pDevice->byBBPreEDIndex = 1;
1592 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1593 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1594 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1595 } else { //RSSI -69, -70,....
1596 if(pDevice->byBBPreEDIndex == 0) break;
1597 pDevice->byBBPreEDIndex = 0;
1598 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1599 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1600 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
1606 //RobertYu:20060627, update new table
1609 { // need Max sensitivity //RSSI -69, -70, ...
1610 if(pDevice->byBBPreEDIndex == 0) break;
1611 pDevice->byBBPreEDIndex = 0;
1612 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1613 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1614 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1618 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1619 if(pDevice->byBBPreEDIndex == 22) break;
1620 pDevice->byBBPreEDIndex = 22;
1621 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1622 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1623 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1624 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1625 if(pDevice->byBBPreEDIndex == 21) break;
1626 pDevice->byBBPreEDIndex = 21;
1627 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1628 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1629 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1630 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1631 if(pDevice->byBBPreEDIndex == 20) break;
1632 pDevice->byBBPreEDIndex = 20;
1633 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1634 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1635 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1636 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1637 if(pDevice->byBBPreEDIndex == 19) break;
1638 pDevice->byBBPreEDIndex = 19;
1639 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1640 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1641 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1642 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1643 if(pDevice->byBBPreEDIndex == 18) break;
1644 pDevice->byBBPreEDIndex = 18;
1645 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1646 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1647 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1648 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1649 if(pDevice->byBBPreEDIndex == 17) break;
1650 pDevice->byBBPreEDIndex = 17;
1651 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1652 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1653 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1654 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1655 if(pDevice->byBBPreEDIndex == 16) break;
1656 pDevice->byBBPreEDIndex = 16;
1657 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1658 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1659 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1660 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1661 if(pDevice->byBBPreEDIndex == 15) break;
1662 pDevice->byBBPreEDIndex = 15;
1663 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1664 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1665 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1666 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1667 if(pDevice->byBBPreEDIndex == 14) break;
1668 pDevice->byBBPreEDIndex = 14;
1669 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1670 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1671 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1672 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1673 if(pDevice->byBBPreEDIndex == 13) break;
1674 pDevice->byBBPreEDIndex = 13;
1675 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1676 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1677 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1678 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1679 if(pDevice->byBBPreEDIndex == 12) break;
1680 pDevice->byBBPreEDIndex = 12;
1681 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1682 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1683 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1684 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1685 if(pDevice->byBBPreEDIndex == 11) break;
1686 pDevice->byBBPreEDIndex = 11;
1687 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1688 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1689 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1690 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1691 if(pDevice->byBBPreEDIndex == 10) break;
1692 pDevice->byBBPreEDIndex = 10;
1693 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1694 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1695 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1696 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1697 if(pDevice->byBBPreEDIndex == 9) break;
1698 pDevice->byBBPreEDIndex = 9;
1699 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1700 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1701 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1702 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1703 if(pDevice->byBBPreEDIndex == 8) break;
1704 pDevice->byBBPreEDIndex = 8;
1705 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1706 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1707 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1708 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1709 if(pDevice->byBBPreEDIndex == 7) break;
1710 pDevice->byBBPreEDIndex = 7;
1711 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1712 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1713 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1714 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1715 if(pDevice->byBBPreEDIndex == 6) break;
1716 pDevice->byBBPreEDIndex = 6;
1717 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1718 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1719 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1720 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1721 if(pDevice->byBBPreEDIndex == 5) break;
1722 pDevice->byBBPreEDIndex = 5;
1723 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1724 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1725 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1726 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1727 if(pDevice->byBBPreEDIndex == 4) break;
1728 pDevice->byBBPreEDIndex = 4;
1729 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1730 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1731 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1732 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1733 if(pDevice->byBBPreEDIndex == 3) break;
1734 pDevice->byBBPreEDIndex = 3;
1735 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1736 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1737 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1738 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1739 if(pDevice->byBBPreEDIndex == 2) break;
1740 pDevice->byBBPreEDIndex = 2;
1741 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1742 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1743 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1744 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1745 if(pDevice->byBBPreEDIndex == 1) break;
1746 pDevice->byBBPreEDIndex = 1;
1747 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1748 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
1749 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1750 } else { //RSSI -69, -70, ...
1751 if(pDevice->byBBPreEDIndex == 0) break;
1752 pDevice->byBBPreEDIndex = 0;
1753 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1754 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1755 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1759 case RF_VT3342A0: //RobertYu:20060627, testing table
1761 { // need Max sensitivity //RSSI -67, -68, ...
1762 if(pDevice->byBBPreEDIndex == 0) break;
1763 pDevice->byBBPreEDIndex = 0;
1764 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1765 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1766 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
1770 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1771 if(pDevice->byBBPreEDIndex == 20) break;
1772 pDevice->byBBPreEDIndex = 20;
1773 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1774 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1775 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1776 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1777 if(pDevice->byBBPreEDIndex == 19) break;
1778 pDevice->byBBPreEDIndex = 19;
1779 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1780 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1781 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1782 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1783 if(pDevice->byBBPreEDIndex == 18) break;
1784 pDevice->byBBPreEDIndex = 18;
1785 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1786 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1787 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1788 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1789 if(pDevice->byBBPreEDIndex == 17) break;
1790 pDevice->byBBPreEDIndex = 17;
1791 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1792 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1793 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1794 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1795 if(pDevice->byBBPreEDIndex == 16) break;
1796 pDevice->byBBPreEDIndex = 16;
1797 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1798 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1799 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1800 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1801 if(pDevice->byBBPreEDIndex == 15) break;
1802 pDevice->byBBPreEDIndex = 15;
1803 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1804 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1805 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1806 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1807 if(pDevice->byBBPreEDIndex == 14) break;
1808 pDevice->byBBPreEDIndex = 14;
1809 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1810 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1811 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1812 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1813 if(pDevice->byBBPreEDIndex == 13) break;
1814 pDevice->byBBPreEDIndex = 13;
1815 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1816 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1817 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1818 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1819 if(pDevice->byBBPreEDIndex == 12) break;
1820 pDevice->byBBPreEDIndex = 12;
1821 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1822 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1823 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1824 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1825 if(pDevice->byBBPreEDIndex == 11) break;
1826 pDevice->byBBPreEDIndex = 11;
1827 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1828 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1829 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1830 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1831 if(pDevice->byBBPreEDIndex == 10) break;
1832 pDevice->byBBPreEDIndex = 10;
1833 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1834 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1835 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1836 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1837 if(pDevice->byBBPreEDIndex == 9) break;
1838 pDevice->byBBPreEDIndex = 9;
1839 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1840 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1841 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1842 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1843 if(pDevice->byBBPreEDIndex == 8) break;
1844 pDevice->byBBPreEDIndex = 8;
1845 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1846 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1847 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1848 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1849 if(pDevice->byBBPreEDIndex == 7) break;
1850 pDevice->byBBPreEDIndex = 7;
1851 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1852 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1853 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1854 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1855 if(pDevice->byBBPreEDIndex == 6) break;
1856 pDevice->byBBPreEDIndex = 6;
1857 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1858 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1859 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1860 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1861 if(pDevice->byBBPreEDIndex == 5) break;
1862 pDevice->byBBPreEDIndex = 5;
1863 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1864 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1865 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1866 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1867 if(pDevice->byBBPreEDIndex == 4) break;
1868 pDevice->byBBPreEDIndex = 4;
1869 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1870 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1871 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1872 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1873 if(pDevice->byBBPreEDIndex == 3) break;
1874 pDevice->byBBPreEDIndex = 3;
1875 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1876 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1877 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1878 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1879 if(pDevice->byBBPreEDIndex == 2) break;
1880 pDevice->byBBPreEDIndex = 2;
1881 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1882 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1883 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1884 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1885 if(pDevice->byBBPreEDIndex == 1) break;
1886 pDevice->byBBPreEDIndex = 1;
1887 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1888 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1889 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1890 } else { //RSSI -67, -68, ...
1891 if(pDevice->byBBPreEDIndex == 0) break;
1892 pDevice->byBBPreEDIndex = 0;
1893 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1894 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1895 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");