1 /******************************************************************************
3 * Copyright(c) 2007 - 2016 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 __PHYDMDIG_H__
27 #define __PHYDMDIG_H__
29 #define DIG_VERSION "1.32" /* 2016.09.02 YuChen. add CCK PD for 8197F*/
31 /* Pause DIG & CCKPD */
32 #define DM_DIG_MAX_PAUSE_TYPE 0x7
34 enum dig_goupcheck_level {
35 DIG_GOUPCHECK_LEVEL_0,
36 DIG_GOUPCHECK_LEVEL_1,
42 bool is_stop_dig; /* for debug */
44 bool is_psd_in_progress;
47 u8 dig_ext_port_stage;
55 u8 cur_sta_connect_state;
56 u8 pre_sta_connect_state;
57 u8 cur_multi_sta_connect_state;
61 u8 backup_ig_value; /* MP DIG */
66 s8 backoff_val_range_max;
67 s8 backoff_val_range_min;
78 u8 pause_cckpd_value[DM_DIG_MAX_PAUSE_TYPE + 1];
81 u8 large_fa_timeout; /*if (large_fa_hit), monitor "large_fa_timeout"
82 *sec, if timeout, large_fa_hit=0
89 bool is_media_connect_0;
90 bool is_media_connect_1;
95 u8 *is_p2p_in_process;
98 u8 pause_dig_value[DM_DIG_MAX_PAUSE_TYPE + 1];
101 enum dig_goupcheck_level dig_go_up_check_level;
107 u8 enable_adjust_big_jump : 1;
108 u8 big_jump_step1 : 3;
109 u8 big_jump_step2 : 2;
110 u8 big_jump_step3 : 2;
113 struct false_alarm_stat {
115 u32 cnt_rate_illegal;
119 u32 cnt_ofdm_fail_pre; /* For RTL8881A */
124 u32 cnt_sb_search_fail;
128 u32 cnt_bw_usc; /* Gary */
129 u32 cnt_bw_lsc; /* Gary */
130 u32 cnt_cck_crc32_error;
131 u32 cnt_cck_crc32_ok;
132 u32 cnt_ofdm_crc32_error;
133 u32 cnt_ofdm_crc32_ok;
134 u32 cnt_ht_crc32_error;
136 u32 cnt_vht_crc32_error;
137 u32 cnt_vht_crc32_ok;
138 u32 cnt_crc32_error_all;
139 u32 cnt_crc32_ok_all;
140 bool cck_block_enable;
141 bool ofdm_block_enable;
147 DIG_TYPE_THRESH_HIGH = 0,
148 DIG_TYPE_THRESH_LOW = 1,
149 DIG_TYPE_BACKOFF = 2,
150 DIG_TYPE_RX_GAIN_MIN = 3,
151 DIG_TYPE_RX_GAIN_MAX = 4,
153 DIG_TYPE_DISABLE = 6,
157 enum phydm_pause_type { PHYDM_PAUSE = BIT(0), PHYDM_RESUME = BIT(1) };
159 enum phydm_pause_level {
160 /* number of pause level can't exceed DM_DIG_MAX_PAUSE_TYPE */
161 PHYDM_PAUSE_LEVEL_0 = 0,
162 PHYDM_PAUSE_LEVEL_1 = 1,
163 PHYDM_PAUSE_LEVEL_2 = 2,
164 PHYDM_PAUSE_LEVEL_3 = 3,
165 PHYDM_PAUSE_LEVEL_4 = 4,
166 PHYDM_PAUSE_LEVEL_5 = 5,
167 PHYDM_PAUSE_LEVEL_6 = 6,
168 PHYDM_PAUSE_LEVEL_7 = DM_DIG_MAX_PAUSE_TYPE /* maximum level */
171 #define DM_DIG_THRESH_HIGH 40
172 #define DM_DIG_THRESH_LOW 35
174 #define DM_FALSEALARM_THRESH_LOW 400
175 #define DM_FALSEALARM_THRESH_HIGH 1000
177 #define DM_DIG_MAX_NIC 0x3e
178 #define DM_DIG_MIN_NIC 0x20
179 #define DM_DIG_MAX_OF_MIN_NIC 0x3e
181 #define DM_DIG_MAX_AP 0x3e
182 #define DM_DIG_MIN_AP 0x20
183 #define DM_DIG_MAX_OF_MIN 0x2A /* 0x32 */
184 #define DM_DIG_MIN_AP_DFS 0x20
186 #define DM_DIG_MAX_NIC_HP 0x46
187 #define DM_DIG_MIN_NIC_HP 0x2e
189 #define DM_DIG_MAX_AP_HP 0x42
190 #define DM_DIG_MIN_AP_HP 0x30
192 /* vivi 92c&92d has different definition, 20110504
195 #define DM_DIG_FA_TH0 0x200 /* 0x20 */
197 #define DM_DIG_FA_TH1 0x300
198 #define DM_DIG_FA_TH2 0x400
199 /* this is for 92d */
200 #define DM_DIG_FA_TH0_92D 0x100
201 #define DM_DIG_FA_TH1_92D 0x400
202 #define DM_DIG_FA_TH2_92D 0x600
204 #define DM_DIG_BACKOFF_MAX 12
205 #define DM_DIG_BACKOFF_MIN -4
206 #define DM_DIG_BACKOFF_DEFAULT 10
208 #define DM_DIG_FA_TH0_LPS 4 /* -> 4 in lps */
209 #define DM_DIG_FA_TH1_LPS 15 /* -> 15 lps */
210 #define DM_DIG_FA_TH2_LPS 30 /* -> 30 lps */
211 #define RSSI_OFFSET_DIG 0x05
212 #define LARGE_FA_TIMEOUT 60
214 void odm_change_dynamic_init_gain_thresh(void *dm_void, u32 dm_type,
217 void odm_write_dig(void *dm_void, u8 current_igi);
219 void odm_pause_dig(void *dm_void, enum phydm_pause_type pause_type,
220 enum phydm_pause_level pause_level, u8 igi_value);
222 void odm_dig_init(void *dm_void);
224 void odm_DIG(void *dm_void);
226 void odm_dig_by_rssi_lps(void *dm_void);
228 void odm_false_alarm_counter_statistics(void *dm_void);
230 void odm_pause_cck_packet_detection(void *dm_void,
231 enum phydm_pause_type pause_type,
232 enum phydm_pause_level pause_level,
233 u8 cck_pd_threshold);
235 void odm_cck_packet_detection_thresh(void *dm_void);
237 void odm_write_cck_cca_thres(void *dm_void, u8 cur_cck_cca_thres);
239 bool phydm_dig_go_up_check(void *dm_void);