mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Julian Scheel <julian@jusst.de>
Cc: Eugeniu Rosca <roscaeugeniu@gmail.com>,
	Felipe Balbi <balbi@kernel.org>,
	Felipe Balbi <felipe.balbi@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Eugeniu Rosca <erosca@de.adit-jv.com>,
	Takashi Iwai <tiwai@suse.de>
Subject: Re: [PATCHv2 3/3] usb: gadget: f_uac*: Support multiple sampling rates
Date: Mon, 2 Jul 2018 18:30:13 +0200	[thread overview]
Message-ID: <20180702162436.GA3496@vmlxhi-102.adit-jv.com> (raw)
In-Reply-To: <2333fe05-da2e-e6f6-931a-16fce2980f17@jusst.de>

Hi Julian,

[CC:Takashi, since we are discussing sound-related parts of USB]

On Mon, Jul 02, 2018 at 04:07:19PM +0200, Julian Scheel wrote:
> Hi Eugeniu,
> 
> On 30.06.2018 20:16, Eugeniu Rosca wrote:
> > Would it be possible to revive the uac2 multiple sampling rate
> > patch-set [1] by rebasing it onto the most recent kernel? If you
> > don't have time for this, I could help you.
> 
> I have this on my todo-list for a while now... In fact I fixed the build
> errors reported by the robot last year, but didn't had the time to
> verify all of it and push again.
> Still, I'd be happy to get this merged, so I'll try to check the state
> of this within the next days and either post to the list or get back to
> you if more work needs to be done.

We've been living with an internally developed uac2 multiple rate
support since June 2015, initially written on top of v3.14. Due to
significant refactoring of uac2 driver brought by v4.13 commit [1], I
went through the comparison between the in-house implementation (which
no more applied cleanly to post-[1] vanilla) and your proposal from [2].

I found a lot things in common, but also a number of differences. The
latter were caused, as example, by internal requirements like:

---<-snip->---
When enabling multiple rates, the application must be aware of this and
needs to reconfigure the device according to the current assigned rate.
ALSA hw parameter refinement is dynamically limited to the actual
assigned rate, the application does not need to close the device on rate
change but just need to restart configuration (snd_pcm_hw_free(),
snd_pcm_hw_params_any()...). snd_hw_params_any() will always provide
the actual assigned rate.
---<-snip->---

The above frees the need for amixer notifications. A PoC/dirty patch
which makes `arecord` work according to this principle is shown in [3].
The way it was tested on our side is:

prereq > connect USB gadget port of H3-Salvator-X to Ubuntu PC
target > create uac2 gadget (scripted)
target > aplay -C -c 2 -r 48000 -f S16_LE -D plughw:UAC2Gadget \
       | aplay    -c 2 -r 48000 -f S16_LE -D entertainment_main
host   > ls -1 sample-*.wav
	sample-11025_hz.wav
	sample-16000_hz.wav
	sample-22000_hz.wav
	sample-32000_hz.wav
	sample-44100_hz.wav
	sample-48000_hz.wav
	sample-8000_hz.wav
	sample-96000_hz.wav
host   > aplay -D hw:<gadget-card-name> -c 2 sample-*.wav
target > Playback of all files is perceived on the target
         (alternatively, the gadget stream can be recorded and compared
	 to original wav files).

Another internal requirement defines the exact behavior of the
target/gadget, depending on the moment at which the host requests
the sample rate change (from gadget point of view):

---<-snip->---
 - If rate changes while refinement is not finished, the call
   to snd_pcm_prepare() will fail and user has to restart again.
 - If rate changes after prepare is done, but stream is not running,
   the call to snd_pcm_start() will fail and user has to restart again.
 - If rate changes while stream is running, it will be signaled as
   xrun (after providing pending frames on capture, as described above).
---<-snip->---

Due to these mentioned requirements, our final solution was a mix
between your and our approaches. I hope we can reach some
understanding what is best suitable for the regular users, so that at
least some core part of the feature is accepted in mainline.

Any comments from Takashi would be greatly appreciated.
I look forward for your re-based patches. Thank you.

Best regards,
Eugeniu.

[1] eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
[2] https://lkml.org/lkml/2017/6/26/91 ("[PATCH 0/3] USB Audio Gadget: \
    Support multiple sampling rates")
[3] https://github.com/erosca/alsa-utils/commit/uac2_test

  reply	other threads:[~2018-07-02 16:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26  7:35 [PATCH 0/3] USB Audio Gadget: " Julian Scheel
2017-06-26  7:35 ` [PATCH 1/3] usb: gadget: f_uac1: Fix endpoint reading Julian Scheel
2017-06-26  7:35 ` [PATCH 2/3] usb: gadget: f_uac*: Reduce code duplication Julian Scheel
2017-06-26 23:39   ` kbuild test robot
2017-06-26  7:35 ` [PATCH 3/3] usb: gadget: f_uac*: Support multiple sampling rates Julian Scheel
2018-06-30 18:16   ` [PATCHv2 " Eugeniu Rosca
2018-07-02 14:07     ` Julian Scheel
2018-07-02 16:30       ` Eugeniu Rosca [this message]
2018-07-02 22:29         ` Ruslan Bilovol
2018-07-05 23:06           ` Eugeniu Rosca
2017-06-30 10:00 [PATCHv2 0/3] USB Audio Gadget: " Julian Scheel
2017-06-30 10:00 ` [PATCHv2 3/3] usb: gadget: f_uac*: " Julian Scheel

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=20180702162436.GA3496@vmlxhi-102.adit-jv.com \
    --to=erosca@de.adit-jv.com \
    --cc=balbi@kernel.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=julian@jusst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=roscaeugeniu@gmail.com \
    --cc=tiwai@suse.de \
    /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

all inboxes | Powered by JetHome®