All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting
@ 2020-03-19  7:43 Oder Chiou
  2020-03-19  7:43 ` [v2 2/3] ASoC: rt5682: Add a property for DMIC delay Oder Chiou
  2020-03-19  7:43 ` [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings Oder Chiou
  0 siblings, 2 replies; 5+ messages in thread
From: Oder Chiou @ 2020-03-19  7:43 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, jack.yu, alsa-devel, cychiang, derek.fang, shumingf,
	flove

The patch adds a property for DMIC clock rate setting and changes the
default clock rate to the common optimize DMIC clock rate.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 include/sound/rt5682.h    | 1 +
 sound/soc/codecs/rt5682.c | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/sound/rt5682.h b/include/sound/rt5682.h
index 6bf0e3581056..96b268ac96bd 100644
--- a/include/sound/rt5682.h
+++ b/include/sound/rt5682.h
@@ -38,6 +38,7 @@ struct rt5682_platform_data {
 	enum rt5682_dmic1_clk_pin dmic1_clk_pin;
 	enum rt5682_jd_src jd_src;
 	unsigned int btndet_delay;
+	unsigned int dmic_clk_rate;
 
 	const char *dai_clk_names[RT5682_DAI_NUM_CLKS];
 };
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 2ee01e782fe0..c9e6f287424b 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1231,10 +1231,13 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
 	struct snd_soc_component *component =
 		snd_soc_dapm_to_component(w->dapm);
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
-	int idx = -EINVAL;
+	int idx = -EINVAL, dmic_clk_rate = 3072000;
 	static const int div[] = {2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128};
 
-	idx = rt5682_div_sel(rt5682, 1500000, div, ARRAY_SIZE(div));
+	if (rt5682->pdata.dmic_clk_rate)
+		dmic_clk_rate = rt5682->pdata.dmic_clk_rate;
+
+	idx = rt5682_div_sel(rt5682, dmic_clk_rate, div, ARRAY_SIZE(div));
 
 	snd_soc_component_update_bits(component, RT5682_DMIC_CTRL_1,
 		RT5682_DMIC_CLK_MASK, idx << RT5682_DMIC_CLK_SFT);
@@ -3231,6 +3234,8 @@ static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
 		&rt5682->pdata.jd_src);
 	device_property_read_u32(dev, "realtek,btndet-delay",
 		&rt5682->pdata.btndet_delay);
+	device_property_read_u32(dev, "realtek,dmic-clk-rate",
+		&rt5682->pdata.dmic_clk_rate);
 
 	rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
 		"realtek,ldo1-en-gpios", 0);
-- 
2.25.1


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

* [v2 2/3] ASoC: rt5682: Add a property for DMIC delay
  2020-03-19  7:43 [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting Oder Chiou
@ 2020-03-19  7:43 ` Oder Chiou
  2020-03-19  7:43 ` [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings Oder Chiou
  1 sibling, 0 replies; 5+ messages in thread
From: Oder Chiou @ 2020-03-19  7:43 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, jack.yu, alsa-devel, cychiang, derek.fang, shumingf,
	flove

The patch adds a property for DMIC delay (ms) to avoid pop noise and
changes the default delay setting.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 include/sound/rt5682.h    |  1 +
 sound/soc/codecs/rt5682.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/sound/rt5682.h b/include/sound/rt5682.h
index 96b268ac96bd..e1f790561ac1 100644
--- a/include/sound/rt5682.h
+++ b/include/sound/rt5682.h
@@ -39,6 +39,7 @@ struct rt5682_platform_data {
 	enum rt5682_jd_src jd_src;
 	unsigned int btndet_delay;
 	unsigned int dmic_clk_rate;
+	unsigned int dmic_delay;
 
 	const char *dai_clk_names[RT5682_DAI_NUM_CLKS];
 };
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index c9e6f287424b..8cabe8bf0979 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1544,10 +1544,18 @@ static int rt5682_hp_event(struct snd_soc_dapm_widget *w,
 static int set_dmic_power(struct snd_soc_dapm_widget *w,
 	struct snd_kcontrol *kcontrol, int event)
 {
+	struct snd_soc_component *component =
+		snd_soc_dapm_to_component(w->dapm);
+	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
+	unsigned int delay = 50;
+
+	if (rt5682->pdata.dmic_delay)
+		delay = rt5682->pdata.dmic_delay;
+
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
 		/*Add delay to avoid pop noise*/
-		msleep(150);
+		msleep(delay);
 		break;
 
 	default:
@@ -3236,6 +3244,8 @@ static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
 		&rt5682->pdata.btndet_delay);
 	device_property_read_u32(dev, "realtek,dmic-clk-rate",
 		&rt5682->pdata.dmic_clk_rate);
+	device_property_read_u32(dev, "realtek,dmic-delay-ms",
+		&rt5682->pdata.dmic_delay);
 
 	rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
 		"realtek,ldo1-en-gpios", 0);
-- 
2.25.1


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

* [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings
  2020-03-19  7:43 [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting Oder Chiou
  2020-03-19  7:43 ` [v2 2/3] ASoC: rt5682: Add a property for DMIC delay Oder Chiou
@ 2020-03-19  7:43 ` Oder Chiou
  2020-03-19 12:35   ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Oder Chiou @ 2020-03-19  7:43 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, jack.yu, alsa-devel, cychiang, derek.fang, shumingf,
	flove

The patch adds the descriptions for the DMIC clock rate and delay settings.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 Documentation/devicetree/bindings/sound/rt5682.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/rt5682.txt b/Documentation/devicetree/bindings/sound/rt5682.txt
index ac98151d29e4..f1d924179d67 100644
--- a/Documentation/devicetree/bindings/sound/rt5682.txt
+++ b/Documentation/devicetree/bindings/sound/rt5682.txt
@@ -38,6 +38,12 @@ Optional properties:
 - clocks : phandle and clock specifier for codec MCLK.
 - clock-names : Clock name string for 'clocks' attribute, should be "mclk".
 
+- realtek,dmic-clk-rate : Set the clock rate for the requirement of the
+  particular DMIC.
+
+- realtek,dmic-delay-ms : Set the delay time (ms) for the requirement of
+  the particular DMIC.
+
 Pins on the device (for linking into audio routes) for RT5682:
 
   * DMIC L1
-- 
2.25.1


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

* Re: [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings
  2020-03-19  7:43 ` [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings Oder Chiou
@ 2020-03-19 12:35   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2020-03-19 12:35 UTC (permalink / raw)
  To: Oder Chiou
  Cc: jack.yu, alsa-devel, cychiang, lgirdwood, derek.fang, shumingf,
	flove

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

On Thu, Mar 19, 2020 at 03:43:28PM +0800, Oder Chiou wrote:

> +- realtek,dmic-clk-rate : Set the clock rate for the requirement of the
> +  particular DMIC.

Lars mentioned on the previous version that this should have units on it
so -hz (I assume, perhaps the unit is different) here.  As he said it'd
also be a bit more idiomatic to say clock rather than clk.

> +- realtek,dmic-delay-ms : Set the delay time (ms) for the requirement of
> +  the particular DMIC.

This change is good though.

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

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

* [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting
@ 2020-03-23  8:21 Oder Chiou
  0 siblings, 0 replies; 5+ messages in thread
From: Oder Chiou @ 2020-03-23  8:21 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: Oder Chiou, jack.yu, alsa-devel, cychiang, derek.fang, shumingf,
	flove

The patch adds a property for DMIC clock rate setting and changes the
default clock rate to the common optimize DMIC clock rate.

Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
 include/sound/rt5682.h    | 1 +
 sound/soc/codecs/rt5682.c | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/sound/rt5682.h b/include/sound/rt5682.h
index 6bf0e3581056..96b268ac96bd 100644
--- a/include/sound/rt5682.h
+++ b/include/sound/rt5682.h
@@ -38,6 +38,7 @@ struct rt5682_platform_data {
 	enum rt5682_dmic1_clk_pin dmic1_clk_pin;
 	enum rt5682_jd_src jd_src;
 	unsigned int btndet_delay;
+	unsigned int dmic_clk_rate;
 
 	const char *dai_clk_names[RT5682_DAI_NUM_CLKS];
 };
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 2ee01e782fe0..c9e6f287424b 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1231,10 +1231,13 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
 	struct snd_soc_component *component =
 		snd_soc_dapm_to_component(w->dapm);
 	struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component);
-	int idx = -EINVAL;
+	int idx = -EINVAL, dmic_clk_rate = 3072000;
 	static const int div[] = {2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128};
 
-	idx = rt5682_div_sel(rt5682, 1500000, div, ARRAY_SIZE(div));
+	if (rt5682->pdata.dmic_clk_rate)
+		dmic_clk_rate = rt5682->pdata.dmic_clk_rate;
+
+	idx = rt5682_div_sel(rt5682, dmic_clk_rate, div, ARRAY_SIZE(div));
 
 	snd_soc_component_update_bits(component, RT5682_DMIC_CTRL_1,
 		RT5682_DMIC_CLK_MASK, idx << RT5682_DMIC_CLK_SFT);
@@ -3231,6 +3234,8 @@ static int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
 		&rt5682->pdata.jd_src);
 	device_property_read_u32(dev, "realtek,btndet-delay",
 		&rt5682->pdata.btndet_delay);
+	device_property_read_u32(dev, "realtek,dmic-clk-rate",
+		&rt5682->pdata.dmic_clk_rate);
 
 	rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
 		"realtek,ldo1-en-gpios", 0);
-- 
2.25.1


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

end of thread, other threads:[~2020-03-23  8:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-19  7:43 [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting Oder Chiou
2020-03-19  7:43 ` [v2 2/3] ASoC: rt5682: Add a property for DMIC delay Oder Chiou
2020-03-19  7:43 ` [v2 3/3] ASoC: rt5682: Add the descriptions for the DMIC clock rate and delay settings Oder Chiou
2020-03-19 12:35   ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2020-03-23  8:21 [v2 1/3] ASoC: rt5682: Add a property for DMIC clock rate setting Oder Chiou

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.