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

ASoC: rockchip: Add support for DP codec

Add support for optional cdn dp 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
3313faf1 0d52954f

+58 -2
+1
sound/soc/rockchip/Kconfig
··· 68 68 select SND_SOC_RT5514 69 69 select SND_SOC_DA7219 70 70 select SND_SOC_RT5514_SPI 71 + select SND_SOC_HDMI_CODEC 71 72 help 72 73 Say Y or M here if you want to add support multiple codecs for SoC 73 74 audio on Rockchip RK3399 GRU boards.
+57 -2
sound/soc/rockchip/rk3399_gru_sound.c
··· 228 228 return 0; 229 229 } 230 230 231 + static int rockchip_sound_cdndp_hw_params(struct snd_pcm_substream *substream, 232 + struct snd_pcm_hw_params *params) 233 + { 234 + struct snd_soc_pcm_runtime *rtd = substream->private_data; 235 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 236 + struct snd_soc_dai *codec_dai = rtd->codec_dai; 237 + int mclk, ret; 238 + 239 + /* in bypass mode, the mclk has to be one of the frequencies below */ 240 + switch (params_rate(params)) { 241 + case 8000: 242 + case 16000: 243 + case 24000: 244 + case 32000: 245 + case 48000: 246 + case 64000: 247 + case 96000: 248 + mclk = 12288000; 249 + break; 250 + case 11025: 251 + case 22050: 252 + case 44100: 253 + case 88200: 254 + mclk = 11289600; 255 + break; 256 + default: 257 + return -EINVAL; 258 + } 259 + 260 + ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, 261 + SND_SOC_CLOCK_OUT); 262 + if (ret < 0) { 263 + dev_err(codec_dai->dev, "Can't set cpu clock out %d\n", ret); 264 + return ret; 265 + } 266 + 267 + return 0; 268 + } 269 + 231 270 static const struct snd_soc_ops rockchip_sound_max98357a_ops = { 232 271 .hw_params = rockchip_sound_max98357a_hw_params, 233 272 }; ··· 277 238 278 239 static const struct snd_soc_ops rockchip_sound_da7219_ops = { 279 240 .hw_params = rockchip_sound_da7219_hw_params, 241 + }; 242 + 243 + static struct snd_soc_ops rockchip_sound_cdndp_ops = { 244 + .hw_params = rockchip_sound_cdndp_hw_params, 280 245 }; 281 246 282 247 static struct snd_soc_card rockchip_sound_card = { ··· 295 252 }; 296 253 297 254 enum { 255 + DAILINK_CDNDP, 298 256 DAILINK_DA7219, 299 257 DAILINK_MAX98357A, 300 258 DAILINK_RT5514, ··· 303 259 }; 304 260 305 261 static const char * const dailink_compat[] = { 262 + [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", 306 263 [DAILINK_DA7219] = "dlg,da7219", 307 264 [DAILINK_MAX98357A] = "maxim,max98357a", 308 265 [DAILINK_RT5514] = "realtek,rt5514-i2c", ··· 311 266 }; 312 267 313 268 static const struct snd_soc_dai_link rockchip_dais[] = { 269 + [DAILINK_CDNDP] = { 270 + .name = "DP", 271 + .stream_name = "DP PCM", 272 + .codec_dai_name = "i2s-hifi", 273 + .ops = &rockchip_sound_cdndp_ops, 274 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 275 + SND_SOC_DAIFMT_CBS_CFS, 276 + }, 314 277 [DAILINK_DA7219] = { 315 278 .name = "DA7219", 316 279 .stream_name = "DA7219 PCM", ··· 369 316 static int rockchip_sound_of_parse_dais(struct device *dev, 370 317 struct snd_soc_card *card) 371 318 { 372 - struct device_node *np_cpu; 319 + struct device_node *np_cpu, *np_cpu0, *np_cpu1; 373 320 struct device_node *np_codec; 374 321 struct snd_soc_dai_link *dai; 375 322 int i, index; ··· 379 326 if (!card->dai_link) 380 327 return -ENOMEM; 381 328 382 - np_cpu = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); 329 + np_cpu0 = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); 330 + np_cpu1 = of_parse_phandle(dev->of_node, "rockchip,cpu", 1); 383 331 384 332 card->num_links = 0; 385 333 for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { ··· 396 342 if (index < 0) 397 343 continue; 398 344 345 + np_cpu = (index == DAILINK_CDNDP) ? np_cpu1 : np_cpu0; 399 346 if (!np_cpu) { 400 347 dev_err(dev, "Missing 'rockchip,cpu' for %s\n", 401 348 rockchip_dais[index].name);