1 /* 2 * 3 * Realtek Bluetooth USB download firmware driver 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22 #include <linux/kernel.h> 23 #include <linux/module.h> 24 #include <linux/version.h> 25 #include <linux/pm_runtime.h> 26 #include <linux/usb.h> 27 #include <linux/suspend.h> 28 29 /* Download LPS patch when host suspends or power off 30 * LPS patch name: lps_rtl8xxx_fw 31 * LPS config name: lps_rtl8xxx_config 32 * Download normal patch when host resume or power on */ 33 /* #define RTKBT_SWITCH_PATCH */ 34 35 /* RTKBT Power-on Whitelist for sideband wake-up by LE Advertising from Remote. 36 * Note that it's necessary to apply TV FW Patch. */ 37 /* #define RTKBT_TV_POWERON_WHITELIST */ 38 39 #if 1 40 #define RTKBT_DBG(fmt, arg...) printk(KERN_INFO "rtk_btusb: " fmt "\n" , ## arg) 41 #define RTKBT_INFO(fmt, arg...) printk(KERN_INFO "rtk_btusb: " fmt "\n" , ## arg) 42 #define RTKBT_WARN(fmt, arg...) printk(KERN_WARNING "rtk_btusb: " fmt "\n", ## arg) 43 #else 44 #define RTKBT_DBG(fmt, arg...) 45 #endif 46 47 #if 1 48 #define RTKBT_ERR(fmt, arg...) printk(KERN_ERR "rtk_btusb: " fmt "\n" , ## arg) 49 #else 50 #define RTKBT_ERR(fmt, arg...) 51 #endif 52 53 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 33) 54 #define USB_RPM 1 55 #else 56 #define USB_RPM 0 57 #endif 58 59 #define CONFIG_NEEDS_BINDING 60 61 /* If module is still powered when kernel suspended, there is no re-binding. */ 62 #ifdef RTKBT_SWITCH_PATCH 63 #undef CONFIG_NEEDS_BINDING 64 #endif 65 66 67 /* 1 SS enable; 0 SS disable */ 68 #define BTUSB_RPM (0*USB_RPM) 69 70 #define PRINT_CMD_EVENT 0 71 #define PRINT_ACL_DATA 0 72 73 extern int patch_add(struct usb_interface *intf); 74 extern void patch_remove(struct usb_interface *intf); 75 extern int download_patch(struct usb_interface *intf); 76 extern void print_event(struct sk_buff *skb); 77 extern void print_command(struct sk_buff *skb); 78 extern void print_acl(struct sk_buff *skb, int dataOut); 79 80 #if defined RTKBT_SWITCH_PATCH || defined RTKBT_TV_POWERON_WHITELIST 81 int __rtk_send_hci_cmd(struct usb_device *udev, u8 *buf, u16 size); 82 int __rtk_recv_hci_evt(struct usb_device *udev, u8 *buf, u8 len, u16 opcode); 83 #endif 84 85 #ifdef RTKBT_SWITCH_PATCH 86 #define RTLBT_CLOSE (1 << 0) 87 struct api_context { 88 u32 flags; 89 struct completion done; 90 int status; 91 }; 92 93 int download_lps_patch(struct usb_interface *intf); 94 int set_scan(struct usb_interface *intf); 95 96 #endif 97