From owner-svn-src-all@FreeBSD.ORG Sat Apr 16 11:59:37 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9C31E106566C; Sat, 16 Apr 2011 11:59:37 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A8398FC0C; Sat, 16 Apr 2011 11:59:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3GBxbKi004051; Sat, 16 Apr 2011 11:59:37 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3GBxbDH004047; Sat, 16 Apr 2011 11:59:37 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104161159.p3GBxbDH004047@svn.freebsd.org> From: Adrian Chadd Date: Sat, 16 Apr 2011 11:59:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220713 - in head/sys/dev/ath/ath_hal: ar5416 ar9002 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Apr 2011 11:59:37 -0000 Author: adrian Date: Sat Apr 16 11:59:37 2011 New Revision: 220713 URL: http://svn.freebsd.org/changeset/base/220713 Log: Remove some duplicate code from the AR9285 TX power configuration path. Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat Apr 16 11:15:57 2011 (r220712) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416.h Sat Apr 16 11:59:37 2011 (r220713) @@ -246,6 +246,8 @@ extern void ar5416InitChainMasks(struct 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, Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sat Apr 16 11:15:57 2011 (r220712) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c Sat Apr 16 11:59:37 2011 (r220713) @@ -61,8 +61,6 @@ static HAL_BOOL ar5416SetPowerPerRateTab 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; Modified: head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Sat Apr 16 11:15:57 2011 (r220712) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_reset.c Sat Apr 16 11:59:37 2011 (r220713) @@ -65,7 +65,6 @@ static void ar9285GetGainBoundariesAndPd 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_ha (((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_ha #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)