Skip to content

Commit

Permalink
ASoC: Fix Zylonite for non-networked SSP mode
Browse files Browse the repository at this point in the history
This also simplifies the code a bit.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Mar 14, 2009
1 parent 0ce36c5 commit 85fab78
Showing 1 changed file with 25 additions and 30 deletions.
55 changes: 25 additions & 30 deletions sound/soc/pxa/zylonite.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,57 +96,42 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
unsigned int pll_out = 0;
unsigned int acds = 0;
unsigned int wm9713_div = 0;
int ret = 0;

switch (params_rate(params)) {
int rate = params_rate(params);
int width = snd_pcm_format_physical_width(params_format(params));

/* Only support ratios that we can generate neatly from the AC97
* based master clock - in particular, this excludes 44.1kHz.
* In most applications the voice DAC will be used for telephony
* data so multiples of 8kHz will be the common case.
*/
switch (rate) {
case 8000:
wm9713_div = 12;
pll_out = 2048000;
break;
case 16000:
wm9713_div = 6;
pll_out = 4096000;
break;
case 48000:
default:
wm9713_div = 2;
pll_out = 12288000;
acds = 1;
break;
default:
/* Don't support OSS emulation */
return -EINVAL;
}

ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;

ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;
/* Add 1 to the width for the leading clock cycle */
pll_out = rate * (width + 1) * 8;

/* Use network mode for stereo, one slot per channel. */
if (params_channels(params) > 1)
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0x3, 2);
else
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 1, 1);
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1);
if (ret < 0)
return ret;

ret = snd_soc_dai_set_pll(cpu_dai, 0, 0, pll_out);
if (ret < 0)
return ret;

ret = snd_soc_dai_set_clkdiv(cpu_dai, PXA_SSP_AUDIO_DIV_ACDS, acds);
if (ret < 0)
return ret;

ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_AUDIO, 0, 1);
if (ret < 0)
return ret;

if (clk_pout)
ret = snd_soc_dai_set_clkdiv(codec_dai, WM9713_PCMCLK_PLL_DIV,
WM9713_PCMDIV(wm9713_div));
Expand All @@ -156,6 +141,16 @@ static int zylonite_voice_hw_params(struct snd_pcm_substream *substream,
if (ret < 0)
return ret;

ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;

ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;

return 0;
}

Expand Down

0 comments on commit 85fab78

Please sign in to comment.