devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wesley Cheng <quic_wcheng@quicinc.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: <srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>,
	<perex@perex.cz>, <lgirdwood@gmail.com>, <andersson@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <gregkh@linuxfoundation.org>,
	<Thinh.Nguyen@synopsys.com>, <broonie@kernel.org>,
	<bgoswami@quicinc.com>, <tiwai@suse.com>, <robh+dt@kernel.org>,
	<agross@kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	<devicetree@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<quic_jackp@quicinc.com>, <quic_plai@quicinc.com>
Subject: Re: [PATCH v5 11/32] sound: usb: card: Introduce USB SND platform op callbacks
Date: Tue, 12 Sep 2023 15:36:07 -0700	[thread overview]
Message-ID: <59d28227-d37f-7131-6d1c-ec55e67d65b7@quicinc.com> (raw)
In-Reply-To: <c32e6983-4641-1849-cb25-d29da27bff15@quicinc.com>

Hi Takashi,

On 9/11/2023 10:57 AM, Wesley Cheng wrote:
> Hi Takashi,
> 
> On 9/7/2023 8:36 AM, Takashi Iwai wrote:
>> On Tue, 29 Aug 2023 23:06:36 +0200,
>> Wesley Cheng wrote:
>>>
>>> Allow for different platforms to be notified on USB SND 
>>> connect/disconnect
>>> seqeunces.  This allows for platform USB SND modules to properly 
>>> initialize
>>> and populate internal structures with references to the USB SND chip
>>> device.
>>>
>>> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
>>> ---
>>>   sound/usb/card.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>>>   sound/usb/card.h |  9 +++++++++
>>>   2 files changed, 54 insertions(+)
>>>
>>> diff --git a/sound/usb/card.c b/sound/usb/card.c
>>> index 1b2edc0fd2e9..067a1e82f4bf 100644
>>> --- a/sound/usb/card.c
>>> +++ b/sound/usb/card.c
>>> @@ -118,6 +118,34 @@ MODULE_PARM_DESC(skip_validation, "Skip unit 
>>> descriptor validation (default: no)
>>>   static DEFINE_MUTEX(register_mutex);
>>>   static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
>>>   static struct usb_driver usb_audio_driver;
>>> +static struct snd_usb_platform_ops *platform_ops;
>>> +
>>> +int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops)
>>> +{
>>> +    int ret;
>>> +
>>> +    mutex_lock(&register_mutex);
>>> +    if (platform_ops) {
>>> +        ret = -EEXIST;
>>> +        goto out;
>>> +    }
>>> +
>>> +    platform_ops = ops;
>>> +out:
>>> +    mutex_unlock(&register_mutex);
>>> +    return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(snd_usb_register_platform_ops);
>>
>> For adding this kind of API, please give the proper comment.
>> Especially this API is special and need a caution, to mention that it
>> can be used only for a single instance.
>>
>> Also, it should be mentioned that all callbacks are exclusive under
>> the global register_mutex.
>>
> 
> Thanks for taking the time to review.  Sure, I'll add some comments in 
> these new APIs to document what they are used for and how they are 
> protected and limited.
> 
>>> @@ -910,7 +938,11 @@ static int usb_audio_probe(struct usb_interface 
>>> *intf,
>>>       chip->num_interfaces++;
>>>       usb_set_intfdata(intf, chip);
>>>       atomic_dec(&chip->active);
>>> +
>>> +    if (platform_ops && platform_ops->connect_cb)
>>> +        platform_ops->connect_cb(chip);
>>>       mutex_unlock(&register_mutex);
>>
>> One uncertain thing is the argument for connect_cb and disconnect_cb.
>> Those take snd_usb_audio object, but the callback gets called per
>> interface at each probe and disconnect.  How does the callee handle
>> multiple calls?
> 
> I guess it should depend on how the platform driver wants to handle it? 
>   I haven't run into a device with multiple UAC interfaces before, so 
> I'll need to mimic this configuration on a device, so I can see how it 
> exposes itself.
> 
> Will investigate this a bit more on my end and come back with my findings.
> 

So looks like if there is a device that has multiple UAC interfaces, 
then it just results in one USB sound card with multiple USB streams. 
As of now, we do expose a ksndcontrol that allows for userspace to 
specify which card and PCM device to issue the audio playback on.  Then 
based on the audio profile received by the audio DSP, it will narrow it 
down to see if that substream supports the requested profile.

This selection is done in the DPCM backend driver (q6usb), since the 
overall QMI USB stream request stems from the audio dsp, and will carry 
this information about which PCM device and card the USB offload driver 
should use.  This may differ based on the implementation of the offload 
path, hence why I mentioned that it might be platform specific.

There is one improvement I need to make in our QC offload driver to 
accommodate for this scenario, and that is to avoid having to 
re-register for the XHCI sideband if there is already a USB SND card 
allocated, which I will fix and submit in the next revision.

Thanks
Wesley Cheng

  reply	other threads:[~2023-09-12 22:36 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 21:06 [PATCH v5 00/32] Introduce QC USB SND audio offloading support Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 01/32] xhci: add support to allocate several interrupters Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 02/32] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 03/32] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 04/32] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 05/32] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 06/32] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 07/32] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 08/32] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 09/32] ASoC: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 10/32] ASoC: qcom: Add USB backend ASoC driver for Q6 Wesley Cheng
2023-08-30 12:50   ` Amadeusz Sławiński
2023-08-31 19:34     ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 11/32] sound: usb: card: Introduce USB SND platform op callbacks Wesley Cheng
2023-09-07 15:36   ` Takashi Iwai
2023-09-11 17:57     ` Wesley Cheng
2023-09-12 22:36       ` Wesley Cheng [this message]
2023-08-29 21:06 ` [PATCH v5 12/32] sound: usb: Export USB SND APIs for modules Wesley Cheng
2023-08-30 12:50   ` Amadeusz Sławiński
2023-08-31 19:36     ` Wesley Cheng
2023-09-07 15:38   ` Takashi Iwai
2023-09-11 17:58     ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 13/32] dt-bindings: usb: dwc3: Add snps,num-hc-interrupters definition Wesley Cheng
2023-08-31 17:24   ` Rob Herring
2023-08-31 19:25     ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 14/32] dt-bindings: usb: xhci: Add num-hc-interrupters definition Wesley Cheng
2023-08-31 17:22   ` Rob Herring
2023-08-29 21:06 ` [PATCH v5 15/32] usb: dwc3: Add DT parameter to specify maximum number of interrupters Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 16/32] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 17/32] sound: usb: qcom: Add USB QMI definitions Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 18/32] sound: usb: Introduce QC USB SND offloading support Wesley Cheng
2023-09-07 15:51   ` Takashi Iwai
2023-09-11 17:59     ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 19/32] sound: usb: card: Check for support for requested audio format Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 20/32] sound: soc: soc-usb: Add PCM format check API for USB backend Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 21/32] sound: soc: qcom: qusb6: Ensure PCM format is supported by USB audio device Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 22/32] sound: usb: Prevent starting of audio stream if in use Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 23/32] ASoC: dt-bindings: Add Q6USB backend Wesley Cheng
2023-08-31 17:29   ` Rob Herring
2023-08-31 19:32     ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 24/32] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2023-08-31 17:29   ` Rob Herring
2023-08-29 21:06 ` [PATCH v5 25/32] ASoC: qcom: qdsp6: q6afe: Split USB AFE dev_token param into separate API Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 26/32] sound: Pass USB SND card and PCM information to SOC USB Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 27/32] sound: soc: qdsp6: Add SND kcontrol to select offload device Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 28/32] sound: soc: qdsp6: Add SND kcontrol for fetching offload status Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 29/32] sound: soc: qcom: q6usb: Add headphone jack for offload connection status Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 30/32] sound: usb: qc_audio_offload: Use card and PCM index from QMI request Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 31/32] sound: usb: card: Allow for rediscovery of connected USB SND devices Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 32/32] sound: soc: soc-usb: Rediscover USB SND devices on USB port add 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=59d28227-d37f-7131-6d1c-ec55e67d65b7@quicinc.com \
    --to=quic_wcheng@quicinc.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=agross@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=andersson@kernel.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=perex@perex.cz \
    --cc=quic_jackp@quicinc.com \
    --cc=quic_plai@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    /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).