diff mbox

[2/4] ASoC: rt5670: check if asrc is useable

Message ID 1415793273-7844-2-git-send-email-bardliao@realtek.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bard Liao Nov. 12, 2014, 11:54 a.m. UTC
From: Bard Liao <bardliao@realtek.com>

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

Signed-off-by: Bard Liao <bardliao@realtek.com>
---
 sound/soc/codecs/rt5670.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Lars-Peter Clausen Nov. 12, 2014, 7:42 p.m. UTC | #1
On 11/12/2014 12:54 PM, bardliao@realtek.com wrote:
> From: Bard Liao <bardliao@realtek.com>
>
> To use ASRC, the sysclk should be faster than 384 times sample
> rate of I2S1.
>
> Signed-off-by: Bard Liao <bardliao@realtek.com>
> ---
>   sound/soc/codecs/rt5670.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
> index 85dc210..898b17f 100644
> --- a/sound/soc/codecs/rt5670.c
> +++ b/sound/soc/codecs/rt5670.c
> @@ -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
Bard Liao Nov. 14, 2014, 11:38 a.m. UTC | #2
> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars@metafoo.de]
> Sent: Thursday, November 13, 2014 3:43 AM
> To: Bard Liao
> Cc: broonie@kernel.org; lgirdwood@gmail.com;
> alsa-devel@alsa-project.org; Flove; Oder Chiou; mengdong.lin@intel.com;
> yao.jin@intel.com
> Subject: Re: [PATCH 2/4] ASoC: rt5670: check if asrc is useable
> 
> On 11/12/2014 12:54 PM, bardliao@realtek.com wrote:
> > From: Bard Liao <bardliao@realtek.com>
> >
> > To use ASRC, the sysclk should be faster than 384 times sample rate of
> > I2S1.
> >
> > Signed-off-by: Bard Liao <bardliao@realtek.com>
> > ---
> >   sound/soc/codecs/rt5670.c | 15 +++++++++++++--
> >   1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
> > index 85dc210..898b17f 100644
> > --- a/sound/soc/codecs/rt5670.c
> > +++ b/sound/soc/codecs/rt5670.c
> > @@ -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.

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.

> 
> Thanks,
> - Lars
> 
> 
> ------Please consider the environment before printing this e-mail.
Mark Brown Nov. 14, 2014, 3:11 p.m. UTC | #3
On Fri, Nov 14, 2014 at 11:38:51AM +0000, Bard Liao wrote:

> 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.
diff mbox

Patch

diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index 85dc210..898b17f 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -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" },