From: Jerome Brunet <jbrunet@baylibre.com>
To: Pavel Hofman <pavel.hofman@ivitera.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: Ruslan Bilovol <ruslan.bilovol@gmail.com>,
Felipe Balbi <balbi@kernel.org>
Subject: Re: usb:gadget:u_audio: Regression in [v3,3/3] usb: gadget: u_audio: add real feedback implementation - wMaxPacketSize calculation
Date: Thu, 15 Jul 2021 15:53:22 +0200 [thread overview]
Message-ID: <1jbl73ptt9.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <94718a5e-ea36-4a86-da4d-a30179c1c2c7@ivitera.com>
On Thu 15 Jul 2021 at 14:36, Pavel Hofman <pavel.hofman@ivitera.com> wrote:
> Dne 15. 07. 21 v 11:39 Jerome Brunet napsal(a):
>> On Tue 13 Jul 2021 at 15:16, Pavel Hofman <pavel.hofman@ivitera.com>
>> wrote:
>>
>> So 48kHz / 2ch / 16bits. Let's assume USB_SPEED_FULL for example (result
>> is the same for the other speeds).
>> In such condition, the nominal packet size is 192B but to accomodate an
>> extra sample, the maximum should indeed be 196B.
>> if (!is_playback && (uac2_opts->c_sync == USB_ENDPOINT_SYNC_ASYNC))
>> srate = srate * (1000 + uac2_opts->fb_max) / 1000;
>> with fb_max being 5 by default, srate should be 48240 after this.
>>
>> max_size_bw = num_channels(chmask) * ssize *
>> DIV_ROUND_UP(srate, factor / (1 << (bInterval - 1)));
>> With USB_SPEED_FULL, bInterval is 1 and factor is 1000 so:
>> => DIV_ROUND_UP(48240, 1000 / 1) should give 49;
>> Then
>> => max_size_bw = 2 * 2 * 49 = 196
>> So the end result should be 196 with current code. I tried on an ARM64
>> platform. Here is what I get:
>> [ 26.241946] set_ep_max_packet_size: speed is USB_SPEED_FULL
>> [ 26.243208] set_ep_max_packet_size: intermediate Playback srate 48000
>> [ 26.249758] set_ep_max_packet_size: max_size_bw 192
>> [ 26.254559] set_ep_max_packet_size: speed is USB_SPEED_FULL
>> [ 26.260130] set_ep_max_packet_size: intermediate Capture srate 48240
>> [ 26.266401] set_ep_max_packet_size: max_size_bw 196
>> [ 26.271209] set_ep_max_packet_size: speed is USB_SPEED_HIGH
>> [ 26.276873] set_ep_max_packet_size: intermediate Playback srate 48000
>> [ 26.283165] set_ep_max_packet_size: max_size_bw 192
>> [ 26.288015] set_ep_max_packet_size: speed is USB_SPEED_HIGH
>> [ 26.293691] set_ep_max_packet_size: intermediate Capture srate 48240
>> [ 26.299965] set_ep_max_packet_size: max_size_bw 196
>> [ 26.304753] set_ep_max_packet_size: speed is USB_SPEED_SUPER
>> [ 26.310426] set_ep_max_packet_size: intermediate Playback srate 48000
>> [ 26.316805] set_ep_max_packet_size: max_size_bw 192
>> [ 26.321625] set_ep_max_packet_size: speed is USB_SPEED_SUPER
>> [ 26.327309] set_ep_max_packet_size: intermediate Capture srate 48240
>> [ 26.333613] set_ep_max_packet_size: max_size_bw 196
>> All seems OK and as expected with what's in mainline ATM.
>> So I'm not quite sure why you would get a different result. It would be
>> great if you could check further.
>>
>
> The problem is max_size_bw=192 for the Playback (i.e. is_playback =
> true). If only capture direction is activated (p_chmask=0), only EP-OUT
> with max_size_bw=196 is generated and Win10 enumerates the playback-only
> audio device.
Ok, that was not clear before.
> Once the other direction with max_size_bw=192 is activated
> (either duplex or capture-only), Win10 refuses to enumerate.
Looking further at the format specification [0] (and crawling the web to
decipher it), it seems that
* For isochronous links: packet size must match the nominal rate.
* For async and adaptative: it must match the nominal rate +/- 1
packet. That is whether we intend on varying the packet size or not.
This has several implication
* In async mode, the device is running of its own clock. It has no
reason to vary the playback packet size but it should still reserve
bandwidth for an extra packet to satisfy the spec. This seems to be
your problem and what Win10 insist on.
When I tested, I had linux on both sides and apparently it is not too
picky about that.
* If we apply the spec strictly, like Win10 seems to insist on,
calculating the maximum packet size based on explicit feedback limits
is wrong too. Whatever happens, it should be +/- 1 around nominal.
Funny thing, is your change puts a +2 capture compared to nominal but
Win10 is not picky on that ...
I'll send a fix to clean this up. Thanks reporting the problem.
[0]: https://www.usb.org/sites/default/files/frmts10.pdf
next prev parent reply other threads:[~2021-07-15 13:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-13 10:22 usb:gadget:u_audio: Regression in [v3,3/3] usb: gadget: u_audio: add real feedback implementation - wMaxPacketSize calculation Pavel Hofman
2021-07-13 10:49 ` Greg KH
2021-07-13 12:05 ` Jerome Brunet
2021-07-13 12:32 ` Felipe Balbi
2021-07-13 13:16 ` Pavel Hofman
2021-07-13 13:28 ` Pavel Hofman
2021-07-15 9:39 ` Jerome Brunet
2021-07-15 12:36 ` Pavel Hofman
2021-07-15 13:53 ` Jerome Brunet [this message]
2021-07-15 14:22 ` Pavel Hofman
2021-07-15 17:52 ` Jassi Brar
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=1jbl73ptt9.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=balbi@kernel.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