diff options
Diffstat (limited to 'drivers/staging/vt6656/baseband.c')
| -rw-r--r-- | drivers/staging/vt6656/baseband.c | 1778 | 
1 files changed, 638 insertions, 1140 deletions
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 1e8b8412e67..694e34a5ff9 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -40,15 +40,10 @@  #include "mac.h"  #include "baseband.h"  #include "rf.h" -#include "srom.h" -#include "control.h" +#include "usbpipe.h"  #include "datarate.h" -#include "rndis.h" -static int          msglevel                =MSG_LEVEL_INFO; -//static int          msglevel                =MSG_LEVEL_DEBUG; - -u8 abyVT3184_AGC[] = { +static u8 abyVT3184_AGC[] = {      0x00,   //0      0x00,   //1      0x02,   //2 @@ -115,7 +110,7 @@ u8 abyVT3184_AGC[] = {      0x3E    //3F  }; -u8 abyVT3184_AL2230[] = { +static u8 abyVT3184_AL2230[] = {          0x31,//00          0x00,          0x00, @@ -375,7 +370,7 @@ u8 abyVT3184_AL2230[] = {  };  //{{RobertYu:20060515, new BB setting for VT3226D0 -u8 abyVT3184_VT3226D0[] = { +static u8 abyVT3184_VT3226D0[] = {          0x31,//00          0x00,          0x00, @@ -634,84 +629,63 @@ u8 abyVT3184_VT3226D0[] = {          0x00,  }; -const u16 awcFrameTime[MAX_RATE] = +static const u16 awcFrameTime[MAX_RATE] =  {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};  /* -static -unsigned long -s_ulGetLowSQ3(PSDevice pDevice); - -static -unsigned long -s_ulGetRatio(PSDevice pDevice); - -static -void -s_vClearSQ3Value(PSDevice pDevice); -*/ - -/*   * Description: Calculate data frame transmitting time   *   * Parameters:   *  In: - *      byPreambleType  - Preamble Type - *      byPktType        - PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA - *      cbFrameLength   - Baseband Type - *      wRate           - Tx Rate + *	preamble_type	- Preamble Type + *	pkt_type	- PK_TYPE_11A, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA + *	frame_length	- Baseband Type + *	tx_rate		- Tx Rate   *  Out:   *   * Return Value: FrameTime   *   */ -unsigned int -BBuGetFrameTime( -     u8 byPreambleType, -     u8 byPktType, -     unsigned int cbFrameLength, -     u16 wRate -    ) +unsigned int BBuGetFrameTime(u8 preamble_type, u8 pkt_type, +	unsigned int frame_length, u16 tx_rate)  { -    unsigned int uFrameTime; -    unsigned int uPreamble; -    unsigned int uTmp; -    unsigned int uRateIdx = (unsigned int)wRate; -    unsigned int uRate = 0; - -    if (uRateIdx > RATE_54M) { -        return 0; -    } - -    uRate = (unsigned int)awcFrameTime[uRateIdx]; - -    if (uRateIdx <= 3) {          //CCK mode - -        if (byPreambleType == 1) {//Short -            uPreamble = 96; -        } else { -            uPreamble = 192; -        } -        uFrameTime = (cbFrameLength * 80) / uRate;  //????? -        uTmp = (uFrameTime * uRate) / 80; -        if (cbFrameLength != uTmp) { -            uFrameTime ++; -        } - -        return (uPreamble + uFrameTime); -    } -    else { -        uFrameTime = (cbFrameLength * 8 + 22) / uRate;   //???????? -        uTmp = ((uFrameTime * uRate) - 22) / 8; -        if(cbFrameLength != uTmp) { -            uFrameTime ++; -        } -        uFrameTime = uFrameTime * 4;    //??????? -        if(byPktType != PK_TYPE_11A) { -            uFrameTime += 6; -        } -        return (20 + uFrameTime); //?????? -    } +	unsigned int frame_time; +	unsigned int preamble; +	unsigned int tmp; +	unsigned int rate = 0; + +	if (tx_rate > RATE_54M) +		return 0; + +	rate = (unsigned int)awcFrameTime[tx_rate]; + +	if (tx_rate <= 3) { +		if (preamble_type == 1) +			preamble = 96; +		else +			preamble = 192; + +		frame_time = (frame_length * 80) / rate; +		tmp = (frame_time * rate) / 80; + +		if (frame_length != tmp) +			frame_time++; + +		return preamble + frame_time; +	} else { +		frame_time = (frame_length * 8 + 22) / rate; +		tmp = ((frame_time * rate) - 22) / 8; + +		if (frame_length != tmp) +			frame_time++; + +		frame_time = frame_time * 4; + +		if (pkt_type != PK_TYPE_11A) +			frame_time += 6; + +		return 20 + frame_time; +	}  }  /* @@ -719,9 +693,9 @@ BBuGetFrameTime(   *   * Parameters:   *  In: - *      pDevice         - Device Structure - *      cbFrameLength   - Tx Frame Length - *      wRate           - Tx Rate + *      priv         - Device Structure + *      frame_length   - Tx Frame Length + *      tx_rate           - Tx Rate   *  Out:   *	struct vnt_phy_field *phy   * 			- pointer to Phy Length field @@ -731,153 +705,135 @@ BBuGetFrameTime(   * Return Value: none   *   */ -void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, -	u16 wRate, u8 byPacketType, struct vnt_phy_field *phy) +void BBvCalculateParameter(struct vnt_private *priv, u32 frame_length, +	u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy)  { -	u32 cbBitCount; -	u32 cbUsCount = 0; -	u32 cbTmp; -	int bExtBit; -	u8 byPreambleType = pDevice->byPreambleType; -	int bCCK = pDevice->bCCK; - -    cbBitCount = cbFrameLength * 8; -    bExtBit = false; - -    switch (wRate) { -    case RATE_1M : -        cbUsCount = cbBitCount; -	phy->signal = 0x00; -        break; - -    case RATE_2M : -        cbUsCount = cbBitCount / 2; -        if (byPreambleType == 1) -		phy->signal = 0x09; -        else // long preamble -		phy->signal = 0x01; -        break; - -    case RATE_5M : -        if (bCCK == false) -            cbBitCount ++; -        cbUsCount = (cbBitCount * 10) / 55; -        cbTmp = (cbUsCount * 55) / 10; -        if (cbTmp != cbBitCount) -            cbUsCount ++; -        if (byPreambleType == 1) -		phy->signal = 0x0a; -        else // long preamble -		phy->signal = 0x02; -        break; - -    case RATE_11M : - -        if (bCCK == false) -            cbBitCount ++; -        cbUsCount = cbBitCount / 11; -        cbTmp = cbUsCount * 11; -        if (cbTmp != cbBitCount) { -            cbUsCount ++; -            if ((cbBitCount - cbTmp) <= 3) -                bExtBit = true; -        } -        if (byPreambleType == 1) -		phy->signal = 0x0b; -        else // long preamble -		phy->signal = 0x03; -        break; - -    case RATE_6M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9b; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8b; -        } -        break; - -    case RATE_9M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9f; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8f; -        } -        break; - -    case RATE_12M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9a; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8a; -        } -        break; - -    case RATE_18M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9e; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8e; -        } -        break; - -    case RATE_24M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x99; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x89; -        } -        break; - -    case RATE_36M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9d; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8d; -        } -        break; - -    case RATE_48M : -        if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x98; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x88; -        } -        break; - -    case RATE_54M : -        if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9c; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8c; -        } -        break; - -    default : -        if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ -		phy->signal = 0x9c; -        } -        else {//11g, 2.4GHZ -		phy->signal = 0x8c; -        } -        break; -    } - -	if (byPacketType == PK_TYPE_11B) { +	u32 bit_count; +	u32 count = 0; +	u32 tmp; +	int ext_bit; +	u8 preamble_type = priv->byPreambleType; + +	bit_count = frame_length * 8; +	ext_bit = false; + +	switch (tx_rate) { +	case RATE_1M: +		count = bit_count; + +		phy->signal = 0x00; + +		break; +	case RATE_2M: +		count = bit_count / 2; + +		if (preamble_type == 1) +			phy->signal = 0x09; +		else +			phy->signal = 0x01; + +		break; +	case RATE_5M: +		count = (bit_count * 10) / 55; +		tmp = (count * 55) / 10; + +		if (tmp != bit_count) +			count++; + +		if (preamble_type == 1) +			phy->signal = 0x0a; +		else +			phy->signal = 0x02; + +		break; +	case RATE_11M: +		count = bit_count / 11; +		tmp = count * 11; + +		if (tmp != bit_count) { +			count++; + +			if ((bit_count - tmp) <= 3) +				ext_bit = true; +		} + +		if (preamble_type == 1) +			phy->signal = 0x0b; +		else +			phy->signal = 0x03; + +		break; +	case RATE_6M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9b; +		else +			phy->signal = 0x8b; + +		break; +	case RATE_9M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9f; +		else +			phy->signal = 0x8f; + +		break; +	case RATE_12M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9a; +		else +			phy->signal = 0x8a; + +		break; +	case RATE_18M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9e; +		else +			phy->signal = 0x8e; + +		break; +	case RATE_24M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x99; +		else +			phy->signal = 0x89; + +		break; +	case RATE_36M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9d; +		else +			phy->signal = 0x8d; + +		break; +	case RATE_48M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x98; +		else +			phy->signal = 0x88; + +		break; +	case RATE_54M: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9c; +		else +			phy->signal = 0x8c; +		break; +	default: +		if (pkt_type == PK_TYPE_11A) +			phy->signal = 0x9c; +		else +			phy->signal = 0x8c; +		break; +	} + +	if (pkt_type == PK_TYPE_11B) {  		phy->service = 0x00; -		if (bExtBit) +		if (ext_bit)  			phy->service |= 0x80; -		phy->len = cpu_to_le16((u16)cbUsCount); +		phy->len = cpu_to_le16((u16)count);  	} else {  		phy->service = 0x00; -		phy->len = cpu_to_le16((u16)cbFrameLength); +		phy->len = cpu_to_le16((u16)frame_length);  	}  } @@ -886,35 +842,31 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength,   *   * Parameters:   *  In: - *      pDevice          - Device Structure - *      byAntennaMode    - Antenna Mode + *	priv		- Device Structure + *	antenna_mode	- Antenna Mode   *  Out:   *      none   *   * Return Value: none   *   */ -void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode) +void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode)  { -    switch (byAntennaMode) { -        case ANT_TXA: -        case ANT_TXB: -            break; -        case ANT_RXA: -            pDevice->byBBRxConf &= 0xFC; -            break; -        case ANT_RXB: -            pDevice->byBBRxConf &= 0xFE; -            pDevice->byBBRxConf |= 0x02; -            break; -    } - -    CONTROLnsRequestOut(pDevice, -                    MESSAGE_TYPE_SET_ANTMD, -                    (u16) byAntennaMode, -                    0, -                    0, -                    NULL); +	switch (antenna_mode) { +	case ANT_TXA: +	case ANT_TXB: +		break; +	case ANT_RXA: +		priv->byBBRxConf &= 0xFC; +		break; +	case ANT_RXB: +		priv->byBBRxConf &= 0xFE; +		priv->byBBRxConf |= 0x02; +		break; +	} + +	vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, +		(u16)antenna_mode, 0, 0, NULL);  }  /* @@ -931,961 +883,507 @@ void BBvSetAntennaMode(struct vnt_private *pDevice, u8 byAntennaMode)   *   */ -int BBbVT3184Init(struct vnt_private *pDevice) +int BBbVT3184Init(struct vnt_private *priv)  { -	int ntStatus; -    u16                    wLength; -    u8 *                   pbyAddr; -    u8 *                   pbyAgc; -    u16                    wLengthAgc; -    u8                    abyArray[256]; - -    ntStatus = CONTROLnsRequestIn(pDevice, -                                  MESSAGE_TYPE_READ, -                                  0, -                                  MESSAGE_REQUEST_EEPROM, -                                  EEP_MAX_CONTEXT_SIZE, -                                  pDevice->abyEEPROM); -    if (ntStatus != STATUS_SUCCESS) { -        return false; -    } - -//    if ((pDevice->abyEEPROM[EEP_OFS_RADIOCTL]&0x06)==0x04) -//        return false; - -//zonetype initial - pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; - if(pDevice->config_file.ZoneType >= 0) {         //read zonetype file ok! -  if ((pDevice->config_file.ZoneType == 0)&& -        (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){          //for USA -    pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0; -    pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B; -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :USA\n"); -  } - else if((pDevice->config_file.ZoneType == 1)&& - 	     (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x01)){   //for Japan -    pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01; -    pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Japan\n"); -  } - else if((pDevice->config_file.ZoneType == 2)&& - 	     (pDevice->abyEEPROM[EEP_OFS_ZONETYPE]!=0x02)){   //for Europe -    pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02; -    pDevice->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Init Zone Type :Europe\n"); -  } -else { -   if(pDevice->config_file.ZoneType !=pDevice->abyEEPROM[EEP_OFS_ZONETYPE]) -      printk("zonetype in file[%02x] mismatch with in EEPROM[%02x]\n",pDevice->config_file.ZoneType,pDevice->abyEEPROM[EEP_OFS_ZONETYPE]); -   else -      printk("Read Zonetype file success,use default zonetype setting[%02x]\n",pDevice->config_file.ZoneType); - } -} +	int status; +	u16 length; +	u8 *addr; +	u8 *agc; +	u16 length_agc; +	u8 array[256]; +	u8 data; + +	status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, +		MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, +						priv->abyEEPROM); +	if (status != STATUS_SUCCESS) +		return false; + +	/* zonetype initial */ +	priv->byOriginalZonetype = priv->abyEEPROM[EEP_OFS_ZONETYPE]; + +	if (priv->config_file.ZoneType >= 0) { +		if ((priv->config_file.ZoneType == 0) && +			(priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x00)) { +			priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0; +			priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0B; + +			dev_dbg(&priv->usb->dev, "Init Zone Type :USA\n"); +		} else if ((priv->config_file.ZoneType == 1) && +			(priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x01)) { +			priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x01; +			priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; + +			dev_dbg(&priv->usb->dev, "Init Zone Type :Japan\n"); +		} else if ((priv->config_file.ZoneType == 2) && +			(priv->abyEEPROM[EEP_OFS_ZONETYPE] != 0x02)) { +			priv->abyEEPROM[EEP_OFS_ZONETYPE] = 0x02; +			priv->abyEEPROM[EEP_OFS_MAXCHANNEL] = 0x0D; + +			dev_dbg(&priv->usb->dev, "Init Zone Type :Europe\n"); +		} else { +			if (priv->config_file.ZoneType != +					priv->abyEEPROM[EEP_OFS_ZONETYPE]) +				printk("zonetype in file[%02x]\ +					 mismatch with in EEPROM[%02x]\n", +					priv->config_file.ZoneType, +					priv->abyEEPROM[EEP_OFS_ZONETYPE]); +			else +				printk("Read Zonetype file success,\ +					use default zonetype setting[%02x]\n", +					priv->config_file.ZoneType); +		} +	} -    if ( !pDevice->bZoneRegExist ) { -        pDevice->byZoneType = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; -    } -    pDevice->byRFType = pDevice->abyEEPROM[EEP_OFS_RFTYPE]; - -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Zone Type %x\n", pDevice->byZoneType); -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RF Type %d\n", pDevice->byRFType); - -    if ((pDevice->byRFType == RF_AL2230) || (pDevice->byRFType == RF_AL2230S)) { -        pDevice->byBBRxConf = abyVT3184_AL2230[10]; -        wLength = sizeof(abyVT3184_AL2230); -        pbyAddr = abyVT3184_AL2230; -        pbyAgc = abyVT3184_AGC; -        wLengthAgc = sizeof(abyVT3184_AGC); - -        pDevice->abyBBVGA[0] = 0x1C; -        pDevice->abyBBVGA[1] = 0x10; -        pDevice->abyBBVGA[2] = 0x0; -        pDevice->abyBBVGA[3] = 0x0; -        pDevice->ldBmThreshold[0] = -70; -        pDevice->ldBmThreshold[1] = -48; -        pDevice->ldBmThreshold[2] = 0; -        pDevice->ldBmThreshold[3] = 0; -    } -    else if (pDevice->byRFType == RF_AIROHA7230) { -        pDevice->byBBRxConf = abyVT3184_AL2230[10]; -        wLength = sizeof(abyVT3184_AL2230); -        pbyAddr = abyVT3184_AL2230; -        pbyAgc = abyVT3184_AGC; -        wLengthAgc = sizeof(abyVT3184_AGC); - -        // Init ANT B select,TX Config CR09 = 0x61->0x45, 0x45->0x41(VC1/VC2 define, make the ANT_A, ANT_B inverted) -        //pbyAddr[0x09] = 0x41; -        // Init ANT B select,RX Config CR10 = 0x28->0x2A, 0x2A->0x28(VC1/VC2 define, make the ANT_A, ANT_B inverted) -        //pbyAddr[0x0a] = 0x28; -        // Select VC1/VC2, CR215 = 0x02->0x06 -        pbyAddr[0xd7] = 0x06; - -        pDevice->abyBBVGA[0] = 0x1C; -        pDevice->abyBBVGA[1] = 0x10; -        pDevice->abyBBVGA[2] = 0x0; -        pDevice->abyBBVGA[3] = 0x0; -        pDevice->ldBmThreshold[0] = -70; -        pDevice->ldBmThreshold[1] = -48; -        pDevice->ldBmThreshold[2] = 0; -        pDevice->ldBmThreshold[3] = 0; -    } -    else if ( (pDevice->byRFType == RF_VT3226) || (pDevice->byRFType == RF_VT3226D0) ) { -        pDevice->byBBRxConf = abyVT3184_VT3226D0[10];   //RobertYu:20060515 -        wLength = sizeof(abyVT3184_VT3226D0);           //RobertYu:20060515 -        pbyAddr = abyVT3184_VT3226D0;                   //RobertYu:20060515 -        pbyAgc = abyVT3184_AGC; -        wLengthAgc = sizeof(abyVT3184_AGC); - -        pDevice->abyBBVGA[0] = 0x20; //RobertYu:20060104, reguest by Jack -        pDevice->abyBBVGA[1] = 0x10; -        pDevice->abyBBVGA[2] = 0x0; -        pDevice->abyBBVGA[3] = 0x0; -        pDevice->ldBmThreshold[0] = -70; -        pDevice->ldBmThreshold[1] = -48; -        pDevice->ldBmThreshold[2] = 0; -        pDevice->ldBmThreshold[3] = 0; -        // Fix VT3226 DFC system timing issue -        MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); -    //}} -    //{{RobertYu:20060609 -    } else if ( (pDevice->byRFType == RF_VT3342A0) ) { -        pDevice->byBBRxConf = abyVT3184_VT3226D0[10]; -        wLength = sizeof(abyVT3184_VT3226D0); -        pbyAddr = abyVT3184_VT3226D0; -        pbyAgc = abyVT3184_AGC; -        wLengthAgc = sizeof(abyVT3184_AGC); - -        pDevice->abyBBVGA[0] = 0x20; -        pDevice->abyBBVGA[1] = 0x10; -        pDevice->abyBBVGA[2] = 0x0; -        pDevice->abyBBVGA[3] = 0x0; -        pDevice->ldBmThreshold[0] = -70; -        pDevice->ldBmThreshold[1] = -48; -        pDevice->ldBmThreshold[2] = 0; -        pDevice->ldBmThreshold[3] = 0; -        // Fix VT3226 DFC system timing issue -        MACvRegBitsOn(pDevice, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); -    //}} -    } else { -        return true; -    } - -   memcpy(abyArray, pbyAddr, wLength); -   CONTROLnsRequestOut(pDevice, -                    MESSAGE_TYPE_WRITE, -                    0, -                    MESSAGE_REQUEST_BBREG, -                    wLength, -                    abyArray -                    ); - -   memcpy(abyArray, pbyAgc, wLengthAgc); -   CONTROLnsRequestOut(pDevice, -                    MESSAGE_TYPE_WRITE, -                    0, -                    MESSAGE_REQUEST_BBAGC, -                    wLengthAgc, -                    abyArray -                    ); - -    if ((pDevice->byRFType == RF_VT3226) || //RobertYu:20051116, 20060111 remove VT3226D0 -         (pDevice->byRFType == RF_VT3342A0)  //RobertYu:20060609 -         ) { -        ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x23); -        MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01); -    } -    else if (pDevice->byRFType == RF_VT3226D0) -    { -        ControlvWriteByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_ITRTMSET,0x11); -        MACvRegBitsOn(pDevice,MAC_REG_PAPEDELAY,0x01); -    } - -    ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x04,0x7F); -    ControlvWriteByte(pDevice,MESSAGE_REQUEST_BBREG,0x0D,0x01); - -    RFbRFTableDownload(pDevice); -    return true;//ntStatus; -} +	if (!priv->bZoneRegExist) +		priv->byZoneType = priv->abyEEPROM[EEP_OFS_ZONETYPE]; + +	priv->byRFType = priv->abyEEPROM[EEP_OFS_RFTYPE]; + +	dev_dbg(&priv->usb->dev, "Zone Type %x\n", priv->byZoneType); + +	dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->byRFType); + +	if ((priv->byRFType == RF_AL2230) || +				(priv->byRFType == RF_AL2230S)) { +		priv->byBBRxConf = abyVT3184_AL2230[10]; +		length = sizeof(abyVT3184_AL2230); +		addr = abyVT3184_AL2230; +		agc = abyVT3184_AGC; +		length_agc = sizeof(abyVT3184_AGC); + +		priv->abyBBVGA[0] = 0x1C; +		priv->abyBBVGA[1] = 0x10; +		priv->abyBBVGA[2] = 0x0; +		priv->abyBBVGA[3] = 0x0; +		priv->ldBmThreshold[0] = -70; +		priv->ldBmThreshold[1] = -48; +		priv->ldBmThreshold[2] = 0; +		priv->ldBmThreshold[3] = 0; +	} else if (priv->byRFType == RF_AIROHA7230) { +		priv->byBBRxConf = abyVT3184_AL2230[10]; +		length = sizeof(abyVT3184_AL2230); +		addr = abyVT3184_AL2230; +		agc = abyVT3184_AGC; +		length_agc = sizeof(abyVT3184_AGC); + +		addr[0xd7] = 0x06; + +		priv->abyBBVGA[0] = 0x1c; +		priv->abyBBVGA[1] = 0x10; +		priv->abyBBVGA[2] = 0x0; +		priv->abyBBVGA[3] = 0x0; +		priv->ldBmThreshold[0] = -70; +		priv->ldBmThreshold[1] = -48; +		priv->ldBmThreshold[2] = 0; +		priv->ldBmThreshold[3] = 0; +	} else if ((priv->byRFType == RF_VT3226) || +			(priv->byRFType == RF_VT3226D0)) { +		priv->byBBRxConf = abyVT3184_VT3226D0[10]; +		length = sizeof(abyVT3184_VT3226D0); +		addr = abyVT3184_VT3226D0; +		agc = abyVT3184_AGC; +		length_agc = sizeof(abyVT3184_AGC); + +		priv->abyBBVGA[0] = 0x20; +		priv->abyBBVGA[1] = 0x10; +		priv->abyBBVGA[2] = 0x0; +		priv->abyBBVGA[3] = 0x0; +		priv->ldBmThreshold[0] = -70; +		priv->ldBmThreshold[1] = -48; +		priv->ldBmThreshold[2] = 0; +		priv->ldBmThreshold[3] = 0; +		/* Fix VT3226 DFC system timing issue */ +		MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); +	} else if ((priv->byRFType == RF_VT3342A0)) { +		priv->byBBRxConf = abyVT3184_VT3226D0[10]; +		length = sizeof(abyVT3184_VT3226D0); +		addr = abyVT3184_VT3226D0; +		agc = abyVT3184_AGC; +		length_agc = sizeof(abyVT3184_AGC); + +		priv->abyBBVGA[0] = 0x20; +		priv->abyBBVGA[1] = 0x10; +		priv->abyBBVGA[2] = 0x0; +		priv->abyBBVGA[3] = 0x0; +		priv->ldBmThreshold[0] = -70; +		priv->ldBmThreshold[1] = -48; +		priv->ldBmThreshold[2] = 0; +		priv->ldBmThreshold[3] = 0; +		/* Fix VT3226 DFC system timing issue */ +		MACvRegBitsOn(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT); +	} else { +		return true; +	} -/* - * Description: Set ShortSlotTime mode - * - * Parameters: - *  In: - *      pDevice     - Device Structure - *  Out: - *      none - * - * Return Value: none - * - */ -void BBvSetShortSlotTime(struct vnt_private *pDevice) -{ -    u8 byBBVGA=0; +	memcpy(array, addr, length); -	if (pDevice->bShortSlotTime) -        pDevice->byBBRxConf &= 0xDF;//1101 1111 -	else -        pDevice->byBBRxConf |= 0x20;//0010 0000 +	vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, +		MESSAGE_REQUEST_BBREG, length, array); -    ControlvReadByte (pDevice, MESSAGE_REQUEST_BBREG, 0xE7, &byBBVGA); -	if (byBBVGA == pDevice->abyBBVGA[0]) -        pDevice->byBBRxConf |= 0x20;//0010 0000 +	memcpy(array, agc, length_agc); -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf); -} +	vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, +		MESSAGE_REQUEST_BBAGC, length_agc, array); -void BBvSetVGAGainOffset(struct vnt_private *pDevice, u8 byData) -{ +	if ((priv->byRFType == RF_VT3226) || +		(priv->byRFType == RF_VT3342A0)) { +		vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, +						MAC_REG_ITRTMSET, 0x23); +		MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); +	} else if (priv->byRFType == RF_VT3226D0) { +		vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, +						MAC_REG_ITRTMSET, 0x11); +		MACvRegBitsOn(priv, MAC_REG_PAPEDELAY, 0x01); +	} -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xE7, byData); +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); -    // patch for 3253B0 Baseband with Cardbus module -	if (pDevice->bShortSlotTime) -		pDevice->byBBRxConf &= 0xDF; /* 1101 1111 */ -	else -		pDevice->byBBRxConf |= 0x20; /* 0010 0000 */ +	vnt_rf_table_download(priv); + +	/* Fix for TX USB resets from vendors driver */ +	vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, +		MESSAGE_REQUEST_MEM, sizeof(data), &data); + +	data |= 0x2; -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0A, pDevice->byBBRxConf);//CR10 +	vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, +		MESSAGE_REQUEST_MEM, sizeof(data), &data); + +	return true;  }  /* - * Description: BBvSetDeepSleep + * Description: Set ShortSlotTime mode   *   * Parameters:   *  In: - *      pDevice          - Device Structure + *	priv	- Device Structure   *  Out:   *      none   *   * Return Value: none   *   */ -void BBvSetDeepSleep(struct vnt_private *pDevice) -{ -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);//CR12 -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0xB9);//CR13 -} - -void BBvExitDeepSleep(struct vnt_private *pDevice) +void BBvSetShortSlotTime(struct vnt_private *priv)  { -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0C, 0x00);//CR12 -    ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0x0D, 0x01);//CR13 -} +	u8 bb_vga = 0; -static unsigned long s_ulGetLowSQ3(struct vnt_private *pDevice) -{ -	int ii; -	unsigned long ulSQ3 = 0; -	unsigned long ulMaxPacket; +	if (priv->bShortSlotTime) +		priv->byBBRxConf &= 0xdf; +	else +		priv->byBBRxConf |= 0x20; -    ulMaxPacket = pDevice->aulPktNum[RATE_54M]; -	if (pDevice->aulPktNum[RATE_54M] != 0) -        ulSQ3 = pDevice->aulSQ3Val[RATE_54M] / pDevice->aulPktNum[RATE_54M]; +	vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); -	for (ii = RATE_48M; ii >= RATE_6M; ii--) -		if (pDevice->aulPktNum[ii] > ulMaxPacket) { -            ulMaxPacket = pDevice->aulPktNum[ii]; -            ulSQ3 = pDevice->aulSQ3Val[ii] / pDevice->aulPktNum[ii]; -        } +	if (bb_vga == priv->abyBBVGA[0]) +		priv->byBBRxConf |= 0x20; -    return ulSQ3; +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf);  } -static unsigned long s_ulGetRatio(struct vnt_private *pDevice) +void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data)  { -	int ii, jj; -	unsigned long ulRatio = 0; -	unsigned long ulMaxPacket; -	unsigned long ulPacketNum; - -    //This is a thousand-ratio -    ulMaxPacket = pDevice->aulPktNum[RATE_54M]; -    if ( pDevice->aulPktNum[RATE_54M] != 0 ) { -        ulPacketNum = pDevice->aulPktNum[RATE_54M]; -        ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); -        ulRatio += TOP_RATE_54M; -    } -	for (ii = RATE_48M; ii >= RATE_1M; ii--) -        if ( pDevice->aulPktNum[ii] > ulMaxPacket ) { -            ulPacketNum = 0; -            for ( jj=RATE_54M;jj>=ii;jj--) -                ulPacketNum += pDevice->aulPktNum[jj]; -            ulRatio = (ulPacketNum * 1000 / pDevice->uDiversityCnt); -            ulRatio += TOP_RATE_48M; -            ulMaxPacket = pDevice->aulPktNum[ii]; -        } - -    return ulRatio; -} -static void s_vClearSQ3Value(struct vnt_private *pDevice) -{ -    int ii; -    pDevice->uDiversityCnt = 0; +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data); -    for ( ii=RATE_1M;ii<MAX_RATE;ii++) { -        pDevice->aulPktNum[ii] = 0; -        pDevice->aulSQ3Val[ii] = 0; -    } +	/* patch for 3253B0 Baseband with Cardbus module */ +	if (priv->bShortSlotTime) +		priv->byBBRxConf &= 0xdf; /* 1101 1111 */ +	else +		priv->byBBRxConf |= 0x20; /* 0010 0000 */ + +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf);  }  /* - * Description: Antenna Diversity + * Description: BBvSetDeepSleep   *   * Parameters:   *  In: - *      pDevice          - Device Structure - *      byRSR            - RSR from received packet - *      bySQ3            - SQ3 value from received packet + *	priv	- Device Structure   *  Out:   *      none   *   * Return Value: none   *   */ - -void BBvAntennaDiversity(struct vnt_private *pDevice, -	u8 byRxRate, u8 bySQ3) +void BBvSetDeepSleep(struct vnt_private *priv)  { - -    pDevice->uDiversityCnt++; -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pDevice->uDiversityCnt = %d\n", (int)pDevice->uDiversityCnt); - -    if (byRxRate == 2) { -        pDevice->aulPktNum[RATE_1M]++; -    } -    else if (byRxRate==4) { -        pDevice->aulPktNum[RATE_2M]++; -    } -    else if (byRxRate==11) { -        pDevice->aulPktNum[RATE_5M]++; -    } -    else if (byRxRate==22) { -        pDevice->aulPktNum[RATE_11M]++; -    } -    else if(byRxRate==12){ -        pDevice->aulPktNum[RATE_6M]++; -        pDevice->aulSQ3Val[RATE_6M] += bySQ3; -    } -    else if(byRxRate==18){ -        pDevice->aulPktNum[RATE_9M]++; -        pDevice->aulSQ3Val[RATE_9M] += bySQ3; -    } -    else if(byRxRate==24){ -        pDevice->aulPktNum[RATE_12M]++; -        pDevice->aulSQ3Val[RATE_12M] += bySQ3; -    } -    else if(byRxRate==36){ -        pDevice->aulPktNum[RATE_18M]++; -        pDevice->aulSQ3Val[RATE_18M] += bySQ3; -    } -    else if(byRxRate==48){ -        pDevice->aulPktNum[RATE_24M]++; -        pDevice->aulSQ3Val[RATE_24M] += bySQ3; -    } -    else if(byRxRate==72){ -        pDevice->aulPktNum[RATE_36M]++; -        pDevice->aulSQ3Val[RATE_36M] += bySQ3; -    } -    else if(byRxRate==96){ -        pDevice->aulPktNum[RATE_48M]++; -        pDevice->aulSQ3Val[RATE_48M] += bySQ3; -    } -    else if(byRxRate==108){ -        pDevice->aulPktNum[RATE_54M]++; -        pDevice->aulSQ3Val[RATE_54M] += bySQ3; -    } - -    if (pDevice->byAntennaState == 0) { - -        if (pDevice->uDiversityCnt > pDevice->ulDiversityNValue) { -            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ulDiversityNValue=[%d],54M-[%d]\n",(int)pDevice->ulDiversityNValue, (int)pDevice->aulPktNum[RATE_54M]); - -            pDevice->ulSQ3_State0 = s_ulGetLowSQ3(pDevice); -            pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); -            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0, SQ3= [%08x] rate = [%08x]\n",(int)pDevice->ulSQ3_State0,(int)pDevice->ulRatio_State0); - -            if ( ((pDevice->aulPktNum[RATE_54M] < pDevice->ulDiversityNValue/2) && -                  (pDevice->ulSQ3_State0 > pDevice->ulSQ3TH) ) || -                 (pDevice->ulSQ3_State0 == 0 ) )  { - -                if ( pDevice->byTMax == 0 ) -                    return; - -		bScheduleCommand((void *) pDevice, -				 WLAN_CMD_CHANGE_ANTENNA, -				 NULL); - -                pDevice->byAntennaState = 1; - -                del_timer(&pDevice->TimerSQ3Tmax3); -                del_timer(&pDevice->TimerSQ3Tmax2); -                pDevice->TimerSQ3Tmax1.expires =  RUN_AT(pDevice->byTMax * HZ); -                add_timer(&pDevice->TimerSQ3Tmax1); - -            } else { -                pDevice->TimerSQ3Tmax3.expires =  RUN_AT(pDevice->byTMax3 * HZ); -                add_timer(&pDevice->TimerSQ3Tmax3); -            } -            s_vClearSQ3Value(pDevice); - -        } -    } else { //byAntennaState == 1 - -        if (pDevice->uDiversityCnt > pDevice->ulDiversityMValue) { - -            del_timer(&pDevice->TimerSQ3Tmax1); -            pDevice->ulSQ3_State1 = s_ulGetLowSQ3(pDevice); -            pDevice->ulRatio_State1 = s_ulGetRatio(pDevice); -            DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State1, rate0 = %08x,rate1 = %08x\n",(int)pDevice->ulRatio_State0,(int)pDevice->ulRatio_State1); - -            if ( ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 != 0)) || -                 ((pDevice->ulSQ3_State1 == 0) && (pDevice->ulSQ3_State0 == 0) && (pDevice->ulRatio_State1 < pDevice->ulRatio_State0)) || -                 ((pDevice->ulSQ3_State1 != 0) && (pDevice->ulSQ3_State0 != 0) && (pDevice->ulSQ3_State0 < pDevice->ulSQ3_State1)) -               ) { - -		bScheduleCommand((void *) pDevice, -				 WLAN_CMD_CHANGE_ANTENNA, -				 NULL); - -                pDevice->TimerSQ3Tmax3.expires =  RUN_AT(pDevice->byTMax3 * HZ); -                pDevice->TimerSQ3Tmax2.expires =  RUN_AT(pDevice->byTMax2 * HZ); -                add_timer(&pDevice->TimerSQ3Tmax3); -                add_timer(&pDevice->TimerSQ3Tmax2); - -            } -            pDevice->byAntennaState = 0; -            s_vClearSQ3Value(pDevice); -        } -    } //byAntennaState +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */  } -/*+ - * - * Description: - *  Timer for SQ3 antenna diversity - * - * Parameters: - *  In: - *      pvSysSpec1 - *      hDeviceContext - Pointer to the adapter - *      pvSysSpec2 - *      pvSysSpec3 - *  Out: - *      none - * - * Return Value: none - * --*/ - -void TimerSQ3CallBack(struct vnt_private *pDevice) +void BBvExitDeepSleep(struct vnt_private *priv)  { - -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3CallBack..."); -    spin_lock_irq(&pDevice->lock); - -    bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); -    pDevice->byAntennaState = 0; -    s_vClearSQ3Value(pDevice); -    pDevice->TimerSQ3Tmax3.expires =  RUN_AT(pDevice->byTMax3 * HZ); -    pDevice->TimerSQ3Tmax2.expires =  RUN_AT(pDevice->byTMax2 * HZ); -    add_timer(&pDevice->TimerSQ3Tmax3); -    add_timer(&pDevice->TimerSQ3Tmax2); - -    spin_unlock_irq(&pDevice->lock); +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */  } -/*+ - * - * Description: - *  Timer for SQ3 antenna diversity - * - * Parameters: - *  In: - *      pvSysSpec1 - *      hDeviceContext - Pointer to the adapter - *      pvSysSpec2 - *      pvSysSpec3 - *  Out: - *      none - * - * Return Value: none - * --*/ - -void TimerSQ3Tmax3CallBack(struct vnt_private *pDevice) +void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning)  { +	u8 cr_201 = 0x0, cr_206 = 0x0; +	u8 ed_inx = priv->byBBPreEDIndex; + +	switch (priv->byRFType) { +	case RF_AL2230: +	case RF_AL2230S: +	case RF_AIROHA7230: +		if (scanning) { /* Max sensitivity */ +			ed_inx = 0; +			cr_206 = 0x30; +			break; +		} + +		if (priv->byBBPreEDRSSI <= 45) { +			ed_inx = 20; +			cr_201 = 0xff; +		} else if (priv->byBBPreEDRSSI <= 46) { +			ed_inx = 19; +			cr_201 = 0x1a; +		} else if (priv->byBBPreEDRSSI <= 47) { +			ed_inx = 18; +			cr_201 = 0x15; +		} else if (priv->byBBPreEDRSSI <= 49) { +			ed_inx = 17; +			cr_201 = 0xe; +		} else if (priv->byBBPreEDRSSI <= 51) { +			ed_inx = 16; +			cr_201 = 0x9; +		} else if (priv->byBBPreEDRSSI <= 53) { +			ed_inx = 15; +			cr_201 = 0x6; +		} else if (priv->byBBPreEDRSSI <= 55) { +			ed_inx = 14; +			cr_201 = 0x3; +		} else if (priv->byBBPreEDRSSI <= 56) { +			ed_inx = 13; +			cr_201 = 0x2; +			cr_206 = 0xa0; +		} else if (priv->byBBPreEDRSSI <= 57) { +			ed_inx = 12; +			cr_201 = 0x2; +			cr_206 = 0x20; +		} else if (priv->byBBPreEDRSSI <= 58) { +			ed_inx = 11; +			cr_201 = 0x1; +			cr_206 = 0xa0; +		} else if (priv->byBBPreEDRSSI <= 59) { +			ed_inx = 10; +			cr_201 = 0x1; +			cr_206 = 0x54; +		} else if (priv->byBBPreEDRSSI <= 60) { +			ed_inx = 9; +			cr_201 = 0x1; +			cr_206 = 0x18; +		} else if (priv->byBBPreEDRSSI <= 61) { +			ed_inx = 8; +			cr_206 = 0xe3; +		} else if (priv->byBBPreEDRSSI <= 62) { +			ed_inx = 7; +			cr_206 = 0xb9; +		} else if (priv->byBBPreEDRSSI <= 63) { +			ed_inx = 6; +			cr_206 = 0x93; +		} else if (priv->byBBPreEDRSSI <= 64) { +			ed_inx = 5; +			cr_206 = 0x79; +		} else if (priv->byBBPreEDRSSI <= 65) { +			ed_inx = 4; +			cr_206 = 0x62; +		} else if (priv->byBBPreEDRSSI <= 66) { +			ed_inx = 3; +			cr_206 = 0x51; +		} else if (priv->byBBPreEDRSSI <= 67) { +			ed_inx = 2; +			cr_206 = 0x43; +		} else if (priv->byBBPreEDRSSI <= 68) { +			ed_inx = 1; +			cr_206 = 0x36; +		} else { +			ed_inx = 0; +			cr_206 = 0x30; +		} +		break; + +	case RF_VT3226: +	case RF_VT3226D0: +		if (scanning)	{ /* Max sensitivity */ +			ed_inx = 0; +			cr_206 = 0x24; +			break; +		} + +		if (priv->byBBPreEDRSSI <= 41) { +			ed_inx = 22; +			cr_201 = 0xff; +		} else if (priv->byBBPreEDRSSI <= 42) { +			ed_inx = 21; +			cr_201 = 0x36; +		} else if (priv->byBBPreEDRSSI <= 43) { +			ed_inx = 20; +			cr_201 = 0x26; +		} else if (priv->byBBPreEDRSSI <= 45) { +			ed_inx = 19; +			cr_201 = 0x18; +		} else if (priv->byBBPreEDRSSI <= 47) { +			ed_inx = 18; +			cr_201 = 0x11; +		} else if (priv->byBBPreEDRSSI <= 49) { +			ed_inx = 17; +			cr_201 = 0xa; +		} else if (priv->byBBPreEDRSSI <= 51) { +			ed_inx = 16; +			cr_201 = 0x7; +		} else if (priv->byBBPreEDRSSI <= 53) { +			ed_inx = 15; +			cr_201 = 0x4; +		} else if (priv->byBBPreEDRSSI <= 55) { +			ed_inx = 14; +			cr_201 = 0x2; +			cr_206 = 0xc0; +		} else if (priv->byBBPreEDRSSI <= 56) { +			ed_inx = 13; +			cr_201 = 0x2; +			cr_206 = 0x30; +		} else if (priv->byBBPreEDRSSI <= 57) { +			ed_inx = 12; +			cr_201 = 0x1; +			cr_206 = 0xb0; +		} else if (priv->byBBPreEDRSSI <= 58) { +			ed_inx = 11; +			cr_201 = 0x1; +			cr_206 = 0x70; +		} else if (priv->byBBPreEDRSSI <= 59) { +			ed_inx = 10; +			cr_201 = 0x1; +			cr_206 = 0x30; +		} else if (priv->byBBPreEDRSSI <= 60) { +			ed_inx = 9; +			cr_206 = 0xea; +		} else if (priv->byBBPreEDRSSI <= 61) { +			ed_inx = 8; +			cr_206 = 0xc0; +		} else if (priv->byBBPreEDRSSI <= 62) { +			ed_inx = 7; +			cr_206 = 0x9c; +		} else if (priv->byBBPreEDRSSI <= 63) { +			ed_inx = 6; +			cr_206 = 0x80; +		} else if (priv->byBBPreEDRSSI <= 64) { +			ed_inx = 5; +			cr_206 = 0x68; +		} else if (priv->byBBPreEDRSSI <= 65) { +			ed_inx = 4; +			cr_206 = 0x52; +		} else if (priv->byBBPreEDRSSI <= 66) { +			ed_inx = 3; +			cr_206 = 0x43; +		} else if (priv->byBBPreEDRSSI <= 67) { +			ed_inx = 2; +			cr_206 = 0x36; +		} else if (priv->byBBPreEDRSSI <= 68) { +			ed_inx = 1; +			cr_206 = 0x2d; +		} else { +			ed_inx = 0; +			cr_206 = 0x24; +		} +		break; + +	case RF_VT3342A0: +		if (scanning) { /* need Max sensitivity */ +			ed_inx = 0; +			cr_206 = 0x38; +			break; +		} + +		if (priv->byBBPreEDRSSI <= 41) { +			ed_inx = 20; +			cr_201 = 0xff; +		} else if (priv->byBBPreEDRSSI <= 42) { +			ed_inx = 19; +			cr_201 = 0x36; +		} else if (priv->byBBPreEDRSSI <= 43) { +			ed_inx = 18; +			cr_201 = 0x26; +		} else if (priv->byBBPreEDRSSI <= 45) { +			ed_inx = 17; +			cr_201 = 0x18; +		} else if (priv->byBBPreEDRSSI <= 47) { +			ed_inx = 16; +			cr_201 = 0x11; +		} else if (priv->byBBPreEDRSSI <= 49) { +			ed_inx = 15; +			cr_201 = 0xa; +		} else if (priv->byBBPreEDRSSI <= 51) { +			ed_inx = 14; +			cr_201 = 0x7; +		} else if (priv->byBBPreEDRSSI <= 53) { +			ed_inx = 13; +			cr_201 = 0x4; +		} else if (priv->byBBPreEDRSSI <= 55) { +			ed_inx = 12; +			cr_201 = 0x2; +			cr_206 = 0xc0; +		} else if (priv->byBBPreEDRSSI <= 56) { +			ed_inx = 11; +			cr_201 = 0x2; +			cr_206 = 0x30; +		} else if (priv->byBBPreEDRSSI <= 57) { +			ed_inx = 10; +			cr_201 = 0x1; +			cr_206 = 0xb0; +		} else if (priv->byBBPreEDRSSI <= 58) { +			ed_inx = 9; +			cr_201 = 0x1; +			cr_206 = 0x70; +		} else if (priv->byBBPreEDRSSI <= 59) { +			ed_inx = 8; +			cr_201 = 0x1; +			cr_206 = 0x30; +		} else if (priv->byBBPreEDRSSI <= 60) { +			ed_inx = 7; +			cr_206 = 0xea; +		} else if (priv->byBBPreEDRSSI <= 61) { +			ed_inx = 6; +			cr_206 = 0xc0; +		} else if (priv->byBBPreEDRSSI <= 62) { +			ed_inx = 5; +			cr_206 = 0x9c; +		} else if (priv->byBBPreEDRSSI <= 63) { +			ed_inx = 4; +			cr_206 = 0x80; +		} else if (priv->byBBPreEDRSSI <= 64) { +			ed_inx = 3; +			cr_206 = 0x68; +		} else if (priv->byBBPreEDRSSI <= 65) { +			ed_inx = 2; +			cr_206 = 0x52; +		} else if (priv->byBBPreEDRSSI <= 66) { +			ed_inx = 1; +			cr_206 = 0x43; +		} else { +			ed_inx = 0; +			cr_206 = 0x38; +		} +		break; -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TimerSQ3Tmax3CallBack..."); -    spin_lock_irq(&pDevice->lock); - -    pDevice->ulRatio_State0 = s_ulGetRatio(pDevice); -    DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"SQ3_State0 = [%08x]\n",(int)pDevice->ulRatio_State0); +	} -    s_vClearSQ3Value(pDevice); -    if ( pDevice->byTMax == 0 ) { -        pDevice->TimerSQ3Tmax3.expires =  RUN_AT(pDevice->byTMax3 * HZ); -        add_timer(&pDevice->TimerSQ3Tmax3); -        spin_unlock_irq(&pDevice->lock); -        return; -    } +	if (ed_inx == priv->byBBPreEDIndex && !scanning) +		return; -    bScheduleCommand((void *) pDevice, WLAN_CMD_CHANGE_ANTENNA, NULL); -    pDevice->byAntennaState = 1; -    del_timer(&pDevice->TimerSQ3Tmax3); -    del_timer(&pDevice->TimerSQ3Tmax2); -    pDevice->TimerSQ3Tmax1.expires =  RUN_AT(pDevice->byTMax * HZ); -    add_timer(&pDevice->TimerSQ3Tmax1); +	priv->byBBPreEDIndex = ed_inx; -    spin_unlock_irq(&pDevice->lock); -} - -void BBvUpdatePreEDThreshold(struct vnt_private *pDevice, int bScanning) -{ +	dev_dbg(&priv->usb->dev, "%s byBBPreEDRSSI %d\n", +					__func__, priv->byBBPreEDRSSI); -    switch(pDevice->byRFType) -    { -        case RF_AL2230: -        case RF_AL2230S: -        case RF_AIROHA7230: -            //RobertYu:20060627, update new table - -            if( bScanning ) -            {   // need Max sensitivity //RSSI -69, -70,.... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -69, -70, -71,...\n"); -                break; -            } - -            if(pDevice->byBBPreEDRSSI <= 45) { // RSSI 0, -1,-2,....-45 -                if(pDevice->byBBPreEDIndex == 20) break; -                pDevice->byBBPreEDIndex = 20; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI 0, -1,-2,..-45\n"); -            } else if(pDevice->byBBPreEDRSSI <= 46)  { //RSSI -46 -                if(pDevice->byBBPreEDIndex == 19) break; -                pDevice->byBBPreEDIndex = 19; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x1A); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -46\n"); -            } else if(pDevice->byBBPreEDRSSI <= 47)  { //RSSI -47 -                if(pDevice->byBBPreEDIndex == 18) break; -                pDevice->byBBPreEDIndex = 18; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x15); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -47\n"); -            } else if(pDevice->byBBPreEDRSSI <= 49)  { //RSSI -48, -49 -                if(pDevice->byBBPreEDIndex == 17) break; -                pDevice->byBBPreEDIndex = 17; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0E); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -48,-49\n"); -            } else if(pDevice->byBBPreEDRSSI <= 51)  { //RSSI -50, -51 -                if(pDevice->byBBPreEDIndex == 16) break; -                pDevice->byBBPreEDIndex = 16; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x09); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -50,-51\n"); -            } else if(pDevice->byBBPreEDRSSI <= 53)  { //RSSI -52, -53 -                if(pDevice->byBBPreEDIndex == 15) break; -                pDevice->byBBPreEDIndex = 15; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x06); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -52,-53\n"); -            } else if(pDevice->byBBPreEDRSSI <= 55)  { //RSSI -54, -55 -                if(pDevice->byBBPreEDIndex == 14) break; -                pDevice->byBBPreEDIndex = 14; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x03); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -54,-55\n"); -            } else if(pDevice->byBBPreEDRSSI <= 56)  { //RSSI -56 -                if(pDevice->byBBPreEDIndex == 13) break; -                pDevice->byBBPreEDIndex = 13; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -56\n"); -            } else if(pDevice->byBBPreEDRSSI <= 57)  { //RSSI -57 -                if(pDevice->byBBPreEDIndex == 12) break; -                pDevice->byBBPreEDIndex = 12; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x20); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -57\n"); -            } else if(pDevice->byBBPreEDRSSI <= 58)  { //RSSI -58 -                if(pDevice->byBBPreEDIndex == 11) break; -                pDevice->byBBPreEDIndex = 11; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xA0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -58\n"); -            } else if(pDevice->byBBPreEDRSSI <= 59)  { //RSSI -59 -                if(pDevice->byBBPreEDIndex == 10) break; -                pDevice->byBBPreEDIndex = 10; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x54); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -59\n"); -            } else if(pDevice->byBBPreEDRSSI <= 60)  { //RSSI -60 -                if(pDevice->byBBPreEDIndex == 9) break; -                pDevice->byBBPreEDIndex = 9; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x18); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -60\n"); -            } else if(pDevice->byBBPreEDRSSI <= 61)  { //RSSI -61 -                if(pDevice->byBBPreEDIndex == 8) break; -                pDevice->byBBPreEDIndex = 8; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xE3); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -61\n"); -            } else if(pDevice->byBBPreEDRSSI <= 62)  { //RSSI -62 -                if(pDevice->byBBPreEDIndex == 7) break; -                pDevice->byBBPreEDIndex = 7; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB9); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -62\n"); -            } else if(pDevice->byBBPreEDRSSI <= 63)  { //RSSI -63 -                if(pDevice->byBBPreEDIndex == 6) break; -                pDevice->byBBPreEDIndex = 6; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x93); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -63\n"); -            } else if(pDevice->byBBPreEDRSSI <= 64)  { //RSSI -64 -                if(pDevice->byBBPreEDIndex == 5) break; -                pDevice->byBBPreEDIndex = 5; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x79); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -64\n"); -            } else if(pDevice->byBBPreEDRSSI <= 65)  { //RSSI -65 -                if(pDevice->byBBPreEDIndex == 4) break; -                pDevice->byBBPreEDIndex = 4; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x62); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -65\n"); -            } else if(pDevice->byBBPreEDRSSI <= 66)  { //RSSI -66 -                if(pDevice->byBBPreEDIndex == 3) break; -                pDevice->byBBPreEDIndex = 3; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x51); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -66\n"); -            } else if(pDevice->byBBPreEDRSSI <= 67)  { //RSSI -67 -                if(pDevice->byBBPreEDIndex == 2) break; -                pDevice->byBBPreEDIndex = 2; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -67\n"); -            } else if(pDevice->byBBPreEDRSSI <= 68)  { //RSSI -68 -                if(pDevice->byBBPreEDIndex == 1) break; -                pDevice->byBBPreEDIndex = 1; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -68\n"); -            } else { //RSSI -69, -70,.... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -69, -70,...\n"); -            } -            break; - -        case RF_VT3226: -        case RF_VT3226D0: -            //RobertYu:20060627, update new table - -            if( bScanning ) -            {   // need Max sensitivity  //RSSI -69, -70, ... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -69, -70,..\n"); -                break; -            } - -            if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 -                if(pDevice->byBBPreEDIndex == 22) break; -                pDevice->byBBPreEDIndex = 22; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); -            } else if(pDevice->byBBPreEDRSSI <= 42)  { //RSSI -42 -                if(pDevice->byBBPreEDIndex == 21) break; -                pDevice->byBBPreEDIndex = 21; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -42\n"); -            } else if(pDevice->byBBPreEDRSSI <= 43)  { //RSSI -43 -                if(pDevice->byBBPreEDIndex == 20) break; -                pDevice->byBBPreEDIndex = 20; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -43\n"); -            } else if(pDevice->byBBPreEDRSSI <= 45)  { //RSSI -44, -45 -                if(pDevice->byBBPreEDIndex == 19) break; -                pDevice->byBBPreEDIndex = 19; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -44,-45\n"); -            } else if(pDevice->byBBPreEDRSSI <= 47)  { //RSSI -46, -47 -                if(pDevice->byBBPreEDIndex == 18) break; -                pDevice->byBBPreEDIndex = 18; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -46,-47\n"); -            } else if(pDevice->byBBPreEDRSSI <= 49)  { //RSSI -48, -49 -                if(pDevice->byBBPreEDIndex == 17) break; -                pDevice->byBBPreEDIndex = 17; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -48,-49\n"); -            } else if(pDevice->byBBPreEDRSSI <= 51)  { //RSSI -50, -51 -                if(pDevice->byBBPreEDIndex == 16) break; -                pDevice->byBBPreEDIndex = 16; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -50,-51\n"); -            } else if(pDevice->byBBPreEDRSSI <= 53)  { //RSSI -52, -53 -                if(pDevice->byBBPreEDIndex == 15) break; -                pDevice->byBBPreEDIndex = 15; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -52,-53\n"); -            } else if(pDevice->byBBPreEDRSSI <= 55)  { //RSSI -54, -55 -                if(pDevice->byBBPreEDIndex == 14) break; -                pDevice->byBBPreEDIndex = 14; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -54,-55\n"); -            } else if(pDevice->byBBPreEDRSSI <= 56)  { //RSSI -56 -                if(pDevice->byBBPreEDIndex == 13) break; -                pDevice->byBBPreEDIndex = 13; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -56\n"); -            } else if(pDevice->byBBPreEDRSSI <= 57)  { //RSSI -57 -                if(pDevice->byBBPreEDIndex == 12) break; -                pDevice->byBBPreEDIndex = 12; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -57\n"); -            } else if(pDevice->byBBPreEDRSSI <= 58)  { //RSSI -58 -                if(pDevice->byBBPreEDIndex == 11) break; -                pDevice->byBBPreEDIndex = 11; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -58\n"); -            } else if(pDevice->byBBPreEDRSSI <= 59)  { //RSSI -59 -                if(pDevice->byBBPreEDIndex == 10) break; -                pDevice->byBBPreEDIndex = 10; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -59\n"); -            } else if(pDevice->byBBPreEDRSSI <= 60)  { //RSSI -60 -                if(pDevice->byBBPreEDIndex == 9) break; -                pDevice->byBBPreEDIndex = 9; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -60\n"); -            } else if(pDevice->byBBPreEDRSSI <= 61)  { //RSSI -61 -                if(pDevice->byBBPreEDIndex == 8) break; -                pDevice->byBBPreEDIndex = 8; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -61\n"); -            } else if(pDevice->byBBPreEDRSSI <= 62)  { //RSSI -62 -                if(pDevice->byBBPreEDIndex == 7) break; -                pDevice->byBBPreEDIndex = 7; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -62\n"); -            } else if(pDevice->byBBPreEDRSSI <= 63)  { //RSSI -63 -                if(pDevice->byBBPreEDIndex == 6) break; -                pDevice->byBBPreEDIndex = 6; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -63\n"); -            } else if(pDevice->byBBPreEDRSSI <= 64)  { //RSSI -64 -                if(pDevice->byBBPreEDIndex == 5) break; -                pDevice->byBBPreEDIndex = 5; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -64\n"); -            } else if(pDevice->byBBPreEDRSSI <= 65)  { //RSSI -65 -                if(pDevice->byBBPreEDIndex == 4) break; -                pDevice->byBBPreEDIndex = 4; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -65\n"); -            } else if(pDevice->byBBPreEDRSSI <= 66)  { //RSSI -66 -                if(pDevice->byBBPreEDIndex == 3) break; -                pDevice->byBBPreEDIndex = 3; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -66\n"); -            } else if(pDevice->byBBPreEDRSSI <= 67)  { //RSSI -67 -                if(pDevice->byBBPreEDIndex == 2) break; -                pDevice->byBBPreEDIndex = 2; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x36); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -67\n"); -            } else if(pDevice->byBBPreEDRSSI <= 68)  { //RSSI -68 -                if(pDevice->byBBPreEDIndex == 1) break; -                pDevice->byBBPreEDIndex = 1; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x2D); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -68\n"); -            } else { //RSSI -69, -70, ... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x24); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -69, -70,..\n"); -            } -            break; - -        case RF_VT3342A0: //RobertYu:20060627, testing table -            if( bScanning ) -            {   // need Max sensitivity  //RSSI -67, -68, ... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -67, -68,..\n"); -                break; -            } - -            if(pDevice->byBBPreEDRSSI <= 41) { // RSSI 0, -1,-2,....-41 -                if(pDevice->byBBPreEDIndex == 20) break; -                pDevice->byBBPreEDIndex = 20; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0xFF); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI 0, -1,-2,..-41\n"); -            } else if(pDevice->byBBPreEDRSSI <= 42)  { //RSSI -42 -                if(pDevice->byBBPreEDIndex == 19) break; -                pDevice->byBBPreEDIndex = 19; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x36); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -42\n"); -            } else if(pDevice->byBBPreEDRSSI <= 43)  { //RSSI -43 -                if(pDevice->byBBPreEDIndex == 18) break; -                pDevice->byBBPreEDIndex = 18; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x26); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -43\n"); -            } else if(pDevice->byBBPreEDRSSI <= 45)  { //RSSI -44, -45 -                if(pDevice->byBBPreEDIndex == 17) break; -                pDevice->byBBPreEDIndex = 17; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x18); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -44,-45\n"); -            } else if(pDevice->byBBPreEDRSSI <= 47)  { //RSSI -46, -47 -                if(pDevice->byBBPreEDIndex == 16) break; -                pDevice->byBBPreEDIndex = 16; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x11); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -46,-47\n"); -            } else if(pDevice->byBBPreEDRSSI <= 49)  { //RSSI -48, -49 -                if(pDevice->byBBPreEDIndex == 15) break; -                pDevice->byBBPreEDIndex = 15; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x0a); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -48,-49\n"); -            } else if(pDevice->byBBPreEDRSSI <= 51)  { //RSSI -50, -51 -                if(pDevice->byBBPreEDIndex == 14) break; -                pDevice->byBBPreEDIndex = 14; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x07); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -50,-51\n"); -            } else if(pDevice->byBBPreEDRSSI <= 53)  { //RSSI -52, -53 -                if(pDevice->byBBPreEDIndex == 13) break; -                pDevice->byBBPreEDIndex = 13; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x04); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x00); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -52,-53\n"); -            } else if(pDevice->byBBPreEDRSSI <= 55)  { //RSSI -54, -55 -                if(pDevice->byBBPreEDIndex == 12) break; -                pDevice->byBBPreEDIndex = 12; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -54,-55\n"); -            } else if(pDevice->byBBPreEDRSSI <= 56)  { //RSSI -56 -                if(pDevice->byBBPreEDIndex == 11) break; -                pDevice->byBBPreEDIndex = 11; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x02); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -56\n"); -            } else if(pDevice->byBBPreEDRSSI <= 57)  { //RSSI -57 -                if(pDevice->byBBPreEDIndex == 10) break; -                pDevice->byBBPreEDIndex = 10; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xB0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -57\n"); -            } else if(pDevice->byBBPreEDRSSI <= 58)  { //RSSI -58 -                if(pDevice->byBBPreEDIndex == 9) break; -                pDevice->byBBPreEDIndex = 9; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x70); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -58\n"); -            } else if(pDevice->byBBPreEDRSSI <= 59)  { //RSSI -59 -                if(pDevice->byBBPreEDIndex == 8) break; -                pDevice->byBBPreEDIndex = 8; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x01); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x30); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -59\n"); -            } else if(pDevice->byBBPreEDRSSI <= 60)  { //RSSI -60 -                if(pDevice->byBBPreEDIndex == 7) break; -                pDevice->byBBPreEDIndex = 7; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xEA); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -60\n"); -            } else if(pDevice->byBBPreEDRSSI <= 61)  { //RSSI -61 -                if(pDevice->byBBPreEDIndex == 6) break; -                pDevice->byBBPreEDIndex = 6; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0xC0); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -61\n"); -            } else if(pDevice->byBBPreEDRSSI <= 62)  { //RSSI -62 -                if(pDevice->byBBPreEDIndex == 5) break; -                pDevice->byBBPreEDIndex = 5; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x9C); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -62\n"); -            } else if(pDevice->byBBPreEDRSSI <= 63)  { //RSSI -63 -                if(pDevice->byBBPreEDIndex == 4) break; -                pDevice->byBBPreEDIndex = 4; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x80); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -63\n"); -            } else if(pDevice->byBBPreEDRSSI <= 64)  { //RSSI -64 -                if(pDevice->byBBPreEDIndex == 3) break; -                pDevice->byBBPreEDIndex = 3; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x68); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -64\n"); -            } else if(pDevice->byBBPreEDRSSI <= 65)  { //RSSI -65 -                if(pDevice->byBBPreEDIndex == 2) break; -                pDevice->byBBPreEDIndex = 2; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x52); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -65\n"); -            } else if(pDevice->byBBPreEDRSSI <= 66)  { //RSSI -66 -                if(pDevice->byBBPreEDIndex == 1) break; -                pDevice->byBBPreEDIndex = 1; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x43); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -66\n"); -            } else { //RSSI -67, -68, ... -                if(pDevice->byBBPreEDIndex == 0) break; -                pDevice->byBBPreEDIndex = 0; -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xC9, 0x00); //CR201(0xC9) -                ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xCE, 0x38); //CR206(0xCE) -                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"            pDevice->byBBPreEDRSSI -67, -68,..\n"); -            } -            break; - -    } +	if (!cr_201 && !cr_206) +		return; +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xc9, cr_201); +	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xce, cr_206);  }  | 
