* [PATCH] ASoC: fsl_micfil: Add DC output remover control
@ 2026-04-20 8:53 Shengjiu Wang
2026-04-20 12:50 ` Mark Brown
2026-04-26 21:49 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Shengjiu Wang @ 2026-04-20 8:53 UTC (permalink / raw)
To: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
broonie, perex, tiwai, linux-sound, linuxppc-dev, linux-kernel
Add support for the DC output remover feature available on i.MX93 and
newer platforms. This allows users to configure the output DC removal
filter with cut-off frequencies of 20Hz, 13.3Hz, 40Hz, or bypass it
entirely.
The control is exposed as an ALSA mixer control and defaults to bypass
mode. It is only available on platforms with the use_verid flag set
(i.MX93+).
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
sound/soc/fsl/fsl_micfil.c | 79 ++++++++++++++++++++++++++++++++++++++
sound/soc/fsl/fsl_micfil.h | 1 +
2 files changed, 80 insertions(+)
diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index 2e887f1f1f36..60ac8eabab9d 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -74,6 +74,7 @@ struct fsl_micfil {
int irq[MICFIL_IRQ_LINES];
enum quality quality;
int dc_remover;
+ int dc_out_remover;
int vad_init_mode;
int vad_enabled;
int vad_detected;
@@ -347,6 +348,11 @@ static const char * const micfil_dc_remover_texts[] = {
"Cut-off @152Hz", "Bypass",
};
+static const char * const micfil_dc_out_remover_texts[] = {
+ "Cut-off @20Hz", "Cut-off @13.3Hz",
+ "Cut-off @40Hz", "Bypass",
+};
+
static const struct soc_enum hwvad_enable_enum =
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(micfil_hwvad_enable),
micfil_hwvad_enable);
@@ -360,6 +366,9 @@ static const struct soc_enum hwvad_hpf_enum =
static const struct soc_enum fsl_micfil_dc_remover_enum =
SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(micfil_dc_remover_texts),
micfil_dc_remover_texts);
+static const struct soc_enum fsl_micfil_dc_out_remover_enum =
+ SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(micfil_dc_out_remover_texts),
+ micfil_dc_out_remover_texts);
static int micfil_put_dc_remover_state(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
@@ -405,6 +414,50 @@ static int micfil_get_dc_remover_state(struct snd_kcontrol *kcontrol,
return 0;
}
+static int micfil_put_dc_out_remover_state(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+ struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
+ struct fsl_micfil *micfil = snd_soc_component_get_drvdata(comp);
+ unsigned int *item = ucontrol->value.enumerated.item;
+ int val = snd_soc_enum_item_to_val(e, item[0]);
+ int i = 0, ret = 0;
+ u32 reg_val = 0;
+
+ if (val < 0 || val > 3)
+ return -EINVAL;
+
+ ret = pm_runtime_resume_and_get(comp->dev);
+ if (ret)
+ return ret;
+
+ micfil->dc_out_remover = val;
+
+ /* Calculate total value for all channels */
+ for (i = 0; i < MICFIL_OUTPUT_CHANNELS; i++)
+ reg_val |= val << MICFIL_DC_CHX_SHIFT(i);
+
+ /* Update DC Remover mode for all channels */
+ ret = snd_soc_component_update_bits(comp, REG_MICFIL_DC_OUT_CTRL,
+ MICFIL_DC_CTRL_CONFIG, reg_val);
+
+ pm_runtime_put_autosuspend(comp->dev);
+
+ return ret;
+}
+
+static int micfil_get_dc_out_remover_state(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol)
+{
+ struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
+ struct fsl_micfil *micfil = snd_soc_component_get_drvdata(comp);
+
+ ucontrol->value.enumerated.item[0] = micfil->dc_out_remover;
+
+ return 0;
+}
+
static int hwvad_put_enable(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
@@ -525,6 +578,11 @@ static const struct snd_kcontrol_new fsl_micfil_volume_sx_controls[] = {
MICFIL_OUTGAIN_CHX_SHIFT(7), 0x8, 0xF, gain_tlv),
};
+static const struct snd_kcontrol_new fsl_micfil_dc_out_controls[] = {
+ SOC_ENUM_EXT("MICFIL DC Out Remover Control", fsl_micfil_dc_out_remover_enum,
+ micfil_get_dc_out_remover_state, micfil_put_dc_out_remover_state),
+};
+
static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
SOC_ENUM_EXT("MICFIL Quality Select",
fsl_micfil_quality_enum,
@@ -1047,6 +1105,19 @@ static int fsl_micfil_dai_probe(struct snd_soc_dai *cpu_dai)
}
micfil->dc_remover = MICFIL_DC_BYPASS;
+ if (micfil->soc->use_verid) {
+ val = 0;
+ for (i = 0; i < MICFIL_OUTPUT_CHANNELS; i++)
+ val |= MICFIL_DC_BYPASS << MICFIL_DC_CHX_SHIFT(i);
+ ret = regmap_update_bits(micfil->regmap, REG_MICFIL_DC_OUT_CTRL,
+ MICFIL_DC_CTRL_CONFIG, val);
+ if (ret) {
+ dev_err(dev, "failed to set DC OUT Remover mode bits\n");
+ return ret;
+ }
+ micfil->dc_out_remover = MICFIL_DC_BYPASS;
+ }
+
snd_soc_dai_init_dma_data(cpu_dai, NULL,
&micfil->dma_params_rx);
@@ -1071,6 +1142,10 @@ static int fsl_micfil_component_probe(struct snd_soc_component *component)
snd_soc_add_component_controls(component, fsl_micfil_range_controls,
ARRAY_SIZE(fsl_micfil_range_controls));
+ if (micfil->soc->use_verid)
+ snd_soc_add_component_controls(component, fsl_micfil_dc_out_controls,
+ ARRAY_SIZE(fsl_micfil_dc_out_controls));
+
return 0;
}
@@ -1117,6 +1192,7 @@ static const struct reg_default fsl_micfil_reg_defaults[] = {
{REG_MICFIL_DATACH6, 0x00000000},
{REG_MICFIL_DATACH7, 0x00000000},
{REG_MICFIL_DC_CTRL, 0x00000000},
+ {REG_MICFIL_DC_OUT_CTRL, 0x00000000},
{REG_MICFIL_OUT_CTRL, 0x00000000},
{REG_MICFIL_OUT_STAT, 0x00000000},
{REG_MICFIL_VAD0_CTRL1, 0x00000000},
@@ -1143,6 +1219,7 @@ static const struct reg_default fsl_micfil_reg_defaults_v2[] = {
{REG_MICFIL_DATACH6 - 0x4, 0x00000000},
{REG_MICFIL_DATACH7 - 0x4, 0x00000000},
{REG_MICFIL_DC_CTRL, 0x00000000},
+ {REG_MICFIL_DC_OUT_CTRL, 0x00000000},
{REG_MICFIL_OUT_CTRL, 0x00000000},
{REG_MICFIL_OUT_STAT, 0x00000000},
{REG_MICFIL_VAD0_CTRL1, 0x00000000},
@@ -1179,6 +1256,7 @@ static bool fsl_micfil_readable_reg(struct device *dev, unsigned int reg)
case REG_MICFIL_VAD0_NDATA:
case REG_MICFIL_VAD0_ZCD:
return true;
+ case REG_MICFIL_DC_OUT_CTRL:
case REG_MICFIL_FSYNC_CTRL:
case REG_MICFIL_VERID:
case REG_MICFIL_PARAM:
@@ -1210,6 +1288,7 @@ static bool fsl_micfil_writeable_reg(struct device *dev, unsigned int reg)
case REG_MICFIL_VAD0_NCONFIG:
case REG_MICFIL_VAD0_ZCD:
return true;
+ case REG_MICFIL_DC_OUT_CTRL:
case REG_MICFIL_FSYNC_CTRL:
if (micfil->soc->use_verid)
return true;
diff --git a/sound/soc/fsl/fsl_micfil.h b/sound/soc/fsl/fsl_micfil.h
index fdfe4e7125bc..e271c6073f42 100644
--- a/sound/soc/fsl/fsl_micfil.h
+++ b/sound/soc/fsl/fsl_micfil.h
@@ -22,6 +22,7 @@
#define REG_MICFIL_DATACH6 0x3C
#define REG_MICFIL_DATACH7 0x40
#define REG_MICFIL_DC_CTRL 0x64
+#define REG_MICFIL_DC_OUT_CTRL 0x68
#define REG_MICFIL_OUT_CTRL 0x74
#define REG_MICFIL_OUT_STAT 0x7C
#define REG_MICFIL_FSYNC_CTRL 0x80
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: fsl_micfil: Add DC output remover control
2026-04-20 8:53 [PATCH] ASoC: fsl_micfil: Add DC output remover control Shengjiu Wang
@ 2026-04-20 12:50 ` Mark Brown
2026-04-21 7:40 ` Shengjiu Wang
2026-04-26 21:49 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2026-04-20 12:50 UTC (permalink / raw)
To: Shengjiu Wang
Cc: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
perex, tiwai, linux-sound, linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 733 bytes --]
On Mon, Apr 20, 2026 at 04:53:44PM +0800, Shengjiu Wang wrote:
> +static int micfil_put_dc_out_remover_state(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + if (val < 0 || val > 3)
> + return -EINVAL;
> +
> + ret = pm_runtime_resume_and_get(comp->dev);
> + if (ret)
> + return ret;
> +
> + micfil->dc_out_remover = val;
...
> + /* Update DC Remover mode for all channels */
> + ret = snd_soc_component_update_bits(comp, REG_MICFIL_DC_OUT_CTRL,
> + MICFIL_DC_CTRL_CONFIG, reg_val);
> +
> + pm_runtime_put_autosuspend(comp->dev);
> +
> + return ret;
This will return 0 not 1 when the value changes, meaning event
generation is missed. The mixer-test selftest should report this.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: fsl_micfil: Add DC output remover control
2026-04-20 12:50 ` Mark Brown
@ 2026-04-21 7:40 ` Shengjiu Wang
2026-04-21 13:00 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Shengjiu Wang @ 2026-04-21 7:40 UTC (permalink / raw)
To: Mark Brown
Cc: Shengjiu Wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
perex, tiwai, linux-sound, linuxppc-dev, linux-kernel
On Mon, Apr 20, 2026 at 8:50 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Mon, Apr 20, 2026 at 04:53:44PM +0800, Shengjiu Wang wrote:
>
> > +static int micfil_put_dc_out_remover_state(struct snd_kcontrol *kcontrol,
> > + struct snd_ctl_elem_value *ucontrol)
> > +{
>
> > + if (val < 0 || val > 3)
> > + return -EINVAL;
> > +
> > + ret = pm_runtime_resume_and_get(comp->dev);
> > + if (ret)
> > + return ret;
> > +
> > + micfil->dc_out_remover = val;
>
> ...
>
> > + /* Update DC Remover mode for all channels */
> > + ret = snd_soc_component_update_bits(comp, REG_MICFIL_DC_OUT_CTRL,
> > + MICFIL_DC_CTRL_CONFIG, reg_val);
> > +
> > + pm_runtime_put_autosuspend(comp->dev);
> > +
> > + return ret;
>
> This will return 0 not 1 when the value changes, meaning event
> generation is missed. The mixer-test selftest should report this.
snd_soc_component_update_bits() will return 1 if the value is changed.
and the mixer-test pass
ok 120 get_value.micfilaudio.8
# micfilaudio.8 MICFIL DC Out Remover Control
ok 121 name.micfilaudio.8
ok 122 write_default.micfilaudio.8
ok 123 write_valid.micfilaudio.8
ok 124 write_invalid.micfilaudio.8
ok 125 event_missing.micfilaudio.8
ok 126 event_spurious.micfilaudio.8
Is there something I missed here?
Best regards
Shengjiu Wang
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] ASoC: fsl_micfil: Add DC output remover control
2026-04-21 7:40 ` Shengjiu Wang
@ 2026-04-21 13:00 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-04-21 13:00 UTC (permalink / raw)
To: Shengjiu Wang
Cc: Shengjiu Wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
perex, tiwai, linux-sound, linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 764 bytes --]
On Tue, Apr 21, 2026 at 03:40:12PM +0800, Shengjiu Wang wrote:
> On Mon, Apr 20, 2026 at 8:50 PM Mark Brown <broonie@kernel.org> wrote:
> > > + /* Update DC Remover mode for all channels */
> > > + ret = snd_soc_component_update_bits(comp, REG_MICFIL_DC_OUT_CTRL,
> > > + MICFIL_DC_CTRL_CONFIG, reg_val);
> > This will return 0 not 1 when the value changes, meaning event
> > generation is missed. The mixer-test selftest should report this.
> snd_soc_component_update_bits() will return 1 if the value is changed.
> and the mixer-test pass
Ah, so it will - I'm used to the regmap one which doesn't do that and
instead has a separate function to get a bool back for changes. The
code is fine
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: fsl_micfil: Add DC output remover control
2026-04-20 8:53 [PATCH] ASoC: fsl_micfil: Add DC output remover control Shengjiu Wang
2026-04-20 12:50 ` Mark Brown
@ 2026-04-26 21:49 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-04-26 21:49 UTC (permalink / raw)
To: shengjiu.wang, Xiubo.Lee, festevam, nicoleotsuka, lgirdwood,
perex, tiwai, linux-sound, linuxppc-dev, linux-kernel,
Shengjiu Wang
On Mon, 20 Apr 2026 16:53:44 +0800, Shengjiu Wang wrote:
> ASoC: fsl_micfil: Add DC output remover control
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: fsl_micfil: Add DC output remover control
https://git.kernel.org/broonie/sound/c/e9a6f077e415
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-26 23:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 8:53 [PATCH] ASoC: fsl_micfil: Add DC output remover control Shengjiu Wang
2026-04-20 12:50 ` Mark Brown
2026-04-21 7:40 ` Shengjiu Wang
2026-04-21 13:00 ` Mark Brown
2026-04-26 21:49 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox