mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chancel Liu <chancel.liu@nxp.com>
To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, perex@perex.cz,
	tiwai@suse.com, ckeepax@opensource.cirrus.com,
	patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: Chancel Liu <chancel.liu@nxp.com>
Subject: [PATCH 4/4] ASoC: wm8524: Delay some time to follow power up sequency
Date: Wed, 22 Feb 2023 19:39:45 +0800	[thread overview]
Message-ID: <20230222113945.3390672-4-chancel.liu@nxp.com> (raw)
In-Reply-To: <20230222113945.3390672-1-chancel.liu@nxp.com>

The recommended power sequence needs to be followed to ensure the best
performance. After MCLK, BCLK and MUTE=1 are ready, this device has to
wait some time before ready to output audio. Otherwise the beginning
data may be lost. For more details about the timing constraints, please
refer to WTN0302 on https://www.cirrus.com/products/wm8524/

Signed-off-by: Chancel Liu <chancel.liu@nxp.com>
---
 sound/soc/codecs/wm8524.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c
index 8f2130e05b32..f61967b66c3b 100644
--- a/sound/soc/codecs/wm8524.c
+++ b/sound/soc/codecs/wm8524.c
@@ -21,6 +21,7 @@
 #include <sound/soc.h>
 #include <sound/initval.h>
 
+#define WM8524_POWER_UP_DELAY_MS 100
 #define WM8524_NUM_RATES 7
 
 /* codec private data */
@@ -29,6 +30,7 @@ struct wm8524_priv {
 	unsigned int sysclk;
 	unsigned int rate_constraint_list[WM8524_NUM_RATES];
 	struct snd_pcm_hw_constraint_list rate_constraint;
+	unsigned int power_up_delay;
 };
 
 
@@ -157,6 +159,28 @@ static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
 	return 0;
 }
 
+static int wm8524_trigger(struct snd_pcm_substream *substream, int cmd,
+			  struct snd_soc_dai *dai)
+{
+	struct wm8524_priv *wm8524 = snd_soc_dai_get_drvdata(dai);
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		mdelay(wm8524->power_up_delay);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+};
+
 #define WM8524_RATES SNDRV_PCM_RATE_8000_192000
 
 #define WM8524_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
@@ -169,6 +193,7 @@ static const struct snd_soc_dai_ops wm8524_dai_ops = {
 	.set_sysclk	= wm8524_set_dai_sysclk,
 	.set_fmt	= wm8524_set_fmt,
 	.mute_stream	= wm8524_mute_stream,
+	.trigger	= wm8524_trigger,
 };
 
 static struct snd_soc_dai_driver wm8524_dai = {
@@ -213,6 +238,7 @@ MODULE_DEVICE_TABLE(of, wm8524_of_match);
 
 static int wm8524_codec_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct wm8524_priv *wm8524;
 	int ret;
 
@@ -230,6 +256,9 @@ static int wm8524_codec_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	wm8524->power_up_delay = WM8524_POWER_UP_DELAY_MS;
+	of_property_read_u32(np, "wlf,power-up-delay-ms", &wm8524->power_up_delay);
+
 	ret = devm_snd_soc_register_component(&pdev->dev,
 			&soc_component_dev_wm8524, &wm8524_dai, 1);
 	if (ret < 0)
-- 
2.25.1


  parent reply	other threads:[~2023-02-22 11:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 11:39 [PATCH 1/4] ASoC: dt-bindings: wlf,wm8524: Convert to json-schema Chancel Liu
2023-02-22 11:39 ` [PATCH 2/4] ASoC: dt-bindings: wlf,wm8524: Add a property to specify power up sequency time Chancel Liu
2023-02-22 12:42   ` Krzysztof Kozlowski
2023-02-24 10:54     ` Chancel Liu
2023-02-24 11:00       ` Krzysztof Kozlowski
2023-02-27  9:06         ` Chancel Liu
2023-02-22 12:50   ` Mark Brown
2023-02-24 10:56     ` Chancel Liu
2023-02-24 10:59       ` Krzysztof Kozlowski
2023-02-22 11:39 ` [PATCH 3/4] ASoC: wm8524: Correct the MUTE setting while power up/down Chancel Liu
2023-02-22 11:39 ` Chancel Liu [this message]
2023-02-22 12:48   ` [PATCH 4/4] ASoC: wm8524: Delay some time to follow power up sequency Mark Brown
2023-02-24 10:54     ` Chancel Liu
2023-02-24 12:30       ` Mark Brown
2023-02-27  9:07         ` Chancel Liu
2023-02-22 12:36 ` [PATCH 1/4] ASoC: dt-bindings: wlf,wm8524: Convert to json-schema Krzysztof Kozlowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230222113945.3390672-4-chancel.liu@nxp.com \
    --to=chancel.liu@nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®