Re: [PATCH v30 00/30] Introduce QC USB SND audio offloading support

Wesley Cheng
2024-12-03T20:38:41Z

Hi Cezary,

On 12/3/2024 8:17 AM, Cezary Rojewski wrote:
> On 2024-12-01 4:14 AM, Pierre-Louis Bossart wrote:
>> Sorry to chime in late, I only look at email occasionally.
>>
>
> ...
>
>> My Reviewed-by tags were added in the last updates. I am not sure if anyone else at Intel had the time to review this large patchset.
>>
>>> I believe Amadeusz was still against having the two card design, and wants the routing to automatically happen when playback happens on the sound card created by the USB SND layer.  However, even with that kind of implementation, the major pieces brought in by this series should still be relevant, ie soc-usb and the vendor offload driver.  The only thing that would really change is adding a path from the USB SND PCM ops to interact with the ASoC entities.  Complexity-wise, this would obviously have a good amount of changes to the USB SND/ASoC core drivers.  Some things I can think of that we'd need to introduce:
>>
>> The notion of two cards was agreed inside Intel as far back as 2018, when Rakesh first looked at USB offload.
>
>
> Well, I believe a lot has changed since then, not sure if USB Audio Offload (UAOL) was even stable on the Windows solution back then. Obviously we want to incorporate what we have learned during all that time into our solution before it lands on upstream.
>

Hard to comment further without more details on the lessons learnt you had on Windows.  I just want to make sure we're talking about the same feature here, because I see sprinkles of the xHCI audio sideband (section 7.9) on the Windows documentation without much details on how its implemented, which is different than what is presented here.

> 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.

>
>>
>> Having a single USB card in IMHO more complicated:  what happens for example if you plug-in two or more USB devices? Which of the USB cards will expose an optimized path? The design with an ASoC-based card which exposes as many PCM devices as the SOC can support is simpler conceptually and scales well. This would allow e.g. to allocate these PCM devices with different policies (last plugged, preferred, etc).
>>
>> Conceptually for the simple case with a single USB device, it does not really matter if there are two cards or not. What matters is that there is a clear mapping visible to userspace so that application can decide to use the optimized PCM device, when enabled, instead of the legacy one. And in the end, the application is *always* in control in terms of routing. It’s really similar to the compress offload path, some application changes will be required.
>>
>>>
>>> 1.  Exposing some of the ASoC PCM (soc-pcm) APIs to be able to be called by soc-usb (to mimic a FE open from ASoC), so we can trigger ASoC DAI ops when USB SND FE is opened.
>>>
>>> 2.  Proper fallback mechanism in case offload path enablement fails to the legacy USB SND path.
>>>
>>> 3.  Master kcontrol to disable offload logic for each USB SND device.
>>>
>>> IMO, both the points you mentioned correspond to the same topic.  If we go with having offload being operated on one FE, then there is no need for the kcontrol of PCM mapping.  If we have two cards, then we will need the control for offload device mapping.  Can't speak for Pierre, but at least with my discussions with him, I don't think he's against the two card design, just as long as we have the proper kcontrol that notifies userspace of how to utilize the offload path.
>>
>> Even if there’s a single card you need to have a mapping between a ‘legacy’ PCM device and an ‘optimized’ one. This would be a scalar mapping instead of a (card, device) pair, but it’s a minor change.
>>
>> -Pierre
>