From: Jerome Brunet <jbrunet@baylibre.com>
To: Ruslan Bilovol <ruslan.bilovol@gmail.com>, balbi@kernel.org
Cc: Jerome Brunet <jbrunet@baylibre.com>,
linux-usb@vger.kernel.org, gschmottlach@gmail.com,
Pavel Hofman <pavel.hofman@ivitera.com>
Subject: [PATCH v3 0/3] UAC2 Gadget: feedback endpoint support
Date: Fri, 4 Jun 2021 00:01:01 +0200 [thread overview]
Message-ID: <20210603220104.1216001-1-jbrunet@baylibre.com> (raw)
Current UAC2 gadget implements capture/sync paths as two USB ISO ASYNC
endpoints (IN and OUT).
This violates USB spec which says that ISO ASYNC OUT endpoint should
have feedback companion endpoint. See USB2.0 spec "5.12.4.1
Synchronization Type": asynchronous sink provides explicit feedback
(isochronous pipe). Interesting that for ISO ASYNC *IN* endpoint
respective feedback isn't required since source provides implicit
feedforward (data stream).
While it's not an issue if UAC2 Gadget is connected to Linux host (Linux
ignores missing feedback endpoint), with other hosts like Windows or
MacOS the UAC2 Gadget isn't enumerated due to missing feedback endpoint.
This patch series adds feedback endpoint support to UAC2 function, new
control to UAC2 mixer which can be used by userspace tools (like
alsaloop from alsa-utils) for updating feedback frequency reported to
the host. This is useful for usecases when UAC2 Gadget's audio samples
are played to another codec or audio card with its own internal
freerunning clock so host can be notified that more/less samples are
required.
The alsaloop tool requires some (relatively small) modifications in
order to start support driving feedback frequency through UAC2 mixer
control. That change will be sent as a separate patch to ALSA
community.
Also added ability to switch ISO ASYNC OUT endpoint into adaptive
endpoint which doesn't require feedback endpoint (as per USB spec).
v2 [2] -> v3:
* Just fold 9 left shift in the feedback calculation to avoid
dealing with big numbers (as suggested by Pavel Hofman)
v1 [0] -> v2:
* Instead of HW rate used by gadget (which the controlling application
might not be directly dealing with), the kcontrol used to provide the
feedback value is expressed in PPM. This way the correction is
agnostic of the rate used by the gadget while retaining enough
precision to allow a smooth adaptation of the clock on the playback
side, if necessary.
* The minimum value for the correction is aligned with
sound/usb/endpoint.c at -25%.
* The maximum correction must be chosen more carefully as it impact the
bandwidth required by the output EP. The minimum is one extra frame
per packet. This is ~500PPM at 192KHz. This seemed more than enough
while testing.
Of course, there is a trade off between saving bandwidth and enabling
devices with a significant (abnormal) clock deviation. The default
extra reserved bandwidth is set at 500PPM but it is configurable
through configfs, like the rest of the gadget.
I have kept Ruslan assigned as the author of series. He did the vast
majority of the work and deserve the credit. I have merely tweaked in
his original patchset.
This patchset has been tested on an arm64 host at HIGH_SPEED, with
various rates and channel configuration. I have not tested with
FULL_SPEED or SUPER_SPEED.
See here [1] an example of regulation with a patched version of
alsaloop.
[0]: https://lore.kernel.org/r/1604794711-8661-1-git-send-email-ruslan.bilovol@gmail.com
[1]: https://pastebin.com/0hiK7LAe
[2]: https://lore.kernel.org/r/20210430142625.357152-1-jbrunet@baylibre.com
Ruslan Bilovol (3):
usb: gadget: f_uac2/u_audio: add feedback endpoint support
usb: gadget: f_uac2: add adaptive sync support for capture
usb: gadget: u_audio: add real feedback implementation
.../ABI/testing/configfs-usb-gadget-uac2 | 2 +
Documentation/usb/gadget-testing.rst | 2 +
drivers/usb/gadget/function/f_uac2.c | 144 ++++++++++-
drivers/usb/gadget/function/u_audio.c | 225 +++++++++++++++++-
drivers/usb/gadget/function/u_audio.h | 12 +
drivers/usb/gadget/function/u_uac2.h | 4 +
6 files changed, 383 insertions(+), 6 deletions(-)
--
2.32.0.rc0
next reply other threads:[~2021-06-03 22:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 22:01 Jerome Brunet [this message]
2021-06-03 22:01 ` [PATCH v3 1/3] usb: gadget: f_uac2/u_audio: add feedback endpoint support Jerome Brunet
2021-06-03 22:01 ` [PATCH v3 2/3] usb: gadget: f_uac2: add adaptive sync support for capture Jerome Brunet
2021-06-03 22:01 ` [PATCH v3 3/3] usb: gadget: u_audio: add real feedback implementation Jerome Brunet
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=20210603220104.1216001-1-jbrunet@baylibre.com \
--to=jbrunet@baylibre.com \
--cc=balbi@kernel.org \
--cc=gschmottlach@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.