[RFC PATCH 2/2] ASoC: select sysclk clock from mlck clock provider in wm8994 driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When defined in device tree, MCLK1 and MCLK2 are used
as sysclk for aif1 and aif2 interfaces respectively.
If clock rate is let 0, the frequency provided by
wm8994_set_dai_sysclk() is used instead.

Signed-off-by: Olivier Moysan <olivier.moysan@xxxxxx>
---
 sound/soc/codecs/wm8994.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 21ffd64..7a84e37 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -11,6 +11,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -2376,18 +2377,35 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
 {
 	struct snd_soc_codec *codec = dai->codec;
 	struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
+	struct wm8994 *control = wm8994->wm8994;
+	struct wm8994_pdata *pdata = &control->pdata;
+	unsigned long rate;
 	int i;
 
 	switch (dai->id) {
 	case 1:
+		if (pdata->mclk1) {
+			rate = clk_get_rate(pdata->mclk1);
+			if (rate)
+				freq = (unsigned int)rate;
+			clk_id = WM8994_SYSCLK_MCLK1;
+		}
+		break;
 	case 2:
+		if (pdata->mclk2) {
+			rate = clk_get_rate(pdata->mclk2);
+			if (rate)
+				freq = (unsigned int)rate;
+			clk_id = WM8994_SYSCLK_MCLK2;
+		}
 		break;
-
 	default:
 		/* AIF3 shares clocking with AIF1/2 */
 		return -EINVAL;
 	}
 
+	dev_info(codec->dev, "%s:.clock id %d\n", __func__, clk_id);
+
 	switch (clk_id) {
 	case WM8994_SYSCLK_MCLK1:
 		wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK1;
-- 
1.9.1

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



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux