blob: ce55bec2166491cb45bd1737ec8f49f85a9012f4 [file] [log] [blame]
From 8b055741a8178f841205144a0271a9def50a1375 Mon Sep 17 00:00:00 2001
From: Michael Sun <michaelfsun@google.com>
Date: Sun, 15 Aug 2021 23:42:54 -0700
Subject: [PATCH] CHROMIUM: Bluetooth: btusb: define HCI packet sizes of USB
Alts
CHROMIUM: Bluetooth: btusb: define HCI packet sizes of USB Alts
It is desirable to define the HCI packet payload sizes of
USB alternate settings so that they can be exposed to user space.
This is some kind of a reland of crrev/2714095, check that CL for
more context.
BUG=b:175350512,b:160439174
TEST=Uprev any Intel/RTL chip to kernel v5.10 and verify WBS works
Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Change-Id: I9c7e760d9e4a076a1a41f8851290d51d809255b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2882998
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Commit-Queue: Archie Pusaka <apusaka@chromium.org>
Tested-by: Archie Pusaka <apusaka@chromium.org>
BUG=b:175350512,b:160439174, b:194836445
TEST=WBS on Guybrush with Kernel 5.10 works
Disallow-Recycled-Builds: test-failures
Cq-Depend: chromium:3096954
Change-Id: Id8fa87a706fd831f6a4303de279d7381e17f9238
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3096955
Reviewed-by: Archie Pusaka <apusaka@chromium.org>
Commit-Queue: Michael Sun <michaelfsun@google.com>
Tested-by: Michael Sun <michaelfsun@google.com>
---
drivers/bluetooth/btusb.c | 23 +++++++++++++++++++++++
include/net/bluetooth/hci_core.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 0cc470a448df80ab1483f2e900fa95c007513634..903b4553ff0a0a4c2095c35fb0803deb59d658da 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -613,6 +613,23 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
#define BTUSB_WAKEUP_AUTOSUSPEND 14
#define BTUSB_USE_ALT3_FOR_WBS 15
+
+/* Per core spec 5, vol 4, part B, table 2.1,
+ * list the hci packet payload sizes for various ALT settings.
+ * This is used to set the packet length for the wideband sppech.
+ * If a controller does not probe its usb alt setting, the default
+ * value will be 0. Any clients at upper layers should interpret it
+ * as a default value and set a proper packet length accordingly.
+ *
+ * To calcuate the HCI packet payload length:
+ * for alternate settings 1 - 5:
+ * hci_packet_size = suggested_max_packet_size * 3 (packets) -
+ * 3 (HCI header octets)
+ * for alternate setting 6:
+ * hci_packet_size = suggested_max_packet_size - 3 (HCI header octets)
+ */
+static const int hci_packet_size_usb_alt[] = { 0, 24, 48, 72, 96, 144, 60 };
+
struct btusb_data {
struct hci_dev *hdev;
struct usb_device *udev;
@@ -3889,6 +3906,12 @@ static int btusb_probe(struct usb_interface *intf,
/* Interface orders are hardcoded in the specification */
data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1);
data->isoc_ifnum = ifnum_base + 1;
+ hdev->wbs_pkt_len =
+ hci_packet_size_usb_alt[btusb_find_altsetting(data, 6) ?
+ 6 :
+ btusb_find_altsetting(data, 3) ?
+ 3 :
+ 1];
}
if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 75d2fcbfd427a0c311ffc0874232b6a8d6ff8385..6f09283595a75fd616459c81a8157893502bce2a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -492,6 +492,7 @@ struct hci_dev {
unsigned int sco_pkts;
unsigned int le_pkts;
unsigned int iso_pkts;
+ unsigned int wbs_pkt_len;
__u16 block_len;
__u16 block_mtu;
--
2.38.1.584.g0f3c55d4c2-goog