/******************************************************************************
*
* Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* The full GNU General Public License is included in this distribution in the
* file called LICENSE.
*
* Contact Information:
* wlanfae <wlanfae@realtek.com>
* Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
* Hsinchu 300, Taiwan.
*
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#include "halbt_precomp.h"
/***********************************************
* Global variables
***********************************************/
struct btc_coexist gl_bt_coexist;
u32 btc_dbg_type[BTC_MSG_MAX];
static u8 btc_dbg_buf[100];
/***************************************************
* Debug related function
***************************************************/
static bool halbtc_is_bt_coexist_available(struct btc_coexist *btcoexist)
{
if (!btcoexist->binded || NULL == btcoexist->adapter)
return false;
return true;
}
static bool halbtc_is_wifi_busy(struct rtl_priv *rtlpriv)
{
if (rtlpriv->link_info.busytraffic)
return true;
else
return false;
}
static void halbtc_dbg_init(void)
{
u8 i;
for (i = 0; i < BTC_MSG_MAX; i++)
btc_dbg_type[i] = 0;
btc_dbg_type[BTC_MSG_INTERFACE] =
/* INTF_INIT | */
/* INTF_NOTIFY | */
0;
btc_dbg_type[BTC_MSG_ALGORITHM] =
/* ALGO_BT_RSSI_STATE | */
/* ALGO_WIFI_RSSI_STATE | */
/* ALGO_BT_MONITOR | */
/* ALGO_TRACE | */
/* ALGO_TRACE_FW | */
/* ALGO_TRACE_FW_DETAIL | */
/* ALGO_TRACE_FW_EXEC | */
/* ALGO_TRACE_SW | */
/* ALGO_TRACE_SW_DETAIL | */
/* ALGO_TRACE_SW_EXEC | */
0;
}
static bool halbtc_is_bt40(struct rtl_priv *adapter)
{
struct rtl_priv *rtlpriv = adapter;
struct rtl_phy *rtlphy = &(rtlpriv->phy);
bool is_ht40 = true;
enum ht_channel_width bw = rtlphy->current_chan_bw;
if (bw == HT_CHANNEL_WIDTH_20)
is_ht40 = false;
else if (bw == HT_CHANNEL_WIDTH_20_40)
is_ht40 = true;
return is_ht40;
}
static bool halbtc_legacy(struct rtl_priv *adapter)
{
struct rtl_priv *rtlpriv = adapter;
struct rtl_mac *mac = rtl_mac(rtlpriv);
bool is_legacy = false;
if ((mac->mode == WIRELESS_MODE_B) || (mac->mode == WIRELESS_MODE_B))
is_legacy = true;
return is_legacy;
}
bool halbtc_is_wifi_uplink(struct rtl_priv *adapter)
{
struct rtl_priv *rtlpriv = adapter;
if (rtlpriv->link_info.tx_busy_traffic)
return true;
else
return false;
}
static u32 halbtc_get_wifi_bw(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv =
(struct rtl_priv *)btcoexist->adapter;
u32 wifi_bw = BTC_WIFI_BW_HT20;
if (halbtc_is_bt40(rtlpriv)) {
wifi_bw = BTC_WIFI_BW_HT40;
} else {
if (halbtc_legacy(rtlpriv))
wifi_bw = BTC_WIFI_BW_LEGACY;
else
wifi_bw = BTC_WIFI_BW_HT20;
}
return wifi_bw;
}
static u8 halbtc_get_wifi_central_chnl(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv = btcoexist->adapter;
struct rtl_phy *rtlphy = &(rtlpriv->phy);
u8 chnl = 1;
if (rtlphy->current_channel != 0)
chnl = rtlphy->current_channel;
BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE,
"static halbtc_get_wifi_central_chnl:%d\n", chnl);
return chnl;
}
static void halbtc_leave_lps(struct btc_coexist *btcoexist)
{
struct rtl_priv *rtlpriv;
struct rtl_ps_ctl *ppsc;
bool ap_enable = false;
rtlpriv = btcoexist->adapter;
ppsc = rtl_psc(rtlpriv);
btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
&ap_enable);
if (ap_enable) {
pr_info("halbtc_leave_lps()<--dont leave lps under AP mode\n");
return;
}
btcoexist->bt_info.bt_ctrl_lps = true;
btcoexist->bt_info.bt_lps_on = false;
}
static void halbtc_enter_lps(struct btc_coexist *btcoexist)
{
struct rtl_priv