[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240422224906.15868-36-quic_wcheng@quicinc.com>
Date: Mon, 22 Apr 2024 15:49:00 -0700
From: Wesley Cheng <quic_wcheng@...cinc.com>
To: <srinivas.kandagatla@...aro.org>, <mathias.nyman@...el.com>,
<perex@...ex.cz>, <conor+dt@...nel.org>, <corbet@....net>,
<lgirdwood@...il.com>, <andersson@...nel.org>,
<krzysztof.kozlowski+dt@...aro.org>, <gregkh@...uxfoundation.org>,
<Thinh.Nguyen@...opsys.com>, <broonie@...nel.org>,
<bgoswami@...cinc.com>, <tiwai@...e.com>, <robh@...nel.org>,
<konrad.dybcio@...aro.org>
CC: <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-sound@...r.kernel.org>, <linux-usb@...r.kernel.org>,
<linux-arm-msm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
<alsa-devel@...a-project.org>, Wesley Cheng <quic_wcheng@...cinc.com>
Subject: [PATCH v19 35/41] ASoC: usb: Fetch ASoC sound card information
For USB sound to expose mixer controls to fetch information about the ASoC
sound card, add an API that returns the platform sound card number that is
registered with SOC USB. Knowing this allows for applications to further
query about the offload status.
Signed-off-by: Wesley Cheng <quic_wcheng@...cinc.com>
---
include/sound/soc-usb.h | 6 ++++++
sound/soc/soc-usb.c | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/include/sound/soc-usb.h b/include/sound/soc-usb.h
index 3137f538270f..56df503c4ecf 100644
--- a/include/sound/soc-usb.h
+++ b/include/sound/soc-usb.h
@@ -85,6 +85,7 @@ int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params,
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);
void *snd_soc_usb_find_priv_data(struct device *dev);
+int snd_soc_usb_device_offload_available(struct device *dev);
int snd_soc_usb_prepare_session(struct snd_soc_usb *usb, int card_idx, int pcm_idx);
int snd_soc_usb_shutdown_session(struct snd_soc_usb *usb, int session_id);
@@ -128,6 +129,11 @@ static inline void *snd_soc_usb_find_priv_data(struct device *dev)
return NULL;
}
+static inline int snd_soc_usb_device_offload_available(struct device *dev)
+{
+ return -ENODEV;
+}
+
static inline int snd_soc_usb_prepare_session(struct snd_soc_usb *usb, int card_idx,
int pcm_idx)
{
diff --git a/sound/soc/soc-usb.c b/sound/soc/soc-usb.c
index 27c76a33da32..53c4e399909e 100644
--- a/sound/soc/soc-usb.c
+++ b/sound/soc/soc-usb.c
@@ -457,6 +457,32 @@ int snd_soc_usb_find_format(int card_idx, struct snd_pcm_hw_params *params,
}
EXPORT_SYMBOL_GPL(snd_soc_usb_find_format);
+/**
+ * snd_soc_usb_device_offload_available() - Fetch BE DAI link sound card
+ * @dev: the device to find in SOC USB
+ *
+ * Finds the component linked to a specific SOC USB instance, and returns
+ * the sound card number for the platform card supporting offloading.
+ *
+ */
+int snd_soc_usb_device_offload_available(struct device *dev)
+{
+ struct snd_soc_usb *ctx;
+ struct device_node *node;
+
+ node = snd_soc_find_phandle(dev);
+ if (IS_ERR(node))
+ return -ENODEV;
+
+ ctx = snd_soc_find_usb_ctx(node);
+ of_node_put(node);
+ if (!ctx)
+ return -ENODEV;
+
+ return ctx->component->card->snd_card->number;
+}
+EXPORT_SYMBOL_GPL(snd_soc_usb_device_offload_available);
+
/**
* snd_soc_usb_allocate_port() - allocate a SOC USB device
* @component: USB DPCM backend DAI component
Powered by blists - more mailing lists