diff mbox series

[RFC,11/14] sound: soc: soc-usb: Add PCM format check API for USB backend

Message ID 20221223233200.26089-12-quic_wcheng@quicinc.com
State New
Headers show
Series Introduce QC USB SND audio offloading support | expand

Commit Message

Wesley Cheng Dec. 23, 2022, 11:31 p.m. UTC
Introduce a check for if a particular PCM format is supported by the USB
audio device connected.  If the USB audio device does not have an audio
profile which can support the requested format, then notify the USB
backend.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
 include/sound/soc-usb.h |  3 +++
 sound/soc/soc-usb.c     | 13 +++++++++++++
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h
index 7d52e5d2371c..36df6f4fe093 100644
--- a/include/sound/soc-usb.h
+++ b/include/sound/soc-usb.h
@@ -19,6 +19,9 @@  struct snd_soc_usb {
 	void *priv_data;
 };
 
+int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params,
+			int direction);
+
 int snd_soc_usb_connect(int card_idx);
 int snd_soc_usb_disconnect(void);
 void snd_soc_usb_set_priv_data(void *priv);
diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
index c6c376960e4d..021380a022bc 100644
--- a/sound/soc/soc-usb.c
+++ b/sound/soc/soc-usb.c
@@ -25,6 +25,19 @@  void snd_soc_usb_set_priv_data(void *priv)
 }
 EXPORT_SYMBOL_GPL(snd_soc_usb_set_priv_data);
 
+int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params,
+			int direction)
+{
+	struct snd_usb_stream *as;
+
+	as = snd_usb_find_suppported_substream(card_idx, params, direction);
+	if (!as)
+		return -EOPNOTSUPP;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_usb_find_format);
+
 struct snd_soc_usb *snd_soc_usb_add_port(struct device *dev,
 			int (*connection_cb)(struct snd_soc_usb *usb, int card_idx,
 			int connected))