spectral_common.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #ifndef SPECTRAL_COMMON_H
  17. #define SPECTRAL_COMMON_H
  18. #define SPECTRAL_HT20_NUM_BINS 56
  19. #define SPECTRAL_HT20_40_NUM_BINS 128
  20. /* TODO: could possibly be 512, but no samples this large
  21. * could be acquired so far.
  22. */
  23. #define SPECTRAL_ATH10K_MAX_NUM_BINS 256
  24. /* FFT sample format given to userspace via debugfs.
  25. *
  26. * Please keep the type/length at the front position and change
  27. * other fields after adding another sample type
  28. *
  29. * TODO: this might need rework when switching to nl80211-based
  30. * interface.
  31. */
  32. enum ath_fft_sample_type {
  33. ATH_FFT_SAMPLE_HT20 = 1,
  34. ATH_FFT_SAMPLE_HT20_40,
  35. ATH_FFT_SAMPLE_ATH10K,
  36. ATH_FFT_SAMPLE_ATH11K
  37. };
  38. struct fft_sample_tlv {
  39. u8 type; /* see ath_fft_sample */
  40. __be16 length;
  41. /* type dependent data follows */
  42. } __packed;
  43. struct fft_sample_ht20 {
  44. struct fft_sample_tlv tlv;
  45. u8 max_exp;
  46. __be16 freq;
  47. s8 rssi;
  48. s8 noise;
  49. __be16 max_magnitude;
  50. u8 max_index;
  51. u8 bitmap_weight;
  52. __be64 tsf;
  53. u8 data[SPECTRAL_HT20_NUM_BINS];
  54. } __packed;
  55. struct fft_sample_ht20_40 {
  56. struct fft_sample_tlv tlv;
  57. u8 channel_type;
  58. __be16 freq;
  59. s8 lower_rssi;
  60. s8 upper_rssi;
  61. __be64 tsf;
  62. s8 lower_noise;
  63. s8 upper_noise;
  64. __be16 lower_max_magnitude;
  65. __be16 upper_max_magnitude;
  66. u8 lower_max_index;
  67. u8 upper_max_index;
  68. u8 lower_bitmap_weight;
  69. u8 upper_bitmap_weight;
  70. u8 max_exp;
  71. u8 data[SPECTRAL_HT20_40_NUM_BINS];
  72. } __packed;
  73. struct fft_sample_ath10k {
  74. struct fft_sample_tlv tlv;
  75. u8 chan_width_mhz;
  76. __be16 freq1;
  77. __be16 freq2;
  78. __be16 noise;
  79. __be16 max_magnitude;
  80. __be16 total_gain_db;
  81. __be16 base_pwr_db;
  82. __be64 tsf;
  83. s8 max_index;
  84. u8 rssi;
  85. u8 relpwr_db;
  86. u8 avgpwr_db;
  87. u8 max_exp;
  88. u8 data[];
  89. } __packed;
  90. struct fft_sample_ath11k {
  91. struct fft_sample_tlv tlv;
  92. u8 chan_width_mhz;
  93. s8 max_index;
  94. u8 max_exp;
  95. __be16 freq1;
  96. __be16 freq2;
  97. __be16 max_magnitude;
  98. __be16 rssi;
  99. __be32 tsf;
  100. __be32 noise;
  101. u8 data[];
  102. } __packed;
  103. #endif /* SPECTRAL_COMMON_H */