1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * 3*4882a593Smuzhiyun * Realtek Bluetooth USB driver 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify 7*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by 8*4882a593Smuzhiyun * the Free Software Foundation; either version 2 of the License, or 9*4882a593Smuzhiyun * (at your option) any later version. 10*4882a593Smuzhiyun * 11*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, 12*4882a593Smuzhiyun * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*4882a593Smuzhiyun * GNU General Public License for more details. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License 17*4882a593Smuzhiyun * along with this program; if not, write to the Free Software 18*4882a593Smuzhiyun * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun */ 21*4882a593Smuzhiyun #include <linux/interrupt.h> 22*4882a593Smuzhiyun #include <linux/module.h> 23*4882a593Smuzhiyun #include <linux/slab.h> 24*4882a593Smuzhiyun #include <linux/types.h> 25*4882a593Smuzhiyun #include <linux/sched.h> 26*4882a593Smuzhiyun #include <linux/skbuff.h> 27*4882a593Smuzhiyun #include <linux/errno.h> 28*4882a593Smuzhiyun #include <linux/usb.h> 29*4882a593Smuzhiyun #include <linux/cdev.h> 30*4882a593Smuzhiyun #include <linux/device.h> 31*4882a593Smuzhiyun #include <linux/poll.h> 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #include <linux/version.h> 34*4882a593Smuzhiyun #include <linux/pm_runtime.h> 35*4882a593Smuzhiyun #include <linux/firmware.h> 36*4882a593Smuzhiyun #include <linux/suspend.h> 37*4882a593Smuzhiyun #include <net/bluetooth/bluetooth.h> 38*4882a593Smuzhiyun #include <net/bluetooth/hci_core.h> 39*4882a593Smuzhiyun #include <net/bluetooth/hci.h> 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun /* #define HCI_VERSION_CODE KERNEL_VERSION(3, 14, 41) */ 42*4882a593Smuzhiyun #define HCI_VERSION_CODE LINUX_VERSION_CODE 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun #define BTCOEX 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun /*********************************** 47*4882a593Smuzhiyun ** Realtek - For rtk_btusb driver ** 48*4882a593Smuzhiyun ***********************************/ 49*4882a593Smuzhiyun #define BTUSB_WAKEUP_HOST 0 /* 1 enable; 0 disable */ 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun #define URB_CANCELING_DELAY_MS 10 // Added by Realtek 52*4882a593Smuzhiyun #if HCI_VERSION_CODE > KERNEL_VERSION(2, 6, 33) 53*4882a593Smuzhiyun #define HDEV_BUS hdev->bus 54*4882a593Smuzhiyun #else 55*4882a593Smuzhiyun #define HDEV_BUS hdev->type 56*4882a593Smuzhiyun #endif 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 33) 59*4882a593Smuzhiyun #define USB_RPM 1 60*4882a593Smuzhiyun #else 61*4882a593Smuzhiyun #define USB_RPM 0 62*4882a593Smuzhiyun #endif 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun #if HCI_VERSION_CODE < KERNEL_VERSION(2, 6, 36) 65*4882a593Smuzhiyun #define NUM_REASSEMBLY 3 66*4882a593Smuzhiyun #endif 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) 69*4882a593Smuzhiyun #define GET_DRV_DATA(x) hci_get_drvdata(x) 70*4882a593Smuzhiyun #else 71*4882a593Smuzhiyun #define GET_DRV_DATA(x) x->driver_data 72*4882a593Smuzhiyun #endif 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun #if HCI_VERSION_CODE < KERNEL_VERSION(3, 13, 0) 75*4882a593Smuzhiyun #define SCO_NUM hdev->conn_hash.sco_num 76*4882a593Smuzhiyun #else 77*4882a593Smuzhiyun #define SCO_NUM hci_conn_num(hdev, SCO_LINK) 78*4882a593Smuzhiyun #endif 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun int patch_add(struct usb_interface *intf); 81*4882a593Smuzhiyun void patch_remove(struct usb_interface *intf); 82*4882a593Smuzhiyun int download_patch(struct usb_interface *intf); 83*4882a593Smuzhiyun int set_btoff(struct usb_interface *intf); 84*4882a593Smuzhiyun void print_event(struct sk_buff *skb); 85*4882a593Smuzhiyun void print_command(struct sk_buff *skb); 86*4882a593Smuzhiyun void print_acl(struct sk_buff *skb, int dataOut); 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) 89*4882a593Smuzhiyun int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb); 90*4882a593Smuzhiyun #else 91*4882a593Smuzhiyun int btusb_send_frame(struct sk_buff *skb); 92*4882a593Smuzhiyun #endif 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun #define BTUSB_MAX_ISOC_FRAMES 10 95*4882a593Smuzhiyun #define BTUSB_INTR_RUNNING 0 96*4882a593Smuzhiyun #define BTUSB_BULK_RUNNING 1 97*4882a593Smuzhiyun #define BTUSB_ISOC_RUNNING 2 98*4882a593Smuzhiyun #define BTUSB_SUSPENDING 3 99*4882a593Smuzhiyun #define BTUSB_DID_ISO_RESUME 4 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun struct btusb_data { 102*4882a593Smuzhiyun struct hci_dev *hdev; 103*4882a593Smuzhiyun struct usb_device *udev; 104*4882a593Smuzhiyun struct usb_interface *intf; 105*4882a593Smuzhiyun struct usb_interface *isoc; 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun spinlock_t lock; 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun unsigned long flags; 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun struct work_struct work; 112*4882a593Smuzhiyun struct work_struct waker; 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun struct usb_anchor tx_anchor; 115*4882a593Smuzhiyun struct usb_anchor intr_anchor; 116*4882a593Smuzhiyun struct usb_anchor bulk_anchor; 117*4882a593Smuzhiyun struct usb_anchor isoc_anchor; 118*4882a593Smuzhiyun struct usb_anchor deferred; 119*4882a593Smuzhiyun int tx_in_flight; 120*4882a593Smuzhiyun spinlock_t txlock; 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) 123*4882a593Smuzhiyun spinlock_t rxlock; 124*4882a593Smuzhiyun struct sk_buff *evt_skb; 125*4882a593Smuzhiyun struct sk_buff *acl_skb; 126*4882a593Smuzhiyun struct sk_buff *sco_skb; 127*4882a593Smuzhiyun #endif 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun struct usb_endpoint_descriptor *intr_ep; 130*4882a593Smuzhiyun struct usb_endpoint_descriptor *bulk_tx_ep; 131*4882a593Smuzhiyun struct usb_endpoint_descriptor *bulk_rx_ep; 132*4882a593Smuzhiyun struct usb_endpoint_descriptor *isoc_tx_ep; 133*4882a593Smuzhiyun struct usb_endpoint_descriptor *isoc_rx_ep; 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun __u8 cmdreq_type; 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun unsigned int sco_num; 138*4882a593Smuzhiyun int isoc_altsetting; 139*4882a593Smuzhiyun int suspend_count; 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun #if HCI_VERSION_CODE >= KERNEL_VERSION(3, 18, 0) 142*4882a593Smuzhiyun int (*recv_bulk) (struct btusb_data * data, void *buffer, int count); 143*4882a593Smuzhiyun #endif 144*4882a593Smuzhiyun struct notifier_block pm_notifier; 145*4882a593Smuzhiyun void *context; 146*4882a593Smuzhiyun }; 147