From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Wesley Cheng <quic_wcheng@quicinc.com>,
srinivas.kandagatla@linaro.org, mathias.nyman@intel.com,
perex@perex.cz, conor+dt@kernel.org, corbet@lwn.net,
broonie@kernel.org, lgirdwood@gmail.com, krzk+dt@kernel.org,
Thinh.Nguyen@synopsys.com, bgoswami@quicinc.com, tiwai@suse.com,
gregkh@linuxfoundation.org, robh@kernel.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-sound@vger.kernel.org, linux-usb@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-doc@vger.kernel.org,
alsa-devel@alsa-project.org
Subject: Re: [PATCH v24 23/34] ALSA: usb-audio: Prevent starting of audio stream if in use
Date: Thu, 8 Aug 2024 16:54:07 +0200 [thread overview]
Message-ID: <e5cd1a9d-0a16-4c80-b9b9-1c63b8e818cc@linux.intel.com> (raw)
In-Reply-To: <24a224a2-0600-4ee2-989e-02224ef849ba@linux.intel.com>
On 8/8/2024 2:36 PM, Pierre-Louis Bossart wrote:
>
>
> On 8/8/24 14:11, Amadeusz Sławiński wrote:
>> On 8/8/2024 3:19 AM, Wesley Cheng wrote:
>>> Hi Amadeusz,
>>>
>>> On 8/6/2024 7:51 AM, Amadeusz Sławiński wrote:
>>>> On 8/1/2024 3:17 AM, Wesley Cheng wrote:
>>>>> With USB audio offloading, an audio session is started from the ASoC
>>>>> platform sound card and PCM devices. Likewise, the USB SND path is
>>>>> still
>>>>> readily available for use, in case the non-offload path is desired. In
>>>>> order to prevent the two entities from attempting to use the USB bus,
>>>>> introduce a flag that determines when either paths are in use.
>>>>>
>>>>
>>>> How can this happen? Can you provide some example with list of
>>>> devices and which one should block the other? If I recall correctly
>>>> devices are already exclusive unless you support substreams which
>>>> ASoC does not at the moment.
>>>>
>>> From past discussions, I think so far everyone is on board with the
>>> idea of having both the USB sound card and PCM devices exist in
>>> conjunction w/ the USB offload path, which is going to be done over
>>> the ASoC platform card. So for example,
>>>
>>
>> Sorry, I must have missed that and examples in documentation could
>> probably be a bit better, it is bit late at patchset 24 that I
>> understood about this now. And is part of a reason why I was confused
>> about kcontrol implementation.
>>
>>> / # cat /proc/asound/cards
>>> 0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
>>> SM8250-MTP-WCD9380-WSA8810-VA-DMIC
>>> 1 [C320M ]: USB-Audio - Plantronics C320-M
>>> Plantronics Plantronics C320-M at usb-xhci-
>>> hcd.1.auto-1.2, full speed
>>>
>>> This device currently has the following sound cards within the system:
>>>
>>> - card#0 - ASoC platform card: handles USB offload, speaker, etc...
>>>
>>> - card#1 - USB SND card: card created for interacting with the
>>> connected USB device.
>>>
>>> So now, with USB offloading in the picture, there are basically two
>>> paths that can start attempting to utilize the same USB device
>>> endpoints. Let's keep it simple and assume the device only has one
>>> playback substream (which means only one PCM device)
>>>
>>> /proc/asound/card1 # cat stream0
>>> Plantronics Plantronics C320-M at usb-xhci-hcd.1.auto-1.2, full
>>> speed : USB Audio
>>>
>>> Playback:
>>> Status: Stop
>>> Interface 2
>>> Altset 1
>>> Format: S16_LE
>>> Channels: 2
>>> Endpoint: 0x01 (1 OUT) (ADAPTIVE)
>>> Rates: 8000, 16000, 24000, 32000, 44100, 48000
>>> Bits: 16
>>> Channel map: FL FR
>>>
>>> So the patch here will prevent transfers from happening from both the
>>> offload path and directly over the USB SND PCM device, which
>>> correlates to the following paths:
>>>
>>> - offload: card#0 pcm#0
>>>
>>> - USB SND: card#1 pcm#0
>>
>> Well, it's one way to do that.
>>
>> Personally I would just reuse USB FEs and when opening one check if it
>> can be offloaded:
>> * check if someone disabled Offload on FE
>> * check if it is connected to HW that can do Offload at all
>> * check if Offload streams are available on backing HW
>> * check if audio formats are supported by above HW
>> * do any other checks that may be needed
>> and then just redirect FE setup to relevant driver doing offload if
>> able, otherwise just go standard path.
>
> How would userspace know which 'USB FE' to use?
>
That's my point, the same one as it would use doing normal
playback/capture on systems which don't have Offload.
If I attach USB Headphones, as a user my expectation would be to use
playback FE on USB card it exposes, not to spend time setting some
controls and telling it to use some FE from other card.
With current design there are _two_ separate FEs, on _two_ separate
cards, which are linked by kcontrol and which block each other. I'm
rather confused how basic userspace application knows which one to use
in this case. (By now of course I know that it needs to read kcontrol to
see if and where it is offloaded and then open the FE on the card, but
in my opinion it is unnecessarily convoluted.)
> The discovery and mapping between cards and devices is the main problem.
>
And "offloading" decision to the user/sound server/HAL doesn't help in
my opinion.
> It's much simpler to start from a generic "USB-Audio" card, and check if
> the functionality exposed by one PCM device is offloaded to another
> ASoC-based card. Then all the interaction can start with this offloaded
> device without any guesswork on the mapping between cards/devices.
>
That's the point, currently there needs to be some guesswork involved,
because you need to check kcontrols to see if the endpoint can be
offloaded and open the other FE it points at, instead of directly
opening the one you usually would, and having it Offloaded by kernel. It
is adding more work on userspace side, which will require special
handling to work correctly.
> The point is that the USB-Audio card will always be there, whereas those
> ASoC cards will have different names and implementation restrictions. In
> the example we have here, if you want to capture audio you *have* to use
> the USB-Audio card.
>
Yes and with the description above it would be just one of the checks
after which it would decide that it can't do Offload on capture path and
open it in standard way, I see no problem?
> In other words, it's just an endianness type of debate with no clear
> difference between solutions and a matter of personal preference. The
> reality is that there's a clear asymmetrical pattern. The USB-Audio card
> is always present and usable, the ASoC offloaded cards are only present
> in specific implementations and only usable if conditions are met.
In my opinion even if it is specific use case, there is no reason to
make it more complicated than it needs to be. From my point of view
problem with current design is that instead of being mostly transparent
to userspace (when it could be), it adds more work for it.
next prev parent reply other threads:[~2024-08-08 14:54 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 1:16 [PATCH v24 00/34] Introduce QC USB SND audio offloading support Wesley Cheng
2024-08-01 1:16 ` [PATCH v24 01/34] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2024-08-01 1:16 ` [PATCH v24 02/34] usb: host: xhci: Repurpose event handler for skipping interrupter events Wesley Cheng
2024-08-01 1:16 ` [PATCH v24 03/34] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2024-08-06 14:49 ` Amadeusz Sławiński
2024-08-20 18:03 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 04/34] usb: xhci: Allow for secondary interrupter to set IMOD Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 05/34] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2024-08-06 14:50 ` Amadeusz Sławiński
2024-08-20 18:18 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 06/34] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2024-08-06 14:50 ` Amadeusz Sławiński
2024-08-01 1:17 ` [PATCH v24 07/34] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 08/34] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 09/34] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-08-01 8:02 ` Pierre-Louis Bossart
2024-08-01 21:43 ` Wesley Cheng
2024-08-02 6:26 ` Pierre-Louis Bossart
2024-08-06 19:52 ` Wesley Cheng
2024-08-16 21:48 ` Wesley Cheng
2024-08-19 6:26 ` Pierre-Louis Bossart
2024-08-13 22:57 ` Wesley Cheng
2024-08-14 9:20 ` Pierre-Louis Bossart
2024-08-01 1:17 ` [PATCH v24 10/34] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-08-01 8:07 ` Pierre-Louis Bossart
2024-08-01 22:43 ` Wesley Cheng
2024-08-06 14:51 ` Amadeusz Sławiński
2024-08-08 1:24 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 11/34] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2024-08-01 8:11 ` Pierre-Louis Bossart
2024-08-01 22:46 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 12/34] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-08-01 8:26 ` Pierre-Louis Bossart
2024-08-01 23:50 ` Wesley Cheng
2024-08-06 14:51 ` Amadeusz Sławiński
2024-08-08 1:23 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 13/34] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-08-01 2:22 ` Rob Herring (Arm)
2024-08-01 1:17 ` [PATCH v24 14/34] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 15/34] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-08-01 8:30 ` Pierre-Louis Bossart
2024-08-01 1:17 ` [PATCH v24 16/34] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-08-01 8:33 ` Pierre-Louis Bossart
2024-08-01 23:04 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 17/34] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-08-01 8:40 ` Pierre-Louis Bossart
2024-08-01 23:10 ` Wesley Cheng
2024-08-02 6:32 ` Pierre-Louis Bossart
2024-08-07 20:05 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 18/34] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 19/34] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2024-08-01 8:46 ` Pierre-Louis Bossart
2024-08-01 1:17 ` [PATCH v24 20/34] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-08-01 8:49 ` Pierre-Louis Bossart
2024-08-01 1:17 ` [PATCH v24 21/34] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 22/34] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 23/34] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-08-06 14:51 ` Amadeusz Sławiński
2024-08-08 1:19 ` Wesley Cheng
2024-08-08 12:11 ` Amadeusz Sławiński
2024-08-08 12:36 ` Pierre-Louis Bossart
2024-08-08 14:54 ` Amadeusz Sławiński [this message]
2024-08-08 19:47 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 24/34] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 25/34] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 26/34] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2024-08-01 8:57 ` Pierre-Louis Bossart
2024-08-08 1:03 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 27/34] ALSA: usb-audio: qcom: Use card and PCM index from QMI request Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 28/34] ALSA: usb-audio: qcom: Populate PCM and USB chip information Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 29/34] ALSA: usb-audio: qcom: Add USB offload route kcontrol Wesley Cheng
2024-08-01 9:02 ` Pierre-Louis Bossart
2024-08-08 1:10 ` Wesley Cheng
2024-08-20 2:33 ` Wesley Cheng
2024-08-20 6:39 ` Pierre-Louis Bossart
2024-08-20 17:37 ` Wesley Cheng
2024-08-20 23:38 ` Wesley Cheng
2024-08-21 7:02 ` Pierre-Louis Bossart
2024-08-21 19:21 ` Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 30/34] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 31/34] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 32/34] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 33/34] ASoC: usb: Add PCM format check API for USB backend Wesley Cheng
2024-08-01 1:17 ` [PATCH v24 34/34] ASoC: qcom: qdsp6: Ensure PCM format is supported by USB audio device Wesley Cheng
2024-08-01 9:04 ` Pierre-Louis Bossart
2024-08-01 8:36 ` [PATCH v24 00/34] Introduce QC USB SND audio offloading support Krzysztof Kozlowski
2024-08-01 9:10 ` Pierre-Louis Bossart
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=e5cd1a9d-0a16-4c80-b9b9-1c63b8e818cc@linux.intel.com \
--to=amadeuszx.slawinski@linux.intel.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=alsa-devel@alsa-project.org \
--cc=bgoswami@quicinc.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=quic_wcheng@quicinc.com \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).