VoodooIntel3945.cpp
/*
 * Determine Tx power index for a given channel/rate combination.
 * This takes into account the regulatory information from EEPROM and the
 * current temperature.
 */
Determine Tx power index for a given channel/rate combination.
This takes into account the regulatory information from EEPROM and the
current temperature.
Determine Tx power index for a given channel / rate combination . This takes into account the regulatory information from EEPROM and the current temperature .
int MyClass::getPowerIndex
( wpi_power_group* group, IEEE::Channel c, int rate)
{	
	wpi_power_sample* sample;
	int pwr, idx;
	u_int chan;
	chan = c.number;
	pwr = group->maxpwr / 2;
	switch (rate) {
		case 72:	
			pwr -= (c.flags & IEEE::Channel::band2GHz) ? 0 :  5;
			break;
		case 96:	
			pwr -= (c.flags & IEEE::Channel::band2GHz) ? 7 : 10;
			break;
		case 108:	
			pwr -= (c.flags & IEEE::Channel::band2GHz) ? 9 : 12;
			break;
	}
	pwr = min(pwr, m_MaxPower[chan]);
	for (sample = group->samples; sample < &group->samples[3]; sample++)
		if (pwr > sample[1].power)
			break;
	idx = interpolate(pwr, sample[0].power, sample[0].index, sample[1].power, sample[1].index, 19);
	idx -= (m_Temperature - group->temp) * 11 / 100;
	if (!WPI_RATE_IS_OFDM(rate))
		idx += 10;
	if (idx < 0)
		return 0;
	if (idx > WPI_MAX_PWR_INDEX)
		return WPI_MAX_PWR_INDEX;
	return idx;
}
int MyClass :: getPowerIndex ( wpi_power_group * group , IEEE :: Channel c , int rate ) { wpi_power_sample * sample ; int pwr , idx ; u_int chan ; chan = c . number ; pwr = group -> maxpwr / 2 ; switch ( rate ) { case 72 : pwr -= ( c . flags & IEEE :: Channel :: band2GHz ) ? 0 : 5 ; break ; case 96 : pwr -= ( c . flags & IEEE :: Channel :: band2GHz ) ? 7 : 10 ; break ; case 108 : pwr -= ( c . flags & IEEE :: Channel :: band2GHz ) ? 9 : 12 ; break ; } pwr = min ( pwr , m_MaxPower [ chan ] ) ; for ( sample = group -> samples ; sample < & group -> samples [ 3 ] ; sample ++ ) if ( pwr > sample [ 1 ] . power ) break ; idx = interpolate ( pwr , sample [ 0 ] . power , sample [ 0 ] . index , sample [ 1 ] . power , sample [ 1 ] . index , 19 ) ; idx -= ( m_Temperature - group -> temp ) * 11 / 100 ; if ( ! WPI_RATE_IS_OFDM ( rate ) ) idx += 10 ; if ( idx < 0 ) return 0 ; if ( idx > WPI_MAX_PWR_INDEX ) return WPI_MAX_PWR_INDEX ; return idx ; }
Determine Tx power index for a given channel/rate combination.
Determine Tx power index for a given channel / rate combination .
/* get channel number */ /* default power is group's maximum power - 3dB */ /* decrease power for highest OFDM rates to reduce distortion */ /* 36Mb/s */ /* 48Mb/s */ /* 54Mb/s */ /* never exceed channel's maximum allowed Tx power */ /* retrieve power index into gain tables from samples */ /* fixed-point linear interpolation using a 19-bit fractional part */ /*
	 *  Adjust power index based on current temperature
	 *	- if colder than factory-calibrated: decreate output power
	 *	- if warmer than factory-calibrated: increase output power
	 */ /* decrease power for CCK rates (-5dB) */ /* keep power index in a valid range */