diff options
author | Harsha Priya <harshapriya.n@intel.com> | 2017-03-15 19:28:25 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-03-21 14:43:32 -0400 |
commit | d7fba9dcf6cd74cb8a8ab1c4c2629a3f7df00bc9 (patch) | |
tree | 7390bc3b6df6ba7db1e06d0e0d88abd127b6bbab | |
parent | bf3e5ef5d549f650c13bef2b2192057cfef33d38 (diff) |
ASoC: Intel: Update bxt_da7219_max98357a to add a new
This patch adds a platform clock widget to turn off the clock only when
both headset capture and headset playback are not in use. This removes
turning off the clock in hw_free so that the clock is on when
either capture or playback of headset is in progress.
Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
Signed-off-by: Sathyanarayana Nujella <sathyanarayana.nujella@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/intel/boards/bxt_da7219_max98357a.c | 97 |
1 files changed, 53 insertions, 44 deletions
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index 2cda06cde4d1..3a8c4d954a91 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c | |||
@@ -55,6 +55,54 @@ enum { | |||
55 | BXT_DPCM_AUDIO_HDMI3_PB, | 55 | BXT_DPCM_AUDIO_HDMI3_PB, |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static inline struct snd_soc_dai *bxt_get_codec_dai(struct snd_soc_card *card) | ||
59 | { | ||
60 | struct snd_soc_pcm_runtime *rtd; | ||
61 | |||
62 | list_for_each_entry(rtd, &card->rtd_list, list) { | ||
63 | |||
64 | if (!strncmp(rtd->codec_dai->name, BXT_DIALOG_CODEC_DAI, | ||
65 | strlen(BXT_DIALOG_CODEC_DAI))) | ||
66 | return rtd->codec_dai; | ||
67 | } | ||
68 | |||
69 | return NULL; | ||
70 | } | ||
71 | |||
72 | static int platform_clock_control(struct snd_soc_dapm_widget *w, | ||
73 | struct snd_kcontrol *k, int event) | ||
74 | { | ||
75 | int ret = 0; | ||
76 | struct snd_soc_dapm_context *dapm = w->dapm; | ||
77 | struct snd_soc_card *card = dapm->card; | ||
78 | struct snd_soc_dai *codec_dai; | ||
79 | |||
80 | codec_dai = bxt_get_codec_dai(card); | ||
81 | if (!codec_dai) { | ||
82 | dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); | ||
83 | return -EIO; | ||
84 | } | ||
85 | |||
86 | if (SND_SOC_DAPM_EVENT_OFF(event)) { | ||
87 | ret = snd_soc_dai_set_pll(codec_dai, 0, | ||
88 | DA7219_SYSCLK_MCLK, 0, 0); | ||
89 | if (ret) | ||
90 | dev_err(card->dev, "failed to stop PLL: %d\n", ret); | ||
91 | } else if(SND_SOC_DAPM_EVENT_ON(event)) { | ||
92 | ret = snd_soc_dai_set_sysclk(codec_dai, | ||
93 | DA7219_CLKSRC_MCLK, 19200000, SND_SOC_CLOCK_IN); | ||
94 | if (ret) | ||
95 | dev_err(card->dev, "can't set codec sysclk configuration\n"); | ||
96 | |||
97 | ret = snd_soc_dai_set_pll(codec_dai, 0, | ||
98 | DA7219_SYSCLK_PLL_SRM, 0, DA7219_PLL_FREQ_OUT_98304); | ||
99 | if (ret) | ||
100 | dev_err(card->dev, "failed to start PLL: %d\n", ret); | ||
101 | } | ||
102 | |||
103 | return ret; | ||
104 | } | ||
105 | |||
58 | static const struct snd_kcontrol_new broxton_controls[] = { | 106 | static const struct snd_kcontrol_new broxton_controls[] = { |
59 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), | 107 | SOC_DAPM_PIN_SWITCH("Headphone Jack"), |
60 | SOC_DAPM_PIN_SWITCH("Headset Mic"), | 108 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
@@ -69,6 +117,8 @@ static const struct snd_soc_dapm_widget broxton_widgets[] = { | |||
69 | SND_SOC_DAPM_SPK("HDMI1", NULL), | 117 | SND_SOC_DAPM_SPK("HDMI1", NULL), |
70 | SND_SOC_DAPM_SPK("HDMI2", NULL), | 118 | SND_SOC_DAPM_SPK("HDMI2", NULL), |
71 | SND_SOC_DAPM_SPK("HDMI3", NULL), | 119 | SND_SOC_DAPM_SPK("HDMI3", NULL), |
120 | SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, | ||
121 | platform_clock_control, SND_SOC_DAPM_POST_PMD|SND_SOC_DAPM_PRE_PMU), | ||
72 | }; | 122 | }; |
73 | 123 | ||
74 | static const struct snd_soc_dapm_route broxton_map[] = { | 124 | static const struct snd_soc_dapm_route broxton_map[] = { |
@@ -109,6 +159,9 @@ static const struct snd_soc_dapm_route broxton_map[] = { | |||
109 | /* DMIC */ | 159 | /* DMIC */ |
110 | {"dmic01_hifi", NULL, "DMIC01 Rx"}, | 160 | {"dmic01_hifi", NULL, "DMIC01 Rx"}, |
111 | {"DMIC01 Rx", NULL, "DMIC AIF"}, | 161 | {"DMIC01 Rx", NULL, "DMIC AIF"}, |
162 | |||
163 | { "Headphone Jack", NULL, "Platform Clock" }, | ||
164 | { "Headset Mic", NULL, "Platform Clock" }, | ||
112 | }; | 165 | }; |
113 | 166 | ||
114 | static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd, | 167 | static int broxton_ssp_fixup(struct snd_soc_pcm_runtime *rtd, |
@@ -243,49 +296,6 @@ static const struct snd_soc_ops broxton_da7219_fe_ops = { | |||
243 | .startup = bxt_fe_startup, | 296 | .startup = bxt_fe_startup, |
244 | }; | 297 | }; |
245 | 298 | ||
246 | static int broxton_da7219_hw_params(struct snd_pcm_substream *substream, | ||
247 | struct snd_pcm_hw_params *params) | ||
248 | { | ||
249 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
250 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
251 | int ret; | ||
252 | |||
253 | ret = snd_soc_dai_set_sysclk(codec_dai, | ||
254 | DA7219_CLKSRC_MCLK, 19200000, SND_SOC_CLOCK_IN); | ||
255 | if (ret < 0) | ||
256 | dev_err(codec_dai->dev, "can't set codec sysclk configuration\n"); | ||
257 | |||
258 | ret = snd_soc_dai_set_pll(codec_dai, 0, | ||
259 | DA7219_SYSCLK_PLL_SRM, 0, DA7219_PLL_FREQ_OUT_98304); | ||
260 | if (ret < 0) { | ||
261 | dev_err(codec_dai->dev, "failed to start PLL: %d\n", ret); | ||
262 | return -EIO; | ||
263 | } | ||
264 | |||
265 | return ret; | ||
266 | } | ||
267 | |||
268 | static int broxton_da7219_hw_free(struct snd_pcm_substream *substream) | ||
269 | { | ||
270 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
271 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
272 | int ret; | ||
273 | |||
274 | ret = snd_soc_dai_set_pll(codec_dai, 0, | ||
275 | DA7219_SYSCLK_MCLK, 0, 0); | ||
276 | if (ret < 0) { | ||
277 | dev_err(codec_dai->dev, "failed to stop PLL: %d\n", ret); | ||
278 | return -EIO; | ||
279 | } | ||
280 | |||
281 | return ret; | ||
282 | } | ||
283 | |||
284 | static const struct snd_soc_ops broxton_da7219_ops = { | ||
285 | .hw_params = broxton_da7219_hw_params, | ||
286 | .hw_free = broxton_da7219_hw_free, | ||
287 | }; | ||
288 | |||
289 | static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd, | 299 | static int broxton_dmic_fixup(struct snd_soc_pcm_runtime *rtd, |
290 | struct snd_pcm_hw_params *params) | 300 | struct snd_pcm_hw_params *params) |
291 | { | 301 | { |
@@ -467,7 +477,6 @@ static struct snd_soc_dai_link broxton_dais[] = { | |||
467 | SND_SOC_DAIFMT_CBS_CFS, | 477 | SND_SOC_DAIFMT_CBS_CFS, |
468 | .ignore_pmdown_time = 1, | 478 | .ignore_pmdown_time = 1, |
469 | .be_hw_params_fixup = broxton_ssp_fixup, | 479 | .be_hw_params_fixup = broxton_ssp_fixup, |
470 | .ops = &broxton_da7219_ops, | ||
471 | .dpcm_playback = 1, | 480 | .dpcm_playback = 1, |
472 | .dpcm_capture = 1, | 481 | .dpcm_capture = 1, |
473 | }, | 482 | }, |