Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jan 2009 20:00:58 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r187234 - in user/sam/wifi/sys/dev/ath/ath_hal: ar5211 ar5212
Message-ID:  <200901142000.n0EK0wEW052407@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901142000.n0EK0wEW052407>