drivers 更新rtk_btusb驱动

This commit is contained in:
云幕
2023-05-10 01:16:48 +00:00
parent 61784e0530
commit ccbc130e07
6 changed files with 757 additions and 278 deletions

View File

@ -268,6 +268,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=16
CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=8192 CONFIG_BLK_DEV_RAM_SIZE=8192
CONFIG_BLK_DEV_NVME=y CONFIG_BLK_DEV_NVME=y
CONFIG_BT_HCIBTUSB=y
CONFIG_BT_HCIBFUSB=y CONFIG_BT_HCIBFUSB=y
CONFIG_BT_HCIVHCI=y CONFIG_BT_HCIVHCI=y
CONFIG_BT_MRVL=y CONFIG_BT_MRVL=y

View File

@ -209,6 +209,13 @@ config BT_HCIUART_RTL
Say Y here to compile support for Realtek protocol. Say Y here to compile support for Realtek protocol.
config BT_RTKBTUSB
tristate "RTK HCI USB driver"
depends on USB
default y
help
RTK Bluetooth HCI USB driver
config BT_HCIUART_QCA config BT_HCIUART_QCA
bool "Qualcomm Atheros protocol support" bool "Qualcomm Atheros protocol support"
depends on BT_HCIUART depends on BT_HCIUART

View File

@ -3,6 +3,13 @@
# Makefile for the Linux Bluetooth HCI device drivers. # Makefile for the Linux Bluetooth HCI device drivers.
# #
EXTRA_CFLAGS += -Wno-unused-value
EXTRA_CFLAGS += -Wno-unused-label
EXTRA_CFLAGS += -Wno-unused-parameter
EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused
EXTRA_CFLAGS += -Wno-uninitialized
obj-$(CONFIG_BT_HCIVHCI) += hci_vhci.o obj-$(CONFIG_BT_HCIVHCI) += hci_vhci.o
obj-$(CONFIG_BT_HCIUART) += hci_uart.o obj-$(CONFIG_BT_HCIUART) += hci_uart.o
obj-$(CONFIG_BT_HCIBCM203X) += bcm203x.o obj-$(CONFIG_BT_HCIBCM203X) += bcm203x.o
@ -25,6 +32,7 @@ obj-$(CONFIG_BT_QCOMSMD) += btqcomsmd.o
obj-$(CONFIG_BT_BCM) += btbcm.o obj-$(CONFIG_BT_BCM) += btbcm.o
obj-$(CONFIG_BT_RTL) += btrtl.o obj-$(CONFIG_BT_RTL) += btrtl.o
obj-$(CONFIG_BT_QCA) += btqca.o obj-$(CONFIG_BT_QCA) += btqca.o
obj-$(CONFIG_BT_RTKBTUSB) += rtk_btusb.o
obj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o obj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o

File diff suppressed because it is too large Load Diff

View File

@ -102,6 +102,7 @@ typedef struct RTK_sco_card {
#define PRINT_CMD_EVENT 0 #define PRINT_CMD_EVENT 0
#define PRINT_ACL_DATA 0 #define PRINT_ACL_DATA 0
#define PRINT_SCO_DATA 0 #define PRINT_SCO_DATA 0
#define PRINT_ISO_DATA 0
#define RTKBT_DBG_FLAG 0 #define RTKBT_DBG_FLAG 0
@ -165,6 +166,7 @@ int mp_drv_mode = 0; /* 1 Mptool Fw; 0 Normal Fw */
#define ROM_LMP_8723b 0x8723 #define ROM_LMP_8723b 0x8723
#define ROM_LMP_8821a 0X8821 #define ROM_LMP_8821a 0X8821
#define ROM_LMP_8761a 0X8761 #define ROM_LMP_8761a 0X8761
#define ROM_LMP_8761b 0X8761
#define ROM_LMP_8703a 0x8723 #define ROM_LMP_8703a 0x8723
#define ROM_LMP_8763a 0x8763 #define ROM_LMP_8763a 0x8763
#define ROM_LMP_8703b 0x8703 #define ROM_LMP_8703b 0x8703
@ -172,6 +174,20 @@ int mp_drv_mode = 0; /* 1 Mptool Fw; 0 Normal Fw */
#define ROM_LMP_8822b 0x8822 #define ROM_LMP_8822b 0x8822
#define ROM_LMP_8723d 0x8723 #define ROM_LMP_8723d 0x8723
#define ROM_LMP_8821c 0x8821 #define ROM_LMP_8821c 0x8821
#define ROM_LMP_8822c 0x8822
#define ROM_LMP_8852a 0x8852
#define ROM_LMP_8723f 0x8723
#define ROM_LMP_8852b 0x8852
#define ROM_LMP_8763c 0x8763
#define ROM_LMP_8773b 0x8773
#define ROM_LMP_8762a 0x8762
#define ROM_LMP_8762b 0x8762
#define ROM_LMP_8852c 0x8852
#define ROM_LMP_8851a 0x8852
#define ROM_LMP_8852bp 0x8852
#define ROM_LMP_8851b 0x8851
#define ROM_LMP_8822e 0x8822
/* signature: Realtek */ /* signature: Realtek */
const uint8_t RTK_EPATCH_SIGNATURE[8] = {0x52,0x65,0x61,0x6C,0x74,0x65,0x63,0x68}; const uint8_t RTK_EPATCH_SIGNATURE[8] = {0x52,0x65,0x61,0x6C,0x74,0x65,0x63,0x68};
@ -190,7 +206,32 @@ uint16_t project_id[] = {
ROM_LMP_8822b, ROM_LMP_8822b,
ROM_LMP_8723d, ROM_LMP_8723d,
ROM_LMP_8821c, ROM_LMP_8821c,
ROM_LMP_NONE ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_8822c, //0x0d
ROM_LMP_8761b,
ROM_LMP_NONE,
ROM_LMP_NONE, //0x10
ROM_LMP_NONE,
ROM_LMP_8852a, //0x12
ROM_LMP_8723f,
ROM_LMP_8852b,
ROM_LMP_8763c, //bbpro2
ROM_LMP_8773b, //bblite
ROM_LMP_8762a, //bee
ROM_LMP_8762b, //bee2
ROM_LMP_8852c,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_NONE,
ROM_LMP_8822e,
ROM_LMP_8852bp,//34 8852bp
ROM_LMP_8851a,
ROM_LMP_8851b
}; };
struct rtk_eversion_evt { struct rtk_eversion_evt {
uint8_t status; uint8_t status;
@ -308,45 +349,16 @@ static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
#define HCI_BREDR 0x00 #define HCI_BREDR 0x00
#define HCI_AMP 0x01 #define HCI_AMP 0x01
#define DRIVER_ON 1
#define DEVICE_PROBED 2
#define CHAR_OPENED 4
#define CHAR_DLFW 8
/* HCI device flags */ /* HCI device flags */
enum { enum {
HCI_UP, HCI_UP, //if char device is opened set this flag, clear flag when close
HCI_INIT, HCI_RUNNING, //if usb transport has opened set this flag, clear flag when close
HCI_RUNNING,
HCI_PSCAN,
HCI_ISCAN,
HCI_AUTH,
HCI_ENCRYPT,
HCI_INQUIRY,
HCI_RAW,
HCI_RESET,
};
/*
* BR/EDR and/or LE controller flags: the flags defined here should represent
* states from the controller.
*/
enum {
HCI_SETUP,
HCI_AUTO_OFF,
HCI_MGMT,
HCI_PAIRABLE,
HCI_SERVICE_CACHE,
HCI_LINK_KEYS,
HCI_DEBUG_KEYS,
HCI_UNREGISTER, HCI_UNREGISTER,
HCI_LE_SCAN,
HCI_SSP_ENABLED,
HCI_HS_ENABLED,
HCI_LE_ENABLED,
HCI_CONNECTABLE,
HCI_DISCOVERABLE,
HCI_LINK_SECURITY,
HCI_PENDING_CLASS,
}; };
/* HCI data types */ /* HCI data types */
@ -354,6 +366,7 @@ enum {
#define HCI_ACLDATA_PKT 0x02 #define HCI_ACLDATA_PKT 0x02
#define HCI_SCODATA_PKT 0x03 #define HCI_SCODATA_PKT 0x03
#define HCI_EVENT_PKT 0x04 #define HCI_EVENT_PKT 0x04
#define HCI_ISODATA_PKT 0x05
#define HCI_VENDOR_PKT 0xff #define HCI_VENDOR_PKT 0xff
#define HCI_MAX_NAME_LENGTH 248 #define HCI_MAX_NAME_LENGTH 248
@ -380,6 +393,7 @@ struct hci_ev_cmd_complete {
#define HCI_EVENT_HDR_SIZE 2 #define HCI_EVENT_HDR_SIZE 2
#define HCI_ACL_HDR_SIZE 4 #define HCI_ACL_HDR_SIZE 4
#define HCI_SCO_HDR_SIZE 3 #define HCI_SCO_HDR_SIZE 3
#define HCI_ISO_HDR_SIZE 4
struct hci_command_hdr { struct hci_command_hdr {
__le16 opcode; /* OCF & OGF */ __le16 opcode; /* OCF & OGF */
@ -401,6 +415,11 @@ struct hci_sco_hdr {
__u8 dlen; __u8 dlen;
} __packed; } __packed;
struct hci_iso_hdr {
__le16 handle; /* Handle & Flags(PB, BC) */
__le16 dlen;
} __packed;
static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
{ {
return (struct hci_event_hdr *) skb->data; return (struct hci_event_hdr *) skb->data;
@ -416,6 +435,11 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
return (struct hci_sco_hdr *) skb->data; return (struct hci_sco_hdr *) skb->data;
} }
static inline struct hci_iso_hdr *hci_iso_hdr(const struct sk_buff *skb)
{
return (struct hci_iso_hdr *) skb->data;
}
/* ---- HCI Ioctl requests structures ---- */ /* ---- HCI Ioctl requests structures ---- */
struct hci_dev_stats { struct hci_dev_stats {
__u32 err_rx; __u32 err_rx;
@ -470,8 +494,6 @@ struct hci_dev {
struct device *parent; struct device *parent;
struct device dev; struct device dev;
unsigned long dev_flags;
int (*open)(struct hci_dev *hdev); int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev); int (*flush)(struct hci_dev *hdev);
@ -591,6 +613,7 @@ static inline void hci_set_drvdata(struct hci_dev *hdev, void *data)
#define CONFIG_MAC_OFFSET_GEN_1_2 (0x3C) //MAC's OFFSET in config/efuse for realtek generation 1~2 bluetooth chip #define CONFIG_MAC_OFFSET_GEN_1_2 (0x3C) //MAC's OFFSET in config/efuse for realtek generation 1~2 bluetooth chip
#define CONFIG_MAC_OFFSET_GEN_3PLUS (0x44) //MAC's OFFSET in config/efuse for rtk generation 3+ bluetooth chip #define CONFIG_MAC_OFFSET_GEN_3PLUS (0x44) //MAC's OFFSET in config/efuse for rtk generation 3+ bluetooth chip
#define CONFIG_MAC_OFFSET_GEN_4PLUS (0x30) //MAC's OFFSET in config/efuse for rtk generation 4+ bluetooth chip
/******************************* /*******************************
** Reasil patch code ** Reasil patch code
@ -607,8 +630,15 @@ static inline void hci_set_drvdata(struct hci_dev *hdev, void *data)
#define CMD_HDR_LEN sizeof(struct hci_command_hdr) #define CMD_HDR_LEN sizeof(struct hci_command_hdr)
#define EVT_HDR_LEN sizeof(struct hci_event_hdr) #define EVT_HDR_LEN sizeof(struct hci_event_hdr)
#define CMD_CMP_LEN sizeof(struct hci_ev_cmd_complete) #define CMD_CMP_LEN sizeof(struct hci_ev_cmd_complete)
#define MAX_PATCH_SIZE_24K (1024*24)
#define MAX_PATCH_SIZE_40K (1024*40) #define MAX_PATCH_SIZE_24K (1024*24 + 529) //24K
#define MAX_PATCH_SIZE_25K (1024*25 + 529) //25K for rtl8822b
#define MAX_PATCH_SIZE_40K (1024*40 + 529) //40K
#define MAX_PATCH_SIZE_49_2K (0xC4CF + 529) //49.2K 8723f
#define MAX_PATCH_SIZE_69_2K (0x114D0 + 529) //69.2K 8852a
#define MAX_PATCH_SIZE_65_2K (0x104D0 + 529) //65.2K 8852b
#define MAX_PATCH_SIZE_78K (1024*78 + 529) //78K 8852c
#define MAX_PATCH_SIZE_145K (0x24620) //145K 8822E
enum rtk_endpoit { enum rtk_endpoit {
CTRL_EP = 0, CTRL_EP = 0,
@ -659,14 +689,15 @@ typedef struct {
} __attribute__((packed)) download_rp; } __attribute__((packed)) download_rp;
#define DOWN_FW_CFG _IOW('E', 176, int)
//Define ioctl cmd the same as HCIDEVUP in the kernel
#define DOWN_FW_CFG _IOW('H', 201, int)
#ifdef CONFIG_SCO_OVER_HCI #ifdef CONFIG_SCO_OVER_HCI
#define SET_ISO_CFG _IOW('H', 202, int) #define SET_ISO_CFG _IOW('E', 177, int)
#endif #endif
#define GET_USB_INFO _IOW('H', 203, int) #define RESET_CONTROLLER _IOW('E', 178, int)
#define RESET_CONTROLLER _IOW('H', 204, int) #define DWFW_CMPLT _IOW('E', 179, int)
#define GET_USB_INFO _IOR('E', 180, int)
#define SET_ISO_MIN_HANDLE _IOR('E', 181, int)
/* for altsettings*/ /* for altsettings*/
#include <linux/fs.h> #include <linux/fs.h>
@ -675,6 +706,7 @@ typedef struct {
static inline int getmacaddr(uint8_t * vnd_local_bd_addr) static inline int getmacaddr(uint8_t * vnd_local_bd_addr)
{ {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 14)
struct file *bdaddr_file; struct file *bdaddr_file;
mm_segment_t oldfs; mm_segment_t oldfs;
char buf[FACTORY_BT_BDADDR_STORAGE_LEN]; char buf[FACTORY_BT_BDADDR_STORAGE_LEN];
@ -710,6 +742,7 @@ static inline int getmacaddr(uint8_t * vnd_local_bd_addr)
} }
return 0; return 0;
} }
#endif
return -1; return -1;
} }

View File

@ -258,6 +258,7 @@ struct usb_interface {
struct device dev; /* interface specific device info */ struct device dev; /* interface specific device info */
struct device *usb_dev; struct device *usb_dev;
struct work_struct reset_ws; /* for resets in atomic context */ struct work_struct reset_ws; /* for resets in atomic context */
atomic_t pm_usage_cnt;
ANDROID_KABI_RESERVE(1); ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2); ANDROID_KABI_RESERVE(2);