hc
2024-05-08 f309769f8af08599af39b6de4f675784ce76530d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/******************************************************************************
 *
 * 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.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 * Contact Information:
 * wlanfae <wlanfae@realtek.com>
 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
 * Hsinchu 300, Taiwan.
 *
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 *****************************************************************************/
 
#ifndef __PHYDM_LNA_SAT_H__
#define __PHYDM_LNA_SAT_H__
#ifdef PHYDM_LNA_SAT_CHK_SUPPORT
/* @1 ============================================================
 * 1  Definition
 * 1 ============================================================
 */
 
#define LNA_SAT_VERSION "1.1"
 
/*@LNA saturation check*/
#define    OFDM_AGC_TAB_0            0
#define    OFDM_AGC_TAB_2            2
 
#define    DIFF_RSSI_TO_IGI        10
#define    ONE_SEC_MS            1000
 
#define LNA_CHK_PERIOD            100 /*@ms*/
#define LNA_CHK_CNT            10 /*@checks per callback*/
#define LNA_CHK_DUTY_CYCLE        5 /*@percentage*/
 
#define    DELTA_STD    2
#define    DELTA_MEAN    2
#define    SNR_STATISTIC_SHIFT    8
#define    SNR_RPT_MAX    256
 
/* @1 ============================================================
 * 1 enumrate
 * 1 ============================================================
 */
 
enum lna_sat_timer_state {
   INIT_LNA_SAT_CHK_TIMMER,
   CANCEL_LNA_SAT_CHK_TIMMER,
   RELEASE_LNA_SAT_CHK_TIMMER
};
 
#ifdef PHYDM_LNA_SAT_CHK_TYPE2
enum lna_sat_chk_type2_status {
   ORI_TABLE_MONITOR,
   ORI_TABLE_TRAINING,
   SAT_TABLE_MONITOR,
   SAT_TABLE_TRAINING,
   SAT_TABLE_TRY_FAIL,
   ORI_TABLE_TRY_FAIL
};
 
#endif
 
enum lna_sat_type {
   LNA_SAT_WITH_PEAK_DET    = 1,    /*type1*/
   LNA_SAT_WITH_TRAIN    = 2,    /*type2*/
};
 
#ifdef PHYDM_HW_SWITCH_AGC_TAB
enum lna_pd_th_level {
   LNA_PD_TH_LEVEL0    = 0,
   LNA_PD_TH_LEVEL1    = 1,
   LNA_PD_TH_LEVEL2    = 2,
   LNA_PD_TH_LEVEL3    = 3
};
 
enum agc_tab_switch_state {
   AGC_SWH_IDLE,
   AGC_SWH_CCK,
   AGC_SWH_OFDM
};
#endif
 
/* @1 ============================================================
 * 1  structure
 * 1 ============================================================
 */
 
struct phydm_lna_sat_t {
#ifdef PHYDM_LNA_SAT_CHK_TYPE1
   u8            chk_cnt;
   u8            chk_duty_cycle;
   u32            chk_period;/*@ms*/
   boolean            is_disable_lna_sat_chk;
   boolean            dis_agc_table_swh;
#endif
#ifdef PHYDM_LNA_SAT_CHK_TYPE2
   u8            force_traget_macid;
   u32            snr_var_thd;
   u32            delta_snr_mean;
   u16            ori_table_try_fail_times;
   u16            cnt_lower_snr_statistic;
   u16            sat_table_monitor_times;
   u16            force_change_period;
   u8            is_snr_detail_en;
   u8            is_force_lna_sat_table;
   u8            lwr_snr_ratio_bit_shift;
   u8            cnt_snr_statistic;
   u16            snr_statistic_sqr[SNR_RPT_MAX];
   u8            snr_statistic[SNR_RPT_MAX];
   u8            is_sm_done;
   u8            is_snr_done;
   u32            cur_snr_var;
   u8            total_bit_shift;
   u8            total_cnt_snr;
   u32            cur_snr_mean;
   u8            cur_snr_var0;
   u32            cur_lower_snr_mean;
   u32            pre_snr_mean;
   u32            pre_snr_var;
   u32            pre_lower_snr_mean;
   u8            nxt_state;
   u8            pre_state;
#endif
   enum lna_sat_type    lna_sat_type;
   u32            sat_cnt_acc_patha;
   u32            sat_cnt_acc_pathb;
#ifdef PHYDM_IC_ABOVE_3SS
   u32            sat_cnt_acc_pathc;
#endif
#ifdef PHYDM_IC_ABOVE_4SS
   u32            sat_cnt_acc_pathd;
#endif
   u32            check_time;
   boolean            pre_sat_status;
   boolean            cur_sat_status;
#ifdef PHYDM_HW_SWITCH_AGC_TAB
   boolean            hw_swh_tab_on;
   enum odm_rf_band    cur_rf_band;
#endif
   struct phydm_timer_list    phydm_lna_sat_chk_timer;
   u32            cur_timer_check_cnt;
   u32            pre_timer_check_cnt;
};
 
/* @1 ============================================================
 * 1 function prototype
 * 1 ============================================================
 */
void phydm_lna_sat_chk_init(void *dm_void);
 
u8 phydm_get_ofdm_agc_tab(void *dm_void);
 
void phydm_lna_sat_chk(void *dm_void);
 
void phydm_lna_sat_chk_timers(void *dm_void, u8 state);
 
#ifdef PHYDM_LNA_SAT_CHK_TYPE1
#if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)
void phydm_lna_sat_chk_bb_init(void *dm_void);
 
void phydm_set_ofdm_agc_tab_path(void *dm_void,
                u8 tab_sel, enum rf_path path);
 
u8 phydm_get_ofdm_agc_tab_path(void *dm_void, enum rf_path path);
#endif /*@#if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)*/
#endif
 
#ifdef PHYDM_LNA_SAT_CHK_TYPE2
void phydm_parsing_snr(void *dm_void, void *pktinfo_void, s8 *rx_snr);
#endif
 
void phydm_lna_sat_debug(void *dm_void, char input[][16], u32 *_used,
            char *output, u32 *_out_len);
 
void phydm_lna_sat_chk_watchdog(void *dm_void);
 
void phydm_lna_sat_check_init(void *dm_void);
 
#ifdef PHYDM_HW_SWITCH_AGC_TAB
void phydm_auto_agc_tab_debug(void *dm_void, char input[][16], u32 *_used,
                 char *output, u32 *_out_len);
#endif
#endif /*@#if (PHYDM_LNA_SAT_CHK_SUPPORT == 1)*/
#endif