18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2013 Qualcomm Atheros, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef SPECTRAL_COMMON_H
188c2ecf20Sopenharmony_ci#define SPECTRAL_COMMON_H
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define SPECTRAL_HT20_NUM_BINS		56
218c2ecf20Sopenharmony_ci#define SPECTRAL_HT20_40_NUM_BINS		128
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* TODO: could possibly be 512, but no samples this large
248c2ecf20Sopenharmony_ci * could be acquired so far.
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci#define SPECTRAL_ATH10K_MAX_NUM_BINS		256
278c2ecf20Sopenharmony_ci#define SPECTRAL_ATH11K_MAX_NUM_BINS		512
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* FFT sample format given to userspace via debugfs.
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * Please keep the type/length at the front position and change
328c2ecf20Sopenharmony_ci * other fields after adding another sample type
338c2ecf20Sopenharmony_ci *
348c2ecf20Sopenharmony_ci * TODO: this might need rework when switching to nl80211-based
358c2ecf20Sopenharmony_ci * interface.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_cienum ath_fft_sample_type {
388c2ecf20Sopenharmony_ci	ATH_FFT_SAMPLE_HT20 = 1,
398c2ecf20Sopenharmony_ci	ATH_FFT_SAMPLE_HT20_40,
408c2ecf20Sopenharmony_ci	ATH_FFT_SAMPLE_ATH10K,
418c2ecf20Sopenharmony_ci	ATH_FFT_SAMPLE_ATH11K
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct fft_sample_tlv {
458c2ecf20Sopenharmony_ci	u8 type;	/* see ath_fft_sample */
468c2ecf20Sopenharmony_ci	__be16 length;
478c2ecf20Sopenharmony_ci	/* type dependent data follows */
488c2ecf20Sopenharmony_ci} __packed;
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct fft_sample_ht20 {
518c2ecf20Sopenharmony_ci	struct fft_sample_tlv tlv;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	u8 max_exp;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	__be16 freq;
568c2ecf20Sopenharmony_ci	s8 rssi;
578c2ecf20Sopenharmony_ci	s8 noise;
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci	__be16 max_magnitude;
608c2ecf20Sopenharmony_ci	u8 max_index;
618c2ecf20Sopenharmony_ci	u8 bitmap_weight;
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	__be64 tsf;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	u8 data[SPECTRAL_HT20_NUM_BINS];
668c2ecf20Sopenharmony_ci} __packed;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct fft_sample_ht20_40 {
698c2ecf20Sopenharmony_ci	struct fft_sample_tlv tlv;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	u8 channel_type;
728c2ecf20Sopenharmony_ci	__be16 freq;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	s8 lower_rssi;
758c2ecf20Sopenharmony_ci	s8 upper_rssi;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	__be64 tsf;
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	s8 lower_noise;
808c2ecf20Sopenharmony_ci	s8 upper_noise;
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci	__be16 lower_max_magnitude;
838c2ecf20Sopenharmony_ci	__be16 upper_max_magnitude;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	u8 lower_max_index;
868c2ecf20Sopenharmony_ci	u8 upper_max_index;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	u8 lower_bitmap_weight;
898c2ecf20Sopenharmony_ci	u8 upper_bitmap_weight;
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	u8 max_exp;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci	u8 data[SPECTRAL_HT20_40_NUM_BINS];
948c2ecf20Sopenharmony_ci} __packed;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cistruct fft_sample_ath10k {
978c2ecf20Sopenharmony_ci	struct fft_sample_tlv tlv;
988c2ecf20Sopenharmony_ci	u8 chan_width_mhz;
998c2ecf20Sopenharmony_ci	__be16 freq1;
1008c2ecf20Sopenharmony_ci	__be16 freq2;
1018c2ecf20Sopenharmony_ci	__be16 noise;
1028c2ecf20Sopenharmony_ci	__be16 max_magnitude;
1038c2ecf20Sopenharmony_ci	__be16 total_gain_db;
1048c2ecf20Sopenharmony_ci	__be16 base_pwr_db;
1058c2ecf20Sopenharmony_ci	__be64 tsf;
1068c2ecf20Sopenharmony_ci	s8 max_index;
1078c2ecf20Sopenharmony_ci	u8 rssi;
1088c2ecf20Sopenharmony_ci	u8 relpwr_db;
1098c2ecf20Sopenharmony_ci	u8 avgpwr_db;
1108c2ecf20Sopenharmony_ci	u8 max_exp;
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci	u8 data[0];
1138c2ecf20Sopenharmony_ci} __packed;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistruct fft_sample_ath11k {
1168c2ecf20Sopenharmony_ci	struct fft_sample_tlv tlv;
1178c2ecf20Sopenharmony_ci	u8 chan_width_mhz;
1188c2ecf20Sopenharmony_ci	s8 max_index;
1198c2ecf20Sopenharmony_ci	u8 max_exp;
1208c2ecf20Sopenharmony_ci	__be16 freq1;
1218c2ecf20Sopenharmony_ci	__be16 freq2;
1228c2ecf20Sopenharmony_ci	__be16 max_magnitude;
1238c2ecf20Sopenharmony_ci	__be16 rssi;
1248c2ecf20Sopenharmony_ci	__be32 tsf;
1258c2ecf20Sopenharmony_ci	__be32 noise;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	u8 data[0];
1288c2ecf20Sopenharmony_ci} __packed;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#endif /* SPECTRAL_COMMON_H */
131