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