From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: Takashi Iwai <tiwai@suse.de>,
Greg KH <gregkh@linuxfoundation.org>,
<srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>,
<perex@perex.cz>, <conor+dt@kernel.org>,
<dmitry.torokhov@gmail.com>, <corbet@lwn.net>,
<broonie@kernel.org>, <lgirdwood@gmail.com>, <krzk+dt@kernel.org>,
<Thinh.Nguyen@synopsys.com>, <tiwai@suse.com>, <robh@kernel.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-sound@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<linux-input@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<linux-doc@vger.kernel.org>,
"Pierre-Louis Bossart" <pierre-louis.bossart@linux.dev>
Subject: Re: [PATCH v30 00/30] Introduce QC USB SND audio offloading support
Date: Tue, 10 Dec 2024 16:18:27 +0100 [thread overview]
Message-ID: <3d9932fa-dbc3-4393-862f-92916e6e821c@intel.com> (raw)
In-Reply-To: <d7c52a11-bd2b-4cce-a0c2-6dc2dadfeaa3@quicinc.com>
On 2024-12-06 1:28 AM, Wesley Cheng wrote:
>
> On 12/4/2024 2:01 PM, Cezary Rojewski wrote:
>> On 2024-12-03 9:38 PM, Wesley Cheng wrote:
>>> Hi Cezary,
>>>
>>> On 12/3/2024 8:17 AM, Cezary Rojewski wrote:
...
>>>> UAOL is one of our priorities right now and some (e.g.: me) prefer to not pollute their mind with another approaches until what they have in mind is crystalized. In short, I'd vote for a approach where USB device has a ASoC representative in sound/soc/codecs/ just like it is the case for HDAudio. Either that or at least a ASoC-component representative, a dependency for UAOL-capable card to enumerate.
>>>>
>>>
>>> Just to clarify, "struct snd_soc_usb" does have some correlation with our "codec" entity within the QCOM ASoC design. This would be the q6usb driver.
>>>
>>>
>>>> Currently struct snd_soc_usb does not represent any component at all. Lack of codec representative, component representative and, given my current understanding, mixed dependency of sound/usb on sound/soc/soc-usb does lead to hard-to-understand ASoC solution.
>>>
>>>
>>> IMO the dependency on USB SND is necessary, so that we can leverage all the pre-existing sequences used to identify USB audio devices, and have some ability to utilize USB HCD APIs as well within the offload driver.
>>
>> So, while I do not have patches in shape good enough to be shared, what we have in mind is closer to existing HDAudio solution and how it is covered in both ALSA and ASoC.
>>
>> A ASoC sound card is effectively a combination of instances of struct snd_soc_component. Think of it as an MFD device. Typically at least two components are needed:
>>
>> - platform component, e.g.: for representing DSP-capable device
>> - codec component, e.g.: for representing the codec device
>>
>> USB could be represented by such a component, listed as a dependency of a sound card. By component I literally mean it extending the base struct:
>>
>> stuct snd_soc_usb {
>> struct snd_soc_component base;
>> (...)
>> };
>>
>> In my opinion HDAudio is a good example of how to mesh existing ALSA-based implementation with ASoC. Full, well implemented behaviour of HDAudio codec device drivers is present at sound/pci/hda/patch_*.c and friends. That part of devoid of any ASoC members. At the same time, an ASoC wrapper is present at sound/soc/codecs/hda.c. It will represent each and every HDAudio codec device on the HDAudio bus as a ASoC-component. This follows the ASoC design and thus is easy understand for any daily ASoC user, at least in my opinion.
>>
>> Next, the USB Audio Offload streams are a limited resource but I do not see a reason to not treat it as a pool. Again, HDAudio comes into picture. The HDAudio streams are assigned and released with help of HDAudio library, code found in sound/hda/hdac_stream.c. In essence, as long as UAOL-capable streaming is allowed, a pcm->open() could approach a UAOL-lib (? component perhaps?) and perform ->assign(). If no resources available, fallback to the non-offloaded case.
>>
>> While I have not commented on the kcontrol part, the above means that our current design does go into a different direction. We'd like to avoid stream-assignment hardcoding i.e.: predefining who owns a UAOL-capable stream if possible.
>>
>>
>
> Thanks for sharing the implementation for HDA. I did take a look to the best of my ability on how the HDAudio library was built, and I see the differences that are there with the current proposal. However, I think modifying the current design to something like that would also require the QCOM ASoC side to change a bit too. As mentioned by Pierre, I think its worthwhile to see if we can get the initial changes in, which is the major part of the challenge. For the most part, I think we could eventually refactor soc-usb to behave similarly to what hda_bind.c is doing. Both entities are the ones that handle linking (or creation in case of HDA) of ASoC components. The one major factor I can see is that within the HDA implementation vs USB SND is that, for USB, hot plugging is a common practice, and that's a scenario that will probably need more discussion if we do make that shift.
>
>
> Anyway, I just wanted to acknowledge the technical details that are utilized by HDAudio, and that we could potentially get there with USB SoC as well.
Hello,
After analyzing the USB for some time to get an even better
understanding of what's present in this series, I arrived at a
conclusion that indeed, the approach present here clearly differs from
what I would call _by the book_ approach for hardware-based USB Audio
offloading.
All sections below refer to the public xHCI spec [1].
A high-level bullets for the probing procedure:
1. xHCI root and resources probe() as they do today
2. xHCI reads HCCPARAMS2 (section 5.3.9) and checks GSC bit
2a. If GSC==0, the UAOL enumeration halts
3. xHCI sends GET_EXTPROP_TRB with ECI=1 to retrieve capabilities
supported (section 4.6.17 and Table 4-3)
3a. If AUDIO_SIDEBAND bit is not set, the UAOL enumeration halts
4. Create a platform_device instance. This instance will act as a bridge
between USB and ASoC world. For simplicity, let's call it usb-component,
a representative of USB in struct snd_soc_component.
5. On the platform_device->probe() the device requests information about
resources available from xHCI (section 7.9.1.1), ECI=1, SubType=001
6. Allocate a list of streams per device or list per endpoint supported
based on the data retrieved with the followup TRB of SubType=010.
(things get more complicated here, stopping)
Now, any time a sound card with bound usb-component would begin PCM
operation, starting with substream->open(), the component would first
check if the device and/or the endpoint has resources necessary to
support offloading. If not, it would fallback to the non-offloaded case.
I do not see implementation for any TRBs I mentioned above here. The
HCCPARAMS2 seem to be ignored too. At the same time, I'm unsure about
the "interrupters" piece. I believe they make the approach present here
somehow work, yet may not be required by the _by the book_ approach at all.
[1]:
https://www.intel.com/content/dam/www/public/us/en/documents/technical-specifications/extensible-host-controler-interface-usb-xhci.pdf
Kind regards,
Czarek
next prev parent reply other threads:[~2024-12-10 15:18 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 19:33 [PATCH v30 00/30] Introduce QC USB SND audio offloading support Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 01/30] usb: host: xhci: Repurpose event handler for skipping interrupter events Wesley Cheng
2024-11-20 11:48 ` Mathias Nyman
2024-11-20 18:48 ` Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 02/30] xhci: sec-intr: add initial api to register a secondary interrupter entity Wesley Cheng
2024-11-20 14:36 ` Mathias Nyman
2024-11-21 1:34 ` Wesley Cheng
2024-11-21 19:15 ` Mathias Nyman
2024-11-21 20:24 ` Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 03/30] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 04/30] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 05/30] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 06/30] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 07/30] ALSA: Add USB audio device jack type Wesley Cheng
2024-11-20 11:51 ` Takashi Iwai
2024-11-06 19:33 ` [PATCH v30 08/30] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 09/30] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 10/30] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 11/30] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 12/30] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 13/30] ASoC: usb: Add PCM format check API for " Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 14/30] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-12-03 16:14 ` Cezary Rojewski
2024-12-03 23:52 ` Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 15/30] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2024-11-20 12:23 ` Takashi Iwai
2024-11-20 22:36 ` Wesley Cheng
2024-11-06 19:33 ` [PATCH v30 16/30] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 17/30] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 18/30] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 19/30] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 20/30] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 21/30] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 22/30] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 23/30] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 24/30] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 25/30] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 26/30] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-11-20 12:15 ` Takashi Iwai
2024-11-20 22:10 ` Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 27/30] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 28/30] ALSA: usb-audio: Add USB offload route kcontrol Wesley Cheng
2024-11-20 12:12 ` Takashi Iwai
2024-11-20 19:13 ` Wesley Cheng
2024-11-21 15:50 ` Takashi Iwai
2024-11-25 20:33 ` Wesley Cheng
2024-11-26 14:14 ` Takashi Iwai
2024-11-26 23:19 ` Wesley Cheng
2024-12-03 16:13 ` Cezary Rojewski
2024-12-03 23:15 ` Wesley Cheng
2024-12-06 9:09 ` Cezary Rojewski
2024-12-06 20:43 ` Wesley Cheng
2024-12-10 15:24 ` Cezary Rojewski
2024-12-10 16:52 ` Takashi Iwai
2024-12-06 23:35 ` Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 29/30] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-11-06 19:34 ` [PATCH v30 30/30] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-11-15 22:42 ` [PATCH v30 00/30] Introduce QC USB SND audio offloading support Wesley Cheng
2024-11-16 7:42 ` Greg KH
2024-11-19 17:50 ` Wesley Cheng
2024-11-20 12:39 ` Takashi Iwai
2024-11-20 23:18 ` Wesley Cheng
2024-12-01 3:14 ` Pierre-Louis Bossart
2024-12-03 16:17 ` Cezary Rojewski
2024-12-03 16:57 ` Greg KH
2024-12-04 21:14 ` Cezary Rojewski
2024-12-05 1:15 ` Wesley Cheng
2024-12-05 6:50 ` Greg KH
2024-12-03 20:38 ` Wesley Cheng
2024-12-04 22:01 ` Cezary Rojewski
2024-12-06 0:28 ` Wesley Cheng
2024-12-10 15:18 ` Cezary Rojewski [this message]
2024-12-10 22:20 ` Wesley Cheng
2024-12-17 23:20 ` Pierre-Louis Bossart
[not found] ` <4C900353-B977-451C-B003-BAA51E458726@linux.dev>
2024-12-04 22:11 ` Cezary Rojewski
[not found] ` <4E9925AF-F297-42A5-9CB8-F8568F0A5EDF@linux.dev>
2024-12-06 0:53 ` Wesley Cheng
2024-12-10 0:59 ` Wesley Cheng
2024-12-10 16:40 ` Takashi Iwai
2024-12-11 2:00 ` Wesley Cheng
2024-12-13 9:10 ` Guan-Yu Lin
2024-12-03 16:16 ` Cezary Rojewski
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=3d9932fa-dbc3-4393-862f-92916e6e821c@intel.com \
--to=cezary.rojewski@intel.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--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-input@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.dev \
--cc=quic_wcheng@quicinc.com \
--cc=robh@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).