All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS
@ 2020-12-10  1:20 Trent Piepho
  2020-12-10  1:47 ` bluez.test.bot
  2020-12-18 21:23 ` [PATCH] " Marcel Holtmann
  0 siblings, 2 replies; 5+ messages in thread
From: Trent Piepho @ 2020-12-10  1:20 UTC (permalink / raw)
  To: linux-bluetooth, linux-kernel
  Cc: Hilda Wu, Sathish Narasimman, Chethan T N, Hsin-Yu Chao,
	Amit K Bag, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Trent Piepho

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(-)

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)
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: Bluetooth: btusb: Always fallback to alt 1 for WBS
  2020-12-10  1:20 [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS Trent Piepho
@ 2020-12-10  1:47 ` bluez.test.bot
  2020-12-18 21:23 ` [PATCH] " Marcel Holtmann
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2020-12-10  1:47 UTC (permalink / raw)
  To: linux-bluetooth, tpiepho

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS
  2020-12-10  1:20 [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS Trent Piepho
  2020-12-10  1:47 ` bluez.test.bot
@ 2020-12-18 21:23 ` Marcel Holtmann
  2021-02-06 15:56   ` Sjoerd Simons
  1 sibling, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2020-12-18 21:23 UTC (permalink / raw)
  To: Trent Piepho
  Cc: linux-bluetooth, LKML, Hilda Wu, Sathish Narasimman, Chethan T N,
	Hsin-Yu Chao, Amit K Bag, Johan Hedberg, Luiz Augusto von Dentz

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS
  2020-12-18 21:23 ` [PATCH] " Marcel Holtmann
@ 2021-02-06 15:56   ` Sjoerd Simons
  2021-02-21 20:35     ` Sebastian Reichel
  0 siblings, 1 reply; 5+ messages in thread
From: Sjoerd Simons @ 2021-02-06 15:56 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Trent Piepho, linux-bluetooth, LKML, Hilda Wu,
	Sathish Narasimman, Chethan T N, Hsin-Yu Chao, Amit K Bag,
	Johan Hedberg, Luiz Augusto von Dentz, kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS
  2021-02-06 15:56   ` Sjoerd Simons
@ 2021-02-21 20:35     ` Sebastian Reichel
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2021-02-21 20:35 UTC (permalink / raw)
  To: stable
  Cc: Marcel Holtmann, Trent Piepho, linux-bluetooth, LKML, Hilda Wu,
	Sathish Narasimman, Chethan T N, Hsin-Yu Chao, Amit K Bag,
	Johan Hedberg, Luiz Augusto von Dentz, kernel, Sjoerd Simons

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

[+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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-21 20:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10  1:20 [PATCH] Bluetooth: btusb: Always fallback to alt 1 for WBS Trent Piepho
2020-12-10  1:47 ` bluez.test.bot
2020-12-18 21:23 ` [PATCH] " Marcel Holtmann
2021-02-06 15:56   ` Sjoerd Simons
2021-02-21 20:35     ` Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.