diff options
author | Jeffy Chen <jeffy.chen@rock-chips.com> | 2017-08-24 00:52:26 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-08-29 15:12:01 -0400 |
commit | 626d84db64d746f63eadf5e241fc2211419e11b8 (patch) | |
tree | f23a457381dccf653543bcc9e2b60bab0b662185 | |
parent | 3313faf1053ee6cb90045f6877f11e2f61ead63a (diff) |
ASoC: rockchip: Add support for DMIC codec
Add support for optional dmic codec.
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/rockchip/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/rockchip/rk3399_gru_sound.c | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index 8f0d0d8d34e6..b0825370d262 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig | |||
@@ -69,6 +69,7 @@ config SND_SOC_RK3399_GRU_SOUND | |||
69 | select SND_SOC_DA7219 | 69 | select SND_SOC_DA7219 |
70 | select SND_SOC_RT5514_SPI | 70 | select SND_SOC_RT5514_SPI |
71 | select SND_SOC_HDMI_CODEC | 71 | select SND_SOC_HDMI_CODEC |
72 | select SND_SOC_DMIC | ||
72 | help | 73 | help |
73 | Say Y or M here if you want to add support multiple codecs for SoC | 74 | Say Y or M here if you want to add support multiple codecs for SoC |
74 | audio on Rockchip RK3399 GRU boards. | 75 | audio on Rockchip RK3399 GRU boards. |
diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 91aab5c18f3b..5ab25962cabd 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c | |||
@@ -267,6 +267,28 @@ static int rockchip_sound_cdndp_hw_params(struct snd_pcm_substream *substream, | |||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int rockchip_sound_dmic_hw_params(struct snd_pcm_substream *substream, | ||
271 | struct snd_pcm_hw_params *params) | ||
272 | { | ||
273 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
274 | unsigned int mclk; | ||
275 | int ret; | ||
276 | |||
277 | mclk = params_rate(params) * SOUND_FS; | ||
278 | |||
279 | ret = snd_soc_dai_set_sysclk(rtd->cpu_dai, 0, mclk, 0); | ||
280 | if (ret) { | ||
281 | dev_err(rtd->card->dev, "%s() error setting sysclk to %u: %d\n", | ||
282 | __func__, mclk, ret); | ||
283 | return ret; | ||
284 | } | ||
285 | |||
286 | /* Wait for DMIC stable */ | ||
287 | msleep(dmic_wakeup_delay); | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
270 | static const struct snd_soc_ops rockchip_sound_max98357a_ops = { | 292 | static const struct snd_soc_ops rockchip_sound_max98357a_ops = { |
271 | .hw_params = rockchip_sound_max98357a_hw_params, | 293 | .hw_params = rockchip_sound_max98357a_hw_params, |
272 | }; | 294 | }; |
@@ -283,6 +305,10 @@ static struct snd_soc_ops rockchip_sound_cdndp_ops = { | |||
283 | .hw_params = rockchip_sound_cdndp_hw_params, | 305 | .hw_params = rockchip_sound_cdndp_hw_params, |
284 | }; | 306 | }; |
285 | 307 | ||
308 | static struct snd_soc_ops rockchip_sound_dmic_ops = { | ||
309 | .hw_params = rockchip_sound_dmic_hw_params, | ||
310 | }; | ||
311 | |||
286 | static struct snd_soc_card rockchip_sound_card = { | 312 | static struct snd_soc_card rockchip_sound_card = { |
287 | .name = "rk3399-gru-sound", | 313 | .name = "rk3399-gru-sound", |
288 | .owner = THIS_MODULE, | 314 | .owner = THIS_MODULE, |
@@ -297,6 +323,7 @@ static struct snd_soc_card rockchip_sound_card = { | |||
297 | enum { | 323 | enum { |
298 | DAILINK_CDNDP, | 324 | DAILINK_CDNDP, |
299 | DAILINK_DA7219, | 325 | DAILINK_DA7219, |
326 | DAILINK_DMIC, | ||
300 | DAILINK_MAX98357A, | 327 | DAILINK_MAX98357A, |
301 | DAILINK_RT5514, | 328 | DAILINK_RT5514, |
302 | DAILINK_RT5514_DSP, | 329 | DAILINK_RT5514_DSP, |
@@ -305,6 +332,7 @@ enum { | |||
305 | static const char * const dailink_compat[] = { | 332 | static const char * const dailink_compat[] = { |
306 | [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", | 333 | [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", |
307 | [DAILINK_DA7219] = "dlg,da7219", | 334 | [DAILINK_DA7219] = "dlg,da7219", |
335 | [DAILINK_DMIC] = "dmic-codec", | ||
308 | [DAILINK_MAX98357A] = "maxim,max98357a", | 336 | [DAILINK_MAX98357A] = "maxim,max98357a", |
309 | [DAILINK_RT5514] = "realtek,rt5514-i2c", | 337 | [DAILINK_RT5514] = "realtek,rt5514-i2c", |
310 | [DAILINK_RT5514_DSP] = "realtek,rt5514-spi", | 338 | [DAILINK_RT5514_DSP] = "realtek,rt5514-spi", |
@@ -329,6 +357,14 @@ static const struct snd_soc_dai_link rockchip_dais[] = { | |||
329 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | 357 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
330 | SND_SOC_DAIFMT_CBS_CFS, | 358 | SND_SOC_DAIFMT_CBS_CFS, |
331 | }, | 359 | }, |
360 | [DAILINK_DMIC] = { | ||
361 | .name = "DMIC", | ||
362 | .stream_name = "DMIC PCM", | ||
363 | .codec_dai_name = "dmic-hifi", | ||
364 | .ops = &rockchip_sound_dmic_ops, | ||
365 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
366 | SND_SOC_DAIFMT_CBS_CFS, | ||
367 | }, | ||
332 | [DAILINK_MAX98357A] = { | 368 | [DAILINK_MAX98357A] = { |
333 | .name = "MAX98357A", | 369 | .name = "MAX98357A", |
334 | .stream_name = "MAX98357A PCM", | 370 | .stream_name = "MAX98357A PCM", |