1/*
2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef SPECTRAL_COMMON_H
18#define SPECTRAL_COMMON_H
19
20#define SPECTRAL_HT20_NUM_BINS		56
21#define SPECTRAL_HT20_40_NUM_BINS		128
22
23/* TODO: could possibly be 512, but no samples this large
24 * could be acquired so far.
25 */
26#define SPECTRAL_ATH10K_MAX_NUM_BINS		256
27#define SPECTRAL_ATH11K_MAX_NUM_BINS		512
28
29/* FFT sample format given to userspace via debugfs.
30 *
31 * Please keep the type/length at the front position and change
32 * other fields after adding another sample type
33 *
34 * TODO: this might need rework when switching to nl80211-based
35 * interface.
36 */
37enum ath_fft_sample_type {
38	ATH_FFT_SAMPLE_HT20 = 1,
39	ATH_FFT_SAMPLE_HT20_40,
40	ATH_FFT_SAMPLE_ATH10K,
41	ATH_FFT_SAMPLE_ATH11K
42};
43
44struct fft_sample_tlv {
45	u8 type;	/* see ath_fft_sample */
46	__be16 length;
47	/* type dependent data follows */
48} __packed;
49
50struct fft_sample_ht20 {
51	struct fft_sample_tlv tlv;
52
53	u8 max_exp;
54
55	__be16 freq;
56	s8 rssi;
57	s8 noise;
58
59	__be16 max_magnitude;
60	u8 max_index;
61	u8 bitmap_weight;
62
63	__be64 tsf;
64
65	u8 data[SPECTRAL_HT20_NUM_BINS];
66} __packed;
67
68struct fft_sample_ht20_40 {
69	struct fft_sample_tlv tlv;
70
71	u8 channel_type;
72	__be16 freq;
73
74	s8 lower_rssi;
75	s8 upper_rssi;
76
77	__be64 tsf;
78
79	s8 lower_noise;
80	s8 upper_noise;
81
82	__be16 lower_max_magnitude;
83	__be16 upper_max_magnitude;
84
85	u8 lower_max_index;
86	u8 upper_max_index;
87
88	u8 lower_bitmap_weight;
89	u8 upper_bitmap_weight;
90
91	u8 max_exp;
92
93	u8 data[SPECTRAL_HT20_40_NUM_BINS];
94} __packed;
95
96struct fft_sample_ath10k {
97	struct fft_sample_tlv tlv;
98	u8 chan_width_mhz;
99	__be16 freq1;
100	__be16 freq2;
101	__be16 noise;
102	__be16 max_magnitude;
103	__be16 total_gain_db;
104	__be16 base_pwr_db;
105	__be64 tsf;
106	s8 max_index;
107	u8 rssi;
108	u8 relpwr_db;
109	u8 avgpwr_db;
110	u8 max_exp;
111
112	u8 data[0];
113} __packed;
114
115struct fft_sample_ath11k {
116	struct fft_sample_tlv tlv;
117	u8 chan_width_mhz;
118	s8 max_index;
119	u8 max_exp;
120	__be16 freq1;
121	__be16 freq2;
122	__be16 max_magnitude;
123	__be16 rssi;
124	__be32 tsf;
125	__be32 noise;
126
127	u8 data[0];
128} __packed;
129
130#endif /* SPECTRAL_COMMON_H */
131