Skip to contentSkip to conversation

patch "usb: gadget: f_uac2: always increase endpoint max_packet_size by one" added to usb-linus

PATCH [email protected] 1 participant 1 message Mar 3, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

usb: gadget: f_uac2: always increase endpoint max_packet_size by one

to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From 089a8b8c66349bc065ea9e865c68872e7cac8bf1 Mon Sep 17 00:00:00 2001
From: Ruslan Bilovol <[email protected]>
Date: Mon, 1 Mar 2021 13:49:31 +0200
Subject: usb: gadget: f_uac2: always increase endpoint max_packet_size by one
audio slot

As per UAC2 Audio Data Formats spec (2.3.1.1 USB Packets), if the sampling rate is a constant, the allowable variation of number of audio slots per virtual frame is +/- 1 audio slot.

It means that endpoint should be able to accept/send +1 audio slot.

Previous endpoint max_packet_size calculation code was adding sometimes +1 audio slot due to DIV_ROUND_UP behaviour which was rounding up to closest integer. However this doesn't work if the numbers are divisible.

It had no any impact with Linux hosts which ignore this issue, but in case of more strict Windows it caused rejected enumeration

Thus always add +1 audio slot to endpoint's max packet size

Fixes 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
Cc Peter Chen <[email protected]>
Cc <[email protected]> #v4.3+
---
 drivers/usb/gadget/function/f_uac2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_uac2.c +1 -1
index 5d960b6603b6..6f03e944e0e3 100644
@@ -478,7 +478,7 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	}
 
 	max_size_bw = num_channels(chmask) * ssize *
-		DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
+		((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1);
 	ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
 						    max_size_ep));
 
Signature · 1 line
2.30.1