Skip to contentSkip to conversation

ASoC: qcom: Shikra machine driver and DT binding support

PATCH New Mohammad Rafi Shaik 2 participants 7 messages Nov 22

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover ASoC: qcom: Shikra machine driver and DT binding support

This series adds Qualcomm Shikra sound-card variant support in DT bindings and in the sc8280xp machine driver.

Shikra EVK variants use different audio components and processing architectures:
- CQM/CQS use an I2S-based path with WSA885x amplifiers and PM4125 + Rouleur codec components.
- CQS uses modem-DSP based audio processing.
- IQS uses a third-party MAX98091 codec with modem-DSP support.

---
Changes in v3:
- Fixed the dummy codec backend ops issue reported by Prasad.
- Fixed the issues reported on Sashiko.
- Reused the existing DAPM widgets.
- Link to v2: https://lore.kernel.org/all/[email protected]/

Changes in v2:
- Split the single machine-driver patch into four separate patches
as requested by Srinivas and Dmitry:
- Patch 2/5: extend hw_params for QAIF MI2S/TDM DAI ranges,
add cpu_dai_fmt, VA_CODEC_DMA_TX_1 and be_ops filter changes
- Patch 3/5: CQM variant support
- Patch 4/5: CQS variant support
- Patch 5/5: IQS variant support
- Carry forward Reviewed-by from Krzysztof on the DT binding patch
- Use correct struct type (qcom_snd_soc_common) for all priv_data
- Link to v1: https://lore.kernel.org/all/[email protected]/

To: Srinivas Kandagatla <[email protected]>
To: Liam Girdwood <[email protected]>
To: Mark Brown <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
To: Jaroslav Kysela <[email protected]>
To: Takashi Iwai <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Ajay Kumar Nandam (5):

      ASoC: dt-bindings: qcom,sm8250: add Shikra sound card compatibles
      ASoC: qcom: sc8280xp: add Shikra backend handling
      ASoC: qcom: sc8280xp: Add shikra-cqm-evk compatible support
      ASoC: qcom: sc8280xp: Add shikra-cqs-evk compatible support
      ASoC: qcom: sc8280xp: Add shikra-iqs-evk compatible support
 .../devicetree/bindings/sound/qcom,sm8250.yaml     |  3 +
 sound/soc/qcom/common.c                            |  1 +
 sound/soc/qcom/sc8280xp.c                          | 70 +++++++++++++++++++++-
 sound/soc/qcom/sdw.c                               |  1 +
 4 files changed, 72 insertions(+), 3 deletions(-)

---
base-commit: 7884221ca9857a317bf4bd81ac3bf5528f266feb
change-id: 20261123-shikra-machine-dc95e3c86af3

Best regards,

Signature · 1 line
Mohammad Rafi Shaik <[email protected]>
#1 lore raw

PATCH v3 1/5 ASoC: dt-bindings: qcom,sm8250: add Shikra sound card compatibles

From: Ajay Kumar Nandam <[email protected]>

Add Shikra sound-card compatible strings to the Qualcomm sound card binding so DT can describe board-specific audio topologies:

- qcom,shikra-cqm-sndcard
- qcom,shikra-cqs-sndcard
- qcom,shikra-iqs-sndcard

Shikra EVK variants use different codec/interface combinations and DSP processing paths. Describing these variants explicitly in DT allows the machine driver to select the correct DAPM routes, controls, and clocking behavior for each board.

---
 Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +3 -0
index a890fa288a76..1dc164e2c73c 100644
@@ -57,6 +57,9 @@ properties:
           - qcom,sc8280xp-sndcard
           - qcom,sdm660-sndcard
           - qcom,sdm845-sndcard
+          - qcom,shikra-cqm-sndcard
+          - qcom,shikra-cqs-sndcard
+          - qcom,shikra-iqs-sndcard
           - qcom,sm8250-sndcard
           - qcom,sm8450-sndcard
           - qcom,x1e80100-sndcard
Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 2/5 ASoC: qcom: sc8280xp: add Shikra backend handling

In reply to Mohammad Rafi Shaik

From: Ajay Kumar Nandam <[email protected]>

Add the remaining sc8280xp machine-driver support needed by Shikra audio links now that the generic QAIF DAI ID support is upstream.

Allow board data to override the CPU DAI format per DAI, so Shikra CQM can use DSP_A only for the QAIF TDM speaker backend without changing the default format for other boards.

Also handle VA_CODEC_DMA_TX_1 as a SoundWire-style capture DAI and allow Shikra cards to attach BE ops to codec-backed links which are not described as no_pcm backends.

---
 sound/soc/qcom/common.c   |  1 +
 sound/soc/qcom/sc8280xp.c | 17 ++++++++++++++---
 sound/soc/qcom/sdw.c      |  1 +
 3 files changed, 16 insertions(+), 3 deletions(-)
sound/soc/qcom/common.c +1 -0
index af5cacddf67d..77845d43c219 100644
@@ -426,6 +426,7 @@ int qcom_snd_wcd_jack_setup(struct snd_soc_pcm_runtime *rtd,
 	case TX_CODEC_DMA_TX_1:
 	case TX_CODEC_DMA_TX_2:
 	case TX_CODEC_DMA_TX_3:
+	case VA_CODEC_DMA_TX_1:
 		for_each_rtd_codec_dais(rtd, i, codec_dai) {
 			rval = snd_soc_component_set_jack(codec_dai->component,
 							  jack, NULL);
sound/soc/qcom/sc8280xp.c +14 -3
index ac4dfb2c2182..ff8ccd3065eb 100644
@@ -71,6 +71,7 @@ enum sc8280xp_jack_setup {
 struct sc8280xp_dai_data {
 	unsigned int id;
 	unsigned int mclk_rate;
+	unsigned int cpu_dai_fmt;
 	bool codec_sysclk_set;
 	bool mi2s_mclk_enable;
 	bool mi2s_bclk_enable;
@@ -91,6 +92,7 @@ struct qcom_snd_soc_common {
 	int num_controls;
 	unsigned int codec_dai_fmt;
 	bool codec_sysclk_set;
+	bool codec_link_be_ops;
 	bool mi2s_mclk_enable;
 	bool mi2s_bclk_enable;
 	bool mi2s_32bit;
@@ -159,6 +161,7 @@ static int sc8280xp_tdm_hw_params(struct snd_pcm_substream *substream,
 	struct qcom_snd_tdm_slot_cfg codec_cfg;
 	bool codec_sysclk_set = data->priv->codec_sysclk_set;
 	bool mi2s_bclk_enable = data->priv->mi2s_bclk_enable;
+	unsigned int cpu_dai_fmt = SND_SOC_DAIFMT_BP_FP;
 	int bclk_freq;
 	int ret;
 	int i;
@@ -167,6 +170,8 @@ static int sc8280xp_tdm_hw_params(struct snd_pcm_substream *substream,
 	if (dai_data) {
 		codec_sysclk_set = dai_data->codec_sysclk_set;
 		mi2s_bclk_enable = dai_data->mi2s_bclk_enable;
+		if (dai_data->cpu_dai_fmt)
+			cpu_dai_fmt = dai_data->cpu_dai_fmt;
 	}
 
 	ret = qcom_snd_get_dai_tdm_slots(rtd, &cpu_cfg, &codec_cfg);
@@ -176,7 +181,7 @@ static int sc8280xp_tdm_hw_params(struct snd_pcm_substream *substream,
 	if (!cpu_cfg.slots)
 		return 0;
 
-	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP);
+	ret = snd_soc_dai_set_fmt(cpu_dai, cpu_dai_fmt);
 	if (ret && ret != -ENOTSUPP)
 		return ret;
 
@@ -329,6 +334,7 @@ static int sc8280xp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 	case TX_CODEC_DMA_TX_1:
 	case TX_CODEC_DMA_TX_2:
 	case TX_CODEC_DMA_TX_3:
+	case VA_CODEC_DMA_TX_1:
 		channels->min = 1;
 		break;
 	case PRIMARY_MI2S_RX ... QUATERNARY_MI2S_TX:
@@ -388,6 +394,7 @@ static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream,
 	bool codec_sysclk_set = data->priv->codec_sysclk_set;
 	bool mi2s_mclk_enable = data->priv->mi2s_mclk_enable;
 	bool mi2s_bclk_enable = data->priv->mi2s_bclk_enable;
+	unsigned int cpu_dai_fmt = SND_SOC_DAIFMT_BP_FP;
 	int mclk_freq;
 	int bclk_freq = sc8280xp_get_bclk_freq(params);
 	int ret;
@@ -398,6 +405,8 @@ static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream,
 		codec_sysclk_set = dai_data->codec_sysclk_set;
 		mi2s_mclk_enable = dai_data->mi2s_mclk_enable;
 		mi2s_bclk_enable = dai_data->mi2s_bclk_enable;
+		if (dai_data->cpu_dai_fmt)
+			cpu_dai_fmt = dai_data->cpu_dai_fmt;
 		if (dai_data->mclk_rate)
 			mclk_freq = dai_data->mclk_rate;
 	}
@@ -408,7 +417,7 @@ static int sc8280xp_snd_hw_params(struct snd_pcm_substream *substream,
 	case SENARY_MI2S_RX ... SENARY_MI2S_TX:
 	case LPI_MI2S_RX_0 ... LPI_MI2S_TX_4:
 	case AIF_MI2S_RX_0 ... AIF_MI2S_TX_12:
-		ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP);
+		ret = snd_soc_dai_set_fmt(cpu_dai, cpu_dai_fmt);
 		if (ret && ret != -ENOTSUPP)
 			return ret;
 
@@ -540,11 +549,13 @@ static const struct snd_soc_ops sc8280xp_be_ops = {
 
 static void sc8280xp_add_be_ops(struct snd_soc_card *card)
 {
+	struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(card);
 	struct snd_soc_dai_link *link;
 	int i;
 
 	for_each_card_prelinks(card, i, link) {
-		if (link->no_pcm == 1) {
+		if (link->no_pcm == 1 ||
+		    (data->priv->codec_link_be_ops && link->num_codecs > 0)) {
 			link->init = sc8280xp_snd_init;
 			link->exit = sc8280xp_snd_exit;
 			link->be_hw_params_fixup = sc8280xp_be_hw_params_fixup;
sound/soc/qcom/sdw.c +1 -0
index 6576b47a4c8c..e19adb7c750b 100644
@@ -30,6 +30,7 @@ static bool qcom_snd_is_sdw_dai(int id)
 	case TX_CODEC_DMA_TX_5:
 	case RX_CODEC_DMA_RX_6:
 	case RX_CODEC_DMA_RX_7:
+	case VA_CODEC_DMA_TX_1:
 	case SLIMBUS_0_RX...SLIMBUS_6_TX:
 		return true;
 	default:
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v3 2/5] ASoC: qcom: sc8280xp: add Shikra backend handling

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ASoC: qcom: sc8280xp: num_codecs check in sc8280xp_add_be_ops() matches FEs --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] ASoC: qcom: sc8280xp: num_codecs check in sc8280xp_add_be_ops() matches FEs
--

commit c0216a2b49790ae6ec3eaaa0b8959c3342929be7
Author: Ajay Kumar Nandam <[email protected]>

ASoC: qcom: sc8280xp: add Shikra backend handling

This commit adds per-DAI CPU format overrides, VA_CODEC_DMA_TX_1 handling, and an option to attach backend operations to codec-backed links on sc8280xp sound cards.

Quoted 4 lines
sound/soc/qcom/sc8280xp.c +0 -0
index ac4dfb2c2182c..ff8ccd3065eb9 100644

[ ... ]

Quoted 5 lines
sound/soc/qcom/sc8280xp.c +1 -0
@@ -540,11 +549,13 @@ static const struct snd_soc_ops sc8280xp_be_ops = {
 
 static void sc8280xp_add_be_ops(struct snd_soc_card *card)
 {
+	struct sc8280xp_snd_data *data = snd_soc_card_get_drvdata(card);

sound/soc/qcom/sc8280xp.c static const struct snd_soc_ops sc8280xp_be_ops = { · line 561

Quoted 10 lines
sound/soc/qcom/sc8280xp.c +2 -1
 	struct snd_soc_dai_link *link;
 	int i;
 
 	for_each_card_prelinks(card, i, link) {
-		if (link->no_pcm == 1) {
+		if (link->no_pcm == 1 ||
+		    (data->priv->codec_link_be_ops && link->num_codecs > 0)) {
 			link->init = sc8280xp_snd_init;
 			link->exit = sc8280xp_snd_exit;
 			link->be_hw_params_fixup = sc8280xp_be_hw_params_fixup;

[Severity: Medium]
Does checking link->num_codecs > 0 attach backend ops to codeless DPCM frontend links as well?

card->dai_link is populated by qcom_snd_parse_of(), which sets num_codecs = 1 on DPCM frontend links using the dummy codec:

sound/soc/qcom/common.c:qcom_snd_parse_of() {
    ...
		if (codec) {
			ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
			if (ret < 0) {
				dev_err_probe(card->dev, ret,
					      "%s: codec dai not found\n", link->name);
				goto err;
			}

			if (platform) {
				/* DPCM backend */
				link->no_pcm = 1;
				link->ignore_pmdown_time = 1;
			}
		} else {
			/* DPCM frontend */
			link->codecs	 = &snd_soc_dummy_dlc;
			link->num_codecs = 1;
			link->dynamic = 1;
		}
    ...
}

Because num_codecs is at least 1 for every link, enabling codec_link_be_ops attaches sc8280xp_be_ops to DPCM frontend links too. If a card defines frontend links whose CPU DAI IDs (such as MSM_FRONTEND_DAI_MULTIMEDIA3..16) overlap with the SLIMBUS_0_RX..SLIMBUS_6_TX IDs matched by qcom_snd_is_sdw_dai(), opening and closing the frontend stream calls qcom_snd_sdw_startup() and leaks a struct sdw_stream_runtime because snd-soc-dummy-dai returns -ENOTSUPP for set_stream and get_stream.

Checking !link->dynamic (or link->codecs != &snd_soc_dummy_dlc) would restrict this to links backed by real codecs.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#4 lore raw

PATCH v3 3/5 ASoC: qcom: sc8280xp: Add shikra-cqm-evk compatible support

In reply to Mohammad Rafi Shaik

From: Ajay Kumar Nandam <[email protected]>

Add machine driver support for the Qualcomm Shikra CQM EVK board. The Shikra CQM platform uses an I2S-based audio path with WSA885x amplifiers and PM4125/Rouleur codec components.

Configure the CQM QAIF TDM speaker backend with DSP_A framing using per-DAI board data.

---
 sound/soc/qcom/sc8280xp.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
sound/soc/qcom/sc8280xp.c +16 -0
index ff8ccd3065eb..e1d701a1b1dd 100644
@@ -727,6 +727,21 @@ static const struct qcom_snd_soc_common sc8280xp_priv_data = {
 	.wcd_jack = true,
 };
 
+static const struct qcom_snd_soc_common shikra_cqm_priv_data = {
+	.driver_name = "shikra",
+	.dapm_widgets = sc8280xp_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(sc8280xp_dapm_widgets),
+	.codec_link_be_ops = true,
+	.wcd_jack = true,
+	SC8280XP_DAI_DATA({
+			.id = AIF_TDM_RX_2,
+			.cpu_dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_BP_FP,
+			.codec_sysclk_set = true,
+			.mi2s_bclk_enable = true,
+		}
+	),
+};
+
 static const struct qcom_snd_soc_common sm8450_priv_data = {
 	.driver_name = "sm8450",
 	.dapm_widgets = sc8280xp_dapm_widgets,
@@ -796,6 +811,7 @@ static const struct of_device_id snd_sc8280xp_dt_match[] = {
 	{ .compatible = "qcom,qcs9075-sndcard", .data = &qcs9100_priv_data },
 	{ .compatible = "qcom,qcs9100-sndcard", .data = &qcs9100_priv_data },
 	{ .compatible = "qcom,sc8280xp-sndcard", .data = &sc8280xp_priv_data },
+	{ .compatible = "qcom,shikra-cqm-sndcard", .data = &shikra_cqm_priv_data },
 	{ .compatible = "qcom,sm8450-sndcard", .data = &sm8450_priv_data },
 	{ .compatible = "qcom,sm8475-sndcard", .data = &sm8475_priv_data },
 	{ .compatible = "qcom,sm8550-sndcard", .data = &sm8550_priv_data },
Signature · 1 line
2.34.1
#5 lore raw

PATCH v3 4/5 ASoC: qcom: sc8280xp: Add shikra-cqs-evk compatible support

In reply to Mohammad Rafi Shaik

From: Ajay Kumar Nandam <[email protected]>

Add machine driver support for the Qualcomm Shikra CQS EVK board. The Shikra CQS platform uses an I2S-based audio path with WSA885x amplifiers and PM4125/Rouleur codec components with modem-DSP based audio processing.

---
 sound/soc/qcom/sc8280xp.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
sound/soc/qcom/sc8280xp.c +14 -0
index e1d701a1b1dd..bf62e8330276 100644
@@ -742,6 +742,19 @@ static const struct qcom_snd_soc_common shikra_cqm_priv_data = {
 	),
 };
 
+static const struct qcom_snd_soc_common shikra_cqs_priv_data = {
+	.driver_name = "shikra",
+	.dapm_widgets = sc8280xp_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(sc8280xp_dapm_widgets),
+	.wcd_jack = true,
+	SC8280XP_DAI_DATA({
+			.id = AIF_TDM_RX_2,
+			.codec_sysclk_set = true,
+			.mi2s_bclk_enable = true,
+		}
+	),
+};
+
 static const struct qcom_snd_soc_common sm8450_priv_data = {
 	.driver_name = "sm8450",
 	.dapm_widgets = sc8280xp_dapm_widgets,
@@ -812,6 +825,7 @@ static const struct of_device_id snd_sc8280xp_dt_match[] = {
 	{ .compatible = "qcom,qcs9100-sndcard", .data = &qcs9100_priv_data },
 	{ .compatible = "qcom,sc8280xp-sndcard", .data = &sc8280xp_priv_data },
 	{ .compatible = "qcom,shikra-cqm-sndcard", .data = &shikra_cqm_priv_data },
+	{ .compatible = "qcom,shikra-cqs-sndcard", .data = &shikra_cqs_priv_data },
 	{ .compatible = "qcom,sm8450-sndcard", .data = &sm8450_priv_data },
 	{ .compatible = "qcom,sm8475-sndcard", .data = &sm8475_priv_data },
 	{ .compatible = "qcom,sm8550-sndcard", .data = &sm8550_priv_data },
Signature · 1 line
2.34.1
#6 lore raw

PATCH v3 5/5 ASoC: qcom: sc8280xp: Add shikra-iqs-evk compatible support

In reply to Mohammad Rafi Shaik

From: Ajay Kumar Nandam <[email protected]>

Add machine driver support for the Qualcomm Shikra IQS EVK board. The Shikra IQS platform uses a third-party MAX98091 codec with modem-DSP support.

IQS requires board-level DAPM widgets and pin-switch kcontrols because the MAX98091 codec driver does not expose its own endpoint topology, unlike the Qualcomm WSA885x/Rouleur codecs used on the CQM/CQS variants.

---
 sound/soc/qcom/sc8280xp.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
sound/soc/qcom/sc8280xp.c +23 -0
index bf62e8330276..a380c82afefa 100644
@@ -45,6 +45,7 @@ static struct snd_soc_dapm_widget sc8280xp_dapm_widgets[] = {
 static const struct snd_kcontrol_new max98090_controls[] = {
 	SOC_DAPM_PIN_SWITCH("Headset Mic12"),
 	SOC_DAPM_PIN_SWITCH("Headphone"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic34"),
 	SOC_DAPM_PIN_SWITCH("Headset Mic56"),
 	SOC_DAPM_PIN_SWITCH("Speaker"),
 	SOC_DAPM_PIN_SWITCH("Receiver"),
@@ -56,6 +57,7 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
 	SND_SOC_DAPM_MIC("Mic Jack", NULL),
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic12", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic34", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic56", NULL),
 	SND_SOC_DAPM_MIC("Int Mic", NULL),
 	SND_SOC_DAPM_SPK("Receiver", NULL),
@@ -755,6 +757,26 @@ static const struct qcom_snd_soc_common shikra_cqs_priv_data = {
 	),
 };
 
+static const struct qcom_snd_soc_common shikra_iqs_priv_data = {
+	.driver_name = "shikra",
+	.dapm_widgets = max98090_dapm_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(max98090_dapm_widgets),
+	.controls = max98090_controls,
+	.num_controls = ARRAY_SIZE(max98090_controls),
+	.codec_dai_fmt = SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_BC_FC,
+	SC8280XP_DAI_DATA({
+			.id = AIF_MI2S_RX_0,
+			.codec_sysclk_set = true,
+			.mi2s_bclk_enable = true,
+			.jack_setup = SC8280XP_JACK_SETUP_CODEC,
+		}, {
+			.id = AIF_MI2S_TX_0,
+			.codec_sysclk_set = true,
+			.mi2s_bclk_enable = true,
+		}
+	),
+};
+
 static const struct qcom_snd_soc_common sm8450_priv_data = {
 	.driver_name = "sm8450",
 	.dapm_widgets = sc8280xp_dapm_widgets,
@@ -826,6 +848,7 @@ static const struct of_device_id snd_sc8280xp_dt_match[] = {
 	{ .compatible = "qcom,sc8280xp-sndcard", .data = &sc8280xp_priv_data },
 	{ .compatible = "qcom,shikra-cqm-sndcard", .data = &shikra_cqm_priv_data },
 	{ .compatible = "qcom,shikra-cqs-sndcard", .data = &shikra_cqs_priv_data },
+	{ .compatible = "qcom,shikra-iqs-sndcard", .data = &shikra_iqs_priv_data },
 	{ .compatible = "qcom,sm8450-sndcard", .data = &sm8450_priv_data },
 	{ .compatible = "qcom,sm8475-sndcard", .data = &sm8475_priv_data },
 	{ .compatible = "qcom,sm8550-sndcard", .data = &sm8550_priv_data },
Signature · 1 line
2.34.1