[Bluetooth] Add full quirk implementation for btusb driver

This implements all the quirk handling from the hci_usb driver to the
new btusb driver.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

+161 -2
+161 -2
drivers/bluetooth/btusb.c
··· 41 41 #define BT_DBG(D...) 42 42 #endif 43 43 44 - #define VERSION "0.1" 44 + #define VERSION "0.2" 45 + 46 + static int ignore_dga; 47 + static int ignore_csr; 48 + static int ignore_sniffer; 49 + static int disable_scofix; 50 + static int force_scofix; 51 + static int reset; 52 + 53 + static struct usb_driver btusb_driver; 54 + 55 + #define BTUSB_IGNORE 0x01 56 + #define BTUSB_RESET 0x02 57 + #define BTUSB_DIGIANSWER 0x04 58 + #define BTUSB_CSR 0x08 59 + #define BTUSB_SNIFFER 0x10 60 + #define BTUSB_BCM92035 0x20 61 + #define BTUSB_BROKEN_ISOC 0x40 62 + #define BTUSB_WRONG_SCO_MTU 0x80 45 63 46 64 static struct usb_device_id btusb_table[] = { 47 65 /* Generic Bluetooth USB device */ 48 66 { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, 67 + 68 + /* AVM BlueFRITZ! USB v2.0 */ 69 + { USB_DEVICE(0x057c, 0x3800) }, 70 + 71 + /* Bluetooth Ultraport Module from IBM */ 72 + { USB_DEVICE(0x04bf, 0x030a) }, 73 + 74 + /* ALPS Modules with non-standard id */ 75 + { USB_DEVICE(0x044e, 0x3001) }, 76 + { USB_DEVICE(0x044e, 0x3002) }, 77 + 78 + /* Ericsson with non-standard id */ 79 + { USB_DEVICE(0x0bdb, 0x1002) }, 80 + 81 + /* Canyon CN-BTU1 with HID interfaces */ 82 + { USB_DEVICE(0x0c10, 0x0000), .driver_info = BTUSB_RESET }, 49 83 50 84 { } /* Terminating entry */ 51 85 }; ··· 87 53 MODULE_DEVICE_TABLE(usb, btusb_table); 88 54 89 55 static struct usb_device_id blacklist_table[] = { 56 + /* CSR BlueCore devices */ 57 + { USB_DEVICE(0x0a12, 0x0001), .driver_info = BTUSB_CSR }, 58 + 59 + /* Broadcom BCM2033 without firmware */ 60 + { USB_DEVICE(0x0a5c, 0x2033), .driver_info = BTUSB_IGNORE }, 61 + 62 + /* Broadcom BCM2035 */ 63 + { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 64 + { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 65 + 66 + /* Broadcom BCM2045 */ 67 + { USB_DEVICE(0x0a5c, 0x2039), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 68 + { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 69 + 70 + /* Broadcom BCM2046 */ 71 + { USB_DEVICE(0x0a5c, 0x2151), .driver_info = BTUSB_RESET }, 72 + 73 + /* IBM/Lenovo ThinkPad with Broadcom chip */ 74 + { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 75 + { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 76 + 77 + /* Targus ACB10US */ 78 + { USB_DEVICE(0x0a5c, 0x2100), .driver_info = BTUSB_RESET }, 79 + 80 + /* ANYCOM Bluetooth USB-200 and USB-250 */ 81 + { USB_DEVICE(0x0a5c, 0x2111), .driver_info = BTUSB_RESET }, 82 + 83 + /* HP laptop with Broadcom chip */ 84 + { USB_DEVICE(0x03f0, 0x171d), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 85 + 86 + /* Dell laptop with Broadcom chip */ 87 + { USB_DEVICE(0x413c, 0x8126), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 88 + 89 + /* Dell Wireless 370 */ 90 + { USB_DEVICE(0x413c, 0x8156), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 91 + 92 + /* Dell Wireless 410 */ 93 + { USB_DEVICE(0x413c, 0x8152), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 94 + 95 + /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ 96 + { USB_DEVICE(0x045e, 0x009c), .driver_info = BTUSB_RESET }, 97 + 98 + /* Kensington Bluetooth USB adapter */ 99 + { USB_DEVICE(0x047d, 0x105d), .driver_info = BTUSB_RESET }, 100 + { USB_DEVICE(0x047d, 0x105e), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 101 + 102 + /* ISSC Bluetooth Adapter v3.1 */ 103 + { USB_DEVICE(0x1131, 0x1001), .driver_info = BTUSB_RESET }, 104 + 105 + /* RTX Telecom based adapters with buggy SCO support */ 106 + { USB_DEVICE(0x0400, 0x0807), .driver_info = BTUSB_BROKEN_ISOC }, 107 + { USB_DEVICE(0x0400, 0x080a), .driver_info = BTUSB_BROKEN_ISOC }, 108 + 109 + /* CONWISE Technology based adapters with buggy SCO support */ 110 + { USB_DEVICE(0x0e5e, 0x6622), .driver_info = BTUSB_BROKEN_ISOC }, 111 + 112 + /* Belkin F8T012 and F8T013 devices */ 113 + { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 114 + { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 115 + 116 + /* Digianswer devices */ 117 + { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER }, 118 + { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE }, 119 + 120 + /* CSR BlueCore Bluetooth Sniffer */ 121 + { USB_DEVICE(0x0a12, 0x0002), .driver_info = BTUSB_SNIFFER }, 122 + 123 + /* Frontline ComProbe Bluetooth Sniffer */ 124 + { USB_DEVICE(0x16d3, 0x0002), .driver_info = BTUSB_SNIFFER }, 125 + 90 126 { } /* Terminating entry */ 91 127 }; 92 128 ··· 537 433 538 434 BT_DBG("intf %p id %p", intf, id); 539 435 436 + /* interface numbers are hardcoded in the spec */ 540 437 if (intf->cur_altsetting->desc.bInterfaceNumber != 0) 541 438 return -ENODEV; 542 439 ··· 547 442 if (match) 548 443 id = match; 549 444 } 445 + 446 + if (id->driver_info == BTUSB_IGNORE) 447 + return -ENODEV; 448 + 449 + if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER) 450 + return -ENODEV; 451 + 452 + if (ignore_csr && id->driver_info & BTUSB_CSR) 453 + return -ENODEV; 454 + 455 + if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) 456 + return -ENODEV; 550 457 551 458 data = kzalloc(sizeof(*data), GFP_KERNEL); 552 459 if (!data) ··· 620 503 621 504 hdev->owner = THIS_MODULE; 622 505 623 - set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); 506 + if (reset || id->driver_info & BTUSB_RESET) 507 + set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); 508 + 509 + if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) { 510 + if (!disable_scofix) 511 + set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); 512 + } 513 + 514 + if (id->driver_info & BTUSB_SNIFFER) { 515 + struct usb_device *udev = interface_to_usbdev(intf); 516 + 517 + if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) 518 + set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); 519 + } 520 + 521 + if (id->driver_info & BTUSB_BCM92035) { 522 + unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 }; 523 + struct sk_buff *skb; 524 + 525 + skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL); 526 + if (skb) { 527 + memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd)); 528 + skb_queue_tail(&hdev->driver_init, skb); 529 + } 530 + } 624 531 625 532 err = hci_register_dev(hdev); 626 533 if (err < 0) { ··· 698 557 699 558 module_init(btusb_init); 700 559 module_exit(btusb_exit); 560 + 561 + module_param(ignore_dga, bool, 0644); 562 + MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001"); 563 + 564 + module_param(ignore_csr, bool, 0644); 565 + MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); 566 + 567 + module_param(ignore_sniffer, bool, 0644); 568 + MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); 569 + 570 + module_param(disable_scofix, bool, 0644); 571 + MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size"); 572 + 573 + module_param(force_scofix, bool, 0644); 574 + MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); 575 + 576 + module_param(reset, bool, 0644); 577 + MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); 701 578 702 579 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); 703 580 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);