Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/phydm_dfs.c
1307 views
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 <[email protected]>
19
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
* Hsinchu 300, Taiwan.
21
*
22
* Larry Finger <[email protected]>
23
*
24
*****************************************************************************/
25
26
/*@
27
* ============================================================
28
* include files
29
* ============================================================
30
*/
31
32
#include "mp_precomp.h"
33
#include "phydm_precomp.h"
34
35
#if defined(CONFIG_PHYDM_DFS_MASTER)
36
37
boolean phydm_dfs_is_meteorology_channel(void *dm_void)
38
{
39
struct dm_struct *dm = (struct dm_struct *)dm_void;
40
41
u8 ch = *dm->channel;
42
u8 bw = *dm->band_width;
43
44
return ((bw == CHANNEL_WIDTH_80 && (ch) >= 116 && (ch) <= 128) ||
45
(bw == CHANNEL_WIDTH_40 && (ch) >= 116 && (ch) <= 128) ||
46
(bw == CHANNEL_WIDTH_20 && (ch) >= 120 && (ch) <= 128));
47
}
48
49
void phydm_dfs_segment_distinguish(void *dm_void, enum rf_syn syn_path)
50
{
51
struct dm_struct *dm = (struct dm_struct *)dm_void;
52
53
if (!(dm->support_ic_type & (ODM_RTL8814B)))
54
return;
55
if (syn_path == RF_SYN1)
56
dm->seg1_dfs_flag = 1;
57
else
58
dm->seg1_dfs_flag = 0;
59
}
60
61
void phydm_dfs_segment_flag_reset(void *dm_void)
62
{
63
struct dm_struct *dm = (struct dm_struct *)dm_void;
64
65
if (!(dm->support_ic_type & (ODM_RTL8814B)))
66
return;
67
if (dm->seg1_dfs_flag)
68
dm->seg1_dfs_flag = 0;
69
}
70
71
void phydm_radar_detect_reset(void *dm_void)
72
{
73
struct dm_struct *dm = (struct dm_struct *)dm_void;
74
75
if (dm->support_ic_type & (ODM_RTL8198F | ODM_RTL8822C | ODM_RTL8812F |
76
ODM_RTL8197G)) {
77
odm_set_bb_reg(dm, R_0xa40, BIT(15), 0);
78
odm_set_bb_reg(dm, R_0xa40, BIT(15), 1);
79
#if (RTL8721D_SUPPORT)
80
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
81
odm_set_bb_reg(dm, R_0xf58, BIT(29), 0);
82
odm_set_bb_reg(dm, R_0xf58, BIT(29), 1);
83
#endif
84
} else if (dm->support_ic_type & (ODM_RTL8814B)) {
85
if (dm->seg1_dfs_flag == 1) {
86
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 0);
87
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 1);
88
return;
89
}
90
odm_set_bb_reg(dm, R_0xa40, BIT(15), 0);
91
odm_set_bb_reg(dm, R_0xa40, BIT(15), 1);
92
} else {
93
odm_set_bb_reg(dm, R_0x924, BIT(15), 0);
94
odm_set_bb_reg(dm, R_0x924, BIT(15), 1);
95
}
96
}
97
98
void phydm_radar_detect_disable(void *dm_void)
99
{
100
struct dm_struct *dm = (struct dm_struct *)dm_void;
101
102
if (dm->support_ic_type & (ODM_RTL8198F | ODM_RTL8822C | ODM_RTL8812F |
103
ODM_RTL8197G))
104
odm_set_bb_reg(dm, R_0xa40, BIT(15), 0);
105
else if (dm->support_ic_type & (ODM_RTL8814B)) {
106
if (dm->seg1_dfs_flag == 1) {
107
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 0);
108
dm->seg1_dfs_flag = 0;
109
return;
110
}
111
odm_set_bb_reg(dm, R_0xa40, BIT(15), 0);
112
}
113
#if (RTL8721D_SUPPORT)
114
else if (dm->support_ic_type & (ODM_RTL8721D))
115
odm_set_bb_reg(dm, R_0xf58, BIT(29), 0);
116
#endif
117
else
118
odm_set_bb_reg(dm, R_0x924, BIT(15), 0);
119
120
PHYDM_DBG(dm, DBG_DFS, "\n");
121
}
122
123
static void phydm_radar_detect_with_dbg_parm(void *dm_void)
124
{
125
struct dm_struct *dm = (struct dm_struct *)dm_void;
126
127
if (dm->support_ic_type & ODM_RTL8721D) {
128
odm_set_bb_reg(dm, R_0xf54, MASKDWORD,
129
dm->radar_detect_reg_f54);
130
odm_set_bb_reg(dm, R_0xf58, MASKDWORD,
131
dm->radar_detect_reg_f58);
132
odm_set_bb_reg(dm, R_0xf5c, MASKDWORD,
133
dm->radar_detect_reg_f5c);
134
odm_set_bb_reg(dm, R_0xf70, MASKDWORD,
135
dm->radar_detect_reg_f70);
136
odm_set_bb_reg(dm, R_0xf74, MASKDWORD,
137
dm->radar_detect_reg_f74);
138
} else if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
139
odm_set_bb_reg(dm, R_0xa40, MASKDWORD,
140
dm->radar_detect_reg_a40);
141
odm_set_bb_reg(dm, R_0xa44, MASKDWORD,
142
dm->radar_detect_reg_a44);
143
odm_set_bb_reg(dm, R_0xa48, MASKDWORD,
144
dm->radar_detect_reg_a48);
145
odm_set_bb_reg(dm, R_0xa4c, MASKDWORD,
146
dm->radar_detect_reg_a4c);
147
odm_set_bb_reg(dm, R_0xa50, MASKDWORD,
148
dm->radar_detect_reg_a50);
149
odm_set_bb_reg(dm, R_0xa54, MASKDWORD,
150
dm->radar_detect_reg_a54);
151
} else {
152
odm_set_bb_reg(dm, R_0x918, MASKDWORD,
153
dm->radar_detect_reg_918);
154
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
155
dm->radar_detect_reg_91c);
156
odm_set_bb_reg(dm, R_0x920, MASKDWORD,
157
dm->radar_detect_reg_920);
158
odm_set_bb_reg(dm, R_0x924, MASKDWORD,
159
dm->radar_detect_reg_924);
160
}
161
}
162
163
/* @Init radar detection parameters, called after ch, bw is set */
164
165
void phydm_radar_detect_enable(void *dm_void)
166
{
167
struct dm_struct *dm = (struct dm_struct *)dm_void;
168
struct _DFS_STATISTICS *dfs = &dm->dfs;
169
u8 region_domain = dm->dfs_region_domain;
170
u8 c_channel = *dm->channel;
171
u8 band_width = *dm->band_width;
172
u8 enable = 0, i;
173
u8 short_pw_upperbound = 0;
174
175
PHYDM_DBG(dm, DBG_DFS, "test, region_domain = %d\n", region_domain);
176
if (region_domain == PHYDM_DFS_DOMAIN_UNKNOWN) {
177
PHYDM_DBG(dm, DBG_DFS, "PHYDM_DFS_DOMAIN_UNKNOWN\n");
178
goto exit;
179
}
180
181
if (dm->support_ic_type & (ODM_RTL8821 | ODM_RTL8812 | ODM_RTL8881A)) {
182
odm_set_bb_reg(dm, R_0x814, 0x3fffffff, 0x04cc4d10);
183
odm_set_bb_reg(dm, R_0x834, MASKBYTE0, 0x06);
184
185
if (dm->radar_detect_dbg_parm_en) {
186
phydm_radar_detect_with_dbg_parm(dm);
187
enable = 1;
188
goto exit;
189
}
190
191
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
192
odm_set_bb_reg(dm, R_0x918, MASKDWORD, 0x1c17ecdf);
193
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x01528500);
194
odm_set_bb_reg(dm, R_0x91c, MASKDWORD, 0x0fa21a20);
195
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe0f69204);
196
197
} else if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
198
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x01528500);
199
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe0d67234);
200
201
if (c_channel >= 52 && c_channel <= 64) {
202
odm_set_bb_reg(dm, R_0x918, MASKDWORD,
203
0x1c16ecdf);
204
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
205
0x0f141a20);
206
} else {
207
odm_set_bb_reg(dm, R_0x918, MASKDWORD,
208
0x1c16acdf);
209
if (band_width == CHANNEL_WIDTH_20)
210
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
211
0x64721a20);
212
else
213
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
214
0x68721a20);
215
}
216
217
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
218
odm_set_bb_reg(dm, R_0x918, MASKDWORD, 0x1c16acdf);
219
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x01528500);
220
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe0d67231);
221
if (band_width == CHANNEL_WIDTH_20)
222
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
223
0x64741a20);
224
else
225
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
226
0x68741a20);
227
228
} else {
229
/* not supported */
230
PHYDM_DBG(dm, DBG_DFS,
231
"Unsupported dfs_region_domain:%d\n",
232
region_domain);
233
goto exit;
234
}
235
236
} else if (dm->support_ic_type &
237
(ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C)) {
238
239
odm_set_bb_reg(dm, R_0x814, 0x3fffffff, 0x04cc4d10);
240
odm_set_bb_reg(dm, R_0x834, MASKBYTE0, 0x06);
241
242
/* @8822B only, when BW = 20M, DFIR output is 40Mhz,
243
* but DFS input is 80MMHz, so it need to upgrade to 80MHz
244
*/
245
if (dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8821C)) {
246
if (band_width == CHANNEL_WIDTH_20)
247
odm_set_bb_reg(dm, R_0x1984, BIT(26), 1);
248
else
249
odm_set_bb_reg(dm, R_0x1984, BIT(26), 0);
250
}
251
252
if (dm->radar_detect_dbg_parm_en) {
253
phydm_radar_detect_with_dbg_parm(dm);
254
enable = 1;
255
goto exit;
256
}
257
258
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
259
odm_set_bb_reg(dm, R_0x918, MASKDWORD, 0x1c16acdf);
260
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x095a8500);
261
odm_set_bb_reg(dm, R_0x91c, MASKDWORD, 0x0fc01a1f);
262
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe0f57204);
263
264
} else if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
265
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x095a8500);
266
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe0d67234);
267
268
if (c_channel >= 52 && c_channel <= 64) {
269
odm_set_bb_reg(dm, R_0x918, MASKDWORD,
270
0x1c16ecdf);
271
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
272
0x0f141a1f);
273
} else {
274
odm_set_bb_reg(dm, R_0x918, MASKDWORD,
275
0x1c166cdf);
276
if (band_width == CHANNEL_WIDTH_20)
277
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
278
0x64721a1f);
279
else
280
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
281
0x68721a1f);
282
}
283
284
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
285
odm_set_bb_reg(dm, R_0x918, MASKDWORD, 0x1c176cdf);
286
odm_set_bb_reg(dm, R_0x924, MASKDWORD, 0x095a8400);
287
odm_set_bb_reg(dm, R_0x920, MASKDWORD, 0xe076d231);
288
if (band_width == CHANNEL_WIDTH_20)
289
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
290
0x64901a1f);
291
else
292
odm_set_bb_reg(dm, R_0x91c, MASKDWORD,
293
0x62901a1f);
294
295
} else {
296
/* not supported */
297
PHYDM_DBG(dm, DBG_DFS,
298
"Unsupported dfs_region_domain:%d\n",
299
region_domain);
300
goto exit;
301
}
302
/*RXHP low corner will extend the pulse width,
303
*so we need to increase the upper bound.
304
*/
305
if (dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8821C)) {
306
if (odm_get_bb_reg(dm, 0x8d8,
307
BIT28 | BIT27 | BIT26) == 0) {
308
short_pw_upperbound =
309
(u8)odm_get_bb_reg(dm, 0x91c,
310
BIT23 | BIT22 |
311
BIT21 | BIT20);
312
if ((short_pw_upperbound + 4) > 15)
313
odm_set_bb_reg(dm, 0x91c,
314
BIT23 | BIT22 |
315
BIT21 | BIT20, 15);
316
else
317
odm_set_bb_reg(dm, 0x91c,
318
BIT23 | BIT22 |
319
BIT21 | BIT20,
320
short_pw_upperbound + 4);
321
}
322
/*@if peak index -1~+1, use original NB method*/
323
odm_set_bb_reg(dm, 0x19e4, 0x003C0000, 13);
324
odm_set_bb_reg(dm, 0x924, 0x70000, 0);
325
}
326
327
if (dm->support_ic_type & (ODM_RTL8881A))
328
odm_set_bb_reg(dm, 0xb00, 0xc0000000, 3);
329
330
/*@for 8814 new dfs mechanism setting*/
331
if (dm->support_ic_type &
332
(ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C)) {
333
/*Turn off dfs scaling factor*/
334
odm_set_bb_reg(dm, 0x19e4, 0x1fff, 0x0c00);
335
/*NonDC peak_th = 2times DC peak_th*/
336
odm_set_bb_reg(dm, 0x19e4, 0x30000, 1);
337
/*power for debug and auto test flow latch after ST*/
338
odm_set_bb_reg(dm, 0x9f8, 0xc0000000, 3);
339
340
/*@low pulse width radar pattern will cause wrong drop*/
341
/*@disable peak index should the same
342
*during the same short pulse (new mechan)
343
*/
344
odm_set_bb_reg(dm, 0x9f4, 0x80000000, 0);
345
346
/*@disable peak index should the same
347
*during the same short pulse (old mechan)
348
*/
349
odm_set_bb_reg(dm, 0x924, 0x20000000, 0);
350
351
/*@if peak index diff >=2, then drop the result*/
352
odm_set_bb_reg(dm, 0x19e4, 0xe000, 2);
353
if (region_domain == 2) {
354
if ((c_channel >= 52) && (c_channel <= 64)) {
355
/*pulse width hist th setting*/
356
/*th1=2*04us*/
357
odm_set_bb_reg(dm, 0x19e4,
358
0xff000000, 2);
359
/*th2 = 3*0.4us, th3 = 4*0.4us
360
*th4 = 7*0.4, th5 = 34*0.4
361
*/
362
odm_set_bb_reg(dm, 0x19e8,
363
MASKDWORD, 0x22070403);
364
365
/*PRI hist th setting*/
366
/*th1=42*32us*/
367
odm_set_bb_reg(dm, 0x19b8,
368
0x00007f80, 42);
369
/*th2=47*32us, th3=115*32us,
370
*th4=123*32us, th5=130*32us
371
*/
372
odm_set_bb_reg(dm, 0x19ec,
373
MASKDWORD, 0x827b732f);
374
} else {
375
/*pulse width hist th setting*/
376
/*th1=2*04us*/
377
odm_set_bb_reg(dm, 0x19e4,
378
0xff000000, 1);
379
/*th2 = 13*0.4us, th3 = 26*0.4us
380
*th4 = 75*0.4us, th5 = 255*0.4us
381
*/
382
odm_set_bb_reg(dm, 0x19e8,
383
MASKDWORD, 0xff4b1a0d);
384
/*PRI hist th setting*/
385
/*th1=4*32us*/
386
387
odm_set_bb_reg(dm, 0x19b8,
388
0x00007f80, 4);
389
/*th2=8*32us, th3=16*32us,
390
*th4=32*32us, th5=128*32=4096us
391
*/
392
odm_set_bb_reg(dm, 0x19ec,
393
MASKDWORD, 0x80201008);
394
}
395
}
396
/*@ETSI*/
397
else if (region_domain == 3) {
398
/*pulse width hist th setting*/
399
/*th1=2*04us*/
400
odm_set_bb_reg(dm, 0x19e4, 0xff000000, 1);
401
odm_set_bb_reg(dm, 0x19e8,
402
MASKDWORD, 0x68260d06);
403
/*PRI hist th setting*/
404
/*th1=7*32us*/
405
odm_set_bb_reg(dm, 0x19b8, 0x00007f80, 7);
406
/*th2=40*32us, th3=80*32us,
407
*th4=110*32us, th5=157*32=5024
408
*/
409
odm_set_bb_reg(dm, 0x19ec,
410
MASKDWORD, 0xc06e2010);
411
}
412
/*@FCC*/
413
else if (region_domain == 1) {
414
/*pulse width hist th setting*/
415
/*th1=2*04us*/
416
odm_set_bb_reg(dm, 0x19e4, 0xff000000, 2);
417
/*th2 = 13*0.4us, th3 = 26*0.4us,
418
*th4 = 75*0.4us, th5 = 255*0.4us
419
*/
420
odm_set_bb_reg(dm, 0x19e8,
421
MASKDWORD, 0xff4b1a0d);
422
423
/*PRI hist th setting*/
424
/*th1=4*32us*/
425
odm_set_bb_reg(dm, 0x19b8, 0x00007f80, 4);
426
/*th2=8*32us, th3=21*32us,
427
*th4=32*32us, th5=96*32=3072
428
*/
429
if (band_width == CHANNEL_WIDTH_20)
430
odm_set_bb_reg(dm, 0x19ec,
431
MASKDWORD, 0x60282010);
432
else
433
odm_set_bb_reg(dm, 0x19ec,
434
MASKDWORD, 0x60282420);
435
} else {
436
}
437
}
438
} else if (dm->support_ic_type &
439
ODM_IC_JGR3_SERIES) {
440
if (dm->radar_detect_dbg_parm_en) {
441
phydm_radar_detect_with_dbg_parm(dm);
442
enable = 1;
443
goto exit;
444
}
445
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
446
odm_set_bb_reg(dm, R_0xa40, MASKDWORD, 0xb359c5bd);
447
if (dm->support_ic_type & (ODM_RTL8814B)) {
448
if (dm->seg1_dfs_flag == 1)
449
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 1);
450
}
451
odm_set_bb_reg(dm, R_0xa44, MASKDWORD, 0x3033bebd);
452
odm_set_bb_reg(dm, R_0xa48, MASKDWORD, 0x2a521254);
453
odm_set_bb_reg(dm, R_0xa4c, MASKDWORD, 0xa2533345);
454
odm_set_bb_reg(dm, R_0xa50, MASKDWORD, 0x605be003);
455
odm_set_bb_reg(dm, R_0xa54, MASKDWORD, 0x500089e8);
456
} else if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
457
odm_set_bb_reg(dm, R_0xa40, MASKDWORD, 0xb359c5bd);
458
if (dm->support_ic_type & (ODM_RTL8814B)) {
459
if (dm->seg1_dfs_flag == 1)
460
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 1);
461
}
462
odm_set_bb_reg(dm, R_0xa44, MASKDWORD, 0x3033bebd);
463
odm_set_bb_reg(dm, R_0xa48, MASKDWORD, 0x2a521254);
464
odm_set_bb_reg(dm, R_0xa4c, MASKDWORD, 0xa2533345);
465
odm_set_bb_reg(dm, R_0xa50, MASKDWORD, 0x605be003);
466
odm_set_bb_reg(dm, R_0xa54, MASKDWORD, 0x500089e8);
467
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
468
odm_set_bb_reg(dm, R_0xa40, MASKDWORD, 0xb359c5bd);
469
if (dm->support_ic_type & (ODM_RTL8814B)) {
470
if (dm->seg1_dfs_flag == 1)
471
odm_set_bb_reg(dm, R_0xa6c, BIT(0), 1);
472
}
473
odm_set_bb_reg(dm, R_0xa44, MASKDWORD, 0x3033bebd);
474
odm_set_bb_reg(dm, R_0xa48, MASKDWORD, 0x2a521254);
475
odm_set_bb_reg(dm, R_0xa4c, MASKDWORD, 0xa2533345);
476
odm_set_bb_reg(dm, R_0xa50, MASKDWORD, 0x605be003);
477
odm_set_bb_reg(dm, R_0xa54, MASKDWORD, 0x500089e8);
478
} else {
479
/* not supported */
480
PHYDM_DBG(dm, DBG_DFS,
481
"Unsupported dfs_region_domain:%d\n",
482
region_domain);
483
goto exit;
484
}
485
#if (RTL8721D_SUPPORT)
486
} else if (dm->support_ic_type & ODM_RTL8721D) {
487
odm_set_bb_reg(dm, R_0x814, 0x3fffffff, 0x04cc4d10);
488
/*CCA MASK*/
489
odm_set_bb_reg(dm, R_0xc38, 0x07c00000, 0x06);
490
/*CCA Threshold*/
491
odm_set_bb_reg(dm, R_0xc3c, 0x00000007, 0x0);
492
493
if (dm->radar_detect_dbg_parm_en) {
494
phydm_radar_detect_with_dbg_parm(dm);
495
enable = 1;
496
goto exit;
497
}
498
499
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
500
odm_set_bb_reg(dm, R_0xf54, MASKDWORD, 0x230006a8);
501
odm_set_bb_reg(dm, R_0xf58, MASKDWORD, 0x354cd7dd);
502
odm_set_bb_reg(dm, R_0xf5c, MASKDWORD, 0x9984ab25);
503
odm_set_bb_reg(dm, R_0xf70, MASKDWORD, 0xbd9fab98);
504
odm_set_bb_reg(dm, R_0xf74, MASKDWORD, 0xcc45029f);
505
506
} else if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
507
odm_set_bb_reg(dm, R_0xf54, MASKDWORD, 0x230006a8);
508
odm_set_bb_reg(dm, R_0xf5c, MASKDWORD, 0x9984ab25);
509
odm_set_bb_reg(dm, R_0xf70, MASKDWORD, 0xbd9fb398);
510
odm_set_bb_reg(dm, R_0xf74, MASKDWORD, 0xcc450e9d);
511
512
if (c_channel >= 52 && c_channel <= 64) {
513
odm_set_bb_reg(dm, R_0xf58, MASKDWORD,
514
0x354cd7fd);
515
} else {
516
odm_set_bb_reg(dm, R_0xf58, MASKDWORD,
517
0x354cd7bd);
518
}
519
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
520
odm_set_bb_reg(dm, R_0xf54, MASKDWORD, 0x230006a8);
521
odm_set_bb_reg(dm, R_0xf58, MASKDWORD, 0x3558d7bd);
522
odm_set_bb_reg(dm, R_0xf5c, MASKDWORD, 0x9984ab35);
523
odm_set_bb_reg(dm, R_0xf70, MASKDWORD, 0xbd9fb398);
524
odm_set_bb_reg(dm, R_0xf74, MASKDWORD, 0xcc444e9d);
525
} else {
526
/* not supported */
527
PHYDM_DBG(dm, DBG_DFS,
528
"Unsupported dfs_region_domain:%d\n",
529
region_domain);
530
goto exit;
531
}
532
533
/*if peak index -1~+1, use original NB method*/
534
odm_set_bb_reg(dm, R_0xf70, 0x00070000, 0x7);
535
odm_set_bb_reg(dm, R_0xf74, 0x000c0000, 0);
536
537
/*Turn off dfs scaling factor*/
538
odm_set_bb_reg(dm, R_0xf70, 0x00080000, 0x0);
539
/*NonDC peak_th = 2times DC peak_th*/
540
odm_set_bb_reg(dm, R_0xf58, 0x00007800, 1);
541
542
/*low pulse width radar pattern will cause wrong drop*/
543
/*disable peak index should the same*/
544
/*during the same short pulse (new mechan)*/
545
odm_set_bb_reg(dm, R_0xf70, 0x00100000, 0x0);
546
/*if peak index diff >=2, then drop the result*/
547
odm_set_bb_reg(dm, R_0xf70, 0x30000000, 0x2);
548
#endif
549
} else {
550
/*not supported IC type*/
551
PHYDM_DBG(dm, DBG_DFS, "Unsupported IC type:%d\n",
552
dm->support_ic_type);
553
goto exit;
554
}
555
556
enable = 1;
557
558
if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
559
dfs->st_l2h_cur = (u8)odm_get_bb_reg(dm, R_0xa40, 0x00007f00);
560
dfs->pwdb_th_cur = (u8)odm_get_bb_reg(dm, R_0xa50, 0x000000f0);
561
dfs->peak_th = (u8)odm_get_bb_reg(dm, R_0xa48, 0x00c00000);
562
dfs->short_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0xa50,
563
0x00f00000);
564
dfs->long_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0xa4c,
565
0xf0000000);
566
dfs->peak_window = (u8)odm_get_bb_reg(dm, R_0xa40, 0x00030000);
567
dfs->three_peak_opt = (u8)odm_get_bb_reg(dm, R_0xa40,
568
0x30000000);
569
dfs->three_peak_th2 = (u8)odm_get_bb_reg(dm, R_0xa44,
570
0x00000007);
571
#if (RTL8721D_SUPPORT)
572
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
573
dfs->st_l2h_cur = (u8)odm_get_bb_reg(dm, R_0xf54,
574
0x0000001f) << 2);
575
dfs->st_l2h_cur += (u8)odm_get_bb_reg(dm, R_0xf58, 0xc0000000);
576
dfs->pwdb_th_cur = (u8)odm_get_bb_reg(dm, R_0xf70, 0x03c00000);
577
dfs->peak_th = (u8)odm_get_bb_reg(dm, R_0xf5c, 0x00000030);
578
dfs->short_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0xf70,
579
0x00007800);
580
dfs->long_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0xf74,
581
0x0000000f);
582
dfs->peak_window = (u8)odm_get_bb_reg(dm, R_0xf58, 0x18000000);
583
dfs->three_peak_opt = (u8)odm_get_bb_reg(dm, R_0xf58,
584
0x00030000);
585
dfs->three_peak_th2 = (u8)odm_get_bb_reg(dm,
586
R_0xf58, 0x00007c00);
587
#endif
588
} else {
589
dfs->st_l2h_cur = (u8)odm_get_bb_reg(dm, R_0x91c, 0x000000ff);
590
dfs->pwdb_th_cur = (u8)odm_get_bb_reg(dm, R_0x918, 0x00001f00);
591
dfs->peak_th = (u8)odm_get_bb_reg(dm, R_0x918, 0x00030000);
592
dfs->short_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0x920,
593
0x000f0000);
594
dfs->long_pulse_cnt_th = (u8)odm_get_bb_reg(dm, R_0x920,
595
0x00f00000);
596
dfs->peak_window = (u8)odm_get_bb_reg(dm, R_0x920, 0x00000300);
597
dfs->three_peak_opt = (u8)odm_get_bb_reg(dm, 0x924, 0x00000180);
598
dfs->three_peak_th2 = (u8)odm_get_bb_reg(dm, 0x924, 0x00007000);
599
}
600
601
phydm_dfs_parameter_init(dm);
602
603
exit:
604
if (enable) {
605
phydm_radar_detect_reset(dm);
606
PHYDM_DBG(dm, DBG_DFS, "on cch:%u, bw:%u\n", c_channel,
607
band_width);
608
} else
609
phydm_radar_detect_disable(dm);
610
}
611
612
void phydm_dfs_parameter_init(void *dm_void)
613
{
614
struct dm_struct *dm = (struct dm_struct *)dm_void;
615
struct _DFS_STATISTICS *dfs = &dm->dfs;
616
617
u8 i;
618
for (i = 0; i < 5; i++) {
619
dfs->pulse_flag_hist[i] = 0;
620
dfs->pulse_type_hist[i] = 0;
621
dfs->radar_det_mask_hist[i] = 0;
622
dfs->fa_inc_hist[i] = 0;
623
}
624
625
/*@for dfs mode*/
626
dfs->force_TP_mode = 0;
627
dfs->sw_trigger_mode = 0;
628
dfs->det_print = 0;
629
dfs->det_print2 = 0;
630
dfs->print_hist_rpt = 0;
631
if (dm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C))
632
dfs->hist_cond_on = 1;
633
else
634
dfs->hist_cond_on = 0;
635
636
/*@for dynamic dfs*/
637
dfs->pwdb_th = 8;
638
dfs->fa_mask_th = 30 * (dfs->dfs_polling_time / 100);
639
dfs->st_l2h_min = 0x20;
640
dfs->st_l2h_max = 0x4e;
641
dfs->pwdb_scalar_factor = 12;
642
643
/*@for dfs histogram*/
644
dfs->pri_hist_th = 5;
645
dfs->pri_sum_g1_th = 9;
646
dfs->pri_sum_g5_th = 5;
647
dfs->pri_sum_g1_fcc_th = 4; /*@FCC Type6*/
648
dfs->pri_sum_g3_fcc_th = 6;
649
dfs->pri_sum_safe_th = 50;
650
dfs->pri_sum_safe_fcc_th = 110; /*@30 for AP*/
651
dfs->pri_sum_type4_th = 16;
652
dfs->pri_sum_type6_th = 12;
653
dfs->pri_sum_g5_under_g1_th = 4;
654
dfs->pri_pw_diff_th = 4;
655
dfs->pri_pw_diff_fcc_th = 8;
656
dfs->pri_pw_diff_fcc_idle_th = 2;
657
dfs->pri_pw_diff_w53_th = 10;
658
dfs->pw_std_th = 7; /*@FCC Type4*/
659
dfs->pw_std_idle_th = 10;
660
dfs->pri_std_th = 6; /*@FCC Type3,4,6*/
661
dfs->pri_std_idle_th = 10;
662
dfs->pri_type1_upp_fcc_th = 110;
663
dfs->pri_type1_low_fcc_th = 50;
664
dfs->pri_type1_cen_fcc_th = 70;
665
dfs->pw_g0_th = 8;
666
dfs->pw_long_lower_th = 6; /*@7->6*/
667
dfs->pri_long_upper_th = 30;
668
dfs->pw_long_lower_20m_th = 7; /*@7 for AP*/
669
dfs->pw_long_sum_upper_th = 60;
670
dfs->type4_pw_max_cnt = 7;
671
dfs->type4_safe_pri_sum_th = 5;
672
}
673
674
void phydm_dfs_dynamic_setting(
675
void *dm_void)
676
{
677
struct dm_struct *dm = (struct dm_struct *)dm_void;
678
struct _DFS_STATISTICS *dfs = &dm->dfs;
679
680
u8 peak_th_cur = 0, short_pulse_cnt_th_cur = 0;
681
u8 long_pulse_cnt_th_cur = 0, three_peak_opt_cur = 0;
682
u8 three_peak_th2_cur = 0;
683
u8 peak_window_cur = 0;
684
u8 region_domain = dm->dfs_region_domain;
685
u8 c_channel = *dm->channel;
686
687
if (dm->rx_tp + dm->tx_tp <= 2) {
688
dfs->idle_mode = 1;
689
if (dfs->force_TP_mode)
690
dfs->idle_mode = 0;
691
} else {
692
dfs->idle_mode = 0;
693
}
694
695
if (dfs->idle_mode == 1) { /*@idle (no traffic)*/
696
peak_th_cur = 3;
697
short_pulse_cnt_th_cur = 6;
698
long_pulse_cnt_th_cur = 9;
699
peak_window_cur = 2;
700
three_peak_opt_cur = 0;
701
three_peak_th2_cur = 2;
702
if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
703
if (c_channel >= 52 && c_channel <= 64) {
704
short_pulse_cnt_th_cur = 14;
705
long_pulse_cnt_th_cur = 15;
706
three_peak_th2_cur = 0;
707
} else {
708
short_pulse_cnt_th_cur = 6;
709
three_peak_th2_cur = 0;
710
long_pulse_cnt_th_cur = 10;
711
}
712
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
713
three_peak_th2_cur = 0;
714
} else if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
715
long_pulse_cnt_th_cur = 15;
716
if (phydm_dfs_is_meteorology_channel(dm)) {
717
/*need to add check cac end condition*/
718
peak_th_cur = 2;
719
three_peak_opt_cur = 0;
720
three_peak_th2_cur = 0;
721
short_pulse_cnt_th_cur = 7;
722
} else {
723
three_peak_opt_cur = 0;
724
three_peak_th2_cur = 0;
725
short_pulse_cnt_th_cur = 7;
726
}
727
} else /*@default: FCC*/
728
three_peak_th2_cur = 0;
729
730
} else { /*@in service (with TP)*/
731
peak_th_cur = 2;
732
short_pulse_cnt_th_cur = 6;
733
long_pulse_cnt_th_cur = 7;
734
peak_window_cur = 2;
735
three_peak_opt_cur = 0;
736
three_peak_th2_cur = 2;
737
if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
738
if (c_channel >= 52 && c_channel <= 64) {
739
long_pulse_cnt_th_cur = 15;
740
/*@for high duty cycle*/
741
short_pulse_cnt_th_cur = 5;
742
three_peak_th2_cur = 0;
743
} else {
744
three_peak_opt_cur = 0;
745
three_peak_th2_cur = 0;
746
long_pulse_cnt_th_cur = 8;
747
}
748
} else if (region_domain == PHYDM_DFS_DOMAIN_FCC) {
749
long_pulse_cnt_th_cur = 5; /*for 80M FCC*/
750
short_pulse_cnt_th_cur = 5; /*for 80M FCC*/
751
} else if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
752
long_pulse_cnt_th_cur = 15;
753
short_pulse_cnt_th_cur = 5;
754
three_peak_opt_cur = 0;
755
}
756
}
757
758
if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
759
if (dfs->peak_th != peak_th_cur)
760
odm_set_bb_reg(dm, R_0xa48, 0x00c00000, peak_th_cur);
761
if (dfs->short_pulse_cnt_th != short_pulse_cnt_th_cur)
762
odm_set_bb_reg(dm, R_0xa50, 0x00f00000,
763
short_pulse_cnt_th_cur);
764
if (dfs->long_pulse_cnt_th != long_pulse_cnt_th_cur)
765
odm_set_bb_reg(dm, R_0xa4c, 0xf0000000,
766
long_pulse_cnt_th_cur);
767
if (dfs->peak_window != peak_window_cur)
768
odm_set_bb_reg(dm, R_0xa40, 0x00030000,
769
peak_window_cur);
770
if (dfs->three_peak_opt != three_peak_opt_cur)
771
odm_set_bb_reg(dm, R_0xa40, 0x30000000,
772
three_peak_opt_cur);
773
if (dfs->three_peak_th2 != three_peak_th2_cur)
774
odm_set_bb_reg(dm, R_0xa44, 0x00000007,
775
three_peak_th2_cur);
776
#if (RTL8721D_SUPPORT)
777
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
778
if (dfs->peak_th != peak_th_cur)
779
odm_set_bb_reg(dm, R_0xf5c, 0x00000030, peak_th_cur);
780
if (dfs->short_pulse_cnt_th != short_pulse_cnt_th_cur)
781
odm_set_bb_reg(dm, R_0xf70, 0x00007800,
782
short_pulse_cnt_th_cur);
783
if (dfs->long_pulse_cnt_th != long_pulse_cnt_th_cur)
784
odm_set_bb_reg(dm, R_0xf74, 0x0000000f,
785
long_pulse_cnt_th_cur);
786
if (dfs->peak_window != peak_window_cur)
787
odm_set_bb_reg(dm, R_0xf58, 0x18000000,
788
peak_window_cur);
789
if (dfs->three_peak_opt != three_peak_opt_cur)
790
odm_set_bb_reg(dm, R_0xf58, 0x00030000,
791
three_peak_opt_cur);
792
if (dfs->three_peak_th2 != three_peak_th2_cur)
793
odm_set_bb_reg(dm, R_0xf58, 0x00007c00,
794
three_peak_th2_cur);
795
#endif
796
} else {
797
if (dfs->peak_th != peak_th_cur)
798
odm_set_bb_reg(dm, R_0x918, 0x00030000, peak_th_cur);
799
if (dfs->short_pulse_cnt_th != short_pulse_cnt_th_cur)
800
odm_set_bb_reg(dm, R_0x920, 0x000f0000,
801
short_pulse_cnt_th_cur);
802
if (dfs->long_pulse_cnt_th != long_pulse_cnt_th_cur)
803
odm_set_bb_reg(dm, R_0x920, 0x00f00000,
804
long_pulse_cnt_th_cur);
805
if (dfs->peak_window != peak_window_cur)
806
odm_set_bb_reg(dm, R_0x920, 0x00000300,
807
peak_window_cur);
808
if (dfs->three_peak_opt != three_peak_opt_cur)
809
odm_set_bb_reg(dm, R_0x924, 0x00000180,
810
three_peak_opt_cur);
811
if (dfs->three_peak_th2 != three_peak_th2_cur)
812
odm_set_bb_reg(dm, R_0x924, 0x00007000,
813
three_peak_th2_cur);
814
}
815
816
dfs->peak_th = peak_th_cur;
817
dfs->short_pulse_cnt_th = short_pulse_cnt_th_cur;
818
dfs->long_pulse_cnt_th = long_pulse_cnt_th_cur;
819
dfs->peak_window = peak_window_cur;
820
dfs->three_peak_opt = three_peak_opt_cur;
821
dfs->three_peak_th2 = three_peak_th2_cur;
822
}
823
824
boolean
825
phydm_radar_detect_dm_check(
826
void *dm_void)
827
{
828
struct dm_struct *dm = (struct dm_struct *)dm_void;
829
struct _DFS_STATISTICS *dfs = &dm->dfs;
830
u8 region_domain = dm->dfs_region_domain, index = 0;
831
832
u16 i = 0, j = 0, k = 0, fa_count_cur = 0, fa_count_inc = 0;
833
u16 total_fa_in_hist = 0, pre_post_now_acc_fa_in_hist = 0;
834
u16 max_fa_in_hist = 0, vht_crc_ok_cnt_cur = 0;
835
u16 vht_crc_ok_cnt_inc = 0, ht_crc_ok_cnt_cur = 0;
836
u16 ht_crc_ok_cnt_inc = 0, leg_crc_ok_cnt_cur = 0;
837
u16 leg_crc_ok_cnt_inc = 0;
838
u16 total_crc_ok_cnt_inc = 0, short_pulse_cnt_cur = 0;
839
u16 short_pulse_cnt_inc = 0, long_pulse_cnt_cur = 0;
840
u16 long_pulse_cnt_inc = 0, total_pulse_count_inc = 0;
841
u32 regf98_value = 0, reg918_value = 0, reg91c_value = 0;
842
u32 reg920_value = 0, reg924_value = 0, radar_rpt_reg_value = 0;
843
u32 regf54_value = 0, regf58_value = 0, regf5c_value = 0;
844
u32 regdf4_value = 0, regf70_value = 0, regf74_value = 0;
845
u32 rega40_value = 0, rega44_value = 0, rega48_value = 0;
846
u32 rega4c_value = 0, rega50_value = 0, rega54_value = 0;
847
#if (RTL8721D_SUPPORT)
848
u32 reg908_value = 0, regdf4_value = 0;
849
u32 regf54_value = 0, regf58_value = 0, regf5c_value = 0;
850
u32 regf70_value = 0, regf74_value = 0;
851
#endif
852
boolean tri_short_pulse = 0, tri_long_pulse = 0, radar_type = 0;
853
boolean fault_flag_det = 0, fault_flag_psd = 0, fa_flag = 0;
854
boolean radar_detected = 0;
855
u8 st_l2h_new = 0, fa_mask_th = 0, sum = 0;
856
u8 c_channel = *dm->channel;
857
858
/*@Get FA count during past 100ms, R_0xf48 for AC series*/
859
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
860
fa_count_cur = (u16)odm_get_bb_reg(dm, R_0x2d00, MASKLWORD);
861
#if (RTL8721D_SUPPORT)
862
else if (dm->support_ic_type & (ODM_RTL8721D)) {
863
fa_count_cur = (u16)odm_get_bb_reg(dm,
864
ODM_REG_OFDM_FA_TYPE2_11N,
865
MASKHWORD);
866
fa_count_cur += (u16)odm_get_bb_reg(dm,
867
ODM_REG_OFDM_FA_TYPE3_11N,
868
MASKLWORD);
869
fa_count_cur += (u16)odm_get_bb_reg(dm,
870
ODM_REG_OFDM_FA_TYPE3_11N,
871
MASKHWORD);
872
fa_count_cur += (u16)odm_get_bb_reg(dm,
873
ODM_REG_OFDM_FA_TYPE4_11N,
874
MASKLWORD);
875
fa_count_cur += (u16)odm_get_bb_reg(dm,
876
ODM_REG_OFDM_FA_TYPE1_11N,
877
MASKLWORD);
878
fa_count_cur += (u16)odm_get_bb_reg(dm,
879
ODM_REG_OFDM_FA_TYPE1_11N,
880
MASKHWORD);
881
}
882
#endif
883
else
884
fa_count_cur = (u16)odm_get_bb_reg(dm, R_0xf48, 0x0000ffff);
885
886
if (dfs->fa_count_pre == 0)
887
fa_count_inc = 0;
888
else if (fa_count_cur >= dfs->fa_count_pre)
889
fa_count_inc = fa_count_cur - dfs->fa_count_pre;
890
else
891
fa_count_inc = fa_count_cur;
892
dfs->fa_count_pre = fa_count_cur;
893
894
dfs->fa_inc_hist[dfs->mask_idx] = fa_count_inc;
895
896
for (i = 0; i < 5; i++) {
897
total_fa_in_hist = total_fa_in_hist + dfs->fa_inc_hist[i];
898
if (dfs->fa_inc_hist[i] > max_fa_in_hist)
899
max_fa_in_hist = dfs->fa_inc_hist[i];
900
}
901
if (dfs->mask_idx >= 2)
902
index = dfs->mask_idx - 2;
903
else
904
index = 5 + dfs->mask_idx - 2;
905
if (index == 0) {
906
pre_post_now_acc_fa_in_hist = dfs->fa_inc_hist[index] +
907
dfs->fa_inc_hist[index + 1] +
908
dfs->fa_inc_hist[4];
909
} else if (index == 4) {
910
pre_post_now_acc_fa_in_hist = dfs->fa_inc_hist[index] +
911
dfs->fa_inc_hist[0] +
912
dfs->fa_inc_hist[index - 1];
913
} else {
914
pre_post_now_acc_fa_in_hist = dfs->fa_inc_hist[index] +
915
dfs->fa_inc_hist[index + 1] +
916
dfs->fa_inc_hist[index - 1];
917
}
918
919
/*@Get VHT CRC32 ok count during past 100ms*/
920
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
921
vht_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0x2c0c, 0xffff);
922
#if (RTL8721D_SUPPORT)
923
else if (dm->support_ic_type & ODM_RTL8721D)
924
vht_crc_ok_cnt_cur = 0;
925
#endif
926
else
927
vht_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0xf0c,
928
0x00003fff);
929
930
if (vht_crc_ok_cnt_cur >= dfs->vht_crc_ok_cnt_pre) {
931
vht_crc_ok_cnt_inc = vht_crc_ok_cnt_cur -
932
dfs->vht_crc_ok_cnt_pre;
933
} else {
934
vht_crc_ok_cnt_inc = vht_crc_ok_cnt_cur;
935
}
936
dfs->vht_crc_ok_cnt_pre = vht_crc_ok_cnt_cur;
937
938
/*@Get HT CRC32 ok count during past 100ms*/
939
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
940
ht_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0x2c10, 0xffff);
941
#if (RTL8721D_SUPPORT)
942
else if (dm->support_ic_type & (ODM_RTL8721D))
943
ht_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0xf90, MASKLWORD);
944
#endif
945
else
946
ht_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0xf10,
947
0x00003fff);
948
949
if (ht_crc_ok_cnt_cur >= dfs->ht_crc_ok_cnt_pre)
950
ht_crc_ok_cnt_inc = ht_crc_ok_cnt_cur - dfs->ht_crc_ok_cnt_pre;
951
else
952
ht_crc_ok_cnt_inc = ht_crc_ok_cnt_cur;
953
dfs->ht_crc_ok_cnt_pre = ht_crc_ok_cnt_cur;
954
955
/*@Get Legacy CRC32 ok count during past 100ms*/
956
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
957
leg_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0x2c14, 0xffff);
958
#if (RTL8721D_SUPPORT)
959
else if (dm->support_ic_type & ODM_RTL8721D)
960
leg_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm,
961
R_0xf94, MASKLWORD);
962
#endif
963
else
964
leg_crc_ok_cnt_cur = (u16)odm_get_bb_reg(dm, R_0xf14,
965
0x00003fff);
966
967
if (leg_crc_ok_cnt_cur >= dfs->leg_crc_ok_cnt_pre)
968
leg_crc_ok_cnt_inc = leg_crc_ok_cnt_cur - dfs->leg_crc_ok_cnt_pre;
969
else
970
leg_crc_ok_cnt_inc = leg_crc_ok_cnt_cur;
971
dfs->leg_crc_ok_cnt_pre = leg_crc_ok_cnt_cur;
972
973
if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
974
if (vht_crc_ok_cnt_cur == 0xffff ||
975
ht_crc_ok_cnt_cur == 0xffff ||
976
leg_crc_ok_cnt_cur == 0xffff) {
977
phydm_reset_bb_hw_cnt(dm);
978
}
979
#if (RTL8721D_SUPPORT)
980
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
981
if (ht_crc_ok_cnt_cur == 0xffff ||
982
leg_crc_ok_cnt_cur == 0xffff) {
983
odm_set_bb_reg(dm, R_0xf14, BIT(16), 1);
984
odm_set_bb_reg(dm, R_0xf14, BIT(16), 0);
985
}
986
#endif
987
} else {
988
if (vht_crc_ok_cnt_cur == 0x3fff ||
989
ht_crc_ok_cnt_cur == 0x3fff ||
990
leg_crc_ok_cnt_cur == 0x3fff) {
991
phydm_reset_bb_hw_cnt(dm);
992
}
993
}
994
995
total_crc_ok_cnt_inc = vht_crc_ok_cnt_inc +
996
ht_crc_ok_cnt_inc +
997
leg_crc_ok_cnt_inc;
998
999
if (dm->support_ic_type & (ODM_RTL8198F | ODM_RTL8822C | ODM_RTL8812F |
1000
ODM_RTL8197G)) {
1001
/* if (phydm_set_bb_dbg_port(dm, DBGPORT_PRI_2, 0x3b0)) {
1002
* odm_set_bb_reg(dm, 0x1e28, 0x03c00000, 8);
1003
* dbgport2dbc_value = phydm_get_bb_dbg_port_val(dm);
1004
* phydm_release_bb_dbg_port(dm); }
1005
*/
1006
radar_rpt_reg_value = odm_get_bb_reg(dm, R_0x2e00, 0xffffffff);
1007
short_pulse_cnt_cur = (u16)((radar_rpt_reg_value & 0x000ff800)
1008
>> 11);
1009
long_pulse_cnt_cur = (u16)((radar_rpt_reg_value & 0x0fc00000)
1010
>> 22);
1011
#if (RTL8721D_SUPPORT)
1012
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
1013
reg908_value = (u32)odm_get_bb_reg(dm, R_0x908, MASKDWORD);
1014
odm_set_bb_reg(dm, R_0x908, MASKDWORD, 0x254);
1015
regdf4_value = odm_get_bb_reg(dm, R_0xdf4, MASKDWORD);
1016
short_pulse_cnt_cur = (u16)((regdf4_value & 0x000ff000) >> 12);
1017
long_pulse_cnt_cur = (u16)((regdf4_value & 0x0fc00000) >> 22);
1018
1019
tri_short_pulse = (regdf4_value & BIT(20)) ? 1 : 0;
1020
tri_long_pulse = (regdf4_value & BIT(28)) ? 1 : 0;
1021
if (tri_short_pulse || tri_long_pulse) {
1022
odm_set_bb_reg(dm, R_0xf58, BIT(29), 0);
1023
odm_set_bb_reg(dm, R_0xf58, BIT(29), 1);
1024
}
1025
#endif
1026
} else if (dm->support_ic_type & (ODM_RTL8814B)) {
1027
if (dm->seg1_dfs_flag == 1)
1028
radar_rpt_reg_value = odm_get_bb_reg(dm, R_0x2e20,
1029
0xffffffff);
1030
else
1031
radar_rpt_reg_value = odm_get_bb_reg(dm, R_0x2e00,
1032
0xffffffff);
1033
short_pulse_cnt_cur = (u16)((radar_rpt_reg_value & 0x000ff800)
1034
>> 11);
1035
long_pulse_cnt_cur = (u16)((radar_rpt_reg_value & 0x0fc00000)
1036
>> 22);
1037
} else {
1038
regf98_value = odm_get_bb_reg(dm, R_0xf98, 0xffffffff);
1039
short_pulse_cnt_cur = (u16)(regf98_value & 0x000000ff);
1040
long_pulse_cnt_cur = (u16)((regf98_value & 0x0000ff00) >> 8);
1041
}
1042
1043
/*@Get short pulse count, need carefully handle the counter overflow*/
1044
1045
if (short_pulse_cnt_cur >= dfs->short_pulse_cnt_pre) {
1046
short_pulse_cnt_inc = short_pulse_cnt_cur -
1047
dfs->short_pulse_cnt_pre;
1048
} else {
1049
short_pulse_cnt_inc = short_pulse_cnt_cur;
1050
}
1051
dfs->short_pulse_cnt_pre = short_pulse_cnt_cur;
1052
1053
/*@Get long pulse count, need carefully handle the counter overflow*/
1054
1055
if (long_pulse_cnt_cur >= dfs->long_pulse_cnt_pre) {
1056
long_pulse_cnt_inc = long_pulse_cnt_cur -
1057
dfs->long_pulse_cnt_pre;
1058
} else {
1059
long_pulse_cnt_inc = long_pulse_cnt_cur;
1060
}
1061
dfs->long_pulse_cnt_pre = long_pulse_cnt_cur;
1062
1063
total_pulse_count_inc = short_pulse_cnt_inc + long_pulse_cnt_inc;
1064
1065
if (dfs->det_print) {
1066
PHYDM_DBG(dm, DBG_DFS,
1067
"===============================================\n");
1068
PHYDM_DBG(dm, DBG_DFS,
1069
"Total_CRC_OK_cnt_inc[%d] VHT_CRC_ok_cnt_inc[%d] HT_CRC_ok_cnt_inc[%d] LEG_CRC_ok_cnt_inc[%d] FA_count_inc[%d]\n",
1070
total_crc_ok_cnt_inc, vht_crc_ok_cnt_inc,
1071
ht_crc_ok_cnt_inc, leg_crc_ok_cnt_inc, fa_count_inc);
1072
if (dm->support_ic_type & (ODM_RTL8721D)) {
1073
PHYDM_DBG(dm, DBG_DFS,
1074
"Init_Gain[%x] st_l2h_cur[%x] 0xdf4[%08x] short_pulse_cnt_inc[%d] long_pulse_cnt_inc[%d]\n",
1075
dfs->igi_cur, dfs->st_l2h_cur, regdf4_value,
1076
short_pulse_cnt_inc, long_pulse_cnt_inc);
1077
regf54_value = odm_get_bb_reg(dm, R_0xf54, MASKDWORD);
1078
regf58_value = odm_get_bb_reg(dm, R_0xf58, MASKDWORD);
1079
regf5c_value = odm_get_bb_reg(dm, R_0xf5c, MASKDWORD);
1080
regf70_value = odm_get_bb_reg(dm, R_0xf70, MASKDWORD);
1081
regf74_value = odm_get_bb_reg(dm, R_0xf74, MASKDWORD);
1082
PHYDM_DBG(dm, DBG_DFS,
1083
"0xf54[%08x] 0xf58[%08x] 0xf5c[%08x] 0xf70[%08x] 0xf74[%08x]\n",
1084
regf54_value, regf58_value, regf5c_value,
1085
regf70_value, regf74_value);
1086
} else if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
1087
PHYDM_DBG(dm, DBG_DFS,
1088
"Init_Gain[%x] st_l2h_cur[%x] 0x2dbc[%08x] short_pulse_cnt_inc[%d] long_pulse_cnt_inc[%d]\n",
1089
dfs->igi_cur, dfs->st_l2h_cur,
1090
radar_rpt_reg_value, short_pulse_cnt_inc,
1091
long_pulse_cnt_inc);
1092
rega40_value = odm_get_bb_reg(dm, R_0xa40, MASKDWORD);
1093
rega44_value = odm_get_bb_reg(dm, R_0xa44, MASKDWORD);
1094
rega48_value = odm_get_bb_reg(dm, R_0xa48, MASKDWORD);
1095
rega4c_value = odm_get_bb_reg(dm, R_0xa4c, MASKDWORD);
1096
rega50_value = odm_get_bb_reg(dm, R_0xa50, MASKDWORD);
1097
rega54_value = odm_get_bb_reg(dm, R_0xa54, MASKDWORD);
1098
PHYDM_DBG(dm, DBG_DFS,
1099
"0xa40[%08x] 0xa44[%08x] 0xa48[%08x] 0xa4c[%08x] 0xa50[%08x] 0xa54[%08x]\n",
1100
rega40_value, rega44_value, rega48_value,
1101
rega4c_value, rega50_value, rega54_value);
1102
} else {
1103
PHYDM_DBG(dm, DBG_DFS,
1104
"Init_Gain[%x] 0x91c[%x] 0xf98[%08x] short_pulse_cnt_inc[%d] long_pulse_cnt_inc[%d]\n",
1105
dfs->igi_cur, dfs->st_l2h_cur, regf98_value,
1106
short_pulse_cnt_inc, long_pulse_cnt_inc);
1107
reg918_value = odm_get_bb_reg(dm, R_0x918,
1108
0xffffffff);
1109
reg91c_value = odm_get_bb_reg(dm, R_0x91c,
1110
0xffffffff);
1111
reg920_value = odm_get_bb_reg(dm, R_0x920,
1112
0xffffffff);
1113
reg924_value = odm_get_bb_reg(dm, R_0x924,
1114
0xffffffff);
1115
PHYDM_DBG(dm, DBG_DFS,
1116
"0x918[%08x] 0x91c[%08x] 0x920[%08x] 0x924[%08x]\n",
1117
reg918_value, reg91c_value,
1118
reg920_value, reg924_value);
1119
}
1120
PHYDM_DBG(dm, DBG_DFS, "Throughput: %dMbps\n",
1121
(dm->rx_tp + dm->tx_tp));
1122
1123
PHYDM_DBG(dm, DBG_DFS,
1124
"dfs_regdomain = %d, dbg_mode = %d, idle_mode = %d, print_hist_rpt = %d, hist_cond_on = %d\n",
1125
region_domain, dfs->dbg_mode,
1126
dfs->idle_mode, dfs->print_hist_rpt,
1127
dfs->hist_cond_on);
1128
}
1129
if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
1130
tri_short_pulse = (radar_rpt_reg_value & BIT(20)) ? 1 : 0;
1131
tri_long_pulse = (radar_rpt_reg_value & BIT(28)) ? 1 : 0;
1132
} else {
1133
tri_short_pulse = (regf98_value & BIT(17)) ? 1 : 0;
1134
tri_long_pulse = (regf98_value & BIT(19)) ? 1 : 0;
1135
}
1136
1137
if (tri_short_pulse) {
1138
phydm_radar_detect_reset(dm);
1139
}
1140
if (tri_long_pulse) {
1141
phydm_radar_detect_reset(dm);
1142
if (region_domain == PHYDM_DFS_DOMAIN_MKK) {
1143
if (c_channel >= 52 && c_channel <= 64) {
1144
tri_long_pulse = 0;
1145
}
1146
}
1147
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
1148
tri_long_pulse = 0;
1149
}
1150
}
1151
1152
st_l2h_new = dfs->st_l2h_cur;
1153
dfs->pulse_flag_hist[dfs->mask_idx] = tri_short_pulse | tri_long_pulse;
1154
dfs->pulse_type_hist[dfs->mask_idx] = (tri_long_pulse) ? 1 : 0;
1155
1156
/* PSD(not ready) */
1157
1158
fault_flag_det = 0;
1159
fault_flag_psd = 0;
1160
fa_flag = 0;
1161
if (region_domain == PHYDM_DFS_DOMAIN_ETSI) {
1162
fa_mask_th = dfs->fa_mask_th + 20;
1163
} else {
1164
fa_mask_th = dfs->fa_mask_th;
1165
}
1166
if (max_fa_in_hist >= fa_mask_th ||
1167
total_fa_in_hist >= fa_mask_th ||
1168
pre_post_now_acc_fa_in_hist >= fa_mask_th ||
1169
dfs->igi_cur >= 0x30) {
1170
st_l2h_new = dfs->st_l2h_max;
1171
dfs->radar_det_mask_hist[index] = 1;
1172
if (dfs->pulse_flag_hist[index] == 1) {
1173
dfs->pulse_flag_hist[index] = 0;
1174
if (dfs->det_print2) {
1175
PHYDM_DBG(dm, DBG_DFS,
1176
"Radar is masked : FA mask\n");
1177
}
1178
}
1179
fa_flag = 1;
1180
} else {
1181
dfs->radar_det_mask_hist[index] = 0;
1182
}
1183
1184
if (dfs->det_print) {
1185
PHYDM_DBG(dm, DBG_DFS, "mask_idx: %d\n", dfs->mask_idx);
1186
PHYDM_DBG(dm, DBG_DFS, "radar_det_mask_hist: ");
1187
for (i = 0; i < 5; i++)
1188
PHYDM_DBG(dm, DBG_DFS, "%d ",
1189
dfs->radar_det_mask_hist[i]);
1190
PHYDM_DBG(dm, DBG_DFS, "pulse_flag_hist: ");
1191
for (i = 0; i < 5; i++)
1192
PHYDM_DBG(dm, DBG_DFS, "%d ", dfs->pulse_flag_hist[i]);
1193
PHYDM_DBG(dm, DBG_DFS, "fa_inc_hist: ");
1194
for (i = 0; i < 5; i++)
1195
PHYDM_DBG(dm, DBG_DFS, "%d ", dfs->fa_inc_hist[i]);
1196
PHYDM_DBG(dm, DBG_DFS,
1197
"\nfa_mask_th: %d max_fa_in_hist: %d total_fa_in_hist: %d pre_post_now_acc_fa_in_hist: %d ",
1198
fa_mask_th, max_fa_in_hist, total_fa_in_hist,
1199
pre_post_now_acc_fa_in_hist);
1200
}
1201
1202
sum = 0;
1203
for (k = 0; k < 5; k++) {
1204
if (dfs->radar_det_mask_hist[k] == 1)
1205
sum++;
1206
}
1207
1208
if (dfs->mask_hist_checked <= 5)
1209
dfs->mask_hist_checked++;
1210
1211
if (dfs->mask_hist_checked >= 5 && dfs->pulse_flag_hist[index]) {
1212
if (sum <= 2) {
1213
if (dfs->hist_cond_on) {
1214
/*return the value from hist_radar_detected*/
1215
radar_detected = phydm_dfs_hist_log(dm, index);
1216
} else {
1217
if (dfs->pulse_type_hist[index] == 0)
1218
dfs->radar_type = 0;
1219
else if (dfs->pulse_type_hist[index] == 1)
1220
dfs->radar_type = 1;
1221
radar_detected = 1;
1222
PHYDM_DBG(dm, DBG_DFS,
1223
"Detected type %d radar signal!\n",
1224
dfs->radar_type);
1225
}
1226
} else {
1227
fault_flag_det = 1;
1228
if (dfs->det_print2) {
1229
PHYDM_DBG(dm, DBG_DFS,
1230
"Radar is masked : mask_hist large than thd\n");
1231
}
1232
}
1233
}
1234
1235
dfs->mask_idx++;
1236
if (dfs->mask_idx == 5)
1237
dfs->mask_idx = 0;
1238
1239
if (fault_flag_det == 0 && fault_flag_psd == 0 && fa_flag == 0) {
1240
if (dfs->igi_cur < 0x30) {
1241
st_l2h_new = dfs->st_l2h_min;
1242
}
1243
}
1244
1245
if (st_l2h_new != dfs->st_l2h_cur) {
1246
if (st_l2h_new < dfs->st_l2h_min) {
1247
dfs->st_l2h_cur = dfs->st_l2h_min;
1248
} else if (st_l2h_new > dfs->st_l2h_max)
1249
dfs->st_l2h_cur = dfs->st_l2h_max;
1250
else
1251
dfs->st_l2h_cur = st_l2h_new;
1252
/*odm_set_bb_reg(dm, R_0x91c, 0xff, dfs->st_l2h_cur);*/
1253
1254
dfs->pwdb_th_cur = ((int)dfs->st_l2h_cur - (int)dfs->igi_cur)
1255
/ 2 + dfs->pwdb_scalar_factor;
1256
1257
/*@limit the pwdb value to absolute lower bound 8*/
1258
dfs->pwdb_th_cur = MAX_2(dfs->pwdb_th_cur, (int)dfs->pwdb_th);
1259
1260
/*@limit the pwdb value to absolute upper bound 0x1f*/
1261
dfs->pwdb_th_cur = MIN_2(dfs->pwdb_th_cur, 0x1f);
1262
1263
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
1264
odm_set_bb_reg(dm, R_0xa50, 0x000000f0,
1265
dfs->pwdb_th_cur);
1266
#if (RTL8721D_SUPPORT)
1267
else if (dm->support_ic_type & ODM_RTL8721D) {
1268
odm_set_bb_reg(dm, R_0xf54, 0x0000001f,
1269
((dfs->st_l2h_cur & 0x0000007c) >> 2));
1270
odm_set_bb_reg(dm, R_0xf58, 0xc0000000,
1271
(dfs->st_l2h_cur & 0x00000003));
1272
odm_set_bb_reg(dm, R_0xf70, 0x03c00000,
1273
dfs->pwdb_th_cur);
1274
}
1275
#endif
1276
else
1277
odm_set_bb_reg(dm, R_0x918, 0x00001f00,
1278
dfs->pwdb_th_cur);
1279
}
1280
1281
if (dfs->det_print) {
1282
PHYDM_DBG(dm, DBG_DFS,
1283
"fault_flag_det[%d], fault_flag_psd[%d], DFS_detected [%d]\n",
1284
fault_flag_det, fault_flag_psd, radar_detected);
1285
}
1286
#if (RTL8721D_SUPPORT)
1287
if (dm->support_ic_type & (ODM_RTL8721D))
1288
odm_set_bb_reg(dm, R_0x908, MASKDWORD, reg908_value);
1289
#endif
1290
1291
return radar_detected;
1292
}
1293
1294
void phydm_dfs_histogram_radar_distinguish(
1295
void *dm_void)
1296
{
1297
struct dm_struct *dm = (struct dm_struct *)dm_void;
1298
struct _DFS_STATISTICS *dfs = &dm->dfs;
1299
u8 region_domain = dm->dfs_region_domain;
1300
u8 c_channel = *dm->channel;
1301
u8 band_width = *dm->band_width;
1302
1303
u8 dfs_pw_thd1 = 0, dfs_pw_thd2 = 0, dfs_pw_thd3 = 0;
1304
u8 dfs_pw_thd4 = 0, dfs_pw_thd5 = 0;
1305
u8 dfs_pri_thd1 = 0, dfs_pri_thd2 = 0, dfs_pri_thd3 = 0;
1306
u8 dfs_pri_thd4 = 0, dfs_pri_thd5 = 0;
1307
u8 pri_th = 0, i = 0;
1308
u8 max_pri_idx = 0, max_pw_idx = 0, max_pri_cnt_th = 0;
1309
u8 max_pri_cnt_fcc_g1_th = 0, max_pri_cnt_fcc_g3_th = 0;
1310
u8 safe_pri_pw_diff_th = 0, safe_pri_pw_diff_fcc_th = 0;
1311
u8 safe_pri_pw_diff_w53_th = 0, safe_pri_pw_diff_fcc_idle_th = 0;
1312
u16 j = 0;
1313
u32 dfs_hist1_peak_index = 0, dfs_hist2_peak_index = 0;
1314
u32 dfs_hist1_pw = 0, dfs_hist2_pw = 0, g_pw[6] = {0};
1315
u32 g_peakindex[16] = {0}, g_mask_32 = 0, false_peak_hist1 = 0;
1316
u32 false_peak_hist2_above10 = 0, false_peak_hist2_above0 = 0;
1317
u32 dfs_hist1_pri = 0, dfs_hist2_pri = 0, g_pri[6] = {0};
1318
u32 pw_sum_g0g5 = 0, pw_sum_g1g2g3g4 = 0;
1319
u32 pri_sum_g0g5 = 0, pri_sum_g1g2g3g4 = 0;
1320
u32 pw_sum_ss_g1g2g3g4 = 0, pri_sum_ss_g1g2g3g4 = 0;
1321
u32 max_pri_cnt = 0, max_pw_cnt = 0;
1322
#if (RTL8721D_SUPPORT)
1323
if (dm->support_ic_type & (ODM_RTL8721D))
1324
return;
1325
#endif
1326
1327
/*read peak index hist report*/
1328
odm_set_bb_reg(dm, 0x19e4, BIT(22) | BIT(23), 0x0);
1329
dfs_hist1_peak_index = odm_get_bb_reg(dm, 0xf5c, 0xffffffff);
1330
dfs_hist2_peak_index = odm_get_bb_reg(dm, 0xf74, 0xffffffff);
1331
1332
g_peakindex[15] = ((dfs_hist1_peak_index & 0x0000000f) >> 0);
1333
g_peakindex[14] = ((dfs_hist1_peak_index & 0x000000f0) >> 4);
1334
g_peakindex[13] = ((dfs_hist1_peak_index & 0x00000f00) >> 8);
1335
g_peakindex[12] = ((dfs_hist1_peak_index & 0x0000f000) >> 12);
1336
g_peakindex[11] = ((dfs_hist1_peak_index & 0x000f0000) >> 16);
1337
g_peakindex[10] = ((dfs_hist1_peak_index & 0x00f00000) >> 20);
1338
g_peakindex[9] = ((dfs_hist1_peak_index & 0x0f000000) >> 24);
1339
g_peakindex[8] = ((dfs_hist1_peak_index & 0xf0000000) >> 28);
1340
g_peakindex[7] = ((dfs_hist2_peak_index & 0x0000000f) >> 0);
1341
g_peakindex[6] = ((dfs_hist2_peak_index & 0x000000f0) >> 4);
1342
g_peakindex[5] = ((dfs_hist2_peak_index & 0x00000f00) >> 8);
1343
g_peakindex[4] = ((dfs_hist2_peak_index & 0x0000f000) >> 12);
1344
g_peakindex[3] = ((dfs_hist2_peak_index & 0x000f0000) >> 16);
1345
g_peakindex[2] = ((dfs_hist2_peak_index & 0x00f00000) >> 20);
1346
g_peakindex[1] = ((dfs_hist2_peak_index & 0x0f000000) >> 24);
1347
g_peakindex[0] = ((dfs_hist2_peak_index & 0xf0000000) >> 28);
1348
1349
/*read pulse width hist report*/
1350
odm_set_bb_reg(dm, 0x19e4, BIT(22) | BIT(23), 0x1);
1351
dfs_hist1_pw = odm_get_bb_reg(dm, 0xf5c, 0xffffffff);
1352
dfs_hist2_pw = odm_get_bb_reg(dm, 0xf74, 0xffffffff);
1353
1354
g_pw[0] = (unsigned int)((dfs_hist2_pw & 0xff000000) >> 24);
1355
g_pw[1] = (unsigned int)((dfs_hist2_pw & 0x00ff0000) >> 16);
1356
g_pw[2] = (unsigned int)((dfs_hist2_pw & 0x0000ff00) >> 8);
1357
g_pw[3] = (unsigned int)dfs_hist2_pw & 0x000000ff;
1358
g_pw[4] = (unsigned int)((dfs_hist1_pw & 0xff000000) >> 24);
1359
g_pw[5] = (unsigned int)((dfs_hist1_pw & 0x00ff0000) >> 16);
1360
1361
/*read pulse repetition interval hist report*/
1362
odm_set_bb_reg(dm, 0x19e4, BIT(22) | BIT(23), 0x3);
1363
dfs_hist1_pri = odm_get_bb_reg(dm, 0xf5c, 0xffffffff);
1364
dfs_hist2_pri = odm_get_bb_reg(dm, 0xf74, 0xffffffff);
1365
odm_set_bb_reg(dm, 0x19b4, 0x10000000, 1); /*reset histo report*/
1366
odm_set_bb_reg(dm, 0x19b4, 0x10000000, 0); /*@continue histo report*/
1367
1368
g_pri[0] = (unsigned int)((dfs_hist2_pri & 0xff000000) >> 24);
1369
g_pri[1] = (unsigned int)((dfs_hist2_pri & 0x00ff0000) >> 16);
1370
g_pri[2] = (unsigned int)((dfs_hist2_pri & 0x0000ff00) >> 8);
1371
g_pri[3] = (unsigned int)dfs_hist2_pri & 0x000000ff;
1372
g_pri[4] = (unsigned int)((dfs_hist1_pri & 0xff000000) >> 24);
1373
g_pri[5] = (unsigned int)((dfs_hist1_pri & 0x00ff0000) >> 16);
1374
1375
dfs->pri_cond1 = 0;
1376
dfs->pri_cond2 = 0;
1377
dfs->pri_cond3 = 0;
1378
dfs->pri_cond4 = 0;
1379
dfs->pri_cond5 = 0;
1380
dfs->pw_cond1 = 0;
1381
dfs->pw_cond2 = 0;
1382
dfs->pw_cond3 = 0;
1383
dfs->pri_type3_4_cond1 = 0; /*@for ETSI*/
1384
dfs->pri_type3_4_cond2 = 0; /*@for ETSI*/
1385
dfs->pw_long_cond1 = 0; /*@for long radar*/
1386
dfs->pw_long_cond2 = 0; /*@for long radar*/
1387
dfs->pri_long_cond1 = 0; /*@for long radar*/
1388
dfs->pw_flag = 0;
1389
dfs->pri_flag = 0;
1390
dfs->pri_type3_4_flag = 0; /*@for ETSI*/
1391
dfs->long_radar_flag = 0;
1392
dfs->pw_std = 0; /*The std(var) of reasonable num of pw group*/
1393
dfs->pri_std = 0; /*The std(var) of reasonable num of pri group*/
1394
1395
for (i = 0; i < 6; i++) {
1396
dfs->pw_hold_sum[i] = 0;
1397
dfs->pri_hold_sum[i] = 0;
1398
dfs->pw_long_hold_sum[i] = 0;
1399
dfs->pri_long_hold_sum[i] = 0;
1400
}
1401
1402
if (dfs->idle_mode == 1)
1403
pri_th = dfs->pri_hist_th;
1404
else
1405
pri_th = dfs->pri_hist_th - 1;
1406
1407
for (i = 0; i < 6; i++) {
1408
dfs->pw_hold[dfs->hist_idx][i] = (u8)g_pw[i];
1409
dfs->pri_hold[dfs->hist_idx][i] = (u8)g_pri[i];
1410
/*@collect whole histogram report may take some time
1411
*so we add the counter of 2 time slots in FCC and ETSI
1412
*/
1413
if (region_domain == 1 || region_domain == 3) {
1414
dfs->pw_hold_sum[i] = dfs->pw_hold_sum[i] +
1415
dfs->pw_hold[(dfs->hist_idx + 1) % 3][i] +
1416
dfs->pw_hold[(dfs->hist_idx + 2) % 3][i];
1417
dfs->pri_hold_sum[i] = dfs->pri_hold_sum[i] +
1418
dfs->pri_hold[(dfs->hist_idx + 1) % 3][i] +
1419
dfs->pri_hold[(dfs->hist_idx + 2) % 3][i];
1420
} else{
1421
/*@collect whole histogram report may take some time,
1422
*so we add the counter of 3 time slots in MKK or else
1423
*/
1424
dfs->pw_hold_sum[i] = dfs->pw_hold_sum[i] +
1425
dfs->pw_hold[(dfs->hist_idx + 1) % 4][i] +
1426
dfs->pw_hold[(dfs->hist_idx + 2) % 4][i] +
1427
dfs->pw_hold[(dfs->hist_idx + 3) % 4][i];
1428
dfs->pri_hold_sum[i] = dfs->pri_hold_sum[i] +
1429
dfs->pri_hold[(dfs->hist_idx + 1) % 4][i] +
1430
dfs->pri_hold[(dfs->hist_idx + 2) % 4][i] +
1431
dfs->pri_hold[(dfs->hist_idx + 3) % 4][i];
1432
}
1433
}
1434
/*@For long radar type*/
1435
for (i = 0; i < 6; i++) {
1436
dfs->pw_long_hold[dfs->hist_long_idx][i] = (u8)g_pw[i];
1437
dfs->pri_long_hold[dfs->hist_long_idx][i] = (u8)g_pri[i];
1438
/*@collect whole histogram report may take some time,
1439
*so we add the counter of 299 time slots for long radar
1440
*/
1441
for (j = 1; j < 300; j++) {
1442
dfs->pw_long_hold_sum[i] = dfs->pw_long_hold_sum[i] +
1443
dfs->pw_long_hold[(dfs->hist_long_idx + j) % 300][i];
1444
dfs->pri_long_hold_sum[i] = dfs->pri_long_hold_sum[i] +
1445
dfs->pri_long_hold[(dfs->hist_long_idx + j) % 300][i];
1446
}
1447
}
1448
dfs->hist_idx++;
1449
dfs->hist_long_idx++;
1450
if (dfs->hist_long_idx == 300)
1451
dfs->hist_long_idx = 0;
1452
if (region_domain == 1 || region_domain == 3) {
1453
if (dfs->hist_idx == 3)
1454
dfs->hist_idx = 0;
1455
} else if (dfs->hist_idx == 4) {
1456
dfs->hist_idx = 0;
1457
}
1458
1459
max_pri_cnt = 0;
1460
max_pri_idx = 0;
1461
max_pw_cnt = 0;
1462
max_pw_idx = 0;
1463
max_pri_cnt_th = dfs->pri_sum_g1_th;
1464
max_pri_cnt_fcc_g1_th = dfs->pri_sum_g1_fcc_th;
1465
max_pri_cnt_fcc_g3_th = dfs->pri_sum_g3_fcc_th;
1466
safe_pri_pw_diff_th = dfs->pri_pw_diff_th;
1467
safe_pri_pw_diff_fcc_th = dfs->pri_pw_diff_fcc_th;
1468
safe_pri_pw_diff_fcc_idle_th = dfs->pri_pw_diff_fcc_idle_th;
1469
safe_pri_pw_diff_w53_th = dfs->pri_pw_diff_w53_th;
1470
1471
/*@g1 to g4 is the reseasonable range of pri and pw*/
1472
for (i = 1; i <= 4; i++) {
1473
if (dfs->pri_hold_sum[i] > max_pri_cnt) {
1474
max_pri_cnt = dfs->pri_hold_sum[i];
1475
max_pri_idx = i;
1476
}
1477
if (dfs->pw_hold_sum[i] > max_pw_cnt) {
1478
max_pw_cnt = dfs->pw_hold_sum[i];
1479
max_pw_idx = i;
1480
}
1481
if (dfs->pri_hold_sum[i] >= pri_th)
1482
dfs->pri_cond1 = 1;
1483
}
1484
1485
pri_sum_g0g5 = dfs->pri_hold_sum[0];
1486
if (pri_sum_g0g5 == 0)
1487
pri_sum_g0g5 = 1;
1488
pri_sum_g1g2g3g4 = dfs->pri_hold_sum[1] + dfs->pri_hold_sum[2]
1489
+ dfs->pri_hold_sum[3] + dfs->pri_hold_sum[4];
1490
1491
/*pw will reduce because of dc, so we do not treat g0 as illegal group*/
1492
pw_sum_g0g5 = dfs->pw_hold_sum[5];
1493
if (pw_sum_g0g5 == 0)
1494
pw_sum_g0g5 = 1;
1495
pw_sum_g1g2g3g4 = dfs->pw_hold_sum[1] + dfs->pw_hold_sum[2] +
1496
dfs->pw_hold_sum[3] + dfs->pw_hold_sum[4];
1497
1498
/*@Calculate the variation from g1 to g4*/
1499
for (i = 1; i < 5; i++) {
1500
/*Sum of square*/
1501
pw_sum_ss_g1g2g3g4 = pw_sum_ss_g1g2g3g4 +
1502
(dfs->pw_hold_sum[i] - (pw_sum_g1g2g3g4 / 4)) *
1503
(dfs->pw_hold_sum[i] - (pw_sum_g1g2g3g4 / 4));
1504
pri_sum_ss_g1g2g3g4 = pri_sum_ss_g1g2g3g4 +
1505
(dfs->pri_hold_sum[i] - (pri_sum_g1g2g3g4 / 4)) *
1506
(dfs->pri_hold_sum[i] - (pri_sum_g1g2g3g4 / 4));
1507
}
1508
/*The value may less than the normal variance,
1509
*since the variable type is int (not float)
1510
*/
1511
dfs->pw_std = (u16)(pw_sum_ss_g1g2g3g4 / 4);
1512
dfs->pri_std = (u16)(pri_sum_ss_g1g2g3g4 / 4);
1513
1514
if (region_domain == 1) {
1515
dfs->pri_type3_4_flag = 1; /*@ETSI flag*/
1516
1517
/*PRI judgment conditions for short radar type*/
1518
/*ratio of reasonable group and illegal group &&
1519
*pri variation of short radar should be large (=6)
1520
*/
1521
if (max_pri_idx != 4 && dfs->pri_hold_sum[5] > 0)
1522
dfs->pri_cond2 = 0;
1523
else
1524
dfs->pri_cond2 = 1;
1525
1526
/*reasonable group shouldn't large*/
1527
if ((pri_sum_g0g5 + pri_sum_g1g2g3g4) / pri_sum_g0g5 > 2 &&
1528
pri_sum_g1g2g3g4 <= dfs->pri_sum_safe_fcc_th)
1529
dfs->pri_cond3 = 1;
1530
1531
/*@Cancel the condition that the abs between pri and pw*/
1532
if (dfs->pri_std >= dfs->pri_std_th)
1533
dfs->pri_cond4 = 1;
1534
else if (max_pri_idx == 1 &&
1535
max_pri_cnt >= max_pri_cnt_fcc_g1_th)
1536
dfs->pri_cond4 = 1;
1537
1538
/*we set threshold = 7 (>4) for distinguishing type 3,4 (g3)*/
1539
if (max_pri_idx == 1 && dfs->pri_hold_sum[3] +
1540
dfs->pri_hold_sum[4] + dfs->pri_hold_sum[5] > 0)
1541
dfs->pri_cond5 = 0;
1542
else
1543
dfs->pri_cond5 = 1;
1544
1545
if (dfs->pri_cond1 && dfs->pri_cond2 && dfs->pri_cond3 &&
1546
dfs->pri_cond4 && dfs->pri_cond5)
1547
dfs->pri_flag = 1;
1548
1549
/* PW judgment conditions for short radar type */
1550
/*ratio of reasonable and illegal group && g5 should be zero*/
1551
if (((pw_sum_g0g5 + pw_sum_g1g2g3g4) / pw_sum_g0g5 > 2) &&
1552
(dfs->pw_hold_sum[5] <= 1))
1553
dfs->pw_cond1 = 1;
1554
/*unreasonable group*/
1555
if (dfs->pw_hold_sum[4] == 0 && dfs->pw_hold_sum[5] == 0)
1556
dfs->pw_cond2 = 1;
1557
/*pw's std (short radar) should be large(=7)*/
1558
if (dfs->pw_std >= dfs->pw_std_th)
1559
dfs->pw_cond3 = 1;
1560
if (dfs->pw_cond1 && dfs->pw_cond2 && dfs->pw_cond3)
1561
dfs->pw_flag = 1;
1562
1563
/* @Judgment conditions of long radar type */
1564
if (band_width == CHANNEL_WIDTH_20) {
1565
if (dfs->pw_long_hold_sum[4] >=
1566
dfs->pw_long_lower_20m_th)
1567
dfs->pw_long_cond1 = 1;
1568
} else{
1569
if (dfs->pw_long_hold_sum[4] >= dfs->pw_long_lower_th)
1570
dfs->pw_long_cond1 = 1;
1571
}
1572
/* @Disable the condition that dfs->pw_long_hold_sum[1] */
1573
if (dfs->pw_long_hold_sum[2] + dfs->pw_long_hold_sum[3] +
1574
dfs->pw_long_hold_sum[4] <= dfs->pw_long_sum_upper_th &&
1575
dfs->pw_long_hold_sum[2] <= dfs->pw_long_hold_sum[4] &&
1576
dfs->pw_long_hold_sum[3] <= dfs->pw_long_hold_sum[4])
1577
dfs->pw_long_cond2 = 1;
1578
/*@g4 should be large for long radar*/
1579
if (dfs->pri_long_hold_sum[4] <= dfs->pri_long_upper_th)
1580
dfs->pri_long_cond1 = 1;
1581
if (dfs->pw_long_cond1 && dfs->pw_long_cond2 &&
1582
dfs->pri_long_cond1)
1583
dfs->long_radar_flag = 1;
1584
} else if (region_domain == 2) {
1585
dfs->pri_type3_4_flag = 1; /*@ETSI flag*/
1586
1587
/*PRI judgment conditions for short radar type*/
1588
if ((pri_sum_g0g5 + pri_sum_g1g2g3g4) / pri_sum_g0g5 > 2)
1589
dfs->pri_cond2 = 1;
1590
1591
/*reasonable group shouldn't too large*/
1592
if (pri_sum_g1g2g3g4 <= dfs->pri_sum_safe_fcc_th)
1593
dfs->pri_cond3 = 1;
1594
1595
/*Cancel the abs diff between pri and pw for idle mode (thr=2)*/
1596
dfs->pri_cond4 = 1;
1597
1598
if (dfs->idle_mode == 1) {
1599
if (dfs->pri_std >= dfs->pri_std_idle_th) {
1600
if (max_pw_idx == 3 &&
1601
pri_sum_g1g2g3g4 <= dfs->pri_sum_type4_th){
1602
/*To distinguish between type 4 radar and false detection*/
1603
dfs->pri_cond5 = 1;
1604
} else if (max_pw_idx == 1 &&
1605
pri_sum_g1g2g3g4 >=
1606
dfs->pri_sum_type6_th) {
1607
/*To distinguish between type 6 radar and false detection*/
1608
dfs->pri_cond5 = 1;
1609
} else {
1610
/*pri variation of short radar should be large (idle mode)*/
1611
dfs->pri_cond5 = 1;
1612
}
1613
}
1614
} else {
1615
/*pri variation of short radar should be large (TP mode)*/
1616
if (dfs->pri_std >= dfs->pri_std_th)
1617
dfs->pri_cond5 = 1;
1618
}
1619
1620
if (dfs->pri_cond1 && dfs->pri_cond2 && dfs->pri_cond3 &&
1621
dfs->pri_cond4 && dfs->pri_cond5)
1622
dfs->pri_flag = 1;
1623
1624
/* PW judgment conditions for short radar type */
1625
if (((pw_sum_g0g5 + pw_sum_g1g2g3g4) / pw_sum_g0g5 > 2) &&
1626
(dfs->pw_hold_sum[5] <= 1))
1627
/*ratio of reasonable and illegal group && g5 should be zero*/
1628
dfs->pw_cond1 = 1;
1629
1630
if ((c_channel >= 52) && (c_channel <= 64))
1631
dfs->pw_cond2 = 1;
1632
/*unreasonable group shouldn't too large*/
1633
else if (dfs->pw_hold_sum[0] <= dfs->pw_g0_th)
1634
dfs->pw_cond2 = 1;
1635
1636
if (dfs->idle_mode == 1) {
1637
/*pw variation of short radar should be large (idle mode)*/
1638
if (dfs->pw_std >= dfs->pw_std_idle_th)
1639
dfs->pw_cond3 = 1;
1640
} else {
1641
/*pw variation of short radar should be large (TP mode)*/
1642
if (dfs->pw_std >= dfs->pw_std_th)
1643
dfs->pw_cond3 = 1;
1644
}
1645
if (dfs->pw_cond1 && dfs->pw_cond2 && dfs->pw_cond3)
1646
dfs->pw_flag = 1;
1647
1648
/* @Judgment conditions of long radar type */
1649
if (band_width == CHANNEL_WIDTH_20) {
1650
if (dfs->pw_long_hold_sum[4] >=
1651
dfs->pw_long_lower_20m_th)
1652
dfs->pw_long_cond1 = 1;
1653
} else{
1654
if (dfs->pw_long_hold_sum[4] >= dfs->pw_long_lower_th)
1655
dfs->pw_long_cond1 = 1;
1656
}
1657
if (dfs->pw_long_hold_sum[1] + dfs->pw_long_hold_sum[2] +
1658
dfs->pw_long_hold_sum[3] + dfs->pw_long_hold_sum[4]
1659
<= dfs->pw_long_sum_upper_th)
1660
dfs->pw_long_cond2 = 1;
1661
/*@g4 should be large for long radar*/
1662
if (dfs->pri_long_hold_sum[4] <= dfs->pri_long_upper_th)
1663
dfs->pri_long_cond1 = 1;
1664
if (dfs->pw_long_cond1 &&
1665
dfs->pw_long_cond2 && dfs->pri_long_cond1)
1666
dfs->long_radar_flag = 1;
1667
} else if (region_domain == 3) {
1668
/*ratio of reasonable group and illegal group */
1669
if ((pri_sum_g0g5 + pri_sum_g1g2g3g4) / pri_sum_g0g5 > 2)
1670
dfs->pri_cond2 = 1;
1671
1672
if (pri_sum_g1g2g3g4 <= dfs->pri_sum_safe_th)
1673
dfs->pri_cond3 = 1;
1674
1675
/*@Cancel the condition that the abs between pri and pw*/
1676
dfs->pri_cond4 = 1;
1677
1678
if (dfs->pri_hold_sum[5] <= dfs->pri_sum_g5_th)
1679
dfs->pri_cond5 = 1;
1680
1681
if (band_width == CHANNEL_WIDTH_40) {
1682
if (max_pw_idx == 4) {
1683
if (max_pw_cnt >= dfs->type4_pw_max_cnt &&
1684
pri_sum_g1g2g3g4 >=
1685
dfs->type4_safe_pri_sum_th) {
1686
dfs->pri_cond1 = 1;
1687
dfs->pri_cond4 = 1;
1688
dfs->pri_type3_4_cond1 = 1;
1689
}
1690
}
1691
}
1692
1693
if (dfs->pri_cond1 && dfs->pri_cond2 &&
1694
dfs->pri_cond3 && dfs->pri_cond4 && dfs->pri_cond5)
1695
dfs->pri_flag = 1;
1696
1697
if (((pw_sum_g0g5 + pw_sum_g1g2g3g4) / pw_sum_g0g5 > 2))
1698
dfs->pw_flag = 1;
1699
1700
/*@max num pri group is g1 means radar type3 or type4*/
1701
if (max_pri_idx == 1) {
1702
if (max_pri_cnt >= max_pri_cnt_th)
1703
dfs->pri_type3_4_cond1 = 1;
1704
if (dfs->pri_hold_sum[4] <=
1705
dfs->pri_sum_g5_under_g1_th &&
1706
dfs->pri_hold_sum[5] <= dfs->pri_sum_g5_under_g1_th)
1707
dfs->pri_type3_4_cond2 = 1;
1708
} else {
1709
dfs->pri_type3_4_cond1 = 1;
1710
dfs->pri_type3_4_cond2 = 1;
1711
}
1712
if (dfs->pri_type3_4_cond1 && dfs->pri_type3_4_cond2)
1713
dfs->pri_type3_4_flag = 1;
1714
} else {
1715
}
1716
1717
if (dfs->print_hist_rpt) {
1718
dfs_pw_thd1 = (u8)odm_get_bb_reg(dm, 0x19e4, 0xff000000);
1719
dfs_pw_thd2 = (u8)odm_get_bb_reg(dm, 0x19e8, 0x000000ff);
1720
dfs_pw_thd3 = (u8)odm_get_bb_reg(dm, 0x19e8, 0x0000ff00);
1721
dfs_pw_thd4 = (u8)odm_get_bb_reg(dm, 0x19e8, 0x00ff0000);
1722
dfs_pw_thd5 = (u8)odm_get_bb_reg(dm, 0x19e8, 0xff000000);
1723
1724
dfs_pri_thd1 = (u8)odm_get_bb_reg(dm, 0x19b8, 0x7F80);
1725
dfs_pri_thd2 = (u8)odm_get_bb_reg(dm, 0x19ec, 0x000000ff);
1726
dfs_pri_thd3 = (u8)odm_get_bb_reg(dm, 0x19ec, 0x0000ff00);
1727
dfs_pri_thd4 = (u8)odm_get_bb_reg(dm, 0x19ec, 0x00ff0000);
1728
dfs_pri_thd5 = (u8)odm_get_bb_reg(dm, 0x19ec, 0xff000000);
1729
1730
PHYDM_DBG(dm, DBG_DFS, "peak index hist\n");
1731
PHYDM_DBG(dm, DBG_DFS, "dfs_hist_peak_index=%x %x\n",
1732
dfs_hist1_peak_index, dfs_hist2_peak_index);
1733
PHYDM_DBG(dm, DBG_DFS, "g_peak_index_hist = ");
1734
for (i = 0; i < 16; i++)
1735
PHYDM_DBG(dm, DBG_DFS, " %x", g_peakindex[i]);
1736
PHYDM_DBG(dm, DBG_DFS, "\ndfs_pw_thd=%d %d %d %d %d\n",
1737
dfs_pw_thd1, dfs_pw_thd2, dfs_pw_thd3,
1738
dfs_pw_thd4, dfs_pw_thd5);
1739
PHYDM_DBG(dm, DBG_DFS, "-----pulse width hist-----\n");
1740
PHYDM_DBG(dm, DBG_DFS, "dfs_hist_pw=%x %x\n",
1741
dfs_hist1_pw, dfs_hist2_pw);
1742
PHYDM_DBG(dm, DBG_DFS, "g_pw_hist = %x %x %x %x %x %x\n",
1743
g_pw[0], g_pw[1], g_pw[2], g_pw[3],
1744
g_pw[4], g_pw[5]);
1745
PHYDM_DBG(dm, DBG_DFS, "dfs_pri_thd=%d %d %d %d %d\n",
1746
dfs_pri_thd1, dfs_pri_thd2, dfs_pri_thd3,
1747
dfs_pri_thd4, dfs_pri_thd5);
1748
PHYDM_DBG(dm, DBG_DFS, "-----pulse interval hist-----\n");
1749
PHYDM_DBG(dm, DBG_DFS, "dfs_hist_pri=%x %x\n",
1750
dfs_hist1_pri, dfs_hist2_pri);
1751
PHYDM_DBG(dm, DBG_DFS,
1752
"g_pri_hist = %x %x %x %x %x %x, pw_flag = %d, pri_flag = %d\n",
1753
g_pri[0], g_pri[1], g_pri[2], g_pri[3], g_pri[4],
1754
g_pri[5], dfs->pw_flag, dfs->pri_flag);
1755
if (region_domain == 1 || region_domain == 3) {
1756
PHYDM_DBG(dm, DBG_DFS, "hist_idx= %d\n",
1757
(dfs->hist_idx + 2) % 3);
1758
} else {
1759
PHYDM_DBG(dm, DBG_DFS, "hist_idx= %d\n",
1760
(dfs->hist_idx + 3) % 4);
1761
}
1762
PHYDM_DBG(dm, DBG_DFS, "hist_long_idx= %d\n",
1763
(dfs->hist_long_idx + 299) % 300);
1764
PHYDM_DBG(dm, DBG_DFS,
1765
"pw_sum_g0g5 = %d, pw_sum_g1g2g3g4 = %d\n",
1766
pw_sum_g0g5, pw_sum_g1g2g3g4);
1767
PHYDM_DBG(dm, DBG_DFS,
1768
"pri_sum_g0g5 = %d, pri_sum_g1g2g3g4 = %d\n",
1769
pri_sum_g0g5, pri_sum_g1g2g3g4);
1770
PHYDM_DBG(dm, DBG_DFS, "pw_hold_sum = %d %d %d %d %d %d\n",
1771
dfs->pw_hold_sum[0], dfs->pw_hold_sum[1],
1772
dfs->pw_hold_sum[2], dfs->pw_hold_sum[3],
1773
dfs->pw_hold_sum[4], dfs->pw_hold_sum[5]);
1774
PHYDM_DBG(dm, DBG_DFS, "pri_hold_sum = %d %d %d %d %d %d\n",
1775
dfs->pri_hold_sum[0], dfs->pri_hold_sum[1],
1776
dfs->pri_hold_sum[2], dfs->pri_hold_sum[3],
1777
dfs->pri_hold_sum[4], dfs->pri_hold_sum[5]);
1778
PHYDM_DBG(dm, DBG_DFS, "pw_long_hold_sum = %d %d %d %d %d %d\n",
1779
dfs->pw_long_hold_sum[0], dfs->pw_long_hold_sum[1],
1780
dfs->pw_long_hold_sum[2], dfs->pw_long_hold_sum[3],
1781
dfs->pw_long_hold_sum[4], dfs->pw_long_hold_sum[5]);
1782
PHYDM_DBG(dm, DBG_DFS,
1783
"pri_long_hold_sum = %d %d %d %d %d %d\n",
1784
dfs->pri_long_hold_sum[0], dfs->pri_long_hold_sum[1],
1785
dfs->pri_long_hold_sum[2], dfs->pri_long_hold_sum[3],
1786
dfs->pri_long_hold_sum[4], dfs->pri_long_hold_sum[5]);
1787
PHYDM_DBG(dm, DBG_DFS, "idle_mode = %d\n", dfs->idle_mode);
1788
PHYDM_DBG(dm, DBG_DFS, "pw_standard = %d\n", dfs->pw_std);
1789
PHYDM_DBG(dm, DBG_DFS, "pri_standard = %d\n", dfs->pri_std);
1790
for (j = 0; j < 4; j++) {
1791
for (i = 0; i < 6; i++) {
1792
PHYDM_DBG(dm, DBG_DFS, "pri_hold = %d ",
1793
dfs->pri_hold[j][i]);
1794
}
1795
PHYDM_DBG(dm, DBG_DFS, "\n");
1796
}
1797
PHYDM_DBG(dm, DBG_DFS, "\n");
1798
PHYDM_DBG(dm, DBG_DFS,
1799
"pri_cond1 = %d, pri_cond2 = %d, pri_cond3 = %d, pri_cond4 = %d, pri_cond5 = %d\n",
1800
dfs->pri_cond1, dfs->pri_cond2, dfs->pri_cond3,
1801
dfs->pri_cond4, dfs->pri_cond5);
1802
PHYDM_DBG(dm, DBG_DFS,
1803
"bandwidth = %d, pri_th = %d, max_pri_cnt_th = %d, safe_pri_pw_diff_th = %d\n",
1804
band_width, pri_th, max_pri_cnt_th,
1805
safe_pri_pw_diff_th);
1806
}
1807
}
1808
1809
boolean phydm_dfs_hist_log(void *dm_void, u8 index)
1810
{
1811
struct dm_struct *dm = (struct dm_struct *)dm_void;
1812
struct _DFS_STATISTICS *dfs = &dm->dfs;
1813
u8 i = 0, j = 0;
1814
boolean hist_radar_detected = 0;
1815
1816
if (dfs->pulse_type_hist[index] == 0) {
1817
dfs->radar_type = 0;
1818
if (dfs->pw_flag && dfs->pri_flag &&
1819
dfs->pri_type3_4_flag) {
1820
hist_radar_detected = 1;
1821
PHYDM_DBG(dm, DBG_DFS,
1822
"Detected type %d radar signal!\n",
1823
dfs->radar_type);
1824
if (dfs->det_print2) {
1825
PHYDM_DBG(dm, DBG_DFS,
1826
"hist_idx= %d\n",
1827
(dfs->hist_idx + 3) % 4);
1828
for (j = 0; j < 4; j++) {
1829
for (i = 0; i < 6; i++) {
1830
PHYDM_DBG(dm, DBG_DFS,
1831
"pri_hold = %d ",
1832
dfs->pri_hold[j][i]);
1833
}
1834
PHYDM_DBG(dm, DBG_DFS, "\n");
1835
}
1836
PHYDM_DBG(dm, DBG_DFS, "\n");
1837
for (j = 0; j < 4; j++) {
1838
for (i = 0; i < 6; i++) {
1839
PHYDM_DBG(dm, DBG_DFS, "pw_hold = %d ",
1840
dfs->pw_hold[j][i]);
1841
}
1842
PHYDM_DBG(dm, DBG_DFS, "\n");
1843
}
1844
PHYDM_DBG(dm, DBG_DFS, "\n");
1845
PHYDM_DBG(dm, DBG_DFS, "idle_mode = %d\n",
1846
dfs->idle_mode);
1847
PHYDM_DBG(dm, DBG_DFS,
1848
"pw_hold_sum = %d %d %d %d %d %d\n",
1849
dfs->pw_hold_sum[0],
1850
dfs->pw_hold_sum[1],
1851
dfs->pw_hold_sum[2],
1852
dfs->pw_hold_sum[3],
1853
dfs->pw_hold_sum[4],
1854
dfs->pw_hold_sum[5]);
1855
PHYDM_DBG(dm, DBG_DFS,
1856
"pri_hold_sum = %d %d %d %d %d %d\n",
1857
dfs->pri_hold_sum[0],
1858
dfs->pri_hold_sum[1],
1859
dfs->pri_hold_sum[2],
1860
dfs->pri_hold_sum[3],
1861
dfs->pri_hold_sum[4],
1862
dfs->pri_hold_sum[5]);
1863
}
1864
} else {
1865
if (dfs->det_print2) {
1866
if (dfs->pulse_flag_hist[index] &&
1867
dfs->pri_flag == 0) {
1868
PHYDM_DBG(dm, DBG_DFS, "pri_variation = %d\n",
1869
dfs->pri_std);
1870
PHYDM_DBG(dm, DBG_DFS,
1871
"PRI criterion is not satisfied!\n");
1872
if (dfs->pri_cond1 == 0)
1873
PHYDM_DBG(dm, DBG_DFS,
1874
"pri_cond1 is not satisfied!\n");
1875
if (dfs->pri_cond2 == 0)
1876
PHYDM_DBG(dm, DBG_DFS,
1877
"pri_cond2 is not satisfied!\n");
1878
if (dfs->pri_cond3 == 0)
1879
PHYDM_DBG(dm, DBG_DFS,
1880
"pri_cond3 is not satisfied!\n");
1881
if (dfs->pri_cond4 == 0)
1882
PHYDM_DBG(dm, DBG_DFS,
1883
"pri_cond4 is not satisfied!\n");
1884
if (dfs->pri_cond5 == 0)
1885
PHYDM_DBG(dm, DBG_DFS,
1886
"pri_cond5 is not satisfied!\n");
1887
}
1888
if (dfs->pulse_flag_hist[index] &&
1889
dfs->pw_flag == 0) {
1890
PHYDM_DBG(dm, DBG_DFS, "pw_variation = %d\n",
1891
dfs->pw_std);
1892
PHYDM_DBG(dm, DBG_DFS,
1893
"PW criterion is not satisfied!\n");
1894
if (dfs->pw_cond1 == 0)
1895
PHYDM_DBG(dm, DBG_DFS,
1896
"pw_cond1 is not satisfied!\n");
1897
if (dfs->pw_cond2 == 0)
1898
PHYDM_DBG(dm, DBG_DFS,
1899
"pw_cond2 is not satisfied!\n");
1900
if (dfs->pw_cond3 == 0)
1901
PHYDM_DBG(dm, DBG_DFS,
1902
"pw_cond3 is not satisfied!\n");
1903
}
1904
if (dfs->pulse_flag_hist[index] &&
1905
(dfs->pri_type3_4_flag == 0)) {
1906
PHYDM_DBG(dm, DBG_DFS,
1907
"pri_type3_4 criterion is not satisfied!\n");
1908
if (dfs->pri_type3_4_cond1 == 0)
1909
PHYDM_DBG(dm, DBG_DFS,
1910
"pri_type3_4_cond1 is not satisfied!\n");
1911
if (dfs->pri_type3_4_cond2 == 0)
1912
PHYDM_DBG(dm, DBG_DFS,
1913
"pri_type3_4_cond2 is not satisfied!\n");
1914
}
1915
PHYDM_DBG(dm, DBG_DFS, "hist_idx= %d\n",
1916
(dfs->hist_idx + 3) % 4);
1917
for (j = 0; j < 4; j++) {
1918
for (i = 0; i < 6; i++) {
1919
PHYDM_DBG(dm, DBG_DFS,
1920
"pri_hold = %d ",
1921
dfs->pri_hold[j][i]);
1922
}
1923
PHYDM_DBG(dm, DBG_DFS, "\n");
1924
}
1925
PHYDM_DBG(dm, DBG_DFS, "\n");
1926
for (j = 0; j < 4; j++) {
1927
for (i = 0; i < 6; i++)
1928
PHYDM_DBG(dm, DBG_DFS,
1929
"pw_hold = %d ",
1930
dfs->pw_hold[j][i]);
1931
PHYDM_DBG(dm, DBG_DFS, "\n");
1932
}
1933
PHYDM_DBG(dm, DBG_DFS, "\n");
1934
PHYDM_DBG(dm, DBG_DFS, "idle_mode = %d\n",
1935
dfs->idle_mode);
1936
PHYDM_DBG(dm, DBG_DFS,
1937
"pw_hold_sum = %d %d %d %d %d %d\n",
1938
dfs->pw_hold_sum[0], dfs->pw_hold_sum[1],
1939
dfs->pw_hold_sum[2], dfs->pw_hold_sum[3],
1940
dfs->pw_hold_sum[4], dfs->pw_hold_sum[5]);
1941
PHYDM_DBG(dm, DBG_DFS,
1942
"pri_hold_sum = %d %d %d %d %d %d\n",
1943
dfs->pri_hold_sum[0], dfs->pri_hold_sum[1],
1944
dfs->pri_hold_sum[2], dfs->pri_hold_sum[3],
1945
dfs->pri_hold_sum[4], dfs->pri_hold_sum[5]);
1946
}
1947
}
1948
} else {
1949
dfs->radar_type = 1;
1950
if (dfs->det_print2) {
1951
PHYDM_DBG(dm, DBG_DFS, "\n");
1952
PHYDM_DBG(dm, DBG_DFS, "idle_mode = %d\n",
1953
dfs->idle_mode);
1954
PHYDM_DBG(dm, DBG_DFS,
1955
"long_radar_pw_hold_sum = %d %d %d %d %d %d\n",
1956
dfs->pw_long_hold_sum[0],
1957
dfs->pw_long_hold_sum[1],
1958
dfs->pw_long_hold_sum[2],
1959
dfs->pw_long_hold_sum[3],
1960
dfs->pw_long_hold_sum[4],
1961
dfs->pw_long_hold_sum[5]);
1962
PHYDM_DBG(dm, DBG_DFS,
1963
"long_radar_pri_hold_sum = %d %d %d %d %d %d\n",
1964
dfs->pri_long_hold_sum[0],
1965
dfs->pri_long_hold_sum[1],
1966
dfs->pri_long_hold_sum[2],
1967
dfs->pri_long_hold_sum[3],
1968
dfs->pri_long_hold_sum[4],
1969
dfs->pri_long_hold_sum[5]);
1970
}
1971
/* @Long radar should satisfy three conditions */
1972
if (dfs->long_radar_flag == 1) {
1973
hist_radar_detected = 1;
1974
PHYDM_DBG(dm, DBG_DFS,
1975
"Detected type %d radar signal!\n",
1976
dfs->radar_type);
1977
} else {
1978
if (dfs->det_print2) {
1979
if (dfs->pw_long_cond1 == 0)
1980
PHYDM_DBG(dm, DBG_DFS,
1981
"--pw_long_cond1 is not satisfied!--\n");
1982
if (dfs->pw_long_cond2 == 0)
1983
PHYDM_DBG(dm, DBG_DFS,
1984
"--pw_long_cond2 is not satisfied!--\n");
1985
if (dfs->pri_long_cond1 == 0)
1986
PHYDM_DBG(dm, DBG_DFS,
1987
"--pri_long_cond1 is not satisfied!--\n");
1988
}
1989
}
1990
}
1991
return hist_radar_detected;
1992
}
1993
1994
boolean phydm_radar_detect(void *dm_void)
1995
{
1996
struct dm_struct *dm = (struct dm_struct *)dm_void;
1997
struct _DFS_STATISTICS *dfs = &dm->dfs;
1998
boolean enable_DFS = false;
1999
boolean radar_detected = false;
2000
2001
if (dm->support_ic_type & ODM_IC_JGR3_SERIES) {
2002
dfs->igi_cur = (u8)odm_get_bb_reg(dm, R_0x1d70, 0x0000007f);
2003
dfs->st_l2h_cur = (u8)odm_get_bb_reg(dm, R_0xa40, 0x00007f00);
2004
#if (RTL8721D_SUPPORT)
2005
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
2006
dfs->st_l2h_cur = (u8)(odm_get_bb_reg(dm, R_0xf54,
2007
0x0000001f) << 2);
2008
dfs->st_l2h_cur += (u8)odm_get_bb_reg(dm, R_0xf58, 0xc0000000);
2009
#endif
2010
} else {
2011
dfs->igi_cur = (u8)odm_get_bb_reg(dm, R_0xc50, 0x0000007f);
2012
dfs->st_l2h_cur = (u8)odm_get_bb_reg(dm, R_0x91c, 0x000000ff);
2013
}
2014
2015
/* @dynamic pwdb calibration */
2016
if (dfs->igi_pre != dfs->igi_cur) {
2017
dfs->pwdb_th_cur = ((int)dfs->st_l2h_cur - (int)dfs->igi_cur)
2018
/ 2 + dfs->pwdb_scalar_factor;
2019
2020
/* @limit the pwdb value to absolute lower bound 0xa */
2021
dfs->pwdb_th_cur = MAX_2(dfs->pwdb_th_cur, (int)dfs->pwdb_th);
2022
/* @limit the pwdb value to absolute upper bound 0x1f */
2023
dfs->pwdb_th_cur = MIN_2(dfs->pwdb_th_cur, 0x1f);
2024
2025
if (dm->support_ic_type & ODM_IC_JGR3_SERIES)
2026
odm_set_bb_reg(dm, R_0xa50, 0x000000f0,
2027
dfs->pwdb_th_cur);
2028
#if (RTL8721D_SUPPORT)
2029
else if (dm->support_ic_type & (ODM_RTL8721D))
2030
odm_set_bb_reg(dm, R_0xf70, 0x03c00000,
2031
dfs->pwdb_th_cur);
2032
#endif
2033
else
2034
odm_set_bb_reg(dm, R_0x918, 0x00001f00,
2035
dfs->pwdb_th_cur);
2036
}
2037
2038
dfs->igi_pre = dfs->igi_cur;
2039
2040
phydm_dfs_dynamic_setting(dm);
2041
if (dm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C))
2042
phydm_dfs_histogram_radar_distinguish(dm);
2043
radar_detected = phydm_radar_detect_dm_check(dm);
2044
2045
if (dm->support_ic_type & (ODM_RTL8198F | ODM_RTL8822C | ODM_RTL8812F |
2046
ODM_RTL8197G)) {
2047
if (odm_get_bb_reg(dm, R_0xa40, BIT(15)))
2048
enable_DFS = true;
2049
#if (RTL8721D_SUPPORT)
2050
} else if (dm->support_ic_type & (ODM_RTL8721D)) {
2051
if (odm_get_bb_reg(dm, R_0xf58, BIT(29)))
2052
enable_DFS = true;
2053
#endif
2054
} else if (dm->support_ic_type & (ODM_RTL8814B)) {
2055
if (dm->seg1_dfs_flag == 1) {
2056
if (odm_get_bb_reg(dm, R_0xa6c, BIT(15)))
2057
enable_DFS = true;
2058
} else if (odm_get_bb_reg(dm, R_0xa40, BIT(15)))
2059
enable_DFS = true;
2060
} else {
2061
if (odm_get_bb_reg(dm, R_0x924, BIT(15)))
2062
enable_DFS = true;
2063
}
2064
2065
if (enable_DFS && radar_detected) {
2066
PHYDM_DBG(dm, DBG_DFS,
2067
"Radar detect: enable_DFS:%d, radar_detected:%d\n",
2068
enable_DFS, radar_detected);
2069
phydm_radar_detect_reset(dm);
2070
if (dfs->dbg_mode == 1) {
2071
PHYDM_DBG(dm, DBG_DFS,
2072
"Radar is detected in DFS dbg mode.\n");
2073
radar_detected = 0;
2074
}
2075
}
2076
2077
if (enable_DFS && dfs->sw_trigger_mode == 1) {
2078
radar_detected = 1;
2079
PHYDM_DBG(dm, DBG_DFS,
2080
"Radar is detected in DFS SW trigger mode.\n");
2081
}
2082
2083
return enable_DFS && radar_detected;
2084
}
2085
2086
void phydm_dfs_hist_dbg(void *dm_void, char input[][16], u32 *_used,
2087
char *output, u32 *_out_len)
2088
{
2089
struct dm_struct *dm = (struct dm_struct *)dm_void;
2090
struct _DFS_STATISTICS *dfs = &dm->dfs;
2091
char help[] = "-h";
2092
u32 argv[30] = {0};
2093
u32 used = *_used;
2094
u32 out_len = *_out_len;
2095
u8 i;
2096
2097
if ((strcmp(input[1], help) == 0)) {
2098
PDM_SNPF(out_len, used, output + used, out_len - used,
2099
"{0} pri_hist_th = %d\n", dfs->pri_hist_th);
2100
PDM_SNPF(out_len, used, output + used, out_len - used,
2101
"{1} pri_sum_g1_th = %d\n", dfs->pri_sum_g1_th);
2102
PDM_SNPF(out_len, used, output + used, out_len - used,
2103
"{2} pri_sum_g5_th = %d\n", dfs->pri_sum_g5_th);
2104
PDM_SNPF(out_len, used, output + used, out_len - used,
2105
"{3} pri_sum_g1_fcc_th = %d\n",
2106
dfs->pri_sum_g1_fcc_th);
2107
PDM_SNPF(out_len, used, output + used, out_len - used,
2108
"{4} pri_sum_g3_fcc_th = %d\n",
2109
dfs->pri_sum_g3_fcc_th);
2110
PDM_SNPF(out_len, used, output + used, out_len - used,
2111
"{5} pri_sum_safe_fcc_th = %d\n",
2112
dfs->pri_sum_safe_fcc_th);
2113
PDM_SNPF(out_len, used, output + used, out_len - used,
2114
"{6} pri_sum_type4_th = %d\n", dfs->pri_sum_type4_th);
2115
PDM_SNPF(out_len, used, output + used, out_len - used,
2116
"{7} pri_sum_type6_th = %d\n", dfs->pri_sum_type6_th);
2117
PDM_SNPF(out_len, used, output + used, out_len - used,
2118
"{8} pri_sum_safe_th = %d\n", dfs->pri_sum_safe_th);
2119
PDM_SNPF(out_len, used, output + used, out_len - used,
2120
"{9} pri_sum_g5_under_g1_th = %d\n",
2121
dfs->pri_sum_g5_under_g1_th);
2122
PDM_SNPF(out_len, used, output + used, out_len - used,
2123
"{10} pri_pw_diff_th = %d\n", dfs->pri_pw_diff_th);
2124
PDM_SNPF(out_len, used, output + used, out_len - used,
2125
"{11} pri_pw_diff_fcc_th = %d\n",
2126
dfs->pri_pw_diff_fcc_th);
2127
PDM_SNPF(out_len, used, output + used, out_len - used,
2128
"{12} pri_pw_diff_fcc_idle_th = %d\n",
2129
dfs->pri_pw_diff_fcc_idle_th);
2130
PDM_SNPF(out_len, used, output + used, out_len - used,
2131
"{13} pri_pw_diff_w53_th = %d\n",
2132
dfs->pri_pw_diff_w53_th);
2133
PDM_SNPF(out_len, used, output + used, out_len - used,
2134
"{14} pri_type1_low_fcc_th = %d\n",
2135
dfs->pri_type1_low_fcc_th);
2136
PDM_SNPF(out_len, used, output + used, out_len - used,
2137
"{15} pri_type1_upp_fcc_th = %d\n",
2138
dfs->pri_type1_upp_fcc_th);
2139
PDM_SNPF(out_len, used, output + used, out_len - used,
2140
"{16} pri_type1_cen_fcc_th = %d\n",
2141
dfs->pri_type1_cen_fcc_th);
2142
PDM_SNPF(out_len, used, output + used, out_len - used,
2143
"{17} pw_g0_th = %d\n", dfs->pw_g0_th);
2144
PDM_SNPF(out_len, used, output + used, out_len - used,
2145
"{18} pw_long_lower_20m_th = %d\n",
2146
dfs->pw_long_lower_20m_th);
2147
PDM_SNPF(out_len, used, output + used, out_len - used,
2148
"{19} pw_long_lower_th = %d\n",
2149
dfs->pw_long_lower_th);
2150
PDM_SNPF(out_len, used, output + used, out_len - used,
2151
"{20} pri_long_upper_th = %d\n",
2152
dfs->pri_long_upper_th);
2153
PDM_SNPF(out_len, used, output + used, out_len - used,
2154
"{21} pw_long_sum_upper_th = %d\n",
2155
dfs->pw_long_sum_upper_th);
2156
PDM_SNPF(out_len, used, output + used, out_len - used,
2157
"{22} pw_std_th = %d\n", dfs->pw_std_th);
2158
PDM_SNPF(out_len, used, output + used, out_len - used,
2159
"{23} pw_std_idle_th = %d\n", dfs->pw_std_idle_th);
2160
PDM_SNPF(out_len, used, output + used, out_len - used,
2161
"{24} pri_std_th = %d\n", dfs->pri_std_th);
2162
PDM_SNPF(out_len, used, output + used, out_len - used,
2163
"{25} pri_std_idle_th = %d\n", dfs->pri_std_idle_th);
2164
PDM_SNPF(out_len, used, output + used, out_len - used,
2165
"{26} type4_pw_max_cnt = %d\n", dfs->type4_pw_max_cnt);
2166
PDM_SNPF(out_len, used, output + used, out_len - used,
2167
"{27} type4_safe_pri_sum_th = %d\n",
2168
dfs->type4_safe_pri_sum_th);
2169
} else {
2170
PHYDM_SSCANF(input[1], DCMD_DECIMAL, &argv[0]);
2171
2172
for (i = 1; i < 30; i++) {
2173
if (input[i + 1])
2174
PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL,
2175
&argv[i]);
2176
}
2177
if (argv[0] == 0) {
2178
dfs->pri_hist_th = (u8)argv[1];
2179
PDM_SNPF(out_len, used, output + used, out_len - used,
2180
"pri_hist_th = %d\n",
2181
dfs->pri_hist_th);
2182
} else if (argv[0] == 1) {
2183
dfs->pri_sum_g1_th = (u8)argv[1];
2184
PDM_SNPF(out_len, used, output + used, out_len - used,
2185
"pri_sum_g1_th = %d\n",
2186
dfs->pri_sum_g1_th);
2187
} else if (argv[0] == 2) {
2188
dfs->pri_sum_g5_th = (u8)argv[1];
2189
PDM_SNPF(out_len, used, output + used, out_len - used,
2190
"pri_sum_g5_th = %d\n",
2191
dfs->pri_sum_g5_th);
2192
} else if (argv[0] == 3) {
2193
dfs->pri_sum_g1_fcc_th = (u8)argv[1];
2194
PDM_SNPF(out_len, used, output + used, out_len - used,
2195
"pri_sum_g1_fcc_th = %d\n",
2196
dfs->pri_sum_g1_fcc_th);
2197
} else if (argv[0] == 4) {
2198
dfs->pri_sum_g3_fcc_th = (u8)argv[1];
2199
PDM_SNPF(out_len, used, output + used, out_len - used,
2200
"pri_sum_g3_fcc_th = %d\n",
2201
dfs->pri_sum_g3_fcc_th);
2202
} else if (argv[0] == 5) {
2203
dfs->pri_sum_safe_fcc_th = (u8)argv[1];
2204
PDM_SNPF(out_len, used, output + used, out_len - used,
2205
"pri_sum_safe_fcc_th = %d\n",
2206
dfs->pri_sum_safe_fcc_th);
2207
} else if (argv[0] == 6) {
2208
dfs->pri_sum_type4_th = (u8)argv[1];
2209
PDM_SNPF(out_len, used, output + used, out_len - used,
2210
"pri_sum_type4_th = %d\n",
2211
dfs->pri_sum_type4_th);
2212
} else if (argv[0] == 7) {
2213
dfs->pri_sum_type6_th = (u8)argv[1];
2214
PDM_SNPF(out_len, used, output + used, out_len - used,
2215
"pri_sum_type6_th = %d\n",
2216
dfs->pri_sum_type6_th);
2217
} else if (argv[0] == 8) {
2218
dfs->pri_sum_safe_th = (u8)argv[1];
2219
PDM_SNPF(out_len, used, output + used, out_len - used,
2220
"pri_sum_safe_th = %d\n",
2221
dfs->pri_sum_safe_th);
2222
} else if (argv[0] == 9) {
2223
dfs->pri_sum_g5_under_g1_th = (u8)argv[1];
2224
PDM_SNPF(out_len, used, output + used, out_len - used,
2225
"pri_sum_g5_under_g1_th = %d\n",
2226
dfs->pri_sum_g5_under_g1_th);
2227
} else if (argv[0] == 10) {
2228
dfs->pri_pw_diff_th = (u8)argv[1];
2229
PDM_SNPF(out_len, used, output + used, out_len - used,
2230
"pri_pw_diff_th = %d\n",
2231
dfs->pri_pw_diff_th);
2232
} else if (argv[0] == 11) {
2233
dfs->pri_pw_diff_fcc_th = (u8)argv[1];
2234
PDM_SNPF(out_len, used, output + used, out_len - used,
2235
"pri_pw_diff_fcc_th = %d\n",
2236
dfs->pri_pw_diff_fcc_th);
2237
} else if (argv[0] == 12) {
2238
dfs->pri_pw_diff_fcc_idle_th = (u8)argv[1];
2239
PDM_SNPF(out_len, used, output + used, out_len - used,
2240
"pri_pw_diff_fcc_idle_th = %d\n",
2241
dfs->pri_pw_diff_fcc_idle_th);
2242
} else if (argv[0] == 13) {
2243
dfs->pri_pw_diff_w53_th = (u8)argv[1];
2244
PDM_SNPF(out_len, used, output + used, out_len - used,
2245
"pri_pw_diff_w53_th = %d\n",
2246
dfs->pri_pw_diff_w53_th);
2247
} else if (argv[0] == 14) {
2248
dfs->pri_type1_low_fcc_th = (u8)argv[1];
2249
PDM_SNPF(out_len, used, output + used, out_len - used,
2250
"pri_type1_low_fcc_th = %d\n",
2251
dfs->pri_type1_low_fcc_th);
2252
} else if (argv[0] == 15) {
2253
dfs->pri_type1_upp_fcc_th = (u8)argv[1];
2254
PDM_SNPF(out_len, used, output + used, out_len - used,
2255
"pri_type1_upp_fcc_th = %d\n",
2256
dfs->pri_type1_upp_fcc_th);
2257
} else if (argv[0] == 16) {
2258
dfs->pri_type1_cen_fcc_th = (u8)argv[1];
2259
PDM_SNPF(out_len, used, output + used, out_len - used,
2260
"pri_type1_cen_fcc_th = %d\n",
2261
dfs->pri_type1_cen_fcc_th);
2262
} else if (argv[0] == 17) {
2263
dfs->pw_g0_th = (u8)argv[1];
2264
PDM_SNPF(out_len, used, output + used, out_len - used,
2265
"pw_g0_th = %d\n",
2266
dfs->pw_g0_th);
2267
} else if (argv[0] == 18) {
2268
dfs->pw_long_lower_20m_th = (u8)argv[1];
2269
PDM_SNPF(out_len, used, output + used, out_len - used,
2270
"pw_long_lower_20m_th = %d\n",
2271
dfs->pw_long_lower_20m_th);
2272
} else if (argv[0] == 19) {
2273
dfs->pw_long_lower_th = (u8)argv[1];
2274
PDM_SNPF(out_len, used, output + used, out_len - used,
2275
"pw_long_lower_th = %d\n",
2276
dfs->pw_long_lower_th);
2277
} else if (argv[0] == 20) {
2278
dfs->pri_long_upper_th = (u8)argv[1];
2279
PDM_SNPF(out_len, used, output + used, out_len - used,
2280
"pri_long_upper_th = %d\n",
2281
dfs->pri_long_upper_th);
2282
} else if (argv[0] == 21) {
2283
dfs->pw_long_sum_upper_th = (u8)argv[1];
2284
PDM_SNPF(out_len, used, output + used, out_len - used,
2285
"pw_long_sum_upper_th = %d\n",
2286
dfs->pw_long_sum_upper_th);
2287
} else if (argv[0] == 22) {
2288
dfs->pw_std_th = (u8)argv[1];
2289
PDM_SNPF(out_len, used, output + used, out_len - used,
2290
"pw_std_th = %d\n",
2291
dfs->pw_std_th);
2292
} else if (argv[0] == 23) {
2293
dfs->pw_std_idle_th = (u8)argv[1];
2294
PDM_SNPF(out_len, used, output + used, out_len - used,
2295
"pw_std_idle_th = %d\n",
2296
dfs->pw_std_idle_th);
2297
} else if (argv[0] == 24) {
2298
dfs->pri_std_th = (u8)argv[1];
2299
PDM_SNPF(out_len, used, output + used, out_len - used,
2300
"pri_std_th = %d\n",
2301
dfs->pri_std_th);
2302
} else if (argv[0] == 25) {
2303
dfs->pri_std_idle_th = (u8)argv[1];
2304
PDM_SNPF(out_len, used, output + used, out_len - used,
2305
"pri_std_idle_th = %d\n",
2306
dfs->pri_std_idle_th);
2307
} else if (argv[0] == 26) {
2308
dfs->type4_pw_max_cnt = (u8)argv[1];
2309
PDM_SNPF(out_len, used, output + used, out_len - used,
2310
"type4_pw_max_cnt = %d\n",
2311
dfs->type4_pw_max_cnt);
2312
} else if (argv[0] == 27) {
2313
dfs->type4_safe_pri_sum_th = (u8)argv[1];
2314
PDM_SNPF(out_len, used, output + used, out_len - used,
2315
"type4_safe_pri_sum_th = %d\n",
2316
dfs->type4_safe_pri_sum_th);
2317
}
2318
}
2319
*_used = used;
2320
*_out_len = out_len;
2321
}
2322
2323
void phydm_dfs_debug(void *dm_void, char input[][16], u32 *_used,
2324
char *output, u32 *_out_len)
2325
{
2326
struct dm_struct *dm = (struct dm_struct *)dm_void;
2327
struct _DFS_STATISTICS *dfs = &dm->dfs;
2328
u32 used = *_used;
2329
u32 out_len = *_out_len;
2330
u32 argv[10] = {0};
2331
u8 i, input_idx = 0;
2332
2333
for (i = 0; i < 7; i++) {
2334
if (input[i + 1]) {
2335
PHYDM_SSCANF(input[i + 1], DCMD_HEX, &argv[i]);
2336
input_idx++;
2337
}
2338
}
2339
2340
if (input_idx == 0)
2341
return;
2342
2343
dfs->dbg_mode = (boolean)argv[0];
2344
dfs->sw_trigger_mode = (boolean)argv[1];
2345
dfs->force_TP_mode = (boolean)argv[2];
2346
dfs->det_print = (boolean)argv[3];
2347
dfs->det_print2 = (boolean)argv[4];
2348
dfs->print_hist_rpt = (boolean)argv[5];
2349
dfs->hist_cond_on = (boolean)argv[6];
2350
2351
PDM_SNPF(out_len, used, output + used, out_len - used,
2352
"dbg_mode: %d, sw_trigger_mode: %d, force_TP_mode: %d, det_print: %d,det_print2: %d, print_hist_rpt: %d, hist_cond_on: %d\n",
2353
dfs->dbg_mode, dfs->sw_trigger_mode, dfs->force_TP_mode,
2354
dfs->det_print, dfs->det_print2, dfs->print_hist_rpt,
2355
dfs->hist_cond_on);
2356
2357
/*switch (argv[0]) {
2358
case 1:
2359
#if defined(CONFIG_PHYDM_DFS_MASTER)
2360
set dbg parameters for radar detection instead of the default value
2361
if (argv[1] == 1) {
2362
dm->radar_detect_reg_918 = argv[2];
2363
dm->radar_detect_reg_91c = argv[3];
2364
dm->radar_detect_reg_920 = argv[4];
2365
dm->radar_detect_reg_924 = argv[5];
2366
dm->radar_detect_dbg_parm_en = 1;
2367
2368
PDM_SNPF((output + used, out_len - used, "Radar detection with dbg parameter\n"));
2369
PDM_SNPF((output + used, out_len - used, "reg918:0x%08X\n", dm->radar_detect_reg_918));
2370
PDM_SNPF((output + used, out_len - used, "reg91c:0x%08X\n", dm->radar_detect_reg_91c));
2371
PDM_SNPF((output + used, out_len - used, "reg920:0x%08X\n", dm->radar_detect_reg_920));
2372
PDM_SNPF((output + used, out_len - used, "reg924:0x%08X\n", dm->radar_detect_reg_924));
2373
} else {
2374
dm->radar_detect_dbg_parm_en = 0;
2375
PDM_SNPF((output + used, out_len - used, "Radar detection with default parameter\n"));
2376
}
2377
phydm_radar_detect_enable(dm);
2378
#endif defined(CONFIG_PHYDM_DFS_MASTER)
2379
2380
break;
2381
default:
2382
break;
2383
}*/
2384
}
2385
2386
u8 phydm_dfs_polling_time(void *dm_void)
2387
{
2388
struct dm_struct *dm = (struct dm_struct *)dm_void;
2389
struct _DFS_STATISTICS *dfs = &dm->dfs;
2390
2391
if (dm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B | ODM_RTL8821C))
2392
dfs->dfs_polling_time = 40;
2393
else
2394
dfs->dfs_polling_time = 100;
2395
2396
return dfs->dfs_polling_time;
2397
}
2398
2399
#endif /* @defined(CONFIG_PHYDM_DFS_MASTER) */
2400
2401
boolean
2402
phydm_is_dfs_band(void *dm_void)
2403
{
2404
struct dm_struct *dm = (struct dm_struct *)dm_void;
2405
2406
if (((*dm->channel >= 52) && (*dm->channel <= 64)) ||
2407
((*dm->channel >= 100) && (*dm->channel <= 144)))
2408
return true;
2409
else
2410
return false;
2411
}
2412
2413
boolean
2414
phydm_dfs_master_enabled(void *dm_void)
2415
{
2416
#ifdef CONFIG_PHYDM_DFS_MASTER
2417
struct dm_struct *dm = (struct dm_struct *)dm_void;
2418
boolean ret_val = false;
2419
2420
if (dm->dfs_master_enabled) /*pointer protection*/
2421
ret_val = *dm->dfs_master_enabled ? true : false;
2422
2423
return ret_val;
2424
#else
2425
return false;
2426
#endif
2427
}
2428
2429
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2430
#ifdef PHYDM_IC_JGR3_SERIES_SUPPORT
2431
void phydm_dfs_ap_reset_radar_detect_counter_and_flag(void *dm_void)
2432
{
2433
struct dm_struct *dm = (struct dm_struct *)dm_void;
2434
2435
/* @Clear Radar Counter and Radar flag */
2436
odm_set_bb_reg(dm, R_0xa40, BIT(15), 0);
2437
odm_set_bb_reg(dm, R_0xa40, BIT(15), 1);
2438
2439
/* RT_TRACE(COMP_DFS, DBG_LOUD, ("[DFS], After reset radar counter, 0xcf8 = 0x%x, 0xcf4 = 0x%x\n", */
2440
/* PHY_QueryBBReg(Adapter, 0xcf8, bMaskDWord), */
2441
/* PHY_QueryBBReg(Adapter, 0xcf4, bMaskDWord))); */
2442
}
2443
#endif
2444
#endif
2445
2446