spectral_common.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. };
  37. struct fft_sample_tlv {
  38. u8 type; /* see ath_fft_sample */
  39. __be16 length;
  40. /* type dependent data follows */
  41. } __packed;
  42. struct fft_sample_ht20 {
  43. struct fft_sample_tlv tlv;
  44. u8 max_exp;
  45. __be16 freq;
  46. s8 rssi;
  47. s8 noise;
  48. __be16 max_magnitude;
  49. u8 max_index;
  50. u8 bitmap_weight;
  51. __be64 tsf;
  52. u8 data[SPECTRAL_HT20_NUM_BINS];
  53. } __packed;
  54. struct fft_sample_ht20_40 {
  55. struct fft_sample_tlv tlv;
  56. u8 channel_type;
  57. __be16 freq;
  58. s8 lower_rssi;
  59. s8 upper_rssi;
  60. __be64 tsf;
  61. s8 lower_noise;
  62. s8 upper_noise;
  63. __be16 lower_max_magnitude;
  64. __be16 upper_max_magnitude;
  65. u8 lower_max_index;
  66. u8 upper_max_index;
  67. u8 lower_bitmap_weight;
  68. u8 upper_bitmap_weight;
  69. u8 max_exp;
  70. u8 data[SPECTRAL_HT20_40_NUM_BINS];
  71. } __packed;
  72. struct fft_sample_ath10k {
  73. struct fft_sample_tlv tlv;
  74. u8 chan_width_mhz;
  75. __be16 freq1;
  76. __be16 freq2;
  77. __be16 noise;
  78. __be16 max_magnitude;
  79. __be16 total_gain_db;
  80. __be16 base_pwr_db;
  81. __be64 tsf;
  82. s8 max_index;
  83. u8 rssi;
  84. u8 relpwr_db;
  85. u8 avgpwr_db;
  86. u8 max_exp;
  87. u8 data[0];
  88. } __packed;
  89. #endif /* SPECTRAL_COMMON_H */