sys/dev/netif/ath/hal/ath_hal/ar5416/ar5416_reset.c
void
ar5416GetTargetPowersLeg(struct ath_hal *ah, 
                         const struct ieee80211_channel *chan,
                         CAL_TARGET_POWER_LEG *powInfo, uint16_t numChannels,
                         CAL_TARGET_POWER_LEG *pNewPower, uint16_t numRates,
			 HAL_BOOL isExtTarget)
{
    uint16_t clo, chi;
    int i;
    int matchIndex = -1, lowIndex = -1;
    uint16_t freq;
    CHAN_CENTERS centers;

    ar5416GetChannelCenters(ah,  chan, &centers);
    freq = (isExtTarget) ? centers.ext_center :centers.ctl_center;

    /* Copy the target powers into the temp channel list */
    if (freq <= fbin2freq(powInfo[0].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) {
        matchIndex = 0;
    } else {
        for (i = 0; (i < numChannels) && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
            if (freq == fbin2freq(powInfo[i].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) {
                matchIndex = i;
                break;
            } else if ((freq < fbin2freq(powInfo[i].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) &&
                       (freq > fbin2freq(powInfo[i - 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))))
            {
                lowIndex = i - 1;
                break;
            }
        }
        if ((matchIndex == -1) && (lowIndex == -1)) {
            HALASSERT(freq > fbin2freq(powInfo[i - 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan)));
            matchIndex = i - 1;
        }
    }

    if (matchIndex != -1) {
        OS_MEMCPY(pNewPower, &powInfo[matchIndex], sizeof(*pNewPower));
    } else {
        HALASSERT(lowIndex != -1);
        /*
         * Get the lower and upper channels, target powers,
         * and interpolate between them.
         */
        clo = fbin2freq(powInfo[lowIndex].bChannel, IEEE80211_IS_CHAN_2GHZ(chan));
        chi = fbin2freq(powInfo[lowIndex + 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan));

        for (i = 0; i < numRates; i++) {
            pNewPower->tPow2x[i] = (uint8_t)interpolate(freq, clo, chi,
                                   powInfo[lowIndex].tPow2x[i], powInfo[lowIndex + 1].tPow2x[i]);
        }
    }
}
/**************************************************************
 * ar5416GetTargetPowersLeg
 *
 * Return the four rates of target power for the given target power table
 * channel, and number of channels
 */
ar5416GetTargetPowersLeg
Return the four rates of target power for the given target power table
channel, and number of channels
ar5416GetTargetPowersLeg Return the four rates of target power for the given target power table channel and number of channels
void
ar5416GetTargetPowersLeg(struct ath_hal *ah, 
                         const struct ieee80211_channel *chan,
                         CAL_TARGET_POWER_LEG *powInfo, uint16_t numChannels,
                         CAL_TARGET_POWER_LEG *pNewPower, uint16_t numRates,
			 HAL_BOOL isExtTarget)
{
    uint16_t clo, chi;
    int i;
    int matchIndex = -1, lowIndex = -1;
    uint16_t freq;
    CHAN_CENTERS centers;
    ar5416GetChannelCenters(ah,  chan, &centers);
    freq = (isExtTarget) ? centers.ext_center :centers.ctl_center;
    if (freq <= fbin2freq(powInfo[0].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) {
        matchIndex = 0;
    } else {
        for (i = 0; (i < numChannels) && (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
            if (freq == fbin2freq(powInfo[i].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) {
                matchIndex = i;
                break;
            } else if ((freq < fbin2freq(powInfo[i].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))) &&
                       (freq > fbin2freq(powInfo[i - 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan))))
            {
                lowIndex = i - 1;
                break;
            }
        }
        if ((matchIndex == -1) && (lowIndex == -1)) {
            HALASSERT(freq > fbin2freq(powInfo[i - 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan)));
            matchIndex = i - 1;
        }
    }
    if (matchIndex != -1) {
        OS_MEMCPY(pNewPower, &powInfo[matchIndex], sizeof(*pNewPower));
    } else {
        HALASSERT(lowIndex != -1);
        clo = fbin2freq(powInfo[lowIndex].bChannel, IEEE80211_IS_CHAN_2GHZ(chan));
        chi = fbin2freq(powInfo[lowIndex + 1].bChannel, IEEE80211_IS_CHAN_2GHZ(chan));
        for (i = 0; i < numRates; i++) {
            pNewPower->tPow2x[i] = (uint8_t)interpolate(freq, clo, chi,
                                   powInfo[lowIndex].tPow2x[i], powInfo[lowIndex + 1].tPow2x[i]);
        }
    }
}
void ar5416GetTargetPowersLeg ( struct ath_hal * ah , const struct ieee80211_channel * chan , CAL_TARGET_POWER_LEG * powInfo , uint16_t numChannels , CAL_TARGET_POWER_LEG * pNewPower , uint16_t numRates , HAL_BOOL isExtTarget ) { uint16_t clo , chi ; int i ; int matchIndex = -1 , lowIndex = -1 ; uint16_t freq ; CHAN_CENTERS centers ; ar5416GetChannelCenters ( ah , chan , & centers ) ; freq = ( isExtTarget ) ? centers . ext_center : centers . ctl_center ; if ( freq <= fbin2freq ( powInfo [ 0 ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ) { matchIndex = 0 ; } else { for ( i = 0 ; ( i < numChannels ) && ( powInfo [ i ] . bChannel != AR5416_BCHAN_UNUSED ) ; i ++ ) { if ( freq == fbin2freq ( powInfo [ i ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ) { matchIndex = i ; break ; } else if ( ( freq < fbin2freq ( powInfo [ i ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ) && ( freq > fbin2freq ( powInfo [ i - 1 ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ) ) { lowIndex = i - 1 ; break ; } } if ( ( matchIndex == -1 ) && ( lowIndex == -1 ) ) { HALASSERT ( freq > fbin2freq ( powInfo [ i - 1 ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ) ; matchIndex = i - 1 ; } } if ( matchIndex != -1 ) { OS_MEMCPY ( pNewPower , & powInfo [ matchIndex ] , sizeof ( * pNewPower ) ) ; } else { HALASSERT ( lowIndex != -1 ) ; clo = fbin2freq ( powInfo [ lowIndex ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ; chi = fbin2freq ( powInfo [ lowIndex + 1 ] . bChannel , IEEE80211_IS_CHAN_2GHZ ( chan ) ) ; for ( i = 0 ; i < numRates ; i ++ ) { pNewPower -> tPow2x [ i ] = ( uint8_t ) interpolate ( freq , clo , chi , powInfo [ lowIndex ] . tPow2x [ i ] , powInfo [ lowIndex + 1 ] . tPow2x [ i ] ) ; } } }
ar5416GetTargetPowersLeg
 Return the four rates of target power for the given target power table
 channel, and number of channels
ar5416GetTargetPowersLeg Return the four rates of target power for the given target power table channel and number of channels
/* Copy the target powers into the temp channel list */ /*
         * Get the lower and upper channels, target powers,
         * and interpolate between them.
         */