1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-26 07:04:12 +00:00
rtl8812au/hal/phydm/rtl8812a/phydm_rtl8812a.c

114 lines
2.9 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
* Copyright(c) 2007 - 2017 Realtek Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*****************************************************************************/
/* ************************************************************
* include files
* ************************************************************ */
#include "mp_precomp.h"
#include "../phydm_precomp.h"
#if (RTL8812A_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
s8 phydm_cck_rssi_8812a(struct dm_struct *dm, u16 lna_idx, u8 vga_idx)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
s8 rx_pwr_all = 0;
switch (lna_idx) {
case 7:
if (vga_idx <= 27)
rx_pwr_all = -94 + 2 * (27 - vga_idx);
else
rx_pwr_all = -94;
break;
case 6:
rx_pwr_all = -42 + 2 * (2 - vga_idx);
break;
case 5:
rx_pwr_all = -36 + 2 * (7 - vga_idx);
break;
case 4:
rx_pwr_all = -30 + 2 * (7 - vga_idx);
break;
case 3:
rx_pwr_all = -18 + 2 * (7 - vga_idx);
break;
case 2:
rx_pwr_all = 2 * (5 - vga_idx);
break;
case 1:
rx_pwr_all = 14 - 2 * vga_idx;
break;
case 0:
rx_pwr_all = 20 - 2 * vga_idx;
break;
default:
break;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
return rx_pwr_all;
2018-06-22 16:48:32 +00:00
}
2018-08-24 20:52:34 +00:00
#ifdef DYN_ANT_WEIGHTING_SUPPORT
2019-05-24 19:43:57 +00:00
void phydm_dynamic_ant_weighting_8812a(void *dm_void)
2018-08-24 20:52:34 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-08-24 20:52:34 +00:00
u8 rssi_l2h = 43, rssi_h2l = 37;
u8 reg_8;
if (dm->is_disable_dym_ant_weighting)
return;
if (*dm->channel <= 14) {
if (dm->rssi_min >= rssi_l2h) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x854, BIT(3), 0x1);
odm_set_bb_reg(dm, R_0x850, BIT(21) | BIT(22), 0x0);
2018-08-24 20:52:34 +00:00
/*equal weighting*/
2019-05-24 19:43:57 +00:00
reg_8 = (u8)odm_get_bb_reg(dm, R_0xf94, BIT(0) | BIT(1) | BIT(2));
PHYDM_DBG(dm, ODM_COMP_API,
"Equal weighting ,rssi_min = %d\n, 0xf94[2:0] = 0x%x\n",
dm->rssi_min, reg_8);
2018-08-24 20:52:34 +00:00
} else if (dm->rssi_min <= rssi_h2l) {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x854, BIT(3), 0x1);
odm_set_bb_reg(dm, R_0x850, BIT(21) | BIT(22), 0x1);
2018-08-24 20:52:34 +00:00
/*fix sec_min_wgt = 1/2*/
2019-05-24 19:43:57 +00:00
reg_8 = (u8)odm_get_bb_reg(dm, R_0xf94, BIT(0) | BIT(1) | BIT(2));
PHYDM_DBG(dm, ODM_COMP_API,
"AGC weighting ,rssi_min = %d\n, 0xf94[2:0] = 0x%x\n",
dm->rssi_min, reg_8);
}
2018-08-24 20:52:34 +00:00
} else {
2019-05-24 19:43:57 +00:00
odm_set_bb_reg(dm, R_0x854, BIT(3), 0x1);
odm_set_bb_reg(dm, R_0x850, BIT(21) | BIT(22), 0x1);
2018-08-24 20:52:34 +00:00
2019-05-24 19:43:57 +00:00
reg_8 = (u8)odm_get_bb_reg(dm, R_0xf94, BIT(0) | BIT(1) | BIT(2));
PHYDM_DBG(dm, ODM_COMP_API,
"AGC weighting ,rssi_min = %d\n, 0xf94[2:0] = 0x%x\n",
dm->rssi_min, reg_8);
2018-08-24 20:52:34 +00:00
/*fix sec_min_wgt = 1/2*/
2019-05-24 19:43:57 +00:00
}
2018-08-24 20:52:34 +00:00
}
#endif
2019-05-24 19:43:57 +00:00
void phydm_hwsetting_8812a(struct dm_struct *dm)
2018-08-24 20:52:34 +00:00
{
phydm_dynamic_ant_weighting(dm);
}
2018-06-22 16:48:32 +00:00
#endif /* #if (RTL8812A_SUPPORT == 1) */