diff mbox series

Bluetooth: btusb: Always fallback to alt 1 for WBS

Message ID 20201210012003.133000-1-tpiepho@gmail.com
State Accepted
Commit 517b693351a2d04f3af1fc0e506ac7e1346094de
Headers show
Series Bluetooth: btusb: Always fallback to alt 1 for WBS | expand

Commit Message

Trent Piepho Dec. 10, 2020, 1:20 a.m. UTC
When alt mode 6 is not available, fallback to the kernel <= 5.7 behavior
of always using alt mode 1.

Prior to kernel 5.8, btusb would always use alt mode 1 for WBS (Wide
Band Speech aka mSBC aka transparent SCO).  In commit baac6276c0a9
("Bluetooth: btusb: handle mSBC audio over USB Endpoints") this
was changed to use alt mode 6, which is the recommended mode in the
Bluetooth spec (Specifications of the Bluetooth System, v5.0, Vol 4.B
§2.2.1).  However, many if not most BT USB adapters do not support alt
mode 6.  In fact, I have been unable to find any which do.

In kernel 5.8, this was changed to use alt mode 6, and if not available,
use alt mode 0.  But mode 0 has a zero byte max packet length and can
not possibly work.  It is just there as a zero-bandwidth dummy mode to
work around a USB flaw that would prevent device enumeration if
insufficient bandwidth were available for the lowest isoc mode
supported.

In effect, WBS was broken for all USB-BT adapters that do not support
alt 6, which appears to nearly all of them.

Then in commit 461f95f04f19 ("Bluetooth: btusb: USB alternate setting 1 for
WBS") the 5.7 behavior was restored, but only for Realtek adapters.

I've tested a Broadcom BRCM20702A and CSR 8510 adapter, both work with
the 5.7 behavior and do not with the 5.8.

So get rid of the Realtek specific flag and use the 5.7 behavior for all
adapters as a fallback when alt 6 is not available.  This was the
kernel's behavior prior to 5.8 and I can find no adapters for which it
is not correct.  And even if there is an adapter for which this does not
work, the current behavior would be to fall back to alt 0, which can not
possibly work either, and so is no better.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
---
 drivers/bluetooth/btusb.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

Comments

bluez.test.bot@gmail.com Dec. 10, 2020, 1:47 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=399381

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuildK - PASS



---
Regards,
Linux Bluetooth
Marcel Holtmann Dec. 18, 2020, 9:23 p.m. UTC | #2
Hi Trent,

> When alt mode 6 is not available, fallback to the kernel <= 5.7 behavior

> of always using alt mode 1.

> 

> Prior to kernel 5.8, btusb would always use alt mode 1 for WBS (Wide

> Band Speech aka mSBC aka transparent SCO).  In commit baac6276c0a9

> ("Bluetooth: btusb: handle mSBC audio over USB Endpoints") this

> was changed to use alt mode 6, which is the recommended mode in the

> Bluetooth spec (Specifications of the Bluetooth System, v5.0, Vol 4.B

> §2.2.1).  However, many if not most BT USB adapters do not support alt

> mode 6.  In fact, I have been unable to find any which do.

> 

> In kernel 5.8, this was changed to use alt mode 6, and if not available,

> use alt mode 0.  But mode 0 has a zero byte max packet length and can

> not possibly work.  It is just there as a zero-bandwidth dummy mode to

> work around a USB flaw that would prevent device enumeration if

> insufficient bandwidth were available for the lowest isoc mode

> supported.

> 

> In effect, WBS was broken for all USB-BT adapters that do not support

> alt 6, which appears to nearly all of them.

> 

> Then in commit 461f95f04f19 ("Bluetooth: btusb: USB alternate setting 1 for

> WBS") the 5.7 behavior was restored, but only for Realtek adapters.

> 

> I've tested a Broadcom BRCM20702A and CSR 8510 adapter, both work with

> the 5.7 behavior and do not with the 5.8.

> 

> So get rid of the Realtek specific flag and use the 5.7 behavior for all

> adapters as a fallback when alt 6 is not available.  This was the

> kernel's behavior prior to 5.8 and I can find no adapters for which it

> is not correct.  And even if there is an adapter for which this does not

> work, the current behavior would be to fall back to alt 0, which can not

> possibly work either, and so is no better.

> 

> Signed-off-by: Trent Piepho <tpiepho@gmail.com>

> ---

> drivers/bluetooth/btusb.c | 20 ++++++--------------

> 1 file changed, 6 insertions(+), 14 deletions(-)


patch has been applied to bluetooth-next tree.

Regards

Marcel
Sjoerd Simons Feb. 6, 2021, 3:56 p.m. UTC | #3
On Fri, Dec 18, 2020 at 10:23:08PM +0100, Marcel Holtmann wrote:
> Hi Trent,

> 

> > When alt mode 6 is not available, fallback to the kernel <= 5.7 behavior

> > of always using alt mode 1.

> > 

> > Prior to kernel 5.8, btusb would always use alt mode 1 for WBS (Wide

> > Band Speech aka mSBC aka transparent SCO).  In commit baac6276c0a9

> > ("Bluetooth: btusb: handle mSBC audio over USB Endpoints") this

> > was changed to use alt mode 6, which is the recommended mode in the

> > Bluetooth spec (Specifications of the Bluetooth System, v5.0, Vol 4.B

> > §2.2.1).  However, many if not most BT USB adapters do not support alt

> > mode 6.  In fact, I have been unable to find any which do.


> patch has been applied to bluetooth-next tree.


For easier application to the stable tree(s) this should probably get:
  Fixes: baac6276c0a9 ("Bluetooth: btusb: handle mSBC audio over USB Endpoints")

In my testing this indeed fixes mSBC audio with both a Belkin (Broadcom
BCM20702A, 050d:065a) and an Intel Bluetooth (8087:0a2b) adapters.

  Tested-By: Sjoerd Simons <sjoerd@collabora.com>


Regards,
  Sjoerd
Sebastian Reichel Feb. 21, 2021, 8:35 p.m. UTC | #4
[+cc stable@vger.kernel.org]

Hi,

On Sat, Feb 06, 2021 at 04:56:53PM +0100, Sjoerd Simons wrote:
> On Fri, Dec 18, 2020 at 10:23:08PM +0100, Marcel Holtmann wrote:

> > Hi Trent,

> > 

> > > When alt mode 6 is not available, fallback to the kernel <= 5.7 behavior

> > > of always using alt mode 1.

> > > 

> > > Prior to kernel 5.8, btusb would always use alt mode 1 for WBS (Wide

> > > Band Speech aka mSBC aka transparent SCO).  In commit baac6276c0a9

> > > ("Bluetooth: btusb: handle mSBC audio over USB Endpoints") this

> > > was changed to use alt mode 6, which is the recommended mode in the

> > > Bluetooth spec (Specifications of the Bluetooth System, v5.0, Vol 4.B

> > > §2.2.1).  However, many if not most BT USB adapters do not support alt

> > > mode 6.  In fact, I have been unable to find any which do.

> 

> > patch has been applied to bluetooth-next tree.

> 

> For easier application to the stable tree(s) this should probably get:

>   Fixes: baac6276c0a9 ("Bluetooth: btusb: handle mSBC audio over USB Endpoints")

> 

> In my testing this indeed fixes mSBC audio with both a Belkin (Broadcom

> BCM20702A, 050d:065a) and an Intel Bluetooth (8087:0a2b) adapters.

> 

>   Tested-By: Sjoerd Simons <sjoerd@collabora.com>


Tested on Intel AX200 Bluetooth (8087:0029):

Tested-by: Sebastian Reichel <sre@kernel.org>


The patch has been merged to Linus' tree today and I think it should
be applied to the 5.10 tree, which is used by Debian. This patch is
required to use BT headset with bidirectional-audio in acceptable
quality (That also requires proper userspace software, e.g. pipewire
0.3.22, which Sjoerd uploaded to Debian experimental).

Patch applies cleanly on 5.10.

Thanks,

-- Sebastian
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 03b83aa91277..1b690164ab5b 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -506,7 +506,6 @@  static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
 #define BTUSB_HW_RESET_ACTIVE	12
 #define BTUSB_TX_WAIT_VND_EVT	13
 #define BTUSB_WAKEUP_DISABLE	14
-#define BTUSB_USE_ALT1_FOR_WBS	15
 
 struct btusb_data {
 	struct hci_dev       *hdev;
@@ -1736,15 +1735,12 @@  static void btusb_work(struct work_struct *work)
 				new_alts = data->sco_num;
 			}
 		} else if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_TRANSP) {
-			/* Check if Alt 6 is supported for Transparent audio */
-			if (btusb_find_altsetting(data, 6)) {
-				data->usb_alt6_packet_flow = true;
-				new_alts = 6;
-			} else if (test_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags)) {
-				new_alts = 1;
-			} else {
-				bt_dev_err(hdev, "Device does not support ALT setting 6");
-			}
+			/* Bluetooth USB spec recommends alt 6 (63 bytes), but
+			 * many adapters do not support it.  Alt 1 appears to
+			 * work for all adapters that do not have alt 6, and
+			 * which work with WBS at all.
+			 */
+			new_alts = btusb_find_altsetting(data, 6) ? 6 : 1;
 		}
 
 		if (btusb_switch_alt_setting(hdev, new_alts) < 0)
@@ -4548,10 +4544,6 @@  static int btusb_probe(struct usb_interface *intf,
 		 * (DEVICE_REMOTE_WAKEUP)
 		 */
 		set_bit(BTUSB_WAKEUP_DISABLE, &data->flags);
-		if (btusb_find_altsetting(data, 1))
-			set_bit(BTUSB_USE_ALT1_FOR_WBS, &data->flags);
-		else
-			bt_dev_err(hdev, "Device does not support ALT setting 1");
 	}
 
 	if (!reset)