public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips
@ 2022-09-29 11:44 hildawu
  2022-09-29 11:44 ` [PATCH v3 1/3] Bluetooth: btrtl: Add btrealtek data struct hildawu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: hildawu @ 2022-09-29 11:44 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel, apusaka,
	yinghsu, max.chou, alex_lu, kidman

From: Hilda Wu <hildawu@realtek.com>

Add btrealtek data struct and use definition of vendor flags to manage the
specific chip.

The Bluetooth: btusb: Workaround for spotty SCO quality patch is for
filter out duplicate packet for avoiding spotty SCO quality.
- The comparison of btrtl_usb_recv_isoc here is for invalid handle,
the invalid handle shouldn't appear.
So we try to find out the rule and filter out this.

The Bluetooth: btsub: Ignore zero length of USB packets on ALT 6 patch is
for some Realtek chips need to transmit mSBC data continuously without the
zero length of USB packets.

---
Changes in v3:
 - Use the vendor function to replace btus_recv_isoc.
 - For ignore_usb_alt6_packet_flow, manage the common flag by the vendor private flag.

Changes in v2:
 - Set the proper priv_size to hci_alloc_dev_priv().
 - Separate commits for functions.
---
Thank you for your review and suggestions.

Hilda Wu (3):
  Bluetooth: btrtl: Add btrealtek data struct
  Bluetooth: btusb: Workaround for spotty SCO quality
  Bluetooth:btsub:Ignore zero length of USB packets on ALT 6 for
    specific chip

 drivers/bluetooth/btrtl.c |  34 ++++++++++++
 drivers/bluetooth/btrtl.h |  29 +++++++++++
 drivers/bluetooth/btusb.c | 105 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 165 insertions(+), 3 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH v4 1/2] Bluetooth: btrtl: Add btrealtek data struct
@ 2022-10-05  8:43 hildawu
  2022-10-05  9:19 ` Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips bluez.test.bot
  0 siblings, 1 reply; 8+ messages in thread
From: hildawu @ 2022-10-05  8:43 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel, apusaka,
	yinghsu, max.chou, alex_lu, kidman

From: Hilda Wu <hildawu@realtek.com>

This patch adds a data structure for btrealtek object, and the
definition of vendor behavior flags. It also adds macros to set/test/get
the flags.

Signed-off-by: Hilda Wu <hildawu@realtek.com>
---
Changes in v4:
 - Since the original 0002 patch has no dependency with this 0001 patch.
   So let the 0002 patch submit another.

Changes in v3:
 - Update private flag.

Changes in v2:
 - Set the proper priv_size to hci_alloc_dev_priv().
 - Separate commits for functions.
---
---
 drivers/bluetooth/btrtl.h | 21 +++++++++++++++++++++
 drivers/bluetooth/btusb.c |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
index 2c441bda390a..ebf0101c959b 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -47,6 +47,27 @@ struct rtl_vendor_config {
 	struct rtl_vendor_config_entry entry[];
 } __packed;
 
+enum {
+	REALTEK_ALT6_CONTINUOUS_TX_CHIP,
+
+	__REALTEK_NUM_FLAGS,
+};
+
+struct btrealtek_data {
+	DECLARE_BITMAP(flags, __REALTEK_NUM_FLAGS);
+};
+
+#define btrealtek_set_flag(hdev, nr)					\
+	do {								\
+		struct btrealtek_data *realtek = hci_get_priv((hdev));	\
+		set_bit((nr), realtek->flags);				\
+	} while (0)
+
+#define btrealtek_get_flag(hdev)					\
+	(((struct btrealtek_data *)hci_get_priv(hdev))->flags)
+
+#define btrealtek_test_flag(hdev, nr)	test_bit((nr), btrealtek_get_flag(hdev))
+
 #if IS_ENABLED(CONFIG_BT_RTL)
 
 struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 271963805a38..4243936c0583 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3755,6 +3755,9 @@ static int btusb_probe(struct usb_interface *intf,
 		/* Override the rx handlers */
 		data->recv_event = btusb_recv_event_intel;
 		data->recv_bulk = btusb_recv_bulk_intel;
+	} else if (id->driver_info & BTUSB_REALTEK) {
+		/* Allocate extra space for Realtek device */
+		priv_size += sizeof(struct btrealtek_data);
 	}
 
 	data->recv_acl = hci_recv_frame;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH v2 1/3] Bluetooth: btrtl: Add btrealtek data struct
@ 2022-09-13 10:02 hildawu
  2022-09-13 11:11 ` Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips bluez.test.bot
  0 siblings, 1 reply; 8+ messages in thread
From: hildawu @ 2022-09-13 10:02 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel, apusaka,
	yinghsu, max.chou, alex_lu, kidman

From: Hilda Wu <hildawu@realtek.com>

This patch adds a data structure for btrealtek object, and the
definition of vendor behavior flags. It also adds macros to set/test/get
the flags.

Signed-off-by: Hilda Wu <hildawu@realtek.com>
---
Changes in v2:
 - Set the proper priv_size to hci_alloc_dev_priv().
 - Separate commits for functions.
---
---
 drivers/bluetooth/btrtl.h | 22 ++++++++++++++++++++++
 drivers/bluetooth/btusb.c |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
index 2c441bda390a..e2c99684799a 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -47,6 +47,28 @@ struct rtl_vendor_config {
 	struct rtl_vendor_config_entry entry[];
 } __packed;
 
+enum {
+	REALTEK_WBS_FILTER,
+	REALTEK_ALT6_CONTINUOUS_TX_CHIP,
+
+	__REALTEK_NUM_FLAGS,
+};
+
+struct btrealtek_data {
+	DECLARE_BITMAP(flags, __REALTEK_NUM_FLAGS);
+};
+
+#define btrealtek_set_flag(hdev, nr)					\
+	do {								\
+		struct btrealtek_data *realtek = hci_get_priv((hdev));	\
+		set_bit((nr), realtek->flags);				\
+	} while (0)
+
+#define btrealtek_get_flag(hdev)					\
+	(((struct btrealtek_data *)hci_get_priv(hdev))->flags)
+
+#define btrealtek_test_flag(hdev, nr)	test_bit((nr), btrealtek_get_flag(hdev))
+
 #if IS_ENABLED(CONFIG_BT_RTL)
 
 struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c3daba17de7f..4c3aed89ff05 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -3749,6 +3749,9 @@ static int btusb_probe(struct usb_interface *intf,
 		/* Override the rx handlers */
 		data->recv_event = btusb_recv_event_intel;
 		data->recv_bulk = btusb_recv_bulk_intel;
+	} else if (id->driver_info & BTUSB_REALTEK) {
+		/* Allocate extra space for Realtek device */
+		priv_size += sizeof(struct btrealtek_data);
 	}
 
 	data->recv_acl = hci_recv_frame;
-- 
2.17.1


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

end of thread, other threads:[~2022-10-05  9:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29 11:44 [PATCH v3 0/3] Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips hildawu
2022-09-29 11:44 ` [PATCH v3 1/3] Bluetooth: btrtl: Add btrealtek data struct hildawu
2022-09-29 12:11   ` Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips bluez.test.bot
2022-09-29 11:44 ` [PATCH v3 2/3] Bluetooth: btusb: Workaround for spotty SCO quality hildawu
2022-09-29 19:35   ` Luiz Augusto von Dentz
2022-09-29 11:44 ` [PATCH v3 3/3] Bluetooth:btsub:Ignore zero length of USB packets on ALT 6 for specific chip hildawu
  -- strict thread matches above, loose matches on Subject: below --
2022-10-05  8:43 [PATCH v4 1/2] Bluetooth: btrtl: Add btrealtek data struct hildawu
2022-10-05  9:19 ` Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips bluez.test.bot
2022-09-13 10:02 [PATCH v2 1/3] Bluetooth: btrtl: Add btrealtek data struct hildawu
2022-09-13 11:11 ` Bluetooth: Add btrealtek data struct and improve SCO sound quality of RTK chips bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox