From addc81bd428f9eb29ed2ab64ad4039c6aed55aea Mon Sep 17 00:00:00 2001 From: Ivo van Doorn Date: Sat, 13 Oct 2007 16:26:23 +0200 Subject: [PATCH] rt2x00: Correctly translate mac80211 antenna setup to rt2x00 mac80211 has 3 values for the antenna setup: 0 - default 1 - use antenna 1 2 - use antenna 2 This means that rt2x00 should store the default value from the EEPROM somwhere and use that when mac80211 indicates that the antenna setup is 0. This also implies that rt2x00 should no longer write the hw->config.antenna_sel_* values based on the EEPROM input. This also adds the basis in rt2x00lib for correct software diversity handling. By default rt2x00lib will now configure antenna B instead of hardware diversity. Signed-off-by: Ivo van Doorn Signed-off-by: John W. Linville Signed-off-by: David S. Miller --- drivers/net/wireless/rt2x00/rt2x00config.c | 51 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless/rt2x00/rt2x00config.c') diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index 12914cf7156c..04518b089bdb 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c @@ -100,6 +100,8 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_conf libconf; struct ieee80211_hw_mode *mode; struct ieee80211_rate *rate; + struct antenna_setup *default_ant = &rt2x00dev->default_ant; + struct antenna_setup *active_ant = &rt2x00dev->link.active_ant; int flags = 0; int short_slot_time; @@ -122,7 +124,35 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, flags |= CONFIG_UPDATE_CHANNEL; if (rt2x00dev->tx_power != conf->power_level) flags |= CONFIG_UPDATE_TXPOWER; - if (rt2x00dev->rx_status.antenna == conf->antenna_sel_rx) + + /* + * Determining changes in the antenna setups request several checks: + * antenna_sel_{r,t}x = 0 + * -> Does active_{r,t}x match default_{r,t}x + * -> Is default_{r,t}x SW_DIVERSITY + * antenna_sel_{r,t}x = 1/2 + * -> Does active_{r,t}x match antenna_sel_{r,t}x + * The reason for not updating the antenna while SW diversity + * should be used is simple: Software diversity means that + * we should switch between the antenna's based on the + * quality. This means that the current antenna is good enough + * to work with untill the link tuner decides that an antenna + * switch should be performed. + */ + if (!conf->antenna_sel_rx && + default_ant->rx != ANTENNA_SW_DIVERSITY && + default_ant->rx != active_ant->rx) + flags |= CONFIG_UPDATE_ANTENNA; + else if (conf->antenna_sel_rx && + conf->antenna_sel_rx != active_ant->rx) + flags |= CONFIG_UPDATE_ANTENNA; + + if (!conf->antenna_sel_tx && + default_ant->tx != ANTENNA_SW_DIVERSITY && + default_ant->tx != active_ant->tx) + flags |= CONFIG_UPDATE_ANTENNA; + else if (conf->antenna_sel_tx && + conf->antenna_sel_tx != active_ant->tx) flags |= CONFIG_UPDATE_ANTENNA; /* @@ -171,6 +201,22 @@ config: sizeof(libconf.rf)); } + if (flags & CONFIG_UPDATE_ANTENNA) { + if (conf->antenna_sel_rx) + libconf.ant.rx = conf->antenna_sel_rx; + else if (default_ant->rx != ANTENNA_SW_DIVERSITY) + libconf.ant.rx = default_ant->rx; + else if (active_ant->rx == ANTENNA_SW_DIVERSITY) + libconf.ant.rx = ANTENNA_B; + + if (conf->antenna_sel_tx) + libconf.ant.tx = conf->antenna_sel_tx; + else if (default_ant->tx != ANTENNA_SW_DIVERSITY) + libconf.ant.tx = default_ant->tx; + else if (active_ant->tx == ANTENNA_SW_DIVERSITY) + libconf.ant.tx = ANTENNA_B; + } + if (flags & CONFIG_UPDATE_SLOT_TIME) { short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME; @@ -201,5 +247,6 @@ config: rt2x00dev->rx_status.freq = conf->freq; rt2x00dev->rx_status.channel = conf->channel; rt2x00dev->tx_power = conf->power_level; - rt2x00dev->rx_status.antenna = conf->antenna_sel_rx; + rt2x00dev->link.active_ant.rx = libconf.ant.rx; + rt2x00dev->link.active_ant.tx = libconf.ant.tx; } -- cgit v1.2.3