blob: 3133afa50e87681d4f66af7fc42c7b00c2a96d97 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 HCI USB driver for Linux Bluetooth protocol stack (BlueZ)
3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
5
6 Copyright (C) 2003 Maxim Krasnyansky <maxk@qualcomm.com>
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 version 2 as
10 published by the Free Software Foundation;
11
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
15 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
16 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
17 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20
21 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
22 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
23 SOFTWARE IS DISCLAIMED.
24*/
25
26/*
27 * Bluetooth HCI USB driver.
28 * Based on original USB Bluetooth driver for Linux kernel
29 * Copyright (c) 2000 Greg Kroah-Hartman <greg@kroah.com>
30 * Copyright (c) 2000 Mark Douglas Corner <mcorner@umich.edu>
31 *
32 */
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/module.h>
35
36#include <linux/kernel.h>
37#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <linux/unistd.h>
39#include <linux/types.h>
40#include <linux/interrupt.h>
41#include <linux/moduleparam.h>
42
43#include <linux/slab.h>
44#include <linux/errno.h>
45#include <linux/string.h>
46#include <linux/skbuff.h>
47
48#include <linux/usb.h>
49
50#include <net/bluetooth/bluetooth.h>
51#include <net/bluetooth/hci_core.h>
52
53#include "hci_usb.h"
54
55#ifndef CONFIG_BT_HCIUSB_DEBUG
56#undef BT_DBG
57#define BT_DBG(D...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#endif
59
60#ifndef CONFIG_BT_HCIUSB_ZERO_PACKET
61#undef URB_ZERO_PACKET
62#define URB_ZERO_PACKET 0
63#endif
64
65static int ignore = 0;
Marcel Holtmann7ef934b2005-11-08 09:57:05 -080066static int ignore_dga = 0;
Marcel Holtmann0915e882005-09-13 01:32:37 +020067static int ignore_csr = 0;
68static int ignore_sniffer = 0;
Marcel Holtmann520ca782006-07-14 16:01:52 +020069static int disable_scofix = 0;
70static int force_scofix = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071static int reset = 0;
72
73#ifdef CONFIG_BT_HCIUSB_SCO
74static int isoc = 2;
75#endif
76
Marcel Holtmann0915e882005-09-13 01:32:37 +020077#define VERSION "2.9"
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79static struct usb_driver hci_usb_driver;
80
81static struct usb_device_id bluetooth_ids[] = {
82 /* Generic Bluetooth USB device */
83 { USB_DEVICE_INFO(HCI_DEV_CLASS, HCI_DEV_SUBCLASS, HCI_DEV_PROTOCOL) },
84
85 /* AVM BlueFRITZ! USB v2.0 */
86 { USB_DEVICE(0x057c, 0x3800) },
87
88 /* Bluetooth Ultraport Module from IBM */
89 { USB_DEVICE(0x04bf, 0x030a) },
90
91 /* ALPS Modules with non-standard id */
92 { USB_DEVICE(0x044e, 0x3001) },
93 { USB_DEVICE(0x044e, 0x3002) },
94
95 /* Ericsson with non-standard id */
96 { USB_DEVICE(0x0bdb, 0x1002) },
97
Marcel Holtmann62ae1592006-09-21 16:19:55 +020098 /* Canyon CN-BTU1 with HID interfaces */
99 { USB_DEVICE(0x0c10, 0x0000), .driver_info = HCI_RESET },
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 { } /* Terminating entry */
102};
103
104MODULE_DEVICE_TABLE (usb, bluetooth_ids);
105
106static struct usb_device_id blacklist_ids[] = {
Marcel Holtmann0915e882005-09-13 01:32:37 +0200107 /* CSR BlueCore devices */
108 { USB_DEVICE(0x0a12, 0x0001), .driver_info = HCI_CSR },
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 /* Broadcom BCM2033 without firmware */
111 { USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE },
112
113 /* Broadcom BCM2035 */
Marcel Holtmanne9e92902006-07-18 18:32:33 +0200114 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 },
116
Marcel Holtmann520ca782006-07-14 16:01:52 +0200117 /* IBM/Lenovo ThinkPad with Broadcom chip */
118 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU },
Marcel Holtmann5939be42007-01-08 02:16:46 +0100119 { USB_DEVICE(0x0a5c, 0x2110), .driver_info = HCI_WRONG_SCO_MTU },
Marcel Holtmann520ca782006-07-14 16:01:52 +0200120
Marcel Holtmannc51bd3d2007-05-05 00:36:17 +0200121 /* Targus ACB10US */
122 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = HCI_RESET },
123
Marcel Holtmann0eab9342006-10-20 08:55:29 +0200124 /* ANYCOM Bluetooth USB-200 and USB-250 */
125 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = HCI_RESET },
126
Marcel Holtmannda942702007-01-08 02:16:50 +0100127 /* HP laptop with Broadcom chip */
128 { USB_DEVICE(0x03f0, 0x171d), .driver_info = HCI_WRONG_SCO_MTU },
129
Marcel Holtmann86112ff2007-01-08 02:16:53 +0100130 /* Dell laptop with Broadcom chip */
131 { USB_DEVICE(0x413c, 0x8126), .driver_info = HCI_WRONG_SCO_MTU },
132
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */
134 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET },
135
Marcel Holtmanncad0f622005-08-06 12:36:36 +0200136 /* Kensington Bluetooth USB adapter */
137 { USB_DEVICE(0x047d, 0x105d), .driver_info = HCI_RESET },
Olivier Galibert71c83512006-12-19 13:15:25 -0800138 { USB_DEVICE(0x047d, 0x105e), .driver_info = HCI_WRONG_SCO_MTU },
Marcel Holtmanncad0f622005-08-06 12:36:36 +0200139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 /* ISSC Bluetooth Adapter v3.1 */
141 { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET },
142
Marcel Holtmann8e4f7232006-07-18 18:04:59 +0200143 /* RTX Telecom based adapters with buggy SCO support */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 { USB_DEVICE(0x0400, 0x0807), .driver_info = HCI_BROKEN_ISOC },
Marcel Holtmann8e4f7232006-07-18 18:04:59 +0200145 { USB_DEVICE(0x0400, 0x080a), .driver_info = HCI_BROKEN_ISOC },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Marcel Holtmannea9727f2006-07-18 17:47:40 +0200147 /* Belkin F8T012 and F8T013 devices */
Marcel Holtmannda1f5192006-07-03 10:02:29 +0200148 { USB_DEVICE(0x050d, 0x0012), .driver_info = HCI_WRONG_SCO_MTU },
Marcel Holtmannea9727f2006-07-18 17:47:40 +0200149 { USB_DEVICE(0x050d, 0x0013), .driver_info = HCI_WRONG_SCO_MTU },
Marcel Holtmannda1f5192006-07-03 10:02:29 +0200150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 /* Digianswer devices */
152 { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER },
153 { USB_DEVICE(0x08fd, 0x0002), .driver_info = HCI_IGNORE },
154
155 /* CSR BlueCore Bluetooth Sniffer */
156 { USB_DEVICE(0x0a12, 0x0002), .driver_info = HCI_SNIFFER },
157
Marcel Holtmann2b86ad22006-07-03 10:02:18 +0200158 /* Frontline ComProbe Bluetooth Sniffer */
159 { USB_DEVICE(0x16d3, 0x0002), .driver_info = HCI_SNIFFER },
160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 { } /* Terminating entry */
162};
163
Al Virodd0fc662005-10-07 07:46:04 +0100164static struct _urb *_urb_alloc(int isoc, gfp_t gfp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165{
166 struct _urb *_urb = kmalloc(sizeof(struct _urb) +
167 sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
168 if (_urb) {
169 memset(_urb, 0, sizeof(*_urb));
170 usb_init_urb(&_urb->urb);
171 }
172 return _urb;
173}
174
175static struct _urb *_urb_dequeue(struct _urb_queue *q)
176{
177 struct _urb *_urb = NULL;
178 unsigned long flags;
179 spin_lock_irqsave(&q->lock, flags);
180 {
181 struct list_head *head = &q->head;
182 struct list_head *next = head->next;
183 if (next != head) {
184 _urb = list_entry(next, struct _urb, list);
185 list_del(next); _urb->queue = NULL;
186 }
187 }
188 spin_unlock_irqrestore(&q->lock, flags);
189 return _urb;
190}
191
David Howells7d12e782006-10-05 14:55:46 +0100192static void hci_usb_rx_complete(struct urb *urb);
193static void hci_usb_tx_complete(struct urb *urb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
195#define __pending_tx(husb, type) (&husb->pending_tx[type-1])
196#define __pending_q(husb, type) (&husb->pending_q[type-1])
197#define __completed_q(husb, type) (&husb->completed_q[type-1])
198#define __transmit_q(husb, type) (&husb->transmit_q[type-1])
199#define __reassembly(husb, type) (husb->reassembly[type-1])
200
201static inline struct _urb *__get_completed(struct hci_usb *husb, int type)
202{
203 return _urb_dequeue(__completed_q(husb, type));
204}
205
206#ifdef CONFIG_BT_HCIUSB_SCO
207static void __fill_isoc_desc(struct urb *urb, int len, int mtu)
208{
209 int offset = 0, i;
210
211 BT_DBG("len %d mtu %d", len, mtu);
212
213 for (i=0; i < HCI_MAX_ISOC_FRAMES && len >= mtu; i++, offset += mtu, len -= mtu) {
214 urb->iso_frame_desc[i].offset = offset;
215 urb->iso_frame_desc[i].length = mtu;
216 BT_DBG("desc %d offset %d len %d", i, offset, mtu);
217 }
218 if (len && i < HCI_MAX_ISOC_FRAMES) {
219 urb->iso_frame_desc[i].offset = offset;
220 urb->iso_frame_desc[i].length = len;
221 BT_DBG("desc %d offset %d len %d", i, offset, len);
222 i++;
223 }
224 urb->number_of_packets = i;
225}
226#endif
227
228static int hci_usb_intr_rx_submit(struct hci_usb *husb)
229{
230 struct _urb *_urb;
231 struct urb *urb;
232 int err, pipe, interval, size;
233 void *buf;
234
235 BT_DBG("%s", husb->hdev->name);
236
237 size = le16_to_cpu(husb->intr_in_ep->desc.wMaxPacketSize);
238
239 buf = kmalloc(size, GFP_ATOMIC);
240 if (!buf)
241 return -ENOMEM;
242
243 _urb = _urb_alloc(0, GFP_ATOMIC);
244 if (!_urb) {
245 kfree(buf);
246 return -ENOMEM;
247 }
248 _urb->type = HCI_EVENT_PKT;
249 _urb_queue_tail(__pending_q(husb, _urb->type), _urb);
250
251 urb = &_urb->urb;
252 pipe = usb_rcvintpipe(husb->udev, husb->intr_in_ep->desc.bEndpointAddress);
253 interval = husb->intr_in_ep->desc.bInterval;
254 usb_fill_int_urb(urb, husb->udev, pipe, buf, size, hci_usb_rx_complete, husb, interval);
255
256 err = usb_submit_urb(urb, GFP_ATOMIC);
257 if (err) {
258 BT_ERR("%s intr rx submit failed urb %p err %d",
259 husb->hdev->name, urb, err);
260 _urb_unlink(_urb);
261 _urb_free(_urb);
262 kfree(buf);
263 }
264 return err;
265}
266
267static int hci_usb_bulk_rx_submit(struct hci_usb *husb)
268{
269 struct _urb *_urb;
270 struct urb *urb;
271 int err, pipe, size = HCI_MAX_FRAME_SIZE;
272 void *buf;
273
274 buf = kmalloc(size, GFP_ATOMIC);
275 if (!buf)
276 return -ENOMEM;
277
278 _urb = _urb_alloc(0, GFP_ATOMIC);
279 if (!_urb) {
280 kfree(buf);
281 return -ENOMEM;
282 }
283 _urb->type = HCI_ACLDATA_PKT;
284 _urb_queue_tail(__pending_q(husb, _urb->type), _urb);
285
286 urb = &_urb->urb;
287 pipe = usb_rcvbulkpipe(husb->udev, husb->bulk_in_ep->desc.bEndpointAddress);
288 usb_fill_bulk_urb(urb, husb->udev, pipe, buf, size, hci_usb_rx_complete, husb);
289 urb->transfer_flags = 0;
290
291 BT_DBG("%s urb %p", husb->hdev->name, urb);
292
293 err = usb_submit_urb(urb, GFP_ATOMIC);
294 if (err) {
295 BT_ERR("%s bulk rx submit failed urb %p err %d",
296 husb->hdev->name, urb, err);
297 _urb_unlink(_urb);
298 _urb_free(_urb);
299 kfree(buf);
300 }
301 return err;
302}
303
304#ifdef CONFIG_BT_HCIUSB_SCO
305static int hci_usb_isoc_rx_submit(struct hci_usb *husb)
306{
307 struct _urb *_urb;
308 struct urb *urb;
309 int err, mtu, size;
310 void *buf;
311
312 mtu = le16_to_cpu(husb->isoc_in_ep->desc.wMaxPacketSize);
313 size = mtu * HCI_MAX_ISOC_FRAMES;
314
315 buf = kmalloc(size, GFP_ATOMIC);
316 if (!buf)
317 return -ENOMEM;
318
319 _urb = _urb_alloc(HCI_MAX_ISOC_FRAMES, GFP_ATOMIC);
320 if (!_urb) {
321 kfree(buf);
322 return -ENOMEM;
323 }
324 _urb->type = HCI_SCODATA_PKT;
325 _urb_queue_tail(__pending_q(husb, _urb->type), _urb);
326
327 urb = &_urb->urb;
328
329 urb->context = husb;
330 urb->dev = husb->udev;
331 urb->pipe = usb_rcvisocpipe(husb->udev, husb->isoc_in_ep->desc.bEndpointAddress);
332 urb->complete = hci_usb_rx_complete;
333
334 urb->interval = husb->isoc_in_ep->desc.bInterval;
335
336 urb->transfer_buffer_length = size;
337 urb->transfer_buffer = buf;
338 urb->transfer_flags = URB_ISO_ASAP;
339
340 __fill_isoc_desc(urb, size, mtu);
341
342 BT_DBG("%s urb %p", husb->hdev->name, urb);
343
344 err = usb_submit_urb(urb, GFP_ATOMIC);
345 if (err) {
346 BT_ERR("%s isoc rx submit failed urb %p err %d",
347 husb->hdev->name, urb, err);
348 _urb_unlink(_urb);
349 _urb_free(_urb);
350 kfree(buf);
351 }
352 return err;
353}
354#endif
355
356/* Initialize device */
357static int hci_usb_open(struct hci_dev *hdev)
358{
359 struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
360 int i, err;
361 unsigned long flags;
362
363 BT_DBG("%s", hdev->name);
364
365 if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
366 return 0;
367
368 write_lock_irqsave(&husb->completion_lock, flags);
369
370 err = hci_usb_intr_rx_submit(husb);
371 if (!err) {
372 for (i = 0; i < HCI_MAX_BULK_RX; i++)
373 hci_usb_bulk_rx_submit(husb);
374
375#ifdef CONFIG_BT_HCIUSB_SCO
376 if (husb->isoc_iface)
377 for (i = 0; i < HCI_MAX_ISOC_RX; i++)
378 hci_usb_isoc_rx_submit(husb);
379#endif
380 } else {
381 clear_bit(HCI_RUNNING, &hdev->flags);
382 }
383
384 write_unlock_irqrestore(&husb->completion_lock, flags);
385 return err;
386}
387
388/* Reset device */
389static int hci_usb_flush(struct hci_dev *hdev)
390{
391 struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
392 int i;
393
394 BT_DBG("%s", hdev->name);
395
396 for (i = 0; i < 4; i++)
397 skb_queue_purge(&husb->transmit_q[i]);
398 return 0;
399}
400
401static void hci_usb_unlink_urbs(struct hci_usb *husb)
402{
403 int i;
404
405 BT_DBG("%s", husb->hdev->name);
406
407 for (i = 0; i < 4; i++) {
408 struct _urb *_urb;
409 struct urb *urb;
410
411 /* Kill pending requests */
412 while ((_urb = _urb_dequeue(&husb->pending_q[i]))) {
413 urb = &_urb->urb;
414 BT_DBG("%s unlinking _urb %p type %d urb %p",
415 husb->hdev->name, _urb, _urb->type, urb);
416 usb_kill_urb(urb);
417 _urb_queue_tail(__completed_q(husb, _urb->type), _urb);
418 }
419
420 /* Release completed requests */
421 while ((_urb = _urb_dequeue(&husb->completed_q[i]))) {
422 urb = &_urb->urb;
423 BT_DBG("%s freeing _urb %p type %d urb %p",
424 husb->hdev->name, _urb, _urb->type, urb);
Marcel Holtmanne9a3e672005-08-06 12:36:47 +0200425 kfree(urb->setup_packet);
426 kfree(urb->transfer_buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 _urb_free(_urb);
428 }
429
430 /* Release reassembly buffers */
431 if (husb->reassembly[i]) {
432 kfree_skb(husb->reassembly[i]);
433 husb->reassembly[i] = NULL;
434 }
435 }
436}
437
438/* Close device */
439static int hci_usb_close(struct hci_dev *hdev)
440{
441 struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
442 unsigned long flags;
443
444 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
445 return 0;
446
447 BT_DBG("%s", hdev->name);
448
449 /* Synchronize with completion handlers */
450 write_lock_irqsave(&husb->completion_lock, flags);
451 write_unlock_irqrestore(&husb->completion_lock, flags);
452
453 hci_usb_unlink_urbs(husb);
454 hci_usb_flush(hdev);
455 return 0;
456}
457
458static int __tx_submit(struct hci_usb *husb, struct _urb *_urb)
459{
460 struct urb *urb = &_urb->urb;
461 int err;
462
463 BT_DBG("%s urb %p type %d", husb->hdev->name, urb, _urb->type);
464
465 _urb_queue_tail(__pending_q(husb, _urb->type), _urb);
466 err = usb_submit_urb(urb, GFP_ATOMIC);
467 if (err) {
468 BT_ERR("%s tx submit failed urb %p type %d err %d",
469 husb->hdev->name, urb, _urb->type, err);
470 _urb_unlink(_urb);
471 _urb_queue_tail(__completed_q(husb, _urb->type), _urb);
472 } else
473 atomic_inc(__pending_tx(husb, _urb->type));
474
475 return err;
476}
477
478static inline int hci_usb_send_ctrl(struct hci_usb *husb, struct sk_buff *skb)
479{
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700480 struct _urb *_urb = __get_completed(husb, bt_cb(skb)->pkt_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 struct usb_ctrlrequest *dr;
482 struct urb *urb;
483
484 if (!_urb) {
485 _urb = _urb_alloc(0, GFP_ATOMIC);
486 if (!_urb)
487 return -ENOMEM;
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700488 _urb->type = bt_cb(skb)->pkt_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
490 dr = kmalloc(sizeof(*dr), GFP_ATOMIC);
491 if (!dr) {
492 _urb_free(_urb);
493 return -ENOMEM;
494 }
495 } else
496 dr = (void *) _urb->urb.setup_packet;
497
498 dr->bRequestType = husb->ctrl_req;
499 dr->bRequest = 0;
500 dr->wIndex = 0;
501 dr->wValue = 0;
502 dr->wLength = __cpu_to_le16(skb->len);
503
504 urb = &_urb->urb;
505 usb_fill_control_urb(urb, husb->udev, usb_sndctrlpipe(husb->udev, 0),
506 (void *) dr, skb->data, skb->len, hci_usb_tx_complete, husb);
507
508 BT_DBG("%s skb %p len %d", husb->hdev->name, skb, skb->len);
509
510 _urb->priv = skb;
511 return __tx_submit(husb, _urb);
512}
513
514static inline int hci_usb_send_bulk(struct hci_usb *husb, struct sk_buff *skb)
515{
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700516 struct _urb *_urb = __get_completed(husb, bt_cb(skb)->pkt_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 struct urb *urb;
518 int pipe;
519
520 if (!_urb) {
521 _urb = _urb_alloc(0, GFP_ATOMIC);
522 if (!_urb)
523 return -ENOMEM;
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700524 _urb->type = bt_cb(skb)->pkt_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 }
526
527 urb = &_urb->urb;
528 pipe = usb_sndbulkpipe(husb->udev, husb->bulk_out_ep->desc.bEndpointAddress);
529 usb_fill_bulk_urb(urb, husb->udev, pipe, skb->data, skb->len,
530 hci_usb_tx_complete, husb);
531 urb->transfer_flags = URB_ZERO_PACKET;
532
533 BT_DBG("%s skb %p len %d", husb->hdev->name, skb, skb->len);
534
535 _urb->priv = skb;
536 return __tx_submit(husb, _urb);
537}
538
539#ifdef CONFIG_BT_HCIUSB_SCO
540static inline int hci_usb_send_isoc(struct hci_usb *husb, struct sk_buff *skb)
541{
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700542 struct _urb *_urb = __get_completed(husb, bt_cb(skb)->pkt_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 struct urb *urb;
544
545 if (!_urb) {
546 _urb = _urb_alloc(HCI_MAX_ISOC_FRAMES, GFP_ATOMIC);
547 if (!_urb)
548 return -ENOMEM;
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700549 _urb->type = bt_cb(skb)->pkt_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 }
551
552 BT_DBG("%s skb %p len %d", husb->hdev->name, skb, skb->len);
553
554 urb = &_urb->urb;
555
556 urb->context = husb;
557 urb->dev = husb->udev;
558 urb->pipe = usb_sndisocpipe(husb->udev, husb->isoc_out_ep->desc.bEndpointAddress);
559 urb->complete = hci_usb_tx_complete;
560 urb->transfer_flags = URB_ISO_ASAP;
561
562 urb->interval = husb->isoc_out_ep->desc.bInterval;
563
564 urb->transfer_buffer = skb->data;
565 urb->transfer_buffer_length = skb->len;
566
567 __fill_isoc_desc(urb, skb->len, le16_to_cpu(husb->isoc_out_ep->desc.wMaxPacketSize));
568
569 _urb->priv = skb;
570 return __tx_submit(husb, _urb);
571}
572#endif
573
574static void hci_usb_tx_process(struct hci_usb *husb)
575{
576 struct sk_buff_head *q;
577 struct sk_buff *skb;
578
579 BT_DBG("%s", husb->hdev->name);
580
581 do {
582 clear_bit(HCI_USB_TX_WAKEUP, &husb->state);
583
584 /* Process command queue */
585 q = __transmit_q(husb, HCI_COMMAND_PKT);
586 if (!atomic_read(__pending_tx(husb, HCI_COMMAND_PKT)) &&
587 (skb = skb_dequeue(q))) {
588 if (hci_usb_send_ctrl(husb, skb) < 0)
589 skb_queue_head(q, skb);
590 }
591
592#ifdef CONFIG_BT_HCIUSB_SCO
593 /* Process SCO queue */
594 q = __transmit_q(husb, HCI_SCODATA_PKT);
595 if (atomic_read(__pending_tx(husb, HCI_SCODATA_PKT)) < HCI_MAX_ISOC_TX &&
596 (skb = skb_dequeue(q))) {
597 if (hci_usb_send_isoc(husb, skb) < 0)
598 skb_queue_head(q, skb);
599 }
600#endif
601
602 /* Process ACL queue */
603 q = __transmit_q(husb, HCI_ACLDATA_PKT);
604 while (atomic_read(__pending_tx(husb, HCI_ACLDATA_PKT)) < HCI_MAX_BULK_TX &&
605 (skb = skb_dequeue(q))) {
606 if (hci_usb_send_bulk(husb, skb) < 0) {
607 skb_queue_head(q, skb);
608 break;
609 }
610 }
611 } while(test_bit(HCI_USB_TX_WAKEUP, &husb->state));
612}
613
614static inline void hci_usb_tx_wakeup(struct hci_usb *husb)
615{
616 /* Serialize TX queue processing to avoid data reordering */
617 if (!test_and_set_bit(HCI_USB_TX_PROCESS, &husb->state)) {
618 hci_usb_tx_process(husb);
619 clear_bit(HCI_USB_TX_PROCESS, &husb->state);
620 } else
621 set_bit(HCI_USB_TX_WAKEUP, &husb->state);
622}
623
624/* Send frames from HCI layer */
625static int hci_usb_send_frame(struct sk_buff *skb)
626{
627 struct hci_dev *hdev = (struct hci_dev *) skb->dev;
628 struct hci_usb *husb;
629
630 if (!hdev) {
631 BT_ERR("frame for uknown device (hdev=NULL)");
632 return -ENODEV;
633 }
634
635 if (!test_bit(HCI_RUNNING, &hdev->flags))
636 return -EBUSY;
637
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700638 BT_DBG("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
640 husb = (struct hci_usb *) hdev->driver_data;
641
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700642 switch (bt_cb(skb)->pkt_type) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 case HCI_COMMAND_PKT:
644 hdev->stat.cmd_tx++;
645 break;
646
647 case HCI_ACLDATA_PKT:
648 hdev->stat.acl_tx++;
649 break;
650
651#ifdef CONFIG_BT_HCIUSB_SCO
652 case HCI_SCODATA_PKT:
653 hdev->stat.sco_tx++;
654 break;
655#endif
656
657 default:
658 kfree_skb(skb);
659 return 0;
660 }
661
662 read_lock(&husb->completion_lock);
663
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700664 skb_queue_tail(__transmit_q(husb, bt_cb(skb)->pkt_type), skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 hci_usb_tx_wakeup(husb);
666
667 read_unlock(&husb->completion_lock);
668 return 0;
669}
670
671static inline int __recv_frame(struct hci_usb *husb, int type, void *data, int count)
672{
673 BT_DBG("%s type %d data %p count %d", husb->hdev->name, type, data, count);
674
675 husb->hdev->stat.byte_rx += count;
676
677 while (count) {
678 struct sk_buff *skb = __reassembly(husb, type);
679 struct { int expect; } *scb;
680 int len = 0;
681
682 if (!skb) {
683 /* Start of the frame */
684
685 switch (type) {
686 case HCI_EVENT_PKT:
687 if (count >= HCI_EVENT_HDR_SIZE) {
688 struct hci_event_hdr *h = data;
689 len = HCI_EVENT_HDR_SIZE + h->plen;
690 } else
691 return -EILSEQ;
692 break;
693
694 case HCI_ACLDATA_PKT:
695 if (count >= HCI_ACL_HDR_SIZE) {
696 struct hci_acl_hdr *h = data;
697 len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen);
698 } else
699 return -EILSEQ;
700 break;
701#ifdef CONFIG_BT_HCIUSB_SCO
702 case HCI_SCODATA_PKT:
703 if (count >= HCI_SCO_HDR_SIZE) {
704 struct hci_sco_hdr *h = data;
705 len = HCI_SCO_HDR_SIZE + h->dlen;
706 } else
707 return -EILSEQ;
708 break;
709#endif
710 }
711 BT_DBG("new packet len %d", len);
712
713 skb = bt_skb_alloc(len, GFP_ATOMIC);
714 if (!skb) {
715 BT_ERR("%s no memory for the packet", husb->hdev->name);
716 return -ENOMEM;
717 }
718 skb->dev = (void *) husb->hdev;
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700719 bt_cb(skb)->pkt_type = type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720
721 __reassembly(husb, type) = skb;
722
723 scb = (void *) skb->cb;
724 scb->expect = len;
725 } else {
726 /* Continuation */
727 scb = (void *) skb->cb;
728 len = scb->expect;
729 }
730
731 len = min(len, count);
732
733 memcpy(skb_put(skb, len), data, len);
734
735 scb->expect -= len;
736 if (!scb->expect) {
737 /* Complete frame */
738 __reassembly(husb, type) = NULL;
Marcel Holtmann0d48d932005-08-09 20:30:28 -0700739 bt_cb(skb)->pkt_type = type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 hci_recv_frame(skb);
741 }
742
743 count -= len; data += len;
744 }
745 return 0;
746}
747
David Howells7d12e782006-10-05 14:55:46 +0100748static void hci_usb_rx_complete(struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749{
750 struct _urb *_urb = container_of(urb, struct _urb, urb);
751 struct hci_usb *husb = (void *) urb->context;
752 struct hci_dev *hdev = husb->hdev;
753 int err, count = urb->actual_length;
754
755 BT_DBG("%s urb %p type %d status %d count %d flags %x", hdev->name, urb,
756 _urb->type, urb->status, count, urb->transfer_flags);
757
758 read_lock(&husb->completion_lock);
759
760 if (!test_bit(HCI_RUNNING, &hdev->flags))
761 goto unlock;
762
763 if (urb->status || !count)
764 goto resubmit;
765
766 if (_urb->type == HCI_SCODATA_PKT) {
767#ifdef CONFIG_BT_HCIUSB_SCO
768 int i;
769 for (i=0; i < urb->number_of_packets; i++) {
770 BT_DBG("desc %d status %d offset %d len %d", i,
771 urb->iso_frame_desc[i].status,
772 urb->iso_frame_desc[i].offset,
773 urb->iso_frame_desc[i].actual_length);
774
775 if (!urb->iso_frame_desc[i].status)
776 __recv_frame(husb, _urb->type,
777 urb->transfer_buffer + urb->iso_frame_desc[i].offset,
778 urb->iso_frame_desc[i].actual_length);
779 }
780#else
781 ;
782#endif
783 } else {
784 err = __recv_frame(husb, _urb->type, urb->transfer_buffer, count);
785 if (err < 0) {
786 BT_ERR("%s corrupted packet: type %d count %d",
787 husb->hdev->name, _urb->type, count);
788 hdev->stat.err_rx++;
789 }
790 }
791
792resubmit:
793 urb->dev = husb->udev;
794 err = usb_submit_urb(urb, GFP_ATOMIC);
795 BT_DBG("%s urb %p type %d resubmit status %d", hdev->name, urb,
796 _urb->type, err);
797
798unlock:
799 read_unlock(&husb->completion_lock);
800}
801
David Howells7d12e782006-10-05 14:55:46 +0100802static void hci_usb_tx_complete(struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803{
804 struct _urb *_urb = container_of(urb, struct _urb, urb);
805 struct hci_usb *husb = (void *) urb->context;
806 struct hci_dev *hdev = husb->hdev;
807
808 BT_DBG("%s urb %p status %d flags %x", hdev->name, urb,
809 urb->status, urb->transfer_flags);
810
811 atomic_dec(__pending_tx(husb, _urb->type));
812
813 urb->transfer_buffer = NULL;
814 kfree_skb((struct sk_buff *) _urb->priv);
815
816 if (!test_bit(HCI_RUNNING, &hdev->flags))
817 return;
818
819 if (!urb->status)
820 hdev->stat.byte_tx += urb->transfer_buffer_length;
821 else
822 hdev->stat.err_tx++;
823
824 read_lock(&husb->completion_lock);
825
826 _urb_unlink(_urb);
827 _urb_queue_tail(__completed_q(husb, _urb->type), _urb);
828
829 hci_usb_tx_wakeup(husb);
830
831 read_unlock(&husb->completion_lock);
832}
833
834static void hci_usb_destruct(struct hci_dev *hdev)
835{
836 struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
837
838 BT_DBG("%s", hdev->name);
839
840 kfree(husb);
841}
842
843static void hci_usb_notify(struct hci_dev *hdev, unsigned int evt)
844{
845 BT_DBG("%s evt %d", hdev->name, evt);
846}
847
848static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
849{
850 struct usb_device *udev = interface_to_usbdev(intf);
851 struct usb_host_endpoint *bulk_out_ep = NULL;
852 struct usb_host_endpoint *bulk_in_ep = NULL;
853 struct usb_host_endpoint *intr_in_ep = NULL;
854 struct usb_host_endpoint *ep;
855 struct usb_host_interface *uif;
856 struct usb_interface *isoc_iface;
857 struct hci_usb *husb;
858 struct hci_dev *hdev;
859 int i, e, size, isoc_ifnum, isoc_alts;
860
861 BT_DBG("udev %p intf %p", udev, intf);
862
863 if (!id->driver_info) {
864 const struct usb_device_id *match;
865 match = usb_match_id(intf, blacklist_ids);
866 if (match)
867 id = match;
868 }
869
870 if (ignore || id->driver_info & HCI_IGNORE)
871 return -ENODEV;
872
Marcel Holtmann7ef934b2005-11-08 09:57:05 -0800873 if (ignore_dga && id->driver_info & HCI_DIGIANSWER)
874 return -ENODEV;
875
Marcel Holtmann0915e882005-09-13 01:32:37 +0200876 if (ignore_csr && id->driver_info & HCI_CSR)
877 return -ENODEV;
878
879 if (ignore_sniffer && id->driver_info & HCI_SNIFFER)
880 return -ENODEV;
881
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 if (intf->cur_altsetting->desc.bInterfaceNumber > 0)
883 return -ENODEV;
884
885 /* Find endpoints that we need */
886 uif = intf->cur_altsetting;
887 for (e = 0; e < uif->desc.bNumEndpoints; e++) {
888 ep = &uif->endpoint[e];
889
890 switch (ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
891 case USB_ENDPOINT_XFER_INT:
892 if (ep->desc.bEndpointAddress & USB_DIR_IN)
893 intr_in_ep = ep;
894 break;
895
896 case USB_ENDPOINT_XFER_BULK:
897 if (ep->desc.bEndpointAddress & USB_DIR_IN)
898 bulk_in_ep = ep;
899 else
900 bulk_out_ep = ep;
901 break;
902 }
903 }
904
905 if (!bulk_in_ep || !bulk_out_ep || !intr_in_ep) {
906 BT_DBG("Bulk endpoints not found");
907 goto done;
908 }
909
Deepak Saxena089b1db2005-11-07 01:01:26 -0800910 if (!(husb = kzalloc(sizeof(struct hci_usb), GFP_KERNEL))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 BT_ERR("Can't allocate: control structure");
912 goto done;
913 }
914
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 husb->udev = udev;
916 husb->bulk_out_ep = bulk_out_ep;
917 husb->bulk_in_ep = bulk_in_ep;
918 husb->intr_in_ep = intr_in_ep;
919
920 if (id->driver_info & HCI_DIGIANSWER)
921 husb->ctrl_req = USB_TYPE_VENDOR;
922 else
923 husb->ctrl_req = USB_TYPE_CLASS;
924
925 /* Find isochronous endpoints that we can use */
926 size = 0;
927 isoc_iface = NULL;
928 isoc_alts = 0;
929 isoc_ifnum = 1;
930
931#ifdef CONFIG_BT_HCIUSB_SCO
932 if (isoc && !(id->driver_info & (HCI_BROKEN_ISOC | HCI_SNIFFER)))
933 isoc_iface = usb_ifnum_to_if(udev, isoc_ifnum);
934
935 if (isoc_iface) {
936 int a;
937 struct usb_host_endpoint *isoc_out_ep = NULL;
938 struct usb_host_endpoint *isoc_in_ep = NULL;
939
940 for (a = 0; a < isoc_iface->num_altsetting; a++) {
941 uif = &isoc_iface->altsetting[a];
942 for (e = 0; e < uif->desc.bNumEndpoints; e++) {
943 ep = &uif->endpoint[e];
944
945 switch (ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
946 case USB_ENDPOINT_XFER_ISOC:
947 if (le16_to_cpu(ep->desc.wMaxPacketSize) < size ||
948 uif->desc.bAlternateSetting != isoc)
949 break;
950 size = le16_to_cpu(ep->desc.wMaxPacketSize);
951
952 isoc_alts = uif->desc.bAlternateSetting;
953
954 if (ep->desc.bEndpointAddress & USB_DIR_IN)
955 isoc_in_ep = ep;
956 else
957 isoc_out_ep = ep;
958 break;
959 }
960 }
961 }
962
963 if (!isoc_in_ep || !isoc_out_ep)
964 BT_DBG("Isoc endpoints not found");
965 else {
966 BT_DBG("isoc ifnum %d alts %d", isoc_ifnum, isoc_alts);
967 if (usb_driver_claim_interface(&hci_usb_driver, isoc_iface, husb) != 0)
968 BT_ERR("Can't claim isoc interface");
969 else if (usb_set_interface(udev, isoc_ifnum, isoc_alts)) {
970 BT_ERR("Can't set isoc interface settings");
971 husb->isoc_iface = isoc_iface;
972 usb_driver_release_interface(&hci_usb_driver, isoc_iface);
973 husb->isoc_iface = NULL;
974 } else {
975 husb->isoc_iface = isoc_iface;
976 husb->isoc_in_ep = isoc_in_ep;
977 husb->isoc_out_ep = isoc_out_ep;
978 }
979 }
980 }
981#endif
982
983 rwlock_init(&husb->completion_lock);
984
985 for (i = 0; i < 4; i++) {
986 skb_queue_head_init(&husb->transmit_q[i]);
987 _urb_queue_init(&husb->pending_q[i]);
988 _urb_queue_init(&husb->completed_q[i]);
989 }
990
991 /* Initialize and register HCI device */
992 hdev = hci_alloc_dev();
993 if (!hdev) {
994 BT_ERR("Can't allocate HCI device");
995 goto probe_error;
996 }
997
998 husb->hdev = hdev;
999
1000 hdev->type = HCI_USB;
1001 hdev->driver_data = husb;
1002 SET_HCIDEV_DEV(hdev, &intf->dev);
1003
1004 hdev->open = hci_usb_open;
1005 hdev->close = hci_usb_close;
1006 hdev->flush = hci_usb_flush;
1007 hdev->send = hci_usb_send_frame;
1008 hdev->destruct = hci_usb_destruct;
1009 hdev->notify = hci_usb_notify;
1010
1011 hdev->owner = THIS_MODULE;
1012
1013 if (reset || id->driver_info & HCI_RESET)
1014 set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks);
1015
Marcel Holtmann520ca782006-07-14 16:01:52 +02001016 if (force_scofix || id->driver_info & HCI_WRONG_SCO_MTU) {
1017 if (!disable_scofix)
1018 set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks);
1019 }
Marcel Holtmannda1f5192006-07-03 10:02:29 +02001020
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 if (id->driver_info & HCI_SNIFFER) {
1022 if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997)
1023 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
1024 }
1025
1026 if (id->driver_info & HCI_BCM92035) {
1027 unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 };
1028 struct sk_buff *skb;
1029
1030 skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
1031 if (skb) {
1032 memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
1033 skb_queue_tail(&hdev->driver_init, skb);
1034 }
1035 }
1036
1037 if (hci_register_dev(hdev) < 0) {
1038 BT_ERR("Can't register HCI device");
1039 hci_free_dev(hdev);
1040 goto probe_error;
1041 }
1042
1043 usb_set_intfdata(intf, husb);
1044 return 0;
1045
1046probe_error:
1047 if (husb->isoc_iface)
1048 usb_driver_release_interface(&hci_usb_driver, husb->isoc_iface);
1049 kfree(husb);
1050
1051done:
1052 return -EIO;
1053}
1054
1055static void hci_usb_disconnect(struct usb_interface *intf)
1056{
1057 struct hci_usb *husb = usb_get_intfdata(intf);
1058 struct hci_dev *hdev;
1059
1060 if (!husb || intf == husb->isoc_iface)
1061 return;
1062
1063 usb_set_intfdata(intf, NULL);
1064 hdev = husb->hdev;
1065
1066 BT_DBG("%s", hdev->name);
1067
1068 hci_usb_close(hdev);
1069
1070 if (husb->isoc_iface)
1071 usb_driver_release_interface(&hci_usb_driver, husb->isoc_iface);
1072
1073 if (hci_unregister_dev(hdev) < 0)
1074 BT_ERR("Can't unregister HCI device %s", hdev->name);
1075
1076 hci_free_dev(hdev);
1077}
1078
Marcel Holtmanndcdcf632006-07-03 10:02:24 +02001079static int hci_usb_suspend(struct usb_interface *intf, pm_message_t message)
1080{
1081 struct hci_usb *husb = usb_get_intfdata(intf);
1082 struct list_head killed;
1083 unsigned long flags;
1084 int i;
1085
1086 if (!husb || intf == husb->isoc_iface)
1087 return 0;
1088
1089 hci_suspend_dev(husb->hdev);
1090
1091 INIT_LIST_HEAD(&killed);
1092
1093 for (i = 0; i < 4; i++) {
1094 struct _urb_queue *q = &husb->pending_q[i];
1095 struct _urb *_urb, *_tmp;
1096
1097 while ((_urb = _urb_dequeue(q))) {
1098 /* reset queue since _urb_dequeue sets it to NULL */
1099 _urb->queue = q;
1100 usb_kill_urb(&_urb->urb);
1101 list_add(&_urb->list, &killed);
1102 }
1103
1104 spin_lock_irqsave(&q->lock, flags);
1105
1106 list_for_each_entry_safe(_urb, _tmp, &killed, list) {
1107 list_move_tail(&_urb->list, &q->head);
1108 }
1109
1110 spin_unlock_irqrestore(&q->lock, flags);
1111 }
1112
1113 return 0;
1114}
1115
1116static int hci_usb_resume(struct usb_interface *intf)
1117{
1118 struct hci_usb *husb = usb_get_intfdata(intf);
1119 unsigned long flags;
1120 int i, err = 0;
1121
1122 if (!husb || intf == husb->isoc_iface)
1123 return 0;
1124
1125 for (i = 0; i < 4; i++) {
1126 struct _urb_queue *q = &husb->pending_q[i];
1127 struct _urb *_urb;
1128
1129 spin_lock_irqsave(&q->lock, flags);
1130
1131 list_for_each_entry(_urb, &q->head, list) {
1132 err = usb_submit_urb(&_urb->urb, GFP_ATOMIC);
1133 if (err)
1134 break;
1135 }
1136
1137 spin_unlock_irqrestore(&q->lock, flags);
1138
1139 if (err)
1140 return -EIO;
1141 }
1142
1143 hci_resume_dev(husb->hdev);
1144
1145 return 0;
1146}
1147
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148static struct usb_driver hci_usb_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .name = "hci_usb",
1150 .probe = hci_usb_probe,
1151 .disconnect = hci_usb_disconnect,
Marcel Holtmanndcdcf632006-07-03 10:02:24 +02001152 .suspend = hci_usb_suspend,
1153 .resume = hci_usb_resume,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .id_table = bluetooth_ids,
1155};
1156
1157static int __init hci_usb_init(void)
1158{
1159 int err;
1160
1161 BT_INFO("HCI USB driver ver %s", VERSION);
1162
1163 if ((err = usb_register(&hci_usb_driver)) < 0)
1164 BT_ERR("Failed to register HCI USB driver");
1165
1166 return err;
1167}
1168
1169static void __exit hci_usb_exit(void)
1170{
1171 usb_deregister(&hci_usb_driver);
1172}
1173
1174module_init(hci_usb_init);
1175module_exit(hci_usb_exit);
1176
1177module_param(ignore, bool, 0644);
1178MODULE_PARM_DESC(ignore, "Ignore devices from the matching table");
1179
Marcel Holtmann7ef934b2005-11-08 09:57:05 -08001180module_param(ignore_dga, bool, 0644);
1181MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001");
1182
Marcel Holtmann0915e882005-09-13 01:32:37 +02001183module_param(ignore_csr, bool, 0644);
1184MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001");
1185
1186module_param(ignore_sniffer, bool, 0644);
1187MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002");
1188
Marcel Holtmann520ca782006-07-14 16:01:52 +02001189module_param(disable_scofix, bool, 0644);
1190MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size");
1191
1192module_param(force_scofix, bool, 0644);
1193MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size");
1194
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195module_param(reset, bool, 0644);
1196MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
1197
1198#ifdef CONFIG_BT_HCIUSB_SCO
1199module_param(isoc, int, 0644);
1200MODULE_PARM_DESC(isoc, "Set isochronous transfers for SCO over HCI support");
1201#endif
1202
1203MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>");
1204MODULE_DESCRIPTION("Bluetooth HCI USB driver ver " VERSION);
1205MODULE_VERSION(VERSION);
1206MODULE_LICENSE("GPL");