Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/halrf/halrf_powertracking.c
1308 views
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 <[email protected]>
19
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20
* Hsinchu 300, Taiwan.
21
*
22
* Larry Finger <[email protected]>
23
*
24
*****************************************************************************/
25
26
/*@************************************************************
27
* include files
28
* ************************************************************
29
*/
30
#include "mp_precomp.h"
31
#include "phydm_precomp.h"
32
33
boolean
34
odm_check_power_status(void *dm_void)
35
{
36
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
37
struct dm_struct *dm = (struct dm_struct *)dm_void;
38
PADAPTER *adapter = dm->adapter;
39
40
RT_RF_POWER_STATE rt_state;
41
MGNT_INFO *mgnt_info = &((PADAPTER)adapter)->MgntInfo;
42
43
/* 2011/07/27 MH We are not testing ready~~!! We may fail to get correct value when init sequence. */
44
if (mgnt_info->init_adpt_in_progress == true) {
45
RF_DBG(dm, DBG_RF_INIT,
46
"check_pow_status Return true, due to initadapter\n");
47
return true;
48
}
49
50
/*
51
* 2011/07/19 MH We can not execute tx pwoer tracking/ LLC calibrate or IQK.
52
*/
53
((PADAPTER)adapter)->HalFunc.GetHwRegHandler((PADAPTER)adapter, HW_VAR_RF_STATE, (u8 *)(&rt_state));
54
if (((PADAPTER)adapter)->bDriverStopped || ((PADAPTER)adapter)->bDriverIsGoingToPnpSetPowerSleep || rt_state == eRfOff) {
55
RF_DBG(dm, DBG_RF_INIT,
56
"check_pow_status Return false, due to %d/%d/%d\n",
57
((PADAPTER)adapter)->bDriverStopped,
58
((PADAPTER)adapter)->bDriverIsGoingToPnpSetPowerSleep,
59
rt_state);
60
return false;
61
}
62
#endif
63
return true;
64
}
65
66
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
67
void halrf_update_pwr_track(void *dm_void, u8 rate)
68
{
69
struct dm_struct *dm = (struct dm_struct *)dm_void;
70
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
71
u8 path_idx = 0;
72
#endif
73
74
RF_DBG(dm, DBG_RF_TX_PWR_TRACK, "Pwr Track Get rate=0x%x\n", rate);
75
76
dm->tx_rate = rate;
77
78
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
79
#if DEV_BUS_TYPE == RT_PCI_INTERFACE
80
#if USE_WORKITEM
81
odm_schedule_work_item(&dm->ra_rpt_workitem);
82
#else
83
if (dm->support_ic_type == ODM_RTL8821) {
84
#if (RTL8821A_SUPPORT == 1)
85
odm_tx_pwr_track_set_pwr8821a(dm, MIX_MODE, RF_PATH_A, 0);
86
#endif
87
} else if (dm->support_ic_type == ODM_RTL8812) {
88
for (path_idx = RF_PATH_A; path_idx < MAX_PATH_NUM_8812A; path_idx++) {
89
#if (RTL8812A_SUPPORT == 1)
90
odm_tx_pwr_track_set_pwr8812a(dm, MIX_MODE, path_idx, 0);
91
#endif
92
}
93
} else if (dm->support_ic_type == ODM_RTL8723B) {
94
#if (RTL8723B_SUPPORT == 1)
95
odm_tx_pwr_track_set_pwr_8723b(dm, MIX_MODE, RF_PATH_A, 0);
96
#endif
97
} else if (dm->support_ic_type == ODM_RTL8192E) {
98
for (path_idx = RF_PATH_A; path_idx < MAX_PATH_NUM_8192E; path_idx++) {
99
#if (RTL8192E_SUPPORT == 1)
100
odm_tx_pwr_track_set_pwr92_e(dm, MIX_MODE, path_idx, 0);
101
#endif
102
}
103
} else if (dm->support_ic_type == ODM_RTL8188E) {
104
#if (RTL8188E_SUPPORT == 1)
105
odm_tx_pwr_track_set_pwr88_e(dm, MIX_MODE, RF_PATH_A, 0);
106
#endif
107
}
108
#endif
109
#else
110
odm_schedule_work_item(&dm->ra_rpt_workitem);
111
#endif
112
#endif
113
}
114
115
#endif
116
117
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
118
void halrf_update_init_rate_work_item_callback(
119
void *context)
120
{
121
void *adapter = (void *)context;
122
HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));
123
struct dm_struct *dm = &hal_data->DM_OutSrc;
124
u8 p = 0;
125
126
if (dm->support_ic_type == ODM_RTL8821) {
127
#if (RTL8821A_SUPPORT == 1)
128
odm_tx_pwr_track_set_pwr8821a(dm, MIX_MODE, RF_PATH_A, 0);
129
#endif
130
} else if (dm->support_ic_type == ODM_RTL8812) {
131
#if (RTL8812A_SUPPORT == 1)
132
/*Don't know how to include &c*/
133
for (p = RF_PATH_A; p < MAX_PATH_NUM_8812A; p++)
134
odm_tx_pwr_track_set_pwr8812a(dm, MIX_MODE, p, 0);
135
#endif
136
} else if (dm->support_ic_type == ODM_RTL8723B) {
137
#if (RTL8723B_SUPPORT == 1)
138
odm_tx_pwr_track_set_pwr_8723b(dm, MIX_MODE, RF_PATH_A, 0);
139
#endif
140
} else if (dm->support_ic_type == ODM_RTL8192E) {
141
#if (RTL8192E_SUPPORT == 1)
142
/*Don't know how to include &c*/
143
for (p = RF_PATH_A; p < MAX_PATH_NUM_8192E; p++)
144
odm_tx_pwr_track_set_pwr92_e(dm, MIX_MODE, p, 0);
145
#endif
146
} else if (dm->support_ic_type == ODM_RTL8188E) {
147
#if (RTL8188E_SUPPORT == 1)
148
odm_tx_pwr_track_set_pwr88_e(dm, MIX_MODE, RF_PATH_A, 0);
149
#endif
150
}
151
}
152
#endif
153
154
void halrf_set_pwr_track(void *dm_void, u8 enable)
155
{
156
struct dm_struct *dm = (struct dm_struct *)dm_void;
157
struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;
158
struct _hal_rf_ *rf = &(dm->rf_table);
159
struct txpwrtrack_cfg c;
160
u8 i;
161
162
configure_txpower_track(dm, &c);
163
if (enable) {
164
rf->rf_supportability = rf->rf_supportability | HAL_RF_TX_PWR_TRACK;
165
if (cali_info->txpowertrack_control == 1 || cali_info->txpowertrack_control == 3)
166
halrf_do_tssi(dm);
167
} else {
168
rf->rf_supportability = rf->rf_supportability & ~HAL_RF_TX_PWR_TRACK;
169
odm_clear_txpowertracking_state(dm);
170
halrf_do_tssi(dm);
171
halrf_calculate_tssi_codeword(dm);
172
halrf_set_tssi_codeword(dm);
173
for (i = 0; i < c.rf_path_count; i++)
174
(*c.odm_tx_pwr_track_set_pwr)(dm, CLEAN_MODE, i, 0);
175
}
176
}
177
178
179