alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
@ 2019-10-25  9:11 Brent Lu
  2019-10-25 14:05 ` Pierre-Louis Bossart
  2019-10-28 14:56 ` [alsa-devel] Applied "ASoC: eve: implement set_bias_level function for rt5514" to the asoc tree Mark Brown
  0 siblings, 2 replies; 7+ messages in thread
From: Brent Lu @ 2019-10-25  9:11 UTC (permalink / raw)
  To: alsa-devel
  Cc: Cezary Rojewski, Kuninori Morimoto, Tzung-Bi Shih, linux-kernel,
	Takashi Iwai, Jie Yang, Pierre-Louis Bossart, Liam Girdwood,
	Richard Fontana, Mark Brown, Naveen M, Thomas Gleixner,
	Subhransu S . Prusty, Brent Lu

The first DMIC capture always fail (zero sequence data from PCM port)
after using DSP hotwording function (i.e. Google assistant).

This rt5514 codec requires to control mclk directly in the set_bias_level
function. Implement this function in machine driver to control the
ssp1_mclk clock explicitly could fix this issue.

Signed-off-by: Brent Lu <brent.lu@intel.com>
---
 .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c  | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index dc09a85..b546de8 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -653,6 +653,55 @@ static struct snd_soc_dai_link kabylake_dais[] = {
 	},
 };
 
+static int kabylake_set_bias_level(struct snd_soc_card *card,
+	struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
+{
+	struct snd_soc_component *component = dapm->component;
+	struct kbl_codec_private *priv = snd_soc_card_get_drvdata(card);
+	int ret = 0;
+
+	if (!component || strcmp(component->name, RT5514_DEV_NAME))
+		return 0;
+
+	if (IS_ERR(priv->mclk))
+		return 0;
+
+	/*
+	 * It's required to control mclk directly in the set_bias_level
+	 * function for rt5514 codec or the recording function could
+	 * break.
+	 */
+	switch (level) {
+	case SND_SOC_BIAS_PREPARE:
+		if (dapm->bias_level == SND_SOC_BIAS_ON) {
+			dev_dbg(card->dev, "Disable mclk");
+			clk_disable_unprepare(priv->mclk);
+		} else {
+			dev_dbg(card->dev, "Enable mclk");
+			ret = clk_set_rate(priv->mclk, 24000000);
+			if (ret) {
+				dev_err(card->dev, "Can't set rate for mclk, err: %d\n",
+					ret);
+				return ret;
+			}
+
+			ret = clk_prepare_enable(priv->mclk);
+			if (ret) {
+				dev_err(card->dev, "Can't enable mclk, err: %d\n",
+					ret);
+
+				/* mclk is already enabled in FW */
+				ret = 0;
+			}
+		}
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
 static int kabylake_card_late_probe(struct snd_soc_card *card)
 {
 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
@@ -692,6 +741,7 @@ static struct snd_soc_card kabylake_audio_card = {
 	.owner = THIS_MODULE,
 	.dai_link = kabylake_dais,
 	.num_links = ARRAY_SIZE(kabylake_dais),
+	.set_bias_level = kabylake_set_bias_level,
 	.controls = kabylake_controls,
 	.num_controls = ARRAY_SIZE(kabylake_controls),
 	.dapm_widgets = kabylake_widgets,
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
  2019-10-25  9:11 [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514 Brent Lu
@ 2019-10-25 14:05 ` Pierre-Louis Bossart
  2019-10-25 14:43   ` Lu, Brent
  2019-10-28 14:56 ` [alsa-devel] Applied "ASoC: eve: implement set_bias_level function for rt5514" to the asoc tree Mark Brown
  1 sibling, 1 reply; 7+ messages in thread
From: Pierre-Louis Bossart @ 2019-10-25 14:05 UTC (permalink / raw)
  To: Brent Lu, alsa-devel
  Cc: Cezary Rojewski, Kuninori Morimoto, Tzung-Bi Shih, linux-kernel,
	Jie Yang, Takashi Iwai, Liam Girdwood, Richard Fontana,
	Mark Brown, Naveen M, Thomas Gleixner, Subhransu S . Prusty



On 10/25/19 4:11 AM, Brent Lu wrote:
> The first DMIC capture always fail (zero sequence data from PCM port)
> after using DSP hotwording function (i.e. Google assistant).

Can you clarify where the DSP hotwording is done? Intel DSP or rt5514?

Turning on the MCLK with the BIAS info might force the Intel DSP to 
remain on, which would impact power consumption if it was supposed to 
remain off.

> This rt5514 codec requires to control mclk directly in the set_bias_level
> function. Implement this function in machine driver to control the
> ssp1_mclk clock explicitly could fix this issue.
> 
> Signed-off-by: Brent Lu <brent.lu@intel.com>
> ---
>   .../soc/intel/boards/kbl_rt5663_rt5514_max98927.c  | 50 ++++++++++++++++++++++
>   1 file changed, 50 insertions(+)
> 
> diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> index dc09a85..b546de8 100644
> --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
> @@ -653,6 +653,55 @@ static struct snd_soc_dai_link kabylake_dais[] = {
>   	},
>   };
>   
> +static int kabylake_set_bias_level(struct snd_soc_card *card,
> +	struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
> +{
> +	struct snd_soc_component *component = dapm->component;
> +	struct kbl_codec_private *priv = snd_soc_card_get_drvdata(card);
> +	int ret = 0;
> +
> +	if (!component || strcmp(component->name, RT5514_DEV_NAME))
> +		return 0;
> +
> +	if (IS_ERR(priv->mclk))
> +		return 0;
> +
> +	/*
> +	 * It's required to control mclk directly in the set_bias_level
> +	 * function for rt5514 codec or the recording function could
> +	 * break.
> +	 */
> +	switch (level) {
> +	case SND_SOC_BIAS_PREPARE:
> +		if (dapm->bias_level == SND_SOC_BIAS_ON) {
> +			dev_dbg(card->dev, "Disable mclk");
> +			clk_disable_unprepare(priv->mclk);
> +		} else {
> +			dev_dbg(card->dev, "Enable mclk");
> +			ret = clk_set_rate(priv->mclk, 24000000);
> +			if (ret) {
> +				dev_err(card->dev, "Can't set rate for mclk, err: %d\n",
> +					ret);
> +				return ret;
> +			}
> +
> +			ret = clk_prepare_enable(priv->mclk);
> +			if (ret) {
> +				dev_err(card->dev, "Can't enable mclk, err: %d\n",
> +					ret);
> +
> +				/* mclk is already enabled in FW */
> +				ret = 0;
> +			}
> +		}
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	return ret;
> +}
> +
>   static int kabylake_card_late_probe(struct snd_soc_card *card)
>   {
>   	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
> @@ -692,6 +741,7 @@ static struct snd_soc_card kabylake_audio_card = {
>   	.owner = THIS_MODULE,
>   	.dai_link = kabylake_dais,
>   	.num_links = ARRAY_SIZE(kabylake_dais),
> +	.set_bias_level = kabylake_set_bias_level,
>   	.controls = kabylake_controls,
>   	.num_controls = ARRAY_SIZE(kabylake_controls),
>   	.dapm_widgets = kabylake_widgets,
> 
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
  2019-10-25 14:05 ` Pierre-Louis Bossart
@ 2019-10-25 14:43   ` Lu, Brent
  2019-10-25 14:48     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 7+ messages in thread
From: Lu, Brent @ 2019-10-25 14:43 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: Rojewski, Cezary, Kuninori Morimoto, Tzung-Bi Shih, linux-kernel,
	Jie Yang, Takashi Iwai, Liam Girdwood, Richard Fontana,
	Mark Brown, M, Naveen, Thomas Gleixner, Subhransu S . Prusty

> On 10/25/19 4:11 AM, Brent Lu wrote:
> > The first DMIC capture always fail (zero sequence data from PCM port)
> > after using DSP hotwording function (i.e. Google assistant).
> 
> Can you clarify where the DSP hotwording is done? Intel DSP or rt5514?
> 
> Turning on the MCLK with the BIAS info might force the Intel DSP to remain
> on, which would impact power consumption if it was supposed to remain off.
> 

Hi Pierre,

It's done in rt5514's DSP and the interface is SPI instead of I2S for the voice wake 
up function.

There is a driver rt5514-spi.c which provides platform driver and DAI. User space 
application first uses the mixer to turn on the voice wake up function:

amixer -c0 cset name='DSP Voice Wake Up' on

Then open and read data from the PCM port which goes to the SPI platform and 
dai code. Finally it uses same mixer to turn off the function and return to normal 
codec mode. The DMIC recording (from I2S) and the voice wake on function should 
be mutually exclusive according to the driver design.

In the codec driver rt5514.c there is a rt5514_set_bias_level function. It's expected to 
turn on/off mclk here according to Realtek people's say but our ssp clock requires set 
rate function to be called in advance so I implement the code in machine driver.


Regards,
Brent
> > This rt5514 codec requires to control mclk directly in the
> > set_bias_level function. Implement this function in machine driver to
> > control the ssp1_mclk clock explicitly could fix this issue.
> >
> > Signed-off-by: Brent Lu <brent.lu@intel.com>

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
  2019-10-25 14:43   ` Lu, Brent
@ 2019-10-25 14:48     ` Pierre-Louis Bossart
  2019-10-25 16:14       ` Lu, Brent
  0 siblings, 1 reply; 7+ messages in thread
From: Pierre-Louis Bossart @ 2019-10-25 14:48 UTC (permalink / raw)
  To: Lu, Brent, alsa-devel
  Cc: Rojewski, Cezary, Kuninori Morimoto, Tzung-Bi Shih, linux-kernel,
	Jie Yang, Takashi Iwai, Liam Girdwood, Richard Fontana,
	Mark Brown, M, Naveen, Thomas Gleixner, Subhransu S . Prusty



On 10/25/19 9:43 AM, Lu, Brent wrote:
>> On 10/25/19 4:11 AM, Brent Lu wrote:
>>> The first DMIC capture always fail (zero sequence data from PCM port)
>>> after using DSP hotwording function (i.e. Google assistant).
>>
>> Can you clarify where the DSP hotwording is done? Intel DSP or rt5514?
>>
>> Turning on the MCLK with the BIAS info might force the Intel DSP to remain
>> on, which would impact power consumption if it was supposed to remain off.
>>
> 
> Hi Pierre,
> 
> It's done in rt5514's DSP and the interface is SPI instead of I2S for the voice wake
> up function.
> 
> There is a driver rt5514-spi.c which provides platform driver and DAI. User space
> application first uses the mixer to turn on the voice wake up function:
> 
> amixer -c0 cset name='DSP Voice Wake Up' on
> 
> Then open and read data from the PCM port which goes to the SPI platform and
> dai code. Finally it uses same mixer to turn off the function and return to normal
> codec mode. The DMIC recording (from I2S) and the voice wake on function should
> be mutually exclusive according to the driver design.
> 
> In the codec driver rt5514.c there is a rt5514_set_bias_level function. It's expected to
> turn on/off mclk here according to Realtek people's say but our ssp clock requires set
> rate function to be called in advance so I implement the code in machine driver.

Can you clarify if the rt5514 needs the MCLK while it's doing the 
hotword detection?

My point is really that this patch uses a card-level BIAS indication, 
and I'd like to make sure this does not interfere with the audio DSP 
being in D3 state.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
  2019-10-25 14:48     ` Pierre-Louis Bossart
@ 2019-10-25 16:14       ` Lu, Brent
  2019-10-25 16:57         ` Pierre-Louis Bossart
  0 siblings, 1 reply; 7+ messages in thread
From: Lu, Brent @ 2019-10-25 16:14 UTC (permalink / raw)
  To: Pierre-Louis Bossart, alsa-devel
  Cc: Rojewski, Cezary, Kuninori Morimoto, Tzung-Bi Shih, linux-kernel,
	Jie Yang, Takashi Iwai, Liam Girdwood, Richard Fontana,
	Mark Brown, M, Naveen, Thomas Gleixner, Subhransu S . Prusty

> 
> Can you clarify if the rt5514 needs the MCLK while it's doing the hotword
> detection?

No, running the detection does not raise the bias level so the set_bias_level 
will not be called. The mclk is only turned on then off in mixer control's handler 
(rt5514_dsp_voice_wake_up_put) when enabling the hotword detection.

> 
> My point is really that this patch uses a card-level BIAS indication, and I'd like
> to make sure this does not interfere with the audio DSP being in D3 state.

The function checks the name of dapm so it would only react when rt5514's 
bias level is changing. And also the idle_bias_off of the codec driver is true so 
it's target_bias_level should not be overwritten in the dapm_power_widgets() 
function. The behavior should be similar to the previous patch which is using 
supply widget.


Regards,
Brent
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514
  2019-10-25 16:14       ` Lu, Brent
@ 2019-10-25 16:57         ` Pierre-Louis Bossart
  0 siblings, 0 replies; 7+ messages in thread
From: Pierre-Louis Bossart @ 2019-10-25 16:57 UTC (permalink / raw)
  To: Lu, Brent, alsa-devel
  Cc: Rojewski, Cezary, Kuninori Morimoto, Richard Fontana, Jie Yang,
	linux-kernel, Takashi Iwai, Liam Girdwood, Tzung-Bi Shih,
	Mark Brown, M, Naveen, Thomas Gleixner, Subhransu S . Prusty



On 10/25/19 11:14 AM, Lu, Brent wrote:
>>
>> Can you clarify if the rt5514 needs the MCLK while it's doing the hotword
>> detection?
> 
> No, running the detection does not raise the bias level so the set_bias_level
> will not be called. The mclk is only turned on then off in mixer control's handler
> (rt5514_dsp_voice_wake_up_put) when enabling the hotword detection.
> 
>>
>> My point is really that this patch uses a card-level BIAS indication, and I'd like
>> to make sure this does not interfere with the audio DSP being in D3 state.
> 
> The function checks the name of dapm so it would only react when rt5514's
> bias level is changing. And also the idle_bias_off of the codec driver is true so
> it's target_bias_level should not be overwritten in the dapm_power_widgets()
> function. The behavior should be similar to the previous patch which is using
> supply widget.

Ah yes, I did miss this test:

+	if (!component || strcmp(component->name, RT5514_DEV_NAME))
+		return 0;

Looks good then, thanks for the explanations.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [alsa-devel] Applied "ASoC: eve: implement set_bias_level function for rt5514" to the asoc tree
  2019-10-25  9:11 [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514 Brent Lu
  2019-10-25 14:05 ` Pierre-Louis Bossart
@ 2019-10-28 14:56 ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-10-28 14:56 UTC (permalink / raw)
  To: Brent Lu
  Cc: Pierre-Louis Bossart, alsa-devel, Kuninori Morimoto,
	Tzung-Bi Shih, linux-kernel, Takashi Iwai, Jie Yang,
	Cezary Rojewski, Liam Girdwood, Richard Fontana, Mark Brown,
	Naveen M, Thomas Gleixner, Subhransu S . Prusty

The patch

   ASoC: eve: implement set_bias_level function for rt5514

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 15747a80207585fe942416025540c0ff34e2aef8 Mon Sep 17 00:00:00 2001
From: Brent Lu <brent.lu@intel.com>
Date: Fri, 25 Oct 2019 17:11:31 +0800
Subject: [PATCH] ASoC: eve: implement set_bias_level function for rt5514

The first DMIC capture always fail (zero sequence data from PCM port)
after using DSP hotwording function (i.e. Google assistant).

This rt5514 codec requires to control mclk directly in the set_bias_level
function. Implement this function in machine driver to control the
ssp1_mclk clock explicitly could fix this issue.

Signed-off-by: Brent Lu <brent.lu@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/1571994691-20199-1-git-send-email-brent.lu@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 .../intel/boards/kbl_rt5663_rt5514_max98927.c | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index dc09a85e4c74..b546de8ba1e3 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -653,6 +653,55 @@ static struct snd_soc_dai_link kabylake_dais[] = {
 	},
 };
 
+static int kabylake_set_bias_level(struct snd_soc_card *card,
+	struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
+{
+	struct snd_soc_component *component = dapm->component;
+	struct kbl_codec_private *priv = snd_soc_card_get_drvdata(card);
+	int ret = 0;
+
+	if (!component || strcmp(component->name, RT5514_DEV_NAME))
+		return 0;
+
+	if (IS_ERR(priv->mclk))
+		return 0;
+
+	/*
+	 * It's required to control mclk directly in the set_bias_level
+	 * function for rt5514 codec or the recording function could
+	 * break.
+	 */
+	switch (level) {
+	case SND_SOC_BIAS_PREPARE:
+		if (dapm->bias_level == SND_SOC_BIAS_ON) {
+			dev_dbg(card->dev, "Disable mclk");
+			clk_disable_unprepare(priv->mclk);
+		} else {
+			dev_dbg(card->dev, "Enable mclk");
+			ret = clk_set_rate(priv->mclk, 24000000);
+			if (ret) {
+				dev_err(card->dev, "Can't set rate for mclk, err: %d\n",
+					ret);
+				return ret;
+			}
+
+			ret = clk_prepare_enable(priv->mclk);
+			if (ret) {
+				dev_err(card->dev, "Can't enable mclk, err: %d\n",
+					ret);
+
+				/* mclk is already enabled in FW */
+				ret = 0;
+			}
+		}
+		break;
+	default:
+		break;
+	}
+
+	return ret;
+}
+
 static int kabylake_card_late_probe(struct snd_soc_card *card)
 {
 	struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card);
@@ -692,6 +741,7 @@ static struct snd_soc_card kabylake_audio_card = {
 	.owner = THIS_MODULE,
 	.dai_link = kabylake_dais,
 	.num_links = ARRAY_SIZE(kabylake_dais),
+	.set_bias_level = kabylake_set_bias_level,
 	.controls = kabylake_controls,
 	.num_controls = ARRAY_SIZE(kabylake_controls),
 	.dapm_widgets = kabylake_widgets,
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-28 15:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-25  9:11 [alsa-devel] [PATCH] ASoC: eve: implement set_bias_level function for rt5514 Brent Lu
2019-10-25 14:05 ` Pierre-Louis Bossart
2019-10-25 14:43   ` Lu, Brent
2019-10-25 14:48     ` Pierre-Louis Bossart
2019-10-25 16:14       ` Lu, Brent
2019-10-25 16:57         ` Pierre-Louis Bossart
2019-10-28 14:56 ` [alsa-devel] Applied "ASoC: eve: implement set_bias_level function for rt5514" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).