From: Jerome Brunet <jbrunet@baylibre.com>
To: Pavel Hofman <pavel.hofman@ivitera.com>, linux-usb@vger.kernel.org
Cc: Ruslan Bilovol <ruslan.bilovol@gmail.com>,
Felipe Balbi <balbi@kernel.org>, Jack Pham <jackp@codeaurora.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v2] usb: gadget: f_uac2: fixed EP-IN wMaxPacketSize
Date: Tue, 05 Oct 2021 10:59:31 +0200 [thread overview]
Message-ID: <1jmtnnvo2x.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20211005084436.6812-1-pavel.hofman@ivitera.com>
On Tue 05 Oct 2021 at 10:44, Pavel Hofman <pavel.hofman@ivitera.com> wrote:
> Async feedback patches broke enumeration on Windows 10 previously fixed
> by commit 789ea77310f0 ("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.
>
> Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
> Fixes: e89bb4288378 ("usb: gadget: u_audio: add real feedback
> implementation")
> Cc: stable@vger.kernel.org
> Tested-by: Henrik Enquist <henrik.enquist@gmail.com>
> Tested-by: Jack Pham <jackp@codeaurora.org>
> ---
> drivers/usb/gadget/function/f_uac2.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
> index 17a7ab2c799c..5c7eddf511e5 100644
> --- a/drivers/usb/gadget/function/f_uac2.c
> +++ b/drivers/usb/gadget/function/f_uac2.c
> @@ -665,11 +665,17 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
> ssize = uac2_opts->c_ssize;
> }
>
> - if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ASYNC))
> + if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ASYNC)) {
> + // Win10 requires max packet size + 1 frame
Actually it is not really about windows 10, but more about the USB Audio
Format specification:
see https://www.usb.org/sites/default/files/USB%20Audio%20v3.0_0.zip
section 2.3.1.2.1
Windows 10 is just picky about what the SIP size should be.
> srate = srate * (1000 + uac2_opts->fb_max) / 1000;
> -
> - max_size_bw = num_channels(chmask) * ssize *
> - DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1)));
> + // updated srate is always bigger, therefore DIV_ROUND_UP always yields +1
> + max_size_bw = num_channels(chmask) * ssize *
> + (DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))));
Doing DIV_ROUND_UP is actually right for
if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ADAPTIVE))
otherwise, it should be rounded down + 1.
I'll reply with my version of the patch to make things more clear
> + } else {
> + // adding 1 frame provision for Win10
> + max_size_bw = num_channels(chmask) * ssize *
> + (DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))) + 1);
> + }
> ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw,
> max_size_ep));
next prev parent reply other threads:[~2021-10-05 9:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 8:44 [PATCH v2] usb: gadget: f_uac2: fixed EP-IN wMaxPacketSize Pavel Hofman
2021-10-05 8:59 ` Jerome Brunet [this message]
2021-10-05 9:37 ` [RFC PATCH 1/2] usb: gadget: uac2: fix maximum bandwidth calculation Jerome Brunet
2021-10-05 9:37 ` [RFC PATCH 2/2] usb: gadget: u_audio: remove fb_max Jerome Brunet
2021-10-05 10:00 ` [RFC PATCH 1/2] usb: gadget: uac2: fix maximum bandwidth calculation Pavel Hofman
2021-10-05 10:13 ` Jerome Brunet
2021-10-05 11:12 ` Pavel Hofman
2021-10-05 16:24 ` Jerome Brunet
2021-10-06 12:08 ` Pavel Hofman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1jmtnnvo2x.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jackp@codeaurora.org \
--cc=linux-usb@vger.kernel.org \
--cc=pavel.hofman@ivitera.com \
--cc=ruslan.bilovol@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox