linux/drivers/staging/rtl8723bs/core/rtw_btcoex.c
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2013 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 ******************************************************************************/
  15#include <drv_types.h>
  16#include <rtw_debug.h>
  17#include <rtw_btcoex.h>
  18#include <hal_btcoex.h>
  19
  20
  21void rtw_btcoex_Initialize(struct adapter *padapter)
  22{
  23        hal_btcoex_Initialize(padapter);
  24}
  25
  26void rtw_btcoex_PowerOnSetting(struct adapter *padapter)
  27{
  28        hal_btcoex_PowerOnSetting(padapter);
  29}
  30
  31void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly)
  32{
  33        hal_btcoex_InitHwConfig(padapter, bWifiOnly);
  34}
  35
  36void rtw_btcoex_IpsNotify(struct adapter *padapter, u8 type)
  37{
  38        hal_btcoex_IpsNotify(padapter, type);
  39}
  40
  41void rtw_btcoex_LpsNotify(struct adapter *padapter, u8 type)
  42{
  43        hal_btcoex_LpsNotify(padapter, type);
  44}
  45
  46void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type)
  47{
  48        hal_btcoex_ScanNotify(padapter, type);
  49}
  50
  51void rtw_btcoex_ConnectNotify(struct adapter *padapter, u8 action)
  52{
  53        hal_btcoex_ConnectNotify(padapter, action);
  54}
  55
  56void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus)
  57{
  58        if ((mediaStatus == RT_MEDIA_CONNECT)
  59                && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) {
  60                rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL);
  61        }
  62
  63        hal_btcoex_MediaStatusNotify(padapter, mediaStatus);
  64}
  65
  66void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType)
  67{
  68        hal_btcoex_SpecialPacketNotify(padapter, pktType);
  69}
  70
  71void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state)
  72{
  73        hal_btcoex_IQKNotify(padapter, state);
  74}
  75
  76void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf)
  77{
  78        hal_btcoex_BtInfoNotify(padapter, length, tmpBuf);
  79}
  80
  81void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state)
  82{
  83        hal_btcoex_SuspendNotify(padapter, state);
  84}
  85
  86void rtw_btcoex_HaltNotify(struct adapter *padapter)
  87{
  88        if (false == padapter->bup) {
  89                DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n",
  90                        FUNC_ADPT_ARG(padapter), padapter->bup);
  91
  92                return;
  93        }
  94
  95        if (true == padapter->bSurpriseRemoved) {
  96                DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n",
  97                        FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved);
  98
  99                return;
 100        }
 101
 102        hal_btcoex_HaltNotify(padapter);
 103}
 104
 105u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter)
 106{
 107        return hal_btcoex_IsBtDisabled(padapter);
 108}
 109
 110void rtw_btcoex_Handler(struct adapter *padapter)
 111{
 112        hal_btcoex_Hanlder(padapter);
 113}
 114
 115s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter)
 116{
 117        s32 coexctrl;
 118
 119        coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter);
 120
 121        return coexctrl;
 122}
 123
 124void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual)
 125{
 126        if (true == manual) {
 127                hal_btcoex_SetManualControl(padapter, true);
 128        } else{
 129                hal_btcoex_SetManualControl(padapter, false);
 130        }
 131}
 132
 133u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter)
 134{
 135        return hal_btcoex_IsBtControlLps(padapter);
 136}
 137
 138u8 rtw_btcoex_IsLpsOn(struct adapter *padapter)
 139{
 140        return hal_btcoex_IsLpsOn(padapter);
 141}
 142
 143u8 rtw_btcoex_RpwmVal(struct adapter *padapter)
 144{
 145        return hal_btcoex_RpwmVal(padapter);
 146}
 147
 148u8 rtw_btcoex_LpsVal(struct adapter *padapter)
 149{
 150        return hal_btcoex_LpsVal(padapter);
 151}
 152
 153void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist)
 154{
 155        hal_btcoex_SetBTCoexist(padapter, bBtExist);
 156}
 157
 158void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType)
 159{
 160        hal_btcoex_SetChipType(padapter, chipType);
 161}
 162
 163void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum)
 164{
 165        hal_btcoex_SetPgAntNum(padapter, antNum);
 166}
 167
 168void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath)
 169{
 170        hal_btcoex_SetSingleAntPath(padapter, singleAntPath);
 171}
 172
 173u32 rtw_btcoex_GetRaMask(struct adapter *padapter)
 174{
 175        return hal_btcoex_GetRaMask(padapter);
 176}
 177
 178void rtw_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen)
 179{
 180        hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen);
 181}
 182
 183void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize)
 184{
 185        hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize);
 186}
 187
 188void rtw_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule)
 189{
 190        hal_btcoex_SetDBG(padapter, pDbgModule);
 191}
 192
 193u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize)
 194{
 195        return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize);
 196}
 197
 198/*  ================================================== */
 199/*  Below Functions are called by BT-Coex */
 200/*  ================================================== */
 201void rtw_btcoex_RejectApAggregatedPacket(struct adapter *padapter, u8 enable)
 202{
 203        struct mlme_ext_info *pmlmeinfo;
 204        struct sta_info *psta;
 205
 206        pmlmeinfo = &padapter->mlmeextpriv.mlmext_info;
 207        psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
 208
 209        if (true == enable) {
 210                pmlmeinfo->accept_addba_req = false;
 211                if (psta)
 212                        send_delba(padapter, 0, psta->hwaddr);
 213        } else{
 214                pmlmeinfo->accept_addba_req = true;
 215        }
 216}
 217
 218void rtw_btcoex_LPS_Enter(struct adapter *padapter)
 219{
 220        struct pwrctrl_priv *pwrpriv;
 221        u8 lpsVal;
 222
 223
 224        pwrpriv = adapter_to_pwrctl(padapter);
 225
 226        pwrpriv->bpower_saving = true;
 227        lpsVal = rtw_btcoex_LpsVal(padapter);
 228        rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX");
 229}
 230
 231void rtw_btcoex_LPS_Leave(struct adapter *padapter)
 232{
 233        struct pwrctrl_priv *pwrpriv;
 234
 235
 236        pwrpriv = adapter_to_pwrctl(padapter);
 237
 238        if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) {
 239                rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX");
 240                LPS_RF_ON_check(padapter, 100);
 241                pwrpriv->bpower_saving = false;
 242        }
 243}
 244