devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@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, corbet@lwn.net,
	broonie@kernel.org, lgirdwood@gmail.com, krzk+dt@kernel.org,
	Thinh.Nguyen@synopsys.com, bgoswami@quicinc.com, tiwai@suse.com,
	gregkh@linuxfoundation.org, robh@kernel.org
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-sound@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 v24 12/34] ASoC: doc: Add documentation for SOC USB
Date: Thu, 1 Aug 2024 10:26:55 +0200	[thread overview]
Message-ID: <57c5af3e-3299-47ae-9e13-bfce077f5e23@linux.intel.com> (raw)
In-Reply-To: <20240801011730.4797-13-quic_wcheng@quicinc.com>


> +
> +::
> +
> +               USB                   |            ASoC
> +                                     |  _________________________
> +                                     | |   ASoC Platform card    |
> +                                     | |_________________________|
> +                                     |         |           |
> +                                     |      ___V____   ____V____
> +                                     |     |ASoC BE | |ASoC FE  |
> +                                     |     |DAI LNK | |DAI LNK  |
> +                                     |     |________| |_________|
> +                                     |         ^  ^        ^
> +                                     |         |  |________|
> +                                     |      ___V____    |
> +                                     |     |SOC-USB |   |
> +     ________       ________               |        |   |
> +    |USB SND |<--->|USBSND  |<------------>|________|   |
> +    |(card.c)|     |offld   |<----------                |
> +    |________|     |________|___     | |                |
> +        ^               ^       |    | |    ____________V_________
> +        |               |       |    | |   |IPC                   |
> +     __ V_______________V_____  |    | |   |______________________|
> +    |USB SND (endpoint.c)     | |    | |              ^
> +    |_________________________| |    | |              |
> +                ^               |    | |   ___________V___________
> +                |               |    | |->|audio DSP              |
> +     ___________V_____________  |    |    |_______________________|
> +    |XHCI HCD                 |<-    |
> +    |_________________________|      |
> +

It wouldn't hurt to describe what you mean by 'port' in this diagram...


> +SOC USB driver
> +==============
> +Structures
> +----------
> +``struct snd_soc_usb``
> +
> +  - ``list``: list head for SND SOC struct list
> +  - ``component``: reference to ASoC component
> +  - ``num_supported_streams``: number of supported concurrent sessions
> +  - ``connection_status_cb``: callback to notify connection events
> +  - ``get_offload_dev``: callback to fetch selected USB sound card/PCM device

I think you meant fetch offloaded sound card and PCM device information
for a given USB card:device pair?


> +Functions
> +---------
> +.. code-block:: rst
> +
> +	const char *snd_soc_usb_get_components_tag(bool playback);
> +..
> +
> +  - ``playback``: direction of audio stream

why not use the usual direction 0: playback and 1: capture?

> +
> +**snd_soc_usb_get_components_tag()** returns the tag used for describing if USB
> +offloading is supported for appending to a sound card's components string.

How does this work if the ASoC part is probe after the USB card? The
component string would be modified after the creation of the card?

A control is more dynamic by nature, not sure about this component
string. Jaroslav?

>
> +**snd_soc_usb_add_port()** add an allocated SOC USB device to the SOC USB framework.
> +Once added, this device can be referenced by further operations.
> +
> +.. code-block:: rst
> +
> +	void snd_soc_usb_remove_port(struct snd_soc_usb *usb);
> +..
> +
> +  - ``usb``: SOC USB device to remove
> +
> +**snd_soc_usb_remove_port()** removes a SOC USB device from the SOC USB framework.
> +After removing a device, any SOC USB operations would not be able to reference the
> +device removed.

Not clear to me if the notion of 'port' helps, why not just
snd_soc_usb_add_device() and remove_device()?


> +
> +USB Offload Related Kcontrols
> +=============================
> +Details
> +-------
> +A set of kcontrols can be utilized by applications to help select the proper sound
> +devices to enable USB audio offloading.  SOC USB exposes the get_offload_dev()
> +callback that designs can use to ensure that the proper indices are returned to the
> +application.
> +
> +Implementation
> +--------------
> +
> +**Example:**
> +
> +  **Sound Cards**:
> +
> +	::
> +
> +	  0 [SM8250MTPWCD938]: sm8250 - SM8250-MTP-WCD9380-WSA8810-VA-D
> +						SM8250-MTP-WCD9380-WSA8810-VA-DMIC
> +	  1 [Seri           ]: USB-Audio - Plantronics Blackwire 3225 Seri
> +						Plantronics Plantronics Blackwire 3225 Seri at usb-xhci-hcd.1.auto-1.1, full sp
> +	  2 [C320M          ]: USB-Audio - Plantronics C320-M
> +                      Plantronics Plantronics C320-M at usb-xhci-hcd.1.auto-1.2, full speed
> +
> +  **USB Sound Card** - card#1:
> +
> +	::
> +
> +	  USB Offload Playback Route PCM#0        -1, -1 (range -1->255)
> +
> +  **USB Sound Card** - card#2:
> +
> +	::
> +
> +	  USB Offload Playback Route PCM#0        0, 1 (range -1->255)
> +
> +The above example shows a scenario where the system has one ASoC platform card
> +(card#0) and two USB sound devices connected (card#1 and card#2).  When reading
> +the available kcontrols for each USB audio device, the following kcontrol lists
> +the mapped offload path for the specific device:
> +
> +	"USB Offload Playback Route#*"
> +
> +The kcontrol is indexed, because a USB audio device could potentially have
> +several PCM devices.  The above kcontrols are defined as:
> +
> +  - ``USB Offload Playback Route PCM`` **(R)**: Returns the ASoC platform sound
> +	card and PCM device index.  The output "0, 1" (card index, PCM device index)
> +	signifies that there is an available offload path for the USB SND device
> +	through card#0-PCM device#1.  If "-1, -1" is seen, then no offload path is
> +	available for the USB SND device.
> +
> +USB Offload Playback Route Kcontrol
> +-----------------------------------
> +In order to allow for vendor specific implementations on audio offloading device
> +selection, the SOC USB layer exposes the following:
> +
> +.. code-block:: rst
> +
> +	int (*get_offload_dev)(struct snd_kcontrol *kcontrol,
> +			      struct snd_ctl_elem_value *ucontrol);
> +..
> +
> +These are specific for the **USB Offload Playback Route PCM#** kcontrol.
> +
> +When users issue get calls to the kcontrol, the registered SOC USB callbacks will
> +execute the registered function calls to the DPCM BE DAI link.

Oh man, now I get what 'get_offload_dev" means: it really means
"update_offload_info' or 'update_info_kcontrol".
The 'get' routines usually provide a handle on something to another part
of the kernel.
Not here, it's an update of something to be looked-up by userspace...


> +**Callback Registration:**
> +
> +.. code-block:: rst
> +
> +	static int q6usb_component_probe(struct snd_soc_component *component)
> +	{
> +	...
> +	usb = snd_soc_usb_allocate_port(component, 1, &data->priv);
> +	if (IS_ERR(usb))
> +		return -ENOMEM;
> +
> +	usb->connection_status_cb = q6usb_alsa_connection_cb;
> +	usb->get_offload_dev = q6usb_get_offload_dev;
> +
> +	ret = snd_soc_usb_add_port(usb);
> +..


  reply	other threads:[~2024-08-01  9:11 UTC|newest]

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

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=57c5af3e-3299-47ae-9e13-bfce077f5e23@linux.intel.com \
    --to=pierre-louis.bossart@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=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-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=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).