phydm_dynamictxpower.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. /*************************************************************
  26. * include files
  27. ************************************************************/
  28. #include "mp_precomp.h"
  29. #include "phydm_precomp.h"
  30. #ifdef CONFIG_DYNAMIC_TX_TWR
  31. #ifdef BB_RAM_SUPPORT
  32. void
  33. phydm_2ndtype_dtp_init(void *dm_void)
  34. {
  35. struct dm_struct *dm = (struct dm_struct *)dm_void;
  36. u8 pwr_offset_minus3, pwr_offset_minus7;
  37. /*@ 2's com, for offset 3dB and 7dB, which 1 step will be 0.25dB*/
  38. pwr_offset_minus3 = BIT(7) | 0x74;
  39. pwr_offset_minus7 = BIT(7) | 0x64;
  40. odm_set_bb_reg(dm, 0x1e70, 0x00ff0000, pwr_offset_minus3);
  41. odm_set_bb_reg(dm, 0x1e70, 0xff000000, pwr_offset_minus7);
  42. };
  43. void
  44. phdm_2ndtype_rd_ram_pwr(void *dm_void, u8 macid)
  45. {
  46. };
  47. void
  48. phdm_2ndtype_wt_ram_pwr(void *dm_void, u8 macid, boolean pwr_offset0_en,
  49. boolean pwr_offset1_en, s8 pwr_offset0, s8 pwr_offset1)
  50. {
  51. u32 reg_io_0x1e84 = 0;
  52. struct dm_struct *dm = (struct dm_struct *)dm_void;
  53. struct phydm_bb_ram_per_sta *dm_ram_per_sta = NULL;
  54. dm_ram_per_sta = &dm->p_bb_ram_ctrl.pram_sta_ctrl[macid];
  55. dm_ram_per_sta->tx_pwr_offset0_en = pwr_offset0_en;
  56. dm_ram_per_sta->tx_pwr_offset1_en = pwr_offset1_en;
  57. dm_ram_per_sta->tx_pwr_offset0 = pwr_offset0;
  58. dm_ram_per_sta->tx_pwr_offset1 = pwr_offset1;
  59. reg_io_0x1e84 = (dm_ram_per_sta->hw_igi_en<<7) + dm_ram_per_sta->hw_igi;
  60. reg_io_0x1e84 |= (pwr_offset0_en<<15) + ((pwr_offset0&0x7f)<<8);
  61. reg_io_0x1e84 |= (pwr_offset1_en<<23) + ((pwr_offset1&0x7f)<<16);
  62. reg_io_0x1e84 |= (macid&0x3f)<<24;
  63. reg_io_0x1e84 |= BIT(30);
  64. odm_set_bb_reg(dm, 0x1e84, 0xffffffff, reg_io_0x1e84);
  65. };
  66. u8 phydm_pwr_lv_mapping_2ndtype(u8 tx_pwr_lv)
  67. {
  68. if (tx_pwr_lv == tx_high_pwr_level_level3)
  69. /*PHYDM_2ND_OFFSET_MINUS_11DB;*/
  70. return PHYDM_2ND_OFFSET_MINUS_7DB;
  71. else if (tx_pwr_lv == tx_high_pwr_level_level2)
  72. return PHYDM_2ND_OFFSET_MINUS_7DB;
  73. else if (tx_pwr_lv == tx_high_pwr_level_level1)
  74. return PHYDM_2ND_OFFSET_MINUS_3DB;
  75. else
  76. return PHYDM_2ND_OFFSET_ZERO;
  77. }
  78. void phydm_dtp_fill_cmninfo_2ndtype(void *dm_void, u8 macid, u8 dtp_lvl)
  79. {
  80. struct dm_struct *dm = (struct dm_struct *)dm_void;
  81. struct dtp_info *dtp = NULL;
  82. dtp = &dm->phydm_sta_info[macid]->dtp_stat;
  83. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  84. return;
  85. dtp->dyn_tx_power = phydm_pwr_lv_mapping_2ndtype(dtp_lvl);
  86. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  87. "Fill cmninfo TxPwr: macid=(%d), PwrLv (%d)\n", macid,
  88. dtp->dyn_tx_power);
  89. /* dyn_tx_power is 2 bit at 8822C/14B/98F/12F*/
  90. }
  91. #endif
  92. boolean
  93. phydm_check_rates(void *dm_void, u8 rate_idx)
  94. {
  95. struct dm_struct *dm = (struct dm_struct *)dm_void;
  96. u32 check_rate_bitmap0 = 0x08080808; /* @check CCK11M, OFDM54M, MCS7, MCS15*/
  97. u32 check_rate_bitmap1 = 0x80200808; /* @check MCS23, MCS31, VHT1SS M9, VHT2SS M9*/
  98. u32 check_rate_bitmap2 = 0x00080200; /* @check VHT3SS M9, VHT4SS M9*/
  99. u32 bitmap_result;
  100. #if (RTL8822B_SUPPORT == 1)
  101. if (dm->support_ic_type & ODM_RTL8822B) {
  102. check_rate_bitmap2 &= 0;
  103. check_rate_bitmap1 &= 0xfffff000;
  104. check_rate_bitmap0 &= 0x0fffffff;
  105. }
  106. #endif
  107. #if (RTL8197F_SUPPORT == 1)
  108. if (dm->support_ic_type & ODM_RTL8197F) {
  109. check_rate_bitmap2 &= 0;
  110. check_rate_bitmap1 &= 0;
  111. check_rate_bitmap0 &= 0x0fffffff;
  112. }
  113. #endif
  114. #if (RTL8192E_SUPPORT == 1)
  115. if (dm->support_ic_type & ODM_RTL8192E) {
  116. check_rate_bitmap2 &= 0;
  117. check_rate_bitmap1 &= 0;
  118. check_rate_bitmap0 &= 0x0fffffff;
  119. }
  120. #endif
  121. /*@jj add 20170822*/
  122. #if (RTL8192F_SUPPORT == 1)
  123. if (dm->support_ic_type & ODM_RTL8192F) {
  124. check_rate_bitmap2 &= 0;
  125. check_rate_bitmap1 &= 0;
  126. check_rate_bitmap0 &= 0x0fffffff;
  127. }
  128. #endif
  129. #if (RTL8821C_SUPPORT == 1)
  130. if (dm->support_ic_type & ODM_RTL8821C) {
  131. check_rate_bitmap2 &= 0;
  132. check_rate_bitmap1 &= 0x003ff000;
  133. check_rate_bitmap0 &= 0x000fffff;
  134. }
  135. #endif
  136. if (rate_idx >= 64)
  137. bitmap_result = BIT(rate_idx - 64) & check_rate_bitmap2;
  138. else if (rate_idx >= 32)
  139. bitmap_result = BIT(rate_idx - 32) & check_rate_bitmap1;
  140. else if (rate_idx <= 31)
  141. bitmap_result = BIT(rate_idx) & check_rate_bitmap0;
  142. if (bitmap_result != 0)
  143. return true;
  144. else
  145. return false;
  146. }
  147. enum rf_path
  148. phydm_check_paths(void *dm_void)
  149. {
  150. struct dm_struct *dm = (struct dm_struct *)dm_void;
  151. enum rf_path max_path = RF_PATH_A;
  152. if (dm->num_rf_path == 1)
  153. max_path = RF_PATH_A;
  154. if (dm->num_rf_path == 2)
  155. max_path = RF_PATH_B;
  156. if (dm->num_rf_path == 3)
  157. max_path = RF_PATH_C;
  158. if (dm->num_rf_path == 4)
  159. max_path = RF_PATH_D;
  160. return max_path;
  161. }
  162. #ifndef PHYDM_COMMON_API_SUPPORT
  163. u8 phydm_dtp_get_txagc(void *dm_void, enum rf_path path, u8 hw_rate)
  164. {
  165. struct dm_struct *dm = (struct dm_struct *)dm_void;
  166. u8 ret = 0xff;
  167. #if (RTL8192E_SUPPORT == 1)
  168. ret = config_phydm_read_txagc_n(dm, path, hw_rate);
  169. #endif
  170. return ret;
  171. }
  172. #endif
  173. u8 phydm_search_min_power_index(void *dm_void)
  174. {
  175. struct dm_struct *dm = (struct dm_struct *)dm_void;
  176. enum rf_path path;
  177. enum rf_path max_path;
  178. u8 min_gain_index = 0x3f;
  179. u8 gain_index;
  180. u8 rate_idx;
  181. PHYDM_DBG(dm, DBG_DYN_TXPWR, "%s\n", __func__);
  182. max_path = phydm_check_paths(dm);
  183. for (path = 0; path <= max_path; path++)
  184. for (rate_idx = 0; rate_idx < 84; rate_idx++)
  185. if (phydm_check_rates(dm, rate_idx)) {
  186. #ifdef PHYDM_COMMON_API_SUPPORT
  187. /*This is for API support IC : 97F,8822B,92F,8821C*/
  188. gain_index = phydm_api_get_txagc(dm, path, rate_idx);
  189. #else
  190. /*This is for API non-support IC : 92E */
  191. gain_index = phydm_dtp_get_txagc(dm, path, rate_idx);
  192. #endif
  193. if (gain_index == 0xff) {
  194. min_gain_index = 0x20;
  195. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  196. "Error Gain idx!! Rewite to: ((%d))\n", min_gain_index);
  197. break;
  198. }
  199. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  200. "Support Rate: ((%d)) -> Gain idx: ((%d))\n",
  201. rate_idx, gain_index);
  202. if (gain_index < min_gain_index)
  203. min_gain_index = gain_index;
  204. }
  205. return min_gain_index;
  206. }
  207. void phydm_dynamic_tx_power_init(void *dm_void)
  208. {
  209. struct dm_struct *dm = (struct dm_struct *)dm_void;
  210. u8 i;
  211. dm->last_dtp_lvl = tx_high_pwr_level_normal;
  212. dm->dynamic_tx_high_power_lvl = tx_high_pwr_level_normal;
  213. for (i = 0; i < 3; i++) {
  214. dm->enhance_pwr_th[i] = 0xff;
  215. }
  216. dm->set_pwr_th[0] = TX_POWER_NEAR_FIELD_THRESH_LVL1;
  217. dm->set_pwr_th[1] = TX_POWER_NEAR_FIELD_THRESH_LVL2;
  218. dm->set_pwr_th[2] = 0xff;
  219. dm->min_power_index = phydm_search_min_power_index(dm);
  220. PHYDM_DBG(dm, DBG_DYN_TXPWR, "DTP init: Min Gain idx: ((%d))\n",
  221. dm->min_power_index);
  222. }
  223. void phydm_noisy_enhance_hp_th(void *dm_void, u8 noisy_state)
  224. {
  225. struct dm_struct *dm = (struct dm_struct *)dm_void;
  226. if (noisy_state == 0) {
  227. dm->enhance_pwr_th[0] = dm->set_pwr_th[0];
  228. dm->enhance_pwr_th[1] = dm->set_pwr_th[1];
  229. dm->enhance_pwr_th[2] = dm->set_pwr_th[2];
  230. } else {
  231. dm->enhance_pwr_th[0] = dm->set_pwr_th[0] + 8;
  232. dm->enhance_pwr_th[1] = dm->set_pwr_th[1] + 5;
  233. dm->enhance_pwr_th[2] = dm->set_pwr_th[2];
  234. }
  235. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  236. "DTP hp_th: Lv1_th =%d ,Lv2_th = %d ,Lv3_th = %d\n",
  237. dm->enhance_pwr_th[0], dm->enhance_pwr_th[1],
  238. dm->enhance_pwr_th[2]);
  239. }
  240. u8 phydm_pwr_lvl_check(void *dm_void, u8 input_rssi)
  241. {
  242. struct dm_struct *dm = (struct dm_struct *)dm_void;
  243. u8 th0,th1,th2;
  244. th2 = dm->enhance_pwr_th[2];
  245. th1 = dm->enhance_pwr_th[1];
  246. th0 = dm->enhance_pwr_th[0];
  247. if (input_rssi >= th2)
  248. return tx_high_pwr_level_level3;
  249. else if (input_rssi < (th2 - 3) && input_rssi >= th1)
  250. return tx_high_pwr_level_level2;
  251. else if (input_rssi < (th1 - 3) && input_rssi >= th0)
  252. return tx_high_pwr_level_level1;
  253. else if (input_rssi < (th0 - 3))
  254. return tx_high_pwr_level_normal;
  255. else
  256. return tx_high_pwr_level_unchange;
  257. }
  258. u8 phydm_pwr_lv_mapping(u8 tx_pwr_lv)
  259. {
  260. if (tx_pwr_lv == tx_high_pwr_level_level3)
  261. return PHYDM_OFFSET_MINUS_11DB;
  262. else if (tx_pwr_lv == tx_high_pwr_level_level2)
  263. return PHYDM_OFFSET_MINUS_7DB;
  264. else if (tx_pwr_lv == tx_high_pwr_level_level1)
  265. return PHYDM_OFFSET_MINUS_3DB;
  266. else
  267. return PHYDM_OFFSET_ZERO;
  268. }
  269. void phydm_dynamic_response_power(void *dm_void)
  270. {
  271. struct dm_struct *dm = (struct dm_struct *)dm_void;
  272. u8 rpwr;
  273. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  274. return;
  275. if (dm->dynamic_tx_high_power_lvl == tx_high_pwr_level_unchange) {
  276. dm->dynamic_tx_high_power_lvl = dm->last_dtp_lvl;
  277. PHYDM_DBG(dm, DBG_DYN_TXPWR, "RespPwr not change\n");
  278. return;
  279. }
  280. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  281. "RespPwr update_DTP_lv: ((%d)) -> ((%d))\n", dm->last_dtp_lvl,
  282. dm->dynamic_tx_high_power_lvl);
  283. dm->last_dtp_lvl = dm->dynamic_tx_high_power_lvl;
  284. rpwr = phydm_pwr_lv_mapping(dm->dynamic_tx_high_power_lvl);
  285. odm_set_mac_reg(dm, ODM_REG_RESP_TX_11AC, BIT(20) | BIT(19) | BIT(18), rpwr);
  286. PHYDM_DBG(dm, DBG_DYN_TXPWR, "RespPwr Set TxPwr: Lv (%d)\n",
  287. dm->dynamic_tx_high_power_lvl);
  288. }
  289. void phydm_dtp_fill_cmninfo(void *dm_void, u8 macid, u8 dtp_lvl)
  290. {
  291. struct dm_struct *dm = (struct dm_struct *)dm_void;
  292. struct dtp_info *dtp = NULL;
  293. dtp = &dm->phydm_sta_info[macid]->dtp_stat;
  294. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  295. return;
  296. dtp->dyn_tx_power = phydm_pwr_lv_mapping(dtp_lvl);
  297. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  298. "Fill cmninfo TxPwr: macid=(%d), PwrLv (%d)\n", macid,
  299. dtp->dyn_tx_power);
  300. }
  301. void phydm_dtp_per_sta(void *dm_void, u8 macid)
  302. {
  303. struct dm_struct *dm = (struct dm_struct *)dm_void;
  304. struct cmn_sta_info *sta = dm->phydm_sta_info[macid];
  305. struct dtp_info *dtp = NULL;
  306. struct rssi_info *rssi = NULL;
  307. if (is_sta_active(sta)) {
  308. dtp = &sta->dtp_stat;
  309. rssi = &sta->rssi_stat;
  310. dtp->sta_tx_high_power_lvl = phydm_pwr_lvl_check(dm, rssi->rssi);
  311. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  312. "STA=%d , RSSI: %d , GetPwrLv: %d\n", macid,
  313. rssi->rssi, dtp->sta_tx_high_power_lvl);
  314. if (dtp->sta_tx_high_power_lvl == tx_high_pwr_level_unchange
  315. || dtp->sta_tx_high_power_lvl == dtp->sta_last_dtp_lvl) {
  316. dtp->sta_tx_high_power_lvl = dtp->sta_last_dtp_lvl;
  317. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  318. "DTP_lv not change: ((%d))\n",
  319. dtp->sta_tx_high_power_lvl);
  320. return;
  321. }
  322. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  323. "DTP_lv update: ((%d)) -> ((%d))\n", dm->last_dtp_lvl,
  324. dm->dynamic_tx_high_power_lvl);
  325. dtp->sta_last_dtp_lvl = dtp->sta_tx_high_power_lvl;
  326. #ifdef BB_RAM_SUPPORT
  327. phydm_dtp_fill_cmninfo_2ndtype(dm, macid, dtp->sta_tx_high_power_lvl);
  328. #else
  329. phydm_dtp_fill_cmninfo(dm, macid, dtp->sta_tx_high_power_lvl);
  330. #endif
  331. }
  332. }
  333. void odm_set_dyntxpwr(void *dm_void, u8 *desc, u8 macid)
  334. {
  335. struct dm_struct *dm = (struct dm_struct *)dm_void;
  336. struct dtp_info *dtp = NULL;
  337. dtp = &dm->phydm_sta_info[macid]->dtp_stat;
  338. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  339. return;
  340. if (dm->fill_desc_dyntxpwr)
  341. dm->fill_desc_dyntxpwr(dm, desc, dtp->dyn_tx_power);
  342. else
  343. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  344. "%s: fill_desc_dyntxpwr is null!\n", __func__);
  345. if (dtp->last_tx_power != dtp->dyn_tx_power) {
  346. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  347. "%s: last_offset=%d, txpwr_offset=%d\n", __func__,
  348. dtp->last_tx_power, dtp->dyn_tx_power);
  349. dtp->last_tx_power = dtp->dyn_tx_power;
  350. }
  351. }
  352. void phydm_dtp_debug(void *dm_void, char input[][16], u32 *_used, char *output,
  353. u32 *_out_len)
  354. {
  355. u32 used = *_used;
  356. u32 out_len = *_out_len;
  357. struct dm_struct *dm = (struct dm_struct *)dm_void;
  358. char help[] = "-h";
  359. u32 var1[3] = {0};
  360. u8 set_pwr_th1, set_pwr_th2, set_pwr_th3;
  361. u8 i;
  362. if ((strcmp(input[1], help) == 0)) {
  363. PDM_SNPF(out_len, used, output + used, out_len - used,
  364. "{DynTxPwr} {TH1 TH2 TH3}\n");
  365. } else {
  366. for (i = 0; i < 3; i++) {
  367. if (input[i + 1])
  368. PHYDM_SSCANF(input[i + 1], DCMD_HEX, &var1[i]);
  369. }
  370. for (i = 0; i < 3; i++)
  371. if (var1[i] == 0 || var1[i] > 100)
  372. dm->set_pwr_th[i] = 0xff;
  373. else
  374. dm->set_pwr_th[i] = (u8)var1[i];
  375. PDM_SNPF(out_len, used, output + used, out_len - used,
  376. "Phydm Set DTP : TH1 = (( 0x%x)), TH2 = (( 0x%x)), TH3 = (( 0x%x))\n",
  377. dm->set_pwr_th[0], dm->set_pwr_th[1],
  378. dm->set_pwr_th[2]);
  379. }
  380. *_used = used;
  381. *_out_len = out_len;
  382. }
  383. void phydm_dynamic_tx_power(void *dm_void)
  384. {
  385. struct dm_struct *dm = (struct dm_struct *)dm_void;
  386. struct cmn_sta_info *sta = NULL;
  387. u8 i;
  388. u8 cnt = 0;
  389. u8 rssi_min = dm->rssi_min;
  390. u8 rssi_tmp = 0;
  391. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  392. return;
  393. PHYDM_DBG(dm, DBG_DYN_TXPWR,
  394. "[%s] RSSI_min = %d, Noisy_dec = %d\n", __func__, rssi_min,
  395. dm->noisy_decision);
  396. phydm_noisy_enhance_hp_th(dm, dm->noisy_decision);
  397. #ifndef BB_RAM_SUPPORT
  398. /* Response Power */
  399. dm->dynamic_tx_high_power_lvl = phydm_pwr_lvl_check(dm, rssi_min);
  400. phydm_dynamic_response_power(dm);
  401. #endif /* #ifndef BB_RAM_SUPPORT */
  402. /* Per STA Tx power */
  403. for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
  404. phydm_dtp_per_sta(dm, i);
  405. cnt++;
  406. if (cnt >= dm->number_linked_client)
  407. break;
  408. }
  409. }
  410. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  411. void phydm_dynamic_tx_power_init_win(void *dm_void)
  412. {
  413. struct dm_struct *dm = (struct dm_struct *)dm_void;
  414. void *adapter = dm->adapter;
  415. PMGNT_INFO mgnt_info = &((PADAPTER)adapter)->MgntInfo;
  416. HAL_DATA_TYPE *hal_data = GET_HAL_DATA((PADAPTER)adapter);
  417. mgnt_info->bDynamicTxPowerEnable = false;
  418. #if DEV_BUS_TYPE == RT_USB_INTERFACE
  419. if (RT_GetInterfaceSelection((PADAPTER)adapter) ==
  420. INTF_SEL1_USB_High_Power) {
  421. mgnt_info->bDynamicTxPowerEnable = true;
  422. }
  423. #endif
  424. hal_data->LastDTPLvl = tx_high_pwr_level_normal;
  425. hal_data->DynamicTxHighPowerLvl = tx_high_pwr_level_normal;
  426. PHYDM_DBG(dm, DBG_DYN_TXPWR, "[%s] DTP=%d\n", __func__,
  427. mgnt_info->bDynamicTxPowerEnable);
  428. }
  429. void phydm_dynamic_tx_power_win(void *dm_void)
  430. {
  431. struct dm_struct *dm = (struct dm_struct *)dm_void;
  432. if (!(dm->support_ability & ODM_BB_DYNAMIC_TXPWR))
  433. return;
  434. #if (RTL8814A_SUPPORT == 1)
  435. if (dm->support_ic_type == ODM_RTL8814A)
  436. odm_dynamic_tx_power_8814a(dm);
  437. #endif
  438. #if (RTL8821A_SUPPORT == 1)
  439. if (dm->support_ic_type & ODM_RTL8821) {
  440. void *adapter = dm->adapter;
  441. PMGNT_INFO mgnt_info = GetDefaultMgntInfo((PADAPTER)adapter);
  442. if (mgnt_info->RegRspPwr == 1) {
  443. if (dm->rssi_min > 60) {
  444. /*Resp TXAGC offset = -3dB*/
  445. odm_set_mac_reg(dm, 0x6d8, 0x1C0000, 1);
  446. } else if (dm->rssi_min < 55) {
  447. /*Resp TXAGC offset = 0dB*/
  448. odm_set_mac_reg(dm, 0x6d8, 0x1C0000, 0);
  449. }
  450. }
  451. }
  452. #endif
  453. }
  454. #endif /*@#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)*/
  455. #endif /* @#ifdef CONFIG_DYNAMIC_TX_TWR */