diff options
author | Jeffy Chen <jeffy.chen@rock-chips.com> | 2017-08-24 00:52:25 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-08-29 15:09:46 -0400 |
commit | 3313faf1053ee6cb90045f6877f11e2f61ead63a (patch) | |
tree | 60e6b4ed09a26630899dd6940e757ed8f718ec8b | |
parent | 0d52954ffe80b051ab79a105bd801485c4bbe20a (diff) |
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>
-rw-r--r-- | sound/soc/rockchip/Kconfig | 1 | ||||
-rw-r--r-- | sound/soc/rockchip/rk3399_gru_sound.c | 59 |
2 files changed, 58 insertions, 2 deletions
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index c84487805876..8f0d0d8d34e6 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig | |||
@@ -68,6 +68,7 @@ config SND_SOC_RK3399_GRU_SOUND | |||
68 | select SND_SOC_RT5514 | 68 | select SND_SOC_RT5514 |
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 | help | 72 | help |
72 | Say Y or M here if you want to add support multiple codecs for SoC | 73 | Say Y or M here if you want to add support multiple codecs for SoC |
73 | audio on Rockchip RK3399 GRU boards. | 74 | 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 347c34d0db4c..91aab5c18f3b 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c | |||
@@ -228,6 +228,45 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) | |||
228 | return 0; | 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 | static const struct snd_soc_ops rockchip_sound_max98357a_ops = { | 270 | static const struct snd_soc_ops rockchip_sound_max98357a_ops = { |
232 | .hw_params = rockchip_sound_max98357a_hw_params, | 271 | .hw_params = rockchip_sound_max98357a_hw_params, |
233 | }; | 272 | }; |
@@ -240,6 +279,10 @@ static const struct snd_soc_ops rockchip_sound_da7219_ops = { | |||
240 | .hw_params = rockchip_sound_da7219_hw_params, | 279 | .hw_params = rockchip_sound_da7219_hw_params, |
241 | }; | 280 | }; |
242 | 281 | ||
282 | static struct snd_soc_ops rockchip_sound_cdndp_ops = { | ||
283 | .hw_params = rockchip_sound_cdndp_hw_params, | ||
284 | }; | ||
285 | |||
243 | static struct snd_soc_card rockchip_sound_card = { | 286 | static struct snd_soc_card rockchip_sound_card = { |
244 | .name = "rk3399-gru-sound", | 287 | .name = "rk3399-gru-sound", |
245 | .owner = THIS_MODULE, | 288 | .owner = THIS_MODULE, |
@@ -252,6 +295,7 @@ static struct snd_soc_card rockchip_sound_card = { | |||
252 | }; | 295 | }; |
253 | 296 | ||
254 | enum { | 297 | enum { |
298 | DAILINK_CDNDP, | ||
255 | DAILINK_DA7219, | 299 | DAILINK_DA7219, |
256 | DAILINK_MAX98357A, | 300 | DAILINK_MAX98357A, |
257 | DAILINK_RT5514, | 301 | DAILINK_RT5514, |
@@ -259,6 +303,7 @@ enum { | |||
259 | }; | 303 | }; |
260 | 304 | ||
261 | static const char * const dailink_compat[] = { | 305 | static const char * const dailink_compat[] = { |
306 | [DAILINK_CDNDP] = "rockchip,rk3399-cdn-dp", | ||
262 | [DAILINK_DA7219] = "dlg,da7219", | 307 | [DAILINK_DA7219] = "dlg,da7219", |
263 | [DAILINK_MAX98357A] = "maxim,max98357a", | 308 | [DAILINK_MAX98357A] = "maxim,max98357a", |
264 | [DAILINK_RT5514] = "realtek,rt5514-i2c", | 309 | [DAILINK_RT5514] = "realtek,rt5514-i2c", |
@@ -266,6 +311,14 @@ static const char * const dailink_compat[] = { | |||
266 | }; | 311 | }; |
267 | 312 | ||
268 | static const struct snd_soc_dai_link rockchip_dais[] = { | 313 | static const struct snd_soc_dai_link rockchip_dais[] = { |
314 | [DAILINK_CDNDP] = { | ||
315 | .name = "DP", | ||
316 | .stream_name = "DP PCM", | ||
317 | .codec_dai_name = "i2s-hifi", | ||
318 | .ops = &rockchip_sound_cdndp_ops, | ||
319 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
320 | SND_SOC_DAIFMT_CBS_CFS, | ||
321 | }, | ||
269 | [DAILINK_DA7219] = { | 322 | [DAILINK_DA7219] = { |
270 | .name = "DA7219", | 323 | .name = "DA7219", |
271 | .stream_name = "DA7219 PCM", | 324 | .stream_name = "DA7219 PCM", |
@@ -316,7 +369,7 @@ static int rockchip_sound_codec_node_match(struct device_node *np_codec) | |||
316 | static int rockchip_sound_of_parse_dais(struct device *dev, | 369 | static int rockchip_sound_of_parse_dais(struct device *dev, |
317 | struct snd_soc_card *card) | 370 | struct snd_soc_card *card) |
318 | { | 371 | { |
319 | struct device_node *np_cpu; | 372 | struct device_node *np_cpu, *np_cpu0, *np_cpu1; |
320 | struct device_node *np_codec; | 373 | struct device_node *np_codec; |
321 | struct snd_soc_dai_link *dai; | 374 | struct snd_soc_dai_link *dai; |
322 | int i, index; | 375 | int i, index; |
@@ -326,7 +379,8 @@ static int rockchip_sound_of_parse_dais(struct device *dev, | |||
326 | if (!card->dai_link) | 379 | if (!card->dai_link) |
327 | return -ENOMEM; | 380 | return -ENOMEM; |
328 | 381 | ||
329 | np_cpu = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); | 382 | np_cpu0 = of_parse_phandle(dev->of_node, "rockchip,cpu", 0); |
383 | np_cpu1 = of_parse_phandle(dev->of_node, "rockchip,cpu", 1); | ||
330 | 384 | ||
331 | card->num_links = 0; | 385 | card->num_links = 0; |
332 | for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { | 386 | for (i = 0; i < ARRAY_SIZE(rockchip_dais); i++) { |
@@ -342,6 +396,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev, | |||
342 | if (index < 0) | 396 | if (index < 0) |
343 | continue; | 397 | continue; |
344 | 398 | ||
399 | np_cpu = (index == DAILINK_CDNDP) ? np_cpu1 : np_cpu0; | ||
345 | if (!np_cpu) { | 400 | if (!np_cpu) { |
346 | dev_err(dev, "Missing 'rockchip,cpu' for %s\n", | 401 | dev_err(dev, "Missing 'rockchip,cpu' for %s\n", |
347 | rockchip_dais[index].name); | 402 | rockchip_dais[index].name); |