⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtmp_init.c

📁 ralink 2870 usb无线网卡 最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
			if (((value&0xf0)>>4) > Gpwrdelta)				t2 = ((value&0xf0)>>4)-(Gpwrdelta);			else				t2 = 0;			if (((value&0xf00)>>8) > Gpwrdelta)				t3 = ((value&0xf00)>>8)-(Gpwrdelta);			else				t3 = 0;			if (((value&0xf000)>>12) > Gpwrdelta)				t4 = ((value&0xf000)>>12)-(Gpwrdelta);			else				t4 = 0;		}						Gdata |= ((t1<<16) + (t2<<20) + (t3<<24) + (t4<<28));		data |= (value<<16);				/* For 20M/40M Power Delta issue */		pAd->Tx20MPwrCfgABand[i] = data;		pAd->Tx20MPwrCfgGBand[i] = data;		pAd->Tx40MPwrCfgABand[i] = Adata;		pAd->Tx40MPwrCfgGBand[i] = Gdata;				if (data != 0xffffffff)			RTMP_IO_WRITE32(pAd, TX_PWR_CFG_0 + i*4, data);		DBGPRINT_RAW(RT_DEBUG_TRACE, ("20MHz BW, 2.4G band-%lx,  Adata = %lx,  Gdata = %lx \n", data, Adata, Gdata));	}}/*	========================================================================		Routine Description:		Read initial channel power parameters from EEPROM			Arguments:		Adapter						Pointer to our adapter	Return Value:		None	IRQL = PASSIVE_LEVEL	Note:			========================================================================*/VOID	RTMPReadChannelPwr(	IN	PRTMP_ADAPTER	pAd){	UCHAR				i, choffset;	EEPROM_TX_PWR_STRUC	    Power;	EEPROM_TX_PWR_STRUC	    Power2;		// Read Tx power value for all channels	// Value from 1 - 0x7f. Default value is 24.	// Power value : 2.4G 0x00 (0) ~ 0x1F (31)	//             : 5.5G 0xF9 (-7) ~ 0x0F (15)		// 0. 11b/g, ch1 - ch 14	for (i = 0; i < 7; i++)	{		RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX_PWR_OFFSET + i * 2, Power.word);		RT28xx_EEPROM_READ16(pAd, EEPROM_G_TX2_PWR_OFFSET + i * 2, Power2.word);		pAd->TxPower[i * 2].Channel = i * 2 + 1;		pAd->TxPower[i * 2 + 1].Channel = i * 2 + 2;		if ((Power.field.Byte0 > 31) || (Power.field.Byte0 < 0))			pAd->TxPower[i * 2].Power = DEFAULT_RF_TX_POWER;		else			pAd->TxPower[i * 2].Power = Power.field.Byte0;		if ((Power.field.Byte1 > 31) || (Power.field.Byte1 < 0))			pAd->TxPower[i * 2 + 1].Power = DEFAULT_RF_TX_POWER;		else			pAd->TxPower[i * 2 + 1].Power = Power.field.Byte1;		if ((Power2.field.Byte0 > 31) || (Power2.field.Byte0 < 0))			pAd->TxPower[i * 2].Power2 = DEFAULT_RF_TX_POWER;		else			pAd->TxPower[i * 2].Power2 = Power2.field.Byte0;		if ((Power2.field.Byte1 > 31) || (Power2.field.Byte1 < 0))			pAd->TxPower[i * 2 + 1].Power2 = DEFAULT_RF_TX_POWER;		else			pAd->TxPower[i * 2 + 1].Power2 = Power2.field.Byte1;	}		// 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz)	// 1.1 Fill up channel	choffset = 14;	for (i = 0; i < 4; i++)	{		pAd->TxPower[3 * i + choffset + 0].Channel	= 36 + i * 8 + 0;		pAd->TxPower[3 * i + choffset + 0].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 0].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Channel	= 36 + i * 8 + 2;		pAd->TxPower[3 * i + choffset + 1].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Channel	= 36 + i * 8 + 4;		pAd->TxPower[3 * i + choffset + 2].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Power2	= DEFAULT_RF_TX_POWER;	}	// 1.2 Fill up power	for (i = 0; i < 6; i++)	{		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + i * 2, Power.word);		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + i * 2, Power2.word);		if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;					if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;				}		// 2. HipperLAN 2 100, 102 ,104; 108, 110, 112; 116, 118, 120; 124, 126, 128; 132, 134, 136; 140 (including central frequency in BW 40MHz)	// 2.1 Fill up channel	choffset = 14 + 12;	for (i = 0; i < 5; i++)	{		pAd->TxPower[3 * i + choffset + 0].Channel	= 100 + i * 8 + 0;		pAd->TxPower[3 * i + choffset + 0].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 0].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Channel	= 100 + i * 8 + 2;		pAd->TxPower[3 * i + choffset + 1].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Channel	= 100 + i * 8 + 4;		pAd->TxPower[3 * i + choffset + 2].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Power2	= DEFAULT_RF_TX_POWER;	}	pAd->TxPower[3 * 5 + choffset + 0].Channel		= 140;	pAd->TxPower[3 * 5 + choffset + 0].Power		= DEFAULT_RF_TX_POWER;	pAd->TxPower[3 * 5 + choffset + 0].Power2		= DEFAULT_RF_TX_POWER;	// 2.2 Fill up power	for (i = 0; i < 8; i++)	{		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);		if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;					if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;				}	// 3. U-NII upper band: 149, 151, 153; 157, 159, 161; 165, 167, 169; 171, 173 (including central frequency in BW 40MHz)	// 3.1 Fill up channel	choffset = 14 + 12 + 16;	/*for (i = 0; i < 2; i++)*/	for (i = 0; i < 3; i++)	{		pAd->TxPower[3 * i + choffset + 0].Channel	= 149 + i * 8 + 0;		pAd->TxPower[3 * i + choffset + 0].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 0].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Channel	= 149 + i * 8 + 2;		pAd->TxPower[3 * i + choffset + 1].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 1].Power2	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Channel	= 149 + i * 8 + 4;		pAd->TxPower[3 * i + choffset + 2].Power	= DEFAULT_RF_TX_POWER;		pAd->TxPower[3 * i + choffset + 2].Power2	= DEFAULT_RF_TX_POWER;	}	pAd->TxPower[3 * 3 + choffset + 0].Channel		= 171;	pAd->TxPower[3 * 3 + choffset + 0].Power		= DEFAULT_RF_TX_POWER;	pAd->TxPower[3 * 3 + choffset + 0].Power2		= DEFAULT_RF_TX_POWER;	pAd->TxPower[3 * 3 + choffset + 1].Channel		= 173;	pAd->TxPower[3 * 3 + choffset + 1].Power		= DEFAULT_RF_TX_POWER;	pAd->TxPower[3 * 3 + choffset + 1].Power2		= DEFAULT_RF_TX_POWER;	// 3.2 Fill up power	/*for (i = 0; i < 4; i++)*/	for (i = 0; i < 6; i++)	{		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + (choffset - 14) + i * 2, Power.word);		RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX2_PWR_OFFSET + (choffset - 14) + i * 2, Power2.word);		if ((Power.field.Byte0 < 16) && (Power.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power = Power.field.Byte0;		if ((Power.field.Byte1 < 16) && (Power.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power = Power.field.Byte1;					if ((Power2.field.Byte0 < 16) && (Power2.field.Byte0 >= -7))			pAd->TxPower[i * 2 + choffset + 0].Power2 = Power2.field.Byte0;		if ((Power2.field.Byte1 < 16) && (Power2.field.Byte1 >= -7))			pAd->TxPower[i * 2 + choffset + 1].Power2 = Power2.field.Byte1;				}	// 4. Print and Debug	/*choffset = 14 + 12 + 16 + 7;*/	choffset = 14 + 12 + 16 + 11;	}/*	========================================================================		Routine Description:		Read the following from the registry		1. All the parameters		2. NetworkAddres	Arguments:		Adapter						Pointer to our adapter		WrapperConfigurationContext	For use by NdisOpenConfiguration	Return Value:		NDIS_STATUS_SUCCESS		NDIS_STATUS_FAILURE		NDIS_STATUS_RESOURCES	IRQL = PASSIVE_LEVEL	Note:		========================================================================*/NDIS_STATUS	NICReadRegParameters(	IN	PRTMP_ADAPTER		pAd,	IN	NDIS_HANDLE			WrapperConfigurationContext	){	NDIS_STATUS						Status = NDIS_STATUS_SUCCESS;	DBGPRINT_S(Status, ("<-- NICReadRegParameters, Status=%x\n", Status));	return Status;}/*	========================================================================		Routine Description:		Read initial parameters from EEPROM			Arguments:		Adapter						Pointer to our adapter	Return Value:		None	IRQL = PASSIVE_LEVEL	Note:			========================================================================*/VOID	NICReadEEPROMParameters(	IN	PRTMP_ADAPTER	pAd,	IN	PUCHAR			mac_addr){	UINT32			data = 0;	USHORT			i, value, value2;	UCHAR			TmpPhy;	EEPROM_TX_PWR_STRUC	    Power;	EEPROM_VERSION_STRUC    Version;	EEPROM_ANTENNA_STRUC	Antenna;	EEPROM_NIC_CONFIG2_STRUC    NicConfig2;	DBGPRINT(RT_DEBUG_TRACE, ("--> NICReadEEPROMParameters\n"));		if (pAd->chipOps.eeinit)		pAd->chipOps.eeinit(pAd);#ifdef RTMP_EFUSE_SUPPORT#endif // RTMP_EFUSE_SUPPORT //	// Init EEPROM Address Number, before access EEPROM; if 93c46, EEPROMAddressNum=6, else if 93c66, EEPROMAddressNum=8	RTMP_IO_READ32(pAd, E2PROM_CSR, &data);	DBGPRINT(RT_DEBUG_TRACE, ("--> E2PROM_CSR = 0x%x\n", data));	if((data & 0x30) == 0)		pAd->EEPROMAddressNum = 6;		// 93C46	else if((data & 0x30) == 0x10)		pAd->EEPROMAddressNum = 8;     // 93C66	else		pAd->EEPROMAddressNum = 8;     // 93C86	DBGPRINT(RT_DEBUG_TRACE, ("--> EEPROMAddressNum = %d\n", pAd->EEPROMAddressNum ));	// RT2860 MAC no longer auto load MAC address from E2PROM. Driver has to intialize	// MAC address registers according to E2PROM setting	if (mac_addr == NULL ||		strlen((PSTRING) mac_addr) != 17 || 		mac_addr[2] != ':'  || mac_addr[5] != ':'  || mac_addr[8] != ':' ||		mac_addr[11] != ':' || mac_addr[14] != ':')	{		USHORT  Addr01,Addr23,Addr45 ;		RT28xx_EEPROM_READ16(pAd, 0x04, Addr01);		RT28xx_EEPROM_READ16(pAd, 0x06, Addr23);		RT28xx_EEPROM_READ16(pAd, 0x08, Addr45);		pAd->PermanentAddress[0] = (UCHAR)(Addr01 & 0xff);		pAd->PermanentAddress[1] = (UCHAR)(Addr01 >> 8);		pAd->PermanentAddress[2] = (UCHAR)(Addr23 & 0xff);		pAd->PermanentAddress[3] = (UCHAR)(Addr23 >> 8);		pAd->PermanentAddress[4] = (UCHAR)(Addr45 & 0xff);		pAd->PermanentAddress[5] = (UCHAR)(Addr45 >> 8);		DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from E2PROM \n"));	}	else	{		INT		j;		PSTRING	macptr;		macptr = (PSTRING) mac_addr;		for (j=0; j<MAC_ADDR_LEN; j++)		{			AtoH(macptr, &pAd->PermanentAddress[j], 1);			macptr=macptr+3;		}					DBGPRINT(RT_DEBUG_TRACE, ("Initialize MAC Address from module parameter \n"));	}			{		//more conveninet to test mbssid, so ap's bssid &0xf1		if (pAd->PermanentAddress[0] == 0xff)			pAd->PermanentAddress[0] = RandomByte(pAd)&0xf8;				//if (pAd->PermanentAddress[5] == 0xff)		//	pAd->PermanentAddress[5] = RandomByte(pAd)&0xf8;					DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",			pAd->PermanentAddress[0], pAd->PermanentAddress[1], 			pAd->PermanentAddress[2], pAd->PermanentAddress[3], 			pAd->PermanentAddress[4], pAd->PermanentAddress[5]));		if (pAd->bLocalAdminMAC == FALSE)		{			MAC_DW0_STRUC csr2;			MAC_DW1_STRUC csr3;			COPY_MAC_ADDR(pAd->CurrentAddress, pAd->PermanentAddress);			csr2.field.Byte0 = pAd->CurrentAddress[0];			csr2.field.Byte1 = pAd->CurrentAddress[1];			csr2.field.Byte2 = pAd->CurrentAddress[2];			csr2.field.Byte3 = pAd->CurrentAddress[3];			RTMP_IO_WRITE32(pAd, MAC_ADDR_DW0, csr2.word);			csr3.word = 0;			csr3.field.Byte4 = pAd->CurrentAddress[4];			csr3.field.Byte5 = pAd->CurrentAddress[5];			csr3.field.U2MeMask = 0xff;			RTMP_IO_WRITE32(pAd, MAC_ADDR_DW1, csr3.word);			DBGPRINT_RAW(RT_DEBUG_TRACE,("E2PROM MAC: =%02x:%02x:%02x:%02x:%02x:%02x\n",							PRINT_MAC(pAd->PermanentAddress)));		}	}   	// if not return early. cause fail at emulation.	// Init the channel number for TX channel power		RTMPReadChannelPwr(pAd);	// if E2PROM version mismatch with driver's expectation, then skip	// all subsequent E2RPOM retieval and set a system error bit to notify GUI	RT28xx_EEPROM_READ16(pAd, EEPROM_VERSION_OFFSET, Version.word);	pAd->EepromVersion = Version.field.Version + Version.field.FaeReleaseNumber * 256;	DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: Version = %d, FAE release #%d\n", Version.field.Version, Version.field.FaeReleaseNumber));	if (Version.field.Version > VALID_EEPROM_VERSION)	{		DBGPRINT_ERR(("E2PROM: WRONG VERSION 0x%x, should be %d\n",Version.field.Version, VALID_EEPROM_VERSION));		/*pAd->SystemErrorBitmap |= 0x00000001;		// hard-code default value when no proper E2PROM installed		pAd->bAutoTxAgcA = FALSE;		pAd->bAutoTxAgcG = FALSE;		// Default the channel power		for (i = 0; i < MAX_NUM_OF_CHANNELS; i++)			pAd->TxPower[i].Power = DEFAULT_RF_TX_POWER;		// Default the channel power		for (i = 0; i < MAX_NUM_OF_11JCHANNELS; i++)			pAd->TxPower11J[i].Power = DEFAULT_RF_TX_POWER;				for(i = 0; i < NUM_EEPROM_BBP_PARMS; i++)			pAd->EEPROMDefaultValue[i] = 0xffff;		return;  */	}	// Read BBP default value from EEPROM and store to array(EEPROMDefaultValue) in pAd	RT28xx_EEPROM_READ16(pAd, EEPROM_NIC1_OFFSET, value);	pAd->EEPROMDefaultValue[0] = value;	RT28xx_EEPROM_READ16(pAd, EEPROM_NIC2_OFFSET, value);	pAd->EEPROMDefaultValue[1] = value;	RT28xx_EEPROM_READ16(pAd, 0x38, value);	// Country Region	pAd->EEPROMDefaultValue[2] = value;	for(i = 0; i < 8; i++)	{		RT28xx_EEPROM_READ16(pAd, EEPROM_BBP_BASE_OFFSET + i*2, value);		pAd->EEPROMDefaultValue[i+3] = value;	}	// We have to parse NIC configuration 0 at here.	// If TSSI did not have preloaded value, it should reset the TxAutoAgc to false	// Therefore, we have to read TxAutoAgc control beforehand.	// Read Tx AGC control bit	Antenna.word = pAd->EEPROMDefaultValue[0];	if (Antenna.word == 0xFFFF)	{		{			Antenna.word = 0;			Antenna.field.RfIcType = RFIC_2820;			Antenna.field.TxPath = 1;			Antenna.field.RxPath = 2;			DBGPRINT(RT_DEBUG_WARN, ("E2PROM error, hard code as 0x%04x\n", Antenna.word));		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -