LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Akshu Agrawal <akshu.agrawal@amd.com>,
	Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	"Agrawal, Akshu" <Akshu.Agrawal@amd.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER
	MANAGEM..." <alsa-devel@alsa-project.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: [PATCH 07/10] ASoC: AMD: Move clk enable from hw_params/free to startup/shutdown
Date: Wed, 2 May 2018 02:20:01 +0530	[thread overview]
Message-ID: <1525207810-1305-7-git-send-email-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <1525207810-1305-1-git-send-email-Vijendar.Mukunda@amd.com>

From: Akshu Agrawal <akshu.agrawal@amd.com>

hw_param can be called multiple times and thus we can have
more clk enable. The clk may not get diabled due to refcounting.
startup/shutdown ensures single clk enable/disable call.

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 sound/soc/amd/acp-da7219-max98357a.c | 49 +++++++++++++++++++++++++-----------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index 215b06b..6495eed 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -91,8 +91,7 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
-static int cz_da7219_hw_params(struct snd_pcm_substream *substream,
-			     struct snd_pcm_hw_params *params)
+static int da7219_clk_enable(struct snd_pcm_substream *substream)
 {
 	int ret = 0;
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -106,11 +105,9 @@ static int cz_da7219_hw_params(struct snd_pcm_substream *substream,
 	return ret;
 }
 
-static int cz_da7219_hw_free(struct snd_pcm_substream *substream)
+static void da7219_clk_disable(void)
 {
 	clk_disable_unprepare(da7219_dai_clk);
-
-	return 0;
 }
 
 static const unsigned int channels[] = {
@@ -133,7 +130,7 @@ static const struct snd_pcm_hw_constraint_list constraints_channels = {
 	.mask = 0,
 };
 
-static int cz_fe_startup(struct snd_pcm_substream *substream)
+static int cz_da7219_startup(struct snd_pcm_substream *substream)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 
@@ -147,23 +144,47 @@ static int cz_fe_startup(struct snd_pcm_substream *substream)
 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
 				   &constraints_rates);
 
-	return 0;
+	return da7219_clk_enable(substream);
+}
+
+static void cz_da7219_shutdown(struct snd_pcm_substream *substream)
+{
+	da7219_clk_disable();
+}
+
+static int cz_max_startup(struct snd_pcm_substream *substream)
+{
+	return da7219_clk_enable(substream);
+}
+
+static void cz_max_shutdown(struct snd_pcm_substream *substream)
+{
+	da7219_clk_disable();
+}
+
+static int cz_dmic_startup(struct snd_pcm_substream *substream)
+{
+	return da7219_clk_enable(substream);
+}
+
+static void cz_dmic_shutdown(struct snd_pcm_substream *substream)
+{
+	da7219_clk_disable();
 }
 
 static struct snd_soc_ops cz_da7219_cap_ops = {
-	.hw_params = cz_da7219_hw_params,
-	.hw_free = cz_da7219_hw_free,
-	.startup = cz_fe_startup,
+	.startup = cz_da7219_startup,
+	.shutdown = cz_da7219_shutdown,
 };
 
 static struct snd_soc_ops cz_max_play_ops = {
-	.hw_params = cz_da7219_hw_params,
-	.hw_free = cz_da7219_hw_free,
+	.startup = cz_max_startup,
+	.shutdown = cz_max_shutdown,
 };
 
 static struct snd_soc_ops cz_dmic_cap_ops = {
-	.hw_params = cz_da7219_hw_params,
-	.hw_free = cz_da7219_hw_free,
+	.startup = cz_dmic_startup,
+	.shutdown = cz_dmic_shutdown,
 };
 
 static struct snd_soc_dai_link cz_dai_7219_98357[] = {
-- 
2.7.4

  parent reply	other threads:[~2018-05-01 20:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01 20:49 [PATCH V2 01/10] ASoC: amd: dma config parameters changes Vijendar Mukunda
2018-05-01 20:49 ` [PATCH V2 02/10] ASoC: amd: added byte count register offset variables to rtd Vijendar Mukunda
2018-05-11  3:20   ` Applied "ASoC: amd: added byte count register offset variables to rtd" to the asoc tree Mark Brown
2018-05-01 20:49 ` [PATCH V2 03/10] ASoC: amd: removed separate byte count variables for playback and capture Vijendar Mukunda
2018-05-11  3:19   ` Applied "ASoC: amd: removed separate byte count variables for playback and capture" to the asoc tree Mark Brown
2018-05-01 20:49 ` [PATCH V2 04/10] ASoC: amd: pte offset related dma driver changes Vijendar Mukunda
2018-05-21 15:48   ` Applied "ASoC: amd: pte offset related dma driver changes" to the asoc tree Mark Brown
2018-05-01 20:49 ` [PATCH 05/10] ASoC: amd: sram bank update changes Vijendar Mukunda
2018-05-21 15:48   ` Applied "ASoC: amd: sram bank update changes" to the asoc tree Mark Brown
2018-05-01 20:50 ` [PATCH 06/10] ASoC: amd: memory release for rtd structure Vijendar Mukunda
2018-05-01 20:50 ` Vijendar Mukunda [this message]
2018-05-01 20:50 ` [PATCH 08/10] ASoC: AMD: Fix clocks in CZ DA7219 machine driver Vijendar Mukunda
2018-05-01 20:50 ` [PATCH 09/10] ASoC: AMD: Add const to snd_soc_ops instances Vijendar Mukunda
2018-05-01 20:50 ` [PATCH V3 10/10] ASoC: amd: dma driver changes for bt i2s instance Vijendar Mukunda
2018-05-03  5:43   ` Daniel Kurtz
2018-05-03  7:35     ` Mukunda,Vijendar
2018-05-03 16:40       ` Daniel Kurtz
2018-05-04  4:34         ` Agrawal, Akshu
2018-05-07  6:44           ` Daniel Kurtz
2018-05-07  6:27 ` [PATCH V2 01/10] ASoC: amd: dma config parameters changes Mukunda,Vijendar
2018-05-07 10:22   ` Mukunda,Vijendar
2018-05-11  3:20 ` Applied "ASoC: amd: dma config parameters changes" to the asoc tree Mark Brown
2018-05-08  4:47 [PATCH V2 01/10] ASoC: amd: dma config parameters changes Vijendar Mukunda
2018-05-08  4:47 ` [PATCH 07/10] ASoC: AMD: Move clk enable from hw_params/free to startup/shutdown Vijendar Mukunda

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=1525207810-1305-7-git-send-email-Vijendar.Mukunda@amd.com \
    --to=vijendar.mukunda@amd.com \
    --cc=akshu.agrawal@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=djkurtz@chromium.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=weiyongjun1@huawei.com \
    --subject='Re: [PATCH 07/10] ASoC: AMD: Move clk enable from hw_params/free to startup/shutdown' \
    /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

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).