diff mbox series

MLK-22197 sound: asoc: add micfil dc remover amixer control

Message ID 20190704125133.1463-1-ioana-irina.patru@nxp.com (mailing list archive)
State New, archived
Headers show
Series MLK-22197 sound: asoc: add micfil dc remover amixer control | expand

Commit Message

Irina Patru July 4, 2019, 12:52 p.m. UTC
Add control for DC Remover Control register:
11b - DC Remover is bypassed
00b - DC Remover is cut-off at 21Hz
01b - DC Remover is cut-off at 83Hz
10b - DC Remover is cut-off at 152Hz

This control modifies DC mode for all channels. For more
information see DC Remover Block Diagram in  micfil
reference manual.

Signed-off-by: Irina Patru <ioana-irina.patru@nxp.com>
---
 sound/soc/fsl/fsl_micfil.c | 59 ++++++++++++++++++++++++++++++++++++++
 sound/soc/fsl/fsl_micfil.h | 10 +++++++
 2 files changed, 69 insertions(+)

Comments

Viorel Suman July 4, 2019, 1:22 p.m. UTC | #1
Hi Irina,

Some nitpicks inline.

/Viorel

On Jo, 2019-07-04 at 12:52 +0000, Irina Patru wrote:


<snip>


+static int micfil_put_dc_remover_state(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       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 -1;


Maybe return -EINVAL here ?


+       micfil->dc_remover = val;
+
+       /* Calculate total value for all channels */
+       for (i = 0; i < 8; i++)
+               reg_val |= MICFIL_DC_MODE(val, i);
+
+       /* Update DC Remover mode for all channels */
+       ret = snd_soc_component_update_bits(comp,
+                                       REG_MICFIL_DC_CTRL,
+                                       MICFIL_DC_CTRL_MASK,
+                                       reg_val);


Please check the description of snd_soc_component_update_bits return value:
==========
 * Return: 1 if the operation was successful and the value of the register
 * changed, 0 if the operation was successful, but the value did not change.
 * Returns a negative error code otherwise.
==========

We may need to return a non-zero value in case of error only, ie:
=============
if (ret < 0)
return ret;

return 0;
=============


+       return ret;
+}
+
+static int micfil_get_dc_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_remover;
+
+       return 0;
+}
+
+
 static int hwvad_put_init_mode(struct snd_kcontrol *kcontrol,
                               struct snd_ctl_elem_value *ucontrol)
 {
@@ -676,6 +731,10 @@ static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
        SOC_ENUM_EXT("Clock Source",
                     fsl_micfil_clk_src_enum,
                     micfil_get_clk_src, micfil_put_clk_src),
+       SOC_ENUM_EXT("MICFIL DC Remover Control",
+                       fsl_micfil_dc_remover_enum,
+                       micfil_get_dc_remover_state,
+                       micfil_put_dc_remover_state),
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
                .name = "HWVAD Input Gain",
diff --git a/sound/soc/fsl/fsl_micfil.h b/sound/soc/fsl/fsl_micfil.h
index 792187b717f0..e47dba9b90b8 100644
--- a/sound/soc/fsl/fsl_micfil.h
+++ b/sound/soc/fsl/fsl_micfil.h
@@ -278,6 +278,16 @@
 #define MICFIL_HWVAD_HPF_102HZ         3
 #define MICFIL_HWVAD_FRAMET_DEFAULT    10

+/* MICFIL DC Remover Control Register -- REG_MICFIL_DC_CTRL */
+#define MICFIL_DC_CTRL_SHIFT           0
+#define MICFIL_DC_CTRL_MASK                    0xFFFF
+#define MICFIL_DC_CTRL_WIDTH           2
+#define MICFIL_DC_CHX_SHIFT(v)         (2 * (v))
+#define MICFIL_DC_CHX_MASK(v)          ((BIT(MICFIL_DC_CTRL_WIDTH) - 1) \
+                               << MICFIL_DC_CHX_SHIFT(v))
+#define MICFIL_DC_MODE(v1, v2)         (((v1) << MICFIL_DC_CHX_SHIFT(v2)) \
+                               & MICFIL_DC_CHX_MASK(v2))
+
 /* MICFIL Output Control Register */
 #define MICFIL_OUTGAIN_CHX_SHIFT(v)    (4 * (v))
jana.build@nxp.com July 4, 2019, 1:34 p.m. UTC | #2
Checkout project linux-imx      
Checkout branch imx_4.14.y      ok 
Checkpatch:                ok 
Apply patch(es):           ok 
Pushed to build server:            ok [https://jana.ea.freescale.net/jenkins//blue/organizations/jenkins/kernel-build-email/detail/kernel-build-email/2692/pipeline]
Build:                ok 
Tests:                FAILED [imx6dl-sabreauto imx6ulz-14x14-evk imx6dl-sabreauto imx6ulz-14x14-evk imx8mq imx8qm-mek imx8qm-val imx8mq imx8qm-mek imx8qm-val imx6sll-evk/bat-cpuidle-sleeptime imx6ull-14x14-evk/bat-cpuidle-sleeptime imx7ulp-evk/bat-audio-probe imx7ulp-evk/bat-cpufreq-freq-check imx7ulp-evk/bat-cpufreq imx7ulp-evk/bat-rtc imx7ulp-evk/bat-uart imx7ulp-evk/bat-suspend imx6ul-14x14-evk/jana_IMX6-debug_cmd-output-imx6ul-14x14-evk_log imx6ull-14x14-evk/jana_IMX6-debug_cmd-output-imx6ull-14x14-evk_log imx7ulp-evk/bat-audio-probe imx7ulp-evk/bat-bootcheck imx7ulp-evk/bat-cpufreq-freq-check imx7ulp-evk/bat-cpufreq imx7ulp-evk/bat-rtc imx7ulp-evk/bat-uart imx7ulp-evk/bat-suspend imx8mm-evk/bat-devicetree imx8qxp-mek/bat-devicetree imx8mm-evk/bat-devicetree imx8qxp-mek/bat-bootcheck imx8qxp-mek/bat-devicetree]
TODOs:
    * imx8qxp-mek: [bat-cpuidle]
    * imx8qxp-mek: [bat-cpuidle]






test errors:

imx6sll-evk/bat-cpuidle-sleeptime: not ok 27 bat-cpuidle-sleeptime.sh
run 27 bat-cpuidle-sleeptime.sh
reexec ./bat-cpuidle-sleeptime.sh inside ramroot...
cleaning up ramroot
not ok 27 bat-cpuidle-sleeptime.sh

imx6ull-14x14-evk/bat-cpuidle-sleeptime: not ok 27 bat-cpuidle-sleeptime.sh
run 27 bat-cpuidle-sleeptime.sh
reexec ./bat-cpuidle-sleeptime.sh inside ramroot...
cleaning up ramroot
not ok 27 bat-cpuidle-sleeptime.sh

imx7ulp-evk/bat-audio-probe: not ok 3 bat-audio-probe.sh
run 3 bat-audio-probe.sh
Available audio cards: 0 expected: 1
machine: NXP i.MX7ULP EVK
cards:

--- no soundcards ---
not ok 3 bat-audio-probe.sh

imx7ulp-evk/bat-cpufreq-freq-check: not ok 8 bat-cpufreq-freq-check.sh
run 8 bat-cpufreq-freq-check.sh
cat: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: No such file or directory
not ok 8 bat-cpufreq-freq-check.sh

imx7ulp-evk/bat-cpufreq: not ok 9 bat-cpufreq.sh
run 9 bat-cpufreq.sh
cat: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: No such file or directory
not ok 9 bat-cpufreq.sh

imx7ulp-evk/bat-rtc: not ok 19 bat-rtc.sh
run 19 bat-rtc.sh
./bat-rtc.sh: line 63: [: 0: unary operator expected
irq missmatch: got 0 , expected 
not ok 19 bat-rtc.sh

imx7ulp-evk/bat-uart: not ok 24 bat-uart.sh
run 24 bat-uart.sh
checking uart ttyLP2 driver fsl-lpuart
Test: loopback test for /dev/ttyLP2

---- Running < /unit_tests/BAT/../UART/mxc_uart_test.out > test ----

/dev/ttyLP2 opened
Attributes set
Test: IOCTL Set
Data Written= Test
Data Read back= 
Data read back  is different than data sent Test

----  Test < /dev/ttyLP2 > ended  ----

not ok 24 bat-uart.sh

imx7ulp-evk/bat-suspend: not ok 26 bat-suspend.sh
run 26 bat-suspend.sh
read rtc time: Invalid argument

---- Running < /unit_tests/BAT/../SRTC/rtcwakeup.out > test ----

not ok 26 bat-suspend.sh

imx6ul-14x14-evk/jana_IMX6-debug_cmd-output-imx6ul-14x14-evk_log: Looks like you planned 27 tests but ran 26.
Last running test was:
run 27 bat-cpuidle-sleeptime.sh

imx6ull-14x14-evk/jana_IMX6-debug_cmd-output-imx6ull-14x14-evk_log: Looks like you planned 27 tests but ran 26.
Last running test was:
run 27 bat-cpuidle-sleeptime.sh

imx7ulp-evk/bat-audio-probe: not ok 3 bat-audio-probe.sh
run 3 bat-audio-probe.sh
Available audio cards: 0 expected: 1
machine: NXP i.MX7ULP EVK
cards:

--- no soundcards ---
not ok 3 bat-audio-probe.sh

imx7ulp-evk/bat-bootcheck: not ok 6 bat-bootcheck.sh
run 6 bat-bootcheck.sh
[   11.789005] using random host ethernet address
[   11.818461] usb0: HOST MAC 66:3a:1f:52:7b:e3
[   11.823984] usb0: MAC 1a:4a:38:81:5b:51

[   11.834612] ================================
[   11.837580] WARNING: inconsistent lock state
[   11.840552] 4.14.98-debug-g9bad3a9 #1 Not tainted
[   11.843950] --------------------------------
[   11.846917] inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
[   11.851623] linuxrc/159 [HC1[1]:SC0[0]:HE0:SE1] takes:
[   11.855452]  (&(&ci->lock)->rlock){?.+.}, at: [<806b982c>] ci_irq+0x1c/0x180
[   11.861233] {HARDIRQ-ON-W} state was registered at:
[   11.864814]   _raw_spin_lock+0x38/0x48
[   11.867264]   ci_controller_resume+0x84/0x16c
[   11.870323]   __rpm_callback+0x144/0x220
[   11.872946]   rpm_callback+0x54/0x80
[   11.875225]   rpm_resume+0x4b0/0x648
[   11.877505]   __pm_runtime_resume+0x60/0x98
[   11.880392]   ci_hdrc_gadget_connect+0x24/0x17c
[   11.883623]   ci_udc_start+0x78/0x88
[   11.885904]   udc_bind_to_driver+0x7c/0xf0
[   11.888702]   usb_gadget_probe_driver+0xa4/0x168
[   11.892021]   gadget_dev_desc_UDC_store+0xa8/0xd0
[   11.895428]   configfs_write_file+0xe8/0x1a4
[   11.898403]   __vfs_write+0x1c/0x128
[   11.900680]   vfs_write+0xa4/0x168
Found WARN during boot
not ok 6 bat-bootcheck.sh

imx7ulp-evk/bat-cpufreq-freq-check: not ok 8 bat-cpufreq-freq-check.sh
run 8 bat-cpufreq-freq-check.sh
cat: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: No such file or directory
not ok 8 bat-cpufreq-freq-check.sh

imx7ulp-evk/bat-cpufreq: not ok 9 bat-cpufreq.sh
run 9 bat-cpufreq.sh
cat: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: No such file or directory
not ok 9 bat-cpufreq.sh

imx7ulp-evk/bat-rtc: not ok 19 bat-rtc.sh
run 19 bat-rtc.sh
./bat-rtc.sh: line 63: [: 0: unary operator expected
irq missmatch: got 0 , expected 
not ok 19 bat-rtc.sh

imx7ulp-evk/bat-uart: not ok 24 bat-uart.sh
run 24 bat-uart.sh
checking uart ttyLP2 driver fsl-lpuart
Test: loopback test for /dev/ttyLP2

---- Running < /unit_tests/BAT/../UART/mxc_uart_test.out > test ----

/dev/ttyLP2 opened
Attributes set
Test: IOCTL Set
Data Written= Test
Data Read back= 
Data read back  is different than data sent Test

----  Test < /dev/ttyLP2 > ended  ----

not ok 24 bat-uart.sh

imx7ulp-evk/bat-suspend: not ok 26 bat-suspend.sh
run 26 bat-suspend.sh
read rtc time: Invalid argument

---- Running < /unit_tests/BAT/../SRTC/rtcwakeup.out > test ----

not ok 26 bat-suspend.sh

imx8mm-evk/bat-devicetree: not ok 12 bat-devicetree.sh
run 12 bat-devicetree.sh
./bat-devicetree.sh: line 16: read: read error: 0: Is a directory
devicetree contains 141 devices, 20 disabled
accept unbound /sys/firmware/devicetree/base/clock-controller@30380000
accept unbound /sys/firmware/devicetree/base/clocks/clock@0
accept unbound /sys/firmware/devicetree/base/clocks/clock@1
accept unbound /sys/firmware/devicetree/base/clocks/clock@2
accept unbound /sys/firmware/devicetree/base/clocks/clock@3
accept unbound /sys/firmware/devicetree/base/clocks/clock@4
accept unbound /sys/firmware/devicetree/base/clocks/clock@5
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cluster-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cpu-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/l2-cache0
accept unbound /sys/firmware/devicetree/base/gpc@303a0000
accept unbound /sys/firmware/devicetree/base/interrupt-controller@38800000
unbound device node /sys/firmware/devicetree/base/lcdif-resets/lcdif-clk-enable compatible: lcdif,clk-enable
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-clk-enable compatible: dsi,clk-enable
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-mipi-reset compatible: dsi,mipi-reset
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-soft-resetn compatible: dsi,soft-resetn
accept unbound /sys/firmware/devicetree/base/reserved-memory/linux,cma
Found 4 unbound devices
not ok 12 bat-devicetree.sh

imx8qxp-mek/bat-devicetree: not ok 12 bat-devicetree.sh
run 12 bat-devicetree.sh
devicetree contains 214 devices, 37 disabled
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cluster-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cpu-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/l2-cache0
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/audio_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/caam_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/cm40_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/connectivity_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/dc0_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/dma_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/gpu-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/hsio-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/imaging_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/lsio_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/vpu-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/interrupt-controller@51a00000
accept unbound /sys/firmware/devicetree/base/reserved-memory/linux,cma
unbound device node /sys/firmware/devicetree/base/reserved-memory/rpmsg_dma@0x90400000 compatible: shared-dma-pool
unbound device node /sys/firmware/devicetree/base/vpu_encoder@2d000000/core0@1020000 compatible: fsl,imx8-mu1-vpu-m0
accept unbound /sys/firmware/devicetree/base/wu compat fsl,imx8-wu
Found 2 unbound devices
not ok 12 bat-devicetree.sh

imx8mm-evk/bat-devicetree: not ok 12 bat-devicetree.sh
run 12 bat-devicetree.sh
./bat-devicetree.sh: line 16: read: read error: 0: Is a directory
devicetree contains 141 devices, 20 disabled
accept unbound /sys/firmware/devicetree/base/clock-controller@30380000
accept unbound /sys/firmware/devicetree/base/clocks/clock@0
accept unbound /sys/firmware/devicetree/base/clocks/clock@1
accept unbound /sys/firmware/devicetree/base/clocks/clock@2
accept unbound /sys/firmware/devicetree/base/clocks/clock@3
accept unbound /sys/firmware/devicetree/base/clocks/clock@4
accept unbound /sys/firmware/devicetree/base/clocks/clock@5
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cluster-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cpu-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/l2-cache0
accept unbound /sys/firmware/devicetree/base/gpc@303a0000
accept unbound /sys/firmware/devicetree/base/interrupt-controller@38800000
unbound device node /sys/firmware/devicetree/base/lcdif-resets/lcdif-clk-enable compatible: lcdif,clk-enable
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-clk-enable compatible: dsi,clk-enable
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-mipi-reset compatible: dsi,mipi-reset
unbound device node /sys/firmware/devicetree/base/mipi-dsi-resets/dsi-soft-resetn compatible: dsi,soft-resetn
accept unbound /sys/firmware/devicetree/base/reserved-memory/linux,cma
Found 4 unbound devices
not ok 12 bat-devicetree.sh

imx8qxp-mek/bat-bootcheck: not ok 6 bat-bootcheck.sh
run 6 bat-bootcheck.sh
[    0.611812] libata version 3.00 loaded.
[    0.612612] usbcore: registered new interface driver usbfs
[    0.612795] usbcore: registered new interface driver hub
[    0.613070] usbcore: registered new device driver usb
[    0.614440] usb_phy_generic usbphynop1: usbphynop1 supply vcc not found, using dummy regulator
[    0.619581] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    0.619627] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[    0.619643] 3 locks held by swapper/0/1:
[    0.619657]  #0:  (&dev->mutex){....}, at: [<ffff00000871d9f8>] __driver_attach+0x50/0xc8
[    0.619711]  #1:  (&dev->mutex){....}, at: [<ffff00000871da08>] __driver_attach+0x60/0xc8
[    0.619747]  #2:  (enable_lock){....}, at: [<ffff0000085a2a0c>] clk_enable_lock+0x2c/0xf0
[    0.619793] irq event stamp: 149972
[    0.619814] hardirqs last  enabled at (149971): [<ffff000008e677d4>] _raw_spin_unlock_irqrestore+0x6c/0x78
[    0.619832] hardirqs last disabled at (149972): [<ffff0000085a2a00>] clk_enable_lock+0x20/0xf0
[    0.619850] softirqs last  enabled at (148118): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    0.619869] softirqs last disabled at (148111): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    0.619888] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.98-debug-g9bad3a9 #1
[    0.619902] Hardware name: Freescale i.MX8QXP MEK (DT)
[    0.619916] Call trace:
[    0.619935] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    0.619952] [<ffff00000808a87c>] show_stack+0x14/0x20
[    0.619974] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    0.619993] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    0.620008] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    0.620027] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[    0.620041] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
--
[    2.274572] io scheduler noop registered
[    2.274977] io scheduler cfq registered (default)
[    2.274994] io scheduler mq-deadline registered
[    2.275008] io scheduler kyber registered
[    2.330850] pwm-backlight lvds_backlight@0: lvds_backlight@0 supply power not found, using dummy regulator
[    2.331746] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    2.331799] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[    2.331815] 4 locks held by swapper/0/1:
[    2.331829]  #0:  (&dev->mutex){....}, at: [<ffff00000871d9f8>] __driver_attach+0x50/0xc8
[    2.331882]  #1:  (&dev->mutex){....}, at: [<ffff00000871da08>] __driver_attach+0x60/0xc8
[    2.331920]  #2:  (&new_bd->update_lock){+.+.}, at: [<ffff0000085431fc>] pwm_backlight_probe+0x3ec/0x4f8
[    2.331965]  #3:  (enable_lock){....}, at: [<ffff0000085a2a0c>] clk_enable_lock+0x2c/0xf0
[    2.332012] irq event stamp: 211452
[    2.332032] hardirqs last  enabled at (211451): [<ffff000008e6780c>] _raw_spin_unlock_irq+0x2c/0x60
[    2.332050] hardirqs last disabled at (211452): [<ffff0000085a2a00>] clk_enable_lock+0x20/0xf0
[    2.332070] softirqs last  enabled at (211436): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    2.332089] softirqs last disabled at (211429): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    2.332108] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    2.332122] Hardware name: Freescale i.MX8QXP MEK (DT)
[    2.332136] Call trace:
[    2.332155] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    2.332172] [<ffff00000808a87c>] show_stack+0x14/0x20
[    2.332192] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    2.332211] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    2.332226] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    2.332243] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
--
[    2.400646] msm_serial: driver initialized
[    2.403877] 5a060000.serial: ttyLP0 at MMIO 0x5a060010 (irq = 63, base_baud = 5000000) is a FSL_LPUART
[    4.159910] console [ttyLP0] enabled
[    4.164802] fsl-lpuart 5a060000.serial: NO DMA tx channel, run at cpu mode
[    4.171755] fsl-lpuart 5a060000.serial: NO DMA rx channel, run at cpu mode
[    4.180337] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    4.188814] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[    4.195614] 3 locks held by swapper/0/1:
[    4.199546]  #0:  (&dev->mutex){....}, at: [<ffff00000871d9f8>] __driver_attach+0x50/0xc8
[    4.207772]  #1:  (&dev->mutex){....}, at: [<ffff00000871da08>] __driver_attach+0x60/0xc8
[    4.215982]  #2:  (enable_lock){....}, at: [<ffff0000085a2a0c>] clk_enable_lock+0x2c/0xf0
[    4.224203] irq event stamp: 258948
[    4.227703] hardirqs last  enabled at (258947): [<ffff000008e677d4>] _raw_spin_unlock_irqrestore+0x6c/0x78
[    4.237367] hardirqs last disabled at (258948): [<ffff0000085a2a00>] clk_enable_lock+0x20/0xf0
[    4.245997] softirqs last  enabled at (258732): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    4.254537] softirqs last disabled at (258711): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    4.262642] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    4.271176] Hardware name: Freescale i.MX8QXP MEK (DT)
[    4.276320] Call trace:
[    4.278774] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    4.284185] [<ffff00000808a87c>] show_stack+0x14/0x20
[    4.289252] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    4.294317] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    4.299898] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    4.305215] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[    4.310531] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
--
[    5.371102] IR SANYO protocol handler initialized
[    5.375844] IR Sharp protocol handler initialized
[    5.380589] IR MCE Keyboard/mouse protocol handler initialized
[    5.386459] IR XMP protocol handler initialized
[    5.394962] mxc-isi 58100000.isi: can't find isi-gpr property
[    5.400880] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    5.409328] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[    5.416130] 3 locks held by swapper/0/1:
[    5.420054]  #0:  (&dev->mutex){....}, at: [<ffff00000871d9f8>] __driver_attach+0x50/0xc8
[    5.428279]  #1:  (&dev->mutex){....}, at: [<ffff00000871da08>] __driver_attach+0x60/0xc8
[    5.436488]  #2:  (enable_lock){....}, at: [<ffff0000085a2a0c>] clk_enable_lock+0x2c/0xf0
[    5.444710] irq event stamp: 366880
[    5.448210] hardirqs last  enabled at (366879): [<ffff000008e677d4>] _raw_spin_unlock_irqrestore+0x6c/0x78
[    5.457875] hardirqs last disabled at (366880): [<ffff0000085a2a00>] clk_enable_lock+0x20/0xf0
[    5.466504] softirqs last  enabled at (366864): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    5.475044] softirqs last disabled at (366843): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    5.483148] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    5.491683] Hardware name: Freescale i.MX8QXP MEK (DT)
[    5.496827] Call trace:
[    5.499281] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    5.504692] [<ffff00000808a87c>] show_stack+0x14/0x20
[    5.509759] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    5.514824] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    5.520405] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    5.525732] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[    5.531056] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
--
[    6.923500] usbhid: USB HID core driver
[    6.936254] tcpci 20-0050: Log buffer index 5 is NULL
[    6.979977] cs42xx8 17-0048: failed to get device ID, ret = -5
[    6.987670] cs42xx8: probe of 17-0048 failed with error -5
[    7.004908] ***** imx8qm_acm_init *****
[    7.012820] BUG: looking up invalid subclass: 8
[    7.017363] turning off the locking correctness validator.
[    7.022859] CPU: 3 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    7.031392] Hardware name: Freescale i.MX8QXP MEK (DT)
[    7.036536] Call trace:
[    7.038998] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    7.044402] [<ffff00000808a87c>] show_stack+0x14/0x20
[    7.049460] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    7.054514] [<ffff00000811ffc4>] register_lock_class+0x28c/0x528
[    7.060525] [<ffff000008122eb0>] __lock_acquire+0x78/0x1788
[    7.066099] [<ffff000008124c04>] lock_acquire+0x44/0x60
[    7.071334] [<ffff000008e63518>] __mutex_lock+0x78/0x868
[    7.076646] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
[    7.082315] [<ffff000008732378>] genpd_lock_nested_mtx+0x10/0x18
[    7.088326] [<ffff000008734b9c>] genpd_power_on.part.9+0x6c/0x1c8
[    7.094421] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
[    7.100520] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
[    7.106618] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
[    7.112719] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
[    7.118818] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
[    7.124914] [<ffff000008734bb0>] genpd_power_on.part.9+0x80/0x1c8
--
[    7.194714] [<ffff00000953fe40>] fsl_asrc_driver_init+0x18/0x20
[    7.200637] [<ffff000008083c08>] do_one_initcall+0x38/0x120
[    7.206215] [<ffff0000094e0d50>] kernel_init_freeable+0x1d0/0x264
[    7.212312] [<ffff000008e60254>] kernel_init+0x10/0xfc
[    7.217455] [<ffff000008085048>] ret_from_fork+0x10/0x18
[    7.255082] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    7.263533] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[    7.270325] INFO: lockdep is turned off.
[    7.274252] irq event stamp: 471395
[    7.277758] hardirqs last  enabled at (471395): [<ffff000008e6780c>] _raw_spin_unlock_irq+0x2c/0x60
[    7.286818] hardirqs last disabled at (471394): [<ffff000008e6760c>] _raw_spin_lock_irq+0x1c/0x60
[    7.295707] softirqs last  enabled at (470966): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    7.304246] softirqs last disabled at (470957): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    7.312343] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    7.320869] Hardware name: Freescale i.MX8QXP MEK (DT)
[    7.326013] Call trace:
[    7.328468] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    7.333878] [<ffff00000808a87c>] show_stack+0x14/0x20
[    7.338937] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    7.344001] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    7.349576] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    7.354892] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[    7.360209] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
[    7.365877] [<ffff0000087344a8>] genpd_get_from_provider.part.10+0x30/0xa0
[    7.372761] [<ffff000008734528>] genpd_get_from_provider+0x10/0x20
[    7.378950] [<ffff0000085ba264>] populate_gate_pd.isra.1+0x34/0x50
--
[    8.431494] imx-drm display-subsystem: bound ldb@562410e0 (ops imx_ldb_ops)
[    8.438639] nwl_dsi-imx mipi_dsi@56248000: No bridge found, skipping encoder creation
[    8.446509] imx-drm display-subsystem: bound mipi_dsi@56248000 (ops imx_nwl_dsi_component_ops)
[    8.455194] [drm] Cannot find any crtc or sizes
[    8.460525] [drm] Initialized imx-drm 1.0.0 20120507 for display-subsystem on minor 0
[    8.482138] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[    8.490592] in_atomic(): 1, irqs_disabled(): 128, pid: 3, name: kworker/0:0
[    8.497556] INFO: lockdep is turned off.
[    8.501483] irq event stamp: 7070
[    8.504816] hardirqs last  enabled at (7069): [<ffff000008e6780c>] _raw_spin_unlock_irq+0x2c/0x60
[    8.513702] hardirqs last disabled at (7070): [<ffff000008e61970>] __schedule+0xb8/0x750
[    8.521800] softirqs last  enabled at (3660): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[    8.530157] softirqs last disabled at (3635): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[    8.538089] CPU: 0 PID: 3 Comm: kworker/0:0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[    8.546788] Hardware name: Freescale i.MX8QXP MEK (DT)
[    8.551939] Workqueue: events deferred_probe_work_func
[    8.557083] Call trace:
[    8.559540] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[    8.564949] [<ffff00000808a87c>] show_stack+0x14/0x20
[    8.570007] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[    8.575072] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[    8.580644] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[    8.585961] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[    8.591278] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
[    8.596947] [<ffff0000087344a8>] genpd_get_from_provider.part.10+0x30/0xa0
[    8.603832] [<ffff000008734528>] genpd_get_from_provider+0x10/0x20
--
[   13.036504] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   13.051557] IP-Config: Complete:
[   13.054799]      device=eth0, hwaddr=00:04:9f:05:57:16, ipaddr=192.168.0.18, mask=255.255.255.0, gw=192.168.0.1
[   13.064923]      host=imx8qxp-mek-0, domain=, nis-domain=(none)
[   13.070870]      bootserver=255.255.255.255, rootserver=192.168.0.1, rootpath=
[   13.078416] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
[   13.086860] in_atomic(): 1, irqs_disabled(): 128, pid: 1, name: swapper/0
[   13.093652] INFO: lockdep is turned off.
[   13.097579] irq event stamp: 471395
[   13.101084] hardirqs last  enabled at (471395): [<ffff000008e6780c>] _raw_spin_unlock_irq+0x2c/0x60
[   13.110136] hardirqs last disabled at (471394): [<ffff000008e6760c>] _raw_spin_lock_irq+0x1c/0x60
[   13.119017] softirqs last  enabled at (470966): [<ffff000008081ccc>] __do_softirq+0x23c/0x288
[   13.127556] softirqs last disabled at (470957): [<ffff0000080d63ac>] irq_exit+0xdc/0x100
[   13.135661] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G        W       4.14.98-debug-g9bad3a9 #1
[   13.144187] Hardware name: Freescale i.MX8QXP MEK (DT)
[   13.149331] Call trace:
[   13.151786] [<ffff00000808a4b0>] dump_backtrace+0x0/0x3b8
[   13.157196] [<ffff00000808a87c>] show_stack+0x14/0x20
[   13.162255] [<ffff000008e4da48>] dump_stack+0xbc/0xf4
[   13.167319] [<ffff0000080fb924>] ___might_sleep+0x144/0x1d8
[   13.172900] [<ffff0000080fba08>] __might_sleep+0x50/0x88
[   13.178219] [<ffff000008e634e8>] __mutex_lock+0x48/0x868
[   13.183533] [<ffff000008e63d24>] mutex_lock_nested+0x1c/0x28
[   13.189204] [<ffff0000087344a8>] genpd_get_from_provider.part.10+0x30/0xa0
[   13.196087] [<ffff000008734528>] genpd_get_from_provider+0x10/0x20
[   13.202275] [<ffff0000085ba264>] populate_gate_pd.isra.1+0x34/0x50
Found BUG during boot
not ok 6 bat-bootcheck.sh

imx8qxp-mek/bat-devicetree: not ok 12 bat-devicetree.sh
run 12 bat-devicetree.sh
devicetree contains 214 devices, 37 disabled
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cluster-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/idle-states/cpu-sleep compat arm,idle-state
accept unbound /sys/firmware/devicetree/base/cpus/l2-cache0
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/audio_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/caam_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/cm40_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/connectivity_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/dc0_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/dma_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/gpu-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/hsio-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/imaging_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/lsio_power_domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/imx8qx-pm/vpu-power-domain compat nxp,imx8-pd
accept unbound /sys/firmware/devicetree/base/interrupt-controller@51a00000
accept unbound /sys/firmware/devicetree/base/reserved-memory/linux,cma
unbound device node /sys/firmware/devicetree/base/reserved-memory/rpmsg_dma@0x90400000 compatible: shared-dma-pool
unbound device node /sys/firmware/devicetree/base/vpu_encoder@2d000000/core0@1020000 compatible: fsl,imx8-mu1-vpu-m0
accept unbound /sys/firmware/devicetree/base/wu compat fsl,imx8-wu
Found 2 unbound devices
not ok 12 bat-devicetree.sh
Cosmin-Gabriel Samoila July 9, 2019, 5:11 p.m. UTC | #3
Hello Irina,

Please see my comments inline.

Best regards,
Cosmin

On Thu, 2019-07-04 at 13:22 +0000, Viorel Suman wrote:
> Hi Irina,
> 
> Some nitpicks inline.
> 
> /Viorel
> 
> On Jo, 2019-07-04 at 12:52 +0000, Irina Patru wrote:
> 
> 
> <snip>
> 
> 
> +static int micfil_put_dc_remover_state(struct snd_kcontrol
> *kcontrol,
> +                                       struct snd_ctl_elem_value
> *ucontrol)
> +{
> +       struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
> +       struct soc_enum *e = (struct soc_enum *)kcontrol-
> >private_value;
> +       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)

Use defines for constants instead of hardcoded values.

> +               return -1;
> 
> 
> Maybe return -EINVAL here ?
> 
> 
> +       micfil->dc_remover = val;
> +
> +       /* Calculate total value for all channels */
> +       for (i = 0; i < 8; i++)

Same as before. I think you already have MICFIL_NUM_CHANNELS in header.

> +               reg_val |= MICFIL_DC_MODE(val, i);
> +
> +       /* Update DC Remover mode for all channels */
> +       ret = snd_soc_component_update_bits(comp,
> +                                       REG_MICFIL_DC_CTRL,
> +                                       MICFIL_DC_CTRL_MASK,
> +                                       reg_val);

I don't know if there is an updated manual for MICFIL but it would be
nice to have a public link.
Please make sure that this change in the configuration can be done live
witout side-effects. Modifying some of the settings were affecting
performance or functionality and you must use other mechanism for
updating the DC_CTRL if it is the case.
> 
> 
> Please check the description of snd_soc_component_update_bits return
> value:
> ==========
>  * Return: 1 if the operation was successful and the value of the
> register
>  * changed, 0 if the operation was successful, but the value did not
> change.
>  * Returns a negative error code otherwise.
> ==========
> 
> We may need to return a non-zero value in case of error only, ie:
> =============
> if (ret < 0)
> return ret;
> 
> return 0;
> =============
> 
> 
> +       return ret;
> +}
> +
> +static int micfil_get_dc_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_remover;
> +
> +       return 0;
> +}
> +
> +
>  static int hwvad_put_init_mode(struct snd_kcontrol *kcontrol,
>                                struct snd_ctl_elem_value *ucontrol)
>  {
> @@ -676,6 +731,10 @@ static const struct snd_kcontrol_new
> fsl_micfil_snd_controls[] = {
>         SOC_ENUM_EXT("Clock Source",
>                      fsl_micfil_clk_src_enum,
>                      micfil_get_clk_src, micfil_put_clk_src),
> +       SOC_ENUM_EXT("MICFIL DC Remover Control",
> +                       fsl_micfil_dc_remover_enum,
> +                       micfil_get_dc_remover_state,
> +                       micfil_put_dc_remover_state),
>         {
>                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
>                 .name = "HWVAD Input Gain",
> diff --git a/sound/soc/fsl/fsl_micfil.h b/sound/soc/fsl/fsl_micfil.h
> index 792187b717f0..e47dba9b90b8 100644
> --- a/sound/soc/fsl/fsl_micfil.h
> +++ b/sound/soc/fsl/fsl_micfil.h
> @@ -278,6 +278,16 @@
>  #define MICFIL_HWVAD_HPF_102HZ         3
>  #define MICFIL_HWVAD_FRAMET_DEFAULT    10
> 
> +/* MICFIL DC Remover Control Register -- REG_MICFIL_DC_CTRL */
> +#define MICFIL_DC_CTRL_SHIFT           0
> +#define MICFIL_DC_CTRL_MASK                    0xFFFF
> +#define MICFIL_DC_CTRL_WIDTH           2
> +#define MICFIL_DC_CHX_SHIFT(v)         (2 * (v))
> +#define MICFIL_DC_CHX_MASK(v)          ((BIT(MICFIL_DC_CTRL_WIDTH) -
> 1) \
> +                               << MICFIL_DC_CHX_SHIFT(v))
> +#define MICFIL_DC_MODE(v1, v2)         (((v1) <<
> MICFIL_DC_CHX_SHIFT(v2)) \
> +                               & MICFIL_DC_CHX_MASK(v2))
> +
>  /* MICFIL Output Control Register */
>  #define MICFIL_OUTGAIN_CHX_SHIFT(v)    (4 * (v))
> 
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
diff mbox series

Patch

diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c
index 7bb8d4cb5f71..2eaf9fda4865 100644
--- a/sound/soc/fsl/fsl_micfil.c
+++ b/sound/soc/fsl/fsl_micfil.c
@@ -45,6 +45,7 @@  struct fsl_micfil {
 	bool slave_mode;
 	int channel_gain[8];
 	int clk_src_id;
+	int dc_remover;
 	int vad_sound_gain;
 	int vad_noise_gain;
 	int vad_input_gain;
@@ -140,6 +141,17 @@  static const char * const micfil_clk_src_texts[] = {
 	"Auto", "AudioPLL1", "AudioPLL2", "ExtClk3",
 };
 
+/* DC Remover Control
+ * Filter Bypassed	1 1
+ * Cut-off @21Hz	0 0
+ * Cut-off @83Hz	0 1
+ * Cut-off @152HZ	1 0
+ */
+static const char * const micfil_dc_remover_texts[] = {
+	"Cut-off @21Hz", "Cut-off @83Hz",
+	"Cut-off @152Hz", "Bypass",
+};
+
 static const struct soc_enum fsl_micfil_quality_enum =
 	SOC_ENUM_SINGLE(REG_MICFIL_CTRL2,
 			MICFIL_CTRL2_QSEL_SHIFT,
@@ -168,6 +180,10 @@  static const struct soc_enum fsl_micfil_hwvad_rate_enum =
 static const struct soc_enum fsl_micfil_clk_src_enum =
 	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(micfil_clk_src_texts),
 			    micfil_clk_src_texts);
+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 int micfil_put_clk_src(struct snd_kcontrol *kcontrol,
 			      struct snd_ctl_elem_value *ucontrol)
@@ -194,6 +210,45 @@  static int micfil_get_clk_src(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
+static int micfil_put_dc_remover_state(struct snd_kcontrol *kcontrol,
+					struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *comp = snd_kcontrol_chip(kcontrol);
+	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	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 -1;
+	micfil->dc_remover = val;
+
+	/* Calculate total value for all channels */
+	for (i = 0; i < 8; i++)
+		reg_val |= MICFIL_DC_MODE(val, i);
+
+	/* Update DC Remover mode for all channels */
+	ret = snd_soc_component_update_bits(comp,
+					REG_MICFIL_DC_CTRL,
+					MICFIL_DC_CTRL_MASK,
+					reg_val);
+	return ret;
+}
+
+static int micfil_get_dc_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_remover;
+
+	return 0;
+}
+
+
 static int hwvad_put_init_mode(struct snd_kcontrol *kcontrol,
 			       struct snd_ctl_elem_value *ucontrol)
 {
@@ -676,6 +731,10 @@  static const struct snd_kcontrol_new fsl_micfil_snd_controls[] = {
 	SOC_ENUM_EXT("Clock Source",
 		     fsl_micfil_clk_src_enum,
 		     micfil_get_clk_src, micfil_put_clk_src),
+	SOC_ENUM_EXT("MICFIL DC Remover Control",
+			fsl_micfil_dc_remover_enum,
+			micfil_get_dc_remover_state,
+			micfil_put_dc_remover_state),
 	{
 		.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 		.name = "HWVAD Input Gain",
diff --git a/sound/soc/fsl/fsl_micfil.h b/sound/soc/fsl/fsl_micfil.h
index 792187b717f0..e47dba9b90b8 100644
--- a/sound/soc/fsl/fsl_micfil.h
+++ b/sound/soc/fsl/fsl_micfil.h
@@ -278,6 +278,16 @@ 
 #define MICFIL_HWVAD_HPF_102HZ		3
 #define MICFIL_HWVAD_FRAMET_DEFAULT	10
 
+/* MICFIL DC Remover Control Register -- REG_MICFIL_DC_CTRL */
+#define MICFIL_DC_CTRL_SHIFT		0
+#define MICFIL_DC_CTRL_MASK			0xFFFF
+#define MICFIL_DC_CTRL_WIDTH		2
+#define MICFIL_DC_CHX_SHIFT(v)		(2 * (v))
+#define MICFIL_DC_CHX_MASK(v)		((BIT(MICFIL_DC_CTRL_WIDTH) - 1) \
+				<< MICFIL_DC_CHX_SHIFT(v))
+#define MICFIL_DC_MODE(v1, v2)		(((v1) << MICFIL_DC_CHX_SHIFT(v2)) \
+				& MICFIL_DC_CHX_MASK(v2))
+
 /* MICFIL Output Control Register */
 #define MICFIL_OUTGAIN_CHX_SHIFT(v)	(4 * (v))