From d8f861f40818fae0b4e712cce31f2399ab051868 Mon Sep 17 00:00:00 2001
From: Ben Greear <greearb@candelatech.com>
Date: Thu, 13 Dec 2018 23:22:32 +0000
Subject: [PATCH] rtl8812au: Add out-of-tree driver.

Use a forked version of the rtl8812au driver that works better
with OpenWRT (fix compile bugs, fix phy MAC address, etc)

Signed-off-by: Ben Greear <greearb@candelatech.com>
[update to 2018-11-16, replace rtw_byteorder.h, rename folder]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 package/kernel/rtl8812au-ct/Makefile          | 53 +++++++++++++++++++
 .../patches/001-use-kernel-byteorder.patch    | 15 ++++++
 2 files changed, 68 insertions(+)
 create mode 100644 package/kernel/rtl8812au-ct/Makefile
 create mode 100644 package/kernel/rtl8812au-ct/patches/001-use-kernel-byteorder.patch

diff --git a/package/kernel/rtl8812au-ct/Makefile b/package/kernel/rtl8812au-ct/Makefile
new file mode 100644
index 0000000000..3afbc14db4
--- /dev/null
+++ b/package/kernel/rtl8812au-ct/Makefile
@@ -0,0 +1,53 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rtl8812au-ct
+PKG_RELEASE=1
+
+PKG_LICENSE:=GPLv2
+PKG_LICENSE_FILES:=
+
+PKG_SOURCE_URL:=https://github.com/greearb/rtl8812AU_8821AU_linux.git
+PKG_MIRROR_HASH:=42b32c56cf31bdf3c9cd4e304c9aac761b623c8737d8c57518117acdc5a84cfe
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_DATE:=2018-11-16
+PKG_SOURCE_VERSION:=661268fd174d4a74834c82d7d3987b0a560e6c57
+
+PKG_MAINTAINER:=Ben Greear <greearb@candelatech.com>
+PKG_BUILD_PARALLEL:=1
+#PKG_EXTMOD_SUBDIRS:=rtl8812au-ct
+
+STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
+
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/rtl8812au-ct
+  SUBMENU:=Wireless Drivers
+  TITLE:=Driver for Realtek 8812 AU devices comfast 912-ac, etc
+  DEPENDS:=+kmod-cfg80211 +kmod-usb-core +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT @!LINUX_3_18 @!LINUX_4_9
+  FILES:=\
+	$(PKG_BUILD_DIR)/rtl8812au.ko
+  AUTOLOAD:=$(call AutoProbe,rtl8812au)
+  PROVIDES:=kmod-rtl8812au
+endef
+
+NOSTDINC_FLAGS = \
+	-I$(PKG_BUILD_DIR) \
+	-I$(PKG_BUILD_DIR)/include \
+	-I$(STAGING_DIR)/usr/include/mac80211-backport \
+	-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
+	-I$(STAGING_DIR)/usr/include/mac80211 \
+	-I$(STAGING_DIR)/usr/include/mac80211/uapi \
+	-include backport/backport.h
+
+NOSTDINC_FLAGS+=-DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -DBUILD_OPENWRT
+
+define Build/Compile
+	+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
+		$(KERNEL_MAKE_FLAGS) \
+		SUBDIRS="$(PKG_BUILD_DIR)" \
+		NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
+		modules
+endef
+
+$(eval $(call KernelPackage,rtl8812au-ct))
diff --git a/package/kernel/rtl8812au-ct/patches/001-use-kernel-byteorder.patch b/package/kernel/rtl8812au-ct/patches/001-use-kernel-byteorder.patch
new file mode 100644
index 0000000000..dd42b12438
--- /dev/null
+++ b/package/kernel/rtl8812au-ct/patches/001-use-kernel-byteorder.patch
@@ -0,0 +1,15 @@
+Fix compile problem when rtw_byteorder.h and asm/byteorder.h gets 
+included in addition for example indirectly, do not use realtek own copy 
+of the byteorder headers.
+
+--- a/include/drv_types.h
++++ b/include/drv_types.h
+@@ -30,7 +30,7 @@
+ #include <drv_conf.h>
+ #include <basic_types.h>
+ #include <osdep_service.h>
+-#include <rtw_byteorder.h>
++#include <asm/byteorder.h>
+ #include <wlan_bssdef.h>
+ #include <wifi.h>
+ #include <ieee80211.h>
-- 
2.30.2