diff mbox

[v3] ASoC: max98090: add shutdown callback for max98090

Message ID CABCoZhB-1nZA5-9YNfuxtNSJpa1bA-YcB4L5ZzEKBNzhZjdKfQ@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anish Kumar April 11, 2015, 12:50 a.m. UTC
On Fri, Apr 10, 2015 at 5:45 PM, anish singh
<anish198519851985@gmail.com> wrote:
>
> ---------- Forwarded message ----------
> From: Caesar Wang <wxt@rock-chips.com>
> Date: Wed, Apr 8, 2015 at 4:05 AM
> Subject: [PATCH v3] ASoC: max98090: add shutdown callback for max98090
> To: Sonny Rao <sonnyrao@chromium.org>, Cheng-Yi Chiang
> <cychiang@chromium.org>, Heiko Stuebner <heiko@sntech.de>, Mark Brown
> <broonie@kernel.org>, zhengxing <zhengxing@rock-chips.com>, "jay.xu"
> <xjq@rock-chips.com>
> Cc: devicetree@vger.kernel.org, dianders@chromium.org,
> dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
> linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org,
> Caesar Wang <wxt@rock-chips.com>, Jaroslav Kysela <perex@perex.cz>,
> alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>, Dylan Reid
> <dgreid@chromium.org>, Liam Girdwood <lgirdwood@gmail.com>, Lars-Peter
> Clausen <lars@metafoo.de>, Jarkko Nikula <jarkko.nikula@linux.intel.com>,
> Tushar Behera <tushar.b@samsung.com>
>
>
> To fix pop noise when shutdown,the pop noise during shutdown
> is the pmic cutoff power of codec without any notice.
>
> Signed-off-by: jay.xu <xjq@rock-chips.com>
> Signed-off-by: zhengxing <zhengxing@rock-chips.com>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
>
> ---
>
> Changes in v3:
> - modify the shutdown function before remove(..)
> - fix the `Serien-cc`
>
> Changes in v2:
> - remove the dev_info(..)
> - fix the comment style
> - add the max98090_i2c_shutdown() in remove() fuction
>
>  sound/soc/codecs/max98090.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
> index b112b1c..3e33ef2 100644
> --- a/sound/soc/codecs/max98090.c
> +++ b/sound/soc/codecs/max98090.c
> @@ -2605,8 +2605,24 @@ err_enable:
>         return ret;
>  }
>

Please check attached patch and see if it solves your problem.
We tested it here with zcd on.

+static void max98090_i2c_shutdown(struct i2c_client *i2c)
+{
+       struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev);
+
+       dev_info(&i2c->dev, "shut down device\n");
+
+       /* enable zero crossing */
+       regmap_write(max98090->regmap,
+               M98090_REG_LEVEL_CONTROL, M98090_ZDENN_MASK-1);
+
+       /* turn down volume levels for all the outputs */
+       regmap_write(max98090->regmap,
+               M98090_REG_RCV_LOUTL_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_LOUTR_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_LEFT_SPK_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_RIGHT_SPK_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_LEFT_HP_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_RIGHT_HP_VOLUME, 0x00);
+       regmap_write(max98090->regmap,
+               M98090_REG_DEVICE_SHUTDOWN, 0x00);
+       msleep(40);
+}
+

if it doesn't solve your problem then please dump
your registers and send it to us to look further. I assume
dapm is turning off the widgets before shutting down
the codec.

> +static void max98090_i2c_shutdown(struct i2c_client *i2c)
> +{
> +       struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev);
> +
> +       /*
> +        * Enable volume smoothing, disable zero cross.  This will cause
> +        * a quick 40ms ramp to mute on shutdown.
> +        */
> +       regmap_write(max98090->regmap,
> +               M98090_REG_LEVEL_CONTROL, M98090_VSENN_MASK);
> +       regmap_write(max98090->regmap,
> +               M98090_REG_DEVICE_SHUTDOWN, 0x00);
> +       msleep(40);
> +}
> +
>  static int max98090_i2c_remove(struct i2c_client *client)
>  {
> +       max98090_i2c_shutdown(client);
>         snd_soc_unregister_codec(&client->dev);
>         return 0;
>  }
> @@ -2696,6 +2712,7 @@ static struct i2c_driver max98090_i2c_driver = {
>                 .acpi_match_table = ACPI_PTR(max98090_acpi_match),
>         },
>         .probe  = max98090_i2c_probe,
> +       .shutdown = max98090_i2c_shutdown,
>         .remove = max98090_i2c_remove,
>         .id_table = max98090_i2c_id,
>  };
> --
> 1.9.1
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
diff mbox

Patch

From 3e57646691d4cb60e2b6295a9bda64ff8d0605c5 Mon Sep 17 00:00:00 2001
From: Anish Kumar <yesanishhere@gmail.com>
Date: Fri, 10 Apr 2015 17:41:36 -0700
Subject: [PATCH] To fix pop noise when shutdown,the pop noise during shutdown
 is the pmic cutoff power of codec without any notice.

Signed-off-by: Anish Kumar <anish.kumar@maximintegrated.com>
---
 sound/soc/codecs/max98090.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index fc17604..65e28f4 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -2349,6 +2349,34 @@  static int max98090_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
+static void max98090_i2c_shutdown(struct i2c_client *i2c)
+{
+	struct max98090_priv *max98090 = dev_get_drvdata(&i2c->dev);
+
+	dev_info(&i2c->dev, "shut down device\n");
+
+	/* enable zero crossing */
+	regmap_write(max98090->regmap,
+		M98090_REG_LEVEL_CONTROL, M98090_ZDENN_MASK-1);
+
+	/* turn down volume levels for all the outputs */
+	regmap_write(max98090->regmap,
+		M98090_REG_RCV_LOUTL_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_LOUTR_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_LEFT_SPK_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_RIGHT_SPK_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_LEFT_HP_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_RIGHT_HP_VOLUME, 0x00);
+	regmap_write(max98090->regmap,
+		M98090_REG_DEVICE_SHUTDOWN, 0x00);
+	msleep(40);
+}
+
 static int max98090_runtime_resume(struct device *dev)
 {
 	struct max98090_priv *max98090 = dev_get_drvdata(dev);
-- 
1.9.3