1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef SPECTRAL_H
18#define SPECTRAL_H
19
20#include "../spectral_common.h"
21
22
23
24
25
26
27
28
29
30
31
32enum spectral_mode {
33 SPECTRAL_DISABLED = 0,
34 SPECTRAL_BACKGROUND,
35 SPECTRAL_MANUAL,
36 SPECTRAL_CHANSCAN,
37};
38
39#define SPECTRAL_SCAN_BITMASK 0x10
40
41struct ath_radar_info {
42 u8 pulse_length_pri;
43 u8 pulse_length_ext;
44 u8 pulse_bw_info;
45} __packed;
46
47
48
49
50
51
52
53
54struct ath_ht20_mag_info {
55 u8 all_bins[3];
56 u8 max_exp;
57} __packed;
58
59
60
61
62struct ath_ht20_fft_packet {
63 u8 data[SPECTRAL_HT20_NUM_BINS];
64 struct ath_ht20_mag_info mag_info;
65 struct ath_radar_info radar_info;
66} __packed;
67
68#define SPECTRAL_HT20_TOTAL_DATA_LEN (sizeof(struct ath_ht20_fft_packet))
69#define SPECTRAL_HT20_SAMPLE_LEN (sizeof(struct ath_ht20_mag_info) +\
70 SPECTRAL_HT20_NUM_BINS)
71
72
73
74
75
76
77
78
79
80
81
82struct ath_ht20_40_mag_info {
83 u8 lower_bins[3];
84 u8 upper_bins[3];
85 u8 max_exp;
86} __packed;
87
88
89
90
91struct ath_ht20_40_fft_packet {
92 u8 data[SPECTRAL_HT20_40_NUM_BINS];
93 struct ath_ht20_40_mag_info mag_info;
94 struct ath_radar_info radar_info;
95} __packed;
96
97struct ath_spec_scan_priv {
98 struct ath_hw *ah;
99
100 struct rchan *rfs_chan_spec_scan;
101 enum spectral_mode spectral_mode;
102 struct ath_spec_scan spec_config;
103};
104
105#define SPECTRAL_HT20_40_TOTAL_DATA_LEN (sizeof(struct ath_ht20_40_fft_packet))
106#define SPECTRAL_HT20_40_SAMPLE_LEN (sizeof(struct ath_ht20_40_mag_info) +\
107 SPECTRAL_HT20_40_NUM_BINS)
108
109#define SPECTRAL_SAMPLE_MAX_LEN SPECTRAL_HT20_40_SAMPLE_LEN
110
111
112static inline u16 spectral_max_magnitude(u8 *bins)
113{
114 return (bins[0] & 0xc0) >> 6 |
115 (bins[1] & 0xff) << 2 |
116 (bins[2] & 0x03) << 10;
117}
118
119
120static inline u8 spectral_max_index(u8 *bins, int num_bins)
121{
122 s8 m = (bins[2] & 0xfc) >> 2;
123 u8 zero_idx = num_bins / 2;
124
125
126
127
128
129 if (m & 0x20) {
130 m &= ~0x20;
131 m |= 0xe0;
132 }
133
134
135
136
137
138
139 m += zero_idx;
140
141
142 if (m < 0 || m > num_bins - 1)
143 m = 0;
144
145 return m;
146}
147
148static inline u8 spectral_max_index_ht40(u8 *bins)
149{
150 u8 idx;
151
152 idx = spectral_max_index(bins, SPECTRAL_HT20_40_NUM_BINS);
153
154
155
156
157 return idx % (SPECTRAL_HT20_40_NUM_BINS / 2);
158}
159
160static inline u8 spectral_max_index_ht20(u8 *bins)
161{
162 return spectral_max_index(bins, SPECTRAL_HT20_NUM_BINS);
163}
164
165
166static inline u8 spectral_bitmap_weight(u8 *bins)
167{
168 return bins[0] & 0x3f;
169}
170
171#ifdef CONFIG_ATH9K_COMMON_SPECTRAL
172void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv, struct dentry *debugfs_phy);
173void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv);
174
175void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
176 struct ath_spec_scan_priv *spec_priv);
177int ath9k_cmn_spectral_scan_config(struct ath_common *common,
178 struct ath_spec_scan_priv *spec_priv,
179 enum spectral_mode spectral_mode);
180int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
181 struct ath_rx_status *rs, u64 tsf);
182#else
183static inline void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv,
184 struct dentry *debugfs_phy)
185{
186}
187
188static inline void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
189{
190}
191
192static inline void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
193 struct ath_spec_scan_priv *spec_priv)
194{
195}
196
197static inline int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv,
198 struct ieee80211_hdr *hdr,
199 struct ath_rx_status *rs, u64 tsf)
200{
201 return 0;
202}
203#endif
204
205#endif
206