* [PATCH 1/2] ASoC: rt5645: Add ASRC support
@ 2014-10-31 7:37 bardliao
2014-10-31 7:37 ` [PATCH 2/2] ASoC: rt5645: Add combo jack support bardliao
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: bardliao @ 2014-10-31 7:37 UTC (permalink / raw)
To: broonie, lgirdwood; +Cc: oder_chiou, Bard Liao, alsa-devel, lars, flove
From: Bard Liao <bardliao@realtek.com>
This patch add ASRC support for rt5645 codec.
Signed-off-by: Bard Liao <bardliao@realtek.com>
---
sound/soc/codecs/rt5645.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index bc442f4..3131e91 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -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" },
--
1.8.1.1.439.g50a6b54
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] ASoC: rt5645: Add combo jack support
2014-10-31 7:37 [PATCH 1/2] ASoC: rt5645: Add ASRC support bardliao
@ 2014-10-31 7:37 ` bardliao
2014-11-07 11:46 ` Mark Brown
2014-11-07 11:47 ` [PATCH 1/2] ASoC: rt5645: Add ASRC support Mark Brown
2014-11-08 8:18 ` Lars-Peter Clausen
2 siblings, 1 reply; 6+ messages in thread
From: bardliao @ 2014-10-31 7:37 UTC (permalink / raw)
To: broonie, lgirdwood; +Cc: oder_chiou, Bard Liao, alsa-devel, lars, flove
From: Bard Liao <bardliao@realtek.com>
This patch adds combo jack support of rt5645.
Signed-off-by: Bard Liao <bardliao@realtek.com>
---
sound/soc/codecs/rt5645.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 3131e91..0e9c77f 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -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
--
1.8.1.1.439.g50a6b54
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] ASoC: rt5645: Add combo jack support
2014-10-31 7:37 ` [PATCH 2/2] ASoC: rt5645: Add combo jack support bardliao
@ 2014-11-07 11:46 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2014-11-07 11:46 UTC (permalink / raw)
To: bardliao; +Cc: oder_chiou, alsa-devel, lars, lgirdwood, flove
[-- Attachment #1.1: Type: text/plain, Size: 667 bytes --]
On Fri, Oct 31, 2014 at 03:37:56PM +0800, bardliao@realtek.com wrote:
> @@ -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.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] ASoC: rt5645: Add ASRC support
2014-10-31 7:37 [PATCH 1/2] ASoC: rt5645: Add ASRC support bardliao
2014-10-31 7:37 ` [PATCH 2/2] ASoC: rt5645: Add combo jack support bardliao
@ 2014-11-07 11:47 ` Mark Brown
2014-11-08 8:18 ` Lars-Peter Clausen
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2014-11-07 11:47 UTC (permalink / raw)
To: bardliao; +Cc: oder_chiou, alsa-devel, lars, lgirdwood, flove
[-- Attachment #1.1: Type: text/plain, Size: 186 bytes --]
On Fri, Oct 31, 2014 at 03:37:55PM +0800, bardliao@realtek.com wrote:
> From: Bard Liao <bardliao@realtek.com>
>
> This patch add ASRC support for rt5645 codec.
Applied, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] ASoC: rt5645: Add ASRC support
2014-10-31 7:37 [PATCH 1/2] ASoC: rt5645: Add ASRC support bardliao
2014-10-31 7:37 ` [PATCH 2/2] ASoC: rt5645: Add combo jack support bardliao
2014-11-07 11:47 ` [PATCH 1/2] ASoC: rt5645: Add ASRC support Mark Brown
@ 2014-11-08 8:18 ` Lars-Peter Clausen
2014-11-11 3:32 ` Bard Liao
2 siblings, 1 reply; 6+ messages in thread
From: Lars-Peter Clausen @ 2014-11-08 8:18 UTC (permalink / raw)
To: bardliao, broonie, lgirdwood; +Cc: oder_chiou, alsa-devel, flove
On 10/31/2014 08:37 AM, bardliao@realtek.com wrote:
> diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
> index bc442f4..3131e91 100644
> --- a/sound/soc/codecs/rt5645.c
> +++ b/sound/soc/codecs/rt5645.c
> @@ -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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] ASoC: rt5645: Add ASRC support
2014-11-08 8:18 ` Lars-Peter Clausen
@ 2014-11-11 3:32 ` Bard Liao
0 siblings, 0 replies; 6+ messages in thread
From: Bard Liao @ 2014-11-11 3:32 UTC (permalink / raw)
To: Lars-Peter Clausen, broonie@kernel.org, lgirdwood@gmail.com
Cc: Oder Chiou, alsa-devel@alsa-project.org, Flove
> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
> Sent: Saturday, November 08, 2014 4:18 PM
> To: Bard Liao; broonie@kernel.org; lgirdwood@gmail.com
> Cc: Oder Chiou; alsa-devel@alsa-project.org; Flove
> Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: rt5645: Add ASRC support
>
> On 10/31/2014 08:37 AM, bardliao@realtek.com wrote:
> > diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
> > index bc442f4..3131e91 100644
> > --- a/sound/soc/codecs/rt5645.c
> > +++ b/sound/soc/codecs/rt5645.c
> > @@ -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.
Just sent a patch to remove it.
Thanks.
>
>
>
> ------Please consider the environment before printing this e-mail.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-11 3:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31 7:37 [PATCH 1/2] ASoC: rt5645: Add ASRC support bardliao
2014-10-31 7:37 ` [PATCH 2/2] ASoC: rt5645: Add combo jack support bardliao
2014-11-07 11:46 ` Mark Brown
2014-11-07 11:47 ` [PATCH 1/2] ASoC: rt5645: Add ASRC support Mark Brown
2014-11-08 8:18 ` Lars-Peter Clausen
2014-11-11 3:32 ` Bard Liao
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.