From 18a3a3309f0d8f96a56c734804fb4fe1132d6898 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Sat, 16 Apr 2011 11:59:37 +0000 Subject: [PATCH] Remove some duplicate code from the AR9285 TX power configuration path. --- sys/dev/ath/ath_hal/ar5416/ar5416.h | 2 + sys/dev/ath/ath_hal/ar5416/ar5416_reset.c | 4 +- sys/dev/ath/ath_hal/ar9002/ar9285_reset.c | 57 +---------------------- 3 files changed, 5 insertions(+), 58 deletions(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index e04e61841e74..5f9ed573f45f 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -246,6 +246,8 @@ extern void ar5416InitChainMasks(struct ath_hal *ah); extern void ar5416RestoreChainMask(struct ath_hal *ah); extern void ar5416EepromSetAddac(struct ath_hal *ah, const struct ieee80211_channel *chan); +extern uint16_t ar5416GetMaxEdgePower(uint16_t freq, + CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz); /* TX power setup related routines in ar5416_reset.c */ extern void ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah, diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c index c4ebec0ab64c..d220dc6877d6 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c @@ -61,8 +61,6 @@ static HAL_BOOL ar5416SetPowerPerRateTable(struct ath_hal *ah, uint16_t cfgCtl, uint16_t AntennaReduction, uint16_t twiceMaxRegulatoryPower, uint16_t powerLimit); -static uint16_t ar5416GetMaxEdgePower(uint16_t freq, - CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz); static void ar5416Set11nRegs(struct ath_hal *ah, const struct ieee80211_channel *chan); /* @@ -1779,7 +1777,7 @@ fbin2freq(uint8_t fbin, HAL_BOOL is2GHz) * * Find the maximum conformance test limit for the given channel and CTL info */ -static uint16_t +uint16_t ar5416GetMaxEdgePower(uint16_t freq, CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz) { uint16_t twiceMaxEdgePower = AR5416_MAX_RATE_POWER; diff --git a/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c b/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c index fd69de64b15a..1b1c10e76833 100644 --- a/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c +++ b/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c @@ -65,7 +65,6 @@ static void ar9285GetGainBoundariesAndPdadcs(struct ath_hal *ah, uint16_t tPdGainOverlap, int16_t *pMinCalPower, uint16_t * pPdGainBoundaries, uint8_t * pPDADCValues, uint16_t numXpdGains); -static uint16_t ar9285GetMaxEdgePower(uint16_t, CAL_CTL_EDGES *); HAL_BOOL ar9285SetTransmitPower(struct ath_hal *ah, @@ -558,9 +557,9 @@ ar9285SetPowerPerRateTable(struct ath_hal *ah, struct ar5416eeprom_4k *pEepData, (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) { rep = &(pEepData->ctlData[i]); - twiceMinEdgePower = ar9285GetMaxEdgePower(freq, + twiceMinEdgePower = ar5416GetMaxEdgePower(freq, rep->ctlEdges[ - owl_get_ntxchains(AH5416(ah)->ah_tx_chainmask) - 1]); + owl_get_ntxchains(AH5416(ah)->ah_tx_chainmask) - 1], AH_TRUE); if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) { /* Find the minimum of all CTL edge powers that apply to this channel */ twiceMaxEdgePower = AH_MIN(twiceMaxEdgePower, twiceMinEdgePower); @@ -643,58 +642,6 @@ ar9285SetPowerPerRateTable(struct ath_hal *ah, struct ar5416eeprom_4k *pEepData, #undef N } -/************************************************************************** - * fbin2freq - * - * Get channel value from binary representation held in eeprom - * RETURNS: the frequency in MHz - */ -static uint16_t -fbin2freq(uint8_t fbin) -{ - /* - * Reserved value 0xFF provides an empty definition both as - * an fbin and as a frequency - do not convert - */ - if (fbin == AR5416_BCHAN_UNUSED) { - return fbin; - } - - return (uint16_t)(2300 + fbin); -} - -/* - * XXX almost the same as ar5416GetMaxEdgePower. - */ -static uint16_t -ar9285GetMaxEdgePower(uint16_t freq, CAL_CTL_EDGES *pRdEdgesPower) -{ - uint16_t twiceMaxEdgePower = AR5416_MAX_RATE_POWER; - int i; - - /* Get the edge power */ - for (i = 0; (i < AR5416_NUM_BAND_EDGES) && (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED) ; i++) { - /* - * If there's an exact channel match or an inband flag set - * on the lower channel use the given rdEdgePower - */ - if (freq == fbin2freq(pRdEdgesPower[i].bChannel)) { - twiceMaxEdgePower = MS(pRdEdgesPower[i].tPowerFlag, CAL_CTL_EDGES_POWER); - break; - } else if ((i > 0) && (freq < fbin2freq(pRdEdgesPower[i].bChannel))) { - if (fbin2freq(pRdEdgesPower[i - 1].bChannel) < freq && (pRdEdgesPower[i - 1].tPowerFlag & CAL_CTL_EDGES_FLAG) != 0) { - twiceMaxEdgePower = MS(pRdEdgesPower[i - 1].tPowerFlag, CAL_CTL_EDGES_POWER); - } - /* Leave loop - no more affecting edges possible in this monotonic increasing list */ - break; - } - } - HALASSERT(twiceMaxEdgePower > 0); - return twiceMaxEdgePower; -} - - - static HAL_BOOL ar9285SetPowerCalTable(struct ath_hal *ah, struct ar5416eeprom_4k *pEepData, const struct ieee80211_channel *chan, int16_t *pTxPowerIndexOffset)