Skip to content

Commit 0560c9c

Browse files
pavhofmangregkh
authored andcommitted
usb: gadget: f_uac2: fixed EP-IN wMaxPacketSize
Async feedback patches broke enumeration on Windows 10 previously fixed by commit 789ea77 ("usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot"). While the existing calculation for EP OUT capture for async mode yields size+1 frame due to uac2_opts->fb_max > 0, playback side lost the +1 feature. Therefore the +1 frame addition must be re-introduced for playback. Win10 enumerates the device only when both EP IN and EP OUT max packet sizes are (at least) +1 frame. Fixes: e89bb42 ("usb: gadget: u_audio: add real feedback implementation") Cc: stable <[email protected]> Tested-by: Henrik Enquist <[email protected]> Tested-by: Jack Pham <[email protected]> Signed-off-by: Pavel Hofman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 04d2b75 commit 0560c9c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/usb/gadget/function/f_uac2.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,17 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
674674
ssize = uac2_opts->c_ssize;
675675
}
676676

677-
if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ASYNC))
677+
if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ASYNC)) {
678+
// Win10 requires max packet size + 1 frame
678679
srate = srate * (1000 + uac2_opts->fb_max) / 1000;
679-
680-
max_size_bw = num_channels(chmask) * ssize *
681-
DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
680+
// updated srate is always bigger, therefore DIV_ROUND_UP always yields +1
681+
max_size_bw = num_channels(chmask) * ssize *
682+
(DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))));
683+
} else {
684+
// adding 1 frame provision for Win10
685+
max_size_bw = num_channels(chmask) * ssize *
686+
(DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))) + 1);
687+
}
682688
ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
683689
max_size_ep));
684690

0 commit comments

Comments
 (0)