diff options
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8192cu/dm.c')
-rw-r--r-- | drivers/net/wireless/rtlwifi/rtl8192cu/dm.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c new file mode 100644 index 000000000000..a4649a2f7e6f --- /dev/null +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/dm.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2009-2010 Realtek Corporation. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms of version 2 of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | * more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in the | ||
19 | * file called LICENSE. | ||
20 | * | ||
21 | * Contact Information: | ||
22 | * wlanfae <wlanfae@realtek.com> | ||
23 | * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||
24 | * Hsinchu 300, Taiwan. | ||
25 | * | ||
26 | * Larry Finger <Larry.Finger@lwfinger.net> | ||
27 | * | ||
28 | *****************************************************************************/ | ||
29 | |||
30 | #include "../wifi.h" | ||
31 | #include "../base.h" | ||
32 | #include "reg.h" | ||
33 | #include "def.h" | ||
34 | #include "phy.h" | ||
35 | #include "dm.h" | ||
36 | #include "fw.h" | ||
37 | |||
38 | #include "../rtl8192c/dm_common.c" | ||
39 | |||
40 | void rtl92c_dm_dynamic_txpower(struct ieee80211_hw *hw) | ||
41 | { | ||
42 | struct rtl_priv *rtlpriv = rtl_priv(hw); | ||
43 | struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||
44 | struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||
45 | long undecorated_smoothed_pwdb; | ||
46 | |||
47 | if (!rtlpriv->dm.dynamic_txpower_enable) | ||
48 | return; | ||
49 | |||
50 | if (rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) { | ||
51 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
52 | return; | ||
53 | } | ||
54 | |||
55 | if ((mac->link_state < MAC80211_LINKED) && | ||
56 | (rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb == 0)) { | ||
57 | RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, | ||
58 | ("Not connected to any\n")); | ||
59 | |||
60 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
61 | |||
62 | rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | if (mac->link_state >= MAC80211_LINKED) { | ||
67 | if (mac->opmode == NL80211_IFTYPE_ADHOC) { | ||
68 | undecorated_smoothed_pwdb = | ||
69 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
70 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
71 | ("AP Client PWDB = 0x%lx\n", | ||
72 | undecorated_smoothed_pwdb)); | ||
73 | } else { | ||
74 | undecorated_smoothed_pwdb = | ||
75 | rtlpriv->dm.undecorated_smoothed_pwdb; | ||
76 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
77 | ("STA Default Port PWDB = 0x%lx\n", | ||
78 | undecorated_smoothed_pwdb)); | ||
79 | } | ||
80 | } else { | ||
81 | undecorated_smoothed_pwdb = | ||
82 | rtlpriv->dm.entry_min_undecoratedsmoothed_pwdb; | ||
83 | |||
84 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
85 | ("AP Ext Port PWDB = 0x%lx\n", | ||
86 | undecorated_smoothed_pwdb)); | ||
87 | } | ||
88 | |||
89 | if (undecorated_smoothed_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { | ||
90 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; | ||
91 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
92 | ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n")); | ||
93 | } else if ((undecorated_smoothed_pwdb < | ||
94 | (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && | ||
95 | (undecorated_smoothed_pwdb >= | ||
96 | TX_POWER_NEAR_FIELD_THRESH_LVL1)) { | ||
97 | |||
98 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; | ||
99 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
100 | ("TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n")); | ||
101 | } else if (undecorated_smoothed_pwdb < | ||
102 | (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { | ||
103 | rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||
104 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
105 | ("TXHIGHPWRLEVEL_NORMAL\n")); | ||
106 | } | ||
107 | |||
108 | if ((rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl)) { | ||
109 | RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||
110 | ("PHY_SetTxPowerLevel8192S() Channel = %d\n", | ||
111 | rtlphy->current_channel)); | ||
112 | rtl92c_phy_set_txpower_level(hw, rtlphy->current_channel); | ||
113 | } | ||
114 | |||
115 | rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; | ||
116 | } | ||