Skip to content

Commit b42fde9

Browse files
pvgregkh
authored andcommitted
Bluetooth: btusb: check conditions before enabling USB ALT 3 for WBS
commit 55981d3 upstream. Some USB BT adapters don't satisfy the MTU requirement mentioned in commit e848dbd ("Bluetooth: btusb: Add support USB ALT 3 for WBS") and have ALT 3 setting that produces no/garbled audio. Some adapters with larger MTU were also reported to have problems with ALT 3. Add a flag and check it and MTU before selecting ALT 3, falling back to ALT 1. Enable the flag for Realtek, restoring the previous behavior for non-Realtek devices. Tested with USB adapters (mtu<72, no/garbled sound with ALT3, ALT1 works) BCM20702A1 0b05:17cb, CSR8510A10 0a12:0001, and (mtu>=72, ALT3 works) RTL8761BU 0bda:8771, Intel AX200 8087:0029 (after disabling ALT6). Also got reports for (mtu>=72, ALT 3 reported to produce bad audio) Intel 8087:0a2b. Signed-off-by: Pauli Virtanen <pav@iki.fi> Fixes: e848dbd ("Bluetooth: btusb: Add support USB ALT 3 for WBS") Tested-by: Michał Kępień <kernel@kempniu.pl> Tested-by: Jonathan Lampérth <jon@h4n.dev> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 60d69cb commit b42fde9

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

drivers/bluetooth/btusb.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
486486
#define BTUSB_HW_RESET_ACTIVE 12
487487
#define BTUSB_TX_WAIT_VND_EVT 13
488488
#define BTUSB_WAKEUP_DISABLE 14
489+
#define BTUSB_USE_ALT3_FOR_WBS 15
489490

490491
struct btusb_data {
491492
struct hci_dev *hdev;
@@ -1718,16 +1719,20 @@ static void btusb_work(struct work_struct *work)
17181719
/* Bluetooth USB spec recommends alt 6 (63 bytes), but
17191720
* many adapters do not support it. Alt 1 appears to
17201721
* work for all adapters that do not have alt 6, and
1721-
* which work with WBS at all.
1722+
* which work with WBS at all. Some devices prefer
1723+
* alt 3 (HCI payload >= 60 Bytes let air packet
1724+
* data satisfy 60 bytes), requiring
1725+
* MTU >= 3 (packets) * 25 (size) - 3 (headers) = 72
1726+
* see also Core spec 5, vol 4, B 2.1.1 & Table 2.1.
17221727
*/
1723-
new_alts = btusb_find_altsetting(data, 6) ? 6 : 1;
1724-
/* Because mSBC frames do not need to be aligned to the
1725-
* SCO packet boundary. If support the Alt 3, use the
1726-
* Alt 3 for HCI payload >= 60 Bytes let air packet
1727-
* data satisfy 60 bytes.
1728-
*/
1729-
if (new_alts == 1 && btusb_find_altsetting(data, 3))
1728+
if (btusb_find_altsetting(data, 6))
1729+
new_alts = 6;
1730+
else if (btusb_find_altsetting(data, 3) &&
1731+
hdev->sco_mtu >= 72 &&
1732+
test_bit(BTUSB_USE_ALT3_FOR_WBS, &data->flags))
17301733
new_alts = 3;
1734+
else
1735+
new_alts = 1;
17311736
}
17321737

17331738
if (btusb_switch_alt_setting(hdev, new_alts) < 0)
@@ -4170,6 +4175,7 @@ static int btusb_probe(struct usb_interface *intf,
41704175
* (DEVICE_REMOTE_WAKEUP)
41714176
*/
41724177
set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
4178+
set_bit(BTUSB_USE_ALT3_FOR_WBS, &data->flags);
41734179
}
41744180

41754181
if (!reset)

0 commit comments

Comments
 (0)