1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
21 #ifndef __PHYDMDIG_H__
22 #define __PHYDMDIG_H__
24 #define DIG_VERSION "1.32" /* 2016.09.02 YuChen. add CCK PD for 8197F*/
28 /* Pause DIG & CCKPD */
29 #define DM_DIG_MAX_PAUSE_TYPE 0x7
31 enum dig_goupcheck_level {
33 DIG_GOUPCHECK_LEVEL_0,
34 DIG_GOUPCHECK_LEVEL_1,
39 struct _dynamic_initial_gain_threshold_ {
40 boolean is_stop_dig; /* for debug */
41 boolean is_ignore_dig;
42 boolean is_psd_in_progress;
45 u8 dig_ext_port_stage;
53 u8 cur_sta_connect_state;
54 u8 pre_sta_connect_state;
55 u8 cur_multi_sta_connect_state;
59 u8 backup_ig_value; /* MP DIG */
64 s8 backoff_val_range_max;
65 s8 backoff_val_range_min;
76 u8 pause_cckpd_value[DM_DIG_MAX_PAUSE_TYPE + 1];
79 u8 large_fa_timeout; /*if (large_fa_hit), monitor "large_fa_timeout" sec, if timeout, large_fa_hit=0*/
85 boolean is_media_connect_0;
86 boolean is_media_connect_1;
91 u8 *is_p2p_in_process;
94 u8 pause_dig_value[DM_DIG_MAX_PAUSE_TYPE + 1];
97 enum dig_goupcheck_level dig_go_up_check_level;
100 #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
101 boolean is_tp_target;
102 boolean is_noise_est;
108 #if (RTL8822B_SUPPORT == 1 || RTL8197F_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
112 u8 enable_adjust_big_jump:1;
123 struct _FALSE_ALARM_STATISTICS {
125 u32 cnt_rate_illegal;
129 u32 cnt_ofdm_fail_pre; /* For RTL8881A */
134 u32 cnt_sb_search_fail;
138 u32 cnt_bw_usc; /* Gary */
139 u32 cnt_bw_lsc; /* Gary */
140 u32 cnt_cck_crc32_error;
141 u32 cnt_cck_crc32_ok;
142 u32 cnt_ofdm_crc32_error;
143 u32 cnt_ofdm_crc32_ok;
144 u32 cnt_ht_crc32_error;
146 u32 cnt_vht_crc32_error;
147 u32 cnt_vht_crc32_ok;
148 u32 cnt_crc32_error_all;
149 u32 cnt_crc32_ok_all;
150 boolean cck_block_enable;
151 boolean ofdm_block_enable;
157 DIG_TYPE_THRESH_HIGH = 0,
158 DIG_TYPE_THRESH_LOW = 1,
159 DIG_TYPE_BACKOFF = 2,
160 DIG_TYPE_RX_GAIN_MIN = 3,
161 DIG_TYPE_RX_GAIN_MAX = 4,
163 DIG_TYPE_DISABLE = 6,
170 CCK_PD_STAGE_LowRssi = 0,
171 CCK_PD_STAGE_HighRssi = 1,
172 CCK_PD_STAGE_MAX = 3,
175 enum dm_dig_ext_port_alg_e
177 DIG_EXT_PORT_STAGE_0 = 0,
178 DIG_EXT_PORT_STAGE_1 = 1,
179 DIG_EXT_PORT_STAGE_2 = 2,
180 DIG_EXT_PORT_STAGE_3 = 3,
181 DIG_EXT_PORT_STAGE_MAX = 4,
184 enum dm_dig_connect_e
186 DIG_STA_DISCONNECT = 0,
188 DIG_STA_BEFORE_CONNECT = 2,
189 dig_multi_sta_disconnect = 3,
190 dig_multi_sta_connect = 4,
195 #define DM_MultiSTA_InitGainChangeNotify(Event) {dm_dig_table.cur_multi_sta_connect_state = Event;}
197 #define DM_MultiSTA_InitGainChangeNotify_CONNECT(_ADAPTER) \
198 DM_MultiSTA_InitGainChangeNotify(dig_multi_sta_connect)
200 #define DM_MultiSTA_InitGainChangeNotify_DISCONNECT(_ADAPTER) \
201 DM_MultiSTA_InitGainChangeNotify(dig_multi_sta_disconnect)
204 enum phydm_pause_type {
205 PHYDM_PAUSE = BIT(0),
206 PHYDM_RESUME = BIT(1)
209 enum phydm_pause_level {
210 /* number of pause level can't exceed DM_DIG_MAX_PAUSE_TYPE */
211 PHYDM_PAUSE_LEVEL_0 = 0,
212 PHYDM_PAUSE_LEVEL_1 = 1,
213 PHYDM_PAUSE_LEVEL_2 = 2,
214 PHYDM_PAUSE_LEVEL_3 = 3,
215 PHYDM_PAUSE_LEVEL_4 = 4,
216 PHYDM_PAUSE_LEVEL_5 = 5,
217 PHYDM_PAUSE_LEVEL_6 = 6,
218 PHYDM_PAUSE_LEVEL_7 = DM_DIG_MAX_PAUSE_TYPE /* maximum level */
221 #define DM_DIG_THRESH_HIGH 40
222 #define DM_DIG_THRESH_LOW 35
224 #define DM_FALSEALARM_THRESH_LOW 400
225 #define DM_FALSEALARM_THRESH_HIGH 1000
227 #define DM_DIG_MAX_NIC 0x3e
228 #define DM_DIG_MIN_NIC 0x20
229 #define DM_DIG_MAX_OF_MIN_NIC 0x3e
232 #define DM_DIG_MAX_AP p_dm_odm->priv->pshare->rf_ft_var.dbg_dig_upper /* 0x3e */
233 #define DM_DIG_MIN_AP ((p_dm_odm->support_ic_type & (ODM_RTL8812 | ODM_RTL8822B)) ? 0x1c : 0x20)/* 0x1c */
235 #define DM_DIG_MAX_AP 0x3e
236 #define DM_DIG_MIN_AP 0x20
238 #define DM_DIG_MAX_OF_MIN 0x2A /* 0x32 */
239 #define DM_DIG_MIN_AP_DFS 0x20
241 #define DM_DIG_MAX_NIC_HP 0x46
242 #define DM_DIG_MIN_NIC_HP 0x2e
244 #define DM_DIG_MAX_AP_HP 0x42
245 #define DM_DIG_MIN_AP_HP 0x30
247 #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
248 #define DM_DIG_MAX_AP_COVERAGR 0x26
250 #define DM_DIG_MIN_AP_COVERAGE ((p_dm_odm->support_ic_type & (ODM_RTL8812 | ODM_RTL8822B)) ? 0x1c : 0x20)
252 #define DM_DIG_MIN_AP_COVERAGE 0x1c
254 #define DM_DIG_MAX_OF_MIN_COVERAGE 0x22
256 #define dm_dig_tp_target_th0 500
257 #define dm_dig_tp_target_th1 1000
258 #define dm_dig_tp_training_period 10
261 /* vivi 92c&92d has different definition, 20110504
263 #if (DM_ODM_SUPPORT_TYPE & ODM_CE)
264 #ifdef CONFIG_SPECIAL_SETTING_FOR_FUNAI_TV
265 #define DM_DIG_FA_TH0 0x80/* 0x20 */
267 #define DM_DIG_FA_TH0 0x200/* 0x20 */
270 #define DM_DIG_FA_TH0 0x200/* 0x20 */
273 #define DM_DIG_FA_TH1 0x300
274 #define DM_DIG_FA_TH2 0x400
275 /* this is for 92d */
276 #define DM_DIG_FA_TH0_92D 0x100
277 #define DM_DIG_FA_TH1_92D 0x400
278 #define DM_DIG_FA_TH2_92D 0x600
280 #define DM_DIG_BACKOFF_MAX 12
281 #define DM_DIG_BACKOFF_MIN -4
282 #define DM_DIG_BACKOFF_DEFAULT 10
284 #define DM_DIG_FA_TH0_LPS 4 /* -> 4 in lps */
285 #define DM_DIG_FA_TH1_LPS 15 /* -> 15 lps */
286 #define DM_DIG_FA_TH2_LPS 30 /* -> 30 lps */
287 #define RSSI_OFFSET_DIG 0x05
288 #define LARGE_FA_TIMEOUT 60
292 odm_change_dynamic_init_gain_thresh(
307 enum phydm_pause_type pause_type,
308 enum phydm_pause_level pause_level,
328 odm_false_alarm_counter_statistics(
333 odm_pause_cck_packet_detection(
335 enum phydm_pause_type pause_type,
336 enum phydm_pause_level pause_level,
341 odm_cck_packet_detection_thresh(
346 odm_write_cck_cca_thres(
352 phydm_dig_go_up_check(
356 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
358 odm_mpt_dig_callback(
359 struct timer_list *p_timer
363 odm_mpt_dig_work_item_callback(
369 #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
371 odm_mpt_dig_callback(
376 #if (DM_ODM_SUPPORT_TYPE != ODM_CE)