phydm_lna_sat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. #ifndef __PHYDM_LNA_SAT_H__
  26. #define __PHYDM_LNA_SAT_H__
  27. #ifdef PHYDM_LNA_SAT_CHK_SUPPORT
  28. /* @1 ============================================================
  29. * 1 Definition
  30. * 1 ============================================================
  31. */
  32. #define LNA_SAT_VERSION "1.0"
  33. /*@LNA saturation check*/
  34. #define OFDM_AGC_TAB_0 0
  35. #define OFDM_AGC_TAB_2 2
  36. #define DIFF_RSSI_TO_IGI 10
  37. #define ONE_SEC_MS 1000
  38. #define LNA_CHK_PERIOD 100 /*@ms*/
  39. #define LNA_CHK_CNT 10 /*@checks per callback*/
  40. #define LNA_CHK_DUTY_CYCLE 5 /*@percentage*/
  41. #define DELTA_STD 2
  42. #define DELTA_MEAN 2
  43. #define SNR_STATISTIC_SHIFT 8
  44. #define SNR_RPT_MAX 256
  45. /* @1 ============================================================
  46. * 1 enumrate
  47. * 1 ============================================================
  48. */
  49. enum lna_sat_timer_state {
  50. INIT_LNA_SAT_CHK_TIMMER,
  51. CANCEL_LNA_SAT_CHK_TIMMER,
  52. RELEASE_LNA_SAT_CHK_TIMMER
  53. };
  54. #ifdef PHYDM_LNA_SAT_CHK_TYPE2
  55. enum lna_sat_chk_type2_status {
  56. ORI_TABLE_MONITOR,
  57. ORI_TABLE_TRAINING,
  58. SAT_TABLE_MONITOR,
  59. SAT_TABLE_TRAINING,
  60. SAT_TABLE_TRY_FAIL,
  61. ORI_TABLE_TRY_FAIL
  62. };
  63. #endif
  64. enum lna_sat_type {
  65. LNA_SAT_WITH_PEAK_DET = 1, /*type1*/
  66. LNA_SAT_WITH_TRAIN = 2, /*type2*/
  67. };
  68. /* @1 ============================================================
  69. * 1 structure
  70. * 1 ============================================================
  71. */
  72. struct phydm_lna_sat_t {
  73. #ifdef PHYDM_LNA_SAT_CHK_TYPE1
  74. u8 chk_cnt;
  75. u8 chk_duty_cycle;
  76. u32 chk_period;/*@ms*/
  77. boolean is_disable_lna_sat_chk;
  78. boolean dis_agc_table_swh;
  79. #endif
  80. #ifdef PHYDM_LNA_SAT_CHK_TYPE2
  81. u8 force_traget_macid;
  82. u32 snr_var_thd;
  83. u32 delta_snr_mean;
  84. u16 ori_table_try_fail_times;
  85. u16 cnt_lower_snr_statistic;
  86. u16 sat_table_monitor_times;
  87. u16 force_change_period;
  88. u8 is_snr_detail_en;
  89. u8 is_force_lna_sat_table;
  90. u8 lwr_snr_ratio_bit_shift;
  91. u8 cnt_snr_statistic;
  92. u16 snr_statistic_sqr[SNR_RPT_MAX];
  93. u8 snr_statistic[SNR_RPT_MAX];
  94. u8 is_sm_done;
  95. u8 is_snr_done;
  96. u32 cur_snr_var;
  97. u8 total_bit_shift;
  98. u8 total_cnt_snr;
  99. u32 cur_snr_mean;
  100. u8 cur_snr_var0;
  101. u32 cur_lower_snr_mean;
  102. u32 pre_snr_mean;
  103. u32 pre_snr_var;
  104. u32 pre_lower_snr_mean;
  105. u8 nxt_state;
  106. u8 pre_state;
  107. #endif
  108. enum lna_sat_type lna_sat_type;
  109. u32 sat_cnt_acc_patha;
  110. u32 sat_cnt_acc_pathb;
  111. #ifdef PHYDM_IC_ABOVE_3SS
  112. u32 sat_cnt_acc_pathc;
  113. #endif
  114. #ifdef PHYDM_IC_ABOVE_4SS
  115. u32 sat_cnt_acc_pathd;
  116. #endif
  117. u32 check_time;
  118. boolean pre_sat_status;
  119. boolean cur_sat_status;
  120. struct phydm_timer_list phydm_lna_sat_chk_timer;
  121. u32 cur_timer_check_cnt;
  122. u32 pre_timer_check_cnt;
  123. };
  124. /* @1 ============================================================
  125. * 1 function prototype
  126. * 1 ============================================================
  127. */
  128. void phydm_lna_sat_chk_init(void *dm_void);
  129. u8 phydm_get_ofdm_agc_tab(void *dm_void);
  130. void phydm_lna_sat_chk(void *dm_void);
  131. void phydm_lna_sat_chk_timers(void *dm_void, u8 state);
  132. #ifdef PHYDM_LNA_SAT_CHK_TYPE1
  133. #if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)
  134. void phydm_lna_sat_chk_bb_init(void *dm_void);
  135. void phydm_set_ofdm_agc_tab_path(void *dm_void,
  136. u8 tab_sel, enum rf_path path);
  137. u8 phydm_get_ofdm_agc_tab_path(void *dm_void, enum rf_path path);
  138. #endif /*@#if (RTL8198F_SUPPORT || RTL8814B_SUPPORT)*/
  139. #endif
  140. #ifdef PHYDM_LNA_SAT_CHK_TYPE2
  141. void phydm_parsing_snr(void *dm_void, void *pktinfo_void, s8 *rx_snr);
  142. #endif
  143. void phydm_lna_sat_debug(void *dm_void, char input[][16], u32 *_used,
  144. char *output, u32 *_out_len);
  145. void phydm_lna_sat_chk_watchdog(void *dm_void);
  146. void phydm_lna_sat_check_init(void *dm_void);
  147. #endif /*@#if (PHYDM_LNA_SAT_CHK_SUPPORT == 1)*/
  148. #endif