From: Wesley Cheng <quic_wcheng@quicinc.com>
To: <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>
Cc: <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>, Wesley Cheng <quic_wcheng@quicinc.com>
Subject: [PATCH v5 12/32] sound: usb: Export USB SND APIs for modules
Date: Tue, 29 Aug 2023 14:06:37 -0700 [thread overview]
Message-ID: <20230829210657.9904-13-quic_wcheng@quicinc.com> (raw)
In-Reply-To: <20230829210657.9904-1-quic_wcheng@quicinc.com>
Some vendor modules will utilize useful parsing and endpoint management
APIs to start audio playback/capture.
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
sound/usb/card.c | 4 +++
sound/usb/endpoint.c | 1 +
sound/usb/helper.c | 1 +
sound/usb/pcm.c | 67 +++++++++++++++++++++++++++++++++-----------
sound/usb/pcm.h | 11 ++++++++
5 files changed, 67 insertions(+), 17 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 067a1e82f4bf..b45b6daee7b7 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -1053,6 +1053,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
wake_up(&chip->shutdown_wait);
return err;
}
+EXPORT_SYMBOL_GPL(snd_usb_lock_shutdown);
/* autosuspend and unlock the shutdown */
void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
@@ -1061,6 +1062,7 @@ void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
if (atomic_dec_and_test(&chip->usage_count))
wake_up(&chip->shutdown_wait);
}
+EXPORT_SYMBOL_GPL(snd_usb_unlock_shutdown);
int snd_usb_autoresume(struct snd_usb_audio *chip)
{
@@ -1083,6 +1085,7 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
}
return 0;
}
+EXPORT_SYMBOL_GPL(snd_usb_autoresume);
void snd_usb_autosuspend(struct snd_usb_audio *chip)
{
@@ -1096,6 +1099,7 @@ void snd_usb_autosuspend(struct snd_usb_audio *chip)
for (i = 0; i < chip->num_interfaces; i++)
usb_autopm_put_interface(chip->intf[i]);
}
+EXPORT_SYMBOL_GPL(snd_usb_autosuspend);
static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
{
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index a385e85c4650..aac92e0b8aa2 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -1503,6 +1503,7 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *chip,
mutex_unlock(&chip->mutex);
return err;
}
+EXPORT_SYMBOL_GPL(snd_usb_endpoint_prepare);
/* get the current rate set to the given clock by any endpoint */
int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock)
diff --git a/sound/usb/helper.c b/sound/usb/helper.c
index bf80e55d013a..4322ae3738e6 100644
--- a/sound/usb/helper.c
+++ b/sound/usb/helper.c
@@ -62,6 +62,7 @@ void *snd_usb_find_csint_desc(void *buffer, int buflen, void *after, u8 dsubtype
}
return NULL;
}
+EXPORT_SYMBOL_GPL(snd_usb_find_csint_desc);
/*
* Wrapper for usb_control_msg().
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 08bf535ed163..999f66080649 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -148,6 +148,16 @@ find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
return found;
}
+const struct audioformat *
+snd_usb_find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
+ unsigned int rate, unsigned int channels, bool strict_match,
+ struct snd_usb_substream *subs)
+{
+ return find_format(fmt_list_head, format, rate, channels, strict_match,
+ subs);
+}
+EXPORT_SYMBOL_GPL(snd_usb_find_format);
+
static const struct audioformat *
find_substream_format(struct snd_usb_substream *subs,
const struct snd_pcm_hw_params *params)
@@ -157,6 +167,14 @@ find_substream_format(struct snd_usb_substream *subs,
true, subs);
}
+const struct audioformat *
+snd_usb_find_substream_format(struct snd_usb_substream *subs,
+ const struct snd_pcm_hw_params *params)
+{
+ return find_substream_format(subs, params);
+}
+EXPORT_SYMBOL_GPL(snd_usb_find_substream_format);
+
bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *subs)
{
const struct audioformat *fp;
@@ -461,20 +479,9 @@ static void close_endpoints(struct snd_usb_audio *chip,
}
}
-/*
- * hw_params callback
- *
- * allocate a buffer and set the given audio format.
- *
- * so far we use a physically linear buffer although packetize transfer
- * doesn't need a continuous area.
- * if sg buffer is supported on the later version of alsa, we'll follow
- * that.
- */
-static int snd_usb_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *hw_params)
+int snd_usb_attach_endpoints(struct snd_usb_substream *subs,
+ struct snd_pcm_hw_params *hw_params)
{
- struct snd_usb_substream *subs = substream->runtime->private_data;
struct snd_usb_audio *chip = subs->stream->chip;
const struct audioformat *fmt;
const struct audioformat *sync_fmt;
@@ -499,7 +506,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
if (fmt->implicit_fb) {
sync_fmt = snd_usb_find_implicit_fb_sync_format(chip, fmt,
hw_params,
- !substream->stream,
+ !subs->direction,
&sync_fixed_rate);
if (!sync_fmt) {
usb_audio_dbg(chip,
@@ -579,15 +586,28 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
return ret;
}
+EXPORT_SYMBOL_GPL(snd_usb_attach_endpoints);
/*
- * hw_free callback
+ * hw_params callback
*
- * reset the audio format and release the buffer
+ * allocate a buffer and set the given audio format.
+ *
+ * so far we use a physically linear buffer although packetize transfer
+ * doesn't need a continuous area.
+ * if sg buffer is supported on the later version of alsa, we'll follow
+ * that.
*/
-static int snd_usb_hw_free(struct snd_pcm_substream *substream)
+static int snd_usb_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *hw_params)
{
struct snd_usb_substream *subs = substream->runtime->private_data;
+
+ return snd_usb_attach_endpoints(subs, hw_params);
+}
+
+int snd_usb_detach_endpoint(struct snd_usb_substream *subs)
+{
struct snd_usb_audio *chip = subs->stream->chip;
snd_media_stop_pipeline(subs);
@@ -603,6 +623,19 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
return 0;
}
+EXPORT_SYMBOL_GPL(snd_usb_detach_endpoint);
+
+/*
+ * hw_free callback
+ *
+ * reset the audio format and release the buffer
+ */
+static int snd_usb_hw_free(struct snd_pcm_substream *substream)
+{
+ struct snd_usb_substream *subs = substream->runtime->private_data;
+
+ return snd_usb_detach_endpoint(subs);
+}
/* free-wheeling mode? (e.g. dmix) */
static int in_free_wheeling_mode(struct snd_pcm_runtime *runtime)
diff --git a/sound/usb/pcm.h b/sound/usb/pcm.h
index 388fe2ba346d..e36df3611a05 100644
--- a/sound/usb/pcm.h
+++ b/sound/usb/pcm.h
@@ -15,4 +15,15 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs);
int snd_usb_audioformat_set_sync_ep(struct snd_usb_audio *chip,
struct audioformat *fmt);
+const struct audioformat *
+snd_usb_find_format(struct list_head *fmt_list_head, snd_pcm_format_t format,
+ unsigned int rate, unsigned int channels, bool strict_match,
+ struct snd_usb_substream *subs);
+const struct audioformat *
+snd_usb_find_substream_format(struct snd_usb_substream *subs,
+ const struct snd_pcm_hw_params *params);
+
+int snd_usb_attach_endpoints(struct snd_usb_substream *subs,
+ struct snd_pcm_hw_params *hw_params);
+int snd_usb_detach_endpoint(struct snd_usb_substream *subs);
#endif /* __USBAUDIO_PCM_H */
next prev parent reply other threads:[~2023-08-29 21:08 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
2023-08-29 21:06 ` Wesley Cheng [this message]
2023-08-30 12:50 ` [PATCH v5 12/32] sound: usb: Export USB SND APIs for modules 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=20230829210657.9904-13-quic_wcheng@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 \
/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).