xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8723ds/hal/phydm/phydm_dfs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017  Realtek Corporation.
4  *
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.
8  *
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
12  * more details.
13  *
14  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25 
26 #ifndef __PHYDM_DFS_H__
27 #define __PHYDM_DFS_H__
28 
29 #define DFS_VERSION "1.1"
30 
31 /*@
32  * ============================================================
33  *  Definition
34  * ============================================================
35  */
36 
37 /*@
38  * ============================================================
39  * 1  structure
40  * ============================================================
41  */
42 
43 struct _DFS_STATISTICS {
44 	u8		mask_idx;
45 	u8		igi_cur;
46 	u8		igi_pre;
47 	u8		st_l2h_cur;
48 	u16		fa_count_pre;
49 	u16		fa_inc_hist[5];
50 	u16		short_pulse_cnt_pre;
51 	u16		long_pulse_cnt_pre;
52 	u8		pwdb_th;
53 	u8		pwdb_th_cur;
54 	u8		pwdb_scalar_factor;
55 	u8		peak_th;
56 	u8		short_pulse_cnt_th;
57 	u8		long_pulse_cnt_th;
58 	u8		peak_window;
59 	u8		three_peak_opt;
60 	u8		three_peak_th2;
61 	u8		fa_mask_th;
62 	u8		st_l2h_max;
63 	u8		st_l2h_min;
64 	u8		dfs_polling_time;
65 	u8		mask_hist_checked : 3;
66 	boolean		pulse_flag_hist[5];
67 	boolean		pulse_type_hist[5];
68 	boolean		radar_det_mask_hist[5];
69 	boolean		idle_mode;
70 	boolean		force_TP_mode;
71 	boolean		dbg_mode;
72 	boolean		sw_trigger_mode;
73 	boolean		det_print;
74 	boolean		det_print2;
75 	boolean		radar_type;
76 	boolean		print_hist_rpt;
77 	boolean		hist_cond_on;
78 	/*@dfs histogram*/
79 	boolean		pri_cond1;
80 	boolean		pri_cond2;
81 	boolean		pri_cond3;
82 	boolean		pri_cond4;
83 	boolean		pri_cond5;
84 	boolean		pw_cond1;
85 	boolean		pw_cond2;
86 	boolean		pw_cond3;
87 	boolean		pri_type3_4_cond1;	/*@for ETSI*/
88 	boolean		pri_type3_4_cond2;	/*@for ETSI*/
89 	boolean		pw_long_cond1;	/*@for long radar*/
90 	boolean		pw_long_cond2;	/*@for long radar*/
91 	boolean		pri_long_cond1;	/*@for long radar*/
92 	boolean		pw_flag;
93 	boolean		pri_flag;
94 	boolean		pri_type3_4_flag;	/*@for ETSI*/
95 	boolean		long_radar_flag;
96 	u8		pri_hold_sum[6];
97 	u8		pw_hold_sum[6];
98 	u8		pri_long_hold_sum[6];
99 	u8		pw_long_hold_sum[6];
100 	u8		hist_idx;
101 	u8		hist_long_idx;
102 	u8		pw_hold[4][6];
103 	u8		pri_hold[4][6];
104 	u8		pw_std;	/*@The std(var) of reasonable num of pw group*/
105 	u8		pri_std;/*@The std(var) of reasonable num of pri group*/
106 	/*@dfs histogram threshold*/
107 	u8		pri_hist_th : 3;
108 	u8		pri_sum_g1_th : 4;
109 	u8		pri_sum_g5_th : 4;
110 	u8		pri_sum_g1_fcc_th : 3;
111 	u8		pri_sum_g3_fcc_th : 3;
112 	u8		pri_sum_safe_fcc_th : 7;
113 	u8		pri_sum_type4_th : 5;
114 	u8		pri_sum_type6_th : 5;
115 	u8		pri_sum_safe_th : 6;
116 	u8		pri_sum_g5_under_g1_th : 3;
117 	u8		pri_pw_diff_th : 3;
118 	u8		pri_pw_diff_fcc_th : 4;
119 	u8		pri_pw_diff_fcc_idle_th : 2;
120 	u8		pri_pw_diff_w53_th : 4;
121 	u8		pri_type1_low_fcc_th : 7;
122 	u8		pri_type1_upp_fcc_th : 7;
123 	u8		pri_type1_cen_fcc_th : 7;
124 	u8		pw_g0_th : 4;
125 	u8		pw_long_lower_20m_th : 4;
126 	u8		pw_long_lower_th : 3;
127 	u8		pri_long_upper_th : 6;
128 	u8		pw_long_sum_upper_th : 7;
129 	u8		pw_std_th : 4;
130 	u8		pw_std_idle_th : 4;
131 	u8		pri_std_th : 4;
132 	u8		pri_std_idle_th : 4;
133 	u8		type4_pw_max_cnt : 4;
134 	u8		type4_safe_pri_sum_th : 3;
135 };
136 
137 /*@
138  * ============================================================
139  * enumeration
140  * ============================================================
141  */
142 
143 enum phydm_dfs_region_domain {
144 	PHYDM_DFS_DOMAIN_UNKNOWN =	0,
145 	PHYDM_DFS_DOMAIN_FCC =		1,
146 	PHYDM_DFS_DOMAIN_MKK =		2,
147 	PHYDM_DFS_DOMAIN_ETSI =		3,
148 };
149 
150 /*@
151  * ============================================================
152  * function prototype
153  * ============================================================
154  */
155 #if defined(CONFIG_PHYDM_DFS_MASTER)
156 void phydm_radar_detect_reset(void *dm_void);
157 void phydm_radar_detect_disable(void *dm_void);
158 void phydm_radar_detect_enable(void *dm_void);
159 boolean phydm_radar_detect(void *dm_void);
160 void phydm_dfs_histogram_radar_distinguish(void *dm_void);
161 boolean phydm_dfs_hist_log(void *dm_void, u8 index);
162 void phydm_dfs_parameter_init(void *dm_void);
163 void phydm_dfs_hist_dbg(void *dm_void, char input[][16], u32 *_used,
164 			char *output, u32 *_out_len);
165 void phydm_dfs_debug(void *dm_void, char input[][16], u32 *_used,
166 		     char *output, u32 *_out_len);
167 u8 phydm_dfs_polling_time(void *dm_void);
168 #endif /* @defined(CONFIG_PHYDM_DFS_MASTER) */
169 
170 boolean
171 phydm_dfs_is_meteorology_channel(void *dm_void);
172 
173 void
174 phydm_dfs_segment_distinguish(void *dm_void, enum rf_syn syn_path);
175 
176 void
177 phydm_dfs_segment_flag_reset(void *dm_void);
178 
179 boolean
180 phydm_is_dfs_band(void *dm_void);
181 
182 boolean
183 phydm_dfs_master_enabled(void *dm_void);
184 
185 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
186 #ifdef PHYDM_IC_JGR3_SERIES_SUPPORT
187 void phydm_dfs_ap_reset_radar_detect_counter_and_flag(void *dm_void);
188 #endif
189 #endif
190 
191 #endif /*@#ifndef __PHYDM_DFS_H__ */
192