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 22/31] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp
Date: Tue, 25 Mar 2025 10:24:42 +0100 [thread overview]
Message-ID: <Z-J2WnrZHP6iMIhT@linaro.org> (raw)
In-Reply-To: <20250319005141.312805-23-quic_wcheng@quicinc.com>
On Tue, Mar 18, 2025 at 05:51:32PM -0700, Wesley Cheng wrote:
> The QC ADSP is able to support USB playback endpoints, so that the main
> application processor can be placed into lower CPU power modes. This adds
> the required AFE port configurations and port start command to start an
> audio session.
>
> Specifically, the QC ADSP can support all potential endpoints that are
> exposed by the audio data interface. This includes isochronous data
> endpoints, in either synchronous mode or asynchronous mode. In the latter
> case both implicit or explicit feedback endpoints are supported. The size
> of audio samples sent per USB frame (microframe) will be adjusted based on
> information received on the feedback endpoint.
>
> Some pre-requisites are needed before issuing the AFE port start command,
> such as setting the USB AFE dev_token. This carries information about the
> available USB SND cards and PCM devices that have been discovered on the
> USB bus. The dev_token field is used by the audio DSP to notify the USB
> offload driver of which card and PCM index to enable playback on.
>
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
> sound/soc/qcom/qdsp6/q6afe-dai.c | 60 +++++++
> sound/soc/qcom/qdsp6/q6afe.c | 192 ++++++++++++++++++++++-
> sound/soc/qcom/qdsp6/q6afe.h | 36 ++++-
> sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c | 23 +++
> sound/soc/qcom/qdsp6/q6dsp-lpass-ports.h | 1 +
> sound/soc/qcom/qdsp6/q6routing.c | 32 +++-
> 6 files changed, 341 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/qcom/qdsp6/q6afe-dai.c b/sound/soc/qcom/qdsp6/q6afe-dai.c
> index 7d9628cda875..0f47aadaabe1 100644
> --- a/sound/soc/qcom/qdsp6/q6afe-dai.c
> +++ b/sound/soc/qcom/qdsp6/q6afe-dai.c
> [...]
> @@ -513,12 +520,96 @@ struct afe_param_id_cdc_dma_cfg {
> u16 active_channels_mask;
> } __packed;
>
> +struct afe_param_id_usb_cfg {
> +/* Minor version used for tracking USB audio device configuration.
> + * Supported values: AFE_API_MINOR_VERSION_USB_AUDIO_CONFIG
> + */
> + u32 cfg_minor_version;
> +/* Sampling rate of the port.
> + * Supported values:
> + * - AFE_PORT_SAMPLE_RATE_8K
> + * - AFE_PORT_SAMPLE_RATE_11025
> + * - AFE_PORT_SAMPLE_RATE_12K
> + * - AFE_PORT_SAMPLE_RATE_16K
> + * - AFE_PORT_SAMPLE_RATE_22050
> + * - AFE_PORT_SAMPLE_RATE_24K
> + * - AFE_PORT_SAMPLE_RATE_32K
> + * - AFE_PORT_SAMPLE_RATE_44P1K
> + * - AFE_PORT_SAMPLE_RATE_48K
> + * - AFE_PORT_SAMPLE_RATE_96K
> + * - AFE_PORT_SAMPLE_RATE_192K
> + */
> + u32 sample_rate;
> +/* Bit width of the sample.
> + * Supported values: 16, 24
> + */
> + u16 bit_width;
> +/* Number of channels.
> + * Supported values: 1 and 2
> + */
> + u16 num_channels;
> +/* Data format supported by the USB. The supported value is
> + * 0 (#AFE_USB_AUDIO_DATA_FORMAT_LINEAR_PCM).
> + */
> + u16 data_format;
> +/* this field must be 0 */
> + u16 reserved;
> +/* device token of actual end USB audio device */
> + u32 dev_token;
> +/* endianness of this interface */
> + u32 endian;
Nitpick: The indentation between u32 and the struct field names is odd,
can you use a single tab character like in the afe_param_id_cdc_dma_cfg
instead?
> +/* service interval */
> + u32 service_interval;
> +} __packed;
> +
> + [...]
> diff --git a/sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c b/sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c
> index 4919001de08b..4a96b11f7fd1 100644
> --- a/sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c
> +++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-ports.c
> @@ -97,6 +97,26 @@
> }
>
> static struct snd_soc_dai_driver q6dsp_audio_fe_dais[] = {
> + {
> + .playback = {
> + .stream_name = "USB Playback",
> + .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |
> + SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |
> + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
> + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |
> + SNDRV_PCM_RATE_192000,
> + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
> + SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE |
> + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |
> + SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE,
> + .channels_min = 1,
> + .channels_max = 2,
> + .rate_min = 8000,
> + .rate_max = 192000,
Nitpick: Indentation after rate_max is also odd here, please choose one
of the styles, either
.rate_min = 8000,
or
.rate_max = 192000,
> + },
> + .id = USB_RX,
> + .name = "USB_RX",
> + },
> {
> .playback = {
> .stream_name = "HDMI Playback",
> [...]
> diff --git a/sound/soc/qcom/qdsp6/q6routing.c b/sound/soc/qcom/qdsp6/q6routing.c
> index 90228699ba7d..b7439420b425 100644
> --- a/sound/soc/qcom/qdsp6/q6routing.c
> +++ b/sound/soc/qcom/qdsp6/q6routing.c
> @@ -435,6 +435,26 @@ static struct session_data *get_session_from_id(struct msm_routing_data *data,
>
> return NULL;
> }
> +
> +static bool is_usb_routing_enabled(struct msm_routing_data *data)
> +{
> + int i;
> +
> + /*
> + * Loop through current sessions to see if there are active routes
> + * to the USB_RX backend DAI. The USB offload routing is designed
> + * similarly to the non offload path. If there are multiple PCM
> + * devices associated with the ASoC platform card, only one active
> + * path can be routed to the USB offloaded endpoint.
> + */
> + for (i = 0; i < MAX_SESSIONS; i++) {
> + if (data->sessions[i].port_id == USB_RX)
> + return true;
> + }
> +
> + return false;
> +}
What is different about USB_RX compared to other output ports we have in
Q6AFE? Obviously, we can only play one stream on an output port. But
doesn't the ADSP mix streams together when you have multiple routes?
Also, this doesn't actually check for *active* routes only. It just
looks if any other MultiMedia DAI is configured to output to USB_RX.
That doesn't mean they will ever be active at the same time.
I might for example want to have MultiMedia1 and MultiMedia2 both
configured to output to USB_RX. Let's assume MultiMedia1 is a normal PCM
DAI, MultiMedia2 is a compress offload DAI. When I want to playback
normal audio, I go through MultiMedia1, when I want to play compressed
audio, I go through MultiMedia2. Only one of them active at a time.
Why can't I set this up statically in the mixers?
If you confirm that it is really impossible to have multiple streams
mixed together to the USB_RX output in the ADSP, then this should be a
runtime check instead when starting the stream IMO.
> +
> /**
> * q6routing_stream_close() - Deregister a stream
> *
> @@ -499,7 +519,8 @@ static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
> struct session_data *session = &data->sessions[session_id];
>
> if (ucontrol->value.integer.value[0]) {
> - if (session->port_id == be_id)
> + if (session->port_id == be_id ||
> + (be_id == USB_RX && is_usb_routing_enabled(data)))
> return 0;
>
> session->port_id = be_id;
> @@ -515,6 +536,9 @@ static int msm_routing_put_audio_mixer(struct snd_kcontrol *kcontrol,
> return 1;
> }
>
> +static const struct snd_kcontrol_new usb_mixer_controls[] = {
usb_rx_mixer_controls
> + Q6ROUTING_RX_MIXERS(USB_RX) };
> +
> static const struct snd_kcontrol_new hdmi_mixer_controls[] = {
> Q6ROUTING_RX_MIXERS(HDMI_RX) };
>
> @@ -950,6 +974,10 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = {
> SND_SOC_DAPM_MIXER("MultiMedia8 Mixer", SND_SOC_NOPM, 0, 0,
> mmul8_mixer_controls, ARRAY_SIZE(mmul8_mixer_controls)),
>
> + SND_SOC_DAPM_MIXER("USB Mixer", SND_SOC_NOPM, 0, 0,
> + usb_mixer_controls,
> + ARRAY_SIZE(usb_mixer_controls)),
Please put this next to the other playback mixers above (below
"RX_CODEC_DMA_RX_7 Audio Mixer").
I think it would also be more clear if you call this "USB_RX Mixer"
instead for consistency with the other playback mixers. This would also
avoid confusion later when USB_TX is added in addition to USB_RX.
Are you planning to send follow-up patches for USB recording offload
(USB_TX) later? Me and Luca successfully used your series to playback
voice call audio via the ADSP to an USB headset, recording would be also
needed to use this fully. :-)
Thanks,
Stephan
next prev parent reply other threads:[~2025-03-25 9:24 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 [this message]
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
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-J2WnrZHP6iMIhT@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).