Skip to contentSkip to conversation

ASoC: rt5670: check if asrc is useable

PATCH Applied Bard Liao 3 participants 6 messages Nov 17, 2014 – Nov 25, 2014

Subsystems (3)
lore
Share & tools
lore

Bard Liao

author
#0 lore raw

PATCH v2 1/3 ASoC: rt5670: check if asrc is useable

To use ASRC, the sysclk should be faster than 384 times sample rate of I2S1.

---
*Change source->codec to snd_soc_dapm_to_codec(source->dapm)

---
 sound/soc/codecs/rt5670.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5670.c +14 -2
index b842be0..fc26742 100644
@@ -576,6 +576,18 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source,
 
 }
 
+static int can_use_asrc(struct snd_soc_dapm_widget *source,
+			 struct snd_soc_dapm_widget *sink)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm);
+	struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
+
+	if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384)
+		return 1;
+
+	return 0;
+}
+
 /* Digital Mixer */
 static const struct snd_kcontrol_new rt5670_sto1_adc_l_mix[] = {
 	SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER,
@@ -1639,8 +1651,8 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
 	{ "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc },
 	{ "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc },
 
-	{ "I2S1", NULL, "I2S1 ASRC" },
-	{ "I2S2", NULL, "I2S2 ASRC" },
+	{ "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
+	{ "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
 
 	{ "DMIC1", NULL, "DMIC L1" },
 	{ "DMIC1", NULL, "DMIC R1" },
Signature · 1 line
1.8.1.1.439.g50a6b54
author
#1 lore raw

PATCH v2 2/3 ASoC: rt5670: add DMIC ASRC support

This patch will enable ASRC for DMIC if ASRC is useable.

---
 sound/soc/codecs/rt5670.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/rt5670.c +12 -0
index fc26742..8a0833d 100644
@@ -1294,6 +1294,14 @@ static const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = {
 			      9, 0, NULL, 0),
 	SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1,
 			      8, 0, NULL, 0),
+	SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5670_ASRC_1,
+			      7, 0, NULL, 0),
+	SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5670_ASRC_1,
+			      6, 0, NULL, 0),
+	SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5670_ASRC_1,
+			      5, 0, NULL, 0),
+	SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5670_ASRC_1,
+			      4, 0, NULL, 0),
 	SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5670_ASRC_1,
 			      3, 0, NULL, 0),
 	SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5670_ASRC_1,
@@ -1650,6 +1658,10 @@ static const struct snd_soc_dapm_route rt5670_dapm_routes[] = {
 	{ "DAC Mono Left Filter", NULL, "DAC MONO L ASRC", is_using_asrc },
 	{ "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc },
 	{ "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc },
+	{ "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
+	{ "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
+	{ "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
+	{ "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
 
 	{ "I2S1", NULL, "I2S1 ASRC", can_use_asrc},
 	{ "I2S2", NULL, "I2S2 ASRC", can_use_asrc},
Signature · 1 line
1.8.1.1.439.g50a6b54
maintainer Applied
#2 lore raw

Re: [PATCH v2 2/3] ASoC: rt5670: add DMIC ASRC support

Quoted 1 line · Bard Liao

This patch will enable ASRC for DMIC if ASRC is useable.

Applied, thanks.

author
#3 lore raw

PATCH v2 3/3 ASoC: rt5670: add codec irq support

In reply to Bard Liao

This patch provide the jack function of rt5670. We use a irq pin to notice the jack event. rt5670_irq_detection will determine which status should be reported. We can get gpio information from gpio number or gpiod_dev. That's why we define both on platform data.

---
 include/sound/rt5670.h    |   2 +
 sound/soc/codecs/rt5670.c | 176 +++++++++++++++++++++++++++++++++++++++++++++-
 sound/soc/codecs/rt5670.h |   2 +
 3 files changed, 178 insertions(+), 2 deletions(-)
include/sound/rt5670.h +2 -0
index bd31119..bb5cf6d 100644
@@ -14,6 +14,8 @@
 struct rt5670_platform_data {
 	int jd_mode;
 	bool in2_diff;
+	int codec_gpio;
+	bool dev_gpio;
 
 	bool dmic_en;
 	unsigned int dmic1_data_pin;
sound/soc/codecs/rt5670.c +174 -2

204 lines not on this page · raw message

sound/soc/codecs/rt5670.h +2 -0
index d11b9c2..54933f3 100644
@@ -1987,6 +1987,8 @@ struct rt5670_priv {
 	struct snd_soc_codec *codec;
 	struct rt5670_platform_data pdata;
 	struct regmap *regmap;
+	struct snd_soc_jack jack;
+	struct snd_soc_jack_gpio hp_gpio;
 
 	int sysclk;
 	int sysclk_src;
Signature · 1 line
1.8.1.1.439.g50a6b54
#4 lore raw

Re: [PATCH v2 3/3] ASoC: rt5670: add codec irq support

Quoted 2 lines · Bard Liao

This patch provide the jack function of rt5670. We use a irq pin to notice the jack event. rt5670_irq_detection will determine which status should be reported. We can get gpio information from gpio number or gpiod_dev. That's why we define both on platform data.

New code should only use the descriptor GPIO API. The old way of passing GPIO numbers as platform data is considered deprecated and will be removed once there are no drivers left using it.

- Lars

maintainer Applied
#5 lore raw
In reply to Bard Liao
Quoted 1 line · Bard Liao

To use ASRC, the sysclk should be faster than 384 times sample rate of I2S1.

Applied, thanks.