Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jeffy Chen and committed by
Mark Brown
626d84db 3313faf1

+37
+1
sound/soc/rockchip/Kconfig
··· 69 69 select SND_SOC_DA7219 70 70 select SND_SOC_RT5514_SPI 71 71 select SND_SOC_HDMI_CODEC 72 + select SND_SOC_DMIC 72 73 help 73 74 Say Y or M here if you want to add support multiple codecs for SoC 74 75 audio on Rockchip RK3399 GRU boards.
+36
sound/soc/rockchip/rk3399_gru_sound.c
··· 267 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 292 static const struct snd_soc_ops rockchip_sound_max98357a_ops = { 271 293 .hw_params = rockchip_sound_max98357a_hw_params, 272 294 }; ··· 305 283 .hw_params = rockchip_sound_cdndp_hw_params, 306 284 }; 307 285 286 + static struct snd_soc_ops rockchip_sound_dmic_ops = { 287 + .hw_params = rockchip_sound_dmic_hw_params, 288 + }; 289 + 308 290 static struct snd_soc_card rockchip_sound_card = { 309 291 .name = "rk3399-gru-sound", 310 292 .owner = THIS_MODULE, ··· 323 297 enum { 324 298 DAILINK_CDNDP, 325 299 DAILINK_DA7219, 300 + DAILINK_DMIC, 326 301 DAILINK_MAX98357A, 327 302 DAILINK_RT5514, 328 303 DAILINK_RT5514_DSP, ··· 332 305 static const char * const dailink_compat[] = { 333 306 [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", 334 307 [DAILINK_DA7219] = "dlg,da7219", 308 + [DAILINK_DMIC] = "dmic-codec", 335 309 [DAILINK_MAX98357A] = "maxim,max98357a", 336 310 [DAILINK_RT5514] = "realtek,rt5514-i2c", 337 311 [DAILINK_RT5514_DSP] = "realtek,rt5514-spi", ··· 354 326 .init = rockchip_sound_da7219_init, 355 327 .ops = &rockchip_sound_da7219_ops, 356 328 /* set da7219 as slave */ 329 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 330 + SND_SOC_DAIFMT_CBS_CFS, 331 + }, 332 + [DAILINK_DMIC] = { 333 + .name = "DMIC", 334 + .stream_name = "DMIC PCM", 335 + .codec_dai_name = "dmic-hifi", 336 + .ops = &rockchip_sound_dmic_ops, 357 337 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 358 338 SND_SOC_DAIFMT_CBS_CFS, 359 339 },