1 /******************************************************************************
3 * Copyright(c) 2007 - 2017 Realtek Corporation.
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.
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
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
26 #ifndef __PHYDM_LNA_SAT_H__
27 #define __PHYDM_LNA_SAT_H__
28 #ifdef PHYDM_LNA_SAT_CHK_SUPPORT
29 /* @1 ============================================================
31 * 1 ============================================================
34 #define LNA_SAT_VERSION "1.0"
36 /*@LNA saturation check*/
37 #define OFDM_AGC_TAB_0 0
38 #define OFDM_AGC_TAB_2 2
40 #define DIFF_RSSI_TO_IGI 10
41 #define ONE_SEC_MS 1000
43 #define LNA_CHK_PERIOD 100 /*@ms*/
44 #define LNA_CHK_CNT 10 /*@checks per callback*/
45 #define LNA_CHK_DUTY_CYCLE 5 /*@percentage*/
49 #define SNR_STATISTIC_SHIFT 8
50 #define SNR_RPT_MAX 256
52 /* @1 ============================================================
54 * 1 ============================================================
57 enum lna_sat_timer_state {
58 INIT_LNA_SAT_CHK_TIMMER,
59 CANCEL_LNA_SAT_CHK_TIMMER,
60 RELEASE_LNA_SAT_CHK_TIMMER
63 #ifdef PHYDM_LNA_SAT_CHK_TYPE2
64 enum lna_sat_chk_type2_status {
76 LNA_SAT_WITH_PEAK_DET = 1, /*type1*/
77 LNA_SAT_WITH_TRAIN = 2, /*type2*/
80 /* @1 ============================================================
82 * 1 ============================================================
85 struct phydm_lna_sat_t {
86 #ifdef PHYDM_LNA_SAT_CHK_TYPE1
89 u32 chk_period;/*@ms*/
90 boolean is_disable_lna_sat_chk;
91 boolean dis_agc_table_swh;
93 #ifdef PHYDM_LNA_SAT_CHK_TYPE2
94 u8 force_traget_macid;
97 u16 ori_table_try_fail_times;
98 u16 cnt_lower_snr_statistic;
99 u16 sat_table_monitor_times;
100 u16 force_change_period;
102 u8 is_force_lna_sat_table;
103 u8 lwr_snr_ratio_bit_shift;
104 u8 cnt_snr_statistic;
105 u16 snr_statistic_sqr[SNR_RPT_MAX];
106 u8 snr_statistic[SNR_RPT_MAX];
114 u32 cur_lower_snr_mean;
117 u32 pre_lower_snr_mean;
121 enum lna_sat_type lna_sat_type;
122 u32 sat_cnt_acc_patha;
123 u32 sat_cnt_acc_pathb;
124 #ifdef PHYDM_IC_ABOVE_3SS
125 u32 sat_cnt_acc_pathc;
127 #ifdef PHYDM_IC_ABOVE_4SS
128 u32 sat_cnt_acc_pathd;
131 boolean pre_sat_status;
132 boolean cur_sat_status;
133 struct phydm_timer_list phydm_lna_sat_chk_timer;
134 u32 cur_timer_check_cnt;
135 u32 pre_timer_check_cnt;
138 /* @1 ============================================================
139 * 1 function prototype
140 * 1 ============================================================
142 void phydm_lna_sat_chk_init(void *dm_void);
144 u8 phydm_get_ofdm_agc_tab(void *dm_void);
146 void phydm_lna_sat_chk(void *dm_void);
148 void phydm_lna_sat_chk_timers(void *dm_void, u8 state);
150 #ifdef PHYDM_LNA_SAT_CHK_TYPE1
151 #if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)
152 void phydm_lna_sat_chk_bb_init(void *dm_void);
154 void phydm_set_ofdm_agc_tab_path(void *dm_void,
155 u8 tab_sel, enum rf_path path);
157 u8 phydm_get_ofdm_agc_tab_path(void *dm_void, enum rf_path path);
158 #endif /*@#if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)*/
161 #ifdef PHYDM_LNA_SAT_CHK_TYPE2
162 void phydm_parsing_snr(void *dm_void, void *pktinfo_void, s8 *rx_snr);
165 void phydm_lna_sat_debug(void *dm_void, char input[][16], u32 *_used,
166 char *output, u32 *_out_len);
168 void phydm_lna_sat_chk_watchdog(void *dm_void);
170 void phydm_lna_sat_check_init(void *dm_void);
172 #endif /*@#if (PHYDM_LNA_SAT_CHK_SUPPORT == 1)*/