39 u8 chnl,
u32 *ofdmbase,
u32 *mcsbase,
45 u32 pwrbase0, pwrbase1;
46 u8 legacy_pwrdiff = 0, ht20_pwrdiff = 0;
49 for (i = 0; i < 2; i++)
50 pwrlevel[i] = p_pwrlevel[i];
63 pwrbase0 = pwrlevel[0] + legacy_pwrdiff;
66 pwrbase0 = (pwrbase0 << 24) | (pwrbase0 << 16) | (pwrbase0 << 8) |
74 for (i = 0; i < 2; i++) {
81 pwrlevel[
i] += ht20_pwrdiff;
83 pwrlevel[
i] -= (16 - ht20_pwrdiff);
89 pwrbase1 = pwrlevel[0];
90 pwrbase1 = (pwrbase1 << 24) | (pwrbase1 << 16) | (pwrbase1 << 8) |
96 p_final_pwridx[0] = pwrlevel[0];
97 p_final_pwridx[1] = pwrlevel[1];
125 "40MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n",
126 p_final_pwridx[0], p_final_pwridx[1]);
129 "20MHz finalpwr_idx (A / B) = 0x%x / 0x%x\n",
130 p_final_pwridx[0], p_final_pwridx[1]);
134 static void _rtl92s_set_antennadiff(
struct ieee80211_hw *hw,
140 char ant_pwr_diff = 0;
144 ant_pwr_diff = p_final_pwridx[1] - p_final_pwridx[0];
148 if (ant_pwr_diff > 7)
150 if (ant_pwr_diff < -8)
154 "Antenna Diff from RF-B to RF-A = %d (0x%x)\n",
155 ant_pwr_diff, ant_pwr_diff & 0xf);
176 static void _rtl92s_get_txpower_writeval_byregulatory(
struct ieee80211_hw *hw,
185 u8 i, chnlgroup, pwrdiff_limit[4];
186 u32 writeval, customer_limit;
197 ((index < 2) ? pwrbase0 : pwrbase1);
200 "RTK better performance, writeval = 0x%x\n", writeval);
206 writeval = ((index < 2) ? pwrbase0 : pwrbase1);
209 "Realtek regulatory, 40MHz, writeval = 0x%x\n",
218 else if (chnl >= 4 && chnl <= 8)
229 pwrbase0 : pwrbase1);
232 "Realtek regulatory, 20MHz, writeval = 0x%x\n",
238 writeval = ((index < 2) ? pwrbase0 : pwrbase1);
240 "Better regulatory, writeval = 0x%x\n", writeval);
249 "customer's limit, 40MHz = 0x%x\n",
254 "customer's limit, 20MHz = 0x%x\n",
259 for (i = 0; i < 4; i++) {
262 [chnlgroup][index] & (0x7f << (i * 8)))
267 if (pwrdiff_limit[i] >
275 if (pwrdiff_limit[i] >
285 customer_limit = (pwrdiff_limit[3] << 24) |
286 (pwrdiff_limit[2] << 16) |
287 (pwrdiff_limit[1] << 8) |
290 "Customer's limit = 0x%x\n", customer_limit);
292 writeval = customer_limit + ((index < 2) ?
293 pwrbase0 : pwrbase1);
295 "Customer, writeval = 0x%x\n", writeval);
300 ((index < 2) ? pwrbase0 : pwrbase1);
302 "RTK better performance, writeval = 0x%x\n", writeval);
307 writeval = 0x10101010;
308 else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
312 *p_outwrite_val = writeval;
316 static void _rtl92s_write_ofdm_powerreg(
struct ieee80211_hw *hw,
322 u16 regoffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c};
324 u8 rfa_lower_bound = 0, rfa_upper_bound = 0, rf_pwr_diff = 0;
334 if (rf_pwr_diff >= 8) {
336 rfa_lower_bound = 0x10 - rf_pwr_diff;
343 for (i = 0; i < 4; i++) {
344 rfa_pwr[
i] = (
u8)((writeval & (0x7f << (i * 8))) >> (i * 8));
353 if (rf_pwr_diff >= 8) {
355 if (rfa_pwr[i] < rfa_lower_bound)
356 rfa_pwr[
i] = rfa_lower_bound;
358 }
else if (rf_pwr_diff >= 1) {
360 if (rfa_pwr[i] > rfa_upper_bound)
361 rfa_pwr[
i] = rfa_upper_bound;
367 writeval = (rfa_pwr[3] << 24) | (rfa_pwr[2] << 16) | (rfa_pwr[1] << 8) |
370 rtl_set_bbreg(hw, regoffset[index], 0x7f7f7f7f, writeval);
374 u8 *p_pwrlevel,
u8 chnl)
376 u32 writeval, pwrbase0, pwrbase1;
380 _rtl92s_get_powerbase(hw, p_pwrlevel, chnl, &pwrbase0, &pwrbase1,
382 _rtl92s_set_antennadiff(hw, &finalpwr_idx[0]);
384 for (index = 0; index < 6; index++) {
385 _rtl92s_get_txpower_writeval_byregulatory(hw, chnl, index,
386 pwrbase0, pwrbase1, &writeval);
388 _rtl92s_write_ofdm_powerreg(hw, index, writeval);
398 bool dont_inc_cck_or_turboscanoff =
false;
404 dont_inc_cck_or_turboscanoff =
true;
408 if (dont_inc_cck_or_turboscanoff)
413 if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
416 else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
434 bool rtstatus =
true;
503 pr_err(
"Radio[%d] Fail!!\n", rfpath);
523 0xfffff3ff) | 0x0400);
535 "unknown bandwidth: %#X\n", bandwidth);