btusb.c 30 KB

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