ASoC: rt5670: make bias level more reasonable
Subsystems (3)
PATCH 1/4 ASoC: rt5670: make bias level more reasonable
From: Bard Liao <[email protected]>
This patah separate bias level off to standby and off. The standby level will provide the necessary power for JD and push button functions.
--- sound/soc/codecs/rt5670.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
sound/soc/codecs/rt5670.c +20 -7
@@ -2309,6 +2309,8 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,static int rt5670_set_bias_level (struct snd_soc_codec *codec,enum snd_soc_bias_level level) { +struct rt5670_priv *rt5670 =snd_soc_codec_get_drvdata (codec); +switch (level) {case SND_SOC_BIAS_PREPARE :if (SND_SOC_BIAS_STANDBY == codec->dapm.bias_level) {
@@ -2330,16 +2332,27 @@ static int rt5670_set_bias_level(struct snd_soc_codec *codec, }break ;case SND_SOC_BIAS_STANDBY : -snd_soc_write (codec,RT5670_PWR_DIG1 ,0x0000 ); -snd_soc_write (codec,RT5670_PWR_DIG2 ,0x0001 ); -snd_soc_write (codec,RT5670_PWR_VOL ,0x0000 ); -snd_soc_write (codec,RT5670_PWR_MIXER ,0x0001 ); -snd_soc_write (codec,RT5670_PWR_ANLG1 ,0x2800 ); -snd_soc_write (codec,RT5670_PWR_ANLG2 ,0x0004 ); -snd_soc_update_bits (codec,RT5670_DIG_MISC ,0x1 ,0x0 ); +snd_soc_update_bits (codec,RT5670_PWR_ANLG1 , +RT5670_PWR_VREF1 |RT5670_PWR_VREF2 | +RT5670_PWR_FV1 |RT5670_PWR_FV2 ,0 );snd_soc_update_bits (codec,RT5670_PWR_ANLG1 ,RT5670_LDO_SEL_MASK ,0x1 );break ; +case SND_SOC_BIAS_OFF : +if (rt5670->pdata.jd_mode) +snd_soc_update_bits (codec,RT5670_PWR_ANLG1 , +RT5670_PWR_VREF1 |RT5670_PWR_MB | +RT5670_PWR_BG |RT5670_PWR_VREF2 | +RT5670_PWR_FV1 |RT5670_PWR_FV2 , +RT5670_PWR_MB |RT5670_PWR_BG ); +else +snd_soc_update_bits (codec,RT5670_PWR_ANLG1 , +RT5670_PWR_VREF1 |RT5670_PWR_MB | +RT5670_PWR_BG |RT5670_PWR_VREF2 | +RT5670_PWR_FV1 |RT5670_PWR_FV2 ,0 ); + +snd_soc_update_bits (codec,RT5670_DIG_MISC ,0x1 ,0x0 ); +break ;default :break ;
Signature · 1 line
1.8.1.1.439.g50a6b54
PATCH 2/4 ASoC: rt5670: check if asrc is useable
From: Bard Liao <[email protected]>
To use ASRC, the sysclk should be faster than 384 times sample rate of I2S1.
--- sound/soc/codecs/rt5670.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
sound/soc/codecs/rt5670.c +13 -2
@@ -575,6 +575,17 @@ 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 rt5670_priv *rt5670 =snd_soc_codec_get_drvdata (source->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,
@@ -1638,8 +1649,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
Re: [PATCH 2/4] ASoC: rt5670: check if asrc is useable
Quoted 15 lines · On 11/12/2014 12:54 PM, [email protected] wrote:
From: Bard Liao <[email protected]>
To use ASRC, the sysclk should be faster than 384 times sample rate of I2S1.
Signed-off-by Bard Liao <[email protected]>--- sound/soc/codecs/rt5670.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)sound/soc/codecs/rt5670.c +0
-0
sound/soc/codecs/rt5670.c static int is_using_asrc(struct snd_soc_dapm_widget *source, · line 581
Quoted 7 lines
sound/soc/codecs/rt5670.c +4
-0@@ -575,6 +575,17 @@ 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 rt5670_priv *rt5670 =snd_soc_codec_get_drvdata (source->codec);
Can you start using snd_soc_dapm_to_codec(source->dapm) instead of source->codec? The codec field will eventually be removed.
Bonus points for fixing up the existing w->codec users in rt drivers.
Thanks,
- Lars
Re: [PATCH 2/4] ASoC: rt5670: check if asrc is useable
Quoted 37 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Thursday, November 13, 2014 3:43 AM
To: Bard Liao
Cc: [email protected]; [email protected]; [email protected]; Flove; Oder Chiou; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] ASoC: rt5670: check if asrc is useableQuoted 15 lines · On 11/12/2014 12:54 PM, [email protected] wrote:
From: Bard Liao <[email protected]>
To use ASRC, the sysclk should be faster than 384 times sample rate of I2S1.
Signed-off-by Bard Liao <[email protected]>--- sound/soc/codecs/rt5670.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)sound/soc/codecs/rt5670.c +0
-0sound/soc/codecs/rt5670.c static int is_using_asrc(struct · line 582
Quoted 8 lines
sound/soc/codecs/rt5670.c +4
-0@@ -575,6 +575,17 @@ 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 rt5670_priv *rt5670 = +snd_soc_codec_get_drvdata (source->codec);Can you start using
snd_soc_dapm_to_codec(source->dapm)instead ofsource->codec? The codec field will eventually be removed.
Quoted 1 line
Bonus points for fixing up the existing
w->codecusers in rt drivers.
Sure, I will resend the patch. Another question is that the patch is one of 4 patches series. Should I resend all of them?
Thanks.
Quoted 6 lines
Thanks,
- Lars------Please consider the environment before printing this e-mail.
Mark Brown
maintainerRe: [PATCH 2/4] ASoC: rt5670: check if asrc is useable
Quoted 2 lines · Bard Liao
Sure, I will resend the patch. Another question is that the patch is one of 4 patches series. Should I resend all of them?
No need to send patch 1 since I applied it but please resend the rest - I assumed that patches 3 and 4 depended on patch 2. In general resend anything that hasn't been applied.
PATCH 3/4 ASoC: rt5670: add DMIC ASRC support
In reply to [email protected]From: Bard Liao <[email protected]>
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
@@ -1292,6 +1292,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,
@@ -1648,6 +1656,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
PATCH 4/4 ASoC: rt5670: add codec irq support
In reply to [email protected]From: Bard Liao <[email protected]>
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
@@ -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
@@ -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
Quoted 5 lines · On Wed, Nov 12, 2014 at 07:54:30PM +0800, [email protected] wrote:
From: Bard Liao <[email protected]>
This patah separate bias level off to standby and off. The standby level will provide the necessary power for JD and push button functions.
Applied, thanks.