Skip to content

Commit

Permalink
ASoC: davinci-mcasp: Allow best effort in selecting BCLK divider
Browse files Browse the repository at this point in the history
Do not fail if the exact BLCK rate can not be produced, just print a
warning. Check that sysclk frequency is set before implicitly setting
the BCLK divider.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Jyri Sarha authored and Mark Brown committed Jun 21, 2014
1 parent 6479285 commit 0929878
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sound/soc/davinci/davinci-mcasp.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,18 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
int ret;

/* If mcasp is BCLK master we need to set BCLK divider */
if (mcasp->bclk_master) {
if (mcasp->bclk_master && mcasp->sysclk_freq) {
unsigned int bclk_freq = snd_soc_params_to_bclk(params);
unsigned int div = mcasp->sysclk_freq / bclk_freq;
if (mcasp->sysclk_freq % bclk_freq != 0) {
dev_err(mcasp->dev, "Can't produce required BCLK\n");
return -EINVAL;
if (((mcasp->sysclk_freq / div) - bclk_freq) >
(bclk_freq - (mcasp->sysclk_freq / (div+1))))
div++;
dev_warn(mcasp->dev,
"Inaccurate BCLK: %u Hz / %u != %u Hz\n",
mcasp->sysclk_freq, div, bclk_freq);
}
davinci_mcasp_set_clkdiv(
cpu_dai, 1, mcasp->sysclk_freq / bclk_freq);
davinci_mcasp_set_clkdiv(cpu_dai, 1, div);
}

ret = mcasp_common_hw_param(mcasp, substream->stream,
Expand Down

0 comments on commit 0929878

Please sign in to comment.