Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/phydm_cck_rx_pathdiv.c
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13* The full GNU General Public License is included in this distribution in the14* file called LICENSE.15*16* Contact Information:17* wlanfae <[email protected]>18* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,19* Hsinchu 300, Taiwan.20*21* Larry Finger <[email protected]>22*23*****************************************************************************/2425/*@************************************************************26* include files27************************************************************/2829#include "mp_precomp.h"30#include "phydm_precomp.h"3132#ifdef PHYDM_CCK_RX_PATHDIV_SUPPORT /* @PHYDM-342*/33void phydm_cck_rx_pathdiv_manaul(void *dm_void, boolean en_cck_rx_pathdiv)34{35struct dm_struct *dm = (struct dm_struct *)dm_void;3637/* @Can not apply for 98F/14B/97G from DD YC*/38if (en_cck_rx_pathdiv) {39odm_set_bb_reg(dm, R_0x1a14, BIT(7), 0x0);40odm_set_bb_reg(dm, R_0x1a74, BIT(8), 0x1);41} else {42odm_set_bb_reg(dm, R_0x1a14, BIT(7), 0x1);43odm_set_bb_reg(dm, R_0x1a74, BIT(8), 0x0);44}45}4647void phydm_cck_rx_pathdiv_watchdog(void *dm_void)48{49struct dm_struct *dm = (struct dm_struct *)dm_void;50struct phydm_cck_rx_pathdiv *cckrx_t = &dm->dm_cck_rx_pathdiv_table;51struct phydm_fa_struct *fa_t = &dm->false_alm_cnt;52u8 rssi_th = 0;53u32 rssi_a = 0, rssi_b = 0, rssi_avg = 0;5455if (!cckrx_t->en_cck_rx_pathdiv)56return;5758rssi_a = PHYDM_DIV(cckrx_t->path_a_sum, cckrx_t->path_a_cnt);59rssi_b = PHYDM_DIV(cckrx_t->path_b_sum, cckrx_t->path_b_cnt);60rssi_avg = (rssi_a + rssi_b) >> 1;6162pr_debug("Rx-A:%d, Rx-B:%d, avg:%d\n", rssi_a, rssi_b, rssi_avg);6364cckrx_t->path_a_cnt = 0;65cckrx_t->path_a_sum = 0;66cckrx_t->path_b_cnt = 0;67cckrx_t->path_b_sum = 0;6869if (fa_t->cnt_all >= 100)70rssi_th = cckrx_t->rssi_fa_th;71else72rssi_th = cckrx_t->rssi_th;7374if (dm->phy_dbg_info.num_qry_beacon_pkt > 14 && rssi_avg <= rssi_th)75phydm_cck_rx_pathdiv_manaul(dm, true);76else77phydm_cck_rx_pathdiv_manaul(dm, false);78}7980void phydm_cck_rx_pathdiv_init(void *dm_void)81{82struct dm_struct *dm = (struct dm_struct *)dm_void;83struct phydm_cck_rx_pathdiv *cckrx_t = &dm->dm_cck_rx_pathdiv_table;8485cckrx_t->en_cck_rx_pathdiv = false;86cckrx_t->path_a_cnt = 0;87cckrx_t->path_a_sum = 0;88cckrx_t->path_b_cnt = 0;89cckrx_t->path_b_sum = 0;90cckrx_t->rssi_fa_th = 45;91cckrx_t->rssi_th = 25;92}9394void phydm_process_rssi_for_cck_rx_pathdiv(void *dm_void, void *phy_info_void,95void *pkt_info_void)96{97struct dm_struct *dm = (struct dm_struct *)dm_void;98struct phydm_phyinfo_struct *phy_info = NULL;99struct phydm_perpkt_info_struct *pktinfo = NULL;100struct phydm_cck_rx_pathdiv *cckrx_t = &dm->dm_cck_rx_pathdiv_table;101102phy_info = (struct phydm_phyinfo_struct *)phy_info_void;103pktinfo = (struct phydm_perpkt_info_struct *)pkt_info_void;104105if (!(pktinfo->is_packet_to_self || pktinfo->is_packet_match_bssid))106return;107108if (pktinfo->is_cck_rate)109return;110111cckrx_t->path_a_sum += phy_info->rx_mimo_signal_strength[0];112cckrx_t->path_a_cnt++;113114cckrx_t->path_b_sum += phy_info->rx_mimo_signal_strength[1];115cckrx_t->path_b_cnt++;116}117118void phydm_cck_rx_pathdiv_dbg(void *dm_void, char input[][16], u32 *_used,119char *output, u32 *_out_len)120{121struct dm_struct *dm = (struct dm_struct *)dm_void;122struct phydm_cck_rx_pathdiv *cckrx_t = &dm->dm_cck_rx_pathdiv_table;123char help[] = "-h";124u32 var1[10] = {0};125u32 used = *_used;126u32 out_len = *_out_len;127u8 i = 0;128129if (!(dm->support_ic_type & ODM_RTL8822C))130return;131132for (i = 0; i < 3; i++) {133if (input[i + 1])134PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]);135}136137if ((strcmp(input[1], help) == 0)) {138PDM_SNPF(out_len, used, output + used, out_len - used,139"CCK rx pathdiv manual on: {1} {En}\n");140PDM_SNPF(out_len, used, output + used, out_len - used,141"CCK rx pathdiv watchdog on: {2} {En}\n");142PDM_SNPF(out_len, used, output + used, out_len - used,143"CCK rx pathdiv rssi_th : {3} {th} {fa_th}\n");144} else if (var1[0] == 1) {145if (var1[1] == 1)146phydm_cck_rx_pathdiv_manaul(dm, true);147else148phydm_cck_rx_pathdiv_manaul(dm, false);149} else if (var1[0] == 2) {150if (var1[1] == 1) {151cckrx_t->en_cck_rx_pathdiv = true;152} else {153cckrx_t->en_cck_rx_pathdiv = false;154phydm_cck_rx_pathdiv_manaul(dm, false);155}156} else if (var1[0] == 3) {157cckrx_t->rssi_th = (u8)var1[1];158cckrx_t->rssi_fa_th = (u8)var1[2];159}160*_used = used;161*_out_len = out_len;162}163#endif164165166