From: Srinivas Kandagatla <srini@kernel.org>
To: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>,
Srinivas Kandagatla <srini@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 v6 5/9] ASoC: qcom: lpass-va-macro: Add SoundWire microphone support
Date: Mon, 9 Nov 2026 15:23:39 +0000 [thread overview]
Message-ID: <f1fa6cd5-3e76-4033-80f3-0233975207ab@kernel.org> (raw)
In-Reply-To: <20261106-add_shikra_support-v6-5-2cda302237cc@oss.qualcomm.com>
On 11/6/26 12:33 PM, Mohammad Rafi Shaik wrote:
> The VA decimators can currently capture audio only from DMIC inputs.
> Add support for routing audio from SoundWire microphone (SMIC) inputs
> as well.
>
> Update the decimator source selection logic to switch between DMIC and
> SMIC sources based on the active input path.
>
> The ADC_DMIC_SEL bit of CDC_VA_TXn_TX_PATH_CFG0 is shared by the DMIC and
> the SoundWire mic mux, so a mixer write to the mux that is not part of the
> active path can leave it stale. Program it from the resolved mux state
> when the decimator is enabled, so capture does not depend on the order in
> which userspace restores the two controls.
>
> Add a helper to detect whether a decimator is using a SoundWire microphone
> input. Use this information to skip DMIC-specific HPF programming sequences
> when the decimator is configured for an SMIC source.
>
> This enables VA decimators to capture audio from either DMIC or SoundWire
> microphone inputs.
>
> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
> ---
lgtm,
Reviewed-by: Srinivas Kandagatla<srinivas.kandagatla@oss.qualcomm.com>
--Srini
> sound/soc/codecs/lpass-va-macro.c | 154 ++++++++++++++++++++++++++++++++++++--
> 1 file changed, 147 insertions(+), 7 deletions(-)
>
> diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c
> index db395674312c..a11347404058 100644
> --- a/sound/soc/codecs/lpass-va-macro.c
> +++ b/sound/soc/codecs/lpass-va-macro.c
> @@ -754,6 +754,16 @@ static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
> return 0;
> }
>
> +static bool is_amic_enabled(struct snd_soc_component *comp, int decimator)
> +{
> + u16 adc_mux_reg;
> +
> + adc_mux_reg = CDC_VA_INP_MUX_ADC_MUX0_CFG1 +
> + VA_MACRO_ADC_MUX_CFG_OFFSET * decimator;
> +
> + return snd_soc_component_read(comp, adc_mux_reg) & BIT(0);
> +}
> +
> static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
> struct snd_ctl_elem_value *ucontrol)
> {
> @@ -763,20 +773,26 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
> struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
> unsigned int val;
> u16 mic_sel_reg;
> + int decimator;
> + bool smic_mux;
>
> val = ucontrol->value.enumerated.item[0];
>
> switch (e->reg) {
> case CDC_VA_INP_MUX_ADC_MUX0_CFG0:
> + decimator = 0;
> mic_sel_reg = CDC_VA_TX0_TX_PATH_CFG0;
> break;
> case CDC_VA_INP_MUX_ADC_MUX1_CFG0:
> + decimator = 1;
> mic_sel_reg = CDC_VA_TX1_TX_PATH_CFG0;
> break;
> case CDC_VA_INP_MUX_ADC_MUX2_CFG0:
> + decimator = 2;
> mic_sel_reg = CDC_VA_TX2_TX_PATH_CFG0;
> break;
> case CDC_VA_INP_MUX_ADC_MUX3_CFG0:
> + decimator = 3;
> mic_sel_reg = CDC_VA_TX3_TX_PATH_CFG0;
> break;
> default:
> @@ -785,10 +801,24 @@ static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
> return -EINVAL;
> }
>
> - if (val != 0)
> + /*
> + * SMIC enums use shift 0 (lower nibble of CFG0), DMIC enums use
> + * shift 4 (upper nibble of CFG0). Use e->shift_l to distinguish them
> + * without relying on widget name comparisons.
> + */
> + smic_mux = (e->shift_l == 0);
> +
> + /*
> + * Both muxes feed the same decimator and share ADC_DMIC_SEL, so only
> + * the one the decimator is routed through may program it. A write to
> + * the mux that is not part of the active path would otherwise switch
> + * the input domain of a running capture.
> + */
> + if (val != 0 && smic_mux == is_amic_enabled(component, decimator))
> snd_soc_component_update_bits(component, mic_sel_reg,
> CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK,
> - CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
> + smic_mux ? CDC_VA_TX_PATH_ADC_DMIC_SEL_ADC :
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
>
> return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
> }
> @@ -978,7 +1008,6 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
> u16 tx_gain_ctl_reg;
> u16 adpt_ctrl_reg;
> u8 hpf_cut_off_freq;
> -
> struct va_macro *va = snd_soc_component_get_drvdata(comp);
>
> decimator = w->shift;
> @@ -995,6 +1024,18 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
>
> switch (event) {
> case SND_SOC_DAPM_PRE_PMU:
> + /*
> + * ADC_DMIC_SEL is shared by the DMIC and the SoundWire mic
> + * mux, so its value depends on the order in which userspace
> + * restores the two controls. Program it from the resolved
> + * mux state of this decimator, which is what selects the
> + * input domain.
> + */
> + snd_soc_component_update_bits(comp, dec_cfg_reg,
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_MASK,
> + is_amic_enabled(comp, decimator) ?
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_ADC :
> + CDC_VA_TX_PATH_ADC_DMIC_SEL_DMIC);
> snd_soc_component_update_bits(comp,
> dec_cfg_reg, CDC_VA_ADC_MODE_MASK,
> va->dec_mode[decimator] << CDC_VA_ADC_MODE_SHIFT);
> @@ -1009,9 +1050,15 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
> snd_soc_component_update_bits(comp, tx_vol_ctl_reg,
> CDC_VA_TX_PATH_CLK_EN_MASK,
> CDC_VA_TX_PATH_CLK_EN);
> - snd_soc_component_update_bits(comp, hpf_gate_reg,
> - CDC_VA_TX_HPF_ZERO_GATE_MASK,
> - CDC_VA_TX_HPF_ZERO_GATE);
> + /*
> + * Only the HPF zero gate assertion is specific to the DMIC
> + * path; the cutoff programming and the gate release below
> + * apply to both input domains.
> + */
> + if (!is_amic_enabled(comp, decimator))
> + snd_soc_component_update_bits(comp, hpf_gate_reg,
> + CDC_VA_TX_HPF_ZERO_GATE_MASK,
> + CDC_VA_TX_HPF_ZERO_GATE);
>
> usleep_range(1000, 1010);
> hpf_cut_off_freq = (snd_soc_component_read(comp, dec_cfg_reg) &
> @@ -1037,7 +1084,6 @@ static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
> 0x0);
> }
>
> -
> usleep_range(1000, 1010);
> snd_soc_component_update_bits(comp, hpf_gate_reg,
> CDC_VA_TX_HPF_ZERO_GATE_MASK,
> @@ -1237,6 +1283,39 @@ static const char * const adc_mux_text[] = {
> "VA_DMIC", "SWR_MIC"
> };
>
> +static const char * const smic_mux_text[] = {
> + "ZERO", "ADC0", "ADC1", "ADC2", "ADC3", "SWR_MIC0", "SWR_MIC1",
> + "SWR_MIC2", "SWR_MIC3", "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7"
> +};
> +
> +static SOC_ENUM_SINGLE_DECL(va_smic0_enum, CDC_VA_INP_MUX_ADC_MUX0_CFG0,
> + 0, smic_mux_text);
> +
> +static SOC_ENUM_SINGLE_DECL(va_smic1_enum, CDC_VA_INP_MUX_ADC_MUX1_CFG0,
> + 0, smic_mux_text);
> +
> +static SOC_ENUM_SINGLE_DECL(va_smic2_enum, CDC_VA_INP_MUX_ADC_MUX2_CFG0,
> + 0, smic_mux_text);
> +
> +static SOC_ENUM_SINGLE_DECL(va_smic3_enum, CDC_VA_INP_MUX_ADC_MUX3_CFG0,
> + 0, smic_mux_text);
> +
> +static const struct snd_kcontrol_new va_smic0_mux = SOC_DAPM_ENUM_EXT("va_smic0",
> + va_smic0_enum, snd_soc_dapm_get_enum_double,
> + va_macro_put_dec_enum);
> +
> +static const struct snd_kcontrol_new va_smic1_mux = SOC_DAPM_ENUM_EXT("va_smic1",
> + va_smic1_enum, snd_soc_dapm_get_enum_double,
> + va_macro_put_dec_enum);
> +
> +static const struct snd_kcontrol_new va_smic2_mux = SOC_DAPM_ENUM_EXT("va_smic2",
> + va_smic2_enum, snd_soc_dapm_get_enum_double,
> + va_macro_put_dec_enum);
> +
> +static const struct snd_kcontrol_new va_smic3_mux = SOC_DAPM_ENUM_EXT("va_smic3",
> + va_smic3_enum, snd_soc_dapm_get_enum_double,
> + va_macro_put_dec_enum);
> +
> static SOC_ENUM_SINGLE_DECL(va_dec0_enum, CDC_VA_INP_MUX_ADC_MUX0_CFG1,
> 0, adc_mux_text);
> static SOC_ENUM_SINGLE_DECL(va_dec1_enum, CDC_VA_INP_MUX_ADC_MUX1_CFG1,
> @@ -1372,6 +1451,11 @@ static const struct snd_soc_dapm_widget va_macro_dapm_widgets[] = {
> SND_SOC_DAPM_MUX("VA DMIC MUX2", SND_SOC_NOPM, 0, 0, &va_dmic2_mux),
> SND_SOC_DAPM_MUX("VA DMIC MUX3", SND_SOC_NOPM, 0, 0, &va_dmic3_mux),
>
> + SND_SOC_DAPM_MUX("VA SMIC MUX0", SND_SOC_NOPM, 0, 0, &va_smic0_mux),
> + SND_SOC_DAPM_MUX("VA SMIC MUX1", SND_SOC_NOPM, 0, 0, &va_smic1_mux),
> + SND_SOC_DAPM_MUX("VA SMIC MUX2", SND_SOC_NOPM, 0, 0, &va_smic2_mux),
> + SND_SOC_DAPM_MUX("VA SMIC MUX3", SND_SOC_NOPM, 0, 0, &va_smic3_mux),
> +
> SND_SOC_DAPM_REGULATOR_SUPPLY("vdd-micb", 0, 0),
> SND_SOC_DAPM_INPUT("DMIC0 Pin"),
> SND_SOC_DAPM_INPUT("DMIC1 Pin"),
> @@ -1516,6 +1600,62 @@ static const struct snd_soc_dapm_route va_audio_map[] = {
> {"VA DMIC MUX3", "DMIC6", "VA DMIC6"},
> {"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
>
> + {"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
> + {"VA SMIC MUX0", "ADC0", "VA SWR_ADC0"},
> + {"VA SMIC MUX0", "ADC1", "VA SWR_ADC1"},
> + {"VA SMIC MUX0", "ADC2", "VA SWR_ADC2"},
> + {"VA SMIC MUX0", "ADC3", "VA SWR_ADC3"},
> + {"VA SMIC MUX0", "SWR_MIC0", "VA SWR_MIC0"},
> + {"VA SMIC MUX0", "SWR_MIC1", "VA SWR_MIC1"},
> + {"VA SMIC MUX0", "SWR_MIC2", "VA SWR_MIC2"},
> + {"VA SMIC MUX0", "SWR_MIC3", "VA SWR_MIC3"},
> + {"VA SMIC MUX0", "SWR_MIC4", "VA SWR_MIC4"},
> + {"VA SMIC MUX0", "SWR_MIC5", "VA SWR_MIC5"},
> + {"VA SMIC MUX0", "SWR_MIC6", "VA SWR_MIC6"},
> + {"VA SMIC MUX0", "SWR_MIC7", "VA SWR_MIC7"},
> +
> + {"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
> + {"VA SMIC MUX1", "ADC0", "VA SWR_ADC0"},
> + {"VA SMIC MUX1", "ADC1", "VA SWR_ADC1"},
> + {"VA SMIC MUX1", "ADC2", "VA SWR_ADC2"},
> + {"VA SMIC MUX1", "ADC3", "VA SWR_ADC3"},
> + {"VA SMIC MUX1", "SWR_MIC0", "VA SWR_MIC0"},
> + {"VA SMIC MUX1", "SWR_MIC1", "VA SWR_MIC1"},
> + {"VA SMIC MUX1", "SWR_MIC2", "VA SWR_MIC2"},
> + {"VA SMIC MUX1", "SWR_MIC3", "VA SWR_MIC3"},
> + {"VA SMIC MUX1", "SWR_MIC4", "VA SWR_MIC4"},
> + {"VA SMIC MUX1", "SWR_MIC5", "VA SWR_MIC5"},
> + {"VA SMIC MUX1", "SWR_MIC6", "VA SWR_MIC6"},
> + {"VA SMIC MUX1", "SWR_MIC7", "VA SWR_MIC7"},
> +
> + {"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
> + {"VA SMIC MUX2", "ADC0", "VA SWR_ADC0"},
> + {"VA SMIC MUX2", "ADC1", "VA SWR_ADC1"},
> + {"VA SMIC MUX2", "ADC2", "VA SWR_ADC2"},
> + {"VA SMIC MUX2", "ADC3", "VA SWR_ADC3"},
> + {"VA SMIC MUX2", "SWR_MIC0", "VA SWR_MIC0"},
> + {"VA SMIC MUX2", "SWR_MIC1", "VA SWR_MIC1"},
> + {"VA SMIC MUX2", "SWR_MIC2", "VA SWR_MIC2"},
> + {"VA SMIC MUX2", "SWR_MIC3", "VA SWR_MIC3"},
> + {"VA SMIC MUX2", "SWR_MIC4", "VA SWR_MIC4"},
> + {"VA SMIC MUX2", "SWR_MIC5", "VA SWR_MIC5"},
> + {"VA SMIC MUX2", "SWR_MIC6", "VA SWR_MIC6"},
> + {"VA SMIC MUX2", "SWR_MIC7", "VA SWR_MIC7"},
> +
> + {"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
> + {"VA SMIC MUX3", "ADC0", "VA SWR_ADC0"},
> + {"VA SMIC MUX3", "ADC1", "VA SWR_ADC1"},
> + {"VA SMIC MUX3", "ADC2", "VA SWR_ADC2"},
> + {"VA SMIC MUX3", "ADC3", "VA SWR_ADC3"},
> + {"VA SMIC MUX3", "SWR_MIC0", "VA SWR_MIC0"},
> + {"VA SMIC MUX3", "SWR_MIC1", "VA SWR_MIC1"},
> + {"VA SMIC MUX3", "SWR_MIC2", "VA SWR_MIC2"},
> + {"VA SMIC MUX3", "SWR_MIC3", "VA SWR_MIC3"},
> + {"VA SMIC MUX3", "SWR_MIC4", "VA SWR_MIC4"},
> + {"VA SMIC MUX3", "SWR_MIC5", "VA SWR_MIC5"},
> + {"VA SMIC MUX3", "SWR_MIC6", "VA SWR_MIC6"},
> + {"VA SMIC MUX3", "SWR_MIC7", "VA SWR_MIC7"},
> +
> { "VA DMIC0", NULL, "DMIC0 Pin" },
> { "VA DMIC1", NULL, "DMIC1 Pin" },
> { "VA DMIC2", NULL, "DMIC2 Pin" },
>
next prev parent reply other threads:[~2026-11-09 15:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 12:32 [PATCH v6 0/9] ASoC: qcom: Add shikra and Hawi LPASS macro support Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 1/9] ASoC: dt-bindings: qcom: Add Shikra RX and VA macro codecs Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 2/9] ASoC: qcom: lpass-macro-common: Add missing v2.9 version string Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 3/9] ASoC: qcom: lpass-rx-macro: Add shikra compatible Mohammad Rafi Shaik
2026-11-09 15:15 ` Srinivas Kandagatla
2026-11-06 12:33 ` [PATCH v6 v6 4/9] ASoC: qcom: lpass-va-macro: " Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 5/9] ASoC: qcom: lpass-va-macro: Add SoundWire microphone support Mohammad Rafi Shaik
2026-11-09 15:23 ` Srinivas Kandagatla [this message]
2026-11-06 12:33 ` [PATCH v6 v6 6/9] ASoC: dt-bindings: qcom: Add Hawi LPASS macro codecs Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 7/9] ASoC: dt-bindings: qcom: Add Maili " Mohammad Rafi Shaik
2026-11-09 11:40 ` Krzysztof Kozlowski
2026-11-06 12:33 ` [PATCH v6 v6 8/9] ASoC: qcom: lpass-tx-macro: Add support for Bolero v4.0 Mohammad Rafi Shaik
2026-11-06 12:33 ` [PATCH v6 v6 9/9] ASoC: qcom: lpass: Add support for LPASS codec v4.0 Mohammad Rafi Shaik
2026-11-09 15:02 ` Srinivas Kandagatla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f1fa6cd5-3e76-4033-80f3-0233975207ab@kernel.org \
--to=srini@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mohammad.rafi.shaik@oss.qualcomm.com \
--cc=perex@perex.cz \
--cc=robh@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®