Bluetooth: ath3k: Add support for a new AR3012 device
[pandora-kernel.git] / drivers / bluetooth / btusb.c
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
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/init.h>
27 #include <linux/slab.h>
28 #include <linux/types.h>
29 #include <linux/sched.h>
30 #include <linux/errno.h>
31 #include <linux/skbuff.h>
32
33 #include <linux/usb.h>
34
35 #include <net/bluetooth/bluetooth.h>
36 #include <net/bluetooth/hci_core.h>
37
38 #define VERSION "0.6"
39
40 static int ignore_dga;
41 static int ignore_csr;
42 static int ignore_sniffer;
43 static int disable_scofix;
44 static int force_scofix;
45
46 static int reset = 1;
47
48 static struct usb_driver btusb_driver;
49
50 #define BTUSB_IGNORE            0x01
51 #define BTUSB_DIGIANSWER        0x02
52 #define BTUSB_CSR               0x04
53 #define BTUSB_SNIFFER           0x08
54 #define BTUSB_BCM92035          0x10
55 #define BTUSB_BROKEN_ISOC       0x20
56 #define BTUSB_WRONG_SCO_MTU     0x40
57 #define BTUSB_ATH3012           0x80
58
59 static struct usb_device_id btusb_table[] = {
60         /* Generic Bluetooth USB device */
61         { USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
62
63         /* Apple-specific (Broadcom) devices */
64         { USB_VENDOR_AND_INTERFACE_INFO(0x05ac, 0xff, 0x01, 0x01) },
65
66         /* MediaTek MT76x0E */
67         { USB_DEVICE(0x0e8d, 0x763f) },
68
69         /* Broadcom SoftSailing reporting vendor specific */
70         { USB_DEVICE(0x0a5c, 0x21e1) },
71
72         /* Apple MacBookPro 7,1 */
73         { USB_DEVICE(0x05ac, 0x8213) },
74
75         /* Apple iMac11,1 */
76         { USB_DEVICE(0x05ac, 0x8215) },
77
78         /* Apple MacBookPro6,2 */
79         { USB_DEVICE(0x05ac, 0x8218) },
80
81         /* Apple MacBookAir3,1, MacBookAir3,2 */
82         { USB_DEVICE(0x05ac, 0x821b) },
83
84         /* Apple MacBookAir4,1 */
85         { USB_DEVICE(0x05ac, 0x821f) },
86
87         /* Apple MacBookPro8,2 */
88         { USB_DEVICE(0x05ac, 0x821a) },
89
90         /* Apple MacMini5,1 */
91         { USB_DEVICE(0x05ac, 0x8281) },
92
93         /* AVM BlueFRITZ! USB v2.0 */
94         { USB_DEVICE(0x057c, 0x3800) },
95
96         /* Bluetooth Ultraport Module from IBM */
97         { USB_DEVICE(0x04bf, 0x030a) },
98
99         /* ALPS Modules with non-standard id */
100         { USB_DEVICE(0x044e, 0x3001) },
101         { USB_DEVICE(0x044e, 0x3002) },
102
103         /* Ericsson with non-standard id */
104         { USB_DEVICE(0x0bdb, 0x1002) },
105
106         /* Canyon CN-BTU1 with HID interfaces */
107         { USB_DEVICE(0x0c10, 0x0000) },
108
109         /* Broadcom BCM20702A0 */
110         { USB_DEVICE(0x0b05, 0x17b5) },
111         { USB_DEVICE(0x0b05, 0x17cb) },
112         { USB_DEVICE(0x04ca, 0x2003) },
113         { USB_DEVICE(0x0489, 0xe042) },
114         { USB_DEVICE(0x413c, 0x8197) },
115
116         /* Foxconn - Hon Hai */
117         { USB_VENDOR_AND_INTERFACE_INFO(0x0489, 0xff, 0x01, 0x01) },
118
119         /*Broadcom devices with vendor specific id */
120         { USB_VENDOR_AND_INTERFACE_INFO(0x0a5c, 0xff, 0x01, 0x01) },
121
122         /* Belkin F8065bf - Broadcom based */
123         { USB_VENDOR_AND_INTERFACE_INFO(0x050d, 0xff, 0x01, 0x01) },
124
125         { }     /* Terminating entry */
126 };
127
128 MODULE_DEVICE_TABLE(usb, btusb_table);
129
130 static struct usb_device_id blacklist_table[] = {
131         /* CSR BlueCore devices */
132         { USB_DEVICE(0x0a12, 0x0001), .driver_info = BTUSB_CSR },
133
134         /* Broadcom BCM2033 without firmware */
135         { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE },
136
137         /* Atheros 3011 with sflash firmware */
138         { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
139         { USB_DEVICE(0x0cf3, 0xe019), .driver_info = BTUSB_IGNORE },
140         { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
141         { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
142         { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
143         { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
144
145         /* Atheros AR9285 Malbec with sflash firmware */
146         { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
147
148         /* Atheros 3012 with sflash firmware */
149         { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 },
150         { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
151         { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 },
152         { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
153         { USB_DEVICE(0x0cf3, 0x817a), .driver_info = BTUSB_ATH3012 },
154         { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
155         { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
156         { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
157         { USB_DEVICE(0x04ca, 0x3006), .driver_info = BTUSB_ATH3012 },
158         { USB_DEVICE(0x04ca, 0x3007), .driver_info = BTUSB_ATH3012 },
159         { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
160         { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
161         { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
162         { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
163         { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
164         { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
165         { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
166         { USB_DEVICE(0x0489, 0xe04e), .driver_info = BTUSB_ATH3012 },
167         { USB_DEVICE(0x0489, 0xe056), .driver_info = BTUSB_ATH3012 },
168         { USB_DEVICE(0x0489, 0xe04d), .driver_info = BTUSB_ATH3012 },
169         { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 },
170         { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 },
171         { USB_DEVICE(0x0cf3, 0x3121), .driver_info = BTUSB_ATH3012 },
172         { USB_DEVICE(0x0cf3, 0xe003), .driver_info = BTUSB_ATH3012 },
173         { USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 },
174
175         /* Atheros AR5BBU12 with sflash firmware */
176         { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
177
178         /* Atheros AR5BBU12 with sflash firmware */
179         { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
180         { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
181
182         /* Broadcom BCM2035 */
183         { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
184         { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
185         { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
186
187         /* Broadcom BCM2045 */
188         { USB_DEVICE(0x0a5c, 0x2039), .driver_info = BTUSB_WRONG_SCO_MTU },
189         { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_WRONG_SCO_MTU },
190
191         /* IBM/Lenovo ThinkPad with Broadcom chip */
192         { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_WRONG_SCO_MTU },
193         { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_WRONG_SCO_MTU },
194
195         /* HP laptop with Broadcom chip */
196         { USB_DEVICE(0x03f0, 0x171d), .driver_info = BTUSB_WRONG_SCO_MTU },
197
198         /* Dell laptop with Broadcom chip */
199         { USB_DEVICE(0x413c, 0x8126), .driver_info = BTUSB_WRONG_SCO_MTU },
200
201         /* Dell Wireless 370 and 410 devices */
202         { USB_DEVICE(0x413c, 0x8152), .driver_info = BTUSB_WRONG_SCO_MTU },
203         { USB_DEVICE(0x413c, 0x8156), .driver_info = BTUSB_WRONG_SCO_MTU },
204
205         /* Belkin F8T012 and F8T013 devices */
206         { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_WRONG_SCO_MTU },
207         { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_WRONG_SCO_MTU },
208
209         /* Asus WL-BTD202 device */
210         { USB_DEVICE(0x0b05, 0x1715), .driver_info = BTUSB_WRONG_SCO_MTU },
211
212         /* Kensington Bluetooth USB adapter */
213         { USB_DEVICE(0x047d, 0x105e), .driver_info = BTUSB_WRONG_SCO_MTU },
214
215         /* RTX Telecom based adapters with buggy SCO support */
216         { USB_DEVICE(0x0400, 0x0807), .driver_info = BTUSB_BROKEN_ISOC },
217         { USB_DEVICE(0x0400, 0x080a), .driver_info = BTUSB_BROKEN_ISOC },
218
219         /* CONWISE Technology based adapters with buggy SCO support */
220         { USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC },
221
222         /* Digianswer devices */
223         { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
224         { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
225
226         /* CSR BlueCore Bluetooth Sniffer */
227         { USB_DEVICE(0x0a12, 0x0002), .driver_info = BTUSB_SNIFFER },
228
229         /* Frontline ComProbe Bluetooth Sniffer */
230         { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER },
231
232         { }     /* Terminating entry */
233 };
234
235 #define BTUSB_MAX_ISOC_FRAMES   10
236
237 #define BTUSB_INTR_RUNNING      0
238 #define BTUSB_BULK_RUNNING      1
239 #define BTUSB_ISOC_RUNNING      2
240 #define BTUSB_SUSPENDING        3
241 #define BTUSB_DID_ISO_RESUME    4
242
243 struct btusb_data {
244         struct hci_dev       *hdev;
245         struct usb_device    *udev;
246         struct usb_interface *intf;
247         struct usb_interface *isoc;
248
249         spinlock_t lock;
250
251         unsigned long flags;
252
253         struct work_struct work;
254         struct work_struct waker;
255
256         struct usb_anchor tx_anchor;
257         struct usb_anchor intr_anchor;
258         struct usb_anchor bulk_anchor;
259         struct usb_anchor isoc_anchor;
260         struct usb_anchor deferred;
261         int tx_in_flight;
262         spinlock_t txlock;
263
264         struct usb_endpoint_descriptor *intr_ep;
265         struct usb_endpoint_descriptor *bulk_tx_ep;
266         struct usb_endpoint_descriptor *bulk_rx_ep;
267         struct usb_endpoint_descriptor *isoc_tx_ep;
268         struct usb_endpoint_descriptor *isoc_rx_ep;
269
270         __u8 cmdreq_type;
271
272         unsigned int sco_num;
273         int isoc_altsetting;
274         int suspend_count;
275 };
276
277 static int inc_tx(struct btusb_data *data)
278 {
279         unsigned long flags;
280         int rv;
281
282         spin_lock_irqsave(&data->txlock, flags);
283         rv = test_bit(BTUSB_SUSPENDING, &data->flags);
284         if (!rv)
285                 data->tx_in_flight++;
286         spin_unlock_irqrestore(&data->txlock, flags);
287
288         return rv;
289 }
290
291 static void btusb_intr_complete(struct urb *urb)
292 {
293         struct hci_dev *hdev = urb->context;
294         struct btusb_data *data = hdev->driver_data;
295         int err;
296
297         BT_DBG("%s urb %p status %d count %d", hdev->name,
298                                         urb, urb->status, urb->actual_length);
299
300         if (!test_bit(HCI_RUNNING, &hdev->flags))
301                 return;
302
303         if (urb->status == 0) {
304                 hdev->stat.byte_rx += urb->actual_length;
305
306                 if (hci_recv_fragment(hdev, HCI_EVENT_PKT,
307                                                 urb->transfer_buffer,
308                                                 urb->actual_length) < 0) {
309                         BT_ERR("%s corrupted event packet", hdev->name);
310                         hdev->stat.err_rx++;
311                 }
312         } else if (urb->status == -ENOENT) {
313                 /* Avoid suspend failed when usb_kill_urb */
314                 return;
315         }
316
317         if (!test_bit(BTUSB_INTR_RUNNING, &data->flags))
318                 return;
319
320         usb_mark_last_busy(data->udev);
321         usb_anchor_urb(urb, &data->intr_anchor);
322
323         err = usb_submit_urb(urb, GFP_ATOMIC);
324         if (err < 0) {
325                 /* -EPERM: urb is being killed;
326                  * -ENODEV: device got disconnected */
327                 if (err != -EPERM && err != -ENODEV)
328                         BT_ERR("%s urb %p failed to resubmit (%d)",
329                                                 hdev->name, urb, -err);
330                 usb_unanchor_urb(urb);
331         }
332 }
333
334 static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
335 {
336         struct btusb_data *data = hdev->driver_data;
337         struct urb *urb;
338         unsigned char *buf;
339         unsigned int pipe;
340         int err, size;
341
342         BT_DBG("%s", hdev->name);
343
344         if (!data->intr_ep)
345                 return -ENODEV;
346
347         urb = usb_alloc_urb(0, mem_flags);
348         if (!urb)
349                 return -ENOMEM;
350
351         size = le16_to_cpu(data->intr_ep->wMaxPacketSize);
352
353         buf = kmalloc(size, mem_flags);
354         if (!buf) {
355                 usb_free_urb(urb);
356                 return -ENOMEM;
357         }
358
359         pipe = usb_rcvintpipe(data->udev, data->intr_ep->bEndpointAddress);
360
361         usb_fill_int_urb(urb, data->udev, pipe, buf, size,
362                                                 btusb_intr_complete, hdev,
363                                                 data->intr_ep->bInterval);
364
365         urb->transfer_flags |= URB_FREE_BUFFER;
366
367         usb_anchor_urb(urb, &data->intr_anchor);
368
369         err = usb_submit_urb(urb, mem_flags);
370         if (err < 0) {
371                 BT_ERR("%s urb %p submission failed (%d)",
372                                                 hdev->name, urb, -err);
373                 usb_unanchor_urb(urb);
374         }
375
376         usb_free_urb(urb);
377
378         return err;
379 }
380
381 static void btusb_bulk_complete(struct urb *urb)
382 {
383         struct hci_dev *hdev = urb->context;
384         struct btusb_data *data = hdev->driver_data;
385         int err;
386
387         BT_DBG("%s urb %p status %d count %d", hdev->name,
388                                         urb, urb->status, urb->actual_length);
389
390         if (!test_bit(HCI_RUNNING, &hdev->flags))
391                 return;
392
393         if (urb->status == 0) {
394                 hdev->stat.byte_rx += urb->actual_length;
395
396                 if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT,
397                                                 urb->transfer_buffer,
398                                                 urb->actual_length) < 0) {
399                         BT_ERR("%s corrupted ACL packet", hdev->name);
400                         hdev->stat.err_rx++;
401                 }
402         } else if (urb->status == -ENOENT) {
403                 /* Avoid suspend failed when usb_kill_urb */
404                 return;
405         }
406
407         if (!test_bit(BTUSB_BULK_RUNNING, &data->flags))
408                 return;
409
410         usb_anchor_urb(urb, &data->bulk_anchor);
411         usb_mark_last_busy(data->udev);
412
413         err = usb_submit_urb(urb, GFP_ATOMIC);
414         if (err < 0) {
415                 /* -EPERM: urb is being killed;
416                  * -ENODEV: device got disconnected */
417                 if (err != -EPERM && err != -ENODEV)
418                         BT_ERR("%s urb %p failed to resubmit (%d)",
419                                                 hdev->name, urb, -err);
420                 usb_unanchor_urb(urb);
421         }
422 }
423
424 static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
425 {
426         struct btusb_data *data = hdev->driver_data;
427         struct urb *urb;
428         unsigned char *buf;
429         unsigned int pipe;
430         int err, size = HCI_MAX_FRAME_SIZE;
431
432         BT_DBG("%s", hdev->name);
433
434         if (!data->bulk_rx_ep)
435                 return -ENODEV;
436
437         urb = usb_alloc_urb(0, mem_flags);
438         if (!urb)
439                 return -ENOMEM;
440
441         buf = kmalloc(size, mem_flags);
442         if (!buf) {
443                 usb_free_urb(urb);
444                 return -ENOMEM;
445         }
446
447         pipe = usb_rcvbulkpipe(data->udev, data->bulk_rx_ep->bEndpointAddress);
448
449         usb_fill_bulk_urb(urb, data->udev, pipe,
450                                         buf, size, btusb_bulk_complete, hdev);
451
452         urb->transfer_flags |= URB_FREE_BUFFER;
453
454         usb_mark_last_busy(data->udev);
455         usb_anchor_urb(urb, &data->bulk_anchor);
456
457         err = usb_submit_urb(urb, mem_flags);
458         if (err < 0) {
459                 BT_ERR("%s urb %p submission failed (%d)",
460                                                 hdev->name, urb, -err);
461                 usb_unanchor_urb(urb);
462         }
463
464         usb_free_urb(urb);
465
466         return err;
467 }
468
469 static void btusb_isoc_complete(struct urb *urb)
470 {
471         struct hci_dev *hdev = urb->context;
472         struct btusb_data *data = hdev->driver_data;
473         int i, err;
474
475         BT_DBG("%s urb %p status %d count %d", hdev->name,
476                                         urb, urb->status, urb->actual_length);
477
478         if (!test_bit(HCI_RUNNING, &hdev->flags))
479                 return;
480
481         if (urb->status == 0) {
482                 for (i = 0; i < urb->number_of_packets; i++) {
483                         unsigned int offset = urb->iso_frame_desc[i].offset;
484                         unsigned int length = urb->iso_frame_desc[i].actual_length;
485
486                         if (urb->iso_frame_desc[i].status)
487                                 continue;
488
489                         hdev->stat.byte_rx += length;
490
491                         if (hci_recv_fragment(hdev, HCI_SCODATA_PKT,
492                                                 urb->transfer_buffer + offset,
493                                                                 length) < 0) {
494                                 BT_ERR("%s corrupted SCO packet", hdev->name);
495                                 hdev->stat.err_rx++;
496                         }
497                 }
498         } else if (urb->status == -ENOENT) {
499                 /* Avoid suspend failed when usb_kill_urb */
500                 return;
501         }
502
503         if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags))
504                 return;
505
506         usb_anchor_urb(urb, &data->isoc_anchor);
507
508         err = usb_submit_urb(urb, GFP_ATOMIC);
509         if (err < 0) {
510                 /* -EPERM: urb is being killed;
511                  * -ENODEV: device got disconnected */
512                 if (err != -EPERM && err != -ENODEV)
513                         BT_ERR("%s urb %p failed to resubmit (%d)",
514                                                 hdev->name, urb, -err);
515                 usb_unanchor_urb(urb);
516         }
517 }
518
519 static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
520 {
521         int i, offset = 0;
522
523         BT_DBG("len %d mtu %d", len, mtu);
524
525         for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu;
526                                         i++, offset += mtu, len -= mtu) {
527                 urb->iso_frame_desc[i].offset = offset;
528                 urb->iso_frame_desc[i].length = mtu;
529         }
530
531         if (len && i < BTUSB_MAX_ISOC_FRAMES) {
532                 urb->iso_frame_desc[i].offset = offset;
533                 urb->iso_frame_desc[i].length = len;
534                 i++;
535         }
536
537         urb->number_of_packets = i;
538 }
539
540 static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
541 {
542         struct btusb_data *data = hdev->driver_data;
543         struct urb *urb;
544         unsigned char *buf;
545         unsigned int pipe;
546         int err, size;
547
548         BT_DBG("%s", hdev->name);
549
550         if (!data->isoc_rx_ep)
551                 return -ENODEV;
552
553         urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, mem_flags);
554         if (!urb)
555                 return -ENOMEM;
556
557         size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) *
558                                                 BTUSB_MAX_ISOC_FRAMES;
559
560         buf = kmalloc(size, mem_flags);
561         if (!buf) {
562                 usb_free_urb(urb);
563                 return -ENOMEM;
564         }
565
566         pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress);
567
568         usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete,
569                                 hdev, data->isoc_rx_ep->bInterval);
570
571         urb->transfer_flags  = URB_FREE_BUFFER | URB_ISO_ASAP;
572
573         __fill_isoc_descriptor(urb, size,
574                         le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize));
575
576         usb_anchor_urb(urb, &data->isoc_anchor);
577
578         err = usb_submit_urb(urb, mem_flags);
579         if (err < 0) {
580                 BT_ERR("%s urb %p submission failed (%d)",
581                                                 hdev->name, urb, -err);
582                 usb_unanchor_urb(urb);
583         }
584
585         usb_free_urb(urb);
586
587         return err;
588 }
589
590 static void btusb_tx_complete(struct urb *urb)
591 {
592         struct sk_buff *skb = urb->context;
593         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
594         struct btusb_data *data = hdev->driver_data;
595
596         BT_DBG("%s urb %p status %d count %d", hdev->name,
597                                         urb, urb->status, urb->actual_length);
598
599         if (!test_bit(HCI_RUNNING, &hdev->flags))
600                 goto done;
601
602         if (!urb->status)
603                 hdev->stat.byte_tx += urb->transfer_buffer_length;
604         else
605                 hdev->stat.err_tx++;
606
607 done:
608         spin_lock(&data->txlock);
609         data->tx_in_flight--;
610         spin_unlock(&data->txlock);
611
612         kfree(urb->setup_packet);
613
614         kfree_skb(skb);
615 }
616
617 static void btusb_isoc_tx_complete(struct urb *urb)
618 {
619         struct sk_buff *skb = urb->context;
620         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
621
622         BT_DBG("%s urb %p status %d count %d", hdev->name,
623                                         urb, urb->status, urb->actual_length);
624
625         if (!test_bit(HCI_RUNNING, &hdev->flags))
626                 goto done;
627
628         if (!urb->status)
629                 hdev->stat.byte_tx += urb->transfer_buffer_length;
630         else
631                 hdev->stat.err_tx++;
632
633 done:
634         kfree(urb->setup_packet);
635
636         kfree_skb(skb);
637 }
638
639 static int btusb_open(struct hci_dev *hdev)
640 {
641         struct btusb_data *data = hdev->driver_data;
642         int err;
643
644         BT_DBG("%s", hdev->name);
645
646         err = usb_autopm_get_interface(data->intf);
647         if (err < 0)
648                 return err;
649
650         data->intf->needs_remote_wakeup = 1;
651
652         if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
653                 goto done;
654
655         if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags))
656                 goto done;
657
658         err = btusb_submit_intr_urb(hdev, GFP_KERNEL);
659         if (err < 0)
660                 goto failed;
661
662         err = btusb_submit_bulk_urb(hdev, GFP_KERNEL);
663         if (err < 0) {
664                 usb_kill_anchored_urbs(&data->intr_anchor);
665                 goto failed;
666         }
667
668         set_bit(BTUSB_BULK_RUNNING, &data->flags);
669         btusb_submit_bulk_urb(hdev, GFP_KERNEL);
670
671 done:
672         usb_autopm_put_interface(data->intf);
673         return 0;
674
675 failed:
676         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
677         clear_bit(HCI_RUNNING, &hdev->flags);
678         usb_autopm_put_interface(data->intf);
679         return err;
680 }
681
682 static void btusb_stop_traffic(struct btusb_data *data)
683 {
684         usb_kill_anchored_urbs(&data->intr_anchor);
685         usb_kill_anchored_urbs(&data->bulk_anchor);
686         usb_kill_anchored_urbs(&data->isoc_anchor);
687 }
688
689 static int btusb_close(struct hci_dev *hdev)
690 {
691         struct btusb_data *data = hdev->driver_data;
692         int err;
693
694         BT_DBG("%s", hdev->name);
695
696         if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
697                 return 0;
698
699         cancel_work_sync(&data->work);
700         cancel_work_sync(&data->waker);
701
702         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
703         clear_bit(BTUSB_BULK_RUNNING, &data->flags);
704         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
705
706         btusb_stop_traffic(data);
707         err = usb_autopm_get_interface(data->intf);
708         if (err < 0)
709                 goto failed;
710
711         data->intf->needs_remote_wakeup = 0;
712         usb_autopm_put_interface(data->intf);
713
714 failed:
715         usb_scuttle_anchored_urbs(&data->deferred);
716         return 0;
717 }
718
719 static int btusb_flush(struct hci_dev *hdev)
720 {
721         struct btusb_data *data = hdev->driver_data;
722
723         BT_DBG("%s", hdev->name);
724
725         usb_kill_anchored_urbs(&data->tx_anchor);
726
727         return 0;
728 }
729
730 static int btusb_send_frame(struct sk_buff *skb)
731 {
732         struct hci_dev *hdev = (struct hci_dev *) skb->dev;
733         struct btusb_data *data = hdev->driver_data;
734         struct usb_ctrlrequest *dr;
735         struct urb *urb;
736         unsigned int pipe;
737         int err;
738
739         BT_DBG("%s", hdev->name);
740
741         if (!test_bit(HCI_RUNNING, &hdev->flags))
742                 return -EBUSY;
743
744         switch (bt_cb(skb)->pkt_type) {
745         case HCI_COMMAND_PKT:
746                 urb = usb_alloc_urb(0, GFP_ATOMIC);
747                 if (!urb)
748                         return -ENOMEM;
749
750                 dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
751                 if (!dr) {
752                         usb_free_urb(urb);
753                         return -ENOMEM;
754                 }
755
756                 dr->bRequestType = data->cmdreq_type;
757                 dr->bRequest     = 0;
758                 dr->wIndex       = 0;
759                 dr->wValue       = 0;
760                 dr->wLength      = __cpu_to_le16(skb->len);
761
762                 pipe = usb_sndctrlpipe(data->udev, 0x00);
763
764                 usb_fill_control_urb(urb, data->udev, pipe, (void *) dr,
765                                 skb->data, skb->len, btusb_tx_complete, skb);
766
767                 hdev->stat.cmd_tx++;
768                 break;
769
770         case HCI_ACLDATA_PKT:
771                 if (!data->bulk_tx_ep)
772                         return -ENODEV;
773
774                 urb = usb_alloc_urb(0, GFP_ATOMIC);
775                 if (!urb)
776                         return -ENOMEM;
777
778                 pipe = usb_sndbulkpipe(data->udev,
779                                         data->bulk_tx_ep->bEndpointAddress);
780
781                 usb_fill_bulk_urb(urb, data->udev, pipe,
782                                 skb->data, skb->len, btusb_tx_complete, skb);
783
784                 hdev->stat.acl_tx++;
785                 break;
786
787         case HCI_SCODATA_PKT:
788                 if (!data->isoc_tx_ep || hdev->conn_hash.sco_num < 1)
789                         return -ENODEV;
790
791                 urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_ATOMIC);
792                 if (!urb)
793                         return -ENOMEM;
794
795                 pipe = usb_sndisocpipe(data->udev,
796                                         data->isoc_tx_ep->bEndpointAddress);
797
798                 usb_fill_int_urb(urb, data->udev, pipe,
799                                 skb->data, skb->len, btusb_isoc_tx_complete,
800                                 skb, data->isoc_tx_ep->bInterval);
801
802                 urb->transfer_flags  = URB_ISO_ASAP;
803
804                 __fill_isoc_descriptor(urb, skb->len,
805                                 le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize));
806
807                 hdev->stat.sco_tx++;
808                 goto skip_waking;
809
810         default:
811                 return -EILSEQ;
812         }
813
814         err = inc_tx(data);
815         if (err) {
816                 usb_anchor_urb(urb, &data->deferred);
817                 schedule_work(&data->waker);
818                 err = 0;
819                 goto done;
820         }
821
822 skip_waking:
823         usb_anchor_urb(urb, &data->tx_anchor);
824
825         err = usb_submit_urb(urb, GFP_ATOMIC);
826         if (err < 0) {
827                 BT_ERR("%s urb %p submission failed", hdev->name, urb);
828                 kfree(urb->setup_packet);
829                 usb_unanchor_urb(urb);
830         } else {
831                 usb_mark_last_busy(data->udev);
832         }
833
834 done:
835         usb_free_urb(urb);
836         return err;
837 }
838
839 static void btusb_destruct(struct hci_dev *hdev)
840 {
841         struct btusb_data *data = hdev->driver_data;
842
843         BT_DBG("%s", hdev->name);
844
845         kfree(data);
846 }
847
848 static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
849 {
850         struct btusb_data *data = hdev->driver_data;
851
852         BT_DBG("%s evt %d", hdev->name, evt);
853
854         if (hdev->conn_hash.sco_num != data->sco_num) {
855                 data->sco_num = hdev->conn_hash.sco_num;
856                 schedule_work(&data->work);
857         }
858 }
859
860 static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
861 {
862         struct btusb_data *data = hdev->driver_data;
863         struct usb_interface *intf = data->isoc;
864         struct usb_endpoint_descriptor *ep_desc;
865         int i, err;
866
867         if (!data->isoc)
868                 return -ENODEV;
869
870         err = usb_set_interface(data->udev, 1, altsetting);
871         if (err < 0) {
872                 BT_ERR("%s setting interface failed (%d)", hdev->name, -err);
873                 return err;
874         }
875
876         data->isoc_altsetting = altsetting;
877
878         data->isoc_tx_ep = NULL;
879         data->isoc_rx_ep = NULL;
880
881         for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
882                 ep_desc = &intf->cur_altsetting->endpoint[i].desc;
883
884                 if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) {
885                         data->isoc_tx_ep = ep_desc;
886                         continue;
887                 }
888
889                 if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) {
890                         data->isoc_rx_ep = ep_desc;
891                         continue;
892                 }
893         }
894
895         if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
896                 BT_ERR("%s invalid SCO descriptors", hdev->name);
897                 return -ENODEV;
898         }
899
900         return 0;
901 }
902
903 static void btusb_work(struct work_struct *work)
904 {
905         struct btusb_data *data = container_of(work, struct btusb_data, work);
906         struct hci_dev *hdev = data->hdev;
907         int err;
908
909         if (hdev->conn_hash.sco_num > 0) {
910                 if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) {
911                         err = usb_autopm_get_interface(data->isoc ? data->isoc : data->intf);
912                         if (err < 0) {
913                                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
914                                 usb_kill_anchored_urbs(&data->isoc_anchor);
915                                 return;
916                         }
917
918                         set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
919                 }
920                 if (data->isoc_altsetting != 2) {
921                         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
922                         usb_kill_anchored_urbs(&data->isoc_anchor);
923
924                         if (__set_isoc_interface(hdev, 2) < 0)
925                                 return;
926                 }
927
928                 if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
929                         if (btusb_submit_isoc_urb(hdev, GFP_KERNEL) < 0)
930                                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
931                         else
932                                 btusb_submit_isoc_urb(hdev, GFP_KERNEL);
933                 }
934         } else {
935                 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
936                 usb_kill_anchored_urbs(&data->isoc_anchor);
937
938                 __set_isoc_interface(hdev, 0);
939                 if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags))
940                         usb_autopm_put_interface(data->isoc ? data->isoc : data->intf);
941         }
942 }
943
944 static void btusb_waker(struct work_struct *work)
945 {
946         struct btusb_data *data = container_of(work, struct btusb_data, waker);
947         int err;
948
949         err = usb_autopm_get_interface(data->intf);
950         if (err < 0)
951                 return;
952
953         usb_autopm_put_interface(data->intf);
954 }
955
956 static int btusb_probe(struct usb_interface *intf,
957                                 const struct usb_device_id *id)
958 {
959         struct usb_endpoint_descriptor *ep_desc;
960         struct btusb_data *data;
961         struct hci_dev *hdev;
962         int i, err;
963
964         BT_DBG("intf %p id %p", intf, id);
965
966         /* interface numbers are hardcoded in the spec */
967         if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
968                 return -ENODEV;
969
970         if (!id->driver_info) {
971                 const struct usb_device_id *match;
972                 match = usb_match_id(intf, blacklist_table);
973                 if (match)
974                         id = match;
975         }
976
977         if (id->driver_info == BTUSB_IGNORE)
978                 return -ENODEV;
979
980         if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER)
981                 return -ENODEV;
982
983         if (ignore_csr && id->driver_info & BTUSB_CSR)
984                 return -ENODEV;
985
986         if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER)
987                 return -ENODEV;
988
989         if (id->driver_info & BTUSB_ATH3012) {
990                 struct usb_device *udev = interface_to_usbdev(intf);
991
992                 /* Old firmware would otherwise let ath3k driver load
993                  * patch and sysconfig files */
994                 if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001)
995                         return -ENODEV;
996         }
997
998         data = kzalloc(sizeof(*data), GFP_KERNEL);
999         if (!data)
1000                 return -ENOMEM;
1001
1002         for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
1003                 ep_desc = &intf->cur_altsetting->endpoint[i].desc;
1004
1005                 if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) {
1006                         data->intr_ep = ep_desc;
1007                         continue;
1008                 }
1009
1010                 if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) {
1011                         data->bulk_tx_ep = ep_desc;
1012                         continue;
1013                 }
1014
1015                 if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) {
1016                         data->bulk_rx_ep = ep_desc;
1017                         continue;
1018                 }
1019         }
1020
1021         if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) {
1022                 kfree(data);
1023                 return -ENODEV;
1024         }
1025
1026         data->cmdreq_type = USB_TYPE_CLASS;
1027
1028         data->udev = interface_to_usbdev(intf);
1029         data->intf = intf;
1030
1031         spin_lock_init(&data->lock);
1032
1033         INIT_WORK(&data->work, btusb_work);
1034         INIT_WORK(&data->waker, btusb_waker);
1035         spin_lock_init(&data->txlock);
1036
1037         init_usb_anchor(&data->tx_anchor);
1038         init_usb_anchor(&data->intr_anchor);
1039         init_usb_anchor(&data->bulk_anchor);
1040         init_usb_anchor(&data->isoc_anchor);
1041         init_usb_anchor(&data->deferred);
1042
1043         hdev = hci_alloc_dev();
1044         if (!hdev) {
1045                 kfree(data);
1046                 return -ENOMEM;
1047         }
1048
1049         hdev->bus = HCI_USB;
1050         hdev->driver_data = data;
1051
1052         data->hdev = hdev;
1053
1054         SET_HCIDEV_DEV(hdev, &intf->dev);
1055
1056         hdev->open     = btusb_open;
1057         hdev->close    = btusb_close;
1058         hdev->flush    = btusb_flush;
1059         hdev->send     = btusb_send_frame;
1060         hdev->destruct = btusb_destruct;
1061         hdev->notify   = btusb_notify;
1062
1063         hdev->owner = THIS_MODULE;
1064
1065         /* Interface numbers are hardcoded in the specification */
1066         data->isoc = usb_ifnum_to_if(data->udev, 1);
1067
1068         if (!reset)
1069                 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1070
1071         if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) {
1072                 if (!disable_scofix)
1073                         set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
1074         }
1075
1076         if (id->driver_info & BTUSB_BROKEN_ISOC)
1077                 data->isoc = NULL;
1078
1079         if (id->driver_info & BTUSB_DIGIANSWER) {
1080                 data->cmdreq_type = USB_TYPE_VENDOR;
1081                 set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1082         }
1083
1084         if (id->driver_info & BTUSB_CSR) {
1085                 struct usb_device *udev = data->udev;
1086
1087                 /* Old firmware would otherwise execute USB reset */
1088                 if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
1089                         set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
1090         }
1091
1092         if (id->driver_info & BTUSB_SNIFFER) {
1093                 struct usb_device *udev = data->udev;
1094
1095                 /* New sniffer firmware has crippled HCI interface */
1096                 if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
1097                         set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
1098
1099                 data->isoc = NULL;
1100         }
1101
1102         if (id->driver_info & BTUSB_BCM92035) {
1103                 unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
1104                 struct sk_buff *skb;
1105
1106                 skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
1107                 if (skb) {
1108                         memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
1109                         skb_queue_tail(&hdev->driver_init, skb);
1110                 }
1111         }
1112
1113         if (data->isoc) {
1114                 err = usb_driver_claim_interface(&btusb_driver,
1115                                                         data->isoc, data);
1116                 if (err < 0) {
1117                         hci_free_dev(hdev);
1118                         kfree(data);
1119                         return err;
1120                 }
1121         }
1122
1123         err = hci_register_dev(hdev);
1124         if (err < 0) {
1125                 hci_free_dev(hdev);
1126                 kfree(data);
1127                 return err;
1128         }
1129
1130         usb_set_intfdata(intf, data);
1131
1132         return 0;
1133 }
1134
1135 static void btusb_disconnect(struct usb_interface *intf)
1136 {
1137         struct btusb_data *data = usb_get_intfdata(intf);
1138         struct hci_dev *hdev;
1139
1140         BT_DBG("intf %p", intf);
1141
1142         if (!data)
1143                 return;
1144
1145         hdev = data->hdev;
1146
1147         __hci_dev_hold(hdev);
1148
1149         usb_set_intfdata(data->intf, NULL);
1150
1151         if (data->isoc)
1152                 usb_set_intfdata(data->isoc, NULL);
1153
1154         hci_unregister_dev(hdev);
1155
1156         if (intf == data->isoc)
1157                 usb_driver_release_interface(&btusb_driver, data->intf);
1158         else if (data->isoc)
1159                 usb_driver_release_interface(&btusb_driver, data->isoc);
1160
1161         __hci_dev_put(hdev);
1162
1163         hci_free_dev(hdev);
1164 }
1165
1166 #ifdef CONFIG_PM
1167 static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
1168 {
1169         struct btusb_data *data = usb_get_intfdata(intf);
1170
1171         BT_DBG("intf %p", intf);
1172
1173         if (data->suspend_count++)
1174                 return 0;
1175
1176         spin_lock_irq(&data->txlock);
1177         if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
1178                 set_bit(BTUSB_SUSPENDING, &data->flags);
1179                 spin_unlock_irq(&data->txlock);
1180         } else {
1181                 spin_unlock_irq(&data->txlock);
1182                 data->suspend_count--;
1183                 return -EBUSY;
1184         }
1185
1186         cancel_work_sync(&data->work);
1187
1188         btusb_stop_traffic(data);
1189         usb_kill_anchored_urbs(&data->tx_anchor);
1190
1191         return 0;
1192 }
1193
1194 static void play_deferred(struct btusb_data *data)
1195 {
1196         struct urb *urb;
1197         int err;
1198
1199         while ((urb = usb_get_from_anchor(&data->deferred))) {
1200                 err = usb_submit_urb(urb, GFP_ATOMIC);
1201                 if (err < 0)
1202                         break;
1203
1204                 data->tx_in_flight++;
1205         }
1206         usb_scuttle_anchored_urbs(&data->deferred);
1207 }
1208
1209 static int btusb_resume(struct usb_interface *intf)
1210 {
1211         struct btusb_data *data = usb_get_intfdata(intf);
1212         struct hci_dev *hdev = data->hdev;
1213         int err = 0;
1214
1215         BT_DBG("intf %p", intf);
1216
1217         if (--data->suspend_count)
1218                 return 0;
1219
1220         if (!test_bit(HCI_RUNNING, &hdev->flags))
1221                 goto done;
1222
1223         if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) {
1224                 err = btusb_submit_intr_urb(hdev, GFP_NOIO);
1225                 if (err < 0) {
1226                         clear_bit(BTUSB_INTR_RUNNING, &data->flags);
1227                         goto failed;
1228                 }
1229         }
1230
1231         if (test_bit(BTUSB_BULK_RUNNING, &data->flags)) {
1232                 err = btusb_submit_bulk_urb(hdev, GFP_NOIO);
1233                 if (err < 0) {
1234                         clear_bit(BTUSB_BULK_RUNNING, &data->flags);
1235                         goto failed;
1236                 }
1237
1238                 btusb_submit_bulk_urb(hdev, GFP_NOIO);
1239         }
1240
1241         if (test_bit(BTUSB_ISOC_RUNNING, &data->flags)) {
1242                 if (btusb_submit_isoc_urb(hdev, GFP_NOIO) < 0)
1243                         clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
1244                 else
1245                         btusb_submit_isoc_urb(hdev, GFP_NOIO);
1246         }
1247
1248         spin_lock_irq(&data->txlock);
1249         play_deferred(data);
1250         clear_bit(BTUSB_SUSPENDING, &data->flags);
1251         spin_unlock_irq(&data->txlock);
1252         schedule_work(&data->work);
1253
1254         return 0;
1255
1256 failed:
1257         usb_scuttle_anchored_urbs(&data->deferred);
1258 done:
1259         spin_lock_irq(&data->txlock);
1260         clear_bit(BTUSB_SUSPENDING, &data->flags);
1261         spin_unlock_irq(&data->txlock);
1262
1263         return err;
1264 }
1265 #endif
1266
1267 static struct usb_driver btusb_driver = {
1268         .name           = "btusb",
1269         .probe          = btusb_probe,
1270         .disconnect     = btusb_disconnect,
1271 #ifdef CONFIG_PM
1272         .suspend        = btusb_suspend,
1273         .resume         = btusb_resume,
1274 #endif
1275         .id_table       = btusb_table,
1276         .supports_autosuspend = 1,
1277 };
1278
1279 static int __init btusb_init(void)
1280 {
1281         BT_INFO("Generic Bluetooth USB driver ver %s", VERSION);
1282
1283         return usb_register(&btusb_driver);
1284 }
1285
1286 static void __exit btusb_exit(void)
1287 {
1288         usb_deregister(&btusb_driver);
1289 }
1290
1291 module_init(btusb_init);
1292 module_exit(btusb_exit);
1293
1294 module_param(ignore_dga, bool, 0644);
1295 MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
1296
1297 module_param(ignore_csr, bool, 0644);
1298 MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
1299
1300 module_param(ignore_sniffer, bool, 0644);
1301 MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002");
1302
1303 module_param(disable_scofix, bool, 0644);
1304 MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
1305
1306 module_param(force_scofix, bool, 0644);
1307 MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");
1308
1309 module_param(reset, bool, 0644);
1310 MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
1311
1312 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
1313 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
1314 MODULE_VERSION(VERSION);
1315 MODULE_LICENSE("GPL");