rt2x00: Implement Powersaving
Listen to IEEE80211_CONF_PS to determine if the device should drop into powersaving mode. This feature depends on the dynamic power save functionality in mac80211. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
3ebbbb56a1
commit
7d7f19ccb7
@@ -844,6 +844,44 @@ static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
|
||||
rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
|
||||
}
|
||||
|
||||
static void rt73usb_config_ps(struct rt2x00_dev *rt2x00dev,
|
||||
struct rt2x00lib_conf *libconf)
|
||||
{
|
||||
enum dev_state state =
|
||||
(libconf->conf->flags & IEEE80211_CONF_PS) ?
|
||||
STATE_SLEEP : STATE_AWAKE;
|
||||
u32 reg;
|
||||
|
||||
if (state == STATE_SLEEP) {
|
||||
rt2x00usb_register_read(rt2x00dev, MAC_CSR11, ®);
|
||||
rt2x00_set_field32(®, MAC_CSR11_DELAY_AFTER_TBCN,
|
||||
libconf->conf->beacon_int - 10);
|
||||
rt2x00_set_field32(®, MAC_CSR11_TBCN_BEFORE_WAKEUP,
|
||||
libconf->conf->listen_interval - 1);
|
||||
rt2x00_set_field32(®, MAC_CSR11_WAKEUP_LATENCY, 5);
|
||||
|
||||
/* We must first disable autowake before it can be enabled */
|
||||
rt2x00_set_field32(®, MAC_CSR11_AUTOWAKE, 0);
|
||||
rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
|
||||
|
||||
rt2x00_set_field32(®, MAC_CSR11_AUTOWAKE, 1);
|
||||
rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
|
||||
|
||||
rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
|
||||
USB_MODE_SLEEP, REGISTER_TIMEOUT);
|
||||
} else {
|
||||
rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
|
||||
USB_MODE_WAKEUP, REGISTER_TIMEOUT);
|
||||
|
||||
rt2x00usb_register_read(rt2x00dev, MAC_CSR11, ®);
|
||||
rt2x00_set_field32(®, MAC_CSR11_DELAY_AFTER_TBCN, 0);
|
||||
rt2x00_set_field32(®, MAC_CSR11_TBCN_BEFORE_WAKEUP, 0);
|
||||
rt2x00_set_field32(®, MAC_CSR11_AUTOWAKE, 0);
|
||||
rt2x00_set_field32(®, MAC_CSR11_WAKEUP_LATENCY, 0);
|
||||
rt2x00usb_register_write(rt2x00dev, MAC_CSR11, reg);
|
||||
}
|
||||
}
|
||||
|
||||
static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
|
||||
struct rt2x00lib_conf *libconf,
|
||||
const unsigned int flags)
|
||||
@@ -861,6 +899,8 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
|
||||
rt73usb_config_retry_limit(rt2x00dev, libconf);
|
||||
if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
|
||||
rt73usb_config_duration(rt2x00dev, libconf);
|
||||
if (flags & IEEE80211_CONF_CHANGE_PS)
|
||||
rt73usb_config_ps(rt2x00dev, libconf);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user