aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>2016-08-12 17:27:52 -0400
committerMark Brown <broonie@kernel.org>2016-08-15 10:14:57 -0400
commit038a50e735c85a7a9fbcda090785a588443ffa26 (patch)
treed6141445958ca97f8cf80de2fef3112bfa5b5119
parentf47088d5ae6bec6d01bb0fd71c7d113aa8eaaa27 (diff)
ASoC: Intel: bytcr_rt5640: fix dai/clock setup for SSP0 routing
SSP0 uses 16 bits 2ch, SSP2 24 bits 2ch Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/intel/boards/bytcr_rt5640.c92
1 files changed, 64 insertions, 28 deletions
diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
index 4337b5e85921..42c7bd20f54d 100644
--- a/sound/soc/intel/boards/bytcr_rt5640.c
+++ b/sound/soc/intel/boards/bytcr_rt5640.c
@@ -138,8 +138,6 @@ static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
138 struct snd_soc_dai *codec_dai = rtd->codec_dai; 138 struct snd_soc_dai *codec_dai = rtd->codec_dai;
139 int ret; 139 int ret;
140 140
141 snd_soc_dai_set_bclk_ratio(codec_dai, 50);
142
143 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1, 141 ret = snd_soc_dai_set_sysclk(codec_dai, RT5640_SCLK_S_PLL1,
144 params_rate(params) * 512, 142 params_rate(params) * 512,
145 SND_SOC_CLOCK_IN); 143 SND_SOC_CLOCK_IN);
@@ -148,9 +146,18 @@ static int byt_rt5640_aif1_hw_params(struct snd_pcm_substream *substream,
148 return ret; 146 return ret;
149 } 147 }
150 148
151 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_BCLK1, 149 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
152 params_rate(params) * 50, 150 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
153 params_rate(params) * 512); 151
152 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_BCLK1,
153 params_rate(params) * 32, /* FIXME */
154 params_rate(params) * 512);
155 } else {
156 ret = snd_soc_dai_set_pll(codec_dai, 0, RT5640_PLL1_S_BCLK1,
157 params_rate(params) * 50,
158 params_rate(params) * 512);
159 }
160
154 if (ret < 0) { 161 if (ret < 0) {
155 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); 162 dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
156 return ret; 163 return ret;
@@ -311,34 +318,63 @@ static int byt_rt5640_codec_fixup(struct snd_soc_pcm_runtime *rtd,
311 SNDRV_PCM_HW_PARAM_CHANNELS); 318 SNDRV_PCM_HW_PARAM_CHANNELS);
312 int ret; 319 int ret;
313 320
314 /* The DSP will covert the FE rate to 48k, stereo, 24bits */ 321 /* The DSP will covert the FE rate to 48k, stereo */
315 rate->min = rate->max = 48000; 322 rate->min = rate->max = 48000;
316 channels->min = channels->max = 2; 323 channels->min = channels->max = 2;
317 324
318 /* set SSP2 to 24-bit */ 325 if ((byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) ||
319 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); 326 (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF2)) {
320 327
321 /* 328 /* set SSP2 to 16-bit */
322 * Default mode for SSP configuration is TDM 4 slot, override config 329 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
323 * with explicit setting to I2S 2ch 24-bit. The word length is set with 330
324 * dai_set_tdm_slot() since there is no other API exposed 331 /*
325 */ 332 * Default mode for SSP configuration is TDM 4 slot, override config
326 ret = snd_soc_dai_set_fmt(rtd->cpu_dai, 333 * with explicit setting to I2S 2ch 16-bit. The word length is set with
327 SND_SOC_DAIFMT_I2S | 334 * dai_set_tdm_slot() since there is no other API exposed
328 SND_SOC_DAIFMT_NB_IF | 335 */
329 SND_SOC_DAIFMT_CBS_CFS 336 ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
330 ); 337 SND_SOC_DAIFMT_I2S |
331 if (ret < 0) { 338 SND_SOC_DAIFMT_NB_IF |
332 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); 339 SND_SOC_DAIFMT_CBS_CFS
333 return ret; 340 );
334 } 341 if (ret < 0) {
342 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
343 return ret;
344 }
335 345
336 ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); 346 ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 16);
337 if (ret < 0) { 347 if (ret < 0) {
338 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); 348 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
339 return ret; 349 return ret;
340 } 350 }
351
352 } else {
341 353
354 /* set SSP2 to 24-bit */
355 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
356
357 /*
358 * Default mode for SSP configuration is TDM 4 slot, override config
359 * with explicit setting to I2S 2ch 24-bit. The word length is set with
360 * dai_set_tdm_slot() since there is no other API exposed
361 */
362 ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
363 SND_SOC_DAIFMT_I2S |
364 SND_SOC_DAIFMT_NB_IF |
365 SND_SOC_DAIFMT_CBS_CFS
366 );
367 if (ret < 0) {
368 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
369 return ret;
370 }
371
372 ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24);
373 if (ret < 0) {
374 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
375 return ret;
376 }
377 }
342 return 0; 378 return 0;
343} 379}
344 380