All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker
@ 2020-11-03  2:25 jack.yu
  2020-11-03 15:34 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 5+ messages in thread
From: jack.yu @ 2020-11-03  2:25 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: oder_chiou, Jack Yu, alsa-devel, lars, kent_chen, kenny_chen,
	tzungbi, derek.fang, shumingf, flove

From: Jack Yu <jack.yu@realtek.com>

Add delay to fix pop noise from speaker.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
 .../devicetree/bindings/sound/rt1015.txt      |  6 ++++++
 include/sound/rt1015.h                        | 15 ++++++++++++++
 sound/soc/codecs/rt1015.c                     | 20 +++++++++++++++++++
 sound/soc/codecs/rt1015.h                     |  2 ++
 4 files changed, 43 insertions(+)
 create mode 100644 include/sound/rt1015.h

diff --git a/Documentation/devicetree/bindings/sound/rt1015.txt b/Documentation/devicetree/bindings/sound/rt1015.txt
index fcfd02d8d32f..2c92c8cf3c7f 100644
--- a/Documentation/devicetree/bindings/sound/rt1015.txt
+++ b/Documentation/devicetree/bindings/sound/rt1015.txt
@@ -8,10 +8,16 @@ Required properties:
 
 - reg : The I2C address of the device.
 
+Optional properties:
+
+- realtek,realtek,power-up-delay-ms
+  Set a delay time for flush work to be completed,
+  this value is adjustable depending on platform.
 
 Example:
 
 rt1015: codec@28 {
 	compatible = "realtek,rt1015";
 	reg = <0x28>;
+	realtek,realtek,power-up-delay-ms = <50>;
 };
diff --git a/include/sound/rt1015.h b/include/sound/rt1015.h
new file mode 100644
index 000000000000..70a7538d4c89
--- /dev/null
+++ b/include/sound/rt1015.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/sound/rt1015.h -- Platform data for RT1015
+ *
+ * Copyright 2020 Realtek Microelectronics
+ */
+
+#ifndef __LINUX_SND_RT1015_H
+#define __LINUX_SND_RT1015_H
+
+struct rt1015_platform_data {
+	unsigned int power_up_delay_ms;
+};
+
+#endif
diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 25fe2ddedd54..967193518349 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -27,10 +27,15 @@
 #include <sound/soc-dapm.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
+#include <sound/rt1015.h>
 
 #include "rl6231.h"
 #include "rt1015.h"
 
+static const struct rt1015_platform_data i2s_default_platform_data = {
+	.power_up_delay_ms = 50,
+};
+
 static const struct reg_default rt1015_reg[] = {
 	{ 0x0000, 0x0000 },
 	{ 0x0004, 0xa000 },
@@ -650,6 +655,7 @@ static int rt1015_amp_drv_event(struct snd_soc_dapm_widget *w,
 	case SND_SOC_DAPM_POST_PMU:
 		if (rt1015->hw_config == RT1015_HW_28)
 			schedule_delayed_work(&rt1015->flush_work, msecs_to_jiffies(10));
+		msleep(rt1015->pdata.power_up_delay_ms);
 		break;
 	default:
 		break;
@@ -1067,9 +1073,16 @@ static struct acpi_device_id rt1015_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt1015_acpi_match);
 #endif
 
+static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
+{
+	device_property_read_u32(dev, "realtek,power-up-delay-ms",
+		&rt1015->pdata.power_up_delay_ms);
+}
+
 static int rt1015_i2c_probe(struct i2c_client *i2c,
 	const struct i2c_device_id *id)
 {
+	struct rt1015_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	struct rt1015_priv *rt1015;
 	int ret;
 	unsigned int val;
@@ -1081,6 +1094,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, rt1015);
 
+	rt1015->pdata = i2s_default_platform_data;
+
+	if (pdata)
+		rt1015->pdata = *pdata;
+	else
+		rt1015_parse_dt(rt1015, &i2c->dev);
+
 	rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap);
 	if (IS_ERR(rt1015->regmap)) {
 		ret = PTR_ERR(rt1015->regmap);
diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h
index d3fdd30aca6d..15cadb361ec3 100644
--- a/sound/soc/codecs/rt1015.h
+++ b/sound/soc/codecs/rt1015.h
@@ -12,6 +12,7 @@
 
 #ifndef __RT1015_H__
 #define __RT1015_H__
+#include <sound/rt1015.h>
 
 #define RT1015_DEVICE_ID_VAL			0x1011
 #define RT1015_DEVICE_ID_VAL2			0x1015
@@ -380,6 +381,7 @@ enum {
 
 struct rt1015_priv {
 	struct snd_soc_component *component;
+	struct rt1015_platform_data pdata;
 	struct regmap *regmap;
 	int sysclk;
 	int sysclk_src;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker
  2020-11-03  2:25 [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker jack.yu
@ 2020-11-03 15:34 ` Pierre-Louis Bossart
  0 siblings, 0 replies; 5+ messages in thread
From: Pierre-Louis Bossart @ 2020-11-03 15:34 UTC (permalink / raw)
  To: jack.yu, broonie, lgirdwood
  Cc: oder_chiou, alsa-devel, lars, kent_chen, kenny_chen, tzungbi,
	derek.fang, shumingf, flove

That should have been a [PATCH v2] ?

On 11/2/20 8:25 PM, jack.yu@realtek.com wrote:
> From: Jack Yu <jack.yu@realtek.com>
> 
> Add delay to fix pop noise from speaker.
> 
> Signed-off-by: Jack Yu <jack.yu@realtek.com>
> ---
>   .../devicetree/bindings/sound/rt1015.txt      |  6 ++++++
>   include/sound/rt1015.h                        | 15 ++++++++++++++
>   sound/soc/codecs/rt1015.c                     | 20 +++++++++++++++++++
>   sound/soc/codecs/rt1015.h                     |  2 ++
>   4 files changed, 43 insertions(+)
>   create mode 100644 include/sound/rt1015.h
> 
> diff --git a/Documentation/devicetree/bindings/sound/rt1015.txt b/Documentation/devicetree/bindings/sound/rt1015.txt
> index fcfd02d8d32f..2c92c8cf3c7f 100644
> --- a/Documentation/devicetree/bindings/sound/rt1015.txt
> +++ b/Documentation/devicetree/bindings/sound/rt1015.txt
> @@ -8,10 +8,16 @@ Required properties:
>   
>   - reg : The I2C address of the device.
>   
> +Optional properties:
> +
> +- realtek,realtek,power-up-delay-ms
> +  Set a delay time for flush work to be completed,
> +  this value is adjustable depending on platform.
>   
>   Example:
>   
>   rt1015: codec@28 {
>   	compatible = "realtek,rt1015";
>   	reg = <0x28>;
> +	realtek,realtek,power-up-delay-ms = <50>;

is the repetition of 'realtek' intended? looks like a typo or copy/paste 
to me?

>   };
> diff --git a/include/sound/rt1015.h b/include/sound/rt1015.h
> new file mode 100644
> index 000000000000..70a7538d4c89
> --- /dev/null
> +++ b/include/sound/rt1015.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * linux/sound/rt1015.h -- Platform data for RT1015
> + *
> + * Copyright 2020 Realtek Microelectronics
> + */
> +
> +#ifndef __LINUX_SND_RT1015_H
> +#define __LINUX_SND_RT1015_H
> +
> +struct rt1015_platform_data {
> +	unsigned int power_up_delay_ms;
> +};
> +
> +#endif
> diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
> index 25fe2ddedd54..967193518349 100644
> --- a/sound/soc/codecs/rt1015.c
> +++ b/sound/soc/codecs/rt1015.c
> @@ -27,10 +27,15 @@
>   #include <sound/soc-dapm.h>
>   #include <sound/soc.h>
>   #include <sound/tlv.h>
> +#include <sound/rt1015.h>
>   
>   #include "rl6231.h"
>   #include "rt1015.h"
>   
> +static const struct rt1015_platform_data i2s_default_platform_data = {
> +	.power_up_delay_ms = 50,
> +};
> +
>   static const struct reg_default rt1015_reg[] = {
>   	{ 0x0000, 0x0000 },
>   	{ 0x0004, 0xa000 },
> @@ -650,6 +655,7 @@ static int rt1015_amp_drv_event(struct snd_soc_dapm_widget *w,
>   	case SND_SOC_DAPM_POST_PMU:
>   		if (rt1015->hw_config == RT1015_HW_28)
>   			schedule_delayed_work(&rt1015->flush_work, msecs_to_jiffies(10));
> +		msleep(rt1015->pdata.power_up_delay_ms);
>   		break;
>   	default:
>   		break;
> @@ -1067,9 +1073,16 @@ static struct acpi_device_id rt1015_acpi_match[] = {
>   MODULE_DEVICE_TABLE(acpi, rt1015_acpi_match);
>   #endif
>   
> +static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
> +{
> +	device_property_read_u32(dev, "realtek,power-up-delay-ms",
> +		&rt1015->pdata.power_up_delay_ms);
> +}
> +
>   static int rt1015_i2c_probe(struct i2c_client *i2c,
>   	const struct i2c_device_id *id)
>   {
> +	struct rt1015_platform_data *pdata = dev_get_platdata(&i2c->dev);
>   	struct rt1015_priv *rt1015;
>   	int ret;
>   	unsigned int val;
> @@ -1081,6 +1094,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
>   
>   	i2c_set_clientdata(i2c, rt1015);
>   
> +	rt1015->pdata = i2s_default_platform_data;
> +
> +	if (pdata)
> +		rt1015->pdata = *pdata;
> +	else
> +		rt1015_parse_dt(rt1015, &i2c->dev);
> +
>   	rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap);
>   	if (IS_ERR(rt1015->regmap)) {
>   		ret = PTR_ERR(rt1015->regmap);
> diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h
> index d3fdd30aca6d..15cadb361ec3 100644
> --- a/sound/soc/codecs/rt1015.h
> +++ b/sound/soc/codecs/rt1015.h
> @@ -12,6 +12,7 @@
>   
>   #ifndef __RT1015_H__
>   #define __RT1015_H__
> +#include <sound/rt1015.h>
>   
>   #define RT1015_DEVICE_ID_VAL			0x1011
>   #define RT1015_DEVICE_ID_VAL2			0x1015
> @@ -380,6 +381,7 @@ enum {
>   
>   struct rt1015_priv {
>   	struct snd_soc_component *component;
> +	struct rt1015_platform_data pdata;
>   	struct regmap *regmap;
>   	int sysclk;
>   	int sysclk_src;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker
  2020-11-02 14:45 ` Pierre-Louis Bossart
@ 2020-11-02 15:41   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2020-11-02 15:41 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: oder_chiou, jack.yu, alsa-devel, lars, kent_chen, kenny_chen,
	lgirdwood, tzungbi, derek.fang, shumingf, flove

[-- Attachment #1: Type: text/plain, Size: 428 bytes --]

On Mon, Nov 02, 2020 at 08:45:33AM -0600, Pierre-Louis Bossart wrote:

> > +static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
> > +{
> > +	device_property_read_u32(dev, "realtek,power-up-delay",
> > +		&rt1015->pdata.power_up_delay);
> > +}

> Don't you need a DT binding description? And use delay-ms maybe?

Yes, any new bindings need to be documented and things should have their
units as a suffix.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker
  2020-11-02  5:28 jack.yu
@ 2020-11-02 14:45 ` Pierre-Louis Bossart
  2020-11-02 15:41   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Pierre-Louis Bossart @ 2020-11-02 14:45 UTC (permalink / raw)
  To: jack.yu, broonie, lgirdwood
  Cc: oder_chiou, alsa-devel, lars, kent_chen, kenny_chen, tzungbi,
	derek.fang, shumingf, flove



> +struct rt1015_platform_data {
> +	unsigned int power_up_delay;

power_up_delay_ms ?

[...]


> +static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
> +{
> +	device_property_read_u32(dev, "realtek,power-up-delay",
> +		&rt1015->pdata.power_up_delay);
> +}

Don't you need a DT binding description? And use delay-ms maybe?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker
@ 2020-11-02  5:28 jack.yu
  2020-11-02 14:45 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 5+ messages in thread
From: jack.yu @ 2020-11-02  5:28 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: oder_chiou, Jack Yu, alsa-devel, lars, kent_chen, kenny_chen,
	tzungbi, derek.fang, shumingf, flove

From: Jack Yu <jack.yu@realtek.com>

Add delay to fix pop noise from speaker.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
 include/sound/rt1015.h    | 15 +++++++++++++++
 sound/soc/codecs/rt1015.c | 20 ++++++++++++++++++++
 sound/soc/codecs/rt1015.h |  2 ++
 3 files changed, 37 insertions(+)
 create mode 100644 include/sound/rt1015.h

diff --git a/include/sound/rt1015.h b/include/sound/rt1015.h
new file mode 100644
index 000000000000..bc83ac22a6bf
--- /dev/null
+++ b/include/sound/rt1015.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * linux/sound/rt1015.h -- Platform data for RT1015
+ *
+ * Copyright 2020 Realtek Microelectronics
+ */
+
+#ifndef __LINUX_SND_RT1015_H
+#define __LINUX_SND_RT1015_H
+
+struct rt1015_platform_data {
+	unsigned int power_up_delay;
+};
+
+#endif
diff --git a/sound/soc/codecs/rt1015.c b/sound/soc/codecs/rt1015.c
index 25fe2ddedd54..4f9d453f1603 100644
--- a/sound/soc/codecs/rt1015.c
+++ b/sound/soc/codecs/rt1015.c
@@ -27,10 +27,15 @@
 #include <sound/soc-dapm.h>
 #include <sound/soc.h>
 #include <sound/tlv.h>
+#include <sound/rt1015.h>
 
 #include "rl6231.h"
 #include "rt1015.h"
 
+static const struct rt1015_platform_data i2s_default_platform_data = {
+	.power_up_delay = 50,
+};
+
 static const struct reg_default rt1015_reg[] = {
 	{ 0x0000, 0x0000 },
 	{ 0x0004, 0xa000 },
@@ -650,6 +655,7 @@ static int rt1015_amp_drv_event(struct snd_soc_dapm_widget *w,
 	case SND_SOC_DAPM_POST_PMU:
 		if (rt1015->hw_config == RT1015_HW_28)
 			schedule_delayed_work(&rt1015->flush_work, msecs_to_jiffies(10));
+		msleep(rt1015->pdata.power_up_delay);
 		break;
 	default:
 		break;
@@ -1067,9 +1073,16 @@ static struct acpi_device_id rt1015_acpi_match[] = {
 MODULE_DEVICE_TABLE(acpi, rt1015_acpi_match);
 #endif
 
+static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
+{
+	device_property_read_u32(dev, "realtek,power-up-delay",
+		&rt1015->pdata.power_up_delay);
+}
+
 static int rt1015_i2c_probe(struct i2c_client *i2c,
 	const struct i2c_device_id *id)
 {
+	struct rt1015_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	struct rt1015_priv *rt1015;
 	int ret;
 	unsigned int val;
@@ -1081,6 +1094,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
 
 	i2c_set_clientdata(i2c, rt1015);
 
+	rt1015->pdata = i2s_default_platform_data;
+
+	if (pdata)
+		rt1015->pdata = *pdata;
+	else
+		rt1015_parse_dt(rt1015, &i2c->dev);
+
 	rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap);
 	if (IS_ERR(rt1015->regmap)) {
 		ret = PTR_ERR(rt1015->regmap);
diff --git a/sound/soc/codecs/rt1015.h b/sound/soc/codecs/rt1015.h
index d3fdd30aca6d..15cadb361ec3 100644
--- a/sound/soc/codecs/rt1015.h
+++ b/sound/soc/codecs/rt1015.h
@@ -12,6 +12,7 @@
 
 #ifndef __RT1015_H__
 #define __RT1015_H__
+#include <sound/rt1015.h>
 
 #define RT1015_DEVICE_ID_VAL			0x1011
 #define RT1015_DEVICE_ID_VAL2			0x1015
@@ -380,6 +381,7 @@ enum {
 
 struct rt1015_priv {
 	struct snd_soc_component *component;
+	struct rt1015_platform_data pdata;
 	struct regmap *regmap;
 	int sysclk;
 	int sysclk_src;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-03 15:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  2:25 [PATCH] ASoC: rt1015: add delay to fix pop noise from speaker jack.yu
2020-11-03 15:34 ` Pierre-Louis Bossart
  -- strict thread matches above, loose matches on Subject: below --
2020-11-02  5:28 jack.yu
2020-11-02 14:45 ` Pierre-Louis Bossart
2020-11-02 15:41   ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.