Skip to content

Commit a479e71

Browse files
hildawurVudentz
authored andcommitted
Bluetooth: btusb: Ignore zero length of USB packets on ALT 6 for specific chip
For USB ALT 6 settings some Realtek chips need to transmit mSBC data continuously without the zero length of USB packets. In this commit, create BTUSB_ALT6_CONTINUOUS_TX to manage the behavior. Therefore, create REALTEK_ALT6_CONTINUOUS_TX_CHIP to manage the specific chip model for the behavior. Signed-off-by: Max Chou <[email protected]> Signed-off-by: Hilda Wu <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 5b35594 commit a479e71

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

drivers/bluetooth/btrtl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,13 @@ void btrtl_set_quirks(struct hci_dev *hdev, struct btrtl_device_info *btrtl_dev)
781781
case CHIP_ID_8852C:
782782
set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
783783
set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
784+
785+
/* RTL8852C needs to transmit mSBC data continuously without
786+
* the zero length of USB packets for the ALT 6 supported chips
787+
*/
788+
if (btrtl_dev->project_id == CHIP_ID_8852C)
789+
btrealtek_set_flag(hdev, REALTEK_ALT6_CONTINUOUS_TX_CHIP);
790+
784791
hci_set_aosp_capable(hdev);
785792
break;
786793
default:

drivers/bluetooth/btusb.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ static const struct dmi_system_id btusb_needs_reset_resume_table[] = {
632632
#define BTUSB_TX_WAIT_VND_EVT 13
633633
#define BTUSB_WAKEUP_AUTOSUSPEND 14
634634
#define BTUSB_USE_ALT3_FOR_WBS 15
635+
#define BTUSB_ALT6_CONTINUOUS_TX 16
635636

636637
struct btusb_data {
637638
struct hci_dev *hdev;
@@ -1322,11 +1323,17 @@ static void btusb_isoc_complete(struct urb *urb)
13221323
static inline void __fill_isoc_descriptor_msbc(struct urb *urb, int len,
13231324
int mtu, struct btusb_data *data)
13241325
{
1325-
int i, offset = 0;
1326+
int i = 0, offset = 0;
13261327
unsigned int interval;
13271328

13281329
BT_DBG("len %d mtu %d", len, mtu);
13291330

1331+
/* For mSBC ALT 6 settings some chips need to transmit the data
1332+
* continuously without the zero length of USB packets.
1333+
*/
1334+
if (test_bit(BTUSB_ALT6_CONTINUOUS_TX, &data->flags))
1335+
goto ignore_usb_alt6_packet_flow;
1336+
13301337
/* For mSBC ALT 6 setting the host will send the packet at continuous
13311338
* flow. As per core spec 5, vol 4, part B, table 2.1. For ALT setting
13321339
* 6 the HCI PACKET INTERVAL should be 7.5ms for every usb packets.
@@ -1346,6 +1353,7 @@ static inline void __fill_isoc_descriptor_msbc(struct urb *urb, int len,
13461353
urb->iso_frame_desc[i].length = offset;
13471354
}
13481355

1356+
ignore_usb_alt6_packet_flow:
13491357
if (len && i < BTUSB_MAX_ISOC_FRAMES) {
13501358
urb->iso_frame_desc[i].offset = offset;
13511359
urb->iso_frame_desc[i].length = len;
@@ -2368,6 +2376,19 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
23682376
return -EILSEQ;
23692377
}
23702378

2379+
static int btusb_setup_realtek(struct hci_dev *hdev)
2380+
{
2381+
struct btusb_data *data = hci_get_drvdata(hdev);
2382+
int ret;
2383+
2384+
ret = btrtl_setup_realtek(hdev);
2385+
2386+
if (btrealtek_test_flag(data->hdev, REALTEK_ALT6_CONTINUOUS_TX_CHIP))
2387+
set_bit(BTUSB_ALT6_CONTINUOUS_TX, &data->flags);
2388+
2389+
return ret;
2390+
}
2391+
23712392
/* UHW CR mapping */
23722393
#define MTK_BT_MISC 0x70002510
23732394
#define MTK_BT_SUBSYS_RST 0x70002610
@@ -3969,7 +3990,7 @@ static int btusb_probe(struct usb_interface *intf,
39693990

39703991
if (IS_ENABLED(CONFIG_BT_HCIBTUSB_RTL) &&
39713992
(id->driver_info & BTUSB_REALTEK)) {
3972-
hdev->setup = btrtl_setup_realtek;
3993+
hdev->setup = btusb_setup_realtek;
39733994
hdev->shutdown = btrtl_shutdown_realtek;
39743995
hdev->cmd_timeout = btusb_rtl_cmd_timeout;
39753996

0 commit comments

Comments
 (0)