diff mbox series

[v4,20/32] sound: soc: soc-usb: Add PCM format check API for USB backend

Message ID 20230725023416.11205-21-quic_wcheng@quicinc.com
State Superseded
Headers show
Series None | expand

Commit Message

Wesley Cheng July 25, 2023, 2:34 a.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 378992ea07bd..71e6e75e600a 100644
--- a/include/sound/soc-usb.h
+++ b/include/sound/soc-usb.h
@@ -23,6 +23,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(struct device *usbdev, int card_idx);
 int snd_soc_usb_disconnect(struct device *usbdev);
 void snd_soc_usb_set_priv_data(struct device *dev, void *priv);
diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
index 4293451cdd49..cdce1bb42df5 100644
--- a/sound/soc/soc-usb.c
+++ b/sound/soc/soc-usb.c
@@ -70,6 +70,19 @@  void *snd_soc_usb_get_priv_data(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_soc_usb_get_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);
+
 /**
  * snd_soc_usb_add_port() - Add a USB backend port
  * @dev: USB backend device