From: Shengjiu Wang <shengjiu.wang@nxp.com>
To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com,
nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org,
perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: fsl_micfil: Add DC output remover control
Date: Mon, 20 Apr 2026 16:53:44 +0800 [thread overview]
Message-ID: <20260420085344.2081805-1-shengjiu.wang@nxp.com> (raw)
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
next reply other threads:[~2026-04-20 8:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 8:53 Shengjiu Wang [this message]
2026-04-20 12:50 ` [PATCH] ASoC: fsl_micfil: Add DC output remover control Mark Brown
2026-04-21 7:40 ` Shengjiu Wang
2026-04-21 13:00 ` Mark Brown
2026-04-26 21:49 ` Mark Brown
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=20260420085344.2081805-1-shengjiu.wang@nxp.com \
--to=shengjiu.wang@nxp.com \
--cc=Xiubo.Lee@gmail.com \
--cc=broonie@kernel.org \
--cc=festevam@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nicoleotsuka@gmail.com \
--cc=perex@perex.cz \
--cc=shengjiu.wang@gmail.com \
--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