0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef SPECTRAL_H
0018 #define SPECTRAL_H
0019
0020 #include "../spectral_common.h"
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 enum spectral_mode {
0033 SPECTRAL_DISABLED = 0,
0034 SPECTRAL_BACKGROUND,
0035 SPECTRAL_MANUAL,
0036 SPECTRAL_CHANSCAN,
0037 };
0038
0039 #define SPECTRAL_SCAN_BITMASK 0x10
0040
0041 struct ath_radar_info {
0042 u8 pulse_length_pri;
0043 u8 pulse_length_ext;
0044 u8 pulse_bw_info;
0045 } __packed;
0046
0047
0048
0049
0050
0051
0052
0053
0054 struct ath_ht20_mag_info {
0055 u8 all_bins[3];
0056 u8 max_exp;
0057 } __packed;
0058
0059
0060
0061
0062 struct ath_ht20_fft_packet {
0063 u8 data[SPECTRAL_HT20_NUM_BINS];
0064 struct ath_ht20_mag_info mag_info;
0065 struct ath_radar_info radar_info;
0066 } __packed;
0067
0068 #define SPECTRAL_HT20_TOTAL_DATA_LEN (sizeof(struct ath_ht20_fft_packet))
0069 #define SPECTRAL_HT20_SAMPLE_LEN (sizeof(struct ath_ht20_mag_info) +\
0070 SPECTRAL_HT20_NUM_BINS)
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 struct ath_ht20_40_mag_info {
0083 u8 lower_bins[3];
0084 u8 upper_bins[3];
0085 u8 max_exp;
0086 } __packed;
0087
0088
0089
0090
0091 struct ath_ht20_40_fft_packet {
0092 u8 data[SPECTRAL_HT20_40_NUM_BINS];
0093 struct ath_ht20_40_mag_info mag_info;
0094 struct ath_radar_info radar_info;
0095 } __packed;
0096
0097 struct ath_spec_scan_priv {
0098 struct ath_hw *ah;
0099
0100 struct rchan *rfs_chan_spec_scan;
0101 enum spectral_mode spectral_mode;
0102 struct ath_spec_scan spec_config;
0103 };
0104
0105 #define SPECTRAL_HT20_40_TOTAL_DATA_LEN (sizeof(struct ath_ht20_40_fft_packet))
0106 #define SPECTRAL_HT20_40_SAMPLE_LEN (sizeof(struct ath_ht20_40_mag_info) +\
0107 SPECTRAL_HT20_40_NUM_BINS)
0108
0109 #define SPECTRAL_SAMPLE_MAX_LEN SPECTRAL_HT20_40_SAMPLE_LEN
0110
0111
0112 static inline u16 spectral_max_magnitude(u8 *bins)
0113 {
0114 return (bins[0] & 0xc0) >> 6 |
0115 (bins[1] & 0xff) << 2 |
0116 (bins[2] & 0x03) << 10;
0117 }
0118
0119
0120 static inline u8 spectral_max_index(u8 *bins, int num_bins)
0121 {
0122 s8 m = (bins[2] & 0xfc) >> 2;
0123 u8 zero_idx = num_bins / 2;
0124
0125
0126
0127
0128
0129 if (m & 0x20) {
0130 m &= ~0x20;
0131 m |= 0xe0;
0132 }
0133
0134
0135
0136
0137
0138
0139 m += zero_idx;
0140
0141
0142 if (m < 0 || m > num_bins - 1)
0143 m = 0;
0144
0145 return m;
0146 }
0147
0148 static inline u8 spectral_max_index_ht40(u8 *bins)
0149 {
0150 u8 idx;
0151
0152 idx = spectral_max_index(bins, SPECTRAL_HT20_40_NUM_BINS);
0153
0154
0155
0156
0157 return idx % (SPECTRAL_HT20_40_NUM_BINS / 2);
0158 }
0159
0160 static inline u8 spectral_max_index_ht20(u8 *bins)
0161 {
0162 return spectral_max_index(bins, SPECTRAL_HT20_NUM_BINS);
0163 }
0164
0165
0166 static inline u8 spectral_bitmap_weight(u8 *bins)
0167 {
0168 return bins[0] & 0x3f;
0169 }
0170
0171 #ifdef CONFIG_ATH9K_COMMON_SPECTRAL
0172 void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv, struct dentry *debugfs_phy);
0173 void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv);
0174
0175 void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
0176 struct ath_spec_scan_priv *spec_priv);
0177 int ath9k_cmn_spectral_scan_config(struct ath_common *common,
0178 struct ath_spec_scan_priv *spec_priv,
0179 enum spectral_mode spectral_mode);
0180 int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
0181 struct ath_rx_status *rs, u64 tsf);
0182 #else
0183 static inline void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv,
0184 struct dentry *debugfs_phy)
0185 {
0186 }
0187
0188 static inline void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
0189 {
0190 }
0191
0192 static inline void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
0193 struct ath_spec_scan_priv *spec_priv)
0194 {
0195 }
0196
0197 static inline int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv,
0198 struct ieee80211_hdr *hdr,
0199 struct ath_rx_status *rs, u64 tsf)
0200 {
0201 return 0;
0202 }
0203 #endif
0204
0205 #endif