From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "Amadeusz Sławiński" <amadeuszx.slawinski@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,
robh@kernel.org, gregkh@linuxfoundation.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 v23 32/32] ASoC: doc: Add documentation for SOC USB
Date: Wed, 3 Jul 2024 11:50:21 +0200 [thread overview]
Message-ID: <ab734271-58ee-4981-926c-9b57f36b8ac6@linux.intel.com> (raw)
In-Reply-To: <b1fcef2a-2af9-4985-ae00-f348ca5df3f1@linux.intel.com>
>>>>>> There are really multiple layers to deal with
>>>>>>
>>>>>> a) is the controller able to support the offload path? IIRC this is
>>>>>> embedded in an obscure XHCI property, it would make sense to
>>>>>> expose it
>>>>>> as a control, or component string, of the USB card.
>>>>> If a component string/tag is desired, I already have some way of
>>>>> doing that. I can add it to the USB card.
>>>>>
>>>>>> b) is there a companion card capable of dealing with the offload
>>>>>> path?
>>>>>> Since the presence of this card may depend on driver probe, there
>>>>>> should
>>>>>> be a control on the USB card. userspace could detect changes to this
>>>>>> control and detect if that path is or is no longer enabled.
>>>>> So currently, the "USB Offload Playback Capable Card" kcontrol (on
>>>>> the USB card) will determine if there is an offload path. However,
>>>>> this differs than what Amadeusz is suggesting, in that he wants a
>>>>> single kcontrol created for EACH USB card identified (per USB audio
>>>>> device), and a simple enable/disable control to determine if the
>>>>> offload path is enabled for that card/pcm stream.
>>>>>
>>>>> It would be a simpler approach for the userspace, and if the card
>>>>> that handles the offload card isn't present, then these
>>>>> enable/disable control will be set to "disabled," and even if users
>>>>> attempt to set the control, it won't go through.
>>>> Not following. Are you suggesting userspace would modify the
>>>> enable/disable status?
>>>
>>> Yes, this is the suggestion. One writeable kcontrol on the USB SND
>>> audio device that will control if that USB audio device is going to
>>> be offloaded. If the kcontrol reads back "enabled" (or 1) then
>>> userspace knows that the offload path is active. Else, if it reads
>>> "disabled" (or 0) after the attempt to set the kcontrol, then the
>>> offload path was unsuccessfully enabled, ie maybe due to no available
>>> offload streams.
>>
>> It's a bit over-engineered IMHO.
>>
>> My alternate suggestion is a read-only control reporting that offload is
>> possible. Then userspace attempts to open a PCM device on the ASoC card,
>> any failures due to resources would be handled at that point.
>>
>>>> I would just have a read-only control that reports what the hardware
>>>> can
>>>> do and which other card can deal with offload. It's up to userspace to
>>>> select the offloaded PCM device or not.
>>>>
>>> That is what I have implemented in the previous patch series. One
>>> USB SND kcontrol within each USB audio device, which points to the
>>> ASoC platform card that supports offloading:
>>>
>>> "USB Offload Playback Capable Card" --> returns the card index to the
>>> ASoC platform card
>>>
>>> >From there the offloading control is all within the ASoC platform
>>> card. This is opposite to what Amaduesz suggested in that, the
>>> offload control of which USB device to offload should be within USB
>>> SND (not ASoC)
>>
>> It's very hard to follow, I don't understand what userspace needs to
>> 'control' - in the modify sense. What userspace needs is a place to read
>> from, and then select the PCM device and follow usual ALSA configuration
>> with hw_params.
>>
>
> From what I've seen I assumed that goal is to allow Offloading of
> specific stream from USB card. Otherwise I would say controls are not
> needed at all, as more user friendly solution is Offloading streams in
> order they are used as long as resources are available.
That's not great in terms of audio routing, you'd really want more rules
or controlled behavior where the order in which devices are used does
not matter.
>>>>>> c) which PCM device is actually offloaded? This could be plural
>>>>>> for some
>>>>>> implementations. The mapping between PCM devices exposed by the USB
>>>>>> card, and those exposed by the companion card, should be known to
>>>>>> userspace. I am not sure how this would be done though, a variable
>>>>>> number of controls is a sure way to confuse userspace.
>>>>> Expanding on Amadeusz's suggestion, my idea is to have an
>>>>> enable/disable kcontrol per USB stream. For example, one USB card
>>>>> could have multiple PCM devices (USB streams). So we would have
>>>>> something like:
>>>>>
>>>>> PCM Offload Playback Enable Stream#0 enable/disable
>>>>>
>>>>> PCM Offload Playback Enable Stream#1 enable/disable
>>>>>
>>>>> ....
>>>> are those read-only or not?
>>>
>>> No, writable and readable.
>>
>> The writable part introduces a complicated error handling, e.g. what
>> happens if you have an offloaded stream and then this control is changed
>> with amixer while streaming?
>>
>
> -EBUSY? and keep old value
That would require a stop, fw_free, close, reopening of the
non-offloaded device and restart. Best to avoid interrupting streams, if
there are no resources that should be detected with an early fail during
open/hw_params. Once the stream is flowing, it should not be interrupted
- unless the USB device is removed of course.
>>>>> So we'd know which USB card and PCM device is selected for USB
>>>>> SND. However, I see what you're getting at in case there are
>>>>> multiple supported streams, because userspace needs to know which
>>>>> ASoC card/pcm combination corresponds to which USB device/combination.
>>>> I don't understand how this would help map the two parts? There's
>>>> got to
>>>> be an additional mapping...
>>> It won't help with the mapping. That is something which we'd need to
>>> add, suggestion below.
>>>>> What do you think about having a USB card kcontrol to display the
>>>>> mapped ASoC card and PCM indexes?
>>>>>
>>>>> PCM Offload Playback Enable Stream Mapping#0 0, 1 (ASoC card#0,
>>>>> PCM device#1)
>>>>>
>>>>> To summarize, if we did this, I'd plan to remove all the kcontrols
>>>>> in ASoC card, and have the following in the USB card for an USB
>>>>> audio device that supports one USB stream:
>>>>>
>>>>> PCM Offload Playback Enable Stream#0 enable/disable
>>>>>
>>>>> PCM Offload Playback Enable Stream Mapping#0 0, 1 (ASoC card#0,
>>>>> PCM device#1)
>>>> ... which is suggested here.
>>>>
>>>> Assuming these are read-only controls, we would need to know which PCM
>>>> device on the USB card can be optimized with the use of which PCM
>>>> device
>>>> on the ASoC card. That means a set of three values. You would also want
>>>> a number of streams to make the guesswork on controls less painful.
>>>
>>> OK, so now to just figuring out something that both you and Amadeusz
>>> can agree on before I put time implementing it. So I've implemented
>>> the "enable/disable" path that Amadeusz suggested, which is
>>> highlighted in my previous response, for evaluation purposes. The
>>> overall question is which layer should control the devices that will
>>> be offloaded. In my submissions up until now, the control was given
>>> to the ASoC platform card to determine which USB device to offload.
>>> Amadeusz mentioned that it might be beneficial to move the control to
>>> the USB SND devices, because what if the offloading is NOT backed by
>>> ASoC. (highlighted in [1]) However, IMO the current implementation
>>> assumes there is ASoC involved, which should mean that there is some
>>> platform "card" that is backing the offload path. Please let me know
>>> if my understanding is incorrect, @Amadeusz.
>>
>> I still fundamentally don't get why userspace would try and modify any
>> controls, this makes the flows more complicated IMHO since you also have
>> the PCM open/hw_params stages.
>> I really think it'd be more than enough if the USB card exposed
>> read-only values showing that offload is possible and which card/device
>> to map to. Then userspace uses the ASoC PCM device and errors are
>> handled at that level.
>
> I tend to agree, less values to change, less chance something breaks.
> However I think that there should be some way to disable Offload in case
> something doesn't work properly. (It doesn't have to be control, one can
> go with module parameter or sysfs toggle or something.)
Agree with this, a 'static' configuration to disable offload would be
just fine. Module parameter is fine.
A control to read if offload is possible and what the mapping is would
be good. From there on, userspace may open the offloaded PCM and deal
with all events (hw_params not supported, xruns, removal, etc).
next prev parent reply other threads:[~2024-07-03 9:50 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 23:57 [PATCH v23 00/32] Introduce QC USB SND audio offloading support Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 01/32] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 02/32] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 03/32] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 04/32] ASoC: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 05/32] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 06/32] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 07/32] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 08/32] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 09/32] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 10/32] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 11/32] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 12/32] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 13/32] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 14/32] ASoC: usb: Add PCM format check API for USB backend Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 15/32] ASoC: qcom: qdsp6: Ensure PCM format is supported by USB audio device Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 16/32] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 17/32] ALSA: usb-audio: Do not allow USB offload path if PCM device is " Wesley Cheng
2024-06-12 14:57 ` Amadeusz Sławiński
2024-06-10 23:57 ` [PATCH v23 18/32] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 19/32] ALSA: usb-audio: qcom: Populate PCM and USB chip information Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 20/32] ASoC: qcom: qdsp6: Add support to track available USB PCM devices Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 21/32] ASoC: Introduce SND kcontrols to select sound card and PCM device Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 22/32] ASoC: qcom: qdsp6: Add SOC USB offload select get/put callbacks Wesley Cheng
2024-06-10 23:57 ` [PATCH v23 23/32] ASoC: Introduce SND kcontrols to track USB offloading state Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 24/32] ASoC: qcom: qdsp6: Add PCM ops to track current state Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 25/32] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 26/32] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 27/32] ASoC: usb: Fetch ASoC sound card information Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 28/32] ALSA: usb-audio: Add USB offloading capable kcontrol Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 29/32] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 30/32] ALSA: usb-audio: qcom: Use card and PCM index from QMI request Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 31/32] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-06-10 23:58 ` [PATCH v23 32/32] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-06-12 12:25 ` Bagas Sanjaya
2024-06-12 19:30 ` Wesley Cheng
2024-06-12 14:47 ` Amadeusz Sławiński
2024-06-12 19:28 ` Wesley Cheng
2024-06-13 7:46 ` Amadeusz Sławiński
2024-06-17 17:02 ` Wesley Cheng
2024-06-18 11:42 ` Amadeusz Sławiński
2024-06-18 20:52 ` Wesley Cheng
2024-06-19 7:52 ` Amadeusz Sławiński
2024-06-20 22:04 ` Wesley Cheng
2024-06-21 8:27 ` Pierre-Louis Bossart
2024-06-28 0:59 ` Wesley Cheng
2024-07-02 8:30 ` Pierre-Louis Bossart
2024-07-02 23:34 ` Wesley Cheng
2024-07-03 8:49 ` Pierre-Louis Bossart
2024-07-03 9:13 ` Amadeusz Sławiński
2024-07-03 9:50 ` Pierre-Louis Bossart [this message]
2024-07-03 22:05 ` Wesley Cheng
2024-07-04 10:01 ` Amadeusz Sławiński
2024-07-04 11:25 ` Pierre-Louis Bossart
2024-07-08 23:16 ` Wesley Cheng
2024-07-26 19:52 ` Wesley Cheng
2024-06-12 14:50 ` [PATCH v23 00/32] Introduce QC USB SND audio offloading support Amadeusz Sławiński
2024-06-12 14:59 ` Pierre-Louis Bossart
2024-06-12 19:41 ` Wesley Cheng
2024-06-12 19:38 ` Wesley Cheng
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=ab734271-58ee-4981-926c-9b57f36b8ac6@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=alsa-devel@alsa-project.org \
--cc=amadeuszx.slawinski@linux.intel.com \
--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=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).