2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
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.
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.
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.
23 Abstract: rt2x00 generic configuration routines.
27 * Set enviroment defines for rt2x00.h
29 #define DRV_NAME "rt2x00lib"
31 #include <linux/kernel.h>
32 #include <linux/module.h>
35 #include "rt2x00lib.h"
37 void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac)
40 rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, mac);
43 void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
46 rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid);
49 void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
51 struct interface *intf = &rt2x00dev->interface;
53 if (!test_bit(INTERFACE_RESUME, &rt2x00dev->flags) &&
54 (!!test_bit(INTERFACE_ENABLED, &rt2x00dev->flags) ==
55 !!is_interface_present(intf)))
58 rt2x00dev->ops->lib->config_type(rt2x00dev, type);
61 * Update the configuration flags.
63 if (is_interface_present(intf))
64 __set_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
66 __clear_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
69 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf)
74 * If we are in RESUME state we should
75 * force all configuration options.
77 if (test_bit(INTERFACE_RESUME, &rt2x00dev->flags)) {
78 flags = CONFIG_UPDATE_ALL;
83 * Check which configuration options have been
84 * updated and should be send to the device.
86 if (rt2x00dev->rx_status.phymode != conf->phymode)
87 flags |= CONFIG_UPDATE_PHYMODE;
88 if (rt2x00dev->rx_status.channel != conf->channel)
89 flags |= CONFIG_UPDATE_CHANNEL;
90 if (rt2x00dev->tx_power != conf->power_level)
91 flags |= CONFIG_UPDATE_TXPOWER;
92 if (rt2x00dev->rx_status.antenna == conf->antenna_sel_rx)
93 flags |= CONFIG_UPDATE_ANTENNA;
96 * The following configuration options are never
97 * stored anywhere and will always be updated.
99 flags |= CONFIG_UPDATE_SLOT_TIME;
100 flags |= CONFIG_UPDATE_BEACON_INT;
103 rt2x00dev->ops->lib->config(rt2x00dev, flags, conf);
106 * Some configuration changes affect the link quality
107 * which means we need to reset the link tuner.
109 if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA))
110 rt2x00lib_reset_link_tuner(rt2x00dev);
112 rt2x00dev->rx_status.phymode = conf->phymode;
113 rt2x00dev->rx_status.freq = conf->freq;
114 rt2x00dev->rx_status.channel = conf->channel;
115 rt2x00dev->tx_power = conf->power_level;
116 rt2x00dev->rx_status.antenna = conf->antenna_sel_rx;