diff mbox

[1/5] ASoC: rt5645: Prevent the pop sound of the headphone while rebooting or shutdowning

Message ID 1440419579-9970-1-git-send-email-oder_chiou@realtek.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oder Chiou Aug. 24, 2015, 12:32 p.m. UTC
Add i2c shutdown function to prevent the pop sound of the headphone while
the system is rebooting or shutdowning

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 sound/soc/codecs/rt5645.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Mark Brown Aug. 25, 2015, 5:57 p.m. UTC | #1
On Mon, Aug 24, 2015 at 08:32:55PM +0800, Oder Chiou wrote:
> Add i2c shutdown function to prevent the pop sound of the headphone while
> the system is rebooting or shutdowning

> +	regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, 0x0020, 0x0020);
> +	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, 0x1000, 0x1000);
> +	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, 0x0004, 0x0000);

Yay, magic numbers!  What is the issue this is fixing?  The core is
supposed to power everything down to _BIAS_OFF before exiting, are we
missing something here?
Oder Chiou Aug. 26, 2015, 2:17 a.m. UTC | #2
> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Wednesday, August 26, 2015 1:57 AM
> To: Oder Chiou
> Cc: lgirdwood@gmail.com; alsa-devel@alsa-project.org; Flove; Bard Liao; John Lin;
> woojoo.lee@samsung.com
> Subject: Re: [PATCH 1/5] ASoC: rt5645: Prevent the pop sound of the headphone
> while rebooting or shutdowning
> 
> On Mon, Aug 24, 2015 at 08:32:55PM +0800, Oder Chiou wrote:
> > Add i2c shutdown function to prevent the pop sound of the headphone
> > while the system is rebooting or shutdowning
> 
> > +	regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, 0x0020, 0x0020);
> > +	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, 0x1000, 0x1000);
> > +	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, 0x0004,
> > +0x0000);
> 
> Yay, magic numbers!  What is the issue this is fixing?  The core is supposed to
> power everything down to _BIAS_OFF before exiting, are we missing something
> here?
> 
It de-initialed our jack detection function, and it cannot be turned off in
_BIAS_OFF. If we didn't de-initial it, we will hear the pop sound in the
situation of powering off, thanks.
Mark Brown Aug. 26, 2015, 10:51 a.m. UTC | #3
On Wed, Aug 26, 2015 at 02:17:40AM +0000, Oder Chiou wrote:

> It de-initialed our jack detection function, and it cannot be turned off in
> _BIAS_OFF. If we didn't de-initial it, we will hear the pop sound in the
> situation of powering off, thanks.

OK, can you add a comment explaining what the register writes do (or
ideally move to using #defines for the register values so it's obvious
just from looking at the writes)?
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index e5fef8f..4189d5a 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3490,13 +3490,23 @@  static int rt5645_i2c_remove(struct i2c_client *i2c)
 	return 0;
 }
 
+static void rt5645_i2c_shutdown(struct i2c_client *i2c)
+{
+	struct rt5645_priv *rt5645 = i2c_get_clientdata(i2c);
+
+	regmap_update_bits(rt5645->regmap, RT5645_GEN_CTRL3, 0x0020, 0x0020);
+	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL2, 0x1000, 0x1000);
+	regmap_update_bits(rt5645->regmap, RT5645_IN1_CTRL1, 0x0004, 0x0000);
+}
+
 static struct i2c_driver rt5645_i2c_driver = {
 	.driver = {
 		.name = "rt5645",
 		.acpi_match_table = ACPI_PTR(rt5645_acpi_match),
 	},
 	.probe = rt5645_i2c_probe,
-	.remove   = rt5645_i2c_remove,
+	.remove = rt5645_i2c_remove,
+	.shutdown = rt5645_i2c_shutdown,
 	.id_table = rt5645_i2c_id,
 };
 module_i2c_driver(rt5645_i2c_driver);