From owner-svn-src-user@FreeBSD.ORG Wed Jan 14 20:00:59 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0ABAD106564A; Wed, 14 Jan 2009 20:00:59 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EAD748FC16; Wed, 14 Jan 2009 20:00:58 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0EK0wWU052409; Wed, 14 Jan 2009 20:00:58 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0EK0wEW052407; Wed, 14 Jan 2009 20:00:58 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200901142000.n0EK0wEW052407@svn.freebsd.org> From: Sam Leffler Date: Wed, 14 Jan 2009 20:00:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187234 - in user/sam/wifi/sys/dev/ath/ath_hal: ar5211 ar5212 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2009 20:00:59 -0000 Author: sam Date: Wed Jan 14 20:00:58 2009 New Revision: 187234 URL: http://svn.freebsd.org/changeset/base/187234 Log: oops, forgot about 5111 usage of ath_hal_mhz2ieee; add private versions of this code stripped down to meet local needs Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c Wed Jan 14 19:43:28 2009 (r187233) +++ user/sam/wifi/sys/dev/ath/ath_hal/ar5211/ar5211_reset.c Wed Jan 14 20:00:58 2009 (r187234) @@ -803,6 +803,38 @@ ar5211SetResetReg(struct ath_hal *ah, ui return rt; } +static __inline int +mappsb(u_int freq, u_int flags) +{ + return ((freq * 10) + (((freq % 5) == 2) ? 5 : 0) - 49400) / 5; +} + +/* + * Convert MHz frequency to IEEE channel number. + */ +static int +mhz2ieee(u_int freq, u_int flags) +{ + HALASSERT((flags & (CHANNEL_2GHZ|CHANNEL_5GHZ)) != 0); + + if (flags & CHANNEL_2GHZ) { + if (freq == 2484) { + return 14; + } else if (freq < 2484) { + return ((int)freq - 2407) / 5; + } else + return 15 + ((freq - 2512) / 20); + } else { + if (IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) { + return mappsb(freq, flags); + } else if ((flags & CHANNEL_A) && freq <= 5000) { + return (freq - 4000) / 5; + } else { + return (freq - 5000) / 5; + } + } +} + /* * Takes the MHz channel value and sets the Channel value * @@ -815,7 +847,7 @@ ar5211SetChannel(struct ath_hal *ah, HA uint32_t refClk, reg32, data2111; int16_t chan5111, chanIEEE; - chanIEEE = ath_hal_mhz2ieee(ah, chan->channel, chan->channelFlags); + chanIEEE = mhz2ieee(chan->channel, chan->channelFlags); if (IS_CHAN_2GHZ(chan)) { const CHAN_INFO_2GHZ* ci = &chan2GHzData[chanIEEE + CI_2GHZ_INDEX_CORRECTION]; Modified: user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c Wed Jan 14 19:43:28 2009 (r187233) +++ user/sam/wifi/sys/dev/ath/ath_hal/ar5212/ar5111.c Wed Jan 14 20:00:58 2009 (r187234) @@ -68,6 +68,38 @@ ar5111WriteRegs(struct ath_hal *ah, u_in HAL_INI_WRITE_ARRAY(ah, ar5212BB_RfGain_5111, freqIndex, writes); } +static __inline int +mappsb(u_int freq, u_int flags) +{ + return ((freq * 10) + (((freq % 5) == 2) ? 5 : 0) - 49400) / 5; +} + +/* + * Convert MHz frequency to IEEE channel number. + */ +static int +mhz2ieee(u_int freq, u_int flags) +{ + HALASSERT((flags & (CHANNEL_2GHZ|CHANNEL_5GHZ)) != 0); + + if (flags & CHANNEL_2GHZ) { + if (freq == 2484) { + return 14; + } else if (freq < 2484) { + return ((int)freq - 2407) / 5; + } else + return 15 + ((freq - 2512) / 20); + } else { + if (IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) { + return mappsb(freq, flags); + } else if ((flags & CHANNEL_A) && freq <= 5000) { + return (freq - 4000) / 5; + } else { + return (freq - 5000) / 5; + } + } +} + /* * Take the MHz channel value and set the Channel value * @@ -142,7 +174,7 @@ ar5111SetChannel(struct ath_hal *ah, HA OS_MARK(ah, AH_MARK_SETCHANNEL, chan->channel); - chanIEEE = ath_hal_mhz2ieee(ah, chan->channel, chan->channelFlags); + chanIEEE = mhz2ieee(chan->channel, chan->channelFlags); if (IS_CHAN_2GHZ(chan)) { const CHAN_INFO_2GHZ* ci = &chan2GHzData[chanIEEE + CI_2GHZ_INDEX_CORRECTION];