Updated to 4.4.1

This commit is contained in:
CGarces
2017-05-11 20:47:23 +02:00
parent 9dde4572b4
commit 3d6c7de21a
396 changed files with 174471 additions and 106990 deletions

View File

@@ -33,11 +33,17 @@
#endif
#endif /* defined(RTW_ENABLE_WIFI_CONTROL_FUNC) */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
#define strnicmp strncasecmp
#endif /* Linux kernel >= 4.0.0 */
#ifdef CONFIG_GPIO_WAKEUP
#include <linux/interrupt.h>
#include <linux/irq.h>
#endif
#include "rtw_version.h"
extern void macstr2num(u8 *dst, u8 *src);
const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = {
@@ -76,6 +82,7 @@ const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = {
"MACADDR",
"BLOCK_SCAN",
"BLOCK",
"WFD-ENABLE",
"WFD-DISABLE",
@@ -86,11 +93,12 @@ const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = {
"HOSTAPD_SET_MACADDR_ACL",
"HOSTAPD_ACL_ADD_STA",
"HOSTAPD_ACL_REMOVE_STA",
#ifdef CONFIG_GTK_OL
#if defined(CONFIG_GTK_OL) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0))
"GTK_REKEY_OFFLOAD",
#endif //CONFIG_GTK_OL
/* Private command for P2P disable*/
"P2P_DISABLE"
"P2P_DISABLE",
"DRIVER_VERSION"
};
#ifdef CONFIG_PNO_SUPPORT
@@ -161,7 +169,8 @@ typedef struct compat_android_wifi_priv_cmd {
*/
static int g_wifi_on = _TRUE;
unsigned int oob_irq;
unsigned int oob_irq = 0;
unsigned int oob_gpio = 0;
#ifdef CONFIG_PNO_SUPPORT
/*
@@ -408,6 +417,18 @@ int rtw_android_get_p2p_dev_addr(struct net_device *net, char *command, int tota
return bytes_written;
}
int rtw_android_set_block_scan(struct net_device *net, char *command, int total_len)
{
_adapter *adapter = (_adapter *)rtw_netdev_priv(net);
char *block_value = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_BLOCK_SCAN]) + 1;
#ifdef CONFIG_IOCTL_CFG80211
adapter_wdev_data(adapter)->block_scan = (*block_value == '0')?_FALSE:_TRUE;
#endif
return 0;
}
int rtw_android_set_block(struct net_device *net, char *command, int total_len)
{
_adapter *adapter = (_adapter *)rtw_netdev_priv(net);
@@ -424,11 +445,11 @@ int rtw_android_setband(struct net_device *net, char *command, int total_len)
{
_adapter *adapter = (_adapter *)rtw_netdev_priv(net);
char *arg = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_SETBAND]) + 1;
u32 band = GHZ_MAX;
u32 band = WIFI_FREQUENCY_BAND_AUTO;
int ret = _FAIL;
sscanf(arg, "%u", &band);
ret = rtw_set_band(adapter, band);
if (sscanf(arg, "%u", &band) >= 1)
ret = rtw_set_band(adapter, band);
return (ret==_SUCCESS)?0:-1;
}
@@ -443,31 +464,11 @@ int rtw_android_getband(struct net_device *net, char *command, int total_len)
return bytes_written;
}
enum {
MIRACAST_DISABLED = 0,
MIRACAST_SOURCE,
MIRACAST_SINK,
MIRACAST_INVALID,
};
static const char *miracast_mode_str[] = {
"DISABLED",
"SOURCE",
"SINK",
"INVALID",
};
static const char *get_miracast_mode_str(int mode)
{
if (mode < MIRACAST_DISABLED || mode >= MIRACAST_INVALID)
mode = MIRACAST_INVALID;
return miracast_mode_str[mode];
}
#ifdef CONFIG_WFD
int rtw_android_set_miracast_mode(struct net_device *net, char *command, int total_len)
{
_adapter *adapter = (_adapter *)rtw_netdev_priv(net);
struct wifi_display_info *wfd_info = &adapter->wfd_info;
char *arg = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_MIRACAST]) + 1;
u8 mode;
int num;
@@ -475,13 +476,30 @@ int rtw_android_set_miracast_mode(struct net_device *net, char *command, int tot
num = sscanf(arg, "%hhu", &mode);
if (num >= 1) {
DBG_871X("Miracast mode: %s(%u)\n", get_miracast_mode_str(mode), mode);
ret = _SUCCESS;
}
if (num < 1)
goto exit;
return (ret==_SUCCESS)?0:-1;
switch (mode) {
case 1: /* soruce */
mode = MIRACAST_SOURCE;
break;
case 2: /* sink */
mode = MIRACAST_SINK;
break;
case 0: /* disabled */
default:
mode = MIRACAST_DISABLED;
break;
}
wfd_info->stack_wfd_mode = mode;
DBG_871X("stack miracast mode: %s\n", get_miracast_mode_str(wfd_info->stack_wfd_mode));
ret = _SUCCESS;
exit:
return (ret == _SUCCESS)?0:-1;
}
#endif /* CONFIG_WFD */
int get_int_from_command( char* pcmd )
{
@@ -499,7 +517,7 @@ int get_int_from_command( char* pcmd )
return ( rtw_atoi( pcmd + i ) );
}
#ifdef CONFIG_GTK_OL
#if defined(CONFIG_GTK_OL) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0))
int rtw_gtk_offload(struct net_device *net, u8 *cmd_ptr)
{
int i;
@@ -569,6 +587,10 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
ret = -EINVAL;
goto exit;
}
if (padapter->registrypriv.mp_mode == 1) {
ret = -EINVAL;
goto exit;
}
#ifdef CONFIG_COMPAT
if (is_compat_task()) {
/* User space is 32-bit, use compat ioctl */
@@ -591,7 +613,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
ret = -EFAULT;
goto exit;
}
//DBG_871X("%s priv_cmd.buf=%p priv_cmd.total_len=%d priv_cmd.used_len=%d\n",__func__,priv_cmd.buf,priv_cmd.total_len,priv_cmd.used_len);
/*DBG_871X("%s priv_cmd.buf=%p priv_cmd.total_len=%d priv_cmd.used_len=%d\n",__func__,priv_cmd.buf,priv_cmd.total_len,priv_cmd.used_len);*/
command = rtw_zmalloc(priv_cmd.total_len);
if (!command)
{
@@ -630,6 +652,17 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
goto exit;
}
if (!hal_chk_wl_func(padapter, WL_FUNC_MIRACAST)) {
switch (cmd_num) {
case ANDROID_WIFI_CMD_WFD_ENABLE:
case ANDROID_WIFI_CMD_WFD_DISABLE:
case ANDROID_WIFI_CMD_WFD_SET_TCPPORT:
case ANDROID_WIFI_CMD_WFD_SET_MAX_TPUT:
case ANDROID_WIFI_CMD_WFD_SET_DEVTYPE:
goto response;
}
}
switch(cmd_num) {
case ANDROID_WIFI_CMD_STOP:
@@ -658,7 +691,11 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
case ANDROID_WIFI_CMD_MACADDR:
bytes_written = rtw_android_get_macaddr(net, command, priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_BLOCK_SCAN:
bytes_written = rtw_android_set_block_scan(net, command, priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_BLOCK:
bytes_written = rtw_android_set_block(net, command, priv_cmd.total_len);
break;
@@ -709,10 +746,6 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
bytes_written = rtw_android_getband(net, command, priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_MIRACAST:
bytes_written = rtw_android_set_miracast_mode(net, command, priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_COUNTRY:
bytes_written = rtw_android_set_country(net, command, priv_cmd.total_len);
break;
@@ -756,15 +789,19 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
#endif //CONFIG_IOCTL_CFG80211
#ifdef CONFIG_WFD
case ANDROID_WIFI_CMD_MIRACAST:
bytes_written = rtw_android_set_miracast_mode(net, command, priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_WFD_ENABLE:
{
// Commented by Albert 2012/07/24
// We can enable the WFD function by using the following command:
// wpa_cli driver wfd-enable
pwfd_info = &padapter->wfd_info;
if( padapter->wdinfo.driver_interface == DRIVER_CFG80211 )
pwfd_info->wfd_enable = _TRUE;
if (padapter->wdinfo.driver_interface == DRIVER_CFG80211)
rtw_wfd_enable(padapter, 1);
break;
}
@@ -774,9 +811,8 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
// We can disable the WFD function by using the following command:
// wpa_cli driver wfd-disable
pwfd_info = &padapter->wfd_info;
if( padapter->wdinfo.driver_interface == DRIVER_CFG80211 )
pwfd_info->wfd_enable = _FALSE;
if (padapter->wdinfo.driver_interface == DRIVER_CFG80211)
rtw_wfd_enable(padapter, 0);
break;
}
case ANDROID_WIFI_CMD_WFD_SET_TCPPORT:
@@ -785,11 +821,8 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
// We can set the tcp port number by using the following command:
// wpa_cli driver wfd-set-tcpport = 554
pwfd_info = &padapter->wfd_info;
if( padapter->wdinfo.driver_interface == DRIVER_CFG80211 )
{
pwfd_info->rtsp_ctrlport = ( u16 ) get_int_from_command( priv_cmd.buf );
}
if (padapter->wdinfo.driver_interface == DRIVER_CFG80211)
rtw_wfd_set_ctrl_port(padapter, (u16)get_int_from_command(priv_cmd.buf));
break;
}
case ANDROID_WIFI_CMD_WFD_SET_MAX_TPUT:
@@ -846,19 +879,26 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
rtw_acl_remove_sta(padapter, addr);
break;
}
#ifdef CONFIG_GTK_OL
#if defined(CONFIG_GTK_OL) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0))
case ANDROID_WIFI_CMD_GTK_REKEY_OFFLOAD:
rtw_gtk_offload(net, (u8*)command);
break;
#endif //CONFIG_GTK_OL
case ANDROID_WIFI_CMD_P2P_DISABLE:
{
#ifdef CONFIG_P2P
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
u8 channel, ch_offset;
u16 bwmode;
rtw_p2p_enable(padapter, P2P_ROLE_DISABLE);
#endif // CONFIG_P2P
break;
}
case ANDROID_WIFI_CMD_DRIVERVERSION:
{
bytes_written = strlen(DRIVERVERSION);
snprintf(command, bytes_written+1, DRIVERVERSION);
break;
}
default:
@@ -1036,9 +1076,13 @@ static int wifi_probe(struct platform_device *pdev)
wifi_irqres->start, wifi_wake_gpio);
if (wifi_wake_gpio > 0) {
#ifdef CONFIG_PLATFORM_INTEL_BYT
wifi_configure_gpio();
#else //CONFIG_PLATFORM_INTEL_BYT
gpio_request(wifi_wake_gpio, "oob_irq");
gpio_direction_input(wifi_wake_gpio);
oob_irq = gpio_to_irq(wifi_wake_gpio);
#endif //CONFIG_PLATFORM_INTEL_BYT
printk("%s oob_irq:%d\n", __func__, oob_irq);
}
else if(wifi_irqres)
@@ -1119,19 +1163,9 @@ static void shutdown_card(void)
// lock register page0 0x0~0xB read/write
rtw_write8(g_test_adapter, 0x1C, 0x0E);
g_test_adapter->bSurpriseRemoved = _TRUE;
DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved=%d\n",
FUNC_ADPT_ARG(g_test_adapter), g_test_adapter->bSurpriseRemoved);
#ifdef CONFIG_CONCURRENT_MODE
if (g_test_adapter->pbuddy_adapter)
{
PADAPTER pbuddy;
pbuddy = g_test_adapter->pbuddy_adapter;
pbuddy->bSurpriseRemoved = _TRUE;
DBG_871X(FUNC_ADPT_FMT ": buddy(" ADPT_FMT ") bSurpriseRemoved=%d\n",
FUNC_ADPT_ARG(g_test_adapter), ADPT_ARG(pbuddy), pbuddy->bSurpriseRemoved);
}
#endif // CONFIG_CONCURRENT_MODE
rtw_set_surprise_removed(g_test_adapter);
DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved=%s\n",
FUNC_ADPT_ARG(g_test_adapter), rtw_is_surprise_removed(g_test_adapter)?"True":"False");
}
#endif // RTW_SUPPORT_PLATFORM_SHUTDOWN
@@ -1226,3 +1260,34 @@ static void wifi_del_dev(void)
}
#endif /* defined(RTW_ENABLE_WIFI_CONTROL_FUNC) */
#ifdef CONFIG_GPIO_WAKEUP
#ifdef CONFIG_PLATFORM_INTEL_BYT
int wifi_configure_gpio(void)
{
if (gpio_request(oob_gpio, "oob_irq")) {
DBG_871X("## %s Cannot request GPIO\n", __FUNCTION__);
return -1;
}
gpio_export(oob_gpio, 0);
if (gpio_direction_input(oob_gpio)) {
DBG_871X("## %s Cannot set GPIO direction input\n", __FUNCTION__);
return -1;
}
if ((oob_irq = gpio_to_irq(oob_gpio)) < 0) {
DBG_871X("## %s Cannot convert GPIO to IRQ\n", __FUNCTION__);
return -1;
}
DBG_871X("## %s OOB_IRQ=%d\n", __FUNCTION__, oob_irq);
return 0;
}
#endif //CONFIG_PLATFORM_INTEL_BYT
void wifi_free_gpio(unsigned int gpio)
{
#ifdef CONFIG_PLATFORM_INTEL_BYT
if(gpio)
gpio_free(gpio);
#endif //CONFIG_PLATFORM_INTEL_BYT
}
#endif //CONFIG_GPIO_WAKEUP