Path: blob/master/ALFA-W1F1/RTL8814AU/hal/phydm/halrf/halrf_powertracking.c
1308 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13* The full GNU General Public License is included in this distribution in the14* file called LICENSE.15*16* Contact Information:17* wlanfae <[email protected]>18* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,19* Hsinchu 300, Taiwan.20*21* Larry Finger <[email protected]>22*23*****************************************************************************/2425/*@************************************************************26* include files27* ************************************************************28*/29#include "mp_precomp.h"30#include "phydm_precomp.h"3132boolean33odm_check_power_status(void *dm_void)34{35#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)36struct dm_struct *dm = (struct dm_struct *)dm_void;37PADAPTER *adapter = dm->adapter;3839RT_RF_POWER_STATE rt_state;40MGNT_INFO *mgnt_info = &((PADAPTER)adapter)->MgntInfo;4142/* 2011/07/27 MH We are not testing ready~~!! We may fail to get correct value when init sequence. */43if (mgnt_info->init_adpt_in_progress == true) {44RF_DBG(dm, DBG_RF_INIT,45"check_pow_status Return true, due to initadapter\n");46return true;47}4849/*50* 2011/07/19 MH We can not execute tx pwoer tracking/ LLC calibrate or IQK.51*/52((PADAPTER)adapter)->HalFunc.GetHwRegHandler((PADAPTER)adapter, HW_VAR_RF_STATE, (u8 *)(&rt_state));53if (((PADAPTER)adapter)->bDriverStopped || ((PADAPTER)adapter)->bDriverIsGoingToPnpSetPowerSleep || rt_state == eRfOff) {54RF_DBG(dm, DBG_RF_INIT,55"check_pow_status Return false, due to %d/%d/%d\n",56((PADAPTER)adapter)->bDriverStopped,57((PADAPTER)adapter)->bDriverIsGoingToPnpSetPowerSleep,58rt_state);59return false;60}61#endif62return true;63}6465#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))66void halrf_update_pwr_track(void *dm_void, u8 rate)67{68struct dm_struct *dm = (struct dm_struct *)dm_void;69#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)70u8 path_idx = 0;71#endif7273RF_DBG(dm, DBG_RF_TX_PWR_TRACK, "Pwr Track Get rate=0x%x\n", rate);7475dm->tx_rate = rate;7677#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)78#if DEV_BUS_TYPE == RT_PCI_INTERFACE79#if USE_WORKITEM80odm_schedule_work_item(&dm->ra_rpt_workitem);81#else82if (dm->support_ic_type == ODM_RTL8821) {83#if (RTL8821A_SUPPORT == 1)84odm_tx_pwr_track_set_pwr8821a(dm, MIX_MODE, RF_PATH_A, 0);85#endif86} else if (dm->support_ic_type == ODM_RTL8812) {87for (path_idx = RF_PATH_A; path_idx < MAX_PATH_NUM_8812A; path_idx++) {88#if (RTL8812A_SUPPORT == 1)89odm_tx_pwr_track_set_pwr8812a(dm, MIX_MODE, path_idx, 0);90#endif91}92} else if (dm->support_ic_type == ODM_RTL8723B) {93#if (RTL8723B_SUPPORT == 1)94odm_tx_pwr_track_set_pwr_8723b(dm, MIX_MODE, RF_PATH_A, 0);95#endif96} else if (dm->support_ic_type == ODM_RTL8192E) {97for (path_idx = RF_PATH_A; path_idx < MAX_PATH_NUM_8192E; path_idx++) {98#if (RTL8192E_SUPPORT == 1)99odm_tx_pwr_track_set_pwr92_e(dm, MIX_MODE, path_idx, 0);100#endif101}102} else if (dm->support_ic_type == ODM_RTL8188E) {103#if (RTL8188E_SUPPORT == 1)104odm_tx_pwr_track_set_pwr88_e(dm, MIX_MODE, RF_PATH_A, 0);105#endif106}107#endif108#else109odm_schedule_work_item(&dm->ra_rpt_workitem);110#endif111#endif112}113114#endif115116#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)117void halrf_update_init_rate_work_item_callback(118void *context)119{120void *adapter = (void *)context;121HAL_DATA_TYPE *hal_data = GET_HAL_DATA(((PADAPTER)adapter));122struct dm_struct *dm = &hal_data->DM_OutSrc;123u8 p = 0;124125if (dm->support_ic_type == ODM_RTL8821) {126#if (RTL8821A_SUPPORT == 1)127odm_tx_pwr_track_set_pwr8821a(dm, MIX_MODE, RF_PATH_A, 0);128#endif129} else if (dm->support_ic_type == ODM_RTL8812) {130#if (RTL8812A_SUPPORT == 1)131/*Don't know how to include &c*/132for (p = RF_PATH_A; p < MAX_PATH_NUM_8812A; p++)133odm_tx_pwr_track_set_pwr8812a(dm, MIX_MODE, p, 0);134#endif135} else if (dm->support_ic_type == ODM_RTL8723B) {136#if (RTL8723B_SUPPORT == 1)137odm_tx_pwr_track_set_pwr_8723b(dm, MIX_MODE, RF_PATH_A, 0);138#endif139} else if (dm->support_ic_type == ODM_RTL8192E) {140#if (RTL8192E_SUPPORT == 1)141/*Don't know how to include &c*/142for (p = RF_PATH_A; p < MAX_PATH_NUM_8192E; p++)143odm_tx_pwr_track_set_pwr92_e(dm, MIX_MODE, p, 0);144#endif145} else if (dm->support_ic_type == ODM_RTL8188E) {146#if (RTL8188E_SUPPORT == 1)147odm_tx_pwr_track_set_pwr88_e(dm, MIX_MODE, RF_PATH_A, 0);148#endif149}150}151#endif152153void halrf_set_pwr_track(void *dm_void, u8 enable)154{155struct dm_struct *dm = (struct dm_struct *)dm_void;156struct dm_rf_calibration_struct *cali_info = &dm->rf_calibrate_info;157struct _hal_rf_ *rf = &(dm->rf_table);158struct txpwrtrack_cfg c;159u8 i;160161configure_txpower_track(dm, &c);162if (enable) {163rf->rf_supportability = rf->rf_supportability | HAL_RF_TX_PWR_TRACK;164if (cali_info->txpowertrack_control == 1 || cali_info->txpowertrack_control == 3)165halrf_do_tssi(dm);166} else {167rf->rf_supportability = rf->rf_supportability & ~HAL_RF_TX_PWR_TRACK;168odm_clear_txpowertracking_state(dm);169halrf_do_tssi(dm);170halrf_calculate_tssi_codeword(dm);171halrf_set_tssi_codeword(dm);172for (i = 0; i < c.rf_path_count; i++)173(*c.odm_tx_pwr_track_set_pwr)(dm, CLEAN_MODE, i, 0);174}175}176177178179