All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akshu Agrawal <akshu.agrawal@amd.com>
To: broonie@kernel.org, alsa-devel@alsa-project.org
Cc: tiwai@suse.de, lgirdwood@gmail.com, akshu.agrawal@amd.com
Subject: [PATCH 2/2] ASoC: AMD: Enable da7219 master clock using common clock framework
Date: Mon, 12 Mar 2018 14:41:23 +0530	[thread overview]
Message-ID: <1520845883-24062-2-git-send-email-akshu.agrawal@amd.com> (raw)
In-Reply-To: <1520845883-24062-1-git-send-email-akshu.agrawal@amd.com>

DA7219 is clock master for other codecs. DA7219 has exposed clock
control by using common clock framework and same is used to enable
and disable clock for all codecs in the system.

TEST=Build, apply grunt_mixer_settings:
iotools mmio_write32 0xfed80e40 0x040c40c0
iotools mmio_write32 0xfed80e28 0x10000
aplay -D hw:0,0 -vv <file>
arecord -D hw:0,0 -f dat -d 5 -vv <file>
aplay -D hw:0,1 -vv <file>

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

diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index d07c2a1..1441be3 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -42,6 +42,7 @@
 #define DUAL_CHANNEL		2
 
 static struct snd_soc_jack cz_jack;
+struct clk *da7219_dai_clk;
 
 static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 {
@@ -66,6 +67,8 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
+	da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
+
 	ret = snd_soc_card_jack_new(card, "Headset Jack",
 				SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
 				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
@@ -81,6 +84,30 @@ 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)
+{
+	int ret = 0;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+	ret = clk_prepare_enable(da7219_dai_clk);
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't enable master clock %d\n", ret);
+		return ret;
+	}
+
+	return ret;
+}
+
+static int cz_da7219_hw_free(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	clk_disable_unprepare(da7219_dai_clk);
+
+	return ret;
+}
+
 static const unsigned int channels[] = {
 	DUAL_CHANNEL,
 };
@@ -119,9 +146,21 @@ static int cz_fe_startup(struct snd_pcm_substream *substream)
 }
 
 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,
 };
 
+static struct snd_soc_ops cz_max_play_ops = {
+	.hw_params = cz_da7219_hw_params,
+	.hw_free = cz_da7219_hw_free,
+};
+
+static struct snd_soc_ops cz_dmic_cap_ops = {
+	.hw_params = cz_da7219_hw_params,
+	.hw_free = cz_da7219_hw_free,
+};
+
 static struct snd_soc_dai_link cz_dai_7219_98357[] = {
 	{
 		.name = "amd-da7219-play-cap",
@@ -147,6 +186,7 @@ static int cz_fe_startup(struct snd_pcm_substream *substream)
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_playback = 1,
+		.ops = &cz_max_play_ops,
 	},
 	{
 		.name = "dmic",
@@ -158,6 +198,7 @@ static int cz_fe_startup(struct snd_pcm_substream *substream)
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_capture = 1,
+		.ops = &cz_dmic_cap_ops,
 	},
 };
 
-- 
1.9.1

  reply	other threads:[~2018-03-12  9:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12  9:11 [PATCH 1/2] ASoC: AMD: Use single dai for da7219 playback and capture Akshu Agrawal
2018-03-12  9:11 ` Akshu Agrawal [this message]
2018-03-13  0:32   ` [PATCH 2/2] ASoC: AMD: Enable da7219 master clock using common clock framework kbuild test robot
2018-03-13  4:37   ` kbuild test robot
2018-03-13  4:37   ` [PATCH] ASoC: AMD: fix returnvar.cocci warnings kbuild test robot
2018-03-13 11:03   ` [RFC PATCH] ASoC: AMD: da7219_dai_clk can be static kbuild test robot
2018-04-16 17:15     ` Applied "ASoC: amd: acp-da7219-max98357: Make symbol da7219_dai_clk static" to the asoc tree Mark Brown
2018-04-16 17:15     ` Mark Brown
2018-04-26 11:51     ` Mark Brown
2018-03-12 17:01 ` [PATCH 1/2] ASoC: AMD: Use single dai for da7219 playback and capture Mark Brown
2018-03-13  4:26   ` Agrawal, Akshu
2018-03-20  1:21 ` Applied "ASoC: amd: Use single dai for da7219 playback and capture" to the asoc tree Mark Brown

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=1520845883-24062-2-git-send-email-akshu.agrawal@amd.com \
    --to=akshu.agrawal@amd.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=tiwai@suse.de \
    /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 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.