phydm_powertracking_win.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  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. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. /* ************************************************************
  21. * include files
  22. * ************************************************************ */
  23. #include "mp_precomp.h"
  24. #include "phydm_precomp.h"
  25. /* ************************************************************
  26. * Global var
  27. * ************************************************************ */
  28. u32 ofdm_swing_table[OFDM_TABLE_SIZE] = {
  29. 0x7f8001fe, /* 0, +6.0dB */
  30. 0x788001e2, /* 1, +5.5dB */
  31. 0x71c001c7, /* 2, +5.0dB */
  32. 0x6b8001ae, /* 3, +4.5dB */
  33. 0x65400195, /* 4, +4.0dB */
  34. 0x5fc0017f, /* 5, +3.5dB */
  35. 0x5a400169, /* 6, +3.0dB */
  36. 0x55400155, /* 7, +2.5dB */
  37. 0x50800142, /* 8, +2.0dB */
  38. 0x4c000130, /* 9, +1.5dB */
  39. 0x47c0011f, /* 10, +1.0dB */
  40. 0x43c0010f, /* 11, +0.5dB */
  41. 0x40000100, /* 12, +0dB */
  42. 0x3c8000f2, /* 13, -0.5dB */
  43. 0x390000e4, /* 14, -1.0dB */
  44. 0x35c000d7, /* 15, -1.5dB */
  45. 0x32c000cb, /* 16, -2.0dB */
  46. 0x300000c0, /* 17, -2.5dB */
  47. 0x2d4000b5, /* 18, -3.0dB */
  48. 0x2ac000ab, /* 19, -3.5dB */
  49. 0x288000a2, /* 20, -4.0dB */
  50. 0x26000098, /* 21, -4.5dB */
  51. 0x24000090, /* 22, -5.0dB */
  52. 0x22000088, /* 23, -5.5dB */
  53. 0x20000080, /* 24, -6.0dB */
  54. 0x1e400079, /* 25, -6.5dB */
  55. 0x1c800072, /* 26, -7.0dB */
  56. 0x1b00006c, /* 27. -7.5dB */
  57. 0x19800066, /* 28, -8.0dB */
  58. 0x18000060, /* 29, -8.5dB */
  59. 0x16c0005b, /* 30, -9.0dB */
  60. 0x15800056, /* 31, -9.5dB */
  61. 0x14400051, /* 32, -10.0dB */
  62. 0x1300004c, /* 33, -10.5dB */
  63. 0x12000048, /* 34, -11.0dB */
  64. 0x11000044, /* 35, -11.5dB */
  65. 0x10000040, /* 36, -12.0dB */
  66. };
  67. u8 cck_swing_table_ch1_ch13[CCK_TABLE_SIZE][8] = {
  68. {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */
  69. {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */
  70. {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */
  71. {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */
  72. {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */
  73. {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */
  74. {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */
  75. {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */
  76. {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */
  77. {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */
  78. {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */
  79. {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */
  80. {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB <== default */
  81. {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */
  82. {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */
  83. {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */
  84. {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */
  85. {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */
  86. {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */
  87. {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */
  88. {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */
  89. {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */
  90. {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */
  91. {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */
  92. {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */
  93. {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */
  94. {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */
  95. {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */
  96. {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */
  97. {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */
  98. {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */
  99. {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */
  100. {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */
  101. };
  102. u8 cck_swing_table_ch14[CCK_TABLE_SIZE][8] = {
  103. {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */
  104. {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */
  105. {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */
  106. {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */
  107. {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */
  108. {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */
  109. {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */
  110. {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */
  111. {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */
  112. {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */
  113. {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */
  114. {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */
  115. {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB <== default */
  116. {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */
  117. {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */
  118. {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */
  119. {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */
  120. {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */
  121. {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */
  122. {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */
  123. {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */
  124. {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */
  125. {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */
  126. {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */
  127. {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */
  128. {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */
  129. {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */
  130. {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */
  131. {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */
  132. {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */
  133. {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */
  134. {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */
  135. {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */
  136. };
  137. u32 ofdm_swing_table_new[OFDM_TABLE_SIZE] = {
  138. 0x0b40002d, /* 0, -15.0dB */
  139. 0x0c000030, /* 1, -14.5dB */
  140. 0x0cc00033, /* 2, -14.0dB */
  141. 0x0d800036, /* 3, -13.5dB */
  142. 0x0e400039, /* 4, -13.0dB */
  143. 0x0f00003c, /* 5, -12.5dB */
  144. 0x10000040, /* 6, -12.0dB */
  145. 0x11000044, /* 7, -11.5dB */
  146. 0x12000048, /* 8, -11.0dB */
  147. 0x1300004c, /* 9, -10.5dB */
  148. 0x14400051, /* 10, -10.0dB */
  149. 0x15800056, /* 11, -9.5dB */
  150. 0x16c0005b, /* 12, -9.0dB */
  151. 0x18000060, /* 13, -8.5dB */
  152. 0x19800066, /* 14, -8.0dB */
  153. 0x1b00006c, /* 15, -7.5dB */
  154. 0x1c800072, /* 16, -7.0dB */
  155. 0x1e400079, /* 17, -6.5dB */
  156. 0x20000080, /* 18, -6.0dB */
  157. 0x22000088, /* 19, -5.5dB */
  158. 0x24000090, /* 20, -5.0dB */
  159. 0x26000098, /* 21, -4.5dB */
  160. 0x288000a2, /* 22, -4.0dB */
  161. 0x2ac000ab, /* 23, -3.5dB */
  162. 0x2d4000b5, /* 24, -3.0dB */
  163. 0x300000c0, /* 25, -2.5dB */
  164. 0x32c000cb, /* 26, -2.0dB */
  165. 0x35c000d7, /* 27, -1.5dB */
  166. 0x390000e4, /* 28, -1.0dB */
  167. 0x3c8000f2, /* 29, -0.5dB */
  168. 0x40000100, /* 30, +0dB */
  169. 0x43c0010f, /* 31, +0.5dB */
  170. 0x47c0011f, /* 32, +1.0dB */
  171. 0x4c000130, /* 33, +1.5dB */
  172. 0x50800142, /* 34, +2.0dB */
  173. 0x55400155, /* 35, +2.5dB */
  174. 0x5a400169, /* 36, +3.0dB */
  175. 0x5fc0017f, /* 37, +3.5dB */
  176. 0x65400195, /* 38, +4.0dB */
  177. 0x6b8001ae, /* 39, +4.5dB */
  178. 0x71c001c7, /* 40, +5.0dB */
  179. 0x788001e2, /* 41, +5.5dB */
  180. 0x7f8001fe /* 42, +6.0dB */
  181. };
  182. u8 cck_swing_table_ch1_ch14_88f[CCK_TABLE_SIZE_88F][16] = {
  183. {0x44, 0x42, 0x3C, 0x33, 0x28, 0x1C, 0x13, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/
  184. {0x48, 0x46, 0x3F, 0x36, 0x2A, 0x1E, 0x14, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/
  185. {0x4D, 0x4A, 0x43, 0x39, 0x2C, 0x20, 0x15, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/
  186. {0x51, 0x4F, 0x47, 0x3C, 0x2F, 0x22, 0x16, 0x0D, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/
  187. {0x56, 0x53, 0x4B, 0x40, 0x32, 0x24, 0x17, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/
  188. {0x5B, 0x58, 0x50, 0x43, 0x35, 0x26, 0x19, 0x0E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/
  189. {0x60, 0x5D, 0x54, 0x47, 0x38, 0x28, 0x1A, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/
  190. {0x66, 0x63, 0x59, 0x4C, 0x3B, 0x2B, 0x1C, 0x10, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/
  191. {0x6C, 0x69, 0x5F, 0x50, 0x3F, 0x2D, 0x1E, 0x11, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/
  192. {0x73, 0x6F, 0x64, 0x55, 0x42, 0x30, 0x1F, 0x12, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/
  193. {0x79, 0x76, 0x6A, 0x5A, 0x46, 0x33, 0x21, 0x13, 0x09, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/
  194. {0x81, 0x7C, 0x71, 0x5F, 0x4A, 0x36, 0x23, 0x14, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/
  195. {0x88, 0x84, 0x77, 0x65, 0x4F, 0x39, 0x25, 0x15, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/
  196. {0x90, 0x8C, 0x7E, 0x6B, 0x54, 0x3C, 0x27, 0x17, 0x0B, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/
  197. {0x99, 0x94, 0x86, 0x71, 0x58, 0x40, 0x2A, 0x18, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/
  198. {0xA2, 0x9D, 0x8E, 0x78, 0x5E, 0x43, 0x2C, 0x19, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/
  199. {0xAC, 0xA6, 0x96, 0x7F, 0x63, 0x47, 0x2F, 0x1B, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/
  200. {0xB6, 0xB0, 0x9F, 0x87, 0x69, 0x4C, 0x32, 0x1D, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/
  201. {0xC1, 0xBA, 0xA8, 0x8F, 0x6F, 0x50, 0x35, 0x1E, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/
  202. {0xCC, 0xC5, 0xB2, 0x97, 0x76, 0x55, 0x38, 0x20, 0x0F, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/
  203. {0xD8, 0xD1, 0xBD, 0xA0, 0x7D, 0x5A, 0x3B, 0x22, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/
  204. };
  205. u8 cck_swing_table_ch1_ch13_88f[CCK_TABLE_SIZE_88F][16] = {
  206. {0x44, 0x42, 0x3C, 0x33, 0x28, 0x1C, 0x13, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/
  207. {0x48, 0x46, 0x3F, 0x36, 0x2A, 0x1E, 0x14, 0x0B, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/
  208. {0x4D, 0x4A, 0x43, 0x39, 0x2C, 0x20, 0x15, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/
  209. {0x51, 0x4F, 0x47, 0x3C, 0x2F, 0x22, 0x16, 0x0D, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/
  210. {0x56, 0x53, 0x4B, 0x40, 0x32, 0x24, 0x17, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/
  211. {0x5B, 0x58, 0x50, 0x43, 0x35, 0x26, 0x19, 0x0E, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/
  212. {0x60, 0x5D, 0x54, 0x47, 0x38, 0x28, 0x1A, 0x0F, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/
  213. {0x66, 0x63, 0x59, 0x4C, 0x3B, 0x2B, 0x1C, 0x10, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/
  214. {0x6C, 0x69, 0x5F, 0x50, 0x3F, 0x2D, 0x1E, 0x11, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/
  215. {0x73, 0x6F, 0x64, 0x55, 0x42, 0x30, 0x1F, 0x12, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/
  216. {0x79, 0x76, 0x6A, 0x5A, 0x46, 0x33, 0x21, 0x13, 0x09, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/
  217. {0x81, 0x7C, 0x71, 0x5F, 0x4A, 0x36, 0x23, 0x14, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/
  218. {0x88, 0x84, 0x77, 0x65, 0x4F, 0x39, 0x25, 0x15, 0x0A, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/
  219. {0x90, 0x8C, 0x7E, 0x6B, 0x54, 0x3C, 0x27, 0x17, 0x0B, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/
  220. {0x99, 0x94, 0x86, 0x71, 0x58, 0x40, 0x2A, 0x18, 0x0B, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/
  221. {0xA2, 0x9D, 0x8E, 0x78, 0x5E, 0x43, 0x2C, 0x19, 0x0C, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/
  222. {0xAC, 0xA6, 0x96, 0x7F, 0x63, 0x47, 0x2F, 0x1B, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/
  223. {0xB6, 0xB0, 0x9F, 0x87, 0x69, 0x4C, 0x32, 0x1D, 0x0D, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/
  224. {0xC1, 0xBA, 0xA8, 0x8F, 0x6F, 0x50, 0x35, 0x1E, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/
  225. {0xCC, 0xC5, 0xB2, 0x97, 0x76, 0x55, 0x38, 0x20, 0x0F, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/
  226. {0xD8, 0xD1, 0xBD, 0xA0, 0x7D, 0x5A, 0x3B, 0x22, 0x10, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/
  227. };
  228. u8 cck_swing_table_ch14_88f[CCK_TABLE_SIZE_88F][16] = {
  229. {0x44, 0x42, 0x3C, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-16dB*/
  230. {0x48, 0x46, 0x3F, 0x2A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15.5dB*/
  231. {0x4D, 0x4A, 0x43, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-15dB*/
  232. {0x51, 0x4F, 0x47, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14.5dB*/
  233. {0x56, 0x53, 0x4B, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-14dB*/
  234. {0x5B, 0x58, 0x50, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13.5dB*/
  235. {0x60, 0x5D, 0x54, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-13dB*/
  236. {0x66, 0x63, 0x59, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12.5dB*/
  237. {0x6C, 0x69, 0x5F, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-12dB*/
  238. {0x73, 0x6F, 0x64, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11.5dB*/
  239. {0x79, 0x76, 0x6A, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-11dB*/
  240. {0x81, 0x7C, 0x71, 0x4A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10.5dB*/
  241. {0x88, 0x84, 0x77, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-10dB*/
  242. {0x90, 0x8C, 0x7E, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9.5dB*/
  243. {0x99, 0x94, 0x86, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-9dB*/
  244. {0xA2, 0x9D, 0x8E, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8.5dB*/
  245. {0xAC, 0xA6, 0x96, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-8dB*/
  246. {0xB6, 0xB0, 0x9F, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7.5dB*/
  247. {0xC1, 0xBA, 0xA8, 0x6F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-7dB*/
  248. {0xCC, 0xC5, 0xB2, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-6.5dB*/
  249. {0xD8, 0xD1, 0xBD, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} /*-6dB*/
  250. };
  251. u8 cck_swing_table_ch1_ch13_new[CCK_TABLE_SIZE][8] = {
  252. {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}, /* 0, -16.0dB */
  253. {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 1, -15.5dB */
  254. {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 2, -15.0dB */
  255. {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 3, -14.5dB */
  256. {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 4, -14.0dB */
  257. {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 5, -13.5dB */
  258. {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 6, -13.0dB */
  259. {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 7, -12.5dB */
  260. {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 8, -12.0dB */
  261. {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 9, -11.5dB */
  262. {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 10, -11.0dB */
  263. {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 11, -10.5dB */
  264. {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 12, -10.0dB */
  265. {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 13, -9.5dB */
  266. {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 14, -9.0dB */
  267. {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 15, -8.5dB */
  268. {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */
  269. {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 17, -7.5dB */
  270. {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 18, -7.0dB */
  271. {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 19, -6.5dB */
  272. {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 20, -6.0dB */
  273. {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 21, -5.5dB */
  274. {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 22, -5.0dB */
  275. {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 23, -4.5dB */
  276. {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 24, -4.0dB */
  277. {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 25, -3.5dB */
  278. {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 26, -3.0dB */
  279. {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 27, -2.5dB */
  280. {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 28, -2.0dB */
  281. {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 29, -1.5dB */
  282. {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 30, -1.0dB */
  283. {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 31, -0.5dB */
  284. {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04} /* 32, +0dB */
  285. };
  286. u8 cck_swing_table_ch14_new[CCK_TABLE_SIZE][8] = {
  287. {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, /* 0, -16.0dB */
  288. {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 1, -15.5dB */
  289. {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 2, -15.0dB */
  290. {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 3, -14.5dB */
  291. {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 4, -14.0dB */
  292. {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 5, -13.5dB */
  293. {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 6, -13.0dB */
  294. {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 7, -12.5dB */
  295. {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 8, -12.0dB */
  296. {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 9, -11.5dB */
  297. {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 10, -11.0dB */
  298. {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 11, -10.5dB */
  299. {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 12, -10.0dB */
  300. {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 13, -9.5dB */
  301. {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 14, -9.0dB */
  302. {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 15, -8.5dB */
  303. {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */
  304. {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 17, -7.5dB */
  305. {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 18, -7.0dB */
  306. {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 19, -6.5dB */
  307. {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 20, -6.0dB */
  308. {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 21, -5.5dB */
  309. {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 22, -5.0dB */
  310. {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 23, -4.5dB */
  311. {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 24, -4.0dB */
  312. {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 25, -3.5dB */
  313. {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 26, -3.0dB */
  314. {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 27, -2.5dB */
  315. {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 28, -2.0dB */
  316. {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 29, -1.5dB */
  317. {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 30, -1.0dB */
  318. {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 31, -0.5dB */
  319. {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00} /* 32, +0dB */
  320. };
  321. u32 cck_swing_table_ch1_ch14_8723d[CCK_TABLE_SIZE_8723D] = {
  322. 0x0CD,
  323. 0x0D9,
  324. 0x0E6,
  325. 0x0F3,
  326. 0x102,
  327. 0x111,
  328. 0x121,
  329. 0x132,
  330. 0x144,
  331. 0x158,
  332. 0x16C,
  333. 0x182,
  334. 0x198,
  335. 0x1B1,
  336. 0x1CA,
  337. 0x1E5,
  338. 0x202,
  339. 0x221,
  340. 0x241,
  341. 0x263,
  342. 0x287,
  343. 0x2AE,
  344. 0x2D6,
  345. 0x301,
  346. 0x32F,
  347. 0x35F,
  348. 0x392,
  349. 0x3C9,
  350. 0x402,
  351. 0x43F,
  352. 0x47F,
  353. 0x4C3,
  354. 0x50C,
  355. 0x558,
  356. 0x5A9,
  357. 0x5FF,
  358. 0x65A,
  359. 0x6BA,
  360. 0x720,
  361. 0x78C,
  362. 0x7FF,
  363. };
  364. /* JJ ADD 20161014 */
  365. u32 cck_swing_table_ch1_ch14_8710b[CCK_TABLE_SIZE_8710B] = {
  366. 0x0CD, /*0 , -20dB*/
  367. 0x0D9,
  368. 0x0E6,
  369. 0x0F3,
  370. 0x102,
  371. 0x111,
  372. 0x121,
  373. 0x132,
  374. 0x144,
  375. 0x158,
  376. 0x16C,
  377. 0x182,
  378. 0x198,
  379. 0x1B1,
  380. 0x1CA,
  381. 0x1E5,
  382. 0x202,
  383. 0x221,
  384. 0x241,
  385. 0x263, /*19*/
  386. 0x287, /*20*/
  387. 0x2AE, /*21*/
  388. 0x2D6, /*22*/
  389. 0x301, /*23*/
  390. 0x32F, /*24*/
  391. 0x35F, /*25*/
  392. 0x392, /*26*/
  393. 0x3C9, /*27*/
  394. 0x402, /*28*/
  395. 0x43F, /*29*/
  396. 0x47F, /*30*/
  397. 0x4C3, /*31*/
  398. 0x50C, /*32*/
  399. 0x558, /*33*/
  400. 0x5A9, /*34*/
  401. 0x5FF, /*35*/
  402. 0x65A, /*36*/
  403. 0x6BA,
  404. 0x720,
  405. 0x78C,
  406. 0x7FF,
  407. };
  408. u32 tx_scaling_table_jaguar[TXSCALE_TABLE_SIZE] = {
  409. 0x081, /* 0, -12.0dB */
  410. 0x088, /* 1, -11.5dB */
  411. 0x090, /* 2, -11.0dB */
  412. 0x099, /* 3, -10.5dB */
  413. 0x0A2, /* 4, -10.0dB */
  414. 0x0AC, /* 5, -9.5dB */
  415. 0x0B6, /* 6, -9.0dB */
  416. 0x0C0, /* 7, -8.5dB */
  417. 0x0CC, /* 8, -8.0dB */
  418. 0x0D8, /* 9, -7.5dB */
  419. 0x0E5, /* 10, -7.0dB */
  420. 0x0F2, /* 11, -6.5dB */
  421. 0x101, /* 12, -6.0dB */
  422. 0x110, /* 13, -5.5dB */
  423. 0x120, /* 14, -5.0dB */
  424. 0x131, /* 15, -4.5dB */
  425. 0x143, /* 16, -4.0dB */
  426. 0x156, /* 17, -3.5dB */
  427. 0x16A, /* 18, -3.0dB */
  428. 0x180, /* 19, -2.5dB */
  429. 0x197, /* 20, -2.0dB */
  430. 0x1AF, /* 21, -1.5dB */
  431. 0x1C8, /* 22, -1.0dB */
  432. 0x1E3, /* 23, -0.5dB */
  433. 0x200, /* 24, +0 dB */
  434. 0x21E, /* 25, +0.5dB */
  435. 0x23E, /* 26, +1.0dB */
  436. 0x261, /* 27, +1.5dB */
  437. 0x285, /* 28, +2.0dB */
  438. 0x2AB, /* 29, +2.5dB */
  439. 0x2D3, /* 30, +3.0dB */
  440. 0x2FE, /* 31, +3.5dB */
  441. 0x32B, /* 32, +4.0dB */
  442. 0x35C, /* 33, +4.5dB */
  443. 0x38E, /* 34, +5.0dB */
  444. 0x3C4, /* 35, +5.5dB */
  445. 0x3FE /* 36, +6.0dB */
  446. };
  447. #ifdef AP_BUILD_WORKAROUND
  448. unsigned int tx_pwr_trk_ofdm_swing_tbl[tx_pwr_trk_ofdm_swing_tbl_len] = {
  449. /* +6.0dB */ 0x7f8001fe,
  450. /* +5.5dB */ 0x788001e2,
  451. /* +5.0dB */ 0x71c001c7,
  452. /* +4.5dB */ 0x6b8001ae,
  453. /* +4.0dB */ 0x65400195,
  454. /* +3.5dB */ 0x5fc0017f,
  455. /* +3.0dB */ 0x5a400169,
  456. /* +2.5dB */ 0x55400155,
  457. /* +2.0dB */ 0x50800142,
  458. /* +1.5dB */ 0x4c000130,
  459. /* +1.0dB */ 0x47c0011f,
  460. /* +0.5dB */ 0x43c0010f,
  461. /* 0.0dB */ 0x40000100,
  462. /* -0.5dB */ 0x3c8000f2,
  463. /* -1.0dB */ 0x390000e4,
  464. /* -1.5dB */ 0x35c000d7,
  465. /* -2.0dB */ 0x32c000cb,
  466. /* -2.5dB */ 0x300000c0,
  467. /* -3.0dB */ 0x2d4000b5,
  468. /* -3.5dB */ 0x2ac000ab,
  469. /* -4.0dB */ 0x288000a2,
  470. /* -4.5dB */ 0x26000098,
  471. /* -5.0dB */ 0x24000090,
  472. /* -5.5dB */ 0x22000088,
  473. /* -6.0dB */ 0x20000080,
  474. /* -6.5dB */ 0x1a00006c,
  475. /* -7.0dB */ 0x1c800072,
  476. /* -7.5dB */ 0x18000060,
  477. /* -8.0dB */ 0x19800066,
  478. /* -8.5dB */ 0x15800056,
  479. /* -9.0dB */ 0x26c0005b,
  480. /* -9.5dB */ 0x14400051,
  481. /* -10.0dB */ 0x24400051,
  482. /* -10.5dB */ 0x1300004c,
  483. /* -11.0dB */ 0x12000048,
  484. /* -11.5dB */ 0x11000044,
  485. /* -12.0dB */ 0x10000040
  486. };
  487. #endif
  488. void
  489. odm_txpowertracking_init(
  490. void *p_dm_void
  491. )
  492. {
  493. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  494. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  495. if (!(p_dm_odm->support_ic_type & (ODM_RTL8814A | ODM_IC_11N_SERIES | ODM_RTL8822B)))
  496. return;
  497. #endif
  498. odm_txpowertracking_thermal_meter_init(p_dm_odm);
  499. }
  500. u8
  501. get_swing_index(
  502. void *p_dm_void
  503. )
  504. {
  505. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  506. struct _ADAPTER *adapter = p_dm_odm->adapter;
  507. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  508. u8 i = 0;
  509. u32 bb_swing;
  510. u32 swing_table_size;
  511. u32 *p_swing_table;
  512. if (p_dm_odm->support_ic_type == ODM_RTL8188E || p_dm_odm->support_ic_type == ODM_RTL8723B ||
  513. p_dm_odm->support_ic_type == ODM_RTL8192E || p_dm_odm->support_ic_type == ODM_RTL8188F || p_dm_odm->support_ic_type == ODM_RTL8703B) {
  514. bb_swing = odm_get_bb_reg(p_dm_odm, REG_OFDM_0_XA_TX_IQ_IMBALANCE, 0xFFC00000);
  515. p_swing_table = ofdm_swing_table_new;
  516. swing_table_size = OFDM_TABLE_SIZE;
  517. } else {
  518. bb_swing = PHY_GetTxBBSwing_8812A(adapter, p_hal_data->CurrentBandType, ODM_RF_PATH_A);
  519. p_swing_table = tx_scaling_table_jaguar;
  520. swing_table_size = TXSCALE_TABLE_SIZE;
  521. }
  522. for (i = 0; i < swing_table_size; ++i) {
  523. u32 table_value = p_swing_table[i];
  524. if (table_value >= 0x100000)
  525. table_value >>= 22;
  526. if (bb_swing == table_value)
  527. break;
  528. }
  529. return i;
  530. }
  531. u8
  532. get_cck_swing_index(
  533. void *p_dm_void
  534. )
  535. {
  536. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  537. u8 i = 0;
  538. u32 bb_cck_swing;
  539. if (p_dm_odm->support_ic_type == ODM_RTL8188E || p_dm_odm->support_ic_type == ODM_RTL8723B ||
  540. p_dm_odm->support_ic_type == ODM_RTL8192E) {
  541. bb_cck_swing = odm_read_1byte(p_dm_odm, 0xa22);
  542. for (i = 0; i < CCK_TABLE_SIZE; i++) {
  543. if (bb_cck_swing == cck_swing_table_ch1_ch13_new[i][0])
  544. break;
  545. }
  546. } else if (p_dm_odm->support_ic_type == ODM_RTL8703B) {
  547. bb_cck_swing = odm_read_1byte(p_dm_odm, 0xa22);
  548. for (i = 0; i < CCK_TABLE_SIZE_88F; i++) {
  549. if (bb_cck_swing == cck_swing_table_ch1_ch14_88f[i][0])
  550. break;
  551. }
  552. }
  553. return i;
  554. }
  555. void
  556. odm_txpowertracking_thermal_meter_init(
  557. void *p_dm_void
  558. )
  559. {
  560. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  561. u8 default_swing_index = get_swing_index(p_dm_odm);
  562. u8 default_cck_swing_index = get_cck_swing_index(p_dm_odm);
  563. struct odm_rf_calibration_structure *p_rf_calibrate_info = &(p_dm_odm->rf_calibrate_info);
  564. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  565. struct _ADAPTER *adapter = p_dm_odm->adapter;
  566. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  567. u8 p = 0;
  568. if (p_dm_odm->mp_mode == false)
  569. p_rf_calibrate_info->txpowertrack_control = true;
  570. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
  571. #ifdef CONFIG_RTL8188E
  572. {
  573. p_rf_calibrate_info->is_txpowertracking = _TRUE;
  574. p_rf_calibrate_info->tx_powercount = 0;
  575. p_rf_calibrate_info->is_txpowertracking_init = _FALSE;
  576. if (p_dm_odm->mp_mode == false)
  577. p_rf_calibrate_info->txpowertrack_control = _TRUE;
  578. MSG_8192C("p_dm_odm txpowertrack_control = %d\n", p_rf_calibrate_info->txpowertrack_control);
  579. }
  580. #else
  581. {
  582. struct _ADAPTER *adapter = p_dm_odm->adapter;
  583. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  584. struct dm_priv *pdmpriv = &p_hal_data->dmpriv;
  585. pdmpriv->is_txpowertracking = _TRUE;
  586. pdmpriv->tx_powercount = 0;
  587. pdmpriv->is_txpowertracking_init = _FALSE;
  588. if (p_dm_odm->mp_mode == false)
  589. pdmpriv->txpowertrack_control = _TRUE;
  590. MSG_8192C("pdmpriv->txpowertrack_control = %d\n", pdmpriv->txpowertrack_control);
  591. }
  592. #endif
  593. #elif (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  594. #ifdef RTL8188E_SUPPORT
  595. {
  596. p_rf_calibrate_info->is_txpowertracking = _TRUE;
  597. p_rf_calibrate_info->tx_powercount = 0;
  598. p_rf_calibrate_info->is_txpowertracking_init = _FALSE;
  599. p_rf_calibrate_info->txpowertrack_control = _TRUE;
  600. }
  601. #endif
  602. #endif
  603. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  604. #if (MP_DRIVER == 1)
  605. p_rf_calibrate_info->txpowertrack_control = false;
  606. #else
  607. p_rf_calibrate_info->txpowertrack_control = true;
  608. #endif
  609. #else
  610. p_rf_calibrate_info->txpowertrack_control = true;
  611. #endif
  612. p_rf_calibrate_info->thermal_value = p_hal_data->eeprom_thermal_meter;
  613. p_rf_calibrate_info->thermal_value_iqk = p_hal_data->eeprom_thermal_meter;
  614. p_rf_calibrate_info->thermal_value_lck = p_hal_data->eeprom_thermal_meter;
  615. if (p_rf_calibrate_info->default_bb_swing_index_flag != true) {
  616. /*The index of "0 dB" in SwingTable.*/
  617. if (p_dm_odm->support_ic_type == ODM_RTL8188E || p_dm_odm->support_ic_type == ODM_RTL8723B ||
  618. p_dm_odm->support_ic_type == ODM_RTL8192E || p_dm_odm->support_ic_type == ODM_RTL8703B) {
  619. p_rf_calibrate_info->default_ofdm_index = (default_swing_index >= OFDM_TABLE_SIZE) ? 30 : default_swing_index;
  620. p_rf_calibrate_info->default_cck_index = (default_cck_swing_index >= CCK_TABLE_SIZE) ? 20 : default_cck_swing_index;
  621. } else if (p_dm_odm->support_ic_type == ODM_RTL8188F) { /*add by Mingzhi.Guo 2015-03-23*/
  622. p_rf_calibrate_info->default_ofdm_index = 28; /*OFDM: -1dB*/
  623. p_rf_calibrate_info->default_cck_index = 20; /*CCK:-6dB*/
  624. } else if (p_dm_odm->support_ic_type == ODM_RTL8723D) { /*add by zhaohe 2015-10-27*/
  625. p_rf_calibrate_info->default_ofdm_index = 28; /*OFDM: -1dB*/
  626. p_rf_calibrate_info->default_cck_index = 28; /*CCK: -6dB*/
  627. /* JJ ADD 20161014 */
  628. } else if (p_dm_odm->support_ic_type == ODM_RTL8710B) {
  629. p_rf_calibrate_info->default_ofdm_index = 28; /*OFDM: -1dB*/
  630. p_rf_calibrate_info->default_cck_index = 28; /*CCK: -6dB*/
  631. } else {
  632. p_rf_calibrate_info->default_ofdm_index = (default_swing_index >= TXSCALE_TABLE_SIZE) ? 24 : default_swing_index;
  633. p_rf_calibrate_info->default_cck_index = 24;
  634. }
  635. p_rf_calibrate_info->default_bb_swing_index_flag = true;
  636. }
  637. p_rf_calibrate_info->bb_swing_idx_cck_base = p_rf_calibrate_info->default_cck_index;
  638. p_rf_calibrate_info->CCK_index = p_rf_calibrate_info->default_cck_index;
  639. for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) {
  640. p_rf_calibrate_info->bb_swing_idx_ofdm_base[p] = p_rf_calibrate_info->default_ofdm_index;
  641. p_rf_calibrate_info->OFDM_index[p] = p_rf_calibrate_info->default_ofdm_index;
  642. p_rf_calibrate_info->delta_power_index[p] = 0;
  643. p_rf_calibrate_info->delta_power_index_last[p] = 0;
  644. p_rf_calibrate_info->power_index_offset[p] = 0;
  645. p_rf_calibrate_info->kfree_offset[p] = 0;
  646. }
  647. p_rf_calibrate_info->modify_tx_agc_value_ofdm = 0;
  648. p_rf_calibrate_info->modify_tx_agc_value_cck = 0;
  649. }
  650. void
  651. odm_txpowertracking_check(
  652. void *p_dm_void
  653. )
  654. {
  655. #if 0
  656. /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
  657. /* at the same time. In the stage2/3, we need to prive universal interface and merge all */
  658. /* HW dynamic mechanism. */
  659. #endif
  660. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  661. switch (p_dm_odm->support_platform) {
  662. case ODM_WIN:
  663. odm_txpowertracking_check_mp(p_dm_odm);
  664. break;
  665. case ODM_CE:
  666. odm_txpowertracking_check_ce(p_dm_odm);
  667. break;
  668. case ODM_AP:
  669. odm_txpowertracking_check_ap(p_dm_odm);
  670. break;
  671. default:
  672. break;
  673. }
  674. }
  675. void
  676. odm_txpowertracking_check_ce(
  677. void *p_dm_void
  678. )
  679. {
  680. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  681. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  682. struct _ADAPTER *adapter = p_dm_odm->adapter;
  683. #if ((RTL8188F_SUPPORT == 1))
  684. rtl8192c_odm_check_txpowertracking(adapter);
  685. #endif
  686. #if (RTL8188E_SUPPORT == 1)
  687. if (!(p_dm_odm->support_ability & ODM_RF_TX_PWR_TRACK))
  688. return;
  689. if (!p_rf_calibrate_info->tm_trigger) {
  690. odm_set_rf_reg(p_dm_odm, ODM_RF_PATH_A, RF_T_METER, RFREGOFFSETMASK, 0x60);
  691. /*DBG_8192C("Trigger 92C Thermal Meter!!\n");*/
  692. p_rf_calibrate_info->tm_trigger = 1;
  693. return;
  694. } else {
  695. /*DBG_8192C("Schedule TxPowerTracking direct call!!\n");*/
  696. odm_txpowertracking_callback_thermal_meter_8188e(adapter);
  697. p_rf_calibrate_info->tm_trigger = 0;
  698. }
  699. #endif
  700. #endif
  701. }
  702. void
  703. odm_txpowertracking_check_mp(
  704. void *p_dm_void
  705. )
  706. {
  707. struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
  708. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  709. struct _ADAPTER *adapter = p_dm_odm->adapter;
  710. if (*p_dm_odm->p_is_fcs_mode_enable)
  711. return;
  712. if (odm_check_power_status(adapter) == false) {
  713. RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("===>odm_check_power_status() return false\n"));
  714. return;
  715. }
  716. if (IS_HARDWARE_TYPE_8821B(adapter)) /* TODO: Don't Do PowerTracking*/
  717. return;
  718. odm_txpowertracking_thermal_meter_check(adapter);
  719. #endif
  720. }
  721. void
  722. odm_txpowertracking_check_ap(
  723. void *p_dm_void
  724. )
  725. {
  726. return;
  727. }
  728. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  729. void
  730. odm_txpowertracking_direct_call(
  731. struct _ADAPTER *adapter
  732. )
  733. {
  734. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  735. struct PHY_DM_STRUCT *p_dm_odm = &p_hal_data->DM_OutSrc;
  736. odm_txpowertracking_callback_thermal_meter(adapter);
  737. }
  738. void
  739. odm_txpowertracking_thermal_meter_check(
  740. struct _ADAPTER *adapter
  741. )
  742. {
  743. #ifndef AP_BUILD_WORKAROUND
  744. static u8 tm_trigger = 0;
  745. if (!(GET_HAL_DATA(adapter)->DM_OutSrc.support_ability & ODM_RF_TX_PWR_TRACK)) {
  746. RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD,
  747. ("===>odm_txpowertracking_thermal_meter_check(),p_mgnt_info->is_txpowertracking is false, return!!\n"));
  748. return;
  749. }
  750. if (!tm_trigger) {
  751. if (IS_HARDWARE_TYPE_8188E(adapter) || IS_HARDWARE_TYPE_JAGUAR(adapter) || IS_HARDWARE_TYPE_8192E(adapter) ||
  752. IS_HARDWARE_TYPE_8723B(adapter) || IS_HARDWARE_TYPE_8814A(adapter) || IS_HARDWARE_TYPE_8188F(adapter) || IS_HARDWARE_TYPE_8703B(adapter)
  753. || IS_HARDWARE_TYPE_8822B(adapter) || IS_HARDWARE_TYPE_8723D(adapter) || IS_HARDWARE_TYPE_8821C(adapter) || IS_HARDWARE_TYPE_8710B(adapter))/* JJ ADD 20161014 */
  754. PHY_SetRFReg(adapter, ODM_RF_PATH_A, RF_T_METER_88E, BIT(17) | BIT(16), 0x03);
  755. else
  756. PHY_SetRFReg(adapter, ODM_RF_PATH_A, RF_T_METER, RFREGOFFSETMASK, 0x60);
  757. RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Trigger Thermal Meter!!\n"));
  758. tm_trigger = 1;
  759. return;
  760. } else {
  761. RT_TRACE(COMP_POWER_TRACKING, DBG_LOUD, ("Schedule TxPowerTracking direct call!!\n"));
  762. odm_txpowertracking_direct_call(adapter);
  763. tm_trigger = 0;
  764. }
  765. #endif
  766. }
  767. #endif