lkml.org 
[lkml]   [2023]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v10 21/41] ASoC: usb: Add PCM format check API for USB backend
Date
Introduce a helper to check 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 | 2 ++
sound/soc/soc-usb.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)

diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h
index 71e2e69ae3a2..f42e7f224549 100644
--- a/include/sound/soc-usb.h
+++ b/include/sound/soc-usb.h
@@ -38,6 +38,8 @@ struct snd_soc_usb {
};

const char *snd_soc_usb_get_components_tag(bool playback);
+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, struct snd_soc_usb_device *sdev);
int snd_soc_usb_disconnect(struct device *usbdev, struct snd_soc_usb_device *sdev);
diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
index 2f3ef835052b..d62a51d9196c 100644
--- a/sound/soc/soc-usb.c
+++ b/sound/soc/soc-usb.c
@@ -80,6 +80,31 @@ void *snd_soc_usb_find_priv_data(struct device *dev)
}
EXPORT_SYMBOL_GPL(snd_soc_usb_find_priv_data);

+/**
+ * snd_soc_usb_find_format() - Check if audio format is supported
+ * @card_idx: USB sound chip array index
+ * @params: PCM parameters
+ * @direction: capture or playback
+ *
+ * Ensure that a requested audio profile from the ASoC side is able to be
+ * supported by the USB device.
+ *
+ * Return 0 on success, negative on error.
+ *
+ */
+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_allocate_port() - allocate a SOC USB device
* @component: USB DPCM backend DAI component
\
 
 \ /
  Last update: 2023-12-15 22:52    [W:0.505 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site