btusb.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. /*
  2. *
  3. * Generic Bluetooth USB driver
  4. *
  5. * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. #include <linux/usb.h>
  25. #include <net/bluetooth/bluetooth.h>
  26. #include <net/bluetooth/hci_core.h>
  27. #define VERSION "0.6"
  28. static bool ignore_dga;
  29. static bool ignore_csr;
  30. static bool ignore_sniffer;
  31. static bool disable_scofix;
  32. static bool force_scofix;
  33. static bool reset = 1;
  34. static struct usb_driver btusb_driver;
  35. #define BTUSB_IGNORE 0x01
  36. #define BTUSB_DIGIANSWER 0x02
  37. #define BTUSB_CSR 0x04
  38. #define BTUSB_SNIFFER 0x08
  39. #define BTUSB_BCM92035 0x10
  40. #define BTUSB_BROKEN_ISOC 0x20
  41. #define BTUSB_WRONG_SCO_MTU 0x40
  42. #define BTUSB_ATH3012 0x80
  43. static struct usb_device_id btusb_table[] = {
  44. /* Generic Bluetooth USB device */
  45. { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
  46. /* Apple-specific (Broadcom) devices */
  47. { USB_VENDOR_AND_INTERFACE_INFO(0x05ac, 0xff, 0x01, 0x01) },
  48. /* Broadcom SoftSailing reporting vendor specific */
  49. { USB_DEVICE(0x0a5c, 0x21e1) },
  50. /* Apple MacBookPro 7,1 */
  51. { USB_DEVICE(0x05ac, 0x8213) },
  52. /* Apple iMac11,1 */
  53. { USB_DEVICE(0x05ac, 0x8215) },
  54. /* Apple MacBookPro6,2 */
  55. { USB_DEVICE(0x05ac, 0x8218) },
  56. /* Apple MacBookAir3,1, MacBookAir3,2 */
  57. { USB_DEVICE(0x05ac, 0x821b) },
  58. /* Apple MacBookAir4,1 */
  59. { USB_DEVICE(0x05ac, 0x821f) },
  60. /* Apple MacBookPro8,2 */
  61. { USB_DEVICE(0x05ac, 0x821a) },
  62. /* Apple MacMini5,1 */
  63. { USB_DEVICE(0x05ac, 0x8281) },
  64. /* AVM BlueFRITZ! USB v2.0 */
  65. { USB_DEVICE(0x057c, 0x3800) },
  66. /* Bluetooth Ultraport Module from IBM */
  67. { USB_DEVICE(0x04bf, 0x030a) },
  68. /* ALPS Modules with non-standard id */
  69. { USB_DEVICE(0x044e, 0x3001) },
  70. { USB_DEVICE(0x044e, 0x3002) },
  71. /* Ericsson with non-standard id */
  72. { USB_DEVICE(0x0bdb, 0x1002) },
  73. /* Canyon CN-BTU1 with HID interfaces */
  74. { USB_DEVICE(0x0c10, 0x0000) },
  75. /* Broadcom BCM20702A0 */
  76. { USB_DEVICE(0x0b05, 0x17b5) },
  77. { USB_DEVICE(0x04ca, 0x2003) },
  78. { USB_DEVICE(0x0489, 0xe042) },
  79. { USB_DEVICE(0x413c, 0x8197) },
  80. /* Foxconn - Hon Hai */
  81. { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
  82. /*Broadcom devices with vendor specific id */
  83. { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
  84. { } /* Terminating entry */
  85. };
  86. MODULE_DEVICE_TABLE(usb, btusb_table);
  87. static struct usb_device_id blacklist_table[] = {
  88. /* CSR BlueCore devices */
  89. { USB_DEVICE(0x0a12, 0x0001), .driver_info = BTUSB_CSR },
  90. /* Broadcom BCM2033 without firmware */
  91. { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE },
  92. /* Atheros 3011 with sflash firmware */
  93. { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
  94. { USB_DEVICE(0x0cf3, 0xe019), .driver_info = BTUSB_IGNORE },
  95. { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
  96. { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
  97. { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
  98. { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
  99. /* Atheros AR9285 Malbec with sflash firmware */
  100. { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
  101. /* Atheros 3012 with sflash firmware */
  102. { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 },
  103. { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
  104. { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
  105. { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
  106. { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
  107. { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
  108. { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
  109. { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
  110. { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
  111. { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
  112. { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
  113. { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
  114. { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
  115. { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
  116. { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
  117. { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
  118. /* Atheros AR5BBU12 with sflash firmware */
  119. { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
  120. /* Atheros AR5BBU12 with sflash firmware */
  121. { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
  122. { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
  123. /* Broadcom BCM2035 */
  124. { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
  125. { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
  126. { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
  127. /* Broadcom BCM2045 */
  128. { USB_DEVICE(0x0a5c, 0x2039), .driver_info = BTUSB_WRONG_SCO_MTU },
  129. { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_WRONG_SCO_MTU },
  130. /* IBM/Lenovo ThinkPad with Broadcom chip */
  131. { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_WRONG_SCO_MTU },
  132. { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_WRONG_SCO_MTU },
  133. /* HP laptop with Broadcom chip */
  134. { USB_DEVICE(0x03f0, 0x171d), .driver_info = BTUSB_WRONG_SCO_MTU },
  135. /* Dell laptop with Broadcom chip */
  136. { USB_DEVICE(0x413c, 0x8126), .driver_info = BTUSB_WRONG_SCO_MTU },
  137. /* Dell Wireless 370 and 410 devices */
  138. { USB_DEVICE(0x413c, 0x8152), .driver_info = BTUSB_WRONG_SCO_MTU },
  139. { USB_DEVICE(0x413c, 0x8156), .driver_info = BTUSB_WRONG_SCO_MTU },
  140. /* Belkin F8T012 and F8T013 devices */
  141. { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_WRONG_SCO_MTU },
  142. { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_WRONG_SCO_MTU },
  143. /* Asus WL-BTD202 device */
  144. { USB_DEVICE(0x0b05, 0x1715), .driver_info = BTUSB_WRONG_SCO_MTU },
  145. /* Kensington Bluetooth USB adapter */
  146. { USB_DEVICE(0x047d, 0x105e), .driver_info = BTUSB_WRONG_SCO_MTU },
  147. /* RTX Telecom based adapters with buggy SCO support */
  148. { USB_DEVICE(0x0400, 0x0807), .driver_info = BTUSB_BROKEN_ISOC },
  149. { USB_DEVICE(0x0400, 0x080a), .driver_info = BTUSB_BROKEN_ISOC },
  150. /* CONWISE Technology based adapters with buggy SCO support */
  151. { USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC },
  152. /* Digianswer devices */
  153. { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
  154. { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
  155. /* CSR BlueCore Bluetooth Sniffer */
  156. { USB_DEVICE(0x0a12, 0x0002), .driver_info = BTUSB_SNIFFER },
  157. /* Frontline ComProbe Bluetooth Sniffer */
  158. { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER },
  159. { } /* Terminating entry */
  160. };
  161. #define BTUSB_MAX_ISOC_FRAMES 10
  162. #define BTUSB_INTR_RUNNING 0
  163. #define BTUSB_BULK_RUNNING 1
  164. #define BTUSB_ISOC_RUNNING 2
  165. #define BTUSB_SUSPENDING 3
  166. #define BTUSB_DID_ISO_RESUME 4
  167. struct btusb_data {
  168. struct hci_dev *hdev;
  169. struct usb_device *udev;
  170. struct usb_interface *intf;
  171. struct usb_interface *isoc;
  172. spinlock_t lock;
  173. unsigned long flags;
  174. struct work_struct work;
  175. struct work_struct waker;
  176. struct usb_anchor tx_anchor;
  177. struct usb_anchor intr_anchor;
  178. struct usb_anchor bulk_anchor;
  179. struct usb_anchor isoc_anchor;
  180. struct usb_anchor deferred;
  181. int tx_in_flight;
  182. spinlock_t txlock;
  183. struct usb_endpoint_descriptor *intr_ep;
  184. struct usb_endpoint_descriptor *bulk_tx_ep;
  185. struct usb_endpoint_descriptor *bulk_rx_ep;
  186. struct usb_endpoint_descriptor *isoc_tx_ep;
  187. struct usb_endpoint_descriptor *isoc_rx_ep;
  188. __u8 cmdreq_type;
  189. unsigned int sco_num;
  190. int isoc_altsetting;
  191. int suspend_count;
  192. };
  193. static int inc_tx(struct btusb_data *data)
  194. {
  195. unsigned long flags;
  196. int rv;
  197. spin_lock_irqsave(&data->txlock, flags);
  198. rv = test_bit(BTUSB_SUSPENDING, &data->flags);
  199. if (!rv)
  200. data->tx_in_flight++;
  201. spin_unlock_irqrestore(&data->txlock, flags);
  202. return rv;
  203. }
  204. static void btusb_intr_complete(struct urb *urb)
  205. {
  206. struct hci_dev *hdev = urb->context;
  207. struct btusb_data *data = hci_get_drvdata(hdev);
  208. int err;
  209. BT_DBG("%s urb %p status %d count %d", hdev->name,
  210. urb, urb->status, urb->actual_length);
  211. if (!test_bit(HCI_RUNNING, &hdev->flags))
  212. return;
  213. if (urb->status == 0) {
  214. hdev->stat.byte_rx += urb->actual_length;
  215. if (hci_recv_fragment(hdev, HCI_EVENT_PKT,
  216. urb->transfer_buffer,
  217. urb->actual_length) < 0) {
  218. BT_ERR("%s corrupted event packet", hdev->name);
  219. hdev->stat.err_rx++;
  220. }
  221. }
  222. if (!test_bit(BTUSB_INTR_RUNNING, &data->flags))
  223. return;
  224. usb_mark_last_busy(data->udev);
  225. usb_anchor_urb(urb, &data->intr_anchor);
  226. err = usb_submit_urb(urb, GFP_ATOMIC);
  227. if (err < 0) {
  228. /* -EPERM: urb is being killed;
  229. * -ENODEV: device got disconnected */
  230. if (err != -EPERM && err != -ENODEV)
  231. BT_ERR("%s urb %p failed to resubmit (%d)",
  232. hdev->name, urb, -err);
  233. usb_unanchor_urb(urb);
  234. }
  235. }
  236. static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
  237. {
  238. struct btusb_data *data = hci_get_drvdata(hdev);
  239. struct urb *urb;
  240. unsigned char *buf;
  241. unsigned int pipe;
  242. int err, size;
  243. BT_DBG("%s", hdev->name);
  244. if (!data->intr_ep)
  245. return -ENODEV;
  246. urb = usb_alloc_urb(0, mem_flags);
  247. if (!urb)
  248. return -ENOMEM;
  249. size = le16_to_cpu(data->intr_ep->wMaxPacketSize);
  250. buf = kmalloc(size, mem_flags);
  251. if (!buf) {
  252. usb_free_urb(urb);
  253. return -ENOMEM;
  254. }
  255. pipe = usb_rcvintpipe(data->udev, data->intr_ep->bEndpointAddress);
  256. usb_fill_int_urb(urb, data->udev, pipe, buf, size,
  257. btusb_intr_complete, hdev,
  258. data->intr_ep->bInterval);
  259. urb->transfer_flags |= URB_FREE_BUFFER;
  260. usb_anchor_urb(urb, &data->intr_anchor);
  261. err = usb_submit_urb(urb, mem_flags);
  262. if (err < 0) {
  263. if (err != -EPERM && err != -ENODEV)
  264. BT_ERR("%s urb %p submission failed (%d)",
  265. hdev->name, urb, -err);
  266. usb_unanchor_urb(urb);
  267. }
  268. usb_free_urb(urb);
  269. return err;
  270. }
  271. static void btusb_bulk_complete(struct urb *urb)
  272. {
  273. struct hci_dev *hdev = urb->context;
  274. struct btusb_data *data = hci_get_drvdata(hdev);
  275. int err;
  276. BT_DBG("%s urb %p status %d count %d", hdev->name,
  277. urb, urb->status, urb->actual_length);
  278. if (!test_bit(HCI_RUNNING, &hdev->flags))
  279. return;
  280. if (urb->status == 0) {
  281. hdev->stat.byte_rx += urb->actual_length;
  282. if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT,
  283. urb->transfer_buffer,
  284. urb->actual_length) < 0) {
  285. BT_ERR("%s corrupted ACL packet", hdev->name);
  286. hdev->stat.err_rx++;
  287. }
  288. }
  289. if (!test_bit(BTUSB_BULK_RUNNING, &data->flags))
  290. return;
  291. usb_anchor_urb(urb, &data->bulk_anchor);
  292. usb_mark_last_busy(data->udev);
  293. err = usb_submit_urb(urb, GFP_ATOMIC);
  294. if (err < 0) {
  295. /* -EPERM: urb is being killed;
  296. * -ENODEV: device got disconnected */
  297. if (err != -EPERM && err != -ENODEV)
  298. BT_ERR("%s urb %p failed to resubmit (%d)",
  299. hdev->name, urb, -err);
  300. usb_unanchor_urb(urb);
  301. }
  302. }
  303. static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
  304. {
  305. struct btusb_data *data = hci_get_drvdata(hdev);
  306. struct urb *urb;
  307. unsigned char *buf;
  308. unsigned int pipe;
  309. int err, size = HCI_MAX_FRAME_SIZE;
  310. BT_DBG("%s", hdev->name);
  311. if (!data->bulk_rx_ep)
  312. return -ENODEV;
  313. urb = usb_alloc_urb(0, mem_flags);
  314. if (!urb)
  315. return -ENOMEM;
  316. buf = kmalloc(size, mem_flags);
  317. if (!buf) {
  318. usb_free_urb(urb);
  319. return -ENOMEM;
  320. }
  321. pipe = usb_rcvbulkpipe(data->udev, data->bulk_rx_ep->bEndpointAddress);
  322. usb_fill_bulk_urb(urb, data->udev, pipe,
  323. buf, size, btusb_bulk_complete, hdev);
  324. urb->transfer_flags |= URB_FREE_BUFFER;
  325. usb_mark_last_busy(data->udev);
  326. usb_anchor_urb(urb, &data->bulk_anchor);
  327. err = usb_submit_urb(urb, mem_flags);
  328. if (err < 0) {
  329. if (err != -EPERM && err != -ENODEV)
  330. BT_ERR("%s urb %p submission failed (%d)",
  331. hdev->name, urb, -err);
  332. usb_unanchor_urb(urb);
  333. }
  334. usb_free_urb(urb);
  335. return err;
  336. }
  337. static void btusb_isoc_complete(struct urb *urb)
  338. {
  339. struct hci_dev *hdev = urb->context;
  340. struct btusb_data *data = hci_get_drvdata(hdev);
  341. int i, err;
  342. BT_DBG("%s urb %p status %d count %d", hdev->name,
  343. urb, urb->status, urb->actual_length);
  344. if (!test_bit(HCI_RUNNING, &hdev->flags))
  345. return;
  346. if (urb->status == 0) {
  347. for (i = 0; i < urb->number_of_packets; i++) {
  348. unsigned int offset = urb->iso_frame_desc[i].offset;
  349. unsigned int length = urb->iso_frame_desc[i].actual_length;
  350. if (urb->iso_frame_desc[i].status)
  351. continue;
  352. hdev->stat.byte_rx += length;
  353. if (hci_recv_fragment(hdev, HCI_SCODATA_PKT,
  354. urb->transfer_buffer + offset,
  355. length) < 0) {
  356. BT_ERR("%s corrupted SCO packet", hdev->name);
  357. hdev->stat.err_rx++;
  358. }
  359. }
  360. }
  361. if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags))
  362. return;
  363. usb_anchor_urb(urb, &data->isoc_anchor);
  364. err = usb_submit_urb(urb, GFP_ATOMIC);
  365. if (err < 0) {
  366. /* -EPERM: urb is being killed;
  367. * -ENODEV: device got disconnected */
  368. if (err != -EPERM && err != -ENODEV)
  369. BT_ERR("%s urb %p failed to resubmit (%d)",
  370. hdev->name, urb, -err);
  371. usb_unanchor_urb(urb);
  372. }
  373. }
  374. static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
  375. {
  376. int i, offset = 0;
  377. BT_DBG("len %d mtu %d", len, mtu);
  378. for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu;
  379. i++, offset += mtu, len -= mtu) {
  380. urb->iso_frame_desc[i].offset = offset;
  381. urb->iso_frame_desc[i].length = mtu;
  382. }
  383. if (len && i < BTUSB_MAX_ISOC_FRAMES) {
  384. urb->iso_frame_desc[i].offset = offset;
  385. urb->iso_frame_desc[i].length = len;
  386. i++;
  387. }
  388. urb->number_of_packets = i;
  389. }
  390. static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
  391. {
  392. struct btusb_data *data = hci_get_drvdata(hdev);
  393. struct urb *urb;
  394. unsigned char *buf;
  395. unsigned int pipe;
  396. int err, size;
  397. BT_DBG("%s", hdev->name);
  398. if (!data->isoc_rx_ep)
  399. return -ENODEV;
  400. urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, mem_flags);
  401. if (!urb)
  402. return -ENOMEM;
  403. size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) *
  404. BTUSB_MAX_ISOC_FRAMES;
  405. buf = kmalloc(size, mem_flags);
  406. if (!buf) {
  407. usb_free_urb(urb);
  408. return -ENOMEM;
  409. }
  410. pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress);
  411. usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete,
  412. hdev, data->isoc_rx_ep->bInterval);
  413. urb->transfer_flags = URB_FREE_BUFFER | URB_ISO_ASAP;
  414. __fill_isoc_descriptor(urb, size,
  415. le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize));
  416. usb_anchor_urb(urb, &data->isoc_anchor);
  417. err = usb_submit_urb(urb, mem_flags);
  418. if (err < 0) {
  419. if (err != -EPERM && err != -ENODEV)
  420. BT_ERR("%s urb %p submission failed (%d)",
  421. hdev->name, urb, -err);
  422. usb_unanchor_urb(urb);
  423. }
  424. usb_free_urb(urb);
  425. return err;
  426. }
  427. static void btusb_tx_complete(struct urb *urb)
  428. {
  429. struct sk_buff *skb = urb->context;
  430. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  431. struct btusb_data *data = hci_get_drvdata(hdev);
  432. BT_DBG("%s urb %p status %d count %d", hdev->name,
  433. urb, urb->status, urb->actual_length);
  434. if (!test_bit(HCI_RUNNING, &hdev->flags))
  435. goto done;
  436. if (!urb->status)
  437. hdev->stat.byte_tx += urb->transfer_buffer_length;
  438. else
  439. hdev->stat.err_tx++;
  440. done:
  441. spin_lock(&data->txlock);
  442. data->tx_in_flight--;
  443. spin_unlock(&data->txlock);
  444. kfree(urb->setup_packet);
  445. kfree_skb(skb);
  446. }
  447. static void btusb_isoc_tx_complete(struct urb *urb)
  448. {
  449. struct sk_buff *skb = urb->context;
  450. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  451. BT_DBG("%s urb %p status %d count %d", hdev->name,
  452. urb, urb->status, urb->actual_length);
  453. if (!test_bit(HCI_RUNNING, &hdev->flags))
  454. goto done;
  455. if (!urb->status)
  456. hdev->stat.byte_tx += urb->transfer_buffer_length;
  457. else
  458. hdev->stat.err_tx++;
  459. done:
  460. kfree(urb->setup_packet);
  461. kfree_skb(skb);
  462. }
  463. static int btusb_open(struct hci_dev *hdev)
  464. {
  465. struct btusb_data *data = hci_get_drvdata(hdev);
  466. int err;
  467. BT_DBG("%s", hdev->name);
  468. err = usb_autopm_get_interface(data->intf);
  469. if (err < 0)
  470. return err;
  471. data->intf->needs_remote_wakeup = 1;
  472. if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
  473. goto done;
  474. if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
  475. goto done;
  476. err = btusb_submit_intr_urb(hdev, GFP_KERNEL);
  477. if (err < 0)
  478. goto failed;
  479. err = btusb_submit_bulk_urb(hdev, GFP_KERNEL);
  480. if (err < 0) {
  481. usb_kill_anchored_urbs(&data->intr_anchor);
  482. goto failed;
  483. }
  484. set_bit(BTUSB_BULK_RUNNING, &data->flags);
  485. btusb_submit_bulk_urb(hdev, GFP_KERNEL);
  486. done:
  487. usb_autopm_put_interface(data->intf);
  488. return 0;
  489. failed:
  490. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  491. clear_bit(HCI_RUNNING, &hdev->flags);
  492. usb_autopm_put_interface(data->intf);
  493. return err;
  494. }
  495. static void btusb_stop_traffic(struct btusb_data *data)
  496. {
  497. usb_kill_anchored_urbs(&data->intr_anchor);
  498. usb_kill_anchored_urbs(&data->bulk_anchor);
  499. usb_kill_anchored_urbs(&data->isoc_anchor);
  500. }
  501. static int btusb_close(struct hci_dev *hdev)
  502. {
  503. struct btusb_data *data = hci_get_drvdata(hdev);
  504. int err;
  505. BT_DBG("%s", hdev->name);
  506. if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
  507. return 0;
  508. cancel_work_sync(&data->work);
  509. cancel_work_sync(&data->waker);
  510. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  511. clear_bit(BTUSB_BULK_RUNNING, &data->flags);
  512. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  513. btusb_stop_traffic(data);
  514. err = usb_autopm_get_interface(data->intf);
  515. if (err < 0)
  516. goto failed;
  517. data->intf->needs_remote_wakeup = 0;
  518. usb_autopm_put_interface(data->intf);
  519. failed:
  520. usb_scuttle_anchored_urbs(&data->deferred);
  521. return 0;
  522. }
  523. static int btusb_flush(struct hci_dev *hdev)
  524. {
  525. struct btusb_data *data = hci_get_drvdata(hdev);
  526. BT_DBG("%s", hdev->name);
  527. usb_kill_anchored_urbs(&data->tx_anchor);
  528. return 0;
  529. }
  530. static int btusb_send_frame(struct sk_buff *skb)
  531. {
  532. struct hci_dev *hdev = (struct hci_dev *) skb->dev;
  533. struct btusb_data *data = hci_get_drvdata(hdev);
  534. struct usb_ctrlrequest *dr;
  535. struct urb *urb;
  536. unsigned int pipe;
  537. int err;
  538. BT_DBG("%s", hdev->name);
  539. if (!test_bit(HCI_RUNNING, &hdev->flags))
  540. return -EBUSY;
  541. switch (bt_cb(skb)->pkt_type) {
  542. case HCI_COMMAND_PKT:
  543. urb = usb_alloc_urb(0, GFP_ATOMIC);
  544. if (!urb)
  545. return -ENOMEM;
  546. dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
  547. if (!dr) {
  548. usb_free_urb(urb);
  549. return -ENOMEM;
  550. }
  551. dr->bRequestType = data->cmdreq_type;
  552. dr->bRequest = 0;
  553. dr->wIndex = 0;
  554. dr->wValue = 0;
  555. dr->wLength = __cpu_to_le16(skb->len);
  556. pipe = usb_sndctrlpipe(data->udev, 0x00);
  557. usb_fill_control_urb(urb, data->udev, pipe, (void *) dr,
  558. skb->data, skb->len, btusb_tx_complete, skb);
  559. hdev->stat.cmd_tx++;
  560. break;
  561. case HCI_ACLDATA_PKT:
  562. if (!data->bulk_tx_ep)
  563. return -ENODEV;
  564. urb = usb_alloc_urb(0, GFP_ATOMIC);
  565. if (!urb)
  566. return -ENOMEM;
  567. pipe = usb_sndbulkpipe(data->udev,
  568. data->bulk_tx_ep->bEndpointAddress);
  569. usb_fill_bulk_urb(urb, data->udev, pipe,
  570. skb->data, skb->len, btusb_tx_complete, skb);
  571. hdev->stat.acl_tx++;
  572. break;
  573. case HCI_SCODATA_PKT:
  574. if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1)
  575. return -ENODEV;
  576. urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC);
  577. if (!urb)
  578. return -ENOMEM;
  579. pipe = usb_sndisocpipe(data->udev,
  580. data->isoc_tx_ep->bEndpointAddress);
  581. usb_fill_int_urb(urb, data->udev, pipe,
  582. skb->data, skb->len, btusb_isoc_tx_complete,
  583. skb, data->isoc_tx_ep->bInterval);
  584. urb->transfer_flags = URB_ISO_ASAP;
  585. __fill_isoc_descriptor(urb, skb->len,
  586. le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize));
  587. hdev->stat.sco_tx++;
  588. goto skip_waking;
  589. default:
  590. return -EILSEQ;
  591. }
  592. err = inc_tx(data);
  593. if (err) {
  594. usb_anchor_urb(urb, &data->deferred);
  595. schedule_work(&data->waker);
  596. err = 0;
  597. goto done;
  598. }
  599. skip_waking:
  600. usb_anchor_urb(urb, &data->tx_anchor);
  601. err = usb_submit_urb(urb, GFP_ATOMIC);
  602. if (err < 0) {
  603. if (err != -EPERM && err != -ENODEV)
  604. BT_ERR("%s urb %p submission failed (%d)",
  605. hdev->name, urb, -err);
  606. kfree(urb->setup_packet);
  607. usb_unanchor_urb(urb);
  608. } else {
  609. usb_mark_last_busy(data->udev);
  610. }
  611. done:
  612. usb_free_urb(urb);
  613. return err;
  614. }
  615. static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
  616. {
  617. struct btusb_data *data = hci_get_drvdata(hdev);
  618. BT_DBG("%s evt %d", hdev->name, evt);
  619. if (hdev->conn_hash.sco_num != data->sco_num) {
  620. data->sco_num = hdev->conn_hash.sco_num;
  621. schedule_work(&data->work);
  622. }
  623. }
  624. static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
  625. {
  626. struct btusb_data *data = hci_get_drvdata(hdev);
  627. struct usb_interface *intf = data->isoc;
  628. struct usb_endpoint_descriptor *ep_desc;
  629. int i, err;
  630. if (!data->isoc)
  631. return -ENODEV;
  632. err = usb_set_interface(data->udev, 1, altsetting);
  633. if (err < 0) {
  634. BT_ERR("%s setting interface failed (%d)", hdev->name, -err);
  635. return err;
  636. }
  637. data->isoc_altsetting = altsetting;
  638. data->isoc_tx_ep = NULL;
  639. data->isoc_rx_ep = NULL;
  640. for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
  641. ep_desc = &intf->cur_altsetting->endpoint[i].desc;
  642. if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) {
  643. data->isoc_tx_ep = ep_desc;
  644. continue;
  645. }
  646. if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) {
  647. data->isoc_rx_ep = ep_desc;
  648. continue;
  649. }
  650. }
  651. if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
  652. BT_ERR("%s invalid SCO descriptors", hdev->name);
  653. return -ENODEV;
  654. }
  655. return 0;
  656. }
  657. static void btusb_work(struct work_struct *work)
  658. {
  659. struct btusb_data *data = container_of(work, struct btusb_data, work);
  660. struct hci_dev *hdev = data->hdev;
  661. int new_alts;
  662. int err;
  663. if (hdev->conn_hash.sco_num > 0) {
  664. if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) {
  665. err = usb_autopm_get_interface(data->isoc ? data->isoc : data->intf);
  666. if (err < 0) {
  667. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  668. usb_kill_anchored_urbs(&data->isoc_anchor);
  669. return;
  670. }
  671. set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
  672. }
  673. if (hdev->voice_setting & 0x0020) {
  674. static const int alts[3] = { 2, 4, 5 };
  675. new_alts = alts[hdev->conn_hash.sco_num - 1];
  676. } else {
  677. new_alts = hdev->conn_hash.sco_num;
  678. }
  679. if (data->isoc_altsetting != new_alts) {
  680. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  681. usb_kill_anchored_urbs(&data->isoc_anchor);
  682. if (__set_isoc_interface(hdev, new_alts) < 0)
  683. return;
  684. }
  685. if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
  686. if (btusb_submit_isoc_urb(hdev, GFP_KERNEL) < 0)
  687. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  688. else
  689. btusb_submit_isoc_urb(hdev, GFP_KERNEL);
  690. }
  691. } else {
  692. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  693. usb_kill_anchored_urbs(&data->isoc_anchor);
  694. __set_isoc_interface(hdev, 0);
  695. if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags))
  696. usb_autopm_put_interface(data->isoc ? data->isoc : data->intf);
  697. }
  698. }
  699. static void btusb_waker(struct work_struct *work)
  700. {
  701. struct btusb_data *data = container_of(work, struct btusb_data, waker);
  702. int err;
  703. err = usb_autopm_get_interface(data->intf);
  704. if (err < 0)
  705. return;
  706. usb_autopm_put_interface(data->intf);
  707. }
  708. static int btusb_probe(struct usb_interface *intf,
  709. const struct usb_device_id *id)
  710. {
  711. struct usb_endpoint_descriptor *ep_desc;
  712. struct btusb_data *data;
  713. struct hci_dev *hdev;
  714. int i, err;
  715. BT_DBG("intf %p id %p", intf, id);
  716. /* interface numbers are hardcoded in the spec */
  717. if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
  718. return -ENODEV;
  719. if (!id->driver_info) {
  720. const struct usb_device_id *match;
  721. match = usb_match_id(intf, blacklist_table);
  722. if (match)
  723. id = match;
  724. }
  725. if (id->driver_info == BTUSB_IGNORE)
  726. return -ENODEV;
  727. if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER)
  728. return -ENODEV;
  729. if (ignore_csr && id->driver_info & BTUSB_CSR)
  730. return -ENODEV;
  731. if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
  732. return -ENODEV;
  733. if (id->driver_info & BTUSB_ATH3012) {
  734. struct usb_device *udev = interface_to_usbdev(intf);
  735. /* Old firmware would otherwise let ath3k driver load
  736. * patch and sysconfig files */
  737. if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
  738. return -ENODEV;
  739. }
  740. data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
  741. if (!data)
  742. return -ENOMEM;
  743. for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
  744. ep_desc = &intf->cur_altsetting->endpoint[i].desc;
  745. if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) {
  746. data->intr_ep = ep_desc;
  747. continue;
  748. }
  749. if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) {
  750. data->bulk_tx_ep = ep_desc;
  751. continue;
  752. }
  753. if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) {
  754. data->bulk_rx_ep = ep_desc;
  755. continue;
  756. }
  757. }
  758. if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep)
  759. return -ENODEV;
  760. data->cmdreq_type = USB_TYPE_CLASS;
  761. data->udev = interface_to_usbdev(intf);
  762. data->intf = intf;
  763. spin_lock_init(&data->lock);
  764. INIT_WORK(&data->work, btusb_work);
  765. INIT_WORK(&data->waker, btusb_waker);
  766. spin_lock_init(&data->txlock);
  767. init_usb_anchor(&data->tx_anchor);
  768. init_usb_anchor(&data->intr_anchor);
  769. init_usb_anchor(&data->bulk_anchor);
  770. init_usb_anchor(&data->isoc_anchor);
  771. init_usb_anchor(&data->deferred);
  772. hdev = hci_alloc_dev();
  773. if (!hdev)
  774. return -ENOMEM;
  775. hdev->bus = HCI_USB;
  776. hci_set_drvdata(hdev, data);
  777. data->hdev = hdev;
  778. SET_HCIDEV_DEV(hdev, &intf->dev);
  779. hdev->open = btusb_open;
  780. hdev->close = btusb_close;
  781. hdev->flush = btusb_flush;
  782. hdev->send = btusb_send_frame;
  783. hdev->notify = btusb_notify;
  784. /* Interface numbers are hardcoded in the specification */
  785. data->isoc = usb_ifnum_to_if(data->udev, 1);
  786. if (!reset)
  787. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  788. if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) {
  789. if (!disable_scofix)
  790. set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
  791. }
  792. if (id->driver_info & BTUSB_BROKEN_ISOC)
  793. data->isoc = NULL;
  794. if (id->driver_info & BTUSB_DIGIANSWER) {
  795. data->cmdreq_type = USB_TYPE_VENDOR;
  796. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  797. }
  798. if (id->driver_info & BTUSB_CSR) {
  799. struct usb_device *udev = data->udev;
  800. /* Old firmware would otherwise execute USB reset */
  801. if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
  802. set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  803. }
  804. if (id->driver_info & BTUSB_SNIFFER) {
  805. struct usb_device *udev = data->udev;
  806. /* New sniffer firmware has crippled HCI interface */
  807. if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
  808. set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
  809. data->isoc = NULL;
  810. }
  811. if (id->driver_info & BTUSB_BCM92035) {
  812. unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
  813. struct sk_buff *skb;
  814. skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
  815. if (skb) {
  816. memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
  817. skb_queue_tail(&hdev->driver_init, skb);
  818. }
  819. }
  820. if (data->isoc) {
  821. err = usb_driver_claim_interface(&btusb_driver,
  822. data->isoc, data);
  823. if (err < 0) {
  824. hci_free_dev(hdev);
  825. return err;
  826. }
  827. }
  828. err = hci_register_dev(hdev);
  829. if (err < 0) {
  830. hci_free_dev(hdev);
  831. return err;
  832. }
  833. usb_set_intfdata(intf, data);
  834. return 0;
  835. }
  836. static void btusb_disconnect(struct usb_interface *intf)
  837. {
  838. struct btusb_data *data = usb_get_intfdata(intf);
  839. struct hci_dev *hdev;
  840. BT_DBG("intf %p", intf);
  841. if (!data)
  842. return;
  843. hdev = data->hdev;
  844. usb_set_intfdata(data->intf, NULL);
  845. if (data->isoc)
  846. usb_set_intfdata(data->isoc, NULL);
  847. hci_unregister_dev(hdev);
  848. if (intf == data->isoc)
  849. usb_driver_release_interface(&btusb_driver, data->intf);
  850. else if (data->isoc)
  851. usb_driver_release_interface(&btusb_driver, data->isoc);
  852. hci_free_dev(hdev);
  853. }
  854. #ifdef CONFIG_PM
  855. static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
  856. {
  857. struct btusb_data *data = usb_get_intfdata(intf);
  858. BT_DBG("intf %p", intf);
  859. if (data->suspend_count++)
  860. return 0;
  861. spin_lock_irq(&data->txlock);
  862. if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
  863. set_bit(BTUSB_SUSPENDING, &data->flags);
  864. spin_unlock_irq(&data->txlock);
  865. } else {
  866. spin_unlock_irq(&data->txlock);
  867. data->suspend_count--;
  868. return -EBUSY;
  869. }
  870. cancel_work_sync(&data->work);
  871. btusb_stop_traffic(data);
  872. usb_kill_anchored_urbs(&data->tx_anchor);
  873. return 0;
  874. }
  875. static void play_deferred(struct btusb_data *data)
  876. {
  877. struct urb *urb;
  878. int err;
  879. while ((urb = usb_get_from_anchor(&data->deferred))) {
  880. err = usb_submit_urb(urb, GFP_ATOMIC);
  881. if (err < 0)
  882. break;
  883. data->tx_in_flight++;
  884. }
  885. usb_scuttle_anchored_urbs(&data->deferred);
  886. }
  887. static int btusb_resume(struct usb_interface *intf)
  888. {
  889. struct btusb_data *data = usb_get_intfdata(intf);
  890. struct hci_dev *hdev = data->hdev;
  891. int err = 0;
  892. BT_DBG("intf %p", intf);
  893. if (--data->suspend_count)
  894. return 0;
  895. if (!test_bit(HCI_RUNNING, &hdev->flags))
  896. goto done;
  897. if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) {
  898. err = btusb_submit_intr_urb(hdev, GFP_NOIO);
  899. if (err < 0) {
  900. clear_bit(BTUSB_INTR_RUNNING, &data->flags);
  901. goto failed;
  902. }
  903. }
  904. if (test_bit(BTUSB_BULK_RUNNING, &data->flags)) {
  905. err = btusb_submit_bulk_urb(hdev, GFP_NOIO);
  906. if (err < 0) {
  907. clear_bit(BTUSB_BULK_RUNNING, &data->flags);
  908. goto failed;
  909. }
  910. btusb_submit_bulk_urb(hdev, GFP_NOIO);
  911. }
  912. if (test_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
  913. if (btusb_submit_isoc_urb(hdev, GFP_NOIO) < 0)
  914. clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
  915. else
  916. btusb_submit_isoc_urb(hdev, GFP_NOIO);
  917. }
  918. spin_lock_irq(&data->txlock);
  919. play_deferred(data);
  920. clear_bit(BTUSB_SUSPENDING, &data->flags);
  921. spin_unlock_irq(&data->txlock);
  922. schedule_work(&data->work);
  923. return 0;
  924. failed:
  925. usb_scuttle_anchored_urbs(&data->deferred);
  926. done:
  927. spin_lock_irq(&data->txlock);
  928. clear_bit(BTUSB_SUSPENDING, &data->flags);
  929. spin_unlock_irq(&data->txlock);
  930. return err;
  931. }
  932. #endif
  933. static struct usb_driver btusb_driver = {
  934. .name = "btusb",
  935. .probe = btusb_probe,
  936. .disconnect = btusb_disconnect,
  937. #ifdef CONFIG_PM
  938. .suspend = btusb_suspend,
  939. .resume = btusb_resume,
  940. #endif
  941. .id_table = btusb_table,
  942. .supports_autosuspend = 1,
  943. .disable_hub_initiated_lpm = 1,
  944. };
  945. module_usb_driver(btusb_driver);
  946. module_param(ignore_dga, bool, 0644);
  947. MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
  948. module_param(ignore_csr, bool, 0644);
  949. MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
  950. module_param(ignore_sniffer, bool, 0644);
  951. MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002");
  952. module_param(disable_scofix, bool, 0644);
  953. MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
  954. module_param(force_scofix, bool, 0644);
  955. MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");
  956. module_param(reset, bool, 0644);
  957. MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
  958. MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
  959. MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
  960. MODULE_VERSION(VERSION);
  961. MODULE_LICENSE("GPL");