/******************************************************************************
*
* Copyright(c) 2009-2010 Realtek Corporation.
*
* 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.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* 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 "../wifi.h"
#include "../pci.h"
#include "../base.h"
#include "reg.h"
#include "def.h"
#include "phy.h"
#include "fw.h"
#include "trx.h"
#include "led.h"
static u8 _rtl92se_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 skb_queue)
{
__le16 fc = rtl_get_fc(skb);
if (unlikely(ieee80211_is_beacon(fc)))
return QSLT_BEACON;
if (ieee80211_is_mgmt(fc))
return QSLT_MGNT;
if (ieee80211_is_nullfunc(fc))
return QSLT_HIGH;
return skb->priority;
}
static int _rtl92se_rate_mapping(bool isht, u8 desc_rate, bool first_ampdu)
{
int rate_idx = 0;
if (first_ampdu) {
if (false == isht) {
switch (desc_rate) {
case DESC92S_RATE1M:
rate_idx = 0;
break;
case DESC92S_RATE2M:
rate_idx = 1;
break;
case DESC92S_RATE5_5M:
rate_idx = 2;
break;
case DESC92S_RATE11M:
rate_idx = 3;
break;
case DESC92S_RATE6M:
rate_idx = 4;
break;
case DESC92S_RATE9M:
rate_idx = 5;
break;
case DESC92S_RATE12M:
rate_idx = 6;
break;
case DESC92S_RATE18M:
rate_idx = 7;
break;
case DESC92S_RATE24M:
rate_idx = 8;
break;
case DESC92S_RATE36M:
rate_idx = 9;
break;
case DESC92S_RATE48M:
rate_idx = 10;
break;
case DESC92S_RATE54M:
rate_idx = 11;
break;
default:
rate_idx = 0;
break;
}
} else {
rate_idx = 11;
}
return rate_idx;
}
switch (desc_rate) {
case DESC92S_RATE1M:
rate_idx = 0;
break;
case DESC92S_RATE2M:
rate_idx = 1;
break;
case DESC92S_RATE5_5M:
rate_idx = 2;
break;
case DESC92S_RATE11M:
rate_idx = 3;
break;
case DESC92S_RATE6M:
rate_idx = 4;
break;
case DESC92S_RATE9M:
rate_idx = 5;
break;
case DESC92S_RATE12M:
rate_idx = 6;
break;
case DESC92S_RATE18M:
rate_idx = 7;
break;
case DESC92S_RATE24M:
rate_idx = 8;
break;
case DESC92S_RATE36M:
rate_idx = 9;
break;
case DESC92S_RATE48M:
rate_idx = 10;
break;
case DESC92S_RATE54M:
rate_idx = 11;
break;
default:
rate_idx = 11;
break;
}
return rate_idx;
}
static u8 _rtl92s_query_rxpwrpercentage(char antpower)
{
if ((antpower <= -100) || (antpower >= 20))
return 0;
else if (antpower >= 0)
return 100;
else
return 100 + antpower;
}
static u8 _rtl92s_evm_db_to_percentage(char value)
{
char ret_val;
ret_val = value;
if (ret_val >= 0)
ret_val = 0;
if (ret_val <= -33)
ret_val = -33;
ret_val = 0 - ret_val;
ret_val *= 3;
if (ret_val == 99)
ret_val = 100;
return ret_val;
}
static long _rtl92se_translate_todbm(struct ieee80211_hw *hw,
u8 signal_strength_index)
{
long signal_power;
signal_power = (long)((signal_strength_index + 1) >> 1);
signal_power -= 95;
return signal_power;
}
static