calib.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications 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 CALIB_H
  17. #define CALIB_H
  18. #include "hw.h"
  19. #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
  20. #define NUM_NF_READINGS 6
  21. #define ATH9K_NF_CAL_HIST_MAX 5
  22. struct ar5416IniArray {
  23. u32 *ia_array;
  24. u32 ia_rows;
  25. u32 ia_columns;
  26. };
  27. #define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
  28. (iniarray)->ia_array = (u32 *)(array); \
  29. (iniarray)->ia_rows = (rows); \
  30. (iniarray)->ia_columns = (columns); \
  31. } while (0)
  32. #define INI_RA(iniarray, row, column) \
  33. (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
  34. #define INIT_CAL(_perCal) do { \
  35. (_perCal)->calState = CAL_WAITING; \
  36. (_perCal)->calNext = NULL; \
  37. } while (0)
  38. #define INSERT_CAL(_ahp, _perCal) \
  39. do { \
  40. if ((_ahp)->cal_list_last == NULL) { \
  41. (_ahp)->cal_list = \
  42. (_ahp)->cal_list_last = (_perCal); \
  43. ((_ahp)->cal_list_last)->calNext = (_perCal); \
  44. } else { \
  45. ((_ahp)->cal_list_last)->calNext = (_perCal); \
  46. (_ahp)->cal_list_last = (_perCal); \
  47. (_perCal)->calNext = (_ahp)->cal_list; \
  48. } \
  49. } while (0)
  50. enum ath9k_cal_state {
  51. CAL_INACTIVE,
  52. CAL_WAITING,
  53. CAL_RUNNING,
  54. CAL_DONE
  55. };
  56. #define MIN_CAL_SAMPLES 1
  57. #define MAX_CAL_SAMPLES 64
  58. #define INIT_LOG_COUNT 5
  59. #define PER_MIN_LOG_COUNT 2
  60. #define PER_MAX_LOG_COUNT 10
  61. struct ath9k_percal_data {
  62. u32 calType;
  63. u32 calNumSamples;
  64. u32 calCountMax;
  65. void (*calCollect) (struct ath_hw *);
  66. void (*calPostProc) (struct ath_hw *, u8);
  67. };
  68. struct ath9k_cal_list {
  69. const struct ath9k_percal_data *calData;
  70. enum ath9k_cal_state calState;
  71. struct ath9k_cal_list *calNext;
  72. };
  73. struct ath9k_nfcal_hist {
  74. int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
  75. u8 currIndex;
  76. int16_t privNF;
  77. u8 invalidNFcount;
  78. };
  79. #define MAX_PACAL_SKIPCOUNT 8
  80. struct ath9k_pacal_info{
  81. int32_t prev_offset; /* Previous value of PA offset value */
  82. int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
  83. int8_t skipcount; /* No. of times the PACAL to be skipped */
  84. };
  85. bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
  86. void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
  87. void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
  88. bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
  89. void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
  90. struct ath9k_channel *chan);
  91. void ath9k_hw_bstuck_nfcal(struct ath_hw *ah);
  92. void ath9k_hw_reset_calibration(struct ath_hw *ah,
  93. struct ath9k_cal_list *currCal);
  94. s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
  95. #endif /* CALIB_H */