[PATCH v2 19/19] ASoC: qcom: sc8280xp: allow using the sc8280xp card with lpass-cpu
From: Neil Armstrong
Date: Tue Nov 24 2026 - 12:33:43 EST
When the ADSP is not used, the sound card links use the LPASS CPU dais
directly, those links are neither DPCM frontends nor backends.
The LPASS CPU dai ids from qcom,lpass.h overlap with the DSP dai ids
from qcom,q6dsp-lpass-ports.h, so add separate init and ops callbacks
for those DSP Bypass links and keep the DSP backends handling unchanged,
allowing the sm8650 sound card bindings to work with either the
Audioreach or the lpass-cpu interfaces.
Also attach the WCD jack to the LPASS CPU TX codec DMA dais on the
DSP Bypass links in qcom_snd_wcd_jack_setup().
Signed-off-by: Neil Armstrong <neil.armstrong@xxxxxxxxxx>
---
sound/soc/qcom/common.c | 43 ++++++++++++++---------
sound/soc/qcom/sc8280xp.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 115 insertions(+), 16 deletions(-)
diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c
index af5cacddf67d..65f0db493642 100644
--- a/sound/soc/qcom/common.c
+++ b/sound/soc/qcom/common.c
@@ -2,6 +2,7 @@
// Copyright (c) 2018, Linaro Limited.
// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+#include <dt-bindings/sound/qcom,lpass.h>
#include <dt-bindings/sound/qcom,q6afe.h>
#include <linux/module.h>
#include <sound/jack.h>
@@ -420,25 +421,35 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
if (rval)
return rval;
- switch (cpu_dai->id) {
- case LPI_MI2S_RX_0:
- case TX_CODEC_DMA_TX_0:
- case TX_CODEC_DMA_TX_1:
- case TX_CODEC_DMA_TX_2:
- case TX_CODEC_DMA_TX_3:
- for_each_rtd_codec_dais(rtd, i, codec_dai) {
- rval = snd_soc_component_set_jack(codec_dai->component,
- jack, NULL);
- if (rval != 0 && rval != -ENOTSUPP) {
- dev_warn(card->dev, "Failed to set jack: %d\n", rval);
- return rval;
- }
+ if (qcom_snd_is_dsp_bypass_link(rtd)) {
+ switch (cpu_dai->id) {
+ case LPASS_CDC_DMA_TX0 ... LPASS_CDC_DMA_TX3:
+ break;
+ default:
+ return 0;
+ }
+ } else {
+ switch (cpu_dai->id) {
+ case LPI_MI2S_RX_0:
+ case TX_CODEC_DMA_TX_0:
+ case TX_CODEC_DMA_TX_1:
+ case TX_CODEC_DMA_TX_2:
+ case TX_CODEC_DMA_TX_3:
+ break;
+ default:
+ return 0;
}
+ }
- break;
- default:
- break;
+ for_each_rtd_codec_dais(rtd, i, codec_dai) {
+ rval = snd_soc_component_set_jack(codec_dai->component,
+ jack, NULL);
+ if (rval != 0 && rval != -ENOTSUPP) {
+ dev_warn(card->dev, "Failed to set jack: %d\n", rval);
+ return rval;
+ }
}
+
return 0;
}
EXPORT_SYMBOL_GPL(qcom_snd_wcd_jack_setup);
diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c
index ac4dfb2c2182..4fcccf7ec496 100644
--- a/sound/soc/qcom/sc8280xp.c
+++ b/sound/soc/qcom/sc8280xp.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022, Linaro Limited
+#include <dt-bindings/sound/qcom,lpass.h>
#include <dt-bindings/sound/qcom,q6afe.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -377,6 +378,37 @@ static int nord_snd_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
+static int sc8280xp_lpass_snd_init(struct snd_soc_pcm_runtime *rtd)
+{
+ struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+ struct snd_soc_card *card = rtd->card;
+
+ switch (cpu_dai->id) {
+ case LPASS_CDC_DMA_WSA_RX0:
+ case LPASS_CDC_DMA_WSA_RX1:
+ /*
+ * Set limit of -3 dB on Digital Volume and 0 dB on PA Volume
+ * to reduce the risk of speaker damage until we have active
+ * speaker protection in place.
+ */
+ snd_soc_limit_volume(card, "WSA_RX0 Digital Volume", 81);
+ snd_soc_limit_volume(card, "WSA_RX1 Digital Volume", 81);
+ snd_soc_limit_volume(card, "SpkrLeft PA Volume", 17);
+ snd_soc_limit_volume(card, "SpkrRight PA Volume", 17);
+ break;
+ case LPASS_DP_RX:
+ return qcom_snd_dp_jack_setup(rtd, &data->dp_jack[0], 0);
+ default:
+ break;
+ }
+
+ if (data->priv->wcd_jack)
+ return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
+
+ return 0;
+}
+
static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
@@ -538,6 +570,58 @@ static const struct snd_soc_ops sc8280xp_be_ops = {
.prepare = sc8280xp_snd_prepare,
};
+static int sc8280xp_lpass_snd_hw_params(struct snd_pcm_substream *substream,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
+ struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
+ int mclk_freq = sc8280xp_get_mclk_freq(params);
+ struct snd_soc_dai *codec_dai;
+ int ret, i;
+
+ switch (cpu_dai->id) {
+ case MI2S_PRIMARY ... MI2S_QUINARY:
+ case MI2S_SENARY ... MI2S_SEPTENARY:
+ for_each_rtd_codec_dais(rtd, i, codec_dai) {
+ if (data->priv->codec_dai_fmt) {
+ ret = snd_soc_dai_set_fmt(codec_dai,
+ data->priv->codec_dai_fmt);
+ if (ret && ret != -ENOTSUPP)
+ return ret;
+ }
+
+ if (data->priv->codec_sysclk_set) {
+ ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk_freq,
+ SND_SOC_CLOCK_IN);
+ if (ret && ret != -ENOTSUPP)
+ return ret;
+ }
+ }
+
+ /* The LPASS CPU dai sets its bit clock from the hw params */
+ if (data->priv->mi2s_mclk_enable) {
+ ret = snd_soc_dai_set_sysclk(cpu_dai, LPASS_MCLK0, mclk_freq,
+ SND_SOC_CLOCK_OUT);
+ if (ret)
+ return ret;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static const struct snd_soc_ops sc8280xp_lpass_ops = {
+ .startup = qcom_snd_sdw_startup,
+ .shutdown = qcom_snd_sdw_shutdown,
+ .hw_params = sc8280xp_lpass_snd_hw_params,
+ .hw_free = sc8280xp_snd_hw_free,
+ .prepare = sc8280xp_snd_prepare,
+};
+
static void sc8280xp_add_be_ops(struct snd_soc_card *card)
{
struct snd_soc_dai_link *link;
@@ -549,6 +633,10 @@ static void sc8280xp_add_be_ops(struct snd_soc_card *card)
link->exit = sc8280xp_snd_exit;
link->be_hw_params_fixup = sc8280xp_be_hw_params_fixup;
link->ops = &sc8280xp_be_ops;
+ } else if (!link->dynamic) {
+ /* DSP Bypass link, neither a DPCM frontend nor a backend */
+ link->init = sc8280xp_lpass_snd_init;
+ link->ops = &sc8280xp_lpass_ops;
}
}
}
--
2.34.1