Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2004 - 2007 rt2x00 SourceForge Project |
| 3 | <http://rt2x00.serialmonkey.com> |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the |
| 17 | Free Software Foundation, Inc., |
| 18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | Module: rt2x00lib |
| 23 | Abstract: rt2x00 generic configuration routines. |
| 24 | */ |
| 25 | |
| 26 | /* |
| 27 | * Set enviroment defines for rt2x00.h |
| 28 | */ |
| 29 | #define DRV_NAME "rt2x00lib" |
| 30 | |
| 31 | #include <linux/kernel.h> |
| 32 | #include <linux/module.h> |
| 33 | |
| 34 | #include "rt2x00.h" |
| 35 | #include "rt2x00lib.h" |
| 36 | |
| 37 | void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac) |
| 38 | { |
| 39 | if (mac) |
| 40 | rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, mac); |
| 41 | } |
| 42 | |
| 43 | void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid) |
| 44 | { |
| 45 | if (bssid) |
| 46 | rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid); |
| 47 | } |
| 48 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 49 | void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type) |
| 50 | { |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame^] | 51 | if (type != INVALID_INTERFACE) |
| 52 | rt2x00dev->ops->lib->config_type(rt2x00dev, type); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame^] | 55 | void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, |
| 56 | struct ieee80211_conf *conf, const int force_config) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 57 | { |
| 58 | int flags = 0; |
| 59 | |
| 60 | /* |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame^] | 61 | * In some situations we want to force all configurations |
| 62 | * to be reloaded (When resuming for instance). |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 63 | */ |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame^] | 64 | if (force_config) { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 65 | flags = CONFIG_UPDATE_ALL; |
| 66 | goto config; |
| 67 | } |
| 68 | |
| 69 | /* |
| 70 | * Check which configuration options have been |
| 71 | * updated and should be send to the device. |
| 72 | */ |
| 73 | if (rt2x00dev->rx_status.phymode != conf->phymode) |
| 74 | flags |= CONFIG_UPDATE_PHYMODE; |
| 75 | if (rt2x00dev->rx_status.channel != conf->channel) |
| 76 | flags |= CONFIG_UPDATE_CHANNEL; |
| 77 | if (rt2x00dev->tx_power != conf->power_level) |
| 78 | flags |= CONFIG_UPDATE_TXPOWER; |
| 79 | if (rt2x00dev->rx_status.antenna == conf->antenna_sel_rx) |
| 80 | flags |= CONFIG_UPDATE_ANTENNA; |
| 81 | |
| 82 | /* |
| 83 | * The following configuration options are never |
| 84 | * stored anywhere and will always be updated. |
| 85 | */ |
| 86 | flags |= CONFIG_UPDATE_SLOT_TIME; |
| 87 | flags |= CONFIG_UPDATE_BEACON_INT; |
| 88 | |
| 89 | config: |
| 90 | rt2x00dev->ops->lib->config(rt2x00dev, flags, conf); |
| 91 | |
| 92 | /* |
| 93 | * Some configuration changes affect the link quality |
| 94 | * which means we need to reset the link tuner. |
| 95 | */ |
| 96 | if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA)) |
| 97 | rt2x00lib_reset_link_tuner(rt2x00dev); |
| 98 | |
| 99 | rt2x00dev->rx_status.phymode = conf->phymode; |
| 100 | rt2x00dev->rx_status.freq = conf->freq; |
| 101 | rt2x00dev->rx_status.channel = conf->channel; |
| 102 | rt2x00dev->tx_power = conf->power_level; |
| 103 | rt2x00dev->rx_status.antenna = conf->antenna_sel_rx; |
| 104 | } |