diff mbox series

Applied "ASoC: amd: Enable da7219 master clock using common clock framework" to the asoc tree

Message ID 20180320012132.ADB6F44007A@finisterre.ee.mobilebroadband
State Accepted
Commit c88d311533563e6dadc244930a36125d592f5ec5
Headers show
Series Applied "ASoC: amd: Enable da7219 master clock using common clock framework" to the asoc tree | expand

Commit Message

Mark Brown March 20, 2018, 1:21 a.m. UTC
The patch

   ASoC: amd: Enable da7219 master clock using common clock framework

has been applied to the asoc tree at

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

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 c88d311533563e6dadc244930a36125d592f5ec5 Mon Sep 17 00:00:00 2001
From: Akshu Agrawal <akshu.agrawal@amd.com>

Date: Mon, 19 Mar 2018 11:07:42 +0530
Subject: [PATCH] ASoC: amd: Enable da7219 master clock using common clock
 framework

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=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>

Signed-off-by: Mark Brown <broonie@kernel.org>

---
 sound/soc/amd/acp-da7219-max98357a.c | 41 ++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

-- 
2.16.2

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
diff mbox series

Patch

diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index d07c2a1d5d9e..99c6b5ce5c6c 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -29,6 +29,7 @@ 
 #include <sound/pcm_params.h>
 #include <sound/soc-dapm.h>
 #include <sound/jack.h>
+#include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/i2c.h>
@@ -42,11 +43,13 @@ 
 #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)
 {
 	int ret;
 	struct snd_soc_card *card = rtd->card;
+	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_component *component = codec_dai->component;
 
@@ -66,6 +69,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 +86,28 @@  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)
+{
+	clk_disable_unprepare(da7219_dai_clk);
+
+	return 0;
+}
+
 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 struct snd_soc_dai_link cz_dai_7219_98357[] = {
 		.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 struct snd_soc_dai_link cz_dai_7219_98357[] = {
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_capture = 1,
+		.ops = &cz_dmic_cap_ops,
 	},
 };