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)
943 ntStatus = CONTROLnsRequestIn(pDevice,
946 MESSAGE_REQUEST_EEPROM,
947 EEP_MAX_CONTEXT_SIZE,
949 if (ntStatus != STATUS_SUCCESS) {
953 // if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04)
957 pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
958 if(pDevice->config_file.ZoneType >= 0) { //read zonetype file ok!
959 if ((pDevice->config_file.ZoneType == 0)&&
960 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA
961 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
962 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
963 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n");
965 else if((pDevice->config_file.ZoneType == 1)&&
966 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){ //for Japan
967 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
968 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
969 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n");
971 else if((pDevice->config_file.ZoneType == 2)&&
972 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){ //for Europe
973 pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
974 pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
975 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n");
978 if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE])
979 printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]);
981 printk("Read Zonetype file success,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType);
985 if ( !pDevice->bZoneRegExist ) {
986 pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE];
988 pDevice->byRFType = pDevice->abyEEPROM[EEP_OFS_RFTYPE];
990 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", pDevice->byZoneType);
991 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", pDevice->byRFType);
993 if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) {
994 pDevice->byBBRxConf = abyVT3184_AL2230[10];
995 wLength = sizeof(abyVT3184_AL2230);
996 pbyAddr = abyVT3184_AL2230;
997 pbyAgc = abyVT3184_AGC;
998 wLengthAgc = sizeof(abyVT3184_AGC);
1000 pDevice->abyBBVGA[0] = 0x1C;
1001 pDevice->abyBBVGA[1] = 0x10;
1002 pDevice->abyBBVGA[2] = 0x0;
1003 pDevice->abyBBVGA[3] = 0x0;
1004 pDevice->ldBmThreshold[0] = -70;
1005 pDevice->ldBmThreshold[1] = -48;
1006 pDevice->ldBmThreshold[2] = 0;
1007 pDevice->ldBmThreshold[3] = 0;
1009 else if (pDevice->byRFType == RF_AIROHA7230) {
1010 pDevice->byBBRxConf = abyVT3184_AL2230[10];
1011 wLength = sizeof(abyVT3184_AL2230);
1012 pbyAddr = abyVT3184_AL2230;
1013 pbyAgc = abyVT3184_AGC;
1014 wLengthAgc = sizeof(abyVT3184_AGC);
1016 // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1017 //pbyAddr[0x09] = 0x41;
1018 // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted)
1019 //pbyAddr[0x0a] = 0x28;
1020 // Select VC1/VC2, CR215 = 0x02->0x06
1021 pbyAddr[0xd7] = 0x06;
1023 pDevice->abyBBVGA[0] = 0x1C;
1024 pDevice->abyBBVGA[1] = 0x10;
1025 pDevice->abyBBVGA[2] = 0x0;
1026 pDevice->abyBBVGA[3] = 0x0;
1027 pDevice->ldBmThreshold[0] = -70;
1028 pDevice->ldBmThreshold[1] = -48;
1029 pDevice->ldBmThreshold[2] = 0;
1030 pDevice->ldBmThreshold[3] = 0;
1032 else if ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) {
1033 pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; //RobertYu:20060515
1034 wLength = sizeof(abyVT3184_VT3226D0); //RobertYu:20060515
1035 pbyAddr = abyVT3184_VT3226D0; //RobertYu:20060515
1036 pbyAgc = abyVT3184_AGC;
1037 wLengthAgc = sizeof(abyVT3184_AGC);
1039 pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack
1040 pDevice->abyBBVGA[1] = 0x10;
1041 pDevice->abyBBVGA[2] = 0x0;
1042 pDevice->abyBBVGA[3] = 0x0;
1043 pDevice->ldBmThreshold[0] = -70;
1044 pDevice->ldBmThreshold[1] = -48;
1045 pDevice->ldBmThreshold[2] = 0;
1046 pDevice->ldBmThreshold[3] = 0;
1047 // Fix VT3226 DFC system timing issue
1048 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1050 //{{RobertYu:20060609
1051 } else if ( (pDevice->byRFType == RF_VT3342A0) ) {
1052 pDevice->byBBRxConf = abyVT3184_VT3226D0[10];
1053 wLength = sizeof(abyVT3184_VT3226D0);
1054 pbyAddr = abyVT3184_VT3226D0;
1055 pbyAgc = abyVT3184_AGC;
1056 wLengthAgc = sizeof(abyVT3184_AGC);
1058 pDevice->abyBBVGA[0] = 0x20;
1059 pDevice->abyBBVGA[1] = 0x10;
1060 pDevice->abyBBVGA[2] = 0x0;
1061 pDevice->abyBBVGA[3] = 0x0;
1062 pDevice->ldBmThreshold[0] = -70;
1063 pDevice->ldBmThreshold[1] = -48;
1064 pDevice->ldBmThreshold[2] = 0;
1065 pDevice->ldBmThreshold[3] = 0;
1066 // Fix VT3226 DFC system timing issue
1067 MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1073 memcpy(abyArray, pbyAddr, wLength);
1074 CONTROLnsRequestOut(pDevice,
1077 MESSAGE_REQUEST_BBREG,
1082 memcpy(abyArray, pbyAgc, wLengthAgc);
1083 CONTROLnsRequestOut(pDevice,
1086 MESSAGE_REQUEST_BBAGC,
1091 if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0
1092 (pDevice->byRFType == RF_VT3342A0) //RobertYu:20060609
1094 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23);
1095 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1097 else if (pDevice->byRFType == RF_VT3226D0)
1099 ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11);
1100 MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01);
1103 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F);
1104 ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01);
1106 RFbRFTableDownload(pDevice);
1107 return true;//ntStatus;
1111 * Description: Set ShortSlotTime mode
1115 * pDevice - Device Structure
1119 * Return Value: none
1122 void BBvSetShortSlotTime(struct vnt_private *pDevice)
1126 if (pDevice->bShortSlotTime)
1127 pDevice->byBBRxConf &= 0xDF;//1101 1111
1129 pDevice->byBBRxConf |= 0x20;//0010 0000
1131 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
1132 if (byBBVGA == pDevice->abyBBVGA[0])
1133 pDevice->byBBRxConf |= 0x20;//0010 0000
1135 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
1138 void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData)
1141 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
1143 // patch for 3253B0 Baseband with Cardbus module
1144 if (pDevice->bShortSlotTime)
1145 pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */
1147 pDevice->byBBRxConf |= 0x20; /* 0010 0000 */
1149 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
1153 * Description: BBvSetDeepSleep
1157 * pDevice - Device Structure
1161 * Return Value: none
1164 void BBvSetDeepSleep(struct vnt_private *pDevice)
1166 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
1167 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
1170 void BBvExitDeepSleep(struct vnt_private *pDevice)
1172 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
1173 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
1176 static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice)
1179 unsigned long ulSQ3 = 0;
1180 unsigned long ulMaxPacket;
1182 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1183 if (pDevice->aulPktNum[RATE_54M] != 0)
1184 ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
1186 for (ii = RATE_48M; ii >= RATE_6M; ii--)
1187 if (pDevice->aulPktNum[ii] > ulMaxPacket) {
1188 ulMaxPacket = pDevice->aulPktNum[ii];
1189 ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
1195 static unsigned long s_ulGetRatio(struct vnt_private *pDevice)
1198 unsigned long ulRatio = 0;
1199 unsigned long ulMaxPacket;
1200 unsigned long ulPacketNum;
1202 //This is a thousand-ratio
1203 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1204 if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
1205 ulPacketNum = pDevice->aulPktNum[RATE_54M];
1206 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1207 ulRatio += TOP_RATE_54M;
1209 for (ii = RATE_48M; ii >= RATE_1M; ii--)
1210 if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
1212 for ( jj=RATE_54M;jj>=ii;jj--)
1213 ulPacketNum += pDevice->aulPktNum[jj];
1214 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1215 ulRatio += TOP_RATE_48M;
1216 ulMaxPacket = pDevice->aulPktNum[ii];
1222 static void s_vClearSQ3Value(struct vnt_private *pDevice)
1225 pDevice->uDiversityCnt = 0;
1227 for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
1228 pDevice->aulPktNum[ii] = 0;
1229 pDevice->aulSQ3Val[ii] = 0;
1234 * Description: Antenna Diversity
1238 * pDevice - Device Structure
1239 * byRSR - RSR from received packet
1240 * bySQ3 - SQ3 value from received packet
1244 * Return Value: none
1248 void BBvAntennaDiversity(struct vnt_private *pDevice,
1249 u8 byRxRate, u8 bySQ3)
1252 pDevice->uDiversityCnt++;
1253 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
1255 if (byRxRate == 2) {
1256 pDevice->aulPktNum[RATE_1M]++;
1258 else if (byRxRate==4) {
1259 pDevice->aulPktNum[RATE_2M]++;
1261 else if (byRxRate==11) {
1262 pDevice->aulPktNum[RATE_5M]++;
1264 else if (byRxRate==22) {
1265 pDevice->aulPktNum[RATE_11M]++;
1267 else if(byRxRate==12){
1268 pDevice->aulPktNum[RATE_6M]++;
1269 pDevice->aulSQ3Val[RATE_6M] += bySQ3;
1271 else if(byRxRate==18){
1272 pDevice->aulPktNum[RATE_9M]++;
1273 pDevice->aulSQ3Val[RATE_9M] += bySQ3;
1275 else if(byRxRate==24){
1276 pDevice->aulPktNum[RATE_12M]++;
1277 pDevice->aulSQ3Val[RATE_12M] += bySQ3;
1279 else if(byRxRate==36){
1280 pDevice->aulPktNum[RATE_18M]++;
1281 pDevice->aulSQ3Val[RATE_18M] += bySQ3;
1283 else if(byRxRate==48){
1284 pDevice->aulPktNum[RATE_24M]++;
1285 pDevice->aulSQ3Val[RATE_24M] += bySQ3;
1287 else if(byRxRate==72){
1288 pDevice->aulPktNum[RATE_36M]++;
1289 pDevice->aulSQ3Val[RATE_36M] += bySQ3;
1291 else if(byRxRate==96){
1292 pDevice->aulPktNum[RATE_48M]++;
1293 pDevice->aulSQ3Val[RATE_48M] += bySQ3;
1295 else if(byRxRate==108){
1296 pDevice->aulPktNum[RATE_54M]++;
1297 pDevice->aulSQ3Val[RATE_54M] += bySQ3;
1300 if (pDevice->byAntennaState == 0) {
1302 if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
1303 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
1305 pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
1306 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1307 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
1309 if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
1310 (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
1311 (pDevice->ulSQ3_State0 == 0 ) ) {
1313 if ( pDevice->byTMax == 0 )
1316 bScheduleCommand((void *) pDevice,
1317 WLAN_CMD_CHANGE_ANTENNA,
1320 pDevice->byAntennaState = 1;
1322 del_timer(&pDevice->TimerSQ3Tmax3);
1323 del_timer(&pDevice->TimerSQ3Tmax2);
1324 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1325 add_timer(&pDevice->TimerSQ3Tmax1);
1328 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1329 add_timer(&pDevice->TimerSQ3Tmax3);
1331 s_vClearSQ3Value(pDevice);
1334 } else { //byAntennaState == 1
1336 if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
1338 del_timer(&pDevice->TimerSQ3Tmax1);
1339 pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
1340 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
1341 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
1343 if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
1344 ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
1345 ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
1348 bScheduleCommand((void *) pDevice,
1349 WLAN_CMD_CHANGE_ANTENNA,
1352 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1353 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1354 add_timer(&pDevice->TimerSQ3Tmax3);
1355 add_timer(&pDevice->TimerSQ3Tmax2);
1358 pDevice->byAntennaState = 0;
1359 s_vClearSQ3Value(pDevice);
1367 * Timer for SQ3 antenna diversity
1372 * hDeviceContext - Pointer to the adapter
1378 * Return Value: none
1382 void TimerSQ3CallBack(struct vnt_private *pDevice)
1385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
1386 spin_lock_irq(&pDevice->lock);
1388 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1389 pDevice->byAntennaState = 0;
1390 s_vClearSQ3Value(pDevice);
1391 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1392 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1393 add_timer(&pDevice->TimerSQ3Tmax3);
1394 add_timer(&pDevice->TimerSQ3Tmax2);
1396 spin_unlock_irq(&pDevice->lock);
1402 * Timer for SQ3 antenna diversity
1407 * hDeviceContext - Pointer to the adapter
1413 * Return Value: none
1417 void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice)
1420 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
1421 spin_lock_irq(&pDevice->lock);
1423 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1424 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
1426 s_vClearSQ3Value(pDevice);
1427 if ( pDevice->byTMax == 0 ) {
1428 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1429 add_timer(&pDevice->TimerSQ3Tmax3);
1430 spin_unlock_irq(&pDevice->lock);
1434 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1435 pDevice->byAntennaState = 1;
1436 del_timer(&pDevice->TimerSQ3Tmax3);
1437 del_timer(&pDevice->TimerSQ3Tmax2);
1438 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1439 add_timer(&pDevice->TimerSQ3Tmax1);
1441 spin_unlock_irq(&pDevice->lock);
1444 void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
1447 switch(pDevice->byRFType)
1452 //RobertYu:20060627, update new table
1455 { // need Max sensitivity //RSSI -69, -70,....
1456 if(pDevice->byBBPreEDIndex == 0) break;
1457 pDevice->byBBPreEDIndex = 0;
1458 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1459 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1460 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
1464 if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
1465 if(pDevice->byBBPreEDIndex == 20) break;
1466 pDevice->byBBPreEDIndex = 20;
1467 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1468 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1469 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
1470 } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
1471 if(pDevice->byBBPreEDIndex == 19) break;
1472 pDevice->byBBPreEDIndex = 19;
1473 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
1474 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1475 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
1476 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
1477 if(pDevice->byBBPreEDIndex == 18) break;
1478 pDevice->byBBPreEDIndex = 18;
1479 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
1480 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1481 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
1482 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1483 if(pDevice->byBBPreEDIndex == 17) break;
1484 pDevice->byBBPreEDIndex = 17;
1485 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
1486 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1487 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1488 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1489 if(pDevice->byBBPreEDIndex == 16) break;
1490 pDevice->byBBPreEDIndex = 16;
1491 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
1492 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1493 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1494 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1495 if(pDevice->byBBPreEDIndex == 15) break;
1496 pDevice->byBBPreEDIndex = 15;
1497 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
1498 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1499 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1500 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1501 if(pDevice->byBBPreEDIndex == 14) break;
1502 pDevice->byBBPreEDIndex = 14;
1503 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
1504 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1505 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1506 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1507 if(pDevice->byBBPreEDIndex == 13) break;
1508 pDevice->byBBPreEDIndex = 13;
1509 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1510 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1511 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1512 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1513 if(pDevice->byBBPreEDIndex == 12) break;
1514 pDevice->byBBPreEDIndex = 12;
1515 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1516 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
1517 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1518 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1519 if(pDevice->byBBPreEDIndex == 11) break;
1520 pDevice->byBBPreEDIndex = 11;
1521 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1522 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1523 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1524 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1525 if(pDevice->byBBPreEDIndex == 10) break;
1526 pDevice->byBBPreEDIndex = 10;
1527 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1528 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
1529 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1530 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1531 if(pDevice->byBBPreEDIndex == 9) break;
1532 pDevice->byBBPreEDIndex = 9;
1533 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1534 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
1535 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1536 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1537 if(pDevice->byBBPreEDIndex == 8) break;
1538 pDevice->byBBPreEDIndex = 8;
1539 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1540 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
1541 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1542 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1543 if(pDevice->byBBPreEDIndex == 7) break;
1544 pDevice->byBBPreEDIndex = 7;
1545 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1546 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
1547 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1548 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1549 if(pDevice->byBBPreEDIndex == 6) break;
1550 pDevice->byBBPreEDIndex = 6;
1551 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1552 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
1553 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1554 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1555 if(pDevice->byBBPreEDIndex == 5) break;
1556 pDevice->byBBPreEDIndex = 5;
1557 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1558 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
1559 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1560 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1561 if(pDevice->byBBPreEDIndex == 4) break;
1562 pDevice->byBBPreEDIndex = 4;
1563 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1564 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
1565 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1566 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1567 if(pDevice->byBBPreEDIndex == 3) break;
1568 pDevice->byBBPreEDIndex = 3;
1569 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1570 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
1571 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1572 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1573 if(pDevice->byBBPreEDIndex == 2) break;
1574 pDevice->byBBPreEDIndex = 2;
1575 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1576 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1577 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1578 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1579 if(pDevice->byBBPreEDIndex == 1) break;
1580 pDevice->byBBPreEDIndex = 1;
1581 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1582 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1583 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1584 } else { //RSSI -69, -70,....
1585 if(pDevice->byBBPreEDIndex == 0) break;
1586 pDevice->byBBPreEDIndex = 0;
1587 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1588 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1589 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
1595 //RobertYu:20060627, update new table
1598 { // need Max sensitivity //RSSI -69, -70, ...
1599 if(pDevice->byBBPreEDIndex == 0) break;
1600 pDevice->byBBPreEDIndex = 0;
1601 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1602 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1603 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1607 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1608 if(pDevice->byBBPreEDIndex == 22) break;
1609 pDevice->byBBPreEDIndex = 22;
1610 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1611 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1612 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1613 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1614 if(pDevice->byBBPreEDIndex == 21) break;
1615 pDevice->byBBPreEDIndex = 21;
1616 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1617 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1618 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1619 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1620 if(pDevice->byBBPreEDIndex == 20) break;
1621 pDevice->byBBPreEDIndex = 20;
1622 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1623 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1624 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1625 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1626 if(pDevice->byBBPreEDIndex == 19) break;
1627 pDevice->byBBPreEDIndex = 19;
1628 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1629 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1630 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1631 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1632 if(pDevice->byBBPreEDIndex == 18) break;
1633 pDevice->byBBPreEDIndex = 18;
1634 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1635 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1636 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1637 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1638 if(pDevice->byBBPreEDIndex == 17) break;
1639 pDevice->byBBPreEDIndex = 17;
1640 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1641 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1642 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1643 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1644 if(pDevice->byBBPreEDIndex == 16) break;
1645 pDevice->byBBPreEDIndex = 16;
1646 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1647 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1648 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1649 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1650 if(pDevice->byBBPreEDIndex == 15) break;
1651 pDevice->byBBPreEDIndex = 15;
1652 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1653 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1654 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1655 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1656 if(pDevice->byBBPreEDIndex == 14) break;
1657 pDevice->byBBPreEDIndex = 14;
1658 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1659 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1660 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1661 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1662 if(pDevice->byBBPreEDIndex == 13) break;
1663 pDevice->byBBPreEDIndex = 13;
1664 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1665 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1666 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1667 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1668 if(pDevice->byBBPreEDIndex == 12) break;
1669 pDevice->byBBPreEDIndex = 12;
1670 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1671 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1672 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1673 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1674 if(pDevice->byBBPreEDIndex == 11) break;
1675 pDevice->byBBPreEDIndex = 11;
1676 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1677 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1678 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1679 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1680 if(pDevice->byBBPreEDIndex == 10) break;
1681 pDevice->byBBPreEDIndex = 10;
1682 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1683 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1684 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1685 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1686 if(pDevice->byBBPreEDIndex == 9) break;
1687 pDevice->byBBPreEDIndex = 9;
1688 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1689 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1690 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1691 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1692 if(pDevice->byBBPreEDIndex == 8) break;
1693 pDevice->byBBPreEDIndex = 8;
1694 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1695 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1696 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1697 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1698 if(pDevice->byBBPreEDIndex == 7) break;
1699 pDevice->byBBPreEDIndex = 7;
1700 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1701 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1702 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1703 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1704 if(pDevice->byBBPreEDIndex == 6) break;
1705 pDevice->byBBPreEDIndex = 6;
1706 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1707 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1708 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1709 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1710 if(pDevice->byBBPreEDIndex == 5) break;
1711 pDevice->byBBPreEDIndex = 5;
1712 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1713 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1714 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1715 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1716 if(pDevice->byBBPreEDIndex == 4) break;
1717 pDevice->byBBPreEDIndex = 4;
1718 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1719 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1720 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1721 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1722 if(pDevice->byBBPreEDIndex == 3) break;
1723 pDevice->byBBPreEDIndex = 3;
1724 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1725 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1726 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1727 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1728 if(pDevice->byBBPreEDIndex == 2) break;
1729 pDevice->byBBPreEDIndex = 2;
1730 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1731 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1732 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1733 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1734 if(pDevice->byBBPreEDIndex == 1) break;
1735 pDevice->byBBPreEDIndex = 1;
1736 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1737 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
1738 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1739 } else { //RSSI -69, -70, ...
1740 if(pDevice->byBBPreEDIndex == 0) break;
1741 pDevice->byBBPreEDIndex = 0;
1742 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1743 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1744 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1748 case RF_VT3342A0: //RobertYu:20060627, testing table
1750 { // need Max sensitivity //RSSI -67, -68, ...
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, 0x38); //CR206(0xCE)
1755 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
1759 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1760 if(pDevice->byBBPreEDIndex == 20) break;
1761 pDevice->byBBPreEDIndex = 20;
1762 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1763 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1764 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1765 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1766 if(pDevice->byBBPreEDIndex == 19) break;
1767 pDevice->byBBPreEDIndex = 19;
1768 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1769 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1770 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1771 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1772 if(pDevice->byBBPreEDIndex == 18) break;
1773 pDevice->byBBPreEDIndex = 18;
1774 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1775 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1776 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1777 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1778 if(pDevice->byBBPreEDIndex == 17) break;
1779 pDevice->byBBPreEDIndex = 17;
1780 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1781 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1782 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1783 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1784 if(pDevice->byBBPreEDIndex == 16) break;
1785 pDevice->byBBPreEDIndex = 16;
1786 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1787 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1788 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1789 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1790 if(pDevice->byBBPreEDIndex == 15) break;
1791 pDevice->byBBPreEDIndex = 15;
1792 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1793 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1794 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1795 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1796 if(pDevice->byBBPreEDIndex == 14) break;
1797 pDevice->byBBPreEDIndex = 14;
1798 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1799 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1800 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1801 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1802 if(pDevice->byBBPreEDIndex == 13) break;
1803 pDevice->byBBPreEDIndex = 13;
1804 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1805 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1806 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1807 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1808 if(pDevice->byBBPreEDIndex == 12) break;
1809 pDevice->byBBPreEDIndex = 12;
1810 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1811 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1812 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1813 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1814 if(pDevice->byBBPreEDIndex == 11) break;
1815 pDevice->byBBPreEDIndex = 11;
1816 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1817 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1818 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1819 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1820 if(pDevice->byBBPreEDIndex == 10) break;
1821 pDevice->byBBPreEDIndex = 10;
1822 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1823 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1824 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1825 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1826 if(pDevice->byBBPreEDIndex == 9) break;
1827 pDevice->byBBPreEDIndex = 9;
1828 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1829 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1830 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1831 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1832 if(pDevice->byBBPreEDIndex == 8) break;
1833 pDevice->byBBPreEDIndex = 8;
1834 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1835 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1836 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1837 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1838 if(pDevice->byBBPreEDIndex == 7) break;
1839 pDevice->byBBPreEDIndex = 7;
1840 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1841 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1842 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1843 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1844 if(pDevice->byBBPreEDIndex == 6) break;
1845 pDevice->byBBPreEDIndex = 6;
1846 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1847 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1848 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1849 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1850 if(pDevice->byBBPreEDIndex == 5) break;
1851 pDevice->byBBPreEDIndex = 5;
1852 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1853 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1854 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1855 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1856 if(pDevice->byBBPreEDIndex == 4) break;
1857 pDevice->byBBPreEDIndex = 4;
1858 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1859 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1860 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1861 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1862 if(pDevice->byBBPreEDIndex == 3) break;
1863 pDevice->byBBPreEDIndex = 3;
1864 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1865 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1866 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1867 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1868 if(pDevice->byBBPreEDIndex == 2) break;
1869 pDevice->byBBPreEDIndex = 2;
1870 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1871 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1872 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1873 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1874 if(pDevice->byBBPreEDIndex == 1) break;
1875 pDevice->byBBPreEDIndex = 1;
1876 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1877 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1878 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1879 } else { //RSSI -67, -68, ...
1880 if(pDevice->byBBPreEDIndex == 0) break;
1881 pDevice->byBBPreEDIndex = 0;
1882 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1883 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1884 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");