devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>,
	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,
	tiwai@suse.com, krzk+dt@kernel.org,
	pierre-louis.bossart@linux.intel.com, Thinh.Nguyen@synopsys.com,
	bgoswami@quicinc.com, robh@kernel.org,
	gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-sound@vger.kernel.org, linux-input@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 v28 00/32] Introduce QC USB SND audio offloading support
Date: Tue, 1 Oct 2024 15:50:22 +0200	[thread overview]
Message-ID: <75ffde3a-7fef-4c15-bfc8-87756e1c3f11@linux.intel.com> (raw)
In-Reply-To: <20240925010000.2231406-1-quic_wcheng@quicinc.com>

On 9/25/2024 2:59 AM, Wesley Cheng wrote:
> Requesting to see if we can get some Acked-By tags, and merge on usb-next.
> 
> Several Qualcomm based chipsets can support USB audio offloading to a
> dedicated audio DSP, which can take over issuing transfers to the USB
> host controller.  The intention is to reduce the load on the main
> processors in the SoC, and allow them to be placed into lower power modes.
> There are several parts to this design:
>    1. Adding ASoC binding layer
>    2. Create a USB backend for Q6DSP
>    3. Introduce XHCI interrupter support
>    4. Create vendor ops for the USB SND driver
> 
>        USB                          |            ASoC
> --------------------------------------------------------------------
>                                     |  _________________________
>                                     | |sm8250 platform card     |
>                                     | |_________________________|
>                                     |         |           |
>                                     |      ___V____   ____V____
>                                     |     |Q6USB   | |Q6AFE    |
>                                     |     |"codec" | |"cpu"    |
>                                     |     |________| |_________|
>                                     |         ^  ^        ^
>                                     |         |  |________|
>                                     |      ___V____    |
>                                     |     |SOC-USB |   |
>     ________       ________               |        |   |
>    |USB SND |<--->|QC offld|<------------>|________|   |
>    |(card.c)|     |        |<----------                |
>    |________|     |________|___     | |                |
>        ^               ^       |    | |    ____________V_________
>        |               |       |    | |   |APR/GLINK             |
>     __ V_______________V_____  |    | |   |______________________|
>    |USB SND (endpoint.c)     | |    | |              ^
>    |_________________________| |    | |              |
>                ^               |    | |   ___________V___________
>                |               |    | |->|audio DSP              |
>     ___________V_____________  |    |    |_______________________|
>    |XHCI HCD                 |<-    |
>    |_________________________|      |
> 
> 
> Adding ASoC binding layer
> =========================
> soc-usb: Intention is to treat a USB port similar to a headphone jack.
> The port is always present on the device, but cable/pin status can be
> enabled/disabled.  Expose mechanisms for USB backend ASoC drivers to
> communicate with USB SND.
> 
> Create a USB backend for Q6DSP
> ==============================
> q6usb: Basic backend driver that will be responsible for maintaining the
> resources needed to initiate a playback stream using the Q6DSP.  Will
> be the entity that checks to make sure the connected USB audio device
> supports the requested PCM format.  If it does not, the PCM open call will
> fail, and userspace ALSA can take action accordingly.
> 
> Introduce XHCI interrupter support
> ==================================
> XHCI HCD supports multiple interrupters, which allows for events to be routed
> to different event rings.  This is determined by "Interrupter Target" field
> specified in Section "6.4.1.1 Normal TRB" of the XHCI specification.
> 
> Events in the offloading case will be routed to an event ring that is assigned
> to the audio DSP.
> 
> Create vendor ops for the USB SND driver
> ========================================
> qc_audio_offload: This particular driver has several components associated
> with it:
> - QMI stream request handler
> - XHCI interrupter and resource management
> - audio DSP memory management
> 
> When the audio DSP wants to enable a playback stream, the request is first
> received by the ASoC platform sound card.  Depending on the selected route,
> ASoC will bring up the individual DAIs in the path.  The Q6USB backend DAI
> will send an AFE port start command (with enabling the USB playback path), and
> the audio DSP will handle the request accordingly.
> 
> Part of the AFE USB port start handling will have an exchange of control
> messages using the QMI protocol.  The qc_audio_offload driver will populate the
> buffer information:
> - Event ring base address
> - EP transfer ring base address
> 
> and pass it along to the audio DSP.  All endpoint management will now be handed
> over to the DSP, and the main processor is not involved in transfers.
> 
> Overall, implementing this feature will still expose separate sound card and PCM
> devices for both the platform card and USB audio device:
>   0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
>                        SM8250-MTP-WCD9380-WSA8810-VA-DMIC
>   1 [Audio          ]: USB-Audio - USB Audio
>                        Generic USB Audio at usb-xhci-hcd.1.auto-1.4, high speed
> 
> This is to ensure that userspace ALSA entities can decide which route to take
> when executing the audio playback.  In the above, if card#1 is selected, then
> USB audio data will take the legacy path over the USB PCM drivers, etc...
> 
> The current limitation is that the latest USB audio device that is identified
> will be automatically selected by the Q6USB BE DAI for offloading.  Future
> patches can be added to possibly add for more flexibility, but until the userpace
> applications can be better defined, having these mechanisms will complicate the
> overall implementation.
> 
> USB offload Kcontrols
> =====================
> Part of the vendor offload package will have a mixer driver associated with it
> (mixer_usb_offload.c).  This entity will be responsible for coordinating with
> SOC USB and the Q6USB backend DAI to fetch information about the sound card
> and PCM device indices associated with the offload path.  The logic is done
> based on the current implementation of how paths are controlled within the QC
> ASoC implementation.
> 
> QC ASoC Q6Routing
> -----------------
> Within the Q6 ASOC design, the registered ASoC platform card will expose a set
> of kcontrols for enabling the BE DAI links to the FE DAI link.  For example:
> 
> tinymix -D 0 contents
> Number of controls: 1033
> ctl     type    num     name                                    value
> ...
> 1025    BOOL    1       USB Mixer MultiMedia1                   Off
> 1026    BOOL    1       USB Mixer MultiMedia2                   Off
> 1027    BOOL    1       USB Mixer MultiMedia3                   Off
> 1028    BOOL    1       USB Mixer MultiMedia4                   Off
> 1029    BOOL    1       USB Mixer MultiMedia5                   Off
> 1030    BOOL    1       USB Mixer MultiMedia6                   Off
> 1031    BOOL    1       USB Mixer MultiMedia7                   Off
> 1032    BOOL    1       USB Mixer MultiMedia8                   Off
> 
> Each of these kcontrols will enable the USB BE DAI link (q6usb) to be connected
> to a FE DAI link (q6asm).  Since each of these controls are DAPM widgets, when
> it is enabled, the DAPM widget's "connect" flag is updated accordingly.
> 
> USB Offload Mapping
> -------------------
> Based on the Q6routing, the USB BE DAI link can determine which sound card and
> PCM device is enabled for offloading.  Fetching the ASoC platform sound card's
> information is fairly straightforward, and the bulk of the work goes to finding
> the corresponding PCM device index.  As mentioned above, the USB BE DAI can
> traverse the DAPM widgets to find the DAPM path that is related to the control
> for the "USB Mixer."  Based on which "USB Mixer" is enabled, it can find the
> corresponding DAPM widget associated w/ the FE DAI link (Multimedia*).  From there
> it can find the PCM device created for the Multimedia* stream.
> 
> Only one BE DAI link can be enabled per FE DAI.  For example, if the HDMI path is
> enabled for Multimedia1, the USB Mixer will be disabled and switched over.
> 
> Examples of kcontrol
> --------------------
> tinymix -D 0 contents
> Number of controls: 1033
> ctl     type    num     name
> ...
> 1025    BOOL    1       USB Mixer MultiMedia1                   Off
> 1026    BOOL    1       USB Mixer MultiMedia2                   On
> 1027    BOOL    1       USB Mixer MultiMedia3                   Off
> 1028    BOOL    1       USB Mixer MultiMedia4                   Off
> 1029    BOOL    1       USB Mixer MultiMedia5                   Off
> 1030    BOOL    1       USB Mixer MultiMedia6                   Off
> 1031    BOOL    1       USB Mixer MultiMedia7                   Off
> 1032    BOOL    1       USB Mixer MultiMedia8                   Off
> 
> tinymix -D 2 contents
> Number of controls: 7
> ctl     type    num     name                                    value
> 0       INT     2       Playback Channel Map                    0, 0 (range 0->36)
> 1       BOOL    2       MDR-1ADAC  Playback Switch              On, On
> 2       BOOL    1       MDR-1ADAC  Playback Switch              On
> 3       INT     2       MDR-1ADAC  Playback Volume              127, 127 (range 0->127)
> 4       INT     1       MDR-1ADAC  Playback Volume              127 (range 0->127)
> 5       BOOL    1       Sony Internal Clock Validity            On
> 6       INT     2       USB Offload Playback Route PCM#0        0, 1 (range -1->255)
> 
> The example highlights that the userspace/application can utilize the offload path
> for the USB device on card#0 PCM device#1.
> 
> When dealing with multiple USB audio devices, only the latest USB device identified
> is going to be selected for offload capable.
> 
> tinymix -D 1 contents
> Number of controls: 9
> ctl     type    num     name                                    value
> 0       INT     2       Capture Channel Map                     0, 0 (range 0->36)
> 1       INT     2       Playback Channel Map                    0, 0 (range 0->36)
> 2       BOOL    1       Headset Capture Switch                  On
> 3       INT     1       Headset Capture Volume                  1 (range 0->4)
> 4       BOOL    1       Sidetone Playback Switch                On
> 5       INT     1       Sidetone Playback Volume                4096 (range 0->8192)
> 6       BOOL    1       Headset Playback Switch                 On
> 7       INT     2       Headset Playback Volume                 20, 20 (range 0->24)
> 8       INT     2       USB Offload Playback Route PCM#0        -1, -1 (range -1->255)
> 
> "-1, -1" shows that this device has no route to the offload path.
> 
> This feature was validated using:
> - tinymix: set/enable the multimedia path to route to USB backend
> - tinyplay: issue playback on platform card
> 



Just a reminder that I'm still not a fan of this design. Two seemingly 
unrelated Front Ends end up accessing same resource and blocking each 
other, that's why there is a need for above kcontrol interface.

In my opinion the fact that audio is routed through different HW paths, 
should not require separate Front Ends. It should start on same FE as it 
ends on one device. It would be a lot more user friendly that when end 
user opens USB FE it will just happen automatically, with current 
implementation user space needs to be aware of two separate front ends 
and internal dependency between them based on kcontrol value. If there 
is need to selectively disable it due to problems with some HW or in 
testing, just provide simple kcontrol on whole USB device with values 
"auto"(default), "force" (to always force offload), "off" (to disable it).


      parent reply	other threads:[~2024-10-01 13:50 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25  0:59 [PATCH v28 00/32] Introduce QC USB SND audio offloading support Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 01/32] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 02/32] usb: host: xhci: Repurpose event handler for skipping interrupter events Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 03/32] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 04/32] usb: xhci: xhci-sideband: Set IMOD for xHCI sideband clients Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 05/32] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 06/32] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 07/32] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 08/32] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 09/32] ALSA: Add USB audio device jack type Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 10/32] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 11/32] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 12/32] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2024-09-25 14:22   ` Pierre-Louis Bossart
2024-09-25  0:59 ` [PATCH v28 13/32] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 14/32] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 15/32] ASoC: usb: Add PCM format check API for " Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 16/32] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 17/32] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 18/32] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2024-09-25 14:43   ` Pierre-Louis Bossart
2024-10-01  1:34     ` Wesley Cheng
2024-10-01 13:48   ` Amadeusz Sławiński
2024-09-25  0:59 ` [PATCH v28 19/32] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 20/32] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 21/32] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 22/32] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 23/32] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 24/32] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 25/32] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2024-09-25 14:48   ` Pierre-Louis Bossart
2024-09-25  0:59 ` [PATCH v28 26/32] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 27/32] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 28/32] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 29/32] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 30/32] ALSA: usb-audio: Add USB offload route kcontrol Wesley Cheng
2024-09-25 14:54   ` Pierre-Louis Bossart
2024-09-25 19:37     ` Wesley Cheng
2024-09-25  0:59 ` [PATCH v28 31/32] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2024-09-25  1:00 ` [PATCH v28 32/32] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2024-09-25 15:04 ` [PATCH v28 00/32] Introduce QC USB SND audio offloading support Pierre-Louis Bossart
2024-10-01 13:50 ` Amadeusz Sławiński [this message]

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=75ffde3a-7fef-4c15-bfc8-87756e1c3f11@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=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.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).