devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: 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, pierre-louis.bossart@linux.intel.com,
	Thinh.Nguyen@synopsys.com, tiwai@suse.com, robh@kernel.org,
	gregkh@linuxfoundation.org, 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,
	Luca Weiss <luca.weiss@fairphone.com>
Subject: Re: [PATCH v36 28/31] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support
Date: Tue, 25 Mar 2025 10:47:11 +0100	[thread overview]
Message-ID: <Z-J7n8qLMPVxpwuV@linaro.org> (raw)
In-Reply-To: <20250319005141.312805-29-quic_wcheng@quicinc.com>

On Tue, Mar 18, 2025 at 05:51:38PM -0700, Wesley Cheng wrote:
> Several Qualcomm SoCs have a dedicated audio DSP, which has the ability to
> support USB sound devices.  This vendor driver will implement the required
> handshaking with the DSP, in order to pass along required resources that
> will be utilized by the DSP's USB SW.  The communication channel used for
> this handshaking will be using the QMI protocol.  Required resources
> include:
> - Allocated secondary event ring address
> - EP transfer ring address
> - Interrupter number
> 
> The above information will allow for the audio DSP to execute USB transfers
> over the USB bus.  It will also be able to support devices that have an
> implicit feedback and sync endpoint as well.  Offloading these data
> transfers will allow the main/applications processor to enter lower CPU
> power modes, and sustain a longer duration in those modes.
> 
> Audio offloading is initiated with the following sequence:
> 1. Userspace configures to route audio playback to USB backend and starts
> playback on the platform soundcard.
> 2. The Q6DSP AFE will communicate to the audio DSP to start the USB AFE
> port.
> 3. This results in a QMI packet with a STREAM enable command.
> 4. The QC audio offload driver will fetch the required resources, and pass
> this information as part of the QMI response to the STREAM enable command.
> 5. Once the QMI response is received the audio DSP will start queuing data
> on the USB bus.
> 
> As part of step#2, the audio DSP is aware of the USB SND card and pcm
> device index that is being selected, and is communicated as part of the QMI
> request received by QC audio offload.  These indices will be used to handle
> the stream enable QMI request.
> 
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
>  sound/usb/Kconfig                 |   14 +
>  sound/usb/Makefile                |    2 +-
>  sound/usb/qcom/Makefile           |    2 +
>  sound/usb/qcom/qc_audio_offload.c | 1988 +++++++++++++++++++++++++++++
>  4 files changed, 2005 insertions(+), 1 deletion(-)
>  create mode 100644 sound/usb/qcom/Makefile
>  create mode 100644 sound/usb/qcom/qc_audio_offload.c
> 
> diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig
> index 4a9569a3a39a..6daa551738da 100644
> --- a/sound/usb/Kconfig
> +++ b/sound/usb/Kconfig
> @@ -176,6 +176,20 @@ config SND_BCD2000
>  	  To compile this driver as a module, choose M here: the module
>  	  will be called snd-bcd2000.
>  
> +config SND_USB_AUDIO_QMI
> +	tristate "Qualcomm Audio Offload driver"
> +	depends on QCOM_QMI_HELPERS && SND_USB_AUDIO && USB_XHCI_SIDEBAND && SND_SOC_USB
> +	help
> +	  Say Y here to enable the Qualcomm USB audio offloading feature.
> +
> +	  This module sets up the required QMI stream enable/disable
> +	  responses to requests generated by the audio DSP.  It passes the
> +	  USB transfer resource references, so that the audio DSP can issue
> +	  USB transfers to the host controller.
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called snd-usb-audio-qmi.
> [...]
> diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
> new file mode 100644
> index 000000000000..3319363a0fd0
> --- /dev/null
> +++ b/sound/usb/qcom/qc_audio_offload.c
> @@ -0,0 +1,1988 @@
> [...]
> +static int __init qc_usb_audio_offload_init(void)
> +{
> +	struct uaudio_qmi_svc *svc;
> +	int ret;
> +
> +	svc = kzalloc(sizeof(*svc), GFP_KERNEL);
> +	if (!svc)
> +		return -ENOMEM;
> +
> +	svc->uaudio_svc_hdl = kzalloc(sizeof(*svc->uaudio_svc_hdl), GFP_KERNEL);
> +	if (!svc->uaudio_svc_hdl) {
> +		ret = -ENOMEM;
> +		goto free_svc;
> +	}
> +
> +	ret = qmi_handle_init(svc->uaudio_svc_hdl,
> +			      QMI_UAUDIO_STREAM_REQ_MSG_V01_MAX_MSG_LEN,
> +			      &uaudio_svc_ops_options,
> +			      &uaudio_stream_req_handlers);
> +	ret = qmi_add_server(svc->uaudio_svc_hdl, UAUDIO_STREAM_SERVICE_ID_V01,
> +			     UAUDIO_STREAM_SERVICE_VERS_V01, 0);
> +
> +	uaudio_svc = svc;
> +
> +	ret = snd_usb_register_platform_ops(&offload_ops);
> +	if (ret < 0)
> +		goto release_qmi;
> +
> +	return 0;
> +
> +release_qmi:
> +	qmi_handle_release(svc->uaudio_svc_hdl);
> +free_svc:
> +	kfree(svc);
> +
> +	return ret;
> +}
> +
> +static void __exit qc_usb_audio_offload_exit(void)
> +{
> +	struct uaudio_qmi_svc *svc = uaudio_svc;
> +	int idx;
> +
> +	/*
> +	 * Remove all connected devices after unregistering ops, to ensure
> +	 * that no further connect events will occur.  The disconnect routine
> +	 * will issue the QMI disconnect indication, which results in the
> +	 * external DSP to stop issuing transfers.
> +	 */
> +	snd_usb_unregister_platform_ops();
> +	for (idx = 0; idx < SNDRV_CARDS; idx++)
> +		qc_usb_audio_offload_disconnect(uadev[idx].chip);
> +
> +	qmi_handle_release(svc->uaudio_svc_hdl);
> +	kfree(svc);
> +	uaudio_svc = NULL;
> +}
> +
> +module_init(qc_usb_audio_offload_init);
> +module_exit(qc_usb_audio_offload_exit);
> +
> +MODULE_DESCRIPTION("QC USB Audio Offloading");
> +MODULE_LICENSE("GPL");

What will trigger loading this if this code is built as module?

Testing suggests nothing does at the moment: If this is built as module,
playback via USB_RX will fail until you manually modprobe
snd-usb-audio-qmi.

I think the easiest way to solve this would be to drop the
module_init()/module_exit() and instead call into these init/exit
functions from one of the other audio modules. This would also ensure
that the QMI server is only registered if we actually need it (if the
board sound card actually has a USB DAI link).

drivers/soc/qcom/qcom_pd_mapper.c is a similar driver that registers a
QMI server. You can also look at that for inspiration.

Thanks,
Stephan

  reply	other threads:[~2025-03-25  9:47 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19  0:51 [PATCH v36 00/31] Introduce QC USB SND audio offloading support Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 01/31] xhci: sideband: add initial api to register a secondary interrupter entity Wesley Cheng
2025-03-27  6:27   ` Puma Hsu
2025-03-27  7:02     ` Greg KH
2025-03-27 10:14       ` Puma Hsu
2025-03-27 10:48         ` Greg KH
2025-03-28  4:08           ` Puma Hsu
2025-03-27 16:12         ` Wesley Cheng
2025-03-28  4:11           ` Puma Hsu
2025-04-01  2:23           ` Jung Daehwan
2025-04-01  6:55             ` Greg KH
2025-04-01  7:50               ` Jung Daehwan
2025-03-27 10:13   ` Puma Hsu
2025-03-19  0:51 ` [PATCH v36 02/31] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2025-03-28  7:42   ` Puma Hsu
2025-04-01  7:51     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 03/31] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2025-03-28  7:43   ` Puma Hsu
2025-04-01  7:51     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 04/31] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2025-03-28  7:44   ` Puma Hsu
2025-04-01  7:52     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 05/31] usb: host: xhci: Notify xHCI sideband on transfer ring free Wesley Cheng
2025-03-28  7:45   ` Puma Hsu
2025-04-01  7:52     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 06/31] usb: dwc3: Specify maximum number of XHCI interrupters Wesley Cheng
2025-03-28  7:46   ` Puma Hsu
2025-04-01  7:53     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 07/31] ALSA: Add USB audio device jack type Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 08/31] ALSA: usb-audio: Export USB SND APIs for modules Wesley Cheng
2025-03-28  7:47   ` Puma Hsu
2025-04-01  7:53     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 09/31] ALSA: usb-audio: Check for support for requested audio format Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 10/31] ALSA: usb-audio: Save UAC sample size information Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 11/31] ALSA: usb-audio: Prevent starting of audio stream if in use Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 12/31] ALSA: usb-audio: Introduce USB SND platform op callbacks Wesley Cheng
2025-03-28  7:48   ` Puma Hsu
2025-04-01  7:53     ` Jung Daehwan
2025-03-19  0:51 ` [PATCH v36 13/31] ALSA: usb-audio: Allow for rediscovery of connected USB SND devices Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 14/31] ASoC: Add SoC USB APIs for adding an USB backend Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 15/31] ASoC: usb: Add PCM format check API for " Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 16/31] ASoC: usb: Create SOC USB SND jack kcontrol Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 17/31] ASoC: usb: Fetch ASoC card and pcm device information Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 18/31] ASoC: usb: Rediscover USB SND devices on USB port add Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 19/31] ASoC: doc: Add documentation for SOC USB Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 20/31] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 21/31] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 22/31] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2025-03-25  9:24   ` Stephan Gerhold
2025-03-25 23:18     ` Wesley Cheng
2025-03-26  9:57       ` Stephan Gerhold
2025-03-31 19:52         ` Wesley Cheng
2025-04-01  8:16           ` Stephan Gerhold
2025-04-01 23:47             ` Wesley Cheng
2025-04-02 14:41               ` Stephan Gerhold
2025-04-03  0:23                 ` Wesley Cheng
2025-04-03  0:54                   ` Wesley Cheng
2025-04-03 13:45                     ` Stephan Gerhold
2025-04-03 15:58                       ` Wesley Cheng
2025-04-03 18:00                         ` Stephan Gerhold
2025-04-03 21:00                           ` Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 23/31] ASoC: qcom: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 24/31] ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6 Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 25/31] ASoC: qcom: qdsp6: Add headphone jack for offload connection status Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 26/31] ASoC: qcom: qdsp6: Fetch USB offload mapped card and PCM device Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 27/31] ALSA: usb-audio: qcom: Add USB QMI definitions Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 28/31] ALSA: usb-audio: qcom: Introduce QC USB SND offloading support Wesley Cheng
2025-03-25  9:47   ` Stephan Gerhold [this message]
2025-03-26  1:32     ` Wesley Cheng
2025-03-26 10:09       ` Stephan Gerhold
2025-03-27 16:57         ` Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 29/31] ALSA: usb-audio: qcom: Don't allow USB offload path if PCM device is in use Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 30/31] ALSA: usb-audio: qcom: Add USB offload route kcontrol Wesley Cheng
2025-03-25 11:35   ` Stephan Gerhold
2025-03-26  1:42     ` Wesley Cheng
2025-03-19  0:51 ` [PATCH v36 31/31] ALSA: usb-audio: qcom: Notify USB audio devices on USB offload probing Wesley Cheng
2025-03-21 13:13 ` [PATCH v36 00/31] Introduce QC USB SND audio offloading support Luca Weiss
2025-03-21 20:06   ` 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=Z-J7n8qLMPVxpwuV@linaro.org \
    --to=stephan.gerhold@linaro.org \
    --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=luca.weiss@fairphone.com \
    --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).