linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rt2x00: Provide regulatory hint with rt2500pci/usb
@ 2009-01-04 19:21 Ivo van Doorn
  2009-01-05 20:08 ` Luis R. Rodriguez
  0 siblings, 1 reply; 23+ messages in thread
From: Ivo van Doorn @ 2009-01-04 19:21 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, rt2400-devel

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);

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-01-13 22:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-04 19:21 [PATCH] rt2x00: Provide regulatory hint with rt2500pci/usb Ivo van Doorn
2009-01-05 20:08 ` 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

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).