ASoC: rt5645: Add ASRC support
Subsystems (3)
PATCH 1/2 ASoC: rt5645: Add ASRC support
From: Bard Liao <[email protected]>
This patch add ASRC support for rt5645 codec.
--- sound/soc/codecs/rt5645.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+)
sound/soc/codecs/rt5645.c +144 -0
@@ -443,6 +443,65 @@ static SOC_ENUM_SINGLE_DECL(rt5645_tdm_adc_sel_enum, RT5645_TDM_CTRL_1, 8, rt5645_tdm_adc_data_select); +static int rt5645_clk_sel_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_soc_kcontrol_codec (kcontrol); +unsigned int u_bit =0 , p_bit =0 ; +struct soc_enum *em = + (struct soc_enum *)kcontrol->private_value; + +switch (em->reg) { +case RT5645_ASRC_2 : +switch (em->shift_l) { +case 0 : + u_bit =0x8 ; + p_bit =RT5645_PWR_ADC_S1F ; +break ; +case 4 : + u_bit =0x100 ; + p_bit =RT5645_PWR_DAC_MF_R ; +break ; +case 8 : + u_bit =0x200 ; + p_bit =RT5645_PWR_DAC_MF_L ; +break ; +case 12 : + u_bit =0x400 ; + p_bit =RT5645_PWR_DAC_S1F ; +break ; + } +break ; +case RT5645_ASRC_3 : +switch (em->shift_l) { +case 0 : + u_bit =0x1 ; + p_bit =RT5645_PWR_ADC_MF_R ; +break ; +case 4 : + u_bit =0x2 ; + p_bit =RT5645_PWR_ADC_MF_L ; +break ; + } +break ; + } + +if (u_bit || p_bit) { +switch (ucontrol->value.integer.value[0 ]) { + case 1 ... 4: /*enable*/ +if (snd_soc_read (codec,RT5645_PWR_DIG2 ) & p_bit) +snd_soc_update_bits (codec, +RT5645_ASRC_1 , u_bit, u_bit); +break ; +default :/*disable*/ +snd_soc_update_bits (codec,RT5645_ASRC_1 , u_bit,0 ); +break ; + } + } + +return snd_soc_put_enum_double (kcontrol, ucontrol); +} +static const struct snd_kcontrol_new rt5645_snd_controls[] = {/* Speaker Output Volume */ SOC_DOUBLE("Speaker Channel Switch", RT5645_SPK_VOL,
@@ -554,6 +613,53 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,return 0 ; } +static int is_using_asrc (struct snd_soc_dapm_widget *source, +struct snd_soc_dapm_widget *sink) +{ +unsigned int reg, shift, val; + +switch (source->shift) { +case 0 : + reg =RT5645_ASRC_3 ; + shift =0 ; +break ; +case 1 : + reg =RT5645_ASRC_3 ; + shift =4 ; +break ; +case 3 : + reg =RT5645_ASRC_2 ; + shift =0 ; +break ; +case 8 : + reg =RT5645_ASRC_2 ; + shift =4 ; +break ; +case 9 : + reg =RT5645_ASRC_2 ; + shift =8 ; +break ; +case 10 : + reg =RT5645_ASRC_2 ; + shift =12 ; +break ; +default : +return 0 ; + } + + val = (snd_soc_read (source->codec, reg) >> shift) &0xf ; +switch (val) { +case 1 : +case 2 : +case 3 : +case 4 : +return 1 ; +default : +return 0 ; + } + +} +/* Digital Mixer */ static const struct snd_kcontrol_new rt5645_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5645_STO1_ADC_MIXER,
@@ -1246,6 +1352,30 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("Mic Det Power" ,RT5645_PWR_VOL ,RT5645_PWR_MIC_DET_BIT ,0 ,NULL ,0 ), +/* ASRC */ +SND_SOC_DAPM_SUPPLY_S ("I2S1 ASRC" ,1 ,RT5645_ASRC_1 , +11 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("I2S2 ASRC" ,1 ,RT5645_ASRC_1 , +12 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DAC STO ASRC" ,1 ,RT5645_ASRC_1 , +10 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DAC MONO L ASRC" ,1 ,RT5645_ASRC_1 , +9 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DAC MONO R ASRC" ,1 ,RT5645_ASRC_1 , +8 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DMIC STO1 ASRC" ,1 ,RT5645_ASRC_1 , +7 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DMIC MONO L ASRC" ,1 ,RT5645_ASRC_1 , +5 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("DMIC MONO R ASRC" ,1 ,RT5645_ASRC_1 , +4 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("ADC STO1 ASRC" ,1 ,RT5645_ASRC_1 , +3 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("ADC MONO L ASRC" ,1 ,RT5645_ASRC_1 , +1 ,0 ,NULL ,0 ), +SND_SOC_DAPM_SUPPLY_S ("ADC MONO R ASRC" ,1 ,RT5645_ASRC_1 , +0 ,0 ,NULL ,0 ), +/* Input Side */ /* micbias */ SND_SOC_DAPM_MICBIAS("micbias1", RT5645_PWR_ANLG2,
@@ -1504,6 +1634,17 @@ static const struct snd_soc_dapm_widget rt5645_dapm_widgets[] = { };static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { + {"adc stereo1 filter" ,NULL ,"ADC STO1 ASRC" , is_using_asrc }, + {"adc stereo2 filter" ,NULL ,"ADC STO2 ASRC" , is_using_asrc }, + {"adc mono left filter" ,NULL ,"ADC MONO L ASRC" , is_using_asrc }, + {"adc mono right filter" ,NULL ,"ADC MONO R ASRC" , is_using_asrc }, + {"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 }, + + {"I2S1" ,NULL ,"I2S1 ASRC" }, + {"I2S2" ,NULL ,"I2S2 ASRC" }, + {"IN1P" ,NULL ,"LDO2" }, {"IN2P" ,NULL ,"LDO2" },
@@ -1550,12 +1691,15 @@ static const struct snd_soc_dapm_route rt5645_dapm_routes[] = { { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" }, { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" }, + { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC" }, { "Mono DMIC L Mux", "DMIC1", "DMIC L1" }, { "Mono DMIC L Mux", "DMIC2", "DMIC L2" }, + { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC" }, { "Mono DMIC R Mux", "DMIC1", "DMIC R1" }, { "Mono DMIC R Mux", "DMIC2", "DMIC R2" }, + { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC" }, { "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC Mux" }, { "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
Signature · 1 line
1.8.1.1.439.g50a6b54
PATCH 2/2 ASoC: rt5645: Add combo jack support
From: Bard Liao <[email protected]>
This patch adds combo jack support of rt5645.
--- sound/soc/codecs/rt5645.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/codecs/rt5645.c +6 -0
@@ -2573,6 +2573,12 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, } +regmap_update_bits (rt5645->regmap,RT5645_IN1_CTRL1 , +RT5645_CBJ_BST1_EN ,RT5645_CBJ_BST1_EN ); +regmap_update_bits (rt5645->regmap,RT5645_JD_CTRL3 , +RT5645_JD_CBJ_EN |RT5645_JD_CBJ_POL , +RT5645_JD_CBJ_EN |RT5645_JD_CBJ_POL ); +if (rt5645->i2c->irq) { ret =request_threaded_irq (rt5645->i2c->irq,NULL , rt5645_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
Signature · 1 line
1.8.1.1.439.g50a6b54
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: rt5645: Add combo jack support
sound/soc/codecs/rt5645.c static int rt5645_i2c_probe(struct i2c_client *i2c, · line 2581
Quoted 10 lines · On Fri, Oct 31, 2014 at 03:37:56PM +0800, [email protected] wrote:
sound/soc/codecs/rt5645.c +6
-0@@ -2573,6 +2573,12 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, } +regmap_update_bits (rt5645->regmap,RT5645_IN1_CTRL1 , +RT5645_CBJ_BST1_EN ,RT5645_CBJ_BST1_EN ); +regmap_update_bits (rt5645->regmap,RT5645_JD_CTRL3 , +RT5645_JD_CBJ_EN |RT5645_JD_CBJ_POL , +RT5645_JD_CBJ_EN |RT5645_JD_CBJ_POL ); +
Is it really a good idea to enable this unconditionally - doesn't it depend on the system hardware if this should be set up or how (the _POL looks like a polarity setting for example)? I'd expect it to at least waste power.
Quoted 3 lines · On Fri, Oct 31, 2014 at 03:37:55PM +0800, [email protected] wrote:
From: Bard Liao <[email protected]>
This patch add ASRC support for rt5645 codec.
Applied, thanks.
sound/soc/codecs/rt5645.c static SOC_ENUM_SINGLE_DECL(rt5645_tdm_adc_sel_enum, · line 473
Quoted 13 lines · On 10/31/2014 08:37 AM, [email protected] wrote:
sound/soc/codecs/rt5645.c +4
-0@@ -443,6 +443,65 @@ static SOC_ENUM_SINGLE_DECL(rt5645_tdm_adc_sel_enum,RT5645_TDM_CTRL_1 ,8 , rt5645_tdm_adc_data_select); +static int rt5645_clk_sel_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +}
This function seems to be completely unused.
Quoted 17 lines
-----Original Message-----
From: Lars-Peter Clausen [mailto:[email protected]]
Sent: Saturday, November 08, 2014 4:18 PM
To: Bard Liao; [email protected]; [email protected]
Cc: Oder Chiou; [email protected]; Flove
Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: rt5645: Add ASRC supportsound/soc/codecs/rt5645.c static
Quoted 5 lines · On 10/31/2014 08:37 AM, [email protected] wrote:
sound/soc/codecs/rt5645.c +0
-0@@ -443,6 +443,65 @@ staticSOC_ENUM_SINGLE_DECL(rt5645_tdm_adc_sel_enum,
Quoted 3 lines
sound/soc/codecs/rt5645.c +0
-0RT5645_TDM_CTRL_1 ,8 , rt5645_tdm_adc_data_select);
Quoted 6 lines
sound/soc/codecs/rt5645.c static SOC_ENUM_SINGLE_DECL(rt5645_tdm_adc_sel_enum, · line 473
Quoted 4 lines
sound/soc/codecs/rt5645.c +3
-0+static int rt5645_clk_sel_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) { +}This function seems to be completely unused.
Just sent a patch to remove it.
Thanks.
Quoted 4 lines
------Please consider the environment before printing this e-mail.