1 /******************************************************************************
2 *
3 * Copyright(c) 2021 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 *****************************************************************************/
15 #define _PHL_TXPWR_C_
16 #include "phl_headers.h"
17
rtw_phl_get_pw_lmt_regu_type_str(void * phl,enum band_type band)18 const char *rtw_phl_get_pw_lmt_regu_type_str(void *phl, enum band_type band)
19 {
20 struct phl_info_t *phl_info = phl;
21
22 return rtw_hal_get_pw_lmt_regu_type_str(phl_info->hal, band);
23 }
24
rtw_phl_get_pwr_lmt_en(void * phl,u8 band_idx)25 bool rtw_phl_get_pwr_lmt_en(void *phl, u8 band_idx)
26 {
27 struct phl_info_t *phl_info = phl;
28
29 return rtw_hal_get_pwr_lmt_en(phl_info->hal, band_idx);
30 }
31
rtw_phl_set_tx_power(void * phl,u8 band_idx)32 enum rtw_phl_status rtw_phl_set_tx_power(void *phl, u8 band_idx)
33 {
34 struct phl_info_t *phl_info = phl;
35 enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
36
37 hstatus = rtw_hal_set_tx_power(phl_info->hal, band_idx, PWR_BY_RATE | PWR_LIMIT | PWR_LIMIT_RU);
38 if (hstatus != RTW_HAL_STATUS_SUCCESS)
39 PHL_ERR("%s rtw_hal_set_tx_power: statuts = %u\n", __func__, hstatus);
40
41 return hstatus == RTW_HAL_STATUS_SUCCESS ? RTW_PHL_STATUS_SUCCESS : RTW_PHL_STATUS_FAILURE;
42 }
43
rtw_phl_get_txinfo_pwr(void * phl,s16 * pwr_dbm)44 enum rtw_phl_status rtw_phl_get_txinfo_pwr(void *phl, s16 *pwr_dbm)
45 {
46 struct phl_info_t *phl_info = phl;
47 enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
48 s16 power_dbm = 0;
49
50 hstatus = rtw_hal_get_txinfo_power(phl_info->hal, &power_dbm);
51 *pwr_dbm = power_dbm;
52
53 return hstatus == RTW_HAL_STATUS_SUCCESS ? RTW_PHL_STATUS_SUCCESS : RTW_PHL_STATUS_FAILURE;
54 }
55
56
57