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 static u8 abyVT3184_AGC[] = {
55 0x02, //3 //RobertYu:20060505, 0x04, //3
57 0x04, //5 //RobertYu:20060505, 0x06, //5
118 static 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 static 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 static 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 *priv)
944 status = CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, 0,
945 MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE,
947 if (status != STATUS_SUCCESS)
950 /* zonetype initial */
951 priv->byOriginalZonetype = priv->abyEEPROM[EEP_OFS_ZONETYPE];
953 if (priv->config_file.ZoneType >= 0) {
954 if ((priv->config_file.ZoneType == 0) &&
955 (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) {
956 priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0;
957 priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B;
958 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
959 "Init Zone Type :USA\n");
960 } else if ((priv->config_file.ZoneType == 1) &&
961 (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) {
962 priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01;
963 priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
964 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
965 "Init Zone Type :Japan\n");
966 } else if ((priv->config_file.ZoneType == 2) &&
967 (priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) {
968 priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02;
969 priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D;
970 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
971 "Init Zone Type :Europe\n");
973 if (priv->config_file.ZoneType !=
974 priv->abyEEPROM[EEP_OFS_ZONETYPE])
975 printk("zonetype in file[%02x]\
976 mismatch with in EEPROM[%02x]\n",
977 priv->config_file.ZoneType,
978 priv->abyEEPROM[EEP_OFS_ZONETYPE]);
980 printk("Read Zonetype file success,\
981 use default zonetype setting[%02x]\n",
982 priv->config_file.ZoneType);
986 if (!priv->bZoneRegExist)
987 priv->byZoneType = priv->abyEEPROM[EEP_OFS_ZONETYPE];
989 priv->byRFType = priv->abyEEPROM[EEP_OFS_RFTYPE];
991 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n",
994 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", priv->byRFType);
996 if ((priv->byRFType == RF_AL2230) ||
997 (priv->byRFType == RF_AL2230S)) {
998 priv->byBBRxConf = abyVT3184_AL2230[10];
999 lenght = sizeof(abyVT3184_AL2230);
1000 addr = abyVT3184_AL2230;
1001 agc = abyVT3184_AGC;
1002 lenght_agc = sizeof(abyVT3184_AGC);
1004 priv->abyBBVGA[0] = 0x1C;
1005 priv->abyBBVGA[1] = 0x10;
1006 priv->abyBBVGA[2] = 0x0;
1007 priv->abyBBVGA[3] = 0x0;
1008 priv->ldBmThreshold[0] = -70;
1009 priv->ldBmThreshold[1] = -48;
1010 priv->ldBmThreshold[2] = 0;
1011 priv->ldBmThreshold[3] = 0;
1012 } else if (priv->byRFType == RF_AIROHA7230) {
1013 priv->byBBRxConf = abyVT3184_AL2230[10];
1014 lenght = sizeof(abyVT3184_AL2230);
1015 addr = abyVT3184_AL2230;
1016 agc = abyVT3184_AGC;
1017 lenght_agc = sizeof(abyVT3184_AGC);
1021 priv->abyBBVGA[0] = 0x1c;
1022 priv->abyBBVGA[1] = 0x10;
1023 priv->abyBBVGA[2] = 0x0;
1024 priv->abyBBVGA[3] = 0x0;
1025 priv->ldBmThreshold[0] = -70;
1026 priv->ldBmThreshold[1] = -48;
1027 priv->ldBmThreshold[2] = 0;
1028 priv->ldBmThreshold[3] = 0;
1029 } else if ((priv->byRFType == RF_VT3226) ||
1030 (priv->byRFType == RF_VT3226D0)) {
1031 priv->byBBRxConf = abyVT3184_VT3226D0[10];
1032 lenght = sizeof(abyVT3184_VT3226D0);
1033 addr = abyVT3184_VT3226D0;
1034 agc = abyVT3184_AGC;
1035 lenght_agc = sizeof(abyVT3184_AGC);
1037 priv->abyBBVGA[0] = 0x20;
1038 priv->abyBBVGA[1] = 0x10;
1039 priv->abyBBVGA[2] = 0x0;
1040 priv->abyBBVGA[3] = 0x0;
1041 priv->ldBmThreshold[0] = -70;
1042 priv->ldBmThreshold[1] = -48;
1043 priv->ldBmThreshold[2] = 0;
1044 priv->ldBmThreshold[3] = 0;
1045 /* Fix VT3226 DFC system timing issue */
1046 MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1047 } else if ((priv->byRFType == RF_VT3342A0)) {
1048 priv->byBBRxConf = abyVT3184_VT3226D0[10];
1049 lenght = sizeof(abyVT3184_VT3226D0);
1050 addr = abyVT3184_VT3226D0;
1051 agc = abyVT3184_AGC;
1052 lenght_agc = sizeof(abyVT3184_AGC);
1054 priv->abyBBVGA[0] = 0x20;
1055 priv->abyBBVGA[1] = 0x10;
1056 priv->abyBBVGA[2] = 0x0;
1057 priv->abyBBVGA[3] = 0x0;
1058 priv->ldBmThreshold[0] = -70;
1059 priv->ldBmThreshold[1] = -48;
1060 priv->ldBmThreshold[2] = 0;
1061 priv->ldBmThreshold[3] = 0;
1062 /* Fix VT3226 DFC system timing issue */
1063 MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
1068 memcpy(array, addr, lenght);
1070 CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0,
1071 MESSAGE_REQUEST_BBREG, lenght, array);
1073 memcpy(array, agc, lenght_agc);
1075 CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, 0,
1076 MESSAGE_REQUEST_BBAGC, lenght_agc, array);
1078 if ((priv->byRFType == RF_VT3226) ||
1079 (priv->byRFType == RF_VT3342A0)) {
1080 ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG,
1081 MAC_REG_ITRTMSET, 0x23);
1082 MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01);
1083 } else if (priv->byRFType == RF_VT3226D0) {
1084 ControlvWriteByte(priv, MESSAGE_REQUEST_MACREG,
1085 MAC_REG_ITRTMSET, 0x11);
1086 MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01);
1089 ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f);
1090 ControlvWriteByte(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
1092 RFbRFTableDownload(priv);
1095 /* Fix for TX USB resets from vendors driver */
1096 CONTROLnsRequestIn(priv, MESSAGE_TYPE_READ, USB_REG4,
1097 MESSAGE_REQUEST_MEM, sizeof(data), &data);
1101 CONTROLnsRequestOut(priv, MESSAGE_TYPE_WRITE, USB_REG4,
1102 MESSAGE_REQUEST_MEM, sizeof(data), &data);
1108 * Description: Set ShortSlotTime mode
1112 * pDevice - Device Structure
1116 * Return Value: none
1119 void BBvSetShortSlotTime(struct vnt_private *pDevice)
1123 if (pDevice->bShortSlotTime)
1124 pDevice->byBBRxConf &= 0xDF;//1101 1111
1126 pDevice->byBBRxConf |= 0x20;//0010 0000
1128 ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA);
1129 if (byBBVGA == pDevice->abyBBVGA[0])
1130 pDevice->byBBRxConf |= 0x20;//0010 0000
1132 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);
1135 void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData)
1138 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData);
1140 // patch for 3253B0 Baseband with Cardbus module
1141 if (pDevice->bShortSlotTime)
1142 pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */
1144 pDevice->byBBRxConf |= 0x20; /* 0010 0000 */
1146 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10
1150 * Description: BBvSetDeepSleep
1154 * pDevice - Device Structure
1158 * Return Value: none
1161 void BBvSetDeepSleep(struct vnt_private *pDevice)
1163 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12
1164 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13
1167 void BBvExitDeepSleep(struct vnt_private *pDevice)
1169 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12
1170 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13
1173 static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice)
1176 unsigned long ulSQ3 = 0;
1177 unsigned long ulMaxPacket;
1179 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1180 if (pDevice->aulPktNum[RATE_54M] != 0)
1181 ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M];
1183 for (ii = RATE_48M; ii >= RATE_6M; ii--)
1184 if (pDevice->aulPktNum[ii] > ulMaxPacket) {
1185 ulMaxPacket = pDevice->aulPktNum[ii];
1186 ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii];
1192 static unsigned long s_ulGetRatio(struct vnt_private *pDevice)
1195 unsigned long ulRatio = 0;
1196 unsigned long ulMaxPacket;
1197 unsigned long ulPacketNum;
1199 //This is a thousand-ratio
1200 ulMaxPacket = pDevice->aulPktNum[RATE_54M];
1201 if ( pDevice->aulPktNum[RATE_54M] != 0 ) {
1202 ulPacketNum = pDevice->aulPktNum[RATE_54M];
1203 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1204 ulRatio += TOP_RATE_54M;
1206 for (ii = RATE_48M; ii >= RATE_1M; ii--)
1207 if ( pDevice->aulPktNum[ii] > ulMaxPacket ) {
1209 for ( jj=RATE_54M;jj>=ii;jj--)
1210 ulPacketNum += pDevice->aulPktNum[jj];
1211 ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt);
1212 ulRatio += TOP_RATE_48M;
1213 ulMaxPacket = pDevice->aulPktNum[ii];
1219 static void s_vClearSQ3Value(struct vnt_private *pDevice)
1222 pDevice->uDiversityCnt = 0;
1224 for ( ii=RATE_1M;ii<MAX_RATE;ii++) {
1225 pDevice->aulPktNum[ii] = 0;
1226 pDevice->aulSQ3Val[ii] = 0;
1231 * Description: Antenna Diversity
1235 * pDevice - Device Structure
1236 * byRSR - RSR from received packet
1237 * bySQ3 - SQ3 value from received packet
1241 * Return Value: none
1245 void BBvAntennaDiversity(struct vnt_private *pDevice,
1246 u8 byRxRate, u8 bySQ3)
1249 pDevice->uDiversityCnt++;
1250 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt);
1252 if (byRxRate == 2) {
1253 pDevice->aulPktNum[RATE_1M]++;
1255 else if (byRxRate==4) {
1256 pDevice->aulPktNum[RATE_2M]++;
1258 else if (byRxRate==11) {
1259 pDevice->aulPktNum[RATE_5M]++;
1261 else if (byRxRate==22) {
1262 pDevice->aulPktNum[RATE_11M]++;
1264 else if(byRxRate==12){
1265 pDevice->aulPktNum[RATE_6M]++;
1266 pDevice->aulSQ3Val[RATE_6M] += bySQ3;
1268 else if(byRxRate==18){
1269 pDevice->aulPktNum[RATE_9M]++;
1270 pDevice->aulSQ3Val[RATE_9M] += bySQ3;
1272 else if(byRxRate==24){
1273 pDevice->aulPktNum[RATE_12M]++;
1274 pDevice->aulSQ3Val[RATE_12M] += bySQ3;
1276 else if(byRxRate==36){
1277 pDevice->aulPktNum[RATE_18M]++;
1278 pDevice->aulSQ3Val[RATE_18M] += bySQ3;
1280 else if(byRxRate==48){
1281 pDevice->aulPktNum[RATE_24M]++;
1282 pDevice->aulSQ3Val[RATE_24M] += bySQ3;
1284 else if(byRxRate==72){
1285 pDevice->aulPktNum[RATE_36M]++;
1286 pDevice->aulSQ3Val[RATE_36M] += bySQ3;
1288 else if(byRxRate==96){
1289 pDevice->aulPktNum[RATE_48M]++;
1290 pDevice->aulSQ3Val[RATE_48M] += bySQ3;
1292 else if(byRxRate==108){
1293 pDevice->aulPktNum[RATE_54M]++;
1294 pDevice->aulSQ3Val[RATE_54M] += bySQ3;
1297 if (pDevice->byAntennaState == 0) {
1299 if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) {
1300 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]);
1302 pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice);
1303 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1304 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0);
1306 if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) &&
1307 (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) ||
1308 (pDevice->ulSQ3_State0 == 0 ) ) {
1310 if ( pDevice->byTMax == 0 )
1313 bScheduleCommand((void *) pDevice,
1314 WLAN_CMD_CHANGE_ANTENNA,
1317 pDevice->byAntennaState = 1;
1319 del_timer(&pDevice->TimerSQ3Tmax3);
1320 del_timer(&pDevice->TimerSQ3Tmax2);
1321 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1322 add_timer(&pDevice->TimerSQ3Tmax1);
1325 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1326 add_timer(&pDevice->TimerSQ3Tmax3);
1328 s_vClearSQ3Value(pDevice);
1331 } else { //byAntennaState == 1
1333 if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) {
1335 del_timer(&pDevice->TimerSQ3Tmax1);
1336 pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice);
1337 pDevice->ulRatio_State1 = s_ulGetRatio(pDevice);
1338 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1);
1340 if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) ||
1341 ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) ||
1342 ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1))
1345 bScheduleCommand((void *) pDevice,
1346 WLAN_CMD_CHANGE_ANTENNA,
1349 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1350 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1351 add_timer(&pDevice->TimerSQ3Tmax3);
1352 add_timer(&pDevice->TimerSQ3Tmax2);
1355 pDevice->byAntennaState = 0;
1356 s_vClearSQ3Value(pDevice);
1364 * Timer for SQ3 antenna diversity
1369 * hDeviceContext - Pointer to the adapter
1375 * Return Value: none
1379 void TimerSQ3CallBack(struct vnt_private *pDevice)
1382 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack...");
1383 spin_lock_irq(&pDevice->lock);
1385 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1386 pDevice->byAntennaState = 0;
1387 s_vClearSQ3Value(pDevice);
1388 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1389 pDevice->TimerSQ3Tmax2.expires = RUN_AT(pDevice->byTMax2 * HZ);
1390 add_timer(&pDevice->TimerSQ3Tmax3);
1391 add_timer(&pDevice->TimerSQ3Tmax2);
1393 spin_unlock_irq(&pDevice->lock);
1399 * Timer for SQ3 antenna diversity
1404 * hDeviceContext - Pointer to the adapter
1410 * Return Value: none
1414 void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice)
1417 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack...");
1418 spin_lock_irq(&pDevice->lock);
1420 pDevice->ulRatio_State0 = s_ulGetRatio(pDevice);
1421 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0);
1423 s_vClearSQ3Value(pDevice);
1424 if ( pDevice->byTMax == 0 ) {
1425 pDevice->TimerSQ3Tmax3.expires = RUN_AT(pDevice->byTMax3 * HZ);
1426 add_timer(&pDevice->TimerSQ3Tmax3);
1427 spin_unlock_irq(&pDevice->lock);
1431 bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL);
1432 pDevice->byAntennaState = 1;
1433 del_timer(&pDevice->TimerSQ3Tmax3);
1434 del_timer(&pDevice->TimerSQ3Tmax2);
1435 pDevice->TimerSQ3Tmax1.expires = RUN_AT(pDevice->byTMax * HZ);
1436 add_timer(&pDevice->TimerSQ3Tmax1);
1438 spin_unlock_irq(&pDevice->lock);
1441 void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning)
1444 switch(pDevice->byRFType)
1449 //RobertYu:20060627, update new table
1452 { // need Max sensitivity //RSSI -69, -70,....
1453 pDevice->byBBPreEDIndex = 0;
1454 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1455 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1456 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70, -71,...\n");
1460 if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45
1461 if(pDevice->byBBPreEDIndex == 20) break;
1462 pDevice->byBBPreEDIndex = 20;
1463 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1464 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1465 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n");
1466 } else if(pDevice->byBBPreEDRSSI <= 46) { //RSSI -46
1467 if(pDevice->byBBPreEDIndex == 19) break;
1468 pDevice->byBBPreEDIndex = 19;
1469 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9)
1470 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1471 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46\n");
1472 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -47
1473 if(pDevice->byBBPreEDIndex == 18) break;
1474 pDevice->byBBPreEDIndex = 18;
1475 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9)
1476 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1477 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -47\n");
1478 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1479 if(pDevice->byBBPreEDIndex == 17) break;
1480 pDevice->byBBPreEDIndex = 17;
1481 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9)
1482 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1483 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1484 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1485 if(pDevice->byBBPreEDIndex == 16) break;
1486 pDevice->byBBPreEDIndex = 16;
1487 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9)
1488 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1489 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1490 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1491 if(pDevice->byBBPreEDIndex == 15) break;
1492 pDevice->byBBPreEDIndex = 15;
1493 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9)
1494 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1495 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1496 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1497 if(pDevice->byBBPreEDIndex == 14) break;
1498 pDevice->byBBPreEDIndex = 14;
1499 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9)
1500 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1501 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1502 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1503 if(pDevice->byBBPreEDIndex == 13) break;
1504 pDevice->byBBPreEDIndex = 13;
1505 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1506 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1507 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1508 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1509 if(pDevice->byBBPreEDIndex == 12) break;
1510 pDevice->byBBPreEDIndex = 12;
1511 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1512 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE)
1513 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1514 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1515 if(pDevice->byBBPreEDIndex == 11) break;
1516 pDevice->byBBPreEDIndex = 11;
1517 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1518 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE)
1519 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1520 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1521 if(pDevice->byBBPreEDIndex == 10) break;
1522 pDevice->byBBPreEDIndex = 10;
1523 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1524 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE)
1525 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1526 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1527 if(pDevice->byBBPreEDIndex == 9) break;
1528 pDevice->byBBPreEDIndex = 9;
1529 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1530 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE)
1531 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1532 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1533 if(pDevice->byBBPreEDIndex == 8) break;
1534 pDevice->byBBPreEDIndex = 8;
1535 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1536 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE)
1537 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1538 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1539 if(pDevice->byBBPreEDIndex == 7) break;
1540 pDevice->byBBPreEDIndex = 7;
1541 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1542 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE)
1543 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1544 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1545 if(pDevice->byBBPreEDIndex == 6) break;
1546 pDevice->byBBPreEDIndex = 6;
1547 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1548 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE)
1549 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1550 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1551 if(pDevice->byBBPreEDIndex == 5) break;
1552 pDevice->byBBPreEDIndex = 5;
1553 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1554 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE)
1555 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1556 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1557 if(pDevice->byBBPreEDIndex == 4) break;
1558 pDevice->byBBPreEDIndex = 4;
1559 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1560 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE)
1561 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1562 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1563 if(pDevice->byBBPreEDIndex == 3) break;
1564 pDevice->byBBPreEDIndex = 3;
1565 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1566 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE)
1567 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1568 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1569 if(pDevice->byBBPreEDIndex == 2) break;
1570 pDevice->byBBPreEDIndex = 2;
1571 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1572 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1574 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1575 if(pDevice->byBBPreEDIndex == 1) break;
1576 pDevice->byBBPreEDIndex = 1;
1577 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1578 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1579 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1580 } else { //RSSI -69, -70,....
1581 if(pDevice->byBBPreEDIndex == 0) break;
1582 pDevice->byBBPreEDIndex = 0;
1583 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1584 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1585 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,...\n");
1591 //RobertYu:20060627, update new table
1594 { // need Max sensitivity //RSSI -69, -70, ...
1595 pDevice->byBBPreEDIndex = 0;
1596 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1597 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1598 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1602 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1603 if(pDevice->byBBPreEDIndex == 22) break;
1604 pDevice->byBBPreEDIndex = 22;
1605 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1606 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1607 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1608 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1609 if(pDevice->byBBPreEDIndex == 21) break;
1610 pDevice->byBBPreEDIndex = 21;
1611 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1612 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1613 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1614 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1615 if(pDevice->byBBPreEDIndex == 20) break;
1616 pDevice->byBBPreEDIndex = 20;
1617 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1618 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1619 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1620 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1621 if(pDevice->byBBPreEDIndex == 19) break;
1622 pDevice->byBBPreEDIndex = 19;
1623 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1624 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1625 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1626 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1627 if(pDevice->byBBPreEDIndex == 18) break;
1628 pDevice->byBBPreEDIndex = 18;
1629 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1630 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1631 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1632 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1633 if(pDevice->byBBPreEDIndex == 17) break;
1634 pDevice->byBBPreEDIndex = 17;
1635 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1636 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1637 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1638 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1639 if(pDevice->byBBPreEDIndex == 16) break;
1640 pDevice->byBBPreEDIndex = 16;
1641 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1642 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1643 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1644 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1645 if(pDevice->byBBPreEDIndex == 15) break;
1646 pDevice->byBBPreEDIndex = 15;
1647 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1648 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1649 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1650 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1651 if(pDevice->byBBPreEDIndex == 14) break;
1652 pDevice->byBBPreEDIndex = 14;
1653 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1654 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1655 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1656 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1657 if(pDevice->byBBPreEDIndex == 13) break;
1658 pDevice->byBBPreEDIndex = 13;
1659 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1660 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1661 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1662 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1663 if(pDevice->byBBPreEDIndex == 12) break;
1664 pDevice->byBBPreEDIndex = 12;
1665 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1666 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1667 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1668 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1669 if(pDevice->byBBPreEDIndex == 11) break;
1670 pDevice->byBBPreEDIndex = 11;
1671 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1672 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1673 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1674 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1675 if(pDevice->byBBPreEDIndex == 10) break;
1676 pDevice->byBBPreEDIndex = 10;
1677 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1678 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1679 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1680 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1681 if(pDevice->byBBPreEDIndex == 9) break;
1682 pDevice->byBBPreEDIndex = 9;
1683 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1684 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1685 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1686 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1687 if(pDevice->byBBPreEDIndex == 8) break;
1688 pDevice->byBBPreEDIndex = 8;
1689 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1690 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1691 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1692 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1693 if(pDevice->byBBPreEDIndex == 7) break;
1694 pDevice->byBBPreEDIndex = 7;
1695 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1696 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1697 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1698 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1699 if(pDevice->byBBPreEDIndex == 6) break;
1700 pDevice->byBBPreEDIndex = 6;
1701 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1702 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1703 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1704 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1705 if(pDevice->byBBPreEDIndex == 5) break;
1706 pDevice->byBBPreEDIndex = 5;
1707 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1708 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1709 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1710 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1711 if(pDevice->byBBPreEDIndex == 4) break;
1712 pDevice->byBBPreEDIndex = 4;
1713 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1714 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1715 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1716 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1717 if(pDevice->byBBPreEDIndex == 3) break;
1718 pDevice->byBBPreEDIndex = 3;
1719 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1720 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1721 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1722 } else if(pDevice->byBBPreEDRSSI <= 67) { //RSSI -67
1723 if(pDevice->byBBPreEDIndex == 2) break;
1724 pDevice->byBBPreEDIndex = 2;
1725 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1726 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE)
1727 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67\n");
1728 } else if(pDevice->byBBPreEDRSSI <= 68) { //RSSI -68
1729 if(pDevice->byBBPreEDIndex == 1) break;
1730 pDevice->byBBPreEDIndex = 1;
1731 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1732 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE)
1733 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -68\n");
1734 } else { //RSSI -69, -70, ...
1735 if(pDevice->byBBPreEDIndex == 0) break;
1736 pDevice->byBBPreEDIndex = 0;
1737 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1738 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE)
1739 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -69, -70,..\n");
1743 case RF_VT3342A0: //RobertYu:20060627, testing table
1745 { // need Max sensitivity //RSSI -67, -68, ...
1746 pDevice->byBBPreEDIndex = 0;
1747 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1748 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1749 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");
1753 if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41
1754 if(pDevice->byBBPreEDIndex == 20) break;
1755 pDevice->byBBPreEDIndex = 20;
1756 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9)
1757 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1758 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n");
1759 } else if(pDevice->byBBPreEDRSSI <= 42) { //RSSI -42
1760 if(pDevice->byBBPreEDIndex == 19) break;
1761 pDevice->byBBPreEDIndex = 19;
1762 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9)
1763 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1764 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -42\n");
1765 } else if(pDevice->byBBPreEDRSSI <= 43) { //RSSI -43
1766 if(pDevice->byBBPreEDIndex == 18) break;
1767 pDevice->byBBPreEDIndex = 18;
1768 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9)
1769 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1770 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -43\n");
1771 } else if(pDevice->byBBPreEDRSSI <= 45) { //RSSI -44, -45
1772 if(pDevice->byBBPreEDIndex == 17) break;
1773 pDevice->byBBPreEDIndex = 17;
1774 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9)
1775 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1776 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -44,-45\n");
1777 } else if(pDevice->byBBPreEDRSSI <= 47) { //RSSI -46, -47
1778 if(pDevice->byBBPreEDIndex == 16) break;
1779 pDevice->byBBPreEDIndex = 16;
1780 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9)
1781 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1782 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -46,-47\n");
1783 } else if(pDevice->byBBPreEDRSSI <= 49) { //RSSI -48, -49
1784 if(pDevice->byBBPreEDIndex == 15) break;
1785 pDevice->byBBPreEDIndex = 15;
1786 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9)
1787 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1788 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -48,-49\n");
1789 } else if(pDevice->byBBPreEDRSSI <= 51) { //RSSI -50, -51
1790 if(pDevice->byBBPreEDIndex == 14) break;
1791 pDevice->byBBPreEDIndex = 14;
1792 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9)
1793 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1794 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -50,-51\n");
1795 } else if(pDevice->byBBPreEDRSSI <= 53) { //RSSI -52, -53
1796 if(pDevice->byBBPreEDIndex == 13) break;
1797 pDevice->byBBPreEDIndex = 13;
1798 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9)
1799 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE)
1800 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -52,-53\n");
1801 } else if(pDevice->byBBPreEDRSSI <= 55) { //RSSI -54, -55
1802 if(pDevice->byBBPreEDIndex == 12) break;
1803 pDevice->byBBPreEDIndex = 12;
1804 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1805 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1806 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -54,-55\n");
1807 } else if(pDevice->byBBPreEDRSSI <= 56) { //RSSI -56
1808 if(pDevice->byBBPreEDIndex == 11) break;
1809 pDevice->byBBPreEDIndex = 11;
1810 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9)
1811 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1812 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -56\n");
1813 } else if(pDevice->byBBPreEDRSSI <= 57) { //RSSI -57
1814 if(pDevice->byBBPreEDIndex == 10) break;
1815 pDevice->byBBPreEDIndex = 10;
1816 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1817 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE)
1818 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -57\n");
1819 } else if(pDevice->byBBPreEDRSSI <= 58) { //RSSI -58
1820 if(pDevice->byBBPreEDIndex == 9) break;
1821 pDevice->byBBPreEDIndex = 9;
1822 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1823 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE)
1824 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -58\n");
1825 } else if(pDevice->byBBPreEDRSSI <= 59) { //RSSI -59
1826 if(pDevice->byBBPreEDIndex == 8) break;
1827 pDevice->byBBPreEDIndex = 8;
1828 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9)
1829 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE)
1830 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -59\n");
1831 } else if(pDevice->byBBPreEDRSSI <= 60) { //RSSI -60
1832 if(pDevice->byBBPreEDIndex == 7) break;
1833 pDevice->byBBPreEDIndex = 7;
1834 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1835 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE)
1836 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -60\n");
1837 } else if(pDevice->byBBPreEDRSSI <= 61) { //RSSI -61
1838 if(pDevice->byBBPreEDIndex == 6) break;
1839 pDevice->byBBPreEDIndex = 6;
1840 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1841 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE)
1842 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -61\n");
1843 } else if(pDevice->byBBPreEDRSSI <= 62) { //RSSI -62
1844 if(pDevice->byBBPreEDIndex == 5) break;
1845 pDevice->byBBPreEDIndex = 5;
1846 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1847 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE)
1848 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -62\n");
1849 } else if(pDevice->byBBPreEDRSSI <= 63) { //RSSI -63
1850 if(pDevice->byBBPreEDIndex == 4) break;
1851 pDevice->byBBPreEDIndex = 4;
1852 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1853 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE)
1854 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -63\n");
1855 } else if(pDevice->byBBPreEDRSSI <= 64) { //RSSI -64
1856 if(pDevice->byBBPreEDIndex == 3) break;
1857 pDevice->byBBPreEDIndex = 3;
1858 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1859 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE)
1860 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -64\n");
1861 } else if(pDevice->byBBPreEDRSSI <= 65) { //RSSI -65
1862 if(pDevice->byBBPreEDIndex == 2) break;
1863 pDevice->byBBPreEDIndex = 2;
1864 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1865 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE)
1866 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -65\n");
1867 } else if(pDevice->byBBPreEDRSSI <= 66) { //RSSI -66
1868 if(pDevice->byBBPreEDIndex == 1) break;
1869 pDevice->byBBPreEDIndex = 1;
1870 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1871 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE)
1872 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -66\n");
1873 } else { //RSSI -67, -68, ...
1874 if(pDevice->byBBPreEDIndex == 0) break;
1875 pDevice->byBBPreEDIndex = 0;
1876 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9)
1877 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE)
1878 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->byBBPreEDRSSI -67, -68,..\n");