From: Ivo van Doorn <ivdoorn@gmail.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: linux-wireless@vger.kernel.org, rt2400-devel@lists.sourceforge.net
Subject: [PATCH] rt2x00: Provide regulatory hint with rt2500pci/usb
Date: Sun, 4 Jan 2009 20:21:10 +0100 [thread overview]
Message-ID: <200901042021.10904.IvDoorn@gmail.com> (raw)
rt2500pci and rt2500usb contain a special field in the EEPROM
which indicates which regulatory domain the card belongs to.
This code can easily be translated into a country code which
we can send as alpha2 hint for CRDA.
Please note that most cards will have 0xffff as EEPROM value,
and thus do not provide a regulatory hint through the EEPROM.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
---
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 76f016d..98d3c6c 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1512,6 +1512,17 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
return 0;
}
+static const char* reg_domain_map[] = {
+ "US", /* REGION_FCC: 1-11 */
+ "CA", /* REGION_IC: 1-11 */
+ "DE", /* REGION_ETSI: 1-13 */
+ "ES", /* REGION_SPAIN: 10-11 */
+ "FR", /* REGION_FRANCE: 10-13 */
+ "JP", /* REGION_MKK: 14 */
+ "JP", /* REGION_MKK1: 1-14 */
+ "IL", /* REGION_ISRAEL: 3-9 */
+};
+
static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
u32 reg;
@@ -1577,6 +1588,16 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
__set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
/*
+ * Read Geography information, if it contains valid data we should
+ * send the regulatory hint as alpha2 value to cfg80211.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_GEOGRAPHY, &eeprom);
+ if (eeprom != 0xffff) {
+ value = rt2x00_get_field16(eeprom, EEPROM_GEOGRAPHY_GEO);
+ regulatory_hint(rt2x00dev->hw->wiphy, reg_domain_map[value]);
+ }
+
+ /*
* Read the RSSI <-> dBm offset information.
*/
rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 2bc4e46..7f364dd 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1546,6 +1546,17 @@ static int rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
return 0;
}
+static const char* reg_domain_map[] = {
+ "US", /* REGION_FCC: 1-11 */
+ "CA", /* REGION_IC: 1-11 */
+ "DE", /* REGION_ETSI: 1-13 */
+ "ES", /* REGION_SPAIN: 10-11 */
+ "FR", /* REGION_FRANCE: 10-13 */
+ "JP", /* REGION_MKK: 14 */
+ "JP", /* REGION_MKK1: 1-14 */
+ "IL", /* REGION_ISRAEL: 3-9 */
+};
+
static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
{
u16 reg;
@@ -1626,6 +1637,16 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
__set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
/*
+ * Read Geography information, if it contains valid data we should
+ * send the regulatory hint as alpha2 value to cfg80211.
+ */
+ rt2x00_eeprom_read(rt2x00dev, EEPROM_GEOGRAPHY, &eeprom);
+ if (eeprom != 0xffff) {
+ value = rt2x00_get_field16(eeprom, EEPROM_GEOGRAPHY_GEO);
+ regulatory_hint(rt2x00dev->hw->wiphy, reg_domain_map[value]);
+ }
+
+ /*
* Read the RSSI <-> dBm offset information.
*/
rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
next reply other threads:[~2009-01-04 19:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 19:21 Ivo van Doorn [this message]
2009-01-05 20:08 ` [PATCH] rt2x00: Provide regulatory hint with rt2500pci/usb Luis R. Rodriguez
2009-01-05 21:29 ` Gertjan van Wingerde
2009-01-05 22:21 ` Ivo van Doorn
2009-01-05 23:45 ` Luis R. Rodriguez
2009-01-06 17:32 ` Ivo van Doorn
2009-01-06 17:36 ` Luis R. Rodriguez
2009-01-06 17:47 ` Ivo van Doorn
2009-01-06 20:39 ` Gertjan van Wingerde
2009-01-06 20:49 ` Luis R. Rodriguez
2009-01-06 21:51 ` Ivo van Doorn
2009-01-06 22:11 ` Gertjan van Wingerde
2009-01-13 22:07 ` Luis R. Rodriguez
2009-01-06 20:32 ` Gertjan van Wingerde
2009-01-06 20:47 ` Luis R. Rodriguez
2009-01-06 22:15 ` Gertjan van Wingerde
2009-01-06 22:23 ` Luis R. Rodriguez
2009-01-06 22:50 ` Gertjan van Wingerde
2009-01-06 20:17 ` Gertjan van Wingerde
2009-01-06 21:52 ` Ivo van Doorn
2009-01-06 22:06 ` Gertjan van Wingerde
2009-01-06 22:12 ` Ivo van Doorn
2009-01-06 22:17 ` Luis R. Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200901042021.10904.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=rt2400-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).